Commit graph

21 commits

Author SHA1 Message Date
Bryce Harrington 6c6164c5ba shared: Update boilerplate from MIT X11 license to MIT Expat license 2015-06-15 13:04:18 -07:00
Pekka Paalanen 6c71aaeec5 Pass config file from compositor to everything
We have the Weston command line option '--no-config' which is meant to
prevent loading weston.ini at all. It works for Weston itself, but it
does not work for any clients that also want to read weston.ini.

To fix that, introduce a new environment variable WESTON_CONFIG_FILE.
Weston will set it to the absolute path of the config file it loads.
Clients will load the config file pointed to by WESTON_CONFIG_FILE. If
the environment variable is set but empty, no config file will be
loaded. If the variable is unset, things fall back to the default
"weston.ini".

Note, that Weston will only set WESTON_CONFIG_FILE, it never reads it.
The ability to specify a custom config file to load will be another patch.

All programs that loaded "weston.ini" are modified to honour
WESTON_CONFIG_FILE.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
Reviewed-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-03-27 09:38:12 +02:00
Pekka Paalanen 49f6d62e9d shared: fail reading a directory as a config file
open() will happily open directories and other non-normal files.
Attempting to parse them as config files makes no sense, so check that
the opened file is indeed a regular file.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
Reviewed-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-03-27 09:38:02 +02:00
Derek Foreman c7210434d4 tests: allow running make check without make install
desktop shell and weston keyboard both refer to themselves prefixed by
LIBEXECDIR, however this is only valid once installed.  make check will
currently either fail or run pre-existing versions.

This patch adds a way to override that location by setting the env var
WESTON_BUILD_DIR - which is then set by the test env script so make check
will test the versions in the build directory regardless of whether they're
installed or not.

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-22 17:47:33 +03:00
Alexandru DAMIAN 5f42930a41 config: Don't crash if we don't have a config file
Adding a check in weston_config_full_path so that
we don't crash if we started without a config file.

Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
2013-09-26 16:24:33 -07:00
Kristian Høgsberg eeefc9e311 compositor: Log the full path of the config file we're using 2013-09-21 23:17:35 -07:00
Kristian Høgsberg 1abe0486bb config-parser: Make weston_config_parse() tkae a file name
Take a basename of the config file to parse instead of an fd.
2013-09-21 23:05:45 -07:00
Kristian Høgsberg 81c2c2eb5e shared: Remove no longer used parse_config_file() 2013-09-21 23:05:12 -07:00
Armin K b502f906db evdev-touchpad: Set some options using weston.ini
This patch adds 3 new options to weston.ini to allow
the user to change default constant_accel_factor,
min_accel_factor and max_accel_factor. If no options
are set, it falls back using defaults as it did before.

v2: create weston_config_section_get_double and use it
instead of manualy converting string to double.

v3: add default values in weston_config_get_double
instead of using conditionals.

v4: don't pass diagonal as pointer.
2013-08-12 22:42:17 -07:00
Quentin Glidic 6e2c12496b shared: Export configuration functions
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2013-07-03 18:28:59 -04:00
Daniel Stone c228e23b05 configure.ac: Enable AC_USE_SYSTEM_EXTENSIONS
AC_USE_SYSTEM_EXTENSIONS enables _XOPEN_SOURCE, _GNU_SOURCE and similar
macros to expose the largest extent of functionality supported by the
underlying system.  This is required since these macros are often
limiting rather than merely additive, e.g. _XOPEN_SOURCE will actually
on some systems hide declarations which are not part of the X/Open spec.

Since this goes into config.h rather than the command line, ensure all
source is consistently including config.h before anything else,
including system libraries.  This doesn't need to be guarded by a
HAVE_CONFIG_H ifdef, which was only ever a hangover from the X.Org
modular transition.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>

[pq: rebased and converted more files]
2013-06-05 01:16:34 -04:00
Mun Gwan-gyeong 7732540f71 config-parser: Avoid null dereference when exiting. (case: weston starts without config file.)
backtrace:
 (gdb) bt
 #0  0xb7704424 in __kernel_vsyscall ()
 #1  0xb757ddde in raise (sig=5) at ../nptl/sysdeps/unix/sysv/linux/pt-raise.c:42
 #2  <signal handler called>
 #3  weston_config_destroy (config=0x0) at config-parser.c:508
 #4  0xb75cbc0e in x11_destroy (ec=0x93506b0) at compositor-x11.c:1473
 #5  0x0804e0e9 in main (argc=1, argv=0xbffe5354) at compositor.c:3337
