CR_FILE *file = NULL;
cr_CompressionType type;
+ assert(mode < CR_CW_MODE_SENTINEL);
+ assert(comtype < CR_CW_COMPRESSION_SENTINEL);
+
if (!filename || (mode != CR_CW_MODE_READ && mode != CR_CW_MODE_WRITE)) {
g_debug("%s: Filename is NULL or bad mode value", __func__);
return NULL;
int
cr_read(CR_FILE *cr_file, void *buffer, unsigned int len)
{
- if (!cr_file || !buffer || cr_file->mode != CR_CW_MODE_READ) {
- return CR_CW_ERR;
- }
-
-
int bzerror;
int ret;
+ assert(cr_file);
+ assert(buffer);
+
+ if (cr_file->mode != CR_CW_MODE_READ)
+ return CR_CW_ERR;
+
switch (cr_file->type) {
case (CR_CW_NO_COMPRESSION): // ----------------------------------------
int bzerror;
int ret = CR_CW_ERR;
- if (!cr_file || !buffer || cr_file->mode != CR_CW_MODE_WRITE) {
+ assert(cr_file);
+ assert(buffer);
+
+ if (cr_file->mode != CR_CW_MODE_WRITE)
return ret;
- }
switch (cr_file->type) {
int
cr_puts(CR_FILE *cr_file, const char *str)
{
- if (!cr_file || !str || cr_file->mode != CR_CW_MODE_WRITE) {
- return CR_CW_ERR;
- }
-
-
size_t len;
int bzerror;
int ret = CR_CW_ERR;
+ assert(cr_file);
+
+ if (!str || cr_file->mode != CR_CW_MODE_WRITE)
+ return CR_CW_ERR;
+
switch (cr_file->type) {
case (CR_CW_NO_COMPRESSION): // ----------------------------------------
int
cr_printf(CR_FILE *cr_file, const char *format, ...)
{
- if (!cr_file || !format || cr_file->mode != CR_CW_MODE_WRITE) {
+ va_list vl;
+ int ret;
+ gchar *buf = NULL;
+
+ assert(cr_file);
+
+ if (!format || cr_file->mode != CR_CW_MODE_WRITE)
return CR_CW_ERR;
- }
- va_list vl;
va_start(vl, format);
// Fill format string
- int ret;
- gchar *buf = NULL;
ret = g_vasprintf(&buf, format, vl);
va_end(vl);
CR_CW_GZ_COMPRESSION, /*!< Gzip compression */
CR_CW_BZ2_COMPRESSION, /*!< BZip2 compression */
CR_CW_XZ_COMPRESSION, /*!< XZ compression */
+ CR_CW_COMPRESSION_SENTINEL, /*!< Sentinel of the list */
} cr_CompressionType;
/** Open modes.
*/
typedef enum {
- CR_CW_MODE_READ, /*!< Read mode */
- CR_CW_MODE_WRITE /*!< Write mode */
+ CR_CW_MODE_READ, /*!< Read mode */
+ CR_CW_MODE_WRITE, /*!< Write mode */
+ CR_CW_MODE_SENTINEL, /*!< Sentinel of the list */
} cr_OpenMode;