summaryrefslogtreecommitdiff
path: root/src/persistence_client_library_tree_helper.h
blob: 60ae99f95970150894b84b23cc292591616386dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#ifndef PERSISTENCE_CLIENT_LIBRARY_TREE_HELPER_H
#define PERSISTENCE_CLIENT_LIBRARY_TREE_HELPER_H

/******************************************************************************
 * Project         Persistency
 * (c) copyright   2015
 * Company         XS Embedded GmbH
 *****************************************************************************/
/******************************************************************************
 * This Source Code Form is subject to the terms of the
 * Mozilla Public License, v. 2.0. If a  copy of the MPL was not distributed
 * with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
******************************************************************************/
 /**
 * @file           persistence_client_library_tree_helper.h
 * @ingroup        Persistence client library
 * @author         Ingo Huerner
 * @brief          Header of persistence client library tree helper functions
 * @see
 */


#include<stdio.h>
#include<stdlib.h>

#include "persistence_client_library_handle.h"
#include "rbtree.h"


/// tree to store key handle information
extern jsw_rbtree_t *gKeyHandleTree;

/// tree to store file handle information
extern jsw_rbtree_t *gFileHandleTree;

/// tree to store OSS file handle information
extern jsw_rbtree_t *gOssFileHandleTree;


/// key handle data union definition
typedef union KeyHandleData_u_
{
   /// key handle data definition
   PersistenceKeyHandle_s keyHandle;

   /// key handle data payload
   char payload[sizeof(struct _PersistenceKeyHandle_s)];

} KeyHandleData_u;

/// type definition of a key tree item
typedef struct _KeyHandleTreeItem_s
{
   /// key handle key
   int key;

   /// key handle data
   KeyHandleData_u value;

} KeyHandleTreeItem_s;



/// file handle data union definition
typedef union FileHandleData_u_
{
   /// file handle data definition
   PersistenceFileHandle_s fileHandle;

   /// file handle data payload
   char payload[sizeof(struct _PersistenceFileHandle_s)];

} FileHandleData_u;

/// type definition of a file tree item
typedef struct _FileHandleTreeItem_s
{
   /// file handle key
   int key;

   /// file handle data
   FileHandleData_u value;

} FileHandleTreeItem_s;



/**
 * @brief Compare function for file handle tree item
 *
 * @param p1 pointer to the first item to compare
 * @param p2 pointer to the second item to compare
 *
 * @return 0 if key is equal; -1 if p1 < p2; 1 if p1 > p2
 */
int fh_key_val_cmp(const void *p1, const void *p2 );


/**
 * @brief Duplicate function for file handle tree item
 *
 * @param p the pointer of the item to duplicate
 *
 * @return pointer to the duplicated item, on failure NULL
 */
void* fh_key_val_dup(void *p);

/**
 * @brief Release function for file handle tree item
 *
 * @param p pointer tp the item to release
 */
void  fh_key_val_rel(void *p );



/**
 * @brief Compare function for key handle tree item
 *
 * @param p1 pointer to the first item to compare
 * @param p2 pointer to the second item to compare
 *
 * @return 0 if key is equal; -1 if p1 < p2; 1 if p1 > p2
 */
int kh_key_val_cmp(const void *p1, const void *p2 );

/**
 * @brief Duplicate function for key handle tree item
 *
 * @param p the pointer of the item to duplicate
 *
 * @return pointer to the duplicated item, on failure NULL
 */
void* kh_key_val_dup(void *p);

/**
 * @brief Release function for key handle tree item
 *
 * @param p pointer tp the item to release
 */
void  kh_key_val_rel(void *p );



#endif /* PERSISTENCE_CLIENT_LIBRARY_TREE_HELPER_H */