about summary refs log tree commit diff
path: root/generator/ppmpat.c
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2012-11-24 20:14:35 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2012-11-24 20:14:35 +0000
commit257bd5555bee87b68c79c3bb81c42a445f6d301a (patch)
tree13d0634cdbe434469d6c9d59db536ce528fb9364 /generator/ppmpat.c
parentd4b614c5a7b50f21e356e1b372cf1ac3dfa93406 (diff)
downloadnetpbm-mirror-257bd5555bee87b68c79c3bb81c42a445f6d301a.tar.gz
netpbm-mirror-257bd5555bee87b68c79c3bb81c42a445f6d301a.tar.xz
netpbm-mirror-257bd5555bee87b68c79c3bb81c42a445f6d301a.zip
Add -randomseed
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1779 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'generator/ppmpat.c')
-rw-r--r--generator/ppmpat.c40
1 files changed, 29 insertions, 11 deletions
diff --git a/generator/ppmpat.c b/generator/ppmpat.c
index c4ceb797..100b4978 100644
--- a/generator/ppmpat.c
+++ b/generator/ppmpat.c
@@ -41,6 +41,8 @@ struct cmdlineInfo {
     pattern basePattern;
     unsigned int width;
     unsigned int height;
+    unsigned int randomseed;
+    unsigned int randomseedSpec;
 };
 
 
@@ -71,16 +73,28 @@ parseCommandLine(int argc, const char ** argv,
     MALLOCARRAY_NOFAIL(option_def, 100);
 
     option_def_index = 0;   /* incremented by OPTENTRY */
-    OPTENT3(0, "gingham2",  OPT_FLAG,   NULL, &gingham2,   0);
-    OPTENT3(0, "g2",        OPT_FLAG,   NULL, &gingham2,   0);
-    OPTENT3(0, "gingham3",  OPT_FLAG,   NULL, &gingham3,   0);
-    OPTENT3(0, "g3",        OPT_FLAG,   NULL, &gingham3,   0);
-    OPTENT3(0, "madras",    OPT_FLAG,   NULL, &madras,     0);
-    OPTENT3(0, "tartan",    OPT_FLAG,   NULL, &tartan,     0);
-    OPTENT3(0, "poles",     OPT_FLAG,   NULL, &poles,      0);
-    OPTENT3(0, "squig",     OPT_FLAG,   NULL, &squig,      0);
-    OPTENT3(0, "camo",      OPT_FLAG,   NULL, &camo,       0);
-    OPTENT3(0, "anticamo",  OPT_FLAG,   NULL, &anticamo,   0);
+    OPTENT3(0, "gingham2",      OPT_FLAG,   NULL,
+            &gingham2,   0);
+    OPTENT3(0, "g2",            OPT_FLAG,   NULL,
+            &gingham2,   0);
+    OPTENT3(0, "gingham3",      OPT_FLAG,   NULL,
+            &gingham3,   0);
+    OPTENT3(0, "g3",            OPT_FLAG,   NULL,
+            &gingham3,   0);
+    OPTENT3(0, "madras",        OPT_FLAG,   NULL,
+            &madras,     0);
+    OPTENT3(0, "tartan",        OPT_FLAG,   NULL,
+            &tartan,     0);
+    OPTENT3(0, "poles",         OPT_FLAG,   NULL,
+            &poles,      0);
+    OPTENT3(0, "squig",         OPT_FLAG,   NULL,
+            &squig,      0);
+    OPTENT3(0, "camo",          OPT_FLAG,   NULL,
+            &camo,       0);
+    OPTENT3(0, "anticamo",      OPT_FLAG,   NULL,
+            &anticamo,   0);
+    OPTENT3(0, "randomseed",    OPT_UINT,   &cmdlineP->randomseed,
+            &cmdlineP->randomseedSpec,      0);
 
     opt.opt_table = option_def;
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
@@ -136,6 +150,7 @@ parseCommandLine(int argc, const char ** argv,
         if (cmdlineP->height < 1)
             pm_error("Height must be at least 1 pixel");
     }
+    free(option_def);
 }
 
 
@@ -1122,7 +1137,8 @@ main(int argc, const char ** argv) {
 
     validateComputableDimensions(cmdline.width, cmdline.height);
     
-    srand(pm_randseed());
+    srand(cmdline.randomseedSpec ? cmdline.randomseed : pm_randseed());
+
     pixels = ppm_allocarray(cmdline.width, cmdline.height);
 
     switch (cmdline.basePattern) {
@@ -1170,3 +1186,5 @@ main(int argc, const char ** argv) {
     return 0;
 }
 
+
+