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

Diff for /src/usr.bin/tip/Attic/cmds.c between version 1.6 and 1.7

version 1.6, 1997/08/22 22:42:07 version 1.7, 1997/09/01 23:24:23
Line 64 
Line 64 
  * FTP - remote ==> local   * FTP - remote ==> local
  *  get a file from the remote host   *  get a file from the remote host
  */   */
   void
 getfl(c)  getfl(c)
         char c;          char c;
 {  {
Line 94 
Line 95 
 /*  /*
  * Cu-like take command   * Cu-like take command
  */   */
   void
 cu_take(cc)  cu_take(cc)
         char cc;          char cc;
 {  {
Line 102 
Line 104 
   
         if (prompt("[take] ", copyname, sizeof(copyname)))          if (prompt("[take] ", copyname, sizeof(copyname)))
                 return;                  return;
         if ((argc = args(copyname, argv)) < 1 || argc > 2) {          if ((argc = args(copyname, argv, sizeof(argv)/sizeof(argv[0]))) < 1 ||
               argc > 2) {
                 printf("usage: <take> from [to]\r\n");                  printf("usage: <take> from [to]\r\n");
                 return;                  return;
         }          }
Line 118 
Line 121 
 }  }
   
 static  jmp_buf intbuf;  static  jmp_buf intbuf;
   
 /*  /*
  * Bulk transfer routine --   * Bulk transfer routine --
  *  used by getfl(), cu_take(), and pipefile()   *  used by getfl(), cu_take(), and pipefile()
  */   */
   void
 transfer(buf, fd, eofchars)  transfer(buf, fd, eofchars)
         char *buf, *eofchars;          char *buf, *eofchars;
           int fd;
 {  {
         register int ct;          register int ct;
         char c, buffer[BUFSIZ];          char c, buffer[BUFSIZ];
         register char *p = buffer;          char *p = buffer;
         register int cnt, eof;          register int cnt, eof;
         time_t start;          time_t start;
         sig_t f;          sig_t f;
Line 174 
Line 180 
                         p = buffer;                          p = buffer;
                 }                  }
         }          }
         if (cnt = (p-buffer))          if ((cnt = (p-buffer)))
                 if (write(fd, buffer, cnt) != cnt)                  if (write(fd, buffer, cnt) != cnt)
                         printf("\r\nwrite error\r\n");                          printf("\r\nwrite error\r\n");
   
