libpkgconf: move pkg_tuple to pkgconf_tuple namespace

feature/tap-sh
William Pitcock 2015-09-06 10:41:40 -05:00
parent 1ee18d0e69
commit 4c71b25d5d
6 changed files with 48 additions and 48 deletions

View File

@ -225,7 +225,7 @@ pkgconf_dependency_parse_str(pkgconf_list_t *deplist_head, const char *depends)
void
pkgconf_dependency_parse(pkg_t *pkg, pkgconf_list_t *deplist, const char *depends)
{
char *kvdepends = pkg_tuple_parse(&pkg->vars, depends);
char *kvdepends = pkgconf_tuple_parse(&pkg->vars, depends);
pkgconf_dependency_parse_str(deplist, kvdepends);
free(kvdepends);

View File

@ -24,7 +24,7 @@ pkg_fragment_copy_munged(const char *source, unsigned int flags)
if (!(flags & PKGF_MUNGE_SYSROOT_PREFIX))
return strdup(source);
sysroot_dir = pkg_tuple_find_global("pc_sysrootdir");
sysroot_dir = pkgconf_tuple_find_global("pc_sysrootdir");
if (*source != '/' ||
(sysroot_dir != NULL && !strncmp(sysroot_dir, source, strlen(sysroot_dir))))
@ -194,7 +194,7 @@ pkg_fragment_parse(pkgconf_list_t *list, pkgconf_list_t *vars, const char *value
{
int i, argc;
char **argv;
char *repstr = pkg_tuple_parse(vars, value);
char *repstr = pkgconf_tuple_parse(vars, value);
pkg_argv_split(repstr, &argc, &argv);

View File

@ -37,7 +37,7 @@ typedef enum {
typedef struct pkg_ pkg_t;
typedef struct pkgconf_dependency_ pkgconf_dependency_t;
typedef struct pkg_tuple_ pkg_tuple_t;
typedef struct pkgconf_tuple_ pkgconf_tuple_t;
typedef struct pkg_fragment_ pkg_fragment_t;
#define PKGCONF_FOREACH_LIST_ENTRY(head, value) \
@ -68,7 +68,7 @@ struct pkgconf_dependency_ {
pkg_t *parent;
};
struct pkg_tuple_ {
struct pkgconf_tuple_ {
pkgconf_node_t iter;
char *key;
@ -169,14 +169,14 @@ void pkg_fragment_free(pkgconf_list_t *list);
char *pkg_fgetline(char *line, size_t size, FILE *stream);
/* tuple.c */
pkg_tuple_t *pkg_tuple_add(pkgconf_list_t *parent, const char *key, const char *value);
char *pkg_tuple_find(pkgconf_list_t *list, const char *key);
char *pkg_tuple_parse(pkgconf_list_t *list, const char *value);
void pkg_tuple_free(pkgconf_list_t *list);
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);
void pkg_tuple_define_global(const char *kv);
pkgconf_tuple_t *pkgconf_tuple_add(pkgconf_list_t *parent, const char *key, const char *value);
char *pkgconf_tuple_find(pkgconf_list_t *list, const char *key);
char *pkgconf_tuple_parse(pkgconf_list_t *list, const char *value);
void pkgconf_tuple_free(pkgconf_list_t *list);
void pkgconf_tuple_add_global(const char *key, const char *value);
char *pkgconf_tuple_find_global(const char *key);
void pkgconf_tuple_free_global(void);
void pkgconf_tuple_define_global(const char *kv);
/* main.c */
extern FILE *error_msgout;

View File

@ -199,7 +199,7 @@ pkg_new_from_file(const char *filename, FILE *f, unsigned int flags)
pkg = calloc(sizeof(pkg_t), 1);
pkg->filename = strdup(filename);
pkg_tuple_add(&pkg->vars, "pcfiledir", pkg_get_parent_dir(pkg));
pkgconf_tuple_add(&pkg->vars, "pcfiledir", pkg_get_parent_dir(pkg));
/* make module id */
if ((idptr = strrchr(pkg->filename, PKG_DIR_SEP_S)) != NULL)
@ -243,11 +243,11 @@ pkg_new_from_file(const char *filename, FILE *f, unsigned int flags)
{
case ':':
if (!strcmp(key, "Name"))
pkg->realname = pkg_tuple_parse(&pkg->vars, value);
pkg->realname = pkgconf_tuple_parse(&pkg->vars, value);
else if (!strcmp(key, "Description"))
pkg->description = pkg_tuple_parse(&pkg->vars, value);
pkg->description = pkgconf_tuple_parse(&pkg->vars, value);
else if (!strcmp(key, "Version"))
pkg->version = pkg_tuple_parse(&pkg->vars, value);
pkg->version = pkgconf_tuple_parse(&pkg->vars, value);
else if (!strcasecmp(key, "CFLAGS"))
pkg_fragment_parse(&pkg->cflags, &pkg->vars, value, flags);
else if (!strcasecmp(key, "CFLAGS.private"))
@ -264,7 +264,7 @@ pkg_new_from_file(const char *filename, FILE *f, unsigned int flags)
pkgconf_dependency_parse(pkg, &pkg->conflicts, value);
break;
case '=':
pkg_tuple_add(&pkg->vars, key, value);
pkgconf_tuple_add(&pkg->vars, key, value);
break;
default:
break;
@ -292,7 +292,7 @@ pkg_free(pkg_t *pkg)
pkg_fragment_free(&pkg->libs);
pkg_fragment_free(&pkg->libs_private);
pkg_tuple_free(&pkg->vars);
pkgconf_tuple_free(&pkg->vars);
if (pkg->id != NULL)
free(pkg->id);
@ -636,7 +636,7 @@ static pkg_t pkg_config_virtual = {
.head = &(pkgconf_node_t){
.prev = NULL,
.next = NULL,
.data = &(pkg_tuple_t){
.data = &(pkgconf_tuple_t){
.key = "pc_path",
.value = PKG_DEFAULT_PATH,
},

View File

@ -18,19 +18,19 @@
static pkgconf_list_t pkg_global_var = PKGCONF_LIST_INITIALIZER;
void
pkg_tuple_add_global(const char *key, const char *value)
pkgconf_tuple_add_global(const char *key, const char *value)
{
pkg_tuple_add(&pkg_global_var, key, value);
pkgconf_tuple_add(&pkg_global_var, key, value);
}
char *
pkg_tuple_find_global(const char *key)
pkgconf_tuple_find_global(const char *key)
{
pkgconf_node_t *node;
PKGCONF_FOREACH_LIST_ENTRY(pkg_global_var.head, node)
{
pkg_tuple_t *tuple = node->data;
pkgconf_tuple_t *tuple = node->data;
if (!strcmp(tuple->key, key))
return tuple->value;
@ -40,13 +40,13 @@ pkg_tuple_find_global(const char *key)
}
void
pkg_tuple_free_global(void)
pkgconf_tuple_free_global(void)
{
pkg_tuple_free(&pkg_global_var);
pkgconf_tuple_free(&pkg_global_var);
}
void
pkg_tuple_define_global(const char *kv)
pkgconf_tuple_define_global(const char *kv)
{
char *workbuf = strdup(kv);
char *value;
@ -56,18 +56,18 @@ pkg_tuple_define_global(const char *kv)
goto out;
*value++ = '\0';
pkg_tuple_add_global(workbuf, value);
pkgconf_tuple_add_global(workbuf, value);
out:
free(workbuf);
}
pkg_tuple_t *
pkg_tuple_add(pkgconf_list_t *list, const char *key, const char *value)
pkgconf_tuple_t *
pkgconf_tuple_add(pkgconf_list_t *list, const char *key, const char *value)
{
pkg_tuple_t *tuple = calloc(sizeof(pkg_tuple_t), 1);
pkgconf_tuple_t *tuple = calloc(sizeof(pkgconf_tuple_t), 1);
tuple->key = strdup(key);
tuple->value = pkg_tuple_parse(list, value);
tuple->value = pkgconf_tuple_parse(list, value);
pkgconf_node_insert(&tuple->iter, tuple, list);
@ -75,17 +75,17 @@ pkg_tuple_add(pkgconf_list_t *list, const char *key, const char *value)
}
char *
pkg_tuple_find(pkgconf_list_t *list, const char *key)
pkgconf_tuple_find(pkgconf_list_t *list, const char *key)
{
pkgconf_node_t *node;
char *res;
if ((res = pkg_tuple_find_global(key)) != NULL)
if ((res = pkgconf_tuple_find_global(key)) != NULL)
return res;
PKGCONF_FOREACH_LIST_ENTRY(list->head, node)
{
pkg_tuple_t *tuple = node->data;
pkgconf_tuple_t *tuple = node->data;
if (!strcmp(tuple->key, key))
return tuple->value;
@ -95,7 +95,7 @@ pkg_tuple_find(pkgconf_list_t *list, const char *key)
}
char *
pkg_tuple_parse(pkgconf_list_t *vars, const char *value)
pkgconf_tuple_parse(pkgconf_list_t *vars, const char *value)
{
char buf[PKG_BUFSIZE];
const char *ptr;
@ -126,11 +126,11 @@ pkg_tuple_parse(pkgconf_list_t *vars, const char *value)
}
ptr += (pptr - ptr);
kv = pkg_tuple_find(vars, varname);
kv = pkgconf_tuple_find(vars, varname);
if (kv != NULL)
{
parsekv = pkg_tuple_parse(vars, kv);
parsekv = pkgconf_tuple_parse(vars, kv);
strncpy(bptr, parsekv, PKG_BUFSIZE - (bptr - buf));
bptr += strlen(parsekv);
@ -146,13 +146,13 @@ pkg_tuple_parse(pkgconf_list_t *vars, const char *value)
}
void
pkg_tuple_free(pkgconf_list_t *list)
pkgconf_tuple_free(pkgconf_list_t *list)
{
pkgconf_node_t *node, *next;
PKGCONF_FOREACH_LIST_ENTRY_SAFE(list->head, next, node)
{
pkg_tuple_t *tuple = node->data;
pkgconf_tuple_t *tuple = node->data;
free(tuple->key);
free(tuple->value);

16
main.c
View File

@ -189,7 +189,7 @@ print_variables(pkg_t *pkg, void *unused, unsigned int flags)
PKGCONF_FOREACH_LIST_ENTRY(pkg->vars.head, node)
{
pkg_tuple_t *tuple = node->data;
pkgconf_tuple_t *tuple = node->data;
printf("%s\n", tuple->key);
}
@ -304,7 +304,7 @@ print_variable(pkg_t *pkg, void *data, unsigned int flags)
const char *var;
(void) flags;
var = pkg_tuple_find(&pkg->vars, req->variable);
var = pkgconf_tuple_find(&pkg->vars, req->variable);
if (var != NULL)
{
if (*(req->buf) == '\0')
@ -648,7 +648,7 @@ main(int argc, char *argv[])
maximum_traverse_depth = atoi(pkg_optarg);
break;
case 27:
pkg_tuple_define_global(pkg_optarg);
pkgconf_tuple_define_global(pkg_optarg);
break;
case 28:
required_exact_module_version = pkg_optarg;
@ -719,17 +719,17 @@ main(int argc, char *argv[])
want_flags |= PKG_KEEP_SYSTEM_LIBS;
if ((builddir = getenv("PKG_CONFIG_TOP_BUILD_DIR")) != NULL)
pkg_tuple_add_global("pc_top_builddir", builddir);
pkgconf_tuple_add_global("pc_top_builddir", builddir);
else
pkg_tuple_add_global("pc_top_builddir", "$(top_builddir)");
pkgconf_tuple_add_global("pc_top_builddir", "$(top_builddir)");
if ((sysroot_dir = getenv("PKG_CONFIG_SYSROOT_DIR")) != NULL)
{
pkg_tuple_add_global("pc_sysrootdir", sysroot_dir);
pkgconf_tuple_add_global("pc_sysrootdir", sysroot_dir);
global_traverse_flags |= PKGF_MUNGE_SYSROOT_PREFIX;
}
else
pkg_tuple_add_global("pc_sysrootdir", "/");
pkgconf_tuple_add_global("pc_sysrootdir", "/");
if (required_pkgconfig_version != NULL)
{
@ -1002,7 +1002,7 @@ out_println:
printf(" \n");
out:
pkg_tuple_free_global();
pkgconf_tuple_free_global();
pkg_cache_free();
return ret;