Upload Tizen:Main source
[external/libsatsolver.git] / src / poolid.h
1 /*
2  * Copyright (c) 2007, Novell Inc.
3  *
4  * This program is licensed under the BSD license, read LICENSE.BSD
5  * for further information
6  */
7
8 /*
9  * poolid.h
10  * 
11  */
12
13 #ifndef SATSOLVER_POOLID_H
14 #define SATSOLVER_POOLID_H
15
16 #include "pooltypes.h"
17 #include "hash.h"
18
19 /*-----------------------------------------------
20  * Ids with relation
21  */
22
23 typedef struct _Reldep {
24   Id name;              // "package"
25   Id evr;               // "0:42-3"
26   int flags;            // operation/relation, see REL_x in pool.h
27 } Reldep;
28
29 extern Id pool_str2id(Pool *pool, const char *, int);
30 extern Id pool_strn2id(Pool *pool, const char *, unsigned int, int);
31 extern Id pool_rel2id(Pool *pool, Id, Id, int, int);
32 extern const char *pool_id2str(const Pool *pool, Id);
33 extern const char *pool_id2rel(const Pool *pool, Id);
34 extern const char *pool_id2evr(const Pool *pool, Id);
35 extern const char *pool_dep2str(Pool *pool, Id); /* might alloc tmpspace */
36
37 extern void pool_shrink_strings(Pool *pool);
38 extern void pool_shrink_rels(Pool *pool);
39 extern void pool_freeidhashes(Pool *pool);
40
41
42 /* deprecated names, do not use in new code */
43 static inline Id str2id(Pool *pool, const char *str, int create)
44 {
45   return pool_str2id(pool, str, create);
46 }
47 static inline Id strn2id(Pool *pool, const char *str, unsigned int len, int create)
48 {
49   return pool_strn2id(pool, str, len, create);
50 }
51 static inline Id rel2id(Pool *pool, Id name, Id evr, int flags, int create)
52 {
53   return pool_rel2id(pool, name, evr, flags, create);
54 }
55 static inline const char *id2str(const Pool *pool, Id id)
56 {
57   return pool_id2str(pool, id);
58 }
59 static inline const char *id2rel(const Pool *pool, Id id)
60 {
61   return pool_id2rel(pool, id);
62 }
63 static inline const char *id2evr(const Pool *pool, Id id)
64 {
65   return pool_id2evr(pool, id);
66 }
67 static inline const char *dep2str(Pool *pool, Id id)
68 {
69   return pool_dep2str(pool, id);
70 }
71
72 #endif /* SATSOLVER_POOLID_H */