PipeWire  0.2.0
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  return pod ?
55  (struct spa_pod *) memcpy(malloc(SPA_POD_SIZE(pod)), pod, SPA_POD_SIZE(pod))
56  : NULL;
57 }
58 
59 #ifdef __cplusplus
60 } /* extern "C" */
61 #endif
62 
63 #endif /* __PIPEWIRE_UTILS_H__ */
void(* pw_destroy_t)(void *object)
a function to destroy an item
Definition: utils.h:36
const 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:39
static struct spa_pod * pw_spa_pod_copy(const struct spa_pod *pod)
Copy a pod structure.
Definition: utils.h:52
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:64
char * pw_strip(char *str, const char *whitespace)
Strip all whitespace before and after a string.
Definition: utils.c:115
void pw_free_strv(char **str)
Free a NULL terminated array of strings.
Definition: utils.c:97