createrepo_c library
C library for metadata manipulation
Miscellaneous useful functions and macros.

Datové struktry

struct  cr_EVR
struct  cr_Version
struct  cr_HeaderRangeStruct

Definice maker

#define CR_UNUSED(x)   (void)(x)
#define cr_cmp_nvrea(A, B)

Funkce

const char * cr_flag_to_str (gint64 flags)
struct cr_EVR cr_str_to_evr (const char *string, GStringChunk *chunk)
char * cr_compute_file_checksum (const char *filename, cr_ChecksumType type)
struct cr_HeaderRangeStruct cr_get_header_byte_range (const char *filename)
const char * cr_checksum_name_str (cr_ChecksumType type)
char * cr_get_filename (const char *filepath)
void cr_download (CURL *handle, const char *url, const char *destination, char **error)
int cr_copy_file (const char *src, const char *dst)
int cr_compress_file (const char *src, const char *dst, cr_CompressionType compression)
int cr_better_copy_file (const char *src, const char *dst)
int cr_remove_dir (const char *path)
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)
int cr_cmp_evr (const char *e1, const char *v1, const char *r1, const char *e2, const char *v2, const char *r2)

Dokumentace k definicím maker

#define cr_cmp_nvrea (   A,
 
)
Hodnota:
(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.

Parametry:
Apointer to first cr_NVREA
Bpointer to second cr_NVREA
Návratová hodnota:
0 = same, 1 = first is newer, -1 = second is newer

Definice je uvedena na řádku 266 v souboru misc.h.

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

Macro for supress compiler warning about unused param.

Definice je uvedena na řádku 39 v souboru misc.h.


Dokumentace funkcí

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

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

Parametry:
srcsource filename
dstdestination (if dst is dir, filename of src is used)
Návratová hodnota:
CR_COPY_OK or CR_COPY_ERR on error
const char* cr_checksum_name_str ( cr_ChecksumType  type)

Return checksum name.

Parametry:
typechecksum type
Návratová hodnota:
constant null terminated string with checksum name or NULL on error
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. param e1 1. epoch param v1 1. version param r1 1. release param e2 2. epoch param v2 2. version param r2 2. release return 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.

Parametry:
str1first version string
str2second version string
Návratová hodnota:
0 - versions are same, 1 - first string is bigger version, 2 - second string is bigger version
int cr_compress_file ( const char *  src,
const char *  dst,
cr_CompressionType  compression 
)

Compress file.

Parametry:
srcsource filename
dstdestination (If dst is dir, filename of src + compression suffix is used. If dst is NULL, src + compression suffix is used)
compressiontype of compression
Návratová hodnota:
CR_COPY_OK or CR_COPY_ERR on error
char* cr_compute_file_checksum ( const char *  filename,
cr_ChecksumType  type 
)

Compute file checksum.

Parametry:
filenamefilename
typetype of checksum
Návratová hodnota:
malloced null terminated string with checksum or NULL on error
int cr_copy_file ( const char *  src,
const char *  dst 
)

Copy file.

Parametry:
srcsource filename
dstdestination (if dst is dir, filename of src is used)
Návratová hodnota:
CR_COPY_OK or CR_COPY_ERR on error
void cr_download ( CURL *  handle,
const char *  url,
const char *  destination,
char **  error 
)

Download a file from the URL into the in_dst via curl handle. If *error == NULL then download was successfull.

Parametry:
handleCURL handle
urlsource url
destinationdestination (if destination is dir, filename from the url is used)
errorpointer to string pointer for error message (mandatory argument!)
const char* cr_flag_to_str ( gint64  flags)

Convert flags from RPM header to a string representation.

Parametry:
flagsflags
Návratová hodnota:
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")

Parametry:
filepathpath
Návratová hodnota:
pointer into the path
struct cr_HeaderRangeStruct cr_get_header_byte_range ( const char *  filename) [read]

Return header byte range.

Parametry:
filenamefilename
Návratová hodnota:
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.

Parametry:
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 '/').

Parametry:
pathpath
Návratová hodnota:
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.

Parametry:
log_domainlogging domain
log_levellogging level
messagemessage
user_datauser data
int cr_remove_dir ( const char *  path)

Recursively remove directory.

Parametry:
pathfilepath
Návratová hodnota:
0 on success, nonzero on failure (errno is set)
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.

Parametry:
listpointer to GSList
free_fthe function to be called to free each element's data
struct cr_EVR cr_str_to_evr ( const char *  string,
GStringChunk *  chunk 
) [read]

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.

Parametry:
stringNULL terminated n-v-r string
chunkstring chunk for strings (optional - could be NULL)
Návratová hodnota:
filled NVR
struct cr_Version cr_str_to_version ( const char *  str) [read]

Convert version string into cr_Version struct.

Parametry:
strversion string
Návratová hodnota:
cr_Version