libpkgconf: move pkg_fragment to pkgconf_fragment namespace

feature/tap-sh
William Pitcock 2015-09-06 10:44:10 -05:00
parent 4c71b25d5d
commit 61d5fc72c8
4 changed files with 60 additions and 60 deletions

View File

@ -16,7 +16,7 @@
#include <libpkgconf/libpkgconf.h> #include <libpkgconf/libpkgconf.h>
static inline char * static inline char *
pkg_fragment_copy_munged(const char *source, unsigned int flags) pkgconf_fragment_copy_munged(const char *source, unsigned int flags)
{ {
char mungebuf[PKG_BUFSIZE]; char mungebuf[PKG_BUFSIZE];
char *sysroot_dir; char *sysroot_dir;
@ -37,22 +37,22 @@ pkg_fragment_copy_munged(const char *source, unsigned int flags)
} }
void void
pkg_fragment_add(pkgconf_list_t *list, const char *string, unsigned int flags) pkgconf_fragment_add(pkgconf_list_t *list, const char *string, unsigned int flags)
{ {
pkg_fragment_t *frag; pkgconf_fragment_t *frag;
if (*string == '-' && strncmp(string, "-lib:", 5) && strncmp(string, "-framework", 10)) if (*string == '-' && strncmp(string, "-lib:", 5) && strncmp(string, "-framework", 10))
{ {
frag = calloc(sizeof(pkg_fragment_t), 1); frag = calloc(sizeof(pkgconf_fragment_t), 1);
frag->type = *(string + 1); frag->type = *(string + 1);
frag->data = pkg_fragment_copy_munged(string + 2, flags); frag->data = pkgconf_fragment_copy_munged(string + 2, flags);
} }
else else
{ {
if (list->tail != NULL && list->tail->data != NULL) if (list->tail != NULL && list->tail->data != NULL)
{ {
pkg_fragment_t *parent = list->tail->data; pkgconf_fragment_t *parent = list->tail->data;
if (!strncmp(parent->data, "-framework", 10)) if (!strncmp(parent->data, "-framework", 10))
{ {
@ -71,7 +71,7 @@ pkg_fragment_add(pkgconf_list_t *list, const char *string, unsigned int flags)
} }
} }
frag = calloc(sizeof(pkg_fragment_t), 1); frag = calloc(sizeof(pkgconf_fragment_t), 1);
frag->type = 0; frag->type = 0;
frag->data = strdup(string); frag->data = strdup(string);
@ -80,14 +80,14 @@ pkg_fragment_add(pkgconf_list_t *list, const char *string, unsigned int flags)
pkgconf_node_insert_tail(&frag->iter, frag, list); pkgconf_node_insert_tail(&frag->iter, frag, list);
} }
static inline pkg_fragment_t * static inline pkgconf_fragment_t *
pkg_fragment_lookup(pkgconf_list_t *list, pkg_fragment_t *base) pkgconf_fragment_lookup(pkgconf_list_t *list, pkgconf_fragment_t *base)
{ {
pkgconf_node_t *node; pkgconf_node_t *node;
PKGCONF_FOREACH_LIST_ENTRY_REVERSE(list->tail, node) PKGCONF_FOREACH_LIST_ENTRY_REVERSE(list->tail, node)
{ {
pkg_fragment_t *frag = node->data; pkgconf_fragment_t *frag = node->data;
if (base->type != frag->type) if (base->type != frag->type)
continue; continue;
@ -100,7 +100,7 @@ pkg_fragment_lookup(pkgconf_list_t *list, pkg_fragment_t *base)
} }
static inline bool static inline bool
pkg_fragment_can_merge_back(pkg_fragment_t *base, unsigned int flags, bool is_private) pkgconf_fragment_can_merge_back(pkgconf_fragment_t *base, unsigned int flags, bool is_private)
{ {
(void) flags; (void) flags;
@ -123,7 +123,7 @@ pkg_fragment_can_merge_back(pkg_fragment_t *base, unsigned int flags, bool is_pr
} }
static inline bool static inline bool
pkg_fragment_can_merge(pkg_fragment_t *base, unsigned int flags, bool is_private) pkgconf_fragment_can_merge(pkgconf_fragment_t *base, unsigned int flags, bool is_private)
{ {
(void) flags; (void) flags;
@ -136,29 +136,29 @@ pkg_fragment_can_merge(pkg_fragment_t *base, unsigned int flags, bool is_private
return true; return true;
} }
static inline pkg_fragment_t * static inline pkgconf_fragment_t *
pkg_fragment_exists(pkgconf_list_t *list, pkg_fragment_t *base, unsigned int flags, bool is_private) pkgconf_fragment_exists(pkgconf_list_t *list, pkgconf_fragment_t *base, unsigned int flags, bool is_private)
{ {
if (!pkg_fragment_can_merge_back(base, flags, is_private)) if (!pkgconf_fragment_can_merge_back(base, flags, is_private))
return NULL; return NULL;
if (!pkg_fragment_can_merge(base, flags, is_private)) if (!pkgconf_fragment_can_merge(base, flags, is_private))
return NULL; return NULL;
return pkg_fragment_lookup(list, base); return pkgconf_fragment_lookup(list, base);
} }
void void
pkg_fragment_copy(pkgconf_list_t *list, pkg_fragment_t *base, unsigned int flags, bool is_private) pkgconf_fragment_copy(pkgconf_list_t *list, pkgconf_fragment_t *base, unsigned int flags, bool is_private)
{ {
pkg_fragment_t *frag; pkgconf_fragment_t *frag;
if ((frag = pkg_fragment_exists(list, base, flags, is_private)) != NULL) if ((frag = pkgconf_fragment_exists(list, base, flags, is_private)) != NULL)
pkg_fragment_delete(list, frag); pkgconf_fragment_delete(list, frag);
else if (!is_private && !pkg_fragment_can_merge_back(base, flags, is_private) && (pkg_fragment_lookup(list, base) != NULL)) else if (!is_private && !pkgconf_fragment_can_merge_back(base, flags, is_private) && (pkgconf_fragment_lookup(list, base) != NULL))
return; return;
frag = calloc(sizeof(pkg_fragment_t), 1); frag = calloc(sizeof(pkgconf_fragment_t), 1);
frag->type = base->type; frag->type = base->type;
frag->data = strdup(base->data); frag->data = strdup(base->data);
@ -167,7 +167,7 @@ pkg_fragment_copy(pkgconf_list_t *list, pkg_fragment_t *base, unsigned int flags
} }
void void
pkg_fragment_delete(pkgconf_list_t *list, pkg_fragment_t *node) pkgconf_fragment_delete(pkgconf_list_t *list, pkgconf_fragment_t *node)
{ {
pkgconf_node_delete(&node->iter, list); pkgconf_node_delete(&node->iter, list);
@ -176,13 +176,13 @@ pkg_fragment_delete(pkgconf_list_t *list, pkg_fragment_t *node)
} }
void void
pkg_fragment_free(pkgconf_list_t *list) pkgconf_fragment_free(pkgconf_list_t *list)
{ {
pkgconf_node_t *node, *next; pkgconf_node_t *node, *next;
PKGCONF_FOREACH_LIST_ENTRY_SAFE(list->head, next, node) PKGCONF_FOREACH_LIST_ENTRY_SAFE(list->head, next, node)
{ {
pkg_fragment_t *frag = node->data; pkgconf_fragment_t *frag = node->data;
free(frag->data); free(frag->data);
free(frag); free(frag);
@ -190,7 +190,7 @@ pkg_fragment_free(pkgconf_list_t *list)
} }
void void
pkg_fragment_parse(pkgconf_list_t *list, pkgconf_list_t *vars, const char *value, unsigned int flags) pkgconf_fragment_parse(pkgconf_list_t *list, pkgconf_list_t *vars, const char *value, unsigned int flags)
{ {
int i, argc; int i, argc;
char **argv; char **argv;
@ -199,7 +199,7 @@ pkg_fragment_parse(pkgconf_list_t *list, pkgconf_list_t *vars, const char *value
pkg_argv_split(repstr, &argc, &argv); pkg_argv_split(repstr, &argc, &argv);
for (i = 0; i < argc; i++) for (i = 0; i < argc; i++)
pkg_fragment_add(list, argv[i], flags); pkgconf_fragment_add(list, argv[i], flags);
pkg_argv_free(argv); pkg_argv_free(argv);
free(repstr); free(repstr);

View File

@ -38,7 +38,7 @@ typedef enum {
typedef struct pkg_ pkg_t; typedef struct pkg_ pkg_t;
typedef struct pkgconf_dependency_ pkgconf_dependency_t; typedef struct pkgconf_dependency_ pkgconf_dependency_t;
typedef struct pkgconf_tuple_ pkgconf_tuple_t; typedef struct pkgconf_tuple_ pkgconf_tuple_t;
typedef struct pkg_fragment_ pkg_fragment_t; typedef struct pkgconf_fragment_ pkgconf_fragment_t;
#define PKGCONF_FOREACH_LIST_ENTRY(head, value) \ #define PKGCONF_FOREACH_LIST_ENTRY(head, value) \
for ((value) = (head); (value) != NULL; (value) = (value)->next) for ((value) = (head); (value) != NULL; (value) = (value)->next)
@ -52,7 +52,7 @@ typedef struct pkg_fragment_ pkg_fragment_t;
#define PKG_MIN(a,b) (((a) < (b)) ? (a) : (b)) #define PKG_MIN(a,b) (((a) < (b)) ? (a) : (b))
#define PKG_MAX(a,b) (((a) > (b)) ? (a) : (b)) #define PKG_MAX(a,b) (((a) > (b)) ? (a) : (b))
struct pkg_fragment_ { struct pkgconf_fragment_ {
pkgconf_node_t iter; pkgconf_node_t iter;
char type; char type;
@ -159,11 +159,11 @@ int pkg_argv_split(const char *src, int *argc, char ***argv);
void pkg_argv_free(char **argv); void pkg_argv_free(char **argv);
/* fragment.c */ /* fragment.c */
void pkg_fragment_parse(pkgconf_list_t *list, pkgconf_list_t *vars, const char *value, unsigned int flags); void pkgconf_fragment_parse(pkgconf_list_t *list, pkgconf_list_t *vars, const char *value, unsigned int flags);
void pkg_fragment_add(pkgconf_list_t *list, const char *string, unsigned int flags); void pkgconf_fragment_add(pkgconf_list_t *list, const char *string, unsigned int flags);
void pkg_fragment_copy(pkgconf_list_t *list, pkg_fragment_t *base, unsigned int flags, bool is_private); void pkgconf_fragment_copy(pkgconf_list_t *list, pkgconf_fragment_t *base, unsigned int flags, bool is_private);
void pkg_fragment_delete(pkgconf_list_t *list, pkg_fragment_t *node); void pkgconf_fragment_delete(pkgconf_list_t *list, pkgconf_fragment_t *node);
void pkg_fragment_free(pkgconf_list_t *list); void pkgconf_fragment_free(pkgconf_list_t *list);
/* fileio.c */ /* fileio.c */
char *pkg_fgetline(char *line, size_t size, FILE *stream); char *pkg_fgetline(char *line, size_t size, FILE *stream);

View File

@ -249,13 +249,13 @@ pkg_new_from_file(const char *filename, FILE *f, unsigned int flags)
else if (!strcmp(key, "Version")) else if (!strcmp(key, "Version"))
pkg->version = pkgconf_tuple_parse(&pkg->vars, value); pkg->version = pkgconf_tuple_parse(&pkg->vars, value);
else if (!strcasecmp(key, "CFLAGS")) else if (!strcasecmp(key, "CFLAGS"))
pkg_fragment_parse(&pkg->cflags, &pkg->vars, value, flags); pkgconf_fragment_parse(&pkg->cflags, &pkg->vars, value, flags);
else if (!strcasecmp(key, "CFLAGS.private")) else if (!strcasecmp(key, "CFLAGS.private"))
pkg_fragment_parse(&pkg->cflags_private, &pkg->vars, value, flags); pkgconf_fragment_parse(&pkg->cflags_private, &pkg->vars, value, flags);
else if (!strcasecmp(key, "LIBS")) else if (!strcasecmp(key, "LIBS"))
pkg_fragment_parse(&pkg->libs, &pkg->vars, value, flags); pkgconf_fragment_parse(&pkg->libs, &pkg->vars, value, flags);
else if (!strcasecmp(key, "LIBS.private")) else if (!strcasecmp(key, "LIBS.private"))
pkg_fragment_parse(&pkg->libs_private, &pkg->vars, value, flags); pkgconf_fragment_parse(&pkg->libs_private, &pkg->vars, value, flags);
else if (!strcmp(key, "Requires")) else if (!strcmp(key, "Requires"))
pkgconf_dependency_parse(pkg, &pkg->requires, value); pkgconf_dependency_parse(pkg, &pkg->requires, value);
else if (!strcmp(key, "Requires.private")) else if (!strcmp(key, "Requires.private"))
@ -287,10 +287,10 @@ pkg_free(pkg_t *pkg)
pkgconf_dependency_free(&pkg->requires_private); pkgconf_dependency_free(&pkg->requires_private);
pkgconf_dependency_free(&pkg->conflicts); pkgconf_dependency_free(&pkg->conflicts);
pkg_fragment_free(&pkg->cflags); pkgconf_fragment_free(&pkg->cflags);
pkg_fragment_free(&pkg->cflags_private); pkgconf_fragment_free(&pkg->cflags_private);
pkg_fragment_free(&pkg->libs); pkgconf_fragment_free(&pkg->libs);
pkg_fragment_free(&pkg->libs_private); pkgconf_fragment_free(&pkg->libs_private);
pkgconf_tuple_free(&pkg->vars); pkgconf_tuple_free(&pkg->vars);
@ -988,8 +988,8 @@ pkg_cflags_collect(pkg_t *pkg, void *data, unsigned int flags)
PKGCONF_FOREACH_LIST_ENTRY(pkg->cflags.head, node) PKGCONF_FOREACH_LIST_ENTRY(pkg->cflags.head, node)
{ {
pkg_fragment_t *frag = node->data; pkgconf_fragment_t *frag = node->data;
pkg_fragment_copy(list, frag, flags, false); pkgconf_fragment_copy(list, frag, flags, false);
} }
} }
@ -1002,9 +1002,9 @@ pkg_cflags_private_collect(pkg_t *pkg, void *data, unsigned int flags)
PKGCONF_FOREACH_LIST_ENTRY(pkg->cflags_private.head, node) PKGCONF_FOREACH_LIST_ENTRY(pkg->cflags_private.head, node)
{ {
pkg_fragment_t *frag = node->data; pkgconf_fragment_t *frag = node->data;
pkg_fragment_copy(list, frag, flags, true); pkgconf_fragment_copy(list, frag, flags, true);
} }
} }
@ -1015,13 +1015,13 @@ pkg_cflags(pkg_t *root, pkgconf_list_t *list, int maxdepth, unsigned int flags)
eflag = pkg_traverse(root, pkg_cflags_collect, list, maxdepth, flags); eflag = pkg_traverse(root, pkg_cflags_collect, list, maxdepth, flags);
if (eflag != PKG_ERRF_OK) if (eflag != PKG_ERRF_OK)
pkg_fragment_free(list); pkgconf_fragment_free(list);
if (flags & PKGF_MERGE_PRIVATE_FRAGMENTS) if (flags & PKGF_MERGE_PRIVATE_FRAGMENTS)
{ {
eflag = pkg_traverse(root, pkg_cflags_private_collect, list, maxdepth, flags); eflag = pkg_traverse(root, pkg_cflags_private_collect, list, maxdepth, flags);
if (eflag != PKG_ERRF_OK) if (eflag != PKG_ERRF_OK)
pkg_fragment_free(list); pkgconf_fragment_free(list);
} }
return eflag; return eflag;
@ -1036,16 +1036,16 @@ pkg_libs_collect(pkg_t *pkg, void *data, unsigned int flags)
PKGCONF_FOREACH_LIST_ENTRY(pkg->libs.head, node) PKGCONF_FOREACH_LIST_ENTRY(pkg->libs.head, node)
{ {
pkg_fragment_t *frag = node->data; pkgconf_fragment_t *frag = node->data;
pkg_fragment_copy(list, frag, flags, (flags & PKGF_ITER_PKG_IS_PRIVATE) != 0); pkgconf_fragment_copy(list, frag, flags, (flags & PKGF_ITER_PKG_IS_PRIVATE) != 0);
} }
if (flags & PKGF_MERGE_PRIVATE_FRAGMENTS) if (flags & PKGF_MERGE_PRIVATE_FRAGMENTS)
{ {
PKGCONF_FOREACH_LIST_ENTRY(pkg->libs_private.head, node) PKGCONF_FOREACH_LIST_ENTRY(pkg->libs_private.head, node)
{ {
pkg_fragment_t *frag = node->data; pkgconf_fragment_t *frag = node->data;
pkg_fragment_copy(list, frag, flags, true); pkgconf_fragment_copy(list, frag, flags, true);
} }
} }
} }
@ -1059,7 +1059,7 @@ pkg_libs(pkg_t *root, pkgconf_list_t *list, int maxdepth, unsigned int flags)
if (eflag != PKG_ERRF_OK) if (eflag != PKG_ERRF_OK)
{ {
pkg_fragment_free(list); pkgconf_fragment_free(list);
return eflag; return eflag;
} }

12
main.c
View File

@ -59,7 +59,7 @@ static char *sysroot_dir = NULL;
FILE *error_msgout = NULL; FILE *error_msgout = NULL;
static bool static bool
fragment_has_system_dir(pkg_fragment_t *frag) fragment_has_system_dir(pkgconf_fragment_t *frag)
{ {
int check_flags = 0; int check_flags = 0;
char *check_paths = NULL; char *check_paths = NULL;
@ -95,7 +95,7 @@ fragment_has_system_dir(pkg_fragment_t *frag)
} }
static void static void
print_fragment(pkg_fragment_t *frag) print_fragment(pkgconf_fragment_t *frag)
{ {
if (fragment_has_system_dir(frag)) if (fragment_has_system_dir(frag))
return; return;
@ -131,7 +131,7 @@ print_cflags(pkgconf_list_t *list)
PKGCONF_FOREACH_LIST_ENTRY(list->head, node) PKGCONF_FOREACH_LIST_ENTRY(list->head, node)
{ {
pkg_fragment_t *frag = node->data; pkgconf_fragment_t *frag = node->data;
int got_flags = 0; int got_flags = 0;
if (frag->type == 'I') if (frag->type == 'I')
@ -153,7 +153,7 @@ print_libs(pkgconf_list_t *list)
PKGCONF_FOREACH_LIST_ENTRY(list->head, node) PKGCONF_FOREACH_LIST_ENTRY(list->head, node)
{ {
pkg_fragment_t *frag = node->data; pkgconf_fragment_t *frag = node->data;
int got_flags = 0; int got_flags = 0;
switch (frag->type) switch (frag->type)
@ -363,7 +363,7 @@ apply_cflags(pkg_t *world, void *list_head, int maxdepth, unsigned int flags)
print_cflags(list); print_cflags(list);
pkg_fragment_free(list); pkgconf_fragment_free(list);
return true; return true;
} }
@ -383,7 +383,7 @@ apply_libs(pkg_t *world, void *list_head, int maxdepth, unsigned int flags)
print_libs(list); print_libs(list);
pkg_fragment_free(list); pkgconf_fragment_free(list);
return true; return true;
} }