summaryrefslogtreecommitdiff
path: root/hw/xfree86/parser
AgeCommit message (Collapse)AuthorFilesLines
2011-11-23Convert strncpy/strncat to strlcpy/strlcatAlan Coopersmith1-2/+4
As long as we're carrying around a compatibility copy in os/strl*.c, might as well use them. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-10-31xfree86: fix potential buffer overflowServaas Vandenberghe1-4/+13
The patch below fixes a potential buffer overflow in xf86addComment(). This occurs if curlen > 0 && eol_seen == 0 && iscomment == 0 , as follows from the code: char *xf86addComment(char *cur, char *add) <...> len = strlen(add); endnewline = add[len - 1] == '\n'; len += 1 + iscomment + (!hasnewline) + (!endnewline) + eol_seen; if ((str = realloc(cur, len + curlen)) == NULL) return cur; cur = str; if (eol_seen || (curlen && !hasnewline)) cur[curlen++] = '\n'; if (!iscomment) cur[curlen++] = '#'; strcpy(cur + curlen, add); if (!endnewline) strcat(cur, "\n"); Signed-off-by: Servaas Vandenberghe <vdb@picaros.org> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> [whot: added buffer overflow test case] Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-10-25input: switch InputOption to use XF86OptionRec storage.Peter Hutterer2-3/+4
Use the same struct for both InputOption and XF86OptionRec so we don't need to convert to and fro the two in the config backends. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Dan Nicholson <dbn.lists@gmail.com> Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-09-29Remove unused vtSysreqAlexandr Shadchin1-2/+0
Signed-off-by: Alexandr Shadchin <Alexandr.Shadchin@gmail.com> Reviewed-by: Jamey Sharp <jamey@minilop.net> Tested-by: Matthieu Herrb <matthieu.herrb@laas.fr>
2011-09-27xfree86: switch options from pointer to XF86OptionPtrPeter Hutterer2-24/+3
In all cases, the pointer was simply type-cast anyway. Let's get some compile-time type safety going, how about that. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Dan Nicholson <dbn.lists@gmail.com> Squashed in: xfree86: Move definition of xf86OptionPtr into separate header file The pile of spaghettis that is the xfree86 include dependencies make it rather hard to have a single typedef somewhere that's not interfering with everything else or drags in a whole bunch of other includes. Move the xf86OptionRec and GenericListRec declarations into a separate header. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2011-05-25xfree86: Allow "MatchLayout" statements in config filesOleh Nykyforchyn3-0/+23
Usage example (tested on a dual-seat PC): Section "InputClass" Identifier "keyboard-all" MatchIsKeyboard "on" MatchDevicePath "/dev/input/event*" MatchLayout "!GeForce|!Matrox" Driver "evdev" Option "XkbLayout" "us" Option "XkbOptions" "terminate:ctrl_alt_bksp" EndSection It disables auto keyboard configuration for layouts "GeForce" and "Matrox". Note that "" in patterns means "no Layout sections found", e.g. MatchLayout "GeForce|" is "in layout GeForce or without explicit layout at all". Signed-off-by: Oleh Nykyforchyn <oleh.nyk@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Acked-by: Dan Nicholson <dbn.lists@gmail.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-03-28xfree86: warning fixAdam Jackson1-1/+1
Pointer.c: In function 'xf86parsePointerSection': Pointer.c:192:5: warning: format '%u' expects type 'unsigned int', but argument 3 has type 'long unsigned int' Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Adam Jackson <ajax@redhat.com>
2011-03-14Consolidate all the PATH_MAX handling into misc.hChristopher James Halse Rogers1-8/+3
Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
2011-01-08xfree86: Convert libxf86config to static libtool libraryDan Nicholson1-3/+4
In order to use libxf86config in a shared library, all the code must be compiled with -fPIC. Add proper PIC support for libxf86config by turning it into a libtool library. However, since we don't want to guarantee API or ABI stability, make sure it's only built static. Signed-off-by: Dan Nicholson <dbn.lists@gmail.com> Acked-by: Gaetan Nadon <memsize@videotron.ca>
2010-12-18Bug 32436 - hw/xfree86/parser/Makefile.am TOP_SRCDIR should be top_srcdirAlan Coopersmith1-1/+1
https://bugs.freedesktop.org/show_bug.cgi?id=32436 Fix typo introduced in 2416255f7e3fd9190a9 that breaks builds when configured --enable-install-libxf86config Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Julien Cristau <jcristau@debian.org> Tested-by: Simon Thum <simon.thum@gmx.de>
2010-12-07Convert hw/xfree86/parser code to use asprintf() callsAlan Coopersmith3-19/+11
Requires linking xprintf.c into libxf86config for those who build it. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net>
2010-11-10xfree86: parser: Remove 'CUSTOM' flag option in Monitor section.Jesse Adkins3-9/+0
Not used in the initial import, and also not documented. Signed-off-by: Jesse Adkins <jesserayadkins@gmail.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2010-10-18dri1: Remove "buffers" from the config logicAdam Jackson3-76/+0
This was only ever used from the glint driver, which has since lost its DRI support. Reviewed-by: Matt Turner <mattst88@gmail.com> Signed-off-by: Adam Jackson <ajax@redhat.com>
2010-10-18xfree86: Remove %M expansion from config parserAdam Jackson1-14/+0
This was to distinguish XFree86 3.x files from XFree86 4.x files. It never really made sense to be looking for xorg.conf-4. Reviewed-by: Matt Turner <mattst88@gmail.com> Reviewed-by: Dan Nicholson <dbn.lists@gmail.com> Reviewed-by: Jesse Adkins <jesserayadkins@gmail.com> Signed-off-by: Adam Jackson <ajax@redhat.com>
2010-10-18xfree86: Remove an open-coded strtoul()Adam Jackson1-48/+1
Reviewed-by: Matt Turner <mattst88@gmail.com> Reviewed-by: Dan Nicholson <dbn.lists@gmail.com> Signed-off-by: Adam Jackson <ajax@redhat.com>
2010-09-10os/xfree86: remove macro checking for POSIX symbolsTiago Vignatti1-4/+0
We assume already that our X implementation is POSIX compliant anyway. So remove those redundant checking. SA_SIGINFO is left there. Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com> Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com> Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2010-08-27Replace malloc/strlen/strcpy with strdup.Matt Turner2-8/+3
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com> Signed-off-by: Matt Turner <mattst88@gmail.com>
2010-08-27xfree86: Purge parsePrologueVoid.Jesse Adkins1-3/+0
This was included in the original commit, and then never used. Signed-off-by: Jesse Adkins <jesserayadkins@gmail.com> Signed-off-by: Matt Turner <mattst88@gmail.com>
2010-08-27xfree86: Removed unused messages from Configint.hJesse Adkins1-6/+0
AUTOREPEAT_MSG, MOVED_TO_FLAGS_MSG, and XLEDS_MSG made obsolete by 81913a12910e39d7ea6af8657c1c66cc6791cd65 Jul 21 2006 (remove undead files from master) UNDEFINED_DEVICE_MSG made obsolete by 6033d8150be3a115b90226eaa42f237bb0cf3369 Oct 9 2007 (first pass at video driver autoloading) Signed-off-by: Jesse Adkins <jesserayadkins@gmail.com> Signed-off-by: Matt Turner <mattst88@gmail.com>
2010-08-27xfree86: Fix leaks in OpenConfigFile and OpenConfigDirJesse Adkins1-0/+2
[mattst88: fixed whitespace and a missing semicolon] Signed-off-by: Jesse Adkins <jesserayadkins@gmail.com> Signed-off-by: Matt Turner <mattst88@gmail.com>
2010-08-27xfree86: Remove comments about unable to use malloc.Jesse Adkins1-2/+0
These are leftovers from when X still used Xmalloc and friends for allocation. Now that those are gone, these comments are just confusing. Signed-off-by: Jesse Adkins <jesserayadkins@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Matt Turner <mattst88@gmail.com>
2010-08-13xfree86: parser: Never use constant strings for driver names (fixes #17438)Jesse Adkins2-4/+9
When the parser sees the "keyboard" driver, it automatically (and silently) replaces it with the constant string "kbd". Everybody else uses malloc'd memory for the driver name, so input device closure assumes it can use free. Free val.str, so this crash doesn't turn into a memory leak. Whew. Signed-off-by: Jesse Adkins <jesserayadkins@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-06-10Merge remote branch 'whot/for-keith'Keith Packard3-43/+172
2010-06-11xfree86: Match devices based on current driver settingDan Nicholson3-0/+23
Often we want to apply a driver specific option to a set of devices and don't care how the driver was selected for that device. The MatchDriver entry can be used to match the current driver string: MatchDriver "evdev|mouse" Option "Emulate3Buttons" "yes" The driver string is a case sensitive match. Signed-off-by: Dan Nicholson <dbn.lists@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-06-11xfree86: Allow multiple InputClass Match* entries for && matchingDan Nicholson2-73/+116
Currently when there multiple InputClass entries of the same type, only the last entry is used and the previous ones are ignored. Instead, multiple entries are used to create multiple matching conditions. For instance, an InputClass with MatchProduct "foo" MatchProduct "bar" will require that the device's product name contain both foo and bar. This provides a complement to the || style matching when an entry is split using the "|" token. The xorg.conf man page has added an example to hopefully clarify the two types of compound matches. Signed-off-by: Dan Nicholson <dbn.lists@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-06-11xfree86: Match devices based on USB IDDan Nicholson3-0/+21
Sometimes the vendor and product names aren't specific enough to target a USB device, so expose the numeric codes in the ID. A MatchUSBID entry has been added that supports shell pattern matching when fnmatch(3) is available. For example: MatchUSBID "046d:*" The IDs are stored in lowercase hex separated by a ':' like "lsusb" or "lspci -n". Signed-off-by: Dan Nicholson <dbn.lists@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-06-11xfree86: Match devices based on PnP IDDan Nicholson3-0/+21
Serial input devices lack properties such as product or vendor name. This makes matching InputClass sections difficult. Add a MatchPnPID entry to test against the PnP ID of the device. The entry supports a shell pattern match on platforms that support fnmatch(3). For example: MatchPnPID "WACf*" A match type for non-path pattern matching, match_pattern, has been added. The difference between this and match_path_pattern is the FNM_PATHNAME flag in fnmatch(3). Signed-off-by: Dan Nicholson <dbn.lists@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-06-10Remove unnecessary parentheses around return values in functionsMikhail Gusarov10-70/+70
This patch was generated by the following Perl code: perl -i -pe 's/([^_])return\s*\(\s*([^(]+?)\s*\)s*;(\s+(\n))?/$1return $2;$4/g;' Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net> Reviewed-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Signed-off-by: Keith Packard <keithp@keithp.com>
2010-06-10xfree86: Add MatchOS InputClass entry for operating system matchingDan Nicholson3-0/+21
Allow InputClass sections to match against the running operating system to narrow the application of rules. An example where this could be used is to specify that the default input driver on Linux is evdev while it's mouse/kbd everywhere else. The operating system name is the same as `uname -s`, and matching is case-insensitive. Signed-off-by: Dan Nicholson <dbn.lists@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-06-06Remove more superfluous if(p) checks around free(p)Mikhail Gusarov2-6/+3
This patch has been generated by the following Coccinelle semantic patch: @@ expression E; @@ -if(E) { free(E); } +free(E); Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net> Reviewed-by: Julien Cristau <jcristau@debian.org> Reviewed-by: Fernando Carrijo <fcarrijo@yahoo.com.br> Reviewed-by: Matt Turner <mattst88@gmail.com>
2010-06-04Stop searching for XF86Config filesAlan Coopersmith1-5/+1
xorg.conf has been used since the X11R6.7 release in April 2004. 6 years has been a generous transition period for users to "mv XF86Config xorg.conf" and for distros to update their configuration tools and packages. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: James Cloos <cloos@jhcloos.com> Signed-off-by: Keith Packard <keithp@keithp.com>
2010-06-04Stop searching for XF86Config filesAlan Coopersmith1-16/+7
xorg.conf has been used since the X11R6.7 release in April 2004. 6 years has been a generous transition period for users to "mv XF86Config xorg.conf" and for distros to update their configuration tools and packages. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: James Cloos <cloos@jhcloos.com> Signed-off-by: Keith Packard <keithp@keithp.com>
2010-04-21xfree86: check for NULL pointer before dereferences it in parser codeTiago Vignatti1-2/+5
Seems to be harmless. Meh. Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
2010-04-21xfree86: fix not reached code in parserTiago Vignatti1-2/+2
...because Error is a macro that returns NULL. Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com> Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
2010-04-08xfree86: Allow adding sysconfdir and datadir to config search pathsDan Nicholson2-1/+17
We could just use $projectroot/etc and $projectroot/share, but the user might have other plans for them. Signed-off-by: Dan Nicholson <dbn.lists@gmail.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-02-17parser: corrected xf86getBoolValue to use case insensitive compareOliver McFadden1-8/+8
commit c6e8637e29e0ca11dfb35c02da7ca6002ac8c597 introduced this regression; it can cause existing config files to be parsed incorrectly. Acked-by: Julien Cristau <jcristau@debian.org> Reviewed-by: Dan Nicholson <dbn.lists@gmail.com> Signed-off-by: Oliver McFadden <oliver.mcfadden@nokia.com> Signed-off-by: Keith Packard <keithp@keithp.com>
2010-02-11Add tag matching to input attributes.Peter Hutterer3-0/+21
Tags may be a list of comma-separated strings that match against a MatchTag InputClass section. If any of the tags specified for a device match against the MatchTag of the section, this match is evaluated true and passed on to the next match condition. Tags are specified as "input.tags" (hal) or "ID_INPUT.tags" (udev), the value of the tags is case-sensitive and require an exact match (not a substring match). i.e. "quirk" will not match "QUIRK", "need_quirk" or "quirk_needed". Example configuration: udev: ENV{ID_INPUT.tags}="foo,bar" hal: <merge key="input.tags" type="string">foo,bar</merge> xorg.conf: Section "InputClass" Identifier "foobar quirks" MatchTag "foo|foobar" Option "Foobar" "on" EndSection Where the xorg.conf section matches against any device with the tag "foo" or tag "foobar" set. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Tested-by: Dan Nicholson <dbn.lists@gmail.com> Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
2010-02-11Add xstrtokenize to the dix.Peter Hutterer1-41/+3
Move tokenize out of the parser, make it a dix util function instead. Splitting a string into multiple substrings is useful by other places, so let's use it across the line. Future users include config/hal, config/udev and of course the parser. Example usage: char **substrings = xstrtokenize(my_string, "\n"); Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
2010-02-11xfree86: Allow multiple arguments to InputClass matchesDan Nicholson2-15/+90
In order to keep the number of InputClass sections manageable, allow matches to contain multiple arguments. The arguments will be separated by the '|' character. This allows a policy to apply to multiple types of devices. For example: Section "InputClass" Identifier "Inverted Mice" MatchProduct "Crazy Mouse|Silly Mouse" Option "InvertX" "yes" EndSection This applies to the MatchProduct, MatchVendor and MatchDevicePath entries. Currently there is no way to escape characters, so names or patterns cannot contain '|'. Signed-off-by: Dan Nicholson <dbn.lists@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-02-11xfree86: Handle config files ending without newlineDan Nicholson1-7/+19
The config parser expects to find a newline at the end of each line, so files ending without one would confuse it. A newline is inserted at the end of the buffer in these situations. Additionally, switching to the next config file is moved to the higher level to allow parsing of the last line of the previous file to complete before shifting the index and resetting the line number. Signed-off-by: Dan Nicholson <dbn.lists@gmail.com> Tested-by: Stephan Raue<stephan.raue@gmx.net> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-12-30Merge remote branch 'dbn/inputclass'Keith Packard9-1/+320
2009-12-23xfree86: Introduce InputClass configurationDan Nicholson7-1/+279
Currently Xorg uses hal's fdi files to decide what configuration options are applied to automatically added input devices. This is sub-optimal since it requires users to use a new and different configuration store than xorg.conf. The InputClass section attempts to provide a system similar to hal where configuration can be applied to all devices with certain attributes. For now, devices can be matched to: * A substring of the product name via a MatchProduct entry * A substring of the vendir name via a MatchVendor entry * A pathname pattern of the device file via a MatchDevicePath entry * A device type via boolean entries for MatchIsKeyboard, MatchIsPointer, MatchIsJoystick, MatchIsTablet, MatchIsTouchpad and MatchIsTouchscreen See the INPUTCLASS section in xorg.conf(5) for more details. Signed-off-by: Dan Nicholson <dbn.lists@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-12-22xfree86: Support non-Option boolean entries in configurationDan Nicholson3-0/+41
Refactored code into the parser to allow the freeform boolean types used in Option entries to be used in other configuration entries. This isn't as powerful as allowing "No" to precede the option names, but it atleast gives a common handling of "yes", "no", etc. A type xf86TriState has been added to support an optional boolean. This allows the boolean sense of the value to be kept while providing a means to signal that it is unset. Signed-off-by: Dan Nicholson <dbn.lists@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
2009-12-22xfree86: Add Option AutoServerLayout for input devices.Peter Hutterer2-17/+63
Any input device with this option will be automatically added to whichever server layout is selected at startup. This removes the need to reference a device from the ServerLayout section. The two following configuration are identical: CONFIG 1: Section "ServerLayout" InputDevice "foo" EndSection Section "InputDevice" Identifier "foo" ... EndSection CONFIG 2: Section "InputDevice" Identifier "foo" Option "AutoServerLayout" "on" ... EndSection The selection of the server layout affects both explicitly specified layouts and the implicit layout. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Keith Packard <keithp at keithp.com>
2009-12-22xfree86: Allow config directory to be specified on command lineDan Nicholson1-4/+13
Add a new command line parameter, -configdir, to specify the config directory to be used. Rules are the same as -config for root vs. user privileges. Signed-off-by: Dan Nicholson <dbn.lists@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
2009-12-22xfree86: Use xorg.conf.d directory for multiple config filesDan Nicholson2-86/+238
Currently there is a single file, xorg.conf, for configuring the server. This works fine most of the time, but it becomes a problem when packages or system services need to adjust the configuration. Instead, allow multiple configuration files to live in a directory. Typically this will be /etc/X11/xorg.conf.d. Files with a suffix of .conf will be read and added to the server configuration after xorg.conf. The server won't fall back to using the auto configuration unless there is no config file and there are no files in the config directory. Right now this uses a simpler search template than the config file search path by not using the command line or environment variable parameters. The matching code was refactored a bit to make this more coherent. Any DDX wanting to read the config files will need to call xf86initConfigFiles before opening/reading them. This is to allow xf86openConfigFile without xf86openConfigDirFiles and vice-versa. Signed-off-by: Dan Nicholson <dbn.lists@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
2009-12-22xfree86: Unexport configuration file symbolsDan Nicholson1-7/+7
These functions should not be used outside of DDXs, so no need to put them in the ABI. Signed-off-by: Dan Nicholson <dbn.lists@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
2009-12-22xfree86: remove some 'enable this later' and if 0 ifdefsPeter Hutterer2-28/+0
2003 called, they want their ifdefs back. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Keith Packard <keithp@keithp.com>
2009-10-28Don't cast double to int: use default conversions or explicitly round.Jamey Sharp1-1/+1
GCC warns about casting a double return value to int. Signed-off-by: Jamey Sharp <jamey@minilop.net> Signed-off-by: Keith Packard <keithp@keithp.com>
2009-08-07parser: make libxf86config_internal.la not installed.Dave Airlie1-1/+1