2 * install.c (c) 1998,1999 Brian Smith
3 * parts by Daniele Vistalli
12 #if defined(__OS2__) || defined(__EMX__) || defined(WINNT) || defined(WIN32)
15 #include <sys/types.h>
19 #if !defined(__EMX__) && !defined(__OS2__) && !defined(WIN32) && !defined(WINNT)
20 #define stricmp strcasecmp
23 /* My Global variables ;) unusually many due to multiple dialogs */
24 char tempPath
[MAX_PATH
];
25 int installstate
= NONE
;
27 int current_file
=0, success
=0;
28 unsigned long int acepos
=0, aceoffset
=0;
30 char confirmstring
[1024];
31 /* I know I am being excessive but... better safe than sorry ;) */
32 char *configsys
[8196];
33 int configfilecount
=-1;
34 int files
= 0, files_deleted
=0, packagesize
=0, packagesselected
[20];
35 /* Global flags often set by the user */
36 int driveselected
, packagechosen
, express
= 1, driverstatus
= -1, no_update
= 0;
37 int licensechecked
= 0, custom
= 0, checkforupdate
= 1, downloadsite
= 0;
38 int usescitech
= 1, usecurrent
= 0, checking
= 0, checkerror
= 0, newerver
= 0;
39 char sddfilename
[256] = "", sddversion
[256] = "", sdddate
[256] = "";
40 char sddurl
[4][256] = { "", "", "", "" };
42 /* So these are accessible to REXX */
46 /* These get loaded in loadheader */
47 char *INSTALLER_APPLICATION
;
48 char *INSTALLER_VERSION
;
49 char *INSTALLER_TITLE
;
51 char *INSTALLER_FOLDER
;
52 char *INSTALLER_PROGRAM
;
53 char *INSTALLER_SHADOW
;
54 char *INSTALLER_OBJECT
;
56 char *INSTALLER_SYSVAR
;
57 char *INSTALLER_SYSLINE
;
58 char *INSTALLER_PACKAGES
[20];
59 char *INSTALLER_CONFIRM_WPS
;
60 char *INSTALLER_CONFIRM_CONFIGSYS
;
61 char *INSTALLER_CONFIRM_OVERWRITE
;
62 int INSTALLER_PACKAGE_COUNT
;
64 /* Will have to seperate this stuff to platform specifics... */
66 /* Config.Sys -- Note the drive letter gets replaced with the boot drive letter
67 It is just a place holder. (For the next 3 entries) */
68 char csfile
[] = "C:\\CONFIG.SYS";
69 /* Backup Config.Sys filename */
70 char bufile
[] = "C:\\CONFIG.SDD";
71 /* Installation Log Database -- Used for uninstallation and aborting */
72 #if defined(__OS2__) || defined(__EMX__) || defined(WINNT) || defined(WIN32)
73 char instlog
[] = "C:\\DBINST.LOG";
75 char instlog
[] = "~/dbinst.log";
79 char bootdrive
[2] = "C";
80 char winpath
[400] = "C:\\OS2\\MDOS\\WINOS2";
81 char winjpath
[400] = "C:\\OS2\\MDOS\\WINJOS2";
82 char wintpath
[400] = "C:\\OS2\\MDOS\\WINTOS2";
83 char winhpath
[400] = "C:\\OS2\\MDOS\\WINHOS2";
84 char browsedir
[400] = "C:\\";
85 char installdir2
[400] = "";
86 char empty_string
[] = "";
87 char currentcf
[400] = "";
93 /* Function prototypes */
94 int installer_unpack(char *filename
, int operation
);
95 void resetglobals(void);
97 typedef struct _replacements
{
98 char *replacestring
, *replacevar
;
101 /* The variables in this array must be static buffers */
102 Replacements InstRep
[] = {
103 { "%INSTALLPATH%", installdir
},
104 { "%BOOTDRIVE%", bootdrive
},
105 { "%ANYSTRING%", empty_string
},
106 { "%WINPATH%", winpath
},
107 { "%WINJPATH%", winjpath
},
108 { "%WINTPATH%", wintpath
},
109 { "%WINHPATH%", winhpath
},
110 { "%USERPATH%", installdir2
},
111 { "%VERSION%", "1.0" }, /* This may be depricated */
112 { "%WEB_VER%", sddversion
},
113 { "%WEB_DATE%", sdddate
},
114 { "%WEB_LOCATION1%", sddurl
[0] },
115 { "%WEB_LOCATION2%", sddurl
[1] },
116 { "%WEB_LOCATION3%", sddurl
[2] },
117 { "%WEB_LOCATION4%", sddurl
[3] },
122 /* In str1, str2 gets replaced by str3 */
123 char *replacestr(char *str1
, char *str2
, char *str3
)
125 char bigbuffer
[4096];
126 int z
, x
=0, len1
= strlen(str1
), len2
= strlen(str2
), len3
= strlen(str3
);
130 if(len2
> 0 && strncmp(&str1
[z
], str2
, len2
)==0)
135 bigbuffer
[x
] = str3
[i
];
140 bigbuffer
[x
] = str1
[z
];
145 return (char *)strdup(bigbuffer
);
148 /* This function parses a string and replaces all the text in the
149 * Replacement array with the current dynamic text */
150 char *replaceem(char *orig
)
152 char *tmp1
= NULL
, *tmp2
= (char *)strdup(orig
);
155 for(z
=0;z
<replacemax
;z
++)
157 tmp1
= replacestr(tmp2
, InstRep
[z
].replacestring
, InstRep
[z
].replacevar
);
166 * Find the offset withing the executable of the ace data for use.
168 int aceseek_entry(int num
)
171 char headerbuf
[20], packageconfig
[100];
172 int z
, start
= 0, entry
= 0, packageoffset
=0;
173 /* Decode DBSOFT-ACE - small memleak but
174 * install should not be running for very long. :) */
175 sprintf(headerbuf
, "%s%d", decode("EEECFDEPEGFECNEBEDEF"), num
);
176 if((headerstart
= findtext(headerbuf
)) < 0)
178 mesg("Could not find ACE header in executable.");
182 fseek(self
, headerstart
+strlen(headerbuf
), SEEK_SET
);
183 fread(packageconfig
, 1, 100, self
);
187 if(packageconfig
[z
] == '-' || packageconfig
[z
] == '*')
189 char cur
= packageconfig
[z
];
190 packageconfig
[z
] = 0;
195 files
= atoi(&packageconfig
[start
]);
198 packagesize
= atoi(&packageconfig
[start
]);
204 packageoffset
= z
+ 1;
210 aceoffset
=headerstart
+strlen(headerbuf
)+packageoffset
;
211 fseek(self
, aceoffset
, SEEK_SET
);
216 * Reads the embedded .cfg data from the executable and place it in the global
217 * INSTALL_* variables for use.
223 int z
, start
=0, entry
=0;
225 buffer
= malloc(8096*4);
227 /* Decode DBSOFT-HEADER */
228 if((headerstart
= findtext(decode("EEECFDEPEGFECNEIEFEBEEEFFC"))) < 0)
230 mesg("Could not find Selfinstaller header in executable.");
233 fseek(self
, headerstart
+13, SEEK_SET
);
235 fread(buffer
, 1, 8096*4, self
);
236 for(z
=0;z
<8096*4;z
++)
238 if(buffer
[z
] == '-' || buffer
[z
] == '*')
240 char cur
= buffer
[z
];
245 INSTALLER_APPLICATION
= (char *)strdup(&buffer
[start
]);
248 INSTALLER_VERSION
= (char *)strdup(&buffer
[start
]);
251 INSTALLER_TITLE
= (char *)strdup(&buffer
[start
]);
254 INSTALLER_PATH
= (char *)strdup(&buffer
[start
]);
257 INSTALLER_FOLDER
= (char *)strdup(&buffer
[start
]);
260 INSTALLER_PROGRAM
= (char *)strdup(&buffer
[start
]);
263 INSTALLER_SHADOW
= (char *)strdup(&buffer
[start
]);
266 INSTALLER_OBJECT
= (char *)strdup(&buffer
[start
]);
269 INSTALLER_SETS
= (char *)strdup(&buffer
[start
]);
272 INSTALLER_SYSVAR
= (char *)strdup(&buffer
[start
]);
275 INSTALLER_SYSLINE
= (char *)strdup(&buffer
[start
]);
278 INSTALLER_CONFIRM_WPS
= (char *)strdup(&buffer
[start
]);
281 INSTALLER_CONFIRM_CONFIGSYS
= (char *)strdup(&buffer
[start
]);
284 INSTALLER_CONFIRM_OVERWRITE
= (char *)strdup(&buffer
[start
]);
287 INSTALLER_PACKAGE_COUNT
= atoi(&buffer
[start
]);
290 INSTALLER_PACKAGES
[entry
-15] = malloc((z
-start
)+1);
291 strcpy(INSTALLER_PACKAGES
[entry
-15], &buffer
[start
]);
309 * Functions to work on an ace file embedded within the archive in an
312 int aceread(void *buf
, size_t count
)
314 unsigned long curpos
= ftell(self
);
317 if(count
> (packagesize
-(curpos
-aceoffset
)))
318 readit
= (packagesize
-(curpos
-aceoffset
));
322 return fread(buf
, 1, readit
, self
);
325 off_t
acelseek(off_t offset
, int whence
)
330 fseek(self
, aceoffset
+offset
, SEEK_SET
);
333 fseek(self
, offset
, SEEK_CUR
);
336 acepos
= ftell(self
);
337 return acepos
-aceoffset
;
340 int aceopen(const char *path
, int flags
)
342 fseek(self
, aceoffset
, SEEK_SET
);
348 fseek(self
, aceoffset
, SEEK_SET
);
359 return ftell(self
)-aceoffset
;
363 * Read the generated log file and remove any files installed.
365 void delete_files(void)
367 char tmpbuf
[8196], *fileptr
;
369 int linenum
=0, found
=-1, z
;
373 if((tmplf
=fopen(instlog
, "rb"))==NULL
)
378 fgets(tmpbuf
, 8196, tmplf
);
380 if(tmpbuf
[0]=='[' && (char *)strstr(tmpbuf
, INSTALLER_APPLICATION
) != NULL
&& !feof(tmplf
))
382 fgets(tmpbuf
, 8196, tmplf
);
384 if((char *)strstr(tmpbuf
, "<Version>") != NULL
&& (char *)strstr(tmpbuf
, INSTALLER_VERSION
) != NULL
)
391 for (z
=0;z
<found
;z
++)
392 fgets(tmpbuf
, 8196, tmplf
);
395 fgets(tmpbuf
, 8196, tmplf
);
396 if((char *)strstr(tmpbuf
, "<FileInst>") != NULL
)
398 fileptr
= (char *)strchr(tmpbuf
, ',')+1;
399 /* Remove trailing CRLFs */
400 if(fileptr
[strlen(fileptr
)-1] == '\r' || fileptr
[strlen(fileptr
)-1] == '\n')
401 fileptr
[strlen(fileptr
)-1]=0;
402 if(fileptr
[strlen(fileptr
)-1] == '\r' || fileptr
[strlen(fileptr
)-1] == '\n')
403 fileptr
[strlen(fileptr
)-1]=0;
410 if((char *)strstr(tmpbuf
, "<End>") != NULL
)
422 * Reads a config file into memory for editing with updatesys, updateset, etc.
424 int readconfigfile(char *filename
)
429 /* Reset this value when restarting */
430 configfilecount
= -1;
432 if((tmpcs
=fopen(filename
, "rb"))==NULL
)
434 strcpy(currentcf
, empty_string
);
438 strcpy(currentcf
, filename
);
443 fgets(tmpbuf
, 8196, tmpcs
);
444 configsys
[configfilecount
] = malloc(strlen(tmpbuf
)+1);
445 strcpy(configsys
[configfilecount
], tmpbuf
);
446 stripcrlf(configsys
[configfilecount
]);
454 * Write the updated config file to disk and backup the original.
456 int writeconfigfile(char *filename
, char *backup
)
464 rename(filename
, backup
);
469 if((tmpcs
=fopen(filename
, "wb"))==NULL
)
472 for(i
=0;i
<configfilecount
;i
++)
476 fwrite(configsys
[i
], 1, strlen(configsys
[i
]), tmpcs
);
477 /* Add the CRLF that got stripped in the reading stage. */
478 fwrite("\r\n", 1, 2, tmpcs
);
487 * Adds or replaces a SET variable based on the flags (CONFIG.SYS)
489 void updateset(char *setname
, char *newvalue
, int flag
)
491 char *cmpbuf1
, *cmpbuf2
, *tmpptr
, *tmpptr2
, *nv
;
494 nv
=replaceem(newvalue
);
496 cmpbuf1
=malloc(strlen(setname
)+2);
497 strcpy(cmpbuf1
, setname
);
498 strcat(cmpbuf1
, "=");
499 for(i
=0;i
<configfilecount
;i
++)
501 if(strlen(cmpbuf1
) <= strlen(configsys
[i
]))
503 tmpptr
=(char *)strdup(configsys
[i
]);
504 #if defined(__EMX__) || defined(__OS2__) || defined(WIN32) || defined(WINNT)
507 if((tmpptr2
=(char*)strstr(tmpptr
, "SET "))!=NULL
)
510 cmpbuf2
=malloc(strlen(tmpptr2
)+1);
511 /* Remove any spaces from the string */
513 for (t
=0;t
<strlen(tmpptr2
) && z
< strlen(cmpbuf1
);t
++)
515 if(tmpptr2
[t
] != ' ')
517 cmpbuf2
[z
]=tmpptr2
[t
];
522 if(stricmp(cmpbuf1
, cmpbuf2
) == 0)
524 /* Ok we found the entry, and if UPDATE_ALWAYS change it to the
525 new entry, otherwise exit */
526 if(flag
== UPDATE_ALWAYS
)
528 #ifdef ENABLE_LOGGING
529 fprintf(logfile
, "<CFRemLine>,%s,%s\r\n", currentcf
, configsys
[i
]);
532 configsys
[i
] = malloc(strlen(setname
)+strlen(nv
)+6);
533 strcpy(configsys
[i
], "SET ");
534 strcat(configsys
[i
], setname
);
535 strcat(configsys
[i
], "=");
536 strcat(configsys
[i
], nv
);
537 #ifdef ENABLE_LOGGING
538 fprintf(logfile
, "<CFAddLine>,%s,%s\r\n", currentcf
, configsys
[i
]);
540 free(cmpbuf1
);free(cmpbuf2
);free(tmpptr
);
549 /* Couldn't find the line so we'll add it */
550 configsys
[configfilecount
]=malloc(strlen(cmpbuf1
)+strlen(nv
)+6);
551 strcpy(configsys
[configfilecount
], "SET ");
552 strcat(configsys
[configfilecount
], setname
);
553 strcat(configsys
[configfilecount
], "=");
554 strcat(configsys
[configfilecount
], nv
);
555 #ifdef ENABLE_LOGGING
556 fprintf(logfile
, "<CFAddLine>,%s,%s\r\n", currentcf
, configsys
[configfilecount
]);
563 * Adds an entry to a system variable (CONFIG.SYS)
565 void updatesys(char *sysname
, char *newvalue
)
567 char *cmpbuf1
, *cmpbuf2
, *tmpptr
, *tmpptr2
, *capbuf1
, *capbuf2
, *nv
, *brian
;
570 nv
=replaceem(newvalue
);
572 cmpbuf1
=malloc(strlen(sysname
)+2);
573 strcpy(cmpbuf1
, sysname
);
574 strcat(cmpbuf1
, "=");
575 for(i
=0;i
<configfilecount
;i
++)
577 if(strlen(cmpbuf1
) <= strlen(configsys
[i
]))
579 cmpbuf2
=malloc(strlen(configsys
[i
])+1);
580 /* Remove any spaces from the string */
582 for (t
=0;t
<strlen(configsys
[i
]) && z
< strlen(cmpbuf1
);t
++)
584 if(configsys
[i
][t
] != ' ')
586 cmpbuf2
[z
]=configsys
[i
][t
];
591 if(stricmp(cmpbuf1
, cmpbuf2
) == 0)
593 /* Do a case insensitive comparison but preserve the case */
594 tmpptr
= &configsys
[i
][t
];
595 capbuf1
=malloc(strlen(tmpptr
)+1);
596 capbuf2
=malloc(strlen(nv
)+1);
597 strcpy(capbuf1
, tmpptr
);
599 #if defined(__EMX__) || defined(__OS2__) || defined(WINNT) || defined(WIN32)
603 /* Ok, we found the line, and it doesn't have an entry so we'll add it */
604 if((tmpptr2
=(char *)strstr(capbuf1
, capbuf2
)) == NULL
)
606 #ifdef ENABLE_LOGGING
607 fprintf(logfile
, "<CFRemLine>,%s,%s\r\n", currentcf
, configsys
[i
]);
609 brian
= configsys
[i
];
610 configsys
[i
] = malloc(strlen(configsys
[i
])+strlen(nv
)+4);
611 strcpy(configsys
[i
], brian
);
613 /* Remove any trailing CRLFs */
614 if(configsys
[i
][strlen(configsys
[i
])-1]!=';')
615 strcat(configsys
[i
], ";");
616 strcat(configsys
[i
], nv
);
617 strcat(configsys
[i
], ";");
618 #ifdef ENABLE_LOGGING
619 fprintf(logfile
, "<CFAddLine>,%s,%s\r\n", currentcf
, configsys
[i
]);
622 free(cmpbuf1
);free(cmpbuf2
);free(capbuf1
);free(capbuf2
);
628 /* Couldn't find the line so we'll add it */
629 configsys
[configfilecount
]=malloc(strlen(cmpbuf1
)+strlen(nv
)+3);
630 strcpy(configsys
[configfilecount
], cmpbuf1
);
631 strcat(configsys
[configfilecount
], nv
);
632 strcat(configsys
[configfilecount
], ";");
633 #ifdef ENABLE_LOGGING
634 fprintf(logfile
, "<CFAddLine>,%s,%s", currentcf
, configsys
[configfilecount
]);
643 * Removes a line from a config file.
645 void removeline(char *text
)
648 for(z
=0;z
<configfilecount
;z
++)
650 if(stricmp(configsys
[z
], text
) == 0)
654 #ifdef ENABLE_LOGGING
655 fprintf(logfile
, "<CFRemLine>,%s,%s\r\n", currentcf
, configsys
[z
]);
658 for(t
=z
;t
<(configfilecount
-1);t
++)
659 configsys
[t
] = configsys
[t
+1];
667 * The Window peocedure for the confirmation dialog.
670 MRESULT EXPENTRY
ConfirmDlgProc(HWND hWnd
, ULONG msg
, MPARAM mp1
, MPARAM mp2
)
677 WinSetWindowText(hWnd
, INSTALLER_TITLE
);
678 WinEnableWindow(WinWindowFromID(mainhwnd
, I_Cancel
), FALSE
);
679 WinSetDlgItemText(hWnd
, I_Confirm
, confirmstring
);
680 WinQueryWindowPos(mainhwnd
, &winpos
);
681 WinSetWindowPos(hWnd
, HWND_TOP
, winpos
.x
+30, winpos
.y
+30, 0, 0, SWP_MOVE
| SWP_ZORDER
);
684 WinEnableWindow(WinWindowFromID(mainhwnd
, I_Cancel
), TRUE
);
685 switch ( SHORT1FROMMP(mp1
) )
688 WinDismissDlg(hWnd
, 0);
691 WinDismissDlg(hWnd
, 1);
694 WinDismissDlg(hWnd
, 2);
698 installstate
=ABORTED
;
699 WinDismissDlg(hWnd
, 3);
704 return(WinDefDlgProc(hWnd
, msg
, mp1
, mp2
));
710 * Display a confirmation dialog with the options: YES NO ALL CANCEL
711 * Returns: 0 for YES, 1 for ALL, 2 for NO and 3 for CANCEL
713 int confirm(char *format
, ...) {
716 /* if no confirmation, return 1, meaning overwrite all */
717 if (stricmp(INSTALLER_CONFIRM_OVERWRITE
, "no") == 0)
720 va_start(args
, format
);
721 vsprintf(confirmstring
, format
, args
);
724 /* Do something here in wxwindows */
729 * A function to grab a file from an embedded archive and extract it to the TEMP directory.
731 void grabfile(char *filename
)
738 installer_unpack(filename
, 2);
743 * This thread runs along side the main thread allowing the user to cancel the process.
745 void install_thread(void *param
)
747 char tmpinstallpath
[1024];
748 int k
, j
, installcount
=0, installed
=0;
750 if(INSTALLER_PACKAGE_COUNT
== 2)
751 packagesselected
[1] = TRUE
;
753 installstate
= INSTALLING
;
755 #ifdef ENABLE_LOGGING
756 if((logfile
=fopen(instlog
, "ab"))==NULL
)
758 error("Log file \"%s\" open failed! Installation aborted!", instlog
);
762 fprintf(logfile
, "[%s]\r\n<Version>,%s\r\n<Start>\r\n", INSTALLER_APPLICATION
, INSTALLER_VERSION
);
765 /* Create nested subdirectories if necessary. */
766 strcpy(tmpinstallpath
, installdir
);
767 for(k
=3;k
<strlen(installdir
);k
++)
769 if(tmpinstallpath
[k
] == '\\')
771 tmpinstallpath
[k
] = 0;
772 #if defined(__EMX__) || defined(__CYGWIN__) || defined(UNIX)
773 if (!mkdir(tmpinstallpath
, 0))
775 if (!mkdir(tmpinstallpath
))
777 #ifdef ENABLE_LOGGING
778 fprintf(logfile
, "<NewDir>,%s\r\n", tmpinstallpath
);
782 tmpinstallpath
[k
] = '\\';
786 #if defined(__EMX__) || defined(__CYGWIN__) || defined(UNIX)
787 if (!mkdir(installdir
, 0))
789 if (!mkdir(installdir
))
791 #ifdef ENABLE_LOGGING
792 fprintf(logfile
, "<NewDir>,%s\r\n", installdir
);
797 /*if(strlen(installdir) > 0 && installdir[0] > 'a'-1 && installdir[0] < 'z'+1)
798 installdir[0]=installdir[0] - ('a'-'A');
799 if(strlen(installdir)>2 && installdir[1]==':' && installdir[2]=='\\')
800 DosSetDefaultDisk((int)(installdir[0]-'A'+1));*/
802 setdrivedir(installdir
);
804 /* Unpack files to destination directory */
805 for(j
=1;j
<INSTALLER_PACKAGE_COUNT
;j
++)
807 if(packagesselected
[j
] == TRUE
)
810 if(installcount
== 0)
812 mesg("No packages selected for installation!");
816 for(j
=1;j
<INSTALLER_PACKAGE_COUNT
;j
++)
818 if(packagesselected
[j
] == TRUE
)
821 char statustext
[512];
826 sprintf(statustext
,"Copying Files for %s %d/%d, Press \"Exit Installation\" to Abort.", INSTALLER_PACKAGES
[j
], installed
+1, installcount
);
827 WinSetDlgItemText(mainhwnd
, I_Info3
, statustext
);
829 /* filename parameter when null is all files */
830 installer_unpack(NULL
, 2);
838 error("Error unpacking files, Installer may be corrupt!");
843 error("User aborted installation!");
846 if(installstate
!= ABORTED
)
847 installstate
= COMPLETED
;
855 * Use the information from the .cfg file which is embedded in the EXE to update the
856 * CONFIG.SYS settings.
858 void configsys_update(void)
860 char *arg1
, *arg2
, *arg3
;
864 if(readconfigfile(csfile
))
867 /* Update Miscellaneous lines */
868 if(strlen(INSTALLER_SYSLINE
)>0)
870 char *tmpptr
= &temp
[0];
873 strcpy(temp
, INSTALLER_SYSLINE
);
884 tmpptr2
= replaceem(tmpptr
);
887 configsys
[configfilecount
] = tmpptr2
;
888 #ifdef ENABLE_LOGGING
889 fprintf(logfile
, "<CFAddLine>,%s,%s\r\n", currentcf
, tmpptr2
);
894 if(tmpptr
&& *tmpptr
)
898 tmpptr2
= replaceem(tmpptr
);
900 configsys
[configfilecount
] = tmpptr2
;
901 #ifdef ENABLE_LOGGING
902 fprintf(logfile
, "<CFAddLine>,%s,%s\r\n", currentcf
, tmpptr2
);
908 /* Update SET variables */
909 if(strlen(INSTALLER_SETS
)>0)
911 strcpy(temp
, INSTALLER_SETS
);
915 for(z
=0;z
<strlen(INSTALLER_SETS
);z
++)
931 updateset(arg1
, arg2
, (int)(arg3
[0]-'0'));
939 updateset(arg1
, arg2
, (int)arg3
-'0');
941 /* Update system variables */
942 if(strlen(INSTALLER_SYSVAR
)>0)
944 strcpy(temp
, INSTALLER_SYSVAR
);
948 for(z
=0;z
<strlen(INSTALLER_SYSVAR
);z
++)
961 updatesys(arg1
, arg2
);
969 updatesys(arg1
, arg2
);
972 writeconfigfile(csfile
, bufile
);
976 * Reads a line from a file and returns it in raw.
978 void getline(FILE *f
, char *raw
)
986 * Removes a character from a buffer by advancing the buffer to the left.
988 void removechar(char *buffer
, int thisone
, int len
)
992 for(x
=thisone
;x
<len
;x
++)
993 buffer
[x
] = buffer
[x
+1];
997 * Breaks up a line in raw into it's components.
999 void parseline(char *raw
, char comment
, char delimiter
, char quotes
, char *entry
, char *entrydata
, char *entrydata2
)
1002 int z
, len
, in_quotes
= 0, entrynum
=0, last
= 0;
1004 strcpy(entry
, empty_string
);
1005 strcpy(entrydata
, empty_string
);
1006 strcpy(entrydata2
, empty_string
);
1009 if(in
[strlen(in
)-1] == '\n')
1010 in
[strlen(in
)-1] = 0;
1012 if(in
[0] != comment
)
1017 if(!in_quotes
&& in
[z
] == delimiter
)
1020 /* Strip any other delimiters */
1022 while(in
[z
] == delimiter
&& z
< len
)
1028 strcpy(entrydata
, &in
[last
]);
1029 strcpy(entrydata2
, &in
[z
]);
1038 removechar(in
, z
, len
);
1050 strcpy(entrydata
, &in
[last
]);
1055 * Reads a line from the file and splits it up into it's components.
1057 int getparseline(FILE *f
, char comment
, char delimiter
, char quotes
, char *raw
, char *entry
, char *entrydata
, char *entrydata2
)
1060 parseline(raw
, comment
, delimiter
, quotes
, entry
, entrydata
, entrydata2
);
1065 void install_init(char *installername
)
1067 if((self
= fopen(installername
, "rb")) == NULL
)
1069 mesg("Could not open SFX archive for reading!");
1072 if(loadheader() == FALSE
)
1074 mesg("Could not load all required variables!");
1078 strcpy(installdir
, INSTALLER_PATH
);