1 /* Copyright (c) 2003-2004, Roger Dingledine
2  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
3  * Copyright (c) 2007-2021, The Tor Project, Inc. */
4 /* See LICENSE for licensing information */
5 
6 /**
7  * @file subsysmgr.h
8  * @brief Header for subsysmgr.c
9  **/
10 
11 #ifndef TOR_SUBSYSMGR_T
12 #define TOR_SUBSYSMGR_T
13 
14 #include "lib/subsys/subsys.h"
15 
16 extern const struct subsys_fns_t *tor_subsystems[];
17 extern const unsigned n_tor_subsystems;
18 
19 int subsystems_init(void);
20 int subsystems_init_upto(int level);
21 
22 struct pubsub_builder_t;
23 int subsystems_add_pubsub_upto(struct pubsub_builder_t *builder,
24                                int target_level);
25 int subsystems_add_pubsub(struct pubsub_builder_t *builder);
26 
27 void subsystems_shutdown(void);
28 void subsystems_shutdown_downto(int level);
29 
30 void subsystems_prefork(void);
31 void subsystems_postfork(void);
32 void subsystems_thread_cleanup(void);
33 
34 void subsystems_dump_list(void);
35 
36 struct config_mgr_t;
37 int subsystems_register_options_formats(struct config_mgr_t *mgr);
38 int subsystems_register_state_formats(struct config_mgr_t *mgr);
39 struct or_options_t;
40 struct or_state_t;
41 int subsystems_set_options(const struct config_mgr_t *mgr,
42                            struct or_options_t *options);
43 int subsystems_set_state(const struct config_mgr_t *mgr,
44                          struct or_state_t *state);
45 int subsystems_flush_state(const struct config_mgr_t *mgr,
46                            struct or_state_t *state);
47 
48 #ifdef TOR_UNIT_TESTS
49 int subsystems_get_options_idx(const subsys_fns_t *sys);
50 int subsystems_get_state_idx(const subsys_fns_t *sys);
51 #endif
52 
53 #endif /* !defined(TOR_SUBSYSMGR_T) */
54