CSL  5.2
message.c File Reference
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <netinet/in.h>
#include "lo_types_internal.h"
#include "lo_internal.h"
#include "lo/lo.h"

Go to the source code of this file.

Macros

#define LO_DEF_TYPE_SIZE   8
#define LO_DEF_DATA_SIZE   8
#define lo_pow2_over(a, b)   a = ((b > a) ? (a << ((int)((log(((double)b/(double)a))/0.69315)+1))) : a);

Functions

static int lo_message_add_typechar (lo_message m, char t)
static void * lo_message_add_data (lo_message m, size_t s)
void lo_arg_pp_internal (lo_type type, void *data, int bigendian)
lo_message lo_message_new ()
 Create a new lo_message object.
void lo_message_free (lo_message m)
 Free memory allocated by lo_message_new() and any subsequent lo_message_add_int32 lo_message_add*() calls.
int lo_message_add_varargs_internal (lo_message msg, const char *types, va_list ap, const char *file, int line)
int lo_message_add (lo_message msg, const char *types,...)
 Append a number of arguments to a message.
int lo_message_add_int32 (lo_message m, int32_t a)
 Append a data item and typechar of the specified type to a message.
int lo_message_add_float (lo_message m, float a)
 Append a data item and typechar of the specified type to a message. See lo_message_add_int32() for details.
int lo_message_add_string (lo_message m, const char *a)
 Append a data item and typechar of the specified type to a message. See lo_message_add_int32() for details.
int lo_message_add_blob (lo_message m, lo_blob a)
 Append a data item and typechar of the specified type to a message. See lo_message_add_int32() for details.
int lo_message_add_int64 (lo_message m, int64_t a)
 Append a data item and typechar of the specified type to a message. See lo_message_add_int32() for details.
int lo_message_add_timetag (lo_message m, lo_timetag a)
 Append a data item and typechar of the specified type to a message. See lo_message_add_int32() for details.
int lo_message_add_double (lo_message m, double a)
 Append a data item and typechar of the specified type to a message. See lo_message_add_int32() for details.
int lo_message_add_symbol (lo_message m, const char *a)
 Append a data item and typechar of the specified type to a message. See lo_message_add_int32() for details.
int lo_message_add_char (lo_message m, char a)
 Append a data item and typechar of the specified type to a message. See lo_message_add_int32() for details.
int lo_message_add_midi (lo_message m, uint8_t a[4])
 Append a data item and typechar of the specified type to a message. See lo_message_add_int32() for details.
int lo_message_add_true (lo_message m)
 Append a data item and typechar of the specified type to a message. See lo_message_add_int32() for details.
int lo_message_add_false (lo_message m)
 Append a data item and typechar of the specified type to a message. See lo_message_add_int32() for details.
int lo_message_add_nil (lo_message m)
 Append a data item and typechar of the specified type to a message. See lo_message_add_int32() for details.
int lo_message_add_infinitum (lo_message m)
 Append a data item and typechar of the specified type to a message. See lo_message_add_int32() for details.
int lo_strsize (const char *s)
 A function to calculate the amount of OSC message space required by a C char *.
size_t lo_arg_size (lo_type type, void *data)
 Return the storage size, in bytes, of the given argument.
char * lo_get_path (void *data, ssize_t size)
 Given a raw OSC message, return the message path.
ssize_t lo_validate_string (void *data, ssize_t size)
 Validate raw OSC string data. Where applicable, data should be in network byte order.
ssize_t lo_validate_blob (void *data, ssize_t size)
 Validate raw OSC blob data. Where applicable, data should be in network byte order.
ssize_t lo_validate_bundle (void *data, ssize_t size)
 Validate raw OSC bundle data. Where applicable, data should be in network byte order.
ssize_t lo_validate_arg (lo_type type, void *data, ssize_t size)
 Validate raw OSC argument data. Where applicable, data should be in network byte order.
void lo_arg_host_endian (lo_type type, void *data)
 Convert the specified argument to host byte order where necessary.
void lo_arg_network_endian (lo_type type, void *data)
 Convert the specified argument to network byte order where necessary.
lo_address lo_message_get_source (lo_message m)
 Returns the source (lo_address) of an incoming message.
lo_timetag lo_message_get_timestamp (lo_message m)
 Returns the timestamp (lo_timetag *) of a bundled incoming message.
size_t lo_message_length (lo_message m, const char *path)
 Return the length of a message in bytes.
int lo_message_get_argc (lo_message m)
 Return the message argument count.
lo_arg ** lo_message_get_argv (lo_message m)
 Return the message arguments. Do not free the returned data.
char * lo_message_get_types (lo_message m)
 Return the message type tag string.
