ec132ca360acfa6b1ef02f7217693db3bfecb353
[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
34 int inet_aton(const char *cp, struct in_addr *inp)
35 {
36 inp->S_un.S_addr = inet_addr(cp);
37 if (INADDR_NONE == inp->S_un.S_addr)
38 return 0;
39
40 return 1;
41 }
42