Utility Functions
[CONNECT]

Collaboration diagram for Utility Functions:


Classes

struct  SConnNetInfo
struct  SLOG_Handler
 Message and miscellaneous data to pass to log post callback FLOG_Handler. More...
class  CConnIniter
 Helper hook-up class that installs default logging/registry/locking (but only if they have not yet been installed explicitly by user). More...
struct  STimeoutTag
 Timeout structure. More...

Defines

#define DEF_CONN_REG_SECTION   "CONN"
#define REG_CONN_SCHEME   "SCHEME"
#define DEF_CONN_SCHEME   0
#define REG_CONN_USER   "USER"
#define DEF_CONN_USER   ""
#define REG_CONN_PASS   "PASS"
#define DEF_CONN_PASS   ""
#define REG_CONN_HOST   "HOST"
#define DEF_CONN_HOST   "www.ncbi.nlm.nih.gov"
#define REG_CONN_PORT   "PORT"
#define DEF_CONN_PORT   0
#define REG_CONN_PATH   "PATH"
#define DEF_CONN_PATH   "/Service/dispd.cgi"
#define REG_CONN_ARGS   "ARGS"
#define DEF_CONN_ARGS   ""
#define REG_CONN_REQ_METHOD   "REQ_METHOD"
#define DEF_CONN_REQ_METHOD   "ANY"
#define REG_CONN_TIMEOUT   "TIMEOUT"
#define DEF_CONN_TIMEOUT   30.0
#define REG_CONN_MAX_TRY   "MAX_TRY"
#define DEF_CONN_MAX_TRY   3
#define REG_CONN_HTTP_PROXY_HOST   "HTTP_PROXY_HOST"
#define DEF_CONN_HTTP_PROXY_HOST   ""
#define REG_CONN_HTTP_PROXY_PORT   "HTTP_PROXY_PORT"
#define DEF_CONN_HTTP_PROXY_PORT   ""
#define REG_CONN_PROXY_HOST   "PROXY_HOST"
#define DEF_CONN_PROXY_HOST   ""
#define REG_CONN_DEBUG_PRINTOUT   "DEBUG_PRINTOUT"
#define DEF_CONN_DEBUG_PRINTOUT   ""
#define REG_CONN_STATELESS   "STATELESS"
#define DEF_CONN_STATELESS   ""
#define REG_CONN_FIREWALL   "FIREWALL"
#define DEF_CONN_FIREWALL   ""
#define REG_CONN_LB_DISABLE   "LB_DISABLE"
#define DEF_CONN_LB_DISABLE   ""
#define REG_CONN_HTTP_USER_HEADER   "HTTP_USER_HEADER"
#define DEF_CONN_HTTP_USER_HEADER   ""
#define REG_CONN_HTTP_REFERER   "HTTP_REFERER"
#define DEF_CONN_HTTP_REFERER   0
#define REG_CONN_SERVICE_NAME   "SERVICE_NAME"
#define REG_CONN_LOCAL_ENABLE   "LOCAL_ENABLE"
#define REG_CONN_LBSMD_DISABLE   "LBSMD_DISABLE"
#define REG_CONN_DISPD_DISABLE   "DISPD_DISABLE"
#define REG_CONN_LOCAL_SERVICES   "LOCAL_SERVICES"
#define REG_CONN_LOCAL_SERVER   DEF_CONN_REG_SECTION "_LOCAL_SERVER"
#define MAX_CONTENT_TYPE_LEN   64
#define NCBI_CONNUTIL_DEPRECATED
#define MT_LOCK_Do(lk, how)   (lk ? MT_LOCK_DoInternal(lk, how) : -1)
 Call "lk->handler(lk->user_data, how)".
#define kDefaultTimeout   ((const STimeout*)(-1))
#define kInfiniteTimeout   ((const STimeout*)( 0))
#define NCBI_TIME_INFINITE   ((TNCBI_Time)(-1))
#define LOG_WRITE(lg, code, subcode, level, message)
 Auxiliary plain macros to write message (maybe, with raw data) to the log.
#define LOG_DATA(lg, code, subcode, level, data, size, message)
#define THIS_FILE   __FILE__
 Defaults for the THIS_FILE and THIS_MODULE macros (used by LOG_WRITE).
#define THIS_MODULE   0
#define fLOG_Short   fLOG_Level
#define fLOG_Full   (fLOG_Level | fLOG_Module | fLOG_FileLine)
#define NCBI_C_DEFINE_ERRCODE_X(name, err_code, max_err_subcode)
 Defines global error code name with given value (err_code).
#define NCBI_C_CONCAT_IDENTIFIER(prefix, postfix)   prefix##postfix
 Makes one identifier from 2 parts.
#define NCBI_C_ERRCODE_X_NAME(name)   NCBI_C_CONCAT_IDENTIFIER(eErrCodeX_, name)
 Returns value of error code by its name defined by NCBI_DEFINE_ERRCODE_X.
#define NCBI_C_ERRCODE_X   NCBI_C_ERRCODE_X_NAME(NCBI_USE_ERRCODE_X)
 Returns currently set default error code.

Typedefs

typedef MT_LOCK_tagMT_LOCK
typedef int(* FMT_LOCK_Handler )(void *user_data, EMT_Lock how)
 MT locking callback (operates like a [recursive] mutex or RW-lock).
typedef void(* FMT_LOCK_Cleanup )(void *user_data)
 MT lock cleanup callback.
typedef LOG_tagLOG
typedef void(* FLOG_Handler )(void *user_data, SLOG_Handler *call_data)
 Log post callback.
typedef void(* FLOG_Cleanup )(void *user_data)
 Log cleanup callback.
typedef REG_tagREG
typedef void(* FREG_Get )(void *user_data, const char *section, const char *name, char *value, size_t value_size)
 Registry getter callback.
typedef int(* FREG_Set )(void *user_data, const char *section, const char *name, const char *value, EREG_Storage storage)
 Registry setter callback.
typedef void(* FREG_Cleanup )(void *user_data)
 Registry cleanup callback.
typedef unsigned int FConnectInitFlags
typedef STimeoutTag STimeout
 Timeout structure.
typedef unsigned int TNCBI_Size
 Fixed size analogs of size_t and time_t (mainly for IPC).
typedef unsigned int TNCBI_Time
typedef unsigned int TLOG_FormatFlags
 binary OR of "ELOG_FormatFlags"

Enumerations

enum  EURLScheme {
  eURL_Unspec = 0, eURL_Https, eURL_Http, eURL_File,
  eURL_Ftp
}
enum  EReqMethod { eReqMethod_Any = 0, eReqMethod_Post, eReqMethod_Get }
enum  EDebugPrintout { eDebugPrintout_None = 0, eDebugPrintout_Some, eDebugPrintout_Data }
enum  EMIME_Type {
  eMIME_T_Undefined = -1, eMIME_T_NcbiData = 0, eMIME_T_Text, eMIME_T_Application,
  eMIME_T_Unknown
}
enum  EMIME_SubType {
  eMIME_Undefined = -1, eMIME_Dispatch = 0, eMIME_AsnText, eMIME_AsnBinary,
  eMIME_Fasta, eMIME_WwwForm, eMIME_Html, eMIME_Plain,
  eMIME_Xml, eMIME_XmlSoap, eMIME_OctetStream, eMIME_Unknown
}
enum  EMIME_Encoding { eENCOD_None = 0, eENCOD_Url, eENCOD_Unknown }
enum  EIO_ReadMethod {
  eIO_ReadPlain, eIO_ReadPeek, eIO_ReadPersist, eIO_Plain = eIO_ReadPlain,
  eIO_Peek = eIO_ReadPeek, eIO_Persist = eIO_ReadPersist
}
 I/O read method. More...
enum  EIO_WriteMethod { eIO_WritePlain, eIO_WritePersist, eIO_WriteOutOfBand }
 I/O write method. More...
enum  EIO_Event {
  eIO_Open = 0x0, eIO_Read = 0x1, eIO_Write = 0x2, eIO_ReadWrite = 0x3,
  eIO_Close = 0x4
}
 I/O event (or direction). More...
enum  EIO_Status {
  eIO_Success = 0, eIO_Timeout, eIO_Closed, eIO_Interrupt,
  eIO_InvalidArg, eIO_NotSupported, eIO_Unknown
}
 I/O status. More...
enum  EMT_Lock {
  eMT_Lock, eMT_LockRead, eMT_Unlock, eMT_TryLock,
  eMT_TryLockRead
}
 Set the lock/unlock callback function and its data for MT critical section. More...
enum  ELOG_Level {
  eLOG_Trace = 0, eLOG_Note, eLOG_Warning, eLOG_Error,
  eLOG_Critical, eLOG_Fatal
}
 Log severity level. More...
enum  EREG_Storage { eREG_Transient = 0, eREG_Persistent }
 Transient/Persistent storage. More...
enum  EConnectInitFlags { eConnectInit_OwnNothing = 0, eConnectInit_OwnRegistry = 0x01, eConnectInit_OwnLock = 0x02 }
enum  ESwitch { eOff = 0, eOn, eDefault }
 Aux. More...
enum  ELOG_Format {
  fLOG_Default = 0x0, fLOG_Level = 0x1, fLOG_Module = 0x2, fLOG_FileLine = 0x4,
  fLOG_DateTime = 0x8, fLOG_FullOctal = 0x2000, fLOG_OmitNoteLevel = 0x4000, fLOG_None = 0x8000
}
 LOG formatting flags: what parts of the message to actually appear. More...

Functions

