summaryrefslogtreecommitdiff
path: root/xserver/hw/xfree86/parser/read.c
diff options
context:
space:
mode:
Diffstat (limited to 'xserver/hw/xfree86/parser/read.c')
-rw-r--r--xserver/hw/xfree86/parser/read.c376
1 files changed, 175 insertions, 201 deletions
diff --git a/xserver/hw/xfree86/parser/read.c b/xserver/hw/xfree86/parser/read.c
index d4d525218..eef873e89 100644
--- a/xserver/hw/xfree86/parser/read.c
+++ b/xserver/hw/xfree86/parser/read.c
@@ -52,7 +52,6 @@
* authorization from the copyright holder(s) and author(s).
*/
-
/* View/edit this file with tab stops set to 4 */
#ifdef HAVE_XORG_CONFIG_H
@@ -65,10 +64,9 @@
extern LexRec val;
-static xf86ConfigSymTabRec TopLevelTab[] =
-{
- {SECTION, "section"},
- {-1, ""},
+static xf86ConfigSymTabRec TopLevelTab[] = {
+ {SECTION, "section"},
+ {-1, ""},
};
#define CLEANUP xf86freeConfig
@@ -78,166 +76,144 @@ static xf86ConfigSymTabRec TopLevelTab[] =
* objects cannot be found.
*/
static int
-xf86validateConfig (XF86ConfigPtr p)
+xf86validateConfig(XF86ConfigPtr p)
{
- if (!xf86validateScreen (p))
- return FALSE;
- if (!xf86validateInput (p))
- return FALSE;
- if (!xf86validateLayout (p))
- return FALSE;
+ if (!xf86validateScreen(p))
+ return FALSE;
+ if (!xf86validateInput(p))
+ return FALSE;
+ if (!xf86validateLayout(p))
+ return FALSE;
- return TRUE;
+ return TRUE;
}
XF86ConfigPtr
-xf86readConfigFile (void)
+xf86readConfigFile(void)
{
- int token;
- XF86ConfigPtr ptr = NULL;
+ int token;
+ XF86ConfigPtr ptr = NULL;
- if ((ptr = calloc (1, sizeof (XF86ConfigRec))) == NULL)
- {
- return NULL;
- }
+ if ((ptr = calloc(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)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_RETURN (conf_files, xf86parseFilesSection ());
- }
- else if (xf86nameCompare (val.str, "serverflags") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_RETURN (conf_flags, xf86parseFlagsSection ());
- }
- else if (xf86nameCompare (val.str, "pointer") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_LIST (conf_input_lst, xf86parsePointerSection,
- XF86ConfInputPtr);
- }
- else if (xf86nameCompare (val.str, "videoadaptor") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_LIST (conf_videoadaptor_lst, xf86parseVideoAdaptorSection,
- XF86ConfVideoAdaptorPtr);
- }
- else if (xf86nameCompare (val.str, "device") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_LIST (conf_device_lst, xf86parseDeviceSection,
- XF86ConfDevicePtr);
- }
- else if (xf86nameCompare (val.str, "monitor") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_LIST (conf_monitor_lst, xf86parseMonitorSection,
- XF86ConfMonitorPtr);
- }
- else if (xf86nameCompare (val.str, "modes") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_LIST (conf_modes_lst, xf86parseModesSection,
- XF86ConfModesPtr);
- }
- else if (xf86nameCompare (val.str, "screen") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_LIST (conf_screen_lst, xf86parseScreenSection,
- XF86ConfScreenPtr);
- }
- else if (xf86nameCompare(val.str, "inputdevice") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_LIST (conf_input_lst, xf86parseInputSection,
- XF86ConfInputPtr);
- }
- else if (xf86nameCompare(val.str, "inputclass") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_LIST (conf_inputclass_lst,
- xf86parseInputClassSection,
- XF86ConfInputClassPtr);
- }
- else if (xf86nameCompare (val.str, "module") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_RETURN (conf_modules, xf86parseModuleSection ());
- }
- else if (xf86nameCompare (val.str, "serverlayout") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_LIST (conf_layout_lst, xf86parseLayoutSection,
- XF86ConfLayoutPtr);
- }
- else if (xf86nameCompare (val.str, "vendor") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_LIST (conf_vendor_lst, xf86parseVendorSection,
- XF86ConfVendorPtr);
- }
- else if (xf86nameCompare (val.str, "dri") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_RETURN (conf_dri, xf86parseDRISection ());
- }
- else if (xf86nameCompare (val.str, "extensions") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_RETURN (conf_extensions, xf86parseExtensionsSection ());
- }
- else
- {
- free(val.str);
- val.str = NULL;
- Error (INVALID_SECTION_MSG, xf86tokenString ());
- }
- break;
- default:
- free(val.str);
- val.str = NULL;
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- }
- }
+ 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) {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_RETURN(conf_files, xf86parseFilesSection());
+ }
+ else if (xf86nameCompare(val.str, "serverflags") == 0) {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_RETURN(conf_flags, xf86parseFlagsSection());
+ }
+ else if (xf86nameCompare(val.str, "pointer") == 0) {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST(conf_input_lst, xf86parsePointerSection,
+ XF86ConfInputPtr);
+ }
+ else if (xf86nameCompare(val.str, "videoadaptor") == 0) {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST(conf_videoadaptor_lst, xf86parseVideoAdaptorSection,
+ XF86ConfVideoAdaptorPtr);
+ }
+ else if (xf86nameCompare(val.str, "device") == 0) {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST(conf_device_lst, xf86parseDeviceSection,
+ XF86ConfDevicePtr);
+ }
+ else if (xf86nameCompare(val.str, "monitor") == 0) {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST(conf_monitor_lst, xf86parseMonitorSection,
+ XF86ConfMonitorPtr);
+ }
+ else if (xf86nameCompare(val.str, "modes") == 0) {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST(conf_modes_lst, xf86parseModesSection,
+ XF86ConfModesPtr);
+ }
+ else if (xf86nameCompare(val.str, "screen") == 0) {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST(conf_screen_lst, xf86parseScreenSection,
+ XF86ConfScreenPtr);
+ }
+ else if (xf86nameCompare(val.str, "inputdevice") == 0) {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST(conf_input_lst, xf86parseInputSection,
+ XF86ConfInputPtr);
+ }
+ else if (xf86nameCompare(val.str, "inputclass") == 0) {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST(conf_inputclass_lst,
+ xf86parseInputClassSection, XF86ConfInputClassPtr);
+ }
+ else if (xf86nameCompare(val.str, "module") == 0) {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_RETURN(conf_modules, xf86parseModuleSection());
+ }
+ else if (xf86nameCompare(val.str, "serverlayout") == 0) {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST(conf_layout_lst, xf86parseLayoutSection,
+ XF86ConfLayoutPtr);
+ }
+ else if (xf86nameCompare(val.str, "vendor") == 0) {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST(conf_vendor_lst, xf86parseVendorSection,
+ XF86ConfVendorPtr);
+ }
+ else if (xf86nameCompare(val.str, "dri") == 0) {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_RETURN(conf_dri, xf86parseDRISection());
+ }
+ else if (xf86nameCompare(val.str, "extensions") == 0) {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_RETURN(conf_extensions, xf86parseExtensionsSection());
+ }
+ else {
+ free(val.str);
+ val.str = NULL;
+ Error(INVALID_SECTION_MSG, xf86tokenString());
+ }
+ break;
+ default:
+ free(val.str);
+ val.str = NULL;
+ Error(INVALID_KEYWORD_MSG, xf86tokenString());
+ }
+ }
- if (xf86validateConfig (ptr))
- return ptr;
- else
- {
- CLEANUP (ptr);
- return NULL;
- }
+ if (xf86validateConfig(ptr))
+ return ptr;
+ else {
+ CLEANUP(ptr);
+ return NULL;
+ }
}
#undef CLEANUP
@@ -249,24 +225,22 @@ xf86readConfigFile (void)
* the first item.
*/
GenericListPtr
-xf86addListItem (GenericListPtr head, GenericListPtr new)
+xf86addListItem(GenericListPtr head, GenericListPtr new)
{
- GenericListPtr p = head;
- GenericListPtr last = NULL;
+ GenericListPtr p = head;
+ GenericListPtr last = NULL;
- while (p)
- {
- last = p;
- p = p->next;
- }
+ while (p) {
+ last = p;
+ p = p->next;
+ }
- if (last)
- {
- last->next = new;
- return head;
- }
- else
- return new;
+ if (last) {
+ last->next = new;
+ return head;
+ }
+ else
+ return new;
}
/*
@@ -276,43 +250,43 @@ xf86addListItem (GenericListPtr head, GenericListPtr new)
int
xf86itemNotSublist(GenericListPtr list_1, GenericListPtr list_2)
{
- GenericListPtr p = list_1;
- GenericListPtr last_1 = NULL, last_2 = NULL;
+ GenericListPtr p = list_1;
+ GenericListPtr last_1 = NULL, last_2 = NULL;
- while (p) {
- last_1 = p;
- p = p->next;
- }
+ while (p) {
+ last_1 = p;
+ p = p->next;
+ }
- p = list_2;
- while (p) {
- last_2 = p;
- p = p->next;
- }
+ p = list_2;
+ while (p) {
+ last_2 = p;
+ p = p->next;
+ }
- return (!(last_1 == last_2));
+ return (!(last_1 == last_2));
}
void
-xf86freeConfig (XF86ConfigPtr p)
+xf86freeConfig(XF86ConfigPtr p)
{
- if (p == NULL)
- return;
+ 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);
+ 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);
- free (p);
+ free(p);
}