| 1 | /* |
| 2 | * Copyright (C) 2014 Steve Harris et al. (see AUTHORS) |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU Lesser General Public License |
| 6 | * as published by the Free Software Foundation; either version 2.1 |
| 7 | * of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU Lesser General Public License for more details. |
| 13 | * |
| 14 | * $Id$ |
| 15 | */ |
| 16 | |
| 17 | #ifndef LO_LOWLEVEL_H |
| 18 | #define LO_LOWLEVEL_H |
| 19 | |
| 20 | #include "lo_osc_types.h" |
| 21 | |
| 22 | /** |
| 23 | * \file lo_lowlevel.h The liblo headerfile defining the low-level API |
| 24 | * functions. |
| 25 | */ |
| 26 | |
| 27 | #ifdef __cplusplus |
| 28 | extern "C" { |
| 29 | #endif |
| 30 | |
| 31 | #include <stdarg.h> |
| 32 | #include <sys/types.h> |
| 33 | #ifdef _MSC_VER |
| 34 | #include <BaseTsd.h> |
| 35 | typedef SSIZE_T ssize_t; |
| 36 | #endif |
| 37 | #include <stdint.h> |
| 38 | |
| 39 | |
| 40 | #include "lo_types.h" |
| 41 | #include "lo_errors.h" |
| 42 | |
| 43 | /** |
| 44 | * \defgroup liblolowlevel Low-level OSC API |
| 45 | * |
| 46 | * Use these functions if you require more precise control over OSC message |
| 47 | * contruction or handling that what is provided in the high-level functions |
| 48 | * described in liblo. |
| 49 | * @{ |
| 50 | */ |
| 51 | |
| 52 | /** |
| 53 | * \brief Type used to represent numerical values in conversions between OSC |
| 54 | * types. |
| 55 | */ |
| 56 | typedef long double lo_hires; |
| 57 | |
| 58 | |
| 59 | /** |
| 60 | * \brief A configuration struct for initializing \ref lo_server using lo_server_new_from_config(). |
| 61 | * |
| 62 | * User code is responsible for allocating and deallocating memory |
| 63 | * pointed to by this struct, including strings for group, port, |
| 64 | * iface, ip, etc. The struct and relevant fields will be copied by |
| 65 | * liblo when necessary, therefore it can be deallocated after use. |
| 66 | * The size field should be set to sizeof(lo_server_config). Fields |
| 67 | * set to 0 shall be ignored. |
| 68 | */ |
| 69 | typedef struct { |
| 70 | size_t size; |
| 71 | const char *group; |
| 72 | const char *port; |
| 73 | const char *iface; |
| 74 | const char *ip; |
| 75 | int proto; |
| 76 | lo_err_handler err_handler; |
| 77 | void *err_handler_context; |
| 78 | } lo_server_config; |
| 79 | |
| 80 | /** |
| 81 | * \brief Used with \ref lo_address_set_stream_slip() to specify whether sent |
| 82 | * messages should be encoded with SLIP, and whether the encoding should |
| 83 | * be single- or double-ENDed. |
| 84 | */ |
| 85 | typedef enum { |
| 86 | LO_SLIP_NONE = 0, |
| 87 | LO_SLIP_SINGLE = 1, |
| 88 | LO_SLIP_DOUBLE = 2 |
| 89 | } lo_slip_encoding; |
| 90 | |
| 91 | /** |
| 92 | * \brief Send a lo_message object to target targ |
| 93 | * |
| 94 | * This is slightly more efficient than lo_send() if you want to send a lot of |
| 95 | * similar messages. The messages are constructed with the lo_message_new() and |
| 96 | * \ref lo_message_add_int32 "lo_message_add*()" functions. |
| 97 | */ |
| 98 | int lo_send_message(lo_address targ, const char *path, lo_message msg); |
| 99 | |
| 100 | /** |
| 101 | * \brief Send a lo_message object to target targ from address of serv |
| 102 | * |
| 103 | * This is slightly more efficient than lo_send() if you want to send a lot of |
| 104 | * similar messages. The messages are constructed with the lo_message_new() and |
| 105 | * \ref lo_message_add_int32 "lo_message_add*()" functions. |
| 106 | * |
| 107 | * \param targ The address to send the message to |
| 108 | * \param serv The server socket to send the message from |
| 109 | * (can be NULL to use new socket) |
| 110 | * \param path The path to send the message to |
| 111 | * \param msg The bundle itself |
| 112 | */ |
| 113 | int lo_send_message_from(lo_address targ, lo_server serv, |
| 114 | const char *path, lo_message msg); |
| 115 | |
| 116 | /** |
| 117 | * \brief Send a lo_bundle object to address targ |
| 118 | * |
| 119 | * Bundles are constructed with the |
| 120 | * lo_bundle_new() and lo_bundle_add_message() functions. |
| 121 | */ |
| 122 | int lo_send_bundle(lo_address targ, lo_bundle b); |
| 123 | |
| 124 | /** |
| 125 | * \brief Send a lo_bundle object to address targ from address of serv |
| 126 | * |
| 127 | * Bundles are constructed with the |
| 128 | * lo_bundle_new() and lo_bundle_add_message() functions. |
| 129 | * |
| 130 | * \param targ The address to send the bundle to |
| 131 | * \param serv The server socket to send the bundle from |
| 132 | * (can be NULL to use new socket) |
| 133 | * \param b The bundle itself |
| 134 | */ |
| 135 | int lo_send_bundle_from(lo_address targ, lo_server serv, lo_bundle b); |
| 136 | |
| 137 | /** |
| 138 | * \brief Create a new lo_message object |
| 139 | */ |
| 140 | lo_message lo_message_new(void); |
| 141 | |
| 142 | /** |
| 143 | * \brief Add one to a message's reference count. |
| 144 | * |
| 145 | * Messages are reference counted. If a message is multiply referenced, |
| 146 | * the message's counter should be incremented. It is automatically |
| 147 | * decremented by lo_message_free lo_message_free_recursive, with |
| 148 | * lo_message_free_recursive being the preferable method. |
| 149 | */ |
| 150 | void lo_message_incref(lo_message m); |
| 151 | |
| 152 | /** |
| 153 | * \brief Create a new lo_message object by cloning an already existing one |
| 154 | */ |
| 155 | lo_message lo_message_clone(lo_message m); |
| 156 | |
| 157 | /** |
| 158 | * \brief Free memory allocated by lo_message_new() and any subsequent |
| 159 | * \ref lo_message_add_int32 lo_message_add*() calls. |
| 160 | */ |
| 161 | void lo_message_free(lo_message m); |
| 162 | |
| 163 | /** |
| 164 | * \brief Append a number of arguments to a message. |
| 165 | * |
| 166 | * The data will be added in OSC byteorder (bigendian). |
| 167 | * |
| 168 | * \param m The message to be extended. |
| 169 | * \param types The types of the data items in the message, types are defined in |
| 170 | * lo_types_common.h |
| 171 | * \param ... The data values to be transmitted. The types of the arguments |
| 172 | * passed here must agree with the types specified in the type parameter. |
| 173 | * |
| 174 | * \return Less than 0 on failure, 0 on success. |
| 175 | */ |
| 176 | int lo_message_add(lo_message m, const char *types, ...); |
| 177 | |
| 178 | /** \internal \brief the real message_add function (don't call directly) */ |
| 179 | int lo_message_add_internal(lo_message m, const char *file, const int line, |
| 180 | const char *types, ...); |
| 181 | |
| 182 | /** |
| 183 | * \brief Append a varargs list to a message. |
| 184 | * |
| 185 | * The data will be added in OSC byteorder (bigendian). |
| 186 | * IMPORTANT: args list must be terminated with LO_ARGS_END, or this call will |
| 187 | * fail. This is used to do simple error checking on the sizes of parameters |
| 188 | * passed. |
| 189 | * |
| 190 | * \param m The message to be extended. |
| 191 | * \param types The types of the data items in the message, types are defined in |
| 192 | * lo_types_common.h |
| 193 | * \param ap The va_list created by a C function declared with an |
| 194 | * ellipsis (...) argument, and pre-initialised with |
| 195 | * "va_start(ap)". The types of the arguments passed here must agree |
| 196 | * with the types specified in the type parameter. |
| 197 | * |
| 198 | * \return Less than 0 on failure, 0 on success. |
| 199 | */ |
| 200 | int lo_message_add_varargs(lo_message m, const char *types, va_list ap); |
| 201 | |
| 202 | /** \internal \brief the real message_add_varargs function (don't call directly) */ |
| 203 | int lo_message_add_varargs_internal(lo_message m, const char *types, va_list ap, |
| 204 | const char *file, const int line); |
| 205 | |
| 206 | /** |
| 207 | * \brief Append a data item and typechar of the specified type to a message. |
| 208 | * |
| 209 | * The data will be added in OSC byteorder (bigendian). |
| 210 | * |
| 211 | * \param m The message to be extended. |
| 212 | * \param a The data item. |
| 213 | * |
| 214 | * \return Less than 0 on failure, 0 on success. |
| 215 | */ |
| 216 | int lo_message_add_int32(lo_message m, int32_t a); |
| 217 | |
| 218 | /** |
| 219 | * \brief Append a data item and typechar of the specified type to a message. |
| 220 | * See lo_message_add_int32() for details. |
| 221 | * |
| 222 | * \return Less than 0 on failure, 0 on success. |
| 223 | */ |
| 224 | int lo_message_add_float(lo_message m, float a); |
| 225 | |
| 226 | /** |
| 227 | * \brief Append a data item and typechar of the specified type to a message. |
| 228 | * See lo_message_add_int32() for details. |
| 229 | * |
| 230 | * \return Less than 0 on failure, 0 on success. |
| 231 | */ |
| 232 | int lo_message_add_string(lo_message m, const char *a); |
| 233 | |
| 234 | /** |
| 235 | * \brief Append a data item and typechar of the specified type to a message. |
| 236 | * See lo_message_add_int32() for details. |
| 237 | * |
| 238 | * \return Less than 0 on failure, 0 on success. |
| 239 | */ |
| 240 | int lo_message_add_blob(lo_message m, lo_blob a); |
| 241 | |
| 242 | /** |
| 243 | * \brief Append a data item and typechar of the specified type to a message. |
| 244 | * See lo_message_add_int32() for details. |
| 245 | * |
| 246 | * \return Less than 0 on failure, 0 on success. |
| 247 | */ |
| 248 | int lo_message_add_int64(lo_message m, int64_t a); |
| 249 | |
| 250 | /** |
| 251 | * \brief Append a data item and typechar of the specified type to a message. |
| 252 | * See lo_message_add_int32() for details. |
| 253 | * |
| 254 | * \return Less than 0 on failure, 0 on success. |
| 255 | */ |
| 256 | int lo_message_add_timetag(lo_message m, lo_timetag a); |
| 257 | |
| 258 | /** |
| 259 | * \brief Append a data item and typechar of the specified type to a message. |
| 260 | * See lo_message_add_int32() for details. |
| 261 | * |
| 262 | * \return Less than 0 on failure, 0 on success. |
| 263 | */ |
| 264 | int lo_message_add_double(lo_message m, double a); |
| 265 | |
| 266 | /** |
| 267 | * \brief Append a data item and typechar of the specified type to a message. |
| 268 | * See lo_message_add_int32() for details. |
| 269 | * |
| 270 | * \return Less than 0 on failure, 0 on success. |
| 271 | */ |
| 272 | int lo_message_add_symbol(lo_message m, const char *a); |
| 273 | |
| 274 | /** |
| 275 | * \brief Append a data item and typechar of the specified type to a message. |
| 276 | * See lo_message_add_int32() for details. |
| 277 | * |
| 278 | * \return Less than 0 on failure, 0 on success. |
| 279 | */ |
| 280 | int lo_message_add_char(lo_message m, char a); |
| 281 | |
| 282 | /** |
| 283 | * \brief Append a data item and typechar of the specified type to a message. |
| 284 | * See lo_message_add_int32() for details. |
| 285 | * |
| 286 | * \return Less than 0 on failure, 0 on success. |
| 287 | */ |
| 288 | int lo_message_add_midi(lo_message m, uint8_t a[4]); |
| 289 | |
| 290 | /** |
| 291 | * \brief Append a data item and typechar of the specified type to a message. |
| 292 | * See lo_message_add_int32() for details. |
| 293 | * |
| 294 | * \return Less than 0 on failure, 0 on success. |
| 295 | */ |
| 296 | int lo_message_add_true(lo_message m); |
| 297 | |
| 298 | /** |
| 299 | * \brief Append a data item and typechar of the specified type to a message. |
| 300 | * See lo_message_add_int32() for details. |
| 301 | * |
| 302 | * \return Less than 0 on failure, 0 on success. |
| 303 | */ |
| 304 | int lo_message_add_false(lo_message m); |
| 305 | |
| 306 | /** |
| 307 | * \brief Append a data item and typechar of the specified type to a message. |
| 308 | * See lo_message_add_int32() for details. |
| 309 | * |
| 310 | * \return Less than 0 on failure, 0 on success. |
| 311 | */ |
| 312 | int lo_message_add_nil(lo_message m); |
| 313 | |
| 314 | /** |
| 315 | * \brief Append a data item and typechar of the specified type to a message. |
| 316 | * See lo_message_add_int32() for details. |
| 317 | * |
| 318 | * \return Less than 0 on failure, 0 on success. |
| 319 | */ |
| 320 | int lo_message_add_infinitum(lo_message m); |
| 321 | |
| 322 | /** |
| 323 | * \brief Returns the source (\ref lo_address) of an incoming message. |
| 324 | * |
| 325 | * Returns NULL if the message is outgoing. Do not free the returned |
| 326 | * address. This is usually called on the \ref lo_message passed to |
| 327 | * \ref lo_method_handler, to set up bidirectional communication. See |
| 328 | * \ref example_tcp_echo_server.c for an example of this. |
| 329 | */ |
| 330 | lo_address lo_message_get_source(lo_message m); |
| 331 | |
| 332 | /** |
| 333 | * \brief Returns the timestamp (lo_timetag *) of a bundled incoming message. |
| 334 | * |
| 335 | * Returns LO_TT_IMMEDIATE if the message is outgoing, or did not arrive |
| 336 | * contained in a bundle. Do not free the returned timetag. |
| 337 | */ |
| 338 | lo_timetag lo_message_get_timestamp(lo_message m); |
| 339 | |
| 340 | /** |
| 341 | * \brief Return the message type tag string. |
| 342 | * |
| 343 | * The result is valid until further data is added with lo_message_add*(). |
| 344 | */ |
| 345 | char *lo_message_get_types(lo_message m); |
| 346 | |
| 347 | /** |
| 348 | * \brief Return the message argument count. |
| 349 | * |
| 350 | * The result is valid until further data is added with lo_message_add*(). |
| 351 | */ |
| 352 | int lo_message_get_argc(lo_message m); |
| 353 | |
| 354 | /** |
| 355 | * \brief Return the message arguments. Do not free the returned data. |
| 356 | * |
| 357 | * The result is valid until further data is added with lo_message_add*(). |
| 358 | */ |
| 359 | lo_arg **lo_message_get_argv(lo_message m); |
| 360 | |
| 361 | /** |
| 362 | * \brief Return the length of a message in bytes. |
| 363 | * |
| 364 | * \param m The message to be sized |
| 365 | * \param path The path the message will be sent to |
| 366 | */ |
| 367 | size_t lo_message_length(lo_message m, const char *path); |
| 368 | |
| 369 | /** |
| 370 | * \brief Serialise the lo_message object to an area of memory and return a |
| 371 | * pointer to the serialised form. Opposite of lo_message_deserialise(). |
| 372 | * |
| 373 | * \param m The message to be serialised |
| 374 | * \param path The path the message will be sent to |
| 375 | * \param to The address to serialise to, memory will be allocated if to is |
| 376 | * NULL. |
| 377 | * \param size If this pointer is non-NULL the size of the memory area |
| 378 | * will be written here |
| 379 | * |
| 380 | * The returned form is suitable to be sent over a low level OSC transport, |
| 381 | * having the correct endianess and bit-packed structure. |
| 382 | */ |
| 383 | void *lo_message_serialise(lo_message m, const char *path, void *to, |
| 384 | size_t *size); |
| 385 | |
| 386 | /** |
| 387 | * \brief Deserialise a raw OSC message and return a new lo_message object. |
| 388 | * Opposite of lo_message_serialise(). |
| 389 | * |
| 390 | * \param data Pointer to the raw OSC message data in network transmission form |
| 391 | * (network byte order where appropriate). |
| 392 | * \param size The size of data in bytes |
| 393 | * \param result If this pointer is non-NULL, the result or error code will |
| 394 | * be written here. |
| 395 | * |
| 396 | * Returns a new lo_message, or NULL if deserialisation fails. |
| 397 | * Use lo_message_free() to free the resulting object. |
| 398 | */ |
| 399 | lo_message lo_message_deserialise(void *data, size_t size, int *result); |
| 400 | |
| 401 | /** |
| 402 | * \brief Dispatch a raw block of memory containing an OSC message. |
| 403 | * |
| 404 | * This is useful when a raw block of memory is available that is |
| 405 | * structured as OSC, and you wish to use liblo to dispatch the |
| 406 | * message to a handler function as if it had been received over the |
| 407 | * network. |
| 408 | * |
| 409 | * \param s The lo_server to use for dispatching. |
| 410 | * \param data Pointer to the raw OSC message data in network transmission form |
| 411 | * (network byte order where appropriate). |
| 412 | * \param size The size of data in bytes |
| 413 | * |
| 414 | * Returns the number of bytes used if successful, or less than 0 otherwise. |
| 415 | */ |
| 416 | int lo_server_dispatch_data(lo_server s, void *data, size_t size); |
| 417 | |
| 418 | /** |
| 419 | * \brief Return the hostname of a lo_address object |
| 420 | * |
| 421 | * Returned value must not be modified or free'd. Value will be a dotted quad, |
| 422 | * colon'd IPV6 address, or resolvable name. |
| 423 | */ |
| 424 | const char *lo_address_get_hostname(lo_address a); |
| 425 | |
| 426 | /** |
| 427 | * \brief Return the port/service name of a lo_address object |
| 428 | * |
| 429 | * Returned value must not be modified or free'd. Value will be a service name |
| 430 | * or ASCII representation of the port number. |
| 431 | */ |
| 432 | const char *lo_address_get_port(lo_address a); |
| 433 | |
| 434 | /** |
| 435 | * \brief Return the protocol of a lo_address object |
| 436 | * |
| 437 | * Returned value will be one of LO_UDP, LO_TCP or LO_UNIX. |
| 438 | */ |
| 439 | int lo_address_get_protocol(lo_address a); |
| 440 | |
| 441 | /** |
| 442 | * \brief Return a URL representing an OSC address |
| 443 | * |
| 444 | * Returned value must be free'd. |
| 445 | */ |
| 446 | char *lo_address_get_url(lo_address a); |
| 447 | |
| 448 | /** |
| 449 | * \brief Set the Time-to-Live value for a given target address. |
| 450 | * |
| 451 | * This is required for sending multicast UDP messages. A value of 1 |
| 452 | * (the usual case) keeps the message within the subnet, while 255 |
| 453 | * means a global, unrestricted scope. |
| 454 | * |
| 455 | * \param t An OSC address. |
| 456 | * \param ttl An integer specifying the scope of a multicast UDP message. |
| 457 | */ |
| 458 | void lo_address_set_ttl(lo_address t, int ttl); |
| 459 | |
| 460 | /** |
| 461 | * \brief Get the Time-to-Live value for a given target address. |
| 462 | * |
| 463 | * \param t An OSC address. |
| 464 | * \return An integer specifying the scope of a multicast UDP message. |
| 465 | */ |
| 466 | int lo_address_get_ttl(lo_address t); |
| 467 | |
| 468 | /** |
| 469 | * \brief Set the network interface to use for a given target address. |
| 470 | * |
| 471 | * The caller should specify either the iface or ip variable. The IP, |
| 472 | * if specified, should match the same network family as the OSC |
| 473 | * address. (That is, should correctly correspond to IPv4 or IPv6.) |
| 474 | * Typically the assigned network interface will only be used in the |
| 475 | * case of sending multicast messages. It is recommended to use the |
| 476 | * if_nameindex POSIX function to get a list of network interface |
| 477 | * names. |
| 478 | * |
| 479 | * \param t An OSC address. |
| 480 | * \param iface The name of a network interface on the local system. |
| 481 | * \param ip The IP address of a network interface on the local system. |
| 482 | * \return 0 if the interface was successfully identified, or non-zero |
| 483 | * otherwise. |
| 484 | */ |
| 485 | int lo_address_set_iface(lo_address t, const char *iface, const char *ip); |
| 486 | |
| 487 | /** |
| 488 | * \brief Get the name of the network interface assigned to an OSC address. |
| 489 | * |
| 490 | * \param t An OSC address. |
| 491 | * \return A string pointer or 0 if no interface has been assigned. |
| 492 | * Caller should not modify the provided string. It is a |
| 493 | * legal pointer until the next call to lo_address_set_iface |
| 494 | * or lo_address_free. |
| 495 | */ |
| 496 | const char* lo_address_get_iface(lo_address t); |
| 497 | |
| 498 | /** |
| 499 | * \brief Set the TCP_NODELAY flag on outgoing TCP connections. |
| 500 | * \param t The address to set this flag for. |
| 501 | * \param enable Non-zero to set the flag, zero to unset it. |
| 502 | * \return the previous value of this flag. |
| 503 | */ |
| 504 | int lo_address_set_tcp_nodelay(lo_address t, int enable); |
| 505 | |
| 506 | /** |
| 507 | * \brief Set outgoing stream connections (e.g., TCP) to be |
| 508 | * transmitted using the SLIP packetizing protocol. |
| 509 | * \param t The address to set this flag for. |
| 510 | * \param encoding Specify single- or double-ENDed SLIP, or disable SLIP. |
| 511 | * \return the previous value of this flag. |
| 512 | */ |
| 513 | int lo_address_set_stream_slip(lo_address t, lo_slip_encoding encoding); |
| 514 | |
| 515 | /** |
| 516 | * \brief Create a new bundle object. |
| 517 | * |
| 518 | * OSC Bundles encapsulate one or more OSC messages and may include a timestamp |
| 519 | * indicating when the bundle should be dispatched. |
| 520 | * |
| 521 | * \param tt The timestamp when the bundle should be handled by the receiver. |
| 522 | * Pass LO_TT_IMMEDIATE if you want the receiving server to dispatch |
| 523 | * the bundle as soon as it receives it. |
| 524 | */ |
| 525 | lo_bundle lo_bundle_new(lo_timetag tt); |
| 526 | |
| 527 | /** |
| 528 | * \brief Add one to a bundle's reference count. |
| 529 | * |
| 530 | * Bundles are reference counted. If a bundle is multiply referenced, |
| 531 | * the bundle's counter should be incremented. It is automatically |
| 532 | * decremented by lo_bundle_free lo_bundle_free_recursive, with |
| 533 | * lo_bundle_free_recursive being the preferable method. |
| 534 | */ |
| 535 | void lo_bundle_incref(lo_bundle b); |
| 536 | |
| 537 | /** |
| 538 | * \brief Adds an OSC message to an existing bundle. |
| 539 | * |
| 540 | * The message passed is appended to the list of messages in the bundle to be |
| 541 | * dispatched to 'path'. |
| 542 | * |
| 543 | * \return 0 if successful, less than 0 otherwise. |
| 544 | */ |
| 545 | int lo_bundle_add_message(lo_bundle b, const char *path, lo_message m); |
| 546 | |
| 547 | /** |
| 548 | * \brief Adds an OSC bundle to an existing bundle. |
| 549 | * |
| 550 | * The child bundle passed is appended to the list of child bundles|messages in the parent bundle to be |
| 551 | * dispatched. |
| 552 | * |
| 553 | * \return 0 if successful, less than 0 otherwise. |
| 554 | */ |
| 555 | int lo_bundle_add_bundle(lo_bundle b, lo_bundle n); |
| 556 | |
| 557 | /** |
| 558 | * \brief Return the length of a bundle in bytes. |
| 559 | * |
| 560 | * Includes the marker and typetag length. |
| 561 | * |
| 562 | * \param b The bundle to be sized |
| 563 | */ |
| 564 | size_t lo_bundle_length(lo_bundle b); |
| 565 | |
| 566 | /** |
| 567 | * \brief Return the number of top-level elements in a bundle. |
| 568 | * |
| 569 | * \param b The bundle to be counted. |
| 570 | */ |
| 571 | unsigned int lo_bundle_count(lo_bundle b); |
| 572 | |
| 573 | /** |
| 574 | * \brief Gets the element type contained within a bundle. |
| 575 | * |
| 576 | * Returns a lo_element_type at a given index within a bundle. |
| 577 | |
| 578 | * \return The requested lo_element_type if successful, otherwise 0. |
| 579 | */ |
| 580 | lo_element_type lo_bundle_get_type(lo_bundle b, int index); |
| 581 | |
| 582 | /** |
| 583 | * \brief Gets a nested bundle contained within a bundle. |
| 584 | * |
| 585 | * Returns a lo_bundle at a given index within a bundle. |
| 586 | * |
| 587 | * \return The requested lo_bundle if successful, otherwise 0. |
| 588 | */ |
| 589 | lo_bundle lo_bundle_get_bundle(lo_bundle b, int index); |
| 590 | |
| 591 | /** |
| 592 | * \brief Gets a message contained within a bundle. |
| 593 | * |
| 594 | * Returns a lo_message at a given index within a bundle, and |
| 595 | * optionally the path associated with that message. |
| 596 | * |
| 597 | * \return The requested lo_message if successful, otherwise 0. |
| 598 | */ |
| 599 | lo_message lo_bundle_get_message(lo_bundle b, int index, |
| 600 | const char **path); |
| 601 | |
| 602 | /** |
| 603 | * \brief Get the timestamp associated with a bundle. |
| 604 | * |
| 605 | * \param b The bundle for which the timestamp should be returned. |
| 606 | * |
| 607 | * \return The timestamp of the bundle as a lo_timetag. |
| 608 | */ |
| 609 | lo_timetag lo_bundle_get_timestamp(lo_bundle b); |
| 610 | |
| 611 | /** |
| 612 | * \brief Serialise the bundle object to an area of memory and return a |
| 613 | * pointer to the serialised form. |
| 614 | * |
| 615 | * \param b The bundle to be serialised |
| 616 | * \param to The address to serialise to, memory will be allocated if to is |
| 617 | * NULL. |
| 618 | * \param size If this pointer is non-NULL the size of the memory area |
| 619 | * will be written here |
| 620 | * |
| 621 | * The returned form is suitable to be sent over a low level OSC transport, |
| 622 | * having the correct endianess and bit-packed structure. |
| 623 | */ |
| 624 | void *lo_bundle_serialise(lo_bundle b, void *to, size_t *size); |
| 625 | |
| 626 | /** |
| 627 | * \brief Frees the memory taken by a bundle object. |
| 628 | * |
| 629 | * \param b The bundle to be freed. |
| 630 | */ |
| 631 | void lo_bundle_free(lo_bundle b); |
| 632 | |
| 633 | /** |
| 634 | * \brief Frees the memory taken by a bundle object and its messages and nested bundles recursively. |
| 635 | * |
| 636 | * \param b The bundle, which may contain messages and nested bundles, to be freed. |
| 637 | */ |
| 638 | void lo_bundle_free_recursive(lo_bundle b); |
| 639 | |
| 640 | /** |
| 641 | * \brief Obsolete, use lo_bundle_free_recursive instead. |
| 642 | * |
| 643 | * \param b The bundle, which may contain messages and nested bundles, to be freed. |
| 644 | */ |
| 645 | void lo_bundle_free_messages(lo_bundle b); |
| 646 | |
| 647 | /** |
| 648 | * \brief Return true if the type specified has a numerical value, such as |
| 649 | * LO_INT32, LO_FLOAT etc. |
| 650 | * |
| 651 | * \param a The type to be tested. |
| 652 | */ |
| 653 | int lo_is_numerical_type(lo_type a); |
| 654 | |
| 655 | /** |
| 656 | * \brief Return true if the type specified has a textual value, such as |
| 657 | * LO_STRING or LO_SYMBOL. |
| 658 | * |
| 659 | * \param a The type to be tested. |
| 660 | */ |
| 661 | int lo_is_string_type(lo_type a); |
| 662 | |
| 663 | /** |
| 664 | * \brief Attempt to convert one OSC type to another. |
| 665 | * |
| 666 | * Numerical types (eg LO_INT32, LO_FLOAT etc.) may be converted to other |
| 667 | * numerical types and string types (LO_STRING and LO_SYMBOL) may be converted |
| 668 | * to the other type. This is done automatically if a received message matches |
| 669 | * the path, but not the exact types, and is coercible (ie. all numerical |
| 670 | * types in numerical positions). |
| 671 | * |
| 672 | * On failure no translation occurs and false is returned. |
| 673 | * |
| 674 | * \param type_to The type of the destination variable. |
| 675 | * \param to A pointer to the destination variable. |
| 676 | * \param type_from The type of the source variable. |
| 677 | * \param from A pointer to the source variable. |
| 678 | */ |
| 679 | int lo_coerce(lo_type type_to, lo_arg *to, lo_type type_from, lo_arg *from); |
| 680 | |
| 681 | /** |
| 682 | * \brief Return the numerical value of the given argument with the |
| 683 | * maximum native system precision. |
| 684 | */ |
| 685 | lo_hires lo_hires_val(lo_type type, lo_arg *p); |
| 686 | |
| 687 | /** |
| 688 | * \brief Create a new server instance. |
| 689 | * |
| 690 | * Using lo_server_recv(), lo_servers block until they receive OSC |
| 691 | * messages. If you want non-blocking behaviour see |
| 692 | * lo_server_recv_noblock() or the \ref lo_server_thread_new |
| 693 | * "lo_server_thread_*" functions. |
| 694 | * |
| 695 | * \param port If NULL is passed then an unused UDP port will be chosen by the |
| 696 | * system, its number may be retrieved with lo_server_thread_get_port() |
| 697 | * so it can be passed to clients. Otherwise a decimal port number, service |
| 698 | * name or UNIX domain socket path may be passed. |
| 699 | * \param err_h An error callback function that will be called if there is an |
| 700 | * error in messge reception or server creation. Pass NULL if you do not want |
| 701 | * error handling. |
| 702 | */ |
| 703 | lo_server lo_server_new(const char *port, lo_err_handler err_h); |
| 704 | |
| 705 | /** |
| 706 | * \brief Create a new server instance, specifying protocol. |
| 707 | * |
| 708 | * Using lo_server_recv(), lo_servers block until they receive OSC |
| 709 | * messages. If you want non-blocking behaviour see |
| 710 | * lo_server_recv_noblock() or the \ref lo_server_thread_new |
| 711 | * "lo_server_thread_*" functions. |
| 712 | * |
| 713 | * \param port If using UDP then NULL may be passed to find an unused port. |
| 714 | * Otherwise a decimal port number orservice name or may be passed. |
| 715 | * If using UNIX domain sockets then a socket path should be passed here. |
| 716 | * \param proto The protocol to use, should be one of LO_UDP, LO_TCP or LO_UNIX. |
| 717 | * \param err_h An error callback function that will be called if there is an |
| 718 | * error in messge reception or server creation. Pass NULL if you do not want |
| 719 | * error handling. |
| 720 | */ |
| 721 | lo_server lo_server_new_with_proto(const char *port, int proto, |
| 722 | lo_err_handler err_h); |
| 723 | |
| 724 | /** |
| 725 | * \brief Create a new server instance, and join a UDP multicast group. |
| 726 | * |
| 727 | * \param group The multicast group to join. See documentation on IP |
| 728 | * multicast for the acceptable address range; e.g., http://tldp.org/HOWTO/Multicast-HOWTO-2.html |
| 729 | * \param port If using UDP then NULL may be passed to find an unused port. |
| 730 | * Otherwise a decimal port number or service name or may be passed. |
| 731 | * If using UNIX domain sockets then a socket path should be passed here. |
| 732 | * \param err_h An error callback function that will be called if there is an |
| 733 | * error in messge reception or server creation. Pass NULL if you do not want |
| 734 | * error handling. |
| 735 | */ |
| 736 | lo_server lo_server_new_multicast(const char *group, const char *port, |
| 737 | lo_err_handler err_h); |
| 738 | |
| 739 | /** |
| 740 | * \brief Create a new server instance, and join a UDP multicast |
| 741 | * group, optionally specifying which network interface to use. |
| 742 | * Note that usually only one of iface or ip are specified. |
| 743 | * |
| 744 | * \param group The multicast group to join. See documentation on IP |
| 745 | * multicast for the acceptable address range; e.g., http://tldp.org/HOWTO/Multicast-HOWTO-2.html |
| 746 | * \param port If using UDP then NULL may be passed to find an unused port. |
| 747 | * Otherwise a decimal port number or service name or may be passed. |
| 748 | * If using UNIX domain sockets then a socket path should be passed here. |
| 749 | * \param iface A string specifying the name of a network interface to |
| 750 | * use, or zero if not specified. |
| 751 | * \param ip A string specifying the IP address of a network interface |
| 752 | * to use, or zero if not specified. |
| 753 | * \param err_h An error callback function that will be called if there is an |
| 754 | * error in messge reception or server creation. Pass NULL if you do not want |
| 755 | * error handling. |
| 756 | */ |
| 757 | lo_server lo_server_new_multicast_iface(const char *group, const char *port, |
| 758 | const char *iface, const char *ip, |
| 759 | lo_err_handler err_h); |
| 760 | |
| 761 | /** |
| 762 | * \brief Create a new server instance, taking port and the optional |
| 763 | * multicast group IP from an URL string. |
| 764 | * |
| 765 | * \param url The URL to specify the server parameters. |
| 766 | * \param err_h An error callback function that will be called if there is an |
| 767 | * error in messge reception or server creation. Pass NULL if you do not want |
| 768 | * error handling. |
| 769 | * \return A new lo_server instance. |
| 770 | */ |
| 771 | lo_server lo_server_new_from_url(const char *url, |
| 772 | lo_err_handler err_h); |
| 773 | |
| 774 | /** |
| 775 | * \brief Create a new server instance, using a configuration struct. |
| 776 | * |
| 777 | * \param config A pre-initialized config struct. A pointer to it will not be kept. |
| 778 | * \return A new lo_server instance. |
| 779 | */ |
| 780 | lo_server lo_server_new_from_config(lo_server_config *config); |
| 781 | |
| 782 | /** |
| 783 | * \brief Enables or disables type coercion during message dispatch. |
| 784 | * \param server The server to toggle this option for. |
| 785 | * \param enable Non-zero to enable, or zero to disable type coercion. |
| 786 | * \return The previous value of this option. |
| 787 | */ |
| 788 | int lo_server_enable_coercion(lo_server server, int enable); |
| 789 | |
| 790 | /** |
| 791 | * \brief Free up memory used by the lo_server object |
| 792 | */ |
| 793 | void lo_server_free(lo_server s); |
| 794 | |
| 795 | /** |
| 796 | * \brief Wait for an OSC message to be received |
| 797 | * |
| 798 | * \param s The server to wait for connections on. |
| 799 | * \param timeout A timeout in milliseconds to wait for the incoming packet. |
| 800 | * a value of 0 will return immediately. |
| 801 | * |
| 802 | * The return value is 1 if there is a message waiting or 0 if |
| 803 | * there is no message. If there is a message waiting you can now |
| 804 | * call lo_server_recv() to receive that message. |
| 805 | */ |
| 806 | int lo_server_wait(lo_server s, int timeout); |
| 807 | |
| 808 | /** |
| 809 | * \brief Wait on multiple servers for an OSC message to be received |
| 810 | * |
| 811 | * \param s An array of servers to wait for connections on. |
| 812 | * \param status An array to receive the status of each server. |
| 813 | * \param num_servers The number of servers in the array s. |
| 814 | * \param timeout A timeout in milliseconds to wait for the incoming packet. |
| 815 | * a value of 0 will return immediately. |
| 816 | * |
| 817 | * The return value is the number of servers with a message waiting or |
| 818 | * 0 if there is no message. If there is a message waiting you can now |
| 819 | * call lo_server_recv() to receive that message. |
| 820 | */ |
| 821 | int lo_servers_wait(lo_server *s, int *status, int num_servers, int timeout); |
| 822 | |
| 823 | /** |
| 824 | * \brief Look for an OSC message waiting to be received |
| 825 | * |
| 826 | * \param s The server to wait for connections on. |
| 827 | * \param timeout A timeout in milliseconds to wait for the incoming packet. |
| 828 | * a value of 0 will return immediately. |
| 829 | * |
| 830 | * The return value is the number of bytes in the received message or 0 if |
| 831 | * there is no message. The message will be dispatched to a matching method |
| 832 | * if one is found. |
| 833 | */ |
| 834 | int lo_server_recv_noblock(lo_server s, int timeout); |
| 835 | |
| 836 | /** |
| 837 | * \brief Look for an OSC message waiting to be received on multiple servers |
| 838 | * |
| 839 | * \param s As array of servers to wait for connections on. |
| 840 | * \param recvd An array to store the number of bytes received by each server |
| 841 | * in array s. |
| 842 | * \param num_servers The number of servers in the array s. |
| 843 | * \param timeout A timeout in milliseconds to wait for the incoming packet. |
| 844 | * a value of 0 will return immediately. |
| 845 | * |
| 846 | * The return value is the total number of bytes received by all servers. |
| 847 | * The messages will be dispatched to a matching method if one is found. |
| 848 | */ |
| 849 | int lo_servers_recv_noblock(lo_server *s, int *recvd, int num_servers, |
| 850 | int timeout); |
| 851 | |
| 852 | /** |
| 853 | * \brief Block, waiting for an OSC message to be received |
| 854 | * |
| 855 | * The return value is the number of bytes in the received message. The message |
| 856 | * will be dispatched to a matching method if one is found. |
| 857 | */ |
| 858 | int lo_server_recv(lo_server s); |
| 859 | |
| 860 | /** |
| 861 | * \brief Add an OSC method to the specifed server. |
| 862 | * |
| 863 | * \param s The server the method is to be added to. |
| 864 | * \param path The OSC path to register the method to. If NULL is passed the |
| 865 | * method will match all paths. |
| 866 | * \param typespec The typespec the method accepts. Incoming messages with |
| 867 | * similar typespecs (e.g. ones with numerical types in the same position) will |
| 868 | * be coerced to the typespec given here. |
| 869 | * \param h The method handler callback function that will be called if a |
| 870 | * matching message is received |
| 871 | * \param user_data A value that will be passed to the callback function, h, |
| 872 | * when its invoked matching from this method. |
| 873 | * \return A unique pointer identifying the method. It should not be freed. |
| 874 | */ |
| 875 | lo_method lo_server_add_method(lo_server s, const char *path, |
| 876 | const char *typespec, lo_method_handler h, |
| 877 | const void *user_data); |
| 878 | |
| 879 | /** |
| 880 | * \brief Delete an OSC method from the specified server. |
| 881 | * |
| 882 | * \param s The server the method is to be removed from. |
| 883 | * \param path The OSC path of the method to delete. If NULL is passed the |
| 884 | * method will match the generic handler. |
| 885 | * \param typespec The typespec the method accepts. |
| 886 | */ |
| 887 | void lo_server_del_method(lo_server s, const char *path, |
| 888 | const char *typespec); |
| 889 | |
| 890 | /** |
| 891 | * \brief Delete a specific OSC method from the specified server. |
| 892 | * |
| 893 | * \param s The server the method is to be removed from. |
| 894 | * \param m The lo_method identifier returned from lo_server_add_method for |
| 895 | * the method to delete from the server. |
| 896 | * \return Non-zero if it was not found in the list of methods for the server. |
| 897 | */ |
| 898 | int lo_server_del_lo_method(lo_server s, lo_method m); |
| 899 | |
| 900 | /** |
| 901 | * \brief Add bundle notification handlers to the specified server. |
| 902 | * |
| 903 | * \param s The server the method is to be added to. |
| 904 | * \param sh The callback function that will be called before the messages |
| 905 | * of a bundle are dispatched |
| 906 | * \param eh The callback function that will be called after the messages |
| 907 | * of a bundle are dispatched |
| 908 | * \param user_data A value that will be passed to the user_data parameter |
| 909 | * of both callback functions. |
| 910 | */ |
| 911 | int lo_server_add_bundle_handlers(lo_server s, |
| 912 | lo_bundle_start_handler sh, |
| 913 | lo_bundle_end_handler eh, |
| 914 | void *user_data); |
| 915 | |
| 916 | /** |
| 917 | * \brief Return the file descriptor of the server socket. |
| 918 | * |
| 919 | * If the server protocol supports exposing the server's underlying |
| 920 | * receive mechanism for monitoring with select() or poll(), this function |
| 921 | * returns the file descriptor needed, otherwise, it returns -1. |
| 922 | * |
| 923 | * WARNING: when using this function beware that not all OSC packets that are |
| 924 | * received are dispatched immediately. lo_server_events_pending() and |
| 925 | * lo_server_next_event_delay() can be used to tell if there are pending |
| 926 | * events and how long before you should attempt to receive them. |
| 927 | */ |
| 928 | int lo_server_get_socket_fd(lo_server s); |
| 929 | |
| 930 | /** |
| 931 | * \brief Return the port number that the server has bound to. |
| 932 | * |
| 933 | * Useful when NULL is passed for the port number and you wish to know how to |
| 934 | * address the server. |
| 935 | */ |
| 936 | int lo_server_get_port(lo_server s); |
| 937 | |
| 938 | /** |
| 939 | * \brief Return the protocol that the server is using. |
| 940 | * |
| 941 | * Returned value will be one of LO_UDP, LO_TCP or LO_UNIX. |
| 942 | */ |
| 943 | int lo_server_get_protocol(lo_server s); |
| 944 | |
| 945 | /** |
| 946 | * \brief Return an OSC URL that can be used to contact the server. |
| 947 | * |
| 948 | * The return value should be free()'d when it is no longer needed. |
| 949 | */ |
| 950 | char *lo_server_get_url(lo_server s); |
| 951 | |
| 952 | /** |
| 953 | * \brief Toggle event queue. |
| 954 | * If queueing is enabled, timetagged messages that are sent in |
| 955 | * advance of the current time will be put on an internal queue, and |
| 956 | * they will be dispatched at the indicated time. By default, |
| 957 | * queueing is enabled. Use this function to disable it, if it is |
| 958 | * desired to have a server process messages immediately. In that |
| 959 | * case, use lo_message_get_timestamp() to get the message timestamp |
| 960 | * from within a method handler. |
| 961 | * \param s A liblo server |
| 962 | * \param queue_enabled Zero to disable queue, non-zero to enable. |
| 963 | * \param dispatch_remaining If non-zero, previously queued messages |
| 964 | * will be immediately dispatched when queue |
| 965 | * is disabled. |
| 966 | * \return The previous state of queue behaviour. Zero if queueing |
| 967 | * was previously disabled, non-zero otherwise. |
| 968 | */ |
| 969 | int lo_server_enable_queue(lo_server s, int queue_enabled, |
| 970 | int dispatch_remaining); |
| 971 | |
| 972 | /** |
| 973 | * \brief Return true if there are scheduled events (eg. from bundles) |
| 974 | * waiting to be dispatched by the server |
| 975 | */ |
| 976 | int lo_server_events_pending(lo_server s); |
| 977 | |
| 978 | /** |
| 979 | * \brief Return the time in seconds until the next scheduled event. |
| 980 | * |
| 981 | * If the delay is greater than 100 seconds then it will return 100.0. |
| 982 | */ |
| 983 | double lo_server_next_event_delay(lo_server s); |
| 984 | |
| 985 | /** |
| 986 | * \brief Set the maximum message size accepted by a server. |
| 987 | * |
| 988 | * For UDP servers, the maximum message size cannot exceed 64k, due to |
| 989 | * the UDP transport specifications. For TCP servers, this number may |
| 990 | * be larger, but be aware that one or more contiguous blocks of |
| 991 | * memory of this size may be allocated by liblo. (At least one per |
| 992 | * connection.) |
| 993 | * |
| 994 | * \param s The server on which to operate. |
| 995 | * \param req_size The new maximum message size to request, 0 if it |
| 996 | * should not be modified, or -1 if it should be set to unlimited. |
| 997 | * Note that an unlimited message buffer may make your application |
| 998 | * open to a denial of service attack. |
| 999 | * \return The new maximum message size is returned, which may or may |
| 1000 | * not be equal to req_size. If -1 is returned, maximum size is |
| 1001 | * unlimited. |
| 1002 | */ |
| 1003 | int lo_server_max_msg_size(lo_server s, int req_size); |
| 1004 | |
| 1005 | /** |
| 1006 | * \brief Return the protocol portion of an OSC URL, eg. udp, tcp. |
| 1007 | * |
| 1008 | * This library uses OSC URLs of the form: osc.prot://hostname:port/path if the |
| 1009 | * prot part is missing, UDP is assumed. |
| 1010 | * |
| 1011 | * The return value should be free()'d when it is no longer needed. |
| 1012 | */ |
| 1013 | char *lo_url_get_protocol(const char *url); |
| 1014 | |
| 1015 | /** |
| 1016 | * \brief Return the protocol ID of an OSC URL. |
| 1017 | * |
| 1018 | * This library uses OSC URLs of the form: osc.prot://hostname:port/path if the |
| 1019 | * prot part is missing, UDP is assumed. |
| 1020 | * Returned value will be one of LO_UDP, LO_TCP, LO_UNIX or -1. |
| 1021 | * |
| 1022 | * \return An integer specifying the protocol. Return -1 when the protocol is |
| 1023 | * not supported by liblo. |
| 1024 | * |
| 1025 | */ |
| 1026 | int lo_url_get_protocol_id(const char *url); |
| 1027 | |
| 1028 | /** |
| 1029 | * \brief Return the hostname portion of an OSC URL. |
| 1030 | * |
| 1031 | * The return value should be free()'d when it is no longer needed. |
| 1032 | */ |
| 1033 | char *lo_url_get_hostname(const char *url); |
| 1034 | |
| 1035 | /** |
| 1036 | * \brief Return the port portion of an OSC URL. |
| 1037 | * |
| 1038 | * The return value should be free()'d when it is no longer needed. |
| 1039 | */ |
| 1040 | char *lo_url_get_port(const char *url); |
| 1041 | |
| 1042 | /** |
| 1043 | * \brief Return the path portion of an OSC URL. |
| 1044 | * |
| 1045 | * The return value should be free()'d when it is no longer needed. |
| 1046 | */ |
| 1047 | char *lo_url_get_path(const char *url); |
| 1048 | |
| 1049 | /* utility functions */ |
| 1050 | |
| 1051 | /** |
| 1052 | * \brief A function to calculate the amount of OSC message space required by a |
| 1053 | * C char *. |
| 1054 | * |
| 1055 | * Returns the storage size in bytes, which will always be a multiple of four. |
| 1056 | */ |
| 1057 | int lo_strsize(const char *s); |
| 1058 | |
| 1059 | /** |
| 1060 | * \brief A function to calculate the amount of OSC message space required by a |
| 1061 | * lo_blob object. |
| 1062 | * |
| 1063 | * Returns the storage size in bytes, which will always be a multiple of four. |
| 1064 | */ |
| 1065 | uint32_t lo_blobsize(lo_blob b); |
| 1066 | |
| 1067 | /** |
| 1068 | * \brief Test a string against an OSC pattern glob |
| 1069 | * |
| 1070 | * \param str The string to test |
| 1071 | * \param p The pattern to test against |
| 1072 | * \return 1 if true, 0 otherwise. |
| 1073 | */ |
| 1074 | int lo_pattern_match(const char *str, const char *p); |
| 1075 | |
| 1076 | /** |
| 1077 | * \brief Test if a string contains any OSC pattern characters |
| 1078 | * |
| 1079 | * \param str The string to test |
| 1080 | * \return 1 if true, 0 otherwise. |
| 1081 | */ |
| 1082 | int lo_string_contains_pattern(const char *str); |
| 1083 | |
| 1084 | /** \internal \brief the real send function (don't call directly) */ |
| 1085 | int lo_send_internal(lo_address t, const char *file, const int line, |
| 1086 | const char *path, const char *types, ...); |
| 1087 | /** \internal \brief the real send_timestamped function (don't call directly) */ |
| 1088 | int lo_send_timestamped_internal(lo_address t, const char *file, const int line, |
| 1089 | lo_timetag ts, const char *path, const char *types, ...); |
| 1090 | /** \internal \brief the real lo_send_from() function (don't call directly) */ |
| 1091 | int lo_send_from_internal(lo_address targ, lo_server from, const char *file, |
| 1092 | const int line, const lo_timetag ts, |
| 1093 | const char *path, const char *types, ...); |
| 1094 | |
| 1095 | |
| 1096 | /** \brief Find the time difference between two timetags |
| 1097 | * |
| 1098 | * Returns a - b in seconds. |
| 1099 | */ |
| 1100 | double lo_timetag_diff(lo_timetag a, lo_timetag b); |
| 1101 | |
| 1102 | /** \brief Return a timetag for the current time |
| 1103 | * |
| 1104 | * On exit the timetag pointed to by t is filled with the OSC |
| 1105 | * representation of this instant in time. |
| 1106 | */ |
| 1107 | void lo_timetag_now(lo_timetag *t); |
| 1108 | |
| 1109 | /** |
| 1110 | * \brief Return the storage size, in bytes, of the given argument. |
| 1111 | */ |
| 1112 | size_t lo_arg_size(lo_type type, void *data); |
| 1113 | |
| 1114 | /** |
| 1115 | * \brief Given a raw OSC message, return the message path. |
| 1116 | * |
| 1117 | * \param data A pointer to the raw OSC message data. |
| 1118 | * \param size The size of data in bytes (total buffer bytes). |
| 1119 | * |
| 1120 | * Returns the message path or NULL if an error occurs. |
| 1121 | * Do not free() the returned pointer. |
| 1122 | */ |
| 1123 | char *lo_get_path(void *data, ssize_t size); |
| 1124 | |
| 1125 | /** |
| 1126 | * \brief Convert the specified argument to host byte order where necessary. |
| 1127 | * |
| 1128 | * \param type The OSC type of the data item (eg. LO_FLOAT). |
| 1129 | * \param data A pointer to the data item to be converted. It is changed |
| 1130 | * in-place. |
| 1131 | */ |
| 1132 | void lo_arg_host_endian(lo_type type, void *data); |
| 1133 | |
| 1134 | /** |
| 1135 | * \brief Convert the specified argument to network byte order where necessary. |
| 1136 | * |
| 1137 | * \param type The OSC type of the data item (eg. LO_FLOAT). |
| 1138 | * \param data A pointer to the data item to be converted. It is changed |
| 1139 | * in-place. |
| 1140 | */ |
| 1141 | void lo_arg_network_endian(lo_type type, void *data); |
| 1142 | |
| 1143 | /** @} */ |
| 1144 | |
| 1145 | /* prettyprinters */ |
| 1146 | |
| 1147 | /** |
| 1148 | * \defgroup pp Prettyprinting functions |
| 1149 | * |
| 1150 | * These functions all print an ASCII representation of their argument to |
| 1151 | * stdout. Useful for debugging. |
| 1152 | * @{ |
| 1153 | */ |
| 1154 | |
| 1155 | /** \brief Pretty-print a lo_bundle object. */ |
| 1156 | void lo_bundle_pp(lo_bundle b); |
| 1157 | |
| 1158 | /** \brief Pretty-print a lo_message object. */ |
| 1159 | void lo_message_pp(lo_message m); |
| 1160 | |
| 1161 | /** \brief Pretty-print a set of typed arguments. |
| 1162 | * \param type A type string in the form provided to lo_send(). |
| 1163 | * \param data An OSC data pointer, like that provided in the |
| 1164 | * lo_method_handler. |
| 1165 | */ |
| 1166 | void lo_arg_pp(lo_type type, void *data); |
| 1167 | |
| 1168 | /** \brief Pretty-print a lo_server object. */ |
| 1169 | void lo_server_pp(lo_server s); |
| 1170 | |
| 1171 | /** \brief Pretty-print a lo_method object. */ |
| 1172 | void lo_method_pp(lo_method m); |
| 1173 | |
| 1174 | /** \brief Pretty-print a lo_method object, but prepend a given prefix |
| 1175 | * to all field names. */ |
| 1176 | void lo_method_pp_prefix(lo_method m, const char *p); |
| 1177 | |
| 1178 | /** @} */ |
| 1179 | |
| 1180 | #ifdef __cplusplus |
| 1181 | } |
| 1182 | #endif |
| 1183 | |
| 1184 | #endif |