2
* See the file LICENSE for redistribution information.
4
* Copyright (c) 1996-2001
5
* Sleepycat Software. All rights reserved.
11
static const char copyright[] =
12
"Copyright (c) 1996-2001\nSleepycat Software Inc. All rights reserved.\n";
13
static const char revid[] =
14
"$Id: db_archive.c,v 11.23 2001/05/10 17:13:55 bostic Exp $";
17
#ifndef NO_SYSTEM_INCLUDES
18
#include <sys/types.h>
26
#include "common_ext.h"
29
int main __P((int, char *[]));
30
void usage __P((void));
31
void version_check __P((void));
35
*progname = "db_archive"; /* Program name. */
45
int ch, e_close, exitval, ret, verbose;
46
char **file, *home, **list;
51
e_close = exitval = verbose = 0;
53
while ((ch = getopt(argc, argv, "ah:lsVv")) != EOF)
68
printf("%s\n", db_version(NULL, NULL, NULL));
69
return (EXIT_SUCCESS);
83
/* Handle possible interruptions. */
87
* Create an environment object and initialize it for error
90
if ((ret = db_env_create(&dbenv, 0)) != 0) {
92
"%s: db_env_create: %s\n", progname, db_strerror(ret));
97
dbenv->set_errfile(dbenv, stderr);
98
dbenv->set_errpfx(dbenv, progname);
101
(void)dbenv->set_verbose(dbenv, DB_VERB_CHKPOINT, 1);
104
* If attaching to a pre-existing environment fails, create a
105
* private one and try again.
107
if ((ret = dbenv->open(dbenv,
108
home, DB_JOINENV | DB_USE_ENVIRON, 0)) != 0 &&
109
(ret = dbenv->open(dbenv, home, DB_CREATE |
110
DB_INIT_LOG | DB_INIT_TXN | DB_PRIVATE | DB_USE_ENVIRON, 0)) != 0) {
111
dbenv->err(dbenv, ret, "open");
115
/* Get the list of names. */
116
if ((ret = log_archive(dbenv, &list, flags)) != 0) {
117
dbenv->err(dbenv, ret, "log_archive");
121
/* Print the list of names. */
123
for (file = list; *file != NULL; ++file)
124
printf("%s\n", *file);
125
__os_free(dbenv, list, 0);
129
shutdown: exitval = 1;
131
if (e_close && (ret = dbenv->close(dbenv, 0)) != 0) {
134
"%s: dbenv->close: %s\n", progname, db_strerror(ret));
137
/* Resend any caught signal. */
138
__db_util_sigresend();
140
return (exitval == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
146
(void)fprintf(stderr, "usage: db_archive [-alsVv] [-h home]\n");
153
int v_major, v_minor, v_patch;
155
/* Make sure we're loaded with the right version of the DB library. */
156
(void)db_version(&v_major, &v_minor, &v_patch);
157
if (v_major != DB_VERSION_MAJOR ||
158
v_minor != DB_VERSION_MINOR || v_patch != DB_VERSION_PATCH) {
160
"%s: version %d.%d.%d doesn't match library version %d.%d.%d\n",
161
progname, DB_VERSION_MAJOR, DB_VERSION_MINOR,
162
DB_VERSION_PATCH, v_major, v_minor, v_patch);