createrepo_c library
C library for metadata manipulation
 Vše Třídy Funkce Proměnné Definice typů Výčty Hodnoty výčtu Skupiny Stránky
misc.h
1 /* createrepo_c - Library of routines for manipulation with repodata
2  * Copyright (C) 2012 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_MISC_H__
21 #define __C_CREATEREPOLIB_MISC_H__
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #include <glib.h>
28 #include <string.h>
29 #include <curl/curl.h>
30 #include "compression_wrapper.h"
31 #include "constants.h"
32 
39 #define CR_UNUSED(x) (void)(x)
40 
46 const char *cr_flag_to_str(gint64 flags);
47 
51 struct cr_EVR {
52  char *epoch;
53  char *version;
54  char *release;
55 };
56 
61 struct cr_Version {
62  long version;
63  long release;
64  long patch;
65  char *suffix;
66 };
67 
68 
78 struct cr_EVR cr_str_to_evr(const char *string, GStringChunk *chunk);
79 
86 static inline int cr_is_primary(const char *filename) {
87  if (!strncmp(filename, "/etc/", 5))
88  return 1;
89  if (!strcmp(filename, "/usr/lib/sendmail"))
90  return 1;
91  if (strstr(filename, "bin/"))
92  return 1;
93  return 0;
94 };
95 
103 char *cr_compute_file_checksum(const char *filename, cr_ChecksumType type);
104 
109  unsigned int start;
110  unsigned int end;
111 };
112 
118 struct cr_HeaderRangeStruct cr_get_header_byte_range(const char *filename);
119 
126 const char *cr_checksum_name_str(cr_ChecksumType type);
127 
134 char *cr_get_filename(const char *filepath);
135 
137 #define CR_COPY_OK 0
138 #define CR_COPY_ERR 1
151 void cr_download(CURL *handle,
152  const char *url,
153  const char *destination,
154  char **error);
155 
162 int cr_copy_file(const char *src, const char *dst);
163 
173 int cr_compress_file(const char *src,
174  const char *dst,
175  cr_CompressionType compression);
176 
183 int cr_better_copy_file(const char *src, const char *dst);
184 
190 int cr_remove_dir(const char *path);
191 
197 char *cr_normalize_dir_path(const char *path);
198 
204 struct cr_Version cr_str_to_version(const char *str);
205 
213 int cr_cmp_version_str(const char* str1, const char *str2);
214 
222 void cr_null_log_fn(const gchar *log_domain,
223  GLogLevelFlags log_level,
224  const gchar *message,
225  gpointer user_data);
226 
234 void cr_log_fn(const gchar *log_domain,
235  GLogLevelFlags log_level,
236  const gchar *message,
237  gpointer user_data);
238 
247 void cr_slist_free_full(GSList *list, GDestroyNotify free_f);
248 
249 #ifdef __cplusplus
250 }
251 #endif
252 
253 #endif /* __C_CREATEREPOLIB_MISC_H__ */