-#include <popt.h>
+#include <popt.h>
+#include <glib.h>
#include <lttv/option.h>
typedef struct _LttvOption {
- const char *long_name;
+ char *long_name;
char char_name;
- const char *description;
- const char *arg_description;
+ char *description;
+ char *arg_description;
LttvOptionType t;
gpointer p;
- LttvOptionHook h;
+ LttvOptionHook hook;
gpointer hook_data;
} LttvOption;
{
LttvOption option;
- GPtrArray list = g_ptr_array_new();
+ GPtrArray *list = g_ptr_array_new();
int i;
option->arg_description = g_strdup(arg_description);
option->t = t;
option->p = p;
- option->h = h;
+ option->hook = h;
option->hook_data = hook_data;
g_hash_table_insert(options, option->long_name, option);
}
static void
build_popts(GPtrArray **plist, struct poptOption **ppopts, poptContext *pc,
- int argv, char **argv)
+ int argc, char **argv)
{
LttvOption *option;
{
g_ptr_array_free(*plist, TRUE); *plist = NULL;
g_free(*ppopts); *ppopts = NULL;
- poptFreeContext(*c);
+ poptFreeContext(*pc);
}
destroy_popts(&list, &popts, &c);
}
+static void show_help(LttvOption *option)
+{
+ printf("--%s -%c argument: %s\n" , option->long_name,
+ option->char_name,
+ option->arg_description);
+ printf(" %s\n" , option->description);
+
+}
+
+void lttv_option_show_help(void)
+{
+ LttvOption option;
+
+ GPtrArray *list = g_ptr_array_new();
+
+ int i;
+
+ g_hash_table_foreach(options, list_options, list);
+
+ printf("Built-in commands available:\n");
+ printf("\n");
+
+ for(i = 0 ; i < list->len ; i++) {
+ show_help((LttvOption *)list->pdata[i]);
+ }
+ g_ptr_array_free(list, TRUE);
+
+
+}