XMMS2
xmmsv_c2c.c File Reference
#include <stddef.h>
#include "xmmsc/xmmsv.h"
#include "xmmsc/xmmsc_util.h"
#include "xmmscpriv/xmmsv_c2c.h"

Macros

#define GEN_C2C_FIELD_GET_FUNC(field, getter, ctype, failval)
 

Functions

int xmmsv_c2c_message_get_id (xmmsv_t *msg)
 Extract the id from a c2c message.
 
int xmmsv_c2c_message_get_sender (xmmsv_t *msg)
 Extract the sender id from a c2c message.
 
int xmmsv_c2c_message_get_destination (xmmsv_t *msg)
 Extract the destination id from a c2c message.
 
xmmsv_txmmsv_c2c_message_get_payload (xmmsv_t *msg)
 Extract the payload from a c2c message.
 
xmmsv_txmmsv_c2c_message_format (int sender, int dest, int id, xmmsv_t *payload)
 Format a client-to-client message.
 

Macro Definition Documentation

◆ GEN_C2C_FIELD_GET_FUNC

#define GEN_C2C_FIELD_GET_FUNC ( field,
getter,
ctype,
failval )
Value:
ctype \
xmmsv_c2c_message_get_##field (xmmsv_t *msg) \
{ \
ctype ret; \
if (!getter (msg, #field, &ret)) \
return failval; \
return ret; \
}

Referenced by xmmsv_c2c_message_get_destination(), xmmsv_c2c_message_get_payload(), and xmmsv_c2c_message_get_sender().

Function Documentation

◆ xmmsv_c2c_message_format()

xmmsv_t * xmmsv_c2c_message_format ( int sender,
int dest,
int id,
xmmsv_t * payload )

Format a client-to-client message.

Messages are dictionaries of the form:
"sender" : id of the sender client
"destination" : id of the destination client
"id" : 0 if the message doesn't expect reply, else a message id
"payload" : the contents of the message

Parameters
senderthe id of the sender client
destthe id of the destination client
idthe id of the message
payloadthe contents of the message
Returns
the formatted message
Note
Increases the refcount of payload.

Referenced by xmmsv_c2c_message_format().

◆ xmmsv_c2c_message_get_destination()

int xmmsv_c2c_message_get_destination ( xmmsv_t * msg)

Extract the destination id from a c2c message.

Parameters
msgThe client-to-client-message.
Returns
The destination id upon success, -1 upon failure.

◆ xmmsv_c2c_message_get_id()

int xmmsv_c2c_message_get_id ( xmmsv_t * msg)

Extract the id from a c2c message.

Parameters
msgThe client-to-client message.
Returns
The id upon success, -1 upon failure.

◆ xmmsv_c2c_message_get_payload()

xmmsv_t * xmmsv_c2c_message_get_payload ( xmmsv_t * msg)

Extract the payload from a c2c message.

Parameters
msgThe client-to-client message.
Returns
The payload upon success, NULL upon failure.

◆ xmmsv_c2c_message_get_sender()

int xmmsv_c2c_message_get_sender ( xmmsv_t * msg)

Extract the sender id from a c2c message.

Parameters
msgThe client-to-client message.
Returns
The sender id upon success, -1 upon failure.