const char * ConnNetInfo_GetValue (const char *service, const char *param, char *value, size_t value_size, const char *def_value)
SConnNetInfoConnNetInfo_Create (const char *service)
int ConnNetInfo_AdjustForHttpProxy (SConnNetInfo *info)
SConnNetInfoConnNetInfo_Clone (const SConnNetInfo *info)
int ConnNetInfo_AppendArg (SConnNetInfo *info, const char *arg, const char *val)
int ConnNetInfo_PrependArg (SConnNetInfo *info, const char *arg, const char *val)
void ConnNetInfo_DeleteArg (SConnNetInfo *info, const char *arg)
void ConnNetInfo_DeleteAllArgs (SConnNetInfo *info, const char *args)
int ConnNetInfo_PreOverrideArg (SConnNetInfo *info, const char *arg, const char *val)
int ConnNetInfo_PostOverrideArg (SConnNetInfo *info, const char *arg, const char *val)
int ConnNetInfo_SetUserHeader (SConnNetInfo *info, const char *header)
int ConnNetInfo_AppendUserHeader (SConnNetInfo *info, const char *header)
int ConnNetInfo_OverrideUserHeader (SConnNetInfo *info, const char *header)
int ConnNetInfo_ExtendUserHeader (SConnNetInfo *info, const char *header)
void ConnNetInfo_DeleteUserHeader (SConnNetInfo *info, const char *hdr)
int ConnNetInfo_ParseURL (SConnNetInfo *info, const char *url)
int ConnNetInfo_SetupStandardArgs (SConnNetInfo *info, const char *service)
void ConnNetInfo_Log (const SConnNetInfo *info, LOG log)
char * ConnNetInfo_URL (const SConnNetInfo *info)
void ConnNetInfo_Destroy (SConnNetInfo *info)
EIO_Status URL_ConnectEx (const char *host, unsigned short port, const char *path, const char *args, EReqMethod req_method, size_t content_length, const STimeout *c_timeout, const STimeout *rw_timeout, const char *user_header, int encode_args, TSOCK_Flags flags, SOCK *sock)
SOCK URL_Connect (const char *host, unsigned short port, const char *path, const char *args, EReqMethod req_method, size_t content_length, const STimeout *c_timeout, const STimeout *rw_timeout, const char *user_header, int encode_args, TSOCK_Flags flags)
EIO_Status CONN_StripToPattern (CONN conn, const void *pattern, size_t pattern_size, BUF *buf, size_t *n_discarded)
EIO_Status SOCK_StripToPattern (SOCK sock, const void *pattern, size_t pattern_size, BUF *buf, size_t *n_discarded)
EIO_Status BUF_StripToPattern (BUF buffer, const void *pattern, size_t pattern_size, BUF *buf, size_t *n_discarded)
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)
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)
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)
char * MIME_ComposeContentTypeEx (EMIME_Type type, EMIME_SubType subtype, EMIME_Encoding encoding, char *buf, size_t buflen)
int MIME_ParseContentTypeEx (const char *str, EMIME_Type *type, EMIME_SubType *subtype, EMIME_Encoding *encoding)
char * MIME_ComposeContentType (EMIME_SubType subtype, EMIME_Encoding encoding, char *buf, size_t buflen)
int MIME_ParseContentType (const char *str, EMIME_SubType *subtype, EMIME_Encoding *encoding)
const char * IO_StatusStr (EIO_Status status)
 Get the text form of an enum status value.
MT_LOCK MT_LOCK_Create (void *user_data, FMT_LOCK_Handler handler, FMT_LOCK_Cleanup cleanup)
 Create new MT lock (with an internal reference counter set to 1).
MT_LOCK MT_LOCK_AddRef (MT_LOCK lk)
 Increment internal reference counter by 1, then return "lk".
MT_LOCK MT_LOCK_Delete (MT_LOCK lk)
 Decrement internal reference counter by 1, and if it reaches 0, then destroy the handle, call "lk->cleanup(lk->user_data)", and return NULL; otherwise (if the reference counter is still > 0), return "lk".
int MT_LOCK_DoInternal (MT_LOCK lk, EMT_Lock how)
const char * LOG_LevelStr (ELOG_Level level)
 Obtain verbal representation of an enum level value.
LOG LOG_Create (void *user_data, FLOG_Handler handler, FLOG_Cleanup cleanup, MT_LOCK mt_lock)
 Create new LOG (with an internal reference counter set to 1).
LOG LOG_Reset (LOG lg, void *user_data, FLOG_Handler handler, FLOG_Cleanup cleanup)
 Reset the "lg" to use the new "user_data", "handler" and "cleanup".
LOG LOG_AddRef (LOG lg)
 Increment internal reference counter by 1, then return "lg".
LOG LOG_Delete (LOG lg)
 Decrement internal reference counter by 1, and if it reaches 0, then call "lg->cleanup(lg->user_data)", destroy the handle, and return NULL; otherwise (if reference counter is still > 0), return "lg".
void LOG_WriteInternal (LOG lg, SLOG_Handler *call_data)
 Write message (perhaps with raw data attached) to the log by calling "lg->handler(lg->user_data, call_data)".
void LOG_Write (LOG lg, int code, int subcode, ELOG_Level level, const char *module, const char *file, int line, const char *message, const void *raw_data, size_t raw_size)
 Write message (perhaps with raw data attached) to the log by calling LOG_WriteInternal() upon filling up SLOG_Handler data from parameters.
REG REG_Create (void *user_data, FREG_Get get, FREG_Set set, FREG_Cleanup cleanup, MT_LOCK mt_lock)
 Create new registry (with an internal reference counter set to 1).
void REG_Reset (REG rg, void *user_data, FREG_Get get, FREG_Set set, FREG_Cleanup cleanup, int do_cleanup)
 Reset the registry handle to use the new "user_data", "set", "get", and "cleanup".
REG REG_AddRef (REG rg)
 Increment internal reference counter by 1, then return "rg".
REG REG_Delete (REG rg)
 Decrement internal referecne counter by 1, and if it reaches 0, then call "rg->cleanup(rg->user_data)", destroy the handle, and return NULL; otherwise (if the reference counter is still > 0), return "rg".
const char * REG_Get (REG rg, const char *section, const char *name, char *value, size_t value_size, const char *def_value)
 Copy the registry value stored in "section" under name "name" to buffer "value"; if the entry is found in both transient and persistent storages, then copy the one from the transient storage.
int REG_Set (REG rg, const char *section, const char *name, const char *value, EREG_Storage storage)
 Store the "value" to the registry section "section" under name "name", and according with "storage".
REG REG_cxx2c (IRWRegistry *reg, bool pass_ownership=false)
 NB: now that registries are CObjects, any we "own" will be deleted if and only if nothing else still holds a reference to them.
LOG LOG_cxx2c (void)
MT_LOCK MT_LOCK_cxx2c (CRWLock *lock=0, bool pass_ownership=false)
void CONNECT_Init (IRWRegistry *reg=0, CRWLock *lock=0, FConnectInitFlags flag=eConnectInit_OwnNothing)
const STimeoutg_CTimeoutToSTimeout (const CTimeout &cto, STimeout &sto)
 Convert CTimeout to STimeout.
CTimeout g_STimeoutToCTimeout (const STimeout *sto)
 Convert STimeout to CTimeout.
unsigned long NcbiTimeoutToMs (const STimeout *timeout)
STimeoutNcbiMsToTimeout (STimeout *timeout, unsigned long ms)
void CORE_SetLOCK (MT_LOCK lk)
 Set the MT critical section lock/unlock handler -- to be used by the core internals for protection of internal static variables and other MT-sensitive code from being accessed/changed by several threads simultaneously.
MT_LOCK CORE_GetLOCK (void)
void CORE_SetLOG (LOG lg)
 Set the log handle (no logging if "lg" is passed zero) -- to be used by the core internals.
LOG CORE_GetLOG (void)
 Get the log handle which is be used by the core internals.
void CORE_SetLOGFILE_Ex (FILE *fp, ELOG_Level cut_off, int auto_close)
 Standard logging to the specified file stream.
void CORE_SetLOGFILE (FILE *fp, int auto_close)
 Same as CORE_SetLOGFILE_Ex() with last parameter passed as 0 (all messages pass).
int CORE_SetLOGFILE_NAME_Ex (const char *filename, ELOG_Level cut_off)
 Same as CORE_SetLOGFILE_Ex(fopen(filename, "a"), cut_off, TRUE).
int CORE_SetLOGFILE_NAME (const char *filename)
 Same as CORE_SetLOGFILE_NAME_Ex with last parameter passed as 0 (all messages pass).
TLOG_FormatFlags CORE_SetLOGFormatFlags (TLOG_FormatFlags)
char * LOG_ComposeMessage (const SLOG_Handler *call_data, TLOG_FormatFlags format_flags)
 Compose message using the "call_data" info.
void LOG_ToFILE_Ex (LOG lg, FILE *fp, ELOG_Level cut_off, int auto_close)
 LOG_Reset specialized to log to a "FILE*" stream using LOG_ComposeMessage.
void LOG_ToFILE (LOG lg, FILE *fp, int auto_close)
 Same as LOG_ToFILEx with "cut_off" parameter passed as 0 (all messages pass).
const char * NcbiMessagePlusError (int *dynamic, const char *message, int error, const char *descr)
 Add current "error" (and maybe its description) to the message: <message>[ {error=[[<error>][,]][<descr>]}].
void CORE_SetREG (REG rg)
 Set the registry (no registry if "rg" is passed zero) -- to be used by the core internals.
REG CORE_GetREG (void)
 Get the registry previously set by CORE_SetREG().
const char * CORE_GetPlatform (void)
const char * CORE_GetUsername (char *buf, size_t bufsize)
 Obtain and store current user's name in the buffer provided.
size_t CORE_GetVMPageSize (void)
 Obtain virtual memory page size.
unsigned int CRC32_Update (unsigned int checksum, const void *ptr, size_t count)
 Calculate/Update CRC32.
int UTIL_MatchesMaskEx (const char *name, const char *mask, int ignore_case)
int UTIL_MatchesMask (const char *name, const char *mask)
 Same as UTIL_MatchesMaskEx(name, mask, 1).
