ReactOS  0.4.12-dev-409-g9f418243
util.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PTRZERO(p, siz)   (void) memset(p, 0, (size_t) (siz))
 
#define ZERO(a)   PTRZERO(&(a), sizeof(a))
 
#define STREQ(a, b)   (strcmp(a,b) == 0)
 
#define STRNEQ(a, b, s)   (strncmp(a,b,(size_t)(s)) == 0)
 
#define ISTRCMP   strcmp
 
#define ISTRNCMP   strncmp
 
#define ISTREQ(a, b)   (ISTRCMP(a,b) == 0)
 
#define ISTRNEQ(a, b, s)   (ISTRNCMP(a,b,(size_t)(s)) == 0)
 
#define QSORT(base, n, s, cmp)   qsort(base, (size_t)(n), (size_t)(s), (cmp_t)(cmp))
 
#define BSEARCH(key, base, n, s, cmp)   bsearch(key, base, (size_t)(n), (size_t)(s), (cmp_t)(cmp))
 
#define kDoPerror   1
 
#define kDontPerror   0
 
#define kClosedFileDescriptor   (-1)
 
#define SZ(a)   ((size_t) (a))
 
#define F_OK   0
 
#define UNLINK   unlink
 
#define SEEK_SET   0
 
#define SEEK_CUR   1
 
#define SEEK_END   2
 
#define SETVBUF   setvbuf
 
#define NcSignal   signal
 

Typedefs

typedef char string[160]
 
typedef char str16[16]
 
typedef char str32[32]
 
typedef char str64[64]
 
typedef char longstring[512]
 
typedef char pathname[512]
 
typedef int(* cmp_t) (const void *, const void *)
 

Functions

charFGets (char *, size_t, FILE *)
 
struct passwd * GetPwByName (void)
 
void GetHomeDir (char *, size_t)
 
void GetUsrName (char *, size_t)
 
void CloseFile (FILE **)
 
void PrintF (const FTPCIPtr cip, const char *const fmt,...)
 
void Error (const FTPCIPtr cip, const int pError, const char *const fmt,...)
 
int GetSockBufSize (int sockfd, size_t *rsize, size_t *ssize)
 
int SetSockBufSize (int sockfd, size_t rsize, size_t ssize)
 
time_t UnMDTMDate (char *)
 
void Scramble (unsigned char *dst, size_t dsize, unsigned char *src, char *key)
 

Macro Definition Documentation

◆ BSEARCH

#define BSEARCH (   key,
  base,
  n,
  s,
  cmp 
)    bsearch(key, base, (size_t)(n), (size_t)(s), (cmp_t)(cmp))

Definition at line 40 of file util.h.

◆ F_OK

#define F_OK   0

Definition at line 52 of file util.h.

◆ ISTRCMP

#define ISTRCMP   strcmp

Definition at line 28 of file util.h.

◆ ISTREQ

#define ISTREQ (   a,
  b 
)    (ISTRCMP(a,b) == 0)

Definition at line 33 of file util.h.

◆ ISTRNCMP

#define ISTRNCMP   strncmp

Definition at line 29 of file util.h.

◆ ISTRNEQ

#define ISTRNEQ (   a,
  b,
  s 
)    (ISTRNCMP(a,b,(size_t)(s)) == 0)

Definition at line 34 of file util.h.

◆ kClosedFileDescriptor

#define kClosedFileDescriptor   (-1)

Definition at line 47 of file util.h.

◆ kDontPerror

#define kDontPerror   0

Definition at line 45 of file util.h.

◆ kDoPerror

#define kDoPerror   1

Definition at line 44 of file util.h.

◆ NcSignal

#define NcSignal   signal

Definition at line 105 of file util.h.

◆ PTRZERO

#define PTRZERO (   p,
  siz 
)    (void) memset(p, 0, (size_t) (siz))

Definition at line 16 of file util.h.

◆ QSORT

#define QSORT (   base,
  n,
  s,
  cmp 
)    qsort(base, (size_t)(n), (size_t)(s), (cmp_t)(cmp))

