home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / OTHERUTI / WWIV420S.ZIP / XFER.C < prev    next >
C/C++ Source or Header  |  1991-07-22  |  35KB  |  1,644 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("Archive listing for %s:\r\n",fn);
  187.     nl();
  188.     i=do_external(s,1);
  189.     nl();
  190.   } else {
  191.     nl();
  192.     outs("Unknown 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,"Your up/download ratio is %-5.3f.  You need a ratio of %-5.3f to 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,"Your post/call ratio is %-5.3f.  You need a ratio of %-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.  
  401. void print_extended(char *fn, int *abort, unsigned char numlist, int indent)
  402. {
  403.   char *ss;
  404.   int next=0;
  405.   unsigned char numl=0;
  406.   int cpos=0;
  407.   char ch,s[81];
  408.   int i;
  409.  
  410.   ss=read_extended_description(fn);
  411.   if (ss) {
  412.     ch=10;
  413.     while ((ss[cpos]) && (!(*abort)) && (numl<numlist)) {
  414.       if ((ch==10) && (indent)) {
  415.         if (okansi())
  416.           sprintf(s,"\x1b[%dC",INDENTION);
  417.         else {
  418.           for (i=0; i<INDENTION; i++)
  419.             s[i]=32;
  420.           s[INDENTION]=0;
  421.         }
  422.         osan(s,abort,&next);
  423.         if ((thisuser.sysstatus & sysstatus_funky_colors) && (!(*abort)))
  424.           ansic(2);
  425.       }
  426.       outchr(ch=ss[cpos++]);
  427.       checka(abort,&next);
  428.       if (ch==10)
  429.         ++numl;
  430.       else
  431.         if ((ch!=13) && (wherex()>=78)) {
  432.           osan("\r\n",abort,&next);
  433.           ch=10;
  434.         }
  435.     }
  436.     if (wherex())
  437.       nl();
  438.   }
  439.   farfree(ss);
  440. }
  441.  
  442.  
  443.  
  444. void modify_extended_description(char **sss)
  445. {
  446.   char s[161],s1[161];
  447.   int f,ii,i,i1,i2;
  448.  
  449.   if (*sss)
  450.     ii=1;
  451.   else
  452.     ii=0;
  453.   do {
  454.     if (ii) {
  455.       nl();
  456.       if (FSED_OK)
  457.         prt(5,"Modify the extended description? ");
  458.       else
  459.         prt(5,"Enter a new extended description? ");
  460.       if (!yn())
  461.         return;
  462.     } else {
  463.       nl();
  464.       prt(5,"Enter an extended description? ");
  465.       if (!yn())
  466.         return;
  467.     }
  468.     if (FSED_OK) {
  469.       sprintf(s,"%sEXTENDED.DSC", syscfg.tempdir);
  470.       if (*sss) {
  471.         f=open(s,O_RDWR | O_BINARY | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
  472.         write(f,*sss,strlen(*sss));
  473.         close(f);
  474.         farfree(*sss);
  475.         *sss=NULL;
  476.       } else
  477.         unlink(s);
  478.       i=thisuser.screenchars;
  479.       if (thisuser.screenchars>(76-INDENTION))
  480.         thisuser.screenchars=76-INDENTION;
  481.       i1=external_edit("extended.dsc",syscfg.tempdir,(int) thisuser.defed-1,MAX_LINES);
  482.       thisuser.screenchars=i;
  483.       if (i1) {
  484.         if ((*sss=malloca(10240))==NULL)
  485.           return;
  486.         f=open(s,O_RDWR | O_BINARY);
  487.         read(f,*sss,(int) filelength(f));
  488.         (*sss)[filelength(f)]=0;
  489.         close(f);
  490.       }
  491.     } else {
  492.       if (*sss)
  493.         farfree(*sss);
  494.       if ((*sss=malloca(10240))==NULL)
  495.         return;
  496.       *sss[0]=0;
  497.       i=1;
  498.       nl();
  499.       sprintf(s,"Enter up to %d lines, %d chars each.",MAX_LINES,78-INDENTION);
  500.       pl(s);
  501.       nl();
  502.       s[0]=0;
  503.       i1=thisuser.screenchars;
  504.       if (thisuser.screenchars>(76-INDENTION))
  505.         thisuser.screenchars=76-INDENTION;
  506.       do {
  507.         ansic(2);
  508.         npr("%d: ",i);
  509.         ansic(0);
  510.         s1[0]=0;
  511.         inli(s1,s,90,1);
  512.         i2=strlen(s1);
  513.         if (i2 && (s1[i2-1]==1))
  514.           s1[i2-1]=0;
  515.         if (s1[0]) {
  516.           strcat(s1,"\r\n");
  517.           strcat(*sss,s1);
  518.         }
  519.       } while ((i++<10) && (s1[0]));
  520.       thisuser.screenchars=i1;
  521.       if (*sss[0]==0) {
  522.         farfree(*sss);
  523.         *sss=NULL;
  524.       }
  525.     }
  526.     prt(5,"Is this what you want? ");
  527.     i=!yn();
  528.     if (i) {
  529.       farfree(*sss);
  530.       *sss=NULL;
  531.     }
  532.   } while (i);
  533. }
  534.  
  535.  
  536. void align(char *s)
  537. {
  538.   char f[40],e[40],s1[20],*s2;
  539.   int i,i1,i2;
  540.  
  541.   i1=0;
  542.   if (s[0]=='.')
  543.     i1=1;
  544.   for (i=0; i<strlen(s); i++)
  545.     if ((s[i]=='\\') || (s[i]=='/') || (s[i]==':') || (s[i]=='<') ||
  546.       (s[i]=='>') || (s[i]=='|'))
  547.       i1=1;
  548.   if (i1) {
  549.     strcpy(s,"        .   ");
  550.     return;
  551.   }
  552.   s2=strchr(s,'.');
  553.   if (s2==NULL) {
  554.     e[0]=0;
  555.   } else {
  556.     strcpy(e,&(s2[1]));
  557.     e[3]=0;
  558.     s2[0]=0;
  559.   }
  560.   strcpy(f,s);
  561.  
  562.   for (i=strlen(f); i<8; i++)
  563.     f[i]=32;
  564.   f[8]=0;
  565.   i1=0;
  566.   i2=0;
  567.   for (i=0; i<8; i++) {
  568.     if (f[i]=='*')
  569.       i1=1;
  570.     if (f[i]==' ')
  571.       i2=1;
  572.     if (i2)
  573.       f[i]=' ';
  574.     if (i1)
  575.       f[i]='?';
  576.   }
  577.  
  578.   for (i=strlen(e); i<3; i++)
  579.     e[i]=32;
  580.   e[3]=0;
  581.   i1=0;
  582.   for (i=0; i<3; i++) {
  583.     if (e[i]=='*')
  584.       i1=1;
  585.     if (i1)
  586.       e[i]='?';
  587.   }
  588.  
  589.   for (i=0; i<12; i++)
  590.     s1[i]=32;
  591.   strcpy(s1,f);
  592.   s1[8]='.';
  593.   strcpy(&(s1[9]),e);
  594.   strcpy(s,s1);
  595.   for (i=0; i<12; i++)
  596.     s[i]=upcase(s[i]);
  597. }
  598.  
  599.  
  600. int compare(char *s1, char *s2)
  601. {
  602.   int ok,i;
  603.  
  604.   ok=1;
  605.   for (i=0; i<12; i++)
  606.     if ((s1[i]!=s2[i]) && (s1[i]!='?') && (s2[i]!='?'))
  607.       ok=0;
  608.   return(ok);
  609. }
  610.  
  611.  
  612. void printinfo(uploadsrec *u, int *abort)
  613. {
  614.   char s[85],s1[40],s2[81];
  615.   int i,next,fc;
  616.  
  617.   fc=thisuser.sysstatus & sysstatus_funky_colors;
  618.  
  619.   if (fc)
  620.     ansic(1);
  621.   strncpy(s,u->filename,8);
  622.   s[8]=0;
  623.   osan(s,abort,&next);
  624.   strncpy(s,&((u->filename)[8]),4);
  625.   s[4]=0;
  626.   if (fc)
  627.     ansic(2);
  628.   osan(s,abort,&next);
  629.   if (fc)
  630.     ansic(0);
  631.   osan(": ",abort,&next);
  632.  
  633.   ltoa((((u->numbytes)+1023)/1024),s1,10);
  634.   strcat(s1,"k");
  635.  
  636. #ifdef CHECK_FOR_EXISTANCE
  637.   strcpy(s2,directories[udir[curdir].subnum].path);
  638.   strcat(s2,u->filename);
  639.   if (!exist(s2))
  640.     strcpy(s1,"N/A");
  641. #endif
  642.  
  643.   for (i=0; i<5-strlen(s1); i++)
  644.     s[i]=32;
  645.   s[i]=0;
  646.   strcat(s,s1);
  647.   if (fc)
  648.     ansic(3);
  649.   osan(s,abort,&next);
  650.  
  651.   if (fc)
  652.     ansic(0);
  653.   osan(" :",abort,&next);
  654.   if (fc)
  655.     ansic(5);
  656.   pla(u->description,abort);
  657.   if ((!*abort) && (thisuser.num_extended) && (u->mask & mask_extended))
  658.     print_extended(u->filename,abort,thisuser.num_extended,1);
  659.   if (!(*abort))
  660.     ++num_listed;
  661. }
  662.  
  663.  
  664. void printtitle(int *abort)
  665. {
  666.   char s[81],s1[20];
  667.   int i,i1;
  668.  
  669.   pla("",abort);
  670.   pla("",abort);
  671.   sprintf(s,"%s - #%s, %d files.",directories[udir[curdir].subnum].name,
  672.                                   udir[curdir].keys,numf);
  673.   i=strlen(s);
  674.   if (thisuser.sysstatus & sysstatus_funky_colors)
  675.     ansic(2);
  676.   pla(s,abort);
  677.   for (i1=0; i1<i; i1++)
  678.     s[i1]='=';
  679.   s[i]=0;
  680.   if (thisuser.sysstatus & sysstatus_funky_colors)
  681.     ansic(2);
  682.   pla(s,abort);
  683.   pla("",abort);
  684. }
  685.  
  686.  
  687. void file_mask(char *s)
  688. {
  689.   nl();
  690.   helpl=9;
  691.   prt(2,"File mask: ");
  692.   input(s,12);
  693.   if (s[0]==0)
  694.     strcpy(s,"*.*");
  695.   if (strchr(s,'.')==NULL)
  696.     strcat(s,".*");
  697.   align(s);
  698.   nl();
  699. }
  700.  
  701.  
  702. void listfiles()
  703. {
  704.   char s[81];
  705.   int i,abort,next=0;
  706.   uploadsrec u;
  707.  
  708.   dliscan();
  709.   file_mask(s);
  710.   abort=0;
  711.   num_listed=0;
  712.   printtitle(&abort);
  713.   for (i=1; (i<=numf) && (!abort) && (!hangup); i++) {
  714.     SETREC(i);
  715.     read(dlf,(void *)&u,sizeof(uploadsrec));
  716.     if (compare(s,u.filename))
  717.       printinfo(&u,&abort);
  718.     else if (!empty())
  719.       checka(&abort,&next);
  720.   }
  721.   closedl();
  722.   if (!abort) {
  723.     nl();
  724.     nl();
  725.     sprintf(s,"Files listed: %d",num_listed);
  726.     pl(s);
  727.     nl();
  728.   }
  729. }
  730.  
  731.  
  732. void nscandir(int d, int *abort,int title)
  733. {
  734.   int i,od,dt,next=0;
  735.   uploadsrec u;
  736.   char s[81];
  737.  
  738.   if ((dir_dates[udir[d].subnum]) && (dir_dates[udir[d].subnum]<nscandate))
  739.     return;
  740.  
  741.   od=curdir;
  742.   curdir=d;
  743.   dt=title;
  744.   dliscan();
  745.   if (this_date>=nscandate) {
  746.     for (i=1; (i<=numf) && (!(*abort)) && (!hangup); i++) {
  747.       SETREC(i);
  748.       read(dlf,(void *)&u,sizeof(uploadsrec));
  749.       if (u.daten>=nscandate) {
  750.         if (dt) {
  751.           printtitle(abort);
  752.           dt=0;
  753.         }
  754.         printinfo(&u,abort);
  755.       } else if (!empty())
  756.         checka(abort,&next);
  757.  
  758.     }
  759.   }
  760.   closedl();
  761.   curdir=od;
  762. }
  763.  
  764.  
  765. void nscanall()
  766. {
  767.   int abort,i,i1;
  768.   char s[81];
  769.  
  770.   abort=0;
  771.   num_listed=0;
  772.   for (i=0; (i<64) && (!abort) && (udir[i].subnum!=-1); i++) {
  773.     i1=udir[i].subnum;
  774.     if (i1>=32) {
  775.       if (thisuser.nscn2 & (1L << (i1-32)))
  776.         nscandir(i,&abort,1);
  777.     } else {
  778.       if (thisuser.nscn1 & (1L << i1))
  779.         nscandir(i,&abort,1);
  780.     }
  781.   }
  782.   if ((num_listed) && (!abort)) {
  783.     nl();
  784.     nl();
  785.     sprintf(s,"Files listed: %d",num_listed);
  786.     pl(s);
  787.     nl();
  788.   }
  789. }
  790.  
  791.  
  792. void searchall()
  793. {
  794.   int i,i1,pts,abort,pty,ocd,next=0;
  795.   char s[81],s1[81];
  796.   uploadsrec u;
  797.  
  798.   abort=0;
  799.   ocd=curdir;
  800.   nl();
  801.   nl();
  802.   pl("Search all directories.");
  803.   file_mask(s);
  804.   num_listed=0;
  805.   for (i=0; (i<64) && (!abort) && (!hangup) && (udir[i].subnum!=-1); i++) {
  806.     i1=udir[i].subnum;
  807.     pts=0;
  808.     if (i1>=32) {
  809.       if (thisuser.nscn2 & (1L << (i1-32)))
  810.         pts=1;
  811.     } else {
  812.       if (thisuser.nscn1 & (1L << i1))
  813.         pts=1;
  814.     }
  815.     pts=1;
  816.     /* remove pts=1 to search only marked directories */
  817.     if (pts) {
  818.       curdir=i;
  819.       dliscan();
  820.       pty=1;
  821.       for (i1=1; (i1<=numf) && (!abort) && (!hangup); i1++) {
  822.         SETREC(i1);
  823.         read(dlf,(void *)&u,sizeof(uploadsrec));
  824.         if (compare(s,u.filename)) {
  825.           if (pty) {
  826.             printtitle(&abort);
  827.             pty=0;
  828.           }
  829.           printinfo(&u,&abort);
  830.         } else if (!empty())
  831.           checka(&abort,&next);
  832.       }
  833.       closedl();
  834.     }
  835.   }
  836.   curdir=ocd;
  837.   if ((num_listed) && (!abort)) {
  838.     nl();
  839.     nl();
  840.     sprintf(s,"Files listed: %d",num_listed);
  841.     pl(s);
  842.     nl();
  843.   }
  844. }
  845.  
  846.  
  847.  
  848. int recno(char *s)
  849. {
  850.   int i;
  851.   uploadsrec u;
  852.  
  853.   i=1;
  854.   if (numf<1)
  855.     return(-1);
  856.   SETREC(i);
  857.   read(dlf,(void *)&u,sizeof(uploadsrec));
  858.   while ((i<numf) && (compare(s,u.filename)==0)) {
  859.     ++i;
  860.     SETREC(i);
  861.     read(dlf,(void *)&u,sizeof(uploadsrec));
  862.   }
  863.   if (compare(s,u.filename))
  864.     return(i);
  865.   else
  866.     return(-1);
  867. }
  868.  
  869.  
  870. int nrecno(char *s,int i1)
  871. {
  872.   int i;
  873.   uploadsrec u;
  874.  
  875.   i=i1+1;
  876.   if ((numf<1) || (i1>=numf))
  877.     return(-1);
  878.  
  879.   SETREC(i);
  880.   read(dlf,(void *)&u,sizeof(uploadsrec));
  881.   while ((i<numf) && (compare(s,u.filename)==0)) {
  882.     ++i;
  883.     SETREC(i);
  884.     read(dlf,(void *)&u,sizeof(uploadsrec));
  885.   }
  886.   if (compare(s,u.filename))
  887.     return(i);
  888.   else
  889.     return(-1);
  890. }
  891.  
  892.  
  893. int printfileinfo(uploadsrec *u, int dn)
  894. {
  895.   char s[81];
  896.   double d;
  897.   int i,abort;
  898.  
  899.   d=((double) (((u->numbytes)+127)/128)) *
  900.     (1620.0) /
  901.     ((double) (modem_speed));
  902.   npr("Filename   : %s\r\n", stripfn(u->filename));
  903.   npr("Description: %s\r\n", u->description);
  904.   npr("File size  : %dk\r\n", ((u->numbytes)+1023)/1024);
  905.   npr("Apprx. time: %s\r\n", ctim(d));
  906.   npr("Uploaded on: %s\r\n", u->date);
  907.   npr("Uploaded by: %s\r\n", u->upby);
  908.   npr("Times D/L'd: %d\r\n", u->numdloads);
  909.   nl();
  910.   abort=0;
  911.   if (u->mask & mask_extended) {
  912.     pl("Extended Description: ");
  913.     print_extended(u->filename,&abort,255,0);
  914.   }
  915.  
  916.   sprintf(s,"%s%s",directories[dn].path,u->filename);
  917.   if (!exist(s)) {
  918.     nl();
  919.     pl("->FILE NOT THERE<-");
  920.     nl();
  921.     return(-1);
  922.   }
  923.  
  924.   if (nsl()>=d)
  925.     return(1);
  926.   else
  927.     return(0);
  928. }
  929.  
  930.  
  931. void upload(int dn)
  932. {
  933.   directoryrec d;
  934.   uploadsrec u,u1;
  935.   int i,i1,i2,ok,xfer,f;
  936.   char s[255],s1[81],*ss;
  937.   long l;
  938.   double ti;
  939.  
  940.   dliscan1(dn);
  941.   d=directories[dn];
  942.   if (numf>=d.maxfiles) {
  943.     nl();
  944.     nl();
  945.     pl("This directory is currently full.");
  946.     nl();
  947.     closedl();
  948.     return;
  949.   }
  950.   if ((d.mask & mask_no_uploads) && (!dcs())) {
  951.     nl();
  952.     nl();
  953.     pl("Uploads are not allowed to this directory.");
  954.     nl();
  955.     closedl();
  956.     return;
  957.   }
  958.   nl();
  959.   l=(long)freek1(d.path);
  960.   sprintf(s,"Upload - %ldk free.",l);
  961.   pl(s);
  962.   nl();
  963.   if (l<100) {
  964.     pl("Not enough disk space to upload here.");
  965.     nl();
  966.     closedl();
  967.     return;
  968.   }
  969.   prt(2,"Filename: ");
  970.   input(s,12);
  971.   if (!okfn(s))
  972.     s[0]=0;
  973.   align(s);
  974.   if (strchr(s,'?')) {
  975.     closedl();
  976.     return;
  977.   }
  978.   if (d.mask & mask_archive) {
  979.     ok=0;
  980.     s1[0]=0;
  981.     for (i=0; i<4; i++) {
  982.       if (syscfg.arcs[i].extension[0] && syscfg.arcs[i].extension[0]!=' ') {
  983.         if (s1[0])
  984.           strcat(s1,", ");
  985.         strcat(s1,syscfg.arcs[i].extension);
  986.         if (strcmp(s+9,syscfg.arcs[i].extension)==0)
  987.           ok=1;
  988.       }
  989.     }
  990.     if (!ok) {
  991.       nl();
  992.       pl("Sorry, all uploads to this dir must");
  993.       pl("be archived.  Supported types are:");
  994.       pl(s1);
  995.       nl();
  996.       closedl();
  997.       return;
  998.     }
  999.   }
  1000.   strcpy(u.filename,s);
  1001.   u.ownerusr=usernum;
  1002.   u.ownersys=0;
  1003.   u.numdloads=0;
  1004.   u.filetype=0;
  1005.   u.mask=0;
  1006.   strcpy(u.upby,nam1(&thisuser,usernum,syscfg.systemnumber));
  1007.   strcpy(u.date,date());
  1008.   nl();
  1009.   ok=1;
  1010.   xfer=1;
  1011.   if (check_batch_queue(u.filename)) {
  1012.     ok=0;
  1013.     nl();
  1014.     pl("That file is already in the batch queue.");
  1015.     nl();
  1016.   } else {
  1017.     sprintf(s1,"Upload '%s' to %s? ",s,d.name);
  1018.     if (strcmp(s,"        .   "))
  1019.       prt(5,s1);
  1020.     else
  1021.       ok=0;
  1022.   }
  1023.   if ((ok) && (yn())) {
  1024.     sprintf(s1,"%s%s",d.path,s);
  1025.     if (exist(s1)) {
  1026.       if (dcs()) {
  1027.         xfer=0;
  1028.         nl();
  1029.         nl();
  1030.         pl("File already exists.");
  1031.         prt(5,"Add to database anyway? ");
  1032.         if (yn()==0)
  1033.           ok=0;
  1034.       } else {
  1035.         nl();
  1036.         nl();
  1037.         pl("That file is already here.");
  1038.         nl();
  1039.         ok=0;
  1040.       }
  1041.     } else
  1042.       if (!incom) {
  1043.         nl();
  1044.         pl("File isn't already there.");
  1045.         pl("Can't upload locally.");
  1046.         nl();
  1047.         ok=0;
  1048.       }
  1049.     if ((d.mask & mask_PD) && (ok)) {
  1050.       nl();
  1051.       prt(5,"Is this program PD/Shareware? ");
  1052.       if (!yn()) {
  1053.         nl();
  1054.         pl("This directory is for Public Domain/");
  1055.         pl("Shareware programs ONLY.  Please do not");
  1056.         pl("upload other programs.  If you have");
  1057.         pl("trouble with this policy, please contact");
  1058.         pl("the sysop.");
  1059.         nl();
  1060.         sprintf(s,"Wanted to upload '%s'",u.filename);
  1061.         add_ass(5,s);
  1062.         ok=0;
  1063.       } else
  1064.         u.mask=mask_PD;
  1065.     }
  1066.     if (ok) {
  1067.       nl();
  1068.       pl("Please enter a one line description.");
  1069.       outstr(": ");
  1070.       inputl(u.description,58);
  1071.       nl();
  1072.       ss=NULL;
  1073.       modify_extended_description(&ss);
  1074.       if (ss) {
  1075.         add_extended_description(u.filename,ss);
  1076.         u.mask |= mask_extended;
  1077.         farfree(ss);
  1078.       }
  1079.       nl();
  1080.       if (xfer) {
  1081.         ti=timer();
  1082.         receive_file(s1,&ok,&u.filetype, u.filename, dn);
  1083.         ti=timer()-ti;
  1084.         if (ti<0)
  1085.           ti += 24.0*3600.0;
  1086.         thisuser.extratime += ti;
  1087.       }
  1088.       if (ok) {
  1089.         if (ok==1) {
  1090.           f=open(s1,O_RDONLY | O_BINARY);
  1091.           if (f<0) {
  1092.             ok=0;
  1093.             nl();
  1094.             nl();
  1095.             pl("DOS error - File not found.");
  1096.             nl();
  1097.             if (u.mask & mask_extended)
  1098.               delete_extended_description(u.filename);
  1099.           }
  1100.           if (ok && syscfg.upload_c[0]) {
  1101.             close(f);
  1102.             pl("Please wait...");
  1103.             if (check_ul_event(dn,&u)) {
  1104.               if (u.mask & mask_extended)
  1105.                 delete_extended_description(u.filename);
  1106.               ok=0;
  1107.             } else {
  1108.               f=open(s1,O_RDONLY | O_BINARY);
  1109.             }
  1110.           }
  1111.         }
  1112.         if (ok) {
  1113.           if (ok==1) {
  1114.             l=filelength(f);
  1115.             u.numbytes=l;
  1116.             close(f);
  1117.             ++thisuser.uploaded;
  1118.             thisuser.uk += ((l+1023)/1024);
  1119.           } else
  1120.             u.numbytes=0;
  1121.           time(&l);
  1122.           u.daten=l;
  1123.           for (i=numf; i>=1; i--) {
  1124.             SETREC(i);
  1125.             read(dlf,(void *)&u1,sizeof(uploadsrec));
  1126.             SETREC(i+1);
  1127.             write(dlf,(void *)&u1,sizeof(uploadsrec));
  1128.           }
  1129.           SETREC(1);
  1130.           write(dlf,(void *)&u,sizeof(uploadsrec));
  1131.           ++numf;
  1132.           SETREC(0);
  1133.           read(dlf, &u1, sizeof(uploadsrec));
  1134.           u1.numbytes=numf;
  1135.           u1.daten=l;
  1136.           dir_dates[dn]=l;
  1137.           SETREC(0);
  1138.           write(dlf,(void *)&u1,sizeof(uploadsrec));
  1139.           if (ok==1) {
  1140.             ++status.uptoday;
  1141.             save_status();
  1142.             sprintf(s,"+%s uploaded on %s",u.filename,directories[dn].name);
  1143.             sysoplog(s);
  1144.             nl();
  1145.             nl();
  1146.             pl("File uploaded.");
  1147.             nl();
  1148.             npr("Your ratio is now: %-6.3f\r\n", ratio());
  1149.             nl();
  1150.             nl();
  1151.             if (useron)
  1152.               topscreen();
  1153.           }
  1154.         }
  1155.       } else {
  1156.         nl();
  1157.         nl();
  1158.         pl("File transmission aborted.");
  1159.         nl();
  1160.         if (u.mask & mask_extended)
  1161.           delete_extended_description(u.filename);
  1162.       }
  1163.     }
  1164.   }
  1165.   closedl();
  1166. }
  1167.  
  1168.  
  1169. /****************************************************************************/
  1170. int try_to_download(char *s, int dn,int title)
  1171. {
  1172.   int i,ok,sent,abort=0,next=0,i1;
  1173.   uploadsrec u;
  1174.   char s1[81];
  1175.  
  1176.   dliscan1(dn);
  1177.   i=recno(s);
  1178.   if (i<=0) {
  1179.     closedl();
  1180.     abort=next=0;
  1181.     checka(&abort,&next);
  1182.     if (abort)
  1183.       return(-1);
  1184.     else
  1185.       return(0);
  1186.   }
  1187.   ok=1;
  1188.   while ((i>0) && (ok) && (!hangup)) {
  1189.     if (!ratio_ok()) {
  1190.       closedl();
  1191.       return(-1);
  1192.     }
  1193.     tleft(1);
  1194.     SETREC(i);
  1195.     read(dlf,(void *)&u,sizeof(uploadsrec));
  1196.     nl();
  1197.     if (title)
  1198.       npr("Directory  : %s\r\n",directories[dn].name);
  1199.     i1=printfileinfo(&u,dn);
  1200.     {
  1201.       if ((i1) || (strncmp(u.filename,"WWIV4",5)==0)) {
  1202.         sprintf(s1,"%s%s",directories[dn].path,u.filename);
  1203.         sent=0;
  1204.         abort=0;
  1205.         if (i1==-1)
  1206.           send_file(s1,&sent,&abort,u.filetype,u.filename,dn, -2L);
  1207.         else
  1208.           send_file(s1,&sent,&abort,u.filetype,u.filename,dn, u.numbytes);
  1209.         if (sent) {
  1210.           ++thisuser.downloaded;
  1211.           thisuser.dk += (int) ((u.numbytes+1023)/1024);
  1212.           ++u.numdloads;
  1213.           SETREC(i);
  1214.           write(dlf,(void *)&u,sizeof(uploadsrec));
  1215.           sprintf(s1,"Downloaded '%s'",u.filename);
  1216.           sysoplog(s1);
  1217.           nl();
  1218.           nl();
  1219.           npr("Your ratio is now: %-6.3f\r\n", ratio());
  1220.           if (syscfg.sysconfig & sysconfig_log_dl) {
  1221.             sprintf(s1,"%s downloaded '%s' on %s",
  1222.               nam(&thisuser,usernum), u.filename, date());
  1223.             ssm(u.ownerusr,0,s1);
  1224.           }
  1225.           if (useron)
  1226.             topscreen();
  1227.         }
  1228.       } else {
  1229.         nl();
  1230.         nl();
  1231.         pl("Not enough time left to D/L.");
  1232.         nl();
  1233.       }
  1234.     }
  1235.     if (abort)
  1236.       ok=0;
  1237.     else
  1238.       i=nrecno(s,i);
  1239.   }
  1240.   closedl();
  1241.   if (abort)
  1242.     return(-1);
  1243.   else
  1244.     return(1);
  1245. }
  1246. /****************************************************************************/
  1247.  
  1248.  
  1249. void download()
  1250. {
  1251.   char s[81];
  1252.   int dn;
  1253.  
  1254.   nl();
  1255.   pl("Download -");
  1256.   nl();
  1257.   prt(2,"Filename: ");
  1258.   input(s,12);
  1259.   if (s[0]==0)
  1260.     return;
  1261.   if (strchr(s,'.')==NULL)
  1262.     strcat(s,".*");
  1263.   align(s);
  1264.   if (try_to_download(s,udir[curdir].subnum,0)==0) {
  1265.     nl();
  1266.     pl("Searching all directories.");
  1267.     nl();
  1268.     dn=0;
  1269.     while ((dn<64) && (udir[dn].subnum!=-1)) {
  1270.       if (try_to_download(s,udir[dn].subnum,1)<0)
  1271.         dn=100;
  1272.       else
  1273.         dn++;
  1274.     }
  1275.   }
  1276. }
  1277.  
  1278.  
  1279. void setldate()
  1280. {
  1281.   struct date d;
  1282.   struct time t;
  1283.   char s[81];
  1284.   int m,dd,y;
  1285.  
  1286.   nl();
  1287.   nl();
  1288.   unixtodos(nscandate,&d,&t);
  1289.   nl();
  1290.   sprintf(s,"Current limiting date = %02d/%02d/%02d",d.da_mon,d.da_day,(d.da_year-1900));
  1291.   pl(s);
  1292.   nl();
  1293.   pl("Enter new limiting date in the format:");
  1294.   pl(" MM/DD/YY");
  1295.   outstr(":");
  1296.   input(s,8);
  1297.   m=atoi(s);
  1298.   dd=atoi(&(s[3]));
  1299.   y=atoi(&(s[6]))+1900;
  1300.   if ((strlen(s)==8) && (m>0) && (m<=12) && (dd>0) && (dd<32) && (y>=1980)) {
  1301.     t.ti_min=0;
  1302.     t.ti_hour=0;
  1303.     t.ti_hund=0;
  1304.     t.ti_sec=0;
  1305.     d.da_year=y;
  1306.     d.da_day=dd;
  1307.     d.da_mon=m;
  1308.     sprintf(s,"Current limiting date = %02d/%02d/%02d",m,dd,(y-1900));
  1309.     nl();
  1310.     pl(s);
  1311.     nl();
  1312.     nscandate=dostounix(&d,&t);
  1313.   }
  1314. }
  1315.  
  1316.  
  1317. void finddescription()
  1318. {
  1319.   uploadsrec u;
  1320.   int i,i1,i2,abort,pty,d,ocd,pts,next=0;
  1321.   char s[81],s1[81];
  1322.  
  1323.   nl();
  1324.   nl();
  1325.   pl("Find description -");
  1326.   nl();
  1327.   pl("Enter string to search for in file description:");
  1328.   outstr(":");
  1329.   input(s1,58);
  1330.   if (s1[0]==0)
  1331.     return;
  1332.  
  1333.   ocd=curdir;
  1334.   abort=0;
  1335.   num_listed=0;
  1336.   for (i=0; (i<64) && (!abort) && (!hangup) && (udir[i].subnum!=-1); i++) {
  1337.     i1=udir[i].subnum;
  1338.     pts=0;
  1339.     if (i1>=32) {
  1340.       if (thisuser.nscn2 & (1L << (i1-32)))
  1341.         pts=1;
  1342.     } else {
  1343.       if (thisuser.nscn1 & (1L << i1))
  1344.         pts=1;
  1345.     }
  1346.     pts=1;
  1347.     /* remove pts=1 to search only marked directories */
  1348.     if (pts) {
  1349.       curdir=i;
  1350.       dliscan();
  1351.       pty=1;
  1352.       for (i1=1; (i1<=numf) && (!abort) && (!hangup); i1++) {
  1353.         SETREC(i1);
  1354.         read(dlf,(void *)&u,sizeof(uploadsrec));
  1355.         strcpy(s,u.description);
  1356.         for (i2=0; i2<strlen(s); i2++)
  1357.           s[i2]=upcase(s[i2]);
  1358.         if (strstr(s,s1)!=NULL) {
  1359.           if (pty) {
  1360.             printtitle(&abort);
  1361.             pty=0;
  1362.           }
  1363.           printinfo(&u,&abort);
  1364.         } else if (!empty())
  1365.           checka(&abort,&next);
  1366.       }
  1367.       closedl();
  1368.     }
  1369.   }
  1370.   curdir=ocd;
  1371.   if ((num_listed) && (!abort)) {
  1372.     nl();
  1373.     nl();
  1374.     sprintf(s,"Files listed: %d",num_listed);
  1375.     pl(s);
  1376.     nl();
  1377.   }
  1378. }
  1379.  
  1380.  
  1381. void arc_l()
  1382. {
  1383.   char s[81],s1[81],s2[81];
  1384.   int i,abort,next,i1;
  1385.   uploadsrec u;
  1386.  
  1387.   nl();
  1388.   prt(2,"File for listing: ");
  1389.   input(s,12);
  1390.   if (strchr(s,'.')==NULL)
  1391.     strcat(s,".*");
  1392.   if (!okfn(s))
  1393.     s[0]=0;
  1394.   align(s);
  1395.   dliscan();
  1396.   abort=0;
  1397.   next=0;
  1398.   i=recno(s);
  1399.   do {
  1400.     if (i>0) {
  1401.       SETREC(i);
  1402.       read(dlf,(void *)&u,sizeof(uploadsrec));
  1403.       i1=list_arc_out(stripfn(u.filename),directories[udir[curdir].subnum].path);
  1404.       if (i1)
  1405.         abort=1;
  1406.       checka(&abort,&next);
  1407.       i=nrecno(s,i);
  1408.     }
  1409.   } while ((i>0) && (!hangup) && (!abort));
  1410.   closedl();
  1411. }
  1412.  
  1413.  
  1414. /****************************************************************************/
  1415.  
  1416.  
  1417. void yourinfodl()
  1418. {
  1419.  
  1420.   nl();
  1421.   nl();
  1422.   npr("Uploads  : %ldk in %d files\r\n",thisuser.uk, thisuser.uploaded);
  1423.   npr("Downloads: %ldk in %d files\r\n",thisuser.dk, thisuser.downloaded);
  1424.   npr("Ratio    : %-6.3f\r\n",ratio());
  1425.   npr("Your DSL : %d\r\n",thisuser.dsl);
  1426.   nl();
  1427. }
  1428.  
  1429. void l_config_nscan()
  1430. {
  1431.   int i,abort,i1;
  1432.   char s[81], s2[81];
  1433.  
  1434.   abort=0;
  1435.   nl();
  1436.   pl("Dirs to n-scan marked with '*'");
  1437.   nl();
  1438.   for (i=0; (i<64) && (udir[i].subnum!=-1) && (!abort); i++) {
  1439.     i1=udir[i].subnum;
  1440.     if (i1<32) {
  1441.       if ((1L << (i1)) & thisuser.nscn1)
  1442.         strcpy(s,"* ");
  1443.       else
  1444.         strcpy(s,"  ");
  1445.     } else {
  1446.       if ((1L << (i1-32)) & thisuser.nscn2)
  1447.         strcpy(s,"* ");
  1448.       else
  1449.         strcpy(s,"  ");
  1450.     }
  1451.     sprintf(s2,"%s%s. %s",s,udir[i].keys, directories[i1].name);
  1452.     pla(s2,&abort);
  1453.   }
  1454.   nl();
  1455.   nl();
  1456. }
  1457.  
  1458. void config_nscan()
  1459. {
  1460.   char *s;
  1461.   int i,done,i1;
  1462.  
  1463.   l_config_nscan();
  1464.   done=0;
  1465.   do {
  1466.     nl();
  1467.     pl("Enter directory identifier, ? to list, or Q to Quit");
  1468.     prt(2,"Config: ");
  1469.     s=mmkey(1);
  1470.     if (s[0])
  1471.       for (i=0; i<64; i++)
  1472.         if (strcmp(udir[i].keys,s)==0) {
  1473.           i1=udir[i].subnum;
  1474.           if (i1<32)
  1475.             thisuser.nscn1 ^= ((1L) << i1);
  1476.           else
  1477.             thisuser.nscn2 ^= ((1L) << (i1-32));
  1478.         }
  1479.     if (strcmp(s,"Q")==0)
  1480.       done=1;
  1481.     if (strcmp(s,"?")==0)
  1482.       l_config_nscan();
  1483.   } while ((!done) && (!hangup));
  1484. }
  1485.  
  1486.  
  1487. void xfer_defaults()
  1488. {
  1489.   char s[81],s1[81],ch;
  1490.   int i,i1,i2,done;
  1491.  
  1492.   done=0;
  1493.   do {
  1494.     outchr(12);
  1495.     pl("1. Set N-Scan Directories.");
  1496.     pl("2. Set Default Protocol.");
  1497.     sprintf(s,"3. N-Scan Transfer after Message Base (%s).",
  1498.       thisuser.sysstatus & sysstatus_nscan_file_system?"Yes":"No");
  1499.     pl(s);
  1500.     sprintf(s,"4. Number of lines of extended description to print (%d line%s).",
  1501.       thisuser.num_extended,thisuser.num_extended==1?"":"s");
  1502.     pl(s);
  1503.     pl("Q. Quit.");
  1504.     nl();
  1505.     prt(2,"Which? ");
  1506.     helpl=32;
  1507.     ch=onek("Q1234");
  1508.     switch(ch) {
  1509.       case 'Q':
  1510.         done=1;
  1511.         break;
  1512.       case '1':
  1513.         helpl=24;
  1514.         config_nscan();
  1515.         break;
  1516.       case '2':
  1517.         nl();
  1518.         nl();
  1519.         pl("Enter your default protocol, 0 for none.");
  1520.         nl();
  1521.         helpl=40;
  1522.         i=get_protocol(xf_down);
  1523.         if (i>=0)
  1524.           thisuser.defprot=i;
  1525.         break;
  1526.       case '3':
  1527.         nl();
  1528.         nl();
  1529.         pl("Do you want to perform a newscan of all selected transfer");
  1530.         outstr("directories after an N-scan of the message base? ");
  1531.         if (thisuser.sysstatus & sysstatus_nscan_file_system)
  1532.           thisuser.sysstatus -= sysstatus_nscan_file_system;
  1533.         if (yn())
  1534.           thisuser.sysstatus += sysstatus_nscan_file_system;
  1535.         break;
  1536.       case '4':
  1537.         nl();
  1538.         nl();
  1539.         pl("How many lines of an extended description");
  1540.         pl("do you want to see when listing files (0-10)");
  1541.         npr("(Currently set to %d lines)\r\n",thisuser.num_extended);
  1542.         prt(5,"? ");
  1543.         helpl=41;
  1544.         input(s,3);
  1545.         if (s[0]) {
  1546.           i=atoi(s);
  1547.           if ((i>=0) && (i<=10))
  1548.             thisuser.num_extended=i;
  1549.         }
  1550.         break;
  1551.     }
  1552.   } while ((!done) && (!hangup));
  1553.  
  1554. }
  1555.  
  1556.  
  1557. void removefile()
  1558. {
  1559.   int i,i1,ok,rm,abort,rdlp;
  1560.   char ch,s[81],s1[81];
  1561.   uploadsrec u;
  1562.   userrec uu;
  1563.  
  1564.   dliscan();
  1565.   nl();
  1566.   pl("Enter filename to remove.");
  1567.   outstr(":");
  1568.   mpl(12);
  1569.   input(s,12);
  1570.   if (s[0]==0) {
  1571.     closedl();
  1572.     return;
  1573.   }
  1574.   if (strchr(s,'.')==NULL)
  1575.     strcat(s,".*");
  1576.   align(s);
  1577.   i=recno(s);
  1578.   abort=0;
  1579.   while ((!hangup) && (i>0) && (!abort)) {
  1580.     SETREC(i);
  1581.     read(dlf,(void *)&u,sizeof(uploadsrec));
  1582.     if ((dcs()) || ((u.ownersys==0) && (u.ownerusr==usernum))) {
  1583.       nl();
  1584.       if (check_batch_queue(u.filename)) {
  1585.         pl("That file is in the batch queue; remove it from there.");
  1586.         nl();
  1587.       } else {
  1588.         printfileinfo(&u,udir[curdir].subnum);
  1589.         prt(2,"Remove (Y/N/Q) : ");
  1590.         ch=onek("QNY");
  1591.         if (ch=='Q')
  1592.           abort=1;
  1593.         if (ch=='Y') {
  1594.           rdlp=1;
  1595.           if (dcs()) {
  1596.             prt(5,"Delete file too? ");
  1597.             rm=yn();
  1598.             if (rm) {
  1599.               prt(5,"Remove DL points? ");
  1600.               rdlp=yn();
  1601.             }
  1602.           } else
  1603.             rm=1;
  1604.           if (rm) {
  1605.             sprintf(s1,"%s%s",directories[udir[curdir].subnum].path,u.filename);
  1606.             unlink(s1);
  1607.             if ((rdlp) && (u.ownersys==0)) {
  1608.               read_user(u.ownerusr,&uu);
  1609.               if ((uu.inact & inact_deleted)==0) {
  1610.                 --uu.uploaded;
  1611.                 uu.uk -= ((u.numbytes+1023)/1024);
  1612.                 write_user(u.ownerusr,&uu);
  1613.               }
  1614.               close_user();
  1615.             }
  1616.           }
  1617.           if (u.mask & mask_extended)
  1618.             delete_extended_description(u.filename);
  1619.           sprintf(s1,"-%s Removed off of %s",u.filename,
  1620.                             directories[udir[curdir].subnum].name);
  1621.           sysoplog(s1);
  1622.           for (i1=i; i1<numf; i1++) {
  1623.             SETREC(i1+1);
  1624.             read(dlf,(void *)&u,sizeof(uploadsrec));
  1625.             SETREC(i1);
  1626.             write(dlf,(void *)&u,sizeof(uploadsrec));
  1627.           }
  1628.           --i;
  1629.           --numf;
  1630.           SETREC(0);
  1631.           read(dlf, &u, sizeof(uploadsrec));
  1632.           u.numbytes=numf;
  1633.           SETREC(0);
  1634.           write(dlf,(void *)&u,sizeof(uploadsrec));
  1635.         }
  1636.       }
  1637.     }
  1638.     i=nrecno(s,i);
  1639.   }
  1640.   closedl();
  1641. }
  1642.  
  1643.  
  1644.