]> git.ozlabs.org Git - ccan/blob - junkcode/dongre.avinash@gmail.com-clibutils/inc/c_lib.h
ccan/structeq: make it safe when there's padding.
[ccan] / junkcode / dongre.avinash@gmail.com-clibutils / inc / c_lib.h
1 /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **\r
2  *  This file is part of clib library\r
3  *  Copyright (C) 2011 Avinash Dongre ( dongre.avinash@gmail.com )\r
4  *\r
5  *  Permission is hereby granted, free of charge, to any person obtaining a copy\r
6  *  of this software and associated documentation files (the "Software"), to deal\r
7  *  in the Software without restriction, including without limitation the rights\r
8  *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
9  *  copies of the Software, and to permit persons to whom the Software is\r
10  *  furnished to do so, subject to the following conditions:\r
11  * \r
12  *  The above copyright notice and this permission notice shall be included in\r
13  *  all copies or substantial portions of the Software.\r
14  * \r
15  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
16  *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
17  *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
18  *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
19  *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
20  *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
21  *  THE SOFTWARE.\r
22  ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **/\r
23 \r
24 #ifndef _C_LIB_H_\r
25 #define _C_LIB_H_\r
26 \r
27 #include "c_errors.h"\r
28 #include <stdlib.h>\r
29 \r
30 /* ------------------------------------------------------------------------*/\r
31 /*       C O M M O N       D E F I N I T O N S                             */\r
32 /* ------------------------------------------------------------------------*/\r
33 \r
34 typedef void (*clib_destroy)(void*);\r
35 typedef int  (*clib_compare)(void*,void*);\r
36 typedef void (*clib_traversal)( void*);\r
37 \r
38 typedef int  clib_error;\r
39 typedef int  clib_bool;\r
40 \r
41 #define clib_black           0\r
42 #define clib_red             1\r
43 #define clib_true            1\r
44 #define clib_false           0\r
45 \r
46 /* ------------------------------------------------------------------------*/\r
47 /*                            P  A  I   R                                  */\r
48 /* ------------------------------------------------------------------------*/\r
49 \r
50 struct clib_object {\r
51     void* raw_data;\r
52     size_t size;\r
53 };\r
54 \r
55 #include "c_array.h"\r
56 #include "c_deque.h"\r
57 #include "c_rb.h"\r
58 #include "c_set.h"\r
59 #include "c_map.h"\r
60 #include "c_slist.h"\r
61 #include "c_map.h"\r
62 #include "c_stack.h"\r
63 #include "c_heap.h"\r
64 \r
65 /* ------------------------------------------------------------------------*/\r
66 /*            H E L P E R       F U N C T I O N S                          */\r
67 /* ------------------------------------------------------------------------*/\r
68 \r
69 extern void  clib_copy ( void *destination, void *source, size_t size );\r
70 extern void  clib_get  ( void *destination, void *source, size_t size);\r
71 extern char* clib_strdup ( char *ptr );\r
72 \r
73 extern struct clib_object* new_clib_object (void *inObject, size_t obj_size);\r
74 extern clib_error get_raw_clib_object (struct clib_object *inObject, void**elem);\r
75 extern void  delete_clib_object  (struct clib_object* inObject );\r
76 extern void replace_raw_clib_object(struct clib_object* current_object,void *elem, size_t elem_size);\r
77 \r
78 #endif\r