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__service__connector_8c_source.html below:

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

43 #define NCBI_USE_ERRCODE_X Connect_Service 106

(

"[%s] Service not found"

, uuu->

name

));

138  int

user_callback_enabled)

140  static const char

kStateless[] =

"TRY_STATELESS"

;

141  static const size_t

kSLen =

sizeof

(kStateless) - 1;

150  if

(server_error || !header_parse)

157  if

(user_callback_enabled && !uuu->

warned

)

160  while

(header && *header) {

163  if

(user_callback_enabled || uuu->

host

)

166  while

(*header &&

isspace

((

unsigned char

)(*header)))

168  if

(

strncasecmp

(header, kStateless, kSLen) == 0 &&

169

(!header[kSLen] ||

isspace

((

unsigned char

) header[kSLen]))) {

171

uuu->

host

= (

unsigned int

)(-1);

172 #if defined(_DEBUG) && !defined(NDEBUG) 175

(

"[%s] Fallback to stateless"

, uuu->

name

));

179  unsigned int

i1, i2, i3, i4, tkt,

n

, m;

180  unsigned char

o1, o2, o3, o4;

183  if

(sscanf(header,

"%u.%u.%u.%u%n"

, &i1, &i2, &i3, &i4, &

n

) < 4

184

|| sscanf(header +

n

,

"%hu%x%n"

, &uuu->

port

, &tkt, &m) < 2

185

|| (header[m +=

n

] && !(header[m] ==

'$'

) &&

186

!

isspace

((

unsigned char

)((header + m)

187

[header[m] ==

'$'

])))) {

190

o1 = (

unsigned

char) i1;

191

o2 = (

unsigned

char) i2;

192

o3 = (

unsigned

char) i3;

193

o4 = (

unsigned

char) i4;

194

sprintf(ipaddr,

"%u.%u.%u.%u"

, o1, o2, o3, o4);

195  if

(

strncmp

(header, ipaddr,

n

) != 0

201  if

(header[m] ==

'$'

)

205  if

((header = strchr(header,

'\n'

)) != 0)

209  if

(header && *header)

211  else if

(!header_parse)

261

&&

isspace

((

unsigned char

) s[kCTLen])) {

262 #if defined(_DEBUG) && !defined(NDEBUG) 280  for

(s += kCTLen + 1; *s; ++s) {

281  if

(!

isspace

((

unsigned char

)(*s)))

284  if

(!(c = strchr(s,

'\n'

)))

286  if

(c > s && c[-1] ==

'\r'

)

288  len

= (size_t)(c - s);

289  if

((

t

= (

char

*)

malloc

(

len

+ 1)) != 0) {

290

memcpy(

t

, s,

len

);

294

c_t,

sizeof

(c_t))) {

298

(

"[%s] Content-Type mismatch: " 299  "%s%s%s%s%s%s%s"

, service,

300  t

&& *

t

?

"specified=<"

:

""

,

302  t

&& *

t

?

">"

:

""

,

303  t

&& *

t

&& *c_t ?

", "

:

""

,

304

*c_t ?

"configured=<"

:

""

,

319  const char

* svcname,

322  const char

* cgi_path,

323  const char

* cgi_args,

325  const char

* static_header,

329  const char

* extend_header)

331  const char

*retval = 0;

341  size_t

sh_len = static_header ? strlen(static_header) : 0;

342  size_t

eh_len = extend_header ? strlen(extend_header) : 0;

348

c_t,

sizeof

(c_t))) {

353  if

((

len

+= sh_len + eh_len) != 0) {

354  char

* temp = (

char

*)

malloc

(++

len

);

358

memcpy(temp, static_header, sh_len);

362

memcpy(temp, extend_header, eh_len);

373  if

(retval && *retval)

374  free

((

void

*) retval);

412 static char

*

x_HostPort

(

const char

* host,

unsigned short

aport)

414  char

* hostport, port[16];

415  size_t

hostlen = strlen(host);

416  size_t

portlen = (size_t) sprintf(port,

":%hu"

, aport) + 1;

417

hostport = (

char

*)

malloc

(hostlen + portlen);

419

memcpy(hostport, host, hostlen);

420

memcpy(hostport + hostlen, port, portlen);

433  const char

* hostport,

458

memset(&

init

, 0,

sizeof

(

init

));

495

net_info->

user

[0] =

'\0'

;

496

net_info->

pass

[0] =

'\0'

;

497

net_info->

path

[0] =

'\0'

;

511

memset(&

init

, 0,

sizeof

(

init

));

559  const char

* end =

memrchr

(vhost,

"]:"

[!(*vhost ==

'['

)], (

size_t

)

info

->vhost);

563  len

= (size_t)(end - vhost);

566  assert

(len <= info->vhost &&

info

->vhost <

sizeof

(net_info->

host

));

571  sizeof

(net_info->

host

) - (

size_t

)(2*ipv6),

574

*net_info->

host

=

'\0'

;

578

*net_info->

host

=

'['

;

582

}

else if

(

info

->host) {

586

*net_info->

host

=

'\0'

;

616  const char

* user_header;

623  if

(

n

== (

unsigned int

)(-1))

636  switch

(

info

->type) {

638

user_header =

"Connection-Mode: STATELESS\r\n"

;

644

user_header,

info

->mime_t,

651

user_header =

"Client-Mode: STATELESS_ONLY\r\n"

;

661

user_header,

info

->mime_t,

667

user_header =

"Client-Mode: STATELESS_ONLY\r\n"

;

671

user_header,

info

->mime_t,

713  char

*

str

, *referer;

716  assert

(mapper && *mapper);

725

net_info->

scheme

= scheme;

727

}

else if

((

str

=

strdup

(mapper)) != 0) {

728  const char

* args = strchr(net_info->

path

,

'?'

);

730  const char

* name = iter->

name

;

739  if

(!(referer = (

char

*) realloc(

str

,

740

3 + 1 + 1

+ (

len

<< 1) +

741

strlen(host) + (args && args[1]

743

: 9 + strlen(name))))){

748  str

+= sprintf(

str

,

"://%s/"

, host);

754

strcpy(strcpy(

str

,

"?service="

) + 9, name);

781  const char

* user_header;

799  switch

(

info

->type) {

807

?

"Connection-Mode: STATELESS\r\n" 809

:

"Connection-Mode: STATEFUL\r\n"

;

814

0, user_header,

info

->mime_t,

827

user_header =

"Client-Mode: STATELESS_ONLY\r\n"

;

832

0, user_header,

info

->mime_t,

847

user_header =

"Client-Mode: STATELESS_ONLY\r\n"

;

850

0, user_header,

info

->mime_t,

869

?

info

->u.firewall.type

881

mime_t =

info

->mime_t;

882

mime_s =

info

->mime_s;

883

mime_e =

info

->mime_e;

893

?

"Client-Mode: STATELESS_ONLY\r\n" 894

:

"Client-Mode: STATEFUL_CAPABLE\r\n"

);

897

0, user_header, mime_t,

903  if

((iter_header =

SERV_Print

(iter, net_info, but_last)) != 0) {

905  if

((uh_len = strlen(user_header)) > 0) {

907  size_t

ih_len = strlen(iter_header);

908  if

((ih = (

char

*) realloc(iter_header, ++uh_len + ih_len)) != 0) {

909

memcpy(ih + ih_len, user_header, uh_len);

912  free

((

void

*) user_header);

914

user_header = iter_header;

915

}

else if

(!*user_header)

929

(net_info,

"User-Agent: NCBIServiceConnector/" 969

aux_status != eIO_Closed &&

970

*status < aux_status) {

971

*status = aux_status;

982

(

"[%s] Unable to create auxiliary HTTP %s%s%s"

,

983

uuu->

name

, c ?

"connection"

:

"connector"

,

987  if

(uuu->

host

== (

unsigned int

)(-1)) {

993  return s_Open

(uuu, timeout,

info

, net_info, status);

1004

(

"[%s] Firewall port :%hu is not in the fallback set"

,

1020  else if

(!net_info->

scheme

)

1147

c =

s_Open

(uuu, timeout,

info

, net_info, &status);

1156

uuu->

descr

= descr;

1162

memset(&uuu->

meta

, 0,

sizeof

(uuu->

meta

));

1166

status = meta_status;

1167

uuu->

descr

= descr;

1173

c->

next

= meta->list;

1177

uuu->

descr

= descr;

1178  else if

(!uuu->

descr

) {

1192  size_t

nlen = strlen(uuu->

name

);

1193  size_t

tlen = strlen(

type

);

1194  char

* temp = (

char

*)

malloc

(nlen + tlen + 2);

1196

memcpy(temp, uuu->

name

, nlen);

1197

temp[nlen++] =

'/'

;

1198

memcpy(temp + nlen,

type

, tlen);

1199

temp[nlen + tlen] =

'\0'

;

1206  s_Close

(connector, timeout, 0

);

1220

(

"[%s] %s connection failure (%s) usually" 1221  " indicates possible firewall configuration" 1222  " problem(s); please consult <%s>"

, uuu->

name

,

1227  s_Close

(connector, timeout, 0

);

1232

(

"[%s] Too many failed attempts (%hu), giving up"

,

1249  return s_Close

(connector, timeout, 1

);

1288

(

const char

* name,

1329

memcpy((

char

*) xxx->

name

, name,

len

);

1350

memcpy(&xxx->

extra

, extra,

sizeof

(xxx->

extra

));

static const char * kContentType

static void cleanup(void)

static CS_CONNECTION * conn

static void DLIST_NAME() init(DLIST_LIST_TYPE *list)

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

static const struct type types[]

CONNECTOR SERVICE_CreateConnectorEx(const char *name, TSERV_Type types, const SConnNetInfo *net_info, const SSERVICE_Extra *extra)

EIO_Status HTTP_CreateTunnel(const SConnNetInfo *net_info, THTTP_Flags flags, SOCK *sock)

Same as HTTP_CreateTunnelEx(net_info, flags, 0, 0, 0, 0, sock)

FSetupVTable setup

init meta, may not be NULL

#define CONN_SET_METHOD(meta, method, function, connector)

CONNECTOR HTTP_CreateConnectorEx(const SConnNetInfo *net_info, THTTP_Flags flags, FHTTP_ParseHeader parse_header, void *user_data, FHTTP_Adjust adjust, FHTTP_Cleanup cleanup)

Create new CONNECTOR structure to hit the specified URL using HTTP with either POST / GET (or ANY) me...

FConnectorGetType get_type

unsigned int THTTP_Flags

Bitwise OR of EHTTP_Flag.

EIO_Status CONN_Flush(CONN conn)

Explicitly flush connection from any pending data written by CONN_Write().

#define CONN_SET_DEFAULT_TIMEOUT(meta, timeout)

CONNECTOR next

linked list

FHTTP_ParseHeader parse_header

EIO_Status CONN_SetTimeout(CONN conn, EIO_Event event, const STimeout *timeout)

Specify timeout for the connection I/O, including "Connect" (aka "Open") and "Close".

EIO_Status CONN_Create(CONNECTOR connector, CONN *conn)

Same as CONN_CreateEx() called with 0 in the "flags" parameter.

FDestroy destroy

destroys handle, can be NULL

FSERVICE_GetNextInfo get_next_info

EIO_Status METACONN_Remove(SMetaConnector *meta, CONNECTOR connector)

Delete given "connector" all its descendants (all connectors if "connector" is NULL) from the connect...

EHTTP_HeaderParse

The extended version HTTP_CreateConnectorEx() is able to track the HTTP response chain and also chang...

EIO_Status METACONN_Insert(SMetaConnector *meta, CONNECTOR connector)

Insert a connector at the beginning of the connection's list of connectors.

void * handle

data handle of the connector

SMetaConnector * meta

back link to original meta

EIO_Status CONN_Close(CONN conn)

Close the connection and destroy all relevant internal data.

CONNECTOR SOCK_CreateConnectorOnTopEx(SOCK sock, unsigned short own_sock, const char *hostport)

@ fHTTP_AdjustOnRedirect

Call adjust routine for redirects, too.

@ fHTTP_NoAutoRetry

No auto-retries allowed.

@ fHTTP_AutoReconnect

See HTTP_CreateConnectorEx()

@ fHTTP_Flushable

Connector will really flush on Flush()

@ eHTTP_HeaderSuccess

Parse succeeded, retain server status.

@ eHTTP_HeaderError

Parse failed, treat as a server error.

#define SERV_HTTP_PATH(ui)

#define SERV_HTTP_ARGS(ui)

SSERV_InfoCPtr SERV_GetNextInfo(SERV_ITER iter)

Same as "SERV_GetNextInfoEx(., 0)" – i.e.

void SERV_Close(SERV_ITER iter)

Deallocate the iterator.

void SERV_Reset(SERV_ITER iter)

Reset the iterator to the state as if it has just been opened.

SERV_ITER SERV_Open(const char *service, TSERV_Type types, unsigned int preferred_host, const SConnNetInfo *net_info)

Same as "SERV_OpenEx(., ., ., ., 0, 0)" – i.e.

unsigned int TSERV_Type

Bitwise OR of ESERV_Type[Special].

unsigned short TSERV_TypeOnly

Server type only, w/o specials.

#define SERV_LOCALHOST

Special values for the "preferred_host" parameter.

#define SERV_NCBID_ARGS(ui)

@ fSERV_Stateless

Stateless servers only.

@ fSERV_DelayOpen

Don't open service until use.

unsigned int SOCK_HostToNetLong(unsigned int value)

See man for the BSDisms, htonl() and htons().

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

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_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 TSOCK_Flags

bitwise "OR" of ESOCK_Flags

@ fSOCK_Secure

subsumes CloseOnExec regardless of Keep

char http_proxy_host[255+1]

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

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

char http_proxy_user[63+1]

unsigned short http_proxy_port

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

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

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

SConnNetInfo * ConnNetInfo_Clone(const SConnNetInfo *net_info)

LOG CORE_GetLOG(void)

Get the log handle that is to be used by the core internals (CORE LOG).

#define CONN_CONTENT_TYPE_LEN

char http_proxy_pass[63+1]

const char * ConnNetInfo_GetArgs(const SConnNetInfo *net_info)

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

char * ConnNetInfo_URL(const SConnNetInfo *net_info)

const char * IO_StatusStr(EIO_Status status)

Get the text form of an enum status value.

int ConnNetInfo_SetUserHeader(SConnNetInfo *net_info, const char *header)

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

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

void ConnNetInfo_Log(const SConnNetInfo *net_info, ELOG_Level sev, LOG log)

const char * http_user_header

EBProxyType http_proxy_mask

EIO_Event

I/O event (or direction).

EBDebugPrintout debug_printout

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

const char * http_referer

void ConnNetInfo_Destroy(SConnNetInfo *net_info)

@ 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)

@ fProxy_Http

$http_proxy used

@ eFWMode_Adaptive

Regular firewall ports first, then fallback.

@ eFWMode_Fallback

Fallback ports only (w/o trying any regular)

@ eIO_ReadWrite

eIO_Read | eIO_Write (also, eCONN_OnFlush)

@ eIO_Open

also serves as no-event indicator in SOCK_Poll

@ eIO_Close

also serves as an error indicator in SOCK_Poll

unsigned int

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

for(len=0;yy_str[len];++len)

if(yy_accept[yy_current_state])

static const CS_INT unused

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

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

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

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

#define NCBI_DISP_VERSION

#define HTTP_CONNECTION_INFO

int SERV_IsFirewallPort(unsigned short port)

SConnNetInfo * ConnNetInfo_CreateInternal(const char *service)

char * NcbiAddrToString(char *buf, size_t bufsize, const TNCBI_IPv6Addr *addr)

Convert an IPv6 address into either a full-quad text IPv4 (for IPv4-mapped IPv6 addresses) or a hex c...

int NcbiIsIPv4(const TNCBI_IPv6Addr *addr)

Return non-zero(true) if the address is a true IPv4 address (a mapped IPv4 address),...

#define CORE_LOGF_X(subcode, level, fmt_args)

const char * SERV_HostOfInfo(const SSERV_Info *info)

char * SERV_ServiceName(const char *service)

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

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

const char * SERV_MapperName(SERV_ITER iter)

static EIO_Status s_Close(CONNECTOR connector, const STimeout *timeout, int cleanup)

static void s_CloseDispatcher(SServiceConnector *uuu)

static const char kHttpHostTag[]

static EHTTP_HeaderParse s_ParseHeaderUCB(const char *header, void *data, int server_error)

static void s_Cleanup(SServiceConnector *uuu)

static const char * s_AdjustNetParams(const char *service, const char *svcname, SConnNetInfo *net_info, EReqMethod req_method, const char *cgi_path, const char *cgi_args, const char *args, const char *static_header, EMIME_Type mime_t, EMIME_SubType mime_s, EMIME_Encoding mime_e, const char *extend_header)

static SSERV_InfoCPtr s_GetNextInfo(SServiceConnector *uuu, int http)

static char * s_VT_Descr(CONNECTOR connector)

static EIO_Status s_VT_Status(CONNECTOR connector, EIO_Event direction)

static int s_IsContentTypeDefined(const char *service, const SConnNetInfo *net_info, EMIME_Type mime_t, EMIME_SubType mime_s, EMIME_Encoding mime_e)

static void x_SetDefaultReferer(SConnNetInfo *net_info, SERV_ITER iter)

static int s_Adjust(SConnNetInfo *net_info, void *data, unsigned int n)

static const char * s_VT_GetType(CONNECTOR connector)

static void s_Reset(SMetaConnector *meta, CONNECTOR connector)

static int x_SetHostPort(SConnNetInfo *net_info, const SSERV_Info *info)

static EIO_Status s_VT_Close(CONNECTOR connector, const STimeout *timeout)

static EIO_Status s_VT_Open(CONNECTOR connector, const STimeout *timeout)

struct SServiceConnectorTag SServiceConnector

static CONNECTOR s_SocketConnectorBuilder(SConnNetInfo *net_info, const char *hostport, EIO_Status *status, const void *data, size_t size, TSOCK_Flags flags)

static EHTTP_HeaderParse s_ParseHeader(const char *header, void *user_data, int server_error, int user_callback_enabled)

static void s_Setup(CONNECTOR connector)

static EHTTP_HeaderParse s_ParseHeaderNoUCB(const char *header, void *data, int server_error)

static char * x_HostPort(const char *host, unsigned short aport)

static CONNECTOR s_Open(SServiceConnector *uuu, const STimeout *timeout, SSERV_InfoCPtr info, SConnNetInfo *net_info, EIO_Status *status)

static int s_OpenDispatcher(SServiceConnector *uuu)

static void s_Destroy(CONNECTOR connector)

static void x_DestroyConnector(CONNECTOR c)

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

const char g_kNcbiSockNameAbbr[]

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

const SConnNetInfo * net_info

voidp calloc(uInt items, uInt size)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4