about summary refs log tree commit diff
path: root/generator/ppmcolors.c
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2006-08-19 03:12:28 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2006-08-19 03:12:28 +0000
commit1fd361a1ea06e44286c213ca1f814f49306fdc43 (patch)
tree64c8c96cf54d8718847339a403e5e67b922e8c3f /generator/ppmcolors.c
downloadnetpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.tar.gz
netpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.tar.xz
netpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.zip
Create Subversion repository
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'generator/ppmcolors.c')
-rw-r--r--generator/ppmcolors.c87
1 files changed, 87 insertions, 0 deletions
diff --git a/generator/ppmcolors.c b/generator/ppmcolors.c
new file mode 100644
index 00000000..9112e1b8
--- /dev/null
+++ b/generator/ppmcolors.c
@@ -0,0 +1,87 @@
+/******************************************************************************
+                                ppmcolors
+*******************************************************************************
+  Generate a color map containing all the colors representable with a certain
+  maxval.
+  
+  THIS PROGRAM IS OBSOLETE.  USE PAMSEQ INSTEAD.  WE KEEP THIS AROUND
+  FOR BACKWARD COMPATIBILITY.
+
+******************************************************************************/
+
+#include "ppm.h"
+#include "shhopt.h"
+#include "nstring.h"
+
+struct cmdlineInfo {
+    /* All the information the user supplied in the command line,
+       in a form easy for the program to use.
+    */
+    unsigned int maxval;   
+};
+
+
+
+static void
+parseCommandLine(int argc, char ** argv, struct cmdlineInfo *cmdlineP) {
+/*----------------------------------------------------------------------------
+   Note that the file spec array we return is stored in the storage that
+   was passed to us as the argv array.
+-----------------------------------------------------------------------------*/
+    optStruct3 opt;  /* set by OPTENT3 */
+    optEntry *option_def = malloc(100*sizeof(optEntry));
+    unsigned int option_def_index;
+
+    option_def_index = 0;   /* incremented by OPTENT3 */
+    OPTENT3(0,   "maxval",       OPT_UINT,   
+            &cmdlineP->maxval,  NULL, 0);
+    
+
+    opt.opt_table = option_def;
+    opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
+    opt.allowNegNum = FALSE;  /* We may have parms that are negative numbers */
+
+    /* defaults */
+    cmdlineP->maxval = 5;
+
+    optParseOptions3(&argc, argv, opt, sizeof(opt), 0);
+        /* Uses and sets argc, argv, and some of *cmdlineP and others. */
+
+    if (cmdlineP->maxval < 1)
+        pm_error("-maxval must be at least 1");
+    else if (cmdlineP->maxval > PPM_OVERALLMAXVAL)
+        pm_error("-maxval too high.  The maximum allowable value is %u",
+                 PPM_OVERALLMAXVAL);
+
+    if (argc-1 > 0)
+        pm_error("This program takes no arguments.  You specified %d",
+                 argc-1);
+}
+
+
+
+int
+main(int argc, char *argv[]) {
+
+    struct cmdlineInfo cmdline;
+    const char * cmd;   /* malloc'ed */
+    int rc;
+
+    ppm_init(&argc, argv);
+
+    parseCommandLine(argc, argv, &cmdline);
+
+    asprintfN(&cmd, "pamseq 3 %u -tupletype=RGB | pamtopnm", cmdline.maxval);
+
+    rc = system(cmd);
+
+    if (rc != 0) 
+        pm_error("pamseq|pamtopnm pipeline failed.  system() rc = %d", rc);
+
+    strfree(cmd);
+    exit(rc);
+}
+
+
+
+