2 * Copyright (c) 2015, SUSE Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
8 /* this is used by repo_rpmmd, repo_rpmdb, and repo_susetags */
13 #include "pool_parserpmrichdep.h"
15 static struct RichOpComp {
20 { "and", 3, REL_AND },
22 { "if", 2, REL_COND },
23 { "else", 4, REL_ELSE },
28 parseRichDep(Pool *pool, const char **depp, Id chainfl)
30 const char *p = *depp;
34 struct RichOpComp *op;
36 if (!chainfl && *p++ != '(')
44 id = parseRichDep(pool, &p, 0);
52 while (*p && !(*p == ' ' || *p == ',' || (*p == ')' && bl-- <= 0)))
57 id = pool_strn2id(pool, n, p - n, 1);
80 while (*p && !(*p == ' ' || *p == ',' || (*p == ')' && bl-- <= 0)))
83 if (p - n > 2 && n[0] == '0' && n[1] == ':')
84 n += 2; /* strip zero epoch */
87 id = pool_rel2id(pool, id, pool_strn2id(pool, n, p - n, 1), fl, 1);
101 while (*p && *p != ' ')
103 for (op = RichOps; op->n; op++)
104 if (p - n == op->l && !strncmp(n, op->n, op->l))
109 if (chainfl == REL_COND && fl == REL_ELSE)
111 if (chainfl && fl != chainfl)
113 evr = parseRichDep(pool, &p, fl);
117 return pool_rel2id(pool, id, evr, fl, 1);
121 pool_parserpmrichdep(Pool *pool, const char *dep)
123 Id id = parseRichDep(pool, &dep, 0);