int main(int argc, char *argv[]) { char *progname = argv[0]; int allowUnsafe = 0; int sawStdin; int state, opt; char *param; int errors; ILContext *context; /* Parse the command-line arguments */ state = 0; while((opt = ILCmdLineNextOption(&argc, &argv, &state, options, ¶m)) != 0) { switch(opt) { case 'u': { allowUnsafe = 1; } break; case 'v': { version(); return 0; } /* Not reached */ default: { usage(progname); return 1; } /* Not reached */ } } /* We need at least one input file argument */ if(argc <= 1) { usage(progname); return 1; } /* Initialize the engine, to ensure that the garbage collector is OK */ #ifdef IL_CONFIG_APPDOMAINS ILExecInit(0, 0); #else ILExecInit(0); #endif /* Create a context to use for image loading */ context = ILContextCreate(); if(!context) { fprintf(stderr, "%s: out of memory\n", progname); return 1; } /* Load and verify the input files */ sawStdin = 0; errors = 0; while(argc > 1) { if(!strcmp(argv[1], "-")) { /* Verify the contents of stdin, but only once */ if(!sawStdin) { errors |= verify("-", context, allowUnsafe); sawStdin = 1; } } else { /* Verify the contents of a regular file */ errors |= verify(argv[1], context, allowUnsafe); } ++argv; --argc; } /* Destroy the context */ ILContextDestroy(context); /* Done */ return errors; }
int main(int argc, char *argv[]) { char *progname = argv[0]; int allowUnsafe = 0; int sawStdin; int state, opt; char *param; int errors; ILExecProcess *process = 0; ILExecThread *thread = 0; /* Parse the command-line arguments */ state = 0; while((opt = ILCmdLineNextOption(&argc, &argv, &state, options, ¶m)) != 0) { switch(opt) { case 'u': { allowUnsafe = 1; } break; case 'v': { version(); return 0; } /* Not reached */ default: { usage(progname); return 1; } /* Not reached */ } } /* We need at least one input file argument */ if(argc <= 1) { usage(progname); return 1; } /* Initialize the engine, to ensure that the garbage collector is OK */ ILExecInit(0); /* Create the default appdomain for the image loading. */ if(!(process = ILExecProcessCreateNull())) { fprintf(stderr, "%s: out of memory\n", progname); return 1; } /* Make sure the current thread is assiciated to the process */ if(!(thread = ILExecProcessGetMain(process))) { fprintf(stderr, "%s: out of memory\n", progname); return 1; } /* Load and verify the input files */ sawStdin = 0; errors = 0; while(argc > 1) { if(!strcmp(argv[1], "-")) { /* Verify the contents of stdin, but only once */ if(!sawStdin) { errors |= verify("-", process->context, allowUnsafe); sawStdin = 1; } } else { /* Verify the contents of a regular file */ errors |= verify(argv[1], process->context, allowUnsafe); } ++argv; --argc; } /* Destroy the engine */ ILExecDeinit(); /* Done */ return errors; }