lib: intro `Float.lerp` for simple linear interpolation
[nit.git] / lib / curl / curl_c.nit
index 61525a6..287dbce 100644 (file)
 # limitations under the License.
 
 # Binding of C libCurl which allow us to interact with network.
-module curl_c
-
-import pipeline
+module curl_c is pkgconfig("libcurl")
 
 in "C header" `{
-       #include <stdio.h>
-       #include <stdlib.h>
        #include <curl/curl.h>
 
        typedef enum {
@@ -44,21 +40,25 @@ in "C header" `{
 `}
 
 in "C body" `{
+       #include <stdio.h>
+       #include <stdlib.h>
+       #include <string.h>
+
        // Callbacks method for Header, Body, Stream.
        size_t nit_curl_callback_func(void *buffer, size_t size, size_t count, CURLCallbackDatas *datas){
                if(datas->type == CURLcallbackTypeHeader){
                        char *line_c = (char*)buffer;
-                       String line_o = new_String_copy_from_native(line_c);
+                       String line_o = NativeString_to_s_with_copy(line_c);
                        CCurlCallbacks_header_callback(datas->delegate, line_o);
                }
                else if(datas->type == CURLcallbackTypeBody){
                        char *line_c = (char*)buffer;
-                       String line_o = new_String_copy_from_native(line_c);
+                       String line_o = NativeString_to_s_with_copy(line_c);
                        CCurlCallbacks_body_callback(datas->delegate, line_o);
                }
                else if(datas->type == CURLcallbackTypeStream){
                        char *line_c = (char*)buffer;
-                       String line_o = new_String_from_cstring(line_c);
+                       String line_o = NativeString_to_s(line_c);
                        CCurlCallbacks_stream_callback(datas->delegate, line_o, size, count);
                }
                return count;
@@ -74,7 +74,7 @@ in "C body" `{
 `}
 
 # CURL Extern Type, reproduce CURL low level behaviors
-extern CCurl `{ CURL * `}
+extern class CCurl `{ CURL * `}
        # Constructor, CURL low level initializer
        new easy_init `{ return curl_easy_init(); `}
        # Check for correct initialization
@@ -101,7 +101,7 @@ extern CCurl `{ CURL * `}
        # Internal method to set options to CURL using CURLSList parameter.
        private fun i_setopt_slist(opt: CURLOption, list: CURLSList):CURLCode `{ return curl_easy_setopt( recv, opt, list); `}
        # Internal method to set options to CURL using String parameter.
