/* cc -o list-extensions `pkg-config --libs --cflags xcb` list-extensions.c */ #include #include #include void fixed_xcb_str_next(xcb_str_iterator_t* it) { it->data = (void*) ((char*) it->data + it->data->name_len + 1); --it->rem; } int main() { xcb_connection_t* ctrl = xcb_connect(NULL, NULL); xcb_generic_error_t* error; xcb_list_extensions_cookie_t ext_cookie; xcb_list_extensions_reply_t* ext_reply; if ((!ctrl || xcb_connection_has_error(ctrl))) { fprintf(stderr, "Failed to connect to the display\n"); return 1; } ext_cookie = xcb_list_extensions(ctrl); error = NULL; ext_reply = xcb_list_extensions_reply(ctrl, ext_cookie, &error); if (!ext_reply || error) { fprintf(stderr, "Failed to request list of extensions\n"); return 1; } { xcb_str_iterator_t it = xcb_list_extensions_names_iterator(ext_reply); while (it.rem) { printf("%d bytes: ", xcb_str_name_length(it.data)); fwrite(xcb_str_name(it.data), 1, xcb_str_name_length(it.data), stdout); printf("\n"); xcb_str_next(&it); } } }