summaryrefslogtreecommitdiff
path: root/key_value_storage.c
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2015-07-26 17:13:42 (GMT)
committerChristian Pointner <equinox@spreadspace.org>2015-07-26 17:13:42 (GMT)
commit1324242685b63a511be3b3625f78e1ebf2dafc76 (patch)
treeb83d4947415757fba945b7a91a25230c9d044144 /key_value_storage.c
parentc6bbdfbdde366bfbb37858e7dc9e0fc351595023 (diff)
moved sources to src/
Diffstat (limited to 'key_value_storage.c')
-rw-r--r--key_value_storage.c92
1 files changed, 0 insertions, 92 deletions
diff --git a/key_value_storage.c b/key_value_storage.c
deleted file mode 100644
index c6341e6..0000000
--- a/key_value_storage.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * rhctl
- *
- * Copyright (C) 2009-2014 Christian Pointner <equinox@helsinki.at>
- *
- * This file is part of rhctl.
- *
- * rhctl is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * rhctl is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with rhctl. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdio.h>
-#include <string.h>
-
-#include "key_value_storage.h"
-
-void key_value_storage_init(key_value_storage_t* stor)
-{
- if(!stor)
- return;
-
- string_list_init(&(stor->keys_));
- string_list_init(&(stor->values_));
-}
-
-void key_value_storage_clear(key_value_storage_t* stor)
-{
- if(!stor)
- return;
-
- string_list_clear(&(stor->keys_));
- string_list_clear(&(stor->values_));
-}
-
-int key_value_storage_add(key_value_storage_t* stor, const char* key, const char* value)
-{
- if(!stor || !key || !value)
- return -1;
-
- int ret = string_list_add(&(stor->keys_), key);
- if(ret!=0)
- return ret;
-
- ret = string_list_add(&(stor->values_), value);
- if(ret!=0)
- return ret;
-
- return 0;
-}
-
-char* key_value_storage_find(key_value_storage_t* stor, const char* key)
-{
- if(!stor || !key)
- return NULL;
-
- string_list_element_t* k = stor->keys_.first_;
- string_list_element_t* v = stor->values_.first_;
- while(v && k) {
- if(!strcmp(k->string_, key))
- return v->string_;
-
- k = k->next_;
- v = v->next_;
- }
-
- return NULL;
-}
-
-void key_value_storage_print(key_value_storage_t* stor, const char* head, const char* sep, const char* tail)
-{
- if(!stor)
- return;
-
- string_list_element_t* k = stor->keys_.first_;
- string_list_element_t* v = stor->values_.first_;
- while(v && k) {
- printf("%s%s%s%s%s", head, k->string_, sep, v->string_, tail);
- k = k->next_;
- v = v->next_;
- }
- printf("\n");
-}