First you have to change into the src/libserveez/coserver/
directory of the Serveez package. Then edit the Makefile.am and
add your header and implementation file to the
You have to declare the coserver handle routine here. This callback gets the input buffer argument and delivers the output buffer result. Both of these buffers are supposed to be lines separated by a ‘\n’.
Here you need to
#include "libserveez/coserver/coserver.h" and
implement the coserver handle routine declared in the coserver header file.
This can be any blocking system call. On successful completion you
can return the result or
NULL on errors. The input and output
buffers are plain strings and can have any format with one exception.
Because the coservers communicate via a line protocol with
Serveez these buffers must not contain ‘\n’ (0x0d).
For this you have to edit coserver.h and coserver.c files
which are located in the src/libserveez/coserver/ directory. In
the header file you have to define a further
(macro) and set the
MAX_COSERVER_TYPES define to the appropriate
value. Then you should define a further
svz_coserver_* macro in
the same file.
In coserver.c you have to implement the
This macro takes three arguments. The first is always specific to your
coserver and is used to create the actual request string. Then follows the
result callback routine, and an optional argument for this callback. The
latter two are simply passed to the
routine. This routine takes four arguments where the first is the
COSERVER_* id and the second is the input buffer
for the coserver handle routine without the trailing ‘\n’.
Then you need to add your coserver to the
COSERVER_* id, the coserver description, the coserver
handle routine discussed above, the number of coserver instances to be
created and an optional initialization routine.