author | Tero Marttila <terom@fixme.fi> |
Wed, 27 May 2009 23:07:00 +0300 | |
branch | new-lib-errors |
changeset 216 | a10ba529ae39 |
parent 109 | bfe9b9a8fe5b |
permissions | -rw-r--r-- |
53
12d806823775
add irc_client module, plus nexus.h header
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
1 |
#ifndef NEXUS_H |
12d806823775
add irc_client module, plus nexus.h header
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
2 |
#define NEXUS_H |
12d806823775
add irc_client module, plus nexus.h header
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
3 |
|
12d806823775
add irc_client module, plus nexus.h header
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
4 |
/** |
87 | 5 |
* @file |
6 |
* |
|
53
12d806823775
add irc_client module, plus nexus.h header
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
7 |
* A nexus is the central brain of the application; the place where the main() method is implemented |
12d806823775
add irc_client module, plus nexus.h header
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
8 |
*/ |
57
ce1accba5fc7
slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents:
55
diff
changeset
|
9 |
struct nexus; |
ce1accba5fc7
slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents:
55
diff
changeset
|
10 |
|
53
12d806823775
add irc_client module, plus nexus.h header
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
11 |
#include <event2/event.h> |
70
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
57
diff
changeset
|
12 |
#include "signals.h" |
55
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
13 |
#include "module.h" |
53
12d806823775
add irc_client module, plus nexus.h header
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
14 |
#include "irc_client.h" |
105
b6b183fbf373
implement a separate nexus_lua module
Tero Marttila <terom@fixme.fi>
parents:
103
diff
changeset
|
15 |
#include "nexus_lua.h" |
b6b183fbf373
implement a separate nexus_lua module
Tero Marttila <terom@fixme.fi>
parents:
103
diff
changeset
|
16 |
#include "lua_console.h" |
53
12d806823775
add irc_client module, plus nexus.h header
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
17 |
|
12d806823775
add irc_client module, plus nexus.h header
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
18 |
/** |
87 | 19 |
* The central brain, as created in the main() function. |
53
12d806823775
add irc_client module, plus nexus.h header
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
20 |
*/ |
55
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
21 |
struct nexus { |
53
12d806823775
add irc_client module, plus nexus.h header
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
22 |
/** The libevent base */ |
12d806823775
add irc_client module, plus nexus.h header
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
23 |
struct event_base *ev_base; |
12d806823775
add irc_client module, plus nexus.h header
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
24 |
|
70
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
57
diff
changeset
|
25 |
/** Our signal handlers */ |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
57
diff
changeset
|
26 |
struct signals *signals; |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
57
diff
changeset
|
27 |
|
55
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
28 |
/** Our loaded modules */ |
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
29 |
struct modules *modules; |
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
30 |
|
53
12d806823775
add irc_client module, plus nexus.h header
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
31 |
/** The IRC client state */ |
12d806823775
add irc_client module, plus nexus.h header
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
32 |
struct irc_client *client; |
103
454aea1e4f11
implement nexus_shutdown, lua_modules/lua_module, and lua_nexus
Tero Marttila <terom@fixme.fi>
parents:
93
diff
changeset
|
33 |
|
105
b6b183fbf373
implement a separate nexus_lua module
Tero Marttila <terom@fixme.fi>
parents:
103
diff
changeset
|
34 |
/** Our lua state */ |
b6b183fbf373
implement a separate nexus_lua module
Tero Marttila <terom@fixme.fi>
parents:
103
diff
changeset
|
35 |
struct nexus_lua *lua; |
b6b183fbf373
implement a separate nexus_lua module
Tero Marttila <terom@fixme.fi>
parents:
103
diff
changeset
|
36 |
|
b6b183fbf373
implement a separate nexus_lua module
Tero Marttila <terom@fixme.fi>
parents:
103
diff
changeset
|
37 |
/** Our lua console */ |
b6b183fbf373
implement a separate nexus_lua module
Tero Marttila <terom@fixme.fi>
parents:
103
diff
changeset
|
38 |
struct lua_console *lua_console; |
b6b183fbf373
implement a separate nexus_lua module
Tero Marttila <terom@fixme.fi>
parents:
103
diff
changeset
|
39 |
|
103
454aea1e4f11
implement nexus_shutdown, lua_modules/lua_module, and lua_nexus
Tero Marttila <terom@fixme.fi>
parents:
93
diff
changeset
|
40 |
/** Shutting down? */ |
454aea1e4f11
implement nexus_shutdown, lua_modules/lua_module, and lua_nexus
Tero Marttila <terom@fixme.fi>
parents:
93
diff
changeset
|
41 |
bool shutdown; |
53
12d806823775
add irc_client module, plus nexus.h header
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
42 |
}; |
12d806823775
add irc_client module, plus nexus.h header
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
43 |
|
12d806823775
add irc_client module, plus nexus.h header
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
44 |
/** |
109
bfe9b9a8fe5b
fix some more valgrind errors
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
45 |
* Load a config file into the nexus from the given path |
bfe9b9a8fe5b
fix some more valgrind errors
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
46 |
*/ |
bfe9b9a8fe5b
fix some more valgrind errors
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
47 |
err_t nexus_load_config (struct nexus *nexus, const char *path, struct error_info *err); |
bfe9b9a8fe5b
fix some more valgrind errors
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
48 |
|
bfe9b9a8fe5b
fix some more valgrind errors
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
49 |
/** |
103
454aea1e4f11
implement nexus_shutdown, lua_modules/lua_module, and lua_nexus
Tero Marttila <terom@fixme.fi>
parents:
93
diff
changeset
|
50 |
* Shut down the nexus cleanly. It /should/ be safe to call this several times, but it won't do anything. |
454aea1e4f11
implement nexus_shutdown, lua_modules/lua_module, and lua_nexus
Tero Marttila <terom@fixme.fi>
parents:
93
diff
changeset
|
51 |
* |
454aea1e4f11
implement nexus_shutdown, lua_modules/lua_module, and lua_nexus
Tero Marttila <terom@fixme.fi>
parents:
93
diff
changeset
|
52 |
* Once everything has shut down nicely (which it should, unless there's something buggy), the event loop should exit, |
454aea1e4f11
implement nexus_shutdown, lua_modules/lua_module, and lua_nexus
Tero Marttila <terom@fixme.fi>
parents:
93
diff
changeset
|
53 |
* and the main() function return. |
454aea1e4f11
implement nexus_shutdown, lua_modules/lua_module, and lua_nexus
Tero Marttila <terom@fixme.fi>
parents:
93
diff
changeset
|
54 |
*/ |
454aea1e4f11
implement nexus_shutdown, lua_modules/lua_module, and lua_nexus
Tero Marttila <terom@fixme.fi>
parents:
93
diff
changeset
|
55 |
void nexus_shutdown (struct nexus *nexus); |
454aea1e4f11
implement nexus_shutdown, lua_modules/lua_module, and lua_nexus
Tero Marttila <terom@fixme.fi>
parents:
93
diff
changeset
|
56 |
|
454aea1e4f11
implement nexus_shutdown, lua_modules/lua_module, and lua_nexus
Tero Marttila <terom@fixme.fi>
parents:
93
diff
changeset
|
57 |
/** |
109
bfe9b9a8fe5b
fix some more valgrind errors
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
58 |
* Shut down the nexus fast. This will stop the event loop right away, which should lead to nexus_destroy being called. |
bfe9b9a8fe5b
fix some more valgrind errors
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
59 |
*/ |
bfe9b9a8fe5b
fix some more valgrind errors
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
60 |
void nexus_crash (struct nexus *nexus); |
bfe9b9a8fe5b
fix some more valgrind errors
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
61 |
|
bfe9b9a8fe5b
fix some more valgrind errors
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
62 |
/** |
bfe9b9a8fe5b
fix some more valgrind errors
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
63 |
* Destroy the nexus directly. This is intended to be used once the event loop as exited. |
103
454aea1e4f11
implement nexus_shutdown, lua_modules/lua_module, and lua_nexus
Tero Marttila <terom@fixme.fi>
parents:
93
diff
changeset
|
64 |
*/ |
454aea1e4f11
implement nexus_shutdown, lua_modules/lua_module, and lua_nexus
Tero Marttila <terom@fixme.fi>
parents:
93
diff
changeset
|
65 |
void nexus_destroy (struct nexus *nexus); |
454aea1e4f11
implement nexus_shutdown, lua_modules/lua_module, and lua_nexus
Tero Marttila <terom@fixme.fi>
parents:
93
diff
changeset
|
66 |
|
454aea1e4f11
implement nexus_shutdown, lua_modules/lua_module, and lua_nexus
Tero Marttila <terom@fixme.fi>
parents:
93
diff
changeset
|
67 |
/** |
53
12d806823775
add irc_client module, plus nexus.h header
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
68 |
* The nexus main function, application entry point, etc. |
12d806823775
add irc_client module, plus nexus.h header
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
69 |
*/ |
12d806823775
add irc_client module, plus nexus.h header
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
70 |
int main (int argc, char **argv); |
12d806823775
add irc_client module, plus nexus.h header
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
71 |
|
12d806823775
add irc_client module, plus nexus.h header
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
72 |
#endif /* NEXUS_H */ |