1706f2543Smrg 2706f2543Smrg/* 3706f2543Smrg * Copyright (c) 1998-2003 by The XFree86 Project, Inc. 4706f2543Smrg * 5706f2543Smrg * Permission is hereby granted, free of charge, to any person obtaining a 6706f2543Smrg * copy of this software and associated documentation files (the "Software"), 7706f2543Smrg * to deal in the Software without restriction, including without limitation 8706f2543Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9706f2543Smrg * and/or sell copies of the Software, and to permit persons to whom the 10706f2543Smrg * Software is furnished to do so, subject to the following conditions: 11706f2543Smrg * 12706f2543Smrg * The above copyright notice and this permission notice shall be included in 13706f2543Smrg * all copies or substantial portions of the Software. 14706f2543Smrg * 15706f2543Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16706f2543Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17706f2543Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18706f2543Smrg * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 19706f2543Smrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 20706f2543Smrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 21706f2543Smrg * OTHER DEALINGS IN THE SOFTWARE. 22706f2543Smrg * 23706f2543Smrg * Except as contained in this notice, the name of the copyright holder(s) 24706f2543Smrg * and author(s) shall not be used in advertising or otherwise to promote 25706f2543Smrg * the sale, use or other dealings in this Software without prior written 26706f2543Smrg * authorization from the copyright holder(s) and author(s). 27706f2543Smrg */ 28706f2543Smrg 29706f2543Smrg/* Option handling things that ModuleSetup procs can use */ 30706f2543Smrg 31706f2543Smrg#ifndef _XF86_OPT_H_ 32706f2543Smrg#define _XF86_OPT_H_ 33706f2543Smrg 34706f2543Smrgtypedef struct { 35706f2543Smrg double freq; 36706f2543Smrg int units; 37706f2543Smrg} OptFrequency; 38706f2543Smrg 39706f2543Smrgtypedef union { 40706f2543Smrg unsigned long num; 41706f2543Smrg char * str; 42706f2543Smrg double realnum; 43706f2543Smrg Bool bool; 44706f2543Smrg OptFrequency freq; 45706f2543Smrg} ValueUnion; 46706f2543Smrg 47706f2543Smrgtypedef enum { 48706f2543Smrg OPTV_NONE = 0, 49706f2543Smrg OPTV_INTEGER, 50706f2543Smrg OPTV_STRING, /* a non-empty string */ 51706f2543Smrg OPTV_ANYSTR, /* Any string, including an empty one */ 52706f2543Smrg OPTV_REAL, 53706f2543Smrg OPTV_BOOLEAN, 54706f2543Smrg OPTV_PERCENT, 55706f2543Smrg OPTV_FREQ 56706f2543Smrg} OptionValueType; 57706f2543Smrg 58706f2543Smrgtypedef enum { 59706f2543Smrg OPTUNITS_HZ = 1, 60706f2543Smrg OPTUNITS_KHZ, 61706f2543Smrg OPTUNITS_MHZ 62706f2543Smrg} OptFreqUnits; 63706f2543Smrg 64706f2543Smrgtypedef struct { 65706f2543Smrg int token; 66706f2543Smrg const char* name; 67706f2543Smrg OptionValueType type; 68706f2543Smrg ValueUnion value; 69706f2543Smrg Bool found; 70706f2543Smrg} OptionInfoRec, *OptionInfoPtr; 71706f2543Smrg 72706f2543Smrgextern _X_EXPORT int xf86SetIntOption(pointer optlist, const char *name, int deflt); 73706f2543Smrgextern _X_EXPORT double xf86SetRealOption(pointer optlist, const char *name, double deflt); 74706f2543Smrgextern _X_EXPORT char *xf86SetStrOption(pointer optlist, const char *name, char *deflt); 75706f2543Smrgextern _X_EXPORT int xf86SetBoolOption(pointer list, const char *name, int deflt ); 76706f2543Smrgextern _X_EXPORT double xf86SetPercentOption(pointer list, const char *name, double deflt ); 77706f2543Smrgextern _X_EXPORT int xf86CheckIntOption(pointer optlist, const char *name, int deflt); 78706f2543Smrgextern _X_EXPORT double xf86CheckRealOption(pointer optlist, const char *name, double deflt); 79706f2543Smrgextern _X_EXPORT char *xf86CheckStrOption(pointer optlist, const char *name, char *deflt); 80706f2543Smrgextern _X_EXPORT int xf86CheckBoolOption(pointer list, const char *name, int deflt ); 81706f2543Smrgextern _X_EXPORT double xf86CheckPercentOption(pointer list, const char *name, double deflt ); 82706f2543Smrgextern _X_EXPORT pointer xf86AddNewOption(pointer head, const char *name, const char *val ); 83706f2543Smrgextern _X_EXPORT pointer xf86NewOption(char *name, char *value ); 84706f2543Smrgextern _X_EXPORT pointer xf86NextOption(pointer list ); 85706f2543Smrgextern _X_EXPORT pointer xf86OptionListCreate(const char **options, int count, int used); 86706f2543Smrgextern _X_EXPORT pointer xf86OptionListMerge(pointer head, pointer tail); 87706f2543Smrgextern _X_EXPORT pointer xf86OptionListDuplicate(pointer list); 88706f2543Smrgextern _X_EXPORT void xf86OptionListFree(pointer opt); 89706f2543Smrgextern _X_EXPORT char *xf86OptionName(pointer opt); 90706f2543Smrgextern _X_EXPORT char *xf86OptionValue(pointer opt); 91706f2543Smrgextern _X_EXPORT void xf86OptionListReport(pointer parm); 92706f2543Smrgextern _X_EXPORT pointer xf86FindOption(pointer options, const char *name); 93706f2543Smrgextern _X_EXPORT char *xf86FindOptionValue(pointer options, const char *name); 94706f2543Smrgextern _X_EXPORT void xf86MarkOptionUsed(pointer option); 95706f2543Smrgextern _X_EXPORT void xf86MarkOptionUsedByName(pointer options, const char *name); 96706f2543Smrgextern _X_EXPORT Bool xf86CheckIfOptionUsed(pointer option); 97706f2543Smrgextern _X_EXPORT Bool xf86CheckIfOptionUsedByName(pointer options, const char *name); 98706f2543Smrgextern _X_EXPORT void xf86ShowUnusedOptions(int scrnIndex, pointer options); 99706f2543Smrgextern _X_EXPORT void xf86ProcessOptions(int scrnIndex, pointer options, OptionInfoPtr optinfo); 100706f2543Smrgextern _X_EXPORT OptionInfoPtr xf86TokenToOptinfo(const OptionInfoRec *table, int token); 101706f2543Smrgextern _X_EXPORT const char *xf86TokenToOptName(const OptionInfoRec *table, int token); 102706f2543Smrgextern _X_EXPORT Bool xf86IsOptionSet(const OptionInfoRec *table, int token); 103706f2543Smrgextern _X_EXPORT char *xf86GetOptValString(const OptionInfoRec *table, int token); 104706f2543Smrgextern _X_EXPORT Bool xf86GetOptValInteger(const OptionInfoRec *table, int token, int *value); 105706f2543Smrgextern _X_EXPORT Bool xf86GetOptValULong(const OptionInfoRec *table, int token, unsigned long *value); 106706f2543Smrgextern _X_EXPORT Bool xf86GetOptValReal(const OptionInfoRec *table, int token, double *value); 107706f2543Smrgextern _X_EXPORT Bool xf86GetOptValFreq(const OptionInfoRec *table, int token, 108706f2543Smrg OptFreqUnits expectedUnits, double *value); 109706f2543Smrgextern _X_EXPORT Bool xf86GetOptValBool(const OptionInfoRec *table, int token, Bool *value); 110706f2543Smrgextern _X_EXPORT Bool xf86ReturnOptValBool(const OptionInfoRec *table, int token, Bool def); 111706f2543Smrgextern _X_EXPORT int xf86NameCmp(const char *s1, const char *s2); 112706f2543Smrgextern _X_EXPORT char *xf86NormalizeName(const char *s); 113706f2543Smrgextern _X_EXPORT pointer xf86ReplaceIntOption(pointer optlist, const char *name, const int val); 114706f2543Smrgextern _X_EXPORT pointer xf86ReplaceRealOption(pointer optlist, const char *name, const double val); 115706f2543Smrgextern _X_EXPORT pointer xf86ReplaceBoolOption(pointer optlist, const char *name, const Bool val); 116706f2543Smrgextern _X_EXPORT pointer xf86ReplacePercentOption(pointer optlist, const char *name, const double val); 117706f2543Smrgextern _X_EXPORT pointer xf86ReplaceStrOption(pointer optlist, const char *name, const char* val); 118706f2543Smrg#endif 119