shithub: rewise

Download patch

ref: 3bc1ca00562af4c7c3d287ae44181f02c361adb3
parent: caba3c6ab89bf631a0c12eab72d51d0353e0f782
author: Jacob Moody <[email protected]>
date: Sun May 7 20:40:19 EDT 2023

tidy diff against upstream and minor fixes

--- a/src/mkfile
+++ b/src/mkfile
@@ -1,6 +1,6 @@
 </$objtype/mkfile
 
-CFLAGS=$CLFAGS -p -I ../../include -I/sys/include/npe -I libpng -I zlib -D__plan9__ -D__${objtype}__ $POSIX -DSTDC
+CFLAGS=$CFLAGS -p -I/sys/include/npe -D__plan9__ -D__${objtype}__
 
 HFILES=\
 	print.h \
--- a/src/rewise.c
+++ b/src/rewise.c
@@ -20,9 +20,13 @@
 #include <stdlib.h>
 #include "getopt.h"
 #include <time.h>
-#include <libgen.h>
+#include <libgen.h> // dirname
 #include <errno.h>
 #include <sys/stat.h> // mkdir
+#include <utime.h>
+#ifndef __plan9__
+#include <sys/statvfs.h>
+#endif
 
 // PATH_MAX, NAME_MAX
 #ifdef __linux__
@@ -81,7 +85,10 @@
 
 
 unsigned long getFreeDiskSpace(char * path) {
-/*
+#ifdef __plan9__
+  USED(path);
+  return 9 * 1024 * 1024 * 1024 * 1024;
+#else
   struct statvfs fsStats;
   if (statvfs((const char *)path, &fsStats) != 0) {
     printError("Failed to determine free disk space for '%s'. Errno: %s\n",
@@ -88,9 +95,8 @@
                strerror(errno));
     return 0;
   }
-  return fsStats.f_bsize * fsStats.f_bavail
-*/
-  return 0;
+  return fsStats.f_bsize * fsStats.f_bavail;
+#endif
 }
 
 
@@ -300,7 +306,6 @@
   time_t creationSeconds;
   convertMsDosTime(&fileCreation, data->date, data->time);
   creationSeconds = mktime(&fileCreation);
-#ifndef __plan9__
   const struct utimbuf times = {
     .actime  = creationSeconds,
     .modtime = creationSeconds
@@ -309,7 +314,6 @@
     printWarning("Failed to set access and modification datetime for file "
                  "'%s'\n", outputFilePath);
   }
-#endif
 
   printInfo("Extracted %s\n", data->destFile);
 }
@@ -669,7 +673,7 @@
 
     // LIST
     if (operation == OP_LIST) {
-      callbacks.cb_0x00 = &printFile;
+      callbacks.cb_0x00 = printFile;
       printf("    FILESIZE FILEDATE   FILETIME FILEPATH\n");
       printf("------------ ---------- -------- ----------------------------\n");
       status = parseWiseScript(tmpFileScript, &callbacks);
@@ -699,7 +703,7 @@
       }
 
       // Start inflating and outputting files
-      callbacks.cb_0x00 = &extractFile;
+      callbacks.cb_0x00 = extractFile;
       status = parseWiseScript(tmpFileScript, &callbacks);
 
       // Something went wrong