char * UTIL_NcbiLocalHostName (char *hostname)
 Cut off well-known NCBI domain suffix out of the passed "hostname".
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 specified size (or, if size is 0, strlen(data)).
char * UTIL_PrintableString (const char *data, size_t size, char *buf, int full)
 Create printable representation of the block of data of the specified size (or, if size is 0, strlen(data), and return buffer pointer past the last stored character (non ''-terminated).


Define Documentation

#define DEF_CONN_ARGS   ""
 

Definition at line 175 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define DEF_CONN_DEBUG_PRINTOUT   ""
 

Definition at line 196 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define DEF_CONN_FIREWALL   ""
 

Definition at line 202 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define DEF_CONN_HOST   "www.ncbi.nlm.nih.gov"
 

Definition at line 166 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define DEF_CONN_HTTP_PROXY_HOST   ""
 

Definition at line 187 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define DEF_CONN_HTTP_PROXY_PORT   ""
 

Definition at line 190 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define DEF_CONN_HTTP_REFERER   0
 

Definition at line 211 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define DEF_CONN_HTTP_USER_HEADER   ""
 

Definition at line 208 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define DEF_CONN_LB_DISABLE   ""
 

Definition at line 205 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define DEF_CONN_MAX_TRY   3
 

Definition at line 184 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define DEF_CONN_PASS   ""
 

Definition at line 163 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define DEF_CONN_PATH   "/Service/dispd.cgi"
 

Definition at line 172 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define DEF_CONN_PORT   0
 

Definition at line 169 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define DEF_CONN_PROXY_HOST   ""
 

Definition at line 193 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define DEF_CONN_REG_SECTION   "CONN"
 

Definition at line 154 of file ncbi_connutil.h.

Referenced by ConnNetInfo_GetValue(), CDebugArgs::ExtractAlgorithmOptions(), and GetAsnDataViaHTTP().

#define DEF_CONN_REQ_METHOD   "ANY"
 

Definition at line 178 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define DEF_CONN_SCHEME   0
 

Definition at line 157 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define DEF_CONN_STATELESS   ""
 

Definition at line 199 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define DEF_CONN_TIMEOUT   30.0
 

Definition at line 181 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define DEF_CONN_USER   ""
 

Definition at line 160 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define fLOG_Full   (fLOG_Level | fLOG_Module | fLOG_FileLine)
 

Definition at line 229 of file ncbi_util.h.

Referenced by LOG_ComposeMessage().

#define fLOG_Short   fLOG_Level
 

Definition at line 228 of file ncbi_util.h.

Referenced by LOG_ComposeMessage().

#define kDefaultTimeout   ((const STimeout*)(-1))
 

Definition at line 74 of file ncbi_types.h.

Referenced by CONN_Create(), CONN_Flush(), CONN_Read(), CONN_ReadLine(), CONN_ReInit(), CONN_SetTimeout(), CONN_Wait(), CUNIXSocket::Connect(), CSocket::Connect(), ConnNetInfo_Clone(), CSocket::CSocket(), CUNIXSocket::CUNIXSocket(), g_CTimeoutToSTimeout(), g_STimeoutToCTimeout(), CSocket::GetTimeout(), CPipe::GetTimeout(), CNamedPipe::GetTimeout(), IServer_ConnectionHandler::GetTimeout(), CSocket::Reconnect(), CThreadedServer::Run(), CServer::Run(), s_CONN_Read(), s_CONN_ReadPersist(), s_CONN_Write(), s_CreateConnector(), s_HttpConnectorBuilder(), s_Open(), s_ServiceConnectorBuilder(), CSocket::SetTimeout(), CPipe::SetTimeout(), CNamedPipe::SetTimeout(), CConn_Streambuf::showmanyc(), CServer_ConnectionPool::SPerConnInfo::UpdateExpiration(), and CRPCClient< CGBenchServiceRequest, CGBenchServiceReply >::x_IsSpecial().

#define kInfiniteTimeout   ((const STimeout*)( 0))
 

Definition at line 75 of file ncbi_types.h.

Referenced by g_CTimeoutToSTimeout(), g_STimeoutToCTimeout(), CThreadedServer::Run(), CServer::Run(), s_SetTimeout(), CServer_ConnectionPool::SPerConnInfo::UpdateExpiration(), and CRPCClient< CGBenchServiceRequest, CGBenchServiceReply >::x_IsSpecial().

#define LOG_DATA lg,
code,
subcode,
level,
data,
size,
message   ) 
 

Value:

LOG_Write(lg, code, subcode, level, THIS_MODULE, THIS_FILE, __LINE__, \
              message, data, size)

Definition at line 119 of file ncbi_util.h.

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

Value:

LOG_Write(lg, code, subcode, level, THIS_MODULE, THIS_FILE, __LINE__, \
              message, 0, 0)
Auxiliary plain macros to write message (maybe, with raw data) to the log.

See also:
LOG_Write

Definition at line 110 of file ncbi_util.h.

Referenced by ConnNetInfo_Log().

#define MAX_CONTENT_TYPE_LEN   64
 

Definition at line 669 of file ncbi_connutil.h.

Referenced by MIME_ComposeContentTypeEx(), s_AdjustNetParams(), s_IsContentTypeDefined(), and SERV_WriteInfo().

#define MT_LOCK_Do lk,
how   )     (lk ? MT_LOCK_DoInternal(lk, how) : -1)
 

Call "lk->handler(lk->user_data, how)".

Parameters:
lk A handle previously obtained from MT_LOCK_Create
how Whether to lock (and how: read, write) or to unlock
Returns:
Value returned by the lock handler ("handler" in MT_LOCK_Create()). If lock handler is not specified then always return "-1".
NOTE:
Use MT_LOCK_Do to avoid overhead!
See also:
MT_LOCK_Create, FMT_LOCK_Handler, EMT_Lock

Definition at line 267 of file ncbi_core.h.

Referenced by Blast_DiagnosticsUpdate(), and BlastHSPStreamWrite().

#define NCBI_C_CONCAT_IDENTIFIER prefix,
postfix   )     prefix##postfix
 

Makes one identifier from 2 parts.

Definition at line 330 of file ncbi_util.h.

#define NCBI_C_DEFINE_ERRCODE_X name,
err_code,
max_err_subcode   ) 
 

Value:

enum enum##name {                                                   \
        eErrCodeX_##name = err_code                                     \
        /* automatic subcode checking is not implemented in C code */   \
    }
Defines global error code name with given value (err_code).

Definition at line 322 of file ncbi_util.h.

#define NCBI_C_ERRCODE_X   NCBI_C_ERRCODE_X_NAME(NCBI_USE_ERRCODE_X)
 

Returns currently set default error code.

Default error code is set by definition of NCBI_USE_ERRCODE_X with name of error code as its value.

See also:
NCBI_DEFINE_ERRCODE_X

Definition at line 344 of file ncbi_util.h.

Referenced by ConnNetInfo_Log().

#define NCBI_C_ERRCODE_X_NAME name   )     NCBI_C_CONCAT_IDENTIFIER(eErrCodeX_, name)
 

Returns value of error code by its name defined by NCBI_DEFINE_ERRCODE_X.

See also:
NCBI_C_DEFINE_ERRCODE_X

Definition at line 336 of file ncbi_util.h.

#define NCBI_CONNUTIL_DEPRECATED
 

Definition at line 704 of file ncbi_connutil.h.

#define NCBI_TIME_INFINITE   ((TNCBI_Time)(-1))
 

Definition at line 116 of file ncbi_types.h.

Referenced by SNetServiceImpl::DiscoverServers(), s_Open(), s_SkipSkip(), and s_Update().

#define REG_CONN_ARGS   "ARGS"
 

Definition at line 174 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define REG_CONN_DEBUG_PRINTOUT   "DEBUG_PRINTOUT"
 

Definition at line 195 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create(), and GetAsnDataViaHTTP().

#define REG_CONN_DISPD_DISABLE   "DISPD_DISABLE"
 

Definition at line 217 of file ncbi_connutil.h.

#define REG_CONN_FIREWALL   "FIREWALL"
 

Definition at line 201 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define REG_CONN_HOST   "HOST"
 

Definition at line 165 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define REG_CONN_HTTP_PROXY_HOST   "HTTP_PROXY_HOST"
 

Definition at line 186 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define REG_CONN_HTTP_PROXY_PORT   "HTTP_PROXY_PORT"
 

Definition at line 189 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define REG_CONN_HTTP_REFERER   "HTTP_REFERER"
 

Definition at line 210 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define REG_CONN_HTTP_USER_HEADER   "HTTP_USER_HEADER"
 

Definition at line 207 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define REG_CONN_LB_DISABLE   "LB_DISABLE"
 

Definition at line 204 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define REG_CONN_LBSMD_DISABLE   "LBSMD_DISABLE"
 

Definition at line 216 of file ncbi_connutil.h.

#define REG_CONN_LOCAL_ENABLE   "LOCAL_ENABLE"
 

Definition at line 215 of file ncbi_connutil.h.

#define REG_CONN_LOCAL_SERVER   DEF_CONN_REG_SECTION "_LOCAL_SERVER"
 

Definition at line 221 of file ncbi_connutil.h.

Referenced by s_LoadSingleService().

#define REG_CONN_LOCAL_SERVICES   "LOCAL_SERVICES"
 

Definition at line 220 of file ncbi_connutil.h.

Referenced by s_LoadServices().

#define REG_CONN_MAX_TRY   "MAX_TRY"
 

Definition at line 183 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define REG_CONN_PASS   "PASS"
 

Definition at line 162 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define REG_CONN_PATH   "PATH"
 

Definition at line 171 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define REG_CONN_PORT   "PORT"
 

Definition at line 168 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define REG_CONN_PROXY_HOST   "PROXY_HOST"
 

Definition at line 192 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define REG_CONN_REQ_METHOD   "REQ_METHOD"
 

Definition at line 177 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create(), and GetAsnDataViaHTTP().

#define REG_CONN_SCHEME   "SCHEME"
 

Definition at line 156 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define REG_CONN_SERVICE_NAME   "SERVICE_NAME"
 

Definition at line 214 of file ncbi_connutil.h.

Referenced by CDebugArgs::ExtractAlgorithmOptions().

#define REG_CONN_STATELESS   "STATELESS"
 

Definition at line 198 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define REG_CONN_TIMEOUT   "TIMEOUT"
 

Definition at line 180 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define REG_CONN_USER   "USER"
 

Definition at line 159 of file ncbi_connutil.h.

Referenced by ConnNetInfo_Create().

#define THIS_FILE   __FILE__
 

Defaults for the THIS_FILE and THIS_MODULE macros (used by LOG_WRITE).

Definition at line 127 of file ncbi_util.h.

#define THIS_MODULE   0
 

Definition at line 131 of file ncbi_util.h.


Typedef Documentation

typedef unsigned int FConnectInitFlags
 

Definition at line 76 of file ncbi_core_cxx.hpp.

typedef void(* FLOG_Cleanup)(void *user_data)
 

Log cleanup callback.

Parameters:
user_data Unspeficied data as passed to LOG_Create() or LOG_Reset()
See also:
LOG_Create, LOG_Reset

Definition at line 368 of file ncbi_core.h.

typedef void(* FLOG_Handler)(void *user_data, SLOG_Handler *call_data)
 

Log post callback.

Parameters:
user_data Unspeficied data as passed to LOG_Create() or LOG_Reset()
call_data Composed from arguments passed to LOG_WriteInternal()
See also:
SLOG_Handler, LOG_Create, LOG_Reset, LOG_WriteInternal

