X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Funix.c;h=8006a6114a50668b6f423a94ba3546750d4a9398;hp=5d6cad19cc88ed87c5d7020d89c8abc05c913421;hb=3498164f9058a807e5e25de88ecce61b97df2d14;hpb=ee6ab2ee3a9ee1a8c65d7272ec7fba1d886f5af0 diff --git a/src/unix.c b/src/unix.c index 5d6cad1..8006a61 100644 --- a/src/unix.c +++ b/src/unix.c @@ -1,5 +1,5 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2008 Index Data + * Copyright (C) 1995-2010 Index Data * See the file LICENSE for details. */ /** @@ -38,7 +38,7 @@ #endif #include -#include +#include #ifndef YAZ_SOCKLEN_T #define YAZ_SOCKLEN_T int @@ -52,7 +52,7 @@ #endif #endif -static int unix_close(COMSTACK h); +static void unix_close(COMSTACK h); static int unix_put(COMSTACK h, char *buf, int size); static int unix_get(COMSTACK h, char **buf, int *bufsize); static int unix_connect(COMSTACK h, void *address); @@ -65,7 +65,7 @@ static int unix_listen(COMSTACK h, char *raddr, int *addrlen, static int unix_set_blocking(COMSTACK p, int blocking); static COMSTACK unix_accept(COMSTACK h); -static char *unix_addrstr(COMSTACK h); +static const char *unix_addrstr(COMSTACK h); static void *unix_straddr(COMSTACK h, const char *str); #ifndef SUN_LEN @@ -157,7 +157,6 @@ COMSTACK unix_type(int s, int flags, int protocol, void *vp) p->state = new_socket ? CS_ST_UNBND : CS_ST_IDLE; /* state of line */ p->event = CS_NONE; p->cerrno = 0; - p->stackerr = 0; p->user = 0; state->altbuf = 0; @@ -425,8 +424,16 @@ static int unix_bind(COMSTACK h, void *address, int mode) h->cerrno = CSYSERR; return -1; } - chown(path, sp->uid, sp->gid); - chmod(path, sp->umask != -1 ? sp->umask : 0666); + if (chown(path, sp->uid, sp->gid)) + { + h->cerrno = CSYSERR; + return -1; + } + if (chmod(path, sp->umask != -1 ? sp->umask : 0666)) + { + h->cerrno = CSYSERR; + return -1; + } if (mode == CS_SERVER && listen(h->iofile, 100) < 0) { h->cerrno = CSYSERR; @@ -693,7 +700,7 @@ static int unix_put(COMSTACK h, char *buf, int size) return 0; } -static int unix_close(COMSTACK h) +static void unix_close(COMSTACK h) { unix_state *sp = (struct unix_state *)h->cprivate; @@ -706,10 +713,9 @@ static int unix_close(COMSTACK h) xfree(sp->altbuf); xfree(sp); xfree(h); - return 0; } -static char *unix_addrstr(COMSTACK h) +static const char *unix_addrstr(COMSTACK h) { unix_state *sp = (struct unix_state *)h->cprivate; char *buf = sp->buf; @@ -737,6 +743,7 @@ static int unix_set_blocking(COMSTACK p, int flags) /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab