home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / W / DEVBBS.ZIP / XFER.C < prev    next >
Text File  |  1992-07-28  |  35KB  |  1,600 lines

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