NCBI C++ ToolKit
Macros | Functions | Variables
ncbi_service.c File Reference
#include "ncbi_ansi_ext.h"
#include "ncbi_dispd.h"
#include "ncbi_lbsmd.h"
#include "ncbi_local.h"
#include "ncbi_lbdns.h"
#include "ncbi_linkerd.h"
#include "ncbi_namerd.h"
#include "ncbi_priv.h"
#include <ctype.h>
#include <stdlib.h>
#include <time.h>
+ Include dependency graph for ncbi_service.c:

Go to the source code of this file.

Go to the SVN repository for this file.

Macros

#define NCBI_USE_ERRCODE_X   Connect_Service
 
#define SERV_SERVICE_NAME_RECURSION_MAX   10
 
#define CONN_IMPLICIT_SERVER_TYPE
 
#define x_getenv   getenv
 
#define s_IsMapperConfigured(s, k)   x_IsMapperConfigured(s, k, s_Fast)
 
#define x_RETURN(retval)   return x_Return((SSERV_Info*) info, infostr, retval)
 
#define putenv   _putenv
 
#define SERV_MERGE(a, b)   a ## b
 
#define SERV_GET_IMPLICIT_SERVER_TYPE(variant)
 
#define SERV_GET_IMPLICIT_SERVER_TYPE_PUBLIC_API
 

Functions

static int x_tr (char *str, char a, char b, size_t len)
 
static char * x_ServiceName (unsigned int depth, const char *service, const char *svc, int ismask, int *isfast)
 
static char * s_ServiceName (const char *service, int ismask, int *isfast)
 
char * SERV_ServiceName (const char *service)
 
static int s_AddSkipInfo (SERV_ITER iter, const char *name, SSERV_InfoCPtr info)
 
static int x_IsMapperConfigured (const char *svc, const char *key, int fast)
 
int SERV_IsMapperConfiguredInternal (const char *svc, const char *key)
 
static SERV_ITER x_Open (const char *service, int ismask, TSERV_Type types, unsigned int preferred_host, unsigned short preferred_port, double preference, const SConnNetInfo *net_info, SSERV_InfoCPtr skip[], size_t n_skip, int external, const char *arg, const char *val, SSERV_Info **info, HOST_INFO *host_info)
 
static void s_SkipSkip (SERV_ITER iter)
 
static int x_Return (SSERV_Info *info, const char *infostr, int retval)
 
static int x_ConsistencyCheck (SERV_ITER iter, const SSERV_Info *info)
 
static SSERV_Infos_GetNextInfo (SERV_ITER iter, HOST_INFO *host_info, int internal)
 
static SERV_ITER s_Open (const char *service, int ismask, TSERV_Type types, unsigned int preferred_host, unsigned short preferred_port, double preference, const SConnNetInfo *net_info, SSERV_InfoCPtr skip[], size_t n_skip, int external, const char *arg, const char *val, SSERV_Info **info, HOST_INFO *host_info)
 
SERV_ITER SERV_OpenSimple (const char *service)
 Allocate an iterator and consult either local databases (if any present), or network database, using all default communication parameters found both in the registry and the environment variables (as if having an implicit parameter "net_info" created with "ConnNetInfo_Create(service)"). More...
 
SERV_ITER SERV_Open (const char *service, TSERV_Type types, unsigned int preferred_host, const SConnNetInfo *net_info)
 Same as "SERV_OpenEx(., ., ., ., 0, 0)" – i.e. More...
 
SERV_ITER SERV_OpenEx (const char *service, TSERV_Type types, unsigned int preferred_host, const SConnNetInfo *net_info, SSERV_InfoCPtr skip[], size_t n_skip)
 Create an iterator for sequential server lookup. More...
 
SERV_ITER SERV_OpenP (const char *service, TSERV_Type types, unsigned int preferred_host, unsigned short preferred_port, double preference, const SConnNetInfo *net_info, SSERV_InfoCPtr skip[], size_t n_skip, int external, const char *arg, const char *val)
 
