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

Diff for /src/usr.bin/cu/cu.c between version 1.21 and 1.22

version 1.21, 2015/02/08 17:33:35 version 1.22, 2015/05/18 09:35:05
Line 41 
Line 41 
 struct termios           saved_tio;  struct termios           saved_tio;
 struct bufferevent      *input_ev;  struct bufferevent      *input_ev;
 struct bufferevent      *output_ev;  struct bufferevent      *output_ev;
   int                      is_direct = -1;
 const char              *line_path = NULL;  const char              *line_path = NULL;
 int                      line_speed = -1;  int                      line_speed = -1;
 int                      line_fd;  int                      line_fd;
Line 65 
Line 66 
 __dead void  __dead void
 usage(void)  usage(void)
 {  {
         fprintf(stderr, "usage: %s [-l line] [-s speed | -speed]\n",          fprintf(stderr, "usage: %s [-d] [-l line] [-s speed | -speed]\n",
             __progname);              __progname);
         fprintf(stderr, "       %s [host]\n", __progname);          fprintf(stderr, "       %s [host]\n", __progname);
         exit(1);          exit(1);
Line 76 
Line 77 
 {  {
         const char      *errstr;          const char      *errstr;
         char            *tmp, *s, *host;          char            *tmp, *s, *host;
         int              opt, i;          int              opt, i, flags;
   
         if (isatty(STDIN_FILENO) && tcgetattr(STDIN_FILENO, &saved_tio) != 0)          if (isatty(STDIN_FILENO) && tcgetattr(STDIN_FILENO, &saved_tio) != 0)
                 err(1, "tcgetattr");                  err(1, "tcgetattr");
Line 95 
Line 96 
                         errx(1, "speed asprintf");                          errx(1, "speed asprintf");
         }          }
   
         while ((opt = getopt(argc, argv, "l:s:")) != -1) {          while ((opt = getopt(argc, argv, "dl:s:")) != -1) {
                 switch (opt) {                  switch (opt) {
                   case 'd':
                           is_direct = 1;
                           break;
                 case 'l':                  case 'l':
                         line_path = optarg;                          line_path = optarg;
                         break;                          break;
Line 114 
Line 118 
         if (argc != 0 && argc != 1)          if (argc != 0 && argc != 1)
                 usage();                  usage();
   
         if (line_path != NULL || line_speed != -1) {          if (line_path != NULL || line_speed != -1 || is_direct != -1) {
                 if (argc != 0)                  if (argc != 0)
                         usage();                          usage();
         } else {          } else {
Line 139 
Line 143 
                 line_path = "/dev/cua00";                  line_path = "/dev/cua00";
         if (line_speed == -1)          if (line_speed == -1)
                 line_speed = 9600;                  line_speed = 9600;
           if (is_direct == -1)
                   is_direct = 0;
   
         if (strchr(line_path, '/') == NULL) {          if (strchr(line_path, '/') == NULL) {
                 if (asprintf(&tmp, "%s%s", _PATH_DEV, line_path) == -1)                  if (asprintf(&tmp, "%s%s", _PATH_DEV, line_path) == -1)
Line 146 
Line 152 
                 line_path = tmp;                  line_path = tmp;
         }          }
   
         line_fd = open(line_path, O_RDWR);          flags = O_RDWR;
           if (is_direct)
                   flags |= O_NONBLOCK;
           line_fd = open(line_path, flags);
         if (line_fd < 0)          if (line_fd < 0)
                 err(1, "open(\"%s\")", line_path);                  err(1, "open(\"%s\")", line_path);
         if (ioctl(line_fd, TIOCEXCL) != 0)          if (ioctl(line_fd, TIOCEXCL) != 0)
Line 346 
Line 355 
                         cu_errx(1, "unknown error in remote file");                          cu_errx(1, "unknown error in remote file");
                 }                  }
         }          }
   
           if (is_direct == -1 && cgetcap(cp, "dc", ':') != NULL)
                   is_direct = 1;
   
         if (line_path == NULL && cgetstr(cp, "dv", &s) >= 0)          if (line_path == NULL && cgetstr(cp, "dv", &s) >= 0)
                 line_path = s;                  line_path = s;

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.22