Definition at line 37 of file util.h.

◆ SEEK_CUR

#define SEEK_CUR   1

Definition at line 63 of file util.h.

◆ SEEK_END

#define SEEK_END   2

Definition at line 64 of file util.h.

◆ SEEK_SET

#define SEEK_SET   0

Definition at line 62 of file util.h.

◆ SETVBUF

#define SETVBUF   setvbuf

Definition at line 70 of file util.h.

◆ STREQ

#define STREQ (   a,
  b 
)    (strcmp(a,b) == 0)

Definition at line 20 of file util.h.

◆ STRNEQ

#define STRNEQ (   a,
  b,
  s 
)    (strncmp(a,b,(size_t)(s)) == 0)

Definition at line 21 of file util.h.

◆ SZ

#define SZ (   a)    ((size_t) (a))

Definition at line 49 of file util.h.

◆ UNLINK

#define UNLINK   unlink

Definition at line 58 of file util.h.

◆ ZERO

#define ZERO (   a)    PTRZERO(&(a), sizeof(a))

Definition at line 19 of file util.h.

Typedef Documentation

◆ cmp_t

typedef int(* cmp_t) (const void *, const void *)

Definition at line 36 of file util.h.

◆ longstring

typedef char longstring[512]

Definition at line 12 of file util.h.

◆ pathname

typedef char pathname[512]

Definition at line 13 of file util.h.

◆ str16

typedef char str16[16]

Definition at line 11 of file util.h.

◆ str32

typedef char str32[32]

Definition at line 11 of file util.h.

◆ str64

typedef char str64[64]

Definition at line 11 of file util.h.

◆ string

typedef const GLchar * string

Definition at line 11 of file util.h.

Function Documentation

◆ CloseFile()

void CloseFile ( FILE **  )

Definition at line 327 of file util.c.

328 {
329  if (*f != NULL) {
330  if ((*f != stdout) && (*f != stdin) && (*f != stderr))
331  (void) fclose(*f);
332  *f = NULL;
333  }
334 } /* CloseFile */
FILE * stdin
FILE * stdout
smooth NULL
Definition: ftsmooth.c:416
GLfloat f
Definition: glext.h:7540
static void(WINAPI *pDeinitMapiUtil)(void)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
FILE * stderr

Referenced by CloseControlConnection(), FTPRebuildConnectionInfo(), and OpenControlConnection().

◆ Error()

void Error ( const FTPCIPtr  cip,
const int  pError,
const char *const  fmt,
  ... 
)

Definition at line 368 of file util.c.

