home *** CD-ROM | disk | FTP | other *** search
/ PC-Online 1998 February / PCOnline_02_1998.iso / filesbbs / dos / cutil100.exe / DOWNLOAD.MEX next >
Text File  |  1997-10-07  |  10KB  |  350 lines

  1. /////////////////////////////////////////////////////////////////////////
  2. //
  3. // Originaly from StarDown V1.00 - (!)1996 Larry Monte\StarLab Systems Software
  4. // CoolUtils V1.00 - (c)1996-97 Updated to look like RA by Neil Staib
  5. //
  6. // MEX: Copyright 1990, 1995 by Lanius Corporation.  All rights reserved.
  7. //
  8. // DownLoad Command Replacement. Allows local users (sysops) to specify a
  9. // path to extract tagged files to.
  10. //
  11. /////////////////////////////////////////////////////////////////////////
  12.  
  13. #include <prm.mh>
  14. #include <max.mh>
  15.  
  16. // Comment the below if you have external protocols
  17. #define protocol_opt
  18.  
  19. ///////////////////////
  20. // Language Definations
  21. ///////////////////////
  22. #define notag   "There are no currently tag files"
  23. #define file    "File:"
  24. #define 1add    "1 files added."
  25. #define nosend  "No files to send !"
  26. #define taglist "Tagged file list (For Downloading):"
  27. #define tfiles  "files"
  28. #define menu    "(A)dd, (D)elete or (C)lear all entries (Enter to continue):"
  29. #define delete  "Delete:"
  30. #define clear   "Clear tag list (y/n)?"
  31. #define yes     "Yes"
  32. #define no      "No"
  33. #define locald  "Local download."
  34. #define ldir    "Directory to move files to:"
  35. #define dprot   "Default protocol:"
  36. #define lmenu   "(S)tart transfer, (L)ogoff after transfer, (N)ew protocol, (A)bort:"
  37. #define protend "Protocol (Enter=quit):"
  38. #define nosent  "No Files Sent"
  39. #define sent    "File Sent"
  40. #define sents   "Files Sent"
  41.  
  42. /////////////////////
  43.  
  44. void main()
  45. {
  46.   int: fnum, flags, pos, qsize, ok,new,done,prot, before, after;
  47.   long: fsize, txtime,tsize;
  48.   char: nonstop,inkey;
  49.   string: rootname, filescheck, added_filename, new_path, out_path,backslash,newdir;
  50.   string: delete_tag,ready_menu;
  51.  
  52.   ok := 0;
  53.   new := 0;
  54.   prot := 0;
  55.   tsize :=0;
  56.  
  57. start:
  58.     qsize := (tag_queue_size());
  59.  
  60.    if (qsize < 1 )
  61.    {
  62.       print(AVATAR_CLS);
  63.       print(COL_LRED, notag, ".\n");
  64.       print("\n");
  65.       print(COL_CYAN , file, " ");
  66.       input_str(added_filename, INPUT_WORD,0,14,"");
  67.  
  68.        if (added_filename <> "")
  69.         {
  70.          input := "A;"+added_filename;
  71.          set_output(DISABLE_BOTH);
  72.          menu_cmd(512,"");
  73.          set_output(DISABLE_NONE);
  74.          print(COL_YELLOW, "\n", 1add);
  75.  
  76.          new := 1;
  77.         }
  78.            if (tag_queue_size() < 1 )
  79.            {
  80.             print ("\n\n\n");
  81.             print (COL_YELLOW , nosend);
  82.             return;
  83.            }
  84.    }
  85.    else
  86.     {
  87.      // Show Tag Files
  88.      print(AVATAR_CLS);
  89.      print(COL_LRED, taglist, "\n");
  90.      print("\n");
  91.      reset_more(nonstop);
  92.      qsize := (tag_queue_size());
  93.  
  94.      for (fnum := 0; fnum < qsize AND do_more(nonstop, COL_CYAN);
  95.         fnum := fnum + 1)
  96.      {
  97.        tag_get_name( fnum, flags, filescheck);
  98.        pos := strridx(filescheck, 0, '\\');
  99.        if (pos=0)
  100.          rootname := filescheck;
  101.        else
  102.         {
  103.          rootname := substr(filescheck, pos+1, strlen(filescheck)-pos+1);
  104.          fsize := (filesize(filescheck)/1000);
  105.          tsize := tsize + fsize;
  106.          print(COL_YELLOW, "(", fnum+1, ") ", COL_LMAGENTA, strpad(
  107.          rootname,13,' '), ' ', COL_LGREEN, ltostr(fsize), "k\n");
  108.         }
  109.      }
  110.  
  111.     }
  112.     while (ok = 0)
  113.     {
  114.        if (prot = 1)
  115.        {
  116.         print(AVATAR_CLS, "\n\n");
  117.         goto newprot;
  118.        }
  119.        if (new = 1 )
  120.         {
  121.          print(AVATAR_CLS);
  122.          print(COL_LRED, taglist, "\n");
  123.          print("\n");
  124.          reset_more(nonstop);
  125.          qsize := (tag_queue_size());
  126.  
  127.         for (fnum := 0; fnum < qsize AND do_more(nonstop, COL_CYAN);
  128.           fnum := fnum + 1)
  129.          {
  130.           tag_get_name( fnum, flags, filescheck);
  131.           pos := strridx(filescheck, 0, '\\');
  132.           if (pos=0)
  133.             rootname := filescheck;
  134.           else
  135.            {
  136.             rootname := substr(filescheck, pos+1, strlen(filescheck)-pos+1);
  137.             fsize := (filesize(filescheck)/1000);
  138.             tsize := tsize + fsize;
  139.             print(COL_YELLOW, "(", fnum+1, ") ", COL_LMAGENTA, strpad(
  140.             rootname,13,' '), ' ', COL_LGREEN, ltostr(fsize), "k\n");
  141.            }
  142.          }
  143.  
  144.          new := 0;
  145.         }
  146.       print("\n");
  147.       qsize := (tag_queue_size());
  148.       print(COL_LCYAN ,qsize, " ", tfiles, " ", ltostr(tsize), "k \n");
  149.       print("\n");
  150.       print(COL_LCYAN, menu);
  151.  
  152.       userenter:
  153.       inkey:=getch();
  154.  
  155.       if (inkey = 'a' or inkey = 'A')
  156.           {
  157.              print("\n\n");
  158.              print(COL_CYAN , file, " ");
  159.              input_str(added_filename, INPUT_WORD,0,14,"");
  160.  
  161.                 if (added_filename <> "")
  162.                 {
  163.                   input := "A;"+added_filename;
  164.                   set_output(DISABLE_BOTH);
  165.                   menu_cmd(512,"");
  166.                   set_output(DISABLE_NONE);
  167.                   print(COL_YELLOW, "\n", 1add);
  168.  
  169.                    if (tag_queue_size() < 1 )
  170.                    {
  171.                       print ("\n\n\n");
  172.                       print (COL_YELLOW, nosend);
  173.                       ok := 1;
  174.                    }
  175.                 }
  176.             goto start;
  177.         }
  178.  
  179.         if (inkey = 'd' or inkey = 'D')
  180.         {
  181.               print("\n\n");
  182.               print(COL_LRED, delete, " ");
  183.               input_str(delete_tag, INPUT_NLB_LINE,0,2,"");
  184.  
  185.               if (delete_tag = "")
  186.                {
  187.                  goto start;
  188.                }
  189.               else if (delete_tag <> "")
  190.               {
  191.                tag_dequeue_file((strtoi(delete_tag)-1));
  192.                goto start;
  193.               }
  194.           }
  195.         if (inkey = 'c' or inkey = 'C')
  196.         {
  197.             print("\n\n");
  198.             print(COL_LRED, clear, " ");
  199.  
  200.             inkey:=getch();
  201.  
  202.             if (inkey = 'y' or inkey = 'Y')
  203.               {
  204.                 print(" ", yes, "\n");
  205.                 input := "C;q;";
  206.                 set_output(DISABLE_BOTH);
  207.                 menu_cmd(512,"");
  208.                 set_output(DISABLE_NONE);
  209.                 goto start;
  210.               }
  211.             else if (inkey = 13 or inkey = 'n' or inkey = 'N')
  212.                {
  213.                  print(" ", no);
  214.                  goto start;
  215.                }
  216.         }
  217.        if (inkey = 13)
  218.        {
  219.          goto newprot;
  220.        }
  221.      goto userenter;
  222. newprot:
  223.      before := (tag_queue_size());
  224.        if (tag_queue_size() > 0 and id.local = TRUE)
  225.         {
  226.          print("\n");
  227.          print(COL_WHITE, locald, "\n");
  228.          print("\n");
  229.          print(COL_LGREEN, ldir, " ");
  230.  
  231.          input_str(new_path,INPUT_WORD,0,80,"");
  232.  
  233.            if (new_path <> "" )
  234.             {
  235.               backslash := "\\";
  236.               newdir := new_path + backslash;
  237.               out_path := newdir;
  238.               qsize := (tag_queue_size());
  239.               for (fnum := 0; fnum < qsize; fnum := fnum +1)
  240.                {
  241.                 tag_get_name( fnum, flags, filescheck);
  242.                 pos := strridx(filescheck, 0, '\\');
  243.                 if (pos=0)
  244.                 rootname := filescheck;
  245.                 else
  246.                 rootname := substr(filescheck, pos+1,
  247.                            strlen(filescheck)-pos+1);
  248.                 filecopy(filescheck,out_path+rootname);
  249.                 }
  250.             set_output(DISABLE_BOTH);
  251.             input := "C;|";
  252.             menu_cmd(512,"");
  253.             set_output(DISABLE_NONE);
  254.             ok := 1;
  255.             }
  256.            else
  257.             {
  258.               ok := 1;
  259.             }
  260.          }
  261.         else if (tag_queue_size() > 0 and id.local = FALSE)
  262.              {
  263.               print(COL_LGREEN, "\n", dprot, " ",protocol_num_to_name(usr.def_proto), "\n");
  264.               print(COL_LCYAN, lmenu, " ");
  265.               inkey:=getch();
  266.  
  267.               if (inkey = 'l' or inkey = 'L')
  268.                 {
  269.                  input := "/g";
  270.                  menu_cmd(505,"");
  271.                  ok := 1;
  272.                 }
  273.               if (inkey = 'a' or inkey = 'A')
  274.                  {
  275.                    ok := 1;
  276.                  }
  277.               if (inkey = 13 or inkey = 's' or inkey = 'S')
  278.                  {
  279.                   input := "|";
  280.                   menu_cmd(505,"");
  281.                   ok := 1;
  282.                  }
  283.               if (inkey = 'n' or inkey = 'N')
  284.                  {
  285.  
  286.                 #ifdef protocol_opt
  287.                  {
  288.                    display_file(prm_string(PRM_PROTOCOLS),nonstop);
  289.                    print(protend, " ");
  290.  
  291.                   do
  292.                   {
  293.                    inkey:=getch();
  294.  
  295.                    if (inkey = 'z' or inkey = 'y' or inkey = 'g' or inkey = 'x' or inkey = '1' or inkey = 's' or inkey=13 or inkey = 'Z' or inkey = 'Y' or inkey = 'G' or inkey = 'X' or inkey = 'S')
  296.                    {
  297.                      done:=TRUE;
  298.  
  299.                      if (inkey='z' or inkey = 'Z' )
  300.                      usr.def_proto:= PROTOCOL_ZMODEM ;
  301.                      else if (inkey='y' or inkey ='Y')
  302.                      usr.def_proto:= PROTOCOL_YMODEM ;
  303.                      else if (inkey='g' or inkey = 'G')
  304.                      usr.def_proto:= PROTOCOL_YMODEMG ;
  305.                      else if (inkey='x' or inkey = 'X')
  306.                      usr.def_proto:= PROTOCOL_XMODEM ;
  307.                      else if (inkey='1')
  308.                      usr.def_proto:= PROTOCOL_XMODEM1K ;
  309.                      else if (inkey='s' or inkey = 'S')
  310.                      usr.def_proto:= PROTOCOL_SEALINK ;
  311.                    }
  312.                    else
  313.                     {
  314.                      done:=FALSE;
  315.                     }
  316.                  }
  317.                   while (done = FALSE);
  318.                   prot:=1;
  319.                }
  320.                #else
  321.                 {
  322.                  print(AVATAR_CLS, "\n");
  323.                  print(protocol_num_to_name(usr.def_proto), '\n');
  324.                  menu_cmd(618, "");
  325.                 }
  326.                #endif
  327.               }
  328.          }
  329.     }
  330.  
  331.   after := (tag_queue_size());
  332.  
  333.   if ((before - after) = 0)
  334.   {
  335.     print(COL_LRED, "\n" , nosent);
  336.   }
  337.  
  338.   if ((before - after) = 1)
  339.   {
  340.     print(COL_LRED, "\n", (before - after), " ", sent,"\n");
  341.   }
  342.  
  343.   if ((before - after) > 1)
  344.   {
  345.     print(COL_LRED, "\n", (before - after), " ", sents, "\n");
  346.   }
  347.   sleep(2);
  348. }
  349.  
  350.