pkgconf/libpkgconf/libpkgconf.h

198 lines
6.3 KiB
C

/*
* pkg.h
* Global include file for everything.
*
* Copyright (c) 2011 pkgconf authors (see AUTHORS).
*
* 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.
*
* 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.
*/
#ifndef __PKG_H
#define __PKG_H
#include <libpkgconf/config.h>
#include <libpkgconf/stdinc.h>
#include <libpkgconf/iter.h>
#include <libpkgconf/bsdstubs.h>
#define PKG_BUFSIZE (65535)
typedef enum {
PKG_ANY = 0,
PKG_LESS_THAN,
PKG_GREATER_THAN,
PKG_LESS_THAN_EQUAL,
PKG_GREATER_THAN_EQUAL,
PKG_EQUAL,
PKG_NOT_EQUAL,
PKG_ALWAYS_MATCH,
PKG_CMP_SIZE
} pkg_comparator_t;
typedef struct pkg_ pkg_t;
typedef struct pkgconf_dependency_ pkgconf_dependency_t;
typedef struct pkgconf_tuple_ pkgconf_tuple_t;
typedef struct pkgconf_fragment_ pkgconf_fragment_t;
#define PKGCONF_FOREACH_LIST_ENTRY(head, value) \
for ((value) = (head); (value) != NULL; (value) = (value)->next)
#define PKGCONF_FOREACH_LIST_ENTRY_SAFE(head, nextiter, value) \
for ((value) = (head), (nextiter) = (head) != NULL ? (head)->next : NULL; (value) != NULL; (value) = (nextiter), (nextiter) = (nextiter) != NULL ? (nextiter)->next : NULL)
#define PKGCONF_FOREACH_LIST_ENTRY_REVERSE(tail, value) \
for ((value) = (tail); (value) != NULL; (value) = (value)->prev)
#define PKG_MIN(a,b) (((a) < (b)) ? (a) : (b))
#define PKG_MAX(a,b) (((a) > (b)) ? (a) : (b))
struct pkgconf_fragment_ {
pkgconf_node_t iter;
char type;
char *data;
};
struct pkgconf_dependency_ {
pkgconf_node_t iter;
char *package;
pkg_comparator_t compare;
char *version;
pkg_t *parent;
};
struct pkgconf_tuple_ {
pkgconf_node_t iter;
char *key;
char *value;
};
#define PKG_PROPF_NONE 0x0
#define PKG_PROPF_VIRTUAL 0x1
#define PKG_PROPF_CACHED 0x2
#define PKG_PROPF_SEEN 0x4
#define PKG_PROPF_UNINSTALLED 0x8
struct pkg_ {
pkgconf_node_t cache_iter;
int refcount;
char *id;
char *filename;
char *realname;
char *version;
char *description;
char *url;
char *pc_filedir;
pkgconf_list_t libs;
pkgconf_list_t libs_private;
pkgconf_list_t cflags;
pkgconf_list_t cflags_private;
pkgconf_list_t requires;
pkgconf_list_t requires_private;
pkgconf_list_t conflicts;
pkgconf_list_t vars;
unsigned int flags;
};
#define PKG_MODULE_SEPARATOR(c) ((c) == ',' || isspace ((c)))
#define PKG_OPERATOR_CHAR(c) ((c) == '<' || (c) == '>' || (c) == '!' || (c) == '=')
#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
#define PKGF_ITER_PKG_IS_PRIVATE 0x200
#define PKG_ERRF_OK 0x0
#define PKG_ERRF_PACKAGE_NOT_FOUND 0x1
#define PKG_ERRF_PACKAGE_VER_MISMATCH 0x2
#define PKG_ERRF_PACKAGE_CONFLICT 0x4
#define PKG_ERRF_DEPGRAPH_BREAK 0x8
typedef void (*pkg_iteration_func_t)(const pkg_t *pkg);
typedef void (*pkg_traverse_func_t)(pkg_t *pkg, void *data, unsigned int flags);
typedef bool (*pkgconf_queue_apply_func_t)(pkg_t *world, void *data, int maxdepth, unsigned int flags);
/* pkg.c */
pkg_t *pkg_ref(pkg_t *pkg);
void pkg_unref(pkg_t *pkg);
void pkg_free(pkg_t *pkg);
pkg_t *pkg_find(const char *name, unsigned int flags);
void pkg_scan_all(pkg_iteration_func_t func);
unsigned int pkg_traverse(pkg_t *root, pkg_traverse_func_t func, void *data, int maxdepth, unsigned int flags);
unsigned int pkg_verify_graph(pkg_t *root, int depth, unsigned int flags);
int pkg_compare_version(const char *a, const char *b);
pkg_t *pkg_verify_dependency(pkgconf_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags);
const char *pkg_get_comparator(pkgconf_dependency_t *pkgdep);
int pkg_cflags(pkg_t *root, pkgconf_list_t *list, int maxdepth, unsigned int flags);
int pkg_libs(pkg_t *root, pkgconf_list_t *list, int maxdepth, unsigned int flags);
pkg_comparator_t pkg_comparator_lookup_by_name(const char *name);
/* parse.c */
pkg_t *pkg_new_from_file(const char *path, FILE *f, unsigned int flags);
void pkgconf_dependency_parse_str(pkgconf_list_t *deplist_head, const char *depends);
void pkgconf_dependency_parse(pkg_t *pkg, pkgconf_list_t *deplist_head, const char *depends);
void pkgconf_dependency_append(pkgconf_list_t *list, pkgconf_dependency_t *tail);
void pkgconf_dependency_free(pkgconf_list_t *list);
/* argvsplit.c */
int pkgconf_argv_split(const char *src, int *argc, char ***argv);
void pkgconf_argv_free(char **argv);
/* fragment.c */
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);
/* fileio.c */
char *pkgconf_fgetline(char *line, size_t size, FILE *stream);
/* tuple.c */
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;
/* queue.c */
void pkgconf_queue_push(pkgconf_list_t *list, const char *package);
bool pkgconf_queue_compile(pkg_t *world, pkgconf_list_t *list);
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);
/* cache.c */
pkg_t *pkgconf_cache_lookup(const char *id);
void pkgconf_cache_add(pkg_t *pkg);
void pkgconf_cache_remove(pkg_t *pkg);
void pkgconf_cache_free(void);
#endif