If I am not mistaken, config_parse_data( CONFIG_REC results, const char *data 
input, const char *error_id ) should take input "data", parse it, and store the 
results in "results". "results" can then be traversed, searched, added to or 
other operations as desired. This is what I am trying to determine with the 
following code:

=== START CODE ===
  CONFIG_REC * config;
  CONFIG_NODE * node, * tmp;
  GSList * list;

/* iconfig.h instructs to use config_open like this in order
 * to just use config_parse_data(...) */
  config = config_open(NULL, -1);

/* we shouldn't expect to see anything from this */
  printtext(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
    "{ fname %s }", config->fname);

/* parse some data that i want */
  config_parse_data(config, "statusbar = { check = { it = \"out\"; }; }; };",  
                             "my config test");
  node = iconfig_node_traverse("statusbar", FALSE);
  if (node == NULL) return;

/* print out all the nodes in the parsed data */
  int index = 0;
  for (tmp = node; tmp != NULL; tmp = config_node_nth(node, index))
  {

    printtext(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
      "{ node%d->key %s }",
       index, tmp->key);

    if (config_node_nth(node,index+1) == NULL)
    {
      node = config_node_nth(node, index);
      index = 0;
      if (config_node_next((GSList*)(node->value)) ==  NULL)
        break;
    }
    else
      index++;
  }

  config_close(config);
=== END CODE === 

The result of running the code in a module loaded into Irssi is this:
=== START RESULTS ===
(17:39) ### { fname  }
(17:39) ### { node0->key statusbar }
(17:39) ### { node1->key default }
(17:39) ### { node0->key window }
(17:39) ### { node1->key topic }
(17:39) ### { node2->key dccstat }
(17:39) ### { node0->key items }
(17:39) ### { node1->key position }
(17:39) ### { node2->key placement }
(17:39) ### { node3->key disabled }
=== END RESULTS ===

As expected, fname does not return anything, because I opened a NULL config.
However, the results of the data iteration are not what I expected. Instead of 
parsing the data I instructed it to, it parsed my actual Irssi config, even 
though I never referred to it. The expected results should have been something 
like this:

node0->key statusbar
node1->key check
node2->key it

Can anyone point to me what I am doing wrong, or if I am using 
config_parse_data(...) completely other than intended? I thought I was correct 
based on my perusals of Irssi code thus far.

Thanks,
Max Englander

       
---------------------------------
Never miss a thing.   Make Yahoo your homepage.

Reply via email to