Definition at line 355 of file ncbi_core.h.

typedef void(* FMT_LOCK_Cleanup)(void *user_data)
 

MT lock cleanup callback.

Parameters:
user_data See "user_data" in MT_LOCK_Create()
See also:
MT_LOCK_Create, MT_LOCK_Delete

Definition at line 213 of file ncbi_core.h.

typedef int(* FMT_LOCK_Handler)(void *user_data, EMT_Lock how)
 

MT locking callback (operates like a [recursive] mutex or RW-lock).

Parameters:
user_data See "user_data" in MT_LOCK_Create()
how As passed to MT_LOCK_Do()
Returns:
Non-zero value if the requested operation was successful.
NOTE:
The "-1" value is reserved for unset handler; you also may want to return "-1" if your locking function does no locking, and you don't consider it as an error, but still want the caller to be ware of this "rightful non-doing" as opposed to the "rightful doing".
See also:
MT_LOCK_Create, MT_LOCK_Delete

Definition at line 202 of file ncbi_core.h.

typedef void(* FREG_Cleanup)(void *user_data)
 

Registry cleanup callback.

Parameters:
user_data Unspecified data as passed to REG_Create or REG_Reset
See also:
REG_Reset, REG_Delete

Definition at line 583 of file ncbi_core.h.

typedef void(* FREG_Get)(void *user_data, const char *section, const char *name, char *value, size_t value_size)
 

Registry getter callback.

Copy registry value stored in "section" under name "name" to buffer "value". Look for the matching entry first in the transient storage, and then in the persistent storage. Do not modify the "value" (leave it "as is", i.e. default) if the requested entry is not found in the registry.

NOTE:
Always terminate value by ''.
NOTE:
Do not put more than "value_size" bytes to "value".
Parameters:
user_data Unspecified data as passed to REG_Create or REG_Reset
section Section name to search
name Key name to search within the section
value Default value passed in (cut to "value_size") symbols, found value out
value_size Size of "value" storage, must be greater than 0
See also:
REG_Create, REG_Reset

Definition at line 541 of file ncbi_core.h.

typedef int(* FREG_Set)(void *user_data, const char *section, const char *name, const char *value, EREG_Storage storage)
 

Registry setter callback.

Store the "value" to the registry section "section" under name "name", and according to "storage".

Parameters:
user_data Unspecified data as passed to REG_Create or REG_Reset
section Section name to add the key to
name Key name to add to the section
value Key value to associate with the key
storage How to store the new setting, temporarily or permanently
Returns:
Non-zero if successful (including replacing a value with itself)
See also:
REG_Create, REG_Reset, EREG_Storage

Definition at line 568 of file ncbi_core.h.

typedef struct LOG_tag* LOG
 

Definition at line 282 of file ncbi_core.h.

typedef struct MT_LOCK_tag* MT_LOCK
 

Definition at line 168 of file ncbi_core.h.

typedef struct REG_tag* REG
 

Definition at line 505 of file ncbi_core.h.

typedef struct STimeoutTag STimeout
 

Timeout structure.

See also:
CTimeout, g_CTimeoutToSTimeout, g_STimeoutToCTimeout

typedef unsigned int TLOG_FormatFlags
 

binary OR of "ELOG_FormatFlags"

Definition at line 227 of file ncbi_util.h.

typedef unsigned int TNCBI_Size
 

Fixed size analogs of size_t and time_t (mainly for IPC).

Definition at line 113 of file ncbi_types.h.

typedef unsigned int TNCBI_Time
 

Definition at line 114 of file ncbi_types.h.


Enumeration Type Documentation

enum EConnectInitFlags
 

Enumerator:
eConnectInit_OwnNothing 
eConnectInit_OwnRegistry 
eConnectInit_OwnLock 

Definition at line 70 of file ncbi_core_cxx.hpp.

enum EDebugPrintout
 

Enumerator:
eDebugPrintout_None 
eDebugPrintout_Some 
eDebugPrintout_Data 

Definition at line 110 of file ncbi_connutil.h.

enum EIO_Event
 

I/O event (or direction).

NOTE:
Internally, these constants are used as bit-values, and thus should not be changed in this header. However, user code should not rely on the values of these constants.
See also:
SOCK_Wait, SOCK_Poll, CONN_Wait, SOCK_SetTimeout, CONN_SetTimeout
Enumerator:
eIO_Open  also serves as no-event indicator in SOCK_Poll
eIO_Read 
eIO_Write 
eIO_ReadWrite  eIO_Read | eIO_Write
eIO_Close  also serves as an error indicator in SOCK_Poll

Definition at line 118 of file ncbi_core.h.

enum EIO_ReadMethod
 

I/O read method.

See also:
EIO_WriteMethod
Enumerator:
eIO_ReadPlain  read presently available data only
eIO_ReadPeek  same eIO_ReadPlain but leave data in input queue
eIO_ReadPersist  try to read exactly "n" bytes; wait for enough data
eIO_Plain 
eIO_Peek 
eIO_Persist 

Definition at line 88 of file ncbi_core.h.

enum EIO_Status
 

I/O status.

Enumerator:
eIO_Success  everything is fine, no errors occurred
eIO_Timeout  timeout expired before any I/O succeeded
eIO_Closed  peer has closed the connection
eIO_Interrupt  signal received while an I/O was in progress
eIO_InvalidArg  bad argument value(s)
eIO_NotSupported  the requested operation is not supported
eIO_Unknown  unknown (most probably -- fatal) error

Definition at line 129 of file ncbi_core.h.

enum EIO_WriteMethod
 

I/O write method.

See also:
EIO_ReadMethod
Enumerator:
eIO_WritePlain  write as much as possible, report back how much
eIO_WritePersist  write exactly as much as specified
eIO_WriteOutOfBand  write out-of-band chunk of urgent data

Definition at line 103 of file ncbi_core.h.

enum ELOG_Format
 

LOG formatting flags: what parts of the message to actually appear.

See also:
CORE_SetLOGFormatFlags
Enumerator:
fLOG_Default  fLOG_Short if NDEBUG, else fLOG_Full
fLOG_Level 
fLOG_Module 
fLOG_FileLine  always here for eLOG_Trace level
fLOG_DateTime 
fLOG_FullOctal  do not do reduction in octal data bytes
fLOG_OmitNoteLevel  do not add NOTE if eLOG_Note is level
fLOG_None  nothing but spec'd parts, msg and data

Definition at line 216 of file ncbi_util.h.

enum ELOG_Level
 

Log severity level.

Enumerator:
eLOG_Trace 
eLOG_Note 
eLOG_Warning 
eLOG_Error 
eLOG_Critical 
eLOG_Fatal 

Definition at line 287 of file ncbi_core.h.

enum EMIME_Encoding
 

Enumerator:
eENCOD_None 
eENCOD_Url 
eENCOD_Unknown 

Definition at line 657 of file ncbi_connutil.h.

enum EMIME_SubType
 

Enumerator:
eMIME_Undefined 
eMIME_Dispatch 
eMIME_AsnText 
eMIME_AsnBinary 
eMIME_Fasta 
eMIME_WwwForm 
eMIME_Html 
eMIME_Plain 
eMIME_Xml 
eMIME_XmlSoap 
eMIME_OctetStream 
eMIME_Unknown 

Definition at line 637 of file ncbi_connutil.h.

enum EMIME_Type
 

Enumerator:
eMIME_T_Undefined 
eMIME_T_NcbiData 
eMIME_T_Text 
eMIME_T_Application 
eMIME_T_Unknown 

Definition at line 625 of file ncbi_connutil.h.

enum EMT_Lock
 

Set the lock/unlock callback function and its data for MT critical section.

TIP:
If the RW-lock functionality is not provided by the callback, then: eMT_LockRead <==> eMT_Lock
Enumerator:
eMT_Lock  lock critical section
eMT_LockRead  lock critical section for reading
eMT_Unlock  unlock critical section
eMT_TryLock  try to lock, return immediately
eMT_TryLockRead  try to lock for reading, return immediately

Definition at line 177 of file ncbi_core.h.

enum EREG_Storage
 

Transient/Persistent storage.

See also:
REG_Get, REG_Set
Enumerator:
eREG_Transient  only in-memory storage while program runs
eREG_Persistent  hard-copy storage across program runs

Definition at line 512 of file ncbi_core.h.

enum EReqMethod
 

Enumerator:
eReqMethod_Any 
eReqMethod_Post 
eReqMethod_Get 

Definition at line 103 of file ncbi_connutil.h.

enum ESwitch
 

Aux.

enum to set/unset/default various features

Enumerator:
eOff 
eOn 
eDefault 

Definition at line 102 of file ncbi_types.h.

enum EURLScheme
 

Enumerator:
eURL_Unspec 
eURL_Https 
eURL_Http 
eURL_File 
eURL_Ftp 

Definition at line 94 of file ncbi_connutil.h.


Function Documentation

EIO_Status BUF_StripToPattern BUF  buffer,
const void *  pattern,
size_t  pattern_size,
BUF buf,
size_t *  n_discarded
 

Definition at line 1543 of file ncbi_connutil.c.

References buf, buffer, s_BUF_IO(), and s_StripToPattern().

EIO_Status CONN_StripToPattern CONN  conn,
const void *  pattern,
size_t  pattern_size,
BUF buf,
size_t *  n_discarded
 

Definition at line 1479 of file ncbi_connutil.c.

References buf, s_CONN_IO(), and s_StripToPattern().

void CONNECT_Init IRWRegistry reg = 0,
CRWLock lock = 0,
FConnectInitFlags  flag = eConnectInit_OwnNothing
 

Definition at line 309 of file ncbi_core_cxx.cpp.

References eConnectInit_Explicit, NCBI_CATCH_ALL_X, and s_Init().

Referenced by CDemoApp::Init(), CSampleObjmgrApplication::Run(), CEditBioseqSampleApp::Run(), CSampleAlnmgrApplication::Run(), CPairwiseAlnApp::Run(), CAlnTestApp::Run(), CAlnBuildApp::Run(), CNCBIwxApplication::Run(), CId2FetchApp::Run(), CId1FetchApp::Run(), CCleanupApp::Run(), CAsn2FlatApp::Run(), CAsn2FastaApp::Run(), CAnnotWriterApp::Run(), and CAgpValidateApplication::Run().

