createrepo_c library  0.2.1
C library for metadata manipulation
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Miscellaneous useful functions and macros.

Data Structures

struct  cr_EVR
 
struct  cr_NVREA
 
struct  cr_Version
 
struct  cr_HeaderRangeStruct
 

Macros

#define CR_UNUSED(x)   (void)(x)
 
#define CR_STATICSTRLEN(s)   (sizeof(s)/sizeof(s[0]))
 
#define cr_compress_file(SRC, DST, COMTYPE, ERR)   cr_compress_file_with_stat(SRC, DST, COMTYPE, NULL, ERR)
 
#define cr_cmp_nvrea(A, B)
 

Functions

const char * cr_flag_to_str (gint64 flags)
 
struct cr_EVR cr_str_to_evr (const char *string, GStringChunk *chunk)
 
struct cr_HeaderRangeStruct cr_get_header_byte_range (const char *filename, GError **err)
 
char * cr_get_filename (const char *filepath)
 
int cr_download (CURL *handle, const char *url, const char *destination, GError **err)
 
int cr_copy_file (const char *src, const char *dst, GError **err)
 
int cr_compress_file_with_stat (const char *src, const char *dst, cr_CompressionType comtype, cr_ContentStat *stat, GError **err)
 
int cr_better_copy_file (const char *src, const char *dst, GError **err)
 
int cr_remove_dir (const char *path, GError **err)
 
char * cr_normalize_dir_path (const char *path)
 
struct cr_Version cr_str_to_version (const char *str)
 
int cr_cmp_version_str (const char *str1, const char *str2)
 
void cr_null_log_fn (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data)
 
void cr_log_fn (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data)
 
void cr_slist_free_full (GSList *list, GDestroyNotify free_f)
 
struct cr_NVREAcr_split_rpm_filename (const char *filename)
 
void cr_nvrea_free (struct cr_NVREA *nvrea)
 
int cr_cmp_evr (const char *e1, const char *v1, const char *r1, const char *e2, const char *v2, const char *r2)
 

Detailed Description

Macro Definition Documentation

#define cr_cmp_nvrea (   A,
 
)
Value:
(cr_cmp_evr((A)->epoch, (A)->version, (A)->release,\
(B)->epoch, (B)->version, (B)->release))

Compare evr of two cr_NVREA. Name and arch are ignored.

Parameters
Apointer to first cr_NVREA
Bpointer to second cr_NVREA
Returns
0 = same, 1 = first is newer, -1 = second is newer

Definition at line 262 of file misc.h.

#define cr_compress_file (   SRC,
  DST,
  COMTYPE,
  ERR 
)    cr_compress_file_with_stat(SRC, DST, COMTYPE, NULL, ERR)

Compress file.

Parameters
SRCsource filename
DSTdestination (If dst is dir, filename of src + compression suffix is used. If dst is NULL, src + compression suffix is used)
COMTYPEtype of compression
ERRGError **
Returns
cr_Error return code

Definition at line 159 of file misc.h.

#define CR_STATICSTRLEN (   s)    (sizeof(s)/sizeof(s[0]))

Lenght of static string (including last '\0' byte)

Definition at line 43 of file misc.h.

#define CR_UNUSED (   x)    (void)(x)

Macro for supress compiler warning about unused param.

Definition at line 39 of file misc.h.

Function Documentation

int cr_better_copy_file ( const char *  src,
const char *  dst,
GError **  err 
)

