Revision: 41393
          http://brlcad.svn.sourceforge.net/brlcad/?rev=41393&view=rev
Author:   brlcad
Date:     2010-11-17 19:38:43 +0000 (Wed, 17 Nov 2010)

Log Message:
-----------
quellage for non-return from functions (was calling bu_exit()).  clean up the 
files while we're in there for ws, style, indent.  restructure for no-decls, 
eliminate globals and reduce.

Modified Paths:
--------------
    brlcad/trunk/src/fb/fb-bw.c
    brlcad/trunk/src/fb/fb-fb.c
    brlcad/trunk/src/fb/fb-pix.c
    brlcad/trunk/src/fb/fb-png.c
    brlcad/trunk/src/fb/fb-rle.c
    brlcad/trunk/src/fb/fbcmap.c
    brlcad/trunk/src/fb/fbfade.c

Modified: brlcad/trunk/src/fb/fb-bw.c
===================================================================
--- brlcad/trunk/src/fb/fb-bw.c 2010-11-17 18:25:44 UTC (rev 41392)
+++ brlcad/trunk/src/fb/fb-bw.c 2010-11-17 19:38:43 UTC (rev 41393)
@@ -20,8 +20,8 @@
 /** @file fb-bw.c
  *
  * Read a Black and White image from the framebuffer and output
- *  it in 8-bit black and white form in pix order,
- *  i.e. Bottom UP, left to right.
+ * it in 8-bit black and white form in pix order,
+ * i.e. Bottom UP, left to right.
  *
  */
 
@@ -38,35 +38,28 @@
 #include "fb.h"
 
 
-FBIO   *fbp;
+#define LINELEN 8192
 
-#define LINELEN                8192
+static unsigned char inbuf[LINELEN*3];
+static unsigned char obuf[LINELEN];
 
-static unsigned char   inbuf[LINELEN*3];
-static unsigned char   obuf[LINELEN];
+int height;
+int width;
+int inverse;
+int scr_xoff, scr_yoff;
 
-int    height;
-int    width;
-int    inverse;
-int    scr_xoff, scr_yoff;
-
 char *framebuffer = NULL;
 char *file_name;
 FILE *outfp;
 