369 {
370  va_list ap;
371  int errnum;
372  size_t len;
373  char buf[256];
374  int endsinperiod;
375  int endsinnewline;
376 #ifndef HAVE_STRERROR
377  char errnostr[16];
378 #endif
379 
380  errnum = errno;
381  va_start(ap, fmt);
382 #ifdef HAVE_VSNPRINTF
383  vsnprintf(buf, sizeof(buf) - 1, fmt, ap);
384  buf[sizeof(buf) - 1] = '\0';
385 #else
386  (void) vsprintf(buf, fmt, ap);
387 #endif
388  va_end(ap);
389 
390  if (pError != 0) {
391  len = strlen(buf);
392  endsinperiod = 0;
393  endsinnewline = 0;
394  if (len > 2) {
395  if (buf[len - 1] == '\n') {
396  endsinnewline = 1;
397  buf[len - 1] = '\0';
398  if (buf[len - 2] == '.') {
399  endsinperiod = 1;
400  buf[len - 2] = '\0';
401  }
402  } else if (buf[len - 1] == '.') {
403  endsinperiod = 1;
404  buf[len - 1] = '\0';
405  }
406  }
407 #ifdef HAVE_STRERROR
408  (void) STRNCAT(buf, ": ");
409  (void) STRNCAT(buf, strerror(errnum));
410 #else
411 # ifdef HAVE_SNPRINTF
412  sprintf(errnostr, sizeof(errnostr) - 1, " (errno = %d)", errnum);
413  errnostr[sizeof(errnostr) - 1] = '\0';
414 # else
415  sprintf(errnostr, " (errno = %d)", errnum);
416 # endif
417  STRNCAT(buf, errnostr);
418 #endif
419  if (endsinperiod != 0)
420  (void) STRNCAT(buf, ".");
421  if (endsinnewline != 0)
422  (void) STRNCAT(buf, "\n");
423  }
424 
425  if (cip->errLog != NULL) {
426  (void) fprintf(cip->errLog, "%s", buf);
427  (void) fflush(cip->errLog);
428  }
429  if ((cip->debugLog != NULL) && (cip->debugLog != cip->errLog)) {
430  if ((cip->errLog != stderr) || (cip->debugLog != stdout)) {
431  (void) fprintf(cip->debugLog, "%s", buf);
432  (void) fflush(cip->debugLog);
433  }
434  }
435  if (cip->errLogProc != NULL) {
436  (*cip->errLogProc)(cip, buf);
437  }
438  if ((cip->debugLogProc != NULL) && (cip->debugLogProc != cip->errLogProc)) {
439  (*cip->debugLogProc)(cip, buf);
440  }
441 } /* Error */
#define vsnprintf
Definition: tif_win32.c:408
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
int errno
const char * strerror(int err)
Definition: compat_str.c:23
FILE * stdout
FTPLogProc errLogProc
Definition: ncftp.h:148
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define va_end(ap)
Definition: acmsvcex.h:90
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
FILE * errLog
Definition: ncftp.h:146
smooth NULL
Definition: ftsmooth.c:416
char * va_list
Definition: acmsvcex.h:78
#define STRNCAT(d, s)
Definition: Strn.h:48
static void(WINAPI *pDeinitMapiUtil)(void)
FTPLogProc debugLogProc
Definition: ncftp.h:147
GLenum GLsizei len
Definition: glext.h:6722
FILE * debugLog
Definition: ncftp.h:145
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
int __cdecl vsprintf(char *_Dest, const char *_Format, va_list _Args)
Definition: sprintf.c:733
#define va_start(ap, A)
Definition: acmsvcex.h:91
void int int ULONGLONG int va_list * ap
Definition: winesup.h:32
FILE * stderr
Definition: dsound.c:943

Referenced by FTPGetLocalCWD().

◆ FGets()

char* FGets ( char ,
size_t  ,
FILE  
)

Definition at line 111 of file util.c.

112 {
113  char *cp, *nlptr;
114 
115  cp = fgets(str, ((int) size) - 1, fp);
116  if (cp != NULL) {
117  cp[((int) size) - 1] = '\0'; /* ensure terminator */
118  nlptr = cp + strlen(cp) - 1;
119  if (*nlptr == '\n')
120  *nlptr = '\0';
121  } else {
122  memset(str, 0, size);
123  }
124  return cp;
125 } /* FGets */
static int
Definition: util.c:37
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
POINT cp
Definition: magnifier.c:60
#define memset(x, y, z)
Definition: compat.h:39

Referenced by GetPass().

◆ GetHomeDir()

void GetHomeDir ( char ,
size_t   
)

Definition at line 240 of file util.c.

