forked from github/server
resolve naming conflict on windows.
This commit is contained in:
parent
ccbcf14458
commit
dd408da3f4
|
@ -6,12 +6,12 @@
|
||||||
|
|
||||||
static struct reg {
|
static struct reg {
|
||||||
struct reg * next;
|
struct reg * next;
|
||||||
CALLBACK cb;
|
HCALLBACK cb;
|
||||||
char *name;
|
char *name;
|
||||||
} *registry;
|
} *registry;
|
||||||
|
|
||||||
CALLBACK create_callback(void (*cbv)(va_list va)) {
|
HCALLBACK create_callback(void(*cbv)(va_list va)) {
|
||||||
CALLBACK cb;
|
HCALLBACK cb;
|
||||||
cb.cbv = cbv;
|
cb.cbv = cbv;
|
||||||
return cb;
|
return cb;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ void reset_callbacks(void) {
|
||||||
registry = 0;
|
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));
|
struct reg * r = (struct reg *)malloc(sizeof(struct reg));
|
||||||
r->next = registry;
|
r->next = registry;
|
||||||
|
@ -36,7 +36,7 @@ CALLBACK register_callback(const char *name, void (*cbv)(va_list va))
|
||||||
return r->cb;
|
return r->cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
int find_callback(const char *name, CALLBACK *result) {
|
int find_callback(const char *name, HCALLBACK *result) {
|
||||||
if (result && name) {
|
if (result && name) {
|
||||||
struct reg *r;
|
struct reg *r;
|
||||||
for (r=registry;r;r=r->next) {
|
for (r=registry;r;r=r->next) {
|
||||||
|
@ -49,7 +49,7 @@ int find_callback(const char *name, CALLBACK *result) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int call_callback(CALLBACK cb, const char *name, ... ) {
|
int call_callback(HCALLBACK cb, const char *name, ...) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
if (name) {
|
if (name) {
|
||||||
int err = find_callback(name, &cb);
|
int err = find_callback(name, &cb);
|
||||||
|
|
|
@ -5,12 +5,12 @@
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void (*cbv)(va_list va);
|
void (*cbv)(va_list va);
|
||||||
} CALLBACK;
|
} HCALLBACK;
|
||||||
|
|
||||||
CALLBACK register_callback(const char *name, void (*cbv)(va_list va));
|
HCALLBACK register_callback(const char *name, void(*cbv)(va_list va));
|
||||||
CALLBACK create_callback(void (*cbv)(va_list va));
|
HCALLBACK create_callback(void(*cbv)(va_list va));
|
||||||
int find_callback(const char *name, CALLBACK *result);
|
int find_callback(const char *name, HCALLBACK *result);
|
||||||
int call_callback(CALLBACK cb, const char *name, ...);
|
int call_callback(HCALLBACK cb, const char *name, ...);
|
||||||
void reset_callbacks(void);
|
void reset_callbacks(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -9,7 +9,7 @@ void callback(va_list ap) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_find_callback(CuTest *tc) {
|
static void test_find_callback(CuTest *tc) {
|
||||||
CALLBACK cb;
|
HCALLBACK cb;
|
||||||
reset_callbacks();
|
reset_callbacks();
|
||||||
CuAssertIntEquals(tc, -1, find_callback("test", &cb));
|
CuAssertIntEquals(tc, -1, find_callback("test", &cb));
|
||||||
cb = register_callback("test", callback);
|
cb = register_callback("test", callback);
|
||||||
|
@ -18,7 +18,7 @@ static void test_find_callback(CuTest *tc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_call_by_handle(CuTest *tc) {
|
static void test_call_by_handle(CuTest *tc) {
|
||||||
CALLBACK cb;
|
HCALLBACK cb;
|
||||||
int x = 0;
|
int x = 0;
|
||||||
reset_callbacks();
|
reset_callbacks();
|
||||||
cb = create_callback(callback);
|
cb = create_callback(callback);
|
||||||
|
@ -28,7 +28,8 @@ static void test_call_by_handle(CuTest *tc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_call_by_name(CuTest *tc) {
|
static void test_call_by_name(CuTest *tc) {
|
||||||
CALLBACK cb, ca;
|
HCALLBACK cb = { 0 };
|
||||||
|
HCALLBACK ca = { 0 };
|
||||||
int x = 0;
|
int x = 0;
|
||||||
reset_callbacks();
|
reset_callbacks();
|
||||||
CuAssertIntEquals(tc, -1, call_callback(cb, "test", 42, &x));
|
CuAssertIntEquals(tc, -1, call_callback(cb, "test", 42, &x));
|
||||||
|
|
Loading…
Reference in New Issue