libamxrt  0.4.2
Ambiorix Run Time Library
amxrt.c
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** SPDX-License-Identifier: BSD-2-Clause-Patent
4 **
5 ** SPDX-FileCopyrightText: Copyright (c) 2023 SoftAtHome
6 **
7 ** Redistribution and use in source and binary forms, with or without modification,
8 ** are permitted provided that the following conditions are met:
9 **
10 ** 1. Redistributions of source code must retain the above copyright notice,
11 ** this list of conditions and the following disclaimer.
12 **
13 ** 2. Redistributions in binary form must reproduce the above copyright notice,
14 ** this list of conditions and the following disclaimer in the documentation
15 ** and/or other materials provided with the distribution.
16 **
17 ** Subject to the terms and conditions of this license, each copyright holder
18 ** and contributor hereby grants to those receiving rights under this license
19 ** a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable
20 ** (except for failure to satisfy the conditions of this license) patent license
21 ** to make, have made, use, offer to sell, sell, import, and otherwise transfer
22 ** this software, where such license applies only to those patent claims, already
23 ** acquired or hereafter acquired, licensable by such copyright holder or contributor
24 ** that are necessarily infringed by:
25 **
26 ** (a) their Contribution(s) (the licensed copyrights of copyright holders and
27 ** non-copyrightable additions of contributors, in source or binary form) alone;
28 ** or
29 **
30 ** (b) combination of their Contribution(s) with the work of authorship to which
31 ** such Contribution(s) was added by such copyright holder or contributor, if,
32 ** at the time the Contribution is added, such addition causes such combination
33 ** to be necessarily infringed. The patent license shall not apply to any other
34 ** combinations which include the Contribution.
35 **
36 ** Except as expressly stated above, no rights or licenses from any copyright
37 ** holder or contributor is granted under this license, whether expressly, by
38 ** implication, estoppel or otherwise.
39 **
40 ** DISCLAIMER
41 **
42 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
43 ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44 ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
45 ** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
46 ** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
47 ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
48 ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
49 ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
50 ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
51 ** USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
52 **
53 ****************************************************************************/
54 
55 #ifndef _GNU_SOURCE
56 #define _GNU_SOURCE
57 #endif
58 
59 #include <stdlib.h>
60 #include <stdio.h>
61 #include <string.h>
62 #include <errno.h>
63 #include <unistd.h>
64 #include <sys/time.h>
65 #include <sys/resource.h>
66 #include <sys/stat.h>
67 #include <syslog.h>
68 #include <cap-ng.h>
69 
70 #include <amxrt/amxrt.h>
71 
72 #include "amxrt_priv.h"
73 
74 static amxrt_t rt;
75 
76 static bool amxrt_file_exists(const char* filename) {
77  struct stat buffer;
78 
79  return (stat(filename, &buffer) == 0);
80 }
81 
82 static int amxrt_parse_odl_string(amxo_parser_t* parser,
83  amxd_object_t* root) {
84  const char* odl_str = NULL;
85  int retval = 0;
86 
87  odl_str = amxc_var_constcast(cstring_t, GET_ARG(&parser->config, AMXRT_COPT_ODL));
88  if(odl_str != NULL) {
89  retval = amxo_parser_parse_string(parser, odl_str, root);
90  if(retval != 0) {
91  amxrt_print_failure(parser, odl_str);
92  }
93  }
94 
95  return retval;
96 }
97 
98 static int amxrt_parse_odl_extensions(amxo_parser_t* parser, amxd_object_t* root) {
99  int retval = 0;
100 
101  const char* ext_dir = GET_CHAR(&parser->config, AMXRT_COPT_EXT_DIR);
102  amxc_string_t opt_include;
103 
104  amxc_string_init(&opt_include, 0);
105  when_str_empty(ext_dir, exit);
106 
107  amxc_string_setf(&opt_include, "#include '%s';", ext_dir);
108 
109  retval = amxo_parser_parse_string(parser, amxc_string_get(&opt_include, 0), root);
110 
111 exit:
112  amxc_string_clean(&opt_include);
113  return retval;
114 }
115 
116 static int amxrt_try_default_odl(amxo_parser_t* parser, amxd_object_t* root) {
117  char* name = amxc_var_dyncast(cstring_t, GET_ARG(&parser->config, AMXRT_COPT_NAME));
118  char* prefix = amxc_var_dyncast(cstring_t, GET_ARG(&parser->config, AMXRT_COPT_PREFIX_PATH));
119  char* cfg_dir = amxc_var_dyncast(cstring_t, GET_ARG(&parser->config, AMXRT_COPT_CFG_DIR));
120  struct stat sb;
121  int retval = 0;
122 
123  amxc_string_t include;
124  amxc_string_init(&include, 32);
125  amxc_string_appendf(&include, "%s/%s/%s/%s.odl", prefix, cfg_dir, name, name);
126 
127  if(stat(amxc_string_get(&include, 0), &sb) == 0) {
128  retval = amxo_parser_parse_file(parser, amxc_string_get(&include, 0), root);
129  if(retval != 0) {
130  amxrt_print_failure(parser, amxc_string_get(&include, 0));
131  }
132  }
133  amxc_string_clean(&include);
134 
135  free(cfg_dir);
136  free(prefix);
137  free(name);
138 
139  return retval;
140 }
141 
142 static int amxrt_parse_odl_files(amxo_parser_t* parser,
143  int argc,
144  char* argv[],
145  int index,
146  amxd_object_t* root) {
147  int retval = 0;
148 
149  if(index >= argc) {
150  retval = amxrt_try_default_odl(parser, root);
151  } else {
152  while(index < argc) {
153  retval = amxo_parser_parse_file(parser, argv[index++], root);
154  if(retval != 0) {
155  amxrt_print_failure(parser, argv[index - 1]);
156  break;
157  }
158  }
159  }
160 
161  return retval;
162 }
163 
164 static int amxrt_create_pid_file(pid_t pid, const char* name) {
165  amxc_string_t pidfile;
166  int retval = -1;
167  FILE* pf = NULL;
168 
169  amxc_string_init(&pidfile, 64);
170 
171  // create pidfile
172  amxc_string_appendf(&pidfile, "/var/run/%s.pid", name);
173  pf = fopen(amxc_string_get(&pidfile, 0), "w");
174  if((pf == NULL) && (errno == EACCES)) {
175  amxc_string_reset(&pidfile);
176  amxc_string_appendf(&pidfile, "/var/run/%s/%s.pid", name, name);
177  pf = fopen(amxc_string_get(&pidfile, 0), "w");
178  }
179  if(pf != NULL) {
180  fprintf(pf, "%d", pid);
181  fflush(pf);
182  fclose(pf);
183  retval = 0;
184  } else {
185  amxrt_print_error("Failed to create pidfile");
186  }
187 
188  amxc_string_clean(&pidfile);
189  return retval;
190 }
191 
192 static void amxrt_remove_pid_file(const char* name) {
193  amxc_string_t pidfile;
194  amxc_string_init(&pidfile, 64);
195 
196  amxc_string_appendf(&pidfile, "/var/run/%s.pid", name);
197  if(!amxrt_file_exists(amxc_string_get(&pidfile, 0))) {
198  amxc_string_reset(&pidfile);
199  amxc_string_appendf(&pidfile, "/var/run/%s/%s.pid", name, name);
200  }
201 
202  if(amxrt_file_exists(amxc_string_get(&pidfile, 0))) {
203  unlink(amxc_string_get(&pidfile, 0));
204  }
205 
206  amxc_string_clean(&pidfile);
207 }
208 
209 static int amxrt_apply_process_settings(amxo_parser_t* parser) {
210  int retval = 0;
211  int pid = -1;
212  bool pidfile = amxc_var_dyncast(bool, GET_ARG(&parser->config, AMXRT_COPT_PID_FILE));
213  char* name = amxc_var_dyncast(cstring_t, GET_ARG(&parser->config, AMXRT_COPT_NAME));
214 
215  int priority = amxc_var_dyncast(uint32_t, GET_ARG(&parser->config, AMXRT_COPT_PRIORITY));
216 
217  pid = getpid();
218  retval = setpriority(PRIO_PROCESS, pid, priority);
219  when_failed(retval, leave);
220 
221  if(pidfile && (name != NULL)) {
222  amxrt_create_pid_file(pid, name);
223  }
224 
225  if(GET_BOOL(&parser->config, AMXRT_COPT_LOG) &&
226  ( GET_CHAR(&parser->config, AMXRT_COPT_NAME) != NULL)) {
227  openlog(GET_CHAR(&parser->config, AMXRT_COPT_NAME), LOG_CONS | LOG_PID, LOG_USER);
228  syslog(LOG_USER | LOG_INFO, "** MARK **");
229  }
230 
231  retval = amxrt_caps_apply();
232 
233 leave:
234  free(name);
235  return retval;
236 }
237 
238 static int amxrt_register(amxo_parser_t* parser, amxd_dm_t* dm) {
239  int retval = 0;
240 
241  retval = amxrt_connection_register_dm(parser, dm);
242  when_failed(retval, leave);
243  amxc_var_set(bool, GET_ARG(&parser->config, AMXRT_COPT_EVENT), true);
244  if(parser->post_includes != NULL) {
245  retval = amxo_parser_invoke_entry_points(parser, dm, AMXO_START);
246  when_failed(retval, leave);
247  retval = amxo_parser_invoke_entry_points(parser, dm, AMXO_ODL_LOADED);
248  when_failed(retval, leave);
249  } else {
250  retval = amxo_parser_invoke_entry_points(parser, dm, AMXO_START);
251  when_failed(retval, leave);
252  }
253 
254  retval = amxo_parser_start_synchronize(parser);
255  if(retval != 0) {
256  amxrt_print_error("Runtime - synchronizations failed to start (nr failed = %d)\n", retval);
257  amxrt_print_message("Runtime - Are all required objects available?");
258  }
259 
260 leave:
261  return retval;
262 }
263 
264 static void amxrt_handle_events(amxd_dm_t* dm, amxo_parser_t* parser) {
265  bool handle_events = GET_BOOL(&parser->config, AMXRT_COPT_HANDLE_EVENTS);
266 
267  if(handle_events) {
268  while(amxp_signal_read() == 0) {
269  }
270  }
271  amxp_sigmngr_trigger_signal(&dm->sigmngr, "app:start", NULL);
272 }
273 
274 static void amxrt_wait_done(UNUSED const char* const s,
275  UNUSED const amxc_var_t* const d,
276  UNUSED void* const p) {
277  amxo_parser_t* parser = amxrt_get_parser();
278  amxd_dm_t* dm = amxrt_get_dm();
279  amxc_var_t* req = GET_ARG(&parser->config, AMXRT_COPT_REQUIRES);
280 
281  amxc_var_clean(req);
282  amxc_var_set_type(req, AMXC_VAR_ID_LIST);
283 
284  amxrt_print_message("RunTime - All required objects available - continue");
285 
286  amxp_sigmngr_resume(&dm->sigmngr);
287 
288  if(amxrt_register(parser, dm) != 0) {
289  amxrt_print_error("Failed to register data model");
290  amxrt_el_stop();
291  } else {
292  amxrt_handle_events(dm, parser);
293  amxp_slot_disconnect(NULL, "wait:done", amxrt_wait_done);
294  }
295 }
296 
298  return &rt;
299 }
300 
301 amxc_var_t* amxrt_get_config(void) {
302  return &rt.parser.config;
303 }
304 
305 amxo_parser_t* amxrt_get_parser(void) {
306  return &rt.parser;
307 }
308 
309 amxd_dm_t* amxrt_get_dm(void) {
310  return &rt.dm;
311 }
312 
313 void amxrt_new(void) {
314  amxd_dm_init(&rt.dm);
315  amxo_parser_init(&rt.parser);
316  amxc_llist_init(&rt.event_sources);
317  amxc_llist_init(&rt.cmd_line_args);
318  rt.usage_doc = "[OPTIONS] <odl files>";
319 
320  // command line options given with -F are stored here and can not be overwritten
321  // by odl config section options
322  amxc_var_init(&rt.forced_options);
323  amxc_var_set_type(&rt.forced_options, AMXC_VAR_ID_HTABLE);
324 
326 
327  amxp_sigmngr_add_signal(NULL, "config:changed");
328  amxp_sigmngr_add_signal(NULL, "wait:done");
329  amxp_sigmngr_add_signal(NULL, "wait:cancel");
330 
332 }
333 
334 int amxrt(int argc, char* argv[], amxrt_arg_fn_t fn) {
335  int retval = 0;
336 
337  retval = amxrt_init(argc, argv, fn);
338  when_failed(retval, leave);
339  retval = amxrt_register_or_wait();
340  when_failed(retval, leave);
341  retval = amxrt_run();
342 
343 leave:
344  amxrt_stop();
345  return retval;
346 }
347 
348 int amxrt_init(int argc, char* argv[], amxrt_arg_fn_t fn) {
349  int retval = 0;
350  int index = 0;
351  amxc_var_t* syssigs = NULL;
352  amxo_parser_t* parser = amxrt_get_parser();
353 
354  amxc_var_set_type(&rt.forced_options, AMXC_VAR_ID_HTABLE);
355  retval = amxrt_config_init(argc, argv, &index, fn);
356  when_failed_status(retval, leave, retval = 10);
357  retval = amxrt_load_odl_files(argc, argv, index);
358  when_failed_status(retval, leave, retval = 11);
360 
361  amxo_parser_add_entry_point(parser, amxrt_dm_save_load_main);
362 
363  retval = amxrt_connect();
364  when_failed_status(retval, leave, retval = 12);
365 
366  syssigs = GET_ARG(&rt.parser.config, "system-signals");
367  if(syssigs != NULL) {
368  amxrt_enable_syssigs(syssigs);
369  }
370 
371  retval = amxrt_el_create();
372  when_failed_status(retval, leave, retval = -13);
373 
374 leave:
375  return retval;
376 }
377 
378 void amxrt_delete(void) {
379  amxd_dm_clean(&rt.dm);
380  amxo_resolver_import_close_all();
381  amxb_be_remove_all();
382 
384  amxc_var_clean(&rt.forced_options);
385 
386  amxo_parser_clean(&rt.parser);
387 }
388 
390  int retval = 0;
391  amxc_var_t* req = NULL;
392  const amxc_llist_t* lreq = NULL;
393 
394  req = GET_ARG(&rt.parser.config, AMXRT_COPT_REQUIRES);
395  lreq = amxc_var_constcast(amxc_llist_t, req);
396 
397  if((lreq == NULL) || amxc_llist_is_empty(lreq)) {
398  retval = amxrt_register(&rt.parser, &rt.dm);
399  when_failed_status(retval, leave, retval = -14);
401  } else {
402  if(GET_BOOL(&rt.parser.config, AMXRT_COPT_SUSPEND)) {
403  amxp_sigmngr_suspend(&rt.dm.sigmngr);
404  }
405  amxp_slot_connect(NULL, "wait:done", NULL, amxrt_wait_done, NULL);
406  amxc_var_for_each(path, req) {
407  const char* txt_path = GET_CHAR(path, NULL);
408  if(amxd_dm_findf(&rt.dm, "%s", txt_path) == NULL) {
409  amxrt_print_message("RunTime - Waiting for required object '%s'", txt_path);
410  retval = amxb_wait_for_object(txt_path);
411  if(retval != AMXB_STATUS_OK) {
412  amxrt_print_error("RunTime - Waiting failed for object '%s'", txt_path);
413  break;
414  }
415  }
416  }
417  }
418 
419  when_failed_status(retval, leave, retval = -14);
420 
421 leave:
422  return retval;
423 }
424 
425 int amxrt_run(void) {
426  int retval = 0;
427 
428  if(GET_BOOL(&rt.parser.config, AMXRT_COPT_DUMP_CONFIG)) {
430  }
431  if(GET_BOOL(&rt.parser.config, AMXRT_COPT_DUMP_CAPS)) {
432  amxrt_caps_dump();
433  }
434 
435  amxrt_el_start();
436 
437  return retval;
438 }
439 
440 void amxrt_stop(void) {
441  amxo_parser_t* parser = amxrt_get_parser();
442  amxd_dm_t* dm = amxrt_get_dm();
443  char* name = amxc_var_dyncast(cstring_t, GET_ARG(&parser->config, AMXRT_COPT_NAME));
444  amxc_var_t* req = GET_ARG(&parser->config, AMXRT_COPT_REQUIRES);
445 
447 
448  amxo_parser_stop_synchronize(parser);
449 
450  if((req == NULL) || amxc_llist_is_empty(amxc_var_constcast(amxc_llist_t, req))) {
451  amxo_parser_rinvoke_entry_points(parser, dm, AMXO_STOP);
452  }
453 
454  amxb_set_config(NULL);
455 
456  amxrt_remove_pid_file(name);
457 
458  if(GET_BOOL(&parser->config, AMXRT_COPT_LOG) &&
459  ( GET_CHAR(&parser->config, AMXRT_COPT_NAME) != NULL)) {
460  closelog();
461  }
462 
463  free(name);
464 }
465 
466 int amxrt_load_odl_files(int argc, char* argv[], int index) {
467  int retval = 0;
468  amxd_object_t* root = NULL;
469  bool dm_eventing_enabled = false;
470 
471  dm_eventing_enabled = GET_BOOL(&rt.parser.config, AMXRT_COPT_EVENT);
472  amxp_sigmngr_enable(&rt.dm.sigmngr, dm_eventing_enabled);
473  root = amxd_dm_get_root(&rt.dm);
474  retval = amxrt_parse_odl_string(&rt.parser, root);
475  when_failed(retval, leave);
476  retval = amxrt_parse_odl_files(&rt.parser, argc, argv, index, root);
477  when_failed(retval, leave);
478  retval = amxrt_parse_odl_extensions(&rt.parser, root);
479  when_failed(retval, leave);
480 
481  amxo_parser_scan_mib_dirs(&rt.parser, NULL);
482  amxp_sigmngr_enable(&rt.dm.sigmngr, true);
483 
484 leave:
485  return retval;
486 }
487 
488 int amxrt_connect(void) {
489  int retval = 0;
490 
491  retval = amxrt_connection_load_backends(&rt.parser.config);
492  when_failed(retval, leave);
493 
495 
496  // Daemonize before opening sockets
497  // Some bus systems requires this.
498  // Daemonizing (going to background) changes process id, sometimes the process id
499  // is used in the initial handshake
500  if(amxc_var_constcast(bool, GET_ARG(&rt.parser.config, AMXRT_COPT_DAEMON))) {
501  retval = daemon(1, 0);
502  when_failed(retval, leave);
503  }
504 
506  when_failed(retval, leave);
508  when_failed(retval, leave);
510  when_failed(retval, leave);
511 
512 leave:
513  return retval;
514 }
515 
516 void amxrt_enable_syssigs(amxc_var_t* syssigs) {
517  if(amxc_var_type_of(syssigs) == AMXC_VAR_ID_LIST) {
518  amxc_var_for_each(var, syssigs) {
519  uint32_t sigid = amxc_var_dyncast(uint32_t, var);
520  if((sigid != 0) &&
521  ( sigid != SIGALRM) &&
522  ( sigid != SIGTERM) &&
523  ( sigid != SIGINT)) {
524  amxp_syssig_enable(sigid, true);
525  }
526  }
527  } else {
528  uint32_t sigid = amxc_var_dyncast(uint32_t, syssigs);
529  if((sigid != 0) &&
530  ( sigid != SIGALRM) &&
531  ( sigid != SIGTERM) &&
532  ( sigid != SIGINT)) {
533  amxp_syssig_enable(sigid, true);
534  }
535  }
536 }
static int amxrt_try_default_odl(amxo_parser_t *parser, amxd_object_t *root)
Definition: amxrt.c:116
static amxrt_t rt
Definition: amxrt.c:74
static int amxrt_register(amxo_parser_t *parser, amxd_dm_t *dm)
Definition: amxrt.c:238
static int amxrt_parse_odl_extensions(amxo_parser_t *parser, amxd_object_t *root)
Definition: amxrt.c:98
static void amxrt_handle_events(amxd_dm_t *dm, amxo_parser_t *parser)
Definition: amxrt.c:264
static int amxrt_apply_process_settings(amxo_parser_t *parser)
Definition: amxrt.c:209
static void amxrt_wait_done(UNUSED const char *const s, UNUSED const amxc_var_t *const d, UNUSED void *const p)
Definition: amxrt.c:274
static int amxrt_parse_odl_string(amxo_parser_t *parser, amxd_object_t *root)
Definition: amxrt.c:82
static void amxrt_remove_pid_file(const char *name)
Definition: amxrt.c:192
static bool amxrt_file_exists(const char *filename)
Definition: amxrt.c:76
static int amxrt_create_pid_file(pid_t pid, const char *name)
Definition: amxrt.c:164
static int amxrt_parse_odl_files(amxo_parser_t *parser, int argc, char *argv[], int index, amxd_object_t *root)
Definition: amxrt.c:142
amxrt_t * amxrt_get(void)
Definition: amxrt.c:297
#define AMXRT_COPT_PID_FILE
Definition: amxrt.h:84
#define AMXRT_COPT_ODL
Definition: amxrt.h:81
#define AMXRT_COPT_EXT_DIR
Definition: amxrt.h:102
#define AMXRT_COPT_SUSPEND
Definition: amxrt.h:101
int(* amxrt_arg_fn_t)(amxc_var_t *config, int arg_id, const char *value)
Definition: amxrt.h:115
#define AMXRT_COPT_CFG_DIR
Definition: amxrt.h:88
#define AMXRT_COPT_DUMP_CONFIG
Definition: amxrt.h:91
#define AMXRT_COPT_PRIORITY
Definition: amxrt.h:83
#define AMXRT_COPT_PREFIX_PATH
Definition: amxrt.h:86
#define AMXRT_COPT_DUMP_CAPS
Definition: amxrt.h:92
#define AMXRT_COPT_NAME
Definition: amxrt.h:85
#define AMXRT_COPT_REQUIRES
Definition: amxrt.h:99
#define AMXRT_COPT_HANDLE_EVENTS
Definition: amxrt.h:100
#define AMXRT_COPT_EVENT
Definition: amxrt.h:90
#define AMXRT_COPT_LOG
Definition: amxrt.h:98
#define AMXRT_COPT_DAEMON
Definition: amxrt.h:82
PRIVATE void amxrt_print_failure(amxo_parser_t *parser, const char *string)
PRIVATE void amxrt_cmd_line_add_default_options(void)
Definition: amxrt_args.c:178
PRIVATE int amxrt_connection_connect_all(amxo_parser_t *parser)
PRIVATE void amxrt_config_add_options(amxo_parser_t *parser)
Definition: amxrt_config.c:183
PRIVATE void amxrt_print_message(const char *fmt,...)
PRIVATE int amxrt_connection_load_backends(amxc_var_t *config)
PRIVATE void amxrt_connection_detect_sockets(amxc_var_t *config)
PRIVATE int amxrt_connection_listen_all(amxo_parser_t *parser)
PRIVATE void amxrt_print_error(const char *fmt,...)
PRIVATE int amxrt_connection_register_dm(amxo_parser_t *parser, amxd_dm_t *dm)
PRIVATE void amxrt_print_configuration(void)
void amxrt_cmd_line_options_reset(void)
Removes all default options.
Definition: amxrt_args.c:200
int amxrt_el_destroy(void)
Cleans-up the event loop components.
int amxrt_el_start(void)
Starts the event loop.
int amxrt_el_stop(void)
Stops the event loop.
int amxrt_el_create(void)
Creates and initializes all needed event loop components.
void amxrt_caps_dump(void)
Dumps the capabilities of the process.
Definition: amxrt_cap.c:180
int amxrt_caps_apply(void)
Apply the user, group and capabilities as defined in the configuration.
Definition: amxrt_cap.c:101
void amxrt_config_scan_backend_dirs(void)
Scan backend directories for available backends.
Definition: amxrt_config.c:246
amxc_var_t * amxrt_get_config(void)
Gets the htable variant containing the configuration options.
Definition: amxrt.c:301
int amxrt_connect(void)
Connects to all bus sockets.
Definition: amxrt.c:488
int amxrt_init(int argc, char *argv[], amxrt_arg_fn_t fn)
Initializes the ambiorix runtime.
Definition: amxrt.c:348
int amxrt(int argc, char *argv[], amxrt_arg_fn_t fn)
This function can create full ambiorix application (data model provider or client).
Definition: amxrt.c:334
int amxrt_dm_save_load_main(int reason, amxd_dm_t *dm, amxo_parser_t *parser)
The data model auto load and save module.
void amxrt_delete(void)
Clean-up ambiorix runtime.
Definition: amxrt.c:378
int amxrt_load_odl_files(int argc, char *argv[], int index)
Load odls files mentioned on the command line or the default odl file.
Definition: amxrt.c:466
int amxrt_run(void)
Starts the event loop.
Definition: amxrt.c:425
amxd_dm_t * amxrt_get_dm(void)
Gets the runtime data model storage.
Definition: amxrt.c:309
void amxrt_new(void)
Create the ambiorix runtime.
Definition: amxrt.c:313
void amxrt_stop(void)
Stops the runtime.
Definition: amxrt.c:440
amxo_parser_t * amxrt_get_parser(void)
Gets runtime odl parser.
Definition: amxrt.c:305
void amxrt_enable_syssigs(amxc_var_t *syssigs)
Enables system signals that should be monitored by the eventloop.
Definition: amxrt.c:516
int amxrt_register_or_wait(void)
Register the data model or wait for required data model objects.
Definition: amxrt.c:389
int amxrt_config_init(int argc, char *argv[], int *index, amxrt_arg_fn_t fn)
Initializes the default runtime configuration.
Definition: amxrt_config.c:217
amxc_llist_t cmd_line_args
Definition: amxrt_priv.h:102
amxc_llist_t event_sources
Definition: amxrt_priv.h:104
amxd_dm_t dm
Definition: amxrt_priv.h:100
amxo_parser_t parser
Definition: amxrt_priv.h:101
amxc_var_t forced_options
Definition: amxrt_priv.h:103
const char * usage_doc
Definition: amxrt_priv.h:105
static void handle_events(void)