home *** CD-ROM | disk | FTP | other *** search
- /**************************************************************************/
- /* Batch upload interface between LiveWire Communication Program and */
- /* Cexyz2 external protocol programs. The setup in LiveWire for a */
- /* batch upload is - BATCHUL.EXE /P%3 /B%1 /Sz %2 (Zmodem Batch upload) */
- /* BATCHUL.EXE /P%3 /B%1 /Szap %2 (ZedZap Batch upload) */
- /* Remember: To use this program you will need the programs LIVEWIRE and */
- /* CEXYZ2. */
- /* */
- /* Copywrite Information: */
- /* */
- /* The Program in its original form was written Jerry Boggs. */
- /* If you have any questions or helpfull suggestions on how to improve */
- /* this program you can contact me through Fidonet Netmail at address */
- /* 1:265/5456@fidonet.org or 1:265/101.5456. I also read most of the OS/2*/
- /* conferences that are on the Zone 1 Backbone. */
- /* */
- /* 1. You may use this program free of charge. */
- /* 2. You may freely distribute this program as long as you include the */
- /* 'C' source code with the program and don't charge for distributing */
- /* this program. */
- /* 3. You may modify this program as long as you post a list of the */
- /* changes in the 'C' Source Code and none of the changes are mean't */
- /* to be harmful to the user or the user's computer. */
- /**************************************************************************/
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <process.h>
- #include <io.h>
- #include <dir.h>
- #include <dos.h>
- #include <conio.h>
-
- char port[20]="";
- char baud[10]="";
- char transfer[8]="";
- char answer[2]="Y";
- char defdir[MAXDIR];
- char defdrive[MAXDRIVE];
- char filename[MAXFILE]="";
- char temppath[MAXPATH];
- char tempdrive[MAXDRIVE];
- char tempdir[MAXDIR];
- char tempfile[MAXFILE];
- char tempext[MAXEXT];
- char path[MAXPATH];
- char drive[MAXDRIVE];
- char dir[MAXDIR];
- char file[MAXFILE];
- char ext[MAXEXT];
- char ul[11]="upload.lst";
- int rc;
- int count;
- int all=0;
- int x=1,y=1;
- int xx,yy;
- FILE *ptr;
- struct ffblk ffblk;
-
- int find1st(void);
- int findnxt(void);
- void pause (int count);
- void addname(void);
- int main(int argc, char *argv[])
- {
- clrscr();
- if((argc<4)||(argc>5)){
- printf("\nSYNTAX:\n\n");
- printf("BATCHUL [<port><baud><type of transfer>][<default directory and/or file name>]\n");
- printf(" [ REQUIRED INFORMATION ][ OPTIONAL INFORMATION ]\n");
- exit(0);
- }
- window(1,1,79,3);
- gotoxy(1,1);
- cprintf("\nEnter names to upload, including path if different from default\n\n");
- ptr=fopen(ul,"w+");
- if (ptr==NULL){
- cprintf("\nCan't open %s",ul);
- exit (0);
- }
- window(1,3,79,5);
- gotoxy(1,1);
- cprintf("UPLOAD LIST");
- gotoxy(1,2);
- cprintf("============");
- if (argc>=5){
- strcpy(path,argv[4]);
- fnsplit(path,drive,dir,file,ext);
- if (strcmp(file,"")!=0){
- window(1,1,79,3);
- gotoxy(1,2);
- cprintf("Default Path = %s%s",drive,dir);
- window(1,20,79,25);
- gotoxy(1,1);
- cprintf("\nFilename (A=Abort Upload)? :%s%s",file,ext);
- gotoxy(1,3);
- rc=find1st();
- }
- }
- strcpy(defdrive,drive);
- strcpy(defdir,dir);
- strcpy(transfer,argv[3]);
- strcpy(baud,argv[2]);
- strcpy(port,argv[1]);
- window(1,1,79,3);
- gotoxy(1,2);
- cprintf("Default Path = %s%s",defdrive,defdir);
- strcpy(path,"");
- do{
- window(1,20,79,25);
- gotoxy(1,1);
- clrscr();
- cprintf("\nFilename (A=Abort Upload)? :");
- gets(path);
- if (strcmpi(path,"A")==0)
- exit(0);
- fnsplit(path,drive,dir,file,ext);
- if(strcmp(file,"")!=0){
-
- if (!strcmp(dir,"")){
- strcpy(drive,defdrive);
- strcpy(dir,defdir);
- fnmerge(path,drive,dir,file,ext);
- }
- rc=find1st();
- /* cprintf("Return Code :%d\n",rc); */
- if (rc){
- do{
- rc=findnxt();
- }while (rc);
- }
- }
- } while(strcmp(file,"")!=0);
- fclose(ptr);
- spawnlp(P_WAIT,"cexyz2.exe","cexyz2.exe",port,baud,transfer,"@d:\\comm\\lw\\upload.lst",NULL);
- exit(1);
- return 0;
- }
-
- int find1st(void)
- {
- all=0;
- if (!findfirst(path,&ffblk,0)){
- fnsplit(ffblk.ff_name,tempdrive,tempdir,tempfile,tempext);
- fnmerge(temppath,drive,dir,tempfile,tempext);
- cprintf("Add - %s(Y,n,a)?",temppath);
- gets(answer);
- if (strcmpi(answer,"A")==0){
- all=1;
- strcpy(answer,"Y");
- }
- if (strcmpi(answer,"")==0)
- strcpy(answer,"Y");
- if (strcmpi(answer,"Y")==0){
- if (fprintf(ptr,"%s\n",temppath)==EOF){
- cprintf("Can't add : %s\n",temppath);
- pause(1);
- return 1;
- }
- else{
- /* cprintf("Adding : %s\n",temppath); */
- yy=wherey();
- addname();
- window(1,20,80,25);
- gotoxy(1,yy);
- return 1;
- }
- }
- else{
- return 1;
- }
- }
- else {
- cprintf("Path or file not found");
- pause(1);
- return 0;
- }
- }
-
- int findnxt(void)
- {
- if (!findnext(&ffblk)){
- fnsplit(ffblk.ff_name,tempdrive,tempdir,tempfile,tempext);
- fnmerge(temppath,drive,dir,tempfile,tempext);
- if (!all){
- window(1,20,80,25);
- gotoxy(1,2);
- cprintf("\nAdd - %s(Y,n,q)?",temppath);
- clreol();
- gets(answer);
- }
- if (strcmpi(answer,"")==0)
- strcpy(answer,"Y");
- if (strcmpi(answer,"Q")==0)
- return 0;
- if (strcmpi(answer,"Y")==0){
- if (fprintf(ptr,"%s\n",temppath)==EOF){
- cprintf("Can't add : %s\n",temppath);
- pause(1);
- return 1;
- }
- else{
- /* cprintf("Adding : %s\n",temppath); */
- addname();
- return 1;
- }
- }
- else{
- return 1;
- }
- }
- else {
- return 0;
- }
- }
-
- void pause(int count)
- {
- int counter;
-
- for(counter=1; counter<=(count*1000000); counter++);
- }
-
- void addname(void)
- {
- window(1,5,80,20);
- gotoxy(1,y);
- cprintf("%s%s\n",tempfile,tempext);
- x=wherex();
- y=wherey();
- return ;
- }
-