]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/test-strv.c
dbus: more efficient implementation of properties
[thirdparty/systemd.git] / src / test-strv.c
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 /***
4 This file is part of systemd.
5
6 Copyright 2010 Lennart Poettering
7
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 ***/
21
22 #include <string.h>
23
24 #include "util.h"
25 #include "specifier.h"
26
27 int main(int argc, char *argv[]) {
28 const Specifier table[] = {
29 { 'a', specifier_string, (char*) "AAAA" },
30 { 'b', specifier_string, (char*) "BBBB" },
31 { 0, NULL, NULL }
32 };
33
34 char *w, *state;
35 size_t l;
36 const char test[] = "test a b c 'd' e '' '' hhh '' ''";
37
38 printf("<%s>\n", test);
39
40 FOREACH_WORD_QUOTED(w, l, test, state) {
41 char *t;
42
43 assert_se(t = strndup(w, l));
44 printf("<%s>\n", t);
45 free(t);
46 }
47
48 printf("%s\n", default_term_for_tty("/dev/tty23"));
49 printf("%s\n", default_term_for_tty("/dev/ttyS23"));
50 printf("%s\n", default_term_for_tty("/dev/tty0"));
51 printf("%s\n", default_term_for_tty("/dev/pty0"));
52 printf("%s\n", default_term_for_tty("/dev/pts/0"));
53 printf("%s\n", default_term_for_tty("/dev/console"));
54 printf("%s\n", default_term_for_tty("tty23"));
55 printf("%s\n", default_term_for_tty("ttyS23"));
56 printf("%s\n", default_term_for_tty("tty0"));
57 printf("%s\n", default_term_for_tty("pty0"));
58 printf("%s\n", default_term_for_tty("pts/0"));
59 printf("%s\n", default_term_for_tty("console"));
60
61 w = specifier_printf("xxx a=%a b=%b yyy", table, NULL);
62 printf("<%s>\n", w);
63 free(w);
64
65 return 0;
66 }