summaryrefslogtreecommitdiff
path: root/Build/source/libs/zziplib/zziplib-0.13.62/test/zzipsetstub.c
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/zziplib/zziplib-0.13.62/test/zzipsetstub.c')
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.62/test/zzipsetstub.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/Build/source/libs/zziplib/zziplib-0.13.62/test/zzipsetstub.c b/Build/source/libs/zziplib/zziplib-0.13.62/test/zzipsetstub.c
new file mode 100644
index 00000000000..5d5ad0c903b
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.62/test/zzipsetstub.c
@@ -0,0 +1,61 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+static const char usage[] =
+{
+ "zzipsetstub <zipfile> <zipsfxstub>... \n"
+ " overwrite the header of the zipfile with the sfxstub code.\n"
+ " this is usually the last step in creating a selfextract archive\n"
+ " or an application with all its data appended as a zip.\n"
+};
+
+int
+main (int argc, char ** argv)
+{
+ int argn;
+ if (argc <= 2)
+ {
+ printf (usage);
+ exit (0);
+ }
+
+ {
+ char buf[17]; int n;
+ char* zipfile = 0; FILE* zipFILE = 0;
+ char* sfxfile = 0; FILE* sfxFILE = 0;
+
+ for (argn=1; argn < argc; argn++)
+ {
+ if (argv[argn][0] == '-') continue;
+ if (! zipfile) { zipfile = argv[argn]; continue; }
+ if (! sfxfile) { sfxfile = argv[argn]; continue; }
+ /* superflous argument */
+ }
+
+ zipFILE = fopen (zipfile, "r+b");
+ if (! zipFILE) { perror (zipfile); return 1; }
+
+ sfxFILE = fopen (sfxfile, "rb");
+ if (! sfxFILE) { perror (sfxfile); return 1; }
+
+ while (0 < (n = fread(buf, 1, 16, sfxFILE)))
+ {
+ buf[n] = '\0';
+ fwrite (buf, 1, n, zipFILE);
+ }
+
+ if (n == -1)
+ perror (argv[argn]);
+
+ fclose (sfxFILE);
+ fclose (zipFILE);
+ }
+
+ return 0;
+}
+
+/*
+ * Local variables:
+ * c-file-style: "stroustrup"
+ * End:
+ */