34ed1d488cdac81f1347acf7ae4394ada974cd64
[reactos.git] / reactos / services / dhcp / compat.c
1 #include "rosdhcp.h"
2 #include "dhcpd.h"
3 #include "stdint.h"
4
5 size_t strlcpy(char *d, const char *s, size_t bufsize)
6 {
7 size_t len = strlen(s);
8 size_t ret = len;
9 if (bufsize > 0) {
10 if (len >= bufsize)
11 len = bufsize-1;
12 memcpy(d, s, len);
13 d[len] = 0;
14 }
15 return ret;
16 }
17
18 // not really random :(
19 u_int32_t arc4random()
20 {
21 static int did_srand = 0;
22 u_int32_t ret;
23
24 if (!did_srand) {
25 srand(0);
26 did_srand = 1;
27 }
28
29 ret = rand() << 10 ^ rand();
30 return ret;
31 }
32
33 int inet_aton(const char *cp, struct in_addr *inp)
34 {
35 inp->S_un.S_addr = inet_addr(cp);
36 if (INADDR_NONE == inp->S_un.S_addr)
37 return 0;
38
39 return 1;
40 }