summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/tests/test-unit/test-unit.c12
-rw-r--r--src/wgtpkg-unit.c5
-rw-r--r--src/wgtpkg-unit.h1
3 files changed, 14 insertions, 4 deletions
diff --git a/src/tests/test-unit/test-unit.c b/src/tests/test-unit/test-unit.c
index 5912dbc..9a205fc 100644
--- a/src/tests/test-unit/test-unit.c
+++ b/src/tests/test-unit/test-unit.c
@@ -46,7 +46,8 @@ static int processunit(const struct unitdesc *desc)
const char *content = desc->content;
printf("\n##########################################################");
-printf("\n### usr=%d sys=%d soc=%d srv=%d name %s%s", isuser, issystem, issock, isserv, name?:"?", issock?".socket":isserv?".service":"");
+printf("\n### usr=%d sys=%d soc=%d srv=%d name %s%s", isuser, issystem, issock,
+ isserv, name?:"?", issock?".socket":isserv?".service":"");
printf("\n##########################################################");
printf("\n%s\n\n",content);
return 0;
@@ -55,6 +56,10 @@ printf("\n%s\n\n",content);
static int process(void *closure, const struct generatedesc *desc)
{
int i;
+printf("\n##########################################################");
+printf("\n###### J S O N D E S C AFTER #######");
+printf("\n##########################################################");
+puts(json_object_to_json_string_ext(desc->desc, JSON_C_TO_STRING_PRETTY));
for (i = 0 ; i < desc->nunits ; i++)
processunit(&desc->units[i]);
return 0;
@@ -77,7 +82,10 @@ int main(int ac, char **av)
if (!obj)
error("can't read widget config at %s: %m",*av);
- puts(json_object_to_json_string_ext(obj, JSON_C_TO_STRING_PRETTY));
+printf("\n##########################################################");
+printf("\n###### J S O N D E S C BEFORE #######");
+printf("\n##########################################################");
+puts(json_object_to_json_string_ext(obj, JSON_C_TO_STRING_PRETTY));
rc = unit_generator_process(obj, &conf, process, NULL);
if (rc)
error("can't apply generate units, error %d",rc);
diff --git a/src/wgtpkg-unit.c b/src/wgtpkg-unit.c
index 8607eb4..123a950 100644
--- a/src/wgtpkg-unit.c
+++ b/src/wgtpkg-unit.c
@@ -249,7 +249,7 @@ static int process_one_unit(char *spec, struct unitdesc *desc)
* with its given 'closure' and the array descripbing the units.
* Return 0 in case of success or a negative value in case of error.
*/
-static int process_all_units(char *corpus, const struct unitconf *conf, int (*process)(void *closure, const struct generatedesc *desc), void *closure)
+static int process_all_units(char *corpus, const struct unitconf *conf, int (*process)(void *closure, const struct generatedesc *desc), void *closure, struct json_object *jdesc)
{
int rc, rc2;
char *beg, *end, *befbeg, *aftend;
@@ -257,6 +257,7 @@ static int process_all_units(char *corpus, const struct unitconf *conf, int (*pr
struct generatedesc gdesc;
gdesc.conf = conf;
+ gdesc.desc = jdesc;
gdesc.units = NULL;
gdesc.nunits = 0;
rc = rc2 = 0;
@@ -408,7 +409,7 @@ int unit_generator_process(struct json_object *jdesc, const struct unitconf *con
instance = NULL;
rc = apply_mustach(template, jdesc, &instance, &size);
if (!rc)
- rc = process_all_units(instance, conf, process, closure);
+ rc = process_all_units(instance, conf, process, closure, jdesc);
free(instance);
}
}
diff --git a/src/wgtpkg-unit.h b/src/wgtpkg-unit.h
index 8acc62e..10751a6 100644
--- a/src/wgtpkg-unit.h
+++ b/src/wgtpkg-unit.h
@@ -52,6 +52,7 @@ struct unitconf {
struct generatedesc {
const struct unitconf *conf;
+ struct json_object *desc;
const struct unitdesc *units;
int nunits;
};