X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;ds=sidebyside;f=src%2Fbin%2Flttng%2Futils.c;h=514bfe645a40363cb4cd6526b1c09c8e13d025b2;hb=ca2eb7f43cf00d12f563905d741a6789c3d130ee;hp=25d463adf92ce49db5642ae488321ce5817116f4;hpb=10a8a2237343699e3923d87e24dbf2d7fe225377;p=lttng-tools.git diff --git a/src/bin/lttng/utils.c b/src/bin/lttng/utils.c index 25d463adf..514bfe645 100644 --- a/src/bin/lttng/utils.c +++ b/src/bin/lttng/utils.c @@ -16,11 +16,14 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#define _GNU_SOURCE #include +#include -#include +#include #include "conf.h" +#include "utils.h" /* * get_session_name @@ -44,7 +47,33 @@ char *get_session_name(void) goto error; } -error: + DBG2("Config file path found: %s", path); DBG("Session name found: %s", session_name); return session_name; + +error: + return NULL; +} + + +/* + * list_cmd_options + * + * Prints a simple list of the options available to a command. This is intended + * to be easily parsed for bash completion. + */ +void list_cmd_options(FILE *ofp, struct poptOption *options) +{ + int i; + struct poptOption *option = NULL; + + for (i = 0; options[i].longName != NULL; i++) { + option = &options[i]; + + fprintf(ofp, "--%s\n", option->longName); + + if (isprint(option->shortName)) { + fprintf(ofp, "-%c\n", option->shortName); + } + } }