ReactOS  0.4.13-dev-259-g5ca9c9c
fake.c File Reference
#include "precomp.h"
#include <wincon.h>
Include dependency graph for fake.c:

Go to the source code of this file.

Macros

#define MAX_ASCII   100
 
#define EPOCHFILETIME   (116444736000000000i64)
 

Functions

int checkRecv (SOCKET s)
 
void blkfree (char **av0)
 
char ** glob (const char *v)
 
int sleep (int time)
 
int herror (char *string)
 
int fgetcSocket (int s)
 
const charfprintfSocket (int s, const char *format,...)
 
const charfputsSocket (const char *format, int s)
 
int fputcSocket (int s, char putChar)
 
int fputSocket (int s, char *buffer, int len)
 
charfgetsSocket (int s, char *string)
 
chargetpass (const char *prompt)
 
int gettimeofday (struct timeval *tv, struct timezone *tz)
 

Macro Definition Documentation

◆ EPOCHFILETIME

#define EPOCHFILETIME   (116444736000000000i64)

Definition at line 303 of file fake.c.

◆ MAX_ASCII

#define MAX_ASCII   100

Definition at line 5 of file fake.c.

Function Documentation

◆ blkfree()

void blkfree ( char **  av0)

Definition at line 28 of file fake.c.

29 {
30  register char **av = av0;
31 
32  while (*av)
33  free(*av++);
34 }
#define free
Definition: debug_ros.c:5

Referenced by globulize(), and mput().

◆ checkRecv()

int checkRecv ( SOCKET  s)

Definition at line 9 of file fake.c.

10 {
11  int testVal;
12  fd_set sSet;
13  struct timeval timeout;
14  timeout.tv_sec = 60;
15 
16  FD_ZERO(&sSet);
17 
18  FD_SET(s, &sSet);
19 
20  testVal = select(0, &sSet, NULL, NULL, &timeout);
21 
22  if (testVal == SOCKET_ERROR)
23  fprintf(stderr, "Socket Error");
24 
25  return testVal;
26 }
Definition: winsock.h:66
#define SOCKET_ERROR
Definition: winsock.h:333
Definition: dhcpd.h:245
#define FD_ZERO(set)
Definition: winsock.h:96
#define FD_SET(fd, set)
Definition: winsock.h:89
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
INT WSAAPI select(IN INT s, IN OUT LPFD_SET readfds, IN OUT LPFD_SET writefds, IN OUT LPFD_SET exceptfds, IN CONST struct timeval *timeout)
Definition: select.c:41
smooth NULL
Definition: ftsmooth.c:416
GLdouble s
Definition: gl.h:2039
FILE * stderr

Referenced by fgetsSocket().

◆ fgetcSocket()

int fgetcSocket ( int  s)

Definition at line 89 of file fake.c.

90 {
91  static int index = 0;
92  static int total = 0;
93  static char buffer[4096];
94 
95  if (index == total)
96  {
97  index = 0;
98  total = recv(s, buffer, sizeof(buffer), 0);
99 
100  if (total == SOCKET_ERROR)
101  {
102  total = 0;
103  return ERROR;
104  }
105 
106  if (total == 0)
107  return EOF;
108  }
109  return buffer[index++];
110 }
#define SOCKET_ERROR
Definition: winsock.h:333
#define ERROR(name)
Definition: error_private.h:53
GLuint buffer
Definition: glext.h:5915
GLuint index
Definition: glext.h:6031
GLdouble s
Definition: gl.h:2039
#define EOF
Definition: stdio.h:24
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
Definition: recv.c:23

Referenced by getreply(), and recvrequest().

◆ fgetsSocket()

char* fgetsSocket ( int  s,
char string 
)

Definition at line 168 of file fake.c.

