/* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2009 Index Data
+ * Copyright (C) 1995-2013 Index Data
* See the file LICENSE for details.
*/
/**
* \file unix.c
* \brief Implements UNIX domain socket COMSTACK
*/
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
#ifndef WIN32
#endif
#include <yaz/unix.h>
-#include <yaz/nmem.h>
+#include <yaz/errno.h>
#ifndef YAZ_SOCKLEN_T
#define YAZ_SOCKLEN_T int
#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);
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
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;
unix_state *sp = (unix_state *)h->cprivate;
char * s = f;
const char * file = NULL;
- char * eol;
sp->uid = sp->gid = sp->umask = -1;
- if ((eol = strchr(s, ',')))
+ if (strchr(s, '='))
{
+ char *eol;
do
{
if ((eol = strchr(s, ',')))
{
char * end;
char * arg = s + 6;
-
+
sp->umask = strtol(arg, &end, 8);
if (errno == EINVAL ||
*end)
}
return 0;
}
- if (!(cnew->flags&CS_FLAGS_BLOCKING) &&
+ if (!(cnew->flags&CS_FLAGS_BLOCKING) &&
(fcntl(cnew->iofile, F_SETFL, O_NONBLOCK) < 0)
)
{
TRC(fprintf(stderr, "unix_get: bufsize=%d\n", *bufsize));
if (sp->altlen) /* switch buffers */
{
- TRC(fprintf(stderr, " %d bytes in altbuf (0x%x)\n", sp->altlen,
- (unsigned) sp->altbuf));
+ TRC(fprintf(stderr, " %d bytes in altbuf (%p )\n", sp->altlen,
+ sp->altbuf));
tmpc = *buf;
tmpi = *bufsize;
*buf = sp->altbuf;
} else if (sp->altsize < req)
if (!(sp->altbuf =(char *)xrealloc(sp->altbuf, sp->altsize = req)))
return -1;
- TRC(fprintf(stderr, " Moving %d bytes to altbuf(0x%x)\n", tomove,
- (unsigned) sp->altbuf));
+ TRC(fprintf(stderr, " Moving %d bytes to altbuf(%p)\n", tomove,
+ sp->altbuf));
memcpy(sp->altbuf, *buf + berlen, sp->altlen = tomove);
}
if (berlen < CS_UNIX_BUFCHUNK - 1)
return 0;
}
-static int unix_close(COMSTACK h)
+static void unix_close(COMSTACK h)
{
unix_state *sp = (struct unix_state *)h->cprivate;
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;