aboutsummaryrefslogtreecommitdiffstats
path: root/xs1b.xs
diff options
context:
space:
mode:
Diffstat (limited to 'xs1b.xs')
-rw-r--r--xs1b.xs43
1 files changed, 43 insertions, 0 deletions
diff --git a/xs1b.xs b/xs1b.xs
new file mode 100644
index 0000000..ea8b169
--- /dev/null
+++ b/xs1b.xs
@@ -0,0 +1,43 @@
+static void
+update_provides_files(const URPM__Package pkg, HV *provides) {
+ if (pkg->h) {
+ STRLEN len;
+ unsigned int i;
+
+ struct rpmtd_s td_baseNames, td_dirIndexes, td_dirNames;
+ if (headerGet(pkg->h, RPMTAG_BASENAMES, &td_baseNames, HEADERGET_DEFAULT) &&
+ headerGet(pkg->h, RPMTAG_DIRINDEXES, &td_dirIndexes, HEADERGET_DEFAULT) &&
+ headerGet(pkg->h, RPMTAG_DIRNAMES, &td_dirNames, HEADERGET_DEFAULT)) {
+
+ char **baseNames = td_baseNames.data;
+ char **dirNames = td_dirNames.data;
+ int32_t *dirIndexes = td_dirIndexes.data;
+
+ char buff[4096];
+ char *p;
+
+ for(i = 0; i < rpmtdCount(&td_baseNames); i++) {
+ len = strlen(dirNames[dirIndexes[i]]);
+ if (len >= sizeof(buff)) continue;
+ memcpy(p = buff, dirNames[dirIndexes[i]], len + 1); p += len;
+ len = strlen(baseNames[i]);
+ if (p - buff + len >= sizeof(buff)) continue;
+ memcpy(p, baseNames[i], len + 1); p += len;
+
+ update_hash_entry(provides, buff, p-buff, 0, 0, pkg);
+ }
+
+ rpmtdFreeData(&td_baseNames);
+ rpmtdFreeData(&td_dirNames);
+ } else {
+ struct rpmtd_s td;
+
+ if (headerGet(pkg->h, RPMTAG_OLDFILENAMES, &td, HEADERGET_DEFAULT)) {
+ for (i = 0; i < rpmtdCount(&td); i++)
+ update_hash_entry(provides, rpmtdNextString(&td), 0, 0, 0, pkg);
+
+ rpmtdFreeData(&td);
+ }
+ }
+ }
+