int init() { systemdefault = new SystemDefault_c; configfile = new char[MAX_PATH]; memcpy(configfile,systemdefault->PrgPath,strlen(systemdefault->PrgPath)+1); memcpy(configfile+strlen(configfile),conf,strlen(conf)+1); runconfig = new runconfig_c(configfile); if (strlen(runconfig->ExeFile) == 0) { MessageBox(0,"Can not read \"setup/run.xml\"","Error",MB_ICONERROR); return 1; } exefile = new char[MAX_PATH]; memcpy(exefile,systemdefault->PrgPath,strlen(systemdefault->PrgPath)+1); memcpy(exefile+strlen(exefile),app,strlen(app)+1); memcpy(exefile+strlen(exefile), runconfig->ExeFile, strlen(runconfig->ExeFile)+1); appdir = new char[MAX_PATH]; memcpy(appdir,exefile,strlen(exefile)+1); StripName(appdir); StripSlash(appdir); return 0; }
int main (int argc, char *argv[]) { int i; int xhot = -1, yhot = -1; char *filename = NULL; char *chars = "-#"; char *name = NULL; FILE *fp; ProgramName = argv[0]; for (i = 1; i < argc; i++) { char *arg = argv[i]; if (arg[0] == '-') { switch (arg[1]) { case '\0': filename = NULL; continue; case 'c': if (++i >= argc) usage (); chars = argv[i]; continue; case 'n': if (++i >= argc) usage (); name = argv[i]; continue; case 'x': if (++i >= argc) usage (); xhot = atoi (argv[i]); continue; case 'y': if (++i >= argc) usage (); yhot = atoi (argv[i]); continue; default: usage (); } } else { filename = arg; } } if (strlen (chars) != 2) { fprintf (stderr, "%s: bad character list \"%s\", must have exactly 2 characters\n", ProgramName, chars); exit (1); } if (filename) { fp = fopen (filename, "r"); if (!fp) { fprintf (stderr, "%s: unable to open file \"%s\".\n", ProgramName, filename); exit (1); } } else { fp = stdin; } if (!name) name = filename ? StripName (filename) : ""; cify_name (name); doit (fp, filename, chars, xhot, yhot, name); if (filename) (void) fclose (fp); exit (0); }