1 CtrlProxy developer documentation
2 =================================
3 Written by Jelmer Vernooij, 2003
8 Here's what some of the core files do:
10 cache.c - Caches and sends cached network state info
11 client.c - Maintains connections to clients
12 gen_config.c - Generates configuration file from current network state
13 hooks.c - Handles calling hooks for various things (connect/disconnect/message)
14 isupport.c - Maintains information about capabilities of server
15 line.c - Parse / generate IRC messages
16 linestack.c - Store lines / network state for later retrieval
19 network.c - Maintains connection to network
20 plugins.c - Handles loading/unloading of plugins
21 posix.c - POSIX support functions
22 redirect.c - Send message received from server to the right clients
23 repl.c - Replication support (sends JOIN/TOPIC messages to client from server state)
24 settings.c - Configuration
25 state.c - Maintains network state information (what users on which channel, etc)
26 util.c - Random utility functions
30 As has been said in the introduction, ctrlproxy
33 The simplest possible module can be found in example/foo.c in the source
36 The init_plugin function is called when the module is loaded.
37 In this function, you should register whatever functions the module
38 provides, such as a 'message handler' or a linestack backend. You
39 can use the data member of the plugin struct to store data for your plugin.
40 This function should return a boolean: false when initialisation failed
41 or true when it succeeded.
43 Building and installing
44 -----------------------
46 A module is in fact a shared library that's loaded
47 at run-time, when the program is already running. The .so file can
48 compiled with a command like:
50 $ gcc -shared -o foo.so input1.c input2.o input3.c
52 Message handler functions
53 -------------------------
55 A message handling function is a function that is called
56 whenever ctrlproxy receives an IRC message. The only argument
57 this function should have would be a line struct.
59 Registering a message handler
60 -----------------------------
62 All IRC lines that ctrlproxy receives and sends are passed thru
63 so-called 'filter functions'. These functions can do things based on
64 the contents of these lines, change the lines or stop further
65 processing of these lines.
67 To add a filter function, call 'add_filter'. To remove the filter
68 function again (usually when your plugin is being unloaded) call 'del_filter'.
73 add_filter("my_module", my_message_handler);
76 The prototype for the message handling function in the example
77 above would look something like this:
79 static gboolean my_message_handler(struct line *l);
81 Your message handler should return TRUE if the rest of the filter
82 functions should also see the message and FALSE if ctrlproxy should
83 stop running filter functions on the given line struct.</para>
85 These hooks are executed before the data as returned by find_channel()
86 and find_nick() is updated
88 Registering a new client/server or lose client/server handler
89 -------------------------------------------------------------
91 A module can also register a function that should be called when a new
92 client connects or when a client disconnects and when the server has successfully connected to
93 the client or when the connection to the client is broken.</para>
95 typedef gboolean (*new_client_hook) (struct client *);
96 typedef void (*lose_client_hook) (struct client *);
97 void add_new_client_hook(char *name, new_client_hook h);
98 void del_new_client_hook(char *name);
99 void add_lose_client_hook(char *name, lose_client_hook h);
100 void del_lose_client_hook(char *name);
102 typedef void (*server_connected_hook) (struct network *);
103 typedef void (*server_disconnected_hook) (struct network *);
104 void add_server_connected_hook(char *name, server_connected_hook);
105 void del_server_connected_hook(char *name);
106 void add_server_disconnected_hook(char *name, server_disconnected_hook);
107 void del_server_disconnected_hook(char *name);
109 The prototypes of these functions pretty much speak for themselves.
110 If a new_client_hook function returns FALSE, the client will be denied
113 Registering a initialization function
114 -------------------------------------
116 The initialization hooks are called after ctrlproxy has been initialized -
117 all plugins are loaded, all networks have been loaded.
119 typedef void (*initialized_hook) (void);
120 void add_initialized_hook(initialized_hook);
122 Registering a MOTD function
123 ---------------------------
125 MOTD functions are functions that add one or more lines to
126 the MOTD that is sent to a client.
128 A module can register a MOTD function using the add_motd_hook() and
129 del_motd_hook() functions, that work similar to the add_new_client_hook() and
130 del_new_client_hook() functions documented above.
132 A motd function should return a dynamically allocated array containing
133 dynamically allocated nul-terminated strings that should be added to the MOTD.
138 Ctrlproxy uses GLib's logging functions. Read the related section in the
139 GLib documentation for details.
144 Paths to data should be configurable, but default to the file/directory name
145 returned by ctrlproxy_path(). The argument to this function should be the
146 name of the subsystem.
148 All top level directories have been created when this function
151 If NULL was returned, one or more directories could not be created.
155 Two very useful utilities are valgrind and gdb.
157 If you're running from gdb, make sure you have set the following:
159 handle SIGPIPE nostop
164 The debug module, if compiled adds support for the following two admin commands,
165 that might be useful when debugging:
168 Makes ctrlproxy print a list of the channels it
169 thinks it has joined on the current network.