ReactOS  0.4.12-dev-102-g4b7f1e0
compat.c File Reference
#include <rosdhcp.h>
Include dependency graph for compat.c:

Go to the source code of this file.

Functions

size_t strlcpy (char *d, const char *s, size_t bufsize)
 
u_int32_t arc4random ()
 
int inet_aton (const char *cp, struct in_addr *inp)
 

Function Documentation

◆ arc4random()

u_int32_t arc4random ( )

Definition at line 17 of file compat.c.

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 }
void __cdecl srand(_In_ unsigned int _Seed)
_Check_return_ int __cdecl rand(void)
Definition: rand.c:10
int ret
unsigned int u_int32_t
Definition: rosdhcp.h:35

◆ inet_aton()

int inet_aton ( const char cp,
struct in_addr inp 
)

Definition at line 32 of file compat.c.

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 }
union in_addr::@985 S_un
char CHAR
Definition: xmlstorage.h:175
GLenum GLclampf GLint i
Definition: glfuncs.h:14
const GLubyte * c
Definition: glext.h:8905
u_long S_addr
Definition: tcpip.h:131
POINT cp
Definition: magnifier.c:60
unsigned int ULONG
Definition: retypes.h:1

◆ strlcpy()

size_t strlcpy ( char d,
const char s,
size_t  bufsize 
)

Definition at line 3 of file compat.c.

Referenced by assign_file_addresses(), get_graft(), merge_old_directory_into_tree(), merge_remaining_entries(), parse_rr(), parse_rrflags(), read_rcfile(), scan_directory_tree(), searchfileinpath(), searchonefile(), sort_n_finish(), and vers_write().

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 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLsizei bufsize
Definition: glext.h:7473
#define d
Definition: ke_i.h:81
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
GLdouble s
Definition: gl.h:2039