-/* XXX -R -G -B */
-char   usage[] = "\
-Usage: fb-bw [-h -i] [-F framebuffer]\n\
-       [-X scr_xoff] [-Y scr_yoff]\n\
-       [-s squaresize] [-w width] [-n height] [file.bw]\n";
 
 int
 get_args(int argc, char **argv)
 {
     int c;
 
-    while ( (c = bu_getopt( argc, argv, "hiF:X:Y:s:w:n:" )) != EOF )  {
-       switch ( c )  {
+    while ((c = bu_getopt(argc, argv, "hiF:X:Y:s:w:n:")) != EOF) {
+       switch (c) {
            case 'h':
                /* high-res */
                height = width = 1024;
@@ -99,71 +92,80 @@
        }
     }
 
-    if ( bu_optind >= argc ) {
-       if ( isatty(fileno(stdout)) )
+    if (bu_optind >= argc) {
+       if (isatty(fileno(stdout)))
            return 0;
        file_name = "-";
        outfp = stdout;
     } else {
        file_name = argv[bu_optind];
-       if ( (outfp = fopen(file_name, "wb")) == NULL )  {
-           (void)fprintf( stderr,
-                          "fb-bw: cannot open \"%s\" for writing\n",
-                          file_name );
+       if ((outfp = fopen(file_name, "wb")) == NULL) {
+           (void)fprintf(stderr,
+                         "fb-bw: cannot open \"%s\" for writing\n",
+                         file_name);
            return 0;
        }
     }
 
-    if ( argc > ++bu_optind )
-       (void)fprintf( stderr, "fb-bw: excess argument(s) ignored\n" );
+    if (argc > ++bu_optind)
+       (void)fprintf(stderr, "fb-bw: excess argument(s) ignored\n");
 
     return 1;          /* OK */
 }
 
+
 int
 main(int argc, char **argv)
 {
-    int        x, y;
-    int        xin, yin;               /* number of sceen output lines */
+    FBIO *fbp;
 
+    int x, y;
+    int xin, yin;              /* number of sceen output lines */
+
+    char usage[] = "\
+Usage: fb-bw [-h -i] [-F framebuffer]\n\
+       [-X scr_xoff] [-Y scr_yoff]\n\
+       [-s squaresize] [-w width] [-n height] [file.bw]\n";
+
     height = width = 512;              /* Defaults */
 
-    if ( !get_args( argc, argv ) )  {
+    if (!get_args(argc, argv)) {
        (void)fputs(usage, stderr);
-       bu_exit( 1, NULL );
+       bu_exit(1, NULL);
     }
 
     /* Open Display Device */
-    if ((fbp = fb_open(framebuffer, width, height )) == NULL ) {
-       fprintf( stderr, "fb_open failed\n");
-       bu_exit( 1, NULL );
+    if ((fbp = fb_open(framebuffer, width, height)) == NULL) {
+       fprintf(stderr, "fb_open failed\n");
+       bu_exit(1, NULL);
     }
 
     /* determine "reasonable" behavior */
     xin = fb_getwidth(fbp) - scr_xoff;
-    if ( xin < 0 ) xin = 0;
-    if ( xin > width ) xin = width;
+    if (xin < 0) xin = 0;
+    if (xin > width) xin = width;
     yin = fb_getheight(fbp) - scr_yoff;
-    if ( yin < 0 ) yin = 0;
-    if ( yin > height ) yin = height;
+    if (yin < 0) yin = 0;
+    if (yin > height) yin = height;
 
-    for ( y = scr_yoff; y < scr_yoff + yin; y++ )  {
-       if ( inverse ) {
-           (void)fb_read( fbp, scr_xoff, fb_getheight(fbp)-1-y, inbuf, xin );
+    for (y = scr_yoff; y < scr_yoff + yin; y++) {
+       if (inverse) {
+           (void)fb_read(fbp, scr_xoff, fb_getheight(fbp)-1-y, inbuf, xin);
        } else {
-           (void)fb_read( fbp, scr_xoff, y, inbuf, xin );
+           (void)fb_read(fbp, scr_xoff, y, inbuf, xin);
        }
-       for ( x = 0; x < xin; x++ ) {
+       for (x = 0; x < xin; x++) {
            obuf[x] = (((int)inbuf[3*x+RED]) + ((int)inbuf[3*x+GRN])
                       + ((int)inbuf[3*x+BLU])) / 3;
        }
-       fwrite( &obuf[0], sizeof( char ), xin, outfp );
+       fwrite(&obuf[0], sizeof(char), xin, outfp);
     }
 
-    fb_close( fbp );
-    bu_exit( 0, NULL );
+    fb_close(fbp);
+    return 0;
 }
 
+
 /*
  * Local Variables:
  * mode: C

Modified: brlcad/trunk/src/fb/fb-fb.c
===================================================================
--- brlcad/trunk/src/fb/fb-fb.c 2010-11-17 18:25:44 UTC (rev 41392)
+++ brlcad/trunk/src/fb/fb-fb.c 2010-11-17 19:38:43 UTC (rev 41393)
@@ -33,18 +33,15 @@
 #include "bu.h"
 #include "fb.h"
 
-static unsigned char *scanline;                /* 1 scanline pixel buffer */
-static int     scanbytes;              /* # of bytes of scanline */
-static int     scanpix;                /* # of pixels of scanline */
-static int     streamline;             /* # scanlines to do at once */
-static int     verbose;
 
-static char    *in_fb_name;
-static char    *out_fb_name;
+static int verbose;
 
-static int     scr_width = 0;          /* screen tracks file if not given */
-static int     scr_height = 0;
+static char *in_fb_name;
+static char *out_fb_name;
 
+static int scr_width = 0;              /* screen tracks file if not given */
+static int scr_height = 0;
+
 static char usage[] = "\
 Usage: fb-fb [-v] [-F output_framebuffer]\n\
        input_framebuffer [output_framebuffer]\n";
@@ -54,8 +51,8 @@
 {
     int c;
 
-    while ( (c = bu_getopt( argc, argv, "vF:" )) != EOF )  {
-       switch ( c )  {
+    while ((c = bu_getopt(argc, argv, "vF:")) != EOF) {
+       switch (c) {
            case 'F':
                out_fb_name = bu_optarg;
                break;
@@ -68,41 +65,47 @@
        }
     }
 
-    if ( bu_optind >= argc )  {
+    if (bu_optind >= argc) {
        return 0;               /* missing input framebuffer */
     }
     in_fb_name = argv[bu_optind++];
 
-    if ( bu_optind >= argc )  {
+    if (bu_optind >= argc) {
        return 1;       /* OK */
     }
     out_fb_name = argv[bu_optind++];
 
-    if ( argc > bu_optind )
-       (void)fprintf( stderr, "fb-fb: excess argument(s) ignored\n" );
+    if (argc > bu_optind)
+       (void)fprintf(stderr, "fb-fb: excess argument(s) ignored\n");
 
     return 1;          /* OK */
 }
 
+
 int
 main(int argc, char **argv)
 {
     int y;
     FBIO *in_fbp, *out_fbp;
-    int        n, m;
-    int        height;
+    int n, m;
+    int height;
 
-    if ( !get_args( argc, argv ) )  {
+    unsigned char *scanline;    /* 1 scanline pixel buffer */
+    int scanbytes;              /* # of bytes of scanline */
+    int scanpix;                /* # of pixels of scanline */
+    int streamline;             /* # scanlines to do at once */
+
+    if (!get_args(argc, argv)) {
        (void)fputs(usage, stderr);
-       bu_exit( 1, NULL );
+       bu_exit(1, NULL);
     }
 
-    if ( verbose )
-       fprintf(stderr, "fb-fb: infb=%s, outfb=%s\n", in_fb_name, out_fb_name );
+    if (verbose)
+       fprintf(stderr, "fb-fb: infb=%s, outfb=%s\n", in_fb_name, out_fb_name);
 
-    if ( (in_fbp = fb_open( in_fb_name, 0, 0 )) == NULL )  {
-       if ( in_fb_name )
-           fprintf(stderr, "fb-fb: unable to open input '%s'\n", in_fb_name );
+    if ((in_fbp = fb_open(in_fb_name, 0, 0)) == NULL) {
+       if (in_fb_name)
+           fprintf(stderr, "fb-fb: unable to open input '%s'\n", in_fb_name);
        bu_exit(12, NULL);
     }
 
@@ -110,19 +113,19 @@
     scr_width = fb_getwidth(in_fbp);
     scr_height = fb_getheight(in_fbp);
 
-    if ( verbose )
+    if (verbose)
        fprintf(stderr, "fb-fb: width=%d height=%d\n", scr_width, scr_height);
 
-    if ( (out_fbp = fb_open( out_fb_name, scr_width, scr_height )) == 
FBIO_NULL )  {
-       if ( out_fb_name )
-           fprintf(stderr, "fb-fb: unable to open output '%s'\n", out_fb_name 
);
+    if ((out_fbp = fb_open(out_fb_name, scr_width, scr_height)) == FBIO_NULL) {
+       if (out_fb_name)
+           fprintf(stderr, "fb-fb: unable to open output '%s'\n", out_fb_name);
        bu_exit(12, NULL);
     }
 
     scanpix = scr_width;                       /* # pixels on scanline */
     streamline = 64;                   /* # scanlines per block */
     scanbytes = scanpix * streamline * sizeof(RGBpixel);
-    if ( (scanline = (unsigned char *)malloc(scanbytes)) == RGBPIXEL_NULL )  {
+    if ((scanline = (unsigned char *)malloc(scanbytes)) == RGBPIXEL_NULL) {
        fprintf(stderr,
                "fb-fb:  malloc(%d) failure for scanline buffer\n",
                scanbytes);
@@ -130,31 +133,32 @@
     }
 
     /* Bottom to top with multi-line reads & writes */
-    for ( y = 0; y < scr_height; y += streamline )  {
-       if ( y+streamline > scr_height )
+    for (y = 0; y < scr_height; y += streamline) {
+       if (y+streamline > scr_height)
            streamline = scr_height-y;
-       if ( verbose )
+       if (verbose)
            fprintf(stderr, "fb-fb: y=%d, nlines=%d\n", y, streamline);
-       n = fb_readrect( in_fbp, 0, y, scr_width, streamline,
-                        scanline );
-       if ( n <= 0 ) break;
+       n = fb_readrect(in_fbp, 0, y, scr_width, streamline,
+                       scanline);
+       if (n <= 0) break;
        height = streamline;
-       if ( n != scr_width * streamline )  {
+       if (n != scr_width * streamline) {
            height = (n+scr_width-1)/scr_width;
-           if ( height <= 0 )  break;
+           if (height <= 0) break;
        }
-       m = fb_writerect( out_fbp, 0, y, scr_width, height,
-                         scanline );
-       if ( m != scr_width*height )
+       m = fb_writerect(out_fbp, 0, y, scr_width, height,
+                        scanline);
+       if (m != scr_width*height)
            fprintf(stderr,
                    "fb-fb: fb_writerect(x=0, y=%d, w=%d, h=%d) failure, 
ret=%d, s/b=%d\n",
-                   y, scr_width, height, m, scanbytes );
+                   y, scr_width, height, m, scanbytes);
     }
-    fb_close( in_fbp );
-    fb_close( out_fbp );
-    bu_exit(0, NULL);
+    fb_close(in_fbp);
+    fb_close(out_fbp);
+    return 0;
 }
 
+
 /*
  * Local Variables:
  * mode: C

Modified: brlcad/trunk/src/fb/fb-pix.c
===================================================================
--- brlcad/trunk/src/fb/fb-pix.c        2010-11-17 18:25:44 UTC (rev 41392)
+++ brlcad/trunk/src/fb/fb-pix.c        2010-11-17 19:38:43 UTC (rev 41393)
@@ -42,33 +42,27 @@
 
 #include "pkg.h"
 
-static unsigned char   *scanline;              /* 1 scanline pixel buffer */
-static int     scanbytes;              /* # of bytes of scanline */
-static int     scanpix;                /* # of pixels of scanline */
-static ColorMap        cmap;                   /* libfb color map */
 
-char   *framebuffer = NULL;
-char   *file_name;
-FILE   *outfp;
+char *framebuffer = NULL;
+char *file_name;
+FILE *outfp;
 
-static int     crunch = 0;             /* Color map crunch? */
-static int     inverse = 0;            /* Draw upside-down */
-int    screen_height;                  /* input height */
-int    screen_width;                   /* input width */
+static int crunch = 0;         /* Color map crunch? */
+static int inverse = 0;                /* Draw upside-down */
+int screen_height;                     /* input height */
+int screen_width;                      /* input width */
 
-extern void    cmap_crunch(RGBpixel (*scan_buf), int pixel_ct, ColorMap 
*colormap);
+/* in cmap-crunch.c */
+extern void cmap_crunch(RGBpixel (*scan_buf), int pixel_ct, ColorMap 
*colormap);
 
-char usage[] = "\
-Usage: fb-pix [-h -i -c] [-F framebuffer]\n\
-       [-s squaresize] [-w width] [-n height] [file.pix]\n";
 
 int
 get_args(int argc, char **argv)
 {
     int c;
 
-    while ( (c = bu_getopt( argc, argv, "chiF:s:w:n:" )) != EOF )  {
-       switch ( c )  {
+    while ((c = bu_getopt(argc, argv, "chiF:s:w:n:")) != EOF) {
+       switch (c) {
            case 'c':
                crunch = 1;
                break;
@@ -98,39 +92,49 @@
        }
     }
 
-    if ( bu_optind >= argc )  {
-       if ( isatty(fileno(stdout)) )
+    if (bu_optind >= argc) {
+       if (isatty(fileno(stdout)))
            return 0;
        file_name = "-";
        outfp = stdout;
     } else {
        file_name = argv[bu_optind];
-       if ( (outfp = fopen(file_name, "wb")) == NULL )  {
-           (void)fprintf( stderr,
-                          "fb-pix: cannot open \"%s\" for writing\n",
-                          file_name );
+       if ((outfp = fopen(file_name, "wb")) == NULL) {
+           (void)fprintf(stderr,
+                         "fb-pix: cannot open \"%s\" for writing\n",
+                         file_name);
            return 0;
        }
        (void)bu_fchmod(outfp, 0444);
     }
 
-    if ( argc > ++bu_optind )
-       (void)fprintf( stderr, "fb-pix: excess argument(s) ignored\n" );
+    if (argc > ++bu_optind)
+       (void)fprintf(stderr, "fb-pix: excess argument(s) ignored\n");
 
     return 1;          /* OK */
 }
 
+
 int
 main(int argc, char **argv)
 {
     FBIO *fbp;
     int y;
 
+    unsigned char *scanline;   /* 1 scanline pixel buffer */
+    int scanbytes;             /* # of bytes of scanline */
+    int scanpix;               /* # of pixels of scanline */
+    ColorMap cmap;             /* libfb color map */
+
+    char usage[] = "\
+Usage: fb-pix [-h -i -c] [-F framebuffer]\n\
+       [-s squaresize] [-w width] [-n height] [file.pix]\n";
+
     screen_height = screen_width = 512;                /* Defaults */
 
-    if ( !get_args( argc, argv ) )  {
+    if (!get_args(argc, argv)) {
        (void)fputs(usage, stderr);
-       bu_exit( 1, NULL );
+       bu_exit(1, NULL);
     }
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
@@ -139,9 +143,9 @@
 
     scanpix = screen_width;
     scanbytes = scanpix * sizeof(RGBpixel);
-    if ( (scanline = (unsigned char *)malloc(scanbytes)) == RGBPIXEL_NULL )  {
+    if ((scanline = (unsigned char *)malloc(scanbytes)) == RGBPIXEL_NULL) {
        fprintf(stderr,
-               "fb-pix:  malloc(%d) failure\n", scanbytes );
+               "fb-pix:  malloc(%d) failure\n", scanbytes);
        bu_exit(2, NULL);
     }
 
@@ -149,46 +153,47 @@
        bu_exit(12, NULL);
     }
 
-    if ( screen_height > fb_getheight(fbp) )
+    if (screen_height > fb_getheight(fbp))
        screen_height = fb_getheight(fbp);
-    if ( screen_width > fb_getwidth(fbp) )
+    if (screen_width > fb_getwidth(fbp))
        screen_width = fb_getwidth(fbp);
 
-    if ( crunch )  {
-       if ( fb_rmap( fbp, &cmap ) == -1 )  {
+    if (crunch) {
+       if (fb_rmap(fbp, &cmap) == -1) {
            crunch = 0;
-       } else if ( fb_is_linear_cmap( &cmap ) ) {
+       } else if (fb_is_linear_cmap(&cmap)) {
            crunch = 0;
        }
     }
 
-    if ( !inverse )  {
-       /*  Regular -- read bottom to top */
-       for ( y=0; y < screen_height; y++ )  {
-           fb_read( fbp, 0, y, scanline, screen_width );
-           if ( crunch )
-               cmap_crunch( (RGBpixel *)scanline, scanpix, &cmap );
-           if ( fwrite( (char *)scanline, scanbytes, 1, outfp ) != 1 )  {
+    if (!inverse) {
+       /* Regular -- read bottom to top */
+       for (y=0; y < screen_height; y++) {
+           fb_read(fbp, 0, y, scanline, screen_width);
+           if (crunch)
+               cmap_crunch((RGBpixel *)scanline, scanpix, &cmap);
+           if (fwrite((char *)scanline, scanbytes, 1, outfp) != 1) {
                perror("fwrite");
                break;
            }
        }
-    }  else  {
-       /*  Inverse -- read top to bottom */
-       for ( y = screen_height-1; y >= 0; y-- )  {
-           fb_read( fbp, 0, y, scanline, screen_width );
-           if ( crunch )
-               cmap_crunch( (RGBpixel *)scanline, scanpix, &cmap );
-           if ( fwrite( (char *)scanline, scanbytes, 1, outfp ) != 1 )  {
+    } else {
+       /* Inverse -- read top to bottom */
+       for (y = screen_height-1; y >= 0; y--) {
+           fb_read(fbp, 0, y, scanline, screen_width);
+           if (crunch)
+               cmap_crunch((RGBpixel *)scanline, scanpix, &cmap);
+           if (fwrite((char *)scanline, scanbytes, 1, outfp) != 1) {
                perror("fwrite");
                break;
            }
        }
     }
-    fb_close( fbp );
-    bu_exit(0, NULL);
+    fb_close(fbp);
+    return 0;
 }
 
+
 /*
  * Local Variables:
  * mode: C

Modified: brlcad/trunk/src/fb/fb-png.c
===================================================================
--- brlcad/trunk/src/fb/fb-png.c        2010-11-17 18:25:44 UTC (rev 41392)
+++ brlcad/trunk/src/fb/fb-png.c        2010-11-17 19:38:43 UTC (rev 41393)
@@ -44,6 +44,8 @@
 
 #include "pkg.h"
 
+
+/* in cmap-crunch.c */
 extern void cmap_crunch(RGBpixel (*scan_buf), int pixel_ct, ColorMap 
*colormap);
 
 
@@ -123,6 +125,7 @@
     return 1;          /* OK */
 }
 
+
 int
 main(int argc, char **argv)
 {
@@ -233,9 +236,10 @@
     }
     fb_close(fbp);
     png_write_end(png_p, NULL);
-    bu_exit(0, NULL);
+    return 0;
 }
 
+
 /*
  * Local Variables:
  * mode: C

Modified: brlcad/trunk/src/fb/fb-rle.c
===================================================================
--- brlcad/trunk/src/fb/fb-rle.c        2010-11-17 18:25:44 UTC (rev 41392)
+++ brlcad/trunk/src/fb/fb-rle.c        2010-11-17 19:38:43 UTC (rev 41393)
@@ -36,41 +36,39 @@
 
 #include "bu.h"
 #include "fb.h"
-
-/* 
- * system installed RLE reports a re-define, so undef it to quell the
- * warning
- */
 #include "rle.h"
 
-#define COMMENT_SIZE 128
-static rle_hdr outrle;
-#define                outfp           outrle.rle_file
-static char                    comment[COMMENT_SIZE];
-#if HAVE_GETHOSTNAME
-static char                    host[COMMENT_SIZE];
+
+#define COMMENT_SIZE 512
+
+static rle_hdr outrle;
+static char comment[COMMENT_SIZE];
+
+#ifdef HAVE_GETHOSTNAME
+static char host[COMMENT_SIZE];
 #endif
-static rle_pixel               **rows;
-static time_t                  now;
-static char                    *who;
 
-static rle_map                 rlemap[3*256];          /* Utah format map */
-static ColorMap                        cmap;                   /* libfb format 
map */
+static rle_pixel **rows;
+static time_t now;
+static char *who;
 
-static int     crunch;
+static rle_map rlemap[3*256];          /* Utah format map */
+static ColorMap cmap;                  /* libfb format map */
 
-static int     background[3];  /* default background is black */
+static int crunch;
 
-static int     screen_width;
-static int     screen_height;
-static int     file_width;
-static int     file_height;
-static int     screen_xoff;
-static int     screen_yoff;
+static int background[3];      /* default background is black */
 
-static char    *framebuffer;
+static int screen_width;
+static int screen_height;
+static int file_width;
+static int file_height;
+static int screen_xoff;
+static int screen_yoff;
 
-static char    usage[] = "\
+static char *framebuffer;
+
+static char usage[] = "\
 Usage: fb-rle [-c -h -d] [-F framebuffer] [-C r/g/b]\n\
        [-S squarescrsize] [-W screen_width] [-N screen_height]\n\
        [-X screen_xoff] [-Y screen_yoff]\n\
@@ -79,18 +77,20 @@
 \n\
 If omitted, the .rle file is written to stdout\n";
 
-extern void    cmap_crunch(RGBpixel (*scan_buf), int pixel_ct, ColorMap 
*colormap);
+/* in cmap-crunch.c */
+extern void cmap_crunch(RGBpixel (*scan_buf), int pixel_ct, ColorMap 
*colormap);
 
+
 /*
- *                     G E T _ A R G S
+ * G E T _ A R G S
  */
 static int
 get_args(int argc, char **argv)
 {
-    int        c;
+    int c;
 
-    while ( (c = bu_getopt( argc, argv, "cF:hds:w:n:S:W:N:X:Y:C:" )) != EOF )  
{
-       switch ( c )  {
+    while ((c = bu_getopt(argc, argv, "cF:hds:w:n:S:W:N:X:Y:C:")) != EOF) {
+       switch (c) {
            case 'c':
                crunch = 1;
                break;
@@ -126,99 +126,99 @@
            case 'Y':
                screen_yoff = atoi(bu_optarg);
                break;
-           case 'C':
-           {
+           case 'C': {
                char *cp = bu_optarg;
                int *conp = background;
 
                /* premature null => atoi gives zeros */
-               for ( c=0; c < 3; c++ )  {
+               for (c=0; c < 3; c++) {
                    *conp++ = atoi(cp);
-                   while ( *cp && *cp++ != '/' )
+                   while (*cp && *cp++ != '/')
                        ;
                }
            }
-           break;
+               break;
            default:
            case '?':
-               return  0;
+               return 0;
        }
     }
-    if ( argv[bu_optind] != NULL )  {
+    if (argv[bu_optind] != NULL) {
        if (bu_file_exists(argv[bu_optind])) {
-           (void) fprintf( stderr,
-                           "\"%s\" already exists.\n",
-                           argv[bu_optind] );
-           bu_exit( 1, NULL );
+           (void) fprintf(stderr,
+                          "\"%s\" already exists.\n",
+                          argv[bu_optind]);
+           bu_exit(1, NULL);
        }
-       if ( (outfp = fopen( argv[bu_optind], "wb" )) == NULL )  {
+       if ((outrle.rle_file = fopen(argv[bu_optind], "wb")) == NULL) {
            perror(argv[bu_optind]);
-           return      0;
+           return 0;
        }
     }
-    if ( argc > ++bu_optind )
-       (void) fprintf( stderr, "fb-rle: Excess arguments ignored\n" );
+    if (argc > ++bu_optind)
+       (void) fprintf(stderr, "fb-rle: Excess arguments ignored\n");
 
-    if ( isatty(fileno(outfp)) )
+    if (isatty(fileno(outrle.rle_file)))
        return 0;
-    return     1;
+    return 1;
 }
 
+
 /*
- *                     M A I N
+ * M A I N
  */
 int
 main(int argc, char **argv)
 {
-    FBIO       *fbp;
+    FBIO *fbp;
     unsigned char *scan_buf;
-    int        y;
-    int                cm_save_needed;
+    int y;
+    int cm_save_needed;
 
-    outfp = stdout;
-    if ( !get_args( argc, argv ) )  {
+    outrle.rle_file = stdout;
+    if (!get_args(argc, argv)) {
        (void)fputs(usage, stderr);
-       bu_exit( 1, NULL );
+       bu_exit(1, NULL);
     }
 
     /* If screen size = default & file size is given, track file size */
-    if ( screen_width == 0 && file_width > 0 )
+    if (screen_width == 0 && file_width > 0)
        screen_width = file_width;
-    if ( screen_height == 0 && file_height > 0 )
+    if (screen_height == 0 && file_height > 0)
        screen_height = file_height;
 
-    if ( (fbp = fb_open( framebuffer, screen_width, screen_height )) == 
FBIO_NULL )
+    if ((fbp = fb_open(framebuffer, screen_width, screen_height)) == FBIO_NULL)
        bu_exit(12, NULL);
 
     /* Honor original screen size desires, if set, unless they shrank */
-    if ( screen_width == 0 || fb_getwidth(fbp) < screen_width )
+    if (screen_width == 0 || fb_getwidth(fbp) < screen_width)
        screen_width = fb_getwidth(fbp);
-    if ( screen_height == 0 || fb_getheight(fbp) < screen_height )
+    if (screen_height == 0 || fb_getheight(fbp) < screen_height)
        screen_height = fb_getheight(fbp);
 
     /* If not specified, output file size tracks screen size */
-    if ( file_width == 0 )
+    if (file_width == 0)
        file_width = screen_width;
-    if ( file_height == 0 )
+    if (file_height == 0)
        file_height = screen_height;
 
     /* Clip below and to left of (0, 0) */
-    if ( screen_xoff < 0 )  {
+    if (screen_xoff < 0) {
        file_width += screen_xoff;
        screen_xoff = 0;
     }
-    if ( screen_yoff < 0 )  {
+    if (screen_yoff < 0) {
        file_height += screen_yoff;
        screen_yoff = 0;
     }
 
     /* Clip up and to the right */
-    if ( screen_xoff + file_width > screen_width )
+    if (screen_xoff + file_width > screen_width)
        file_width = screen_width - screen_xoff;
-    if ( screen_yoff + file_height > screen_height )
+    if (screen_yoff + file_height > screen_height)
        file_height = screen_height - screen_yoff;
 
-    if ( file_width <= 0 || file_height <= 0 )  {
+    if (file_width <= 0 || file_height <= 0) {
        fprintf(stderr,
                "fb-rle: Error: image rectangle entirely off screen\n");
        bu_exit(1, NULL);
@@ -226,21 +226,21 @@
 
     /* Read color map, see if it is linear */
     cm_save_needed = 1;
-    if ( fb_rmap( fbp, &cmap ) == -1 )
+    if (fb_rmap(fbp, &cmap) == -1)
        cm_save_needed = 0;
-    if ( cm_save_needed && fb_is_linear_cmap( &cmap ) )
+    if (cm_save_needed && fb_is_linear_cmap(&cmap))
        cm_save_needed = 0;
-    if ( crunch && (cm_save_needed == 0) )
+    if (crunch && (cm_save_needed == 0))
        crunch = 0;
 
     /* Convert to Utah format */
-    if ( cm_save_needed )  for ( y=0; y<256; y++ )  {
+    if (cm_save_needed) for (y=0; y<256; y++) {
        rlemap[y+0*256] = cmap.cm_red[y];
        rlemap[y+1*256] = cmap.cm_green[y];
        rlemap[y+2*256] = cmap.cm_blue[y];
     }
 
-    scan_buf = (unsigned char *)malloc( sizeof(RGBpixel) * screen_width );
+    scan_buf = (unsigned char *)malloc(sizeof(RGBpixel) * screen_width);
 
     /* Build RLE header */
     outrle.ncolors = 3;
@@ -250,7 +250,7 @@
     outrle.background = 2;             /* use background */
     outrle.bg_color = background;
     outrle.alpha = 0;                  /* no alpha channel */
-    if ( cm_save_needed && !crunch ) {
+    if (cm_save_needed && !crunch) {
        outrle.ncmap = 3;
        outrle.cmaplen = 8;             /* 1<<8 = 256 */
        outrle.cmap = rlemap;
@@ -266,62 +266,63 @@
     outrle.comments = (const char **)0;
 
     /* Add comments to the header file, since we have one */
-    if ( framebuffer == (char *)0 )
+    if (framebuffer == (char *)0)
        framebuffer = fbp->if_name;
-    snprintf( comment, COMMENT_SIZE, "encoded_from=%s", framebuffer );
-    rle_putcom( bu_strdup(comment), &outrle );
+    snprintf(comment, COMMENT_SIZE, "encoded_from=%s", framebuffer);
+    rle_putcom(bu_strdup(comment), &outrle);
     now = time(0);
-    snprintf( comment, COMMENT_SIZE, "encoded_date=%24.24s", ctime(&now) );
-    rle_putcom( bu_strdup(comment), &outrle );
-    if ( (who = getenv("USER")) != (char *)0 ) {
-       snprintf( comment, COMMENT_SIZE, "encoded_by=%s", who);
-       rle_putcom( bu_strdup(comment), &outrle );
+    snprintf(comment, COMMENT_SIZE, "encoded_date=%24.24s", ctime(&now));
+    rle_putcom(bu_strdup(comment), &outrle);
+    if ((who = getenv("USER")) != (char *)0) {
+       snprintf(comment, COMMENT_SIZE, "encoded_by=%s", who);
+       rle_putcom(bu_strdup(comment), &outrle);
     }
-#      if HAVE_GETHOSTNAME
-    gethostname( host, sizeof(host) );
-    snprintf( comment, COMMENT_SIZE, "encoded_host=%s", host);
-    rle_putcom( bu_strdup(comment), &outrle );
-#      endif
+# if HAVE_GETHOSTNAME
+    gethostname(host, sizeof(host));
+    snprintf(comment, COMMENT_SIZE, "encoded_host=%s", host);
+    rle_putcom(bu_strdup(comment), &outrle);
+# endif
 
-    rle_put_setup( &outrle );
-    rle_row_alloc( &outrle, &rows );
+    rle_put_setup(&outrle);
+    rle_row_alloc(&outrle, &rows);
 
     /* Read the image a scanline at a time, and encode it */
-    for ( y = 0; y < file_height; y++ )  {
-       if ( fb_read( fbp, screen_xoff, y+screen_yoff, scan_buf,
-                     file_width ) == -1 )  {
-           (void) fprintf(     stderr,
-                               "fb-rle: read of %d pixels on line %d 
failed!\n",
-                               file_width, y+screen_yoff );
+    for (y = 0; y < file_height; y++) {
+       if (fb_read(fbp, screen_xoff, y+screen_yoff, scan_buf,
+                   file_width) == -1) {
+           (void) fprintf(stderr,
+                          "fb-rle: read of %d pixels on line %d failed!\n",
+                          file_width, y+screen_yoff);
            bu_exit(1, NULL);
        }
 
-       if ( crunch )
-           cmap_crunch( (RGBpixel *)scan_buf, file_width, &cmap );
+       if (crunch)
+           cmap_crunch((RGBpixel *)scan_buf, file_width, &cmap);
 
        /* Grumble, convert to Utah layout */
        {
-           unsigned char       *pp = (unsigned char *)scan_buf;
-           rle_pixel   *rp = rows[0];
-           rle_pixel   *gp = rows[1];
-           rle_pixel   *bp = rows[2];
-           int         i;
+           unsigned char *pp = (unsigned char *)scan_buf;
+           rle_pixel *rp = rows[0];
+           rle_pixel *gp = rows[1];
+           rle_pixel *bp = rows[2];
+           int i;
 
-           for ( i=0; i<file_width; i++ )  {
+           for (i=0; i<file_width; i++) {
                *rp++ = *pp++;
                *gp++ = *pp++;
                *bp++ = *pp++;
            }
        }
-       rle_putrow( rows, file_width, &outrle );
+       rle_putrow(rows, file_width, &outrle);
     }
-    rle_puteof( &outrle );
+    rle_puteof(&outrle);
 
-    fb_close( fbp );
-    fclose( outfp );
-    bu_exit(0, NULL);
+    fb_close(fbp);
+    fclose(outrle.rle_file);
+    return 0;
 }
 
+
 /*
  * Local Variables:
  * mode: C

Modified: brlcad/trunk/src/fb/fbcmap.c
===================================================================
--- brlcad/trunk/src/fb/fbcmap.c        2010-11-17 18:25:44 UTC (rev 41392)
+++ brlcad/trunk/src/fb/fbcmap.c        2010-11-17 19:38:43 UTC (rev 41393)
@@ -35,18 +35,15 @@
 #include "fb.h"
 #include "pkg.h"
 
-void           usage(char **argv);
-int            pars_Argv(int argc, char **argv);
 
-static char    *framebuffer = NULL;
-static int     scr_width = 0;
-static int     scr_height = 0;
+static char *framebuffer = NULL;
+static int scr_width = 0;
+static int scr_height = 0;
 
 
-static ColorMap cmap;
-static int     flavor = 0;
-extern unsigned char   utah8[], utah9[];       /* defined at end of file */
-static unsigned char   utah_cmap[256] = {
+static int flavor = 0;
+
+static unsigned char utah_cmap[256] = {
     0,  4,  9, 13, 17, 21, 25, 29, 32, 36, 39, 42, 45, 48, 51, 54,
     57, 59, 62, 64, 67, 69, 72, 74, 76, 78, 81, 83, 85, 87, 89, 91,
     92, 94, 96, 98, 100, 101, 103, 105, 106, 108, 110, 111, 113, 114, 116, 117,
@@ -65,232 +62,7 @@
     249, 249, 249, 250, 250, 251, 251, 251, 252, 252, 252, 253, 253, 254, 254, 
255
 };
 
-int
-main(int argc, char **argv)
-{
-    int                i;
-    int                fudge;
-    ColorMap   *cp = &cmap;
-    FBIO *fbp;
 
-    if ( ! pars_Argv( argc, argv ) ) {
-       usage( NULL );
-       return  1;
-    }
-
-    if ( (fbp = fb_open( framebuffer, scr_width, scr_height )) == NULL )
-       return  1;
-
-    switch ( flavor )  {
-
-       case 0 : /* Standard - Linear color map */
-           (void) fprintf( stderr, "Color map #0, linear (standard).\n" );
-           cp = (ColorMap *) NULL;
-           break;
-
-       case 1 : /* Reverse linear color map */
-           (void) fprintf( stderr, "Color map #1, reverse-linear 
(negative).\n" );
-           for ( i = 0; i < 256; i++ ) {
-               cp->cm_red[255-i] =
-                   cp->cm_green[255-i] =
-                   cp->cm_blue[255-i] = i << 8;
-           }
-           break;
-
-       case 2 :
-           /* Experimental correction, for POLAROID 8x10 print film */
-           (void) fprintf( stderr,
-                           "Color map #2, corrected for POLAROID 809/891 
film.\n" );
-           /* First entry black */
-#define BOOST(point, bias) \
-       ((int)((bias)+((float)(point)/256.*(255-(bias)))))
-           for ( i = 1; i < 256; i++ )  {
-               fudge = BOOST(i, 70);
-               cp->cm_red[i] = fudge << 8;             /* B */
-           }
-           for ( i = 1; i < 256; i++ )  {
-               fudge = i;
-               cp->cm_green[i] = fudge << 8;   /* G */
-           }
-           for ( i = 1; i < 256; i++ )  {
-               fudge = BOOST( i, 30 );
-               cp->cm_blue[i] = fudge << 8;    /* R */
-           }
-           break;
-
-       case 3 : /* Standard, with low intensities set to black */
-           (void) fprintf( stderr, "Color map #3, low 100 entries black.\n" );
-           for ( i = 100; i < 256; i++ )  {
-               cp->cm_red[i] =
-                   cp->cm_green[i] =
-                   cp->cm_blue[i] = i << 8;
-           }
-           break;
-
-       case 4 : /* Amplify middle of the range, for Moss's dim pictures */
-#define UPSHIFT        64
-           (void) fprintf( stderr,
-                           "Color map #4, amplify middle range to boost dim 
pictures.\n" );
-           /* First entry black */
-           for ( i = 1; i< 256-UPSHIFT; i++ )  {
-               int j = i + UPSHIFT;
-               cp->cm_red[i] =
-                   cp->cm_green[i] =
-                   cp->cm_blue[i] = j << 8;
-           }
-           for ( i = 256-UPSHIFT; i < 256; i++ )  {
-               cp->cm_red[i] =
-                   cp->cm_green[i] =
-                   cp->cm_blue[i] = 255 << 8;  /* Full Scale */
-           }
-           break;
-
-       case 5 : /* University of Utah's color map */
-           (void) fprintf( stderr,
-                           "Color map #5, University of Utah's gamma 
correcting map.\n" );
-           for ( i = 0; i < 256; i++ )
-               cp->cm_red[i] =
-                   cp->cm_green[i] =
-                   cp->cm_blue[i] = utah_cmap[i] << 8;
-           break;
-
-       case 6 :        /* Delta's */
-           (void) fprintf( stderr, "Color map #6, color deltas.\n" );
-           /* white at zero */
-           cp->cm_red[0] = 65535;
-           cp->cm_green[0] = 65535;
-           cp->cm_blue[0] = 65535;
-           /* magenta at 32 */
-           cp->cm_red[32] = 65535;
-           cp->cm_blue[32] = 65535;
-           /* Red at 64 */
-           cp->cm_red[32*2] = 65535;
-           /* Yellow ... */
-           cp->cm_red[32*3] = 65535;
-           cp->cm_green[32*3] = 65535;
-           /* Green */
-           cp->cm_green[32*4] = 65535;
-           /* Cyan */
-           cp->cm_green[32*5] = 65535;
-           cp->cm_blue[32*5] = 65535;
-           /* Blue */
-           cp->cm_blue[32*6] = 65535;
-           break;
-
-       case 8:
-           (void) fprintf( stderr, "Color map #8, Ikcmap 8.\n" );
-           for ( i = 0; i < 256; i++ ) {
-               cp->cm_red[i] = utah8[3*i] << 8;
-               cp->cm_green[i] = utah8[3*i+1] << 8;
-               cp->cm_blue[i] = utah8[3*i+2] << 8;
-           }
-           break;
-
-       case 9:
-           (void) fprintf( stderr, "Color map #9, Ikcmap 9.\n" );
-           for ( i = 0; i < 256; i++ ) {
-               cp->cm_red[i] = utah9[3*i] << 8;
-               cp->cm_green[i] = utah9[3*i+1] << 8;
-               cp->cm_blue[i] = utah9[3*i+2] << 8;
-           }
-           break;
-
-       case 10:        /* Black */
-           (void) fprintf( stderr, "Color map #10, solid black.\n" );
-           break;
-
-       case 11:        /* White */
-           (void) fprintf( stderr, "Color map #11, solid white.\n" );
-           for ( i = 0; i < 256; i++ )  {
-               cp->cm_red[i] =
-                   cp->cm_green[i] =
-                   cp->cm_blue[i] = 255 << 8;
-           }
-           break;
-
-       case 12:        /* 18% Grey */
-           (void) fprintf( stderr, "Color map #12, 18%% neutral grey.\n" );
-           for ( i = 0; i < 256; i++ )  {
-               cp->cm_red[i] =
-                   cp->cm_green[i] =
-                   cp->cm_blue[i] = 46 << 8;
-           }
-           break;
-
-       default:
-           (void) fprintf(     stderr,
-                               "Color map #%d, flavor not implemented!\n",
-                               flavor );
-           usage( NULL );
-           return      1;
-    }
-    fb_wmap( fbp, cp );
-    return fb_close( fbp );
-}
-
-/*     p a r s _ A r g v ( )
- */
-int
-pars_Argv(int argc, char **argv)
-{
-    int        c;
-
-    while ( (c = bu_getopt( argc, argv, "hF:s:S:w:W:n:N:" )) != EOF ) {
-       switch ( c ) {
-           case 'h' :
-               scr_width = scr_height = 1024;
-               break;
-           case 'F':
-               framebuffer = bu_optarg;
-               break;
-           case 'S':
-           case 's':
-               /* square file size */
-               scr_height = scr_width = atoi(bu_optarg);
-               break;
-           case 'w':
-           case 'W':
-               scr_width = atoi(bu_optarg);
-               break;
-           case 'n':
-           case 'N':
-               scr_height = atoi(bu_optarg);
-               break;
-           case '?' :
-               return  0;
-       }
-    }
-    if ( argv[bu_optind] != NULL )
-       flavor = atoi( argv[bu_optind] );
-    return     1;
-}
-
-void
-usage(char **argv)
-{
-    (void) fprintf(stderr, "Usage : fbcmap [-h] [-F framebuffer]\n");
-    (void) fprintf(stderr, "   [-{sS} squarescrsize] [-{wW} scr_width] [-{nN} 
scr_height]\n");
-    (void) fprintf(stderr, "   [map_number]\n" );
-    (void) fprintf( stderr,
-                   "Color map #0, linear (standard).\n" );
-    (void) fprintf( stderr,
-                   "Color map #1, reverse-linear (negative).\n" );
-    (void) fprintf( stderr,
-                   "Color map #2, corrected for POLAROID 809/891 film.\n" );
-    (void) fprintf( stderr,
-                   "Color map #3, low 100 entries black.\n" );
-    (void) fprintf( stderr,
-                   "Color map #4, amplify middle range to boost dim 
pictures.\n" );
-    (void) fprintf( stderr,
-                   "Color map #5, University of Utah's gamma correcting 
map.\n" );
-    (void) fprintf( stderr, "Color map #6, color deltas.\n" );
-    (void) fprintf( stderr, "Color map #8, ikcmap 8.\n" );
-    (void) fprintf( stderr, "Color map #9, ikcmap 9.\n" );
-    (void) fprintf( stderr, "Color map #10, solid black.\n" );
-    (void) fprintf( stderr, "Color map #11, solid white.\n" );
-    (void) fprintf( stderr, "Color map #12, 18%% neutral grey.\n" );
-}
-
 /* Ikcmap 8 & 9 colormaps */
 unsigned char utah8[256*3] = {
     /* from 27.rle */
@@ -811,6 +583,237 @@
     255, 255, 255,
 };
 
+
+/* p a r s _ A r g v ()
+ */
+static int
+pars_Argv(int argc, char **argv)
+{
+    int c;
+
+    while ((c = bu_getopt(argc, argv, "hF:s:S:w:W:n:N:")) != EOF) {
+       switch (c) {
+           case 'h' :
+               scr_width = scr_height = 1024;
+               break;
+           case 'F':
+               framebuffer = bu_optarg;
+               break;
+           case 'S':
+           case 's':
+               /* square file size */
+               scr_height = scr_width = atoi(bu_optarg);
+               break;
+           case 'w':
+           case 'W':
+               scr_width = atoi(bu_optarg);
+               break;
+           case 'n':
+           case 'N':
+               scr_height = atoi(bu_optarg);
+               break;
+           case '?' :
+               return 0;
+       }
+    }
+    if (argv[bu_optind] != NULL)
+       flavor = atoi(argv[bu_optind]);
+    return 1;
+}
+
+
+static void
+usage()
+{
+    (void) fprintf(stderr, "Usage : fbcmap [-h] [-F framebuffer]\n");
+    (void) fprintf(stderr, "   [-{sS} squarescrsize] [-{wW} scr_width] [-{nN} 
scr_height]\n");
+    (void) fprintf(stderr, "   [map_number]\n");
+    (void) fprintf(stderr,
+                  "Color map #0, linear (standard).\n");
+    (void) fprintf(stderr,
+                  "Color map #1, reverse-linear (negative).\n");
+    (void) fprintf(stderr,
+                  "Color map #2, corrected for POLAROID 809/891 film.\n");
+    (void) fprintf(stderr,
+                  "Color map #3, low 100 entries black.\n");
+    (void) fprintf(stderr,
+                  "Color map #4, amplify middle range to boost dim 
pictures.\n");
+    (void) fprintf(stderr,
+                  "Color map #5, University of Utah's gamma correcting 
map.\n");
+    (void) fprintf(stderr, "Color map #6, color deltas.\n");
+    (void) fprintf(stderr, "Color map #8, ikcmap 8.\n");
+    (void) fprintf(stderr, "Color map #9, ikcmap 9.\n");
+    (void) fprintf(stderr, "Color map #10, solid black.\n");
+    (void) fprintf(stderr, "Color map #11, solid white.\n");
+    (void) fprintf(stderr, "Color map #12, 18%% neutral grey.\n");
+}
+
+
+int
+main(int argc, char **argv)
+{
+    int i;
+    int fudge;
+    ColorMap cmap;
+    ColorMap *cp = &cmap;
+    FBIO *fbp;
+
+    if (! pars_Argv(argc, argv)) {
+       usage();
+       return 1;
+    }
+
+    if ((fbp = fb_open(framebuffer, scr_width, scr_height)) == NULL)
+       return 1;
+
+    switch (flavor) {
+
+       case 0 : /* Standard - Linear color map */
+           (void) fprintf(stderr, "Color map #0, linear (standard).\n");
+           cp = (ColorMap *) NULL;
+           break;
+
+       case 1 : /* Reverse linear color map */
+           (void) fprintf(stderr, "Color map #1, reverse-linear 
(negative).\n");
+           for (i = 0; i < 256; i++) {
+               cp->cm_red[255-i] =
+                   cp->cm_green[255-i] =
+                   cp->cm_blue[255-i] = i << 8;
+           }
+           break;
+
+       case 2 :
+           /* Experimental correction, for POLAROID 8x10 print film */
+           (void) fprintf(stderr,
+                          "Color map #2, corrected for POLAROID 809/891 
film.\n");
+           /* First entry black */
+#define BOOST(point, bias) \
+       ((int)((bias)+((float)(point)/256.*(255-(bias)))))
+           for (i = 1; i < 256; i++) {
+               fudge = BOOST(i, 70);
+               cp->cm_red[i] = fudge << 8;             /* B */
+           }
+           for (i = 1; i < 256; i++) {
+               fudge = i;
+               cp->cm_green[i] = fudge << 8;   /* G */
+           }
+           for (i = 1; i < 256; i++) {
+               fudge = BOOST(i, 30);
+               cp->cm_blue[i] = fudge << 8;    /* R */
+           }
+           break;
+
+       case 3 : /* Standard, with low intensities set to black */
+           (void) fprintf(stderr, "Color map #3, low 100 entries black.\n");
+           for (i = 100; i < 256; i++) {
+               cp->cm_red[i] =
+                   cp->cm_green[i] =
+                   cp->cm_blue[i] = i << 8;
+           }
+           break;
+
+       case 4 : /* Amplify middle of the range, for Moss's dim pictures */
+#define UPSHIFT 64
+           (void) fprintf(stderr,
+                          "Color map #4, amplify middle range to boost dim 
pictures.\n");
+           /* First entry black */
+           for (i = 1; i< 256-UPSHIFT; i++) {
+               int j = i + UPSHIFT;
+               cp->cm_red[i] =
+                   cp->cm_green[i] =
+                   cp->cm_blue[i] = j << 8;
+           }
+           for (i = 256-UPSHIFT; i < 256; i++) {
+               cp->cm_red[i] =
+                   cp->cm_green[i] =
+                   cp->cm_blue[i] = 255 << 8;  /* Full Scale */
+           }
+           break;
+
+       case 5 : /* University of Utah's color map */
+           (void) fprintf(stderr,
+                          "Color map #5, University of Utah's gamma correcting 
map.\n");
+           for (i = 0; i < 256; i++)
+               cp->cm_red[i] =
+                   cp->cm_green[i] =
+                   cp->cm_blue[i] = utah_cmap[i] << 8;
+           break;
+
+       case 6 :        /* Delta's */
+           (void) fprintf(stderr, "Color map #6, color deltas.\n");
+           /* white at zero */
+           cp->cm_red[0] = 65535;
+           cp->cm_green[0] = 65535;
+           cp->cm_blue[0] = 65535;
+           /* magenta at 32 */
+           cp->cm_red[32] = 65535;
+           cp->cm_blue[32] = 65535;
+           /* Red at 64 */
+           cp->cm_red[32*2] = 65535;
+           /* Yellow ... */
+           cp->cm_red[32*3] = 65535;
+           cp->cm_green[32*3] = 65535;
+           /* Green */
+           cp->cm_green[32*4] = 65535;
+           /* Cyan */
+           cp->cm_green[32*5] = 65535;
+           cp->cm_blue[32*5] = 65535;
+           /* Blue */
+           cp->cm_blue[32*6] = 65535;
+           break;
+
+       case 8:
+           (void) fprintf(stderr, "Color map #8, Ikcmap 8.\n");
+           for (i = 0; i < 256; i++) {
+               cp->cm_red[i] = utah8[3*i] << 8;
+               cp->cm_green[i] = utah8[3*i+1] << 8;
+               cp->cm_blue[i] = utah8[3*i+2] << 8;
+           }
+           break;
+
+       case 9:
+           (void) fprintf(stderr, "Color map #9, Ikcmap 9.\n");
+           for (i = 0; i < 256; i++) {
+               cp->cm_red[i] = utah9[3*i] << 8;
+               cp->cm_green[i] = utah9[3*i+1] << 8;
+               cp->cm_blue[i] = utah9[3*i+2] << 8;
+           }
+           break;
+
+       case 10:        /* Black */
+           (void) fprintf(stderr, "Color map #10, solid black.\n");
+           break;
+
+       case 11:        /* White */
+           (void) fprintf(stderr, "Color map #11, solid white.\n");
+           for (i = 0; i < 256; i++) {
+               cp->cm_red[i] =
+                   cp->cm_green[i] =
+                   cp->cm_blue[i] = 255 << 8;
+           }
+           break;
+
+       case 12:        /* 18% Grey */
+           (void) fprintf(stderr, "Color map #12, 18%% neutral grey.\n");
+           for (i = 0; i < 256; i++) {
+               cp->cm_red[i] =
+                   cp->cm_green[i] =
+                   cp->cm_blue[i] = 46 << 8;
+           }
+           break;
+
+       default:
+           (void) fprintf(stderr,
+                          "Color map #%d, flavor not implemented!\n",
+                          flavor);
+           usage();
+           return 1;
+    }
+    fb_wmap(fbp, cp);
+    return fb_close(fbp);
+}
+
+
 /*
  * Local Variables:
  * mode: C

Modified: brlcad/trunk/src/fb/fbfade.c
===================================================================
--- brlcad/trunk/src/fb/fbfade.c        2010-11-17 18:25:44 UTC (rev 41392)
+++ brlcad/trunk/src/fb/fbfade.c        2010-11-17 19:38:43 UTC (rev 41393)
@@ -1,4 +1,4 @@
-/* F B F A D E . C
+/*                        F B F A D E . C
  * BRL-CAD
  *
  * Copyright (c) 2004-2010 United States Government as represented by
@@ -68,7 +68,7 @@
 #define USAGE1 "fbfade [ -s size ] [ -w width ] [ -n height ] [ -f in_fb_file 
]"
 #define USAGE2 \
        "\t[ -h ] [ -S size ] [ -W width ] [ -N height ] [ [ -F ] out_fb_file ]"
-#define OPTSTR "f:F:hn:N:s:S:w:W:"
+#define OPTSTR "f:F:hn:N:s:S:w:W:"
 
 
 typedef int bool_t;
@@ -77,16 +77,16 @@
 static char *in_fb_file = NULL;                /* input image name */
 static char *out_fb_file = NULL;       /* output frame buffer name */
 static FBIO *fbp = FBIO_NULL;          /* libfb input/output handle */
-static int src_width = 0,
-    src_height = 0;                    /* input image size */
-static int dst_width = 0,
-    dst_height = 0;                    /* output frame buffer size */
+static int src_width = 0;              /* input image width */
+static int src_height = 0;             /* input image height */
+static int dst_width = 0;              /* output frame buffer size */
+static int dst_height = 0;             /* output frame buffer size */
 static RGBpixel *pix;                  /* input image */
 static RGBpixel bg = { 0, 0, 0 };      /* background */
 
 /* in ioutil.c */
-void Message(const char *format, ...);
-void Fatal(FBIO *fbiop, const char *format, ...);
+extern void Message(const char *format, ...);
+extern void Fatal(FBIO *fbiop, const char *format, ...);
 
 
 static void
@@ -229,7 +229,7 @@
            if (ht < src_height)
                src_height = ht;
 
-           if ((pix = (RGBpixel *)malloc((size_t)src_width * 
(size_t)src_height * sizeof(RGBpixel) ) ) == NULL)
+           if ((pix = (RGBpixel *)malloc((size_t)src_width * 
(size_t)src_height * sizeof(RGBpixel))) == NULL)
                Fatal(fbp, "Not enough memory for pixel array");
 
            for (y = 0; y < src_height; ++y) {
@@ -319,9 +319,10 @@
        Fatal(fbp, "Error closing output frame buffer");
     }
 
-    bu_exit(EXIT_SUCCESS, NULL);
+    return 0;
 }
 
+
 /*
  * Local Variables:
  * mode: C


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to