From 8c8cefa4d1caa5e0fa1727b5f9f2261ac4d07338 Mon Sep 17 00:00:00 2001 From: Jan Pokorný Date: Wed, 7 May 2014 19:34:59 +0200 Subject: ccs-flatten: code both removed-stale and added-needed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan Pokorný --- __root__/ccs-flatten/flatten.c | 13 ++----------- __root__/ccs-flatten/resrules.c | 8 +++++++- 2 files changed, 9 insertions(+), 12 deletions(-) (limited to '__root__/ccs-flatten') diff --git a/__root__/ccs-flatten/flatten.c b/__root__/ccs-flatten/flatten.c index e2f0662..f7ef546 100644 --- a/__root__/ccs-flatten/flatten.c +++ b/__root__/ccs-flatten/flatten.c @@ -108,7 +108,7 @@ replace_resource(xmlNodePtr rm, char *restype, char *primattr, char *ident, xmlN } static int -flatten(int argc, char **argv, xmlDocPtr * doc) +flatten(int argc, char **argv) { xmlDocPtr d = NULL; xmlNode *n = NULL, *rm = NULL, *new_rb = NULL; @@ -142,7 +142,6 @@ flatten(int argc, char **argv, xmlDocPtr * doc) /* allow fallback to rawmetadata, but not the other way around */ do { - fprintf(stderr, "%s\n", rawmetadata ? "raw":"noraw"); load_resource_rules(agentpath, &rulelist, rawmetadata); if (rulelist) break; @@ -200,11 +199,6 @@ flatten(int argc, char **argv, xmlDocPtr * doc) fclose(f); out: - if (ret < 0) { - xmlFreeDoc(d); - } else { - *doc = d; - } conf_close(); destroy_resource_tree(&tree); destroy_resources(&reslist); @@ -232,7 +226,6 @@ main(int argc, char **argv) { char *arg0 = basename(argv[0]); int ret = 0; - xmlDocPtr doc = NULL; if (argc < 2) { usage(arg0, 1); @@ -247,10 +240,8 @@ main(int argc, char **argv) xmlKeepBlanksDefault(0); shift(); - ret = flatten(argc, argv, &doc); + ret = flatten(argc, argv); - //if (doc) - //xmlFreeDoc(doc); xmlCleanupParser(); return ret; } diff --git a/__root__/ccs-flatten/resrules.c b/__root__/ccs-flatten/resrules.c index 9187c00..db2078d 100644 --- a/__root__/ccs-flatten/resrules.c +++ b/__root__/ccs-flatten/resrules.c @@ -938,7 +938,7 @@ load_resource_rules(const char *rpath, resource_rule_t ** rules, /* 1st cond: 8+ items symloop (if 8 <= SYMLOOP_MAX) or readlink fail */ if (i >= 8 || !(dir = opendir(dirname(*path1)))) return -1; - rpath = *path1; + rpath = *path1; } xmlInitParser(); @@ -967,6 +967,12 @@ load_resource_rules(const char *rpath, resource_rule_t ** rules, } } +#ifdef RAWMETADATA_EXT + /* when only raw metadata accepted */ + if (rawmetadata && (!dot || strcmp(dot + 1, RAWMETADATA_EXT))) + continue; +#endif + snprintf(path, sizeof(path), "%s/%s", rpath, de->d_name); if (stat(path, &st_buf) < 0) -- cgit