summaryrefslogtreecommitdiff
path: root/network/nsclilib
diff options
context:
space:
mode:
authorAaron M. Ucko <ucko@debian.org>2005-03-23 20:19:28 +0000
committerAaron M. Ucko <ucko@debian.org>2005-03-23 20:19:28 +0000
commitc36b9906c3ef791147b3643f9e485cc02568819f (patch)
tree97b50039b1b1666f165eb1b05713b820e11b09bd /network/nsclilib
parent8db608ab43e4a775576ba5ff61add11d231de4b4 (diff)
Load ncbi (6.1.20020426) into ncbi-tools6/branches/upstream/current.
Diffstat (limited to 'network/nsclilib')
-rw-r--r--network/nsclilib/netcli.dsp165
-rw-r--r--network/nsclilib/ni_lib_.c11
-rw-r--r--network/nsclilib/ni_lib_.h17
-rw-r--r--network/nsclilib/ni_service.c190
4 files changed, 183 insertions, 200 deletions
diff --git a/network/nsclilib/netcli.dsp b/network/nsclilib/netcli.dsp
deleted file mode 100644
index f671f316..00000000
--- a/network/nsclilib/netcli.dsp
+++ /dev/null
@@ -1,165 +0,0 @@
-# Microsoft Developer Studio Project File - Name="netcli" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Static Library" 0x0104
-
-CFG=netcli - Win32 Release
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "netcli.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "netcli.mak" CFG="netcli - Win32 Release"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "netcli - Win32 Debug" (based on "Win32 (x86) Static Library")
-!MESSAGE "netcli - Win32 Release" (based on "Win32 (x86) Static Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "netcli - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /W2 /Gm /GX /ZI /Od /I "..\.." /I "..\..\ddv" /I "..\..\cn3d" /I "..\..\access" /I "..\..\asnstat" /I "..\..\connect\lbapi" /I "..\..\connect" /I "..\..\asnlib" /I "..\..\vibrant" /I "..\..\biostruc" /I "..\..\object" /I "..\..\api" /I "..\..\cdromlib" /I "..\..\desktop" /I "..\..\tools" /I "..\..\corelib" /I "..\taxon1\common" /I "..\vibnet" /I "..\entrez\client" /I "..\nsclilib" /I "..\medarch\client" /I "..\id1arch" /I "..\taxon1\taxon2" /I "..\blast3\client" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-
-!ELSEIF "$(CFG)" == "netcli - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "netcli___Win32_Release"
-# PROP BASE Intermediate_Dir "netcli___Win32_Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "netcli___Win32_Release"
-# PROP Intermediate_Dir "netcli___Win32_Release"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W2 /Gm /GX /ZI /Od /I "..\.." /I "..\..\ddv" /I "..\..\cn3d" /I "..\..\access" /I "..\..\asnstat" /I "..\..\connect\lbapi" /I "..\..\connect" /I "..\..\asnlib" /I "..\..\vibrant" /I "..\..\biostruc" /I "..\..\object" /I "..\..\api" /I "..\..\cdromlib" /I "..\..\desktop" /I "..\..\tools" /I "..\..\corelib" /I "..\taxon1\common" /I "..\vibnet" /I "..\entrez\client" /I "..\nsclilib" /I "..\medarch\client" /I "..\id1arch" /I "..\taxon1\taxon2" /I "..\blast3\client" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /I /GZ /c
-# SUBTRACT BASE CPP /Fr
-# ADD CPP /nologo /W2 /Gm /GX /Zi /I "..\.." /I "..\..\ddv" /I "..\..\cn3d" /I "..\..\access" /I "..\..\asnstat" /I "..\..\connect\lbapi" /I "..\..\connect" /I "..\..\asnlib" /I "..\..\vibrant" /I "..\..\biostruc" /I "..\..\object" /I "..\..\api" /I "..\..\cdromlib" /I "..\..\desktop" /I "..\..\tools" /I "..\..\corelib" /I "..\taxon1\common" /I "..\vibnet" /I "..\entrez\client" /I "..\nsclilib" /I "..\medarch\client" /I "..\id1arch" /I "..\taxon1\taxon2" /I "..\blast3\client" /D "_LIB" /D "WIN32" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-
-!ENDIF
-
-# Begin Target
-
-# Name "netcli - Win32 Debug"
-# Name "netcli - Win32 Release"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=..\..\connect\ncbi_misc.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\connect\ncbi_priv.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ncbicli.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ncbiurl.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ni_debug.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ni_disp.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ni_encrs.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ni_error.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ni_lib_.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ni_msg.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ni_www.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=..\..\connect\ncbi_misc.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\connect\ncbi_priv.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ncbicli.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ncbiurl.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ni_error.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ni_lib_.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ni_msg.h
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/network/nsclilib/ni_lib_.c b/network/nsclilib/ni_lib_.c
index ea6cd839..134cad32 100644
--- a/network/nsclilib/ni_lib_.c
+++ b/network/nsclilib/ni_lib_.c
@@ -1,4 +1,4 @@
-/* $RCSfile: ni_lib_.c,v $ $Revision: 4.9 $ $Date: 2001/02/21 22:09:27 $
+/* $RCSfile: ni_lib_.c,v $ $Revision: 4.10 $ $Date: 2002/04/16 21:34:20 $
* ==========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -32,6 +32,9 @@
*
* --------------------------------------------------------------------------
* $Log: ni_lib_.c,v $
+* Revision 4.10 2002/04/16 21:34:20 lavr
+* Disable old dispatcher completely and unconditionally
+*
* Revision 4.9 2001/02/21 22:09:27 lavr
* SERVICE connector included
*
@@ -64,11 +67,11 @@
#include <ncbinet.h>
#include <ncbithr.h>
-/* As for now, the old-fashioned interface is supported for all platforms
+/* From now on, the old-fashioned interface is NOT supported for all platforms
*/
-#define NI_DISP_SUPPORTED
+#undef NI_DISP_SUPPORTED
-/* As for now, the WWW(HTTPD)-based interfaces are not always supported
+/* WWW(HTTPD)-based interfaces are supported on selected platforms
*/
#if defined(OS_UNIX) || defined(OS_MSWIN) || defined(OS_MAC)
#define NI_WWW_SUPPORTED
diff --git a/network/nsclilib/ni_lib_.h b/network/nsclilib/ni_lib_.h
index 09c53c6a..c276c16c 100644
--- a/network/nsclilib/ni_lib_.h
+++ b/network/nsclilib/ni_lib_.h
@@ -1,7 +1,7 @@
#ifndef NI_LIB___H
#define NI_LIB___H
-/* $Id: ni_lib_.h,v 4.7 2001/02/21 22:09:27 lavr Exp $
+/* $Id: ni_lib_.h,v 4.8 2002/04/16 21:33:50 lavr Exp $
* ==========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -35,6 +35,9 @@
*
* --------------------------------------------------------------------------
* $Log: ni_lib_.h,v $
+* Revision 4.8 2002/04/16 21:33:50 lavr
+* Change "ni_serv.c" -> "ni_service.c"
+*
* Revision 4.7 2001/02/21 22:09:27 lavr
* SERVICE connector included
*
@@ -155,12 +158,12 @@ typedef struct {
* NOTE: although these are global, however they must *NOT* be referenced
* anywhere but in this module!
*/
-extern const NIInterface *g_NII_Dispatcher; /* "ni_lib.c" */
-extern const NIInterface *g_NII_WWW; /* "ni_www.c" */
-extern const NIInterface *g_NII_WWWFirewall; /* "ni_www.c" */
-extern const NIInterface *g_NII_WWWDirect; /* "ni_www.c" */
-extern const NIInterface *g_NII_Service; /* "ni_serv.c" */
-extern const NIInterface *g_NII_Debug; /* "ni_debug.c" */
+extern const NIInterface *g_NII_Dispatcher; /* "ni_disp.c" */
+extern const NIInterface *g_NII_WWW; /* "ni_www.c" */
+extern const NIInterface *g_NII_WWWFirewall; /* "ni_www.c" */
+extern const NIInterface *g_NII_WWWDirect; /* "ni_www.c" */
+extern const NIInterface *g_NII_Service; /* "ni_service.c" */
+extern const NIInterface *g_NII_Debug; /* "ni_debug.c" */
/* Try to extract the specified parameter from the environment or
diff --git a/network/nsclilib/ni_service.c b/network/nsclilib/ni_service.c
index 69c73546..8bd03210 100644
--- a/network/nsclilib/ni_service.c
+++ b/network/nsclilib/ni_service.c
@@ -1,4 +1,4 @@
-/* $RCSfile: ni_serv.c,v $ $Revision: 6.1 $ $Date: 2001/02/21 22:09:15 $
+/* $RCSfile: ni_service.c,v $ $Revision: 6.6 $ $Date: 2002/04/23 17:57:54 $
* ==========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -29,7 +29,22 @@
* NCBI Named Service Client (based on SERVICE connector)
*
* --------------------------------------------------------------------------
- * $Log: ni_serv.c,v $
+ * $Log: ni_service.c,v $
+ * Revision 6.6 2002/04/23 17:57:54 lavr
+ * Recognize "INFINITE" as a timeout from registry/environment
+ *
+ * Revision 6.5 2002/04/16 21:58:06 lavr
+ * Few fixes after test compilation and run
+ *
+ * Revision 6.4 2002/04/16 21:33:24 lavr
+ * Add compatibility for service parameters taken as for WWW disp
+ *
+ * Revision 6.3 2002/03/23 04:21:04 lavr
+ * Typo corrected
+ *
+ * Revision 6.2 2002/03/22 22:22:45 lavr
+ * Try to do the best in setting up proper timeouts
+ *
* Revision 6.1 2001/02/21 22:09:15 lavr
* Initial revision
*
@@ -46,6 +61,43 @@
* INTERNALS
*/
+/* Hard-coded constants, environment parameter names & defaults
+ * NOTE:: These are taken from ni_www.c for backward compatibility.
+ * Their use will eventually get deprecated in the future...
+ */
+
+#define SRV_SECTION "NET_SERV"
+
+#define ENV_ENGINE_HOST "SRV_ENGINE_HOST"
+#define DEF_ENGINE_HOST DEF_CONN_HOST
+
+#define ENV_ENGINE_PORT "SRV_ENGINE_PORT"
+#define DEF_ENGINE_PORT DEF_CONN_PORT
+
+#define ENV_ENGINE_URL "SRV_ENGINE_URL"
+#define DEF_ENGINE_URL DEF_CONN_PATH
+
+#define ENV_TIMEOUT "SRV_CONN_TIMEOUT"
+#define DEF_TIMEOUT DEF_CONN_TIMEOUT
+
+#define ENV_CONN_TRY "SRV_CONN_TRY"
+#define DEF_CONN_TRY DEF_CONN_MAX_TRY
+
+#define ENV_HTTP_PROXY_HOST "SRV_HTTP_PROXY_HOST"
+#define DEF_HTTP_PROXY_HOST DEF_CONN_HTTP_PROXY_HOST
+
+#define ENV_HTTP_PROXY_PORT "SRV_HTTP_PROXY_PORT"
+#define DEF_HTTP_PROXY_PORT DEF_CONN_HTTP_PROXY_PORT
+
+#define ENV_PROXY_HOST "SRV_PROXY_HOST"
+#define DEF_PROXY_HOST DEF_CONN_PROXY_HOST
+
+#define ENV_DEBUG_PRINTOUT "SRV_DEBUG_PRINTOUT"
+#define DEF_DEBUG_PRINTOUT DEF_CONN_DEBUG_PRINTOUT
+
+#define ENV_NO_LB_DIRECT "SRV_NO_LB_DIRECT"
+#define DEF_NO_LB_DIRECT DEF_CONN_LB_DISABLE
+
/* Static functions
*/
@@ -53,16 +105,16 @@
static Int2 LIBCALLBACK s_AsnRead(Pointer p, CharPtr buff, Uint2 len)
{
size_t n_read = 0;
- CONN_Read((CONN)p, buff, len, &n_read, eIO_Plain);
- return (Int2)n_read;
+ CONN_Read((CONN) p, buff, len, &n_read, eIO_Plain);
+ return (Int2) n_read;
}
static Int2 LIBCALLBACK s_AsnWrite(Pointer p, CharPtr buff, Uint2 len)
{
size_t n_written = 0;
- CONN_Write((CONN)p, buff, len, &n_written);
- return (Int2)n_written;
+ CONN_Write((CONN) p, buff, len, &n_written);
+ return (Int2) n_written;
}
@@ -85,7 +137,7 @@ static NI_DispatcherPtr s_GenericInit
if ( lastDispatcher )
StringNCpy_0(lastDispatcher, "NCBI Named Service", lastDispLen);
- disp->motd = StringSave("New load-balanced service resolution facility");
+ disp->motd = StringSave("Load-balancing service mapping facility");
disp->adminInfo = StringSave("Anton Lavrentiev (lavr@ncbi.nlm.nih.gov)");
disp->referenceCount = 1;
return disp;
@@ -104,33 +156,123 @@ static NI_HandPtr s_GenericGetService
(NI_DispatcherPtr disp, CharPtr configFile, CharPtr configSection,
CharPtr defService, Boolean hasResource)
{
- NI_HandPtr result;
- CONN conn;
- CONNECTOR c;
-
+ SConnNetInfo* net_info;
+ Char str[64];
+ NI_HandPtr result;
+ double valf;
+ CONN conn;
+ int val;
+ CONNECTOR c;
+
+ {{ /* alternate service name */
+ static const Char ENV_PREFIX[] = "NI_SERVICE_NAME_";
+ CharPtr envName = (CharPtr)MemNew(sizeof(ENV_PREFIX) +
+ StringLen(configSection));
+ StringCpy(envName, ENV_PREFIX);
+ StringCat(envName, configSection);
+ NI_GetEnvParamEx(configFile, configSection, envName, "SERVICE_NAME",
+ str, sizeof(str), defService);
+ MemFree(envName);
+ }}
+ if (!(net_info = ConnNetInfo_Create(str))) {
+ ErrPostEx(SEV_ERROR, 0, 1, "[Service NI Client] "
+ " Cannot set parameters for service \"%s\"", str);
+ return 0;
+ }
+
+ /* Now override default parameters with proprietary parameters
+ * of older WWW service dispatcher -- should go obsolete soon... */
+
+ /* alternate dispatcher's host name & port */
+ NI_GetEnvParam(configFile, SRV_SECTION, ENV_ENGINE_HOST,
+ net_info->host, sizeof(net_info->host), DEF_ENGINE_HOST);
+
+ NI_GetEnvParam(configFile, SRV_SECTION, ENV_ENGINE_PORT,
+ str, sizeof(str), "");
+ val = atoi(str);
+ net_info->port = val > 0 ? val : DEF_ENGINE_PORT;
+
+ /* alternate the dispatcher's CGI path */
+ NI_GetEnvParam(configFile, SRV_SECTION, ENV_ENGINE_URL,
+ net_info->path, sizeof(net_info->path), DEF_ENGINE_URL);
+
+ /* alternate HTTP proxy host & port */
+ NI_GetEnvParam(configFile, SRV_SECTION, ENV_HTTP_PROXY_HOST,
+ net_info->http_proxy_host,
+ sizeof(net_info->http_proxy_host), DEF_HTTP_PROXY_HOST);
+ NI_GetEnvParam(configFile, SRV_SECTION, ENV_HTTP_PROXY_PORT,
+ str, sizeof(str), "");
+ val = atoi(str);
+ net_info->http_proxy_port = val > 0 ? val : DEF_HTTP_PROXY_PORT;
+
+ /* alternate non-transparent CERN-like firewall proxy server */
+ NI_GetEnvParam(configFile, SRV_SECTION, ENV_PROXY_HOST,
+ net_info->proxy_host, sizeof(net_info->proxy_host),
+ DEF_PROXY_HOST);
+
+ /* alternate connection timeout */
+ NI_GetEnvParam(configFile, SRV_SECTION, ENV_TIMEOUT,
+ str, sizeof(str), "");
+ if (strlen(str) < 3 || StringNICmp(str, "infinite", strlen(str)) != 0) {
+ valf = atof(str);
+ if (valf <= 0)
+ valf = DEF_TIMEOUT;
+ if (!net_info->timeout)
+ net_info->timeout = &net_info->tmo;
+ net_info->timeout->sec =
+ (unsigned int) valf;
+ net_info->timeout->usec =
+ (unsigned int) ((valf - net_info->timeout->sec) * 1000000);
+ } else
+ net_info->timeout = 0;
+
+ /* alternate max. number of attemts to establish connection */
+ NI_GetEnvParam(configFile, SRV_SECTION, ENV_CONN_TRY,
+ str, sizeof(str), "");
+ val = atoi(str);
+ net_info->max_try = val > 0 ? val : DEF_CONN_TRY;
+
+ NI_GetEnvParam(configFile, SRV_SECTION, ENV_DEBUG_PRINTOUT,
+ str, sizeof(str), DEF_DEBUG_PRINTOUT);
+ if (*str && (StringICmp(str, "1" ) == 0 ||
+ StringICmp(str, "true") == 0 ||
+ StringICmp(str, "yes" ) == 0))
+ net_info->debug_printout = 1/*true*/;
+
+ /* whether to prohibit the use of local LBSMD */
+ NI_GetEnvParam(configFile, SRV_SECTION, ENV_NO_LB_DIRECT,
+ str, sizeof(str), DEF_NO_LB_DIRECT);
+ if (*str && (StringICmp(str, "0" ) != 0 &&
+ StringICmp(str, "false") != 0 &&
+ StringICmp(str, "no" ) != 0))
+ net_info->lb_disable = 1/*true*/;
+
/* establish connection to the server */
- if (!(c = SERVICE_CreateConnector(defService)) ||
+ if (!(c = SERVICE_CreateConnectorEx(defService, fSERV_Any, net_info, 0)) ||
CONN_Create(c, &conn) != eIO_Success) {
- ErrPostEx(SEV_ERROR, 0, 1,
- "[Service NI Client] Cannot use service \"%s\"",
- defService);
+ ErrPostEx(SEV_ERROR, 0, 1, "[Service NI Client] "
+ " Service \"%s\" unusable", net_info->service);
+ ConnNetInfo_Destroy(net_info);
return 0;
}
-
+ CONN_SetTimeout(conn, eIO_Open, net_info ? net_info->timeout : 0);
+ CONN_SetTimeout(conn, eIO_ReadWrite, net_info ? net_info->timeout : 0);
+ CONN_SetTimeout(conn, eIO_Close, net_info ? net_info->timeout : 0);
+
/* open ASN i/o, etc. */
- result = (NI_HandPtr)MemNew(sizeof(NI_Handle));
+ result = (NI_HandPtr) MemNew(sizeof(NI_Handle));
result->extra_proc_info = conn;
- result->raip = AsnIoNew((ASNIO_BIN | ASNIO_IN), (FILE *)0,
- (void *)conn, s_AsnRead, (IoFuncType)0);
- result->waip = AsnIoNew((ASNIO_BIN | ASNIO_OUT), (FILE *)0,
- (void *)conn, (IoFuncType)0, s_AsnWrite);
-
+ result->raip = AsnIoNew(ASNIO_BIN | ASNIO_IN, (FILE*) 0,
+ (void*) conn, s_AsnRead, (IoFuncType) 0);
+ result->waip = AsnIoNew(ASNIO_BIN | ASNIO_OUT, (FILE*) 0,
+ (void*) conn, (IoFuncType) 0, s_AsnWrite);
AsnIoSetErrorMsg(result->raip, s_AsnErrorFunc);
AsnIoSetErrorMsg(result->waip, s_AsnErrorFunc);
- result->hostname = StringSave("");
+ result->hostname = StringSave(net_info ? net_info->client_host : "");
result->disp = disp;
disp->referenceCount++;
-
+ ConnNetInfo_Destroy(net_info);
+
return result;
}