TTKMusicPlayer
4.1.3.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
|
#include "http_parser.h"
#include <assert.h>
#include <stddef.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
Go to the source code of this file.
Macros | |
#define | ULLONG_MAX ((uint64_t) -1) /* 2^64-1 */ |
#define | MIN(a, b) ((a) < (b) ? (a) : (b)) |
#define | ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) |
#define | BIT_AT(a, i) |
#define | ELEM_AT(a, i, v) ((unsigned int) (i) < ARRAY_SIZE(a) ? (a)[(i)] : (v)) |
#define | SET_ERRNO(e) |
#define | CURRENT_STATE() p_state |
#define | UPDATE_STATE(V) p_state = (enum state) (V); |
#define | RETURN(V) |
#define | REEXECUTE() goto reexecute; \ |
#define | LIKELY(X) (X) |
#define | UNLIKELY(X) (X) |
#define | CALLBACK_NOTIFY_(FOR, ER) |
#define | CALLBACK_NOTIFY(FOR) CALLBACK_NOTIFY_(FOR, p - data + 1) |
#define | CALLBACK_NOTIFY_NOADVANCE(FOR) CALLBACK_NOTIFY_(FOR, p - data) |
#define | CALLBACK_DATA_(FOR, LEN, ER) |
#define | CALLBACK_DATA(FOR) CALLBACK_DATA_(FOR, p - FOR##_mark, p - data + 1) |
#define | CALLBACK_DATA_NOADVANCE(FOR) CALLBACK_DATA_(FOR, p - FOR##_mark, p - data) |
#define | MARK(FOR) |
#define | COUNT_HEADER_SIZE(V) |
#define | PROXY_CONNECTION "proxy-connection" |
#define | CONNECTION "connection" |
#define | CONTENT_LENGTH "content-length" |
#define | TRANSFER_ENCODING "transfer-encoding" |
#define | UPGRADE "upgrade" |
#define | CHUNKED "chunked" |
#define | KEEP_ALIVE "keep-alive" |
#define | CLOSE "close" |
#define | XX(num, name, string) #string, |
#define | T(v) 0 |
#define | PARSING_HEADER(state) (state <= s_headers_done) |
#define | CR '\r' |
#define | LF '\n' |
#define | LOWER(c) (unsigned char)(c | 0x20) |
#define | IS_ALPHA(c) (LOWER(c) >= 'a' && LOWER(c) <= 'z') |
#define | IS_NUM(c) ((c) >= '0' && (c) <= '9') |
#define | IS_ALPHANUM(c) (IS_ALPHA(c) || IS_NUM(c)) |
#define | IS_HEX(c) (IS_NUM(c) || (LOWER(c) >= 'a' && LOWER(c) <= 'f')) |
#define | IS_MARK(c) |
#define | IS_USERINFO_CHAR(c) |
#define | STRICT_TOKEN(c) (tokens[(unsigned char)c]) |
#define | TOKEN(c) (tokens[(unsigned char)c]) |
#define | IS_URL_CHAR(c) (BIT_AT(normal_url_char, (unsigned char)c)) |
#define | IS_HOST_CHAR(c) (IS_ALPHANUM(c) || (c) == '.' || (c) == '-') |
#define | start_state (parser->type == HTTP_REQUEST ? s_start_req : s_start_res) |
#define | STRICT_CHECK(cond) |
#define | NEW_MESSAGE() (http_should_keep_alive(parser) ? start_state : s_dead) |
#define | HTTP_STRERROR_GEN(n, s) { "HPE_" #n, s }, |
Variables | |
static const char * | method_strings [] |
static const char | tokens [256] |
static const int8_t | unhex [256] |
static const uint8_t | normal_url_char [32] |
struct { | |
const char * name | |
const char * description | |
} | http_strerror_tab [] |
#define ARRAY_SIZE | ( | a | ) | (sizeof(a) / sizeof((a)[0])) |
Definition at line 41 of file http_parser.c.
#define BIT_AT | ( | a, | |
i | |||
) |
#define CALLBACK_DATA | ( | FOR | ) | CALLBACK_DATA_(FOR, p - FOR##_mark, p - data + 1) |
Definition at line 128 of file http_parser.c.
Referenced by http_parser_execute().
#define CALLBACK_DATA_ | ( | FOR, | |
LEN, | |||
ER | |||
) |
Definition at line 105 of file http_parser.c.
Referenced by http_parser_execute().
#define CALLBACK_DATA_NOADVANCE | ( | FOR | ) | CALLBACK_DATA_(FOR, p - FOR##_mark, p - data) |
Definition at line 132 of file http_parser.c.
Referenced by http_parser_execute().
#define CALLBACK_NOTIFY | ( | FOR | ) | CALLBACK_NOTIFY_(FOR, p - data + 1) |
Definition at line 99 of file http_parser.c.
Referenced by http_parser_execute().
#define CALLBACK_NOTIFY_ | ( | FOR, | |
ER | |||
) |
Definition at line 80 of file http_parser.c.
#define CALLBACK_NOTIFY_NOADVANCE | ( | FOR | ) | CALLBACK_NOTIFY_(FOR, p - data) |
Definition at line 102 of file http_parser.c.
Referenced by http_parser_execute().
#define CHUNKED "chunked" |
Definition at line 169 of file http_parser.c.
Referenced by http_parser_execute().
#define CLOSE "close" |
Definition at line 171 of file http_parser.c.
Referenced by http_parser_execute().
#define CONNECTION "connection" |
Definition at line 165 of file http_parser.c.
Referenced by http_parser_execute().
#define CONTENT_LENGTH "content-length" |
Definition at line 166 of file http_parser.c.
Referenced by http_parser_execute().
#define COUNT_HEADER_SIZE | ( | V | ) |
Definition at line 154 of file http_parser.c.
Referenced by http_parser_execute().
#define CR '\r' |
Definition at line 408 of file http_parser.c.
Referenced by http_parser_execute().
#define CURRENT_STATE | ( | ) | p_state |
Definition at line 59 of file http_parser.c.
Referenced by http_parser_execute().
#define ELEM_AT | ( | a, | |
i, | |||
v | |||
) | ((unsigned int) (i) < ARRAY_SIZE(a) ? (a)[(i)] : (v)) |
Definition at line 51 of file http_parser.c.
Referenced by http_method_str().
#define HTTP_STRERROR_GEN | ( | n, | |
s | |||
) | { "HPE_" #n, s }, |
Definition at line 456 of file http_parser.c.
Definition at line 411 of file http_parser.c.
Referenced by http_parser_execute(), and parse_url_char().
Definition at line 413 of file http_parser.c.
Definition at line 414 of file http_parser.c.
Referenced by http_parse_host_char().
#define IS_HOST_CHAR | ( | c | ) | (IS_ALPHANUM(c) || (c) == '.' || (c) == '-') |
Definition at line 427 of file http_parser.c.
Referenced by http_parse_host_char().
#define IS_MARK | ( | c | ) |
Definition at line 415 of file http_parser.c.
#define IS_NUM | ( | c | ) | ((c) >= '0' && (c) <= '9') |
Definition at line 412 of file http_parser.c.
Referenced by http_parse_host_char(), and http_parser_execute().
#define IS_URL_CHAR | ( | c | ) | (BIT_AT(normal_url_char, (unsigned char)c)) |
Definition at line 426 of file http_parser.c.
Referenced by parse_url_char().
#define IS_USERINFO_CHAR | ( | c | ) |
Definition at line 418 of file http_parser.c.
Referenced by http_parse_host_char(), and parse_url_char().
#define KEEP_ALIVE "keep-alive" |
Definition at line 170 of file http_parser.c.
Referenced by http_parser_execute().
#define LF '\n' |
Definition at line 409 of file http_parser.c.
Referenced by http_parser_execute().
#define LIKELY | ( | X | ) | (X) |
Definition at line 74 of file http_parser.c.
Referenced by http_parser_execute().
#define LOWER | ( | c | ) | (unsigned char)(c | 0x20) |
Definition at line 410 of file http_parser.c.
Referenced by http_parser_execute().
#define MARK | ( | FOR | ) |
Definition at line 136 of file http_parser.c.
Referenced by http_parser_execute().
#define MIN | ( | a, | |
b | |||
) | ((a) < (b) ? (a) : (b)) |
Definition at line 37 of file http_parser.c.
Referenced by http_parser_execute().
#define NEW_MESSAGE | ( | ) | (http_should_keep_alive(parser) ? start_state : s_dead) |
Definition at line 448 of file http_parser.c.
Referenced by http_parser_execute().
#define PARSING_HEADER | ( | state | ) | (state <= s_headers_done) |
Definition at line 360 of file http_parser.c.
Referenced by http_parser_execute().
#define PROXY_CONNECTION "proxy-connection" |
Definition at line 164 of file http_parser.c.
Referenced by http_parser_execute().
#define REEXECUTE | ( | ) | goto reexecute; \ |
Definition at line 66 of file http_parser.c.
Referenced by http_parser_execute().
#define RETURN | ( | V | ) |
Definition at line 61 of file http_parser.c.
Referenced by http_parser_execute().
#define SET_ERRNO | ( | e | ) |
Definition at line 54 of file http_parser.c.
Referenced by http_parser_execute(), and http_parser_pause().
#define start_state (parser->type == HTTP_REQUEST ? s_start_req : s_start_res) |
Definition at line 437 of file http_parser.c.
#define STRICT_CHECK | ( | cond | ) |
Definition at line 441 of file http_parser.c.
Referenced by http_parser_execute().
#define STRICT_TOKEN | ( | c | ) | (tokens[(unsigned char)c]) |
Definition at line 422 of file http_parser.c.
Referenced by http_parser_execute().
#define T | ( | v | ) | 0 |
Definition at line 237 of file http_parser.c.
Referenced by TTKAny::cast(), TTK::const_pointer_cast(), VariantHelper< T, Args...>::copy(), VariantHelper< T, Args...>::Destroy(), TTK::dynamic_pointer_cast(), TTKVariant< Types >::indexOf(), TTKSingleton< T >::instance(), TTKAny::isSame(), TTKVariant< Types >::isSame(), TTK::make_any(), VariantHelper< T, Args...>::move(), TTK::reinterpret_pointer_cast(), TTK::static_pointer_cast(), and TTKVariant< Types >::TTKVariant().
#define TOKEN | ( | c | ) | (tokens[(unsigned char)c]) |
Definition at line 425 of file http_parser.c.
Referenced by http_parser_execute().
#define TRANSFER_ENCODING "transfer-encoding" |
Definition at line 167 of file http_parser.c.
Referenced by http_parser_execute().
#define ULLONG_MAX ((uint64_t) -1) /* 2^64-1 */ |
Definition at line 33 of file http_parser.c.
Referenced by http_message_needs_eof(), and http_parser_execute().
#define UNLIKELY | ( | X | ) | (X) |
Definition at line 75 of file http_parser.c.
Referenced by http_parser_execute().
#define UPDATE_STATE | ( | V | ) | p_state = (enum state) (V); |
Definition at line 60 of file http_parser.c.
Referenced by http_parser_execute().
#define UPGRADE "upgrade" |
Definition at line 168 of file http_parser.c.
Referenced by http_parser_execute().
#define XX | ( | num, | |
name, | |||
string | |||
) | #string, |
enum header_states |
Definition at line 363 of file http_parser.c.
enum http_host_state |
Enumerator | |
---|---|
s_http_host_dead | |
s_http_userinfo_start | |
s_http_userinfo | |
s_http_host_start | |
s_http_host_v6_start | |
s_http_host | |
s_http_host_v6 | |
s_http_host_v6_end | |
s_http_host_port_start | |
s_http_host_port |
Definition at line 393 of file http_parser.c.
enum state |
Definition at line 279 of file http_parser.c.
int http_body_is_final | ( | const struct http_parser * | parser | ) |
Definition at line 2421 of file http_parser.c.
References s_message_done, and http_parser::state.
const char* http_errno_description | ( | enum http_errno | err | ) |
Definition at line 2162 of file http_parser.c.
References http_strerror_tab.
const char* http_errno_name | ( | enum http_errno | err | ) |
Definition at line 2155 of file http_parser.c.
References http_strerror_tab.
int http_message_needs_eof | ( | const http_parser * | parser | ) |
Definition at line 2089 of file http_parser.c.
References http_parser::content_length, F_CHUNKED, F_SKIPBODY, http_parser::flags, HTTP_REQUEST, http_parser::status_code, http_parser::type, and ULLONG_MAX.
Referenced by http_parser_execute(), and http_should_keep_alive().
const char* http_method_str | ( | enum http_method | m | ) |
Definition at line 2131 of file http_parser.c.
References ELEM_AT, and method_strings.
|
static |
Definition at line 2234 of file http_parser.c.
References http_parser_url::field_data, http_parser_url::field_set, http_parse_host_char(), http_parser_url::len, http_parser_url::off, s_http_host, s_http_host_dead, s_http_host_port, s_http_host_port_start, s_http_host_start, s_http_host_v6, s_http_host_v6_start, s_http_userinfo, s_http_userinfo_start, UF_HOST, UF_PORT, and UF_USERINFO.
Referenced by http_parser_parse_url().
|
static |
Definition at line 2169 of file http_parser.c.
References IS_HEX, IS_HOST_CHAR, IS_NUM, IS_USERINFO_CHAR, s_http_host, s_http_host_dead, s_http_host_port, s_http_host_port_start, s_http_host_start, s_http_host_v6, s_http_host_v6_end, s_http_host_v6_start, s_http_userinfo, and s_http_userinfo_start.
Referenced by http_parse_host().
size_t http_parser_execute | ( | http_parser * | parser, |
const http_parser_settings * | settings, | ||
const char * | data, | ||
size_t | len | ||
) |
Definition at line 626 of file http_parser.c.
References CALLBACK_DATA, CALLBACK_DATA_, CALLBACK_DATA_NOADVANCE, CALLBACK_NOTIFY, CALLBACK_NOTIFY_NOADVANCE, CHUNKED, CLOSE, CONNECTION, CONTENT_LENGTH, http_parser::content_length, COUNT_HEADER_SIZE, CR, CURRENT_STATE, F_CHUNKED, F_CONNECTION_CLOSE, F_CONNECTION_KEEP_ALIVE, F_CONNECTION_UPGRADE, F_SKIPBODY, F_TRAILING, F_UPGRADE, http_parser::flags, h_C, h_CO, h_CON, h_connection, h_connection_close, h_connection_keep_alive, h_connection_upgrade, h_content_length, h_general, h_matching_connection, h_matching_connection_close, h_matching_connection_keep_alive, h_matching_connection_token, h_matching_connection_token_start, h_matching_connection_upgrade, h_matching_content_length, h_matching_proxy_connection, h_matching_transfer_encoding, h_matching_transfer_encoding_chunked, h_matching_upgrade, h_transfer_encoding, h_transfer_encoding_chunked, h_upgrade, http_parser::header_state, http_parser::http_major, HTTP_MAX_HEADER_SIZE, http_message_needs_eof(), http_parser::http_minor, HTTP_PARSER_ERRNO, HTTP_REQUEST, HTTP_RESPONSE, http_parser::index, IS_ALPHA, IS_NUM, KEEP_ALIVE, LF, LIKELY, LOWER, MARK, http_parser::method, method_strings, MIN, NEW_MESSAGE, http_parser::nread, http_parser_settings::on_headers_complete, parse_url_char(), PARSING_HEADER, PROXY_CONNECTION, REEXECUTE, RETURN, s_body_identity, s_body_identity_eof, s_chunk_data, s_chunk_data_almost_done, s_chunk_data_done, s_chunk_parameters, s_chunk_size, s_chunk_size_almost_done, s_chunk_size_start, s_dead, s_header_almost_done, s_header_field, s_header_field_start, s_header_value, s_header_value_discard_lws, s_header_value_discard_ws, s_header_value_discard_ws_almost_done, s_header_value_lws, s_header_value_start, s_headers_almost_done, s_headers_done, s_message_done, s_req_first_http_major, s_req_first_http_minor, s_req_fragment, s_req_fragment_start, s_req_http_H, s_req_http_HT, s_req_http_HTT, s_req_http_HTTP, s_req_http_major, s_req_http_minor, s_req_http_start, s_req_line_almost_done, s_req_method, s_req_path, s_req_query_string, s_req_query_string_start, s_req_schema, s_req_schema_slash, s_req_schema_slash_slash, s_req_server, s_req_server_start, s_req_server_with_at, s_req_spaces_before_url, s_res_first_http_major, s_res_first_http_minor, s_res_first_status_code, s_res_H, s_res_HT, s_res_HTT, s_res_HTTP, s_res_http_major, s_res_http_minor, s_res_line_almost_done, s_res_or_resp_H, s_res_status, s_res_status_code, s_res_status_start, s_start_req, s_start_req_or_res, s_start_res, SET_ERRNO, http_parser::state, http_parser::status_code, STRICT_CHECK, STRICT_TOKEN, TOKEN, TRANSFER_ENCODING, http_parser::type, ULLONG_MAX, unhex, UNLIKELY, UPDATE_STATE, UPGRADE, and http_parser::upgrade.
Referenced by QHttpConnectionPrivate::parseRequest().
void http_parser_init | ( | http_parser * | parser, |
enum http_parser_type | t | ||
) |
Definition at line 2138 of file http_parser.c.
References http_parser::data, http_parser::http_errno, HTTP_REQUEST, HTTP_RESPONSE, s_start_req, s_start_req_or_res, s_start_res, http_parser::state, and http_parser::type.
Referenced by QHttpConnectionPrivate::QHttpConnectionPrivate().
int http_parser_parse_url | ( | const char * | buf, |
size_t | buflen, | ||
int | is_connect, | ||
struct http_parser_url * | u | ||
) |
Definition at line 2307 of file http_parser.c.
References http_parser_url::field_data, http_parser_url::field_set, http_parse_host(), http_parser_url::len, http_parser_url::off, parse_url_char(), http_parser_url::port, s_dead, s_req_fragment, s_req_fragment_start, s_req_path, s_req_query_string, s_req_query_string_start, s_req_schema, s_req_schema_slash, s_req_schema_slash_slash, s_req_server, s_req_server_start, s_req_server_with_at, s_req_spaces_before_url, UF_FRAGMENT, UF_HOST, UF_MAX, UF_PATH, UF_PORT, UF_QUERY, and UF_SCHEMA.
Referenced by QHttpConnectionPrivate::HeadersComplete().
void http_parser_pause | ( | http_parser * | parser, |
int | paused | ||
) |
Definition at line 2407 of file http_parser.c.
References HTTP_PARSER_ERRNO, and SET_ERRNO.
void http_parser_settings_init | ( | http_parser_settings * | settings | ) |
Definition at line 2149 of file http_parser.c.
unsigned long http_parser_version | ( | void | ) |
Definition at line 2426 of file http_parser.c.
References HTTP_PARSER_VERSION_MAJOR, HTTP_PARSER_VERSION_MINOR, and HTTP_PARSER_VERSION_PATCH.
int http_should_keep_alive | ( | const http_parser * | parser | ) |
Definition at line 2112 of file http_parser.c.
References F_CONNECTION_CLOSE, F_CONNECTION_KEEP_ALIVE, http_parser::flags, http_parser::http_major, http_message_needs_eof(), and http_parser::http_minor.
Definition at line 479 of file http_parser.c.
References IS_ALPHA, IS_URL_CHAR, IS_USERINFO_CHAR, s_dead, s_req_fragment, s_req_fragment_start, s_req_path, s_req_query_string, s_req_query_string_start, s_req_schema, s_req_schema_slash, s_req_schema_slash_slash, s_req_server, s_req_server_start, s_req_server_with_at, and s_req_spaces_before_url.
Referenced by http_parser_execute(), and http_parser_parse_url().
const char* description |
Definition at line 459 of file http_parser.c.
Referenced by MusicSourceUpdateWidget::downLoadFinished(), and TTKCommandLineParser::setDescription().
struct { ... } http_strerror_tab[] |
Referenced by http_errno_description(), and http_errno_name().
|
static |
Definition at line 174 of file http_parser.c.
Referenced by http_method_str(), and http_parser_execute().
const char* name |
Definition at line 458 of file http_parser.c.
Referenced by MusicLrcPhotoWidget::addButtonClicked(), MusicToolSetsWidget::addCelltItems(), MusicWebFMRadioWidget::addCelltItems(), MusicSongsContainerWidget::addNewRowItem(), MusicSongsListPlayedTableWidget::adjustPlayWidgetRow(), MusicSongsListPlayTableWidget::adjustPlayWidgetRow(), MusicSingleManager::appendObject(), MusicSongsContainerWidget::appendSongItemList(), MusicLrcFloatPhotoWidget::artistNameChanged(), MusicSongsContainerWidget::changRowItemName(), MusicSongsContainerWidget::checkTitleNameValid(), QDlnaClientPrivate::connect(), MusicBackgroundListWidget::contains(), MusicSongsListPlayTableWidget::contextMenuEvent(), MusicIdentifySongWidget::createDetectedSuccessedWidget(), MusicSpectrumWidget::createLightWidget(), MusicSpectrumWidget::createModuleWidget(), MusicSpectrumWidget::createSpectrumWidget(), MusicDeviceInfoModule::disksProperty(), MusicBPDownloadBackgroundRequest::downLoadFinished(), TTK::TTKQmmp::enabledEffectPlugin(), TTK::TTKQmmp::enabledVisualPlugin(), MusicBackgroundListWidget::find(), TTK::generateSongArtist(), TTK::generateSongList(), TTK::generateSongTitle(), TTKVariant< Types >::get(), QDlnaFileServer::handleRequest(), MusicDownloadResetWidget::initialize(), MusicSongSharingWidget::initialize(), MusicSongRingtoneMaker::initInputPath(), MusicWebFMRadioPlayWidget::lrcDownloadStateChanged(), MusicSong::MusicSong(), TTKXmlHelper::nodeName(), MusicSingleManager::object(), MusicExtractWrapper::outputBinary(), MusicExtractWrapper::outputData(), MusicExtractWrapper::outputSkin(), MusicExtractWrapper::outputThunderSkin(), QJson::QObjectHelper::qobject2qvariant(), MusicWebFMRadioPlayWidget::querySongInfoFinished(), MusicXSPFConfigManager::readBuffer(), MusicASXConfigManager::readBuffer(), QSyncListData::receiveDataFromServer(), MusicSongDlnaTransferWidget::scanFinished(), MusicSongsListPlayedTableWidget::selectRow(), MusicSongsListPlayTableWidget::selectRow(), MusicLrcAnalysis::setCurrentFilePath(), MusicBackgroundListWidget::setCurrentItemName(), MusicMoreFunctionsPopWidget::setCurrentSongName(), MusicLrcPosterItemWidget::setCurrentSongName(), MusicLrcContainer::setCurrentSongName(), MusicLrcLocalLinkWidget::setCurrentSongName(), MusicBackgroundListItem::setFileName(), MusicNetworkProxy::setHostName(), MusicVideoPlayWidget::shareButtonClicked(), MusicApplication::showCurrentSong(), TTK::TTKQmmp::showEffectSetting(), MusicSongsListPlayTableWidget::startToDrag(), MusicSongsListPlayWidget::updateCurrentArtist(), and QHttpResponsePrivate::writeHeaders().
|
static |
Definition at line 243 of file http_parser.c.
|
static |
Definition at line 189 of file http_parser.c.
|
static |
Definition at line 224 of file http_parser.c.
Referenced by http_parser_execute().