int flags;
u_int32_t flags;
log_archive(dblp, listp, flags, db_malloc)	DB_LOG *dblp;	char ***listp;	int flags;	void *(*db_malloc) __P((size_t));{	DBT rec;	DB_LSN stable_lsn;	u_int32_t fnum;	int array_size, n, ret;	char **array, **arrayp, *name, *p, *pref, buf[MAXPATHLEN];	COMPQUIET(fnum, 0);#define	OKFLAGS	(DB_ARCH_ABS | DB_ARCH_DATA | DB_ARCH_LOG)	if (flags != 0) {		if ((ret =		    __db_fchk(dblp->dbenv, "log_archive", flags, OKFLAGS)) != 0)			return (ret);		if ((ret =		    __db_fcchk(dblp->dbenv,		        "log_archive", flags, DB_ARCH_DATA, DB_ARCH_LOG)) != 0)			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;		if ((pref = getcwd(buf, sizeof(buf))) == NULL)			return (errno == 0 ? ENOMEM : errno);	} else		pref = NULL;	switch (LF_ISSET(~DB_ARCH_ABS)) {	case DB_ARCH_DATA:		return (__build_data(dblp, pref, listp, db_malloc));	case DB_ARCH_LOG:		memset(&rec, 0, sizeof(rec));		if (F_ISSET(dblp, DB_AM_THREAD))			F_SET(&rec, DB_DBT_MALLOC);		if ((ret = log_get(dblp, &stable_lsn, &rec, DB_LAST)) != 0)			return (ret);		if (F_ISSET(dblp, DB_AM_THREAD))			__db_free(rec.data);		fnum = stable_lsn.file;		break;	case 0:		if ((ret = __log_findckp(dblp, &stable_lsn)) != 0) {			if (ret != DB_NOTFOUND)				return (ret);			*listp = NULL;			return (0);		}		/* Remove any log files before the last stable LSN. */		fnum = stable_lsn.file - 1;		break;	}#define	LIST_INCREMENT	64	/* Get some initial space. */	if ((array =	    (char **)__db_malloc(sizeof(char *) * (array_size = 10))) == NULL)		return (ENOMEM);	array[0] = NULL;	/* Build an array of the file names. */	for (n = 0; fnum > 0; --fnum) {		if ((ret = __log_name(dblp, fnum, &name)) != 0)			goto err;		if (__db_exists(name, NULL) != 0)			break;		if (n >= array_size - 1) {			array_size += LIST_INCREMENT;			if ((array = (char **)__db_realloc(array,			    sizeof(char *) * array_size)) == NULL) {				ret = ENOMEM;				goto err;			}		}		if (LF_ISSET(DB_ARCH_ABS)) {			if ((ret = __absname(pref, name, &array[n])) != 0)				goto err;			FREES(name);		} else if ((p = __db_rpath(name)) != NULL) {			if ((array[n] = (char *)__db_strdup(p + 1)) == NULL) {				ret = ENOMEM;				goto err;			}			FREES(name);		} else			array[n] = name;		array[++n] = NULL;	}	/* If there's nothing to return, we're done. */	if (n == 0) {		*listp = NULL;		ret = 0;		goto err;	}	/* Sort the list. */	qsort(array, (size_t)n, sizeof(char *), __cmpfunc);	/* Rework the memory. */	if ((ret = __usermem(&array, db_malloc)) != 0)		goto err;	*listp = array;	return (0);err:	if (array != NULL) {		for (arrayp = array; *arrayp != NULL; ++arrayp)			FREES(*arrayp);		__db_free(array);	}	return (ret);}