#include #ifdef MYGETOPT char getopt( int argc, char *argv[], char *format ); #else #include #endif #include "prefs.h" #include "errors.h" #include "version.h" static void usage(char *name); static void usage(char *name) { DoError(NO_ERR,INFO_ERR, "Usage: %s [-hVc][-v][files]",name); DoError(NO_ERR,INFO_ERR,"Translate RIB binary to ascii "); DoError(NO_ERR,INFO_ERR,"-h: This text"); DoError(NO_ERR,INFO_ERR,"-V: Print Version"); DoError(NO_ERR,INFO_ERR,"-c: To stdout"); DoError(NO_ERR,INFO_ERR,"-f: Force overwrite of output file"); DoError(NO_ERR,INFO_ERR,"-v n: Verbose Level (7 for quiet)"); DoError(NO_ERR,INFO_ERR,"file must match *.rbb"); exit(1); } boolean GetPrefs(PrefsType *PrefsPtr, int argc, char *argv[] ) { int opcion,i; float f; extern char *optarg; extern int optind,opterr; PrefsPtr->verbose=2; PrefsPtr->tostdout=false; PrefsPtr->fromstdin=false; PrefsPtr->force=false; while ( (opcion=getopt(argc,argv,"hVcv:f")) != EOF ) { switch(opcion) { case 'V': DoError(NO_ERR,INFO_ERR,VERS_STR); exit(0); break; case 'h': usage(argv[0]); exit(0); break; case 'c': PrefsPtr->tostdout=true; break; case 'f': PrefsPtr->force=true; break; case 'v': i = atoi(optarg); if(( i < 0 )||(i>ASK_ERR)) DoError(INPUT_ERR,WARN_ERR,"Verbose: %d-%d,ignored ", 0,ASK_ERR); else PrefsPtr->verbose = i; break; default: usage(argv[0]); break; } } if(argc==optind) { PrefsPtr->fromstdin=true; PrefsPtr->tostdout=true; optind--; } return( true ); }