from collections import OrderedDict

from rpython.rlib import rfloat
from rpython.rlib.unroll import unrolling_iterable
from rpython.rlib.objectmodel import specialize
from rpython.rlib.rarithmetic import intmask

E_ERROR = 1
E_RECOVERABLE_ERROR = 4096
E_WARNING = 2
E_PARSE = 4
E_NOTICE = 8
E_STRICT = 2048
E_DEPRECATED = 8192
E_CORE_ERROR = 16
E_CORE_WARNING = 32
E_COMPILE_ERROR = 64
E_COMPILE_WARNING = 128
E_USER_ERROR = 256
E_USER_WARNING = 512
E_USER_NOTICE = 1024
E_USER_DEPRECATED = 16384
E_HIPPY_WARN = 30768

E_ALL = (E_ERROR | E_RECOVERABLE_ERROR | E_WARNING | E_PARSE | E_NOTICE |
         E_STRICT | E_DEPRECATED | E_CORE_ERROR | E_CORE_WARNING |
         E_COMPILE_ERROR | E_COMPILE_WARNING | E_USER_ERROR | E_USER_WARNING |
         E_USER_NOTICE | E_USER_DEPRECATED)

def maybe_float(x):
    if intmask(x) == x:
        return x
    else:
        return float(x)

CONSTS = OrderedDict(
    Core=OrderedDict(
        E_ERROR=E_ERROR,
        E_RECOVERABLE_ERROR=E_RECOVERABLE_ERROR,
        E_WARNING=E_WARNING,
        E_PARSE=E_PARSE,
        E_NOTICE=E_NOTICE,
        E_STRICT=E_STRICT,
        E_DEPRECATED=E_DEPRECATED,
        E_CORE_ERROR=E_CORE_ERROR,
        E_CORE_WARNING=E_CORE_WARNING,
        E_COMPILE_ERROR=E_COMPILE_ERROR,
        E_COMPILE_WARNING=E_COMPILE_WARNING,
        E_HIPPY_WARN=E_HIPPY_WARN,
        E_USER_ERROR=E_USER_ERROR,
        E_USER_WARNING=E_USER_WARNING,
        E_USER_NOTICE=E_USER_NOTICE,
        E_USER_DEPRECATED=E_USER_DEPRECATED,
        E_ALL=E_ALL,
        DEBUG_BACKTRACE_PROVIDE_OBJECT=1,
        DEBUG_BACKTRACE_IGNORE_ARGS=2,
        #TRUE=1,       -- special-cased: any cAsE mIxInG allowed
        #FALSE=0,      -- special-cased: any cAsE mIxInG allowed
        #NULL=None,    -- special-cased: any cAsE mIxInG allowed
        ZEND_THREAD_SAFE='',
        ZEND_DEBUG_BUILD='',
        PHP_VERSION='5.4.21',
        PHP_MAJOR_VERSION=5,
        PHP_MINOR_VERSION=4,
        PHP_RELEASE_VERSION=21,
        PHP_EXTRA_VERSION='',
        PHP_VERSION_ID=50409,
        PHP_ZTS=0,
        PHP_DEBUG=0,
        PHP_OS='Linux',
        PHP_SAPI='cli',
        DEFAULT_INCLUDE_PATH='.:/usr/share/pear:/usr/share/php',
        PEAR_INSTALL_DIR='/usr/share/pear',
        PEAR_EXTENSION_DIR='/usr/lib64/php/modules',
        PHP_EXTENSION_DIR='/usr/lib64/php/modules',
        PHP_PREFIX='/usr',
        PHP_BINDIR='/usr/bin',
        PHP_MANDIR='/usr/share/man',
        PHP_LIBDIR='/usr/lib64/php',
        PHP_DATADIR='/usr/share',
        PHP_SYSCONFDIR='/etc',
        PHP_LOCALSTATEDIR='/var',
        PHP_CONFIG_FILE_PATH='/etc',
        PHP_CONFIG_FILE_SCAN_DIR='/etc/php.d',
        PHP_SHLIB_SUFFIX='so',
        PHP_EOL='\n',
        PHP_MAXPATHLEN=4096,
        #PHP_INT_MAX=9223372036854775807,  -- special-cased
        #PHP_INT_SIZE=8,                   -- special-cased
        PHP_BINARY='/usr/bin/php',
        PHP_OUTPUT_HANDLER_START=1,
        PHP_OUTPUT_HANDLER_WRITE=0,
        PHP_OUTPUT_HANDLER_FLUSH=4,
        PHP_OUTPUT_HANDLER_CLEAN=2,
        PHP_OUTPUT_HANDLER_FINAL=8,
        PHP_OUTPUT_HANDLER_CONT=0,
        PHP_OUTPUT_HANDLER_END=8,
        PHP_OUTPUT_HANDLER_CLEANABLE=16,
        PHP_OUTPUT_HANDLER_FLUSHABLE=32,
        PHP_OUTPUT_HANDLER_REMOVABLE=64,
        PHP_OUTPUT_HANDLER_STDFLAGS=112,
        PHP_OUTPUT_HANDLER_STARTED=4096,
        PHP_OUTPUT_HANDLER_DISABLED=8192,
        UPLOAD_ERR_OK=0,
        UPLOAD_ERR_INI_SIZE=1,
        UPLOAD_ERR_FORM_SIZE=2,
        UPLOAD_ERR_PARTIAL=3,
        UPLOAD_ERR_NO_FILE=4,
        UPLOAD_ERR_NO_TMP_DIR=6,
        UPLOAD_ERR_CANT_WRITE=7,
        UPLOAD_ERR_EXTENSION=8,
        STDIN='Resource id #1',
        STDOUT='Resource id #2',
        STDERR='Resource id #3'),
    date=OrderedDict(
        DATE_ATOM='Y-m-d\TH:i:sP',
        DATE_COOKIE='l, d-M-y H:i:s T',
        DATE_ISO8601='Y-m-d\TH:i:sO',
        DATE_RFC822='D, d M y H:i:s O',
        DATE_RFC850='l, d-M-y H:i:s T',
        DATE_RFC1036='D, d M y H:i:s O',
        DATE_RFC1123='D, d M Y H:i:s O',
        DATE_RFC2822='D, d M Y H:i:s O',
        DATE_RFC3339='Y-m-d\TH:i:sP',
        DATE_RSS='D, d M Y H:i:s O',
        DATE_W3C='Y-m-d\TH:i:sP',
        SUNFUNCS_RET_TIMESTAMP=0,
        SUNFUNCS_RET_STRING=1,
        SUNFUNCS_RET_DOUBLE=2),
    libxml=OrderedDict(
        LIBXML_VERSION=20708,
        LIBXML_DOTTED_VERSION='2.7.8',
        LIBXML_LOADED_VERSION='20708',
        LIBXML_NOENT=2,
        LIBXML_DTDLOAD=4,
        LIBXML_DTDATTR=8,
        LIBXML_DTDVALID=16,
        LIBXML_NOERROR=32,
        LIBXML_NOWARNING=64,
        LIBXML_NOBLANKS=256,
        LIBXML_XINCLUDE=1024,
        LIBXML_NSCLEAN=8192,
        LIBXML_NOCDATA=16384,
        LIBXML_NONET=2048,
        LIBXML_PEDANTIC=128,
        LIBXML_COMPACT=65536,
        LIBXML_NOXMLDECL=2,
        LIBXML_PARSEHUGE=524288,
        LIBXML_NOEMPTYTAG=4,
        LIBXML_HTML_NOIMPLIED=8192,
        LIBXML_HTML_NODEFDTD=4,
        LIBXML_ERR_NONE=0,
        LIBXML_ERR_WARNING=1,
        LIBXML_ERR_ERROR=2,
        LIBXML_ERR_FATAL=3),
    openssl=OrderedDict(
        OPENSSL_VERSION_TEXT='OpenSSL 1.0.0j-fips 10 May 2012',
        OPENSSL_VERSION_NUMBER=268435459,
        X509_PURPOSE_SSL_CLIENT=1,
        X509_PURPOSE_SSL_SERVER=2,
        X509_PURPOSE_NS_SSL_SERVER=3,
        X509_PURPOSE_SMIME_SIGN=4,
        X509_PURPOSE_SMIME_ENCRYPT=5,
        X509_PURPOSE_CRL_SIGN=6,
        X509_PURPOSE_ANY=7,
        OPENSSL_ALGO_SHA1=1,
        OPENSSL_ALGO_MD5=2,
        OPENSSL_ALGO_MD4=3,
        OPENSSL_ALGO_DSS1=5,
        OPENSSL_ALGO_SHA224=6,
        OPENSSL_ALGO_SHA256=7,
        OPENSSL_ALGO_SHA384=8,
        OPENSSL_ALGO_SHA512=9,
        OPENSSL_ALGO_RMD160=10,
        PKCS7_DETACHED=64,
        PKCS7_TEXT=1,
        PKCS7_NOINTERN=16,
        PKCS7_NOVERIFY=32,
        PKCS7_NOCHAIN=8,
        PKCS7_NOCERTS=2,
        PKCS7_NOATTR=256,
        PKCS7_BINARY=128,
        PKCS7_NOSIGS=4,
        OPENSSL_PKCS1_PADDING=1,
        OPENSSL_SSLV23_PADDING=2,
        OPENSSL_NO_PADDING=3,
        OPENSSL_PKCS1_OAEP_PADDING=4,
        OPENSSL_CIPHER_RC2_40=0,
        OPENSSL_CIPHER_RC2_128=1,
        OPENSSL_CIPHER_RC2_64=2,
        OPENSSL_CIPHER_DES=3,
        OPENSSL_CIPHER_3DES=4,
        OPENSSL_CIPHER_AES_128_CBC=5,
        OPENSSL_CIPHER_AES_192_CBC=6,
        OPENSSL_CIPHER_AES_256_CBC=7,
        OPENSSL_KEYTYPE_RSA=0,
        OPENSSL_KEYTYPE_DSA=1,
        OPENSSL_KEYTYPE_DH=2,
        OPENSSL_KEYTYPE_EC=3,
        OPENSSL_RAW_DATA=1,
        OPENSSL_ZERO_PADDING=2,
        OPENSSL_TLSEXT_SERVER_NAME=1),
    pcre=OrderedDict(
        PREG_PATTERN_ORDER=1,
        PREG_SET_ORDER=2,
        PREG_OFFSET_CAPTURE=256,
        PREG_SPLIT_NO_EMPTY=1,
        PREG_SPLIT_DELIM_CAPTURE=2,
        PREG_SPLIT_OFFSET_CAPTURE=4,
        PREG_GREP_INVERT=1,
        PREG_NO_ERROR=0,
        PREG_INTERNAL_ERROR=1,
        PREG_BACKTRACK_LIMIT_ERROR=2,
        PREG_RECURSION_LIMIT_ERROR=3,
        PREG_BAD_UTF8_ERROR=4,
        PREG_BAD_UTF8_OFFSET_ERROR=5,
        PREG_REPLACE_EVAL=1,
        PCRE_VERSION='8.21 2011-12-12'),
    zlib=OrderedDict(
        FORCE_GZIP=31,
        FORCE_DEFLATE=15,
        ZLIB_ENCODING_RAW=-15,
        ZLIB_ENCODING_GZIP=31,
        ZLIB_ENCODING_DEFLATE=15),
    calendar=OrderedDict(
        CAL_GREGORIAN=0,
        CAL_JULIAN=1,
        CAL_JEWISH=2,
        CAL_FRENCH=3,
        CAL_NUM_CALS=4,
        CAL_DOW_DAYNO=0,
        CAL_DOW_SHORT=1,
        CAL_DOW_LONG=2,
        CAL_MONTH_GREGORIAN_SHORT=0,
        CAL_MONTH_GREGORIAN_LONG=1,
        CAL_MONTH_JULIAN_SHORT=2,
        CAL_MONTH_JULIAN_LONG=3,
        CAL_MONTH_JEWISH=4,
        CAL_MONTH_FRENCH=5,
        CAL_EASTER_DEFAULT=0,
        CAL_EASTER_ROMAN=1,
        CAL_EASTER_ALWAYS_GREGORIAN=2,
        CAL_EASTER_ALWAYS_JULIAN=3,
        CAL_JEWISH_ADD_ALAFIM_GERESH=2,
        CAL_JEWISH_ADD_ALAFIM=4,
        CAL_JEWISH_ADD_GERESHAYIM=8),
    hash=OrderedDict(
        HASH_HMAC=1,
        MHASH_CRC32=0,
        MHASH_MD5=1,
        MHASH_SHA1=2,
        MHASH_HAVAL256=3,
        MHASH_RIPEMD160=5,
        MHASH_TIGER=7,
        MHASH_GOST=8,
        MHASH_CRC32B=9,
        MHASH_HAVAL224=10,
        MHASH_HAVAL192=11,
        MHASH_HAVAL160=12,
        MHASH_HAVAL128=13,
        MHASH_TIGER128=14,
        MHASH_TIGER160=15,
        MHASH_MD4=16,
        MHASH_SHA256=17,
        MHASH_ADLER32=18,
        MHASH_SHA224=19,
        MHASH_SHA512=20,
        MHASH_SHA384=21,
        MHASH_WHIRLPOOL=22,
        MHASH_RIPEMD128=23,
        MHASH_RIPEMD256=24,
        MHASH_RIPEMD320=25,
        MHASH_SNEFRU256=27,
        MHASH_MD2=28,
        MHASH_FNV132=29,
        MHASH_FNV1A32=30,
        MHASH_FNV164=31,
        MHASH_FNV1A64=32,
        MHASH_JOAAT=33),
    filter=OrderedDict(
        INPUT_POST=0,
        INPUT_GET=1,
        INPUT_COOKIE=2,
        INPUT_ENV=4,
        INPUT_SERVER=5,
        INPUT_SESSION=6,
        INPUT_REQUEST=99,
        FILTER_FLAG_NONE=0,
        FILTER_REQUIRE_SCALAR=33554432,
        FILTER_REQUIRE_ARRAY=16777216,
        FILTER_FORCE_ARRAY=67108864,
        FILTER_NULL_ON_FAILURE=134217728,
        FILTER_VALIDATE_INT=257,
        FILTER_VALIDATE_BOOLEAN=258,
        FILTER_VALIDATE_FLOAT=259,
        FILTER_VALIDATE_REGEXP=272,
        FILTER_VALIDATE_URL=273,
        FILTER_VALIDATE_EMAIL=274,
        FILTER_VALIDATE_IP=275,
        FILTER_DEFAULT=516,
        FILTER_UNSAFE_RAW=516,
        FILTER_SANITIZE_STRING=513,
        FILTER_SANITIZE_STRIPPED=513,
        FILTER_SANITIZE_ENCODED=514,
        FILTER_SANITIZE_SPECIAL_CHARS=515,
        FILTER_SANITIZE_FULL_SPECIAL_CHARS=515,
        FILTER_SANITIZE_EMAIL=517,
        FILTER_SANITIZE_URL=518,
        FILTER_SANITIZE_NUMBER_INT=519,
        FILTER_SANITIZE_NUMBER_FLOAT=520,
        FILTER_SANITIZE_MAGIC_QUOTES=521,
        FILTER_CALLBACK=1024,
        FILTER_FLAG_ALLOW_OCTAL=1,
        FILTER_FLAG_ALLOW_HEX=2,
        FILTER_FLAG_STRIP_LOW=4,
        FILTER_FLAG_STRIP_HIGH=8,
        FILTER_FLAG_STRIP_BACKTICK=512,
        FILTER_FLAG_ENCODE_LOW=16,
        FILTER_FLAG_ENCODE_HIGH=32,
        FILTER_FLAG_ENCODE_AMP=64,
        FILTER_FLAG_NO_ENCODE_QUOTES=128,
        FILTER_FLAG_EMPTY_STRING_NULL=256,
        FILTER_FLAG_ALLOW_FRACTION=4096,
        FILTER_FLAG_ALLOW_THOUSAND=8192,
        FILTER_FLAG_ALLOW_SCIENTIFIC=16384,
        FILTER_FLAG_SCHEME_REQUIRED=65536,
        FILTER_FLAG_HOST_REQUIRED=131072,
        FILTER_FLAG_PATH_REQUIRED=262144,
        FILTER_FLAG_QUERY_REQUIRED=524288,
        FILTER_FLAG_IPV4=1048576,
        FILTER_FLAG_IPV6=2097152,
        FILTER_FLAG_NO_RES_RANGE=4194304,
        FILTER_FLAG_NO_PRIV_RANGE=8388608),
    ftp=OrderedDict(
        FTP_ASCII=1,
        FTP_TEXT=1,
        FTP_BINARY=2,
        FTP_IMAGE=2,
        FTP_AUTORESUME=-1,
        FTP_TIMEOUT_SEC=0,
        FTP_AUTOSEEK=1,
        FTP_FAILED=0,
        FTP_FINISHED=1,
        FTP_MOREDATA=2),
    gmp=OrderedDict(
        GMP_ROUND_ZERO=0,
        GMP_ROUND_PLUSINF=1,
        GMP_ROUND_MINUSINF=2,
        GMP_VERSION='5.0.2'),
    iconv=OrderedDict(
        ICONV_IMPL='glibc',
        ICONV_VERSION='2.15',
        ICONV_MIME_DECODE_STRICT=1,
        ICONV_MIME_DECODE_CONTINUE_ON_ERROR=2),
    pcntl=OrderedDict(
        WNOHANG=1,
        WUNTRACED=2,
        SIG_IGN=1,
        SIG_DFL=0,
        SIG_ERR=-1,
        SIGHUP=1,
        SIGINT=2,
        SIGQUIT=3,
        SIGILL=4,
        SIGTRAP=5,
        SIGABRT=6,
        SIGIOT=6,
        SIGBUS=7,
        SIGFPE=8,
        SIGKILL=9,
        SIGUSR1=10,
        SIGSEGV=11,
        SIGUSR2=12,
        SIGPIPE=13,
        SIGALRM=14,
        SIGTERM=15,
        SIGSTKFLT=16,
        SIGCLD=17,
        SIGCHLD=17,
        SIGCONT=18,
        SIGSTOP=19,
        SIGTSTP=20,
        SIGTTIN=21,
        SIGTTOU=22,
        SIGURG=23,
        SIGXCPU=24,
        SIGXFSZ=25,
        SIGVTALRM=26,
        SIGPROF=27,
        SIGWINCH=28,
        SIGPOLL=29,
        SIGIO=29,
        SIGPWR=30,
        SIGSYS=31,
        SIGBABY=31,
        PRIO_PGRP=1,
        PRIO_USER=2,
        PRIO_PROCESS=0,
        SIG_BLOCK=0,
        SIG_UNBLOCK=1,
        SIG_SETMASK=2,
        SI_USER=0,
        SI_KERNEL=128,
        SI_QUEUE=-1,
        SI_TIMER=-2,
        SI_MESGQ=-3,
        SI_ASYNCIO=-4,
        SI_SIGIO=-5,
        SI_TKILL=-6,
        CLD_EXITED=1,
        CLD_KILLED=2,
        CLD_DUMPED=3,
        CLD_TRAPPED=4,
        CLD_STOPPED=5,
        CLD_CONTINUED=6,
        TRAP_BRKPT=1,
        TRAP_TRACE=2,
        POLL_IN=1,
        POLL_OUT=2,
        POLL_MSG=3,
        POLL_ERR=4,
        POLL_PRI=5,
        POLL_HUP=6,
        ILL_ILLOPC=1,
        ILL_ILLOPN=2,
        ILL_ILLADR=3,
        ILL_ILLTRP=4,
        ILL_PRVOPC=5,
        ILL_PRVREG=6,
        ILL_COPROC=7,
        ILL_BADSTK=8,
        FPE_INTDIV=1,
        FPE_INTOVF=2,
        FPE_FLTDIV=3,
        FPE_FLTOVF=4,
        FPE_FLTUND=7,
        FPE_FLTRES=6,
        FPE_FLTINV=7,
        FPE_FLTSUB=8,
        SEGV_MAPERR=1,
        SEGV_ACCERR=2,
        BUS_ADRALN=1,
        BUS_ADRERR=2,
        BUS_OBJERR=3,
        PCNTL_EINTR=4,
        PCNTL_ECHILD=10,
        PCNTL_EINVAL=22,
        PCNTL_EAGAIN=11,
        PCNTL_ESRCH=3,
        PCNTL_EACCES=13,
        PCNTL_EPERM=1,
        PCNTL_ENOMEM=12,
        PCNTL_E2BIG=7,
        PCNTL_EFAULT=14,
        PCNTL_EIO=5,
        PCNTL_EISDIR=21,
        PCNTL_ELIBBAD=80,
        PCNTL_ELOOP=40,
        PCNTL_EMFILE=24,
        PCNTL_ENAMETOOLONG=36,
        PCNTL_ENFILE=23,
        PCNTL_ENOENT=2,
        PCNTL_ENOEXEC=8,
        PCNTL_ENOTDIR=20,
        PCNTL_ETXTBSY=26),
    readline=OrderedDict(
        READLINE_LIB='libedit'),
    session=OrderedDict(
        PHP_SESSION_DISABLED=0,
        PHP_SESSION_NONE=1,
        PHP_SESSION_ACTIVE=2),
    standard=OrderedDict([
        ('CONNECTION_ABORTED', 1),
        ('CONNECTION_NORMAL', 0),
        ('CONNECTION_TIMEOUT', 2),
        ('INI_USER', 1),
        ('INI_PERDIR', 2),
        ('INI_SYSTEM', 4),
        ('INI_ALL', 7),
        ('INI_SCANNER_NORMAL', 0),
        ('INI_SCANNER_RAW', 1),
        ('PHP_URL_SCHEME', 0),
        ('PHP_URL_HOST', 1),
        ('PHP_URL_PORT', 2),
        ('PHP_URL_USER', 3),
        ('PHP_URL_PASS', 4),
        ('PHP_URL_PATH', 5),
        ('PHP_URL_QUERY', 6),
        ('PHP_URL_FRAGMENT', 7),
        ('PHP_QUERY_RFC1738', 1),
        ('PHP_QUERY_RFC3986', 2),
        ('M_E', 2.718281828459),
        ('M_LOG2E', 1.442695040889),
        ('M_LOG10E', 0.43429448190325),
        ('M_LN2', 0.69314718055995),
        ('M_LN10', 2.302585092994),
        ('M_PI', 3.1415926535898),
        ('M_PI_2', 1.5707963267949),
        ('M_PI_4', 0.78539816339745),
        ('M_1_PI', 0.31830988618379),
        ('M_2_PI', 0.63661977236758),
        ('M_SQRTPI', 1.7724538509055),
        ('M_2_SQRTPI', 1.1283791670955),
        ('M_LNPI', 1.1447298858494),
        ('M_EULER', 0.57721566490153),
        ('M_SQRT2', 1.4142135623731),
        ('M_SQRT1_2', 0.70710678118655),
        ('M_SQRT3', 1.7320508075689),
        ('INF', rfloat.INFINITY),
        ('NAN', rfloat.NAN),
        ('PHP_ROUND_HALF_UP', 1),
        ('PHP_ROUND_HALF_DOWN', 2),
        ('PHP_ROUND_HALF_EVEN', 3),
        ('PHP_ROUND_HALF_ODD', 4),
        ('INFO_GENERAL', 1),
        ('INFO_CREDITS', 2),
        ('INFO_CONFIGURATION', 4),
        ('INFO_MODULES', 8),
        ('INFO_ENVIRONMENT', 16),
        ('INFO_VARIABLES', 32),
        ('INFO_LICENSE', 64),
        ('INFO_ALL', -1),
        ('CREDITS_GROUP', 1),
        ('CREDITS_GENERAL', 2),
        ('CREDITS_SAPI', 4),
        ('CREDITS_MODULES', 8),
        ('CREDITS_DOCS', 16),
        ('CREDITS_FULLPAGE', 32),
        ('CREDITS_QA', 64),
        ('CREDITS_ALL', maybe_float(4294967295)),
        ('HTML_SPECIALCHARS', 0),
        ('HTML_ENTITIES', 1),
        ('ENT_COMPAT', 2),
        ('ENT_QUOTES', 3),
        ('ENT_NOQUOTES', 0),
        ('ENT_IGNORE', 4),
        ('ENT_SUBSTITUTE', 8),
        ('ENT_DISALLOWED', 128),
        ('ENT_HTML401', 0),
        ('ENT_XML1', 16),
        ('ENT_XHTML', 32),
        ('ENT_HTML5', 48),
        ('STR_PAD_LEFT', 0),
        ('STR_PAD_RIGHT', 1),
        ('STR_PAD_BOTH', 2),
        ('PATHINFO_DIRNAME', 1),
        ('PATHINFO_BASENAME', 2),
        ('PATHINFO_EXTENSION', 4),
        ('PATHINFO_FILENAME', 8),
        ('CHAR_MAX', 127),
        ('LC_CTYPE', 0),
        ('LC_NUMERIC', 1),
        ('LC_TIME', 2),
        ('LC_COLLATE', 3),
        ('LC_MONETARY', 4),
        ('LC_ALL', 6),
        ('LC_MESSAGES', 5),
        ('SEEK_SET', 0),
        ('SEEK_CUR', 1),
        ('SEEK_END', 2),
        ('LOCK_SH', 1),
        ('LOCK_EX', 2),
        ('LOCK_UN', 3),
        ('LOCK_NB', 4),
        ('STREAM_NOTIFY_CONNECT', 2),
        ('STREAM_NOTIFY_AUTH_REQUIRED', 3),
        ('STREAM_NOTIFY_AUTH_RESULT', 10),
        ('STREAM_NOTIFY_MIME_TYPE_IS', 4),
        ('STREAM_NOTIFY_FILE_SIZE_IS', 5),
        ('STREAM_NOTIFY_REDIRECTED', 6),
        ('STREAM_NOTIFY_PROGRESS', 7),
        ('STREAM_NOTIFY_FAILURE', 9),
        ('STREAM_NOTIFY_COMPLETED', 8),
        ('STREAM_NOTIFY_RESOLVE', 1),
        ('STREAM_NOTIFY_SEVERITY_INFO', 0),
        ('STREAM_NOTIFY_SEVERITY_WARN', 1),
        ('STREAM_NOTIFY_SEVERITY_ERR', 2),
        ('STREAM_FILTER_READ', 1),
        ('STREAM_FILTER_WRITE', 2),
        ('STREAM_FILTER_ALL', 3),
        ('STREAM_CLIENT_PERSISTENT', 1),
        ('STREAM_CLIENT_ASYNC_CONNECT', 2),
        ('STREAM_CLIENT_CONNECT', 4),
        ('STREAM_CRYPTO_METHOD_SSLv2_CLIENT', 0),
        ('STREAM_CRYPTO_METHOD_SSLv3_CLIENT', 1),
        ('STREAM_CRYPTO_METHOD_SSLv23_CLIENT', 2),
        ('STREAM_CRYPTO_METHOD_TLS_CLIENT', 3),
        ('STREAM_CRYPTO_METHOD_SSLv2_SERVER', 4),
        ('STREAM_CRYPTO_METHOD_SSLv3_SERVER', 5),
        ('STREAM_CRYPTO_METHOD_SSLv23_SERVER', 6),
        ('STREAM_CRYPTO_METHOD_TLS_SERVER', 7),
        ('STREAM_SHUT_RD', 0),
        ('STREAM_SHUT_WR', 1),
        ('STREAM_SHUT_RDWR', 2),
        ('STREAM_PF_INET', 2),
        ('STREAM_PF_INET6', 10),
        ('STREAM_PF_UNIX', 1),
        ('STREAM_IPPROTO_IP', 0),
        ('STREAM_IPPROTO_TCP', 6),
        ('STREAM_IPPROTO_UDP', 17),
        ('STREAM_IPPROTO_ICMP', 1),
        ('STREAM_IPPROTO_RAW', 255),
        ('STREAM_SOCK_STREAM', 1),
        ('STREAM_SOCK_DGRAM', 2),
        ('STREAM_SOCK_RAW', 3),
        ('STREAM_SOCK_SEQPACKET', 5),
        ('STREAM_SOCK_RDM', 4),
        ('STREAM_PEEK', 2),
        ('STREAM_OOB', 1),
        ('STREAM_SERVER_BIND', 4),
        ('STREAM_SERVER_LISTEN', 8),
        ('FILE_USE_INCLUDE_PATH', 1),
        ('FILE_IGNORE_NEW_LINES', 2),
        ('FILE_SKIP_EMPTY_LINES', 4),
        ('FILE_APPEND', 8),
        ('FILE_NO_DEFAULT_CONTEXT', 16),
        ('FILE_TEXT', 0),
        ('FILE_BINARY', 0),
        ('FNM_NOESCAPE', 2),
        ('FNM_PATHNAME', 1),
        ('FNM_PERIOD', 4),
        ('FNM_CASEFOLD', 16),
        ('PSFS_PASS_ON', 2),
        ('PSFS_FEED_ME', 1),
        ('PSFS_ERR_FATAL', 0),
        ('PSFS_FLAG_NORMAL', 0),
        ('PSFS_FLAG_FLUSH_INC', 1),
        ('PSFS_FLAG_FLUSH_CLOSE', 2),
        ('ABDAY_1', 131072),
        ('ABDAY_2', 131073),
        ('ABDAY_3', 131074),
        ('ABDAY_4', 131075),
        ('ABDAY_5', 131076),
        ('ABDAY_6', 131077),
        ('ABDAY_7', 131078),
        ('DAY_1', 131079),
        ('DAY_2', 131080),
        ('DAY_3', 131081),
        ('DAY_4', 131082),
        ('DAY_5', 131083),
        ('DAY_6', 131084),
        ('DAY_7', 131085),
        ('ABMON_1', 131086),
        ('ABMON_2', 131087),
        ('ABMON_3', 131088),
        ('ABMON_4', 131089),
        ('ABMON_5', 131090),
        ('ABMON_6', 131091),
        ('ABMON_7', 131092),
        ('ABMON_8', 131093),
        ('ABMON_9', 131094),
        ('ABMON_10', 131095),
        ('ABMON_11', 131096),
        ('ABMON_12', 131097),
        ('MON_1', 131098),
        ('MON_2', 131099),
        ('MON_3', 131100),
        ('MON_4', 131101),
        ('MON_5', 131102),
        ('MON_6', 131103),
        ('MON_7', 131104),
        ('MON_8', 131105),
        ('MON_9', 131106),
        ('MON_10', 131107),
        ('MON_11', 131108),
        ('MON_12', 131109),
        ('AM_STR', 131110),
        ('PM_STR', 131111),
        ('D_T_FMT', 131112),
        ('D_FMT', 131113),
        ('T_FMT', 131114),
        ('T_FMT_AMPM', 131115),
        ('ERA', 131116),
        ('ERA_D_T_FMT', 131120),
        ('ERA_D_FMT', 131118),
        ('ERA_T_FMT', 131121),
        ('ALT_DIGITS', 131119),
        ('CRNCYSTR', 262159),
        ('RADIXCHAR', 65536),
        ('THOUSEP', 65537),
        ('YESEXPR', 327680),
        ('NOEXPR', 327681),
        ('CODESET', 14),
        ('CRYPT_SALT_LENGTH', 123),
        ('CRYPT_STD_DES', 1),
        ('CRYPT_EXT_DES', 1),
        ('CRYPT_MD5', 1),
        ('CRYPT_BLOWFISH', 1),
        ('CRYPT_SHA256', 1),
        ('CRYPT_SHA512', 1),
        ('DIRECTORY_SEPARATOR', '/'),
        ('PATH_SEPARATOR', ':'),
        ('SCANDIR_SORT_ASCENDING', 0),
        ('SCANDIR_SORT_DESCENDING', 1),
        ('SCANDIR_SORT_NONE', 2),
        ('GLOB_BRACE', 1024),
        ('GLOB_MARK', 2),
        ('GLOB_NOSORT', 4),
        ('GLOB_NOCHECK', 16),
        ('GLOB_NOESCAPE', 64),
        ('GLOB_ERR', 1),
        ('GLOB_ONLYDIR', 8192),
        ('GLOB_AVAILABLE_FLAGS', 9303),
        ('LOG_EMERG', 0),
        ('LOG_ALERT', 1),
        ('LOG_CRIT', 2),
        ('LOG_ERR', 3),
        ('LOG_WARNING', 4),
        ('LOG_NOTICE', 5),
        ('LOG_INFO', 6),
        ('LOG_DEBUG', 7),
        ('LOG_KERN', 0),
        ('LOG_USER', 8),
        ('LOG_MAIL', 16),
        ('LOG_DAEMON', 24),
        ('LOG_AUTH', 32),
        ('LOG_SYSLOG', 40),
        ('LOG_LPR', 48),
        ('LOG_NEWS', 56),
        ('LOG_UUCP', 64),
        ('LOG_CRON', 72),
        ('LOG_AUTHPRIV', 80),
        ('LOG_LOCAL0', 128),
        ('LOG_LOCAL1', 136),
        ('LOG_LOCAL2', 144),
        ('LOG_LOCAL3', 152),
        ('LOG_LOCAL4', 160),
        ('LOG_LOCAL5', 168),
        ('LOG_LOCAL6', 176),
        ('LOG_LOCAL7', 184),
        ('LOG_PID', 1),
        ('LOG_CONS', 2),
        ('LOG_ODELAY', 4),
        ('LOG_NDELAY', 8),
        ('LOG_NOWAIT', 16),
        ('LOG_PERROR', 32),
        ('EXTR_OVERWRITE', 0),
        ('EXTR_SKIP', 1),
        ('EXTR_PREFIX_SAME', 2),
        ('EXTR_PREFIX_ALL', 3),
        ('EXTR_PREFIX_INVALID', 4),
        ('EXTR_PREFIX_IF_EXISTS', 5),
        ('EXTR_IF_EXISTS', 6),
        ('EXTR_REFS', 256),
        ('SORT_ASC', 4),
        ('SORT_DESC', 3),
        ('SORT_REGULAR', 0),
        ('SORT_NUMERIC', 1),
        ('SORT_STRING', 2),
        ('SORT_LOCALE_STRING', 5),
        ('SORT_NATURAL', 6),
        ('SORT_FLAG_CASE', 8),
        ('CASE_LOWER', 0),
        ('CASE_UPPER', 1),
        ('COUNT_NORMAL', 0),
        ('COUNT_RECURSIVE', 1),
        ('ASSERT_ACTIVE', 1),
        ('ASSERT_CALLBACK', 2),
        ('ASSERT_BAIL', 3),
        ('ASSERT_WARNING', 4),
        ('ASSERT_QUIET_EVAL', 5),
        ('STREAM_USE_PATH', 1),
        ('STREAM_IGNORE_URL', 2),
        ('STREAM_REPORT_ERRORS', 8),
        ('STREAM_MUST_SEEK', 16),
        ('STREAM_URL_STAT_LINK', 1),
        ('STREAM_URL_STAT_QUIET', 2),
        ('STREAM_MKDIR_RECURSIVE', 1),
        ('STREAM_IS_URL', 1),
        ('STREAM_OPTION_BLOCKING', 1),
        ('STREAM_OPTION_READ_TIMEOUT', 4),
        ('STREAM_OPTION_READ_BUFFER', 2),
        ('STREAM_OPTION_WRITE_BUFFER', 3),
        ('STREAM_BUFFER_NONE', 0),
        ('STREAM_BUFFER_LINE', 1),
        ('STREAM_BUFFER_FULL', 2),
        ('STREAM_CAST_AS_STREAM', 0),
        ('STREAM_CAST_FOR_SELECT', 3),
        ('STREAM_META_TOUCH', 1),
        ('STREAM_META_OWNER', 3),
        ('STREAM_META_OWNER_NAME', 2),
        ('STREAM_META_GROUP', 5),
        ('STREAM_META_GROUP_NAME', 4),
        ('STREAM_META_ACCESS', 6),
        ('IMAGETYPE_GIF', 1),
        ('IMAGETYPE_JPEG', 2),
        ('IMAGETYPE_PNG', 3),
        ('IMAGETYPE_SWF', 4),
        ('IMAGETYPE_PSD', 5),
        ('IMAGETYPE_BMP', 6),
        ('IMAGETYPE_TIFF_II', 7),
        ('IMAGETYPE_TIFF_MM', 8),
        ('IMAGETYPE_JPC', 9),
        ('IMAGETYPE_JP2', 10),
        ('IMAGETYPE_JPX', 11),
        ('IMAGETYPE_JB2', 12),
        ('IMAGETYPE_SWC', 13),
        ('IMAGETYPE_IFF', 14),
        ('IMAGETYPE_WBMP', 15),
        ('IMAGETYPE_JPEG2000', 9),
        ('IMAGETYPE_XBM', 16),
        ('IMAGETYPE_ICO', 17),
        ('IMAGETYPE_UNKNOWN', 0),
        ('IMAGETYPE_COUNT', 18),
        ('DNS_A', 1),
        ('DNS_NS', 2),
        ('DNS_CNAME', 16),
        ('DNS_SOA', 32),
        ('DNS_PTR', 2048),
        ('DNS_HINFO', 4096),
        ('DNS_MX', 16384),
        ('DNS_TXT', 32768),
        ('DNS_SRV', 33554432),
        ('DNS_NAPTR', 67108864),
        ('DNS_AAAA', 134217728),
        ('DNS_A6', 16777216),
        ('DNS_ANY', 268435456),
        ('DNS_ALL', 251713587)]),
    sockets=OrderedDict(
        AF_UNIX=1,
        AF_INET=2,
        AF_INET6=10,
        SOCK_STREAM=1,
        SOCK_DGRAM=2,
        SOCK_RAW=3,
        SOCK_SEQPACKET=5,
        SOCK_RDM=4,
        MSG_OOB=1,
        MSG_WAITALL=256,
        MSG_DONTWAIT=64,
        MSG_PEEK=2,
        MSG_DONTROUTE=4,
        MSG_EOR=128,
        MSG_EOF=512,
        SO_DEBUG=1,
        SO_REUSEADDR=2,
        SO_KEEPALIVE=9,
        SO_DONTROUTE=5,
        SO_LINGER=13,
        SO_BROADCAST=6,
        SO_OOBINLINE=10,
        SO_SNDBUF=7,
        SO_RCVBUF=8,
        SO_SNDLOWAT=19,
        SO_RCVLOWAT=18,
        SO_SNDTIMEO=21,
        SO_RCVTIMEO=20,
        SO_TYPE=3,
        SO_ERROR=4,
        SOL_SOCKET=1,
        SOMAXCONN=128,
        TCP_NODELAY=1,
        PHP_NORMAL_READ=1,
        PHP_BINARY_READ=2,
        MCAST_JOIN_GROUP=42,
        MCAST_LEAVE_GROUP=45,
        MCAST_BLOCK_SOURCE=43,
        MCAST_UNBLOCK_SOURCE=44,
        MCAST_JOIN_SOURCE_GROUP=46,
        MCAST_LEAVE_SOURCE_GROUP=47,
        IP_MULTICAST_IF=32,
        IP_MULTICAST_TTL=33,
        IP_MULTICAST_LOOP=34,
        IPV6_MULTICAST_IF=17,
        IPV6_MULTICAST_HOPS=18,
        IPV6_MULTICAST_LOOP=19,
        SOCKET_EPERM=1,
        SOCKET_ENOENT=2,
        SOCKET_EINTR=4,
        SOCKET_EIO=5,
        SOCKET_ENXIO=6,
        SOCKET_E2BIG=7,
        SOCKET_EBADF=9,
        SOCKET_EAGAIN=11,
        SOCKET_ENOMEM=12,
        SOCKET_EACCES=13,
        SOCKET_EFAULT=14,
        SOCKET_ENOTBLK=15,
        SOCKET_EBUSY=16,
        SOCKET_EEXIST=17,
        SOCKET_EXDEV=18,
        SOCKET_ENODEV=19,
        SOCKET_ENOTDIR=20,
        SOCKET_EISDIR=21,
        SOCKET_EINVAL=22,
        SOCKET_ENFILE=23,
        SOCKET_EMFILE=24,
        SOCKET_ENOTTY=25,
        SOCKET_ENOSPC=28,
        SOCKET_ESPIPE=29,
        SOCKET_EROFS=30,
        SOCKET_EMLINK=31,
        SOCKET_EPIPE=32,
        SOCKET_ENAMETOOLONG=36,
        SOCKET_ENOLCK=37,
        SOCKET_ENOSYS=38,
        SOCKET_ENOTEMPTY=39,
        SOCKET_ELOOP=40,
        SOCKET_EWOULDBLOCK=11,
        SOCKET_ENOMSG=42,
        SOCKET_EIDRM=43,
        SOCKET_ECHRNG=44,
        SOCKET_EL2NSYNC=45,
        SOCKET_EL3HLT=46,
        SOCKET_EL3RST=47,
        SOCKET_ELNRNG=48,
        SOCKET_EUNATCH=49,
        SOCKET_ENOCSI=50,
        SOCKET_EL2HLT=51,
        SOCKET_EBADE=52,
        SOCKET_EBADR=53,
        SOCKET_EXFULL=54,
        SOCKET_ENOANO=55,
        SOCKET_EBADRQC=56,
        SOCKET_EBADSLT=57,
        SOCKET_ENOSTR=60,
        SOCKET_ENODATA=61,
        SOCKET_ETIME=62,
        SOCKET_ENOSR=63,
        SOCKET_ENONET=64,
        SOCKET_EREMOTE=66,
        SOCKET_ENOLINK=67,
        SOCKET_EADV=68,
        SOCKET_ESRMNT=69,
        SOCKET_ECOMM=70,
        SOCKET_EPROTO=71,
        SOCKET_EMULTIHOP=72,
        SOCKET_EBADMSG=74,
        SOCKET_ENOTUNIQ=76,
        SOCKET_EBADFD=77,
        SOCKET_EREMCHG=78,
        SOCKET_ERESTART=85,
        SOCKET_ESTRPIPE=86,
        SOCKET_EUSERS=87,
        SOCKET_ENOTSOCK=88,
        SOCKET_EDESTADDRREQ=89,
        SOCKET_EMSGSIZE=90,
        SOCKET_EPROTOTYPE=91,
        SOCKET_ENOPROTOOPT=92,
        SOCKET_EPROTONOSUPPORT=93,
        SOCKET_ESOCKTNOSUPPORT=94,
        SOCKET_EOPNOTSUPP=95,
        SOCKET_EPFNOSUPPORT=96,
        SOCKET_EAFNOSUPPORT=97,
        SOCKET_EADDRINUSE=98,
        SOCKET_EADDRNOTAVAIL=99,
        SOCKET_ENETDOWN=100,
        SOCKET_ENETUNREACH=101,
        SOCKET_ENETRESET=102,
        SOCKET_ECONNABORTED=103,
        SOCKET_ECONNRESET=104,
        SOCKET_ENOBUFS=105,
        SOCKET_EISCONN=106,
        SOCKET_ENOTCONN=107,
        SOCKET_ESHUTDOWN=108,
        SOCKET_ETOOMANYREFS=109,
        SOCKET_ETIMEDOUT=110,
        SOCKET_ECONNREFUSED=111,
        SOCKET_EHOSTDOWN=112,
        SOCKET_EHOSTUNREACH=113,
        SOCKET_EALREADY=114,
        SOCKET_EINPROGRESS=115,
        SOCKET_EISNAM=120,
        SOCKET_EREMOTEIO=121,
        SOCKET_EDQUOT=122,
        SOCKET_ENOMEDIUM=123,
        SOCKET_EMEDIUMTYPE=124,
        IPPROTO_IP=0,
        IPPROTO_IPV6=41,
        SOL_TCP=6,
        SOL_UDP=17),
    exif=OrderedDict(
        EXIF_USE_MBSTRING=0),
    tokenizer=OrderedDict(
        T_REQUIRE_ONCE=258,
        T_REQUIRE=259,
        T_EVAL=260,
        T_INCLUDE_ONCE=261,
        T_INCLUDE=262,
        T_LOGICAL_OR=263,
        T_LOGICAL_XOR=264,
        T_LOGICAL_AND=265,
        T_PRINT=266,
        T_SR_EQUAL=267,
        T_SL_EQUAL=268,
        T_XOR_EQUAL=269,
        T_OR_EQUAL=270,
        T_AND_EQUAL=271,
        T_MOD_EQUAL=272,
        T_CONCAT_EQUAL=273,
        T_DIV_EQUAL=274,
        T_MUL_EQUAL=275,
        T_MINUS_EQUAL=276,
        T_PLUS_EQUAL=277,
        T_BOOLEAN_OR=278,
        T_BOOLEAN_AND=279,
        T_IS_NOT_IDENTICAL=280,
        T_IS_IDENTICAL=281,
        T_IS_NOT_EQUAL=282,
        T_IS_EQUAL=283,
        T_IS_GREATER_OR_EQUAL=284,
        T_IS_SMALLER_OR_EQUAL=285,
        T_SR=286,
        T_SL=287,
        T_INSTANCEOF=288,
        T_UNSET_CAST=289,
        T_BOOL_CAST=290,
        T_OBJECT_CAST=291,
        T_ARRAY_CAST=292,
        T_STRING_CAST=293,
        T_DOUBLE_CAST=294,
        T_INT_CAST=295,
        T_DEC=296,
        T_INC=297,
        T_CLONE=298,
        T_NEW=299,
        T_EXIT=300,
        T_IF=301,
        T_ELSEIF=302,
        T_ELSE=303,
        T_ENDIF=304,
        T_LNUMBER=305,
        T_DNUMBER=306,
        T_STRING=307,
        T_STRING_VARNAME=308,
        T_VARIABLE=309,
        T_NUM_STRING=310,
        T_INLINE_HTML=311,
        T_CHARACTER=312,
        T_BAD_CHARACTER=313,
        T_ENCAPSED_AND_WHITESPACE=314,
        T_CONSTANT_ENCAPSED_STRING=315,
        T_ECHO=316,
        T_DO=317,
        T_WHILE=318,
        T_ENDWHILE=319,
        T_FOR=320,
        T_ENDFOR=321,
        T_FOREACH=322,
        T_ENDFOREACH=323,
        T_DECLARE=324,
        T_ENDDECLARE=325,
        T_AS=326,
        T_SWITCH=327,
        T_ENDSWITCH=328,
        T_CASE=329,
        T_DEFAULT=330,
        T_BREAK=331,
        T_CONTINUE=332,
        T_GOTO=333,
        T_FUNCTION=334,
        T_CONST=335,
        T_RETURN=336,
        T_TRY=337,
        T_CATCH=338,
        T_THROW=339,
        T_USE=340,
        T_INSTEADOF=341,
        T_GLOBAL=342,
        T_PUBLIC=343,
        T_PROTECTED=344,
        T_PRIVATE=345,
        T_FINAL=346,
        T_ABSTRACT=347,
        T_STATIC=348,
        T_VAR=349,
        T_UNSET=350,
        T_ISSET=351,
        T_EMPTY=352,
        T_HALT_COMPILER=353,
        T_CLASS=354,
        T_TRAIT=355,
        T_INTERFACE=356,
        T_EXTENDS=357,
        T_IMPLEMENTS=358,
        T_OBJECT_OPERATOR=359,
        T_DOUBLE_ARROW=360,
        T_LIST=361,
        T_ARRAY=362,
        T_CALLABLE=363,
        T_CLASS_C=364,
        T_TRAIT_C=365,
        T_METHOD_C=366,
        T_FUNC_C=367,
        T_LINE=368,
        T_FILE=369,
        T_COMMENT=370,
        T_DOC_COMMENT=371,
        T_OPEN_TAG=372,
        T_OPEN_TAG_WITH_ECHO=373,
        T_CLOSE_TAG=374,
        T_WHITESPACE=375,
        T_START_HEREDOC=376,
        T_END_HEREDOC=377,
        T_DOLLAR_OPEN_CURLY_BRACES=378,
        T_CURLY_OPEN=379,
        T_PAAMAYIM_NEKUDOTAYIM=380,
        T_NAMESPACE=381,
        T_NS_C=382,
        T_DIR=383,
        T_NS_SEPARATOR=384,
        T_DOUBLE_COLON=380),
    xml=OrderedDict(
        XML_ERROR_NONE=0,
        XML_ERROR_NO_MEMORY=1,
        XML_ERROR_SYNTAX=2,
        XML_ERROR_NO_ELEMENTS=3,
        XML_ERROR_INVALID_TOKEN=4,
        XML_ERROR_UNCLOSED_TOKEN=5,
        XML_ERROR_PARTIAL_CHAR=6,
        XML_ERROR_TAG_MISMATCH=7,
        XML_ERROR_DUPLICATE_ATTRIBUTE=8,
        XML_ERROR_JUNK_AFTER_DOC_ELEMENT=9,
        XML_ERROR_PARAM_ENTITY_REF=10,
        XML_ERROR_UNDEFINED_ENTITY=11,
        XML_ERROR_RECURSIVE_ENTITY_REF=12,
        XML_ERROR_ASYNC_ENTITY=13,
        XML_ERROR_BAD_CHAR_REF=14,
        XML_ERROR_BINARY_ENTITY_REF=15,
        XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF=16,
        XML_ERROR_MISPLACED_XML_PI=17,
        XML_ERROR_UNKNOWN_ENCODING=18,
        XML_ERROR_INCORRECT_ENCODING=19,
        XML_ERROR_UNCLOSED_CDATA_SECTION=20,
        XML_ERROR_EXTERNAL_ENTITY_HANDLING=21,
        XML_OPTION_CASE_FOLDING=1,
        XML_OPTION_TARGET_ENCODING=2,
        XML_OPTION_SKIP_TAGSTART=3,
        XML_OPTION_SKIP_WHITE=4,
        XML_SAX_IMPL='libxml'),
    curl=OrderedDict([
        ('CURLOPT_IPRESOLVE', 113),
        ('CURL_IPRESOLVE_WHATEVER', 0),
        ('CURL_IPRESOLVE_V4', 1),
        ('CURL_IPRESOLVE_V6', 2),
        ('CURLOPT_DNS_USE_GLOBAL_CACHE', 91),
        ('CURLOPT_DNS_CACHE_TIMEOUT', 92),
        ('CURLOPT_PORT', 3),
        ('CURLOPT_FILE', 10001),
        ('CURLOPT_READDATA', 10009),
        ('CURLOPT_INFILE', 10009),
        ('CURLOPT_INFILESIZE', 14),
        ('CURLOPT_URL', 10002),
        ('CURLOPT_PROXY', 10004),
        ('CURLOPT_VERBOSE', 41),
        ('CURLOPT_HEADER', 42),
        ('CURLOPT_HTTPHEADER', 10023),
        ('CURLOPT_NOPROGRESS', 43),
        ('CURLOPT_PROGRESSFUNCTION', 20056),
        ('CURLOPT_NOBODY', 44),
        ('CURLOPT_FAILONERROR', 45),
        ('CURLOPT_UPLOAD', 46),
        ('CURLOPT_POST', 47),
        ('CURLOPT_FTPLISTONLY', 48),
        ('CURLOPT_FTPAPPEND', 50),
        ('CURLOPT_NETRC', 51),
        ('CURLOPT_FOLLOWLOCATION', 52),
        ('CURLOPT_PUT', 54),
        ('CURLOPT_USERPWD', 10005),
        ('CURLOPT_PROXYUSERPWD', 10006),
        ('CURLOPT_RANGE', 10007),
        ('CURLOPT_TIMEOUT', 13),
        ('CURLOPT_TIMEOUT_MS', 155),
        ('CURLOPT_POSTFIELDS', 10015),
        ('CURLOPT_REFERER', 10016),
        ('CURLOPT_USERAGENT', 10018),
        ('CURLOPT_FTPPORT', 10017),
        ('CURLOPT_FTP_USE_EPSV', 85),
        ('CURLOPT_LOW_SPEED_LIMIT', 19),
        ('CURLOPT_LOW_SPEED_TIME', 20),
        ('CURLOPT_RESUME_FROM', 21),
        ('CURLOPT_COOKIE', 10022),
        ('CURLOPT_COOKIESESSION', 96),
        ('CURLOPT_AUTOREFERER', 58),
        ('CURLOPT_SSLCERT', 10025),
        ('CURLOPT_SSLCERTPASSWD', 10026),
        ('CURLOPT_WRITEHEADER', 10029),
        ('CURLOPT_SSL_VERIFYHOST', 81),
        ('CURLOPT_COOKIEFILE', 10031),
        ('CURLOPT_SSLVERSION', 32),
        ('CURLOPT_TIMECONDITION', 33),
        ('CURLOPT_TIMEVALUE', 34),
        ('CURLOPT_CUSTOMREQUEST', 10036),
        ('CURLOPT_STDERR', 10037),
        ('CURLOPT_TRANSFERTEXT', 53),
        ('CURLOPT_RETURNTRANSFER', 19913),
        ('CURLOPT_QUOTE', 10028),
        ('CURLOPT_POSTQUOTE', 10039),
        ('CURLOPT_INTERFACE', 10062),
        ('CURLOPT_KRB4LEVEL', 10063),
        ('CURLOPT_HTTPPROXYTUNNEL', 61),
        ('CURLOPT_FILETIME', 69),
        ('CURLOPT_WRITEFUNCTION', 20011),
        ('CURLOPT_READFUNCTION', 20012),
        ('CURLOPT_HEADERFUNCTION', 20079),
        ('CURLOPT_MAXREDIRS', 68),
        ('CURLOPT_MAXCONNECTS', 71),
        ('CURLOPT_CLOSEPOLICY', 72),
        ('CURLOPT_FRESH_CONNECT', 74),
        ('CURLOPT_FORBID_REUSE', 75),
        ('CURLOPT_RANDOM_FILE', 10076),
        ('CURLOPT_EGDSOCKET', 10077),
        ('CURLOPT_CONNECTTIMEOUT', 78),
        ('CURLOPT_CONNECTTIMEOUT_MS', 156),
        ('CURLOPT_SSL_VERIFYPEER', 64),
        ('CURLOPT_CAINFO', 10065),
        ('CURLOPT_CAPATH', 10097),
        ('CURLOPT_COOKIEJAR', 10082),
        ('CURLOPT_SSL_CIPHER_LIST', 10083),
        ('CURLOPT_BINARYTRANSFER', 19914),
        ('CURLOPT_NOSIGNAL', 99),
        ('CURLOPT_PROXYTYPE', 101),
        ('CURLOPT_BUFFERSIZE', 98),
        ('CURLOPT_HTTPGET', 80),
        ('CURLOPT_HTTP_VERSION', 84),
        ('CURLOPT_SSLKEY', 10087),
        ('CURLOPT_SSLKEYTYPE', 10088),
        ('CURLOPT_SSLKEYPASSWD', 10026),
        ('CURLOPT_SSLENGINE', 10089),
        ('CURLOPT_SSLENGINE_DEFAULT', 90),
        ('CURLOPT_SSLCERTTYPE', 10086),
        ('CURLOPT_CRLF', 27),
        ('CURLOPT_ENCODING', 10102),
        ('CURLOPT_PROXYPORT', 59),
        ('CURLOPT_UNRESTRICTED_AUTH', 105),
        ('CURLOPT_FTP_USE_EPRT', 106),
        ('CURLOPT_TCP_NODELAY', 121),
        ('CURLOPT_HTTP200ALIASES', 10104),
        ('CURL_TIMECOND_IFMODSINCE', 1),
        ('CURL_TIMECOND_IFUNMODSINCE', 2),
        ('CURL_TIMECOND_LASTMOD', 3),
        ('CURLOPT_MAX_RECV_SPEED_LARGE', 30146),
        ('CURLOPT_MAX_SEND_SPEED_LARGE', 30145),
        ('CURLOPT_HTTPAUTH', 107),
        ('CURLAUTH_BASIC', 1),
        ('CURLAUTH_DIGEST', 2),
        ('CURLAUTH_GSSNEGOTIATE', 4),
        ('CURLAUTH_NTLM', 8),
        ('CURLAUTH_ANY', -17),
        ('CURLAUTH_ANYSAFE', -18),
        ('CURLOPT_PROXYAUTH', 111),
        ('CURLOPT_FTP_CREATE_MISSING_DIRS', 110),
        ('CURLOPT_PRIVATE', 10103),
        ('CURLCLOSEPOLICY_LEAST_RECENTLY_USED', 2),
        ('CURLCLOSEPOLICY_LEAST_TRAFFIC', 3),
        ('CURLCLOSEPOLICY_SLOWEST', 4),
        ('CURLCLOSEPOLICY_CALLBACK', 5),
        ('CURLCLOSEPOLICY_OLDEST', 1),
        ('CURLINFO_EFFECTIVE_URL', 1048577),
        ('CURLINFO_HTTP_CODE', 2097154),
        ('CURLINFO_HEADER_SIZE', 2097163),
        ('CURLINFO_REQUEST_SIZE', 2097164),
        ('CURLINFO_TOTAL_TIME', 3145731),
        ('CURLINFO_NAMELOOKUP_TIME', 3145732),
        ('CURLINFO_CONNECT_TIME', 3145733),
        ('CURLINFO_PRETRANSFER_TIME', 3145734),
        ('CURLINFO_SIZE_UPLOAD', 3145735),
        ('CURLINFO_SIZE_DOWNLOAD', 3145736),
        ('CURLINFO_SPEED_DOWNLOAD', 3145737),
        ('CURLINFO_SPEED_UPLOAD', 3145738),
        ('CURLINFO_FILETIME', 2097166),
        ('CURLINFO_SSL_VERIFYRESULT', 2097165),
        ('CURLINFO_CONTENT_LENGTH_DOWNLOAD', 3145743),
        ('CURLINFO_CONTENT_LENGTH_UPLOAD', 3145744),
        ('CURLINFO_STARTTRANSFER_TIME', 3145745),
        ('CURLINFO_CONTENT_TYPE', 1048594),
        ('CURLINFO_REDIRECT_TIME', 3145747),
        ('CURLINFO_REDIRECT_COUNT', 2097172),
        ('CURLINFO_HEADER_OUT', 2),
        ('CURLINFO_PRIVATE', 1048597),
        ('CURLINFO_CERTINFO', 4194338),
        ('CURLINFO_REDIRECT_URL', 1048607),
        ('CURLINFO_PRIMARY_IP', 1048608),
        ('CURLINFO_PRIMARY_PORT', 2097192),
        ('CURLINFO_LOCAL_IP', 1048617),
        ('CURLINFO_LOCAL_PORT', 2097194),
        ('CURL_VERSION_IPV6', 1),
        ('CURL_VERSION_KERBEROS4', 2),
        ('CURL_VERSION_SSL', 4),
        ('CURL_VERSION_LIBZ', 8),
        ('CURLVERSION_NOW', 3),
        ('CURLE_OK', 0),
        ('CURLE_UNSUPPORTED_PROTOCOL', 1),
        ('CURLE_FAILED_INIT', 2),
        ('CURLE_URL_MALFORMAT', 3),
        ('CURLE_URL_MALFORMAT_USER', 4),
        ('CURLE_COULDNT_RESOLVE_PROXY', 5),
        ('CURLE_COULDNT_RESOLVE_HOST', 6),
        ('CURLE_COULDNT_CONNECT', 7),
        ('CURLE_FTP_WEIRD_SERVER_REPLY', 8),
        ('CURLE_FTP_ACCESS_DENIED', 9),
        ('CURLE_FTP_USER_PASSWORD_INCORRECT', 10),
        ('CURLE_FTP_WEIRD_PASS_REPLY', 11),
        ('CURLE_FTP_WEIRD_USER_REPLY', 12),
        ('CURLE_FTP_WEIRD_PASV_REPLY', 13),
        ('CURLE_FTP_WEIRD_227_FORMAT', 14),
        ('CURLE_FTP_CANT_GET_HOST', 15),
        ('CURLE_FTP_CANT_RECONNECT', 16),
        ('CURLE_FTP_COULDNT_SET_BINARY', 17),
        ('CURLE_PARTIAL_FILE', 18),
        ('CURLE_FTP_COULDNT_RETR_FILE', 19),
        ('CURLE_FTP_WRITE_ERROR', 20),
        ('CURLE_FTP_QUOTE_ERROR', 21),
        ('CURLE_HTTP_NOT_FOUND', 22),
        ('CURLE_WRITE_ERROR', 23),
        ('CURLE_MALFORMAT_USER', 24),
        ('CURLE_FTP_COULDNT_STOR_FILE', 25),
        ('CURLE_READ_ERROR', 26),
        ('CURLE_OUT_OF_MEMORY', 27),
        ('CURLE_OPERATION_TIMEOUTED', 28),
        ('CURLE_FTP_COULDNT_SET_ASCII', 29),
        ('CURLE_FTP_PORT_FAILED', 30),
        ('CURLE_FTP_COULDNT_USE_REST', 31),
        ('CURLE_FTP_COULDNT_GET_SIZE', 32),
        ('CURLE_HTTP_RANGE_ERROR', 33),
        ('CURLE_HTTP_POST_ERROR', 34),
        ('CURLE_SSL_CONNECT_ERROR', 35),
        ('CURLE_FTP_BAD_DOWNLOAD_RESUME', 36),
        ('CURLE_FILE_COULDNT_READ_FILE', 37),
        ('CURLE_LDAP_CANNOT_BIND', 38),
        ('CURLE_LDAP_SEARCH_FAILED', 39),
        ('CURLE_LIBRARY_NOT_FOUND', 40),
        ('CURLE_FUNCTION_NOT_FOUND', 41),
        ('CURLE_ABORTED_BY_CALLBACK', 42),
        ('CURLE_BAD_FUNCTION_ARGUMENT', 43),
        ('CURLE_BAD_CALLING_ORDER', 44),
        ('CURLE_HTTP_PORT_FAILED', 45),
        ('CURLE_BAD_PASSWORD_ENTERED', 46),
        ('CURLE_TOO_MANY_REDIRECTS', 47),
        ('CURLE_UNKNOWN_TELNET_OPTION', 48),
        ('CURLE_TELNET_OPTION_SYNTAX', 49),
        ('CURLE_OBSOLETE', 50),
        ('CURLE_SSL_PEER_CERTIFICATE', 51),
        ('CURLE_GOT_NOTHING', 52),
        ('CURLE_SSL_ENGINE_NOTFOUND', 53),
        ('CURLE_SSL_ENGINE_SETFAILED', 54),
        ('CURLE_SEND_ERROR', 55),
        ('CURLE_RECV_ERROR', 56),
        ('CURLE_SHARE_IN_USE', 57),
        ('CURLE_SSL_CERTPROBLEM', 58),
        ('CURLE_SSL_CIPHER', 59),
        ('CURLE_SSL_CACERT', 60),
        ('CURLE_BAD_CONTENT_ENCODING', 61),
        ('CURLE_LDAP_INVALID_URL', 62),
        ('CURLE_FILESIZE_EXCEEDED', 63),
        ('CURLE_FTP_SSL_FAILED', 64),
        ('CURLPROXY_HTTP', 0),
        ('CURLPROXY_SOCKS4', 4),
        ('CURLPROXY_SOCKS5', 5),
        ('CURL_NETRC_OPTIONAL', 1),
        ('CURL_NETRC_IGNORED', 0),
        ('CURL_NETRC_REQUIRED', 2),
        ('CURL_HTTP_VERSION_NONE', 0),
        ('CURL_HTTP_VERSION_1_0', 1),
        ('CURL_HTTP_VERSION_1_1', 2),
        ('CURLM_CALL_MULTI_PERFORM', -1),
        ('CURLM_OK', 0),
        ('CURLM_BAD_HANDLE', 1),
        ('CURLM_BAD_EASY_HANDLE', 2),
        ('CURLM_OUT_OF_MEMORY', 3),
        ('CURLM_INTERNAL_ERROR', 4),
        ('CURLMSG_DONE', 1),
        ('CURLOPT_FTPSSLAUTH', 129),
        ('CURLFTPAUTH_DEFAULT', 0),
        ('CURLFTPAUTH_SSL', 1),
        ('CURLFTPAUTH_TLS', 2),
        ('CURLOPT_FTP_SSL', 119),
        ('CURLFTPSSL_NONE', 0),
        ('CURLFTPSSL_TRY', 1),
        ('CURLFTPSSL_CONTROL', 2),
        ('CURLFTPSSL_ALL', 3),
        ('CURLOPT_CERTINFO', 172),
        ('CURLOPT_POSTREDIR', 161),
        ('CURLSSH_AUTH_NONE', 0),
        ('CURLSSH_AUTH_PUBLICKEY', 1),
        ('CURLSSH_AUTH_PASSWORD', 2),
        ('CURLSSH_AUTH_HOST', 4),
        ('CURLSSH_AUTH_KEYBOARD', 8),
        ('CURLSSH_AUTH_DEFAULT', -1),
        ('CURLOPT_SSH_AUTH_TYPES', 151),
        ('CURLOPT_KEYPASSWD', 10026),
        ('CURLOPT_SSH_PUBLIC_KEYFILE', 10152),
        ('CURLOPT_SSH_PRIVATE_KEYFILE', 10153),
        ('CURLOPT_SSH_HOST_PUBLIC_KEY_MD5', 10162),
        ('CURLE_SSH', 79),
        ('CURLOPT_REDIR_PROTOCOLS', 182),
        ('CURLOPT_PROTOCOLS', 181),
        ('CURLPROTO_HTTP', 1),
        ('CURLPROTO_HTTPS', 2),
        ('CURLPROTO_FTP', 4),
        ('CURLPROTO_FTPS', 8),
        ('CURLPROTO_SCP', 16),
        ('CURLPROTO_SFTP', 32),
        ('CURLPROTO_TELNET', 64),
        ('CURLPROTO_LDAP', 128),
        ('CURLPROTO_LDAPS', 256),
        ('CURLPROTO_DICT', 512),
        ('CURLPROTO_FILE', 1024),
        ('CURLPROTO_TFTP', 2048),
        ('CURLPROTO_ALL', -1),
        ('CURLOPT_FTP_FILEMETHOD', 138),
        ('CURLOPT_FTP_SKIP_PASV_IP', 137),
        ('CURLFTPMETHOD_MULTICWD', 1),
        ('CURLFTPMETHOD_NOCWD', 2),
        ('CURLFTPMETHOD_SINGLECWD', 3)]),
    fileinfo=OrderedDict(
        FILEINFO_NONE=0,
        FILEINFO_SYMLINK=2,
        FILEINFO_MIME=1040,
        FILEINFO_MIME_TYPE=16,
        FILEINFO_MIME_ENCODING=1024,
        FILEINFO_DEVICES=8,
        FILEINFO_CONTINUE=32,
        FILEINFO_PRESERVE_ATIME=128,
        FILEINFO_RAW=256),
    json=OrderedDict(
        JSON_HEX_TAG=1,
        JSON_HEX_AMP=2,
        JSON_HEX_APOS=4,
        JSON_HEX_QUOT=8,
        JSON_FORCE_OBJECT=16,
        JSON_NUMERIC_CHECK=32,
        JSON_UNESCAPED_SLASHES=64,
        JSON_PRETTY_PRINT=128,
        JSON_UNESCAPED_UNICODE=256,
        JSON_ERROR_NONE=0,
        JSON_ERROR_DEPTH=1,
        JSON_ERROR_STATE_MISMATCH=2,
        JSON_ERROR_CTRL_CHAR=3,
        JSON_ERROR_SYNTAX=4,
        JSON_ERROR_UTF8=5,
        JSON_OBJECT_AS_ARRAY=1,
        JSON_BIGINT_AS_STRING=2),
    posix=OrderedDict(
        POSIX_F_OK=0,
        POSIX_R_OK=4,
        POSIX_W_OK=2,
        POSIX_X_OK=1,
        POSIX_S_IFBLK=24576,
        POSIX_S_IFCHR=8192,
        POSIX_S_IFIFO=4096,
        POSIX_S_IFREG=32768,
        POSIX_S_IFSOCK=49152),
    mysql=OrderedDict(
        MYSQL_ASSOC=1,
        MYSQL_NUM=2,
        MYSQL_BOTH=3,
        MYSQL_CLIENT_COMPRESS=32,
        MYSQL_CLIENT_SSL=2048,
        MYSQL_CLIENT_INTERACTIVE=1024,
        MYSQL_CLIENT_IGNORE_SPACE=256)
)


@specialize.memo()
def get_const(module, name):
    return CONSTS[module][name] # no wrapping

@specialize.memo()
def get_constants(space, module):
    result = []
    c = CONSTS.get(module, None)
    if c is not None:
        for key, value in c.items():
            result.append((key, space.wrap(value)))
    return result

CONST_KEYS = unrolling_iterable(CONSTS.keys())
