about summary refs log tree commit diff
path: root/converter/other
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2022-03-12 21:30:22 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2022-03-12 21:30:22 +0000
commit35631a7b3e08c1eedfe91c32be9a0a93effa07eb (patch)
tree009b8c1c2e5c62a8c850b24d1965eea3c15aa09f /converter/other
parentdebfd161228669926437c15b064f54ad8197828a (diff)
downloadnetpbm-mirror-35631a7b3e08c1eedfe91c32be9a0a93effa07eb.tar.gz
netpbm-mirror-35631a7b3e08c1eedfe91c32be9a0a93effa07eb.tar.xz
netpbm-mirror-35631a7b3e08c1eedfe91c32be9a0a93effa07eb.zip
Add -fixedtime
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4304 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/other')
-rw-r--r--converter/other/pamtopdbimg.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/converter/other/pamtopdbimg.c b/converter/other/pamtopdbimg.c
index 890237a8..da0f5064 100644
--- a/converter/other/pamtopdbimg.c
+++ b/converter/other/pamtopdbimg.c
@@ -55,6 +55,7 @@ struct CmdlineInfo {
     const char * notefile;  /* NULL if not specified */
     enum CompMode compMode;
     unsigned int depth4;
+    unsigned int fixedtime;
 };
 
 
@@ -97,6 +98,8 @@ parseCommandLine(int argc, const char ** argv,
             &uncompressed,            0);
     OPTENT3(0, "4depth",              OPT_FLAG,      NULL,
             &cmdlineP->depth4,        0);
+    OPTENT3(0, "fixedtime",           OPT_FLAG,      NULL,
+            &cmdlineP->fixedtime,     0);
 
     opt.opt_table = option_def;
     opt.short_allowed = false;  /* We have no short (old-fashioned) options */
@@ -154,19 +157,27 @@ static uint32_t const unixepoch = (66*365+17)*24*3600;
 
 static void
 setPdbHeader(PDBHEAD *    const pdbHeadP,
-             const char * const name) {
+             const char * const name,
+             bool         const wantFixedTime) {
 
     STRSCPY(pdbHeadP->name, name);
 
-    /*
-     * All of the Image Viewer pdb files that I've come across have
-     * 3510939142U (1997.08.16 14:38:22 UTC) here.  I don't know where
-     * this bizarre datetime comes from but the real date works fine so
-     * I'm using it.
-     */
-    pdbHeadP->ctime =
-        pdbHeadP->mtime = (uint32_t)time(NULL) + unixepoch;
+    {
+        /*
+         * All of the Image Viewer pdb files that I've come across have
+         * 3510939142U (1997.08.16 14:38:22 UTC) here.  I don't know where
+         * this bizarre datetime comes from but the real date works fine so
+         * I'm using it unless user asked for a fixed time (probably just so he
+         * gets repeatable output).
+         */
+
+        uint32_t const stdTime = 3510939142U;
 
+        uint32_t const hdrDt =
+            wantFixedTime ? stdTime : (uint32_t)time(NULL) + unixepoch;
+
+        pdbHeadP->ctime = pdbHeadP->mtime = hdrDt;
+    }
     MEMSCPY(&pdbHeadP->type, IPDB_vIMG);
     MEMSCPY(&pdbHeadP->id,   IPDB_View);
 }
@@ -749,7 +760,7 @@ main(int argc, const char **argv) {
     if (pdbP == NULL)
         pm_error("Failed to allocate IPDB structure");
 
-    setPdbHeader(pdbP->p, cmdline.title);
+    setPdbHeader(pdbP->p, cmdline.title, cmdline.fixedtime);
 
     readimg(pdbP, ifP, cmdline.depth4);