r70: added imagefiles
[ctsim.git] / src / sdfinfo.c
index 9f406ded3815ce7153064a796ab73b984b55e3b8..568c951aa09c421c70163af6b68118c5eb9d4bbc 100644 (file)
@@ -2,10 +2,17 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: sdfinfo.c,v 1.1 2000/04/28 13:02:44 kevin Exp $
+**  $Id: sdfinfo.c,v 1.3 2000/05/16 04:33:59 kevin Exp $
 **  $Log: sdfinfo.c,v $
-**  Revision 1.1  2000/04/28 13:02:44  kevin
-**  Initial revision
+**  Revision 1.3  2000/05/16 04:33:59  kevin
+**  Improved option processing
+**
+**  Revision 1.2  2000/05/08 20:02:32  kevin
+**  ANSI C changes
+**
+**  Revision 1.1.1.1  2000/04/28 13:02:44  kevin
+**  Initial CVS import for first public release
+**
 **
 **
 **  This program is free software; you can redistribute it and/or modify
 **  along with this program; if not, write to the Free Software
 **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ******************************************************************************/
+
 /* FILE
  *   sdfinfo.c             Display info on sdf files
  */
 
 #include "ct.h"
 
-#define O_LABELS   5
-#define O_STATS    6
-#define O_VERBOSE  7
-#define O_HELP     8
-#define O_VERSION  9
-#define O_DEBUG    10
-#define O_NO_STATS 11
-#define O_NO_LABELS 12
+enum { O_LABELS, O_STATS, O_NO_STATS, O_NO_LABELS, O_VERBOSE, O_HELP, O_VERSION, O_DEBUG };
 
 static struct option my_options[] =
 {
@@ -50,9 +51,9 @@ static struct option my_options[] =
 };
 
 void 
-usage (const char *program)
+sdfinfo_usage (const char *program)
 {
-  fprintf(stdout, "usage: %s infile [OPTIONS]\n", kbasename(program));
+  fprintf(stdout, "sdfinfo_usage: %s infile [OPTIONS]\n", kbasename(program));
   fprintf(stdout, "Analyze an SDF2D file\n");
   fprintf(stdout, "\n");
   fprintf(stdout, "     infile       Name of input SDF file\n");
@@ -65,11 +66,10 @@ usage (const char *program)
   fprintf(stdout, "     --verbose    Verbose mode\n");
   fprintf(stdout, "     --version    Print version\n");
   fprintf(stdout, "     --help       Print this help message\n");
-  exit(1);
 }
 
 int 
-main (int argc, char *const argv[])
+sdfinfo_main (int argc, char *const argv[])
 {
   IMAGE *im;
   char *in_file;
@@ -114,18 +114,18 @@ main (int argc, char *const argv[])
          exit(0);
        case O_HELP:
        case '?':
-         usage(argv[0]);
-         exit(0);
+         sdfinfo_usage(argv[0]);
+         return (0);
        default:
-         usage(argv[0]);
-         exit(1);
+         sdfinfo_usage(argv[0]);
+         return (1);
        }
     }
 
   if (optind + 1 != argc)
     {
-      usage(argv[0]);
-      exit(1);
+      sdfinfo_usage(argv[0]);
+      return (1);
     }
   
   in_file = argv[optind];
@@ -228,3 +228,11 @@ main (int argc, char *const argv[])
   
   return (0);
 }
+
+#ifndef NO_MAIN
+int 
+main (int argc, char *const argv[])
+{
+  return (sdfinfo_main(argc, argv));
+}
+#endif