-struct PrimaryReStruct new_optimalized_primary_files_re()
+int is_primary(const char *filename)
{
- struct PrimaryReStruct res;
- GRegexMatchFlags compile_flags = G_REGEX_OPTIMIZE|G_REGEX_MATCH_ANCHORED;
- res.pri_re_1 = g_regex_new(".*bin/.*", compile_flags, 0, NULL);
- res.pri_re_2 = g_regex_new("/etc/.*", compile_flags, 0, NULL);
- res.pri_re_3 = g_regex_new("/usr/lib/sendmail$", compile_flags, 0, NULL);
- return res;
-}
-
-void free_optimalized_primary_files_re(struct PrimaryReStruct in) {
- g_regex_unref(in.pri_re_1);
- g_regex_unref(in.pri_re_2);
- g_regex_unref(in.pri_re_3);
-}
-
-int is_primary(const char *filename, struct PrimaryReStruct *user_re)
-{
-
- GRegex *pri_re_1 = NULL;
- GRegex *pri_re_2 = NULL;
- GRegex *pri_re_3 = NULL;
-
- if (!user_re) {
- GRegexMatchFlags compile_flags = G_REGEX_MATCH_ANCHORED;
- pri_re_1 = g_regex_new(".*bin/.*", compile_flags, 0, NULL);
- pri_re_2 = g_regex_new("/etc/.*", compile_flags, 0, NULL);
- pri_re_3 = g_regex_new("/usr/lib/sendmail$", compile_flags, 0, NULL);
- } else {
- pri_re_1 = user_re->pri_re_1;
- pri_re_2 = user_re->pri_re_2;
- pri_re_3 = user_re->pri_re_3;
+ if (!strncmp(filename, "/bin/", 5)) {
+ return 1;
}
- int ret = 0;
- if (g_regex_match(pri_re_1, filename, 0, NULL)
- || g_regex_match(pri_re_2, filename, 0, NULL)
- || g_regex_match(pri_re_3, filename, 0, NULL))
- {
- ret = 1;
+ if (!strncmp(filename, "/sbin/", 6)) {
+ return 1;
}
- if (!user_re) {
- g_regex_unref(pri_re_1);
- g_regex_unref(pri_re_2);
- g_regex_unref(pri_re_3);
+ if (!strncmp(filename, "/usr/", 5)) {
+ if (!strncmp(filename+5, "bin/", 4)) {
+ return 1;
+ }
+
+ if (!strncmp(filename+5, "sbin/", 5)) {
+ return 1;
+ }
+
+ if (!strcmp(filename+5, "lib/sendmail")) {
+ return 1;
+ }
}
- return ret;
+ return 0;
}
*/
struct VersionStruct string_to_version(const char *string, GStringChunk *chunk);
-struct PrimaryReStruct {
- GRegex *pri_re_1;
- GRegex *pri_re_2;
- GRegex *pri_re_3;
-};
-struct PrimaryReStruct new_optimalized_primary_files_re();
-void free_optimalized_primary_files_re(struct PrimaryReStruct in);
-int is_primary(const char *filename, struct PrimaryReStruct *user_re);
+int is_primary(const char *filename);
char *compute_file_checksum(const char *filename, ChecksumType type);
struct HeaderRangeStruct {
packagefile->name = rpmtdGetString(filenames);
packagefile->path = rpmtdGetString(dirnames);
- printf("%s | %s\n", packagefile->path, packagefile->name);
-
// TODO:
// na zaklade toho, ze se zmenila struktura package...
// upravit hashovaci tabulku - OK
// Hashtable with already processed files from requires
GHashTable *ap_hashtable = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, free);
- // Get oprimalized regexps for primary filename matching
- struct PrimaryReStruct re = new_optimalized_primary_files_re();
-
int pcor_type;
for (pcor_type=0; pcor_type <= REQUIRES; pcor_type++) {
if (headerGet(hdr, file_tags[pcor_type], filenames, flags) &&
// Skip package primary files
if (g_hash_table_lookup_extended(filenames_hashtable, filename, NULL, NULL)) {
- if (is_primary(filename, &re)) {
+ if (is_primary(filename)) {
continue;
}
}
pkg->obsoletes = g_slist_reverse (pkg->obsoletes);
pkg->requires = g_slist_reverse (pkg->requires);
- free_optimalized_primary_files_re(re);
-
g_hash_table_remove_all(filenames_hashtable);
g_hash_table_remove_all(provided_hashtable);
g_hash_table_remove_all(ap_hashtable);
return;
}
- struct PrimaryReStruct re;
- if (primary) {
- // Get optimalized regexps for primary filenames matching
- re = new_optimalized_primary_files_re();
- }
GSList *element = NULL;
for(element = package->files; element; element=element->next) {
PackageFile *entry = (PackageFile*) element->data;
+ // File withou name or path is suspicious => Skip it
+ if (!(entry->path)) {
+ continue;
+ }
+
+ if (!(entry->name)) {
+ continue;
+ }
+
// String concatenation (path + basename)
char fullname_buffer[NAMEBUFF_LEN];
int path_len = strlen(entry->path);
int name_len = strlen(entry->name);
+
+
if ( (path_len + name_len) > (NAMEBUFF_LEN - 1) ) {
printf("XML FILE DUMP - ERROR: Pathname + basename is too long: %s%s\n", entry->path, entry->name);
if (path_len >= NAMEBUFF_LEN) {
fullname_buffer[path_len+name_len] = '\0';
- if (primary && !is_primary(fullname_buffer, &re)) {
+ if (primary && !is_primary(fullname_buffer)) {
continue;
}
-
+/*
+ if (primary && !is_primary(entry->path, &re)) {
+ continue;
+ }
+*/
// ***********************************
// Element: file
// ************************************
}
// Write text (file path)
- tmp = ConvertInput(fullname_buffer, handler);
+ //tmp = ConvertInput(fullname_buffer, handler);
+ tmp = ConvertInput(entry->name, handler);
if (tmp) {
xmlTextWriterWriteString(writer, BAD_CAST tmp);
if (handler && tmp != NULL) xmlFree(tmp);
return;
}
}
-
- if (primary) {
- free_optimalized_primary_files_re(re);
- }
}