X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng%2Futils.c;fp=src%2Fbin%2Flttng%2Futils.c;h=556728da23773f19935d0ea8b484a1b2cf901664;hb=8b833f70b3d3697e74c54f3a2f5efbe5292097ef;hp=6041655ddda0f6eb42de5b829cb29688c11f1a24;hpb=5aaa62a111f332a7c4412558bb9da9b30320eefd;p=lttng-tools.git diff --git a/src/bin/lttng/utils.c b/src/bin/lttng/utils.c index 6041655dd..556728da2 100644 --- a/src/bin/lttng/utils.c +++ b/src/bin/lttng/utils.c @@ -16,6 +16,7 @@ */ #define _GNU_SOURCE +#include #include #include #include @@ -25,6 +26,11 @@ #include "conf.h" #include "utils.h" +#include "command.h" + +static const char *str_kernel = "Kernel"; +static const char *str_ust = "UST"; +static const char *str_jul = "JUL"; /* * get_session_name @@ -56,6 +62,24 @@ error: return NULL; } +/* + * list_commands + * + * List commands line by line. This is mostly for bash auto completion and to + * avoid difficult parsing. + */ +void list_commands(struct cmd_struct *commands, FILE *ofp) +{ + int i = 0; + struct cmd_struct *cmd = NULL; + + cmd = &commands[i]; + while (cmd->name != NULL) { + fprintf(ofp, "%s\n", cmd->name); + i++; + cmd = &commands[i]; + } +} /* * list_cmd_options @@ -230,3 +254,25 @@ int get_count_order_ulong(unsigned long x) return fls_ulong(x - 1); } + +const char *get_domain_str(enum lttng_domain_type domain) +{ + const char *str_dom; + + switch (domain) { + case LTTNG_DOMAIN_KERNEL: + str_dom = str_kernel; + break; + case LTTNG_DOMAIN_UST: + str_dom = str_ust; + break; + case LTTNG_DOMAIN_JUL: + str_dom = str_jul; + break; + default: + /* Should not have an unknown domain or else define it. */ + assert(0); + } + + return str_dom; +}