-       private fun i_setopt_string(opt: CURLOption, str: String):CURLCode import String::to_cstring `{
+       private fun i_setopt_string(opt: CURLOption, str: String):CURLCode import String.to_cstring `{
                char *rStr = String_to_cstring(str);
                return curl_easy_setopt( recv, opt, rStr);
        `}
@@ -113,11 +113,11 @@ extern CCurl `{ CURL * `}
                 return answ
        end
        # Internal method used to get String object information initially knowns as C Chars type
-       private fun i_getinfo_chars(opt: CURLInfoChars, res: CURLInfoResponseString):CURLCode import CURLInfoResponseString::response= `{
+       private fun i_getinfo_chars(opt: CURLInfoChars, res: CURLInfoResponseString):CURLCode import CURLInfoResponseString.response=, NativeString.to_s_with_copy `{
                char *r = NULL;
                CURLcode c = curl_easy_getinfo( recv, opt, &r);
                if((c == CURLE_OK) && r != NULL){
-                       String ro = new_String_copy_from_native(r);
+                       String ro = NativeString_to_s_with_copy(r);
                        CURLInfoResponseString_response__assign( res, ro);
                }
                return c;
@@ -130,7 +130,7 @@ extern CCurl `{ CURL * `}
                 return answ
        end
        # Internal method used to get Int object information initially knowns as C Long type
-       private fun i_getinfo_long(opt: CURLInfoLong, res: CURLInfoResponseLong):CURLCode import CURLInfoResponseLong::response= `{
+       private fun i_getinfo_long(opt: CURLInfoLong, res: CURLInfoResponseLong):CURLCode import CURLInfoResponseLong.response= `{
                long *r = NULL;
                r = malloc(sizeof(long));
                CURLcode c = curl_easy_getinfo( recv, opt, r);
@@ -146,7 +146,7 @@ extern CCurl `{ CURL * `}
                 return answ
        end
        # Internal method used to get Int object information initially knowns as C Double type
-       private fun i_getinfo_double(opt: CURLInfoDouble, res: CURLInfoResponseDouble):CURLCode import CURLInfoResponseDouble::response= `{
+       private fun i_getinfo_double(opt: CURLInfoDouble, res: CURLInfoResponseDouble):CURLCode import CURLInfoResponseDouble.response= `{
                double *r = NULL;
                r = malloc(sizeof(double));
                CURLcode c = curl_easy_getinfo( recv, opt, r);
@@ -164,7 +164,7 @@ extern CCurl `{ CURL * `}
                return answ
        end
        # Internal method used to get Array[String] object information initially knowns as C SList type
-       private fun i_getinfo_slist(opt: CURLInfoSList, res: CURLInfoResponseArray):CURLCode import CURLInfoResponseArray::prim_response=`{
+       private fun i_getinfo_slist(opt: CURLInfoSList, res: CURLInfoResponseArray):CURLCode import CURLInfoResponseArray.prim_response=`{
                struct curl_slist* csl = NULL;
                CURLcode ce = curl_easy_getinfo( recv, opt, &csl);
                CURLInfoResponseArray_prim_response__assign(res, csl);
@@ -185,17 +185,16 @@ extern CCurl `{ CURL * `}
                return once new CURLCode.unknown_option
        end
        # Internal method used to configure read callback
-       private fun i_register_read_datas_callback(delegate: CCurlCallbacks, datas: String, size: Int):CURLCode import String::to_cstring, String::copy_from_native `{
+       private fun i_register_read_datas_callback(delegate: CCurlCallbacks, datas: String, size: Int):CURLCode import String.to_cstring `{
                CURLCallbackReadDatas *d = NULL;
                d = malloc(sizeof(CURLCallbackReadDatas));
                d->data = (char*)String_to_cstring(datas);
                d->len = size;
                d->pos = 0;
                return curl_easy_setopt( recv, CURLOPT_READDATA, d);
-
        `}
        # Internal method used to configure callbacks in terms of given type
-       private fun i_register_callback(delegate: CCurlCallbacks, cbtype: CURLCallbackType):CURLCode is extern import CCurlCallbacks::header_callback,  CCurlCallbacks::body_callback, CCurlCallbacks::stream_callback  `{
+       private fun i_register_callback(delegate: CCurlCallbacks, cbtype: CURLCallbackType):CURLCode is extern import CCurlCallbacks.header_callback, CCurlCallbacks.body_callback, CCurlCallbacks.stream_callback, NativeString.to_s_with_copy, NativeString.to_s `{
                CURLCallbackDatas *d = malloc(sizeof(CURLCallbackDatas));
                CCurlCallbacks_incr_ref(delegate);
                d->type = cbtype;
@@ -203,36 +202,36 @@ extern CCurl `{ CURL * `}
                CURLcode e;
                switch(cbtype){
                        case CURLcallbackTypeHeader:
-                               e = curl_easy_setopt( recv, CURLOPT_HEADERFUNCTION, &nit_curl_callback_func);
+                               e = curl_easy_setopt( recv, CURLOPT_HEADERFUNCTION, (curl_write_callback)&nit_curl_callback_func);
                                if(e != CURLE_OK) return e;
                                e = curl_easy_setopt( recv, CURLOPT_WRITEHEADER, d);
                        break;
                        case CURLcallbackTypeBody:
                        case CURLcallbackTypeStream:
-                               e = curl_easy_setopt( recv, CURLOPT_WRITEFUNCTION, &nit_curl_callback_func);
+                               e = curl_easy_setopt( recv, CURLOPT_WRITEFUNCTION, (curl_write_callback)&nit_curl_callback_func);
                                if(e != CURLE_OK) return e;
                                e = curl_easy_setopt( recv, CURLOPT_WRITEDATA, d);
                        break;
                        case CURLcallbackTypeRead:
-                               e = curl_easy_setopt( recv, CURLOPT_READFUNCTION, &nit_curl_callback_read_func);
+                               e = curl_easy_setopt( recv, CURLOPT_READFUNCTION, (curl_write_callback)&nit_curl_callback_read_func);
                        default:
                        break;
                }
                return e;
        `}
        # Convert given string to URL encoded string
-       fun escape(url: String):String `{
+       fun escape(url: String):String import String.to_cstring, NativeString.to_s_with_copy `{
                char *orig_url, *encoded_url = NULL;
                orig_url = String_to_cstring(url);
                encoded_url = curl_easy_escape( recv, orig_url, strlen(orig_url));
-               String b_url = new_String_copy_from_native(encoded_url);
+               String b_url = NativeString_to_s_with_copy(encoded_url);
                curl_free(encoded_url);
                return b_url;
        `}
 end
 
 # FILE Extern type, reproduce basic FILE I/O
-extern OFile `{ FILE* `}
+extern class OFile `{ FILE* `}
        # Open / Create a file from given name
        new open(str: NativeString) `{ return fopen(str, "wb"); `}
        # Check for File validity
@@ -263,7 +262,7 @@ interface CCurlCallbacks
 end
 
 # Extern Type to reproduce Enum of available Callback type
-extern CURLCallbackType `{ CURLcallbackType `}
+extern class CURLCallbackType `{ CURLcallbackType `}
        new header `{ return CURLcallbackTypeHeader; `}
        new body `{ return CURLcallbackTypeBody; `}
        new stream `{ return CURLcallbackTypeStream; `}
@@ -272,7 +271,7 @@ extern CURLCallbackType `{ CURLcallbackType `}
 end
 
 # CURL Code binding and helpers
-extern CURLCode `{ CURLcode `}
+extern class CURLCode `{ CURLcode `}
        new unknown_option `{ return CURLE_UNKNOWN_OPTION; `}
        new unsupported_protocol `{ return CURLE_UNSUPPORTED_PROTOCOL; `}
        new ok `{ return CURLE_OK; `}
@@ -282,18 +281,18 @@ extern CURLCode `{ CURLcode `}
        fun is_valid_protocol:Bool `{ return recv == CURLE_UNSUPPORTED_PROTOCOL; `}
        fun is_valid_init:Bool `{ return recv == CURLE_FAILED_INIT; `}
        fun to_i:Int do return code end
