return 0;
}
+size_t ctdb_bool_len(bool *in)
+{
+ uint8_t u8 = *in;
+
+ return ctdb_uint8_len(&u8);
+}
+
+void ctdb_bool_push(bool *in, uint8_t *buf, size_t *npush)
+{
+ size_t np;
+ uint8_t u8 = *in;
+
+ ctdb_uint8_push(&u8, buf, &np);
+ *npush = np;
+}
+
+int ctdb_bool_pull(uint8_t *buf, size_t buflen, bool *out, size_t *npull)
+{
+ size_t np;
+ uint8_t u8;
+ int ret;
+
+ ret = ctdb_uint8_pull(buf, buflen, &u8, &np);
+ if (ret != 0) {
+ return ret;
+ }
+
+ if (u8 == 0) {
+ *out = false;
+ } else if (u8 == 1) {
+ *out = true;
+ } else {
+ return EINVAL;
+ }
+
+ *npull = np;
+ return 0;
+}
+
size_t ctdb_string_len(const char *str)
{
if (str == NULL) {
void ctdb_double_push(double *in, uint8_t *buf, size_t *npush);
int ctdb_double_pull(uint8_t *buf, size_t buflen, double *out, size_t *npull);
+size_t ctdb_bool_len(bool *in);
+void ctdb_bool_push(bool *in, uint8_t *buf, size_t *npush);
+int ctdb_bool_pull(uint8_t *buf, size_t buflen, bool *out, size_t *npull);
+
size_t ctdb_string_len(const char *str);
void ctdb_string_push(const char *str, uint8_t *buf);
int ctdb_string_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
PROTOCOL_TYPE1_TEST(uint32_t, ctdb_uint32);
PROTOCOL_TYPE1_TEST(uint64_t, ctdb_uint64);
PROTOCOL_TYPE1_TEST(double, ctdb_double);
+PROTOCOL_TYPE1_TEST(bool, ctdb_bool);
static void test_ctdb_string(void)
{
TEST_FUNC(ctdb_uint32)();
TEST_FUNC(ctdb_uint64)();
TEST_FUNC(ctdb_double)();
+ TEST_FUNC(ctdb_bool)();
test_ctdb_string();
test_ctdb_stringn();
assert(*p1 == *p2);
}
+void fill_ctdb_bool(bool *p)
+{
+ if (rand_int(2) == 0) {
+ *p = true;
+ } else {
+ *p = false;
+ }
+}
+
+void verify_ctdb_bool(bool *p1, bool *p2)
+{
+ assert(*p1 == *p2);
+}
+
void fill_ctdb_string(TALLOC_CTX *mem_ctx, const char **out)
{
char *p;
void fill_ctdb_double(double *p);
void verify_ctdb_double(double *p1, double *p2);
+void fill_ctdb_bool(bool *p);
+void verify_ctdb_bool(bool *p1, bool *p2);
+
void fill_ctdb_string(TALLOC_CTX *mem_ctx, const char **out);
void verify_ctdb_string(const char *p1, const char *p2);