]>
Commit | Line | Data |
---|---|---|
40d088c8 JB |
1 | --- libteam-1.11/teamd/teamd_zmq_common.h.orig 1970-01-01 01:00:00.000000000 +0100 |
2 | +++ libteam-1.11/teamd/teamd_zmq_common.h 2014-07-05 14:44:36.829477784 +0200 | |
3 | @@ -0,0 +1,58 @@ | |
4 | +/* | |
5 | + * teamd_zmq_common.h - Teamd unix socket api common things | |
6 | + * Copyright (C) 2013 Jiri Zupka <jzupka@redhat.com> | |
7 | + * | |
8 | + * This library is free software; you can redistribute it and/or | |
9 | + * modify it under the terms of the GNU Lesser General Public | |
10 | + * License as published by the Free Software Foundation; either | |
11 | + * version 2.1 of the License, or (at your option) any later version. | |
12 | + * | |
13 | + * This library is distributed in the hope that it will be useful, | |
14 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | + * Lesser General Public License for more details. | |
17 | + * | |
18 | + * You should have received a copy of the GNU Lesser General Public | |
19 | + * License along with this library; if not, write to the Free Software | |
20 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
21 | + */ | |
22 | + | |
23 | +#ifndef _TEAMD_ZMQ_COMMON_H_ | |
24 | +#define _TEAMD_ZMQ_COMMON_H_ | |
25 | + | |
26 | +#include <stdio.h> | |
27 | +#include <errno.h> | |
28 | +#include <sys/ioctl.h> | |
29 | +#include <linux/sockios.h> | |
30 | + | |
31 | +#include "teamd.h" | |
32 | + | |
33 | +#define TEAMD_ZMQ_REQUEST_PREFIX "REQUEST" | |
34 | +#define TEAMD_ZMQ_REPLY_ERR_PREFIX "REPLY_ERROR" | |
35 | +#define TEAMD_ZMQ_REPLY_SUCC_PREFIX "REPLY_SUCCESS" | |
36 | + | |
37 | +static inline char *teamd_zmq_msg_getline(char **p_rest) | |
38 | +{ | |
39 | + char *start = NULL; | |
40 | + char *rest = NULL; | |
41 | + char *str = *p_rest; | |
42 | + | |
43 | + if (!str) | |
44 | + return NULL; | |
45 | + while (1) { | |
46 | + if (*str == '\0') | |
47 | + break; | |
48 | + if ((*str != '\n') && !start) | |
49 | + start = str; | |
50 | + if ((*str == '\n') && start) { | |
51 | + *str = '\0'; | |
52 | + rest = str + 1; | |
53 | + break; | |
54 | + } | |
55 | + str++; | |
56 | + } | |
57 | + *p_rest = rest; | |
58 | + return start; | |
59 | +} | |
60 | + | |
61 | +#endif /* _TEAMD_ZMQ_COMMON_H_ */ |