[BACK]Return to main.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / tftp

Diff for /src/usr.bin/tftp/main.c between version 1.4 and 1.5

version 1.4, 1997/01/17 07:13:30 version 1.5, 2000/12/07 18:13:14
Line 74 
Line 74 
   
 #define TIMEOUT         5               /* secs between rexmt's */  #define TIMEOUT         5               /* secs between rexmt's */
 #define LBUFLEN         200             /* size of input buffer */  #define LBUFLEN         200             /* size of input buffer */
   #define MAXARGV         20
   
 struct  sockaddr_in peeraddr;  struct  sockaddr_in peeraddr;
 int     f;  int     f;
Line 84 
Line 85 
 char    mode[32];  char    mode[32];
 char    line[LBUFLEN];  char    line[LBUFLEN];
 int     margc;  int     margc;
 char    *margv[20];  char    *margv[MAXARGV+1];
 char    *prompt = "tftp";  char    *prompt = "tftp";
 jmp_buf toplevel;  jmp_buf toplevel;
 void    intr();  void    intr();
Line 107 
Line 108 
 static __dead void command __P((void));  static __dead void command __P((void));
   
 static void getusage __P((char *));  static void getusage __P((char *));
 static void makeargv __P((void));  static int makeargv __P((void));
 static void putusage __P((char *));  static void putusage __P((char *));
 static void settftpmode __P((char *));  static void settftpmode __P((char *));
   
Line 201 
Line 202 
                 strcpy(line, "Connect ");                  strcpy(line, "Connect ");
                 printf("(to) ");                  printf("(to) ");
                 fgets(&line[strlen(line)], LBUFLEN-strlen(line), stdin);                  fgets(&line[strlen(line)], LBUFLEN-strlen(line), stdin);
                 makeargv();                  if (makeargv())
                           return;
                 argc = margc;                  argc = margc;
                 argv = margv;                  argv = margv;
         }          }
Line 329 
Line 331 
                 strcpy(line, "send ");                  strcpy(line, "send ");
                 printf("(file) ");                  printf("(file) ");
                 fgets(&line[strlen(line)], LBUFLEN-strlen(line), stdin);                  fgets(&line[strlen(line)], LBUFLEN-strlen(line), stdin);
                 makeargv();                  if (makeargv())
                           return;
                 argc = margc;                  argc = margc;
                 argv = margv;                  argv = margv;
         }          }
Line 423 
Line 426 
                 strcpy(line, "get ");                  strcpy(line, "get ");
                 printf("(files) ");                  printf("(files) ");
                 fgets(&line[strlen(line)], LBUFLEN-strlen(line), stdin);                  fgets(&line[strlen(line)], LBUFLEN-strlen(line), stdin);
                 makeargv();                  if (makeargv())
                           return;
                 argc = margc;                  argc = margc;
                 argv = margv;                  argv = margv;
         }          }
Line 507 
Line 511 
                 strcpy(line, "Rexmt-timeout ");                  strcpy(line, "Rexmt-timeout ");
                 printf("(value) ");                  printf("(value) ");
                 fgets(&line[strlen(line)], LBUFLEN-strlen(line), stdin);                  fgets(&line[strlen(line)], LBUFLEN-strlen(line), stdin);
                 makeargv();                  if (makeargv())
                           return;
                 argc = margc;                  argc = margc;
                 argv = margv;                  argv = margv;
         }          }
Line 535 
Line 540 
                 strcpy(line, "Maximum-timeout ");                  strcpy(line, "Maximum-timeout ");
                 printf("(value) ");                  printf("(value) ");
                 fgets(&line[strlen(line)], LBUFLEN-strlen(line), stdin);                  fgets(&line[strlen(line)], LBUFLEN-strlen(line), stdin);
                 makeargv();                  if (makeargv())
                           return;
                 argc = margc;                  argc = margc;
                 argv = margv;                  argv = margv;
         }          }
Line 610 
Line 616 
                 }                  }
                 if ((line[0] == 0) || (line[0] == '\n'))                  if ((line[0] == 0) || (line[0] == '\n'))
                         continue;                          continue;
                 makeargv();                  if (makeargv())
                           continue;
                 if (margc == 0)                  if (margc == 0)
                         continue;                          continue;
                 c = getcmd(margv[0]);                  c = getcmd(margv[0]);
Line 658 
Line 665 
 /*  /*
  * Slice a string up into argc/argv.   * Slice a string up into argc/argv.
  */   */
 static void  static int
 makeargv()  makeargv()
 {  {
         register char *cp;          register char *cp;
         register char **argp = margv;          register char **argp = margv;
           int ret = 0;
   
         margc = 0;          margc = 0;
         for (cp = line; *cp;) {          for (cp = line; *cp;) {
                   if (margc >= MAXARGV) {
                           printf("too many arguments\n");
                           ret = 1;
                           break;
                   }
                 while (isspace(*cp))                  while (isspace(*cp))
                         cp++;                          cp++;
                 if (*cp == '\0')                  if (*cp == '\0')
Line 679 
Line 692 
                 *cp++ = '\0';                  *cp++ = '\0';
         }          }
         *argp++ = 0;          *argp++ = 0;
           return (ret);
 }  }
   
 void  void

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5