/*-------------------------------------------------------------------------*/ void ccinit(int argc, char *argv[]) { char buffer[260]; strcpy(copyright, COPYRIGHT); strcpy(version, STRING_VERSION); outfile[0] = 0; #ifdef CPREPROCESSOR banner("ocpp Version %s %s", version, copyright); #else banner("%s Version %s %s", chosenAssembler->progname, version, copyright); /* parse the environment and command line */ if (chosenAssembler->envname && !parseenv(chosenAssembler->envname)) usage(argv[0]); #endif #ifdef MICROSOFT GetModuleFileNameA(NULL, buffer, sizeof(buffer)); //FIXME NULL as int #else strcpy(buffer, argv[0]); #endif parseconfigfile(buffer); if (!parse_args(&argc, argv, TRUE) || (!clist && argc == 1)) usage(argv[0]); /* tack the environment includes in */ addinclude(); /* Scan the command line for file names or response files */ { int i; for (i = 1; i < argc; i++) if (argv[i][0] == '@') parsefile(0, argv[i] + 1); else InsertAnyFile(argv[i], 0, - 1); } if ((clist && clist->next) && has_output_file) fatal("Cannot specify output file for multiple input files\n"); if (has_output_file && !cparams.prm_compileonly) { #ifndef CPREPROCESSOR if (chosenAssembler->insert_noncompile_file) chosenAssembler->insert_noncompile_file(outfile); #endif has_output_file = FALSE; } /* Set up a ctrl-C handler so we can exit the prog */ signal(SIGINT, ctrlchandler); if (setjmp(ctrlcreturn)) exit(1); }
int parse_arbitrary(char *string) /* * take a C string and and convert it to ARGC, ARGV format and then run * it through the argument parser */ { char *argv[40]; char output[1024]; int rv, i; int argc = 1; if (!string || ! *string) return 1; scan_env(output, string); string = output; while (1) { int quoted = ' '; while (*string == ' ') string++; if (! *string) break; if (*string == '\"') quoted = *string++; argv[argc++] = string; while (*string && *string != quoted) string++; if (! *string) break; *string = 0; string++; } rv = parse_args(&argc, argv, TRUE); for (i = 1; i < argc; i++) InsertAnyFile(argv[i], 0, - 1); return rv; }