[BACK]Return to server-client.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / tmux

Diff for /src/usr.bin/tmux/server-client.c between version 1.32 and 1.33

version 1.32, 2010/06/05 16:47:11 version 1.33, 2010/06/28 22:10:42
Line 69 
Line 69 
   
         ARRAY_INIT(&c->prompt_hdata);          ARRAY_INIT(&c->prompt_hdata);
   
           c->stdin_file = NULL;
           c->stdout_file = NULL;
           c->stderr_file = NULL;
   
         c->tty.fd = -1;          c->tty.fd = -1;
         c->title = NULL;          c->title = NULL;
   
Line 118 
Line 122 
         if (c->flags & CLIENT_TERMINAL)          if (c->flags & CLIENT_TERMINAL)
                 tty_free(&c->tty);                  tty_free(&c->tty);
   
           if (c->stdin_file != NULL)
                   fclose(c->stdin_file);
           if (c->stdout_file != NULL)
                   fclose(c->stdout_file);
           if (c->stderr_file != NULL)
                   fclose(c->stderr_file);
   
         screen_free(&c->status);          screen_free(&c->status);
         job_tree_free(&c->status_jobs);          job_tree_free(&c->status_jobs);
   
Line 555 
Line 566 
                                 fatalx("MSG_IDENTIFY missing fd");                                  fatalx("MSG_IDENTIFY missing fd");
                         memcpy(&identifydata, imsg.data, sizeof identifydata);                          memcpy(&identifydata, imsg.data, sizeof identifydata);
   
                           c->stdin_file = fdopen(imsg.fd, "r");
                           if (c->stdin_file == NULL)
                                   fatal("fdopen(stdin) failed");
                         server_client_msg_identify(c, &identifydata, imsg.fd);                          server_client_msg_identify(c, &identifydata, imsg.fd);
                         break;                          break;
                   case MSG_STDOUT:
                           if (datalen != 0)
                                   fatalx("bad MSG_STDOUT size");
                           if (imsg.fd == -1)
                                   fatalx("MSG_STDOUT missing fd");
   
                           c->stdout_file = fdopen(imsg.fd, "w");
                           if (c->stdout_file == NULL)
                                   fatal("fdopen(stdout) failed");
                           break;
                   case MSG_STDERR:
                           if (datalen != 0)
                                   fatalx("bad MSG_STDERR size");
                           if (imsg.fd == -1)
                                   fatalx("MSG_STDERR missing fd");
   
                           c->stderr_file = fdopen(imsg.fd, "w");
                           if (c->stderr_file == NULL)
                                   fatal("fdopen(stderr) failed");
                           break;
                 case MSG_RESIZE:                  case MSG_RESIZE:
                         if (datalen != 0)                          if (datalen != 0)
                                 fatalx("bad MSG_RESIZE size");                                  fatalx("bad MSG_RESIZE size");
Line 622 
Line 656 
 void printflike2  void printflike2
 server_client_msg_error(struct cmd_ctx *ctx, const char *fmt, ...)  server_client_msg_error(struct cmd_ctx *ctx, const char *fmt, ...)
 {  {
         struct msg_print_data   data;          va_list ap;
         va_list                 ap;  
   
         va_start(ap, fmt);          va_start(ap, fmt);
         xvsnprintf(data.msg, sizeof data.msg, fmt, ap);          vfprintf(ctx->cmdclient->stderr_file, fmt, ap);
         va_end(ap);          va_end(ap);
   
         server_write_client(ctx->cmdclient, MSG_ERROR, &data, sizeof data);          fputc('\n', ctx->cmdclient->stderr_file);
           fflush(ctx->cmdclient->stderr_file);
 }  }
   
 /* Callback to send print message to client. */  /* Callback to send print message to client. */
 void printflike2  void printflike2
 server_client_msg_print(struct cmd_ctx *ctx, const char *fmt, ...)  server_client_msg_print(struct cmd_ctx *ctx, const char *fmt, ...)
 {  {
         struct msg_print_data   data;          va_list ap;
         va_list                 ap;  
   
         va_start(ap, fmt);          va_start(ap, fmt);
         xvsnprintf(data.msg, sizeof data.msg, fmt, ap);          vfprintf(ctx->cmdclient->stdout_file, fmt, ap);
         va_end(ap);          va_end(ap);
   
         server_write_client(ctx->cmdclient, MSG_PRINT, &data, sizeof data);          fputc('\n', ctx->cmdclient->stdout_file);
           fflush(ctx->cmdclient->stdout_file);
 }  }
   
 /* Callback to send print message to client, if not quiet. */  /* Callback to send print message to client, if not quiet. */
 void printflike2  void printflike2
 server_client_msg_info(struct cmd_ctx *ctx, const char *fmt, ...)  server_client_msg_info(struct cmd_ctx *ctx, const char *fmt, ...)
 {  {
         struct msg_print_data   data;          va_list ap;
         va_list                 ap;  
   
         if (options_get_number(&global_options, "quiet"))          if (options_get_number(&global_options, "quiet"))
                 return;                  return;
   
         va_start(ap, fmt);          va_start(ap, fmt);
         xvsnprintf(data.msg, sizeof data.msg, fmt, ap);          vfprintf(ctx->cmdclient->stdout_file, fmt, ap);
         va_end(ap);          va_end(ap);
   
         server_write_client(ctx->cmdclient, MSG_PRINT, &data, sizeof data);          fputc('\n', ctx->cmdclient->stderr_file);
           fflush(ctx->cmdclient->stdout_file);
 }  }
   
 /* Handle command message. */  /* Handle command message. */
Line 717 
Line 751 
 server_client_msg_identify(  server_client_msg_identify(
     struct client *c, struct msg_identify_data *data, int fd)      struct client *c, struct msg_identify_data *data, int fd)
 {  {
           int     tty_fd;
   
         c->cwd = NULL;          c->cwd = NULL;
         data->cwd[(sizeof data->cwd) - 1] = '\0';          data->cwd[(sizeof data->cwd) - 1] = '\0';
         if (*data->cwd != '\0')          if (*data->cwd != '\0')
                 c->cwd = xstrdup(data->cwd);                  c->cwd = xstrdup(data->cwd);
   
           if (!isatty(fd))
               return;
           if ((tty_fd = dup(fd)) == -1)
                   fatal("dup failed");
         data->term[(sizeof data->term) - 1] = '\0';          data->term[(sizeof data->term) - 1] = '\0';
         tty_init(&c->tty, fd, data->term);          tty_init(&c->tty, tty_fd, data->term);
         if (data->flags & IDENTIFY_UTF8)          if (data->flags & IDENTIFY_UTF8)
                 c->tty.flags |= TTY_UTF8;                  c->tty.flags |= TTY_UTF8;
         if (data->flags & IDENTIFY_256COLOURS)          if (data->flags & IDENTIFY_256COLOURS)

Legend:
Removed from v.1.32  
changed lines
  Added in v.1.33