Added. Added. Added. Added. Added. Added. Added. Added. Added. Added.
[platform/upstream/glib.git] / gio / fen / fen-dump.c
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* vim:set expandtab ts=4 shiftwidth=4: */
3 /* 
4  * Copyright (C) 2008 Sun Microsystem.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General
17  * Public License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *
21  * Authors: Lin Ma <lin.ma@sun.com>
22  */
23
24 #include "config.h"
25 #include <glib.h>
26 #include <glib/gprintf.h>
27 #include "fen-node.h"
28 #include "fen-data.h"
29 #include "fen-kernel.h"
30 #include "fen-missing.h"
31 #include "fen-dump.h"
32
33 G_LOCK_EXTERN (fen_lock);
34
35 /*-------------------- node ------------------*/
36 static void
37 dump_node (node_t* node, gpointer data)
38 {
39     if (data && node->user_data) {
40         return;
41     }
42     g_printf ("[%s] < 0x%p : 0x%p > %s\n", __func__, node, node->user_data, NODE_NAME(node));
43 }
44
45 static gboolean
46 dump_node_tree (node_t* node, gpointer user_data)
47 {
48     node_op_t op = {dump_node, NULL, NULL, user_data};
49     GList* children;
50     GList* i;
51     if (G_TRYLOCK (fen_lock)) {
52         if (node) {
53             travel_nodes (node, &op);
54         }
55         G_UNLOCK (fen_lock);
56     }
57     return TRUE;
58 }
59
60 /* ------------------ fdata port hash --------------------*/
61 void
62 dump_hash_cb (gpointer key,
63   gpointer value,
64   gpointer user_data)
65 {
66     g_printf ("[%s] < 0x%p : 0x%p >\n", __func__, key, value);
67 }
68
69 gboolean
70 dump_hash (GHashTable* hash, gpointer user_data)
71 {
72     if (G_TRYLOCK (fen_lock)) {
73         if (g_hash_table_size (hash) > 0) {
74             g_hash_table_foreach (hash, dump_hash_cb, user_data);
75         }
76         G_UNLOCK (fen_lock);
77     }
78     return TRUE;
79 }
80
81 /* ------------------ event --------------------*/
82 void
83 dump_event (fnode_event_t* ev, gpointer user_data)
84 {
85     fdata* data = ev->user_data;
86     g_printf ("[%s] < 0x%p : 0x%p > [ %10s ] %s\n", __func__, ev, ev->user_data, _event_string (ev->e), FN_NAME(data));
87 }
88
89 void
90 dump_event_queue (fdata* data, gpointer user_data)
91 {
92     if (G_TRYLOCK (fen_lock)) {
93         if (data->eventq) {
94             g_queue_foreach (data->eventq, (GFunc)dump_event, user_data);
95         }
96         G_UNLOCK (fen_lock);
97     }
98 }
99