PipeWire: utils.h Source File

PipeWire 0.2.7

utils.h
Go to the documentation of this file.
1 /* PipeWire
2 * Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library 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 GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #ifndef __PIPEWIRE_UTILS_H__
21 #define __PIPEWIRE_UTILS_H__
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 #include <spa/utils/defs.h>
28 #include <spa/pod/pod.h>
29
36 typedef void (*pw_destroy_t) (void *object);
37
38 const char *
39 pw_split_walk(const char *str, const char *delimiter, size_t *len, const char **state);
40
41 char **
42 pw_split_strv(const char *str, const char *delimiter, int max_tokens, int *n_tokens);
43
44 void
45 pw_free_strv(char **str);
46
47 char *
48 pw_strip(char *str, const char *whitespace);
49
51 static inline struct spa_pod *
52 pw_spa_pod_copy(const struct spa_pod *pod)
53 {
54 size_t size;
55 struct spa_pod *c;
56
57 if (pod == NULL)
58 return NULL;
59
60 size = SPA_POD_SIZE(pod);
61 if ((c = (struct spa_pod *) malloc(size)) == NULL)
62 return NULL;
63
64 return (struct spa_pod *) memcpy(c, pod, size);
65 }
66
67 #ifdef __cplusplus
68 } /* extern "C" */
69 #endif
70
71 #endif /* __PIPEWIRE_UTILS_H__ */
pw_utils::pw_split_walk
const SPA_EXPORT char * pw_split_walk(const char *str, const char *delimiter, size_t *len, const char **state)
Split a string based on delimiters.
Definition: utils.c:40
pw_utils::pw_split_strv
SPA_EXPORT char ** pw_split_strv(const char *str, const char *delimiter, int max_tokens, int *n_tokens)
Split a string based on delimiters.
Definition: utils.c:66
array.h
pw_utils::pw_spa_pod_copy
static struct spa_pod * pw_spa_pod_copy(const struct spa_pod *pod)
Copy a pod structure.
Definition: utils.h:52
pw_array
An array object.
Definition: array.h:36
utils.h
pw_array::pw_array_add_ptr
#define pw_array_add_ptr(a, p)
Add a pointer to array.
Definition: array.h:127
log.h
pw_utils::pw_strip
SPA_EXPORT char * pw_strip(char *str, const char *whitespace)
Strip all whitespace before and after a string.
Definition: utils.c:119
pw_array::data
void * data
pointer to array data
Definition: array.h:37
pw_utils::pw_free_strv
SPA_EXPORT void pw_free_strv(char **str)
Free a NULL terminated array of strings.
Definition: utils.c:100
pw_array::pw_array_init
static void pw_array_init(struct pw_array *arr, size_t extend)
Initialize the array with given extend.
Definition: array.h:62
pw_utils::pw_destroy_t
void(* pw_destroy_t)(void *object)
a function to destroy an item
Definition: utils.h:36