Break the common process set up, event loop and imsg dispatch code

between server and client out into a separate internal API. This will
make it easier to add another process.
This commit is contained in:
nicm
2015-10-27 13:23:24 +00:00
parent 9952201ca7
commit 07b0ea03c3
13 changed files with 648 additions and 614 deletions

31
tmux.h
View File

@ -24,11 +24,9 @@
#include <sys/time.h>
#include <sys/queue.h>
#include <sys/tree.h>
#include <sys/uio.h>
#include <bitstring.h>
#include <event.h>
#include <imsg.h>
#include <limits.h>
#include <stdarg.h>
#include <stdint.h>
@ -1170,8 +1168,10 @@ struct message_entry {
};
/* Client connection. */
struct tmuxproc;
struct tmuxpeer;
struct client {
struct imsgbuf ibuf;
struct tmuxpeer *peer;
pid_t pid;
int fd;
@ -1209,7 +1209,7 @@ struct client {
#define CLIENT_STATUS 0x10
#define CLIENT_REPEAT 0x20
#define CLIENT_SUSPENDED 0x40
#define CLIENT_BAD 0x80
/* 0x80 unused */
#define CLIENT_IDENTIFY 0x100
#define CLIENT_DEAD 0x200
#define CLIENT_BORDERS 0x400
@ -1420,6 +1420,19 @@ int areshell(const char *);
void setblocking(int, int);
const char *find_home(void);
/* proc.c */
struct imsg;
int proc_send(struct tmuxpeer *, enum msgtype, int, const void *, size_t);
int proc_send_s(struct tmuxpeer *, enum msgtype, const char *);
struct tmuxproc *proc_start(const char *, struct event_base *, int,
void (*)(int));
void proc_loop(struct tmuxproc *, int (*)(void));
void proc_exit(struct tmuxproc *);
struct tmuxpeer *proc_add_peer(struct tmuxproc *, int,
void (*)(struct imsg *, void *), void *);
void proc_remove_peer(struct tmuxpeer *);
void proc_kill_peer(struct tmuxpeer *);
/* cfg.c */
extern int cfg_finished;
extern int cfg_references;
@ -1727,6 +1740,7 @@ void alerts_reset_all(void);
void alerts_queue(struct window *, int);
/* server.c */
extern struct tmuxproc *server_proc;
extern struct clients clients;
extern struct session *marked_session;
extern struct winlink *marked_winlink;
@ -1748,16 +1762,10 @@ void server_client_create(int);
int server_client_open(struct client *, char **);
void server_client_unref(struct client *);
void server_client_lost(struct client *);
void server_client_callback(int, short, void *);
void server_client_loop(void);
/* server-fn.c */
void server_fill_environ(struct session *, struct environ *);
void server_write_ready(struct client *);
int server_write_client(struct client *, enum msgtype, const void *,
size_t);
void server_write_session(struct session *, enum msgtype, const void *,
size_t);
void server_redraw_client(struct client *);
void server_status_client(struct client *);
void server_redraw_session(struct session *);
@ -1780,7 +1788,6 @@ void server_destroy_session(struct session *);
void server_check_unattached(void);
void server_set_identify(struct client *);
void server_clear_identify(struct client *);
void server_update_event(struct client *);
void server_push_stdout(struct client *);
void server_push_stderr(struct client *);
int server_set_stdin_callback(struct client *, void (*)(struct client *,
@ -2110,7 +2117,7 @@ char *format_window_name(struct window *);
char *parse_window_name(const char *);
/* signal.c */
void set_signals(void(*)(int, short, void *));
void set_signals(void(*)(int, short, void *), void *);
void clear_signals(int);
/* control.c */