2016-12-20 00:32:34 -08:00
|
|
|
#ifndef LIBDS_HEADER
|
|
|
|
#define LIBDS_HEADER
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
2016-12-22 18:43:59 -08:00
|
|
|
/**
|
|
|
|
* Enum representing return codes from error-prone libds functions.
|
|
|
|
*/
|
2016-12-21 16:58:00 -08:00
|
|
|
enum libds_result_e { LIBDS_SUCCESS, LIBDS_MALLOC };
|
2016-12-20 00:32:34 -08:00
|
|
|
|
|
|
|
typedef enum libds_result_e libds_result;
|
2016-12-22 18:43:59 -08:00
|
|
|
/**
|
|
|
|
* Comparison function type.
|
|
|
|
* Comparison functions are used in searches etc.
|
|
|
|
* The function should take two elements, and, if they match, return 1. Otherwise, it should
|
|
|
|
* return 0.
|
|
|
|
*/
|
2016-12-20 00:32:34 -08:00
|
|
|
typedef int (*compare_func)(void*, void*);
|
2016-12-22 18:43:59 -08:00
|
|
|
/**
|
|
|
|
* Foreach function type.
|
|
|
|
* Foreach functions are passed to _foreach calls.
|
|
|
|
* The function should return 0 if all goes well, or a nonzero error code if there is an issue.
|
|
|
|
*/
|
2016-12-20 00:32:34 -08:00
|
|
|
typedef int (*foreach_func)(void*, va_list);
|
|
|
|
|
2016-12-22 18:43:59 -08:00
|
|
|
/**
|
|
|
|
* A compare_func implementation that always returns true.
|
|
|
|
* @param a The first piece of data being compared
|
|
|
|
* @param b The second piece of data being compared
|
|
|
|
* @return always true, i.e 1
|
|
|
|
*/
|
2016-12-20 00:32:34 -08:00
|
|
|
int compare_always(void* a, void* b);
|
2016-12-28 19:29:51 -08:00
|
|
|
/**
|
|
|
|
* A compare_func implementation that compares two pointers using ==.
|
|
|
|
* @param a the first piece of data being compared
|
|
|
|
* @param b the second piece of data being compared
|
|
|
|
* @return true if a and b are the same value.
|
|
|
|
*/
|
|
|
|
int compare_pointer(void* a, void* b);
|
2016-12-20 00:32:34 -08:00
|
|
|
|
|
|
|
#endif
|