static void __config_parse_xresource_options ( xcb_xrm_database_t *xDB, enum ConfigSource source ) { const char * namePrefix = "rofi"; for ( unsigned int i = 0; i < sizeof ( xrmOptions ) / sizeof ( XrmOption ); ++i ) { char *name = g_strdup_printf ( "%s.%s", namePrefix, xrmOptions[i].name ); char *xrmValue = NULL; if ( xcb_xrm_resource_get_string ( xDB, name, NULL, &xrmValue ) == 0 ) { config_parser_set ( &( xrmOptions[i] ), xrmValue, source ); } if ( xrmValue ) { free ( xrmValue ); } g_free ( name ); } }
static int check_get_resource(const char *str_database, const char *res_name, const char *res_class, const char *value, bool expected_xlib_mismatch) { xcb_xrm_database_t *database; bool err = false; char *xcb_value; char *xlib_value; fprintf(stderr, "== Assert that getting resource <%s> / <%s> returns <%s>\n", res_name, res_class, value); database = xcb_xrm_database_from_string(str_database); if (xcb_xrm_resource_get_string(database, res_name, res_class, &xcb_value) < 0) { if (value != NULL) { fprintf(stderr, "xcb_xrm_resource_get_string() returned NULL\n"); err = true; } if (!expected_xlib_mismatch) { xlib_value = check_get_resource_xlib(str_database, res_name, res_class); err |= check_strings(NULL, xlib_value, "Returned NULL, but Xlib returned <%s>\n", xlib_value); if (xlib_value != NULL) free(xlib_value); } goto done_get_resource; } err |= check_strings(value, xcb_value, "Expected <%s>, but got <%s>\n", value, xcb_value); free(xcb_value); if (!expected_xlib_mismatch) { /* And for good measure, also compare it against Xlib. */ xlib_value = check_get_resource_xlib(str_database, res_name, res_class); err |= check_strings(value, xlib_value, "Xlib returns <%s>, but expected <%s>\n", xlib_value, value); if (xlib_value != NULL) free(xlib_value); } done_get_resource: xcb_xrm_database_free(database); return err; }