diff --git a/src/csync.c b/src/csync.c index 240332804..7b254e88c 100644 --- a/src/csync.c +++ b/src/csync.c @@ -135,6 +135,8 @@ int csync_init(CSYNC *ctx) { goto out; } + /* TODO: load plugins */ + ctx->initialized = 1; rc = 0; diff --git a/src/csync_private.h b/src/csync_private.h index dcd0de52e..65af23e12 100644 --- a/src/csync_private.h +++ b/src/csync_private.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * vim: ts=2 sw=2 et cindent + * vim: ft=c.doxygen ts=2 sw=2 et cindent */ /** @@ -66,6 +66,7 @@ enum csync_replica_e { struct csync_s { c_rbtree_t *local; c_rbtree_t *remote; + c_strlist_t *excludes; sqlite3 *journal; struct { diff --git a/src/std/c_string.c b/src/std/c_string.c index d1f535332..2c80a04da 100644 --- a/src/std/c_string.c +++ b/src/std/c_string.c @@ -20,6 +20,7 @@ * vim: ts=2 sw=2 et cindent */ +#include #include #include "c_string.h" @@ -47,6 +48,7 @@ c_strlist_t *c_strlist_new(size_t size) { c_strlist_t *strlist = NULL; if (size == 0) { + errno = EINVAL; return NULL; } @@ -55,7 +57,7 @@ c_strlist_t *c_strlist_new(size_t size) { return NULL; } - strlist->vector = c_malloc(size * sizeof(char *)); + strlist->vector = (char **) c_malloc(size * sizeof(char *)); if (strlist->vector == NULL) { SAFE_FREE(strlist); return NULL; @@ -66,6 +68,26 @@ c_strlist_t *c_strlist_new(size_t size) { return strlist; } +c_strlist_t *c_strlist_expand(c_strlist_t *strlist, size_t size) { + if (strlist == NULL || size == 0) { + errno = EINVAL; + return NULL; + } + + if (strlist->size >= size) { + return strlist; + } + + strlist->vector = (char **) c_realloc(strlist->vector, size * sizeof(char *)); + if (strlist->vector == NULL) { + return NULL; + } + + strlist->size = size; + + return strlist; +} + int c_strlist_add(c_strlist_t *strlist, char *string) { if (strlist == NULL || string == NULL) { return -1; diff --git a/src/std/c_string.h b/src/std/c_string.h index 770b5e801..c02968e3e 100644 --- a/src/std/c_string.h +++ b/src/std/c_string.h @@ -74,6 +74,16 @@ int c_streq(const char *a, const char *b); */ c_strlist_t *c_strlist_new(size_t size); +/** + * @brief Expand the stringlist + * + * @param strlist Stringlist to expand + * @param size New size of the strlinglist to expand + * + * @return Pointer to the expanded stringlist. NULL if an error occured. + */ +c_strlist_t *c_strlist_expand(c_strlist_t *strlist, size_t size); + /** * @brief Add a string to the stringlist. * diff --git a/tests/std_tests/check_std_c_str.c b/tests/std_tests/check_std_c_str.c index 69477c4f5..f9ca8aaa5 100644 --- a/tests/std_tests/check_std_c_str.c +++ b/tests/std_tests/check_std_c_str.c @@ -74,11 +74,34 @@ START_TEST (check_c_strlist_add) } END_TEST +START_TEST (check_c_strlist_expand) +{ + size_t i = 0; + c_strlist_t *strlist = NULL; + + strlist = c_strlist_new(42); + fail_if(strlist == NULL, NULL); + fail_unless(strlist->size == 42, NULL); + fail_unless(strlist->count == 0, NULL); + + strlist = c_strlist_expand(strlist, 84); + fail_if(strlist == NULL, NULL); + fail_unless(strlist->size == 84, NULL); + + for (i = 0; i < strlist->size; i++) { + fail_unless(c_strlist_add(strlist, (char *) "foobar") == 0, NULL); + } + + c_strlist_destroy(strlist); +} +END_TEST + static Suite *make_std_c_strlist_suite(void) { Suite *s = suite_create("std:str:c_stringlist"); create_case(s, "check_c_strlist_new", check_c_strlist_new); create_case(s, "check_c_strlist_add", check_c_strlist_add); + create_case(s, "check_c_strlist_expand", check_c_strlist_expand); return s; } @@ -91,6 +114,9 @@ int main(void) { SRunner *sr; sr = srunner_create(s); +#if 0 + srunner_set_fork_status(sr, CK_NOFORK); +#endif srunner_add_suite (sr, s2); srunner_run_all(sr, CK_VERBOSE); nf = srunner_ntests_failed(sr);