Commit | Line | Data |
---|---|---|
c39c72ee PMF |
1 | /* Copyright (C) 2009 Pierre-Marc Fournier |
2 | * | |
3 | * This library is free software; you can redistribute it and/or | |
4 | * modify it under the terms of the GNU Lesser General Public | |
5 | * License as published by the Free Software Foundation; either | |
6 | * version 2.1 of the License, or (at your option) any later version. | |
7 | * | |
8 | * This library is distributed in the hope that it will be useful, | |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
11 | * Lesser General Public License for more details. | |
12 | * | |
13 | * You should have received a copy of the GNU Lesser General Public | |
14 | * License along with this library; if not, write to the Free Software | |
15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
16 | */ | |
17 | ||
f9e5ce61 PMF |
18 | #ifndef USTCOMM_H |
19 | #define USTCOMM_H | |
20 | ||
21 | #include <sys/types.h> | |
b02e31e5 | 22 | #include <sys/un.h> |
f9e5ce61 | 23 | |
aca1ad90 PMF |
24 | #include "kcompat.h" |
25 | ||
26 | struct ustcomm_connection { | |
27 | struct list_head list; | |
28 | int fd; | |
29 | }; | |
30 | ||
3a7b90de | 31 | /* ustcomm_server must be shallow-copyable */ |
811e4b93 | 32 | struct ustcomm_server { |
b0540e11 | 33 | /* the "server" socket for serving the external requests */ |
aca1ad90 | 34 | int listen_fd; |
d0b5f2b9 | 35 | char *socketpath; |
aca1ad90 PMF |
36 | |
37 | struct list_head connections; | |
d0b5f2b9 PMF |
38 | }; |
39 | ||
40 | struct ustcomm_ustd { | |
811e4b93 PMF |
41 | struct ustcomm_server server; |
42 | }; | |
aca1ad90 | 43 | |
811e4b93 PMF |
44 | struct ustcomm_app { |
45 | struct ustcomm_server server; | |
d0b5f2b9 PMF |
46 | }; |
47 | ||
3a7b90de | 48 | /* ustcomm_source must be shallow-copyable */ |
b02e31e5 | 49 | struct ustcomm_source { |
811e4b93 PMF |
50 | int fd; |
51 | void *priv; | |
b02e31e5 PMF |
52 | }; |
53 | ||
688760ef PMF |
54 | char *strdup_malloc(const char *s); |
55 | ||
3bb56863 | 56 | //int send_message_pid(pid_t pid, const char *msg, char **reply); |
9160b4e4 | 57 | int ustcomm_request_consumer(pid_t pid, const char *channel); |
d0b5f2b9 | 58 | |
688760ef PMF |
59 | int ustcomm_ustd_recv_message(struct ustcomm_ustd *ustd, char **msg, struct ustcomm_source *src, int timeout); |
60 | int ustcomm_app_recv_message(struct ustcomm_app *app, char **msg, struct ustcomm_source *src, int timeout); | |
3847c3ba | 61 | |
d0b5f2b9 PMF |
62 | int ustcomm_init_app(pid_t pid, struct ustcomm_app *handle); |
63 | ||
64 | int ustcomm_init_ustd(struct ustcomm_ustd *handle); | |
f9e5ce61 | 65 | |
3bb56863 PMF |
66 | int ustcomm_connect_app(pid_t pid, struct ustcomm_connection *conn); |
67 | int ustcomm_send_request(struct ustcomm_connection *conn, char *req, char **reply); | |
9160b4e4 | 68 | int ustcomm_send_reply(struct ustcomm_server *server, char *msg, struct ustcomm_source *src); |
3bb56863 | 69 | |
b02e31e5 PMF |
70 | int nth_token_is(char *str, char *token, int tok_no); |
71 | ||
72 | char *nth_token(char *str, int tok_no); | |
73 | ||
f9e5ce61 | 74 | #endif /* USTCOMM_H */ |