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

📄 wsphttp.c

📁 SyncML手册及其编程
💻 C
📖 第 1 页 / 共 3 页
字号:
   if (parmPtr == NULL)      return SML_ERR_A_XPT_INVALID_PARM;   if (parmPtr->request == NULL)      return SML_ERR_OK;   rc = updateStringField(&(parmPtr->request->referer), referer);   return rc;} /* End httpSetReferer */unsigned int httpParseResponseHdr(WspHttpParms_t *parmPtr, const char *rspHeader){   unsigned int rc = SML_ERR_OK;   XPTDEBUG(("    httpParseResponseHdr(%lx, %s)\n", (unsigned long) parmPtr, rspHeader));   rc = initializeResponseParms(parmPtr, rspHeader);   if (rc != SML_ERR_OK)      return rc;   rc = validateResponse(parmPtr);   return rc;} /* End httpParseResponseHdr */unsigned int initializeRequestParms(WspHttpParms_t *parmPtr, const char *settings){   unsigned int rc = SML_ERR_OK;   XPTDEBUG(("    initializeRequestParms(%lx, %s)\n", (unsigned long) parmPtr, settings));   if (parmPtr == NULL)      return SML_ERR_A_XPT_INVALID_PARM;   if (parmPtr->request != NULL)      releaseRequestParms(parmPtr->request);   parmPtr->request = (WspHttpRequestParms_t *) xppMalloc(sizeof(WspHttpRequestParms_t));   if (parmPtr->request == NULL)      return SML_ERR_A_XPT_MEMORY;   xppMemset(parmPtr->request, 0, sizeof(WspHttpRequestParms_t));   rc = parseRequestParms(parmPtr->request, settings);   if (rc != SML_ERR_OK) {      releaseRequestParms(parmPtr->request);      parmPtr->request = NULL;   }   return rc;} /* End initializeRequestParms() */unsigned int parseRequestParms(WspHttpRequestParms_t *request, const char *settings){   unsigned int   rc             = SML_ERR_OK;   XPTDEBUG(("    parseRequestParms(%lx, %s)\n", (unsigned long) request, settings));   if (request == NULL)      return SML_ERR_A_XPT_INVALID_PARM;   if (settings == NULL)      return rc;   request->accept = getMetaInfoValue(settings, WSP_HTTP_ACCEPT);   request->acceptCharset = getMetaInfoValue(settings, WSP_HTTP_ACCEPT_CHARSET);   request->acceptEncoding = getMetaInfoValue(settings, WSP_HTTP_ACCEPT_ENCODING);   request->acceptLanguage = getMetaInfoValue(settings, WSP_HTTP_ACCEPT_LANGUAGE);   request->from = getMetaInfoValue(settings, WSP_HTTP_FROM);   rc = parseAuthorizationParms(request, settings);   if (rc != SML_ERR_OK)      return rc;   /* If client didn't specify certain header tags, we need to default them.    * Note that we use dynamic storage so we don't have to constantly    * distinguish between default and specified values when managing the    * object    */   if (request->accept == NULL) {      request->accept = (char *) xppMalloc(xppStrlen(D_ACCEPT) + 1);      if (request->accept != NULL)         xppStrcpy(request->accept,D_ACCEPT);   }   if (request->acceptCharset == NULL) {      request->acceptCharset = (char *) xppMalloc(xppStrlen(D_ACCEPT_CHARSET) + 1);      if (request->acceptCharset != NULL)         xppStrcpy(request->acceptCharset, D_ACCEPT_CHARSET);   }   return rc;} /* End parseRequestParms() */unsigned int parseAuthorizationParms(WspHttpRequestParms_t *request, const char *settings){   unsigned int   rc             = SML_ERR_OK;   unsigned int   validAuthParms = 0;   char    *tempValue      = NULL;   XPTDEBUG(("    parseAuthorizationParms(%lx, %s)\n", (unsigned long) request, settings));   if ((request == NULL) || (settings == NULL))      return rc;   /* We can't do any auth without a userid, so if no userid is    * present then ignore other auth parms.  We also need the realm.    * But since the password isn't required for Digest, we don't    * care if it's present or not at this time    */   tempValue = getMetaInfoValue(settings, WSP_HTTP_AUTH_USERID);   if (tempValue == NULL)      return rc;   rc = initializeAuthorizationParms(&(request->authorization));   if (rc != SML_ERR_OK) {      xppFree(tempValue);      return rc;   }   request->authorization->userid = tempValue;   if (request->authorization->userid != NULL) {      validAuthParms = 1;      request->authorization->realm = getMetaInfoValue(settings, WSP_HTTP_AUTH_REALM);      if (request->authorization->realm != NULL)         request->authorization->password = getMetaInfoValue(settings, WSP_HTTP_AUTH_PASSWORD);      else         validAuthParms = 0;   } /* End valid userid */   if (!validAuthParms) {      releaseAuthorizationParms(request->authorization);      rc = SML_ERR_A_XPT_INVALID_PARM;   }   return rc;} /* End parseAuthorizationParms() */unsigned int initializeAuthorizationParms(WspAuthorization_t **auth){   unsigned int rc = SML_ERR_OK;   XPTDEBUG(("    initializeAuthorizationParms(%lx)\n", (unsigned long) auth));   if (auth == NULL)      return SML_ERR_A_XPT_INVALID_PARM;   if (*auth != NULL)      releaseAuthorizationParms(*auth);   *auth = (WspAuthorization_t *) xppMalloc(sizeof(WspAuthorization_t));   if (*auth == NULL)      return SML_ERR_A_XPT_MEMORY;   xppMemset(*auth, 0, sizeof(WspAuthorization_t));   return rc;} /* End initializeAuthorization() */unsigned int initializeResponseParms(WspHttpParms_t *parmPtr, const char *rspHeader){   unsigned int rc = SML_ERR_OK;   XPTDEBUG(("    initializeResponseParms(%lx, %s)\n", (unsigned long) parmPtr, rspHeader));   if (parmPtr == NULL)      return SML_ERR_A_XPT_INVALID_PARM;   if (parmPtr->response != NULL)      releaseResponseParms(parmPtr->response);   parmPtr->response = (WspHttpResponseParms_t *) xppMalloc(sizeof(WspHttpResponseParms_t));   if (parmPtr->response == NULL)      return SML_ERR_A_XPT_MEMORY;   xppMemset(parmPtr->response, 0, sizeof(WspHttpResponseParms_t));   rc = parseResponseParms(parmPtr->response, rspHeader);/* I think we may want to leave whatever response info we can process so it * can be queried for 'why it failed'.  It'll be cleaned up on the next * request anyway *//*   if (rc != SML_ERR_OK) {      releaseResponseParms(parmPtr->response);      parmPtr->response = NULL;   }*/   return rc;} /* End initializeResponseParms() */unsigned int parseResponseParms(WspHttpResponseParms_t *response, const char *rspHdr){   unsigned int rc = SML_ERR_OK;   char  *tempValue = NULL;   XPTDEBUG(("    parseResponseParms(%lx, %s)\n", (unsigned long) response, rspHdr));   if (response == NULL)      return SML_ERR_A_XPT_INVALID_PARM;   if (rspHdr == NULL)      return rc;   /* Binding MUST support                                                     */   /* Binding must honor                                                       */   /* Cache-control: private                                                   */   response->cacheControl = getHeaderTag("Cache-Control", rspHdr);   /* Binding optionally supports                                              */   /* Either Binding does redirect automatically, or reflects to client        */   /* Location: "URI"                                                          */   response->location = getHeaderTag("Location", rspHdr);   /* Binding optionally supports                                              */   /* Either Binding does retry automatically, or reflects to client           */   /* Retry-After: <date|secs>                                                 */   response->retryAfter = getHeaderTag("Retry-After", rspHdr);   /* Binding MUST support                                                     */   /* Binding must verify successful client auth                               */   /* Authentication-Info: <info>                                               */   tempValue = getHeaderTag("Authentication-Info", rspHdr);   if (tempValue != NULL)      rc = initializeAuthVerification(response, tempValue);   xppFree(tempValue);   if (rc != SML_ERR_OK)      return rc;           /* Keep whatever response info we have...???        */   /* Binding MUST support                                                     */   /* Binding must reply to challenge with Authorization                       */   /* WWW-Authenticate: <auth challenge>                                       */   tempValue = getHeaderTag("WWW-Authenticate", rspHdr);   if (tempValue != NULL)      rc = initializeAuthChallenge(response, tempValue);   xppFree(tempValue);   return rc;} /* End parseResponseParms() */unsigned int initializeAuthVerification(WspHttpResponseParms_t *response,                                        char *tempValue){   unsigned int rc = SML_ERR_OK;   XPTDEBUG(("    initializeAuthVerification(%lx, %s)\n", (unsigned long) response, tempValue));   if (response == NULL)      return SML_ERR_A_XPT_INVALID_PARM;   releaseAuthenticationParms(response->authVerification);   if (tempValue == NULL)      return rc;   response->authVerification = (WspAuthentication_t *) xppMalloc(sizeof(WspAuthentication_t));   if (response->authVerification == NULL)      return SML_ERR_A_XPT_MEMORY;   xppMemset(response->authVerification, 0, sizeof(WspAuthentication_t));   rc = parseAuthVerification(response->authVerification, tempValue);   return rc;} /* End initializeAuthVerification() */unsigned int parseAuthVerification(WspAuthentication_t *auth, const char *source){   XPTDEBUG(("    parseAuthVerification(%lx, %s)\n", (unsigned long) auth, source));   if ((auth == NULL) || (source == NULL))      return SML_ERR_A_XPT_INVALID_PARM;   auth->nextNonce = getHeaderParmValue("nextnonce", source);   auth->qop       = getHeaderParmValue("qop", source);   auth->rspAuth   = getHeaderParmValue("rspauth", source);   auth->cnonce    = getHeaderParmValue("cnonce", source);   auth->nc        = getHeaderParmValue("nc", source);   return SML_ERR_OK;} /* End parseAuthVerification() */unsigned int initializeAuthChallenge(WspHttpResponseParms_t *response,                                     char *tempValue){   unsigned int rc = SML_ERR_OK;   XPTDEBUG(("    initializeAuthChallenge(%lx, %s)\n", (unsigned long) response, tempValue));   if (response == NULL)      return SML_ERR_A_XPT_INVALID_PARM;   releaseChallengeParms(response->authChallenge);   if (tempValue == NULL)      return rc;

⌨️ 快捷键说明

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