c_lib.h 3.2 KB

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