Fix: Typo from a previous patch in an assert()
[lttng-tools.git] / src / bin / lttng / utils.c
1 /*
2 * Copyright (c) 2011 David Goulet <david.goulet@polymtl.ca>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, version 2 only,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 */
17
18 #define _GNU_SOURCE
19 #include <stdlib.h>
20 #include <ctype.h>
21 #include <limits.h>
22
23 #include <common/error.h>
24
25 #include "conf.h"
26 #include "utils.h"
27
28 /*
29 * get_session_name
30 *
31 * Return allocated string with the session name found in the config
32 * directory.
33 */
34 char *get_session_name(void)
35 {
36 char *path, *session_name = NULL;
37
38 /* Get path to config file */
39 path = config_get_default_path();
40 if (path == NULL) {
41 goto error;
42 }
43
44 /* Get session name from config */
45 session_name = config_read_session_name(path);
46 if (session_name == NULL) {
47 goto error;
48 }
49
50 DBG2("Config file path found: %s", path);
51 DBG("Session name found: %s", session_name);
52 return session_name;
53
54 error:
55 return NULL;
56 }
57
58
59 /*
60 * list_cmd_options
61 *
62 * Prints a simple list of the options available to a command. This is intended
63 * to be easily parsed for bash completion.
64 */
65 void list_cmd_options(FILE *ofp, struct poptOption *options)
66 {
67 int i;
68 struct poptOption *option = NULL;
69
70 for (i = 0; options[i].longName != NULL; i++) {
71 option = &options[i];
72
73 fprintf(ofp, "--%s\n", option->longName);
74
75 if (isprint(option->shortName)) {
76 fprintf(ofp, "-%c\n", option->shortName);
77 }
78 }
79 }
This page took 0.029952 seconds and 4 git commands to generate.