+ fprintf(stderr, "Gob version %s\n\n", VERSION);
+ fprintf(stderr, "Options:\n"
+ "\t--help,-h,-? Display this help\n"
+ "\t--version Display version\n"
+ "\t--exit-on-warn,-w Exit with an error on warnings\n"
+ "\t--no-exit-on-warn Don't exit on warnings [default]\n"
+ "\t--for-cpp Create C++ files\n"
+ "\t--no-extern-c Never print extern \"C\" into the "
+ "header\n"
+ "\t--no-gnu Never use GNU extentions\n"
+ "\t--no-touch-headers Don't touch headers unless they "
+ "really changed\n"
+ "\t--always-private-header Always create a private header "
+ "file,\n"
+ "\t even if it would be empty "
+ "[default]\n"
+ "\t--ondemand-private-header Create private header only when "
+ "needed\n"
+ "\t--no-private-header Don't create a private header, "
+ "put private\n"
+ "\t structure and protected "
+ "prototypes inside c file\n"
+ "\t--no-write,-n Don't write output files, just "
+ "check syntax\n"
+ "\t--no-lines Don't print '#line' to output\n");
+}
+
+static void
+parse_options(int argc, char *argv[])
+{
+ int i;
+ int got_file = FALSE;
+ int no_opts = FALSE;
+
+ filename = NULL;
+
+ for(i=1;i<argc;i++) {
+ if(no_opts || argv[i][0]!='-') {
+ /*must be a file*/
+ if(got_file) {
+ fprintf(stderr, "Specify only one file!\n");
+ print_help();
+ exit(1);
+ }
+ filename = argv[i];
+ got_file = TRUE;
+ } else if(strcmp(argv[i], "--help")==0) {
+ print_help();
+ exit(0);
+ } else if(strcmp(argv[i], "--version")==0) {
+ fprintf(stderr, "Gob version %s\n", VERSION);
+ exit(0);
+ } else if(strcmp(argv[i], "--exit-on-warn")==0) {
+ exit_on_warn = TRUE;
+ } else if(strcmp(argv[i], "--no-exit-on-warn")==0) {
+ exit_on_warn = FALSE;
+ } else if(strcmp(argv[i], "--for-cpp")==0) {
+ for_cpp = TRUE;
+ } else if(strcmp(argv[i], "--no-touch-headers")==0) {
+ no_touch_headers = TRUE;
+ } else if(strcmp(argv[i], "--ondemand-private-header")==0) {
+ private_header == PRIVATE_HEADER_ONDEMAND;
+ } else if(strcmp(argv[i], "--always-private-header")==0) {
+ private_header == PRIVATE_HEADER_ALWAYS;
+ } else if(strcmp(argv[i], "--no-private-header")==0) {
+ private_header == PRIVATE_HEADER_NEVER;
+ } else if(strcmp(argv[i], "--no-gnu")==0) {
+ no_gnu = TRUE;
+ } else if(strcmp(argv[i], "--no-extern-c")==0) {
+ no_extern_c = TRUE;
+ } else if(strcmp(argv[i], "--no-write")==0) {
+ no_write = TRUE;
+ } else if(strcmp(argv[i], "--no-lines")==0) {
+ no_lines = TRUE;
+ } else if(strcmp(argv[i], "--")==0) {
+ /*further arguments are files*/
+ no_opts = TRUE;
+ } else if(strncmp(argv[i], "--", 2)==0) {
+ /*unknown long option*/
+ fprintf(stderr, "Unknown option '%s'!\n", argv[i]);
+ print_help();
+ exit(1);
+ } else {
+ /*by now we know we have a string starting with
+ - which is a short option string*/
+ char *p = argv[i]+1;
+ for(p=argv[i]+1; *p; p++) {
+ switch(*p) {
+ case 'w':
+ exit_on_warn=TRUE;
+ break;
+ case 'n':
+ no_write = TRUE;
+ break;
+ case 'h':
+ case '?':
+ print_help();
+ exit(0);
+ default:
+ fprintf(stderr,
+ "Unknown option '%c'!\n", *p);
+ print_help();
+ exit(1);
+ }
+ }
+ }
+ }