summaryrefslogtreecommitdiff
path: root/src/poolvendor.c
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2007-10-30 17:55:35 +0000
committerMichael Schroeder <mls@suse.de>2007-10-30 17:55:35 +0000
commit18871f075d0aab1aa86ce6cdc6aff5ce77a27cf9 (patch)
tree289fc8e8fd1f28bcbac351901a526e893d7dee61 /src/poolvendor.c
parent555a08b276116a939f9343445e1c0939c7da4db2 (diff)
downloadlibsolv-18871f075d0aab1aa86ce6cdc6aff5ce77a27cf9.tar.gz
libsolv-18871f075d0aab1aa86ce6cdc6aff5ce77a27cf9.tar.bz2
libsolv-18871f075d0aab1aa86ce6cdc6aff5ce77a27cf9.zip
- add vendor change policy (but fixes no test case, as there is no
good test case)
Diffstat (limited to 'src/poolvendor.c')
-rw-r--r--src/poolvendor.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/poolvendor.c b/src/poolvendor.c
new file mode 100644
index 0000000..b818445
--- /dev/null
+++ b/src/poolvendor.c
@@ -0,0 +1,62 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define _GNU_SOURCE 1
+#include <fnmatch.h>
+
+#include "pool.h"
+#include "poolid.h"
+#include "poolvendor.h"
+#include "util.h"
+
+const char *vendors[] = {
+ "SUSE*",
+ "openSUSE*",
+ "SGI*",
+ "Novell*",
+ "Silicon Graphics*",
+ "Jpackage Project*",
+ "ATI Technologies Inc.*",
+ "Nvidia*",
+ 0,
+ 0,
+};
+
+Id pool_vendor2mask(Pool *pool, Id vendor)
+{
+ const char *vstr;
+ int i;
+ Id mask, m;
+ const char **v;
+
+ if (vendor == 0)
+ return 0;
+ for (i = 0; i < pool->vendormap.count; i += 2)
+ if (pool->vendormap.elements[i] == vendor)
+ return pool->vendormap.elements[i + 1];
+ vstr = id2str(pool, vendor);
+ m = 1;
+ mask = 0;
+ for (v = vendors; ; v++)
+ {
+ if (*v == 0)
+ {
+ v++;
+ if (*v == 0)
+ break;
+ if (m == (1 << 31))
+ break;
+ m <<= 1;
+ }
+ if (fnmatch(*v, vstr, FNM_CASEFOLD) == 0)
+ {
+ mask |= m;
+ while (v[1])
+ v++;
+ }
+ }
+ queue_push(&pool->vendormap, vendor);
+ queue_push(&pool->vendormap, mask);
+ return mask;
+}