createrepo_c library  1.0.2
C library for metadata manipulation
xml_file.h
1 /* createrepo_c - Library of routines for manipulation with repodata
2  * Copyright (C) 2013 Tomas Mlcoch
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but 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 the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17  * USA.
18  */
19 
20 #ifndef __C_CREATEREPOLIB_XML_FILE_H__
21 #define __C_CREATEREPOLIB_XML_FILE_H__
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #include <glib.h>
28 #include "compression_wrapper.h"
29 #include "package.h"
30 
38 typedef enum {
47 
50 typedef struct {
55  int header;
57  int footer;
59  long pkgs;
61 } cr_XmlFile;
62 
69 #define cr_xmlfile_open_primary(FILENAME, COMTYPE, ERR) \
70  cr_xmlfile_open(FILENAME, CR_XMLFILE_PRIMARY, COMTYPE, ERR)
71 
79 #define cr_xmlfile_sopen_primary(FILENAME, COMTYPE, STAT, ERR) \
80  cr_xmlfile_sopen(FILENAME, CR_XMLFILE_PRIMARY, COMTYPE, STAT, ERR)
81 
88 #define cr_xmlfile_open_filelists(FILENAME, COMTYPE, ERR) \
89  cr_xmlfile_open(FILENAME, CR_XMLFILE_FILELISTS, COMTYPE, ERR)
90 
97 #define cr_xmlfile_open_filelists_ext(FILENAME, COMTYPE, ERR) \
98  cr_xmlfile_open(FILENAME, CR_XMLFILE_FILELISTS_EXT, COMTYPE, ERR)
99 
107 #define cr_xmlfile_sopen_filelists(FILENAME, COMTYPE, STAT, ERR) \
108  cr_xmlfile_sopen(FILENAME, CR_XMLFILE_FILELISTS, COMTYPE, STAT, ERR)
109 
117 #define cr_xmlfile_sopen_filelists_ext(FILENAME, COMTYPE, STAT, ERR) \
118  cr_xmlfile_sopen(FILENAME, CR_XMLFILE_FILELISTS_EXT, COMTYPE, STAT, ERR)
119 
126 #define cr_xmlfile_open_other(FILENAME, COMTYPE, ERR) \
127  cr_xmlfile_open(FILENAME, CR_XMLFILE_OTHER, COMTYPE, ERR)
128 
136 #define cr_xmlfile_sopen_other(FILENAME, COMTYPE, STAT, ERR) \
137  cr_xmlfile_sopen(FILENAME, CR_XMLFILE_OTHER, COMTYPE, STAT, ERR)
138 
145 #define cr_xmlfile_open_prestodelta(FILENAME, COMTYPE, ERR) \
146  cr_xmlfile_open(FILENAME, CR_XMLFILE_PRESTODELTA, COMTYPE, ERR)
147 
155 #define cr_xmlfile_sopen_prestodelta(FILENAME, COMTYPE, STAT, ERR) \
156  cr_xmlfile_sopen(FILENAME, CR_XMLFILE_PRESTODELTA, COMTYPE, STAT, ERR)
157 
164 #define cr_xmlfile_open_updateinfo(FILENAME, COMTYPE, ERR) \
165  cr_xmlfile_open(FILENAME, CR_XMLFILE_UPDATEINFO, COMTYPE, ERR)
166 
174 #define cr_xmlfile_sopen_updateinfo(FILENAME, COMTYPE, STAT, ERR) \
175  cr_xmlfile_sopen(FILENAME, CR_XMLFILE_UPDATEINFO, COMTYPE, STAT, ERR)
176 
186 #define cr_xmlfile_open(FILENAME, TYPE, COMTYPE, ERR) \
187  cr_xmlfile_sopen(FILENAME, TYPE, COMTYPE, NULL, ERR)
188 
199 cr_XmlFile *cr_xmlfile_sopen(const char *filename,
200  cr_XmlFileType type,
201  cr_CompressionType comtype,
202  cr_ContentStat *stat,
203  GError **err);
204 
213 int cr_xmlfile_set_num_of_pkgs(cr_XmlFile *f, long num, GError **err);
214 
221 int cr_xmlfile_add_pkg(cr_XmlFile *f, cr_Package *pkg, GError **err);
222 
235 int cr_xmlfile_add_chunk(cr_XmlFile *f, const char *chunk, GError **err);
236 
242 int cr_xmlfile_close(cr_XmlFile *f, GError **err);
243 
254 void cr_rewrite_header_package_count(gchar *original_filename,
255  cr_CompressionType xml_compression,
256  int package_count,
257  int task_count,
258  cr_ContentStat *file_stat,
259  gchar *zck_dict_file,
260  GError **err);
261 
262 
265 #ifdef __cplusplus
266 }
267 #endif
268 
269 #endif /* __C_CREATEREPOLIB_XML_FILE_H__ */
void cr_rewrite_header_package_count(gchar *original_filename, cr_CompressionType xml_compression, int package_count, int task_count, cr_ContentStat *file_stat, gchar *zck_dict_file, GError **err)
cr_CompressionType
cr_XmlFileType type
Definition: xml_file.h:53
cr_XmlFile * cr_xmlfile_sopen(const char *filename, cr_XmlFileType type, cr_CompressionType comtype, cr_ContentStat *stat, GError **err)
int cr_xmlfile_close(cr_XmlFile *f, GError **err)
int cr_xmlfile_add_pkg(cr_XmlFile *f, cr_Package *pkg, GError **err)
int header
Definition: xml_file.h:55
int cr_xmlfile_add_chunk(cr_XmlFile *f, const char *chunk, GError **err)
int footer
Definition: xml_file.h:57
long pkgs
Definition: xml_file.h:59
cr_XmlFileType
Definition: xml_file.h:38
CR_FILE * f
Definition: xml_file.h:51
int cr_xmlfile_set_num_of_pkgs(cr_XmlFile *f, long num, GError **err)