Debian Codegraph @

src/lib/profiles/custom.c

raw symbols SCIP
1 /*
2 Authors:
3 Pavel Březina <[email protected]>
4
5 Copyright (C) 2018 Red Hat
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include <string.h>
22
23 #include "common/common.h"
24 #include "lib/constants.h"
25
26 char *
27 authselect_profile_custom_id(const char *name)
28 {
29 return format("%s%s", AUTHSELECT_CUSTOM_PREFIX, name);
30 }
31
32 const char *
33 authselect_profile_parse_custom(const char *profile_id)
34 {
35 static size_t len = strlen(AUTHSELECT_CUSTOM_PREFIX);
36
37 if (profile_id == NULL) {
38 return NULL;
39 }
40
41 if (strncmp(AUTHSELECT_CUSTOM_PREFIX, profile_id, len) != 0) {
42 return NULL;
43 }
44
45 return profile_id + len;
46 }
47
48 bool
49 authselect_profile_is_custom(const char *profile_id)
50 {
51 return authselect_profile_parse_custom(profile_id) != NULL;
52 }