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 
57 struct cr_NVREA {
58  char *name;
59  char *version;
60  char *release;
61  char *epoch;
62  char *arch;
63 };
64 
69 struct cr_Version {
70  long version;
71  long release;
72  long patch;
73  char *suffix;
74 };
75 
76 
86 struct cr_EVR cr_str_to_evr(const char *string, GStringChunk *chunk);
87 
94 static inline int cr_is_primary(const char *filename) {
95  if (!strncmp(filename, "/etc/", 5))
96  return 1;
97  if (!strcmp(filename, "/usr/lib/sendmail"))
98  return 1;
99  if (strstr(filename, "bin/"))
100  return 1;
101  return 0;
102 };
103 
111 char *cr_compute_file_checksum(const char *filename, cr_ChecksumType type);
112 
117  unsigned int start;
118  unsigned int end;
119 };
120 
126 struct cr_HeaderRangeStruct cr_get_header_byte_range(const char *filename);
127 
134 const char *cr_checksum_name_str(cr_ChecksumType type);
135 
142 char *cr_get_filename(const char *filepath);
143 
145 #define CR_COPY_OK 0
146 #define CR_COPY_ERR 1
159 void cr_download(CURL *handle,
160  const char *url,
161  const char *destination,
162  char **error);
163 
170 int cr_copy_file(const char *src, const char *dst);
171 
181 int cr_compress_file(const char *src,
182  const char *dst,
183  cr_CompressionType compression);
184 
191 int cr_better_copy_file(const char *src, const char *dst);
192 
198 int cr_remove_dir(const char *path);
199 
205 char *cr_normalize_dir_path(const char *path);
206 
212 struct cr_Version cr_str_to_version(const char *str);
213 
221 int cr_cmp_version_str(const char* str1, const char *str2);
222 
230 void cr_null_log_fn(const gchar *log_domain,
231  GLogLevelFlags log_level,
232  const gchar *message,
233  gpointer user_data);
234 
242 void cr_log_fn(const gchar *log_domain,
243  GLogLevelFlags log_level,
244  const gchar *message,
245  gpointer user_data);
246 
255 void cr_slist_free_full(GSList *list, GDestroyNotify free_f);
256 
257 struct cr_NVREA *cr_split_rpm_filename(const char *filename);
258 void cr_nvrea_free(struct cr_NVREA *);
259 
266 #define cr_cmp_nvrea(A, B) (cr_cmp_evr((A)->epoch, (A)->version, (A)->release,\
267  (B)->epoch, (B)->version, (B)->release))
268 
279 int cr_cmp_evr(const char *e1, const char *v1, const char *r1,
280  const char *e2, const char *v2, const char *r2);
281 
282 #ifdef __cplusplus
283 }
284 #endif
285 
286 #endif /* __C_CREATEREPOLIB_MISC_H__ */