Drop bson code from core 03/141203/2
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Fri, 28 Jul 2017 12:13:09 +0000 (14:13 +0200)
committerKrzysztof Opasiak <k.opasiak@samsung.com>
Thu, 3 Aug 2017 14:34:54 +0000 (16:34 +0200)
This commit will cause faultd to be linked to libejdb only
when ejdb module is enabled.

Change-Id: Id8957cb4e95ce7ea48079d53aaad31bceda2cf12
[Rebase to current HEAD]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
src/util/common.c
src/util/common.h

index c7bf804db18244751c543dccd372f6f9b5cfdbf9..a1bbd880a45d9ab024f6690801f900834e9ed41c 100644 (file)
 
 #include "common.h"
 
-GENERATE_BSON_APPEND_STRUCT(timespec,
-                                                       bson_append_long(out, "sec", data->tv_sec);
-                                                       bson_append_long(out, "nsec", data->tv_nsec);
-                                                       )
-
-int faultd_bson_iterator_timespec(const bson_iterator *i, struct timespec *t)
-{
-       int ret = -EINVAL;
-       bson_iterator it;
-       bson_type bt;
-       bool sec = false;
-       bool nsec = false;
-
-       bson_iterator_subiterator(i, &it);
-       while ((bt = bson_iterator_next(&it)) != BSON_EOO) {
-               if ((bt == BSON_LONG) &&
-                       (strcmp("sec", bson_iterator_key(&it)) == 0)) {
-
-                       sec = true;
-                       t->tv_sec = bson_iterator_long(&it);
-
-               } else if ((bt == BSON_LONG) &&
-                                  (strcmp("nsec", bson_iterator_key(&it)) == 0)) {
-
-                       nsec = true;
-                       t->tv_nsec = bson_iterator_long(&it);
-
-               }
-       }
-
-       if (sec && nsec)
-               ret = 0;
-
-       return ret;
-}
-
-int bson_fill_empty(bson *b)
-{
-       int ret;
-
-       ret = faultd_bson_safe_init_size(b, BSON_EMPTY_SIZE);
-       if (ret != BSON_OK)
-               goto out;
-
-       ret = bson_finish(b);
-       if (ret != BSON_OK)
-               goto destroy;
-
-       return 0;
-destroy:
-       bson_destroy(b);
-out:
-       return -ENOMEM;
-}
-
-char *bson_get_string(bson *b, char *fieldpath)
-{
-       bson_iterator it;
-       int ret;
-
-       BSON_ITERATOR_INIT(&it, b);
-
-       ret = bson_find_fieldpath_value(fieldpath, &it);
-       if (ret == BSON_EOO || ret != BSON_STRING)
-               return NULL;
-
-       return (char *)bson_iterator_string(&it);
-}
-
 static const size_t data_size[] = {
        [TYPE_OID] = sizeof(faultd_oid_t),
        [TYPE_STRING] = sizeof(char *),
index 2c09c628184683c42e114d63bf2cae23624b69d7..9b948063ce3f558a74e7b36b7fae7a9f0f1efa53 100644 (file)
@@ -68,50 +68,6 @@ static inline void freep(void *p)
 }
 #define _cleanup_free_ _cleanup_(freep)
 
-#define DECLARE_BSON_APPEND_STRUCT(type) \
-       void faultd_bson_append_##type(bson* out, const char *key, struct type *data)
-
-/* FIXME: bson_append_XXX can faile, check return codes */
-#define GENERATE_BSON_APPEND_STRUCT(type, code)        \
-       DECLARE_BSON_APPEND_STRUCT(type)                        \
-       {                                                                                       \
-               bson_append_start_object(out, key);             \
-               do { code } while(0);                                   \
-               bson_append_finish_object(out);                 \
-       }
-
-DECLARE_BSON_APPEND_STRUCT(timespec);
-int faultd_bson_iterator_timespec(const bson_iterator *i, struct timespec *t);
-
-#define BSON_EMPTY_SIZE (4 /* len */ + 1 /* \0 */)
-
-#define BSON_INITIAL_BUFFER_SIZE 128
-
-static inline int faultd_bson_safe_init_size(bson *b, int size)
-{
-       int ret;
-       /*
-        * TODO:
-        * For now ejdb does not provide bson constructors
-        * which return error if memory allocation fails.
-        * This wrapper should be removed when such functions
-        * become available.
-        */
-       bson_init_size(b, 0);
-       ret = bson_ensure_space(b, size);
-       if (ret != BSON_OK)
-               bson_destroy(b);
-
-       return ret;
-}
-
-#define faultd_bson_safe_init(b)                               \
-       faultd_bson_safe_init_size(b, BSON_INITIAL_BUFFER_SIZE)
-
-int bson_fill_empty(bson *b);
-
-char *bson_get_string(bson *b, char *fieldpath);
-
 enum faultd_type {
        TYPE_OID,
        TYPE_STRING,