Hi Remy!

Remy HAREL schrieb am 2004-05-26 12:26:42:
> Ok Mathias, but I don't understand how to use it. In fact, imagine I ( 
> [EMAIL PROTECTED]) have a session opened... the current "sess" in c2s.c, 
> c2s_client_sx_callback. I 'm gonna send a packet to you ( [EMAIL PROTECTED] ), 
> juste before the sm_packet.  the full jid of the session "sess" is mine, 
> [EMAIL PROTECTED] If I sent a message to you, I should be able to read somewhere 
> ( in nad I suppose ) that this message is for "[EMAIL PROTECTED]", no ?

Sure you could ... but you realy SHOULD NOT do this. The task of c2s is
to authenticate you and to forward messages to your own session manager.

All processing of these messages should be done in the session manager
(sm) then.

> How should I call nad_find_attr  to do what I want ? I've tried 
> something like :
> 
> attr_tmp = nad_find_attr(nad,0,-1,"to",NULL);    // here value is '-1'
> recipient = (char*) malloc(sizeof(char) * NAD_AVAL_T(nad, attr_tmp);
> recipient = (char*)NAD_AVAL(nad, attr_tmp);   // crash, due to 
> attr_tmp's value

you have to tell nad_find_attr the handle of the element where you want
to search for the attribute ... there is nothing like a global search
for an attribute in a nad (AFAIK). So start with nad_find_elem ... you
get back a handle for the element which you can use in nad_find_attr.

Also don't forget the handling of namespaces!

also your assignment won't work ... you only would produce a memory leak
... you are allocating memory and you throgh away the pointer to it in
the line afterwards ... your second assignment does not copy the string
in C but only assigns a pointer. You have to use something like the
following for the second line:
sprintf(recipient, "%.*s", NAD_AVAL_L(nad, attr_tmp), NAD_AVAL(nad, attr_tmp));

Another bug you have in your code is that you have to reserve memory for
the terminating zero byte in the string as well, not only for the pure
content of it.

> due to attr_tmp which value's -1; nad_find_attr didn't find the 
> attribute "to". Moreover, this attribute value isn't "[EMAIL PROTECTED]" but 
> just "gabber"... so only the domain. I saw this by using  tcpdump.

If you are searching for anything in XML you always have to check if you
got something back ... you can never expect all clients sending correct
XML streams.


Tot kijk
    Matthias

-- 
Fon: +49-(0)70 0770 07770       http://matthias.wimmer.name/
HAM: DB1MW                      xmpp:[EMAIL PROTECTED]

Attachment: signature.asc
Description: Digital signature

_______________________________________________
jdev mailing list
[EMAIL PROTECTED]
https://jabberstudio.org/mailman/listinfo/jdev

Reply via email to