-       redef fun to_s `{
+       redef fun to_s import NativeString.to_s_with_copy `{
                char *c = (char*)curl_easy_strerror(recv);
-               return new_String_copy_from_native(c);
+               return NativeString_to_s_with_copy(c);
        `}
 end
 
 # Extern Type of the Linked list type of CURL
-extern CURLSList `{ struct curl_slist * `}
+extern class CURLSList `{ struct curl_slist * `}
        # Empty constructor which allow us to avoid the use of Nit NULLABLE type
        private new `{ return NULL; `}
        # Constructor allow us to get list instancied by appending an element inside.
-       new with_str(s: String) import String::to_cstring `{
+       new with_str(s: String) import String.to_cstring `{
                struct curl_slist *l = NULL;
                l = curl_slist_append(l, String_to_cstring(s));
                return l;
@@ -301,7 +300,7 @@ extern CURLSList `{ struct curl_slist * `}
        # Check for initialization
        fun is_init:Bool `{ return (recv != NULL); `}
        # Append an element in the linked list
-       fun append(key: String) import String::to_cstring `{
+       fun append(key: String) import String.to_cstring `{
                 char *k = String_to_cstring(key);
                 curl_slist_append(recv, (char*)k);
        `}
@@ -310,7 +309,7 @@ extern CURLSList `{ struct curl_slist * `}
        # Internal method to check for reachability of next element
        private fun i_next_reachable(c: CURLSList):Bool `{ return (c != NULL && c->next != NULL); `}
        # Internal method to get current data
-       private fun i_data(c: CURLSList):String `{ return new_String_from_cstring(c->data); `}
+       private fun i_data(c: CURLSList):String import NativeString.to_s `{ return NativeString_to_s(c->data); `}
        # Internal method to get next element
        private fun i_next(c: CURLSList):CURLSList `{ return c->next; `}
        # Convert current low level List to an Array[String] object
@@ -337,23 +336,27 @@ redef class Collection[E]
                        print "Collection item must be strings."
                end
                var primList = new CURLSList.with_str(self.first)
-               for s in self.skip_head(1) do primList.append(s)
+               var is_first = true
+               for s in self do
+                       if not is_first then primList.append(s)
+                       is_first = false
+               end
                return primList
        end
 end
 
-# Array Response type of CCurl::easy_getinfo method
+# Array Response type of CCurl.easy_getinfo method
 class CURLInfoResponseArray
        var response:Array[String] = new Array[String]
        private var prim_response:CURLSList = new CURLSList
 end
 
-# Long Response type of CCurl::easy_getinfo method
+# Long Response type of CCurl.easy_getinfo method
 class CURLInfoResponseLong
        var response:Int=0
 end
 
-# Double Response type of CCurl::easy_getinfo method
+# Double Response type of CCurl.easy_getinfo method
 class CURLInfoResponseDouble
        var response:Int=0
 end
@@ -363,14 +366,14 @@ class CURLInfoResponseString
        var response:String = ""
 end
 
-# Reproduce Enum of available CURL SList information, used for CCurl::easy_getinfo
-extern CURLInfoSList `{ CURLINFO `}
+# Reproduce Enum of available CURL SList information, used for CCurl.easy_getinfo
+extern class CURLInfoSList `{ CURLINFO `}
        new ssl_engines `{ return CURLINFO_SSL_ENGINES; `}
        new cookielist `{ return CURLINFO_COOKIELIST; `}
 end
 
-# Reproduce Enum of available CURL Long information, used for CCurl::easy_getinfo
-extern CURLInfoLong `{ CURLINFO `}
+# Reproduce Enum of available CURL Long information, used for CCurl.easy_getinfo
+extern class CURLInfoLong `{ CURLINFO `}
        new response_code `{ return CURLINFO_RESPONSE_CODE; `}
        new header_size `{ return CURLINFO_HEADER_SIZE; `}
        new http_connectcode `{ return CURLINFO_HTTP_CONNECTCODE; `}
@@ -391,8 +394,8 @@ extern CURLInfoLong `{ CURLINFO `}
        new rtsp_cseq_recv `{ return CURLINFO_RTSP_CSEQ_RECV; `}
 end
 
-# Reproduce Enum of available CURL Double information, used for CCurl::easy_getinfo
-extern CURLInfoDouble `{ CURLINFO `}
+# Reproduce Enum of available CURL Double information, used for CCurl.easy_getinfo
+extern class CURLInfoDouble `{ CURLINFO `}
        new total_time `{ return CURLINFO_TOTAL_TIME; `}
        new namelookup_time `{ return CURLINFO_NAMELOOKUP_TIME; `}
        new connect_time `{ return CURLINFO_CONNECT_TIME; `}
@@ -408,8 +411,8 @@ extern CURLInfoDouble `{ CURLINFO `}
        new content_length_upload `{ return CURLINFO_CONTENT_LENGTH_UPLOAD; `}
 end
 
-# Reproduce Enum of available CURL Chars information, used for CCurl::easy_getinfo
-extern CURLInfoChars `{ CURLINFO `}
+# Reproduce Enum of available CURL Chars information, used for CCurl.easy_getinfo
+extern class CURLInfoChars `{ CURLINFO `}
        new content_type `{ return CURLINFO_CONTENT_TYPE; `}
        new effective_url `{ return CURLINFO_EFFECTIVE_URL; `}
        new redirect_url `{ return CURLINFO_REDIRECT_URL; `}
@@ -421,7 +424,7 @@ extern CURLInfoChars `{ CURLINFO `}
 end
 
 # Reproduce Enum of HTTP Status Code
-extern CURLStatusCode `{ int `}
+extern class CURLStatusCode `{ int `}
        new proceed `{ return 100; `}
        new switching_protocols `{ return 101; `}
        new ok `{ return 200; `}
@@ -462,207 +465,299 @@ extern CURLStatusCode `{ int `}
        fun to_i:Int `{ return recv; `}
 end
 
-# Reproduce Enum of CURL Options usable, used for CCurl::easy_setopt
-extern CURLOption `{ CURLoption `}
+# Reproduce Enum of CURL Options usable, used for CCurl.easy_setopt
+extern class CURLOption `{ CURLoption `}
+
+       # Behavior options
+
+       # Display verbose information.
+       new verbose `{ return CURLOPT_VERBOSE; `}
+       # Include the header in the body output.
+       new header `{ return CURLOPT_HEADER; `}
+       # Shut off the progress meter.
+       new no_progress `{ return CURLOPT_NOPROGRESS; `}
+       # Do not install signal handlers.
+       new     no_signal `{ return CURLOPT_NOSIGNAL; `}
+       # Transfer multiple files according to a file name pattern.
+       new     wild_card_match `{ return CURLOPT_WILDCARDMATCH; `}
+
+       # Callback Options
+
+       # Callback for writing data.
        new write_function `{ return CURLOPT_WRITEFUNCTION; `}
