~ubuntu-branches/ubuntu/edgy/ncbi-tools6/edgy

« back to all changes in this revision

Viewing changes to connect/ncbi_connutil.h

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese
  • Date: 2006-07-19 23:28:07 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20060719232807-et3cdmcjgmnyleyx
Tags: 6.1.20060507-3ubuntu1
Re-merge with Debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#ifndef CONNECT___NCBI_CONNUTIL__H
2
2
#define CONNECT___NCBI_CONNUTIL__H
3
3
 
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
 * ===========================================================================
6
6
 *
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_***
54
56
 *
76
78
 *       SOCK_StripToPattern()
77
79
 *       BUF_StripToPattern()
78
80
 *
79
 
 *    7.Convert "[host][:port]" from verbal into binary form and vice versa:
80
 
 *       StringToHostPort()
81
 
 *       HostPortToString()
82
 
 *
83
 
 *    8.CRC32
 
81
 *    7.CRC32
84
82
 *       CRC32_Update()
85
83
 *
 
84
 *    8.Miscellaneous
 
85
 *       CONNUTIL_GetUsername()
 
86
 *       CONNUTIL_GetVMPageSize()
86
87
 */
87
88
 
88
89
#include <connect/ncbi_buffer.h>
207
208
#define REG_CONN_HTTP_USER_HEADER "HTTP_USER_HEADER"
208
209
#define DEF_CONN_HTTP_USER_HEADER 0
209
210
 
 
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"
 
216
 
 
217
/* Local service dispatcher */
 
218
#define REG_CONN_LOCAL_SERVICES   "LOCAL_SERVICES"
 
219
#define REG_CONN_LOCAL_SERVER     DEF_CONN_REG_SECTION "_LOCAL_SERVER"
 
220
 
 
221
 
 
222
extern NCBI_XCONNECT_EXPORT const char* ConnNetInfo_GetValue
 
223
(const char* service,
 
224
 const char* param,
 
225
 char*       value,
 
226
 size_t      value_size,
 
227
 const char* def_value
 
228
 );
 
229
 
210
230
 
211
231
/* This function to fill out the "*info" structure using
212
232
 * registry entries named (see above) in macros REG_CONN_<NAME>:
225
245
 *  http_proxy_port   HTTP_PROXY_PORT
226
246
 *  proxy_host        PROXY_HOST
227
247
 *  debug_printout    DEBUG_PRINTOUT
228
 
 *  client_mode       CLIENT_MODE
 
248
 *  stateless         STATELESS
 
249
 *  firewall          FIREWALL
229
250
 *  lb_disable        LB_DISABLE
230
251
 *  http_user_header  HTTP_USER_HEADER  "\r\n" if missing is appended
231
252
 *
264
285
 
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.
273
294
 */
286
307
 const char*   val
287
308
 );
288
309
 
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,
292
313
 const char*   arg
293
314
 );
294
315
 
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
 
318
(SConnNetInfo* info,
 
319
 const char*   args
 
320
 );
 
321
 
 
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,
298
325
 const char*   arg,
299
326
 const char*   val
300
327
 );
301
328
 
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,
305
332
 const char*   arg,
372
399
 );
373
400
 
374
401
 
 
402
/* Setup standard arguments:  service, address, and platform.
 
403
 * Return non-zero on success; zero on error.
 
404
 */
 
405
extern int/*bool*/ ConnNetInfo_SetupStandardArgs
 
406
(SConnNetInfo* info
 
407
 );
 
408
 
 
409
 
375
410
/* Log the contents of "*info".
376
411
 */
377
412
extern NCBI_XCONNECT_EXPORT void ConnNetInfo_Log
674
709
 );
675
710
 
676
711
 
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.
685
 
 */
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 */
690
 
 );
691
 
 
692
 
 
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.
696
 
 */
697
 
extern NCBI_XCONNECT_EXPORT size_t HostPortToString
698
 
(unsigned int   host,
699
 
 unsigned short port,
700
 
 char*          buf,
701
 
 size_t         buflen
702
 
 );
 
712
/* Deprecated:  Use SOCK_StringHostToPort() and SOCK_HostPortToString() instead
 
713
 */
 
714
#ifndef NCBI_DEPRECATED
 
715
#  define NCBI_CONNUTIL_DEPRECATED
 
716
#else
 
717
#  define NCBI_CONNUTIL_DEPRECATED NCBI_DEPRECATED
 
718
#endif
 
719
extern NCBI_XCONNECT_EXPORT NCBI_CONNUTIL_DEPRECATED
 
720
const char* StringToHostPort
 
721
(const char*, unsigned int*, unsigned short*);
 
722
 
 
723
extern NCBI_XCONNECT_EXPORT NCBI_CONNUTIL_DEPRECATED
 
724
size_t HostPortToString
 
725
(unsigned int, unsigned short, char*, size_t);
703
726
 
704
727
 
705
728
/* Calculate/Update CRC32
713
736
 );
714
737
 
715
738
 
 
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.
 
745
 */
 
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                     */
 
749
 );
 
750
 
 
751
 
 
752
/* Obtain virtual memory page size.
 
753
 * Return 0 if the page size cannot be determined.
 
754
 */
 
755
extern NCBI_XCONNECT_EXPORT size_t CONNUTIL_GetVMPageSize(void);
 
756
 
 
757
 
716
758
#ifdef __cplusplus
717
759
}  /* extern "C" */
718
760
#endif
724
766
/*
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
 
771
 *
 
772
 * Revision 6.55  2006/04/21 01:33:22  lavr
 
773
 * SConnNetInfo::lb_disable reinstated along with LB_DISABLE reg/env key
 
774
 *
 
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
 
778
 *
 
779
 * Revision 6.52  2006/04/19 02:26:05  lavr
 
780
 * Document ConnNetInfo_{Pre|Post}OverrideArg in more details
 
781
 *
 
782
 * Revision 6.51  2006/02/23 15:46:16  lavr
 
783
 * Clean ChangeLog
 
784
 *
 
785
 * Revision 6.50  2006/02/23 15:22:43  lavr
 
786
 * +CONNUTIL_GetVMPageSize()
 
787
 *
 
788
 * Revision 6.49  2006/01/27 19:17:41  lavr
 
789
 * Fix NCBI_DEPRECATED placement to satify MSVC compiler
 
790
 *
 
791
 * Revision 6.48  2006/01/27 17:08:35  lavr
 
792
 * Spell CONNUTIL_GetUsername() this way
 
793
 *
 
794
 * Revision 6.47  2006/01/27 16:57:53  lavr
 
795
 * Obsoleted StringHostToPort() and HostPortToString()
 
796
 * Added new CONNUTIL_GetUsername()
 
797
 *
 
798
 * Revision 6.46  2006/01/11 20:19:56  lavr
 
799
 * -UTIL_ClientAddress()
 
800
 * +ConnNetInfo_DeleteAllArgs()
 
801
 * +ConnNetInfo_SetupStandardArgs()
 
802
 *
 
803
 * Revision 6.45  2006/01/11 16:24:03  lavr
 
804
 * +UTIL_ClientAddress()
 
805
 *
727
806
 * Revision 6.44  2005/11/29 21:32:07  lavr
728
807
 * Reserve SConnNetInfo::scheme, user, and pass for future use
729
808
 *