241 {
242 #if defined(WIN32) || defined(_WINDOWS)
243  const char *homedrive, *homepath;
244 
245  homedrive = getenv("HOMEDRIVE");
246  homepath = getenv("HOMEPATH");
247  if ((homedrive != NULL) && (homepath != NULL)) {
248  (void) Strncpy(dst, homedrive, size);
249  (void) Strncat(dst, homepath, size);
250  return;
251  }
252 
253 // GetSpecialDir(dst, size, CSIDL_PERSONAL /* "My Documents" */);
254 // if (dst[0] != '\0')
255 // return;
256 //
257 // dst[0] = '\0';
258 // if (GetWindowsDirectory(dst, size - 1) < 1)
259 // (void) Strncpy(dst, ".", size);
260 // else if (dst[1] == ':') {
261 // dst[2] = '\\';
262 // dst[3] = '\0';
263 // }
264 #else
265  const char *cp;
266  struct passwd *pw;
267 
268  pw = NULL;
269 #if defined(USE_GETPWUID)
270  /* Try to use getpwuid(), but if we have to, fall back to getpwnam(). */
271  if ((pw = getpwuid(getuid())) == NULL)
272  pw = GetPwByName(); /* Oh well, try getpwnam() then. */
273 #else
274  /* Try to use getpwnam(), but if we have to, fall back to getpwuid(). */
275  if ((pw = GetPwByName()) == NULL)
276  pw = getpwuid(getuid()); /* Try getpwnam() then. */
277 #endif
278  if (pw != NULL)
279  cp = pw->pw_dir;
280  else if ((cp = (const char *) getenv("LOGNAME")) == NULL)
281  cp = ".";
282  (void) Strncpy(dst, cp, size);
283 #endif
284 } /* GetHomeDir */
char * Strncat(char *const, const char *const, const size_t)
Definition: Strncat.c:13
struct passwd * GetPwByName(void)
Definition: util.c:165
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
static void(WINAPI *pDeinitMapiUtil)(void)
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
char * Strncpy(char *const, const char *const, const size_t)
Definition: Strncpy.c:11
GLenum GLenum dst
Definition: glext.h:6340
uid_t getuid()
Definition: uid.c:27
POINT cp
Definition: magnifier.c:60

◆ GetPwByName()

struct passwd* GetPwByName ( void  )

Definition at line 165 of file util.c.

166 {
167  char *cp;
168  struct passwd *pw;
169 
170  cp = getlogin();
171  if (cp == NULL) {
172  cp = (char *) getenv("LOGNAME");
173  if (cp == NULL)
174  cp = (char *) getenv("USER");
175  }
176  pw = NULL;
177  if (cp != NULL)
178  pw = getpwnam(cp);
179  return (pw);
180 } /* GetPwByName */
smooth NULL
Definition: ftsmooth.c:416
char * getlogin(void)
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
POINT cp
Definition: magnifier.c:60

Referenced by GetHomeDir(), and GetUsrName().

◆ GetSockBufSize()

int GetSockBufSize ( int  sockfd,
size_t rsize,
size_t ssize 
)

Definition at line 534 of file util.c.

535 {
536 #ifdef SO_SNDBUF
537  int rc = -1;
538  int opt;
539  int optsize;
540 
541  if (ssize != NULL) {
542  opt = 0;
543  optsize = sizeof(opt);
544  rc = getsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, (char *) &opt, &optsize);
545  if (rc == 0)
546  *ssize = (size_t) opt;
547  else
548  *ssize = 0;
549  }
550  if (rsize != NULL) {
551  opt = 0;
552  optsize = sizeof(opt);
553  rc = getsockopt(sockfd, SOL_SOCKET, SO_RCVBUF, (char *) &opt, &optsize);
554  if (rc == 0)
555  *rsize = (size_t) opt;
556  else
557  *rsize = 0;
558  }
559  return (rc);
560 #else
561  if (ssize != NULL)
562  *ssize = 0;
563  if (rsize != NULL)
564  *rsize = 0;
565  return (-1);
566 #endif
567 } /* GetSockBufSize */
#define SOL_SOCKET
Definition: winsock.h:398
smooth NULL
Definition: ftsmooth.c:416
__kernel_size_t size_t
Definition: linux.h:237
#define SO_RCVBUF
Definition: winsock.h:189
INT WSAAPI getsockopt(IN SOCKET s, IN INT level, IN INT optname, OUT CHAR FAR *optval, IN OUT INT FAR *optlen)
Definition: sockctrl.c:271
#define SO_SNDBUF
Definition: winsock.h:188

◆ GetUsrName()

void GetUsrName ( char ,
size_t   
)

Definition at line 290 of file util.c.

