Librepo library  1.12.1
C library for downloading linux repository metadata and packages
util.h
1 /* librepo - A library providing (libcURL like) API to downloading repository
2  * Copyright (C) 2012 Tomas Mlcoch
3  *
4  * Licensed under the GNU Lesser General Public License Version 2.1
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef __LR_UTIL_H__
22 #define __LR_UTIL_H__
23 
24 #include <glib.h>
25 #include <stdlib.h>
26 #include <stdarg.h>
27 #include <curl/curl.h>
28 
29 #ifdef WITH_ZCHUNK
30 #include <zck.h>
31 #endif /* WITH_ZCHUNK */
32 
33 #include "checksum.h"
34 #include "xmlparser.h"
35 #include "downloadtarget.h"
36 
37 G_BEGIN_DECLS
38 
50 #define LR_CURL_VERSION_CHECK(major,minor,patch) \
51  (LIBCURL_VERSION_MAJOR > (major) || \
52  (LIBCURL_VERSION_MAJOR == (major) && LIBCURL_VERSION_MINOR > (minor)) || \
53  (LIBCURL_VERSION_MAJOR == (major) && LIBCURL_VERSION_MINOR == (minor) && \
54  LIBCURL_VERSION_PATCH >= (patch)))
55 
60 void lr_global_init(void);
61 
69 
73 void lr_out_of_memory(void);
74 
79 void *lr_malloc(size_t len);
80 
85 void *lr_malloc0(size_t len);
86 
92 void *lr_realloc(void *ptr, size_t len);
93 
97 void lr_free(void *mem);
98 
102 int lr_gettmpfile(void);
103 
107 char *lr_gettmpdir(void);
108 
115 char *lr_pathconcat(const char *str, ...) G_GNUC_NULL_TERMINATED;
116 
121 int lr_remove_dir(const char *path);
122 
128 int lr_copy_content(int source, int dest);
129 
136 char *lr_prepend_url_protocol(const char *path);
137 
144 gchar *
145 lr_string_chunk_insert(GStringChunk *chunk, const gchar *string);
146 
150 int
152  char *msg,
153  void *cbdata,
154  GError **err G_GNUC_UNUSED) G_GNUC_UNUSED;
155 
156 
165 gboolean
166 lr_best_checksum(GSList *list, LrChecksumType *type, gchar **value);
167 
172 gchar *
173 lr_url_without_path(const char *url);
174 
181 gchar **
182 lr_strv_dup(gchar **array);
183 
184 
192 gboolean
193 lr_is_local_path(const gchar *path);
194 
203 gboolean
204 lr_key_file_save_to_file(GKeyFile *key_file,
205  const gchar *filename,
206  GError **error);
207 
208 #ifdef WITH_ZCHUNK
209 
217 lr_checksum_from_zck_hash(zck_hash zck_checksum_type);
218 
226 zck_hash
227 lr_zck_hash_from_lr_checksum(LrChecksumType checksum_type);
228 
240 zckCtx *
241 lr_zck_init_read_base(const char *checksum, LrChecksumType checksum_type,
242  gint64 zck_header_size, int fd, GError **err);
243 
254 gboolean
255 lr_zck_valid_header_base(const char *checksum, LrChecksumType checksum_type,
256  gint64 zck_header_size, int fd, GError **err);
257 
266 zckCtx *
267 lr_zck_init_read(LrDownloadTarget *target, char *filename, int fd, GError **err);
268 
277 gboolean
278 lr_zck_valid_header(LrDownloadTarget *target, char *filename, int fd, GError **err);
279 
289 #endif /* WITH_ZCHUNK */
290 
291 GSList *
292 lr_get_recursive_files(char *path, char *extension, GError **err);
293 
296 G_END_DECLS
297 
298 #endif
lr_strv_dup
gchar ** lr_strv_dup(gchar **array)
lr_log_librepo_summary
void lr_log_librepo_summary(void)
lr_remove_dir
int lr_remove_dir(const char *path)
lr_is_local_path
gboolean lr_is_local_path(const gchar *path)
lr_free
void lr_free(void *mem)
lr_best_checksum
gboolean lr_best_checksum(GSList *list, LrChecksumType *type, gchar **value)
lr_realloc
void * lr_realloc(void *ptr, size_t len)
lr_gettmpfile
int lr_gettmpfile(void)
lr_prepend_url_protocol
char * lr_prepend_url_protocol(const char *path)
lr_global_init
void lr_global_init(void)
lr_gettmpdir
char * lr_gettmpdir(void)
LrChecksumType
LrChecksumType
Definition: checksum.h:36
lr_key_file_save_to_file
gboolean lr_key_file_save_to_file(GKeyFile *key_file, const gchar *filename, GError **error)
lr_xml_parser_warning_logger
int lr_xml_parser_warning_logger(LrXmlParserWarningType type G_GNUC_UNUSED, char *msg, void *cbdata, GError **err G_GNUC_UNUSED) G_GNUC_UNUSED
lr_string_chunk_insert
gchar * lr_string_chunk_insert(GStringChunk *chunk, const gchar *string)
lr_malloc
void * lr_malloc(size_t len)
lr_out_of_memory
void lr_out_of_memory(void)
LrXmlParserWarningType
LrXmlParserWarningType
Definition: xmlparser.h:38
lr_copy_content
int lr_copy_content(int source, int dest)
lr_malloc0
void * lr_malloc0(size_t len)
lr_url_without_path
gchar * lr_url_without_path(const char *url)
lr_pathconcat
char * lr_pathconcat(const char *str,...) G_GNUC_NULL_TERMINATED