forked from ariadne/pkgconf
libpkgconf: fragment: make pkgconf_fragment_filter() accept userdata (closes #106)
parent
bd386d20ac
commit
4f94090fe4
|
@ -44,6 +44,7 @@ which is composable, mergeable and reorderable.
|
||||||
:param pkgconf_list_t* dest: The destination list.
|
:param pkgconf_list_t* dest: The destination list.
|
||||||
:param pkgconf_list_t* src: The source list.
|
:param pkgconf_list_t* src: The source list.
|
||||||
:param pkgconf_fragment_filter_func_t filter_func: The filter function to use.
|
:param pkgconf_fragment_filter_func_t filter_func: The filter function to use.
|
||||||
|
:param void* data: Optional data to pass to the filter function.
|
||||||
:param uint flags: A set of dependency resolver flags.
|
:param uint flags: A set of dependency resolver flags.
|
||||||
:return: nothing
|
:return: nothing
|
||||||
|
|
||||||
|
|
|
@ -355,11 +355,12 @@ pkgconf_fragment_copy(pkgconf_list_t *list, const pkgconf_fragment_t *base, unsi
|
||||||
* :param pkgconf_list_t* dest: The destination list.
|
* :param pkgconf_list_t* dest: The destination list.
|
||||||
* :param pkgconf_list_t* src: The source list.
|
* :param pkgconf_list_t* src: The source list.
|
||||||
* :param pkgconf_fragment_filter_func_t filter_func: The filter function to use.
|
* :param pkgconf_fragment_filter_func_t filter_func: The filter function to use.
|
||||||
|
* :param void* data: Optional data to pass to the filter function.
|
||||||
* :param uint flags: A set of dependency resolver flags.
|
* :param uint flags: A set of dependency resolver flags.
|
||||||
* :return: nothing
|
* :return: nothing
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
pkgconf_fragment_filter(const pkgconf_client_t *client, pkgconf_list_t *dest, pkgconf_list_t *src, pkgconf_fragment_filter_func_t filter_func, unsigned int flags)
|
pkgconf_fragment_filter(const pkgconf_client_t *client, pkgconf_list_t *dest, pkgconf_list_t *src, pkgconf_fragment_filter_func_t filter_func, void *data, unsigned int flags)
|
||||||
{
|
{
|
||||||
pkgconf_node_t *node;
|
pkgconf_node_t *node;
|
||||||
|
|
||||||
|
@ -367,7 +368,7 @@ pkgconf_fragment_filter(const pkgconf_client_t *client, pkgconf_list_t *dest, pk
|
||||||
{
|
{
|
||||||
pkgconf_fragment_t *frag = node->data;
|
pkgconf_fragment_t *frag = node->data;
|
||||||
|
|
||||||
if (filter_func(client, frag, flags))
|
if (filter_func(client, frag, data, flags))
|
||||||
pkgconf_fragment_copy(dest, frag, flags, true);
|
pkgconf_fragment_copy(dest, frag, flags, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,13 +227,13 @@ int pkgconf_argv_split(const char *src, int *argc, char ***argv);
|
||||||
void pkgconf_argv_free(char **argv);
|
void pkgconf_argv_free(char **argv);
|
||||||
|
|
||||||
/* fragment.c */
|
/* fragment.c */
|
||||||
typedef bool (*pkgconf_fragment_filter_func_t)(const pkgconf_client_t *client, const pkgconf_fragment_t *frag, unsigned int flags);
|
typedef bool (*pkgconf_fragment_filter_func_t)(const pkgconf_client_t *client, const pkgconf_fragment_t *frag, void *data, unsigned int flags);
|
||||||
void pkgconf_fragment_parse(const pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_list_t *vars, const char *value);
|
void pkgconf_fragment_parse(const pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_list_t *vars, const char *value);
|
||||||
void pkgconf_fragment_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *string);
|
void pkgconf_fragment_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *string);
|
||||||
void pkgconf_fragment_copy(pkgconf_list_t *list, const pkgconf_fragment_t *base, unsigned int flags, bool is_private);
|
void pkgconf_fragment_copy(pkgconf_list_t *list, const pkgconf_fragment_t *base, unsigned int flags, bool is_private);
|
||||||
void pkgconf_fragment_delete(pkgconf_list_t *list, pkgconf_fragment_t *node);
|
void pkgconf_fragment_delete(pkgconf_list_t *list, pkgconf_fragment_t *node);
|
||||||
void pkgconf_fragment_free(pkgconf_list_t *list);
|
void pkgconf_fragment_free(pkgconf_list_t *list);
|
||||||
void pkgconf_fragment_filter(const pkgconf_client_t *client, pkgconf_list_t *dest, pkgconf_list_t *src, pkgconf_fragment_filter_func_t filter_func, unsigned int flags);
|
void pkgconf_fragment_filter(const pkgconf_client_t *client, pkgconf_list_t *dest, pkgconf_list_t *src, pkgconf_fragment_filter_func_t filter_func, void *data, unsigned int flags);
|
||||||
size_t pkgconf_fragment_render_len(const pkgconf_list_t *list);
|
size_t pkgconf_fragment_render_len(const pkgconf_list_t *list);
|
||||||
void pkgconf_fragment_render_buf(const pkgconf_list_t *list, char *buf, size_t len);
|
void pkgconf_fragment_render_buf(const pkgconf_list_t *list, char *buf, size_t len);
|
||||||
char *pkgconf_fragment_render(const pkgconf_list_t *list);
|
char *pkgconf_fragment_render(const pkgconf_list_t *list);
|
||||||
|
|
10
main.c
10
main.c
|
@ -101,10 +101,11 @@ print_package_entry(const pkgconf_pkg_t *entry, void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
filter_cflags(const pkgconf_client_t *client, const pkgconf_fragment_t *frag, unsigned int flags)
|
filter_cflags(const pkgconf_client_t *client, const pkgconf_fragment_t *frag, void *data, unsigned int flags)
|
||||||
{
|
{
|
||||||
int got_flags = 0;
|
int got_flags = 0;
|
||||||
(void) client;
|
(void) client;
|
||||||
|
(void) data;
|
||||||
(void) flags;
|
(void) flags;
|
||||||
|
|
||||||
if (pkgconf_fragment_has_system_dir(client, frag))
|
if (pkgconf_fragment_has_system_dir(client, frag))
|
||||||
|
@ -119,10 +120,11 @@ filter_cflags(const pkgconf_client_t *client, const pkgconf_fragment_t *frag, un
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
filter_libs(const pkgconf_client_t *client, const pkgconf_fragment_t *frag, unsigned int flags)
|
filter_libs(const pkgconf_client_t *client, const pkgconf_fragment_t *frag, void *data, unsigned int flags)
|
||||||
{
|
{
|
||||||
int got_flags = 0;
|
int got_flags = 0;
|
||||||
(void) client;
|
(void) client;
|
||||||
|
(void) data;
|
||||||
(void) flags;
|
(void) flags;
|
||||||
|
|
||||||
if (pkgconf_fragment_has_system_dir(client, frag))
|
if (pkgconf_fragment_has_system_dir(client, frag))
|
||||||
|
@ -383,7 +385,7 @@ apply_cflags(pkgconf_client_t *client, pkgconf_pkg_t *world, void *unused, int m
|
||||||
if (eflag != PKGCONF_PKG_ERRF_OK)
|
if (eflag != PKGCONF_PKG_ERRF_OK)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
pkgconf_fragment_filter(client, &filtered_list, &unfiltered_list, filter_cflags, flags);
|
pkgconf_fragment_filter(client, &filtered_list, &unfiltered_list, filter_cflags, NULL, flags);
|
||||||
|
|
||||||
if (filtered_list.head == NULL)
|
if (filtered_list.head == NULL)
|
||||||
return true;
|
return true;
|
||||||
|
@ -411,7 +413,7 @@ apply_libs(pkgconf_client_t *client, pkgconf_pkg_t *world, void *unused, int max
|
||||||
if (eflag != PKGCONF_PKG_ERRF_OK)
|
if (eflag != PKGCONF_PKG_ERRF_OK)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
pkgconf_fragment_filter(client, &filtered_list, &unfiltered_list, filter_libs, flags);
|
pkgconf_fragment_filter(client, &filtered_list, &unfiltered_list, filter_libs, NULL, flags);
|
||||||
|
|
||||||
if (filtered_list.head == NULL)
|
if (filtered_list.head == NULL)
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue