X-Git-Url: http://git.thejh.net/?p=libjh.git;a=blobdiff_plain;f=net.c;h=2fba39ada9b800539d6e6964aac052af3311b2fd;hp=8d67e71be62b551f4eed403da97de9b992cf3690;hb=467866fd55129d1149200c44849c08e9f71f33a7;hpb=ae33d7fe92d8dd8593e7a2b938d1f42d2aa60896 diff --git a/net.c b/net.c index 8d67e71..2fba39a 100644 --- a/net.c +++ b/net.c @@ -40,20 +40,10 @@ err_socket: return EAI_SYSTEM; } -// err points to where the error from netopen() should be stored -PUBLIC_FN FILE *fnetopen(const char *node, const char *service, const struct addrinfo *hints, int *err) { - int rval = netopen(node, service, hints); - if (rval < 0) goto err; - - FILE *res = fdopen(rval, "r+"); - if (res) return res; - - int errno_ = errno; - close(rval); - errno = errno_; - rval = EAI_SYSTEM; - -err: - if (err) *err = rval; - return NULL; +PUBLIC_FN int fnetopen(FILE **in, FILE **out, const char *node, const char *service, const struct addrinfo *hints) { + int fd = netopen(node, service, hints); + if (fd < 0) return EAI_SYSTEM; + int ret = fopen_bistream(in, out, fd, 0); + if (ret) close(fd); + return ret; } \ No newline at end of file