1 #ifndef CONNECT___NCBI_PRIV__H
2 #define CONNECT___NCBI_PRIV__H
65 # include <WinSock2.h>
67 # include <sys/socket.h>
86 #define NCBI_C_DEFINE_ERRCODE_X(name, err_code, max_err_subcode) \
88 eErrCodeX_##name = err_code \
112 #define NCBI_C_CONCAT_IDENTIFIER(prefix, postfix) prefix##postfix
118 #define NCBI_C_ERRCODE_X_NAME(name) \
119 NCBI_C_CONCAT_IDENTIFIER(eErrCodeX_, name)
126 #define NCBI_C_ERRCODE_X \
127 NCBI_C_ERRCODE_X_NAME(NCBI_USE_ERRCODE_X)
137 # define CORE_TRACE(message) CORE_LOG(eLOG_Trace, message)
138 # define CORE_TRACEF(fmt_args) CORE_LOGF(eLOG_Trace, fmt_args)
139 # define CORE_DEBUG_ARG(arg) arg
141 # define CORE_TRACE(message) ((void) 0)
142 # define CORE_TRACEF(fmt_args) ((void) 0)
143 # define CORE_DEBUG_ARG(arg)
146 #define CORE_LOG_X(subcode, level, message) \
147 DO_CORE_LOG(NCBI_C_ERRCODE_X, subcode, level, \
150 #define CORE_LOGF_X(subcode, level, fmt_args) \
151 DO_CORE_LOG(NCBI_C_ERRCODE_X, subcode, level, \
152 g_CORE_Sprintf fmt_args, 1)
154 #define CORE_LOG(level, message) \
155 DO_CORE_LOG(0, 0, level, \
158 #define CORE_LOGF(level, fmt_args) \
159 DO_CORE_LOG(0, 0, level, \
160 g_CORE_Sprintf fmt_args, 1)
162 #define CORE_LOG_ERRNO_X(subcode, level, error, message) \
163 DO_CORE_LOG_ERRNO(NCBI_C_ERRCODE_X, subcode, level, error, 0, \
166 #define CORE_LOGF_ERRNO_X(subcode, level, error, fmt_args) \
167 DO_CORE_LOG_ERRNO(NCBI_C_ERRCODE_X, subcode, level, error, 0, \
168 g_CORE_Sprintf fmt_args, 1)
170 #define CORE_LOG_ERRNO(level, error, message) \
171 DO_CORE_LOG_ERRNO(0, 0, level, error, 0, \
174 #define CORE_LOGF_ERRNO(level, error, fmt_args) \
175 DO_CORE_LOG_ERRNO(0, 0, level, error, 0, \
176 g_CORE_Sprintf fmt_args, 1)
178 #define CORE_LOG_ERRNO_EXX(subcode, level, error, descr, message) \
179 DO_CORE_LOG_ERRNO(NCBI_C_ERRCODE_X, subcode, level, error, descr, \
182 #define CORE_LOGF_ERRNO_EXX(subcode, level, error, descr, fmt_args) \
183 DO_CORE_LOG_ERRNO(NCBI_C_ERRCODE_X, subcode, level, error, descr, \
184 g_CORE_Sprintf fmt_args, 1)
186 #define CORE_LOG_ERRNO_EX(level, error, descr, message) \
187 DO_CORE_LOG_ERRNO(0, 0, level, error, descr, \
190 #define CORE_LOGF_ERRNO_EX(level, error, descr, fmt_args) \
191 DO_CORE_LOG_ERRNO(0, 0, level, error, descr, \
192 g_CORE_Sprintf fmt_args, 1)
194 #define CORE_DATA_X(subcode, level, data, size, message) \
195 DO_CORE_LOG_DATA(NCBI_C_ERRCODE_X, subcode, level, data, size, \
198 #define CORE_DATAF_X(subcode, level, data, size, fmt_args) \
199 DO_CORE_LOG_DATA(NCBI_C_ERRCODE_X, subcode, level, data, size, \
200 g_CORE_Sprintf fmt_args, 1)
202 #define CORE_DATA(level, data, size, message) \
203 DO_CORE_LOG_DATA(0, 0, level, data, size, \
206 #define CORE_DATAF(level, data, size, fmt_args) \
207 DO_CORE_LOG_DATA(0, 0, level, data, size, \
208 g_CORE_Sprintf fmt_args, 1)
211 #define DO_CORE_LOG_X(_code, _subcode, _level, _message, _dynamic, \
212 _error, _descr, _raw_data, _raw_size) \
214 ELOG_Level _xx_level = (_level); \
215 if (g_CORE_Log || _xx_level == eLOG_Fatal) { \
216 SLOG_Message _mess; \
217 _mess.dynamic = _dynamic; \
218 _mess.message = NcbiMessagePlusError(&_mess.dynamic, \
222 _mess.level = _xx_level; \
223 _mess.module = THIS_MODULE; \
224 _mess.func = CORE_CURRENT_FUNCTION; \
225 _mess.file = __FILE__; \
226 _mess.line = __LINE__; \
227 _mess.raw_data = (_raw_data); \
228 _mess.raw_size = (_raw_size); \
229 _mess.err_code = (_code); \
230 _mess.err_subcode = (_subcode); \
232 LOG_WriteInternal(g_CORE_Log, &_mess); \
237 #define DO_CORE_LOG(code, subcode, level, \
239 DO_CORE_LOG_X(code, subcode, level, message, dynamic, 0, 0, 0, 0)
241 #define DO_CORE_LOG_ERRNO(code, subcode, level, error, descr, \
243 DO_CORE_LOG_X(code, subcode, level, message, dynamic, error, descr, 0, 0)
245 #define DO_CORE_LOG_DATA(code, subcode, level, data, size, \
247 DO_CORE_LOG_X(code, subcode, level, message, dynamic, 0, 0, data, size)
251 __attribute__((
format(printf,1,2)))
269 #define CORE_LOCK_WRITE verify(CORE_CHECK_LOCK != 0 && \
270 MT_LOCK_Do(g_CORE_MT_Lock, eMT_Lock ) != 0)
271 #define CORE_LOCK_READ verify(CORE_CHECK_LOCK != 0 && \
272 MT_LOCK_Do(g_CORE_MT_Lock, eMT_LockRead) != 0)
273 #define CORE_UNLOCK verify(CORE_CHECK_UNLOCK != 0 && \
274 MT_LOCK_Do(g_CORE_MT_Lock, eMT_Unlock ) != 0)
279 # define CORE_CHECK_LOCK g_NCBI_CoreCheckLock()
280 # define CORE_CHECK_UNLOCK g_NCBI_CoreCheckUnlock()
282 # define CORE_CHECK_LOCK (1)
283 # define CORE_CHECK_UNLOCK (1)
297 #define CORE_REG_GET(section, name, value, value_size, def_value) \
298 g_CORE_RegistryGET(section, name, value, value_size, def_value)
300 #define CORE_REG_SET(section, name, value, storage) \
301 g_CORE_RegistrySET(section, name, value, storage)
305 (
const char* section,
309 const char* def_value
314 (
const char* section,
343 #define NCBI_CONNECT_SRAND_ADDEND g_NCBI_ConnectSrandAddend()
351 typedef const char* (*FNcbiGetAppName)(void);
359 typedef const char* (*FNcbiGetReferer)(void);
376 typedef const char* (*FNcbiGetRequestDtab)(void);
385 # define likely(x) __builtin_expect(!!(x),1)
386 # define unlikely(x) __builtin_expect(!!(x),0)
388 # define likely(x) (x)
389 # define unlikely(x) (x)
402 # ifdef NCBI_OS_MSWIN
403 # define MONKEY_RETTYPE int
404 # define MONKEY_SOCKTYPE SOCKET
405 # define MONKEY_DATATYPE char*
406 # define MONKEY_LENTYPE int
407 # define MONKEY_SOCKLENTYPE int
408 # define MONKEY_STDCALL __stdcall
411 # define MONKEY_RETTYPE ssize_t
412 # define MONKEY_SOCKTYPE int
413 # define MONKEY_DATATYPE void*
414 # define MONKEY_LENTYPE size_t
415 # define MONKEY_SOCKLENTYPE socklen_t
416 # define MONKEY_STDCALL
422 typedef MONKEY_RETTYPE
423 (MONKEY_STDCALL *FMonkeyRecv) (MONKEY_SOCKTYPE socket,
428 typedef MONKEY_RETTYPE
429 (MONKEY_STDCALL *FMonkeySend) (MONKEY_SOCKTYPE socket,
430 const MONKEY_DATATYPE
data,
434 typedef int(MONKEY_STDCALL *FMonkeyConnect)(MONKEY_SOCKTYPE socket,
435 const struct sockaddr* name,
436 MONKEY_SOCKLENTYPE namelen);
438 typedef int (*FMonkeyPoll) (
size_t*
n,
441 typedef void (*FMonkeyClose) (MONKEY_SOCKTYPE socket);
442 typedef void (*FSockHasSocket)(
void* sock,
443 MONKEY_SOCKTYPE socket);
EREG_Storage
Transient/Persistent storage.
ENcbiRequestID
NCBI request ID enumerator.
#define NCBI_XCONNECT_EXPORT
unsigned int
A callback function used to compare two keys in a database.
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
int g_CORE_RegistrySET(const char *section, const char *name, const char *value, EREG_Storage storage)
const char *(* FNcbiGetRequestDtab)(void)
unsigned int g_NCBI_ConnectSrandAddend(void)
unsigned int g_NCBI_ConnectRandomSeed
int g_NCBI_CoreCheckUnlock(void)
const char * g_CORE_Sprintf(const char *fmt,...)
FNcbiGetRequestDtab g_CORE_GetRequestDtab
const char *(* FNcbiGetReferer)(void)
#define NCBI_C_DEFINE_ERRCODE_X(name, err_code, max_err_subcode)
Define global error code name with given value (err_code)
FNcbiGetRequestID g_CORE_GetRequestID
FNcbiGetAppName g_CORE_GetAppName
const char *(* FNcbiGetAppName)(void)
const char * g_CORE_RegistryGET(const char *section, const char *name, char *value, size_t value_size, const char *def_value)
char *(* FNcbiGetRequestID)(ENcbiRequestID)
FNcbiGetReferer g_CORE_GetReferer
int g_NCBI_CoreCheckLock(void)
struct MT_LOCK_tag g_CORE_MT_Lock_default