+++ /dev/null
-/*
- * install.c (c) 1998,1999 Brian Smith
- * parts by Daniele Vistalli
- */
-
-#include <stdio.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <fcntl.h>
-#if defined(__OS2__) || defined(__EMX__) || defined(WINNT) || defined(WIN32)
-#include <process.h>
-#endif
-#include <sys/types.h>
-#include "install.h"
-#include "instsup.h"
-
-#if !defined(__EMX__) && !defined(__OS2__) && !defined(WIN32) && !defined(WINNT)
-#define stricmp strcasecmp
-#endif
-
-/* My Global variables ;) unusually many due to multiple dialogs */
-char tempPath[MAX_PATH];
-int installstate = NONE;
-int installstage = 0;
-int current_file=0, success=0;
-unsigned long int acepos=0, aceoffset=0;
-int pixels=0;
-char confirmstring[1024];
-/* I know I am being excessive but... better safe than sorry ;) */
-char *configsys[8196];
-int configfilecount=-1;
-int files = 0, files_deleted=0, packagesize=0, packagesselected[20];
-/* Global flags often set by the user */
-int driveselected, packagechosen, express = 1, driverstatus = -1, no_update = 0;
-int licensechecked = 0, custom = 0, checkforupdate = 1, downloadsite = 0;
-int usescitech = 1, usecurrent = 0, checking = 0, checkerror = 0, newerver = 0;
-char sddfilename[256] = "", sddversion[256] = "", sdddate[256] = "";
-char sddurl[4][256] = { "", "", "", "" };
-
-/* So these are accessible to REXX */
-int drivelist[26];
-FILE *self;
-
-/* These get loaded in loadheader */
-char *INSTALLER_APPLICATION;
-char *INSTALLER_VERSION;
-char *INSTALLER_TITLE;
-char *INSTALLER_PATH;
-char *INSTALLER_FOLDER;
-char *INSTALLER_PROGRAM;
-char *INSTALLER_SHADOW;
-char *INSTALLER_OBJECT;
-char *INSTALLER_SETS;
-char *INSTALLER_SYSVAR;
-char *INSTALLER_SYSLINE;
-char *INSTALLER_PACKAGES[20];
-char *INSTALLER_CONFIRM_WPS;
-char *INSTALLER_CONFIRM_CONFIGSYS;
-char *INSTALLER_CONFIRM_OVERWRITE;
-int INSTALLER_PACKAGE_COUNT;
-
-/* Will have to seperate this stuff to platform specifics... */
-
-/* Config.Sys -- Note the drive letter gets replaced with the boot drive letter
- It is just a place holder. (For the next 3 entries) */
-char csfile[] = "C:\\CONFIG.SYS";
-/* Backup Config.Sys filename */
-char bufile[] = "C:\\CONFIG.SDD";
-/* Installation Log Database -- Used for uninstallation and aborting */
-#if defined(__OS2__) || defined(__EMX__) || defined(WINNT) || defined(WIN32)
-char instlog[] = "C:\\DBINST.LOG";
-#else
-char instlog[] = "~/dbinst.log";
-#endif
-char installdir[400];
-
-char bootdrive[2] = "C";
-char winpath[400] = "C:\\OS2\\MDOS\\WINOS2";
-char winjpath[400] = "C:\\OS2\\MDOS\\WINJOS2";
-char wintpath[400] = "C:\\OS2\\MDOS\\WINTOS2";
-char winhpath[400] = "C:\\OS2\\MDOS\\WINHOS2";
-char browsedir[400] = "C:\\";
-char installdir2[400] = "";
-char empty_string[] = "";
-char currentcf[400] = "";
-
-#ifdef ENABLE_LOGGING
-FILE *logfile;
-#endif
-
-/* Function prototypes */
-int installer_unpack(char *filename, int operation);
-void resetglobals(void);
-
-typedef struct _replacements {
- char *replacestring, *replacevar;
-} Replacements;
-
-/* The variables in this array must be static buffers */
-Replacements InstRep[] = {
- { "%INSTALLPATH%", installdir },
- { "%BOOTDRIVE%", bootdrive },
- { "%ANYSTRING%", empty_string },
- { "%WINPATH%", winpath },
- { "%WINJPATH%", winjpath },
- { "%WINTPATH%", wintpath },
- { "%WINHPATH%", winhpath },
- { "%USERPATH%", installdir2 },
- { "%VERSION%", "1.0" }, /* This may be depricated */
- { "%WEB_VER%", sddversion },
- { "%WEB_DATE%", sdddate },
- { "%WEB_LOCATION1%", sddurl[0] },
- { "%WEB_LOCATION2%", sddurl[1] },
- { "%WEB_LOCATION3%", sddurl[2] },
- { "%WEB_LOCATION4%", sddurl[3] },
- { "%PRI%", "SVGA" }
-};
-int replacemax = 16;
-
-/* In str1, str2 gets replaced by str3 */
-char *replacestr(char *str1, char *str2, char *str3)
-{
- char bigbuffer[4096];
- int z, x=0, len1 = strlen(str1), len2 = strlen(str2), len3 = strlen(str3);
-
- for(z=0;z<len1;z++)
- {
- if(len2 > 0 && strncmp(&str1[z], str2, len2)==0)
- {
- int i;
- for(i=0;i<len3;i++)
- {
- bigbuffer[x] = str3[i];
- x++;
- }
- z=z+(len2-1);
- } else {
- bigbuffer[x] = str1[z];
- x++;
- }
- }
- bigbuffer[x] = 0;
- return (char *)strdup(bigbuffer);
-}
-
-/* This function parses a string and replaces all the text in the
- * Replacement array with the current dynamic text */
-char *replaceem(char *orig)
-{
- char *tmp1 = NULL, *tmp2 = (char *)strdup(orig);
- int z;
-
- for(z=0;z<replacemax;z++)
- {
- tmp1 = replacestr(tmp2, InstRep[z].replacestring, InstRep[z].replacevar);
- free(tmp2);
- tmp2 = tmp1;
- tmp1 = NULL;
- }
- return tmp2;
-}
-
-/*
- * Find the offset withing the executable of the ace data for use.
- */
-int aceseek_entry(int num)
-{
- long headerstart;
- char headerbuf[20], packageconfig[100];
- int z, start = 0, entry = 0, packageoffset=0;
- /* Decode DBSOFT-ACE - small memleak but
- * install should not be running for very long. :) */
- sprintf(headerbuf, "%s%d", decode("EEECFDEPEGFECNEBEDEF"), num);
- if((headerstart = findtext(headerbuf)) < 0)
- {
- mesg("Could not find ACE header in executable.");
- exit(2);
- }
-
- fseek(self, headerstart+strlen(headerbuf), SEEK_SET);
- fread(packageconfig, 1, 100, self);
-
- for(z=0;z<100;z++)
- {
- if(packageconfig[z] == '-' || packageconfig[z] == '*')
- {
- char cur = packageconfig[z];
- packageconfig[z] = 0;
- switch(entry)
- {
- case 0:
- current_file = 0;
- files = atoi(&packageconfig[start]);
- break;
- case 1:
- packagesize = atoi(&packageconfig[start]);
- break;
- }
- start = z+1;
- if(cur == '*')
- {
- packageoffset = z + 1;
- z = 100;
- }
- entry++;
- }
- }
- aceoffset=headerstart+strlen(headerbuf)+packageoffset;
- fseek(self, aceoffset, SEEK_SET);
- return TRUE;
-}
-
-/*
- * Reads the embedded .cfg data from the executable and place it in the global
- * INSTALL_* variables for use.
- */
-int loadheader(void)
-{
- char *buffer;
- long headerstart;
- int z, start=0, entry=0;
-
- buffer = malloc(8096*4);
-
- /* Decode DBSOFT-HEADER */
- if((headerstart = findtext(decode("EEECFDEPEGFECNEIEFEBEEEFFC"))) < 0)
- {
- mesg("Could not find Selfinstaller header in executable.");
- exit(2);
- }
- fseek(self, headerstart+13, SEEK_SET);
-
- fread(buffer, 1, 8096*4, self);
- for(z=0;z<8096*4;z++)
- {
- if(buffer[z] == '-' || buffer[z] == '*')
- {
- char cur = buffer[z];
- buffer[z] = 0;
- switch(entry)
- {
- case 0:
- INSTALLER_APPLICATION = (char *)strdup(&buffer[start]);
- break;
- case 1:
- INSTALLER_VERSION = (char *)strdup(&buffer[start]);
- break;
- case 2:
- INSTALLER_TITLE = (char *)strdup(&buffer[start]);
- break;
- case 3:
- INSTALLER_PATH = (char *)strdup(&buffer[start]);
- break;
- case 4:
- INSTALLER_FOLDER = (char *)strdup(&buffer[start]);
- break;
- case 5:
- INSTALLER_PROGRAM = (char *)strdup(&buffer[start]);
- break;
- case 6:
- INSTALLER_SHADOW = (char *)strdup(&buffer[start]);
- break;
- case 7:
- INSTALLER_OBJECT = (char *)strdup(&buffer[start]);
- break;
- case 8:
- INSTALLER_SETS = (char *)strdup(&buffer[start]);
- break;
- case 9:
- INSTALLER_SYSVAR = (char *)strdup(&buffer[start]);
- break;
- case 10:
- INSTALLER_SYSLINE = (char *)strdup(&buffer[start]);
- break;
- case 11:
- INSTALLER_CONFIRM_WPS = (char *)strdup(&buffer[start]);
- break;
- case 12:
- INSTALLER_CONFIRM_CONFIGSYS = (char *)strdup(&buffer[start]);
- break;
- case 13:
- INSTALLER_CONFIRM_OVERWRITE = (char *)strdup(&buffer[start]);
- break;
- case 14:
- INSTALLER_PACKAGE_COUNT = atoi(&buffer[start]);
- break;
- default:
- INSTALLER_PACKAGES[entry-15] = malloc((z-start)+1);
- strcpy(INSTALLER_PACKAGES[entry-15], &buffer[start]);
- break;
- }
- start = z+1;
- if(cur == '*')
- {
- free(buffer);
- return TRUE;
- }
-
- entry++;
- }
- }
- free(buffer);
- return FALSE;
-}
-
-/*
- * Functions to work on an ace file embedded within the archive in an
- * abstract manner.
- */
-int aceread(void *buf, size_t count)
-{
- unsigned long curpos = ftell(self);
- size_t readit;
-
- if(count > (packagesize-(curpos-aceoffset)))
- readit = (packagesize-(curpos-aceoffset));
- else
- readit = count;
-
- return fread(buf, 1, readit, self);
-}
-
-off_t acelseek(off_t offset, int whence)
-{
- switch(whence)
- {
- case SEEK_SET:
- fseek(self, aceoffset+offset, SEEK_SET);
- break;
- case SEEK_CUR:
- fseek(self, offset, SEEK_CUR);
- break;
- }
- acepos = ftell(self);
- return acepos-aceoffset;
-}
-
-int aceopen(const char *path, int flags)
-{
- fseek(self, aceoffset, SEEK_SET);
- return 1;
-}
-
-int aceclose(int fd)
-{
- fseek(self, aceoffset, SEEK_SET);
- return 0;
-}
-
-int acesize(void)
-{
- return packagesize;
-}
-
-int acetell(int fd)
-{
- return ftell(self)-aceoffset;
-}
-
-/*
- * Read the generated log file and remove any files installed.
- */
-void delete_files(void)
-{
- char tmpbuf[8196], *fileptr;
- FILE *tmplf;
- int linenum=0, found=-1, z;
-
- files_deleted=1;
-
- if((tmplf=fopen(instlog, "rb"))==NULL)
- return;
-
- while(!feof(tmplf))
- {
- fgets(tmpbuf, 8196, tmplf);
- linenum++;
- if(tmpbuf[0]=='[' && (char *)strstr(tmpbuf, INSTALLER_APPLICATION) != NULL && !feof(tmplf))
- {
- fgets(tmpbuf, 8196, tmplf);
- linenum++;
- if((char *)strstr(tmpbuf, "<Version>") != NULL && (char *)strstr(tmpbuf, INSTALLER_VERSION) != NULL)
- found=linenum;
- }
- }
- if(found != -1)
- {
- rewind(tmplf);
- for (z=0;z<found;z++)
- fgets(tmpbuf, 8196, tmplf);
- while(!feof(tmplf))
- {
- fgets(tmpbuf, 8196, tmplf);
- if((char *)strstr(tmpbuf, "<FileInst>") != NULL)
- {
- fileptr = (char *)strchr(tmpbuf, ',')+1;
- /* Remove trailing CRLFs */
- if(fileptr[strlen(fileptr)-1] == '\r' || fileptr[strlen(fileptr)-1] == '\n')
- fileptr[strlen(fileptr)-1]=0;
- if(fileptr[strlen(fileptr)-1] == '\r' || fileptr[strlen(fileptr)-1] == '\n')
- fileptr[strlen(fileptr)-1]=0;
- remove(fileptr);
- current_file--;
-#if 0
- sendmessage(0, 1);
-#endif
- }
- if((char *)strstr(tmpbuf, "<End>") != NULL)
- {
- fclose(tmplf);
- return;
- }
- }
- }
- fclose(tmplf);
- return;
-}
-
-/*
- * Reads a config file into memory for editing with updatesys, updateset, etc.
- */
-int readconfigfile(char *filename)
-{
- char tmpbuf[8196];
- FILE *tmpcs;
-
- /* Reset this value when restarting */
- configfilecount = -1;
-
- if((tmpcs=fopen(filename, "rb"))==NULL)
- {
- strcpy(currentcf, empty_string);
- return 1;
- }
- else
- strcpy(currentcf, filename);
-
- while(!feof(tmpcs))
- {
- configfilecount++;
- fgets(tmpbuf, 8196, tmpcs);
- configsys[configfilecount] = malloc(strlen(tmpbuf)+1);
- strcpy(configsys[configfilecount], tmpbuf);
- stripcrlf(configsys[configfilecount]);
- }
-
- fclose(tmpcs);
- return 0;
-}
-
-/*
- * Write the updated config file to disk and backup the original.
- */
-int writeconfigfile(char *filename, char *backup)
-{
- FILE *tmpcs;
- int i;
-
- if(backup)
- {
- remove(backup);
- rename(filename, backup);
- }
- else
- remove(filename);
-
- if((tmpcs=fopen(filename, "wb"))==NULL)
- return 1;
-
- for(i=0;i<configfilecount;i++)
- {
- if(configsys[i])
- {
- fwrite(configsys[i], 1, strlen(configsys[i]), tmpcs);
- /* Add the CRLF that got stripped in the reading stage. */
- fwrite("\r\n", 1, 2, tmpcs);
- free(configsys[i]);
- }
- }
-
- fclose(tmpcs);
- return 0;
-}
-/*
- * Adds or replaces a SET variable based on the flags (CONFIG.SYS)
- */
-void updateset(char *setname, char *newvalue, int flag)
-{
- char *cmpbuf1, *cmpbuf2, *tmpptr, *tmpptr2, *nv;
- int i, z, t;
-
- nv=replaceem(newvalue);
-
- cmpbuf1=malloc(strlen(setname)+2);
- strcpy(cmpbuf1, setname);
- strcat(cmpbuf1, "=");
- for(i=0;i<configfilecount;i++)
- {
- if(strlen(cmpbuf1) <= strlen(configsys[i]))
- {
- tmpptr=(char *)strdup(configsys[i]);
-#if defined(__EMX__) || defined(__OS2__) || defined(WIN32) || defined(WINNT)
- strupr(tmpptr);
-#endif
- if((tmpptr2=(char*)strstr(tmpptr, "SET "))!=NULL)
- {
- tmpptr2 += 4;
- cmpbuf2=malloc(strlen(tmpptr2)+1);
- /* Remove any spaces from the string */
- z=0;
- for (t=0;t<strlen(tmpptr2) && z < strlen(cmpbuf1);t++)
- {
- if(tmpptr2[t] != ' ')
- {
- cmpbuf2[z]=tmpptr2[t];
- z++;
- }
- }
- cmpbuf2[z]=0;
- if(stricmp(cmpbuf1, cmpbuf2) == 0)
- {
- /* Ok we found the entry, and if UPDATE_ALWAYS change it to the
- new entry, otherwise exit */
- if(flag == UPDATE_ALWAYS)
- {
-#ifdef ENABLE_LOGGING
- fprintf(logfile, "<CFRemLine>,%s,%s\r\n", currentcf, configsys[i]);
-#endif
- free(configsys[i]);
- configsys[i] = malloc(strlen(setname)+strlen(nv)+6);
- strcpy(configsys[i], "SET ");
- strcat(configsys[i], setname);
- strcat(configsys[i], "=");
- strcat(configsys[i], nv);
-#ifdef ENABLE_LOGGING
- fprintf(logfile, "<CFAddLine>,%s,%s\r\n", currentcf, configsys[i]);
-#endif
- free(cmpbuf1);free(cmpbuf2);free(tmpptr);
- }
- return;
- }
- free(cmpbuf2);
- }
- free(tmpptr);
- }
- }
- /* Couldn't find the line so we'll add it */
- configsys[configfilecount]=malloc(strlen(cmpbuf1)+strlen(nv)+6);
- strcpy(configsys[configfilecount], "SET ");
- strcat(configsys[configfilecount], setname);
- strcat(configsys[configfilecount], "=");
- strcat(configsys[configfilecount], nv);
-#ifdef ENABLE_LOGGING
- fprintf(logfile, "<CFAddLine>,%s,%s\r\n", currentcf, configsys[configfilecount]);
-#endif
- configfilecount++;
- free(cmpbuf1);
-}
-
-/*
- * Adds an entry to a system variable (CONFIG.SYS)
- */
-void updatesys(char *sysname, char *newvalue)
-{
- char *cmpbuf1, *cmpbuf2, *tmpptr, *tmpptr2, *capbuf1, *capbuf2, *nv, *brian;
- int i, z, t;
-
- nv=replaceem(newvalue);
-
- cmpbuf1=malloc(strlen(sysname)+2);
- strcpy(cmpbuf1, sysname);
- strcat(cmpbuf1, "=");
- for(i=0;i<configfilecount;i++)
- {
- if(strlen(cmpbuf1) <= strlen(configsys[i]))
- {
- cmpbuf2=malloc(strlen(configsys[i])+1);
- /* Remove any spaces from the string */
- z=0;
- for (t=0;t<strlen(configsys[i]) && z < strlen(cmpbuf1);t++)
- {
- if(configsys[i][t] != ' ')
- {
- cmpbuf2[z]=configsys[i][t];
- z++;
- }
- }
- cmpbuf2[z]=0;
- if(stricmp(cmpbuf1, cmpbuf2) == 0)
- {
- /* Do a case insensitive comparison but preserve the case */
- tmpptr = &configsys[i][t];
- capbuf1=malloc(strlen(tmpptr)+1);
- capbuf2=malloc(strlen(nv)+1);
- strcpy(capbuf1, tmpptr);
- strcpy(capbuf2, nv);
-#if defined(__EMX__) || defined(__OS2__) || defined(WINNT) || defined(WIN32)
- strupr(capbuf1);
- strupr(capbuf2);
-#endif
- /* Ok, we found the line, and it doesn't have an entry so we'll add it */
- if((tmpptr2=(char *)strstr(capbuf1, capbuf2)) == NULL)
- {
-#ifdef ENABLE_LOGGING
- fprintf(logfile, "<CFRemLine>,%s,%s\r\n", currentcf, configsys[i]);
-#endif
- brian = configsys[i];
- configsys[i] = malloc(strlen(configsys[i])+strlen(nv)+4);
- strcpy(configsys[i], brian);
- free(brian);
- /* Remove any trailing CRLFs */
- if(configsys[i][strlen(configsys[i])-1]!=';')
- strcat(configsys[i], ";");
- strcat(configsys[i], nv);
- strcat(configsys[i], ";");
-#ifdef ENABLE_LOGGING
- fprintf(logfile, "<CFAddLine>,%s,%s\r\n", currentcf, configsys[i]);
-#endif
- }
- free(cmpbuf1);free(cmpbuf2);free(capbuf1);free(capbuf2);
- return;
- }
- free(cmpbuf2);
- }
- }
- /* Couldn't find the line so we'll add it */
- configsys[configfilecount]=malloc(strlen(cmpbuf1)+strlen(nv)+3);
- strcpy(configsys[configfilecount], cmpbuf1);
- strcat(configsys[configfilecount], nv);
- strcat(configsys[configfilecount], ";");
-#ifdef ENABLE_LOGGING
- fprintf(logfile, "<CFAddLine>,%s,%s", currentcf, configsys[configfilecount]);
-#endif
- configfilecount++;
- free(cmpbuf1);
- if(nv)
- free(nv);
-}
-
-/*
- * Removes a line from a config file.
- */
-void removeline(char *text)
-{
- int z;
- for(z=0;z<configfilecount;z++)
- {
- if(stricmp(configsys[z], text) == 0)
- {
- int t;
-
-#ifdef ENABLE_LOGGING
- fprintf(logfile, "<CFRemLine>,%s,%s\r\n", currentcf, configsys[z]);
-#endif
- free(configsys[z]);
- for(t=z;t<(configfilecount-1);t++)
- configsys[t] = configsys[t+1];
- configfilecount--;
- }
- }
-}
-
-
-/*
- * The Window peocedure for the confirmation dialog.
- */
-#if 0
-MRESULT EXPENTRY ConfirmDlgProc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
-{
- SWP winpos;
-
- switch (msg)
- {
- case WM_INITDLG:
- WinSetWindowText(hWnd, INSTALLER_TITLE);
- WinEnableWindow(WinWindowFromID(mainhwnd, I_Cancel), FALSE);
- WinSetDlgItemText(hWnd, I_Confirm, confirmstring);
- WinQueryWindowPos(mainhwnd, &winpos);
- WinSetWindowPos(hWnd, HWND_TOP, winpos.x+30, winpos.y+30, 0, 0, SWP_MOVE | SWP_ZORDER);
- break;
- case WM_COMMAND:
- WinEnableWindow(WinWindowFromID(mainhwnd, I_Cancel), TRUE);
- switch ( SHORT1FROMMP(mp1) )
- {
- case I_Ja:
- WinDismissDlg(hWnd, 0);
- break;
- case I_Alle:
- WinDismissDlg(hWnd, 1);
- break;
- case I_Nein:
- WinDismissDlg(hWnd, 2);
- break;
- case I_Halt:
- success=2;
- installstate=ABORTED;
- WinDismissDlg(hWnd, 3);
- break;
- }
- break;
- default :
- return(WinDefDlgProc(hWnd, msg, mp1, mp2));
- }
- return(0L);
-}
-#endif
-/*
- * Display a confirmation dialog with the options: YES NO ALL CANCEL
- * Returns: 0 for YES, 1 for ALL, 2 for NO and 3 for CANCEL
- */
-int confirm(char *format, ...) {
- va_list args;
-
- /* if no confirmation, return 1, meaning overwrite all */
- if (stricmp(INSTALLER_CONFIRM_OVERWRITE, "no") == 0)
- return 1;
-
- va_start(args, format);
- vsprintf(confirmstring, format, args);
- va_end(args);
-
- /* Do something here in wxwindows */
- return 1;
-}
-
-/*
- * A function to grab a file from an embedded archive and extract it to the TEMP directory.
- */
-void grabfile(char *filename)
-{
- no_update = 1;
- settempdir();
- remove(filename);
- aceseek_entry(0);
- resetglobals();
- installer_unpack(filename, 2);
- no_update = 0;
-}
-
-/*
- * This thread runs along side the main thread allowing the user to cancel the process.
- */
-void install_thread(void *param)
-{
- char tmpinstallpath[1024];
- int k, j, installcount=0, installed=0;
-
- if(INSTALLER_PACKAGE_COUNT == 2)
- packagesselected[1] = TRUE;
-
- installstate = INSTALLING;
-
-#ifdef ENABLE_LOGGING
- if((logfile=fopen(instlog, "ab"))==NULL)
- {
- error("Log file \"%s\" open failed! Installation aborted!", instlog);
- exit(1);
- }
-
- fprintf(logfile, "[%s]\r\n<Version>,%s\r\n<Start>\r\n", INSTALLER_APPLICATION, INSTALLER_VERSION);
-#endif
-
- /* Create nested subdirectories if necessary. */
- strcpy(tmpinstallpath, installdir);
- for(k=3;k<strlen(installdir);k++)
- {
- if(tmpinstallpath[k] == '\\')
- {
- tmpinstallpath[k] = 0;
-#if defined(__EMX__) || defined(__CYGWIN__) || defined(UNIX)
- if (!mkdir(tmpinstallpath, 0))
-#else
- if (!mkdir(tmpinstallpath))
-#endif
-#ifdef ENABLE_LOGGING
- fprintf(logfile, "<NewDir>,%s\r\n", tmpinstallpath);
-#else
- ;
-#endif
- tmpinstallpath[k] = '\\';
- }
- }
-
-#if defined(__EMX__) || defined(__CYGWIN__) || defined(UNIX)
- if (!mkdir(installdir, 0))
-#else
- if (!mkdir(installdir))
-#endif
-#ifdef ENABLE_LOGGING
- fprintf(logfile, "<NewDir>,%s\r\n", installdir);
-#else
- ;
-#endif
-
- /*if(strlen(installdir) > 0 && installdir[0] > 'a'-1 && installdir[0] < 'z'+1)
- installdir[0]=installdir[0] - ('a'-'A');
- if(strlen(installdir)>2 && installdir[1]==':' && installdir[2]=='\\')
- DosSetDefaultDisk((int)(installdir[0]-'A'+1));*/
-
- setdrivedir(installdir);
-
- /* Unpack files to destination directory */
- for(j=1;j<INSTALLER_PACKAGE_COUNT;j++)
- {
- if(packagesselected[j] == TRUE)
- installcount++;
- }
- if(installcount == 0)
- {
- mesg("No packages selected for installation!");
- }
- else
- {
- for(j=1;j<INSTALLER_PACKAGE_COUNT;j++)
- {
- if(packagesselected[j] == TRUE)
- {
-#if 0
- char statustext[512];
-#endif
- aceseek_entry(j);
- resetglobals();
-#if 0
- sprintf(statustext,"Copying Files for %s %d/%d, Press \"Exit Installation\" to Abort.", INSTALLER_PACKAGES[j], installed+1, installcount);
- WinSetDlgItemText(mainhwnd, I_Info3, statustext);
-#endif
- /* filename parameter when null is all files */
- installer_unpack(NULL, 2);
- installed++;
- }
- }
- }
-
- if(success==1)
- {
- error("Error unpacking files, Installer may be corrupt!");
- }
-
- if(success==2)
- {
- error("User aborted installation!");
- }
-
- if(installstate != ABORTED)
- installstate = COMPLETED;
-
-#if 0
- sendmessage(0, 2);
-#endif
-}
-
-/*
- * Use the information from the .cfg file which is embedded in the EXE to update the
- * CONFIG.SYS settings.
- */
-void configsys_update(void)
-{
- char *arg1, *arg2, *arg3;
- char temp[5000];
- int z, argn=0;
-
- if(readconfigfile(csfile))
- return;
-
- /* Update Miscellaneous lines */
- if(strlen(INSTALLER_SYSLINE)>0)
- {
- char *tmpptr = &temp[0];
- int len;
-
- strcpy(temp, INSTALLER_SYSLINE);
- temp[4999] = 0;
- len = strlen(temp);
-
- for(z=0;z<len;z++)
- {
- if(temp[z]==',')
- {
- char *tmpptr2;
-
- temp[z] = 0;
- tmpptr2 = replaceem(tmpptr);
- tmpptr = &temp[z+1];
- removeline(tmpptr2);
- configsys[configfilecount] = tmpptr2;
-#ifdef ENABLE_LOGGING
- fprintf(logfile, "<CFAddLine>,%s,%s\r\n", currentcf, tmpptr2);
-#endif
- configfilecount++;
- }
- }
- if(tmpptr && *tmpptr)
- {
- char *tmpptr2;
-
- tmpptr2 = replaceem(tmpptr);
- removeline(tmpptr2);
- configsys[configfilecount] = tmpptr2;
-#ifdef ENABLE_LOGGING
- fprintf(logfile, "<CFAddLine>,%s,%s\r\n", currentcf, tmpptr2);
-#endif
- configfilecount++;
- }
-
- }
- /* Update SET variables */
- if(strlen(INSTALLER_SETS)>0)
- {
- strcpy(temp, INSTALLER_SETS);
- argn=0;
- arg1=&temp[0];
- arg2=arg3=NULL;
- for(z=0;z<strlen(INSTALLER_SETS);z++)
- {
- if(temp[z]==',')
- {
- argn++;
- temp[z]=0;
- switch(argn)
- {
- case 1:
- arg2=&temp[z+1];
- break;
- case 2:
- arg3=&temp[z+1];
- break;
- case 3:
- argn=0;
- updateset(arg1, arg2, (int)(arg3[0]-'0'));
- arg1=&temp[z+1];
- arg2=arg3=NULL;
- break;
- }
- }
- }
- if(arg3)
- updateset(arg1, arg2, (int)arg3-'0');
- }
- /* Update system variables */
- if(strlen(INSTALLER_SYSVAR)>0)
- {
- strcpy(temp, INSTALLER_SYSVAR);
- argn=0;
- arg1=&temp[0];
- arg2=NULL;
- for(z=0;z<strlen(INSTALLER_SYSVAR);z++)
- {
- if(temp[z]==',')
- {
- argn++;
- temp[z]=0;
- switch(argn)
- {
- case 1:
- arg2=&temp[z+1];
- break;
- case 2:
- argn=0;
- updatesys(arg1, arg2);
- arg1=&temp[z+1];
- arg2=NULL;
- break;
- }
- }
- }
- if(arg2)
- updatesys(arg1, arg2);
- }
-
- writeconfigfile(csfile, bufile);
-}
-
-/*
- * Reads a line from a file and returns it in raw.
- */
-void getline(FILE *f, char *raw)
-{
- memset(raw, 0, 256);
- fgets(raw, 255, f);
- stripcrlf(raw);
-}
-
-/*
- * Removes a character from a buffer by advancing the buffer to the left.
- */
-void removechar(char *buffer, int thisone, int len)
-{
- int x;
-
- for(x=thisone;x<len;x++)
- buffer[x] = buffer[x+1];
-}
-
-/*
- * Breaks up a line in raw into it's components.
- */
-void parseline(char *raw, char comment, char delimiter, char quotes, char *entry, char *entrydata, char *entrydata2)
-{
- char in[256];
- int z, len, in_quotes = 0, entrynum=0, last = 0;
-
- strcpy(entry, empty_string);
- strcpy(entrydata, empty_string);
- strcpy(entrydata2, empty_string);
- strcpy(in, raw);
-
- if(in[strlen(in)-1] == '\n')
- in[strlen(in)-1] = 0;
-
- if(in[0] != comment)
- {
- len=strlen(in);
- for(z=0;z<len;z++)
- {
- if(!in_quotes && in[z] == delimiter)
- {
- in[z] = 0;
- /* Strip any other delimiters */
- z++;
- while(in[z] == delimiter && z < len)
- z++;
- if(!entrynum)
- strcpy(entry, in);
- else
- {
- strcpy(entrydata, &in[last]);
- strcpy(entrydata2, &in[z]);
- }
- last = z;
- if(entrynum)
- return;
- entrynum++;
- }
- if(in[z] == quotes)
- {
- removechar(in, z, len);
- z--;
- len--;
- if(in_quotes)
- in_quotes = 0;
- else
- in_quotes = 1;
- }
- }
- if(!entrynum)
- strcpy(entry, in);
- else
- strcpy(entrydata, &in[last]);
- }
-}
-
-/*
- * Reads a line from the file and splits it up into it's components.
- */
-int getparseline(FILE *f, char comment, char delimiter, char quotes, char *raw, char *entry, char *entrydata, char *entrydata2)
-{
- getline(f, raw);
- parseline(raw, comment, delimiter, quotes, entry, entrydata, entrydata2);
- return strlen(raw);
-}
-
-
-void install_init(char *installername)
-{
- if((self = fopen(installername, "rb")) == NULL)
- {
- mesg("Could not open SFX archive for reading!");
- exit(1);
- }
- if(loadheader() == FALSE)
- {
- mesg("Could not load all required variables!");
- exit(3);
- }
-
- strcpy(installdir, INSTALLER_PATH);
-}
-
-
+++ /dev/null
-/*
- * instsup.c (c) 1999,2000 Brian Smith
- */
-
-#include "wx/wxprec.h"
-
-#ifndef WX_PRECOMP
-#include "wx/wx.h"
-#endif
-
-#include <stdio.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <fcntl.h>
-#if defined(__OS2__) || defined(__EMX__) || defined(WIN32) || defined(WINNT)
-#include <process.h>
-#endif
-#include <sys/types.h>
-#ifdef WIN32
-#include <shlobj.h>
-#endif
-#include "install.h"
-#include "instsup.h"
-
-extern char *INSTALLER_TITLE;
-extern char *INSTALLER_PROGRAM;
-extern char *INSTALLER_FOLDER;
-extern char *INSTALLER_SHADOW;
-extern char *INSTALLER_OBJECT;
-extern char tempPath[], installdir[], csfile[], bufile[], bootdrive[], instlog[], installdir2[];
-extern int installstate, success;
-
-extern FILE *self;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-char *replaceem(char *orig);
-
-int sendmessage(int destination, int messid)
-{
-#if 0
- /* Update percentage bar */
- if(messid == 1)
- {
- wxMutexGuiEnter();
-
- updatepercent();
-
- wxMutexGuiLeave();
- }
- if(messid == 2)
- {
- extern wxCondition *InstCond;
-
- InstCond->Broadcast();
- }
-
-#endif
- return 0;
-}
-
-void DoGUI(void)
-{
- updatepercent();
- wxYield();
-}
-/* This should return the current color depth */
-unsigned long color_depth(void)
-{
-#if __OS2__
- HDC hdc = WinOpenWindowDC(HWND_DESKTOP);
- LONG colors;
-
- DevQueryCaps(hdc, CAPS_COLORS, 1, &colors);
- DevCloseDC(hdc);
- return colors;
-#endif
- return 0;
-}
-
-/*
- * Call the reboot vector.
- */
-void sysreboot(void)
-{
-#if __OS2__
-#define SYSFUNC 0xD5
-#define REBOOT 0xAB
-#define REBOOTDEV "\\DEV\\DOS$"
-
- APIRET rc;
- HFILE hREBOOT;
- ULONG ulAction;
-
- rc = DosOpen(REBOOTDEV,
- &hREBOOT,
- &ulAction,
- 0L,
- FILE_NORMAL,
- FILE_OPEN,
- OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
- 0L);
- if (rc == 0)
- {
- DosDevIOCtl(hREBOOT,
- SYSFUNC,
- REBOOT,
- NULL,
- 0L,
- NULL,
- NULL,
- 0L,
- NULL);
- DosClose(hREBOOT);
- }
-#endif
-}
-
-/*
- * Display an informational dialog box to the user with the given text.
- */
-int mesg(char *format, ...) {
- va_list args;
- char outbuf[4096];
-
- va_start(args, format);
- vsprintf(outbuf, format, args);
- va_end(args);
-
- wxMessageBox(outbuf, INSTALLER_TITLE,
- wxOK | wxICON_EXCLAMATION, NULL);
-
- return strlen(outbuf);
-}
-
-int checktext(char *text, char *buffer, int buflen)
-{
- int z, len = strlen(text);
-
- for(z=0;z<(buflen-len);z++)
- {
- if(memcmp(text, &buffer[z], len) == 0)
- return z;
- }
- return -1;
-
-}
-
-/*
- * Returns the offset withing the executable to the specified text.
- */
-long findtext(char *text)
-{
- char buffer[512];
- int offset;
- unsigned long curpos = 0;
-
- fseek(self, 0, SEEK_SET);
- fread(buffer, 1, 512, self);
- if((offset = checktext(text, buffer, 512)) > -1)
- return offset;
- while(!feof(self))
- {
- memcpy(buffer, &buffer[256], 256);
- fread(&buffer[256], 1, 256, self);
- curpos += 256;
- if((offset = checktext(text, buffer, 512)) > -1)
- return offset+curpos;
-
- }
- return -1;
-}
-
-/* We encode archive search text so we don't get confused
- * by the string table - I was using LXLite to take care
- * of this problem on OS/2 but in portable code this may
- * not be an option. */
-char *decode(char *input)
-{
- char *result;
- int i = 0;
-
- result = (char *)malloc(strlen(input) / 2 + 1);
-
- while (input[0] && input[1])
- {
- result[i] = ((input[0] - 0x41) << 4) | (input[1] - 0x41);
- input += 2;
- i++;
- }
- result[i] = '\0';
-
- return result;
-}
-
-/*
- * Removes any carriage returns or line feeds from the buffer.
- */
-void stripcrlf(char *buffer)
-{
- int z, len = strlen(buffer);
-
- for(z=0;z<len;z++)
- {
- if(buffer[z] == '\r' || buffer[z] == '\n')
- {
- buffer[z] = 0;
- return;
- }
- }
-}
-
-/*
- * Returns the space free on a given drive... where 0 is A: in MB
- */
-unsigned long drivefree(int drive)
-{
-#if __OS2__
- ULONG aulFSInfoBuf[40] = {0};
- APIRET rc = NO_ERROR;
- double bytesFree;
-
- DosError(FERR_DISABLEHARDERR);
- rc = DosQueryFSInfo(drive,
- FSIL_ALLOC,
- (PVOID)aulFSInfoBuf,
- sizeof(aulFSInfoBuf));
-
- DosError(FERR_ENABLEHARDERR);
- if (rc != NO_ERROR)
- return 0;
-
- bytesFree = (double)aulFSInfoBuf[3] * (double)aulFSInfoBuf[1] * (USHORT)aulFSInfoBuf[4];
- return (unsigned long)(bytesFree / (1024.0 * 1024.0));
-#endif
- return 0;
-}
-
-
-/*
- * Display a fatal error message and set the abort flag in case we are in a secondary thread.
- */
-void error(char *format, ...) {
- va_list args;
- char errstring[1024];
-
- va_start(args, format);
- vsprintf(errstring, format, args);
- va_end(args);
-
- if(installstate != ABORTED)
- {
- success=1;
- installstate=ABORTED;
- }
- wxMessageBox(errstring, INSTALLER_TITLE,
- wxOK | wxICON_EXCLAMATION, NULL);
-}
-
-void setdrivedir(char *drivedir)
-{
- wxSetWorkingDirectory(drivedir);
-}
-
-/*
- * Make the TEMP directory the current directory, or the root directory of the boot drive.
- */
-void settempdir(void)
-{
-#if defined(__EMX__) || defined(__OS2__) || defined(WIN32) || defined(WINNT)
- /* Windows or OS/2 */
- char *envdir = getenv("TMP");
- int len;
-
- if (!envdir)
- envdir = getenv("TEMP");
- if (!envdir)
- envdir = replaceem("%BOOTDRIVE%:\\");
- strcpy(tempPath,envdir);
- len = strlen(tempPath);
- if (len > 3 && tempPath[len-1] == '\\')
- tempPath[len-1] = 0;
- strupr(tempPath);
- setdrivedir(tempPath);
-#else
- /* Unix */
- setdrivedir("/tmp");
-#endif
-}
-
-void getbootdrive(void)
-{
- /* On windows I don't think you can boot from anything
- except C: drive. So I am not going to do anything here. */
-}
-
-void PM_backslash(char *s)
-{
- unsigned int pos = strlen(s);
- if (s[pos-1] != '\\') {
- s[pos] = '\\';
- s[pos+1] = '\0';
- }
-}
-
-/*
- * Makes a folder on the desktop.
- */
-void MakeFolder(char Title[], char Icon[], char dest[], char id[], char setup[])
-{
-#ifdef __OS2__
- char szArg[200];
-
- memset(szArg,0,sizeof(szArg));
-
- if ((Icon != NULL) && (strlen(Icon) != 0))
- {
- strcat(szArg,"ICONFILE=");
- strcat(szArg,Icon);
- }
-
- if ((id != NULL) && (strlen(id) != 0))
- {
- strcat(szArg,";OBJECTID=");
- strcat(szArg,id);
- }
-
- if ((setup != NULL) && (strlen(setup) != 0))
- {
- strcat(szArg,";");
- strcat(szArg,setup);
- }
-
- WinCreateObject("WPFolder",Title,szArg,dest,CO_REPLACEIFEXISTS);
-#elif defined(WIN32)
- char startpath[MAX_PATH];
- LPITEMIDLIST pidl;
-
- if(!SHGetSpecialFolderLocation(NULL, CSIDL_PROGRAMS, &pidl))
- {
- SHGetPathFromIDList(pidl, startpath);
-
- if(startpath[strlen(startpath)-1] != '\\')
- strcat(startpath, "\\");
- strcat(startpath, Title);
- CreateDirectory(startpath, NULL);
- }
-#else
- /* Unix? */
-#endif
-}
-
-#ifdef WIN32
-HRESULT CreateLink(LPCSTR lpszPathObj,
- LPSTR lpszPathLink, LPSTR lpszDesc)
-{
- HRESULT hres;
- IShellLink* psl;
-
- // Get a pointer to the IShellLink interface.
- hres = CoCreateInstance(CLSID_ShellLink, NULL,
- CLSCTX_INPROC_SERVER, IID_IShellLink, (void **)&psl);
- if (SUCCEEDED(hres)) {
- IPersistFile* ppf;
-
- // Set the path to the shortcut target, and add the
- // description.
- psl->SetPath(lpszPathObj);
-
- psl->SetDescription(lpszDesc);
-
- // Query IShellLink for the IPersistFile interface for saving the
- // shortcut in persistent storage.
- hres = psl->QueryInterface(IID_IPersistFile,
- (void **)&ppf);
-
- if (SUCCEEDED(hres)) {
- WCHAR wsz[MAX_PATH];
-
- // Ensure that the string is ANSI.
- MultiByteToWideChar(CP_ACP, 0, lpszPathLink, -1,
- wsz, MAX_PATH);
-
-
- // Save the link by calling IPersistFile::Save.
- hres = ppf->Save(wsz, TRUE);
- ppf->Release();
- }
- psl->Release();
- }
- return hres;
-}
-#endif
-
-/*
- * Makes a Program object on the desktop.
- */
-void MakeProgram(char Title[], char Program[], char Icon[], char dest[], char id[], char setup[])
-{
-#ifdef __OS2__
- char szArg[200];
-
- memset(szArg,0,sizeof(szArg));
-
- strcat(szArg,"EXENAME=");
- strcat(szArg,Program);
-
- if ((Icon != NULL) && (strlen(Icon) != 0))
- {
- strcat(szArg,";ICONFILE=");
- strcat(szArg,Icon);
- }
-
- if ((id != NULL) && (strlen(id) != 0))
- {
- strcat(szArg,";OBJECTID=");
- strcat(szArg,id);
- }
-
- if ((setup != NULL) && (strlen(setup) != 0))
- {
- strcat(szArg,";");
- strcat(szArg,setup);
- }
-
- WinCreateObject("WPProgram",Title,szArg,dest,CO_REPLACEIFEXISTS);
-#elif defined(WIN32)
- char startpath[MAX_PATH];
- LPITEMIDLIST pidl;
-
- if(!SHGetSpecialFolderLocation(NULL, CSIDL_PROGRAMS, &pidl))
- {
- SHGetPathFromIDList(pidl, startpath);
-
- if(startpath[strlen(startpath)-1] != '\\')
- strcat(startpath, "\\");
- strcat(startpath, dest);
- strcat(startpath, "\\");
- strcat(startpath, Title);
- strcat(startpath, ".lnk");
-
- CoInitialize(NULL);
- CreateLink(Program, startpath, Title);
- CoUninitialize();
- }
-
-
-#else
- /* Unix? */
-#endif
-}
-/*
- * Makes a user defined object on the desktop.
- */
-void MakeObject(char Title[], char oclass[], char dest[], char id[], char setup[])
-{
-#ifdef __OS2__
- char szArg[200];
-
- memset(szArg,0,sizeof(szArg));
-
- if ((oclass == NULL) || (strlen(oclass) == 0))
- return;
-
- if ((id != NULL) && (strlen(id) != 0))
- {
- strcat(szArg,"OBJECTID=");
- strcat(szArg,id);
- }
-
- if ((setup != NULL) && (strlen(setup) != 0))
- {
- if ((id != NULL) && (strlen(id) != 0))
- strcat(szArg,";");
- strcat(szArg,setup);
- }
-
- WinCreateObject(oclass,Title,szArg,dest,CO_REPLACEIFEXISTS);
-#elif defined(WIN32)
- /* Not sure if there is an equivilent on Windows */
-#else
- /* Unix? */
-#endif
-}
-/*
- * Makes a shadow on the desktop.
- */
-void MakeShadow(char Title[], char reference[], char dest[], char id[])
-{
-#ifdef __OS2__
- char szArg[400];
-
- memset(szArg,0,sizeof(szArg));
-
- strcpy(szArg,"SHADOWID=");
- strcat(szArg,reference);
- if ((id != NULL) && (strlen(id) != 0))
- {
- strcat(szArg,";OBJECTID=");
- strcat(szArg,id);
- }
- strcat(szArg,";");
- WinCreateObject("WPShadow",Title,szArg,dest,CO_REPLACEIFEXISTS);
-#elif defined(WIN32)
- /* Nothing like this on Windows9x anyway */
-#else
- /* Unix? */
-#endif
-}
-
-/* This creates program objects on the desktop, it was originally designed
- * for the OS/2 Workplace Shell so it may be somewhat different in use on
- * other platforms.
- */
-void create_wps_objects(void)
-{
- char *arg1, *arg2, *arg3, *arg4, *arg5, *arg6;
- char temp[5000];
- char zerotext[2] = "";
- int z, argn, len;
-
- /* No distinction for the moment... this may change.. */
- strcpy(installdir2, installdir);
-
- /* Create Folder Objects */
- if(strlen(INSTALLER_FOLDER)>0)
- {
- strcpy(temp, replaceem(INSTALLER_FOLDER));
- argn=0;
- arg1=&temp[0];
- arg2=arg3=arg4=arg5=&zerotext[0];
- len = strlen(temp);
- for(z=0;z<len;z++)
- {
- if(temp[z]==',')
- {
- argn++;
- temp[z]=0;
- switch(argn)
- {
- case 1:
- arg2=&temp[z+1];
- break;
- case 2:
- arg3=&temp[z+1];
- break;
- case 3:
- arg4=&temp[z+1];
- break;
- case 4:
- arg5=&temp[z+1];
- break;
- case 5:
- argn=0;
- MakeFolder(arg1, arg2, arg3, arg4, arg5);
-#ifdef ENABLE_LOGGING
- fprintf(logfile, "<WPSFolderAdd>,%s,%s,%s,%s,%s\r\n", arg1, arg2,arg3,arg4,arg5);
-#endif
- arg1=&temp[z+1];
- arg2=arg3=arg4=arg5=&zerotext[0];
- break;
- }
- }
- }
- MakeFolder(arg1, arg2, arg3, arg4, arg5);
-#ifdef ENABLE_LOGGING
- fprintf(logfile, "<WPSFolderAdd>,%s,%s,%s,%s,%s\r\n", arg1, arg2,arg3,arg4,arg5);
-#endif
- }
-
- /* Create Program Objects */
- if(strlen(INSTALLER_PROGRAM)>0)
- {
- strcpy(temp, replaceem(INSTALLER_PROGRAM));
- argn=0;
- arg1=&temp[0];
- arg2=arg3=arg4=arg5=arg6=&zerotext[0];
- len = strlen(temp);
- for(z=0;z<len;z++)
- {
- if(temp[z]==',')
- {
- argn++;
- temp[z]=0;
- switch(argn)
- {
- case 1:
- arg2=&temp[z+1];
- break;
- case 2:
- arg3=&temp[z+1];
- break;
- case 3:
- arg4=&temp[z+1];
- break;
- case 4:
- arg5=&temp[z+1];
- break;
- case 5:
- arg6=&temp[z+1];
- break;
- case 6:
- argn=0;
- MakeProgram(arg1, arg2, arg3, arg4, arg5, arg6);
-#ifdef ENABLE_LOGGING
- fprintf(logfile, "<WPSProgramAdd>,%s,%s,%s,%s,%s,%s\r\n", arg1,arg2,arg3,arg4,arg5,arg6);
-#endif
- arg1=&temp[z+1];
- arg2=arg3=arg4=arg5=arg6=&zerotext[0];
- break;
- }
- }
- }
- MakeProgram(arg1, arg2, arg3, arg4, arg5, arg6);
-#ifdef ENABLE_LOGGING
- fprintf(logfile, "<WPSProgramAdd>,%s,%s,%s,%s,%s,%s\r\n", arg1, arg2,arg3,arg4,arg5,arg6);
-#endif
- }
-
- /* Create Shadow Objects */
- if(strlen(INSTALLER_SHADOW)>0)
- {
- strcpy(temp, replaceem(INSTALLER_SHADOW));
- argn=0;
- arg1=&temp[0];
- arg2=arg3=arg4=&zerotext[0];
- len = strlen(temp);
- for(z=0;z<len;z++)
- {
- if(temp[z]==',')
- {
- argn++;
- temp[z]=0;
- switch(argn)
- {
- case 1:
- arg2=&temp[z+1];
- break;
- case 2:
- arg3=&temp[z+1];
- break;
- case 3:
- arg4=&temp[z+1];
- break;
- case 4:
- argn=0;
- MakeShadow(arg1, arg2, arg3, arg4);
-#ifdef ENABLE_LOGGING
- fprintf(logfile, "<WPSShadowAdd>,%s,%s,%s,%s\r\n", arg1,arg2,arg3,arg4);
-#endif
- arg1=&temp[z+1];
- arg2=arg3=arg4=&zerotext[0];
- break;
- }
- }
- }
- MakeShadow(arg1, arg2, arg3, arg4);
-#ifdef ENABLE_LOGGING
- fprintf(logfile, "<WPSShadowAdd>,%s,%s,%s,%s\r\n", arg1,arg2,arg3,arg4);
-#endif
- }
-
- /* Create Generic Objects */
- if(strlen(INSTALLER_OBJECT)>0)
- {
- strcpy(temp, replaceem(INSTALLER_OBJECT));
- argn=0;
- arg1=&temp[0];
- arg2=arg3=arg4=arg5=&zerotext[0];
- len = strlen(temp);
- for(z=0;z<len;z++)
- {
- if(temp[z]==',')
- {
- argn++;
- temp[z]=0;
- switch(argn)
- {
- case 1:
- arg2=&temp[z+1];
- break;
- case 2:
- arg3=&temp[z+1];
- break;
- case 3:
- arg4=&temp[z+1];
- break;
- case 4:
- arg5=&temp[z+1];
- break;
- case 5:
- argn=0;
- MakeObject(arg1, arg2, arg3, arg4, arg5);
-#ifdef ENABLE_LOGGING
- fprintf(logfile, "<WPSObjectAdd>,%s,%s,%s,%s,%s\r\n", arg1,arg2,arg3,arg4,arg5);
-#endif
- arg1=&temp[z+1];
- arg2=arg3=arg4=arg5=&zerotext[0];
- break;
- }
- }
- }
- MakeObject(arg1, arg2, arg3, arg4, arg5);
-#ifdef ENABLE_LOGGING
- fprintf(logfile, "<WPSObjectAdd>,%s,%s,%s,%s,%s\r\n", arg1, arg2,arg3,arg4,arg5);
-#endif
- }
-}
-
-
-#ifdef __cplusplus
-}
-#endif
\ No newline at end of file
+++ /dev/null
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
-#pragma hdrstop
-#endif
-
-#ifndef WX_PRECOMP
-#include "wx/wx.h"
-#endif
-
-#include "wx/resource.h"
-#include "install.h"
-#include "instsup.h"
-
-#include <ctype.h>
-
-#if !defined(__EMX__) && !defined(__OS2__) && !defined(WIN32) && !defined(WINNT)
-#define stricmp strcasecmp
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern char installdir[];
-
-#ifdef __cplusplus
-}
-#endif
-
-typedef struct _wxCommands {
- int id;
- char file[50];
-} wxCommands;
-
-#define COMMANDMAX 20
-
-wxCommands wxcommands[COMMANDMAX];
-char finishedscript[256] = "";
-char percentname[256] = "";
-
-class MyApp: public wxApp
-{
-public:
- MyApp();
-
- virtual bool OnInit();
-
- virtual ~MyApp();
-};
-
-class MyDialog : public wxDialog
-{
-public:
- void handle_button(wxCommandEvent& event);
-};
-
-class MyThread : public wxThread
-{
-public:
- virtual void *Entry();
-};
-
-void *MyThread::Entry()
-{
- install_thread(NULL);
- return NULL;
-}
-
-MyDialog *dialog = NULL;
-
-IMPLEMENT_APP(MyApp)
-
-MyApp::MyApp()
-{
-}
-
-wxCondition *InstCond = NULL;
-
-void updatepercent(void)
-{
- wxGauge *tmp = (wxGauge *)wxFindWindowByName(percentname, dialog);
-
- if(tmp)
- {
- unsigned long sliderpos;
- int pixels = 100;
- extern int current_file, files;
-
- sliderpos = (unsigned long)(((float)(current_file)/(float)files)*pixels);
- tmp->SetValue(sliderpos);
- }
-}
-
-int parse_ini(char *filename)
-{
- FILE *f;
- int b;
-
- for(b=0;b<COMMANDMAX;b++)
- {
- wxcommands[b].id = 0;
- wxcommands[b].file[0] = 0;
- }
-
- grabfile(filename);
- if((f=fopen(filename, "r")) != NULL)
- {
- int bytesread = 1;
- char raw[256], entry[256], entrydata[256], entrydata2[256];
-
- /* figure out why we are not getting an EOF on windows...
- bytesread is a hack to make sure it doesn't loop forever. */
- while(!feof(f) && bytesread)
- {
- bytesread = getparseline(f, '#', ',', '\"', raw, entry, entrydata, entrydata2);
- if(stricmp(entry, "loadwxr") == 0)
- {
- grabfile(entrydata);
- if(!wxResourceParseFile(entrydata))
- {
- error("Error loading resources!");
- remove(entrydata);
- remove(filename);
- return FALSE;
- }
- remove(entrydata);
-
- dialog = new MyDialog;
-
- dialog->LoadFromResource(NULL, "dialog1");
- dialog->Show(TRUE);
-
- /*MyApp::SetTopWindow(dialog);*/
- }
- else if(stricmp(entry, "closeold") == 0)
- {
- if(dialog)
- dialog->Destroy();
- dialog = NULL;
- }
- else if(stricmp(entry, "getcheck") == 0)
- {
- wxCheckBox *tmp = (wxCheckBox *)wxFindWindowByName(entrydata, dialog);
-
- if(tmp)
- {
- if(!tmp->GetValue())
- {
- parse_ini(entrydata2);
- bytesread = 0;
- }
- }
- }
- else if(stricmp(entry, "gettext") == 0)
- {
- wxTextCtrl *tmp = (wxTextCtrl *)wxFindWindowByName(entrydata, dialog);
- wxString bleah;
-
- if(tmp)
- {
- if((bleah = tmp->GetValue()))
- strcpy(installdir, bleah);
- }
- }
- else if(stricmp(entry, "settext") == 0)
- {
- wxTextCtrl *tmp = (wxTextCtrl *)wxFindWindowByName(entrydata, dialog);
-
- if(tmp)
- tmp->SetValue(installdir);
- }
- else if(stricmp(entry, "message") == 0)
- mesg(entrydata);
- else if(stricmp(entry, "disable") == 0)
- {
- wxButton *tmp = (wxButton *)wxFindWindowByName(entrydata, dialog);
- if(tmp)
- tmp->Disable();
- }
- else if(stricmp(entry, "grabfile") == 0)
- grabfile(entrydata);
- else if(stricmp(entry, "remove") == 0)
- remove(entrydata);
- else if(stricmp(entry, "system") == 0)
- wxExecute(entrydata);
- else if(stricmp(entry, "startinst") == 0)
- {
- strcpy(percentname, entrydata);
- strcpy(finishedscript, entrydata2);
-
- /* I couldn't get it working with threads, even when
- using conditions it blocked the message loop making
- it unreadable, so I am going with wxYield for the
- moment. */
-#if 0
- MyThread *thread = new MyThread();
-
- if ( thread->Create() != wxTHREAD_NO_ERROR )
- {
- error("Can't create thread!");
- }
- strcpy(finishedscript, entrydata);
-
- InstCond = new wxCondition();
-
- thread->Run();
-
- wxMutex *test = new wxMutex();
-
- InstCond->Wait(*test);
-#endif
- install_thread(NULL);
- create_wps_objects();
- parse_ini(finishedscript);
- }
- else if(stricmp(entry, "mleview") == 0)
- {
- FILE *f;
- unsigned long bytes;
- char buffer[1025];
- wxTextCtrl *tmp = (wxTextCtrl *)wxFindWindowByName(entrydata, dialog);
-
- if(tmp)
- {
- grabfile(entrydata2);
-
- if((f = fopen(entrydata2, "rb"))!= NULL)
- {
- while(!feof(f))
- {
- memset(buffer, 0, 1025);
- bytes = fread(buffer, 1, 1024, f);
- *tmp << buffer;
- }
- fclose(f);
- }
- remove(entrydata2);
- tmp->ShowPosition(0);
- }
-
- }
- else if(stricmp(entry, "setbutton") == 0)
- {
- for(b=0;b<COMMANDMAX;b++)
- {
- if(!wxcommands[b].id)
- {
- wxcommands[b].id = atoi(entrydata);
- strcpy(wxcommands[b].file, entrydata2);
- b = COMMANDMAX;
- }
- }
- dialog->Connect( atol(entrydata), -1, wxEVT_COMMAND_BUTTON_CLICKED,
- (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction)
- &MyDialog::handle_button);
-
- }
- }
- fclose(f);
- remove(filename);
- return TRUE;
- }
- remove(filename);
- return FALSE;
-}
-
-void MyDialog::handle_button(wxCommandEvent& event )
-{
- int b;
-
- for(b=0;b<COMMANDMAX;b++)
- {
- if(wxcommands[b].id &&
- wxcommands[b].id == event.GetId())
- {
- char tempbuf[50];
-
- strcpy(tempbuf, wxcommands[b].file);
- if(stricmp(tempbuf, "exit") == 0)
- exit(0);
- grabfile(tempbuf);
- if(!parse_ini(tempbuf))
- {
- error("Error loading script \"%s\"", tempbuf);
- exit(1);
- }
- remove(tempbuf);
- return;
- }
- }
-
-}
-
-bool MyApp::OnInit(void)
-{
-#if 1
- install_init(argv[0]);
-#else
- install_init("install.exe");
-#endif
-
- if(!parse_ini("page1.ini"))
- {
- error("Could not load startup script!");
- return FALSE;
- }
-
- return TRUE;
-}
-
-MyApp::~MyApp()
-{
-}
-
-