?? handle-queued-nag-messages.c
字號:
#include <string.h>#include <glib.h>#include "bionet.h"#include "libbionet-internal.h"void bionet_handle_queued_nag_messages(void) { do { xmlDoc *xml; xmlNode *root; xml = g_slist_nth_data(libbionet_queued_messages_from_nag, 0); if (xml == NULL) return; libbionet_queued_messages_from_nag = g_slist_remove(libbionet_queued_messages_from_nag, xml); root = xmlDocGetRootElement(xml); if (strcmp(root->name, "node") == 0) { bionet_node_t *node; if (libbionet_callback_new_node == NULL) { g_log(BIONET_LOG_DOMAIN, G_LOG_LEVEL_INFO, "dropping <node> request from NAG: no callback registered"); xmlFreeDoc(xml); continue; } node = libbionet_parse_node_from_xml(root); xmlFreeDoc(xml); if (node != NULL) { libbionet_callback_new_node(node); } } else if (strcmp(root->name, "lost-node") == 0) { char *hab_type, *hab_id, *node_id; if (libbionet_callback_lost_node == NULL) { g_log(BIONET_LOG_DOMAIN, G_LOG_LEVEL_INFO, "dropping <lost-node> request from NAG: no callback registered"); xmlFreeDoc(xml); continue; } hab_type = xmlGetProp(root, "hab-type"); if (hab_type == NULL) { g_log(BIONET_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "got <lost-node> with no hab-type"); xmlFreeDoc(xml); return; } hab_id = xmlGetProp(root, "hab-id"); if (hab_id == NULL) { g_log(BIONET_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "got <lost-node> with no hab-id"); xmlFree(hab_type); xmlFreeDoc(xml); return; } node_id = xmlGetProp(root, "node-id"); if (node_id == NULL) { g_log(BIONET_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "got <lost-node> with no node-id"); xmlFree(hab_type); xmlFree(hab_id); xmlFreeDoc(xml); return; } libbionet_callback_lost_node(hab_type, hab_id, node_id); xmlFree(hab_type); xmlFree(hab_id); xmlFree(node_id); xmlFreeDoc(xml); } else if (strcmp(root->name, "resource") == 0) { bionet_resource_t *resource; if (libbionet_callback_resource_value == NULL) { g_log(BIONET_LOG_DOMAIN, G_LOG_LEVEL_INFO, "dropping <resource> request from NAG: no callback registered"); xmlFreeDoc(xml); continue; } resource = libbionet_parse_resource(root); xmlFreeDoc(xml); if (resource == NULL) { return; } libbionet_callback_resource_value(resource); } else { g_log(BIONET_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "unhandled message from NAG: %s", root->name); xmlFreeDoc(xml); } } while (1);}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -