aboutsummaryrefslogtreecommitdiff
path: root/src/param.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/param.c')
-rw-r--r--src/param.c38
1 files changed, 13 insertions, 25 deletions
diff --git a/src/param.c b/src/param.c
index d87a610..73005af 100644
--- a/src/param.c
+++ b/src/param.c
@@ -1,42 +1,30 @@
#include "param.h"
-#include "error.h"
#include <stdlib.h>
#include <string.h>
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * Parameter
- */
int magi_param_list_add(struct magi_param_list ** list,
struct magi_param * item)
{
- struct magi_param_list * old = *list;
- int ok = 1;
- *list = malloc(sizeof(**list));
- if (*list) {
- (*list)->next = old;
- (*list)->item = *item;
- } else {
- ok = 0;
- magi_error_set("[param:list] Cannot allocate new list node.");
- *list = old;
+ struct magi_param_list * node = malloc(sizeof(*node));
+ if (node) {
+ node->next = *list;
+ node->item = *item;
+ *list = node;
}
- return ok;
+ return node;
}
-struct magi_param * magi_param_list_get(struct magi_param_list * list,
- const char * name)
+char * magi_param_list_get(struct magi_param_list * list, const char * name)
{
- struct magi_param * item = 0;
- if (list && name) {
- if (!strcmp(list->item.name, name)) {
- item = &list->item;
- } else {
- item = magi_param_list_get(list->next, name);
- }
+ if (!list || !name) {
+ return 0;
+ } else if (!strcmp(list->item.name, name)) {
+ return &list->item.data;
+ } else {
+ return magi_param_list_get(list->next, name);
}
- return item;
}
void magi_param_list_destroy(struct magi_param_list * list)