4 * include.c (c) 1998,1999 Brian Smith
11 #include <sys/types.h>
17 FILE *cfgfile
, *installfile
;
18 char *INSTALLER_APPLICATION
;
19 char *INSTALLER_VERSION
;
20 char *INSTALLER_TITLE
;
22 char *INSTALLER_FOLDER
;
23 char *INSTALLER_PROGRAM
;
24 char *INSTALLER_SHADOW
;
25 char *INSTALLER_OBJECT
;
27 char *INSTALLER_SYSVAR
;
28 char *INSTALLER_SYSLINE
;
29 char *INSTALLER_PACKAGES
[20];
30 char *INSTALLER_CONFIRM_WPS
;
31 char *INSTALLER_CONFIRM_CONFIGSYS
;
32 char *INSTALLER_CONFIRM_OVERWRITE
;
33 int INSTALLER_BITMAP_WIDTH
;
34 int INSTALLER_BITMAP_HEIGHT
;
35 int INSTALLER_PACKAGE_COUNT
=0;
38 char *packagefilename
[20];
40 void resetglobals(void);
42 int include_unpack(char *aname
);
44 void append_file(char *filename
)
50 if((appendfile
= fopen(filename
, "rb"))==NULL
)
52 printf("Error opening %s for reading!\n", filename
);
55 while(!feof(appendfile
))
57 amnt
= fread(buffer
, 1, 512, appendfile
);
58 fwrite(buffer
, 1, amnt
, installfile
);
63 void getline(FILE *f
, char *entry
, char *entrydata
)
71 if(in
[strlen(in
)-1] == '\n')
76 for(z
=0;z
<strlen(in
);z
++)
82 strcpy(entrydata
, &in
[z
+1]);
88 strcpy(entrydata
, "");
91 int main(int argc
, char *argv
[])
93 char entry
[8096], entrydata
[8096];
96 printf("Packinst- version 2.0 (c) 1999-2000 DBSoft\n\n");
99 printf("Usage: Packinst <filename.cfg>\n");
102 if((cfgfile
= fopen(argv
[1], "r"))==NULL
)
104 printf("Error opening config file \"%s\"!\n", argv
[1]);
107 if((installfile
= fopen("install.exe", "wb"))==NULL
)
109 printf("Error opening install.exe for writing!\n");
113 printf("Adding resources to sfx.exe...\n");
114 system("rc install.rc sfx.exe > NUL");
116 printf("Creating installer...\n");
117 append_file("sfx.exe");
118 fwrite("DBSOFT-HEADER", 1, 13, installfile
);
119 while(!feof(cfgfile
))
121 getline(cfgfile
, entry
, entrydata
);
122 if(stricmp(entry
, "INSTALLER_APPLICATION") == 0)
123 INSTALLER_APPLICATION
= (char *)strdup(entrydata
);
124 if(stricmp(entry
, "INSTALLER_VERSION") == 0)
125 INSTALLER_VERSION
= (char *)strdup(entrydata
);
126 if(stricmp(entry
, "INSTALLER_TITLE") == 0)
127 INSTALLER_TITLE
= (char *)strdup(entrydata
);
128 if(stricmp(entry
, "INSTALLER_PATH") == 0)
129 INSTALLER_PATH
= (char *)strdup(entrydata
);
130 if(stricmp(entry
, "INSTALLER_FOLDER") == 0)
131 INSTALLER_FOLDER
= (char *)strdup(entrydata
);
132 if(stricmp(entry
, "INSTALLER_PROGRAM") == 0)
133 INSTALLER_PROGRAM
= (char *)strdup(entrydata
);
134 if(stricmp(entry
, "INSTALLER_SHADOW") == 0)
135 INSTALLER_SHADOW
= (char *)strdup(entrydata
);
136 if(stricmp(entry
, "INSTALLER_OBJECT") == 0)
137 INSTALLER_OBJECT
= (char *)strdup(entrydata
);
138 if(stricmp(entry
, "INSTALLER_SETS") == 0)
139 INSTALLER_SETS
= (char *)strdup(entrydata
);
140 if(stricmp(entry
, "INSTALLER_SYSVAR") == 0)
141 INSTALLER_SYSVAR
= (char *)strdup(entrydata
);
142 if(stricmp(entry
, "INSTALLER_SYSLINE") == 0)
143 INSTALLER_SYSLINE
= (char *)strdup(entrydata
);
144 if(stricmp(entry
, "INSTALLER_CONFIRM_WPS") == 0)
145 INSTALLER_CONFIRM_WPS
= (char *)strdup(entrydata
);
146 if(stricmp(entry
, "INSTALLER_CONFIRM_CONFIGSYS") == 0)
147 INSTALLER_CONFIRM_CONFIGSYS
= (char *)strdup(entrydata
);
148 if(stricmp(entry
, "INSTALLER_CONFIRM_OVERWRITE") == 0)
149 INSTALLER_CONFIRM_OVERWRITE
= (char *)strdup(entrydata
);
150 if(stricmp(entry
, "INSTALLER_PACKAGE") == 0)
152 for(z
=0;z
<strlen(entrydata
);z
++)
154 if(entrydata
[z
] == ',')
157 packagefilename
[INSTALLER_PACKAGE_COUNT
] = (char *)strdup(entrydata
);
158 INSTALLER_PACKAGES
[INSTALLER_PACKAGE_COUNT
] = (char *)strdup(&entrydata
[z
+1]);
163 include_unpack(packagefilename
[INSTALLER_PACKAGE_COUNT
]);
164 packagefiles
[INSTALLER_PACKAGE_COUNT
] = files
;
165 INSTALLER_PACKAGE_COUNT
++;
169 fprintf(installfile
, "%s-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s-%d",
170 INSTALLER_APPLICATION
, INSTALLER_VERSION
, INSTALLER_TITLE
,
171 INSTALLER_PATH
, INSTALLER_FOLDER
, INSTALLER_PROGRAM
,
172 INSTALLER_SHADOW
, INSTALLER_OBJECT
, INSTALLER_SETS
, INSTALLER_SYSVAR
,
173 INSTALLER_SYSLINE
, INSTALLER_CONFIRM_WPS
, INSTALLER_CONFIRM_CONFIGSYS
,
174 INSTALLER_CONFIRM_OVERWRITE
, INSTALLER_PACKAGE_COUNT
);
175 for(z
=0;z
<INSTALLER_PACKAGE_COUNT
;z
++)
176 fprintf(installfile
, "-%s", INSTALLER_PACKAGES
[z
]);
177 fwrite("*", 1, 1, installfile
);
178 for(z
=0;z
<INSTALLER_PACKAGE_COUNT
;z
++)
182 stat(packagefilename
[z
], &blah
);
183 fprintf(installfile
, "DBSOFT-ACE%d%d-%lu*", z
, packagefiles
[z
], blah
.st_size
);
184 append_file(packagefilename
[z
]);
185 printf("Package: %s - %d files in %s (%lu bytes).\n", INSTALLER_PACKAGES
[z
], packagefiles
[z
], packagefilename
[z
], blah
.st_size
);