mirror of
https://github.com/lexborisov/Modest
synced 2024-11-21 21:31:25 +03:00
Little changes for api
This commit is contained in:
parent
a7fef72710
commit
32876b578f
@ -2081,6 +2081,23 @@ myhtml_encoding_name_by_id(myhtml_encoding_t encoding, size_t *length);
|
||||
myhtml_encoding_t
|
||||
myhtml_encoding_prescan_stream_to_determine_encoding(const char *data, size_t data_size);
|
||||
|
||||
/**
|
||||
* Extracting character encoding from string. Find "charset=" and see encoding.
|
||||
* For example: "text/html; charset=windows-1251". Return MyHTML_ENCODING_WINDOWS_1251
|
||||
*
|
||||
*
|
||||
* See https://html.spec.whatwg.org/multipage/infrastructure.html#algorithm-for-extracting-a-character-encoding-from-a-meta-element
|
||||
*
|
||||
* @param[in] data
|
||||
* @param[in] data length
|
||||
* @param[out] return encoding
|
||||
*
|
||||
* @return true if encoding found
|
||||
*/
|
||||
bool
|
||||
myhtml_encoding_extracting_character_encoding_from_charset(const char *data, size_t data_size,
|
||||
myhtml_encoding_t *encoding);
|
||||
|
||||
/***********************************************************************************
|
||||
*
|
||||
* MyHTML_STRING
|
||||
|
@ -154,6 +154,7 @@ const myhtml_encoding_detect_name_entry_t * myhtml_encoding_name_entry_by_name(c
|
||||
bool myhtml_encoding_by_name(const char *name, size_t length, myhtml_encoding_t *encoding);
|
||||
const char * myhtml_encoding_name_by_id(myhtml_encoding_t encoding, size_t *length);
|
||||
|
||||
bool myhtml_encoding_extracting_character_encoding_from_charset(const char *data, size_t data_size, myhtml_encoding_t *encoding);
|
||||
myhtml_encoding_t myhtml_encoding_prescan_stream_to_determine_encoding(const char *data, size_t data_size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -2081,6 +2081,23 @@ myhtml_encoding_name_by_id(myhtml_encoding_t encoding, size_t *length);
|
||||
myhtml_encoding_t
|
||||
myhtml_encoding_prescan_stream_to_determine_encoding(const char *data, size_t data_size);
|
||||
|
||||
/**
|
||||
* Extracting character encoding from string. Find "charset=" and see encoding.
|
||||
* For example: "text/html; charset=windows-1251". Return MyHTML_ENCODING_WINDOWS_1251
|
||||
*
|
||||
*
|
||||
* See https://html.spec.whatwg.org/multipage/infrastructure.html#algorithm-for-extracting-a-character-encoding-from-a-meta-element
|
||||
*
|
||||
* @param[in] data
|
||||
* @param[in] data length
|
||||
* @param[out] return encoding
|
||||
*
|
||||
* @return true if encoding found
|
||||
*/
|
||||
bool
|
||||
myhtml_encoding_extracting_character_encoding_from_charset(const char *data, size_t data_size,
|
||||
myhtml_encoding_t *encoding);
|
||||
|
||||
/***********************************************************************************
|
||||
*
|
||||
* MyHTML_STRING
|
||||
|
@ -154,6 +154,7 @@ const myhtml_encoding_detect_name_entry_t * myhtml_encoding_name_entry_by_name(c
|
||||
bool myhtml_encoding_by_name(const char *name, size_t length, myhtml_encoding_t *encoding);
|
||||
const char * myhtml_encoding_name_by_id(myhtml_encoding_t encoding, size_t *length);
|
||||
|
||||
bool myhtml_encoding_extracting_character_encoding_from_charset(const char *data, size_t data_size, myhtml_encoding_t *encoding);
|
||||
myhtml_encoding_t myhtml_encoding_prescan_stream_to_determine_encoding(const char *data, size_t data_size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -406,8 +406,7 @@ const char * myhtml_encoding_name_by_id(myhtml_encoding_t encoding, size_t *leng
|
||||
the user agent either runs out of bytes (meaning the position pointer created in the first step below goes beyond the end of the byte stream obtained so far)
|
||||
or reaches its end condition, then abort the prescan a byte stream to determine its encoding algorithm unsuccessfully.
|
||||
*/
|
||||
|
||||
bool myhtml_encoding_algorithm_extracting_character_encoding_from_meta_element(const char *data, size_t data_size, myhtml_encoding_t *encoding)
|
||||
bool myhtml_encoding_extracting_character_encoding_from_charset(const char *data, size_t data_size, myhtml_encoding_t *encoding)
|
||||
{
|
||||
*encoding = MyHTML_ENCODING_NOT_DETERMINED;
|
||||
|
||||
@ -754,7 +753,7 @@ bool myhtml_encoding_prescan_stream_to_determine_encoding_check_meta(const unsig
|
||||
if((is_exists & 2) == 0) {
|
||||
is_exists |= 2;
|
||||
|
||||
if(myhtml_encoding_algorithm_extracting_character_encoding_from_meta_element((const char*)(&udata[ attr.value_begin ]), attr.value_length, encoding)) {
|
||||
if(myhtml_encoding_extracting_character_encoding_from_charset((const char*)(&udata[ attr.value_begin ]), attr.value_length, encoding)) {
|
||||
need_pragma = 2;
|
||||
}
|
||||
}
|
||||
|
60
source/myhtml/url.h
Normal file
60
source/myhtml/url.h
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
Copyright (C) 2016 Alexander Borisov
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Author: lex.borisov@gmail.com (Alexander Borisov)
|
||||
*/
|
||||
|
||||
#ifndef MyHTML_URL_H
|
||||
#define MyHTML_URL_H
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
//extern "C" {
|
||||
#endif
|
||||
|
||||
#include "myhtml/myosi.h"
|
||||
#include "myhtml/mystring.h"
|
||||
#include "myhtml/url/scheme.h"
|
||||
|
||||
typedef struct myhtml_url myhtml_url_t;
|
||||
|
||||
struct myhtml_url {
|
||||
const myhtml_url_scheme_entry_t* scheme;
|
||||
|
||||
char* href;
|
||||
char* origin;
|
||||
char* protocol;
|
||||
char* username;
|
||||
char* password;
|
||||
char* host;
|
||||
char* hostname;
|
||||
char* port;
|
||||
char* pathname;
|
||||
char* search;
|
||||
char* hash;
|
||||
|
||||
mchar_async_t* mchar;
|
||||
size_t node_idx;
|
||||
};
|
||||
|
||||
myhtml_status_t myhtml_url_parse(myhtml_url_t* url, mchar_async_t* mchar, size_t node_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* MyHTML_URL_H */
|
@ -47,7 +47,7 @@ myhtml_status_t myhtml_utils_mhash_init(myhtml_utils_mhash_t* mhash, size_t tabl
|
||||
{
|
||||
mhash->mchar_obj = mchar_async_create(128, 4096);
|
||||
if(mhash->mchar_obj == NULL)
|
||||
return MyHTML_STATUS_ATTR_ERROR_ALLOCATION;
|
||||
return MyHTML_STATUS_ERROR_MEMORY_ALLOCATION;
|
||||
|
||||
mhash->mchar_node = mchar_async_node_add(mhash->mchar_obj);
|
||||
|
||||
@ -56,7 +56,7 @@ myhtml_status_t myhtml_utils_mhash_init(myhtml_utils_mhash_t* mhash, size_t tabl
|
||||
|
||||
mhash->table = myhtml_calloc(table_size, sizeof(myhtml_utils_mhash_entry_t*));
|
||||
if(mhash->table == NULL)
|
||||
return MyHTML_STATUS_ATTR_ERROR_ALLOCATION;
|
||||
return MyHTML_STATUS_ERROR_MEMORY_ALLOCATION;
|
||||
|
||||
if(max_depth < 1)
|
||||
max_depth = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user