version 1.62, 2013/06/06 02:40:37 |
version 1.63, 2013/06/06 15:15:07 |
|
|
|
|
#include <assert.h> |
#include <assert.h> |
#include <ctype.h> |
#include <ctype.h> |
|
#include <errno.h> |
#include <fcntl.h> |
#include <fcntl.h> |
#include <fts.h> |
#include <fts.h> |
#include <getopt.h> |
#include <getopt.h> |
|
|
dbclose(int real) |
dbclose(int real) |
{ |
{ |
size_t i; |
size_t i; |
char file[PATH_MAX]; |
|
|
|
if (nodb) |
if (nodb) |
return; |
return; |
Line 1880 dbclose(int real) |
|
Line 1880 dbclose(int real) |
|
if (real) |
if (real) |
return; |
return; |
|
|
strlcpy(file, MANDOC_DB, PATH_MAX); |
if (-1 == rename(MANDOC_DB "~", MANDOC_DB)) { |
strlcat(file, "~", PATH_MAX); |
|
if (-1 == rename(file, MANDOC_DB)) { |
|
exitcode = (int)MANDOCLEVEL_SYSERR; |
exitcode = (int)MANDOCLEVEL_SYSERR; |
say(MANDOC_DB, NULL); |
say(MANDOC_DB, NULL); |
} |
} |
Line 1899 dbclose(int real) |
|
Line 1897 dbclose(int real) |
|
static int |
static int |
dbopen(int real) |
dbopen(int real) |
{ |
{ |
char file[PATH_MAX]; |
const char *file, *sql; |
const char *sql; |
|
int rc, ofl; |
int rc, ofl; |
size_t sz; |
|
|
|
if (nodb) |
if (nodb) |
return(1); |
return(1); |
|
|
sz = strlcpy(file, MANDOC_DB, PATH_MAX); |
ofl = SQLITE_OPEN_READWRITE; |
if ( ! real) |
if (0 == real) { |
sz = strlcat(file, "~", PATH_MAX); |
file = MANDOC_DB "~"; |
|
if (-1 == remove(file) && ENOENT != errno) { |
if (sz >= PATH_MAX) { |
exitcode = (int)MANDOCLEVEL_SYSERR; |
fprintf(stderr, "%s: Path too long\n", file); |
say(file, NULL); |
return(0); |
return(0); |
} |
} |
|
ofl |= SQLITE_OPEN_EXCLUSIVE; |
if ( ! real) |
} else |
remove(file); |
file = MANDOC_DB; |
|
|
ofl = SQLITE_OPEN_READWRITE | |
|
(0 == real ? SQLITE_OPEN_EXCLUSIVE : 0); |
|
|
|
rc = sqlite3_open_v2(file, &db, ofl, NULL); |
rc = sqlite3_open_v2(file, &db, ofl, NULL); |
if (SQLITE_OK == rc) |
if (SQLITE_OK == rc) |