int ConnNetInfo_AdjustForHttpProxy SConnNetInfo info  ) 
 

Definition at line 304 of file ncbi_connutil.c.

References CORE_LOGF_X, eLOG_Error, eURL_Http, eURL_Unspec, SConnNetInfo::host, SConnNetInfo::http_proxy_adjusted, SConnNetInfo::http_proxy_host, SConnNetInfo::http_proxy_port, len, memmove, SConnNetInfo::path, SConnNetInfo::port, s_Scheme(), SConnNetInfo::scheme, and strncpy0().

Referenced by s_CreateConnector().

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

Definition at line 728 of file ncbi_connutil.c.

References SConnNetInfo::args, and len.

Referenced by ConnNetInfo_PostOverrideArg().

int ConnNetInfo_AppendUserHeader SConnNetInfo info,
const char *  header
 

Definition at line 529 of file ncbi_connutil.c.

References ConnNetInfo_SetUserHeader(), SConnNetInfo::http_user_header, and realloc().

SConnNetInfo* ConnNetInfo_Clone const SConnNetInfo info  ) 
 

Definition at line 941 of file ncbi_connutil.c.

References ConnNetInfo_SetUserHeader(), SConnNetInfo::http_referer, SConnNetInfo::http_user_header, kDefaultTimeout, malloc(), SConnNetInfo::service, strdup, SConnNetInfo::timeout, and SConnNetInfo::tmo.

Referenced by s_CreateConnector(), s_HttpConnectorBuilder(), s_ServiceConnectorBuilder(), s_VT_Open(), SERV_DISPD_Open(), and SERVICE_CreateConnectorEx().

SConnNetInfo* ConnNetInfo_Create const char *  service  ) 
 

Definition at line 143 of file ncbi_connutil.c.

References ConnNetInfo_GetValue(), DEF_CONN_ARGS, DEF_CONN_DEBUG_PRINTOUT, DEF_CONN_FIREWALL, DEF_CONN_HOST, DEF_CONN_HTTP_PROXY_HOST, DEF_CONN_HTTP_PROXY_PORT, DEF_CONN_HTTP_REFERER, DEF_CONN_HTTP_USER_HEADER, DEF_CONN_LB_DISABLE, DEF_CONN_MAX_TRY, DEF_CONN_PASS, DEF_CONN_PATH, DEF_CONN_PORT, DEF_CONN_PROXY_HOST, DEF_CONN_REQ_METHOD, DEF_CONN_SCHEME, DEF_CONN_STATELESS, DEF_CONN_TIMEOUT, DEF_CONN_USER, eDebugPrintout_Data, eDebugPrintout_None, eDebugPrintout_Some, eReqMethod_Any, eReqMethod_Get, eReqMethod_Post, errno, len, malloc(), REG_CONN_ARGS, REG_CONN_DEBUG_PRINTOUT, REG_CONN_FIREWALL, REG_CONN_HOST, REG_CONN_HTTP_PROXY_HOST, REG_CONN_HTTP_PROXY_PORT, REG_CONN_HTTP_REFERER, REG_CONN_HTTP_USER_HEADER, REG_CONN_LB_DISABLE, REG_CONN_MAX_TRY, REG_CONN_PASS, REG_CONN_PATH, REG_CONN_PORT, REG_CONN_PROXY_HOST, REG_CONN_REQ_METHOD, REG_CONN_SCHEME, REG_CONN_STATELESS, REG_CONN_TIMEOUT, REG_CONN_USER, REG_VALUE, s_ParseScheme(), strcasecmp, util::strcmp(), strdup, and strncasecmp.

Referenced by CReaderServiceConnector::Connect(), ConnNetInfo_ParseURL(), SNetServiceImpl::DiscoverServers(), s_CreateConnector(), s_HttpConnectorBuilder(), s_ServiceConnectorBuilder(), SERV_OpenSimple(), SERVICE_CreateConnectorEx(), CRPCClient< TRequest, TReply >::x_Connect(), and CBlastHitMatrixCGIApplication::x_GetSeqAnnot().

void ConnNetInfo_DeleteAllArgs SConnNetInfo info,
const char *  args
 

Definition at line 815 of file ncbi_connutil.c.

References SConnNetInfo::args, ConnNetInfo_DeleteArg(), free(), and strdup.

Referenced by ConnNetInfo_PostOverrideArg(), ConnNetInfo_PreOverrideArg(), and s_AdjustNetParams().

void ConnNetInfo_DeleteArg SConnNetInfo info,
const char *  arg
 

Definition at line 786 of file ncbi_connutil.c.

References SConnNetInfo::args, memmove, and strncasecmp.

Referenced by ConnNetInfo_DeleteAllArgs(), and ConnNetInfo_SetupStandardArgs().

void ConnNetInfo_DeleteUserHeader SConnNetInfo info,
const char *  hdr
 

Definition at line 714 of file ncbi_connutil.c.

References eUserHeaderOp_Delete, s_ModifyUserHeader(), and verify.

Referenced by s_Open(), and s_Resolve().

void ConnNetInfo_Destroy SConnNetInfo info  ) 
 

Definition at line 1151 of file ncbi_connutil.c.

References ConnNetInfo_SetUserHeader(), free(), and SConnNetInfo::http_referer.

Referenced by ConnNetInfo_ParseURL(), ConnNetInfoDeleter::Delete(), ConnInfoDeleter2::Delete(), SNetServiceImpl::DiscoverServers(), s_Close(), s_CreateConnector(), s_Destroy(), s_HttpConnectorBuilder(), s_ServiceConnectorBuilder(), s_VT_Open(), and SERV_OpenSimple().

int ConnNetInfo_ExtendUserHeader SConnNetInfo info,
const char *  header
 

Definition at line 721 of file ncbi_connutil.c.

References eUserHeaderOp_Extend, and s_ModifyUserHeader().

Referenced by s_Connect(), s_Open(), SERV_DISPD_Open(), and x_SetupUserAgent().

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

Definition at line 44 of file ncbi_connutil.c.

References buf, CORE_REG_GET, DEF_CONN_REG_SECTION, strncpy0(), and strupr.

Referenced by ConnNetInfo_Create(), s_CreateConnector(), s_IsMapperConfigured(), s_LoadServices(), and s_Open().

void ConnNetInfo_Log const SConnNetInfo info,
LOG  log
 

Definition at line 1037 of file ncbi_connutil.c.

References eDebugPrintout_Data, eDebugPrintout_None, eDebugPrintout_Some, eLOG_Error, eLOG_Trace, eReqMethod_Any, eReqMethod_Get, eReqMethod_Post, free(), SConnNetInfo::http_user_header, LOG_Write(), LOG_WRITE, malloc(), NCBI_C_ERRCODE_X, s_PortStr(), s_SaveBool(), s_SaveKeyval(), s_SaveString(), s_SaveULong(), s_SaveUserHeader(), s_SchemeStr(), and UTIL_PrintableStringSize().

Referenced by s_Connect().

int ConnNetInfo_OverrideUserHeader SConnNetInfo info,
const char *  header
 

Definition at line 707 of file ncbi_connutil.c.

References eUserHeaderOp_Override, and s_ModifyUserHeader().

Referenced by s_CreateConnector(), s_HttpConnectorBuilder(), s_Open(), and s_Resolve().

int ConnNetInfo_ParseURL SConnNetInfo info,
const char *  url
 

Definition at line 360 of file ncbi_connutil.c.

References SConnNetInfo::args, ConnNetInfo_Create(), ConnNetInfo_Destroy(), ConnNetInfo_ParseURL(), eURL_Unspec, SConnNetInfo::host, SConnNetInfo::http_proxy_adjusted, len, memmove, SConnNetInfo::pass, SConnNetInfo::path, SConnNetInfo::port, s_ParseScheme(), SConnNetInfo::scheme, SConnNetInfo::service, strncpy0(), and SConnNetInfo::user.

Referenced by ConnNetInfo_ParseURL(), s_Adjust(), and s_HttpConnectorBuilder().

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

Definition at line 850 of file ncbi_connutil.c.

References ConnNetInfo_AppendArg(), and ConnNetInfo_DeleteAllArgs().

Referenced by CRPCClient< TRequest, TReply >::x_Connect().

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

Definition at line 839 of file ncbi_connutil.c.

References ConnNetInfo_DeleteAllArgs(), and ConnNetInfo_PrependArg().

Referenced by ConnNetInfo_SetupStandardArgs().

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

Definition at line 757 of file ncbi_connutil.c.

References SConnNetInfo::args, len, and memmove.

Referenced by ConnNetInfo_PreOverrideArg(), and s_AdjustNetParams().

int ConnNetInfo_SetupStandardArgs SConnNetInfo info,
const char *  service
 

Definition at line 897 of file ncbi_connutil.c.

References ConnNetInfo_DeleteArg(), ConnNetInfo_PreOverrideArg(), CORE_GetPlatform(), free(), s_ClientAddress(), SOCK_gethostbyaddr(), and SOCK_gethostname().

Referenced by SERV_DISPD_Open(), and SERVICE_CreateConnectorEx().

int ConnNetInfo_SetUserHeader SConnNetInfo info,
const char *  header
 

Definition at line 515 of file ncbi_connutil.c.

References free(), SConnNetInfo::http_user_header, and strdup.

Referenced by ConnNetInfo_AppendUserHeader(), ConnNetInfo_Clone(), ConnNetInfo_Destroy(), and s_Connect().

char* ConnNetInfo_URL const SConnNetInfo info  ) 
 

Definition at line 1120 of file ncbi_connutil.c.

References SConnNetInfo::args, eURL_Unspec, SConnNetInfo::host, SConnNetInfo::http_proxy_adjusted, len, malloc(), SConnNetInfo::path, SConnNetInfo::port, s_Scheme(), and SConnNetInfo::scheme.

Referenced by s_SetDefaultReferer(), and s_VT_Descr().

MT_LOCK CORE_GetLOCK void   ) 
 

Definition at line 90 of file ncbi_util.c.

References g_CORE_MT_Lock.

LOG CORE_GetLOG void   ) 
 

Get the log handle which is be used by the core internals.

Returns:
LOG handle as set by CORE_SetLOG or NULL if no logging is currently active
  • NOTE: You may not delete the handle (by means of LOG_Delete).
See also:
CORE_SetLOG, LOG_Create, LOG_Delete

Definition at line 115 of file ncbi_util.c.

