1 /*
2   Copyright 2016 David Robillard <d@drobilla.net>
3 
4   Permission to use, copy, modify, and/or distribute this software for any
5   purpose with or without fee is hereby granted, provided that the above
6   copyright notice and this permission notice appear in all copies.
7 
8   THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9   WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10   MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11   ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16 
17 #ifndef ZIX_COMMON_H
18 #define ZIX_COMMON_H
19 
20 /**
21    @addtogroup zix
22    @{
23 */
24 
25 /** @cond */
26 #ifdef ZIX_SHARED
27 #  ifdef _WIN32
28 #    define ZIX_LIB_IMPORT __declspec(dllimport)
29 #    define ZIX_LIB_EXPORT __declspec(dllexport)
30 #  else
31 #    define ZIX_LIB_IMPORT __attribute__((visibility("default")))
32 #    define ZIX_LIB_EXPORT __attribute__((visibility("default")))
33 #  endif
34 #  ifdef ZIX_INTERNAL
35 #    define ZIX_API ZIX_LIB_EXPORT
36 #  else
37 #    define ZIX_API ZIX_LIB_IMPORT
38 #  endif
39 #  define ZIX_PRIVATE static
40 #elif defined(ZIX_INLINE)
41 #  define ZIX_API static inline
42 #  define ZIX_PRIVATE static inline
43 #else
44 #  define ZIX_API
45 #  define ZIX_PRIVATE static
46 #endif
47 /** @endcond */
48 
49 #ifdef __cplusplus
50 extern "C" {
51 #else
52 #  include <stdbool.h>
53 #endif
54 
55 typedef enum {
56   ZIX_STATUS_SUCCESS,
57   ZIX_STATUS_ERROR,
58   ZIX_STATUS_NO_MEM,
59   ZIX_STATUS_NOT_FOUND,
60   ZIX_STATUS_EXISTS,
61   ZIX_STATUS_BAD_ARG,
62   ZIX_STATUS_BAD_PERMS
63 } ZixStatus;
64 
65 /**
66    Function for comparing two elements.
67 */
68 typedef int (*ZixComparator)(const void* a, const void* b, void* user_data);
69 
70 /**
71    Function for testing equality of two elements.
72 */
73 typedef bool (*ZixEqualFunc)(const void* a, const void* b);
74 
75 /**
76    Function to destroy an element.
77 */
78 typedef void (*ZixDestroyFunc)(void* ptr);
79 
80 /**
81    @}
82 */
83 
84 #ifdef __cplusplus
85 } /* extern "C" */
86 #endif
87 
88 #endif /* ZIX_COMMON_H */
89