--- sbbs/sbbs2/install/install.c 2018/04/24 16:37:52 1.1.1.1 +++ sbbs/sbbs2/install/install.c 2018/04/24 16:38:56 1.1.1.2 @@ -1,1048 +1,1048 @@ -/* install.c */ - -/* Developed 1990-1997 by Rob Swindell; PO Box 501, Yorba Linda, CA 92885 */ - -/* Synchronet BBS Installation program */ - -unsigned int _stklen=0x8000; - -#include -#include -#include -#include -#include -#include -#include "uifc.h" - -/* OS Specific */ -#if defined(__FLAT__) // 32-bit - #define FAR16 - #define HUGE16 - #define lread(f,b,l) read(f,b,l) - #define lfread(b,l,f) fread(b,l,f) - #define lwrite(f,b,l) write(f,b,l) - #define lfwrite(b,l,f) fwrite(b,l,f) -#else // 16-bit - #define FAR16 far - #define HUGE16 huge -#endif - -void bail(int code); - -char **opt; - -#define EXEC (1<<1) -#define CFGS (1<<2) -#define TEXT (1<<3) -#define DOCS (1<<4) - -#define DISK1 (EXEC|CFGS|TEXT|DOCS) - -#define UTIL (1<<10) -#define XTRN (1<<11) -#define XSDK (1<<12) - -#define DISK2 (UTIL|XTRN|XSDK) - -#define UPGRADE (1<<13) - -#define LOOP_NOPEN 100 - -int mode=(DISK1|DISK2); - -enum { /* Upgrade FROM version */ - NONE - ,SBBS20 - ,SBBS21 - ,SBBS22 - ,SBBS23 - }; - -char tmp[256]; -char install_to[129],install_from[256]; - -/****************************************************************************/ -/* Puts a backslash on path strings */ -/****************************************************************************/ -void backslash(char *str) -{ - int i; - -i=strlen(str); -if(i && str[i-1]!='\\') { - str[i]='\\'; str[i+1]=0; } -} - - -/****************************************************************************/ -/* If the directory 'path' doesn't exist, create it. */ -/* returns 1 if successful, 0 otherwise */ -/****************************************************************************/ -int md(char *path) -{ - char str[128]; - struct ffblk ff; - -if(strlen(path)<2) { - umsg("Invalid path"); - return(0); } -strcpy(str,path); -if(strcmp(str+1,":\\") && str[strlen(str)-1]=='\\') - str[strlen(str)-1]=0; /* Chop of \ if not root directory */ -if(findfirst(str,&ff,FA_DIREC)) { - if(mkdir(str)) { - sprintf(str,"Unable to Create Directory '%s'",path); - umsg(str); - return(0); } } -return(1); -} - -long fdate_dir(char *filespec) -{ - struct ffblk f; - struct date fd; - struct time ft; - -if(findfirst(filespec,&f,FA_RDONLY|FA_HIDDEN|FA_SYSTEM|FA_DIREC)==0) { - fd.da_day=f.ff_fdate&0x1f; - fd.da_mon=(f.ff_fdate>>5)&0xf; - fd.da_year=1980+((f.ff_fdate>>9)&0x7f); - ft.ti_hour=0; - ft.ti_min=0; - ft.ti_sec=0; - return(dostounix(&fd,&ft)); } -else return(0); -} - -/****************************************************************************/ -/* Returns the length of the file in 'filespec' */ -/****************************************************************************/ -long flength(char *filespec) -{ - struct ffblk f; - -if(findfirst(filespec,&f,0)==0) - return(f.ff_fsize); -return(-1L); -} - -/****************************************************************************/ -/* Checks the disk drive for the existence of a file. Returns 1 if it */ -/* exists, 0 if it doesn't. */ -/****************************************************************************/ -char fexist(char *filespec) -{ - struct ffblk f; - -if(findfirst(filespec,&f,FA_RDONLY|FA_HIDDEN|FA_SYSTEM|FA_DIREC)==0) - return(1); -return(0); -} - -#ifndef __OS2__ -/****************************************************************************/ -/* This function reads files that are potentially larger than 32k. */ -/* Up to one megabyte of data can be read with each call. */ -/****************************************************************************/ -long lread(int file, char huge *buf,long bytes) -{ - long count; - -for(count=bytes;count>32767;count-=32767,buf+=32767) - if(read(file,(char *)buf,32767)!=32767) - return(-1L); -if(read(file,(char *)buf,(int)count)!=count) - return(-1L); -return(bytes); -} - -/****************************************************************************/ -/* This function writes files that are potentially larger than 32767 bytes */ -/* Up to one megabytes of data can be written with each call. */ -/****************************************************************************/ -long lwrite(int file, char huge *buf, long bytes) -{ - - long count; - -for(count=bytes;count>32767;count-=32767,buf+=32767) - if(write(file,(char *)buf,32767)!=32767) - return(-1L); -if(write(file,(char *)buf,(int)count)!=count) - return(-1L); -return(bytes); -} -#endif - -/****************************************************************************/ -/* Network open function. Opens all files DENYALL and retries LOOP_NOPEN */ -/* number of times if the attempted file is already open or denying access */ -/* for some other reason. All files are opened in BINARY mode. */ -/****************************************************************************/ -int nopen(char *str, int access) -{ - char logstr[256]; - int file,share,count=0; - -if(access==O_RDONLY) share=O_DENYWRITE; - else share=O_DENYALL; -while(((file=open(str,O_BINARY|share|access,S_IWRITE))==-1) - && errno==EACCES && count++length) /* leave space for stack expansion */ - chunk=length; -if((buf=MALLOC(chunk))==NULL) { - close(in); - close(out); - sprintf(str,"ERROR ALLOC %s %lu",src,chunk); - umsg(str); - puttext(1,1,80,scrn_len,scrnsave); - FREE(scrnsave); - showmouse(); - return(-1); } -l=0L; -while(llength) - chunk=length-l; - lread(in,buf,chunk); - lwrite(out,buf,chunk); - l+=chunk; - cputs("\b\b\b"); - } -// cputs(" \b\b\b"); /* erase it */ -FREE((char *)buf); -getftime(in,&ftime); -setftime(out,&ftime); -close(in); -close(out); -puttext(1,1,80,scrn_len,scrnsave); -FREE(scrnsave); -showmouse(); -return(0); -} - -int unarc(int timestamp, char *src, char *dir, char *arg) -{ - int i,atr; - char str[128],cmd[128],*scrnsave; - -if((scrnsave=MALLOC((scrn_len+1)*80*2))==NULL) - return(-1); -hidemouse(); -gettext(1,1,80,scrn_len+1,scrnsave); -//lclini(scrn_len+1); -textattr(LIGHTGRAY); -clrscr(); -sprintf(cmd,"%sLHA.EXE",install_from); -sprintf(str,"/c%d",timestamp); -i=spawnlp(P_WAIT,cmd,cmd,"x",str,"/s","/m1",src,dir,arg,NULL); -if(i==-1) { - printf("\r\nCannot execute %s. Hit any key to continue.",cmd); - getch(); } -else if(i) { - printf("\r\n%s returned error level %d. Hit any key to continue.",cmd,i); - getch(); } -clrscr(); -puttext(1,1,80,scrn_len+1,scrnsave); -showmouse(); -FREE(scrnsave); -//lclini(scrn_len); -//textattr(atr); -return(i); -} - - -void main(int argc, char **argv) -{ - int i,j,k,ver; - long l; - char str[128],*p; - char text_dir[64],docs_dir[64],exec_dir[64],ctrl_dir[64]; - struct text_info txt; - struct ffblk ff; - -timezone=0; -daylight=0; -uifcini(); -if(argc>1) { /* user specified install path */ - sprintf(install_to,"%.20s",argv[1]); - strupr(install_to); - if(strlen(install_to)==1) { - if(!isalpha(install_to[0])) { - cprintf("\7\r\nInvalid install path - '%s'\r\n",install_to); - bail(1); } - strcat(install_to,":"); } - backslash(install_to); - if(strlen(install_to)<4) /* user says C, C:, or C:\, make C:\SBBS */ - strcat(install_to,"SBBS\\"); } -else - strcpy(install_to,"C:\\SBBS\\"); - -strcpy(install_from,argv[0]); -strupr(install_from); -p=strrchr(install_from,'\\'); -if(p) - *(p+1)=0; -else { /* incase of A:INSTALL */ - p=strchr(install_from,':'); - if(p) - *(p+1)=0; } - -if((opt=(char **)MALLOC(sizeof(char *)*MAX_OPTS))==NULL) { - cputs("memory allocation error\r\n"); - bail(1); } -for(i=0;iSystem->Loadable Modules->Login set to LOGIN\r\n" -"and SCFG->System->Loadable Modules->Logon set to LOGON.\r\n" -"\r\n" -"If you want your users to be able to use WIP compatible terminals with\r\n" -"your BBS, add WIPSHELL to SCFG->Command Shells with an Access\r\n" -"Requirement String of \"WIP\"."; - help(); } - uifcbail(); - if(mode&UPGRADE) { - cprintf("Synchronet Upgrade Complete.\r\n"); - exit(0); } - if(mode&CFGS) - p="/F"; - else - p=NULL; - spawnl(P_WAIT,"..\\EXEC\\SCFG.EXE" - ,"..\\EXEC\\SCFG","..\\CTRL",p,NULL); - textattr(LIGHTGRAY); - cprintf( -"Synchronet BBS and its utilities use file and record locking to maintain\r\n" -"data integrity in a multinode environment. File and record locking under DOS\r\n" -"requires the use of SHARE.\r\n" -"\r\n" - ); - cprintf( -"SHARE is a program that is distributed with MS-DOS and PC-DOS v3.0 and higher\r\n" -"and must be executed prior to running SBBS. SHARE.EXE should be located in the\r\n" -"DOS directory of your hard disk.\r\n" -"\r\n" - ); - cprintf( -"If you are running Microsoft Windows, you must exit Windows and load SHARE\r\n" -"before reloading Windows.\r\n" -"\r\n" - ); - cprintf( -"It is not necessary to run SHARE if using a single node on a Novell NetWare\r\n" -"workstation or in an OS/2 DOS window.\r\n" -"\r\n" - ); - cprintf( -"SHARE.EXE can be automatically loaded in your AUTOEXEC.BAT or CONFIG.SYS.\r\n" -"\r\n" - ); - textattr(WHITE); - cprintf( -"After you have loaded SHARE, type SBBS from THIS directory.\r\n" - ); - textattr(LIGHTGRAY); - exit(0); - case -1: - j=0; - strcpy(opt[0],"Yes"); - strcpy(opt[1],"No"); - opt[2][0]=0; - if(!(ulist(WIN_MID,0,0,20,&j,0,"Abort Installation",opt))) - bail(0); - break; } } -} - -void bail(int code) -{ - -if(code) - getch(); -uifcbail(); -exit(code); -} +/* install.c */ + +/* Developed 1990-1997 by Rob Swindell; PO Box 501, Yorba Linda, CA 92885 */ + +/* Synchronet BBS Installation program */ + +unsigned int _stklen=0x8000; + +#include +#include +#include +#include +#include +#include +#include "uifc.h" + +/* OS Specific */ +#if defined(__FLAT__) // 32-bit + #define FAR16 + #define HUGE16 + #define lread(f,b,l) read(f,b,l) + #define lfread(b,l,f) fread(b,l,f) + #define lwrite(f,b,l) write(f,b,l) + #define lfwrite(b,l,f) fwrite(b,l,f) +#else // 16-bit + #define FAR16 far + #define HUGE16 huge +#endif + +void bail(int code); + +char **opt; + +#define EXEC (1<<1) +#define CFGS (1<<2) +#define TEXT (1<<3) +#define DOCS (1<<4) + +#define DISK1 (EXEC|CFGS|TEXT|DOCS) + +#define UTIL (1<<10) +#define XTRN (1<<11) +#define XSDK (1<<12) + +#define DISK2 (UTIL|XTRN|XSDK) + +#define UPGRADE (1<<13) + +#define LOOP_NOPEN 100 + +int mode=(DISK1|DISK2); + +enum { /* Upgrade FROM version */ + NONE + ,SBBS20 + ,SBBS21 + ,SBBS22 + ,SBBS23 + }; + +char tmp[256]; +char install_to[129],install_from[256]; + +/****************************************************************************/ +/* Puts a backslash on path strings */ +/****************************************************************************/ +void backslash(char *str) +{ + int i; + +i=strlen(str); +if(i && str[i-1]!='\\') { + str[i]='\\'; str[i+1]=0; } +} + + +/****************************************************************************/ +/* If the directory 'path' doesn't exist, create it. */ +/* returns 1 if successful, 0 otherwise */ +/****************************************************************************/ +int md(char *path) +{ + char str[128]; + struct ffblk ff; + +if(strlen(path)<2) { + umsg("Invalid path"); + return(0); } +strcpy(str,path); +if(strcmp(str+1,":\\") && str[strlen(str)-1]=='\\') + str[strlen(str)-1]=0; /* Chop of \ if not root directory */ +if(findfirst(str,&ff,FA_DIREC)) { + if(mkdir(str)) { + sprintf(str,"Unable to Create Directory '%s'",path); + umsg(str); + return(0); } } +return(1); +} + +long fdate_dir(char *filespec) +{ + struct ffblk f; + struct date fd; + struct time ft; + +if(findfirst(filespec,&f,FA_RDONLY|FA_HIDDEN|FA_SYSTEM|FA_DIREC)==0) { + fd.da_day=f.ff_fdate&0x1f; + fd.da_mon=(f.ff_fdate>>5)&0xf; + fd.da_year=1980+((f.ff_fdate>>9)&0x7f); + ft.ti_hour=0; + ft.ti_min=0; + ft.ti_sec=0; + return(dostounix(&fd,&ft)); } +else return(0); +} + +/****************************************************************************/ +/* Returns the length of the file in 'filespec' */ +/****************************************************************************/ +long flength(char *filespec) +{ + struct ffblk f; + +if(findfirst(filespec,&f,0)==0) + return(f.ff_fsize); +return(-1L); +} + +/****************************************************************************/ +/* Checks the disk drive for the existence of a file. Returns 1 if it */ +/* exists, 0 if it doesn't. */ +/****************************************************************************/ +char fexist(char *filespec) +{ + struct ffblk f; + +if(findfirst(filespec,&f,FA_RDONLY|FA_HIDDEN|FA_SYSTEM|FA_DIREC)==0) + return(1); +return(0); +} + +#ifndef __OS2__ +/****************************************************************************/ +/* This function reads files that are potentially larger than 32k. */ +/* Up to one megabyte of data can be read with each call. */ +/****************************************************************************/ +long lread(int file, char huge *buf,long bytes) +{ + long count; + +for(count=bytes;count>32767;count-=32767,buf+=32767) + if(read(file,(char *)buf,32767)!=32767) + return(-1L); +if(read(file,(char *)buf,(int)count)!=count) + return(-1L); +return(bytes); +} + +/****************************************************************************/ +/* This function writes files that are potentially larger than 32767 bytes */ +/* Up to one megabytes of data can be written with each call. */ +/****************************************************************************/ +long lwrite(int file, char huge *buf, long bytes) +{ + + long count; + +for(count=bytes;count>32767;count-=32767,buf+=32767) + if(write(file,(char *)buf,32767)!=32767) + return(-1L); +if(write(file,(char *)buf,(int)count)!=count) + return(-1L); +return(bytes); +} +#endif + +/****************************************************************************/ +/* Network open function. Opens all files DENYALL and retries LOOP_NOPEN */ +/* number of times if the attempted file is already open or denying access */ +/* for some other reason. All files are opened in BINARY mode. */ +/****************************************************************************/ +int nopen(char *str, int access) +{ + char logstr[256]; + int file,share,count=0; + +if(access==O_RDONLY) share=O_DENYWRITE; + else share=O_DENYALL; +while(((file=open(str,O_BINARY|share|access,S_IWRITE))==-1) + && errno==EACCES && count++length) /* leave space for stack expansion */ + chunk=length; +if((buf=MALLOC(chunk))==NULL) { + close(in); + close(out); + sprintf(str,"ERROR ALLOC %s %lu",src,chunk); + umsg(str); + puttext(1,1,80,scrn_len,scrnsave); + FREE(scrnsave); + showmouse(); + return(-1); } +l=0L; +while(llength) + chunk=length-l; + lread(in,buf,chunk); + lwrite(out,buf,chunk); + l+=chunk; + cputs("\b\b\b"); + } +// cputs(" \b\b\b"); /* erase it */ +FREE((char *)buf); +getftime(in,&ftime); +setftime(out,&ftime); +close(in); +close(out); +puttext(1,1,80,scrn_len,scrnsave); +FREE(scrnsave); +showmouse(); +return(0); +} + +int unarc(int timestamp, char *src, char *dir, char *arg) +{ + int i,atr; + char str[128],cmd[128],*scrnsave; + +if((scrnsave=MALLOC((scrn_len+1)*80*2))==NULL) + return(-1); +hidemouse(); +gettext(1,1,80,scrn_len+1,scrnsave); +//lclini(scrn_len+1); +textattr(LIGHTGRAY); +clrscr(); +sprintf(cmd,"%sLHA.EXE",install_from); +sprintf(str,"/c%d",timestamp); +i=spawnlp(P_WAIT,cmd,cmd,"x",str,"/s","/m1",src,dir,arg,NULL); +if(i==-1) { + printf("\r\nCannot execute %s. Hit any key to continue.",cmd); + getch(); } +else if(i) { + printf("\r\n%s returned error level %d. Hit any key to continue.",cmd,i); + getch(); } +clrscr(); +puttext(1,1,80,scrn_len+1,scrnsave); +showmouse(); +FREE(scrnsave); +//lclini(scrn_len); +//textattr(atr); +return(i); +} + + +void main(int argc, char **argv) +{ + int i,j,k,ver; + long l; + char str[128],*p; + char text_dir[64],docs_dir[64],exec_dir[64],ctrl_dir[64]; + struct text_info txt; + struct ffblk ff; + +timezone=0; +daylight=0; +uifcini(); +if(argc>1) { /* user specified install path */ + sprintf(install_to,"%.20s",argv[1]); + strupr(install_to); + if(strlen(install_to)==1) { + if(!isalpha(install_to[0])) { + cprintf("\7\r\nInvalid install path - '%s'\r\n",install_to); + bail(1); } + strcat(install_to,":"); } + backslash(install_to); + if(strlen(install_to)<4) /* user says C, C:, or C:\, make C:\SBBS */ + strcat(install_to,"SBBS\\"); } +else + strcpy(install_to,"C:\\SBBS\\"); + +strcpy(install_from,argv[0]); +strupr(install_from); +p=strrchr(install_from,'\\'); +if(p) + *(p+1)=0; +else { /* incase of A:INSTALL */ + p=strchr(install_from,':'); + if(p) + *(p+1)=0; } + +if((opt=(char **)MALLOC(sizeof(char *)*MAX_OPTS))==NULL) { + cputs("memory allocation error\r\n"); + bail(1); } +for(i=0;iSystem->Loadable Modules->Login set to LOGIN\r\n" +"and SCFG->System->Loadable Modules->Logon set to LOGON.\r\n" +"\r\n" +"If you want your users to be able to use WIP compatible terminals with\r\n" +"your BBS, add WIPSHELL to SCFG->Command Shells with an Access\r\n" +"Requirement String of \"WIP\"."; + help(); } + uifcbail(); + if(mode&UPGRADE) { + cprintf("Synchronet Upgrade Complete.\r\n"); + exit(0); } + if(mode&CFGS) + p="/F"; + else + p=NULL; + spawnl(P_WAIT,"..\\EXEC\\SCFG.EXE" + ,"..\\EXEC\\SCFG","..\\CTRL",p,NULL); + textattr(LIGHTGRAY); + cprintf( +"Synchronet BBS and its utilities use file and record locking to maintain\r\n" +"data integrity in a multinode environment. File and record locking under DOS\r\n" +"requires the use of SHARE.\r\n" +"\r\n" + ); + cprintf( +"SHARE is a program that is distributed with MS-DOS and PC-DOS v3.0 and higher\r\n" +"and must be executed prior to running SBBS. SHARE.EXE should be located in the\r\n" +"DOS directory of your hard disk.\r\n" +"\r\n" + ); + cprintf( +"If you are running Microsoft Windows, you must exit Windows and load SHARE\r\n" +"before reloading Windows.\r\n" +"\r\n" + ); + cprintf( +"It is not necessary to run SHARE if using a single node on a Novell NetWare\r\n" +"workstation or in an OS/2 DOS window.\r\n" +"\r\n" + ); + cprintf( +"SHARE.EXE can be automatically loaded in your AUTOEXEC.BAT or CONFIG.SYS.\r\n" +"\r\n" + ); + textattr(WHITE); + cprintf( +"After you have loaded SHARE, type SBBS from THIS directory.\r\n" + ); + textattr(LIGHTGRAY); + exit(0); + case -1: + j=0; + strcpy(opt[0],"Yes"); + strcpy(opt[1],"No"); + opt[2][0]=0; + if(!(ulist(WIN_MID,0,0,20,&j,0,"Abort Installation",opt))) + bail(0); + break; } } +} + +void bail(int code) +{ + +if(code) + getch(); +uifcbail(); +exit(code); +}