Пример #1
0
static int readFile(char * filename)
{
	  Card32 value;

	/* See if we can recognize the file type */
	value = fileSniff();	
	switch (value)
	{
		case bits_:
		case typ1_:		
		case true_:
		case mor0_:
		case OTTO_:
		case VERSION(1,0):
		  sfntRead(0, -1);	/* Read plain sfnt file */
		  sfntDump();
		  sfntFree(1);		  
		  break;
		case ttcf_:
		  sfntTTCRead(0);		/* Read TTC and dump file */
		  break;
		case 256:
		  SEEK_ABS(0); /* Raw resource file as a data fork */ 
		  resRead(0);			/* Read and dump  Macintosh resource file */
		  break;
		case sig_AppleSingle:
		case sig_AppleDouble:
			doASDFormats((ctlTag)value);
			break;
		default:
 			warning(SPOT_MSG_BADFILE, filename);
 			return 1;
		}
	return 0;
}
Пример #2
0
/* Process AppleSingle/Double format data. */
static void doASDFormats(ctlTag magic)
	{
	long junk;
	long i;
	Card16 entryCount = 0;
	struct					/* AppleSingle/Double data */
		{
		unsigned long magic;/* Magic #, 00051600-single, 00051607-double */
		unsigned long version;/* Format version */
		da_DCL(EntryDesc, entries);/* Entry descriptors */
	} asd;

	asd.magic = magic;
	IN1(asd.version);

	/* Skip filler of 16 bytes*/
	IN1(junk);
	IN1(junk);
	IN1(junk);
	IN1(junk);

	/* Read number of entries */
	IN1(entryCount);
	da_INIT(asd.entries, entryCount,10);
	
	/* Read entry descriptors */
	for (i = 0; i < entryCount; i++)
		{
		EntryDesc *entry = da_INDEX(asd.entries,i);
	 	IN1(entry->id);
	 	IN1(entry->offset);
	 	IN1(entry->length);
		}

		for (i = 0; i < entryCount; i++)
			{
			EntryDesc  *entry = da_INDEX(asd.entries,i);
			if (entry->length > 0)
				switch (entry->id)
					{
				case 1:
					/* Data fork (AppleSingle); see if it's an sfnt */
		  			sfntRead(entry->offset + 4, -1);	/* Read plain sfnt file */
					  sfntDump();
					  sfntFree(1);		  
					break;
				case 2:
					/* Resource fork (AppleSingle/Double) */
					fileSeek(entry->offset, 0);
		 			resRead(entry->offset);			/* Read and dump Macintosh resource file */
					break;
					}
			}
	}
