Enforce numeric application IDs
[src/app-framework-main.git] / src / wgtpkg-unit.h
1 /*
2  Copyright (C) 2016-2019 IoT.bzh
3
4  author: José Bollo <jose.bollo@iot.bzh>
5
6  Licensed under the Apache License, Version 2.0 (the "License");
7  you may not use this file except in compliance with the License.
8  You may obtain a copy of the License at
9
10      http://www.apache.org/licenses/LICENSE-2.0
11
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  See the License for the specific language governing permissions and
16  limitations under the License.
17 */
18
19
20 struct json_object;
21 struct wgt_info;
22
23
24 enum unitscope {
25         unitscope_unknown = 0,
26         unitscope_system,
27         unitscope_user
28 };
29
30 enum unittype {
31         unittype_unknown = 0,
32         unittype_service,
33         unittype_socket
34 };
35
36 struct unitdesc {
37         enum unitscope scope;
38         enum unittype type;
39         const char *name;
40         size_t name_length;
41         const char *content;
42         size_t content_length;
43         const char *wanted_by;
44         size_t wanted_by_length;
45 };
46
47 struct unitconf {
48         const char *installdir;
49         const char *icondir;
50         int (*new_afid)();
51         int base_http_ports;
52 };
53
54 struct generatedesc {
55         const struct unitconf *conf;
56         struct json_object *desc;
57         const struct unitdesc *units;
58         int nunits;
59 };
60
61 extern int unit_generator_open_template(const char *filename);
62 extern void unit_generator_close_template();
63 extern int unit_generator_process(struct json_object *jdesc, const struct unitconf *conf, int (*process)(void *closure, const struct generatedesc *desc), void *closure);
64 extern int unit_install(struct wgt_info *ifo, const struct unitconf *conf);
65 extern int unit_uninstall(struct wgt_info *ifo, const struct unitconf *conf);
66