1 #include <stdio.h>
2 #include <stdlib.h>
3
4 static const char usage[] =
5 {
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"
10 };
11
12 int
main(int argc,char ** argv)13 main (int argc, char ** argv)
14 {
15 int argn;
16 if (argc <= 2)
17 {
18 printf (usage);
19 exit (0);
20 }
21
22 {
23 char buf[17]; int n;
24 char* zipfile = 0; FILE* zipFILE = 0;
25 char* sfxfile = 0; FILE* sfxFILE = 0;
26
27 for (argn=1; argn < argc; argn++)
28 {
29 if (argv[argn][0] == '-') continue;
30 if (! zipfile) { zipfile = argv[argn]; continue; }
31 if (! sfxfile) { sfxfile = argv[argn]; continue; }
32 /* superflous argument */
33 }
34
35 zipFILE = fopen (zipfile, "r+b");
36 if (! zipFILE) { perror (zipfile); return 1; }
37
38 sfxFILE = fopen (sfxfile, "rb");
39 if (! sfxFILE) { perror (sfxfile); return 1; }
40
41 while (0 < (n = fread(buf, 1, 16, sfxFILE)))
42 {
43 buf[n] = '\0';
44 fwrite (buf, 1, n, zipFILE);
45 }
46
47 if (n == -1)
48 perror (argv[argn]);
49
50 fclose (sfxFILE);
51 fclose (zipFILE);
52 }
53
54 return 0;
55 }
56
57 /*
58 * Local variables:
59 * c-file-style: "stroustrup"
60 * End:
61 */
62