/*-
* See the file LICENSE for redistribution information.
*
* Copyright (c) 1997, 1998
* Sleepycat Software. All rights reserved.
*/
#include "config.h"
#ifndef lint
#endif /* not lint */
#ifndef NO_SYSTEM_INCLUDES
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#endif
#include "db_int.h"
#include "db_dispatch.h"
#include "shqueue.h"
#include "log.h"
#include "common_ext.h"
#include "clib_ext.h" /* XXX: needed for getcwd. */
/*
* log_archive --
* Supporting function for db_archive(1).
*/
int
char ***listp;
{
if (flags != 0) {
if ((ret =
return (ret);
if ((ret =
return (ret);
}
/*
* Get the absolute pathname of the current directory. It would
* be nice to get the shortest pathname of the database directory,
* but that's just not possible.
*/
if (LF_ISSET(DB_ARCH_ABS)) {
errno = 0;
} else
switch (LF_ISSET(~DB_ARCH_ABS)) {
case DB_ARCH_DATA:
case DB_ARCH_LOG:
return (ret);
break;
case 0:
/*
* A return of DB_NOTFOUND means that we didn't find
* any records in the log (so we are not going to be
* deleting any log files).
*/
if (ret != DB_NOTFOUND)
return (ret);
return (0);
}
/* Remove any log files before the last stable LSN. */
break;
}
/* Get some initial space. */
array_size = 10;
return (ret);
/* Build an array of the file names. */
goto err;
break;
}
if (n >= array_size - 1) {
sizeof(char *) * array_size)) != 0)
goto err;
}
if (LF_ISSET(DB_ARCH_ABS)) {
goto err;
goto err;
} else
}
/* If there's nothing to return, we're done. */
if (n == 0) {
ret = 0;
goto err;
}
/* Sort the list. */
/* Rework the memory. */
goto err;
return (0);
}
return (ret);
}
/*
* __build_data --
* Build a list of datafiles for return.
*/
static int
{
/* Get some initial space. */
array_size = 10;
return (ret);
goto lg_free;
}
if (rectype != DB_log_register) {
}
continue;
}
"log_archive: unable to read log record");
goto lg_free;
}
if (n >= array_size - 1) {
sizeof(char *) * array_size)) != 0)
goto lg_free;
}
goto err1;
}
}
}
/* If there's nothing to return, we're done. */
if (n == 0) {
ret = 0;
goto err1;
}
/* Sort the list. */
/*
* Build the real pathnames, discarding nonexistent files and
* duplicates.
*/
/*
* Discard duplicates. Last is the next slot we're going
* to return to the user, nxt is the next slot that we're
* going to consider.
*/
}
}
/* Get the real name. */
goto err2;
/* If the file doesn't exist, ignore it. */
continue;
}
/* Rework the name as requested by the user. */
if (ret != 0)
goto err2;
if (ret != 0)
goto err2;
} else
++last;
}
/* NULL-terminate the list. */
/* Rework the memory. */
goto err1;
return (0);
err2: /*
* XXX
* We've possibly inserted NULLs into the array list, so clean up a
* bit so that the other error processing works.
*/
/* FALLTHROUGH */
}
return (ret);
}
/*
* __absname --
* Return an absolute path name for the file.
*/
static int
{
char *newname;
/* Malloc space for concatenating the two. */
return (ret);
/* Build the name. If `name' is an absolute path, ignore any prefix. */
if (!isabspath) {
}
return (0);
}
/*
* __usermem --
* Create a single chunk of memory that holds the returned information.
* If the user has their own malloc routine, use it.
*/
static int
char ***listp;
{
int ret;
/* Find out how much space we need. */
len += sizeof(char *);
/* Allocate it and set up the pointers. */
return (ret);
/* Copy the original information into the new memory. */
__os_freestr(*orig);
}
/* NULL-terminate the list. */
return (0);
}
static int
{
}