diff --git a/main.c b/main.c index f216329..088c7ad 100644 --- a/main.c +++ b/main.c @@ -620,5 +620,8 @@ main(int argc, char *argv[]) return EXIT_FAILURE; } - return pkg_queue_walk(pkgq_head); + ret = pkg_queue_walk(pkgq_head); + + pkg_tuple_free_global(); + return ret; } diff --git a/pkg.h b/pkg.h index 457ecda..0453434 100644 --- a/pkg.h +++ b/pkg.h @@ -165,5 +165,8 @@ pkg_tuple_t *pkg_tuple_add(pkg_tuple_t *parent, const char *key, const char *val char *pkg_tuple_find(pkg_tuple_t *head, const char *key); char *pkg_tuple_parse(pkg_tuple_t *vars, const char *value); void pkg_tuple_free(pkg_tuple_t *head); +void pkg_tuple_add_global(const char *key, const char *value); +char *pkg_tuple_find_global(const char *key); +void pkg_tuple_free_global(void); #endif diff --git a/tuple.c b/tuple.c index bdab5fd..e5cf13e 100644 --- a/tuple.c +++ b/tuple.c @@ -24,6 +24,34 @@ #include "pkg.h" #include "bsdstubs.h" +static pkg_tuple_t *pkg_global_var; + +void +pkg_tuple_add_global(const char *key, const char *value) +{ + pkg_global_var = pkg_tuple_add(pkg_global_var, key, value); +} + +char * +pkg_tuple_find_global(const char *key) +{ + pkg_tuple_t *node; + + PKG_FOREACH_LIST_ENTRY(pkg_global_var, node) + { + if (!strcasecmp(node->key, key)) + return node->value; + } + + return NULL; +} + +void +pkg_tuple_free_global(void) +{ + pkg_tuple_free(pkg_global_var); +} + pkg_tuple_t * pkg_tuple_add(pkg_tuple_t *parent, const char *key, const char *value) { @@ -50,7 +78,7 @@ pkg_tuple_find(pkg_tuple_t *head, const char *key) return node->value; } - return NULL; + return pkg_tuple_find_global(key); } char *