diff options
author | Reinhard Tartler <siretart@tauware.de> | 2011-10-10 17:43:39 +0200 |
---|---|---|
committer | Reinhard Tartler <siretart@tauware.de> | 2011-10-10 17:43:39 +0200 |
commit | f4092abdf94af6a99aff944d6264bc1284e8bdd4 (patch) | |
tree | 2ac1c9cc16ceb93edb2c4382c088dac5aeafdf0f /nx-X11/programs/Xserver/hw/xfree86/parser | |
parent | a840692edc9c6d19cd7c057f68e39c7d95eb767d (diff) | |
download | nx-libs-f4092abdf94af6a99aff944d6264bc1284e8bdd4.tar.gz nx-libs-f4092abdf94af6a99aff944d6264bc1284e8bdd4.tar.bz2 nx-libs-f4092abdf94af6a99aff944d6264bc1284e8bdd4.zip |
Imported nx-X11-3.1.0-1.tar.gznx-X11/3.1.0-1
Summary: Imported nx-X11-3.1.0-1.tar.gz
Keywords:
Imported nx-X11-3.1.0-1.tar.gz
into Git repository
Diffstat (limited to 'nx-X11/programs/Xserver/hw/xfree86/parser')
24 files changed, 7990 insertions, 0 deletions
diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/Configint.h b/nx-X11/programs/Xserver/hw/xfree86/parser/Configint.h new file mode 100644 index 000000000..a51116b55 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/parser/Configint.h @@ -0,0 +1,226 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Configint.h,v 1.21 2003/08/24 17:37:07 dawes Exp $ */ +/* + * + * 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-2002 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). + */ + + +/* + * These definitions are used through out the configuration file parser, but + * they should not be visible outside of the parser. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifndef _Configint_h_ +#define _Configint_h_ + +#include <stdio.h> +#include <string.h> +#include <stdarg.h> +#include <stddef.h> +#include "xf86Parser.h" + +typedef struct +{ + int num; /* returned number */ + char *str; /* private copy of the return-string */ + double realnum; /* returned number as a real */ +} +LexRec, *LexPtr; + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#include "configProcs.h" +#include <stdlib.h> +#define xf86confmalloc malloc +#define xf86confrealloc realloc +#define xf86confcalloc calloc +#define xf86conffree free + +#define TestFree(a) if (a) { xf86conffree (a); a = NULL; } + +#define parsePrologue(typeptr,typerec) typeptr ptr; \ +if( (ptr=(typeptr)xf86confcalloc(1,sizeof(typerec))) == NULL ) { return NULL; } \ +memset(ptr,0,sizeof(typerec)); + +#define parsePrologueVoid(typeptr,typerec) int token; typeptr ptr; \ +if( (ptr=(typeptr)xf86confcalloc(1,sizeof(typerec))) == NULL ) { return; } \ +memset(ptr,0,sizeof(typerec)); + +#define HANDLE_RETURN(f,func)\ +if ((ptr->f=func) == NULL)\ +{\ + CLEANUP (ptr);\ + return (NULL);\ +} + +#define HANDLE_LIST(field,func,type)\ +{\ +type p = func ();\ +if (p == NULL)\ +{\ + CLEANUP (ptr);\ + return (NULL);\ +}\ +else\ +{\ + ptr->field = (type) xf86addListItem ((glp) ptr->field, (glp) p);\ +}\ +} + +#define Error(a,b) do { \ + xf86parseError (a, b); CLEANUP (ptr); return NULL; \ + } while (0) + +/* + * These are defines for error messages to promote consistency. + * error messages are preceded by the line number, section and file name, + * so these messages should be about the specific keyword and syntax in error. + * To help limit namespace polution, end each with _MSG. + * limit messages to 70 characters if possible. + */ + +#define BAD_OPTION_MSG \ +"The Option keyword requires 1 or 2 quoted strings to follow it." +#define INVALID_KEYWORD_MSG \ +"\"%s\" is not a valid keyword in this section." +#define INVALID_SECTION_MSG \ +"\"%s\" is not a valid section name." +#define UNEXPECTED_EOF_MSG \ +"Unexpected EOF. Missing EndSection keyword?" +#define QUOTE_MSG \ +"The %s keyword requires a quoted string to follow it." +#define NUMBER_MSG \ +"The %s keyword requires a number to follow it." +#define POSITIVE_INT_MSG \ +"The %s keyword requires a positive integer to follow it." +#define ZAXISMAPPING_MSG \ +"The ZAxisMapping keyword requires 2 positive numbers or X or Y to follow it." +#define AUTOREPEAT_MSG \ +"The AutoRepeat keyword requires 2 numbers (delay and rate) to follow it." +#define XLEDS_MSG \ +"The XLeds keyword requries one or more numbers to follow it." +#define DACSPEED_MSG \ +"The DacSpeed keyword must be followed by a list of up to %d numbers." +#define DISPLAYSIZE_MSG \ +"The DisplaySize keyword must be followed by the width and height in mm." +#define HORIZSYNC_MSG \ +"The HorizSync keyword must be followed by a list of numbers or ranges." +#define VERTREFRESH_MSG \ +"The VertRefresh keyword must be followed by a list of numbers or ranges." +#define VIEWPORT_MSG \ +"The Viewport keyword must be followed by an X and Y value." +#define VIRTUAL_MSG \ +"The Virtual keyword must be followed by a width and height value." +#define WEIGHT_MSG \ +"The Weight keyword must be followed by red, green and blue values." +#define BLACK_MSG \ +"The Black keyword must be followed by red, green and blue values." +#define WHITE_MSG \ +"The White keyword must be followed by red, green and blue values." +#define SCREEN_MSG \ +"The Screen keyword must be followed by an optional number, a screen name\n" \ +"\tin quotes, and optional position/layout information." +#define INVALID_SCR_MSG \ +"Invalid Screen line." +#define INPUTDEV_MSG \ +"The InputDevice keyword must be followed by an input device name in quotes." +#define INACTIVE_MSG \ +"The Inactive keyword must be followed by a Device name in quotes." +#define UNDEFINED_SCREEN_MSG \ +"Undefined Screen \"%s\" referenced by ServerLayout \"%s\"." +#define UNDEFINED_MONITOR_MSG \ +"Undefined Monitor \"%s\" referenced by Screen \"%s\"." +#define UNDEFINED_MODES_MSG \ +"Undefined Modes Section \"%s\" referenced by Monitor \"%s\"." +#define UNDEFINED_DEVICE_MSG \ +"Undefined Device \"%s\" referenced by Screen \"%s\"." +#define UNDEFINED_ADAPTOR_MSG \ +"Undefined VideoAdaptor \"%s\" referenced by Screen \"%s\"." +#define ADAPTOR_REF_TWICE_MSG \ +"VideoAdaptor \"%s\" already referenced by Screen \"%s\"." +#define UNDEFINED_DEVICE_LAY_MSG \ +"Undefined Device \"%s\" referenced by ServerLayout \"%s\"." +#define UNDEFINED_INPUT_MSG \ +"Undefined InputDevice \"%s\" referenced by ServerLayout \"%s\"." +#define NO_IDENT_MSG \ +"This section must have an Identifier line." +#define ONLY_ONE_MSG \ +"This section must have only one of either %s line." +#define UNDEFINED_DRIVER_MSG \ +"Device section \"%s\" must have a Driver line." +#define UNDEFINED_INPUTDRIVER_MSG \ +"InputDevice section \"%s\" must have a Driver line." +#define INVALID_GAMMA_MSG \ +"gamma correction value(s) expected\n either one value or three r/g/b values." +#define GROUP_MSG \ +"The Group keyword must be followed by either a group name in quotes or\n" \ +"\ta numerical group id." +#define MULTIPLE_MSG \ +"Multiple \"%s\" lines." + +/* Warning messages */ +#define OBSOLETE_MSG \ +"Ignoring obsolete keyword \"%s\"." +#define MOVED_TO_FLAGS_MSG \ +"Keyword \"%s\" is now an Option flag in the ServerFlags section." + +#endif /* _Configint_h_ */ diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/DRI.c b/nx-X11/programs/Xserver/hw/xfree86/parser/DRI.c new file mode 100644 index 000000000..93d0d4b52 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/parser/DRI.c @@ -0,0 +1,187 @@ +/* DRI.c -- DRI Section in XF86Config file + * Created: Fri Mar 19 08:40:22 1999 by faith@precisioninsight.com + * Revised: Thu Jun 17 16:08:05 1999 by faith@precisioninsight.com + * + * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * 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 (including the next + * paragraph) 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 + * PRECISION INSIGHT AND/OR ITS SUPPLIERS 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. + * + * $XFree86: xc/programs/Xserver/hw/xfree86/parser/DRI.c,v 1.13 2003/01/01 19:22:20 paulo Exp $ + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Parser.h" +#include "xf86tokens.h" +#include "Configint.h" + +extern LexRec val; + +static xf86ConfigSymTabRec DRITab[] = +{ + {ENDSECTION, "endsection"}, + {GROUP, "group"}, + {BUFFERS, "buffers"}, + {MODE, "mode"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeBuffersList + +XF86ConfBuffersPtr +xf86parseBuffers (void) +{ + int token; + parsePrologue (XF86ConfBuffersPtr, XF86ConfBuffersRec) + + if (xf86getSubToken (&(ptr->buf_comment)) != NUMBER) + Error ("Buffers count expected", NULL); + ptr->buf_count = val.num; + + if (xf86getSubToken (&(ptr->buf_comment)) != NUMBER) + Error ("Buffers size expected", NULL); + ptr->buf_size = val.num; + + if ((token = xf86getSubToken (&(ptr->buf_comment))) == STRING) { + ptr->buf_flags = val.str; + if ((token = xf86getToken (NULL)) == COMMENT) + ptr->buf_comment = xf86addComment(ptr->buf_comment, val.str); + else + xf86unGetToken(token); + } + +#ifdef DEBUG + printf ("Buffers parsed\n"); +#endif + + return ptr; +} + +#undef CLEANUP + +#define CLEANUP xf86freeDRI + +XF86ConfDRIPtr +xf86parseDRISection (void) +{ + int token; + parsePrologue (XF86ConfDRIPtr, XF86ConfDRIRec); + + /* Zero is a valid value for this. */ + ptr->dri_group = -1; + while ((token = xf86getToken (DRITab)) != ENDSECTION) { + switch (token) + { + case GROUP: + if ((token = xf86getSubToken (&(ptr->dri_comment))) == STRING) + ptr->dri_group_name = val.str; + else if (token == NUMBER) + ptr->dri_group = val.num; + else + Error (GROUP_MSG, NULL); + break; + case MODE: + if (xf86getSubToken (&(ptr->dri_comment)) != NUMBER) + Error (NUMBER_MSG, "Mode"); + ptr->dri_mode = val.num; + break; + case BUFFERS: + HANDLE_LIST (dri_buffers_lst, xf86parseBuffers, + XF86ConfBuffersPtr); + break; + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + case COMMENT: + ptr->dri_comment = xf86addComment(ptr->dri_comment, val.str); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + } + +#ifdef DEBUG + ErrorF("DRI section parsed\n"); +#endif + + return ptr; +} + +#undef CLEANUP + +void +xf86printDRISection (FILE * cf, XF86ConfDRIPtr ptr) +{ + XF86ConfBuffersPtr bufs; + + if (ptr == NULL) + return; + + fprintf (cf, "Section \"DRI\"\n"); + if (ptr->dri_comment) + fprintf (cf, "%s", ptr->dri_comment); + if (ptr->dri_group_name) + fprintf (cf, "\tGroup \"%s\"\n", ptr->dri_group_name); + else if (ptr->dri_group >= 0) + fprintf (cf, "\tGroup %d\n", ptr->dri_group); + if (ptr->dri_mode) + fprintf (cf, "\tMode 0%o\n", ptr->dri_mode); + for (bufs = ptr->dri_buffers_lst; bufs; bufs = bufs->list.next) { + fprintf (cf, "\tBuffers %d %d", + bufs->buf_count, bufs->buf_size); + if (bufs->buf_flags) fprintf (cf, " \"%s\"", bufs->buf_flags); + if (bufs->buf_comment) + fprintf(cf, "%s", bufs->buf_comment); + else + fprintf (cf, "\n"); + } + fprintf (cf, "EndSection\n\n"); +} + +void +xf86freeDRI (XF86ConfDRIPtr ptr) +{ + if (ptr == NULL) + return; + + xf86freeBuffersList (ptr->dri_buffers_lst); + TestFree (ptr->dri_comment); + xf86conffree (ptr); +} + +void +xf86freeBuffersList (XF86ConfBuffersPtr ptr) +{ + XF86ConfBuffersPtr prev; + + while (ptr) { + TestFree (ptr->buf_flags); + TestFree (ptr->buf_comment); + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } +} + diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/Device.c b/nx-X11/programs/Xserver/hw/xfree86/parser/Device.c new file mode 100644 index 000000000..6eb2857f0 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/parser/Device.c @@ -0,0 +1,403 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Device.c,v 1.27 2003/08/24 17:37:07 dawes Exp $ */ +/* + * + * 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" + +extern LexRec val; + +static +xf86ConfigSymTabRec DeviceTab[] = +{ + {ENDSECTION, "endsection"}, + {IDENTIFIER, "identifier"}, + {VENDOR, "vendorname"}, + {BOARD, "boardname"}, + {CHIPSET, "chipset"}, + {RAMDAC, "ramdac"}, + {DACSPEED, "dacspeed"}, + {CLOCKS, "clocks"}, + {OPTION, "option"}, + {VIDEORAM, "videoram"}, + {BIOSBASE, "biosbase"}, + {MEMBASE, "membase"}, + {IOBASE, "iobase"}, + {CLOCKCHIP, "clockchip"}, + {CHIPID, "chipid"}, + {CHIPREV, "chiprev"}, + {CARD, "card"}, + {DRIVER, "driver"}, + {BUSID, "busid"}, + {TEXTCLOCKFRQ, "textclockfreq"}, + {IRQ, "irq"}, + {SCREEN, "screen"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeDeviceList + +XF86ConfDevicePtr +xf86parseDeviceSection (void) +{ + int i; + int has_ident = FALSE; + int token; + parsePrologue (XF86ConfDevicePtr, XF86ConfDeviceRec) + + /* Zero is a valid value for these */ + ptr->dev_chipid = -1; + ptr->dev_chiprev = -1; + ptr->dev_irq = -1; + while ((token = xf86getToken (DeviceTab)) != ENDSECTION) + { + switch (token) + { + case COMMENT: + ptr->dev_comment = xf86addComment(ptr->dev_comment, val.str); + break; + case IDENTIFIER: + if (xf86getSubToken (&(ptr->dev_comment)) != STRING) + Error (QUOTE_MSG, "Identifier"); + if (has_ident == TRUE) + Error (MULTIPLE_MSG, "Identifier"); + ptr->dev_identifier = val.str; + has_ident = TRUE; + break; + case VENDOR: + if (xf86getSubToken (&(ptr->dev_comment)) != STRING) + Error (QUOTE_MSG, "Vendor"); + ptr->dev_vendor = val.str; + break; + case BOARD: + if (xf86getSubToken (&(ptr->dev_comment)) != STRING) + Error (QUOTE_MSG, "Board"); + ptr->dev_board = val.str; + break; + case CHIPSET: + if (xf86getSubToken (&(ptr->dev_comment)) != STRING) + Error (QUOTE_MSG, "Chipset"); + ptr->dev_chipset = val.str; + break; + case CARD: + if (xf86getSubToken (&(ptr->dev_comment)) != STRING) + Error (QUOTE_MSG, "Card"); + ptr->dev_card = val.str; + break; + case DRIVER: + if (xf86getSubToken (&(ptr->dev_comment)) != STRING) + Error (QUOTE_MSG, "Driver"); + ptr->dev_driver = val.str; + break; + case RAMDAC: + if (xf86getSubToken (&(ptr->dev_comment)) != STRING) + Error (QUOTE_MSG, "Ramdac"); + ptr->dev_ramdac = val.str; + break; + case DACSPEED: + for (i = 0; i < CONF_MAXDACSPEEDS; i++) + ptr->dev_dacSpeeds[i] = 0; + if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER) + { + Error (DACSPEED_MSG, CONF_MAXDACSPEEDS); + } + else + { + ptr->dev_dacSpeeds[0] = (int) (val.realnum * 1000.0 + 0.5); + for (i = 1; i < CONF_MAXDACSPEEDS; i++) + { + if (xf86getSubToken (&(ptr->dev_comment)) == NUMBER) + ptr->dev_dacSpeeds[i] = (int) + (val.realnum * 1000.0 + 0.5); + else + { + xf86unGetToken (token); + break; + } + } + } + break; + case VIDEORAM: + if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER) + Error (NUMBER_MSG, "VideoRam"); + ptr->dev_videoram = val.num; + break; + case BIOSBASE: + if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER) + Error (NUMBER_MSG, "BIOSBase"); + ptr->dev_bios_base = val.num; + break; + case MEMBASE: + if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER) + Error (NUMBER_MSG, "MemBase"); + ptr->dev_mem_base = val.num; + break; + case IOBASE: + if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER) + Error (NUMBER_MSG, "IOBase"); + ptr->dev_io_base = val.num; + break; + case CLOCKCHIP: + if (xf86getSubToken (&(ptr->dev_comment)) != STRING) + Error (QUOTE_MSG, "ClockChip"); + ptr->dev_clockchip = val.str; + break; + case CHIPID: + if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER) + Error (NUMBER_MSG, "ChipID"); + ptr->dev_chipid = val.num; + break; + case CHIPREV: + if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER) + Error (NUMBER_MSG, "ChipRev"); + ptr->dev_chiprev = val.num; + break; + + case CLOCKS: + token = xf86getSubToken(&(ptr->dev_comment)); + for( i = ptr->dev_clocks; + token == NUMBER && i < CONF_MAXCLOCKS; i++ ) { + ptr->dev_clock[i] = (int)(val.realnum * 1000.0 + 0.5); + token = xf86getSubToken(&(ptr->dev_comment)); + } + ptr->dev_clocks = i; + xf86unGetToken (token); + break; + case TEXTCLOCKFRQ: + if ((token = xf86getSubToken(&(ptr->dev_comment))) != NUMBER) + Error (NUMBER_MSG, "TextClockFreq"); + ptr->dev_textclockfreq = (int)(val.realnum * 1000.0 + 0.5); + break; + case OPTION: + ptr->dev_option_lst = xf86parseOption(ptr->dev_option_lst); + break; + case BUSID: + if (xf86getSubToken (&(ptr->dev_comment)) != STRING) + Error (QUOTE_MSG, "BusID"); + ptr->dev_busid = val.str; + break; + case IRQ: + if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER) + Error (QUOTE_MSG, "IRQ"); + ptr->dev_irq = val.num; + break; + case SCREEN: + if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER) + Error (NUMBER_MSG, "Screen"); + ptr->dev_screen = val.num; + 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 ("Device section parsed\n"); +#endif + + return ptr; +} + +#undef CLEANUP + +void +xf86printDeviceSection (FILE * cf, XF86ConfDevicePtr ptr) +{ + int i; + + while (ptr) + { + fprintf (cf, "Section \"Device\"\n"); + if (ptr->dev_comment) + fprintf (cf, "%s", ptr->dev_comment); + if (ptr->dev_identifier) + fprintf (cf, "\tIdentifier \"%s\"\n", ptr->dev_identifier); + if (ptr->dev_driver) + fprintf (cf, "\tDriver \"%s\"\n", ptr->dev_driver); + if (ptr->dev_vendor) + fprintf (cf, "\tVendorName \"%s\"\n", ptr->dev_vendor); + if (ptr->dev_board) + fprintf (cf, "\tBoardName \"%s\"\n", ptr->dev_board); + if (ptr->dev_chipset) + fprintf (cf, "\tChipSet \"%s\"\n", ptr->dev_chipset); + if (ptr->dev_card) + fprintf (cf, "\tCard \"%s\"\n", ptr->dev_card); + if (ptr->dev_ramdac) + fprintf (cf, "\tRamDac \"%s\"\n", ptr->dev_ramdac); + if (ptr->dev_dacSpeeds[0] > 0 ) { + fprintf (cf, "\tDacSpeed "); + for (i = 0; i < CONF_MAXDACSPEEDS + && ptr->dev_dacSpeeds[i] > 0; i++ ) + fprintf (cf, "%g ", (double) (ptr->dev_dacSpeeds[i])/ 1000.0 ); + fprintf (cf, "\n"); + } + if (ptr->dev_videoram) + fprintf (cf, "\tVideoRam %d\n", ptr->dev_videoram); + if (ptr->dev_bios_base) + fprintf (cf, "\tBiosBase 0x%lx\n", ptr->dev_bios_base); + if (ptr->dev_mem_base) + fprintf (cf, "\tMemBase 0x%lx\n", ptr->dev_mem_base); + if (ptr->dev_io_base) + fprintf (cf, "\tIOBase 0x%lx\n", ptr->dev_io_base); + if (ptr->dev_clockchip) + fprintf (cf, "\tClockChip \"%s\"\n", ptr->dev_clockchip); + if (ptr->dev_chipid != -1) + fprintf (cf, "\tChipId 0x%x\n", ptr->dev_chipid); + if (ptr->dev_chiprev != -1) + fprintf (cf, "\tChipRev 0x%x\n", ptr->dev_chiprev); + + xf86printOptionList(cf, ptr->dev_option_lst, 1); + if (ptr->dev_clocks > 0 ) { + fprintf (cf, "\tClocks "); + for (i = 0; i < ptr->dev_clocks; i++ ) + fprintf (cf, "%.1f ", (double)ptr->dev_clock[i] / 1000.0 ); + fprintf (cf, "\n"); + } + if (ptr->dev_textclockfreq) { + fprintf (cf, "\tTextClockFreq %.1f\n", + (double)ptr->dev_textclockfreq / 1000.0); + } + if (ptr->dev_busid) + fprintf (cf, "\tBusID \"%s\"\n", ptr->dev_busid); + if (ptr->dev_screen > 0) + fprintf (cf, "\tScreen %d\n", ptr->dev_screen); + if (ptr->dev_irq >= 0) + fprintf (cf, "\tIRQ %d\n", ptr->dev_irq); + fprintf (cf, "EndSection\n\n"); + ptr = ptr->list.next; + } +} + +void +xf86freeDeviceList (XF86ConfDevicePtr ptr) +{ + XF86ConfDevicePtr prev; + + while (ptr) + { + TestFree (ptr->dev_identifier); + TestFree (ptr->dev_vendor); + TestFree (ptr->dev_board); + TestFree (ptr->dev_chipset); + TestFree (ptr->dev_card); + TestFree (ptr->dev_driver); + TestFree (ptr->dev_ramdac); + TestFree (ptr->dev_clockchip); + TestFree (ptr->dev_comment); + xf86optionListFree (ptr->dev_option_lst); + + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } +} + +int +xf86validateDevice (XF86ConfigPtr p) +{ + XF86ConfDevicePtr device = p->conf_device_lst; + + if (!device) { + xf86validationError ("At least one Device section is required."); + return (FALSE); + } + + while (device) { + if (!device->dev_driver) { + xf86validationError (UNDEFINED_DRIVER_MSG, device->dev_identifier); + return (FALSE); + } + device = device->list.next; + } + return (TRUE); +} + +XF86ConfDevicePtr +xf86findDevice (const char *ident, XF86ConfDevicePtr p) +{ + while (p) + { + if (xf86nameCompare (ident, p->dev_identifier) == 0) + return (p); + + p = p->list.next; + } + return (NULL); +} + +char * +xf86configStrdup (const char *s) +{ + char *tmp; + if (!s) return NULL; + tmp = xf86confmalloc (sizeof (char) * (strlen (s) + 1)); + if (tmp) + strcpy (tmp, s); + return (tmp); +} diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/Extensions.c b/nx-X11/programs/Xserver/hw/xfree86/parser/Extensions.c new file mode 100644 index 000000000..b64f08111 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/parser/Extensions.c @@ -0,0 +1,111 @@ +/* + * Copyright 2004 Red Hat Inc., Raleigh, North Carolina. + * + * All Rights Reserved. + * + * 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 on 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 (including the + * next paragraph) 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 + * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS + * 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. + */ + +/* + * Authors: + * Kevin E. Martin <kem@redhat.com> + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Parser.h" +#include "xf86tokens.h" +#include "Configint.h" + +extern LexRec val; + +static xf86ConfigSymTabRec ExtensionsTab[] = +{ + {ENDSECTION, "endsection"}, + {OPTION, "option"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeExtensions + +XF86ConfExtensionsPtr +xf86parseExtensionsSection (void) +{ + int token; + parsePrologue (XF86ConfExtensionsPtr, XF86ConfExtensionsRec); + + while ((token = xf86getToken (ExtensionsTab)) != ENDSECTION) { + switch (token) { + case OPTION: + ptr->ext_option_lst = xf86parseOption(ptr->ext_option_lst); + break; + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + case COMMENT: + ptr->extensions_comment = + xf86addComment(ptr->extensions_comment, val.str); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + } + +#ifdef DEBUG + ErrorF("Extensions section parsed\n"); +#endif + + return ptr; +} + +#undef CLEANUP + +void +xf86printExtensionsSection (FILE * cf, XF86ConfExtensionsPtr ptr) +{ + XF86OptionPtr p; + + if (ptr == NULL || ptr->ext_option_lst == NULL) + return; + + p = ptr->ext_option_lst; + fprintf (cf, "Section \"Extensions\"\n"); + if (ptr->extensions_comment) + fprintf (cf, "%s", ptr->extensions_comment); + xf86printOptionList(cf, p, 1); + fprintf (cf, "EndSection\n\n"); +} + +void +xf86freeExtensions (XF86ConfExtensionsPtr ptr) +{ + if (ptr == NULL) + return; + + xf86optionListFree (ptr->ext_option_lst); + TestFree (ptr->extensions_comment); + xf86conffree (ptr); +} diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/Files.c b/nx-X11/programs/Xserver/hw/xfree86/parser/Files.c new file mode 100644 index 000000000..cbbcc74c8 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/parser/Files.c @@ -0,0 +1,295 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Files.c,v 1.16 2003/08/24 17:37:07 dawes Exp $ */ +/* + * + * 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 <X11/Xos.h> +#include "xf86Parser.h" +#include "xf86tokens.h" +#include "Configint.h" + +extern LexRec val; + +static xf86ConfigSymTabRec FilesTab[] = +{ + {ENDSECTION, "endsection"}, + {FONTPATH, "fontpath"}, + {RGBPATH, "rgbpath"}, + {MODULEPATH, "modulepath"}, + {INPUTDEVICES, "inputdevices"}, + {LOGFILEPATH, "logfile"}, + {-1, ""}, +}; + +static char * +prependRoot (char *pathname) +{ +#ifndef __EMX__ + return pathname; +#else + /* XXXX caveat: multiple path components in line */ + return (char *) __XOS2RedirRoot (pathname); +#endif +} + +#define CLEANUP xf86freeFiles + +XF86ConfFilesPtr +xf86parseFilesSection (void) +{ + int i, j; + int k, l; + char *str; + int token; + parsePrologue (XF86ConfFilesPtr, XF86ConfFilesRec) + + while ((token = xf86getToken (FilesTab)) != ENDSECTION) + { + switch (token) + { + case COMMENT: + ptr->file_comment = xf86addComment(ptr->file_comment, val.str); + break; + case FONTPATH: + if (xf86getSubToken (&(ptr->file_comment)) != STRING) + Error (QUOTE_MSG, "FontPath"); + j = FALSE; + str = prependRoot (val.str); + if (ptr->file_fontpath == NULL) + { + ptr->file_fontpath = xf86confmalloc (1); + ptr->file_fontpath[0] = '\0'; + i = strlen (str) + 1; + } + else + { + i = strlen (ptr->file_fontpath) + strlen (str) + 1; + if (ptr->file_fontpath[strlen (ptr->file_fontpath) - 1] != ',') + { + i++; + j = TRUE; + } + } + ptr->file_fontpath = + xf86confrealloc (ptr->file_fontpath, i); + if (j) + strcat (ptr->file_fontpath, ","); + + strcat (ptr->file_fontpath, str); + xf86conffree (val.str); + break; + case RGBPATH: + if (xf86getSubToken (&(ptr->file_comment)) != STRING) + Error (QUOTE_MSG, "RGBPath"); + ptr->file_rgbpath = val.str; + break; + case MODULEPATH: + if (xf86getSubToken (&(ptr->file_comment)) != STRING) + Error (QUOTE_MSG, "ModulePath"); + l = FALSE; + str = prependRoot (val.str); + if (ptr->file_modulepath == NULL) + { + ptr->file_modulepath = xf86confmalloc (1); + ptr->file_modulepath[0] = '\0'; + k = strlen (str) + 1; + } + else + { + k = strlen (ptr->file_modulepath) + strlen (str) + 1; + if (ptr->file_modulepath[strlen (ptr->file_modulepath) - 1] != ',') + { + k++; + l = TRUE; + } + } + ptr->file_modulepath = xf86confrealloc (ptr->file_modulepath, k); + if (l) + strcat (ptr->file_modulepath, ","); + + strcat (ptr->file_modulepath, str); + xf86conffree (val.str); + break; + case INPUTDEVICES: + if (xf86getSubToken (&(ptr->file_comment)) != STRING) + Error (QUOTE_MSG, "InputDevices"); + l = FALSE; + str = prependRoot (val.str); + if (ptr->file_inputdevs == NULL) + { + ptr->file_inputdevs = xf86confmalloc (1); + ptr->file_inputdevs[0] = '\0'; + k = strlen (str) + 1; + } + else + { + k = strlen (ptr->file_inputdevs) + strlen (str) + 1; + if (ptr->file_inputdevs[strlen (ptr->file_inputdevs) - 1] != ',') + { + k++; + l = TRUE; + } + } + ptr->file_inputdevs = xf86confrealloc (ptr->file_inputdevs, k); + if (l) + strcat (ptr->file_inputdevs, ","); + + strcat (ptr->file_inputdevs, str); + xf86conffree (val.str); + break; + case LOGFILEPATH: + if (xf86getSubToken (&(ptr->file_comment)) != STRING) + Error (QUOTE_MSG, "LogFile"); + ptr->file_logfile = val.str; + break; + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + } + +#ifdef DEBUG + printf ("File section parsed\n"); +#endif + + return ptr; +} + +#undef CLEANUP + +void +xf86printFileSection (FILE * cf, XF86ConfFilesPtr ptr) +{ + char *p, *s; + + if (ptr == NULL) + return; + + if (ptr->file_comment) + fprintf (cf, "%s", ptr->file_comment); + if (ptr->file_logfile) + fprintf (cf, "\tLogFile \"%s\"\n", ptr->file_logfile); + if (ptr->file_rgbpath) + fprintf (cf, "\tRgbPath \"%s\"\n", ptr->file_rgbpath); + if (ptr->file_modulepath) + { + s = ptr->file_modulepath; + p = index (s, ','); + while (p) + { + *p = '\000'; + fprintf (cf, "\tModulePath \"%s\"\n", s); + *p = ','; + s = p; + s++; + p = index (s, ','); + } + fprintf (cf, "\tModulePath \"%s\"\n", s); + } + if (ptr->file_inputdevs) + { + s = ptr->file_inputdevs; + p = index (s, ','); + while (p) + { + *p = '\000'; + fprintf (cf, "\tInputDevices \"%s\"\n", s); + *p = ','; + s = p; + s++; + p = index (s, ','); + } + fprintf (cf, "\tInputdevs \"%s\"\n", s); + } + if (ptr->file_fontpath) + { + s = ptr->file_fontpath; + p = index (s, ','); + while (p) + { + *p = '\000'; + fprintf (cf, "\tFontPath \"%s\"\n", s); + *p = ','; + s = p; + s++; + p = index (s, ','); + } + fprintf (cf, "\tFontPath \"%s\"\n", s); + } +} + +void +xf86freeFiles (XF86ConfFilesPtr p) +{ + if (p == NULL) + return; + + TestFree (p->file_logfile); + TestFree (p->file_rgbpath); + TestFree (p->file_modulepath); + TestFree (p->file_inputdevs); + TestFree (p->file_fontpath); + TestFree (p->file_comment); + + xf86conffree (p); +} diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/Flags.c b/nx-X11/programs/Xserver/hw/xfree86/parser/Flags.c new file mode 100644 index 000000000..bda24df1b --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/parser/Flags.c @@ -0,0 +1,525 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Flags.c,v 1.23 2003/08/24 17:37:07 dawes Exp $ */ +/* + * + * 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 <math.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; + /* can't use strdup because it calls malloc */ + tmp = xf86configStrdup (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); + valstr = xf86confmalloc(16); + if (valstr) + sprintf(valstr, "%d", val.num); + } + } + 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 */ + if (head != NULL && (old = xf86findOption(head, name)) != NULL) + new = old; + else { + new = xf86confcalloc (1, sizeof (XF86OptionRec)); + new->list.next = NULL; + } + new->opt_name = name; + new->opt_val = val; + new->opt_used = used; + + if (old == NULL) + return ((XF86OptionPtr) xf86addListItem ((glp) head, (glp) new)); + else + return head; +} + +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); + xf86conffree (flags); +} + +XF86OptionPtr +xf86optionListDup (XF86OptionPtr opt) +{ + XF86OptionPtr newopt = NULL; + + while (opt) + { + newopt = xf86addNewOption(newopt, xf86configStrdup(opt->opt_name), + xf86configStrdup(opt->opt_val)); + newopt->opt_used = opt->opt_used; + if (opt->opt_comment) + newopt->opt_comment = xf86configStrdup(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; + xf86conffree (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 = xf86confcalloc(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) + { + /* can't use strdup because it calls malloc */ + t1 = xf86confmalloc (sizeof (char) * + (strlen (options[i]) + 1)); + strcpy (t1, options[i]); + t2 = xf86confmalloc (sizeof (char) * + (strlen (options[i + 1]) + 1)); + strcpy (t2, 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; + int l; + + l = (int)(ceil(log10((double)i) + 2.5)); + s = xf86confmalloc(l); + if (!s) + return NULL; + sprintf(s, "%lu", i); + return s; +} + +void +xf86debugListOptions(XF86OptionPtr Options) +{ + while (Options) { + ErrorF("Option: %s Value: %s\n",Options->opt_name,Options->opt_val); + Options = Options->list.next; + } +} + +XF86OptionPtr +xf86parseOption(XF86OptionPtr head) +{ + XF86OptionPtr option, cnew, old; + char *name, *comment = NULL; + int token; + + if ((token = xf86getSubToken(&comment)) != STRING) { + xf86parseError(BAD_OPTION_MSG, NULL); + if (comment) + xf86conffree(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; + xf86conffree(option->opt_name); + TestFree(option->opt_val); + TestFree(option->opt_comment); + xf86conffree(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/nx-X11/programs/Xserver/hw/xfree86/parser/Imakefile b/nx-X11/programs/Xserver/hw/xfree86/parser/Imakefile new file mode 100644 index 000000000..29708b64b --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/parser/Imakefile @@ -0,0 +1,51 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Imakefile,v 1.12 2001/01/12 19:28:35 dawes Exp $ */ + + + +#define DoNormalLib YES +#define DoSharedLib NO +#define DoDebugLib NO +#define DoProfileLib NO +#define HasSharedData NO +#define LibName xf86config + +#define UseDBMalloc NO + +#if UseDBMalloc +SYS_LIBRARIES=-ldbmalloc +DBMALLOCDEFINE=-DDBMALLOC +#endif + +SYS_LIBRARIES = MathLibrary + +XCONFIGFILE = XConfigFile +XCONFIGDIR = XConfigDir +#if defined XFree86Version +XVERS = XFree86Version +#elif defined (XorgVersion) +XVERS = XorgVersion +#endif + +INCLUDES = -I. -I$(XF86OSSRC) + +HEADERS = xf86Parser.h xf86Optrec.h + +SRCS = Device.c Files.c Flags.c Input.c Keyboard.c Layout.c Module.c \ + Video.c Monitor.c Pointer.c Screen.c Vendor.c read.c scan.c write.c \ + DRI.c Extensions.c +OBJS = Device.o Files.o Flags.o Input.o Keyboard.o Layout.o Module.o \ + Video.o Monitor.o Pointer.o Screen.o Vendor.o read.o scan.o write.o \ + DRI.o Extensions.o + +CONFIG_DEFINES = -DXCONFIGDIR=\"$(XCONFIGDIR)\" \ + -DXCONFIGFILE=\"$(XCONFIGFILE)\" \ + -DXVERSION="$(XVERS)" + +#include <Library.tmpl> + +SpecialCObjectRule(scan,NullParameter,$(CONFIG_DEFINES) $(MODULEDEFINES) $(EXT_DEFINES)) + +NormalProgramTarget(cpconfig,cpconfig.o $(OBJS),NullParameter,$(LOCAL_LIBRARIES),NullParameter) + +AllTarget(ProgramTargetName(cpconfig)) +DependTarget() diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/Input.c b/nx-X11/programs/Xserver/hw/xfree86/parser/Input.c new file mode 100644 index 000000000..9f9323f05 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/parser/Input.c @@ -0,0 +1,215 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Input.c,v 1.14 2003/08/24 17:37:07 dawes Exp $ */ +/* + * + * 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" + +extern LexRec val; + +static +xf86ConfigSymTabRec InputTab[] = +{ + {ENDSECTION, "endsection"}, + {IDENTIFIER, "identifier"}, + {OPTION, "option"}, + {DRIVER, "driver"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeInputList + +XF86ConfInputPtr +xf86parseInputSection (void) +{ + int has_ident = FALSE; + int token; + parsePrologue (XF86ConfInputPtr, XF86ConfInputRec) + + while ((token = xf86getToken (InputTab)) != ENDSECTION) + { + switch (token) + { + case COMMENT: + ptr->inp_comment = xf86addComment(ptr->inp_comment, val.str); + break; + case IDENTIFIER: + if (xf86getSubToken (&(ptr->inp_comment)) != STRING) + Error (QUOTE_MSG, "Identifier"); + if (has_ident == TRUE) + Error (MULTIPLE_MSG, "Identifier"); + ptr->inp_identifier = val.str; + has_ident = TRUE; + break; + case DRIVER: + if (xf86getSubToken (&(ptr->inp_comment)) != STRING) + Error (QUOTE_MSG, "Driver"); + ptr->inp_driver = val.str; + break; + case OPTION: + ptr->inp_option_lst = xf86parseOption(ptr->inp_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 ("InputDevice section parsed\n"); +#endif + + return ptr; +} + +#undef CLEANUP + +void +xf86printInputSection (FILE * cf, XF86ConfInputPtr ptr) +{ + while (ptr) + { + fprintf (cf, "Section \"InputDevice\"\n"); + if (ptr->inp_comment) + fprintf (cf, "%s", ptr->inp_comment); + if (ptr->inp_identifier) + fprintf (cf, "\tIdentifier \"%s\"\n", ptr->inp_identifier); + if (ptr->inp_driver) + fprintf (cf, "\tDriver \"%s\"\n", ptr->inp_driver); + xf86printOptionList(cf, ptr->inp_option_lst, 1); + fprintf (cf, "EndSection\n\n"); + ptr = ptr->list.next; + } +} + +void +xf86freeInputList (XF86ConfInputPtr ptr) +{ + XF86ConfInputPtr prev; + + while (ptr) + { + TestFree (ptr->inp_identifier); + TestFree (ptr->inp_driver); + TestFree (ptr->inp_comment); + xf86optionListFree (ptr->inp_option_lst); + + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } +} + +int +xf86validateInput (XF86ConfigPtr p) +{ + XF86ConfInputPtr input = p->conf_input_lst; + +#if 0 /* Enable this later */ + if (!input) { + xf86validationError ("At least one InputDevice section is required."); + return (FALSE); + } +#endif + + while (input) { + if (!input->inp_driver) { + xf86validationError (UNDEFINED_INPUTDRIVER_MSG, input->inp_identifier); + return (FALSE); + } + input = input->list.next; + } + return (TRUE); +} + +XF86ConfInputPtr +xf86findInput (const char *ident, XF86ConfInputPtr p) +{ + while (p) + { + if (xf86nameCompare (ident, p->inp_identifier) == 0) + return (p); + + p = p->list.next; + } + return (NULL); +} + +XF86ConfInputPtr +xf86findInputByDriver (const char *driver, XF86ConfInputPtr p) +{ + while (p) + { + if (xf86nameCompare (driver, p->inp_driver) == 0) + return (p); + + p = p->list.next; + } + return (NULL); +} + diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/Keyboard.c b/nx-X11/programs/Xserver/hw/xfree86/parser/Keyboard.c new file mode 100644 index 000000000..4ba893a9d --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/parser/Keyboard.c @@ -0,0 +1,306 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Keyboard.c,v 1.17 2003/08/24 17:37:07 dawes Exp $ */ +/* + * + * 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 "ctype.h" + +extern LexRec val; + +static xf86ConfigSymTabRec KeyboardTab[] = +{ + {ENDSECTION, "endsection"}, + {KPROTOCOL, "protocol"}, + {AUTOREPEAT, "autorepeat"}, + {XLEDS, "xleds"}, + {PANIX106, "panix106"}, + {XKBKEYMAP, "xkbkeymap"}, + {XKBCOMPAT, "xkbcompat"}, + {XKBTYPES, "xkbtypes"}, + {XKBKEYCODES, "xkbkeycodes"}, + {XKBGEOMETRY, "xkbgeometry"}, + {XKBSYMBOLS, "xkbsymbols"}, + {XKBDISABLE, "xkbdisable"}, + {XKBRULES, "xkbrules"}, + {XKBMODEL, "xkbmodel"}, + {XKBLAYOUT, "xkblayout"}, + {XKBVARIANT, "xkbvariant"}, + {XKBOPTIONS, "xkboptions"}, + /* The next two have become ServerFlags options */ + {VTINIT, "vtinit"}, + {VTSYSREQ, "vtsysreq"}, + /* Obsolete keywords */ + {SERVERNUM, "servernumlock"}, + {LEFTALT, "leftalt"}, + {RIGHTALT, "rightalt"}, + {RIGHTALT, "altgr"}, + {SCROLLLOCK_TOK, "scrolllock"}, + {RIGHTCTL, "rightctl"}, + {-1, ""}, +}; + +/* Obsolete */ +static xf86ConfigSymTabRec KeyMapTab[] = +{ + {CONF_KM_META, "meta"}, + {CONF_KM_COMPOSE, "compose"}, + {CONF_KM_MODESHIFT, "modeshift"}, + {CONF_KM_MODELOCK, "modelock"}, + {CONF_KM_SCROLLLOCK, "scrolllock"}, + {CONF_KM_CONTROL, "control"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeInputList + +XF86ConfInputPtr +xf86parseKeyboardSection (void) +{ + char *s, *s1, *s2; + int l; + int token, ntoken; + parsePrologue (XF86ConfInputPtr, XF86ConfInputRec) + + while ((token = xf86getToken (KeyboardTab)) != ENDSECTION) + { + switch (token) + { + case COMMENT: + ptr->inp_comment = xf86addComment(ptr->inp_comment, val.str); + break; + case KPROTOCOL: + if (xf86getSubToken (&(ptr->inp_comment)) != STRING) + Error (QUOTE_MSG, "Protocol"); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("Protocol"), + val.str); + break; + case AUTOREPEAT: + if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER) + Error (AUTOREPEAT_MSG, NULL); + s1 = xf86uLongToString(val.num); + if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER) + Error (AUTOREPEAT_MSG, NULL); + s2 = xf86uLongToString(val.num); + l = strlen(s1) + 1 + strlen(s2) + 1; + s = xf86confmalloc(l); + sprintf(s, "%s %s", s1, s2); + xf86conffree(s1); + xf86conffree(s2); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("AutoRepeat"), s); + break; + case XLEDS: + if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER) + Error (XLEDS_MSG, NULL); + s = xf86uLongToString(val.num); + l = strlen(s) + 1; + while ((token = xf86getSubToken (&(ptr->inp_comment))) == NUMBER) + { + s1 = xf86uLongToString(val.num); + l += (1 + strlen(s1)); + s = xf86confrealloc(s, l); + strcat(s, " "); + strcat(s, s1); + xf86conffree(s1); + } + xf86unGetToken (token); + break; + case SERVERNUM: + xf86parseWarning(OBSOLETE_MSG, xf86tokenString()); + break; + case LEFTALT: + case RIGHTALT: + case SCROLLLOCK_TOK: + case RIGHTCTL: + xf86parseWarning(OBSOLETE_MSG, xf86tokenString()); + break; + ntoken = xf86getToken (KeyMapTab); + switch (ntoken) + { + case EOF_TOKEN: + xf86parseError (UNEXPECTED_EOF_MSG); + CLEANUP (ptr); + return (NULL); + break; + + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + break; + case VTINIT: + if (xf86getSubToken (&(ptr->inp_comment)) != STRING) + Error (QUOTE_MSG, "VTInit"); + xf86parseWarning(MOVED_TO_FLAGS_MSG, "VTInit"); + break; + case VTSYSREQ: + xf86parseWarning(MOVED_TO_FLAGS_MSG, "VTSysReq"); + break; + case XKBDISABLE: + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("XkbDisable"), + NULL); + break; + case XKBKEYMAP: + if (xf86getSubToken (&(ptr->inp_comment)) != STRING) + Error (QUOTE_MSG, "XKBKeymap"); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("XkbKeymap"), + val.str); + break; + case XKBCOMPAT: + if (xf86getSubToken (&(ptr->inp_comment)) != STRING) + Error (QUOTE_MSG, "XKBCompat"); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("XkbCompat"), + val.str); + break; + case XKBTYPES: + if (xf86getSubToken (&(ptr->inp_comment)) != STRING) + Error (QUOTE_MSG, "XKBTypes"); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("XkbTypes"), + val.str); + break; + case XKBKEYCODES: + if (xf86getSubToken (&(ptr->inp_comment)) != STRING) + Error (QUOTE_MSG, "XKBKeycodes"); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("XkbKeycodes"), + val.str); + break; + case XKBGEOMETRY: + if (xf86getSubToken (&(ptr->inp_comment)) != STRING) + Error (QUOTE_MSG, "XKBGeometry"); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("XkbGeometry"), + val.str); + break; + case XKBSYMBOLS: + if (xf86getSubToken (&(ptr->inp_comment)) != STRING) + Error (QUOTE_MSG, "XKBSymbols"); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("XkbSymbols"), + val.str); + break; + case XKBRULES: + if (xf86getSubToken (&(ptr->inp_comment)) != STRING) + Error (QUOTE_MSG, "XKBRules"); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("XkbRules"), + val.str); + break; + case XKBMODEL: + if (xf86getSubToken (&(ptr->inp_comment)) != STRING) + Error (QUOTE_MSG, "XKBModel"); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("XkbModel"), + val.str); + break; + case XKBLAYOUT: + if (xf86getSubToken (&(ptr->inp_comment)) != STRING) + Error (QUOTE_MSG, "XKBLayout"); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("XkbLayout"), + val.str); + break; + case XKBVARIANT: + if (xf86getSubToken (&(ptr->inp_comment)) != STRING) + Error (QUOTE_MSG, "XKBVariant"); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("XkbVariant"), + val.str); + break; + case XKBOPTIONS: + if (xf86getSubToken (&(ptr->inp_comment)) != STRING) + Error (QUOTE_MSG, "XKBOptions"); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("XkbOptions"), + val.str); + break; + case PANIX106: + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("Panix106"), NULL); + break; + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + } + + ptr->inp_identifier = xf86configStrdup(CONF_IMPLICIT_KEYBOARD); + ptr->inp_driver = xf86configStrdup("keyboard"); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("CoreKeyboard"), NULL); + +#ifdef DEBUG + printf ("Keyboard section parsed\n"); +#endif + + return ptr; +} + diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/Layout.c b/nx-X11/programs/Xserver/hw/xfree86/parser/Layout.c new file mode 100644 index 000000000..56d92a79c --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/parser/Layout.c @@ -0,0 +1,513 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Layout.c,v 1.24 2003/08/24 17:37:07 dawes Exp $ */ +/* + * + * 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> + +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 = xf86confcalloc (1, sizeof (XF86ConfInactiveRec)); + iptr->list.next = NULL; + if (xf86getSubToken (&(ptr->lay_comment)) != STRING) + 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 = xf86confcalloc (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) + 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: + 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) + Error(INVALID_SCR_MSG, NULL); + aptr->adj_y = val.num; + } else { + if (absKeyword) + 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) + 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) + Error(INVALID_SCR_MSG, NULL); + aptr->adj_x = val.num; + token = xf86getSubToken(&(ptr->lay_comment)); + if (token != NUMBER) + 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) + Error (SCREEN_MSG, NULL); + aptr->adj_bottom_str = val.str; + + /* left */ + if (xf86getSubToken (&(ptr->lay_comment)) != STRING) + Error (SCREEN_MSG, NULL); + aptr->adj_left_str = val.str; + + /* right */ + if (xf86getSubToken (&(ptr->lay_comment)) != STRING) + 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 = xf86confcalloc (1, sizeof (XF86ConfInputrefRec)); + iptr->list.next = NULL; + iptr->iref_option_lst = NULL; + if (xf86getSubToken (&(ptr->lay_comment)) != STRING) + 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; + } +} + +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; + xf86conffree (prev); + } +} + +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; + xf86conffree (prev); + } + +} + +void +xf86freeInputrefList (XF86ConfInputrefPtr ptr) +{ + XF86ConfInputrefPtr prev; + + while (ptr) + { + TestFree (ptr->iref_inputdev_str); + xf86optionListFree (ptr->iref_option_lst); + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } + +} + +#define CheckScreen(str, ptr)\ +if (str[0] != '\0') \ +{ \ +screen = xf86findScreen (str, p->conf_screen_lst); \ +if (!screen) \ +{ \ + xf86validationError (UNDEFINED_SCREEN_MSG, \ + str, layout->lay_identifier); \ + return (FALSE); \ +} \ +else \ + ptr = screen; \ +} + +int +xf86validateLayout (XF86ConfigPtr p) +{ + XF86ConfLayoutPtr layout = p->conf_layout_lst; + XF86ConfAdjacencyPtr adj; + XF86ConfInactivePtr iptr; + XF86ConfInputrefPtr inptr; + XF86ConfScreenPtr screen; + XF86ConfDevicePtr device; + XF86ConfInputPtr input; + + 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; + +#if 0 + CheckScreen (adj->adj_top_str, adj->adj_top); + CheckScreen (adj->adj_bottom_str, adj->adj_bottom); + CheckScreen (adj->adj_left_str, adj->adj_left); + CheckScreen (adj->adj_right_str, adj->adj_right); +#endif + + 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; + } + inptr = layout->lay_input_lst; + while (inptr) + { + input = xf86findInput (inptr->iref_inputdev_str, + p->conf_input_lst); + if (!input) + { + xf86validationError (UNDEFINED_INPUT_MSG, + inptr->iref_inputdev_str, layout->lay_identifier); + return (FALSE); + } + else + inptr->iref_inputdev = input; + inptr = inptr->list.next; + } + 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); +} + diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/Module.c b/nx-X11/programs/Xserver/hw/xfree86/parser/Module.c new file mode 100644 index 000000000..7a5a25207 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/parser/Module.c @@ -0,0 +1,261 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Module.c,v 1.12 2003/08/24 17:37:08 dawes Exp $ */ +/* + * + * 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" + +extern LexRec val; + +static xf86ConfigSymTabRec SubModuleTab[] = +{ + {ENDSUBSECTION, "endsubsection"}, + {OPTION, "option"}, + {-1, ""}, +}; + +static xf86ConfigSymTabRec ModuleTab[] = +{ + {ENDSECTION, "endsection"}, + {LOAD, "load"}, + {LOAD_DRIVER, "loaddriver"}, + {SUBSECTION, "subsection"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeModules + +XF86LoadPtr +xf86parseModuleSubSection (XF86LoadPtr head, char *name) +{ + int token; + parsePrologue (XF86LoadPtr, XF86LoadRec) + + ptr->load_name = name; + ptr->load_type = XF86_LOAD_MODULE; + ptr->load_opt = NULL; + ptr->list.next = NULL; + + while ((token = xf86getToken (SubModuleTab)) != ENDSUBSECTION) + { + switch (token) + { + case COMMENT: + ptr->load_comment = xf86addComment(ptr->load_comment, val.str); + break; + case OPTION: + ptr->load_opt = xf86parseOption(ptr->load_opt); + break; + case EOF_TOKEN: + xf86parseError (UNEXPECTED_EOF_MSG, NULL); + xf86conffree(ptr); + return NULL; + default: + xf86parseError (INVALID_KEYWORD_MSG, xf86tokenString ()); + xf86conffree(ptr); + return NULL; + break; + } + + } + + return ((XF86LoadPtr) xf86addListItem ((glp) head, (glp) ptr)); +} + +XF86ConfModulePtr +xf86parseModuleSection (void) +{ + int token; + parsePrologue (XF86ConfModulePtr, XF86ConfModuleRec) + + while ((token = xf86getToken (ModuleTab)) != ENDSECTION) + { + switch (token) + { + case COMMENT: + ptr->mod_comment = xf86addComment(ptr->mod_comment, val.str); + break; + case LOAD: + if (xf86getSubToken (&(ptr->mod_comment)) != STRING) + Error (QUOTE_MSG, "Load"); + ptr->mod_load_lst = + xf86addNewLoadDirective (ptr->mod_load_lst, val.str, + XF86_LOAD_MODULE, NULL); + break; + case LOAD_DRIVER: + if (xf86getSubToken (&(ptr->mod_comment)) != STRING) + Error (QUOTE_MSG, "LoadDriver"); + ptr->mod_load_lst = + xf86addNewLoadDirective (ptr->mod_load_lst, val.str, + XF86_LOAD_DRIVER, NULL); + break; + case SUBSECTION: + if (xf86getSubToken (&(ptr->mod_comment)) != STRING) + Error (QUOTE_MSG, "SubSection"); + ptr->mod_load_lst = + xf86parseModuleSubSection (ptr->mod_load_lst, val.str); + break; + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + } + +#ifdef DEBUG + printf ("Module section parsed\n"); +#endif + + return ptr; +} + +#undef CLEANUP + +void +xf86printModuleSection (FILE * cf, XF86ConfModulePtr ptr) +{ + XF86LoadPtr lptr; + + if (ptr == NULL) + return; + + if (ptr->mod_comment) + fprintf(cf, "%s", ptr->mod_comment); + for (lptr = ptr->mod_load_lst; lptr; lptr = lptr->list.next) + { + switch (lptr->load_type) + { + case XF86_LOAD_MODULE: + if( lptr->load_opt == NULL ) { + fprintf (cf, "\tLoad \"%s\"", lptr->load_name); + if (lptr->load_comment) + fprintf(cf, "%s", lptr->load_comment); + else + fputc('\n', cf); + } + else + { + fprintf (cf, "\tSubSection \"%s\"\n", lptr->load_name); + if (lptr->load_comment) + fprintf(cf, "%s", lptr->load_comment); + xf86printOptionList(cf, lptr->load_opt, 2); + fprintf (cf, "\tEndSubSection\n"); + } + break; + case XF86_LOAD_DRIVER: + fprintf (cf, "\tLoadDriver \"%s\"", lptr->load_name); + if (lptr->load_comment) + fprintf(cf, "%s", lptr->load_comment); + else + fputc('\n', cf); + break; +#if 0 + default: + fprintf (cf, "#\tUnknown type \"%s\"\n", lptr->load_name); + break; +#endif + } + } +} + +XF86LoadPtr +xf86addNewLoadDirective (XF86LoadPtr head, char *name, int type, XF86OptionPtr opts) +{ + XF86LoadPtr new; + int token; + + new = xf86confcalloc (1, sizeof (XF86LoadRec)); + new->load_name = name; + new->load_type = type; + new->load_opt = opts; + new->list.next = NULL; + + if ((token = xf86getToken(NULL)) == COMMENT) + new->load_comment = xf86addComment(new->load_comment, val.str); + else + xf86unGetToken(token); + + return ((XF86LoadPtr) xf86addListItem ((glp) head, (glp) new)); +} + +void +xf86freeModules (XF86ConfModulePtr ptr) +{ + XF86LoadPtr lptr; + XF86LoadPtr prev; + + if (ptr == NULL) + return; + lptr = ptr->mod_load_lst; + while (lptr) + { + TestFree (lptr->load_name); + TestFree (lptr->load_comment); + prev = lptr; + lptr = lptr->list.next; + xf86conffree (prev); + } + TestFree (ptr->mod_comment); + xf86conffree (ptr); +} diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/Monitor.c b/nx-X11/programs/Xserver/hw/xfree86/parser/Monitor.c new file mode 100644 index 000000000..52ff5a735 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/parser/Monitor.c @@ -0,0 +1,907 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Monitor.c,v 1.28 2003/08/24 17:37:08 dawes Exp $ */ +/* + * + * 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" + +extern LexRec val; + +static xf86ConfigSymTabRec MonitorTab[] = +{ + {ENDSECTION, "endsection"}, + {IDENTIFIER, "identifier"}, + {VENDOR, "vendorname"}, + {MODEL, "modelname"}, + {USEMODES, "usemodes"}, + {MODELINE, "modeline"}, + {DISPLAYSIZE, "displaysize"}, + {HORIZSYNC, "horizsync"}, + {VERTREFRESH, "vertrefresh"}, + {MODE, "mode"}, + {GAMMA, "gamma"}, + {OPTION, "option"}, + {-1, ""}, +}; + +static xf86ConfigSymTabRec ModesTab[] = +{ + {ENDSECTION, "endsection"}, + {IDENTIFIER, "identifier"}, + {MODELINE, "modeline"}, + {MODE, "mode"}, + {-1, ""}, +}; + +static xf86ConfigSymTabRec TimingTab[] = +{ + {TT_INTERLACE, "interlace"}, + {TT_PHSYNC, "+hsync"}, + {TT_NHSYNC, "-hsync"}, + {TT_PVSYNC, "+vsync"}, + {TT_NVSYNC, "-vsync"}, + {TT_CSYNC, "composite"}, + {TT_PCSYNC, "+csync"}, + {TT_NCSYNC, "-csync"}, + {TT_DBLSCAN, "doublescan"}, + {TT_HSKEW, "hskew"}, + {TT_BCAST, "bcast"}, + {TT_VSCAN, "vscan"}, + {TT_CUSTOM, "CUSTOM"}, + {-1, ""}, +}; + +static xf86ConfigSymTabRec ModeTab[] = +{ + {DOTCLOCK, "dotclock"}, + {HTIMINGS, "htimings"}, + {VTIMINGS, "vtimings"}, + {FLAGS, "flags"}, + {HSKEW, "hskew"}, + {BCAST, "bcast"}, + {VSCAN, "vscan"}, + {ENDMODE, "endmode"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeModeLineList + +XF86ConfModeLinePtr +xf86parseModeLine (void) +{ + int token; + parsePrologue (XF86ConfModeLinePtr, XF86ConfModeLineRec) + + /* Identifier */ + if (xf86getSubToken (&(ptr->ml_comment)) != STRING) + Error ("ModeLine identifier expected", NULL); + ptr->ml_identifier = val.str; + + /* DotClock */ + if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) + Error ("ModeLine dotclock expected", NULL); + ptr->ml_clock = (int) (val.realnum * 1000.0 + 0.5); + + /* HDisplay */ + if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) + Error ("ModeLine Hdisplay expected", NULL); + ptr->ml_hdisplay = val.num; + + /* HSyncStart */ + if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) + Error ("ModeLine HSyncStart expected", NULL); + ptr->ml_hsyncstart = val.num; + + /* HSyncEnd */ + if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) + Error ("ModeLine HSyncEnd expected", NULL); + ptr->ml_hsyncend = val.num; + + /* HTotal */ + if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) + Error ("ModeLine HTotal expected", NULL); + ptr->ml_htotal = val.num; + + /* VDisplay */ + if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) + Error ("ModeLine Vdisplay expected", NULL); + ptr->ml_vdisplay = val.num; + + /* VSyncStart */ + if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) + Error ("ModeLine VSyncStart expected", NULL); + ptr->ml_vsyncstart = val.num; + + /* VSyncEnd */ + if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) + Error ("ModeLine VSyncEnd expected", NULL); + ptr->ml_vsyncend = val.num; + + /* VTotal */ + if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) + Error ("ModeLine VTotal expected", NULL); + ptr->ml_vtotal = val.num; + + token = xf86getSubTokenWithTab (&(ptr->ml_comment), TimingTab); + while ((token == TT_INTERLACE) || (token == TT_PHSYNC) || + (token == TT_NHSYNC) || (token == TT_PVSYNC) || + (token == TT_NVSYNC) || (token == TT_CSYNC) || + (token == TT_PCSYNC) || (token == TT_NCSYNC) || + (token == TT_DBLSCAN) || (token == TT_HSKEW) || + (token == TT_VSCAN) || (token == TT_BCAST)) + { + switch (token) + { + + case TT_INTERLACE: + ptr->ml_flags |= XF86CONF_INTERLACE; + break; + case TT_PHSYNC: + ptr->ml_flags |= XF86CONF_PHSYNC; + break; + case TT_NHSYNC: + ptr->ml_flags |= XF86CONF_NHSYNC; + break; + case TT_PVSYNC: + ptr->ml_flags |= XF86CONF_PVSYNC; + break; + case TT_NVSYNC: + ptr->ml_flags |= XF86CONF_NVSYNC; + break; + case TT_CSYNC: + ptr->ml_flags |= XF86CONF_CSYNC; + break; + case TT_PCSYNC: + ptr->ml_flags |= XF86CONF_PCSYNC; + break; + case TT_NCSYNC: + ptr->ml_flags |= XF86CONF_NCSYNC; + break; + case TT_DBLSCAN: + ptr->ml_flags |= XF86CONF_DBLSCAN; + break; + case TT_HSKEW: + if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) + Error (NUMBER_MSG, "Hskew"); + ptr->ml_hskew = val.num; + ptr->ml_flags |= XF86CONF_HSKEW; + break; + case TT_BCAST: + ptr->ml_flags |= XF86CONF_BCAST; + break; + case TT_VSCAN: + if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) + Error (NUMBER_MSG, "Vscan"); + ptr->ml_vscan = val.num; + ptr->ml_flags |= XF86CONF_VSCAN; + break; + case TT_CUSTOM: + ptr->ml_flags |= XF86CONF_CUSTOM; + break; + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + token = xf86getSubTokenWithTab (&(ptr->ml_comment), TimingTab); + } + xf86unGetToken (token); + +#ifdef DEBUG + printf ("ModeLine parsed\n"); +#endif + return (ptr); +} + +XF86ConfModeLinePtr +xf86parseVerboseMode (void) +{ + int token, token2; + int had_dotclock = 0, had_htimings = 0, had_vtimings = 0; + parsePrologue (XF86ConfModeLinePtr, XF86ConfModeLineRec) + + if (xf86getSubToken (&(ptr->ml_comment)) != STRING) + Error ("Mode name expected", NULL); + ptr->ml_identifier = val.str; + while ((token = xf86getToken (ModeTab)) != ENDMODE) + { + switch (token) + { + case COMMENT: + ptr->ml_comment = xf86addComment(ptr->ml_comment, val.str); + break; + case DOTCLOCK: + if ((token = xf86getSubToken (&(ptr->ml_comment))) != NUMBER) + Error (NUMBER_MSG, "DotClock"); + ptr->ml_clock = (int) (val.realnum * 1000.0 + 0.5); + had_dotclock = 1; + break; + case HTIMINGS: + if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER) + ptr->ml_hdisplay = val.num; + else + Error ("Horizontal display expected", NULL); + + if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER) + ptr->ml_hsyncstart = val.num; + else + Error ("Horizontal sync start expected", NULL); + + if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER) + ptr->ml_hsyncend = val.num; + else + Error ("Horizontal sync end expected", NULL); + + if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER) + ptr->ml_htotal = val.num; + else + Error ("Horizontal total expected", NULL); + had_htimings = 1; + break; + case VTIMINGS: + if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER) + ptr->ml_vdisplay = val.num; + else + Error ("Vertical display expected", NULL); + + if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER) + ptr->ml_vsyncstart = val.num; + else + Error ("Vertical sync start expected", NULL); + + if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER) + ptr->ml_vsyncend = val.num; + else + Error ("Vertical sync end expected", NULL); + + if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER) + ptr->ml_vtotal = val.num; + else + Error ("Vertical total expected", NULL); + had_vtimings = 1; + break; + case FLAGS: + token = xf86getSubToken (&(ptr->ml_comment)); + if (token != STRING) + Error (QUOTE_MSG, "Flags"); + while (token == STRING) + { + token2 = xf86getStringToken (TimingTab); + switch (token2) + { + case TT_INTERLACE: + ptr->ml_flags |= XF86CONF_INTERLACE; + break; + case TT_PHSYNC: + ptr->ml_flags |= XF86CONF_PHSYNC; + break; + case TT_NHSYNC: + ptr->ml_flags |= XF86CONF_NHSYNC; + break; + case TT_PVSYNC: + ptr->ml_flags |= XF86CONF_PVSYNC; + break; + case TT_NVSYNC: + ptr->ml_flags |= XF86CONF_NVSYNC; + break; + case TT_CSYNC: + ptr->ml_flags |= XF86CONF_CSYNC; + break; + case TT_PCSYNC: + ptr->ml_flags |= XF86CONF_PCSYNC; + break; + case TT_NCSYNC: + ptr->ml_flags |= XF86CONF_NCSYNC; + break; + case TT_DBLSCAN: + ptr->ml_flags |= XF86CONF_DBLSCAN; + break; + case TT_CUSTOM: + ptr->ml_flags |= XF86CONF_CUSTOM; + break; + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error ("Unknown flag string", NULL); + break; + } + token = xf86getSubToken (&(ptr->ml_comment)); + } + xf86unGetToken (token); + break; + case HSKEW: + if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) + Error ("Horizontal skew expected", NULL); + ptr->ml_flags |= XF86CONF_HSKEW; + ptr->ml_hskew = val.num; + break; + case VSCAN: + if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) + Error ("Vertical scan count expected", NULL); + ptr->ml_flags |= XF86CONF_VSCAN; + ptr->ml_vscan = val.num; + break; + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error ("Unexepcted token in verbose \"Mode\" entry\n", NULL); + } + } + if (!had_dotclock) + Error ("the dotclock is missing", NULL); + if (!had_htimings) + Error ("the horizontal timings are missing", NULL); + if (!had_vtimings) + Error ("the vertical timings are missing", NULL); + +#ifdef DEBUG + printf ("Verbose Mode parsed\n"); +#endif + return (ptr); +} + +#undef CLEANUP + +#define CLEANUP xf86freeMonitorList + +XF86ConfMonitorPtr +xf86parseMonitorSection (void) +{ + int has_ident = FALSE; + int token; + parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec) + + while ((token = xf86getToken (MonitorTab)) != ENDSECTION) + { + switch (token) + { + case COMMENT: + ptr->mon_comment = xf86addComment(ptr->mon_comment, val.str); + break; + case IDENTIFIER: + if (xf86getSubToken (&(ptr->mon_comment)) != STRING) + Error (QUOTE_MSG, "Identifier"); + if (has_ident == TRUE) + Error (MULTIPLE_MSG, "Identifier"); + ptr->mon_identifier = val.str; + has_ident = TRUE; + break; + case VENDOR: + if (xf86getSubToken (&(ptr->mon_comment)) != STRING) + Error (QUOTE_MSG, "Vendor"); + ptr->mon_vendor = val.str; + break; + case MODEL: + if (xf86getSubToken (&(ptr->mon_comment)) != STRING) + Error (QUOTE_MSG, "ModelName"); + ptr->mon_modelname = val.str; + break; + case MODE: + HANDLE_LIST (mon_modeline_lst, xf86parseVerboseMode, + XF86ConfModeLinePtr); + break; + case MODELINE: + HANDLE_LIST (mon_modeline_lst, xf86parseModeLine, + XF86ConfModeLinePtr); + break; + case DISPLAYSIZE: + if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER) + Error (DISPLAYSIZE_MSG, NULL); + ptr->mon_width = val.realnum; + if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER) + Error (DISPLAYSIZE_MSG, NULL); + ptr->mon_height = val.realnum; + break; + + case HORIZSYNC: + if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER) + Error (HORIZSYNC_MSG, NULL); + do { + ptr->mon_hsync[ptr->mon_n_hsync].lo = val.realnum; + switch (token = xf86getSubToken (&(ptr->mon_comment))) + { + case COMMA: + ptr->mon_hsync[ptr->mon_n_hsync].hi = + ptr->mon_hsync[ptr->mon_n_hsync].lo; + break; + case DASH: + if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER || + (float)val.realnum < ptr->mon_hsync[ptr->mon_n_hsync].lo) + Error (HORIZSYNC_MSG, NULL); + ptr->mon_hsync[ptr->mon_n_hsync].hi = val.realnum; + if ((token = xf86getSubToken (&(ptr->mon_comment))) == COMMA) + break; + ptr->mon_n_hsync++; + goto HorizDone; + default: + /* We cannot currently know if a '\n' was found, + * or this is a real error + */ + ptr->mon_hsync[ptr->mon_n_hsync].hi = + ptr->mon_hsync[ptr->mon_n_hsync].lo; + ptr->mon_n_hsync++; + goto HorizDone; + } + if (ptr->mon_n_hsync >= CONF_MAX_HSYNC) + Error ("Sorry. Too many horizontal sync intervals.", NULL); + ptr->mon_n_hsync++; + } while ((token = xf86getSubToken (&(ptr->mon_comment))) == NUMBER); +HorizDone: + xf86unGetToken (token); + break; + + case VERTREFRESH: + if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER) + Error (VERTREFRESH_MSG, NULL); + do { + ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo = val.realnum; + switch (token = xf86getSubToken (&(ptr->mon_comment))) + { + case COMMA: + ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi = + ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo; + break; + case DASH: + if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER || + (float)val.realnum < ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo) + Error (VERTREFRESH_MSG, NULL); + ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi = val.realnum; + if ((token = xf86getSubToken (&(ptr->mon_comment))) == COMMA) + break; + ptr->mon_n_vrefresh++; + goto VertDone; + default: + /* We cannot currently know if a '\n' was found, + * or this is a real error + */ + ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi = + ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo; + ptr->mon_n_vrefresh++; + goto VertDone; + } + if (ptr->mon_n_vrefresh >= CONF_MAX_VREFRESH) + Error ("Sorry. Too many vertical refresh intervals.", NULL); + ptr->mon_n_vrefresh++; + } while ((token = xf86getSubToken (&(ptr->mon_comment))) == NUMBER); +VertDone: + xf86unGetToken (token); + break; + + case GAMMA: + if( xf86getSubToken (&(ptr->mon_comment)) != NUMBER ) + { + Error (INVALID_GAMMA_MSG, NULL); + } + else + { + ptr->mon_gamma_red = ptr->mon_gamma_green = + ptr->mon_gamma_blue = val.realnum; + if( xf86getSubToken (&(ptr->mon_comment)) == NUMBER ) + { + ptr->mon_gamma_green = val.realnum; + if( xf86getSubToken (&(ptr->mon_comment)) == NUMBER ) + { + ptr->mon_gamma_blue = val.realnum; + } + else + { + Error (INVALID_GAMMA_MSG, NULL); + } + } + else + xf86unGetToken (token); + } + break; + case OPTION: + ptr->mon_option_lst = xf86parseOption(ptr->mon_option_lst); + break; + case USEMODES: + { + XF86ConfModesLinkPtr mptr; + + if ((token = xf86getSubToken (&(ptr->mon_comment))) != STRING) + Error (QUOTE_MSG, "UseModes"); + + /* add to the end of the list of modes sections + referenced here */ + mptr = xf86confcalloc (1, sizeof (XF86ConfModesLinkRec)); + mptr->list.next = NULL; + mptr->ml_modes_str = val.str; + mptr->ml_modes = NULL; + ptr->mon_modes_sect_lst = (XF86ConfModesLinkPtr) + xf86addListItem((GenericListPtr)ptr->mon_modes_sect_lst, + (GenericListPtr)mptr); + } + break; + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + xf86parseError (INVALID_KEYWORD_MSG, xf86tokenString ()); + CLEANUP (ptr); + return NULL; + break; + } + } + + if (!has_ident) + Error (NO_IDENT_MSG, NULL); + +#ifdef DEBUG + printf ("Monitor section parsed\n"); +#endif + return ptr; +} + +#undef CLEANUP +#define CLEANUP xf86freeModesList + +XF86ConfModesPtr +xf86parseModesSection (void) +{ + int has_ident = FALSE; + int token; + parsePrologue (XF86ConfModesPtr, XF86ConfModesRec) + + while ((token = xf86getToken (ModesTab)) != ENDSECTION) + { + switch (token) + { + case COMMENT: + ptr->modes_comment = xf86addComment(ptr->modes_comment, val.str); + break; + case IDENTIFIER: + if (xf86getSubToken (&(ptr->modes_comment)) != STRING) + Error (QUOTE_MSG, "Identifier"); + if (has_ident == TRUE) + Error (MULTIPLE_MSG, "Identifier"); + ptr->modes_identifier = val.str; + has_ident = TRUE; + break; + case MODE: + HANDLE_LIST (mon_modeline_lst, xf86parseVerboseMode, + XF86ConfModeLinePtr); + break; + case MODELINE: + HANDLE_LIST (mon_modeline_lst, xf86parseModeLine, + XF86ConfModeLinePtr); + break; + default: + xf86parseError (INVALID_KEYWORD_MSG, xf86tokenString ()); + CLEANUP (ptr); + return NULL; + break; + } + } + + if (!has_ident) + Error (NO_IDENT_MSG, NULL); + +#ifdef DEBUG + printf ("Modes section parsed\n"); +#endif + return ptr; +} + +#undef CLEANUP + +void +xf86printMonitorSection (FILE * cf, XF86ConfMonitorPtr ptr) +{ + int i; + XF86ConfModeLinePtr mlptr; + XF86ConfModesLinkPtr mptr; + + while (ptr) + { + mptr = ptr->mon_modes_sect_lst; + fprintf (cf, "Section \"Monitor\"\n"); + if (ptr->mon_comment) + fprintf (cf, "%s", ptr->mon_comment); + if (ptr->mon_identifier) + fprintf (cf, "\tIdentifier \"%s\"\n", ptr->mon_identifier); + if (ptr->mon_vendor) + fprintf (cf, "\tVendorName \"%s\"\n", ptr->mon_vendor); + if (ptr->mon_modelname) + fprintf (cf, "\tModelName \"%s\"\n", ptr->mon_modelname); + while (mptr) { + fprintf (cf, "\tUseModes \"%s\"\n", mptr->ml_modes_str); + mptr = mptr->list.next; + } + if (ptr->mon_width) + fprintf (cf, "\tDisplaySize %d\t%d\n", + ptr->mon_width, + ptr->mon_height); + if ( ptr->mon_n_hsync || ptr->mon_n_vrefresh ) + fprintf(cf," ### Comment all HorizSync and VertSync values to use DDC:\n"); + for (i = 0; i < ptr->mon_n_hsync; i++) + { + fprintf (cf, "\tHorizSync %2.1f - %2.1f\n", + ptr->mon_hsync[i].lo, + ptr->mon_hsync[i].hi); + } + for (i = 0; i < ptr->mon_n_vrefresh; i++) + { + fprintf (cf, "\tVertRefresh %2.1f - %2.1f\n", + ptr->mon_vrefresh[i].lo, + ptr->mon_vrefresh[i].hi); + } + if (ptr->mon_gamma_red) { + if (ptr->mon_gamma_red == ptr->mon_gamma_green + && ptr->mon_gamma_red == ptr->mon_gamma_blue) + { + fprintf (cf, "\tGamma %.4g\n", + ptr->mon_gamma_red); + } else { + fprintf (cf, "\tGamma %.4g %.4g %.4g\n", + ptr->mon_gamma_red, + ptr->mon_gamma_green, + ptr->mon_gamma_blue); + } + } + for (mlptr = ptr->mon_modeline_lst; mlptr; mlptr = mlptr->list.next) + { + fprintf (cf, "\tModeLine \"%s\" %2.1f ", + mlptr->ml_identifier, mlptr->ml_clock / 1000.0); + fprintf (cf, "%d %d %d %d %d %d %d %d", + mlptr->ml_hdisplay, mlptr->ml_hsyncstart, + mlptr->ml_hsyncend, mlptr->ml_htotal, + mlptr->ml_vdisplay, mlptr->ml_vsyncstart, + mlptr->ml_vsyncend, mlptr->ml_vtotal); + if (mlptr->ml_flags & XF86CONF_PHSYNC) + fprintf (cf, " +hsync"); + if (mlptr->ml_flags & XF86CONF_NHSYNC) + fprintf (cf, " -hsync"); + if (mlptr->ml_flags & XF86CONF_PVSYNC) + fprintf (cf, " +vsync"); + if (mlptr->ml_flags & XF86CONF_NVSYNC) + fprintf (cf, " -vsync"); + if (mlptr->ml_flags & XF86CONF_INTERLACE) + fprintf (cf, " interlace"); + if (mlptr->ml_flags & XF86CONF_CSYNC) + fprintf (cf, " composite"); + if (mlptr->ml_flags & XF86CONF_PCSYNC) + fprintf (cf, " +csync"); + if (mlptr->ml_flags & XF86CONF_NCSYNC) + fprintf (cf, " -csync"); + if (mlptr->ml_flags & XF86CONF_DBLSCAN) + fprintf (cf, " doublescan"); + if (mlptr->ml_flags & XF86CONF_HSKEW) + fprintf (cf, " hskew %d", mlptr->ml_hskew); + if (mlptr->ml_flags & XF86CONF_BCAST) + fprintf (cf, " bcast"); + fprintf (cf, "\n"); + } + xf86printOptionList(cf, ptr->mon_option_lst, 1); + fprintf (cf, "EndSection\n\n"); + ptr = ptr->list.next; + } +} + +void +xf86printModesSection (FILE * cf, XF86ConfModesPtr ptr) +{ + XF86ConfModeLinePtr mlptr; + + while (ptr) + { + fprintf (cf, "Section \"Modes\"\n"); + if (ptr->modes_comment) + fprintf (cf, "%s", ptr->modes_comment); + if (ptr->modes_identifier) + fprintf (cf, "\tIdentifier \"%s\"\n", ptr->modes_identifier); + for (mlptr = ptr->mon_modeline_lst; mlptr; mlptr = mlptr->list.next) + { + fprintf (cf, "\tModeLine \"%s\" %2.1f ", + mlptr->ml_identifier, mlptr->ml_clock / 1000.0); + fprintf (cf, "%d %d %d %d %d %d %d %d", + mlptr->ml_hdisplay, mlptr->ml_hsyncstart, + mlptr->ml_hsyncend, mlptr->ml_htotal, + mlptr->ml_vdisplay, mlptr->ml_vsyncstart, + mlptr->ml_vsyncend, mlptr->ml_vtotal); + if (mlptr->ml_flags & XF86CONF_PHSYNC) + fprintf (cf, " +hsync"); + if (mlptr->ml_flags & XF86CONF_NHSYNC) + fprintf (cf, " -hsync"); + if (mlptr->ml_flags & XF86CONF_PVSYNC) + fprintf (cf, " +vsync"); + if (mlptr->ml_flags & XF86CONF_NVSYNC) + fprintf (cf, " -vsync"); + if (mlptr->ml_flags & XF86CONF_INTERLACE) + fprintf (cf, " interlace"); + if (mlptr->ml_flags & XF86CONF_CSYNC) + fprintf (cf, " composite"); + if (mlptr->ml_flags & XF86CONF_PCSYNC) + fprintf (cf, " +csync"); + if (mlptr->ml_flags & XF86CONF_NCSYNC) + fprintf (cf, " -csync"); + if (mlptr->ml_flags & XF86CONF_DBLSCAN) + fprintf (cf, " doublescan"); + if (mlptr->ml_flags & XF86CONF_HSKEW) + fprintf (cf, " hskew %d", mlptr->ml_hskew); + if (mlptr->ml_flags & XF86CONF_VSCAN) + fprintf (cf, " vscan %d", mlptr->ml_vscan); + if (mlptr->ml_flags & XF86CONF_BCAST) + fprintf (cf, " bcast"); + if (mlptr->ml_comment) + fprintf (cf, "%s", mlptr->ml_comment); + else + fprintf (cf, "\n"); + } + fprintf (cf, "EndSection\n\n"); + ptr = ptr->list.next; + } +} + +void +xf86freeMonitorList (XF86ConfMonitorPtr ptr) +{ + XF86ConfMonitorPtr prev; + + while (ptr) + { + TestFree (ptr->mon_identifier); + TestFree (ptr->mon_vendor); + TestFree (ptr->mon_modelname); + TestFree (ptr->mon_comment); + xf86optionListFree (ptr->mon_option_lst); + xf86freeModeLineList (ptr->mon_modeline_lst); + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } +} + +void +xf86freeModesList (XF86ConfModesPtr ptr) +{ + XF86ConfModesPtr prev; + + while (ptr) + { + TestFree (ptr->modes_identifier); + TestFree (ptr->modes_comment); + xf86freeModeLineList (ptr->mon_modeline_lst); + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } +} + +void +xf86freeModeLineList (XF86ConfModeLinePtr ptr) +{ + XF86ConfModeLinePtr prev; + while (ptr) + { + TestFree (ptr->ml_identifier); + TestFree (ptr->ml_comment); + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } +} + +XF86ConfMonitorPtr +xf86findMonitor (const char *ident, XF86ConfMonitorPtr p) +{ + while (p) + { + if (xf86nameCompare (ident, p->mon_identifier) == 0) + return (p); + + p = p->list.next; + } + return (NULL); +} + +XF86ConfModesPtr +xf86findModes (const char *ident, XF86ConfModesPtr p) +{ + while (p) + { + if (xf86nameCompare (ident, p->modes_identifier) == 0) + return (p); + + p = p->list.next; + } + return (NULL); +} + +XF86ConfModeLinePtr +xf86findModeLine (const char *ident, XF86ConfModeLinePtr p) +{ + while (p) + { + if (xf86nameCompare (ident, p->ml_identifier) == 0) + return (p); + + p = p->list.next; + } + return (NULL); +} + +int +xf86validateMonitor (XF86ConfigPtr p, XF86ConfScreenPtr screen) +{ + XF86ConfMonitorPtr monitor = screen->scrn_monitor; + XF86ConfModesLinkPtr modeslnk = monitor->mon_modes_sect_lst; + XF86ConfModesPtr modes; + while(modeslnk) + { + modes = xf86findModes (modeslnk->ml_modes_str, p->conf_modes_lst); + if (!modes) + { + xf86validationError (UNDEFINED_MODES_MSG, + modeslnk->ml_modes_str, + screen->scrn_identifier); + return (FALSE); + } + modeslnk->ml_modes = modes; + modeslnk = modeslnk->list.next; + } + return (TRUE); +} diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/Pointer.c b/nx-X11/programs/Xserver/hw/xfree86/parser/Pointer.c new file mode 100644 index 000000000..81984a3e7 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/parser/Pointer.c @@ -0,0 +1,236 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Pointer.c,v 1.13 2003/08/24 17:37:08 dawes Exp $ */ +/* + * + * 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" + +extern LexRec val; + +static xf86ConfigSymTabRec PointerTab[] = +{ + {PROTOCOL, "protocol"}, + {EMULATE3, "emulate3buttons"}, + {EM3TIMEOUT, "emulate3timeout"}, + {ENDSUBSECTION, "endsubsection"}, + {ENDSECTION, "endsection"}, + {PDEVICE, "device"}, + {PDEVICE, "port"}, + {BAUDRATE, "baudrate"}, + {SAMPLERATE, "samplerate"}, + {CLEARDTR, "cleardtr"}, + {CLEARRTS, "clearrts"}, + {CHORDMIDDLE, "chordmiddle"}, + {PRESOLUTION, "resolution"}, + {DEVICE_NAME, "devicename"}, + {ALWAYSCORE, "alwayscore"}, + {PBUTTONS, "buttons"}, + {ZAXISMAPPING, "zaxismapping"}, + {-1, ""}, +}; + +static xf86ConfigSymTabRec ZMapTab[] = +{ + {XAXIS, "x"}, + {YAXIS, "y"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeInputList + +XF86ConfInputPtr +xf86parsePointerSection (void) +{ + char *s, *s1, *s2; + int l; + int token; + parsePrologue (XF86ConfInputPtr, XF86ConfInputRec) + + while ((token = xf86getToken (PointerTab)) != ENDSECTION) + { + switch (token) + { + case COMMENT: + ptr->inp_comment = xf86addComment(ptr->inp_comment, val.str); + break; + case PROTOCOL: + if (xf86getSubToken (&(ptr->inp_comment)) != STRING) + Error (QUOTE_MSG, "Protocol"); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("Protocol"), + val.str); + break; + case PDEVICE: + if (xf86getSubToken (&(ptr->inp_comment)) != STRING) + Error (QUOTE_MSG, "Device"); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("Device"), + val.str); + break; + case EMULATE3: + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("Emulate3Buttons"), + NULL); + break; + case EM3TIMEOUT: + if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0) + Error (POSITIVE_INT_MSG, "Emulate3Timeout"); + s = xf86uLongToString(val.num); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("Emulate3Timeout"), + s); + break; + case CHORDMIDDLE: + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("ChordMiddle"), + NULL); + break; + case PBUTTONS: + if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0) + Error (POSITIVE_INT_MSG, "Buttons"); + s = xf86uLongToString(val.num); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("Buttons"), s); + break; + case BAUDRATE: + if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0) + Error (POSITIVE_INT_MSG, "BaudRate"); + s = xf86uLongToString(val.num); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("BaudRate"), s); + break; + case SAMPLERATE: + if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0) + Error (POSITIVE_INT_MSG, "SampleRate"); + s = xf86uLongToString(val.num); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("SampleRate"), s); + break; + case PRESOLUTION: + if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0) + Error (POSITIVE_INT_MSG, "Resolution"); + s = xf86uLongToString(val.num); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("Resolution"), s); + break; + case CLEARDTR: + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("ClearDTR"), NULL); + break; + case CLEARRTS: + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("ClearRTS"), NULL); + break; + case ZAXISMAPPING: + switch (xf86getToken(ZMapTab)) { + case NUMBER: + if (val.num < 0) + Error (ZAXISMAPPING_MSG, NULL); + s1 = xf86uLongToString(val.num); + if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0) + Error (ZAXISMAPPING_MSG, NULL); + s2 = xf86uLongToString(val.num); + l = strlen(s1) + 1 + strlen(s2) + 1; + s = xf86confmalloc(l); + sprintf(s, "%s %s", s1, s2); + xf86conffree(s1); + xf86conffree(s2); + break; + case XAXIS: + s = xf86configStrdup("x"); + break; + case YAXIS: + s = xf86configStrdup("y"); + break; + default: + Error (ZAXISMAPPING_MSG, NULL); + break; + } + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("ZAxisMapping"), + s); + break; + case ALWAYSCORE: + break; + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + } + + ptr->inp_identifier = xf86configStrdup(CONF_IMPLICIT_POINTER); + ptr->inp_driver = xf86configStrdup("mouse"); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("CorePointer"), NULL); + +#ifdef DEBUG + printf ("Pointer section parsed\n"); +#endif + + return ptr; +} + +#undef CLEANUP + diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/Screen.c b/nx-X11/programs/Xserver/hw/xfree86/parser/Screen.c new file mode 100644 index 000000000..d572af56c --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/parser/Screen.c @@ -0,0 +1,578 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Screen.c,v 1.28 2003/11/07 23:41:41 dawes Exp $ */ +/* + * + * 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" + +extern LexRec val; + +static xf86ConfigSymTabRec DisplayTab[] = +{ + {ENDSUBSECTION, "endsubsection"}, + {MODES, "modes"}, + {VIEWPORT, "viewport"}, + {VIRTUAL, "virtual"}, + {VISUAL, "visual"}, + {BLACK_TOK, "black"}, + {WHITE_TOK, "white"}, + {DEPTH, "depth"}, + {BPP, "fbbpp"}, + {WEIGHT, "weight"}, + {OPTION, "option"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeDisplayList + +XF86ConfDisplayPtr +xf86parseDisplaySubSection (void) +{ + int token; + parsePrologue (XF86ConfDisplayPtr, XF86ConfDisplayRec) + + ptr->disp_black.red = ptr->disp_black.green = ptr->disp_black.blue = -1; + ptr->disp_white.red = ptr->disp_white.green = ptr->disp_white.blue = -1; + ptr->disp_frameX0 = ptr->disp_frameY0 = -1; + while ((token = xf86getToken (DisplayTab)) != ENDSUBSECTION) + { + switch (token) + { + case COMMENT: + ptr->disp_comment = xf86addComment(ptr->disp_comment, val.str); + break; + case VIEWPORT: + if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) + Error (VIEWPORT_MSG, NULL); + ptr->disp_frameX0 = val.num; + if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) + Error (VIEWPORT_MSG, NULL); + ptr->disp_frameY0 = val.num; + break; + case VIRTUAL: + if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) + Error (VIRTUAL_MSG, NULL); + ptr->disp_virtualX = val.num; + if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) + Error (VIRTUAL_MSG, NULL); + ptr->disp_virtualY = val.num; + break; + case DEPTH: + if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) + Error (NUMBER_MSG, "Display"); + ptr->disp_depth = val.num; + break; + case BPP: + if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) + Error (NUMBER_MSG, "Display"); + ptr->disp_bpp = val.num; + break; + case VISUAL: + if (xf86getSubToken (&(ptr->disp_comment)) != STRING) + Error (QUOTE_MSG, "Display"); + ptr->disp_visual = val.str; + break; + case WEIGHT: + if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) + Error (WEIGHT_MSG, NULL); + ptr->disp_weight.red = val.num; + if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) + Error (WEIGHT_MSG, NULL); + ptr->disp_weight.green = val.num; + if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) + Error (WEIGHT_MSG, NULL); + ptr->disp_weight.blue = val.num; + break; + case BLACK_TOK: + if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) + Error (BLACK_MSG, NULL); + ptr->disp_black.red = val.num; + if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) + Error (BLACK_MSG, NULL); + ptr->disp_black.green = val.num; + if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) + Error (BLACK_MSG, NULL); + ptr->disp_black.blue = val.num; + break; + case WHITE_TOK: + if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) + Error (WHITE_MSG, NULL); + ptr->disp_white.red = val.num; + if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) + Error (WHITE_MSG, NULL); + ptr->disp_white.green = val.num; + if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) + Error (WHITE_MSG, NULL); + ptr->disp_white.blue = val.num; + break; + case MODES: + { + XF86ModePtr mptr; + + while ((token = xf86getSubTokenWithTab (&(ptr->disp_comment), DisplayTab)) == STRING) + { + mptr = xf86confcalloc (1, sizeof (XF86ModeRec)); + mptr->mode_name = val.str; + mptr->list.next = NULL; + ptr->disp_mode_lst = (XF86ModePtr) + xf86addListItem ((glp) ptr->disp_mode_lst, (glp) mptr); + } + xf86unGetToken (token); + } + break; + case OPTION: + ptr->disp_option_lst = xf86parseOption(ptr->disp_option_lst); + break; + + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + } + +#ifdef DEBUG + printf ("Display subsection parsed\n"); +#endif + + return ptr; +} + +#undef CLEANUP + +static xf86ConfigSymTabRec ScreenTab[] = +{ + {ENDSECTION, "endsection"}, + {IDENTIFIER, "identifier"}, + {OBSDRIVER, "driver"}, + {MDEVICE, "device"}, + {MONITOR, "monitor"}, + {VIDEOADAPTOR, "videoadaptor"}, + {SCREENNO, "screenno"}, + {SUBSECTION, "subsection"}, + {DEFAULTDEPTH, "defaultcolordepth"}, + {DEFAULTDEPTH, "defaultdepth"}, + {DEFAULTBPP, "defaultbpp"}, + {DEFAULTFBBPP, "defaultfbbpp"}, + {OPTION, "option"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeScreenList +XF86ConfScreenPtr +xf86parseScreenSection (void) +{ + int has_ident = FALSE; + int has_driver= FALSE; + int token; + + parsePrologue (XF86ConfScreenPtr, XF86ConfScreenRec) + + while ((token = xf86getToken (ScreenTab)) != ENDSECTION) + { + switch (token) + { + case COMMENT: + ptr->scrn_comment = xf86addComment(ptr->scrn_comment, val.str); + break; + case IDENTIFIER: + if (xf86getSubToken (&(ptr->scrn_comment)) != STRING) + Error (QUOTE_MSG, "Identifier"); + ptr->scrn_identifier = val.str; + if (has_ident || has_driver) + Error (ONLY_ONE_MSG,"Identifier or Driver"); + has_ident = TRUE; + break; + case OBSDRIVER: + if (xf86getSubToken (&(ptr->scrn_comment)) != STRING) + Error (QUOTE_MSG, "Driver"); + ptr->scrn_obso_driver = val.str; + if (has_ident || has_driver) + Error (ONLY_ONE_MSG,"Identifier or Driver"); + has_driver = TRUE; + break; + case DEFAULTDEPTH: + if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER) + Error (NUMBER_MSG, "DefaultDepth"); + ptr->scrn_defaultdepth = val.num; + break; + case DEFAULTBPP: + if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER) + Error (NUMBER_MSG, "DefaultBPP"); + ptr->scrn_defaultbpp = val.num; + break; + case DEFAULTFBBPP: + if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER) + Error (NUMBER_MSG, "DefaultFbBPP"); + ptr->scrn_defaultfbbpp = val.num; + break; + case MDEVICE: + if (xf86getSubToken (&(ptr->scrn_comment)) != STRING) + Error (QUOTE_MSG, "Device"); + ptr->scrn_device_str = val.str; + break; + case MONITOR: + if (xf86getSubToken (&(ptr->scrn_comment)) != STRING) + Error (QUOTE_MSG, "Monitor"); + ptr->scrn_monitor_str = val.str; + break; + case VIDEOADAPTOR: + { + XF86ConfAdaptorLinkPtr aptr; + + if (xf86getSubToken (&(ptr->scrn_comment)) != STRING) + Error (QUOTE_MSG, "VideoAdaptor"); + + /* Don't allow duplicates */ + for (aptr = ptr->scrn_adaptor_lst; aptr; + aptr = (XF86ConfAdaptorLinkPtr) aptr->list.next) + if (xf86nameCompare (val.str, aptr->al_adaptor_str) == 0) + break; + + if (aptr == NULL) + { + aptr = xf86confcalloc (1, sizeof (XF86ConfAdaptorLinkRec)); + aptr->list.next = NULL; + aptr->al_adaptor_str = val.str; + ptr->scrn_adaptor_lst = (XF86ConfAdaptorLinkPtr) + xf86addListItem ((glp) ptr->scrn_adaptor_lst, (glp) aptr); + } + } + break; + case OPTION: + ptr->scrn_option_lst = xf86parseOption(ptr->scrn_option_lst); + break; + case SUBSECTION: + if (xf86getSubToken (&(ptr->scrn_comment)) != STRING) + Error (QUOTE_MSG, "SubSection"); + { + xf86conffree(val.str); + HANDLE_LIST (scrn_display_lst, xf86parseDisplaySubSection, + XF86ConfDisplayPtr); + } + break; + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + } + + if (!has_ident && !has_driver) + Error (NO_IDENT_MSG, NULL); + +#ifdef DEBUG + printf ("Screen section parsed\n"); +#endif + + return ptr; +} + +void +xf86printScreenSection (FILE * cf, XF86ConfScreenPtr ptr) +{ + XF86ConfAdaptorLinkPtr aptr; + XF86ConfDisplayPtr dptr; + XF86ModePtr mptr; + + while (ptr) + { + fprintf (cf, "Section \"Screen\"\n"); + if (ptr->scrn_comment) + fprintf (cf, "%s", ptr->scrn_comment); + if (ptr->scrn_identifier) + fprintf (cf, "\tIdentifier \"%s\"\n", ptr->scrn_identifier); + if (ptr->scrn_obso_driver) + fprintf (cf, "\tDriver \"%s\"\n", ptr->scrn_obso_driver); + if (ptr->scrn_device_str) + fprintf (cf, "\tDevice \"%s\"\n", ptr->scrn_device_str); + if (ptr->scrn_monitor_str) + fprintf (cf, "\tMonitor \"%s\"\n", ptr->scrn_monitor_str); + if (ptr->scrn_defaultdepth) + fprintf (cf, "\tDefaultDepth %d\n", + ptr->scrn_defaultdepth); + if (ptr->scrn_defaultbpp) + fprintf (cf, "\tDefaultBPP %d\n", + ptr->scrn_defaultbpp); + if (ptr->scrn_defaultfbbpp) + fprintf (cf, "\tDefaultFbBPP %d\n", + ptr->scrn_defaultfbbpp); + xf86printOptionList(cf, ptr->scrn_option_lst, 1); + for (aptr = ptr->scrn_adaptor_lst; aptr; aptr = aptr->list.next) + { + fprintf (cf, "\tVideoAdaptor \"%s\"\n", aptr->al_adaptor_str); + } + for (dptr = ptr->scrn_display_lst; dptr; dptr = dptr->list.next) + { + fprintf (cf, "\tSubSection \"Display\"\n"); + if (dptr->disp_comment) + fprintf (cf, "%s", dptr->disp_comment); + if (dptr->disp_frameX0 >= 0 || dptr->disp_frameY0 >= 0) + { + fprintf (cf, "\t\tViewport %d %d\n", + dptr->disp_frameX0, dptr->disp_frameY0); + } + if (dptr->disp_virtualX != 0 || dptr->disp_virtualY != 0) + { + fprintf (cf, "\t\tVirtual %d %d\n", + dptr->disp_virtualX, dptr->disp_virtualY); + } + if (dptr->disp_depth) + { + fprintf (cf, "\t\tDepth %d\n", dptr->disp_depth); + } + if (dptr->disp_bpp) + { + fprintf (cf, "\t\tFbBPP %d\n", dptr->disp_bpp); + } + if (dptr->disp_visual) + { + fprintf (cf, "\t\tVisual \"%s\"\n", dptr->disp_visual); + } + if (dptr->disp_weight.red != 0) + { + fprintf (cf, "\t\tWeight %d %d %d\n", + dptr->disp_weight.red, dptr->disp_weight.green, dptr->disp_weight.blue); + } + if (dptr->disp_black.red != -1) + { + fprintf (cf, "\t\tBlack 0x%04x 0x%04x 0x%04x\n", + dptr->disp_black.red, dptr->disp_black.green, dptr->disp_black.blue); + } + if (dptr->disp_white.red != -1) + { + fprintf (cf, "\t\tWhite 0x%04x 0x%04x 0x%04x\n", + dptr->disp_white.red, dptr->disp_white.green, dptr->disp_white.blue); + } + if (dptr->disp_mode_lst) + { + fprintf (cf, "\t\tModes "); + } + for (mptr = dptr->disp_mode_lst; mptr; mptr = mptr->list.next) + { + fprintf (cf, " \"%s\"", mptr->mode_name); + } + if (dptr->disp_mode_lst) + { + fprintf (cf, "\n"); + } + xf86printOptionList(cf, dptr->disp_option_lst, 2); + fprintf (cf, "\tEndSubSection\n"); + } + fprintf (cf, "EndSection\n\n"); + ptr = ptr->list.next; + } + +} + +void +xf86freeScreenList (XF86ConfScreenPtr ptr) +{ + XF86ConfScreenPtr prev; + + while (ptr) + { + TestFree (ptr->scrn_identifier); + TestFree (ptr->scrn_monitor_str); + TestFree (ptr->scrn_device_str); + TestFree (ptr->scrn_comment); + xf86optionListFree (ptr->scrn_option_lst); + xf86freeAdaptorLinkList (ptr->scrn_adaptor_lst); + xf86freeDisplayList (ptr->scrn_display_lst); + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } +} + +void +xf86freeAdaptorLinkList (XF86ConfAdaptorLinkPtr ptr) +{ + XF86ConfAdaptorLinkPtr prev; + + while (ptr) + { + TestFree (ptr->al_adaptor_str); + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } +} + +void +xf86freeDisplayList (XF86ConfDisplayPtr ptr) +{ + XF86ConfDisplayPtr prev; + + while (ptr) + { + xf86freeModeList (ptr->disp_mode_lst); + xf86optionListFree (ptr->disp_option_lst); + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } +} + +void +xf86freeModeList (XF86ModePtr ptr) +{ + XF86ModePtr prev; + + while (ptr) + { + TestFree (ptr->mode_name); + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } +} + +int +xf86validateScreen (XF86ConfigPtr p) +{ + XF86ConfScreenPtr screen = p->conf_screen_lst; + XF86ConfMonitorPtr monitor; + XF86ConfDevicePtr device; + XF86ConfAdaptorLinkPtr adaptor; + + if (!screen) + { + xf86validationError ("At least one Screen section is required."); + return (FALSE); + } + + while (screen) + { + if (screen->scrn_obso_driver && !screen->scrn_identifier) + screen->scrn_identifier = screen->scrn_obso_driver; + + monitor = xf86findMonitor (screen->scrn_monitor_str, p->conf_monitor_lst); + if (screen->scrn_monitor_str) + { + if (!monitor) + { + xf86validationError (UNDEFINED_MONITOR_MSG, + screen->scrn_monitor_str, screen->scrn_identifier); + return (FALSE); + } + else + { + screen->scrn_monitor = monitor; + if (!xf86validateMonitor(p, screen)) + return (FALSE); + } + } + + device = xf86findDevice (screen->scrn_device_str, p->conf_device_lst); + if (!device) + { + xf86validationError (UNDEFINED_DEVICE_MSG, + screen->scrn_device_str, screen->scrn_identifier); + return (FALSE); + } + else + screen->scrn_device = device; + + adaptor = screen->scrn_adaptor_lst; + while (adaptor) + { + adaptor->al_adaptor = xf86findVideoAdaptor (adaptor->al_adaptor_str, p->conf_videoadaptor_lst); + if (!adaptor->al_adaptor) + { + xf86validationError (UNDEFINED_ADAPTOR_MSG, adaptor->al_adaptor_str, screen->scrn_identifier); + return (FALSE); + } + else if (adaptor->al_adaptor->va_fwdref) + { + xf86validationError (ADAPTOR_REF_TWICE_MSG, adaptor->al_adaptor_str, + adaptor->al_adaptor->va_fwdref); + return (FALSE); + } + + adaptor->al_adaptor->va_fwdref = xf86configStrdup(screen->scrn_identifier); + adaptor = adaptor->list.next; + } + + screen = screen->list.next; + } + + return (TRUE); +} + +XF86ConfScreenPtr +xf86findScreen (const char *ident, XF86ConfScreenPtr p) +{ + while (p) + { + if (xf86nameCompare (ident, p->scrn_identifier) == 0) + return (p); + + p = p->list.next; + } + return (NULL); +} + diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/Vendor.c b/nx-X11/programs/Xserver/hw/xfree86/parser/Vendor.c new file mode 100644 index 000000000..9c6469bb8 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/parser/Vendor.c @@ -0,0 +1,258 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Vendor.c,v 1.17 2003/08/24 17:37:08 dawes Exp $ */ +/* + * + * 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" + +extern LexRec val; + +static xf86ConfigSymTabRec VendorSubTab[] = +{ + {ENDSUBSECTION, "endsubsection"}, + {IDENTIFIER, "identifier"}, + {OPTION, "option"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeVendorSubList + +XF86ConfVendSubPtr +xf86parseVendorSubSection (void) +{ + int has_ident = FALSE; + int token; + parsePrologue (XF86ConfVendSubPtr, XF86ConfVendSubRec) + + while ((token = xf86getToken (VendorSubTab)) != ENDSUBSECTION) + { + switch (token) + { + case COMMENT: + ptr->vs_comment = xf86addComment(ptr->vs_comment, val.str); + break; + case IDENTIFIER: + if (xf86getSubToken (&(ptr->vs_comment))) + Error (QUOTE_MSG, "Identifier"); + if (has_ident == TRUE) + Error (MULTIPLE_MSG, "Identifier"); + ptr->vs_identifier = val.str; + has_ident = TRUE; + break; + case OPTION: + ptr->vs_option_lst = xf86parseOption(ptr->vs_option_lst); + break; + + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + } + +#ifdef DEBUG + printf ("Vendor subsection parsed\n"); +#endif + + return ptr; +} + +#undef CLEANUP + +static xf86ConfigSymTabRec VendorTab[] = +{ + {ENDSECTION, "endsection"}, + {IDENTIFIER, "identifier"}, + {OPTION, "option"}, + {SUBSECTION, "subsection"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeVendorList + +XF86ConfVendorPtr +xf86parseVendorSection (void) +{ + int has_ident = FALSE; + int token; + parsePrologue (XF86ConfVendorPtr, XF86ConfVendorRec) + + while ((token = xf86getToken (VendorTab)) != ENDSECTION) + { + switch (token) + { + case COMMENT: + ptr->vnd_comment = xf86addComment(ptr->vnd_comment, val.str); + break; + case IDENTIFIER: + if (xf86getSubToken (&(ptr->vnd_comment)) != STRING) + Error (QUOTE_MSG, "Identifier"); + if (has_ident == TRUE) + Error (MULTIPLE_MSG, "Identifier"); + ptr->vnd_identifier = val.str; + has_ident = TRUE; + break; + case OPTION: + ptr->vnd_option_lst = xf86parseOption(ptr->vnd_option_lst); + break; + case SUBSECTION: + if (xf86getSubToken (&(ptr->vnd_comment)) != STRING) + Error (QUOTE_MSG, "SubSection"); + { + HANDLE_LIST (vnd_sub_lst, xf86parseVendorSubSection, + XF86ConfVendSubPtr); + } + 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 ("Vendor section parsed\n"); +#endif + + return ptr; +} + +#undef CLEANUP + +void +xf86printVendorSection (FILE * cf, XF86ConfVendorPtr ptr) +{ + XF86ConfVendSubPtr pptr; + + while (ptr) + { + fprintf (cf, "Section \"Vendor\"\n"); + if (ptr->vnd_comment) + fprintf (cf, "%s", ptr->vnd_comment); + if (ptr->vnd_identifier) + fprintf (cf, "\tIdentifier \"%s\"\n", ptr->vnd_identifier); + + xf86printOptionList(cf, ptr->vnd_option_lst, 1); + for (pptr = ptr->vnd_sub_lst; pptr; pptr = pptr->list.next) + { + fprintf (cf, "\tSubSection \"Vendor\"\n"); + if (pptr->vs_comment) + fprintf (cf, "%s", pptr->vs_comment); + if (pptr->vs_identifier) + fprintf (cf, "\t\tIdentifier \"%s\"\n", pptr->vs_identifier); + xf86printOptionList(cf, pptr->vs_option_lst, 2); + fprintf (cf, "\tEndSubSection\n"); + } + fprintf (cf, "EndSection\n\n"); + ptr = ptr->list.next; + } +} + +void +xf86freeVendorList (XF86ConfVendorPtr p) +{ + if (p == NULL) + return; + xf86freeVendorSubList (p->vnd_sub_lst); + TestFree (p->vnd_identifier); + TestFree (p->vnd_comment); + xf86optionListFree (p->vnd_option_lst); + xf86conffree (p); +} + +void +xf86freeVendorSubList (XF86ConfVendSubPtr ptr) +{ + XF86ConfVendSubPtr prev; + + while (ptr) + { + TestFree (ptr->vs_identifier); + TestFree (ptr->vs_name); + TestFree (ptr->vs_comment); + xf86optionListFree (ptr->vs_option_lst); + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } +} + +XF86ConfVendorPtr +xf86findVendor (const char *name, XF86ConfVendorPtr list) +{ + while (list) + { + if (xf86nameCompare (list->vnd_identifier, name) == 0) + return (list); + list = list->list.next; + } + return (NULL); +} + diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/Video.c b/nx-X11/programs/Xserver/hw/xfree86/parser/Video.c new file mode 100644 index 000000000..88788aea8 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/parser/Video.c @@ -0,0 +1,297 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Video.c,v 1.13 2003/08/24 17:37:08 dawes Exp $ */ +/* + * + * 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" + +extern LexRec val; + +static xf86ConfigSymTabRec VideoPortTab[] = +{ + {ENDSUBSECTION, "endsubsection"}, + {IDENTIFIER, "identifier"}, + {OPTION, "option"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeVideoPortList + +XF86ConfVideoPortPtr +xf86parseVideoPortSubSection (void) +{ + int has_ident = FALSE; + int token; + parsePrologue (XF86ConfVideoPortPtr, XF86ConfVideoPortRec) + + while ((token = xf86getToken (VideoPortTab)) != ENDSUBSECTION) + { + switch (token) + { + case COMMENT: + ptr->vp_comment = xf86addComment(ptr->vp_comment, val.str); + break; + case IDENTIFIER: + if (xf86getSubToken (&(ptr->vp_comment)) != STRING) + Error (QUOTE_MSG, "Identifier"); + if (has_ident == TRUE) + Error (MULTIPLE_MSG, "Identifier"); + ptr->vp_identifier = val.str; + has_ident = TRUE; + break; + case OPTION: + ptr->vp_option_lst = xf86parseOption(ptr->vp_option_lst); + break; + + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + } + +#ifdef DEBUG + printf ("VideoPort subsection parsed\n"); +#endif + + return ptr; +} + +#undef CLEANUP + +static xf86ConfigSymTabRec VideoAdaptorTab[] = +{ + {ENDSECTION, "endsection"}, + {IDENTIFIER, "identifier"}, + {VENDOR, "vendorname"}, + {BOARD, "boardname"}, + {BUSID, "busid"}, + {DRIVER, "driver"}, + {OPTION, "option"}, + {SUBSECTION, "subsection"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeVideoAdaptorList + +XF86ConfVideoAdaptorPtr +xf86parseVideoAdaptorSection (void) +{ + int has_ident = FALSE; + int token; + + parsePrologue (XF86ConfVideoAdaptorPtr, XF86ConfVideoAdaptorRec) + + while ((token = xf86getToken (VideoAdaptorTab)) != ENDSECTION) + { + switch (token) + { + case COMMENT: + ptr->va_comment = xf86addComment(ptr->va_comment, val.str); + break; + case IDENTIFIER: + if (xf86getSubToken (&(ptr->va_comment)) != STRING) + Error (QUOTE_MSG, "Identifier"); + ptr->va_identifier = val.str; + if (has_ident == TRUE) + Error (MULTIPLE_MSG, "Identifier"); + has_ident = TRUE; + break; + case VENDOR: + if (xf86getSubToken (&(ptr->va_comment)) != STRING) + Error (QUOTE_MSG, "Vendor"); + ptr->va_vendor = val.str; + break; + case BOARD: + if (xf86getSubToken (&(ptr->va_comment)) != STRING) + Error (QUOTE_MSG, "Board"); + ptr->va_board = val.str; + break; + case BUSID: + if (xf86getSubToken (&(ptr->va_comment)) != STRING) + Error (QUOTE_MSG, "BusID"); + ptr->va_busid = val.str; + break; + case DRIVER: + if (xf86getSubToken (&(ptr->va_comment)) != STRING) + Error (QUOTE_MSG, "Driver"); + ptr->va_driver = val.str; + break; + case OPTION: + ptr->va_option_lst = xf86parseOption(ptr->va_option_lst); + break; + case SUBSECTION: + if (xf86getSubToken (&(ptr->va_comment)) != STRING) + Error (QUOTE_MSG, "SubSection"); + { + HANDLE_LIST (va_port_lst, xf86parseVideoPortSubSection, + XF86ConfVideoPortPtr); + } + 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 ("VideoAdaptor section parsed\n"); +#endif + + return ptr; +} + +void +xf86printVideoAdaptorSection (FILE * cf, XF86ConfVideoAdaptorPtr ptr) +{ + XF86ConfVideoPortPtr pptr; + + while (ptr) + { + fprintf (cf, "Section \"VideoAdaptor\"\n"); + if (ptr->va_comment) + fprintf (cf, "%s", ptr->va_comment); + if (ptr->va_identifier) + fprintf (cf, "\tIdentifier \"%s\"\n", ptr->va_identifier); + if (ptr->va_vendor) + fprintf (cf, "\tVendorName \"%s\"\n", ptr->va_vendor); + if (ptr->va_board) + fprintf (cf, "\tBoardName \"%s\"\n", ptr->va_board); + if (ptr->va_busid) + fprintf (cf, "\tBusID \"%s\"\n", ptr->va_busid); + if (ptr->va_driver) + fprintf (cf, "\tDriver \"%s\"\n", ptr->va_driver); + xf86printOptionList(cf, ptr->va_option_lst, 1); + for (pptr = ptr->va_port_lst; pptr; pptr = pptr->list.next) + { + fprintf (cf, "\tSubSection \"VideoPort\"\n"); + if (pptr->vp_comment) + fprintf (cf, "%s", pptr->vp_comment); + if (pptr->vp_identifier) + fprintf (cf, "\t\tIdentifier \"%s\"\n", pptr->vp_identifier); + xf86printOptionList(cf, pptr->vp_option_lst, 2); + fprintf (cf, "\tEndSubSection\n"); + } + fprintf (cf, "EndSection\n\n"); + ptr = ptr->list.next; + } + +} + +void +xf86freeVideoAdaptorList (XF86ConfVideoAdaptorPtr ptr) +{ + XF86ConfVideoAdaptorPtr prev; + + while (ptr) + { + TestFree (ptr->va_identifier); + TestFree (ptr->va_vendor); + TestFree (ptr->va_board); + TestFree (ptr->va_busid); + TestFree (ptr->va_driver); + TestFree (ptr->va_fwdref); + TestFree (ptr->va_comment); + xf86freeVideoPortList (ptr->va_port_lst); + xf86optionListFree (ptr->va_option_lst); + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } +} + +void +xf86freeVideoPortList (XF86ConfVideoPortPtr ptr) +{ + XF86ConfVideoPortPtr prev; + + while (ptr) + { + TestFree (ptr->vp_identifier); + TestFree (ptr->vp_comment); + xf86optionListFree (ptr->vp_option_lst); + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } +} + +XF86ConfVideoAdaptorPtr +xf86findVideoAdaptor (const char *ident, XF86ConfVideoAdaptorPtr p) +{ + while (p) + { + if (xf86nameCompare (ident, p->va_identifier) == 0) + return (p); + + p = p->list.next; + } + return (NULL); +} diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/configProcs.h b/nx-X11/programs/Xserver/hw/xfree86/parser/configProcs.h new file mode 100644 index 000000000..bb5f4e9b2 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/parser/configProcs.h @@ -0,0 +1,132 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/configProcs.h,v 1.17 2003/08/24 17:37:08 dawes Exp $ */ +/* + * Copyright (c) 1997-2001 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). + */ + +/* Private procs. Public procs are in xf86Parser.h and xf86Optrec.h */ + +/* Device.c */ +XF86ConfDevicePtr xf86parseDeviceSection(void); +void xf86printDeviceSection(FILE *cf, XF86ConfDevicePtr ptr); +void xf86freeDeviceList(XF86ConfDevicePtr ptr); +int xf86validateDevice(XF86ConfigPtr p); +/* Files.c */ +XF86ConfFilesPtr xf86parseFilesSection(void); +void xf86printFileSection(FILE *cf, XF86ConfFilesPtr ptr); +void xf86freeFiles(XF86ConfFilesPtr p); +/* Flags.c */ +XF86ConfFlagsPtr xf86parseFlagsSection(void); +void xf86printServerFlagsSection(FILE *f, XF86ConfFlagsPtr flags); +void xf86freeFlags(XF86ConfFlagsPtr flags); +/* Input.c */ +XF86ConfInputPtr xf86parseInputSection(void); +void xf86printInputSection(FILE *f, XF86ConfInputPtr ptr); +void xf86freeInputList(XF86ConfInputPtr ptr); +int xf86validateInput (XF86ConfigPtr p); +/* Keyboard.c */ +XF86ConfInputPtr xf86parseKeyboardSection(void); +/* Layout.c */ +XF86ConfLayoutPtr xf86parseLayoutSection(void); +void xf86printLayoutSection(FILE *cf, XF86ConfLayoutPtr ptr); +void xf86freeLayoutList(XF86ConfLayoutPtr ptr); +void xf86freeAdjacencyList(XF86ConfAdjacencyPtr ptr); +void xf86freeInputrefList(XF86ConfInputrefPtr ptr); +int xf86validateLayout(XF86ConfigPtr p); +/* Module.c */ +XF86LoadPtr xf86parseModuleSubSection(XF86LoadPtr head, char *name); +XF86ConfModulePtr xf86parseModuleSection(void); +void xf86printModuleSection(FILE *cf, XF86ConfModulePtr ptr); +XF86LoadPtr xf86addNewLoadDirective(XF86LoadPtr head, char *name, int type, XF86OptionPtr opts); +void xf86freeModules(XF86ConfModulePtr ptr); +/* Monitor.c */ +XF86ConfModeLinePtr xf86parseModeLine(void); +XF86ConfModeLinePtr xf86parseVerboseMode(void); +XF86ConfMonitorPtr xf86parseMonitorSection(void); +XF86ConfModesPtr xf86parseModesSection(void); +void xf86printMonitorSection(FILE *cf, XF86ConfMonitorPtr ptr); +void xf86printModesSection(FILE *cf, XF86ConfModesPtr ptr); +void xf86freeMonitorList(XF86ConfMonitorPtr ptr); +void xf86freeModesList(XF86ConfModesPtr ptr); +void xf86freeModeLineList(XF86ConfModeLinePtr ptr); +int xf86validateMonitor(XF86ConfigPtr p, XF86ConfScreenPtr screen); +/* Pointer.c */ +XF86ConfInputPtr xf86parsePointerSection(void); +/* Screen.c */ +XF86ConfDisplayPtr xf86parseDisplaySubSection(void); +XF86ConfScreenPtr xf86parseScreenSection(void); +void xf86printScreenSection(FILE *cf, XF86ConfScreenPtr ptr); +void xf86freeScreenList(XF86ConfScreenPtr ptr); +void xf86freeAdaptorLinkList(XF86ConfAdaptorLinkPtr ptr); +void xf86freeDisplayList(XF86ConfDisplayPtr ptr); +void xf86freeModeList(XF86ModePtr ptr); +int xf86validateScreen(XF86ConfigPtr p); +/* Vendor.c */ +XF86ConfVendorPtr xf86parseVendorSection(void); +XF86ConfVendSubPtr xf86parseVendorSubSection (void); +void xf86freeVendorList(XF86ConfVendorPtr p); +void xf86printVendorSection(FILE * cf, XF86ConfVendorPtr ptr); +void xf86freeVendorSubList (XF86ConfVendSubPtr ptr); +/* Video.c */ +XF86ConfVideoPortPtr xf86parseVideoPortSubSection(void); +XF86ConfVideoAdaptorPtr xf86parseVideoAdaptorSection(void); +void xf86printVideoAdaptorSection(FILE *cf, XF86ConfVideoAdaptorPtr ptr); +void xf86freeVideoAdaptorList(XF86ConfVideoAdaptorPtr ptr); +void xf86freeVideoPortList(XF86ConfVideoPortPtr ptr); +/* read.c */ +int xf86validateConfig(XF86ConfigPtr p); +/* scan.c */ +unsigned int xf86strToUL(char *str); +int xf86getToken(xf86ConfigSymTabRec *tab); +int xf86getSubToken(char **comment); +int xf86getSubTokenWithTab(char **comment, xf86ConfigSymTabRec *tab); +void xf86unGetToken(int token); +char *xf86tokenString(void); +void xf86parseError(char *format, ...); +void xf86parseWarning(char *format, ...); +void xf86validationError(char *format, ...); +void xf86setSection(char *section); +int xf86getStringToken(xf86ConfigSymTabRec *tab); +/* write.c */ +/* DRI.c */ +XF86ConfBuffersPtr xf86parseBuffers (void); +void xf86freeBuffersList (XF86ConfBuffersPtr ptr); +XF86ConfDRIPtr xf86parseDRISection (void); +void xf86printDRISection (FILE * cf, XF86ConfDRIPtr ptr); +void xf86freeDRI (XF86ConfDRIPtr ptr); +/* Extensions.c */ +XF86ConfExtensionsPtr xf86parseExtensionsSection (void); +void xf86printExtensionsSection (FILE * cf, XF86ConfExtensionsPtr ptr); +void xf86freeExtensions (XF86ConfExtensionsPtr ptr); + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifndef IN_XSERVER +/* Externally provided functions */ +void ErrorF(const char *f, ...); +void VErrorF(const char *f, va_list args); +#endif diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/cpconfig.c b/nx-X11/programs/Xserver/hw/xfree86/parser/cpconfig.c new file mode 100644 index 000000000..4eb635b30 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/parser/cpconfig.c @@ -0,0 +1,123 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/cpconfig.c,v 1.6 2000/10/20 14:59:03 alanh Exp $ */ +/* + * + * 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. + * + */ + +/* View/edit this file with tab stops set to 4 */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> +#include <ctype.h> +#include "xf86Parser.h" +#include "configProcs.h" + +#ifdef MALLOC_FUNCTIONS +void +xfree (void *p) +{ + free (p); + return; +} + +void * +xalloc (int size) +{ + return malloc (size); +} + +void * +xrealloc (void *p, int size) +{ + return realloc (p, size); +} + +#endif + +#define CONFPATH "%A,%R,/etc/X11/%R,%P/etc/X11/%R,%E,%F,/etc/X11/%F," \ + "%P/etc/X11/%F,%D/%X,/etc/X11/%X,/etc/%X,%P/etc/X11/%X.%H," \ + "%P/etc/X11/%X,%P/lib/X11/%X.%H,%P/lib/X11/%X" + +int +main (int argc, char *argv[]) +{ + const char *filename; + char *cmdline = NULL; + XF86ConfigPtr conf; + + if (argc > 1) + { + cmdline = argv[1]; + } + if ((filename = xf86openConfigFile (CONFPATH, cmdline, NULL))) + { + fprintf (stderr, "Opened %s for the config file\n", filename); + } + else + { + fprintf (stderr, "Unable to open config file\n"); + exit (1); + } + + if ((conf = xf86readConfigFile ()) == NULL) + { + fprintf (stderr, "Problem when parsing config file\n"); + } + else + { + fprintf (stderr, "Config file parsed OK\n"); + } + xf86closeConfigFile (); + + if (argc > 2) { + fprintf(stderr, "Writing config file to `%s'\n", argv[2]); + xf86writeConfigFile (argv[2], conf); + } + exit(0); +} + +/* Functions that the parser requires */ + +void +VErrorF(const char *f, va_list args) +{ + vfprintf(stderr, f, args); +} + +void +ErrorF(const char *f, ...) +{ + va_list args; + + va_start(args, f); + vfprintf(stderr, f, args); + va_end(args); +} diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/read.c b/nx-X11/programs/Xserver/hw/xfree86/parser/read.c new file mode 100644 index 000000000..59b0ea6fb --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/parser/read.c @@ -0,0 +1,321 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/read.c,v 1.24 2003/08/24 17:37:08 dawes Exp $ */ +/* + * + * 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" + +extern LexRec val; + +static xf86ConfigSymTabRec TopLevelTab[] = +{ + {SECTION, "section"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeConfig + +XF86ConfigPtr +xf86readConfigFile (void) +{ + int token; + XF86ConfigPtr ptr = NULL; + + if ((ptr = xf86confcalloc (1, sizeof (XF86ConfigRec))) == NULL) + { + return NULL; + } + memset (ptr, 0, sizeof (XF86ConfigRec)); + + while ((token = xf86getToken (TopLevelTab)) != EOF_TOKEN) + { + switch (token) + { + case COMMENT: + ptr->conf_comment = xf86addComment(ptr->conf_comment, val.str); + break; + case SECTION: + if (xf86getSubToken (&(ptr->conf_comment)) != STRING) + { + xf86parseError (QUOTE_MSG, "Section"); + CLEANUP (ptr); + return (NULL); + } + xf86setSection (val.str); + if (xf86nameCompare (val.str, "files") == 0) + { + xf86conffree(val.str); + val.str = NULL; + HANDLE_RETURN (conf_files, xf86parseFilesSection ()); + } + else if (xf86nameCompare (val.str, "serverflags") == 0) + { + xf86conffree(val.str); + val.str = NULL; + HANDLE_RETURN (conf_flags, xf86parseFlagsSection ()); + } + else if (xf86nameCompare (val.str, "keyboard") == 0) + { + xf86conffree(val.str); + val.str = NULL; + HANDLE_LIST (conf_input_lst, xf86parseKeyboardSection, + XF86ConfInputPtr); + } + else if (xf86nameCompare (val.str, "pointer") == 0) + { + xf86conffree(val.str); + val.str = NULL; + HANDLE_LIST (conf_input_lst, xf86parsePointerSection, + XF86ConfInputPtr); + } + else if (xf86nameCompare (val.str, "videoadaptor") == 0) + { + xf86conffree(val.str); + val.str = NULL; + HANDLE_LIST (conf_videoadaptor_lst, xf86parseVideoAdaptorSection, + XF86ConfVideoAdaptorPtr); + } + else if (xf86nameCompare (val.str, "device") == 0) + { + xf86conffree(val.str); + val.str = NULL; + HANDLE_LIST (conf_device_lst, xf86parseDeviceSection, + XF86ConfDevicePtr); + } + else if (xf86nameCompare (val.str, "monitor") == 0) + { + xf86conffree(val.str); + val.str = NULL; + HANDLE_LIST (conf_monitor_lst, xf86parseMonitorSection, + XF86ConfMonitorPtr); + } + else if (xf86nameCompare (val.str, "modes") == 0) + { + xf86conffree(val.str); + val.str = NULL; + HANDLE_LIST (conf_modes_lst, xf86parseModesSection, + XF86ConfModesPtr); + } + else if (xf86nameCompare (val.str, "screen") == 0) + { + xf86conffree(val.str); + val.str = NULL; + HANDLE_LIST (conf_screen_lst, xf86parseScreenSection, + XF86ConfScreenPtr); + } + else if (xf86nameCompare(val.str, "inputdevice") == 0) + { + xf86conffree(val.str); + val.str = NULL; + HANDLE_LIST (conf_input_lst, xf86parseInputSection, + XF86ConfInputPtr); + } + else if (xf86nameCompare (val.str, "module") == 0) + { + xf86conffree(val.str); + val.str = NULL; + HANDLE_RETURN (conf_modules, xf86parseModuleSection ()); + } + else if (xf86nameCompare (val.str, "serverlayout") == 0) + { + xf86conffree(val.str); + val.str = NULL; + HANDLE_LIST (conf_layout_lst, xf86parseLayoutSection, + XF86ConfLayoutPtr); + } + else if (xf86nameCompare (val.str, "vendor") == 0) + { + xf86conffree(val.str); + val.str = NULL; + HANDLE_LIST (conf_vendor_lst, xf86parseVendorSection, + XF86ConfVendorPtr); + } + else if (xf86nameCompare (val.str, "dri") == 0) + { + xf86conffree(val.str); + val.str = NULL; + HANDLE_RETURN (conf_dri, xf86parseDRISection ()); + } + else if (xf86nameCompare (val.str, "extensions") == 0) + { + xf86conffree(val.str); + val.str = NULL; + HANDLE_RETURN (conf_extensions, xf86parseExtensionsSection ()); + } + else + { + Error (INVALID_SECTION_MSG, xf86tokenString ()); + xf86conffree(val.str); + val.str = NULL; + } + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + xf86conffree(val.str); + val.str = NULL; + } + } + + if (xf86validateConfig (ptr)) + return (ptr); + else + { + CLEANUP (ptr); + return (NULL); + } +} + +#undef CLEANUP + +/* + * This function resolves name references and reports errors if the named + * objects cannot be found. + */ +int +xf86validateConfig (XF86ConfigPtr p) +{ + if (!xf86validateDevice (p)) + return FALSE; + if (!xf86validateScreen (p)) + return FALSE; + if (!xf86validateInput (p)) + return FALSE; + if (!xf86validateLayout (p)) + return FALSE; + + return (TRUE); +} + +/* + * adds an item to the end of the linked list. Any record whose first field + * is a GenericListRec can be cast to this type and used with this function. + * A pointer to the head of the list is returned to handle the addition of + * the first item. + */ +GenericListPtr +xf86addListItem (GenericListPtr head, GenericListPtr new) +{ + GenericListPtr p = head; + GenericListPtr last = NULL; + + while (p) + { + last = p; + p = p->next; + } + + if (last) + { + last->next = new; + return (head); + } + else + return (new); +} + +/* + * Test if one chained list contains the other. + * In this case both list have the same endpoint (provided they don't loop) + */ +int +xf86itemNotSublist(GenericListPtr list_1, GenericListPtr list_2) +{ + GenericListPtr p = list_1; + GenericListPtr last_1 = NULL, last_2 = NULL; + + while (p) { + last_1 = p; + p = p->next; + } + + p = list_2; + while (p) { + last_2 = p; + p = p->next; + } + + return (!(last_1 == last_2)); +} + +void +xf86freeConfig (XF86ConfigPtr p) +{ + if (p == NULL) + return; + + xf86freeFiles (p->conf_files); + xf86freeModules (p->conf_modules); + xf86freeFlags (p->conf_flags); + xf86freeMonitorList (p->conf_monitor_lst); + xf86freeModesList (p->conf_modes_lst); + xf86freeVideoAdaptorList (p->conf_videoadaptor_lst); + xf86freeDeviceList (p->conf_device_lst); + xf86freeScreenList (p->conf_screen_lst); + xf86freeLayoutList (p->conf_layout_lst); + xf86freeInputList (p->conf_input_lst); + xf86freeVendorList (p->conf_vendor_lst); + xf86freeDRI (p->conf_dri); + xf86freeExtensions (p->conf_extensions); + TestFree(p->conf_comment); + + xf86conffree (p); +} diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/scan.c b/nx-X11/programs/Xserver/hw/xfree86/parser/scan.c new file mode 100644 index 000000000..ce3cda128 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/parser/scan.c @@ -0,0 +1,949 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/scan.c,v 1.30 2003/11/03 05:11:52 tsi Exp $ */ +/* + * + * 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 <ctype.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <stdarg.h> + +#if !defined(X_NOT_POSIX) +#if defined(_POSIX_SOURCE) +#include <limits.h> +#else +#define _POSIX_SOURCE +#include <limits.h> +#undef _POSIX_SOURCE +#endif /* _POSIX_SOURCE */ +#endif /* !X_NOT_POSIX */ +#if !defined(PATH_MAX) +#if defined(MAXPATHLEN) +#define PATH_MAX MAXPATHLEN +#else +#define PATH_MAX 1024 +#endif /* MAXPATHLEN */ +#endif /* !PATH_MAX */ + +#if !defined(MAXHOSTNAMELEN) +#define MAXHOSTNAMELEN 32 +#endif /* !MAXHOSTNAMELEN */ + +#include "Configint.h" +#include "xf86tokens.h" + +#define CONFIG_BUF_LEN 1024 + +static int StringToToken (char *, xf86ConfigSymTabRec *); + +static FILE *configFile = NULL; +static const char **builtinConfig = NULL; +static int builtinIndex = 0; +static int configPos = 0; /* current readers position */ +static int configLineNo = 0; /* linenumber */ +static char *configBuf, *configRBuf; /* buffer for lines */ +static char *configPath; /* path to config file */ +static char *configSection = NULL; /* name of current section being parsed */ +static int pushToken = LOCK_TOKEN; +static int eol_seen = 0; /* private state to handle comments */ +LexRec val; + +#ifdef __UNIXOS2__ +extern char *__XOS2RedirRoot(char *path); +#endif + +/* + * xf86strToUL -- + * + * A portable, but restricted, version of strtoul(). It only understands + * hex, octal, and decimal. But it's good enough for our needs. + */ +unsigned int +xf86strToUL (char *str) +{ + int base = 10; + char *p = str; + unsigned int tot = 0; + + if (*p == '0') + { + p++; + if ((*p == 'x') || (*p == 'X')) + { + p++; + base = 16; + } + else + base = 8; + } + while (*p) + { + if ((*p >= '0') && (*p <= ((base == 8) ? '7' : '9'))) + { + tot = tot * base + (*p - '0'); + } + else if ((base == 16) && (*p >= 'a') && (*p <= 'f')) + { + tot = tot * base + 10 + (*p - 'a'); + } + else if ((base == 16) && (*p >= 'A') && (*p <= 'F')) + { + tot = tot * base + 10 + (*p - 'A'); + } + else + { + return (tot); + } + p++; + } + return (tot); +} + +/* + * xf86getToken -- + * Read next Token form the config file. Handle the global variable + * pushToken. + */ +int +xf86getToken (xf86ConfigSymTabRec * tab) +{ + int c, i; + + /* + * First check whether pushToken has a different value than LOCK_TOKEN. + * In this case rBuf[] contains a valid STRING/TOKEN/NUMBER. But in the + * oth * case the next token must be read from the input. + */ + if (pushToken == EOF_TOKEN) + return (EOF_TOKEN); + else if (pushToken == LOCK_TOKEN) + { + /* + * eol_seen is only set for the first token after a newline. + */ + eol_seen = 0; + + c = configBuf[configPos]; + + /* + * Get start of next Token. EOF is handled, + * whitespaces are skipped. + */ + +again: + if (!c) + { + char *ret; + if (configFile) + ret = fgets (configBuf, CONFIG_BUF_LEN - 1, configFile); + else { + if (builtinConfig[builtinIndex] == NULL) + ret = NULL; + else { + ret = strncpy(configBuf, builtinConfig[builtinIndex], + CONFIG_BUF_LEN); + builtinIndex++; + } + } + if (ret == NULL) + { + return (pushToken = EOF_TOKEN); + } + configLineNo++; + configPos = 0; + eol_seen = 1; + } + + i = 0; + for (;;) { + c = configBuf[configPos++]; + configRBuf[i++] = c; + switch (c) { + case ' ': + case '\t': + case '\r': + continue; + case '\n': + i = 0; + continue; + } + break; + } + if (c == '\0') + goto again; + + if (c == '#') + { + do + { + configRBuf[i++] = (c = configBuf[configPos++]); + } + while ((c != '\n') && (c != '\r') && (c != '\0')); + configRBuf[i] = '\0'; + /* XXX no private copy. + * Use xf86addComment when setting a comment. + */ + val.str = configRBuf; + return (COMMENT); + } + + /* GJA -- handle '-' and ',' * Be careful: "-hsync" is a keyword. */ + else if ((c == ',') && !isalpha (configBuf[configPos])) + { + return COMMA; + } + else if ((c == '-') && !isalpha (configBuf[configPos])) + { + return DASH; + } + + /* + * Numbers are returned immediately ... + */ + if (isdigit (c)) + { + int base; + + if (c == '0') + if ((configBuf[configPos] == 'x') || + (configBuf[configPos] == 'X')) + base = 16; + else + base = 8; + else + base = 10; + + configRBuf[0] = c; + i = 1; + while (isdigit (c = configBuf[configPos++]) || + (c == '.') || (c == 'x') || (c == 'X') || + ((base == 16) && (((c >= 'a') && (c <= 'f')) || + ((c >= 'A') && (c <= 'F'))))) + configRBuf[i++] = c; + configPos--; /* GJA -- one too far */ + configRBuf[i] = '\0'; + val.num = xf86strToUL (configRBuf); + val.realnum = atof (configRBuf); + return (NUMBER); + } + + /* + * All Strings START with a \" ... + */ + else if (c == '\"') + { + i = -1; + do + { + configRBuf[++i] = (c = configBuf[configPos++]); + } + while ((c != '\"') && (c != '\n') && (c != '\r') && (c != '\0')); + configRBuf[i] = '\0'; + val.str = xf86confmalloc (strlen (configRBuf) + 1); + strcpy (val.str, configRBuf); /* private copy ! */ + return (STRING); + } + + /* + * ... and now we MUST have a valid token. The search is + * handled later along with the pushed tokens. + */ + else + { + configRBuf[0] = c; + i = 0; + do + { + configRBuf[++i] = (c = configBuf[configPos++]);; + } + while ((c != ' ') && (c != '\t') && (c != '\n') && (c != '\r') && (c != '\0') && (c != '#')); + --configPos; + configRBuf[i] = '\0'; + i = 0; + } + + } + else + { + + /* + * Here we deal with pushed tokens. Reinitialize pushToken again. If + * the pushed token was NUMBER || STRING return them again ... + */ + int temp = pushToken; + pushToken = LOCK_TOKEN; + + if (temp == COMMA || temp == DASH) + return (temp); + if (temp == NUMBER || temp == STRING) + return (temp); + } + + /* + * Joop, at last we have to lookup the token ... + */ + if (tab) + { + i = 0; + while (tab[i].token != -1) + if (xf86nameCompare (configRBuf, tab[i].name) == 0) + return (tab[i].token); + else + i++; + } + + return (ERROR_TOKEN); /* Error catcher */ +} + +int +xf86getSubToken (char **comment) +{ + int token; + + for (;;) { + token = xf86getToken(NULL); + if (token == COMMENT) { + if (comment) + *comment = xf86addComment(*comment, val.str); + } + else + return (token); + } + /*NOTREACHED*/ +} + +int +xf86getSubTokenWithTab (char **comment, xf86ConfigSymTabRec *tab) +{ + int token; + + for (;;) { + token = xf86getToken(tab); + if (token == COMMENT) { + if (comment) + *comment = xf86addComment(*comment, val.str); + } + else + return (token); + } + /*NOTREACHED*/ +} + +void +xf86unGetToken (int token) +{ + pushToken = token; +} + +char * +xf86tokenString (void) +{ + return configRBuf; +} + +int +xf86pathIsAbsolute(const char *path) +{ + if (path && path[0] == '/') + return 1; +#ifdef __UNIXOS2__ + if (path && (path[0] == '\\' || (path[1] == ':'))) + return 1; +#endif + return 0; +} + +/* A path is "safe" if it is relative and if it contains no ".." elements. */ +int +xf86pathIsSafe(const char *path) +{ + if (xf86pathIsAbsolute(path)) + return 0; + + /* Compare with ".." */ + if (!strcmp(path, "..")) + return 0; + + /* Look for leading "../" */ + if (!strncmp(path, "../", 3)) + return 0; + + /* Look for trailing "/.." */ + if ((strlen(path) > 3) && !strcmp(path + strlen(path) - 3, "/..")) + return 0; + + /* Look for "/../" */ + if (strstr(path, "/../")) + return 0; + + return 1; +} + +/* + * This function substitutes the following escape sequences: + * + * %A cmdline argument as an absolute path (must be absolute to match) + * %R cmdline argument as a relative path + * %S cmdline argument as a "safe" path (relative, and no ".." elements) + * %X default config file name ("xorg.conf") + * %H hostname + * %E config file environment ($XORGCONFIG) as an absolute path + * %F config file environment ($XORGCONFIG) as a relative path + * %G config file environment ($XORGCONFIG) as a safe path + * %D $HOME + * %P projroot + * %M major version number + * %% % + * %& UNIXOS2 only: prepend X11ROOT env var + */ + +#ifndef XCONFIGFILE +#define XCONFIGFILE "xorg.conf" +#endif +#ifndef PROJECTROOT +#define PROJECTROOT "/usr/X11R6" +#endif +#ifndef XCONFENV +#define XCONFENV "XORGCONFIG" +#endif +#define XFREE86CFGFILE "XF86Config" +#ifndef XF86_VERSION_MAJOR +#ifdef XVERSION +#if XVERSION > 40000000 +#define XF86_VERSION_MAJOR (XVERSION / 10000000) +#else +#define XF86_VERSION_MAJOR (XVERSION / 1000) +#endif +#else +#define XF86_VERSION_MAJOR 4 +#endif +#endif + +#define BAIL_OUT do { \ + xf86conffree(result); \ + return NULL; \ + } while (0) + +#define CHECK_LENGTH do { \ + if (l > PATH_MAX) { \ + BAIL_OUT; \ + } \ + } while (0) + +#define APPEND_STR(s) do { \ + if (strlen(s) + l > PATH_MAX) { \ + BAIL_OUT; \ + } else { \ + strcpy(result + l, s); \ + l += strlen(s); \ + } \ + } while (0) + +static char * +DoSubstitution(const char *template, const char *cmdline, const char *projroot, + int *cmdlineUsed, int *envUsed, char *XConfigFile) +{ + char *result; + int i, l; + static const char *env = NULL, *home = NULL; + static char *hostname = NULL; + static char majorvers[3] = ""; +#ifdef __UNIXOS2__ + static char *x11root = NULL; +#endif + + if (!template) + return NULL; + + if (cmdlineUsed) + *cmdlineUsed = 0; + if (envUsed) + *envUsed = 0; + + result = xf86confmalloc(PATH_MAX + 1); + l = 0; + for (i = 0; template[i]; i++) { + if (template[i] != '%') { + result[l++] = template[i]; + CHECK_LENGTH; + } else { + switch (template[++i]) { + case 'A': + if (cmdline && xf86pathIsAbsolute(cmdline)) { + APPEND_STR(cmdline); + if (cmdlineUsed) + *cmdlineUsed = 1; + } else + BAIL_OUT; + break; + case 'R': + if (cmdline && !xf86pathIsAbsolute(cmdline)) { + APPEND_STR(cmdline); + if (cmdlineUsed) + *cmdlineUsed = 1; + } else + BAIL_OUT; + break; + case 'S': + if (cmdline && xf86pathIsSafe(cmdline)) { + APPEND_STR(cmdline); + if (cmdlineUsed) + *cmdlineUsed = 1; + } else + BAIL_OUT; + break; + case 'X': + APPEND_STR(XConfigFile); + break; + case 'H': + if (!hostname) { + if ((hostname = xf86confmalloc(MAXHOSTNAMELEN + 1))) { + if (gethostname(hostname, MAXHOSTNAMELEN) == 0) { + hostname[MAXHOSTNAMELEN] = '\0'; + } else { + xf86conffree(hostname); + hostname = NULL; + } + } + } + if (hostname) + APPEND_STR(hostname); + break; + case 'E': + if (!env) + env = getenv(XCONFENV); + if (env && xf86pathIsAbsolute(env)) { + APPEND_STR(env); + if (envUsed) + *envUsed = 1; + } else + BAIL_OUT; + break; + case 'F': + if (!env) + env = getenv(XCONFENV); + if (env && !xf86pathIsAbsolute(env)) { + APPEND_STR(env); + if (envUsed) + *envUsed = 1; + } else + BAIL_OUT; + break; + case 'G': + if (!env) + env = getenv(XCONFENV); + if (env && xf86pathIsSafe(env)) { + APPEND_STR(env); + if (envUsed) + *envUsed = 1; + } else + BAIL_OUT; + break; + case 'D': + if (!home) + home = getenv("HOME"); + if (home && xf86pathIsAbsolute(home)) + APPEND_STR(home); + else + BAIL_OUT; + break; + case 'P': + if (projroot && xf86pathIsAbsolute(projroot)) + APPEND_STR(projroot); + else + BAIL_OUT; + break; + case 'M': + if (!majorvers[0]) { + if (XF86_VERSION_MAJOR < 0 || XF86_VERSION_MAJOR > 99) { + fprintf(stderr, "XF86_VERSION_MAJOR is out of range\n"); + BAIL_OUT; + } else + sprintf(majorvers, "%d", XF86_VERSION_MAJOR); + } + APPEND_STR(majorvers); + break; + case '%': + result[l++] = '%'; + CHECK_LENGTH; + break; +#ifdef __UNIXOS2__ + case '&': + if (!x11root) + x11root = getenv("X11ROOT"); + if (x11root) + APPEND_STR(x11root); + else + BAIL_OUT; + break; +#endif + default: + fprintf(stderr, "invalid escape %%%c found in path template\n", + template[i]); + BAIL_OUT; + break; + } + } + } +#ifdef DEBUG + fprintf(stderr, "Converted `%s' to `%s'\n", template, result); +#endif + return result; +} + +/* + * xf86openConfigFile -- + * + * This function take a config file search path (optional), a command-line + * specified file name (optional) and the ProjectRoot path (optional) and + * locates and opens a config file based on that information. If a + * command-line file name is specified, then this function fails if none + * of the located files. + * + * The return value is a pointer to the actual name of the file that was + * opened. When no file is found, the return value is NULL. + * + * The escape sequences allowed in the search path are defined above. + * + */ + +#ifndef DEFAULT_CONF_PATH +#define DEFAULT_CONF_PATH "/etc/X11/%S," \ + "%P/etc/X11/%S," \ + "/etc/X11/%G," \ + "%P/etc/X11/%G," \ + "/etc/X11/%X-%M," \ + "/etc/X11/%X," \ + "/etc/%X," \ + "%P/etc/X11/%X.%H," \ + "%P/etc/X11/%X-%M," \ + "%P/etc/X11/%X," \ + "%P/lib/X11/%X.%H," \ + "%P/lib/X11/%X-%M," \ + "%P/lib/X11/%X" +#endif + +const char * +xf86openConfigFile(const char *path, const char *cmdline, const char *projroot) +{ + char *pathcopy; + const char *template; + int cmdlineUsed = 0; + + configFile = NULL; + configPos = 0; /* current readers position */ + configLineNo = 0; /* linenumber */ + pushToken = LOCK_TOKEN; + + if (!path || !path[0]) + path = DEFAULT_CONF_PATH; + pathcopy = xf86confmalloc(strlen(path) + 1); + strcpy(pathcopy, path); + if (!projroot || !projroot[0]) + projroot = PROJECTROOT; + + template = strtok(pathcopy, ","); + + /* First, search for a config file. */ + while (template && !configFile) { + if ((configPath = DoSubstitution(template, cmdline, projroot, + &cmdlineUsed, NULL, + XCONFIGFILE))) { + if ((configFile = fopen(configPath, "r")) != 0) { + if (cmdline && !cmdlineUsed) { + fclose(configFile); + configFile = NULL; + } + } + } + if (configPath && !configFile) { + xf86conffree(configPath); + configPath = NULL; + } + template = strtok(NULL, ","); + } + + /* Then search for fallback */ + if (!configFile) { + strcpy(pathcopy, path); + template = strtok(pathcopy, ","); + + while (template && !configFile) { + if ((configPath = DoSubstitution(template, cmdline, projroot, + &cmdlineUsed, NULL, + XFREE86CFGFILE))) { + if ((configFile = fopen(configPath, "r")) != 0) { + if (cmdline && !cmdlineUsed) { + fclose(configFile); + configFile = NULL; + } + } + } + if (configPath && !configFile) { + xf86conffree(configPath); + configPath = NULL; + } + template = strtok(NULL, ","); + } + } + + xf86conffree(pathcopy); + if (!configFile) { + + return NULL; + } + + configBuf = xf86confmalloc (CONFIG_BUF_LEN); + configRBuf = xf86confmalloc (CONFIG_BUF_LEN); + configBuf[0] = '\0'; /* sanity ... */ + + return configPath; +} + +void +xf86closeConfigFile (void) +{ + xf86conffree (configPath); + configPath = NULL; + xf86conffree (configRBuf); + configRBuf = NULL; + xf86conffree (configBuf); + configBuf = NULL; + + if (configFile) { + fclose (configFile); + configFile = NULL; + } else { + builtinConfig = NULL; + builtinIndex = 0; + } +} + +void +xf86setBuiltinConfig(const char *config[]) +{ + builtinConfig = config; + configPath = xf86configStrdup("<builtin configuration>"); + configBuf = xf86confmalloc (CONFIG_BUF_LEN); + configRBuf = xf86confmalloc (CONFIG_BUF_LEN); + configBuf[0] = '\0'; /* sanity ... */ + +} + +void +xf86parseError (char *format,...) +{ + va_list ap; + + ErrorF ("Parse error on line %d of section %s in file %s\n\t", + configLineNo, configSection, configPath); + va_start (ap, format); + VErrorF (format, ap); + va_end (ap); + + ErrorF ("\n"); +} + +void +xf86parseWarning (char *format,...) +{ + va_list ap; + + ErrorF ("Parse warning on line %d of section %s in file %s\n\t", + configLineNo, configSection, configPath); + va_start (ap, format); + VErrorF (format, ap); + va_end (ap); + + ErrorF ("\n"); +} + +void +xf86validationError (char *format,...) +{ + va_list ap; + + ErrorF ("Data incomplete in file %s\n\t", configPath); + va_start (ap, format); + VErrorF (format, ap); + va_end (ap); + + ErrorF ("\n"); +} + +void +xf86setSection (char *section) +{ + if (configSection) + xf86conffree(configSection); + configSection = xf86confmalloc(strlen (section) + 1); + strcpy (configSection, section); +} + +/* + * xf86getToken -- + * Lookup a string if it is actually a token in disguise. + */ +int +xf86getStringToken (xf86ConfigSymTabRec * tab) +{ + return StringToToken (val.str, tab); +} + +static int +StringToToken (char *str, xf86ConfigSymTabRec * tab) +{ + int i; + + for (i = 0; tab[i].token != -1; i++) + { + if (!xf86nameCompare (tab[i].name, str)) + return tab[i].token; + } + return (ERROR_TOKEN); +} + + +/* + * Compare two names. The characters '_', ' ', and '\t' are ignored + * in the comparison. + */ +int +xf86nameCompare (const char *s1, const char *s2) +{ + char c1, c2; + + if (!s1 || *s1 == 0) { + if (!s2 || *s2 == 0) + return (0); + else + return (1); + } + + while (*s1 == '_' || *s1 == ' ' || *s1 == '\t') + s1++; + while (*s2 == '_' || *s2 == ' ' || *s2 == '\t') + s2++; + c1 = (isupper (*s1) ? tolower (*s1) : *s1); + c2 = (isupper (*s2) ? tolower (*s2) : *s2); + while (c1 == c2) + { + if (c1 == '\0') + return (0); + s1++; + s2++; + while (*s1 == '_' || *s1 == ' ' || *s1 == '\t') + s1++; + while (*s2 == '_' || *s2 == ' ' || *s2 == '\t') + s2++; + c1 = (isupper (*s1) ? tolower (*s1) : *s1); + c2 = (isupper (*s2) ? tolower (*s2) : *s2); + } + return (c1 - c2); +} + +char * +xf86addComment(char *cur, char *add) +{ + char *str; + int len, curlen, iscomment, hasnewline = 0, endnewline; + + if (add == NULL || add[0] == '\0') + return (cur); + + if (cur) { + curlen = strlen(cur); + if (curlen) + hasnewline = cur[curlen - 1] == '\n'; + eol_seen = 0; + } + else + curlen = 0; + + str = add; + iscomment = 0; + while (*str) { + if (*str != ' ' && *str != '\t') + break; + ++str; + } + iscomment = (*str == '#'); + + len = strlen(add); + endnewline = add[len - 1] == '\n'; + len += 1 + iscomment + (!hasnewline) + (!endnewline) + eol_seen; + + if ((str = xf86confrealloc(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"); + + return (cur); +} diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/write.c b/nx-X11/programs/Xserver/hw/xfree86/parser/write.c new file mode 100644 index 000000000..285080d99 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/parser/write.c @@ -0,0 +1,220 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/write.c,v 1.18 2003/08/24 17:37:08 dawes Exp $ */ +/* + * + * 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 <unistd.h> +#include <sys/types.h> +#include <sys/wait.h> +#include <signal.h> +#include <errno.h> + +#if ((defined(sun) && !defined(SVR4)) || defined(macII)) && !defined(__GLIBC__) +#ifndef strerror +extern char *sys_errlist[]; +extern int sys_nerr; +#define strerror(n) \ + (((n) >= 0 && (n) < sys_nerr) ? sys_errlist[n] : "unknown error") +#endif +#endif + +#if defined(SVR4) || defined(__linux__) || defined(CSRG_BASED) +#define HAS_SAVED_IDS_AND_SETEUID +#endif +#if defined(__UNIXOS2__) || defined(WIN32) +#define HAS_NO_UIDS +#endif + +#ifdef HAS_NO_UIDS +#define doWriteConfigFile xf86writeConfigFile +#define Local /**/ +#else +#define Local static +#endif + +Local int +doWriteConfigFile (const char *filename, XF86ConfigPtr cptr) +{ + FILE *cf; + + if ((cf = fopen (filename, "w")) == NULL) + { + return 0; + } + + if (cptr->conf_comment) + fprintf (cf, "%s\n", cptr->conf_comment); + + xf86printLayoutSection (cf, cptr->conf_layout_lst); + + fprintf (cf, "Section \"Files\"\n"); + xf86printFileSection (cf, cptr->conf_files); + fprintf (cf, "EndSection\n\n"); + + fprintf (cf, "Section \"Module\"\n"); + xf86printModuleSection (cf, cptr->conf_modules); + fprintf (cf, "EndSection\n\n"); + + xf86printVendorSection (cf, cptr->conf_vendor_lst); + + xf86printServerFlagsSection (cf, cptr->conf_flags); + + xf86printInputSection (cf, cptr->conf_input_lst); + + xf86printVideoAdaptorSection (cf, cptr->conf_videoadaptor_lst); + + xf86printModesSection (cf, cptr->conf_modes_lst); + + xf86printMonitorSection (cf, cptr->conf_monitor_lst); + + xf86printDeviceSection (cf, cptr->conf_device_lst); + + xf86printScreenSection (cf, cptr->conf_screen_lst); + + xf86printDRISection (cf, cptr->conf_dri); + + xf86printExtensionsSection (cf, cptr->conf_extensions); + + fclose(cf); + return 1; +} + +#ifndef HAS_NO_UIDS + +int +xf86writeConfigFile (const char *filename, XF86ConfigPtr cptr) +{ + int ret; + +#if !defined(HAS_SAVED_IDS_AND_SETEUID) + int pid, p; + int status; + void (*csig)(int); +#else + int ruid, euid; +#endif + + if (getuid() != geteuid()) + { + +#if !defined(HAS_SAVED_IDS_AND_SETEUID) + /* Need to fork to change ruid without loosing euid */ +#ifdef SIGCHLD + csig = signal(SIGCHLD, SIG_DFL); +#endif + switch ((pid = fork())) + { + case -1: + ErrorF("xf86writeConfigFile(): fork failed (%s)\n", + strerror(errno)); + return 0; + case 0: /* child */ + setuid(getuid()); + ret = doWriteConfigFile(filename, cptr); + exit(ret); + break; + default: /* parent */ + do + { + p = waitpid(pid, &status, 0); + } while (p == -1 && errno == EINTR); + } +#ifdef SIGCHLD + signal(SIGCHLD, csig); +#endif + if (p != -1 && WIFEXITED(status) && WEXITSTATUS(status) == 0) + return 1; /* success */ + else + return 0; + +#else /* HAS_SAVED_IDS_AND_SETEUID */ + + ruid = getuid(); + euid = geteuid(); + + if (seteuid(ruid) == -1) + { + ErrorF("xf86writeConfigFile(): seteuid(%d) failed (%s)\n", + ruid, strerror(errno)); + return 0; + } + ret = doWriteConfigFile(filename, cptr); + + if (seteuid(euid) == -1) + { + ErrorF("xf86writeConfigFile(): seteuid(%d) failed (%s)\n", + euid, strerror(errno)); + } + return ret; + +#endif /* HAS_SAVED_IDS_AND_SETEUID */ + + } + else + { + return doWriteConfigFile(filename, cptr); + } +} + +#endif /* !HAS_NO_UIDS */ diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/xf86Optrec.h b/nx-X11/programs/Xserver/hw/xfree86/parser/xf86Optrec.h new file mode 100644 index 000000000..c38f2c219 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/parser/xf86Optrec.h @@ -0,0 +1,113 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/xf86Optrec.h,v 1.11 2003/08/24 17:37:08 dawes Exp $ */ +/* + * + * 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-2001 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). + */ + + +/* + * This file contains the Option Record that is passed between the Parser, + * and Module setup procs. + */ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifndef _xf86Optrec_h_ +#define _xf86Optrec_h_ +#include <stdio.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; + +/* + * All options are stored using this data type. + */ +typedef struct +{ + GenericListRec list; + char *opt_name; + char *opt_val; + int opt_used; + char *opt_comment; +} +XF86OptionRec, *XF86OptionPtr; + + +XF86OptionPtr xf86addNewOption(XF86OptionPtr head, char *name, char *val); +XF86OptionPtr xf86optionListDup(XF86OptionPtr opt); +void xf86optionListFree(XF86OptionPtr opt); +char *xf86optionName(XF86OptionPtr opt); +char *xf86optionValue(XF86OptionPtr opt); +XF86OptionPtr xf86newOption(char *name, char *value); +XF86OptionPtr xf86nextOption(XF86OptionPtr list); +XF86OptionPtr xf86findOption(XF86OptionPtr list, const char *name); +char *xf86findOptionValue(XF86OptionPtr list, const char *name); +int xf86findOptionBoolean (XF86OptionPtr, const char *, int); +XF86OptionPtr xf86optionListCreate(const char **options, int count, int used); +XF86OptionPtr xf86optionListMerge(XF86OptionPtr head, XF86OptionPtr tail); +char *xf86configStrdup (const char *s); +int xf86nameCompare (const char *s1, const char *s2); +char *xf86uLongToString(unsigned long i); +void xf86debugListOptions(XF86OptionPtr); +XF86OptionPtr xf86parseOption(XF86OptionPtr head); +void xf86printOptionList(FILE *fp, XF86OptionPtr list, int tabs); + + +#endif /* _xf86Optrec_h_ */ diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/xf86Parser.h b/nx-X11/programs/Xserver/hw/xfree86/parser/xf86Parser.h new file mode 100644 index 000000000..71568842d --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/parser/xf86Parser.h @@ -0,0 +1,483 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/xf86Parser.h,v 1.33 2003/10/08 14:58:30 dawes Exp $ */ +/* + * + * 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). + */ + + +/* + * This file contains the external interfaces for the XFree86 configuration + * file parser. + */ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifndef _xf86Parser_h_ +#define _xf86Parser_h_ + +#include "xf86Optrec.h" + +#define HAVE_PARSER_DECLS + +typedef struct +{ + char *file_logfile; + char *file_rgbpath; + char *file_modulepath; + char *file_inputdevs; + char *file_fontpath; + char *file_comment; +} +XF86ConfFilesRec, *XF86ConfFilesPtr; + +/* Values for load_type */ +#define XF86_LOAD_MODULE 0 +#define XF86_LOAD_DRIVER 1 + +typedef struct +{ + GenericListRec list; + int load_type; + char *load_name; + XF86OptionPtr load_opt; + char *load_comment; +} +XF86LoadRec, *XF86LoadPtr; + +typedef struct +{ + XF86LoadPtr mod_load_lst; + char *mod_comment; +} +XF86ConfModuleRec, *XF86ConfModulePtr; + +#define CONF_IMPLICIT_KEYBOARD "Implicit Core Keyboard" + +#define CONF_IMPLICIT_POINTER "Implicit Core Pointer" + +#define XF86CONF_PHSYNC 0x0001 +#define XF86CONF_NHSYNC 0x0002 +#define XF86CONF_PVSYNC 0x0004 +#define XF86CONF_NVSYNC 0x0008 +#define XF86CONF_INTERLACE 0x0010 +#define XF86CONF_DBLSCAN 0x0020 +#define XF86CONF_CSYNC 0x0040 +#define XF86CONF_PCSYNC 0x0080 +#define XF86CONF_NCSYNC 0x0100 +#define XF86CONF_HSKEW 0x0200 /* hskew provided */ +#define XF86CONF_BCAST 0x0400 +#define XF86CONF_CUSTOM 0x0800 /* timing numbers customized by editor */ +#define XF86CONF_VSCAN 0x1000 + +typedef struct +{ + GenericListRec list; + char *ml_identifier; + int ml_clock; + int ml_hdisplay; + int ml_hsyncstart; + int ml_hsyncend; + int ml_htotal; + int ml_vdisplay; + int ml_vsyncstart; + int ml_vsyncend; + int ml_vtotal; + int ml_vscan; + int ml_flags; + int ml_hskew; + char *ml_comment; +} +XF86ConfModeLineRec, *XF86ConfModeLinePtr; + +typedef struct +{ + GenericListRec list; + char *vp_identifier; + XF86OptionPtr vp_option_lst; + char *vp_comment; +} +XF86ConfVideoPortRec, *XF86ConfVideoPortPtr; + +typedef struct +{ + GenericListRec list; + char *va_identifier; + char *va_vendor; + char *va_board; + char *va_busid; + char *va_driver; + XF86OptionPtr va_option_lst; + XF86ConfVideoPortPtr va_port_lst; + char *va_fwdref; + char *va_comment; +} +XF86ConfVideoAdaptorRec, *XF86ConfVideoAdaptorPtr; + +#define CONF_MAX_HSYNC 8 +#define CONF_MAX_VREFRESH 8 + +typedef struct +{ + float hi, lo; +} +parser_range; + +typedef struct +{ + int red, green, blue; +} +parser_rgb; + +typedef struct +{ + GenericListRec list; + char *modes_identifier; + XF86ConfModeLinePtr mon_modeline_lst; + char *modes_comment; +} +XF86ConfModesRec, *XF86ConfModesPtr; + +typedef struct +{ + GenericListRec list; + char *ml_modes_str; + XF86ConfModesPtr ml_modes; +} +XF86ConfModesLinkRec, *XF86ConfModesLinkPtr; + +typedef struct +{ + GenericListRec list; + char *mon_identifier; + char *mon_vendor; + char *mon_modelname; + int mon_width; /* in mm */ + int mon_height; /* in mm */ + XF86ConfModeLinePtr mon_modeline_lst; + int mon_n_hsync; + parser_range mon_hsync[CONF_MAX_HSYNC]; + int mon_n_vrefresh; + parser_range mon_vrefresh[CONF_MAX_VREFRESH]; + float mon_gamma_red; + float mon_gamma_green; + float mon_gamma_blue; + XF86OptionPtr mon_option_lst; + XF86ConfModesLinkPtr mon_modes_sect_lst; + char *mon_comment; +} +XF86ConfMonitorRec, *XF86ConfMonitorPtr; + +#define CONF_MAXDACSPEEDS 4 +#define CONF_MAXCLOCKS 128 + +typedef struct +{ + GenericListRec list; + char *dev_identifier; + char *dev_vendor; + char *dev_board; + char *dev_chipset; + char *dev_busid; + char *dev_card; + char *dev_driver; + char *dev_ramdac; + int dev_dacSpeeds[CONF_MAXDACSPEEDS]; + int dev_videoram; + int dev_textclockfreq; + unsigned long dev_bios_base; + unsigned long dev_mem_base; + unsigned long dev_io_base; + char *dev_clockchip; + int dev_clocks; + int dev_clock[CONF_MAXCLOCKS]; + int dev_chipid; + int dev_chiprev; + int dev_irq; + int dev_screen; + XF86OptionPtr dev_option_lst; + char *dev_comment; +} +XF86ConfDeviceRec, *XF86ConfDevicePtr; + +typedef struct +{ + GenericListRec list; + char *mode_name; +} +XF86ModeRec, *XF86ModePtr; + +typedef struct +{ + GenericListRec list; + int disp_frameX0; + int disp_frameY0; + int disp_virtualX; + int disp_virtualY; + int disp_depth; + int disp_bpp; + char *disp_visual; + parser_rgb disp_weight; + parser_rgb disp_black; + parser_rgb disp_white; + XF86ModePtr disp_mode_lst; + XF86OptionPtr disp_option_lst; + char *disp_comment; +} +XF86ConfDisplayRec, *XF86ConfDisplayPtr; + +typedef struct +{ + XF86OptionPtr flg_option_lst; + char *flg_comment; +} +XF86ConfFlagsRec, *XF86ConfFlagsPtr; + +typedef struct +{ + GenericListRec list; + char *al_adaptor_str; + XF86ConfVideoAdaptorPtr al_adaptor; +} +XF86ConfAdaptorLinkRec, *XF86ConfAdaptorLinkPtr; + +typedef struct +{ + GenericListRec list; + char *scrn_identifier; + char *scrn_obso_driver; + int scrn_defaultdepth; + int scrn_defaultbpp; + int scrn_defaultfbbpp; + char *scrn_monitor_str; + XF86ConfMonitorPtr scrn_monitor; + char *scrn_device_str; + XF86ConfDevicePtr scrn_device; + XF86ConfAdaptorLinkPtr scrn_adaptor_lst; + XF86ConfDisplayPtr scrn_display_lst; + XF86OptionPtr scrn_option_lst; + char *scrn_comment; +} +XF86ConfScreenRec, *XF86ConfScreenPtr; + +typedef struct +{ + GenericListRec list; + char *inp_identifier; + char *inp_driver; + XF86OptionPtr inp_option_lst; + char *inp_comment; +} +XF86ConfInputRec, *XF86ConfInputPtr; + +typedef struct +{ + GenericListRec list; + XF86ConfInputPtr iref_inputdev; + char *iref_inputdev_str; + XF86OptionPtr iref_option_lst; +} +XF86ConfInputrefRec, *XF86ConfInputrefPtr; + +/* Values for adj_where */ +#define CONF_ADJ_OBSOLETE -1 +#define CONF_ADJ_ABSOLUTE 0 +#define CONF_ADJ_RIGHTOF 1 +#define CONF_ADJ_LEFTOF 2 +#define CONF_ADJ_ABOVE 3 +#define CONF_ADJ_BELOW 4 +#define CONF_ADJ_RELATIVE 5 + +typedef struct +{ + GenericListRec list; + int adj_scrnum; + XF86ConfScreenPtr adj_screen; + char *adj_screen_str; + XF86ConfScreenPtr adj_top; + char *adj_top_str; + XF86ConfScreenPtr adj_bottom; + char *adj_bottom_str; + XF86ConfScreenPtr adj_left; + char *adj_left_str; + XF86ConfScreenPtr adj_right; + char *adj_right_str; + int adj_where; + int adj_x; + int adj_y; + char *adj_refscreen; +} +XF86ConfAdjacencyRec, *XF86ConfAdjacencyPtr; + +typedef struct +{ + GenericListRec list; + char *inactive_device_str; + XF86ConfDevicePtr inactive_device; +} +XF86ConfInactiveRec, *XF86ConfInactivePtr; + +typedef struct +{ + GenericListRec list; + char *lay_identifier; + XF86ConfAdjacencyPtr lay_adjacency_lst; + XF86ConfInactivePtr lay_inactive_lst; + XF86ConfInputrefPtr lay_input_lst; + XF86OptionPtr lay_option_lst; + char *lay_comment; +} +XF86ConfLayoutRec, *XF86ConfLayoutPtr; + +typedef struct +{ + GenericListRec list; + char *vs_name; + char *vs_identifier; + XF86OptionPtr vs_option_lst; + char *vs_comment; +} +XF86ConfVendSubRec, *XF86ConfVendSubPtr; + +typedef struct +{ + GenericListRec list; + char *vnd_identifier; + XF86OptionPtr vnd_option_lst; + XF86ConfVendSubPtr vnd_sub_lst; + char *vnd_comment; +} +XF86ConfVendorRec, *XF86ConfVendorPtr; + +typedef struct +{ + GenericListRec list; + int buf_count; + int buf_size; + char *buf_flags; + char *buf_comment; +} +XF86ConfBuffersRec, *XF86ConfBuffersPtr; + +typedef struct +{ + char *dri_group_name; + int dri_group; + int dri_mode; + XF86ConfBuffersPtr dri_buffers_lst; + char *dri_comment; +} +XF86ConfDRIRec, *XF86ConfDRIPtr; + +typedef struct +{ + XF86OptionPtr ext_option_lst; + char *extensions_comment; +} +XF86ConfExtensionsRec, *XF86ConfExtensionsPtr; + +typedef struct +{ + XF86ConfFilesPtr conf_files; + XF86ConfModulePtr conf_modules; + XF86ConfFlagsPtr conf_flags; + XF86ConfVideoAdaptorPtr conf_videoadaptor_lst; + XF86ConfModesPtr conf_modes_lst; + XF86ConfMonitorPtr conf_monitor_lst; + XF86ConfDevicePtr conf_device_lst; + XF86ConfScreenPtr conf_screen_lst; + XF86ConfInputPtr conf_input_lst; + XF86ConfLayoutPtr conf_layout_lst; + XF86ConfVendorPtr conf_vendor_lst; + XF86ConfDRIPtr conf_dri; + XF86ConfExtensionsPtr conf_extensions; + char *conf_comment; +} +XF86ConfigRec, *XF86ConfigPtr; + +typedef struct +{ + int token; /* id of the token */ + char *name; /* pointer to the LOWERCASED name */ +} +xf86ConfigSymTabRec, *xf86ConfigSymTabPtr; + +/* + * prototypes for public functions + */ +extern const char *xf86openConfigFile (const char *, const char *, + const char *); +extern void xf86setBuiltinConfig(const char *config[]); +extern XF86ConfigPtr xf86readConfigFile (void); +extern void xf86closeConfigFile (void); +extern void xf86freeConfig (XF86ConfigPtr p); +extern int xf86writeConfigFile (const char *, XF86ConfigPtr); +XF86ConfDevicePtr xf86findDevice(const char *ident, XF86ConfDevicePtr p); +XF86ConfLayoutPtr xf86findLayout(const char *name, XF86ConfLayoutPtr list); +XF86ConfMonitorPtr xf86findMonitor(const char *ident, XF86ConfMonitorPtr p); +XF86ConfModesPtr xf86findModes(const char *ident, XF86ConfModesPtr p); +XF86ConfModeLinePtr xf86findModeLine(const char *ident, XF86ConfModeLinePtr p); +XF86ConfScreenPtr xf86findScreen(const char *ident, XF86ConfScreenPtr p); +XF86ConfInputPtr xf86findInput(const char *ident, XF86ConfInputPtr p); +XF86ConfInputPtr xf86findInputByDriver(const char *driver, XF86ConfInputPtr p); +XF86ConfVendorPtr xf86findVendor(const char *name, XF86ConfVendorPtr list); +XF86ConfVideoAdaptorPtr xf86findVideoAdaptor(const char *ident, + XF86ConfVideoAdaptorPtr p); + +GenericListPtr xf86addListItem(GenericListPtr head, GenericListPtr c_new); +int xf86itemNotSublist(GenericListPtr list_1, GenericListPtr list_2); + +int xf86pathIsAbsolute(const char *path); +int xf86pathIsSafe(const char *path); +char *xf86addComment(char *cur, char *add); + +#endif /* _xf86Parser_h_ */ diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/xf86tokens.h b/nx-X11/programs/Xserver/hw/xfree86/parser/xf86tokens.h new file mode 100644 index 000000000..3c7e68ece --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/parser/xf86tokens.h @@ -0,0 +1,280 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/xf86tokens.h,v 1.20 2003/08/24 17:37:09 dawes Exp $ */ +/* + * + * 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). + */ + + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifndef _xf86_tokens_h +#define _xf86_tokens_h + +/* Undefine symbols that some OSs might define */ +#undef IOBASE + +/* + * Each token should have a unique value regardless of the section + * it is used in. + */ + +typedef enum { + /* errno-style tokens */ + EOF_TOKEN = -4, + LOCK_TOKEN = -3, + ERROR_TOKEN = -2, + + /* value type tokens */ + NUMBER = 1, + STRING, + + /* Tokens that can appear in many sections */ + SECTION, + SUBSECTION, + ENDSECTION, + ENDSUBSECTION, + IDENTIFIER, + VENDOR, + DASH, + COMMA, + OPTION, + COMMENT, + + /* Frequency units */ + HRZ, + KHZ, + MHZ, + + /* File tokens */ + FONTPATH, + RGBPATH, + MODULEPATH, + INPUTDEVICES, + LOGFILEPATH, + + /* Server Flag tokens. These are deprecated in favour of generic Options */ + NOTRAPSIGNALS, + DONTZAP, + DONTZOOM, + DISABLEVIDMODE, + ALLOWNONLOCAL, + DISABLEMODINDEV, + MODINDEVALLOWNONLOCAL, + ALLOWMOUSEOPENFAIL, + BLANKTIME, + STANDBYTIME, + SUSPENDTIME, + OFFTIME, + DEFAULTLAYOUT, + + /* Monitor tokens */ + MODEL, + MODELINE, + DISPLAYSIZE, + HORIZSYNC, + VERTREFRESH, + MODE, + GAMMA, + USEMODES, + + /* Modes tokens */ + /* no new ones */ + + /* Mode tokens */ + DOTCLOCK, + HTIMINGS, + VTIMINGS, + FLAGS, + HSKEW, + BCAST, + VSCAN, + ENDMODE, + + /* Screen tokens */ + OBSDRIVER, + MDEVICE, + MONITOR, + SCREENNO, + DEFAULTDEPTH, + DEFAULTBPP, + DEFAULTFBBPP, + + /* VideoAdaptor tokens */ + VIDEOADAPTOR, + + /* Mode timing tokens */ + TT_INTERLACE, + TT_PHSYNC, + TT_NHSYNC, + TT_PVSYNC, + TT_NVSYNC, + TT_CSYNC, + TT_PCSYNC, + TT_NCSYNC, + TT_DBLSCAN, + TT_HSKEW, + TT_BCAST, + TT_VSCAN, + TT_CUSTOM, + + /* Module tokens */ + LOAD, + LOAD_DRIVER, + + /* Device tokens */ + DRIVER, + CHIPSET, + CLOCKS, + VIDEORAM, + BOARD, + IOBASE, + RAMDAC, + DACSPEED, + BIOSBASE, + MEMBASE, + CLOCKCHIP, + CHIPID, + CHIPREV, + CARD, + BUSID, + TEXTCLOCKFRQ, + IRQ, + + /* Keyboard tokens */ + AUTOREPEAT, + XLEDS, + KPROTOCOL, + XKBKEYMAP, + XKBCOMPAT, + XKBTYPES, + XKBKEYCODES, + XKBGEOMETRY, + XKBSYMBOLS, + XKBDISABLE, + PANIX106, + XKBRULES, + XKBMODEL, + XKBLAYOUT, + XKBVARIANT, + XKBOPTIONS, + /* The next two have become ServerFlags options */ + VTINIT, + VTSYSREQ, + /* Obsolete keyboard tokens */ + SERVERNUM, + LEFTALT, + RIGHTALT, + SCROLLLOCK_TOK, + RIGHTCTL, + /* arguments for the above obsolete tokens */ + CONF_KM_META, + CONF_KM_COMPOSE, + CONF_KM_MODESHIFT, + CONF_KM_MODELOCK, + CONF_KM_SCROLLLOCK, + CONF_KM_CONTROL, + + /* Pointer tokens */ + EMULATE3, + BAUDRATE, + SAMPLERATE, + PRESOLUTION, + CLEARDTR, + CLEARRTS, + CHORDMIDDLE, + PROTOCOL, + PDEVICE, + EM3TIMEOUT, + DEVICE_NAME, + ALWAYSCORE, + PBUTTONS, + ZAXISMAPPING, + + /* Pointer Z axis mapping tokens */ + XAXIS, + YAXIS, + + /* Display tokens */ + MODES, + VIEWPORT, + VIRTUAL, + VISUAL, + BLACK_TOK, + WHITE_TOK, + DEPTH, + BPP, + WEIGHT, + + /* Layout Tokens */ + SCREEN, + INACTIVE, + INPUTDEVICE, + + /* Adjaceny Tokens */ + RIGHTOF, + LEFTOF, + ABOVE, + BELOW, + RELATIVE, + ABSOLUTE, + + /* Vendor Tokens */ + VENDORNAME, + + /* DRI Tokens */ + GROUP, + BUFFERS +} ParserTokens; + +#endif /* _xf86_tokens_h */ |