XrmEnumerateDatabase(3)
β¨ XrmEnumerateDatabase β the one where we go shopping for resources π
okay so bestie, this is a page from XLIB FUNCTIONS and it's literally called XrmEnumerateDatabase π
πΈ NAME πΈ
XrmEnumerateDatabase β enumerate resource database entries. yes girl, it's the "walk through the whole database and show me what matches" function, no cap π₯
π SYNTAX π
#include <X11/Xresource.h>
#define XrmEnumAllLevels 0
#define XrmEnumOneLevel 1
Bool XrmEnumerateDatabase(XrmDatabase database, XrmNameList name_prefix,
XrmClassList class_prefix, int mode, Bool (*proc)(), XPointer
arg);
those two #defines are the whole personality of the mode argument, iykyk π¦ β XrmEnumAllLevels is 0 and XrmEnumOneLevel is 1, and like, remember them because you're gonna need them.
π¦ ARGUMENTS π¦
databaseβ the resource database. like, the actual thing you're digging through ποΈname_prefixβ the resource name prefix. your starting point, bestie β¨class_prefixβ the resource class prefix. the classy counterpart to the name prefix πmodeβ how many levels deep you wanna enumerate, aka yourXrmEnumOneLevelvsXrmEnumAllLevelsmoment πprocβ the procedure that gets called for each matching entry. your little callback bestie that does the actual work π«Άargβ the user-supplied argument that gets passed straight through to the procedure. a little gift for your callback π
π DESCRIPTION π
so here's the tea β β XrmEnumerateDatabase calls the specified procedure for each resource in the database that would match some completion of the given name/class resource prefix. it's giving "scavenger hunt but the prizes are resource entries" πβ¨
the order in which resources are found is implementation-dependent, so like... don't come for me about the order, okay? it's not defined and that's just how it is π
mode check, bestie:
- if
modeisXrmEnumOneLevel, a resource must match the given name/class prefix with just a single name and class appended. one and done, no extra layers π - if
modeisXrmEnumAllLevels, the resource must match the given name/class prefix with one or more names and classes appended. go as deep as you want, we love a deep dive π
and the stopping condition? flawless logic honestly:
- if the procedure returns
True, the enumeration terminates and the function returnsTrueπβ - if the procedure always returns
False, all matching resources get enumerated and the function returnsFalseπβ
π§ how the procedure gets called
the procedure is called with these exact arguments, and yes I'm putting the whole signature because it's important:
(*proc)(database, bindings, quarks, type, value, arg)
XrmDatabase *database;
XrmBindingList bindings;
XrmQuarkList quarks;
XrmRepresentation *type;
XrmValue *value;
XPointer arg;
the bindings and quarks lists are terminated by NULLQUARK β that's your sentinel, that's your "we're done here" marker π
not me reminding you that pointers to the database and type are passed, but these values should not be modified π like please do not touch, look respectfully only. π
β οΈ RULES, bestie, listen up: the procedure must not modify the database. that's a hard no π«
and here's the spicy caveat πΆοΈ β if Xlib has been initialized for threads, the procedure is called with the database locked, and the result of a call by the procedure to any Xlib function using the same database is not defined. yes, not defined, like, undefined-behavior kind of not defined π so maybe don't do that!!
π SEE ALSO π
XrmGetResource(3)XrmInitialize(3)XrmPutResource(3)- Xlib - C Language X Interface
okay that's the whole page, you ate that π β¨ X Version 11, libX11 1.8.14 β go forth and enumerate your resources, queen ππ¦π
π¦ where this page comes from
- alpine 3.24: libx11-doc 1.8.14-r0 Β· X11
- arch rolling: libx11 1.8.14-1 Β· MIT AND X11
- nixos 26.05: libx11 1.8.14
- nixpkgs unstable: libx11 1.8.14
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms