X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=lib%2Finit.c;h=5663f250123ef1b6bccf24b0b84feae768083961;hb=1ad6f93185b6735f259d2e7ff13da0f6776e8f5c;hp=fb2ae83512150b4f0eb0114eccbc11ec9b5dcad5;hpb=84004dbf9bb2ab8a7f8b968affc53ee3065fa911;p=deb_libnfs.git diff --git a/lib/init.c b/lib/init.c index fb2ae83..5663f25 100644 --- a/lib/init.c +++ b/lib/init.c @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include #include "slist.h" #include "libnfs.h" @@ -33,7 +35,6 @@ struct rpc_context *rpc_init_context(void) rpc = malloc(sizeof(struct rpc_context)); if (rpc == NULL) { - printf("Failed to allocate rpc context\n"); return NULL; } bzero(rpc, sizeof(struct rpc_context)); @@ -41,14 +42,12 @@ struct rpc_context *rpc_init_context(void) 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; } rpc->auth = authunix_create_default(); if (rpc->auth == NULL) { - printf("failed to create authunix\n"); free(rpc->encodebuf); free(rpc); return NULL; @@ -60,6 +59,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) { @@ -137,6 +148,11 @@ void rpc_destroy_context(struct rpc_context *rpc) rpc->error_string = NULL; } + if (rpc->udp_dest != NULL) { + free(rpc->udp_dest); + rpc->udp_dest = NULL; + } + free(rpc); }