291 {
292 #if defined(WIN32) || defined(_WINDOWS)
293  DWORD size1;
294 
295  size1 = size - 1;
296  if (! GetUserName(dst, &size1))
297  (void) strncpy(dst, "unknown", size);
298  dst[size - 1] = '\0';
299 #else
300  const char *cp;
301  struct passwd *pw;
302 
303  pw = NULL;
304 #ifdef USE_GETPWUID
305  /* Try to use getpwuid(), but if we have to, fall back to getpwnam(). */
306  if ((pw = getpwuid(getuid())) == NULL)
307  pw = GetPwByName(); /* Oh well, try getpwnam() then. */
308 #else
309  /* Try to use getpwnam(), but if we have to, fall back to getpwuid(). */
310  if ((pw = GetPwByName()) == NULL)
311  pw = getpwuid(getuid()); /* Try getpwnam() then. */
312 #endif
313  if (pw != NULL)
314  cp = pw->pw_name;
315  else if ((cp = (const char *) getenv("LOGNAME")) == NULL)
316  cp = "UNKNOWN";
317  (void) Strncpy(dst, cp, size);
318 #endif
319 } /* GetUserName */
#define GetUserName
Definition: winbase.h:3665
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
struct passwd * GetPwByName(void)
Definition: util.c:165
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
static void(WINAPI *pDeinitMapiUtil)(void)
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
char * Strncpy(char *const, const char *const, const size_t)
Definition: Strncpy.c:11
GLenum GLenum dst
Definition: glext.h:6340
uid_t getuid()
Definition: uid.c:27
POINT cp
Definition: magnifier.c:60

◆ PrintF()

void PrintF ( const FTPCIPtr  cip,
const char *const  fmt,
  ... 
)

Definition at line 340 of file util.c.

341 {
342  va_list ap;
343  char buf[256];
344 
345  va_start(ap, fmt);
346  if (cip->debugLog != NULL) {
347  (void) vfprintf(cip->debugLog, fmt, ap);
348  (void) fflush(cip->debugLog);
349  }
350  if (cip->debugLogProc != NULL) {
351 #ifdef HAVE_VSNPRINTF
352  (void) vsnprintf(buf, sizeof(buf) - 1, fmt, ap);
353  buf[sizeof(buf) - 1] = '\0';
354 #else
355  (void) vsprintf(buf, fmt, ap);
356 #endif
357  (*cip->debugLogProc)(cip, buf);
358  }
359  va_end(ap);
360 } /* PrintF */
#define vsnprintf
Definition: tif_win32.c:408
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
const char * fmt
Definition: wsprintf.c:30
#define va_end(ap)
Definition: acmsvcex.h:90
smooth NULL
Definition: ftsmooth.c:416
char * va_list
Definition: acmsvcex.h:78
static void(WINAPI *pDeinitMapiUtil)(void)
FTPLogProc debugLogProc
Definition: ncftp.h:147
FILE * debugLog
Definition: ncftp.h:145
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
int __cdecl vsprintf(char *_Dest, const char *_Format, va_list _Args)
Definition: sprintf.c:733
#define va_start(ap, A)
Definition: acmsvcex.h:91
void int int ULONGLONG int va_list * ap
Definition: winesup.h:32
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
Definition: dsound.c:943

Referenced by FTPAbortDataTransfer(), FTPGetFiles3(), FTPLoginHost(), FTPOpenHost(), FTPOpenHostNoLogin(), FTPPutFiles3(), FTPRemoteGlob(), LazyUnixLocalGlob(), OpenControlConnection(), PrintResponse(), SendCommand(), and TraceResponse().

◆ Scramble()

void Scramble ( unsigned char dst,
size_t  dsize,
unsigned char src,
char key 
)

Definition at line 607 of file util.c.

608 {
609  int i;
610  unsigned int ch;
611  unsigned char *k2;
612  size_t keyLen;
613 
614  keyLen = strlen(key);
615  k2 = (unsigned char *) key;
616  for (i=0; i < (int) dsize - 1; i++) {
617  ch = src[i];
618  if (ch == 0)
619  break;
620  dst[i] = (unsigned char) (ch ^ (int) (k2[i % (int) keyLen]));
621  }
622  dst[i] = '\0';
623 } /* Scramble */
static int
Definition: util.c:37
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
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
unsigned char
Definition: typeof.h:27
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
Definition: path.c:42

