home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / UTIL / WWIVE / XFER.C < prev    next >
Text File  |  1992-05-05  |  38KB  |  1,745 lines

  1. /*****************************************************************************
  2.  
  3.                 WWIV Version 4
  4.                     Copyright (C) 1988-1991 by Wayne Bell
  5.  
  6. Distribution of the source code for WWIV, in any form, modified or unmodified,
  7. without PRIOR, WRITTEN APPROVAL by the author, is expressly prohibited.
  8. Distribution of compiled versions of WWIV is limited to copies compiled BY
  9. THE AUTHOR.  Distribution of any copies of WWIV not compiled by the author
  10. is expressly prohibited.
  11.  
  12.  
  13. *****************************************************************************/
  14.  
  15.  
  16.  
  17. #include "vars.h"
  18.  
  19. #pragma hdrstop
  20.  
  21. #include <dir.h>
  22.  
  23.  
  24.  
  25. #define SETREC(i)  lseek(dlf,((long) (i))*((long)sizeof(uploadsrec)),SEEK_SET);
  26.  
  27.  
  28. /* How far to indent extended descriptions */
  29. #define INDENTION 24
  30.  
  31. /* Max # of lines for extended description */
  32. #define MAX_LINES 10
  33.  
  34. /* If its OK to use the FSED for editing extended descriptions */
  35. #define FSED_OK ((okfsed()) && (0))
  36.  
  37. /* If this is defined, the system will put in "ASK" if a file isn't there */
  38. #define CHECK_FOR_EXISTANCE
  39.  
  40. /* the archive type to use */
  41. #define ARC_NUMBER 0
  42.  
  43.  
  44.  
  45. int check_batch_queue(char *fn)
  46. {
  47.   int i;
  48.  
  49.   for (i=0; i<numbatch; i++) {
  50.     if (strcmp(fn,batch[i].filename)==0)
  51.       if (batch[i].sending)
  52.         return(1);
  53.       else
  54.         return(-1);
  55.   }
  56.  
  57.   return(0);
  58. }
  59.  
  60.  
  61. int check_ul_event(int dn, uploadsrec *u)
  62. {
  63.   char s[161];
  64.  
  65.   if (syscfg.upload_c[0]) {
  66.     stuff_in(s,syscfg.upload_c,create_chain_file("CHAIN.TXT"),
  67.              directories[dn].path,stripfn(u->filename),"","");
  68.     run_external(s);
  69.     topscreen();
  70.     sprintf(s,"%s%s",directories[dn].path, stripfn(u->filename));
  71.     if (!exist(s)) {
  72.       sprintf(s,"File '%s' to %s deleted by UL event.",
  73.               u->filename, directories[dn].name);
  74.       sysoplog(s);
  75.       npr("File '%s' was deleted by upload event.\r\n",u->filename);
  76.       return(1);
  77.     }
  78.   }
  79.  
  80.   return(0);
  81. }
  82.  
  83.  
  84. int okfn(char *s)
  85. {
  86.   int i,l,ok;
  87.   unsigned char ch;
  88.  
  89.   ok=1;
  90.   l=strlen(s);
  91.   if ((s[0]=='-') || (s[0]==' '))
  92.     ok=0;
  93.   for (i=0; i<l; i++) {
  94.     ch=s[i];
  95.     if ((ch==' ') || (ch=='/') || (ch=='\\') || (ch==':') ||
  96.         (ch=='>') || (ch=='<') || (ch=='|')  || (ch=='+') ||
  97.         (ch==',') || (ch==';') || (ch>126))
  98.       ok=0;
  99.   }
  100.   return(ok);
  101. }
  102.  
  103.  
  104. char *make_abs_cmd(char *out)
  105. {
  106.   char s[161],s1[161],*ss,*ss1;
  107.  
  108.   strcpy(s1,out);
  109.   ss=strchr(s1,' ');
  110.   if (ss)
  111.     *ss=0;
  112.   strcpy(s,s1);
  113.   ss1=searchpath(s);
  114.   if (!ss1) {
  115.     sprintf(s,"%s.COM",s1);
  116.     ss1=searchpath(s);
  117.   }
  118.   if (!ss1) {
  119.     sprintf(s,"%s.EXE",s1);
  120.     ss1=searchpath(s);
  121.   }
  122.   if (!ss1) {
  123.     sprintf(s,"%s.BAT",s1);
  124.     ss1=searchpath(s);
  125.   }
  126.   if (ss1)
  127.     strcpy(s,ss1);
  128.   else {
  129.     strcpy(s,cdir);
  130.     strcat(s,s1);
  131.   }
  132.   if (ss) {
  133.     strcat(s," ");
  134.     strcat(s,ss+1);
  135.   }
  136.   strcpy(out,s);
  137.  
  138.   return(out);
  139. }
  140.  
  141. void get_arc_cmd(char *out, char *arcfn, int cmd, char *ofn)
  142. {
  143.   char *ss,*ss1,s[161],s1[161];
  144.   int i;
  145.  
  146.   out[0]=0;
  147.   ss=strchr(arcfn,'.');
  148.   if (ss==NULL)
  149.     return;
  150.   ++ss;
  151.   ss1=strchr(ss,'.');
  152.   while (ss1!=NULL) {
  153.     ss=ss1;
  154.     ++ss1;
  155.     ss1=strchr(ss,'.');
  156.   }
  157.   for (i=0; i<4; i++)
  158.     if (stricmp(ss,syscfg.arcs[i].extension)==0) {
  159.       switch(cmd) {
  160.         case 0: strcpy(s,syscfg.arcs[i].arcl); break;
  161.         case 1: strcpy(s,syscfg.arcs[i].arce); break;
  162.         case 2: strcpy(s,syscfg.arcs[i].arca); break;
  163.       }
  164.       if (s[0]==0)
  165.         return;
  166.       stuff_in(out,s,arcfn,ofn,"","","");
  167.       make_abs_cmd(out);
  168.       return;
  169.     }
  170.  
  171. }
  172.  
  173.  
  174. int list_arc_out(char *fn, char *dir)
  175. {
  176.   char s[161],s1[81];
  177.   int i=0;
  178.  
  179.   sprintf(s1,"%s%s",dir,fn);
  180.   get_arc_cmd(s,s1,0,"");
  181.   if (!okfn(fn))
  182.     s[0]=0;
  183.   if (exist(s1) && (s[0]!=0)) {
  184.     nl();
  185.     nl();
  186.     npr("1Archive listing for3 %s1:\r\n",fn);
  187.     nl();
  188.     i=do_external(s,1);
  189.     nl();
  190.   } else {
  191.     nl();
  192.     outs("6Unknown archive: ");
  193.     pl(fn);
  194.     nl();
  195.     i=0;
  196.   }
  197.   return(i);
  198. }
  199.  
  200.  
  201. int ratio_ok()
  202. {
  203.   int ok=1;
  204.   char s[101];
  205.  
  206.   if (!(thisuser.exempt & exempt_ratio))
  207.     if ((syscfg.req_ratio>0.0001) && (ratio()<syscfg.req_ratio)) {
  208.       ok=0;
  209.       nl();
  210.       nl();
  211.       sprintf(s,"1Your up/download ratio is6 %-5.3f1.  You need a ratio of 6%-5.3f 1to download.",
  212.     ratio(), syscfg.req_ratio);
  213.       pl(s);
  214.       nl();
  215.     }
  216.  
  217.   if (!(thisuser.exempt & exempt_post))
  218.     if ((syscfg.post_call_ratio>0.0001) && (post_ratio()<syscfg.post_call_ratio)) {
  219.       ok=0;
  220.       nl();
  221.       nl();
  222.       sprintf(s,"1Your post/call ratio is 6%-5.3f1.  You need a ratio of 6%-5.3f to download.",
  223.     post_ratio(), syscfg.post_call_ratio);
  224.       pl(s);
  225.       nl();
  226.     }
  227.  
  228.  
  229.   return(ok);
  230. }
  231.  
  232.  
  233. int dcs()
  234. {
  235.   if (cs())
  236.     return(1);
  237.   if (thisuser.dsl>=100)
  238.     return(1);
  239.   else
  240.     return(0);
  241. }
  242.  
  243.  
  244. void dliscan1(int dn)
  245. {
  246.   char s[81];
  247.   int i;
  248.   uploadsrec u;
  249.   long l;
  250.  
  251.   sprintf(s,"%s%s.DIR",syscfg.datadir,directories[dn].filename);
  252.   dlf=open(s,O_RDWR | O_BINARY | O_CREAT, S_IREAD | S_IWRITE);
  253.   i=filelength(dlf)/sizeof(uploadsrec);
  254.   if (i==0) {
  255.     memset(&u, 0, sizeof(uploadsrec));
  256.     strcpy(u.filename,"|MARKER|");
  257.     time(&l);
  258.     u.daten=l;
  259.     SETREC(0);
  260.     write(dlf,(void *)&u,sizeof(uploadsrec));
  261.   } else {
  262.     SETREC(0);
  263.     read(dlf,(void *)&u,sizeof(uploadsrec));
  264.     if (strcmp(u.filename,"|MARKER|")) {
  265.       numf=u.numbytes;
  266.       memset(&u, 0, sizeof(uploadsrec));
  267.       strcpy(u.filename,"|MARKER|");
  268.       time(&l);
  269.       u.daten=l;
  270.       u.numbytes = numf;
  271.       SETREC(0);
  272.       write(dlf, &u, sizeof(uploadsrec));
  273.     }
  274.   }
  275.   numf=u.numbytes;
  276.   this_date = u.daten;
  277.   dir_dates[dn]=this_date;
  278.  
  279.   sprintf(s,"%s%s.EXT",syscfg.datadir,directories[dn].filename);
  280.   edlf=open(s,O_RDWR | O_BINARY | O_CREAT, S_IREAD | S_IWRITE);
  281. }
  282.  
  283. void dliscan_hash(int dn)
  284. {
  285.   char s[81];
  286.   int i,dlf;
  287.   uploadsrec u;
  288.  
  289.   if ((dn>=num_dirs) || (dir_dates[dn]))
  290.     return;
  291.  
  292.   sprintf(s,"%s%s.DIR",syscfg.datadir,directories[dn].filename);
  293.   dlf=open(s,O_RDWR | O_BINARY);
  294.   if (dlf<0) {
  295.     time(&(dir_dates[dn]));
  296.     return;
  297.   }
  298.   i=filelength(dlf)/sizeof(uploadsrec);
  299.   if (i<1) {
  300.     time(&(dir_dates[dn]));
  301.   } else {
  302.     SETREC(0);
  303.     read(dlf,(void *)&u,sizeof(uploadsrec));
  304.     if (strcmp(u.filename,"|MARKER|")==0) {
  305.       dir_dates[dn]=u.daten;
  306.     } else {
  307.       time(&(dir_dates[dn]));
  308.     }
  309.   }
  310.   close(dlf);
  311. }
  312.  
  313.  
  314. void dliscan()
  315. {
  316.   dliscan1(udir[curdir].subnum);
  317. }
  318.  
  319.  
  320. void closedl()
  321. {
  322.   if (dlf>0) {
  323.     close(dlf);
  324.     dlf=-1;
  325.   }
  326.   if (edlf>0) {
  327.     close(edlf);
  328.     edlf=-1;
  329.   }
  330. }
  331.  
  332. void add_extended_description(char *fn, char *desc)
  333. {
  334.   ext_desc_type ed;
  335.  
  336.   strcpy(ed.name,fn);
  337.   ed.len=strlen(desc);
  338.   lseek(edlf,0L,SEEK_END);
  339.   write(edlf,&ed,sizeof(ext_desc_type));
  340.   write(edlf,desc,ed.len);
  341. }
  342.  
  343.  
  344. void delete_extended_description(char *fn)
  345. {
  346.   ext_desc_type ed;
  347.   long r,w,l1;
  348.   char *ss=NULL;
  349.  
  350.   r=w=0;
  351.   if ((ss=malloca(10240L))==NULL)
  352.     return;
  353.   l1=filelength(edlf);
  354.   while (r<l1) {
  355.     lseek(edlf,r,SEEK_SET);
  356.     read(edlf,&ed,sizeof(ext_desc_type));
  357.     if (ed.len<10000) {
  358.       read(edlf,ss,ed.len);
  359.       if (strcmp(fn,ed.name)) {
  360.         if (r!=w) {
  361.           lseek(edlf,w,SEEK_SET);
  362.           write(edlf,&ed,sizeof(ext_desc_type));
  363.           write(edlf,ss,ed.len);
  364.         }
  365.         w +=(sizeof(ext_desc_type) + ed.len);
  366.       }
  367.     }
  368.     r += (sizeof(ext_desc_type) + ed.len);
  369.   }
  370.   farfree(ss);
  371.   chsize(edlf,w);
  372. }
  373.  
  374.  
  375. char *read_extended_description(char *fn)
  376. {
  377.   ext_desc_type ed;
  378.   long l,l1;
  379.   char *ss=NULL;
  380.  
  381.   l=0;
  382.   l1=filelength(edlf);
  383.   while (l<l1) {
  384.     lseek(edlf,l,SEEK_SET);
  385.     l += (long) read(edlf,&ed,sizeof(ext_desc_type));
  386.     if (strcmp(fn,ed.name)==0) {
  387.       ss=malloca((long) ed.len+10);
  388.       if (ss) {
  389.         read(edlf,ss,ed.len);
  390.         ss[ed.len]=0;
  391.       }
  392.       return(ss);
  393.     } else
  394.       l += (long) ed.len;
  395.   }
  396.   return(NULL);
  397. }
  398.  
  399.  
  400. void print_extended(char *fn, int *abort, unsigned char numlist, int indent)
  401. {
  402.   char *ss;
  403.   int next=0;
  404.   unsigned char numl=0;
  405.   int cpos=0;
  406.   char ch,s[81];
  407.   int i,fc;
  408.  
  409.   fc=thisuser.sysstatus & sysstatus_funky_colors;
  410.  
  411.   ss=read_extended_description(fn);
  412.   if (ss) {
  413.     ch=10;
  414.     while ((ss[cpos]) && (!(*abort)) && (numl<numlist)) {
  415.       if ((ch==10) && (indent)) {
  416.         if (okansi()) {
  417.           if (fc)
  418.             sprintf(s,"3│\x1b[%dC1",INDENTION);
  419.           else
  420.             sprintf(s,"│\x1b[%dC",INDENTION);
  421.         } else {
  422.           outstr(":");
  423.           for (i=0; i<INDENTION; i++)
  424.             s[i]=32;
  425.           s[INDENTION]=0;
  426.         }
  427.         osan(s,abort,&next);
  428.       }
  429.       ch=ss[cpos++];
  430.       if ((ch==13) && (indent)) {
  431.        while (!(wherex()>=77))
  432.           outstr(" ");
  433.        if (okansi()) {
  434.          if (fc)
  435.            outstr("3│");
  436.          else
  437.          outstr("│");
  438.        } else
  439.          outstr(":");
  440.       }
  441.       outchr(ch);
  442.       checka(abort,&next);
  443.       if (ch==10)
  444.         ++numl;
  445.       else {
  446.         if ((ch!=13) && (wherex()>=77)) {
  447.         while (!(wherex()>=77))
  448.       outstr(" ");
  449.           if (fc)
  450.             ansic(3);
  451.           if (okansi())
  452.             outstr("│");
  453.           else
  454.             outstr(":");
  455.           osan("\r\n",abort,&next);
  456.           ch=10;
  457.         }
  458.       }
  459.     }
  460.     if (wherex())
  461.       nl();
  462.   }
  463.   farfree(ss);
  464. }
  465.  
  466.  
  467.  
  468. void modify_extended_description(char **sss)
  469. {
  470.   char s[161],s1[161];
  471.   int f,ii,i,i1,i2;
  472.  
  473.   if (*sss)
  474.     ii=1;
  475.   else
  476.     ii=0;
  477.   do {
  478.     if (ii) {
  479.       nl();
  480.       if (FSED_OK)
  481.     prt(3,"Modify the extended description5? ");
  482.       else
  483.     prt(7,"Enter a new extended description1? ");
  484.       if (!yn())
  485.         return;
  486.     } else {
  487.       nl();
  488.       prt(7,"Enter an extended description1? ");
  489.       if (!yn())
  490.         return;
  491.     }
  492.     if (FSED_OK) {
  493.       sprintf(s,"%sEXTENDED.DSC", syscfg.tempdir);
  494.       if (*sss) {
  495.         f=open(s,O_RDWR | O_BINARY | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
  496.         write(f,*sss,strlen(*sss));
  497.         close(f);
  498.         farfree(*sss);
  499.         *sss=NULL;
  500.       } else
  501.         unlink(s);
  502.       i=thisuser.screenchars;
  503.       if (thisuser.screenchars>(76-INDENTION))
  504.         thisuser.screenchars=76-INDENTION;
  505.       i1=external_edit("extended.dsc",syscfg.tempdir,(int) thisuser.defed-1,MAX_LINES);
  506.       thisuser.screenchars=i;
  507.       if (i1) {
  508.         if ((*sss=malloca(10240))==NULL)
  509.           return;
  510.         f=open(s,O_RDWR | O_BINARY);
  511.         read(f,*sss,(int) filelength(f));
  512.         (*sss)[filelength(f)]=0;
  513.         close(f);
  514.       }
  515.     } else {
  516.       if (*sss)
  517.         farfree(*sss);
  518.       if ((*sss=malloca(10240))==NULL)
  519.         return;
  520.       *sss[0]=0;
  521.       i=1;
  522.       nl();
  523.       sprintf(s,"1Enter up to 3%d 1lines, 3%d 1chars each.",MAX_LINES,78-INDENTION);
  524.       pl(s);
  525.       nl();
  526.       s[0]=0;
  527.       i1=thisuser.screenchars;
  528.       if (thisuser.screenchars>(76-INDENTION))
  529.         thisuser.screenchars=76-INDENTION;
  530.       do {
  531.         ansic(2);
  532.         npr("%d: ",i);
  533.         ansic(0);
  534.         s1[0]=0;
  535.         inli(s1,s,90,1);
  536.         i2=strlen(s1);
  537.         if (i2 && (s1[i2-1]==1))
  538.           s1[i2-1]=0;
  539.         if (s1[0]) {
  540.           strcat(s1,"\r\n");
  541.           strcat(*sss,s1);
  542.         }
  543.       } while ((i++<10) && (s1[0]));
  544.       thisuser.screenchars=i1;
  545.       if (*sss[0]==0) {
  546.         farfree(*sss);
  547.         *sss=NULL;
  548.       }
  549.     }
  550.     prt(3,"Is this what you want5? ");
  551.     i=!yn();
  552.     if (i) {
  553.       farfree(*sss);
  554.       *sss=NULL;
  555.     }
  556.   } while (i);
  557. }
  558.  
  559.  
  560. void align(char *s)
  561. {
  562.   char f[40],e[40],s1[20],*s2;
  563.   int i,i1,i2;
  564.  
  565.   i1=0;
  566.   if (s[0]=='.')
  567.     i1=1;
  568.   for (i=0; i<strlen(s); i++)
  569.     if ((s[i]=='\\') || (s[i]=='/') || (s[i]==':') || (s[i]=='<') ||
  570.       (s[i]=='>') || (s[i]=='|'))
  571.       i1=1;
  572.   if (i1) {
  573.     strcpy(s,"        .   ");
  574.     return;
  575.   }
  576.   s2=strchr(s,'.');
  577.   if (s2==NULL) {
  578.     e[0]=0;
  579.   } else {
  580.     strcpy(e,&(s2[1]));
  581.     e[3]=0;
  582.     s2[0]=0;
  583.   }
  584.   strcpy(f,s);
  585.  
  586.   for (i=strlen(f); i<8; i++)
  587.     f[i]=32;
  588.   f[8]=0;
  589.   i1=0;
  590.   i2=0;
  591.   for (i=0; i<8; i++) {
  592.     if (f[i]=='*')
  593.       i1=1;
  594.     if (f[i]==' ')
  595.       i2=1;
  596.     if (i2)
  597.       f[i]=' ';
  598.     if (i1)
  599.       f[i]='?';
  600.   }
  601.  
  602.   for (i=strlen(e); i<3; i++)
  603.     e[i]=32;
  604.   e[3]=0;
  605.   i1=0;
  606.   for (i=0; i<3; i++) {
  607.     if (e[i]=='*')
  608.       i1=1;
  609.     if (i1)
  610.       e[i]='?';
  611.   }
  612.  
  613.   for (i=0; i<12; i++)
  614.     s1[i]=32;
  615.   strcpy(s1,f);
  616.   s1[8]='.';
  617.   strcpy(&(s1[9]),e);
  618.   strcpy(s,s1);
  619.   for (i=0; i<12; i++)
  620.     s[i]=upcase(s[i]);
  621. }
  622.  
  623.  
  624. int compare(char *s1, char *s2)
  625. {
  626.   int ok,i;
  627.  
  628.   ok=1;
  629.   for (i=0; i<12; i++)
  630.     if ((s1[i]!=s2[i]) && (s1[i]!='?') && (s2[i]!='?'))
  631.       ok=0;
  632.   return(ok);
  633. }
  634.  
  635.  
  636. void printinfo(uploadsrec *u, int *abort)
  637. {
  638.   char s[85],s1[40],s2[81];
  639.   int i,next,fc;
  640.  
  641.   fc=thisuser.sysstatus & sysstatus_funky_colors;
  642.  
  643.   if (fc)
  644.     ansic(3);
  645.   if (okansi())
  646.     strcpy(s,"│ ");
  647.   else
  648.     strcpy(s,": ");
  649.   osan(s,abort,&next);
  650.   strncpy(s,u->filename,8);
  651.   s[8]=0;
  652.   if (fc)
  653.     ansic(2);
  654.   osan(s,abort,&next);
  655.   strncpy(s,&((u->filename)[8]),4);
  656.   s[4]=0;
  657.   if (fc)
  658.     ansic(2);
  659.   osan(s,abort,&next);
  660.   if (fc)
  661.     ansic(3);
  662.   if (okansi())
  663.     osan(" │ ",abort,&next);
  664.   else
  665.     osan(" : ",abort,&next);
  666.  
  667.   ltoa((((u->numbytes)+1023)/1024),s1,10);
  668.   strcat(s1,"k");
  669.  
  670. #ifdef CHECK_FOR_EXISTANCE
  671.   strcpy(s2,directories[udir[curdir].subnum].path);
  672.   strcat(s2,u->filename);
  673.   if (!exist(s2))
  674.     strcpy(s1,"REQ");
  675. #endif
  676.  
  677.   for (i=0; i<5-strlen(s1); i++)
  678.     s[i]=32;
  679.   s[i]=0;
  680.   strcat(s,s1);
  681.   if (fc)
  682.     ansic(5);
  683.   osan(s,abort,&next);
  684.  
  685.   if (fc)
  686.     ansic(3);
  687.   if (okansi())
  688.     osan(" │ ",abort,&next);
  689.   else
  690.     osan(" : ",abort,&next);
  691.   if (fc)
  692.     ansic(1);
  693.   if (okansi())
  694.     if (fc)
  695.       sprintf(s,"%-51.51s 3│",u->description);
  696.     else
  697.       sprintf(s,"%-51.51s │",u->description);
  698.   else
  699.     sprintf(s,"%-51.51s :",u->description);
  700.   pla(s,abort);
  701.   if ((!*abort) && (thisuser.num_extended) && (u->mask & mask_extended))
  702.     print_extended(u->filename,abort,thisuser.num_extended,1);
  703.   if (!(*abort))
  704.     ++num_listed;
  705. }
  706.  
  707.  
  708. void printtitle(int *abort)
  709. {
  710.   char s[81],s1[20],s2[101];
  711.   int i,i1,fc;
  712.  
  713.   fc=thisuser.sysstatus & sysstatus_funky_colors;
  714.  
  715.   nl();
  716.   nl();
  717.   npr("5Area:7 [1%s7]",directories[udir[curdir].subnum].name," - ",udir[curdir].keys,"");
  718.   nl();
  719.   if (okansi()) {
  720.     if (fc)
  721.       ansic(3);
  722.     pla("┌──────────────┬───────┬─────────────────────────────────────────────────────┐",abort);
  723.     if (fc)
  724.       sprintf(s2,"3│ 2Filename.Ext 3│ 5Size 3 │ 1Description                      Total Files:   %3d 3│",numf);
  725.     else
  726.       sprintf(s2,"│ Filename.Ext │ Size  │ Description                      Total Files:   %3d │",numf);
  727.     pla(s2,abort);
  728.     if (fc)
  729.       ansic(3);
  730.     pla("├──────────────┼───────┼─────────────────────────────────────────────────────┤",abort);
  731.   } else {
  732.     pla("+--------------+-------+-----------------------------------------------------+",abort);
  733.     sprintf(s2,": Filename.Ext : Size  : Description                      Total Files:   %3d :",numf);
  734.     pla(s2,abort);
  735.     pla("+--------------+-------+-----------------------------------------------------+",abort);
  736.   }
  737. }
  738.  
  739.  
  740. void file_mask(char *s)
  741. {
  742.   nl();
  743.   helpl=9;
  744.   prt(1,"File mask3: ");
  745.   input(s,12);
  746.   if (s[0]==0)
  747.     strcpy(s,"*.*");
  748.   if (strchr(s,'.')==NULL)
  749.     strcat(s,".*");
  750.   align(s);
  751.   nl();
  752. }
  753.  
  754.  
  755. void listfiles()
  756. {
  757.   char s[81];
  758.   int i,abort,fc;
  759.   uploadsrec u;
  760.  
  761.   fc=thisuser.sysstatus & sysstatus_funky_colors;
  762.   dliscan();
  763.   file_mask(s);
  764.   abort=0;
  765.   num_listed=0;
  766.   printtitle(&abort);
  767.   for (i=1; (i<=numf) && (!abort) && (!hangup); i++) {
  768.     SETREC(i);
  769.     read(dlf,(void *)&u,sizeof(uploadsrec));
  770.     if (compare(s,u.filename))
  771.       printinfo(&u,&abort);
  772.   }
  773.   closedl();
  774.   if (!abort) {
  775.    if (fc)
  776.      ansic(3);
  777.    if (okansi())
  778.      pla("└──────────────┴───────┴─────────────────────────────────────────────────────┘",&abort);
  779.    else
  780.        pla("+--------------+-------+-----------------------------------------------------+",&abort);
  781.       nl();
  782.  
  783.       sprintf(s,"3[ 2Files listed:1 %d",num_listed);
  784.       outstr(s);
  785.       pl(" 3]");
  786.   nl();
  787.  }
  788. }
  789.  
  790.  
  791.  
  792. void nscandir(int d, int *abort,int title)
  793. {
  794.   int i,od,dt,fc,pc;
  795.   uploadsrec u;
  796.   char s[81];
  797.  
  798.   fc=thisuser.sysstatus & sysstatus_funky_colors;
  799.   od=curdir;
  800.   curdir=d;
  801.   dt=title;
  802.   pc=0;
  803.   dliscan();
  804.   for (i=1; (i<=numf) && (!(*abort)) && (!hangup); i++) {
  805.     SETREC(i);
  806.     read(dlf,(void *)&u,sizeof(uploadsrec));
  807.     if (u.daten>=nscandate) {
  808.       if (dt) {
  809.         printtitle(abort);
  810.         dt=0;
  811.         pc=1;
  812.       }
  813.       printinfo(&u,abort);
  814.     }
  815.   }
  816.   if ((pc) && (!(*abort))) {
  817.     if (fc)
  818.       ansic(3);
  819.     if (okansi())
  820.       pl("└──────────────┴───────┴─────────────────────────────────────────────────────┘");
  821.     else
  822.       pl("+--------------+-------+-----------------------------------------------------+");
  823.     nl();
  824.     pc=0;
  825.   }
  826.   closedl();
  827.   curdir=od;
  828. }
  829.  
  830.  
  831.  
  832. void nscanall()
  833. {
  834.   int abort,i,i1;
  835.   char s[81];
  836.  
  837.   abort=0;
  838.   num_listed=0;
  839.   for (i=0; (i<64) && (!abort) && (udir[i].subnum!=-1); i++) {
  840.     i1=udir[i].subnum;
  841.     if (i1>=32) {
  842.       if (thisuser.nscn2 & (1L << (i1-32)))
  843.         nscandir(i,&abort,1);
  844.     } else {
  845.       if (thisuser.nscn1 & (1L << i1))
  846.         nscandir(i,&abort,1);
  847.     }
  848.   }
  849.   if ((num_listed) && (!abort)) {
  850.     nl();
  851.     nl();
  852.     sprintf(s,"1Files listed:7 %d",num_listed);
  853.     pl(s);
  854.     nl();
  855.   }
  856. }
  857.  
  858.  
  859. void searchall()
  860. {
  861.   int i,i1,pts,abort,pty,ocd,pc,fc;
  862.   char s[81],s1[81];
  863.   uploadsrec u;
  864.  
  865.   fc=thisuser.sysstatus & sysstatus_funky_colors;
  866.   abort=0;
  867.   ocd=curdir;
  868.   pc=0;
  869.   nl();
  870.   nl();
  871.   pl("Search all directories.");
  872.   file_mask(s);
  873.   num_listed=0;
  874.   for (i=0; (i<64) && (!abort) && (!hangup) && (udir[i].subnum!=-1); i++) {
  875.     i1=udir[i].subnum;
  876.     pts=0;
  877.     if (i1>=32) {
  878.       if (thisuser.nscn2 & (1L << (i1-32)))
  879.         pts=1;
  880.     } else {
  881.       if (thisuser.nscn1 & (1L << i1))
  882.         pts=1;
  883.     }
  884.     pts=1;
  885.     /* remove pts=1 to search only marked directories */
  886.     if (pts) {
  887.       curdir=i;
  888.       dliscan();
  889.       pty=1;
  890.       for (i1=1; (i1<=numf) && (!abort) && (!hangup); i1++) {
  891.         SETREC(i1);
  892.         read(dlf,(void *)&u,sizeof(uploadsrec));
  893.         if (compare(s,u.filename)) {
  894.           if (pty) {
  895.             printtitle(&abort);
  896.             pty=0;
  897.             pc=1;
  898.           }
  899.           printinfo(&u,&abort);
  900.         }
  901.       }
  902.       if (pc) {
  903.         if (fc)
  904.           ansic(3);
  905.         if (okansi())
  906.           pla("└──────────────┴───────┴─────────────────────────────────────────────────────┘",&abort);
  907.         else
  908.           pla("+--------------+-------+-----------------------------------------------------+",&abort);
  909.         nl();
  910.         pc=0;
  911.       }
  912.       closedl();
  913.     }
  914.   }
  915.   curdir=ocd;
  916.   if ((num_listed) && (!abort)) {
  917.     nl();
  918.     nl();
  919.     sprintf(s,"Files listed: %d",num_listed);
  920.     pl(s);
  921.     nl();
  922.   }
  923. }
  924.  
  925.  
  926.  
  927. int recno(char *s)
  928. {
  929.   int i;
  930.   uploadsrec u;
  931.  
  932.   i=1;
  933.   if (numf<1)
  934.     return(-1);
  935.   SETREC(i);
  936.   read(dlf,(void *)&u,sizeof(uploadsrec));
  937.   while ((i<numf) && (compare(s,u.filename)==0)) {
  938.     ++i;
  939.     SETREC(i);
  940.     read(dlf,(void *)&u,sizeof(uploadsrec));
  941.   }
  942.   if (compare(s,u.filename))
  943.     return(i);
  944.   else
  945.     return(-1);
  946. }
  947.  
  948.  
  949. int nrecno(char *s,int i1)
  950. {
  951.   int i;
  952.   uploadsrec u;
  953.  
  954.   i=i1+1;
  955.   if ((numf<1) || (i1>=numf))
  956.     return(-1);
  957.  
  958.   SETREC(i);
  959.   read(dlf,(void *)&u,sizeof(uploadsrec));
  960.   while ((i<numf) && (compare(s,u.filename)==0)) {
  961.     ++i;
  962.     SETREC(i);
  963.     read(dlf,(void *)&u,sizeof(uploadsrec));
  964.   }
  965.   if (compare(s,u.filename))
  966.     return(i);
  967.   else
  968.     return(-1);
  969. }
  970.  
  971.  
  972. int printfileinfo(uploadsrec *u, int dn)
  973. {
  974.   char s[81];
  975.   double d;
  976.   int i,abort;
  977.  
  978.   d=((double) (((u->numbytes)+127)/128)) *
  979.     (1620.0) /
  980.     ((double) (modem_speed));
  981.   npr("1Filename   : %s\r\n", stripfn(u->filename));
  982.   npr("2Description: %s\r\n", u->description);
  983.   npr("3File size  : %dk\r\n", ((u->numbytes)+1023)/1024);
  984.   npr("5Apprx. time: %s\r\n", ctim(d));
  985.   npr("7Uploaded on: %s\r\n", u->date);
  986.   npr("1Uploaded by: %s\r\n", u->upby);
  987.   npr("2Times D/L'd: %d\r\n", u->numdloads);
  988.   nl();
  989.   abort=0;
  990.   if (u->mask & mask_extended) {
  991.     pl("3Extended Description: ");
  992.     print_extended(u->filename,&abort,255,0);
  993.   }
  994.  
  995.   sprintf(s,"%s%s",directories[dn].path,u->filename);
  996.   if (!exist(s)) {
  997.     nl();
  998.     pl("1->7MUST BE REQUESTED1<-");
  999.     nl();
  1000.     prt(1,"Request file?");
  1001.     if (yn()) {
  1002.       sprintf(irt,"File Request5: 1%s", stripfn(u->filename));
  1003.       irt_name[0]=0;
  1004.       email(1,0,1,0);
  1005.       return(-1);
  1006.       }
  1007.   }
  1008.  
  1009.   if (nsl()>=d)
  1010.     return(1);
  1011.   else
  1012.     return(0);
  1013. }
  1014.  
  1015.  
  1016. void upload(int dn)
  1017. {
  1018.   directoryrec d;
  1019.   uploadsrec u,u1;
  1020.   int i,i1,i2,ok,xfer,f;
  1021.   char s[255],s1[81],*ss;
  1022.   long l;
  1023.   double ti;
  1024.  
  1025.   dliscan1(dn);
  1026.   d=directories[dn];
  1027.   if (numf>=d.maxfiles) {
  1028.     nl();
  1029.     nl();
  1030.     pl("3This directory is currently full5.");
  1031.     nl();
  1032.     closedl();
  1033.     return;
  1034.   }
  1035.   if ((d.mask & mask_no_uploads) && (!dcs())) {
  1036.     nl();
  1037.     nl();
  1038.     pl("3Uploads are not allowed5.");
  1039.     nl();
  1040.     closedl();
  1041.     return;
  1042.   }
  1043.   nl();
  1044.   l=(long)freek1(d.path);
  1045.   sprintf(s,"7Upload 1- 3%ldk free5.",l);
  1046.   pl(s);
  1047.   nl();
  1048.   if (l<100) {
  1049.     pl("3Not enough disk space to upload here5.");
  1050.     nl();
  1051.     closedl();
  1052.     return;
  1053.   }
  1054.   prt(1,"What's the filename3? ");
  1055.   input(s,12);
  1056.   if (!okfn(s))
  1057.     s[0]=0;
  1058.   align(s);
  1059.   if (strchr(s,'?')) {
  1060.     closedl();
  1061.     return;
  1062.   }
  1063.   if (d.mask & mask_archive) {
  1064.     ok=0;
  1065.     s1[0]=0;
  1066.     for (i=0; i<4; i++) {
  1067.       if (syscfg.arcs[i].extension[0] && syscfg.arcs[i].extension[0]!=' ') {
  1068.         if (s1[0])
  1069.           strcat(s1,", ");
  1070.         strcat(s1,syscfg.arcs[i].extension);
  1071.         if (strcmp(s+9,syscfg.arcs[i].extension)==0)
  1072.           ok=1;
  1073.       }
  1074.     }
  1075.     if (!ok) {
  1076.       nl();
  1077.       pl("3Sorry, all uploads to this dir must");
  1078.       pl("3be archived.  Supported types are:");
  1079.       pl(s1);
  1080.       nl();
  1081.       closedl();
  1082.       return;
  1083.     }
  1084.   }
  1085.   strcpy(u.filename,s);
  1086.   u.ownerusr=usernum;
  1087.   u.ownersys=0;
  1088.   u.numdloads=0;
  1089.   u.filetype=0;
  1090.   u.mask=0;
  1091.   strcpy(u.upby,nam1(&thisuser,usernum,syscfg.systemnumber));
  1092.   strcpy(u.date,date());
  1093.   nl();
  1094.   ok=1;
  1095.   xfer=1;
  1096.   if (check_batch_queue(u.filename)) {
  1097.     ok=0;
  1098.     nl();
  1099.     pl("1That file is already in the batch queue.");
  1100.     nl();
  1101.   } else {
  1102.     sprintf(s1,"3Upload 1'5%s1' 3to 5%s1? ",s,d.name);
  1103.     if (strcmp(s,"        .   "))
  1104.       prt(5,s1);
  1105.     else
  1106.       ok=0;
  1107.   }
  1108.   if ((ok) && (yn())) {
  1109.     sprintf(s1,"%s%s",d.path,s);
  1110.     if (exist(s1)) {
  1111.       if (dcs()) {
  1112.         xfer=0;
  1113.         nl();
  1114.         nl();
  1115.     pl("1File already exists7.");
  1116.     prt(3,"Add to database anyway5? ");
  1117.         if (yn()==0)
  1118.           ok=0;
  1119.       } else {
  1120.         nl();
  1121.         nl();
  1122.     pl("3That file is already here5.");
  1123.     nl();
  1124.     ok=0;
  1125.       }
  1126.     } else
  1127.       if (!incom) {
  1128.         nl();
  1129.     pl("3File isn't already there5.");
  1130.     pl("3Can't upload locally5.");
  1131.     nl();
  1132.     ok=0;
  1133.       }
  1134.     if ((d.mask & mask_PD) && (ok)) {
  1135.       nl();
  1136.       prt(3,"Is this program PD5/3Shareware5? ");
  1137.       if (!yn()) {
  1138.         nl();
  1139.     pl("3This directory is for Public Domain/");
  1140.     pl("3Shareware programs ONLY.  Please do not");
  1141.     pl("3upload other programs.  If you have");
  1142.     pl("3trouble with this policy, please contact");
  1143.     pl("3the sysop.");
  1144.     nl();
  1145.     sprintf(s,"Wanted to upload '%s'",u.filename);
  1146.     add_ass(5,s);
  1147.     ok=0;
  1148.       } else
  1149.         u.mask=mask_PD;
  1150.     }
  1151.     if (ok) {
  1152.       nl();
  1153.       pl("1Please enter a one line description5.");
  1154.       outstr(": ");
  1155.       inputl(u.description,51);
  1156.       nl();
  1157.       ss=NULL;
  1158.       modify_extended_description(&ss);
  1159.       if (ss) {
  1160.         add_extended_description(u.filename,ss);
  1161.         u.mask |= mask_extended;
  1162.         farfree(ss);
  1163.       }
  1164.       nl();
  1165.       if (xfer) {
  1166.         ti=timer();
  1167.         receive_file(s1,&ok,&u.filetype, u.filename, dn);
  1168.         ti=timer()-ti;
  1169.         if (ti<0)
  1170.           ti += 24.0*3600.0;
  1171.         thisuser.extratime += ti;
  1172.       }
  1173.       if (ok) {
  1174.         if (ok==1) {
  1175.           f=open(s1,O_RDONLY | O_BINARY);
  1176.           if (f<0) {
  1177.             ok=0;
  1178.             nl();
  1179.             nl();
  1180.             pl("DOS error - File not found.");
  1181.             nl();
  1182.             if (u.mask & mask_extended)
  1183.               delete_extended_description(u.filename);
  1184.           }
  1185.           if (ok && syscfg.upload_c[0]) {
  1186.             close(f);
  1187.         pl("7Please wait1...");
  1188.         if (check_ul_event(dn,&u)) {
  1189.           if (u.mask & mask_extended)
  1190.         delete_extended_description(u.filename);
  1191.           ok=0;
  1192.         } else {
  1193.           f=open(s1,O_RDONLY | O_BINARY);
  1194.         }
  1195.       }
  1196.     }
  1197.     if (ok) {
  1198.       if (ok==1) {
  1199.         l=filelength(f);
  1200.         u.numbytes=l;
  1201.         close(f);
  1202.         ++thisuser.uploaded;
  1203.         thisuser.uk += ((l+1023)/1024);
  1204.       } else
  1205.         u.numbytes=0;
  1206.       time(&l);
  1207.       u.daten=l;
  1208.       for (i=numf; i>=1; i--) {
  1209.         SETREC(i);
  1210.         read(dlf,(void *)&u1,sizeof(uploadsrec));
  1211.         SETREC(i+1);
  1212.         write(dlf,(void *)&u1,sizeof(uploadsrec));
  1213.       }
  1214.       SETREC(1);
  1215.       write(dlf,(void *)&u,sizeof(uploadsrec));
  1216.       ++numf;
  1217.       SETREC(0);
  1218.       read(dlf, &u1, sizeof(uploadsrec));
  1219.       u1.numbytes=numf;
  1220.       u1.daten=l;
  1221.       dir_dates[dn]=l;
  1222.       SETREC(0);
  1223.       write(dlf,(void *)&u1,sizeof(uploadsrec));
  1224.       if (ok==1) {
  1225.         ++status.uptoday;
  1226.         save_status();
  1227.         sprintf(s,"+%s uploaded on %s",u.filename,directories[dn].name);
  1228.         sysoplog(s);
  1229.         nl();
  1230.         nl();
  1231.         pl("1File uploaded3.");
  1232.         nl();
  1233.        /* npr("1Your ratio is now7:5 %-6.3f\r\n", ratio());*/
  1234.         nl();
  1235.         nl();
  1236.         if (useron)
  1237.           topscreen();
  1238.       }
  1239.     }
  1240.       } else {
  1241.         nl();
  1242.         nl();
  1243.     pl("6File transmission aborted.");
  1244.     nl();
  1245.     if (u.mask & mask_extended)
  1246.       delete_extended_description(u.filename);
  1247.       }
  1248.     }
  1249.   }
  1250.   closedl();
  1251. }
  1252.  
  1253.  
  1254. /****************************************************************************/
  1255. int try_to_download(char *s, int dn,int title)
  1256. {
  1257.   int i,ok,sent,abort=0,next=0,i1;
  1258.   uploadsrec u;
  1259.   char s1[81];
  1260.  
  1261.   dliscan1(dn);
  1262.   i=recno(s);
  1263.   if (i<=0) {
  1264.     closedl();
  1265.     abort=next=0;
  1266.     checka(&abort,&next);
  1267.     if (abort)
  1268.       return(-1);
  1269.     else
  1270.       return(0);
  1271.   }
  1272.   ok=1;
  1273.   while ((i>0) && (ok) && (!hangup)) {
  1274.     if (!ratio_ok()) {
  1275.       closedl();
  1276.       return(-1);
  1277.     }
  1278.     tleft(1);
  1279.     SETREC(i);
  1280.     read(dlf,(void *)&u,sizeof(uploadsrec));
  1281.     nl();
  1282.     if (title)
  1283.       npr("1Directory  3:5 %s\r\n",directories[dn].name);
  1284.     i1=printfileinfo(&u,dn);
  1285.     {
  1286.       if ((i1) || (strncmp(u.filename,"WWIV4",5)==0)) {
  1287.         sprintf(s1,"%s%s",directories[dn].path,u.filename);
  1288.         sent=0;
  1289.         abort=0;
  1290.         if (i1==-1)
  1291.           send_file(s1,&sent,&abort,u.filetype,u.filename,dn, -2L);
  1292.         else
  1293.           send_file(s1,&sent,&abort,u.filetype,u.filename,dn, u.numbytes);
  1294.         if (sent) {
  1295.           ++thisuser.downloaded;
  1296.           thisuser.dk += (int) ((u.numbytes+1023)/1024);
  1297.           ++u.numdloads;
  1298.           SETREC(i);
  1299.           write(dlf,(void *)&u,sizeof(uploadsrec));
  1300.       sprintf(s1,"Leeched'%s'",u.filename);
  1301.           sysoplog(s1);
  1302.           nl();
  1303.           nl();
  1304.      /* npr("1Your ratio is now7: 5%-6.3f\r\n", ratio());*/
  1305.       if (syscfg.sysconfig & sysconfig_log_dl) {
  1306.         sprintf(s1,"%s downloaded '%s' on %s",
  1307.           nam(&thisuser,usernum), u.filename, date());
  1308.         ssm(u.ownerusr,0,s1);
  1309.       }
  1310.       if (useron)
  1311.         topscreen();
  1312.     }
  1313.       } else {
  1314.         nl();
  1315.         nl();
  1316.     pl("6Not enough time left to D/L.");
  1317.     nl();
  1318.       }
  1319.     }
  1320.     if (abort)
  1321.       ok=0;
  1322.     else
  1323.       i=nrecno(s,i);
  1324.   }
  1325.   closedl();
  1326.   if (abort)
  1327.     return(-1);
  1328.   else
  1329.     return(1);
  1330. }
  1331. /****************************************************************************/
  1332.  
  1333.  
  1334. void download()
  1335. {
  1336.   char s[81];
  1337.   int dn;
  1338.  
  1339.   nl();
  1340.   pl("1Download 3-");
  1341.   nl();
  1342.   prt(1,"What's the filename5? ");
  1343.   input(s,12);
  1344.   if (s[0]==0)
  1345.     return;
  1346.   if (strchr(s,'.')==NULL)
  1347.     strcat(s,".*");
  1348.   align(s);
  1349.   if (try_to_download(s,udir[curdir].subnum,0)==0) {
  1350.     nl();
  1351.     pl("6Searching all directories.");
  1352.     nl();
  1353.     dn=0;
  1354.     while ((dn<64) && (udir[dn].subnum!=-1)) {
  1355.       if (try_to_download(s,udir[dn].subnum,1)<0)
  1356.         dn=100;
  1357.       else
  1358.         dn++;
  1359.     }
  1360.   }
  1361. }
  1362.  
  1363.  
  1364. void setldate()
  1365. {
  1366.   struct date d;
  1367.   struct time t;
  1368.   char s[81];
  1369.   int m,dd,y;
  1370.  
  1371.   nl();
  1372.   nl();
  1373.   unixtodos(nscandate,&d,&t);
  1374.   nl();
  1375.   sprintf(s,"3Current limiting date 1= 5%02d/%02d/%02d",d.da_mon,d.da_day,(d.da_year-1900));
  1376.   pl(s);
  1377.   nl();
  1378.   pl("1Enter new limiting date in the format3:");
  1379.   pl(" 1MM7/1DD7/1YY");
  1380.   outstr("3:");
  1381.   input(s,8);
  1382.   m=atoi(s);
  1383.   dd=atoi(&(s[3]));
  1384.   y=atoi(&(s[6]))+1900;
  1385.   if ((strlen(s)==8) && (m>0) && (m<=12) && (dd>0) && (dd<32) && (y>=1980)) {
  1386.     t.ti_min=0;
  1387.     t.ti_hour=0;
  1388.     t.ti_hund=0;
  1389.     t.ti_sec=0;
  1390.     d.da_year=y;
  1391.     d.da_day=dd;
  1392.     d.da_mon=m;
  1393.     sprintf(s,"3Current limiting date 1= 5%02d/%02d/%02d",m,dd,(y-1900));
  1394.     nl();
  1395.     pl(s);
  1396.     nl();
  1397.     nscandate=dostounix(&d,&t);
  1398.   }
  1399. }
  1400.  
  1401.  
  1402. void finddescription()
  1403. {
  1404.   uploadsrec u;
  1405.   int i,i1,i2,abort,pty,d,ocd,pts,pc,fc;
  1406.   char s[81],s1[81];
  1407.  
  1408.   fc=thisuser.sysstatus & sysstatus_funky_colors;
  1409.  
  1410.   nl();
  1411.   nl();
  1412.   pl("Find description -");
  1413.   nl();
  1414.   pl("Enter string to search for in file description:");
  1415.   outstr(":");
  1416.   input(s1,51);
  1417.   if (s1[0]==0)
  1418.     return;
  1419.  
  1420.   ocd=curdir;
  1421.   abort=0;
  1422.   num_listed=0;
  1423.   for (i=0; (i<64) && (!abort) && (!hangup) && (udir[i].subnum!=-1); i++) {
  1424.     i1=udir[i].subnum;
  1425.     pts=0;
  1426.     if (i1>=32) {
  1427.       if (thisuser.nscn2 & (1L << (i1-32)))
  1428.         pts=1;
  1429.     } else {
  1430.       if (thisuser.nscn1 & (1L << i1))
  1431.         pts=1;
  1432.     }
  1433.     pts=1;
  1434.     /* remove pts=1 to search only marked directories */
  1435.     if (pts) {
  1436.       curdir=i;
  1437.       dliscan();
  1438.       pty=1;
  1439.       pc=0;
  1440.       for (i1=1; (i1<=numf) && (!abort) && (!hangup); i1++) {
  1441.         SETREC(i1);
  1442.         read(dlf,(void *)&u,sizeof(uploadsrec));
  1443.         strcpy(s,u.description);
  1444.         for (i2=0; i2<strlen(s); i2++)
  1445.           s[i2]=upcase(s[i2]);
  1446.         if (strstr(s,s1)!=NULL) {
  1447.           if (pty) {
  1448.             printtitle(&abort);
  1449.         pty=0;
  1450.         pc=1;
  1451.           }
  1452.           printinfo(&u,&abort);
  1453.         }
  1454.       }
  1455.       if ((pc) && (!abort)) {
  1456.     if (fc)
  1457.       ansic(3);
  1458.     if (okansi())
  1459.       pla("└──────────────┴───────┴─────────────────────────────────────────────────────┘",&abort);
  1460.     else
  1461.       pla("+--------------+-------+-----------------------------------------------------+",&abort);
  1462.     nl();
  1463.     pc=0;
  1464.       }
  1465.       closedl();
  1466.     }
  1467.   }
  1468.   curdir=ocd;
  1469.   if ((num_listed) && (!abort)) {
  1470.     nl();
  1471.     nl();
  1472.     sprintf(s,"Files listed: %d",num_listed);
  1473.     pl(s);
  1474.     nl();
  1475.   }
  1476.  
  1477. }
  1478.  
  1479.  
  1480. void arc_l()
  1481. {
  1482.   char s[81],s1[81],s2[81];
  1483.   int i,abort,next,i1;
  1484.   uploadsrec u;
  1485.  
  1486.   nl();
  1487.   prt(1,"File for listing5: ");
  1488.   input(s,12);
  1489.   if (strchr(s,'.')==NULL)
  1490.     strcat(s,".*");
  1491.   if (!okfn(s))
  1492.     s[0]=0;
  1493.   align(s);
  1494.   dliscan();
  1495.   abort=0;
  1496.   next=0;
  1497.   i=recno(s);
  1498.   do {
  1499.     if (i>0) {
  1500.       SETREC(i);
  1501.       read(dlf,(void *)&u,sizeof(uploadsrec));
  1502.       i1=list_arc_out(stripfn(u.filename),directories[udir[curdir].subnum].path);
  1503.       if (i1)
  1504.         abort=1;
  1505.       checka(&abort,&next);
  1506.       i=nrecno(s,i);
  1507.     }
  1508.   } while ((i>0) && (!hangup) && (!abort));
  1509.   closedl();
  1510. }
  1511.  
  1512.  
  1513. /****************************************************************************/
  1514.  
  1515.  
  1516. void yourinfodl()
  1517. {
  1518.  
  1519.   nl();
  1520.   nl();
  1521.   npr("1Uploads  : %ldk in %d files\r\n",thisuser.uk, thisuser.uploaded);
  1522.   npr("3Downloads: %ldk in %d files\r\n",thisuser.dk, thisuser.downloaded);
  1523.  /* npr("5Ratio    : %-6.3f\r\n",ratio());*/
  1524.   npr("5Your DSL : %d\r\n",thisuser.dsl);
  1525.   npr("7Your P/C : %-5.3f\r\n",post_ratio(),syscfg.post_call_ratio);
  1526.   nl();
  1527. }
  1528.  
  1529. void l_config_nscan()
  1530. {
  1531.   int i,abort,i1;
  1532.   char s[81], s2[81];
  1533.  
  1534.   abort=0;
  1535.   nl();
  1536.   pl("1Dirs to n5-1scan marked with 3'5*3'");
  1537.   nl();
  1538.   for (i=0; (i<64) && (udir[i].subnum!=-1) && (!abort); i++) {
  1539.     i1=udir[i].subnum;
  1540.     if (i1<32) {
  1541.       if ((1L << (i1)) & thisuser.nscn1)
  1542.     strcpy(s,"5* ");
  1543.       else
  1544.         strcpy(s,"  ");
  1545.     } else {
  1546.       if ((1L << (i1-32)) & thisuser.nscn2)
  1547.     strcpy(s,"5* ");
  1548.       else
  1549.         strcpy(s,"  ");
  1550.     }
  1551.     sprintf(s2,"%s%s. %s",s,udir[i].keys, directories[i1].name);
  1552.     pla(s2,&abort);
  1553.   }
  1554.   nl();
  1555.   nl();
  1556. }
  1557.  
  1558. void config_nscan()
  1559. {
  1560.   char *s;
  1561.   int i,done,i1;
  1562.  
  1563.   l_config_nscan();
  1564.   done=0;
  1565.   do {
  1566.     nl();
  1567.     pl("1Enter directory identifier5, 1? to list5, 1or Q to Quit");
  1568.     prt(3,"Config5: ");
  1569.     s=mmkey(1);
  1570.     if (s[0])
  1571.       for (i=0; i<64; i++)
  1572.         if (strcmp(udir[i].keys,s)==0) {
  1573.           i1=udir[i].subnum;
  1574.           if (i1<32)
  1575.             thisuser.nscn1 ^= ((1L) << i1);
  1576.           else
  1577.             thisuser.nscn2 ^= ((1L) << (i1-32));
  1578.         }
  1579.     if (strcmp(s,"Q")==0)
  1580.       done=1;
  1581.     if (strcmp(s,"?")==0)
  1582.       l_config_nscan();
  1583.   } while ((!done) && (!hangup));
  1584. }
  1585.  
  1586.  
  1587. void xfer_defaults()
  1588. {
  1589.   char s[81],s1[81],ch;
  1590.   int i,i1,i2,done;
  1591.  
  1592.   done=0;
  1593.   do {
  1594.     outchr(12);
  1595.     pl("7[117]5. 3Set N-Scan Directories5.");
  1596.     pl("7[127]5. 3Set Default Protocol5.");
  1597.     sprintf(s,"7[137]5. 3N-Scan Transfer after Message Base (%s)5.",
  1598.       thisuser.sysstatus & sysstatus_nscan_file_system?"Yes":"No");
  1599.     pl(s);
  1600.     sprintf(s,"7[147]5. 3Number of lines of extended description to print (%d line%s)5.",
  1601.       thisuser.num_extended,thisuser.num_extended==1?"":"s");
  1602.     pl(s);
  1603.     pl("7[1Q7]5. 3Quit5.");
  1604.     nl();
  1605.     prt(1,"Which3? ");
  1606.     helpl=32;
  1607.     ch=onek("Q1234");
  1608.     switch(ch) {
  1609.       case 'Q':
  1610.         done=1;
  1611.         break;
  1612.       case '1':
  1613.         helpl=24;
  1614.         config_nscan();
  1615.         break;
  1616.       case '2':
  1617.         nl();
  1618.         nl();
  1619.     pl("1Enter your default protocol5, 10 for none5.");
  1620.     nl();
  1621.     helpl=40;
  1622.     i=get_protocol(xf_down);
  1623.     if (i>=0)
  1624.       thisuser.defprot=i;
  1625.     break;
  1626.       case '3':
  1627.         nl();
  1628.         nl();
  1629.     pl("3Do you want to perform a newscan of all selected transfer");
  1630.     outstr("3directories after an N-scan of the message base5? ");
  1631.     if (thisuser.sysstatus & sysstatus_nscan_file_system)
  1632.       thisuser.sysstatus -= sysstatus_nscan_file_system;
  1633.     if (yn())
  1634.       thisuser.sysstatus += sysstatus_nscan_file_system;
  1635.     break;
  1636.       case '4':
  1637.         nl();
  1638.         nl();
  1639.     pl("3How many lines of an extended description");
  1640.     pl("3do you want to see when listing files 5(107-1105)");
  1641.     npr("5(1Currently set to 3%d 1lines5)\r\n",thisuser.num_extended);
  1642.     prt(5,"? ");
  1643.     helpl=41;
  1644.     input(s,3);
  1645.     if (s[0]) {
  1646.       i=atoi(s);
  1647.       if ((i>=0) && (i<=10))
  1648.         thisuser.num_extended=i;
  1649.     }
  1650.     break;
  1651.     }
  1652.   } while ((!done) && (!hangup));
  1653.  
  1654. }
  1655.  
  1656.  
  1657. void removefile()
  1658. {
  1659.   int i,i1,ok,rm,abort,rdlp;
  1660.   char ch,s[81],s1[81];
  1661.   uploadsrec u;
  1662.   userrec uu;
  1663.  
  1664.   dliscan();
  1665.   nl();
  1666.   pl("1Enter filename to remove5.");
  1667.   outstr("5:1");
  1668.   mpl(12);
  1669.   input(s,12);
  1670.   if (s[0]==0) {
  1671.     closedl();
  1672.     return;
  1673.   }
  1674.   if (strchr(s,'.')==NULL)
  1675.     strcat(s,".*");
  1676.   align(s);
  1677.   i=recno(s);
  1678.   abort=0;
  1679.   while ((!hangup) && (i>0) && (!abort)) {
  1680.     SETREC(i);
  1681.     read(dlf,(void *)&u,sizeof(uploadsrec));
  1682.     if ((dcs()) || ((u.ownersys==0) && (u.ownerusr==usernum))) {
  1683.       nl();
  1684.       if (check_batch_queue(u.filename)) {
  1685.     pl("1That file is in the batch queue5; 1remove it from there5.");
  1686.     nl();
  1687.       } else {
  1688.         printfileinfo(&u,udir[curdir].subnum);
  1689.     prt(1,"Remove 5(3Y5/3N5/3Q5) 1: ");
  1690.     ch=onek("QNY");
  1691.         if (ch=='Q')
  1692.           abort=1;
  1693.         if (ch=='Y') {
  1694.           rdlp=1;
  1695.           if (dcs()) {
  1696.         prt(1,"Delete file too5? ");
  1697.         rm=yn();
  1698.         if (rm) {
  1699.           prt(1,"Remove DL points5? ");
  1700.           rdlp=yn();
  1701.             }
  1702.           } else
  1703.             rm=1;
  1704.           if (rm) {
  1705.             sprintf(s1,"%s%s",directories[udir[curdir].subnum].path,u.filename);
  1706.             unlink(s1);
  1707.             if ((rdlp) && (u.ownersys==0)) {
  1708.               read_user(u.ownerusr,&uu);
  1709.               if ((uu.inact & inact_deleted)==0) {
  1710.                 --uu.uploaded;
  1711.                 uu.uk -= ((u.numbytes+1023)/1024);
  1712.                 write_user(u.ownerusr,&uu);
  1713.               }
  1714.               close_user();
  1715.             }
  1716.           }
  1717.           if (u.mask & mask_extended)
  1718.             delete_extended_description(u.filename);
  1719.           sprintf(s1,"-%s Removed off of %s",u.filename,
  1720.                             directories[udir[curdir].subnum].name);
  1721.           sysoplog(s1);
  1722.           for (i1=i; i1<numf; i1++) {
  1723.             SETREC(i1+1);
  1724.             read(dlf,(void *)&u,sizeof(uploadsrec));
  1725.             SETREC(i1);
  1726.             write(dlf,(void *)&u,sizeof(uploadsrec));
  1727.           }
  1728.           --i;
  1729.           --numf;
  1730.           SETREC(0);
  1731.           read(dlf, &u, sizeof(uploadsrec));
  1732.           u.numbytes=numf;
  1733.           SETREC(0);
  1734.           write(dlf,(void *)&u,sizeof(uploadsrec));
  1735.         }
  1736.       }
  1737.     }
  1738.     i=nrecno(s,i);
  1739.   }
  1740.   closedl();
  1741.  
  1742. }
  1743.  
  1744.  
  1745.