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

📄 awsp.c

📁 SyncML ToolKits,学习syncml的参考工具包.非常好用.
💻 C
📖 第 1 页 / 共 2 页
字号:
/*************************************************************************//* module:          Communication Services, Abstract WSP implementation  *//* file:            src/xpt/awsp/awsp.c                                  *//* target system:   all                                                  *//* target OS:       all                                                  *//*************************************************************************//* * Copyright Notice * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication  * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,  * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001). * All Rights Reserved. * Implementation of all or part of any Specification may require  * licenses under third party intellectual property rights,  * including without limitation, patent rights (such a third party  * may or may not be a Supporter). The Sponsors of the Specification  * are not responsible and shall not be held responsible in any  * manner for identifying or failing to identify any or all such  * third party intellectual property rights. *  * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED  * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,  * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,  * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML  * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING  * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION  * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT  * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,  * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY  * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF  * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF  * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,  * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH  * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED  * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE. *  * The above notice and this paragraph must be included on all copies  * of this document that are made. *  *//* * Version Label * * RELEASE RED CANDIDATE 1 * 27.03.2000 */#define WSP_EXPORTING#include <awsp.h>#include <xptTransport.h>  // For the XPTDEBUG macro#include <xptport.h>#define RESPONSE_BODY "This is a response to a syncml document"//#define RESPONSE_HDR  "Content-Length: 39\nContent-Type: text/plain\n\n"#define RESPONSE_HDR  "Content-Length: 39\nContent-Type: text/plain\nCache-Control: private\nLocation: http:\\\\www.ibm.com\\\nRetry-After: 30\nWWW-Authenticate: Basic realm=\"MyRealm\"\n\n"//#define RESPONSE_HDR  "Content-Length: 39\nContent-Type: text/plain\nCache-Control: private\nLocation: http:\\\\www.ibm.com\\\nRetry-After: 30\nWWW-Authenticate: Digest  realm=\"MyRealm\",domain=\"www.ibm.com\",nonce=\"12A7536F48\", opaque=\"9A1B8C2D7E3F6\",stale=\"true\",  algorithm=\"MD5\",qop=\"auth\"\n\n"//#define RESPONSE_HDR  "Content-Length: 39\nContent-Type: text/plain\nCache-Control: private\nLocation: http:\\\\www.ibm.com\\\nRetry-After: 30\nAuthentication-Info: nextnonce=\"12A7536F48\", rspauth=\"123456789\",cnonce=\"9A1B8C2D7E3F6\",nc=00000001\n\n"#define RESPONSE_STATUS AWSP_SUCCESS//#define RESPONSE_STATUS AWSP_INTERNAL_SERVER_ERROR/*****************************************************************************//*****************************************************************************//**                                                                         **//**                     Prototypes of WSP functions                        **//**                                                                         **//*****************************************************************************//*****************************************************************************/XPTEXP1 awsp_Rc_t XPTAPI XPTEXP2 awsp_connect_req(awsp_ConnectionHandle connHandle,                           awsp_SessionHandle   *sessionHandle,                           const char           *clientHttpHeaders,                           const size_t          clientHttpHeadersLength,                           awsp_Capabilities    *requestedCapabilities){   const char *eye = "SESSIONHANDLE";   char *handle = NULL;   XPTDEBUG(("awsp_connect_req(%lx, %lx, %s, %lu, %lx)\n",          (unsigned long) connHandle, (unsigned long) sessionHandle,          clientHttpHeaders, (unsigned long) clientHttpHeadersLength,          (unsigned long) requestedCapabilities));   handle = (char *) xppMalloc(xppStrlen(eye) + 1);   xppStrcpy(handle, eye);   *sessionHandle = (void *) handle;   return AWSP_RC_OK;} /* End awsp_connect_req() */XPTEXP1 awsp_Rc_t XPTAPI XPTEXP2 awsp_get_connect_cnf(awsp_SessionHandle    sessionHandle,                               const char           *serverHttpHeaders,                               size_t               *serverHttpHeadersLength,                               awsp_Capabilities   **negotiatedCapabilities){   XPTDEBUG(("awsp_get_connect_cnf(%lx, %s, %lu, %lx)\n",          (unsigned long) sessionHandle, serverHttpHeaders,          (unsigned long) serverHttpHeadersLength,          (unsigned long) negotiatedCapabilities));   return AWSP_RC_OK;} /* End awsp_get_connect_cnf() */XPTEXP1 awsp_Rc_t XPTAPI XPTEXP2 awsp_disconnect_req(awsp_SessionHandle sessionHandle,                              int                reasonCode,                              awsp_BOOL          redirectSecurity,                              const char        *redirectAddresses[],                              const char        *errorHeaders,                              size_t             errorHeadersLength,                              void              *errorBody,                              size_t             errorBodyLength){   XPTDEBUG(("awsp_disconnect_req(%lx, %d, %i, %lx, %s, %lu, %lx, %lu)\n",          (unsigned long) sessionHandle, reasonCode, (int) redirectSecurity,          (unsigned long) redirectAddresses, errorHeaders,          (unsigned long) errorHeadersLength, (unsigned long) errorBody,          (unsigned long) errorBodyLength));   xppFree(sessionHandle);   return AWSP_RC_OK;} /* End awsp_disconnect_req() */XPTEXP1 awsp_Rc_t XPTAPI XPTEXP2 awsp_methodInvoke_req(awsp_SessionHandle sessionHandle,                           unsigned long      clientTransactionID,                           const char        *method,                           const char        *requestURI,                           const char        *requestHeaders,                           size_t             requestHeadersLength,                           void              *requestBody,                           size_t             requestBodyLength){   XPTDEBUG(("awsp_methodInvoke_req(%lx, %lu, %s, %s, %s, %lu, %lx, %lu)\n",          (unsigned long) sessionHandle, clientTransactionID, method,          requestURI, requestHeaders, (unsigned long) requestHeadersLength,          (unsigned long) requestBody, (unsigned long) requestBodyLength));   return AWSP_RC_OK;} /* End awsp_methodInvoke_req() */XPTEXP1 awsp_Rc_t XPTAPI XPTEXP2 awsp_get_methodResult_ind(awsp_SessionHandle  sessionHandle,                                    unsigned long       clientTransactionID,                                    awsp_StatusCode_t  *status,                                    char               *responseHeaders,                                    size_t             *responseHeadersLength,                                    void               *responseBody,                                    size_t             *responseBodyLength){   const char *body = RESPONSE_BODY;   const char *hdrs = RESPONSE_HDR;   awsp_Rc_t   rc   = AWSP_RC_OK;   XPTDEBUG(("awsp_get_methodResult_ind(%lx, %lu, %lx, %s, %lu, %lx, %lu)\n",          (unsigned long) sessionHandle, clientTransactionID, (unsigned long) status,          responseHeaders, (unsigned long) responseHeadersLength,          (unsigned long) responseBody, (unsigned long) responseBodyLength));   if ((responseHeadersLength == NULL) || (responseBodyLength == NULL))     return -1;   if ((*responseHeadersLength < (xppStrlen(hdrs) + 1)) || (*responseBodyLength < xppStrlen(body)))     rc = AWSP_RC_BUFFER_TOO_SMALL;   *responseHeadersLength = xppStrlen(hdrs) + 1;   *responseBodyLength    = xppStrlen(body);   if (rc != AWSP_RC_OK)     return rc;   if ((responseHeaders == NULL) || (responseBody == NULL))     return AWSP_RC_BUFFER_TOO_SMALL;

⌨️ 快捷键说明

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