- add solvable allocation functions
[platform/upstream/libsolv.git] / tools / attr_store.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 #ifndef ATTR_STORE_H
9 #define ATTR_STORE_H
10
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14
15 #include "poolid.h"
16
17 struct _Pool;
18 struct _Attrstore;
19 typedef struct _Attrstore Attrstore;
20 typedef unsigned short NameId;
21 typedef Id LocalId;
22
23 Attrstore * new_store (struct _Pool *pool);
24 unsigned int new_entry (Attrstore *s);
25 Attrstore * attr_store_read (FILE *fp, struct _Pool *pool);
26 void ensure_entry (Attrstore *s, unsigned int entry);
27 void write_attr_store (FILE *fp, Attrstore *s);
28 void attr_store_pack (Attrstore *s);
29 void attr_store_unpack (Attrstore *s);
30
31 NameId  str2nameid (Attrstore *s, const char *str);
32 LocalId str2localid (Attrstore *s, const char *str, int create);
33 const char * localid2str(Attrstore *s, LocalId id);
34
35 void add_attr_int (Attrstore *s, unsigned int entry, NameId name, unsigned int val);
36 void add_attr_blob (Attrstore *s, unsigned int entry, NameId name, const void *ptr, unsigned int len);
37 void add_attr_string (Attrstore *s, unsigned int entry, NameId name, const char *val);
38 void add_attr_id (Attrstore *s, unsigned int entry, NameId name, Id val);
39 void add_attr_intlist_int (Attrstore *s, unsigned int entry, NameId name, int val);
40 void add_attr_localids_id (Attrstore *s, unsigned int entry, NameId name, LocalId id);
41
42 const void * attr_retrieve_blob (Attrstore *s, unsigned int ofs, unsigned int len);
43
44 #define SEARCH_SUBSTRING 1
45 #define SEARCH_STRING 2
46 #define SEARCH_GLOB 3
47 #define SEARCH_REGEX 4
48 #define SEARCH_NOCASE 8
49 #define SEARCH_BLOBS 16
50 #define SEARCH_IDS 32
51 typedef int (*cb_attr_search_s) (Attrstore *s, unsigned entry, Id name, const char *str);
52 void attr_store_search_s (Attrstore *s, const char *pattern, int flags, NameId name, cb_attr_search_s cb);
53 #ifdef __cplusplus
54 }
55 #endif
56
57 #endif