libopkg: support passing callbacks to feed parsing functions
[oweals/opkg-lede.git] / libopkg / pkg_hash.h
1 /* pkg_hash.h - the opkg package management system
2
3    Steven M. Ayer
4
5    Copyright (C) 2002 Compaq Computer Corporation
6
7    This program is free software; you can redistribute it and/or
8    modify it under the terms of the GNU General Public License as
9    published by the Free Software Foundation; either version 2, or (at
10    your option) any later version.
11
12    This program is distributed in the hope that it will be useful, but
13    WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    General Public License for more details.
16 */
17
18 #ifndef PKG_HASH_H
19 #define PKG_HASH_H
20
21 #include "pkg.h"
22 #include "pkg_src.h"
23 #include "pkg_dest.h"
24 #include "hash_table.h"
25
26 void pkg_hash_init(void);
27 void pkg_hash_deinit(void);
28
29 void pkg_hash_fetch_available(pkg_vec_t * available);
30
31 int dist_hash_add_from_file(const char *file_name, pkg_src_t * dist);
32 int pkg_hash_add_from_file(const char *file_name, pkg_src_t * src,
33                            pkg_dest_t * dest, int is_status_file, int state_flags,
34                            void (*cb)(pkg_t *, void *), void *priv);
35 int pkg_hash_load_feeds(int state_flags, void (*cb)(pkg_t *, void *), void *priv);
36 int pkg_hash_load_status_files(void (*cb)(pkg_t *, void *), void *priv);
37 int pkg_hash_load_package_details(void);
38
39 void hash_insert_pkg(pkg_t * pkg, int set_status);
40
41 static inline abstract_pkg_t *abstract_pkg_fetch_by_name(const char *pkg_name)
42 {
43    return (abstract_pkg_t *) hash_table_get(&conf->pkg_hash, pkg_name);
44 }
45
46 abstract_pkg_t *ensure_abstract_pkg_by_name(const char *pkg_name);
47 void pkg_hash_fetch_all_installed(pkg_vec_t * installed);
48 pkg_t *pkg_hash_fetch_by_name_version(const char *pkg_name,
49                                       const char *version);
50 pkg_t *pkg_hash_fetch_best_installation_candidate(abstract_pkg_t * apkg,
51                                                   int (*constraint_fcn) (pkg_t *
52                                                                          pkg,
53                                                                          void
54                                                                          *data),
55                                                   void *cdata, int quiet);
56 pkg_t *pkg_hash_fetch_best_installation_candidate_by_name(const char *name);
57 pkg_t *pkg_hash_fetch_installed_by_name(const char *pkg_name);
58 pkg_t *pkg_hash_fetch_installed_by_name_dest(const char *pkg_name,
59                                              pkg_dest_t * dest);
60
61 void file_hash_remove(const char *file_name);
62 pkg_t *file_hash_get_file_owner(const char *file_name);
63 void file_hash_set_file_owner(const char *file_name, pkg_t * pkg);
64
65 #endif