Home | History | Annotate | Download | only in fen
      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 Microsystems, Inc. All rights reserved.
      5  * Use is subject to license terms.
      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 (at) sun.com>
     23  */
     24 
     25 #ifndef _FEN_NODE_H_
     26 #define _FEN_NODE_H_
     27 
     28 typedef struct node node_t;
     29 
     30 struct node
     31 {
     32     gchar *filename;
     33     gchar *basename;
     34     gint stat;
     35 
     36 	/* the parent and children of node */
     37     node_t *parent;
     38     GHashTable *children; /* children in basename */
     39 
     40     gpointer user_data;
     41 };
     42 
     43 #define	IS_TOPNODE(fp)	(((node_t *)(fp))->parent == NULL)
     44 #define NODE_NAME(fp)	(((node_t *)(fp))->filename)
     45 
     46 typedef struct node_op
     47 {
     48     /* find */
     49     void (*hit) (node_t* node, gpointer user_data);
     50     node_t* (*add_missing) (node_t* parent, gpointer user_data);
     51     /* delete */
     52     gboolean (*pre_del) (node_t* node, gpointer user_data);
     53 	/* data */
     54     gpointer user_data;
     55 } node_op_t;
     56 
     57 node_t* add_node (node_t* parent, const gchar* filename);
     58 void remove_node (node_t* node, node_op_t* op);
     59 void pending_remove_node (node_t* node, node_op_t* op);
     60 
     61 void travel_nodes (node_t* node, node_op_t* op);
     62 node_t* find_node_full (const gchar* filename, node_op_t* op);
     63 node_t* find_node (const gchar *filename);
     64 
     65 node_t* children_find (node_t *f, const gchar *basename);
     66 guint children_num (node_t *f);
     67 
     68 gpointer node_get_data (node_t* node);
     69 gpointer node_set_data (node_t* node, gpointer user_data);
     70 
     71 gboolean node_class_init ();
     72 
     73 #endif /* _FEN_NODE_H_ */
     74