diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2020-11-27 14:49:16 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2020-11-27 14:49:16 +0900 |
commit | 6a68988035ea989055076d81b7ab53c7015c8c32 (patch) | |
tree | 882953ab11585f025ce133c8ad5a281eb4857a80 /src/repodata.c | |
parent | cbc3c6a32d29006dda50336e30b42c25f5ca7454 (diff) | |
download | libsolv-6a68988035ea989055076d81b7ab53c7015c8c32.tar.gz libsolv-6a68988035ea989055076d81b7ab53c7015c8c32.tar.bz2 libsolv-6a68988035ea989055076d81b7ab53c7015c8c32.zip |
Imported Upstream version 0.7.12upstream/0.7.12
Diffstat (limited to 'src/repodata.c')
-rw-r--r-- | src/repodata.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/repodata.c b/src/repodata.c index 3cae0fe..0580cff 100644 --- a/src/repodata.c +++ b/src/repodata.c @@ -841,6 +841,57 @@ repodata_lookup_binary(Repodata *data, Id solvid, Id keyname, int *lenp) return dp; } +unsigned int +repodata_lookup_count(Repodata *data, Id solvid, Id keyname) +{ + unsigned char *dp; + Repokey *key; + unsigned int cnt = 0; + + dp = find_key_data(data, solvid, keyname, &key); + if (!dp) + return 0; + switch (key->type) + { + case REPOKEY_TYPE_IDARRAY: + case REPOKEY_TYPE_REL_IDARRAY: + for (cnt = 1; (*dp & 0xc0) != 0; dp++) + if ((*dp & 0xc0) == 0x40) + cnt++; + return cnt; + case REPOKEY_TYPE_FIXARRAY: + case REPOKEY_TYPE_FLEXARRAY: + data_read_id(dp, (int *)&cnt); + return cnt; + case REPOKEY_TYPE_DIRSTRARRAY: + for (;;) + { + cnt++; + while (*dp & 0x80) + dp++; + if (!(*dp++ & 0x40)) + return cnt; + dp += strlen((const char *)dp) + 1; + } + case REPOKEY_TYPE_DIRNUMNUMARRAY: + for (;;) + { + cnt++; + while (*dp++ & 0x80) + ; + while (*dp++ & 0x80) + ; + while (*dp & 0x80) + dp++; + if (!(*dp++ & 0x40)) + return cnt; + } + default: + break; + } + return 1; +} + /* highly specialized function to speed up fileprovides adding. * - repodata must be available * - solvid must be >= data->start and < data->end |