Line |
Branch |
Exec |
Source |
1 |
|
|
/* |
2 |
|
|
* Copyright © 2019 Red Hat, Inc |
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 |
6 |
|
|
* License as published by the Free Software Foundation; either |
7 |
|
|
* version 2.1 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 |
|
|
* Lesser General Public License for more details. |
13 |
|
|
* |
14 |
|
|
* You should have received a copy of the GNU Lesser General Public |
15 |
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
16 |
|
|
* |
17 |
|
|
* Authors: |
18 |
|
|
* Christian J. Kellner <christian@kellner.me> |
19 |
|
|
*/ |
20 |
|
|
|
21 |
|
|
#include "config.h" |
22 |
|
|
|
23 |
|
|
#include "bolt-names.h" |
24 |
|
|
|
25 |
|
|
/* Each element must only contain the ASCII characters "[A-Z][a-z][0-9]_" */ |
26 |
|
|
#define DBUS_OPATH_VALID_CHARS "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_" |
27 |
|
|
|
28 |
|
|
char * |
29 |
|
✗ |
bolt_gen_object_path (const char *base, |
30 |
|
|
const char *oid) |
31 |
|
|
{ |
32 |
|
✗ |
g_autofree char *id = NULL; |
33 |
|
|
|
34 |
|
✗ |
if (oid) |
35 |
|
|
{ |
36 |
|
✗ |
id = g_strdup (oid); |
37 |
|
✗ |
g_strcanon (id, DBUS_OPATH_VALID_CHARS, '_'); |
38 |
|
|
} |
39 |
|
|
|
40 |
|
✗ |
if (base && id) |
41 |
|
✗ |
return g_build_path ("/", "/", base, id, NULL); |
42 |
|
✗ |
else if (base) |
43 |
|
✗ |
return g_build_path ("/", "/", base, NULL); |
44 |
|
✗ |
else if (id) |
45 |
|
✗ |
return g_build_path ("/", "/", id, NULL); |
46 |
|
|
|
47 |
|
✗ |
return g_strdup ("/"); |
48 |
|
|
} |
49 |
|
|
|