2011-07-25 02:03:17 +00:00
|
|
|
/*
|
2015-09-06 16:37:20 +00:00
|
|
|
* libpkgconf.h
|
|
|
|
* Global include file for everything in libpkgconf.
|
2011-07-25 02:03:17 +00:00
|
|
|
*
|
2015-09-06 16:37:20 +00:00
|
|
|
* Copyright (c) 2011, 2015 pkgconf authors (see AUTHORS).
|
2011-07-25 02:03:17 +00:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
2012-07-20 19:29:58 +00:00
|
|
|
* This software is provided 'as is' and without any warranty, express or
|
|
|
|
* implied. In no event shall the authors be liable for any damages arising
|
|
|
|
* from the use of this software.
|
2011-07-25 02:03:17 +00:00
|
|
|
*/
|
|
|
|
|
2015-09-06 16:37:20 +00:00
|
|
|
#ifndef LIBPKGCONF__LIBPKGCONF_H
|
|
|
|
#define LIBPKGCONF__LIBPKGCONF_H
|
2011-07-25 02:03:17 +00:00
|
|
|
|
2015-09-06 14:35:08 +00:00
|
|
|
#include <libpkgconf/config.h>
|
|
|
|
#include <libpkgconf/stdinc.h>
|
|
|
|
#include <libpkgconf/iter.h>
|
|
|
|
#include <libpkgconf/bsdstubs.h>
|
2011-07-25 02:03:17 +00:00
|
|
|
|
2015-09-06 16:29:56 +00:00
|
|
|
#define PKGCONF_BUFSIZE (65535)
|
2011-07-25 02:03:17 +00:00
|
|
|
|
|
|
|
typedef enum {
|
2015-09-06 16:34:09 +00:00
|
|
|
PKGCONF_CMP_ANY = 0,
|
|
|
|
PKGCONF_CMP_LESS_THAN,
|
|
|
|
PKGCONF_CMP_GREATER_THAN,
|
|
|
|
PKGCONF_CMP_LESS_THAN_EQUAL,
|
|
|
|
PKGCONF_CMP_GREATER_THAN_EQUAL,
|
|
|
|
PKGCONF_CMP_EQUAL,
|
|
|
|
PKGCONF_CMP_NOT_EQUAL,
|
|
|
|
PKGCONF_CMP_ALWAYS_MATCH,
|
|
|
|
PKGCONF_CMP_SIZE
|
2015-09-06 15:57:26 +00:00
|
|
|
} pkgconf_pkg_comparator_t;
|
2011-07-25 02:03:17 +00:00
|
|
|
|
2015-09-06 16:20:48 +00:00
|
|
|
typedef struct pkgconf_pkg_ pkgconf_pkg_t;
|
2015-09-06 15:38:30 +00:00
|
|
|
typedef struct pkgconf_dependency_ pkgconf_dependency_t;
|
2015-09-06 15:41:40 +00:00
|
|
|
typedef struct pkgconf_tuple_ pkgconf_tuple_t;
|
2015-09-06 15:44:10 +00:00
|
|
|
typedef struct pkgconf_fragment_ pkgconf_fragment_t;
|
2011-07-25 02:03:17 +00:00
|
|
|
|
2015-09-06 15:31:21 +00:00
|
|
|
#define PKGCONF_FOREACH_LIST_ENTRY(head, value) \
|
2011-07-25 02:03:17 +00:00
|
|
|
for ((value) = (head); (value) != NULL; (value) = (value)->next)
|
|
|
|
|
2015-09-06 15:31:21 +00:00
|
|
|
#define PKGCONF_FOREACH_LIST_ENTRY_SAFE(head, nextiter, value) \
|
2012-05-07 01:36:59 +00:00
|
|
|
for ((value) = (head), (nextiter) = (head) != NULL ? (head)->next : NULL; (value) != NULL; (value) = (nextiter), (nextiter) = (nextiter) != NULL ? (nextiter)->next : NULL)
|
2012-05-07 01:15:45 +00:00
|
|
|
|
2015-09-06 15:31:21 +00:00
|
|
|
#define PKGCONF_FOREACH_LIST_ENTRY_REVERSE(tail, value) \
|
2015-05-22 04:06:38 +00:00
|
|
|
for ((value) = (tail); (value) != NULL; (value) = (value)->prev)
|
|
|
|
|
2015-09-06 15:44:10 +00:00
|
|
|
struct pkgconf_fragment_ {
|
2015-09-06 15:31:21 +00:00
|
|
|
pkgconf_node_t iter;
|
2012-05-03 19:25:33 +00:00
|
|
|
|
|
|
|
char type;
|
|
|
|
char *data;
|
|
|
|
};
|
|
|
|
|
2015-09-06 15:38:30 +00:00
|
|
|
struct pkgconf_dependency_ {
|
2015-09-06 15:31:21 +00:00
|
|
|
pkgconf_node_t iter;
|
2011-07-25 02:03:17 +00:00
|
|
|
|
2011-07-25 04:20:22 +00:00
|
|
|
char *package;
|
2015-09-06 15:57:26 +00:00
|
|
|
pkgconf_pkg_comparator_t compare;
|
2011-07-25 02:03:17 +00:00
|
|
|
char *version;
|
2015-09-06 16:20:48 +00:00
|
|
|
pkgconf_pkg_t *parent;
|
2011-07-25 02:03:17 +00:00
|
|
|
};
|
|
|
|
|
2015-09-06 15:41:40 +00:00
|
|
|
struct pkgconf_tuple_ {
|
2015-09-06 15:31:21 +00:00
|
|
|
pkgconf_node_t iter;
|
2011-07-25 02:03:17 +00:00
|
|
|
|
|
|
|
char *key;
|
|
|
|
char *value;
|
|
|
|
};
|
|
|
|
|
2015-09-06 16:37:20 +00:00
|
|
|
#define PKGCONF_PKG_PROPF_NONE 0x0
|
|
|
|
#define PKGCONF_PKG_PROPF_VIRTUAL 0x1
|
|
|
|
#define PKGCONF_PKG_PROPF_CACHED 0x2
|
|
|
|
#define PKGCONF_PKG_PROPF_SEEN 0x4
|
|
|
|
#define PKGCONF_PKG_PROPF_UNINSTALLED 0x8
|
2012-05-07 01:38:48 +00:00
|
|
|
|
2015-09-06 16:20:48 +00:00
|
|
|
struct pkgconf_pkg_ {
|
2015-09-06 15:31:21 +00:00
|
|
|
pkgconf_node_t cache_iter;
|
2013-02-24 14:14:23 +00:00
|
|
|
|
2013-02-26 05:29:57 +00:00
|
|
|
int refcount;
|
2011-07-27 01:37:01 +00:00
|
|
|
char *id;
|
2011-07-25 02:03:17 +00:00
|
|
|
char *filename;
|
|
|
|
char *realname;
|
|
|
|
char *version;
|
|
|
|
char *description;
|
|
|
|
char *url;
|
|
|
|
char *pc_filedir;
|
2012-05-03 19:25:59 +00:00
|
|
|
|
2015-09-06 15:31:21 +00:00
|
|
|
pkgconf_list_t libs;
|
|
|
|
pkgconf_list_t libs_private;
|
|
|
|
pkgconf_list_t cflags;
|
|
|
|
pkgconf_list_t cflags_private;
|
2011-07-25 02:03:17 +00:00
|
|
|
|
2015-09-06 15:31:21 +00:00
|
|
|
pkgconf_list_t requires;
|
|
|
|
pkgconf_list_t requires_private;
|
|
|
|
pkgconf_list_t conflicts;
|
2013-03-01 16:45:55 +00:00
|
|
|
|
2015-09-06 15:31:21 +00:00
|
|
|
pkgconf_list_t vars;
|
2012-05-06 04:00:20 +00:00
|
|
|
|
2012-05-07 01:38:48 +00:00
|
|
|
unsigned int flags;
|
2011-07-25 02:03:17 +00:00
|
|
|
};
|
|
|
|
|
2015-12-07 10:04:31 +00:00
|
|
|
#define PKGCONF_IS_MODULE_SEPARATOR(c) ((c) == ',' || isspace ((unsigned int)(c)))
|
2015-09-06 16:39:55 +00:00
|
|
|
#define PKGCONF_IS_OPERATOR_CHAR(c) ((c) == '<' || (c) == '>' || (c) == '!' || (c) == '=')
|
2012-05-06 02:26:15 +00:00
|
|
|
|
2015-09-06 16:45:00 +00:00
|
|
|
#define PKGCONF_PKG_PKGF_NONE 0x000
|
|
|
|
#define PKGCONF_PKG_PKGF_SEARCH_PRIVATE 0x001
|
|
|
|
#define PKGCONF_PKG_PKGF_ENV_ONLY 0x002
|
|
|
|
#define PKGCONF_PKG_PKGF_NO_UNINSTALLED 0x004
|
|
|
|
#define PKGCONF_PKG_PKGF_SKIP_ROOT_VIRTUAL 0x008
|
|
|
|
#define PKGCONF_PKG_PKGF_MERGE_PRIVATE_FRAGMENTS 0x010
|
|
|
|
#define PKGCONF_PKG_PKGF_SKIP_CONFLICTS 0x020
|
|
|
|
#define PKGCONF_PKG_PKGF_NO_CACHE 0x040
|
|
|
|
#define PKGCONF_PKG_PKGF_MUNGE_SYSROOT_PREFIX 0x080
|
|
|
|
#define PKGCONF_PKG_PKGF_SKIP_ERRORS 0x100
|
|
|
|
#define PKGCONF_PKG_PKGF_ITER_PKG_IS_PRIVATE 0x200
|
|
|
|
|
|
|
|
#define PKGCONF_PKG_ERRF_OK 0x0
|
|
|
|
#define PKGCONF_PKG_ERRF_PACKAGE_NOT_FOUND 0x1
|
|
|
|
#define PKGCONF_PKG_ERRF_PACKAGE_VER_MISMATCH 0x2
|
|
|
|
#define PKGCONF_PKG_ERRF_PACKAGE_CONFLICT 0x4
|
|
|
|
#define PKGCONF_PKG_ERRF_DEPGRAPH_BREAK 0x8
|
2012-05-03 17:42:04 +00:00
|
|
|
|
2015-09-06 16:20:48 +00:00
|
|
|
typedef void (*pkgconf_pkg_iteration_func_t)(const pkgconf_pkg_t *pkg);
|
|
|
|
typedef void (*pkgconf_pkg_traverse_func_t)(pkgconf_pkg_t *pkg, void *data, unsigned int flags);
|
|
|
|
typedef bool (*pkgconf_queue_apply_func_t)(pkgconf_pkg_t *world, void *data, int maxdepth, unsigned int flags);
|
2015-09-06 17:01:12 +00:00
|
|
|
typedef bool (*pkgconf_error_handler_func_t)(const char *msg);
|
2012-05-12 00:56:38 +00:00
|
|
|
|
2012-05-07 01:30:50 +00:00
|
|
|
/* pkg.c */
|
2015-09-06 17:01:12 +00:00
|
|
|
#if defined(__GNUC__) || defined(__INTEL_COMPILER)
|
|
|
|
#define PRINTFLIKE(fmtarg, firstvararg) \
|
|
|
|
__attribute__((__format__ (__printf__, fmtarg, firstvararg)))
|
|
|
|
#define DEPRECATED \
|
|
|
|
__attribute__((deprecated))
|
|
|
|
#else
|
|
|
|
#define PRINTFLIKE(fmtarg, firstvararg)
|
|
|
|
#define DEPRECATED
|
|
|
|
#endif /* defined(__INTEL_COMPILER) || defined(__GNUC__) */
|
|
|
|
|
|
|
|
bool pkgconf_error(const char *format, ...) PRINTFLIKE(1, 2);
|
|
|
|
bool pkgconf_default_error_handler(const char *msg);
|
|
|
|
void pkgconf_set_error_handler(pkgconf_error_handler_func_t func);
|
|
|
|
|
2015-09-06 16:20:48 +00:00
|
|
|
pkgconf_pkg_t *pkgconf_pkg_ref(pkgconf_pkg_t *pkg);
|
|
|
|
void pkgconf_pkg_unref(pkgconf_pkg_t *pkg);
|
|
|
|
void pkgconf_pkg_free(pkgconf_pkg_t *pkg);
|
|
|
|
pkgconf_pkg_t *pkgconf_pkg_find(const char *name, unsigned int flags);
|
|
|
|
unsigned int pkgconf_pkg_traverse(pkgconf_pkg_t *root, pkgconf_pkg_traverse_func_t func, void *data, int maxdepth, unsigned int flags);
|
|
|
|
unsigned int pkgconf_pkg_verify_graph(pkgconf_pkg_t *root, int depth, unsigned int flags);
|
|
|
|
pkgconf_pkg_t *pkgconf_pkg_verify_dependency(pkgconf_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags);
|
2015-09-06 15:57:26 +00:00
|
|
|
const char *pkgconf_pkg_get_comparator(pkgconf_dependency_t *pkgdep);
|
2015-09-06 16:20:48 +00:00
|
|
|
int pkgconf_pkg_cflags(pkgconf_pkg_t *root, pkgconf_list_t *list, int maxdepth, unsigned int flags);
|
|
|
|
int pkgconf_pkg_libs(pkgconf_pkg_t *root, pkgconf_list_t *list, int maxdepth, unsigned int flags);
|
2015-09-06 15:57:26 +00:00
|
|
|
pkgconf_pkg_comparator_t pkgconf_pkg_comparator_lookup_by_name(const char *name);
|
2011-07-25 02:03:17 +00:00
|
|
|
|
2015-09-06 16:00:46 +00:00
|
|
|
int pkgconf_compare_version(const char *a, const char *b);
|
2015-09-06 16:20:48 +00:00
|
|
|
void pkgconf_scan_all(pkgconf_pkg_iteration_func_t func);
|
2015-09-06 16:00:46 +00:00
|
|
|
|
2011-07-25 02:03:17 +00:00
|
|
|
/* parse.c */
|
2015-09-06 16:20:48 +00:00
|
|
|
pkgconf_pkg_t *pkgconf_pkg_new_from_file(const char *path, FILE *f, unsigned int flags);
|
2015-09-06 15:38:30 +00:00
|
|
|
void pkgconf_dependency_parse_str(pkgconf_list_t *deplist_head, const char *depends);
|
2015-09-06 16:20:48 +00:00
|
|
|
void pkgconf_dependency_parse(pkgconf_pkg_t *pkg, pkgconf_list_t *deplist_head, const char *depends);
|
2015-09-06 15:38:30 +00:00
|
|
|
void pkgconf_dependency_append(pkgconf_list_t *list, pkgconf_dependency_t *tail);
|
|
|
|
void pkgconf_dependency_free(pkgconf_list_t *list);
|
2011-07-25 02:03:17 +00:00
|
|
|
|
2012-05-03 18:59:14 +00:00
|
|
|
/* argvsplit.c */
|
2015-09-06 15:48:24 +00:00
|
|
|
int pkgconf_argv_split(const char *src, int *argc, char ***argv);
|
|
|
|
void pkgconf_argv_free(char **argv);
|
2012-05-03 18:59:14 +00:00
|
|
|
|
2012-05-03 20:22:19 +00:00
|
|
|
/* fragment.c */
|
2015-09-06 15:44:10 +00:00
|
|
|
void pkgconf_fragment_parse(pkgconf_list_t *list, pkgconf_list_t *vars, const char *value, unsigned int flags);
|
|
|
|
void pkgconf_fragment_add(pkgconf_list_t *list, const char *string, unsigned int flags);
|
|
|
|
void pkgconf_fragment_copy(pkgconf_list_t *list, 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_free(pkgconf_list_t *list);
|
2012-05-03 20:22:19 +00:00
|
|
|
|
2012-05-04 03:21:51 +00:00
|
|
|
/* fileio.c */
|
2015-09-06 15:48:24 +00:00
|
|
|
char *pkgconf_fgetline(char *line, size_t size, FILE *stream);
|
2012-05-04 03:21:51 +00:00
|
|
|
|
2012-05-07 01:06:48 +00:00
|
|
|
/* tuple.c */
|
2015-12-07 23:02:14 +00:00
|
|
|
pkgconf_tuple_t *pkgconf_tuple_add(pkgconf_list_t *parent, const char *key, const char *value, bool parse);
|
2015-09-06 15:41:40 +00:00
|
|
|
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);
|
2012-05-07 01:06:48 +00:00
|
|
|
|
2012-07-29 08:49:56 +00:00
|
|
|
/* queue.c */
|
2015-09-06 15:51:34 +00:00
|
|
|
void pkgconf_queue_push(pkgconf_list_t *list, const char *package);
|
2015-09-06 16:20:48 +00:00
|
|
|
bool pkgconf_queue_compile(pkgconf_pkg_t *world, pkgconf_list_t *list);
|
2015-09-06 15:51:34 +00:00
|
|
|
void pkgconf_queue_free(pkgconf_list_t *list);
|
|
|
|
bool pkgconf_queue_apply(pkgconf_list_t *list, pkgconf_queue_apply_func_t func, int maxdepth, unsigned int flags, void *data);
|
|
|
|
bool pkgconf_queue_validate(pkgconf_list_t *list, int maxdepth, unsigned int flags);
|
2012-07-29 08:49:56 +00:00
|
|
|
|
2013-02-25 23:36:09 +00:00
|
|
|
/* cache.c */
|
2015-09-06 16:20:48 +00:00
|
|
|
pkgconf_pkg_t *pkgconf_cache_lookup(const char *id);
|
|
|
|
void pkgconf_cache_add(pkgconf_pkg_t *pkg);
|
|
|
|
void pkgconf_cache_remove(pkgconf_pkg_t *pkg);
|
2015-09-06 15:50:23 +00:00
|
|
|
void pkgconf_cache_free(void);
|
2013-02-25 23:36:09 +00:00
|
|
|
|
2011-07-25 02:03:17 +00:00
|
|
|
#endif
|