kv_system.h
Go to the documentation of this file.
1 /******************************************************************************/
35 /******************************************************************************/
36 
37 #if !defined(KV_SYSTEM_H_)
38 #define KV_SYSTEM_H_
39 
40 #if defined(__cplusplus)
41 extern "C" {
42 #endif
43 
44 #include <stdio.h>
45 #include <stdlib.h>
46 #include <string.h>
47 #include <stdint.h>
48 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32)
49 #include <malloc.h>
50 #else /* Not windows, then use the proper header */
51 #include <alloca.h>
52 #endif
53 
54 /* Only on PC */
55 #if !defined(ARDUINO)
56 #define fremove(x) remove(x)
57 #define frewind(x) rewind(x)
58 #define fdeleteall()
59 #endif
60 
61 #define ION_USING_MASTER_TABLE 1
62 #define ION_USING_ECLIPSE 0
63 #define ION_DEBUG 0
64 #define ION_IS_EQUAL 0
65 #define ION_IS_GREATER 1
66 #define ION_IS_LESS -1
67 #define ION_ZERO 0
68 #define ION_RETURN_VALUE 0x73/* Magic default return value to be easy to spot */
69 
73 #define ION_MAX_FILENAME_LENGTH 12
74 
75 /* ==================== ARDUINO CONDITIONAL COMPILATION ================================ */
76 #if !defined(ARDUINO)
77 /* Only if we're on desktop do we want to flush. Otherwise we only do a printf. */
78 #define DUMP(varname, format) printf("Variable %s = " format "\n", # varname, varname);fflush(stdout)
79 #define PANIC(stuff) printf("\t\t%s\n", stuff);fflush(stdout)
80 #else
81 #define DUMP(varname, format) printf("Variable %s = " format "\n", # varname, varname)
82 #define PANIC(stuff) printf("\t\t%s\n", stuff)
83 #endif /* Clause ARDUINO */
84 
85 /* ==================== PC CONDITIONAL COMPILATION ===================================== */
86 #if !defined(ARDUINO)
87 
93 typedef unsigned char byte;
94 
95 #endif
96 /* ===================================================================================== */
97 
98 #define IONIZE(something, type) & (type) { (something) }
99 #define NEUTRALIZE(something, type) (*((type *) (something)))
100 #define IONIZE_VAL(varname, size) ion_byte_t varname[size]
101 
102 #define UNUSED(x) (void) ((x))
103 
104 #define ION_STATUS_CREATE(error, count) \
105  ((ion_status_t) { (error), (count) } \
106  )
107 #define ION_STATUS_INITIALIZE \
108  ((ion_status_t) { err_uninitialized, 0 } \
109  )
110 #define ION_STATUS_ERROR(error) \
111  ((ion_status_t) { (error), 0 } \
112  )
113 #define ION_STATUS_OK(count) \
114  ((ion_status_t) { err_ok, (count) } \
115  )
116 
121 typedef enum ION_KEY_TYPE {
132 
137 typedef enum ION_DICTIONARY_TYPE {
153 
158 enum ION_ERROR {
219 };
220 
226 typedef char ion_err_t;
227 
232 typedef unsigned char ion_byte_t;
233 
237 typedef long ion_fpos_t;
241 typedef void *ion_key_t;
242 
246 typedef void *ion_value_t;
247 
251 typedef int ion_key_size_t;
252 
256 typedef int ion_value_size_t;
257 
264 typedef unsigned int ion_dictionary_size_t;
265 
269 typedef char ion_boolean_t;
270 
274 typedef enum ION_BOOLEAN {
279 } ion_boolean_e;
280 
284 typedef int ion_result_count_t;
285 
290 typedef struct {
291  ion_err_t error;
293  ion_result_count_t count;
294 } ion_status_t;
295 
301 typedef char ion_record_status_t;
302 
306 typedef struct record_info {
307  ion_key_size_t key_size;
309  ion_value_size_t value_size;
311 
315 typedef struct ion_record {
316  ion_key_t key;
318  ion_value_t value;
319 } ion_record_t;
320 
321 #if defined(__cplusplus)
322 }
323 #endif
324 
325 #endif /* KV_SYSTEM_H_ */
unsigned char ion_byte_t
A byte type.
Definition: kv_system.h:232
enum ION_KEY_TYPE ion_key_type_t
This is the available key types for ION_DB. All types will be based on system defines.
struct ion_record ion_record_t
Struct used to maintain key and value.
int ion_value_size_t
The size (length) of a dictionary value in bytes.
Definition: kv_system.h:256
enum ION_DICTIONARY_TYPE ion_dictionary_type_t
This is the available dictionary types for ION_DB. All types will be based on system defines...
ion_value_t value
Definition: kv_system.h:318
Struct used to maintain key and value.
Definition: kv_system.h:315
unsigned int ion_dictionary_size_t
The implementation specific size of the dictionary.
Definition: kv_system.h:264
ion_err_t error
Definition: kv_system.h:291
ion_key_t key
Definition: kv_system.h:316
char ion_err_t
The error type used to store error codes.
Definition: kv_system.h:226
void * ion_key_t
A dictionary key.
Definition: kv_system.h:241
void * ion_value_t
A dictionary value.
Definition: kv_system.h:246
char ion_record_status_t
A type for record statuses used in some structures.
Definition: kv_system.h:301
ION_BOOLEAN
Boolean values.
Definition: kv_system.h:274
ion_result_count_t count
Definition: kv_system.h:293
ion_key_size_t key_size
Definition: kv_system.h:307
ION_ERROR
The list of all possible errors generated by any IonDB operation.
Definition: kv_system.h:158
long ion_fpos_t
A file position type.
Definition: kv_system.h:237
unsigned char byte
A byte type. Do not use this type directly.
Definition: kv_system.h:93
int ion_key_size_t
The size (length) of a dictionary key in bytes.
Definition: kv_system.h:251
char ion_boolean_t
A boolean type.
Definition: kv_system.h:269
int ion_result_count_t
A type for the number of results changed during an operation.
Definition: kv_system.h:284
struct record_info ion_record_info_t
Struct used to maintain information about size of key and value.
enum ION_BOOLEAN ion_boolean_e
Boolean values.
Struct used to maintain information about size of key and value.
Definition: kv_system.h:306
ION_KEY_TYPE
This is the available key types for ION_DB. All types will be based on system defines.
Definition: kv_system.h:121
ion_value_size_t value_size
Definition: kv_system.h:309
ION_DICTIONARY_TYPE
This is the available dictionary types for ION_DB. All types will be based on system defines...
Definition: kv_system.h:137
A status object that describes the result of a dictionary operation.
Definition: kv_system.h:290