2 * Copyright (c) 2012, Intel Corporation
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of Intel Corporation nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #ifndef __MURPHY_CONTEXT_H__
31 #define __MURPHY_CONTEXT_H__
35 typedef struct mrp_context_s mrp_context_t;
37 #include <murphy/common/list.h>
38 #include <murphy/common/mainloop.h>
39 #include <murphy/resolver/resolver.h>
43 MRP_STATE_INITIAL = 0,
48 } mrp_context_state_t;
51 struct mrp_context_s {
52 /* logging settings, path configuration, etc. */
53 int log_mask; /* what to log */
54 const char *log_target; /* and where to log to */
56 const char *config_file; /* configuration file */
57 const char *config_dir; /* plugin configuration directory */
58 const char *plugin_dir; /* plugin directory */
59 bool foreground; /* whether to stay in foreground*/
61 char *resolver_ruleset; /* resolver ruleset file */
63 const char *blacklist_plugins; /* blacklisted plugins */
64 const char *blacklist_builtin; /* blacklisted builtin plugins */
65 const char *blacklist_dynamic; /* blacklisted dynamic plugins */
66 const char *whitelist_plugins; /* whitelisted plugins */
67 const char *whitelist_builtin; /* whitelisted builtin plugins */
68 const char *whitelist_dynamic; /* whitelisted dynamic plugins */
69 bool disable_runtime_load; /* disallow post-startup loading */
70 bool disable_console; /* disable murphy console */
72 /* actual runtime context data */
73 int state; /* context/daemon state */
74 mrp_mainloop_t *ml; /* mainloop */
75 mrp_list_hook_t plugins; /* list of loaded plugins */
76 mrp_event_bus_t *plugin_bus; /* bus for plugin events */
77 mrp_event_bus_t *daemon_bus; /* bus for daemon events */
78 mrp_list_hook_t cmd_groups; /* console command groups */
79 mrp_list_hook_t consoles; /* active consoles */
80 mrp_resolver_t *r; /* resolver context */
81 void *lua_state; /* state for Lua bindings */
82 mrp_list_hook_t auth; /* authenticator backends */
85 * Hmm, this is not very nice. Most of the domain handling code (in
86 * practice all) used to live in the domain-control plugin. To avoid
87 * loading order dependencies on plugin-domain-control we now started
88 * collecting registered handlers of proxied functions here. Calls by
89 * the core to proxied functions of domain controllers and by domain-
90 * controllers to the core are still handled in the domain-control
91 * plugin (and in the domain-controller client library).
93 * It would be perhaps the cleanest not to have a domain-controller
94 * specific function export mechanism at all. Instead the various
95 * import/export mechanisms (at least plugins, resolver, and this) should
96 * be replaced by / built on a single core implementation that is flexible
97 * enough to handle all the needs of all these.
100 mrp_list_hook_t domain_methods; /* functions for domain controllers */
101 void *domain_invoke; /* domain invoke handler */
102 void *domain_data; /* domain invoke handler data */
105 /** Create a new murphy context. */
106 mrp_context_t *mrp_context_create(void);
108 /** Destroy an existing murphy context. */
109 void mrp_context_destroy(mrp_context_t *c);
111 /** Set the context state to the given state. */
112 void mrp_context_setstate(mrp_context_t *c, mrp_context_state_t state);
114 #endif /* __MURPHY_CONTEXT_H__ */