diff options
author | Ian Osgood <iano@quirkster.com> | 2006-09-24 13:34:03 -0700 |
---|---|---|
committer | Ian Osgood <iano@quirkster.com> | 2006-09-24 13:34:03 -0700 |
commit | a76558d985a2a0172e452e705249c37c5dafae0b (patch) | |
tree | 5dc8fb6598e537e6dfcb4108e71a7c66d432cf81 /reply | |
parent | ab76fa5412e8f707031fe012c411a8702c1bcf45 (diff) |
All xcb-util libraries compile after the Great Renaming.
Many of the exported library functions still need to follow the new convention.
Diffstat (limited to 'reply')
-rw-r--r-- | reply/reply.c | 38 | ||||
-rw-r--r-- | reply/test_reply.c | 22 | ||||
-rw-r--r-- | reply/xcb_reply.h | 18 |
3 files changed, 39 insertions, 39 deletions
diff --git a/reply/reply.c b/reply/reply.c index 5045690..8bec445 100644 --- a/reply/reply.c +++ b/reply/reply.c @@ -6,22 +6,22 @@ struct node { struct node *next; unsigned int request; - GenericReplyHandler handler; + generic_reply_handler handler; void *data; char handled; }; -struct ReplyHandlers { +struct reply_handlers { pthread_mutex_t lock; pthread_cond_t cond; struct node *head; - XCBConnection *c; + xcb_connection_t *c; char stop; }; -ReplyHandlers *allocReplyHandlers(XCBConnection *c) +reply_handlers_t *alloc_reply_handlers(xcb_connection_t *c) { - ReplyHandlers *ret = calloc(1, sizeof(ReplyHandlers)); + reply_handlers_t *ret = calloc(1, sizeof(reply_handlers_t)); if(ret) { static const pthread_mutex_t proto_lock = PTHREAD_MUTEX_INITIALIZER; @@ -33,17 +33,17 @@ ReplyHandlers *allocReplyHandlers(XCBConnection *c) return ret; } -void freeReplyHandlers(ReplyHandlers *h) +void free_reply_handlers(reply_handlers_t *h) { free(h); } -XCBConnection *getXCBConnection(ReplyHandlers *h) +xcb_connection_t *get_xcb_connection(reply_handlers_t *h) { return h->c; } -static void insert_handler(ReplyHandlers *h, struct node *cur) +static void insert_handler(reply_handlers_t *h, struct node *cur) { struct node **prev = &h->head; while(*prev && (*prev)->request < cur->request) @@ -52,17 +52,17 @@ static void insert_handler(ReplyHandlers *h, struct node *cur) *prev = cur; } -static int do_poll(ReplyHandlers *h) +static int do_poll(reply_handlers_t *h) { - XCBGenericRep *reply; - XCBGenericError *error; + xcb_generic_reply_t *reply; + xcb_generic_error_t *error; int handled; struct node *cur = h->head; h->head = cur->next; pthread_mutex_unlock(&h->lock); pthread_cleanup_push((void (*)(void *)) pthread_mutex_lock, &h->lock); - reply = XCBWaitForReply(h->c, cur->request, &error); + reply = xcb_wait_for_reply(h->c, cur->request, &error); if(reply || error) { @@ -83,12 +83,12 @@ static int do_poll(ReplyHandlers *h) return handled; } -int PollReplies(ReplyHandlers *h) +int poll_replies(reply_handlers_t *h) { int ret = 1; - XCBFlush(h->c); + xcb_flush(h->c); pthread_mutex_lock(&h->lock); - while(ret && h->head && XCBGetRequestRead(h->c) >= h->head->request) + while(ret && h->head && xcb_get_request_read(h->c) >= h->head->request) ret = do_poll(h); pthread_mutex_unlock(&h->lock); return ret; @@ -96,7 +96,7 @@ int PollReplies(ReplyHandlers *h) static void *reply_thread(void *hvp) { - ReplyHandlers *h = hvp; + reply_handlers_t *h = hvp; pthread_mutex_lock(&h->lock); pthread_cleanup_push((void (*)(void *)) pthread_mutex_unlock, &h->lock); while(1) @@ -111,14 +111,14 @@ static void *reply_thread(void *hvp) return 0; } -pthread_t StartReplyThread(ReplyHandlers *h) +pthread_t start_reply_thread(reply_handlers_t *h) { pthread_t ret; pthread_create(&ret, 0, reply_thread, h); return ret; } -void StopReplyThreads(ReplyHandlers *h) +void stop_reply_threads(reply_handlers_t *h) { pthread_mutex_lock(&h->lock); h->stop = 1; @@ -126,7 +126,7 @@ void StopReplyThreads(ReplyHandlers *h) pthread_mutex_unlock(&h->lock); } -void AddReplyHandler(ReplyHandlers *h, unsigned int request, GenericReplyHandler handler, void *data) +void add_reply_handler(reply_handlers_t *h, unsigned int request, generic_reply_handler handler, void *data) { struct node *cur = malloc(sizeof(struct node)); cur->request = request; diff --git a/reply/test_reply.c b/reply/test_reply.c index a8ba254..8c44c6d 100644 --- a/reply/test_reply.c +++ b/reply/test_reply.c @@ -6,16 +6,16 @@ #include <stdlib.h> #include <unistd.h> -void fontinfo_handler(void *data, XCBConnection *c, XCBGenericRep *rg, XCBGenericError *eg) +void fontinfo_handler(void *data, xcb_connection_t *c, xcb_generic_reply_t *rg, xcb_generic_error_t *eg) { - XCBListFontsWithInfoRep *rep = (XCBListFontsWithInfoRep *) rg; + xcb_list_fonts_with_info_reply_t *rep = (xcb_list_fonts_with_info_reply_t *) rg; if(rep) { - int len = XCBListFontsWithInfoNameLength(rep); + int len = xcb_list_fonts_with_info_name_length(rep); if(len) printf("(+%u) Font \"%.*s\"\n", (unsigned int) rep->replies_hint, - len, XCBListFontsWithInfoName(rep)); + len, xcb_list_fonts_with_info_name(rep)); else printf("End of font list.\n"); } @@ -27,8 +27,8 @@ int main(int argc, char **argv) { int count = 10; char *pattern = "*"; - XCBConnection *c = XCBConnect(NULL, NULL); - ReplyHandlers *h = allocReplyHandlers(c); + xcb_connection_t *c = xcb_connect(NULL, NULL); + reply_handlers_t *h = alloc_reply_handlers(c); pthread_t reply_thread; if(argc > 1) @@ -36,12 +36,12 @@ int main(int argc, char **argv) if(argc > 2) pattern = argv[2]; - AddReplyHandler(h, XCBListFontsWithInfo(c, count, strlen(pattern), pattern).sequence, fontinfo_handler, 0); - reply_thread = StartReplyThread(h); + add_reply_handler(h, xcb_list_fonts_with_info(c, count, strlen(pattern), pattern).sequence, fontinfo_handler, 0); + reply_thread = start_reply_thread(h); - XCBSync(c, 0); - StopReplyThreads(h); + free(xcb_get_input_focus_reply(c, xcb_get_input_focus(c), NULL)); + stop_reply_threads(h); pthread_join(reply_thread, 0); - XCBDisconnect(c); + xcb_disconnect(c); exit(0); } diff --git a/reply/xcb_reply.h b/reply/xcb_reply.h index 0f52d61..781e11d 100644 --- a/reply/xcb_reply.h +++ b/reply/xcb_reply.h @@ -10,18 +10,18 @@ extern "C" { #endif -typedef struct ReplyHandlers ReplyHandlers; -ReplyHandlers *allocReplyHandlers(XCBConnection *c); -void freeReplyHandlers(ReplyHandlers *h); -XCBConnection *getXCBConnection(ReplyHandlers *h); +typedef struct reply_handlers reply_handlers_t; +reply_handlers_t *alloc_reply_handlers(xcb_connection_t *c); +void free_reply_handlers(reply_handlers_t *h); +xcb_connection_t *get_xcb_connection(reply_handlers_t *h); -int PollReplies(ReplyHandlers *h); -pthread_t StartReplyThread(ReplyHandlers *h); -void StopReplyThreads(ReplyHandlers *h); +int poll_replies(reply_handlers_t *h); +pthread_t start_reply_thread(reply_handlers_t *h); +void stop_reply_threads(reply_handlers_t *h); -typedef void (*GenericReplyHandler)(void *data, XCBConnection *c, XCBGenericRep *reply, XCBGenericError *error); +typedef void (*generic_reply_handler)(void *data, xcb_connection_t *c, xcb_generic_reply_t *reply, xcb_generic_error_t *error); -void AddReplyHandler(ReplyHandlers *h, unsigned int request, GenericReplyHandler handler, void *data); +void add_reply_handler(reply_handlers_t *h, unsigned int request, generic_reply_handler handler, void *data); #ifdef __cplusplus |