home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / batchula.zip / batchul.cpp next >
C/C++ Source or Header  |  1994-01-03  |  7KB  |  234 lines

  1. /**************************************************************************/
  2. /* Batch upload interface between LiveWire Communication Program and      */
  3. /* Cexyz2 external protocol programs.  The setup in LiveWire for a        */
  4. /* batch upload is - BATCHUL.EXE /P%3 /B%1 /Sz   %2 (Zmodem Batch upload) */
  5. /*                   BATCHUL.EXE /P%3 /B%1 /Szap %2 (ZedZap Batch upload) */
  6. /* Remember:  To use this program you will need the programs LIVEWIRE and */
  7. /* CEXYZ2.                                                                */
  8. /*                                                                        */
  9. /* Copywrite Information:                                                 */
  10. /*                                                                        */
  11. /* The Program in its original form was written Jerry Boggs.              */
  12. /* If you have any questions or helpfull suggestions on how to improve    */
  13. /* this program you can contact me through Fidonet Netmail at address     */
  14. /* 1:265/5456@fidonet.org or 1:265/101.5456.  I also read most of the OS/2*/
  15. /* conferences that are on the Zone 1 Backbone.                           */
  16. /*                                                                        */
  17. /* 1. You may use this program free of charge.                            */
  18. /* 2. You may freely distribute this program as long as you include the   */
  19. /*    'C' source code with the program and don't charge for distributing  */
  20. /*    this program.                                                       */
  21. /* 3. You may modify this program as long as you post a list of the       */
  22. /*    changes in the 'C' Source Code and none of the changes are mean't   */
  23. /*    to be harmful to the user or the user's computer.                   */
  24. /**************************************************************************/
  25.  
  26. #include <stdio.h>
  27. #include <stdlib.h>
  28. #include <string.h>
  29. #include <process.h>
  30. #include <io.h>
  31. #include <dir.h>
  32. #include <dos.h>
  33. #include <conio.h>
  34.  
  35. char port[20]="";
  36. char baud[10]="";
  37. char transfer[8]="";
  38. char answer[2]="Y";
  39. char defdir[MAXDIR];
  40. char defdrive[MAXDRIVE];
  41. char filename[MAXFILE]="";
  42. char temppath[MAXPATH];
  43. char tempdrive[MAXDRIVE];
  44. char tempdir[MAXDIR];
  45. char tempfile[MAXFILE];
  46. char tempext[MAXEXT];
  47. char path[MAXPATH];
  48. char drive[MAXDRIVE];
  49. char dir[MAXDIR];
  50. char file[MAXFILE];
  51. char ext[MAXEXT];
  52. char ul[11]="upload.lst";
  53. int rc;
  54. int count;
  55. int all=0;
  56. int x=1,y=1;
  57. int xx,yy;
  58. FILE *ptr;
  59. struct ffblk ffblk;
  60.  
  61. int find1st(void);
  62. int findnxt(void);
  63. void pause (int count);
  64. void addname(void);
  65. int main(int argc, char *argv[])
  66. {
  67.   clrscr();
  68.   if((argc<4)||(argc>5)){
  69.         printf("\nSYNTAX:\n\n");
  70.         printf("BATCHUL [<port><baud><type of transfer>][<default directory and/or file name>]\n");
  71.         printf("        [     REQUIRED INFORMATION     ][        OPTIONAL INFORMATION        ]\n");
  72.         exit(0);
  73.         }
  74.   window(1,1,79,3);
  75.   gotoxy(1,1);
  76.   cprintf("\nEnter names to upload, including path if different from default\n\n");
  77.   ptr=fopen(ul,"w+");
  78.   if (ptr==NULL){
  79.         cprintf("\nCan't open %s",ul);
  80.         exit (0);
  81.          }
  82.   window(1,3,79,5);
  83.   gotoxy(1,1);
  84.   cprintf("UPLOAD LIST");
  85.   gotoxy(1,2);
  86.   cprintf("============");
  87.   if (argc>=5){
  88.         strcpy(path,argv[4]);
  89.         fnsplit(path,drive,dir,file,ext);
  90.         if (strcmp(file,"")!=0){
  91.                   window(1,1,79,3);
  92.                   gotoxy(1,2);
  93.                   cprintf("Default Path = %s%s",drive,dir);
  94.                   window(1,20,79,25);
  95.           gotoxy(1,1);
  96.           cprintf("\nFilename (A=Abort Upload)? :%s%s",file,ext);
  97.           gotoxy(1,3);
  98.           rc=find1st();
  99.    }
  100.     }
  101.   strcpy(defdrive,drive);
  102.   strcpy(defdir,dir);
  103.   strcpy(transfer,argv[3]);
  104.   strcpy(baud,argv[2]);
  105.   strcpy(port,argv[1]);
  106.   window(1,1,79,3);
  107.   gotoxy(1,2);
  108.   cprintf("Default Path = %s%s",defdrive,defdir);
  109.   strcpy(path,"");
  110.   do{
  111.     window(1,20,79,25);
  112.     gotoxy(1,1);
  113.     clrscr();
  114.     cprintf("\nFilename (A=Abort Upload)? :");
  115.     gets(path);
  116.     if (strcmpi(path,"A")==0)
  117.         exit(0);
  118.     fnsplit(path,drive,dir,file,ext);
  119.     if(strcmp(file,"")!=0){
  120.  
  121.       if (!strcmp(dir,"")){
  122.         strcpy(drive,defdrive);
  123.         strcpy(dir,defdir);
  124.     fnmerge(path,drive,dir,file,ext);
  125.      }
  126.      rc=find1st();
  127. /*     cprintf("Return Code :%d\n",rc);   */
  128.      if (rc){
  129.         do{
  130.            rc=findnxt();
  131.         }while (rc);
  132.      }
  133.     }
  134.   } while(strcmp(file,"")!=0);
  135.   fclose(ptr);
  136.   spawnlp(P_WAIT,"cexyz2.exe","cexyz2.exe",port,baud,transfer,"@d:\\comm\\lw\\upload.lst",NULL);
  137.   exit(1);
  138. return 0;
  139. }
  140.  
  141. int find1st(void)
  142. {
  143. all=0;
  144. if (!findfirst(path,&ffblk,0)){
  145.     fnsplit(ffblk.ff_name,tempdrive,tempdir,tempfile,tempext);
  146.     fnmerge(temppath,drive,dir,tempfile,tempext);
  147.     cprintf("Add - %s(Y,n,a)?",temppath);
  148.     gets(answer);
  149.     if (strcmpi(answer,"A")==0){
  150.     all=1;
  151.     strcpy(answer,"Y");
  152.     }
  153.     if (strcmpi(answer,"")==0)
  154.     strcpy(answer,"Y");
  155.     if (strcmpi(answer,"Y")==0){
  156.     if (fprintf(ptr,"%s\n",temppath)==EOF){
  157.            cprintf("Can't add : %s\n",temppath);
  158.            pause(1);
  159.            return 1;
  160.            }
  161.            else{
  162. /*                 cprintf("Adding : %s\n",temppath);   */
  163.            yy=wherey();
  164.            addname();
  165.            window(1,20,80,25);
  166.            gotoxy(1,yy);
  167.            return 1;
  168.            }
  169.      }
  170.      else{
  171.           return 1;
  172.           }
  173.      }
  174.         else {
  175.         cprintf("Path or file not found");
  176.         pause(1);
  177.         return 0;
  178.         }
  179.     }
  180.  
  181. int findnxt(void)
  182. {
  183. if (!findnext(&ffblk)){
  184.     fnsplit(ffblk.ff_name,tempdrive,tempdir,tempfile,tempext);
  185.     fnmerge(temppath,drive,dir,tempfile,tempext);
  186.     if (!all){
  187.     window(1,20,80,25);
  188.     gotoxy(1,2);
  189.     cprintf("\nAdd - %s(Y,n,q)?",temppath);
  190.     clreol();
  191.     gets(answer);
  192.      }
  193.     if (strcmpi(answer,"")==0)
  194.     strcpy(answer,"Y");
  195.     if (strcmpi(answer,"Q")==0)
  196.     return 0;
  197.     if (strcmpi(answer,"Y")==0){
  198.     if (fprintf(ptr,"%s\n",temppath)==EOF){
  199.            cprintf("Can't add : %s\n",temppath);
  200.            pause(1);
  201.            return 1;
  202.            }
  203.                else{
  204. /*                 cprintf("Adding : %s\n",temppath); */
  205.                    addname();
  206.                    return 1;
  207.                    }
  208.          }
  209.          else{
  210.               return 1;
  211.               }
  212.          }
  213.             else {
  214.                 return 0;
  215.                 }
  216.     }
  217.  
  218. void pause(int count)
  219. {
  220.   int counter;
  221.  
  222.   for(counter=1; counter<=(count*1000000); counter++);
  223. }
  224.  
  225. void addname(void)
  226. {
  227.   window(1,5,80,20);
  228.   gotoxy(1,y);
  229.   cprintf("%s%s\n",tempfile,tempext);
  230.   x=wherex();
  231.   y=wherey();
  232.   return ;
  233. }
  234.