⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 handle-queued-nag-messages.c

📁 MANTIS是由科罗拉多大学开发的传感器网络嵌入式操作系统。 这是mantis的0.9.5版本的源码。
💻 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 + -