projects
/
ctsim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
r56: Improved option processing
[ctsim.git]
/
src
/
sdf2img.c
diff --git
a/src/sdf2img.c
b/src/sdf2img.c
index 4972ac63b615f541eeaf400c086ff4420133463a..600d8d77582a43369545876a2d09a941956e882f 100644
(file)
--- a/
src/sdf2img.c
+++ b/
src/sdf2img.c
@@
-2,10
+2,17
@@
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: sdf2img.c,v 1.
1 2000/04/28 13:02:44
kevin Exp $
+** $Id: sdf2img.c,v 1.
3 2000/05/16 04:33:59
kevin Exp $
** $Log: sdf2img.c,v $
** $Log: sdf2img.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
**
**
** This program is free software; you can redistribute it and/or modify
@@
-21,8
+28,9
@@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
******************************************************************************/
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
******************************************************************************/
+
/* FILE
/* FILE
- * sdf2img.c
Convert an SDF file to a viewable format image
+ * sdf2img.c Convert an SDF file to a viewable format image
*/
#include "ct.h"
*/
#include "ct.h"
@@
-36,18
+44,8
@@
void sdf2d_to_gif (IMAGE *im, char *outfile, int nxcell, int nycell, double dens
void sdf2d_to_pgm (IMAGE *im, char *outfile, int nxcell, int nycell, double densmin, double densmax);
void sdf2d_to_pgmasc (IMAGE *im, char *outfile, int nxcell, int nycell, double densmin, double densmax);
void sdf2d_to_pgm (IMAGE *im, char *outfile, int nxcell, int nycell, double densmin, double densmax);
void sdf2d_to_pgmasc (IMAGE *im, char *outfile, int nxcell, int nycell, double densmin, double densmax);
-#define O_SCALE 1
-#define O_MIN 2
-#define O_MAX 3
-#define O_AUTO 4
-#define O_CENTER 5
-#define O_STATS 6
-#define O_VERBOSE 7
-#define O_HELP 8
-#define O_FORMAT 9
-#define O_LABELS 10
-#define O_VERSION 11
-#define O_DEBUG 12
+enum { O_SCALE, O_MIN, O_MAX, O_AUTO, O_CENTER, O_STATS, O_FORMAT, O_LABELS,
+ O_HELP, O_VERBOSE, O_VERSION, O_DEBUG };
static struct option my_options[] =
{
static struct option my_options[] =
{
@@
-95,9
+93,9
@@
static struct option my_options[] =
#define O_FORMAT_PGMASC_STR "pgmasc"
void
#define O_FORMAT_PGMASC_STR "pgmasc"
void
-usage (const char *program)
+
sdf2img_
usage (const char *program)
{
{
- fprintf(stdout, "usage: %s sdfname outfile [OPTIONS]\n", kbasename(program));
+ fprintf(stdout, "
sdf2img_
usage: %s sdfname outfile [OPTIONS]\n", kbasename(program));
fprintf(stdout, "Convert SDF2D file to an image file\n");
fprintf(stdout, "\n");
fprintf(stdout, " sdfname Name of input SDF file\n");
fprintf(stdout, "Convert SDF2D file to an image file\n");
fprintf(stdout, "\n");
fprintf(stdout, " sdfname Name of input SDF file\n");
@@
-130,11
+128,11
@@
usage (const char *program)
fprintf(stdout, " --verbose Set verbose mode\n");
fprintf(stdout, " --version Print version\n");
fprintf(stdout, " --help Print this help message\n");
fprintf(stdout, " --verbose Set verbose mode\n");
fprintf(stdout, " --version Print version\n");
fprintf(stdout, " --help Print this help message\n");
- exit(1);
}
}
+
int
int
-main (int argc, char *const argv[])
+
sdf2img_
main (int argc, char *const argv[])
{
IMAGE *im;
double densmin = HUGE_VAL, densmax = -HUGE_VAL;
{
IMAGE *im;
double densmin = HUGE_VAL, densmax = -HUGE_VAL;
@@
-168,8
+166,8
@@
main (int argc, char *const argv[])
if (endptr != endstr)
{
fprintf(stderr, "Error setting --min to %s\n", optarg);
if (endptr != endstr)
{
fprintf(stderr, "Error setting --min to %s\n", optarg);
- usage(argv[0]);
-
exit
(1);
+
sdf2img_
usage(argv[0]);
+
return
(1);
}
break;
case O_MAX:
}
break;
case O_MAX:
@@
-179,8
+177,8
@@
main (int argc, char *const argv[])
if (endptr != endstr)
{
fprintf(stderr, "Error setting --max to %s\n", optarg);
if (endptr != endstr)
{
fprintf(stderr, "Error setting --max to %s\n", optarg);
- usage(argv[0]);
-
exit
(1);
+
sdf2img_
usage(argv[0]);
+
return
(1);
}
break;
case O_SCALE:
}
break;
case O_SCALE:
@@
-189,8
+187,8
@@
main (int argc, char *const argv[])
if (endptr != endstr)
{
fprintf(stderr,"Error setting --scale to %s\n", optarg);
if (endptr != endstr)
{
fprintf(stderr,"Error setting --scale to %s\n", optarg);
- usage(argv[0]);
-
exit
(1);
+
sdf2img_
usage(argv[0]);
+
return
(1);
}
break;
case O_AUTO:
}
break;
case O_AUTO:
@@
-209,8
+207,8
@@
main (int argc, char *const argv[])
else
{
fprintf(stderr, "Invalid auto mode %s\n", optarg);
else
{
fprintf(stderr, "Invalid auto mode %s\n", optarg);
- usage(argv[0]);
-
exit
(1);
+
sdf2img_
usage(argv[0]);
+
return
(1);
}
break;
case O_CENTER:
}
break;
case O_CENTER:
@@
-221,8
+219,8
@@
main (int argc, char *const argv[])
else
{
fprintf(stderr, "Invalid center mode %s\n", optarg);
else
{
fprintf(stderr, "Invalid center mode %s\n", optarg);
- usage(argv[0]);
-
exit
(1);
+
sdf2img_
usage(argv[0]);
+
return
(1);
}
break;
case O_FORMAT:
}
break;
case O_FORMAT:
@@
-240,10
+238,10
@@
main (int argc, char *const argv[])
#endif
else {
fprintf(stderr, "Invalid format mode %s\n", optarg);
#endif
else {
fprintf(stderr, "Invalid format mode %s\n", optarg);
- usage(argv[0]);
-
exit
(1);
+
sdf2img_
usage(argv[0]);
+
return
(1);
}
}
-
break;
+ break;
case O_LABELS:
opt_labels = 1;
break;
case O_LABELS:
opt_labels = 1;
break;
@@
-265,18
+263,18
@@
main (int argc, char *const argv[])
exit(0);
case O_HELP:
case '?':
exit(0);
case O_HELP:
case '?':
- usage(argv[0]);
-
exit
(0);
+
sdf2img_
usage(argv[0]);
+
return
(0);
default:
default:
- usage(argv[0]);
-
exit
(1);
+
sdf2img_
usage(argv[0]);
+
return
(1);
}
}
if (optind + 2 != argc)
{
}
}
if (optind + 2 != argc)
{
- usage(argv[0]);
-
exit
(1);
+
sdf2img_
usage(argv[0]);
+
return
(1);
}
in_file = argv[optind];
}
in_file = argv[optind];
@@
-285,7
+283,7
@@
main (int argc, char *const argv[])
if ((im = image_load (in_file)) == NULL)
{
fprintf(stderr, "File %s does not exist\n", in_file);
if ((im = image_load (in_file)) == NULL)
{
fprintf(stderr, "File %s does not exist\n", in_file);
-
exit
(1);
+
return
(1);
}
if (opt_labels)
}
if (opt_labels)
@@
-397,7
+395,7
@@
main (int argc, char *const argv[])
else
{
fprintf(stderr, "Internal Error: Invalid auto mode %d\n", opt_auto);
else
{
fprintf(stderr, "Internal Error: Invalid auto mode %d\n", opt_auto);
-
exit
(1);
+
return
(1);
}
}
if (opt_stats)
}
}
if (opt_stats)
@@
-421,7
+419,7
@@
main (int argc, char *const argv[])
else
{
fprintf(stderr, "Internal Error: Invalid center mode %d\n", opt_center);
else
{
fprintf(stderr, "Internal Error: Invalid center mode %d\n", opt_center);
-
exit
(1);
+
return
(1);
}
if (! opt_set_max)
densmax = center + window;
}
if (! opt_set_max)
densmax = center + window;
@@
-451,7
+449,7
@@
main (int argc, char *const argv[])
else
{
fprintf(stderr, "Internal Error: Invalid format mode %d\n", opt_format);
else
{
fprintf(stderr, "Internal Error: Invalid format mode %d\n", opt_format);
-
exit
(1);
+
return
(1);
}
return (0);
}
}
return (0);
}
@@
-698,3
+696,10
@@
sdf2d_to_gif (IMAGE *im, char *outfile, int nxcell, int nycell, double densmin,
#endif
}
#endif
}
+#ifndef NO_MAIN
+int
+main (int argc, char *const argv[])
+{
+ return (sdf2img_main(argc, argv));
+}
+#endif