1 |
|
---|
2 | /*
|
---|
3 | * Copyright (c) 1998-2003 by The XFree86 Project, Inc.
|
---|
4 | *
|
---|
5 | * Permission is hereby granted, free of charge, to any person obtaining a
|
---|
6 | * copy of this software and associated documentation files (the "Software"),
|
---|
7 | * to deal in the Software without restriction, including without limitation
|
---|
8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
---|
9 | * and/or sell copies of the Software, and to permit persons to whom the
|
---|
10 | * Software is furnished to do so, subject to the following conditions:
|
---|
11 | *
|
---|
12 | * The above copyright notice and this permission notice shall be included in
|
---|
13 | * all copies or substantial portions of the Software.
|
---|
14 | *
|
---|
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
---|
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
---|
18 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
---|
19 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
---|
20 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
---|
21 | * OTHER DEALINGS IN THE SOFTWARE.
|
---|
22 | *
|
---|
23 | * Except as contained in this notice, the name of the copyright holder(s)
|
---|
24 | * and author(s) shall not be used in advertising or otherwise to promote
|
---|
25 | * the sale, use or other dealings in this Software without prior written
|
---|
26 | * authorization from the copyright holder(s) and author(s).
|
---|
27 | */
|
---|
28 |
|
---|
29 | /* Option handling things that ModuleSetup procs can use */
|
---|
30 |
|
---|
31 | #ifndef _XF86_OPT_H_
|
---|
32 | #define _XF86_OPT_H_
|
---|
33 |
|
---|
34 | typedef struct {
|
---|
35 | double freq;
|
---|
36 | int units;
|
---|
37 | } OptFrequency;
|
---|
38 |
|
---|
39 | typedef union {
|
---|
40 | unsigned long num;
|
---|
41 | char * str;
|
---|
42 | double realnum;
|
---|
43 | Bool bool;
|
---|
44 | OptFrequency freq;
|
---|
45 | } ValueUnion;
|
---|
46 |
|
---|
47 | typedef enum {
|
---|
48 | OPTV_NONE = 0,
|
---|
49 | OPTV_INTEGER,
|
---|
50 | OPTV_STRING, /* a non-empty string */
|
---|
51 | OPTV_ANYSTR, /* Any string, including an empty one */
|
---|
52 | OPTV_REAL,
|
---|
53 | OPTV_BOOLEAN,
|
---|
54 | OPTV_FREQ
|
---|
55 | } OptionValueType;
|
---|
56 |
|
---|
57 | typedef enum {
|
---|
58 | OPTUNITS_HZ = 1,
|
---|
59 | OPTUNITS_KHZ,
|
---|
60 | OPTUNITS_MHZ
|
---|
61 | } OptFreqUnits;
|
---|
62 |
|
---|
63 | typedef struct {
|
---|
64 | int token;
|
---|
65 | const char* name;
|
---|
66 | OptionValueType type;
|
---|
67 | ValueUnion value;
|
---|
68 | Bool found;
|
---|
69 | } OptionInfoRec, *OptionInfoPtr;
|
---|
70 |
|
---|
71 | int xf86SetIntOption(pointer optlist, const char *name, int deflt);
|
---|
72 | double xf86SetRealOption(pointer optlist, const char *name, double deflt);
|
---|
73 | char *xf86SetStrOption(pointer optlist, const char *name, char *deflt);
|
---|
74 | int xf86SetBoolOption(pointer list, const char *name, int deflt );
|
---|
75 | int xf86CheckIntOption(pointer optlist, const char *name, int deflt);
|
---|
76 | double xf86CheckRealOption(pointer optlist, const char *name, double deflt);
|
---|
77 | char *xf86CheckStrOption(pointer optlist, const char *name, char *deflt);
|
---|
78 | int xf86CheckBoolOption(pointer list, const char *name, int deflt );
|
---|
79 | pointer xf86AddNewOption(pointer head, const char *name, const char *val );
|
---|
80 | pointer xf86NewOption(char *name, char *value );
|
---|
81 | pointer xf86NextOption(pointer list );
|
---|
82 | pointer xf86OptionListCreate(const char **options, int count, int used);
|
---|
83 | pointer xf86OptionListMerge(pointer head, pointer tail);
|
---|
84 | void xf86OptionListFree(pointer opt);
|
---|
85 | char *xf86OptionName(pointer opt);
|
---|
86 | char *xf86OptionValue(pointer opt);
|
---|
87 | void xf86OptionListReport(pointer parm);
|
---|
88 | pointer xf86FindOption(pointer options, const char *name);
|
---|
89 | char *xf86FindOptionValue(pointer options, const char *name);
|
---|
90 | void xf86MarkOptionUsed(pointer option);
|
---|
91 | void xf86MarkOptionUsedByName(pointer options, const char *name);
|
---|
92 | Bool xf86CheckIfOptionUsed(pointer option);
|
---|
93 | Bool xf86CheckIfOptionUsedByName(pointer options, const char *name);
|
---|
94 | void xf86ShowUnusedOptions(int scrnIndex, pointer options);
|
---|
95 | void xf86ProcessOptions(int scrnIndex, pointer options, OptionInfoPtr optinfo);
|
---|
96 | OptionInfoPtr xf86TokenToOptinfo(const OptionInfoRec *table, int token);
|
---|
97 | const char *xf86TokenToOptName(const OptionInfoRec *table, int token);
|
---|
98 | Bool xf86IsOptionSet(const OptionInfoRec *table, int token);
|
---|
99 | char *xf86GetOptValString(const OptionInfoRec *table, int token);
|
---|
100 | Bool xf86GetOptValInteger(const OptionInfoRec *table, int token, int *value);
|
---|
101 | Bool xf86GetOptValULong(const OptionInfoRec *table, int token, unsigned long *value);
|
---|
102 | Bool xf86GetOptValReal(const OptionInfoRec *table, int token, double *value);
|
---|
103 | Bool xf86GetOptValFreq(const OptionInfoRec *table, int token,
|
---|
104 | OptFreqUnits expectedUnits, double *value);
|
---|
105 | Bool xf86GetOptValBool(const OptionInfoRec *table, int token, Bool *value);
|
---|
106 | Bool xf86ReturnOptValBool(const OptionInfoRec *table, int token, Bool def);
|
---|
107 | int xf86NameCmp(const char *s1, const char *s2);
|
---|
108 | char *xf86NormalizeName(const char *s);
|
---|
109 | pointer xf86ReplaceIntOption(pointer optlist, const char *name, const int val);
|
---|
110 | pointer xf86ReplaceRealOption(pointer optlist, const char *name, const double val);
|
---|
111 | pointer xf86ReplaceBoolOption(pointer optlist, const char *name, const Bool val);
|
---|
112 | pointer xf86ReplaceStrOption(pointer optlist, const char *name, const char* val);
|
---|
113 | #endif
|
---|