xf86Parser.h revision 9ace9065
1/* 2 * 3 * Copyright (c) 1997 Metro Link Incorporated 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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 20 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 * SOFTWARE. 22 * 23 * Except as contained in this notice, the name of the Metro Link shall not be 24 * used in advertising or otherwise to promote the sale, use or other dealings 25 * in this Software without prior written authorization from Metro Link. 26 * 27 */ 28/* 29 * Copyright (c) 1997-2003 by The XFree86 Project, Inc. 30 * 31 * Permission is hereby granted, free of charge, to any person obtaining a 32 * copy of this software and associated documentation files (the "Software"), 33 * to deal in the Software without restriction, including without limitation 34 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 35 * and/or sell copies of the Software, and to permit persons to whom the 36 * Software is furnished to do so, subject to the following conditions: 37 * 38 * The above copyright notice and this permission notice shall be included in 39 * all copies or substantial portions of the Software. 40 * 41 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 42 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 43 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 44 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 45 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 46 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 47 * OTHER DEALINGS IN THE SOFTWARE. 48 * 49 * Except as contained in this notice, the name of the copyright holder(s) 50 * and author(s) shall not be used in advertising or otherwise to promote 51 * the sale, use or other dealings in this Software without prior written 52 * authorization from the copyright holder(s) and author(s). 53 */ 54 55 56/* 57 * This file contains the external interfaces for the XFree86 configuration 58 * file parser. 59 */ 60#ifdef HAVE_XORG_CONFIG_H 61#include <xorg-config.h> 62#endif 63 64#ifndef _xf86Parser_h_ 65#define _xf86Parser_h_ 66 67#include <X11/Xdefs.h> 68#include "xf86Optrec.h" 69#include "list.h" 70 71#define HAVE_PARSER_DECLS 72 73typedef struct 74{ 75 char *file_logfile; 76 char *file_modulepath; 77 char *file_fontpath; 78 char *file_comment; 79 char *file_xkbdir; 80} 81XF86ConfFilesRec, *XF86ConfFilesPtr; 82 83/* Values for load_type */ 84#define XF86_LOAD_MODULE 0 85#define XF86_LOAD_DRIVER 1 86#define XF86_DISABLE_MODULE 2 87 88typedef struct 89{ 90 GenericListRec list; 91 int load_type; 92 char *load_name; 93 XF86OptionPtr load_opt; 94 char *load_comment; 95 int ignore; 96} 97XF86LoadRec, *XF86LoadPtr; 98 99typedef struct 100{ 101 XF86LoadPtr mod_load_lst; 102 XF86LoadPtr mod_disable_lst; 103 char *mod_comment; 104} 105XF86ConfModuleRec, *XF86ConfModulePtr; 106 107#define CONF_IMPLICIT_KEYBOARD "Implicit Core Keyboard" 108 109#define CONF_IMPLICIT_POINTER "Implicit Core Pointer" 110 111#define XF86CONF_PHSYNC 0x0001 112#define XF86CONF_NHSYNC 0x0002 113#define XF86CONF_PVSYNC 0x0004 114#define XF86CONF_NVSYNC 0x0008 115#define XF86CONF_INTERLACE 0x0010 116#define XF86CONF_DBLSCAN 0x0020 117#define XF86CONF_CSYNC 0x0040 118#define XF86CONF_PCSYNC 0x0080 119#define XF86CONF_NCSYNC 0x0100 120#define XF86CONF_HSKEW 0x0200 /* hskew provided */ 121#define XF86CONF_BCAST 0x0400 122#define XF86CONF_VSCAN 0x1000 123 124typedef struct 125{ 126 GenericListRec list; 127 char *ml_identifier; 128 int ml_clock; 129 int ml_hdisplay; 130 int ml_hsyncstart; 131 int ml_hsyncend; 132 int ml_htotal; 133 int ml_vdisplay; 134 int ml_vsyncstart; 135 int ml_vsyncend; 136 int ml_vtotal; 137 int ml_vscan; 138 int ml_flags; 139 int ml_hskew; 140 char *ml_comment; 141} 142XF86ConfModeLineRec, *XF86ConfModeLinePtr; 143 144typedef struct 145{ 146 GenericListRec list; 147 char *vp_identifier; 148 XF86OptionPtr vp_option_lst; 149 char *vp_comment; 150} 151XF86ConfVideoPortRec, *XF86ConfVideoPortPtr; 152 153typedef struct 154{ 155 GenericListRec list; 156 char *va_identifier; 157 char *va_vendor; 158 char *va_board; 159 char *va_busid; 160 char *va_driver; 161 XF86OptionPtr va_option_lst; 162 XF86ConfVideoPortPtr va_port_lst; 163 char *va_fwdref; 164 char *va_comment; 165} 166XF86ConfVideoAdaptorRec, *XF86ConfVideoAdaptorPtr; 167 168#define CONF_MAX_HSYNC 8 169#define CONF_MAX_VREFRESH 8 170 171typedef struct 172{ 173 float hi, lo; 174} 175parser_range; 176 177typedef struct 178{ 179 int red, green, blue; 180} 181parser_rgb; 182 183typedef struct 184{ 185 GenericListRec list; 186 char *modes_identifier; 187 XF86ConfModeLinePtr mon_modeline_lst; 188 char *modes_comment; 189} 190XF86ConfModesRec, *XF86ConfModesPtr; 191 192typedef struct 193{ 194 GenericListRec list; 195 char *ml_modes_str; 196 XF86ConfModesPtr ml_modes; 197} 198XF86ConfModesLinkRec, *XF86ConfModesLinkPtr; 199 200typedef struct 201{ 202 GenericListRec list; 203 char *mon_identifier; 204 char *mon_vendor; 205 char *mon_modelname; 206 int mon_width; /* in mm */ 207 int mon_height; /* in mm */ 208 XF86ConfModeLinePtr mon_modeline_lst; 209 int mon_n_hsync; 210 parser_range mon_hsync[CONF_MAX_HSYNC]; 211 int mon_n_vrefresh; 212 parser_range mon_vrefresh[CONF_MAX_VREFRESH]; 213 float mon_gamma_red; 214 float mon_gamma_green; 215 float mon_gamma_blue; 216 XF86OptionPtr mon_option_lst; 217 XF86ConfModesLinkPtr mon_modes_sect_lst; 218 char *mon_comment; 219} 220XF86ConfMonitorRec, *XF86ConfMonitorPtr; 221 222#define CONF_MAXDACSPEEDS 4 223#define CONF_MAXCLOCKS 128 224 225typedef struct 226{ 227 GenericListRec list; 228 char *dev_identifier; 229 char *dev_vendor; 230 char *dev_board; 231 char *dev_chipset; 232 char *dev_busid; 233 char *dev_card; 234 char *dev_driver; 235 char *dev_ramdac; 236 int dev_dacSpeeds[CONF_MAXDACSPEEDS]; 237 int dev_videoram; 238 int dev_textclockfreq; 239 unsigned long dev_bios_base; 240 unsigned long dev_mem_base; 241 unsigned long dev_io_base; 242 char *dev_clockchip; 243 int dev_clocks; 244 int dev_clock[CONF_MAXCLOCKS]; 245 int dev_chipid; 246 int dev_chiprev; 247 int dev_irq; 248 int dev_screen; 249 XF86OptionPtr dev_option_lst; 250 char *dev_comment; 251} 252XF86ConfDeviceRec, *XF86ConfDevicePtr; 253 254typedef struct 255{ 256 GenericListRec list; 257 char *mode_name; 258} 259XF86ModeRec, *XF86ModePtr; 260 261typedef struct 262{ 263 GenericListRec list; 264 int disp_frameX0; 265 int disp_frameY0; 266 int disp_virtualX; 267 int disp_virtualY; 268 int disp_depth; 269 int disp_bpp; 270 char *disp_visual; 271 parser_rgb disp_weight; 272 parser_rgb disp_black; 273 parser_rgb disp_white; 274 XF86ModePtr disp_mode_lst; 275 XF86OptionPtr disp_option_lst; 276 char *disp_comment; 277} 278XF86ConfDisplayRec, *XF86ConfDisplayPtr; 279 280typedef struct 281{ 282 XF86OptionPtr flg_option_lst; 283 char *flg_comment; 284} 285XF86ConfFlagsRec, *XF86ConfFlagsPtr; 286 287typedef struct 288{ 289 GenericListRec list; 290 char *al_adaptor_str; 291 XF86ConfVideoAdaptorPtr al_adaptor; 292} 293XF86ConfAdaptorLinkRec, *XF86ConfAdaptorLinkPtr; 294 295typedef struct 296{ 297 GenericListRec list; 298 char *scrn_identifier; 299 char *scrn_obso_driver; 300 int scrn_defaultdepth; 301 int scrn_defaultbpp; 302 int scrn_defaultfbbpp; 303 char *scrn_monitor_str; 304 XF86ConfMonitorPtr scrn_monitor; 305 char *scrn_device_str; 306 XF86ConfDevicePtr scrn_device; 307 XF86ConfAdaptorLinkPtr scrn_adaptor_lst; 308 XF86ConfDisplayPtr scrn_display_lst; 309 XF86OptionPtr scrn_option_lst; 310 char *scrn_comment; 311 int scrn_virtualX, scrn_virtualY; 312} 313XF86ConfScreenRec, *XF86ConfScreenPtr; 314 315typedef struct 316{ 317 GenericListRec list; 318 char *inp_identifier; 319 char *inp_driver; 320 XF86OptionPtr inp_option_lst; 321 char *inp_comment; 322} 323XF86ConfInputRec, *XF86ConfInputPtr; 324 325typedef struct 326{ 327 GenericListRec list; 328 XF86ConfInputPtr iref_inputdev; 329 char *iref_inputdev_str; 330 XF86OptionPtr iref_option_lst; 331} 332XF86ConfInputrefRec, *XF86ConfInputrefPtr; 333 334typedef struct 335{ 336 Bool set; 337 Bool val; 338} 339xf86TriState; 340 341typedef struct 342{ 343 struct list entry; 344 char **values; 345} 346xf86MatchGroup; 347 348typedef struct 349{ 350 GenericListRec list; 351 char *identifier; 352 char *driver; 353 struct list match_product; 354 struct list match_vendor; 355 struct list match_device; 356 struct list match_os; 357 struct list match_pnpid; 358 struct list match_usbid; 359 struct list match_driver; 360 struct list match_tag; 361 xf86TriState is_keyboard; 362 xf86TriState is_pointer; 363 xf86TriState is_joystick; 364 xf86TriState is_tablet; 365 xf86TriState is_touchpad; 366 xf86TriState is_touchscreen; 367 XF86OptionPtr option_lst; 368 char *comment; 369} 370XF86ConfInputClassRec, *XF86ConfInputClassPtr; 371 372/* Values for adj_where */ 373#define CONF_ADJ_OBSOLETE -1 374#define CONF_ADJ_ABSOLUTE 0 375#define CONF_ADJ_RIGHTOF 1 376#define CONF_ADJ_LEFTOF 2 377#define CONF_ADJ_ABOVE 3 378#define CONF_ADJ_BELOW 4 379#define CONF_ADJ_RELATIVE 5 380 381typedef struct 382{ 383 GenericListRec list; 384 int adj_scrnum; 385 XF86ConfScreenPtr adj_screen; 386 char *adj_screen_str; 387 XF86ConfScreenPtr adj_top; 388 char *adj_top_str; 389 XF86ConfScreenPtr adj_bottom; 390 char *adj_bottom_str; 391 XF86ConfScreenPtr adj_left; 392 char *adj_left_str; 393 XF86ConfScreenPtr adj_right; 394 char *adj_right_str; 395 int adj_where; 396 int adj_x; 397 int adj_y; 398 char *adj_refscreen; 399} 400XF86ConfAdjacencyRec, *XF86ConfAdjacencyPtr; 401 402typedef struct 403{ 404 GenericListRec list; 405 char *inactive_device_str; 406 XF86ConfDevicePtr inactive_device; 407} 408XF86ConfInactiveRec, *XF86ConfInactivePtr; 409 410typedef struct 411{ 412 GenericListRec list; 413 char *lay_identifier; 414 XF86ConfAdjacencyPtr lay_adjacency_lst; 415 XF86ConfInactivePtr lay_inactive_lst; 416 XF86ConfInputrefPtr lay_input_lst; 417 XF86OptionPtr lay_option_lst; 418 char *lay_comment; 419} 420XF86ConfLayoutRec, *XF86ConfLayoutPtr; 421 422typedef struct 423{ 424 GenericListRec list; 425 char *vs_name; 426 char *vs_identifier; 427 XF86OptionPtr vs_option_lst; 428 char *vs_comment; 429} 430XF86ConfVendSubRec, *XF86ConfVendSubPtr; 431 432typedef struct 433{ 434 GenericListRec list; 435 char *vnd_identifier; 436 XF86OptionPtr vnd_option_lst; 437 XF86ConfVendSubPtr vnd_sub_lst; 438 char *vnd_comment; 439} 440XF86ConfVendorRec, *XF86ConfVendorPtr; 441 442typedef struct 443{ 444 char *dri_group_name; 445 int dri_group; 446 int dri_mode; 447 char *dri_comment; 448} 449XF86ConfDRIRec, *XF86ConfDRIPtr; 450 451typedef struct 452{ 453 XF86OptionPtr ext_option_lst; 454 char *extensions_comment; 455} 456XF86ConfExtensionsRec, *XF86ConfExtensionsPtr; 457 458typedef struct 459{ 460 XF86ConfFilesPtr conf_files; 461 XF86ConfModulePtr conf_modules; 462 XF86ConfFlagsPtr conf_flags; 463 XF86ConfVideoAdaptorPtr conf_videoadaptor_lst; 464 XF86ConfModesPtr conf_modes_lst; 465 XF86ConfMonitorPtr conf_monitor_lst; 466 XF86ConfDevicePtr conf_device_lst; 467 XF86ConfScreenPtr conf_screen_lst; 468 XF86ConfInputPtr conf_input_lst; 469 XF86ConfInputClassPtr conf_inputclass_lst; 470 XF86ConfLayoutPtr conf_layout_lst; 471 XF86ConfVendorPtr conf_vendor_lst; 472 XF86ConfDRIPtr conf_dri; 473 XF86ConfExtensionsPtr conf_extensions; 474 char *conf_comment; 475} 476XF86ConfigRec, *XF86ConfigPtr; 477 478typedef struct 479{ 480 int token; /* id of the token */ 481 char *name; /* pointer to the LOWERCASED name */ 482} 483xf86ConfigSymTabRec, *xf86ConfigSymTabPtr; 484 485/* 486 * prototypes for public functions 487 */ 488extern void xf86initConfigFiles(void); 489extern const char *xf86openConfigFile(const char *path, const char *cmdline, 490 const char *projroot); 491extern const char *xf86openConfigDirFiles(const char *path, const char *cmdline, 492 const char *projroot); 493extern void xf86setBuiltinConfig(const char *config[]); 494extern XF86ConfigPtr xf86readConfigFile(void); 495extern void xf86closeConfigFile(void); 496extern void xf86freeConfig(XF86ConfigPtr p); 497extern int xf86writeConfigFile(const char *, XF86ConfigPtr); 498extern _X_EXPORT XF86ConfDevicePtr xf86findDevice(const char *ident, XF86ConfDevicePtr p); 499extern _X_EXPORT XF86ConfLayoutPtr xf86findLayout(const char *name, XF86ConfLayoutPtr list); 500extern _X_EXPORT XF86ConfMonitorPtr xf86findMonitor(const char *ident, XF86ConfMonitorPtr p); 501extern _X_EXPORT XF86ConfModesPtr xf86findModes(const char *ident, XF86ConfModesPtr p); 502extern _X_EXPORT XF86ConfModeLinePtr xf86findModeLine(const char *ident, XF86ConfModeLinePtr p); 503extern _X_EXPORT XF86ConfScreenPtr xf86findScreen(const char *ident, XF86ConfScreenPtr p); 504extern _X_EXPORT XF86ConfInputPtr xf86findInput(const char *ident, XF86ConfInputPtr p); 505extern _X_EXPORT XF86ConfInputPtr xf86findInputByDriver(const char *driver, XF86ConfInputPtr p); 506extern _X_EXPORT XF86ConfVideoAdaptorPtr xf86findVideoAdaptor(const char *ident, 507 XF86ConfVideoAdaptorPtr p); 508extern int xf86layoutAddInputDevices(XF86ConfigPtr config, XF86ConfLayoutPtr layout); 509 510extern _X_EXPORT GenericListPtr xf86addListItem(GenericListPtr head, GenericListPtr c_new); 511extern _X_EXPORT int xf86itemNotSublist(GenericListPtr list_1, GenericListPtr list_2); 512 513extern _X_EXPORT int xf86pathIsAbsolute(const char *path); 514extern _X_EXPORT int xf86pathIsSafe(const char *path); 515extern _X_EXPORT char *xf86addComment(char *cur, char *add); 516extern _X_EXPORT Bool xf86getBoolValue(Bool *val, const char *str); 517 518#endif /* _xf86Parser_h_ */ 519