2 * Copyright © 2008 Ian Osgood <iano@quirkster.com>
3 * Copyright © 2008 Jamey Sharp <jamey@minilop.net>
4 * Copyright © 2008 Josh Triplett <josh@freedesktop.org>
5 * Copyright © 2008 Julien Danjou <julien@danjou.info>
7 * Permission is hereby granted, free of charge, to any person
8 * obtaining a copy of this software and associated documentation
9 * files (the "Software"), to deal in the Software without
10 * restriction, including without limitation the rights to use, copy,
11 * modify, merge, publish, distribute, sublicense, and/or sell copies
12 * of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be
16 * included in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
22 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
23 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 * Except as contained in this notice, the names of the authors or
27 * their institutions shall not be used in advertising or otherwise to
28 * promote the sale, use or other dealings in this Software without
29 * prior written authorization from the authors.
32 #include "xcb_reply.h"
39 pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
40 pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
42 void fontinfo_handler(void *data, xcb_connection_t *c, xcb_generic_reply_t *rg, xcb_generic_error_t *eg)
44 xcb_list_fonts_with_info_reply_t *rep = (xcb_list_fonts_with_info_reply_t *) rg;
47 int len = xcb_list_fonts_with_info_name_length(rep);
49 printf("(+%u) Font \"%.*s\"\n",
50 (unsigned int) rep->replies_hint,
51 len, xcb_list_fonts_with_info_name(rep));
54 pthread_mutex_lock(&lock);
55 pthread_cond_broadcast(&cond);
56 pthread_mutex_unlock(&lock);
57 printf("End of font list.\n");
61 printf("Error from ListFontsWithInfo: %d\n", eg->error_code);
64 int main(int argc, char **argv)
68 xcb_connection_t *c = xcb_connect(NULL, NULL);
69 xcb_reply_handlers_t h;
70 xcb_reply_handlers_init(c, &h);
73 count = atoi(argv[1]);
77 xcb_reply_add_handler(&h, xcb_list_fonts_with_info(c, count, strlen(pattern), pattern).sequence, fontinfo_handler, 0);
78 pthread_mutex_lock(&lock);
79 xcb_reply_start_thread(&h);
80 pthread_cond_wait(&cond, &lock);
81 xcb_reply_stop_thread(&h);
82 pthread_mutex_unlock(&lock);