A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/ncbi__connutil_8c_source.html below:

NCBI C++ ToolKit: src/connect/ncbi_connutil.c Source File

43 #define NCBI_USE_ERRCODE_X Connect_Util 46 #define CONN_NET_INFO_MAGIC 0x600DCAFE 48 #define SizeOf(arr) (sizeof(arr) / sizeof((arr)[0])) 63 static char

*

x_getenv

(

const char

* name)

65  char

*

env

= getenv(name);

71 # define x_getenv getenv 84  size_t

dstlen = dst && *dst ? strlen(dst) : 0;

85  size_t

srclen = src && *src ? strlen(src) : 0;

86  if

(dstlen && dst[dstlen - 1] ==

'\n'

) {

87  if

(--dstlen && dst[dstlen - 1] ==

'\r'

)

91  if

(!

isspace

((

unsigned char

)(*src)))

97  if

(!

isspace

((

unsigned char

) src[srclen - 1]))

101  if

(dstlen | srclen) {

104  len

= (dstlen ? dstlen + 2 : 0) + (srclen ? srclen + 2 : 0) + 1;

105  if

(!(temp = (

char

*)(dst ? realloc(dst,

len

) :

malloc

(

len

))))

109  memmove

(dst + srclen + 2, dst, dstlen);

110

memcpy(temp, src, srclen);

112

memcpy(temp,

"\r\n"

, 2 + !dstlen);

117

memcpy(temp,

"\r\n"

, 3);

120  if

(srclen && !pre) {

121

memcpy(temp, src, srclen);

123

memcpy(temp,

"\r\n"

, 3);

131 static const char

*

x_strncpy0

(

char

* dst,

const char

* src,

size_t

dst_size)

133  size_t

src_len = strlen(src);

134  const char

* retval = dst;

136  if

(src_len >= dst_size) {

137

src_len = dst_size - 1;

149  const char

* end =

str

+

len

;

150  while

(

str

!= end) {

151  unsigned char

c = (

unsigned

char)(*

str

);

164 typedef int

(*

FStrNCmp

)(

const char

* s1,

const char

* s2,

size_t n

);

182 static const char

*

x_GetValue

(

const char

* svc

,

size_t

svclen,

183  const char

* param,

char

*

value

,

184  size_t

value_size,

const char

* def_value,

185  int

*

generic

,

FStrNCmp

strncompar)

187  const char

*

val

, *rv;

192  assert

(!svclen || (svclen == strlen(svc)));

197

parlen = strlen(param) + 1;

200  size_t len

= svclen + 1 + parlen;

201  char tmp

[

sizeof

(

buf

)];

210  if

(

len

>

sizeof

(

buf

))

214

s = (

char

*) memcpy(

buf

, svc, svclen) + svclen;

216

memcpy(

tmp

,

buf

, svclen);

227

memcpy(s, param, parlen);

232

|| (memcmp(

buf

,

tmp

, svclen) != 0

243

memcpy(

buf

, svc, svclen);

244  buf

[svclen++] =

'\0'

;

261

}

else if

(strncompar !=

strncmp

) {

262  if

(parlen >

sizeof

(

buf

))

268

memcpy(s, param, parlen);

297  while

(*ptr &&

isspace

((

unsigned char

)(*ptr)))

304  if

(

len

> 1 && (*ptr ==

'"'

|| *ptr ==

'\''

) && ptr[

len

- 1] == *ptr)

312 static const char

*

s_GetValue

(

const char

* svc,

size_t

svclen,

313  const char

* param,

char

*

value

,

314  size_t

value_size,

const char

* def_value,

315  int

*

generic

,

FStrNCmp

strncompar)

318

value_size, def_value,

generic

,strncompar);

326  CORE_TRACEF

((

"ConnNetInfo(%s%.*s%s%s=\"%s\"): %s%s%s"

, &

"\""

[!svclen],

327

(

int

) svclen, svc, svclen ?

"\", "

:

""

, param,

value

,

328

&

"\""

[!retval], retval ? retval :

"NULL"

,

336  char

*

value

,

size_t

value_size,

337  const char

* def_value)

339  int

service_only = 0

;

341

&& !strpbrk(service,

"?*["

)));

345  return s_GetValue

(service, service && *service ? strlen(service) : 0,

346

param,

value

, value_size, def_value,

353  char

*

value

,

size_t

value_size,

354  const char

* def_value)

357  int

service_only = 1

;

359

&& !strpbrk(service,

"?*["

));

363

retval =

s_GetValue

(service, strlen(service),

364

param,

value

, value_size, def_value,

372  char

*

value

,

size_t

value_size,

373  const char

* def_value)

379  if

(!

value

|| !value_size)

386  if

(!*service || strpbrk(service,

"?*["

))

391  verify

((svclen = strlen(service)) != 0);

397

param,

value

, value_size, def_value,

400  free

((

void

*) service);

417  if

(c ==

'Y'

|| c ==

'T'

)

419  if

(c ==

'N'

|| c ==

'F'

)

445 #if defined(_DEBUG) && !defined(NDEBUG) 447

(

"Unrecognized boolean value %s%s%s treated as FALSE"

,

448

&

"\""

[!

str

],

str

?

str

:

"NULL"

, &

"\""

[!

str

]));

494  if

(sscanf(ptr,

"%hu%n"

, &port, &

n

) < 1 || port < 2)

499  if

(!*(ptr += strspn(ptr,

" \t"

)))

552  if

(*

val

==

'"'

|| *

val

==

'\''

) {

555  size_t len

= strlen(

val

);

559

((

char

*)

val

)[

len

] =

'\0'

;

566

x_info->

user

[0] =

'\0'

;

567

x_info->

pass

[0] =

'\0'

;

568

x_info->

host

[0] =

'\0'

;

570

x_info->

path

[0] =

'\0'

;

575

&& (!x_info->

host

[0] || !x_info->

port 576

|| (x_info->

path

[0]

577

&& (x_info->

path

[0] !=

'/'

|| x_info->

path

[1])))) {

583  if

(!

info

->http_proxy_mask) {

585  info

->http_proxy_port = x_info->

port

;

586

strcpy(

info

->http_proxy_host, x_info->

host

);

587

strcpy(

info

->http_proxy_user, x_info->

user

);

588

strcpy(

info

->http_proxy_pass, x_info->

pass

);

589

}

else if

(

info

->http_proxy_port != x_info->

port

||

594

(

"ConnNetInfo($%s): Non-identical proxy setting" 595  " \"%s\" compared to %s"

,

env

,

val

,

600  info

->http_proxy_mask |= proxy;

612

(

"ConnNetInfo($%s): %s \"%s\""

,

env

, parsed

613

?

"Unable to utilize secure HTTPS proxy" 614

:

"Unrecognized HTTP proxy specification"

,

val

));

626  static volatile int

s_ProxySet = 0

;

628  static char

s_ProxyHost[

sizeof

(

info

->http_proxy_host)] = { 0 };

629  static unsigned short

s_ProxyPort = 0;

630  static char

s_ProxyUser[

sizeof

(

info

->http_proxy_user)] = { 0 };

631  static char

s_ProxyPass[

sizeof

(

info

->http_proxy_pass)] = { 0 };

637

s_ProxyPass[0] =

'\0'

;

638

s_ProxyUser[0] =

'\0'

;

640

s_ProxyHost[0] =

'\0'

;

648

!

info

->http_proxy_port &&

649

!

info

->http_proxy_host[0]);

650  if

(

info

->http_proxy_skip)

656

rv = !

info

->http_proxy_leak ? 0

: -1

;

657  else if

(!s_ProxyMask)

661  info

->http_proxy_mask = s_ProxyMask;

662  info

->http_proxy_port = s_ProxyPort;

663

strcpy(

info

->http_proxy_host, s_ProxyHost);

664

strcpy(

info

->http_proxy_user, s_ProxyUser);

665

strcpy(

info

->http_proxy_pass, s_ProxyPass);

673  assert

(!(rv <= 0) ^ !

info

->http_proxy_mask);

686

strcpy(s_ProxyPass,

info

->http_proxy_pass);

687

strcpy(s_ProxyUser,

info

->http_proxy_user);

688

strcpy(s_ProxyHost,

info

->http_proxy_host);

689

s_ProxyPort =

info

->http_proxy_port;

690

s_ProxyMask =

info

->http_proxy_mask;

699  return

rv || !

info

->http_proxy_leak ? rv : -1

;

708  assert

(!referer || *referer);

727  if

(

info

->http_user_header) {

728  free

((

void

*)

info

->http_user_header);

729  info

->http_user_header = 0;

731  if

(

info

->http_referer) {

732  free

((

void

*)

info

->http_referer);

733  info

->http_referer = 0;

759 #define REG_VALUE(name, value, def_value) \ 762  if (!s_GetValue(service, len, \ 763  name, value, sizeof(value), def_value, \ 764  &generic, strncmp)) \ 775  len

= service && *service ? strlen(service) : 0;

777

&& !strpbrk(service,

"?*["

)));

784  info

->reserved = 0

;

785  info

->http_referer = 0;

786  info

->http_user_header = 0;

789

memcpy((

char

*)

info

->svc, service ? service :

""

,

len

+ 1);

792  info

->client_host[0] =

'\0'

;

826  info

->http_version = *

str

&& atoi(

str

) == 1 ? 1 : 0;

867

(

"[ConnNetInfo_Create%s%s%s] Invalid host specification" 868  " \"%s\""

, *

info

->svc ?

"(\""

:

""

,

876  if

(*

str

&& (

val

= (

long

) strtoul(

str

, &e, 10)) > 0

877

&& !errno && !*e &&

val

< (1 << 16)) {

878  info

->port = (

unsigned

short)

val

;

886  info

->http_proxy_host[0] =

'\0'

;

887  info

->http_proxy_port = 0;

888  info

->http_proxy_user[0] =

'\0'

;

889  info

->http_proxy_pass[0] =

'\0'

;

903  info

->tmo.sec = (

unsigned int

) dbl;

904  info

->tmo.usec = (

unsigned int

)((dbl -

info

->tmo.sec) * 1.0e6);

905  if

(dbl && !(

info

->tmo.sec |

info

->tmo.usec))

906  info

->tmo.usec = 1

;

921  info

->credentials = 0;

937

!

info

->http_proxy_port &&

938

!

info

->http_proxy_host[0]);

944

strlen(

info

->http_proxy_host))){

946

(

"[ConnNetInfo_Create%s%s%s] Invalid HTTP proxy" 947  " host specification \"%s\""

,

948

*

info

->svc ?

"(\""

:

""

,

info

->svc,

949

*

info

->svc ?

"\")"

:

""

,

info

->http_proxy_host));

950  if

(!

info

->http_proxy_leak)

952  info

->http_proxy_host[0] =

'\0'

;

954  if

(

info

->http_proxy_host[0]) {

957  if

(*

str

&& (

val

= (

long

) strtoul(

str

, &e, 10)) > 0

958

&& !errno && !*e &&

val

< (1 << 16)) {

959  info

->http_proxy_port = (

unsigned

short)

val

;

961  info

->http_proxy_port = 0

;

988  const char

* x_service;

991  if

(service && *service && !strpbrk(service,

"?*["

)) {

1001  free

((

void

*) x_service);

1007  const char

* user_header)

1012  if

(

info

->http_user_header) {

1013  free

((

void

*)

info

->http_user_header);

1014  info

->http_user_header = 0;

1016  return x_StrcatCRLF

((

char

**) &

info

->http_user_header, user_header, 0);

1021  const char

* user_header)

1025  return x_StrcatCRLF

((

char

**) &

info

->http_user_header, user_header, 0);

1030  const char

* user_header)

1034  return x_StrcatCRLF

((

char

**) &

info

->http_user_header, user_header, 1);

1039  const char

* newval,

size_t

newvallen)

1042  while

(oldvallen > 0) {

1044  if

(!

isspace

((

unsigned char

)(*oldval)))

1047

}

while

(--oldvallen > 0);

1048  if

(oldvallen < newvallen)

1051

&& (oldvallen == newvallen

1052

||

isspace

((

unsigned char

) oldval[newvallen]))) {

1057  if

(

isspace

((

unsigned char

)(*oldval)))

1060

}

while

(--oldvallen > 0);

1075  const char

* user_header,

1089  if

(!user_header || !(newhdrlen = strlen(user_header)))

1092  if

(!(hdr = (

char

*)

info

->http_user_header) || !(hdrlen = strlen(hdr))) {

1095  if

(!hdr && !(hdr =

strdup

(

""

)))

1103  if

(!(newhdr = (

char

*)

malloc

(newhdrlen + 1))) {

1107

memcpy(newhdr, user_header, newhdrlen + 1);

1110  for

(newline = newhdr; *newline; newline += newlinelen) {

1111  char

* eol = strchr(newline,

'\n'

);

1112  char

* eot = strchr(newline,

':'

);

1121

newlinelen = (size_t)

1122

(eol ? eol - newline + 1 : newhdr + newhdrlen - newline);

1123  if

(!eot || eot >= newline + newlinelen) {

1128  if

(eot > newline && eot[-1] ==

'\r'

)

1131

eot = newhdr + newhdrlen;

1133  if

(!(newtaglen = (

size_t

)(eot - newline)))

1137

newtagval = newline + newtaglen;

1139  assert

(*newtagval ==

':'

);

1140  while

(++newtagval < newline + newlinelen) {

1141  if

(!

isspace

((

unsigned char

)(*newtagval)))

1147

newlen = newtagval < newline + newlinelen ? newlinelen : 0;

1151  if

(!(newlen = newlinelen - (

size_t

)(newtagval - newline)))

1159  if

(newlen && eol) {

1160  if

(eol[-1] ==

'\r'

)

1169  for

(line = hdr; *line; line += linelen) {

1174

eol = strchr(line,

'\n'

);

1175

eot = strchr(line,

':'

);

1177

linelen = (size_t)(eol ? eol - line + 1 : hdr + hdrlen - line);

1178  if

(!eot || eot >= line + linelen)

1181

taglen = (size_t)(eot - line);

1182  if

(newtaglen != taglen ||

strncasecmp

(newline, line, taglen) != 0)

1184  assert

(0 < taglen && taglen <= linelen);

1188

off = !eol ? 0 : eol[-1] !=

'\r'

? 1 : 2;

1190  assert

(line[taglen] ==

':'

);

1193

newtagval, newlen)) {

1196

line += linelen - off;

1201  len

= linelen - off;

1205

off = (size_t)(line - hdr);

1206  if

(

len

< newlen) {

1209  if

(!(temp = (

char

*) realloc(hdr, hdrlen +

len

+ 1))) {

1215  memmove

(line +

len

, line, hdrlen - off + 1);

1219

memcpy(line + 1, newtagval, newlen - 1);

1224

}

else if

(

len

> newlen) {

1227  memmove

(line + newlen, line +

len

, hdrlen - off + 1);

1232

memcpy(line, newline, newlen);

1238  memmove

(line, line + linelen, hdrlen - off + 1);

1246

off = (size_t)(newline - newhdr);

1247

newhdrlen -= newlinelen;

1248  memmove

(newline, newline + newlinelen, newhdrlen - off + 1);

1259  info

->http_user_header = hdr;

1273  const char

* header)

1280  const char

* header)

1287  const char

* header)

1294  const char

* header)

1302  size_t

* hostlen,

long

* port)

1310  if

(*

str

==

'['

) {

1312  if

(!(ptr = (

char

*) memchr(++

str

,

']'

, --

len

)) || ptr ==

str

)

1324

}

else if

(!(ptr = (

char

*) memchr(

str

,

':'

,

len

))) {

1328

*hostlen = (size_t)(ptr -

str

);

1334  if

(*ptr ==

'0'

|| !

isdigit

((

unsigned char

)(*ptr)))

1337

x_port = strtol(ptr, &end, 10);

1338  if

(errno || end !=

str

+

len

)

1340  if

(!x_port || (x_port ^ (x_port & 0xFFFF)))

1350  const char

*user, *pass, *host, *path, *args;

1351  size_t

userlen, passlen, hostlen, pathlen, argslen;

1372

memcpy(

info

->host, host, hostlen);

1373  info

->host[hostlen] =

'\0'

;

1376  info

->port = (

unsigned

short) port;

1381  if

((s = strstr(url,

"//"

)) != 0) {

1386  len

= (size_t)(s++ - url);

1392

hostlen = strcspn(host,

"/?#"

);

1395

path = host + hostlen;

1399

user = pass = host = (scheme ==

eURL_File

?

""

: 0);

1400

userlen = passlen = 0;

1402  if

(!(s = (

const char

*)

memrchr

(host,

'@'

, hostlen))) {

1404

userlen = passlen = 0;

1407

userlen = (size_t)(s - user);

1409

hostlen = (size_t)(path - s);

1412  if

(!(s = (

const char

*) memchr(user,

':'

, userlen))) {

1416

userlen = (size_t)(s++ - user);

1418

passlen = (size_t)(host - s);

1420  if

(userlen >=

sizeof

(

info

->user) ||

1421

passlen >=

sizeof

(

info

->pass)) {

1436

s = (

const char

*) strchr(url,

':'

);

1437  if

(s && s != url &&

1447

&& hostlen && x_port) {

1457

userlen = passlen = 0;

1459  assert

(!hostlen || host);

1460  if

(hostlen && hostlen == strlen(

info

->host)

1466

? strcspn(path,

"?#"

) : strlen(path));

1467

args = path + pathlen;

1469  if

((!pathlen && !*args) || (pathlen && *path ==

'/'

)) {

1480

? strcspn(

info

->path,

"?#"

) : strlen(

info

->path));

1484

}

else if

(!(p = (

char

*)

memrchr

(

info

->path,

'/'

,

len

))) {

1488  len

= (size_t)(++p -

info

->path);

1490  if

(

len

+ pathlen >=

sizeof

(

info

->path))

1497

argslen = strlen(args);

1500  else if

(!(frag = strchr(args + 1

,

'#'

)))

1501

frag = args + argslen;

1502  assert

(!*frag || *frag ==

'#'

);

1508  if

((

size_t

)(p -

info

->path)

1509

+ pathlen + argslen >=

sizeof

(

info

->path)) {

1513

}

else if

((frag = strchr(

info

->path,

'#'

)) != 0) {

1516  if

((

size_t

)(p -

info

->path)

1517

+ pathlen + argslen +

len

>=

sizeof

(

info

->path)) {

1522  if

((

size_t

)(p -

info

->path)

1523

+ pathlen + argslen >=

sizeof

(

info

->path)) {

1528

memcpy(p + pathlen, args, argslen);

1529

p[pathlen + argslen +

len

] =

'\0'

;

1531

&& (args = strchr(

info

->path,

'#'

))) {

1533  memmove

(p + pathlen, args, strlen(args) + 1

);

1537

memcpy(p, path, pathlen);

1539  info

->port = (

unsigned

short)(port < 0 ? 0 : port);

1542

memcpy(

info

->host, host, hostlen);

1543  info

->host[hostlen] =

'\0'

;

1545  if

(user && (*user || host)) {

1547

memcpy(

info

->pass, pass, passlen);

1548  info

->pass[passlen] =

'\0'

;

1549

memcpy(

info

->user, user, userlen);

1550  info

->user[userlen] =

'\0'

;

1552  info

->scheme = scheme;

1561  size_t n

= strcspn(

str

, sep);

1566

sep += (size_t)(strchr(sep,

str

[

n

++]) - sep) + 1;

1570

*

len

= m + strlen(

str

);

1577  size_t

plen, x_alen;

1586  info

->path[0] =

'\0'

;

1592

x_args =

info

->path + strcspn(

info

->path, sep);

1596  info

->path[0] =

'\0'

;

1597  else if

(x_args !=

info

->path)

1598  memmove

(

info

->path, x_args, strlen(x_args) + 1

);

1602

x_alen = strlen(x_args);

1603  if

((frag = (

const char

*) memchr(path,

'#'

, plen)) != 0 && !frag[1])

1605  if

(plen + x_alen >=

sizeof

(

info

->path))

1608  memmove

(

info

->path + plen, x_args, x_alen + 1

);

1609

memcpy(

info

->path, path, plen);

1616  size_t

plen, x_alen;

1624  if

(!path || !*path)

1630

x_args =

info

->path + strcspn(

info

->path, sep);

1631

x_alen = strlen(x_args);

1633  if

(*path ==

'?'

|| *path ==

'#'

) {

1634

x_path = (

char

*) memchr (

info

->path,

1635

*path, (

size_t

)(x_args -

info

->path));

1638  if

(*path ==

'#'

&& !path[1])

1640

}

else if

(*path !=

'/'

) {

1642  '/'

, (

size_t

)(x_args -

info

->path));

1644

x_path =

info

->path;

1648

x_path =

info

->path + strcspn(

info

->path,

"?#"

);

1649  if

(x_path !=

info

->path && x_path[-1] ==

'/'

)

1652  if

((

size_t

)(x_path -

info

->path) + plen + x_alen >=

sizeof

(

info

->path))

1655  memmove

(x_path + plen, x_args, x_alen + 1

);

1656

memcpy(x_path, path, plen);

1663  size_t

alen, x_flen, room;

1670

alen = args ? strlen(args) : 0;

1672

x_args =

info

->path + strcspn(

info

->path,

"?#"

);

1678  if

(*x_args ==

'?'

) {

1679

x_frag = (x_args + 1) + strcspn(x_args + 1,

"#"

);

1683  memmove

(x_args, x_frag, strlen(x_frag) + 1

);

1688  if

(!(frag = (

const char

*) memchr(args,

'#'

, alen))) {

1690

x_frag = x_args + strcspn(x_args,

"#"

);

1691

x_flen = strlen(x_frag);

1698

room = !(*args ==

'#'

) + alen;

1699  if

((

size_t

)(x_args -

info

->path) + room + x_flen >=

sizeof

(

info

->path))

1703  memmove

(x_args + room, x_frag, x_flen + 1

);

1704  if

(!(*args ==

'#'

))

1706

memcpy(x_args, args, alen);

1708

x_args[alen] =

'\0'

;

1727

flen = frag ? strlen(frag += !(*frag !=

'#'

)) : 0;

1729

x_frag =

info

->path + strcspn(

info

->path,

"#"

);

1735  if

((

size_t

)(x_frag -

info

->path) + flen >=

sizeof

(

info

->path))

1739

memcpy(x_frag, frag, flen

);

1751

args =

info

->path + strcspn(

info

->path,

"?#"

);

1762  size_t

alen, vlen, x_alen, x_flen, room;

1763  char

* x_args, *x_frag;

1767  if

(!arg || !(alen = strcspn(arg,

"#"

)))

1769

vlen =

val

? 1

+ strcspn(

val

,

"#"

) : 0;

1771

x_args =

info

->path + strcspn(

info

->path,

"?#"

);

1772

x_alen = strlen(x_args);

1774  if

(*x_args ==

'?'

) {

1775

x_frag = (x_args + 1) + strcspn(x_args + 1,

"#"

);

1776

x_flen = x_alen - (size_t)(x_frag - x_args);

1783

room = (x_alen == 1 ? 0 : x_alen) + 1

+ (alen + vlen);

1784  if

((

size_t

)(x_args -

info

->path) + room + x_flen >=

sizeof

(

info

->path))

1787  assert

(!x_flen || *x_frag ==

'#'

);

1789  memmove

(x_args + room, x_frag, x_flen + 1

);

1791  assert

(*x_args ==

'?'

);

1796

memcpy(x_args, arg, alen);

1800

memcpy(x_args,

val

, vlen);

1821  size_t

alen, vlen, x_alen, room;

1822  char

* x_args, *xx_args;

1826  if

(!arg || !(alen = strcspn(arg,

"#"

)))

1828

vlen =

val

? 1

+ strcspn(

val

,

"#"

) : 0;

1830

x_args =

info

->path + strcspn(

info

->path,

"?#"

);

1831

x_alen = strlen(x_args);

1834  if

(*xx_args ==

'?'

&& (!xx_args[1] || xx_args[1] ==

'#'

)) {

1840

room += alen + vlen;

1841  if

((

size_t

)(x_args -

info

->path) + room + x_alen >=

sizeof

(

info

->path))

1845  if

(*xx_args ==

'?'

)

1847  memmove

(xx_args + room, xx_args, x_alen + 1

);

1850

memcpy(x_args, arg, alen);

1854

memcpy(x_args,

val

, vlen);

1875  size_t

alen, x_alen;

1876  char

* x_args, *x_a;

1880  if

(!arg || !(alen = strcspn(arg,

"=&#"

)))

1884

x_args =

info

->path + strcspn(

info

->path,

"?#"

);

1885  for

(x_a = x_args; *x_a && *x_a !=

'#'

; x_a += x_alen) {

1886  if

(x_a == x_args || *x_a ==

'&'

)

1888

x_alen = strcspn(x_a,

"&#"

);

1889  if

(x_alen < alen ||

strncasecmp

(x_a, arg, alen) != 0 ||

1891

x_a[alen] !=

'='

&& x_a[alen] !=

'&'

&& x_a[alen] !=

'#'

)) {

1894  if

(x_a[x_alen] ==

'&'

)

1898  memmove

(x_a, x_a + x_alen, strlen(x_a + x_alen) + 1

);

1918  while

(*args && *args !=

'#'

) {

1919  size_t

alen = strcspn(args,

"&#"

);

1922  if

(args[alen] ==

'&'

)

1970  return

!strchr(

addr

,

' '

)

1972

|| ((c = strchr(

addr

,

'.'

)) != 0 && c[1] &&

1973

(c = strchr(c + 2,

'.'

)) != 0 && c[1]));

1980  const char

* c = client_host;

1991

|| !(

ip

= (*c && !local_host

1995

|| !(s = (

char

*)

malloc

(strlen(client_host) + strlen(

addr

) + 3))) {

1996  return

client_host

;

1999

sprintf(s,

"%s(%s)"

, client_host,

addr

);

2000  if

(client_host != c)

2001  free

((

void

*) client_host);

2002  for

(client_host = s; *s; ++s) {

2011  const char

* service)

2013  static const char

kService[] =

"service"

;

2014  static const char

kAddress[] =

"address"

;

2015  static const char

kPlatform[] =

"platform"

;

2025

sprintf(ua,

"User-Agent: %.80s"

, s);

2034

local_host = !

info

->client_host[0];

2043  if

(s !=

info

->client_host)

2069

svclen = strlen(

info

->svc);

2087

strcpy(x_info->

user

,

info

->user);

2088

strcpy(x_info->

pass

,

info

->pass);

2089

strcpy(x_info->

host

,

info

->host);

2091

strcpy(x_info->

path

,

info

->path);

2104

memcpy((

char

*) x_info->

svc

,

info

->svc, svclen + 1);

2118  if

(

info

->http_user_header && *

info

->http_user_header

2122  if

(

info

->http_referer && *

info

->http_referer

2136

sprintf(

buf

,

"0x%08lX (INVALID != 0x%08lX)"

,

2142 static const char

*

x_Num

(

unsigned int

num,

char buf

[])

2144

sprintf(

buf

,

"(#%u)"

, num);

2169 static const char

*

x_Port

(

unsigned short

port,

char buf

[])

2172

sprintf(

buf

,

"%hu"

, port);

2181  switch

(req_method) {

2183  return

v1 ?

"ANY/1.1"

:

"ANY"

;

2185  return

v1 ?

"GET/1.1"

:

"GET"

;

2187  return

v1 ?

"POST/1.1"

:

"POST"

;

2189  return

v1 ?

"HEAD/1.1"

:

"HEAD"

;

2191  return

v1 ?

"CONNECT/1.1"

:

"CONNECT"

;

2211  switch

((

EFWMode

) firewall) {

2228  unsigned int

who, what;

2231

who = cred->

type

/ 100;

2232

what = cred->

type

% 100;

2237  return "(GNUTLS X.509 Cert Cred)"

;

2239

sprintf(

buf

,

"(GNUTLS/%u)"

, what);

2245  return "(MBEDTLS X.509 Cert & PK)"

;

2247

sprintf(

buf

,

"(MBEDTLS/%u)"

, what);

2253

sprintf(

buf

,

"(TLS 0x%08X/%u)"

, cred->

type

, what);

2259  const char

*

str

,

int

quote)

2261

sprintf(s + strlen(s),

"%-16.16s: %s%s%s\n"

, name,

2262  str

&& quote ?

"\""

:

""

,

2264  str

&& quote ?

"\""

:

""

);

2278 static void s_SaveBool

(

char

* s,

const char

* name,

unsigned int

bbb)

2283 static void s_SaveULong

(

char

* s,

const char

* name,

unsigned long

lll)

2285

sprintf(s + strlen(s),

"%-16.16s: %lu\n"

, name, lll);

2289  const char

* uh,

size_t

uhlen)

2292

s += sprintf(s,

"%-16.16s: "

, name);

2297

memcpy(s,

"NULL\n"

, 6);

2310  "ConnNetInfo_Log: NULL"

, 0, 0);

2314

uhlen =

info

->http_user_header ? strlen(

info

->http_user_header) : 0;

2316  len

=

sizeof

(*info) + 1024

2318

+ (

info

->http_referer ? strlen(

info

->http_referer) : 0)

2319

+ strlen(

info

->svc);

2324  "ConnNetInfo_Log: Cannot allocate memory"

);

2328

strcpy(s,

"ConnNetInfo_Log\n" 2329  "#################### [BEGIN] SConnNetInfo:\n"

);

2336  if

(*

info

->client_host)

2342

| (

info

->http_version

2349 #if defined(_DEBUG) && !defined(NDEBUG) 2369 #if defined(_DEBUG) && !defined(NDEBUG) 2373

?

"(set)"

:

"\"\""

));

2375  if

(*

info

->http_proxy_pass) {

2377

?

"(set)"

:

"(ignored)"

));

2384  if

(

info

->timeout) {

2396

:

info

->debug_printout

2399

:

info

->debug_printout

2406  if

(

info

->credentials)

2409  "#################### [_END_] SConnNetInfo"

);

2412  LOG_Write

(

lg

,

NCBI_C_ERRCODE_X

, 12, sev, 0, 0, 0, 0, s, 0, 0);

2420  const char

* scheme;

2434

bare = !memchr(

info

->host,

':'

,

len

);

2442

schlen = strlen(scheme);

2443  len

+= schlen + 4

+ strlen(path);

2445  len

+= (bare ? 0 : 2

) + 7

;

2449  strlwr

((

char

*) memcpy(url, scheme, schlen + 1));

2451  len

+= sprintf(url +

len

,

2452

&

"://%s%s%s"

[schlen ? 0 : path ? 1 : 3],

2453

&

"["

[bare],

info

->host, &

"]"

[bare]);

2454  if

(

info

->port || !path

)

2455  len

+= sprintf(url +

len

,

":%hu"

,

info

->port);

2457  "%s%s"

, &

"/"

[!(path && *path !=

'/'

)], path ? path :

""

);

2470  info

->tmo = *timeout;

2502

(

const char

* host,

2503  unsigned short

port,

2507  size_t

content_length,

2510  const char

* user_hdr,

2515  static const char

kHttp[][12] = {

" HTTP/1.0\r\n"

,

2529  unsigned short

x_port;

2531  size_t

user_hdr_len = user_hdr && *user_hdr ? strlen(user_hdr) : 0;

2535

args_len = strcspn(path,

"?#"

)

;

2543  if

(!sock || !host || !*host || !path_len || args_len < path_len) {

2555  if

(path[path_len]

)

2556

args = &path[path_len] + !(path[path_len] !=

'?'

);

2559  while

(user_hdr_len) {

2560  if

(!

isspace

((

unsigned char

) user_hdr[0]))

2565  while

(user_hdr_len) {

2566  if

(!

isspace

((

unsigned char

) user_hdr[user_hdr_len - 1]))

2572

x_c_l = content_length && content_length != (size_t)(-1L) ? 1 : 0;

2578

sprintf(temp,

":%hu"

, port);

2582

(

"[URL_Connect; http%s://%s%s%s%.*s] " 2583  " Content-Length (%lu) is ignored with request method %s"

,

2585

&

"/"

[path_len && *path ==

'/'

], (

int

) path_len, path,

2586

(

unsigned long

) content_length,

2588

content_length = (size_t)(-1L);

2592

x_c_l = content_length

2601

sprintf(temp,

":%hu"

, port);

2605

(

"[URL_Connect; http%s://%s%s%s%.*s] " 2606  " Unsupported request method %s"

,

2608

&

"/"

[path_len && *path ==

'/'

], (

int

) path_len, path,

2618

args_len = args ? strcspn(args,

"#"

) : 0;

2637

sprintf(temp,

"Content-Length: %lu\r\n"

,

2638

(

unsigned long

) content_length))) ||

2645

!

BUF_Write

(&

buf

,

"\r\n\r\n"

, user_hdr_len ? 4 : 2) ||

2649

&& content_length && content_length != (

size_t

)(-1L)

2651  int

x_errno = errno;

2653

sprintf(temp,

":%hu"

, port);

2657

(

"[URL_Connect; http%s://%s%s%s%.*s%s%.*s] " 2658  " Cannot build HTTP header"

,

2660

&

"/"

[path_len && *path ==

'/'

], (

int

)path_len, path,

2661

&

"?"

[!args_len], (

int

) args_len, args));

2668  int

x_errno = errno;

2670

sprintf(temp,

":%hu"

, port);

2674

(

"[URL_Connect; http%s://%s%s%s%.*s%s%.*s] " 2675  " Cannot maintain HTTP header (%lu byte%s)"

,

2677

&

"/"

[path_len && *path ==

'/'

], (

int

)path_len, path,

2678

&

"?"

[!args_len], (

int

) args_len, args,

2679

(

unsigned long

) hdr_len, &

"s"

[hdr_len == 1]));

2687

memset(&

init

, 0,

sizeof

(

init

));

2689  init

.size = hdr_len;

2713

sprintf(timeout,

"[%u.%06u]"

,

2714

o_timeout->

usec

/ 1000000 + o_timeout->

sec

,

2715

o_timeout->

usec

% 1000000);

2719

sprintf(temp,

":%hu"

, port);

2723

(

"[URL_Connect; http%s://%s%s%s%.*s%s%.*s] " 2724  " Failed to %s: %s%s"

,

2726

&

"/"

[path_len && *path ==

'/'

], (

int

) path_len, path,

2727

&

"?"

[!args_len], (

int

) args_len, args,

2728

s ?

"use connection"

:

"connect"

,

2737

(

const char

* host,

2738  unsigned short

port,

2742  size_t

content_length,

2745  const char

* user_hdr,

2749  static void

*

volatile

s_Once = 0;

2750  static const char kHost

[] =

"Host: "

;

2751  const char

* x_hdr = user_hdr;

2757  " *DEPRECATED*!!! DON'T USE IT!! Update your code please!"

);

2761  "[URL_Connect] Unsupported version of HTTP protocol"

);

2767  while

(x_hdr && *x_hdr) {

2768  if

(x_hdr != user_hdr)

2774

x_hdr = strchr(x_hdr,

'\n'

);

2777  size_t

x_len = host && *host ? strlen(host) : 0;

2778  char

* x_host = x_len ? (

char

*)

malloc

(x_len +

sizeof

(

kHost

)+6) : 0;

2780

memcpy(x_host,

kHost

,

sizeof

(

kHost

) - 1);

2781

memcpy(x_host +

sizeof

(

kHost

) - 1, host, x_len);

2782

x_len +=

sizeof

(

kHost

) - 1;

2784

sprintf(x_host + x_len,

":%hu"

, port);

2786

x_host[x_len] =

'\0'

;

2797  if

(args && encode_args && (x_add = strcspn(args,

"#"

)) > 0) {

2799  size_t size

= 3 * x_add;

2800  size_t

rd_len, wr_len;

2801  if

(!(x_args = (

char

*)

malloc

(

size

+ 1))) {

2803

(

"[URL_Connect] Out of memory (%lu)"

,

2804

(

unsigned long

)(

size

+ 1)));

2805  if

(x_hdr != user_hdr)

2806  free

((

void

*) x_hdr);

2810  assert

(rd_len == x_add);

2812

x_args[wr_len] =

'\0'

;

2819

req_method, content_length,

2820

o_timeout, rw_timeout,

2826  if

(x_hdr != user_hdr)

2827  free

((

void

*) x_hdr);

2849  const void

* pattern,

2850  size_t

pattern_size,

2852  size_t

* n_discarded)

2866  if

(!pattern_size) {

2868

buf_size =

sizeof

(x_buf);

2870

buf_size = pattern ? pattern_size << 1 : pattern_size;

2873  if

(buf_size <=

sizeof

(x_buf) && pattern) {

2874

buf_size =

sizeof

(x_buf);

2876

}

else if

(!(

buf

= (

char

*)

malloc

(buf_size)))

2882  char

* xx_buf =

buf

;

2884

status = io_func(stream, xx_buf, buf_size, &n_read,

eIO_Read

);

2885  assert

(buf_size && n_read <= buf_size);

2892  if

(xx_buf ==

buf

) {

2902

*n_discarded += n_read;

2903  if

(!(buf_size -= n_read)) {

2910

buf_size =

sizeof

(x_buf);

2931  size_t

x_read, n_stored;

2933  assert

(n_read <= pattern_size && n_read < buf_size);

2934

status = io_func(stream,

buf

+ n_read, buf_size - n_read,

2936  assert

(x_read <= buf_size - n_read);

2942

n_stored = n_read + x_read;

2944  if

(n_stored > pattern_size) {

2947  const char

*

b

=

buf

;

2948  for

(n_check = n_stored - pattern_size; n_check; --n_check) {

2949  if

(*

b

++ != *((

const char

*)pattern))

2953  if

(memcmp(

b

, (

const char

*)pattern + 1, pattern_size) == 0)

2958  size_t

x_discarded = (size_t)(

b

-

buf

) + pattern_size;

2960

x_discarded - n_read)) {

2964

*n_discarded += x_discarded - n_read;

2966

status = io_func(stream,

buf

+ x_discarded,

2976

*n_discarded += x_read;

2977  if

(discard && !

BUF_Write

(discard,

buf

+ n_read, x_read)) {

2985  if

(n_stored > pattern_size) {

2986

n_read = pattern_size;

2994  if

(

buf

&&

buf

!= x_buf)

3021  const void

* pattern,

3022  size_t

pattern_size,

3024  size_t

* n_discarded)

3027

(

conn

,

s_CONN_IO

, pattern, pattern_size, discard, n_discarded);

3052  const void

* pattern,

3053  size_t

pattern_size,

3055  size_t

* n_discarded)

3058

(sock,

s_SOCK_IO

, pattern, pattern_size, discard, n_discarded);

3087  const void

* pattern,

3088  size_t

pattern_size,

3090  size_t

* n_discarded)

3093

(

buffer

,

s_BUF_IO

, pattern, pattern_size, discard, n_discarded);

3108  unsigned int

rc = (

unsigned int

)(ch -

'0'

);

3111

rc = (

unsigned int

)((ch |

' '

) -

'a'

);

3112  return

rc <= 5 ? (

int

)(rc + 10) : -1;

3119  "%00"

,

"%01"

,

"%02"

,

"%03"

,

"%04"

,

"%05"

,

"%06"

,

"%07"

,

3120  "%08"

,

"%09"

,

"%0A"

,

"%0B"

,

"%0C"

,

"%0D"

,

"%0E"

,

"%0F"

,

3121  "%10"

,

"%11"

,

"%12"

,

"%13"

,

"%14"

,

"%15"

,

"%16"

,

"%17"

,

3122  "%18"

,

"%19"

,

"%1A"

,

"%1B"

,

"%1C"

,

"%1D"

,

"%1E"

,

"%1F"

,

3123  "+"

,

"!"

,

"%22"

,

"%23"

,

"$"

,

"%25"

,

"%26"

,

"'"

,

3124  "("

,

")"

,

"*"

,

"%2B"

,

","

,

"-"

,

"."

,

"%2F"

,

3125  "0"

,

"1"

,

"2"

,

"3"

,

"4"

,

"5"

,

"6"

,

"7"

,

3126  "8"

,

"9"

,

"%3A"

,

"%3B"

,

"%3C"

,

"%3D"

,

"%3E"

,

"%3F"

,

3127  "%40"

,

"A"

,

"B"

,

"C"

,

"D"

,

"E"

,

"F"

,

"G"

,

3128  "H"

,

"I"

,

"J"

,

"K"

,

"L"

,

"M"

,

"N"

,

"O"

,

3129  "P"

,

"Q"

,

"R"

,

"S"

,

"T"

,

"U"

,

"V"

,

"W"

,

3130  "X"

,

"Y"

,

"Z"

,

"%5B"

,

"%5C"

,

"%5D"

,

"%5E"

,

"_"

,

3131  "%60"

,

"a"

,

"b"

,

"c"

,

"d"

,

"e"

,

"f"

,

"g"

,

3132  "h"

,

"i"

,

"j"

,

"k"

,

"l"

,

"m"

,

"n"

,

"o"

,

3133  "p"

,

"q"

,

"r"

,

"s"

,

"t"

,

"u"

,

"v"

,

"w"

,

3134  "x"

,

"y"

,

"z"

,

"%7B"

,

"%7C"

,

"%7D"

,

"%7E"

,

"%7F"

,

3135  "%80"

,

"%81"

,

"%82"

,

"%83"

,

"%84"

,

"%85"

,

"%86"

,

"%87"

,

3136  "%88"

,

"%89"

,

"%8A"

,

"%8B"

,

"%8C"

,

"%8D"

,

"%8E"

,

"%8F"

,

3137  "%90"

,

"%91"

,

"%92"

,

"%93"

,

"%94"

,

"%95"

,

"%96"

,

"%97"

,

3138  "%98"

,

"%99"

,

"%9A"

,

"%9B"

,

"%9C"

,

"%9D"

,

"%9E"

,

"%9F"

,

3139  "%A0"

,

"%A1"

,

"%A2"

,

"%A3"

,

"%A4"

,

"%A5"

,

"%A6"

,

"%A7"

,

3140  "%A8"

,

"%A9"

,

"%AA"

,

"%AB"

,

"%AC"

,

"%AD"

,

"%AE"

,

"%AF"

,

3141  "%B0"

,

"%B1"

,

"%B2"

,

"%B3"

,

"%B4"

,

"%B5"

,

"%B6"

,

"%B7"

,

3142  "%B8"

,

"%B9"

,

"%BA"

,

"%BB"

,

"%BC"

,

"%BD"

,

"%BE"

,

"%BF"

,

3143  "%C0"

,

"%C1"

,

"%C2"

,

"%C3"

,

"%C4"

,

"%C5"

,

"%C6"

,

"%C7"

,

3144  "%C8"

,

"%C9"

,

"%CA"

,

"%CB"

,

"%CC"

,

"%CD"

,

"%CE"

,

"%CF"

,

3145  "%D0"

,

"%D1"

,

"%D2"

,

"%D3"

,

"%D4"

,

"%D5"

,

"%D6"

,

"%D7"

,

3146  "%D8"

,

"%D9"

,

"%DA"

,

"%DB"

,

"%DC"

,

"%DD"

,

"%DE"

,

"%DF"

,

3147  "%E0"

,

"%E1"

,

"%E2"

,

"%E3"

,

"%E4"

,

"%E5"

,

"%E6"

,

"%E7"

,

3148  "%E8"

,

"%E9"

,

"%EA"

,

"%EB"

,

"%EC"

,

"%ED"

,

"%EE"

,

"%EF"

,

3149  "%F0"

,

"%F1"

,

"%F2"

,

"%F3"

,

"%F4"

,

"%F5"

,

"%F6"

,

"%F7"

,

3150  "%F8"

,

"%F9"

,

"%FA"

,

"%FB"

,

"%FC"

,

"%FD"

,

"%FE"

,

"%FF" 3153 #define VALID_URL_SYMBOL(ch) (s_EncodeTable[(unsigned char)ch][0] != '%') 3157

(

const void

* src_buf,

3162  size_t

* dst_written,

3163  const char

* allow_symbols)

3165  const char

* src = (

char

*

const

) src_buf;

3166  char

* dst = (

char

*) dst_buf;

3170  if

(!src_size || !dst_size)

3175  for

( ; *src_read != src_size && *dst_written != dst_size;

3176

++(*src_read), ++(*dst_written), ++src, ++dst) {

3182  if

(*src_read + 2 < src_size) {

3186

*dst = (char)((i1 << 4) + i2);

3191

}

else if

(src != src_buf) {

3195  if

(!allow_symbols || *allow_symbols)

3196  return

*dst_written ? 1

: 0

;

3200

|| (allow_symbols && (!*allow_symbols

3201

|| strchr(allow_symbols, *src)))) {

3204  return

*dst_written ? 1

: 0

;

3208  assert

(src == (

const char

*) src_buf + *src_read );

3209  assert

(dst == (

char

*) dst_buf + *dst_written);

3210  assert

(*src_read && *dst_written);

3216

(

const void

* src_buf,

3221  size_t

* dst_written)

3224

(src_buf, src_size, src_read, dst_buf, dst_size, dst_written, 0);

3229

(

const void

* src_buf,

3234  size_t

* dst_written,

3235  const char

* allow_symbols)

3237  const char

* src = (

const char

*) src_buf;

3238  char

* dst = (

char

*) dst_buf;

3242  if

(!src_size || !dst_size || !dst || !src)

3245  for

( ; *src_read != src_size && *dst_written != dst_size;

3246

++(*src_read), ++(*dst_written), ++src, ++dst) {

3247  const char

* subst = allow_symbols ? strchr(allow_symbols, *src) : 0;

3253  if

(*subst !=

'%'

) {

3255

}

else if

(*dst_written < dst_size - 2) {

3257

*(++dst) = *(++subst);

3258

*(++dst) = *(++subst);

3263  assert

(src == (

const char

*) src_buf + *src_read );

3264  assert

(dst == (

char

*) dst_buf + *dst_written);

3269

(

const void

* src_buf,

3274  size_t

* dst_written)

3277

(src_buf, src_size, src_read, dst_buf, dst_size, dst_written, 0);

3323  const char

* x_type, *x_subtype, *x_encoding;

3345  if

( *x_encoding ) {

3347

+ strlen(x_encoding) + 4 <

sizeof

(x_buf));

3348

sprintf(x_buf,

"%s%s/%s-%s\r\n"

,

3352

+ 3 <

sizeof

(x_buf));

3353

sprintf(x_buf,

"%s%s/%s\r\n"

,

kContentType

, x_type, x_subtype);

3355  len

= strlen(x_buf);

3368

(

const char

*

str

,

3392

x_type = x_buf +

x_size

;

3396  if

((sscanf(x_buf,

" content-type: %s "

, x_type) != 1 &&

3397

sscanf(x_buf,

" %s "

, x_type) != 1)

3398

|| !(x_subtype = strchr(x_type,

'/'

))) {

3402

*x_subtype++ =

'\0'

;

3403  x_size

= strlen(x_subtype);

3416  char

* x_encoding = x_subtype +

x_size

-

len

;

3417  if

(x_encoding[-1] ==

'-' 3423

x_encoding[-1] =

'\0'

;

3454

m = port % (

sizeof

(

s_FWPorts

[0]) << 3);

3469

m = port % (

sizeof

(

s_FWPorts

[0]) << 3);

3489

memcpy(

buf

,

"0"

, 2);

3499  for

(p = (

unsigned short

)(m + 1);

mask

; ++p,

mask

>>= 1) {

3502  size_t

k = (size_t) sprintf(port, &

" %hu"

[!

len

], p);

3504

memcpy(

buf

+

len

, port, k);

3509

m = (

unsigned

short)(m + (

sizeof

(

s_FWPorts

[0]) << 3));

ncbi::TMaskedQueryRegions mask

static const char * kContentType

std::ofstream out("events_result.xml")

main entry point for tests

static CS_CONNECTION * conn

static void DLIST_NAME() init(DLIST_LIST_TYPE *list)

static const char * str(char *buf, int n)

int BUF_Write(BUF *pBuf, const void *data, size_t size)

struct SNcbiBuf * BUF

handle of a buffer

int BUF_Pushback(BUF *pBuf, const void *data, size_t size)

int BUF_AppendEx(BUF *pBuf, void *base, size_t alloc_size, void *data, size_t size)

size_t BUF_Read(BUF buf, void *data, size_t size)

void BUF_Destroy(BUF buf)

EIO_Status CONN_Read(CONN conn, void *buf, size_t size, size_t *n_read, EIO_ReadMethod how)

const STimeout g_NcbiDefConnTimeout

DEF_CONN_TIMEOUT as STimeout.

EIO_Status CONN_Pushback(CONN conn, const void *data, size_t size)

Push "size" bytes from the buffer "data" back into connection.

EIO_Status SOCK_SetTimeout(SOCK sock, EIO_Event event, const STimeout *timeout)

Specify timeout for the connection I/O (see SOCK_[Read|Write|Close]()).

void SOCK_DisableOSSendDelay(SOCK sock, int on_off)

Control OS-defined send strategy by disabling/enabling the TCP Nagle algorithm (which is on by defaul...

EIO_Status SOCK_Close(SOCK sock)

Close the SOCK handle, and destroy all relevant internal data.

const char * SOCK_gethostbyaddr(unsigned int addr, char *buf, size_t buflen)

Same as SOCK_gethostbyaddrEx(,,<current API data logging>)

EIO_Status SOCK_Read(SOCK sock, void *buf, size_t size, size_t *n_read, EIO_ReadMethod how)

Read/peek up to "size" bytes from "sock" to a buffer pointed to by "buf".

int SOCK_gethostname(char *name, size_t namelen)

Same as SOCK_gethostnameEx(,,<current API data logging>)

unsigned int SOCK_gethostbyname(const char *hostname)

Same as SOCK_gethostbynameEx(,<current API data logging>)

EIO_Status SOCK_Pushback(SOCK sock, const void *data, size_t size)

Push the specified data back to the socket's input queue (in the socket's internal read buffer).

EIO_Status SOCK_Abort(SOCK sock)

If there is outstanding connection or output data pending, cancel it.

int SOCK_ntoa(unsigned int addr, char *buf, size_t bufsize)

Convert IP address to a string in dotted notation.

unsigned int SOCK_GetLocalHostAddress(ESwitch reget)

Same as SOCK_GetLocalHostAddress6() only strictly for IPv4.

int SOCK_isip(const char *host)

Equivalent of SOCK_isip(host, 0)

unsigned int TSOCK_Flags

bitwise "OR" of ESOCK_Flags

@ fSOCK_Secure

subsumes CloseOnExec regardless of Keep

#define LOG_WRITE(lg, code, subcode, level, message)

Auxiliary plain macros to write message (maybe, with raw data) to the log.

ELOG_Level

Log severity level.

#define REG_CONN_HTTP_VERSION

#define DEF_CONN_HTTP_PROXY_SKIP

char http_proxy_host[255+1]

int ConnNetInfo_ExtendUserHeader(SConnNetInfo *info, const char *header)

const char * host

SSL host id (aka SNI) (if differs from "host")

EIO_Status URL_ConnectEx(const char *host, unsigned short port, const char *path, const char *args, TReqMethod req_method, size_t content_length, const STimeout *o_timeout, const STimeout *rw_timeout, const char *user_hdr, SURLExtra *extra, TSOCK_Flags flags, SOCK *sock)

int ConnNetInfo_AddPath(SConnNetInfo *info, const char *path)

int ConnNetInfo_SetupStandardArgs(SConnNetInfo *info, const char *service)

#define UTIL_PrintableString(d, s, b, f)

Same as UTIL_PrintableStringEx(..., 0) – i.e.

char http_proxy_user[63+1]

unsigned short http_proxy_port

#define DEF_CONN_HTTP_PROXY_HOST

#define REG_CONN_HTTP_PROXY_PORT

int ConnNetInfo_SetTimeout(SConnNetInfo *info, const STimeout *timeout)

int ConnNetInfo_OverrideUserHeader(SConnNetInfo *info, const char *header)

void ConnNetInfo_DeleteAllArgs(SConnNetInfo *info, const char *args)

int ConnNetInfo_PreOverrideUserHeader(SConnNetInfo *info, const char *header)

int ConnNetInfo_ParseURL(SConnNetInfo *info, const char *url)

char * MIME_ComposeContentTypeEx(EMIME_Type type, EMIME_SubType subtype, EMIME_Encoding encoding, char *buf, size_t bufsize)

int ConnNetInfo_SetArgs(SConnNetInfo *info, const char *args)

int ConnNetInfo_AppendUserHeader(SConnNetInfo *info, const char *user_header)

SConnNetInfo * ConnNetInfo_Clone(const SConnNetInfo *info)

int ConnNetInfo_AppendArg(SConnNetInfo *info, const char *arg, const char *val)

#define REG_CONN_HTTP_PROXY_USER

#define REG_CONN_DEBUG_PRINTOUT

#define REG_CONN_HTTP_USER_HEADER

const char * ConnNetInfo_GetValue(const char *service, const char *param, char *value, size_t value_size, const char *def_value)

#define DEF_CONN_LB_DISABLE

#define DEF_CONN_HTTP_PUSH_AUTH

#define REG_CONN_STATELESS

EIO_Status CONN_StripToPattern(CONN conn, const void *pattern, size_t pattern_size, BUF *discard, size_t *n_discarded)

Discard all input data before (and including) the first occurrence of a "pattern".

#define REG_CONN_HTTP_PUSH_AUTH

unsigned int usec

microseconds (modulo 1,000,000)

#define REG_CONN_LB_DISABLE

int URL_Decode(const void *src_buf, size_t src_size, size_t *src_read, void *dst_buf, size_t dst_size, size_t *dst_written)

#define CONN_CONTENT_TYPE_LEN

char http_proxy_pass[63+1]

#define DEF_CONN_FIREWALL

const char * ConnNetInfo_GetArgs(const SConnNetInfo *info)

int ConnNetInfo_PreOverrideArg(SConnNetInfo *info, const char *arg, const char *val)

#define DEF_CONN_REQ_METHOD

#define REG_CONN_FIREWALL

#define REG_CONN_HTTP_PROXY_LEAK

SOCK URL_Connect(const char *host, unsigned short port, const char *path, const char *args, EReqMethod req_method, size_t content_length, const STimeout *o_timeout, const STimeout *rw_timeout, const char *user_hdr, int encode_args, TSOCK_Flags flags)

#define DEF_CONN_HTTP_PROXY_LEAK

#define DEF_CONN_STATELESS

#define DEF_CONN_HTTP_PROXY_PASS

char * ConnNetInfo_URL(const SConnNetInfo *info)

#define DEF_CONN_DEBUG_PRINTOUT

const char * IO_StatusStr(EIO_Status status)

Get the text form of an enum status value.

const char * CORE_GetAppName(void)

Obtain current application name (toolkit dependent).

int ConnNetInfo_PostOverrideArg(SConnNetInfo *info, const char *arg, const char *val)

int ConnNetInfo_PrependUserHeader(SConnNetInfo *info, const char *user_header)

void LOG_Write(LOG lg, int code, int subcode, ELOG_Level level, const char *module, const char *func, const char *file, int line, const char *message, const void *raw_data, size_t raw_size)

Upon having filled SLOG_Message data from parameters, write a message (perhaps with raw data attached...

int ConnNetInfo_SetUserHeader(SConnNetInfo *info, const char *user_header)

int MIME_ParseContentTypeEx(const char *str, EMIME_Type *type, EMIME_SubType *subtype, EMIME_Encoding *encoding)

void ConnNetInfo_DeleteUserHeader(SConnNetInfo *info, const char *header)

#define DEF_CONN_HTTP_PROXY_USER

#define REG_CONN_HTTP_REFERER

void URL_EncodeEx(const void *src_buf, size_t src_size, size_t *src_read, void *dst_buf, size_t dst_size, size_t *dst_written, const char *allow_symbols)

#define DEF_CONN_HTTP_REFERER

NCBI_CRED cred

SSL credentials (if any)

#define REG_CONN_EXTERNAL

void ConnNetInfo_Log(const SConnNetInfo *info, ELOG_Level sev, LOG lg)

#define REG_CONN_REQ_METHOD

const char * http_user_header

size_t UTIL_PrintableStringSize(const char *data, size_t size)

Calculate size of buffer needed to store printable representation of the block of data of the specifi...

#define DEF_CONN_REG_SECTION

EBProxyType http_proxy_mask

int ConnNetInfo_DeleteArg(SConnNetInfo *info, const char *arg)

#define REG_CONN_HTTP_PROXY_SKIP

char * UTIL_NcbiLocalHostName(char *hostname)

Cut off well-known NCBI domain suffix out of the passed "hostname".

EIO_Status SOCK_StripToPattern(SOCK sock, const void *pattern, size_t pattern_size, BUF *discard, size_t *n_discarded)

SConnNetInfo * ConnNetInfo_Create(const char *service)

#define REG_CONN_HTTP_PROXY_HOST

int ConnNetInfo_PrependArg(SConnNetInfo *info, const char *arg, const char *val)

#define DEF_CONN_HTTP_USER_HEADER

EIO_Event

I/O event (or direction).

#define DEF_CONN_HTTP_VERSION

void URL_Encode(const void *src_buf, size_t src_size, size_t *src_read, void *dst_buf, size_t dst_size, size_t *dst_written)

#define DEF_CONN_HTTP_PROXY_PORT

int ConnNetInfo_Boolean(const char *str)

#define DEF_CONN_EXTERNAL

const char * CORE_GetPlatform(void)

Return NCBI platrofm ID (if known).

EBDebugPrintout debug_printout

int URL_DecodeEx(const void *src_buf, size_t src_size, size_t *src_read, void *dst_buf, size_t dst_size, size_t *dst_written, const char *allow_symbols)

int ConnNetInfo_SetPath(SConnNetInfo *info, const char *path)

const char * http_referer

void ConnNetInfo_Destroy(SConnNetInfo *info)

int ConnNetInfo_SetFrag(SConnNetInfo *info, const char *frag)

uint64_t TNCBI_BigCount

Big unsigned integer for file size and position.

EIO_Status BUF_StripToPattern(BUF buffer, const void *pattern, size_t pattern_size, BUF *discard, size_t *n_discarded)

#define REG_CONN_HTTP_PROXY_PASS

@ eIO_Timeout

timeout expired before any I/O succeeded

@ eIO_NotSupported

operation is not supported or is not available

@ eIO_Success

everything is fine, no error occurred

@ eIO_Unknown

unknown I/O error (likely fatal but can retry)

@ eIO_InvalidArg

bad argument / parameter value(s) supplied

@ fProxy_None

No $http_proxy / $https_proxy used.

@ fProxy_Http

$http_proxy used

@ fProxy_Https

$https_proxy used

@ eFWMode_Legacy

Relay, no firewall.

@ eFWMode_Firewall

Regular firewall ports only, no fallback.

@ eFWMode_Adaptive

Regular firewall ports first, then fallback.

@ eFWMode_Fallback

Fallback ports only (w/o trying any regular)

@ eIO_ReadPlain

read readily available data only, wait if none

@ eIO_ReadWrite

eIO_Read | eIO_Write (also, eCONN_OnFlush)

unsigned int

A callback function used to compare two keys in a database.

if(yy_accept[yy_current_state])

const struct ncbi::grid::netcache::search::fields::SIZE size

const GenericPointer< typename T::ValueType > T2 value

int strncmp(const char *str1, const char *str2, size_t count)

int strcmp(const char *str1, const char *str2)

int NCBI_HasSpaces(const char *s, size_t n)

Return non-zero(true) if a block of memory based at "s" and of size "n" has any space characters (as ...

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,...

static void x_DestroyNetInfo(SConnNetInfo *info, unsigned int magic)

static void s_SaveKeyval(char *s, const char *name, const char *str)

static const char * x_BadMagic(unsigned int magic, char buf[])

static int x_PrependArg(SConnNetInfo *info, const char *arg, const char *val)

static void s_SaveString(char *s, const char *name, const char *str)

static int x_SetArgs(SConnNetInfo *info, const char *args)

static EIO_Status s_CONN_IO(void *stream, void *buf, size_t size, size_t *n_read, EIO_Event what)

static const char * x_ReqMethod(TReqMethod req_method, char buf[])

static int x_mkenv(char *str, size_t len)

SConnNetInfo * ConnNetInfo_CloneInternal(const SConnNetInfo *info)

#define REG_VALUE(name, value, def_value)

const char * ConnNetInfo_GetValueService(const char *service, const char *param, char *value, size_t value_size, const char *def_value)

static const char s_EncodeTable[256][4]

#define CONN_NET_INFO_MAGIC

static const char * kMIME_Encoding[eENCOD_Unknown+1]

static int x_TagValueMatches(const char *oldval, size_t oldvallen, const char *newval, size_t newvallen)

static void s_SaveStringQuot(char *s, const char *name, const char *str, int quote)

static void x_Trim(char *str)

const char * ConnNetInfo_GetValueInternal(const char *service, const char *param, char *value, size_t value_size, const char *def_value)

static TNCBI_BigCount s_FWPorts[1024/sizeof(TNCBI_BigCount)]

static EIO_Status s_SOCK_IO(void *stream, void *buf, size_t size, size_t *n_read, EIO_Event what)

static const char * x_ClientAddress(const char *client_host, int local_host)

static const char * x_SepAndLen(const char *str, const char *sep, size_t *len)

static void x_DeleteAllArgs(SConnNetInfo *info, const char *args)

static const char * x_strncpy0(char *dst, const char *src, size_t dst_size)

EIO_Status(* FDoIO)(void *stream, void *buf, size_t size, size_t *n_read, EIO_Event what)

static const char * x_Firewall(unsigned int firewall)

static EIO_Status x_URLConnectErrorReturn(SOCK sock, EIO_Status status)

void SERV_PrintFirewallPorts(char *buf, size_t bufsize, EFWMode mode)

static int x_SetupSystemHttpProxy(SConnNetInfo *info)

static void s_SaveULong(char *s, const char *name, unsigned long lll)

static int x_SetupHttpProxy(SConnNetInfo *info, const char *env, EBProxyType proxy)

static const char * s_GetValue(const char *svc, size_t svclen, const char *param, char *value, size_t value_size, const char *def_value, int *generic, FStrNCmp strncompar)

static int s_InfoIsValid(const SConnNetInfo *info)

static const char * x_Num(unsigned int num, char buf[])

void SERV_InitFirewallPorts(void)

static void s_SaveUserHeader(char *s, const char *name, const char *uh, size_t uhlen)

int SERV_IsFirewallPort(unsigned short port)

static int x_StrcatCRLF(char **dstp, const char *src, int pre)

static EFWMode x_ParseFirewall(const char *str, int generic)

#define VALID_URL_SYMBOL(ch)

static const char * x_GetValue(const char *svc, size_t svclen, const char *param, char *value, size_t value_size, const char *def_value, int *generic, FStrNCmp strncompar)

static const char * x_ProxyStr(EBProxyType proxy)

static int s_HexChar(char ch)

static EURLScheme x_ParseScheme(const char *str, size_t len)

static const char * kMIME_Type[eMIME_T_Unknown+1]

static int x_DeleteArg(SConnNetInfo *info, const char *arg)

SConnNetInfo * ConnNetInfo_CreateInternal(const char *service)

static const char * x_GetReferer(char *str, size_t size)

static const char * x_Port(unsigned short port, char buf[])

int SERV_AddFirewallPort(unsigned short port)

static const char * x_Scheme(EURLScheme scheme, char buf[])

static const char * x_CredInfo(NCBI_CRED cred, char buf[])

void ConnNetInfo_ResetHttpProxyInternal(void)

@ eUserHeaderOp_PreOverride

int(* FStrNCmp)(const char *s1, const char *s2, size_t n)

static int x_IsSufficientAddress(const char *addr)

static EIO_Status s_StripToPattern(void *stream, FDoIO io_func, const void *pattern, size_t pattern_size, BUF *discard, size_t *n_discarded)

static int s_ModifyUserHeader(SConnNetInfo *info, const char *user_header, enum EUserHeaderOp op)

static const char * x_ParseHostPort(const char *str, size_t len, size_t *hostlen, long *port)

static EIO_Status s_BUF_IO(void *stream, void *buf, size_t size, size_t *n_read, EIO_Event what)

static void s_SaveBool(char *s, const char *name, unsigned int bbb)

static const char * kMIME_SubType[eMIME_Unknown+1]

static int x_AppendArg(SConnNetInfo *info, const char *arg, const char *val)

static size_t x_size(const char *dst, size_t len, const char *ptr)

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...

#define CORE_Once(once)

Return non-zero (true) if "*once" had a value of NULL, and set the value to non-NULL regardless (best...

FNcbiGetReferer g_CORE_GetReferer

#define CORE_REG_GET(section, name, value, value_size, def_value)

#define NCBI_C_ERRCODE_X

Return currently set default error code.

#define CORE_LOGF_X(subcode, level, fmt_args)

#define CORE_LOGF_ERRNO_X(subcode, level, error, fmt_args)

#define CORE_TRACEF(fmt_args)

#define CORE_LOG_X(subcode, level, message)

#define CORE_LOG(level, message)

char * SERV_ServiceName(const char *service)

EIO_Status SOCK_CreateOnTopInternal(const void *handle, size_t handle_size, SOCK *sock, const SSOCK_Init *init, TSOCK_Flags flags)

EIO_Status SOCK_CreateInternal(const char *host, unsigned short port, const STimeout *timeout, SOCK *sock, const SSOCK_Init *init, TSOCK_Flags flags)

static PCRE2_SIZE bufsize

static SLJIT_INLINE sljit_ins lg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)


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