about summary refs log tree commit diff
path: root/converter
diff options
context:
space:
mode:
Diffstat (limited to 'converter')
-rw-r--r--converter/pbm/pbmtobbnbg.c24
-rw-r--r--converter/ppm/gouldtoppm.c179
-rw-r--r--converter/ppm/ppmtoacad.c56
3 files changed, 142 insertions, 117 deletions
diff --git a/converter/pbm/pbmtobbnbg.c b/converter/pbm/pbmtobbnbg.c
index f9191a49..9608f5f1 100644
--- a/converter/pbm/pbmtobbnbg.c
+++ b/converter/pbm/pbmtobbnbg.c
@@ -17,15 +17,12 @@
 
 #include "pbm.h"
 
-static void write16 ARGS(( unsigned int ));
+static void write16 ( unsigned int word );
 
 static int nco;
 
 int
-main(argc,argv)
-int argc;
-char **argv;
-{
+main(int argc, char ** argv) {
  int rows;
  int cols;
  int format;
@@ -89,9 +86,7 @@ char **argv;
 
 #ifdef POSITIVE_VALUES_ONLY
 static void
-write16(sixteen)
-unsigned int sixteen;
-{
+write16(unsigned int sixteen) {
  if (nco > 75)
   { putchar('\n');
     nco = 0;
@@ -107,6 +102,9 @@ unsigned int sixteen;
  putchar(060+(sixteen&0xf));
  nco ++;
 }
+
+
+
 #else
 /*
  *  This version of "write16" uses negative Packed Pixel Data values to
@@ -114,9 +112,8 @@ unsigned int sixteen;
  *  require fewer characters as they approach the upper end of that range.
  */
 static void
-write16 (word)
-unsigned int    word;
-{
+write16 (unsigned int word) {
+
     int         high;
     int         mid;
     int         low;
@@ -128,7 +125,7 @@ unsigned int    word;
     }
 
     if (word > 0x7fff) {
-        word = (unsigned int) (0x10000L - (long) word);
+        word = (unsigned int) (0x10000L - (long int) word);
         signChar = ' ';
     }
     else
@@ -152,3 +149,6 @@ unsigned int    word;
     }
 }
 #endif
+
+
+
diff --git a/converter/ppm/gouldtoppm.c b/converter/ppm/gouldtoppm.c
index 6cc7726c..d085d5f0 100644
--- a/converter/ppm/gouldtoppm.c
+++ b/converter/ppm/gouldtoppm.c
@@ -15,112 +15,123 @@
 
 #define MAXVAL 255
 
-static void getgouldheader ARGS(( FILE *infile, unsigned long *cols, unsigned long *nlines, unsigned long *bytesperline, unsigned long *bitsperpixel, unsigned long *NB ));
+static void getgouldheader ( FILE *infile,
+                             unsigned long int *cols,
+                             unsigned long int *nlines,
+                             unsigned long int *bytesperline,
+                             unsigned long int *bitsperpixel,
+                             unsigned long int *NB );
+
+
 
 int
-main( argc, argv )
-int argc;
-char *argv[];
-{
-        FILE *ifp;
-        pixel *pixrow;
+main( int argc, char * argv[] ) {
+
+    FILE *ifp;
+    pixel *pixrow;
 
-        unsigned long cols, nlines, bytesperline, bitsperpixel, NB, x, y;
-        unsigned char pbuffer[4];
+    unsigned long int cols, nlines, bytesperline, bitsperpixel, NB, x, y;
+    unsigned char pbuffer[4];
 
-        int color_type;
+    int color_type;
 
 
-        ppm_init( &argc, argv );
+    ppm_init( &argc, argv );
 
-        if ( argc > 2 )
-                pm_usage( "[gouldfile]" );
+    if ( argc > 2 )
+        pm_usage( "[gouldfile]" );
 
-        if ( argc == 2 )
-                ifp = pm_openr( argv[1] );
-        else
-                ifp = stdin;
+    if ( argc == 2 )
+        ifp = pm_openr( argv[1] );
+    else
+        ifp = stdin;
 
-        getgouldheader( ifp, &cols, &nlines, &bytesperline, &bitsperpixel, &NB);
+    getgouldheader( ifp, &cols, &nlines, &bytesperline, &bitsperpixel, &NB);
 
-        ppm_writeppminit(stdout, cols, nlines, MAXVAL, 0);
+    ppm_writeppminit(stdout, cols, nlines, MAXVAL, 0);
 
-        color_type = bitsperpixel/8;
-        if (color_type == 0) color_type = NB;
+    color_type = bitsperpixel/8;
+    if (color_type == 0) color_type = NB;
 
-        pixrow = ppm_allocrow(cols);
+    pixrow = ppm_allocrow(cols);
 
-        for (y = 0; y < nlines; ++y)
+    for (y = 0; y < nlines; ++y)
+    {
+        for (x = 0; x < cols; ++x)
         {
-                for (x = 0; x < cols; ++x)
-                {
-                        switch (color_type)
-                        {
-                        case 0:
-                                pm_error("incorrect color type" );
-
-                        case 1:
-                                fread(pbuffer, 1, 1, ifp);
-                                PPM_ASSIGN( pixrow[x], pbuffer[0], pbuffer[0], pbuffer[0]);
-                                break;
-
-                        case 2:
-                                fread(pbuffer, 2, 1, ifp);
-                                PPM_ASSIGN( pixrow[x], pbuffer[0], pbuffer[1], pbuffer[1]);
-                                break;
-
-                        case 3:
-                                fread(pbuffer, 3, 1, ifp);
-                                PPM_ASSIGN( pixrow[x], pbuffer[0], pbuffer[1], pbuffer[2]);
-                                break;
-
-                        default :
-                                fread(pbuffer, 3, 1, ifp);
-                                PPM_ASSIGN( pixrow[x], pbuffer[0], pbuffer[1], pbuffer[2]);
-                                break;
-
-                        } /* switch */
-                }
-                ppm_writeppmrow(stdout, pixrow, cols, MAXVAL, 0);
+            switch (color_type)
+            {
+            case 0:
+                pm_error("incorrect color type" );
+
+            case 1:
+                fread(pbuffer, 1, 1, ifp);
+                PPM_ASSIGN( pixrow[x], pbuffer[0], pbuffer[0], pbuffer[0]);
+                break;
+
+            case 2:
+                fread(pbuffer, 2, 1, ifp);
+                PPM_ASSIGN( pixrow[x], pbuffer[0], pbuffer[1], pbuffer[1]);
+                break;
+
+            case 3:
+                fread(pbuffer, 3, 1, ifp);
+                PPM_ASSIGN( pixrow[x], pbuffer[0], pbuffer[1], pbuffer[2]);
+                break;
+
+            default :
+                fread(pbuffer, 3, 1, ifp);
+                PPM_ASSIGN( pixrow[x], pbuffer[0], pbuffer[1], pbuffer[2]);
+                break;
+
+            } /* switch */
         }
+        ppm_writeppmrow(stdout, pixrow, cols, MAXVAL, 0);
+    }
 
-        pm_close(ifp);
-        pm_close(stdout);
+    pm_close(ifp);
+    pm_close(stdout);
 
-        exit(0);
+    exit(0);
 }
 
 
 
 static void
-getgouldheader( infile, cols, nlines, bytesperline, bitsperpixel, NB)
-FILE *infile;
-unsigned long *cols, *nlines, *bytesperline, *bitsperpixel, *NB;
-{
-        unsigned long nlines_new, bytesperline_new, numheaderrec;
-        unsigned char headerblk[512];
-        int i;
-
-        if (fread(headerblk, 512, 1, infile) == 0)
-                pm_error("cannot read gould header" );
-
-        *nlines       = (headerblk[3]<<8) | headerblk[2];
-        *bytesperline = (headerblk[5]<<8) | headerblk[4];
-        *bitsperpixel = (headerblk[7]<<8) | headerblk[6];
-        numheaderrec  = (headerblk[9]<<8) | headerblk[8];
-        nlines_new    = (headerblk[15]<<24)| (headerblk[14]<<16) | (headerblk[13]<<8) | (headerblk[12]);
-        bytesperline_new = (headerblk[19]<<24)| (headerblk[18]<<16) | (headerblk[17]<<8) | (headerblk[16]);
-        *NB           = (headerblk[23]<<24)| (headerblk[22]<<16) | (headerblk[21]<<8) | (headerblk[20]);
-
-        if (numheaderrec > 1)
-                for (i = 1 ; i <numheaderrec; ++i)
-                        if (fread(headerblk, 512, 1, infile) == 0)
-                                pm_error("cannot read gould header(2nd)" );
-
-        if (*nlines==0) *nlines=nlines_new;
-        if (*bytesperline==0) *bytesperline=bytesperline_new;
-
-        *cols = (*bytesperline)*8 / (*bitsperpixel);
+getgouldheader(FILE * infile,
+               unsigned long int *cols,
+               unsigned long int *nlines,
+               unsigned long int *bytesperline,
+               unsigned long int *bitsperpixel,
+               unsigned long int *NB ) {
+
+    unsigned long int nlines_new, bytesperline_new, numheaderrec;
+    unsigned char headerblk[512];
+    int i;
+
+    if (fread(headerblk, 512, 1, infile) == 0)
+        pm_error("cannot read gould header" );
+
+    *nlines       = (headerblk[3]<<8) | headerblk[2];
+    *bytesperline = (headerblk[5]<<8) | headerblk[4];
+    *bitsperpixel = (headerblk[7]<<8) | headerblk[6];
+    numheaderrec  = (headerblk[9]<<8) | headerblk[8];
+    nlines_new    = (headerblk[15]<<24)| (headerblk[14]<<16) |\
+                    (headerblk[13]<<8) | (headerblk[12]);
+    bytesperline_new = (headerblk[19]<<24)| (headerblk[18]<<16) |\
+                       (headerblk[17]<<8) | (headerblk[16]);
+    *NB           = (headerblk[23]<<24)| (headerblk[22]<<16) |\
+                    (headerblk[21]<<8) | (headerblk[20]);
+
+    if (numheaderrec > 1)
+        for (i = 1 ; i <numheaderrec; ++i)
+            if (fread(headerblk, 512, 1, infile) == 0)
+                pm_error("cannot read gould header(2nd)" );
+
+    if (*nlines==0) *nlines=nlines_new;
+    if (*bytesperline==0) *bytesperline=bytesperline_new;
+
+    *cols = (*bytesperline)*8 / (*bitsperpixel);
 }
 
 
diff --git a/converter/ppm/ppmtoacad.c b/converter/ppm/ppmtoacad.c
index 4f4dc5dd..1bc91640 100644
--- a/converter/ppm/ppmtoacad.c
+++ b/converter/ppm/ppmtoacad.c
@@ -40,16 +40,29 @@ static int gamut = 256;               /* Output color gamut */
 #include "autocad.h"                  /* AutoCAD standard color assignments */
 
 /* prototypes */
-static void outrun ARGS((int color, int ysize, int y, int xstart, int xend));
-static void slideout ARGS((int xdots, int ydots, int ncolors,
-        unsigned char *red, unsigned char *green, unsigned char *blue));
+static void outrun (int const color,
+                    int const ysize,
+                    int const y,
+                    int const xstart,
+                    int const xend);
+
+static void slideout (int const xdots,
+                      int const ydots,
+                      int const ncolors,
+                      unsigned char *red,
+                      unsigned char *green,
+                      unsigned char *blue);
 
 
 /*  OUTRUN  --  Output a run of pixels. */
 
-static void outrun(color, ysize, y, xstart, xend)
-  int color, ysize, y, xstart, xend;
-{
+static void
+outrun (int const color,
+        int const ysize,
+        int const y,
+        int const xstart,
+        int const xend) {
+
     if (color == 0) {
         return;                       /* Let screen background handle this */
     }
@@ -151,10 +164,14 @@ static void outrun(color, ysize, y, xstart, xend)
 
 /*  SLIDEOUT  --  Write an AutoCAD slide.  */
 
-static void slideout(xdots, ydots, ncolors, red, green, blue)
-  int xdots, ydots, ncolors;
-  unsigned char *red, *green, *blue;
-{
+static void
+slideout (int const xdots,
+          int const ydots,
+          int const ncolors,
+          unsigned char *red,
+          unsigned char *green,
+          unsigned char *blue) {
+
     static char sldhead[18] = "AutoCAD Slide\r\n\32";
     static char dxbhead[20] = "AutoCAD DXB 1.0\r\n\32";
     unsigned char *acadmap;
@@ -187,7 +204,7 @@ static void slideout(xdots, ydots, ncolors, red, green, blue)
         (void) pm_writelittleshort(stdout, ysize); /* Max Y co-ordinate value */
                                       /* Aspect ratio indicator */
         (void) pm_writelittlelong(
-            stdout, (long) ((((double) xsize) / ysize) * aspect * 1E7));
+            stdout, (long int) ((((double) xsize) / ysize) * aspect * 1E7));
         (void) pm_writelittleshort(stdout, 2);        /* Polygon fill type */
         (void) pm_writelittleshort(stdout, 0x1234);   /* Byte order indicator */
     }
@@ -198,13 +215,13 @@ static void slideout(xdots, ydots, ncolors, red, green, blue)
 
     for (i = 0; i < ncolors; i++) {
         int best, j;
-        long dist = 3 * 256 * 256;
+        long int dist = 3 * 256 * 256;
 
         for (j = 0; j < gamut; j++) {
-            long dr = red[i] - acadcol[j][0],
-                 dg = green[i] - acadcol[j][1],
-                 db = blue[i] - acadcol[j][2];
-            long tdist = dr * dr + dg * dg + db * db;
+            long int const dr = red[i] - acadcol[j][0],
+                     dg = green[i] - acadcol[j][1],
+                     db = blue[i] - acadcol[j][2];
+            long int const tdist = dr * dr + dg * dg + db * db;
 
             if (tdist < dist) {
                 dist = tdist;
@@ -265,10 +282,8 @@ static void slideout(xdots, ydots, ncolors, red, green, blue)
 
 /*  Main program.  */
 
-int main(argc, argv)
-  int argc;
-  char* argv[];
-{
+int main(int argc, char* argv[]) {
+
     FILE *ifp;
     int argn, rows, cols, ncolors, i;
     int aspectspec = FALSE;
@@ -279,7 +294,6 @@ int main(argc, argv)
         "[-poly] [-dxb] [-white] [-background <col>]\n\
                   [-aspect <f>] [-8] [ppmfile]";
 
-
     ppm_init(&argc, argv);
 
     argn = 1;