20 #ifndef __C_CREATEREPOLIB_MISC_H__
21 #define __C_CREATEREPOLIB_MISC_H__
29 #include <curl/curl.h>
30 #include "compression_wrapper.h"
31 #include "xml_parser.h"
40 #define CR_UNUSED(x) (void)(x)
44 #define CR_STATICSTRLEN(s) (sizeof(s)/sizeof(s[0]))
48 #define CR_ARRAYLEN(x) ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x])))))
100 static inline int cr_is_primary(
const char *filename) {
101 if (!strncmp(filename,
"/etc/", 5))
103 if (!strcmp(filename,
"/usr/lib/sendmail"))
105 if (strstr(filename,
"bin/"))
142 const char *destination,
164 #define cr_compress_file(SRC, DST, COMTYPE, ERR) \
165 cr_compress_file_with_stat(SRC, DST, COMTYPE, NULL, ERR)
193 #define cr_decompress_file(SRC, DST, COMTYPE, ERR) \
194 cr_decompress_file_with_stat(SRC, DST, COMTYPE, NULL, ERR)
257 GLogLevelFlags log_level,
258 const gchar *message,
268 GLogLevelFlags log_level,
269 const gchar *message,
297 #define cr_cmp_nvrea(A, B) (cr_cmp_evr((A)->epoch, (A)->version, (A)->release,\
298 (B)->epoch, (B)->version, (B)->release))
309 int cr_cmp_evr(
const char *e1,
const char *v1,
const char *r1,
310 const char *e2,
const char *v2,
const char *r2);
318 static inline gchar *
319 cr_safe_string_chunk_insert(GStringChunk *chunk,
const char *str)
321 if (!str)
return NULL;
322 return g_string_chunk_insert(chunk, str);
330 static inline gchar *
331 cr_safe_string_chunk_insert_and_free(GStringChunk *chunk,
char *str)
333 if (!str)
return NULL;
334 gchar *copy = g_string_chunk_insert(chunk, str);
345 static inline gchar *
346 cr_safe_string_chunk_insert_null(GStringChunk *chunk,
const char *str)
348 if (!str || *str ==
'\0')
return NULL;
349 return g_string_chunk_insert(chunk, str);
358 static inline gchar *
359 cr_safe_string_chunk_insert_const(GStringChunk *chunk,
const char *str)
361 if (!str)
return NULL;
362 return g_string_chunk_insert_const(chunk, str);
365 static inline gboolean
366 cr_key_file_get_boolean_default(GKeyFile *key_file,
367 const gchar *group_name,
369 gboolean default_value,
372 GError *tmp_err = NULL;
373 gboolean ret = g_key_file_get_boolean(key_file, group_name, key, &tmp_err);
375 g_propagate_error(error, tmp_err);
376 return default_value;
418 cr_cp(
const char *src,
421 const char *working_directory,
440 cr_rm(
const char *path,
442 const char *working_dir,