+       # Data pointer to pass to the write callback.
        new write_data `{ return CURLOPT_WRITEDATA; `}
-#      new     `{ return CURLOPT_FILE; `}
-       new url `{ return CURLOPT_URL; `}
-#      new     `{ return CURLOPT_PORT; `}
-#      new     `{ return CURLOPT_PROXY; `}
-#      new     `{ return CURLOPT_USERPWD; `}
-#      new     `{ return CURLOPT_PROXYUSERPWD; `}
-#      new     `{ return CURLOPT_RANGE; `}
-#      new     `{ return CURLOPT_INFILE; `}
-#      new     `{ return CURLOPT_ERRORBUFFER; `}
-#      new     `{ return CURLOPT_WRITEFUNCTION; `}
+
 #      new     `{ return CURLOPT_READFUNCTION; `}
-#      new     `{ return CURLOPT_TIMEOUT; `}
-#      new     `{ return CURLOPT_INFILESIZE; `}
-       new postfields `{ return CURLOPT_POSTFIELDS; `}
-#      new     `{ return CURLOPT_REFERER; `}
-#      new     `{ return CURLOPT_FTPPORT; `}
-#      new     `{ return CURLOPT_USERAGENT; `}
-#      new     `{ return CURLOPT_LOW_SPEED_LIMIT; `}
-#      new     `{ return CURLOPT_LOW_SPEED_TIME; `}
-#      new     `{ return CURLOPT_RESUME_FROM; `}
-#      new     `{ return CURLOPT_COOKIE; `}
-       new httpheader `{ return CURLOPT_HTTPHEADER; `}
-#      new     `{ return CURLOPT_HTTPPOST; `}
-#      new     `{ return CURLOPT_SSLCERT; `}
-#      new     `{ return CURLOPT_KEYPASSWD; `}
-#      new     `{ return CURLOPT_CRLF; `}
-#      new     `{ return CURLOPT_QUOTE; `}
-#      new     `{ return CURLOPT_WRITEHEADER; `}
-#      new     `{ return CURLOPT_COOKIEFILE; `}
-#      new     `{ return CURLOPT_SSLVERSION; `}
-#      new     `{ return CURLOPT_TIMECONDITION; `}
-#      new     `{ return CURLOPT_TIMEVALUE; `}
-#      new     `{ return CURLOPT_CUSTOMREQUEST; `}
-#      new     `{ return CURLOPT_STDERR; `}
-#      new     `{ return CURLOPT_POSTQUOTE; `}
-#      new     `{ return CURLOPT_WRITEINFO; `} /* DEPRECATED, do not use! */
-       new verbose `{ return CURLOPT_VERBOSE; `}                       # talk a lot
-       new header `{ return CURLOPT_HEADER; `}                  # throw the header out too
-       new no_progress `{ return CURLOPT_NOPROGRESS; `}         # shut off the progress meter
-       new no_body `{ return CURLOPT_NOBODY; `}                         # use HEAD to get http document
-       new fail_on_error `{ return CURLOPT_FAILONERROR; `}     # no output on http error codes >= 300
-       new upload `{ return CURLOPT_UPLOAD; `}                  # this is an upload
-       new post `{ return CURLOPT_POST; `}                              # HTTP POST method
-       new dir_list_only `{ return CURLOPT_DIRLISTONLY; `}     # bare names when listing directories
-       new append `{ return CURLOPT_APPEND; `}                  # Append instead of overwrite on upload!
-#      new     `{ return CURLOPT_NETRC; `}
-       new follow_location `{ return CURLOPT_FOLLOWLOCATION; `}        # use Location: Luke!
-       new transfert_text `{ return CURLOPT_TRANSFERTEXT; `} # transfer data in text/ASCII format
-       new put `{ return CURLOPT_PUT; `}                                       # HTTP PUT */
+#      new `{ return CURLOPT_READDATA; `}
+#      new     `{ return CURLOPT_IOCTLFUNCTION; `}
+#      new     `{ return CURLOPT_IOCTLDATA; `}
+#      new     `{ return CURLOPT_SEEKFUNCTION; `}
+#      new     `{ return CURLOPT_SEEKDATA; `}
+#      new     `{ return CURLOPT_SOCKOPTFUNCTION; `}
+#      new     `{ return CURLOPT_SOCKOPTDATA; `}
+#      new     `{ return CURLOPT_OPENSOCKETFUNCTION; `}
+#      new     `{ return CURLOPT_OPENSOCKETDATA; `}
+#      new     `{ return CURLOPT_CLOSESOCKETFUNCTION; `}
+#      new     `{ return CURLOPT_CLOSESOCKETDATA; `}
 #      new     `{ return CURLOPT_PROGRESSFUNCTION; `}
 #      new     `{ return CURLOPT_PROGRESSDATA; `}
-#      new     `{ return CURLOPT_AUTOREFERER; `}
-#      new     `{ return CURLOPT_PROXYPORT; `}
-#      new     `{ return CURLOPT_POSTFIELDSIZE; `}
-#      new     `{ return CURLOPT_HTTPPROXYTUNNEL; `}
-#      new     `{ return CURLOPT_INTERFACE; `}
-#      new     `{ return CURLOPT_KRBLEVEL; `}
-#      new     `{ return CURLOPT_SSL_VERIFYPEER; `}
-#      new     `{ return CURLOPT_CAINFO; `}
-#      new     `{ return CURLOPT_MAXREDIRS; `}
-#      new     `{ return CURLOPT_FILETIME; `}
-#      new     `{ return CURLOPT_TELNETOPTIONS; `}
-#      new     `{ return CURLOPT_MAXCONNECTS; `}
-#      new     `{ return CURLOPT_CLOSEPOLICY; `} /* DEPRECATED, do not use! */
-#      new     `{ return CURLOPT_FRESH_CONNECT; `}
-#      new     `{ return CURLOPT_FORBID_REUSE; `}
-#      new     `{ return CURLOPT_RANDOM_FILE; `}
-#      new     `{ return CURLOPT_EGDSOCKET; `}
-#      new     `{ return CURLOPT_CONNECTTIMEOUT; `}
 #      new     `{ return CURLOPT_HEADERFUNCTION; `}
