X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=comstack%2Fcomstack.c;h=07903eb7d9f3cdacb8b9f9505d3514231158b40f;hb=34203146338c5f6c89774bde4caad110345405bd;hp=84603168d902ca4482d1c3a4424d9f24be21425f;hpb=d9ee01635f03f9095a66f71b73580560d48798e8;p=yaz-moved-to-github.git diff --git a/comstack/comstack.c b/comstack/comstack.c index 8460316..07903eb 100644 --- a/comstack/comstack.c +++ b/comstack/comstack.c @@ -1,37 +1,14 @@ /* - * Copyright (c) 1995-1998, Index Data + * Copyright (c) 1995-2003, Index Data * See the file LICENSE for details. - * Sebastian Hammer, Adam Dickmeiss - * - * $Log: comstack.c,v $ - * Revision 1.6 1999-11-30 13:47:11 adam - * Improved installation. Moved header files to include/yaz. - * - * Revision 1.5 1998/06/22 11:32:35 adam - * Added 'conditional cs_listen' feature. - * - * Revision 1.4 1997/09/29 07:16:14 adam - * Array cs_errlist no longer global. - * - * Revision 1.3 1997/09/01 08:49:14 adam - * New windows NT/95 port using MSV5.0. Minor changes only. - * - * Revision 1.2 1995/09/29 17:01:48 quinn - * More Windows work - * - * Revision 1.1 1995/06/14 09:58:20 quinn - * Renamed yazlib to comstack. - * - * Revision 1.2 1995/05/16 08:51:15 quinn - * License, documentation, and memory fixes - * - * Revision 1.1 1995/03/14 10:28:34 quinn - * Adding server-side support to tcpip.c and fixing bugs in nonblocking I/O - * * + * $Id: comstack.c,v 1.11 2003-02-14 18:49:23 adam Exp $ */ +#include #include +#include +#include static const char *cs_errlist[] = { @@ -40,10 +17,70 @@ static const char *cs_errlist[] = "Operation out of state", "No data (operation would block)", "New data while half of old buffer is on the line (flow control)", - "Permission denied" + "Permission denied", + "SSL error" }; const char *cs_errmsg(int n) { + if (n < 0 || n > 6) + n = 0; return cs_errlist[n]; } + +const char *cs_strerror(COMSTACK h) +{ + return cs_errmsg(h->cerrno); +} + +COMSTACK cs_create_host(const char *type_and_host, int blocking, void **vp) +{ + const char *host = 0; + COMSTACK cs; + CS_TYPE t; + + if (strncmp (type_and_host, "tcp:", 4) == 0) + { + t = tcpip_type; + host = type_and_host + 4; + } + else if (strncmp (type_and_host, "ssl:", 4) == 0) + { +#if HAVE_OPENSSL_SSL_H + t = ssl_type; + host = type_and_host + 4; +#else + return 0; +#endif + } + else if (strncmp (type_and_host, "unix:", 5) == 0) + { +#ifndef WIN32 + t = unix_type; + host = type_and_host + 5; +#else + return 0; +#endif + } + else + { + t = tcpip_type; + host = type_and_host; + + } + cs = cs_create (t, blocking, PROTO_Z3950); + if (!cs) + return 0; + + if (!(*vp = cs_straddr(cs, host))) + { + cs_close (cs); + return 0; + } + return cs; +} + +int cs_look (COMSTACK cs) +{ + return cs->event; +}