2 * See the file LICENSE for redistribution information.
4 * Copyright (c) 1996, 1997
5 * Sleepycat Software. All rights reserved.
11 static const char copyright[] =
12 "@(#) Copyright (c) 1997\n\
13 Sleepycat Software Inc. All rights reserved.\n";
14 static const char sccsid[] = "@(#)db_archive.c 10.12 (Sleepycat) 7/25/97";
17 #ifndef NO_SYSTEM_INCLUDES
18 #include <sys/types.h>
31 #include "db_dispatch.h"
33 #include "common_ext.h"
35 DB_ENV *db_init __P((char *, int));
36 void onint __P((int));
37 void siginit __P((void));
38 void usage __P((void));
39 int main __P((int, char *[]));
42 const char *progname = "db_archive"; /* Program name. */
52 int ch, flags, verbose;
57 while ((ch = getopt(argc, argv, "ah:lsv")) != EOF)
69 flags |= DB_ARCH_DATA;
84 /* Initialize the environment. */
85 dbenv = db_init(home, verbose);
87 /* Get the list of names. */
88 if ((errno = log_archive(dbenv->lg_info, &list, flags, NULL)) != 0) {
89 (void)db_appexit(dbenv);
90 err(1, "log_archive");
93 /* Print the names. */
95 for (; *list != NULL; ++list)
96 printf("%s\n", *list);
98 return (db_appexit(dbenv) ? 1 : 0);
103 * Initialize the environment.
106 db_init(home, verbose)
112 if ((dbenv = (DB_ENV *)calloc(sizeof(DB_ENV), 1)) == NULL) {
116 dbenv->db_errfile = stderr;
117 dbenv->db_errpfx = progname;
118 dbenv->db_verbose = verbose;
120 if ((errno = db_appinit(home, NULL, dbenv,
121 DB_CREATE | DB_INIT_LOG | DB_INIT_TXN | DB_USE_ENVIRON)) != 0)
122 err(1, "db_appinit");
131 * Initialize the set of signals for which we want to clean up.
132 * Generally, we try not to leave the shared regions locked if
139 (void)signal(SIGHUP, onint);
141 (void)signal(SIGINT, onint);
143 (void)signal(SIGKILL, onint);
145 (void)signal(SIGTERM, onint);
150 * Interrupt signal handler.
156 if ((interrupted = signo) == 0)
157 interrupted = SIGINT;
163 (void)fprintf(stderr, "usage: db_archive [-alsv] [-h home]\n");