void * lo_message_serialise (lo_message m, const char *path, void *to, size_t *size)
 Serialise the lo_message object to an area of memory and return a pointer to the serialised form. Opposite of lo_message_deserialise().
lo_message lo_message_deserialise (void *data, size_t size, int *result)
 Deserialise a raw OSC message and return a new lo_message object. Opposite of lo_message_serialise().
void lo_message_pp (lo_message m)
 Pretty-print a lo_message object.
void lo_arg_pp (lo_type type, void *data)
 Pretty-print a set of typed arguments.
int lo_is_numerical_type (lo_type a)
 Return true if the type specified has a numerical value, such as LO_INT32, LO_FLOAT etc.
int lo_is_string_type (lo_type a)
 Return true if the type specified has a textual value, such as LO_STRING or LO_SYMBOL.
int lo_coerce (lo_type type_to, lo_arg *to, lo_type type_from, lo_arg *from)
 Attempt to convert one OSC type to another.
lo_hires lo_hires_val (lo_type type, lo_arg *p)
 Return the numerical value of the given argument with the maximum native system precision.

Variables

static char lo_numerical_types []
static char lo_string_types []

Macro Definition Documentation

#define LO_DEF_TYPE_SIZE   8

Definition at line 34 of file message.c.

Referenced by lo_message_add_typechar(), and lo_message_new().

#define LO_DEF_DATA_SIZE   8

Definition at line 35 of file message.c.

Referenced by lo_message_add_data().

#define lo_pow2_over (   a,
 
)    a = ((b > a) ? (a << ((int)((log(((double)b/(double)a))/0.69315)+1))) : a);

Definition at line 59 of file message.c.

Referenced by lo_message_add_data().


Function Documentation

ssize_t lo_validate_string ( void *  data,
ssize_t  size 
)

Validate raw OSC string data. Where applicable, data should be in network byte order.

This function is used internally to parse and validate raw OSC data.

Returns length of string or < 0 if data is invalid.

Parameters:
dataA pointer to the data.
sizeThe size of data in bytes (total bytes remaining).

Definition at line 507 of file message.c.

References data, LO_EPAD, LO_ESIZE, and LO_ETERM.

Referenced by lo_get_path(), lo_message_deserialise(), lo_server_dispatch_data(), lo_validate_arg(), and lo_validate_bundle().

ssize_t lo_validate_blob ( void *  data,
ssize_t  size 
)

Validate raw OSC blob data. Where applicable, data should be in network byte order.

This function is used internally to parse and validate raw OSC data.

Returns length of blob or < 0 if data is invalid.

Parameters:
dataA pointer to the data.
sizeThe size of data in bytes (total bytes remaining).

Definition at line 536 of file message.c.

References LO_EPAD, LO_ESIZE, LO_MAX_MSG_SIZE, and lo_otoh32.

Referenced by lo_validate_arg().

ssize_t lo_validate_bundle ( void *  data,
ssize_t  size 
)

Validate raw OSC bundle data. Where applicable, data should be in network byte order.

This function is used internally to parse and validate raw OSC data.

Returns length of bundle or < 0 if data is invalid.

Parameters:
dataA pointer to the data.
sizeThe size of data in bytes (total bytes remaining).

Definition at line 563 of file message.c.

References data, LO_EINVALIDBUND, LO_ESIZE, lo_otoh32, and lo_validate_string().

Referenced by lo_server_dispatch_data().

ssize_t lo_validate_arg ( lo_type  type,
void *  data,
ssize_t  size 
)

Validate raw OSC argument data. Where applicable, data should be in network byte order.

This function is used internally to parse and validate raw OSC data.

Returns length of argument data or < 0 if data is invalid.

Parameters:
typeThe OSC type of the data item (eg. LO_FLOAT).
dataA pointer to the data.
sizeThe size of data in bytes (total bytes remaining).

Definition at line 603 of file message.c.

References LO_BLOB, LO_CHAR, LO_DOUBLE, LO_EINVALIDTYPE, LO_ESIZE, LO_FALSE, LO_FLOAT, LO_INFINITUM, LO_INT32, LO_INT64, LO_INT_ERR, LO_MIDI, LO_NIL, LO_STRING, LO_SYMBOL, LO_TIMETAG, LO_TRUE, lo_validate_blob(), and lo_validate_string().

Referenced by lo_message_deserialise().


Variable Documentation

char lo_numerical_types[]
static
Initial value:

Definition at line 37 of file message.c.

Referenced by lo_is_numerical_type().

char lo_string_types[]
static
Initial value:
{
'\0'
}

Definition at line 45 of file message.c.

Referenced by lo_is_string_type().