105b261ecSmrg/* 205b261ecSmrg * Copyright 2004 Red Hat Inc., Raleigh, North Carolina. 305b261ecSmrg * 405b261ecSmrg * All Rights Reserved. 505b261ecSmrg * 605b261ecSmrg * Permission is hereby granted, free of charge, to any person obtaining 705b261ecSmrg * a copy of this software and associated documentation files (the 805b261ecSmrg * "Software"), to deal in the Software without restriction, including 905b261ecSmrg * without limitation on the rights to use, copy, modify, merge, 1005b261ecSmrg * publish, distribute, sublicense, and/or sell copies of the Software, 1105b261ecSmrg * and to permit persons to whom the Software is furnished to do so, 1205b261ecSmrg * subject to the following conditions: 1305b261ecSmrg * 1405b261ecSmrg * The above copyright notice and this permission notice (including the 1505b261ecSmrg * next paragraph) shall be included in all copies or substantial 1605b261ecSmrg * portions of the Software. 1705b261ecSmrg * 1805b261ecSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 1905b261ecSmrg * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 2005b261ecSmrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 2105b261ecSmrg * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS 2205b261ecSmrg * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 2305b261ecSmrg * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 2405b261ecSmrg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 2505b261ecSmrg * SOFTWARE. 2605b261ecSmrg */ 2705b261ecSmrg 2805b261ecSmrg/* 2905b261ecSmrg * Authors: 3005b261ecSmrg * Kevin E. Martin <kem@redhat.com> 3105b261ecSmrg * 3205b261ecSmrg */ 3305b261ecSmrg 3405b261ecSmrg#ifdef HAVE_XORG_CONFIG_H 3505b261ecSmrg#include <xorg-config.h> 3605b261ecSmrg#endif 3705b261ecSmrg 3835c4bbdfSmrg#include "os.h" 3905b261ecSmrg#include "xf86Parser.h" 4005b261ecSmrg#include "xf86tokens.h" 4105b261ecSmrg#include "Configint.h" 4205b261ecSmrg 4305b261ecSmrg 441b5d61b8Smrgstatic const xf86ConfigSymTabRec ExtensionsTab[] = { 4505b261ecSmrg {ENDSECTION, "endsection"}, 4635c4bbdfSmrg {OPTION, "option"}, 4735c4bbdfSmrg {-1, ""}, 4805b261ecSmrg}; 4905b261ecSmrg 5005b261ecSmrg#define CLEANUP xf86freeExtensions 5105b261ecSmrg 5205b261ecSmrgXF86ConfExtensionsPtr 5335c4bbdfSmrgxf86parseExtensionsSection(void) 5405b261ecSmrg{ 5505b261ecSmrg int token; 5635c4bbdfSmrg 5735c4bbdfSmrg parsePrologue(XF86ConfExtensionsPtr, XF86ConfExtensionsRec); 5835c4bbdfSmrg 5935c4bbdfSmrg while ((token = xf86getToken(ExtensionsTab)) != ENDSECTION) { 6035c4bbdfSmrg switch (token) { 6135c4bbdfSmrg case OPTION: 6235c4bbdfSmrg ptr->ext_option_lst = xf86parseOption(ptr->ext_option_lst); 6335c4bbdfSmrg break; 6435c4bbdfSmrg case EOF_TOKEN: 6535c4bbdfSmrg Error(UNEXPECTED_EOF_MSG); 6635c4bbdfSmrg break; 6735c4bbdfSmrg case COMMENT: 6835c4bbdfSmrg ptr->extensions_comment = 6935c4bbdfSmrg xf86addComment(ptr->extensions_comment, xf86_lex_val.str); 7058cf2af7Smrg free(xf86_lex_val.str); 7158cf2af7Smrg xf86_lex_val.str = NULL; 7235c4bbdfSmrg break; 7335c4bbdfSmrg default: 7435c4bbdfSmrg Error(INVALID_KEYWORD_MSG, xf86tokenString()); 7535c4bbdfSmrg break; 7635c4bbdfSmrg } 7705b261ecSmrg } 7805b261ecSmrg 7905b261ecSmrg#ifdef DEBUG 8005b261ecSmrg ErrorF("Extensions section parsed\n"); 8105b261ecSmrg#endif 8205b261ecSmrg 8305b261ecSmrg return ptr; 8405b261ecSmrg} 8505b261ecSmrg 8605b261ecSmrg#undef CLEANUP 8705b261ecSmrg 8805b261ecSmrgvoid 8935c4bbdfSmrgxf86printExtensionsSection(FILE * cf, XF86ConfExtensionsPtr ptr) 9005b261ecSmrg{ 9105b261ecSmrg XF86OptionPtr p; 9205b261ecSmrg 9305b261ecSmrg if (ptr == NULL || ptr->ext_option_lst == NULL) 9435c4bbdfSmrg return; 9505b261ecSmrg 9605b261ecSmrg p = ptr->ext_option_lst; 9735c4bbdfSmrg fprintf(cf, "Section \"Extensions\"\n"); 9805b261ecSmrg if (ptr->extensions_comment) 9935c4bbdfSmrg fprintf(cf, "%s", ptr->extensions_comment); 10005b261ecSmrg xf86printOptionList(cf, p, 1); 10135c4bbdfSmrg fprintf(cf, "EndSection\n\n"); 10205b261ecSmrg} 10305b261ecSmrg 10405b261ecSmrgvoid 10535c4bbdfSmrgxf86freeExtensions(XF86ConfExtensionsPtr ptr) 10605b261ecSmrg{ 10705b261ecSmrg if (ptr == NULL) 10835c4bbdfSmrg return; 10905b261ecSmrg 11035c4bbdfSmrg xf86optionListFree(ptr->ext_option_lst); 11135c4bbdfSmrg TestFree(ptr->extensions_comment); 11235c4bbdfSmrg free(ptr); 11305b261ecSmrg} 114