ReactOS  0.4.12-dev-51-ge94618b
compat.c
Go to the documentation of this file.
1 #include <rosdhcp.h>
2 
3 size_t strlcpy(char *d, const char *s, size_t bufsize)
4 {
5  size_t len = strlen(s);
6  size_t ret = len;
7  if (bufsize > 0) {
8  if (len >= bufsize)
9  len = bufsize-1;
10  memcpy(d, s, len);
11  d[len] = 0;
12  }
13  return ret;
14 }
15 
16 // not really random :(
18 {
19  static int did_srand = 0;
20  u_int32_t ret;
21 
22  if (!did_srand) {
23  srand(0);
24  did_srand = 1;
25  }
26 
27  ret = rand() << 10 ^ rand();
28  return ret;
29 }
30 
31 
32 int inet_aton(const char *cp, struct in_addr *inp)
33 /* inet_addr code from ROS, slightly modified. */
34 {
35  ULONG Octets[4] = {0,0,0,0};
36  ULONG i = 0;
37 
38  if(!cp)
39  return 0;
40 
41  while(*cp)
42  {
43  CHAR c = *cp;
44  cp++;
45 
46  if(c == '.')
47  {
48  i++;
49  continue;
50  }
51 
52  if(c < '0' || c > '9')
53  return 0;
54 
55  Octets[i] *= 10;
56  Octets[i] += (c - '0');
57 
58  if(Octets[i] > 255)
59  return 0;
60  }
61 
62  inp->S_un.S_addr = (Octets[3] << 24) + (Octets[2] << 16) + (Octets[1] << 8) + Octets[0];
63  return 1;
64 }
65 
union in_addr::@985 S_un
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char CHAR
Definition: xmlstorage.h:175
size_t strlcpy(char *d, const char *s, size_t bufsize)
Definition: compat.c:3
void __cdecl srand(_In_ unsigned int _Seed)
GLenum GLuint GLsizei bufsize
Definition: glext.h:7473
GLenum GLclampf GLint i
Definition: glfuncs.h:14
int inet_aton(const char *cp, struct in_addr *inp)
Definition: compat.c:32
_Check_return_ int __cdecl rand(void)
Definition: rand.c:10
u_int32_t arc4random()
Definition: compat.c:17
#define d
Definition: ke_i.h:81
Definition: tcpip.h:125
const GLubyte * c
Definition: glext.h:8905
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
unsigned int u_int32_t
Definition: rosdhcp.h:35
GLdouble s
Definition: gl.h:2039
u_long S_addr
Definition: tcpip.h:131
POINT cp
Definition: magnifier.c:60
unsigned int ULONG
Definition: retypes.h:1