a2342238c340fa430c002aba10fa7a02cf21d124
[platform/upstream/libsolv.git] / src / solver_private.h
1 /*
2  * Copyright (c) 2011, Novell Inc.
3  *
4  * This program is licensed under the BSD license, read LICENSE.BSD
5  * for further information
6  */
7
8 /*
9  * solver_private.h - private functions
10  *
11  */
12
13 #ifndef LIBSOLV_SOLVER_PRIVATE_H
14 #define LIBSOLV_SOLVER_PRIVATE_H
15
16 extern void solver_run_sat(Solver *solv, int disablerules, int doweak);
17 extern void solver_reset(Solver *solv);
18
19 extern int solver_splitprovides(Solver *solv, Id dep, Map *m);
20 extern int solver_dep_fulfilled_cplx(Solver *solv, Reldep *rd);
21
22 static inline int
23 solver_dep_fulfilled(Solver *solv, Id dep)
24 {
25   Pool *pool = solv->pool;
26   Id p, pp;
27
28   if (ISRELDEP(dep))
29     {
30       Reldep *rd = GETRELDEP(pool, dep);
31       if (rd->flags == REL_COND || rd->flags == REL_UNLESS || rd->flags == REL_AND || rd->flags == REL_OR)
32         return solver_dep_fulfilled_cplx(solv, rd);
33       if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_SPLITPROVIDES)
34         return solver_splitprovides(solv, rd->evr, 0);
35     }
36   FOR_PROVIDES(p, pp, dep)
37     {
38       if (solv->decisionmap[p] > 0)
39         return 1;
40     }
41   return 0;
42 }
43
44 static inline int
45 solver_is_supplementing(Solver *solv, Solvable *s)
46 {
47   Id sup, *supp;
48   if (!s->supplements)
49     return 0;
50   supp = s->repo->idarraydata + s->supplements;
51   while ((sup = *supp++) != 0)
52     if (solver_dep_fulfilled(solv, sup))
53       return 1;
54   return 0;
55 }
56
57 static inline int
58 solver_is_enhancing(Solver *solv, Solvable *s)
59 {
60   Id enh, *enhp;
61   if (!s->enhances)
62     return 0;
63   enhp = s->repo->idarraydata + s->enhances;
64   while ((enh = *enhp++) != 0)
65     if (solver_dep_fulfilled(solv, enh))
66       return 1;
67   return 0;
68 }
69
70 #endif /* LIBSOLV_SOLVER_PRIVATE_H */