forked from dyninc/OpenBFDD
-
Notifications
You must be signed in to change notification settings - Fork 1
/
compat.cpp
33 lines (29 loc) · 922 Bytes
/
compat.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**************************************************************
* Copyright (c) 2010-2013, Dynamic Network Services, Inc.
* Jake Montgomery ([email protected]) & Tom Daly ([email protected])
* Distributed under the FreeBSD License - see LICENSE
***************************************************************/
#include "standard.h"
#include <string.h>
#include <cstdio>
using namespace std;
#ifndef HAS_STRERROR_R
#error no strerror_r() function found.
#endif
#ifdef IS_ISO_STRERROR_R
void compat_strerror_r(int errnum, char *buf, size_t buflen)
{
int ret = strerror_r(errnum, buf, buflen);
if (ret != 0)
snprintf(buf, buflen, "Error %d", errnum);
}
#elif defined(IS_GNU_STRERROR_R)
void compat_strerror_r(int errnum, char *buf, size_t buflen)
{
char *ret = strerror_r(errnum, buf, buflen);
if (ret != buf)
snprintf(buf, buflen, "%s", ret);
}
#else
#error no compatible strerror_r() function found.
#endif