void CNodedMemoryBuffer::SkipNode() { while(ReadNextFieldHeader()) { SkipField(); } }
BOOLEAN HttpcCheckSW() { UCHAR pOldFile[MAX_DNS_LEN]; UCHAR pNewFile[MAX_DNS_LEN]; UCHAR pFlag[32]; PCHAR pCur; PCHAR pImage; UCHAR iLen; iLen = strlen(_pProvSwUrl); if (!iLen) { UdpDebugString("No SW image"); return FALSE; } pImage = (PCHAR)(_pProvSwUrl + iLen); while (pImage != _pProvSwUrl) { if (*pImage == (UCHAR)'/') { pImage ++; break; } else { pImage --; } }; strcpy(pNewFile, pImage); pCur = SkipField(pNewFile, '_'); if (pCur) { OptionsGetString(pFlag, OPT_FLAG_PRODUCT, MAX_FLAG_PRODUCT_LEN); if (!strcmp(pNewFile, pFlag)) { OptionsGetString(pFlag, OPT_FLAG_PROTOCOL, MAX_FLAG_PROTOCOL); strcpy(pOldFile, pFlag); strcat_char(pOldFile, '_'); OptionsGetString(pFlag, OPT_FLAG_COUNTRY, MAX_FLAG_COUNTRY); strcat(pOldFile, pFlag); strcat_char(pOldFile, '_'); OptionsGetString(pFlag, OPT_FLAG_OEM, MAX_FLAG_OEM_LEN); if (strlen(pFlag)) { strcat(pOldFile, pFlag); strcat_char(pOldFile, '_'); } OptionsGetString(pFlag, OPT_FLAG_VERSION, MAX_FLAG_VERSION); strcat(pOldFile, pFlag); strcat(pOldFile, ".bin"); if (strcmp(pCur, pOldFile)) { return TRUE; } } } return FALSE; }
PCHAR _unquote_str(PCHAR pStr) { PCHAR pTemp; PCHAR pCur; pCur = pStr; pTemp = strchr(pCur, '"'); if (pTemp) { pCur = pTemp; pCur ++; SkipField(pCur, '"'); } else { SkipField(pCur, ' '); } return pCur; }
USHORT GetProvPort() { PCHAR pCur; pCur = SkipField(_pProvUrl, ':'); if (pCur) { return atoi(pCur, 10); } return 0; }
bool WireFormatLite::SkipMessage(io::CodedInputStream* input) { while(true) { uint32 tag = input->ReadTag(); if (tag == 0) { // End of input. This is a valid place to end, so return true. return true; } WireFormatLite::WireType wire_type = WireFormatLite::GetTagWireType(tag); if (wire_type == WireFormatLite::WIRETYPE_END_GROUP) { // Must be the end of the message. return true; } if (!SkipField(input, tag)) return false; } }
void http_digest(PCHAR pDstBuf, PCHAR pAuthData, PCHAR pUri, PCHAR pAccount, PCHAR pPassword, PCHAR pMethod) { PCHAR pCur; PCHAR pTemp; PCHAR pValue; PCHAR pRealm; PCHAR pNonce; PCHAR pOpaque; BOOLEAN bRealm, bNonce, bOpaque; UCHAR iAlg, iQop; UCHAR pHA1[33]; UCHAR pHA2[33]; UCHAR pMD5Value[MD5_SIGNATURE_SIZE]; strcpy(pDstBuf, pAuthData); pCur = pDstBuf; if (memcmp_lowercase(pCur, "digest ")) { pDstBuf[0] = 0; return; } pCur += 7; iQop = QOP_NONE; iAlg = ALG_NONE; pRealm = NULL; pNonce = NULL; pOpaque = NULL; bRealm = FALSE; bNonce = FALSE; bOpaque = FALSE; do { pTemp = SkipField(pCur, ','); pValue = SkipField(pCur, '='); pValue = _unquote_str(pValue); if (!strcmp_lowercase(pCur, "realm")) { if (!bRealm) { pRealm = heap_save_str(pValue); bRealm = TRUE; } } else if (!strcmp_lowercase(pCur, "nonce")) { if (!bNonce) { pNonce = heap_save_str(pValue); bNonce = TRUE; } } else if (!strcmp_lowercase(pCur, "opaque")) { if (!bOpaque) { pOpaque = heap_save_str(pValue); bOpaque = TRUE; } } else if (!strcmp_lowercase(pCur, "qop")) { iQop = QOP_AUTH; } else if (!strcmp_lowercase(pCur, "algorithm")) { if (!strcmp_lowercase(pValue, "md5")) { iAlg = ALG_MD5; } if (!strcmp_lowercase(pValue, "md5-sess")) { iAlg = ALG_MD5SESS; } } if (pTemp) { pCur = pTemp; // pCur ++; pCur += count_space(pCur); } } while (pTemp); line_backup(); // generate HA1 line_start(pDstBuf); line_add_str_with_char(pAccount, ':'); line_add_str_with_char(pRealm, ':'); line_add_str(pPassword); MD5GenValue(pHA2, pDstBuf, line_get_len()); TaskMiniRun(); if (iAlg == ALG_MD5SESS) { line_start(pDstBuf); line_add_data(pHA2, MD5_SIGNATURE_SIZE); line_add_char(':'); line_add_str_with_char(pNonce, ':'); line_add_str(_cCnonce); MD5GenValue(pHA2, pDstBuf, line_get_len()); TaskMiniRun(); } char2asc_str(pHA1, pHA2, MD5_SIGNATURE_SIZE, FALSE); // Generate HA2 line_start(pDstBuf); line_add_str_with_char(pMethod, ':'); line_add_str(pUri); if (iQop == QOP_AUTHINT) { line_add_char(':'); line_add_str(_cHEntity); } MD5GenValue(pMD5Value, pDstBuf, line_get_len()); TaskMiniRun(); char2asc_str(pHA2, pMD5Value, MD5_SIGNATURE_SIZE, FALSE); // generate final response line_start(pDstBuf); line_add_str_with_char(pHA1, ':'); line_add_str_with_char(pNonce, ':'); if (iQop != QOP_NONE) { line_add_str_with_char(_cNc, ':'); line_add_str_with_char(_cCnonce, ':'); line_add_str_with_char(_cQopType[iQop], ':'); } line_add_str(pHA2); MD5GenValue(pMD5Value, pDstBuf, line_get_len()); TaskMiniRun(); char2asc_str(pHA2, pMD5Value, MD5_SIGNATURE_SIZE, FALSE); // Write response line_start(pDstBuf); line_add_str("Digest username=\""); line_add_str_with_char(pAccount, '"'); if (bRealm) { line_add_str(",realm=\""); line_add_str_with_char(pRealm, '"'); } if (bNonce) { line_add_str(",nonce=\""); line_add_str_with_char(pNonce, '"'); } line_add_str(",uri=\""); line_add_str_with_char(pUri, '"'); // qop=auth, some system don't allow quote sign qop="auth" here if (iQop != QOP_NONE) { line_add_str(",qop="); line_add_str(_cQopType[iQop]); line_add_str(",nc="); line_add_str(_cNc); line_add_str(",cnonce=\""); line_add_str_with_char(_cCnonce, '"'); } if (bOpaque) { line_add_str(",opaque=\""); line_add_str_with_char(pOpaque, '"'); } if (iAlg != ALG_NONE) { line_add_str(",algorithm="); line_add_str(_cAlgType[iAlg]); } line_add_str(",response=\""); line_add_str_with_char(pHA2, '"'); if (pRealm) free(pRealm); if (pNonce) free(pNonce); if (pOpaque) free(pOpaque); line_restore(); }