find_package(Libmagic REQUIRED)
find_package(LibXml2 REQUIRED)
find_package(LZMA REQUIRED)
+find_package(OpenSSL REQUIRED)
find_package(Sqlite3 REQUIRED)
find_package(ZLIB REQUIRED)
* libxml2 (http://xmlsoft.org/) - libxml2-devel/libxml2-dev
* python (http://python.org/) - python2-devel/libpython2.7-dev
* rpm (http://www.rpm.org/) - rpm-devel/librpm-dev
+* openssl (http://www.openssl.org/) - openssl-devel/libssl-dev
* sqlite3 (https://sqlite.org/) - sqlite-devel/libsqlite3-dev
* xz (http://tukaani.org/xz/) - xz-devel/liblzma-dev
* zlib (http://www.zlib.net/) - zlib-devel/zlib1g-dev
SET (createrepo_c_SRCS
+ checksum.c
compression_wrapper.c
error.c
load_metadata.c
xml_parser_primary.c)
SET(headers
+ checksum.h
compression_wrapper.h
constants.h
createrepo_c.h
TARGET_LINK_LIBRARIES(libcreaterepo_c ${Libmagic_LIBRARY})
TARGET_LINK_LIBRARIES(libcreaterepo_c ${LIBXML2_LIBRARIES})
TARGET_LINK_LIBRARIES(libcreaterepo_c ${LZMA_LIBRARIES})
+TARGET_LINK_LIBRARIES(libcreaterepo_c ${OPENSSL_LIBRARIES})
TARGET_LINK_LIBRARIES(libcreaterepo_c ${RPMDB_LIBRARY})
TARGET_LINK_LIBRARIES(libcreaterepo_c ${SQLITE3_LIBRARIES})
TARGET_LINK_LIBRARIES(libcreaterepo_c ${ZLIB_LIBRARY})
--- /dev/null
+/* createrepo_c - Library of routines for manipulation with repodata
+ * Copyright (C) 2013 Tomas Mlcoch
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ * USA.
+ */
+
+#include <glib.h>
+#include <glib/gprintf.h>
+#include <assert.h>
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
+#include <openssl/evp.h>
+#include "error.h"
+#include "checksum.h"
+
+#define MAX_CHECKSUM_NAME_LEN 7
+#define BUFFER_SIZE 2048
+
+struct _cr_ChecksumCtx {
+ EVP_MD_CTX *ctx;
+ cr_ChecksumType type;
+};
+
+cr_ChecksumType
+cr_checksum_type(const char *name)
+{
+ size_t len;
+ char name_lower[MAX_CHECKSUM_NAME_LEN+1];
+
+ if (!name)
+ return CR_CHECKSUM_UNKNOWN;
+
+ len = strlen(name);
+ if (len > MAX_CHECKSUM_NAME_LEN)
+ return CR_CHECKSUM_UNKNOWN;
+
+ for (size_t x = 0; x <= len; x++)
+ name_lower[x] = tolower(name[x]);
+
+ if (!strncmp(name_lower, "md", 2)) {
+ // MD* family
+ if (name_lower[2] == '2')
+ return CR_CHECKSUM_MD2;
+ else if (name_lower[2] == '5')
+ return CR_CHECKSUM_MD5;
+ } else if (!strncmp(name_lower, "sha", 3)) {
+ // SHA* family
+ char *sha_type = name_lower + 3;
+ if (!strcmp(sha_type, ""))
+ return CR_CHECKSUM_SHA1;
+ else if (!strcmp(sha_type, "1"))
+ return CR_CHECKSUM_SHA1;
+ else if (!strcmp(sha_type, "224"))
+ return CR_CHECKSUM_SHA224;
+ else if (!strcmp(sha_type, "256"))
+ return CR_CHECKSUM_SHA256;
+ else if (!strcmp(sha_type, "384"))
+ return CR_CHECKSUM_SHA384;
+ else if (!strcmp(sha_type, "512"))
+ return CR_CHECKSUM_SHA512;
+ }
+
+ return CR_CHECKSUM_UNKNOWN;
+}
+
+const char *
+cr_checksum_name_str(cr_ChecksumType type)
+{
+ switch (type) {
+ case CR_CHECKSUM_UNKNOWN:
+ return "Unknown checksum";
+// case CR_CHECKSUM_MD2:
+// return "md2";
+ case CR_CHECKSUM_MD5:
+ return "md5";
+ case CR_CHECKSUM_SHA:
+ return "sha";
+ case CR_CHECKSUM_SHA1:
+ return "sha1";
+ case CR_CHECKSUM_SHA224:
+ return "sha224";
+ case CR_CHECKSUM_SHA256:
+ return "sha256";
+ case CR_CHECKSUM_SHA384:
+ return "sha384";
+ case CR_CHECKSUM_SHA512:
+ return "sha512";
+ }
+ return NULL;
+}
+
+char *
+cr_checksum_file(const char *filename,
+ cr_ChecksumType type,
+ GError **err)
+{
+ FILE *f;
+ int rc;
+ unsigned int len;
+ ssize_t readed;
+ char buf[BUFFER_SIZE];
+ unsigned char raw_checksum[EVP_MAX_MD_SIZE];
+ char *checksum;
+ EVP_MD_CTX *ctx;
+ const EVP_MD *ctx_type;
+
+ switch (type) {
+ //case CR_CHECKSUM_MD2: ctx_type = EVP_md2(); break;
+ case CR_CHECKSUM_MD5: ctx_type = EVP_md5(); break;
+ case CR_CHECKSUM_SHA: ctx_type = EVP_sha(); break;
+ case CR_CHECKSUM_SHA1: ctx_type = EVP_sha1(); break;
+ case CR_CHECKSUM_SHA224: ctx_type = EVP_sha224(); break;
+ case CR_CHECKSUM_SHA256: ctx_type = EVP_sha256(); break;
+ case CR_CHECKSUM_SHA384: ctx_type = EVP_sha384(); break;
+ case CR_CHECKSUM_SHA512: ctx_type = EVP_sha512(); break;
+ case CR_CHECKSUM_UNKNOWN:
+ default:
+ g_set_error(err, CR_CHECKSUM_ERROR, CRE_UNKNOWNCHECKSUMTYPE,
+ "Unknown checksum type");
+ return NULL;
+ }
+
+ f = fopen(filename, "rb");
+ if (!f) {
+ g_set_error(err, CR_CHECKSUM_ERROR, CRE_IO,
+ "Cannot open a file: %s", strerror(errno));
+ return NULL;
+ }
+
+ ctx = EVP_MD_CTX_create();
+ rc = EVP_DigestInit_ex(ctx, ctx_type, NULL);
+ if (!rc) {
+ g_set_error(err, CR_CHECKSUM_ERROR, CRE_OPENSSL,
+ "EVP_DigestInit_ex() failed");
+ EVP_MD_CTX_destroy(ctx);
+ fclose(f);
+ return NULL;
+ }
+
+ while ((readed = fread(buf, 1, BUFFER_SIZE, f)) == BUFFER_SIZE)
+ EVP_DigestUpdate(ctx, buf, readed);
+
+ if (feof(f)) {
+ EVP_DigestUpdate(ctx, buf, readed);
+ } else {
+ g_set_error(err, CR_CHECKSUM_ERROR, CRE_IO,
+ "Error while reading a file: %s", strerror(errno));
+ EVP_MD_CTX_destroy(ctx);
+ fclose(f);
+ return NULL;
+ }
+
+ fclose(f);
+
+ EVP_DigestFinal_ex(ctx, raw_checksum, &len);
+ EVP_MD_CTX_destroy(ctx);
+ checksum = g_malloc0(sizeof(char) * (len * 2 + 1));
+ for (size_t x = 0; x < len; x++)
+ sprintf(checksum+(x*2), "%02x", raw_checksum[x]);
+
+ return checksum;
+}
+
+cr_ChecksumCtx *
+cr_checksum_new(cr_ChecksumType type, GError **err)
+{
+ int rc;
+ EVP_MD_CTX *ctx;
+ const EVP_MD *ctx_type;
+ cr_ChecksumCtx *cr_ctx;
+
+ assert(!err || *err == NULL);
+
+ switch (type) {
+ //case CR_CHECKSUM_MD2: ctx_type = EVP_md2(); break;
+ case CR_CHECKSUM_MD5: ctx_type = EVP_md5(); break;
+ case CR_CHECKSUM_SHA: ctx_type = EVP_sha(); break;
+ case CR_CHECKSUM_SHA1: ctx_type = EVP_sha1(); break;
+ case CR_CHECKSUM_SHA224: ctx_type = EVP_sha224(); break;
+ case CR_CHECKSUM_SHA256: ctx_type = EVP_sha256(); break;
+ case CR_CHECKSUM_SHA384: ctx_type = EVP_sha384(); break;
+ case CR_CHECKSUM_SHA512: ctx_type = EVP_sha512(); break;
+ case CR_CHECKSUM_UNKNOWN:
+ default:
+ g_set_error(err, CR_CHECKSUM_ERROR, CRE_UNKNOWNCHECKSUMTYPE,
+ "Unknown checksum type");
+ return NULL;
+ }
+
+ ctx = EVP_MD_CTX_create();
+ if (!ctx) {
+ g_set_error(err, CR_CHECKSUM_ERROR, CRE_OPENSSL,
+ "EVP_MD_CTX_create() failed");
+ return NULL;
+ }
+
+ if (!EVP_DigestInit_ex(ctx, ctx_type, NULL)) {
+ g_set_error(err, CR_CHECKSUM_ERROR, CRE_OPENSSL,
+ "EVP_DigestInit_ex() failed");
+ EVP_MD_CTX_destroy(ctx);
+ return NULL;
+ }
+
+ cr_ctx = g_malloc0(sizeof(cr_ChecksumCtx));
+ cr_ctx->ctx = ctx;
+ cr_ctx->type = type;
+
+ return cr_ctx;
+}
+
+int
+cr_checksum_update(cr_ChecksumCtx *ctx,
+ const void *buf,
+ size_t len,
+ GError **err)
+{
+ assert(ctx);
+ assert(!err || *err == NULL);
+
+ if (len == 0)
+ return CRE_OK;
+
+ if (EVP_DigestUpdate(ctx->ctx, buf, len)) {
+ g_set_error(err, CR_CHECKSUM_ERROR, CRE_OPENSSL,
+ "EVP_DigestInit_ex() failed");
+ return CRE_OPENSSL;
+ }
+
+ return CRE_OK;
+}
+
+char *
+cr_checksum_final(cr_ChecksumCtx *ctx, GError **err)
+{
+ unsigned int len;
+ unsigned char raw_checksum[EVP_MAX_MD_SIZE];
+ char *checksum;
+
+ assert(ctx);
+ assert(!err || *err == NULL);
+
+ if (!EVP_DigestFinal_ex(ctx->ctx, raw_checksum, &len)) {
+ g_set_error(err, CR_CHECKSUM_ERROR, CRE_OPENSSL,
+ "EVP_DigestFinal_ex() failed");
+ EVP_MD_CTX_destroy(ctx->ctx);
+ g_free(ctx);
+ return NULL;
+ }
+
+ EVP_MD_CTX_destroy(ctx->ctx);
+
+ checksum = g_malloc0(sizeof(char) * (len * 2 + 1));
+ for (size_t x = 0; x < len; x++)
+ sprintf(checksum+(x*2), "%02x", raw_checksum[x]);
+
+ g_free(ctx);
+
+ return checksum;
+}
--- /dev/null
+/* createrepo_c - Library of routines for manipulation with repodata
+ * Copyright (C) 2013 Tomas Mlcoch
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ * USA.
+ */
+
+#ifndef __C_CREATEREPOLIB_CHECKSUM_H__
+#define __C_CREATEREPOLIB_CHECKSUM_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** \defgroup checksum API for checksum calculation.
+ * \addtogroup checksum
+ * @{
+ */
+
+typedef struct _cr_ChecksumCtx cr_ChecksumCtx;
+
+/**
+ * Enum of supported checksum types.
+ */
+typedef enum {
+ CR_CHECKSUM_UNKNOWN, /*!< Unknown checksum */
+ CR_CHECKSUM_MD2, /*!< MD2 checksum */
+ CR_CHECKSUM_MD5, /*!< MD5 checksum */
+ CR_CHECKSUM_SHA, /*!< SHA checksum */
+ CR_CHECKSUM_SHA1, /*!< SHA1 checksum */
+ CR_CHECKSUM_SHA224, /*!< SHA224 checksum */
+ CR_CHECKSUM_SHA256, /*!< SHA256 checksum */
+ CR_CHECKSUM_SHA384, /*!< SHA384 checksum */
+ CR_CHECKSUM_SHA512, /*!< SHA512 checksum */
+ CR_CHECKSUM_SENTINEL, /*!< sentinel of the list */
+} cr_ChecksumType;
+
+/** Return checksum name.
+ * @param type checksum type
+ * @return constant null terminated string with checksum name
+ * or NULL on error
+ */
+const char *cr_checksum_name_str(cr_ChecksumType type);
+
+/** Return checksum type.
+ * @param name checksum name
+ * @return checksum type
+ */
+cr_ChecksumType cr_checksum_type(const char *name);
+
+/** Compute file checksum.
+ * @param filename filename
+ * @param type type of checksum
+ * @param err GError **
+ * @return malloced null terminated string with checksum
+ * or NULL on error
+ */
+char *cr_checksum_file(const char *filename,
+ cr_ChecksumType type,
+ GError **err);
+
+/** Create new checksum context.
+ * @param type Checksum algorithm of the new checksum context.
+ * @param err GError **
+ * @return cr_ChecksumCtx or NULL on error
+ */
+cr_ChecksumCtx *cr_checksum_new(cr_ChecksumType type, GError **err);
+
+/** Feeds data into the checksum.
+ * @param ctx Checksum context.
+ * @param buf Pointer to the data.
+ * @param len Length of the data.
+ * @param err GError **
+ * @return cr_Error code.
+ */
+int cr_checksum_update(cr_ChecksumCtx *ctx,
+ const void *buf,
+ size_t len,
+ GError **err);
+
+/** Finalize checksum calculation, return checksum string and frees
+ * all checksum context resources.
+ * @param ctx Checksum context.
+ * @param err GError **
+ * @return Checksum string or NULL on error.
+ */
+char *cr_checksum_final(cr_ChecksumCtx *ctx, GError **err);
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __C_CREATEREPOLIB_XML_PARSER_H__ */
// Check and set checksum type
if (options->checksum) {
- GString *checksum_str = g_string_ascii_down(g_string_new(options->checksum));
- if (!strcmp(checksum_str->str, "sha256")) {
- options->checksum_type = CR_CHECKSUM_SHA256;
- } else if (!strcmp(checksum_str->str, "sha1")) {
- options->checksum_type = CR_CHECKSUM_SHA1;
- } else if (!strcmp(checksum_str->str, "sha")) {
- options->checksum_type = CR_CHECKSUM_SHA1;
- } else if (!strcmp(checksum_str->str, "md5")) {
- options->checksum_type = CR_CHECKSUM_MD5;
- } else {
- g_string_free(checksum_str, TRUE);
+ cr_ChecksumType type;
+ type = cr_checksum_type(options->checksum);
+ if (type == CR_CHECKSUM_UNKNOWN) {
g_critical("Unknown/Unsupported checksum type \"%s\"", options->checksum);
return FALSE;
}
- g_string_free(checksum_str, TRUE);
+ options->checksum_type = type;
}
// Check and set compression type
#define __C_CREATEREPOLIB_CMD_PARSER_H__
#include <glib.h>
-#include "constants.h"
+#include "checksum.h"
#include "compression_wrapper.h"
* @{
*/
-/**
- * Checksum type.
- */
-typedef enum {
- CR_CHECKSUM_MD5, /*!< MD5 checksum */
- CR_CHECKSUM_SHA1, /*!< SHA1 checksum */
- CR_CHECKSUM_SHA256, /*!< SHA256 checksum */
- CR_CHECKSUM_SENTINEL, /*!< sentinel of the list */
-} cr_ChecksumType;
/** @} */
#include <fcntl.h>
#include "cmd_parser.h"
#include "compression_wrapper.h"
-#include "constants.h"
+#include "checksum.h"
#include "error.h"
#include "load_metadata.h"
#include "locate_metadata.h"
*/
#include <glib.h>
+#include "checksum.h"
#include "compression_wrapper.h"
-#include "constants.h"
#include "error.h"
#include "load_metadata.h"
#include "locate_metadata.h"
(21) Bzip2 library related error */
CRE_XZ, /*!<
(22) Xz (lzma) library related error */
+ CRE_OPENSSL, /*!<
+ (23) OpenSSL library related error */
} cr_Error;
/** Converts cr_Error return code to error string.
#include <rpm/rpmlib.h>
#include "error.h"
#include "logging.h"
-#include "constants.h"
#include "misc.h"
#define BUFFER_SIZE 4096
}
*/
-
-char *
-cr_compute_file_checksum(const char *filename,
- cr_ChecksumType type,
- GError **err)
-{
- GChecksumType gchecksumtype;
-
- assert(filename);
- assert(!err || *err == NULL);
-
- // Check if file exists and if it is a regular file (not a directory)
-
- if (!g_file_test(filename, G_FILE_TEST_IS_REGULAR)) {
- g_debug("%s: File %s doesn't exists or not a regular file",
- __func__, filename);
- g_set_error(err, CR_CHECKSUM_ERROR, CRE_NOFILE,
- "File %s doesn't exists or not a regular file", filename);
- return NULL;
- }
-
-
- // Convert our checksum type into glib type
-
- switch (type) {
- case CR_CHECKSUM_MD5:
- gchecksumtype = G_CHECKSUM_MD5;
- break;
- case CR_CHECKSUM_SHA1:
- gchecksumtype = G_CHECKSUM_SHA1;
- break;
- case CR_CHECKSUM_SHA256:
- gchecksumtype = G_CHECKSUM_SHA256;
- break;
- default:
- g_debug("%s: Unknown checksum type", __func__);
- g_set_error(err, CR_CHECKSUM_ERROR, CRE_UNKNOWNCHECKSUMTYPE,
- "Unknown checksum type: %d", type);
- return NULL;
- };
-
-
- // Open file and initialize checksum structure
-
- FILE *fp = fopen(filename, "rb");
- if (!fp) {
- g_critical("%s: Cannot open %s (%s)", __func__, filename,
- strerror(errno));
- g_set_error(err, CR_CHECKSUM_ERROR, CRE_IO,
- "Cannot open %s: %s", filename, strerror(errno));
- return NULL;
- }
-
-
- // Calculate checksum
-
- GChecksum *checksum = g_checksum_new(gchecksumtype);
- unsigned char buffer[BUFFER_SIZE];
-
- while (1) {
- size_t input_len;
- input_len = fread((void *) buffer, sizeof(unsigned char),
- BUFFER_SIZE, fp);
- g_checksum_update(checksum, (const guchar *) buffer, input_len);
- if (input_len < BUFFER_SIZE) {
- break;
- }
- }
-
- if (ferror(fp)) {
- g_set_error(err, CR_CHECKSUM_ERROR, CRE_IO,
- "fread call faied: %s", strerror(errno));
- fclose(fp);
- g_checksum_free(checksum);
- return NULL;
- }
-
- fclose(fp);
-
-
- // Get checksum
-
- char *checksum_str = g_strdup(g_checksum_get_string(checksum));
- g_checksum_free(checksum);
-
- if (!checksum_str) {
- g_critical("%s: Cannot get checksum %s (low memory?)", __func__,
- filename);
- g_set_error(err, CR_CHECKSUM_ERROR, CRE_MEMORY,
- "Cannot calculate checksum (low memory?)");
- }
-
- return checksum_str;
-}
-
-
-
#define VAL_LEN 4 // Len of numeric values in rpm
struct cr_HeaderRangeStruct
return results;
}
-
-const char *
-cr_checksum_name_str(cr_ChecksumType type)
-{
- char *name = NULL;
-
- switch (type) {
- case CR_CHECKSUM_MD5:
- name = "md5";
- break;
- case CR_CHECKSUM_SHA1:
- name = "sha";
- break;
- case CR_CHECKSUM_SHA256:
- name = "sha256";
- break;
- default:
- g_debug("%s: Unknown checksum (%d)", __func__, type);
- break;
- }
-
- return name;
-}
-
-
char *
cr_get_filename(const char *filepath)
{
#include <string.h>
#include <curl/curl.h>
#include "compression_wrapper.h"
-#include "constants.h"
/** \defgroup misc Miscellaneous useful functions and macros.
* \addtogroup misc
return 0;
};
-/** Compute file checksum.
- * @param filename filename
- * @param type type of checksum
- * @param err GError **
- * @return malloced null terminated string with checksum
- * or NULL on error
- */
-char *cr_compute_file_checksum(const char *filename,
- cr_ChecksumType type,
- GError **err);
-
/** Header range
*/
struct cr_HeaderRangeStruct {
*/
struct cr_HeaderRangeStruct cr_get_header_byte_range(const char *filename);
-/** Return checksum name.
- * @param type checksum type
- * @return constant null terminated string with checksum name
- * or NULL on error
- */
-const char *cr_checksum_name_str(cr_ChecksumType type);
-
/** Return pointer to the rest of string after last '/'.
* (e.g. for "/foo/bar" returns "bar")
* @param filepath path
#include <rpm/rpmkeyring.h>
#include "logging.h"
#include "error.h"
-#include "constants.h"
#include "parsehdr.h"
#include "misc.h"
-#include "parsehdr.h"
+#include "checksum.h"
volatile short cr_initialized = 0;
rpmts cr_ts = NULL;
assert(filename);
assert(!err || *err == NULL);
- // Set checksum type
-
- switch (checksum_type) {
- case CR_CHECKSUM_MD5:
- checksum_type_str = "md5";
- break;
- case CR_CHECKSUM_SHA1:
- checksum_type_str = "sha1";
- break;
- case CR_CHECKSUM_SHA256:
- checksum_type_str = "sha256";
- break;
- default:
- g_warning("%s: Unknown checksum type", __func__);
- g_set_error(err, CR_PARSEPKG_ERROR, CRE_UNKNOWNCHECKSUMTYPE,
- "Unknown/Unsupported checksum type: %d", checksum_type);
- return NULL;
- };
+ checksum_type_str = cr_checksum_name_str(checksum_type);
// Read header
// Compute checksum
- char *checksum = cr_compute_file_checksum(filename, checksum_type, &tmp_err);
+ char *checksum = cr_checksum_file(filename, checksum_type, &tmp_err);
if (tmp_err) {
g_propagate_prefixed_error(err, tmp_err,
- "Error while checksum calculation:");
+ "Error while checksum calculation: ");
headerFree(hdr);
return NULL;
}
result.filelists = NULL;
result.other = NULL;
+ checksum_type_str = cr_checksum_name_str(checksum_type);
- // Set checksum type
-
- switch (checksum_type) {
- case CR_CHECKSUM_MD5:
- checksum_type_str = "md5";
- break;
- case CR_CHECKSUM_SHA1:
- checksum_type_str = "sha1";
- break;
- case CR_CHECKSUM_SHA256:
- checksum_type_str = "sha256";
- break;
- default:
- g_warning("%s: Unknown checksum type", __func__);
- g_set_error(err, CR_PARSEPKG_ERROR, CRE_UNKNOWNCHECKSUMTYPE,
- "Unknown/Unsupported checksum type: %d", checksum_type);
- return result;
- };
-
- // Read header
+ // Read header
Header hdr;
read_header(filename, &hdr, &tmp_err);
// Compute checksum
- char *checksum = cr_compute_file_checksum(filename, checksum_type, NULL);
+ char *checksum = cr_checksum_file(filename, checksum_type, &tmp_err);
if (tmp_err) {
g_propagate_prefixed_error(err, tmp_err,
- "Error while checksum calculation:");
+ "Error while checksum calculation: ");
headerFree(hdr);
return result;
}
#endif
#include <glib.h>
-#include "constants.h"
+#include "checksum.h"
#include "package.h"
/** \defgroup parsepkg Package parser API.
#include "error.h"
#include "logging.h"
#include "misc.h"
+#include "checksum.h"
#include "repomd.h"
#include "compression_wrapper.h"
}
- // Create checksum structure
-
- GChecksumType gchecksumtype;
- switch (checksum_type) {
- case CR_CHECKSUM_MD5:
- gchecksumtype = G_CHECKSUM_MD5;
- break;
- case CR_CHECKSUM_SHA1:
- gchecksumtype = G_CHECKSUM_SHA1;
- break;
- case CR_CHECKSUM_SHA256:
- gchecksumtype = G_CHECKSUM_SHA256;
- break;
- default:
- g_critical("%s: Unknown checksum type", __func__);
- g_set_error(err, CR_REPOMD_RECORD_ERROR, CRE_UNKNOWNCHECKSUMTYPE,
- "Unknown checksum type: %d", checksum_type);
- return NULL;
- };
-
-
// Read compressed file and calculate checksum and size
- GChecksum *checksum = g_checksum_new(gchecksumtype);
- if (!checksum) {
+ cr_ChecksumCtx *checksum = cr_checksum_new(checksum_type, &tmp_err);
+ if (tmp_err) {
g_critical("%s: g_checksum_new() failed", __func__);
- g_set_error(err, CR_REPOMD_RECORD_ERROR, CRE_UNKNOWNCHECKSUMTYPE,
- "g_checksum_new() failed - Unknown checksum type");
+ g_propagate_prefixed_error(err, tmp_err,
+ "Error while checksum calculation: ");
return NULL;
}
filename);
break;
}
- g_checksum_update (checksum, buffer, readed);
+ cr_checksum_update(checksum, buffer, readed, NULL);
size += readed;
} while (readed == BUFFER_SIZE);
contentStat* result = g_malloc(sizeof(contentStat));
if (result) {
- result->checksum = g_strdup(g_checksum_get_string(checksum));
+ result->checksum = cr_checksum_final(checksum, NULL);
result->size = size;
} else {
g_set_error(err, CR_REPOMD_RECORD_ERROR, CRE_MEMORY,
"Cannot allocate memory");
}
-
- // Clean up
-
- g_checksum_free(checksum);
cr_close(cwfile, NULL);
return result;
if (!md->checksum_type || !md->checksum) {
gchar *chksum;
- chksum = cr_compute_file_checksum(path, checksum_t, &tmp_err);
+ chksum = cr_checksum_file(path, checksum_t, &tmp_err);
if (tmp_err) {
int code = tmp_err->code;
g_propagate_prefixed_error(err, tmp_err,
// Compute checksums
- checksum = cr_compute_file_checksum(path, checksum_type, &tmp_err);
+ checksum = cr_checksum_file(path, checksum_type, &tmp_err);
if (tmp_err) {
int code = tmp_err->code;
g_propagate_prefixed_error(err, tmp_err,
return code;
}
- cchecksum = cr_compute_file_checksum(cpath, checksum_type, &tmp_err);
+ cchecksum = cr_checksum_file(cpath, checksum_type, &tmp_err);
if (tmp_err) {
int code = tmp_err->code;
g_propagate_prefixed_error(err, tmp_err,
extern "C" {
#endif
+#include "checksum.h"
#include "compression_wrapper.h"
#include "package.h"
+ADD_EXECUTABLE(test_checksum test_checksum.c)
+TARGET_LINK_LIBRARIES(test_checksum libcreaterepo_c ${GLIB2_LIBRARIES})
+ADD_DEPENDENCIES(tests test_checksum)
+
ADD_EXECUTABLE(test_compression_wrapper test_compression_wrapper.c)
TARGET_LINK_LIBRARIES(test_compression_wrapper libcreaterepo_c ${GLIB2_LIBRARIES})
ADD_DEPENDENCIES(tests test_compression_wrapper)
#define TEST_MRF_UE_OTH_01 TEST_MODIFIED_REPO_FILES_PATH"unknown_element_01-other.xml"
#define TEST_MRF_UE_OTH_02 TEST_MODIFIED_REPO_FILES_PATH"unknown_element_02-other.xml"
+// Test files
+
+#define TEST_EMPTY_FILE TEST_FILES_PATH"empty_file"
+#define TEST_TEXT_FILE TEST_FILES_PATH"text_file"
+#define TEST_BINARY_FILE TEST_FILES_PATH"binary_file"
+
+// Other
+
+#define NON_EXIST_FILE "/tmp/foobarfile.which.should.not.exists"
+
#endif
--- /dev/null
+/* createrepo_c - Library of routines for manipulation with repodata
+ * Copyright (C) 2012 Tomas Mlcoch
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ * USA.
+ */
+
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include "fixtures.h"
+#include "createrepo/checksum.h"
+
+static void
+test_cr_checksum_file(void)
+{
+ char *checksum;
+ GError *tmp_err = NULL;
+
+ checksum = cr_checksum_file(TEST_EMPTY_FILE, CR_CHECKSUM_MD5, NULL);
+ g_assert_cmpstr(checksum, ==, "d41d8cd98f00b204e9800998ecf8427e");
+ g_free(checksum);
+ checksum = cr_checksum_file(TEST_EMPTY_FILE, CR_CHECKSUM_SHA1, NULL);
+ g_assert_cmpstr(checksum, ==, "da39a3ee5e6b4b0d3255bfef95601890afd80709");
+ g_free(checksum);
+ checksum = cr_checksum_file(TEST_EMPTY_FILE, CR_CHECKSUM_SHA256, NULL);
+ g_assert_cmpstr(checksum, ==, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649"
+ "b934ca495991b7852b855");
+ g_free(checksum);
+ checksum = cr_checksum_file(TEST_EMPTY_FILE, CR_CHECKSUM_SHA512, NULL);
+ g_assert_cmpstr(checksum, ==, "cf83e1357eefb8bdf1542850d66d8007d620e4050b5"
+ "715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd4741"
+ "7a81a538327af927da3e");
+ g_free(checksum);
+
+ checksum = cr_checksum_file(TEST_TEXT_FILE, CR_CHECKSUM_MD5, &tmp_err);
+ g_assert_cmpstr(checksum, ==, "d6d4da5c15f8fe7570ce6ab6b3503916");
+ g_assert(!tmp_err);
+ g_free(checksum);
+ checksum = cr_checksum_file(TEST_TEXT_FILE, CR_CHECKSUM_SHA1, &tmp_err);
+ g_assert_cmpstr(checksum, ==, "da048ee8fabfbef1b3d6d3f5a4be20029eecec77");
+ g_assert(!tmp_err);
+ g_free(checksum);
+ checksum = cr_checksum_file(TEST_TEXT_FILE, CR_CHECKSUM_SHA256, &tmp_err);
+ g_assert_cmpstr(checksum, ==, "2f395bdfa2750978965e4781ddf224c89646c7d7a15"
+ "69b7ebb023b170f7bd8bb");
+ g_assert(!tmp_err);
+ g_free(checksum);
+ checksum = cr_checksum_file(TEST_TEXT_FILE, CR_CHECKSUM_SHA512, &tmp_err);
+ g_assert_cmpstr(checksum, ==, "6ef7c2fd003614033aab59a65164c897fd150cfa855"
+ "1f2dd66828cc7a4d16afc3a35890f342eeaa424c1270fa8bbb4b792875b9deb34"
+ "cd78ab9ded1c360de45c");
+ g_assert(!tmp_err);
+ g_free(checksum);
+
+ checksum = cr_checksum_file(TEST_BINARY_FILE, CR_CHECKSUM_MD5, NULL);
+ g_assert_cmpstr(checksum, ==, "4f8b033d7a402927a20c9328fc0e0f46");
+ g_free(checksum);
+ checksum = cr_checksum_file(TEST_BINARY_FILE, CR_CHECKSUM_SHA1, NULL);
+ g_assert_cmpstr(checksum, ==, "3539fb660a41846352ac4fa9076d168a3c77070b");
+ g_free(checksum);
+ checksum = cr_checksum_file(TEST_BINARY_FILE, CR_CHECKSUM_SHA256, NULL);
+ g_assert_cmpstr(checksum, ==, "bf68e32ad78cea8287be0f35b74fa3fecd0eaa91770"
+ "b48f1a7282b015d6d883e");
+ g_free(checksum);
+ checksum = cr_checksum_file(TEST_BINARY_FILE, CR_CHECKSUM_SHA512, NULL);
+ g_assert_cmpstr(checksum, ==, "339877a8ce6cdb2df62f3f76c005cac4f50144197bd"
+ "095cec21056d6ddde570fe5b16e3f1cd077ece799d5dd23dc6c9c1afed018384d"
+ "840bd97233c320e60dfa");
+ g_free(checksum);
+
+ // Corner cases
+
+ checksum = cr_checksum_file(TEST_BINARY_FILE, 244, &tmp_err);
+ g_assert(!checksum);
+ g_assert(tmp_err);
+ g_error_free(tmp_err);
+ tmp_err = NULL;
+
+ checksum = cr_checksum_file(NON_EXIST_FILE, CR_CHECKSUM_MD5, &tmp_err);
+ g_assert(!checksum);
+ g_assert(tmp_err);
+ g_error_free(tmp_err);
+ tmp_err = NULL;
+}
+
+
+static void
+test_cr_checksum_name_str(void)
+{
+ const char *checksum_name;
+
+ checksum_name = cr_checksum_name_str(CR_CHECKSUM_MD5);
+ g_assert_cmpstr(checksum_name, ==, "md5");
+
+ checksum_name = cr_checksum_name_str(CR_CHECKSUM_SHA);
+ g_assert_cmpstr(checksum_name, ==, "sha");
+
+ checksum_name = cr_checksum_name_str(CR_CHECKSUM_SHA1);
+ g_assert_cmpstr(checksum_name, ==, "sha1");
+
+ checksum_name = cr_checksum_name_str(CR_CHECKSUM_SHA224);
+ g_assert_cmpstr(checksum_name, ==, "sha224");
+
+ checksum_name = cr_checksum_name_str(CR_CHECKSUM_SHA256);
+ g_assert_cmpstr(checksum_name, ==, "sha256");
+
+ checksum_name = cr_checksum_name_str(CR_CHECKSUM_SHA384);
+ g_assert_cmpstr(checksum_name, ==, "sha384");
+
+ checksum_name = cr_checksum_name_str(CR_CHECKSUM_SHA512);
+ g_assert_cmpstr(checksum_name, ==, "sha512");
+
+ checksum_name = cr_checksum_name_str(244);
+ g_assert_cmpstr(checksum_name, ==, NULL);
+}
+
+int
+main(int argc, char *argv[])
+{
+ g_test_init(&argc, &argv, NULL);
+
+ g_test_add_func("/checksum/test_cr_checksum_file",
+ test_cr_checksum_file);
+ g_test_add_func("/checksum/test_cr_checksum_name_str",
+ test_cr_checksum_name_str);
+
+ return g_test_run();
+}
#include <stdio.h>
#include <unistd.h>
#include "fixtures.h"
+#include "createrepo/checksum.h"
#include "createrepo/misc.h"
-
-#define EMPTY_FILE TEST_FILES_PATH"empty_file"
-#define TEXT_FILE TEST_FILES_PATH"text_file"
-#define BINARY_FILE TEST_FILES_PATH"binary_file"
-
#define PACKAGE_01 TEST_PACKAGES_PATH"super_kernel-6.0.1-2.x86_64.rpm"
#define PACKAGE_01_HEADER_START 280
#define PACKAGE_01_HEADER_END 2637
#define PACKAGE_02_HEADER_START 280
#define PACKAGE_02_HEADER_END 2057
-#define TMP_DIR_PATTERN "/tmp/createrepo_test_XXXXXX"
-#define NON_EXIST_FILE "/tmp/foobarfile.which.should.not.exists"
-
#define VALID_URL_01 "http://google.com/index.html"
#define URL_FILENAME_01 "index.html"
#define INVALID_URL "htp://foo.bar"
static void
-test_cr_compute_file_checksum(void)
-{
- char *checksum;
-
- checksum = cr_compute_file_checksum(EMPTY_FILE, CR_CHECKSUM_MD5, NULL);
- g_assert_cmpstr(checksum, ==, "d41d8cd98f00b204e9800998ecf8427e");
- g_free(checksum);
- checksum = cr_compute_file_checksum(EMPTY_FILE, CR_CHECKSUM_SHA1, NULL);
- g_assert_cmpstr(checksum, ==, "da39a3ee5e6b4b0d3255bfef95601890afd80709");
- g_free(checksum);
- checksum = cr_compute_file_checksum(EMPTY_FILE, CR_CHECKSUM_SHA256, NULL);
- g_assert_cmpstr(checksum, ==, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855");
- g_free(checksum);
-
- checksum = cr_compute_file_checksum(TEXT_FILE, CR_CHECKSUM_MD5, NULL);
- g_assert_cmpstr(checksum, ==, "d6d4da5c15f8fe7570ce6ab6b3503916");
- g_free(checksum);
- checksum = cr_compute_file_checksum(TEXT_FILE, CR_CHECKSUM_SHA1, NULL);
- g_assert_cmpstr(checksum, ==, "da048ee8fabfbef1b3d6d3f5a4be20029eecec77");
- g_free(checksum);
- checksum = cr_compute_file_checksum(TEXT_FILE, CR_CHECKSUM_SHA256, NULL);
- g_assert_cmpstr(checksum, ==, "2f395bdfa2750978965e4781ddf224c89646c7d7a1569b7ebb023b170f7bd8bb");
- g_free(checksum);
-
- checksum = cr_compute_file_checksum(BINARY_FILE, CR_CHECKSUM_MD5, NULL);
- g_assert_cmpstr(checksum, ==, "4f8b033d7a402927a20c9328fc0e0f46");
- g_free(checksum);
- checksum = cr_compute_file_checksum(BINARY_FILE, CR_CHECKSUM_SHA1, NULL);
- g_assert_cmpstr(checksum, ==, "3539fb660a41846352ac4fa9076d168a3c77070b");
- g_free(checksum);
- checksum = cr_compute_file_checksum(BINARY_FILE, CR_CHECKSUM_SHA256, NULL);
- g_assert_cmpstr(checksum, ==, "bf68e32ad78cea8287be0f35b74fa3fecd0eaa91770b48f1a7282b015d6d883e");
- g_free(checksum);
-
- // Corner cases
-
- checksum = cr_compute_file_checksum(BINARY_FILE, 244, NULL);
- g_assert(!checksum);
-
- checksum = cr_compute_file_checksum(NON_EXIST_FILE, CR_CHECKSUM_MD5, NULL);
- g_assert(!checksum);
-}
-
-
-static void
test_cr_get_header_byte_range(void)
{
struct cr_HeaderRangeStruct hdr_range;
static void
-test_cr_checksum_name_str(void)
-{
- const char *checksum_name;
-
- checksum_name = cr_checksum_name_str(CR_CHECKSUM_MD5);
- g_assert_cmpstr(checksum_name, ==, "md5");
-
- checksum_name = cr_checksum_name_str(CR_CHECKSUM_SHA1);
- g_assert_cmpstr(checksum_name, ==, "sha");
-
- checksum_name = cr_checksum_name_str(CR_CHECKSUM_SHA256);
- g_assert_cmpstr(checksum_name, ==, "sha256");
-
- checksum_name = cr_checksum_name_str(244);
- g_assert_cmpstr(checksum_name, ==, NULL);
-}
-
-
-static void
test_cr_get_filename(void)
{
char *filename;
copyfiletest_setup(Copyfiletest *copyfiletest, gconstpointer test_data)
{
CR_UNUSED(test_data);
- copyfiletest->tmp_dir = g_strdup(TMP_DIR_PATTERN);
+ copyfiletest->tmp_dir = g_strdup(TMPDIR_TEMPLATE);
mkdtemp(copyfiletest->tmp_dir);
copyfiletest->dst_file = g_strconcat(copyfiletest->tmp_dir, "/", DST_FILE, NULL);
}
char *checksum;
g_assert(!g_file_test(copyfiletest->dst_file, G_FILE_TEST_EXISTS));
- ret = cr_copy_file(EMPTY_FILE, copyfiletest->dst_file);
+ ret = cr_copy_file(TEST_EMPTY_FILE, copyfiletest->dst_file);
g_assert_cmpint(ret, ==, CR_COPY_OK);
g_assert(g_file_test(copyfiletest->dst_file, G_FILE_TEST_EXISTS|G_FILE_TEST_IS_REGULAR));
- checksum = cr_compute_file_checksum(copyfiletest->dst_file, CR_CHECKSUM_SHA256, NULL);
+ checksum = cr_checksum_file(copyfiletest->dst_file, CR_CHECKSUM_SHA256, NULL);
g_assert_cmpstr(checksum, ==, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855");
g_free(checksum);
}
char *checksum;
g_assert(!g_file_test(copyfiletest->dst_file, G_FILE_TEST_EXISTS));
- ret = cr_copy_file(TEXT_FILE, copyfiletest->dst_file);
+ ret = cr_copy_file(TEST_TEXT_FILE, copyfiletest->dst_file);
g_assert_cmpint(ret, ==, CR_COPY_OK);
g_assert(g_file_test(copyfiletest->dst_file, G_FILE_TEST_EXISTS|G_FILE_TEST_IS_REGULAR));
- checksum = cr_compute_file_checksum(copyfiletest->dst_file, CR_CHECKSUM_SHA256, NULL);
+ checksum = cr_checksum_file(copyfiletest->dst_file, CR_CHECKSUM_SHA256, NULL);
g_assert_cmpstr(checksum, ==, "2f395bdfa2750978965e4781ddf224c89646c7d7a1569b7ebb023b170f7bd8bb");
g_free(checksum);
}
char *checksum;
g_assert(!g_file_test(copyfiletest->dst_file, G_FILE_TEST_EXISTS));
- ret = cr_copy_file(BINARY_FILE, copyfiletest->dst_file);
+ ret = cr_copy_file(TEST_BINARY_FILE, copyfiletest->dst_file);
g_assert_cmpint(ret, ==, CR_COPY_OK);
g_assert(g_file_test(copyfiletest->dst_file, G_FILE_TEST_EXISTS|G_FILE_TEST_IS_REGULAR));
- checksum = cr_compute_file_checksum(copyfiletest->dst_file, CR_CHECKSUM_SHA256, NULL);
+ checksum = cr_checksum_file(copyfiletest->dst_file, CR_CHECKSUM_SHA256, NULL);
g_assert_cmpstr(checksum, ==, "bf68e32ad78cea8287be0f35b74fa3fecd0eaa91770b48f1a7282b015d6d883e");
g_free(checksum);
}
char *checksum;
g_assert(!g_file_test(copyfiletest->dst_file, G_FILE_TEST_EXISTS));
- ret = cr_copy_file(BINARY_FILE, copyfiletest->dst_file);
+ ret = cr_copy_file(TEST_BINARY_FILE, copyfiletest->dst_file);
g_assert_cmpint(ret, ==, CR_COPY_OK);
g_assert(g_file_test(copyfiletest->dst_file, G_FILE_TEST_EXISTS|G_FILE_TEST_IS_REGULAR));
- checksum = cr_compute_file_checksum(copyfiletest->dst_file, CR_CHECKSUM_SHA256, NULL);
+ checksum = cr_checksum_file(copyfiletest->dst_file, CR_CHECKSUM_SHA256, NULL);
g_assert_cmpstr(checksum, ==, "bf68e32ad78cea8287be0f35b74fa3fecd0eaa91770b48f1a7282b015d6d883e");
g_free(checksum);
- ret = cr_copy_file(TEXT_FILE, copyfiletest->dst_file);
+ ret = cr_copy_file(TEST_TEXT_FILE, copyfiletest->dst_file);
g_assert_cmpint(ret, ==, CR_COPY_OK);
g_assert(g_file_test(copyfiletest->dst_file, G_FILE_TEST_EXISTS|G_FILE_TEST_IS_REGULAR));
- checksum = cr_compute_file_checksum(copyfiletest->dst_file, CR_CHECKSUM_SHA256, NULL);
+ checksum = cr_checksum_file(copyfiletest->dst_file, CR_CHECKSUM_SHA256, NULL);
g_assert_cmpstr(checksum, ==, "2f395bdfa2750978965e4781ddf224c89646c7d7a1569b7ebb023b170f7bd8bb");
g_free(checksum);
}
char *checksum;
g_assert(!g_file_test(copyfiletest->dst_file, G_FILE_TEST_EXISTS));
- ret = cr_compress_file(TEXT_FILE, copyfiletest->dst_file, CR_CW_GZ_COMPRESSION);
+ ret = cr_compress_file(TEST_TEXT_FILE, copyfiletest->dst_file, CR_CW_GZ_COMPRESSION);
g_assert_cmpint(ret, ==, CR_COPY_OK);
g_assert(g_file_test(copyfiletest->dst_file, G_FILE_TEST_EXISTS|G_FILE_TEST_IS_REGULAR));
- checksum = cr_compute_file_checksum(copyfiletest->dst_file, CR_CHECKSUM_SHA256, NULL);
+ checksum = cr_checksum_file(copyfiletest->dst_file, CR_CHECKSUM_SHA256, NULL);
g_assert_cmpstr(checksum, ==, "8909fde88a5747d800fd2562b0f22945f014aa7df64cf1c15c7933ae54b72ab6");
g_free(checksum);
}
char *checksum;
g_assert(!g_file_test(copyfiletest->dst_file, G_FILE_TEST_EXISTS));
- ret = cr_better_copy_file(BINARY_FILE, copyfiletest->dst_file);
+ ret = cr_better_copy_file(TEST_BINARY_FILE, copyfiletest->dst_file);
g_assert_cmpint(ret, ==, CR_COPY_OK);
g_assert(g_file_test(copyfiletest->dst_file, G_FILE_TEST_EXISTS|G_FILE_TEST_IS_REGULAR));
- checksum = cr_compute_file_checksum(copyfiletest->dst_file, CR_CHECKSUM_SHA256, NULL);
+ checksum = cr_checksum_file(copyfiletest->dst_file, CR_CHECKSUM_SHA256, NULL);
g_assert_cmpstr(checksum, ==, "bf68e32ad78cea8287be0f35b74fa3fecd0eaa91770b48f1a7282b015d6d883e");
g_free(checksum);
}
char *subdir01, *subdir02, *subsubdir011, *subsubsubdir0111;
gchar *tmp_file_1, *tmp_file_2, *tmp_file_3;
- tmp_dir = g_strdup(TMP_DIR_PATTERN);
+ tmp_dir = g_strdup(TMPDIR_TEMPLATE);
g_assert(mkdtemp(tmp_dir));
subdir01 = g_strconcat(tmp_dir, "/subdir01", NULL);
g_test_add_func("/misc/test_cr_str_to_evr", test_cr_str_to_evr);
g_test_add_func("/misc/test_cr_str_to_evr_with_chunk", test_cr_str_to_evr_with_chunk);
g_test_add_func("/misc/test_cr_is_primary", test_cr_is_primary);
- g_test_add_func("/misc/test_cr_compute_file_checksum", test_cr_compute_file_checksum);
g_test_add_func("/misc/test_cr_get_header_byte_range", test_cr_get_header_byte_range);
- g_test_add_func("/misc/test_cr_checksum_name_str", test_cr_checksum_name_str);
g_test_add_func("/misc/test_cr_get_filename", test_cr_get_filename);
g_test_add("/misc/copyfiletest_test_empty_file", Copyfiletest, NULL, copyfiletest_setup, copyfiletest_test_empty_file, copyfiletest_teardown);
g_test_add("/misc/copyfiletest_test_text_file", Copyfiletest, NULL, copyfiletest_setup, copyfiletest_test_text_file, copyfiletest_teardown);