1
1
#ifndef CONNECT___NCBI_CONNUTIL__H
2
2
#define CONNECT___NCBI_CONNUTIL__H
4
/* $Id: ncbi_connutil.h,v 6.44 2005/11/29 21:32:07 lavr Exp $
4
/* $Id: ncbi_connutil.h,v 6.56 2006/04/21 14:41:19 lavr Exp $
5
5
* ===========================================================================
7
7
* PUBLIC DOMAIN NOTICE
47
47
* ConnNetInfo_AppendArg()
48
48
* ConnNetInfo_PrependArg()
49
49
* ConnNetInfo_DeleteArg()
50
* ConnNetInfo_DeleteAllArgs()
50
51
* ConnNetInfo_PreOverrideArg()
51
52
* ConnNetInfo_PostOverrideArg()
53
* ConnNetInfo_SetupStandardArgs()
52
54
* #define REG_CONN_***
53
55
* #define DEF_CONN_***
207
208
#define REG_CONN_HTTP_USER_HEADER "HTTP_USER_HEADER"
208
209
#define DEF_CONN_HTTP_USER_HEADER 0
211
/* Environment/registry keys that are not kept in SConnNetInfo */
212
#define REG_CONN_SERVICE_NAME "SERVICE_NAME"
213
#define REG_CONN_LOCAL_DISABLE "LOCAL_DISABLE"
214
#define REG_CONN_LBSMD_DISABLE "LBSMD_DISABLE"
215
#define REG_CONN_DISPD_DISABLE "DISPD_DISABLE"
217
/* Local service dispatcher */
218
#define REG_CONN_LOCAL_SERVICES "LOCAL_SERVICES"
219
#define REG_CONN_LOCAL_SERVER DEF_CONN_REG_SECTION "_LOCAL_SERVER"
222
extern NCBI_XCONNECT_EXPORT const char* ConnNetInfo_GetValue
223
(const char* service,
227
const char* def_value
211
231
/* This function to fill out the "*info" structure using
212
232
* registry entries named (see above) in macros REG_CONN_<NAME>:
265
286
/* Convenience routines to manipulate SConnNetInfo::args[].
266
287
* In "arg" all routines below assume to have a single arg name
267
* or an "arg=value" pair. In the former case, additional "val"
288
* or an "arg=value" pair. In the former case, additional "val"
268
289
* may be supplied separately (and will be prepended by "=" if
269
* necessary). In the latter case, having a non-zero string in
270
* "val" may result in an erroneous behavior. Ampersand (&) gets
290
* necessary). In the latter case, having a non-zero string in
291
* "val" may result in an erroneous behavior. Ampersand (&) gets
271
292
* automatically added to keep the arg list correct.
272
293
* Return value (if any): none-zero on success; 0 on error.
289
/* delete argument from the list */
310
/* delete one (first) argument from the list of arguments in "info" */
290
311
extern NCBI_XCONNECT_EXPORT void ConnNetInfo_DeleteArg
291
312
(SConnNetInfo* info,
295
/* same as sequence Delete then Prepend, see above */
316
/* delete all arguments specified in "args" from the list in "info" */
317
extern NCBI_XCONNECT_EXPORT void ConnNetInfo_DeleteAllArgs
322
/* same as sequence DeleteAll(arg) then Prepend(arg, val), see above */
296
323
extern NCBI_XCONNECT_EXPORT int/*bool*/ ConnNetInfo_PreOverrideArg
297
324
(SConnNetInfo* info,
302
/* same as sequence Delete then Append, see above */
329
/* same as sequence DeleteAll(arg) then Append(arg, val), see above */
303
330
extern NCBI_XCONNECT_EXPORT int/*bool*/ ConnNetInfo_PostOverrideArg
304
331
(SConnNetInfo* info,
402
/* Setup standard arguments: service, address, and platform.
403
* Return non-zero on success; zero on error.
405
extern int/*bool*/ ConnNetInfo_SetupStandardArgs
375
410
/* Log the contents of "*info".
377
412
extern NCBI_XCONNECT_EXPORT void ConnNetInfo_Log
677
/* Read (skipping leading blanks) "[host][:port]" from a string.
678
* On success, return the advanced pointer past the host/port read.
679
* If no host/port detected, return 'str'.
680
* On format error, return 0.
681
* If host and/or port fragments are missing,
682
* then corresponding 'host'/'port' value returned as 0.
683
* Note that 'host' returned is in network byte order,
684
* unlike 'port', which always comes out in host (native) byte order.
686
extern NCBI_XCONNECT_EXPORT const char* StringToHostPort
687
(const char* str, /* must not be NULL */
688
unsigned int* host, /* must not be NULL */
689
unsigned short* port /* must not be NULL */
693
/* Print host:port into provided buffer string, not to exceed 'buflen' size.
694
* Suppress printing host if parameter 'host' is zero.
695
* Return the number of bytes printed.
697
extern NCBI_XCONNECT_EXPORT size_t HostPortToString
712
/* Deprecated: Use SOCK_StringHostToPort() and SOCK_HostPortToString() instead
714
#ifndef NCBI_DEPRECATED
715
# define NCBI_CONNUTIL_DEPRECATED
717
# define NCBI_CONNUTIL_DEPRECATED NCBI_DEPRECATED
719
extern NCBI_XCONNECT_EXPORT NCBI_CONNUTIL_DEPRECATED
720
const char* StringToHostPort
721
(const char*, unsigned int*, unsigned short*);
723
extern NCBI_XCONNECT_EXPORT NCBI_CONNUTIL_DEPRECATED
724
size_t HostPortToString
725
(unsigned int, unsigned short, char*, size_t);
705
728
/* Calculate/Update CRC32
739
/* Obtain and store current user's name in the buffer provided.
740
* Return 0 when the user name cannot be determined.
741
* Otherwise, return "buf".
742
* Note that resultant strlen(buf) is always guaranteed to be less
743
* than "bufsize", extra non-fit characters discarded.
744
* Both "buf" and "bufsize" must not be zeros.
746
extern NCBI_XCONNECT_EXPORT const char* CONNUTIL_GetUsername
747
(char* buf, /* Pointer to buffer to store the user name at */
748
size_t bufsize /* Size of buffer in bytes */
752
/* Obtain virtual memory page size.
753
* Return 0 if the page size cannot be determined.
755
extern NCBI_XCONNECT_EXPORT size_t CONNUTIL_GetVMPageSize(void);
716
758
#ifdef __cplusplus
717
759
} /* extern "C" */
725
767
* --------------------------------------------------------------------------
726
768
* $Log: ncbi_connutil.h,v $
769
* Revision 6.56 2006/04/21 14:41:19 lavr
770
* REG_CONN_SERVICE_NAME added
772
* Revision 6.55 2006/04/21 01:33:22 lavr
773
* SConnNetInfo::lb_disable reinstated along with LB_DISABLE reg/env key
775
* Revision 6.53 2006/04/20 13:57:51 lavr
776
* Registry keys for new switching scheme for service mappers;
777
* Registry keys for LOCAL service mappers
779
* Revision 6.52 2006/04/19 02:26:05 lavr
780
* Document ConnNetInfo_{Pre|Post}OverrideArg in more details
782
* Revision 6.51 2006/02/23 15:46:16 lavr
785
* Revision 6.50 2006/02/23 15:22:43 lavr
786
* +CONNUTIL_GetVMPageSize()
788
* Revision 6.49 2006/01/27 19:17:41 lavr
789
* Fix NCBI_DEPRECATED placement to satify MSVC compiler
791
* Revision 6.48 2006/01/27 17:08:35 lavr
792
* Spell CONNUTIL_GetUsername() this way
794
* Revision 6.47 2006/01/27 16:57:53 lavr
795
* Obsoleted StringHostToPort() and HostPortToString()
796
* Added new CONNUTIL_GetUsername()
798
* Revision 6.46 2006/01/11 20:19:56 lavr
799
* -UTIL_ClientAddress()
800
* +ConnNetInfo_DeleteAllArgs()
801
* +ConnNetInfo_SetupStandardArgs()
803
* Revision 6.45 2006/01/11 16:24:03 lavr
804
* +UTIL_ClientAddress()
727
806
* Revision 6.44 2005/11/29 21:32:07 lavr
728
807
* Reserve SConnNetInfo::scheme, user, and pass for future use