ReactOS 0.4.15-dev-8222-g9164419
adns_unix_calls.c
Go to the documentation of this file.
1
2/*
3* adns_unix_calls.c
4* - Simple implementation of requiered UNIX system calls and
5* library functions.
6*/
7/*
8* This file is
9* Copyright (C) 2000, 2002 Jarle (jgaa) Aase <jgaa@jgaa.com>
10*
11* It is part of adns, which is
12* Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
13* Copyright (C) 1999 Tony Finch <dot@dotat.at>
14*
15* This program is free software; you can redistribute it and/or modify
16* it under the terms of the GNU General Public License as published by
17* the Free Software Foundation; either version 2, or (at your option)
18* any later version.
19*
20* This program is distributed in the hope that it will be useful,
21* but WITHOUT ANY WARRANTY; without even the implied warranty of
22* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23* GNU General Public License for more details.
24*
25* You should have received a copy of the GNU General Public License
26* along with this program; if not, write to the Free Software Foundation,
27* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28*/
29
30
31#include "adns.h"
32
33int adns_writev(int FileDescriptor, const struct iovec * iov, int iovCount)
34{
35 size_t total_len = 0;
36 int i = 0, r = 0;
37 char *buf = NULL, *p = NULL;
38
39 for(; i < iovCount; i++)
40 total_len += iov[i].iov_len;
41
42 p = buf = (char *)_alloca(total_len);
43
44 for(; i < iovCount; i++)
45 {
46 memcpy(p, iov[i].iov_base, iov[i].iov_len);
47 p += iov[i].iov_len;
48 }
49
51 r = send(FileDescriptor, buf, total_len, 0);
53 return r;
54}
55
56int adns_inet_aton(const char *cp, struct in_addr *inp)
57{
58 if (!cp || !*cp || !inp)
59 {
60 errno = EINVAL;
61 return -1;
62 }
63
64 if (!strcmp(cp, "255.255.255.255"))
65 {
66 // Special case
67 inp->s_addr = INADDR_NONE;
68 return 0;
69 }
70
71 inp->s_addr = inet_addr(cp);
72 return (inp->s_addr == INADDR_NONE) ? -1 : 0;
73}
74
76{
77 return GetCurrentProcessId();
78}
79
80int gettimeofday(struct timeval *tv, struct timezone *tz)
81{
82 static __int64 Adjustment;
83 __int64 now = 0;
84
85 if (!Adjustment)
86 {
87 SYSTEMTIME st = {1970,1,0,1,0,0,0};
89 }
90
91 if (tz)
92 {
93 errno = EINVAL;
94 return -1;
95 }
96
98 now -= Adjustment;
99
100 tv->tv_sec = (long)(now / 10000000);
101 tv->tv_usec = (long)((now % 10000000) / 10);
102
103 return 0;
104}
105
106/* Memory allocated in the DLL must be freed in the dll, so
107 we provide memory manegement functions. */
108
109#ifdef ADNS_DLL
110
111#undef malloc
112#undef realloc
113#undef free
114
115void *adns_malloc(const size_t bytes)
116{
117 return malloc(bytes);
118}
119
120void *adns_realloc(void *ptr, const size_t bytes)
121{
122 return realloc(ptr, bytes);
123}
124
125void adns_free(void *ptr)
126{
127 free(ptr);
128}
129
130#endif /* ADNS_DLL */
#define EINVAL
Definition: acclib.h:90
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
int adns_inet_aton(const char *cp, struct in_addr *inp)
int adns_getpid()
int adns_writev(int FileDescriptor, const struct iovec *iov, int iovCount)
#define ADNS_CLEAR_ERRNO
Definition: adns_win32.h:108
#define gettimeofday(tv, tz)
Definition: adns_win32.h:159
#define ADNS_CAPTURE_ERRNO
Definition: adns_win32.h:107
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
#define INADDR_NONE
Definition: tcp.c:42
#define __int64
Definition: basetyps.h:16
#define realloc
Definition: debug_ros.c:6
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:158
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
time_t now
Definition: finger.c:65
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLbyte GLbyte tz
Definition: glext.h:8756
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLfloat GLfloat p
Definition: glext.h:8902
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 inet_addr(cp)
Definition: inet.h:98
POINT cp
Definition: magnifier.c:59
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static PVOID ptr
Definition: dispmode.c:27
#define long
Definition: qsort.c:33
#define errno
Definition: errno.h:18
Definition: tcpip.h:126
u32_t s_addr
Definition: inet.h:45
Definition: linux.h:1700
__kernel_size_t iov_len
Definition: linux.h:1702
unsigned long tv_sec
Definition: linux.h:1738
unsigned long tv_usec
Definition: linux.h:1739
Definition: fake.h:14
DWORD WINAPI GetCurrentProcessId(void)
Definition: proc.c:1158
_In_ KPRIORITY _In_ LONG Adjustment
Definition: kefuncs.h:427