home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / BBS / MISC / XSRC_117.ZIP / XMSGIN.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-10  |  70.9 KB  |  2,297 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*   XBBS SOURCE CODE copyright (c) 1990 by M. Kimes                        */
  4. /*   All Rights Reserved                                                    */
  5. /*                                                                          */
  6. /*    For complete details of the licensing restrictions, please refer      */
  7. /*    to the License agreement, which is published in its entirety in       */
  8. /*    the in the file LICENSE.XBS.                                          */
  9. /*                                                                          */
  10. /*    USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE      */
  11. /*    XBBS LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF            */
  12. /*    THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO       */
  13. /*    NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT M. KIMES         */
  14. /*    AT THE ADDRESS LISTED BELOW.  IN NO EVENT SHOULD YOU PROCEED TO USE   */
  15. /*    THIS FILE WITHOUT HAVING ACCEPTED THE TERMS OF THE XBBS LICENSING     */
  16. /*    AGREEMENT, OR SUCH OTHER AGREEMENT AS YOU ARE ABLE TO REACH WITH      */
  17. /*    M. KIMES                                                              */
  18. /*                                                                          */
  19. /*                                                                          */
  20. /* You can contact M. Kimes at the following address:                       */
  21. /*                                                                          */
  22. /* M. Kimes                         1:380/16.0@FidoNet                      */
  23. /* 542 Merrick                      (318)222-3455 data                      */
  24. /* Shreveport, LA  71104                                                    */
  25. /*                                                                          */
  26. /*                                                                          */
  27. /* Please feel free to contact me at any time to share your comments about  */
  28. /* my software and/or licensing policies.                                   */
  29. /*                                                                          */
  30. /*--------------------------------------------------------------------------*/
  31. /*======================================================================*/
  32. /*  XBBS Bulletin Board System.....Bulls & Msg reading                  */
  33. /*======================================================================*/
  34.  
  35.  
  36. #include "msg.h"
  37. #include "xext.h"
  38.  
  39.  
  40. struct _mboard far *marea=NULL;
  41. struct _fboard holdboard;
  42. struct _mboard holdmboard;
  43. char exporting;
  44. word maxareas=0;
  45. word higharea;
  46.  
  47.  
  48. /* Bulls-mode support routines */
  49.  
  50. void pascal load_areas (char *areasfile) {
  51.  
  52.     register word x;
  53.     int fphandle;
  54.     struct ffblk f;
  55.     char string[256];
  56.     word tempareas=0;
  57.     char filename[128];
  58.     char *p;
  59.     char *pp;
  60.  
  61.     maxareas=higharea=0;
  62.     marea=NULL;
  63.  
  64.     if (areasfile==NULL || *areasfile==0) sprintf(filename,"%sMSGAREAS.XBS",messpath);
  65.     else strcpy(filename,areasfile);
  66.     if (findfirst(filename,&f,0)) {
  67.         say_prompt(257);
  68.         return;
  69.     }
  70.     if ((fphandle=oopen(filename,O_RDONLY | O_TEXT | O_DENYNONE))==-1) {
  71.         say_prompt(258);
  72.         return;
  73.     }
  74.  
  75. /* Find out how many areas there are */
  76.  
  77.     while (!eof(fphandle)) {
  78.         if (fgetsx(string,255,fphandle)==NULL) break;
  79.         if (*string=='\r' || *string=='\n' || *string==';' || !*string) continue;
  80.         maxareas++;
  81.     }
  82.  
  83.     lseek(fphandle,0L,SEEK_SET);
  84.  
  85. /* Allocate memory for areas */
  86.  
  87.     marea=(struct _mboard far*)mmalloc((maxareas+1)*sizeof(struct _mboard));
  88.     if (marea==NULL) {
  89.         say_prompt(259);
  90.         maxareas=0;
  91.         cclose(fphandle);
  92.         return;
  93.     }
  94.  
  95. /* Parse through the file */
  96.  
  97.     while (!eof(fphandle) && tempareas<maxareas+1) {
  98. BreakOut:
  99.         if (fgetsx(string,255,fphandle)==NULL) break;
  100.         if (*string=='\n' || *string==';' || !*string) continue;
  101.         stripcr(string);
  102.         strncpy(marea[tempareas].name,strtok(string,","),47);
  103.         marea[tempareas].name[47]=0;
  104.         marea[tempareas].attr=(word)atoi(strtok(0," ,"));
  105.         marea[tempareas].max=(word)atoi(strtok(0," ,"));
  106.         marea[tempareas].number=(word)atoi(strtok(0," ,"));
  107.         marea[tempareas].substat1=(word)atoi(strtok(0," ,"));
  108.         if(marea[tempareas].substat1>user.stat[0]) continue;
  109.         marea[tempareas].substat2=(word)atoi(strtok(0," ,"));
  110.         pp=strtok(0,"\n");
  111.         p=NULL;
  112.         if(pp && *pp) {
  113.             if(*pp!=',') {
  114.                 p=strtok(pp,",");
  115.                 pp=strtok(0,"\n");
  116.             }
  117.             else pp++;
  118.         }
  119.         if(p!=NULL)strncpy(marea[tempareas].forceto,p,36);
  120.         else *marea[tempareas].forceto=0;
  121.         marea[tempareas].forceto[35]=0;
  122.         p=NULL;
  123.         if(pp && *pp) {
  124.             if(*pp!=',') {
  125.                 p=strtok(pp,",");
  126.                 pp=strtok(0,"\n");
  127.             }
  128.             else pp++;
  129.         }
  130.         p=NULL;
  131.         if(pp && *pp) {
  132.             if(*pp!=',') {
  133.                 p=strtok(pp,",");
  134.                 pp=strtok(0,"\n");
  135.             }
  136.             else pp++;
  137.         }
  138.         if(!p) marea[tempareas].age=0;
  139.         else marea[tempareas].age=(signed char)atoi(p);
  140.         if(marea[tempareas].age) {
  141.             if(marea[tempareas].age<0) {
  142.                 if(age>(char)abs(marea[tempareas].age)) continue;
  143.             }
  144.             else {
  145.                 if(age<(char)marea[tempareas].age) continue;
  146.             }
  147.         }
  148.         p=NULL;
  149.         if(pp && *pp) {
  150.             if(*pp!=',') {
  151.                 p=strtok(pp,",");
  152.                 pp=strtok(0,"\n");
  153.             }
  154.             else pp++;
  155.         }
  156.         if(!p)marea[tempareas].flags=0;
  157.         else marea[tempareas].flags=(word)atol(p);
  158.         if(marea[tempareas].flags) {
  159.             for(x=0;x<16;x++) {
  160.                 if(mboard.flags & (1<<x)) {
  161.                     if(!(user.attr2 & (1<<x))) {
  162.                         goto BreakOut;
  163.                     }
  164.                 }
  165.             }
  166.         }
  167.         p=NULL;
  168.         if(pp && *pp) {
  169.             if(*pp!=',') {
  170.                 p=strtok(pp,",");
  171.                 pp=strtok(0,"\n");
  172.             }
  173.             else pp++;
  174.         }
  175.         p=NULL;
  176.         if(pp && *pp) {
  177.             if(*pp!=',') {
  178.                 p=strtok(pp,",");
  179.                 pp=strtok(0,"\n");
  180.             }
  181.             else pp++;
  182.         }
  183.         p=NULL;
  184.         if(pp && *pp) {
  185.             if(*pp!=',') {
  186.                 p=strtok(pp,",");
  187.                 pp=strtok(0,"\n");
  188.             }
  189.             else pp++;
  190.         }
  191.         if(p){
  192.             marea[tempareas].minwrite=(word)atol(p);
  193.         }
  194.         else marea[tempareas].minwrite=0;
  195.  
  196.         if (marea[tempareas].number>higharea) higharea=marea[tempareas].number;
  197.         tempareas++;
  198.     }
  199.     if (tempareas<maxareas) maxareas=tempareas;
  200.     cclose(fphandle);
  201. }
  202.  
  203.  
  204.  
  205. char pascal find_area (word areano,char type) {
  206.  
  207.     word register x;
  208.     /* word register y; */
  209.  
  210.     for (x=0;x<maxareas;x++) {
  211.         if (marea[x].number==areano) {
  212. /*          if (user.stat[0]<marea[x].substat1) goto NullArea;
  213.             if (marea[x].flags) {
  214.                 for(y=0;y<16;y++) {
  215.                     if(marea[x].flags & (1<<y)) {
  216.                         if(!(user.attr2 & (1<<y))) {
  217.                             goto NullArea;
  218.                         }
  219.                     }
  220.                 }
  221.             }
  222.             if(marea[x].age) {
  223.                 if(marea[x].age>0) {
  224.                     if(age<(char)marea[x].age) {
  225.                         goto NullArea;
  226.                     }
  227.                 }
  228.                 else {
  229.                     if(age>(char)abs(marea[x].age)) {
  230.                         goto NullArea;
  231.                     }
  232.                 }
  233.             }
  234. */          if ((marea[x].attr & ANSI)!=0 && user.graphics==0) goto NullArea; /* No graphics */
  235.             memcpy(&mboard,&marea[x],sizeof(struct _mboard));
  236.             if((mboard.attr & ASSOC) && !exporting) {
  237.                 find_filearea(say_prompt(446),mboard.name,user.stat[0]);
  238.                 strcpy(mboard.name,marea[x].name);
  239.             }
  240.             else {
  241.                 memcpy(&fboard,&holdboard,sizeof(struct _fboard));
  242.             }
  243.             if (type) return (1+tellabout(type));
  244.             return 1;
  245.         }
  246.     }
  247.  
  248. NullArea:
  249.  
  250.     if (!type) say_prompt(20);
  251.     return 0;
  252. }
  253.  
  254.  
  255.  
  256.  
  257. void pascal dobulls (char *areasfile,char uploads) {    /* Bulls-mode */
  258.  
  259.     static unsigned deja_vu[4096];
  260.     static char exported=0;
  261.     long maxexportsize;
  262.     long total=0;
  263.     char command;
  264.     char selecting;
  265.     char neworold;
  266.     word areano;
  267.     word temparea;
  268.     word temp;
  269.     char filename[148];
  270.     static char counter=0;
  271.     char string[79];
  272.     int  fp;
  273.     int  comval;
  274.     register word x;
  275.     word tempbaud;
  276.     static char comstring[41];
  277.     static char doprompting=0;
  278.     char prettystring[384];
  279.     char *divie[43];
  280.     char lastcommand=0,highcommand,wascommand,useftn;
  281.  
  282.     exporting=0;
  283.     memcpy(&holdboard,&fboard,sizeof(struct _fboard));
  284.     memcpy(&holdmboard,&mboard,sizeof(struct _mboard));
  285.     find_filearea(say_prompt(446),mboard.name,user.stat[0]);
  286.  
  287.     load_areas(areasfile);
  288.     if (!maxareas) {
  289.         if(marea)ffree(marea);
  290.         marea=NULL;
  291.         return;
  292.     }
  293.     areano=mboard.number;
  294.     if (!find_area(areano,2)) {
  295.         if (marea) ffree(marea);
  296.         marea=NULL;
  297.         maxareas=0;
  298.         return;
  299.     }
  300.     sprintf(filename,"%sBULLS\\INTRO.%03x",conf.menupath,areano);
  301.     if (!findfirst(filename,&filestat,0)) readfile(filename,0,0,1);
  302.     if (areano<(conf.nolmrs+1) && lastread[areano-1]==0) {
  303.         sprintf(filename,"%sBULLS\\RULES.%03x",conf.menupath,areano);
  304.         if (!findfirst(filename,&filestat,0)) readtext(filename);
  305.     }
  306.     if(!*comstring) {
  307.         strncpy(comstring,say_prompt(433),41);
  308.         say_prompt(461);
  309.     }
  310.     strncpy(prettystring,say_prompt(582),384);
  311.     prettystring[383]=0;
  312.     divie[0]=strtok(prettystring," ");
  313.     if(divie[0]) {
  314.         x=1;
  315.         while((divie[x]=strtok(0," ")) && x<41) {
  316.  
  317.             char *p;
  318.  
  319.             while(p=strchr(divie[x],'_')) *p=' ';
  320.             x++;
  321.         }
  322.         highcommand=(char)x-1;
  323.     }
  324.     deja_vu[areano-1]=1;
  325.  
  326.   while(1) {
  327.     temparea=areano;
  328.     exporting=0;
  329.     useftn=0;
  330. FancyReDo:
  331.     tellabout(0);
  332.     printg("\x1b[0;1;36m");
  333.     if ((user.ansimenus || !user.graphics) || !divie[0]) {
  334.         say_prompt(22);
  335.         helpnum=560;
  336.         command=*genin(1,0,1,1,ALLL);
  337.         helpnum=0;
  338.     }
  339.     else {
  340.         say_prompt(585);
  341. FancyRepeat:
  342.         printm(divie[lastcommand]);
  343. FancyNull:
  344.         helpnum=0;
  345.         command=*genin(1,0,1,1,HYPER);
  346.         wascommand=lastcommand;
  347.         switch((int)command) {
  348.             case 0:   command=toupper(*divie[lastcommand]);
  349.                       backup(divie[lastcommand]);
  350.                       gprintf(0,"%c",*divie[lastcommand]);
  351.                       goto DirectEntry;
  352.             case 1:
  353.             case 4:
  354.             case '4':
  355.             case '8': if(lastcommand==0) lastcommand=highcommand;
  356.                       else lastcommand--;
  357.                       break;
  358.             case 5:
  359.             case 2:
  360.             case '6':
  361.             case '2': if(lastcommand==highcommand) lastcommand=0;
  362.                       else lastcommand++;
  363.                       break;
  364.             case 11:
  365.             case 27:  printm("\n");
  366.                       say_prompt(178);
  367.                       readfile("BullHelp.XBS",1,1,1);
  368.                       printm("\n");
  369.                       goto FancyReDo;
  370.             case 3:   printm("\n");
  371.                       goto FancyReDo;
  372.             default:  backup(divie[wascommand]);
  373.                       gprintf(0,"%c",toupper(command));
  374.                       goto DirectEntry;
  375.         }
  376.         backup(divie[wascommand]);
  377.         goto FancyRepeat;
  378.     }
  379. DirectEntry:
  380.     if(command)comval=-1;
  381.     else comval=0;
  382.     if(comval) {
  383.         for(x=0;x<42;x++) {
  384.             if(!comstring[x])break;
  385.             if(command==comstring[x]) {
  386.                 comval=(int)x+1;
  387.                 break;
  388.             }
  389.         }
  390.     }
  391.     switch (comval) {
  392.  
  393.         case '*':   readfile("BullXTRA.XBS",0,0,1);
  394.                     break;
  395.         case 0:     break;
  396.         case 1:
  397.         case 2:   say_prompt(178);
  398.                     readfile("BullHelp.XBS",1,1,1);
  399.                     break;
  400.         case 3:   say_prompt(179);
  401.                     goto SkipTheAsk;
  402.         case 4:   x=areano;
  403.                     do {
  404.                         x++;
  405.                     } while (!find_area(x,2) && x<(higharea+1));
  406.                     if (x>higharea) continue;
  407.                     else {
  408.                         areano=x;
  409.                         goto GotArea;
  410.                     }
  411.         case 5:   x=areano;
  412.                     do {
  413.                         x--;
  414.                     } while (!find_area(x,2) && x);
  415.                     if (!x) continue;
  416.                     else {
  417.                         areano=x;
  418.                         goto GotArea;
  419.                     }
  420.         case 6:   if(user.cold) goto ColdJump;
  421.                     helpnum=561;
  422.                     strcpy(string,genin(48,0,1,0,SUBJECT));
  423.                     helpnum=0;
  424.                     if(!(word)atol(string) && *string) {
  425.  
  426.                         for(x=0;x<maxareas;x++) {
  427.                             if(!stricmp(marea[x].name,string)) {
  428.                                 areano=marea[x].number;
  429.                                 break;
  430.                             }
  431.                         }
  432.                     }
  433.                     else areano=(word)atol(string);
  434. SkipTheAsk:
  435.                     if (!areano || command==comstring[2]) {
  436.                       sprintf(filename,"%sBULLS\\BOARDLST.XBS",conf.menupath,areano);
  437.                       if (!findfirst(filename,&filestat,0)) {
  438.                         readfile(filename,1,1,1);
  439.                       }
  440.                       else {
  441.                         neworold=0;
  442.                         temparea=areano=mboard.number;
  443.                         for (x=1;x<(higharea+1);x++) {
  444.                             if (find_area(x,1)) {
  445.                                 neworold++;
  446.                                 if (user.width<65) neworold++;
  447.                                 if (mboard.attr & ANSI) say_prompt(288);
  448.                                 if ((mboard.attr & ECHO) || (mboard.attr & ALTECHO)) say_prompt(289);
  449.                                 if (mboard.attr & NET) say_prompt(290);
  450.                                 if (mboard.attr & ALTERNATE) say_prompt(336);
  451.                                 if (mboard.attr & MCI) say_prompt(291);
  452.                             }
  453.                             if (!user.more && ((char)neworold>=(user.length-1))) {
  454.                                 say_prompt(23);
  455.                                 if (*genin(1,0,1,1,YESNOM)=='N') {
  456.                                      say_prompt(399);
  457.                                      break;
  458.                                 }
  459.                                 say_prompt(399);
  460.                                 neworold=0;
  461.                             }
  462.                         }
  463.                       }
  464.                         if (command==comstring[2]) {
  465.                             find_area(areano,0);
  466.                             if (neworold>(user.length-4)) hitreturn();
  467.                             printm("\n");
  468.                             break;
  469.                         }
  470. ColdJump:
  471.                         if(command==comstring[2]) break;
  472.                         say_prompt(21);
  473.                         helpnum=562;
  474.                         strcpy(string,genin(48,0,1,0,SUBJECT));
  475.                         helpnum=0;
  476.                         if(!(word)atol(string)) {
  477.  
  478.                             for(x=0;x<maxareas;x++) {
  479.                                 if(!stricmp(marea[x].name,string)) {
  480.                                     areano=marea[x].number;
  481.                                     break;
  482.                                 }
  483.                             }
  484.                         }
  485.                         else areano=(word)atol(string);
  486.                     }
  487.                     if (areano<1 || areano>4096) areano=temparea;
  488. GotArea:
  489.                     find_area(areano,0);
  490.                     if (!deja_vu[areano-1]) {
  491.                         sprintf(filename,"%sBULLS\\INTRO.%03x",conf.menupath,areano);
  492.                         if (!findfirst(filename,&filestat,0)) readfile(filename,0,0,1);
  493.                         if (areano<(conf.nolmrs+1) && lastread[areano-1]==0) {
  494.                             sprintf(filename,"%sBULLS\\RULES.%03x",conf.menupath,areano);
  495.                             if (!findfirst(filename,&filestat,0)) readtext(filename);
  496.                         }
  497.                     }
  498.                     deja_vu[areano-1]=1;
  499.                     break;
  500.         case 7:   say_prompt(180);
  501.                     readamessage(0,0);
  502.                     break;
  503.         case 8:   say_prompt(181);
  504.                     if(user.stat[0]<mboard.minwrite) {
  505.                         say_prompt(591);
  506.                         break;
  507.                     }
  508.                     safe=0;
  509.                     *assocfile=0;
  510.                     if (!(level=(word)askwrite(0))) {
  511.                         if (!(level=(word)writemessage(0))) {
  512.                             level=(word)makemessage(0);
  513.                         }
  514.                     }
  515.                     safe=1;
  516.                     break;
  517.         case 9:   say_prompt(182);
  518.                     readamessage(128,0);
  519.                     break;
  520.         case 10:   say_prompt(260);
  521.                     if (*genin(1,0,1,1,YESNO)!='N') {
  522.                         printm("\n");
  523.                         areano=mboard.number;
  524.                         for (x=areano;x<(higharea+1);x++) {
  525.                             if (inkey()==' ' || toupper(inkey())=='S') break;
  526.                             if (find_area(x,1)) {
  527.                                 if(!doprompting && x<(conf.nolmrs+1)) readamessage(2,0);
  528.                                 else readamessage(2,lastread[x-1]+1);
  529.                             }
  530.                         }
  531.                         find_area(areano,0);
  532.                         printm("\n");
  533.                     }
  534.                     else {
  535.                         printm("\n");
  536.                         readamessage(1,0);
  537.                     }
  538.                     break;
  539.         case 11:   say_prompt(184);
  540.                     if (marea) ffree(marea);
  541.                     marea=NULL;
  542.                     maxareas=0;
  543.                     memcpy(&fboard,&holdboard,sizeof(struct _fboard));
  544.                     memcpy(&mboard,&holdmboard,sizeof(struct _mboard));
  545.                     return;
  546.         case 12:   say_prompt(185);
  547.                     readamessage(4,0);
  548.                     break;
  549.         case 13:   if (!(uploads & 2)) break;
  550.                    say_prompt(425);
  551.                    say_prompt(589);
  552.                    if(*genin(1,0,1,1,ALPHA)=='F') {
  553.                         if(user.pointid==0) {
  554.                             say_prompt(586);
  555.                             break;
  556.                         }
  557.                         useftn=1;
  558.                         counter++;
  559.                    }
  560.                    else useftn=0;
  561.                    if (exported!=0 && !useftn) {
  562.                         if (nodenumber!=1) sprintf(string,"%sXPORT%hu\\*.MAL",conf.homepath,nodenumber);
  563.                         else sprintf(string,"%sXPORT\\*.MAL",conf.homepath);
  564.                         if (!findfirst(string,&filestat,0)) {
  565.                             say_prompt(384);
  566.                             if (*genin(1,0,1,1,YESNO)!='N') goto DoMailPacketDL;
  567.                         }
  568.                         say_prompt(355);
  569.                         if (*genin(1,0,1,1,YESNO)!='Y') break;
  570.                         exported=0;
  571.                    }
  572.                    if(!useftn) {
  573.                         if (nodenumber!=1) sprintf(string,"%sXPORT%hu\\*.*",conf.homepath,nodenumber);
  574.                         else sprintf(string,"%sXPORT\\*.*",conf.homepath);
  575.                         if (!findfirst(string,&filestat,0)) {
  576.                             if (nodenumber!=1) sprintf(string,"%sXPORT%hu\\%s",conf.homepath,nodenumber,filestat.ff_name);
  577.                             else sprintf(string,"%sXPORT\\%s",conf.homepath,filestat.ff_name);
  578.                             unlink(string);
  579.                             while (!findnext(&filestat)) {
  580.                                 if (nodenumber!=1) sprintf(string,"%sXPORT%hu\\%s",conf.homepath,nodenumber,filestat.ff_name);
  581.                                 else sprintf(string,"%sXPORT\\%s",conf.homepath,filestat.ff_name);
  582.                                 unlink(string);
  583.                             }
  584.                         }
  585.                         if(!doprompting) {
  586.                             say_prompt(266);
  587.                             if (*genin(1,0,1,1,YESNO)=='Y') selecting=1;
  588.                             else selecting=0;
  589.                         }
  590.                         else selecting=0;
  591.                         tempbaud=baud;
  592.                         if (!baud) tempbaud=1200;
  593.                         maxexportsize=(long)((((long)tempbaud)*(((long)timelimit-(getxbbstime()/60L))*60L)))/11L;
  594.                         sprintf(string,say_prompt(373),maxexportsize);
  595.                    }
  596.                    else selecting=0;
  597.                    exporting=1;
  598.         case 14:
  599.         case 15:   if ((command==comstring[14] || command==comstring[13]) && !useftn) {
  600.                         if(command==comstring[14]) {
  601.                             if(!doprompting)say_prompt(24);
  602.                             selecting=0;
  603.                         }
  604.                         else if (command==comstring[13]) {
  605.                             if(!doprompting)say_prompt(183);
  606.                             selecting=1;
  607.                         }
  608.                         exporting=0;
  609.                         *string=0;
  610.                     }
  611.                     if(!doprompting && !useftn) {
  612.                         if(command==comstring[12]) say_prompt(353);
  613.                         if (*genin(1,0,1,1,YESNO)!='N') neworold=2;
  614.                         else neworold=1;
  615.                     }
  616.                     else neworold=2;
  617.                     printm("\n");
  618.                     printm(string);
  619.                     areano=mboard.number;
  620.                     for (x=areano;x<(higharea+1);x++) {
  621.                         if (inkey()==' ' || toupper(inkey())=='S') break;
  622.                         temp=find_area(x,1);
  623.                         if(!temp) continue;
  624.                         if (temp==neworold || neworold==1) {
  625.                             sprintf(filename,"%sXDATA.%03x",messpath,x);
  626.                             if (findfirst(filename,&filestat,0)) filestat.ff_fsize=0;
  627.                             if (!filestat.ff_fsize) continue;
  628.                             if(x<(conf.nolmrs+1) && lastread[x-1]>(word)(filestat.ff_fsize/(long)sizeof(struct _xmsg))) lastread[x-1]=(word)(filestat.ff_fsize/(long)sizeof(struct _xmsg));
  629.                             if(!doprompting) {
  630.                                 if (exporting) say_prompt(372);
  631.                                 else say_prompt(292);
  632.                                 helpnum=563;
  633.                                 command=*genin(1,0,1,1,ALPHA);
  634.                                 helpnum=0;
  635.                             }
  636.                             else command=0;     /* Default */
  637.                             if (command=='S') continue;
  638.                             if (command=='A') break;
  639.                             if (command=='I') {
  640.                                 if(x<(conf.nolmrs+1)) lastread[x-1]=(word)(filestat.ff_fsize/(long)sizeof(struct _xmsg));
  641.                                 continue;
  642.                             }
  643.                             if (!deja_vu[x-1] && !doprompting) {
  644.                                 sprintf(filename,"%sBULLS\\INTRO.%03x",conf.menupath,x);
  645.                                 if (!findfirst(filename,&filestat,0)) readfile(filename,0,0,1);
  646.                                 if (x<(conf.nolmrs+1) && lastread[x-1]==0) {
  647.                                     sprintf(filename,"%sBULLS\\RULES.%03x",conf.menupath,x);
  648.                                     if (!findfirst(filename,&filestat,0)) readtext(filename);
  649.                                 }
  650.                                 deja_vu[x-1]=1;
  651.                             }
  652.                             temp=0;
  653.                             if(doprompting && x<(conf.nolmrs+1)) {
  654.                                     if(inkey()==' ') break;
  655.                                     if (lastread[x-1]>=(filestat.ff_fsize/(long)sizeof(struct _xmsg))) continue;
  656.                                     if (lastread[x-1]!=0) {
  657.                                         if(!useftn) {
  658.                                             temp=readamessage((64 * exporting),lastread[x-1]+1);
  659.                                         }
  660.                                         else export_mail(mboard.number,lastread[x-1]+1);
  661.                                     }
  662.                                     else {
  663.                                         if(useftn) export_mail(mboard.number,0);
  664.                                         else temp=readamessage((64 * exporting),1);
  665.                                     }
  666.                             }
  667.                             else {
  668.                                 if(useftn) export_mail(mboard.number,lastread[x-1]+1);
  669.                                 else temp=readamessage((64 * (exporting))+((16 * (selecting))),0);
  670.                             }
  671.                             if (temp) {
  672.                                 if (exporting && !useftn) {
  673.                                     if (nodenumber!=1) sprintf(string,"%sXPORT%hu\\MSGAREAS.XBS",conf.homepath,nodenumber);
  674.                                     else sprintf(string,"%sXPORT\\MSGAREAS.XBS",conf.homepath);
  675.                                     if(findfirst(string,&filestat,0)) {
  676.  
  677.                                         word xx;
  678.  
  679.                                         if ((fp=oopen(string,O_RDWR | O_TEXT | O_APPEND | O_DENYNONE))==-1)
  680.                                             if((fp=ccreat(string,S_IWRITE))==-1) {
  681.                                                 say_prompt(354);
  682.                                                 break;
  683.                                             }
  684.                                         ffprintf(fp,"%u:%u/%u\r\n",conf.zone,conf.net,conf.node);
  685.                                         ffprintf(fp,"%s\r\n",conf.system);
  686.                                         ffprintf(fp,"%s\r\n",say_prompt(358));
  687.                                         ffprintf(fp,"%s\r\n",say_prompt(359));
  688.                                         ffprintf(fp,"%s\r\n",say_prompt(360));
  689.                                         for (xx=0;xx<maxareas;xx++) {
  690.                                             ffprintf(fp,"%s,%u,%u,%u,%u,%u",marea[xx].name,marea[xx].attr,marea[xx].max,marea[xx].number,marea[xx].substat1,marea[xx].substat2);
  691.                                             if(marea[xx].forceto && *marea[xx].forceto) ffprintf(fp,",%s",marea[xx].forceto);
  692.                                                 ffprintf(fp,"\r\n");
  693.                                             }
  694.                                             exported=1;
  695.                                             cclose(fp);
  696.                                         }
  697.                                         if (nodenumber!=1) sprintf(string,"%sXPORT%hu\\MSGAREAS.XBS",conf.homepath,nodenumber);
  698.                                         else sprintf(string,"%sXPORT\\MSGAREAS.XBS",conf.homepath);
  699.                                         if (!findfirst(string,&filestat,0)) total=filestat.ff_fsize;
  700.                                         if (nodenumber!=1) sprintf(string,"%sXPORT%hu\\X*.*",conf.homepath,nodenumber);
  701.                                         else sprintf(string,"%sXPORT\\X*.*",conf.homepath);
  702.                                         if (!findfirst(string,&filestat,0)) {
  703.                                             total+=filestat.ff_fsize;
  704.                                             while (!findnext(&filestat)) {
  705.                                                 total+=filestat.ff_fsize;
  706.                                             }
  707.                                         }
  708.                                         gprintf(0,say_prompt(378),total);
  709.                                         if (total>=maxexportsize) {
  710.                                             say_prompt(379);
  711.                                             break;
  712.                                         }
  713.                                     }
  714.                                     else if (useftn) {
  715.                                         if (nodenumber!=1) sprintf(string,"%sXPORT%hu\\*.PKT",conf.homepath,nodenumber);
  716.                                         else sprintf(string,"%sXPORT\\*.PKT",conf.homepath);
  717.                                         if (!findfirst(string,&filestat,0)) {
  718.                                            gprintf(0,say_prompt(378),filestat.ff_fsize);
  719.                                         }
  720.                                     }
  721.                                 }
  722.                         }
  723.                     }
  724.                     if(useftn) goto DoMailPacketDL;
  725.                     if (exporting && exported) {
  726.                         if(!useftn) {
  727.                             say_prompt(374);
  728.                             if (nodenumber!=1) sprintf(string,"%sXPORT%hu\\MSGAREAS.XBS",conf.homepath,nodenumber);
  729.                             else sprintf(string,"%sXPORT\\MSGAREAS.XBS",conf.homepath);
  730.                             if ((fp=oopen(string,O_RDONLY | O_TEXT | O_DENYNONE))!=-1) {
  731.  
  732.                                 struct ftime t;
  733.                                 struct date dos_date;
  734.  
  735.                                 t.ft_tsec=0;
  736.                                 t.ft_min=0;
  737.                                 t.ft_hour=0;
  738.                                 getdate(&dos_date);
  739.                                 t.ft_day=(unsigned) dos_date.da_day;
  740.                                 t.ft_month=(unsigned) dos_date.da_mon;
  741.                                 t.ft_year=(unsigned) (dos_date.da_year-1980);
  742.  
  743.                                 setftime(fp,&t);
  744.                                 cclose(fp);
  745.                             }
  746.                             if (nodenumber!=1) sprintf(string,"%hu",nodenumber);
  747.                             else *string=0;
  748.                             sprintf(filename,say_prompt(356),string,conf.net,conf.node,string);
  749.                             spawnit(filename,0,0);
  750.                             sprintf(filename,say_prompt(361),string,conf.net,conf.node,string);
  751.                             spawnit(filename,0,0);
  752.                             sprintf(filename,"XPORT%s\\%04x%04x.MAL",string,conf.net,conf.node);
  753.                             unlink(filename);
  754.                             if (nodenumber!=1) sprintf(string,"%sXPORT%hu\\%04x%04x.EXE",conf.homepath,nodenumber,conf.net,conf.node);
  755.                             else sprintf(string,"%sXPORT\\%04x%04x.EXE",conf.homepath,conf.net,conf.node);
  756.                             rename(string,filename);
  757.                             if (nodenumber!=1) sprintf(string,"%sXPORT%hu\\MSGAREAS.XBS",conf.homepath,nodenumber);
  758.                             else sprintf(string,"%sXPORT\\MSGAREAS.XBS",conf.homepath);
  759.                             unlink(string);
  760.                             if (nodenumber!=1) sprintf(string,"%sXPORT%hu\\X*.*",conf.homepath,nodenumber);
  761.                             else sprintf(string,"%sXPORT\\X*.*",conf.homepath);
  762.                             if (!findfirst(string,&filestat,0)) {
  763.                                 if (nodenumber!=1) sprintf(string,"%sXPORT%hu\\%s",nodenumber,filestat.ff_name);
  764.                                 else sprintf(string,"%sXPORT\\%s",conf.homepath,filestat.ff_name);
  765.                                 unlink(string);
  766.                                 while (!findnext(&filestat)) {
  767.                                     if (nodenumber!=1) sprintf(string,"%sXPORT%hu\\%s",conf.homepath,nodenumber,filestat.ff_name);
  768.                                     else sprintf(string,"%sXPORT\\%s",conf.homepath,filestat.ff_name);
  769.                                     unlink(string);
  770.                                 }
  771.                             }
  772.                         }
  773. DoMailPacketDL:
  774.                         if(!useftn) sprintf(filename,"%04x%04x.MAL",conf.net,conf.node);
  775.                         else {
  776.                             if(nodenumber!=1) sprintf(filename,"%sXPORT%hu\\%04x%04x.PKT",conf.homepath,nodenumber,conf.net,conf.node);
  777.                             else sprintf(filename,"%sXPORT\\%04x%04x.PKT",conf.homepath,conf.net,conf.node);
  778.                             if(findfirst(filename,&filestat,0)) goto NoPacket;
  779.                             if(nodenumber!=1) {
  780.                                 sprintf(filename,"%s%sXPORT%hu\\00000000.MO%hu %sXPORT%hu\\%04x%04x.PKT",say_prompt(594),conf.homepath,nodenumber,counter,conf.homepath,nodenumber,conf.net,conf.node);
  781.                             }
  782.                             else {
  783.                                 sprintf(filename,"%s%sXPORT\\00000000.MO%hu %sXPORT\\%04x%04x.PKT",say_prompt(594),conf.homepath,counter,conf.homepath,conf.net,conf.node);
  784.                             }
  785.                             gprintf(0,say_prompt(378),filestat.ff_fsize);
  786.                             say_prompt(374);
  787.                             spawnit(filename,0,0);
  788.                             sprintf(filename,"00000000.*");
  789.                         }
  790.                         if(nodenumber!=1) {
  791.                             sprintf(fboard.dpath,"%sXPORT%hu\\",conf.homepath,nodenumber);
  792.                             sprintf(fboard.upath,"%sMPORT%hu\\",conf.homepath,nodenumber);
  793.                         }
  794.                         else {
  795.                             sprintf(fboard.dpath,"%sXPORT\\",conf.homepath);
  796.                             sprintf(fboard.upath,"%sMPORT\\",conf.homepath);
  797.                         }
  798.                         fboard.flags=7;
  799.                         strcpy(fboard.name,"XPORT");
  800.                         if (!askdl(filename,128,NULL,0)) {
  801.                             say_prompt(381);
  802.                             if (*genin(1,0,1,1,YESNO)!='N') {
  803.                                 if (!askdl(filename,128,NULL,0)) {
  804.                                     say_prompt(382);
  805.                                     if (*genin(1,0,1,1,YESNO)!='N') {
  806.                                         if (!askdl(filename,128,NULL,0)) say_prompt(383);
  807.                                     }
  808.                                 }
  809.                             }
  810.                         }
  811.                     }
  812. NoPacket:
  813.                     find_area(areano,0);
  814.                     printm("\n");
  815.                     break;
  816.         case 16:   say_prompt(186);
  817.                     sprintf(filename,"%sBULLS\\RULES.%03x",conf.menupath,areano);
  818.                     if (!findfirst(filename,&filestat,0)) readtext(filename);
  819.                     else say_prompt(25);
  820.                     break;
  821.         case 17:   if ((uploads & 1) || (uploads & 2)) {
  822.                         if ((uploads & 2) && (uploads & 1)) {
  823.                             say_prompt(375);
  824.                             helpnum=564;
  825.                             if (*genin(1,0,1,1,ALPHA)=='R') {
  826.                                 helpnum=0;
  827.                                 if(nodenumber!=1) {
  828.                                     sprintf(fboard.dpath,"%sXPORT%hu\\",conf.homepath,nodenumber);
  829.                                     sprintf(fboard.upath,"%sMPORT%hu\\",conf.homepath,nodenumber);
  830.                                 }
  831.                                 else {
  832.                                     sprintf(fboard.dpath,"%sXPORT\\",conf.homepath);
  833.                                     sprintf(fboard.upath,"%sMPORT\\",conf.homepath);
  834.                                 }
  835.                                 fboard.flags=7;
  836.                                 strcpy(fboard.name,"MPORT");
  837.                                 say_prompt(589);
  838.                                 if(*genin(1,0,1,1,ALPHA)!='F') {
  839.                                     sprintf(filename,"%04x%04x.RPK",conf.net,conf.node);
  840.                                     upload(filename,0);
  841.                                 }
  842.                                 else {
  843.                                     if(!user.pointid) {
  844.                                         gprintf(0,say_prompt(586),conf.sysop);
  845.                                     }
  846.                                     else {
  847.                                         sprintf(filename,"*.MO?");
  848.                                         upload(filename,0);
  849.                                     }
  850.                                 }
  851.                                 break;
  852.                             }
  853.                             helpnum=0;
  854.                             printm("\n");
  855.                         }
  856.                         else if (uploads & 2) {
  857.                             say_prompt(376);
  858.                             sprintf(fboard.dpath,"%sXPORT\\",conf.homepath);
  859.                             sprintf(fboard.upath,"%sMPORT\\",conf.homepath);
  860.                             fboard.flags=7;
  861.                             strcpy(fboard.name,"MPORT");
  862.                             say_prompt(589);
  863.                             if(*genin(1,0,1,1,ALPHA)!='F') {
  864.                                 sprintf(filename,"%04x%04x.RPK",conf.net,conf.node);
  865.                                 upload(filename,0);
  866.                             }
  867.                             else {
  868.                                 if(!user.pointid) {
  869.                                     gprintf(0,say_prompt(586),conf.sysop);
  870.                                 }
  871.                                 else {
  872.                                     sprintf(filename,"*.MO?");
  873.                                     upload(filename,0);
  874.                                 }
  875.                             }
  876.                             break;
  877.                         }
  878.                         else say_prompt(187);
  879.                         if(user.stat[0]<mboard.minwrite) {
  880.                             say_prompt(591);
  881.                             break;
  882.                         }
  883.                         safe=0;
  884.                         *assocfile=0;
  885.                         if (!(level=(word)askwrite(0))) {
  886.                             if (!(level=(word)writemessage(4))) {
  887.                                 level=(word)makemessage(0);
  888.                             }
  889.                         }
  890.                         safe=1;
  891.                         break;
  892.                     }
  893.         case 18:    say_prompt(471);
  894.                     doprompting=1-doprompting;
  895.                     (doprompting) ? say_prompt(472) : say_prompt(474);
  896.                     break;
  897.         default:    sprintf(filename,"BULLS%03u.XBS",comval);
  898.                     readfile(filename,1,1,1);
  899.                     printm("\n");
  900.                     break;
  901.     }
  902.   }
  903. }
  904.  
  905.  
  906.  
  907. word pascal readamessage (char type,word messno) {
  908.                     /* Type=0.....Read messages public & private
  909.                        Type=1.....Read personal mail
  910.                        Type=2.....Quiet check for personal mess
  911.                        Type=4.....Read non-stop
  912.                        Type=8.....Selected read use what's there
  913.                        Type=16....Selected read
  914.                        Type=32....Associated search
  915.                        Type=64....Export
  916.                        Type=128...Scan
  917.                        Extremely large, ugly function, but it works
  918.                      */
  919.  
  920.  static char comstring[40]="";
  921.  int comval;
  922.  char qstring[6];
  923.  char text[124];
  924.  char textarc[127];
  925.  char filearc[127];
  926.  static char p294[41]="";
  927.  static char p295[24];
  928.  static char p296[24];
  929.  static char p297[24];
  930.  static char p298[24];
  931.  static char p370[24];
  932.  static char p380[24];
  933.  static char p349[24];
  934.  static char p466[24];
  935.  int  ta=0;
  936.  int  fa=0;
  937.  int  pp=0;
  938.  word threadstart=0;
  939.  word nomess;
  940.  word temp;
  941.  char ctla=0;
  942.  char message[81];
  943.  char nextkey;
  944.  char sub=0;
  945.  word lastmess=0;
  946.  char *hold=NULL;
  947.  char *tempo;
  948.  char *p;
  949.  char * pos[51];
  950.  char page;
  951.  register word x;
  952.  word exported=0;
  953.  char lastmsgid[80]="";
  954.  char lastreply[80]="";
  955.  char matchany=0;
  956.  char scanflag=0;
  957.  char wasone=0;
  958.  char tweenavail=0;
  959.  
  960.  *msginfo=0;
  961.  if (!*p294) {
  962.     strcpy(p294,say_prompt(294));
  963.     strcpy(p295,say_prompt(295));
  964.     strcpy(p296,say_prompt(296));
  965.     strcpy(p297,say_prompt(297));
  966.     strcpy(p298,say_prompt(298));
  967.     strcpy(p370,say_prompt(370));
  968.     strcpy(p380,say_prompt(380));
  969.     strcpy(p349,say_prompt(349));
  970.     strcpy(p466,say_prompt(466));
  971.  }
  972.  if(!*comstring) {
  973.     strncpy(comstring,say_prompt(434),40);
  974.  }
  975.  nextkey=comstring[3];
  976.  
  977.  sprintf(filearc,"%sTWEENMSG.XBS",conf.messpath);
  978.  if(!findfirst(filearc,&filestat,0)) tweenavail=1;
  979.  *filearc=0;
  980.  
  981.  if (type & 64) {
  982.     if (nodenumber==1) {
  983.         sprintf(filearc,"%sXPORT\\XDATA.%03x",conf.homepath,mboard.number);
  984.         sprintf(textarc,"%sXPORT\\XTEXT.%03x",conf.homepath,mboard.number);
  985.     }
  986.     else {
  987.         sprintf(filearc,"%sXPORT%hu\\XDATA.%03x",conf.homepath,nodenumber,mboard.number);
  988.         sprintf(textarc,"%sXPORT%hu\\XTEXT.%03x",conf.homepath,nodenumber,mboard.number);
  989.     }
  990.  }
  991.  if (mboard.number<(conf.nolmrs+1)) lastmess=lastread[mboard.number-1];
  992.  
  993.  
  994. DoNumber:
  995.  
  996.  sprintf(buffer,"%sXDATA.%03x",messpath,mboard.number);
  997.  if (findfirst(buffer,&filestat,0)) {
  998.   if (!(type & 2)) say_prompt(26);
  999.   return(0);
  1000.  }
  1001.  threadstart=0;
  1002.  if (!(type & 2)) {
  1003.    printm("\n");
  1004.    gprintf(0,say_prompt(27),mboard.number,mboard.name);
  1005.  }
  1006.  nomess=(word)((filestat.ff_fsize/(long)sizeof(struct _xmsg)));
  1007.  
  1008.  if (mboard.number<(conf.nolmrs+1) && (!messno || messno>nomess)) {
  1009.     if (lastread[mboard.number-1]>nomess) lastread[mboard.number-1]=nomess;
  1010.     if (type & 2) if (lastread[mboard.number-1]>=nomess) {
  1011.         lastread[mboard.number-1]=nomess;
  1012.         goto SetLast;
  1013.     }
  1014.  }
  1015.  if(messno>nomess) messno=nomess;
  1016.  
  1017.  if (!(type & 2)) {
  1018.    gprintf(0,"%u%s",nomess,say_prompt(29));
  1019.  }
  1020.  if (!(type & 2)) {
  1021.     if (mboard.number<(conf.nolmrs+1)) if ((nomess) && (lastread[mboard.number-1]<nomess)) {
  1022.         gprintf(0,"%s%u)",say_prompt(30),lastread[mboard.number-1]+1);
  1023.     }
  1024.  }
  1025.  if (!messno) {
  1026.   if (!(type & 2)) {
  1027.    if (type & 16) {
  1028.         *msgto=*msgsubj=*msgbody=*msgfrom=0;
  1029.         say_prompt(31);
  1030.         say_prompt(34);
  1031.         helpnum=565;
  1032.         strcpy(msgfrom,genin(36,0,0,0,NEAT));
  1033.         say_prompt(35);
  1034.         helpnum=566;
  1035.         strcpy(msgto,genin(36,0,0,0,NEAT));
  1036.         say_prompt(36);
  1037.         helpnum=567;
  1038.         strcpy(msgsubj,genin(64,0,0,0,SUBJECT));
  1039.         say_prompt(37);
  1040.         helpnum=568;
  1041.         strcpy(msgbody,genin(80,0,0,0,ALLL));
  1042.         helpnum=0;
  1043.         say_prompt(93);
  1044.         helpnum=575;
  1045.         if(*genin(1,0,1,1,YESNO)=='Y') matchany=1;
  1046.         else matchany=0;
  1047.         helpnum=0;
  1048.         printm("\n");
  1049.    }
  1050. Scanswitch:
  1051.        if (type & 128) {
  1052.             say_prompt(32);
  1053.        }
  1054.        else if (type & 64) say_prompt(371);
  1055.        else say_prompt(33);
  1056.        say_prompt(261);                 /* From which #? */
  1057.        if(mboard.number<(conf.nolmrs+1))
  1058.          if(lastmess>0 && lastmess<nomess && lastread[mboard.number-1]<nomess)
  1059.             gprintf(0,"[%u] ",lastmess+1); /*  default */
  1060.        helpnum=569;
  1061.        strcpy(text,genin(5,0,0,0,NUM));
  1062.        helpnum=0;
  1063.        messno=(word)atol(text);
  1064.        if ((messno<1) or (messno>nomess)) {
  1065.          if (!messno && strlen(text)) {
  1066.             say_prompt(262);
  1067.             return(0);
  1068.          }
  1069.          else if (mboard.number<(conf.nolmrs+1)) {
  1070.             if (nomess && lastmess<nomess && !strlen(text)) {
  1071.                 gprintf(0,"%u\n",lastmess+1);
  1072.                 messno=lastmess+1;
  1073.             }
  1074.             else {
  1075.                 printm("\n");
  1076.                 goto SetLast;
  1077.             }
  1078.          }
  1079.          else {
  1080.             printm("\n");
  1081.             goto SetLast;
  1082.          }
  1083.      }
  1084.      printm("\n");
  1085.    }
  1086.      else {
  1087.        if (nomess) {
  1088.             if(mboard.number<(conf.nolmrs+1)) {
  1089.                 if (lastread[mboard.number-1]<nomess) messno=lastread[mboard.number-1]+1;
  1090.             }
  1091.             else {
  1092.                 messno=1;
  1093.             }
  1094.        }
  1095.      }
  1096.  }
  1097.  else if(!(type & 2)) printm("\n");
  1098.  
  1099.  if (type & 64) {
  1100.     if ((ta=oopen(textarc,O_RDWR | O_BINARY | O_APPEND | O_DENYNONE))==-1)
  1101.        if((ta=ccreat(textarc,S_IWRITE))==-1) {
  1102.         if (!(type & 2)) say_prompt(351);
  1103.         return (0);
  1104.     }
  1105.     lseek(ta,0L,SEEK_END);
  1106.     if ((fa=oopen(filearc,O_RDWR | O_BINARY | O_APPEND | O_DENYNONE))==-1)
  1107.        if((fa=ccreat(filearc,S_IWRITE))==-1) {
  1108.         if (!(type & 2)) say_prompt(352);
  1109.         cclose(ta);
  1110.         return (0);
  1111.     }
  1112.     lseek(fa,0L,SEEK_END);
  1113.  }
  1114.  if ((type & 16) || (type & 8)) say_prompt(39);
  1115.  goto Readhere;
  1116.  
  1117. Restart:
  1118.  
  1119.  slowprint=0;
  1120.  if(type & 2) {
  1121.     messno=get_abunch (messno,0,1,"");
  1122.     if(!messno) goto SetLast;
  1123.  }
  1124.  if(type & 64) safe=0;
  1125.  sprintf(buffer,"%sXDATA.%03x",messpath,mboard.number);
  1126.  if (!findfirst(buffer,&filestat,0)) {
  1127.      nomess=(word)((filestat.ff_fsize/(long)sizeof(struct _xmsg)));
  1128.  }
  1129.  if (!(type & 32)) *assocfile=0;
  1130.  if (type & 128) messno++;
  1131.  else {
  1132.      if (!(type & 16) && !(type & 64) && !(type & 8) && !(type & 2)) printg("\x1b[0;1;32m");
  1133.      sub=0;
  1134.      if (nextkey=='S') goto SetLast;
  1135.      if (nextkey==comstring[6]) {
  1136.         messno--;
  1137.      }
  1138.      else if (nextkey!=comstring[6]) {
  1139.         if(!(type & 2)) messno++;
  1140.      }
  1141.  }
  1142.  
  1143. Thread:
  1144.  
  1145.  if ((messno>nomess) or (messno<1)) {
  1146.    if (!(type & 2) && !(type & 64)) {
  1147.         if (mboard.attr & ANSI) printg("\x1b[23;1H\x1b[K");
  1148.         say_prompt(40);
  1149.    }
  1150.    if(!(type & 128))if (lastmess>nomess) lastmess=nomess;
  1151.    if((type & 128) && wasone) goto AfterScan;
  1152.    goto SetLast;
  1153.  }
  1154.  
  1155. Readhere:
  1156.  
  1157.  if (get_mess(messno)) goto SetLast;
  1158.  if ((type & 2) || (type & 1)) {
  1159.     if (stricmp(user.name,msg.to) && stricmp(user.handle,msg.to)) {
  1160.         goto Restart;
  1161.     }
  1162.  }
  1163.  if (type & 2) if (msg.attr & MSGREAD) goto Restart;
  1164.  if (msg.m_attr & MSGDELETED) if ((user.stat[0]<mboard.substat1) || (user.stat[1]<mboard.substat2)) {
  1165.     if (!(type & 2) && !(type & 1) && !(type & 128)) lastmess=messno;
  1166.     if (!(type & 2) && !(type & 64) & !(type & 16)) {
  1167.         pauser=2;
  1168.         printg("\x1b[0;1;33m");
  1169.         pauser=1;
  1170.         if (gprintf(0,"#%-5u%s",messno,say_prompt(42))) {
  1171.             if (type & 128) {
  1172.                 safe=1;
  1173.                 if(wasone)goto AfterScan;
  1174.                 else goto SetLast;
  1175.             }
  1176.             else goto SetLast;
  1177.         }
  1178.     }
  1179.     goto Restart;
  1180.  }
  1181.  if (msg.attr & MSGPRIVATE) if (((user.stat[0]<mboard.substat1) || (user.stat[1]<mboard.substat2)) && stricmp(user.name,msg.to) && stricmp(user.handle,msg.to) && stricmp(user.name,msg.from) && stricmp(user.handle,msg.from)) {
  1182.     if (!(type & 2) && !(type & 1) && !(type & 128)) lastmess=messno;
  1183.     if (!(type & 2) && !(type & 64) &&!(type & 16)) {
  1184.         pauser=2;
  1185.         printg("\x1b[0;1;33m");
  1186.         pauser=1;
  1187.         if (gprintf(0,"#%-5u%s",messno,say_prompt(43))) {
  1188.             if (type & 128) {
  1189.                 safe=1;
  1190.                 if(wasone) goto AfterScan;
  1191.                 else goto SetLast;
  1192.             }
  1193.             else goto SetLast;
  1194.         }
  1195.     }
  1196.     goto Restart;
  1197.  }
  1198.  if ((type & 16) || (type & 8) && !(type & 64) && !(type & 2)) {
  1199.  
  1200.     char hit=0;
  1201.     char miss=0;
  1202.  
  1203.     pauser=0;
  1204.     printm(".");
  1205.     if (*msgfrom) {
  1206.         if (stricmp(msg.from,msgfrom)) {
  1207.             if(!matchany) goto Restart;
  1208.             miss++;
  1209.         }
  1210.         else hit++;
  1211.     }
  1212.     if (*msgto) {
  1213.         if (stricmp(msg.to,msgto)) {
  1214.             if(!matchany) goto Restart;
  1215.             miss++;
  1216.         }
  1217.         else hit++;
  1218.     }
  1219.     if (*msgsubj) {
  1220.         if (stristr(msg.subj,msgsubj)==NULL) {
  1221.             if(!matchany) goto Restart;
  1222.             miss++;
  1223.         }
  1224.         else hit++;
  1225.     }
  1226.     if (*msgbody) {
  1227.         hold=get_text(messno);
  1228.         if (hold==NULL) {
  1229.             say_prompt(41);
  1230.             goto Restart;
  1231.         }
  1232.         tempo=stristr(hold,msgbody);
  1233.  
  1234. #ifdef DEBUG
  1235.  
  1236. gprintf("FOUND: %s\n",tempo);
  1237.  
  1238. #endif
  1239.  
  1240.         ffree(hold);
  1241.         if (tempo==NULL) {
  1242.             if(!matchany) goto Restart;
  1243.             miss++;
  1244.         }
  1245.         else hit++;
  1246.     }
  1247.     if((!matchany && miss) || !hit) goto Restart;
  1248.     printm("\n");
  1249.  }
  1250.  if (type & 128) {
  1251.      pauser=2;
  1252.      wasone=1;
  1253.      if ((msg.m_attr & MSGANON)) {
  1254.         sprintf(message,say_prompt(45));
  1255.         message[32]=0;
  1256.      }
  1257.      else {
  1258.         sprintf(message,"%-31.31s",msg.from);
  1259.         message[32]=0;
  1260.      }
  1261.  
  1262.       {
  1263.  
  1264.         char tempstring[80];
  1265.         int tempint;
  1266.  
  1267.          printg("\x1b[0;1;33m");
  1268.          sprintf(tempstring,"#%-5u  To: %-0.30s..",messno,msg.to);
  1269.          tempstring[34]=0;
  1270.          tempint=41-strlen(tempstring);
  1271.          for(x=0;x<tempint;x++) strcat(tempstring,".");
  1272.          printm(tempstring);
  1273.          printg("\x1b[0;1;32m");
  1274.          gprintf(0,"Fm: %s\n",message);
  1275.          msg.subj[63]=0;
  1276.          printg("\x1b[0;1;36m");
  1277.          lines+=2;
  1278.          if (gprintf(0,"      Subj: %s\n",msg.subj)) goto SetLast;
  1279.          nextkey=toupper(inkey());
  1280.          switch (nextkey) {
  1281.             case 'S':
  1282.             case ' ':
  1283.               goto SetLast;
  1284.             case 'P':
  1285.             case 19:
  1286.               pauseit();
  1287.          }
  1288.          nextkey=0;
  1289.          if(lines>(user.length-3)) {
  1290. AfterScan:
  1291.             say_prompt(477);
  1292. ScanAgain:
  1293.             helpnum=478;
  1294.             nextkey=*genin(1,0,1,1,ALPHA);
  1295.             helpnum=0;
  1296.             if(user.graphics) {
  1297.                 fputs("\r",stdout);
  1298.                 if (baud) while (!fossil(TRANSMIT,'\r')) carrchk();
  1299.                 printm("\x1b[K");
  1300.             }
  1301.             else printm("\n");
  1302.             if(nextkey=='A' || nextkey=='S') goto SetLast;
  1303.             if(nextkey=='H') {
  1304.                 say_prompt(478);
  1305.                 goto ScanAgain;
  1306.             }
  1307.             if(nextkey=='R') {
  1308.                 type=type & (~128);
  1309.                 scanflag=1;
  1310.                 nextkey=0;
  1311.                 goto Scanswitch;
  1312.             }
  1313.             if(nextkey=='C' && messno>nomess) goto SetLast;
  1314.             nextkey=0;
  1315.          }
  1316.        }
  1317.        goto Restart;
  1318.  }
  1319.  
  1320.  if (messno>lastmess && !(type & 128)) lastmess=messno;
  1321.  if (!(msg.attr & MSGPRIVATE) || (!stricmp(user.name,msg.to) || !stricmp(user.handle,msg.to))) {
  1322.     if (!stricmp(user.name,msg.to) || !stricmp(user.handle,msg.to)) msg.attr = msg.attr | MSGREAD;
  1323.     msg.times++;
  1324.     put_mess(messno);
  1325.  }
  1326. Over:
  1327.  if (!(type&4) && !(type&64) && !(mboard.attr & ANSI)) cls();
  1328.  if ((mboard.attr & ANSI) && !(type&64)) printm("\x1b[2J");
  1329.  page=0;
  1330.  
  1331.  if (!(type & 64)) {
  1332.     printheader(page,messno,type,nomess);
  1333.     if(!(mboard.attr & ANSI)) printm("\n");
  1334.     lines=7;
  1335.     if (user.graphics) if (!user.scrnclr) if (!user.more) if (type!=4) if (baud==0 || baud>1200) lines=6;
  1336.     if (!(type & 4)) pauser=1;
  1337.  }
  1338.  else {
  1339.     pauser=0;
  1340.     if (!exported) printm("\nExporting...");
  1341.     else printm(".");
  1342.  }
  1343.  
  1344.   hold=get_text(messno);
  1345.   if (hold==NULL) {
  1346.       say_prompt(41);
  1347.       goto SetLast;
  1348.   }
  1349.  
  1350.   if(tempo=strstr(hold,"\01INFO:")) {
  1351.     strncpy(msginfo,&tempo[6],81);
  1352.     msginfo[80]=0;
  1353.     tempo=strchr(msginfo,'\r');
  1354.     if(tempo)*tempo=0;
  1355.     lstrip(msginfo);
  1356.     rstrip(msginfo);
  1357.   }
  1358.   else *msginfo=0;
  1359.   if(!threadstart) {
  1360.       if(tempo=strstr(hold,"\01MSGID:")) {
  1361.         strncpy(lastmsgid,&tempo[7],80);
  1362.         lastmsgid[79]=0;
  1363.         tempo=strchr(lastmsgid,'\r');
  1364.         if(tempo)*tempo=0;
  1365.         lstrip(lastmsgid);
  1366.         rstrip(lastmsgid);
  1367.       }
  1368.       else *lastmsgid=0;
  1369.       if(tempo=strstr(hold,"\01REPLY:")) {
  1370.         strncpy(lastreply,&tempo[7],80);
  1371.         lastreply[79]=0;
  1372.         tempo=strchr(lastreply,'\r');
  1373.         if(tempo)*tempo=0;
  1374.         lstrip(lastreply);
  1375.         rstrip(lastreply);
  1376.       }
  1377.       else *lastreply=0;
  1378.   }
  1379.   strip_seenbys(hold);
  1380.   strip_blanklines(hold);
  1381.   if (type & 64) {
  1382.     msg.start=tell(ta);
  1383.     msg.length=strlen(hold)+1;
  1384.     msg.times=0;
  1385.     msg.attr = msg.attr & (~MSGLOCAL);
  1386.     lseek(fa,0L,SEEK_END);
  1387.     _write(fa,&msg,sizeof(struct _xmsg));
  1388.     _write(ta,hold,strlen(hold));
  1389.     _write(ta,"\0",1);
  1390.     if (hold) ffree(hold);
  1391.     nextkey=comstring[3];
  1392.     exported++;
  1393.     goto Restart;
  1394.   }
  1395.  
  1396.   if (mboard.attr & ANSI) {
  1397.     pauser=0;
  1398.     tempo=hold;
  1399.     while (*tempo) {
  1400.         tempo++;
  1401.         if(*tempo=='\01' && !ctla) {
  1402.             do {
  1403.                 tempo++;
  1404.             }while(*tempo!='\r' && *tempo);
  1405.             if(tempo)tempo++;
  1406.             continue;
  1407.         }
  1408.         if (baud) while (!fossil(TRANSMIT,*tempo)) carrchk();
  1409.         fputc(*tempo,stdout);
  1410.         temp=wherey();
  1411.         if(temp>23) gotoxy(wherex(),23);
  1412.         if(temp<6) gotoxy(wherex(),6);
  1413.         nextkey=toupper(inkey());
  1414.         if (nextkey) if (nextkey=='S' || nextkey==comstring[3] ||
  1415.           nextkey==comstring[6]) {
  1416.             fossil(PURGEOUT,0);
  1417.             goto StopIt;
  1418.         }
  1419.     }
  1420.     nextkey=0;
  1421.     goto StopIt;
  1422.   }
  1423.   if ((tempo=strstr(hold,"\01ASSOC: ")) && (mboard.attr & ASSOC) && (fboard.flags & FILEASSOC)) {
  1424.  
  1425.       long filelen;
  1426.       word temp;
  1427.       struct fdate {
  1428.          bit day:   5;
  1429.          bit month: 4;
  1430.          bit year:  7;
  1431.       };
  1432.       union df {
  1433.          struct fdate fd;
  1434.          int x;
  1435.       } fdf;
  1436.  
  1437.       tempo+=8;
  1438.       x=0;
  1439.       while (x<133 && tempo[x] && tempo[x]!='\r' && tempo[x]!=' ') {
  1440.         assocfile[x]=tempo[x];
  1441.         x++;
  1442.       }
  1443.       assocfile[x]=0;
  1444.       if(strchr(assocfile,'\\') || strchr(assocfile,':')) strcpy(buffer,assocfile);
  1445.       else sprintf(buffer,"%s%s",fboard.dpath,assocfile);
  1446.       temp = findfirst(buffer,&filestat,0);
  1447.       if(!temp) {
  1448.         if(strchr(assocfile,'\\') || strchr(assocfile,':')) *buffer=0;
  1449.         else strcpy(buffer,fboard.dpath);
  1450.       }
  1451.       else {
  1452.           sprintf(buffer,"%s%s",fboard.upath,assocfile);
  1453.           temp=findfirst(buffer,&filestat,0);
  1454.           if (!temp) strcpy(buffer,fboard.upath);
  1455.           else *buffer=0;
  1456.       }
  1457.       if (!temp) {
  1458.          strcat(buffer,assocfile);
  1459.          temp=baud;
  1460.          if (temp==0) temp=1200;
  1461.          filelen=(long)((((filestat.ff_fsize)/temp)*1000)/80);
  1462.          fdf.x=filestat.ff_fdate;
  1463.          printg("\x1b[0;1;33m");
  1464.          gprintf(0,"%-12s (%lu bytes) %02u/%02u/%02u  %d mins %d secs @ %u baud\n",filestat.ff_name,filestat.ff_fsize,fdf.fd.month,fdf.fd.day,fdf.fd.year+80,(int)filelen/60,(int)filelen%60,temp);
  1465.          printg("\x1b[0;1;32m");
  1466.       }
  1467.   }
  1468.   else *assocfile=0;
  1469.  
  1470.   if(*assocfile || *msginfo) readfile("BETWEEN.XBS",0,0,1);
  1471.   else if(tweenavail) {
  1472.         readfile("TWEENMSG.XBS",0,0,1);
  1473.   }
  1474.  
  1475.   page=0;
  1476.   for(x=1;x<50;x++) pos[x]=NULL;
  1477.   pos[0]=tempo=p=hold;
  1478.   while (*p) {
  1479.       strcpy(message,write_line(&p,user.width,ctla));
  1480.       strcat(message,"\n");
  1481.       tempo=message;
  1482.       if (mboard.attr & MCI) {
  1483.         if (strchr(tempo,'^')) {
  1484.             tempo=mci(tempo);
  1485.             if (strlen(tempo)>user.width+1) {
  1486.                 lines+=strlen(tempo)/user.width;
  1487.             }
  1488.         }
  1489.         fast=0;
  1490.       }
  1491.       else fast=1;
  1492.       if (printm(tempo)) {
  1493.          nextkey='S';
  1494.          goto Shutdown;
  1495.       }
  1496.       nextkey=toupper(inkey());
  1497. Shutdown:
  1498.       slowprint=0;
  1499.       switch (nextkey) {
  1500.          case 0:  break;
  1501.          case 'S':
  1502.          case 'N':
  1503.          case '-':
  1504.          case ' ':
  1505.           fossil(PURGEOUT,0);
  1506.           goto StopIt;
  1507.          case 'P':
  1508.          case 19:
  1509.           pauseit();
  1510.           nextkey=0;
  1511.       }
  1512.       if (user.graphics) if (!user.scrnclr) if (!user.more) if (type!=4) if (!baud || baud>1200) if (lines>(user.length-3)+((mboard.attr & MCI)!=0)) {
  1513.         if(!*p) break;
  1514.         pauser=0;
  1515.         lprint("\x1b[23;1H");
  1516.         if (baud) while (!fossil(TRANSMIT,'\r')) carrchk();
  1517.         say_prompt(293);
  1518.         if (page || pos[page+1]) printheader(page,messno,type,nomess);
  1519.         printm("\x1b[u");
  1520.         fossil(FLUSHOUT,0);
  1521.         fossil(PURGEIN,0);
  1522.         pos[page+1]=p;
  1523. Getitagain:
  1524.         keymess=messno;
  1525.         helpnum=570;
  1526.         nextkey=*genin(1,0,1,1,ALPHA+128);
  1527.         helpnum=0;
  1528.         switch (nextkey) {
  1529.             case 'S':   nextkey=0;
  1530.                         fputs("\r",stdout);
  1531.                         if (baud) while (fossil(TRANSMIT,'\r')==0) carrchk();
  1532.                         goto StopIt;
  1533.             case 'N':
  1534.             case 0:     nextkey='N';
  1535.                         if (++page>49) page=1;
  1536.                         pos[page]=p;
  1537.                         break;
  1538.             case 'O':    p=pos[page];
  1539.                         break;
  1540.             case 'P':
  1541.             case '-':   if (!page) goto StopIt;
  1542.                         p=pos[--page];
  1543.                         break;
  1544.             default:    printm(BACKSPACE);
  1545.                         goto Getitagain;
  1546.         }
  1547.         fputs("\r",stdout);
  1548.         if (baud) while (!fossil(TRANSMIT,'\r')) carrchk();
  1549.         printm("\x1b[K\x1b[0;1;32m");
  1550.         pauser=1;
  1551.         lines=6;
  1552.       }
  1553.     }
  1554.  
  1555. StopIt:
  1556.  
  1557.  if (hold!=NULL) ffree(hold);
  1558.  pauser=0;
  1559.  
  1560. Aborted:
  1561.  
  1562.     slowprint=0;
  1563.     if(nextkey)comval=-1;
  1564.     else comval=0;
  1565.     if(comval) {
  1566.         for(x=0;x<18;x++) {
  1567.             if(!comstring[x])break;
  1568.             if(nextkey==comstring[x]) {
  1569.                 comval=(int)x+1;
  1570.                 break;
  1571.             }
  1572.         }
  1573.     }
  1574.     switch (comval) {
  1575.      case 8:  nextkey=comstring[6];
  1576.      case 4:
  1577.      case 7:
  1578.      case 6:  goto Restart;
  1579.    }
  1580.  
  1581. Doitall:
  1582.  
  1583.   scanflag=1;
  1584.   slowprint=0;
  1585.   if (strcmp(message,"\n") && !(mboard.attr & ANSI)) printm("\n");
  1586.   if (type&4) {
  1587.         if (nextkey!=comstring[4]) {
  1588.             nextkey=comstring[3];
  1589.             goto Restart;
  1590.         }
  1591.   }
  1592.   if (mboard.attr & ANSI) printm(" \x1b[0;1;31m\x1b[23;1H\x1b[K");
  1593.   else printg("\x1b[0;1;31m");
  1594.   printm(p294);
  1595.   if (nomess>1 && (!(type & 2))) printm(p295);
  1596.   if (!(type & 2)) printm(p296);
  1597.   if (((mboard.substat1<=user.stat[0]) && (mboard.substat2<=user.stat[1])) || ((!stricmp(user.handle,msg.to)) || (!stricmp(user.handle,msg.from)) || (!stricmp(user.name,msg.to)) || (!stricmp(user.name,msg.from)))) {
  1598.      printm(p297);
  1599.      sub=1;
  1600.   }
  1601.   else sub=0;
  1602.   if ((!(mboard.attr & READONLY)) or (sub)) printm(p298);
  1603.   gprintf(0,"\n%s",p466);
  1604.   if ((mboard.attr & ASSOC) && (fboard.flags & FILEASSOC) && *assocfile) printm(p349);
  1605.   if (mboard.attr & EXTERN) printm(p370);
  1606.   if (threadstart) printm(p380);
  1607.   printm(": ");
  1608.  
  1609. Doitover:
  1610.  
  1611.   keymess=messno;
  1612.   helpnum=571;
  1613.   nextkey=*genin(1,0,1,1,ALLL);
  1614.   helpnum=0;
  1615.  
  1616.     if(nextkey) comval=-1;
  1617.     else comval=0;
  1618.     if(comval)for(x=0;x<40;x++) {
  1619.         if(!comstring[x]) break;
  1620.         if(nextkey==comstring[x]) {
  1621.             comval=(int)x+1;
  1622.             break;
  1623.         }
  1624.     }
  1625.     switch (comval) {
  1626.     case 1:   say_prompt(424);
  1627.                 goto Doitall;
  1628.     case 2:
  1629.         if(type & 16) {
  1630.             type=type &(~16);
  1631.             say_prompt(369);
  1632.         }
  1633.         else {
  1634.             type=type | 16;
  1635.         }
  1636.         if(type & 16) {
  1637.             messno=0;
  1638.             goto DoNumber;
  1639.         }
  1640.         else goto Doitall;
  1641.     case 3:
  1642.         if (!threadstart || (type & 2)) goto Doitall;
  1643.         messno=threadstart;
  1644.         nextkey=comstring[6];
  1645.         threadstart=0;
  1646.         printm("\n");
  1647.         get_mess(messno);
  1648.         goto Thread;
  1649.     case 0:
  1650.         nextkey=comstring[3];
  1651.     case 4:
  1652.      threadstart=0;
  1653.      printm("\n");
  1654.      goto Restart;
  1655.     case 5:
  1656.      goto SetLast;
  1657.     case 6:
  1658.      printm("\n");
  1659.      goto Over;
  1660.     case 7:
  1661.     case 8:
  1662.      threadstart=0;
  1663.      nextkey=comstring[6];
  1664.      printm("\n");
  1665.      goto Restart;
  1666.     case 9:
  1667.      if (!(type & 2)) {
  1668.         messno=0;
  1669.         goto DoNumber;
  1670.      }
  1671.      break;
  1672.     case 10:
  1673.      nextkey=comstring[5];
  1674.      ctla=1-ctla;
  1675.      ctla!=0 ? say_prompt(299) : say_prompt(300);
  1676.      goto Over;
  1677.     case 11:
  1678.     case 12:
  1679.     case 13:
  1680.      if (type & 2) break;
  1681. ReThreadLoop:
  1682.      if(comval==13) nextkey='B';
  1683.      else if (comval==12) nextkey='F';
  1684.      else {
  1685.          while (comval!=12 && comval!=13) {
  1686.             say_prompt(51);
  1687.             helpnum=573;
  1688.             nextkey=*genin(1,0,1,1,ALPHA);
  1689.             helpnum=0;
  1690.             if(nextkey==0) nextkey=comstring[11];
  1691.             for(x=0;x<27;x++) {
  1692.                 if(!comstring[x])break;
  1693.                 if(nextkey==comstring[x]) {
  1694.                     comval=(int)x+1;
  1695.                     break;
  1696.                 }
  1697.             }
  1698.             if (nextkey=='A') threadstart=0;
  1699.             if (nextkey=='Q') goto Doitall;
  1700.             *lastmsgid=0;
  1701.             *lastreply=0;
  1702.          }
  1703.      }
  1704.      printm("\n");
  1705.  
  1706.      {
  1707.         char *p;
  1708.         char type;
  1709.         int direction;
  1710.  
  1711.         if((nextkey=='F' && messno!=nomess) || messno==1) {
  1712.             direction=1;
  1713.             if(*lastmsgid) {
  1714.                 type=2;
  1715.                 p=lastmsgid;
  1716.             }
  1717.             else {
  1718.                 type=1;
  1719.                 p=msg.subj;
  1720.             }
  1721.         }
  1722.         else {
  1723.             direction=-1;
  1724.             if(*lastreply) {
  1725.                 type=2;
  1726.                 p=lastreply;
  1727.             }
  1728.             else {
  1729.                 type=1;
  1730.                 p=msg.subj;
  1731.             }
  1732.         }
  1733.         say_prompt(52);
  1734.         temp=get_abunch(messno,type,direction,p);
  1735.  
  1736.      }
  1737.      if (temp) {
  1738.         if (!threadstart) threadstart=messno;
  1739.         messno=temp;
  1740.         goto Thread;
  1741.      }
  1742.      say_prompt(53);
  1743.      goto Doitall;
  1744.     case 14:
  1745.     if (mboard.attr & EXTERN) {
  1746.         readfile("EXTRAMSG.XBS",0,0,1);
  1747.     }
  1748.     goto Doitall;
  1749.     case 15:
  1750.     if ((mboard.attr & ASSOC) && (fboard.flags & FILEASSOC) && *assocfile) {
  1751.  
  1752.         char tempfile[133]="";
  1753.         char *p;
  1754.  
  1755.         if(strchr(assocfile,'\\') || strchr(assocfile,':')) strcpy(tempfile,assocfile);
  1756.         else sprintf(tempfile,"%s%s",fboard.dpath,assocfile);
  1757.         temp = findfirst(tempfile,&filestat,0);
  1758.         if (!temp) {
  1759.             if(strchr(assocfile,'\\') || strchr(assocfile,':')) *tempfile=0;
  1760.             else strcpy(tempfile,fboard.dpath);
  1761.         }
  1762.         else {
  1763.             sprintf(tempfile,"%s%s",fboard.upath,assocfile);
  1764.             temp=findfirst(tempfile,&filestat,0);
  1765.             if (!temp) strcpy(tempfile,fboard.upath);
  1766.         }
  1767.         if (temp && !maxareas) {
  1768.             say_prompt(350);
  1769.             goto Doitall;
  1770.         }
  1771.         strcat(tempfile,assocfile);
  1772.         p=strrchr(assocfile,'.');
  1773.         if(!p)p=assocfile;
  1774.         if (p>assocfile) if (!stricmp(p,".TXT") || !stricmp(p,".DOC") || !strchr(assocfile,'.')) {
  1775.             readtext(tempfile);
  1776.             goto Doitall;
  1777.         }
  1778.         readfile("VIEWFILE.XBS",0,0,1);
  1779.         goto Doitall;
  1780.     }
  1781.     goto Doitall;
  1782.     case 16:
  1783.      if(user.stat[0]<mboard.minwrite) {
  1784.         say_prompt(591);
  1785.         goto Doitall;
  1786.      }
  1787.      memcpy(&oldmsg,&msg,sizeof(struct _xmsg));
  1788.      *replyid=0;
  1789.      if ((sub) || (!(mboard.attr & READONLY))) {
  1790.      if (nodenumber!=1) sprintf(message,"MSGTMP%hu",nodenumber);
  1791.      else strcpy(message,"MSGTMP");
  1792.      unlink(message);
  1793.      if(mboard.attr & ALTERNATE) strcpy(to_domain,conf.alt_domain);
  1794.      else strcpy(to_domain,conf.domain);
  1795.      if ((pp=oopen(message,O_RDWR | O_BINARY | O_DENYNONE))==-1)
  1796.         if((pp=ccreat(message,S_IWRITE))==-1) {
  1797.           say_prompt(301);
  1798.           goto Replyhere;
  1799.       }
  1800.       hold=get_text(messno);
  1801.       if (hold==NULL) {
  1802.         cclose(pp);
  1803.         say_prompt(41);
  1804.         goto SetLast;
  1805.       }
  1806.       strip_seenbys(hold);
  1807.       strip_blanklines(hold);
  1808.       p=tempo=hold;
  1809.  
  1810.       x=user.width-9;
  1811.       if (x>65) x=65;
  1812.  
  1813.       say_prompt(426);
  1814.  
  1815.           helpnum=572;
  1816.           strcpy(qstring,genin(5,0,0,0,ALLL));
  1817.           helpnum=0;
  1818.           if(!*qstring) {
  1819.             ffprintf(pp,"\r\n");
  1820.             ffprintf(pp,say_prompt(427),msg.date,msg.from,msg.to,msg.subj);
  1821.             ffprintf(pp,"\r\n%s\r\n",say_prompt(428));
  1822.           }
  1823.  
  1824.       while (*p) {
  1825.           strcpy(message,write_line(&p,x,1));
  1826. Restrip:
  1827.             if (*message=='\x1') {
  1828.               if (!strncmp(message,"\01PATH:",6)) break;
  1829.               if(msg.o_zone==0) {
  1830.                 if (!strncmp(message,"\01FMPT",5)) {
  1831.                     msg.o_point=(word)atol(&message[6]);
  1832.                     continue;
  1833.                 }
  1834.                 else if (!strncmp(message,"\01INTL",5)) {
  1835.                     strtok(message," :");
  1836.                     strtok(0," ");
  1837.                     tempo=strtok(0,":");
  1838.                     if(tempo) if ((word)atoi(tempo)) msg.o_zone=(word)atol(tempo);
  1839.                     continue;
  1840.                 }
  1841.                 if (!strncmp(message,"\01DOMAIN",7)) {
  1842.                     strtok(message," ");
  1843.                     tempo=strtok(0,"\n");
  1844.                     if(tempo) {
  1845.                         strncpy(to_domain,tempo,37);
  1846.                         to_domain[36]=0;
  1847.                     }
  1848.                     continue;
  1849.                 }
  1850.               }
  1851.               if (!strncmp(message,"\01MSGID",6)) {
  1852.  
  1853.                     char *p;
  1854.                     char *ispoint;
  1855.                     char *isdomain;
  1856.                     char *isnumsign;
  1857.                     char *mss;
  1858.  
  1859.                     strncpy(replyid,&message[7],80);
  1860.                     replyid[79]=0;
  1861.                     lstrip(replyid);
  1862.                     rstrip(replyid);
  1863.                     mss=message;
  1864.                     ispoint=strchr(mss,'.');
  1865.                     isdomain=strchr(mss,'@');
  1866.                     isnumsign=strchr(mss,'#');
  1867.                     if(isnumsign) {     /* For [user@]domain#z:n/n.p */
  1868.                         if(isdomain) {
  1869.                             if(isnumsign<isdomain) {
  1870.                                 strtok(mss,"@");
  1871.                                 strncpy(msg.to,mss,36);
  1872.                                 msg.to[35]=0;
  1873.                                 mss=strtok(0,"\n");
  1874.                                 isdomain=NULL;  /* Was username */
  1875.                             }
  1876.                         }
  1877.                         strtok(mss,"#");
  1878.                         strncpy(to_domain,mss,37);
  1879.                         to_domain[36]=0;
  1880.                         mss=strtok(0,"\n");
  1881.                     }
  1882.                     strtok(mss," :");
  1883.                     p=strtok(0,":");
  1884.                     if(p)msg.o_zone=(word)atol(p);
  1885.                     p=strtok(0,"/");
  1886.                     msg.orig_net=(word)atol(p);
  1887.                     if(ispoint) p=strtok(0,".");
  1888.                     else if (isdomain) p=strtok(0,"@");
  1889.                     else p=strtok(0," ");
  1890.                     if(p)msg.orig=(word)atol(p);
  1891.                     if(ispoint) {
  1892.                         p=strtok(0,"@ ");
  1893.                         if(p && (word)atoi(p) && atol(p)<65536)
  1894.                             msg.o_point=(word)atol(p);
  1895.                     }
  1896.                     if(isdomain) {
  1897.                         p=strtok(0," \r");
  1898.                         if(p) strncpy(to_domain,p,37);
  1899.                         to_domain[36]=0;
  1900.                     }
  1901.                     continue;
  1902.               }
  1903.               else {
  1904.                     if(!ctla) continue;
  1905.                     while ((tempo=strchr(hold,'\x1'))) *tempo='@';
  1906.               }
  1907.             }
  1908.           if(!*message)ffprintf(pp,"\r\n");
  1909.           else ffprintf(pp,"%s%s\r\n",qstring,message);
  1910.        }
  1911.        if (hold) ffree(hold);
  1912.        if(!*qstring) ffprintf(pp,"%s\r\n",say_prompt(429));
  1913.        cclose(pp);
  1914. Replyhere:
  1915.        x=(word)*msginfo;
  1916.        if(!strstr(msginfo,"RETAIN "))*msginfo=0;
  1917.        if ((mboard.attr & NET) || (mboard.attr & ALTERNATE)) {
  1918.          msg.m_attr = msg.m_attr | MSGNET;
  1919.          msg.dest=msg.orig;
  1920.          msg.dest_net=msg.orig_net;
  1921.          msg.d_zone=msg.o_zone;
  1922.          msg.d_point=msg.o_point;
  1923.        }
  1924.        if (strnicmp(msg.subj,"Re:",3)) {
  1925.          strcpy(message,msg.subj);
  1926.          strcpy(msg.subj,"Re: ");
  1927.          strncat(msg.subj,message,64);
  1928.          msg.subj[63]=0;
  1929.          strcpy(oldmsg.subj,msg.subj);
  1930.        }
  1931.        if (!(msg.m_attr & MSGANON)) strcpy(msg.to,msg.from);
  1932.        else {
  1933.             strcpy(msg.to,say_prompt(47));
  1934.             strcpy(oldmsg.from,say_prompt(47));
  1935.        }
  1936.        safe=0;
  1937.        if (!askwrite(1+(16*(msg.attr & MSGPRIVATE)))) {
  1938.             if (!writemessage(0)) level=(word)makemessage(0);
  1939.        }
  1940.        else {
  1941.             level=1;
  1942.             if (nodenumber!=1) sprintf(message,"MSGTMP%hu",nodenumber);
  1943.             else strcpy(message,"MSGTMP");
  1944.             unlink(message);
  1945.             strcat(message,".INF");
  1946.             unlink(message);
  1947.             tempo=strchr(message,'.');
  1948.             *tempo=0;
  1949.             strcat(message,".HDR");
  1950.             unlink(message);
  1951.        }
  1952.        safe=1;
  1953.        sprintf(buffer,"%sXDATA.%03x",messpath,mboard.number);
  1954.        if(findfirst(buffer,&filestat,0)) {
  1955.             say_prompt(48);
  1956.             goto SetLast;
  1957.        }
  1958.        nomess=(word)((filestat.ff_fsize/(long)sizeof(struct _xmsg)));
  1959.        get_mess(messno);
  1960.        *msginfo=(char)x;
  1961.        goto Doitall;
  1962.      }
  1963.      break;
  1964.     case 17:
  1965.      if (sub) {
  1966.        msg.m_attr=(msg.m_attr ^ MSGDELETED);
  1967.        (msg.m_attr & MSGDELETED)!=0 ? say_prompt(303) : say_prompt(304);
  1968.        put_mess(messno);
  1969.        if((msg.m_attr & MSGNET) && !(msg.attr & MSGSENT) && !(msg.m_attr & MSGSCANNED)) {
  1970.             if(msg.m_attr & MSGDELETED) gprintf(LOGONLY,"Deleted net msg MSGID %s",lastmsgid);
  1971.             else gprintf(LOGONLY,"Undeleted net msg MSGID %s",lastmsgid);
  1972.        }
  1973.        goto Doitall;
  1974.      }
  1975.      break;
  1976.     case 18:
  1977.      type=type|128;
  1978.      nextkey=0;
  1979.      goto Scanswitch;
  1980.     default: {
  1981.         char s[13];
  1982.  
  1983.         sprintf(s,"AFTER%03u.XBS",comval);
  1984.         readfile(s,1,1,1);
  1985.         goto Doitall;
  1986.     }
  1987.   }
  1988.   printm(BACKSPACE);
  1989.   goto Doitover;
  1990.  
  1991. SetLast:
  1992.  
  1993.     *msginfo=0;
  1994.     pauser=0;
  1995.     slowprint=0;
  1996.  
  1997.     keymess=lastmess;
  1998.     cclose(ta);
  1999.     cclose(fa);
  2000.     if (exported) {
  2001.         gprintf(0,say_prompt(377),exported);
  2002.     }
  2003.     safe=1;
  2004.     if((type & 128) && !scanflag) return (lastmess);
  2005.     if (!(type & 2)) {
  2006.         if (mboard.number<(conf.nolmrs+1)) {
  2007.             if (lastmess>lastread[mboard.number-1]) {
  2008.                 if(conf.logmsg) gprintf(LOGONLY,"Read msgs in %s (%u)",mboard.name,mboard.number);
  2009.                 lastread[mboard.number-1]=lastmess;
  2010.             }
  2011.         }
  2012.     }
  2013.     return (lastmess);
  2014. }
  2015.  
  2016.  
  2017.  
  2018. char * pascal mci (char *text) {
  2019.  
  2020.     static char s[256];
  2021.     char work[81];
  2022.     char temp[36];
  2023.     char *p;
  2024.     register word x=0;
  2025.     struct date dos_date;
  2026.     struct time dos_time;
  2027.  
  2028.     if (!*text) return text;
  2029.     stripcr(text);
  2030.     if (!*text) return "\r\n";
  2031.     *work=0;
  2032.     if (*text=='^') strcat(work," ");
  2033.     strcat(work,text);
  2034.     text=work;
  2035.     strcpy(s,strtok(text,"^"));
  2036.     while ((p=strtok(0,"^"))!=NULL && (strlen(s)+strlen(p)+1)<(256-35)) {
  2037.         switch ((int)toupper(*p)) {
  2038.             case 'H':   if (!isdigit(p[1])) {
  2039.                             strcat(s,BACKSPACE);
  2040.                             p++;
  2041.                             break;
  2042.                         }
  2043.                         for (x=0;x<(p[1]-'0');x++) strcat(s,BACKSPACE);
  2044.                         p+=2;
  2045.                         break;
  2046.             case 'U':   if (!(mboard.attr & REAL)) strcpy(temp,user.name);
  2047.                         else strcpy(temp,user.handle);
  2048.                         if (!isdigit(p[1]) || p[1]=='0') {
  2049.                             strcat(s,temp);
  2050.                             if (p[1]!='0') {
  2051.                                 p++;
  2052.                                 break;
  2053.                             }
  2054.                         }
  2055.                         else if (p[1]=='1' || !strchr(temp,' ')) {
  2056.  
  2057.                             char *pp;
  2058.  
  2059.                             if(pp=strchr(temp,' ')) *pp=0;
  2060.                             strcat(s,temp);
  2061.                         }
  2062.                         else {
  2063.                             strtok(temp," ");
  2064.                             strcat(s,strtok(0," "));
  2065.                         }
  2066.                         p+=2;
  2067.                         break;
  2068.             case 'B':    strcat(s,"\x7");
  2069.                         p++;
  2070.                         break;
  2071.             case 'A':   p++;
  2072.                         if(isdigit(*p)) *p=*p-'0';
  2073.                         else if(toupper(*p)=='A') {
  2074.                             strcat(temp,"\x1b[36m");
  2075.                             goto CoitusInterruptus;
  2076.                         }
  2077.                         else {
  2078.                             p--;
  2079.                             break;
  2080.                         }
  2081.                         strcat(temp,"\x1b[");
  2082.                         switch((int)(*p)) {
  2083.                             case 0: strcat(temp,"0;1;32");
  2084.                                     break;
  2085.                             case 1: strcat(temp,"1");
  2086.                                     break;
  2087.                             case 2: strcat(temp,"2");
  2088.                                     break;
  2089.                             case 3: strcat(temp,"5");
  2090.                                     break;
  2091.                             case 4: strcat(temp,"7");
  2092.                                     break;
  2093.                             case 5: strcat(temp,"31");
  2094.                                     break;
  2095.                             case 6: strcat(temp,"32");
  2096.                                     break;
  2097.                             case 7: strcat(temp,"33");
  2098.                                     break;
  2099.                             case 8: strcat(temp,"34");
  2100.                                     break;
  2101.                             case 9: strcat(temp,"35");
  2102.                                     break;
  2103.                         }
  2104.                         strcat(temp,"m");
  2105. CoitusInterruptus:
  2106.                         if(user.graphics)strcat(s,temp);
  2107.                         p++;
  2108.                         break;
  2109.             case 'T':   gettime(&dos_time);
  2110.                         strcat(s,saytime(&dos_time));
  2111.                         p++;
  2112.                         break;
  2113.             case 'D':    getdate(&dos_date);
  2114.                         strcat(s,saydate(&dos_date));
  2115.                         p++;
  2116.                         break;
  2117.             case 'R':   sprintf(temp,"%u",(word)(timelimit-(getxbbstime()/60)));
  2118.                         strcat(s,temp);
  2119.                         p++;
  2120.                         break;
  2121.             case 'S':   slowprint=1;
  2122.                         p++;
  2123.                         break;
  2124.             default:    break;
  2125.         }
  2126.         strcat(s,p);
  2127.     }
  2128.     strcat(s,"\n");
  2129.     return s;
  2130. }
  2131.  
  2132.  
  2133.  
  2134. void pascal printheader (page,messno,type,nomess)
  2135.  
  2136.     char page;
  2137.     word messno;
  2138.     char type;
  2139.     word nomess;
  2140.  
  2141. {
  2142.  
  2143.  char text[125];
  2144.  static char readprompt[80]="";
  2145.  static char headprompt[90];
  2146.  static char messprompt[80];
  2147.  
  2148.  if (!*readprompt) {
  2149.     strcpy(readprompt,say_prompt(316));
  2150.     strcpy(messprompt,say_prompt(317));
  2151.     strcpy(headprompt,say_prompt(318));
  2152.  }
  2153.  if (!user.scrnclr && !(type & 4) && user.graphics) printm("\x1b[1;1H");
  2154.  else printm("\n");
  2155.  printg("\x1b[0;2;37m\x1b[K");
  2156.  gprintf(0,headprompt,mboard.number,mboard.name,nomess,page+1);
  2157.  printg("\x1b[0;1;36m\x1b[K");
  2158.  gprintf(0,messprompt,messno);
  2159.  if ((msg.attr & MSGPRIVATE)) say_prompt(305);
  2160.  if ((msg.m_attr & MSGDELETED)) say_prompt(306);
  2161.  if ((mboard.attr & NET) || (mboard.attr & ALTERNATE)) {
  2162.      if ((msg.attr & MSGCRASH)) say_prompt(307);
  2163.      if ((msg.attr & MSGKILL)) say_prompt(308);
  2164.      if ((msg.attr & MSGSENT)) say_prompt(309);
  2165.      if ((msg.attr & MSGFWD)) say_prompt(310);
  2166.      if ((msg.attr & MSGRRQ)) say_prompt(312);
  2167.      if ((msg.attr & MSGCPT)) say_prompt(313);
  2168.      if ((msg.attr & MSGARQ)) say_prompt(314);
  2169.      if ((msg.attr & MSGURQ)) say_prompt(315);
  2170.  }
  2171.  if ((msg.attr & MSGREAD)) say_prompt(311);
  2172.  gprintf(0,readprompt,msg.times);
  2173.  printg("\x1b[K");
  2174.  gprintf(0,"To:   %-36s",msg.to);
  2175.  if ((mboard.attr & NET) || (mboard.attr & ALTERNATE)) {
  2176.     gprintf(0," (%u:%u/%u.%01u) ",msg.d_zone,msg.dest_net,msg.dest,msg.d_point);
  2177.  }
  2178.  if ((msg.m_attr & MSGANON)) {
  2179.    left(text,msg.date,9);
  2180.    printm(text);
  2181.  }
  2182.  else printm(msg.date);
  2183.  printm("\n");
  2184.  printg("\x1b[K");
  2185.  printm("From: ");
  2186.  if (msg.m_attr & MSGANON) {
  2187.    say_prompt(264);
  2188.    gprintf(LOCALONLY," \04(%s)",msg.from);
  2189.  }
  2190.  else printm(msg.from);
  2191.  if ((mboard.attr & NET) || (mboard.attr & ALTERNATE)) {
  2192.     gprintf(0," (%u:%u/%u.%01u)",msg.o_zone,msg.orig_net,msg.orig,msg.o_point);
  2193.  }
  2194.  printm("\n");
  2195.  printg("\x1b[K");
  2196.  if ((msg.attr & MSGFILE)) say_prompt(329);
  2197.  else if ((msg.attr & MSGFRQ)) say_prompt(330);
  2198.  else if ((msg.attr & MSGURQ)) say_prompt(331);
  2199.  else printm("Subj: ");
  2200.  printm(msg.subj);
  2201.  printm("\n");
  2202.  printg("\x1b[K\x1b[0;1;32m");
  2203.  
  2204. }
  2205.  
  2206.  
  2207.  
  2208. void pascal strip_seenbys (char *hold) {
  2209.  
  2210.     char *path=NULL;
  2211.     char *seenby=NULL;
  2212.     char *origin=NULL;
  2213.     char *p;
  2214.  
  2215.         origin=strstr(hold,"\r * Origin:");
  2216.         if (origin) {
  2217.             while(p=strstr(&origin[1],"\r * Origin:")) origin=p;
  2218.             path=stristr(origin,"\r\01PATH:");
  2219.             seenby=strstr(origin,"\rSEEN-BY:");
  2220.             if (!seenby) seenby=stristr(origin,"\r\01SEEN-BY:");
  2221.             if (!path) if (seenby) *seenby=0;
  2222.             if (seenby && path) memmove (seenby,path,strlen(path)+1);
  2223.         }
  2224. }
  2225.  
  2226.  
  2227.  
  2228. char * pascal write_line (char **text,word linelen,char ctla) {
  2229.  
  2230.     static char line[133];
  2231.     word register x=0;
  2232.     char *p;
  2233.     char *pp;
  2234.  
  2235.     if(!*text) return "";
  2236.     if(!**text) return *text;
  2237.     p=*text;
  2238.     pp=line;
  2239.     *pp=0;
  2240.     while(++x<linelen && *p && *p!='\r') {
  2241.         if(*p=='\n' || *p=='\x8d') {
  2242.             p++;
  2243.             continue;
  2244.         }
  2245.         if((*p=='\01' && (*(p-1)=='\r' || p==*text)) && !ctla) {
  2246.             while(*p!='\r' && *p)p++;
  2247.             if(*p=='\r') p++;
  2248.             continue;
  2249.         }
  2250.         *pp++=*p++;
  2251.         *pp=0;
  2252.     }
  2253.     if(*p=='\r') {
  2254.         *pp=0;
  2255.         p++;
  2256.     }
  2257.     else if(*p==' ') {
  2258.         *pp=0;
  2259.         while(*p==' ') p++;
  2260.     }
  2261.     else if(x==linelen) {
  2262.         if(strchr(line,' ')) {
  2263.             while(p>*text && *pp!=' ') {
  2264.                 *pp=0;
  2265.                 pp--;
  2266.                 p--;
  2267.                 if(*p=='\n' || *p=='\x8d') p--;
  2268.             }
  2269.             if(p==*text) {
  2270.                 strncpy(line,*text,linelen);
  2271.                 line[linelen]=0;
  2272.                 p=text[linelen];
  2273.             }
  2274.             else p++;
  2275.         }
  2276.     }
  2277.     while(*pp==' ' && pp>line) {    /* Rstrip returned string */
  2278.         *pp=0;
  2279.         --pp;
  2280.     }
  2281.     *text=p;
  2282.     return line;
  2283. }
  2284.  
  2285.  
  2286. void pascal strip_blanklines (char *hold) {
  2287.  
  2288.     char *p;
  2289.  
  2290.     p=&hold[strlen(hold)-1];
  2291.     while(*p=='\r' && p>hold) {
  2292.         *p=0;
  2293.         p--;
  2294.     }
  2295. }
  2296.  
  2297.