curl.inc
Original include source with line numbers.
| 1 | #if defined _curl_included |
| 2 | #endinput |
| 3 | #endif |
| 4 | #define _curl_included |
| 5 | |
| 6 | #include <curl_consts> |
| 7 | |
| 8 | #if AMXX_VERSION_NUM >= 175 |
| 9 | #pragma reqlib curl |
| 10 | #if !defined AMXMODX_NOAUTOLOAD |
| 11 | #pragma loadlib curl |
| 12 | #endif |
| 13 | #else |
| 14 | #pragma library curl |
| 15 | #endif |
| 16 | |
| 17 | enum _:curl_off_t { |
| 18 | curl_off_left, |
| 19 | curl_off_right |
| 20 | }; |
| 21 | |
| 22 | enum curl_slist |
| 23 | { |
| 24 | SList_Empty |
| 25 | }; |
| 26 | |
| 27 | /** |
| 28 | * This function converts the given input string to a URL encoded string. |
| 29 | * All input characters that are not a-z, A-Z, 0-9, '-', '.', '_' or '~' are converted to their "URL escaped" version |
| 30 | * (%NN where NN is a two-digit hexadecimal number). |
| 31 | * see also https://curl.haxx.se/libcurl/c/curl_easy_escape.html |
| 32 | * |
| 33 | * @param handle Curl handle |
| 34 | * @param url URL for encoding |
| 35 | * @param buffer Buffer to copy encoded url |
| 36 | * @param maxlen Maximum size of the buffer |
| 37 | * |
| 38 | * @noreturn |
| 39 | * @error If passed curl handle is not a valid |
| 40 | */ |
| 41 | native curl_easy_escape(const CURL:handle, const url[], buffer[], const maxlen); |
| 42 | |
| 43 | /** |
| 44 | * This function converts the given URL encoded input string to a "plain string". |
| 45 | * All input characters that are URL encoded (%XX where XX is a two-digit hexadecimal number) are converted to their binary versions. |
| 46 | * see also https://curl.haxx.se/libcurl/c/curl_easy_unescape.html |
| 47 | * |
| 48 | * @param handle Curl handle |
| 49 | * @param url URL for decoding |
| 50 | * @param buffer Buffer to copy decoded url |
| 51 | * @param maxlen Maximum size of the buffer |
| 52 | * |
| 53 | * @noreturn |
| 54 | * @error If passed curl handle is not a valid |
| 55 | */ |
| 56 | native curl_easy_unescape(const CURL: handle, const url[], buffer[], const maxlen); |
| 57 | |
| 58 | /** |
| 59 | * This function must be the first function to call, and it returns a CURL easy handle that you must |
| 60 | * use as input to other functions in the easy interface. This call MUST have a corresponding call to curl_easy_cleanup |
| 61 | * when the operation is complete. |
| 62 | * see also https://curl.haxx.se/libcurl/c/curl_easy_init.html |
| 63 | * |
| 64 | * @return Curl handle |
| 65 | */ |
| 66 | native CURL: curl_easy_init(); |
| 67 | |
| 68 | /** |
| 69 | * Invoke this function after curl_easy_init and all the curl_easy_setopt calls are made, and will perform the transfer as described in the options. |
| 70 | * It must be called with the same curl handle as input as the curl_easy_init call returned. |
| 71 | * You can do any amount of calls to curl_easy_perform while using the same curl handle. If you intend to transfer more than one file, you are even |
| 72 | * encouraged to do so. libcurl will then attempt to re-use the same connection for the following transfers, thus making the operations faster, |
| 73 | * less CPU intense and using less network resources. Just note that you will have to use curl_easy_setopt between the invokes to set options |
| 74 | * for the following curl_easy_perform. |
| 75 | * see also https://curl.haxx.se/libcurl/c/curl_easy_perform.html |
| 76 | * |
| 77 | * @param handle Curl handle |
| 78 | * @param callback The forward to call after request completed |
| 79 | * @param data Any data to pass to the callback forward |
| 80 | * @param len Maximum size of the data |
| 81 | * |
| 82 | * @noreturn |
| 83 | * @error If passed curl handle is not a valid or or undefined callback function |
| 84 | */ |
| 85 | native curl_easy_perform(const CURL: handle, const callback[], const data[] = {}, const len = 0); |
| 86 | |
| 87 | /** |
| 88 | * This function is used to tell libcurl how to behave. By setting the appropriate options, the application can change libcurl's behavior. |
| 89 | * All options are set with an option followed by a parameter. That parameter can be a long, a function pointer, an object pointer or a curl_off_t, |
| 90 | * depending on what the specific option expects. Read this manual carefully as bad input values may cause libcurl to behave badly! |
| 91 | * You can only set one option in each function call. A typical application uses many curl_easy_setopt calls in the setup phase. |
| 92 | * Options set with this function call are valid for all forthcoming transfers performed using this handle. The options are not in any way reset between |
| 93 | * transfers, so if you want subsequent transfers with different options, you must change them between the transfers. You can optionally reset all options |
| 94 | * back to internal default with curl_easy_reset. |
| 95 | * see also https://curl.haxx.se/libcurl/c/curl_easy_setopt.html |
| 96 | * |
| 97 | * @param handle Curl handle |
| 98 | * @param option Necessary option (see CURLoption enum) |
| 99 | * |
| 100 | * @return If the operation was successful, CURLE_OK is returned. Otherwise an appropriate error code will be returned. |
| 101 | * @error If passed curl handle is not a valid or or undefined option |
| 102 | */ |
| 103 | native CURLcode: curl_easy_setopt(const CURL: handle, const CURLoption: option, any: ...); |
| 104 | |
| 105 | /** |
| 106 | * This function must be the last function to call for an easy session. It is the opposite of the curl_easy_init function and must be called |
| 107 | * with the same handle as input that a curl_easy_init call returned. |
| 108 | * This might close all connections this handle has used and possibly has kept open until now - unless it was attached to a multi handle while |
| 109 | * doing the transfers. Don't call this function if you intend to transfer more files, re-using handles is a key to good performance with libcurl. |
| 110 | * see also https://curl.haxx.se/libcurl/c/curl_easy_cleanup.html |
| 111 | * |
| 112 | * @param handle Curl handle |
| 113 | * |
| 114 | * @noreturn |
| 115 | * @error If passed curl handle is not a valid |
| 116 | */ |
| 117 | native curl_easy_cleanup(const CURL: handle); |
| 118 | |
| 119 | /** |
| 120 | * Re-initializes all options previously set on a specified CURL handle to the default values. This puts back the handle to the same state as it |
| 121 | * was in when it was just created with curl_easy_init. |
| 122 | * It does not change the following information kept in the handle: live connections, the Session ID cache, the DNS cache, the cookies and shares. |
| 123 | * see also https://curl.haxx.se/libcurl/c/curl_easy_reset.html |
| 124 | * |
| 125 | * @param handle Curl handle |
| 126 | * |
| 127 | * @noreturn |
| 128 | * @error If passed curl handle is not a valid |
| 129 | */ |
| 130 | native curl_easy_reset(const CURL: handle); |
| 131 | |
| 132 | /** |
| 133 | * Request internal information from the curl session with this function. The third argument MUST be a buffer for value (num, string, float) |
| 134 | * The data pointed-to will be filled in accordingly and can be relied upon only if the function returns CURLE_OK. Use this function AFTER |
| 135 | * a performed transfer if you want to get transfer related data. |
| 136 | * see also https://curl.haxx.se/libcurl/c/curl_easy_getinfo.html |
| 137 | * |
| 138 | * @param handle Curl handle |
| 139 | * @param info Necessary info (see CURLINFO enum) |
| 140 | * |
| 141 | * @return If the operation was successful, CURLE_OK is returned. Otherwise an appropriate error code will be returned. |
| 142 | * @error If passed curl handle is not a valid or or undefined info |
| 143 | */ |
| 144 | native CURLcode: curl_easy_getinfo(const CURL: handle, const CURLINFO: info, any: ...); |
| 145 | |
| 146 | /** |
| 147 | * The function receives a text description of the specified error code. |
| 148 | * |
| 149 | * @param code Error code (see CURLcode enum) |
| 150 | * @param buffer Buffer to copy error description |
| 151 | * @param maxlen Maximum size of the buffer |
| 152 | * |
| 153 | * @noreturn |
| 154 | */ |
| 155 | native curl_easy_strerror(const CURLcode: code, buffer[], const maxlen); |
| 156 | |
| 157 | /** |
| 158 | * @deprecated This function does not catch all cases. |
| 159 | */ |
| 160 | #pragma deprecated This function is deprecated. Do not use! |
| 161 | native CURLFORMcode: curl_formadd(&curl_httppost: first, &curl_httppost: last, any: ...); |
| 162 | |
| 163 | /** |
| 164 | * @deprecated This function does not catch all cases. |
| 165 | */ |
| 166 | #pragma deprecated This function is deprecated. Do not use! |
| 167 | native curl_formfree(&curl_httppost: first); |
| 168 | |
| 169 | /** |
| 170 | * This function appends a string to a linked list of strings. |
| 171 | * The existing list should be passed as the first argument and the new list is returned from this function. |
| 172 | * Pass in SList_Empty (0) in the list argument to create a new list. The specified string has been appended when this function returns. |
| 173 | * see also https://curl.haxx.se/libcurl/c/curl_slist_append.html |
| 174 | * |
| 175 | * @param list Existing list |
| 176 | * @param string Some string |
| 177 | * |
| 178 | * @return A null pointer is returned if anything went wrong, otherwise the new list pointer is returned. |
| 179 | * To avoid overwriting an existing non-empty list on failure, the new list should be returned to a |
| 180 | * temporary variable which can be tested for SList_Empty (0) before updating the original list pointer |
| 181 | */ |
| 182 | native curl_slist: curl_slist_append(curl_slist: list, string[]); |
| 183 | |
| 184 | /** |
| 185 | * This function removes all traces of a previously built curl_slist linked list. |
| 186 | * see also https://curl.haxx.se/libcurl/c/curl_slist_free_all.html |
| 187 | * |
| 188 | * @param list Existing list |
| 189 | * |
| 190 | * @noreturn |
| 191 | */ |
| 192 | native curl_slist_free_all(curl_slist: list); |
| 193 | |
| 194 | /** |
| 195 | * Returns a human readable string with the version number of libcurl and some of its important components (like OpenSSL version). |
| 196 | * see also https://curl.haxx.se/libcurl/c/curl_version.html |
| 197 | * |
| 198 | * @param buffer Buffer to copy string with the version number |
| 199 | * @param maxlen Maximum size of the buffer |
| 200 | * |
| 201 | * @noreturn |
| 202 | */ |
| 203 | native curl_version(buffer[], const maxlen); |
| 204 | |