diff options
author | marha <marha@users.sourceforge.net> | 2011-10-26 10:58:41 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2011-10-26 10:58:41 +0200 |
commit | 4f005bade376d15ee60e90ca45a831aff9725087 (patch) | |
tree | 5abdbe5a7c55acf9e30c533414796f629fa9e47c /xorg-server/hw/xfree86 | |
parent | 9f986778bd4393c5a9108426969d45aa7f10f334 (diff) | |
download | vcxsrv-4f005bade376d15ee60e90ca45a831aff9725087.tar.gz vcxsrv-4f005bade376d15ee60e90ca45a831aff9725087.tar.bz2 vcxsrv-4f005bade376d15ee60e90ca45a831aff9725087.zip |
libX11 libXft mesa mkfontscale pixman xserver git update 26 okt 2011
Diffstat (limited to 'xorg-server/hw/xfree86')
-rw-r--r-- | xorg-server/hw/xfree86/common/xf86Config.c | 16 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/common/xf86Events.c | 9 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/common/xf86Helper.c | 6 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/common/xf86Init.c | 29 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/common/xf86Option.c | 3 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/common/xf86Optionstr.h | 13 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/common/xf86Xinput.c | 5 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/doc/ddxDesign.xml | 4 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/loader/loadmod.c | 41 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/man/xorg.conf.man | 4 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/modes/xf86Crtc.c | 66 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/os-support/linux/lnx_init.c | 14 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/parser/Flags.c | 1009 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/parser/Layout.c | 1116 |
14 files changed, 1152 insertions, 1183 deletions
diff --git a/xorg-server/hw/xfree86/common/xf86Config.c b/xorg-server/hw/xfree86/common/xf86Config.c index 5c46152b2..cb4be4210 100644 --- a/xorg-server/hw/xfree86/common/xf86Config.c +++ b/xorg-server/hw/xfree86/common/xf86Config.c @@ -1194,8 +1194,12 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout) if (Pointer) foundPointer = configInput(Pointer, confInput, from); if (foundPointer) { - Pointer->options = xf86addNewOption(Pointer->options, - xnfstrdup("CorePointer"), "on"); + Pointer->options = xf86AddNewOption(Pointer->options, + "CorePointer", "on"); + Pointer->options = xf86AddNewOption(Pointer->options, + "driver", confInput->inp_driver); + Pointer->options = xf86AddNewOption(Pointer->options, + "identifier", confInput->inp_identifier); servlayoutp->inputs = addDevice(servlayoutp->inputs, Pointer); } } @@ -1284,8 +1288,12 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout) if (Keyboard) foundKeyboard = configInput(Keyboard, confInput, from); if (foundKeyboard) { - Keyboard->options = xf86addNewOption(Keyboard->options, - xnfstrdup("CoreKeyboard"), "on"); + Keyboard->options = xf86AddNewOption(Keyboard->options, + "CoreKeyboard", "on"); + Keyboard->options = xf86AddNewOption(Keyboard->options, + "driver", confInput->inp_driver); + Keyboard->options = xf86AddNewOption(Keyboard->options, + "identifier", confInput->inp_identifier); servlayoutp->inputs = addDevice(servlayoutp->inputs, Keyboard); } } diff --git a/xorg-server/hw/xfree86/common/xf86Events.c b/xorg-server/hw/xfree86/common/xf86Events.c index c4a4db9be..41ffabde3 100644 --- a/xorg-server/hw/xfree86/common/xf86Events.c +++ b/xorg-server/hw/xfree86/common/xf86Events.c @@ -601,16 +601,15 @@ xf86AddGeneralHandler(int fd, InputHandlerProc proc, pointer data) InputHandlerProc xf86SetConsoleHandler(InputHandlerProc proc, pointer data) { - static InputHandlerProc handler = NULL; - InputHandlerProc old_handler = handler; + static IHPtr handler = NULL; + IHPtr old_handler = handler; if (old_handler) xf86RemoveGeneralHandler(old_handler); - xf86AddGeneralHandler(xf86Info.consoleFd, proc, data); - handler = proc; + handler = xf86AddGeneralHandler(xf86Info.consoleFd, proc, data); - return old_handler; + return (old_handler) ? old_handler->ihproc : NULL; } static void diff --git a/xorg-server/hw/xfree86/common/xf86Helper.c b/xorg-server/hw/xfree86/common/xf86Helper.c index cf577522a..d99522cf6 100644 --- a/xorg-server/hw/xfree86/common/xf86Helper.c +++ b/xorg-server/hw/xfree86/common/xf86Helper.c @@ -1553,13 +1553,7 @@ xf86LoadOneModule(char *name, pointer opt) void xf86UnloadSubModule(pointer mod) { - /* - * This is disabled for now. The loader isn't smart enough yet to undo - * relocations. - */ -#if 0 UnloadSubModule(mod); -#endif } Bool diff --git a/xorg-server/hw/xfree86/common/xf86Init.c b/xorg-server/hw/xfree86/common/xf86Init.c index 74e0bc220..a0fdf29ad 100644 --- a/xorg-server/hw/xfree86/common/xf86Init.c +++ b/xorg-server/hw/xfree86/common/xf86Init.c @@ -811,21 +811,6 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv) NULL); } -static InputInfoPtr -duplicateDevice(InputInfoPtr pInfo) -{ - InputInfoPtr dup = calloc(1, sizeof(InputInfoRec)); - if (dup) { - dup->name = strdup(pInfo->name); - dup->driver = strdup(pInfo->driver); - dup->options = xf86OptionListDuplicate(pInfo->options); - /* type_name is a const string */ - dup->type_name = pInfo->type_name; - dup->fd = -1; - } - return dup; -} - /** * Initialize all supported input devices present and referenced in the * xorg.conf. @@ -842,20 +827,8 @@ InitInput(int argc, char **argv) /* Initialize all configured input devices */ for (pInfo = xf86ConfigLayout.inputs; pInfo && *pInfo; pInfo++) { - InputInfoPtr dup; - /* Replace obsolete keyboard driver with kbd */ - if (!xf86NameCmp((*pInfo)->driver, "keyboard")) { - strcpy((*pInfo)->driver, "kbd"); - } - - /* Data passed into xf86NewInputDevice will be freed on shutdown. - * Duplicate from xf86ConfigLayout.inputs, otherwise we don't have any - * xorg.conf input devices in the second generation - */ - dup = duplicateDevice(*pInfo); - /* If one fails, the others will too */ - if (xf86NewInputDevice(dup, &dev, TRUE) == BadAlloc) + if (NewInputDeviceRequest((*pInfo)->options, NULL, &dev) == BadAlloc) break; } diff --git a/xorg-server/hw/xfree86/common/xf86Option.c b/xorg-server/hw/xfree86/common/xf86Option.c index 73b6573f1..9c528782f 100644 --- a/xorg-server/hw/xfree86/common/xf86Option.c +++ b/xorg-server/hw/xfree86/common/xf86Option.c @@ -44,6 +44,7 @@ #include "xf86Xinput.h" #include "xf86Optrec.h" #include "xf86Parser.h" +#include "optionstr.h" static Bool ParseOptionValue(int scrnIndex, XF86OptionPtr options, OptionInfoPtr p, Bool markUsed); @@ -298,7 +299,7 @@ xf86CheckPercentOption(XF86OptionPtr optlist, const char *name, double deflt) return LookupPercentOption(optlist, name, deflt, FALSE); } /* - * addNewOption() has the required property of replacing the option value + * xf86AddNewOption() has the required property of replacing the option value * if the option is already present. */ XF86OptionPtr diff --git a/xorg-server/hw/xfree86/common/xf86Optionstr.h b/xorg-server/hw/xfree86/common/xf86Optionstr.h index 8cc82d34c..fc9385617 100644 --- a/xorg-server/hw/xfree86/common/xf86Optionstr.h +++ b/xorg-server/hw/xfree86/common/xf86Optionstr.h @@ -24,16 +24,7 @@ #ifndef XF86OPTIONSTR_H #define XF86OPTIONSTR_H - -/* - * all records that need to be linked lists should contain a GenericList as - * their first field. - */ -typedef struct generic_list_rec -{ - void *next; -} -GenericListRec, *GenericListPtr, *glp; +#include "list.h" /* * All options are stored using this data type. @@ -48,6 +39,6 @@ typedef struct _XF86OptionRec } XF86OptionRec; -typedef struct _XF86OptionRec *XF86OptionPtr; +typedef struct _InputOption *XF86OptionPtr; #endif diff --git a/xorg-server/hw/xfree86/common/xf86Xinput.c b/xorg-server/hw/xfree86/common/xf86Xinput.c index ea1f92761..425b35957 100644 --- a/xorg-server/hw/xfree86/common/xf86Xinput.c +++ b/xorg-server/hw/xfree86/common/xf86Xinput.c @@ -68,6 +68,7 @@ #include "exglobals.h" #include "eventstr.h" #include "inpututils.h" +#include "optionstr.h" #include <string.h> /* InputClassMatches */ #ifdef HAVE_FNMATCH_H @@ -908,7 +909,7 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs, if (!pInfo) return BadAlloc; - nt_list_for_each_entry(option, options, next) { + nt_list_for_each_entry(option, options, list.next) { if (strcasecmp(input_option_get_key(option), "driver") == 0) { if (pInfo->driver) { rval = BadRequest; @@ -946,7 +947,7 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs, } } - nt_list_for_each_entry(option, options, next) { + nt_list_for_each_entry(option, options, list.next) { /* Copy option key/value strings from the provided list */ pInfo->options = xf86AddNewOption(pInfo->options, input_option_get_key(option), diff --git a/xorg-server/hw/xfree86/doc/ddxDesign.xml b/xorg-server/hw/xfree86/doc/ddxDesign.xml index a4baad557..0d5e952a2 100644 --- a/xorg-server/hw/xfree86/doc/ddxDesign.xml +++ b/xorg-server/hw/xfree86/doc/ddxDesign.xml @@ -189,7 +189,7 @@ following changes: <varlistentry><term><emphasis>Keyboard</emphasis></term> <listitem><literallayout> &k.identifier; "Implicit Core Keyboard" - &k.driver; "keyboard" + &k.driver; "kbd" </literallayout></listitem></varlistentry> <varlistentry><term><emphasis>Pointer</emphasis></term> <listitem><literallayout> @@ -206,7 +206,7 @@ following changes: is no &k.serverlayout; section, if the <option>-screen</option> command line options is used, or if the &k.serverlayout; section doesn't reference any &k.inputdevice; sections. In this case, the first - sections with drivers "keyboard" and "mouse" are used as the core + sections with drivers "kbd" and "mouse" are used as the core keyboard and pointer respectively. </para> </sect2> diff --git a/xorg-server/hw/xfree86/loader/loadmod.c b/xorg-server/hw/xfree86/loader/loadmod.c index 9f820993a..a21f43d63 100644 --- a/xorg-server/hw/xfree86/loader/loadmod.c +++ b/xorg-server/hw/xfree86/loader/loadmod.c @@ -94,6 +94,8 @@ const ModuleVersions LoaderVersionInfo = { ABI_FONT_VERSION }; +static int ModuleDuplicated[] = {}; + static void FreeStringList(char **paths) { @@ -785,7 +787,6 @@ ModuleDescPtr DuplicateModule(ModuleDescPtr mod, ModuleDescPtr parent) { ModuleDescPtr ret; - int errmaj, errmin; if (!mod) return NULL; @@ -794,14 +795,11 @@ DuplicateModule(ModuleDescPtr mod, ModuleDescPtr parent) if (ret == NULL) return NULL; - if (!(ret->handle = LoaderOpen(mod->path, &errmaj, &errmin))) { - free(ret); - return NULL; - } + ret->handle = mod->handle; ret->SetupProc = mod->SetupProc; ret->TearDownProc = mod->TearDownProc; - ret->TearDownData = NULL; + ret->TearDownData = ModuleDuplicated; ret->child = DuplicateModule(mod->child, ret); ret->sib = DuplicateModule(mod->sib, parent); ret->parent = parent; @@ -1072,11 +1070,16 @@ UnloadModuleOrDriver(ModuleDescPtr mod) if (mod == NULL || mod->name == NULL) return; - xf86MsgVerb(X_INFO, 3, "UnloadModule: \"%s\"\n", mod->name); + if (mod->parent) + xf86MsgVerb(X_INFO, 3, "UnloadSubModule: \"%s\"\n", mod->name); + else + xf86MsgVerb(X_INFO, 3, "UnloadModule: \"%s\"\n", mod->name); - if ((mod->TearDownProc) && (mod->TearDownData)) - mod->TearDownProc(mod->TearDownData); - LoaderUnload(mod->name, mod->handle); + if (mod->TearDownData != ModuleDuplicated) { + if ((mod->TearDownProc) && (mod->TearDownData)) + mod->TearDownProc(mod->TearDownData); + LoaderUnload(mod->name, mod->handle); + } if (mod->child) UnloadModuleOrDriver(mod->child); @@ -1092,23 +1095,8 @@ UnloadSubModule(pointer _mod) { ModuleDescPtr mod = (ModuleDescPtr)_mod; - if (mod == NULL || mod->name == NULL) - return; - - xf86MsgVerb(X_INFO, 3, "UnloadSubModule: \"%s\"\n", mod->name); - - if ((mod->TearDownProc) && (mod->TearDownData)) - mod->TearDownProc(mod->TearDownData); - LoaderUnload(mod->name, mod->handle); - RemoveChild(mod); - - if (mod->child) - UnloadModuleOrDriver(mod->child); - - free(mod->path); - free(mod->name); - free(mod); + UnloadModuleOrDriver(mod); } static void @@ -1135,6 +1123,7 @@ RemoveChild(ModuleDescPtr child) } if (mdp == child) prevsib->sib = child->sib; + child->sib = NULL; return; } diff --git a/xorg-server/hw/xfree86/man/xorg.conf.man b/xorg-server/hw/xfree86/man/xorg.conf.man index 7f98851b6..996798f1c 100644 --- a/xorg-server/hw/xfree86/man/xorg.conf.man +++ b/xorg-server/hw/xfree86/man/xorg.conf.man @@ -379,7 +379,9 @@ is a number used to order the fontfile FPEs. Examples: .I misc:unscaled:pri=10 \-> /usr/share/X11/fonts/misc .fi .PP -.RE .RE .RE +.RE +.RE +.RE .PP .RS 7 Font server identifiers: diff --git a/xorg-server/hw/xfree86/modes/xf86Crtc.c b/xorg-server/hw/xfree86/modes/xf86Crtc.c index cbe0b5cf6..aac33d32f 100644 --- a/xorg-server/hw/xfree86/modes/xf86Crtc.c +++ b/xorg-server/hw/xfree86/modes/xf86Crtc.c @@ -1915,19 +1915,25 @@ xf86SetScrnInfoModes (ScrnInfoPtr scrn) break; } - if (scrn->modes != NULL) { - /* For some reason, scrn->modes is circular, unlike the other mode - * lists. How great is that? - */ - for (last = scrn->modes; last && last->next; last = last->next) - ; - last->next = scrn->modes; - scrn->modes->prev = last; - if (mode) { - while (scrn->modes != mode) - scrn->modes = scrn->modes->next; - } + if (!scrn->modes) { + scrn->modes = xf86ModesAdd(scrn->modes, + xf86CVTMode(scrn->display->virtualX, + scrn->display->virtualY, + 60, 0, 0)); + } + + /* For some reason, scrn->modes is circular, unlike the other mode + * lists. How great is that? + */ + for (last = scrn->modes; last && last->next; last = last->next) + ; + last->next = scrn->modes; + scrn->modes->prev = last; + if (mode) { + while (scrn->modes != mode) + scrn->modes = scrn->modes->next; } + scrn->currentMode = scrn->modes; #ifdef XFreeXDGA if (scrn->pScreen) @@ -2060,13 +2066,28 @@ xf86TargetPreferred(ScrnInfoPtr scrn, xf86CrtcConfigPtr config, if (o == p) continue; - for (mode = output->probed_modes; mode; mode = mode->next) { - Rotation r = output->initial_rotation; - if (xf86ModeWidth(mode, r) == pref_width && - xf86ModeHeight(mode, r) == pref_height) { + /* + * First see if the preferred mode matches on the next + * output as well. This catches the common case of identical + * monitors and makes sure they all have the same timings + * and refresh. If that fails, we fall back to trying to + * match just width & height. + */ + mode = xf86OutputHasPreferredMode(output, pref_width, + pref_height); + if (mode && xf86ModesEqual(mode, preferred[p])) { preferred[o] = mode; match = TRUE; - } + } else { + for (mode = output->probed_modes; mode; + mode = mode->next) { + Rotation r = output->initial_rotation; + if (xf86ModeWidth(mode, r) == pref_width && + xf86ModeHeight(mode, r) == pref_height) { + preferred[o] = mode; + match = TRUE; + } + } } all_match &= match; @@ -2514,16 +2535,7 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow) width, height); } - if (have_outputs) { - /* Mirror output modes to scrn mode list */ - xf86SetScrnInfoModes (scrn); - } else { - /* Clear any existing modes from scrn->modes */ - while (scrn->modes != NULL) - xf86DeleteMode(&scrn->modes, scrn->modes); - scrn->modes = xf86ModesAdd(scrn->modes, - xf86CVTMode(width, height, 60, 0, 0)); - } + xf86SetScrnInfoModes (scrn); success = TRUE; bailout: diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_init.c b/xorg-server/hw/xfree86/os-support/linux/lnx_init.c index 9c9174034..f18271f38 100644 --- a/xorg-server/hw/xfree86/os-support/linux/lnx_init.c +++ b/xorg-server/hw/xfree86/os-support/linux/lnx_init.c @@ -45,15 +45,12 @@ static char vtname[11]; static struct termios tty_attr; /* tty state to restore */ static int tty_mode; /* kbd mode to restore */ -static void *console_handler; - static void drain_console(int fd, void *closure) { errno = 0; if (tcflush(fd, TCIOFLUSH) == -1 && errno == EIO) { - xf86RemoveGeneralHandler(console_handler); - console_handler = NULL; + xf86SetConsoleHandler(NULL, NULL); } } @@ -257,10 +254,11 @@ xf86CloseConsole(void) return; } - if (console_handler) { - xf86RemoveGeneralHandler(console_handler); - console_handler = NULL; - }; + /* + * unregister the drain_console handler + * - what to do if someone else changed it in the meantime? + */ + xf86SetConsoleHandler(NULL, NULL); /* Back to text mode ... */ SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT)); diff --git a/xorg-server/hw/xfree86/parser/Flags.c b/xorg-server/hw/xfree86/parser/Flags.c index 17e079a8c..f0a61707b 100644 --- a/xorg-server/hw/xfree86/parser/Flags.c +++ b/xorg-server/hw/xfree86/parser/Flags.c @@ -1,504 +1,505 @@ -/*
- * Copyright (c) 1997 Metro Link Incorporated
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
- * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * Except as contained in this notice, the name of the Metro Link shall not be
- * used in advertising or otherwise to promote the sale, use or other dealings
- * in this Software without prior written authorization from Metro Link.
- *
- */
-/*
- * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-
-/* View/edit this file with tab stops set to 4 */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Parser.h"
-#include "xf86tokens.h"
-#include "Configint.h"
-#include <X11/Xfuncproto.h>
-#include "Xprintf.h"
-
-extern LexRec val;
-
-static xf86ConfigSymTabRec ServerFlagsTab[] =
-{
- {ENDSECTION, "endsection"},
- {NOTRAPSIGNALS, "notrapsignals"},
- {DONTZAP, "dontzap"},
- {DONTZOOM, "dontzoom"},
- {DISABLEVIDMODE, "disablevidmodeextension"},
- {ALLOWNONLOCAL, "allownonlocalxvidtune"},
- {DISABLEMODINDEV, "disablemodindev"},
- {MODINDEVALLOWNONLOCAL, "allownonlocalmodindev"},
- {ALLOWMOUSEOPENFAIL, "allowmouseopenfail"},
- {OPTION, "option"},
- {BLANKTIME, "blanktime"},
- {STANDBYTIME, "standbytime"},
- {SUSPENDTIME, "suspendtime"},
- {OFFTIME, "offtime"},
- {DEFAULTLAYOUT, "defaultserverlayout"},
- {-1, ""},
-};
-
-#define CLEANUP xf86freeFlags
-
-XF86ConfFlagsPtr
-xf86parseFlagsSection (void)
-{
- int token;
- parsePrologue (XF86ConfFlagsPtr, XF86ConfFlagsRec)
-
- while ((token = xf86getToken (ServerFlagsTab)) != ENDSECTION)
- {
- int hasvalue = FALSE;
- int strvalue = FALSE;
- int tokentype;
- switch (token)
- {
- case COMMENT:
- ptr->flg_comment = xf86addComment(ptr->flg_comment, val.str);
- break;
- /*
- * these old keywords are turned into standard generic options.
- * we fall through here on purpose
- */
- case DEFAULTLAYOUT:
- strvalue = TRUE;
- case BLANKTIME:
- case STANDBYTIME:
- case SUSPENDTIME:
- case OFFTIME:
- hasvalue = TRUE;
- case NOTRAPSIGNALS:
- case DONTZAP:
- case DONTZOOM:
- case DISABLEVIDMODE:
- case ALLOWNONLOCAL:
- case DISABLEMODINDEV:
- case MODINDEVALLOWNONLOCAL:
- case ALLOWMOUSEOPENFAIL:
- {
- int i = 0;
- while (ServerFlagsTab[i].token != -1)
- {
- char *tmp;
-
- if (ServerFlagsTab[i].token == token)
- {
- char *valstr = NULL;
- tmp = strdup (ServerFlagsTab[i].name);
- if (hasvalue)
- {
- tokentype = xf86getSubToken(&(ptr->flg_comment));
- if (strvalue) {
- if (tokentype != STRING)
- Error (QUOTE_MSG, tmp);
- valstr = val.str;
- } else {
- if (tokentype != NUMBER)
- Error (NUMBER_MSG, tmp);
- if (asprintf(&valstr, "%d", val.num) == -1)
- valstr = NULL;
- }
- }
- ptr->flg_option_lst = xf86addNewOption
- (ptr->flg_option_lst, tmp, valstr);
- }
- i++;
- }
- }
- break;
- case OPTION:
- ptr->flg_option_lst = xf86parseOption(ptr->flg_option_lst);
- break;
-
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG, NULL);
- break;
- default:
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
- }
-
-#ifdef DEBUG
- printf ("Flags section parsed\n");
-#endif
-
- return ptr;
-}
-
-#undef CLEANUP
-
-void
-xf86printServerFlagsSection (FILE * f, XF86ConfFlagsPtr flags)
-{
- XF86OptionPtr p;
-
- if ((!flags) || (!flags->flg_option_lst))
- return;
- p = flags->flg_option_lst;
- fprintf (f, "Section \"ServerFlags\"\n");
- if (flags->flg_comment)
- fprintf (f, "%s", flags->flg_comment);
- xf86printOptionList(f, p, 1);
- fprintf (f, "EndSection\n\n");
-}
-
-static XF86OptionPtr
-addNewOption2 (XF86OptionPtr head, char *name, char *val, int used)
-{
- XF86OptionPtr new, old = NULL;
-
- /* Don't allow duplicates, free old strings */
- if (head != NULL && (old = xf86findOption(head, name)) != NULL) {
- new = old;
- free(new->opt_name);
- free(new->opt_val);
- }
- else
- new = calloc (1, sizeof (XF86OptionRec));
- new->opt_name = name;
- new->opt_val = val;
- new->opt_used = used;
-
- if (old)
- return head;
- return ((XF86OptionPtr) xf86addListItem ((glp) head, (glp) new));
-}
-
-XF86OptionPtr
-xf86addNewOption (XF86OptionPtr head, char *name, char *val)
-{
- return addNewOption2(head, name, val, 0);
-}
-
-void
-xf86freeFlags (XF86ConfFlagsPtr flags)
-{
- if (flags == NULL)
- return;
- xf86optionListFree (flags->flg_option_lst);
- TestFree(flags->flg_comment);
- free (flags);
-}
-
-XF86OptionPtr
-xf86optionListDup (XF86OptionPtr opt)
-{
- XF86OptionPtr newopt = NULL;
- char *val;
-
- while (opt)
- {
- val = opt->opt_val ? strdup(opt->opt_val) : NULL;
- newopt = xf86addNewOption(newopt, strdup(opt->opt_name), val);
- newopt->opt_used = opt->opt_used;
- if (opt->opt_comment)
- newopt->opt_comment = strdup(opt->opt_comment);
- opt = opt->list.next;
- }
- return newopt;
-}
-
-void
-xf86optionListFree (XF86OptionPtr opt)
-{
- XF86OptionPtr prev;
-
- while (opt)
- {
- TestFree (opt->opt_name);
- TestFree (opt->opt_val);
- TestFree (opt->opt_comment);
- prev = opt;
- opt = opt->list.next;
- free (prev);
- }
-}
-
-char *
-xf86optionName(XF86OptionPtr opt)
-{
- if (opt)
- return opt->opt_name;
- return 0;
-}
-
-char *
-xf86optionValue(XF86OptionPtr opt)
-{
- if (opt)
- return opt->opt_val;
- return 0;
-}
-
-XF86OptionPtr
-xf86newOption(char *name, char *value)
-{
- XF86OptionPtr opt;
-
- opt = calloc(1, sizeof (XF86OptionRec));
- if (!opt)
- return NULL;
-
- opt->opt_used = 0;
- opt->list.next = 0;
- opt->opt_name = name;
- opt->opt_val = value;
-
- return opt;
-}
-
-XF86OptionPtr
-xf86nextOption(XF86OptionPtr list)
-{
- if (!list)
- return NULL;
- return list->list.next;
-}
-
-/*
- * this function searches the given option list for the named option and
- * returns a pointer to the option rec if found. If not found, it returns
- * NULL
- */
-
-XF86OptionPtr
-xf86findOption (XF86OptionPtr list, const char *name)
-{
- while (list)
- {
- if (xf86nameCompare (list->opt_name, name) == 0)
- return list;
- list = list->list.next;
- }
- return NULL;
-}
-
-/*
- * this function searches the given option list for the named option. If
- * found and the option has a parameter, a pointer to the parameter is
- * returned. If the option does not have a parameter an empty string is
- * returned. If the option is not found, a NULL is returned.
- */
-
-char *
-xf86findOptionValue (XF86OptionPtr list, const char *name)
-{
- XF86OptionPtr p = xf86findOption (list, name);
-
- if (p)
- {
- if (p->opt_val)
- return p->opt_val;
- else
- return "";
- }
- return NULL;
-}
-
-XF86OptionPtr
-xf86optionListCreate( const char **options, int count, int used )
-{
- XF86OptionPtr p = NULL;
- char *t1, *t2;
- int i;
-
- if (count == -1)
- {
- for (count = 0; options[count]; count++)
- ;
- }
- if( (count % 2) != 0 )
- {
- fprintf( stderr, "xf86optionListCreate: count must be an even number.\n" );
- return NULL;
- }
- for (i = 0; i < count; i += 2)
- {
- t1 = strdup(options[i]);
- t2 = strdup(options[i + 1]);
- p = addNewOption2 (p, t1, t2, used);
- }
-
- return p;
-}
-
-/* the 2 given lists are merged. If an option with the same name is present in
- * both, the option from the user list - specified in the second argument -
- * is used. The end result is a single valid list of options. Duplicates
- * are freed, and the original lists are no longer guaranteed to be complete.
- */
-XF86OptionPtr
-xf86optionListMerge (XF86OptionPtr head, XF86OptionPtr tail)
-{
- XF86OptionPtr a, b, ap = NULL, bp = NULL;
-
- a = tail;
- b = head;
- while (tail && b) {
- if (xf86nameCompare (a->opt_name, b->opt_name) == 0) {
- if (b == head)
- head = a;
- else
- bp->list.next = a;
- if (a == tail)
- tail = a->list.next;
- else
- ap->list.next = a->list.next;
- a->list.next = b->list.next;
- b->list.next = NULL;
- xf86optionListFree (b);
- b = a->list.next;
- bp = a;
- a = tail;
- ap = NULL;
- } else {
- ap = a;
- if (!(a = a->list.next)) {
- a = tail;
- bp = b;
- b = b->list.next;
- ap = NULL;
- }
- }
- }
-
- if (head) {
- for (a = head; a->list.next; a = a->list.next)
- ;
- a->list.next = tail;
- } else
- head = tail;
-
- return head;
-}
-
-char *
-xf86uLongToString(unsigned long i)
-{
- char *s;
-
- if (asprintf(&s, "%lu", i) == -1)
- return NULL;
- return s;
-}
-
-XF86OptionPtr
-xf86parseOption(XF86OptionPtr head)
-{
- XF86OptionPtr option, cnew, old;
- char *name, *comment = NULL;
- int token;
-
- if ((token = xf86getSubToken(&comment)) != STRING) {
- xf86parseError(BAD_OPTION_MSG, NULL);
- free(comment);
- return head;
- }
-
- name = val.str;
- if ((token = xf86getSubToken(&comment)) == STRING) {
- option = xf86newOption(name, val.str);
- option->opt_comment = comment;
- if ((token = xf86getToken(NULL)) == COMMENT)
- option->opt_comment = xf86addComment(option->opt_comment, val.str);
- else
- xf86unGetToken(token);
- }
- else {
- option = xf86newOption(name, NULL);
- option->opt_comment = comment;
- if (token == COMMENT)
- option->opt_comment = xf86addComment(option->opt_comment, val.str);
- else
- xf86unGetToken(token);
- }
-
- old = NULL;
-
- /* Don't allow duplicates */
- if (head != NULL && (old = xf86findOption(head, name)) != NULL) {
- cnew = old;
- free(option->opt_name);
- TestFree(option->opt_val);
- TestFree(option->opt_comment);
- free(option);
- }
- else
- cnew = option;
-
- if (old == NULL)
- return ((XF86OptionPtr)xf86addListItem((glp)head, (glp)cnew));
-
- return head;
-}
-
-void
-xf86printOptionList(FILE *fp, XF86OptionPtr list, int tabs)
-{
- int i;
-
- if (!list)
- return;
- while (list) {
- for (i = 0; i < tabs; i++)
- fputc('\t', fp);
- if (list->opt_val)
- fprintf(fp, "Option \"%s\" \"%s\"", list->opt_name, list->opt_val);
- else
- fprintf(fp, "Option \"%s\"", list->opt_name);
- if (list->opt_comment)
- fprintf(fp, "%s", list->opt_comment);
- else
- fputc('\n', fp);
- list = list->list.next;
- }
-}
+/* + * Copyright (c) 1997 Metro Link Incorporated + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + + +/* View/edit this file with tab stops set to 4 */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Parser.h" +#include "xf86tokens.h" +#include "Configint.h" +#include <X11/Xfuncproto.h> +#include "Xprintf.h" +#include "optionstr.h" + +extern LexRec val; + +static xf86ConfigSymTabRec ServerFlagsTab[] = +{ + {ENDSECTION, "endsection"}, + {NOTRAPSIGNALS, "notrapsignals"}, + {DONTZAP, "dontzap"}, + {DONTZOOM, "dontzoom"}, + {DISABLEVIDMODE, "disablevidmodeextension"}, + {ALLOWNONLOCAL, "allownonlocalxvidtune"}, + {DISABLEMODINDEV, "disablemodindev"}, + {MODINDEVALLOWNONLOCAL, "allownonlocalmodindev"}, + {ALLOWMOUSEOPENFAIL, "allowmouseopenfail"}, + {OPTION, "option"}, + {BLANKTIME, "blanktime"}, + {STANDBYTIME, "standbytime"}, + {SUSPENDTIME, "suspendtime"}, + {OFFTIME, "offtime"}, + {DEFAULTLAYOUT, "defaultserverlayout"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeFlags + +XF86ConfFlagsPtr +xf86parseFlagsSection (void) +{ + int token; + parsePrologue (XF86ConfFlagsPtr, XF86ConfFlagsRec) + + while ((token = xf86getToken (ServerFlagsTab)) != ENDSECTION) + { + int hasvalue = FALSE; + int strvalue = FALSE; + int tokentype; + switch (token) + { + case COMMENT: + ptr->flg_comment = xf86addComment(ptr->flg_comment, val.str); + break; + /* + * these old keywords are turned into standard generic options. + * we fall through here on purpose + */ + case DEFAULTLAYOUT: + strvalue = TRUE; + case BLANKTIME: + case STANDBYTIME: + case SUSPENDTIME: + case OFFTIME: + hasvalue = TRUE; + case NOTRAPSIGNALS: + case DONTZAP: + case DONTZOOM: + case DISABLEVIDMODE: + case ALLOWNONLOCAL: + case DISABLEMODINDEV: + case MODINDEVALLOWNONLOCAL: + case ALLOWMOUSEOPENFAIL: + { + int i = 0; + while (ServerFlagsTab[i].token != -1) + { + char *tmp; + + if (ServerFlagsTab[i].token == token) + { + char *valstr = NULL; + tmp = strdup (ServerFlagsTab[i].name); + if (hasvalue) + { + tokentype = xf86getSubToken(&(ptr->flg_comment)); + if (strvalue) { + if (tokentype != STRING) + Error (QUOTE_MSG, tmp); + valstr = val.str; + } else { + if (tokentype != NUMBER) + Error (NUMBER_MSG, tmp); + if (asprintf(&valstr, "%d", val.num) == -1) + valstr = NULL; + } + } + ptr->flg_option_lst = xf86addNewOption + (ptr->flg_option_lst, tmp, valstr); + } + i++; + } + } + break; + case OPTION: + ptr->flg_option_lst = xf86parseOption(ptr->flg_option_lst); + break; + + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + } + +#ifdef DEBUG + printf ("Flags section parsed\n"); +#endif + + return ptr; +} + +#undef CLEANUP + +void +xf86printServerFlagsSection (FILE * f, XF86ConfFlagsPtr flags) +{ + XF86OptionPtr p; + + if ((!flags) || (!flags->flg_option_lst)) + return; + p = flags->flg_option_lst; + fprintf (f, "Section \"ServerFlags\"\n"); + if (flags->flg_comment) + fprintf (f, "%s", flags->flg_comment); + xf86printOptionList(f, p, 1); + fprintf (f, "EndSection\n\n"); +} + +static XF86OptionPtr +addNewOption2 (XF86OptionPtr head, char *name, char *val, int used) +{ + XF86OptionPtr new, old = NULL; + + /* Don't allow duplicates, free old strings */ + if (head != NULL && (old = xf86findOption(head, name)) != NULL) { + new = old; + free(new->opt_name); + free(new->opt_val); + } + else + new = calloc (1, sizeof (*new)); + new->opt_name = name; + new->opt_val = val; + new->opt_used = used; + + if (old) + return head; + return ((XF86OptionPtr) xf86addListItem ((glp) head, (glp) new)); +} + +XF86OptionPtr +xf86addNewOption (XF86OptionPtr head, char *name, char *val) +{ + return addNewOption2(head, name, val, 0); +} + +void +xf86freeFlags (XF86ConfFlagsPtr flags) +{ + if (flags == NULL) + return; + xf86optionListFree (flags->flg_option_lst); + TestFree(flags->flg_comment); + free (flags); +} + +XF86OptionPtr +xf86optionListDup (XF86OptionPtr opt) +{ + XF86OptionPtr newopt = NULL; + char *val; + + while (opt) + { + val = opt->opt_val ? strdup(opt->opt_val) : NULL; + newopt = xf86addNewOption(newopt, strdup(opt->opt_name), val); + newopt->opt_used = opt->opt_used; + if (opt->opt_comment) + newopt->opt_comment = strdup(opt->opt_comment); + opt = opt->list.next; + } + return newopt; +} + +void +xf86optionListFree (XF86OptionPtr opt) +{ + XF86OptionPtr prev; + + while (opt) + { + TestFree (opt->opt_name); + TestFree (opt->opt_val); + TestFree (opt->opt_comment); + prev = opt; + opt = opt->list.next; + free (prev); + } +} + +char * +xf86optionName(XF86OptionPtr opt) +{ + if (opt) + return opt->opt_name; + return 0; +} + +char * +xf86optionValue(XF86OptionPtr opt) +{ + if (opt) + return opt->opt_val; + return 0; +} + +XF86OptionPtr +xf86newOption(char *name, char *value) +{ + XF86OptionPtr opt; + + opt = calloc(1, sizeof (*opt)); + if (!opt) + return NULL; + + opt->opt_used = 0; + opt->list.next = 0; + opt->opt_name = name; + opt->opt_val = value; + + return opt; +} + +XF86OptionPtr +xf86nextOption(XF86OptionPtr list) +{ + if (!list) + return NULL; + return list->list.next; +} + +/* + * this function searches the given option list for the named option and + * returns a pointer to the option rec if found. If not found, it returns + * NULL + */ + +XF86OptionPtr +xf86findOption (XF86OptionPtr list, const char *name) +{ + while (list) + { + if (xf86nameCompare (list->opt_name, name) == 0) + return list; + list = list->list.next; + } + return NULL; +} + +/* + * this function searches the given option list for the named option. If + * found and the option has a parameter, a pointer to the parameter is + * returned. If the option does not have a parameter an empty string is + * returned. If the option is not found, a NULL is returned. + */ + +char * +xf86findOptionValue (XF86OptionPtr list, const char *name) +{ + XF86OptionPtr p = xf86findOption (list, name); + + if (p) + { + if (p->opt_val) + return p->opt_val; + else + return ""; + } + return NULL; +} + +XF86OptionPtr +xf86optionListCreate( const char **options, int count, int used ) +{ + XF86OptionPtr p = NULL; + char *t1, *t2; + int i; + + if (count == -1) + { + for (count = 0; options[count]; count++) + ; + } + if( (count % 2) != 0 ) + { + fprintf( stderr, "xf86optionListCreate: count must be an even number.\n" ); + return NULL; + } + for (i = 0; i < count; i += 2) + { + t1 = strdup(options[i]); + t2 = strdup(options[i + 1]); + p = addNewOption2 (p, t1, t2, used); + } + + return p; +} + +/* the 2 given lists are merged. If an option with the same name is present in + * both, the option from the user list - specified in the second argument - + * is used. The end result is a single valid list of options. Duplicates + * are freed, and the original lists are no longer guaranteed to be complete. + */ +XF86OptionPtr +xf86optionListMerge (XF86OptionPtr head, XF86OptionPtr tail) +{ + XF86OptionPtr a, b, ap = NULL, bp = NULL; + + a = tail; + b = head; + while (tail && b) { + if (xf86nameCompare (a->opt_name, b->opt_name) == 0) { + if (b == head) + head = a; + else + bp->list.next = a; + if (a == tail) + tail = a->list.next; + else + ap->list.next = a->list.next; + a->list.next = b->list.next; + b->list.next = NULL; + xf86optionListFree (b); + b = a->list.next; + bp = a; + a = tail; + ap = NULL; + } else { + ap = a; + if (!(a = a->list.next)) { + a = tail; + bp = b; + b = b->list.next; + ap = NULL; + } + } + } + + if (head) { + for (a = head; a->list.next; a = a->list.next) + ; + a->list.next = tail; + } else + head = tail; + + return head; +} + +char * +xf86uLongToString(unsigned long i) +{ + char *s; + + if (asprintf(&s, "%lu", i) == -1) + return NULL; + return s; +} + +XF86OptionPtr +xf86parseOption(XF86OptionPtr head) +{ + XF86OptionPtr option, cnew, old; + char *name, *comment = NULL; + int token; + + if ((token = xf86getSubToken(&comment)) != STRING) { + xf86parseError(BAD_OPTION_MSG, NULL); + free(comment); + return head; + } + + name = val.str; + if ((token = xf86getSubToken(&comment)) == STRING) { + option = xf86newOption(name, val.str); + option->opt_comment = comment; + if ((token = xf86getToken(NULL)) == COMMENT) + option->opt_comment = xf86addComment(option->opt_comment, val.str); + else + xf86unGetToken(token); + } + else { + option = xf86newOption(name, NULL); + option->opt_comment = comment; + if (token == COMMENT) + option->opt_comment = xf86addComment(option->opt_comment, val.str); + else + xf86unGetToken(token); + } + + old = NULL; + + /* Don't allow duplicates */ + if (head != NULL && (old = xf86findOption(head, name)) != NULL) { + cnew = old; + free(option->opt_name); + TestFree(option->opt_val); + TestFree(option->opt_comment); + free(option); + } + else + cnew = option; + + if (old == NULL) + return ((XF86OptionPtr)xf86addListItem((glp)head, (glp)cnew)); + + return head; +} + +void +xf86printOptionList(FILE *fp, XF86OptionPtr list, int tabs) +{ + int i; + + if (!list) + return; + while (list) { + for (i = 0; i < tabs; i++) + fputc('\t', fp); + if (list->opt_val) + fprintf(fp, "Option \"%s\" \"%s\"", list->opt_name, list->opt_val); + else + fprintf(fp, "Option \"%s\"", list->opt_name); + if (list->opt_comment) + fprintf(fp, "%s", list->opt_comment); + else + fputc('\n', fp); + list = list->list.next; + } +} diff --git a/xorg-server/hw/xfree86/parser/Layout.c b/xorg-server/hw/xfree86/parser/Layout.c index 60e83390f..4487b0df6 100644 --- a/xorg-server/hw/xfree86/parser/Layout.c +++ b/xorg-server/hw/xfree86/parser/Layout.c @@ -1,558 +1,558 @@ -/*
- *
- * Copyright (c) 1997 Metro Link Incorporated
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
- * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * Except as contained in this notice, the name of the Metro Link shall not be
- * used in advertising or otherwise to promote the sale, use or other dealings
- * in this Software without prior written authorization from Metro Link.
- *
- */
-/*
- * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-
-/* View/edit this file with tab stops set to 4 */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Parser.h"
-#include "xf86tokens.h"
-#include "Configint.h"
-#include <string.h>
-
-
-/* Needed for auto server layout */
-extern int xf86CheckBoolOption(void* optlist, const char *name, int deflt);
-
-extern LexRec val;
-
-static xf86ConfigSymTabRec LayoutTab[] =
-{
- {ENDSECTION, "endsection"},
- {SCREEN, "screen"},
- {IDENTIFIER, "identifier"},
- {INACTIVE, "inactive"},
- {INPUTDEVICE, "inputdevice"},
- {OPTION, "option"},
- {-1, ""},
-};
-
-static xf86ConfigSymTabRec AdjTab[] =
-{
- {RIGHTOF, "rightof"},
- {LEFTOF, "leftof"},
- {ABOVE, "above"},
- {BELOW, "below"},
- {RELATIVE, "relative"},
- {ABSOLUTE, "absolute"},
- {-1, ""},
-};
-
-#define CLEANUP xf86freeLayoutList
-
-XF86ConfLayoutPtr
-xf86parseLayoutSection (void)
-{
- int has_ident = FALSE;
- int token;
- parsePrologue (XF86ConfLayoutPtr, XF86ConfLayoutRec)
-
- while ((token = xf86getToken (LayoutTab)) != ENDSECTION)
- {
- switch (token)
- {
- case COMMENT:
- ptr->lay_comment = xf86addComment(ptr->lay_comment, val.str);
- break;
- case IDENTIFIER:
- if (xf86getSubToken (&(ptr->lay_comment)) != STRING)
- Error (QUOTE_MSG, "Identifier");
- if (has_ident == TRUE)
- Error (MULTIPLE_MSG, "Identifier");
- ptr->lay_identifier = val.str;
- has_ident = TRUE;
- break;
- case INACTIVE:
- {
- XF86ConfInactivePtr iptr;
-
- iptr = calloc (1, sizeof (XF86ConfInactiveRec));
- iptr->list.next = NULL;
- if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
- free (iptr);
- Error (INACTIVE_MSG, NULL);
- }
- iptr->inactive_device_str = val.str;
- ptr->lay_inactive_lst = (XF86ConfInactivePtr)
- xf86addListItem ((glp) ptr->lay_inactive_lst, (glp) iptr);
- }
- break;
- case SCREEN:
- {
- XF86ConfAdjacencyPtr aptr;
- int absKeyword = 0;
-
- aptr = calloc (1, sizeof (XF86ConfAdjacencyRec));
- aptr->list.next = NULL;
- aptr->adj_scrnum = -1;
- aptr->adj_where = CONF_ADJ_OBSOLETE;
- aptr->adj_x = 0;
- aptr->adj_y = 0;
- aptr->adj_refscreen = NULL;
- if ((token = xf86getSubToken (&(ptr->lay_comment))) == NUMBER)
- aptr->adj_scrnum = val.num;
- else
- xf86unGetToken (token);
- token = xf86getSubToken(&(ptr->lay_comment));
- if (token != STRING) {
- free(aptr);
- Error (SCREEN_MSG, NULL);
- }
- aptr->adj_screen_str = val.str;
-
- token = xf86getSubTokenWithTab(&(ptr->lay_comment), AdjTab);
- switch (token)
- {
- case RIGHTOF:
- aptr->adj_where = CONF_ADJ_RIGHTOF;
- break;
- case LEFTOF:
- aptr->adj_where = CONF_ADJ_LEFTOF;
- break;
- case ABOVE:
- aptr->adj_where = CONF_ADJ_ABOVE;
- break;
- case BELOW:
- aptr->adj_where = CONF_ADJ_BELOW;
- break;
- case RELATIVE:
- aptr->adj_where = CONF_ADJ_RELATIVE;
- break;
- case ABSOLUTE:
- aptr->adj_where = CONF_ADJ_ABSOLUTE;
- absKeyword = 1;
- break;
- case EOF_TOKEN:
- free(aptr);
- Error (UNEXPECTED_EOF_MSG, NULL);
- break;
- default:
- xf86unGetToken (token);
- token = xf86getSubToken(&(ptr->lay_comment));
- if (token == STRING)
- aptr->adj_where = CONF_ADJ_OBSOLETE;
- else
- aptr->adj_where = CONF_ADJ_ABSOLUTE;
- }
- switch (aptr->adj_where)
- {
- case CONF_ADJ_ABSOLUTE:
- if (absKeyword)
- token = xf86getSubToken(&(ptr->lay_comment));
- if (token == NUMBER)
- {
- aptr->adj_x = val.num;
- token = xf86getSubToken(&(ptr->lay_comment));
- if (token != NUMBER) {
- free(aptr);
- Error(INVALID_SCR_MSG, NULL);
- }
- aptr->adj_y = val.num;
- } else {
- if (absKeyword) {
- free(aptr);
- Error(INVALID_SCR_MSG, NULL);
- } else
- xf86unGetToken (token);
- }
- break;
- case CONF_ADJ_RIGHTOF:
- case CONF_ADJ_LEFTOF:
- case CONF_ADJ_ABOVE:
- case CONF_ADJ_BELOW:
- case CONF_ADJ_RELATIVE:
- token = xf86getSubToken(&(ptr->lay_comment));
- if (token != STRING) {
- free(aptr);
- Error(INVALID_SCR_MSG, NULL);
- }
- aptr->adj_refscreen = val.str;
- if (aptr->adj_where == CONF_ADJ_RELATIVE)
- {
- token = xf86getSubToken(&(ptr->lay_comment));
- if (token != NUMBER) {
- free(aptr);
- Error(INVALID_SCR_MSG, NULL);
- }
- aptr->adj_x = val.num;
- token = xf86getSubToken(&(ptr->lay_comment));
- if (token != NUMBER) {
- free(aptr);
- Error(INVALID_SCR_MSG, NULL);
- }
- aptr->adj_y = val.num;
- }
- break;
- case CONF_ADJ_OBSOLETE:
- /* top */
- aptr->adj_top_str = val.str;
-
- /* bottom */
- if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
- free(aptr);
- Error (SCREEN_MSG, NULL);
- }
- aptr->adj_bottom_str = val.str;
-
- /* left */
- if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
- free(aptr);
- Error (SCREEN_MSG, NULL);
- }
- aptr->adj_left_str = val.str;
-
- /* right */
- if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
- free(aptr);
- Error (SCREEN_MSG, NULL);
- }
- aptr->adj_right_str = val.str;
-
- }
- ptr->lay_adjacency_lst = (XF86ConfAdjacencyPtr)
- xf86addListItem ((glp) ptr->lay_adjacency_lst, (glp) aptr);
- }
- break;
- case INPUTDEVICE:
- {
- XF86ConfInputrefPtr iptr;
-
- iptr = calloc (1, sizeof (XF86ConfInputrefRec));
- iptr->list.next = NULL;
- iptr->iref_option_lst = NULL;
- if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
- free(iptr);
- Error (INPUTDEV_MSG, NULL);
- }
- iptr->iref_inputdev_str = val.str;
- while ((token = xf86getSubToken (&(ptr->lay_comment))) == STRING)
- {
- iptr->iref_option_lst =
- xf86addNewOption (iptr->iref_option_lst, val.str, NULL);
- }
- xf86unGetToken (token);
- ptr->lay_input_lst = (XF86ConfInputrefPtr)
- xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
- }
- break;
- case OPTION:
- ptr->lay_option_lst = xf86parseOption(ptr->lay_option_lst);
- break;
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG, NULL);
- break;
- default:
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
- }
-
- if (!has_ident)
- Error (NO_IDENT_MSG, NULL);
-
-#ifdef DEBUG
- printf ("Layout section parsed\n");
-#endif
-
- return ptr;
-}
-
-#undef CLEANUP
-
-void
-xf86printLayoutSection (FILE * cf, XF86ConfLayoutPtr ptr)
-{
- XF86ConfAdjacencyPtr aptr;
- XF86ConfInactivePtr iptr;
- XF86ConfInputrefPtr inptr;
- XF86OptionPtr optr;
-
- while (ptr)
- {
- fprintf (cf, "Section \"ServerLayout\"\n");
- if (ptr->lay_comment)
- fprintf (cf, "%s", ptr->lay_comment);
- if (ptr->lay_identifier)
- fprintf (cf, "\tIdentifier \"%s\"\n", ptr->lay_identifier);
-
- for (aptr = ptr->lay_adjacency_lst; aptr; aptr = aptr->list.next)
- {
- fprintf (cf, "\tScreen ");
- if (aptr->adj_scrnum >= 0)
- fprintf (cf, "%2d", aptr->adj_scrnum);
- else
- fprintf (cf, " ");
- fprintf (cf, " \"%s\"", aptr->adj_screen_str);
- switch(aptr->adj_where)
- {
- case CONF_ADJ_OBSOLETE:
- fprintf (cf, " \"%s\"", aptr->adj_top_str);
- fprintf (cf, " \"%s\"", aptr->adj_bottom_str);
- fprintf (cf, " \"%s\"", aptr->adj_right_str);
- fprintf (cf, " \"%s\"\n", aptr->adj_left_str);
- break;
- case CONF_ADJ_ABSOLUTE:
- if (aptr->adj_x != -1)
- fprintf (cf, " %d %d\n", aptr->adj_x, aptr->adj_y);
- else
- fprintf (cf, "\n");
- break;
- case CONF_ADJ_RIGHTOF:
- fprintf (cf, " RightOf \"%s\"\n", aptr->adj_refscreen);
- break;
- case CONF_ADJ_LEFTOF:
- fprintf (cf, " LeftOf \"%s\"\n", aptr->adj_refscreen);
- break;
- case CONF_ADJ_ABOVE:
- fprintf (cf, " Above \"%s\"\n", aptr->adj_refscreen);
- break;
- case CONF_ADJ_BELOW:
- fprintf (cf, " Below \"%s\"\n", aptr->adj_refscreen);
- break;
- case CONF_ADJ_RELATIVE:
- fprintf (cf, " Relative \"%s\" %d %d\n", aptr->adj_refscreen,
- aptr->adj_x, aptr->adj_y);
- break;
- }
- }
- for (iptr = ptr->lay_inactive_lst; iptr; iptr = iptr->list.next)
- fprintf (cf, "\tInactive \"%s\"\n", iptr->inactive_device_str);
- for (inptr = ptr->lay_input_lst; inptr; inptr = inptr->list.next)
- {
- fprintf (cf, "\tInputDevice \"%s\"", inptr->iref_inputdev_str);
- for (optr = inptr->iref_option_lst; optr; optr = optr->list.next)
- {
- fprintf(cf, " \"%s\"", optr->opt_name);
- }
- fprintf(cf, "\n");
- }
- xf86printOptionList(cf, ptr->lay_option_lst, 1);
- fprintf (cf, "EndSection\n\n");
- ptr = ptr->list.next;
- }
-}
-
-static void
-xf86freeAdjacencyList (XF86ConfAdjacencyPtr ptr)
-{
- XF86ConfAdjacencyPtr prev;
-
- while (ptr)
- {
- TestFree (ptr->adj_screen_str);
- TestFree (ptr->adj_top_str);
- TestFree (ptr->adj_bottom_str);
- TestFree (ptr->adj_left_str);
- TestFree (ptr->adj_right_str);
-
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
-
-}
-
-static void
-xf86freeInputrefList (XF86ConfInputrefPtr ptr)
-{
- XF86ConfInputrefPtr prev;
-
- while (ptr)
- {
- TestFree (ptr->iref_inputdev_str);
- xf86optionListFree (ptr->iref_option_lst);
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
-
-}
-
-void
-xf86freeLayoutList (XF86ConfLayoutPtr ptr)
-{
- XF86ConfLayoutPtr prev;
-
- while (ptr)
- {
- TestFree (ptr->lay_identifier);
- TestFree (ptr->lay_comment);
- xf86freeAdjacencyList (ptr->lay_adjacency_lst);
- xf86freeInputrefList (ptr->lay_input_lst);
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
-}
-
-int
-xf86layoutAddInputDevices(XF86ConfigPtr config, XF86ConfLayoutPtr layout)
-{
- int count = 0;
- XF86ConfInputPtr input = config->conf_input_lst;
- XF86ConfInputrefPtr inptr;
-
- /* add all AutoServerLayout devices to the server layout */
- while (input)
- {
- if (xf86CheckBoolOption(input->inp_option_lst, "AutoServerLayout", FALSE))
- {
- XF86ConfInputrefPtr iref = layout->lay_input_lst;
-
- /* avoid duplicates if referenced but lists AutoServerLayout too */
- while (iref)
- {
- if (strcmp(iref->iref_inputdev_str, input->inp_identifier) == 0)
- break;
- iref = iref->list.next;
- }
-
- if (!iref)
- {
- XF86ConfInputrefPtr iptr;
- iptr = calloc(1, sizeof(XF86ConfInputrefRec));
- iptr->iref_inputdev_str = input->inp_identifier;
- layout->lay_input_lst = (XF86ConfInputrefPtr)
- xf86addListItem((glp)layout->lay_input_lst, (glp)iptr);
- count++;
- }
- }
- input = input->list.next;
- }
-
- inptr = layout->lay_input_lst;
- while (inptr)
- {
- input = xf86findInput (inptr->iref_inputdev_str,
- config->conf_input_lst);
- if (!input)
- {
- xf86validationError (UNDEFINED_INPUT_MSG,
- inptr->iref_inputdev_str, layout->lay_identifier);
- return -1;
- }
- else
- inptr->iref_inputdev = input;
- inptr = inptr->list.next;
- }
-
- return count;
-}
-
-int
-xf86validateLayout (XF86ConfigPtr p)
-{
- XF86ConfLayoutPtr layout = p->conf_layout_lst;
- XF86ConfAdjacencyPtr adj;
- XF86ConfInactivePtr iptr;
- XF86ConfScreenPtr screen;
- XF86ConfDevicePtr device;
-
- while (layout)
- {
- adj = layout->lay_adjacency_lst;
- while (adj)
- {
- /* the first one can't be "" but all others can */
- screen = xf86findScreen (adj->adj_screen_str, p->conf_screen_lst);
- if (!screen)
- {
- xf86validationError (UNDEFINED_SCREEN_MSG,
- adj->adj_screen_str, layout->lay_identifier);
- return FALSE;
- }
- else
- adj->adj_screen = screen;
-
- adj = adj->list.next;
- }
- iptr = layout->lay_inactive_lst;
- while (iptr)
- {
- device = xf86findDevice (iptr->inactive_device_str,
- p->conf_device_lst);
- if (!device)
- {
- xf86validationError (UNDEFINED_DEVICE_LAY_MSG,
- iptr->inactive_device_str, layout->lay_identifier);
- return FALSE;
- }
- else
- iptr->inactive_device = device;
- iptr = iptr->list.next;
- }
-
- if (xf86layoutAddInputDevices(p, layout) == -1)
- return FALSE;
-
- layout = layout->list.next;
- }
- return TRUE;
-}
-
-XF86ConfLayoutPtr
-xf86findLayout (const char *name, XF86ConfLayoutPtr list)
-{
- while (list)
- {
- if (xf86nameCompare (list->lay_identifier, name) == 0)
- return list;
- list = list->list.next;
- }
- return NULL;
-}
-
+/* + * + * Copyright (c) 1997 Metro Link Incorporated + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + + +/* View/edit this file with tab stops set to 4 */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Parser.h" +#include "xf86tokens.h" +#include "Configint.h" +#include <string.h> +#include "optionstr.h" + +/* Needed for auto server layout */ +extern int xf86CheckBoolOption(void* optlist, const char *name, int deflt); + +extern LexRec val; + +static xf86ConfigSymTabRec LayoutTab[] = +{ + {ENDSECTION, "endsection"}, + {SCREEN, "screen"}, + {IDENTIFIER, "identifier"}, + {INACTIVE, "inactive"}, + {INPUTDEVICE, "inputdevice"}, + {OPTION, "option"}, + {-1, ""}, +}; + +static xf86ConfigSymTabRec AdjTab[] = +{ + {RIGHTOF, "rightof"}, + {LEFTOF, "leftof"}, + {ABOVE, "above"}, + {BELOW, "below"}, + {RELATIVE, "relative"}, + {ABSOLUTE, "absolute"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeLayoutList + +XF86ConfLayoutPtr +xf86parseLayoutSection (void) +{ + int has_ident = FALSE; + int token; + parsePrologue (XF86ConfLayoutPtr, XF86ConfLayoutRec) + + while ((token = xf86getToken (LayoutTab)) != ENDSECTION) + { + switch (token) + { + case COMMENT: + ptr->lay_comment = xf86addComment(ptr->lay_comment, val.str); + break; + case IDENTIFIER: + if (xf86getSubToken (&(ptr->lay_comment)) != STRING) + Error (QUOTE_MSG, "Identifier"); + if (has_ident == TRUE) + Error (MULTIPLE_MSG, "Identifier"); + ptr->lay_identifier = val.str; + has_ident = TRUE; + break; + case INACTIVE: + { + XF86ConfInactivePtr iptr; + + iptr = calloc (1, sizeof (XF86ConfInactiveRec)); + iptr->list.next = NULL; + if (xf86getSubToken (&(ptr->lay_comment)) != STRING) { + free (iptr); + Error (INACTIVE_MSG, NULL); + } + iptr->inactive_device_str = val.str; + ptr->lay_inactive_lst = (XF86ConfInactivePtr) + xf86addListItem ((glp) ptr->lay_inactive_lst, (glp) iptr); + } + break; + case SCREEN: + { + XF86ConfAdjacencyPtr aptr; + int absKeyword = 0; + + aptr = calloc (1, sizeof (XF86ConfAdjacencyRec)); + aptr->list.next = NULL; + aptr->adj_scrnum = -1; + aptr->adj_where = CONF_ADJ_OBSOLETE; + aptr->adj_x = 0; + aptr->adj_y = 0; + aptr->adj_refscreen = NULL; + if ((token = xf86getSubToken (&(ptr->lay_comment))) == NUMBER) + aptr->adj_scrnum = val.num; + else + xf86unGetToken (token); + token = xf86getSubToken(&(ptr->lay_comment)); + if (token != STRING) { + free(aptr); + Error (SCREEN_MSG, NULL); + } + aptr->adj_screen_str = val.str; + + token = xf86getSubTokenWithTab(&(ptr->lay_comment), AdjTab); + switch (token) + { + case RIGHTOF: + aptr->adj_where = CONF_ADJ_RIGHTOF; + break; + case LEFTOF: + aptr->adj_where = CONF_ADJ_LEFTOF; + break; + case ABOVE: + aptr->adj_where = CONF_ADJ_ABOVE; + break; + case BELOW: + aptr->adj_where = CONF_ADJ_BELOW; + break; + case RELATIVE: + aptr->adj_where = CONF_ADJ_RELATIVE; + break; + case ABSOLUTE: + aptr->adj_where = CONF_ADJ_ABSOLUTE; + absKeyword = 1; + break; + case EOF_TOKEN: + free(aptr); + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + xf86unGetToken (token); + token = xf86getSubToken(&(ptr->lay_comment)); + if (token == STRING) + aptr->adj_where = CONF_ADJ_OBSOLETE; + else + aptr->adj_where = CONF_ADJ_ABSOLUTE; + } + switch (aptr->adj_where) + { + case CONF_ADJ_ABSOLUTE: + if (absKeyword) + token = xf86getSubToken(&(ptr->lay_comment)); + if (token == NUMBER) + { + aptr->adj_x = val.num; + token = xf86getSubToken(&(ptr->lay_comment)); + if (token != NUMBER) { + free(aptr); + Error(INVALID_SCR_MSG, NULL); + } + aptr->adj_y = val.num; + } else { + if (absKeyword) { + free(aptr); + Error(INVALID_SCR_MSG, NULL); + } else + xf86unGetToken (token); + } + break; + case CONF_ADJ_RIGHTOF: + case CONF_ADJ_LEFTOF: + case CONF_ADJ_ABOVE: + case CONF_ADJ_BELOW: + case CONF_ADJ_RELATIVE: + token = xf86getSubToken(&(ptr->lay_comment)); + if (token != STRING) { + free(aptr); + Error(INVALID_SCR_MSG, NULL); + } + aptr->adj_refscreen = val.str; + if (aptr->adj_where == CONF_ADJ_RELATIVE) + { + token = xf86getSubToken(&(ptr->lay_comment)); + if (token != NUMBER) { + free(aptr); + Error(INVALID_SCR_MSG, NULL); + } + aptr->adj_x = val.num; + token = xf86getSubToken(&(ptr->lay_comment)); + if (token != NUMBER) { + free(aptr); + Error(INVALID_SCR_MSG, NULL); + } + aptr->adj_y = val.num; + } + break; + case CONF_ADJ_OBSOLETE: + /* top */ + aptr->adj_top_str = val.str; + + /* bottom */ + if (xf86getSubToken (&(ptr->lay_comment)) != STRING) { + free(aptr); + Error (SCREEN_MSG, NULL); + } + aptr->adj_bottom_str = val.str; + + /* left */ + if (xf86getSubToken (&(ptr->lay_comment)) != STRING) { + free(aptr); + Error (SCREEN_MSG, NULL); + } + aptr->adj_left_str = val.str; + + /* right */ + if (xf86getSubToken (&(ptr->lay_comment)) != STRING) { + free(aptr); + Error (SCREEN_MSG, NULL); + } + aptr->adj_right_str = val.str; + + } + ptr->lay_adjacency_lst = (XF86ConfAdjacencyPtr) + xf86addListItem ((glp) ptr->lay_adjacency_lst, (glp) aptr); + } + break; + case INPUTDEVICE: + { + XF86ConfInputrefPtr iptr; + + iptr = calloc (1, sizeof (XF86ConfInputrefRec)); + iptr->list.next = NULL; + iptr->iref_option_lst = NULL; + if (xf86getSubToken (&(ptr->lay_comment)) != STRING) { + free(iptr); + Error (INPUTDEV_MSG, NULL); + } + iptr->iref_inputdev_str = val.str; + while ((token = xf86getSubToken (&(ptr->lay_comment))) == STRING) + { + iptr->iref_option_lst = + xf86addNewOption (iptr->iref_option_lst, val.str, NULL); + } + xf86unGetToken (token); + ptr->lay_input_lst = (XF86ConfInputrefPtr) + xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr); + } + break; + case OPTION: + ptr->lay_option_lst = xf86parseOption(ptr->lay_option_lst); + break; + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + } + + if (!has_ident) + Error (NO_IDENT_MSG, NULL); + +#ifdef DEBUG + printf ("Layout section parsed\n"); +#endif + + return ptr; +} + +#undef CLEANUP + +void +xf86printLayoutSection (FILE * cf, XF86ConfLayoutPtr ptr) +{ + XF86ConfAdjacencyPtr aptr; + XF86ConfInactivePtr iptr; + XF86ConfInputrefPtr inptr; + XF86OptionPtr optr; + + while (ptr) + { + fprintf (cf, "Section \"ServerLayout\"\n"); + if (ptr->lay_comment) + fprintf (cf, "%s", ptr->lay_comment); + if (ptr->lay_identifier) + fprintf (cf, "\tIdentifier \"%s\"\n", ptr->lay_identifier); + + for (aptr = ptr->lay_adjacency_lst; aptr; aptr = aptr->list.next) + { + fprintf (cf, "\tScreen "); + if (aptr->adj_scrnum >= 0) + fprintf (cf, "%2d", aptr->adj_scrnum); + else + fprintf (cf, " "); + fprintf (cf, " \"%s\"", aptr->adj_screen_str); + switch(aptr->adj_where) + { + case CONF_ADJ_OBSOLETE: + fprintf (cf, " \"%s\"", aptr->adj_top_str); + fprintf (cf, " \"%s\"", aptr->adj_bottom_str); + fprintf (cf, " \"%s\"", aptr->adj_right_str); + fprintf (cf, " \"%s\"\n", aptr->adj_left_str); + break; + case CONF_ADJ_ABSOLUTE: + if (aptr->adj_x != -1) + fprintf (cf, " %d %d\n", aptr->adj_x, aptr->adj_y); + else + fprintf (cf, "\n"); + break; + case CONF_ADJ_RIGHTOF: + fprintf (cf, " RightOf \"%s\"\n", aptr->adj_refscreen); + break; + case CONF_ADJ_LEFTOF: + fprintf (cf, " LeftOf \"%s\"\n", aptr->adj_refscreen); + break; + case CONF_ADJ_ABOVE: + fprintf (cf, " Above \"%s\"\n", aptr->adj_refscreen); + break; + case CONF_ADJ_BELOW: + fprintf (cf, " Below \"%s\"\n", aptr->adj_refscreen); + break; + case CONF_ADJ_RELATIVE: + fprintf (cf, " Relative \"%s\" %d %d\n", aptr->adj_refscreen, + aptr->adj_x, aptr->adj_y); + break; + } + } + for (iptr = ptr->lay_inactive_lst; iptr; iptr = iptr->list.next) + fprintf (cf, "\tInactive \"%s\"\n", iptr->inactive_device_str); + for (inptr = ptr->lay_input_lst; inptr; inptr = inptr->list.next) + { + fprintf (cf, "\tInputDevice \"%s\"", inptr->iref_inputdev_str); + for (optr = inptr->iref_option_lst; optr; optr = optr->list.next) + { + fprintf(cf, " \"%s\"", optr->opt_name); + } + fprintf(cf, "\n"); + } + xf86printOptionList(cf, ptr->lay_option_lst, 1); + fprintf (cf, "EndSection\n\n"); + ptr = ptr->list.next; + } +} + +static void +xf86freeAdjacencyList (XF86ConfAdjacencyPtr ptr) +{ + XF86ConfAdjacencyPtr prev; + + while (ptr) + { + TestFree (ptr->adj_screen_str); + TestFree (ptr->adj_top_str); + TestFree (ptr->adj_bottom_str); + TestFree (ptr->adj_left_str); + TestFree (ptr->adj_right_str); + + prev = ptr; + ptr = ptr->list.next; + free (prev); + } + +} + +static void +xf86freeInputrefList (XF86ConfInputrefPtr ptr) +{ + XF86ConfInputrefPtr prev; + + while (ptr) + { + TestFree (ptr->iref_inputdev_str); + xf86optionListFree (ptr->iref_option_lst); + prev = ptr; + ptr = ptr->list.next; + free (prev); + } + +} + +void +xf86freeLayoutList (XF86ConfLayoutPtr ptr) +{ + XF86ConfLayoutPtr prev; + + while (ptr) + { + TestFree (ptr->lay_identifier); + TestFree (ptr->lay_comment); + xf86freeAdjacencyList (ptr->lay_adjacency_lst); + xf86freeInputrefList (ptr->lay_input_lst); + prev = ptr; + ptr = ptr->list.next; + free (prev); + } +} + +int +xf86layoutAddInputDevices(XF86ConfigPtr config, XF86ConfLayoutPtr layout) +{ + int count = 0; + XF86ConfInputPtr input = config->conf_input_lst; + XF86ConfInputrefPtr inptr; + + /* add all AutoServerLayout devices to the server layout */ + while (input) + { + if (xf86CheckBoolOption(input->inp_option_lst, "AutoServerLayout", FALSE)) + { + XF86ConfInputrefPtr iref = layout->lay_input_lst; + + /* avoid duplicates if referenced but lists AutoServerLayout too */ + while (iref) + { + if (strcmp(iref->iref_inputdev_str, input->inp_identifier) == 0) + break; + iref = iref->list.next; + } + + if (!iref) + { + XF86ConfInputrefPtr iptr; + iptr = calloc(1, sizeof(XF86ConfInputrefRec)); + iptr->iref_inputdev_str = input->inp_identifier; + layout->lay_input_lst = (XF86ConfInputrefPtr) + xf86addListItem((glp)layout->lay_input_lst, (glp)iptr); + count++; + } + } + input = input->list.next; + } + + inptr = layout->lay_input_lst; + while (inptr) + { + input = xf86findInput (inptr->iref_inputdev_str, + config->conf_input_lst); + if (!input) + { + xf86validationError (UNDEFINED_INPUT_MSG, + inptr->iref_inputdev_str, layout->lay_identifier); + return -1; + } + else + inptr->iref_inputdev = input; + inptr = inptr->list.next; + } + + return count; +} + +int +xf86validateLayout (XF86ConfigPtr p) +{ + XF86ConfLayoutPtr layout = p->conf_layout_lst; + XF86ConfAdjacencyPtr adj; + XF86ConfInactivePtr iptr; + XF86ConfScreenPtr screen; + XF86ConfDevicePtr device; + + while (layout) + { + adj = layout->lay_adjacency_lst; + while (adj) + { + /* the first one can't be "" but all others can */ + screen = xf86findScreen (adj->adj_screen_str, p->conf_screen_lst); + if (!screen) + { + xf86validationError (UNDEFINED_SCREEN_MSG, + adj->adj_screen_str, layout->lay_identifier); + return FALSE; + } + else + adj->adj_screen = screen; + + adj = adj->list.next; + } + iptr = layout->lay_inactive_lst; + while (iptr) + { + device = xf86findDevice (iptr->inactive_device_str, + p->conf_device_lst); + if (!device) + { + xf86validationError (UNDEFINED_DEVICE_LAY_MSG, + iptr->inactive_device_str, layout->lay_identifier); + return FALSE; + } + else + iptr->inactive_device = device; + iptr = iptr->list.next; + } + + if (xf86layoutAddInputDevices(p, layout) == -1) + return FALSE; + + layout = layout->list.next; + } + return TRUE; +} + +XF86ConfLayoutPtr +xf86findLayout (const char *name, XF86ConfLayoutPtr list) +{ + while (list) + { + if (xf86nameCompare (list->lay_identifier, name) == 0) + return list; + list = list->list.next; + } + return NULL; +} + |