airblader / xcb-util-xrm Goto Github PK
View Code? Open in Web Editor NEWXCB utility functions for the X resource manager
License: Other
XCB utility functions for the X resource manager
License: Other
About XCB util modules ====================== The XCB util modules provides a number of libraries which sit on top of libxcb, the core X protocol library, and some of the extension libraries. These experimental libraries provide convenience functions and interfaces which make the raw X protocol more usable. Some of the libraries also provide client-side code which is not strictly part of the X protocol but which have traditionally been provided by Xlib. If you find any of these libraries useful, please let us know what you're using and why you aren't in a mental hospital yet. We'd welcome patches/suggestions for enhancement and new libraries; Please report any issues you find to the freedesktop.org bug tracker, at: <https://bugs.freedesktop.org/enter_bug.cgi?product=XCB> Discussion about XCB occurs on the XCB mailing list: <mailto:xcb at lists.freedesktop.org> <http://lists.freedesktop.org/mailman/listinfo/xcb> About XCB util-xrm module ========================= XCB util-xrm module provides the following libraries: - xrm: utility functions for the X resource manager You can obtain the latest development versions of XCB util-xrm using GIT. Use git clone --recursive https://github.com/Airblader/xcb-util-xrm.git
Hey Airblader, thank you for all you've done on this project.
I've got a fresh install of Ubuntu 18.04 and when checking out the repo with
git clone --recursive https://github.com/Airblader/xcb-util-xrm.git
I am unable to clone into m4
:
Cloning into 'xcb-util-xrm'...
remote: Counting objects: 926, done.
remote: Total 926 (delta 0), reused 0 (delta 0), pack-reused 926
Receiving objects: 100% (926/926), 207.56 KiB | 3.24 MiB/s, done.
Resolving deltas: 100% (594/594), done.
Submodule 'm4' (git://anongit.freedesktop.org/xcb/util-common-m4.git) registered for path 'm4'
Cloning into '/home/ygx/dev/kassa/xcb-util-xrm/m4'...
fatal: unable to connect to anongit.freedesktop.org:
anongit.freedesktop.org[0: 131.252.210.161]: errno=Connection timed out
anongit.freedesktop.org[1: 2610:10:20:722:a800:ff:fe24:61cf]: errno=Network is unreachable
fatal: clone of 'git://anongit.freedesktop.org/xcb/util-common-m4.git' into submodule path '/home/ygx/dev/kassa/xcb-util-xrm/m4' failed
Failed to clone 'm4'. Retry scheduled
Cloning into '/home/ygx/dev/kassa/xcb-util-xrm/m4'...
^Cwarning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry the checkout with 'git checkout -f HEAD'
Edit: Adding some more diagnostics:
When I check the status:
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
and running git checkout -f HEAD
:
Your branch is up to date with 'origin/master'.
Any thoughts?
Hello,
This is probably not worth your time and I figured it out, but with the default settings if one goes to install the submodules behind a firewall (well, in my case at least), the clone will fail due to the git protocol. The Arch AUR package already has http specified, but the build kept failing due to trying to pull m4
from git://anongit
. I found that by manually editing the .gitmodules
file to use the following URL, it would work: https://anongit.freedesktop.org/git/xcb/util-common-m4.git/
Anyway, again, not a typical issue but just wondered if there was a way to set a "backup" URL. I've not encountered submodules before so this had me really racking my brain since nothing in the Arch PKGBUILD
file said anything about anongit
, just this github URL!
Hi,
I've got some trouble installing xcb-xrm on Nvidia Jetson-TX2 running ubuntu 16.04.
./autogen.sh autoreconf: Entering directory
.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal -I m4
autoreconf: configure.ac: tracing
autoreconf: running: libtoolize --copy
/usr/bin/libtoolize: 1: eval: hookable_fns+=: not found
/usr/bin/libtoolize: 1: eval: hookable_fns+=: not found
/usr/bin/libtoolize: 1: eval: hookable_fns+=: not found
/usr/bin/libtoolize: 1: eval: hookable_fns+=: not found
libtoolize: error: 'func_options_prep' does not accept hook functions.
autoreconf: libtoolize failed with exit status: 1`
After a fresh git clone and git submodule.
Thanks you in advance.
See corresponding Xlib methods.
I can't figure out how to compile this.
I have tried: autoreconf --install
configure.ac:16: error: must install xorg-macros 1.16.0 or later before running autoconf/autogen
m4/xcb_util_common.m4:8: XCB_UTIL_COMMON is expanded from...
configure.ac:16: the top level
autom4te: /usr/bin/m4 failed with exit status: 1
aclocal: error: echo failed with exit status: 1
autoreconf: aclocal failed with exit status: 1
but it doesn't work.
Any ideas?
Add the following API functions:
xcb_xrm_database_put
xcb_xrm_database_put_line
Ensure to override duplicates if necessary ( see #22 ).
From https://tronche.com/gui/x/xlib/resource-manager/file-syntax.html:
If a ResourceName contains a contiguous sequence of two or more Binding characters, the sequence will be replaced with single
.'' character if the sequence contains only
.'' characters; otherwise, the sequence will be replaced with a single ``*'' character.
This documents the necessary tasks for a first official release:
RESOURCE_MANAGER
strings and parse them correctly.xcb_xrm_database_from_resource_manager
#
lines.Database: A*c.e: 42
Query: A.b.c.d.c.e
XLib returns a match here, so it doesn't stop at the first c
.
From @psychon:
Makefile.am:
TEST_LIBS = $(shell pkg-config --libs x11 x11-xcb xcb xcb-aux)
That's... unusual. I don't know if this is portable to non-gnu-make. Something like this should be done in configure.ac with the usual macros (and error messages if one of the libraries is missing)
Hey, using ubuntu 16.04, autoconf 2.69, when i try to build, the following happens:
idf@ubuntu:~/src$ cd /tmp
idf@ubuntu:/tmp$ git clone https://github.com/Airblader/xcb-util-xrm
Cloning into 'xcb-util-xrm'...
remote: Counting objects: 906, done.
remote: Total 906 (delta 0), reused 0 (delta 0), pack-reused 906
Receiving objects: 100% (906/906), 202.80 KiB | 0 bytes/s, done.
Resolving deltas: 100% (580/580), done.
Checking connectivity... done.
idf@ubuntu:/tmp$ cd xcb-util-xrm/
idf@ubuntu:/tmp/xcb-util-xrm$ git submodule update --init
Submodule 'm4' (git://anongit.freedesktop.org/xcb/util-common-m4.git) registered for path 'm4'
Cloning into 'm4'...
remote: Counting objects: 15, done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 15 (delta 5), reused 15 (delta 5)
Receiving objects: 100% (15/15), 4.97 KiB | 0 bytes/s, done.
Resolving deltas: 100% (5/5), done.
Checking connectivity... done.
Submodule path 'm4': checked out 'f662e3a93ebdec3d1c9374382dcc070093a42fed'
idf@ubuntu:/tmp/xcb-util-xrm$ ./autogen.sh --prefix=/usr
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal -I m4
configure.ac:16: error: must install xorg-macros 1.16.0 or later before running autoconf/autogen
m4/xcb_util_common.m4:8: XCB_UTIL_COMMON is expanded from...
configure.ac:16: the top level
autom4te: /usr/bin/m4 failed with exit status: 1
aclocal: error: echo failed with exit status: 1
autoreconf: aclocal failed with exit status: 1
Is there a way to see if an option is unset?
If I do:
rofi.width:
It does not find a match when looking it up using: xcb_xrm_resource_get_string.
(kind of expected)
But is there anyway to see that is specified but not set.
When packaging this library for Debian, I’ve noticed that even though configure passes, when libx11-dev and libx11-xcb-dev are missing, the build fails:
Package x11 was not found in the pkg-config search path.
Perhaps you should add the directory containing `x11.pc'
to the PKG_CONFIG_PATH environment variable
No package 'x11' found
Package x11-xcb was not found in the pkg-config search path.
Perhaps you should add the directory containing `x11-xcb.pc'
to the PKG_CONFIG_PATH environment variable
No package 'x11-xcb' found
/bin/bash ./libtool --tag=CC --mode=link gcc -Wall -Wpointer-arith -Wmissing-declarations -Wformat=2 -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wbad-function-cast -Wold-style-definition -Wdeclaration-after-statement -Wunused -Wuninitialized -Wshadow -Wmissing-noreturn -Wmissing-format-attribute -Wredundant-decls -Wlogical-op -Werror=implicit -Werror=nonnull -Werror=init-self -Werror=main -Werror=missing-braces -Werror=sequence-point -Werror=return-type -Werror=trigraphs -Werror=array-bounds -Werror=write-strings -Werror=address -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast -fno-strict-aliasing -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -fPIE -pie -Wl,-z,relro -Wl,-z,now -o tests/tests_parser tests/tests_tests_parser-tests_utils.o tests/tests_tests_parser-tests_parser.o libxcb-xrm.la -lxcb
libtool: link: gcc -Wall -Wpointer-arith -Wmissing-declarations -Wformat=2 -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wbad-function-cast -Wold-style-definition -Wdeclaration-after-statement -Wunused -Wuninitialized -Wshadow -Wmissing-noreturn -Wmissing-format-attribute -Wredundant-decls -Wlogical-op -Werror=implicit -Werror=nonnull -Werror=init-self -Werror=main -Werror=missing-braces -Werror=sequence-point -Werror=return-type -Werror=trigraphs -Werror=array-bounds -Werror=write-strings -Werror=address -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast -fno-strict-aliasing -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -fPIE -pie -Wl,-z -Wl,relro -Wl,-z -Wl,now -o tests/.libs/tests_parser tests/tests_tests_parser-tests_utils.o tests/tests_tests_parser-tests_parser.o ./.libs/libxcb-xrm.so -lxcb
gcc -DPACKAGE_NAME=\"xcb-util-xrm\" -DPACKAGE_TARNAME=\"xcb-util-xrm\" -DPACKAGE_VERSION=\"1.0\" -DPACKAGE_STRING=\"xcb-util-xrm\ 1.0\" -DPACKAGE_BUGREPORT=\"[email protected]\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -D__EXTENSIONS__=1 -D_ALL_SOURCE=1 -D_GNU_SOURCE=1 -D_POSIX_PTHREAD_SEMANTICS=1 -D_TANDEM_SOURCE=1 -DPACKAGE=\"xcb-util-xrm\" -DVERSION=\"1.0\" -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DPACKAGE_VERSION_MAJOR=1 -DPACKAGE_VERSION_MINOR=0 -DPACKAGE_VERSION_PATCHLEVEL=0 -I. -I./include/ -Wdate-time -D_FORTIFY_SOURCE=2 -Wall -Wpointer-arith -Wmissing-declarations -Wformat=2 -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wbad-function-cast -Wold-style-definition -Wdeclaration-after-statement -Wunused -Wuninitialized -Wshadow -Wmissing-noreturn -Wmissing-format-attribute -Wredundant-decls -Wlogical-op -Werror=implicit -Werror=nonnull -Werror=init-self -Werror=main -Werror=missing-braces -Werror=sequence-point -Werror=return-type -Werror=trigraphs -Werror=array-bounds -Werror=write-strings -Werror=address -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast -fno-strict-aliasing -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -c -o tests/tests_tests_match-tests_utils.o `test -f 'tests/tests_utils.c' || echo './'`tests/tests_utils.c
gcc -DPACKAGE_NAME=\"xcb-util-xrm\" -DPACKAGE_TARNAME=\"xcb-util-xrm\" -DPACKAGE_VERSION=\"1.0\" -DPACKAGE_STRING=\"xcb-util-xrm\ 1.0\" -DPACKAGE_BUGREPORT=\"[email protected]\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -D__EXTENSIONS__=1 -D_ALL_SOURCE=1 -D_GNU_SOURCE=1 -D_POSIX_PTHREAD_SEMANTICS=1 -D_TANDEM_SOURCE=1 -DPACKAGE=\"xcb-util-xrm\" -DVERSION=\"1.0\" -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DPACKAGE_VERSION_MAJOR=1 -DPACKAGE_VERSION_MINOR=0 -DPACKAGE_VERSION_PATCHLEVEL=0 -I. -I./include/ -Wdate-time -D_FORTIFY_SOURCE=2 -Wall -Wpointer-arith -Wmissing-declarations -Wformat=2 -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wbad-function-cast -Wold-style-definition -Wdeclaration-after-statement -Wunused -Wuninitialized -Wshadow -Wmissing-noreturn -Wmissing-format-attribute -Wredundant-decls -Wlogical-op -Werror=implicit -Werror=nonnull -Werror=init-self -Werror=main -Werror=missing-braces -Werror=sequence-point -Werror=return-type -Werror=trigraphs -Werror=array-bounds -Werror=write-strings -Werror=address -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast -fno-strict-aliasing -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -c -o tests/tests_tests_match-tests_match.o `test -f 'tests/tests_match.c' || echo './'`tests/tests_match.c
tests/tests_match.c:32:26: fatal error: X11/Xlib-xcb.h: No such file or directory
compilation terminated.
I think a check should be added to configure.
The current implementation of file_get_contents()
gets the file size, allocates a buffer and then does a loop where it copies data from the file into the buffer. The file size could change while reading the file, leading to a buffer overflow.
I would suggest the following (untested) implementation:
char *file_get_contents(const char *filename) {
int fd;
struct stat stbuf;
char *content;
size_t file_size;
if ((fd = fopen(filename, O_RDONLY)) < 0)
return NULL;
if (fstat(fd, &stbuf) < 0) {
close(fd);
return NULL;
}
file_size = stbuf.st_size;
content = scalloc(file_size, 1);
if (read(fd, content, file_size) != file_size) {
FREE(content);
close(fd);
return NULL;
}
close(fd);
content[file_size] = '\0';
return content;
}
We currently allocate several buffers to a fixed size, but don't prevent overflows. This should be fixed.
The tests currently all reside in tests/test.c
and use both public and non-public API. It would be good to split tests for different functions up (with a common file for the utility functions). That also allows us to have separate test suites for public and non-public API.
Hi!
Could you upload a "dist" tarball for 1.3 so that packagers and end users don't have to run "autoreconf" by themselves?
@Airblader
Compilation fails with the above error on ubuntu 15.10. I installed all the dependencies in the wiki.
When building from the release packages, the user shall shall not be required to run git submodule update --init
.
See #33. We currently export way too many symbols. We need to rename all functions which we don't actually expose via the API by prefixing them so that they're not exported.
I'm using Chromebrew, by the way.
bash-4.3$ pwd
/usr/local/tmp/crew/v1.3.tar.gz.dir/xcb-util-xrm-1.3
bash-4.3$ ls
autogen.sh configure.ac COPYING Doxyfile include m4 Makefile.am README src tests
xcb_xrm_intro.in xcb-xrm.pc.in
bash-4.3$ ./autogen.sh
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal -I m4
/usr/local/share/aclocal/aalib.m4:12: warning: underquoted definition of AM_PATH_AALIB
/usr/local/share/aclocal/aalib.m4:12: run info Automake 'Extending aclocal'
/usr/local/share/aclocal/aalib.m4:12: or see https://www.gnu.org/software/automake/manual/automake.html#Extending-aclocal
autoreconf: configure.ac: tracing
autoreconf: configure.ac: not using Libtool
autoreconf: running: /usr/local/bin/autoconf
autoreconf: configure.ac: not using Autoheader
autoreconf: running: automake --add-missing --copy --no-force
configure.ac:10: installing './compile'
configure.ac:12: installing './install-sh'
configure.ac:12: installing './missing'
Makefile.am:24: error: Libtool library used but 'LIBTOOL' is undefined
Makefile.am:24: The usual way to define 'LIBTOOL' is to add 'LT_INIT'
Makefile.am:24: to 'configure.ac' and run 'aclocal' and 'autoconf' again.
Makefile.am:24: If 'LT_INIT' is in 'configure.ac', make sure
Makefile.am:24: its definition is in aclocal's search path.
Makefile.am: installing './depcomp'
Makefile.am:35: error: 'pkgconfig_DATA' is used but 'pkgconfigdir' is undefined
Makefile.am:26: error: 'xcbinclude_HEADERS' is used but 'xcbincludedir' is undefined
parallel-tests: installing './test-driver'
autoreconf: automake failed with exit status: 1
I can confirm that gettext
, autoconf
, automake
, libtool
, pkgconfig
, and xcb_util
are installed.
It looks like XrmMergeDatabases doesn't fail if the source database is NULL
, so neither should we.
The last component is case-sensitive, all others are case-insensitive.
See #33, relative filenames in #include
statements must be handled relative to the file they occur in, according to the specification.
Since we want to mimick Xlib, we should run testcases against it as well and compare the results.
When we parse a file, we should run the C preprocessor as well. This came up here:
https://www.reddit.com/r/i3wm/comments/76p3tg/color_scheme_not_loading_set_from_resource_upon/
Was working on making this for Deb. Cloned into a clean directory, update the m4 submodule, and ran the autogen. This spit out the error: possibly undefined macro: AC_PROG_LIBTOOL. I got the xorg-macros from xutils-dev so I don't believe there is any problem there.
Perhaps using m4_pattern_allow in the configure is the best way to 'legitimize the token'?
To prevent crashing machines due to faulty setup, we should limit the depth of #include
recursion. Let's use a depth of 100, just like Xlib.
The functions XGetDefault
, XrmGetDatabase
and XrmSetDatabase
should have an equivalent in xcb-util-xrm.
Add new APIs to load a database from disk and store an existing database to disk.
When loading from disk, we should learn to resolve include directives.
See #35
The following should be matched, but isn't:
Database: A*c*e: 42
Query: A.b.c.d.c.e: 42
xcb_xrm_resource_to_number
xcb_xrm_resource_to_bool
We should validate that the query for name and class have the same number of components (if a class string has been given). This must be true according to the spec.
I'm not 100% sure this is the right place to ask this, but: I'm attempting to install xcb-util-xrm
on Ubuntu 16.04, and I added the aguinard PPA. Then I ran sudo apt update
, and finally sudo apt install xcb-util-xrm
. However, when I ran the final command, I got that the package could not be located...Am I doing something glaringly wrong, or is something up with the PPA? That's the same process I've used for PPAs in the past...
Thanks!
Unsure if this is a xlib not following spec or not, but setting this in RM database:
*.dpi: 133
and then requesting: rofi.dpi
worked. but not when using xcb-util-xrm.
This test will show it:
diff --git a/tests/tests_match.c b/tests/tests_match.c
index 345b9ca..e9b45f8 100644
--- a/tests/tests_match.c
+++ b/tests/tests_match.c
@@ -75,6 +75,7 @@ static int test_get_resource(void) {
err |= check_get_resource("First*?.third: 1", "First.third", "", NULL, false);
err |= check_get_resource("First: 1", "first", "", NULL, false);
err |= check_get_resource("First: 1", "", "first", NULL, false);
+ err |= check_get_resource("*.dpi: 133", "rofi.dpi", "rofi.dpi", "133", false);
/* Duplicate entries */
err |= check_get_resource(
"First: 1\n"
results in:
== Assert that getting resource <rofi.dpi> / <rofi.dpi> returns <133>
xcb_xrm_resource_get_string() returned NULL
Returned NULL, but Xlib returned <133>
(original bug here)
Handling allocation errors by calling err()
is simple, but bad, e.g. http://stackoverflow.com/questions/14199689/how-can-i-handle-exit-calls-in-3rd-party-library-code http://ubuntuforums.org/showthread.php?t=612606 (random google results).
Hi There, I'm trying to build this on ubuntu 16.04 because there's no package for it, git fails, but I saw they have http, going to their server here: https://cgit.freedesktop.org/?q=xcb%2Futil-common-m4
and clicking the result comes up 404 not found, so your package won't build for me
Am I doing something wrong?
We need to filter duplicate entries.
I am having trouble installing xcb-util-xrm which I need for installing rofi for i3. I ran git clone --recursive https://github.com/Airblader/xcb-util-xrm.git (as specified on the xcb-util git page) then ran libtoolize, aclocal, ./autogen.sh but I receive an error:
./autogen.sh
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal -I m4
autoreconf: configure.ac: tracing
autoreconf: running: libtoolize --copy
autoreconf: running: /usr/bin/autoconf
autoreconf: configure.ac: not using Autoheader
autoreconf: running: automake --add-missing --copy --no-force
configure.ac:16: error: required file '../ltmain.sh' not found
autoreconf: automake failed with exit status: 1
I have tried copying ltmain.sh from /usr/share/libtool/config/ to the xcb-util folder manually but it still produces the same error. Says the file is not there even when it is! I have even changed the permissions on the file to be executable thinking that may help, but nothing doing. I have searched online for a fix, reading through multiple sites to no avail, nothing I have tried produces a fix, this is extremely frustrating and I have no idea where the problem is. Please help.
See #33. The entry parser could be refactored to work on a token-by-token basis, something like strtok
. In particular, the boolean resource_only
flag isn't very pretty at the moment.
This issue serves as a sync point for a review by anyone who wants to review. Please add any comment here and/or create issues for it. Please also note when you are done with the review.
The idea of this is to have this new library reviewed before a first stable release to avoid breakage.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.