NCBI C++ ToolKit
ncbi_server_info.c
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: ncbi_server_info.c 95559 2021-11-24 20:22:45Z lavr $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Author: Anton Lavrentiev, Denis Vakatov
27  *
28  * File Description:
29  * NCBI server meta-address info
30  *
31  */
32 
33 #include "ncbi_ansi_ext.h"
34 #include "ncbi_assert.h"
35 #include "ncbi_server_infop.h"
36 #include "ncbi_socketp.h"
37 #include <ctype.h>
38 #include <stdio.h>
39 #include <stdlib.h>
40 
41 #ifdef fabs
42 # undef fabs
43 #endif /*fabs*/
44 #define fabs(v) ((v) < 0.0 ? -(v) : (v))
45 
46 #define MAX_IP_ADDR_LEN 80 /*IPv6 friendly*/
47 
48 #define SERV_VHOSTABLE (/*fSERV_Ncbid |*/ fSERV_Http | fSERV_Standalone)
49 
50 #if CONN_HOST_LEN > 255
51 # error "CONN_HOST_LEN may not be greater than 255"
52 #endif
53 
54 
55 /*
56  * Server-info storage model:
57  * SSERV_Info's basic fields are stored per the structure;
58  * SSERV_Info::u is the last "fixed" field;
59  * SSERV_Info::u's string parameters are stored contiguously following the
60  * "fixed" area (SSERV_Ops::SizeOf() returns the size of the
61  * type-dependent "u" plus all the string parameters);
62  * SSERV_Info::vhost (if non-zero) is stored past the parameters (+'\0');
63  * SSERV_Info::extra defines the size of "extra" opaque bytes (which may be
64  * used to keep private information) that follow vhost (or the
65  * SSERV_Info::u's block if vhost is empty), zero means none;
66  * SERV_SizeOfInfo() returns the size that includes all of the above.
67  * Service name may be stored right past the entire info, contiguously.
68  */
69 
70 
71 /*****************************************************************************
72  * Attributes for the different server types:: Interface
73  */
74 
75 /* Table of operations: req = required; opt = optional
76  */
77 typedef struct {
78  SSERV_Info* (*Read )(const char** str, size_t add); /*req*/
79  char* (*Write )(size_t reserve, const USERV_Info* u); /*req*/
80  int/*bool*/ (*Equal )(const USERV_Info *u1, const USERV_Info *u2); /*opt*/
81  size_t (*SizeOf)(const USERV_Info *u); /*req*/
82 } SSERV_Ops;
83 
84 
85 /* Attributes
86  */
87 typedef struct {
89  const char* tag;
90  size_t len;
92 } SSERV_Attr;
93 
94 
95 /* Flags: to be removed, backward compatibility only
96  */
97 static const char kRegularInter[] = "RegularInter";
98 static const char kBlastInter[] = "BlastInter";
99 static const char kRegular[] = "Regular";
100 static const char kBlast[] = "Blast";
101 
102 static struct {
103  const char* tag;
104  size_t len;
107 } kFlags[] = {
108  /* must be ordered longer-to-shorter */
111  { kRegular, sizeof(kRegular)-1, eSERV_Regular, (ESERV_Site) 0 },
112  { kBlast, sizeof(kBlast)-1, eSERV_Blast, (ESERV_Site) 0 }
113 };
114 
115 
116 /* Attributes' lookup (by either type or tag)
117  */
119 static const SSERV_Attr* s_GetAttrByTag (const char* tag);
120 
121 
122 extern const char* SERV_TypeStr(ESERV_Type type)
123 {
124  const SSERV_Attr* attr = s_GetAttrByType(type);
125  return attr ? attr->tag : "";
126 }
127 
128 
129 extern const char* SERV_ReadType(const char* str,
130  ESERV_Type* type)
131 {
132  const SSERV_Attr* attr = s_GetAttrByTag(str);
133  if (!attr)
134  return 0;
135  *type = attr->type;
136  return str + attr->len;
137 }
138 
139 
140 
141 /*****************************************************************************
142  * Generic methods based on the server info's virtual functions
143  */
144 
145 extern char* SERV_WriteInfo(const SSERV_Info* info)
146 {
147  static const char* k_YN[] = { "yes", "no" };
148  char c_t[CONN_CONTENT_TYPE_LEN+1];
149  const SSERV_Attr* attr;
150  size_t reserve;
151  char* str;
152 
153  if (!(attr = s_GetAttrByType(info->type)))
154  return 0;
155  if (info->type != fSERV_Dns
156  && MIME_ComposeContentTypeEx(info->mime_t, info->mime_s,
157  info->mime_e, c_t, sizeof(c_t))) {
158  char* p;
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, ' ');
162  assert(p);
163  p++;
164  memmove(c_t, p, strlen(p) + 1);
165  } else
166  *c_t = '\0';
167  reserve = attr->len+1 + MAX_IP_ADDR_LEN + 1+5/*port*/ + 1+12/*algo*/
168  + 1+9/*coef*/ + 3+strlen(c_t)/*cont.type*/ + 3*(1+5)/*site*/
169  + 1+14/*rate*/ + 2*(1+5)/*mode*/ + 1+12/*time*/ + 2*(1+5)/*$,X*/
170  + 3+info->vhost
171  + 1/*EOL*/;
172  /* write server-specific info */
173  if ((str = attr->ops.Write(reserve, &info->u)) != 0) {
174  char* s = str;
175  size_t n;
176 
177  memcpy(s, attr->tag, attr->len);
178  s += attr->len;
179  *s++ = ' ';
180  if (info->host == SOCK_HostToNetLong((unsigned int)(-1))) {
181  int/*bool*/ ipv6 = !NcbiIsIPv4(&info->addr) && info->port;
182  if (ipv6)
183  *s++ = '[';
184  if (!(s = NcbiAddrToString(s, MAX_IP_ADDR_LEN, &info->addr))) {
185  free(str);
186  return 0;
187  }
188  if (ipv6)
189  *s++ = ']';
190  if (info->port)
191  s += sprintf(s, ":%hu", info->port);
192  } else
193  s += SOCK_HostPortToString(info->host, info->port, s, reserve);
194  if ((n = strlen(str + reserve)) != 0) {
195  *s++ = ' ';
196  memmove(s, str + reserve, n + 1);
197  s = str + strlen(str);
198  }
199  if (info->algo != eSERV_Regular) {
200  assert(info->algo == eSERV_Blast);
201  strcpy(s, " A=B");
202  s += 4;
203  }
204  if (info->coef)
205  s = NCBI_simple_ftoa(strcpy(s, " B=") + 3, info->coef, 2);
206  if (*c_t)
207  s += sprintf(s, " C=%s", c_t);
208  if (info->vhost) {
209  size_t size = attr->ops.SizeOf(&info->u);
210  const char* vhost = (const char*) &info->u + size;
211  s += sprintf(s, " H=%.*s", (int) info->vhost, vhost);
212  }
213  s += sprintf(s, " L=%s", k_YN[!(info->site & fSERV_Local)]);
214  if (info->type != fSERV_Dns && (info->site & fSERV_Private))
215  s += sprintf(s, " P=yes");
216  s = NCBI_simple_ftoa(strcpy(s," R=") + 3, info->rate,
217  fabs(info->rate) < 0.01 ? 3 : 2);
218  if (!(info->type & fSERV_Http) && info->type != fSERV_Dns)
219  s += sprintf(s, " S=%s", k_YN[!(info->mode & fSERV_Stateful)]);
220  if (info->type != fSERV_Dns && (info->mode & fSERV_Secure))
221  s += sprintf(s, " $=yes");
222  if (info->time)
223  s += sprintf(s, " T=%lu", (unsigned long) info->time);
224  if (info->site & fSERV_Interzone)
225  sprintf(s, " X=yes");
226  }
227  return str;
228 }
229 
230 
232  const char* name,
233  int/*bool*/ lazy)
234 {
235  int/*bool*/ algo, coef, mime, locl, priv, rate, sful, secu, time, cros, vh;
236  const char* vhost;
237  const SSERV_Attr* attr;
238  unsigned int host; /* network byte order */
239  unsigned short port; /* host (native) byte order */
241  SSERV_Info* info;
243  size_t len;
244 
245  /* detect server type */
246  str = SERV_ReadType(str, &type);
247  if (!str || (*str && !isspace((unsigned char)(*str))))
248  return 0;
249  /* NB: "str" guarantees there is a non-NULL attr */
250  verify((attr = s_GetAttrByType(type)) != 0);
251  while (*str && isspace((unsigned char)(*str)))
252  ++str;
253 
254  /* read optional connection point */
255  if (*str &&
256  (*str == ':' || *str == '[' || !ispunct((unsigned char)(*str)))) {
257  const char* end = str;
258  while (*end && !isspace((unsigned char)(*end)))
259  ++end;
260  verify((len = (size_t)(end - str)) > 0);
261 
262  if (!(*str == ':' || *str == '[')) {
263  if (strcspn(str, "=") >= len) {
264  size_t i;
265  for (i = 0; i < sizeof(kFlags) / sizeof(kFlags[0]); ++i) {
266  if (len == kFlags[i].len
267  && strncasecmp(str, kFlags[i].tag, len) == 0) {
268  end = 0;
269  break;
270  }
271  }
272  } else
273  end = 0;
274  }
275  if (end) {
276  int/*bool*/ ipv6 = *str == '[' && len > 2 ? 1/*T*/ : 0/*F*/;
277  const char* tmp = NcbiIPToAddr(&addr, str + ipv6, len - ipv6);
278  if (tmp && (!ipv6 || (*tmp++ == ']' && *tmp == ':'))) {
279  if (tmp != end && *tmp != ':')
280  return 0;
281  str = tmp;
282  ipv6 = 1;
283  vhost = 0;
284  } else if (*str == '[') {
285  /* not a valid IP(v4/v6) address */
286  return 0;
287  } else {
288  assert(!ipv6);
289  vhost = attr->type & SERV_VHOSTABLE ? str : 0;
290  }
291  if (str == end)
292  port = 0/*NB: "ipv6" case only*/;
293  else if (!(str = SOCK_StringToHostPortEx(str, &host, &port, lazy)))
294  return 0;
295  else if (str != end)
296  return 0;
297  else if (!lazy && host == SOCK_HostToNetLong((unsigned int)(-1)))
298  vhost = 0;
299  if (!ipv6)
300  NcbiIPv4ToIPv6(&addr, host, 0);
301  else if (NcbiIsIPv4(&addr))
302  host = NcbiIPv6ToIPv4(&addr, 0);
303  else
304  host = SOCK_HostToNetLong((unsigned int)(-1));
305  while (*str && isspace((unsigned char)(*str)))
306  ++str;
307  if (vhost) {
308  /*NB: NcbiIPToAddr() can parse full-quad IPv4, so !vhost*/
309  int/*bool*/ dot = 0/*false*/;
310  for (len = 0; len < (size_t)(end - vhost); ++len) {
311  if (vhost[len] == ':')
312  break;
313  if (vhost[len] == '.')
314  dot = 1/*true*/;
315  }
316  if (1 < len && len <= CONN_HOST_LEN && dot) {
317  tmp = strndup(vhost, len);
318  assert(!tmp || !SOCK_isipEx(tmp, 1/*full-quad*/));
319  if (tmp) {
320  if (SOCK_isip(tmp)/*NB: very unlikely*/)
321  vhost = 0;
322  free((void*) tmp);
323  } else
324  vhost = 0;
325  } else
326  vhost = 0;
327  }
328  } else {
329  host = 0;
330  port = 0;
331  memset(&addr, 0, sizeof(addr));
332  vhost = 0;
333  len = 0;
334  }
335  } else {
336  host = 0;
337  port = 0;
338  memset(&addr, 0, sizeof(addr));
339  vhost = 0;
340  len = 0;
341  }
342  if (!port && attr->type == fSERV_Standalone)
343  return 0;
344 
345  /* read server-specific info according to the detected type... */
346  info = attr->ops.Read(&str,
347  (attr->type & SERV_VHOSTABLE ? CONN_HOST_LEN+1 : 0) +
348  (name ? strlen(name) + 1 : 0));
349  if (!info)
350  return 0;
351  assert(info->type == attr->type);
352  info->host = host;
353  info->port = port;
354  info->addr = addr;
355  algo = coef = mime = locl = priv = rate = sful = secu = time = cros = vh
356  = 0/*false*/;
357 
358  /* ...continue reading server info: optional tags */
359  while (*str && isspace((unsigned char)(*str)))
360  ++str;
361  while (*str) {
362  if (str[1] == '=' && str[2] && !isspace((unsigned char) str[2])) {
363  char* e;
364  int n;
365  double d;
366  unsigned long t;
367  char s[4];
368  EMIME_Type mime_t;
369  EMIME_SubType mime_s;
370  EMIME_Encoding mime_e;
371 
372  switch (toupper((unsigned char)(*str++))) {
373  case 'A':
374  if (algo)
375  break;
376  algo = 1/*true*/;
377  switch ((unsigned char)(*++str)) {
378  case 'B':
379  info->algo = eSERV_Blast;
380  ++str;
381  break;
382  case 'R':
383  info->algo = eSERV_Regular;
384  ++str;
385  break;
386  default:
387  break;
388  }
389  break;
390  case 'B':
391  if (coef)
392  break;
393  coef = 1/*true*/;
394  d = NCBI_simple_atof(++str, &e);
395  if (e > str) {
396  if (fabs(d) < SERV_MINIMAL_BONUS / 2.0)
397  d = 0.0;
398  else if (fabs(d) < SERV_MINIMAL_BONUS)
399  d = d < 0.0 ? -SERV_MINIMAL_BONUS : SERV_MINIMAL_BONUS;
400  else if (fabs(d) > SERV_MAXIMAL_BONUS)
401  d = d < 0.0 ? -SERV_MAXIMAL_BONUS : SERV_MAXIMAL_BONUS;
402  info->coef = d;
403  str = e;
404  }
405  break;
406  case 'C':
407  if (mime || type == fSERV_Dns)
408  break;
409  mime = 1/*true*/;
410  if (MIME_ParseContentTypeEx(++str, &mime_t, &mime_s, &mime_e)){
411  info->mime_t = mime_t;
412  info->mime_s = mime_s;
413  info->mime_e = mime_e;
414  /* skip the entire token */
415  while (*str && !isspace((unsigned char)(*str)))
416  ++str;
417  }
418  break;
419  case 'H':
420  if (vh || !(info->type & SERV_VHOSTABLE))
421  break;
422  vh = 1/*true*/;
423  for (len = 0, vhost = ++str; vhost[len]; ++len) {
424  if (isspace((unsigned char) vhost[len]))
425  break;
426  if (len > CONN_HOST_LEN)
427  break;
428  }
429  assert(len);
430  if (len > CONN_HOST_LEN)
431  break;
432  str = vhost + len;
433  if (len == 2 && memcmp(vhost, "''", 2) == 0)
434  vhost = 0;
435  break;
436  case 'L':
437  if (locl)
438  break;
439  locl = 1/*true*/;
440  if (sscanf(++str, "%3s%n", s, &n) >= 1) {
441  if (strcasecmp(s, "YES") == 0) {
442  info->site |= fSERV_Local;
443  str += n;
444  } else if (strcasecmp(s, "NO") == 0) {
445  info->site &= (TSERV_Site)(~fSERV_Local);
446  str += n;
447  }
448  }
449  break;
450  case 'P':
451  if (priv || type == fSERV_Dns)
452  break;
453  priv = 1/*true*/;
454  if (sscanf(++str, "%3s%n", s, &n) >= 1) {
455  if (strcasecmp(s, "YES") == 0) {
456  info->site |= fSERV_Private;
457  str += n;
458  } else if (strcasecmp(s, "NO") == 0) {
459  info->site &= (TSERV_Site)(~fSERV_Private);
460  str += n;
461  }
462  }
463  break;
464  case 'R':
465  if (rate)
466  break;
467  rate = 1/*true*/;
468  d = NCBI_simple_atof(++str, &e);
469  if (e > str) {
470  if (fabs(d) < SERV_MINIMAL_RATE / 2.0)
471  d = 0.0;
472  else if (fabs(d) < SERV_MINIMAL_RATE)
473  d = d < 0.0 ? -SERV_MINIMAL_RATE : SERV_MINIMAL_RATE;
474  else if (fabs(d) > SERV_MAXIMAL_RATE)
475  d = d < 0.0 ? -SERV_MAXIMAL_RATE : SERV_MAXIMAL_RATE;
476  info->rate = d;
477  str = e;
478  }
479  break;
480  case 'S':
481  if (sful || type == fSERV_Dns || (type & fSERV_Http))
482  break;
483  sful = 1/*true*/;
484  if (sscanf(++str, "%3s%n", s, &n) >= 1) {
485  if (strcasecmp(s, "YES") == 0) {
486  info->mode |= fSERV_Stateful;
487  str += n;
488  } else if (strcasecmp(s, "NO") == 0) {
489  info->mode &= (TSERV_Mode)(~fSERV_Stateful);
490  str += n;
491  }
492  }
493  break;
494  case '$':
495  if (secu || type == fSERV_Dns)
496  break;
497  secu = 1/*true*/;
498  if (sscanf(++str, "%3s%n", s, &n) >= 1) {
499  if (strcasecmp(s, "YES") == 0) {
500  info->mode |= fSERV_Secure;
501  str += n;
502  } else if (strcasecmp(s, "NO") == 0) {
503  info->mode &= (TSERV_Mode)(~fSERV_Secure);
504  str += n;
505  }
506  }
507  break;
508  case 'T':
509  if (time)
510  break;
511  time = 1/*true*/;
512  if (sscanf(++str, "%lu%n", &t, &n) >= 1) {
513  info->time = (TNCBI_Time) t;
514  str += n;
515  }
516  break;
517  case 'X':
518  if (cros)
519  break;
520  cros = 1/*true*/;
521  if (sscanf(++str, "%3s%n", s, &n) >= 1) {
522  if (strcasecmp(s, "YES") == 0) {
523  info->site |= fSERV_Interzone;
524  str += n;
525  } else if (strcasecmp(s, "NO") == 0) {
526  info->site &= (TSERV_Site)(~fSERV_Interzone);
527  str += n;
528  }
529  }
530  break;
531  }
532  } else if (!algo) {
533  size_t i;
534  algo = 1/*true*/;
535  for (i = 0; i < sizeof(kFlags) / sizeof(kFlags[0]); ++i) {
536  if (strncasecmp(str, kFlags[i].tag, kFlags[i].len) == 0) {
537  if (kFlags[i].site) {
538  if (cros)
539  break;
540  cros = 1/*true*/;
541  info->site |= (TSERV_Site) kFlags[i].site;
542  }
543  info->algo = kFlags[i].algo;
544  str += kFlags[i].len;
545  break;
546  }
547  }
548  } else
549  break;
550  if (*str && !isspace((unsigned char)(*str)))
551  break;
552  while (*str && isspace((unsigned char)(*str)))
553  ++str;
554  }
555 
556  if (!*str &&
557  (!vh || (info->mode & fSERV_Secure) || (info->type & fSERV_Http))){
558  if (!vh
559  && !((info->mode & fSERV_Secure) || (info->type & fSERV_Http))){
560  vhost = 0;
561  }
562  if (vhost) {
563  assert(len && len <= CONN_HOST_LEN);
564  strncpy0((char*) &info->u + attr->ops.SizeOf(&info->u),
565  vhost, len);
566  info->vhost = (unsigned char) len;
567  assert((size_t) info->vhost == len);
568  }
569  if (name) {
570  strcpy((char*) info + SERV_SizeOfInfo(info), name);
571  if (info->type == fSERV_Dns)
572  info->u.dns.name = 1/*true*/;
573  } else if (info->type == fSERV_Dns)
574  info->u.dns.name = 0/*false*/;
575  if (!info->port
576  && (info->type == fSERV_Ncbid || (info->type & fSERV_Http))) {
577  info->port = secu ? CONN_PORT_HTTPS : CONN_PORT_HTTP;
578  }
579  } else {
580  free(info);
581  info = 0;
582  }
583  return info;
584 }
585 
586 
587 extern SSERV_Info* SERV_ReadInfo(const char* str)
588 {
589  return SERV_ReadInfoEx(str, 0, 0);
590 }
591 
592 
594  const char* name)
595 {
596  size_t nlen, size = SERV_SizeOfInfo(orig);
597  SSERV_Info* info;
598  if (!size)
599  return 0;
600  nlen = name ? strlen(name) + 1 : 0;
601  if ((info = (SSERV_Info*) malloc(size + nlen)) != 0){
602  memcpy(info, orig, size);
603  if (name) {
604  memcpy((char*) info + size, name, nlen);
605  if (orig->type == fSERV_Dns)
606  info->u.dns.name = 1/*true*/;
607  } else if (orig->type == fSERV_Dns)
608  info->u.dns.name = 0/*false*/;
609  }
610  return info;
611 }
612 
613 
615 {
616  return SERV_CopyInfoEx(orig, 0);
617 }
618 
619 
620 const char* SERV_NameOfInfo(const SSERV_Info* info)
621 {
622  return !info ? 0
623  : info->type != fSERV_Dns || info->u.dns.name
624  ? (const char*) info + SERV_SizeOfInfo(info) : "";
625 }
626 
627 
628 extern size_t SERV_SizeOfInfo(const SSERV_Info *info)
629 {
630  const SSERV_Attr* attr = info ? s_GetAttrByType(info->type) : 0;
631  return attr
632  ? (sizeof(*info) - sizeof(info->u)
633  + attr->ops.SizeOf(&info->u)
634  + (info->vhost ? (size_t) info->vhost + 1 : 0)
635  + info->extra)
636  : 0;
637 }
638 
639 
640 extern int/*bool*/ SERV_EqualInfo(const SSERV_Info *i1,
641  const SSERV_Info *i2)
642 {
643  const SSERV_Attr* attr;
644  assert(i1 && i2);
645  /* NB: IPv6 address causes the "host" field to be INADDR_NONE(-1) */
646  if (i1->type != i2->type ||
647  i1->host != i2->host ||
648  i1->port != i2->port) {
649  return 0/*false*/;
650  }
651  if (!NcbiIsEmptyIPv6(&i1->addr) && !NcbiIsEmptyIPv6(&i2->addr)
652  && memcmp(&i1->addr, &i2->addr, sizeof(i1->addr)) != 0) {
653  return 0/*false*/;
654  }
655  if (!(attr = s_GetAttrByType(i1->type/*==i2->type*/)))
656  return 0/*false*/;
657  return attr->ops.Equal ? attr->ops.Equal(&i1->u, &i2->u) : 1;
658 }
659 
660 
661 const char* SERV_HostOfInfo(const SSERV_Info* info)
662 {
663  const SSERV_Attr* attr;
664  if (!info->vhost || !(attr = s_GetAttrByType(info->type)))
665  return 0;
666  return (const char*) &info->u + attr->ops.SizeOf(&info->u);
667 }
668 
669 
671 {
673  if (!NcbiIsEmptyIPv6(&info->addr))
674  return info->addr;
675  NcbiIPv4ToIPv6(&addr, info->host, 0);
676  return addr;
677 }
678 
679 
680 /*****************************************************************************
681  * NCBID:: constructor and virtual functions
682  */
683 
684 static char* s_Ncbid_Write(size_t reserve, const USERV_Info* u)
685 {
686  const SSERV_NcbidInfo* info = &u->ncbid;
687  const char* args = SERV_NCBID_ARGS(info);
688  char* str = (char*) malloc(reserve + strlen(args) + 3);
689 
690  if (str)
691  sprintf(str + reserve, "%s", *args ? args : "''");
692  return str;
693 }
694 
695 
696 static SSERV_Info* s_Ncbid_Read(const char** str, size_t add)
697 {
698  char* args = 0;
699  SSERV_Info* info;
700  const char* c;
701 
702  assert(!isspace((unsigned char)(**str)));
703  for (c = *str; *c; ++c) {
704  if (isspace((unsigned char)(*c))) {
705  size_t len = (size_t)(c - *str);
706  assert(len);
707  if (!(args = strndup(*str, len)))
708  return 0;
709  while (*c && isspace((unsigned char)(*c)))
710  ++c;
711  break;
712  }
713  }
714  info = SERV_CreateNcbidInfoEx(0, 0, args, add);
715  if (info)
716  *str = c;
717  if (args)
718  free(args);
719  return info;
720 }
721 
722 
723 static size_t s_Ncbid_SizeOf(const USERV_Info* u)
724 {
725  return sizeof(u->ncbid) + strlen(SERV_NCBID_ARGS(&u->ncbid))+1;
726 }
727 
728 
729 static int/*bool*/ s_Ncbid_Equal(const USERV_Info* u1, const USERV_Info* u2)
730 {
731  return
732  strcmp(SERV_NCBID_ARGS(&u1->ncbid), SERV_NCBID_ARGS(&u2->ncbid)) == 0;
733 }
734 
735 
737  unsigned short port,
738  const char* args,
739  size_t add)
740 {
741  size_t args_len;
742  SSERV_Info* info;
743 
744  if (!args)
745  args_len = 1;
746  else if (strcmp(args, "''"/*special case*/) == 0)
747  args_len = 1, args = 0;
748  else
749  args_len = strlen(args) + 1;
750  add += args_len;
751  if ((info = (SSERV_Info*) malloc(sizeof(SSERV_Info) + add)) != 0) {
752  info->type = fSERV_Ncbid;
753  info->host = host;
754  info->port = port;
755  info->mode = 0;
756  info->site = fSERV_Local;
757  info->time = 0;
758  info->coef = 0.0;
759  info->rate = 0.0;
760  info->mime_t = eMIME_T_Undefined;
761  info->mime_s = eMIME_Undefined;
762  info->mime_e = eENCOD_None;
763  info->algo = SERV_DEFAULT_ALGO;
764  info->vhost = 0;
765  info->extra = 0;
766  memset(&info->addr, 0, sizeof(info->addr));
767  info->u.ncbid.args = (TNCBI_Size) sizeof(info->u.ncbid);
768  memcpy(SERV_NCBID_ARGS(&info->u.ncbid), args ? args : "", args_len);
769  }
770  return info;
771 }
772 
773 
774 extern SSERV_Info* SERV_CreateNcbidInfo(unsigned int host,
775  unsigned short port,
776  const char* args)
777 {
778  return SERV_CreateNcbidInfoEx(host, port, args, 0);
779 }
780 
781 
782 /*****************************************************************************
783  * STANDALONE:: constructor and virtual functions
784  */
785 
786 /*ARGSUSED*/
787 static char* s_Standalone_Write(size_t reserve, const USERV_Info* u)
788 {
789  char* str = (char*) malloc(reserve + 1);
790 
791  if (str)
792  str[reserve] = '\0';
793  return str;
794 }
795 
796 
797 /*ARGSUSED*/
798 static SSERV_Info* s_Standalone_Read(const char** str, size_t add)
799 {
800  return SERV_CreateStandaloneInfoEx(0, 0, add);
801 }
802 
803 
804 static size_t s_Standalone_SizeOf(const USERV_Info* u)
805 {
806  return sizeof(u->standalone);
807 }
808 
809 
811  unsigned short port,
812  size_t add)
813 {
814  SSERV_Info *info = (SSERV_Info*) malloc(sizeof(SSERV_Info) + add);
815 
816  if (info) {
817  info->type = fSERV_Standalone;
818  info->host = host;
819  info->port = port;
820  info->mode = 0;
821  info->site = fSERV_Local;
822  info->time = 0;
823  info->coef = 0.0;
824  info->rate = 0.0;
825  info->mime_t = eMIME_T_Undefined;
826  info->mime_s = eMIME_Undefined;
827  info->mime_e = eENCOD_None;
828  info->algo = SERV_DEFAULT_ALGO;
829  info->vhost = 0;
830  info->extra = 0;
831  memset(&info->addr, 0, sizeof(info->addr));
832  memset(&info->u.standalone, 0, sizeof(info->u.standalone));
833  }
834  return info;
835 }
836 
837 
838 extern SSERV_Info* SERV_CreateStandaloneInfo(unsigned int host,
839  unsigned short port)
840 {
841  return SERV_CreateStandaloneInfoEx(host, port, 0);
842 }
843 
844 
845 /*****************************************************************************
846  * HTTP:: constructor and virtual functions
847  */
848 
849 static char* s_Http_Write(size_t reserve, const USERV_Info* u)
850 {
851  const SSERV_HttpInfo* info = &u->http;
852  const char* path = SERV_HTTP_PATH(info);
853  const char* args = SERV_HTTP_ARGS(info);
854  char* str = (char*) malloc(reserve + strlen(path) + strlen(args) + 2);
855  if (str) {
856  int n = sprintf(str + reserve, "%s", path);
857  if (*args)
858  sprintf(str + reserve + n, "%s%s", &"?"[!(*args != '#')], args);
859  }
860  return str;
861 }
862 
863 
864 static SSERV_Info* s_HttpAny_Read(ESERV_Type type,const char** str, size_t add)
865 {
866  char* path, *args;
867  SSERV_Info* info;
868  const char* c;
869 
870  if (!**str)
871  return 0;
872  assert(!isspace((unsigned char)(**str)));
873  for (c = *str; ; ++c) {
874  if (!*c || isspace((unsigned char)(*c))) {
875  size_t len = (size_t)(c - *str);
876  assert(len);
877  if (!(path = strndup(*str, len)))
878  return 0;
879  while (*c && isspace((unsigned char)(*c)))
880  ++c;
881  break;
882  }
883  }
884  if ((args = strchr(path, '?')) != 0)
885  *args++ = '\0';
886  info = SERV_CreateHttpInfoEx(type, 0, 0, path, args, add);
887  if (info)
888  *str = c;
889  free(path);
890  return info;
891 }
892 
893 
894 static SSERV_Info* s_HttpGet_Read(const char** str, size_t add)
895 {
896  return s_HttpAny_Read(fSERV_HttpGet, str, add);
897 }
898 
899 
900 static SSERV_Info* s_HttpPost_Read(const char** str, size_t add)
901 {
902  return s_HttpAny_Read(fSERV_HttpPost, str, add);
903 }
904 
905 
906 static SSERV_Info* s_Http_Read(const char** str, size_t add)
907 {
908  return s_HttpAny_Read(fSERV_Http, str, add);
909 }
910 
911 
912 static size_t s_Http_SizeOf(const USERV_Info* u)
913 {
914  const char* path = SERV_HTTP_PATH(&u->http);
915  const char* args = SERV_HTTP_ARGS(&u->http);
916  return sizeof(u->http) + (size_t)((args + strlen(args) + 1) - path);
917 }
918 
919 
920 static int/*bool*/ s_Http_Equal(const USERV_Info* u1, const USERV_Info* u2)
921 {
922  return
923  strcmp(SERV_HTTP_PATH(&u1->http), SERV_HTTP_PATH(&u2->http)) == 0 &&
924  strcmp(SERV_HTTP_ARGS(&u1->http), SERV_HTTP_ARGS(&u2->http)) == 0;
925 }
926 
927 
929  unsigned int host,
930  unsigned short port,
931  const char* path,
932  const char* args,
933  size_t add)
934 {
935  size_t path_len, args_len;
936  SSERV_Info* info;
937 
938  if (type & (unsigned int)(~fSERV_Http))
939  return 0;
940  if (!path || !*path)
941  return 0;
942  else
943  path_len = strlen(path) + 1;
944 #if 1 /* NB: have to use this for ABI compatibility */
945  args_len = args && *args ? strlen(args) + 1 : 1;
946 #else
947  if (!args || !*args)
948  path_len--, args_len = 1;
949  else
950  args_len = strlen(args) + 1;
951 #endif
952  add += path_len + args_len;
953  if ((info = (SSERV_Info*) malloc(sizeof(SSERV_Info) + add)) != 0) {
954  info->type = type;
955  info->host = host;
956  info->port = port;
957  info->mode = 0;
958  info->site = fSERV_Local;
959  info->time = 0;
960  info->coef = 0.0;
961  info->rate = 0.0;
962  info->mime_t = eMIME_T_Undefined;
963  info->mime_s = eMIME_Undefined;
964  info->mime_e = eENCOD_None;
965  info->algo = SERV_DEFAULT_ALGO;
966  info->vhost = 0;
967  info->extra = 0;
968  memset(&info->addr, 0, sizeof(info->addr));
969  info->u.http.path = (TNCBI_Size) sizeof(info->u.http);
970  info->u.http.args = (TNCBI_Size)(info->u.http.path + path_len);
971  memcpy(SERV_HTTP_PATH(&info->u.http), path ? path : "", path_len);
972  memcpy(SERV_HTTP_ARGS(&info->u.http), args ? args : "", args_len);
973  }
974  return info;
975 }
976 
977 
979  unsigned int host,
980  unsigned short port,
981  const char* path,
982  const char* args)
983 {
984  return SERV_CreateHttpInfoEx(type, host, port, path, args, 0);
985 }
986 
987 
988 /*****************************************************************************
989  * FIREWALL:: constructor and virtual functions
990  */
991 
992 static char* s_Firewall_Write(size_t reserve, const USERV_Info* u)
993 {
994  const char* name = SERV_TypeStr(u->firewall.type);
995  size_t namelen = strlen(name);
996  char* str = (char*) malloc(reserve + (namelen ? namelen + 1 : 0));
997 
998  if (str)
999  strcpy(str + reserve, name);
1000  return str;
1001 }
1002 
1003 
1004 static SSERV_Info* s_Firewall_Read(const char** str, size_t add)
1005 {
1006  ESERV_Type type;
1007  const char* s;
1008  if (!(s = SERV_ReadType(*str, &type)))
1009  type = (ESERV_Type) 0/*fSERV_Any*/;
1010  else
1011  *str = s;
1012  return SERV_CreateFirewallInfoEx(0, 0, type, add);
1013 }
1014 
1015 
1016 static size_t s_Firewall_SizeOf(const USERV_Info* u)
1017 {
1018  return sizeof(u->firewall);
1019 }
1020 
1021 
1022 static int/*bool*/ s_Firewall_Equal(const USERV_Info* u1, const USERV_Info* u2)
1023 {
1024  return u1->firewall.type == u2->firewall.type;
1025 }
1026 
1027 
1029  unsigned short port,
1030  ESERV_Type type,
1031  size_t add)
1032 {
1033  SSERV_Info* info = (SSERV_Info*) malloc(sizeof(SSERV_Info) + add);
1034 
1035  if (info) {
1036  info->type = fSERV_Firewall;
1037  info->host = host;
1038  info->port = port;
1039  info->mode = 0;
1040  info->site = fSERV_Local;
1041  info->time = 0;
1042  info->coef = 0.0;
1043  info->rate = 0.0;
1044  info->mime_t = eMIME_T_Undefined;
1045  info->mime_s = eMIME_Undefined;
1046  info->mime_e = eENCOD_None;
1047  info->algo = SERV_DEFAULT_ALGO;
1048  info->vhost = 0;
1049  info->extra = 0;
1050  memset(&info->addr, 0, sizeof(info->addr));
1051  info->u.firewall.type = type;
1052  }
1053  return info;
1054 }
1055 
1056 
1058  unsigned short port,
1059  ESERV_Type type)
1060 {
1061  return SERV_CreateFirewallInfoEx(host, port, type, 0);
1062 }
1063 
1064 
1065 /*****************************************************************************
1066  * DNS:: constructor and virtual functions
1067  */
1068 
1069 /*ARGSUSED*/
1070 static char* s_Dns_Write(size_t reserve, const USERV_Info* u)
1071 {
1072  char* str = (char*) malloc(reserve + 1);
1073 
1074  if (str)
1075  str[reserve] = '\0';
1076  return str;
1077 }
1078 
1079 
1080 /*ARGSUSED*/
1081 static SSERV_Info* s_Dns_Read(const char** str, size_t add)
1082 {
1083  return SERV_CreateDnsInfoEx(0, add);
1084 }
1085 
1086 
1087 static size_t s_Dns_SizeOf(const USERV_Info* u)
1088 {
1089  return sizeof(u->dns);
1090 }
1091 
1092 
1094  size_t add)
1095 {
1096  SSERV_Info* info = (SSERV_Info*) malloc(sizeof(SSERV_Info) + add);
1097 
1098  if (info) {
1099  info->type = fSERV_Dns;
1100  info->host = host;
1101  info->port = 0;
1102  info->mode = 0;
1103  info->site = fSERV_Local;
1104  info->time = 0;
1105  info->coef = 0.0;
1106  info->rate = 0.0;
1107  info->mime_t = eMIME_T_Undefined;
1108  info->mime_s = eMIME_Undefined;
1109  info->mime_e = eENCOD_None;
1110  info->algo = SERV_DEFAULT_ALGO;
1111  info->vhost = 0;
1112  info->extra = 0;
1113  memset(&info->addr, 0, sizeof(info->addr));
1114  memset(&info->u.dns, 0, sizeof(info->u.dns));
1115  }
1116  return info;
1117 }
1118 
1119 
1120 SSERV_Info* SERV_CreateDnsInfo(unsigned int host)
1121 {
1122  return SERV_CreateDnsInfoEx(host, 0);
1123 }
1124 
1125 
1126 /*****************************************************************************
1127  * Attributes for the different server types:: Implementation
1128  */
1129 
1130 static const char kNCBID [] = "NCBID";
1131 static const char kSTANDALONE[] = "STANDALONE";
1132 static const char kHTTP_GET [] = "HTTP_GET";
1133 static const char kHTTP_POST [] = "HTTP_POST";
1134 static const char kHTTP [] = "HTTP";
1135 static const char kFIREWALL [] = "FIREWALL";
1136 static const char kDNS [] = "DNS";
1137 
1138 
1139 static const SSERV_Attr kSERV_Attr[] = {
1140  { fSERV_Ncbid,
1141  kNCBID, sizeof(kNCBID) - 1,
1144 
1145  { fSERV_Standalone,
1146  kSTANDALONE, sizeof(kSTANDALONE) - 1,
1148  0, s_Standalone_SizeOf} },
1149 
1150  { fSERV_HttpGet,
1151  kHTTP_GET, sizeof(kHTTP_GET) - 1,
1154 
1155  { fSERV_HttpPost,
1156  kHTTP_POST, sizeof(kHTTP_POST) - 1,
1159 
1160  { fSERV_Http,
1161  kHTTP, sizeof(kHTTP) - 1,
1164 
1165  { fSERV_Firewall,
1166  kFIREWALL, sizeof(kFIREWALL) - 1,
1169 
1170  { fSERV_Dns,
1171  kDNS, sizeof(kDNS) - 1,
1173  0, s_Dns_SizeOf} }
1174 };
1175 
1176 
1178 {
1179  size_t i;
1180  for (i = 0; i < sizeof(kSERV_Attr)/sizeof(kSERV_Attr[0]); ++i) {
1181  if (kSERV_Attr[i].type == type)
1182  return &kSERV_Attr[i];
1183  }
1184  return 0;
1185 }
1186 
1187 
1188 static const SSERV_Attr* s_GetAttrByTag(const char* tag)
1189 {
1190  if (tag) {
1191  size_t i;
1192  for (i = 0; i < sizeof(kSERV_Attr)/sizeof(kSERV_Attr[0]); ++i) {
1193  size_t len = kSERV_Attr[i].len;
1194  if (strncasecmp(tag, kSERV_Attr[i].tag, len) == 0
1195  && (!tag[len] || isspace((unsigned char) tag[len])))
1196  return &kSERV_Attr[i];
1197  }
1198  }
1199  return 0;
1200 }
static int type
Definition: getdata.c:31
static const char * str(char *buf, int n)
Definition: stats.c:84
static char tmp[3200]
Definition: utf8.c:42
#define SERV_MINIMAL_RATE
SSERV_Info * SERV_CreateStandaloneInfo(unsigned int host, unsigned short port)
#define SERV_HTTP_PATH(ui)
ESERV_Type
SSERV_HttpInfo http
#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_DnsInfo dns
unsigned char TSERV_Mode
SSERV_FirewallInfo firewall
SSERV_Info * SERV_ReadInfo(const char *str)
size_t SERV_SizeOfInfo(const SSERV_Info *info)
SSERV_NcbidInfo ncbid
const char * SERV_ReadType(const char *str, ESERV_Type *type)
TNCBI_IPv6Addr addr
#define SERV_MINIMAL_BONUS
#define SERV_MAXIMAL_RATE
unsigned char TSERV_Site
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)
ESERV_Algo
unsigned int host
ESERV_Site
unsigned short port
USERV_Info u
int SERV_EqualInfo(const SSERV_Info *i1, const SSERV_Info *i2)
ESERV_Type type
#define SERV_MAXIMAL_BONUS
#define SERV_NCBID_ARGS(ui)
@ fSERV_Firewall
@ fSERV_Http
@ fSERV_HttpPost
@ fSERV_Standalone
@ fSERV_HttpGet
@ fSERV_Dns
@ fSERV_Ncbid
@ fSERV_Secure
@ fSERV_Stateful
@ eSERV_Blast
@ eSERV_Regular
@ fSERV_Local
@ fSERV_Interzone
@ fSERV_Private
int SOCK_isipEx(const char *host, int fullquad)
Check whether the given string represents a valid IPv4 address.
Definition: ncbi_socket.c:8681
unsigned int SOCK_HostToNetLong(unsigned int value)
See man for the BSDisms, htonl() and htons().
Definition: ncbi_socket.c:8737
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...
Definition: ncbi_socket.c:8946
int SOCK_isip(const char *host)
Equivalent of SOCK_isip(host, 0)
Definition: ncbi_socket.c:8713
unsigned int TNCBI_Time
Definition: ncbi_types.h:145
unsigned int TNCBI_Size
Fixed-size analogs of size_t and time_t (mainly for IPC)
Definition: ncbi_types.h:144
char * MIME_ComposeContentTypeEx(EMIME_Type type, EMIME_SubType subtype, EMIME_Encoding encoding, char *buf, size_t bufsize)
EMIME_Type
EMIME_SubType
#define CONN_CONTENT_TYPE_LEN
EMIME_Encoding
int MIME_ParseContentTypeEx(const char *str, EMIME_Type *type, EMIME_SubType *subtype, EMIME_Encoding *encoding)
@ eMIME_T_Undefined
@ eMIME_Undefined
@ eENCOD_None
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
int i
if(yy_accept[yy_current_state])
yy_size_t n
static MDB_envinfo info
Definition: mdb_load.c:37
const struct ncbi::grid::netcache::search::fields::SIZE size
int strcmp(const char *str1, const char *str2)
Definition: odbc_utils.hpp:160
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",...
#define strncasecmp
#define strcasecmp
#define strndup
Definition: ncbi_ansi_ext.h:89
#define verify(expr)
Definition: ncbi_assert.h:51
#define CONN_PORT_HTTP
Definition: ncbi_connutil.h:95
#define CONN_HOST_LEN
#define CONN_PORT_HTTPS
Definition: ncbi_connutil.h:96
int NcbiIsEmptyIPv6(const TNCBI_IPv6Addr *addr)
Return non-zero if the address is empty (either as IPv6 or IPv4); return zero otherwise.
Definition: ncbi_ipv6.c:80
unsigned int NcbiIPv6ToIPv4(const TNCBI_IPv6Addr *addr, size_t pfxlen)
Extract and return a network byte order IPv4 embedded address from an IPv6 address,...
Definition: ncbi_ipv6.c:101
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...
Definition: ncbi_ipv6.c:490
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...
Definition: ncbi_ipv6.c:89
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...
Definition: ncbi_ipv6.c:142
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...
Definition: ncbi_ipv6.c:679
EIPRangeType t
Definition: ncbi_localip.c:101
#define SizeOf(a)
Definition: ncbi_localnet.c:51
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)
#define fabs(v)
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)
ESERV_Site site
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)
const char * tag
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)
size_t len
#define SERV_VHOSTABLE
static const char kDNS[]
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[]
#define MAX_IP_ADDR_LEN
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)
ESERV_Algo algo
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)
Definition: ncbi_socket.c:8838
int isspace(Uchar c)
Definition: ncbictype.hpp:69
int toupper(Uchar c)
Definition: ncbictype.hpp:73
int ispunct(Uchar c)
Definition: ncbictype.hpp:68
#define memmove(a, b, c)
#define assert(x)
Definition: srv_diag.hpp:58
SSERV_Ops ops
const char * tag
ESERV_Type type
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)
Definition: type.c:6
void free(voidpf ptr)
voidp malloc(uInt size)
Modified on Fri Sep 20 14:58:05 2024 by modify_doxy.py rev. 669887