From: Ronnie Sahlberg Date: Tue, 28 May 2013 23:15:16 +0000 (-0700) Subject: WIN32 fixes X-Git-Tag: upstream/1.9.6^2~204 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=67a9f57e67c3b2c147969c752532fd55eb99259c;p=deb_libnfs.git WIN32 fixes --- diff --git a/examples/nfs-cp.c b/examples/nfs-cp.c index eeea404..3d25189 100644 --- a/examples/nfs-cp.c +++ b/examples/nfs-cp.c @@ -29,6 +29,8 @@ #ifdef WIN32 #include "win32_compat.h" +#pragma comment(lib, "ws2_32.lib") +WSADATA wsaData; #else #include #include diff --git a/examples/nfs-ls.c b/examples/nfs-ls.c index c4b9fa9..e0131c8 100644 --- a/examples/nfs-ls.c +++ b/examples/nfs-ls.c @@ -30,7 +30,9 @@ #include "win32_compat.h" #pragma comment(lib, "ws2_32.lib") WSADATA wsaData; +#define PRId64 "ll" #else +#include #include #include #ifndef AROS @@ -45,7 +47,6 @@ WSADATA wsaData; #include #include #include -#include #include #include #include @@ -167,7 +168,7 @@ int main(int argc, char *argv[]) continue; } - snprintf(path, 1024, "%s/%s", "/", nfsdirent->name); + sprintf(path, "%s/%s", "/", nfsdirent->name); ret = nfs_stat(nfs, path, &st); if (ret != 0) { fprintf(stderr, "Failed to stat(%s) %s\n", path, nfs_get_error(nfs)); @@ -175,7 +176,9 @@ int main(int argc, char *argv[]) } switch (st.st_mode & S_IFMT) { +#ifndef WIN32 case S_IFLNK: +#endif case S_IFREG: printf("-"); break; diff --git a/examples/nfsclient-sync.c b/examples/nfsclient-sync.c index 72aa312..9ca58b4 100644 --- a/examples/nfsclient-sync.c +++ b/examples/nfsclient-sync.c @@ -32,7 +32,9 @@ #include "win32_compat.h" #pragma comment(lib, "ws2_32.lib") WSADATA wsaData; +#define PRId64 "ll" #else +#include #include #include #ifndef AROS @@ -47,7 +49,6 @@ WSADATA wsaData; #include #include #include -#include #include #include #include @@ -172,7 +173,7 @@ int main(int argc, char *argv[]) continue; } - snprintf(path, 1024, "%s/%s", "/", nfsdirent->name); + sprintf(path, "%s/%s", "/", nfsdirent->name); ret = nfs_stat(nfs, path, &st); if (ret != 0) { fprintf(stderr, "Failed to stat(%s) %s\n", path, nfs_get_error(nfs)); @@ -180,7 +181,9 @@ int main(int argc, char *argv[]) } switch (st.st_mode & S_IFMT) { +#ifndef WIN32 case S_IFLNK: +#endif case S_IFREG: printf("-"); break; diff --git a/include/libnfs-private.h b/include/libnfs-private.h index f995a7e..79ac411 100644 --- a/include/libnfs-private.h +++ b/include/libnfs-private.h @@ -18,11 +18,14 @@ #include "config.h" /* HAVE_SOCKADDR_STORAGE ? */ #endif +#ifndef WIN32 #include /* struct sockaddr_storage */ +#endif #include "libnfs-zdr.h" -#ifndef HAVE_SOCKADDR_STORAGE + +#if !defined(HAVE_SOCKADDR_STORAGE) && !defined(WIN32) /* * RFC 2553: protocol-independent placeholder for socket addresses */ diff --git a/include/nfsc/libnfs-zdr.h b/include/nfsc/libnfs-zdr.h index aae56be..5d9fe7c 100644 --- a/include/nfsc/libnfs-zdr.h +++ b/include/nfsc/libnfs-zdr.h @@ -29,6 +29,13 @@ #ifndef _LIBNFS_ZDR_H_ #define _LIBNFS_ZDR_H_ +#ifdef WIN32 +#ifndef CADDR_T_DEFINED +#define CADDR_T_DEFINED +typedef char *caddr_t; +#endif +#endif + #include #include #include @@ -41,6 +48,7 @@ /* we dont need these */ typedef void CLIENT; struct svc_req { + int _dummy_; }; typedef void SVCXPRT; diff --git a/lib/init.c b/lib/init.c index ecac1e7..09ab61c 100644 --- a/lib/init.c +++ b/lib/init.c @@ -61,11 +61,7 @@ struct rpc_context *rpc_init_context(void) return NULL; } -#if defined(WIN32) - rpc->auth = authunix_create("LibNFS", 65535, 65535, 0, NULL); -#else rpc->auth = authunix_create_default(); -#endif if (rpc->auth == NULL) { free(rpc->encodebuf); free(rpc); diff --git a/lib/libnfs-sync.c b/lib/libnfs-sync.c index 4478a49..5ca7c66 100644 --- a/lib/libnfs-sync.c +++ b/lib/libnfs-sync.c @@ -32,6 +32,7 @@ #include #include #include +#include #endif /*WIN32*/ #ifdef ANDROID @@ -65,7 +66,6 @@ #include #include #include -#include #include #ifdef HAVE_SYS_SOCKIO_H diff --git a/lib/libnfs-zdr.c b/lib/libnfs-zdr.c index 29bb18d..e904df9 100644 --- a/lib/libnfs-zdr.c +++ b/lib/libnfs-zdr.c @@ -504,7 +504,11 @@ struct AUTH *libnfs_authunix_create(char *host, uint32_t uid, uint32_t gid, uint struct AUTH *libnfs_authunix_create_default(void) { +#ifdef WIN32 + return libnfs_authunix_create("libnfs", 65535, 65535, 0, NULL); +#else return libnfs_authunix_create("libnfs", getuid(), getgid(), 0, NULL); +#endif } void libnfs_auth_destroy(struct AUTH *auth) diff --git a/lib/libnfs.c b/lib/libnfs.c index d2f60da..97663ac 100644 --- a/lib/libnfs.c +++ b/lib/libnfs.c @@ -30,6 +30,7 @@ #else #include #include +#include #endif /*WIN32*/ #ifdef ANDROID @@ -59,7 +60,6 @@ #include #include #include -#include #include "libnfs-zdr.h" #include "libnfs.h" #include "libnfs-raw.h" diff --git a/lib/pdu.c b/lib/pdu.c index 5dff517..3d8feca 100644 --- a/lib/pdu.c +++ b/lib/pdu.c @@ -22,13 +22,13 @@ #include "win32_compat.h" #else #include +#include +#include #endif/*WIN32*/ #include #include #include -#include -#include #include #include #include "slist.h" diff --git a/nfs/libnfs-raw-nfs.h b/nfs/libnfs-raw-nfs.h index 2d04497..dc47c05 100644 --- a/nfs/libnfs-raw-nfs.h +++ b/nfs/libnfs-raw-nfs.h @@ -21,6 +21,10 @@ extern "C" { typedef long long int quad_t; typedef long long unsigned u_quad_t; #endif +#if defined(WIN32) +typedef long long int quad_t; +typedef long long unsigned u_quad_t; +#endif typedef char cookieverf3[NFS3_COOKIEVERFSIZE]; diff --git a/win32/win32_compat.h b/win32/win32_compat.h index abdf1db..71f10bd 100644 --- a/win32/win32_compat.h +++ b/win32/win32_compat.h @@ -105,6 +105,5 @@ int win32_poll(struct pollfd *fds, unsigned int nfsd, int timeout); int win32_gettimeofday(struct timeval *tv, struct timezone *tz); #define DllExport -#define HAVE_POLL_H #endif//win32_COMPAT_H_ diff --git a/win32build.bat b/win32build.bat index 86641e3..35a3c30 100755 --- a/win32build.bat +++ b/win32build.bat @@ -1,69 +1,90 @@ -rem build script for win32 -rem set the -rem - - - -rem NFS -rem -cl /I. /Iinclude -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd nfs\libnfs-raw-nfs.c -Fonfs\libnfs-raw-nfs.obj -cl /I. /Iinclude -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd nfs\nfs.c -Fonfs\nfs.obj -cl /I. /Iinclude -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd nfs\nfsacl.c -Fonfs\nfsacl.obj - - - -rem -rem RQUOTA -rem -cl /I. /Iinclude -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd rquota\libnfs-raw-rquota.c -Forquota\libnfs-raw-rquota.obj -cl /I. /Iinclude -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd rquota\rquota.c -Forquota\rquota.obj - - - -rem -rem PORTMAP -rem -cl /I. /Iinclude -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd portmap\libnfs-raw-portmap.c -Foportmap\libnfs-raw-portmap.obj -cl /I. /Iinclude -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd portmap\portmap.c -Foportmap\portmap.obj - - -rem -rem MOUNT -rem -cl /I. /Iinclude -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd mount\libnfs-raw-mount.c -Fomount\libnfs-raw-mount.obj -cl /I. /Iinclude -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd mount\mount.c -Fomount\mount.obj - - - -rem -rem generate core part of library -rem -cl /I. /Iinclude -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd lib\init.c -Folib\init.obj -cl /I. /Iinclude -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd -D_U_="" lib\pdu.c -Folib\pdu.obj -cl /I. /Iinclude -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd -D_U_="" lib\socket.c -Folib\socket.obj -cl /I. /Iinclude /Imount /Infs -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd -D_U_="" lib\libnfs.c -Folib\libnfs.obj -cl /I. /Iinclude /Imount /Infs -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd -D_U_="" lib\libnfs-sync.c -Folib\libnfs-sync.obj - - - -rem -rem create a linklibrary/dll -rem -lib /out:lib\libnfs.lib /def:lib\libnfs-win32.def nfs\nfs.obj nfs\nfsacl.obj nfs\libnfs-raw-nfs.obj rquota\rquota.obj rquota\libnfs-raw-rquota.obj mount\mount.obj mount\libnfs-raw-mount.obj portmap\portmap.obj portmap\libnfs-raw-portmap.obj lib\init.obj lib\pdu.obj lib\socket.obj lib\libnfs.obj lib\libnfs-sync.obj - -link /DLL /out:lib\libnfs.dll /DEBUG /DEBUGTYPE:cv lib\libnfs.exp nfs\nfs.obj nfs\nfsacl.obj nfs\libnfs-raw-nfs.obj rquota\rquota.obj rquota\libnfs-raw-rquota.obj mount\mount.obj mount\libnfs-raw-mount.obj portmap\portmap.obj portmap\libnfs-raw-portmap.obj lib\init.obj lib\pdu.obj lib\socket.obj lib\libnfs.obj lib\libnfs-sync.obj ws2_32.lib - - - -rem -rem build a test application -rem -cl /I. /Iinclude /Imount /Infs -Zi -Od -DWIN32 -D_WIN32_WINNT=0x0600 -MDd -D_U_="" examples\nfsclient-sync.c lib\libnfs.lib WS2_32.lib kernel32.lib mswsock.lib advapi32.lib wsock32.lib advapi32.lib - - - - - - - - +rem build script for win32 +rem set the +rem + + + +rem NFS +rem +cl /I. /Iwin32 /Iinclude/nfsc /Iinclude -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd nfs\libnfs-raw-nfs.c -Fonfs\libnfs-raw-nfs.obj +cl /I. /Iwin32 /Iinclude/nfsc /Iinclude -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd nfs\nfs.c -Fonfs\nfs.obj +cl /I. /Iwin32 /Iinclude/nfsc /Iinclude -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd nfs\nfsacl.c -Fonfs\nfsacl.obj + + + +rem +rem RQUOTA +rem +cl /I. /Iwin32 /Iinclude/nfsc /Iinclude -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd rquota\libnfs-raw-rquota.c -Forquota\libnfs-raw-rquota.obj +cl /I. /Iwin32 /Iinclude/nfsc /Iinclude -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd rquota\rquota.c -Forquota\rquota.obj + + + +rem +rem PORTMAP +rem +cl /I. /Iwin32 /Iinclude/nfsc /Iinclude -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd portmap\libnfs-raw-portmap.c -Foportmap\libnfs-raw-portmap.obj +cl /I. /Iwin32 /Iinclude/nfsc /Iinclude -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd portmap\portmap.c -Foportmap\portmap.obj + + +rem +rem MOUNT +rem +cl /I. /Iwin32 /Iinclude/nfsc /Iinclude -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd mount\libnfs-raw-mount.c -Fomount\libnfs-raw-mount.obj +cl /I. /Iwin32 /Iinclude/nfsc /Iinclude -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd mount\mount.c -Fomount\mount.obj + + + +rem +rem generate core part of library +rem +cl /I. /Iwin32 /Iinclude/nfsc /Iinclude -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd lib\init.c -Folib\init.obj +cl /I. /Iwin32 /Iinclude/nfsc /Iinclude -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd -D_U_="" lib\pdu.c -Folib\pdu.obj +cl /I. /Iwin32 /Iinclude/nfsc /Iinclude -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd -D_U_="" lib\socket.c -Folib\socket.obj +cl /I. /Iwin32 /Iinclude/nfsc /Iinclude /Imount /Infs -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd -D_U_="" lib\libnfs.c -Folib\libnfs.obj +cl /I. /Iwin32 /Iinclude/nfsc /Iinclude /Imount /Infs -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd -D_U_="" lib\libnfs-sync.c -Folib\libnfs-sync.obj +cl /I. /Iwin32 /Iinclude/nfsc /Iinclude /Imount /Infs -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd -D_U_="" lib\libnfs-zdr.c -Folib\libnfs-zdr.obj +cl /I. /Iwin32 /Iinclude/nfsc /Iinclude /Imount /Infs -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd -D_U_="" win32\win32_compat.c -Fowin32\win32_compat.obj + + + +rem +rem create a linklibrary/dll +rem +lib /out:lib\libnfs.lib /def:lib\libnfs-win32.def nfs\nfs.obj nfs\nfsacl.obj nfs\libnfs-raw-nfs.obj rquota\rquota.obj rquota\libnfs-raw-rquota.obj mount\mount.obj mount\libnfs-raw-mount.obj portmap\portmap.obj portmap\libnfs-raw-portmap.obj lib\init.obj lib\pdu.obj lib\socket.obj lib\libnfs.obj lib\libnfs-sync.obj lib\libnfs-zdr.obj win32\win32_compat.obj + +link /DLL /out:lib\libnfs.dll /DEBUG /DEBUGTYPE:cv lib\libnfs.exp nfs\nfs.obj nfs\nfsacl.obj nfs\libnfs-raw-nfs.obj rquota\rquota.obj rquota\libnfs-raw-rquota.obj mount\mount.obj mount\libnfs-raw-mount.obj portmap\portmap.obj portmap\libnfs-raw-portmap.obj lib\init.obj lib\pdu.obj lib\socket.obj lib\libnfs.obj lib\libnfs-sync.obj lib\libnfs-zdr.obj win32\win32_compat.obj ws2_32.lib + + + +rem +rem build a test application +rem +cl /I. /Iwin32 /Iinclude/nfsc /Iinclude /Imount /Infs -Zi -Od -DWIN32 -D_WIN32_WINNT=0x0600 -MDd -D_U_="" examples\nfs-ls.c lib\libnfs.lib WS2_32.lib kernel32.lib mswsock.lib advapi32.lib wsock32.lib advapi32.lib +cl /I. /Iwin32 /Iinclude/nfsc /Iinclude /Imount /Infs -Zi -Od -DWIN32 -D_WIN32_WINNT=0x0600 -MDd -D_U_="" examples\nfs-cp.c lib\libnfs.lib WS2_32.lib kernel32.lib mswsock.lib advapi32.lib wsock32.lib advapi32.lib + + + + + + + + +.lib mswsock.lib advapi32.lib wsock32.lib advapi32.lib + + + + + + + + + + + + + + + + +