1 /*
2 * Copyright (C) 2007 Karel Zak <kzak@redhat.com>
3 *
4 * This file is part of util-linux.
5 *
6 * This file is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This file is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <string.h>
20 #include <unistd.h>
21
22 #include "pathnames.h"
23
24 struct hlpPath
25 {
26 const char *name;
27 const char *path;
28 };
29
30 #define DEF_HLPPATH(_p) { #_p, _p }
31
32 struct hlpPath paths[] =
33 {
34 DEF_HLPPATH(_PATH_DEFPATH),
35 DEF_HLPPATH(_PATH_DEFPATH_ROOT),
36 DEF_HLPPATH(_PATH_DEV_TTY),
37 DEF_HLPPATH(_PATH_DEV_LOOP),
38 DEF_HLPPATH(_PATH_SECURETTY),
39 DEF_HLPPATH(_PATH_WTMPLOCK),
40 DEF_HLPPATH(_PATH_HUSHLOGIN),
41 DEF_HLPPATH(_PATH_MAILDIR),
42 DEF_HLPPATH(_PATH_MOTDFILE),
43 DEF_HLPPATH(_PATH_NOLOGIN),
44 DEF_HLPPATH(_PATH_LOGIN),
45 DEF_HLPPATH(_PATH_INITTAB),
46 DEF_HLPPATH(_PATH_RC),
47 DEF_HLPPATH(_PATH_REBOOT),
48 DEF_HLPPATH(_PATH_SINGLE),
49 DEF_HLPPATH(_PATH_SHUTDOWN_CONF),
50 DEF_HLPPATH(_PATH_SECURE),
51 DEF_HLPPATH(_PATH_USERTTY),
52 DEF_HLPPATH(_PATH_UMOUNT),
53 DEF_HLPPATH(_PATH_PASSWD),
54 DEF_HLPPATH(_PATH_GSHADOW),
55 DEF_HLPPATH(_PATH_GROUP),
56 DEF_HLPPATH(_PATH_SHADOW_PASSWD),
57 DEF_HLPPATH(_PATH_WORDS),
58 DEF_HLPPATH(_PATH_WORDS_ALT),
59 DEF_HLPPATH(_PATH_UMOUNT),
60 DEF_HLPPATH(_PATH_FILESYSTEMS),
61 DEF_HLPPATH(_PATH_PROC_SWAPS),
62 DEF_HLPPATH(_PATH_PROC_FILESYSTEMS),
63 DEF_HLPPATH(_PATH_MOUNTED),
64 DEF_HLPPATH(_PATH_MNTTAB),
65 DEF_HLPPATH(_PATH_MOUNTED_LOCK),
66 DEF_HLPPATH(_PATH_MOUNTED_TMP),
67 DEF_HLPPATH(_PATH_DEV_BYLABEL),
68 DEF_HLPPATH(_PATH_DEV_BYUUID),
69 { NULL, NULL }
70 };
71
72 int
main(int argc,char ** argv)73 main(int argc, char **argv)
74 {
75 struct hlpPath *p;
76
77 if (argc == 1) {
78 for (p = paths; p->name; p++)
79 printf("%20s %s\n", p->name, p->path);
80 exit(EXIT_SUCCESS);
81 } else {
82 if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0) {
83 printf("%s <option>\n", argv[0]);
84 fputs("options:\n", stdout);
85 for (p = paths; p->name; p++)
86 printf("\t%s\n", p->name);
87 exit(EXIT_SUCCESS);
88 }
89
90 for (p = paths; p->name; p++) {
91 if (strcmp(p->name, argv[1]) == 0) {
92 printf("%s\n", p->path);
93 exit(EXIT_SUCCESS);
94 }
95 }
96 }
97
98 exit(EXIT_FAILURE);
99 }
100
101