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

📄 session.c

📁 SyncML手册及其编程
💻 C
📖 第 1 页 / 共 2 页
字号:
   return rc;}   /* End of sessionResume() */unsigned int initializeSession(WspSession_t **oSession){   unsigned int  rc      = SML_ERR_OK;   WspSession_t *session = NULL;   XPTDEBUG(("      initializeSession(%lx)\n", (unsigned long) oSession));   if (oSession == NULL)      return SML_ERR_A_XPT_INVALID_PARM;   if (*oSession != NULL)      sessionDisconnect(*oSession);   session = (WspSession_t *) xppMalloc(sizeof(WspSession_t));   if (session == NULL)      rc = SML_ERR_A_XPT_MEMORY;   xppMemset(session, 0, sizeof(WspSession_t));   *oSession = session;   return rc;} /* End of initializeSession() *//** *  sessionRelease *       - releases all storage associated with the session. *       - nullifies the protocol structure's access to the session. * *  IN     pid             A pointer to a protocol handle structure * **/void sessionRelease(WspSession_t *session) {   if (session == NULL) return;   XPTDEBUG(("    sessionRelease(%lx)\n", (unsigned long) session));   releaseCapabilities(session);   releaseStaticClientHeaders(session);   releaseStaticServerHeaders(session);   xppFree(session);} /* End of sessionRelease() *//** *  releaseCapabilities *       - releases all storage associated with the session's negotiated *         capabilities. *       - nullifies the session structure's access to the capabilities. * *  IN     session         A pointer to a session structure * **/void releaseCapabilities(WspSession_t *session) {   XPTDEBUG(("      releaseCapabilities(%lx)\n", (unsigned long) session));   if (session == NULL) return;   /**    * The object was allocated by the WAP stack and deallocated when we    * disconnected the session, so we just have to nullify our pointer to it.    **/   session->negotiatedCapabilities = NULL;} /* End releaseCapabilities() */unsigned int getConnectResponse(WspSession_t *session){   unsigned int rc  = SML_ERR_OK;   awsp_Rc_t aRc = AWSP_RC_OK;   char *bufferPtr = NULL;   size_t  bufSize   = 0;   XPTDEBUG(("      getConnectResponse(%lx)\n", (unsigned long) session));   aRc = awsp_get_connect_cnf(session->sessionHandle,                              bufferPtr,                              &bufSize,                              &(session->negotiatedCapabilities));   if (aRc == AWSP_RC_BUFFER_TOO_SMALL) {      bufferPtr = (char *)xppMalloc(bufSize);      if (bufferPtr != NULL) {         xppMemset(bufferPtr, 0, bufSize);         aRc = awsp_get_connect_cnf(session->sessionHandle,                                    bufferPtr,                                    &bufSize,                                    &(session->negotiatedCapabilities));         if (aRc != AWSP_RC_OK) {            xppFree(bufferPtr);            releaseCapabilities(session);         } else {            /* allocated buffer is used, so don't release it                   */            initializeStaticServerHeaders(session, bufferPtr,bufSize);         }      } else         rc = SML_ERR_A_XPT_MEMORY;   } /* End of confirmation buffer acquisition */   if (aRc != AWSP_RC_OK) {      setLastError(aRc, "WSP Binding awsp connect confirmation failed.");      rc = SML_ERR_A_XPT_COMMUNICATION;   }   return rc;} /* End of getConnectResponse() */unsigned int getResumeResponse(awsp_ConnectionHandle connHandle, WspSession_t *session){   unsigned int rc      = SML_ERR_OK;   awsp_Rc_t aRc      = AWSP_RC_OK;   char     *hdrBuf   = NULL;   size_t   hdrLength = 0;   XPTDEBUG(("      getResumeResponse(%lx, %lx)\n", (unsigned long) connHandle, (unsigned long) session));   aRc = awsp_get_resume_cnf(connHandle,                            &(session->sessionHandle),                            hdrBuf,                            &hdrLength);   if (aRc == AWSP_RC_BUFFER_TOO_SMALL) {      hdrBuf = (char *) xppMalloc(hdrLength);      if (hdrBuf != NULL) {         xppMemset(hdrBuf, 0, hdrLength);         aRc = awsp_get_resume_cnf(connHandle,                                  &(session->sessionHandle),                                  hdrBuf,                                  &hdrLength);         if (aRc != AWSP_RC_OK)            xppFree(hdrBuf);         else            /* move static header info into static buffer */            initializeStaticServerHeaders(session, hdrBuf, hdrLength);      } else         rc = SML_ERR_A_XPT_MEMORY;   }   if (aRc != AWSP_RC_OK) {      setLastError(aRc, "WSP Binding awsp resume confirmation failed.");      return SML_ERR_A_XPT_COMMUNICATION;   }   return rc;} /* End getResumeResponse() */void initializeStaticServerHeaders(WspSession_t *session,                                   char *bufferPtr,                                   size_t bufSize) {   XPTDEBUG(("      initializeStaticServerHeaders(%lx, %lx, %lu)\n",             (unsigned long) session, (unsigned long) bufferPtr, (unsigned long) bufSize));   if (session->staticServerHeaders != NULL)      releaseStaticServerHeaders(session);   session->staticServerHeaders = bufferPtr;} /* End initializeStaticServerHeaders *//** *  releaseStaticServerHeaders *       - releases all storage associated with the session's server-specified *         'static' HTTP header. *       - nullifies the session structure's access to this header. * *  IN     session         A pointer to a session structure * **/void releaseStaticServerHeaders(WspSession_t *session) {   XPTDEBUG(("      releaseStaticServerHeaders(%lx)\n", (unsigned long) session));   if (session == NULL) return;   xppFree((void *)session->staticServerHeaders);   session->staticServerHeaders = NULL;} /* End releaseStaticServerHeaders() *//** *  releaseStaticClientHeaders *       - releases all storage associated with the session's client-specified *         'static' HTTP header. *       - nullifies the session structure's access to this header. * *  IN     session         A pointer to a session structure * **/void releaseStaticClientHeaders(WspSession_t *session) {   XPTDEBUG(("      releaseStaticClientHeaders(%lx)\n", (unsigned long) session));   if (session == NULL) return;   xppFree((void *)session->staticClientHeaders);   session->staticClientHeaders = NULL;} /* End releaseStaticClientHeaders() *//** *  sessionIsConnected *       - Determines if the service access point was opened for session *         connections, and whether we have established a valid session. * *  IN:    session      A pointer to a session structure * *  RETURN: *       AWSP_TRUE      We are in session mode *       AWSP_FALSE     We are in connectionless mode **/awsp_BOOL sessionIsConnected(WspSession_t *session){/* We can verify what port the SAP was opened with only if the SAP parms   were specified by the app - how do we know what port was used with   the default initializeSAP()?  I guess we should heed whatever rc comes   back from the sessionCreate - and if the RC indicates that the port   doesn't support sessions, we'll know that the SAP is connectionless..   Presumably the session handle doesn't exist if the SAP was opened   for connectionless communication...What if SAP was opened for Session   but something prevented the session handle from being created?   if (sapSessionMode == AWSP_FALSE)      return AWSP_FALSE;*/   XPTDEBUG(("    sessionIsConnected(%lx)\n", (unsigned long) session));   if ((session == NULL) || (session->sessionHandle == NULL))      return AWSP_FALSE;   return AWSP_TRUE;} /* End sessionIsConnected() */const char *sessionGetStaticServerHeaders(WspSession_t *session){   XPTDEBUG(("    sessionGetStaticServerHeaders()\n"));   if (session == NULL)      return NULL;   return session->staticServerHeaders;} /* End sessionGetStaticServerHeaders() */

⌨️ 快捷键说明

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