/*
- Copyright 2016, 2017 IoT.bzh
+ Copyright (C) 2016, 2017, 2018 IoT.bzh
author: José Bollo <jose.bollo@iot.bzh>
/*
* Clear the unit generator
*/
-void unit_generator_off()
+void unit_generator_close_template()
{
free(template);
template = NULL;
* Initialises the unit generator with the content of the file of path 'filename'.
* Returns 0 in case of success or a negative number in case of error.
*/
-int unit_generator_on(const char *filename)
+int unit_generator_open_template(const char *filename)
{
size_t size;
char *tmp;
int rc;
- unit_generator_off();
+ unit_generator_close_template();
rc = getfile(filename ? : FWK_UNIT_CONF, &template, NULL);
if (!rc) {
size = pack(template, ';');
sprintf(portstr, "%d", conf->port);
return j_add_many_strings_m(jdesc,
"#metadata.install-dir", conf->installdir,
- "#metadata.app-data-dir", "%h/app-data",
"#metadata.icons-dir", conf->icondir,
"#metadata.http-port", portstr,
NULL) ? 0 : -1;
* Applies the object 'jdesc' augmented of meta data coming
* from 'conf' to the current unit generator.
* The current unit generator will be set to the default one if not unit
- * was previously set using the function 'unit_generator_on'.
+ * was previously set using the function 'unit_generator_open_template'.
* The callback function 'process' is then called with the
* unit descriptors array and the expected closure.
* Return what returned process in case of success or a negative
if (rc)
ERROR("can't set the metadata. %m");
else {
- rc = template ? 0 : unit_generator_on(NULL);
+ rc = template ? 0 : unit_generator_open_template(NULL);
if (!rc) {
instance = NULL;
rc = apply_mustach(template, jdesc, &instance, &size);