TcorePlugin *p;
struct tcore_plugin_define_desc *desc;
- if (!path || !s)
+ if ((path == NULL) || (s == NULL))
return FALSE;
dir = g_dir_open(path, 0, NULL);
- if (!dir)
+ if (dir == NULL)
return FALSE;
while ((file = g_dir_read_name(dir)) != NULL) {
}
desc = dlsym(handle, "plugin_define_desc");
- if (!desc) {
+ if (desc == NULL) {
dbg("fail to load symbol: %s", dlerror());
dlclose(handle);
g_free(filename);
list = tcore_server_ref_plugins(s);
for (; list; list = list->next) {
p = list->data;
- if (!p)
+ if (p == NULL)
continue;
desc = (struct tcore_plugin_define_desc *)tcore_plugin_get_description(p);
- if (!desc)
+ if (desc == NULL)
continue;
- if (!desc->init)
+ if (desc->init == NULL)
continue;
- if (!desc->init(p)) {
+ if (desc->init(p) == FALSE) {
dbg("plugin(%s) init failed.", tcore_plugin_get_filename(p));
}
}
static void on_signal_usr1(int signo)
{
- if (!_server)
+ if (_server == NULL)
return;
monitor_server_state(_server);
while (1) {
opt = getopt_long(argc, argv, "hT", options, &opt_index);
- if (-1 == opt)
+ if (opt == -1)
break;
switch (opt) {
#endif
s = tcore_server_new();
- if (!s) {
+ if (s == NULL) {
err("server_new failed.");
goto end;
}
_server = s;
- if (!load_plugins(s, plugin_path, flag_test_load))
+ if (load_plugins(s, plugin_path, flag_test_load) == FALSE)
goto free_end;
if (flag_test_load)
#include "monitor.h"
-/* hacking TcoreQueue */
+/* Hacking TcoreQueue */
struct tcore_queue_type {
TcorePlugin *plugin;
GQueue *gq;
msg("-- Plugins --");
list = tcore_server_ref_plugins(s);
- if (!list)
+ if (list == NULL)
return;
do {
msg("-- Storages --");
list = tcore_server_ref_storages(s);
- if (!list)
+ if (list == NULL)
return;
do {
GSList *list;
Communicator *comm;
- msg("-- Coomunicators --");
+ msg("-- Communicators --");
list = tcore_server_ref_communicators(s);
- if (!list)
+ if (list == NULL)
return;
do {
} while(list);
}
-static void _monitor_hal(Server *s)
+static void _monitor_modems(Server *s)
{
GSList *list;
- TcoreHal *h;
- TcoreQueue *q;
- TcorePending *pending;
- UserRequest *ur;
- char *str;
- int qlen;
- int i;
- void *data;
- unsigned int data_len;
+ TcorePlugin *p;
- msg("-- Hals --");
+ msg("-- Modems --");
- list = tcore_server_ref_hals(s);
- if (!list)
+ list = tcore_server_ref_plugins(s);
+ if (list == NULL)
return;
do {
- h = list->data;
-
- str = tcore_hal_get_name(h);
- msg("Name: [%s]", str);
- msg(" - addr: %p", h);
- msg(" - parent_plugin: %p", tcore_hal_ref_plugin(h));
- msg(" - userdata: %p", tcore_hal_ref_user_data(h));
-
- q = tcore_hal_ref_queue(h);
- if (!q) {
- msg("");
- list = list->next;
- continue;
- }
-
- if (!(q->gq)) {
- msg("");
- list = list->next;
+ p = list->data;
+ if (p == NULL)
continue;
- }
-
- qlen = tcore_queue_get_length(q);
- msg(" - queue: %p, length: %d", q, qlen);
- msg(" queue_head: %p", g_queue_peek_head(q->gq));
- for (i = 0; i < qlen; i++) {
- pending = g_queue_peek_nth(q->gq, i);
- ur = tcore_pending_ref_user_request(pending);
- msg(" [%02d] pending=%p, id=0x%x, ur=%p", i, pending, tcore_pending_get_id(pending), ur);
- if (ur) {
- msg(" ur request command = 0x%x", tcore_user_request_get_command(ur));
- }
- data_len = 0;
- data = tcore_pending_ref_request_data(pending, &data_len);
- msg(" data=%p, data_len=%d", data, data_len);
- }
- msg(" queue_tail: %p", g_queue_peek_tail(q->gq));
- msg("");
- list = list->next;
+ tcore_server_print_modems(p);
} while(list);
}
_monitor_plugin(s);
_monitor_storage(s);
_monitor_communicator(s);
- _monitor_hal(s);
+ _monitor_modems(s);
}