home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / BBS / MISC / XSRC_117.ZIP / XUD.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-10-28  |  39.2 KB  |  1,440 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.....U/D routines                         */
  33. /*======================================================================*/
  34.  
  35. #include "msg.h"
  36. #include "xext.h"
  37.  
  38.  
  39. void pascal pauseit (void) {
  40.  
  41.     char  a;
  42.     ulong start;
  43.     int register x;
  44.  
  45.       start=getxbbstime();
  46.       a=pauser;
  47.       pauser=0;
  48.       fossil(FLUSHOUT,0);
  49.       fossil (PURGEIN,0);
  50.       lprint ("[Paused]");
  51.       while (!inkey() && (getxbbstime()-start)<45L);
  52.       for (x=0;x<8;x++) lprint (BACKSPACE);
  53.       pauser=a;
  54.  
  55. }
  56.  
  57.  
  58. char pascal filesbbs (fname,type,sdate,searchstring)
  59.                                  /* READS FILES.BBS TO MODEM & SCREEN
  60.                                     !(type & 1) = from d/l path
  61.                                     type & 1    = from u/l path
  62.                                     type & 2    = newlist
  63.                                     type & 4    = use searchstring
  64.                                     type & 8    = recognize 'D'
  65.                                     type & 16   = recognize 'M'
  66.                                  */
  67.   char *fname;
  68.   char type;
  69.   char *sdate;
  70.   char *searchstring;
  71.  
  72. {
  73.  
  74.     int register x;
  75.     int  handle;
  76.     char path[81];
  77.     char mask[26];
  78.     char dupe[81];
  79.     char str[256];
  80.     char a;
  81.     char *b;
  82.     char *bb;
  83.     char filename[94];
  84.     char p;
  85.     char new[14]="";
  86.     char saidone=0;
  87.     struct ffblk f;
  88.     word dls;
  89.     char limitarea=0;
  90.     char asktodl=0;
  91.     char asktomark=0;
  92.  
  93.     ulong temppos;
  94.     ulong pos[77];
  95.     signed char page;
  96.  
  97.     struct fdate {
  98.       bit day:   5;
  99.       bit month: 4;
  100.       bit year:  7;
  101.     };
  102.     union df {
  103.       struct fdate fd;
  104.       int x;
  105.     } fdf,fdu;
  106.     struct ftime {
  107.       bit sec:  5;
  108.       bit min:  6;
  109.       bit hour: 5;
  110.     };
  111.     union tf {
  112.       struct ftime ft;
  113.       int x;
  114.     } fdt;
  115.     char should=0;
  116.     static char comstring[26]="";
  117.     char showcomments=0;
  118.  
  119. #ifdef UDDEBUG
  120.     gprintf(LOCALONLY,"\n\04Before:  %s\n",sdate);
  121. #endif
  122.  
  123.  pauser=0;
  124.  if(type & 128) {
  125.     type=(type &(~128));
  126.     limitarea=1;
  127.  }
  128.  if(type & 8) {
  129.     type = type &(~8);
  130.     asktodl=1;
  131.  }
  132.  if(type & 16) {
  133.     type = type &(~16);
  134.     asktomark=1;
  135.  }
  136.  if (!(type & 1))strcpy(path,fboard.dpath);
  137.  else strcpy(path,fboard.upath);
  138.  sprintf(filename,"%s%s",path,fname);
  139.  
  140.  if(!*comstring)strncpy(comstring,say_prompt(268),26);
  141.  if ((handle=oopen(filename,O_RDONLY | O_TEXT | O_DENYNONE))==-1) return 4;
  142.  
  143.  fdu.fd.month=(unsigned)atoi(strtok(sdate,"/"));
  144.  fdu.fd.day=(unsigned)atoi(strtok(0,"/"));
  145.  fdu.fd.year=(unsigned)(atoi(strtok(0,"\n"))-1980);
  146.  
  147. #ifdef UDDEBUG
  148.     gprintf(LOCALONLY,"\n\04After:  Month: %u Day: %u Year: %u\n",fdu.fd.month,fdu.fd.day,fdu.fd.year);
  149. #endif
  150.  
  151.  *mask=0;
  152.  if (type<2) {
  153.     say_prompt(274);
  154.     helpnum=524;
  155.     strcpy(mask,genin(25,0,1,0,ALLL));
  156.     helpnum=0;
  157.     if (!*mask && type<2) {
  158.         cls();
  159.         if ((!baud || baud>=1200) && (user.graphics)) {
  160.             gprintf(0,say_prompt(339),fboard.name);
  161.             lines++;
  162.         }
  163.     }
  164.     else {
  165.         if(wherex()!=1) {
  166.             printm("\n");
  167.             lines++;
  168.         }
  169.     }
  170.  }
  171.  else {
  172.         if(wherex()!=1) {
  173.             printm("\n");
  174.             lines++;
  175.         }
  176.  }
  177.  if(type&4) {
  178.     if(searchstring) {
  179.         strncpy(mask,searchstring,26);
  180.         mask[25]=0;
  181.     }
  182.  }
  183.  
  184.  if(type & 2) strcpy(str,"New-");
  185.  else *str=0;
  186.  if (conf.logfiles) gprintf(LOGONLY,"%sListed %s (%s)",str,filename,mask);
  187.  
  188.  page=0;
  189.  pos[0]=0;
  190.  
  191.  while (!eof(handle)) {
  192. DoItAgain:
  193.  
  194.    if ((!(b=fgetsx(str, 81, handle)))) goto nomore;
  195.    if(!showcomments) if(first_non_white(b)==';') continue;
  196.  
  197. DoItOver:
  198.    pauser=2;
  199.    getxbbstime();
  200.    if (*mask) {
  201.         strcpy(dupe,str);
  202.         if (!stristr(dupe,mask)) {
  203.             p=0;
  204.             goto Loop;
  205.         }
  206.    }
  207.    if(*b==';') b++;
  208.    if (*b && *b!=' ' && *b!='\n') if (strcspn(b," ")<13 || strlen(b)<13) {
  209.      if(!eof(handle) && limitarea) {
  210. AgainAndAgain:
  211.         temppos=tell(handle);
  212.         if(fgetsx(dupe,81,handle)) {
  213.             dupe[80]=0;
  214.             if(!strncmp(dupe," ;Area: ",7)) {
  215.                 bb=&dupe[6];
  216.                 stripcr(bb);
  217.                 lstrip(bb);
  218.                 rstrip(bb);
  219.                 if(stricmp(bb,fboard.name)) {  /* Not current area */
  220.                     while(!eof(handle)) {
  221.                         if(!fgetsx(str,81,handle)) break;
  222.                         if((!showcomments && first_non_white(str)==';') || strncmp(b,"                              ",30)) break;
  223.                     }
  224.                     continue;
  225.                 }
  226.             }
  227.             if(!showcomments && first_non_white(dupe)==';') goto AgainAndAgain;
  228.         }
  229.         lseek(handle,temppos,SEEK_SET);
  230.      }
  231.      b=strtok(b," \n");
  232.      b=strtok(0,"\0");
  233.      b=lstrip(b);
  234.      if (*b && b[strlen(b)-1]!='\n') strcat(b,"\n");
  235.      if (!*str) goto nomore;
  236.      bb=str;
  237.      if(*bb==';') bb++;
  238.      if (type & 2) {
  239.        sprintf(filename,"%s%s",path,bb);
  240.        if(findfirst(filename,&f,0)) goto nomore;
  241.        fdf.x=f.ff_fdate;
  242.        if (fdf.x<fdu.x) {
  243.             b=NULL;
  244.             goto nomore;
  245.        }
  246.      }
  247.      saidone=1;
  248.      printg("\x1b[0;1;33m");
  249.      gprintf(0,"%-12s",str);
  250.      sprintf(filename,"%s%s",path,bb);
  251.      if(findfirst(filename,&f,0)!=0) {
  252.        printg("\x1b[37m");
  253.        printm(" MISSING ");
  254.        if (b==NULL || !*b) {
  255.             printm("\n");
  256.             lines++;
  257.        }
  258.        goto nomore;
  259.      }
  260.      fdf.x=f.ff_fdate;
  261.      fdt.x=f.ff_ftime;
  262.      dls=(word)fdt.x;
  263.      if (fdf.x>=fdu.x) {
  264.             (user.graphics) ? strcpy(new,"\x1b[0;1;5;31m*") : strcpy(new,"*");
  265.      }
  266.      else strcpy(new," ");
  267.      if (user.graphics) gprintf(0,"\x1b[34m  %-6lu \x1b[0;2;31m%02u/%02u/%02u%s",f.ff_fsize,fdf.fd.month,fdf.fd.day,(fdf.fd.year+80)%100,new);
  268.      else gprintf(0,"  %-6lu %02u/%02u/%02u%s",f.ff_fsize,fdf.fd.month,fdf.fd.day,(fdf.fd.year+80)%100,new);
  269.      if (dls && (fboard.flags & COUNTDLS) && (strcmp(f.ff_name,"FILES.BBS"))) {
  270.         if (dls>1) strcpy(new,"s");
  271.         else *new=0;
  272.         printg("\x1b[0;1;31m");
  273.         if (user.graphics) gprintf(0,"(%u Download%s)\n\x1b[30C",((word)(dls)),new);
  274.         else gprintf(0,"(%u Download%s)\n                              ",((word)(dls)),new);
  275.         lines++;
  276.      }
  277.      if (lines>=(user.length-3)) should++;
  278.      printg("\x1b[0;1;32m");
  279.      if ((b!=NULL) && *b) {
  280.         if(p=check4more()) goto Abort;
  281.         if (strlen(b)+30>=user.width) lines+=2;
  282.         else lines++;
  283.         p=printm(b);
  284.      }
  285.      else {
  286.         if (user.width>=47) lines++;
  287.         say_prompt(151);
  288.      }
  289.      a=toupper(inkey());
  290.      if ((a=='A') || (a == ' ') || (a == 'S') or (p)) goto Abort;
  291.      if (a=='P' || a == 19) {
  292.         pauseit();
  293.         lines=0;
  294.      }
  295.      b=NULL;
  296.      getxbbstime();
  297.      temppos=tell(handle);
  298.      if ((eof(handle)) || (!(b=fgetsx(str,80,handle)))) goto nomore;
  299.      while ((!showcomments && first_non_white(b)==';') || !strncmp(b,"                              ",30)) {
  300.         if(!showcomments)if(first_non_white(b)==';') goto SkipComments;
  301.         if (lines>=(user.length-3)) should++;
  302.         if(p=check4more()) goto Abort;
  303.         if (user.graphics) {
  304.             b+=30;
  305.             printg("\x1b[30C");
  306.         }
  307.         if(p=printm(b)) goto Abort;
  308.         lines++;
  309. SkipComments:
  310.         temppos=tell(handle);
  311.         if ((!(b=fgetsx(str, 81, handle)))) break;
  312.      }
  313.      lseek(handle,temppos,SEEK_SET);
  314.      b=NULL;
  315.     }
  316.  
  317. nomore:
  318.  
  319.    p=0;
  320.    if (lines>=(user.length-2)) should++;
  321.    if ((!(type & 2)) && b!=NULL && *b) {
  322.     printg("\x1b[0;1;37m");
  323.     lines++;
  324.     p=printm(b);
  325.     b=NULL;
  326.    }
  327. Loop:
  328.    if (eof(handle)==-1) lprint("\n\04ARGH!\n");
  329.    a=toupper(inkey());
  330. Abort:
  331.    if ((a == 'S') || (a == ' ') || (p) || (a=='A')) {
  332.       fossil (PURGEOUT,0);
  333.       fossil (PURGEIN,0);
  334.       cclose(handle);
  335.       if(a=='A') return 5;
  336.       return 1;
  337.    }
  338.    if (a=='P' || a == 19) pauseit();
  339.    if (user.graphics) if (saidone) if (!user.more) if (!baud || baud>300) if (lines>=(user.length-1) || (eof(handle)) || (should)) {
  340. Doitallagain:
  341.         lines=should=0;
  342.         lprint("\x1b[23;1H");
  343.         if (baud) while (!fossil(TRANSMIT,'\r')) carrchk();
  344.         if (eof(handle)) {
  345.              printg("\x1b[0;1;31m");
  346.              say_prompt(438);
  347.         }
  348.         say_prompt(340);
  349.         fossil(FLUSHOUT,0);
  350.         fossil(PURGEIN,0);
  351.         pos[page+1]=tell(handle);
  352. Getitagain:
  353.         helpnum=525;
  354.         a=*genin(1,0,1,1,ALPHA +128);
  355.         helpnum=0;
  356.         if(a) {
  357.             for(x=0;x<27;x++) {
  358.                 if(!comstring[x])break;
  359.                 if(a==comstring[x]) {
  360.                     a=(char)x+1;
  361.                     break;
  362.                 }
  363.             }
  364.         }
  365.         switch (a) {
  366.             case 1:     fputs("\r",stdout);
  367.                         if (baud) while (!fossil(TRANSMIT,'\r')) carrchk();
  368.                         cclose(handle);
  369.                         return 1;
  370.             case 2:
  371.             case 0:   if (eof(handle)) goto StopIt;
  372.                         a=0;
  373.                         if (++page>75) page=1;
  374.                         pos[page]=tell(handle);
  375.                         break;
  376.             case 3:
  377. PageOver:
  378.                         lseek(handle,pos[page],SEEK_SET);
  379.                         break;
  380.             case 4:
  381.             case 5:     if (!page) {
  382.                             printm(BACKSPACE);
  383.                             printm("\x7");
  384.                             goto Getitagain;
  385.                         }
  386.                         lseek(handle,pos[--page],SEEK_SET);
  387.                         break;
  388.             case 6:     if(asktodl) {
  389.                             fputs("\r",stdout);
  390.                             if (baud) while (!fossil(TRANSMIT,'\r')) carrchk();
  391.                             cclose(handle);
  392.                             return 3;
  393.                         }
  394.                         goto Default;
  395.             case 7:     if(asktomark) {
  396.                             fputs("\r",stdout);
  397.                             if(baud)while(!fossil(TRANSMIT,'\r')) carrchk();
  398.                             readfile("MARKFILE.XBS",1,1,1);
  399.                             goto Doitallagain;
  400.                         }
  401.                         goto Default;
  402.             case 8:     if(!stricmp(user.name,conf.sysop) || !stricmp(user.handle,conf.sysop)) {
  403.                             showcomments=1-showcomments;
  404.                             goto PageOver;
  405.                         }
  406.                         goto Default;
  407.             case 9:     fputs("\r",stdout);
  408.                         if (baud) while (!fossil(TRANSMIT,'\r')) carrchk();
  409.                         cclose(handle);
  410.                         return 5;
  411.             default:    {
  412.                         char s[13];
  413.  
  414.                         sprintf(s,"FLBBS%03hu.XBS",a);
  415.                         if(readfile(s,1,1,1)==2) printm(BACKSPACE);
  416.                         else {
  417.                             printm("\n");
  418.                             goto Doitallagain;
  419.                         }
  420.                         goto Getitagain;
  421.             }
  422.  
  423. Default:
  424.                         printm(BACKSPACE);
  425.                         goto Getitagain;
  426.         }
  427.         fputs("\r",stdout);
  428.         if (baud) while (!fossil(TRANSMIT,'\r')) carrchk();
  429.         printm("\x1b[K\x1b[0;1;35m");
  430.         gprintf(0,say_prompt(341),fboard.name,page+1);
  431.         lines++;
  432.       }
  433.       if(p=check4more()) goto Abort;
  434.  }
  435.  
  436. StopIt:
  437.  cclose(handle);
  438.  if (!saidone) return 2;
  439.  return 0;
  440. }
  441.  
  442.  
  443. char pascal check4more (void) {
  444.  
  445.     char p=0;
  446.  
  447.     if (lines>=(user.length-1) && !user.more) {
  448.         say_prompt(18);
  449.         fossil(FLUSHOUT,0);
  450.         fossil(PURGEIN,0);
  451.         p = *genin(1,0,1,1,YESNOM);
  452.         say_prompt(276);
  453.         if (p == 'N') printm ("\n");
  454.         else p=0;
  455.         lines=0;
  456.     }
  457.     return p;
  458. }
  459.  
  460.  
  461.  
  462. word pascal download (fname,proto,type)
  463.  
  464.  char *fname;
  465.  struct protocol *proto;
  466.  char type;
  467.  
  468. {
  469.   char s[133];
  470.   ulong total;
  471.   word nofiles=0;
  472.   ulong transtime;
  473.   char uselist=0;
  474.   char tempsafe;
  475.  
  476.    tempsafe=safe;
  477.    safe=0;
  478.    printm("\n");
  479.    if (*fname=='@') uselist=1;
  480.    strcpy(s,fname);
  481.    total=check_dls(s,&nofiles,1);
  482.    if (total==0 || nofiles==0) {
  483.         safe=tempsafe;
  484.         return 0;
  485.    }
  486.    say_prompt(279);
  487.    gprintf(0,say_prompt(280),total,nofiles);
  488.    transtime=transfer_time(total,proto->adj);
  489.    if (!(type & 128)) {
  490.         if (transtime>=(ulong)((ulong)timelimit-(getxbbstime()/60))) {
  491.              say_prompt(281);
  492.              safe=tempsafe;
  493.              level=1;
  494.              return 0;
  495.         }
  496.    }
  497.    gprintf(0,say_prompt(286),proto->name,proto->abort);
  498.    strcpy(s,proto->spawndn);
  499.    replace(s,fname);
  500.    fossil(FLUSHOUT,0);
  501.    if (!strchr(fname,'\\') && !uselist) {
  502.         gothere(conf.downtime,s,0,proto);
  503.    }
  504.    else spawnit(s,0,0);
  505.    if (!level || proto->dszlog) {
  506.         if(!proto->dszlog) {
  507.             strcpy(s,fname);
  508.             total=check_dls(fname,&nofiles,2);
  509.             gprintf(LOGONLY,"%c-D/L %s%s (%lu bytes)",proto->key,fboard.dpath,s,total);
  510.         }
  511.         else {
  512.             do_dszlog(proto,0);
  513.         }
  514.         carrchk();
  515.         sleep(1);
  516.         say_prompt(283);
  517.         timer_off=0;
  518.         safe=tempsafe;
  519.         return ((word)total/1024);
  520.   }
  521.   else {
  522.         mprint(STOPDL);
  523.         gprintf(LOGONLY,"Bad %c-D/L %s%s",proto->key,fboard.dpath,fname);
  524.         carrchk();
  525.         sleep(1);
  526.         say_prompt(284);
  527.         timer_off=0;
  528.         safe=tempsafe;
  529.         return 0;
  530.   }
  531. }
  532.  
  533.  
  534.  
  535.  
  536. ulong pascal transfer_time (ulong total,int adj) {
  537.  
  538.   word tempbaud;
  539.   ulong transtime;
  540.  
  541.    tempbaud=baud;
  542.    if (!tempbaud) tempbaud=1200;
  543.    transtime=(long)(((((long)total)/(long)tempbaud)*1000L)/(long)adj);
  544.    gprintf(0,say_prompt(285),(word)(transtime/60L),(word)((transtime%60L)+((transtime%60L)==0)),tempbaud);
  545.    return (transtime/60L);
  546. }
  547.  
  548.  
  549.  
  550.  
  551. ulong pascal check_dls (char *namestring, word *nofiles,char sayit) {
  552.  
  553.   char *fname;
  554.   char filename[133];
  555.   char temp[133];
  556.   ulong total=0;
  557.   char uselist=0;
  558.   int x;
  559.  
  560.     if (*namestring=='@') uselist=1;
  561.     if (!uselist) {
  562.         strcpy(temp,namestring);
  563.         *namestring=0;
  564.         fname=strtok(temp," ");
  565.     }
  566.     else fname=readfromlist(namestring,1);
  567.     while (fname!=NULL) {
  568.        if (*fname == '.') return 0;            /* directory */
  569.        x= oopen(fname,O_RDONLY);            /* if we can't open it */
  570.        if (x!= -1) {                        /* it aint there, s'ok */
  571.             r.h.ah=0x44;
  572.             r.h.al=0x00;
  573.             r.x.bx=x;
  574.             int86(33,&r,&r);                /* see if device */
  575.             cclose(x);                         /* close handle  */
  576.             if ((int)r.h.al == -1) return 0;/* some error    */
  577.             if(r.h.al & 0x80) return 0;        /* 0x80 is the 'device' bit */
  578.        }
  579.        if (!strchr(fname,':') && !strchr(fname,'\\')) sprintf(filename,"%s%s",fboard.dpath,fname);
  580.        else strcpy(filename,fname);
  581.        x=findfirst(filename,&filestat,0);
  582.        if (x) {
  583.          if (sayit & 1) {
  584.              gprintf(0,"%s%s\n",say_prompt(152),fname);
  585.          }
  586.          goto ReLoop;
  587.        }
  588.        else {
  589.          strcat(namestring,fname);
  590.          strcat(namestring," ");
  591.        }
  592.        while (!x) {
  593.          (*nofiles)++;
  594.          total+=(ulong)filestat.ff_fsize;
  595.          if(sayit & 1) gprintf(0,"%-13s -- %lu bytes\n",filestat.ff_name,filestat.ff_fsize);
  596.          if(sayit & 2) do_dls(filestat.ff_name,filestat.ff_fsize);
  597.          x=findnext(&filestat);
  598.        }
  599. ReLoop:
  600.        if (!uselist) fname=strtok(0," ");
  601.        else fname=readfromlist(namestring,0);
  602.    }
  603.    rstrip(namestring);
  604.    return total;
  605. }
  606.  
  607.  
  608. void pascal gothere (char adjust,char *s, char which,struct protocol *proto)
  609.  
  610. {
  611.  
  612.   char str[133];
  613.   int  drive;
  614.   char dir[MAXDIR];
  615.   int x;
  616.   struct ffblk f;
  617.  
  618.   level=0;
  619.        drive=getdisk();
  620.        getcurdir(++drive,dir);
  621.        if (!which) {
  622.            setdisk(toupper(*fboard.dpath)-'A');
  623.            strcpy(str,fboard.dpath);
  624.            while(*str && str[strlen(str)-1]=='\\')str[strlen(str)-1]=0;
  625.            if(chdir(str)) {
  626.                 say_prompt(443);
  627.                 level=1;
  628.                 return;
  629.            }
  630.        }
  631.        else {
  632.            setdisk(toupper(*fboard.upath)-'A');
  633.            if(proto->noname) {
  634.                 sprintf(str,"%s%03hu",fboard.upath,nodenumber);
  635.                 mkdir(str);
  636.            }
  637.            else {
  638.                 strcpy(str,fboard.upath);
  639.                 while(*str && str[strlen(str)-1]=='\\')str[strlen(str)-1]=0;
  640.            }
  641.            if(chdir(str)) {
  642.                 say_prompt(443);
  643.                 level=1;
  644.                 return;
  645.            }
  646.            if(proto->noname) {
  647.                 sprintf(str,"%s%03hu\\*.*",fboard.upath,nodenumber);
  648.                 x=findfirst(str,&f,0);
  649.                 while(!x) {
  650.                     unlink(f.ff_name);
  651.                     x=findnext(&f);
  652.                 }
  653.            }
  654.        }
  655.        fossil(FLUSHOUT,0);
  656.        if (adjust) adjust_time(0);
  657.        if(baud)spawnit(s,0,0);
  658.        if (adjust) adjust_time(1);
  659.        timer_off++;
  660.        setdisk (--drive);
  661.        strcpy(str,"\\");
  662.        strcat(str,dir);
  663.        chdir(str);
  664. }
  665.  
  666.  
  667. void pascal add_one (char *filename) {
  668.                                 /* INCREMENT TIME STAMP (#Downloads) BY 1 */
  669.     word x;
  670.     char fname[133];
  671.     char far *ptr;
  672.     struct SREGS sregs;
  673.     int temp;
  674.  
  675.                       x=findfirst(filename,&filestat,0);
  676.                       while (!x) {
  677.                         sprintf(fname,"%s%s",fboard.dpath,filestat.ff_name);
  678.                         ptr=fname;
  679.                         r.x.dx=FP_OFF(ptr);
  680.                         sregs.ds=FP_SEG(ptr);
  681.                         r.h.ah=61;
  682.                         r.h.al=64;
  683.                         int86x(33,&r,&r,&sregs);  /* Open file */
  684.                         temp=r.x.ax;              /* Save handle */
  685.                         r.x.bx=temp;
  686.                         r.h.ah=87;
  687.                         r.h.al=0;
  688.                         int86(33,&r,&r);          /* Get time/date */
  689.                         r.x.bx=temp;
  690.                         r.h.ah=87;
  691.                         r.h.al=1;
  692.                         r.x.cx++;
  693.                         int86(33,&r,&r);          /* Set time/date */
  694.                         r.x.bx=temp;
  695.                         r.h.ah=62;
  696.                         int86(33,&r,&r);          /* Close file */
  697.                         x=findnext(&filestat);
  698.                       }
  699. }
  700.  
  701.  
  702. word pascal askdl (filename,type,flsearch,key)
  703.  
  704.  char *filename;
  705.  char type;
  706.  char *flsearch;
  707.  char key;
  708.  
  709. {
  710.  
  711.   int handle;
  712.   char s[133];
  713.   struct protocol proto;
  714.   char *p;
  715.   struct ffblk f;
  716.   char fname[133]="";
  717.   char temp[256]="";
  718.   word temptotal=0;
  719.   char logem=0;
  720.   char uselist=0;
  721.   struct _fboard tempboard;
  722.  
  723.   if(*filename=='@') uselist=1;
  724.   memcpy(&tempboard,&fboard,sizeof(struct _fboard));
  725.   if(conf.debug) {
  726.     gprintf(LOCALONLY,"\n\x4 %s \x4 %hu \x4 %s \x4 %c\n\x4 %s\n\x4 %s\n\x4 %s %hu",filename,type,flsearch,key,fboard.dpath,fboard.upath,fboard.name,fboard.flags);
  727.   }
  728.   if(!flsearch || !stricmp(flsearch,"NULL") || !*flsearch) {
  729.     if(!stricmp(fboard.dpath,"NUL") || !stricmp(fboard.dpath,"NUL\\")) {
  730.         say_prompt(106);
  731.         return 0;
  732.     }
  733.   }
  734.   if(filename) strcpy(fname,filename);
  735.   if(!strcmp(fname,"NULL")) {
  736.     filename=NULL;
  737.     *fname=0;
  738.   }
  739.   if(key && *fname){
  740.     if(!find_protocol(&proto,key)) return 0;
  741.   }
  742.   else strcpy(temp,getstuff(&proto,1+(*fname==0)+(type & 128)+(64*(*filename=='@'))));
  743.   if (!proto.key) return 0;
  744.   if (!*fname && !*temp) return 0;
  745.   else if (!*fname) strcpy(fname,temp);
  746.   if(proto.dszlog) if(getenv("DSZLOG")) unlink(getenv("DSZLOG"));
  747.  
  748.   say_prompt(153);
  749.   helpnum=526;
  750.   logem=(*genin(1,0,1,1,YESNO)=='Y');
  751.   helpnum=0;
  752.   printm("\n");
  753.  
  754.   if (!flsearch || !*flsearch || !strcmp(flsearch,"NULL")) {
  755.     temptotal=download(fname,&proto,(0 + (uselist*2)));
  756.     goto DoLog;
  757.   }
  758.   type = type & 15;
  759.   if (type>9 || type<0) type=0;
  760.   if ((handle=oopen(flsearch,O_RDONLY | O_TEXT | O_DENYNONE))!=-1) {
  761.     say_prompt(155);
  762.      while (!eof(handle)) {
  763.         if (!fgetsx(s,127,handle)) break;
  764.         if (*s=='\n' || *s=='\r' || *s==';') continue;
  765.         stripcr(s);
  766.         strncpy(fboard.dpath,strtok(s," "),78);
  767.         fboard.dpath[78]=0;
  768.         if (fboard.dpath[strlen(fboard.dpath)-1]!='\\') strcat(fboard.dpath,"\\");
  769.         if ((word)atoi(strtok(0," "))>user.stat[type]) continue;
  770.         printm(".");
  771.         strncpy(fboard.name,strtok(0," "),48);
  772.         fboard.name[47]=0;
  773.         while((p=strchr(fboard.name,'_'))!=NULL) *p=' ';
  774.         fboard.flags=(char)atoi(strtok(0," "));
  775.         p=strchr(fname,' ');
  776.         if (p!=NULL) {
  777.             *p=0;
  778.             sprintf(temp,"%s%s",fboard.dpath,fname);
  779.             *p=' ';
  780.         }
  781.         else sprintf(temp,"%s%s",fboard.dpath,fname);
  782.         if (!findfirst(temp,&f,0)) {
  783.             gprintf(0,"%s '%s':\n",say_prompt(154),fboard.name);
  784.             temptotal=download(fname,&proto,0);
  785.             cclose(handle);
  786.             goto DoLog;
  787.         }
  788.      }
  789.      gprintf(0,"%s%s\n",say_prompt(156),strtok(fname," "));
  790.      cclose(handle);
  791.      return 0;
  792.   }
  793.   say_prompt(342);
  794.   return 0;
  795.  
  796. DoLog:
  797.     if (logem) autolog();
  798.     memcpy(&fboard,&tempboard,sizeof(struct _fboard));
  799.     return temptotal;
  800. }
  801.  
  802.  
  803.  
  804. void pascal autolog (void) {
  805.  
  806.     char logem=30;
  807.     char keyin;
  808.  
  809.     pauser=0;
  810.     say_prompt(157);
  811.     fossil(PURGEOUT,0);
  812.     fossil(PURGEIN,0);
  813.     while (--logem) {
  814.         keyin=inkey();
  815.         gprintf(0,"%s%s%02u",BACKSPACE,BACKSPACE,logem);
  816.         if(!keyin) keyin=inkey();
  817.         if (keyin==13) {
  818.             say_prompt(347);
  819.             return;
  820.         }
  821.         if (keyin==27 || keyin==11) break;
  822.         if (!(logem % 5)) printm("\x7");
  823.         sleep(1);
  824.     }
  825.     say_prompt(346);
  826.     fossil(FLUSHOUT,0);
  827.     fossil(DTR,DOWN);
  828.     baud=0;
  829.     leaving++;
  830.     logoff();
  831.     exit(254);
  832. }
  833.  
  834.  
  835.  
  836. word pascal upload (char *uname,char key) {
  837.  
  838.   char s[133];
  839.   char *fname;
  840.   char temporary[256];
  841.   struct protocol proto;
  842.   char filename[133]="";
  843.   char str[256];
  844.   char logem=0;
  845.   char uselist=0;
  846.   word temptotal=0;
  847.   int  handle;
  848.   char tempsafe;
  849.  
  850.   if(!stricmp(fboard.upath,"NUL") || !stricmp(fboard.upath,"NUL\\")) {
  851.         say_prompt(338);
  852.         return 0;
  853.   }
  854.  
  855.   if ((stristr(uname,"00000000.") || stristr(uname,".RPK")) && (stristr(fboard.upath,"\\MPORT"))) handle=128;
  856.   else handle=0;
  857.   if(key && (uname && *uname)) {
  858.     if(!find_protocol(&proto,key)) return 0;
  859.   }
  860.   else strcpy(str,getstuff(&proto,(handle+(32 * (*uname!=0))+(64 * (*uname=='@')))));
  861.   if ((!*str && (!*uname || !uname)) || !proto.key) return 0;
  862.   if (stristr(uname,".RPK") && (stristr(fboard.upath,"\\MPORT"))) {
  863.     proto.dszlog=0;
  864.     proto.noname=0;
  865.   }
  866.   if(proto.dszlog) if(getenv("DSZLOG")) unlink(getenv("DSZLOG"));
  867.   if (*uname=='@' && uname) uselist=1;
  868.  
  869.   say_prompt(158);
  870.  
  871.   if (!uselist) {
  872.         strcpy(temporary,str);
  873.         if (*uname && uname) {
  874.             strcpy(temporary,uname);
  875.             strcpy(str,uname);
  876.         }
  877.         fname=strtok(temporary," ");
  878.   }
  879.   else fname=readfromlist(uname,1);
  880.     if (stristr(fname,".BBS") && baud) {
  881.       say_prompt(159);
  882.       user.violations++;
  883.       fossil(DTR,DOWN);
  884.       baud=0;
  885.       leaving++;
  886.       logoff();
  887.       exit(253);
  888.     }
  889.   while (fname!=NULL) {
  890.       sprintf(filename,"%s%s",fboard.upath,fname);
  891.  
  892.        if (baud) {
  893.           if (!findfirst(filename,&filestat,0)) {
  894.             say_prompt(160);
  895.             return 0;
  896.           }
  897.           sprintf(filename,"%s%s",fboard.upath,str);
  898.           if (!findfirst(filename,&filestat,0)) {
  899.             say_prompt(160);
  900.             return 0;
  901.           }
  902.           sprintf(s,"%s%s",fboard.upath,"FILES.BBS");
  903.           if ((handle=oopen(s,O_RDONLY | O_TEXT | O_DENYNONE))==-1);
  904.           else {
  905.                 while((!eof(handle)) && (strcmp(s,str))) {
  906.                     if(fgetsx(s,81,handle)==NULL) break;
  907.                     s[12]=0;
  908.                     rstrip(s);
  909.                     if (!strcmp(s,fname)) {
  910.                         cclose(handle);
  911.                         gprintf(0,"%s%s",fname,say_prompt(161));
  912.                         return 0;
  913.                     }
  914.                 }
  915.                 cclose(handle);
  916.            }
  917.        }
  918.        if (*filename == '.') {        /* Directory */
  919.                 say_prompt(160);
  920.                 return 0;
  921.        }
  922.        handle = oopen(filename,O_RDONLY | O_DENYNONE);
  923.        if (handle!= -1) {                    /* it aint there, s'ok */
  924.             r.h.ah=0x44;
  925.             r.h.al=0x00;
  926.             r.x.bx=handle;
  927.             int86(33,&r,&r);                /* see if device */
  928.             cclose(handle);                    /* close handle  */
  929.             if ((int)r.h.al == -1 || (r.h.al & 0x80)) {
  930.                 say_prompt(160);
  931.                 return 0;
  932.             }
  933.        }
  934.        if (!uselist) fname=strtok(0," ");
  935.        else fname=readfromlist(uname,0);
  936.    }
  937.   logem=0;
  938.   gprintf(0,say_prompt(287),proto.name,proto.abort);
  939.   if (*uname && uname && !uselist) {
  940.     gprintf(0,say_prompt(447),uname);
  941.   }
  942.   if(baud) {
  943.       tempsafe=safe;
  944.       safe=0;
  945.       strcpy(s,proto.spawnup);
  946.       replace(s,str);
  947.       gothere(conf.uptime,s,1,&proto);
  948.   }
  949.   if (!level || proto.dszlog) {
  950.               if (stristr(str,".RPK") && (stristr(fboard.upath,"\\MPORT"))) goto SkipEntry;
  951.               if(proto.dszlog) {
  952.                   do_dszlog(&proto,1);
  953.                   goto SkipEntry;
  954.               }
  955.               if(!proto.noname)temptotal=getentry(str,&proto);
  956.               else temptotal=getentry("*.*",&proto);
  957.               if (!temptotal) {
  958.                 say_prompt(163);
  959.                 goto NoSuccess;
  960.               }
  961. SkipEntry:
  962.               say_prompt(164);
  963.   }
  964.   else  {
  965. NoSuccess:
  966.         mprint(STOPDL);
  967.         sprintf(s,"Bad %c-U/L %s",proto.key,filename);
  968.         addtolog(s);
  969.         say_prompt(165);
  970.         timer_off=0;
  971.         safe=tempsafe;
  972.         return 0;
  973.   }
  974. DoLog:
  975.     if (!logem) return temptotal;
  976.     else autolog();
  977.     safe=tempsafe;
  978.     return temptotal;
  979. }
  980.  
  981.  
  982.  
  983. char * pascal getstuff (struct protocol *proto, char type) {
  984.  
  985.   int handle;
  986.   char s[133];
  987.   char choices[129];
  988.   char choice;
  989.   int register x;
  990.   struct ffblk f;
  991.   int flag;
  992.  
  993.   strset(choices,0);
  994.   *dlstr=0;
  995.   proto->key=0;
  996.  
  997.   if (findfirst("protocol.ctl",&filestat,0)) {
  998.         return dlstr;
  999.   }
  1000.   if ((handle=oopen(searchpath("protocol.ctl"),O_RDONLY | O_BINARY | O_DENYNONE))==-1) {
  1001.         return dlstr;
  1002.   }
  1003.   sprintf(s,"%sPROTOCOL.XBS",conf.menupath);
  1004.   flag=findfirst(s,&f,0);
  1005.  
  1006. ListAgain:
  1007.  
  1008.   if (flag) say_prompt(166);
  1009.   for (x=0;x<(filestat.ff_fsize/sizeof(struct protocol));x++) {
  1010.         if (eof(handle)==-1) break;
  1011.         if (x==129) break;
  1012.         if (_read(handle,proto,sizeof(struct protocol))<1) return dlstr;
  1013.         if (type & 64) {
  1014.             if (!proto->list) continue;
  1015.         }
  1016.         if (!type) strcpy(s,proto->spawnup);
  1017.         else strcpy(s,proto->spawndn);
  1018.         if (!*s) choices[x]=8;
  1019.         else {
  1020.             if(flag) {
  1021.                 if(!(x%2)) sprintf(s,"[%c]...%-28s",proto->key,proto->name);
  1022.                 else sprintf(s,"[%c]...%s\n",proto->key,proto->name);
  1023.             }
  1024.             choices[x]=proto->key;
  1025.             if (flag)printm(s);
  1026.         }
  1027.   }
  1028.   if(flag)printm("\n -> ");
  1029.   else readfile("PROTOCOL.XBS",0,0,1);
  1030.   helpnum=527;
  1031.   choice=*genin(1,0,1,1,ALLL);
  1032.   helpnum=0;
  1033.   if (!choice) {
  1034.     proto->key=0;
  1035.     return dlstr;
  1036.   }
  1037.   if (choice=='?') {
  1038.     if (!type || (type & 32)) say_prompt(431);
  1039.     else say_prompt(432);
  1040.     hitreturn();
  1041.     lseek(handle,0L,SEEK_SET);
  1042.     goto ListAgain;
  1043.   }
  1044.   if (strchr(choices,choice)==NULL) {
  1045.         lseek(handle,0L,SEEK_SET);
  1046.         goto ListAgain;
  1047.   }
  1048.   for (x=0;x<strlen(choices);x++) if (choice==choices[x]) break;
  1049.   lseek(handle,(long)x*sizeof(struct protocol),SEEK_SET);
  1050.   if (_read(handle,proto,sizeof(struct protocol))<1) return dlstr;
  1051.   cclose(handle);
  1052.   gprintf(0,"\n%s%s",proto->name,say_prompt(167));
  1053.   if (type==1 || (type & 128) || (type & 32) || (type & 64)) return dlstr;
  1054.   if (proto->noname && !type) return " ";
  1055.   if (proto->wild) say_prompt(168);
  1056.   if (proto->multi && !(type & 4)) say_prompt(282);
  1057.   if (proto->simul) say_prompt(444);
  1058.   say_prompt(169);
  1059.   if (!type) printm("send?\n-> ");
  1060.   else printm("receive?\n-> ");
  1061.   if (!proto->multi || (type & 4)) {
  1062.       helpnum=528;
  1063.       strcpy(dlstr,genin(13,0,1,0,FLE+(proto->wild*2)));
  1064.       helpnum=0;
  1065.   }
  1066.   else {
  1067.       helpnum=529;
  1068.       strcpy(dlstr,genin(76,0,1,0,FBATCH+(proto->wild)));
  1069.       helpnum=0;
  1070.   }
  1071.   if(*dlstr) {
  1072.     readfile("CHEKFILE.XBS",0,0,1);
  1073.   }
  1074.   return (dlstr);
  1075. }
  1076.  
  1077.  
  1078.  
  1079. word pascal getentry (char *namestring,struct protocol *proto) {
  1080.  
  1081.   char s[133];
  1082.   char filename[133];
  1083.   char tempath[133];
  1084.   char temporary[256];
  1085.   char *descriplines[255];
  1086.   char *fname;
  1087.   int register x;
  1088.   int register y;
  1089.   ulong total=0;
  1090.   char str[81];
  1091.   char postedmsg=0;
  1092.   struct date dos_date;
  1093.   struct fdate {
  1094.      bit day:   5;
  1095.      bit month: 4;
  1096.      bit year:  7;
  1097.   };
  1098.   union df {
  1099.      struct fdate fd;
  1100.      int x;
  1101.   } fdf;
  1102.   struct ffblk f;
  1103.   char far *ptr;
  1104.   char uselist=0;
  1105.   int temp;
  1106.   int handle;
  1107.   struct SREGS sregs;
  1108.  
  1109.     safe=0;
  1110.     if (*namestring=='@') uselist=1;
  1111.     strcpy(temporary,namestring);
  1112.     *namestring=0;
  1113.     if (!uselist) fname=strtok(temporary," ");
  1114.     else fname=readfromlist(temporary,1);
  1115.     while (fname!=NULL) {
  1116.        if(strchr(fname,':') || strchr(fname,'\\')) strcpy(filename,fname);
  1117.        else if(proto->noname)sprintf(filename,"%s%03hu\\%s",fboard.upath,nodenumber,fname);
  1118.        else sprintf(filename,"%s%s",fboard.upath,fname);
  1119.                   x=findfirst(filename,&f,0);
  1120.                   while (!x) {
  1121.                     if (!(fboard.flags & FREEUP)) {
  1122.                         user.upno++;
  1123.                         user.upk+=(ulong)(f.ff_fsize/1024L);
  1124.                         user.uktoday+=(word)(f.ff_fsize/1024L);
  1125.                     }
  1126.                     total+=(ulong)f.ff_fsize;
  1127.                     if (conf.touchup) {   /* TOUCH-UP FILE DATE */
  1128.                         if(strchr(fname,':') || strchr(fname,'\\')) {
  1129.                             strcpy(filename,fname);
  1130.                             ptr=strrchr(filename,'\\');
  1131.                             if(ptr!=NULL) {
  1132.                                 *ptr=0;
  1133.                                 strcat(filename,"\\");
  1134.                                 strcat(filename,f.ff_name);
  1135.                             }
  1136.                         }
  1137.                         else if(proto->noname)sprintf(filename,"%s%03hu\\%s",fboard.upath,nodenumber,f.ff_name);
  1138.                         else sprintf(filename,"%s%s",fboard.upath,fname);
  1139.                         getdate(&dos_date);
  1140.                         fdf.fd.day=dos_date.da_day;
  1141.                         fdf.fd.month=dos_date.da_mon;
  1142.                         fdf.fd.year=dos_date.da_year-1980;
  1143.                         ptr=filename;
  1144.                         r.x.dx=FP_OFF(ptr);
  1145.                         sregs.ds=FP_SEG(ptr);
  1146.                         r.h.ah=61;
  1147.                         r.h.al=64;
  1148.                         int86x(33,&r,&r,&sregs);  /* Open file */
  1149.                         temp=r.x.ax;              /* Save handle */
  1150.                         r.x.bx=temp;
  1151.                         r.h.ah=87;
  1152.                         r.h.al=1;
  1153.                         r.x.cx=(word)0;
  1154.                         r.x.dx=fdf.x;
  1155.                         int86(33,&r,&r);          /* Set time/date */
  1156.                         r.x.bx=temp;
  1157.                         r.h.ah=62;
  1158.                         int86(33,&r,&r);          /* Close file */
  1159.                     }
  1160.                     gprintf(LOGONLY,"%c-U/L %s (%lu bytes)",proto->key,filename,f.ff_fsize);
  1161.                     if(proto->noname) {
  1162.                         sprintf(tempath,"%s%03hu\\%s",fboard.upath,nodenumber,f.ff_name);
  1163.                         sprintf(filename,"%s%s",fboard.upath,f.ff_name);
  1164.                         r.h.ah=0x56;
  1165.                         r.x.dx=FP_OFF(tempath);
  1166.                         sregs.ds=FP_SEG(tempath);
  1167.                         r.x.di=FP_OFF(filename);
  1168.                         sregs.es=FP_SEG(filename);
  1169.                         int86x(33,&r,&r,&sregs);        /* Move file to real
  1170.                                                            upload directory */
  1171.                     }
  1172.                     x=0;
  1173.                     carrchk();
  1174.                     if (!conf.comments) goto SkipComments;
  1175.                     gprintf(0,"%s%s (%lu bytes):\n",say_prompt(170),f.ff_name,f.ff_fsize);
  1176.                     gprintf(0,say_prompt(171),conf.comments);
  1177.                     say_prompt(270);
  1178. DoComment:
  1179.                     say_prompt(269);
  1180.                     helpnum=530;
  1181.                     strcpy(str,genin(46,0,0,0,ALLL));
  1182.                     helpnum=0;
  1183.                     if ((x==0) && (strlen(str)<3)) {
  1184.                         timer_off=0;
  1185.                         goto DoComment;
  1186.                     }
  1187.                     if (*str) {
  1188.                         gprintf(LOGONLY,"Descr: %s",str);
  1189.                         descriplines[x]=(char *)mmalloc((word)82 * (word)sizeof(char));
  1190.                         descriplines[x+1]=NULL;
  1191.                         if (descriplines[x]==NULL) goto SkipComments;
  1192.                         sprintf(descriplines[x],"%s%s",say_prompt(348),str);
  1193.                         x++;
  1194.                         if (x<(int)conf.comments) goto DoComment;
  1195.                     }
  1196. SkipComments:
  1197.                         if ((mboard.attr & ASSOC) && (fboard.flags & FILEASSOC)) {
  1198.                             if(!conf.comments) goto ForceComment;
  1199.                             say_prompt(442);
  1200.                             helpnum=531;
  1201.                             if (*genin(1,0,1,1,YESNO)=='Y') {
  1202. ForceComment:
  1203.                                 helpnum=0;
  1204.                                 strcpy(assocfile,f.ff_name);
  1205.                                 if (!(level=(word)askwrite(0))) {
  1206.                                     if (!(level=(word)writemessage(0))) {
  1207.                                         level=(word)makemessage(0);
  1208.                                     }
  1209.                                 }
  1210.                                 if (level && (!conf.comments || conf.forcefilemsg)) goto ForceComment;
  1211.                                 if(!level) postedmsg=1;
  1212.                                 else postedmsg=0;
  1213.                                 *assocfile=0;
  1214.                                 goto DoneNow;
  1215.                             }
  1216.                             helpnum=0;
  1217.                         }
  1218. DoneNow:
  1219.                     sprintf(s,"%s%s",fboard.upath,"FILES.BBS");
  1220.                     if ((handle=oopen(s,O_RDWR | O_APPEND | O_TEXT | O_DENYWRITE))==-1) {
  1221.                         if((handle=ccreat(s,S_IWRITE))==-1) continue;
  1222.                     }
  1223.                     *s=0;
  1224.                     if(conf.comments) {
  1225.                         if(*descriplines[0]==';') *s=';';
  1226.                     }
  1227.                     strcat(s,say_prompt(440));
  1228.                     ffprintf(handle,s,f.ff_name,user.handle,'\r','\n');
  1229.                     ffprintf(handle," ;Area: %s\r\n",fboard.name);
  1230.                     if(postedmsg) ffprintf(handle," ;MSGID: %08lx\r\n",lastfilemsgid);
  1231.                     if(!conf.comments) goto BadFile;
  1232.                     for (y=0;y<x;y++) {
  1233.                         if (descriplines[y]) {
  1234.                             ffprintf(handle,"%s\r\n",descriplines[y]);
  1235.                             ffree(descriplines[y]);
  1236.                         }
  1237.                     }
  1238.                     cclose(handle);
  1239. BadFile:
  1240.                     x=findnext(&f);
  1241.                   }
  1242.        if (!uselist) fname=strtok(0," ");
  1243.        else fname=readfromlist(temporary,0);
  1244.    }
  1245.    if(proto->noname){
  1246.         sprintf(filename,"%s%03hu",fboard.upath,nodenumber);
  1247.         rmdir(filename);
  1248.    }
  1249.    if (total) say_prompt(172);
  1250.    timer_off=0;
  1251.    safe=1;
  1252.    if((word)(total/1024L)<1) return 1;
  1253.    return (word)(total/1024L);
  1254. }
  1255.  
  1256.  
  1257.  
  1258. char * pascal replace (s,fname)      /* Replaces *F w/ filename(s) */
  1259.  
  1260.   char *s;
  1261.   char *fname;
  1262.  
  1263. {
  1264.  
  1265.   static char str[256];
  1266.   char *p;
  1267.  
  1268.   if (!strstr(s,"*F")) return s;
  1269.   p=strstr(s,"*F");
  1270.   *p=0;
  1271.   strcpy(str,s);
  1272.   p+=2;
  1273.   strcat(str,fname);
  1274.   strcat(str,p);
  1275.   str[132]=0;
  1276.   strcpy(s,str);
  1277.   return s;
  1278. }
  1279.  
  1280.     char uploadordownload=0;
  1281.  
  1282. char * pascal readfromlist (char *filename, char type) { /* Reads files one at
  1283.                                                        a time from file
  1284.                                                        list for protocol
  1285.                                                        use (@list.ext)
  1286.                                                        Translates entries
  1287.                                                        from DSZLOG into
  1288.                                                        filenames if there
  1289.                                                        was no error        */
  1290.  
  1291.     static char str[255];
  1292.     char *p;
  1293.     int handle;
  1294.     register word x;
  1295.     static long markedplace=0;
  1296.  
  1297. ReStart:
  1298.  
  1299.     if ((handle=oopen(&filename[1],O_RDONLY | O_TEXT | O_DENYNONE))==-1) return NULL;
  1300.     if (!type) lseek(handle,markedplace,SEEK_SET);
  1301.     else lseek(handle,0,SEEK_SET);
  1302.     if (fgetsx(str,255,handle)==NULL) {
  1303.         cclose(handle);
  1304.         if(stristr(&filename[1],"DSZLOG"))unlink(&filename[1]);
  1305.         markedplace=0;
  1306.         return NULL;
  1307.     }
  1308.     markedplace=tell(handle);
  1309.     cclose(handle);
  1310.     stripcr(str);
  1311.  
  1312. #ifdef UDDEBUG
  1313.   gprintf(LOCALONLY,"\n\04%s: %s\n",&filename[1],str);
  1314. #endif
  1315.  
  1316.     if(stristr(&filename[1],"DSZLOG")) {
  1317.         p=strtok(str," ");
  1318.         if(!stricmp(str,"E") || !stricmp(str,"L") || !atol(strtok(0," "))) {
  1319.             type=0;
  1320.             goto ReStart;
  1321.         }
  1322.         for(x=0;x<8;x++) strtok(0," ");
  1323.         if(isupper(*str))uploadordownload=1;
  1324.         else uploadordownload=0;
  1325.         p=strtok(0," ");
  1326.         return p;
  1327.     }
  1328.     return str;
  1329. }
  1330.  
  1331.  
  1332.  
  1333. void pascal do_dls (char *uname,long filesize) {
  1334.  
  1335.     char s[133];
  1336.  
  1337.         if (!(fboard.flags & FREEFILES)) {
  1338.           user.downno++;
  1339.           user.downk+=(ulong)(filesize/1024L);
  1340.           user.dktoday+=(word)(filesize/1024L);
  1341.         }
  1342.         if (fboard.flags & COUNTDLS) {   /* TOUCH-UP FILE TIME */
  1343.             if(!strchr(uname,':') && !strchr(uname,'\\')) sprintf(s,"%s%s",fboard.dpath,uname);
  1344.             else strcpy(s,uname);
  1345.             add_one(s);
  1346.         }
  1347. }
  1348.  
  1349.  
  1350. void pascal do_dszlog (struct protocol *proto,char type) {
  1351.  
  1352.     int handle;
  1353.     int temp=0;
  1354.     char str[133];
  1355.     char file[133];
  1356.     char *p;
  1357.     char *ud;
  1358.     struct ffblk f;
  1359.  
  1360.     if(!getenv("DSZLOG")) return;
  1361.     sprintf(str,"DSZTEMP.%03hu",nodenumber);
  1362.     handle=ccreat(str,S_IWRITE);
  1363.     if(handle==-1) return;
  1364.     sprintf(str,"@%s",getenv("DSZLOG"));
  1365.     p=readfromlist(str,1);
  1366.     while(p!=NULL) {
  1367.         if(conf.debug) {
  1368.             if (proto->simul) {
  1369.                 if(!uploadordownload) ud="Downloaded";
  1370.                 else ud="Uploaded";
  1371.             }
  1372.             else if(!type) {
  1373.                 ud="Downloaded";
  1374.                 uploadordownload=0;
  1375.             }
  1376.             else if(type){
  1377.                 uploadordownload++;
  1378.                 ud="Uploaded";
  1379.             }
  1380.             gprintf(LOCALONLY,"\04DSZLog: %s %s\n",ud,p);
  1381.         }
  1382.         if(uploadordownload) {
  1383.             temp++;
  1384.             ffprintf(handle,"%s\r\n",p);
  1385.         }
  1386.         else {
  1387.             if(!strchr(p,':') && !strchr(p,'\\'))sprintf(file,"%s%s",fboard.dpath,p);
  1388.             else strcpy(file,p);
  1389.             if(!findfirst(file,&f,0)) {
  1390.                 if(!strchr(p,':') && !strchr(p,'\\'))sprintf(file,"%s%s",fboard.dpath,f.ff_name);
  1391.                 else strcpy(file,f.ff_name);
  1392.                 do_dls(file,f.ff_fsize);
  1393.                 gprintf(LOGONLY,"%c-D/L %s (%lu bytes)",proto->key,file,f.ff_fsize);
  1394.             }
  1395.         }
  1396.         p=readfromlist(str,0);
  1397.     }
  1398.     if(getenv("DSZLOG")) unlink(getenv("DSZLOG"));
  1399.     cclose(handle);
  1400.     proto->dszlog=0;
  1401.     sprintf(str,"@DSZTEMP.%03hu",nodenumber);
  1402.     if(temp) getentry(str,proto);
  1403.     unlink(&str[1]);
  1404. }
  1405.  
  1406.  
  1407.  
  1408. char pascal find_protocol (struct protocol *proto,char key) {
  1409.  
  1410.     register word x;
  1411.     int handle;
  1412.  
  1413.   proto->key=0;
  1414.   if (findfirst("protocol.ctl",&filestat,0)) {
  1415.         return 0;
  1416.   }
  1417.   if ((handle=oopen(searchpath("protocol.ctl"),O_RDONLY | O_BINARY | O_DENYNONE))==-1) {
  1418.         return 0;
  1419.   }
  1420.   for (x=0;x<(filestat.ff_fsize/sizeof(struct protocol));x++) {
  1421.     if (eof(handle)==-1) break;
  1422.     if (_read(handle,proto,sizeof(struct protocol))<1) break;
  1423.     if(proto->key==key) break;
  1424.   }
  1425.   cclose(handle);
  1426.   if(proto->key==key)return 1;
  1427.   return 0;
  1428. }
  1429.  
  1430.  
  1431. char pascal first_non_white (char *a) {
  1432.  
  1433.     char *b;
  1434.  
  1435.     b=a;
  1436.     while(*b && (*b==' ' || *b=='\t')) b++;
  1437.     if(*b) return *b;
  1438.     return 0;
  1439. }
  1440.