|
LMMS
|
#include <assert.h>#include <inttypes.h>#include <limits.h>#include <ctype.h>#include <string.h>#include <time.h>#include <stdio.h>#include <rtosc/rtosc.h>#include <rtosc/pretty-format.h>Functions | |
| static int | asnprintf (char *str, size_t size, const char *format,...) |
| static int | as_escaped_char (int c, int chr) |
| static void | break_string (char **buffer, size_t bs, int wrt, int *cols_used) |
| size_t | rtosc_print_arg_val (const rtosc_arg_val_t *arg, char *buffer, size_t bs, const rtosc_print_options *opt, int *cols_used) |
| size_t | rtosc_print_arg_vals (const rtosc_arg_val_t *args, size_t n, char *buffer, size_t bs, const rtosc_print_options *opt, int cols_used) |
| size_t | rtosc_print_message (const char *address, const rtosc_arg_val_t *args, size_t n, char *buffer, size_t bs, const rtosc_print_options *opt, int cols_used) |
| static void | skip_while (const char **s, int(*property)(int)) |
| static int | skip_fmt (const char **src, const char *fmt) |
| static int | skip_fmt_null (const char **src, const char *fmt) |
| static const char * | try_fmt (const char *src, int exp, const char *fmt, char *typesrc, char type) |
| static const char * | scanf_fmtstr (const char *src, char *type) |
| static const char * | scanf_fmtstr_scan (const char *src, char *bytes8, char *type) |
| static size_t | skip_numeric (const char **src, char *type) |
| static char | get_escaped_char (char c, int chr) |
| static const char * | end_of_printed_string (const char *src) |
| static const char * | skip_word (const char *exp, const char **str) |
| static const char * | skip_identifier (const char *str) |
| const char * | rtosc_skip_next_printed_arg (const char *src) |
| int | rtosc_count_printed_arg_vals (const char *src) |
| int | rtosc_count_printed_arg_vals_of_msg (const char *msg) |
| const char * | parse_identifier (const char *src, rtosc_arg_val_t *arg, char *buffer_for_strings, size_t *bufsize) |
Tries to parse an identifier at src and stores it in arg. | |
| size_t | rtosc_scan_arg_val (const char *src, rtosc_arg_val_t *arg, char *buffer_for_strings, size_t *bufsize) |
| size_t | rtosc_scan_arg_vals (const char *src, rtosc_arg_val_t *args, size_t n, char *buffer_for_strings, size_t bufsize) |
| size_t | rtosc_scan_message (const char *src, char *address, size_t adrsize, rtosc_arg_val_t *args, size_t n, char *buffer_for_strings, size_t bufsize) |
Variables | |
| static const rtosc_print_options | default_print_options = ((rtosc_print_options) { true, 2, " ", 80}) |
Return the char that represents the escape sequence
| c | The escape sequence, e.g. ' ' |
| chr | True if the character appears in a single character (vs in a string) |
Call snprintf and assert() that it did fit into the buffer
Called inside a string at src, skips until after the closing quote
|
static |
Return the escape sequence that's generated with the given character
| c | The character, e.g. 'n' |
| chr | True if the character appears in a single character (vs in a string) |
| const char * parse_identifier | ( | const char * | src, |
| rtosc_arg_val_t * | arg, | ||
| char * | buffer_for_strings, | ||
| size_t * | bufsize ) |
Tries to parse an identifier at src and stores it in arg.
Count arguments that would be scanned and do a complete syntax check
This function should be run before rtosc_scan_arg_vals() in order to know the number of argument values. Also, rtosc_scan_arg_vals() does no complete syntax check.
| src | The string to scan from |
Count arguments of a message that would be scanned and do a complete syntax check
| msg | The message to scan from |
| size_t rtosc_print_arg_val | ( | const rtosc_arg_val_t * | arg, |
| char * | buffer, | ||
| size_t | buffersize, | ||
| const rtosc_print_options * | opt, | ||
| int * | cols_used ) |
Pretty-print rtosct_arg_val_t structure into buffer
| arg | Pointer to the structure that shall be printed |
| buffer | The buffer to write to |
| buffersize | The maximum size to write to, includin a trailing 0 byte |
| opt | Printer options, NULL for default options |
| cols_used | How many columns have been used for writing in this line (will be updated by this function) |
| size_t rtosc_print_arg_vals | ( | const rtosc_arg_val_t * | args, |
| size_t | n, | ||
| char * | buffer, | ||
| size_t | bs, | ||
| const rtosc_print_options * | opt, | ||
| int | cols_used ) |
Pretty-print rtosct_arg_val_t array into buffer
| size_t rtosc_print_message | ( | const char * | address, |
| const rtosc_arg_val_t * | args, | ||
| size_t | n, | ||
| char * | buffer, | ||
| size_t | bs, | ||
| const rtosc_print_options * | opt, | ||
| int | cols_used ) |
Pretty-print OSC message into string buffer
A newline will be appended.
| address | OSC pattern to send message to |
| args | The array to print |
| n | Number of args from the array that should be printed |
| buffer | The buffer to write to |
| bs | The maximum size to write to, includin a trailing 0 byte |
| opt | Printer options, NULL for default options |
| cols_used | How many columns have been used for writing in this line |
| size_t rtosc_scan_arg_val | ( | const char * | src, |
| rtosc_arg_val_t * | arg, | ||
| char * | buffer_for_strings, | ||
| size_t * | bufsize ) |
Scan one argument value from a string
This function does no complete syntaxcheck. Call rtosc_count_printed_arg_vals() before.
| src | The string |
| arg | Pointer to where to store the argument value; must be allocated |
| buffer_for_strings | A buffer with enough space for scanned strings and blobs |
| bufsize | Size of buffer_for_strings , will be shrinked to the bufferbytes left after the scan |
| size_t rtosc_scan_arg_vals | ( | const char * | src, |
| rtosc_arg_val_t * | args, | ||
| size_t | n, | ||
| char * | buffer_for_strings, | ||
| size_t | bufsize ) |
Scan a fixed number of argument values from a string
This function does no complete syntaxcheck. Call rtosc_count_printed_arg_vals() before. This will also give you the n parameter.
| size_t rtosc_scan_message | ( | const char * | src, |
| char * | address, | ||
| size_t | adrsize, | ||
| rtosc_arg_val_t * | args, | ||
| size_t | n, | ||
| char * | buffer_for_strings, | ||
| size_t | bufsize ) |
Scan an OSC message from a string
This function does no complete syntaxcheck. Call rtosc_count_printed_arg_vals() before. This will also give you the n parameter. Preceding and trailing whitespace will be consumed.
| src | The string |
| address | A buffer where the port address will be written |
| adrsize | Size of buffer address |
| args | Pointer to an array of argument values; the output will be written here |
| n | The amount of argument values to scan |
| buffer_for_strings | A buffer with enough space for scanned strings and blobs |
| bufsize | Size of buffer_for_strings |
Skip characters from a string until one argument value would have been scanned
| src | The string |
Return the right format string for skipping the next numeric value
This can be used to find out how to sscanf() ints, floats and doubles. If the string needs to be read, too, see scanf_fmtstr_scan() below.
| src | The beginning of the numeric value to scan |
| type | If non-NULL, the corresponding rtosc argument character (h,i,f,d) will be written here |
Return the right format string for reading the next numeric value
Parse the string pointed to by src conforming to the format string @param src Pointer to the input string
| fmt | Format string for sscanf(). Must suppress all assignments, except the last one, which must be "%n" and be at the string's end. |
src Behave like skip_fmt() , but set *src to NULL if the string didn't match
Tries to skip the next identifier beginning at str
str .
|
static |
Skip the next numeric at src
Skips string exp at the current string pointed to by str, but only if it's a separated word, i.e. if there's a char after the string, it mus be a slash or whitespace.
str .
|
static |
Helper function for scanf_fmtstr()
|
static |