Line 21... |
Line 21... |
21 |
#include "pkginst.h" /* include self for control */
|
21 |
#include "pkginst.h" /* include self for control */
|
22 |
#include "version.h"
|
22 |
#include "version.h"
|
23 |
|
23 |
|
24 |
|
24 |
|
25 |
/* return 1 if fname looks like a link filename, 0 otherwise */
|
25 |
/* return 1 if fname looks like a link filename, 0 otherwise */
|
26 |
static int islinkfile(char *fname) {
|
26 |
static int islinkfile(const char *fname) {
|
27 |
char *link1 = "LINKS\\";
|
27 |
char *link1 = "LINKS\\";
|
28 |
char *link2 = "links\\";
|
28 |
char *link2 = "links\\";
|
29 |
int x;
|
29 |
int x;
|
30 |
for (x = 0; ; x++) {
|
30 |
for (x = 0; ; x++) {
|
31 |
if (link1[x] == 0) return(1);
|
31 |
if (link1[x] == 0) return(1);
|
Line 34... |
Line 34... |
34 |
}
|
34 |
}
|
35 |
|
35 |
|
36 |
|
36 |
|
37 |
/* validate a filename (8+3, no weird characters, etc). returns 0 on success,
|
37 |
/* validate a filename (8+3, no weird characters, etc). returns 0 on success,
|
38 |
* nonzero otherwise. */
|
38 |
* nonzero otherwise. */
|
39 |
static int validfilename(char *fname) {
|
39 |
static int validfilename(const char *fname) {
|
40 |
int i, i2;
|
40 |
int i, i2;
|
41 |
char *validchars = "!#$%&'()-@^_`{}~";
|
41 |
char *validchars = "!#$%&'()-@^_`{}~";
|
42 |
int elemlen = 0;
|
42 |
int elemlen = 0;
|
43 |
int elemmaxlen = 8; /* switches from 8 to 3 depending wheter I am analyzing
|
43 |
int elemmaxlen = 8; /* switches from 8 to 3 depending wheter I am analyzing
|
44 |
a filename or an extension */
|
44 |
a filename or an extension */
|
Line 79... |
Line 79... |
79 |
}
|
79 |
}
|
80 |
|
80 |
|
81 |
|
81 |
|
82 |
/* processes a link file - that is, reads the target inside, and overwrite
|
82 |
/* processes a link file - that is, reads the target inside, and overwrite
|
83 |
* the file with new content */
|
83 |
* the file with new content */
|
84 |
static void processlinkfile(char *linkfile, char *dosdir, struct customdirs *dirlist, char *buff) {
|
84 |
static void processlinkfile(const char *linkfile, const char *dosdir, const struct customdirs *dirlist, char *buff) {
|
85 |
char origtarget[512];
|
85 |
char origtarget[512];
|
86 |
int x;
|
86 |
int x;
|
87 |
char *shortfile;
|
87 |
char *shortfile;
|
88 |
unsigned char comstub[] = { /* machine code of a COM stub launcher */
|
88 |
unsigned char comstub[] = { /* machine code of a COM stub launcher */
|
89 |
0xBC,0x00,0x00,0xBB,0x00,0x10,0xB4,0x4A,0xCD,0x21,0xBB,0x2A,0x01,0x8C,0x5F,0x04,
|
89 |
0xBC,0x00,0x00,0xBB,0x00,0x10,0xB4,0x4A,0xCD,0x21,0xBB,0x2A,0x01,0x8C,0x5F,0x04,
|
Line 154... |
Line 154... |
154 |
return(0);
|
154 |
return(0);
|
155 |
}
|
155 |
}
|
156 |
|
156 |
|
157 |
|
157 |
|
158 |
/* find a filename in a flist linked list, and returns a pointer to it */
|
158 |
/* find a filename in a flist linked list, and returns a pointer to it */
|
159 |
static struct flist_t *findfileinlist(struct flist_t *flist, char *fname) {
|
159 |
static struct flist_t *findfileinlist(struct flist_t *flist, const char *fname) {
|
160 |
while (flist != NULL) {
|
160 |
while (flist != NULL) {
|
161 |
if (strcmp(flist->fname, fname) == 0) return(flist);
|
161 |
if (strcmp(flist->fname, fname) == 0) return(flist);
|
162 |
flist = flist->next;
|
162 |
flist = flist->next;
|
163 |
}
|
163 |
}
|
164 |
return(NULL);
|
164 |
return(NULL);
|
165 |
}
|
165 |
}
|
166 |
|
166 |
|
167 |
|
167 |
|
168 |
/* prepare a package for installation. this is mandatory before actually installing it!
|
168 |
/* prepare a package for installation. this is mandatory before actually installing it!
|
169 |
* returns a pointer to the zip file's index on success, NULL on failure. the **zipfd pointer is updated with a file descriptor to the open zip file to install. */
|
169 |
* returns a pointer to the zip file's index on success, NULL on failure. the **zipfd pointer is updated with a file descriptor to the open zip file to install. */
|
170 |
struct ziplist *pkginstall_preparepackage(const char *pkgname, const char *zipfile, int flags, FILE **zipfd, const char *dosdir, const struct customdirs *dirlist, char *buffmem1k) {
|
170 |
struct ziplist *pkginstall_preparepackage(const char *pkgname, const char *zipfile, int flags, FILE **zipfd, const char *dosdir, const struct customdirs *dirlist) {
|
171 |
char *fname;
|
171 |
char fname[256];
|
172 |
char *appinfofile;
|
172 |
char appinfofile[256];
|
173 |
int appinfopresence;
|
173 |
int appinfopresence;
|
174 |
char *shortfile;
|
174 |
char *shortfile;
|
175 |
struct ziplist *ziplinkedlist = NULL, *curzipnode, *prevzipnode;
|
175 |
struct ziplist *ziplinkedlist = NULL, *curzipnode, *prevzipnode;
|
176 |
struct flist_t *flist = NULL;
|
176 |
struct flist_t *flist = NULL;
|
177 |
|
177 |
|
178 |
fname = buffmem1k;
|
- |
|
179 |
appinfofile = buffmem1k + 512;
|
- |
|
180 |
|
- |
|
181 |
sprintf(appinfofile, "appinfo\\%s.lsm", pkgname); /* Prepare the appinfo/xxxx.lsm filename string for later use */
|
178 |
sprintf(appinfofile, "appinfo\\%s.lsm", pkgname); /* Prepare the appinfo/xxxx.lsm filename string for later use */
|
182 |
|
179 |
|
183 |
/* check if not already installed, if already here, print a message "you might want to use update instead"
|
180 |
/* check if not already installed, if already here, print a message "you might want to use update instead"
|
184 |
* of course this must not be done if we are in the process of upgrading said package */
|
181 |
* of course this must not be done if we are in the process of upgrading said package */
|
185 |
if (((flags & PKGINST_UPDATE) == 0) && (validate_package_not_installed(pkgname, dosdir) != 0)) {
|
182 |
if (((flags & PKGINST_UPDATE) == 0) && (validate_package_not_installed(pkgname, dosdir) != 0)) {
|
Line 293... |
Line 290... |
293 |
}
|
290 |
}
|
294 |
|
291 |
|
295 |
|
292 |
|
296 |
/* install a package that has been prepared already. returns 0 on success,
|
293 |
/* install a package that has been prepared already. returns 0 on success,
|
297 |
* or a negative value on error, or a positive value on warning */
|
294 |
* or a negative value on error, or a positive value on warning */
|
298 |
int pkginstall_installpackage(char *pkgname, char *dosdir, struct customdirs *dirlist, struct ziplist *ziplinkedlist, FILE *zipfd) {
|
295 |
int pkginstall_installpackage(const char *pkgname, const char *dosdir, const struct customdirs *dirlist, struct ziplist *ziplinkedlist, FILE *zipfd) {
|
299 |
char *buff;
|
296 |
char *buff;
|
300 |
char *fulldestfilename;
|
297 |
char *fulldestfilename;
|
301 |
char packageslst[64];
|
298 |
char packageslst[64];
|
302 |
char *shortfile;
|
299 |
char *shortfile;
|
303 |
long filesextractedsuccess = 0, filesextractedfailure = 0;
|
300 |
long filesextractedsuccess = 0, filesextractedfailure = 0;
|