2011-07-25 02:03:17 +00:00
|
|
|
/*
|
|
|
|
* pkg.h
|
|
|
|
* Global include file for everything.
|
|
|
|
*
|
2012-07-26 02:09:31 +00:00
|
|
|
* Copyright (c) 2011 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
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __PKG_H
|
|
|
|
#define __PKG_H
|
|
|
|
|
|
|
|
#include "config.h"
|
2012-05-11 18:47:20 +00:00
|
|
|
#include "stdinc.h"
|
2013-03-01 16:09:22 +00:00
|
|
|
#include "iter.h"
|
2011-07-25 02:03:17 +00:00
|
|
|
|
2012-07-21 19:38:13 +00:00
|
|
|
#define PKG_BUFSIZE (65535)
|
2011-07-25 02:03:17 +00:00
|
|
|
|
2013-02-24 13:45:20 +00:00
|
|
|
/* we are compatible with 0.28 of pkg-config */
|
|
|
|
#define PKG_PKGCONFIG_VERSION_EQUIV "0.28"
|
2012-05-06 02:51:25 +00:00
|
|
|
|
2011-07-25 02:03:17 +00:00
|
|
|
typedef enum {
|
|
|
|
PKG_ANY = 0,
|
|
|
|
PKG_LESS_THAN,
|
|
|
|
PKG_GREATER_THAN,
|
|
|
|
PKG_LESS_THAN_EQUAL,
|
|
|
|
PKG_GREATER_THAN_EQUAL,
|
|
|
|
PKG_EQUAL,
|
|
|
|
PKG_NOT_EQUAL,
|
2013-02-24 13:20:50 +00:00
|
|
|
PKG_ALWAYS_MATCH,
|
|
|
|
PKG_CMP_SIZE
|
2011-07-25 02:03:17 +00:00
|
|
|
} pkg_comparator_t;
|
|
|
|
|
|
|
|
typedef struct pkg_ pkg_t;
|
2012-05-07 03:50:15 +00:00
|
|
|
typedef struct pkg_dependency_ pkg_dependency_t;
|
|
|
|
typedef struct pkg_tuple_ pkg_tuple_t;
|
|
|
|
typedef struct pkg_fragment_ pkg_fragment_t;
|
2011-07-25 02:03:17 +00:00
|
|
|
|
2012-05-07 03:55:00 +00:00
|
|
|
#define PKG_FOREACH_LIST_ENTRY(head, value) \
|
2011-07-25 02:03:17 +00:00
|
|
|
for ((value) = (head); (value) != NULL; (value) = (value)->next)
|
|
|
|
|
2012-05-07 03:55:00 +00:00
|
|
|
#define PKG_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-05-22 04:06:38 +00:00
|
|
|
#define PKG_FOREACH_LIST_ENTRY_REVERSE(tail, value) \
|
|
|
|
for ((value) = (tail); (value) != NULL; (value) = (value)->prev)
|
|
|
|
|
2012-05-07 03:52:05 +00:00
|
|
|
#define PKG_MIN(a,b) (((a) < (b)) ? (a) : (b))
|
|
|
|
#define PKG_MAX(a,b) (((a) > (b)) ? (a) : (b))
|
2012-04-30 18:07:51 +00:00
|
|
|
|
2012-05-07 03:50:15 +00:00
|
|
|
struct pkg_fragment_ {
|
2013-03-01 17:10:43 +00:00
|
|
|
pkg_node_t iter;
|
2012-05-03 19:25:33 +00:00
|
|
|
|
|
|
|
char type;
|
|
|
|
char *data;
|
|
|
|
};
|
|
|
|
|
2012-05-07 03:50:15 +00:00
|
|
|
struct pkg_dependency_ {
|
2013-03-01 17:36:21 +00:00
|
|
|
pkg_node_t iter;
|
2011-07-25 02:03:17 +00:00
|
|
|
|
2011-07-25 04:20:22 +00:00
|
|
|
char *package;
|
2011-07-25 02:03:17 +00:00
|
|
|
pkg_comparator_t compare;
|
|
|
|
char *version;
|
|
|
|
pkg_t *parent;
|
|
|
|
};
|
|
|
|
|
2012-05-07 03:50:15 +00:00
|
|
|
struct pkg_tuple_ {
|
2013-03-01 16:45:55 +00:00
|
|
|
pkg_node_t iter;
|
2011-07-25 02:03:17 +00:00
|
|
|
|
|
|
|
char *key;
|
|
|
|
char *value;
|
|
|
|
};
|
|
|
|
|
2012-05-07 01:38:48 +00:00
|
|
|
#define PKG_PROPF_NONE 0x0
|
|
|
|
#define PKG_PROPF_VIRTUAL 0x1
|
2013-02-24 14:14:23 +00:00
|
|
|
#define PKG_PROPF_CACHED 0x2
|
2013-02-26 05:29:57 +00:00
|
|
|
#define PKG_PROPF_SEEN 0x4
|
2013-03-01 18:06:52 +00:00
|
|
|
#define PKG_PROPF_UNINSTALLED 0x8
|
2012-05-07 01:38:48 +00:00
|
|
|
|
2011-07-25 02:03:17 +00:00
|
|
|
struct pkg_ {
|
2013-03-01 16:14:20 +00:00
|
|
|
pkg_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
|
|
|
|
2013-03-01 17:10:43 +00:00
|
|
|
pkg_list_t libs;
|
|
|
|
pkg_list_t libs_private;
|
|
|
|
pkg_list_t cflags;
|
2013-08-14 05:36:43 +00:00
|
|
|
pkg_list_t cflags_private;
|
2011-07-25 02:03:17 +00:00
|
|
|
|
2013-03-01 17:36:21 +00:00
|
|
|
pkg_list_t requires;
|
|
|
|
pkg_list_t requires_private;
|
|
|
|
pkg_list_t conflicts;
|
2013-03-01 16:45:55 +00:00
|
|
|
|
|
|
|
pkg_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
|
|
|
};
|
|
|
|
|
2012-05-06 02:26:15 +00:00
|
|
|
#define PKG_MODULE_SEPARATOR(c) ((c) == ',' || isspace ((c)))
|
|
|
|
#define PKG_OPERATOR_CHAR(c) ((c) == '<' || (c) == '>' || (c) == '!' || (c) == '=')
|
|
|
|
|
2013-03-16 00:59:20 +00:00
|
|
|
#define PKGF_NONE 0x000
|
|
|
|
#define PKGF_SEARCH_PRIVATE 0x001
|
|
|
|
#define PKGF_ENV_ONLY 0x002
|
|
|
|
#define PKGF_NO_UNINSTALLED 0x004
|
|
|
|
#define PKGF_SKIP_ROOT_VIRTUAL 0x008
|
|
|
|
#define PKGF_MERGE_PRIVATE_FRAGMENTS 0x010
|
|
|
|
#define PKGF_SKIP_CONFLICTS 0x020
|
|
|
|
#define PKGF_NO_CACHE 0x040
|
|
|
|
#define PKGF_MUNGE_SYSROOT_PREFIX 0x080
|
|
|
|
#define PKGF_SKIP_ERRORS 0x100
|
2015-05-22 04:06:38 +00:00
|
|
|
#define PKGF_ITER_PKG_IS_PRIVATE 0x200
|
2012-05-02 21:44:58 +00:00
|
|
|
|
2012-05-03 17:42:04 +00:00
|
|
|
#define PKG_ERRF_OK 0x0
|
|
|
|
#define PKG_ERRF_PACKAGE_NOT_FOUND 0x1
|
|
|
|
#define PKG_ERRF_PACKAGE_VER_MISMATCH 0x2
|
2012-05-12 01:51:13 +00:00
|
|
|
#define PKG_ERRF_PACKAGE_CONFLICT 0x4
|
2012-07-29 10:36:21 +00:00
|
|
|
#define PKG_ERRF_DEPGRAPH_BREAK 0x8
|
2012-05-03 17:42:04 +00:00
|
|
|
|
2012-07-26 04:49:07 +00:00
|
|
|
typedef void (*pkg_iteration_func_t)(const pkg_t *pkg);
|
2012-05-12 00:58:34 +00:00
|
|
|
typedef void (*pkg_traverse_func_t)(pkg_t *pkg, void *data, unsigned int flags);
|
2012-08-12 10:32:31 +00:00
|
|
|
typedef bool (*pkg_queue_apply_func_t)(pkg_t *world, void *data, int maxdepth, unsigned int flags);
|
2012-05-12 00:56:38 +00:00
|
|
|
|
2012-05-07 01:30:50 +00:00
|
|
|
/* pkg.c */
|
2013-02-26 05:29:57 +00:00
|
|
|
pkg_t *pkg_ref(pkg_t *pkg);
|
|
|
|
void pkg_unref(pkg_t *pkg);
|
2012-05-07 01:30:50 +00:00
|
|
|
void pkg_free(pkg_t *pkg);
|
2012-05-02 23:14:53 +00:00
|
|
|
pkg_t *pkg_find(const char *name, unsigned int flags);
|
2012-07-26 04:49:07 +00:00
|
|
|
void pkg_scan_all(pkg_iteration_func_t func);
|
2012-05-12 00:56:38 +00:00
|
|
|
unsigned int pkg_traverse(pkg_t *root, pkg_traverse_func_t func, void *data, int maxdepth, unsigned int flags);
|
2012-05-07 02:42:15 +00:00
|
|
|
unsigned int pkg_verify_graph(pkg_t *root, int depth, unsigned int flags);
|
2011-07-26 16:56:59 +00:00
|
|
|
int pkg_compare_version(const char *a, const char *b);
|
2012-05-03 17:42:04 +00:00
|
|
|
pkg_t *pkg_verify_dependency(pkg_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags);
|
2011-07-27 00:59:46 +00:00
|
|
|
const char *pkg_get_comparator(pkg_dependency_t *pkgdep);
|
2013-03-01 17:10:43 +00:00
|
|
|
int pkg_cflags(pkg_t *root, pkg_list_t *list, int maxdepth, unsigned int flags);
|
|
|
|
int pkg_libs(pkg_t *root, pkg_list_t *list, int maxdepth, unsigned int flags);
|
2013-02-24 13:37:20 +00:00
|
|
|
pkg_comparator_t pkg_comparator_lookup_by_name(const char *name);
|
2011-07-25 02:03:17 +00:00
|
|
|
|
|
|
|
/* parse.c */
|
2013-02-24 14:58:35 +00:00
|
|
|
pkg_t *pkg_new_from_file(const char *path, FILE *f, unsigned int flags);
|
2013-03-01 17:36:21 +00:00
|
|
|
void pkg_dependency_parse_str(pkg_list_t *deplist_head, const char *depends);
|
|
|
|
void pkg_dependency_parse(pkg_t *pkg, pkg_list_t *deplist_head, const char *depends);
|
|
|
|
void pkg_dependency_append(pkg_list_t *list, pkg_dependency_t *tail);
|
|
|
|
void pkg_dependency_free(pkg_list_t *list);
|
2011-07-25 02:03:17 +00:00
|
|
|
|
2012-05-03 18:59:14 +00:00
|
|
|
/* argvsplit.c */
|
2012-05-07 03:21:11 +00:00
|
|
|
int pkg_argv_split(const char *src, int *argc, char ***argv);
|
|
|
|
void pkg_argv_free(char **argv);
|
2012-05-03 18:59:14 +00:00
|
|
|
|
2012-05-03 20:22:19 +00:00
|
|
|
/* fragment.c */
|
2014-07-09 06:23:51 +00:00
|
|
|
void pkg_fragment_parse(pkg_list_t *list, pkg_list_t *vars, const char *value, unsigned int flags);
|
|
|
|
void pkg_fragment_add(pkg_list_t *list, const char *string, unsigned int flags);
|
2015-05-22 04:06:38 +00:00
|
|
|
void pkg_fragment_copy(pkg_list_t *list, pkg_fragment_t *base, unsigned int flags, bool is_private);
|
2013-03-01 17:10:43 +00:00
|
|
|
void pkg_fragment_delete(pkg_list_t *list, pkg_fragment_t *node);
|
|
|
|
void pkg_fragment_free(pkg_list_t *list);
|
2012-05-03 20:22:19 +00:00
|
|
|
|
2012-05-04 03:21:51 +00:00
|
|
|
/* fileio.c */
|
|
|
|
char *pkg_fgetline(char *line, size_t size, FILE *stream);
|
|
|
|
|
2012-05-07 01:06:48 +00:00
|
|
|
/* tuple.c */
|
2013-03-01 16:45:55 +00:00
|
|
|
pkg_tuple_t *pkg_tuple_add(pkg_list_t *parent, const char *key, const char *value);
|
|
|
|
char *pkg_tuple_find(pkg_list_t *list, const char *key);
|
|
|
|
char *pkg_tuple_parse(pkg_list_t *list, const char *value);
|
|
|
|
void pkg_tuple_free(pkg_list_t *list);
|
2012-05-07 04:10:41 +00:00
|
|
|
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);
|
2012-05-07 04:32:08 +00:00
|
|
|
void pkg_tuple_define_global(const char *kv);
|
2012-05-07 01:06:48 +00:00
|
|
|
|
2012-07-02 02:21:31 +00:00
|
|
|
/* main.c */
|
|
|
|
extern FILE *error_msgout;
|
|
|
|
|
2012-07-29 08:49:56 +00:00
|
|
|
/* queue.c */
|
2013-03-01 16:24:57 +00:00
|
|
|
void pkg_queue_push(pkg_list_t *list, const char *package);
|
|
|
|
bool pkg_queue_compile(pkg_t *world, pkg_list_t *list);
|
|
|
|
void pkg_queue_free(pkg_list_t *list);
|
|
|
|
bool pkg_queue_apply(pkg_list_t *list, pkg_queue_apply_func_t func, int maxdepth, unsigned int flags, void *data);
|
|
|
|
bool pkg_queue_validate(pkg_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 */
|
|
|
|
pkg_t *pkg_cache_lookup(const char *id);
|
|
|
|
void pkg_cache_add(pkg_t *pkg);
|
|
|
|
void pkg_cache_remove(pkg_t *pkg);
|
2013-02-26 05:29:57 +00:00
|
|
|
void pkg_cache_free(void);
|
2013-02-25 23:36:09 +00:00
|
|
|
|
2011-07-25 02:03:17 +00:00
|
|
|
#endif
|