mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-04 12:20:42 +09:00
priv.h : Add compatibility code for Windows
Compatibility code for mapping open, read, write, close and unlink to _open, _read, _write, _close and _unlink respectively on Windows was repeated in a lot of .c files. This commit adds that compatibility code to include/libssh/priv.h and removes it from the .c files (while ensuring that those .c files include priv.h) so that the compatibility code stays in one place, can be maintained easily and can be added easily to another source file by including priv.h in that file. Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
committed by
Jakub Jelen
parent
fe80f47b0a
commit
5726af1956
@@ -162,6 +162,20 @@ int ssh_gettimeofday(struct timeval *__p, void *__t);
|
||||
|
||||
#define _XCLOSESOCKET closesocket
|
||||
|
||||
# ifdef HAVE_IO_H
|
||||
# include <io.h>
|
||||
# undef open
|
||||
# define open _open
|
||||
# undef close
|
||||
# define close _close
|
||||
# undef read
|
||||
# define read _read
|
||||
# undef write
|
||||
# define write _write
|
||||
# undef unlink
|
||||
# define unlink _unlink
|
||||
# endif /* HAVE_IO_H */
|
||||
|
||||
#else /* _WIN32 */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -54,11 +54,6 @@
|
||||
#define NTDDI_VERSION 0x05010000 /* NTDDI_WINXP */
|
||||
#endif
|
||||
|
||||
#if _MSC_VER >= 1400
|
||||
#include <io.h>
|
||||
#undef close
|
||||
#define close _close
|
||||
#endif /* _MSC_VER */
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
|
||||
@@ -34,19 +34,7 @@
|
||||
#define CHUNKSIZE 4096
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifdef HAVE_IO_H
|
||||
# include <io.h>
|
||||
# undef open
|
||||
# define open _open
|
||||
# undef close
|
||||
# define close _close
|
||||
# undef read
|
||||
# define read _read
|
||||
# undef unlink
|
||||
# define unlink _unlink
|
||||
# endif /* HAVE_IO_H */
|
||||
#else
|
||||
#ifndef _WIN32
|
||||
# include <sys/types.h>
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
14
src/pki.c
14
src/pki.c
@@ -43,20 +43,6 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifdef HAVE_IO_H
|
||||
# include <io.h>
|
||||
# undef open
|
||||
# define open _open
|
||||
# undef close
|
||||
# define close _close
|
||||
# undef read
|
||||
# define read _read
|
||||
# undef unlink
|
||||
# define unlink _unlink
|
||||
# endif /* HAVE_IO_H */
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#include "libssh/libssh.h"
|
||||
#include "libssh/session.h"
|
||||
#include "libssh/priv.h"
|
||||
|
||||
11
src/socket.c
11
src/socket.c
@@ -37,17 +37,6 @@ struct sockaddr_un {
|
||||
char sun_path[UNIX_PATH_MAX];
|
||||
};
|
||||
#endif
|
||||
#if _MSC_VER >= 1400
|
||||
#include <io.h>
|
||||
#undef open
|
||||
#define open _open
|
||||
#undef close
|
||||
#define close _close
|
||||
#undef read
|
||||
#define read _read
|
||||
#undef write
|
||||
#define write _write
|
||||
#endif /* _MSC_VER */
|
||||
#else /* _WIN32 */
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
@@ -40,11 +40,6 @@
|
||||
#include <unistd.h>
|
||||
#elif (defined _WIN32) || (defined _WIN64)
|
||||
#include <direct.h>
|
||||
#include <io.h>
|
||||
#define read _read
|
||||
#define open _open
|
||||
#define write _write
|
||||
#define close _close
|
||||
#define chdir _chdir
|
||||
#endif
|
||||
|
||||
|
||||
@@ -9,15 +9,10 @@
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#elif (defined _WIN32) || (defined _WIN64)
|
||||
#include <io.h>
|
||||
#define read _read
|
||||
#define open _open
|
||||
#define write _write
|
||||
#define close _close
|
||||
#endif
|
||||
|
||||
#include "torture_pki.h"
|
||||
#include <libssh/priv.h>
|
||||
|
||||
char *torture_pki_read_file(const char *filename)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user