References g_CORE_Log.

Referenced by s_Connect(), and s_DoLog().

const char* CORE_GetPlatform void   ) 
 

Returns:
Return read-only textual but machine-readable platform description.

Definition at line 589 of file ncbi_util.c.

References HOST.

Referenced by ConnNetInfo_SetupStandardArgs().

REG CORE_GetREG void   ) 
 

Get the registry previously set by CORE_SetREG().

Returns:
Registry handle. NOTE: You may not delete the handle with REG_Delete().
See also:
CORE_SetREG

Definition at line 578 of file ncbi_util.c.

References g_CORE_Registry.

Referenced by GetAsnDataViaHTTP().

const char* CORE_GetUsername char *  buf,
size_t  bufsize
 

Obtain and store current user's name in the buffer provided.

NCBI_OS_UNIX

Definition at line 604 of file ncbi_util.c.

References CORE_LOCK_WRITE, CORE_UNLOCK, and strncpy0().

Referenced by s_MakeFrom(), and SetDiagUserAndHost().

size_t CORE_GetVMPageSize void   ) 
 

Obtain virtual memory page size.

Returns:
0 if the page size cannot be determined.

Definition at line 718 of file ncbi_util.c.

References NCBI_OS_UNIX, and si.

void CORE_SetLOCK MT_LOCK  lk  ) 
 

Set the MT critical section lock/unlock handler -- to be used by the core internals for protection of internal static variables and other MT-sensitive code from being accessed/changed by several threads simultaneously.

It is also to fully protect the core log handler, including its setting up, and its callback and cleanup functions.

  • NOTES: This function itself is NOT MT-safe!
  • NOTES: If there is an active CORE MT-lock set already, which is different from the new one, then MT_LOCK_Delete() is called for the old lock (i.e. the one being replaced).
    Parameters:
    lk MT-Lock as created by MT_LOCK_Create
    See also:
    MT_LOCK_Create, CORE_SetLOG

Definition at line 80 of file ncbi_util.c.

References g_CORE_MT_Lock, and MT_LOCK_Delete().

Referenced by s_Fini(), and s_Init().

void CORE_SetLOG LOG  lg  ) 
 

Set the log handle (no logging if "lg" is passed zero) -- to be used by the core internals.

If there is an active log handler set already, and it is different from the new one, then LOG_Delete is called for the old logger (that is, the one being replaced).

Parameters:
lg LOG handle as returned by LOG_Create, or NULL to stop logging
See also:
LOG_Create, LOG_Delete, CORE_GetLOG

Definition at line 102 of file ncbi_util.c.

References CORE_LOCK_WRITE, CORE_UNLOCK, g_CORE_Log, and LOG_Delete().

Referenced by CORE_SetLOGFILE_Ex(), s_Fini(), s_Init(), and CAsnvalApp::Setup().

void CORE_SetLOGFILE FILE *  fp,
int  auto_close
 

Same as CORE_SetLOGFILE_Ex() with last parameter passed as 0 (all messages pass).

See also:
CORE_SetLOGFILE_Ex, CORE_SetLOG

Definition at line 134 of file ncbi_util.c.

References CORE_SetLOGFILE_Ex(), and eLOG_Trace.

void CORE_SetLOGFILE_Ex FILE *  fp,
ELOG_Level  cut_off,
int  auto_close
 

Standard logging to the specified file stream.

Parameters:
fp The file stream to log to
cut_off Do not post messages with severity levels lower than specified
auto_close Do "fclose(fp)" when the LOG is reset/destroyed
See also:
LOG_ToFILE_Ex, CORE_SetLOG

Definition at line 122 of file ncbi_util.c.

References CORE_SetLOG(), LOG_Create(), and LOG_ToFILE_Ex().

Referenced by CORE_SetLOGFILE(), and CORE_SetLOGFILE_NAME_Ex().

int CORE_SetLOGFILE_NAME const char *  filename  ) 
 

Same as CORE_SetLOGFILE_NAME_Ex with last parameter passed as 0 (all messages pass).

See also:
CORE_SetLOGFILE_NAME_Ex, CORE_SetLOG

Definition at line 158 of file ncbi_util.c.

References CORE_SetLOGFILE_NAME_Ex(), and eLOG_Trace.

int CORE_SetLOGFILE_NAME_Ex const char *  filename,
ELOG_Level  cut_off
 

Same as CORE_SetLOGFILE_Ex(fopen(filename, "a"), cut_off, TRUE).

Parameters:
filename Filename to write the log into
cut_off Do not post messages with severity levels lower than specified
Returns:
Return zero on error, non-zero on success
See also:
CORE_SetLOGFILE_Ex, CORE_SetLOG

Definition at line 142 of file ncbi_util.c.

References CORE_LOGF_ERRNO_X, CORE_SetLOGFILE_Ex(), eLOG_Error, and errno.

Referenced by CORE_SetLOGFILE_NAME().

TLOG_FormatFlags CORE_SetLOGFormatFlags TLOG_FormatFlags   ) 
 

Definition at line 167 of file ncbi_util.c.

void CORE_SetREG REG  rg  ) 
 

Set the registry (no registry if "rg" is passed zero) -- to be used by the core internals.

If there is an active registry set already, and it is different from the new one, then REG_Delete() is called for the old(replaced) registry.

Parameters:
rg Registry handle as returned by REG_Create()
See also:
REG_Create, CORE_GetREG

Definition at line 565 of file ncbi_util.c.

References CORE_LOCK_WRITE, CORE_UNLOCK, g_CORE_Registry, and REG_Delete().

Referenced by GetAsnDataViaHTTP(), s_Fini(), s_Init(), and CAsnvalApp::Setup().

unsigned int CRC32_Update unsigned int  checksum,
const void *  ptr,
size_t  count
 

Calculate/Update CRC32.

Parameters:
checksum Checksum to update (start with 0)
ptr Block of data
count Size of data
Returns:
Return the checksum updated according to the contents of the block pointed to by "ptr" and having "count" bytes in it.

Definition at line 862 of file ncbi_util.c.

const STimeout * g_CTimeoutToSTimeout const CTimeout cto,
STimeout sto
[inline]
 

Convert CTimeout to STimeout.

Parameters:
cto Timeout value to convert.
sto Variable used to store numeric timeout value.
Returns:
A special constants kDefaultTimeout or kInfiniteTimeout, if timeout have default or infinite value accordingly. A pointer to "sto" object, if timeout have numeric value. "sto" will be used to store numeric value.
See also:
CTimeout, STimeout

Definition at line 125 of file ncbi_core_cxx.hpp.

References CTimeout::Get(), CTimeout::IsDefault(), CTimeout::IsInfinite(), kDefaultTimeout, kInfiniteTimeout, STimeoutTag::sec, and STimeoutTag::usec.

Referenced by CEUtils_Request::Connect().

CTimeout g_STimeoutToCTimeout const STimeout sto  )  [inline]
 

Convert STimeout to CTimeout.

See also:
CTimeout, STimeout

Definition at line 138 of file ncbi_core_cxx.hpp.

References CTimeout::eDefault, CTimeout::eInfinite, kDefaultTimeout, kInfiniteTimeout, STimeoutTag::sec, and STimeoutTag::usec.

const char* IO_StatusStr EIO_Status  status  ) 
 

Get the text form of an enum status value.

Parameters:
status An enum value to get the text form for
Returns:
Verbal description of the I/O status
See also:
EIO_Status

Definition at line 43 of file ncbi_core.c.

References eIO_Success, and eIO_Unknown.

Referenced by SNetServerImpl::Connect(), CThreadedServer::Run(), s_Close(), s_Open(), s_Resolve(), s_Shutdown(), s_VT_Open(), s_WritePending(), URL_ConnectEx(), CConn_Streambuf::x_Cleanup(), and CConn_Streambuf::x_LogIfError().

LOG LOG_AddRef LOG  lg  ) 
 

Increment internal reference counter by 1, then return "lg".

Parameters:
lg A log handle previously obtained from LOG_Create
See also:
LOG_Create

Definition at line 222 of file ncbi_core.c.

References LOG_LOCK_WRITE, LOG_UNLOCK, LOG_VALID, and LOG_tag::ref_count.

char* LOG_ComposeMessage const SLOG_Handler call_data,
TLOG_FormatFlags  format_flags
 

Compose message using the "call_data" info.

Full log record format: mm/dd/yy HH:MM:SS "<file>", line <line>: [<module>] <level>: <message>
----- [BEGIN] Raw Data (<raw_size> bytes) -----
<raw_data>
----- [END] Raw Data -----

  • NOTE: the returned string must be deallocated using "free()".
    Parameters:
    call_data Parts of the message
    format_flags Which fields of "call_data" to use
    See also:
    CORE_SetLOG, CORE_SetLOGFormatFlags

Definition at line 347 of file ncbi_util.c.

References eLOG_Note, eLOG_Trace, SLOG_Handler::file, fLOG_DateTime, fLOG_Default, fLOG_FileLine, fLOG_Full, fLOG_Level, fLOG_Module, fLOG_None, fLOG_OmitNoteLevel, fLOG_Short, SLOG_Handler::level, LOG_LevelStr(), malloc(), SLOG_Handler::message, SLOG_Handler::module, SLOG_Handler::raw_data, SLOG_Handler::raw_size, and UTIL_PrintableStringSize().

Referenced by s_LOG_FileHandler().

LOG LOG_Create void *  user_data,
FLOG_Handler  handler,
FLOG_Cleanup  cleanup,
MT_LOCK  mt_lock
 

Create new LOG (with an internal reference counter set to 1).

ATTENTION:
If non-NULL "mt_lock" is specified then MT_LOCK_Delete() will be called on it when this LOG gets deleted -- be aware of it (hence, if the lock is also to be used with something else, then call MT_LOCK_AddRef() on it before passing to LOG_Create)!
Parameters:
user_data Unspecified data to call "handler" and "cleanup" with
handler Log post callback
cleanup Cleanup callback
mt_lock Protective MT lock (can be NULL)
See also:
MT_LOCK, MT_LOCK_AddRef, FLOG_Handler, FLOG_Cleanup, LOG_Reset, LOG_Delete

Definition at line 182 of file ncbi_core.c.

References LOG_tag::cleanup, LOG_tag::handler, LOG_tag::magic_number, malloc(), LOG_tag::mt_lock, LOG_tag::ref_count, and LOG_tag::user_data.

