00001 /* vim: set sw=8 ts=8 sts=8 expandtab: */ 00002 #ifndef CMAID_VALUE_H 00003 #define CMAID_VALUE_H 00004 00009 #ifndef FALSE 00010 00014 # define FALSE (1 == 0) 00015 #endif 00016 00017 #ifndef TRUE 00018 00022 # define TRUE (1 == 1) 00023 #endif 00024 00029 #define CMAID_VALUE_COMPARE_CB(func) ((Cmaid_Value_Compare_Cb)(func)) 00030 00033 typedef int (*Cmaid_Value_Compare_Cb)(const void *v1, const void *v2); 00034 00039 #define CMAID_VALUE_HASH_CB(func) ((Cmaid_Value_Hash_Cb)(func)) 00040 00043 typedef unsigned int (*Cmaid_Value_Hash_Cb)(const void *v1, unsigned int *nbytes); 00044 00049 #define CMAID_VALUE_SIZE_CB(func) ((Cmaid_Value_Size_Cb)(func)) 00050 00053 typedef unsigned int (*Cmaid_Value_Size_Cb)(const void *v); 00054 00059 #define CMAID_VALUE_COPY_CB(func) ((Cmaid_Value_Copy_Cb)(func)) 00060 00063 typedef void (*Cmaid_Value_Copy_Cb)(void *dest, const void *src, 00064 unsigned int nbytes); 00069 #define CMAID_VALUE_CLONE_CB(func) ((Cmaid_Value_Clone_Cb)(func)) 00070 00073 typedef void *(*Cmaid_Value_Clone_Cb)(const void *v); 00074 00079 #define CMAID_VALUE_FREE_CB(func) ((Cmaid_Value_Free_Cb)(func)) 00080 00083 typedef void (*Cmaid_Value_Free_Cb)(void *v); 00084 00086 typedef struct Cmaid_Value Cmaid_Value; 00087 00091 struct Cmaid_Value 00092 { 00093 Cmaid_Value_Compare_Cb cmp; 00094 Cmaid_Value_Hash_Cb hash; 00095 int size; 00101 struct 00102 { 00103 Cmaid_Value_Size_Cb size; 00104 Cmaid_Value_Copy_Cb copy; 00105 Cmaid_Value_Free_Cb free; 00106 } sized; 00107 00109 struct 00110 { 00111 Cmaid_Value_Clone_Cb dup; 00112 Cmaid_Value_Free_Cb free; 00113 } pointer; 00114 }; 00115 00116 EAPI extern const Cmaid_Value cmaid_value_pointer; 00117 EAPI extern const Cmaid_Value cmaid_value_inline_string; 00118 EAPI extern const Cmaid_Value cmaid_value_const_string; 00119 00120 EAPI unsigned int cmaid_value_pointer_hash(const void *key, unsigned int *size); 00121 EAPI unsigned int cmaid_value_string_hash(const void *key, unsigned int *size); 00122 EAPI int cmaid_value_pointer_compare(const void *key1, 00123 const void *key2); 00124 EAPI int cmaid_value_string_compare(const void *key1, 00125 const void *key2); 00126 EAPI unsigned int cmaid_value_string_size(const void *key); 00127 00128 /* only for debugging */ 00129 void *cmaid_value_string_dup(const void *key); 00130 void cmaid_value_string_free(void *key); 00135 #endif
1.5.8