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
Use structures for generating units
[src/app-framework-main.git]
/
src
/
tests
/
test-unit
/
test-unit.c
diff --git
a/src/tests/test-unit/test-unit.c
b/src/tests/test-unit/test-unit.c
index
09b7c86
..
5912dbc
100644
(file)
--- a/
src/tests/test-unit/test-unit.c
+++ b/
src/tests/test-unit/test-unit.c
@@
-36,7
+36,7
@@
-static int process
1
(const struct unitdesc *desc)
+static int process
unit
(const struct unitdesc *desc)
{
int isuser = desc->scope == unitscope_user;
int issystem = desc->scope == unitscope_system;
{
int isuser = desc->scope == unitscope_user;
int issystem = desc->scope == unitscope_system;
@@
-52,18
+52,23
@@
printf("\n%s\n\n",content);
return 0;
}
return 0;
}
-static int process(void *closure, const struct
unitdesc descs[], unsigned count
)
+static int process(void *closure, const struct
generatedesc *desc
)
{
{
- while (count--)
- process1(descs++);
+ int i;
+ for (i = 0 ; i < desc->nunits ; i++)
+ processunit(&desc->units[i]);
return 0;
}
int main(int ac, char **av)
{
return 0;
}
int main(int ac, char **av)
{
+ struct unitconf conf;
struct json_object *obj;
int rc;
struct json_object *obj;
int rc;
+ conf.installdir = "INSTALL-DIR";
+ conf.icondir = "ICONS-DIR";
+ conf.port = 666;
rc = unit_generator_on(*++av);
if (rc < 0)
error("can't read template %s: %m",*av);
rc = unit_generator_on(*++av);
if (rc < 0)
error("can't read template %s: %m",*av);
@@
-72,13
+77,8
@@
int main(int ac, char **av)
if (!obj)
error("can't read widget config at %s: %m",*av);
if (!obj)
error("can't read widget config at %s: %m",*av);
- j_add_string_m(obj, "#metadata.install-dir", "INSTALL-DIR");
- j_add_string_m(obj, "#metadata.app-data-dir", "%h/app-data");
- j_add_string_m(obj, "#metadata.icons-dir", "ICONS-DIR");
- j_add_string_m(obj, "#metadata.http-port", "HTTP-PORT");
-
puts(json_object_to_json_string_ext(obj, JSON_C_TO_STRING_PRETTY));
puts(json_object_to_json_string_ext(obj, JSON_C_TO_STRING_PRETTY));
- rc = unit_generator_process(obj, process, NULL);
+ rc = unit_generator_process(obj,
&conf,
process, NULL);
if (rc)
error("can't apply generate units, error %d",rc);
json_object_put(obj);
if (rc)
error("can't apply generate units, error %d",rc);
json_object_put(obj);