00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __C_CREATEREPOLIB_MISC_H__
00021 #define __C_CREATEREPOLIB_MISC_H__
00022
00023 #ifdef __cplusplus
00024 extern "C" {
00025 #endif
00026
00027 #include <glib.h>
00028 #include <string.h>
00029 #include <curl/curl.h>
00030 #include "compression_wrapper.h"
00031 #include "constants.h"
00032
00039 #define CR_UNUSED(x) (void)(x)
00040
00046 const char *cr_flag_to_str(gint64 flags);
00047
00051 struct cr_EVR {
00052 char *epoch;
00053 char *version;
00054 char *release;
00055 };
00056
00057 struct cr_NVREA {
00058 char *name;
00059 char *version;
00060 char *release;
00061 char *epoch;
00062 char *arch;
00063 };
00064
00069 struct cr_Version {
00070 long version;
00071 long release;
00072 long patch;
00073 char *suffix;
00074 };
00075
00076
00086 struct cr_EVR cr_str_to_evr(const char *string, GStringChunk *chunk);
00087
00094 static inline int cr_is_primary(const char *filename) {
00095 if (!strncmp(filename, "/etc/", 5))
00096 return 1;
00097 if (!strcmp(filename, "/usr/lib/sendmail"))
00098 return 1;
00099 if (strstr(filename, "bin/"))
00100 return 1;
00101 return 0;
00102 };
00103
00111 char *cr_compute_file_checksum(const char *filename, cr_ChecksumType type);
00112
00116 struct cr_HeaderRangeStruct {
00117 unsigned int start;
00118 unsigned int end;
00119 };
00120
00126 struct cr_HeaderRangeStruct cr_get_header_byte_range(const char *filename);
00127
00134 const char *cr_checksum_name_str(cr_ChecksumType type);
00135
00142 char *cr_get_filename(const char *filepath);
00143
00145 #define CR_COPY_OK 0
00146 #define CR_COPY_ERR 1
00159 void cr_download(CURL *handle,
00160 const char *url,
00161 const char *destination,
00162 char **error);
00163
00170 int cr_copy_file(const char *src, const char *dst);
00171
00181 int cr_compress_file(const char *src,
00182 const char *dst,
00183 cr_CompressionType compression);
00184
00191 int cr_better_copy_file(const char *src, const char *dst);
00192
00198 int cr_remove_dir(const char *path);
00199
00205 char *cr_normalize_dir_path(const char *path);
00206
00212 struct cr_Version cr_str_to_version(const char *str);
00213
00221 int cr_cmp_version_str(const char* str1, const char *str2);
00222
00230 void cr_null_log_fn(const gchar *log_domain,
00231 GLogLevelFlags log_level,
00232 const gchar *message,
00233 gpointer user_data);
00234
00242 void cr_log_fn(const gchar *log_domain,
00243 GLogLevelFlags log_level,
00244 const gchar *message,
00245 gpointer user_data);
00246
00255 void cr_slist_free_full(GSList *list, GDestroyNotify free_f);
00256
00257 struct cr_NVREA *cr_split_rpm_filename(const char *filename);
00258 void cr_nvrea_free(struct cr_NVREA *);
00259
00266 #define cr_cmp_nvrea(A, B) (cr_cmp_evr((A)->epoch, (A)->version, (A)->release,\
00267 (B)->epoch, (B)->version, (B)->release))
00268
00279 int cr_cmp_evr(const char *e1, const char *v1, const char *r1,
00280 const char *e2, const char *v2, const char *r2);
00281
00282 #ifdef __cplusplus
00283 }
00284 #endif
00285
00286 #endif