aboutsummaryrefslogtreecommitdiff
path: root/tmux.h
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2009-08-09 17:48:55 +0000
committerTiago Cunha <tcunha@gmx.com>2009-08-09 17:48:55 +0000
commit29b1b2fb5eee4319cdc1464ee377b68f3171dc27 (patch)
tree724627190ad66e119ec2771c5731e720a70ea3e9 /tmux.h
parentaf3db9a4fea9c436ff8e6f452a538ba295e1e6fe (diff)
downloadrtmux-29b1b2fb5eee4319cdc1464ee377b68f3171dc27.tar.gz
rtmux-29b1b2fb5eee4319cdc1464ee377b68f3171dc27.tar.bz2
rtmux-29b1b2fb5eee4319cdc1464ee377b68f3171dc27.zip
Sync OpenBSD patchset 231:
Infrastructure and commands to manage the environment for processes started within tmux. There is a global environment, copied from the external environment when the server is started and each session has an (initially empty) session environment which overrides it. New commands set-environment and show-environment manipulate or display the environments. A new session option, update-environment, is a space-separated list of variables which are updated from the external environment into the session environment every time a new session is created - the default is DISPLAY.
Diffstat (limited to 'tmux.h')
-rw-r--r--tmux.h48
1 files changed, 42 insertions, 6 deletions
diff --git a/tmux.h b/tmux.h
index 76e09fb9..7d2518b2 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1,4 +1,4 @@
-/* $Id: tmux.h,v 1.407 2009-08-09 17:32:06 tcunha Exp $ */
+/* $Id: tmux.h,v 1.408 2009-08-09 17:48:55 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -38,6 +38,7 @@
#include "compat.h"
extern char *__progname;
+extern char **environ;
/* Default configuration files. */
#define DEFAULT_CFG ".tmux.conf"
@@ -68,6 +69,7 @@ extern char *__progname;
#define COMMAND_LENGTH 2048 /* packed argv size */
#define TERMINAL_LENGTH 128 /* length of TERM environment variable */
#define PRINT_LENGTH 512 /* printed error/message size */
+#define ENVIRON_LENGTH 1024 /* environment variable length */
/* Fatal errors. */
#define fatal(msg) log_fatal("%s: %s", __func__, msg);
@@ -301,6 +303,7 @@ enum msgtype {
MSG_SUSPEND,
MSG_UNLOCK,
MSG_WAKEUP,
+ MSG_ENVIRON
};
/*
@@ -355,6 +358,10 @@ struct msg_unlock_data {
char pass[PASS_MAX];
};
+struct msg_environ_data {
+ char var[ENVIRON_LENGTH];
+};
+
/* Mode key commands. */
enum mode_key_cmd {
MODEKEY_NONE,
@@ -764,6 +771,15 @@ struct paste_buffer {
};
ARRAY_DECL(paste_stack, struct paste_buffer *);
+/* Environment variable. */
+struct environ_entry {
+ char *name;
+ char *value;
+
+ RB_ENTRY(environ_entry) entry;
+};
+RB_HEAD(environ, environ_entry);
+
/* Client session. */
struct session_alert {
struct winlink *wl;
@@ -791,6 +807,8 @@ struct session {
#define SESSION_UNATTACHED 0x1 /* not attached to any clients */
int flags;
+
+ struct environ environ;
};
ARRAY_DECL(sessions, struct session *);
@@ -893,6 +911,8 @@ struct client {
struct buffer *in;
struct buffer *out;
+ struct environ environ;
+
char *title;
char *cwd;
@@ -991,6 +1011,7 @@ struct cmd_entry {
#define CMD_CANTNEST 0x2
#define CMD_ARG1 0x4
#define CMD_ARG01 0x8
+#define CMD_SENDENVIRON 0x10
int flags;
#define CMD_CHFLAG(flag) \
@@ -1073,6 +1094,7 @@ extern volatile sig_atomic_t sigusr1;
extern volatile sig_atomic_t sigusr2;
extern struct options global_s_options;
extern struct options global_w_options;
+extern struct environ global_environ;
extern char *cfg_file;
extern int server_locked;
extern u_int password_failures;
@@ -1122,6 +1144,18 @@ char *options_get_string(struct options *, const char *);
void options_set_number(struct options *, const char *, long long);
long long options_get_number(struct options *, const char *);
+/* environ.c */
+int environ_cmp(struct environ_entry *, struct environ_entry *);
+RB_PROTOTYPE(environ, environ_entry, entry, environ_cmp);
+void environ_init(struct environ *);
+void environ_free(struct environ *);
+void environ_copy(struct environ *, struct environ *);
+struct environ_entry *environ_find(struct environ *, const char *);
+void environ_set(struct environ *, const char *, const char *);
+void environ_put(struct environ *, const char *);
+void environ_unset(struct environ *, const char *);
+void environ_update(const char *, struct environ *, struct environ *);
+
/* tty.c */
u_char tty_get_acs(struct tty *, u_char);
void tty_reset(struct tty *);
@@ -1284,10 +1318,12 @@ extern const struct cmd_entry cmd_send_keys_entry;
extern const struct cmd_entry cmd_send_prefix_entry;
extern const struct cmd_entry cmd_server_info_entry;
extern const struct cmd_entry cmd_set_buffer_entry;
+extern const struct cmd_entry cmd_set_environment_entry;
extern const struct cmd_entry cmd_set_option_entry;
extern const struct cmd_entry cmd_set_password_entry;
extern const struct cmd_entry cmd_set_window_option_entry;
extern const struct cmd_entry cmd_show_buffer_entry;
+extern const struct cmd_entry cmd_show_environment_entry;
extern const struct cmd_entry cmd_show_options_entry;
extern const struct cmd_entry cmd_show_window_options_entry;
extern const struct cmd_entry cmd_source_file_entry;
@@ -1383,7 +1419,7 @@ int server_start(char *);
int server_msg_dispatch(struct client *);
/* server-fn.c */
-const char **server_fill_environ(struct session *);
+void server_fill_environ(struct session *, struct environ *);
void server_write_error(struct client *, const char *);
void server_write_client(
struct client *, enum msgtype, const void *, size_t);
@@ -1553,8 +1589,8 @@ void winlink_stack_push(struct winlink_stack *, struct winlink *);
void winlink_stack_remove(struct winlink_stack *, struct winlink *);
int window_index(struct window *, u_int *);
struct window *window_create1(u_int, u_int);
-struct window *window_create(const char *, const char *,
- const char *, const char **, u_int, u_int, u_int, char **);
+struct window *window_create(const char *, const char *, const char *,
+ struct environ *, u_int, u_int, u_int, char **);
void window_destroy(struct window *);
void window_set_active_pane(struct window *, struct window_pane *);
struct window_pane *window_add_pane(struct window *, u_int);
@@ -1567,7 +1603,7 @@ void window_destroy_panes(struct window *);
struct window_pane *window_pane_create(struct window *, u_int, u_int, u_int);
void window_pane_destroy(struct window_pane *);
int window_pane_spawn(struct window_pane *,
- const char *, const char *, const char **, char **);
+ const char *, const char *, struct environ *, char **);
void window_pane_resize(struct window_pane *, u_int, u_int);
int window_pane_set_mode(
struct window_pane *, const struct window_mode *);
@@ -1647,7 +1683,7 @@ int session_alert_has(struct session *, struct winlink *, int);
int session_alert_has_window(struct session *, struct window *, int);
struct session *session_find(const char *);
struct session *session_create(const char *, const char *,
- const char *, u_int, u_int, char **);
+ const char *, struct environ *, u_int, u_int, char **);
void session_destroy(struct session *);
int session_index(struct session *, u_int *);
struct winlink *session_new(struct session *,