1 // Copyright (c) 2022 Marshall A. Greenblatt. All rights reserved. 2 // 3 // Redistribution and use in source and binary forms, with or without 4 // modification, are permitted provided that the following conditions are 5 // met: 6 // 7 // * Redistributions of source code must retain the above copyright 8 // notice, this list of conditions and the following disclaimer. 9 // * Redistributions in binary form must reproduce the above 10 // copyright notice, this list of conditions and the following disclaimer 11 // in the documentation and/or other materials provided with the 12 // distribution. 13 // * Neither the name of Google Inc. nor the name Chromium Embedded 14 // Framework nor the names of its contributors may be used to endorse 15 // or promote products derived from this software without specific prior 16 // written permission. 17 // 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 // 30 // --------------------------------------------------------------------------- 31 // 32 // This file was generated by the CEF translator tool and should not edited 33 // by hand. See the translator.README.txt file in the tools directory for 34 // more information. 35 // 36 // $hash=f5e1c0fc43c6e85dbafa66975d9dc5e2bc7be69f$ 37 // 38 39 #ifndef CEF_INCLUDE_CAPI_CEF_PARSER_CAPI_H_ 40 #define CEF_INCLUDE_CAPI_CEF_PARSER_CAPI_H_ 41 #pragma once 42 43 #include "include/capi/cef_base_capi.h" 44 45 #ifdef __cplusplus 46 extern "C" { 47 #endif 48 49 /// 50 // Parse the specified |url| into its component parts. Returns false (0) if the 51 // URL is NULL or invalid. 52 /// 53 CEF_EXPORT int cef_parse_url(const cef_string_t* url, 54 struct _cef_urlparts_t* parts); 55 56 /// 57 // Creates a URL from the specified |parts|, which must contain a non-NULL spec 58 // or a non-NULL host and path (at a minimum), but not both. Returns false (0) 59 // if |parts| isn't initialized as described. 60 /// 61 CEF_EXPORT int cef_create_url(const struct _cef_urlparts_t* parts, 62 cef_string_t* url); 63 64 /// 65 // This is a convenience function for formatting a URL in a concise and human- 66 // friendly way to help users make security-related decisions (or in other 67 // circumstances when people need to distinguish sites, origins, or otherwise- 68 // simplified URLs from each other). Internationalized domain names (IDN) may be 69 // presented in Unicode if the conversion is considered safe. The returned value 70 // will (a) omit the path for standard schemes, excepting file and filesystem, 71 // and (b) omit the port if it is the default for the scheme. Do not use this 72 // for URLs which will be parsed or sent to other applications. 73 /// 74 // The resulting string must be freed by calling cef_string_userfree_free(). 75 CEF_EXPORT cef_string_userfree_t 76 cef_format_url_for_security_display(const cef_string_t* origin_url); 77 78 /// 79 // Returns the mime type for the specified file extension or an NULL string if 80 // unknown. 81 /// 82 // The resulting string must be freed by calling cef_string_userfree_free(). 83 CEF_EXPORT cef_string_userfree_t 84 cef_get_mime_type(const cef_string_t* extension); 85 86 /// 87 // Get the extensions associated with the given mime type. This should be passed 88 // in lower case. There could be multiple extensions for a given mime type, like 89 // "html,htm" for "text/html", or "txt,text,html,..." for "text/*". Any existing 90 // elements in the provided vector will not be erased. 91 /// 92 CEF_EXPORT void cef_get_extensions_for_mime_type(const cef_string_t* mime_type, 93 cef_string_list_t extensions); 94 95 /// 96 // Encodes |data| as a base64 string. 97 /// 98 // The resulting string must be freed by calling cef_string_userfree_free(). 99 CEF_EXPORT cef_string_userfree_t cef_base64encode(const void* data, 100 size_t data_size); 101 102 /// 103 // Decodes the base64 encoded string |data|. The returned value will be NULL if 104 // the decoding fails. 105 /// 106 CEF_EXPORT struct _cef_binary_value_t* cef_base64decode( 107 const cef_string_t* data); 108 109 /// 110 // Escapes characters in |text| which are unsuitable for use as a query 111 // parameter value. Everything except alphanumerics and -_.!~*'() will be 112 // converted to "%XX". If |use_plus| is true (1) spaces will change to "+". The 113 // result is basically the same as encodeURIComponent in Javacript. 114 /// 115 // The resulting string must be freed by calling cef_string_userfree_free(). 116 CEF_EXPORT cef_string_userfree_t cef_uriencode(const cef_string_t* text, 117 int use_plus); 118 119 /// 120 // Unescapes |text| and returns the result. Unescaping consists of looking for 121 // the exact pattern "%XX" where each X is a hex digit and converting to the 122 // character with the numerical value of those digits (e.g. "i%20=%203%3b" 123 // unescapes to "i = 3;"). If |convert_to_utf8| is true (1) this function will 124 // attempt to interpret the initial decoded result as UTF-8. If the result is 125 // convertable into UTF-8 it will be returned as converted. Otherwise the 126 // initial decoded result will be returned. The |unescape_rule| parameter 127 // supports further customization the decoding process. 128 /// 129 // The resulting string must be freed by calling cef_string_userfree_free(). 130 CEF_EXPORT cef_string_userfree_t 131 cef_uridecode(const cef_string_t* text, 132 int convert_to_utf8, 133 cef_uri_unescape_rule_t unescape_rule); 134 135 /// 136 // Parses the specified |json_string| and returns a dictionary or list 137 // representation. If JSON parsing fails this function returns NULL. 138 /// 139 CEF_EXPORT struct _cef_value_t* cef_parse_json( 140 const cef_string_t* json_string, 141 cef_json_parser_options_t options); 142 143 /// 144 // Parses the specified UTF8-encoded |json| buffer of size |json_size| and 145 // returns a dictionary or list representation. If JSON parsing fails this 146 // function returns NULL. 147 /// 148 CEF_EXPORT struct _cef_value_t* cef_parse_json_buffer( 149 const void* json, 150 size_t json_size, 151 cef_json_parser_options_t options); 152 153 /// 154 // Parses the specified |json_string| and returns a dictionary or list 155 // representation. If JSON parsing fails this function returns NULL and 156 // populates |error_msg_out| with a formatted error message. 157 /// 158 CEF_EXPORT struct _cef_value_t* cef_parse_jsonand_return_error( 159 const cef_string_t* json_string, 160 cef_json_parser_options_t options, 161 cef_string_t* error_msg_out); 162 163 /// 164 // Generates a JSON string from the specified root |node| which should be a 165 // dictionary or list value. Returns an NULL string on failure. This function 166 // requires exclusive access to |node| including any underlying data. 167 /// 168 // The resulting string must be freed by calling cef_string_userfree_free(). 169 CEF_EXPORT cef_string_userfree_t 170 cef_write_json(struct _cef_value_t* node, cef_json_writer_options_t options); 171 172 #ifdef __cplusplus 173 } 174 #endif 175 176 #endif // CEF_INCLUDE_CAPI_CEF_PARSER_CAPI_H_ 177