home *** CD-ROM | disk | FTP | other *** search
- /*--------------------------------------------------------------------------*/
- /* */
- /* XBBS SOURCE CODE copyright (c) 1990 by M. Kimes */
- /* All Rights Reserved */
- /* */
- /* For complete details of the licensing restrictions, please refer */
- /* to the License agreement, which is published in its entirety in */
- /* the in the file LICENSE.XBS. */
- /* */
- /* USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE */
- /* XBBS LICENSING AGREEMENT. IF YOU DO NOT FIND THE TEXT OF */
- /* THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO */
- /* NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT M. KIMES */
- /* AT THE ADDRESS LISTED BELOW. IN NO EVENT SHOULD YOU PROCEED TO USE */
- /* THIS FILE WITHOUT HAVING ACCEPTED THE TERMS OF THE XBBS LICENSING */
- /* AGREEMENT, OR SUCH OTHER AGREEMENT AS YOU ARE ABLE TO REACH WITH */
- /* M. KIMES */
- /* */
- /* */
- /* You can contact M. Kimes at the following address: */
- /* */
- /* M. Kimes 1:380/16.0@FidoNet */
- /* 542 Merrick (318)222-3455 data */
- /* Shreveport, LA 71104 */
- /* */
- /* */
- /* Please feel free to contact me at any time to share your comments about */
- /* my software and/or licensing policies. */
- /* */
- /*--------------------------------------------------------------------------*/
- /**************************************************************************/
- /* XBBS Files-mode module */
- /**************************************************************************/
-
- #include "msg.h"
- #include "xext.h"
-
- void xfile (char *fname,char statnum) {
-
- char filename[133];
- char string[256];
- char tempstring[49];
- struct ffblk f;
- static char comstring[26]="";
- int comval=0;
- char command=0;
- struct _fboard *fb;
- struct _fboard ff;
- struct _mboard mb;
- char *p;
- word x;
- char listing;
- struct dfree drivefree;
- char lastcommand=0,highcommand,wascommand=0;
- char *divie[28];
- char prettystring[256];
-
- if(!fname || !*fname) strcpy(filename,say_prompt(446));
- else strcpy(filename,fname);
- if(findfirst(filename,&f,0)) return;
-
- statnum=min(statnum,9);
- memcpy(&mb,&mboard,sizeof(struct _mboard));
- memcpy(&ff,&fboard,sizeof(struct _fboard));
- strcpy(string,say_prompt(486));
- if(!find_msgarea(string,fboard.name,0)) {
- memcpy(&mboard,&mb,sizeof(struct _mboard));
- }
- if(!*comstring) {
- strncpy(comstring,say_prompt(206),26);
- say_prompt(500);
- }
- strncpy(prettystring,say_prompt(583),256);
- prettystring[255]=0;
- divie[0]=strtok(prettystring," ");
- if(divie[0]) {
- x=1;
- while((divie[x]=strtok(0," ")) && x<26) {
-
- char *p;
-
- while(p=strchr(divie[x],'_')) *p=' ';
- x++;
- }
- highcommand=(char)x-1;
- }
-
- ReList:
- command=0;
- while(1) {
- FancyReDo:
- comval=0;
- gprintf(0,say_prompt(103),fboard.name); /* Current area */
- sprintf(string,"%sFILES.BBS",fboard.dpath);
- if(findfirst(string,&f,0)) say_prompt(106); /* No files.bbs */
- if ((user.ansimenus || !user.graphics) || !divie[0]) {
- say_prompt(452); /* Menu */
- helpnum=590;
- command=*genin(1,0,1,1,ALLL);
- }
- else {
- say_prompt(584);
- FancyRepeat:
- printm(divie[lastcommand]);
- FancyNull:
- helpnum=0;
- command=*genin(1,0,1,1,HYPER);
- wascommand=lastcommand;
- switch((int)command) {
- case 0: command=toupper(*divie[lastcommand]);
- backup(divie[lastcommand]);
- gprintf(0,"%c",*divie[lastcommand]);
- goto DirectEntry;
- case 1:
- case 4:
- case '4':
- case '8': if(lastcommand==0) lastcommand=highcommand;
- else lastcommand--;
- break;
- case 5:
- case 2:
- case '6':
- case '2': if(lastcommand==highcommand) lastcommand=0;
- else lastcommand++;
- break;
- case 11:
- case 27: printm("\n");
- say_prompt(452);
- printm("\n");
- goto FancyReDo;
- case 3: printm("\n");
- goto FancyReDo;
- default: for(x=0;x<(int)(highcommand+1);x++) {
- if(toupper(command)==toupper(*divie[x])) {
- lastcommand=(char)x;
- backup(divie[wascommand]);
- gprintf(0,"%c",*divie[lastcommand]);
- goto DirectEntry;
- }
- }
- backup(divie[wascommand]);
- gprintf(0,"%c",toupper(command));
- goto DirectEntry;
- }
- backup(divie[wascommand]);
- goto FancyRepeat;
- }
- DirectEntry:
- for(x=0;x<27;x++) {
- if(!comstring[x])break;
- if(command==comstring[x]) {
- command=(char)x+1;
- break;
- }
- }
- helpnum=0;
- switch ((int)command) {
- case '*': readfile("FILEXTRA.XBS",0,0,1);
- break;
- case 1: memcpy(&mboard,&mb,sizeof(struct _mboard));
- memcpy(&fboard,&ff,sizeof(struct _fboard));
- return;
- case 2: if(filesbbs("FILES.BBS",0|8,saydate(&user.lastdate),NULL)==3) goto DownLoad;
- break;
- case 3: if(filesbbs("FILES.BBS",2|8,saydate(&user.lastdate),NULL)==3) goto DownLoad;
- break;
- case 4: say_prompt(482);
- helpnum=595;
- strcpy(tempstring,genin(8,0,1,0,DATE));
- helpnum=0;
- if(strlen(tempstring)<8) {
- strcpy(tempstring,saydate(&user.lastdate));
- say_prompt(483);
- }
- else {
- printm("\n");
- sprintf(string,"%2.2s/%2.2s/%4.4s",tempstring,&tempstring[2],&tempstring[4]);
- strcpy(tempstring,string);
- }
- if(filesbbs("FILES.BBS",2|8,tempstring,NULL)==3) goto DownLoad;
- break;
- case 5:
- case 6:
- case 7: fb=(struct _fboard*)mmalloc(sizeof(struct _fboard));
- if(fb==NULL) {
- say_prompt(459);
- break;
- }
- memcpy(fb,&fboard,sizeof(struct _fboard));
- if(command==7) {
- say_prompt(484);
- helpnum=596;
- strcpy(tempstring,genin(8,0,1,0,FLE));
- helpnum=0;
- if(p=strchr(tempstring,'.')) *p=0;
- }
- else if(command==6) {
- say_prompt(485);
- helpnum=597;
- strcpy(tempstring,genin(25,0,1,0,ALLL));
- helpnum=0;
- }
- if(command!=5)if(!*tempstring) goto SearchDone;
- say_prompt(498);
- next_filearea(NULL,0);
- level=0;
- while((listing=next_filearea(say_prompt(446),user.stat[statnum]))) {
- if(level) {
- level=0;
- break;
- }
- if(!stricmp(fboard.dpath,"NUL") || !stricmp(fboard.dpath,"NUL\\")) {
- continue;
- }
- if(command==7) {
- sprintf(string,"%s%s.*",fboard.dpath,tempstring);
- if(!findfirst(string,&f,0)) {
- gprintf(0,say_prompt(497),fboard.name);
- level=filesbbs("FILES.BBS",4|8,saydate(&user.lastdate),tempstring);
- if(level!=0 && level!=2 && level!=4) break;
- printm("\n");
- check_dls(string,&x,1);
- say_prompt(496);
- }
- }
- else {
- if(command==6) {
- gprintf(0,say_prompt(495),fboard.name);
- level=filesbbs("FILES.BBS",4|8,saydate(&user.lastdate),tempstring);
- if(level!=0 && level!=2 && level!=4) break;
- }
- else {
- gprintf(0,say_prompt(495),fboard.name);
- level=filesbbs("FILES.BBS",2|8,saydate(&user.lastdate),NULL);
- if(level!=0 && level!=2 && level!=4)break;
- }
- }
- }
- if(level==0 || level==2 || level==4 || !listing) say_prompt(494);
- else say_prompt(460);
- SearchDone:
- if(fb) {
- if(level!=3) memcpy(&fboard,fb,sizeof(struct _fboard));
- ffree(fb);
- fb=NULL;
- }
- if(level==3) {
- printm("\n");
- goto DownLoad;
- }
- break;
- case 8: rawdir(fboard.dpath,0);
- break;
- case 9: goto Filelistings;
- case 10:
- DownLoad:
- say_prompt(464);
- if(isleech(fboard.leechpercent)) {
- say_prompt(598);
- break;
- }
- strcpy(string,filename);
- x=(word)*genin(1,0,1,1,ALPHA);
- printm("\n");
- if(x!=(word)'A') askdl("NULL",statnum,string,0);
- else askdl("NULL",0,"NULL",0);
- break;
- case 11: comval=1;
- say_prompt(473);
- gprintf(0,say_prompt(490),fboard.name);
- say_prompt(489);
- if(*genin(1,0,1,1,YESNO)=='Y') goto Filelistings;
- printm("\n");
- ReUp:
- if(fboard.upath==NULL || !*fboard.upath || !strcmp(fboard.upath,"NUL") ||
- !strcmp(fboard.upath,"NUL\\")) {
- say_prompt(451);
- break;
- }
- printm("\n");
- getdfree((toupper(*fboard.upath)-'@'),&drivefree);
- gprintf(0,"%lu bytes free\n",(long)drivefree.df_avail*(drivefree.df_bsec*drivefree.df_sclus));
- if ((long)drivefree.df_avail*(drivefree.df_bsec*drivefree.df_sclus)<atol(say_prompt(487))) {
- say_prompt(488);
- break;
- }
- upload(NULL,0);
- break;
- case 12: say_prompt(109);
- break;
- case 0: break;
- case 13: say_prompt(6);
- strcpy(tempstring,genin(13,0,1,0,FLE));
- printm("\n");
- if(!*tempstring) break;
- sprintf(string,"%s%s",fboard.dpath,tempstring);
- if(!findfirst(string,&f,0)) {
-
- char dostring[256];
- char *p;
-
- p=strrchr(string,'.');
- if(p) p++;
- if(!p || !*p) {
- readtext(string);
- break;
- }
- sprintf(dostring,"%sARCHIVERS.XBS",conf.homepath);
- if(!findfirst(dostring,&f,0)) {
-
- int handle;
- char ok=0;
-
- handle=oopen(dostring,O_RDONLY | O_BINARY | O_DENYNONE);
- if(handle!=-1) {
- while(!eof(handle)) {
- if(!fgetsx(dostring,145,handle)) break;
- if(!strnicmp(dostring,p,3)) {
- stripcr(dostring);
- lstrip(rstrip(dostring));
- ok=1;
- break;
- }
- }
- cclose(handle);
- if(!ok) {
- readtext(string);
- break;
- }
- else {
-
- FILE *fptr;
- char tmpnm[133];
-
- strcpy(tmpnm,say_prompt(9));
- if(!(fptr=freopen(tmpnm,"w",stdout))) {
- break;
- }
- strcat(dostring," ");
- strcat(dostring,string);
- spawnit(&dostring[4],0,0);
- fclose(fptr);
- freopen("CON","w",stdout);
- setbuf(stdout,NULL);
- readtext(tmpnm);
- break;
- }
- }
- }
- }
- else {
- say_prompt(7);
- }
- break;
- default: sprintf(string,"XFILE%03hu.XBS",command);
- readfile(string,1,1,1);
- printm("\n");
- break;
- }
- }
-
- Filelistings:
- gprintf(0,say_prompt(490),fboard.name);
- say_prompt(449); /* Change current file area */
- helpnum=592;
- strcpy(tempstring,genin(48,0,1,0,ALLL));
- helpnum=0;
- printm("\n");
- if(*tempstring=='?') {
- sprintf(string,"%sAREALIST.XBS",conf.menupath);
- if(findfirst(string,&f,0)) find_filearea(filename,"___",user.stat[statnum]);
- else readfile("arealist.xbs",1,1,1);
- goto Filelistings;
- }
- if(*tempstring) {
- if(atol(tempstring)) {
- strcpy(string,"#");
- strcat(string,tempstring);
- }
- else strcpy(string,tempstring);
- if(!find_filearea(filename,string,user.stat[statnum])) {
- say_prompt(450);
- }
- else {
- sprintf(string,"%s",say_prompt(486));
- if(!find_msgarea(string,fboard.name,0)) {
- memcpy(&mboard,&mb,sizeof(struct _mboard));
- }
- }
- }
- if(comval) goto ReUp;
- else goto ReList;
- }
-