libcomps: /build/libcomps/src/libcomps-0.1.21/libcomps/src/comps_doc.h Source File

libcomps ..

Loading...
Searching...
No Matches
comps_doc.h
Go to the documentation of this file.
1/* libcomps - C alternative to yum.comps library
2 * Copyright (C) 2013 Jindrich Luza
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17 * USA
18 */
19
20#ifndef COMPS_DOC_H
21#define COMPS_DOC_H
22
23#include "comps_obj.h"
24#include "comps_objdict.h"
25#include "comps_objlist.h"
26#include "comps_log.h"
27#include "comps_types.h"
28#include "comps_docgroup.h"
29#include "comps_doccategory.h"
30#include "comps_docenv.h"
31#include "comps_validate.h"
32#include "comps_default.h"
33
42
44#define COMPS_DOC_GETOBJLIST(OBJS) COMPS_ObjList* CONCAT(comps_doc_, OBJS)\
45 (COMPS_Doc *doc){\
46 COMPS_ObjList *ret;\
47 ret = (COMPS_ObjList*)comps_objdict_get(doc->objects, #OBJS);\
48 if (!ret) {\
49 ret = COMPS_OBJECT_CREATE(COMPS_ObjList, NULL);\
50 comps_objdict_set_x(doc->objects, #OBJS, (COMPS_Object*)ret);\
51 ret = (COMPS_ObjList*)comps_object_incref((COMPS_Object*)ret);\
52 }\
53 return ret;\
54}
56
57#define HEAD_COMPS_DOC_GETOBJLIST(OBJS) COMPS_ObjList* CONCAT(comps_doc_, OBJS)\
58 (COMPS_Doc *doc);
60
61#define COMPS_DOC_SETOBJLIST(OBJS) void CONCAT(comps_doc_set_, OBJS)\
62 (COMPS_Doc *doc,\
63 COMPS_ObjList *list){\
64 comps_objdict_set(doc->objects, #OBJS, (COMPS_Object*)list);\
65}
67#define HEAD_COMPS_DOC_SETOBJLIST(OBJS) void CONCAT(comps_doc_set_, OBJS)\
68 (COMPS_Doc *doc,\
69 COMPS_ObjList *list);
71
72#define COMPS_DOC_GETOBJDICT(OBJNAME) COMPS_ObjDict* CONCAT(comps_doc_, OBJNAME)\
73 (COMPS_Doc *doc){\
74 COMPS_ObjDict *ret;\
75 ret = (COMPS_ObjDict*)comps_objdict_get(doc->objects, #OBJNAME);\
76 if (!ret) {\
77 ret = COMPS_OBJECT_CREATE(COMPS_ObjDict, NULL);\
78 comps_objdict_set_x(doc->objects, #OBJNAME, (COMPS_Object*)ret);\
79 ret = (COMPS_ObjDict*)comps_object_incref((COMPS_Object*)ret);\
80 }\
81 return ret;\
82}
84#define HEAD_COMPS_DOC_GETOBJDICT(OBJNAME) COMPS_ObjDict* CONCAT(comps_doc_, OBJNAME)\
85 (COMPS_Doc *doc);
87
88#define COMPS_DOC_GETOBJMDICT(OBJNAME) COMPS_ObjMDict* CONCAT(comps_doc_, OBJNAME)\
89 (COMPS_Doc *doc){\
90 COMPS_ObjMDict *ret;\
91 ret = (COMPS_ObjMDict*)comps_objdict_get(doc->objects, #OBJNAME);\
92 if (!ret) {\
93 ret = COMPS_OBJECT_CREATE(COMPS_ObjMDict, NULL);\
94 comps_objdict_set_x(doc->objects, #OBJNAME, (COMPS_Object*)ret);\
95 ret = (COMPS_ObjMDict*)comps_object_incref((COMPS_Object*)ret);\
96 }\
97 return ret;\
98}
100#define HEAD_COMPS_DOC_GETOBJMDICT(OBJNAME) COMPS_ObjMDict* CONCAT(comps_doc_, OBJNAME)\
101 (COMPS_Doc *doc);
103
104#define COMPS_DOC_SETOBJDICT(OBJS) void CONCAT(comps_doc_set_, OBJS)\
105 (COMPS_Doc *doc,\
106 COMPS_ObjDict *dict){\
107 comps_objdict_set(doc->objects, #OBJS, (COMPS_Object*)dict);\
108}
110#define HEAD_COMPS_DOC_SETOBJDICT(OBJS) void CONCAT(comps_doc_set_, OBJS)\
111 (COMPS_Doc *doc,\
112 COMPS_ObjDict *dict);
114
115#define COMPS_DOC_SETOBJMDICT(OBJS) void CONCAT(comps_doc_set_, OBJS)\
116 (COMPS_Doc *doc,\
117 COMPS_ObjMDict *dict){\
118 comps_objdict_set(doc->objects, #OBJS, (COMPS_Object*)dict);\
119}
121#define HEAD_COMPS_DOC_SETOBJMDICT(OBJS) void CONCAT(comps_doc_set_, OBJS)\
122 (COMPS_Doc *doc,\
123 COMPS_ObjMDict *dict);
125
126
127#define COMPS_DOC_ADDOBJLIST(OBJS, OBJNAME, OBJTYPE) void CONCAT(comps_doc_add_,\
128 OBJNAME)\
129 (COMPS_Doc *doc,\
130 OBJTYPE *obj){\
131 COMPS_ObjList *ret;\
132 ret = (COMPS_ObjList*)comps_objdict_get(doc->objects, #OBJS);\
133 if (!ret) {\
134 ret = COMPS_OBJECT_CREATE(COMPS_ObjList, NULL);\
135 comps_objdict_set(doc->objects, #OBJS, (COMPS_Object*)ret);\
136 } else {\
137 }\
138 comps_objlist_append_x(ret, (COMPS_Object*)obj);\
139 COMPS_OBJECT_DESTROY(ret);\
140}
142#define HEAD_COMPS_DOC_ADDOBJLIST(OBJNAME, OBJTYPE) void CONCAT(comps_doc_add_,\
143 OBJNAME)\
144 (COMPS_Doc *doc,\
145 OBJTYPE *obj);
147
148#define COMPS_DOC_ADDOBJDICT(OBJS, OBJNAME) void CONCAT(comps_doc_add_,\
149 OBJNAME)\
150 (COMPS_Doc *doc,\
151 char *key,\
152 COMPS_Str *obj){\
153 COMPS_ObjDict *ret;\
154 ret = (COMPS_ObjDict*)comps_objdict_get(doc->objects, #OBJS);\
155 if (!ret) {\
156 ret = COMPS_OBJECT_CREATE(COMPS_ObjDict, NULL);\
157 comps_objdict_set(doc->objects, #OBJS, (COMPS_Object*)ret);\
158 }\
159 comps_objdict_set_x(ret, key, (COMPS_Object*)obj);\
160 COMPS_OBJECT_DESTROY(ret);\
161}
163#define HEAD_COMPS_DOC_ADDOBJDICT(OBJNAME) void CONCAT(comps_doc_add_,\
164 OBJNAME)\
165 (COMPS_Doc *doc,\
166 char *key,\
167 COMPS_Str *obj);
169
170
171#define COMPS_DOC_ADDOBJMDICT(OBJS, OBJNAME) void CONCAT(comps_doc_add_,\
172 OBJNAME)\
173 (COMPS_Doc *doc,\
174 char *key,\
175 COMPS_Str *obj){\
176 COMPS_ObjMDict *ret;\
177 ret = (COMPS_ObjMDict*)comps_objdict_get(doc->objects, #OBJS);\
178 if (!ret) {\
179 ret = COMPS_OBJECT_CREATE(COMPS_ObjMDict, NULL);\
180 comps_objdict_set(doc->objects, #OBJS, (COMPS_Object*)ret);\
181 }\
182 comps_objmdict_set_x(ret, key, (COMPS_Object*)obj);\
183 COMPS_OBJECT_DESTROY(ret);\
184}
186#define HEAD_COMPS_DOC_ADDOBJMDICT(OBJNAME) void CONCAT(comps_doc_add_,\
187 OBJNAME)\
188 (COMPS_Doc *doc,\
189 char *key,\
190 COMPS_Str *obj);
192
193#define COMPS_DOC_GETPROP(OBJ,TYPE) CONCAT(TYPE,CONCAT(* ,CONCAT(comps_doc_, OBJ)))\
194 (COMPS_Doc *doc){\
195 TYPE *ret;\
196 ret = (COMPS_Str*)comps_objdict_get(doc->objects, #OBJ);\
197 if (!ret) {\
198 ret = COMPS_OBJECT_CREATE(TYPE, NULL);\
199 comps_objdict_set_x(doc->objects, #OBJ, (COMPS_Object*)ret);\
200 ret = (TYPE*)comps_object_incref((COMPS_Object*)ret);\
201 }\
202 return ret;\
203}
205
206#define HEAD_COMPS_DOC_GETPROP(OBJ, TYPE) CONCAT(TYPE,CONCAT(*,CONCAT(comps_doc_, OBJS)))\
207 (COMPS_Doc *doc);
209
210
211#define COMPS_DOC_SETPROP(OBJ, TYPE) void CONCAT(comps_doc_set_, OBJ)\
212 (COMPS_Doc *doc,\
213 TYPE *value){\
214 comps_objdict_set(doc->objects, #OBJ, (COMPS_Object*)value);\
215}
216
218
219
220#define HEAD_COMPS_DOC_SETPROP(OBJ, TYPE) void CONCAT(comps_doc_set_, OBJ)\
221 (COMPS_Doc *doc,\
222 TYPE *value);
223
226
229 typedef struct {
230 COMPS_Object_HEAD;
231 COMPS_ObjDict *objects;
232 COMPS_Log *log;
235 COMPS_Str *encoding;
236 COMPS_Str *doctype_name;
237 COMPS_Str *doctype_sysid;
238 COMPS_Str *doctype_pubid;
239 COMPS_Str *lang;
240 } COMPS_Doc;
241 COMPS_Object_TAIL(COMPS_Doc);
242
243//HEAD_COMPS_CREATE_u(doc, COMPS_Doc) /*comps_utils.h macro*/
244//HEAD_COMPS_COPY_u(doc, COMPS_Doc) /*comps_utils.h macro*/
245//HEAD_COMPS_DESTROY_u(doc, COMPS_Doc) /*comps_utils.h macro*/
246
255 void comps_doc_create(COMPS_Doc* doc, COMPS_Object **args);
256
258 void comps_doc_copy(COMPS_Doc *doc_dst, COMPS_Doc *doc_src);
259
262 void comps_doc_destroy(COMPS_Doc *doc);
263
265 signed char comps_doc_cmp_u(COMPS_Object *obj1, COMPS_Object *obj2);
266
270
274HEAD_COMPS_DOC_GETOBJLIST(groups) /*comps_doc.h macro*/
275
276
279HEAD_COMPS_DOC_GETOBJLIST(categories) /*comps_doc.h macro*/
280
281
284HEAD_COMPS_DOC_GETOBJLIST(environments) /*comps_doc.h macro*/
285
286
289HEAD_COMPS_DOC_GETOBJDICT(langpacks) /*comps_doc.h macro*/
290
291
294HEAD_COMPS_DOC_GETOBJMDICT(blacklist) /*comps_doc.h macro*/
295
296
299HEAD_COMPS_DOC_GETOBJMDICT(whiteout) /*comps_doc.h macro*/
300
301
302
303
306
307
313HEAD_COMPS_DOC_SETOBJLIST(groups) /*comps_doc.h macro*/
314
315
321HEAD_COMPS_DOC_SETOBJLIST(categories) /*comps_doc.h macro*/
322
323
329HEAD_COMPS_DOC_SETOBJLIST(environments) /*comps_doc.h macro*/
330
331
337HEAD_COMPS_DOC_SETOBJDICT(langpacks) /*comps_doc.h macro*/
338
339
345HEAD_COMPS_DOC_SETOBJMDICT(blacklist) /*comps_doc.h macro*/
346
347
353HEAD_COMPS_DOC_SETOBJMDICT(whiteout) /*comps_doc.h macro*/
354
355
356
357
360
361
367HEAD_COMPS_DOC_ADDOBJLIST(group, COMPS_DocGroup) /*comps_doc.h macro*/
368
369
375HEAD_COMPS_DOC_ADDOBJLIST(category, COMPS_DocCategory) /*comps_doc.h macro*/
376
377
383HEAD_COMPS_DOC_ADDOBJLIST(environment, COMPS_DocEnv) /*comps_doc.h macro*/
384
385
393HEAD_COMPS_DOC_ADDOBJDICT(langpack) /*comps_doc.h macro*/
394
395
403HEAD_COMPS_DOC_ADDOBJMDICT(blacklist) /*comps_doc.h macro*/
404
405
413HEAD_COMPS_DOC_ADDOBJMDICT(whiteout) /*comps_doc.h macro*/
414
415
416
417
422
423HEAD_COMPS_DOC_SETPROP(lang, COMPS_Str) /*comps_doc.h macro*/
424
425
426
427
430
431 COMPS_ObjList* comps_doc_get_groups(COMPS_Doc *doc, char *id, char *name,
432 char *desc, char *lang, int flags);
433 COMPS_ObjList* comps_doc_get_categories(COMPS_Doc *doc, char *id, char *name,
434 char *desc, char *lang, int flags);
435 COMPS_ObjList* comps_doc_get_envs(COMPS_Doc *doc, char *id, char *name,
436 char *desc, char *lang, int flags);
437
439
440//char* comps_doc_xml_str(COMPS_Doc* doc, char *enc, COMPS_Log *log);
441
442
443//static signed char comps_doc_xml(COMPS_Doc *doc, xmlTextWriterPtr writer);
444
453 signed char comps2xml_f(COMPS_Doc * doc, char *filename, char stdoutredirect,
454 COMPS_XMLOptions *xml_options,
455 COMPS_DefaultsOptions *def_options);
456
461 char* comps2xml_str(COMPS_Doc *doc, COMPS_XMLOptions *options,
462 COMPS_DefaultsOptions *def_options);
463
472 COMPS_Doc* comps_doc_union(COMPS_Doc *c1, COMPS_Doc *c2);
473 COMPS_Doc* comps_doc_intersect(COMPS_Doc *c1, COMPS_Doc *c2);
474
475 COMPS_Doc* comps_doc_arch_filter(COMPS_Doc *source, COMPS_ObjList *arches);
476
477 COMPS_Str* comps_doc_doctype_name_get(COMPS_Doc* doc);
478 COMPS_Str* comps_doc_doctype_pubid_get(COMPS_Doc* doc);
479 COMPS_Str* comps_doc_doctype_sysid_get(COMPS_Doc* doc);
480void comps_doc_doctype_name_set(COMPS_Doc* doc, COMPS_Str *val);
481void comps_doc_doctype_sysid_set(COMPS_Doc* doc, COMPS_Str *val);
482void comps_doc_doctype_pubid_set(COMPS_Doc* doc, COMPS_Str *val);
483
484//extern COMPS_ObjectInfo COMPS_Doc_ObjInfo;
485extern COMPS_ValRuleGeneric* COMPS_Doc_ValidateRules[];
486
487#endif //COMPS_DOC_H
488
comps2xml_str
char * comps2xml_str(COMPS_Doc *doc, COMPS_XMLOptions *options, COMPS_DefaultsOptions *def_options)
comps_doc_union
COMPS_Doc * comps_doc_union(COMPS_Doc *c1, COMPS_Doc *c2)
comps_doc_create
void comps_doc_create(COMPS_Doc *doc, COMPS_Object **args)
comps_doc_copy
void comps_doc_copy(COMPS_Doc *doc_dst, COMPS_Doc *doc_src)
comps_doc_destroy
void comps_doc_destroy(COMPS_Doc *doc)
comps2xml_f
signed char comps2xml_f(COMPS_Doc *doc, char *filename, char stdoutredirect, COMPS_XMLOptions *xml_options, COMPS_DefaultsOptions *def_options)
comps_doc_cmp_u
signed char comps_doc_cmp_u(COMPS_Object *obj1, COMPS_Object *obj2)
comps_doccategory.h
COMPS_DocCategory header file.
comps_docenv.h
COMPS_DocEnv header file.
comps_docgroup.h
COMPS_DocGroup header file.
comps_obj.h
COMPS_Object header file.
COMPS_Object_HEAD
#define COMPS_Object_HEAD
Definition comps_obj.h:86
COMPS_Object_TAIL
#define COMPS_Object_TAIL(obj)
insert "extern COMPS_ObjectInfo <obj>_ObjInfo" statement. Use this macro in combination with COMPS_OB...
Definition comps_obj.h:89
comps_objdict.h
Libcomps dictionary and multi-dictionary. COMPS_ObjDict and COMPS_ObjMDict are both derivates of COMP...
comps_objlist.h
A Documented file. Details.
COMPS_DocCategory
Definition comps_doccategory.h:49
COMPS_DocEnv
Definition comps_docenv.h:18
COMPS_DocGroup
Definition comps_docgroup.h:49
COMPS_Doc
Definition comps_doc.h:229
COMPS_Doc::encoding
COMPS_Str * encoding
Definition comps_doc.h:235
COMPS_Doc::objects
COMPS_ObjDict * objects
Definition comps_doc.h:231
COMPS_Doc::log
COMPS_Log * log
Definition comps_doc.h:232
COMPS_ObjList
Definition comps_objlist.h:41
COMPS_Object
Definition comps_obj.h:124
COMPS_Str
Definition comps_obj.h:143