poldek: poldek/pkgdir/pkgdir_dirindex.c, poldek/pkgdir/pkgdir_diri...
mis
mis at pld-linux.org
Tue Jan 22 11:00:53 CET 2008
Author: mis Date: Tue Jan 22 10:00:53 2008 GMT
Module: poldek Tag: HEAD
---- Log message:
- pkgdir_dirindex_get_provided() added
---- Files affected:
poldek/poldek/pkgdir:
pkgdir_dirindex.c (1.17 -> 1.18) , pkgdir_dirindex.h (1.4 -> 1.5) , pkgdir.h (1.39 -> 1.40)
---- Diffs:
================================================================
Index: poldek/poldek/pkgdir/pkgdir_dirindex.c
diff -u poldek/poldek/pkgdir/pkgdir_dirindex.c:1.17 poldek/poldek/pkgdir/pkgdir_dirindex.c:1.18
--- poldek/poldek/pkgdir/pkgdir_dirindex.c:1.17 Thu Jul 12 22:56:07 2007
+++ poldek/poldek/pkgdir/pkgdir_dirindex.c Tue Jan 22 11:00:48 2008
@@ -121,12 +121,13 @@
void add_to_path_index(tn_hash *path_index, const char *path, uint32_t package_no)
{
char val[512];
- int vlen;
+ int vlen, klen = 0;
+ unsigned khash = 0;
tn_array *keys;
- if ((keys = n_hash_get(path_index, path)) == NULL) {
+ if ((keys = n_hash_get_ex(path_index, path, &klen, &khash)) == NULL) {
keys = n_array_new(16, free, (tn_fn_cmp)strcmp);
- n_hash_insert(path_index, path, keys);
+ n_hash_insert_ex(path_index, path, klen, khash, keys);
}
vlen = package_no_key(val, sizeof(val), package_no, 0);
@@ -558,18 +559,19 @@
if (*dir) {
struct capreq *req = capreq_new(pkg->na, dir, 0, NULL, NULL, 0,
- CAPREQ_BASTARD);
+ CAPREQ_BASTARD | CAPREQ_ISDIR);
n_array_push(pkg->reqs, req);
}
tl++;
}
+ n_str_tokl_free(tl_save);
if (ndirs > 10)
n_array_sort(pkg->reqs);
else
n_array_isort(pkg->reqs);
-
- n_str_tokl_free(tl_save);
+
+ pkg->flags |= PKG_INCLUDED_DIRREQS;
return ndirs;
}
@@ -731,8 +733,8 @@
}
-tn_array *pkgdir_dirindex_get_reqdirs(const struct pkgdir *pkgdir,
- const struct pkg *pkg)
+tn_array *get_package_directories_as_array(const struct pkgdir *pkgdir,
+ const struct pkg *pkg, int prefix)
{
const struct pkgdir_dirindex *dirindex = pkgdir->dirindex;
const char **tl, **tl_save;
@@ -744,8 +746,9 @@
return NULL;
vlen = sizeof(val);
- klen = package_key(key, sizeof(key), pkg, PREFIX_PKGKEY_REQDIR);
- tl = tl_save = get_package_directories(dirindex->db, key, klen, val, &vlen, &n);
+ klen = package_key(key, sizeof(key), pkg, prefix);
+ tl = tl_save = get_package_directories(dirindex->db, key, klen,
+ val, &vlen, &n);
if (tl == NULL)
return NULL;
@@ -764,6 +767,20 @@
return dirs;
}
+tn_array *pkgdir_dirindex_get_required(const struct pkgdir *pkgdir,
+ const struct pkg *pkg)
+{
+ return get_package_directories_as_array(pkgdir, pkg, PREFIX_PKGKEY_REQDIR);
+}
+
+tn_array *pkgdir_dirindex_get_provided(const struct pkgdir *pkgdir,
+ const struct pkg *pkg)
+{
+ return get_package_directories_as_array(pkgdir, pkg, PREFIX_PKGKEY_OWNDIR);
+}
+
+
+
static tn_array *do_dirindex_get(const struct pkgdir_dirindex *dirindex,
tn_array *pkgs, const char *path)
{
@@ -777,7 +794,6 @@
if (!tndb_get_str(dirindex->db, path, val, sizeof(val)))
return 0;
-
tl = tl_save = n_str_tokl_n(val, ":", &n);
DBGF("%s: FOUND %d (pkgs=%p)\n", path, n, pkgs ? pkgs : NULL);
================================================================
Index: poldek/poldek/pkgdir/pkgdir_dirindex.h
diff -u poldek/poldek/pkgdir/pkgdir_dirindex.h:1.4 poldek/poldek/pkgdir/pkgdir_dirindex.h:1.5
--- poldek/poldek/pkgdir/pkgdir_dirindex.h:1.4 Mon Jul 2 18:39:22 2007
+++ poldek/poldek/pkgdir/pkgdir_dirindex.h Tue Jan 22 11:00:48 2008
@@ -10,7 +10,7 @@
struct pkgdir_dirindex *pkgdir__dirindex_open(struct pkgdir *pkgdir);
void pkgdir__dirindex_close(struct pkgdir_dirindex *dirindex);
-/* returns packages having path */
+/* returns path providers */
tn_array *pkgdir_dirindex_get(const struct pkgdir *pkgdir,
tn_array *pkgs, const char *path);
/* path belongs to pkg? */
@@ -18,8 +18,8 @@
const struct pkg *pkg, const char *path);
/* returns directories required by package */
-tn_array *pkgdir_dirindex_get_reqdirs(const struct pkgdir *pkgdir,
- const struct pkg *pkg);
+tn_array *pkgdir_dirindex_get_required(const struct pkgdir *pkgdir,
+ const struct pkg *pkg);
-/* public prototypes are in pkgdir.h */
+/* for public prototypes see pkgdir.h */
#endif
================================================================
Index: poldek/poldek/pkgdir/pkgdir.h
diff -u poldek/poldek/pkgdir/pkgdir.h:1.39 poldek/poldek/pkgdir/pkgdir.h:1.40
--- poldek/poldek/pkgdir/pkgdir.h:1.39 Mon Jul 9 14:59:54 2007
+++ poldek/poldek/pkgdir/pkgdir.h Tue Jan 22 11:00:48 2008
@@ -185,8 +185,12 @@
const struct pkg *pkg, const char *path);
/* directories required by package */
-tn_array *pkgdir_dirindex_get_reqdirs(const struct pkgdir *pkgdir,
- const struct pkg *pkg);
+tn_array *pkgdir_dirindex_get_required(const struct pkgdir *pkgdir,
+ const struct pkg *pkg);
+
+tn_array *pkgdir_dirindex_get_provided(const struct pkgdir *pkgdir,
+ const struct pkg *pkg);
+
#endif
#endif /* POLDEK_PKGDIR_H*/
================================================================
---- CVS-web:
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/poldek/poldek/pkgdir/pkgdir_dirindex.c?r1=1.17&r2=1.18&f=u
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/poldek/poldek/pkgdir/pkgdir_dirindex.h?r1=1.4&r2=1.5&f=u
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/poldek/poldek/pkgdir/pkgdir.h?r1=1.39&r2=1.40&f=u
More information about the pld-cvs-commit
mailing list