示例#1
0
文件: main.c 项目: digideskio/afdko
/* Main program */
int main(int argc, char *argv[]) {
	dnaCtx mainDnaCtx = NULL;
	long value;

	/* Extract program name */
	progname = strrchr(argv[0], '/');
	if (progname == NULL) {
		progname = strrchr(argv[0], '\\');
	}
	progname = (progname == NULL) ? argv[0] : progname + 1;
	argc--;
	argv++;
	value = setjmp(mark);
	if (value == -1) {
		return 1;
	}


	/* Initialize */
	cb_dna_memcb.ctx = mainDnaCtx;
	cb_dna_memcb.manage = cb_manage;
	mainDnaCtx = dnaNew(&cb_dna_memcb, DNA_CHECK_ARGS);

	cbctx = cbNew(progname, convert.dir.pfb,
				  convert.dir.otf, convert.dir.cmap, convert.dir.feat, mainDnaCtx);

	script.buf = NULL;
	dnaINIT(mainDnaCtx, script.args, 100, 500);

	convert.dir.pfb[0] = '\0';
	convert.dir.otf[0] = '\0';
	convert.dir.cmap[0] = '\0';
	convert.dir.feat[0] = '\0';
	convert.features = NULL;
	convert.hCMap = NULL;
	convert.vCMap = NULL;
	convert.flags = 0;
	convert.otherflags = 0;
	convert.os2_version = 0;
	convert.fsSelectionMask_on = -1;
	convert.fsSelectionMask_off = -1;

	/* Process args. Call convFont at end. */
	parseArgs(argc, argv, 0);

	fprintf(stderr, "\n");			/* Terminate progress line */

	/* Clean up */
	cbMemFree(cbctx, script.buf);
	dnaFREE(script.args);
	cbFree(cbctx);

	return 0;
}
示例#2
0
/* Validate client and create context. */
ufwCtx ufwNew(ctlMemoryCallbacks *mem_cb, ctlStreamCallbacks *stm_cb,
              CTL_CHECK_ARGS_DCL) {
    ufwCtx h;

    /* Check client/library compatibility */
    if (CTL_CHECK_ARGS_TEST(UFW_VERSION))
        return NULL;

    /* Allocate context */
    h = mem_cb->manage(mem_cb, NULL, sizeof(struct ufwCtx_));
    if (h == NULL)
        return NULL;

    /* Safety initialization */
    h->state = 0;
    h->top = NULL;
    h->glyphs.size = 0;
    h->path.opList.size = 0;

    h->dna = NULL;
    h->stm.dst = NULL;
    h->stm.dbg = NULL;
    h->err.code = ufwSuccess;
    h->lastiFD = ABF_UNSET_INT;

    /* Copy callbacks */
    h->cb.mem = *mem_cb;
    h->cb.stm = *stm_cb;

    /* Initialize service library */
    h->dna = dnaNew(&h->cb.mem, DNA_CHECK_ARGS);
    if (h->dna == NULL)
        goto cleanup;

    h->arg.glyphLayer = "glyphs";

    dnaINIT(h->dna, h->glyphs, 256, 750);
    dnaINIT(h->dna, h->path.opList, 256, 750);

    /* Open debug stream */
    h->stm.dbg = h->cb.stm.open(&h->cb.stm, UFW_DBG_STREAM_ID, 0);

    return h;

cleanup:
    /* Initialization failed */
    ufwFree(h);
    return NULL;
}
示例#3
0
/* Create new context */
tcCtx tcNew(tcCallbacks *cb) {
    tcCtx g = cb->malloc(cb->ctx, sizeof(struct tcCtx_));
    tcprivCtx h;

    g->cb = *cb;

    h = MEM_NEW(g, sizeof(struct tcprivCtx_));

    tc_dna_memcb.ctx = g;
    tc_dna_memcb.manage = tc_manage;
    g->ctx.dnaCtx = dnaNew(&tc_dna_memcb, DNA_CHECK_ARGS);

    dnaINIT(g->ctx.dnaCtx, h->set, 4, 120);
    h->set.func = fontInit;

    initSet(g, h);

    /* Initialize other library modules */
    g->ctx.sindex = NULL;
    g->ctx.fdselect = NULL;
    g->ctx.subr = NULL;
    g->ctx.cs = NULL;
    g->ctx.encoding = NULL;
    g->ctx.charset = NULL;
    g->ctx.recode = NULL;
    g->ctx.parse = NULL;
    g->ctx.tcpriv = NULL;
    g->ctx.t13 = NULL;

    sindexNew(g);
    encodingNew(g);
    charsetNew(g);
    parseNew(g);
    csNew(g);
    recodeNew(g);
#if TC_SUBR_SUPPORT
    subrNew(g);
#endif /* TC_SUBR_SUPPORT */
    fdselectNew(g);
    t13New(g);

    /* Link contexts */
    h->g = g;
    g->ctx.tcpriv = h;

    return g;
}