Home | History | Annotate | Download | only in patches
      1 Index: tdb/tdb.c
      2 ===================================================================
      3 --- tdb.orig/tdb.c
      4 +++ tdb/tdb.c
      5 @@ -29,11 +29,82 @@ Last Changed Date: 2007-06-22 13:36:10 -
      6     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
      7  */
      8  
      9 -#include "replace.h"
     10 -#include "system/filesys.h"
     11 -#include "system/time.h"
     12 -#include "system/shmem.h"
     13 -#include "system/select.h"
     14 +#ifdef CONFIG_STAND_ALONE
     15 +#define HAVE_MMAP
     16 +#define HAVE_STRDUP
     17 +#define HAVE_SYS_MMAN_H
     18 +#define HAVE_UTIME_H
     19 +#define HAVE_UTIME
     20 +#endif
     21 +#define _XOPEN_SOURCE 500
     22 +
     23 +#include <unistd.h>
     24 +#include <stdio.h>
     25 +#include <stdlib.h>
     26 +#include <stdarg.h>
     27 +#include <stddef.h>
     28 +#include <errno.h>
     29 +#include <string.h>
     30 +#ifdef HAVE_SYS_SELECT_H
     31 +#include <sys/select.h>
     32 +#endif
     33 +#include <sys/time.h>
     34 +#include <sys/types.h>
     35 +#include <time.h>
     36 +#ifdef HAVE_UTIME_H
     37 +#include <utime.h>
     38 +#endif
     39 +#include <sys/stat.h>
     40 +#include <sys/file.h>
     41 +#include <fcntl.h>
     42 +
     43 +#ifdef HAVE_SYS_MMAN_H
     44 +#include <sys/mman.h>
     45 +#endif
     46 +
     47 +#ifndef MAP_FILE
     48 +#define MAP_FILE 0
     49 +#endif
     50 +
     51 +#ifndef MAP_FAILED
     52 +#define MAP_FAILED ((void *)-1)
     53 +#endif
     54 +
     55 +#ifndef HAVE_STRDUP
     56 +#define strdup rep_strdup
     57 +static char *rep_strdup(const char *s)
     58 +{
     59 +	char *ret;
     60 +	int length;
     61 +	if (!s)
     62 +		return NULL;
     63 +
     64 +	if (!length)
     65 +		length = strlen(s);
     66 +
     67 +	ret = malloc(length + 1);
     68 +	if (ret) {
     69 +		strncpy(ret, s, length);
     70 +		ret[length] = '\0';
     71 +	}
     72 +	return ret;
     73 +}
     74 +#endif
     75 +
     76 +#ifndef PRINTF_ATTRIBUTE
     77 +#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 )
     78 +/** Use gcc attribute to check printf fns.  a1 is the 1-based index of
     79 + * the parameter containing the format, and a2 the index of the first
     80 + * argument. Note that some gcc 2.x versions don't handle this
     81 + * properly **/
     82 +#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
     83 +#else
     84 +#define PRINTF_ATTRIBUTE(a1, a2)
     85 +#endif
     86 +#endif
     87 +
     88 +typedef int bool;
     89 +
     90  #include "tdb.h"
     91  
     92  #ifndef u32
     93