projects
/
yaz-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix doc WRT ZOOM opts start, doc (bug #2198)
[yaz-moved-to-github.git]
/
src
/
tcpip.c
diff --git
a/src/tcpip.c
b/src/tcpip.c
index
fcdcce1
..
ffbcf44
100644
(file)
--- a/
src/tcpip.c
+++ b/
src/tcpip.c
@@
-1,5
+1,5
@@
/* This file is part of the YAZ toolkit.
/* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2008 Index Data
+ * Copyright (C) 1995-2009 Index Data
* See the file LICENSE for details.
*/
/**
* See the file LICENSE for details.
*/
/**
@@
-25,7
+25,6
@@
#endif
#ifdef WIN32
#endif
#ifdef WIN32
-
/* VS 2003 or later has getaddrinfo; older versions do not */
#include <winsock2.h>
#if _MSC_VER >= 1300
/* VS 2003 or later has getaddrinfo; older versions do not */
#include <winsock2.h>
#if _MSC_VER >= 1300
@@
-34,14
+33,20
@@
#else
#define HAVE_GETADDRINFO 0
#endif
#else
#define HAVE_GETADDRINFO 0
#endif
+#endif
-#else
+#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#include <netinet/in.h>
+#endif
+#if HAVE_NETDB_H
#include <netdb.h>
#include <netdb.h>
+#endif
+#if HAVE_ARPA_INET_H
#include <arpa/inet.h>
#include <arpa/inet.h>
+#endif
+#if HAVE_NETINET_TCP_H
#include <netinet/tcp.h>
#endif
#include <netinet/tcp.h>
#endif
-
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
@@
-63,7
+68,7
@@
#include <yaz/comstack.h>
#include <yaz/tcpip.h>
#include <yaz/comstack.h>
#include <yaz/tcpip.h>
-#include <yaz/nmem.h>
+#include <yaz/errno.h>
static int tcpip_close(COMSTACK h);
static int tcpip_put(COMSTACK h, char *buf, int size);
static int tcpip_close(COMSTACK h);
static int tcpip_put(COMSTACK h, char *buf, int size);
@@
-413,7
+418,6
@@
int tcpip_strtoaddr_ex(const char *str, struct sockaddr_in *add,
return 1;
}
return 1;
}
-
#if HAVE_GETADDRINFO
void *tcpip_straddr(COMSTACK h, const char *str)
{
#if HAVE_GETADDRINFO
void *tcpip_straddr(COMSTACK h, const char *str)
{
@@
-435,7
+439,10
@@
void *tcpip_straddr(COMSTACK h, const char *str)
{
s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
if (s != -1)
{
s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
if (s != -1)
+ {
+ sp->ai = ai;
break;
break;
+ }
}
if (s == -1)
return 0;
}
if (s == -1)
return 0;
@@
-806,7
+813,11
@@
int tcpip_listen(COMSTACK h, char *raddr, int *addrlen,
h->cerrno = CSOUTSTATE;
return -1;
}
h->cerrno = CSOUTSTATE;
return -1;
}
+#ifdef WIN32
+ h->newfd = accept(h->iofile, 0, 0);
+#else
h->newfd = accept(h->iofile, (struct sockaddr*)&addr, &len);
h->newfd = accept(h->iofile, (struct sockaddr*)&addr, &len);
+#endif
if (h->newfd < 0)
{
if (
if (h->newfd < 0)
{
if (
@@
-1039,8
+1050,8
@@
int tcpip_get(COMSTACK h, char **buf, int *bufsize)
TRC(fprintf(stderr, "tcpip_get: bufsize=%d\n", *bufsize));
if (sp->altlen) /* switch buffers */
{
TRC(fprintf(stderr, "tcpip_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;
tmpc = *buf;
tmpi = *bufsize;
*buf = sp->altbuf;
@@
-1145,8
+1156,8
@@
int tcpip_get(COMSTACK h, char **buf, int *bufsize)
h->cerrno = CSYSERR;
return -1;
}
h->cerrno = CSYSERR;
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_TCPIP_BUFCHUNK - 1)
memcpy(sp->altbuf, *buf + berlen, sp->altlen = tomove);
}
if (berlen < CS_TCPIP_BUFCHUNK - 1)
@@
-1170,8
+1181,8
@@
int ssl_get(COMSTACK h, char **buf, int *bufsize)
TRC(fprintf(stderr, "ssl_get: bufsize=%d\n", *bufsize));
if (sp->altlen) /* switch buffers */
{
TRC(fprintf(stderr, "ssl_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;
tmpc = *buf;
tmpi = *bufsize;
*buf = sp->altbuf;
@@
-1229,8
+1240,8
@@
int ssl_get(COMSTACK h, char **buf, int *bufsize)
} else if (sp->altsize < req)
if (!(sp->altbuf =(char *)xrealloc(sp->altbuf, sp->altsize = req)))
return -1;
} 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_TCPIP_BUFCHUNK - 1)
memcpy(sp->altbuf, *buf + berlen, sp->altlen = tomove);
}
if (berlen < CS_TCPIP_BUFCHUNK - 1)
@@
-1662,6
+1673,7
@@
static int tcpip_get_connect(COMSTACK h, char **buf, int *bufsize)
/*
* Local variables:
* c-basic-offset: 4
/*
* Local variables:
* c-basic-offset: 4
+ * c-file-style: "Stroustrup"
* indent-tabs-mode: nil
* End:
* vim: shiftwidth=4 tabstop=8 expandtab
* indent-tabs-mode: nil
* End:
* vim: shiftwidth=4 tabstop=8 expandtab