From ca7064277a864e8e33cf9042c693c5580727282b Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Wed, 19 Feb 2014 23:12:24 +0100 Subject: [PATCH] store: Split private type definitions into a new header store-private.h. --- src/Makefile.am | 1 + src/core/store-private.h | 92 +++++++++++++++++++++++++++++++ src/core/store.c | 46 +--------------- src/frontend/connection-private.h | 2 +- 4 files changed, 95 insertions(+), 46 deletions(-) create mode 100644 src/core/store-private.h diff --git a/src/Makefile.am b/src/Makefile.am index 8736948..77ce39f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -66,6 +66,7 @@ libsysdb_la_SOURCES = \ core/object.c include/core/object.h \ core/plugin.c include/core/plugin.h \ core/store.c include/core/store.h \ + core/store-private.h \ core/data.c include/core/data.h \ frontend/connection.c include/frontend/connection.h \ frontend/connection-private.h \ diff --git a/src/core/store-private.h b/src/core/store-private.h new file mode 100644 index 0000000..abd94c2 --- /dev/null +++ b/src/core/store-private.h @@ -0,0 +1,92 @@ +/* + * SysDB - src/core/store-private.h + * Copyright (C) 2012-2013 Sebastian 'tokkee' Harl + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * private data structures used by the store module + */ + +#ifndef SDB_CORE_STORE_PRIVATE_H +#define SDB_CORE_STORE_PRIVATE_H 1 + +#include "core/store.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct sdb_store_base { + sdb_object_t super; + + /* object type */ + int type; + + /* common meta information */ + sdb_time_t last_update; + sdb_store_base_t *parent; +}; +#define STORE_BASE(obj) ((sdb_store_base_t *)(obj)) +#define STORE_CONST_BASE(obj) ((const sdb_store_base_t *)(obj)) + +typedef struct { + sdb_store_base_t super; + + sdb_data_t value; +} sdb_attribute_t; +#define SDB_ATTR(obj) ((sdb_attribute_t *)(obj)) +#define SDB_CONST_ATTR(obj) ((const sdb_attribute_t *)(obj)) + +typedef struct { + sdb_store_base_t super; + + sdb_llist_t *children; + sdb_llist_t *attributes; +} sdb_store_obj_t; +#define SDB_STORE_OBJ(obj) ((sdb_store_obj_t *)(obj)) +#define SDB_CONST_STORE_OBJ(obj) ((const sdb_store_obj_t *)(obj)) + +enum { + SDB_HOST = 1, + SDB_SERVICE, + SDB_ATTRIBUTE, +}; +#define TYPE_TO_NAME(t) \ + (((t) == SDB_HOST) ? "host" \ + : ((t) == SDB_SERVICE) ? "service" \ + : ((t) == SDB_ATTRIBUTE) ? "attribute" : "unknown") + +/* shortcuts for accessing the sdb_store_obj_t attributes + * of inheriting objects */ +#define _last_update super.last_update + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* ! SDB_CORE_STORE_H */ + +/* vim: set tw=78 sw=4 ts=4 noexpandtab : */ + diff --git a/src/core/store.c b/src/core/store.c index 753b981..d3448c2 100644 --- a/src/core/store.c +++ b/src/core/store.c @@ -26,7 +26,7 @@ */ #include "sysdb.h" -#include "core/store.h" +#include "core/store-private.h" #include "core/plugin.h" #include "utils/error.h" #include "utils/llist.h" @@ -55,50 +55,6 @@ static pthread_rwlock_t obj_lock = PTHREAD_RWLOCK_INITIALIZER; static sdb_type_t sdb_store_obj_type; static sdb_type_t sdb_attribute_type; -struct sdb_store_base { - sdb_object_t super; - - /* object type */ - int type; - - /* common meta information */ - sdb_time_t last_update; - sdb_store_base_t *parent; -}; -#define STORE_BASE(obj) ((sdb_store_base_t *)(obj)) -#define STORE_CONST_BASE(obj) ((const sdb_store_base_t *)(obj)) - -typedef struct { - sdb_store_base_t super; - - sdb_data_t value; -} sdb_attribute_t; -#define SDB_ATTR(obj) ((sdb_attribute_t *)(obj)) -#define SDB_CONST_ATTR(obj) ((const sdb_attribute_t *)(obj)) - -typedef struct { - sdb_store_base_t super; - - sdb_llist_t *children; - sdb_llist_t *attributes; -} sdb_store_obj_t; -#define SDB_STORE_OBJ(obj) ((sdb_store_obj_t *)(obj)) -#define SDB_CONST_STORE_OBJ(obj) ((const sdb_store_obj_t *)(obj)) - -enum { - SDB_HOST = 1, - SDB_SERVICE, - SDB_ATTRIBUTE, -}; -#define TYPE_TO_NAME(t) \ - (((t) == SDB_HOST) ? "host" \ - : ((t) == SDB_SERVICE) ? "service" \ - : ((t) == SDB_ATTRIBUTE) ? "attribute" : "unknown") - -/* shortcuts for accessing the sdb_store_obj_t attributes - * of inheriting objects */ -#define _last_update super.last_update - static int store_base_init(sdb_object_t *obj, va_list ap) { diff --git a/src/frontend/connection-private.h b/src/frontend/connection-private.h index 6cf7395..39fc852 100644 --- a/src/frontend/connection-private.h +++ b/src/frontend/connection-private.h @@ -1,5 +1,5 @@ /* - * SysDB - src/include/frontend/connection-private.h + * SysDB - src/frontend/connection-private.h * Copyright (C) 2013 Sebastian 'tokkee' Harl * All rights reserved. * -- 2.30.2