+#endif
+
+static void
+print_help(void)
+{
+ fprintf(stderr,"Gob version %s\n\n",VERSION);
+ fprintf(stderr,"Options:\n"
+ "\t--help,-h,-? Display this help\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-touch-headers Don't touch headers unless they "
+ "really changed\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],"--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],"--")==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 'h':
+ case '?':
+ print_help();
+ exit(0);
+ default:
+ fprintf(stderr,
+ "Unknown option '%c'!\n",*p);
+ print_help();
+ exit(1);
+ }
+ }
+ }
+ }
+}