Skip to content

Commit

Permalink
Using enums instead of const variables for constants
Browse files Browse the repository at this point in the history
  • Loading branch information
jcd committed Mar 29, 2011
1 parent 5195ec0 commit a42a954
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions etc/c/curl.d
Expand Up @@ -46,9 +46,9 @@ enum LIBCURL_VERSION = "7.21.4";

/* The numeric version number is also available "in parts" by using these
defines: */
const LIBCURL_VERSION_MAJOR = 7;
const LIBCURL_VERSION_MINOR = 21;
const LIBCURL_VERSION_PATCH = 4;
enum LIBCURL_VERSION_MAJOR = 7;
enum LIBCURL_VERSION_MINOR = 21;
enum LIBCURL_VERSION_PATCH = 4;

/* This is the numeric version of the libcurl version number, meant for easier
parsing and comparions by programs. The LIBCURL_VERSION_NUM define will
Expand All @@ -66,7 +66,7 @@ const LIBCURL_VERSION_PATCH = 4;
comparisons with greater than and less than work.
*/

const LIBCURL_VERSION_NUM = 0x071504;
enum LIBCURL_VERSION_NUM = 0x071504;

/*
* This is the date and time when the full source package was created. The
Expand Down Expand Up @@ -104,9 +104,9 @@ alias socket_t curl_socket_t;
// jdrewsen: Would like to get socket error constant from std.socket by it is private atm.
version(Win32) {
private import std.c.windows.windows, std.c.windows.winsock;
const int CURL_SOCKET_BAD = SOCKET_ERROR;
enum CURL_SOCKET_BAD = SOCKET_ERROR;
}
version(Posix) const int CURL_SOCKET_BAD = -1;
version(Posix) enum CURL_SOCKET_BAD = -1;

extern (C) struct curl_httppost
{
Expand All @@ -130,15 +130,15 @@ extern (C) struct curl_httppost
HTTPPOST_CALLBACK posts */
}