Line 190 
Line 196 
  * FTP - remote ==> local process   * FTP - remote ==> local process
  *   send remote input to local process via pipe   *   send remote input to local process via pipe
  */   */
   void
 pipefile()  pipefile()
 {  {
         int cpid, pdes[2];          int cpid, pdes[2];
Line 249 
Line 256 
  *  send local file to remote host   *  send local file to remote host
  *  terminate transmission with pseudo EOF sequence   *  terminate transmission with pseudo EOF sequence
  */   */
   void
 sendfile(cc)  sendfile(cc)
         char cc;          char cc;
 {  {
Line 280 
Line 288 
  * Bulk transfer routine to remote host --   * Bulk transfer routine to remote host --
  *   used by sendfile() and cu_put()   *   used by sendfile() and cu_put()
  */   */
   void
 transmit(fd, eofchars, command)  transmit(fd, eofchars, command)
         FILE *fd;          FILE *fd;
         char *eofchars, *command;          char *eofchars, *command;
Line 377 
Line 386 
 /*  /*
  * Cu-like put command   * Cu-like put command
  */   */
   void
 cu_put(cc)  cu_put(cc)
         char cc;          char cc;
 {  {
Line 388 
Line 398 
   
         if (prompt("[put] ", copyname, sizeof(copyname)))          if (prompt("[put] ", copyname, sizeof(copyname)))
                 return;                  return;
         if ((argc = args(copyname, argv)) < 1 || argc > 2) {          if ((argc = args(copyname, argv, sizeof(argv)/sizeof(argv[0]))) < 1 ||
               argc > 2) {
                 printf("usage: <put> from [to]\r\n");                  printf("usage: <put> from [to]\r\n");
                 return;                  return;
         }          }
Line 411 
Line 422 
  * FTP - send single character   * FTP - send single character
  *  wait for echo & handle timeout   *  wait for echo & handle timeout
  */   */
   void
 send(c)  send(c)
         char c;          int c;
 {  {
         char cc;          char cc;
         int retry = 0;          int retry = 0;
Line 455 
Line 467 
  * Stolen from consh() -- puts a remote file on the output of a local command.   * Stolen from consh() -- puts a remote file on the output of a local command.
  *      Identical to consh() except for where stdout goes.   *      Identical to consh() except for where stdout goes.
  */   */
   void
 pipeout(c)  pipeout(c)
 {  {
         char buf[256];          char buf[256];
         int cpid, status, p;          int cpid, status, p;
         time_t start;          time_t start = time(NULL);
   
         putchar(c);          putchar(c);
         if (prompt("Local command? ", buf, sizeof(buf)))          if (prompt("Local command? ", buf, sizeof(buf)))
Line 476 
Line 489 
         if ((cpid = fork()) < 0)          if ((cpid = fork()) < 0)
                 printf("can't fork!\r\n");                  printf("can't fork!\r\n");
         else if (cpid) {          else if (cpid) {
                 start = time(0);                  start = time(NULL);
                 while ((p = wait(&status)) > 0 && p != cpid)                  while ((p = wait(&status)) > 0 && p != cpid)
                         ;                          ;
         } else {          } else {
Line 506 
Line 519 
  *  1 <-> remote tty out   *  1 <-> remote tty out
  *  2 <-> local tty out   *  2 <-> local tty out
  */   */
   void
 consh(c)  consh(c)
 {  {
         char buf[256];          char buf[256];
         int cpid, status, p;          int cpid, status, p;
         time_t start;          time_t start = time(NULL);
   
         putchar(c);          putchar(c);
         if (prompt("Local command? ", buf, sizeof(buf)))          if (prompt("Local command? ", buf, sizeof(buf)))
Line 555 
Line 569 
 /*  /*
  * Escape to local shell   * Escape to local shell
  */   */
   void
 shell()  shell()
 {  {
         int shpid, status;          int shpid, status;
         extern char **environ;  
         char *cp;          char *cp;
   
         printf("[sh]\r\n");          printf("[sh]\r\n");
         signal(SIGINT, SIG_IGN);          signal(SIGINT, SIG_IGN);
         signal(SIGQUIT, SIG_IGN);          signal(SIGQUIT, SIG_IGN);
         unraw();          unraw();
         if (shpid = fork()) {          if ((shpid = fork())) {
                 while (shpid != wait(&status));                  while (shpid != wait(&status));
                 raw();                  raw();
                 printf("\r\n!\r\n");                  printf("\r\n!\r\n");
Line 590 
Line 604 
  * TIPIN portion of scripting   * TIPIN portion of scripting
  *   initiate the conversation with TIPOUT   *   initiate the conversation with TIPOUT
  */   */
   void
 setscript()  setscript()
 {  {
         char c;          char c;
Line 612 
Line 627 
  * Change current working directory of   * Change current working directory of
  *   local portion of tip   *   local portion of tip
  */   */
   void
 chdirectory()  chdirectory()
 {  {
         char dirname[PATH_MAX];          char dirname[PATH_MAX];
Line 627 
Line 643 
         printf("!\r\n");          printf("!\r\n");
 }  }
   
   void
 tipabort(msg)  tipabort(msg)
         char *msg;          char *msg;
 {  {
Line 642 
Line 659 
         exit(0);          exit(0);
 }  }
   
   void
 finish()  finish()
 {  {
         char *dismsg;          char *dismsg;
Line 661 
Line 679 
         longjmp(intbuf, 1);          longjmp(intbuf, 1);
 }  }
   
   void
 execute(s)  execute(s)
         char *s;          char *s;
 {  {
Line 674 
Line 693 
         execl(value(SHELL), cp, "-c", s, 0);          execl(value(SHELL), cp, "-c", s, 0);
 }  }
   
 args(buf, a)  int
   args(buf, a, num)
         char *buf, *a[];          char *buf, *a[];
           int num;
 {  {
         register char *p = buf, *start;          register char *p = buf, *start;
         register char **parg = a;          register char **parg = a;
Line 693 
Line 714 
                         parg++, n++;                          parg++, n++;
                 if (*p)                  if (*p)
                         *p++ = '\0';                          *p++ = '\0';
         } while (*p);          } while (*p && n < num);
   
         return(n);          return(n);
 }  }
   
   void
 prtime(s, a)  prtime(s, a)
         char *s;          char *s;
         time_t a;          time_t a;
Line 717 
Line 739 
         printf("\r\n!\r\n");          printf("\r\n!\r\n");
 }  }
   
   void
 variable()  variable()
 {  {
         char    buf[256];          char    buf[256];
Line 756 
Line 779 
         }          }
         if (vtable[PARITY].v_access&CHANGED) {          if (vtable[PARITY].v_access&CHANGED) {
                 vtable[PARITY].v_access &= ~CHANGED;                  vtable[PARITY].v_access &= ~CHANGED;
                 setparity();                  setparity(NOSTR);
         }          }
 }  }
   
 /*  /*
  * Turn tandem mode on or off for remote tty.   * Turn tandem mode on or off for remote tty.
  */   */
   void
 tandem(option)  tandem(option)
         char *option;          char *option;
 {  {
Line 783 
Line 807 
 /*  /*
  * Send a break.   * Send a break.
  */   */
   void
 genbrk()  genbrk()
 {  {
   
Line 794 
Line 819 
 /*  /*
  * Suspend tip   * Suspend tip
  */   */
   void
 suspend(c)  suspend(c)
         char c;          char c;
 {  {
Line 813 
Line 839 
 {  {
         static char xname[BUFSIZ];          static char xname[BUFSIZ];
         char cmdbuf[BUFSIZ];          char cmdbuf[BUFSIZ];
         register int pid, l, rc;          register int pid, l;
         register char *cp, *Shell;          register char *cp, *Shell;
         int s, pivec[2], (*sigint)();          int s, pivec[2];
   
         if (!anyof(name, "~{[*?$`'\"\\"))          if (!anyof(name, "~{[*?$`'\"\\"))
                 return(name);                  return(name);
Line 877 
Line 903 
 /*  /*
  * Are any of the characters in the two strings the same?   * Are any of the characters in the two strings the same?
  */   */
   int
 anyof(s1, s2)  anyof(s1, s2)
         register char *s1, *s2;          register char *s1, *s2;
 {  {
         register int c;          register int c;
   
         while (c = *s1++)          while ((c = *s1++))
                 if (any(c, s2))                  if (any(c, s2))
                         return(1);                          return(1);
         return(0);          return(0);

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7