Blame src/microhttpd/mhd_compat.h

Packit 875988
/*
Packit 875988
  This file is part of libmicrohttpd
Packit 875988
  Copyright (C) 2014-2016 Karlson2k (Evgeny Grin)
Packit 875988
Packit 875988
  This library is free software; you can redistribute it and/or
Packit 875988
  modify it under the terms of the GNU Lesser General Public
Packit 875988
  License as published by the Free Software Foundation; either
Packit 875988
  version 2.1 of the License, or (at your option) any later version.
Packit 875988
Packit 875988
  This library is distributed in the hope that it will be useful,
Packit 875988
  but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 875988
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 875988
  Lesser General Public License for more details.
Packit 875988
Packit 875988
  You should have received a copy of the GNU Lesser General Public
Packit 875988
  License along with this library; if not, write to the Free Software
Packit 875988
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
Packit 875988
Packit 875988
*/
Packit 875988
Packit 875988
/**
Packit 875988
 * @file microhttpd/mhd_compat.h
Packit 875988
 * @brief  Header for platform missing functions.
Packit 875988
 * @author Karlson2k (Evgeny Grin)
Packit 875988
 *
Packit 875988
 * Provides compatibility for platforms with some missing
Packit 875988
 * functionality.
Packit 875988
 * Any functions can be implemented as macro on some platforms
Packit 875988
 * unless explicitly marked otherwise.
Packit 875988
 * Any function argument can be skipped in macro, so avoid
Packit 875988
 * variable modification in function parameters.
Packit 875988
 */
Packit 875988
Packit 875988
#ifndef MHD_COMPAT_H
Packit 875988
#define MHD_COMPAT_H 1
Packit 875988
Packit 875988
#include "mhd_options.h"
Packit 875988
#include <stdlib.h>
Packit 875988
#ifdef HAVE_STRING_H /* for strerror() */
Packit 875988
#include <string.h>
Packit 875988
#endif /* HAVE_STRING_H */
Packit 875988
Packit 875988
 /* MHD_strerror_ is strerror */
Packit 875988
#define MHD_strerror_(errnum) strerror((errnum))
Packit 875988
Packit 875988
/* Platform-independent snprintf name */
Packit 875988
#if defined(HAVE_SNPRINTF)
Packit 875988
#define MHD_snprintf_ snprintf
Packit 875988
#else  /* ! HAVE_SNPRINTF */
Packit 875988
#if defined(_WIN32) && ! defined(__CYGWIN__)
Packit 875988
/* Emulate snprintf function on W32 */
Packit 875988
int W32_snprintf(char *__restrict s, size_t n, const char *__restrict format, ...);
Packit 875988
#define MHD_snprintf_ W32_snprintf
Packit 875988
#else  /* ! _WIN32 || __CYGWIN__ */
Packit 875988
#error Your platform does not support snprintf() and MHD does not know how to emulate it on your platform.
Packit 875988
#endif /* ! _WIN32 || __CYGWIN__ */
Packit 875988
#endif /* ! HAVE_SNPRINTF */
Packit 875988
Packit 875988
#ifdef HAVE_RANDOM
Packit 875988
/**
Packit 875988
 * Generate pseudo random number at least 30-bit wide.
Packit 875988
 * @return pseudo random number at least 30-bit wide.
Packit 875988
 */
Packit 875988
#define MHD_random_() random()
Packit 875988
#else  /* HAVE_RANDOM */
Packit 875988
#ifdef HAVE_RAND
Packit 875988
/**
Packit 875988
 * Generate pseudo random number at least 30-bit wide.
Packit 875988
 * @return pseudo random number at least 30-bit wide.
Packit 875988
 */
Packit 875988
#define MHD_random_() ( (((long)rand()) << 15) + (long)rand() )
Packit 875988
#endif /* HAVE_RAND */
Packit 875988
#endif /* HAVE_RANDOM */
Packit 875988
Packit 875988
#ifdef HAVE_CALLOC
Packit 875988
/**
Packit 875988
 * MHD_calloc_ is platform-independent calloc()
Packit 875988
 */
Packit 875988
#define MHD_calloc_(n,s) calloc((n),(s))
Packit 875988
#else  /* ! HAVE_CALLOC */
Packit 875988
/**
Packit 875988
 * MHD_calloc_ is platform-independent calloc()
Packit 875988
 */
Packit 875988
void *MHD_calloc_(size_t nelem, size_t elsize);
Packit 875988
#endif /* ! HAVE_CALLOC */
Packit 875988
Packit 875988
#endif /* MHD_COMPAT_H */