mirror of
https://github.com/hufrea/byedpi.git
synced 2024-12-22 06:15:14 +00:00
Remove error.c
This commit is contained in:
parent
212d9c4b2d
commit
90d2a3e4f3
2
Makefile
2
Makefile
@ -1,7 +1,7 @@
|
||||
TARGET = ciadpi
|
||||
CC ?= gcc
|
||||
CFLAGS += -std=c99 -O2 -D_XOPEN_SOURCE=500
|
||||
SOURCES = packets.c main.c conev.c proxy.c desync.c error.c
|
||||
SOURCES = packets.c main.c conev.c proxy.c desync.c
|
||||
|
||||
all:
|
||||
$(CC) $(CFLAGS) $(SOURCES) -I . -o $(TARGET)
|
||||
|
46
error.c
46
error.c
@ -1,46 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
int unie(int e)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
switch (e) {
|
||||
case WSAEWOULDBLOCK:
|
||||
return EAGAIN;
|
||||
case WSAETIMEDOUT:
|
||||
return ETIMEDOUT;
|
||||
case WSAENETUNREACH:
|
||||
return ENETUNREACH;
|
||||
case WSAEHOSTUNREACH:
|
||||
return EHOSTUNREACH;
|
||||
case WSAECONNREFUSED:
|
||||
return ECONNREFUSED;
|
||||
}
|
||||
#endif
|
||||
return e;
|
||||
}
|
||||
|
||||
int get_e()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
int e = WSAGetLastError();
|
||||
return unie(e);
|
||||
#else
|
||||
return errno;
|
||||
#endif
|
||||
}
|
||||
|
||||
void uniperror(char *str)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
int e = WSAGetLastError();
|
||||
fprintf(stderr, "%s: %d\n", str, e);
|
||||
#else
|
||||
perror(str);
|
||||
#endif
|
||||
}
|
45
error.h
45
error.h
@ -1,4 +1,41 @@
|
||||
int unie(int e);
|
||||
void uniperror(char *str);
|
||||
int get_e();
|
||||
void uniperror(char *str);
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define get_e() \
|
||||
unie(WSAGetLastError())
|
||||
#else
|
||||
#define get_e() \
|
||||
errno
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define uniperror(str) \
|
||||
fprintf(stderr, "%s: %d\n", str, WSAGetLastError())
|
||||
#else
|
||||
#define uniperror(str) \
|
||||
perror(str)
|
||||
#endif
|
||||
|
||||
inline const int unie(int e)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
switch (e) {
|
||||
case WSAEWOULDBLOCK:
|
||||
return EAGAIN;
|
||||
case WSAETIMEDOUT:
|
||||
return ETIMEDOUT;
|
||||
case WSAENETUNREACH:
|
||||
return ENETUNREACH;
|
||||
case WSAEHOSTUNREACH:
|
||||
return EHOSTUNREACH;
|
||||
case WSAECONNREFUSED:
|
||||
return ECONNREFUSED;
|
||||
}
|
||||
#endif
|
||||
return e;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user