mirror of
https://framagit.org/bortzmeyer/echoping
synced 2024-11-15 00:12:48 +00:00
60 lines
2.1 KiB
Plaintext
60 lines
2.1 KiB
Plaintext
If you want to write your own plugins, you will first have to decide
|
|
wether your plugin uses a "cooked" hostname or a "raw" one.
|
|
|
|
In the first case, the cooked hostname, your plugin will receive from
|
|
echoping a struct addrinfo. All the DNS stuff, including IDN, is
|
|
performed by echoping. You can immediately start using the struct
|
|
addrinfo.
|
|
|
|
But some libraries (typically, the one used by the DBMS) do not work
|
|
on struct addrinfo but on strings such as "dbname=test
|
|
hostname=foo.bar". Plugins using these libraries will have to use the
|
|
raw interface. The host name given as argument is ignored.
|
|
|
|
You indicate to echoping wether you use the raw interface or the
|
|
cooked one by returning a port name or NULL from the init() function.
|
|
|
|
You will have to provide three functions:
|
|
|
|
char * init (const int argc, const char **argv, const echoping_options options))
|
|
Accepts remaining arguments (you have to use popt to parse them, or do
|
|
it by hand, getopt does not allow you to resume the parsing) and
|
|
returns a string identifying the port name (cooked interface) or NULL
|
|
(raw interface). The options struct will give you the global options
|
|
(see echoping.h).
|
|
|
|
For the cooked interface:
|
|
|
|
void start (struct addrinfo *res)
|
|
Typically just stores the res structure for later use.
|
|
|
|
For the raw interface:
|
|
|
|
void start_raw ()
|
|
Typically connects to the server.
|
|
|
|
int execute ()
|
|
Connects and do whatever the protocol requires. It is called once
|
|
per iteration. It returns >=0 if it succeeds, -1 if it failed
|
|
temporarily (so echoping will continue its loop) and -2 if it failed
|
|
permanently (so echoping will stop the iteration).
|
|
|
|
void terminate ()
|
|
Cleans everything. It is called after all iterations.
|
|
|
|
Start your plugin source code with:
|
|
|
|
#define IN_PLUGIN
|
|
#include "/wherever/echoping/is/installed/echoping.h"
|
|
|
|
You can look at random.c, the simplest plugin, and whois.c, the
|
|
simplest which still does something useful.
|
|
|
|
The documentation of the plugin should be in a manual page named
|
|
echoping_PLUGINNAME. See the above plugins for examples.
|
|
|
|
You can write a shell script named test.sh in the plugin directory to
|
|
test the plugin. test-echoping-plugins will execute it.
|
|
|
|
$Id$
|