#define Z_DEFAULT_STRATEGY 0
*/
#define GZ_STRATEGY Z_DEFAULT_STRATEGY
-#define GZ_BUFFER_SIZE 131072 // 1024 * 128
+#define GZ_BUFFER_SIZE (1024*128)
#define BZ2_VERBOSITY 0
#define BZ2_WORK_FACTOR 30
magic_t myt = magic_open(MAGIC_MIME_TYPE);
magic_load(myt, NULL);
if (magic_check(myt, NULL) == -1) {
- g_critical(MODULE"detect_compression: magic_check() failed");
+ g_critical(MODULE"%s: magic_check() failed", __func__);
return type;
}
const char *mime_type = magic_file(myt, filename);
if (mime_type) {
- g_debug(MODULE"detect_compression: Detected mime type: %s", mime_type);
+ g_debug(MODULE"%s: Detected mime type: %s", __func__, mime_type);
if (g_str_has_suffix(mime_type, "gzip") ||
g_str_has_suffix(mime_type, "gunzip"))
type = NO_COMPRESSION;
}
} else {
- g_debug(MODULE"detect_compression: Mime type not detected!");
+ g_debug(MODULE"%s: Mime type not detected!", __func__);
}
magic_close(myt);
}
if (gzbuffer((gzFile) file->FILE, GZ_BUFFER_SIZE) == -1) {
- g_debug(MODULE"cw_open: gzbuffer() call failed");
+ g_debug(MODULE"%s: gzbuffer() call failed", __func__);
}
break;
va_end(vl);
if (ret < 0) {
- g_debug(MODULE"cw_printf: vasprintf() call failed");
+ g_debug(MODULE"%s: vasprintf() call failed", __func__);
return CW_ERR;
}
pri_pkg_xml = g_strndup((char *) xmlBufferContent(buf), (gsize) len);
} else {
pri_pkg_xml = NULL;
- g_critical(MODULE"process_node: xmlNodeDump() [primary.xml] failed");
+ g_critical(MODULE"%s: xmlNodeDump() [primary.xml] failed", __func__);
}
xmlBufferEmpty(buf);
fil_pkg_xml = g_strndup((char *) xmlBufferContent(buf), (gsize) len);
} else {
fil_pkg_xml = NULL;
- g_critical(MODULE"process_node: xmlNodeDump() [filelists.xml] failed");
+ g_critical(MODULE"%s: xmlNodeDump() [filelists.xml] failed", __func__);
}
xmlBufferEmpty(buf);
oth_pkg_xml = g_strndup((char *) xmlBufferContent(buf), (gsize) len);
} else {
oth_pkg_xml = NULL;
- g_critical(MODULE"process_node: xmlNodeDump() [other.xml] failed");
+ g_critical(MODULE"%s: xmlNodeDump() [other.xml] failed", __func__);
}
xmlBufferFree(buf);
}
if ( counter != 4 || !location_href || !checksum_type) {
- g_warning(MODULE"process_node: Bad xml data! Some information are missing (for package: %s)!", location_href);
+ g_warning(MODULE"%s: Bad xml data! Some information are missing (for package: %s)!", __func__, location_href);
g_free(pri_pkg_xml);
g_free(fil_pkg_xml);
g_free(oth_pkg_xml);
// Check if key already exists
if (g_hash_table_lookup(metadata, key)) {
- g_debug(MODULE"process_node: Warning: Key \"%s\" already exists in old metadata\n", key);
+ g_debug(MODULE"%s: Warning: Key \"%s\" already exists in old metadata\n", __func__, key);
g_free(pri_pkg_xml);
g_free(fil_pkg_xml);
g_free(oth_pkg_xml);
pri_ret = xmlTextReaderRead(pri_reader);
name = xmlTextReaderName(pri_reader);
if (g_strcmp0((char *) name, "package")) {
- g_warning(MODULE"parse_xml_metadata: Probably bad xml");
+ g_warning(MODULE"%s: Probably bad xml", __func__);
xmlFree(name);
return 0;
}
fil_ret = xmlTextReaderRead(fil_reader);
name = xmlTextReaderName(fil_reader);
if (g_strcmp0((char *) name, "package")) {
- g_warning(MODULE"parse_xml_metadata: Probably bad xml");
+ g_warning(MODULE"%s: Probably bad xml", __func__);
xmlFree(name);
return 0;
}
oth_ret = xmlTextReaderRead(oth_reader);
name = xmlTextReaderName(oth_reader);
if (g_strcmp0((char *) name, "package")) {
- g_warning(MODULE"parse_xml_metadata: Probably bad xml");
+ g_warning(MODULE"%s: Probably bad xml", __func__);
xmlFree(name);
return 0;
}
int load_compressed_xml_metadata(GHashTable *hashtable, const char *primary_xml_path, const char *filelists_xml_path, const char *other_xml_path)
{
if (!hashtable) {
- g_debug(MODULE"load_compressed_xml_metadata: No hash table passed");
+ g_debug(MODULE"%s: No hash table passed", __func__);
return 0;
}
!g_file_test(filelists_xml_path, flags) ||
!g_file_test(other_xml_path, flags))
{
- g_debug(MODULE"load_compressed_xml_metadata: One or more files don't exist");
+ g_debug(MODULE"%s: One or more files don't exist", __func__);
return 0;
}
CompressionType c_type;
c_type = detect_compression(primary_xml_path);
if (c_type == UNKNOWN_COMPRESSION || c_type == NO_COMPRESSION) {
- g_debug(MODULE"load_compressed_xml_metadata: Unknown compression");
+ g_debug(MODULE"%s: Unknown compression", __func__);
return 0;
}
NULL,
XML_PARSE_NOBLANKS);
if (!pri_reader) {
- g_critical(MODULE"load_compressed_xml_metadata: Reader for primary.xml.* file failed");
+ g_critical(MODULE"%s: Reader for primary.xml.* file failed", __func__);
cw_close(pri_xml_cwfile);
cw_close(fil_xml_cwfile);
cw_close(oth_xml_cwfile);
NULL,
XML_PARSE_NOBLANKS);
if (!fil_reader) {
- g_critical(MODULE"load_compressed_xml_metadata: Reader for filelists.xml.* file failed");
+ g_critical(MODULE"%s: Reader for filelists.xml.* file failed", __func__);
xmlFreeTextReader(pri_reader);
cw_close(fil_xml_cwfile);
cw_close(oth_xml_cwfile);
NULL,
XML_PARSE_NOBLANKS);
if (!oth_reader) {
- g_critical(MODULE"load_compressed_xml_metadata: Reader for other.xml.* file failed");
+ g_critical(MODULE"%s: Reader for other.xml.* file failed", __func__);
xmlFreeTextReader(pri_reader);
xmlFreeTextReader(fil_reader);
cw_close(oth_xml_cwfile);
int load_xml_metadata(GHashTable *hashtable, const char *primary_xml_path, const char *filelists_xml_path, const char *other_xml_path)
{
if (!hashtable) {
- g_debug(MODULE"load_xml_metadata: No hash table passed");
+ g_debug(MODULE"%s: No hash table passed", __func__);
return 0;
}
!g_file_test(filelists_xml_path, flags) ||
!g_file_test(other_xml_path, flags))
{
- g_debug(MODULE"load_xml_metadata: One or more files don't exist");
+ g_debug(MODULE"%s: One or more files don't exist", __func__);
return 0;
}
NULL,
XML_PARSE_NOBLANKS);
if (!pri_reader) {
- g_critical(MODULE"load_xml_metadata: Reader for primary.xml file failed");
+ g_critical(MODULE"%s: Reader for primary.xml file failed", __func__);
fclose(pri_xml_file);
fclose(fil_xml_file);
fclose(oth_xml_file);
NULL,
XML_PARSE_NOBLANKS);
if (!fil_reader) {
- g_critical(MODULE"load_xml_metadata: Reader for filelists.xml file failed");
+ g_critical(MODULE"%s: Reader for filelists.xml file failed", __func__);
xmlFreeTextReader(pri_reader);
fclose(fil_xml_file);
fclose(oth_xml_file);
}
if (!g_file_test(repomd, G_FILE_TEST_EXISTS)) {
- g_debug(MODULE"locate_metadata_via_repomd: %s doesn't exists", repomd);
+ g_debug(MODULE"%s: %s doesn't exists", __func__, repomd);
g_free(repomd);
return NULL;
}
ret = xmlTextReaderRead(reader);
name = xmlTextReaderName(reader);
if (g_strcmp0((char *) name, "repomd")) {
- g_warning(MODULE"locate_metadata_via_repomd: Bad xml - missing repomd element? (%s)", name);
+ g_warning(MODULE"%s: Bad xml - missing repomd element? (%s)", __func__, name);
xmlFree(name);
xmlFreeTextReader(reader);
g_free(repomd);
ret = xmlTextReaderRead(reader);
name = xmlTextReaderName(reader);
if (g_strcmp0((char *) name, "revision")) {
- g_warning(MODULE"locate_metadata_via_repomd: Bad xml - missing revision element? (%s)", name);
+ g_warning(MODULE"%s: Bad xml - missing revision element? (%s)", __func__, name);
xmlFree(name);
xmlFreeTextReader(reader);
g_free(repomd);
if (!ret) {
// No elements left -> Bad xml
- g_warning(MODULE"locate_metadata_vie_repomd: Bad xml - missing data elements?");
+ g_warning(MODULE"%s: Bad xml - missing data elements?", __func__);
xmlFreeTextReader(reader);
g_free(repomd);
return NULL;
GDir *repodir;
repodir = g_dir_open(full_repopath, 0, NULL);
if (!repodir) {
- g_debug(MODULE"remove_old_metadata: Path %s doesn't exists", repopath);
+ g_debug(MODULE"%s: Path %s doesn't exists", __func__, repopath);
return -1;
}
for (element=list; element; element=element->next) {
gchar *path = (char *) element->data;
- g_debug(MODULE"Removing: %s (path obtained from repomd.xml)", path);
+ g_debug("%s: Removing: %s (path obtained from repomd.xml)", __func__, path);
if (g_remove(path) == -1) {
- g_warning(MODULE"remove_old_metadata: Cannot remove %s", path);
+ g_warning("%s: remove_old_metadata: Cannot remove %s", __func__, path);
} else {
removed_files++;
}
gchar *path;
path = g_strconcat(full_repopath, file, NULL);
- g_debug(MODULE"Removing: %s", path);
+ g_debug(MODULE"%s: Removing: %s", __func__, path);
if (g_remove(path) == -1) {
- g_warning(MODULE"remove_old_metadata: Cannot remove %s", path);
+ g_warning(MODULE"%s: Cannot remove %s", __func__, path);
} else {
removed_files++;
}
// Check if file exists and if it is a regular file (not a directory)
if (!g_file_test(filename, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))) {
- g_critical(MODULE"compute_file_checksum: File %s doesn't exists", filename);
+ g_critical(MODULE"%s: File %s doesn't exists", __func__, filename);
return NULL;
}
gchecksumtype = G_CHECKSUM_SHA256;
break;
default:
- g_critical(MODULE"compute_file_checksum: Unknown checksum type");
+ g_critical(MODULE"%s: Unknown checksum type", __func__);
return NULL;
};
FILE *fp = fopen(filename, "rb");
if (!fp) {
- g_critical(MODULE"compute_file_checksum: Cannot open %s (%s)", filename, strerror(errno));
+ g_critical(MODULE"%s: Cannot open %s (%s)", __func__, filename, strerror(errno));
return NULL;
}
g_checksum_free(checksum);
if (!checksum_str) {
- g_critical(MODULE"compute_file_checksum: Cannot get checksum %s (low memory?)", filename);
+ g_critical(MODULE"%s: Cannot get checksum %s (low memory?)", __func__, filename);
}
return checksum_str;
FILE *fp = fopen(filename, "rb");
if (!fp) {
- g_critical(MODULE"get_header_byte_range: Cannot open file %s (%s)", filename, strerror(errno));
+ g_critical(MODULE"%s: Cannot open file %s (%s)", __func__, filename, strerror(errno));
return results;
}
// Get header range
if (fseek(fp, 104, SEEK_SET) != 0) {
- g_critical(MODULE"get_header_byte_range: fseek fail on %s (%s)", filename, strerror(errno));
+ g_critical(MODULE"%s: fseek fail on %s (%s)", __func__, filename, strerror(errno));
fclose(fp);
return results;
}
// Check sanity
if (hdrend < hdrstart) {
- g_critical(MODULE"get_header_byte_range: sanity check fail on %s (%d > %d))", filename, hdrstart, hdrend);
+ g_critical(MODULE"%s: sanity check fail on %s (%d > %d))", __func__, filename, hdrstart, hdrend);
return results;
}
name = "sha256";
break;
default:
- g_debug(MODULE"get_checksum_name_str: Unknown checksum");
+ g_debug(MODULE"%s: Unknown checksum", __func__);
break;
}
FILE *new;
if ((orig = fopen(src, "r")) == NULL) {
- g_debug(MODULE"copy_file: Cannot open source file %s (%s)", src, strerror(errno));
+ g_debug(MODULE"%s: Cannot open source file %s (%s)", __func__, src, strerror(errno));
return CR_COPY_ERR;
}
if ((new = fopen(dst, "w")) == NULL) {
- g_debug(MODULE"copy_file: Cannot open destination file %s (%s)", dst, strerror(errno));
+ g_debug(MODULE"%s: Cannot open destination file %s (%s)", __func__, dst, strerror(errno));
fclose(orig);
return CR_COPY_ERR;
}
while ((readed = fread(buf, 1, BUFFER_SIZE, orig)) > 0) {
if (fwrite(buf, 1, readed, new) != readed) {
- g_debug(MODULE"copy_file: Error while copy %s -> %s (%s)", src, dst, strerror(errno));
+ g_debug(MODULE"%s: Error while copy %s -> %s (%s)", __func__, src, dst, strerror(errno));
fclose(new);
fclose(orig);
return CR_COPY_ERR;
}
if (readed != BUFFER_SIZE && ferror(orig)) {
- g_debug(MODULE"copy_file: Error while copy %s -> %s (%s)", src, dst, strerror(errno));
+ g_debug(MODULE"%s: Error while copy %s -> %s (%s)", __func__, src, dst, strerror(errno));
fclose(new);
fclose(orig);
return CR_COPY_ERR;
rpmReadConfigFiles(NULL, NULL);
ts = rpmtsCreate();
if (!ts) {
- g_critical(MODULE"init_package_parser: rpmtsCreate() failed");
+ g_critical(MODULE"%s: rpmtsCreate() failed", __func__);
}
rpmVSFlags vsflags = 0;
checksum_type_str = "sha256";
break;
default:
- g_critical(MODULE"Unknown checksum type");
+ g_critical(MODULE"%s: Unknown checksum type", __func__);
return result;
break;
};
FD_t fd = NULL;
fd = Fopen(filename, "r.ufdio");
if (!fd) {
- g_critical(MODULE"xml_from_package_file: Fopen failed %s", strerror(errno));
+ g_critical(MODULE"%s: Fopen failed %s", __func__, strerror(errno));
return result;
}
if (rc != RPMRC_OK) {
switch (rc) {
case RPMRC_NOKEY:
- g_debug(MODULE"xml_from_package_file: %s: Public key is unavailable.", filename);
+ g_debug(MODULE"%s: %s: Public key is unavailable.", __func__, filename);
break;
case RPMRC_NOTTRUSTED:
- g_debug(MODULE"xml_from_package_file: %s: Signature is OK, but key is not trusted.", filename);
+ g_debug(MODULE"%s: %s: Signature is OK, but key is not trusted.", __func__, filename);
break;
default:
- g_critical(MODULE"xml_from_package_file: rpmReadPackageFile() error (%s)", strerror(errno));
+ g_critical(MODULE"%s: rpmReadPackageFile() error (%s)", __func__, strerror(errno));
return result;
}
}
if (!stat_buf) {
struct stat stat_buf_own;
if (stat(filename, &stat_buf_own) == -1) {
- g_critical(MODULE"xml_from_package_file: stat() error (%s)", strerror(errno));
+ g_critical(MODULE"%s: stat() error (%s)", __func__, strerror(errno));
return result;
}
mtime = stat_buf_own.st_mtime;
gchecksumtype = G_CHECKSUM_SHA256;
break;
default:
- g_critical(MODULE"get_compressed_content_stat: Unknown checksum type");
+ g_critical(MODULE"%s: Unknown checksum type", __func__);
return NULL;
};
GChecksum *checksum = g_checksum_new(gchecksumtype);
if (!checksum) {
- g_critical(MODULE"get_compressed_content_stat: g_checksum_new() failed");
+ g_critical(MODULE"%s: g_checksum_new() failed", __func__);
return NULL;
}
if (!g_file_test(path, G_FILE_TEST_EXISTS|G_FILE_TEST_IS_REGULAR)) {
// File doesn't exists
- g_warning(MODULE"fill_missing_data: File %s doesn't exists", path);
+ g_warning(MODULE"%s: File %s doesn't exists", __func__, path);
return REPOMD_ERR;
}
g_free(open_stat);
} else {
// Unknown compression
- g_warning(MODULE"File \"%s\" compressed by an unsupported type of compression", path);
+ g_warning(MODULE"%s: File \"%s\" compressed by an unsupported type of compression", __func__, path);
md->checksum_open_type = g_string_chunk_insert(md->chunk, "UNKNOWN");
md->checksum_open = g_string_chunk_insert(md->chunk, "file_compressed_by_an_unsupported_type_of_compression");
md->size_open = -1;
md->size = buf.st_size;
}
} else {
- g_warning(MODULE"Stat on file \"%s\" failed", path);
+ g_warning(MODULE"%s: Stat on file \"%s\" failed", __func__, path);
}
}
if (!g_file_test(path, G_FILE_TEST_EXISTS|G_FILE_TEST_IS_REGULAR)) {
// File doesn't exists
- g_warning(MODULE"process_groupfile: File %s doesn't exists", path);
+ g_warning(MODULE"%s: File %s doesn't exists", __func__, path);
g_free(path);
g_free(cpath);
return;
while ((readed = cw_read(cw_plain, buf, BUFFER_SIZE)) > 0) {
if (cw_write(cw_compressed, buf, (unsigned int) readed) == CW_ERR) {
- g_debug(MODULE"process_groupfile: Error while groupfile compression");
+ g_debug(MODULE"%s: Error while groupfile compression", __func__);
break;
}
}
cw_close(cw_plain);
if (readed == CW_ERR) {
- g_debug(MODULE"process_groupfile: Error while groupfile compression");
+ g_debug(MODULE"%s: Error while groupfile compression", __func__);
}
struct stat gf_stat, cgf_stat;
if (stat(path, &gf_stat)) {
- g_debug(MODULE"process_groupfile: Error while stat() on %s", path);
+ g_debug(MODULE"%s: Error while stat() on %s", __func__, path);
} else {
gf_size = gf_stat.st_size;
gf_time = gf_stat.st_mtime;
}
if (stat(cpath, &cgf_stat)) {
- g_debug(MODULE"process_groupfile: Error while stat() on %s", path);
+ g_debug(MODULE"%s: Error while stat() on %s", __func__, path);
} else {
cgf_size = cgf_stat.st_size;
cgf_time = cgf_stat.st_mtime;
{
xmlBufferPtr buf = xmlBufferCreate();
if (!buf) {
- g_critical(MODULE"Error creating the xml buffer");
+ g_critical(MODULE"%s: Error creating the xml buffer", __func__);
return NULL;
}
xmlTextWriterPtr writer = xmlNewTextWriterMemory(buf, 0);
if (writer == NULL) {
- g_critical(MODULE"Error creating the xml writer");
+ g_critical(MODULE"%s: Error creating the xml writer", __func__);
return NULL;
}
rc = xmlTextWriterStartDocument(writer, NULL, "UTF-8", NULL);
if (rc < 0) {
- g_critical(MODULE"Error at xmlTextWriterStartDocument\n");
+ g_critical(MODULE"%s: Error at xmlTextWriterStartDocument\n", __func__);
return NULL;
}
rc = xmlTextWriterStartElement(writer, BAD_CAST "repomd");
if (rc < 0) {
- g_critical(MODULE"Error at xmlTextWriterStartElement repomd\n");
+ g_critical(MODULE"%s: Error at xmlTextWriterStartElement repomd\n", __func__);
return NULL;
}
xmlTextWriterWriteAttribute(writer, BAD_CAST "xmlns:rpm", (xmlChar *) RPM_NS);
rc = xmlTextWriterStartElement(writer, BAD_CAST "revision");
if (rc < 0) {
- g_critical(MODULE"Error at xmlTextWriterStartElement revision\n");
+ g_critical(MODULE"%s: Error at xmlTextWriterStartElement revision\n", __func__);
return NULL;
}
// Rename
if (g_file_test (new_path, G_FILE_TEST_EXISTS)) {
if (remove(new_path)) {
- g_critical(MODULE"rename_file: Cannot delete old %s", new_path);
+ g_critical(MODULE"%s: Cannot delete old %s", __func__, new_path);
g_free(path);
g_free(new_location_href);
g_free(new_path);
}
}
if (rename(path, new_path)) {
- g_critical(MODULE"rename_file: Cannot rename %s to %s", path, new_path);
+ g_critical(MODULE"%s: Cannot rename %s to %s", __func__, path, new_path);
g_free(path);
g_free(new_location_href);
g_free(new_path);
char *result;
xmlBufferPtr buf = xmlBufferCreate();
if (buf == NULL) {
- g_critical(MODULE"xml_dump_filelists: Error creating the xml buffer");
+ g_critical(MODULE"%s: Error creating the xml buffer", __func__);
return NULL;
}
// Seems to be little bit faster than xmlDocDumpFormatMemory
char *result;
xmlBufferPtr buf = xmlBufferCreate();
if (buf == NULL) {
- g_critical(MODULE"xml_dump_other: Error creating the xml buffer");
+ g_critical(MODULE"%s: Error creating the xml buffer", __func__);
return NULL;
}
// Seems to be little bit faster than xmlDocDumpFormatMemory
void dump_pco(xmlNodePtr root, Package *package, int pcotype)
{
- const char *elem_name = NULL;
+ const char *elem_name;
GSList *files = NULL;
const char *provides = "rpm:provides";
char *result;
xmlBufferPtr buf = xmlBufferCreate();
if (buf == NULL) {
- g_critical(MODULE"xml_dump_other: Error creating the xml buffer");
+ g_critical(MODULE"%s: Error creating the xml buffer", __func__);
return NULL;
}
// Seems to be little bit faster than xmlDocDumpFormatMemory