converted the arc4* function wrappers to makros

This commit is contained in:
git@daemon.de
2014-03-17 17:06:14 +01:00
parent 2e337c3aeb
commit 9e234600ca
2 changed files with 20 additions and 40 deletions

View File

@@ -67,58 +67,51 @@
#ifndef HAVE_ARC4RANDOM #ifndef HAVE_ARC4RANDOM
#include <sodium.h> #include <sodium.h>
u_int32_t arc4random(); #define arc4random() randombytes_random()
#endif #endif
#ifndef HAVE_ARC4RANDOM_BUF #ifndef HAVE_ARC4RANDOM_BUF
#include <sodium.h> #include <sodium.h>
void arc4random_buf(void *buf, size_t nbytes); #define arc4random_buf(buf, nbytes) randombytes((byte *)buf, nbytes)
#endif #endif
#ifndef HAVE_ERR_H #ifndef HAVE_ERR_H
#include <errno.h>
#include <errno.h> #include <string.h>
#include <string.h> #include <stdarg.h>
#include <stdarg.h> #include <stdio.h>
#include <stdio.h> void err(int eval, const char *fmt, ...);
void err(int eval, const char *fmt, ...);
#else #else
#include <errno.h>
#include <errno.h> #include <err.h>
#include <err.h>
#endif #endif
#ifndef HAVE_VASPRINTF #ifndef HAVE_VASPRINTF
#include <stdarg.h>
#include <stdarg.h> int vasprintf(char **ret, const char *format, va_list args);
int vasprintf(char **ret, const char *format, va_list args);
#endif #endif
#ifdef _AIX_SOURCE #ifdef _AIX_SOURCE
#define _LINUX_SOURCE_COMPAT #define _LINUX_SOURCE_COMPAT
#endif #endif
#ifndef HAVE_STRNLEN #ifndef HAVE_STRNLEN
size_t size_t
strnlen(const char *msg, size_t maxlen); strnlen(const char *msg, size_t maxlen);
#endif #endif
#ifndef HAVE_STRNSTR #ifndef HAVE_STRNSTR
/* via FreeBSD libc */ /* via FreeBSD libc */
#include <string.h> #include <string.h>
char * char *
strnstr(const char *s, const char *find, size_t slen); strnstr(const char *s, const char *find, size_t slen);
#endif #endif
/* size_t format string */ /* size_t format string */

View File

@@ -21,19 +21,6 @@
#include "platform.h" #include "platform.h"
#ifndef HAVE_ARC4RANDOM
u_int32_t arc4random() {
return randombytes_random();
}
#endif
#ifndef HAVE_ARC4RANDOM_BUF
#include <sodium.h>
void arc4random_buf(void *buf, size_t nbytes) {
randombytes((unsigned char*)buf, nbytes);
}
#endif
#ifndef HAVE_ERR_H #ifndef HAVE_ERR_H
void err(int eval, const char *fmt, ...) { void err(int eval, const char *fmt, ...) {
va_list ap; va_list ap;