MathEngine engine;
main(int argc, char *argv[]){  sprintf(appName, "MathML to PostScript v%s", MATHML2PS_VERSION);  while (TRUE) {    int option_index = 0;    static struct option long_options[] =    {      { "version", 	 no_argument,       NULL, OPTION_VERSION },      { "help",    	 no_argument,       NULL, OPTION_HELP },      { "verbose",       optional_argument, NULL, OPTION_VERBOSE },      { "size",          required_argument, NULL, OPTION_SIZE },      { "unit",          required_argument, NULL, OPTION_UNIT },      { "margins",       required_argument, NULL, OPTION_MARGINS },      { "font-size",     required_argument, NULL, OPTION_FONT_SIZE },      { "disable-colors",no_argument,       NULL, OPTION_DISABLE_COLORS },      { "config",        required_argument, NULL, OPTION_CONFIG },      { NULL,            no_argument, NULL, 0 }    };    int c = getopt_long(argc, argv, "vhg:u:m:f:", long_options, &option_index);    if (c == -1) break;    switch (c) {    case OPTION_VERSION:    case 'v':      printVersion();      break;    case OPTION_HELP:    case 'h':      printHelp();      break;    case OPTION_SIZE:    case 'g':      if (optarg == NULL) printHelp();      if (!parseSize(optarg)) fprintf(stderr, "error while parsing size\n");      break;    case OPTION_UNIT:    case 'u':      if (optarg == NULL) printHelp();      if (!parseUnit(optarg)) fprintf(stderr, "error while parsing unit\n");      break;    case OPTION_MARGINS:    case 'm':      if (optarg == NULL) printHelp();      if (!parseMargins(optarg)) fprintf(stderr, "error while parsing margins\n");      break;    case OPTION_VERBOSE:      if (optarg == NULL) MathEngine::logger.SetLogLevel(0);      else MathEngine::logger.SetLogLevel(*optarg - '0');      break;    case OPTION_FONT_SIZE:    case 'f':      if (optarg == NULL) printHelp();      fontSize = atof(optarg);      break;    case OPTION_DISABLE_COLORS:      colors = false;      break;    case OPTION_CONFIG:      configPath = optarg;      break;    case '?':      break;    default:      fprintf(stderr, "*** getopt returned %o value\n", c);      break;    }  }  if (configPath == NULL) configPath = getenv("MATHENGINECONF");  MathEngine::logger(LOG_INFO, "Font size : %f", fontSize);  MathEngine::logger(LOG_INFO, "Paper size: %fx%f", width, height);  MathEngine::logger(LOG_INFO, "Margins   : %fx%f", xMargin, yMargin);#ifdef HAVE_LIBT1  if (optind >= argc) {    printHelp();    exit(1);  }    MathEngine::InitGlobalData(configPath);  UnitValue uWidth;  UnitValue uHeight;  UnitValue uXMargin;  UnitValue uYMargin;  uWidth.Set(width, unitId);  uHeight.Set(height, unitId);  uXMargin.Set(xMargin, unitId);  uYMargin.Set(yMargin, unitId);  scaled w = uWidth.ToScaledPoints();  scaled h = uHeight.ToScaledPoints();  scaled x0 = uXMargin.ToScaledPoints();  scaled y0 = uYMargin.ToScaledPoints();  GraphicsContextValues values;  values.foreground = BLACK_COLOR;  values.background = WHITE_COLOR;  values.lineStyle = LINE_STYLE_SOLID;  values.lineWidth = px2sp(1);  while (optind < argc) {    MathEngine::logger(LOG_INFO, "Processing `%s'...", argv[optind]);    char* outName = getOutputFileName(argv[optind]);    assert(outName != NULL);    FILE* outFile = fopen(outName, "wt");    if (outFile == NULL) {      MathEngine::logger(LOG_ERROR, "could not open output file `%s' for writing", outName);      exit(1);    }    PS_T1_FontManager fm;    PS_DrawingArea area(values, x0, y0, outFile);    area.SetSize(w, h);    if (!colors) area.DisableColors();    MathEngine engine;    engine.Init(&area, &fm);    engine.SetDefaultFontSize(fontSize);    engine.Load(argv[optind]);    engine.Layout();    Rectangle rect;    engine.GetDocumentRectangle(rect);    area.DumpHeader(appName, argv[optind], rect);    fm.DumpFontDictionary(outFile);    Rectangle sheet;    sheet.x = 0;    sheet.y = 0;    sheet.width = w;    sheet.height = h;    area.DumpPreamble();    //area.DumpGrid();    engine.Render(&sheet);    area.DumpEpilogue();    fclose(outFile);    delete [] outName;    optind++;  }#else   printHelp();#endif  exit(0);}