From 702717d224dd7c48ec17e0f60e899064b73c97ec Mon Sep 17 00:00:00 2001 From: giraffedata Date: Sun, 19 Aug 2007 17:28:15 +0000 Subject: cleanup git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@379 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- converter/other/pstopnm.c | 141 +++++++++++++++++++++++++--------------------- 1 file changed, 76 insertions(+), 65 deletions(-) (limited to 'converter/other') diff --git a/converter/other/pstopnm.c b/converter/other/pstopnm.c index 5798e340..f99478db 100644 --- a/converter/other/pstopnm.c +++ b/converter/other/pstopnm.c @@ -196,8 +196,9 @@ parseCommandLine(int argc, char ** argv, static void -add_ps_to_filespec(const char orig_filespec[], char ** const new_filespec_p, - const int verbose) { +addPsToFilespec(char const orig_filespec[], + const char ** const new_filespec_p, + bool const verbose) { /*---------------------------------------------------------------------------- If orig_filespec[] does not name an existing file, but the same name with ".ps" added to the end does, return the name with the .ps @@ -288,13 +289,13 @@ computeSizeResBlind(unsigned int const xmax, static void -compute_size_res(struct cmdlineInfo const cmdline, - enum orientation const orientation, - struct box const bordered_box, - unsigned int * const xsizeP, - unsigned int * const ysizeP, - unsigned int * const xresP, - unsigned int * const yresP) { +computeSizeRes(struct cmdlineInfo const cmdline, + enum orientation const orientation, + struct box const bordered_box, + unsigned int * const xsizeP, + unsigned int * const ysizeP, + unsigned int * const xresP, + unsigned int * const yresP) { /*---------------------------------------------------------------------------- Figure out how big the output image should be (return as *xsizeP and *ysizeP) and what output device resolution Ghostscript @@ -353,7 +354,8 @@ compute_size_res(struct cmdlineInfo const cmdline, enum postscript_language {COMMON_POSTSCRIPT, ENCAPSULATED_POSTSCRIPT}; static enum postscript_language -language_declaration(const char input_filespec[], int const verbose) { +languageDeclaration(char const input_filespec[], + bool const verbose) { /*---------------------------------------------------------------------------- Return the Postscript language in which the file declares it is written. (Except that if the file is on Standard Input or doesn't validly declare @@ -395,9 +397,9 @@ language_declaration(const char input_filespec[], int const verbose) { static struct box -compute_box_to_extract(struct box const cmdline_extract_box, - char const input_filespec[], - bool const verbose) { +computeBoxToExtract(struct box const cmdline_extract_box, + char const input_filespec[], + bool const verbose) { struct box retval; @@ -466,8 +468,8 @@ compute_box_to_extract(struct box const cmdline_extract_box, static enum orientation -compute_orientation(struct cmdlineInfo const cmdline, - struct box const extract_box) { +computeOrientation(struct cmdlineInfo const cmdline, + struct box const extract_box) { enum orientation retval; unsigned int const input_width = extract_box.urx - extract_box.llx; @@ -511,9 +513,10 @@ compute_orientation(struct cmdlineInfo const cmdline, static struct box -add_borders(const struct box input_box, - const float xborder_scale, float yborder_scale, - const int verbose) { +addBorders(struct box const input_box, + float const xborder_scale, + float const yborder_scale, + bool const verbose) { /*---------------------------------------------------------------------------- Return a box which is 'input_box' plus some borders. @@ -543,9 +546,12 @@ add_borders(const struct box input_box, static const char * -compute_pstrans(const struct box box, const enum orientation orientation, - const int xsize, const int ysize, - const int xres, const int yres) { +computePstrans(struct box const box, + enum orientation const orientation, + int const xsize, + int const ysize, + int const xres, + int const yres) { const char * retval; @@ -570,7 +576,7 @@ compute_pstrans(const struct box box, const enum orientation orientation, static const char * -compute_outfile_arg(const struct cmdlineInfo cmdline) { +computeOutfileArg(struct cmdlineInfo const cmdline) { const char *retval; /* malloc'ed */ @@ -605,7 +611,8 @@ compute_outfile_arg(const struct cmdlineInfo cmdline) { static const char * -compute_gs_device(const int format_type, const int forceplain) { +computeGsDevice(int const format_type, + bool const forceplain) { const char * basetype; const char * retval; @@ -673,19 +680,22 @@ findGhostscriptProg(const char ** const retvalP) { static void -execGhostscript(int const inputPipeFd, - const char ghostscript_device[], - const char outfile_arg[], - int const xsize, int const ysize, - int const xres, int const yres, - const char input_filespec[], int const verbose) { +execGhostscript(int const inputPipeFd, + char const ghostscript_device[], + char const outfile_arg[], + int const xsize, + int const ysize, + int const xres, + int const yres, + char const input_filespec[], + bool const verbose) { - const char *arg0; - const char *ghostscriptProg; - const char *deviceopt; - const char *outfileopt; - const char *gopt; - const char *ropt; + const char * arg0; + const char * ghostscriptProg; + const char * deviceopt; + const char * outfileopt; + const char * gopt; + const char * ropt; int rc; findGhostscriptProg(&ghostscriptProg); @@ -723,15 +733,17 @@ execGhostscript(int const inputPipeFd, - static void -execute_ghostscript(const char pstrans[], const char ghostscript_device[], - const char outfile_arg[], - const int xsize, const int ysize, - const int xres, const int yres, - const char input_filespec[], - const enum postscript_language language, - const int verbose) { +executeGhostscript(char const pstrans[], + char const ghostscript_device[], + char const outfile_arg[], + int const xsize, + int const ysize, + int const xres, + int const yres, + char const input_filespec[], + enum postscript_language const language, + bool const verbose) { int gs_exit; /* wait4 exit code from Ghostscript */ FILE *gs; /* Pipe to Ghostscript's standard input */ @@ -835,10 +847,10 @@ execute_ghostscript(const char pstrans[], const char ghostscript_device[], int -main(int argc, char **argv) { +main(int argc, char ** argv) { struct cmdlineInfo cmdline; - char *input_filespec; /* malloc'ed */ + const char * input_filespec; /* malloc'ed */ /* The file specification of our Postscript input file */ unsigned int xres, yres; /* Resolution in pixels per inch */ unsigned int xsize, ysize; /* output image size in pixels */ @@ -851,43 +863,42 @@ main(int argc, char **argv) { enum postscript_language language; enum orientation orientation; - const char *ghostscript_device; - const char *outfile_arg; - const char *pstrans; + const char * ghostscript_device; + const char * outfile_arg; + const char * pstrans; pnm_init(&argc, argv); parseCommandLine(argc, argv, &cmdline); - add_ps_to_filespec(cmdline.input_filespec, &input_filespec, - cmdline.verbose); + addPsToFilespec(cmdline.input_filespec, &input_filespec, cmdline.verbose); - extract_box = compute_box_to_extract(cmdline.extract_box, input_filespec, - cmdline.verbose); + extract_box = computeBoxToExtract(cmdline.extract_box, input_filespec, + cmdline.verbose); - language = language_declaration(input_filespec, cmdline.verbose); + language = languageDeclaration(input_filespec, cmdline.verbose); - orientation = compute_orientation(cmdline, extract_box); + orientation = computeOrientation(cmdline, extract_box); - bordered_box = add_borders(extract_box, cmdline.xborder, cmdline.yborder, - cmdline.verbose); + bordered_box = addBorders(extract_box, cmdline.xborder, cmdline.yborder, + cmdline.verbose); - compute_size_res(cmdline, orientation, bordered_box, - &xsize, &ysize, &xres, &yres); + computeSizeRes(cmdline, orientation, bordered_box, + &xsize, &ysize, &xres, &yres); - pstrans = compute_pstrans(bordered_box, orientation, - xsize, ysize, xres, yres); + pstrans = computePstrans(bordered_box, orientation, + xsize, ysize, xres, yres); - outfile_arg = compute_outfile_arg(cmdline); + outfile_arg = computeOutfileArg(cmdline); ghostscript_device = - compute_gs_device(cmdline.format_type, cmdline.forceplain); + computeGsDevice(cmdline.format_type, cmdline.forceplain); pm_message("Writing %s file", ghostscript_device); - execute_ghostscript(pstrans, ghostscript_device, outfile_arg, - xsize, ysize, xres, yres, input_filespec, - language, cmdline.verbose); + executeGhostscript(pstrans, ghostscript_device, outfile_arg, + xsize, ysize, xres, yres, input_filespec, + language, cmdline.verbose); strfree(ghostscript_device); strfree(outfile_arg); -- cgit 1.4.1