2003-11-14 17:48:57 +01: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.
|
|
|
|
*
|
|
|
|
*/
|
2003-11-25 20:29:01 +01:00
|
|
|
/*
|
|
|
|
* 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).
|
|
|
|
*/
|
|
|
|
|
2005-07-03 09:02:09 +02:00
|
|
|
#ifdef HAVE_XORG_CONFIG_H
|
|
|
|
#include <xorg-config.h>
|
|
|
|
#endif
|
|
|
|
|
2003-11-14 17:48:57 +01:00
|
|
|
#include "xf86Parser.h"
|
|
|
|
#include "xf86tokens.h"
|
|
|
|
#include "Configint.h"
|
|
|
|
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
static xf86ConfigSymTabRec TopLevelTab[] = {
|
|
|
|
{SECTION, "section"},
|
|
|
|
{-1, ""},
|
2003-11-14 17:48:57 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#define CLEANUP xf86freeConfig
|
|
|
|
|
2007-03-25 18:27:01 +02:00
|
|
|
/*
|
|
|
|
* This function resolves name references and reports errors if the named
|
|
|
|
* objects cannot be found.
|
|
|
|
*/
|
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86validateConfig(XF86ConfigPtr p)
|
2007-03-25 18:27:01 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!xf86validateScreen(p))
|
|
|
|
return FALSE;
|
|
|
|
if (!xf86validateInput(p))
|
|
|
|
return FALSE;
|
|
|
|
if (!xf86validateLayout(p))
|
|
|
|
return FALSE;
|
2007-03-25 18:27:01 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
return TRUE;
|
2007-03-25 18:27:01 +02:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
XF86ConfigPtr
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86readConfigFile(void)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
int token;
|
|
|
|
XF86ConfigPtr ptr = NULL;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if ((ptr = calloc(1, sizeof(XF86ConfigRec))) == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
while ((token = xf86getToken(TopLevelTab)) != EOF_TOKEN) {
|
|
|
|
switch (token) {
|
|
|
|
case COMMENT:
|
2013-12-15 10:41:19 +01:00
|
|
|
ptr->conf_comment = xf86addComment(ptr->conf_comment, xf86_lex_val.str);
|
2012-03-21 20:55:09 +01:00
|
|
|
break;
|
|
|
|
case SECTION:
|
|
|
|
if (xf86getSubToken(&(ptr->conf_comment)) != STRING) {
|
|
|
|
xf86parseError(QUOTE_MSG, "Section");
|
|
|
|
CLEANUP(ptr);
|
|
|
|
return NULL;
|
|
|
|
}
|
2013-12-15 10:41:19 +01:00
|
|
|
xf86setSection(xf86_lex_val.str);
|
|
|
|
if (xf86nameCompare(xf86_lex_val.str, "files") == 0) {
|
|
|
|
free(xf86_lex_val.str);
|
|
|
|
xf86_lex_val.str = NULL;
|
2012-03-21 20:55:09 +01:00
|
|
|
HANDLE_RETURN(conf_files, xf86parseFilesSection());
|
|
|
|
}
|
2013-12-15 10:41:19 +01:00
|
|
|
else if (xf86nameCompare(xf86_lex_val.str, "serverflags") == 0) {
|
|
|
|
free(xf86_lex_val.str);
|
|
|
|
xf86_lex_val.str = NULL;
|
2012-03-21 20:55:09 +01:00
|
|
|
HANDLE_RETURN(conf_flags, xf86parseFlagsSection());
|
|
|
|
}
|
2013-12-15 10:41:19 +01:00
|
|
|
else if (xf86nameCompare(xf86_lex_val.str, "pointer") == 0) {
|
|
|
|
free(xf86_lex_val.str);
|
|
|
|
xf86_lex_val.str = NULL;
|
2012-03-21 20:55:09 +01:00
|
|
|
HANDLE_LIST(conf_input_lst, xf86parsePointerSection,
|
|
|
|
XF86ConfInputPtr);
|
|
|
|
}
|
2013-12-15 10:41:19 +01:00
|
|
|
else if (xf86nameCompare(xf86_lex_val.str, "videoadaptor") == 0) {
|
|
|
|
free(xf86_lex_val.str);
|
|
|
|
xf86_lex_val.str = NULL;
|
2012-03-21 20:55:09 +01:00
|
|
|
HANDLE_LIST(conf_videoadaptor_lst, xf86parseVideoAdaptorSection,
|
|
|
|
XF86ConfVideoAdaptorPtr);
|
|
|
|
}
|
2013-12-15 10:41:19 +01:00
|
|
|
else if (xf86nameCompare(xf86_lex_val.str, "device") == 0) {
|
|
|
|
free(xf86_lex_val.str);
|
|
|
|
xf86_lex_val.str = NULL;
|
2012-03-21 20:55:09 +01:00
|
|
|
HANDLE_LIST(conf_device_lst, xf86parseDeviceSection,
|
|
|
|
XF86ConfDevicePtr);
|
|
|
|
}
|
2013-12-15 10:41:19 +01:00
|
|
|
else if (xf86nameCompare(xf86_lex_val.str, "monitor") == 0) {
|
|
|
|
free(xf86_lex_val.str);
|
|
|
|
xf86_lex_val.str = NULL;
|
2012-03-21 20:55:09 +01:00
|
|
|
HANDLE_LIST(conf_monitor_lst, xf86parseMonitorSection,
|
|
|
|
XF86ConfMonitorPtr);
|
|
|
|
}
|
2013-12-15 10:41:19 +01:00
|
|
|
else if (xf86nameCompare(xf86_lex_val.str, "modes") == 0) {
|
|
|
|
free(xf86_lex_val.str);
|
|
|
|
xf86_lex_val.str = NULL;
|
2012-03-21 20:55:09 +01:00
|
|
|
HANDLE_LIST(conf_modes_lst, xf86parseModesSection,
|
|
|
|
XF86ConfModesPtr);
|
|
|
|
}
|
2013-12-15 10:41:19 +01:00
|
|
|
else if (xf86nameCompare(xf86_lex_val.str, "screen") == 0) {
|
|
|
|
free(xf86_lex_val.str);
|
|
|
|
xf86_lex_val.str = NULL;
|
2012-03-21 20:55:09 +01:00
|
|
|
HANDLE_LIST(conf_screen_lst, xf86parseScreenSection,
|
|
|
|
XF86ConfScreenPtr);
|
|
|
|
}
|
2013-12-15 10:41:19 +01:00
|
|
|
else if (xf86nameCompare(xf86_lex_val.str, "inputdevice") == 0) {
|
|
|
|
free(xf86_lex_val.str);
|
|
|
|
xf86_lex_val.str = NULL;
|
2012-03-21 20:55:09 +01:00
|
|
|
HANDLE_LIST(conf_input_lst, xf86parseInputSection,
|
|
|
|
XF86ConfInputPtr);
|
|
|
|
}
|
2013-12-15 10:41:19 +01:00
|
|
|
else if (xf86nameCompare(xf86_lex_val.str, "inputclass") == 0) {
|
|
|
|
free(xf86_lex_val.str);
|
|
|
|
xf86_lex_val.str = NULL;
|
2012-03-21 20:55:09 +01:00
|
|
|
HANDLE_LIST(conf_inputclass_lst,
|
|
|
|
xf86parseInputClassSection, XF86ConfInputClassPtr);
|
|
|
|
}
|
2013-12-15 10:41:19 +01:00
|
|
|
else if (xf86nameCompare(xf86_lex_val.str, "module") == 0) {
|
|
|
|
free(xf86_lex_val.str);
|
|
|
|
xf86_lex_val.str = NULL;
|
2012-03-21 20:55:09 +01:00
|
|
|
HANDLE_RETURN(conf_modules, xf86parseModuleSection());
|
|
|
|
}
|
2013-12-15 10:41:19 +01:00
|
|
|
else if (xf86nameCompare(xf86_lex_val.str, "serverlayout") == 0) {
|
|
|
|
free(xf86_lex_val.str);
|
|
|
|
xf86_lex_val.str = NULL;
|
2012-03-21 20:55:09 +01:00
|
|
|
HANDLE_LIST(conf_layout_lst, xf86parseLayoutSection,
|
|
|
|
XF86ConfLayoutPtr);
|
|
|
|
}
|
2013-12-15 10:41:19 +01:00
|
|
|
else if (xf86nameCompare(xf86_lex_val.str, "vendor") == 0) {
|
|
|
|
free(xf86_lex_val.str);
|
|
|
|
xf86_lex_val.str = NULL;
|
2012-03-21 20:55:09 +01:00
|
|
|
HANDLE_LIST(conf_vendor_lst, xf86parseVendorSection,
|
|
|
|
XF86ConfVendorPtr);
|
|
|
|
}
|
2013-12-15 10:41:19 +01:00
|
|
|
else if (xf86nameCompare(xf86_lex_val.str, "dri") == 0) {
|
|
|
|
free(xf86_lex_val.str);
|
|
|
|
xf86_lex_val.str = NULL;
|
2012-03-21 20:55:09 +01:00
|
|
|
HANDLE_RETURN(conf_dri, xf86parseDRISection());
|
|
|
|
}
|
2013-12-15 10:41:19 +01:00
|
|
|
else if (xf86nameCompare(xf86_lex_val.str, "extensions") == 0) {
|
|
|
|
free(xf86_lex_val.str);
|
|
|
|
xf86_lex_val.str = NULL;
|
2012-03-21 20:55:09 +01:00
|
|
|
HANDLE_RETURN(conf_extensions, xf86parseExtensionsSection());
|
|
|
|
}
|
|
|
|
else {
|
2013-12-15 10:41:19 +01:00
|
|
|
free(xf86_lex_val.str);
|
|
|
|
xf86_lex_val.str = NULL;
|
2012-03-21 20:55:09 +01:00
|
|
|
Error(INVALID_SECTION_MSG, xf86tokenString());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2013-12-15 10:41:19 +01:00
|
|
|
free(xf86_lex_val.str);
|
|
|
|
xf86_lex_val.str = NULL;
|
2012-03-21 20:55:09 +01:00
|
|
|
Error(INVALID_KEYWORD_MSG, xf86tokenString());
|
|
|
|
}
|
|
|
|
}
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (xf86validateConfig(ptr))
|
|
|
|
return ptr;
|
|
|
|
else {
|
|
|
|
CLEANUP(ptr);
|
|
|
|
return NULL;
|
|
|
|
}
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#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.
|
|
|
|
*/
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
GenericListPtr
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86addListItem(GenericListPtr head, GenericListPtr new)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
GenericListPtr p = head;
|
|
|
|
GenericListPtr last = NULL;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
while (p) {
|
|
|
|
last = p;
|
|
|
|
p = p->next;
|
|
|
|
}
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (last) {
|
|
|
|
last->next = new;
|
|
|
|
return head;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return new;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Test if one chained list contains the other.
|
|
|
|
* In this case both list have the same endpoint (provided they don't loop)
|
|
|
|
*/
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
int
|
2003-11-14 17:48:57 +01:00
|
|
|
xf86itemNotSublist(GenericListPtr list_1, GenericListPtr list_2)
|
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
GenericListPtr p = list_1;
|
|
|
|
GenericListPtr last_1 = NULL, last_2 = NULL;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
while (p) {
|
|
|
|
last_1 = p;
|
|
|
|
p = p->next;
|
|
|
|
}
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
p = list_2;
|
|
|
|
while (p) {
|
|
|
|
last_2 = p;
|
|
|
|
p = p->next;
|
|
|
|
}
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
return (!(last_1 == last_2));
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86freeConfig(XF86ConfigPtr p)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
if (p == NULL)
|
|
|
|
return;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
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);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
free(p);
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|