Referenced by CORE_SetLOGFILE_Ex(), and LOG_cxx2c().

LOG LOG_cxx2c void   ) 
 

Definition at line 177 of file ncbi_core_cxx.cpp.

References LOG_Create(), and s_LOG_Handler().

Referenced by s_Init(), and CAsnvalApp::Setup().

LOG LOG_Delete LOG  lg  ) 
 

Decrement internal reference counter by 1, and if it reaches 0, then call "lg->cleanup(lg->user_data)", destroy the handle, and return NULL; otherwise (if reference counter is still > 0), return "lg".

Parameters:
lg A log handle previously obtained from LOG_Create
See also:
LOG_Create

Definition at line 234 of file ncbi_core.c.

References free(), LOG_LOCK_WRITE, LOG_Reset(), LOG_UNLOCK, LOG_VALID, LOG_tag::magic_number, LOG_tag::mt_lock, MT_LOCK_Delete(), and LOG_tag::ref_count.

Referenced by CORE_SetLOG().

const char* LOG_LevelStr ELOG_Level  level  ) 
 

Obtain verbal representation of an enum level value.

Parameters:
level An enum value to get the text form for
Returns:
Verbal description of the log level
See also:
ELOG_Level

Definition at line 167 of file ncbi_core.c.

References eLOG_Fatal.

Referenced by LOG_ComposeMessage().

LOG LOG_Reset LOG  lg,
void *  user_data,
FLOG_Handler  handler,
FLOG_Cleanup  cleanup
 

Reset the "lg" to use the new "user_data", "handler" and "cleanup".

NOTE:
It does not change the reference counter of the log.
Parameters:
lg A log handle previously obtained from LOG_Create
user_data New user data
handler New log post callback
cleanup New cleanup callback
Returns:
lg (as passed in the first parameter)
See also:
LOG_Create

Definition at line 202 of file ncbi_core.c.

References LOG_tag::cleanup, LOG_tag::handler, LOG_LOCK_WRITE, LOG_UNLOCK, LOG_VALID, and LOG_tag::user_data.

Referenced by LOG_Delete(), and LOG_ToFILE_Ex().

void LOG_ToFILE LOG  lg,
FILE *  fp,
int  auto_close
 

Same as LOG_ToFILEx with "cut_off" parameter passed as 0 (all messages pass).

See also:
LOG_ToFILE_Ex

Definition at line 551 of file ncbi_util.c.

References eLOG_Trace, and LOG_ToFILE_Ex().

void LOG_ToFILE_Ex LOG  lg,
FILE *  fp,
ELOG_Level  cut_off,
int  auto_close
 

LOG_Reset specialized to log to a "FILE*" stream using LOG_ComposeMessage.

Parameters:
lg Created by LOG_Create
fp The file stream to log to
cut_off Do not post messages with severity levels lower than specified
auto_close Whether to do "fclose(fp)" when the LOG is reset/destroyed
See also:
LOG_Create, LOG_Reset, LOG_ComposeMessage, LOG_ToFILE

Definition at line 532 of file ncbi_util.c.

References LOG_Reset(), malloc(), s_LOG_FileCleanup(), and s_LOG_FileHandler().

Referenced by CORE_SetLOGFILE_Ex(), and LOG_ToFILE().

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

Write message (perhaps with raw data attached) to the log by calling LOG_WriteInternal() upon filling up SLOG_Handler data from parameters.

NOTE:
Do not call this function directly, if possible. Instead, use LOG_WRITE() and LOG_DATA() macros from <ncbi_util.h>!
Parameters:
code Error code of the message
subcode Error subcode of the message
level The message severity
module Module name (can be NULL)
file Source file name (can be NULL)
line Source line within the file (can be 0 to omit the line number)
message Message content
raw_data Raw data to log (can be NULL)
raw_size Size of the raw data (can be zero)
See also:
LOG_Create, ELOG_Level, FLOG_Handler, LOG_WriteInternal

Definition at line 292 of file ncbi_core.c.

References SLOG_Handler::dynamic, SLOG_Handler::err_code, SLOG_Handler::err_subcode, SLOG_Handler::file, SLOG_Handler::level, SLOG_Handler::line, LOG_WriteInternal(), SLOG_Handler::message, SLOG_Handler::module, SLOG_Handler::raw_data, and SLOG_Handler::raw_size.

Referenced by ConnNetInfo_Log().

void LOG_WriteInternal LOG  lg,
SLOG_Handler call_data
 

Write message (perhaps with raw data attached) to the log by calling "lg->handler(lg->user_data, call_data)".

NOTE:
Do not call this function directly, if possible. Instead, use LOG_WRITE() and LOG_DATA() macros from <ncbi_util.h>!
Parameters:
lg A log handle previously obtained from LOG_Create
See also:
LOG_Create, ELOG_Level, FLOG_Handler, LOG_WRITE, LOG_DATA

Definition at line 261 of file ncbi_core.c.

References SLOG_Handler::dynamic, eLOG_Fatal, free(), LOG_tag::handler, SLOG_Handler::level, LOG_LOCK_READ, LOG_UNLOCK, LOG_VALID, SLOG_Handler::message, SLOG_Handler::raw_data, SLOG_Handler::raw_size, and LOG_tag::user_data.

Referenced by LOG_Write().

char* MIME_ComposeContentType EMIME_SubType  subtype,
EMIME_Encoding  encoding,
char *  buf,
size_t  buflen
 

Definition at line 1872 of file ncbi_connutil.c.

References eMIME_T_NcbiData, and MIME_ComposeContentTypeEx().

char* MIME_ComposeContentTypeEx EMIME_Type  type,
EMIME_SubType  subtype,
EMIME_Encoding  encoding,
char *  buf,
size_t  buflen
 

Definition at line 1751 of file ncbi_connutil.c.

References eENCOD_Unknown, eMIME_T_Undefined, eMIME_T_Unknown, eMIME_Undefined, eMIME_Unknown, MAX_CONTENT_TYPE_LEN, and strncpy0().

Referenced by MIME_ComposeContentType(), s_AdjustNetParams(), s_IsContentTypeDefined(), and SERV_WriteInfo().

int MIME_ParseContentType const char *  str,
EMIME_SubType subtype,
EMIME_Encoding encoding
 

Definition at line 1884 of file ncbi_connutil.c.

References eENCOD_Unknown, eMIME_T_NcbiData, eMIME_Unknown, and MIME_ParseContentTypeEx().

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

Definition at line 1796 of file ncbi_connutil.c.

References eENCOD_None, eMIME_T_Undefined, eMIME_T_Unknown, eMIME_Undefined, free(), malloc(), util::strcmp(), and strlwr.

Referenced by MIME_ParseContentType(), s_IsContentTypeDefined(), and SERV_ReadInfoEx().

MT_LOCK MT_LOCK_AddRef MT_LOCK  lk  ) 
 

Increment internal reference counter by 1, then return "lk".

Parameters:
lk A handle previously obtained from MT_LOCK_Create
See also:
MT_LOCK_Create, MT_LOCK_Delete

Definition at line 99 of file ncbi_core.c.

References MT_LOCK_VALID, and MT_LOCK_tag::ref_count.

MT_LOCK MT_LOCK_Create void *  user_data,
FMT_LOCK_Handler  handler,
FMT_LOCK_Cleanup  cleanup
 

Create new MT lock (with an internal reference counter set to 1).

Parameters:
user_data Unspecified data to call "handler" and "cleanup" with
handler Locking callback
cleanup Cleanup callback
See also:
FMT_LOCK_Handler, FMT_LOCK_Cleanup, MT_LOCK_Delete

Definition at line 82 of file ncbi_core.c.

References MT_LOCK_tag::cleanup, MT_LOCK_tag::handler, kMT_LOCK_magic_number, MT_LOCK_tag::magic_number, malloc(), MT_LOCK_tag::ref_count, and MT_LOCK_tag::user_data.

Referenced by Blast_CMT_LOCKInit(), and MT_LOCK_cxx2c().

MT_LOCK MT_LOCK_cxx2c CRWLock lock = 0,
bool  pass_ownership = false
 

Definition at line 236 of file ncbi_core_cxx.cpp.

References MT_LOCK_Create(), s_LOCK_Cleanup(), and s_LOCK_Handler().

Referenced by s_Init().

MT_LOCK MT_LOCK_Delete MT_LOCK  lk  ) 
 

Decrement internal reference counter by 1, and if it reaches 0, then destroy the handle, call "lk->cleanup(lk->user_data)", and return NULL; otherwise (if the reference counter is still > 0), return "lk".

Parameters:
lk A handle previously obtained from MT_LOCK_Create
See also:
MT_LOCK_Create, FMT_LOCK_Cleanup

Definition at line 107 of file ncbi_core.c.

References MT_LOCK_tag::cleanup, eMT_Lock, eMT_Unlock, free(), MT_LOCK_tag::handler, MT_LOCK_tag::magic_number, MT_LOCK_VALID, MT_LOCK_tag::ref_count, MT_LOCK_tag::user_data, and verify.

Referenced by Blast_DiagnosticsFree(), BlastHSPStreamClose(), BlastHSPStreamFree(), BlastHSPStreamRegisterMTLock(), CORE_SetLOCK(), LOG_Delete(), and REG_Delete().

int MT_LOCK_DoInternal MT_LOCK  lk,
EMT_Lock  how
 

Definition at line 130 of file ncbi_core.c.

References MT_LOCK_tag::handler, MT_LOCK_VALID, and MT_LOCK_tag::user_data.

const char* NcbiMessagePlusError int *  dynamic,
const char *  message,
int  error,
const char *  descr
 

Add current "error" (and maybe its description) to the message: <message>[ {error=[[<error>][,]][<descr>]}].

Parameters:
dynamic [inout] non-zero pointed value means message was allocated from heap
message [in] message text (can be NULL)
error [in] error code (if it is zero, then use "descr" only if non-NULL/empty)
descr [in] error description (if NULL, then use "strerror(error)" if error!=0)
Returns:
Always non-NULL message (perhaps, "") and re-set "*dynamic" as appropriate.
  • NOTE: this routine may call "free(message)" if it had to reallocate the original message that had been allocated dynamically before the call (and "*dynamic" thus had been passed non-zero).
See also:
LOG_ComposeMessage

Definition at line 289 of file ncbi_util.c.

References buf, free(), malloc(), realloc(), and strerror().

