REG_CONN_IMPLICIT_SERVER_TYPE
72 static char*
x_getenv(
const char* name)
74 char*
env= getenv(name);
80 # define x_getenv getenv 88 const char* end =
str+
len;
90 unsigned charc = (
unsignedchar)(*
str);
117 size_t n,
len= strlen(svc);
118 for(
n= 0;
n<
len; ++
n) {
119 unsigned charc = (
unsignedchar)(*svc++);
121 if(!(under = c ==
'_') && !(alpha =
isalpha(c)))
127under = delim =
minus= 0
;
131under = delim =
minus= 0
;
142 if(under || delim ||
n==
len- 1)
150 if(delim ||
n==
len- 1)
160 returnalpha ?
len: 0;
173 const char* service,
const char* svc,
174 intismask,
int*
isfast)
180 assert(!svc == !service);
187 if(!service ||
strcasecmp(service, svc) == 0)
190(
"%s%s%s%s%s service name%s%s",
191!svc || !*svc ?
"":
"[",
193!svc || !*svc ?
"":
"] ",
194level ==
eLOG_Critical?
"Internal program logic error: ":
"",
195!svc ?
"NULL": !*svc ?
"Empty":
len?
"Too long":
"Invalid",
196*service ?
" for: ":
"", service));
199 if(!ismask && !*isfast) {
200 char tmp[
sizeof(
buf)];
222 CORE_TRACEF((
"[%s] SERV_ServiceName(\"%s\"): \"%s\"",
228(
"[%s] Maximal service name recursion" 229 " depth exceeded: %u", service,
depth));
232svc = s, *isfast = 1
;
242 intismask,
int*
isfast)
246retval =
x_ServiceName(0
, service, service, ismask, isfast);
283? realloc((
void*) iter->
skip,
n*
sizeof(*temp))
284:
malloc(
n*
sizeof(*temp)));
310 #define s_IsMapperConfigured(s, k) x_IsMapperConfigured(s, k, s_Fast) 322 unsigned intpreferred_host,
323 unsigned shortpreferred_port,
339 #ifdef NCBI_CXX_TOOLKIT 357 free((
void*) svc);
365iter->
port= preferred_port;
366iter->
pref= (preference < 0.0
368: 0.01 * (preference > 100.0
387iter->
exact= exact;
390iter->
arglen= strlen(arg);
402 for(
i= 0;
i< n_skip; ++
i) {
407iter->
name: name );
436 #ifdef NCBI_CXX_TOOLKIT 437do_linkerd = do_namerd =
513&& !do_lbnull && !do_linkerd && !do_namerd
519 assert(*service || !svc);
521(
"%s%s%s%s%sNo service mappers available",
522&
"["[!*service], service,
523&
"/"[!svc], svc ? svc :
"",
524*service ?
"] ":
""));
542 while(n < iter->n_skip) {
550 memmove((
void*) ptr, (
void*)(ptr + 1),
551(iter->
n_skip-
n) *
sizeof(*ptr));
553 free((
void*) temp);
560 #if defined(_DEBUG) && !defined(NDEBUG) 562 #define x_RETURN(retval) return x_Return((SSERV_Info*) info, infostr, retval) 569 const char* infostr,
573 free((
void*) infostr);
591(
"[%s] NULL name @%p\n%s", iter->
name,
info,
592infostr ? infostr :
"<NULL>"));
597(
"[%s] %s name \"%s\" @%p\n%s", iter->
name,
598*name ?
"Unexpected":
"Empty", name,
599 info, infostr ? infostr :
"<NULL>"));
602 if(!
info->host || !
info->port) {
605(
"[%s] Non-DNS server with empty %s @%p:\n%s",
606iter->
name, !(
info->host |
info->port) ?
"host:port" 607:
info->host ?
"port":
"host",
608 info, infostr ? infostr :
"<NULL>"));
613(
"[%s] Interim DNS server w/o host @%p:\n%s",
614iter->
name,
info, infostr ? infostr :
"<NULL>"));
624(
"[%s] Expired entry (%u < %u) @%p:\n%s", iter->
name,
626 info, infostr ? infostr :
"<NULL>"));
633(
"[%s] Excessive expiration (%u) @%p:\n%s", iter->
name,
635 info, infostr ? infostr :
"<NULL>"));
642(
"[%s] Firewall DNS entry not allowed @%p:\n%s",
643iter->
name,
info, infostr ? infostr :
"<NULL>"));
648(
"[%s] Firewall entry with %s%s%s @%p:\n%s", iter->
name,
649 info->vhost ?
"vhost":
"",
650 info->extra &&
info->vhost ?
" and ":
"",
651 info->extra ?
"extra":
"",
652 info, infostr ? infostr :
"<NULL>"));
659(
"[%s] DNS entry cannot be private @%p:\n%s",
660iter->
name,
info, infostr ? infostr :
"<NULL>"));
665(
"[%s] DNS entry cannot be stateful @%p:\n%s",
666iter->
name,
info, infostr ? infostr :
"<NULL>"));
671(
"[%s] DNS entry cannot be secure @%p:\n%s",
672iter->
name,
info, infostr ? infostr :
"<NULL>"));
679(
"[%s] DNS entry with MIME type @%p:\n%s", iter->
name,
680 info, infostr ? infostr :
"<NULL>"));
686(
"[%s] HTTP entry cannot be stateful @%p:\n%s", iter->
name,
687 info, infostr ? infostr :
"<NULL>"));
694(
"[%s] DNS entry unwarranted @%p:\n%s", iter->
name,
695 info, infostr ? infostr :
"<NULL>"));
701&& !(
types&
info->u.firewall.type))) {
704(
"[%s] Mismatched type 0x%X vs 0x%X @%p:\n%s",
706?
info->u.firewall.type
708 info, infostr ? infostr :
"<NULL>"));
714(
"[%s] Local/private entry for external @%p:\n%s",
715iter->
name,
info, infostr ? infostr :
"<NULL>"));
721(
"[%s] Private entry unwarranted @%p:\n%s", iter->
name,
722 info, infostr ? infostr :
"<NULL>"));
727(
"[%s] Stateful entry in stateless search @%p:\n%s",
728iter->
name,
info, infostr ? infostr :
"<NULL>"));
732 if(!
info->time && !
info->rate) {
734(
"[%s] Off entry not allowed @%p:\n%s", iter->
name,
735 info, infostr ? infostr :
"<NULL>"));
740(
"[%s] Suppressed entry unwarranted @%p:\n%s",
741iter->
name,
info, infostr ? infostr :
"<NULL>"));
746(
"[%s] Down entry unwarranted @%p:\n%s", iter->
name,
747 info, infostr ? infostr :
"<NULL>"));
752(
"[%s] Reserved entry unwarranted @%p:\n%s", iter->
name,
753 info, infostr ? infostr :
"<NULL>"));
757 for(
n= 0;
n< iter->
n_skip; ++
n) {
760(
"[%s] Standby entry unwarranted @%p:\n%s",
761iter->
name,
info, infostr? infostr :
"<NULL>"));
767 for(
n= 0;
n< iter->
n_skip; ++
n) {
772(
"[%s] Entry is a duplicate of @%p and must be skipped" 773 " @%p:\n%s%s%s%s", iter->
name, skip,
info,
774&
"\""[!*name], name, *name ?
"\" ":
"",
775infostr ? infostr :
"<NULL>"));
781iter->
name,
info, &
"\""[!*name], name,
782*name ?
"\" ":
"", infostr ? infostr :
"<NULL>"));
810!
info->host || iter->
pref>= 0.0 ||
832 unsigned intpreferred_host,
833 unsigned shortpreferred_port,
846preferred_host, preferred_port, preference,
847net_info, skip, n_skip,
884 unsigned intpreferred_host,
888preferred_host, 0
, 0.0
,
897 unsigned intpreferred_host,
903preferred_host, 0
, 0.0
,
904net_info, skip, n_skip,
912 unsigned intpreferred_host,
913 unsigned shortpreferred_port,
923service && (!*service || strpbrk(service,
"?*[")),
types,
924preferred_host, preferred_port, preference,
925net_info, skip, n_skip,
933 unsigned intpreferred_host,
934 unsigned shortpreferred_port,
946preferred_host, preferred_port, preference,
947net_info, skip, n_skip,
972 unsigned intpreferred_host,
986 unsigned intpreferred_host,
995net_info, skip, n_skip,
1019 returniter ? iter->
op->
mapper: 0;
1026 returnname && *name ? name : iter->
name;
1035 returniter->
op->
Feedback(iter, fine, time ? time : 1
);
1050 returniter->
op->
Feedback(iter, rate, 0
);
1089 static const charused_server_info[] =
"Used-Server-Info-";
1094 for(s =
text; (c = strchr(s,
'\n')) != 0; s = c + 1) {
1095 size_t len= (size_t)(c - s);
1104 if(q[
len- 1] ==
'\r')
1105q[
len- 1] =
'\0';
1111 if(!
strncasecmp(p, used_server_info,
sizeof(used_server_info) - 1)
1112&&
isdigit((
unsigned char) p[
sizeof(used_server_info) - 1])) {
1113p +=
sizeof(used_server_info) - 1;
1114 if(sscanf(p,
"%u: %n", &d1, &d2) >= 1
1130 static const charkAcceptedServerTypes[] =
"Accepted-Server-Types:";
1131 static const charkClientRevision[] =
"Client-Revision: %u.%u\r\n";
1132 static const charkUsedServerInfo[] =
"Used-Server-Info: ";
1133 static const charkNcbiExternal[] =
NCBI_EXTERNAL ": Y\r\n";
1134 static const charkNcbiFWPorts[] =
"NCBI-Firewall-Ports: ";
1135 static const charkPreference[] =
"Preference: ";
1136 static const charkSkipInfo[] =
"Skip-Info-%u: ";
1137 static const charkAffinity[] =
"Affinity: ";
1143buflen = (size_t) sprintf(
buffer, kClientRevision,
1155 if(!
BUF_Write(&
buf, kNcbiExternal,
sizeof(kNcbiExternal)-1)) {
1164 for(
t= 1;
t;
t<<= 1) {
1167 size_tnamelen = strlen(name);
1170 if(buflen + namelen + (1 + 2) >
sizeof(
buffer))
1172 buffer[buflen++] =
' ';
1173memcpy(
buffer+ buflen, name, namelen);
1179memcpy(
buffer+ buflen,
"\r\n", 2);
1181 sizeof(kAcceptedServerTypes) - 1)
1194&& (!
BUF_Write(&
buf, kNcbiFWPorts,
sizeof(kNcbiFWPorts)-1) ||
1205 buffer[buflen++] =
' ';
1207iter->
pref* 100.0, 2),
1208 "%\r\n") -
buffer) + 3
;
1209 if(!
BUF_Write(&
buf, kPreference,
sizeof(kPreference) - 1) ||
1217 if(!
BUF_Write(&
buf, kAffinity,
sizeof(kAffinity) - 1) ||
1230 for(
i= 0;
i< iter->
n_skip; ++
i) {
1233 size_tnamelen = name && *name ? strlen(name) : 0;
1236 if(but_last && iter->
last== iter->
skip[
i]) {
1237buflen =
sizeof(kUsedServerInfo) - 1;
1238memcpy(
buffer, kUsedServerInfo, buflen);
1240buflen = (size_t) sprintf(
buffer, kSkipInfo, (
unsigned)
i+ 1);
1252 if(i < iter->n_skip) {
1259 if((
str= (
char*)
malloc(buflen + 1)) != 0) {
1264 str[buflen] =
'\0';
1277 unsigned shortport;
1316+ 2
) + strlen(typ))) {
1330strcpy(
buf+
len, typ);
1337 # ifdef NCBI_OS_MSWIN 1338 # define putenv _putenv 1348 return len? 1
: 0
;
1352 #define _SERV_MERGE(a, b) a ## b 1353 #define SERV_MERGE(a, b) _SERV_MERGE(a, b) 1356 #define SERV_GET_IMPLICIT_SERVER_TYPE(variant) \ 1357 ESERV_Type SERV_MERGE(SERV_GetImplicitServerType, \ 1358 _SERV_MERGE(variant, Ex)) \ 1359 (const char* service, ESERV_Type default_type) \ 1365 if (!_SERV_MERGE(ConnNetInfo_GetValue, variant) \ 1366 (service, REG_CONN_IMPLICIT_SERVER_TYPE, val, sizeof(val), 0) \ 1367 || !*val || !(end = SERV_ReadType(val, &type)) || *end) { \ 1368 return default_type; \ 1375 #define SERV_GET_IMPLICIT_SERVER_TYPE_PUBLIC_API 1377 #undef SERV_GET_IMPLICIT_SERVER_TYPE_PUBLIC_API 1394 #undef SERV_GET_IMPLICIT_SERVER_TYPE 1401 intSERV_MatchesHost(
const SSERV_Info*
info,
unsigned inthost)
1406 return info->host == host ? 1
: 0
;
static unsigned char depth[2 *(256+1+29)+1]
static const char * str(char *buf, int n)
static const struct type types[]
int BUF_Write(BUF *pBuf, const void *data, size_t size)
size_t BUF_Read(BUF buf, void *data, size_t size)
void BUF_Destroy(BUF buf)
SSERV_InfoCPtr SERV_GetNextInfo(SERV_ITER iter)
Same as "SERV_GetNextInfoEx(., 0)" â i.e.
void SERV_Close(SERV_ITER iter)
Deallocate the iterator.
SSERV_Info * SERV_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(),...
SSERV_Info * SERV_GetInfoSimple(const char *service)
Equivalent to "SERV_GetInfo(., fSERV_Any, SERV_ANYHOST, ConnNetInfo_Crea...
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 (t...
SSERV_FirewallInfo firewall
void SERV_Reset(SERV_ITER iter)
Reset the iterator to the state as if it has just been opened.
int SERV_Penalize(SERV_ITER iter, double fine)
Penalize the server returned last from SERV_GetNextInfo[Ex]().
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 hos...
int SERV_PenalizeEx(SERV_ITER iter, double fine, TNCBI_Time time)
const char * SERV_TypeStr(ESERV_Type type)
SSERV_Info * SERV_GetInfo(const char *service, TSERV_Type types, unsigned int preferred_host, const SConnNetInfo *net_info)
Same as "SERV_GetInfoEx(., ., ., ., 0, 0, 0)" â i.e.
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.
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.
char * SERV_WriteInfo(const SSERV_Info *info)
unsigned int TSERV_Type
Bitwise OR of ESERV_Type[Special].
unsigned short TSERV_TypeOnly
Server type only, w/o specials.
int SERV_Rerate(SERV_ITER iter, double rate)
Rerate the server returned last from SERV_GetNextInfo[Ex]().
ESERV_Type SERV_GetImplicitServerType(const char *service)
Get a server type that would be assigned to typeless entries for the given service name.
SERV_ITER SERV_OpenSimple(const char *service)
Allocate an iterator and consult either local databases (if any present), or network database,...
#define SERV_CLIENT_REVISION_MAJOR
Revision 7.0.
#define SERV_CLIENT_REVISION_MINOR
#define SERV_LOCALHOST
Special values for the "preferred_host" parameter.
int SERV_EqualInfo(const SSERV_Info *info1, const SSERV_Info *info2)
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...
@ fSERV_ReverseDns
LB-DNS translation.
@ fSERV_IncludeSuppressed
@ fSERV_All
Server type mask.
@ fSERV_Stateless
Stateless servers only.
@ fSERV_Promiscuous
Evrthng and the kitchen sink.
size_t SOCK_HostPortToString(unsigned int host, unsigned short port, char *buf, size_t bufsize)
Print numeric string "host:port" into a buffer provided, not to exceed 'bufsize' bytes (including the...
unsigned int SOCK_GetLocalHostAddress(ESwitch reget)
Same as SOCK_GetLocalHostAddress6() only strictly for IPv4.
#define REG_CONN_LBSMD_DISABLE
ELOG_Level
Log severity level.
enum ENcbiSwitch ESwitch
Aux.
#define REG_CONN_LBNULL_ENABLE
#define REG_CONN_LINKERD_ENABLE
#define REG_CONN_LBDNS_ENABLE
#define REG_CONN_LOCAL_ENABLE
#define NCBI_TIME_INFINITE
#define REG_CONN_NAMERD_ENABLE
#define REG_CONN_DISPD_DISABLE
SConnNetInfo * ConnNetInfo_Create(const char *service)
int ConnNetInfo_Boolean(const char *str)
#define REG_CONN_SERVICE_NAME
void ConnNetInfo_Destroy(SConnNetInfo *net_info)
@ eREG_Transient
only in-memory storage while program runs
@ eFWMode_Legacy
Relay, no firewall.
static void text(MDB_val *v)
const struct ncbi::grid::netcache::search::fields::KEY key
char * NCBI_simple_ftoa(char *s, double f, int p)
Locale-independent double-to-ASCII conversion of value "f" into a character buffer pointed to by "s",...
#define LBSM_DEFAULT_TIME
const char * ConnNetInfo_GetValueInternal(const char *service, const char *param, char *value, size_t value_size, const char *def_value)
void SERV_PrintFirewallPorts(char *buf, size_t bufsize, EFWMode mode)
const SSERV_VTable * SERV_DISPD_Open(SERV_ITER iter, const SConnNetInfo *net_info, SSERV_Info **info)
const SSERV_VTable * SERV_LBDNS_Open(SERV_ITER iter, SSERV_Info **info)
const SSERV_VTable * SERV_LBNULL_Open(SERV_ITER iter, SSERV_Info **info)
const SSERV_VTable * SERV_LBSMD_Open(SERV_ITER iter, SSERV_Info **info, HOST_INFO *host_info, int no_dispd_follows)
const SSERV_VTable * SERV_LINKERD_Open(SERV_ITER iter, const SConnNetInfo *net_info, SSERV_Info **info, int *do_namerd)
const SSERV_VTable * SERV_LOCAL_Open(SERV_ITER iter, SSERV_Info **info)
const SSERV_VTable * SERV_NAMERD_Open(SERV_ITER iter, const SConnNetInfo *net_info, SSERV_Info **info)
#define CORE_REG_GET(section, name, value, value_size, def_value)
#define CORE_DEBUG_ARG(arg)
#define CORE_REG_SET(section, name, value, storage)
#define CORE_LOGF_X(subcode, level, fmt_args)
#define CORE_TRACEF(fmt_args)
#define CORE_LOGF(level, fmt_args)
SSERV_Info * SERV_ReadInfoEx(const char *str, const char *name, int lazy)
SSERV_Info * SERV_CopyInfoEx(const SSERV_Info *orig, const char *name)
const char * SERV_NameOfInfo(const SSERV_Info *info)
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 ESERV_Type SERV_GetImplicitServerTypeEx(const char *service, ESERV_Type default_type)
#define CONN_IMPLICIT_SERVER_TYPE
ESERV_Type SERV_GetImplicitServerTypeInternal(const char *service)
static int x_mkenv(char *str, size_t len)
static void s_SkipSkip(SERV_ITER iter)
static int s_AddSkipInfo(SERV_ITER iter, const char *name, SSERV_InfoCPtr info)
#define SERV_GET_IMPLICIT_SERVER_TYPE(variant)
#define SERV_GET_IMPLICIT_SERVER_TYPE_PUBLIC_API
int SERV_IsMapperConfiguredInternal(const char *svc, const char *key)
static size_t x_CheckServiceName(const char *svc)
#define SERV_SERVICE_NAME_RECURSION_MAX
ESERV_Type SERV_GetImplicitServerTypeInternalEx(const char *service, ESERV_Type default_type)
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)
char * SERV_ServiceName(const char *service)
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)
int SERV_Update(SERV_ITER iter, const char *text, int code)
const char * SERV_CurrentName(SERV_ITER iter)
#define s_IsMapperConfigured(s, k)
static int x_Return(SSERV_Info *info, const char *infostr, int retval)
static int x_IsMapperConfigured(const char *svc, const char *key, int fast)
static char * s_ServiceName(const char *service, int ismask, int *isfast)
static SSERV_Info * s_GetNextInfo(SERV_ITER iter, HOST_INFO *host_info, int internal)
char * SERV_Print(SERV_ITER iter, const SConnNetInfo *net_info, int but_last)
ESwitch SERV_DoFastOpens(ESwitch on)
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)
static int x_ConsistencyCheck(SERV_ITER iter, const SSERV_Info *info)
static char * x_ServiceName(unsigned int depth, const char *service, const char *svc, int ismask, int *isfast)
const char * SERV_MapperName(SERV_ITER iter)
Int4 delta(size_t dimension_, const Int4 *score_)
#define SERV_IsReserved(i)
#define SERV_GetImplicitServerTypeDefault()
#define SERV_IfSuppressed(i)
#define SERV_IsStandby(i)
void(* Reset)(SERV_ITER iter)
SSERV_Info *(* GetNextInfo)(SERV_ITER iter, HOST_INFO *host_info)
void(* Close)(SERV_ITER iter)
int(* Update)(SERV_ITER iter, const char *text, int code)
int(* Feedback)(SERV_ITER iter, double rate, TNCBI_Time fine)
voidp calloc(uInt items, uInt size)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4