compile fixes
[lttv.git] / ltt / branches / poly / lttv / option.c
index fc5bc26f0a6f4451280d6237810264412fc044a3..c5046ef861a2100dd10d115373e0cec20ea58efa 100644 (file)
@@ -1,9 +1,9 @@
-
-#include "lttv.h"
-#include "option.h"
-#include "hook.h"
 #include <popt.h>
 
+#include <lttv/hook.h>
+#include <lttv/lttv.h>
+#include <lttv/option.h>
+
 /* Extensible array of popt command line options. Modules add options as
    they are loaded and initialized. */
 
@@ -12,8 +12,6 @@ typedef struct _lttv_option {
   void *hook_data;
 } lttv_option;
 
-extern lttv_attributes *attributes_global;
-
 static GArray *lttv_options_command;
 
 static GArray *lttv_options_command_popt;
@@ -48,16 +46,16 @@ void lttv_option_init(int argc, char **argv) {
   hooks_options_before = lttv_hooks_new();
   hooks_options_after = lttv_hooks_new();
 
-  lttv_attributes_set_pointer_pathname(attributes_global
+  lttv_attributes_set_pointer_pathname(lttv_global_attributes()
       "hooks/options/before", hooks_options_before);
 
-  lttv_attributes_set_pointer_pathname(attributes_global,
+  lttv_attributes_set_pointer_pathname(lttv_global_attributes(),
       "hooks/options/after",  hooks_options_after);
 
   lttv_options_command_popt = g_array_new(0,0,sizeof(struct poptOption));
   lttv_options_command = g_array_new(0,0,sizeof(lttv_option));
 
-  hooks_init_after = lttv_attributes_get_pointer_pathname(attributes_global,
+  hooks_init_after = lttv_attributes_get_pointer_pathname(lttv_global_attributes(),
                  "hooks/init/after");
   lttv_hooks_add(hooks_init_after, lttv_options_command_parse, NULL);
 
@@ -65,13 +63,24 @@ void lttv_option_init(int argc, char **argv) {
 
 void lttv_option_destroy() {
 
+  struct poptOption *poption;
+
+  int i;
+  
+  for(i=0; i < lttv_options_command_popt->len ; i++) {
+    poption = &g_array_index (lttv_options_command_popt, struct poptOption, i);
+
+    g_free((gpointer)poption->longName);
+    g_free((gpointer)poption->descrip);
+    g_free((gpointer)poption->argDescrip);
+  }
   g_array_free(lttv_options_command_popt,TRUE) ;
   g_array_free(lttv_options_command,TRUE) ;
 
-  lttv_attributes_set_pointer_pathname(attributes_global
+  lttv_attributes_set_pointer_pathname(lttv_global_attributes()
       "hooks/options/before", NULL);
 
-  lttv_attributes_set_pointer_pathname(attributes_global,
+  lttv_attributes_set_pointer_pathname(lttv_global_attributes(),
       "hooks/options/after",  NULL);
 
   lttv_hooks_destroy(hooks_options_before);
@@ -85,18 +94,19 @@ static int poptToLTT[] = {
 };
 
 
-void lttv_option_add(char *long_name, char char_name, char *description, 
-    char *argDescription, lttv_option_type t, void *p, 
-    lttv_option_hook h, void *hook_data)
+void lttv_option_add(const char *long_name, const char char_name,
+               const char *description, const char *argDescription,
+               const lttv_option_type t, void *p, 
+               const lttv_option_hook h, void *hook_data)
 {
   struct poptOption poption;
 
   lttv_option option;
 
-  poption.longName = long_name;
+  poption.longName = (char *)g_strdup(long_name);
   poption.shortName = char_name;
-  poption.descrip = description;
-  poption.argDescrip = argDescription;
+  poption.descrip = (char *)g_strdup(description);
+  poption.argDescrip = (char *)g_strdup(argDescription);
   poption.argInfo = poptToLTT[t];
   poption.arg = p;
   poption.val = lttv_options_command->len + 1;
This page took 0.024077 seconds and 4 git commands to generate.