compat.c revision bff6afb9717f2ec7dafa20c4e2b7f00236ec7bfe
/* Copyright (c) 2002-2009 Dovecot authors, see the included COPYING file */
#include "config.h"
/* Linux needs the _XOPEN_SOURCE define, but others don't. It needs to be
#ifdef PREAD_WRAPPERS
#endif
#define IN_COMPAT_C
#include "lib.h"
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <unistd.h>
#include <syslog.h>
#include <time.h>
#ifdef HAVE_INTTYPES_H
# include <inttypes.h> /* for strtoimax() and strtoumax() */
#endif
#ifndef INADDR_NONE
# define INADDR_NONE INADDR_BROADCAST
#endif
#if !defined (HAVE_STRCASECMP) && !defined (HAVE_STRICMP)
{
}
}
{
}
}
#endif
#ifndef HAVE_INET_ATON
{
if (addr == INADDR_NONE)
return 0;
return 1;
}
#endif
#ifndef HAVE_VSYSLOG
{
T_BEGIN {
} T_END;
}
#endif
#ifndef HAVE_GETPAGESIZE
int i_my_getpagesize(void)
{
#ifdef _SC_PAGESIZE
return sysconf(_SC_PAGESIZE);
#else
# ifdef __GNUC__
# endif
return 4096;
#endif
}
#endif
#ifndef HAVE_WRITEV
{
int i;
written = 0;
if (ret < 0)
return -1;
break;
}
if (written > SSIZE_T_MAX) {
return -1;
}
}
#endif
#if !defined(HAVE_PREAD) || defined(PREAD_BROKEN)
{
if (old_offset == -1)
return -1;
return -1;
if (ret < 0)
return -1;
return -1;
return ret;
}
{
if (old_offset == -1)
return -1;
return -1;
if (ret < 0)
return -1;
return -1;
return ret;
}
#elif defined(PREAD_WRAPPERS)
{
return ret;
}
{
}
#endif
#ifndef HAVE_SETEUID
{
#ifdef HAVE_SETREUID
/* HP-UX at least doesn't have seteuid() but has setreuid() */
#else
#endif
}
#endif
#ifndef HAVE_SETEGID
{
#ifdef HAVE_SETRESGID
/* HP-UX at least doesn't have setegid() but has setresgid() */
#else
#endif
}
#endif
#ifndef HAVE_LIBGEN_H
char *i_my_basename(char *path)
{
char *p;
/* note that this isn't POSIX-compliant basename() replacement.
too much trouble without any gain. */
}
#endif
#ifndef HAVE_STRTOULL
{
#ifdef HAVE_STRTOUMAX
#elif defined(HAVE_STRTOUQ)
#else
unsigned long ret = 0;
/* we support only base-10 in our fallback implementation.. */
break;
}
return ret;
#endif
}
#endif
#ifndef HAVE_STRTOLL
{
#ifdef HAVE_STRTOIMAX
#elif defined (HAVE_STRTOQ)
#else
i_panic("strtoll() not implemented");
#endif
}
#endif
#ifdef HAVE_OLD_VSNPRINTF
{
char *tmp;
int ret;
/* On overflow HP-UX returns -1, IRIX and Tru64 return size-1. */
return ret;
/* see if data stack has enough available space for it */
if (size > 0) {
}
return ret;
}
} else {
}
/* try to allocate enough memory to get it to fit. */
do {
if (size > 0) {
}
return ret;
}
i_panic("my_vsnprintf(): Output string too big");
}
#endif
#ifndef HAVE_CLOCK_GETTIME
{
/* fallback to using microseconds */
return -1;
return 0;
}
#endif