~ubuntu-branches/ubuntu/precise/nvidia-settings/precise-proposed

« back to all changes in this revision

Viewing changes to src/parse.h

  • Committer: Bazaar Package Importer
  • Author(s): Randall Donald
  • Date: 2004-07-03 19:09:17 UTC
  • Revision ID: james.westby@ubuntu.com-20040703190917-rqkze2s58ux5pamy
Tags: upstream-1.0
ImportĀ upstreamĀ versionĀ 1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * nvidia-settings: A tool for configuring the NVIDIA X driver on Unix
 
3
 * and Linux systems.
 
4
 *
 
5
 * Copyright (C) 2004 NVIDIA Corporation.
 
6
 *
 
7
 * This program is free software; you can redistribute it and/or
 
8
 * modify it under the terms of Version 2 of the GNU General Public
 
9
 * License as published by the Free Software Foundation.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful, but
 
12
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See Version 2
 
14
 * of the GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, write to the:
 
18
 *
 
19
 *           Free Software Foundation, Inc.
 
20
 *           59 Temple Place - Suite 330
 
21
 *           Boston, MA 02111-1307, USA
 
22
 *
 
23
 */
 
24
 
 
25
/*
 
26
 * parse.h - prototypes and definitions for the parser.
 
27
 */
 
28
 
 
29
#ifndef __PARSE_H__
 
30
#define __PARSE_H__
 
31
 
 
32
 
 
33
/*
 
34
 * Flag values used in the flags field of the ParsedAttribute struct.
 
35
 */
 
36
 
 
37
#define NV_PARSER_HAS_X_DISPLAY         (1<<0)
 
38
#define NV_PARSER_HAS_X_SCREEN          (1<<2)
 
39
#define NV_PARSER_HAS_DISPLAY_DEVICE    (1<<3)
 
40
#define NV_PARSER_HAS_VAL               (1<<4)
 
41
 
 
42
/*
 
43
 * Flag values used in the flags field of the AttributeTableEntry struct.
 
44
 */
 
45
 
 
46
#define NV_PARSER_TYPE_FRAMELOCK        (1<<16)
 
47
#define NV_PARSER_TYPE_COLOR_ATTRIBUTE  (1<<17)
 
48
#define NV_PARSER_TYPE_NO_CONFIG_WRITE  (1<<18)
 
49
#define NV_PARSER_TYPE_GUI_ATTRIUBUTE   (1<<19)
 
50
#define NV_PARSER_TYPE_XVIDEO_ATTRIBUTE (1<<20)
 
51
 
 
52
#define NV_PARSER_ASSIGNMENT 0
 
53
#define NV_PARSER_QUERY 1
 
54
 
 
55
#define NV_PARSER_MAX_NAME_LEN 256
 
56
 
 
57
#define DISPLAY_NAME_SEPARATOR '/'
 
58
 
 
59
 
 
60
/*
 
61
 * error codes returned by nv_parse_attribute_string().
 
62
 */
 
63
 
 
64
#define NV_PARSER_STATUS_SUCCESS                0
 
65
#define NV_PARSER_STATUS_BAD_ARGUMENT           1
 
66
#define NV_PARSER_STATUS_EMPTY_STRING           2
 
67
#define NV_PARSER_STATUS_ATTR_NAME_TOO_LONG     3
 
68
#define NV_PARSER_STATUS_ATTR_NAME_MISSING      4
 
69
#define NV_PARSER_STATUS_BAD_DISPLAY_DEVICE     5
 
70
#define NV_PARSER_STATUS_MISSING_EQUAL_SIGN     6
 
71
#define NV_PARSER_STATUS_NO_VALUE               7
 
72
#define NV_PARSER_STATUS_TRAILING_GARBAGE       8
 
73
#define NV_PARSER_STATUS_UNKNOWN_ATTR_NAME      9
 
74
 
 
75
/*
 
76
 * define useful types
 
77
 */
 
78
 
 
79
typedef unsigned int uint32;
 
80
 
 
81
 
 
82
/*
 
83
 * The valid attribute names, and their corresponding protocol
 
84
 * attribute identifiers are stored in an array of
 
85
 * AttributeTableEntries.
 
86
 */
 
87
 
 
88
typedef struct _AttributeTableEntry {
 
89
    char *name;
 
90
    int attr;
 
91
    uint32 flags;
 
92
} AttributeTableEntry;
 
93
 
 
94
 
 
95
/*
 
96
 * ParsedAttribute - struct filled out by
 
97
 * nv_ParseAttributeString().
 
98
 */
 
99
 
 
100
typedef struct _ParsedAttribute {
 
101
    char *display;
 
102
    char *name;
 
103
    int screen;
 
104
    int attr;
 
105
    int val;
 
106
    float fval; /* XXX put in a union with val? */
 
107
    uint32 display_device_mask;
 
108
    uint32 flags;
 
109
    struct _ParsedAttribute *next;
 
110
} ParsedAttribute;
 
111
 
 
112
 
 
113
 
 
114
/*
 
115
 * Attribute table; defined in parse.c
 
116
 */
 