STimeout* NcbiMsToTimeout STimeout timeout,
unsigned long  ms
 

Definition at line 48 of file ncbi_types.c.

References STimeoutTag::sec, and STimeoutTag::usec.

Referenced by CPipe::ExecWait(), and s_GetDefaultCommTimeout().

unsigned long NcbiTimeoutToMs const STimeout timeout  ) 
 

Definition at line 40 of file ncbi_types.c.

References STimeoutTag::sec, and STimeoutTag::usec.

Referenced by s_Close().

REG REG_AddRef REG  rg  ) 
 

Increment internal reference counter by 1, then return "rg".

Parameters:
rg Registry handle as previously obtained from REG_Create
See also:
REG_Create

Definition at line 395 of file ncbi_core.c.

References REG_tag::ref_count, REG_LOCK_WRITE, REG_UNLOCK, and REG_VALID.

REG REG_Create void *  user_data,
FREG_Get  get,
FREG_Set  set,
FREG_Cleanup  cleanup,
MT_LOCK  mt_lock
 

Create new registry (with an internal reference counter set to 1).

ATTENTION:
if non-NULL "mt_lock" is specified then MT_LOCK_Delete() will be called on it when this REG gets destroyed -- be aware of it (hence, if the lock is also to be used with something else, then call MT_LOCK_AddRef() on it before passing to REG_Create)! Passing NULL callbacks below causes limiting the functionality only to those operations that have the callbacks set.
Parameters:
user_data Unspecified data to call "set", "get" and "cleanup" with
get Getter callback
set Setter callback
cleanup Cleanup callback
mt_lock Protective MT lock (can be NULL)
See also:
MT_LOCK, MT_LOCK_AddRef, REG_Get, REG_Set, REG_Reset, REG_Delete

Definition at line 351 of file ncbi_core.c.

References REG_tag::cleanup, REG_tag::get, REG_tag::magic_number, malloc(), REG_tag::mt_lock, REG_tag::ref_count, REG_tag::set, and REG_tag::user_data.

Referenced by REG_cxx2c().

REG REG_cxx2c IRWRegistry reg,
bool  pass_ownership = false
 

NB: now that registries are CObjects, any we "own" will be deleted if and only if nothing else still holds a reference to them.

Definition at line 104 of file ncbi_core_cxx.cpp.

References CObject::AddReference(), REG_Create(), s_REG_Cleanup(), s_REG_Get(), and s_REG_Set().

Referenced by GetAsnDataViaHTTP(), s_Init(), and CAsnvalApp::Setup().

REG REG_Delete REG  rg  ) 
 

Decrement internal referecne counter by 1, and if it reaches 0, then call "rg->cleanup(rg->user_data)", destroy the handle, and return NULL; otherwise (if the reference counter is still > 0), return "rg".

Parameters:
rg Registry handle as previously obtained from REG_Create
See also:
REG_Create

Definition at line 407 of file ncbi_core.c.

References free(), REG_tag::magic_number, REG_tag::mt_lock, MT_LOCK_Delete(), REG_tag::ref_count, REG_LOCK_WRITE, REG_Reset(), REG_UNLOCK, and REG_VALID.

Referenced by CORE_SetREG().

const char* REG_Get REG  rg,
const char *  section,
const char *  name,
char *  value,
size_t  value_size,
const char *  def_value
 

Copy the registry value stored in "section" under name "name" to buffer "value"; if the entry is found in both transient and persistent storages, then copy the one from the transient storage.

If the specified entry is not found in the registry (or if there is no registry defined), and "def_value" is not NULL, then copy "def_value" to "value" (although, only up to "value_size" characters).

Parameters:
rg Registry handle as previously obtained from REG_Create
section Registry section name
name Registry entry name
value Buffer to put the value of the requested entry to
value_size Maximal size of buffer "value"
def_value Default value (none if passed NULL)
Returns:
Return "value" (however, if "value_size" is zero, then return NULL). If non-NULL, the returned "value" will be terminated by ''.
See also:
REG_Create, REG_Set

Definition at line 434 of file ncbi_core.c.

References REG_tag::get, REG_LOCK_READ, REG_UNLOCK, REG_VALID, strncpy0(), and REG_tag::user_data.

Referenced by g_CORE_RegistryGET().

void REG_Reset REG  rg,
void *  user_data,
FREG_Get  get,
FREG_Set  set,
FREG_Cleanup  cleanup,
int  do_cleanup
 

Reset the registry handle to use the new "user_data", "set", "get", and "cleanup".

NOTE:
No change to the internal reference counter.
Parameters:
rg Registry handle as previously obtained from REG_Create
user_data New user data
get New getter callback
set New setter callback
cleanup New cleanup callback
do_cleanup Whether to call old cleanup (if any specified) for old data
See also:
REG_Create, REG_Delete

Definition at line 373 of file ncbi_core.c.

References REG_tag::cleanup, REG_tag::get, REG_LOCK_WRITE, REG_UNLOCK, REG_VALID, REG_tag::set, and REG_tag::user_data.

Referenced by REG_Delete().

int REG_Set REG  rg,
const char *  section,
const char *  name,
const char *  value,
EREG_Storage  storage
 

Store the "value" to the registry section "section" under name "name", and according with "storage".

Parameters:
rg Registry handle as previously obtained from REG_Create
section Section name to store the value into
name Name to store the value under
value The value to store
storage Whether to store temporarily or permanently
Returns:
Non-zero if successful (including replacing a value with itself)
See also:
REG_Create, EREG_Storage, REG_Get

Definition at line 464 of file ncbi_core.c.

References REG_LOCK_READ, REG_UNLOCK, REG_VALID, REG_tag::set, and REG_tag::user_data.

EIO_Status SOCK_StripToPattern SOCK  sock,
const void *  pattern,
size_t  pattern_size,
BUF buf,
size_t *  n_discarded
 

Definition at line 1509 of file ncbi_connutil.c.

References buf, s_SOCK_IO(), and s_StripToPattern().

SOCK URL_Connect const char *  host,
unsigned short  port,
const char *  path,
const char *  args,
EReqMethod  req_method,
size_t  content_length,
const STimeout c_timeout,
const STimeout rw_timeout,
const char *  user_header,
int  encode_args,
TSOCK_Flags  flags
 

Definition at line 1330 of file ncbi_connutil.c.

References eIO_Success, and URL_ConnectEx().

EIO_Status URL_ConnectEx const char *  host,
unsigned short  port,
const char *  path,
const char *  args,
EReqMethod  req_method,
size_t  content_length,
const STimeout c_timeout,
const STimeout rw_timeout,
const char *  user_header,
int  encode_args,
TSOCK_Flags  flags,
SOCK sock
 

Definition at line 1171 of file ncbi_connutil.c.

References buf, BUF_Destroy(), BUF_Read(), BUF_Size(), BUF_Write(), CORE_LOG_X, CORE_LOGF_ERRNO_X, CORE_LOGF_X, eIO_InvalidArg, eIO_ReadWrite, eIO_Success, eIO_Timeout, eIO_Unknown, eLOG_Error, eLOG_Warning, eReqMethod_Any, eReqMethod_Get, eReqMethod_Post, errno, free(), fSOCK_Secure, IO_StatusStr(), malloc(), STimeoutTag::sec, size, SOCK_CreateEx(), SOCK_SetTimeout(), URL_Encode(), STimeoutTag::usec, and verify.

Referenced by s_Connect(), and URL_Connect().

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
 

Definition at line 1670 of file ncbi_connutil.c.

References URL_DecodeEx().

Referenced by s_Read().

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
 

Definition at line 1615 of file ncbi_connutil.c.

References s_HexChar().

Referenced by URL_Decode().

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
 

Definition at line 1683 of file ncbi_connutil.c.

Referenced by s_VT_Write(), and URL_ConnectEx().

int UTIL_MatchesMask const char *  name,
const char *  mask
 

Same as UTIL_MatchesMaskEx(name, mask, 1).

Parameters:
name TODO!
mask TODO!

Definition at line 924 of file ncbi_util.c.

References UTIL_MatchesMaskEx().

Referenced by s_LoadServices().

int UTIL_MatchesMaskEx const char *  name,
const char *  mask,
int  ignore_case
 

Parameters:
name TODO!
mask TODO!
ignore_case TODO!

Definition at line 887 of file ncbi_util.c.

Referenced by UTIL_MatchesMask().

char* UTIL_NcbiLocalHostName char *  hostname  ) 
 

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

Parameters:
hostname Hostname to shorten (if possible)
Returns:
0 if the hostname wasn't modified, otherwise return "hostname".

Definition at line 930 of file ncbi_util.c.

References len, prefix, and strcasecmp.

Referenced by s_ClientAddress().

char* UTIL_PrintableString const char *  data,
size_t  size,
char *  buf,
int  full
 

Create printable representation of the block of data of the specified size (or, if size is 0, strlen(data), and return buffer pointer past the last stored character (non ''-terminated).

NOTE: The input buffer "buf" where to store the printable representation is assumed to be of adequate size to hold the resultant string. Non-printable characters can be represented in a reduced octal form as long as the result is unambiguous (unless "full" passed true (non-zero), in which case all non-printable characters get represented by full octal tetrads). NB: Hexadecimal output is not used because it is ambiguous by the standard (can contain undefined number of hex digits).

Parameters:
data Block of data (NULL causes NULL to return regardless of "size" or "buf")
size Size of block (0 causes strlen(data) to be used) Buffer to store the result (NULL always causes NULL to return) Whether to print full octal representation of non-printable characters
Returns:
next position in the buffer past the last stored character.
See also:
UTIL_PrintableStringSize

Definition at line 209 of file ncbi_util.c.

References s_IsQuoted().

Referenced by s_SaveUserHeader().

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 specified size (or, if size is 0, strlen(data)).

NOTE: The calculated size does not include terminating ''.

Parameters:
data Block of data (NULL causes 0 to return regardless of "size")
size Size of block (0 causes strlen(data) to be used)
Returns:
the buffer size needed (0 for NULL or empty (size==0) block).
See also:
UTIL_PrintableString

Definition at line 188 of file ncbi_util.c.

References s_IsQuoted().

Referenced by ConnNetInfo_Log(), and LOG_ComposeMessage().


Generated on Mon Dec 7 16:02:00 2009 for NCBI C++ ToolKit by  doxygen 1.4.6
Modified on Mon Dec 07 16:24:35 2009 by modify_doxy.py rev. 173732