]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/tree.h
Restructure tree.c + misc
[bacula/bacula] / bacula / src / lib / tree.h
index e398e546cd361a417bca94dca576430e69545380..dd81675648993ea7f0c5de956e235038ae882cfb 100644 (file)
@@ -31,6 +31,16 @@ struct s_mem {
    char first[1];                     /* first byte */
 };
 
+#define foreach_child(cld, node) \
+        for(cld=(node)->child_; cld; cld=cld->sibling_)
+
+#define tree_node_has_child(node) \
+        ((node)->child_ != NULL)
+
+#define first_child(node) \
+        ((node)->child_)
+
+
 /*
  * Keep this node as small as possible because
  *   there is one for each file.
@@ -45,10 +55,11 @@ struct s_tree_node {
    unsigned int extract_dir: 1;       /* extract dir entry only */
    unsigned int hard_link: 1;         /* set if have hard link */
    unsigned int soft_link: 1;         /* set if is soft link */  
+   unsigned int inserted: 1;          /* set when newly inserted */
    struct s_tree_node *parent;
-   struct s_tree_node *sibling;
-   struct s_tree_node *child;
+   struct s_tree_node *sibling_;
    struct s_tree_node *next;          /* next hash of FileIndex */
+   struct s_tree_node *child_;
 };
 typedef struct s_tree_node TREE_NODE;
 
@@ -61,10 +72,11 @@ struct s_tree_root {
    unsigned int extract: 1;           /* extract item */
    unsigned int extract_dir: 1;       /* extract dir entry only */
    unsigned int have_link: 1;         /* set if have hard link */
+   unsigned int inserted: 1;          /* set when newly inserted */
    struct s_tree_node *parent;
-   struct s_tree_node *sibling;
-   struct s_tree_node *child;
+   struct s_tree_node *sibling_;
    struct s_tree_node *next;          /* next hash of FileIndex */
+   struct s_tree_node *child_;
 
    /* The above ^^^ must be identical to a TREE_NODE structure */
    struct s_tree_node *first;         /* first entry in the tree */
@@ -85,15 +97,13 @@ typedef struct s_tree_root TREE_ROOT;
 #define TN_DIR_NLS 4                  /* directory -- no leading slash -- win32 */
 #define TN_FILE    5                  /* file entry */
 
+/* External interface */
 TREE_ROOT *new_tree(int count);
-TREE_NODE *new_tree_node(TREE_ROOT *root, int type);
-TREE_NODE *insert_tree_node(char *fname, TREE_NODE *node, 
+TREE_NODE *insert_tree_node(char *path, char *fname, TREE_NODE *node, 
                             TREE_ROOT *root, TREE_NODE *parent);
 TREE_NODE *make_tree_path(char *path, TREE_ROOT *root);
 TREE_NODE *tree_cwd(char *path, TREE_ROOT *root, TREE_NODE *node);
 TREE_NODE *tree_relcwd(char *path, TREE_ROOT *root, TREE_NODE *node);
-void append_tree_node(char *path, TREE_NODE *node, TREE_ROOT *root, TREE_NODE *parent);
-void print_tree(char *path, TREE_NODE *root);    
 void free_tree(TREE_ROOT *root);
 int tree_getpath(TREE_NODE *node, char *buf, int buf_size);