◆ SetSockBufSize()

int SetSockBufSize ( int  sockfd,
size_t  rsize,
size_t  ssize 
)

Definition at line 572 of file util.c.

573 {
574 #ifdef SO_SNDBUF
575  int rc = -1;
576  int opt;
577  int optsize;
578 
579 #ifdef TCP_RFC1323
580  /* This is an AIX-specific socket option to do RFC1323 large windows */
581  if (ssize > 0 || rsize > 0) {
582  opt = 1;
583  optsize = sizeof(opt);
584  rc = setsockopt(sockfd, IPPROTO_TCP, TCP_RFC1323, &opt, optsize);
585  }
586 #endif
587 
588  if (ssize > 0) {
589  opt = (int) ssize;
590  optsize = sizeof(opt);
591  rc = setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, (char *) &opt, optsize);
592  }
593  if (rsize > 0) {
594  opt = (int) rsize;
595  optsize = sizeof(opt);
596  rc = setsockopt(sockfd, SOL_SOCKET, SO_RCVBUF, (char *) &opt, optsize);
597  }
598  return (rc);
599 #else
600  return (-1);
601 #endif
602 } /* SetSockBufSize */
static int
Definition: util.c:37
#define SOL_SOCKET
Definition: winsock.h:398
INT WSAAPI setsockopt(IN SOCKET s, IN INT level, IN INT optname, IN CONST CHAR FAR *optval, IN INT optlen)
Definition: sockctrl.c:421
#define SO_RCVBUF
Definition: winsock.h:189
#define SO_SNDBUF
Definition: winsock.h:188

Referenced by OpenControlConnection(), and OpenDataConnection().

◆ UnMDTMDate()

time_t UnMDTMDate ( char )

Definition at line 486 of file util.c.

487 {
488 #ifndef HAVE_MKTIME
489  return (kModTimeUnknown);
490 #else
491  struct tm ut, *t;
492  time_t mt, now;
494 
495  if (strncmp(dstr, "19100", 5) == 0) {
496  /* Server Y2K bug! */
497  return (result);
498  }
499 
500  (void) time(&now);
501  t = localtime(&now);
502 
503  /* Copy the whole structure of the 'tm' pointed to by t, so it will
504  * also set all fields we don't specify explicitly to be the same as
505  * they were in t. That way we copy non-standard fields such as
506  * tm_gmtoff, if it exists or not.
507  */
508  ut = *t;
509 
510  /* The time we get back from the server is (should be) in UTC. */
511  if (sscanf(dstr, "%04d%02d%02d%02d%02d%02d",
512  &ut.tm_year,
513  &ut.tm_mon,
514  &ut.tm_mday,
515  &ut.tm_hour,
516  &ut.tm_min,
517  &ut.tm_sec) == 6)
518  {
519  --ut.tm_mon;
520  ut.tm_year -= 1900;
521  mt = mktime(&ut);
522  if (mt != (time_t) -1) {
523  mt += GetUTCOffset(ut.tm_mon, ut.tm_mday);
524  result = (time_t) mt;
525  }
526  }
527  return result;
528 #endif /* HAVE_MKTIME */
529 } /* UnMDTMDate */
GLdouble GLdouble t
Definition: gl.h:2047
__u16 time
Definition: mkdosfs.c:366
time_t now
Definition: finger.c:65
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
static time_t GetUTCOffset(int mon, int mday)
Definition: util.c:449
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
static void(WINAPI *pDeinitMapiUtil)(void)
Definition: time.h:76
_CRTIMP struct tm *__cdecl localtime(const time_t *_Time)
Definition: time.h:426
__kernel_time_t time_t
Definition: linux.h:252
_CRTIMP time_t __cdecl mktime(struct tm *_Tm)
Definition: time.h:428
#define kModTimeUnknown
Definition: ncftp.h:377
GLuint64EXT * result
Definition: glext.h:11304