createrepo_c library  0.1.17
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 
40 #define CR_UNUSED(x) (void)(x)
41 
46 const char *cr_flag_to_str(gint64 flags);
47 
50 struct cr_EVR {
51  char *epoch;
52  char *version;
53  char *release;
54 };
55 
58 struct cr_NVREA {
59  char *name;
60  char *version;
61  char *release;
62  char *epoch;
63  char *arch;
64 };
65 
69 struct cr_Version {
70  long version;
71  long release;
72  long patch;
73  char *suffix;
74 };
75 
76 
85 struct cr_EVR cr_str_to_evr(const char *string, GStringChunk *chunk);
86 
92 static inline int cr_is_primary(const char *filename) {
93  if (!strncmp(filename, "/etc/", 5))
94  return 1;
95  if (!strcmp(filename, "/usr/lib/sendmail"))
96  return 1;
97  if (strstr(filename, "bin/"))
98  return 1;
99  return 0;
100 };
101 
108 char *cr_compute_file_checksum(const char *filename, cr_ChecksumType type);
109 
113  unsigned int start;
114  unsigned int end;
115 };
116 
121 struct cr_HeaderRangeStruct cr_get_header_byte_range(const char *filename);
122 
128 const char *cr_checksum_name_str(cr_ChecksumType type);
129 
135 char *cr_get_filename(const char *filepath);
136 
137 #define CR_COPY_OK 0
138 #define CR_COPY_ERR 1
149 void cr_download(CURL *handle,
150  const char *url,
151  const char *destination,
152  char **error);
153 
159 int cr_copy_file(const char *src, const char *dst);
160 
169 int cr_compress_file(const char *src,
170  const char *dst,
171  cr_CompressionType compression);
172 
178 int cr_better_copy_file(const char *src, const char *dst);
179 
184 int cr_remove_dir(const char *path);
185 
190 char *cr_normalize_dir_path(const char *path);
191 
196 struct cr_Version cr_str_to_version(const char *str);
197 
204 int cr_cmp_version_str(const char* str1, const char *str2);
205 
212 void cr_null_log_fn(const gchar *log_domain,
213  GLogLevelFlags log_level,
214  const gchar *message,
215  gpointer user_data);
216 
223 void cr_log_fn(const gchar *log_domain,
224  GLogLevelFlags log_level,
225  const gchar *message,
226  gpointer user_data);
227 
235 void cr_slist_free_full(GSList *list, GDestroyNotify free_f);
236 
241 struct cr_NVREA *cr_split_rpm_filename(const char *filename);
242 
246 void cr_nvrea_free(struct cr_NVREA *nvrea);
247 
253 #define cr_cmp_nvrea(A, B) (cr_cmp_evr((A)->epoch, (A)->version, (A)->release,\
254  (B)->epoch, (B)->version, (B)->release))
255 
265 int cr_cmp_evr(const char *e1, const char *v1, const char *r1,
266  const char *e2, const char *v2, const char *r2);
267 
270 #ifdef __cplusplus
271 }
272 #endif
273 
274 #endif /* __C_CREATEREPOLIB_MISC_H__ */