Imported Upstream version 0.6.11
[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
21 static inline int
22 solver_dep_fulfilled(Solver *solv, Id dep)
23 {
24   Pool *pool = solv->pool;
25   Id p, pp;
26
27   if (ISRELDEP(dep))
28     {
29       Reldep *rd = GETRELDEP(pool, dep);
30       if (rd->flags == REL_AND || rd->flags == REL_COND)
31         {
32           if (!solver_dep_fulfilled(solv, rd->name))
33             return 0;
34           return solver_dep_fulfilled(solv, rd->evr);
35         }
36       if (rd->flags == REL_OR)
37         {
38           if (solver_dep_fulfilled(solv, rd->name))
39             return 1;
40           return solver_dep_fulfilled(solv, rd->evr);
41         }
42       if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_SPLITPROVIDES)
43         return solver_splitprovides(solv, rd->evr, 0);
44     }
45   FOR_PROVIDES(p, pp, dep)
46     {
47       if (solv->decisionmap[p] > 0)
48         return 1;
49     }
50   return 0;
51 }
52
53 static inline int
54 solver_is_supplementing(Solver *solv, Solvable *s)
55 {
56   Id sup, *supp;
57   if (!s->supplements)
58     return 0;
59   supp = s->repo->idarraydata + s->supplements;
60   while ((sup = *supp++) != 0)
61     if (solver_dep_fulfilled(solv, sup))
62       return 1;
63   return 0;
64 }
65
66 static inline int
67 solver_is_enhancing(Solver *solv, Solvable *s)
68 {
69   Id enh, *enhp;
70   if (!s->enhances)
71     return 0;
72   enhp = s->repo->idarraydata + s->enhances;
73   while ((enh = *enhp++) != 0)
74     if (solver_dep_fulfilled(solv, enh))
75       return 1;
76   return 0;
77 }
78
79 #endif /* LIBSOLV_SOLVER_PRIVATE_H */