-#      new     `{ return CURLOPT_HTTPGET; `}
-#      new     `{ return CURLOPT_SSL_VERIFYHOST; `}
-#      new     `{ return CURLOPT_COOKIEJAR; `}
-#      new     `{ return CURLOPT_SSL_CIPHER_LIST; `}
-#      new     `{ return CURLOPT_HTTP_VERSION; `}
-#      new     `{ return CURLOPT_FTP_USE_EPSV; `}
-#      new     `{ return CURLOPT_SSLCERTTYPE; `}
-#      new     `{ return CURLOPT_SSLKEY; `}
-#      new     `{ return CURLOPT_SSLKEYTYPE; `}
-#      new     `{ return CURLOPT_SSLENGINE; `}
-#      new     `{ return CURLOPT_SSLENGINE_DEFAULT; `}
-#      new     `{ return CURLOPT_DNS_USE_GLOBAL_CACHE; `} /* DEPRECATED, do not use! */
-#      new     `{ return CURLOPT_DNS_CACHE_TIMEOUT; `}
-#      new     `{ return CURLOPT_PREQUOTE; `}
 #      new     `{ return CURLOPT_DEBUGFUNCTION; `}
 #      new     `{ return CURLOPT_DEBUGDATA; `}
-#      new     `{ return CURLOPT_COOKIESESSION; `}
-#      new     `{ return CURLOPT_CAPATH; `}
-#      new     `{ return CURLOPT_BUFFERSIZE; `}
-#      new     `{ return CURLOPT_NOSIGNAL; `}
-#      new     `{ return CURLOPT_SHARE; `}
-#      new     `{ return CURLOPT_PROXYTYPE; `}
-#      new     `{ return CURLOPT_ACCEPT_ENCODING; `}
-#      new     `{ return CURLOPT_PRIVATE; `}
-#      new     `{ return CURLOPT_HTTP200ALIASES; `}
-#      new     `{ return CURLOPT_UNRESTRICTED_AUTH; `}
-#      new     `{ return CURLOPT_FTP_USE_EPRT; `}
-#      new     `{ return CURLOPT_HTTPAUTH; `}
 #      new     `{ return CURLOPT_SSL_CTX_FUNCTION; `}
 #      new     `{ return CURLOPT_SSL_CTX_DATA; `}
-#      new     `{ return CURLOPT_FTP_CREATE_MISSING_DIRS; `}
-#      new     `{ return CURLOPT_PROXYAUTH; `}
-#      new     `{ return CURLOPT_FTP_RESPONSE_TIMEOUT; `}
-#      new     `{ return CURLOPT_IPRESOLVE; `}
-#      new     `{ return CURLOPT_MAXFILESIZE; `}
-#      new     `{ return CURLOPT_INFILESIZE_LARGE; `}
-#      new     `{ return CURLOPT_RESUME_FROM_LARGE; `}
-#      new     `{ return CURLOPT_MAXFILESIZE_LARGE; `}
-#      new     `{ return CURLOPT_NETRC_FILE; `}
-#      new     `{ return CURLOPT_USE_SSL; `}
-#      new     `{ return CURLOPT_POSTFIELDSIZE_LARGE; `}
-#      new     `{ return CURLOPT_TCP_NODELAY; `}
-#      new     `{ return CURLOPT_FTPSSLAUTH; `}
-#      new     `{ return CURLOPT_IOCTLFUNCTION; `}
-#      new     `{ return CURLOPT_IOCTLDATA; `}
-#      new     `{ return CURLOPT_FTP_ACCOUNT; `}
-#      new     `{ return CURLOPT_COOKIELIST; `}
-#      new     `{ return CURLOPT_IGNORE_CONTENT_LENGTH; `}
-#      new     `{ return CURLOPT_FTP_SKIP_PASV_IP; `}
-#      new     `{ return CURLOPT_FTP_FILEMETHOD; `}
-#      new     `{ return CURLOPT_LOCALPORT; `}
-#      new     `{ return CURLOPT_LOCALPORTRANGE; `}
-#      new     `{ return CURLOPT_CONNECT_ONLY; `}
-#      new     `{ return CURLOPT_CONV_FROM_NETWORK_FUNCTION; `}
 #      new     `{ return CURLOPT_CONV_TO_NETWORK_FUNCTION; `}
+#      new     `{ return CURLOPT_CONV_FROM_NETWORK_FUNCTION; `}
 #      new     `{ return CURLOPT_CONV_FROM_UTF8_FUNCTION; `}
