44 #define fabs(v) ((v) < 0.0 ? -(v) : (v))
46 #define MAX_IP_ADDR_LEN 80
48 #define SERV_VHOSTABLE ( fSERV_Http | fSERV_Standalone)
50 #if CONN_HOST_LEN > 255
51 # error "CONN_HOST_LEN may not be greater than 255"
125 return attr ? attr->
tag :
"";
147 static const char* k_YN[] = {
"yes",
"no" };
157 info->mime_e, c_t,
sizeof(c_t))) {
159 assert(c_t[strlen(c_t) - 2] ==
'\r' && c_t[strlen(c_t) - 1] ==
'\n');
160 c_t[strlen(c_t) - 2] =
'\0';
161 p = strchr(c_t,
' ');
164 memmove(c_t, p, strlen(p) + 1);
168 + 1+9 + 3+strlen(c_t) + 3*(1+5)
169 + 1+14 + 2*(1+5) + 1+12 + 2*(1+5)
177 memcpy(s, attr->
tag, attr->
len);
191 s += sprintf(s,
":%hu",
info->port);
194 if ((
n = strlen(
str + reserve)) != 0) {
207 s += sprintf(s,
" C=%s", c_t);
210 const char* vhost = (
const char*) &
info->u +
size;
211 s += sprintf(s,
" H=%.*s", (
int)
info->vhost, vhost);
215 s += sprintf(s,
" P=yes");
221 s += sprintf(s,
" $=yes");
223 s += sprintf(s,
" T=%lu", (
unsigned long)
info->time);
225 sprintf(s,
" X=yes");
235 int algo, coef, mime, locl, priv, rate, sful, secu, time, cros, vh;
257 const char* end =
str;
258 while (*end && !
isspace((
unsigned char)(*end)))
262 if (!(*
str ==
':' || *
str ==
'[')) {
263 if (strcspn(
str,
"=") >=
len) {
276 int ipv6 = *
str ==
'[' &&
len > 2 ? 1 : 0;
278 if (
tmp && (!ipv6 || (*
tmp++ ==
']' && *
tmp ==
':'))) {
279 if (
tmp != end && *
tmp !=
':')
284 }
else if (*
str ==
'[') {
310 for (
len = 0;
len < (size_t)(end - vhost); ++
len) {
311 if (vhost[
len] ==
':')
313 if (vhost[
len] ==
'.')
348 (name ? strlen(name) + 1 : 0));
355 algo = coef = mime = locl = priv = rate = sful = secu = time = cros = vh
377 switch ((
unsigned char)(*++
str)) {
411 info->mime_t = mime_t;
412 info->mime_s = mime_s;
413 info->mime_e = mime_e;
433 if (
len == 2 && memcmp(vhost,
"''", 2) == 0)
440 if (sscanf(++
str,
"%3s%n", s, &
n) >= 1) {
454 if (sscanf(++
str,
"%3s%n", s, &
n) >= 1) {
484 if (sscanf(++
str,
"%3s%n", s, &
n) >= 1) {
498 if (sscanf(++
str,
"%3s%n", s, &
n) >= 1) {
512 if (sscanf(++
str,
"%lu%n", &
t, &
n) >= 1) {
521 if (sscanf(++
str,
"%3s%n", s, &
n) >= 1) {
552 while (*
str &&
isspace((
unsigned char)(*str)))
566 info->vhost = (
unsigned char)
len;
572 info->u.dns.name = 1;
574 info->u.dns.name = 0;
600 nlen = name ? strlen(name) + 1 : 0;
604 memcpy((
char*)
info +
size, name, nlen);
606 info->u.dns.name = 1;
608 info->u.dns.name = 0;
632 ? (
sizeof(*info) -
sizeof(
info->u)
634 + (
info->vhost ? (size_t)
info->vhost + 1 : 0)
652 && memcmp(&i1->
addr, &i2->
addr,
sizeof(i1->
addr)) != 0) {
688 char*
str = (
char*)
malloc(reserve + strlen(args) + 3);
691 sprintf(
str + reserve,
"%s", *args ? args :
"''");
703 for (c = *
str; *c; ++c) {
704 if (
isspace((
unsigned char)(*c))) {
705 size_t len = (size_t)(c - *
str);
709 while (*c &&
isspace((
unsigned char)(*c)))
746 else if (
strcmp(args,
"''") == 0)
747 args_len = 1, args = 0;
749 args_len = strlen(args) + 1;
766 memset(&
info->addr, 0,
sizeof(
info->addr));
831 memset(&
info->addr, 0,
sizeof(
info->addr));
832 memset(&
info->u.standalone, 0,
sizeof(
info->u.standalone));
854 char*
str = (
char*)
malloc(reserve + strlen(path) + strlen(args) + 2);
856 int n = sprintf(
str + reserve,
"%s", path);
858 sprintf(
str + reserve +
n,
"%s%s", &
"?"[!(*args !=
'#')], args);
873 for (c = *
str; ; ++c) {
874 if (!*c ||
isspace((
unsigned char)(*c))) {
875 size_t len = (size_t)(c - *
str);
879 while (*c &&
isspace((
unsigned char)(*c)))
884 if ((args = strchr(path,
'?')) != 0)
916 return sizeof(u->
http) + (
size_t)((args + strlen(args) + 1) - path);
935 size_t path_len, args_len;
943 path_len = strlen(path) + 1;
945 args_len = args && *args ? strlen(args) + 1 : 1;
948 path_len--, args_len = 1;
950 args_len = strlen(args) + 1;
952 add += path_len + args_len;
968 memset(&
info->addr, 0,
sizeof(
info->addr));
995 size_t namelen = strlen(name);
996 char*
str = (
char*)
malloc(reserve + (namelen ? namelen + 1 : 0));
999 strcpy(
str + reserve, name);
1029 unsigned short port,
1050 memset(&
info->addr, 0,
sizeof(
info->addr));
1058 unsigned short port,
1072 char*
str = (
char*)
malloc(reserve + 1);
1075 str[reserve] =
'\0';
1089 return sizeof(u->
dns);
1113 memset(&
info->addr, 0,
sizeof(
info->addr));
1114 memset(&
info->u.dns, 0,
sizeof(
info->u.dns));
static const char * str(char *buf, int n)
#define SERV_MINIMAL_RATE
SSERV_Info * SERV_CreateStandaloneInfo(unsigned int host, unsigned short port)
#define SERV_HTTP_PATH(ui)
#define SERV_HTTP_ARGS(ui)
SSERV_Info * SERV_CreateNcbidInfo(unsigned int host, unsigned short port, const char *args)
SSERV_Info * SERV_CopyInfo(const SSERV_Info *orig)
SSERV_Info * SERV_CreateDnsInfo(unsigned int host)
SSERV_FirewallInfo firewall
SSERV_Info * SERV_ReadInfo(const char *str)
size_t SERV_SizeOfInfo(const SSERV_Info *info)
const char * SERV_ReadType(const char *str, ESERV_Type *type)
#define SERV_MINIMAL_BONUS
#define SERV_MAXIMAL_RATE
const char * SERV_TypeStr(ESERV_Type type)
SSERV_StandaloneInfo standalone
SSERV_Info * SERV_CreateHttpInfo(ESERV_Type type, unsigned int host, unsigned short port, const char *path, const char *args)
#define SERV_DEFAULT_ALGO
char * SERV_WriteInfo(const SSERV_Info *info)
SSERV_Info * SERV_CreateFirewallInfo(unsigned int host, unsigned short port, ESERV_Type type)
int SERV_EqualInfo(const SSERV_Info *i1, const SSERV_Info *i2)
#define SERV_MAXIMAL_BONUS
#define SERV_NCBID_ARGS(ui)
int SOCK_isipEx(const char *host, int fullquad)
Check whether the given string represents a valid IPv4 address.
unsigned int SOCK_HostToNetLong(unsigned int value)
See man for the BSDisms, htonl() and htons().
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...
int SOCK_isip(const char *host)
Equivalent of SOCK_isip(host, 0)
unsigned int TNCBI_Size
Fixed-size analogs of size_t and time_t (mainly for IPC)
char * MIME_ComposeContentTypeEx(EMIME_Type type, EMIME_SubType subtype, EMIME_Encoding encoding, char *buf, size_t bufsize)
#define CONN_CONTENT_TYPE_LEN
int MIME_ParseContentTypeEx(const char *str, EMIME_Type *type, EMIME_SubType *subtype, EMIME_Encoding *encoding)
where boath are integers</td > n< td ></td > n</tr > n< tr > n< td > tse</td > n< td > optional</td > n< td > String</td > n< td class=\"description\"> TSE option controls what blob is orig
if(yy_accept[yy_current_state])
const struct ncbi::grid::netcache::search::fields::SIZE size
int strcmp(const char *str1, const char *str2)
double NCBI_simple_atof(const char *s, char **t)
Locale-independent ASCII-to-double conversion of string "s".
char * strncpy0(char *s1, const char *s2, size_t n)
Copy not more than "n" characters from string "s2" into "s1", and return the result,...
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",...
int NcbiIsEmptyIPv6(const TNCBI_IPv6Addr *addr)
Return non-zero if the address is empty (either as IPv6 or IPv4); return zero otherwise.
unsigned int NcbiIPv6ToIPv4(const TNCBI_IPv6Addr *addr, size_t pfxlen)
Extract and return a network byte order IPv4 embedded address from an IPv6 address,...
char * NcbiAddrToString(char *buf, size_t bufsize, const TNCBI_IPv6Addr *addr)
Convert an IPv6 address into either a full-quad text IPv4 (for IPv4-mapped IPv6 addresses) or a hex c...
int NcbiIsIPv4(const TNCBI_IPv6Addr *addr)
Return non-zero(true) if the address is a true IPv4 address (a mapped IPv4 address); return zero(fals...
int NcbiIPv4ToIPv6(TNCBI_IPv6Addr *addr, unsigned int ipv4, size_t pfxlen)
Embed a passed network byte order IPv4 address into an IPv6 address using the specified prefix length...
const char * NcbiIPToAddr(TNCBI_IPv6Addr *addr, const char *str, size_t len)
Convert into an IPv6 address, the first "len" (or "strlen(str)" if "len" is 0) bytes of "str" from ei...
static const SSERV_Attr * s_GetAttrByTag(const char *tag)
static SSERV_Info * s_Ncbid_Read(const char **str, size_t add)
static SSERV_Info * s_Http_Read(const char **str, size_t add)
static char * s_Firewall_Write(size_t reserve, const USERV_Info *u)
SSERV_Info * SERV_ReadInfoEx(const char *str, const char *name, int lazy)
static char * s_Dns_Write(size_t reserve, const USERV_Info *u)
static const char kHTTP_GET[]
static size_t s_Firewall_SizeOf(const USERV_Info *u)
static size_t s_Ncbid_SizeOf(const USERV_Info *u)
static const char kRegularInter[]
static int s_Http_Equal(const USERV_Info *u1, const USERV_Info *u2)
static SSERV_Info * s_HttpPost_Read(const char **str, size_t add)
static int s_Ncbid_Equal(const USERV_Info *u1, const USERV_Info *u2)
static const char kHTTP[]
static size_t s_Dns_SizeOf(const USERV_Info *u)
TNCBI_IPv6Addr SERV_AddrOfInfo(const SSERV_Info *info)
static const char kFIREWALL[]
static const char kBlast[]
static char * s_Standalone_Write(size_t reserve, const USERV_Info *u)
static SSERV_Info * s_HttpAny_Read(ESERV_Type type, const char **str, size_t add)
static SSERV_Info * s_Dns_Read(const char **str, size_t add)
SSERV_Info * SERV_CopyInfoEx(const SSERV_Info *orig, const char *name)
static size_t s_Http_SizeOf(const USERV_Info *u)
SSERV_Info * SERV_CreateDnsInfoEx(unsigned int host, size_t add)
static SSERV_Info * s_Standalone_Read(const char **str, size_t add)
static const SSERV_Attr kSERV_Attr[]
static SSERV_Info * s_Firewall_Read(const char **str, size_t add)
SSERV_Info * SERV_CreateHttpInfoEx(ESERV_Type type, unsigned int host, unsigned short port, const char *path, const char *args, size_t add)
static size_t s_Standalone_SizeOf(const USERV_Info *u)
SSERV_Info * SERV_CreateNcbidInfoEx(unsigned int host, unsigned short port, const char *args, size_t add)
static struct @1002 kFlags[]
static const char kSTANDALONE[]
static const char kRegular[]
const char * SERV_HostOfInfo(const SSERV_Info *info)
static char * s_Ncbid_Write(size_t reserve, const USERV_Info *u)
static const char kBlastInter[]
static SSERV_Info * s_HttpGet_Read(const char **str, size_t add)
const char * SERV_NameOfInfo(const SSERV_Info *info)
static const SSERV_Attr * s_GetAttrByType(ESERV_Type type)
SSERV_Info * SERV_CreateStandaloneInfoEx(unsigned int host, unsigned short port, size_t add)
static const char kNCBID[]
SSERV_Info * SERV_CreateFirewallInfoEx(unsigned int host, unsigned short port, ESERV_Type type, size_t add)
static const char kHTTP_POST[]
static char * s_Http_Write(size_t reserve, const USERV_Info *u)
static int s_Firewall_Equal(const USERV_Info *u1, const USERV_Info *u2)
const char * SOCK_StringToHostPortEx(const char *str, unsigned int *host, unsigned short *port, int flag)
SSERV_Info *(* Read)(const char **str, size_t add)
int(* Equal)(const USERV_Info *u1, const USERV_Info *u2)
size_t(* SizeOf)(const USERV_Info *u)
char *(* Write)(size_t reserve, const USERV_Info *u)