code cleanups
[lttng-ust.git] / libustcomm / ustcomm.h
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
18 #ifndef USTCOMM_H
19 #define USTCOMM_H
20
21 #include <sys/types.h>
22 #include <sys/un.h>
23
24 #include "kcompat.h"
25
26 #define SOCK_DIR "/tmp/socks"
27 #define UST_SIGNAL SIGIO
28
29 struct ustcomm_connection {
30 struct list_head list;
31 int fd;
32 };
33
34 /* ustcomm_server must be shallow-copyable */
35 struct ustcomm_server {
36 /* the "server" socket for serving the external requests */
37 int listen_fd;
38 char *socketpath;
39
40 struct list_head connections;
41 };
42
43 struct ustcomm_ustd {
44 struct ustcomm_server server;
45 };
46
47 struct ustcomm_app {
48 struct ustcomm_server server;
49 };
50
51 /* ustcomm_source must be shallow-copyable */
52 struct ustcomm_source {
53 int fd;
54 void *priv;
55 };
56
57 char *strdup_malloc(const char *s);
58
59 //int send_message_pid(pid_t pid, const char *msg, char **reply);
60 int ustcomm_request_consumer(pid_t pid, const char *channel);
61
62 int ustcomm_ustd_recv_message(struct ustcomm_ustd *ustd, char **msg, struct ustcomm_source *src, int timeout);
63 int ustcomm_app_recv_message(struct ustcomm_app *app, char **msg, struct ustcomm_source *src, int timeout);
64
65 int ustcomm_init_app(pid_t pid, struct ustcomm_app *handle);
66
67 int ustcomm_init_ustd(struct ustcomm_ustd *handle);
68
69 int ustcomm_connect_app(pid_t pid, struct ustcomm_connection *conn);
70 int ustcomm_send_request(struct ustcomm_connection *conn, const char *req, char **reply);
71 int ustcomm_send_reply(struct ustcomm_server *server, char *msg, struct ustcomm_source *src);
72
73 int nth_token_is(char *str, char *token, int tok_no);
74
75 char *nth_token(char *str, int tok_no);
76
77 int pid_is_online(pid_t);
78
79 #endif /* USTCOMM_H */
This page took 0.041777 seconds and 5 git commands to generate.