169 {
170  char buffer[2] = {0};
171  int i, count;
172 
173  for (i = 0, count = 1; count != 0 && buffer[0] != '\n'; i++)
174  {
175  checkRecv(s);
176 
177  count = recv(s, buffer, 1, 0);
178 
179  if (count == SOCKET_ERROR)
180  {
181  printf("Error in fgetssocket");
182  return NULL;
183  }
184 
185  if (count == 1)
186  {
187  string[i] = buffer[0];
188 
189  if (i == MAX_ASCII - 3)
190  {
191  count = 0;
192  string[++i] = '\n';
193  string[++i] = '\0';
194  }
195  }
196  else
197  {
198  if (i == 0)
199  return NULL;
200  else
201  {
202  string[i] = '\n';
203  string[i + 1] = '\0'; // This is risky
204  return string;
205  }
206 
207  }
208 
209  }
210  string[i] = '\0';
211 
212 #ifdef DEBUG_IN
213  printf("%s", string);
214 #endif
215  return string;
216 }
#define SOCKET_ERROR
Definition: winsock.h:333
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint buffer
Definition: glext.h:5915
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 MAX_ASCII
Definition: fake.c:5
int checkRecv(SOCKET s)
Definition: fake.c:9
smooth NULL
Definition: ftsmooth.c:416
GLdouble s
Definition: gl.h:2039
char string[160]
Definition: util.h:11
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
Definition: recv.c:23
#define printf
Definition: config.h:203

◆ fprintfSocket()

const char* fprintfSocket ( int  s,
const char format,
  ... 
)

Definition at line 114 of file fake.c.

