beta-0.89.2
[luatex.git] / source / libs / zziplib / zziplib-0.13.62 / test / zzipsetstub.c
blob5d5ad0c903bbbf598f83c12f31752c1be4e6e7b0
1 #include <stdio.h>
2 #include <stdlib.h>
4 static const char usage[] =
6 "zzipsetstub <zipfile> <zipsfxstub>... \n"
7 " overwrite the header of the zipfile with the sfxstub code.\n"
8 " this is usually the last step in creating a selfextract archive\n"
9 " or an application with all its data appended as a zip.\n"
12 int
13 main (int argc, char ** argv)
15 int argn;
16 if (argc <= 2)
18 printf (usage);
19 exit (0);
23 char buf[17]; int n;
24 char* zipfile = 0; FILE* zipFILE = 0;
25 char* sfxfile = 0; FILE* sfxFILE = 0;
27 for (argn=1; argn < argc; argn++)
29 if (argv[argn][0] == '-') continue;
30 if (! zipfile) { zipfile = argv[argn]; continue; }
31 if (! sfxfile) { sfxfile = argv[argn]; continue; }
32 /* superflous argument */
35 zipFILE = fopen (zipfile, "r+b");
36 if (! zipFILE) { perror (zipfile); return 1; }
38 sfxFILE = fopen (sfxfile, "rb");
39 if (! sfxFILE) { perror (sfxfile); return 1; }
41 while (0 < (n = fread(buf, 1, 16, sfxFILE)))
43 buf[n] = '\0';
44 fwrite (buf, 1, n, zipFILE);
47 if (n == -1)
48 perror (argv[argn]);
50 fclose (sfxFILE);
51 fclose (zipFILE);
54 return 0;
57 /*
58 * Local variables:
59 * c-file-style: "stroustrup"
60 * End: