Skip to content

Commit

Permalink
WIN32 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sahlberg committed May 28, 2013
1 parent e083c2a commit 67a9f57
Show file tree
Hide file tree
Showing 13 changed files with 126 additions and 83 deletions.
2 changes: 2 additions & 0 deletions examples/nfs-cp.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

#ifdef WIN32
#include "win32_compat.h"
#pragma comment(lib, "ws2_32.lib")
WSADATA wsaData;
#else
#include <sys/stat.h>
#include <string.h>
Expand Down
7 changes: 5 additions & 2 deletions examples/nfs-ls.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
#include "win32_compat.h"
#pragma comment(lib, "ws2_32.lib")
WSADATA wsaData;
#define PRId64 "ll"
#else
#include <inttypes.h>
#include <string.h>
#include <sys/stat.h>
#ifndef AROS
Expand All @@ -45,7 +47,6 @@ WSADATA wsaData;
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
Expand Down Expand Up @@ -167,15 +168,17 @@ 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));
continue;
}

switch (st.st_mode & S_IFMT) {
#ifndef WIN32
case S_IFLNK:
#endif
case S_IFREG:
printf("-");
break;
Expand Down
7 changes: 5 additions & 2 deletions examples/nfsclient-sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
#include "win32_compat.h"
#pragma comment(lib, "ws2_32.lib")
WSADATA wsaData;
#define PRId64 "ll"
#else
#include <inttypes.h>
#include <string.h>
#include <sys/stat.h>
#ifndef AROS
Expand All @@ -47,7 +49,6 @@ WSADATA wsaData;
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
Expand Down Expand Up @@ -172,15 +173,17 @@ 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));
continue;
}

switch (st.st_mode & S_IFMT) {
#ifndef WIN32
case S_IFLNK:
#endif
case S_IFREG:
printf("-");
break;
Expand Down
5 changes: 4 additions & 1 deletion include/libnfs-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
#include "config.h" /* HAVE_SOCKADDR_STORAGE ? */
#endif

#ifndef WIN32
#include <sys/socket.h> /* 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
*/
Expand Down
8 changes: 8 additions & 0 deletions include/nfsc/libnfs-zdr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stdio.h>
#include <assert.h>
#include <stdint.h>
Expand All @@ -41,6 +48,7 @@
/* we dont need these */
typedef void CLIENT;
struct svc_req {
int _dummy_;
};
typedef void SVCXPRT;

Expand Down
4 changes: 0 additions & 4 deletions lib/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/libnfs-sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <netdb.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
#endif /*WIN32*/

#ifdef ANDROID
Expand Down Expand Up @@ -65,7 +66,6 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <errno.h>

#ifdef HAVE_SYS_SOCKIO_H
Expand Down
4 changes: 4 additions & 0 deletions lib/libnfs-zdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/libnfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#else
#include <strings.h>
#include <utime.h>
#include <netinet/in.h>
#endif /*WIN32*/

#ifdef ANDROID
Expand Down Expand Up @@ -59,7 +60,6 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <netinet/in.h>
#include "libnfs-zdr.h"
#include "libnfs.h"
#include "libnfs-raw.h"
Expand Down
4 changes: 2 additions & 2 deletions lib/pdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
#include "win32_compat.h"
#else
#include <strings.h>
#include <sys/socket.h>
#include <netinet/in.h>
#endif/*WIN32*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <assert.h>
#include <errno.h>
#include "slist.h"
Expand Down
4 changes: 4 additions & 0 deletions nfs/libnfs-raw-nfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down
1 change: 0 additions & 1 deletion win32/win32_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_
159 changes: 90 additions & 69 deletions win32build.bat
Original file line number Diff line number Diff line change
@@ -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

















0 comments on commit 67a9f57

Please sign in to comment.