#define NFSDIR "/BOOKS/Classics/"
#define _GNU_SOURCE
+
+#if defined(WIN32)
+#include <winsock2.h>
+typedef int off_t;
+#pragma comment(lib, "ws2_32.lib")
+WSADATA wsaData;
+#else
+#include <sys/statvfs.h>
+#include <unistd.h>
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/statvfs.h>
-#include <unistd.h>
#include <fcntl.h>
#include "libnfs.h"
#include <rpc/rpc.h> /* for authunix_create() */
{
struct nfs_context *nfs;
int i, ret;
+ off_t offset;
struct client client;
struct stat st;
struct nfsfh *nfsfh;
struct nfsdir *nfsdir;
struct nfsdirent *nfsdirent;
- client.server = SERVER;
- client.export = EXPORT;
- client.is_finished = 0;
- off_t offset;
struct statvfs svfs;
exports export, tmp;
+#if defined(WIN32)
+ if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) {
+ printf("Failed to start Winsock2\n");
+ exit(10);
+ }
+#endif
+
+ client.server = SERVER;
+ client.export = EXPORT;
+ client.is_finished = 0;
export = mount_getexports(SERVER);
if (export != NULL) {
printf("exports on server %s\n", SERVER);
exit(10);
}
while((nfsdirent = nfs_readdir(nfs, nfsdir)) != NULL) {
- char *filename = NULL;
+ char filename[1024];
printf("Inode:%d Name:%s ", (int)nfsdirent->inode, nfsdirent->name);
- asprintf(&filename, "%s/%s", NFSDIR, nfsdirent->name);
+ sprintf(&filename, "%s/%s", NFSDIR, nfsdirent->name);
ret = nfs_open(nfs, filename, O_RDONLY, &nfsfh);
- free(filename);
if (ret != 0) {
printf("Failed to open(%s) %s\n", filename, nfs_get_error(nfs));
exit(10);
*/
#define _GNU_SOURCE
+
+#if defined(WIN32)
+#include <winsock2.h>
+#else
+#include <unistd.h>
+#include <strings.h>
+#endif
+
#include <stdio.h>
#include <stdarg.h>
-#include <unistd.h>
#include <string.h>
-#include <strings.h>
#include <stdlib.h>
#include <rpc/rpc.h>
#include <rpc/xdr.h>
return NULL;
}
- rpc->auth = authunix_create_default();
+#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);
rpc->auth =NULL;
if (rpc->fd != -1) {
- close(rpc->fd);
+#if defined(WIN32)
+ closesocket(rpc->fd);
+#else
+ close(rpc->fd);
+#endif
}
if (rpc->encodebuf != NULL) {
* High level api to nfs filesystems
*/
+#if defined (WIN32)
+#include <winsock2.h>
+#define DllExport
+#else
+#include <strings.h>
+#include <unistd.h>
+#include <sys/statvfs.h>
+#include <poll.h>
+#include <sys/ioctl.h>
+#include <netdb.h>
+#include <sys/socket.h>
+#include <net/if.h>
+#endif
+
+#ifdef HAVE_CONFIG_H
#include "config.h"
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <strings.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/statvfs.h>
-#include <sys/ioctl.h>
-#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
-#include <poll.h>
-#include <sys/socket.h>
-#include <net/if.h>
-#include <netdb.h>
#include "libnfs.h"
#include "libnfs-raw.h"
#include "libnfs-raw-mount.h"
-
+#if !defined(WIN32)
void free_nfs_srvr_list(struct nfs_server_list *srv)
{
while (srv != NULL) {
return data.srvrs;
}
+#endif