7a34fa49ce300029c7d5a82d850c8634f0142b1c
[platform/upstream/glib2.0.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, 2010 Oracle and/or its affiliates, Inc. All rights
5  * reserved.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General
18  * Public License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20  * Boston, MA 02111-1307, USA.
21  *
22  * Authors: Lin Ma <lin.ma@sun.com>
23  */
24
25 #include "config.h"
26 #include <glib.h>
27 #include <glib/gprintf.h>
28 #include "fen-node.h"
29 #include "fen-dump.h"
30
31 G_LOCK_EXTERN (fen_lock);
32
33 /*-------------------- node ------------------*/
34 static void
35 dump_node (node_t* node, gpointer data)
36 {
37     g_printf ("n:0x%p ds:0x%p s:0x%p %s\n", node, node->dir_subs, node->subs, NODE_NAME(node));
38 }
39
40 static void
41 dump_tree (node_t* node)
42 {
43     if (G_TRYLOCK (fen_lock)) {
44         node_traverse(NULL, dump_node, NULL);
45         G_UNLOCK (fen_lock);
46     }
47 }
48
49 /* ------------------ fdata port hash --------------------*/
50 void
51 dump_hash_cb (gpointer key,
52   gpointer value,
53   gpointer user_data)
54 {
55     g_printf ("k:0x%p v:0x%p >\n", key, value);
56 }
57
58 gboolean
59 dump_hash (GHashTable* hash, gpointer user_data)
60 {
61     if (G_TRYLOCK (fen_lock)) {
62         if (g_hash_table_size (hash) > 0) {
63             g_hash_table_foreach (hash, dump_hash_cb, user_data);
64         }
65         G_UNLOCK (fen_lock);
66     }
67     return TRUE;
68 }
69
70 /* ------------------ event --------------------*/
71 void
72 dump_event (node_event_t* ev, gpointer user_data)
73 {
74     node_t* node = ev->user_data;
75     g_printf ("ne:0x%p e:%p n:0x%p ds:0x%p s:0x%p s\n", ev, ev->e, node, node->dir_subs, node->subs, NODE_NAME(node));
76 }