]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/test-strv.c
relicense to LGPLv2.1 (with exceptions)
[thirdparty/systemd.git] / src / test-strv.c
CommitLineData
f90cf44c
LP
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
5430f7f2
LP
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
f90cf44c
LP
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
5430f7f2 16 Lesser General Public License for more details.
f90cf44c 17
5430f7f2 18 You should have received a copy of the GNU Lesser General Public License
f90cf44c
LP
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20***/
21
22#include <string.h>
2c4b304e 23
f90cf44c 24#include "util.h"
2c4b304e 25#include "specifier.h"
f90cf44c
LP
26
27int main(int argc, char *argv[]) {
2c4b304e
LP
28 const Specifier table[] = {
29 { 'a', specifier_string, (char*) "AAAA" },
30 { 'b', specifier_string, (char*) "BBBB" },
31 { 0, NULL, NULL }
32 };
33
f90cf44c
LP
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
e3aa71c3
LP
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
2c4b304e
LP
61 w = specifier_printf("xxx a=%a b=%b yyy", table, NULL);
62 printf("<%s>\n", w);
63 free(w);
64
f90cf44c
LP
65 return 0;
66}