Revision: 2795
          http://tmux.svn.sourceforge.net/tmux/?rev=2795&view=rev
Author:   tcunha
Date:     2012-05-12 15:00:19 +0000 (Sat, 12 May 2012)
Log Message:
-----------
Sync OpenBSD patchset 1111:

Add a helper function to open the terminal for attach-/new-session.

Modified Paths:
--------------
    trunk/cmd-attach-session.c
    trunk/cmd-new-session.c
    trunk/server-client.c
    trunk/tmux.h

Modified: trunk/cmd-attach-session.c
===================================================================
--- trunk/cmd-attach-session.c  2012-05-12 14:59:17 UTC (rev 2794)
+++ trunk/cmd-attach-session.c  2012-05-12 15:00:19 UTC (rev 2795)
@@ -43,7 +43,7 @@
        struct session  *s;
        struct client   *c;
        const char      *update;
-       char            *overrides, *cause;
+       char            *cause;
        u_int            i;
 
        if (RB_EMPTY(&sessions)) {
@@ -79,15 +79,8 @@
                server_redraw_client(ctx->curclient);
                s->curw->flags &= ~WINLINK_ALERTFLAGS;
        } else {
-               if (!(ctx->cmdclient->flags & CLIENT_TERMINAL)) {
-                       ctx->error(ctx, "not a terminal");
-                       return (-1);
-               }
-
-               overrides =
-                   options_get_string(&s->options, "terminal-overrides");
-               if (tty_open(&ctx->cmdclient->tty, overrides, &cause) != 0) {
-                       ctx->error(ctx, "terminal open failed: %s", cause);
+               if (server_client_open(ctx->cmdclient, s, &cause) != 0) {
+                       ctx->error(ctx, "open terminal failed: %s", cause);
                        xfree(cause);
                        return (-1);
                }

Modified: trunk/cmd-new-session.c
===================================================================
--- trunk/cmd-new-session.c     2012-05-12 14:59:17 UTC (rev 2794)
+++ trunk/cmd-new-session.c     2012-05-12 15:00:19 UTC (rev 2795)
@@ -63,7 +63,7 @@
        struct termios           tio, *tiop;
        struct passwd           *pw;
        const char              *newname, *target, *update, *cwd, *errstr;
-       char                    *overrides, *cmd, *cause;
+       char                    *cmd, *cause;
        int                      detached, idx;
        u_int                    sx, sy, i;
 
@@ -128,14 +128,7 @@
 
        /* Open the terminal if necessary. */
        if (!detached && ctx->cmdclient != NULL) {
-               if (!(ctx->cmdclient->flags & CLIENT_TERMINAL)) {
-                       ctx->error(ctx, "not a terminal");
-                       return (-1);
-               }
-
-               overrides =
-                   options_get_string(&global_s_options, "terminal-overrides");
-               if (tty_open(&ctx->cmdclient->tty, overrides, &cause) != 0) {
+               if (server_client_open(ctx->cmdclient, NULL, &cause) != 0) {
                        ctx->error(ctx, "open terminal failed: %s", cause);
                        xfree(cause);
                        return (-1);

Modified: trunk/server-client.c
===================================================================
--- trunk/server-client.c       2012-05-12 14:59:17 UTC (rev 2794)
+++ trunk/server-client.c       2012-05-12 15:00:19 UTC (rev 2795)
@@ -104,6 +104,25 @@
        log_debug("new client %d", fd);
 }
 
+/* Open client terminal if needed. */
+int
+server_client_open(struct client *c, struct session *s, char **cause)
+{
+       struct options  *oo = s != NULL ? &s->options : &global_s_options;
+       char            *overrides;
+
+       if (!(c->flags & CLIENT_TERMINAL)) {
+               *cause = xstrdup ("not a terminal");
+               return (-1);
+       }
+
+       overrides = options_get_string(oo, "terminal-overrides");
+       if (tty_open(&c->tty, overrides, cause) != 0)
+               return (-1);
+
+       return (0);
+}
+
 /* Lost a client. */
 void
 server_client_lost(struct client *c)

Modified: trunk/tmux.h
===================================================================
--- trunk/tmux.h        2012-05-12 14:59:17 UTC (rev 2794)
+++ trunk/tmux.h        2012-05-12 15:00:19 UTC (rev 2795)
@@ -1719,6 +1719,7 @@
 
 /* server-client.c */
 void    server_client_create(int);
+int      server_client_open(struct client *, struct session *, char **);
 void    server_client_lost(struct client *);
 void    server_client_callback(int, short, void *);
 void    server_client_status_timer(void);

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to