From 1bdb731976b708d57a322b0a103b635036041493 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Sat, 7 Oct 2023 05:12:45 +0000 Subject: whitespace git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4730 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- converter/pbm/atktopbm.c | 3 + converter/pbm/brushtopbm.c | 10 +- converter/pbm/cistopbm.c | 7 +- converter/pbm/cmuwmtopbm.c | 11 +- converter/pbm/ddbugtopbm.c | 19 ++-- converter/pbm/g3topbm.c | 1 + converter/pbm/macp.h | 12 +- converter/pbm/macptopbm.c | 6 +- converter/pbm/mrftopbm.c | 29 +++-- converter/pbm/pbmto10x.c | 8 +- converter/pbm/pbmtoascii.c | 5 +- converter/pbm/pbmtoatk.c | 3 + converter/pbm/pbmtobbnbg.c | 50 +++++---- converter/pbm/pbmtocis.c | 15 ++- converter/pbm/pbmtocmuwm.c | 13 ++- converter/pbm/pbmtodjvurle.c | 14 ++- converter/pbm/pbmtoepsi.c | 42 +++---- converter/pbm/pbmtoepson.c | 35 +++--- converter/pbm/pbmtoescp2.c | 3 + converter/pbm/pbmtog3.c | 3 +- converter/pbm/pbmtogem.c | 12 +- converter/pbm/pbmtoibm23xx.c | 9 +- converter/pbm/pbmtoln03.c | 1 + converter/pbm/pbmtolps.c | 3 + converter/pbm/pbmtomacp.c | 2 + converter/pbm/pbmtomatrixorbital.c | 12 +- converter/pbm/pbmtomda.c | 2 +- converter/pbm/pbmtomrf.c | 52 +++++---- converter/pbm/pbmtonokia.c | 3 - converter/pbm/pbmtopi3.c | 5 +- converter/pbm/pbmtoplot.c | 49 ++++---- converter/pbm/pbmtoppa/cutswath.c | 221 +++++++++++++++++++------------------ converter/pbm/pbmtoppa/cutswath.h | 2 +- converter/pbm/pbmtoppa/pbm.c | 1 + converter/pbm/pbmtoppa/ppa.c | 179 ++++++++++++++++-------------- converter/pbm/pbmtoppa/ppa.h | 2 +- converter/pbm/pbmtoppa/ppapbm.h | 2 +- converter/pbm/pbmtopsg3.c | 149 +++++++++++++------------ converter/pbm/pbmtoptx.c | 1 + converter/pbm/pbmtosunicon.c | 18 +-- converter/pbm/pbmtowbmp.c | 18 +-- converter/pbm/pbmtoybm.c | 3 +- converter/pbm/pbmtozinc.c | 3 + converter/pbm/pi3topbm.c | 17 +-- converter/pbm/wbmptopbm.c | 18 +-- converter/pbm/xbmtopbm.c | 2 + converter/pbm/ybmtopbm.c | 3 + 47 files changed, 596 insertions(+), 482 deletions(-) diff --git a/converter/pbm/atktopbm.c b/converter/pbm/atktopbm.c index 57782d91..eb3c071a 100644 --- a/converter/pbm/atktopbm.c +++ b/converter/pbm/atktopbm.c @@ -353,3 +353,6 @@ main(int argc, const char ** argv) { return 0; } + + + diff --git a/converter/pbm/brushtopbm.c b/converter/pbm/brushtopbm.c index ebd817be..63cd0d04 100644 --- a/converter/pbm/brushtopbm.c +++ b/converter/pbm/brushtopbm.c @@ -26,7 +26,7 @@ getinit(FILE * const ifP, bytesRead = fread(header, sizeof(header), 1, ifP); if (bytesRead !=1) - pm_error("Error reading header"); + pm_error("Error reading header"); if (header[0] != 1) pm_error("bad magic number 1"); @@ -49,6 +49,7 @@ validateEof(FILE * const ifP) { } + /* The routine for converting the raster closely resembles the pbm case of pnminvert. Input is padded up to 16 bit border. @@ -85,7 +86,7 @@ main(int argc, const char ** argv) { unsigned int i; size_t bytesRead; - bytesRead = fread (bitrow, 1, inRowBytes, ifP); + bytesRead = fread (bitrow, 1, inRowBytes, ifP); if (bytesRead != inRowBytes) pm_error("Error reading a row of data from brushfile"); @@ -102,6 +103,9 @@ main(int argc, const char ** argv) { pm_close(ifP); pm_close(stdout); - + return 0; } + + + diff --git a/converter/pbm/cistopbm.c b/converter/pbm/cistopbm.c index 591e2aa5..b62f6045 100644 --- a/converter/pbm/cistopbm.c +++ b/converter/pbm/cistopbm.c @@ -38,6 +38,8 @@ static void syntax(const char *prog) ); } + + int main(int argc, const char **argv) { FILE *ifP; @@ -176,5 +178,8 @@ int main(int argc, const char **argv) } pbm_writepbm(stdout, bits, width, height, 0); pm_close(ifP); - return 0; + return 0; } + + + diff --git a/converter/pbm/cmuwmtopbm.c b/converter/pbm/cmuwmtopbm.c index be8a7fc1..c2e3bde0 100644 --- a/converter/pbm/cmuwmtopbm.c +++ b/converter/pbm/cmuwmtopbm.c @@ -87,7 +87,7 @@ main(int argc, inputFileName = argv[1]; else inputFileName = "-"; - + ifP = pm_openr(inputFileName); readCmuwmHeader(ifP, &cols, &rows, &depth); @@ -105,15 +105,15 @@ main(int argc, bytesRead = fread(bitrow, 1, bytesPerRow, ifP); if (bytesRead != bytesPerRow) pm_error("CWU window manager bitmap EOF / read error"); - + /* Invert all bits in row - raster formats are similar. CMUWM Black:0 White:1 End of row padded with 1 PBM Black:1 White:0 End preferably padded with 0 */ - + for (byteSeq = 0; byteSeq < bytesPerRow; ++byteSeq) bitrow[byteSeq] = ~bitrow[byteSeq]; - + pbm_writepbmrow_packed(stdout, bitrow, cols, 0); } @@ -123,3 +123,6 @@ main(int argc, return 0; } + + + diff --git a/converter/pbm/ddbugtopbm.c b/converter/pbm/ddbugtopbm.c index 8b0a6d0e..75b39b77 100644 --- a/converter/pbm/ddbugtopbm.c +++ b/converter/pbm/ddbugtopbm.c @@ -13,15 +13,15 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. - * + * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * Adapted to Netpbm by Bryan Henderson 2003.08.09. Bryan got his copy * from ftp:ibiblio.com/pub/linux/apps/graphics/convert, dated 2002.08.21. @@ -37,7 +37,7 @@ #include "mallocvar.h" /* this is basically UncompressSketch() from DiddleBug 2.50's diddlebug.c */ -static void +static void uncompress_sketch(unsigned char * const cPtr, unsigned char * const uPtr, int const size) { @@ -79,7 +79,7 @@ make_noname(void) { do { num++; - if (out != NULL) + if (out != NULL) fclose(out); sprintf(name, "sketch-%04d.pbm", num); } while (num<10000 && (out = fopen(name, "rb")) != NULL); @@ -92,7 +92,7 @@ make_noname(void) { -int +int main(int argc, char ** argv) { FILE * const in=stdin; @@ -147,7 +147,7 @@ main(int argc, char ** argv) { for (ptr = nameptr; *ptr; ++ptr) { if (!isalnum(*ptr) && strchr("()-_+=[]:;,.<>?",*ptr) == NULL) *ptr='_'; - if (isupper(*ptr)) + if (isupper(*ptr)) *ptr = tolower(*ptr); } @@ -161,7 +161,7 @@ main(int argc, char ** argv) { pm_message("extracting sketch %2d as `%s'", f, outfilename); if((out=fopen(outfilename,"wb"))==NULL) - pm_message("WARNING: couldn't open file '%s'. Carrying on...", + pm_message("WARNING: couldn't open file '%s'. Carrying on...", outfilename); else { pbm_writepbminit(out, 160, 160, FALSE); @@ -171,3 +171,6 @@ main(int argc, char ** argv) { } return 0; } + + + diff --git a/converter/pbm/g3topbm.c b/converter/pbm/g3topbm.c index f9655fce..56462768 100644 --- a/converter/pbm/g3topbm.c +++ b/converter/pbm/g3topbm.c @@ -249,6 +249,7 @@ readBitAndDetectEol(struct BitStream * const bitStreamP, } + static void initBitStream(struct BitStream * const bitStreamP, FILE * const fileP, diff --git a/converter/pbm/macp.h b/converter/pbm/macp.h index d00dc5c9..dcd96af9 100644 --- a/converter/pbm/macp.h +++ b/converter/pbm/macp.h @@ -6,11 +6,11 @@ #ifndef MACP_H_INCLUDED #define MACP_H_INCLUDED -#define MACBIN_HEAD_LEN 128 -#define MACP_HEAD_LEN 512 -#define MACP_ROWS 720 -#define MACP_COLCHARS 72 -#define MACP_COLS ((MACP_COLCHARS) * 8) -#define MACP_BYTES ((MACP_COLCHARS) * (MACP_ROWS)) +#define MACBIN_HEAD_LEN 128 +#define MACP_HEAD_LEN 512 +#define MACP_ROWS 720 +#define MACP_COLCHARS 72 +#define MACP_COLS ((MACP_COLCHARS) * 8) +#define MACP_BYTES ((MACP_COLCHARS) * (MACP_ROWS)) #endif diff --git a/converter/pbm/macptopbm.c b/converter/pbm/macptopbm.c index db628b6c..b5dbcbad 100644 --- a/converter/pbm/macptopbm.c +++ b/converter/pbm/macptopbm.c @@ -133,7 +133,6 @@ scanMacBinaryHeader( const unsigned char * rBuff ) { - static void skipHeader( FILE * const ifP ) { /*-------------------------------------------------------------------------- @@ -227,7 +226,6 @@ readChar( FILE * const ifP ) { - static void ReadMacPaintFile( FILE * const ifP, int * outOfSyncP, @@ -291,6 +289,7 @@ ReadMacPaintFile( FILE * const ifP, } + int main( int argc, char * argv[]) { @@ -354,3 +353,6 @@ main( int argc, char * argv[]) { pm_close( stdout ); exit( 0 ); } + + + diff --git a/converter/pbm/mrftopbm.c b/converter/pbm/mrftopbm.c index 32f36ef3..07cf0ed2 100644 --- a/converter/pbm/mrftopbm.c +++ b/converter/pbm/mrftopbm.c @@ -20,15 +20,15 @@ static int bitbox; static int bitsleft; -static void +static void bit_init(void) { - bitbox=0; + bitbox=0; bitsleft=0; } -static int +static int bit_input(FILE * const in) { if (bitsleft == 0) { int rc; @@ -45,7 +45,7 @@ bit_input(FILE * const in) { -static void +static void doSquare(FILE * const ifP, unsigned char * const image, unsigned int const ulCol, @@ -60,7 +60,7 @@ doSquare(FILE * const ifP, image[], which is a concatenation of rows 'imageWidth' pixels wide, one byte per pixel. -----------------------------------------------------------------------------*/ - if (size == 1 || bit_input(ifP)) { + if (size == 1 || bit_input(ifP)) { /* It's all black or all white. Next bit says which. */ unsigned int const c = bit_input(ifP); @@ -100,7 +100,7 @@ writeOutput(FILE * const ofP, int const cols, int const rows, const unsigned char * const image) { - + /* w64 is units-of-64-bits width */ unsigned int const w64 = (cols+63)/64; @@ -113,9 +113,9 @@ writeOutput(FILE * const ofP, for (row = 0; row < rows; ++row) { unsigned int col; - + for (col = 0; col < cols; ++col) - bitrow[col] = + bitrow[col] = (image[row * (w64*64) + col] == 1) ? PBM_WHITE : PBM_BLACK; pbm_writepbmrow(ofP, bitrow, cols, FALSE); @@ -173,7 +173,7 @@ readMrfImage(FILE * const ifP, image = calloc(w64*h64*64*64, 1); if (image == NULL) pm_error("Unable to get memory for raster"); - + /* now recursively input squares. */ bit_init(); @@ -191,7 +191,7 @@ readMrfImage(FILE * const ifP, -int +int main(int argc, char *argv[]) { FILE *ifP; @@ -213,7 +213,7 @@ main(int argc, char *argv[]) { pm_error("Too many arguments: %d. Only argument is input file", argc-1); - if (argc-1 == 1) + if (argc-1 == 1) ifP = pm_openr(argv[1]); else ifP = stdin; @@ -221,9 +221,9 @@ main(int argc, char *argv[]) { ofP = stdout; readMrfImage(ifP, expandAll, &image, &cols, &rows); - + pm_close(ifP); - + writeOutput(ofP, cols, rows, image); free(image); @@ -233,6 +233,3 @@ main(int argc, char *argv[]) { - - - diff --git a/converter/pbm/pbmto10x.c b/converter/pbm/pbmto10x.c index d040b3ed..99f35847 100644 --- a/converter/pbm/pbmto10x.c +++ b/converter/pbm/pbmto10x.c @@ -23,8 +23,8 @@ static void -outstripe(char * const stripe, - char * const sP, +outstripe(char * const stripe, + char * const sP, int const reschar) { char * p; @@ -32,7 +32,7 @@ outstripe(char * const stripe, p = sP; /* initial value */ /* scan backwards, removing empty columns */ - while (p != stripe) + while (p != stripe) if (*--p != 0) { ++p; break; @@ -199,7 +199,7 @@ main(int argc, const char ** argv) { fname = argv[1]; else fname = "-"; - + ifP = pm_openr(fname); pbm_readpbminit(ifP, &cols, &rows, &format); diff --git a/converter/pbm/pbmtoascii.c b/converter/pbm/pbmtoascii.c index 0305a47b..634bea67 100644 --- a/converter/pbm/pbmtoascii.c +++ b/converter/pbm/pbmtoascii.c @@ -272,7 +272,7 @@ main(int argc, const char ** argv) { } else ifP = stdin; - + if ( argn != argc ) pm_usage( usage ); @@ -282,3 +282,6 @@ main(int argc, const char ** argv) { return 0; } + + + diff --git a/converter/pbm/pbmtoatk.c b/converter/pbm/pbmtoatk.c index 5f2b625c..d58d7c7d 100644 --- a/converter/pbm/pbmtoatk.c +++ b/converter/pbm/pbmtoatk.c @@ -178,3 +178,6 @@ main(int argc, const char ** argv) { return 0; } + + + diff --git a/converter/pbm/pbmtobbnbg.c b/converter/pbm/pbmtobbnbg.c index e97ef4f2..f9191a49 100644 --- a/converter/pbm/pbmtobbnbg.c +++ b/converter/pbm/pbmtobbnbg.c @@ -9,7 +9,7 @@ ** documentation. This software is provided "as is" without express or ** implied warranty. */ - + /* ** Changed to take advantage of negative Packed Pixed Data values and ** supply ANSI-standard string terminator. Paul Milazzo, 28 May 1990. @@ -17,7 +17,7 @@ #include "pbm.h" -static void write16 ARGS(( unsigned int )); +static void write16 ARGS(( unsigned int )); static int nco; @@ -72,10 +72,10 @@ char **argv; { if (bitrow[i]==PBM_BLACK) sixteen |= mask; mask >>= 1; if (mask == 0) - { mask = 0x8000; - write16(sixteen); - sixteen = 0; - } + { mask = 0x8000; + write16(sixteen); + sixteen = 0; + } } if (mask != 0x8000) { write16(sixteen); @@ -85,6 +85,8 @@ char **argv; exit(0); } + + #ifdef POSITIVE_VALUES_ONLY static void write16(sixteen) @@ -113,40 +115,40 @@ unsigned int sixteen; */ static void write16 (word) -unsigned int word; +unsigned int word; { - int high; - int mid; - int low; - int signChar; + int high; + int mid; + int low; + int signChar; if (nco > 75) { - putchar ('\n'); - nco = 0; + putchar ('\n'); + nco = 0; } if (word > 0x7fff) { - word = (unsigned int) (0x10000L - (long) word); - signChar = ' '; + word = (unsigned int) (0x10000L - (long) word); + signChar = ' '; } else - signChar = '0'; + signChar = '0'; high = (word >> 10) + '@'; - mid = ((word & 0x3f0) >> 4) + '@'; - low = (word & 0xf) + signChar; + mid = ((word & 0x3f0) >> 4) + '@'; + low = (word & 0xf) + signChar; if (high != '@') { - printf ("%c%c%c", high, mid, low); - nco += 3; + printf ("%c%c%c", high, mid, low); + nco += 3; } else if (mid != '@') { - printf ("%c%c", mid, low); - nco += 2; + printf ("%c%c", mid, low); + nco += 2; } else { - putchar (low); - nco++; + putchar (low); + nco++; } } #endif diff --git a/converter/pbm/pbmtocis.c b/converter/pbm/pbmtocis.c index 9bb42c56..c7a29055 100644 --- a/converter/pbm/pbmtocis.c +++ b/converter/pbm/pbmtocis.c @@ -42,6 +42,8 @@ static void syntax(const char *prog) ); } + + int main(int argc, const char **argv) { FILE *ofP = stdout; @@ -86,7 +88,7 @@ int main(int argc, const char **argv) pm_keymatch(argv[n], "-W", 2) || pm_keymatch(argv[n], "--whitebg", 9)) { - bg = PBM_WHITE; + bg = PBM_WHITE; continue; } if (argv[n][0] == '-' && argv[n][1] != 0) @@ -126,7 +128,7 @@ int main(int argc, const char **argv) run = 0; while (y < outh) { - if (x < width && y < height) + if (x < width && y < height) { cell = bits[y][x]; if (inverse) cell ^= (PBM_BLACK ^ PBM_WHITE); @@ -137,11 +139,11 @@ int main(int argc, const char **argv) { ++run; if (run > MAXRUNLENGTH) - { + { fputc(0x20 + MAXRUNLENGTH, ofP); fputc(0x20, ofP); run -= MAXRUNLENGTH; - } + } } else /* change */ { @@ -166,5 +168,8 @@ int main(int argc, const char **argv) fputc(0x47, ofP); fputc(0x4E, ofP); pm_close(ifP); - return 0; + return 0; } + + + diff --git a/converter/pbm/pbmtocmuwm.c b/converter/pbm/pbmtocmuwm.c index 983ea491..f166b5ba 100644 --- a/converter/pbm/pbmtocmuwm.c +++ b/converter/pbm/pbmtocmuwm.c @@ -67,18 +67,18 @@ main(int argc, inputFileName = argv[1]; else inputFileName = "-"; - + ifP = pm_openr(inputFileName); pbm_readpbminit(ifP, &cols, &rows, &format); bitrow = pbm_allocrow_packed(cols); putinit(rows, cols); - - /* Convert PBM raster data to CMUWM and write */ + + /* Convert PBM raster data to CMUWM and write */ for (row = 0; row < rows; ++row) { unsigned int const bytesPerRow = pbm_packed_bytes(cols); - unsigned char const padding = + unsigned char const padding = (cols % 8 == 0) ? 0x00 : ((unsigned char) ~0 >> (cols % 8)); unsigned int i; @@ -95,7 +95,7 @@ main(int argc, bitrow[i] = ~bitrow[i]; bitrow[bytesPerRow-1] |= padding; /* Set row end pad bits */ - + bytesWritten = fwrite(bitrow, 1, bytesPerRow, stdout); if (bytesWritten != bytesPerRow) pm_error("fwrite() failed to write CMU window manager bitmap"); @@ -104,3 +104,6 @@ main(int argc, pm_close(ifP); return 0; } + + + diff --git a/converter/pbm/pbmtodjvurle.c b/converter/pbm/pbmtodjvurle.c index 83e99ec4..598abfbb 100644 --- a/converter/pbm/pbmtodjvurle.c +++ b/converter/pbm/pbmtodjvurle.c @@ -1,7 +1,7 @@ /* Convert a PBM image into the DjVu Bitonal RLE format described in the csepdjvu(1) documentation - + Copyright (c) 2004 Scott Pakin All rights reserved. @@ -9,7 +9,7 @@ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - + 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright @@ -17,7 +17,7 @@ documentation and/or other materials provided with the distribution. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. @@ -48,8 +48,9 @@ writebyte(FILE * const ofP, } + /* Write a run length to the RLE file. */ -static void +static void write_rle(FILE * const rlefile, uint32_t const tallyArg) { @@ -83,7 +84,7 @@ write_rle(FILE * const rlefile, -int +int main (int argc, const char * argv[]) { FILE * const rlefile = stdout; /* Generated Bitonal RLE file */ @@ -144,3 +145,6 @@ main (int argc, const char * argv[]) { return 0; } + + + diff --git a/converter/pbm/pbmtoepsi.c b/converter/pbm/pbmtoepsi.c index 87985a1f..7ffd6103 100644 --- a/converter/pbm/pbmtoepsi.c +++ b/converter/pbm/pbmtoepsi.c @@ -45,7 +45,7 @@ struct cmdlineInfo { static void -parseDpi(char * const dpiOpt, +parseDpi(char * const dpiOpt, unsigned int * const dpiXP, unsigned int * const dpiYP) { @@ -53,7 +53,7 @@ parseDpi(char * const dpiOpt, unsigned int dpiX, dpiY; dpiX = strtol(dpiOpt, &dpistr2, 10); - if (dpistr2 == dpiOpt) + if (dpistr2 == dpiOpt) pm_error("Invalid value for -dpi: '%s'. Must be either number " "or NxN ", dpiOpt); else { @@ -64,7 +64,7 @@ parseDpi(char * const dpiOpt, char * dpistr3; dpistr2++; /* Move past 'x' */ - dpiY = strtol(dpistr2, &dpistr3, 10); + dpiY = strtol(dpistr2, &dpistr3, 10); if (dpistr3 != dpistr2 && *dpistr3 == '\0') { *dpiXP = dpiX; *dpiYP = dpiY; @@ -77,6 +77,7 @@ parseDpi(char * const dpiOpt, } + static void parseCommandLine(int argc, const char ** const argv, struct cmdlineInfo * const cmdlineP) { @@ -105,17 +106,17 @@ parseCommandLine(int argc, const char ** const argv, pm_optParseOptions3(&argc, (char **)argv, opt, sizeof(opt), 0); /* Uses and sets argc, argv, and some of *cmdlineP and others. */ - + if (dpiOptSpec) parseDpi(dpiOpt, &cmdlineP->dpiX, &cmdlineP->dpiY); else cmdlineP->dpiX = cmdlineP->dpiY = 72; - + if ((argc-1) > 1) pm_error("Too many arguments (%d). Only argument is input file name", argc-1); - + if (argc-1 == 0) cmdlineP->inputFileName = "-"; else @@ -125,7 +126,7 @@ parseCommandLine(int argc, const char ** const argv, static void -findPrincipalImage(bit ** const bits, +findPrincipalImage(bit ** const bits, unsigned int const rows, unsigned int const cols, unsigned int * const topP, @@ -151,25 +152,25 @@ findPrincipalImage(bit ** const bits, bottom = 0; left = cols; right = 0; - + for (row = 0; row < rows; ++row) { unsigned int col; for (col = 0; col < cols; ++col) { if (bits[row][col] == PBM_BLACK) { - if (row < top) + if (row < top) top = row; - if (row > bottom) + if (row > bottom) bottom = row; - if (col < left) + if (col < left) left = col; - if (col > right) + if (col > right) right = col; } } } if (top > bottom) { - /* No black pixels encountered */ + /* No black pixels encountered */ pm_message("Blank page"); top = 0; left = 0; @@ -194,8 +195,8 @@ outputBoundingBox(int const top, int const bottom, float const xScale = 72.0 / dpiX; float const yScale = 72.0 / dpiY; - printf("%%%%BoundingBox: %d %d %d %d\n", - ROUND(left*xScale), ROUND((rows - bottom)*yScale), + printf("%%%%BoundingBox: %d %d %d %d\n", + ROUND(left*xScale), ROUND((rows - bottom)*yScale), ROUND(right*xScale), ROUND((rows - top)*yScale)); } @@ -244,7 +245,7 @@ main(int argc, const char * argv[]) { */ pm_proginit(&argc, argv); - + parseCommandLine(argc, argv, &cmdline); ifP = pm_openr(cmdline.inputFileName); @@ -255,12 +256,12 @@ main(int argc, const char * argv[]) { printf("%%!PS-Adobe-2.0 EPSF-1.2\n"); - outputBoundingBox(top, bottom, left, right, rows, + outputBoundingBox(top, bottom, left, right, rows, cmdline.dpiX, cmdline.dpiY); if (!cmdline.bbonly) { int row; - printf("%%%%BeginPreview: %d %d 1 %d\n", + printf("%%%%BeginPreview: %d %d 1 %d\n", right - left + 1, bottom - top + 1, bottom - top + 1); for (row = top; row <= bottom; row++) { @@ -274,7 +275,7 @@ main(int argc, const char * argv[]) { if (outChars == 72) { printf("\n%% "); outChars = 2; - } + } printf("%02x", eightPixels(bits, row, col, cols)); outChars += 2; @@ -287,3 +288,6 @@ main(int argc, const char * argv[]) { } return 0; } + + + diff --git a/converter/pbm/pbmtoepson.c b/converter/pbm/pbmtoepson.c index 122a438f..69742368 100644 --- a/converter/pbm/pbmtoepson.c +++ b/converter/pbm/pbmtoepson.c @@ -1,7 +1,7 @@ /* pbmtoeps.c - read a PBM image and produce Epson graphics ** ** Copyright (C) 1990 by John Tiller (tiller@galois.msfc.nasa.gov) -** and Jef Poskanzer. +** and Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided @@ -42,12 +42,12 @@ struct CmdlineInfo { static void -parseCommandLine(int argc, +parseCommandLine(int argc, const char ** argv, struct CmdlineInfo * cmdlineP ) { /*---------------------------------------------------------------------------- Parse program command line described in Unix standard form by argc - and argv. Return the information in the options as *cmdlineP. + and argv. Return the information in the options as *cmdlineP. If command line is internally inconsistent (invalid options, etc.), issue error message to stderr and abort program. @@ -107,7 +107,7 @@ parseCommandLine(int argc, "Only recognized values are 'escp9' and 'escp'", protocol); } - + if (adjacentSpec && nonadjacentSpec) pm_error("You can't specify both -adjacent and -nonadjacent"); else if (adjacentSpec) @@ -143,7 +143,7 @@ lineWidth(const bit ** const stripeBits, -----------------------------------------------------------------------------*/ unsigned int col; unsigned int endSoFar; - + endSoFar = 0; for (col = 0; col < cols; ++ col) { @@ -177,14 +177,14 @@ printStripe(const bit ** const stripeBits, /* Print header of Select Bit Image command */ printf("%c%c%c%c%c", esc, '*', m, cols % 256, cols / 256); - + /* Print the data part of the Select Bit Image command */ for (col = 0; col < cols; ++col) { unsigned int stripeRow; int val; - + val = 0; - for (stripeRow = 0; stripeRow < stripeRows; ++stripeRow) + for (stripeRow = 0; stripeRow < stripeRows; ++stripeRow) if (stripeBits[stripeRow][col] == PBM_BLACK) val |= (1 << (8-1-stripeRow)); putchar(val); @@ -213,7 +213,7 @@ computeM(enum epsonProtocol const protocol, } } break; - case 60: + case 60: if (adjacence == ADJACENT_NO) pm_error("You can't print at %u dpi " "with adjacent dot printing", dpi); @@ -236,7 +236,7 @@ computeM(enum epsonProtocol const protocol, break; case 72: if (protocol != ESCP9) - pm_error("%u dpi is possible only with the ESC/P 9-pin protocol", + pm_error("%u dpi is possible only with the ESC/P 9-pin protocol", dpi); if (adjacence == ADJACENT_NO) pm_error("You can't print at %u dpi " @@ -251,7 +251,7 @@ computeM(enum epsonProtocol const protocol, break; case 144: if (protocol != ESCP9) - pm_error("%u dpi is possible only with the ESC/P 9-pin protocol", + pm_error("%u dpi is possible only with the ESC/P 9-pin protocol", dpi); if (adjacence == ADJACENT_NO) pm_error("You can't print at %u dpi " @@ -273,13 +273,13 @@ convertToEpson(const bit ** const bits, enum epsonProtocol const protocol, unsigned int const dpi, enum adjacence const adjacence) { - + unsigned int const rowsPerStripe = 8; unsigned int const stripeCt = (rows + rowsPerStripe-1) / rowsPerStripe; unsigned int stripe; char m; - + computeM(protocol, dpi, adjacence, &m); /* Change line spacing to 8/72 inches. */ @@ -292,10 +292,10 @@ convertToEpson(const bit ** const bits, for (stripe = 0; stripe < stripeCt; ++stripe) { const bit ** const stripeBits = &bits[stripe*rowsPerStripe]; - unsigned int const stripeRows = + unsigned int const stripeRows = MIN(rowsPerStripe, rows - stripe * rowsPerStripe); /* Number of rows in this stripe (8 for all but bottom stripe) */ - + unsigned int const endcol = lineWidth(stripeBits, cols, stripeRows); /* Column where right margin (contiguous white area at right end of stripe) begins. Zero if entire stripe is white. @@ -332,10 +332,13 @@ main(int argc, const char ** argv) { pm_close(ifP); - convertToEpson(bits, cols, rows, + convertToEpson(bits, cols, rows, cmdline.protocol, cmdline.dpi, cmdline.adjacence); pbm_freearray(bits, rows); return 0; } + + + diff --git a/converter/pbm/pbmtoescp2.c b/converter/pbm/pbmtoescp2.c index 942ecec9..54a77e44 100644 --- a/converter/pbm/pbmtoescp2.c +++ b/converter/pbm/pbmtoescp2.c @@ -245,3 +245,6 @@ main(int argc, const char * argv[]) { return 0; } + + + diff --git a/converter/pbm/pbmtog3.c b/converter/pbm/pbmtog3.c index f034b466..48de8885 100644 --- a/converter/pbm/pbmtog3.c +++ b/converter/pbm/pbmtog3.c @@ -145,7 +145,7 @@ flushBuffer(struct OutStream * const outP) { outbytes = pm_bigendFromUint32( buffer.intBuffer << (fullBuffer - buffer.bitCount)); if (outP->reverseBits) - reversebuffer((unsigned char *)&outbytes, bytesToWrite); + reversebuffer((unsigned char *)&outbytes, bytesToWrite); rc = fwrite((unsigned char *)&outbytes, 1, bytesToWrite, outP->fp); if (rc != bytesToWrite) pm_error("Output error"); @@ -153,6 +153,7 @@ flushBuffer(struct OutStream * const outP) { } + #if 1==0 static void putbitsDump(struct OutStream * const outP, diff --git a/converter/pbm/pbmtogem.c b/converter/pbm/pbmtogem.c index 4fd30e92..64bcb761 100644 --- a/converter/pbm/pbmtogem.c +++ b/converter/pbm/pbmtogem.c @@ -32,7 +32,7 @@ * * Deficiencies: * Compression of repeated scanlines not added -* +* * Johann Haider (jh@fortec.tuwien.ac.at) * * 94/01/31 Andreas Schwab (schwab@ls5.informatik.uni-dortmund.de) @@ -85,6 +85,8 @@ putinit (int const rows, int const cols) linerepeat = -1; } + + static void putitem( ) { @@ -119,6 +121,7 @@ putstring ( unsigned char *p, int n) } + static void flushrow( ) { @@ -173,7 +176,7 @@ flushrow( ) p++; col--; } - } + } if (p > outp) putstring (outp, p-outp); if (ferror (stdout)) @@ -181,6 +184,7 @@ flushrow( ) } + static void putrow( ) { @@ -203,6 +207,7 @@ putrow( ) } + int main( int argc, char* argv[]) { @@ -246,3 +251,6 @@ main( int argc, char* argv[]) exit( 0 ); } + + + diff --git a/converter/pbm/pbmtoibm23xx.c b/converter/pbm/pbmtoibm23xx.c index 3f1f9679..86103ba6 100644 --- a/converter/pbm/pbmtoibm23xx.c +++ b/converter/pbm/pbmtoibm23xx.c @@ -120,7 +120,7 @@ parseCommandLine(int argc, char ** const argv, /* Read all pbm images from a filehandle and print them */ -static void +static void process_handle(FILE * const fh, unsigned char const graph_mode, unsigned int const passes) { @@ -155,7 +155,7 @@ process_handle(FILE * const fh, for(bitline = 0; bitline < 8; ++bitline) for(pass = 0; pass < passes; ++pass) /* don't read beyond the end of the image if - height is not a multiple of passes + height is not a multiple of passes */ if(y + bitline * passes + pass < rows) { pbm_readpbmrow(fh, row, cols, format); @@ -188,7 +188,7 @@ process_handle(FILE * const fh, -int +int main(int argc,char **argv) { struct cmdlineInfo cmdline; @@ -212,3 +212,6 @@ main(int argc,char **argv) { return 0; } + + + diff --git a/converter/pbm/pbmtoln03.c b/converter/pbm/pbmtoln03.c index 235429cd..cf1f7959 100644 --- a/converter/pbm/pbmtoln03.c +++ b/converter/pbm/pbmtoln03.c @@ -268,3 +268,4 @@ main (int argc, char **argv) { } + diff --git a/converter/pbm/pbmtolps.c b/converter/pbm/pbmtolps.c index d974fcb2..2c6b01a0 100644 --- a/converter/pbm/pbmtolps.c +++ b/converter/pbm/pbmtolps.c @@ -251,3 +251,6 @@ main(int argc, const char *argv[]) { return 0; } + + + diff --git a/converter/pbm/pbmtomacp.c b/converter/pbm/pbmtomacp.c index 4897e6d0..5fa54ad6 100644 --- a/converter/pbm/pbmtomacp.c +++ b/converter/pbm/pbmtomacp.c @@ -441,3 +441,5 @@ main(int argc, const char *argv[]) { return 0; } + + diff --git a/converter/pbm/pbmtomatrixorbital.c b/converter/pbm/pbmtomatrixorbital.c index 41f8e260..f91fd5ff 100644 --- a/converter/pbm/pbmtomatrixorbital.c +++ b/converter/pbm/pbmtomatrixorbital.c @@ -14,7 +14,7 @@ static void -generateMo(FILE * const ofP, +generateMo(FILE * const ofP, bit ** const bits, unsigned int const cols, unsigned int const rows) { @@ -28,7 +28,7 @@ generateMo(FILE * const ofP, unsigned int row; unsigned int outbitpos; unsigned char outchar; - + outbitpos = 0; /* Start at 1st bit of 1st output byte */ for (row = 0; row < rows; ++row) { @@ -38,7 +38,7 @@ generateMo(FILE * const ofP, outchar |= bits[row][col] << outbitpos; - if (outbitpos == 7) + if (outbitpos == 7) /* We filled up a byte. Output it. */ fputc(outchar, ofP); @@ -65,13 +65,13 @@ main(int argc, const char ** argv) { if (argc-1 > 1) pm_error("Too many arguments (%u). The only valid argument is an " "input file name.", argc-1); - else if (argc-1 == 1) + else if (argc-1 == 1) inputFilename = argv[1]; else inputFilename = "-"; ifP = pm_openr(inputFilename); - + bits = pbm_readpbm(ifP, &cols, &rows); if (rows > 255) @@ -80,7 +80,7 @@ main(int argc, const char ** argv) { pm_error("Image is too wide: %u cols. Max width: 255 cols", cols); generateMo(stdout, bits, cols, rows); - + pm_close(ifP); pbm_freearray(bits, rows); diff --git a/converter/pbm/pbmtomda.c b/converter/pbm/pbmtomda.c index a39cf1a7..2ed862fc 100644 --- a/converter/pbm/pbmtomda.c +++ b/converter/pbm/pbmtomda.c @@ -1,4 +1,3 @@ - /*************************************************************************** PBMTOMDA: Convert PBM to Microdesign area @@ -106,6 +105,7 @@ encode(bit ** const bits, } + static void doTranslation(bit ** const bits, unsigned int const nOutCols, diff --git a/converter/pbm/pbmtomrf.c b/converter/pbm/pbmtomrf.c index e7b7fcc9..a9243561 100644 --- a/converter/pbm/pbmtomrf.c +++ b/converter/pbm/pbmtomrf.c @@ -23,18 +23,18 @@ typedef struct bitOut { -static void +static void bit_init(struct bitOut * const bitOutP, FILE * const ofP) { - bitOutP->bitbox = 0; + bitOutP->bitbox = 0; bitOutP->bitsleft = 8; bitOutP->fileP = ofP; } -static void +static void bit_output(struct bitOut * const bitOutP, int const bit) { @@ -49,7 +49,7 @@ bit_output(struct bitOut * const bitOutP, -static void +static void bit_flush(struct bitOut * const bitOutP) { /* there are never 0 bits left outside of bit_output, but * if 8 bits are left here there's nothing to flush, so @@ -86,7 +86,7 @@ determineBlackWhiteOrMix(const unsigned char * const image, t += image[rowOfImage * imageWidth + colOfImage]; } - } + } /* if the total's 0, it's black. if it's size*size, it's white. */ if (t == 0) { *oneColorP = TRUE; @@ -100,7 +100,7 @@ determineBlackWhiteOrMix(const unsigned char * const image, -static void +static void doSquare(bitOut * const bitOutP, const unsigned char * const image, unsigned int const ulCol, @@ -148,7 +148,7 @@ doSquare(bitOut * const bitOutP, } } } - + static void @@ -186,7 +186,7 @@ fiddleBottomEdge(unsigned char * const image, unsigned int const pw, unsigned int const ph, bool * const flippedP) { - + unsigned int col; unsigned int t; @@ -207,7 +207,6 @@ fiddleBottomEdge(unsigned char * const image, - static void fiddleBottomRightCorner(unsigned char * const image, unsigned int const w, @@ -218,7 +217,7 @@ fiddleBottomRightCorner(unsigned char * const image, for (row = h; row < ph; ++row) { unsigned int col; - + for (col = w; col < pw; ++col) image[row*pw + col] = 1; } @@ -226,7 +225,7 @@ fiddleBottomRightCorner(unsigned char * const image, -static void +static void fiddleEdges(unsigned char * const image, int const cols, int const rows) { @@ -247,9 +246,9 @@ fiddleEdges(unsigned char * const image, * So, all we do is flip the runoff area of an edge to white * if more than half of the pixels on that edge are * white. Then for the bottom-right runoff square (if there is - * one), we flip it if we flipped both edges. + * one), we flip it if we flipped both edges. */ - + /* w64 is units-of-64-bits width, h64 same for height */ unsigned int const w64 = (cols + 63) / 64; unsigned int const h64 = (rows + 63) / 64; @@ -259,28 +258,28 @@ fiddleEdges(unsigned char * const image, bool flippedRight, flippedBottom; - if (cols % 64 != 0) + if (cols % 64 != 0) fiddleRightEdge(image, cols, rows, pw, &flippedRight); else flippedRight = FALSE; - if (rows % 64 != 0) + if (rows % 64 != 0) fiddleBottomEdge(image, cols, rows, pw, ph, &flippedBottom); else flippedBottom = FALSE; - if (flippedRight && flippedBottom) + if (flippedRight && flippedBottom) fiddleBottomRightCorner(image, cols, rows, pw, ph); } static void -readPbmImage(FILE * const ifP, +readPbmImage(FILE * const ifP, unsigned char ** const imageP, int * const colsP, int * const rowsP) { - + /* w64 is units-of-64-bits width, h64 same for height */ unsigned int w64, h64; @@ -289,7 +288,7 @@ readPbmImage(FILE * const ifP, int cols, rows, format; unsigned int row; bit * bitrow; - + pbm_readpbminit(ifP, &cols, &rows, &format); w64 = (cols + 63) / 64; @@ -302,7 +301,7 @@ readPbmImage(FILE * const ifP, image = calloc(w64*h64*64*64, 1); if (image == NULL) pm_error("Unable to get memory for raster"); - + /* get bytemap image rounded up into mod 64x64 squares */ bitrow = pbm_allocrow(cols); @@ -324,7 +323,7 @@ readPbmImage(FILE * const ifP, static void -outputMrf(FILE * const ofP, +outputMrf(FILE * const ofP, unsigned char * const image, unsigned int const cols, unsigned int const rows) { @@ -340,7 +339,7 @@ outputMrf(FILE * const ofP, fprintf(ofP, "%c%c%c%c", cols >> 24, cols >> 16, cols >> 8, cols >> 0); fprintf(ofP, "%c%c%c%c", rows >> 24, rows >> 16, rows >> 8, rows >> 0); fputc(0, ofP); /* option byte, unused for now */ - + /* now recursively check squares. */ bit_init(&bitOut, ofP); @@ -355,18 +354,18 @@ outputMrf(FILE * const ofP, -int +int main(int argc,char *argv[]) { FILE * ifP; FILE * ofP; unsigned char *image; int rows, cols; - + pbm_init(&argc, argv); if (argc-1 > 1) - pm_error("Too many arguments: %d. Only argument is input file", + pm_error("Too many arguments: %d. Only argument is input file", argc-1); if (argc-1 == 1) @@ -375,7 +374,7 @@ main(int argc,char *argv[]) { ifP = stdin; ofP = stdout; - + readPbmImage(ifP, &image, &cols, &rows); pm_close(ifP); @@ -395,4 +394,3 @@ main(int argc,char *argv[]) { - diff --git a/converter/pbm/pbmtonokia.c b/converter/pbm/pbmtonokia.c index 4604064a..7bf51368 100644 --- a/converter/pbm/pbmtonokia.c +++ b/converter/pbm/pbmtonokia.c @@ -168,7 +168,6 @@ validateSize(unsigned int const cols, - static void convertToHexNol(bit ** const image, unsigned int const cols, @@ -236,7 +235,6 @@ convertToHexNgg(bit ** const image, - static void convertToHexNpm(bit ** const image, unsigned int const cols, @@ -337,7 +335,6 @@ convertToNol(bit ** const image, - static void convertToNgg(bit ** const image, unsigned int const cols, diff --git a/converter/pbm/pbmtopi3.c b/converter/pbm/pbmtopi3.c index 791bcb50..35e73ca3 100644 --- a/converter/pbm/pbmtopi3.c +++ b/converter/pbm/pbmtopi3.c @@ -67,7 +67,7 @@ main(int argc, const char ** argv) { inColByteCt = pbm_packed_bytes(inCols); bitrow = pbm_allocrow_packed(MAX(outCols, inCols)); - + /* Add padding to round cols up to 640 */ for (i = inColByteCt; i < outColByteCt; ++i) bitrow[i] = 0x00; @@ -96,3 +96,6 @@ main(int argc, const char ** argv) { return 0; } + + + diff --git a/converter/pbm/pbmtoplot.c b/converter/pbm/pbmtoplot.c index 8c9075b2..db897bd0 100644 --- a/converter/pbm/pbmtoplot.c +++ b/converter/pbm/pbmtoplot.c @@ -30,13 +30,13 @@ main( argc, argv ) FILE* ifp; register bit** bits; register int row, col, scol; - int rows, cols; + int rows, cols; pbm_init( &argc, argv ); if ( argc > 2 ) - pm_usage( "[pbmfile]" ); + pm_usage( "[pbmfile]" ); ifp = (argc == 2) ? pm_openr( argv[1] ) : stdin; @@ -50,27 +50,30 @@ main( argc, argv ) puttwo( rows - 1 ); puttwo( cols - 1 ); for ( row = 0; row < rows; ++row ) - { - for ( col = 0; col < cols; ++col ) - { - if ( bits[row][col] == PBM_WHITE ) - continue; - scol = col; - while ( ++col < cols && bits[row][col] == PBM_BLACK ) - ; /* nothing */ - --col; - if ( col == scol ) - (void) putchar( 'p' ); - else - { - (void) putchar( 'l' ); - puttwo( scol ); - puttwo( rows - 1 - row ); - } - puttwo( col ); - puttwo( rows - 1 - row ); - } - } + { + for ( col = 0; col < cols; ++col ) + { + if ( bits[row][col] == PBM_WHITE ) + continue; + scol = col; + while ( ++col < cols && bits[row][col] == PBM_BLACK ) + ; /* nothing */ + --col; + if ( col == scol ) + (void) putchar( 'p' ); + else + { + (void) putchar( 'l' ); + puttwo( scol ); + puttwo( rows - 1 - row ); + } + puttwo( col ); + puttwo( rows - 1 - row ); + } + } exit( 0 ); } + + + diff --git a/converter/pbm/pbmtoppa/cutswath.c b/converter/pbm/pbmtoppa/cutswath.c index d3f15c03..cd94e1ea 100644 --- a/converter/pbm/pbmtoppa/cutswath.c +++ b/converter/pbm/pbmtoppa/cutswath.c @@ -29,7 +29,7 @@ extern int Pwidth; /* Returns: 0 if unsuccessful 1 if successful, but with non-printing result (end of page) 2 if successful, with printing result */ -int +int cut_pbm_swath(pbm_stat* pbm,ppa_stat* prn,int maxlines,ppa_sweep_data* sweep_data) { unsigned char *data, *ppa, *place, *maxplace; @@ -42,17 +42,17 @@ cut_pbm_swath(pbm_stat* pbm,ppa_stat* prn,int maxlines,ppa_sweep_data* sweep_dat ppa = NULL; /* shift = 6 if DPI==300 */ - /* shift = 12 if DPI==600 */ + /* shift = 12 if DPI==600 */ shift = ( prn->DPI == 300 ? 6:12 ) ; - + /* safeguard against the user freeing these */ sweep_data->image_data = NULL; sweep_data->nozzle_data = NULL; /* read the data from the input file */ width8 = (pbm->width + 7) / 8; - -/* + +/* fprintf(stderr,"cutswath(): width=%u\n",pbm->width); fprintf(stderr,"cutswath(): height=%u\n",pbm->height); */ @@ -78,9 +78,9 @@ cut_pbm_swath(pbm_stat* pbm,ppa_stat* prn,int maxlines,ppa_sweep_data* sweep_dat while(pbm->current_line < pbm->height) if(!pbm_readline(pbm,data)) { - fprintf(stderr,"cutswath(): could not clear bottom margin\n"); - free (data); data=NULL; - return 0; + fprintf(stderr,"cutswath(): could not clear bottom margin\n"); + free (data); data=NULL; + return 0; } free (data); data=NULL; return 1; @@ -92,7 +92,7 @@ cut_pbm_swath(pbm_stat* pbm,ppa_stat* prn,int maxlines,ppa_sweep_data* sweep_dat /* eat all beginning blank lines and then up to maxlines or lower margin */ got_nonblank=numlines=0; while( (pbm->current_line < Height-prn->bottom_margin) && - (numlines < maxlines) ) + (numlines < maxlines) ) { if(!pbm_readline(pbm,data+width8*numlines)) { @@ -102,71 +102,71 @@ cut_pbm_swath(pbm_stat* pbm,ppa_stat* prn,int maxlines,ppa_sweep_data* sweep_dat } if(!got_nonblank) for(j=prn->left_margin/8; jleft_margin/8; i < left; i++) - if (data[width8*numlines+i]) - { - newleft = i; - break; - } - /* find right-most nonblank */ - for (i = Pwidth-prn->right_margin/8-1; i >= right; i--) - if (data[width8*numlines+i]) - { - newright = i; - break; - } - numlines++; - - if (newright < newleft) - { - fprintf (stderr, "Ack! newleft=%d, newright=%d, left=%d, right=%d\n", - newleft, newright, left, right); - free (data); data=NULL; - return 0; - } - - /* if the next line might push us over the buffer size, stop here! */ - /* ignore this test for the 720 right now. Will add better */ - /* size-guessing for compressed data in the near future! */ - if (numlines % 2 == 1 && prn->version != HP720) - { - int l = newleft, r = newright, w; - - l--; - r+=2; - l*=8; - r*=8; - w = r-l; - w = (w+7)/8; - - if ((w+2*shift)*numlines > prn->bufsize) - { - numlines--; - pbm_unreadline (pbm, data+width8*numlines); - break; - } - else - { - left = newleft; - right = newright; - } - } - else - { - left = newleft; - right = newright; - } + int newleft = left, newright = right; + + /* find left-most nonblank */ + for (i = prn->left_margin/8; i < left; i++) + if (data[width8*numlines+i]) + { + newleft = i; + break; + } + /* find right-most nonblank */ + for (i = Pwidth-prn->right_margin/8-1; i >= right; i--) + if (data[width8*numlines+i]) + { + newright = i; + break; + } + numlines++; + + if (newright < newleft) + { + fprintf (stderr, "Ack! newleft=%d, newright=%d, left=%d, right=%d\n", + newleft, newright, left, right); + free (data); data=NULL; + return 0; + } + + /* if the next line might push us over the buffer size, stop here! */ + /* ignore this test for the 720 right now. Will add better */ + /* size-guessing for compressed data in the near future! */ + if (numlines % 2 == 1 && prn->version != HP720) + { + int l = newleft, r = newright, w; + + l--; + r+=2; + l*=8; + r*=8; + w = r-l; + w = (w+7)/8; + + if ((w+2*shift)*numlines > prn->bufsize) + { + numlines--; + pbm_unreadline (pbm, data+width8*numlines); + break; + } + else + { + left = newleft; + right = newright; + } + } + else + { + left = newleft; + right = newright; + } } } @@ -176,12 +176,12 @@ cut_pbm_swath(pbm_stat* pbm,ppa_stat* prn,int maxlines,ppa_sweep_data* sweep_dat if(pbm->current_line >= Height - prn->bottom_margin) { while(pbm->current_line < pbm->height) - if(!pbm_readline(pbm,data)) - { - fprintf(stderr,"cutswath(): could not clear bottom margin\n"); - free (data); data=NULL; - return 0; - } + if(!pbm_readline(pbm,data)) + { + fprintf(stderr,"cutswath(): could not clear bottom margin\n"); + free (data); data=NULL; + return 0; + } free (data); data=NULL; return 1; } @@ -189,19 +189,19 @@ cut_pbm_swath(pbm_stat* pbm,ppa_stat* prn,int maxlines,ppa_sweep_data* sweep_dat return 0; /* error, since didn't get to lower margin, yet blank */ } - /* make sure numlines is even and >= 2 (b/c we have to pass the printer + /* make sure numlines is even and >= 2 (b/c we have to pass the printer HALF of the number of pins used */ if (numlines == 1) { /* there's no way that we only have 1 line and not enough memory, so - we're safe to increase numlines here. Also, the bottom margin should - be > 0 so we have some lines to read */ + we're safe to increase numlines here. Also, the bottom margin should + be > 0 so we have some lines to read */ if(!pbm_readline(pbm,data+width8*numlines)) - { - fprintf(stderr,"cutswath(): C-could not read next line\n"); - free (data); data=NULL; - return 0; - } + { + fprintf(stderr,"cutswath(): C-could not read next line\n"); + free (data); data=NULL; + return 0; + } numlines++; } if (numlines % 2 == 1) @@ -244,24 +244,24 @@ cut_pbm_swath(pbm_stat* pbm,ppa_stat* prn,int maxlines,ppa_sweep_data* sweep_dat { if (i >= shift) { - for (j = 0; j < numlines/2; j++) - *place++ = data[j*2*width8 + i + left/8-shift]; + for (j = 0; j < numlines/2; j++) + *place++ = data[j*2*width8 + i + left/8-shift]; } else { - memset (place, 0, numlines/2); - place += numlines/2; + memset (place, 0, numlines/2); + place += numlines/2; } if (i < p_width8) { - for (j = 0; j < numlines/2; j++) - *place++ = data[(j*2+1)*width8 + i + left/8]; + for (j = 0; j < numlines/2; j++) + *place++ = data[(j*2+1)*width8 + i + left/8]; } else { - memset (place, 0, numlines/2); - place += numlines/2; + memset (place, 0, numlines/2); + place += numlines/2; } } } @@ -271,24 +271,24 @@ cut_pbm_swath(pbm_stat* pbm,ppa_stat* prn,int maxlines,ppa_sweep_data* sweep_dat { if (i < p_width8) { - for (j = 0; j < numlines/2; j++) - *place++ = data[(j*2+1)*width8 + i + left/8]; + for (j = 0; j < numlines/2; j++) + *place++ = data[(j*2+1)*width8 + i + left/8]; } else { - memset (place, 0, numlines/2); - place += numlines/2; + memset (place, 0, numlines/2); + place += numlines/2; } if (i >= shift) { - for (j = 0; j < numlines/2; j++) - *place++ = data[j*2*width8 + i + left/8 - shift]; + for (j = 0; j < numlines/2; j++) + *place++ = data[j*2*width8 + i + left/8 - shift]; } else { - memset (place, 0, numlines/2); - place += numlines/2; + memset (place, 0, numlines/2); + place += numlines/2; } } } @@ -312,16 +312,16 @@ cut_pbm_swath(pbm_stat* pbm,ppa_stat* prn,int maxlines,ppa_sweep_data* sweep_dat horzpos = left * 600/prn->DPI; hp2 = horzpos + ( p_width8 + 2*shift )*8 * 600/prn->DPI; - - + + sweep_data->left_margin = horzpos; sweep_data->right_margin = hp2 + prn->marg_diff; - + for (i = 0; i < 2; i++) { nozzles[i].DPI = prn->DPI; - + nozzles[i].pins_used_d2 = numlines/2; nozzles[i].unused_pins_p1 = 301-numlines; nozzles[i].first_pin = 1; @@ -331,10 +331,10 @@ cut_pbm_swath(pbm_stat* pbm,ppa_stat* prn,int maxlines,ppa_sweep_data* sweep_dat nozzles[i].right_margin = hp2 + prn->marg_diff; if(sweep_data->direction == right_to_left) /* 0 */ - nozzles[i].nozzle_delay=prn->right_to_left_delay[0]; + nozzles[i].nozzle_delay=prn->right_to_left_delay[0]; else /* 6 */ - nozzles[i].nozzle_delay=prn->left_to_right_delay[0]; + nozzles[i].nozzle_delay=prn->left_to_right_delay[0]; } else { @@ -342,10 +342,10 @@ cut_pbm_swath(pbm_stat* pbm,ppa_stat* prn,int maxlines,ppa_sweep_data* sweep_dat nozzles[i].right_margin = hp2; if(sweep_data->direction == right_to_left) /* 2 */ - nozzles[i].nozzle_delay=prn->right_to_left_delay[1]; + nozzles[i].nozzle_delay=prn->right_to_left_delay[1]; else /* 0 */ - nozzles[i].nozzle_delay=prn->left_to_right_delay[1]; + nozzles[i].nozzle_delay=prn->left_to_right_delay[1]; } } @@ -360,3 +360,4 @@ cut_pbm_swath(pbm_stat* pbm,ppa_stat* prn,int maxlines,ppa_sweep_data* sweep_dat } + diff --git a/converter/pbm/pbmtoppa/cutswath.h b/converter/pbm/pbmtoppa/cutswath.h index 430558de..347510cf 100644 --- a/converter/pbm/pbmtoppa/cutswath.h +++ b/converter/pbm/pbmtoppa/cutswath.h @@ -1,4 +1,4 @@ -int +int cut_pbm_swath(pbm_stat* pbm,ppa_stat* prn,int maxlines, ppa_sweep_data* sweep_data); diff --git a/converter/pbm/pbmtoppa/pbm.c b/converter/pbm/pbmtoppa/pbm.c index ae36e0d2..495b610b 100644 --- a/converter/pbm/pbmtoppa/pbm.c +++ b/converter/pbm/pbmtoppa/pbm.c @@ -193,3 +193,4 @@ pbm_unreadline(pbm_stat * const pbmStatP, } + diff --git a/converter/pbm/pbmtoppa/ppa.c b/converter/pbm/pbmtoppa/ppa.c index 69e7bb79..0f75aa1e 100644 --- a/converter/pbm/pbmtoppa/ppa.c +++ b/converter/pbm/pbmtoppa/ppa.c @@ -31,7 +31,7 @@ (*): responses, autostatus, and pacing are communicated from the printer to the computer, and may be safely ignored. */ -static void +static void vlink_put(FILE *fptr, int channel, int length, void *data) { fputc ('$', fptr); @@ -40,6 +40,8 @@ vlink_put(FILE *fptr, int channel, int length, void *data) fwrite (data, length, 1, fptr); } + + /* SCP packet structure: @@ -60,9 +62,9 @@ vlink_put(FILE *fptr, int channel, int length, void *data) 19 1 Handle Media 18 1 Print Sweep */ -static void +static void scp_put(FILE *fptr, int comspec, int comref, int priority, - int length, void *data) + int length, void *data) { /* encapsulate the vlink_put call in here, to avoid a memcpy */ fputc ('$', fptr); @@ -79,6 +81,7 @@ scp_put(FILE *fptr, int comspec, int comref, int priority, } + /* SCP2 packet structure: @@ -101,10 +104,10 @@ scp_put(FILE *fptr, int comspec, int comref, int priority, 0x181 1 Handle Media 0x180 1 Print Sweep */ -static void +static void scp2_put(FILE *fptr,unsigned short comspec,unsigned short pkt_len_s16, - unsigned char priority,unsigned short comref,unsigned data_len, - void *data) + unsigned char priority,unsigned short comref,unsigned data_len, + void *data) { /* encapsulate the vlink_put call in here, to avoid a memcpy */ fputc ('$', fptr); @@ -128,6 +131,7 @@ scp2_put(FILE *fptr,unsigned short comspec,unsigned short pkt_len_s16, } + /* SCP3 packet structure: @@ -152,10 +156,10 @@ scp2_put(FILE *fptr,unsigned short comspec,unsigned short pkt_len_s16, 0x181 1 Handle Media 0x180 1 Print Sweep */ -static void +static void scp3_put(FILE *fptr,unsigned short comspec,unsigned short pkt_len_s16, - unsigned char priority,unsigned short comref,unsigned data_len, - void *data) + unsigned char priority,unsigned short comref,unsigned data_len, + void *data) { /* encapsulate the vlink_put call in here, to avoid a memcpy */ fputc ('$', fptr); @@ -179,6 +183,7 @@ scp3_put(FILE *fptr,unsigned short comspec,unsigned short pkt_len_s16, } + void ppa_init_job(ppa_stat* prn) { unsigned char init1[8] = { 0x00, 0x00, 0x01, 0xf4, 0x01, 0x00, 0x00, 0x00 }; @@ -211,6 +216,8 @@ void ppa_init_job(ppa_stat* prn) } } + + void ppa_end_print(ppa_stat* prn) { unsigned char pageA[4] = { 0x05, 0x01, 0x03, 0x84 }; @@ -219,12 +226,14 @@ void ppa_end_print(ppa_stat* prn) scp3_put (prn->fptr, 0x0181, sizeof(pageA), 7, 2, 0, pageA); } + + void ppa_init_page(ppa_stat* prn) { unsigned char pageA[16] = {0x28, 0x2d, 0x00, 0x41, 0x29, 0x2e, 0x00, 0x42, - 0x29, 0x2e, 0x00, 0x42, 0x29, 0x2e, 0x00, 0x42 }; + 0x29, 0x2e, 0x00, 0x42, 0x29, 0x2e, 0x00, 0x42 }; unsigned char pageB[16] = {0x28, 0x2d, 0x00, 0x41, 0x2d, 0x32, 0x00, 0x46, - 0x2d, 0x32, 0x00, 0x46, 0x2d, 0x32, 0x00, 0x46 }; + 0x2d, 0x32, 0x00, 0x46, 0x2d, 0x32, 0x00, 0x46 }; switch(prn->version) { @@ -242,6 +251,8 @@ void ppa_init_page(ppa_stat* prn) } } + + void ppa_load_page(ppa_stat* prn) { unsigned char loadA[4] = {0x01, 0x01, 0x09, 0x60 }; @@ -264,6 +275,8 @@ void ppa_load_page(ppa_stat* prn) } } + + void ppa_eject_page(ppa_stat* prn) { unsigned char loadA[4] = {0x02, 0x01, 0x09, 0x60 }; @@ -288,8 +301,8 @@ void ppa_eject_page(ppa_stat* prn) -static int -compress(unsigned char *in, int num_lines_d2, int final_len, +static int +compress(unsigned char *in, int num_lines_d2, int final_len, unsigned char *iout) { unsigned char* out = iout; @@ -301,89 +314,91 @@ compress(unsigned char *in, int num_lines_d2, int final_len, /* Find the size of duplicate values */ int dup_len = 0; while ((i + dup_len < len) - && (in[i + dup_len] == in[i])) { - dup_len++; + && (in[i + dup_len] == in[i])) { + dup_len++; } /* See if we have enough zeros to be worth compressing. */ /* I figure one is enough. */ if ((dup_len >= 1) && (in[i] == 0)) { - /* Output run of zeros. */ - while (dup_len >= 128) { - /* Max is 128 */ - *out++ = 0x00; - i += 128; - dup_len -= 128; - } - if (dup_len >= 1) - { - *out++ = dup_len; - i += dup_len; - } - /* See if we have enough non-zeros to be worth compressing. */ - /* Here two should be enough. */ + /* Output run of zeros. */ + while (dup_len >= 128) { + /* Max is 128 */ + *out++ = 0x00; + i += 128; + dup_len -= 128; + } + if (dup_len >= 1) + { + *out++ = dup_len; + i += dup_len; + } + /* See if we have enough non-zeros to be worth compressing. */ + /* Here two should be enough. */ } else if (dup_len >= 2) { - /* Output run of duplicates. */ - while (dup_len >= 64) { - /* Max is 64 */ - *out++ = 0x80; - *out++ = in[i]; - i += 64; - dup_len -= 64; - } - if (dup_len >= 2) - { - *out++ = dup_len + 0x80; - *out++ = in[i]; - i += dup_len; - } + /* Output run of duplicates. */ + while (dup_len >= 64) { + /* Max is 64 */ + *out++ = 0x80; + *out++ = in[i]; + i += 64; + dup_len -= 64; + } + if (dup_len >= 2) + { + *out++ = dup_len + 0x80; + *out++ = in[i]; + i += dup_len; + } } else { - /* Look for two zeros, or three duplicates to end literal run. */ - /* Note this is one more than the number to start a run. */ - int lit_len = -1; - int add_more = 1; - while (add_more) { - lit_len++; - if (i + lit_len == len) add_more = 0; - /* Always add more if we are near the very end. */ - if (i + lit_len < len - 3) { - char a = in[i + lit_len + 0]; - char b = in[i + lit_len + 1]; - char c = in[i + lit_len + 2]; - /* See if there are enough zeros */ - if ((a == b) && (b == 0)) add_more = 0; - /* See if there are enough duplicates */ - if ((a == b) && (b == c)) add_more = 0; - } - } - /* Output run of literals. */ - while (lit_len >= 64) { - /* Max is 64 */ - int j; - *out++ = 0xc0; - for (j = i; j < i + 64; j++) { - *out++ = in[j]; - } - i += 64; - lit_len -= 64; - } - if (lit_len) { - int j; - *out++ = lit_len + 0xc0; - for (j = i; j < i + lit_len; j++) { - *out++ = in[j]; - } - i += lit_len; - } + /* Look for two zeros, or three duplicates to end literal run. */ + /* Note this is one more than the number to start a run. */ + int lit_len = -1; + int add_more = 1; + while (add_more) { + lit_len++; + if (i + lit_len == len) add_more = 0; + /* Always add more if we are near the very end. */ + if (i + lit_len < len - 3) { + char a = in[i + lit_len + 0]; + char b = in[i + lit_len + 1]; + char c = in[i + lit_len + 2]; + /* See if there are enough zeros */ + if ((a == b) && (b == 0)) add_more = 0; + /* See if there are enough duplicates */ + if ((a == b) && (b == c)) add_more = 0; + } + } + /* Output run of literals. */ + while (lit_len >= 64) { + /* Max is 64 */ + int j; + *out++ = 0xc0; + for (j = i; j < i + 64; j++) { + *out++ = in[j]; + } + i += 64; + lit_len -= 64; + } + if (lit_len) { + int j; + *out++ = lit_len + 0xc0; + for (j = i; j < i + lit_len; j++) { + *out++ = in[j]; + } + i += lit_len; + } } } } return out-iout; } + + static void __inline__ place_2bytes(int x,unsigned char* y) { y[0]=x>>8; y[1]=x; } static void __inline__ place_4bytes(int x,unsigned char* y) @@ -519,9 +534,13 @@ void ppa_print_sweep(ppa_stat* prn,ppa_sweep_data* data) } + void ppa_print_sweeps(ppa_stat* prn,ppa_sweep_data* data) { ppa_sweep_data* current_sweep; for(current_sweep=data; current_sweep; current_sweep=current_sweep->next) ppa_print_sweep(prn,current_sweep); } + + + diff --git a/converter/pbm/pbmtoppa/ppa.h b/converter/pbm/pbmtoppa/ppa.h index 1c7e6f18..cfa18c11 100644 --- a/converter/pbm/pbmtoppa/ppa.h +++ b/converter/pbm/pbmtoppa/ppa.h @@ -32,7 +32,7 @@ typedef struct } ppa_stat; typedef struct -{ +{ int DPI; int right; int left; diff --git a/converter/pbm/pbmtoppa/ppapbm.h b/converter/pbm/pbmtoppa/ppapbm.h index 1ffc093b..10ef4233 100644 --- a/converter/pbm/pbmtoppa/ppapbm.h +++ b/converter/pbm/pbmtoppa/ppapbm.h @@ -22,7 +22,7 @@ typedef struct } pbm_stat; int make_pbm_stat(pbm_stat*,FILE*); -int pbm_readline(pbm_stat*,unsigned char*); +int pbm_readline(pbm_stat*,unsigned char*); /* reads a single line into char* */ void pbm_unreadline(pbm_stat*,void*); /* pushes a single line back */ diff --git a/converter/pbm/pbmtopsg3.c b/converter/pbm/pbmtopsg3.c index 8163b70a..c3bb636d 100644 --- a/converter/pbm/pbmtopsg3.c +++ b/converter/pbm/pbmtopsg3.c @@ -1,20 +1,20 @@ /* pbmtopsg3 Reads a series of PBM images and writes a Postscript program - containing these images as individual pages with Fax-G3 + containing these images as individual pages with Fax-G3 (CCITT-Fiter) compression. (Useful for combining scanned pages into a comfortably printable document.) - Copyright (C) 2001 Kristof Koehler + Copyright (C) 2001 Kristof Koehler Netpbm adaptation by Bryan Henderson June 2001. - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -55,7 +55,7 @@ parseCommandLine(int argc, char ** argv, OPTENT3(0, "dpi", OPT_FLOAT, &dpiOpt, &dpiSpec, 0); OPTENT3(0, "title", OPT_STRING, &titleOpt, &titleSpec, 0); - + opt.opt_table = option_def; opt.short_allowed = FALSE; opt.allowNegNum = FALSE; @@ -75,67 +75,71 @@ parseCommandLine(int argc, char ** argv, cmdlineP->title = titleSpec ? titleOpt : NULL; } - -static void + +static void write85 ( unsigned int bits, int *col ) { - char buf[5] ; - if ( bits == 0 ) { - fputc ( 'z', stdout ) ; - *col += 1 ; - } else { - buf[4] = bits % 85 + '!' ; - bits /= 85 ; - buf[3] = bits % 85 + '!' ; - bits /= 85 ; - buf[2] = bits % 85 + '!' ; - bits /= 85 ; - buf[1] = bits % 85 + '!' ; - bits /= 85 ; - buf[0] = bits % 85 + '!' ; - fwrite ( buf, 1, 5, stdout ) ; - *col += 5 ; - } - if ( *col > 70 ) { - printf ( "\n" ) ; - *col = 0 ; - } + char buf[5] ; + if ( bits == 0 ) { + fputc ( 'z', stdout ) ; + *col += 1 ; + } else { + buf[4] = bits % 85 + '!' ; + bits /= 85 ; + buf[3] = bits % 85 + '!' ; + bits /= 85 ; + buf[2] = bits % 85 + '!' ; + bits /= 85 ; + buf[1] = bits % 85 + '!' ; + bits /= 85 ; + buf[0] = bits % 85 + '!' ; + fwrite ( buf, 1, 5, stdout ) ; + *col += 5 ; + } + if ( *col > 70 ) { + printf ( "\n" ) ; + *col = 0 ; + } } -static void + +static void writebits ( unsigned int *outbits, int *outbitsidx, int *col, unsigned int bits, int n ) { - int k, m ; - unsigned int usedbits ; - while ( n > 0 ) { - if ( *outbitsidx == 0 ) - *outbits = 0 ; - k = 32 - *outbitsidx ; - m = n > k ? k : n ; - usedbits = (bits >> (n-m)) & ((1< 0 ) { + if ( *outbitsidx == 0 ) + *outbits = 0 ; + k = 32 - *outbitsidx ; + m = n > k ? k : n ; + usedbits = (bits >> (n-m)) & ((1< 0 ) { - write85 ( *outbits, col ) ; - *outbitsidx = 0 ; - } + if ( *outbitsidx > 0 ) { + write85 ( *outbits, col ) ; + *outbitsidx = 0 ; + } } + + struct { unsigned int b, l ; } makeup[40][2] = { { { 0x001b, 5 } /* 11011 */ , { 0x000f,10 } /* 0000001111 */ }, { { 0x0012, 5 } /* 10010 */ , { 0x00c8,12 } /* 000011001000 */ }, @@ -243,7 +247,7 @@ struct { unsigned int b, l ; } term[64][2] = { { { 0x004b, 8 } /* 01001011 */ , { 0x002c,12 } /* 000000101100 */ }, { { 0x0032, 8 } /* 00110010 */ , { 0x005a,12 } /* 000001011010 */ }, { { 0x0033, 8 } /* 00110011 */ , { 0x0066,12 } /* 000001100110 */ }, - { { 0x0034, 8 } /* 00110100 */ , { 0x0067,12 } /* 000001100111 */ } + { { 0x0034, 8 } /* 00110100 */ , { 0x0067,12 } /* 000001100111 */ } } ; @@ -251,16 +255,16 @@ static void writelength ( unsigned int *outbits, int *outbitsidx, int *col, int bit, int length ) { - while ( length >= 64 ) { - int m = length / 64 ; - if ( m > 40 ) - m = 40 ; - writebits ( outbits, outbitsidx, col, - makeup[m-1][bit].b, makeup[m-1][bit].l ) ; - length -= 64*m ; - } - writebits ( outbits, outbitsidx, col, - term[length][bit].b, term[length][bit].l ) ; + while ( length >= 64 ) { + int m = length / 64 ; + if ( m > 40 ) + m = 40 ; + writebits ( outbits, outbitsidx, col, + makeup[m-1][bit].b, makeup[m-1][bit].l ) ; + length -= 64*m ; + } + writebits ( outbits, outbitsidx, col, + term[length][bit].b, term[length][bit].l ) ; } @@ -277,9 +281,9 @@ doPage(FILE * const ifP, int outbitsidx, col ; pbm_readpbminit(ifP, &cols, &rows, &format); - + bitrow = pbm_allocrow(cols); - + pm_message("[%u]\n", pageNum); printf ("%%%%Page: %u %u\n", pageNum, pageNum); @@ -288,16 +292,16 @@ doPage(FILE * const ifP, " << /Columns %u /Rows %u /EndOfBlock false >> " "/CCITTFaxDecode filter\n" " image } exec\n", - cols, rows, dpi/72.0, -dpi/72.0, rows, + cols, rows, dpi/72.0, -dpi/72.0, rows, cols, rows) ; - + outbitsidx = col = 0 ; for (row = 0 ; row < rows; ++row) { int lastbit, cnt ; unsigned int j; pbm_readpbmrow(ifP, bitrow, cols, format); - + lastbit = cnt = 0 ; for (j = 0; j < cols; ++j) { if (bitrow[j] != lastbit) { @@ -309,7 +313,7 @@ doPage(FILE * const ifP, } writelength(&outbits, &outbitsidx, &col, lastbit, cnt); } - + flushbits(&outbits, &outbitsidx, &col) ; printf("~>\nshowpage\n") ; @@ -318,7 +322,7 @@ doPage(FILE * const ifP, -static void +static void doPages(FILE * const ifP, unsigned int * const pagesP, double const dpi) { @@ -345,7 +349,7 @@ main(int argc, FILE *ifP; unsigned int pages; - + struct cmdline_info cmdline; pbm_init(&argc, argv); @@ -360,7 +364,7 @@ main(int argc, printf ("%%%%Creator: pbmtopsg3, Copyright (C) 2001 Kristof Koehler\n" "%%%%Pages: (atend)\n" "%%%%EndComments\n") ; - + doPages(ifP, &pages, cmdline.dpi); printf ("%%%%Trailer\n" @@ -370,6 +374,9 @@ main(int argc, pm_close(ifP); pm_close(stdout); - + return 0; } + + + diff --git a/converter/pbm/pbmtoptx.c b/converter/pbm/pbmtoptx.c index 69f1707a..b9d4b756 100644 --- a/converter/pbm/pbmtoptx.c +++ b/converter/pbm/pbmtoptx.c @@ -87,3 +87,4 @@ main(int argc, const char ** argv) { } + diff --git a/converter/pbm/pbmtosunicon.c b/converter/pbm/pbmtosunicon.c index 95deab7c..af5cff91 100644 --- a/converter/pbm/pbmtosunicon.c +++ b/converter/pbm/pbmtosunicon.c @@ -42,7 +42,7 @@ putitem(uint16_t const item) { if (ip.itemCnt == 8 ) { /* Buffer is full. Write out one line. */ int rc; - + rc = fprintf(ip.putFp, "\t0x%04x,0x%04x,0x%04x,0x%04x," "0x%04x,0x%04x,0x%04x,0x%04x,\n", @@ -50,9 +50,9 @@ putitem(uint16_t const item) { ip.itemBuff[2], ip.itemBuff[3], ip.itemBuff[4], ip.itemBuff[5], ip.itemBuff[6], ip.itemBuff[7]); - if (rc < 0) + if (rc < 0) pm_error("fprintf() failed to write Icon bitmap"); - + ip.itemCnt = 0; } ip.itemBuff[ip.itemCnt++] = item & 0xffff; @@ -71,10 +71,10 @@ putterm(void) { rc = fprintf(ip.putFp, "%s0x%04x%c", i == 0 ? "\t" : "", ip.itemBuff[i], i == ip.itemCnt - 1 ? '\n' : ','); - if (rc < 0) + if (rc < 0) pm_error("fprintf() failed to write Icon bitmap"); } -} +} @@ -89,7 +89,7 @@ writeIconHeader(FILE * const ofP, "/* Format_version=1, Width=%u, Height=%u", width, height); if (rc < 0) pm_error("fprintf() failed to write Icon header"); - + rc = fprintf(ofP, ", Depth=1, Valid_bits_per_item=16\n */\n"); if (rc < 0) pm_error("fprintf() failed to write Icon header"); @@ -123,7 +123,7 @@ writeIcon(FILE * const ifP, for (itemSeq = 0; itemSeq < items; ++itemSeq) { /* Read bits from bitrow, send to format & print function. */ - + putitem((bitrow[itemSeq*2]<<8) + bitrow[itemSeq*2+1]); } } @@ -151,7 +151,7 @@ main(int argc, inputFileName = argv[1]; else inputFileName = "-"; - + ifP = pm_openr(inputFileName); pbm_readpbminit(ifP, &cols, &rows, &format); @@ -163,3 +163,5 @@ main(int argc, return 0; } + + diff --git a/converter/pbm/pbmtowbmp.c b/converter/pbm/pbmtowbmp.c index 2907fd68..e1b2b146 100644 --- a/converter/pbm/pbmtowbmp.c +++ b/converter/pbm/pbmtowbmp.c @@ -1,9 +1,9 @@ /* pbmtowbmp.c - convert a portable bitmap to a Wireless Bitmap file - This is derived for Netpbm from the pbmwbmp package from + This is derived for Netpbm from the pbmwbmp package from on 2000.06.06. - - The specifications for the wbmp format are part of the Wireless + + The specifications for the wbmp format are part of the Wireless Application Environment specification at . @@ -19,7 +19,7 @@ #include "pbm.h" -static void +static void outputint(int i) { int c = 1; while(i & 0x7f << 7*c) c++; @@ -29,7 +29,7 @@ outputint(int i) { -int +int main(int argc, char *argv[]) { FILE *f; bit **image; @@ -58,13 +58,15 @@ main(int argc, char *argv[]) { for(col = 0; col < cols; col++) { if(image[row][col] == PBM_WHITE) c = c | (1 << (7-p)); if(++p == 8) { - putchar(c); - p = c = 0; + putchar(c); + p = c = 0; } } if(p) putchar(c); } - + return 0; } + + diff --git a/converter/pbm/pbmtoybm.c b/converter/pbm/pbmtoybm.c index 27ce6cb1..7281866c 100644 --- a/converter/pbm/pbmtoybm.c +++ b/converter/pbm/pbmtoybm.c @@ -66,7 +66,7 @@ main(int argc, const char *argv[]) { pm_error("Input image is too large."); bitrow = pbm_allocrow_packed(cols + 8); - + putinit(cols, rows); bitrow[pbm_packed_bytes(cols + 8) - 1] = 0x00; @@ -95,3 +95,4 @@ main(int argc, const char *argv[]) { } + diff --git a/converter/pbm/pbmtozinc.c b/converter/pbm/pbmtozinc.c index a89b8c9f..3bf3acd0 100644 --- a/converter/pbm/pbmtozinc.c +++ b/converter/pbm/pbmtozinc.c @@ -182,3 +182,6 @@ main(int argc, const char * argv[]) { return 0; } + + + diff --git a/converter/pbm/pi3topbm.c b/converter/pbm/pi3topbm.c index 17b07d6f..82665f6c 100644 --- a/converter/pbm/pi3topbm.c +++ b/converter/pbm/pi3topbm.c @@ -40,13 +40,13 @@ struct CmdlineInfo { -static void -parseCommandLine(int argc, - const char ** argv, +static void +parseCommandLine(int argc, + const char ** argv, struct CmdlineInfo * const cmdlineP) { /* -------------------------------------------------------------------------- Parse program command line described in Unix standard form by argc - and argv. Return the information in the options as *cmdlineP. + and argv. Return the information in the options as *cmdlineP. If command line is internally inconsistent (invalid options, etc.), issue error message to stderr and abort program. @@ -58,12 +58,12 @@ parseCommandLine(int argc, optStruct3 opt; /* Instructions to pm_optParseOptions3 on how to parse our options. */ unsigned int option_def_index; - + MALLOCARRAY_NOFAIL(option_def, 100); option_def_index = 0; /* incremented by OPTENT3 */ OPTENT3(0, "debug", OPT_FLAG, NULL, &cmdlineP->debug, 0); - + opt.opt_table = option_def; opt.short_allowed = FALSE; /* We have no short (old-fashioned) options */ opt.allowNegNum = FALSE; /* We have no parms that are negative numbers */ @@ -71,7 +71,7 @@ parseCommandLine(int argc, pm_optParseOptions3(&argc, (char **)argv, opt, sizeof(opt), 0); /* Uses and sets argc, argv, and some of *cmdlineP and others. */ - if (argc-1 < 1) + if (argc-1 < 1) cmdlineP->inputFileName = "-"; else { cmdlineP->inputFileName = argv[1]; @@ -166,3 +166,6 @@ main(int argc, const char ** argv) { return 0; } + + + diff --git a/converter/pbm/wbmptopbm.c b/converter/pbm/wbmptopbm.c index a3ce7ec3..3b941fcb 100644 --- a/converter/pbm/wbmptopbm.c +++ b/converter/pbm/wbmptopbm.c @@ -1,9 +1,9 @@ /* wbmptopbm.c - convert a wbmp file to a portable bitmap - This is derived for Netpbm from the pbmwbmp package from + This is derived for Netpbm from the pbmwbmp package from on 2000.06.06. - - The specifications for the wbmp format are part of the Wireless + + The specifications for the wbmp format are part of the Wireless Application Environment specification at . @@ -19,7 +19,7 @@ #include "pbm.h" -static int +static int readc(FILE *f) { int c = fgetc(f); if(c == EOF) pm_error("EOF / read error"); @@ -28,7 +28,7 @@ readc(FILE *f) { -static int +static int readint(FILE *f) { int c=0, pos=0, sum=0; do { @@ -40,7 +40,7 @@ readint(FILE *f) { -static void +static void readheader(int h, FILE *f) { int c,i; switch(h & 0x60) { @@ -81,7 +81,7 @@ readwbmp(FILE *f, int *cols, int *rows) { for(j=0; j> k) ? PBM_WHITE : PBM_BLACK; + image[i][j*8+k] = c & (0x80 >> k) ? PBM_WHITE : PBM_BLACK; } } } @@ -90,7 +90,7 @@ readwbmp(FILE *f, int *cols, int *rows) { -int +int main(int argc, char *argv[]) { FILE *f; bit **image; @@ -110,3 +110,5 @@ main(int argc, char *argv[]) { return 0; } + + diff --git a/converter/pbm/xbmtopbm.c b/converter/pbm/xbmtopbm.c index 1f5384ed..d3595ca1 100644 --- a/converter/pbm/xbmtopbm.c +++ b/converter/pbm/xbmtopbm.c @@ -384,6 +384,8 @@ main(int argc, return 0; } + + /* CHANGE HISTORY: 99.09.08 bryanh Recognize "static unsigned char" declaration. diff --git a/converter/pbm/ybmtopbm.c b/converter/pbm/ybmtopbm.c index 78eb79f2..13210e43 100644 --- a/converter/pbm/ybmtopbm.c +++ b/converter/pbm/ybmtopbm.c @@ -116,3 +116,6 @@ main(int argc, const char * argv[]) { return 0; } + + + -- cgit 1.4.1