Better copy file. Source (src) could be remote address (http:// or ftp://).

Parameters
srcsource filename
dstdestination (if dst is dir, filename of src is used)
errGError **
Returns
cr_Error return code
int cr_cmp_evr ( const char *  e1,
const char *  v1,
const char *  r1,
const char *  e2,
const char *  v2,
const char *  r2 
)

Compare two version strings splited into evr chunks.

Parameters
e11. epoch
v11. version
r11. release
e22. epoch
v22. version
r22. release
Returns
0 = same, 1 = first is newer, -1 = second is newer
int cr_cmp_version_str ( const char *  str1,
const char *  str2 
)

Compare two version string.

Parameters
str1first version string
str2second version string
Returns
0 - versions are same, 1 - first string is bigger version, 2 - second string is bigger version
int cr_compress_file_with_stat ( const char *  src,
const char *  dst,
cr_CompressionType  comtype,
cr_ContentStat stat,
GError **  err 
)

Compress file.

Parameters
srcsource filename
dstdestination (If dst is dir, filename of src + compression suffix is used. If dst is NULL, src + compression suffix is used)
comtypetype of compression
statpointer to cr_ContentStat or NULL
errGError **
Returns
cr_Error return code
int cr_copy_file ( const char *  src,
const char *  dst,
GError **  err 
)

Copy file.

Parameters
srcsource filename
dstdestination (if dst is dir, filename of src is used)
errGError **
Returns
cr_Error return code
int cr_download ( CURL *  handle,
const char *  url,
const char *  destination,
GError **  err 
)

Download a file from the URL into the in_dst via curl handle.

Parameters
handleCURL handle
urlsource url
destinationdestination (if destination is dir, filename from the url is used)
errGError **
Returns
cr_Error
const char* cr_flag_to_str ( gint64  flags)

Convert flags from RPM header to a string representation.

Parameters
flagsflags
Returns
flags as constant string
char* cr_get_filename ( const char *  filepath)

Return pointer to the rest of string after last '/'. (e.g. for "/foo/bar" returns "bar")

Parameters
filepathpath
Returns
pointer into the path
struct cr_HeaderRangeStruct cr_get_header_byte_range ( const char *  filename,
GError **  err 
)

Return header byte range.

Parameters
filenamefilename
errGError **
Returns
header range (start = end = 0 on error)
void cr_log_fn ( const gchar *  log_domain,
GLogLevelFlags  log_level,
const gchar *  message,
gpointer  user_data 
)

Createrepo_c library standard logging function.

Parameters
log_domainlogging domain
log_levellogging level
messagemessage
user_datauser data
char* cr_normalize_dir_path ( const char *  path)

Normalize path (Path with exactly one trailing '/').

Parameters
pathpath
Returns
mallocated string with normalized path or NULL
void cr_null_log_fn ( const gchar *  log_domain,
GLogLevelFlags  log_level,
const gchar *  message,
gpointer  user_data 
)

Logging function with no output.

Parameters
log_domainlogging domain
log_levellogging level
messagemessage
user_datauser data
void cr_nvrea_free ( struct cr_NVREA nvrea)

Free struct cr_NVREA.

Parameters
nvreastruct cr_NVREA
int cr_remove_dir ( const char *  path,
GError **  err 
)

Recursively remove directory.

Parameters
pathfilepath
errGError **
Returns
cr_Error return code
void cr_slist_free_full ( GSList *  list,
GDestroyNotify  free_f 
)

Frees all the memory used by a GSList, and calls the specified destroy function on every element's data. This is the same function as g_slist_free_full(). The original function is implemented in glib since 2.28 but we need to support the older glib too.

Parameters
listpointer to GSList
free_fthe function to be called to free each element's data
struct cr_NVREA* cr_split_rpm_filename ( const char *  filename)

Split filename into the NVREA structure.

Parameters
filenamefilename
Returns
struct cr_NVREA
struct cr_EVR cr_str_to_evr ( const char *  string,
GStringChunk *  chunk 
)

Convert epoch-version-release string into cr_EVR structure. If no GStringChunk passed, all non NULL items in returned structure are malloced and in that case, you have to free all non-NULL element yourself.

Parameters
stringNULL terminated n-v-r string
chunkstring chunk for strings (optional - could be NULL)
Returns
filled NVR
struct cr_Version cr_str_to_version ( const char *  str)

Convert version string into cr_Version struct.

Parameters
strversion string
Returns
cr_Version