Irssi's config_parse_data does not behave as expected.

Max Englander <[email protected]> Thu, 6 Dec 2007 14:53:10 -0800 (PST)
Newsgroups gmane.network.irc.irssi.devel
Message-ID <[email protected]>
--0-342894552-1196981590=:81288
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable


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, an=
d store the results in "results". "results" can then be traversed, search=
ed, added to or other operations as desired. This is what I am trying to =
determine with the following code:

=3D=3D=3D START CODE =3D=3D=3D
  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 =3D 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 =3D { check =3D { it =3D \"out\"; =
}; }; };", =20
                             "my config test");
  node =3D iconfig_node_traverse("statusbar", FALSE);
  if (node =3D=3D NULL) return;

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

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

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

  config_close(config);
=3D=3D=3D END CODE =3D=3D=3D=20

The result of running the code in a module loaded into Irssi is this:
=3D=3D=3D START RESULTS =3D=3D=3D
(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 }
=3D=3D=3D END RESULTS =3D=3D=3D

As expected, fname does not return anything, because I opened a NULL conf=
ig.
However, the results of the data iteration are not what I expected. Inste=
ad of parsing the data I instructed it to, it parsed my actual Irssi conf=
ig, 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_par=
se_data(...) completely other than intended? I thought I was correct base=
d on my perusals of Irssi code thus far.

Thanks,
Max Englander

      =20
---------------------------------
Never miss a thing.   Make Yahoo your homepage.
--0-342894552-1196981590=:81288
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

<br>If I am not mistaken, config_parse_data( CONFIG_REC results, const ch=
ar *data input, const char *error_id ) should take input "data", parse it=
, and store the results in "results". "results" can then be traversed, se=
arched, added to or other operations as desired. This is what I am trying=
 to determine with the following code:<br><br>=3D=3D=3D START CODE =3D=3D=
=3D<br>&nbsp; CONFIG_REC * config;<br>&nbsp; CONFIG_NODE * node, * tmp;<b=
r>&nbsp; GSList * list;<br><br>/* iconfig.h instructs to use config_open =
like this in order<br>&nbsp;* to just use config_parse_data(...) */<br>&n=
bsp; config =3D config_open(NULL, -1);<br><br>/* we shouldn't expect to s=
ee anything from this */<br>&nbsp; printtext(NULL, NULL, MSGLEVEL_CLIENTN=
OTICE,<br>&nbsp;&nbsp;&nbsp; "{ fname %s }", config-&gt;fname);<br><br>/*=
 parse some data that i want */<br>&nbsp; config_parse_data(config, "stat=
usbar =3D { check =3D { it =3D \"out\"; }; }; };",=20
 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp; "my config test");<br>&nbsp; node =3D iconfig=
_node_traverse("statusbar", FALSE);<br>&nbsp; if (node =3D=3D NULL) retur=
n;<br><br>/* print out all the nodes in the parsed data */<br>&nbsp; int =
index =3D 0;<br>&nbsp; for (tmp =3D node; tmp !=3D NULL; tmp =3D config_n=
ode_nth(node, index))<br>&nbsp; {<br><br>&nbsp;&nbsp;&nbsp; printtext(NUL=
L, NULL, MSGLEVEL_CLIENTNOTICE,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "{ node=
%d-&gt;key %s }",<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; index, tmp-&gt;=
key);<br><br>&nbsp;&nbsp;&nbsp; if (config_node_nth(node,index+1) =3D=3D =
NULL)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; node =3D =
config_node_nth(node, index);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; index =3D=
 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (config_node_next((GSList*)(node=
-&gt;value)) =3D=3D=20
 NULL)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br>&nbsp;&nbs=
p;&nbsp; }<br>&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i=
ndex++;<br>&nbsp; }<br><br>&nbsp; config_close(config);<br>=3D=3D=3D END =
CODE =3D=3D=3D <br><br>The result of running the code in a module loaded =
into Irssi is this:<br>=3D=3D=3D START RESULTS =3D=3D=3D<br>(17:39) ### {=
 fname&nbsp; }<br>(17:39) ### { node0-&gt;key statusbar }<br>(17:39) ### =
{ node1-&gt;key default }<br>(17:39) ### { node0-&gt;key window }<br>(17:=
39) ### { node1-&gt;key topic }<br>(17:39) ### { node2-&gt;key dccstat }<=
br>(17:39) ### { node0-&gt;key items }<br>(17:39) ### { node1-&gt;key pos=
ition }<br>(17:39) ### { node2-&gt;key placement }<br>(17:39) ### { node3=
-&gt;key disabled }<br>=3D=3D=3D END RESULTS =3D=3D=3D<br><br>As expected=
, fname does not return anything, because I opened a NULL config.<br>Howe=
ver, the results of the data iteration are not what I expected. Instead o=
f 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 bee=
n something like this:<br><br>node0-&gt;key statusbar<br>node1-&gt;key ch=
eck<br>node2-&gt;key it<br><br>Can anyone point to me what I am doing wro=
ng, or if I am using config_parse_data(...) completely other than intende=
d? I thought I was correct based on my perusals of Irssi code thus far.<b=
r><br>Thanks,<br>Max Englander<br><p>&#32;

      <hr size=3D1>Never miss a thing.  <a href=3D"http://us.rd.yahoo.com=
/evt=3D51438/*http://www.yahoo.com/r/hs"> Make Yahoo your homepage.</a>


--0-342894552-1196981590=:81288--