c-icap-doc  0.1
Data Fields
ci_service_module Struct Reference

Is the structure which implements a service. More...

#include <service.h>

Data Fields

const char * mod_name
 The service name.
 
const char * mod_short_descr
 Service short description.
 
int mod_type
 Service type. More...
 
int(* mod_init_service )(ci_service_xdata_t *srv_xdata, struct ci_server_conf *server_conf)
 Pointer to the function called when the service loaded. More...
 
int(* mod_post_init_service )(ci_service_xdata_t *srv_xdata, struct ci_server_conf *server_conf)
 Pointer to the function which called after the c-icap initialized, but before the c-icap start serves requests. More...
 
void(* mod_close_service )()
 Pointer to the function which called on c-icap server shutdown. More...
 
void *(* mod_init_request_data )(struct ci_request *req)
 Pointer to the function called when a new request for this services arrives to c-icap server. More...
 
void(* mod_release_request_data )(void *srv_data)
 Pointer to the function which releases the service data. More...
 
int(* mod_check_preview_handler )(char *preview_data, int preview_data_len, struct ci_request *req)
 Pointer to the function which is used to preview the ICAP client request. More...
 
int(* mod_end_of_data_handler )(struct ci_request *req)
 Pointer to the function called when the icap client has send all the data to the service. More...
 
int(* mod_service_io )(char *wbuf, int *wlen, char *rbuf, int *rlen, int iseof, struct ci_request *req)
 Pointer to the function called to read/send body data from/to icap client. More...
 
struct ci_conf_entrymod_conf_table
 Pointer to the config table of the service. More...
 
void * mod_data
 NULL pointer. More...
 

Detailed Description

Is the structure which implements a service.

To implement a service someones needs to implement the member functions of this struct. These functions will be called by c-icap as follows:

Examples:
services/echo/srv_echo.c.

Field Documentation

int(* ci_service_module::mod_check_preview_handler)(char *preview_data, int preview_data_len, struct ci_request *req)

Pointer to the function which is used to preview the ICAP client request.

The client if supports preview sends some data for examination. The service using this function will decide if the client request must processed so the client must send more data or no processing is needed so the request ended here.

Parameters
preview_dataPointer to the preview data
preview_data_lenThe size of preview data
reqPointer to the related ci_request struct
Returns
CI_MOD_CONTINUE if the client must send more data, CI_MOD_ALLOW204 if the service does not want to modify anything, or CI_ERROR on errors.
void(* ci_service_module::mod_close_service)()

Pointer to the function which called on c-icap server shutdown.

This function can be used to release service allocated resources

struct ci_conf_entry* ci_service_module::mod_conf_table

Pointer to the config table of the service.

Is an array which contains the definitions of configuration parameters used by the service. The configuration parameters defined in this array can be used in c-icap.conf file.

void* ci_service_module::mod_data

NULL pointer.

This field does not used. Set it to NULL.

int(* ci_service_module::mod_end_of_data_handler)(struct ci_request *req)

Pointer to the function called when the icap client has send all the data to the service.

This function called when the ICAP client has send all data.

Parameters
reqpointer to the related ci_request struct
Returns
CI_MOD_DONE if all are OK, CI_MOD_ALLOW204 if the ICAP client request supports 204 responses and we are not planning to modify anything, or CI_ERROR on errors. The service must not return CI_MOD_ALLOW204 if has already send some data to the client, or when the client does not support allow204 responses. To examine if client supports 204 responses the ci_req_allow204 macro can be used
void*(* ci_service_module::mod_init_request_data)(struct ci_request *req)

Pointer to the function called when a new request for this services arrives to c-icap server.

This function should inititalize the data and structures required for serving the request.

Parameters
reqa pointer to the related ci_request_t structure
Returns
a void pointer to the "service data", the user defined data required for serving the request.The developer can obtain the service data from the related ci_request_t object using the macro ci_service_data
int(* ci_service_module::mod_init_service)(ci_service_xdata_t *srv_xdata, struct ci_server_conf *server_conf)

Pointer to the function called when the service loaded.

This function called exactly when the service loaded by c-icap. Can be used to initialize the service.

Parameters
srv_xdataPointer to the ci_service_xdata_t object of this service
server_confPointer to the struct holds the main c-icap server configuration
Returns
CI_OK on success, CI_ERROR on any error.
int(* ci_service_module::mod_post_init_service)(ci_service_xdata_t *srv_xdata, struct ci_server_conf *server_conf)

Pointer to the function which called after the c-icap initialized, but before the c-icap start serves requests.

This function can be used to initialize the service. Unlike to the ci_service_module::mod_init_service, when this function called the c-icap has initialized and it is known system parameters like the services and modules which are loaded, network ports and addresses the c-icap is listening to, etc.

Parameters
srv_xdataPointer to the ci_service_xadata_t object of this service
server_confPointer to the struct holds the main c-icap server configuration
Returns
CI_OK on success, CI_ERROR on errors.
void(* ci_service_module::mod_release_request_data)(void *srv_data)

Pointer to the function which releases the service data.

This function called after the user request served to release the service data

Parameters
srv_datapointer to the service data returned by the ci_service_module::mod_init_request_data call
int(* ci_service_module::mod_service_io)(char *wbuf, int *wlen, char *rbuf, int *rlen, int iseof, struct ci_request *req)

Pointer to the function called to read/send body data from/to icap client.

This function reads body data from the ICAP client and sends back the modified body data. To allow c-icap send data to the ICAP client before all data received by the c-icap, a call to the ci_req_unlock_data function is required.

Parameters
wbufThe buffer for writing data to the ICAP client
wlenThe size of the write buffer. It must modified to be the size of writing data. If the service has send all the data to the client, this parameter must set to CI_EOF.
rbufPointer to the data read from the ICAP client
rlenThe lenght of the data read from the ICAP client. If this function for a reason can not read all the data, it must modify the rlen to be equal to the read data
iseofIt has non zero value if the data in rbuf buffer are the last data from the ICAP client.
reqpointer to the related ci_request struct
Returns
Return CI_OK if all are OK or CI_ERROR on errors
int ci_service_module::mod_type

Service type.

The service type can be ICAP_RESPMOD for a responce modification service, ICAP_REQMOD for request modification service or ICAP_RESPMOD|ICAP_REQMOD for a service implements both response and request modification


The documentation for this struct was generated from the following file: