ReactOS 0.4.17-dev-423-ged51a5d
wine.c
Go to the documentation of this file.
1/*
2 * Protocol-level socket functions
3 *
4 * Copyright (C) 1993,1994,1996,1997 John Brezak, Erik Bos, Alex Korobka.
5 * Copyright (C) 2001 Stefan Leichter
6 * Copyright (C) 2004 Hans Leidekker
7 * Copyright (C) 2005 Marcus Meissner
8 * Copyright (C) 2006-2008 Kai Blin
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <ws2_32.h>
26
27#define NDEBUG
28#include <debug.h>
29
30#define TRACE(...)
31
32/***********************************************************************
33 * inet_addr (ws2_32.11)
34 */
35u_long WINAPI inet_addr( const char *str )
36{
37 unsigned long a[4] = { 0 };
38 const char *s = str;
39 unsigned char *d;
40 unsigned int i;
42 char *z;
43
44 TRACE( "str %s.\n", debugstr_a(str) );
45
46 if (!s)
47 {
49 return INADDR_NONE;
50 }
51
52 d = (unsigned char *)&addr;
53
54 if (s[0] == ' ' && !s[1]) return 0;
55
56 for (i = 0; i < 4; ++i)
57 {
58 a[i] = strtoul( s, &z, 0 );
59 if (z == s || !isdigit( *s )) return INADDR_NONE;
60 if (!*z || isspace(*z)) break;
61 if (*z != '.') return INADDR_NONE;
62 s = z + 1;
63 }
64
65 if (i == 4) return INADDR_NONE;
66
67 switch (i)
68 {
69 case 0:
70 a[1] = a[0] & 0xffffff;
71 a[0] >>= 24;
72 /* fallthrough */
73 case 1:
74 a[2] = a[1] & 0xffff;
75 a[1] >>= 16;
76 /* fallthrough */
77 case 2:
78 a[3] = a[2] & 0xff;
79 a[2] >>= 8;
80 }
81 for (i = 0; i < 4; ++i)
82 {
83 if (a[i] > 255) return INADDR_NONE;
84 d[i] = a[i];
85 }
86 return addr;
87}
#define isspace(c)
Definition: acclib.h:69
#define isdigit(c)
Definition: acclib.h:68
#define INADDR_NONE
Definition: tcp.c:42
#define SetLastError(x)
Definition: compat.h:752
_ACRTIMP __msvcrt_ulong __cdecl strtoul(const char *, char **, int)
Definition: string.c:1864
__msvcrt_ulong u_long
Definition: types.h:53
GLdouble s
Definition: gl.h:2039
GLenum const GLvoid * addr
Definition: glext.h:9621
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
GLdouble GLdouble z
Definition: glext.h:5874
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
#define d
Definition: ke_i.h:81
#define debugstr_a
Definition: kernel32.h:31
const WCHAR * str
#define WINAPI
Definition: msvc.h:6
#define TRACE(...)
Definition: wine.c:30
u_long WINAPI inet_addr(const char *str)
Definition: wine.c:35
#define WSAEFAULT
Definition: winerror.h:2844