-#      new     `{ return CURLOPT_MAX_SEND_SPEED_LARGE; `}
-#      new     `{ return CURLOPT_MAX_RECV_SPEED_LARGE; `}
-#      new     `{ return CURLOPT_FTP_ALTERNATIVE_TO_USER; `}
-#      new     `{ return CURLOPT_SOCKOPTFUNCTION; `}
-#      new     `{ return CURLOPT_SOCKOPTDATA; `}
-#      new     `{ return CURLOPT_SSL_SESSIONID_CACHE; `}
-#      new     `{ return CURLOPT_SSH_AUTH_TYPES; `}
-#      new     `{ return CURLOPT_SSH_PUBLIC_KEYFILE; `}
-#      new     `{ return CURLOPT_SSH_PRIVATE_KEYFILE; `}
-#      new     `{ return CURLOPT_FTP_SSL_CCC; `}
-#      new     `{ return CURLOPT_TIMEOUT_MS; `}
-#      new     `{ return CURLOPT_CONNECTTIMEOUT_MS; `}
-#      new     `{ return CURLOPT_HTTP_TRANSFER_DECODING; `}
-#      new     `{ return CURLOPT_HTTP_CONTENT_DECODING; `}
-#      new     `{ return CURLOPT_NEW_FILE_PERMS; `}
-#      new     `{ return CURLOPT_NEW_DIRECTORY_PERMS; `}
-#      new     `{ return CURLOPT_POSTREDIR; `}
-#      new     `{ return CURLOPT_SSH_HOST_PUBLIC_KEY_MD5; `}
-#      new     `{ return CURLOPT_OPENSOCKETFUNCTION; `}
-#      new     `{ return CURLOPT_OPENSOCKETDATA; `}
-#      new     `{ return CURLOPT_COPYPOSTFIELDS; `}
-#      new     `{ return CURLOPT_PROXY_TRANSFER_MODE; `}
-#      new     `{ return CURLOPT_SEEKFUNCTION; `}
-#      new     `{ return CURLOPT_SEEKDATA; `}
-#      new     `{ return CURLOPT_CRLFILE; `}
-#      new     `{ return CURLOPT_ISSUERCERT; `}
+#      new     `{ return CURLOPT_INTERLEAVEFUNCTION; `}
+#      new     `{ return CURLOPT_INTERLEAVEDATA; `}
+#      new     `{ return CURLOPT_CHUNK_BGN_FUNCTION; `}
+#      new     `{ return CURLOPT_CHUNK_END_FUNCTION; `}
+#      new     `{ return CURLOPT_CHUNK_DATA; `}
+#      new     `{ return CURLOPT_FNMATCH_FUNCTION; `}
+#      new     `{ return CURLOPT_FNMATCH_DATA; `}
+
+       # Error Options
+
+#      new     `{ return CURLOPT_ERRORBUFFER; `}
+#      new     `{ return CURLOPT_STDERR; `}
+
+       # Fail on HTTP 4xx errors.
+       new fail_on_error `{ return CURLOPT_FAILONERROR; `}
+
+       # Networkd Options
+
+       # URL to work on.
+       new url `{ return CURLOPT_URL; `}
+
+#      new     `{ return CURLOPT_PROTOCOLS; `}
+#      new     `{ return CURLOPT_REDIR_PROTOCOLS; `}
+#      new     `{ return CURLOPT_PROXY; `}
+#      new     `{ return CURLOPT_PROXYPORT; `}
+#      new     `{ return CURLOPT_PROXYTYPE; `}
+#      new     `{ return CURLOPT_NOPROXY; `}
+#      new     `{ return CURLOPT_HTTPPROXYTUNNEL; `}
+#      new     `{ return CURLOPT_SOCKS5_GSSAPI_SERVICE; `}
+#      new     `{ return CURLOPT_SOCKS5_GSSAPI_NEC; `}
+#      new     `{ return CURLOPT_INTERFACE; `}
+#      new     `{ return CURLOPT_LOCALPORT; `}
+#      new     `{ return CURLOPT_LOCALPORTRANGE; `}
+#      new     `{ return CURLOPT_DNS_CACHE_TIMEOUT; `}
+#      new     `{ return CURLOPT_DNS_USE_GLOBAL_CACHE; `} /* DEPRECATED, do not use! */
+#      new     `{ return CURLOPT_BUFFERSIZE; `}
+#      new     `{ return CURLOPT_PORT; `}
+#      new     `{ return CURLOPT_TCP_NODELAY; `}
 #      new     `{ return CURLOPT_ADDRESS_SCOPE; `}
-#      new     `{ return CURLOPT_CERTINFO; `}
+#      new     `{ return CURLOPT_TCP_KEEPALIVE; `}
+#      new     `{ return CURLOPT_TCP_KEEPIDLE; `}
+#      new     `{ return CURLOPT_TCP_KEEPINTVL; `}
+
+       # Names and Passwords Options
+
+#      new     `{ return CURLOPT_NETRC; `}
+#      new     `{ return CURLOPT_NETRC_FILE; `}
+#      new     `{ return CURLOPT_USERPWD; `}
+#      new     `{ return CURLOPT_PROXYUSERPWD; `}
+
        new     username `{ return CURLOPT_USERNAME; `}
        new     password `{ return CURLOPT_PASSWORD; `}
+
 #      new     `{ return CURLOPT_PROXYUSERNAME; `}
 #      new     `{ return CURLOPT_PROXYPASSWORD; `}
