1N/A * See the file LICENSE for redistribution information. 1N/A * Copyright (c) 1996, 1997, 1998 1N/A * Sleepycat Software. All rights reserved. 1N/A#
endif /* not lint */ 1N/A * This conflict array is used for concurrent db access (cdb). It 1N/A * uses the same locks as the db_rw_conflict array, but adds an IW 1N/A * mode to be used for write cursors. 1N/A * Return version information. 1N/A * Initialize the application environment. 1N/A /* Validate arguments. */ 1N/A /* Transactions imply logging. */ 1N/A /* Convert the db_appinit(3) flags. */ 1N/A /* Set the database home. */ 1N/A /* Parse the config array. */ 1N/A * Parse the config file. 1N/A * Don't use sprintf(3)/snprintf(3) -- the former is dangerous, and 1N/A * the latter isn't standard, and we're manipulating strings handed 1N/A * us by the application. 1N/A /* Set up the tmp directory path. */ 1N/A * Flag that the structure has been initialized by the application. 1N/A * Note, this must be set before calling into the subsystems as it 1N/A * is used when we're doing file naming. 1N/A * If we are doing recovery, remove all the old shared memory 1N/A * Create the new shared regions. 1N/A * Default permissions are read-write for both owner and group. 1N/A * If the application is running with transactions, initialize the 1N/A * function tables. Once that's done, do recovery for any previous 1N/A * Close down the default application environment. 1N/A /* Close subsystems. */ 1N/A /* Clear initialized flag (after subsystems, it affects naming). */ 1N/A /* Free allocated memory. */ 1N/A /* If leading slash, start over. */ \
1N/A /* Append to the current string. */ \
1N/A * Given an optional DB environment, directory and file name and type 1N/A * of call, build a path based on the db_appinit(3) rules, and return 1N/A * it in allocated space. 1N/A * PUBLIC: int __db_appname __P((DB_ENV *, 1N/A * PUBLIC: APPNAME, const char *, const char *, u_int32_t, int *, char **)); 1N/A const char *a, *b, *c;
1N/A * We don't return a name when creating temporary files, just an fd. 1N/A * Default to error now. 1N/A * Absolute path names are never modified. If the file is an absolute 1N/A * path, we're done. If the directory is, simply append the file and 1N/A * DB_ENV DIR APPNAME RESULT 1N/A * ------------------------------------------- 1N/A * null null none <tmp>/file 1N/A * DB_ENV FILE APPNAME RESULT 1N/A * ------------------------------------------- 1N/A * null null DB_APP_DATA <tmp>/<create> 1N/A * null set DB_APP_DATA ./file 1N/A * set null DB_APP_DATA <tmp>/<create> 1N/A * DB_ENV DIR APPNAME RESULT 1N/A * ------------------------------------------- 1N/A * null null DB_APP_LOG <tmp>/file 1N/A * DB_ENV APPNAME RESULT 1N/A * ------------------------------------------- 1N/A * null DB_APP_TMP* <tmp>/<create> 1N/A "DB_APP_DATA: illegal directory specification");
1N/A "DB_APP_TMP: illegal directory or file specification");
1N/A /* Reference a file from the appropriate temporary directory. */ 1N/A * Allocate space to hold the current path information, as well as any 1N/A * temporary space that we're going to need to create a temporary file 1N/A /* Discard any space allocated to find the temp directory. */ 1N/A * If we're opening a data file, see if it exists. If it does, 1N/A * return it, otherwise, try and find another one to open. 1N/A /* Create the file if so requested. */ 1N/A * Find the database home. 1N/A /* Use the environment if it's permitted and initialized. */ 1N/A else if (p[0] ==
'\0') {
1N/A "illegal DB_HOME environment variable");
1N/A * Parse a single NAME VALUE pair. 1N/A * We need to strdup the argument in case the caller passed us 1N/A * Name/value pairs are parsed as two white-space separated strings. 1N/A * Leading and trailing white-space is trimmed from the value, but 1N/A * it may contain embedded white-space. Note: we use the isspace(3) 1N/A * macro because it's more portable, but that means that you can use 1N/A * characters like form-feed to separate the strings. 1N/A * Create a temporary file. 1N/A * Check the target directory; if you have six X's and it doesn't 1N/A * exist, this runs for a *very* long time. 1N/A /* Build the path. */ 1N/A * Replace the X's with the process ID. Pid should be a pid_t, 1N/A * but we use unsigned long for portability. 1N/A /* Set up open flags and mode. */ 1N/A /* Loop, trying to open a file. */ 1N/A * If we don't get an EEXIST error, then there's something 1N/A * seriously wrong. Unfortunately, if the implementation 1N/A * doesn't return EEXIST for O_CREAT and O_EXCL regardless 1N/A * of other possible errors, we've lost. 1N/A * Tricky little algorithm for backward compatibility. 1N/A * Assumes the ASCII ordering of lower-case characters.