SSERV_InfoSERV_GetInfoSimple (const char *service)
 Equivalent to "SERV_GetInfo(., fSERV_Any, SERV_ANYHOST, ConnNetInfo_Create(service))", but it takes care not to leak its last "net_info" parameter, which it builds on the fly. More...
 
SSERV_InfoSERV_GetInfo (const char *service, TSERV_Type types, unsigned int preferred_host, const SConnNetInfo *net_info)
 Same as "SERV_GetInfoEx(., ., ., ., 0, 0, 0)" – i.e. More...
 
SSERV_InfoSERV_GetInfoEx (const char *service, TSERV_Type types, unsigned int preferred_host, const SConnNetInfo *net_info, SSERV_InfoCPtr skip[], size_t n_skip, HOST_INFO *host_info)
 A "fast track" routine equivalent to creating of an iterator as with SERV_OpenEx(), and then taking an info as with SERV_GetNextInfoEx(). More...
 
SSERV_InfoSERV_GetInfoP (const char *service, TSERV_Type types, unsigned int preferred_host, unsigned short preferred_port, double preference, const SConnNetInfo *net_info, SSERV_InfoCPtr skip[], size_t n_skip, int external, const char *arg, const char *val, HOST_INFO *host_info)
 
SSERV_InfoCPtr SERV_GetNextInfoEx (SERV_ITER iter, HOST_INFO *host_info)
 Get the next server meta-address, optionally accompanied by the host parameters made available by the LB daemon (LBSMD). More...
 
SSERV_InfoCPtr SERV_GetNextInfo (SERV_ITER iter)
 Same as "SERV_GetNextInfoEx(., 0)" – i.e. More...
 
const char * SERV_MapperName (SERV_ITER iter)
 
const char * SERV_CurrentName (SERV_ITER iter)
 
int SERV_PenalizeEx (SERV_ITER iter, double fine, TNCBI_Time time)
 
int SERV_Penalize (SERV_ITER iter, double fine)
 Penalize the server returned last from SERV_GetNextInfo[Ex](). More...
 
int SERV_Rerate (SERV_ITER iter, double rate)
 Rerate the server returned last from SERV_GetNextInfo[Ex](). More...
 
void SERV_Reset (SERV_ITER iter)
 Reset the iterator to the state as if it has just been opened. More...
 
void SERV_Close (SERV_ITER iter)
 Deallocate the iterator. More...
 
int SERV_Update (SERV_ITER iter, const char *text, int code)
 
char * SERV_Print (SERV_ITER iter, const SConnNetInfo *net_info, int but_last)
 
unsigned short SERV_ServerPort (const char *name, unsigned int host)
 Obtain a port number that corresponds to the named (standalone) service declared at the specified host (per the LB configuration information). More...
 
int SERV_SetImplicitServerType (const char *service, ESERV_Type type)
 Set a server type to use when a service mapper returns typeless entries for the given service name (typed entries retain their types as received). More...
 
ESERV_Type SERV_GetImplicitServerType (const char *service)
 Get a server type that would be assigned to typeless entries for the given service name. More...
 
ESERV_Type SERV_GetImplicitServerTypeInternal (const char *service)
 
ESERV_Type SERV_GetImplicitServerTypeDefault (void)
 
ESwitch SERV_DoFastOpens (ESwitch on)
 

Variables

static ESwitch s_Fast = eOff
 

Macro Definition Documentation

◆ CONN_IMPLICIT_SERVER_TYPE

#define CONN_IMPLICIT_SERVER_TYPE
Value:
#define REG_CONN_IMPLICIT_SERVER_TYPE
#define DEF_CONN_REG_SECTION

Definition at line 64 of file ncbi_service.c.

◆ NCBI_USE_ERRCODE_X

#define NCBI_USE_ERRCODE_X   Connect_Service

Definition at line 49 of file ncbi_service.c.

◆ putenv