2013-05-28 15:30:27 -04:00
Mun Gwan-gyeong 151a52834e config-parser: Avoid null dereference when handling config-parser ( when weston starts without config file. )
backtrace:
 (gdb) bt
 #0  weston_config_next_section (config=0x0, section=0xbfb2b608, name=0xbfb2b618) at config-parser.c:485
 #1  0xb75b1371 in x11_compositor_create (config=0x1, argv=0xbfb2ba44, argc=<optimized out>, use_pixman=0, no_input=0, fullscreen=0, display=0xb75b55f9)
    at compositor-x11.c:1582
 #2  backend_init (display=0x8354490, argc=0xbfb2b9b0, argv=0xbfb2ba44, config=0x0) at compositor-x11.c:1674
 #3  0x0804df7b in main (argc=1, argv=0xbfb2ba44) at compositor.c:3289
2013-05-28 15:30:14 -04:00
Kristian Høgsberg f73f316248 config-parser: Add section iterator API
The X backend needs to iterate through all outputs.
2013-05-26 20:50:53 -04:00
Mun Gwan-gyeong 72a3ab7b85 config-parser: Avoid null dereference when handling config-parser
backtrace:
 (gdb) bt
 #0  weston_config_get_section (config=0x0, section=0x8062f31 "keyboard", key=0x0, value=0x0)
     at config-parser.c:265
 #1  0x080535a1 in weston_compositor_init (ec=0x905b690, display=0x9056490, argc=0xbf8bd2f0,
     argv=0xbf8bd384, config_fd=-1) at compositor.c:2819
 #2  0xb75d72bb in x11_compositor_create (config_fd=-1, argv=0xbf8bd384, argc=<optimized out>,
     use_pixman=0, no_input=0, fullscreen=0, display=0x9056490) at compositor-x11.c:1527
 #3  backend_init (display=0x9056490, argc=0xbf8bd2f0, argv=0xbf8bd384, config_fd=-1)
     at compositor-x11.c:1746
2013-05-26 20:07:47 -04:00
Kristian Høgsberg 732747114a Add new config parser
The current config parser, parses the ini file and pulls out the values
specified by the struct config_section passed to parse_config_file() and
then throw the rest away.  This means that every place we want to get
info out of the ini file, we have to parse the whole thing again.  It's not
a big overhead, but it's also not a convenient API.

This patch adds a parser that parses the ini file to a data structure and
puts that in weston_compositor->config along with API to query comfig
keys from the data structure.  The old parser is still available, but
we'll transition to the new approach over the next few commits.
2013-05-23 21:25:42 -04:00
Ossama Othman a50e6e4c50 config-parser: Honor XDG_CONFIG_DIRS
This set of changes adds support for searching for a given config file
in the directories listed in $XDG_CONFIG_DIRS if it wasn't found in
$XDG_CONFIG_HOME or ~/.config.  This allows packages to install custom
config files in /etc/xdg/weston, for example, thus allowing them to
avoid dealing with home directories.

To avoid a TOCTOU race the config file is actually open()ed during the
search.  Its file descriptor is returned and stored in the compositor
for later use when performing subsequent config file parses.

Signed-off-by: Ossama Othman <ossama.othman@intel.com>
2013-05-14 14:36:37 -04:00
Kristian Høgsberg 3d89049546 config-parser: Handle lines that don't end in \n
If the last line in a config file doesn't have a newline
we end up chopping off the last character from that line.
2012-08-03 21:56:41 -04:00
Pekka Paalanen 4ea4d1bb39 config-parser: add missing return for an error case
Fixes
config-parser.c: In function 'handle_key':
config-parser.c:81: error: control reaches end of non-void function

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-04-17 14:33:30 +03:00
Scott Moreau fa1de69203 Implement CONFIG_KEY_UNSIGNED_INTEGER
strtol() does not work when trying to assign 32 bits of data into a
regular signed int on 32 bit systems. Use corresponding strtoul()
instead.
2012-01-27 15:34:27 -05:00
Kristian Høgsberg 9b935c8239 Use '-' to separate words in file names
Eventually we will want more functionality in the shared library and we
will rename it at that point.  Perhaps we'll name it libnih, but for now
let's stick with libconfig-parser.
2011-12-08 12:44:27 -05:00
Renamed from shared/configparser.c (Browse further)