home *** CD-ROM | disk | FTP | other *** search
/ The Arcade BBS / arcadebbs.zip / arcadebbs / bbstools / MODS / ALLMODS.ZIP / TRY2UL40.ZIP / TRYTOUL.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-20  |  23.3 KB  |  1,045 lines

  1. #include "vars.h"
  2. #pragma hdrstop
  3.  
  4.  
  5. #include <dir.h>
  6.  
  7. /* Uncomment the correct one for you.  It will probably be __423__ for */
  8. /* most everyone out there for now (as of date of writting             */
  9. // #define __423__
  10. #define __424__
  11.  
  12.  
  13. #define SETREC(f,i)  sh_lseek(f,((long) (i))*((long)sizeof(uploadsrec)),SEEK_SET);
  14.  
  15. void upload(int dn)
  16. {
  17.   directoryrec d;
  18.   uploadsrec u,u1;
  19.   int i,i1,i2,i3,i4,ok,xfer,f, key;
  20.   char s[255],s1[81],*ss;
  21.   long l;
  22.   double ti;
  23.  
  24.  
  25.   listbatch();
  26.   nl();
  27.  
  28.   existprint("TRY2UL");
  29.  
  30.   outstr("2B3) 1Batch upload  <Just hit Enter>");
  31.   nl();
  32.   outstr("2S3) 1Single (one at a time) upload");
  33.   nl();
  34.   outstr("2Q3) 1Quit");
  35.   nl();
  36.   nl();
  37.  
  38.   outstr("1Your choice : ");
  39.  
  40.   key=onek("QB\rS");    /* <CR> and B for batch, Q to abort, S for single */
  41.  
  42.   switch(key)
  43.   {
  44.     case 'Q':
  45.       return;
  46.  
  47.     case 'B':
  48.     case '\r':
  49.       batchdl(2);
  50.       return;
  51.  
  52.     case 'S':
  53.       dliscan1(dn);
  54.       d=directories[dn];
  55.       if (numf>=d.maxfiles) {
  56.         nl();
  57.         nl();
  58.         pl(get_string(755));
  59.         nl();
  60.         return;
  61.       }
  62.       if ((d.mask & mask_no_uploads) && (!dcs())) {
  63.         nl();
  64.         nl();
  65.         pl(get_string(756));
  66.         nl();
  67.         return;
  68.       }
  69.       nl();
  70.       l=(long)freek1(d.path);
  71.       sprintf(s,"%s - %ldk %s.",get_string(757), l, get_string(758));
  72.       pl(s);
  73.       nl();
  74.       if (l<100) {
  75.         pl(get_string(759));
  76.         nl();
  77.         return;
  78.       }
  79.       prt(2,get_string(44));
  80.       input(s,12);
  81.       if (!okfn(s))
  82.         s[0]=0;
  83. #ifdef __423__     /* 423 specific */
  84. #ifdef OPT_FAST_SEARCH
  85.       else {
  86.         if (!is_uploadable(s)) {
  87.           if (so()) {
  88.             nl();
  89.             prt(5,get_string(1322));
  90.             if (!yn()) {
  91.               s[0]=0;
  92.             }
  93.           } else {
  94.             s[0]=0;
  95.             nl();
  96.             pl(get_string(1323));
  97.           }
  98.         }
  99.       }
  100. #endif
  101. #else     /* 424 specific */
  102.       else {
  103.         if (!is_uploadable(s)) {
  104.           if (so()) {
  105.             nl();
  106.             prt(5,get_string(1322));
  107.             if (!yn()) {
  108.               s[0]=0;
  109.             }
  110.           } else {
  111.             s[0]=0;
  112.             nl();
  113.             pl(get_string(1323));
  114.           }
  115.         }
  116.       }
  117. #endif
  118.       align(s);
  119.       if (strchr(s,'?')) {
  120.         return;
  121.       }
  122.       if (d.mask & mask_archive) {
  123.         ok=0;
  124.         s1[0]=0;
  125.         for (i=0; i<4; i++) {
  126.           if (syscfg.arcs[i].extension[0] && syscfg.arcs[i].extension[0]!=' ') {
  127.             if (s1[0])
  128.               strcat(s1,", ");
  129.             strcat(s1,syscfg.arcs[i].extension);
  130.             if (strcmp(s+9,syscfg.arcs[i].extension)==0)
  131.               ok=1;
  132.           }
  133.         }
  134.         if (!ok) {
  135.           nl();
  136.           pl(get_string(760));
  137.           pl(get_string(761));
  138.           pl(s1);
  139.           nl();
  140.           return;
  141.         }
  142.       }
  143.       strcpy(u.filename,s);
  144.       u.ownerusr=usernum;
  145.       u.ownersys=0;
  146.       u.numdloads=0;
  147.       u.filetype=0;
  148.       u.mask=0;
  149.       strcpy(u.upby,nam(&thisuser,usernum));
  150.       strcpy(u.date,date());
  151.       nl();
  152.       ok=1;
  153.       xfer=1;
  154.       if (check_batch_queue(u.filename))
  155.       {
  156.         ok=0;
  157.         nl();
  158.         pl(get_string(762));
  159.         nl();
  160.       }
  161.       else
  162.       {
  163.         sprintf(s1,"%s '%s' %s %s? ",get_string(757), s,get_string(763),d.name);
  164.         if (strcmp(s,get_string(1310)))
  165.           prt(5,s1);
  166.         else
  167.           ok=0;
  168.       }
  169.       if ((ok) && (yn())) {
  170.         sprintf(s1,"%s%s",d.path,s);
  171.         if (exist(s1)) {
  172.           if (dcs()) {
  173.             xfer=0;
  174.             nl();
  175.             nl();
  176.             pl(get_string(764));
  177.             prt(5,get_string(765));
  178.             if (yn()==0)
  179.               ok=0;
  180.           } else {
  181.             nl();
  182.             nl();
  183.             pl(get_string(766));
  184.             nl();
  185.             ok=0;
  186.           }
  187.         } else
  188.           if (!incom) {
  189.             nl();
  190.             pl(get_string(767));
  191.             pl(get_string(768));
  192.             nl();
  193.             ok=0;
  194.           }
  195.         if ((d.mask & mask_PD) && (ok)) {
  196.           nl();
  197.           prt(5,get_string(769));
  198.           if (!yn()) {
  199.             nl();
  200.             pl(get_string(770));
  201.             pl(get_string(771));
  202.             pl(get_string(772));
  203.             pl(get_string(773));
  204.             pl(get_string(774));
  205.             nl();
  206.             sprintf(s,get_stringx(1,41),u.filename);
  207.             add_ass(5,s);
  208.             ok=0;
  209.           } else
  210.             u.mask=mask_PD;
  211.         }
  212. #ifdef __423__    /* 423 specific */
  213. #ifndef OPT_FAST_SEARCH
  214.         if (ok) {
  215.           nl();
  216.           pl(get_string(775));
  217.           nl();
  218.           i2=0;
  219.           for (i=0; (i<num_dirs) && (udir[i].subnum!=-1); i++) {
  220.             strcpy(s,get_string(776));
  221.             strcat(s,directories[udir[i].subnum].name);
  222.             for (i3=i4=strlen(s); i3<i2; i3++) {
  223.               s[i3]=' ';
  224.               s[i3+1]=0;
  225.             }
  226.             i2=i4;
  227.             npr("%s\r",s);
  228.  
  229.             dliscan1(udir[i].subnum);
  230.             i1=recno(u.filename);
  231.             if (i1>=0) {
  232.               nl();
  233.               outstr(get_string(777));
  234.               pl(directories[udir[i].subnum].name);
  235.               if (dcs()) {
  236.                 nl();
  237.                 prt(5,get_string(778));
  238.                 if (!yn()) {
  239.                   ok=0;
  240.                   break;
  241.                 }
  242.                 nl();
  243.               } else {
  244.                 ok=0;
  245.                 break;
  246.               }
  247.             }
  248.           }
  249.           for (i1=0; i1<i2; i1++)
  250.             s[i1]=' ';
  251.           s[i1]=0;
  252.           npr("%s\r",s);
  253.           if (ok)
  254.             dliscan1(dn);
  255.           nl();
  256.         }
  257. #endif
  258. #else    /* 424 specific */
  259.         if (ok && (!(sysinfo.flags & OP_FLAGS_FAST_SEARCH)))
  260.         {
  261.           nl();
  262.           pl(get_string(775));
  263.           nl();
  264.           i2=0;
  265.           for (i=0; (i<num_dirs) && (udir[i].subnum!=-1); i++) {
  266.             strcpy(s,get_string(776));
  267.             strcat(s,directories[udir[i].subnum].name);
  268.             for (i3=i4=strlen(s); i3<i2; i3++) {
  269.               s[i3]=' ';
  270.               s[i3+1]=0;
  271.             }
  272.             i2=i4;
  273.             npr("%s\r",s);
  274.  
  275.             dliscan1(udir[i].subnum);
  276.             i1=recno(u.filename);
  277.             if (i1>=0) {
  278.               nl();
  279.               outstr(get_string(777));
  280.               pl(directories[udir[i].subnum].name);
  281.               if (dcs()) {
  282.                 nl();
  283.                 prt(5,get_string(778));
  284.                 if (!yn()) {
  285.                   ok=0;
  286.                   break;
  287.                 }
  288.                 nl();
  289.               } else {
  290.                 ok=0;
  291.                 break;
  292.               }
  293.             }
  294.           }
  295.           for (i1=0; i1<i2; i1++)
  296.             s[i1]=' ';
  297.           s[i1]=0;
  298.           npr("%s\r",s);
  299.           if (ok)
  300.             dliscan1(dn);
  301.           nl();
  302.         }
  303. #endif    /* end of 424 specific */
  304.         if (ok) {
  305.           nl();
  306.           pl(get_string(779));
  307.           outstr(": ");
  308.           inputl(u.description,58);
  309.           nl();
  310.           ss=NULL;
  311.           modify_extended_description(&ss, directories[dn].name,u.filename);
  312.           if (ss) {
  313.             add_extended_description(u.filename,ss);
  314.             u.mask |= mask_extended;
  315.             farfree(ss);
  316.           }
  317.           nl();
  318.           if (xfer) {
  319.             write_inst(INST_LOC_UPLOAD,udir[curdir].subnum,INST_FLAGS_ONLINE);
  320.             ti=timer();
  321.             receive_file(s1,&ok,&u.filetype, u.filename, dn);
  322.             ti=timer()-ti;
  323.             if (ti<0)
  324.               ti += 24.0*3600.0;
  325.             thisuser.extratime += ti;
  326.           }
  327.           if (ok) {
  328.             if (ok==1) {
  329.               f=sh_open1(s1,O_RDONLY | O_BINARY);
  330.               if (f<0) {
  331.                 ok=0;
  332.                 nl();
  333.                 nl();
  334.                 pl(get_string(780));
  335.                 nl();
  336.                 if (u.mask & mask_extended)
  337.                   delete_extended_description(u.filename);
  338.               }
  339.               if (ok && syscfg.upload_c[0]) {
  340.                 sh_close(f);
  341.                 pl(get_string(26));
  342.                 if (check_ul_event(dn,&u)) {
  343.                   if (u.mask & mask_extended)
  344.                     delete_extended_description(u.filename);
  345.                   ok=0;
  346.                 } else {
  347.                   f=sh_open1(s1,O_RDONLY | O_BINARY);
  348.                 }
  349.               }
  350.             }
  351.             if (ok) {
  352.               if (ok==1) {
  353.                 l=filelength(f);
  354.                 u.numbytes=l;
  355.                 sh_close(f);
  356.                 ++thisuser.uploaded;
  357. #ifdef __423__                       /* 423 specific */
  358. #ifdef OPT_FAST_SEARCH
  359.                 modify_database(u.filename,1);
  360. #endif
  361. #ifdef OPT_PACKSCAN_FREQ
  362.                 remotenotify(u.filename,u.description);
  363. #endif
  364. #else                                /* 424 specific */
  365.                 modify_database(u.filename,1);
  366.                 if (sysinfo.flags & OP_FLAGS_PACKSCAN_FREQ)
  367.                   remotenotify(u.filename,u.description);
  368. #endif                               /* end 424 specific */
  369.  
  370.                 thisuser.uk += bytes_to_k(u.numbytes);
  371.  
  372.  
  373.                 get_file_idz(&u,dn);
  374.               } else
  375.                 u.numbytes=0;
  376.               time(&l);
  377.               u.daten=l;
  378.               f=sh_open(dlfn,O_RDWR | O_BINARY | O_CREAT, S_IREAD | S_IWRITE);
  379.               for (i=numf; i>=1; i--) {
  380.                 SETREC(f,i);
  381.                 sh_read(f,(void *)&u1,sizeof(uploadsrec));
  382.                 SETREC(f,i+1);
  383.                 sh_write(f,(void *)&u1,sizeof(uploadsrec));
  384.               }
  385.               SETREC(f,1);
  386.               sh_write(f,(void *)&u,sizeof(uploadsrec));
  387.               ++numf;
  388.               SETREC(f,0);
  389.               sh_read(f, &u1, sizeof(uploadsrec));
  390.               u1.numbytes=numf;
  391.               u1.daten=l;
  392.               dir_dates[dn]=l;
  393.               SETREC(f,0);
  394.               sh_write(f,(void *)&u1,sizeof(uploadsrec));
  395.               f=sh_close(f);
  396.               if (ok==1) {
  397.                 lock_status();
  398.                 ++status.uptoday;
  399.                 ++status.filechange[filechange_upload];
  400.                 save_status();
  401.                 sprintf(s,get_stringx(1,42),u.filename,directories[dn].name);
  402.                 sysoplog(s);
  403.                 nl();
  404.                 nl();
  405.                 pl(get_string(781));
  406.                 nl();
  407.                 outstr(get_string(782));
  408.                 npr("%-6.3f\r\n", ratio());
  409.                 nl();
  410.                 nl();
  411.                 if (useron)
  412.                   topscreen();
  413.               }
  414.             }
  415.           } else {
  416.             nl();
  417.             nl();
  418.             pl(get_string(783));
  419.             nl();
  420.             if (u.mask & mask_extended)
  421.               delete_extended_description(u.filename);
  422.           }
  423.         }
  424.       }
  425.       break;
  426.   }
  427.  
  428. }
  429.  
  430.  
  431. int try_to_ul(char *fn)
  432. {
  433.  
  434.   int ac=0;
  435.   char src[201], dest[201];
  436.  
  437.  
  438.   if ((uconfsub[1].confnum!=-1) && (okconf(&thisuser)))
  439.     { ac=1; tmp_disable_conf(1); }
  440.  
  441.   if(!try_to_ul_wh(fn))
  442.   {
  443.     if(ac)
  444.       tmp_disable_conf(0);
  445.     return 0;       /* success */
  446.   }
  447.  
  448.   // see if 'try2ul' already exist off the upload dir, if not, creat it
  449.   sprintf(dest,"%sTRY2UL", syscfg.dloadsdir);
  450.   if(chdir(dest))
  451.   {
  452.     cd_to(cdir);       /* get back to our bbs dir                */
  453.     mkdir(dest);       /* creat the \DLOADS\TRY2UL directory     */
  454.   }
  455.   cd_to(cdir);         /* ensure we are in the correct directory */
  456.  
  457.  
  458.   ansic(2);
  459.   pl("Your file had problems, it is being moved to a special dir for sysop review");
  460.  
  461.  
  462.   sprintf(src, "Failed to upload %s, moving to TRY2UL dir", fn);
  463.   sysoplog(src);
  464.  
  465.  
  466.   sprintf(src,"%s%s",syscfgovr.batchdir, fn);
  467.   sprintf(dest,"%sTRY2UL\\%s", syscfg.dloadsdir, fn);
  468.  
  469.  
  470.   if(exist(dest))       /* this is iffy <sp?/who cares>, I chooose to   */
  471.     unlink(dest);       /* remove duplicates in the try2ul dir, so keep */
  472.                         /* it clean and up to date                      */
  473.  
  474.   copyfile(src, dest, 1);  /* copy file from batch dir, over to try2ul dir */
  475.  
  476.  
  477.   if (useron)
  478.     topscreen();
  479.  
  480.  
  481.   if(ac)
  482.     tmp_disable_conf(0);
  483.  
  484.   return 1;         /* return failure, removes ul k credits etc... */
  485. }
  486.  
  487.  
  488. int try_to_ul_wh(char *fn)
  489. {
  490.   directoryrec d;
  491.   char s[101], s1[101], s2[101], *ss;
  492.   int i, i1, i2, i3, i4, done=0, key, ok, dn=0, f; // upload to sysop dir
  493.   long l;
  494.   uploadsrec u, u1;
  495.  
  496.  
  497.  
  498.   unalign(fn);
  499.   strip_string(fn);
  500.  
  501.   strcpy(s, fn);
  502.   if (!okfn(fn))
  503.   {
  504.     t2u_error(fn, "Bad filename");    /* bad filename */
  505.     return(1);
  506.   }
  507.  
  508.   CLS();
  509.   nln(3);
  510.  
  511.   if ((thisuser.restrict & (restrict_validate | restrict_upload)) || (syscfg.sysconfig & sysconfig_all_sysop))
  512.   {
  513.     if (syscfg.newuploads<num_dirs)
  514.       dn=syscfg.newuploads;
  515.     else
  516.       dn=0;
  517.   }
  518.   else
  519.   {
  520.     int done=0, x;
  521.     char temp[10];
  522.  
  523.     while(!done)  /* The hangup check is below */
  524.     {
  525.       if(hangup)  /* right here, so uploads get uploaded even on hangup */
  526.       {
  527.         if (syscfg.newuploads<num_dirs)
  528.           dn=syscfg.newuploads;
  529.         else
  530.           dn=0;
  531.         done=1;
  532.       }
  533.       else
  534.       {
  535.         wait_sec_or_hit(1);
  536.  
  537.         nl();
  538.         npr("Upload %s to which dir? <CR>=0 ?=List ", fn);
  539.         nl();
  540.  
  541.         mpl(5);
  542.         input(temp, 5);
  543.  
  544.         strip_string(temp);
  545.  
  546.         if(temp[0]=='?')
  547.           dirlist();
  548.         else if(!temp[0])
  549.         {
  550.           dn=0;
  551.           done=1;
  552.         }
  553.         else
  554.         {
  555.           x=atoi(temp);
  556.  
  557.           if(udir[x].subnum>=0)
  558.           {
  559.             dliscan1(udir[x].subnum);
  560.             d=directories[dn];
  561.  
  562.             if((d.mask & mask_no_uploads) && (!dcs()))
  563.             {
  564.               pl("Can't upload there...");
  565.               pausescr();
  566.             }
  567.             else
  568.             {
  569.               dn=udir[x].subnum;
  570.               done=1;
  571.             }
  572.           }
  573.         }
  574.       }
  575.     }
  576.   }
  577.  
  578.   dliscan1(dn);
  579.   d=directories[dn];
  580.   if (numf>=d.maxfiles)
  581.   {
  582.     t2u_error(fn, get_string(755));
  583.     return 1;
  584.   }
  585.   if ((d.mask & mask_no_uploads) && (!dcs()))
  586.   {
  587.     t2u_error(fn, get_string(756));
  588.     return 1;
  589.   }
  590.  
  591.  
  592.  
  593. #ifdef __423__                /* 423 specific */
  594. #ifdef OPT_FAST_SEARCH
  595.   if (!is_uploadable(s))
  596.   {
  597.     if (so())
  598.     {
  599.       nl();
  600.       prt(5,get_string(1322));
  601.       if (!yn())
  602.       {
  603.         t2u_error(fn, get_string(1323));
  604.         return 1;
  605.       }
  606.     }
  607.     else
  608.     {
  609.       t2u_error(fn, get_string(1323));
  610.       return 1;
  611.     }
  612.   }
  613. #endif
  614. #else
  615.   if (!is_uploadable(s))
  616.   {
  617.     if (so())
  618.     {
  619.       nl();
  620.       prt(5,get_string(1322));
  621.       if (!yn())
  622.       {
  623.         t2u_error(fn, get_string(1323));
  624.         return 1;
  625.       }
  626.     }
  627.     else
  628.     {
  629.       t2u_error(fn, get_string(1323));
  630.       return 1;
  631.     }
  632.   }
  633. #endif
  634.  
  635.   align(s);
  636.   if (strchr(s,'?'))
  637.   {
  638.     t2u_error(fn, "Contains wildcards");
  639.     return 1;
  640.   }
  641.   if (d.mask & mask_archive)
  642.   {
  643.     ok=0;
  644.     s1[0]=0;
  645.     for (i=0; i<4; i++)
  646.     {
  647.       if (syscfg.arcs[i].extension[0] && syscfg.arcs[i].extension[0]!=' ')
  648.       {
  649.         if (s1[0])
  650.           strcat(s1,", ");
  651.         strcat(s1,syscfg.arcs[i].extension);
  652.         if (strcmp(s+9,syscfg.arcs[i].extension)==0)
  653.           ok=1;
  654.       }
  655.     }
  656.     if(!ok)
  657.     {
  658.       nl();
  659.       pl(get_string(760));
  660.       pl(get_string(761));
  661.       pl(s1);
  662.       nl();
  663.  
  664.       t2u_error(fn, "Unsupported archive");
  665.       return 1;
  666.     }
  667.   }
  668.  
  669.  
  670.   strcpy(u.filename,s);
  671.   u.ownerusr=usernum;
  672.   u.ownersys=0;
  673.   u.numdloads=0;
  674.   u.filetype=0;
  675.   u.mask=0;
  676.   strncpy(u.upby,nam(&thisuser,usernum), 44);
  677.   u.upby[44]=0;
  678.   strcpy(u.date,date());
  679.  
  680.   sprintf(s1,"%s%s",d.path,s);
  681.   if (exist(s1))
  682.   {
  683.     if (dcs())
  684.     {
  685.       nl();
  686.       nl();
  687.       pl(get_string(764));
  688.       prt(5,get_string(765));
  689.       if (yn()==0)
  690.       {
  691.         t2u_error(fn, get_string(766));
  692.         return 1;
  693.       }
  694.     }
  695.     else
  696.     {
  697.       t2u_error(fn, get_string(766));
  698.       return 1;
  699.     }
  700.   }
  701.  
  702.  
  703. #ifdef __423__              /* 423 specific */
  704. #ifndef OPT_FAST_SEARCH
  705.   nl();
  706.   pl(get_string(775));
  707.   nl();
  708.   i2=0;
  709.  
  710.   for (i=0; (i<num_dirs) && (udir[i].subnum!=-1); i++)
  711.   {
  712.     strcpy(s1,get_string(776));
  713.     strcat(s1,directories[udir[i].subnum].name);
  714.  
  715.     for (i3=i4=strlen(s1); i3<i2; i3++)
  716.     {
  717.       s1[i3]=' ';
  718.       s1[i3+1]=0;
  719.     }
  720.  
  721.     i2=i4;
  722.     outstr(s1);
  723.     outchr('\r');
  724.  
  725.     dliscan1(udir[i].subnum);
  726.     i1=recno(u.filename);
  727.     if (i1>=0)
  728.     {
  729.       nl();
  730.       outstr(get_string(777));
  731.       pl(directories[udir[i].subnum].name);
  732.  
  733.       if (dcs())
  734.       {
  735.         nl();
  736.         prt(5,get_string(778));
  737.         if (!yn())
  738.         {
  739.           t2u_error(fn, get_string(766));
  740.           return 1;
  741.         }
  742.         nl();
  743.       }
  744.       else
  745.       {
  746.         t2u_error(fn, get_string(766));
  747.         return 1;
  748.       }
  749.     }
  750.   }
  751.  
  752.  
  753.   for (i1=0; i1<i2; i1++)
  754.     s1[i1]=' ';
  755.   s1[i1]=0;
  756.   npr("%s\r",s1);
  757.  
  758.   dliscan1(dn);
  759.   nl();
  760. #endif
  761. #else     /* 424 specific */
  762.   if (ok && (!(sysinfo.flags & OP_FLAGS_FAST_SEARCH)))
  763.   {
  764.     nl();
  765.     pl(get_string(775));
  766.     nl();
  767.     i2=0;
  768.  
  769.     for (i=0; (i<num_dirs) && (udir[i].subnum!=-1); i++)
  770.     {
  771.       strcpy(s1,get_string(776));
  772.       strcat(s1,directories[udir[i].subnum].name);
  773.  
  774.       for (i3=i4=strlen(s1); i3<i2; i3++)
  775.       {
  776.         s1[i3]=' ';
  777.         s1[i3+1]=0;
  778.       }
  779.  
  780.       i2=i4;
  781.       outstr(s1);
  782.       outchr('\r');
  783.  
  784.       dliscan1(udir[i].subnum);
  785.       i1=recno(u.filename);
  786.       if (i1>=0)
  787.       {
  788.         nl();
  789.         outstr(get_string(777));
  790.         pl(directories[udir[i].subnum].name);
  791.  
  792.         if (dcs())
  793.         {
  794.           nl();
  795.           prt(5,get_string(778));
  796.           if (!yn())
  797.           {
  798.             t2u_error(fn, get_string(766));
  799.             return 1;
  800.           }
  801.           nl();
  802.         }
  803.         else
  804.         {
  805.           t2u_error(fn, get_string(766));
  806.           return 1;
  807.         }
  808.       }
  809.     }
  810.  
  811.  
  812.     for (i1=0; i1<i2; i1++)
  813.       s1[i1]=' ';
  814.     s1[i1]=0;
  815.     npr("%s\r",s1);
  816.  
  817.     dliscan1(dn);
  818.     nl();
  819.   }
  820. #endif             /* end of 424 specific */
  821.  
  822.   // Copy file from batch dir to new dir
  823.   sprintf(s1,"%s%s",syscfgovr.batchdir, fn);
  824.   sprintf(s2,"%s%s", d.path, fn);
  825.  
  826.   if(exist(s2))
  827.     unlink(s2);
  828.  
  829.   movefile(s1,s2, 1); /* s1 and s2 should remain set, they are used below */
  830.   strcpy(u.description, "NO DESCRIPTION GIVEN");
  831.  
  832.  
  833.   // Now get the file_id.diz
  834.   get_file_idz(&u,dn);
  835.  
  836.  
  837.   done=0;
  838.   while(!done && !hangup)
  839.   {
  840.     int abort=0;
  841.  
  842.     CLS();
  843.     nl();
  844.     npr("1Upload going to 3%s", d.name);
  845.     nln(2);
  846.  
  847.     npr("   1Filename    8: 7%s", fn);
  848.     nl();
  849.     npr("2A5] 1Description 8: 7%s", u.description);
  850.     nl();
  851.     pl("2B5] 1Modify extended description");
  852.     nl();
  853.     print_extended(u.filename, &abort, 10, 0);
  854.     npr("2<5CR2> 1to continue, 3Q1 to abort upload: ");
  855.     mpl(1);
  856.  
  857.     key=onek("\rQABC");
  858.  
  859.     switch(key)
  860.     {
  861.       case 'Q':
  862.         outstr("Are you sure, file will be lost? ");
  863.         if(yn())
  864.         {
  865.           t2u_error(fn, "Changed mind");
  866.           movefile(s2, s1, 1);     /* move file back to batch dir */
  867.           return 1;
  868.         }
  869.         break;
  870.  
  871.       case 'A':
  872.         nl();
  873.         pl(get_string(779));
  874.         outstr(": ");
  875.         inputl(u.description,58);
  876.         break;
  877.  
  878.       case 'B':
  879.         nl();
  880.  
  881.         ss=read_extended_description(u.filename);
  882.         prt(5,get_string(834));
  883.         if (yn())
  884.         {
  885.           nl();
  886.           if (ss)
  887.           {
  888.             prt(5,get_string(835));
  889.             if (yn())
  890.             {
  891.               farfree(ss);
  892.               delete_extended_description(u.filename);
  893.               u.mask &= ~mask_extended;
  894.             }
  895.             else
  896.             {
  897.               u.mask |= mask_extended;
  898.               modify_extended_description(&ss,
  899.                 directories[udir[curdir].subnum].name,u.filename);
  900.               if (ss)
  901.               {
  902.                 delete_extended_description(u.filename);
  903.                 add_extended_description(u.filename,ss);
  904.                 farfree(ss);
  905.               }
  906.             }
  907.           }
  908.           else
  909.           {
  910.             modify_extended_description(&ss,
  911.                 directories[udir[curdir].subnum].name,u.filename);
  912.             if (ss)
  913.             {
  914.               add_extended_description(u.filename,ss);
  915.               farfree(ss);
  916.               u.mask |= mask_extended;
  917.             }
  918.             else
  919.               u.mask &= ~mask_extended;
  920.           }
  921.         }
  922.         else if (ss)
  923.         {
  924.           farfree(ss);
  925.           u.mask |= mask_extended;
  926.         }
  927.         else
  928.           u.mask &= ~mask_extended;
  929.  
  930.         break;
  931.  
  932.       case '\r':
  933.         nl();
  934.         done=1;
  935.     }
  936.   }
  937.  
  938.   nln(3);
  939.  
  940.  
  941. // Ok to upload, save file in database, update user info etc...
  942.  
  943.   sprintf(s1,"%s%s",d.path,s);
  944.   f=sh_open1(s1,O_RDONLY | O_BINARY);
  945.  
  946.   if (f<0)   /* dos error, file not found */
  947.   {
  948.     if (u.mask & mask_extended)
  949.       delete_extended_description(u.filename);
  950.  
  951.     t2u_error(fn, get_string(780));
  952.     return 1;
  953.   }
  954.  
  955.   if (syscfg.upload_c[0])
  956.   {
  957.     sh_close(f);
  958.     pl(get_string(26));
  959.     if (check_ul_event(dn,&u))
  960.     {
  961.       if (u.mask & mask_extended)
  962.         delete_extended_description(u.filename);
  963.  
  964.       t2u_error(fn, "Failed upload event");
  965.       return 1;
  966.     }
  967.     else
  968.       f=sh_open1(s1,O_RDONLY | O_BINARY);
  969.   }
  970.  
  971.   l=filelength(f);
  972.   u.numbytes=l;
  973.   f=sh_close(f);
  974.   ++thisuser.uploaded;
  975.  
  976.   // Move files and add file to database
  977.   time(&l);
  978.   u.daten=l;
  979.   f=sh_open(dlfn,O_RDWR | O_BINARY | O_CREAT, S_IREAD | S_IWRITE);
  980.   for (i=numf; i>=1; i--)
  981.   {
  982.     SETREC(f,i);
  983.     sh_read(f,(void *)&u1,sizeof(uploadsrec));
  984.     SETREC(f,i+1);
  985.     sh_write(f,(void *)&u1,sizeof(uploadsrec));
  986.   }
  987.  
  988.   SETREC(f,1);
  989.   sh_write(f,(void *)&u,sizeof(uploadsrec));
  990.   ++numf;
  991.   SETREC(f,0);
  992.   sh_read(f, &u1, sizeof(uploadsrec));
  993.   u1.numbytes=numf;
  994.   u1.daten=l;
  995.   dir_dates[dn]=l;
  996.   SETREC(f,0);
  997.   sh_write(f,(void *)&u1,sizeof(uploadsrec));
  998.   f=sh_close(f);
  999.   // Done putting file in database and updating record 0
  1000.  
  1001.  
  1002. #ifdef __423__                           /* 423 specific */
  1003. #ifdef OPT_FAST_SEARCH
  1004.   modify_database(u.filename,1);
  1005. #endif
  1006. #ifdef OPT_PACKSCAN_FREQ
  1007.   remotenotify(u.filename,u.description);
  1008. #endif
  1009. #else                                    /* 424 specific */
  1010.   modify_database(u.filename,1);
  1011.   if (sysinfo.flags & OP_FLAGS_PACKSCAN_FREQ)
  1012.     remotenotify(u.filename,u.description);
  1013. #endif                                   /* end of 424 specific */
  1014.  
  1015.  
  1016.   thisuser.uk += bytes_to_k(u.numbytes);
  1017.  
  1018.   lock_status();
  1019.   ++status.uptoday;
  1020.   ++status.filechange[filechange_upload];
  1021.   save_status();
  1022.   sprintf(s,get_stringx(1,42),u.filename,directories[dn].name);
  1023.   sysoplog(s);
  1024.  
  1025.  
  1026.   return 0;  // This means success
  1027. }
  1028.  
  1029.  
  1030. void t2u_error(char *fn, char *msg)
  1031. {
  1032.   char temp[201];
  1033.  
  1034.   nln(2);
  1035.  
  1036.   sprintf(temp,"**  %s failed T2U qualifications", fn);
  1037.   pl(temp);
  1038.   sysoplog(temp);
  1039.  
  1040.   sprintf(temp, "** Reason : %s", msg);
  1041.   pl(temp);
  1042.   sysoplog(temp);
  1043. }
  1044.  
  1045.