Librepo library 1.14.5
C library for downloading linux repository metadata and packages
Loading...
Searching...
No Matches
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
37G_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
60void lr_global_init(void);
61
69
74
79void *lr_malloc(size_t len);
80
85void *lr_malloc0(size_t len);
86
92void *lr_realloc(void *ptr, size_t len);
93
97void lr_free(void *mem);
98
103
107char *lr_gettmpdir(void);
108
115char *lr_pathconcat(const char *str, ...) G_GNUC_NULL_TERMINATED;
116
121int lr_remove_dir(const char *path);
122
128int lr_copy_content(int source, int dest);
129
136char *lr_prepend_url_protocol(const char *path);
137
144gchar *
145lr_string_chunk_insert(GStringChunk *chunk, const gchar *string);
146
150int
152 char *msg,
153 void *cbdata,
154 GError **err G_GNUC_UNUSED) G_GNUC_UNUSED;
155
156
165gboolean
166lr_best_checksum(GSList *list, LrChecksumType *type, gchar **value);
167
172gchar *
173lr_url_without_path(const char *url);
174
181gchar **
182lr_strv_dup(gchar **array);
183
184
192gboolean
193lr_is_local_path(const gchar *path);
194
203gboolean
204lr_key_file_save_to_file(GKeyFile *key_file,
205 const gchar *filename,
206 GError **error);
207
208#ifdef WITH_ZCHUNK
217lr_checksum_from_zck_hash(zck_hash zck_checksum_type);
218
226zck_hash
227lr_zck_hash_from_lr_checksum(LrChecksumType checksum_type);
228
240zckCtx *
241lr_zck_init_read_base(const char *checksum, LrChecksumType checksum_type,
242 gint64 zck_header_size, int fd, GError **err);
243
254gboolean
255lr_zck_valid_header_base(const char *checksum, LrChecksumType checksum_type,
256 gint64 zck_header_size, int fd, GError **err);
257
266zckCtx *
267lr_zck_init_read(LrDownloadTarget *target, char *filename, int fd, GError **err);
268
277gboolean
278lr_zck_valid_header(LrDownloadTarget *target, char *filename, int fd, GError **err);
279
289#endif /* WITH_ZCHUNK */
290
291GSList *
292lr_get_recursive_files(char *path, char *extension, GError **err);
293
296G_END_DECLS
297
298#endif
LrChecksumType
Definition checksum.h:36
void * lr_malloc0(size_t len)
gchar * lr_string_chunk_insert(GStringChunk *chunk, const gchar *string)
void lr_global_init(void)
gboolean lr_key_file_save_to_file(GKeyFile *key_file, const gchar *filename, GError **error)
void * lr_realloc(void *ptr, size_t len)
int lr_xml_parser_warning_logger(LrXmlParserWarningType type G_GNUC_UNUSED, char *msg, void *cbdata, GError **err G_GNUC_UNUSED) G_GNUC_UNUSED
void lr_out_of_memory(void)
gboolean lr_best_checksum(GSList *list, LrChecksumType *type, gchar **value)
gchar ** lr_strv_dup(gchar **array)
int lr_remove_dir(const char *path)
int lr_gettmpfile(void)
char * lr_gettmpdir(void)
void lr_free(void *mem)
void * lr_malloc(size_t len)
gchar * lr_url_without_path(const char *url)
gboolean lr_is_local_path(const gchar *path)
void lr_log_librepo_summary(void)
char * lr_prepend_url_protocol(const char *path)
int lr_copy_content(int source, int dest)
char * lr_pathconcat(const char *str,...) G_GNUC_NULL_TERMINATED
LrXmlParserWarningType
Definition xmlparser.h:38