For server option -a@ produces APDU prints in YAZ log.
* Copyright (c) 1995-2002, Index Data
* See the file LICENSE for details.
*
- * $Id: tcpip.c,v 1.49 2002-09-20 22:23:13 adam Exp $
+ * $Id: tcpip.c,v 1.50 2002-09-25 12:37:07 adam Exp $
*/
#include <stdio.h>
return 1;
}
#else
- if (errno == EINPROGRESS)
+ if (yaz_errno() == EINPROGRESS)
{
h->event = CS_CONNECT;
h->state = CS_ST_CONNECTING;
#ifdef WIN32
WSAGetLastError() == WSAEWOULDBLOCK
#else
- errno == EWOULDBLOCK
+ yaz_errno() == EWOULDBLOCK
#ifdef EAGAIN
#if EAGAIN != EWOULDBLOCK
- || errno == EAGAIN
+ || yaz_errno() == EAGAIN
#endif
#endif
#endif
else
return -1;
#else
- if (errno == EWOULDBLOCK
+ if (yaz_errno() == EWOULDBLOCK
#ifdef EAGAIN
#if EAGAIN != EWOULDBLOCK
- || errno == EAGAIN
+ || yaz_errno() == EAGAIN
#endif
#endif
- || errno == EINPROGRESS
+ || yaz_errno() == EINPROGRESS
#ifdef __sun__
- || errno == ENOENT /* Sun's sometimes set errno to this */
+ || yaz_errno() == ENOENT /* Sun's sometimes set errno to this */
#endif
)
{
h->io_pending = CS_WANT_READ;
break;
}
- else if (errno == 0)
+ else if (yaz_errno() == 0)
continue;
else
return -1;
#ifdef WIN32
WSAGetLastError() == WSAEWOULDBLOCK
#else
- errno == EWOULDBLOCK
+ yaz_errno() == EWOULDBLOCK
#ifdef EAGAIN
#if EAGAIN != EWOULDBLOCK
- || errno == EAGAIN
+ || yaz_errno() == EAGAIN
#endif
#endif
#endif
* Copyright (c) 1995-2002, Index Data
* See the file LICENSE for details.
*
- * $Id: unix.c,v 1.6 2002-09-20 22:23:13 adam Exp $
+ * $Id: unix.c,v 1.7 2002-09-25 12:37:07 adam Exp $
* UNIX socket COMSTACK. By Morten Bøgeskov.
*/
#ifndef WIN32
r = connect(h->iofile, (struct sockaddr *) add, SUN_LEN(add));
if (r < 0)
{
- if (errno == EINPROGRESS)
+ if (yaz_errno() == EINPROGRESS)
{
h->event = CS_CONNECT;
h->state = CS_ST_CONNECTING;
int socket_out = -1;
if(! S_ISSOCK(stat_buf.st_mode)) {
h->cerrno = CSYSERR;
- errno = EEXIST; /* Not a socket (File exists) */
+ yaz_set_errno(EEXIST); /* Not a socket (File exists) */
return -1;
}
if((socket_out = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
socket_unix.sun_family = AF_UNIX;
strncpy(socket_unix.sun_path, path, sizeof(socket_unix.sun_path));
if(connect(socket_out, (struct sockaddr *) &socket_unix, SUN_LEN(&socket_unix)) < 0) {
- if(errno == ECONNREFUSED) {
+ if(yaz_errno() == ECONNREFUSED) {
TRC (fprintf (stderr, "Socket exists but nobody is listening\n"));
} else {
h->cerrno = CSYSERR;
} else {
close(socket_out);
h->cerrno = CSYSERR;
- errno = EADDRINUSE;
+ yaz_set_errno(EADDRINUSE);
return -1;
}
unlink(path);
if (h->newfd < 0)
{
if (
- errno == EWOULDBLOCK
+ yaz_errno() == EWOULDBLOCK
#ifdef EAGAIN
#if EAGAIN != EWOULDBLOCK
- || errno == EAGAIN
+ || yaz_errno() == EAGAIN
#endif
#endif
)
TRC(fprintf(stderr, " recv res=%d, hasread=%d\n", res, hasread));
if (res < 0)
{
- if (errno == EWOULDBLOCK
+ if (yaz_errno() == EWOULDBLOCK
#ifdef EAGAIN
#if EAGAIN != EWOULDBLOCK
- || errno == EAGAIN
+ || yaz_errno() == EAGAIN
#endif
#endif
- || errno == EINPROGRESS
+ || yaz_errno() == EINPROGRESS
)
{
h->io_pending = CS_WANT_READ;
break;
}
- else if (errno == 0)
+ else if (yaz_errno() == 0)
continue;
else
return -1;
)) < 0)
{
if (
- errno == EWOULDBLOCK
+ yaz_errno() == EWOULDBLOCK
#ifdef EAGAIN
#if EAGAIN != EWOULDBLOCK
- || errno == EAGAIN
+ || yaz_errno() == EAGAIN
#endif
#endif
)
* OF THIS SOFTWARE.
*
* $Log: nmem.h,v $
- * Revision 1.7 2002-09-10 18:41:18 adam
+ * Revision 1.8 2002-09-25 12:37:07 adam
+ * Thread-safe handling of errno variable.
+ * For server option -a@ produces APDU prints in YAZ log.
+ *
+ * Revision 1.7 2002/09/10 18:41:18 adam
* Added yaz_errno
*
* Revision 1.6 2001/06/26 14:11:27 adam
YAZ_EXPORT void nmem_init (void);
YAZ_EXPORT void nmem_exit (void);
YAZ_EXPORT int yaz_errno (void);
+YAZ_EXPORT void yaz_set_errno (int v);
YAZ_END_CDECL
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: eventl.c,v 1.31 2001-10-05 14:43:22 adam Exp $
+ * $Id: eventl.c,v 1.32 2002-09-25 12:37:07 adam Exp $
*/
#include <stdio.h>
res = YAZ_EV_SELECT(max + 1, &in, &out, &except, timeout);
if (res < 0)
{
- if (errno == EINTR)
+ if (yaz_errno() == EINTR)
continue;
else
{
* Copyright (c) 1995-2002, Index Data
* See the file LICENSE for details.
*
- * $Id: seshigh.c,v 1.131 2002-07-25 12:52:54 adam Exp $
+ * $Id: seshigh.c,v 1.132 2002-09-25 12:37:07 adam Exp $
*/
/*
strcpy(filename, control_block->apdufile);
if (!(anew->print = odr_createmem(ODR_PRINT)))
return 0;
- if (*control_block->apdufile != '-')
+ if (*control_block->apdufile == '@')
+ {
+ odr_setprint(anew->print, yaz_log_file());
+ }
+ else if (*control_block->apdufile != '-')
{
strcpy(filename, control_block->apdufile);
if (!control_block->dynamic)
* NT threaded server code by
* Chas Woodfield, Fretwell Downing Informatics.
*
- * $Id: statserv.c,v 1.84 2002-09-06 19:52:57 adam Exp $
+ * $Id: statserv.c,v 1.85 2002-09-25 12:37:07 adam Exp $
*/
#include <stdio.h>
char dummy[1];
int res;
- if ((res = read(hand[0], dummy, 1)) < 0 && errno != EINTR)
+ if ((res = read(hand[0], dummy, 1)) < 0 &&
+ yaz_errno() != EINTR)
{
yaz_log(LOG_FATAL|LOG_ERRNO, "handshake read");
return;
* Copyright (c) 1995-2002, Index Data
* See the file LICENSE for details.
*
- * $Id: log.c,v 1.28 2002-08-29 09:58:42 adam Exp $
+ * $Id: log.c,v 1.29 2002-09-25 12:37:07 adam Exp $
*/
#if HAVE_CONFIG_H
strcat(buf, "]");
}
#else
- sprintf(buf + strlen(buf), " [%s]", strerror(errno));
+ sprintf(buf + strlen(buf), " [%s]", strerror(yaz_errno()));
#endif
}
if (start_hook_func)
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: nmem.c,v 1.36 2002-09-10 18:41:18 adam Exp $
+ * $Id: nmem.c,v 1.37 2002-09-25 12:37:07 adam Exp $
*/
/*
{
return errno;
}
+
+void yaz_set_errno(int v)
+{
+ errno = v;
+}
* Copyright (c) 1997-2002, Index Data
* See the file LICENSE for details.
*
- * $Id: siconv.c,v 1.5 2002-09-24 08:05:41 adam Exp $
+ * $Id: siconv.c,v 1.6 2002-09-25 12:37:08 adam Exp $
*/
/* mini iconv and wrapper for system iconv library (if present) */
iconv(cd->iconv_cd, inbuf, inbytesleft, outbuf, outbytesleft);
if (r == (size_t)(-1))
{
- switch (errno)
+ switch (yaz_errno())
{
case E2BIG:
cd->my_errno = YAZ_ICONV_E2BIG;