aboutsummaryrefslogtreecommitdiffstats
path: root/xs1b.xs
blob: ea8b169ad2b38058fd9c630bcf42984c8a70de2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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);
      }
    }
  }