diff options
Diffstat (limited to 'format.c')
-rw-r--r-- | format.c | 126 |
1 files changed, 65 insertions, 61 deletions
@@ -40,35 +40,41 @@ struct format_entry; typedef void (*format_cb)(struct format_tree *, struct format_entry *); -void format_job_callback(struct job *); -char *format_job_get(struct format_tree *, const char *); -void format_job_timer(int, short, void *); - -void format_cb_host(struct format_tree *, struct format_entry *); -void format_cb_host_short(struct format_tree *, struct format_entry *); -void format_cb_pid(struct format_tree *, struct format_entry *); -void format_cb_session_alerts(struct format_tree *, struct format_entry *); -void format_cb_window_layout(struct format_tree *, struct format_entry *); -void format_cb_window_visible_layout(struct format_tree *, - struct format_entry *); -void format_cb_start_command(struct format_tree *, struct format_entry *); -void format_cb_current_command(struct format_tree *, struct format_entry *); -void format_cb_current_path(struct format_tree *, struct format_entry *); -void format_cb_history_bytes(struct format_tree *, struct format_entry *); -void format_cb_pane_tabs(struct format_tree *, struct format_entry *); - -char *format_find(struct format_tree *, const char *, int); -void format_add_cb(struct format_tree *, const char *, format_cb); -void format_add_tv(struct format_tree *, const char *, struct timeval *); -int format_replace(struct format_tree *, const char *, size_t, char **, - size_t *, size_t *); -char *format_time_string(time_t); - -void format_defaults_pane_tabs(struct format_tree *, struct window_pane *); -void format_defaults_session(struct format_tree *, struct session *); -void format_defaults_client(struct format_tree *, struct client *); -void format_defaults_winlink(struct format_tree *, struct session *, - struct winlink *); +static void format_job_callback(struct job *); +static char *format_job_get(struct format_tree *, const char *); +static void format_job_timer(int, short, void *); + +static void format_cb_host(struct format_tree *, struct format_entry *); +static void format_cb_host_short(struct format_tree *, + struct format_entry *); +static void format_cb_pid(struct format_tree *, struct format_entry *); +static void format_cb_session_alerts(struct format_tree *, + struct format_entry *); +static void format_cb_window_layout(struct format_tree *, + struct format_entry *); +static void format_cb_window_visible_layout(struct format_tree *, + struct format_entry *); +static void format_cb_start_command(struct format_tree *, + struct format_entry *); +static void format_cb_current_command(struct format_tree *, + struct format_entry *); +static void format_cb_history_bytes(struct format_tree *, + struct format_entry *); +static void format_cb_pane_tabs(struct format_tree *, + struct format_entry *); + +static char *format_find(struct format_tree *, const char *, int); +static void format_add_cb(struct format_tree *, const char *, format_cb); +static void format_add_tv(struct format_tree *, const char *, + struct timeval *); +static int format_replace(struct format_tree *, const char *, size_t, + char **, size_t *, size_t *); + +static void format_defaults_session(struct format_tree *, + struct session *); +static void format_defaults_client(struct format_tree *, struct client *); +static void format_defaults_winlink(struct format_tree *, struct session *, + struct winlink *); /* Entry in format job tree. */ struct format_job { @@ -84,14 +90,13 @@ struct format_job { }; /* Format job tree. */ -struct event format_job_event; -int format_job_cmp(struct format_job *, struct format_job *); -RB_HEAD(format_job_tree, format_job) format_jobs = RB_INITIALIZER(); -RB_PROTOTYPE(format_job_tree, format_job, entry, format_job_cmp); -RB_GENERATE(format_job_tree, format_job, entry, format_job_cmp); +static struct event format_job_event; +static int format_job_cmp(struct format_job *, struct format_job *); +static RB_HEAD(format_job_tree, format_job) format_jobs = RB_INITIALIZER(); +RB_GENERATE_STATIC(format_job_tree, format_job, entry, format_job_cmp); /* Format job tree comparison function. */ -int +static int format_job_cmp(struct format_job *fj1, struct format_job *fj2) { return (strcmp(fj1->cmd, fj2->cmd)); @@ -122,19 +127,18 @@ struct format_tree { RB_HEAD(format_entry_tree, format_entry) tree; }; -int format_entry_cmp(struct format_entry *, struct format_entry *); -RB_PROTOTYPE(format_entry_tree, format_entry, entry, format_entry_cmp); -RB_GENERATE(format_entry_tree, format_entry, entry, format_entry_cmp); +static int format_entry_cmp(struct format_entry *, struct format_entry *); +RB_GENERATE_STATIC(format_entry_tree, format_entry, entry, format_entry_cmp); /* Format entry tree comparison function. */ -int +static int format_entry_cmp(struct format_entry *fe1, struct format_entry *fe2) { return (strcmp(fe1->key, fe2->key)); } /* Single-character uppercase aliases. */ -const char *format_upper[] = { +static const char *format_upper[] = { NULL, /* A */ NULL, /* B */ NULL, /* C */ @@ -164,7 +168,7 @@ const char *format_upper[] = { }; /* Single-character lowercase aliases. */ -const char *format_lower[] = { +static const char *format_lower[] = { NULL, /* a */ NULL, /* b */ NULL, /* c */ @@ -194,7 +198,7 @@ const char *format_lower[] = { }; /* Format job callback. */ -void +static void format_job_callback(struct job *job) { struct format_job *fj = job->data; @@ -226,7 +230,7 @@ format_job_callback(struct job *job) } /* Find a job. */ -char * +static char * format_job_get(struct format_tree *ft, const char *cmd) { struct format_job fj0, *fj; @@ -260,7 +264,7 @@ format_job_get(struct format_tree *ft, const char *cmd) } /* Remove old jobs. */ -void +static void format_job_timer(__unused int fd, __unused short events, __unused void *arg) { struct format_job *fj, *fj1; @@ -289,7 +293,7 @@ format_job_timer(__unused int fd, __unused short events, __unused void *arg) } /* Callback for host. */ -void +static void format_cb_host(__unused struct format_tree *ft, struct format_entry *fe) { char host[HOST_NAME_MAX + 1]; @@ -301,7 +305,7 @@ format_cb_host(__unused struct format_tree *ft, struct format_entry *fe) } /* Callback for host_short. */ -void +static void format_cb_host_short(__unused struct format_tree *ft, struct format_entry *fe) { char host[HOST_NAME_MAX + 1], *cp; @@ -316,14 +320,14 @@ format_cb_host_short(__unused struct format_tree *ft, struct format_entry *fe) } /* Callback for pid. */ -void +static void format_cb_pid(__unused struct format_tree *ft, struct format_entry *fe) { xasprintf(&fe->value, "%ld", (long)getpid()); } /* Callback for session_alerts. */ -void +static void format_cb_session_alerts(struct format_tree *ft, struct format_entry *fe) { struct session *s = ft->s; @@ -353,7 +357,7 @@ format_cb_session_alerts(struct format_tree *ft, struct format_entry *fe) } /* Callback for window_layout. */ -void +static void format_cb_window_layout(struct format_tree *ft, struct format_entry *fe) { struct window *w = ft->w; @@ -368,7 +372,7 @@ format_cb_window_layout(struct format_tree *ft, struct format_entry *fe) } /* Callback for window_visible_layout. */ -void +static void format_cb_window_visible_layout(struct format_tree *ft, struct format_entry *fe) { struct window *w = ft->w; @@ -380,7 +384,7 @@ format_cb_window_visible_layout(struct format_tree *ft, struct format_entry *fe) } /* Callback for pane_start_command. */ -void +static void format_cb_start_command(struct format_tree *ft, struct format_entry *fe) { struct window_pane *wp = ft->wp; @@ -392,7 +396,7 @@ format_cb_start_command(struct format_tree *ft, struct format_entry *fe) } /* Callback for pane_current_command. */ -void +static void format_cb_current_command(struct format_tree *ft, struct format_entry *fe) { struct window_pane *wp = ft->wp; @@ -430,7 +434,7 @@ format_cb_current_path(struct format_tree *ft, struct format_entry *fe) } /* Callback for history_bytes. */ -void +static void format_cb_history_bytes(struct format_tree *ft, struct format_entry *fe) { struct window_pane *wp = ft->wp; @@ -455,7 +459,7 @@ format_cb_history_bytes(struct format_tree *ft, struct format_entry *fe) } /* Callback for pane_tabs. */ -void +static void format_cb_pane_tabs(struct format_tree *ft, struct format_entry *fe) { struct window_pane *wp = ft->wp; @@ -556,7 +560,7 @@ format_add(struct format_tree *ft, const char *key, const char *fmt, ...) } /* Add a key and time. */ -void +static void format_add_tv(struct format_tree *ft, const char *key, struct timeval *tv) { struct format_entry *fe; @@ -580,7 +584,7 @@ format_add_tv(struct format_tree *ft, const char *key, struct timeval *tv) } /* Add a key and function. */ -void +static void format_add_cb(struct format_tree *ft, const char *key, format_cb cb) { struct format_entry *fe; @@ -604,7 +608,7 @@ format_add_cb(struct format_tree *ft, const char *key, format_cb cb) } /* Find a format entry. */ -char * +static char * format_find(struct format_tree *ft, const char *key, int modifiers) { struct format_entry *fe, fe_find; @@ -699,7 +703,7 @@ found: * Replace a key/value pair in buffer. #{blah} is expanded directly, * #{?blah,a,b} is replace with a if blah exists and is nonzero else b. */ -int +static int format_replace(struct format_tree *ft, const char *key, size_t keylen, char **buf, size_t *len, size_t *off) { @@ -1019,7 +1023,7 @@ format_defaults(struct format_tree *ft, struct client *c, struct session *s, } /* Set default format keys for a session. */ -void +static void format_defaults_session(struct format_tree *ft, struct session *s) { struct session_group *sg; @@ -1048,7 +1052,7 @@ format_defaults_session(struct format_tree *ft, struct session *s) } /* Set default format keys for a client. */ -void +static void format_defaults_client(struct format_tree *ft, struct client *c) { struct session *s; @@ -1115,7 +1119,7 @@ format_defaults_window(struct format_tree *ft, struct window *w) } /* Set default format keys for a winlink. */ -void +static void format_defaults_winlink(struct format_tree *ft, struct session *s, struct winlink *wl) { |