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> CONFIG_REC * config;<br> CONFIG_NODE * node, * tmp;<b=
r> GSList * list;<br><br>/* iconfig.h instructs to use config_open =
like this in order<br> * 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> printtext(NULL, NULL, MSGLEVEL_CLIENTN=
OTICE,<br> "{ fname %s }", config->fname);<br><br>/*=
parse some data that i want */<br> config_parse_data(config, "stat=
usbar =3D { check =3D { it =3D \"out\"; }; }; };",=20
<br> &n=
bsp; &nb=
sp; "my config test");<br> node =3D iconfig=
_node_traverse("statusbar", FALSE);<br> if (node =3D=3D NULL) retur=
n;<br><br>/* print out all the nodes in the parsed data */<br> int =
index =3D 0;<br> for (tmp =3D node; tmp !=3D NULL; tmp =3D config_n=
ode_nth(node, index))<br> {<br><br> printtext(NUL=
L, NULL, MSGLEVEL_CLIENTNOTICE,<br> "{ node=
%d->key %s }",<br> index, tmp->=
key);<br><br> if (config_node_nth(node,index+1) =3D=3D =
NULL)<br> {<br> node =3D =
config_node_nth(node, index);<br> index =3D=
0;<br> if (config_node_next((GSList*)(node=
->value)) =3D=3D=20
NULL)<br> break;<br> &nbs=
p; }<br> else<br> i=
ndex++;<br> }<br><br> 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 }<br>(17:39) ### { node0->key statusbar }<br>(17:39) ### =
{ node1->key default }<br>(17:39) ### { node0->key window }<br>(17:=
39) ### { node1->key topic }<br>(17:39) ### { node2->key dccstat }<=
br>(17:39) ### { node0->key items }<br>(17:39) ### { node1->key pos=
ition }<br>(17:39) ### { node2->key placement }<br>(17:39) ### { node3=
->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->key statusbar<br>node1->key ch=
eck<br>node2->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> 
<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--