Code Review
/
src
/
app-framework-main.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Merge changes from topic 'binding-v3'
[src/app-framework-main.git]
/
src
/
wgtpkg-unit.c
diff --git
a/src/wgtpkg-unit.c
b/src/wgtpkg-unit.c
index
8607eb4
..
89d1473
100644
(file)
--- a/
src/wgtpkg-unit.c
+++ b/
src/wgtpkg-unit.c
@@
-1,5
+1,5
@@
/*
/*
- Copyright
2016, 2017
IoT.bzh
+ Copyright
(C) 2016, 2017, 2018
IoT.bzh
author: José Bollo <jose.bollo@iot.bzh>
author: José Bollo <jose.bollo@iot.bzh>
@@
-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.
*/
* 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;
{
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;
struct generatedesc gdesc;
gdesc.conf = conf;
+ gdesc.desc = jdesc;
gdesc.units = NULL;
gdesc.nunits = 0;
rc = rc2 = 0;
gdesc.units = NULL;
gdesc.nunits = 0;
rc = rc2 = 0;
@@
-343,7
+344,7
@@
static int process_all_units(char *corpus, const struct unitconf *conf, int (*pr
/*
* Clear the unit generator
*/
/*
* Clear the unit generator
*/
-void unit_generator_
off
()
+void unit_generator_
close_template
()
{
free(template);
template = NULL;
{
free(template);
template = NULL;
@@
-353,13
+354,13
@@
void unit_generator_off()
* 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.
*/
* 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_o
n
(const char *filename)
+int unit_generator_o
pen_template
(const char *filename)
{
size_t size;
char *tmp;
int rc;
{
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, ';');
rc = getfile(filename ? : FWK_UNIT_CONF, &template, NULL);
if (!rc) {
size = pack(template, ';');
@@
-377,7
+378,6
@@
static int add_metadata(struct json_object *jdesc, const struct unitconf *conf)
sprintf(portstr, "%d", conf->port);
return j_add_many_strings_m(jdesc,
"#metadata.install-dir", conf->installdir,
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;
"#metadata.icons-dir", conf->icondir,
"#metadata.http-port", portstr,
NULL) ? 0 : -1;
@@
-387,7
+387,7
@@
static int add_metadata(struct json_object *jdesc, const struct unitconf *conf)
* 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
* 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_o
n
'.
+ * was previously set using the function 'unit_generator_o
pen_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
* 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
@@
-403,12
+403,12
@@
int unit_generator_process(struct json_object *jdesc, const struct unitconf *con
if (rc)
ERROR("can't set the metadata. %m");
else {
if (rc)
ERROR("can't set the metadata. %m");
else {
- rc = template ? 0 : unit_generator_o
n
(NULL);
+ rc = template ? 0 : unit_generator_o
pen_template
(NULL);
if (!rc) {
instance = NULL;
rc = apply_mustach(template, jdesc, &instance, &size);
if (!rc)
if (!rc) {
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);
}
}
free(instance);
}
}