diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2009-09-27 21:44:29 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2009-09-27 21:44:29 +0000 |
commit | 43939e66b1d4eeb2f3799c124f3598756755005a (patch) | |
tree | 15733092de55d52421a6ea02f5a43d5f8ff24393 /converter/pgm/rawtopgm.c | |
parent | 49f4336c9bba33650573ba780b70bc501b38643e (diff) | |
download | netpbm-mirror-43939e66b1d4eeb2f3799c124f3598756755005a.tar.gz netpbm-mirror-43939e66b1d4eeb2f3799c124f3598756755005a.tar.xz netpbm-mirror-43939e66b1d4eeb2f3799c124f3598756755005a.zip |
Rebase Stable series to current Advanced: 10.47.04
git-svn-id: http://svn.code.sf.net/p/netpbm/code/stable@995 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/pgm/rawtopgm.c')
-rw-r--r-- | converter/pgm/rawtopgm.c | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/converter/pgm/rawtopgm.c b/converter/pgm/rawtopgm.c index c91c6178..0180a02c 100644 --- a/converter/pgm/rawtopgm.c +++ b/converter/pgm/rawtopgm.c @@ -11,6 +11,8 @@ */ #include <math.h> + +#include "pm_c_util.h" #include "pgm.h" #include "shhopt.h" @@ -18,13 +20,13 @@ struct cmdline_info { /* All the information the user supplied in the command line, in a form easy for the program to use. */ - const char *input_filespec; /* Filespec of input file */ + const char * inputFileName; unsigned int headerskip; float rowskip; int bottomfirst; /* the -bottomfirst/-bt option */ int autosize; /* User wants us to figure out the size */ - int width; - int height; + unsigned int width; + unsigned int height; int bpp; /* bytes per pixel in input format. 1 or 2 */ int littleendian; @@ -74,21 +76,21 @@ parse_command_line(int argc, char ** argv, /* Uses and sets argc, argv, and some of *cmdline_p and others. */ if (argc-1 == 0) { - cmdline_p->input_filespec = "-"; + cmdline_p->inputFileName = "-"; cmdline_p->autosize = TRUE; } else if (argc-1 == 1) { - cmdline_p->input_filespec = argv[1]; + cmdline_p->inputFileName = argv[1]; cmdline_p->autosize = TRUE; } else if (argc-1 == 2) { - cmdline_p->input_filespec = "-"; + cmdline_p->inputFileName = "-"; cmdline_p->autosize = FALSE; - cmdline_p->width = atoi(argv[1]); - cmdline_p->height = atoi(argv[2]); + cmdline_p->width = pm_parse_width(argv[1]); + cmdline_p->height = pm_parse_height(argv[2]); } else if (argc-1 == 3) { - cmdline_p->input_filespec = argv[3]; + cmdline_p->inputFileName = argv[3]; cmdline_p->autosize = FALSE; - cmdline_p->width = atoi(argv[1]); - cmdline_p->height = atoi(argv[2]); + cmdline_p->width = pm_parse_width(argv[1]); + cmdline_p->height = pm_parse_height(argv[2]); } else pm_error("Program takes zero, one, two, or three arguments. You " "specified %d", argc-1); @@ -107,11 +109,6 @@ parse_command_line(int argc, char ** argv, pm_error("Maxval must be less than 65536. You specified %d.", cmdline_p->maxval); - if (cmdline_p->width <= 0) - pm_error("Width must be a positive number."); - if (cmdline_p->height <= 0) - pm_error("Height must be a positive number."); - if (cmdline_p->rowskip && cmdline_p->autosize) pm_error("If you specify -rowskip, you must also give the image " "dimensions."); @@ -221,7 +218,7 @@ main(int argc, char *argv[] ) { parse_command_line(argc, argv, &cmdline); - ifp = pm_openr(cmdline.input_filespec); + ifp = pm_openr(cmdline.inputFileName); if (cmdline.autosize || cmdline.bottomfirst) { buf = pm_read_unknown_size( ifp, &nread ); |