* 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;
struct generatedesc gdesc;
gdesc.conf = conf;
+ gdesc.desc = jdesc;
gdesc.units = NULL;
gdesc.nunits = 0;
rc = rc2 = 0;
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);
}
}
return rc;
}
-static int do_send_reload(const struct generatedesc *desc)
-{
- int i;
- int reloadsys, reloadusr;
- const struct unitdesc *u;
-
- reloadsys = reloadusr = 0;
- for (i = 0 ; i < desc->nunits ; i++) {
- u = &desc->units[i];
- if (u->wanted_by != NULL) {
- switch (u->scope) {
- case unitscope_user:
- reloadusr = 1;
- break;
- case unitscope_system:
- reloadsys = 1;
- break;
- default:
- break;
- }
- }
- }
-
- if (reloadusr)
- reloadusr = systemd_daemon_reload(1);
- if (reloadsys)
- reloadsys = systemd_daemon_reload(0);
- return 0;
-}
-
static int do_uninstall_units(void *closure, const struct generatedesc *desc)
{
int rc, rc2;
if (rc2 < 0 && rc == 0)
rc = rc2;
}
- rc2 = do_send_reload(desc);
- if (rc2 < 0 && rc == 0)
- rc = rc2;
return rc;
}
if (rc < 0)
goto error;
}
- rc = do_send_reload(desc);
- if (rc < 0)
- goto error;
return 0;
error:
i = errno;