-#      new     `{ return CURLOPT_NOPROXY; `}
-#      new     `{ return CURLOPT_TFTP_BLKSIZE; `}
-#      new     `{ return CURLOPT_SOCKS5_GSSAPI_SERVICE; `}
-#      new     `{ return CURLOPT_SOCKS5_GSSAPI_NEC; `}
-#      new     `{ return CURLOPT_PROTOCOLS; `}
-#      new     `{ return CURLOPT_REDIR_PROTOCOLS; `}
-#      new     `{ return CURLOPT_SSH_KNOWNHOSTS; `}
-#      new     `{ return CURLOPT_SSH_KEYFUNCTION; `}
-#      new     `{ return CURLOPT_SSH_KEYDATA; `}
+#      new     `{ return CURLOPT_HTTPAUTH; `}
+#      new     `{ return CURLOPT_TLSAUTH_USERNAME; `}
+#      new     `{ return CURLOPT_TLSAUTH_PASSWORD; `}
+#      new     `{ return CURLOPT_PROXYAUTH; `}
+
+       # HTTP Options
+
+#      new     `{ return CURLOPT_AUTOREFERER; `}
+
+       # Accept-Encoding and automatic decompressing data.
+       new     accept_encoding `{ return CURLOPT_ACCEPT_ENCODING; `}
+       # Request Transfer-Encoding.
+       new     transfert_encoding `{ return CURLOPT_TRANSFER_ENCODING; `}
+       # Follow HTTP redirects.
+       new follow_location `{ return CURLOPT_FOLLOWLOCATION; `}
+
+#      new     `{ return CURLOPT_UNRESTRICTED_AUTH; `}
+#      new     `{ return CURLOPT_MAXREDIRS; `}
+#      new     `{ return CURLOPT_POSTREDIR; `}
+
+       # Issue a HTTP PUT request.
+       new put `{ return CURLOPT_PUT; `}
+       # Issue a HTTP POS request.
+       new post `{ return CURLOPT_POST; `}
+       # Send a POST with this data.
+       new postfields `{ return CURLOPT_POSTFIELDS; `}
+
+#      new     `{ return CURLOPT_POSTFIELDSIZE; `}
+#      new     `{ return CURLOPT_POSTFIELDSIZE_LARGE; `}
+#      new     `{ return CURLOPT_COPYPOSTFIELDS; `}
+#      new     `{ return CURLOPT_HTTPPOST; `}
+#      new     `{ return CURLOPT_REFERER; `}
+
+       # User-Agent: header.
+       new user_agent  `{ return CURLOPT_USERAGENT; `}
+       # Custom HTTP headers.
+       new httpheader `{ return CURLOPT_HTTPHEADER; `}
+
+#      new     `{ return CURLOPT_HTTP200ALIASES; `}
+#      new     `{ return CURLOPT_COOKIE; `}
+#      new     `{ return CURLOPT_COOKIEFILE; `}
+#      new     `{ return CURLOPT_COOKIEJAR; `}
+#      new     `{ return CURLOPT_COOKIESESSION; `}
+#      new     `{ return CURLOPT_COOKIELIST; `}
+
+       # Issue a HTTP GET request.
+       new     get `{ return CURLOPT_HTTPGET; `}
+
+       # HTTP version to use.
+       new http_version `{ return CURLOPT_HTTP_VERSION; `}
+
+#      new     `{ return CURLOPT_IGNORE_CONTENT_LENGTH; `}
+#      new     `{ return CURLOPT_HTTP_CONTENT_DECODING; `}
+#      new     `{ return CURLOPT_HTTP_TRANSFER_DECODING; `}
+
+       # SMTP Options
+
+       # Address of the sender.
        new     mail_from `{ return CURLOPT_MAIL_FROM; `}
+       # Address of the recipients.
        new     mail_rcpt `{ return CURLOPT_MAIL_RCPT; `}
+
+#      new     `{ return CURLOPT_MAIL_AUTH; `}
+
+       # TFTP Options
+
+#      new     `{ return CURLOPT_TFTP_BLKSIZE; `}
+
+       # FTP Options
+
+#      new     `{ return CURLOPT_FTPPORT; `}
+#      new     `{ return CURLOPT_QUOTE; `}
+#      new     `{ return CURLOPT_POSTQUOTE; `}
+#      new     `{ return CURLOPT_PREQUOTE; `}
+
+       # List only.
+       new dir_list_only `{ return CURLOPT_DIRLISTONLY; `}
+       # Append to remote file.
+       new append `{ return CURLOPT_APPEND; `}
+
+#      new     `{ return CURLOPT_FTP_USE_EPRT; `}
+#      new     `{ return CURLOPT_FTP_USE_EPSV; `}
 #      new     `{ return CURLOPT_FTP_USE_PRET; `}
+#      new     `{ return CURLOPT_FTP_CREATE_MISSING_DIRS; `}
+#      new     `{ return CURLOPT_FTP_RESPONSE_TIMEOUT; `}
+#      new     `{ return CURLOPT_FTP_ALTERNATIVE_TO_USER; `}
+#      new     `{ return CURLOPT_FTP_SKIP_PASV_IP; `}
+#      new     `{ return CURLOPT_FTPSSLAUTH; `}
+#      new     `{ return CURLOPT_FTP_SSL_CCC; `}
+#      new     `{ return CURLOPT_FTP_ACCOUNT; `}
+#      new     `{ return CURLOPT_FTP_FILEMETHOD; `}
+
+       # RTSP Options
+
 #      new     `{ return CURLOPT_RTSP_REQUEST; `}
 #      new     `{ return CURLOPT_RTSP_SESSION_ID; `}
 #      new     `{ return CURLOPT_RTSP_STREAM_URI; `}
 #      new     `{ return CURLOPT_RTSP_TRANSPORT; `}
 #      new     `{ return CURLOPT_RTSP_CLIENT_CSEQ; `}
 #      new     `{ return CURLOPT_RTSP_SERVER_CSEQ; `}
