Factory object for protocol messages. More...
#include <msg_mclass.h>
Data Fields | |
struct msg_hclass_s | mc_hclass [1] |
Recursive header class. | |
char const * | mc_name |
Protocol name, e.g., "SIP/2.0". | |
void * | mc_tag |
Protocol-specific tag. | |
unsigned | mc_flags |
Default flags. | |
unsigned | mc_msize |
Size of public message structure. | |
issize_t(* | mc_extract_body )(msg_t *msg, msg_pub_t *pub, char b[], isize_t bsiz, int eos) |
Function extracting the message contents. | |
msg_href_t | mc_request [1] |
Request line reference. | |
msg_href_t | mc_status [1] |
Status line reference. | |
msg_href_t | mc_separator [1] |
Separator line reference. | |
msg_href_t | mc_payload [1] |
Message body reference. | |
msg_href_t | mc_unknown [1] |
Reference for unknown headers. | |
msg_href_t | mc_error [1] |
Reference for erroneous header. | |
msg_href_t | mc_multipart [1] |
Multipart body reference. | |
msg_href_t const * | mc_short |
Short forms (or NULL). | |
short | mc_hash_size |
Size of parsing table. | |
short | mc_hash_used |
Number of headers in parsing table. | |
msg_href_t | mc_hash [MC_HASH_SIZE] |
Hash table for parsing containing reference for each header. | |
Related Functions | |
(Note that these are not member functions.) | |
msg_mclass_t * | msg_mclass_clone (msg_mclass_t const *old, int newsize, int empty) |
Clone a message class. | |
int | msg_mclass_insert_header (msg_mclass_t *mc, msg_hclass_t *hc, unsigned short offset) |
Add a new header to the message class. | |
int | msg_mclass_insert_with_mask (msg_mclass_t *mc, msg_hclass_t *hc, unsigned short offset, unsigned short flags) |
Add a new header to the message class. | |
int | msg_mclass_insert (msg_mclass_t *mc, msg_href_t const *hr) |
Add a header reference to the message class. | |
msg_href_t const * | msg_find_hclass (msg_mclass_t const *mc, char const *s, isize_t *return_start_of_content) |
Search for a header class. |
Factory object for protocol messages.
The message class is a kind of a factory object used to create new message objects for the protocol it represents (see msg_create()).
The message class object contains all the information needed to parse a message. It used when headers are added or removed from the message. When a message is sent, the message class is used to order message components and print (encode) the message in text format.
The message class contains reference objects to headers and other components within the message. Each reference contains a pointer to a header class and a offset to the header objects within public message structure. The parser engine uses these references when it adds a newly parsed header object to the message structure. The function msg_find_hclass() searches for the reference of the named header.
The application can make a copy of existing message class object using the function msg_mclass_clone(). New headers can be added to the message class with the msg_mclass_insert_header() and msg_mclass_insert() functions. The message class of an existing message object can be found out with the function msg_mclass().
msg_href_t const * msg_find_hclass | ( | msg_mclass_t const * | mc, | |
char const * | s, | |||
isize_t * | return_start_of_content | |||
) | [related] |
Search for a header class.
The function msg_find_hclass() searches for a header class from a message class based on the contents of the header to be parsed. The buffer s should point to the first character in the header name.
[in] | mc | message class object |
[in] | s | header contents |
[out] | return_start_of_content | start of header content (may be NULL) |
int msg_mclass_insert | ( | msg_mclass_t * | mc, | |
msg_href_t const * | hr | |||
) | [related] |
Add a header reference to the message class.
[in,out] | mc | pointer to a message class object |
[in] | hr | header reference object |
int msg_mclass_insert_header | ( | msg_mclass_t * | mc, | |
msg_hclass_t * | hc, | |||
unsigned short | offset | |||
) | [related] |
Add a new header to the message class.
Insert a header class hc to the message class object mc. If the given offset of the header in public message structure" is zero, the function extends the public message structure in order to store newly inserted header there.
[in,out] | mc | pointer to a message class object |
[in] | hc | pointer to a header class object |
[in] | offset | offset of the header in public message structure |
If the offset is 0, the msg_mclass_insert_header() increases size of the public message structure and places the header at the end of message.
int msg_mclass_insert_with_mask | ( | msg_mclass_t * | mc, | |
msg_hclass_t * | hc, | |||
unsigned short | offset, | |||
unsigned short | flags | |||
) | [related] |
Add a new header to the message class.
Insert a header class hc to the message class mc. If the given offset of the header in public message structure is zero, extend the size of the public message structure in order to store headers at the end of structure.
[in,out] | mc | pointer to a message class |
[in] | hc | pointer to a header class |
[in] | offset | offset of the header in public message structure |
[in] | flags | classification flags for the header |
issize_t(* mc_extract_body)(msg_t *msg, msg_pub_t *pub, char b[], isize_t bsiz, int eos) |
Function extracting the message contents.
msg_href_t mc_hash[MC_HASH_SIZE] |
Hash table for parsing containing reference for each header.