1117N/A * Copyright (c) 1997 Metro Link Incorporated 1117N/A * Permission is hereby granted, free of charge, to any person obtaining a 1117N/A * copy of this software and associated documentation files (the "Software"), 1117N/A * to deal in the Software without restriction, including without limitation 1117N/A * the rights to use, copy, modify, merge, publish, distribute, sublicense, 1117N/A * and/or sell copies of the Software, and to permit persons to whom the 1117N/A * Software is furnished to do so, subject to the following conditions: 1117N/A * The above copyright notice and this permission notice shall be included in 1117N/A * all copies or substantial portions of the Software. 1117N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1117N/A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1117N/A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1117N/A * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 1117N/A * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 1117N/A * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 1117N/A * Except as contained in this notice, the name of the Metro Link shall not be 1117N/A * used in advertising or otherwise to promote the sale, use or other dealings 1117N/A * in this Software without prior written authorization from Metro Link. 1117N/A * Copyright (c) 1997-2003 by The XFree86 Project, Inc. 1117N/A * Permission is hereby granted, free of charge, to any person obtaining a 1117N/A * copy of this software and associated documentation files (the "Software"), 1117N/A * to deal in the Software without restriction, including without limitation 1117N/A * the rights to use, copy, modify, merge, publish, distribute, sublicense, 1117N/A * and/or sell copies of the Software, and to permit persons to whom the 1117N/A * Software is furnished to do so, subject to the following conditions: 1117N/A * The above copyright notice and this permission notice shall be included in 1117N/A * all copies or substantial portions of the Software. 1117N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1117N/A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1117N/A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1117N/A * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 1117N/A * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 1117N/A * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 1117N/A * OTHER DEALINGS IN THE SOFTWARE. 1117N/A * Except as contained in this notice, the name of the copyright holder(s) 1117N/A * and author(s) shall not be used in advertising or otherwise to promote 1117N/A * the sale, use or other dealings in this Software without prior written 1117N/A * authorization from the copyright holder(s) and author(s). 1117N/A#
endif /* !MAXHOSTNAMELEN */ 1117N/A * A portable, but restricted, version of strtoul(). It only understands 1117N/A * hex, octal, and decimal. But it's good enough for our needs. 1117N/A if ((*p ==
'x') || (*p ==
'X'))
1117N/A if ((*p >=
'0') && (*p <= ((
base ==
8) ?
'7' :
'9')))
1117N/A else if ((
base ==
16) && (*p >=
'a') && (*p <=
'f'))
1117N/A else if ((
base ==
16) && (*p >=
'A') && (*p <=
'F'))
1117N/A * Read from the configFile FILE stream until we encounter a newline; 1117N/A * this is a wrapper for fgets(3) that can handle arbitrarily long 1117N/A * Callers, such as xf86getToken(), assume that we will read up to the 1117N/A * next newline; we need to grow configBuf as necessary to support that. 1117N/A * Reallocate the buffer if it was grown last time (i.e., is no 1117N/A * longer CONFIG_BUF_LEN); we malloc the new buffer first, so 1117N/A * that if the malloc() fails, we can fall back to use the 1117N/A * [Might want to wait and shrink the buffer after reading the line.] 1117N/A * The malloc() succeeded; free the old buffer and use 1117N/A /* read in another block of chars */ 1117N/A /* search for EOL in the new block of chars */ 1117N/A if ((c ==
'\n') || (c ==
'\r')) {
1117N/A * if we didn't find EOL, then grow the buffer and 1117N/A * The reallocation failed; we have to fall 1117N/A * back to the previous configBufLen size and 1117N/A * use the string we have, even though we don't 1117N/A /* reallocation succeeded */ 1117N/A * Read next Token from the config file. Handle the global variable 1117N/A * pushToken. If a pointer to a symbol table has been provided 1117N/A * (tab != NULL), the table may be searched for a match with the 1117N/A * token. If all attempts to recognize the token fail, an 1117N/A * ERROR_TOKEN code is returned. 1117N/A * First check whether pushToken has a different value than LOCK_TOKEN. 1117N/A * Otherwise the next token must be read from the input. 1117N/A * eol_seen is only set for the first token after a newline. 1117N/A * Get start of next Token. EOF is handled, 1117N/A * Make the token buffer the same size as the input line 1117N/A * buffer. We malloc() the new token buffer first, so 1117N/A * that if the malloc() fails, we can fall back to use the 1117N/A * The malloc() succeeded; free the old buffer 1117N/A * Start scanning the new token, which may include whitespace 1117N/A while ((c !=
'\n') && (c !=
'\r') && (c !=
'\0'));
1117N/A * Use xf86addComment when setting a comment. 1117N/A /* GJA -- handle '-' and ',' * Be careful: "-hsync" is a keyword. */ 1117N/A * Numbers are returned immediately ... 1117N/A (c ==
'.') || (c ==
'x') || (c ==
'X') ||
1117N/A ((
base ==
16) && (((c >=
'a') && (c <=
'f')) ||
1117N/A ((c >=
'A') && (c <=
'F')))))
1117N/A * All Strings START with a \" ... 1117N/A while ((c !=
'\"') && (c !=
'\n') && (c !=
'\r') && (c !=
'\0'));
1117N/A * ... and now we MUST have a valid token. The search is 1117N/A * handled later along with the pushed tokens. 1117N/A while ((c !=
' ') && (c !=
'\t') && (c !=
'\n') && (c !=
'\r') && (c !=
'\0') && (c !=
'#'));
1117N/A * Here we deal with pushed tokens. Reinitialize pushToken again. If 1117N/A * the pushed token was NUMBER || STRING return them again ... 1117N/A * Joop, at last we have to lookup the token ... 1117N/A * Read tokens from the configuration file until a non-COMMENT 1117N/A * token is encountered. No symbol table is provided for token 1117N/A * lookup. Unless no comment pointer is provided by the caller, 1117N/A * append any COMMENT text to the dynamically grown string of 1117N/A * comments. Return the code for the non-COMMENT token. 1117N/A * Read tokens from the configuration file until a non-COMMENT 1117N/A * token is encountered. A symbol table is provided for token 1117N/A * lookup. Unless no comment pointer is provided by the caller, 1117N/A * append any COMMENT text to the dynamically grown string of 1117N/A * comments. Return the code for the non-COMMENT token. 1117N/A/* A path is "safe" if it is relative and if it contains no ".." elements. */ 1117N/A /* Look for leading "../" */ 1117N/A /* Look for trailing "/.." */ 1117N/A * This function substitutes the following escape sequences: 1117N/A * %A cmdline argument as an absolute path (must be absolute to match) 1117N/A * %R cmdline argument as a relative path 1117N/A * %S cmdline argument as a "safe" path (relative, and no ".." elements) 1117N/A * %E config file environment ($XORGCONFIG) as an absolute path 1117N/A * %F config file environment ($XORGCONFIG) as a relative path 1117N/A * %G config file environment ($XORGCONFIG) as a safe path 1117N/A * %& UNIXOS2 only: prepend X11ROOT env var 1117N/A * This function takes a config file search path (optional), a command-line 1117N/A * specified file name (optional) and the ProjectRoot path (optional) and 1117N/A * locates and opens a config file based on that information. This 1117N/A * function will fail if a command-line file name is specified and there 1117N/A * is no %A, %R, or %S escape sequence in the effective search path. 1117N/A * The return value is a pointer to the actual name of the file that was 1117N/A * opened. When no file is found, the return value is NULL. 1117N/A * The escape sequences allowed in the search path are defined above. The 1117N/A * default search path is defined below. 1117N/A };
/* Substitutions for %X */ 1117N/A /* Initialize global variables for the scanner */ 1117N/A /* Be sure there's a non-empty search path and a scratch buffer */ 1117N/A /* Be sure there's a non-empty project root to substitute for %P */ 1117N/A /* Repeat for each config filename that can be substituted for %X */ 1117N/A /* Repeat for each comma-separated pathname template */ 1117N/A /* Construct a config pathname from the template */ 1117N/A /* Open the path unless a provided name wasn't used */ 1117N/A /* Discard the failed config pathname */ 1117N/A * This function takes a config file search path (optional), a command-line 1117N/A * specified file name (optional) and the ProjectRoot path (optional) and 1117N/A * locates and opens a config file based on that information. This 1117N/A * function will fail if a command-line file name is specified and there 1117N/A * is no %A, %R, or %S escape sequence in the effective search path. 1117N/A * The return value is a pointer to the actual name of the file that was 1117N/A * opened. When no file is found, the return value is NULL. 1117N/A * The escape sequences allowed in the search path are defined above. 1117N/A * Release all dynamically allocated memory used to scan the 1117N/A * Release all dynamically allocated memory used to scan the 1117N/A * configuration file. Close the input configuration file, else 1117N/A * discard the in-memory configuration text. 1117N/A * Lookup a string if it is actually a token in disguise. 1117N/A * xf86nameCompareResumable() 1117N/A * Compare two name-like strings pointed to by s1 and s2. Ignore 1117N/A * alphabetic case and the characters, '_', ' ', and '\t'. If s2 1117N/A * matches the initial characters of s1 then return a pointer to the 1117N/A * next character of s1 via s1resume (where further comparison could 1117N/A * be resumed). Otherwise return NULL via s1resume. Return the 1117N/A * conventional negative, zero, or positive value to indicate the 1117N/A * result of the basic comparison. 1117N/A int c1;
/* Normalized character from s1 */ 1117N/A int c2;
/* Normalized character from s2 */ 1117N/A return (-
1);
/* Behave as if NULL < non-NULL */ 1117N/A return (
1);
/* Behave as if non-NULL > NULL */ 1117N/A /* s1 matches s2 or contains s2 as a prefix */ 1117N/A * Compare two name-like strings pointed to by s1 and s2. Ignore 1117N/A * alphabetic case and the characters, '_', ' ', and '\t'. Return 1117N/A * the conventional negative, zero, or positive value to indicate the 1117N/A * result of the comparison. 1117N/A * Compare the name strings, s1 and s2 1117N/A * Determine whether s2 matches all of or just part of s1 1117N/A * Note that s1resume will not be NULL if result is 1117N/A * Return the final result of the comparison 1117N/A * Look up an option name in an array of known Boolean option names. 1117N/A * Note that a Boolean option name can have a "No" prefix. If found, 1117N/A * return the array subscript of the Boolean option name. Otherwise 1117N/A int i;
/* Index into option name array */ 1117N/A * Look up the option name, which can be negated using a "No" prefix 1117N/A * See whether this is a plain instance of the option name 1117N/A return (i);
/* Have a match */ 1117N/A * See whether this is a negated instance of the option name 1117N/A return (i);
/* Have a match */ 1117N/A * Not the name of a known Boolean option 1117N/A * Compare two option names pointed to by s1 and s2. Ignore 1117N/A * alphabetic case and the characters, '_', ' ', and '\t'. For names 1117N/A * of known Boolean options (provided via bool_option_names[]), any 1117N/A * "No" prefix is ignored. Return the usual negative, zero, or 1117N/A * positive values to indicate the results of the comparison. 1117N/A * To see why we want a list of known Boolean option names, consider 1117N/A * * Can we tell from this hypothetical example whether "Tables" 1117N/A * is the name of a Boolean option, which could be negated? 1117N/A * * Can we tell whether "Notables" is the opposite of "Tables"? 1117N/A * * Is the opposite of the documented Boolean option, 1117N/A * "NoTrapSignals", intended to be "NoNoTrapSignals" or 1117N/A * "TrapSignals"? Ditto for "NoPM" and "NoInt10". 1117N/A int i;
/* Index of option name, else -1 */ 1117N/A return (0);
/* Known Boolean option names match */