-#      new     `{ return CURLOPT_INTERLEAVEDATA; `}
-#      new     `{ return CURLOPT_INTERLEAVEFUNCTION; `}
-#      new     `{ return CURLOPT_WILDCARDMATCH; `}
-#      new     `{ return CURLOPT_CHUNK_BGN_FUNCTION; `}
-#      new     `{ return CURLOPT_CHUNK_END_FUNCTION; `}
-#      new     `{ return CURLOPT_FNMATCH_FUNCTION; `}
-#      new     `{ return CURLOPT_CHUNK_DATA; `}
-#      new     `{ return CURLOPT_FNMATCH_DATA; `}
+
+       # Protocol Options
+
+       # Transfer data in text/ASCII format.
+       new transfert_text `{ return CURLOPT_TRANSFERTEXT; `}
+
+#      new     `{ return CURLOPT_PROXY_TRANSFER_MODE; `}
+#      new     `{ return CURLOPT_CRLF; `}
+#      new     `{ return CURLOPT_RANGE; `}
+#      new     `{ return CURLOPT_RESUME_FROM; `}
+#      new     `{ return CURLOPT_RESUME_FROM_LARGE; `}
+
+       # Issue a custom request/method.
+       new     custom_request `{ return CURLOPT_CUSTOMREQUEST; `}
+
+#      new     `{ return CURLOPT_FILETIME; `}
+
+       # Do not get the body contents.
+       new no_body `{ return CURLOPT_NOBODY; `}
+
+#      new     `{ return CURLOPT_INFILESIZE; `}
+#      new     `{ return CURLOPT_INFILESIZE_LARGE; `}
+
+       # Upload data.
+       new upload `{ return CURLOPT_UPLOAD; `}
+
+#      new     `{ return CURLOPT_MAXFILESIZE; `}
+#      new     `{ return CURLOPT_MAXFILESIZE_LARGE; `}
+#      new     `{ return CURLOPT_TIMECONDITION; `}
+#      new     `{ return CURLOPT_TIMEVALUE; `}
+
+       # Connection Options
+
+#      new     `{ return CURLOPT_TIMEOUT; `}
+#      new     `{ return CURLOPT_TIMEOUT_MS; `}
+#      new     `{ return CURLOPT_LOW_SPEED_LIMIT; `}
+#      new     `{ return CURLOPT_LOW_SPEED_TIME; `}
+#      new     `{ return CURLOPT_MAX_SEND_SPEED_LARGE; `}
+#      new     `{ return CURLOPT_MAX_RECV_SPEED_LARGE; `}
+#      new     `{ return CURLOPT_MAXCONNECTS; `}
+#      new     `{ return CURLOPT_FRESH_CONNECT; `}
+#      new     `{ return CURLOPT_FORBID_REUSE; `}
+#      new     `{ return CURLOPT_CONNECTTIMEOUT; `}
+#      new     `{ return CURLOPT_CONNECTTIMEOUT_MS; `}
+#      new     `{ return CURLOPT_IPRESOLVE; `}
+#      new     `{ return CURLOPT_CONNECT_ONLY; `}
+#      new     `{ return CURLOPT_USE_SSL; `}
 #      new     `{ return CURLOPT_RESOLVE; `}
-#      new     `{ return CURLOPT_TLSAUTH_USERNAME; `}
-#      new     `{ return CURLOPT_TLSAUTH_PASSWORD; `}
-#      new     `{ return CURLOPT_TLSAUTH_TYPE; `}
-#      new     `{ return CURLOPT_TRANSFER_ENCODING; `}
-#      new     `{ return CURLOPT_CLOSESOCKETFUNCTION; `}
-#      new     `{ return CURLOPT_CLOSESOCKETDATA; `}
-#      new     `{ return CURLOPT_GSSAPI_DELEGATION; `}
-#      new     `{ return CURLOPT_DNS_SERVERS; `}
 #      new     `{ return CURLOPT_ACCEPTTIMEOUT_MS; `}
-#      new     `{ return CURLOPT_TCP_KEEPALIVE; `}
-#      new     `{ return CURLOPT_TCP_KEEPIDLE; `}
-#      new     `{ return CURLOPT_TCP_KEEPINTVL; `}
+
+       # SSL and Security Options
+
+#      new     `{ return CURLOPT_SSLCERT; `}
+#      new     `{ return CURLOPT_SSLCERTTYPE; `}
+#      new     `{ return CURLOPT_SSLKEY; `}
+#      new     `{ return CURLOPT_SSLKEYTYPE; `}
+#      new     `{ return CURLOPT_KEYPASSWD; `}
+#      new     `{ return CURLOPT_SSLENGINE; `}
+#      new     `{ return CURLOPT_SSLENGINE_DEFAULT; `}
+#      new     `{ return CURLOPT_SSLVERSION; `}
+#      new     `{ return CURLOPT_SSL_VERIFYPEER; `}
+#      new     `{ return CURLOPT_CAINFO; `}
+#      new     `{ return CURLOPT_ISSUERCERT; `}
+#      new     `{ return CURLOPT_CAPATH; `}
+#      new     `{ return CURLOPT_CRLFILE; `}
+#      new     `{ return CURLOPT_SSL_VERIFYHOST; `}
+#      new     `{ return CURLOPT_CERTINFO; `}
+#      new     `{ return CURLOPT_RANDOM_FILE; `}
+#      new     `{ return CURLOPT_EGDSOCKET; `}
+#      new     `{ return CURLOPT_SSL_CIPHER_LIST; `}
+#      new     `{ return CURLOPT_SSL_SESSIONID_CACHE; `}
 #      new     `{ return CURLOPT_SSL_OPTIONS; `}
-#      new     `{ return CURLOPT_MAIL_AUTH; `}
+#      new     `{ return CURLOPT_KRBLEVEL; `}
+#      new     `{ return CURLOPT_GSSAPI_DELEGATION; `}
+
+       # SSH Options
+
+#      new     `{ return CURLOPT_SSH_AUTH_TYPES; `}
+#      new     `{ return CURLOPT_SSH_HOST_PUBLIC_KEY_MD5; `}
+#      new     `{ return CURLOPT_SSH_PUBLIC_KEYFILE; `}
+#      new     `{ return CURLOPT_SSH_PRIVATE_KEYFILE; `}
+#      new     `{ return CURLOPT_SSH_KNOWNHOSTS; `}
+#      new     `{ return CURLOPT_SSH_KEYFUNCTION; `}
+#      new     `{ return CURLOPT_SSH_KEYDATA; `}
+
+       # Other Options
+
+#      new     `{ return CURLOPT_PRIVATE; `}
+#      new     `{ return CURLOPT_SHARE; `}
+#      new     `{ return CURLOPT_NEW_FILE_PERMS; `}
+#      new     `{ return CURLOPT_NEW_DIRECTORY_PERMS; `}
+
+       # TELNET Options
+
+#      new     `{ return CURLOPT_TELNETOPTIONS; `}
 end