Пример #3
0
/* Main program */
IntN main(IntN argc, Byte8 *argv[]) {
    static opt_Option opt[] =
        {
            {"-u", opt_Call, showUsage},
            {"-h", opt_Call, showHelp},
            {"-T", opt_Flag},
            {"-x", sfntTagScan},
            {"-i", sfntTagScan},
            {"-d", opt_Int, &level, "0", 0, 4},
        };

    IntN argi;
    bool supported, supported2;
    Byte8 *filename1;
    Byte8 *filename2;
    IntN name1isDir, name2isDir;
    Byte8 **SimpleNameList;
    IntN NumSimpleNames = 0;

    da_SetMemFuncs(memNew, memResize, memFree);
    global.progname = "sfntdiff";

    argi = opt_Scan(argc, argv, opt_NOPTS(opt), opt, NULL, NULL);

    if (opt_Present("-u") || opt_Present("-h")) return 0;

    if (opt_Present("-x") && opt_Present("-i")) {
        printf("ERROR: '-x' switch and '-i' switch are exclusive of each other.\n");
        showUsage();
        return 1;
    }

    if (level > 4) level = 4;

    if ((argc - argi) < 2) {
        printf("ERROR: not enough files/directories specified.\n");
        showUsage();
        return 1;
    }

    filename1 = argv[argi];
    filename2 = argv[argi + 1];

    name1isDir = sysIsDir(filename1);
    name2isDir = sysIsDir(filename2);

    printf("%s\n", ourtime());
    printf("%s (%s) (-d %d)  files:\n", global.progname, version, level);

    if (!name1isDir && !name2isDir) {
        if (!fileIsOpened(1)) fileOpen(1, filename1);
        if (!fileIsOpened(2)) fileOpen(2, filename2);

        if (opt_Present("-T")) {
            printf("< %s\t%s\n", filename1, fileModTimeString(1, filename1));
            printf("> %s\t%s\n", filename2, fileModTimeString(2, filename2));
        } else {
            printf("< %s\n", filename1);
            printf("> %s\n", filename2);
        }

        /* See if we can recognize the file type */
        supported = isSupportedFontFormat(fileSniff(1), filename1);
        supported2 = isSupportedFontFormat(fileSniff(2), filename2);

        if (!supported || !supported2) {
            fileClose(1);
            fileClose(2);
            quit(1);
        }

        sfntRead(0, -1, 0, -1); /* Read plain sfnt file */
        sfntDump();
        sfntFree();
        fileClose(1);
        fileClose(2);
    } else if (name1isDir && name2isDir) {
        Byte8 fil1[MAX_PATH];
        Byte8 fil2[MAX_PATH];
        IntN nn;

        NumSimpleNames = sysReadInputDir(filename1, &SimpleNameList);
        for (nn = 0; nn < NumSimpleNames; nn++) {
            strcpy(fil1, filename1);
            strcat(fil1, sysPathSep);
            strcat(fil1, SimpleNameList[nn]);

            strcpy(fil2, filename2);
            strcat(fil2, sysPathSep);
            strcat(fil2, SimpleNameList[nn]);

            fileOpen(1, fil1);
            fileOpen(2, fil2);

            printf("\n---------------------------------------------\n");
            if (opt_Present("-T")) {
                printf("< %s\t%s\n", fil1, fileModTimeString(1, fil1));
                printf("> %s\t%s\n", fil2, fileModTimeString(2, fil2));
            } else {
                printf("< %s\n", fil1);
                printf("> %s\n", fil2);
            }

            /* See if we can recognize the file type */
            supported = isSupportedFontFormat(fileSniff(1), fil1);
            supported2 = isSupportedFontFormat(fileSniff(2), fil2);

            if (!supported || !supported2) {
                fileClose(1);
                fileClose(2);
                continue;
            }

            sfntRead(0, -1, 0, -1); /* Read plain sfnt file */
            sfntDump();
            sfntFree();
            fileClose(1);
            fileClose(2);
        }
    } else if (!name1isDir && name2isDir) {
        Byte8 fil2[MAX_PATH];
        Byte8 *c;

        strcpy(fil2, filename2);
        strcat(fil2, sysPathSep);
        c = strrchr(filename1, sysPathSep[0]);
        if (c == NULL)
            strcat(fil2, filename1);
        else
            strcat(fil2, ++c);

        fileOpen(1, filename1);
        fileOpen(2, fil2);

        if (opt_Present("-T")) {
            printf("< %s\t%s\n", filename1, fileModTimeString(1, filename1));
            printf("> %s\t%s\n", fil2, fileModTimeString(2, fil2));
        } else {
            printf("< %s\n", filename1);
            printf("> %s\n", fil2);
        }

        /* See if we can recognize the file type */
        supported = isSupportedFontFormat(fileSniff(1), filename1);
        supported2 = isSupportedFontFormat(fileSniff(2), fil2);

        if (!supported || !supported2) {
            fileClose(1);
            fileClose(2);
            quit(1);
        }

        sfntRead(0, -1, 0, -1); /* Read plain sfnt file */
        sfntDump();
        sfntFree();
        fileClose(1);
        fileClose(2);
    } else {
        printf("ERROR: Incorrect/insufficient files/directories specified.\n");
        showUsage();
        return 1;
    }
    return 0;
}
Пример #4
0
PyObject * main_python(PyObject *self, PyObject *args)
	{
	static double glyphptsize = STDPAGE_GLYPH_PTSIZE;
	static opt_Option opt[] =
		{
		  {"-u", opt_Call, showUsage},
		  {"-h", opt_Call, showHelp},
		  {"-ht", opt_Call, sfntTableSpecificUsage},
		  {"-l", opt_Flag},
		  {"-O", opt_Flag},
		  {"-r", opt_Flag},
		  {"-n", opt_Flag},
		  {"-nc", opt_Flag},
		  {"-T", opt_Flag},
		  {"-F", opt_Flag},
		  {"-f", opt_Flag},
		  {"-G", opt_Flag},
		  {"-V", opt_Flag},
		  {"-m", opt_Flag},
		  {"-d", opt_Flag},
		  {"-br", opt_Flag},
		  {"-i", resIdScan},
		  {"-o", sfntTTCScan},
		  {"-t", sfntTagScan},
		  {"-P", sfntFeatScan}, 
		  {"-A", sfntFeatScan}, 
		  {"-p", proofPolicyScan}, 
		  {"-a", opt_Flag},
		  {"-R", opt_Flag},
		  {"-c", opt_Flag},
		  {"-g", glyfGlyphScan},
		  {"-b", glyfBBoxScan},
		  {"-s", glyfScaleScan},
		  {"-@", opt_Double, &glyphptsize},
		  {"-C", opt_Int, &cmapSelected},
#if AUTOSCRIPT
		  {"-X", opt_String, scriptfilename},
#endif
		  {"-ag", opt_String, &glyphaliasfilename},
		  {"-of", opt_String, &outputfilebase},
		};
	char **argv, **argfree;
	int strIndex, argc, argtotal, tries;
	char * argString, *outfilename;
	IntX files;
	IntN argi;
    Byte8 *filename = NULL;
	Card32 value;
	int i = 0;
#if AUTOSCRIPT
	cmdlinetype *cmdl;
	Byte8 foundXswitch = 0;
#endif
    IntN status;

#ifdef SUNOS
	{
	/* To allow gdb to attach to process */
	char* do_debug_sleep;
	do_debug_sleep = getenv("STOP_OTFPROOF_FOR_GDB");
	while (do_debug_sleep != NULL)
		sleep(1);
	}	
#endif


	/* Resetting globals*/
	gcr.reportNumber=0;
	aliasfromfileinit = 0; 
	
/*	freopen("OTFProof.std.log", "w", stdout);*/
	
	value = setjmp(mark);
	
	if(value==-1){
		PyErr_SetString(ErrorObject, "Fatal Error");
		if (PyOutFile != NULL)
			{
			fclose(PyOutFile);
			PyOutFile = NULL;
			}
		freemap();
		return NULL;
	}
	
	if(!PyArg_ParseTuple(args, "ss", &argString, &outfilename)){
		freemap();
		return NULL;
	}
	
	if (PyOutFile == NULL)
		PyOutFile = fopen(outfilename, "w");
	else
		PyOutFile = freopen(outfilename, "w", PyOutFile);
	
	VORGfound=0;
	strIndex=0;
	argfree= (char **) memNew(MAX_ARGS*sizeof(char *));
	argv=(char **) memNew(MAX_ARGS*sizeof(char *));
	
	for(i=0; i<MAX_ARGS; i++){
		argfree[i]=argv[i]=NextToken(argString, &strIndex);
		if(argv[i]==NULL) {
			argtotal=argc=i;
			break;
		}else{
			/*fprintf(OUTPUTBUFF,  ">>%s<<\n", argv[i]);*/
		}
	}
	  status = setjmp(global.env);
	  if (status)
	  {
#if AUTOSCRIPT
	  	if (global.doingScripting)
	  		{
	  		  goto scriptAbEnd;
	  		}
	  	else
#endif
			if(status==2){
				PyErr_SetString(ErrorObject, "Fatal Error");
				if (PyOutFile != NULL)
					{
					fclose(PyOutFile);
					PyOutFile = NULL;
					}
				freemap();
				argFree(argfree, argv);
				return NULL;
			}else{
				if (PyOutFile != NULL)
					{
					fclose(PyOutFile);
					PyOutFile = NULL;
					}
				freemap();
				argFree(argfree, argv);
				return Py_None;
			}
	  }
	  
	  da_SetMemFuncs(memNew, memResize, memFree);
	  global.progname = "OTFproof";
#if AUTOSCRIPT
	scriptfilename[0]='\0';
	for (i = 0; i < argc; i++)
	{
		if (strcmp(argv[i], "-X") == 0)
		{
			if ((argv[i+1] != NULL) && (argv[i+1][0] != '\0'))
			{
				strcpy(scriptfilename, argv[i+1]);
				foundXswitch = 1;
			}
			break;
		}
	}
#endif 
	proofResetPolicies();
	argi = opt_Scan(argc, argv, opt_NOPTS(opt), opt, NULL, NULL);
	
	if (opt_hasError())
		{
		if (PyOutFile != NULL)
			{
			fclose(PyOutFile);
			PyOutFile = NULL;
			}
 		  freemap();
		  argFree(argfree, argv);
		  return Py_None;
		}
		
	 if (opt_Present("-@"))
		proofSetGlyphSize(glyphptsize);

	  if (opt_Present("-V"))  /* equivalent to "-p6" */
		proofSetPolicy(6, 1); 

	  files = argc - argi;

	  for (; argi < argc; argi++)
		{
		  filename = argv[argi];
		  
			fileOpen(filename);
			if (!fileIsOpened())
		  {
		  	warning(SPOT_MSG_BADFILE, filename);
			fileClose();
			continue;
		  }
/*			fprintf(OUTPUTBUFF, "\nProofing %s.\n", filename);			*/
		  tries = 0;
		  /* See if we can recognize the file type */
		  value = fileSniff();	
		  switch (value)
			{
			case bits_:
			case typ1_:		
			case true_:
			case mor0_:
			case OTTO_:
			case VERSION(1,0):
			  sfntRead(0, -1);	/* Read plain sfnt file */
			  sfntDump();
			  sfntFree(1);		  
			  break;
			case ttcf_:
			  sfntTTCRead(0);		/* Read TTC file */
			  continue;
			  break;
			case 256:
			  SEEK_ABS(0); /* Raw resource file as a data fork */ 
			  resRead(0);			/* Read and dump  Macintosh resource file */
			  continue;
			  break;
			case sig_AppleSingle:
			case sig_AppleDouble:
				doASDFormats((ctlTag)value);
				break;
			default:
				warning(SPOT_MSG_BADFILE, filename);
			  	fileClose();
			  continue;
			}

		  fileClose();
		  freemap();
		  argFree(argfree, argv);
#if MEMCHECK
		  memReport();
#endif
		fclose(PyOutFile);
		PyOutFile = NULL;
		  return Py_None;
		}
#if AUTOSCRIPT	
execscript:
			{
				char * end;
				
				end=strrchr(scriptfilename, '\\');
				if(end==NULL)
					sourcepath="";
				else{
					char *scurr = scriptfilename;
					char *dcurr;
					
					sourcepath=(char *)memNew(strlen(scriptfilename));
					dcurr = sourcepath;
					while(scurr!=end)
					{
						*dcurr++=*scurr++;
					}		
					*dcurr=0;
				}
			
			}

	  for (i = 0; i < script.cmdline.cnt ; i++) 
	  {
		char * tempfilename;
		
		cmdl = da_INDEX(script.cmdline, i);
		if (cmdl->args.cnt < 2) continue;

		proofResetPolicies();
		
		{
			IntX a;
			
			inform(SPOT_MSG_EOLN);
			message(SPOT_MSG_ECHOSCRIPTCMD);
			for (a = 1; a < cmdl->args.cnt; a++)
			{
				inform(SPOT_MSG_RAWSTRING, cmdl->args.array[a]);
			}
			inform(SPOT_MSG_EOLN);
		}
		
		argi = opt_Scan(cmdl->args.cnt, cmdl->args.array, opt_NOPTS(opt), opt, NULL, NULL);		

		if (opt_hasError())
			{
			if (PyOutFile != NULL)
				{
				fclose(PyOutFile);
				PyOutFile = NULL;
				}
			freemap();
			argFree(argfree, argv);
			return Py_None;
			}

		if (opt_Present("-@"))
			proofSetGlyphSize(glyphptsize);
	  	if (opt_Present("-V"))  /* equivalent to "-p6" */
			proofSetPolicy(6, 1); 

		tempfilename = MakeFullPath(cmdl->args.array[cmdl->args.cnt-1]);
		
		
		if (fileExists(tempfilename) )
		  { 						/* (new) font filename on cmdline */
			memFree(tempfilename);
			if (filename != NULL) /* not first time */
			{
			  fileClose(); /* previous font file */
	  		  sfntFree(1);
		  	}
			if(sourcepath[0]!='\0')
				filename=MakeFullPath(cmdl->args.array[cmdl->args.cnt-1]);
			else
				filename = cmdl->args.array[cmdl->args.cnt-1];
			fileOpen(filename);
			  tries=0;
retry:
			/* See if we can recognize the file type */
			value = fileSniff();	
			switch (value)
			  {
			  case bits_:
			  case typ1_:		
			  case true_:
			  case mor0_:
			  case OTTO_:
			  case VERSION(1,0):
				sfntRead(0, -1);	/* Read plain sfnt file */
				break;
			  case ttcf_:
				sfntTTCRead(0);		/* Read TTC file */
				continue;
				break;
			  case 256:
				resRead(0);			/* Read Macintosh resource file */
				continue;
				break;
			  default:	 
 				warning(SPOT_MSG_BADFILE, filename);
				fileClose();
				continue;
			  }
		  }
		else
		{
		  /* none specified */
		  fatal(SPOT_MSG_MISSINGFILENAME);
		  memFree(tempfilename);
		  continue;
		}
		
		sfntDump();
		
scriptAbEnd:
		sfntFree(1);
	    fileClose();
	  }
	  global.doingScripting = 0;
#endif	

	/*fprintf(stderr, "\nDone.\n");*/
	
	fileClose();	
	freemap();
	argFree(argfree, argv);
#if MEMCHECK
	memReport();
#endif
	fclose(PyOutFile);
	PyOutFile = NULL;
	return Py_None;
}
Пример #5
0
PyObject * proof_complement(PyObject *self, PyObject *args)
{
	static double glyphptsize = STDPAGE_GLYPH_PTSIZE;
	static opt_Option opt[] =
	{
	  {"-u", opt_Call, showUsage},
	  {"-h", opt_Call, showHelp},
	  {"-ht", opt_Call, sfntTableSpecificUsage},
	  {"-l", opt_Flag},
	  {"-O", opt_Flag},
	  {"-r", opt_Flag},
	  {"-n", opt_Flag},
	  {"-nc", opt_Flag},
	  {"-T", opt_Flag},
	  {"-F", opt_Flag},
	  {"-G", opt_Flag},
	  {"-V", opt_Flag},
	  {"-m", opt_Flag},
	  {"-d", opt_Flag},
	  {"-br", opt_Flag},
	  {"-i", resIdScan},
	  {"-o", sfntTTCScan},
	  {"-t", sfntTagScan},
	  {"-P", sfntFeatScan}, 
	  {"-A", sfntFeatScan}, 
	  {"-p", proofPolicyScan}, 
	  {"-a", opt_Flag},
	  {"-R", opt_Flag},
	  {"-c", opt_Flag},
	  {"-g", glyfGlyphScan},
	  {"-b", glyfBBoxScan},
	  {"-s", glyfScaleScan},
	  {"-@", opt_Double, &glyphptsize},
	  {"-C", opt_Int, &cmapSelected},
	};

	IntN argi;
	Card32 value;
	char *outfilename;
	char *infilenameorig;
	IntN status;
	char *argv[30];
	int argc;
	int startIndex=0;
	int infilesSize;
	int useStdOut = 0;
	int i;
	

	{
	/* To allow gdb to attach to process */
	char* do_debug_sleep;
	do_debug_sleep = getenv("STOP_GLYPH_PROOFER");
	while (do_debug_sleep != NULL)
		sleep(1);
	}	


	value = setjmp(mark);
	
	if(value==-1){
		PyErr_SetString(ErrorObject, "Fatal Error");
		if (PyOutFile != NULL)
			{
			fclose(PyOutFile);
			PyOutFile = NULL;
			}
		freemap();
		return NULL;
	}
	
	if(!PyArg_ParseTuple(args, "s#iisiii", 
				&infilename, &infilesSize, 
				&(gcr.synOnly), &(gcr.numFonts), 
				&outfilename, 
				&(gcr.maxNumGlyphs), &(gcr.byname), &useStdOut)){
		freemap();
		return NULL;
	}

	if (PyOutFile != NULL)
		freopen(outfilename, "w", PyOutFile);
	else
		PyOutFile = fopen(outfilename, "w");
	
	infilenameorig=infilename;
	gcr.reportNumber=0;
	gcr.startGlyph=0;
	gcr.numGlyphs=2;
	gcr.endGlyph=1;
	
	VORGfound=0;
	status = setjmp(global.env);
	if (status)
	{
		if(status==2){
			PyErr_SetString(ErrorObject, "Fatal Error");
			if (PyOutFile != NULL)
				{
				fclose(PyOutFile);
				PyOutFile = NULL;
				}
			freemap();
			return NULL;
		}else{
			if (PyOutFile != NULL)
				{
				fclose(PyOutFile);
				PyOutFile = NULL;
				}
			freemap();
			return Py_None;
		}
	}

	da_SetMemFuncs(memNew, memResize, memFree);
	global.progname = "Glyph_Proofer";
	outputfilebase =  "glyphproofer";
	
	fprintf(OUTPUTBUFF, "%s-library v.%s\n\n", global.progname, libversion);
	
	
	while(gcr.endGlyph!=0 && gcr.endGlyph<gcr.numGlyphs)
	{
		int newstart=gcr.endGlyph;
		infilename=infilenameorig;
		
		if (newstart==1) newstart=0;
		
		/*fprintf(stderr, "Starting again with %d of %d\n", gcr.endGlyph, gcr.numGlyphs);*/
		gcr.endGlyph=0;
		
		for (i=0; i<gcr.numFonts; i++)
		{
			gcr.startGlyph=newstart;	
			/*fprintf(OUTPUTBUFF, "Processing %s\n", infilename);*/
			argc = 0;
			argv[argc++]=global.progname;
			if (useStdOut)
			argv[argc++]="-O";
			argv[argc++]="-tCFF_=9";
			argv[argc++]="-d";
			argv[argc++]="-l";
			argv[argc++]=infilename;
			
			argi = opt_Scan(argc, argv, opt_NOPTS(opt), opt, NULL, NULL);
			
			if (opt_hasError())
				{
				if (PyOutFile != NULL)
					{
					fclose(PyOutFile);
					PyOutFile = NULL;
					}
		 		  freemap();
				  return NULL;
				}
			
			fileOpen(infilename);
			
			if (!fileIsOpened())
			{
				warning(SPOT_MSG_BADFILE, infilename);
				fileClose();
				if (PyOutFile != NULL)
					{
					fclose(PyOutFile);
					PyOutFile = NULL;
					}
				freemap();
				return NULL;
			}else{
				/* See if we can recognize the file type */
				value = fileSniff();
				switch (value)
				{
					case bits_:
					case typ1_:		
					case true_:
					case mor0_:
					case OTTO_:
					case VERSION(1,0):
					  sfntRead(0, -1);	/* Read plain sfnt file */
					  sfntDump();
					  sfntFree(1);		  
					  break;
					case ttcf_:
					  sfntTTCRead(0);		/* Read TTC file */
					  break;
					case 256:
					  SEEK_ABS(0); /* Raw resource file as a data fork */ 
					  resRead(0);			/* Read and dump  Macintosh resource file */
					  break;
					default:
						warning(SPOT_MSG_BADFILE, infilename);
						PyErr_SetString(ErrorObject, "Fatal Error: Not a valid font file");
					  	fileClose();
						if (PyOutFile != NULL)
							{
							fclose(PyOutFile);
							PyOutFile = NULL;
							}
						freemap();
						return NULL;
				}
				fileClose();
				
			}
		
			while(*infilename)
				infilename++;
			infilename++;  /*Gets us past the next NULL character*/
		}
	}
	CFF_SynopsisFinish();
	fclose(PyOutFile);
	PyOutFile = NULL;
	freemap();
	return Py_None;
}
Пример #6
0
/* Main program */
IntN main(IntN argc, Byte8 *argv[])
	{
	   IntX value = 0;
	  static double glyphptsize = STDPAGE_GLYPH_PTSIZE;
	  static opt_Option opt[] =
		{
		  {"-u", opt_Call, (void*)showUsage},
		  {"-h", opt_Call, (void*)showHelp},
		  {"-ht", opt_Call, (void*)sfntTableSpecificUsage},
#if AUTOSPOOL
		  {"-l", opt_Flag},
		  {"-O", opt_Flag},
#endif
		  {"-r", opt_Flag},
		  {"-n", opt_Flag},
		  {"-nc", opt_Flag},
		  {"-ngid", opt_Flag},
		  {"-T", opt_Flag},
		  {"-F", opt_Flag},
		  {"-f", opt_Flag},
		  {"-G", opt_Flag},
		  {"-V", opt_Flag},
		  {"-m", opt_Flag},
		  {"-d", opt_Flag},
		  {"-br", opt_Flag},
		  {"-i", resIdScan},
		  {"-o", sfntTTCScan},
		  {"-t", sfntTagScan},
		  {"-P", sfntFeatScan}, 
		  {"-A", sfntFeatScan}, 
		  {"-p", proofPolicyScan}, 
		  {"-a", opt_Flag},
		  {"-R", opt_Flag},
		  {"-c", opt_Flag},
		  {"-g", glyfGlyphScan},
		  {"-b", glyfBBoxScan},
		  {"-s", glyfScaleScan},
		  {"-@", opt_Double, &glyphptsize},
		  {"-C", opt_Int, &cmapSelected},
#if AUTOSCRIPT
		  {"-X", opt_String, scriptfilename},
#endif
		  {"-ag", opt_String, &glyphaliasfilename},
		  {"-of", opt_String, &outputfilebase},
		};

	  IntX files, goodFileCount=0;
	  IntN argi;
      Byte8 *filename = NULL;
	  volatile IntX i = 0;
#if AUTOSCRIPT
	  cmdlinetype *cmdl;
	  Byte8 foundXswitch = 0;
#endif
	  int status = 0; /* = setjmp(global.env); only ued when compiled as lib */

	  if (status)
	  {
#if AUTOSCRIPT
	  	if (global.doingScripting)
	  		{
	  		  goto scriptAbEnd;
	  		}
	  	else
#endif
			exit(status - 1);	/* Finish processing */
	  }
	  gcr.reportNumber=0;
	 /*  value = setjmp(mark); only used when comiled as lib */

         if (value==-1)
                 exit(1);

	  da_SetMemFuncs(memNew, memResize, memFree);
	  global.progname = "spot";

#if AUTOSCRIPT
	scriptfilename[0] = '\0'; /* init */

	if (!foundXswitch && (argc < 2)) /* if no -X on cmdline, and no OTHER switches */
	  strcpy(scriptfilename, "spot.scr");

/* see if scriptfile exists to Auto-execute */
	if ((scriptfilename[0] != '\0') && sysFileExists(scriptfilename))
		{
			global.doingScripting = 1;
			makeArgs(scriptfilename);
		}
#endif /* AUTOSCRIPT */

	  if (
#if AUTOSCRIPT
		  !global.doingScripting
#else
		  1
#endif
		  )
		{
	  	argi = opt_Scan(argc, argv, opt_NOPTS(opt), opt, NULL, NULL);
		if (opt_hasError())
			{
			exit(1);
			}
	  
	  if (argi == 0 )
		showUsage();

#if AUTOSCRIPT
	if (!global.doingScripting && opt_Present("-X"))
	{
		if (scriptfilename && scriptfilename[0] != '\0')
		{
		global.doingScripting = 1;
		makeArgs(scriptfilename);
		goto execscript;
		}
	}
#endif


	  if (opt_Present("-@"))
		proofSetGlyphSize(glyphptsize);

	  if (opt_Present("-V"))  /* equivalent to "-p6" */
		proofSetPolicy(6, 1); 

	  if (opt_Present("-ngid")) 
		global.flags |= SUPPRESS_GID_IN_NAME;

	  files = argc - argi;
      if ((files == 0) && (argc > 1)) /* no files on commandline, but other switches */
		{
		}

	  for (; argi < argc; argi++)
		{
		  filename = argv[argi];
		  
		  if (files > 1)
		  	{
			fprintf(stderr, "Proofing %s.\n", filename);
			fflush(stderr);
			}

		  if (outputfilebase== NULL)
		 	outputfilebase = filename;
		  fileOpen(filename);		  
		  
		  if (!fileIsOpened())
		  {
		  	warning(SPOT_MSG_BADFILE, filename);
			fileClose();
			continue;
		  }
		  if (readFile(filename))
			{
			  fileClose();
			  continue;
			}

		  goodFileCount++;
		  fileClose();
		}
		
	}
#if AUTOSCRIPT
	else /* executing cmdlines from a script file */
	{
execscript:
			{
				char * end;
				
			end=strrchr(scriptfilename, '\\');
				if(end==NULL)
					sourcepath="";
				else{
					char *scurr = scriptfilename;
					char *dcurr;
					
					sourcepath=(char *)memNew(strlen(scriptfilename));
					dcurr = sourcepath;
					while(scurr!=end)
					{
						*dcurr++=*scurr++;
					}		
					*dcurr=0;
				}
			
			}

	  for (i = 0; i < script.cmdline.cnt ; i++) 
	  {
		char * tempfilename;
		
		cmdl = da_INDEX(script.cmdline, i);
		if (cmdl->args.cnt < 2) continue;

		proofResetPolicies();
		
		{
			IntX a;
			
			inform(SPOT_MSG_EOLN);
			message(SPOT_MSG_ECHOSCRIPTCMD);
			for (a = 1; a < cmdl->args.cnt; a++)
			{
				inform(SPOT_MSG_RAWSTRING, cmdl->args.array[a]);
			}
			inform(SPOT_MSG_EOLN);
		}
		
		argi = opt_Scan(cmdl->args.cnt, cmdl->args.array, opt_NOPTS(opt), opt, NULL, NULL);		
		if (opt_hasError())
			{
			exit(1);
			}

		if (opt_Present("-@"))
			proofSetGlyphSize(glyphptsize);
	  	if (opt_Present("-V"))  /* equivalent to "-p6" */
			proofSetPolicy(6, 1); 

		tempfilename = MakeFullPath(cmdl->args.array[cmdl->args.cnt-1]);
		
		
		if (fileExists(tempfilename) )
		  { 						/* (new) font filename on cmdline */
			memFree(tempfilename);
			if (filename != NULL) /* not first time */
			{
			  fileClose(); /* previous font file */
	  		  sfntFree(1);
		  	}
			if(sourcepath[0]!='\0')
				filename=MakeFullPath(cmdl->args.array[cmdl->args.cnt-1]);
			else
				filename = cmdl->args.array[cmdl->args.cnt-1];
			fileOpen(filename);
			if (outputfilebase == NULL)
		 		outputfilebase = filename;
			fprintf(stderr, "Proofing %s.\n", filename);
			fflush(stderr);
		    goodFileCount++;
		
		  if (readFile(filename))
			{
			  goodFileCount--;
			  fileClose();
			  continue;
			}
			
		  }
		else
		{
		  /* none specified */
		  fatal(SPOT_MSG_MISSINGFILENAME);
		  memFree(tempfilename);
		  continue;
		}
		
		sfntDump();
		
scriptAbEnd:
		sfntFree(1);
	    fileClose();
	  }
	  global.doingScripting = 0;
	}
#endif /* AUTOSCRIPT */

/*	fprintf(stderr, "\nDone.\n");*/
	if(goodFileCount<=0)
		exit(1);

	quit(0);
	return 0;		
}