const HTTPPOST_FILENAME = 1; /* specified content is a file name */
const HTTPPOST_READFILE = 2; /* specified content is a file name */
const HTTPPOST_PTRNAME = 4; /* name is only stored pointer
enum HTTPPOST_FILENAME = 1; /* specified content is a file name */
enum HTTPPOST_READFILE = 2; /* specified content is a file name */
enum HTTPPOST_PTRNAME = 4; /* name is only stored pointer
do not free in formfree */
const HTTPPOST_PTRCONTENTS = 8; /* contents is only stored pointer
enum HTTPPOST_PTRCONTENTS = 8; /* contents is only stored pointer
do not free in formfree */
const HTTPPOST_BUFFER = 16; /* upload file from buffer */
const HTTPPOST_PTRBUFFER = 32; /* upload file from pointer contents */
const HTTPPOST_CALLBACK = 64; /* upload file contents by using the
enum HTTPPOST_BUFFER = 16; /* upload file from buffer */
enum HTTPPOST_PTRBUFFER = 32; /* upload file from pointer contents */
enum HTTPPOST_CALLBACK = 64; /* upload file contents by using the
regular read callback to get the data
and pass the given pointer as custom
pointer */
Expand All @@ -152,17 +152,17 @@ alias int function(void *clientp, double dltotal, double dlnow, double ultotal,
time for those who feel adventurous. The practical minimum is about
400 bytes since libcurl uses a buffer of this size as a scratch area
(unrelated to network send operations). */
const CURL_MAX_WRITE_SIZE = 16384;
enum CURL_MAX_WRITE_SIZE = 16384;

/* The only reason to have a max limit for this is to avoid the risk of a bad
server feeding libcurl with a never-ending header that will cause reallocs
infinitely */
const CURL_MAX_HTTP_HEADER = (100*1024);
enum CURL_MAX_HTTP_HEADER = (100*1024);


/* This is a magic return code for the write callback that, when returned,
will signal libcurl to pause receiving on the current transfer. */
const CURL_WRITEFUNC_PAUSE = 0x10000001;
enum CURL_WRITEFUNC_PAUSE = 0x10000001;
alias size_t function(char *buffer, size_t size, size_t nitems, void *outstream)curl_write_callback;

/* enumeration of file types */
Expand Down Expand Up @@ -525,7 +525,7 @@ enum CurlSshAuth {
keyboard = 8, /* keyboard interactive */
default_ = -1 // CURLSSH_AUTH_ANY;
}
const CURL_ERROR_SIZE = 256;
enum CURL_ERROR_SIZE = 256;
/* points to a zero-terminated string encoded with base64
if len is zero, otherwise to the "raw" data */
enum CurlKHType
Expand Down Expand Up @@ -652,11 +652,11 @@ enum CurlProto {

/* long may be 32 or 64 bits, but we should never depend on anything else
but 32 */
const CURLOPTTYPE_LONG = 0;
const CURLOPTTYPE_OBJECTPOINT = 10000;
const CURLOPTTYPE_FUNCTIONPOINT = 20000;
enum CURLOPTTYPE_LONG = 0;
enum CURLOPTTYPE_OBJECTPOINT = 10000;
enum CURLOPTTYPE_FUNCTIONPOINT = 20000;

const CURLOPTTYPE_OFF_T = 30000;
enum CURLOPTTYPE_OFF_T = 30000;
/* name is uppercase CURLOPT_<name>,
type is one of the defined CURLOPTTYPE_<type>
number is unique identifier */
Expand Down Expand Up @@ -1194,7 +1194,7 @@ enum CurlOption {
lastentry
}
alias int CURLoption;
const CURLOPT_SERVER_RESPONSE_TIMEOUT = CurlOption.ftp_response_timeout;
enum CURLOPT_SERVER_RESPONSE_TIMEOUT = CurlOption.ftp_response_timeout;

/* Below here follows defines for the CURLOPT_IPRESOLVE option. If a host
name resolves addresses using more than one IP protocol version, this
Expand All @@ -1206,10 +1206,10 @@ enum CurlIpResolve {
}

/* three convenient "aliases" that follow the name scheme better */
const CURLOPT_WRITEDATA = CurlOption.file;
const CURLOPT_READDATA = CurlOption.infile;
const CURLOPT_HEADERDATA = CurlOption.writeheader;
const CURLOPT_RTSPHEADER = CurlOption.httpheader;
enum CURLOPT_WRITEDATA = CurlOption.file;
enum CURLOPT_READDATA = CurlOption.infile;
enum CURLOPT_HEADERDATA = CurlOption.writeheader;
enum CURLOPT_RTSPHEADER = CurlOption.httpheader;

/* These enums are for use with the CURLOPT_HTTP_VERSION option. */
enum CurlHttpVersion {
Expand Down Expand Up @@ -1543,13 +1543,13 @@ struct curl_certinfo

} // extern (C) end

const CURLINFO_STRING = 0x100000;
const CURLINFO_LONG = 0x200000;
const CURLINFO_DOUBLE = 0x300000;
const CURLINFO_SLIST = 0x400000;
const CURLINFO_MASK = 0x0fffff;
enum CURLINFO_STRING = 0x100000;
enum CURLINFO_LONG = 0x200000;
enum CURLINFO_DOUBLE = 0x300000;
enum CURLINFO_SLIST = 0x400000;
enum CURLINFO_MASK = 0x0fffff;

const CURLINFO_TYPEMASK = 0xf00000;
enum CURLINFO_TYPEMASK = 0xf00000;

enum CurlInfo {
none,
Expand Down Expand Up @@ -1602,7 +1602,7 @@ alias int CURLINFO;

/* CURLINFO_RESPONSE_CODE is the new name for the option previously known as
CURLINFO_HTTP_CODE */
const CURLINFO_HTTP_CODE = CurlInfo.response_code;
enum CURLINFO_HTTP_CODE = CurlInfo.response_code;


enum CurlClosePolicy {
Expand Down Expand Up @@ -1707,7 +1707,7 @@ alias int CURLversion;
meant to be a built-in version number for what kind of struct the caller
expects. If the struct ever changes, we redefine the NOW to another enum
from above. */
const CURLVERSION_NOW = CurlVer.fourth;
enum CURLVERSION_NOW = CurlVer.fourth;

extern (C) struct _N28
{
Expand Down Expand Up @@ -1951,7 +1951,7 @@ alias int CURLMcode;
/* just to make code nicer when using curl_multi_socket() you can now check
for CURLM_CALL_MULTI_SOCKET too in the same style it works for
curl_multi_perform() and CURLM_CALL_MULTI_PERFORM */
const CURLM_CALL_MULTI_SOCKET = CurlM.call_multi_perform;
enum CURLM_CALL_MULTI_SOCKET = CurlM.call_multi_perform;

enum CurlMsg
{
Expand Down

0 comments on commit a42a954

Please sign in to comment.