xserver/hw/xfree86/parser/read.c

311 lines
8.4 KiB
C
Raw Normal View History

2003-11-14 16:48:57 +00:00
/*
*
* 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).
*/
2003-11-14 16:48:57 +00:00
/* View/edit this file with tab stops set to 4 */
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
#endif
2003-11-14 16:48:57 +00:00
#include "xf86Parser.h"
#include "xf86tokens.h"
#include "Configint.h"
extern LexRec val;
static xf86ConfigSymTabRec TopLevelTab[] =
{
{SECTION, "section"},
{-1, ""},
};
#define CLEANUP xf86freeConfig
2007-03-25 12:27:01 -04:00
/*
* This function resolves name references and reports errors if the named
* objects cannot be found.
*/
static int
xf86validateConfig (XF86ConfigPtr p)
{
if (!xf86validateScreen (p))
return FALSE;
2007-03-25 12:27:01 -04:00
if (!xf86validateInput (p))
return FALSE;
if (!xf86validateLayout (p))
return FALSE;
return (TRUE);
}
Export symbols defined in the sdk. This is the biggest "visibility" patch. Instead of doing a "export" symbol on demand, export everything in the sdk, so that if some module fails due to an unresolved symbol, it is because it is using a symbol not in the sdk. Most exported symbols shouldn't really be made visible, neither advertised in the sdk, as they are only used by a single shared object. Symbols in the sdk (or referenced in sdk macros), but not defined anywhere include: XkbBuildCoreState() XkbInitialMap XkbXIUnsupported XkbCheckActionVMods() XkbSendCompatNotify() XkbDDXFakePointerButton() XkbDDXApplyConfig() _XkbStrCaseCmp() _XkbErrMessages[] _XkbErrCode _XkbErrLocation _XkbErrData XkbAccessXDetailText() XkbNKNDetailMaskText() XkbLookupGroupAndLevel() XkbInitAtoms() XkbGetOrderedDrawables() XkbFreeOrderedDrawables() XkbConvertXkbComponents() XkbWriteXKBSemantics() XkbWriteXKBLayout() XkbWriteXKBKeymap() XkbWriteXKBFile() XkbWriteCFile() XkbWriteXKMFile() XkbWriteToServer() XkbMergeFile() XkmFindTOCEntry() XkmReadFileSection() XkmReadFileSectionName() InitExtInput() xf86CheckButton() xf86SwitchCoreDevice() RamDacSetGamma() RamDacRestoreDACValues() xf86Bpp xf86ConfigPix24 xf86MouseCflags[] xf86SupportedMouseTypes[] xf86NumMouseTypes xf86ChangeBusIndex() xf86EntityEnter() xf86EntityLeave() xf86WrapperInit() xf86RingBell() xf86findOptionBoolean() xf86debugListOptions() LoadSubModuleLocal() LoaderSymbolLocal() getInt10Rec() xf86CurrentScreen xf86ReallocatePciResources() xf86NewSerialNumber() xf86RandRSetInitialMode() fbCompositeSolidMask_nx1xn fbCompositeSolidMask_nx8888x0565C fbCompositeSolidMask_nx8888x8888C fbCompositeSolidMask_nx8x0565 fbCompositeSolidMask_nx8x0888 fbCompositeSolidMask_nx8x8888 fbCompositeSrc_0565x0565 fbCompositeSrc_8888x0565 fbCompositeSrc_8888x0888 fbCompositeSrc_8888x8888 fbCompositeSrcAdd_1000x1000 fbCompositeSrcAdd_8000x8000 fbCompositeSrcAdd_8888x8888 fbGeneration fbIn fbOver fbOver24 fbOverlayGeneration fbRasterizeEdges fbRestoreAreas fbSaveAreas composeFunctions VBEBuildVbeModeList() VBECalcVbeModeIndex() TIramdac3030CalculateMNPForClock() shadowBufPtr shadowFindBuf() miRRGetScreenInfo() RRSetScreenConfig() RRModePruneUnused() PixmanImageFromPicture() extern int miPointerGetMotionEvents() miClipPicture() miRasterizeTriangle() fbPush1toN() fbInitializeBackingStore() ddxBeforeReset() SetupSprite() InitSprite() DGADeliverEvent() SPECIAL CASES o defined as _X_INTERNAL xf86NewInputDevice() o defined as static fbGCPrivateKey fbOverlayScreenPrivateKey fbScreenPrivateKey fbWinPrivateKey o defined in libXfont.so, but declared in xorg/dixfont.h GetGlyphs() QueryGlyphExtents() QueryTextExtents() ParseGlyphCachingMode() InitGlyphCaching() SetGlyphCachingMode()
2008-11-29 23:56:06 -02:00
_X_EXPORT XF86ConfigPtr
2003-11-14 16:48:57 +00:00
xf86readConfigFile (void)
{
int token;
XF86ConfigPtr ptr = NULL;
if ((ptr = xf86confcalloc (1, sizeof (XF86ConfigRec))) == NULL)
{
return NULL;
}
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, "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 ());
}
2003-11-14 16:48:57 +00:00
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
/*
* 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.
*/
Export symbols defined in the sdk. This is the biggest "visibility" patch. Instead of doing a "export" symbol on demand, export everything in the sdk, so that if some module fails due to an unresolved symbol, it is because it is using a symbol not in the sdk. Most exported symbols shouldn't really be made visible, neither advertised in the sdk, as they are only used by a single shared object. Symbols in the sdk (or referenced in sdk macros), but not defined anywhere include: XkbBuildCoreState() XkbInitialMap XkbXIUnsupported XkbCheckActionVMods() XkbSendCompatNotify() XkbDDXFakePointerButton() XkbDDXApplyConfig() _XkbStrCaseCmp() _XkbErrMessages[] _XkbErrCode _XkbErrLocation _XkbErrData XkbAccessXDetailText() XkbNKNDetailMaskText() XkbLookupGroupAndLevel() XkbInitAtoms() XkbGetOrderedDrawables() XkbFreeOrderedDrawables() XkbConvertXkbComponents() XkbWriteXKBSemantics() XkbWriteXKBLayout() XkbWriteXKBKeymap() XkbWriteXKBFile() XkbWriteCFile() XkbWriteXKMFile() XkbWriteToServer() XkbMergeFile() XkmFindTOCEntry() XkmReadFileSection() XkmReadFileSectionName() InitExtInput() xf86CheckButton() xf86SwitchCoreDevice() RamDacSetGamma() RamDacRestoreDACValues() xf86Bpp xf86ConfigPix24 xf86MouseCflags[] xf86SupportedMouseTypes[] xf86NumMouseTypes xf86ChangeBusIndex() xf86EntityEnter() xf86EntityLeave() xf86WrapperInit() xf86RingBell() xf86findOptionBoolean() xf86debugListOptions() LoadSubModuleLocal() LoaderSymbolLocal() getInt10Rec() xf86CurrentScreen xf86ReallocatePciResources() xf86NewSerialNumber() xf86RandRSetInitialMode() fbCompositeSolidMask_nx1xn fbCompositeSolidMask_nx8888x0565C fbCompositeSolidMask_nx8888x8888C fbCompositeSolidMask_nx8x0565 fbCompositeSolidMask_nx8x0888 fbCompositeSolidMask_nx8x8888 fbCompositeSrc_0565x0565 fbCompositeSrc_8888x0565 fbCompositeSrc_8888x0888 fbCompositeSrc_8888x8888 fbCompositeSrcAdd_1000x1000 fbCompositeSrcAdd_8000x8000 fbCompositeSrcAdd_8888x8888 fbGeneration fbIn fbOver fbOver24 fbOverlayGeneration fbRasterizeEdges fbRestoreAreas fbSaveAreas composeFunctions VBEBuildVbeModeList() VBECalcVbeModeIndex() TIramdac3030CalculateMNPForClock() shadowBufPtr shadowFindBuf() miRRGetScreenInfo() RRSetScreenConfig() RRModePruneUnused() PixmanImageFromPicture() extern int miPointerGetMotionEvents() miClipPicture() miRasterizeTriangle() fbPush1toN() fbInitializeBackingStore() ddxBeforeReset() SetupSprite() InitSprite() DGADeliverEvent() SPECIAL CASES o defined as _X_INTERNAL xf86NewInputDevice() o defined as static fbGCPrivateKey fbOverlayScreenPrivateKey fbScreenPrivateKey fbWinPrivateKey o defined in libXfont.so, but declared in xorg/dixfont.h GetGlyphs() QueryGlyphExtents() QueryTextExtents() ParseGlyphCachingMode() InitGlyphCaching() SetGlyphCachingMode()
2008-11-29 23:56:06 -02:00
_X_EXPORT GenericListPtr
2003-11-14 16:48:57 +00:00
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)
*/
Export symbols defined in the sdk. This is the biggest "visibility" patch. Instead of doing a "export" symbol on demand, export everything in the sdk, so that if some module fails due to an unresolved symbol, it is because it is using a symbol not in the sdk. Most exported symbols shouldn't really be made visible, neither advertised in the sdk, as they are only used by a single shared object. Symbols in the sdk (or referenced in sdk macros), but not defined anywhere include: XkbBuildCoreState() XkbInitialMap XkbXIUnsupported XkbCheckActionVMods() XkbSendCompatNotify() XkbDDXFakePointerButton() XkbDDXApplyConfig() _XkbStrCaseCmp() _XkbErrMessages[] _XkbErrCode _XkbErrLocation _XkbErrData XkbAccessXDetailText() XkbNKNDetailMaskText() XkbLookupGroupAndLevel() XkbInitAtoms() XkbGetOrderedDrawables() XkbFreeOrderedDrawables() XkbConvertXkbComponents() XkbWriteXKBSemantics() XkbWriteXKBLayout() XkbWriteXKBKeymap() XkbWriteXKBFile() XkbWriteCFile() XkbWriteXKMFile() XkbWriteToServer() XkbMergeFile() XkmFindTOCEntry() XkmReadFileSection() XkmReadFileSectionName() InitExtInput() xf86CheckButton() xf86SwitchCoreDevice() RamDacSetGamma() RamDacRestoreDACValues() xf86Bpp xf86ConfigPix24 xf86MouseCflags[] xf86SupportedMouseTypes[] xf86NumMouseTypes xf86ChangeBusIndex() xf86EntityEnter() xf86EntityLeave() xf86WrapperInit() xf86RingBell() xf86findOptionBoolean() xf86debugListOptions() LoadSubModuleLocal() LoaderSymbolLocal() getInt10Rec() xf86CurrentScreen xf86ReallocatePciResources() xf86NewSerialNumber() xf86RandRSetInitialMode() fbCompositeSolidMask_nx1xn fbCompositeSolidMask_nx8888x0565C fbCompositeSolidMask_nx8888x8888C fbCompositeSolidMask_nx8x0565 fbCompositeSolidMask_nx8x0888 fbCompositeSolidMask_nx8x8888 fbCompositeSrc_0565x0565 fbCompositeSrc_8888x0565 fbCompositeSrc_8888x0888 fbCompositeSrc_8888x8888 fbCompositeSrcAdd_1000x1000 fbCompositeSrcAdd_8000x8000 fbCompositeSrcAdd_8888x8888 fbGeneration fbIn fbOver fbOver24 fbOverlayGeneration fbRasterizeEdges fbRestoreAreas fbSaveAreas composeFunctions VBEBuildVbeModeList() VBECalcVbeModeIndex() TIramdac3030CalculateMNPForClock() shadowBufPtr shadowFindBuf() miRRGetScreenInfo() RRSetScreenConfig() RRModePruneUnused() PixmanImageFromPicture() extern int miPointerGetMotionEvents() miClipPicture() miRasterizeTriangle() fbPush1toN() fbInitializeBackingStore() ddxBeforeReset() SetupSprite() InitSprite() DGADeliverEvent() SPECIAL CASES o defined as _X_INTERNAL xf86NewInputDevice() o defined as static fbGCPrivateKey fbOverlayScreenPrivateKey fbScreenPrivateKey fbWinPrivateKey o defined in libXfont.so, but declared in xorg/dixfont.h GetGlyphs() QueryGlyphExtents() QueryTextExtents() ParseGlyphCachingMode() InitGlyphCaching() SetGlyphCachingMode()
2008-11-29 23:56:06 -02:00
_X_EXPORT int
2003-11-14 16:48:57 +00:00
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));
}
Export symbols defined in the sdk. This is the biggest "visibility" patch. Instead of doing a "export" symbol on demand, export everything in the sdk, so that if some module fails due to an unresolved symbol, it is because it is using a symbol not in the sdk. Most exported symbols shouldn't really be made visible, neither advertised in the sdk, as they are only used by a single shared object. Symbols in the sdk (or referenced in sdk macros), but not defined anywhere include: XkbBuildCoreState() XkbInitialMap XkbXIUnsupported XkbCheckActionVMods() XkbSendCompatNotify() XkbDDXFakePointerButton() XkbDDXApplyConfig() _XkbStrCaseCmp() _XkbErrMessages[] _XkbErrCode _XkbErrLocation _XkbErrData XkbAccessXDetailText() XkbNKNDetailMaskText() XkbLookupGroupAndLevel() XkbInitAtoms() XkbGetOrderedDrawables() XkbFreeOrderedDrawables() XkbConvertXkbComponents() XkbWriteXKBSemantics() XkbWriteXKBLayout() XkbWriteXKBKeymap() XkbWriteXKBFile() XkbWriteCFile() XkbWriteXKMFile() XkbWriteToServer() XkbMergeFile() XkmFindTOCEntry() XkmReadFileSection() XkmReadFileSectionName() InitExtInput() xf86CheckButton() xf86SwitchCoreDevice() RamDacSetGamma() RamDacRestoreDACValues() xf86Bpp xf86ConfigPix24 xf86MouseCflags[] xf86SupportedMouseTypes[] xf86NumMouseTypes xf86ChangeBusIndex() xf86EntityEnter() xf86EntityLeave() xf86WrapperInit() xf86RingBell() xf86findOptionBoolean() xf86debugListOptions() LoadSubModuleLocal() LoaderSymbolLocal() getInt10Rec() xf86CurrentScreen xf86ReallocatePciResources() xf86NewSerialNumber() xf86RandRSetInitialMode() fbCompositeSolidMask_nx1xn fbCompositeSolidMask_nx8888x0565C fbCompositeSolidMask_nx8888x8888C fbCompositeSolidMask_nx8x0565 fbCompositeSolidMask_nx8x0888 fbCompositeSolidMask_nx8x8888 fbCompositeSrc_0565x0565 fbCompositeSrc_8888x0565 fbCompositeSrc_8888x0888 fbCompositeSrc_8888x8888 fbCompositeSrcAdd_1000x1000 fbCompositeSrcAdd_8000x8000 fbCompositeSrcAdd_8888x8888 fbGeneration fbIn fbOver fbOver24 fbOverlayGeneration fbRasterizeEdges fbRestoreAreas fbSaveAreas composeFunctions VBEBuildVbeModeList() VBECalcVbeModeIndex() TIramdac3030CalculateMNPForClock() shadowBufPtr shadowFindBuf() miRRGetScreenInfo() RRSetScreenConfig() RRModePruneUnused() PixmanImageFromPicture() extern int miPointerGetMotionEvents() miClipPicture() miRasterizeTriangle() fbPush1toN() fbInitializeBackingStore() ddxBeforeReset() SetupSprite() InitSprite() DGADeliverEvent() SPECIAL CASES o defined as _X_INTERNAL xf86NewInputDevice() o defined as static fbGCPrivateKey fbOverlayScreenPrivateKey fbScreenPrivateKey fbWinPrivateKey o defined in libXfont.so, but declared in xorg/dixfont.h GetGlyphs() QueryGlyphExtents() QueryTextExtents() ParseGlyphCachingMode() InitGlyphCaching() SetGlyphCachingMode()
2008-11-29 23:56:06 -02:00
_X_EXPORT void
2003-11-14 16:48:57 +00:00
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);
2003-11-14 16:48:57 +00:00
TestFree(p->conf_comment);
xf86conffree (p);
}