add support for complex dependencies
[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_dep_installed(Solver *solv, Id dep);
20 extern int solver_splitprovides(Solver *solv, Id dep);
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_AND || rd->flags == REL_COND)
32         {
33           if (!solver_dep_fulfilled(solv, rd->name))
34             return 0;
35           return solver_dep_fulfilled(solv, rd->evr);
36         }
37       if (rd->flags == REL_OR)
38         {
39           if (solver_dep_fulfilled(solv, rd->name))
40             return 1;
41           return solver_dep_fulfilled(solv, rd->evr);
42         }
43       if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_SPLITPROVIDES)
44         return solver_splitprovides(solv, rd->evr);
45       if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_INSTALLED)
46         return solver_dep_installed(solv, rd->evr);
47     }
48   FOR_PROVIDES(p, pp, dep)
49     {
50       if (solv->decisionmap[p] > 0)
51         return 1;
52     }
53   return 0;
54 }
55
56 static inline int
57 solver_is_supplementing(Solver *solv, Solvable *s)
58 {
59   Id sup, *supp;
60   if (!s->supplements)
61     return 0;
62   supp = s->repo->idarraydata + s->supplements;
63   while ((sup = *supp++) != 0)
64     if (solver_dep_fulfilled(solv, sup))
65       return 1;
66   return 0;
67 }
68
69 static inline int
70 solver_is_enhancing(Solver *solv, Solvable *s)
71 {
72   Id enh, *enhp;
73   if (!s->enhances)
74     return 0;
75   enhp = s->repo->idarraydata + s->enhances;
76   while ((enh = *enhp++) != 0)
77     if (solver_dep_fulfilled(solv, enh))
78       return 1;
79   return 0;
80 }
81
82 #endif /* LIBSOLV_SOLVER_PRIVATE_H */