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:
Eshan Kelkar
2023-07-04 19:41:11 +05:30
committed by Jakub Jelen
parent fe80f47b0a
commit 5726af1956
7 changed files with 16 additions and 54 deletions

View File

@@ -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