117
 
 
118
extern AttributeTableEntry attributeTable[];
 
119
 
 
120
/*
 
121
 * nv_parse_attribute_string() - this function parses an attribute
 
122
 * string, the syntax for which is:
 
123
 *
 
124
 * {host}:{display}.{screen}/{attribute name}[{display devices}]={value}
 
125
 *
 
126
 * {host}:{display}.{screen} indicates which X server and X screen to
 
127
 * interact with; this is optional.  If no X server is specified, then
 
128
 * the default X server is used.  If no X screen is specified, then
 
129
 * all X screens on the X server are used.
 
130
 *
 
131
 * {screen}/ may be specified by itself (ie: without the
 
132
 * "{host}:{display}." part).
 
133
 *
 
134
 * {attribute name} should be a string without any whitespace (a case
 
135
 * insensitive compare will be done to find a match in the
 
136
 * attributeTable in parse.c).  {value} should be an integer.
 
137
 *
 
138
 * {display devices} is optional.  If no display mask is specified,
 
139
 * then all display devices are assumed.
 
140
 *
 
141
 * The query parameter controls whether the attribute string is parsed
 
142
 * for setting or querying.  If query == NV_PARSER_SET, then the
 
143
 * attribute string will be interpretted as described above.  If query
 
144
 * == NV_PARSER_QUERY, the "={value}" portion of the string should be
 
145
 * omitted.
 
146
 *
 
147
 * If successful, NV_PARSER_STATUS_SUCCESS will be returned and the
 
148
 * ParsedAttribute struct will contain the attribute id corresponding
 
149
 * to the attribute name.  If the X server or display devices were
 
150
 * given in the string, then those fields will be appropriately
 
151
 * assigned in the ParsedAttribute struct, and the
 
152
 * NV_PARSER_HAS_X_SERVER and NV_PARSER_HAS_DISPLAY_DEVICE_MASK bits
 
153
 * will be set in the flags field.
 
154
 */
 
155
 
 
156
int nv_parse_attribute_string(const char *, int, ParsedAttribute *);
 
157
 
 
158
 
 
159
/*
 
160
 * nv_assign_default_display() - assigns the display name to the
 
161
 * ParsedAttribute struct.  As a side affect, also assigns the screen
 
162
 * field, if a screen is specified in the display name.
 
163
 */
 
164
 
 
165
void nv_assign_default_display(ParsedAttribute *a, const char *display);
 
166
 
 
167
 
 
168
/*
 
169
 * nv_parse_strerror() - given the error status returned by
 
170
 * nv_parse_attribute_string(), this function returns a string
 
171
 * describing the error.
 
172
 */
 
173
 
 
174
char *nv_parse_strerror(int);
 
175
 
 
176
int nv_strcasecmp(const char *, const char *);
 
177
 
 
178
 
 
179
char *remove_spaces(const char *o);
 
180
 
 
181
/*
 
182
 * diaplay_mask/display_name conversions: the NV-CONTROL X extension
 
183
 * identifies a display device by a bit in a display device mask.  The
 
184
 * below functions translate between a display mask, and a string
 
185
 * describing the display devices.
 
186
 */
 
187
 
 
188
#define BITSHIFT_CRT  0
 
189
#define BITSHIFT_TV   8
 
190
#define BITSHIFT_DFP 16
 
191
 
 
192
#define BITMASK_ALL_CRT (0xff << BITSHIFT_CRT)
 
193
#define BITMASK_ALL_TV  (0xff << BITSHIFT_TV)
 
194
#define BITMASK_ALL_DFP (0xff << BITSHIFT_DFP)
 
195
 
 
196
#define INVALID_DISPLAY_DEVICE_MASK   (0xffffffff)
 
197
 
 
198
#define VALID_DISPLAY_DEVICES_MASK    (0x00ffffff)
 
199
#define DISPLAY_DEVICES_WILDCARD_MASK (0xff000000)
 
200
 
 
201
#define DISPLAY_DEVICES_WILDCARD_CRT  (1 << 24)
 
202
#define DISPLAY_DEVICES_WILDCARD_TV   (1 << 25)
 
203
#define DISPLAY_DEVICES_WILDCARD_DFP  (1 << 26)
 
204
 
 
205
 
 
206
 
 
207
char *display_device_mask_to_display_device_name(const uint32);
 
208
uint32 display_device_name_to_display_device_mask(const char *);
 
209
 
 
210
uint32 expand_display_device_mask_wildcards(const uint32, const uint32);
 
211
 
 
212
ParsedAttribute *nv_parsed_attribute_init(void);
 
213
 
 
214
void nv_parsed_attribute_add(ParsedAttribute *head, ParsedAttribute *a);
 
215
 
 
216
void nv_parsed_attribute_free(ParsedAttribute *p);
 
217
void nv_parsed_attribute_clean(ParsedAttribute *p);
 
218
 
 
219
char *nv_get_attribute_name(const int attr);
 
220
 
 
221
char *nv_standardize_screen_name(const char *display_name, int screen);
 
222
 
 
223
#endif /* __PARSE_H__ */