void tektextcenter(const char *str, const t_bunny_position *pos, t_bunny_pixelarray *out, t_font *font) { int i; int j; t_bunny_position pix; int sp; pix.y = pos->y - count_line(str, font->font_size); sp = count_space(str, font->font_size, 0); i = 0; j = 0; while (str[i]) { if (str[i] == '\n') { pix.y += font->font_size + font->font_size / 4; j = 0; sp = count_space(str, font->font_size, ++i); } else { pix.x = pos->x + j * font->font_size + (font->font_size / 4) * j - sp; tekchar(out, font, &pix, str[i++]); j++; } } }
CommandHolder::CommandHolder(const std::string& name, const std::string& params, const std::string& summary, uint32_t since, const std::string& example, uint8_t required_arguments_count, uint8_t optional_arguments_count, Type type, function_t func, test_functions_t tests) : CommandInfo(name, params, summary, since, example, required_arguments_count, optional_arguments_count, type), func_(func), white_spaces_count_(count_space(name)), test_funcs_(tests) {}
bool CommandHolder::IsEqualFirstName(const std::string& cmd_first_name) const { DCHECK(count_space(cmd_first_name) == 0) << "Command (" << cmd_first_name << ") should be without spaces."; if (white_spaces_count_ == 0) { return IsEqualName(cmd_first_name); } for (size_t i = 0; i < name.size(); ++i) { char c = name[i]; if (std::isspace(c)) { return common::FullEqualsASCII(cmd_first_name, name.substr(0, i), false); } } return IsEqualName(cmd_first_name); }
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(); }
uint32_t mm_kspace(void) { return count_space(kernelheap, MM_KERNEL_NUM_BLOCKS, &kernelheap_mutex); }
uint32_t mm_space(void) { return count_space(userheap, MM_USER_NUM_BLOCKS, &userheap_mutex); }