⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ncbi_connutil.h

📁 ncbi源码
💻 H
📖 第 1 页 / 共 2 页
字号:
 *       and/or read/write timeouts were passed as {0,0}, meaning that both *       connection and HTTP header write operation may still be pending in *       the resultant socket. It is responsibility of the application to *       analyze the actual socket state in this case (see "ncbi_socket.h"). */extern NCBI_XCONNECT_EXPORT 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,       /* timeout for the CONNECT stage          */ const STimeout* rw_timeout,      /* timeout for READ and WRITE             */ const char*     user_header, int/*bool*/     encode_args,     /* URL-encode the "args", if any          */ ESwitch         data_logging     /* sock.data log.; eDefault in most cases */ );/* Discard all input data before(and including) the first occurrence of * "pattern". If "buf" is not NULL then add the discarded data(including * the "pattern") to it. If "n_discarded" is not NULL then "*n_discarded" * will return # of discarded bytes. * NOTE: "pattern" == NULL causes stripping to the EOF. */extern NCBI_XCONNECT_EXPORT EIO_Status CONN_StripToPattern(CONN        conn, const void* pattern, size_t      pattern_size, BUF*        buf, size_t*     n_discarded );extern NCBI_XCONNECT_EXPORT EIO_Status SOCK_StripToPattern(SOCK        sock, const void* pattern, size_t      pattern_size, BUF*        buf, size_t*     n_discarded );extern NCBI_XCONNECT_EXPORT EIO_Status BUF_StripToPattern(BUF         buffer, const void* pattern, size_t      pattern_size, BUF*        buf, size_t*     n_discarded );/* URL-decode up to "src_size" symbols(bytes) from buffer "src_buf". * Write the decoded data to buffer "dst_buf", but no more than "dst_size" * bytes. * Assign "*src_read" to the # of bytes successfully decoded from "src_buf". * Assign "*dst_written" to the # of bytes written to buffer "dst_buf". * Return FALSE only if cannot decode nothing, and an unrecoverable * URL-encoding error (such as an invalid symbol or a bad "%.." sequence) * has occurred. * NOTE:  the unfinished "%.." sequence is fine -- return TRUE, but dont *        "read" it. */extern NCBI_XCONNECT_EXPORT int/*bool*/ URL_Decode(const void* src_buf,    /* [in]     non-NULL */ size_t      src_size,   /* [in]              */ size_t*     src_read,   /* [out]    non-NULL */ void*       dst_buf,    /* [in/out] non-NULL */ size_t      dst_size,   /* [in]              */ size_t*     dst_written /* [out]    non-NULL */ );/* Act just like URL_Decode (see above) but caller can allow the specified * non-standard URL symbols in the input buffer to be decoded "as is". * The extra allowed symbols are passed in a '\0'-terminated string * "allow_symbols" (it can be NULL or empty -- then this will be an exact * equivalent of URL_Decode). */extern NCBI_XCONNECT_EXPORT int/*bool*/ URL_DecodeEx(const void* src_buf,      /* [in]     non-NULL  */ size_t      src_size,     /* [in]               */ size_t*     src_read,     /* [out]    non-NULL  */ void*       dst_buf,      /* [in/out] non-NULL  */ size_t      dst_size,     /* [in]               */ size_t*     dst_written,  /* [out]    non-NULL  */ const char* allow_symbols /* [in]     '\0'-term */ );/* URL-encode up to "src_size" symbols(bytes) from buffer "src_buf". * Write the encoded data to buffer "dst_buf", but no more than "dst_size" * bytes. * Assign "*src_read" to the # of bytes successfully encoded from "src_buf". * Assign "*dst_written" to the # of bytes written to buffer "dst_buf". */extern NCBI_XCONNECT_EXPORT void URL_Encode(const void* src_buf,    /* [in]     non-NULL */ size_t      src_size,   /* [in]              */ size_t*     src_read,   /* [out]    non-NULL */ void*       dst_buf,    /* [in/out] non-NULL */ size_t      dst_size,   /* [in]              */ size_t*     dst_written /* [out]    non-NULL */ );/**************************************************************************** * NCBI-specific MIME content type and sub-types * (the API to compose and parse them) *    Content-Type: <type>/<MIME_ComposeSubType()>\r\n * *    Content-Type: <type>/<subtype>-<encoding>\r\n * * where  MIME_ComposeSubType(EMIME_SubType subtype, EMIME_Encoding encoding): *   "x-<subtype>-<encoding>": *     "x-<subtype>",   "x-<subtype>-urlencoded",   "x-<subtype>-<encoding>", *     "x-dispatch",    "x-dispatch-urlencoded",    "x-dispatch-<encoding> *     "x-asn-text",    "x-asn-text-urlencoded",    "x-asn-text-<encoding> *     "x-asn-binary",  "x-asn-binary-urlencoded",  "x-asn-binary-<encoding>" *     "x-www-form",    "x-www-form-urlencoded",    "x-www-form-<encoding>" *     "html",          "html-urlencoded",          "html-<encoding>" *     "x-unknown",     "x-unknown-urlencoded",     "x-unknown-<encoding>" * *  Note:  <subtype> and <encoding> are expected to contain only *         alphanumeric symbols, '-' and '_'. They are case-insensitive. ****************************************************************************//* Type */typedef enum {    eMIME_T_NcbiData = 0,  /* "x-ncbi-data"  (NCBI specific data) */    eMIME_T_Text,          /* "text"                              */    eMIME_T_Application,   /* "application"                       */    /* eMIME_T_???, "<type>" here go other types                  */    eMIME_T_Unknown        /* "unknown"                           */} EMIME_Type;/* SubType */typedef enum {    eMIME_Dispatch = 0,  /* "x-dispatch"    (dispatcher info)          */    eMIME_AsnText,       /* "x-asn-text"    (text ASN.1 data)          */    eMIME_AsnBinary,     /* "x-asn-binary"  (binary ASN.1 data)        */    eMIME_Fasta,         /* "x-fasta"       (data in FASTA format)     */    eMIME_WwwForm,       /* "x-www-form"                               */    /* standard MIMEs */    eMIME_Html,          /* "html"                                     */    eMIME_Plain,         /* "plain"                                    */    eMIME_Xml,           /* "xml"                                      */    eMIME_XmlSoap,       /* "xml+soap"                                 */    /* eMIME_???,           "<subtype>" here go other NCBI subtypes    */    eMIME_Unknown        /* "x-unknown"     (an arbitrary binary data) */} EMIME_SubType;/* Encoding */typedef enum {    eENCOD_None = 0, /* ""              (the content is passed "as is") */    eENCOD_Url,      /* "-urlencoded"   (the content is URL-encoded)    */    /* eENCOD_???,      "-<encoding>" here go other NCBI encodings      */    eENCOD_Unknown   /* "-encoded"      (unknown encoding)              */} EMIME_Encoding;/* Write up to "buflen" bytes to "buf": *   Content-Type: <type>/[x-]<subtype>-<encoding>\r\n * Return pointer to the "buf". */#define MAX_CONTENT_TYPE_LEN 64extern NCBI_XCONNECT_EXPORT char* MIME_ComposeContentTypeEx(EMIME_Type     type, EMIME_SubType  subtype, EMIME_Encoding encoding, char*          buf, size_t         buflen    /* must be at least MAX_CONTENT_TYPE_LEN */ );/* Exactly equivalent to MIME_ComposeContentTypeEx(eMIME_T_NcbiData, ...) */extern NCBI_XCONNECT_EXPORT char* MIME_ComposeContentType(EMIME_SubType  subtype, EMIME_Encoding encoding, char*          buf, size_t         buflen );/* Parse the NCBI-specific content-type; the (case-insensitive) "str" * can be in the following two formats: *   Content-Type: <type>/x-<subtype>-<encoding> *   <type>/x-<subtype>-<encoding> * * NOTE:  all leading spaces and all trailing spaces (and any trailing symbols, *        if they separated from the content type by at least one space) will *        be ignored, e.g. these are valid content type strings: *           "   Content-Type: text/plain  foobar" *           "  text/html \r\n  barfoo coocoo ....\n boooo" * * If it does not match any of NCBI MIME type/subtypes/encodings, then * return TRUE, eMIME_T_Unknown, eMIME_Unknown or eENCOD_None, respectively. * If the passed "str" has an invalid (non-HTTP ContentType) format * (or if it is NULL/empty), then * return FALSE, eMIME_T_Unknown, eMIME_Unknown, and eENCOD_Unknown */extern NCBI_XCONNECT_EXPORT int/*bool*/ MIME_ParseContentTypeEx(const char*     str,      /* the HTTP "Content-Type:" header to parse */ EMIME_Type*     type,     /* can be NULL */ EMIME_SubType*  subtype,  /* can be NULL */ EMIME_Encoding* encoding  /* can be NULL */ );/* Requires the MIME type be "x-ncbi-data" */extern NCBI_XCONNECT_EXPORT int/*bool*/ MIME_ParseContentType(const char*     str,      /* the HTTP "Content-Type:" header to parse */ EMIME_SubType*  subtype,  /* can be NULL */ EMIME_Encoding* encoding  /* can be NULL */ );/* Read (skipping leading blanks) "[host][:port]" from a string. * On success, return the advanced pointer past the host/port read. * If no host/port detected, return 'str'. * On format error, return 0. * If host and/or port fragments are missing, * then corresponding 'host'/'port' value returned as 0. * Note that 'host' returned is in network byte order, * unlike 'port', which always comes out in host (native) byte order. */extern NCBI_XCONNECT_EXPORT const char* StringToHostPort(const char*     str,   /* must not be NULL */ unsigned int*   host,  /* must not be NULL */ unsigned short* port   /* must not be NULL */ );/* Print host:port into provided buffer string, not to exceed 'buflen' size. * Suppress printing host if parameter 'host' is zero. * Return the number of bytes printed. */extern NCBI_XCONNECT_EXPORT size_t HostPortToString(unsigned int   host, unsigned short port, char*          buf, size_t         buflen );#ifdef __cplusplus}  /* extern "C" */#endif/* @} *//* * -------------------------------------------------------------------------- * $Log: ncbi_connutil.h,v $ * Revision 1000.1  2004/02/12 21:51:37  gouriano * PRODUCTION: UPGRADED [CORE_001] Dev-tree R6.35 * * Revision 6.35  2004/01/14 18:51:41  lavr * +eMIME_XmlSoap * * Revision 6.34  2004/01/07 19:24:40  lavr * Added MIME subtype eMIME_Xml * * Revision 6.33  2003/09/23 21:00:33  lavr * Reorder included header files * * Revision 6.32  2003/08/25 14:48:50  lavr * ConnNetInfo_SetUserHeader():  to return completion status * * Revision 6.31  2003/05/29 17:56:53  lavr * More (clarified) comments for URL_Connect() * * Revision 6.30  2003/05/20 21:24:01  lavr * Limit SConnNetInfo::max_try by reasonable "short" value * * Revision 6.29  2003/04/09 17:58:47  siyan * Added doxygen support * * Revision 6.28  2003/01/17 19:44:20  lavr * Reduce dependencies * * Revision 6.27  2003/01/08 01:59:32  lavr * DLL-ize CONNECT library for MSVC (add NCBI_XCONNECT_EXPORT) * * Revision 6.26  2002/11/19 19:19:24  lavr * +ConnNetInfo_ExtendUserHeader() * * Revision 6.25  2002/11/12 05:49:47  lavr * Expand host names to hold 256 chars (instead of 64) * * Revision 6.24  2002/10/21 18:30:27  lavr * +ConnNetInfo_AppendArg() * +ConnNetInfo_PrependArg() * +ConnNetInfo_DeleteArg() * +ConnNetInfo_PreOverrideArg() * +ConnNetInfo_PostOverrideArg() * * Revision 6.23  2002/10/11 19:41:40  lavr * +ConnNetInfo_AppendUserHeader() * +ConnNetInfo_OverrideUserHeader() * +ConnNetInfo_DeleteUserHeader() * * Revision 6.22  2002/09/19 18:00:21  lavr * Header file guard macro changed; log moved to the end * * Revision 6.21  2002/05/06 19:07:25  lavr * -#include <stdlib>; -ConnNetInfo_Print(); +ConnNetInfo_Log() * * Revision 6.20  2002/02/20 19:12:03  lavr * Swapped eENCOD_Url and eENCOD_None; eENCOD_Unknown introduced * * Revision 6.19  2001/12/30 19:39:36  lavr * +ConnNetInfo_ParseURL() * * Revision 6.18  2001/09/28 20:45:26  lavr * SConnNetInfo::max_try equal to 0 is now treated the same way as equal to 1 * * Revision 6.17  2001/09/19 15:58:37  lavr * Cut trailing blanks in blank lines * * Revision 6.16  2001/09/10 21:14:47  lavr * Added functions: StringToHostPort() *                  HostPortToString() * * Revision 6.15  2001/06/01 16:01:58  vakatov * MIME_ParseContentTypeEx() -- extended description * * Revision 6.14  2001/05/29 21:15:42  vakatov * + eMIME_Plain * * Revision 6.13  2001/04/24 21:21:38  lavr * Special text value "infinite" accepted as infinite timeout from environment * * Revision 6.12  2001/03/07 23:00:15  lavr * Default value for SConnNetInfo::stateless set to empty (FALSE) * * Revision 6.11  2001/03/02 20:07:07  lavr * Typos fixed * * Revision 6.10  2001/02/26 16:56:41  vakatov * Comment SConnNetInfo. * * Revision 6.9  2001/01/23 23:06:15  lavr * SConnNetInfo.debug_printout converted from boolean to enum * BUF_StripToPattern() introduced * * Revision 6.8  2001/01/11 23:05:13  lavr * ConnNetInfo_Create() fully documented * * Revision 6.7  2001/01/08 23:46:10  lavr * REQUEST_METHOD -> REQ_METHOD to be consistent with SConnNetInfo * * Revision 6.6  2001/01/08 22:47:13  lavr * ReqMethod constants changed (to conform to coding standard) * ClientMode removed; replaced by 2 booleans: stateless and firewall * in SConnInfo structure * * Revision 6.5  2000/12/29 17:47:46  lavr * NCBID stuff removed; ClientMode enum added; * ConnNetInfo_SetUserHeader added; http_user_header is now * included in ConnInfo structure. ConnNetInfo_Destroy parameter * changed to be a pointer (was a double pointer). * * Revision 6.4  2000/11/07 23:23:15  vakatov * In-sync with the C Toolkit "connutil.c:R6.15", "connutil.h:R6.13" * (with "eMIME_Dispatch" added). * * Revision 6.3  2000/10/05 22:39:21  lavr * SConnNetInfo modified to contain 'client_mode' instead of just 'firewall' * * Revision 6.2  2000/09/26 22:01:30  lavr * Registry entries changed, HTTP request method added * * Revision 6.1  2000/03/24 22:52:48  vakatov * Initial revision * * ========================================================================== */#endif /* CONNECT___NCBI_CONNUTIL__H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -