-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdummies.cpp
127 lines (123 loc) · 2.44 KB
/
dummies.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include <stdexcept>
extern "C" {
int strlen(char* v);
int write(int, char*, int);
#define DUMMY(name) \
int name() { \
write(1, #name " not implemented\n", strlen(#name " not implemented\n")); \
return 0; \
}
#define RDUMMY(name, ret) \
int name() { \
write(1, #name " not implemented\n", strlen(#name " not implemented\n")); \
return ret; \
}
#define TDUMMY(name) \
int name() { \
write(1, #name " not implemented\n", strlen(#name " not implemented\n")); \
throw std::runtime_error(#name " not implemented"); \
}
unsigned int ntohl(unsigned int v)
{
unsigned char*ptr = (unsigned char*)(void*)&v;
return ptr[3] + (ptr[2] << 8) + (ptr[1] << 16) + (ptr[0] << 24);
}
unsigned int htonl(unsigned int v)
{
return ntohl(v);
}
unsigned short ntohs(unsigned short v)
{
unsigned char*ptr = (unsigned char*)(void*)&v;
return ptr[1] + (ptr[0] << 8);
}
unsigned short htons(unsigned short v)
{
return ntohs(v);
}
//DUMMY(inet_ntop)
DUMMY(if_indextoname)
DUMMY(accept)
DUMMY(backtrace)
DUMMY(backtrace_symbols)
DUMMY(bind)
DUMMY(chdir)
DUMMY(chmod)
DUMMY(chown)
DUMMY(closedir)
DUMMY(connect)
DUMMY(dladdr)
DUMMY(dlclose)
DUMMY(dlerror)
DUMMY(dlopen)
DUMMY(dlsym)
DUMMY(execvp)
DUMMY(fchdir)
DUMMY(freeaddrinfo)
DUMMY(getaddrinfo)
DUMMY(getegid)
DUMMY(geteuid)
DUMMY(gethostname)
DUMMY(getlogin)
DUMMY(getpeername)
DUMMY(getpwuid)
DUMMY(getsockname)
DUMMY(getsockopt)
DUMMY(getuid)
DUMMY(open64)
DUMMY(opendir)
DUMMY(openlog)
RDUMMY(pipe, -1)
DUMMY(poll)
DUMMY(readdir)
DUMMY(readdir64)
DUMMY(readdir64_r)
//DUMMY(readlink)
DUMMY(readv)
DUMMY(recvmsg)
DUMMY(select)
DUMMY(sendmsg)
DUMMY(setegid)
DUMMY(seteuid)
DUMMY(setgid)
DUMMY(setsockopt)
DUMMY(setuid)
DUMMY(shutdown)
DUMMY(sigaction)
RDUMMY(socket, -1)
//TDUMMY(socket)
DUMMY(statvfs64)
DUMMY(symlink)
DUMMY(sysconf)
DUMMY(syslog)
DUMMY(tcgetattr)
DUMMY(tcsetattr)
DUMMY(times)
DUMMY(truncate64)
DUMMY(utime)
DUMMY(waitpid)
DUMMY(__xstat64)
DUMMY(if_nametoindex)
//DUMMY(inet_pton)
DUMMY(ioctl)
DUMMY(listen)
DUMMY(__lxstat64)
DUMMY(statvfs)
DUMMY(lstat)
DUMMY(fchmodat)
DUMMY(truncate)
//TDUMMY(___xpg_strerror_r)
DUMMY(getgid)
DUMMY(gethostbyname)
DUMMY(getservbyname)
DUMMY(closelog)
DUMMY(sendto)
DUMMY(recvfrom)
extern "C" void strcpy(char*, const char*);
int ___xpg_strerror_r(int errnum, char * buf, unsigned int buflen)
{
if (buflen > 5)
strcpy(buf, "boum");
return 0;
}
}