115 {
116  va_list argptr;
117  char buffer[10009];
118 
119  va_start(argptr, format);
120  vsprintf(buffer, format, argptr);
121  va_end(argptr);
122 
123  send(s, buffer, strlen(buffer), 0);
124 
125  return NULL;
126 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLuint buffer
Definition: glext.h:5915
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define va_end(ap)
Definition: acmsvcex.h:90
smooth NULL
Definition: ftsmooth.c:416
char * va_list
Definition: acmsvcex.h:78
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
GLdouble s
Definition: gl.h:2039
int __cdecl vsprintf(char *_Dest, const char *_Format, va_list _Args)
Definition: sprintf.c:733
#define va_start(ap, A)
Definition: acmsvcex.h:91

Referenced by command(), getreply(), proxtrans(), and recvrequest().

◆ fputcSocket()

int fputcSocket ( int  s,
char  putChar 
)

Definition at line 135 of file fake.c.

136 {
137  char buffer[2];
138 
139  buffer[0] = putChar;
140  buffer[1] = '\0';
141 
142  if(SOCKET_ERROR==send(s, buffer, 1, 0)) {
143  int iret=WSAGetLastError ();
144  fprintf(stdout,"fputcSocket: %d\n",iret);
145  return 0;
146  }
147  else {
148  return putChar;
149  }
150 }
#define SOCKET_ERROR
Definition: winsock.h:333
GLuint buffer
Definition: glext.h:5915
FILE * stdout
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
GLdouble s
Definition: gl.h:2039

◆ fputSocket()

int fputSocket ( int  s,
char buffer,
int  len 
)

Definition at line 151 of file fake.c.

152 {
153  int iret;
154  while(len) {
155  if(SOCKET_ERROR==(iret=send(s, buffer, len, 0)))
156  {
157  iret=WSAGetLastError ();
158  fprintf(stdout,"fputcSocket: %d\n",iret);
159  return 0;
160  }
161  else {
162  return len-=iret;
163  }
164  }
165  return 0;
166 }
#define SOCKET_ERROR
Definition: winsock.h:333
GLuint buffer
Definition: glext.h:5915
FILE * stdout
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
GLenum GLsizei len
Definition: glext.h:6722
GLdouble s
Definition: gl.h:2039

Referenced by sendrequest().

◆ fputsSocket()

const char* fputsSocket ( const char format,
int  s 
)

Definition at line 128 of file fake.c.

129 {
130  send(s, format, strlen(format), 0);
131 
132  return NULL;
133 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
smooth NULL
Definition: ftsmooth.c:416
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
GLdouble s
Definition: gl.h:2039

◆ getpass()

char* getpass ( const char prompt)

Definition at line 231 of file fake.c.

232 {
233  static char input[256];
234  HANDLE in;
235  HANDLE err;
236  DWORD count;
237 
240 
242  return NULL;
243 
244  if (WriteFile (err, prompt, strlen (prompt), &count, NULL))
245  {
246  int istty = (GetFileType (in) == FILE_TYPE_CHAR);
247  DWORD old_flags;
248  int rc;
249 
250  if (istty)
251  {
252  if (GetConsoleMode (in, &old_flags))
254  else
255  istty = 0;
256  }
257  /* Need to read line one byte at time to avoid blocking, if not a
258  tty, so always do it this way. */
259  count = 0;
260  while (1)
261  {
262  DWORD dummy;
263  char one_char;
264 
265  rc = ReadFile (in, &one_char, 1, &dummy, NULL);
266  if (rc == 0)
267  break;
268  if (one_char == '\r')
269  {
270  /* CR is always followed by LF if reading from tty. */
271  if (istty)
272  continue;
273  else
274  break;
275  }
276  if (one_char == '\n')
277  break;
278  /* Silently truncate password string if overly long. */
279  if (count < sizeof (input) - 1)
280  input[count++] = one_char;
281  }
282  input[count] = '\0';
283 
284  WriteFile (err, "\r\n", 2, &count, NULL);
285  if (istty)
286  SetConsoleMode (in, old_flags);
287  if (rc)
288  return input;
289  }
290 
291  return NULL;
292 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLuint GLuint GLsizei count
Definition: gl.h:1545
BOOL WINAPI GetConsoleMode(HANDLE hConsoleHandle, LPDWORD lpMode)
Definition: console.c:1571
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:152
DWORD WINAPI GetFileType(HANDLE hFile)
Definition: fileinfo.c:419
#define FILE_TYPE_CHAR
Definition: winbase.h:257
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMode(HANDLE hConsoleHandle, DWORD dwMode)
Definition: console.c:1608
smooth NULL
Definition: ftsmooth.c:416
#define STD_INPUT_HANDLE
Definition: winbase.h:264
#define STD_ERROR_HANDLE
Definition: winbase.h:266
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ENABLE_LINE_INPUT
Definition: wincon.h:76
#define err(...)
#define ENABLE_PROCESSED_INPUT
Definition: wincon.h:75
GLenum GLenum GLenum input
Definition: glext.h:9031
GLuint in
Definition: glext.h:9616
unsigned char dummy
Definition: maze.c:118
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123

Referenced by account(), GetPass(), login(), and user().

◆ gettimeofday()

int gettimeofday ( struct timeval tv,
struct timezone tz 
)

Definition at line 308 of file fake.c.

309 {
310  FILETIME ft;
311  LARGE_INTEGER li;
312  __int64 t;
313  static int tzflag;
314 
315  if (tv)
316  {
318  li.LowPart = ft.dwLowDateTime;
319  li.HighPart = ft.dwHighDateTime;
320  t = li.QuadPart; /* In 100-nanosecond intervals */
321  t -= EPOCHFILETIME; /* Offset to the Epoch time */
322  t /= 10; /* In microseconds */
323  tv->tv_sec = (long)(t / 1000000);
324  tv->tv_usec = (long)(t % 1000000);
325  }
326 
327  if (tz)
328  {
329  if (!tzflag)
330  {
331  _tzset();
332  tzflag++;
333  }
334  tz->tz_minuteswest = _timezone / 60;
335  tz->tz_dsttime = _daylight;
336  }
337 
338  return 0;
339 }
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
_CRTIMP void __cdecl _tzset(void)
Definition: timezone.c:92
unsigned long tv_sec
Definition: linux.h:1738
GLdouble GLdouble t
Definition: gl.h:2047
DWORD dwHighDateTime
Definition: mapidefs.h:66
unsigned long tv_usec
Definition: linux.h:1739
int _daylight
Definition: timezone.c:30
ULONG LowPart
Definition: typedefs.h:104
long _timezone
Definition: timezone.c:46
#define long
Definition: qsort.c:33
GLbyte GLbyte tz
Definition: glext.h:8756
#define EPOCHFILETIME
Definition: fake.c:303
DWORD dwLowDateTime
Definition: mapidefs.h:65
#define __int64
Definition: basetyps.h:16
LONGLONG QuadPart
Definition: typedefs.h:112

◆ glob()

char** glob ( const char v)

Definition at line 36 of file fake.c.

37 {
38  return NULL;
39 }
smooth NULL
Definition: ftsmooth.c:416

Referenced by EnumColorProfilesA(), EnumColorProfilesW(), extract_one(), fill_datafile(), fill_directory(), globulize(), have_profile(), mput(), and write_bitmap().

◆ herror()

int herror ( char string)

Definition at line 46 of file fake.c.

47 {
48  return 0;
49 }

Referenced by hookup().

◆ sleep()

int sleep ( int  time)

Definition at line 41 of file fake.c.

42 {
43  return time;
44 }
__u16 time
Definition: mkdosfs.c:366