c-icap-doc  0.1
Functions
Data type recogintion api

Macros, functions and structures used for data type recognition. More...

Functions

struct ci_magics_db * ci_magic_db_load (const char *filename)
 Read the magics db from a file and create a ci_magics_db object. More...
 
int ci_magic_req_data_type (ci_request_t *req, int *isencoded)
 Return the type of data of an c-icap request object. More...
 
int ci_magic_type_id (const char *name)
 Finds the type id from type name. More...
 
int ci_magic_group_id (const char *group)
 Finds the group id from group name. More...
 
int ci_magic_group_check (int type, int group)
 Checks if a magic type belongs to a magic types group. More...
 
int ci_magic_types_count ()
 The number of types stored in internal magic db. More...
 
int ci_magic_groups_count ()
 The number of groups stored in internal magic db. More...
 
char * ci_magic_type_name (int type)
 Retrieve the name of a magic type. More...
 
char * ci_magic_type_descr (int type)
 Retrieve the short description of a magic type. More...
 
char * ci_magic_group_name (int group)
 Retrieve the name of a magic types group. More...
 

Detailed Description

Macros, functions and structures used for data type recognition.

Function Documentation

struct ci_magics_db* ci_magic_db_load ( const char *  filename)

Read the magics db from a file and create a ci_magics_db object.

The user normaly does not need to call this function inside c-icap server. It is not a thread safe function, should called only during icap library initialization before threads started.

Parameters
filenameis the name of the file contains the db
Returns
a pointer to a ci_magics_db object
int ci_magic_group_check ( int  type,
int  group 
)

Checks if a magic type belongs to a magic types group.

Parameters
typeis the type id to check
groupis the group id
Returns
non zero if the type belongs to group, zero otherwise
int ci_magic_group_id ( const char *  group)

Finds the group id from group name.

Parameters
groupis the name of the group
Returns
the group id
char* ci_magic_group_name ( int  group)

Retrieve the name of a magic types group.

Parameters
groupthe group id
Returns
the name of the group or NULL if the group does not exists
int ci_magic_groups_count ( )

The number of groups stored in internal magic db.

Returns
the number of stored magic groups
int ci_magic_req_data_type ( ci_request_t req,
int *  isencoded 
)

Return the type of data of an c-icap request object.

This function checks the preview data of the request. If the data are encoded this function try to uncompress them before data type recognition

Parameters
reqthe c-icap request (ci_request_t) data
isencodedset to CI_ENCODE_GZIP, CI_ENCODE_DEFLATE or CI_ENCODE_UNKNOWN if the data are encoded with an unknown method
Returns
the data type or -1 if the data type recognition fails for a reason (eg no preview data, of library not initialized)
char* ci_magic_type_descr ( int  type)

Retrieve the short description of a magic type.

Parameters
typethe type id
Returns
the short description if the type or NULL if the type does not exists
int ci_magic_type_id ( const char *  name)

Finds the type id from type name.

Parameters
nameis the name of the magic type
Returns
the type id
char* ci_magic_type_name ( int  type)

Retrieve the name of a magic type.

Parameters
typethe type id
Returns
the name of the type or NULL if the type does not exists
int ci_magic_types_count ( )

The number of types stored in internal magic db.

Returns
the number of stored magic types