@@ -717,7 +721,7 @@
     }
     else
     if (operation == OP_VERIFY) {
-      callbacks.cb_0x00 = &noExtractFile;
+      callbacks.cb_0x00 = noExtractFile;
       status = parseWiseScript(tmpFileScript, &callbacks);
       if (status != REWERR_OK) {
         printError("Parsing WiseScript failed.\n");
--- a/src/wisescript.c
+++ b/src/wisescript.c
@@ -1601,9 +1601,9 @@
   REWError status;
 
   initWiseScriptCallbacks(&callbacks);
-  callbacks.cb_0x00 = &updateParsedInfo0x00;
-  callbacks.cb_0x06 = &updateParsedInfo0x06;
-  callbacks.cb_0x14 = &updateParsedInfo0x14;
+  callbacks.cb_0x00 = updateParsedInfo0x00;
+  callbacks.cb_0x06 = updateParsedInfo0x06;
+  callbacks.cb_0x14 = updateParsedInfo0x14;
 
   WISESCRIPT_PARSED_INFO.totalInflatedSize  = 0;
   WISESCRIPT_PARSED_INFO.inflateStartOffset = 0;
@@ -1622,28 +1622,28 @@
   WiseScriptCallbacks callbacks;
 
   initWiseScriptCallbacks(&callbacks);
-  callbacks.cb_header = &printWiseScriptHeader;
-  callbacks.cb_texts  = &printWiseScriptTexts;
-  callbacks.cb_0x00   = &printWiseScriptFileHeader;
-  callbacks.cb_0x03   = &printWiseScriptUnknown0x03;
-  callbacks.cb_0x04   = &printWiseScriptUnknown0x04;
-  callbacks.cb_0x05   = &printWiseScriptUnknown0x05;
-  callbacks.cb_0x06   = &printWiseScriptUnknown0x06;
-  callbacks.cb_0x07   = &printWiseScriptUnknown0x07;
-  callbacks.cb_0x08   = &printWiseScriptUnknown0x08;
-  callbacks.cb_0x09   = &printWiseScriptUnknown0x09;
-  callbacks.cb_0x0A   = &printWiseScriptUnknown0x0A;
-  callbacks.cb_0x0B   = &printWiseScriptUnknown0x0B;
-  callbacks.cb_0x0C   = &printWiseScriptUnknown0x0C;
-  callbacks.cb_0x11   = &printWiseScriptUnknown0x11;
-  callbacks.cb_0x12   = &printWiseScriptUnknown0x12;
-  callbacks.cb_0x14   = &printWiseScriptUnknown0x14;
-  callbacks.cb_0x15   = &printWiseScriptUnknown0x15;
-  callbacks.cb_0x16   = &printWiseScriptUnknown0x16;
-  callbacks.cb_0x17   = &printWiseScriptUnknown0x17;
-  callbacks.cb_0x1C   = &printWiseScriptUnknown0x1C;
-  callbacks.cb_0x1E   = &printWiseScriptUnknown0x1E;
-  callbacks.cb_0x23   = &printWiseScriptUnknown0x23;
+  callbacks.cb_header = printWiseScriptHeader;
+  callbacks.cb_texts  = printWiseScriptTexts;
+  callbacks.cb_0x00   = printWiseScriptFileHeader;
+  callbacks.cb_0x03   = printWiseScriptUnknown0x03;
+  callbacks.cb_0x04   = printWiseScriptUnknown0x04;
+  callbacks.cb_0x05   = printWiseScriptUnknown0x05;
+  callbacks.cb_0x06   = printWiseScriptUnknown0x06;
+  callbacks.cb_0x07   = printWiseScriptUnknown0x07;
+  callbacks.cb_0x08   = printWiseScriptUnknown0x08;
+  callbacks.cb_0x09   = printWiseScriptUnknown0x09;
+  callbacks.cb_0x0A   = printWiseScriptUnknown0x0A;
+  callbacks.cb_0x0B   = printWiseScriptUnknown0x0B;
+  callbacks.cb_0x0C   = printWiseScriptUnknown0x0C;
+  callbacks.cb_0x11   = printWiseScriptUnknown0x11;
+  callbacks.cb_0x12   = printWiseScriptUnknown0x12;
+  callbacks.cb_0x14   = printWiseScriptUnknown0x14;
+  callbacks.cb_0x15   = printWiseScriptUnknown0x15;
+  callbacks.cb_0x16   = printWiseScriptUnknown0x16;
+  callbacks.cb_0x17   = printWiseScriptUnknown0x17;
+  callbacks.cb_0x1C   = printWiseScriptUnknown0x1C;
+  callbacks.cb_0x1E   = printWiseScriptUnknown0x1E;
+  callbacks.cb_0x23   = printWiseScriptUnknown0x23;
 
   return parseWiseScript(filepath, &callbacks);
 }