ReactOS  0.4.12-dev-685-gf36cbf7
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 }
char CHAR
Definition: xmlstorage.h:175
union in_addr::@979 S_un
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
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.

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

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().