| 1 | #ifndef USTCOMM_H |
| 2 | #define USTCOMM_H |
| 3 | |
| 4 | #include <sys/types.h> |
| 5 | #include <sys/un.h> |
| 6 | |
| 7 | #include "kcompat.h" |
| 8 | |
| 9 | struct ustcomm_connection { |
| 10 | struct list_head list; |
| 11 | int fd; |
| 12 | }; |
| 13 | |
| 14 | /* ustcomm_server must be shallow-copyable */ |
| 15 | struct ustcomm_server { |
| 16 | /* the "server" socket for serving the external requests */ |
| 17 | int listen_fd; |
| 18 | char *socketpath; |
| 19 | |
| 20 | struct list_head connections; |
| 21 | }; |
| 22 | |
| 23 | struct ustcomm_ustd { |
| 24 | struct ustcomm_server server; |
| 25 | }; |
| 26 | |
| 27 | struct ustcomm_app { |
| 28 | struct ustcomm_server server; |
| 29 | }; |
| 30 | |
| 31 | /* ustcomm_source must be shallow-copyable */ |
| 32 | struct ustcomm_source { |
| 33 | int fd; |
| 34 | void *priv; |
| 35 | }; |
| 36 | |
| 37 | char *strdup_malloc(const char *s); |
| 38 | |
| 39 | //int send_message_pid(pid_t pid, const char *msg, char **reply); |
| 40 | |
| 41 | int ustcomm_ustd_recv_message(struct ustcomm_ustd *ustd, char **msg, struct ustcomm_source *src, int timeout); |
| 42 | int ustcomm_app_recv_message(struct ustcomm_app *app, char **msg, struct ustcomm_source *src, int timeout); |
| 43 | |
| 44 | int ustcomm_init_app(pid_t pid, struct ustcomm_app *handle); |
| 45 | |
| 46 | int ustcomm_init_ustd(struct ustcomm_ustd *handle); |
| 47 | |
| 48 | int ustcomm_connect_app(pid_t pid, struct ustcomm_connection *conn); |
| 49 | int ustcomm_send_request(struct ustcomm_connection *conn, char *req, char **reply); |
| 50 | |
| 51 | int nth_token_is(char *str, char *token, int tok_no); |
| 52 | |
| 53 | char *nth_token(char *str, int tok_no); |
| 54 | |
| 55 | #endif /* USTCOMM_H */ |