本文整理汇总了C++中xmlnode_put_attrib函数的典型用法代码示例。如果您正苦于以下问题:C++ xmlnode_put_attrib函数的具体用法?C++ xmlnode_put_attrib怎么用?C++ xmlnode_put_attrib使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xmlnode_put_attrib函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dnsrv_child_process_xstream_io
/* Coprocess functionality */
void dnsrv_child_process_xstream_io(int type, xmlnode x, void* args)
{
dns_io di = (dns_io)args;
char* hostname;
char* str = NULL;
dns_resend_list iternode = NULL;
if (type == XSTREAM_NODE)
{
/* Get the hostname out... */
hostname = xmlnode_get_data(x);
log_debug(ZONE, "dnsrv: Recv'd lookup request for %s", hostname);
if (hostname != NULL)
{
/* For each entry in the svclist, try and resolve using
the specified service and resend it to the specified host */
iternode = di->svclist;
while (iternode != NULL)
{
str = srv_lookup(x->p, iternode->service, hostname);
if (str != NULL)
{
log_debug(ZONE, "Resolved %s(%s): %s\tresend to:%s", hostname, iternode->service, str, iternode->host);
xmlnode_put_attrib(x, "ip", str);
xmlnode_put_attrib(x, "to", iternode->host);
break;
}
iternode = iternode->next;
}
str = xmlnode2str(x);
write(di->out, str, strlen(str));
}
}
xmlnode_free(x);
}
示例2: mt_unknown_bounce
/* bounces packet for unknown users with the appropriate error */
void mt_unknown_bounce(void *arg)
{
jpacket jp = (jpacket) arg;
mti ti = (mti) jp->aux1;
xmlnode reg;
lowercase(jp->from->user);
lowercase(jp->from->server);
if ((reg = xdb_get(ti->xc,mt_xdb_id(jp->p,jp->from,jp->to->server),NS_REGISTER)) != NULL)
{
xmlnode p = xmlnode_new_tag("presence");
xmlnode_put_attrib(p,"to",jid_full(jp->from));
xmlnode_put_attrib(p,"from",jp->to->server);
xmlnode_put_attrib(p,"type","probe");
mt_deliver(ti,p);
jutil_error(jp->x,TERROR_NOTFOUND);
xmlnode_free(reg);
}
else
jutil_error(jp->x,TERROR_REGISTER);
mt_deliver(ti,jp->x);
}
示例3: jutil_msgnew
/**
* utility for making message stanzas
*
* @param type the type of the message (as a string!)
* @param to the recipient of the message
* @param subj the subject of the message (NULL for no subject element)
* @param body the body of the message
* @return the xmlnode containing the new message stanza
*/
xmlnode jutil_msgnew(char *type, char *to, char *subj, char *body)
{
xmlnode msg;
msg = xmlnode_new_tag("message");
if (type != NULL) {
xmlnode_put_attrib(msg, "type", type);
}
if (to != NULL) {
xmlnode_put_attrib(msg, "to", to);
}
if (subj != NULL) {
xmlnode_insert_cdata(xmlnode_insert_tag(msg, "subject"),
subj, strlen(subj));
}
if (body != NULL) {
xmlnode_insert_cdata(xmlnode_insert_tag(msg, "body"), body,
strlen(body));
}
return msg;
}
示例4: message_send_error
int message_send_error(struct stream_s *stream,const char *from,
const char *to,const char *body,int code,const char *str){
xmlnode msg;
xmlnode n;
char *s;
msg=xmlnode_new_tag("message");
if (from!=NULL)
xmlnode_put_attrib(msg,"from",from);
else{
char *jid;
jid=jid_my_registered();
xmlnode_put_attrib(msg,"from",jid);
g_free(jid);
}
xmlnode_put_attrib(msg,"to",to);
xmlnode_put_attrib(msg,"type","error");
s=g_strdup_printf("%03u",code);
xmlnode_put_attrib(msg,"code",s);
g_free(s);
n=xmlnode_insert_tag(msg,"error");
xmlnode_insert_cdata(n,str,-1);
if (body){
n=xmlnode_insert_tag(msg,"body");
xmlnode_insert_cdata(n,body,-1);
}
stream_write(stream,msg);
xmlnode_free(msg);
return 0;
}
示例5: presence_send_error
int presence_send_error(struct stream_s *stream,const char *from,const char *to,
int code,const char *string){
xmlnode pres;
xmlnode error;
char *jid;
char *str;
pres=xmlnode_new_tag("presence");
jid=jid_my_registered();
if (from!=NULL)
xmlnode_put_attrib(pres,"from",from);
else{
char *jid;
jid=jid_my_registered();
xmlnode_put_attrib(pres,"from",jid);
g_free(jid);
}
g_free(jid);
xmlnode_put_attrib(pres,"to",to);
xmlnode_put_attrib(pres,"type","error");
error=xmlnode_insert_tag(pres,"error");
if (code>0){
str=g_strdup_printf("%03u",(unsigned)code);
xmlnode_put_attrib(error,"code",str);
g_free(str);
}
xmlnode_insert_cdata(error,string,-1);
stream_write(stream,pres);
xmlnode_free(pres);
return 0;
}
示例6: mod_browse_reply
mreturn mod_browse_reply(mapi m, void *arg)
{
xmlnode browse, ns, cur;
session s;
if (m->packet->type != JPACKET_IQ)
return M_IGNORE;
if (!NSCHECK(m->packet->iq, NS_BROWSE))
return M_PASS;
/* first, is this a valid request? */
switch (jpacket_subtype(m->packet)) {
case JPACKET__RESULT:
case JPACKET__ERROR:
return M_PASS;
case JPACKET__SET:
js_bounce(m->si, m->packet->x, TERROR_NOTALLOWED);
return M_HANDLED;
}
log_debug("handling query for user %s", m->user->user);
/* get this dudes browse info */
browse = mod_browse_get(m, m->packet->to);
/* insert the namespaces */
ns = xdb_get(m->si->xc, m->packet->to, NS_XDBNSLIST);
for (cur = xmlnode_get_firstchild(ns); cur != NULL;
cur = xmlnode_get_nextsibling(cur))
if (xmlnode_get_attrib(cur, "type") == NULL)
xmlnode_insert_tag_node(browse, cur); /* only include the generic <ns>foo</ns> */
xmlnode_free(ns);
/* include any connected resources if there's a s10n from them */
if (js_trust(m->user, m->packet->from)) {
SEM_LOCK(m->user->sem);
for (s = m->user->sessions; s != NULL; s = s->next) {
/* if(s->priority < 0) continue; *** include all resources I guess */
if (xmlnode_get_tag
(browse,
spools(m->packet->p, "?jid=", jid_full(s->id),
m->packet->p)) != NULL)
continue; /* already in the browse result */
cur = xmlnode_insert_tag(browse, "user");
xmlnode_put_attrib(cur, "type", "client");
xmlnode_put_attrib(cur, "jid", jid_full(s->id));
}
SEM_UNLOCK(m->user->sem);
}
/* XXX include iq:filter forwards */
jutil_iqresult(m->packet->x);
jpacket_reset(m->packet);
xmlnode_insert_tag_node(m->packet->x, browse);
js_deliver(m->si, m->packet);
xmlnode_free(browse);
return M_HANDLED;
}
示例7: message_send_subject
int message_send_subject(struct stream_s *stream,const char *from,
const char *to,const char *subject,const char *message,time_t timestamp){
xmlnode msg;
xmlnode n;
struct tm *tm;
char buf[101];
msg=xmlnode_new_tag("message");
if (from!=NULL)
xmlnode_put_attrib(msg,"from",from);
else{
char *jid;
jid=jid_my_registered();
xmlnode_put_attrib(msg,"from",jid);
g_free(jid);
}
xmlnode_put_attrib(msg,"to",to);
n=xmlnode_insert_tag(msg,"subject");
xmlnode_insert_cdata(n,subject,-1);
n=xmlnode_insert_tag(msg,"body");
xmlnode_insert_cdata(n,message,-1);
if (timestamp){
n=xmlnode_insert_tag(msg,"x");
xmlnode_put_attrib(n,"xmlns","jabber:x:delay");
tm=gmtime(×tamp);
strftime(buf,100,"%Y%m%dT%H:%M:%S",tm);
xmlnode_put_attrib(n,"stamp",buf);
xmlnode_insert_cdata(n,"Delayed message",-1);
}
stream_write(stream,msg);
xmlnode_free(msg);
return 0;
}
示例8: at_iq_vcard
int at_iq_vcard(ati ti, jpacket jp)
{
xmlnode data;
at_session s;
s = at_session_find_by_jid(ti, jp->from);
if(jpacket_subtype(jp) != JPACKET__GET ||
(s && ((!s->icq && jp->to->user) || (s->icq && s->icq_vcard_response))))
{
at_bounce(ti, jp, TERROR_BAD);
return 1;
}
if(!jp->to->user)
{
xmlnode_insert_node(jutil_iqresult(jp->x),ti->vcard);
at_deliver(ti,jp->x);
return 1;
}
if(!s)
return 0;
jutil_iqresult(jp->x);
jp->iq = data = xmlnode_insert_tag(jp->x,"vCard");
xmlnode_put_attrib(data,"xmlns",NS_VCARD);
xmlnode_put_attrib(data,"version","3.0");
xmlnode_put_attrib(data,"prodid","-//HandGen//NONSGML vGen v1.0//EN");
s->icq_vcard_response = jp;
aim_icq_getsimpleinfo(s->ass,
jp->to->user);
return 1;
}
示例9: base_to_deliver
result base_to_deliver(instance id, dpacket p, void *arg)
{
char *log_data = xmlnode_get_data(p->x);
char *subject;
xmlnode message;
if (log_data == NULL)
return r_ERR;
message = xmlnode_new_tag("message");
xmlnode_insert_cdata(xmlnode_insert_tag(message, "body"), log_data,
-1);
subject =
spools(xmlnode_pool(message), "Log Packet from ",
xmlnode_get_attrib(p->x, "from"),
xmlnode_pool(message));
xmlnode_insert_cdata(xmlnode_insert_tag(message, "thread"),
shahash(subject), -1);
xmlnode_insert_cdata(xmlnode_insert_tag(message, "subject"),
subject, -1);
xmlnode_put_attrib(message, "from",
xmlnode_get_attrib(p->x, "from"));
xmlnode_put_attrib(message, "to", (char *) arg);
deliver(dpacket_new(message), id);
pool_free(p->p);
return r_DONE;
}
示例10: jutil_tofrom
void jutil_tofrom(xmlnode x)
{
char *to, *from;
to = xmlnode_get_attrib(x,"to");
from = xmlnode_get_attrib(x,"from");
xmlnode_put_attrib(x,"from",to);
xmlnode_put_attrib(x,"to",from);
}
示例11: mod_roster_auto_in_s10n
mreturn mod_roster_auto_in_s10n(mapi m, void *arg)
{
xmlnode reply, x;
log_debug("AUTO ROSTER");
//in not s10n
if (m->packet->type != JPACKET_S10N)
return M_IGNORE;
//if no to
if (m->packet->to == NULL)
return M_PASS;
//if from me
if (jid_cmpx(m->s->uid, m->packet->from, JID_USER | JID_SERVER) ==
0)
return M_PASS;
log_debug("handling incoming s10n");
switch (jpacket_subtype(m->packet)) {
case JPACKET__SUBSCRIBE:
log_debug("SUBSCRIBE");
reply =
jutil_presnew(JPACKET__SUBSCRIBED,
jid_full(m->packet->from), NULL);
js_session_from(m->s, jpacket_new(reply));
reply =
jutil_presnew(JPACKET__SUBSCRIBE,
jid_full(m->packet->from), NULL);
js_session_from(m->s, jpacket_new(reply));
break;
case JPACKET__SUBSCRIBED:
break;
case JPACKET__UNSUBSCRIBE:
log_debug("UNSUBSCRIBE");
//reply = jutil_presnew(JPACKET__UNSUBSCRIBED, jid_full(m->packet->from),NULL);
//js_session_from(m->s, jpacket_new(reply));
//remove account.
reply = jutil_iqnew(JPACKET__SET, NS_ROSTER);
x = xmlnode_get_tag(reply, "query");
x = xmlnode_insert_tag(x, "item");
xmlnode_put_attrib(x, "jid",
jid_full(jid_user(m->packet->from)));
xmlnode_put_attrib(x, "subscription", "remove");
js_session_from(m->s, jpacket_new(reply));
// reply = jutil_iqnewpresnew(JPACKET__UNSUBSCRIBE, jid_full(m->packet->from),NULL);
// js_session_from(m->s, jpacket_new(reply));
break;
case JPACKET__UNSUBSCRIBED:
break;
}
xmlnode_free(m->packet->x);
return M_HANDLED;
}
示例12: _js_session_from
/* child that handles packets from the user */
void _js_session_from(void *arg)
{
jpacket p = (jpacket) arg;
session s = (session) (p->aux1);
/* if this session is dead */
if (s->exit_flag) {
/* send the packet into oblivion */
xmlnode_free(p->x);
return;
}
/* at least we must have a valid packet */
if (p->type == JPACKET_UNKNOWN) {
/* send an error back */
jutil_error(p->x, TERROR_BAD);
jpacket_reset(p);
js_session_to(s, p);
return;
}
/* debug message */
log_debug("THREAD:SESSION:FROM received a packet!");
/* increment packet out count */
s->si->stats->packets_out++;
s->c_out++;
/* make sure we have our from set correctly for outgoing packets */
if (jid_cmpx(p->from, s->id, JID_USER | JID_SERVER) != 0) {
/* nope, fix it */
xmlnode_put_attrib(p->x, "from", jid_full(s->id));
p->from = jid_new(p->p, jid_full(s->id));
}
/* if you use to="[email protected]" it's the same as not having a to, the modules use the NULL as a self-flag */
if (jid_cmp(p->to, s->uid) == 0) {
/* xmlnode_hide_attrib(p->x,"to"); */
p->to = NULL;
}
/* let the modules have their heyday */
if (js_mapi_call(NULL, es_OUT, p, s->u, s))
return;
/* no module handled it, so restore the to attrib to us */
if (p->to == NULL) {
xmlnode_put_attrib(p->x, "to", jid_full(s->uid));
p->to = jid_new(p->p, jid_full(s->uid));
}
js_post_out_main(s, p);
/* pass these to the general delivery function */
// js_deliver(s->si, p);
}
示例13: form_new_result
/*
* creates a new jabber:x:data result form
* returns the node created added
*/
xmlnode form_new_result(const char *title){
xmlnode form,tag;
form=xmlnode_new_tag("x");
xmlnode_put_attrib(form,"xmlns","jabber:x:data");
xmlnode_put_attrib(form,"type","result");
tag=xmlnode_insert_tag(form,"title");
xmlnode_insert_cdata(tag,title,-1);
return form;
}
示例14: jutil_delay
void jutil_delay(xmlnode msg, char *reason)
{
xmlnode delay;
delay = xmlnode_insert_tag(msg,"x");
xmlnode_put_attrib(delay,"xmlns",NS_DELAY);
xmlnode_put_attrib(delay,"from",xmlnode_get_attrib(msg,"to"));
xmlnode_put_attrib(delay,"stamp",jutil_timestamp());
if(reason != NULL)
xmlnode_insert_cdata(delay,reason,strlen(reason));
}
示例15: mt_ns_msg
void mt_ns_msg(mpacket mp, session s)
{
xmlnode msg, oob;
char *body, *ctype, *ptr;
/* message body spool*/
pool p = pool_new();
spool sp = spool_new(p);
if (s->ti->inbox_headlines == 0)
return;
ctype = strchr(mt_packet_data(mp,5),':') + 2;
body = mt_packet_data(mp,mp->count - 1);
/* this message is a Hotmail inbox notification */
if ((strncmp(ctype,"text/x-msmsgsinitialemailnotification",37) != 0) &&
(strncmp(ctype,"text/x-msmsgsemailnotification",30) != 0))
return;
/* Fede <[email protected]> */
/* cut off the junk at the end */
if ((ptr = strstr(body,"Inbox-URL")) != NULL) {
*ptr = '\0';
spool_add(sp,body);
} else {
if ((ptr = strstr(body,"From:")) != NULL) {
char *p = strchr(ptr, '\r');
*p = '\0';
spooler(sp,"Mail from: ", ptr + 6,sp);
body = p + 1;
}
if ((ptr = strstr(body,"From-Addr:")) != NULL) {
*strchr(ptr, '\r') = '\0';
spooler(sp," <",ptr + 11,">",sp);
}
}
msg = xmlnode_new_tag("message");
xmlnode_put_attrib(msg,"to",jid_full(s->id));
xmlnode_put_attrib(msg,"from",s->host);
xmlnode_put_attrib(msg,"type","headline");
xmlnode_insert_cdata(xmlnode_insert_tag(msg,"subject"),"Hotmail",-1);
xmlnode_insert_cdata(xmlnode_insert_tag(msg,"body"),spool_print(sp),-1);
oob = xmlnode_insert_tag(msg,"x");
xmlnode_put_attrib(oob,"xmlns","jabber:x:oob");
xmlnode_insert_cdata(xmlnode_insert_tag(oob,"url"),"http://www.hotmail.com/cgi-bin/folders",-1);
xmlnode_insert_cdata(xmlnode_insert_tag(oob,"desc"),"Login to your Hotmail e-mail account",-1);
mt_deliver(s->ti,msg);
pool_free(p);
}