mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
message-params: Allow parameter strings to contain escaped curly braces
The patch adds the possibility to escape curly braces within parameter strings and introduces several new functions that can be used for writing parameters. For writing, the structure pa_message_params, which is a wrapper for pa_strbuf has been created. Following new write functions are available: pa_message_params_new() - creates a new pa_message_params structure pa_message_params_free() - frees a pa_message_params structure pa_message_param_to_string_free() - converts a pa_message_param to string and frees the structure pa_message_params_begin_list() - starts a list pa_message_params_end_list() - ends a list pa_message_params_write_string() - writes a string to a pa_message_params structure pa_message_params_write_raw() - writes a raw string to a pa_message_params structure For string parameters that contain curly braces or backslashes, those characters will be escaped when using pa_message_params_write_string(), while write_raw() will put the string into the buffer without any changes. For reading, pa_message_params_read_string() reverts the changes that pa_message_params_write_string() might have introduced. The patch also adds more restrictions on the object path name. Now only alphanumeric characters and one of "_", ".", "-" and "/" are allowed. The path name may not end with a / or contain a double slash. If the user specifies a trailing / when sending a message, it will be silently removed. Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/51>
This commit is contained in:
parent
4a28b164d1
commit
590fd1ca69
8 changed files with 249 additions and 47 deletions
|
|
@ -30,13 +30,48 @@
|
|||
|
||||
PA_C_DECL_BEGIN
|
||||
|
||||
/** Structure which holds a parameter list. Wrapper for pa_strbuf \since 15.0 */
|
||||
typedef struct pa_message_params pa_message_params;
|
||||
|
||||
/** @{ \name Read functions */
|
||||
|
||||
/** Read raw data from a parameter list. Used to split a message parameter
|
||||
* string into list elements \since 15.0 */
|
||||
* string into list elements. The string returned in *result must not be freed. \since 15.0 */
|
||||
int pa_message_params_read_raw(char *c, char **result, void **state);
|
||||
|
||||
/** Read a string from a parameter list. \since 15.0 */
|
||||
/** Read a string from a parameter list. Escaped curly braces and backslashes
|
||||
* will be unescaped. \since 15.0 */
|
||||
int pa_message_params_read_string(char *c, const char **result, void **state);
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @{ \name Write functions */
|
||||
|
||||
/** Create a new pa_message_params structure \since 15.0 */
|
||||
pa_message_params *pa_message_params_new(void);
|
||||
|
||||
/** Free a pa_message_params structure. \since 15.0 */
|
||||
void pa_message_params_free(pa_message_params *params);
|
||||
|
||||
/** Convert pa_message_params to string, free pa_message_params structure. \since 15.0 */
|
||||
char *pa_message_params_to_string_free(pa_message_params *params);
|
||||
|
||||
/** Start a list by writing an opening brace. \since 15.0 */
|
||||
void pa_message_params_begin_list(pa_message_params *params);
|
||||
|
||||
/** End a list by writing a closing brace. \since 15.0 */
|
||||
void pa_message_params_end_list(pa_message_params *params);
|
||||
|
||||
/** Append string to parameter list. Curly braces and backslashes will be escaped. \since 15.0 */
|
||||
void pa_message_params_write_string(pa_message_params *params, const char *value);
|
||||
|
||||
/** Append raw string to parameter list. Used to write incomplete strings
|
||||
* or complete parameter lists (for example arrays). Adds curly braces around
|
||||
* the string if add_braces is true. \since 15.0 */
|
||||
void pa_message_params_write_raw(pa_message_params *params, const char *value, bool add_braces);
|
||||
|
||||
/** @} */
|
||||
|
||||
PA_C_DECL_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue