ReactOS  0.4.14-dev-114-gc8cbd56
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 
33 int 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 
56 int 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 
80 int 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 
115 void *adns_malloc(const size_t bytes)
116 {
117  return malloc(bytes);
118 }
119 
120 void *adns_realloc(void *ptr, const size_t bytes)
121 {
122  return realloc(ptr, bytes);
123 }
124 
125 void adns_free(void *ptr)
126 {
127  free(ptr);
128 }
129 
130 #endif /* ADNS_DLL */
#define realloc
Definition: debug_ros.c:6
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
#define inet_addr(cp)
Definition: inet.h:98
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
Definition: arc.h:39
#define free
Definition: debug_ros.c:5
#define INADDR_NONE
Definition: tcp.c:42
unsigned long tv_sec
Definition: linux.h:1738
int errno
u32_t s_addr
Definition: inet.h:45
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
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
__kernel_size_t iov_len
Definition: linux.h:1702
_In_ KPRIORITY _In_ LONG Adjustment
Definition: kefuncs.h:451
time_t now
Definition: finger.c:65
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
unsigned long tv_usec
Definition: linux.h:1739
#define ADNS_CLEAR_ERRNO
Definition: adns_win32.h:108
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
Definition: tcpip.h:125
int adns_inet_aton(const char *cp, struct in_addr *inp)
Definition: linux.h:1699
int adns_getpid()
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:148
#define long
Definition: qsort.c:33
GLbyte GLbyte tz
Definition: glext.h:8756
#define ADNS_CAPTURE_ERRNO
Definition: adns_win32.h:107
int gettimeofday(struct timeval *tv, struct timezone *tz)
int adns_writev(int FileDescriptor, const struct iovec *iov, int iovCount)
POINT cp
Definition: magnifier.c:59
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define malloc
Definition: debug_ros.c:4
Definition: fake.h:14
GLfloat GLfloat p
Definition: glext.h:8902
#define __int64
Definition: basetyps.h:16
DWORD WINAPI GetCurrentProcessId(VOID)
Definition: proc.c:1158