static int my_find_key(_FW_URL_FUNC_ARGV) { int total, n; char key[256]; sort_idx_t idx; char *buf_data = m_buf_data[pthread_idx]; char *tmp_data = m_tmp_data[pthread_idx]; strncpy(key, http->hp_param("key"), sizeof(key) - 1); key[sizeof(key) - 1] = 0; trim(key); /* TODO */ q_tolower(key); if (_is_http_full_text(http)) return my_find_full_text(ws, http, sock, pthread_idx, key); if (m_wiki_index->wi_find(key, WK_KEY_FIND, -1, &idx, &total) == 0) { if ((n = m_wiki_data->wd_sys_read((int)idx.data_file_idx, idx.data_pos, (int)idx.data_len, buf_data, MAX_PAGE_LEN)) > 0) { char *data = convert_nohtml(buf_data, n, tmp_data, &n); output_one_page(sock, ws, data, n, http->hp_param("key")); return 0; } } return output_one_page(sock, ws, "Not Found", 9, ""); }
int q_strncasecmp(const char *s1, const char *s2, size_t n) { const char * p1 = s1; const char * p2 = s2; char c1, c2; if (p1 == p2 || n == 0) return 0; do { c1 = q_tolower (*p1++); c2 = q_tolower (*p2++); if (c1 == '\0' || c1 != c2) break; } while (--n > 0); return (int)(c1 - c2); }
int q_strcasecmp(const char * s1, const char * s2) { const char * p1 = s1; const char * p2 = s2; char c1, c2; if (p1 == p2) return 0; do { c1 = q_tolower (*p1++); c2 = q_tolower (*p2++); if (c1 == '\0') break; } while (c1 == c2); return (int)(c1 - c2); }
char *q_strlwr (char *str) { char *c; c = str; while (*c) { *c = q_tolower(*c); c++; } return str; }