version 1.12, 2009/07/20 14:37:51 |
version 1.13, 2009/07/21 19:54:22 |
|
|
/* Client list. */ |
/* Client list. */ |
struct clients clients; |
struct clients clients; |
|
|
|
void server_create_client(int); |
int server_create_socket(void); |
int server_create_socket(void); |
int server_main(int); |
int server_main(int); |
void server_shutdown(void); |
void server_shutdown(void); |
|
|
void server_handle_windows(struct pollfd **); |
void server_handle_windows(struct pollfd **); |
void server_fill_clients(struct pollfd **); |
void server_fill_clients(struct pollfd **); |
void server_handle_clients(struct pollfd **); |
void server_handle_clients(struct pollfd **); |
struct client *server_accept_client(int); |
void server_accept_client(int); |
void server_handle_client(struct client *); |
void server_handle_client(struct client *); |
void server_handle_window(struct window *, struct window_pane *); |
void server_handle_window(struct window *, struct window_pane *); |
int server_check_window_bell(struct session *, struct window *); |
int server_check_window_bell(struct session *, struct window *); |
|
|
int server_update_socket(void); |
int server_update_socket(void); |
|
|
/* Create a new client. */ |
/* Create a new client. */ |
struct client * |
void |
server_create_client(int fd) |
server_create_client(int fd) |
{ |
{ |
struct client *c; |
struct client *c; |
|
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) { |
for (i = 0; i < ARRAY_LENGTH(&clients); i++) { |
if (ARRAY_ITEM(&clients, i) == NULL) { |
if (ARRAY_ITEM(&clients, i) == NULL) { |
ARRAY_SET(&clients, i, c); |
ARRAY_SET(&clients, i, c); |
return (c); |
return; |
} |
} |
} |
} |
ARRAY_ADD(&clients, c); |
ARRAY_ADD(&clients, c); |
return (c); |
|
} |
} |
|
|
/* Find client index. */ |
/* Find client index. */ |
|
|
} |
} |
|
|
/* accept(2) and create new client. */ |
/* accept(2) and create new client. */ |
struct client * |
void |
server_accept_client(int srv_fd) |
server_accept_client(int srv_fd) |
{ |
{ |
struct sockaddr_storage sa; |
struct sockaddr_storage sa; |
|
|
fd = accept(srv_fd, (struct sockaddr *) &sa, &slen); |
fd = accept(srv_fd, (struct sockaddr *) &sa, &slen); |
if (fd == -1) { |
if (fd == -1) { |
if (errno == EAGAIN || errno == EINTR || errno == ECONNABORTED) |
if (errno == EAGAIN || errno == EINTR || errno == ECONNABORTED) |
return (NULL); |
return; |
fatal("accept failed"); |
fatal("accept failed"); |
} |
} |
if (sigterm) { |
if (sigterm) { |
close(fd); |
close(fd); |
return (NULL); |
return; |
} |
} |
return (server_create_client(fd)); |
server_create_client(fd); |
} |
} |
|
|
/* Input data from client. */ |
/* Input data from client. */ |