Ejemplo n.º 1
0
void
print_stats()
{
#ifdef WITH_LIB
    memReport(stdout);
#endif
    getrusage(RUSAGE_SELF, &myusage);
    printf("m/c/f/r=%d/%d/%d/%d\n", mstat.mallocs, mstat.callocs,
           mstat.frees, mstat.reallocs);
#if 0
    printf("types                 : %d\n", size2id_len);
#endif
    printf("user time used        : %d.%d\n", (int) myusage.ru_utime.tv_sec,
           (int) myusage.ru_utime.tv_usec);
    printf("system time used      : %d.%d\n", (int) myusage.ru_stime.tv_sec,
           (int) myusage.ru_stime.tv_usec);
    printf("max resident set size : %d\n", (int) myusage.ru_maxrss);
    printf("page faults           : %d\n", (int) myusage.ru_majflt);
}
Ejemplo n.º 2
0
static void
memStats(StoreEntry * sentry)
{
    storeBuffer(sentry);
    memReport(sentry);
    memStringStats(sentry);
    memBufStats(sentry);
    storeBufferFlush(sentry);
#if WITH_VALGRIND
    if (RUNNING_ON_VALGRIND) {
        long int leaked = 0, dubious = 0, reachable = 0, suppressed = 0;
        storeAppendPrintf(sentry, "Valgrind Report:\n");
        storeAppendPrintf(sentry, "Type\tAmount\n");
        debug(13, 1) ("Asking valgrind for memleaks\n");
        VALGRIND_DO_LEAK_CHECK;
        debug(13, 1) ("Getting valgrind statistics\n");
        VALGRIND_COUNT_LEAKS(leaked, dubious, reachable, suppressed);
        storeAppendPrintf(sentry, "Leaked\t%ld\n", leaked);
        storeAppendPrintf(sentry, "Dubious\t%ld\n", dubious);
        storeAppendPrintf(sentry, "Reachable\t%ld\n", reachable);
        storeAppendPrintf(sentry, "Suppressed\t%ld\n", suppressed);
    }
#endif
}
Ejemplo n.º 3
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;
}