#define putenv   _putenv

◆ s_IsMapperConfigured

#define s_IsMapperConfigured (   s,
 
)    x_IsMapperConfigured(s, k, s_Fast)

Definition at line 244 of file ncbi_service.c.

◆ SERV_GET_IMPLICIT_SERVER_TYPE

#define SERV_GET_IMPLICIT_SERVER_TYPE (   variant)
Value:
(const char* service) \
{ \
ESERV_Type type; \
const char *end; \
char val[40]; \
/* Try to retrieve service-specific first, then global default */ \
(service, REG_CONN_IMPLICIT_SERVER_TYPE, val, sizeof(val), 0) \
|| !*val || !(end = SERV_ReadType(val, &type)) || *end) { \
} \
return type; \
} \
constexpr auto end(const ct_const_array< T, N > &in) noexcept
static int type
Definition: getdata.c:31
ESERV_Type
const char * SERV_ReadType(const char *str, ESERV_Type *type)
ESERV_Type SERV_GetImplicitServerType(const char *service)
Get a server type that would be assigned to typeless entries for the given service name.
const char * ConnNetInfo_GetValue(const char *service, const char *param, char *value, size_t value_size, const char *def_value)
#define SERV_MERGE(a, b)
ESERV_Type SERV_GetImplicitServerTypeDefault(void)
Definition: type.c:6

Definition at line 1281 of file ncbi_service.c.

◆ SERV_GET_IMPLICIT_SERVER_TYPE_PUBLIC_API

#define SERV_GET_IMPLICIT_SERVER_TYPE_PUBLIC_API

Definition at line 1299 of file ncbi_service.c.

◆ SERV_MERGE

#define SERV_MERGE (   a,
  b 
)    a ## b

Definition at line 1279 of file ncbi_service.c.

◆ SERV_SERVICE_NAME_RECURSION_MAX

#define SERV_SERVICE_NAME_RECURSION_MAX   10

Definition at line 63 of file ncbi_service.c.

◆ x_getenv

#define x_getenv   getenv

Definition at line 79 of file ncbi_service.c.

◆ x_RETURN

#define x_RETURN (   retval)    return x_Return((SSERV_Info*) info, infostr, retval)

Definition at line 489 of file ncbi_service.c.

Function Documentation

◆ s_AddSkipInfo()

static int s_AddSkipInfo ( SERV_ITER  iter,
const char *  name,
SSERV_InfoCPtr  info 
)
static

◆ s_GetNextInfo()

static SSERV_Info* s_GetNextInfo ( SERV_ITER  iter,
HOST_INFO host_info,
int  internal 
)
static

◆ s_Open()

static SERV_ITER s_Open ( const char *  service,
int  ismask,
TSERV_Type  types,
unsigned int  preferred_host,
unsigned short  preferred_port,
double  preference,
const SConnNetInfo net_info,
SSERV_InfoCPtr  skip[],
size_t  n_skip,
int  external,
const char *  arg,
const char *  val,
SSERV_Info **  info,
HOST_INFO host_info 
)
static

◆ s_ServiceName()

static char* s_ServiceName ( const char *  service,
int  ismask,
int isfast 
)
static

Definition at line 175 of file ncbi_service.c.

References CORE_LOCK_READ, CORE_UNLOCK, and x_ServiceName().

Referenced by SERV_ServiceName(), and x_Open().

◆ s_SkipSkip()

static void s_SkipSkip ( SERV_ITER  iter)
static

◆ SERV_CurrentName()

const char* SERV_CurrentName ( SERV_ITER  iter)

Definition at line 950 of file ncbi_service.c.

References SSERV_IterTag::last, SSERV_IterTag::name, and SERV_NameOfInfo().

Referenced by s_Feedback().

◆ SERV_DoFastOpens()

ESwitch SERV_DoFastOpens ( ESwitch  on)

Definition at line 1333 of file ncbi_service.c.

References eDefault, and s_Fast.

