本文整理汇总了C++中xmlnode_get_data函数的典型用法代码示例。如果您正苦于以下问题:C++ xmlnode_get_data函数的具体用法?C++ xmlnode_get_data怎么用?C++ xmlnode_get_data使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xmlnode_get_data函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: base_to_config
result base_to_config(instance id, xmlnode x, void *arg)
{
if (id == NULL) {
jid j = jid_new(xmlnode_pool(x), xmlnode_get_data(x));
log_debug("base_to_config validating configuration\n");
if (j == NULL) {
xmlnode_put_attrib(x, "error",
"'to' tag must contain a jid to send log data to");
log_debug("Invalid Configuration for base_to");
return r_ERR;
}
return r_PASS;
}
log_debug("base_to configuring instance %s", id->id);
if (id->type != p_LOG) {
log_alert(NULL,
"ERROR in instance %s: <to>..</to> element only allowed in log sections",
id->id);
return r_ERR;
}
register_phandler(id, o_DELIVER, base_to_deliver,
(void *) xmlnode_get_data(x));
return r_DONE;
}
示例2: mod_presence
/**
* init the module, register callbacks
*
* builds a list of JabberIDs where presences should be blind carbon copied to.
* (Enclosing each in a <bcc/> element, which are contained in one <presence/>
* element in the session manager configuration.)
*
* registers mod_presence_session() as a callback, that gets notified on new sessions
* and mod_presence_deliver() as a callback to deliver presence stanzas locally.
*
* @param si the session manager instance
*/
JSM_FUNC void mod_presence(jsmi si)
{
xmlnode cfg = js_config(si, "presence");
modpres_conf conf =
(modpres_conf) pmalloco(si->p, sizeof(_modpres_conf));
log_debug("init");
for (cfg = xmlnode_get_firstchild(cfg); cfg != NULL;
cfg = xmlnode_get_nextsibling(cfg)) {
char *element_name = NULL;
if (xmlnode_get_type(cfg) != NTYPE_TAG)
continue;
element_name = xmlnode_get_name(cfg);
if (j_strcmp(element_name, "bcc") == 0) {
if (conf->bcc == NULL)
conf->bcc =
jid_new(si->p, xmlnode_get_data(cfg));
else
jid_append(conf->bcc,
jid_new(si->p,
xmlnode_get_data(cfg)));
} else if (j_strcmp(element_name, "presence2xdb") == 0) {
conf->pres_to_xdb++;
}
}
js_mapi_register(si, e_DELIVER, mod_presence_deliver, NULL);
js_mapi_register(si, e_SESSION, mod_presence_session,
(void *) conf);
}
示例3: jabber_vcard_parse_avatar
static void
jabber_vcard_parse_avatar(JabberStream *js, const char *from,
JabberIqType type, const char *id,
xmlnode *packet, gpointer blah)
{
JabberBuddy *jb = NULL;
xmlnode *vcard, *photo, *binval, *fn, *nick;
char *text;
if(!from)
return;
jb = jabber_buddy_find(js, from, TRUE);
js->pending_avatar_requests = g_slist_remove(js->pending_avatar_requests, jb);
if((vcard = xmlnode_get_child(packet, "vCard")) ||
(vcard = xmlnode_get_child_with_namespace(packet, "query", "vcard-temp"))) {
/* The logic here regarding the nickname and full name is copied from
* buddy.c:jabber_vcard_parse. */
gchar *nickname = NULL;
if ((fn = xmlnode_get_child(vcard, "FN")))
nickname = xmlnode_get_data(fn);
if ((nick = xmlnode_get_child(vcard, "NICKNAME"))) {
char *tmp = xmlnode_get_data(nick);
char *bare_jid = jabber_get_bare_jid(from);
if (tmp && strstr(bare_jid, tmp) == NULL) {
g_free(nickname);
nickname = tmp;
} else if (tmp)
g_free(tmp);
g_free(bare_jid);
}
if (nickname) {
serv_got_alias(js->gc, from, nickname);
g_free(nickname);
}
if ((photo = xmlnode_get_child(vcard, "PHOTO")) &&
(binval = xmlnode_get_child(photo, "BINVAL")) &&
(text = xmlnode_get_data(binval))) {
guchar *data;
gsize size;
data = purple_base64_decode(text, &size);
if (data) {
gchar *hash = jabber_calculate_data_hash(data, size, "sha1");
purple_buddy_icons_set_for_user(js->gc->account, from, data,
size, hash);
g_free(hash);
}
g_free(text);
}
}
}
示例4: msn_soap_handle_body
static gboolean
msn_soap_handle_body(MsnSoapConnection *conn, MsnSoapMessage *response)
{
xmlnode *body = xmlnode_get_child(response->xml, "Body");
xmlnode *fault = xmlnode_get_child(response->xml, "Fault");
if (fault) {
xmlnode *faultcode = xmlnode_get_child(fault, "faultcode");
if (faultcode != NULL) {
char *faultdata = xmlnode_get_data(faultcode);
if (faultdata && g_str_equal(faultdata, "psf:Redirect")) {
xmlnode *url = xmlnode_get_child(fault, "redirectUrl");
if (url) {
char *urldata = xmlnode_get_data(url);
if (urldata)
msn_soap_handle_redirect(conn, urldata);
g_free(urldata);
}
g_free(faultdata);
msn_soap_message_destroy(response);
return TRUE;
} else if (faultdata && g_str_equal(faultdata, "wsse:FailedAuthentication")) {
xmlnode *reason = xmlnode_get_child(fault, "faultstring");
char *reasondata = NULL;
if (reason)
reasondata = xmlnode_get_data(reason);
msn_soap_connection_sanitize(conn, TRUE);
msn_session_set_error(conn->session, MSN_ERROR_AUTH,
reasondata);
g_free(reasondata);
g_free(faultdata);
msn_soap_message_destroy(response);
return FALSE;
}
g_free(faultdata);
}
}
if (fault || body) {
if (conn->current_request) {
MsnSoapRequest *request = conn->current_request;
conn->current_request = NULL;
request->cb(request->message, response,
request->cb_data);
msn_soap_request_destroy(request, FALSE);
}
msn_soap_message_destroy(response);
}
return TRUE;
}
示例5: nexus_parse_token
static gboolean
nexus_parse_token(MsnNexus *nexus, int id, xmlnode *node)
{
char *token_str, *expiry_str;
const char *id_str;
char **elems, **cur, **tokens;
xmlnode *token = xmlnode_get_child(node, "RequestedSecurityToken/BinarySecurityToken");
xmlnode *secret = xmlnode_get_child(node, "RequestedProofToken/BinarySecret");
xmlnode *expires = xmlnode_get_child(node, "LifeTime/Expires");
if (!token)
return FALSE;
/* Use the ID that the server sent us */
if (id == -1) {
id_str = xmlnode_get_attrib(token, "Id");
if (id_str == NULL)
return FALSE;
id = atol(id_str + 7) - 1; /* 'Compact#' or 'PPToken#' */
if (id >= nexus->token_len)
return FALSE; /* Where did this come from? */
}
token_str = xmlnode_get_data(token);
if (token_str == NULL)
return FALSE;
g_hash_table_remove_all(nexus->tokens[id].token);
elems = g_strsplit(token_str, "&", 0);
for (cur = elems; *cur != NULL; cur++) {
tokens = g_strsplit(*cur, "=", 2);
g_hash_table_insert(nexus->tokens[id].token, tokens[0], tokens[1]);
/* Don't free each of the tokens, only the array. */
g_free(tokens);
}
g_strfreev(elems);
g_free(token_str);
if (secret)
nexus->tokens[id].secret = xmlnode_get_data(secret);
else
nexus->tokens[id].secret = NULL;
/* Yay for MS using ISO-8601 */
expiry_str = xmlnode_get_data(expires);
nexus->tokens[id].expiry = purple_str_to_time(expiry_str,
FALSE, NULL, NULL, NULL);
g_free(expiry_str);
purple_debug_info("msn", "Updated ticket for domain '%s', expires at %" G_GINT64_FORMAT ".\n",
ticket_domains[id][SSO_VALID_TICKET_DOMAIN],
(gint64)nexus->tokens[id].expiry);
return TRUE;
}
示例6: main
int
main(){
xmlnode point;
xmlnode conf;
conf=xmlnode_file("./test.xml");
point=conf;
printf("\n");
printf("Tagname is %s.\n", xmlnode_get_name(point));
printf("Data is \"%s\"\n", xmlnode_get_data(point));
printf("Type is %d.\n", xmlnode_get_type(point));
point = xmlnode_get_firstchild(point);
printf("\n");
printf("Tagname is %s.\n", xmlnode_get_name(point));
printf("Data is \"%s\"\n", xmlnode_get_data(point));
printf("Type is %d.\n", xmlnode_get_type(point));
point = xmlnode_get_nextsibling(point);
printf("\n");
printf("Tagname is %s.\n", xmlnode_get_name(point));
printf("Data is %s.\n", xmlnode_get_data(point));
printf("Type is %d.\n", xmlnode_get_type(point));
point = xmlnode_get_nextsibling(point);
printf("\n");
printf("Tagname is %s.\n", xmlnode_get_name(point));
printf("Data is %s.\n", xmlnode_get_data(point));
printf("Type is %d.\n", xmlnode_get_type(point));
point = xmlnode_get_nextsibling(point);
printf("\n");
printf("Tagname is %s.\n", xmlnode_get_name(point));
printf("Data is %s.\n", xmlnode_get_data(point));
printf("Type is %d.\n", xmlnode_get_type(point));
point = xmlnode_get_nextsibling(point);
/*
point = xmlnode_get_nextsibling(point);
point = xmlnode_get_firstchild(point);
point = xmlnode_get_nextsibling(xmlnode_get_parent(point));
*/
xmlnode_free(conf);
} /* END MAIN */
示例7: 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);
}
示例8: jutil_priority
/* returns the priority on a presence packet */
int jutil_priority(xmlnode x)
{
char *str;
int p;
if(x == NULL)
return -1;
if(xmlnode_get_attrib(x,"type") != NULL)
return -1;
x = xmlnode_get_tag(x,"priority");
if(x == NULL)
return 0;
str = xmlnode_get_data((x));
if(str == NULL)
return 0;
p = atoi(str);
if(p >= 0)
return p;
else
return 0;
}
示例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: msn_oim_get_read_cb
/* Parse the XML data,
* prepare to report the OIM to user
*/
static void
msn_oim_get_read_cb(MsnSoapMessage *request, MsnSoapMessage *response,
gpointer data)
{
MsnOimRecvData *rdata = data;
if (response != NULL) {
xmlnode *msg_node = xmlnode_get_child(response->xml,
"Body/GetMessageResponse/GetMessageResult");
if (msg_node) {
char *msg_str = xmlnode_get_data(msg_node);
msn_oim_report_to_user(rdata, msg_str);
g_free(msg_str);
} else {
char *str = xmlnode_to_str(response->xml, NULL);
purple_debug_info("msn", "Unknown OIM response: %s\n", str);
g_free(str);
msn_oim_recv_data_free(rdata);
}
} else {
purple_debug_info("msn", "Failed to get OIM\n");
msn_oim_recv_data_free(rdata);
}
}
示例11: base_file_deliver
result base_file_deliver(instance id, dpacket p, void* arg)
{
char* message = NULL;
basefile bf = (basefile) arg;
char date[50],buf[200];
struct tm *today;
unsigned long ltime;
FILE * f;
time( <ime );
/* once per second */
if ((ltime > bf->last_time) || (bf->f == NULL)) {
/* try to route */
bf->last_time = ltime;
/* lock */
pthread_mutex_lock(&(bf->sem));
today = localtime( <ime );
/* if day changed or new raport */
if ((bf->yesterday.tm_mday != today->tm_mday) || (bf->f == NULL)) {
memcpy(&(bf->yesterday),today,sizeof(struct tm));
strftime((char *)date,128,"%Y_%m_%d",today);
sprintf(buf,"%s_%s.log",bf->filename,date);
f = bf->f;
bf->f = fopen(buf,"at");
if (f)
fclose(f);
}
/* unlock */
pthread_mutex_unlock(&(bf->sem));
}
if (bf->f == NULL)
{
log_debug(ZONE,"base_file_deliver error: no file available to print to.\n");
return r_ERR;
}
message = xmlnode_get_data(p->x);
if (message == NULL) {
log_debug(ZONE,"base_file_deliver error: no message available to print.\n");
return r_ERR;
}
if (fprintf(bf->f,"%s\n", message) == EOF) {
log_debug(ZONE,"base_file_deliver error: error writing to file(%d).\n", errno);
return r_ERR;
}
fflush(bf->f);
/* Release the packet */
pool_free(p->p);
return r_DONE;
}
示例12: xmlnode_cmp
/* loop through both a and b comparing everything, attribs, cdata, children, etc */
int xmlnode_cmp(xmlnode a, xmlnode b)
{
int ret = 0;
while(1)
{
if(a == NULL && b == NULL)
return 0;
if(a == NULL || b == NULL)
return -1;
if(xmlnode_get_type(a) != xmlnode_get_type(b))
return -1;
switch(xmlnode_get_type(a))
{
case NTYPE_ATTRIB:
ret = j_strcmp(xmlnode_get_name(a), xmlnode_get_name(b));
if(ret != 0)
return -1;
ret = j_strcmp(xmlnode_get_data(a), xmlnode_get_data(b));
if(ret != 0)
return -1;
break;
case NTYPE_TAG:
ret = j_strcmp(xmlnode_get_name(a), xmlnode_get_name(b));
if(ret != 0)
return -1;
ret = xmlnode_cmp(xmlnode_get_firstattrib(a), xmlnode_get_firstattrib(b));
if(ret != 0)
return -1;
ret = xmlnode_cmp(xmlnode_get_firstchild(a), xmlnode_get_firstchild(b));
if(ret != 0)
return -1;
break;
case NTYPE_CDATA:
ret = j_strcmp(xmlnode_get_data(a), xmlnode_get_data(b));
if(ret != 0)
return -1;
}
a = xmlnode_get_nextsibling(a);
b = xmlnode_get_nextsibling(b);
}
}
示例13: jabber_stream_error
void jabber_stream_error(Stream *s,xmlnode x){
char *data;
data=xmlnode_get_data(x);
if (data==NULL) data="-unknown-";
g_critical(L_("Stream error: %s"),data);
stream_close(s);
stop_it=1;
}
示例14: xmlnode_get_tag
/* return the cdata from any tag */
char *xmlnode_get_tag_data(xmlnode parent, const char *name)
{
xmlnode tag;
tag = xmlnode_get_tag(parent, name);
if(tag == NULL) return NULL;
return xmlnode_get_data(tag);
}
示例15: coincoin_message_new
CoinCoinMessage* coincoin_message_new(gint64 id, xmlnode* post)
{
CoinCoinMessage* msg;
xmlnode* message = xmlnode_get_child(post, "message");
xmlnode* info = xmlnode_get_child(post, "info");
xmlnode* login = xmlnode_get_child(post, "login");
gchar *data, *ptr;
static struct tm t;
time_t tt = time(NULL);
if(!message || !info || !login)
return NULL;
/* Parse time */
if (sscanf(xmlnode_get_attrib(post, "time"), "%4d%2d%2d%2d%2d%2d", &t.tm_year,&t.tm_mon,&t.tm_mday,&t.tm_hour,&t.tm_min,&t.tm_sec) == 6)
{
t.tm_year -= 1900;
t.tm_mon -= 1;
tt = mktime(&t);
}
/* Skip chars before message. */
ptr = data = xmlnode_get_data(message);
while(ptr && *ptr && (*ptr == '\t' || *ptr == '\n' || *ptr == '\r'))
++ptr;
msg = g_new0(CoinCoinMessage, 1);
if(!msg)
{
return NULL;
}
msg->message = g_strdup(ptr);
msg->info = xmlnode_get_data(info);
msg->from = xmlnode_get_data(login);
msg->timestamp = tt;
msg->id = id;
msg->ref = 1;
msg->multiple = FALSE;
g_free(data);
return msg;
}