diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2013-12-22 03:49:47 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2013-12-22 03:49:47 +0000 |
commit | 8796566268e8f7469f8dc6ccc41cf03d135c4d74 (patch) | |
tree | a415c4d896186f15e4c99301c81e66cedeaf7605 | |
parent | 95464d410e763b050410b4e0e405d0e9040c86bb (diff) | |
download | netpbm-mirror-8796566268e8f7469f8dc6ccc41cf03d135c4d74.tar.gz netpbm-mirror-8796566268e8f7469f8dc6ccc41cf03d135c4d74.tar.xz netpbm-mirror-8796566268e8f7469f8dc6ccc41cf03d135c4d74.zip |
cleanup
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2073 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r-- | editor/pamfunc.c | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/editor/pamfunc.c b/editor/pamfunc.c index 2f6ac682..bcec22f3 100644 --- a/editor/pamfunc.c +++ b/editor/pamfunc.c @@ -23,7 +23,7 @@ #include "shhopt.h" #include "pam.h" -enum function { +enum Function { FN_MULTIPLY, FN_DIVIDE, FN_ADD, @@ -42,17 +42,17 @@ enum function { a "max" function. */ -struct cmdlineInfo { +struct CmdlineInfo { /* All the information the user supplied in the command line, in a form easy for the program to use. */ - const char *inputFilespec; /* Filespec of input file */ - enum function function; + const char * inputFileName; + enum Function function; union { - float multiplier; - float divisor; - int adder; - int subtractor; + float multiplier; + float divisor; + int adder; + int subtractor; unsigned int max; unsigned int min; unsigned int mask; @@ -80,8 +80,8 @@ parseHex(const char * const hexString) { static void -parseCommandLine(int argc, char ** const argv, - struct cmdlineInfo * const cmdlineP) { +parseCommandLine(int argc, const char ** const argv, + struct CmdlineInfo * const cmdlineP) { /*---------------------------------------------------------------------------- Note that the file spec array we return is stored in the storage that was passed to us as the argv array. @@ -132,7 +132,7 @@ parseCommandLine(int argc, char ** const argv, opt.short_allowed = FALSE; /* We have no short (old-fashioned) options */ opt.allowNegNum = FALSE; /* We have no parms that are negative numbers */ - pm_optParseOptions3(&argc, argv, opt, sizeof(opt), 0); + pm_optParseOptions3(&argc, (char **)argv, opt, sizeof(opt), 0); /* Uses and sets argc, argv, and some of *cmdlineP and others. */ if (multiplierSpec + divisorSpec + adderSpec + subtractorSpec + @@ -186,16 +186,17 @@ parseCommandLine(int argc, char ** const argv, argc-1); if (argc-1 < 1) - cmdlineP->inputFilespec = "-"; + cmdlineP->inputFileName = "-"; else - cmdlineP->inputFilespec = argv[1]; + cmdlineP->inputFileName = argv[1]; + free(option_def); } static bool -isDyadicMaskFunction(enum function const fn) { +isDyadicMaskFunction(enum Function const fn) { return (fn == FN_AND || fn == FN_OR || fn == FN_XOR); } @@ -203,7 +204,7 @@ isDyadicMaskFunction(enum function const fn) { static bool -isMaskFunction(enum function const fn) { +isMaskFunction(enum Function const fn) { return (isDyadicMaskFunction(fn) || fn == FN_NOT); } @@ -211,7 +212,7 @@ isMaskFunction(enum function const fn) { static bool -isShiftFunction(enum function const fn) { +isShiftFunction(enum Function const fn) { return (fn == FN_SHIFTLEFT || fn == FN_SHIFTRIGHT); } @@ -219,7 +220,7 @@ isShiftFunction(enum function const fn) { static bool -isBitstringFunction(enum function const fn) { +isBitstringFunction(enum Function const fn) { return isMaskFunction(fn) || isShiftFunction(fn); } @@ -227,7 +228,7 @@ isBitstringFunction(enum function const fn) { static void -validateFunction(struct cmdlineInfo const cmdline, +validateFunction(struct CmdlineInfo const cmdline, const struct pam * const pamP) { if (isBitstringFunction(cmdline.function)) { @@ -259,7 +260,7 @@ validateFunction(struct cmdlineInfo const cmdline, static void -applyFunction(struct cmdlineInfo const cmdline, +applyFunction(struct CmdlineInfo const cmdline, struct pam const inpam, struct pam const outpam, tuple * const inputRow, @@ -330,21 +331,21 @@ applyFunction(struct cmdlineInfo const cmdline, int -main(int argc, char *argv[]) { +main(int argc, const char *argv[]) { FILE * ifP; tuple * inputRow; /* Row from input image */ tuple * outputRow; /* Row of output image */ int row; - struct cmdlineInfo cmdline; + struct CmdlineInfo cmdline; struct pam inpam; /* Input PAM image */ struct pam outpam; /* Output PAM image */ - pnm_init(&argc, argv); + pm_proginit(&argc, argv); parseCommandLine(argc, argv, &cmdline); - ifP = pm_openr(cmdline.inputFilespec); + ifP = pm_openr(cmdline.inputFileName); pnm_readpaminit(ifP, &inpam, PAM_STRUCT_SIZE(tuple_type)); @@ -374,3 +375,5 @@ main(int argc, char *argv[]) { return 0; } + + |