Guest User

cURL.ini

a guest
Jun 20th, 2020
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.36 KB | None | 0 0
  1.  
  2. #if defined _cURL_included
  3. #endinput
  4. #endif
  5. #define _cURL_included
  6.  
  7. #include <cURL_header>
  8.  
  9.  
  10. /*
  11. ========================================
  12. The Following CURLOPT_* NOT support:
  13. ERRORBUFFER // use curl_get_error_buffer
  14. WRITEINFO // ???
  15. PROGRESSFUNCTION // unused
  16. PROGRESSDATA // same
  17. HEADERFUNCTION // unused
  18. DEBUGFUNCTION // unused
  19. DEBUGDATA // same
  20. SHARE // unsupport
  21. PRIVATE // unsupport
  22. SSL_CTX_FUNC // unused
  23. SSL_CTX_DATA // same
  24. IOCTLFUNCTION // unused
  25. IOCTLDATA // same
  26. CONV_FROM_NETWORK_FUNC // unused
  27. CONV_TO_NETWORK_FUNC // unused
  28. CONV_FROM_UTF8_FUNC // unused
  29. SOCKOPTFUNCTION // unused
  30. SOCKOPTDATA // unused
  31. OPENSOCKETFUNCTION // used
  32. OPENSOCKETDATA // used
  33. COPYPOSTFIELDS // unsupport
  34. SEEKFUNCTION // unused
  35. SEEKDATA // unused
  36. SOCKS5_GSSAPI_SERVICE // unsupport
  37. SOCKS5_GSSAPI_NEC // unsupport
  38. SSH_KEYFUNCTION // unsupport
  39. SSH_KEYDATA // unsupport
  40. INTERLEAVEFUNCTION // unsupport
  41. CHUNK_BGN_FUNC // unsupport
  42. CHUNK_END_FUNC // unsupport
  43. FNMATCH_FUNC // unsupport
  44. CHUNK_DATA // unsupport
  45. FNMATCH_DATA // unsupport
  46. TLSAUTH_USERNAME // unsupport, require tls-srp
  47. TLSAUTH_PASSWORD // unsupport, require tls-srp
  48. TLSAUTH_TYPE // unsupport, require tls-srp
  49. CLOSESOCKETFUNCTION // unsupport
  50. CLOSESOCKETDATA // unsupport
  51. ========================================*/
  52.  
  53. /*
  54. ========================================
  55. The Following CURLOPT_* supports the "file://" notation.
  56. COOKIEFILE
  57. COOKIEJAR
  58. RANDOM_FILE
  59. EGDSOCKET
  60. SSLKEY
  61. CAPATH
  62. NETRC_FILE
  63. SSH_PUBLIC_KEYFILE
  64. SSH_PRIVATE_KEYFILE
  65. _CRLFILE
  66. ISSUERCERT
  67. SSH_KNOWNHOSTS
  68.  
  69. ========================================*/
  70.  
  71. /*
  72. ========================================
  73. The Following CURLINFO_* NOT support:
  74. CURLINFO_SLIST
  75.  
  76. ========================================*/
  77.  
  78. /*
  79. ========================================
  80. The Following CURLFORM_* NOT support:
  81. CURLFORM_PTRNAME
  82. CURLFORM_PTRCONTENTS
  83. CURLFORM_ARRAY
  84. CURLFORM_BUFFER
  85. CURLFORM_BUFFERPTR
  86. CURLFORM_BUFFERLENGTH
  87. CURLFORM_STREAM
  88.  
  89. ========================================*/
  90.  
  91.  
  92.  
  93.  
  94. /*************************************************************************************************/
  95. /******************************************** OPTIONS ********************************************/
  96. /*************************************************************************************************/
  97.  
  98.  
  99. /**
  100. * The Send & Receive Action
  101. * Using on CURL_OnSend, CURL_OnReceive
  102. * SendRecv_Act_GOTO_SEND = go to send
  103. * SendRecv_Act_GOTO_RECV = go to receive
  104. * SendRecv_Act_GOTO_WAIT = go to wait
  105. * SendRecv_Act_GOTO_END = end the connection
  106. * SendRecv_Act_GOTO_SEND_NO_WAIT = go to send but no select
  107. * SendRecv_Act_GOTO_RECV_NO_WAIT = go to receive but no select
  108. * To see how it work? see curl_echo_test.sp & curl_rcon_test.sp examples
  109. */
  110. enum SendRecv_Act {
  111. SendRecv_Act_NOTHING = 0,
  112.  
  113. SendRecv_Act_GOTO_SEND,
  114. SendRecv_Act_GOTO_RECV,
  115. SendRecv_Act_GOTO_WAIT,
  116. SendRecv_Act_GOTO_END,
  117. SendRecv_Act_GOTO_SEND_NO_WAIT,
  118. SendRecv_Act_GOTO_RECV_NO_WAIT,
  119.  
  120. SendRecv_Act_LAST,
  121. };
  122.  
  123. /**
  124. * Hash type for curl_hash_file, curl_hash_string
  125. */
  126. enum Openssl_Hash {
  127. Openssl_Hash_MD5 = 0,
  128. Openssl_Hash_MD4,
  129. Openssl_Hash_MD2,
  130. Openssl_Hash_SHA,
  131. Openssl_Hash_SHA1,
  132. Openssl_Hash_SHA224,
  133. Openssl_Hash_SHA256,
  134. Openssl_Hash_SHA384,
  135. Openssl_Hash_SHA512,
  136. Openssl_Hash_RIPEMD160,
  137. };
  138.  
  139.  
  140. /*************************************************************************************************/
  141. /******************************************* CALLBACKS *******************************************/
  142. /*************************************************************************************************/
  143.  
  144.  
  145. /**
  146. * called if curl_easy_perform_thread() or curl_easy_send_recv() Complete
  147. * @ param Handle hndl The curl handle
  148. * @ param CURLcode code The CURLcode code, see cURL_header.inc
  149. * @ param any data Data passed to curl_easy_perform_thread()
  150. * @ noreturn
  151. */
  152. typeset CURL_OnComplete
  153. {
  154. function void (Handle hndl, CURLcode code);
  155. function void (Handle hndl, CURLcode code , any data);
  156. };
  157.  
  158. /**
  159. * called if curl_easy_send_recv() before sending data
  160. * @ param Handle hndl The curl handle
  161. * @ param CURLcode code The last CURLcode code, see cURL_header.inc
  162. * @ param cell_t last_sent_dataSize The last sent datasize
  163. * @ param any data Data passed to curl_easy_send_recv()
  164. * @ return SendRecv_Act
  165. */
  166. typeset CURL_OnSend
  167. {
  168. function SendRecv_Act (Handle hndl, CURLcode code, const last_sent_dataSize);
  169. function SendRecv_Act (Handle hndl, CURLcode code, const last_sent_dataSize, any data);
  170. }
  171.  
  172. /**
  173. * called if curl_easy_send_recv() after received data
  174. * @ param Handle hndl The curl handle
  175. * @ param CURLcode code The CURLcode code, see cURL_header.inc
  176. * @ param String dataSize The received datasize
  177. * @ param any data Data passed to curl_easy_send_recv()
  178. * @ return SendRecv_Act
  179. */
  180. typeset CURL_OnReceive
  181. {
  182. function SendRecv_Act (Handle hndl, CURLcode code, const char receiveData[], const dataSize);
  183. function SendRecv_Act (Handle hndl, CURLcode code, const char receiveData[], const dataSize, any data);
  184. }
  185.  
  186. /**
  187. * called if Openssl_Hash_file() after hashed the file
  188. * @ param bool success True on success, false if hash file fail
  189. * @ param String buffer The hash string
  190. * @ param any data Data passed to Openssl_Hash_file()
  191. * @ noreturn
  192. */
  193. typeset Openssl_Hash_Complete
  194. {
  195. function void (const bool success, const char buffer[]);
  196. function void (const bool success, const char buffer[], any data);
  197. }
  198.  
  199.  
  200. typeset CURL_Function_CB
  201. {
  202. // CURLOPT_WRITEFUNCTION
  203. function void (Handle hndl, const char buffer[], const bytes, const nmemb);
  204. function void (Handle hndl, const char buffer[], const bytes, const nmemb, any data);
  205.  
  206. // CURLOPT_READFUNCTION
  207. function void (Handle hndl, const bytes, const nmemb);
  208. function void (Handle hndl, const bytes, const nmemb, any data);
  209. }
  210.  
  211. /*************************************************************************************************/
  212. /******************************************** NATIVES ********************************************/
  213. /*************************************************************************************************/
  214.  
  215.  
  216. /**
  217. * Create a curl handle
  218. * @ return Handle The curl handle. Returns INVALID_HANDLE on failure
  219. */
  220. native Handle:curl_easy_init();
  221.  
  222. /**
  223. * Set a curl option for CURLOPTTYPE_OBJECTPOINT type
  224. *
  225. * @ param Handle hndl The handle of the curl to be used. May be INVALID_HANDLE if not essential.
  226. * @ param CURLoption opt The option to add (see enum CURLoption for details).
  227. * @ param String buffer The value to set the option to.
  228. * @ return bool 1 on success. 0 = The option not accept string or unsupport.
  229. */
  230. native bool:curl_easy_setopt_string(Handle:hndl, CURLoption:opt, const char[] buffer);
  231.  
  232. /**
  233. * Set a curl option for CURLOPTTYPE_LONG type
  234. *
  235. * @ param Handle hndl The handle of the curl to be used. May be INVALID_HANDLE if not essential.
  236. * @ param CURLoption opt The option to add (see enum CURLoption for details).
  237. * @ param cell_t value The value to set the option to.
  238. * @ return bool 1 on success. 0 = The option not accept integer or unsupport.
  239. */
  240. native bool:curl_easy_setopt_int(Handle:hndl, CURLoption:opt, value);
  241.  
  242. /**
  243. * Set a curl option for CURLOPTTYPE_LONG type
  244. * @ example"
  245. new opt[][2] = {
  246. {_:CURLOPT_NOPROGRESS,1},
  247. {_:CURLOPT_VERBOSE,0}
  248. };
  249. *
  250. * @ param Handle hndl The handle of the curl to be used. May be INVALID_HANDLE if not essential.
  251. * @ param cell_t array The option array to add (see enum CURLoption for details).
  252. * @ param cell_t array_size The array size.
  253. * @ return bool 1 on success. 0 = The option not accept integer or unsupport.
  254. */
  255. native bool:curl_easy_setopt_int_array(Handle:hndl, array[][2], array_size);
  256.  
  257. /**
  258. * Set a curl option for CURLOPTTYPE_OFF_T type
  259. *
  260. * @ param Handle hndl The handle of the curl to be used. May be INVALID_HANDLE if not essential.
  261. * @ param CURLoption opt The option to add (see enum CURLoption for details).
  262. * @ param String buffer The value to set the option to.
  263. * @ return bool 1 on success. 0 = The option not accept string or unsupport.
  264. */
  265. native bool:curl_easy_setopt_int64(Handle:hndl, CURLoption:opt, const String:buffer[]);
  266.  
  267. /**
  268. * Set a curl option for CURLOPTTYPE_OBJECTPOINT type
  269. * @ note only accept the following handle type
  270. curl_OpenFile()
  271. curl_httppost()
  272. curl_slist()
  273. *
  274. * @ param Handle hndl The handle of the curl to be used. May be INVALID_HANDLE if not essential.
  275. * @ param CURLoption opt The option to add (see enum CURLoption for details).
  276. * @ param Handle other_hndl The other handle to set the option to.
  277. * @ return bool 1 on success. 0 = The option not accept string or unsupport.
  278. */
  279. native bool:curl_easy_setopt_handle(Handle:hndl, CURLoption:opt, Handle:other_hndl);
  280.  
  281. /**
  282. * Set a curl option for CURLOPTTYPE_FUNCTIONPOINT type
  283. *
  284. * @ param Handle hndl The handle of the curl to be used. May be INVALID_HANDLE if not essential.
  285. * @ param CURLoption opt The option to add (see enum CURLoption for details).
  286. * @ param CURL_Function_CB callback The value to set the option to.
  287. * @ param cell_t value Value to set.
  288. * @ return bool 1 on success. 0 = The option unsupport or invalid callback function.
  289. */
  290. native bool:curl_easy_setopt_function(Handle:hndl, CURLoption:opt, CURL_Function_CB:callback, any:value=0);
  291.  
  292. /**
  293. * Load all CURLoption to curl Handle
  294. * @ note
  295. * Using curl_easy_perform_thread() will load option in thread
  296. * Use this on curl_easy_perform or check all CURLoption are valid or not
  297. * Only can use one time for each curl handle
  298. * @ return The CURLcode code, see cURL_header.inc
  299. */
  300. native CURLcode:curl_load_opt(Handle:hndl);
  301.  
  302. /**
  303. * Perform a file transfer
  304. * @ return The CURLcode code, see cURL_header.inc
  305. */
  306. native CURLcode:curl_easy_perform(Handle:hndl);
  307.  
  308. /**
  309. * Perform a file transfer, using thread
  310. * @ param Handle hndl The handle of the curl to be used. May be INVALID_HANDLE if not essential.
  311. * @ param CURL_OnComplete perform_callback The complete callback.
  312. * @ param cell_t value Value to set.
  313. * @ noreturn
  314. */
  315. native curl_easy_perform_thread(Handle:hndl, CURL_OnComplete:perform_callback, any:value=0);
  316.  
  317. /**
  318. * Create a send & receive function for a connected curl handle
  319. * @ param Handle hndl The handle of the curl to be used.
  320. * @ param CURL_OnSend send_callback The send callback.
  321. * @ param CURL_OnReceive receive_callback The receive callback.
  322. * @ param CURL_OnComplete complete_callback The complete callback.
  323. * @ param SendRecv_Act act The first SendRecv_Act action
  324. * @ param cell_t send_timeout Send timeout value in milliseconds.
  325. * @ param cell_t recv_timeout Receive timeout value in milliseconds.
  326. * @ param cenn_t recv_buffer_Size Receive buffer size.
  327. * @ param cell_t value Value to set.
  328. * @ noreturn
  329. */
  330. native curl_easy_send_recv(Handle:hndl, CURL_OnSend:send_callback, CURL_OnReceive:receive_callback, CURL_OnComplete:complete_callback, SendRecv_Act:act, send_timeout, recv_timeout, recv_buffer_Size = 1024, any:value=0);
  331.  
  332. /**
  333. * Send a signal to a send & receive curl handle
  334. * @ param Handle hndl The handle of the send & receive curl to be used.
  335. * @ param SendRecv_Act act The SendRecv_Act action after the singal
  336. * @ return bool 1 on success. 0 = not a curl_easy_send_recv() curl, or not running/waiting
  337. */
  338. native bool:curl_send_recv_Signal(Handle:hndl, SendRecv_Act:act);
  339.  
  340. /**
  341. * Check send & receive curl handle is Waiting or not
  342. * @ param Handle hndl The handle of the send & receive curl to be used.
  343. * @ return bool 1 = is waiting. 0 = not a curl_easy_send_recv() curl, or not running/waiting
  344. */
  345. native bool:curl_send_recv_IsWaiting(Handle:hndl);
  346.  
  347. /**
  348. * Send the send buffer for send & receive curl handle
  349. * @ param Handle hndl The handle of the send & receive curl to be used.
  350. * @ param cell_t data The data to send
  351. * @ param cell_t size if specified the \0 terminator will not be included
  352. * @ noreturn
  353. */
  354. native curl_set_send_buffer(Handle:hndl, const String:data[], size=-1);
  355.  
  356. /**
  357. * Send the receive data size for send & receive curl handle
  358. * @ param Handle hndl The handle of the send & receive curl to be used.
  359. * @ param cell_t size The receive size
  360. * @ noreturn
  361. */
  362. native curl_set_receive_size(Handle:hndl, size);
  363.  
  364. /**
  365. * Set send timeout for curl_easy_send_recv()
  366. * @ param Handle hndl The handle of the send & receive curl to be used.
  367. * @ param cell_t timeout How long will try to send data before it timeout (milliseconds).
  368. * @ noreturn
  369. */
  370. native curl_set_send_timeout(Handle:hndl, timeout);
  371.  
  372. /**
  373. * Set receive timeout for curl_easy_send_recv()
  374. * @ param Handle hndl The handle of the send & receive curl to be used.
  375. * @ param cell_t timeout How long will try to receive data before it timeout (milliseconds).
  376. * @ noreturn
  377. */
  378. native curl_set_recv_timeout(Handle:hndl, timeout);
  379.  
  380. /**
  381. * Get CURLOPT_ERRORBUFFER error string in curl handle
  382. * @ param Handle hndl The handle of the curl to be used.
  383. * @ param String buffer Destination string buffer to copy to.
  384. * @ param cell_t maxlen Destination buffer length (includes null terminator).
  385. * @ noreturn
  386. */
  387. native curl_get_error_buffer(Handle:hndl, String:buffer[], maxlen);
  388.  
  389. /**
  390. * Extract information from a curl handle. (CURLINFO_STRING only)
  391. * @ param Handle hndl The handle of the curl to be used.
  392. * @ param CURLINFO info The enum CURLINFO, see cURL_header.inc
  393. * @ param String buffer Destination string buffer to copy to.
  394. * @ param cell_t maxlen Destination buffer length (includes null terminator).
  395. * @ return The CURLcode code, see cURL_header.inc
  396. */
  397. native CURLcode:curl_easy_getinfo_string(Handle:hndl, CURLINFO:info, String:buffer[], maxlen);
  398.  
  399. /**
  400. * Extract information from a curl handle. (CURLINFO_LONG, CURLINFO_DOUBLE only)
  401. * @ param Handle hndl The handle of the curl to be used.
  402. * @ param CURLINFO info The enum CURLINFO, see cURL_header.inc
  403. * @ param value Variable to store the value.
  404. * @ return The CURLcode code, see cURL_header.inc
  405. */
  406. native CURLcode:curl_easy_getinfo_int(Handle:hndl, CURLINFO:info, &any:value);
  407.  
  408. /**
  409. * URL encodes the given string
  410. * @ param Handle hndl The handle of the curl to be used.
  411. * @ param String url The string to encodes.
  412. * @ param String buffer Destination string buffer to copy to.
  413. * @ param cell_t maxlen Destination buffer length (includes null terminator).
  414. * @ return 1 on success.
  415. */
  416. native bool:curl_easy_escape(Handle:hndl, const String:url[], String:buffer[], maxlen);
  417.  
  418. /**
  419. * URL decodes the given string
  420. * @ param Handle hndl The handle of the curl to be used.
  421. * @ param String url The string to dencodes.
  422. * @ param String buffer Destination string buffer to copy to.
  423. * @ param cell_t maxlen Destination buffer length (includes null terminator).
  424. * @ return The output length.
  425. */
  426. native curl_easy_unescape(Handle:hndl, const String:url[], String:buffer[], maxlen);
  427.  
  428. /**
  429. * Return string describing error code
  430. * @ param CURLcode code The CURLcode code, see cURL_header.inc
  431. * @ param String buffer Destination string buffer to copy to.
  432. * @ param cell_t maxlen Destination buffer length (includes null terminator).
  433. * @ noreturn
  434. */
  435. native curl_easy_strerror(CURLcode: code, String:buffer[], maxlen);
  436.  
  437. /**
  438. * Returns the libcurl version string
  439. * @ param String buffer Destination string buffer to copy to.
  440. * @ param cell_t maxlen Destination buffer length (includes null terminator).
  441. * @ noreturn
  442. */
  443. native curl_version(String:buffer[], maxlen);
  444.  
  445. /**
  446. * Returns the libcurl supported protocols string
  447. * @ param String buffer Destination string buffer to copy to.
  448. * @ param cell_t maxlen Destination buffer length (includes null terminator).
  449. * @ noreturn
  450. */
  451. native curl_protocols(String:buffer[], maxlen);
  452.  
  453. /**
  454. * Returns the libcurl supported features
  455. * @ return The currently features bits. see CURL_VERSION_*
  456. */
  457. native curl_features();
  458.  
  459. /**
  460. * This funcitopn same as Sourcemod OpenFile()
  461. * For the following CUROPT_* only
  462. * CURLOPT_WRITEDATA
  463. * CURLOPT_HEADERDATA
  464. * CURLOPT_READDATA
  465. * CURLOPT_STDERR
  466. * CURLOPT_INTERLEAVEDATA
  467. *
  468. * @ note
  469. * Should not share to another threaded curl handle.
  470. *
  471. * @ param file File to open.
  472. * @ param mode Open mode.
  473. * @ return A Handle to the file, INVALID_HANDLE on open error.
  474. */
  475. native Handle:curl_OpenFile(const String:file[], const String:mode[]);
  476.  
  477.  
  478. /**
  479. * Create a curl_httppost struct
  480. * For the following CUROPT_* only
  481. * CURLOPT_HTTPPOST
  482. * @ note
  483. * Should not share to another threaded curl handle.
  484. *
  485. * @ return A Handle to the curl_httppost, INVALID_HANDLE on error.
  486. */
  487. native Handle:curl_httppost();
  488.  
  489. /**
  490. * Add a section to a multipart/formdata HTTP POST
  491. * @ note
  492. * Check enum CURLformoption (cURL_head.inc) to see which option supported
  493. *
  494. * @ param Handle hndl The handle of the curl_httppost to be used.
  495. * @ param ... Variable number of format parameters.
  496. * @ return The CURLFORMcode code, see cURL_header.inc
  497. */
  498. native CURLFORMcode:curl_formadd(Handle:handl, any:...);
  499.  
  500. /**
  501. * Create a curl_slist struct
  502. * For the following CUROPT_* only
  503. * CURLOPT_QUOTE
  504. * CURLOPT_HTTPHEADER
  505. * CURLOPT_POSTQUOTE
  506. * CURLOPT_TELNETOPTIONS
  507. * CURLOPT_PREQUOTE
  508. * CURLOPT_HTTP200ALIASES
  509. * CURLOPT_MAIL_RCPT
  510. * CURLOPT_RESOLVE
  511. *
  512. * @ note
  513. * Should not share to another threaded curl handle.
  514. *
  515. * @ return A Handle to the curl_slist, INVALID_HANDLE on error.
  516. */
  517. native Handle:curl_slist();
  518.  
  519. /**
  520. * Add a string to an slist
  521. * @ param Handle hndl The handle of the curl_slist to be used.
  522. * @ param String buffer The string to add
  523. * @ noreturn
  524. */
  525. native curl_slist_append(Handle:hndl, const String:buffer[]);
  526.  
  527. /**
  528. * Hash a file
  529. * @ parma String file The file path. supports the "file://" notation.
  530. * @ param Openssl_Hash algorithm Hash Algorithm.
  531. * @ param Openssl_Hash_Complete complete_callback The complete callback.
  532. * @ param cell_t value Value to set.
  533. * @ noreturn
  534. */
  535. native curl_hash_file(const String:file[], Openssl_Hash:algorithm, Openssl_Hash_Complete:complete_callback, any:value=0);
  536.  
  537. /**
  538. * Hash a string
  539. * @ parma String input The string to hash.
  540. * @ param cell_t dataSize The input string size.
  541. * @ param Openssl_Hash algorithm Hash Algorithm.
  542. * @ param String buffer Destination string buffer to copy to.
  543. * @ param cell_t maxlen Destination buffer length (includes null terminator).
  544. * @ return 1 on success
  545. */
  546. native bool:curl_hash_string(const String:input[], dataSize, Openssl_Hash:algorithm, String:buffer[], maxlength);
  547.  
  548.  
  549. /**
  550. * Do not edit below this line!
  551. */
  552. public Extension:__ext_curl =
  553. {
  554. name = "curl",
  555. file = "curl.ext",
  556. #if defined AUTOLOAD_EXTENSIONS
  557. autoload = 1,
  558. #else
  559. autoload = 0,
  560. #endif
  561. #if defined REQUIRE_EXTENSIONS
  562. required = 1,
  563. #else
  564. required = 0,
  565. #endif
  566. };
Add Comment
Please, Sign In to add comment