<commit_before>#the CBUS reference implentation

This API description only covers the "public" API. all other
function are meant for internal use only and may be subject to change
##Central data types

###struct CBUS\_conn
This structure holds the information on a single connection

**Fields**

- char \*address | the address of the connection
- int fd | the file descriptor
- struct CBUS\_sub \*subs | the signals the client subscribed to.
- char \*path | the path of the Unix Domain Socket, which this
connection is connected to

###struct CBUS\_sub
This structure holds information on a single signal subscription of a
connection

- char \*sender\_name | which sender we want to listen for
- char \*signal\_name | which signal name we want to listen for

###struct CBUS\_msg

- uint32\_t length  | the length of the message
- uint32\_t type | the type of the message
- uint32\_t serial | the serial of the message
- char \*token | the token
- char \*from | the sender's name
- char \*to | the receiver's name
- char \*fn\_name | the signal's or sender's name
- char \*arg\_str | string describing the arguments
- struct CBUS\_arg \*args | the arguments
- char \*msg | the message as is

Refer to the protocol definition for more information on this
data structure

###struct CBUS\_arg

- int int\_value | the value, if it is an int;
- double double\_value | the value, if it is a double;
- char \*str\_value | the value if it is a string;
- int type | the type of the argument

You may only access the \*\_value which matches the data type

#The API

##Parsing messages

###struct CBUS\_msg \*cbus\_parse\_msg(char \*msg);

**Arguments**
- char \*msg | the message to be parsed

**Returns**
- a CBUS\_msg struct representing the message, or NULL on failure

*Note:* Do not free msg, it will be freed on calling cbus\_free\_msg

###void cbus\_free\_msg(struct CBUS\_msg \*msg);

Frees a message

**Arguments**
- struct CBUS\_msg \*msg | will be freed

##Helpers

###int fn\_call\_mathches(struct CBUS\_msg \*msg, char \*to, char \*fn\_name, char \*args);
Checks wether the arguments given to this function are equal to the
corresponding fields inside the "msg" structure.

Arguments may be "", when they aren't checked for.

###int fn\_return\_mathches(struct CBUS\_msg \*msg, char \*from, char \*fn\_name, char \*args);
Checks wether the arguments given to this function are equal to the
corresponding fields inside the "msg" structure.

Arguments may be "", when they aren't checked for.

###int signal\_mathches(struct CBUS\_msg \*msg, char \*from, char \*sig\_name, char \*args);
Checks wether the arguments given to this function are equal to the
corresponding fields inside the "msg" structure.

Arguments may be "", when they aren't checked for.

###void cbus\_print\_msg(struct CBUS\_msg \*msg)

Debug call to print messages

**Arguments**
- struct CBUS\_msg \*msg | the message to be printed

##Starting and stopping the connection

###struct CBUS\_conn \*cbus\_connect(char \*address, int \*err)

**Arguments**
- char \*address | the base directory of the CBUS instance
- int \*err | An pointer to an integer filled with an error code

**Returns**

A pointer to a struct CBUS\_conn representing the connection, or 
NULL on failure

**Errors**<commit_msg>Edited documentation<commit_after>#the CBUS reference implentation

This API description only covers the "public" API. all other
function are meant for internal use only and may be subject to change
##Central data types

###struct CBUS\_conn
This structure holds the information on a single connection

**Fields**

- char \*address | the address of the connection
- int fd | the file descriptor
- struct CBUS\_sub \*subs | the signals the client subscribed to.
- char \*path | the path of the Unix Domain Socket, which this
connection is connected to

###struct CBUS\_sub
This structure holds information on a single signal subscription of a
connection

- char \*sender\_name | which sender we want to listen for
- char \*signal\_name | which signal name we want to listen for

###struct CBUS\_msg

- uint32\_t length  | the length of the message
- uint32\_t type | the type of the message
- uint32\_t serial | the serial of the message
- char \*token | the token
- char \*from | the sender's name
- char \*to | the receiver's name
- char \*fn\_name | the signal's or sender's name
- char \*arg\_str | string describing the arguments
- struct CBUS\_arg \*args | the arguments
- char \*msg | the message as is

Refer to the protocol definition for more information on this
data structure

###struct CBUS\_arg

- int int\_value | the value, if it is an int;
- double double\_value | the value, if it is a double;
- char \*str\_value | the value if it is a string;
- int type | the type of the argument

You may only access the \*\_value which matches the data type

#The API

##Helpers

###int fn\_call\_matches(struct CBUS\_msg \*msg, char \*to, char \*fn\_name, char \*args);
Checks wether the arguments given to this function are equal to the
corresponding fields inside the "msg" structure.

Arguments may be "", when they aren't checked for.

###int fn\_return\_matches(struct CBUS\_msg \*msg, char \*from, char \*fn\_name, char \*args);
Checks wether the arguments given to this function are equal to the
corresponding fields inside the "msg" structure.

Arguments may be "", when they aren't checked for.

###int signal\_matches(struct CBUS\_msg \*msg, char \*from, char \*sig\_name, char \*args);
Checks wether the arguments given to this function are equal to the
corresponding fields inside the "msg" structure.

Arguments may be "", when they aren't checked for.

###void cbus\_print\_msg(struct CBUS\_msg \*msg)

Debug call to print messages

**Arguments**
- struct CBUS\_msg \*msg | the message to be printed

##Starting and stopping the connection

###struct CBUS\_conn \*cbus\_connect(char \*address, int \*err)

**Arguments**
- char \*address | the base directory of the CBUS instance
- int \*err | An pointer to an integer filled with an error code

**Returns**

A pointer to a struct CBUS\_conn representing the connection, or 
NULL on failure

**Errors**
{'fraction_non_alphanumeric': 0.09612251547735419, 'fraction_numerical': 0.0019550342130987292, 'mean_word_length': 3.8877388535031847, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1108900', 'n_tokens_mistral': 1787, 'n_tokens_neox': 1677, 'n_words': 867}