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 Bulletin Board System.....Msg writing routines */
- /*======================================================================*/
-
- #include "msg.h"
- #include "xext.h"
-
- long pascal make_msgid (void);
-
-
-
- word pascal makemessage (char type) {
- /* Makes a msg from a MSGTMP? and header struct */
-
- int comval;
- static char comstring[26]="";
- word register x;
- char filename[127];
- char textname[127];
- char *p;
- char message[81];
- word lenmess;
- struct date dos_date;
- int handlem;
- int handlet=-1;
- int handlef;
- long mlen;
- long tlen;
- long flen;
- struct ffblk f;
- char numcarbons=0;
-
- /* Make checks to see if message good... */
-
- if(!*comstring) {
- strncpy(comstring,say_prompt(435),26);
- }
-
- msg.o_point=0;
- if (nodenumber!=1) sprintf(message,"MSGTMP%hu",nodenumber);
- else strcpy(message,"MSGTMP");
- strcpy(filename,message);
- strcat(filename,".HDR");
- strcpy(textname,message);
- strcat(textname,".INF");
- unlink(textname);
- level=0;
- if (findfirst(message,&filestat,0)) level=1;
-
- Aborted:
-
- printm("\n");
- carrchk();
- if(level==1) {
- say_prompt(54);
- unlink(message);
- unlink(filename);
- return(1);
- }
- else if ((filestat.ff_fsize)<3L) {
- level=1;
- goto Aborted;
- }
-
- if(!findfirst(filename,&filestat,0)) {
- handlem=oopen(filename,O_RDONLY | O_DENYNONE | O_BINARY);
- if(handlem!=-1) {
- while(!eof(handlem)) {
- fgetsx(filename,127,handlem);
- stripcr(filename);
- p=strtok(filename," ");
- p=strtok(0,"\n");
- if(!stricmp(filename,"NEWTO")) {
- if((!(msg.attr & MSGPRIVATE)) && (strcmp(mboard.forceto,msg.to))) {
- strncpy(msg.to,p,36);
- msg.to[35]=0;
- handlet=0;
- }
- }
- if(!stricmp(filename,"NEWSUBJ")) {
- strncpy(msg.subj,p,64);
- msg.subj[63]=0;
- handlet=0;
- }
- }
- }
- cclose(handlem);
- }
- if (!(type & 8)) {
- while (1) { /* Pre-save menu */
- if(handlet!=-1) {
- if ((mboard.attr & ECHO) || (mboard.attr & ALTECHO) &&
- (mboard.attr & NET) || (mboard.attr & ALTERNATE) &&
- (mboard.attr & ANSI) || ((*mboard.forceto) ||
- !(mboard.forceto==NULL)) || (!conf.carbons)) break;
- }
- say_prompt(332);
- printm(msg.subj);
- say_prompt(333);
- printm(msg.to);
- if (numcarbons) {
- for(x=0;x<numcarbons;x++) {
- gprintf(0,"\nCC: %s",&buffer[650+(37*x)]);
- }
- }
- say_prompt(55);
- if ((!(msg.attr & MSGPRIVATE)) && (strcmp(mboard.forceto,msg.to))) {
- say_prompt(334);
- }
- if (!(mboard.attr & ECHO) && !(mboard.attr & ALTECHO) &&
- !(mboard.attr & NET) && !(mboard.attr & ALTERNATE) &&
- !(mboard.attr & ANSI) && ((!*mboard.forceto) ||
- (mboard.forceto==NULL)) && (conf.carbons)) {
- if(numcarbons<conf.carbons)say_prompt(414);
- if (numcarbons) say_prompt(417);
- }
- say_prompt(335);
- helpnum=537;
- p=genin(1,0,1,1,ALPHA);
- helpnum=0;
- if(*p) comval=-1;
- else comval=0;
- if(comval) {
- for(x=0;x<6;x++) {
- if(!comstring[x])break;
- if(*p==comstring[x]) {
- comval=(int)x+1;
- break;
- }
- }
- }
- switch (comval) {
- case 1: /* Abort it */
- printm("\n");
- level=1;
- goto Aborted;
- case 2: /* Finished, save it */
- case 0:
- printm("\n");
- goto BreakOut;
- case 3: /* Change Subject field */
- say_prompt(56);
- helpnum=538;
- strcpy(message,genin(64,0,0,0,SUBJECT));
- helpnum=0;
- if (!strlen(message)) break;
- strcpy(msg.subj,message);
- break;
- case 4: say_prompt(430);
- break;
- case 5: /* Change To field */
- if ((!(msg.attr & MSGPRIVATE)) && (strcmp(mboard.forceto,msg.to))) {
- say_prompt(319);
- helpnum=539;
- strcpy(message,genin(36,0,0,0,NAME));
- helpnum=0;
- if (strlen(message)) strcpy(msg.to,message);
- }
- case 6: /* Carbon maker */
- if (!(mboard.attr & ECHO) && !(mboard.attr & ALTECHO) &&
- !(mboard.attr & NET) && !(mboard.attr & ALTERNATE) &&
- !(mboard.attr & ANSI) && (!*mboard.forceto ||
- mboard.forceto==NULL) && (conf.carbons)) {
- if(numcarbons<conf.carbons) {
-
- char temp[37];
-
- say_prompt(415);
- helpnum=540;
- strcpy(temp,genin(36,0,0,0,NAME));
- helpnum=0;
- for(x=0;x<numcarbons;x++) {
- if(!strcmp(temp,&buffer[650+(37*x)])) break;
- }
- if(verify_user(temp))break;
- strcpy(&buffer[650+(37*numcarbons)],temp);
- if(buffer[650+(37*numcarbons)]==0) break;
- numcarbons++;
- }
- }
- break;
- case 7: /* Delete last carbons */
- if (numcarbons) numcarbons--;
- break;
- }
- }
- }
- BreakOut: /* Set up save filenames */
- sprintf(filename,"%sXDATA.%03x",messpath,mboard.number);
- sprintf(textname,"%sXTEXT.%03x",messpath,mboard.number);
-
- AccessLoop1: /* Open datafile, loop if no access */
- if (findfirst(filename,&f,0)) flen=0;
- else flen=f.ff_fsize;
- if ((handlef=oopen(filename,O_RDWR | O_BINARY | O_DENYNONE))==-1)
- if ((handlef=ccreat(filename,S_IWRITE))==-1) {
- if (errno==EACCES) {
- say_prompt(57);
- carrchk();
- getxbbstime();
- goto AccessLoop1;
- }
- say_prompt(58);
- return(4);
- }
- if (conf.share) {
- x=0;
- while (lock(handlef,flen,(long)sizeof(struct _xmsg))){
- x++;
- if(x>2) {
- say_prompt(50);
- return 1;
- }
- say_prompt(57);
- sleep(1);
- }
- }
- lseek(handlef,0L,SEEK_END);
-
- AccessLoop: /* Open textfile, loop if no access */
- if (findfirst(textname,&f,0))tlen=0;
- else tlen=f.ff_fsize;
- if ((handlet=oopen(textname,O_RDWR | O_BINARY | O_DENYNONE))==-1)
- if((handlet=ccreat(textname,S_IWRITE))==-1) {
- if (errno==EACCES) {
- say_prompt(57);
- carrchk();
- getxbbstime();
- goto AccessLoop;
- }
- say_prompt(59);
- cclose(handlef);
- return(4);
- }
- if (conf.share) {
- x=0;
- while (lock(handlet,tlen,65535L)){
- x++;
- if(x>2) {
- say_prompt(50);
- return 1;
- }
- say_prompt(57);
- sleep(1);
- }
- }
- lseek(handlet,0L,SEEK_END);
-
- /* Open MSGTMP? file */
-
- if (nodenumber!=1) sprintf(message,"MSGTMP%hu",nodenumber);
- else strcpy(message,"MSGTMP");
- if (findfirst(message,&f,0)) mlen=0;
- else mlen=f.ff_fsize;
- if ((handlem=oopen(message,O_RDONLY | O_BINARY | O_DENYNONE))==-1) {
- say_prompt(60);
- cclose(handlef);
- cclose(handlet);
- return(4);
- }
- if(conf.share)lock(handlem,0L,mlen);
- msg.start=(ulong)tell(handlet);
- lenmess=0;
-
- /* Kludge lines for netmail */
-
- lastfilemsgid=make_msgid();
- if (mboard.attr & ALTECHO || mboard.attr & ALTERNATE)
- lenmess+=ffprintf(handlet,"\01MSGID: %u:%u/%01u.0@%s %lX\r",conf.alt_zone,conf.alt_net,conf.alt_node,conf.alt_domain,lastfilemsgid);
- else lenmess+=ffprintf(handlet,"\01MSGID: %u:%u/%01u.0@%s %lX\r",conf.zone,conf.net,conf.node,conf.domain,lastfilemsgid);
-
- if(*replyid) {
- lenmess+=ffprintf(handlet,"\01REPLY: %s\r",replyid);
- *replyid=0;
- }
-
- if ((mboard.attr & NET) || (mboard.attr & ALTERNATE)) {
- lenmess+=ffprintf(handlet,"\01MSGTO: %u:%u/%01u.%01u@%s\r",msg.d_zone,msg.dest_net,msg.dest,msg.d_point,to_domain);
-
- if(mboard.attr & NET) {
- if (conf.zone!=msg.d_zone && msg.d_zone && conf.zone) {
- lenmess+=ffprintf(handlet,"\01INTL %u:%u/%u %u:%u/%u\r",msg.d_zone,msg.dest_net,msg.dest,conf.zone,conf.net,conf.node);
- }
- else msg.d_zone=conf.zone;
- }
- else {
- if (conf.alt_zone!=msg.d_zone && msg.d_zone && conf.alt_zone) {
- lenmess+=ffprintf(handlet,"\01INTL %u:%u/%u %u:%u/%u\r",msg.d_zone,msg.dest_net,msg.dest,conf.alt_zone,conf.alt_net,conf.alt_node);
- }
- else msg.d_zone=conf.alt_zone;
- }
- if(msg.d_point) lenmess+=ffprintf(handlet,"\01TOPT %01u\r",msg.d_point);
- }
- if(*msginfo) {
- lenmess+=ffprintf(handlet,"\01INFO: %s\r",msginfo);
- *msginfo=0;
- }
-
- /* Kludge lines for associated messages */
-
- if ((mboard.attr & ASSOC) && (fboard.flags & FILEASSOC) && *assocfile) {
- lenmess+=ffprintf(handlet,"\01ASSOC: %s\r",assocfile);
- }
-
- while(!eof(handlem)) { /* Load and save MSGTMP? */
- if (!fgetsx(message,81,handlem)) break;
- while (p=strstr(message,"\r\n")) memmove(&p[1],&p[2],strlen(&p[2])+1);
- while (p=strchr(message,'\n')) *p='\r';
- while (p=strstr(message," \x8d")) memmove(&p[1],&p[2],strlen(&p[2])+1);
- while (p=strchr(message,'\x8d')) *p=' ';
- while (p=strchr(message,'\x1a')) memmove(p,&p[1],strlen(&p[1])+1);
- lenmess+=strlen(message);
- _write(handlet,message,strlen(message));
- if(lenmess>65100) break;
- }
- if(conf.share)unlock(handlem,0L,mlen);
- cclose(handlem);
- msg.m_attr=(msg.m_attr | MSGTREATED);
-
- if (numcarbons) { /* Tack carbon notes on the end */
- lenmess+=ffprintf(handlet,"%s%s\r",say_prompt(100),msg.to);
- for(x=0;x<numcarbons;x++) {
- lenmess+=ffprintf(handlet,"%s%s\r",say_prompt(124),&buffer[650+(37*x)]);
- }
- }
-
- if ((mboard.attr & ECHO) || (mboard.attr & ALTECHO)) { /* Origins for echo mail */
-
- word tempzone;
- word tempnet;
- word tempnode;
-
- if(mboard.attr & ECHO) {
- tempzone=conf.zone;
- tempnet=conf.net;
- tempnode=conf.node;
- }
- else {
- tempzone=conf.alt_zone;
- tempnet=conf.alt_net;
- tempnode=conf.alt_node;
- }
- if (mboard.attr & ANSI) lenmess+=ffprintf(handlet,"\x1b[22;1H\x1b[K");
- sprintf(buffer,"%sORIGINS.BBS",messpath);
- if ((handlem=oopen(buffer,O_RDONLY | O_TEXT | O_DENYNONE))==-1) goto SkipOrigins;
- while (!(eof(handlem)) && (atoi(message)!=mboard.number)) {
- fgetsx(message,80,handlem);
- message[66]=0;
- stripcr(message);
- }
- cclose(handlem);
- if (atoi(message)!=mboard.number) goto SkipOrigins;
- strtok(message,"; ");
- lenmess+=(ffprintf(handlet,"\r\n--- XBBS %s\r\n * Origin: %s (%u:%u/%u)\r",XVERSION,strtok(0,"\n"),tempzone,tempnet,tempnode));
- goto GotOrigin;
- SkipOrigins:
- lenmess+=(ffprintf(handlet,"\r\n--- XBBS %s\r\n * Origin: %s (%u:%u/%u)\r",XVERSION,conf.origin,tempzone,tempnet,tempnode));
- }
- else {
- _write(handlet,"\r",1);
- lenmess++;
- }
-
- GotOrigin:
-
- _write(handlet,"\0",1); /* Finish the text entry */
- msg.length=lenmess+2;
- if(conf.share)unlock(handlet,tlen,65535L);
- strcpy(msg.date,fidodate()); /* Set up msg header */
- if (msg.date[18]==0) msg.date[18]=' ';
- getdate(&dos_date);
- msg.indate[0]=dos_date.da_year-1989;
- msg.indate[1]=dos_date.da_mon;
- msg.indate[2]=dos_date.da_day;
- msg.indate[3]=0;
- msg.times=0;
-
- x=0;
-
- if((mboard.attr & COMPRESS) && msg.length>conf.packsize) {
-
- char *hold;
-
- hold=(char *)malloc(msg.length+1);
- if(!hold) {
- gprintf(LOCALONLY,"\n\04Can't malloc memory to compress\n");
- }
- else {
- lseek(handlet,msg.start,SEEK_SET);
- if(_read(handlet,hold,msg.length)<(msg.length-1)) {
- gprintf(LOCALONLY,"\n\04Can't compress\n");
- }
- else {
- hold[msg.length]=0;
- hold[msg.length-1]=0;
- if(strlen(hold)>conf.packsize) {
- hold[msg.length]=0;
- hold[msg.length-1]=0;
- hold=pack_msg(hold);
- if(!hold || !codesize) {
- gprintf(LOCALONLY,"\n\04Compression failed\n");
- }
- else {
- lseek(handlet,msg.start,SEEK_SET);
- msg.m_attr = msg.m_attr | MSGPACKED;
- _write(handlet,hold,msg.length);
- free(hold);
- }
- }
- else free(hold);
- }
- }
- }
-
- cclose(handlet);
- gprintf(LOGONLY,say_prompt(320),msg.subj);
- gprintf(LOGONLY,say_prompt(321),msg.to,mboard.name);
-
- CarbonLoop:
-
- _write(handlef,&msg,sizeof(struct _xmsg)); /* Save header */
- if(conf.share)unlock(handlef,flen,(long)sizeof(struct _xmsg));
- findfirst(filename,&filestat,0);
- if ((long)(filestat.ff_fsize/(long)sizeof(struct _xmsg)) > (long)mboard.max) {
-
- struct _xmsg msgtwo;
- long pos;
-
- /* Do "rollover" if over max msgs */
-
- lseek(handlef,(filestat.ff_fsize-((long)(mboard.max)-1L)*(long)sizeof(struct _xmsg)),SEEK_SET);
- pos=tell(handlef);
- if (conf.share) {
-
- int y=0;
-
- while (lock(handlef,pos,(long)sizeof(struct _xmsg))){
- y++;
- if(y>2) {
- say_prompt(50);
- return 1;
- }
- say_prompt(57);
- sleep(1);
- }
- }
- if (_read(handlef,&msgtwo,sizeof(struct _xmsg))>0) {
- if (!(msgtwo.m_attr & MSGKEEP)) {
- msgtwo.m_attr = msgtwo.m_attr & (~MSGDELETED);
- lseek(handlef,pos,SEEK_SET);
- _write(handlef,&msgtwo,sizeof(struct _xmsg));
- }
- }
- if(conf.share)unlock(handlef,pos,(long)sizeof(struct _xmsg));
- }
-
- /* Copy header for each carbon recipient */
-
- if (numcarbons>x) {
- strcpy(msg.to,&buffer[650+(37*x)]);
- x++;
- lseek(handlef,0L,SEEK_END);
- flen=tell(handlef);
- if (conf.share) {
-
- int y=0;
-
- while (lock(handlef,flen,(long)sizeof(struct _xmsg))){
- y++;
- if(y>2) {
- say_prompt(50);
- return 1;
- }
- say_prompt(57);
- sleep(1);
- }
- }
- goto CarbonLoop;
- }
-
- cclose(handlef);
-
- /* Clean up and exit */
-
- if (nodenumber!=1) sprintf(message,"MSGTMP%hu",nodenumber);
- else strcpy(message,"MSGTMP");
- unlink(message);
-
- /* Update user stats */
-
- user.posts++;
- if ((mboard.attr & NET || mboard.attr & ALTERNATE)) {
- if (msg.cost>0) user.credit-=msg.cost;
- }
-
- /* Log entries */
-
- if (numcarbons) {
- for (x=0;x<numcarbons;x++) {
- gprintf(LOGONLY,"CC: %s",&buffer[650+(37*x)]);
- }
- }
- return(0);
- }
-
-
-
- word pascal writemessage (char type) {
-
- int handle;
- char message[81];
- char msghdr[89];
- struct ffblk f;
- char *p;
-
- if (nodenumber!=1) sprintf(message,"MSGTMP%hu",nodenumber);
- else strcpy(message,"MSGTMP");
- level=0;
-
- strcpy(msghdr,message);
- strcat(msghdr,".INF");
- unlink(msghdr);
- if(!(type & 4)) {
- if((handle=(ccreat(msghdr,S_IWRITE)))!=-1) {
- if((mboard.attr & NET) || (mboard.attr & ALTERNATE)) {
- ffprintf(handle,"NET\r\n");
- if(mboard.attr & NET) p=conf.domain;
- else p=conf.alt_domain;
- ffprintf(handle,"ORIG %01u:%01u/%01u.0@%s\r\n",
- msg.o_zone,msg.orig_net,msg.orig,p);
- ffprintf(handle,"DEST %01u:%01u/%01u.%01u@%s\r\n",
- msg.d_zone,msg.dest_net,msg.dest,msg.d_point,to_domain);
- }
- if(*oldmsg.from) {
- ffprintf(handle,"REPLY\r\n");
- ffprintf(handle,"FROM %s\r\n",oldmsg.from);
- if(*oldmsg.date)ffprintf(handle,"DATE %s\r\n",oldmsg.date);
- if(*oldmsg.to)ffprintf(handle,"WASTO %s\r\n",oldmsg.to);
- }
- if((mboard.attr & ECHO) || (mboard.attr & ALTECHO)) {
- ffprintf(handle,"ECHO\r\n");
- }
- ffprintf(handle,"TO %s\r\n",msg.to);
- ffprintf(handle,"SUBJ %s\r\n",msg.subj);
- ffprintf(handle,"WRITER %s\r\n",msg.from);
- ffprintf(handle,"AREANAME %s\r\n",mboard.name);
- ffprintf(handle,"AREA# %01u\r\n",mboard.number);
- ffprintf(handle,"AREAATTRIB %u\r\n",mboard.attr);
- ffprintf(handle,"MSGATTRIB %u\r\n",msg.attr);
- ffprintf(handle,"MSGATTRIB2 %u\r\n",msg.m_attr);
- ffprintf(handle,"READER XBBS %s\r\n",XVERSION);
- ffprintf(handle,"NODE# %01u\r\n",nodenumber);
- cclose(handle);
- }
- }
-
- strcpy(msghdr,message);
- strcat(msghdr,".HDR");
- unlink(msghdr);
- if (!(type & 4)) {
- if((handle=ccreat(msghdr,S_IWRITE))!=-1) {
- if ((mboard.attr & REAL) || (mboard.attr & NET)) ffprintf(handle,"USER %s\r\n",user.name);
- else ffprintf(handle,"USER %s\r\n",user.handle);
- if(*oldmsg.from)ffprintf(handle,"FROM %s\r\n",oldmsg.from);
- else ffprintf(handle,"RECP %s\r\n",msg.to);
- if(*oldmsg.to)ffprintf(handle,"TO %s\r\n",oldmsg.to);
- ffprintf(handle,"SUBJ %s\r\n",msg.subj);
- if(*oldmsg.date)ffprintf(handle,"DATE %s\r\n",oldmsg.date);
- cclose(handle);
- memset(&oldmsg,0,sizeof(struct _xmsg));
- }
-
- if (!baud) {
- strcpy(buffer,conf.edlocal);
- }
- else if ((user.graphics) && (user.fullscreen) && (*conf.edansi)) strcpy(buffer,conf.edansi);
- else strcpy(buffer,conf.edline);
- if (mboard.attr & ANSI) {
- strcpy(buffer,conf.edgraph);
- }
- level=(word)spawnit(buffer,0,0);
- }
- else {
- say_prompt(61);
- sprintf(buffer,say_prompt(322),message);
- if (spawnit(buffer,3,0)) level=1;
- }
- carrchk();
- if (!level) if (findfirst(message,&f,0))level=1;
- if (!level) {
- if (searchpath("MESSCHEK.EXE")) {
- sprintf(buffer,"%s %s",searchpath("MESSCHEK.EXE"),message);
- level=(word)spawnit(buffer,0,0);
- }
- else readfile("aftermsg.xbs",0,0,1);
- }
- if(!level) return 0;
-
- unlink(message);
- unlink(msghdr);
- strcpy(msghdr,message);
- strcat(msghdr,".INF");
- unlink(msghdr);
- if (level==1) say_prompt(64);
- if (level==2) {
- say_prompt(63);
- exit(254);
- }
- if (level==3) {
- say_prompt(275);
- if (conf.debug) say_prompt(62);
- }
- return level;
- }
-
-
-
- int pascal askwrite (char type) {
-
- struct nodeidx nid;
- char temp[131];
- int tempcost;
-
- msg.attr=0;
- msg.m_attr=0;
- if(!(type & 1)) *replyid=0;
-
- if(mboard.attr & ALTERNATE) strcpy(to_domain,conf.alt_domain);
- else strcpy(to_domain,conf.domain);
- if ((mboard.attr & READONLY) && ((user.stat[0]<mboard.substat1) || (user.stat[1]<mboard.substat2))) {
- say_prompt(65);
- return(1);
- }
- if((mboard.attr & FORCE) && mboard.forceto!=NULL && ((user.stat[0]<mboard.substat1) || (user.stat[1]<mboard.substat2))) type = type | 2;
- if ((type & 2) && (!stricmp(user.name,mboard.forceto) || !stricmp(user.handle,mboard.forceto))) type = type & (~2);
- if (type & 2) {
- if (mboard.forceto!=NULL && *mboard.forceto) strcpy(msg.to,mboard.forceto);
- else strcpy(msg.to,conf.sysop);
- if((mboard.attr & PRIVATE) && !(mboard.attr & PUBLIC)) goto Reply1;
- else if ((mboard.attr & PUBLIC) && !(mboard.attr & PRIVATE)) {
- msg.m_attr = msg.m_attr & (~MSGPRIVATE);
- goto GoTo;
- }
- else {
- say_prompt(89);
- printm("y/N) ");
- if(*genin(1,0,1,1,YESNO)=='Y') goto Reply1;
- else msg.m_attr = msg.m_attr & (~MSGPRIVATE);
- goto GoTo;
- }
- }
- if ((user.stat[0]>=mboard.substat1) && (user.stat[1]>=mboard.substat2)) goto Both;
- if ((mboard.attr & PRIVATE) && (mboard.attr & PUBLIC)) goto Both;
- if (mboard.attr & PRIVATE) {
- Private:
- if (!stricmp(msg.to,say_prompt(47))) goto Public;
- say_prompt(70);
- if (type & 1) goto Reply1;
- else msg.d_point=0;
- say_prompt(323);
- helpnum=541;
- strcpy(temp,genin(36,0,0,0,NAME));
- helpnum=0;
- if (strlen(temp)<2) return(1);
- if ((!(mboard.attr & NET)) && !(mboard.attr & ALTERNATE) && !(mboard.attr & ALTECHO) && (!(mboard.attr & ECHO))) {
- if (!stricmp(temp,user.handle) || !stricmp(temp,user.name)) {
- say_prompt(416);
- return(1);
- }
- if(verify_user(temp))goto Private;
- }
- strcpy(msg.to,temp);
- Reply1:
- msg.attr=(msg.attr | MSGPRIVATE);
- goto GoTo;
- }
-
- else {
-
- Public:
- say_prompt(68);
- msg.attr=(msg.attr & (~MSGPRIVATE));
- if ((type & 1) or (type & 2)) goto GoTo;
- say_prompt(324);
- helpnum=542;
- strcpy(temp,genin(36,0,0,0,NAME));
- helpnum=0;
- if (strlen(temp)<1) {
- printm("All");
- strcpy(temp,"All");
- }
- strcpy(msg.to,temp);
- if (!stricmp(msg.to,"Sysop")) {
- if ((mboard.attr & ECHO) || (mboard.attr & ALTECHO)) {
- say_prompt(71);
- return(1);
- }
- strcpy(msg.to,conf.sysop);
- }
- if ((mboard.attr & ANON)) {
- say_prompt(265);
- helpnum=543;
- if (*genin(1,0,0,1,YESNO)=='Y') msg.m_attr = (msg.m_attr | MSGANON);
- helpnum=0;
- }
- }
-
- GoTo:
-
- if ((mboard.attr & REAL) || (mboard.attr & NET)) strcpy(msg.from,user.name);
- else strcpy(msg.from,user.handle);
-
- msg.attr=(msg.attr | MSGLOCAL);
-
- if (mboard.attr & NET || mboard.attr & ALTERNATE) {
- msg.m_attr=msg.m_attr | MSGNET;
- nid.node=((word)65535);
- nid.type=255;
-
- if (type & 1) {
- nid.zone=msg.d_zone;
- if (!nid.zone) {
- if (mboard.attr & ALTERNATE) nid.zone=conf.alt_zone;
- else nid.zone=conf.zone;
- }
- nid.net=msg.dest_net;
- nid.node=msg.dest;
- goto ReplyNode;
- }
- else {
- if((mboard.attr & ALTERNATE)) {
- nid.zone=conf.alt_zone;
- nid.net=conf.alt_net;
- }
- else {
- nid.zone=conf.zone;
- nid.net=conf.net;
- }
- }
- Nodeover:
- nid.node=((word)65535);
- nid.type=255;
- pauser=0;
- say_prompt(72);
- if ((nodelist(&nid,0))<0) return(1);
- Pointover:
- if(msg.d_point)gprintf(0,"\nTo point #%u\n",msg.d_point);
- Domainover:
- if(*to_domain) gprintf(0,"\nTo domain: %s\n",to_domain);
- say_prompt(73);
- helpnum=544;
- strcpy(temp,genin(5,0,1,0,ALPHANUM));
- helpnum=0;
- printm("\n");
- if ((*temp!='L') && (*temp!='Z') && (*temp!='N') && (*temp!='P') && (*temp!='D') && (strcmp(temp,"0")) && (!atoi(temp))) return(1);
- if (*temp=='L') {
-
- word tempzone;
- word tempnet;
-
- tempzone=nid.zone;
- tempnet=nid.net;
- nid.node=0;
- nid.type=255;
- if ((nodelist(&nid,1))==(-1)) {
- say_prompt(74);
- nid.zone=tempzone;
- nid.net=tempnet;
- goto Nodeover;
- }
- nid.type=0;
- lines=3;
- pauser=1;
- while((nodelist(&nid,2))>(-1)) if (toupper(inkey())=='S') break;
- nid.zone=tempzone;
- nid.net=tempnet;
- goto Nodeover;
- }
- if (*temp=='Z') {
- say_prompt(83);
- helpnum=545;
- strcpy(temp,genin(5,0,1,0,NUM));
- helpnum=0;
- if (!(word)atol(temp)) return(1);
- nid.zone=(word)atol(temp);
- nid.net= (word)65535;
- goto Nodeover;
- }
- if (*temp=='N') {
- say_prompt(84);
- helpnum=546;
- strcpy(temp,genin(5,0,1,0,NUM));
- helpnum=0;
- if (!(word)atol(temp)) return(1);
- nid.net=(word)atol(temp);
- nid.type=255;
- goto Nodeover;
- }
- if(*temp=='P') {
- say_prompt(445);
- helpnum=547;
- strcpy(temp,genin(3,0,1,0,NUM));
- helpnum=0;
- if(*temp) msg.d_point=(word)atol(temp);
- goto Pointover;
- }
- if(*temp=='D') {
- say_prompt(362);
- helpnum=574;
- strcpy(temp,genin(36,0,1,0,NUM));
- helpnum=0;
- if(*temp) strcpy(to_domain,temp);
- goto Domainover;
- }
- nid.node=(word)atol(temp);
-
- ReplyNode:
-
- if ((tempcost=nodelist(&nid,1))<0) {
- if (userno!=1) return(1);
- say_prompt(75);
- helpnum=548;
- if (*genin(1,0,1,1,YESNO)!='Y') {
- helpnum=0;
- return (1);
- }
- say_prompt(76);
- helpnum=549;
- if (*genin(1,0,1,1,YESNO)=='Y') msg.m_attr = msg.m_attr | MSGHOST;
- helpnum=0;
- }
- if (tempcost>(-1)) msg.cost=(word)tempcost;
- printm("\n");
- gprintf(0,say_prompt(325),msg.cost,user.credit);
- if (msg.cost>user.credit && stricmp(user.name,conf.sysop)) {
- say_prompt(77);
- return(1);
- }
- say_prompt(78);
- if (*genin(1,0,0,1,YESNOM)=='N') goto Nodeover;
- msg.dest=nid.node;
- msg.dest_net=nid.net;
- msg.d_zone=nid.zone;
-
- if (((user.stat[0]>=mboard.substat1) && (user.stat[1]>=mboard.substat2))) {
- say_prompt(79);
- helpnum=550;
- if (*genin(1,0,0,1,YESNO)!='N') msg.attr = (msg.attr | MSGKILL);
- say_prompt(80);
- helpnum=551;
- if (*genin(1,0,0,1,YESNO)!='N') msg.attr = (msg.attr | MSGCRASH);
- else {
- say_prompt(81);
- helpnum=552;
- if (*genin(1,0,0,1,YESNO)!='N') msg.m_attr = (msg.m_attr | MSGHOLD);
- }
- say_prompt(82);
- helpnum=553;
- if (*genin(1,0,0,1,YESNO)=='Y') {
- msg.attr = (msg.attr | MSGFILE);
- say_prompt(85);
- goto SkipRequest;
- }
- say_prompt(86);
- helpnum=554;
- if (*genin(1,0,0,1,YESNO)=='Y') {
- msg.attr = (msg.attr | MSGFRQ);
- say_prompt(87);
- }
- SkipRequest:
- ;
- }
- helpnum=0;
- printm("\n");
- }
-
- msg.o_point=0;
- if ((mboard.attr & ECHO) || (mboard.attr & ALTECHO)) msg.m_attr=(msg.m_attr | MSGECHO);
- if ((mboard.attr & ALTERNATE) || (mboard.attr & ALTECHO)) {
- msg.o_zone=conf.alt_zone;
- msg.orig_net=conf.alt_net;
- msg.orig=conf.alt_node;
- }
- else {
- msg.o_zone=conf.zone;
- msg.orig_net=conf.net;
- msg.orig=conf.node;
- }
-
- if (!(type & 1)) {
- say_prompt(88);
- helpnum=555;
- strcpy(temp,genin(64,0,0,0,SUBJECT));
- helpnum=0;
- if (!strlen(temp)) return(1);
- strcpy(msg.subj,temp);
- }
- if(!(type & 1)) memset(&oldmsg,0,sizeof(struct _xmsg));
- return(0);
-
- Both:
-
- say_prompt(89);
- if (type & 16 || ((mboard.attr & NET))) {
- printm("Y-n) ");
- if (*genin(1,0,0,1,YESNO)=='N') goto Public;
- goto Private;
- }
- else {
- printm("y-N) ");
- if (*genin(1,0,0,1,YESNO)!='Y') goto Public;
- goto Private;
- }
- }
-
-
- char pascal verify_user (char *uname) {
-
- int fphandle;
- struct _user check;
- register word x;
-
- if ((fphandle=oopen(searchpath("USERS.BBS"),O_RDONLY | O_BINARY | O_DENYNONE))==-1) {
- say_prompt(67);
- return(1);
- }
- x=0;
- say_prompt(69);
- while (!eof(fphandle) && _read(fphandle,&check,sizeof(struct _user))>0) {
- if (mboard.attr & REAL) strcpy(check.handle,check.name);
- if (!(stricmp(check.handle,uname)) && (!check.deleted)) break;
- if ((++x%50)==0) printm(".");
- }
- cclose(fphandle);
- printm("\n");
- if ((stricmp(check.handle,uname)) || (check.deleted)) {
- say_prompt(66);
- helpnum=556;
- if (*genin(1,0,0,1,YESNO)!='N') {
- helpnum=0;
- userlist((mboard.attr & REAL));
- }
- helpnum=0;
- return 1;
- }
- return 0;
- }
-
- int pascal nodelist (struct nodeidx *nii,char type) {
-
- struct nodeinfo nif;
- struct nodeidx nid;
- static int cidx;
- char temp[129];
- char len;
- int handle;
-
- nif.zone=nii->zone;
- nif.net=nii->net;
- nif.node=nii->node;
- nif.type=nii->type;
- if (type==2) cidx++;
- else if ((nif.net==((word)65535)) || (nif.type==255)) cidx=0;
-
-
- sprintf(temp,"%sQNL_IDX.BBS",conf.nodelist);
- if ((handle=oopen(temp,O_RDONLY | O_BINARY | O_DENYNONE))==-1) {
- say_prompt(90);
- return(-1);
- }
- lseek(handle,(long)(cidx)*(long)sizeof(struct nodeidx),SEEK_SET);
-
- nid.zone=0;
- nid.net=0;
- nid.node=0;
- nid.type=0;
-
- while((nif.zone!=nid.zone) && (!eof(handle))) {
- if (_read(handle,&nid,sizeof(struct nodeidx))<1) {
- cclose(handle);
- return (-1);
- }
- if (!((cidx++)%50)) if (type==1) printm(".");
- }
- if (nif.net!=((word)65535)) {
- while((nif.net!=nid.net) && (!eof(handle))) {
- if (_read(handle,&nid,sizeof(struct nodeidx))<1) {
- cclose(handle);
- return (-1);
- }
- if (!((cidx++)%50)) if (type==1) printm(".");
- }
- }
- if (nif.node!=((word)65535) && type!=2) {
- while((nif.node!=nid.node) && (!eof(handle))) {
- if (_read(handle,&nid,sizeof(struct nodeidx))<1) {
- cclose(handle);
- return (-1);
- }
- if (!((cidx++)%50)) if (type==1) printm(".");
- }
- }
-
- if (type!=2) {
- if (eof(handle) || (nif.node!=((word)65535) && nid.node!=nif.node) || (nif.net!=((word)65535) && nid.net!=nif.net) || (nif.zone!=((word)65535) && nid.zone!=nif.zone)) {
- say_prompt(91);
- cclose(handle);
- return(-1);
- }
- }
- if (eof(handle)) {
- cclose(handle);
- return (-1);
- }
-
- GotwhatIwant:
-
- cclose(handle);
- if (type==2 && (nif.zone!=nid.zone || nif.net!=nid.net)) return (-1);
- sprintf(temp,"%sQNL_DAT.BBS",conf.nodelist);
- if ((handle=oopen(temp,O_RDONLY | O_BINARY | O_DENYNONE))==-1) {
- say_prompt(92);
- return(-1);
- }
- lseek(handle,(long)(--cidx)*(long)sizeof(struct nodeinfo),SEEK_SET);
- if (_read(handle,&nif,sizeof(struct nodeinfo))<1) {
- cclose(handle);
- return (-1);
- }
- cclose(handle);
- len=*nif.name;
- memmove(nif.name,&nif.name[1],len);
- nif.name[len]=0;
- len=*nif.city;
- memmove(nif.city,&nif.city[1],len);
- nif.city[len]=0;
- len=*nif.phone;
- memmove(nif.phone,&nif.phone[1],len);
- nif.phone[len]=0;
- len=*nif.password;
- memmove(nif.password,&nif.password[1],len);
- nif.password[len]=0;
- if (gprintf(0,say_prompt(326),'\n',nif.type,nif.zone,nif.net,nif.node,nif.name,nif.city)) return (-1);
- if (pauser==1) if ((char)strlen(temp)>user.width) lines++;
- sprintf(temp,say_prompt(327),nif.phone,nif.baud,nif.cost);
- if (nif.flags & B_hub) strcat(temp,"Hub ");
- if (nif.flags & B_host) strcat(temp,"Host ");
- if (nif.flags & B_region) strcat(temp,"RC ");
- if (nif.flags & B_zone) strcat(temp,"ZC ");
- if (nif.flags & B_CM) strcat(temp,"CM");
- if (printm(temp)) return (-1);
- if (pauser==1) if ((char)strlen(temp)>user.width) lines++;
- return(nif.cost);
-
- }
-
- long pascal make_msgid (void) {
-
- time_t t;
-
- (void)time(&t);
- t = (t<<4) | (nodenumber);
- return t;
- }
-