1117N/A/*
1117N/A * Copyright 2004 Red Hat Inc., Raleigh, North Carolina.
1117N/A *
1117N/A * All Rights Reserved.
1117N/A *
1117N/A * Permission is hereby granted, free of charge, to any person obtaining
1117N/A * a copy of this software and associated documentation files (the
1117N/A * "Software"), to deal in the Software without restriction, including
1117N/A * without limitation on the rights to use, copy, modify, merge,
1117N/A * publish, distribute, sublicense, and/or sell copies of the Software,
1117N/A * and to permit persons to whom the Software is furnished to do so,
1117N/A * subject to the following conditions:
1117N/A *
1117N/A * The above copyright notice and this permission notice (including the
1117N/A * next paragraph) shall be included in all copies or substantial
1117N/A * portions of the Software.
1117N/A *
1117N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1117N/A * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1117N/A * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1117N/A * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
1117N/A * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
1117N/A * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1117N/A * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1117N/A * SOFTWARE.
1117N/A */
1117N/A
1117N/A/*
1117N/A * Authors:
1117N/A * Kevin E. Martin <kem@redhat.com>
1117N/A *
1117N/A */
1117N/A
1117N/A#ifdef HAVE_XORG_CONFIG_H
1117N/A#include <xorg-config.h>
1117N/A#endif
1117N/A
1117N/A#include "xf86Parser.h"
1117N/A#include "xf86tokens.h"
1117N/A#include "Configint.h"
1117N/A#include "fields.h" /* Config file output line fields */
1117N/A
1117N/Aextern LexRec val;
1117N/A
1117N/Astatic xf86ConfigSymTabRec ExtensionsTab[] =
1117N/A{
1117N/A {ENDSECTION, "endsection"},
1117N/A {OPTION, "option"},
1117N/A {-1, ""},
1117N/A};
1117N/A
1117N/A#define CLEANUP xf86freeExtensions
1117N/A
1117N/AXF86ConfExtensionsPtr
1117N/Axf86parseExtensionsSection (void)
1117N/A{
1117N/A int token;
1117N/A parsePrologue (XF86ConfExtensionsPtr, XF86ConfExtensionsRec);
1117N/A
1117N/A while ((token = xf86getToken (ExtensionsTab)) != ENDSECTION) {
1117N/A switch (token) {
1117N/A case OPTION:
1117N/A ptr->ext_option_lst = xf86parseOption(ptr->ext_option_lst);
1117N/A break;
1117N/A case EOF_TOKEN:
1117N/A Error (UNEXPECTED_EOF_MSG, NULL);
1117N/A break;
1117N/A case COMMENT:
1117N/A ptr->extensions_comment =
1117N/A xf86addComment(ptr->extensions_comment, val.str);
1117N/A break;
1117N/A default:
1117N/A Error (INVALID_KEYWORD_MSG, xf86tokenString ());
1117N/A break;
1117N/A }
1117N/A }
1117N/A
1117N/A#ifdef DEBUG
1117N/A ErrorF("Extensions section parsed\n");
1117N/A#endif
1117N/A
1117N/A return ptr;
1117N/A}
1117N/A
1117N/A#undef CLEANUP
1117N/A
1117N/Avoid
1117N/Axf86printExtensionsSection (FILE * cf, XF86ConfExtensionsPtr ptr)
1117N/A{
1117N/A XF86OptionPtr p;
1117N/A
1117N/A if (ptr == NULL || ptr->ext_option_lst == NULL)
1117N/A return;
1117N/A
1117N/A p = ptr->ext_option_lst;
1117N/A fprintf (cf, "Section \"Extensions\"\n");
1117N/A if (ptr->extensions_comment)
1117N/A fprintf (cf, "%s", ptr->extensions_comment);
1117N/A xf86printOptionList(cf, p, xf86whitespace_1);
1117N/A fprintf (cf, "EndSection\n\n");
1117N/A}
1117N/A
1117N/Avoid
1117N/Axf86freeExtensions (XF86ConfExtensionsPtr ptr)
1117N/A{
1117N/A if (ptr == NULL)
1117N/A return;
1117N/A
1117N/A xf86optionListFree (ptr->ext_option_lst);
1117N/A TestFree (ptr->extensions_comment);
1117N/A xf86conffree (ptr);
1117N/A}
1117N/A