◆ SERV_GetImplicitServerTypeDefault()

ESERV_Type SERV_GetImplicitServerTypeDefault ( void  )

Definition at line 1313 of file ncbi_service.c.

References fSERV_Http.

◆ SERV_GetImplicitServerTypeInternal()

ESERV_Type SERV_GetImplicitServerTypeInternal ( const char *  service)

Definition at line 1305 of file ncbi_service.c.

Referenced by s_ParseResponse(), and s_Resolve().

◆ SERV_GetInfoP()

SSERV_Info* SERV_GetInfoP ( const char *  service,
TSERV_Type  types,
unsigned int  preferred_host,
unsigned short  preferred_port,
double  preference,
const SConnNetInfo net_info,
SSERV_InfoCPtr  skip[],
size_t  n_skip,
int  external,
const char *  arg,
const char *  val,
HOST_INFO host_info 
)

◆ SERV_IsMapperConfiguredInternal()

int SERV_IsMapperConfiguredInternal ( const char *  svc,
const char *  key 
)

◆ SERV_MapperName()

const char* SERV_MapperName ( SERV_ITER  iter)

◆ SERV_OpenP()

SERV_ITER SERV_OpenP ( const char *  service,
TSERV_Type  types,
unsigned int  preferred_host,
unsigned short  preferred_port,
double  preference,
const SConnNetInfo net_info,
SSERV_InfoCPtr  skip[],
size_t  n_skip,
int  external,
const char *  arg,
const char *  val 
)

Definition at line 837 of file ncbi_service.c.

References s_Open(), types, and val.

Referenced by CServiceDiscovery::DiscoverImpl().

◆ SERV_PenalizeEx()

int SERV_PenalizeEx ( SERV_ITER  iter,
double  fine,
TNCBI_Time  time 
)

Definition at line 957 of file ncbi_service.c.

References assert, SSERV_VTable::Feedback, SSERV_IterTag::last, and SSERV_IterTag::op.

Referenced by SERV_Penalize().

◆ SERV_Print()

char* SERV_Print ( SERV_ITER  iter,
const SConnNetInfo net_info,
int  but_last 
)

◆ SERV_ServiceName()

char* SERV_ServiceName ( const char *  service)

◆ SERV_Update()

int SERV_Update ( SERV_ITER  iter,
const char *  text,
int  code 
)

◆ x_ConsistencyCheck()

static int x_ConsistencyCheck ( SERV_ITER  iter,
const SSERV_Info info 
)
static

◆ x_IsMapperConfigured()

static int x_IsMapperConfigured ( const char *  svc,
const char *  key,
int  fast 
)
static

◆ x_Open()

static SERV_ITER x_Open ( const char *  service,
int  ismask,
TSERV_Type  types,
unsigned int  preferred_host,
unsigned short  preferred_port,
double  preference,
const SConnNetInfo net_info,
SSERV_InfoCPtr  skip[],
size_t  n_skip,
int  external,
const char *  arg,
const char *  val,
SSERV_Info **  info,
HOST_INFO host_info 
)
static

◆ x_Return()

static int x_Return ( SSERV_Info info,
const char *  infostr,
int  retval 
)
static

Definition at line 495 of file ncbi_service.c.

References free(), and info.

◆ x_ServiceName()

static char* x_ServiceName ( unsigned int  depth,
const char *  service,
const char *  svc,
int  ismask,
int isfast 
)
static

◆ x_tr()

static int x_tr ( char *  str,
char  a,
char  b,
size_t  len 
)
static

Definition at line 83 of file ncbi_service.c.

References a, b, done, len, and str().

Referenced by SERV_SetImplicitServerType(), and x_ServiceName().

Variable Documentation

◆ s_Fast

ESwitch s_Fast = eOff
static

Definition at line 67 of file ncbi_service.c.

Referenced by SERV_DoFastOpens(), and x_Open().

Modified on Sat May 25 14:21:40 2024 by modify_doxy.py rev. 669887