License header fixes
[lttng-tools.git] / src / bin / lttng / utils.c
index e993f0f7231c8c5b71ef6363e37598f5ba4bda5a..b982bd5936149ab7667e64176a9f0c499dfd0207 100644 (file)
@@ -1,10 +1,9 @@
 /*
  * Copyright (c)  2011 David Goulet <david.goulet@polymtl.ca>
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; only version 2
- * of the License.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2 only,
+ * as published by the Free Software Foundation.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#define _GNU_SOURCE
 #include <stdlib.h>
+#include <ctype.h>
 
 #include <common/error.h>
 
 #include "conf.h"
+#include "utils.h"
 
 /*
  *  get_session_name
@@ -44,7 +46,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);
+               }
+       }
 }
This page took 0.025659 seconds and 5 git commands to generate.