예제 #1
0
/* Verify that the storage file for the specified CryptedFile
   exists. */
static CoreResult storageFileExists(CryptedVolume * pVolume,
   CryptedFileID id)
{
   char szPathName[MAX_STORAGE_PATH_NAME];
   SysResult sr;
   bool fExists;
   makeStoragePathName(pVolume, id, szPathName);
   if (sr = sysFileExists(szPathName, &fExists)) return sys2core(sr);
   return fExists ? CORERC_FILE_EXISTS : CORERC_OK;
}
예제 #2
0
파일: Dfile.c 프로젝트: Acidburn0zzz/afdko
IntX fileExists(Byte8 *filename)
	{
	  return (sysFileExists(filename));
	}
예제 #3
0
파일: main.c 프로젝트: Acidburn0zzz/afdko
/* 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;		
}