filter text module:
authorsiboud <siboud@04897980-b3bd-0310-b5e0-8ef037075253>
Fri, 1 Apr 2005 22:20:44 +0000 (22:20 +0000)
committersiboud <siboud@04897980-b3bd-0310-b5e0-8ef037075253>
Fri, 1 Apr 2005 22:20:44 +0000 (22:20 +0000)
- added file input function

git-svn-id: http://ltt.polymtl.ca/svn@913 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/lttv/lttv/filter.c
ltt/branches/poly/lttv/modules/text/textFilter.c

index 7f31c53d5b444f0b9583717d535aa0319a75d8a0..dcb3350e247f07bed06ba6b29ea6579401047194 100644 (file)
@@ -397,7 +397,7 @@ gboolean lttv_simple_expression_assign_operator(LttvSimpleExpression* se, LttvEx
  */
 gboolean lttv_simple_expression_assign_value(LttvSimpleExpression* se, char* value) {
 
-  g_print("se->value:%s\n",value);
+//  g_print("se->value:%s\n",value);
   
   switch(se->field) {
      /* 
@@ -1036,8 +1036,8 @@ lttv_filter_update(LttvFilter* filter) {
    *    3. pop the tree value from the tree stack
    */
   
-  g_print("expression: %s\n",filter->expression);
-  g_print("strlen(expression): %i\n",strlen(filter->expression));
+//  g_print("expression: %s\n",filter->expression);
+//  g_print("strlen(expression): %i\n",strlen(filter->expression));
   for(i=0;i<strlen(filter->expression);i++) {
     // debug
     g_print("%c ",filter->expression[i]);
@@ -1186,14 +1186,12 @@ lttv_filter_update(LttvFilter* filter) {
           //a_simple_expression->value = g_string_free(a_field_component,FALSE);
           a_field_component = g_string_new("");
           t1 = g_ptr_array_index(tree_stack,tree_stack->len-1);
-          g_print("here\n");
           while(t1->right != LTTV_TREE_IDLE) {
              g_print("while right:%i %p->child:%p\n",t1->right,t1,t1->r_child.t);
              g_assert(t1->right == LTTV_TREE_NODE);
              g_assert(t1->r_child.t != NULL);
              t1 = t1->r_child.t;
           }
-          g_print("here2\n");
           t1->right = LTTV_TREE_LEAF;
           t1->r_child.leaf = a_simple_expression;
           a_simple_expression = lttv_simple_expression_new(); 
@@ -1257,8 +1255,8 @@ lttv_filter_update(LttvFilter* filter) {
     }
   }
 
-  g_print("subtree:%p, tree:%p, t1:%p, t2:%p\n",subtree,tree,t1,t2);
-  g_print("stack size: %i\n",tree_stack->len);
+//  g_print("subtree:%p, tree:%p, t1:%p, t2:%p\n",subtree,tree,t1,t2);
+//  g_print("stack size: %i\n",tree_stack->len);
 
   /*
    * Preliminary check to see
index f8a2ea4533ba92b25d09fbf317a39f9d114debac..8f7a7d81ed567a4da53a9ad8c514bcdf94ececf7 100644 (file)
@@ -57,8 +57,6 @@ static LttvHooks
   *before_traceset,
   *event_hook;
 
-static FILE *a_file;
-
 /**
  * filters the file input from user
  * @param hook_data the hook data
@@ -77,7 +75,9 @@ void filter_analyze_file(void *hook_data) {
         *      and/or command line string.  From these sources, an 
         *      option string is rebuilded and sent to the filter core
         */
-  GString* a_file_content = g_string_new("");
+  
+/* OLD CODE
+ * GString* a_file_content = g_string_new("");
   a_file = fopen(a_file_name, "r"); 
        if(a_file == NULL) { 
                g_warning("file %s does not exist", a_file_name);
@@ -92,14 +92,27 @@ void filter_analyze_file(void *hook_data) {
     g_string_append(a_file_content,line);
   }
   free(line);
+
+  fclose(a_file);
+*/  
+  
+  if(!g_file_test(a_file_name,G_FILE_TEST_EXISTS)) {
+    g_warning("file %s does not exist", a_file_name);
+    return;
+  }
+
+  char* a_file_content = NULL;
+
+  g_file_get_contents(a_file_name,&a_file_content,NULL,NULL);
   
   g_assert(lttv_iattribute_find_by_path(attributes, "filter/expression",
       LTTV_POINTER, &value));
 
   if(((GString*)*(value.v_pointer))->len != 0) g_string_append_c((GString*)*(value.v_pointer),'&');
-  g_string_append((GString*)*(value.v_pointer),a_file_content->str);
+  g_string_append_c((GString*)*(value.v_pointer),'(');
+  g_string_append((GString*)*(value.v_pointer),a_file_content);
+  g_string_append_c((GString*)*(value.v_pointer),')');
   
-  fclose(a_file);
 }
 
 /**
@@ -134,7 +147,9 @@ void filter_analyze_string(void *hook_data) {
       LTTV_POINTER, &value));
 
   if(((GString*)*(value.v_pointer))->len != 0) g_string_append_c((GString*)*(value.v_pointer),'&');
+  g_string_append_c((GString*)*(value.v_pointer),'(');
   g_string_append((GString*)*(value.v_pointer),a_string);
+  g_string_append_c((GString*)*(value.v_pointer),')');
 
 //  LttvFilter* filter = lttv_filter_new();
 //  lttv_filter_append_expression(filter,a_string);
This page took 0.026065 seconds and 4 git commands to generate.