2 CTDB protocol marshalling
4 Copyright (C) Amitay Isaacs 2018
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #ifndef __PROTOCOL_BASIC_H__
21 #define __PROTOCOL_BASIC_H__
24 * From protocol/protocol_basic.c
27 size_t ctdb_uint8_len(uint8_t *in
);
28 void ctdb_uint8_push(uint8_t *in
, uint8_t *buf
, size_t *npush
);
29 int ctdb_uint8_pull(uint8_t *buf
, size_t buflen
, uint8_t *out
, size_t *npull
);
31 size_t ctdb_uint16_len(uint16_t *in
);
32 void ctdb_uint16_push(uint16_t *in
, uint8_t *buf
, size_t *npush
);
33 int ctdb_uint16_pull(uint8_t *buf
, size_t buflen
, uint16_t *out
,
36 size_t ctdb_int32_len(int32_t *in
);
37 void ctdb_int32_push(int32_t *in
, uint8_t *buf
, size_t *npush
);
38 int ctdb_int32_pull(uint8_t *buf
, size_t buflen
, int32_t *out
, size_t *npull
);
40 size_t ctdb_uint32_len(uint32_t *in
);
41 void ctdb_uint32_push(uint32_t *in
, uint8_t *buf
, size_t *npush
);
42 int ctdb_uint32_pull(uint8_t *buf
, size_t buflen
, uint32_t *out
,
45 size_t ctdb_uint64_len(uint64_t *in
);
46 void ctdb_uint64_push(uint64_t *in
, uint8_t *buf
, size_t *npush
);
47 int ctdb_uint64_pull(uint8_t *buf
, size_t buflen
, uint64_t *out
,
50 size_t ctdb_double_len(double *in
);
51 void ctdb_double_push(double *in
, uint8_t *buf
, size_t *npush
);
52 int ctdb_double_pull(uint8_t *buf
, size_t buflen
, double *out
, size_t *npull
);
54 size_t ctdb_bool_len(bool *in
);
55 void ctdb_bool_push(bool *in
, uint8_t *buf
, size_t *npush
);
56 int ctdb_bool_pull(uint8_t *buf
, size_t buflen
, bool *out
, size_t *npull
);
58 size_t ctdb_chararray_len(char *in
, size_t len
);
59 void ctdb_chararray_push(char *in
, size_t len
, uint8_t *buf
, size_t *npush
);
60 int ctdb_chararray_pull(uint8_t *buf
, size_t buflen
, char *out
, size_t len
,
63 size_t ctdb_string_len(const char **in
);
64 void ctdb_string_push(const char **in
, uint8_t *buf
, size_t *npush
);
65 int ctdb_string_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
66 const char **out
, size_t *npull
);
68 size_t ctdb_stringn_len(const char **in
);
69 void ctdb_stringn_push(const char **in
, uint8_t *buf
, size_t *npush
);
70 int ctdb_stringn_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
71 const char **out
, size_t *npull
);
73 size_t ctdb_pid_len(pid_t
*in
);
74 void ctdb_pid_push(pid_t
*in
, uint8_t *buf
, size_t *npush
);
75 int ctdb_pid_pull(uint8_t *buf
, size_t buflen
, pid_t
*out
, size_t *npull
);
77 size_t ctdb_timeval_len(struct timeval
*in
);
78 void ctdb_timeval_push(struct timeval
*in
, uint8_t *buf
, size_t *npush
);
79 int ctdb_timeval_pull(uint8_t *buf
, size_t buflen
, struct timeval
*out
,
82 size_t ctdb_padding_len(int count
);
83 void ctdb_padding_push(int count
, uint8_t *buf
, size_t *npush
);
84 int ctdb_padding_pull(uint8_t *buf
, size_t buflen
, int count
, size_t *npull
);
86 #endif /* __PROTOCOL_BASIC_H__ */