resolve naming conflict on windows.

This commit is contained in:
Enno Rehling 2014-07-03 12:20:50 -07:00
parent ccbcf14458
commit dd408da3f4
3 changed files with 15 additions and 14 deletions

View File

@ -6,12 +6,12 @@
static struct reg {
struct reg * next;
CALLBACK cb;
HCALLBACK cb;
char *name;
} *registry;
CALLBACK create_callback(void (*cbv)(va_list va)) {
CALLBACK cb;
HCALLBACK create_callback(void(*cbv)(va_list va)) {
HCALLBACK cb;
cb.cbv = cbv;
return cb;
}
@ -26,7 +26,7 @@ void reset_callbacks(void) {
registry = 0;
}
CALLBACK register_callback(const char *name, void (*cbv)(va_list va))
HCALLBACK register_callback(const char *name, void(*cbv)(va_list va))
{
struct reg * r = (struct reg *)malloc(sizeof(struct reg));
r->next = registry;
@ -36,7 +36,7 @@ CALLBACK register_callback(const char *name, void (*cbv)(va_list va))
return r->cb;
}
int find_callback(const char *name, CALLBACK *result) {
int find_callback(const char *name, HCALLBACK *result) {
if (result && name) {
struct reg *r;
for (r=registry;r;r=r->next) {
@ -49,7 +49,7 @@ int find_callback(const char *name, CALLBACK *result) {
return -1;
}
int call_callback(CALLBACK cb, const char *name, ... ) {
int call_callback(HCALLBACK cb, const char *name, ...) {
va_list ap;
if (name) {
int err = find_callback(name, &cb);

View File

@ -5,12 +5,12 @@
typedef struct {
void (*cbv)(va_list va);
} CALLBACK;
} HCALLBACK;
CALLBACK register_callback(const char *name, void (*cbv)(va_list va));
CALLBACK create_callback(void (*cbv)(va_list va));
int find_callback(const char *name, CALLBACK *result);
int call_callback(CALLBACK cb, const char *name, ...);
HCALLBACK register_callback(const char *name, void(*cbv)(va_list va));
HCALLBACK create_callback(void(*cbv)(va_list va));
int find_callback(const char *name, HCALLBACK *result);
int call_callback(HCALLBACK cb, const char *name, ...);
void reset_callbacks(void);
#endif

View File

@ -9,7 +9,7 @@ void callback(va_list ap) {
}
static void test_find_callback(CuTest *tc) {
CALLBACK cb;
HCALLBACK cb;
reset_callbacks();
CuAssertIntEquals(tc, -1, find_callback("test", &cb));
cb = register_callback("test", callback);
@ -18,7 +18,7 @@ static void test_find_callback(CuTest *tc) {
}
static void test_call_by_handle(CuTest *tc) {
CALLBACK cb;
HCALLBACK cb;
int x = 0;
reset_callbacks();
cb = create_callback(callback);
@ -28,7 +28,8 @@ static void test_call_by_handle(CuTest *tc) {
}
static void test_call_by_name(CuTest *tc) {
CALLBACK cb, ca;
HCALLBACK cb = { 0 };
HCALLBACK ca = { 0 };
int x = 0;
reset_callbacks();
CuAssertIntEquals(tc, -1, call_callback(cb, "test", 42, &x));