repositories
/
deb_libnfs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Win32: more win32 adaptations
[deb_libnfs.git]
/
lib
/
init.c
diff --git
a/lib/init.c
b/lib/init.c
index dde97d773062d8438e7c3c972a821740f275949d..536a56c605ac75111b10ba0e142d7690c1b41649 100644
(file)
--- a/
lib/init.c
+++ b/
lib/init.c
@@
-16,11
+16,17
@@
*/
#define _GNU_SOURCE
*/
#define _GNU_SOURCE
+
+#if defined(WIN32)
+#include <winsock2.h>
+#else
+#include <unistd.h>
+#include <strings.h>
+#endif
+
#include <stdio.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdarg.h>
-#include <unistd.h>
#include <string.h>
#include <string.h>
-#include <strings.h>
#include <stdlib.h>
#include <rpc/rpc.h>
#include <rpc/xdr.h>
#include <stdlib.h>
#include <rpc/rpc.h>
#include <rpc/xdr.h>
@@
-35,7
+41,6
@@
struct rpc_context *rpc_init_context(void)
rpc = malloc(sizeof(struct rpc_context));
if (rpc == NULL) {
rpc = malloc(sizeof(struct rpc_context));
if (rpc == NULL) {
- printf("Failed to allocate rpc context\n");
return NULL;
}
bzero(rpc, sizeof(struct rpc_context));
return NULL;
}
bzero(rpc, sizeof(struct rpc_context));
@@
-43,14
+48,16
@@
struct rpc_context *rpc_init_context(void)
rpc->encodebuflen = 65536;
rpc->encodebuf = malloc(rpc->encodebuflen);
if (rpc->encodebuf == NULL) {
rpc->encodebuflen = 65536;
rpc->encodebuf = malloc(rpc->encodebuflen);
if (rpc->encodebuf == NULL) {
- printf("Failed to allocate a buffer for rpc encoding\n");
free(rpc);
return NULL;
}
free(rpc);
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) {
if (rpc->auth == NULL) {
- printf("failed to create authunix\n");
free(rpc->encodebuf);
free(rpc);
return NULL;
free(rpc->encodebuf);
free(rpc);
return NULL;
@@
-62,6
+69,18
@@
struct rpc_context *rpc_init_context(void)
}
}
+struct rpc_context *rpc_init_udp_context(void)
+{
+ struct rpc_context *rpc;
+
+ rpc = rpc_init_context();
+ if (rpc != NULL) {
+ rpc->is_udp = 1;
+ }
+
+ return rpc;
+}
+
void rpc_set_auth(struct rpc_context *rpc, struct AUTH *auth)
{
if (rpc->auth != NULL) {
void rpc_set_auth(struct rpc_context *rpc, struct AUTH *auth)
{
if (rpc->auth != NULL) {
@@
-126,7
+145,11
@@
void rpc_destroy_context(struct rpc_context *rpc)
rpc->auth =NULL;
if (rpc->fd != -1) {
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) {
}
if (rpc->encodebuf != NULL) {
@@
-139,6
+162,11
@@
void rpc_destroy_context(struct rpc_context *rpc)
rpc->error_string = NULL;
}
rpc->error_string = NULL;
}
+ if (rpc->udp_dest != NULL) {
+ free(rpc->udp_dest);
+ rpc->udp_dest = NULL;
+ }
+
free(rpc);
}
free(rpc);
}