Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F32058466
tree.h
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
tree.h
View Options
#ifndef _TREE_H
# define _TREE_H
#include
<sys/types.h>
#include
<string.h>
#include
<strings.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
<unistd.h>
#include
<limits.h>
#define E_FN_DEL(_fn, _h) if (_h) { _fn(_h); _h = NULL; }
#define E_REALLOC(p, s, n) p = (s *)realloc(p, sizeof(s) * n)
#define E_NEW(s, n) (s *)calloc(n, sizeof(s))
#define E_NEW_BIG(s, n) (s *)malloc(n * sizeof(s))
#define E_FREE(p) { if (p) {free(p); p = NULL;} }
enum
_Tree_Element_Type
{
TREE_ELEMENT_TYPE_NULL
=
0
,
TREE_ELEMENT_TYPE_STRING
=
1
,
TREE_ELEMENT_TYPE_TREE
=
2
,
};
typedef
enum
_Tree_Element_Type
Tree_Element_Type
;
struct
_Tree_Element
{
void
*
element
;
/* A pointer to the element. */
Tree_Element_Type
type
;
/* The type of the element. */
};
typedef
struct
_Tree_Element
Tree_Element
;
typedef
struct
_Tree
Tree
;
struct
_Tree
{
Tree_Element
*
elements
;
/* An array of elements. */
int
size
;
/* The size of the array. */
char
**
buffers
;
/* An array of pointers to the bits of data. */
int
buffers_size
;
/* The size of the array. */
Tree
*
parent
;
/* Parent if this is a child. */
};
# ifdef __cplusplus
extern
"C"
{
# endif
Tree
*
tree_new
(
char
*
buffer
);
Tree
*
tree_add
(
Tree
*
tree
,
const
char
*
element
);
void
tree_track
(
Tree
*
tree
,
void
*
element
);
Tree
*
tree_extend
(
Tree
*
tree
,
const
char
*
element
);
Tree
*
tree_insert
(
Tree
*
tree
,
int
before
,
void
*
element
,
Tree_Element_Type
type
);
Tree
*
tree_merge
(
Tree
*
tree
,
int
before
,
Tree
*
element
);
Tree
*
tree_add_child
(
Tree
*
tree
,
Tree
*
element
);
void
tree_remove
(
Tree
*
tree
,
int
element
);
int
tree_exist
(
Tree
*
tree
,
char
*
element
);
int
tree_foreach
(
Tree
*
tree
,
int
level
,
int
(
*
func
)
(
const
void
*
data
,
Tree
*
tree
,
int
element
,
int
level
),
const
void
*
data
);
void
tree_dump
(
Tree
*
tree
,
int
level
);
void
tree_del
(
Tree
*
tree
);
Tree
*
xmlame_new
(
char
*
buffer
);
Tree
*
xmlame_get
(
char
*
file
);
Tree
*
xmlame_from_string
(
char
*
data
);
# ifdef __cplusplus
}
# endif
#endif
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Mon, Jun 8, 07:57 (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3718487
Default Alt Text
tree.h (1 KB)
Attached To
Mode
rDARKBOT Darkbot
Attached
Detach File
Event Timeline
Log In to Comment