visaljs 0.0.0-stage → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +45 -2
- package/cli.js +8084 -0
- package/node/include/js_node.h +46 -0
- package/node/prelude/async_hooks.js +88 -0
- package/node/prelude/buffer.js +31 -0
- package/node/prelude/crypto.js +114 -0
- package/node/prelude/events.js +227 -0
- package/node/prelude/fs.js +79 -0
- package/node/prelude/http.js +536 -0
- package/node/prelude/http2.js +30 -0
- package/node/prelude/internal/crypto/asym.js +333 -0
- package/node/prelude/internal/crypto/cipher.js +205 -0
- package/node/prelude/internal/crypto/hash.js +137 -0
- package/node/prelude/internal/crypto/kdf.js +182 -0
- package/node/prelude/internal/crypto/keys.js +603 -0
- package/node/prelude/internal/crypto/random.js +118 -0
- package/node/prelude/internal/crypto/util.js +76 -0
- package/node/prelude/internal/errors.js +88 -0
- package/node/prelude/internal/querystring.js +105 -0
- package/node/prelude/module.js +53 -0
- package/node/prelude/net.js +51 -0
- package/node/prelude/os.js +129 -0
- package/node/prelude/path.js +257 -0
- package/node/prelude/process.js +21 -0
- package/node/prelude/querystring.js +469 -0
- package/node/prelude/stream.js +1327 -0
- package/node/prelude/stream_promises.js +7 -0
- package/node/prelude/stream_web.js +6 -0
- package/node/prelude/string_decoder.js +236 -0
- package/node/prelude/tty.js +18 -0
- package/node/prelude/url.js +1156 -0
- package/node/prelude/util.js +64 -0
- package/node/prelude/zlib.js +81 -0
- package/node/src/host_fs.c +126 -0
- package/node/src/host_http.c +486 -0
- package/node/src/host_os.c +505 -0
- package/node/src/host_sys.c +78 -0
- package/node/third_party/libuv/LICENSE +19 -0
- package/node/third_party/libuv/include/uv/aix.h +32 -0
- package/node/third_party/libuv/include/uv/bsd.h +34 -0
- package/node/third_party/libuv/include/uv/darwin.h +61 -0
- package/node/third_party/libuv/include/uv/errno.h +483 -0
- package/node/third_party/libuv/include/uv/linux.h +34 -0
- package/node/third_party/libuv/include/uv/os390.h +33 -0
- package/node/third_party/libuv/include/uv/posix.h +31 -0
- package/node/third_party/libuv/include/uv/sunos.h +44 -0
- package/node/third_party/libuv/include/uv/threadpool.h +37 -0
- package/node/third_party/libuv/include/uv/tree.h +521 -0
- package/node/third_party/libuv/include/uv/unix.h +512 -0
- package/node/third_party/libuv/include/uv/version.h +43 -0
- package/node/third_party/libuv/include/uv/win.h +698 -0
- package/node/third_party/libuv/include/uv.h +1990 -0
- package/node/third_party/libuv/src/fs-poll.c +290 -0
- package/node/third_party/libuv/src/heap-inl.h +245 -0
- package/node/third_party/libuv/src/idna.c +560 -0
- package/node/third_party/libuv/src/idna.h +31 -0
- package/node/third_party/libuv/src/inet.c +298 -0
- package/node/third_party/libuv/src/queue.h +90 -0
- package/node/third_party/libuv/src/random.c +123 -0
- package/node/third_party/libuv/src/strscpy.c +38 -0
- package/node/third_party/libuv/src/strscpy.h +39 -0
- package/node/third_party/libuv/src/strtok.c +52 -0
- package/node/third_party/libuv/src/strtok.h +27 -0
- package/node/third_party/libuv/src/thread-common.c +175 -0
- package/node/third_party/libuv/src/threadpool.c +419 -0
- package/node/third_party/libuv/src/timer.c +200 -0
- package/node/third_party/libuv/src/unix/async.c +418 -0
- package/node/third_party/libuv/src/unix/bsd-ifaddrs.c +164 -0
- package/node/third_party/libuv/src/unix/core.c +2104 -0
- package/node/third_party/libuv/src/unix/darwin-proctitle.c +176 -0
- package/node/third_party/libuv/src/unix/darwin-stub.h +97 -0
- package/node/third_party/libuv/src/unix/darwin-syscalls.h +17 -0
- package/node/third_party/libuv/src/unix/darwin.c +237 -0
- package/node/third_party/libuv/src/unix/dl.c +80 -0
- package/node/third_party/libuv/src/unix/fs.c +2303 -0
- package/node/third_party/libuv/src/unix/fsevents.c +906 -0
- package/node/third_party/libuv/src/unix/getaddrinfo.c +252 -0
- package/node/third_party/libuv/src/unix/getnameinfo.c +121 -0
- package/node/third_party/libuv/src/unix/internal.h +530 -0
- package/node/third_party/libuv/src/unix/kqueue.c +667 -0
- package/node/third_party/libuv/src/unix/linux.c +2761 -0
- package/node/third_party/libuv/src/unix/loop-watcher.c +68 -0
- package/node/third_party/libuv/src/unix/loop.c +240 -0
- package/node/third_party/libuv/src/unix/pipe.c +555 -0
- package/node/third_party/libuv/src/unix/poll.c +159 -0
- package/node/third_party/libuv/src/unix/process.c +1123 -0
- package/node/third_party/libuv/src/unix/procfs-exepath.c +45 -0
- package/node/third_party/libuv/src/unix/proctitle.c +157 -0
- package/node/third_party/libuv/src/unix/random-devurandom.c +93 -0
- package/node/third_party/libuv/src/unix/random-getentropy.c +57 -0
- package/node/third_party/libuv/src/unix/random-getrandom.c +86 -0
- package/node/third_party/libuv/src/unix/random-sysctl-linux.c +99 -0
- package/node/third_party/libuv/src/unix/signal.c +581 -0
- package/node/third_party/libuv/src/unix/stream.c +1567 -0
- package/node/third_party/libuv/src/unix/tcp.c +673 -0
- package/node/third_party/libuv/src/unix/thread.c +975 -0
- package/node/third_party/libuv/src/unix/tty.c +510 -0
- package/node/third_party/libuv/src/unix/udp.c +1434 -0
- package/node/third_party/libuv/src/uv-common.c +1051 -0
- package/node/third_party/libuv/src/uv-common.h +474 -0
- package/node/third_party/libuv/src/uv-data-getter-setters.c +119 -0
- package/node/third_party/libuv/src/version.c +45 -0
- package/node/third_party/llhttp/LICENSE +22 -0
- package/node/third_party/llhttp/api.c +509 -0
- package/node/third_party/llhttp/http.c +170 -0
- package/node/third_party/llhttp/llhttp.c +10099 -0
- package/node/third_party/llhttp/llhttp.h +907 -0
- package/package.json +25 -4
- package/runtime/include/js_atoms.gen.h +68 -0
- package/runtime/include/js_atoms.h +54 -0
- package/runtime/include/js_bigint.h +93 -0
- package/runtime/include/js_buffer.h +79 -0
- package/runtime/include/js_builtins.h +168 -0
- package/runtime/include/js_console.h +58 -0
- package/runtime/include/js_convert.h +22 -0
- package/runtime/include/js_core.def +188 -0
- package/runtime/include/js_crypto.h +58 -0
- package/runtime/include/js_error.h +37 -0
- package/runtime/include/js_exception.h +65 -0
- package/runtime/include/js_function.h +167 -0
- package/runtime/include/js_gc.h +195 -0
- package/runtime/include/js_generator.h +96 -0
- package/runtime/include/js_host.h +19 -0
- package/runtime/include/js_jobs.h +84 -0
- package/runtime/include/js_module.h +16 -0
- package/runtime/include/js_object.h +384 -0
- package/runtime/include/js_ops.h +111 -0
- package/runtime/include/js_promise.h +45 -0
- package/runtime/include/js_regexp.h +25 -0
- package/runtime/include/js_runtime.h +30 -0
- package/runtime/include/js_symbol.h +62 -0
- package/runtime/include/js_web.h +110 -0
- package/runtime/include/jscell.h +48 -0
- package/runtime/include/jscontext.h +240 -0
- package/runtime/include/jsnum.h +42 -0
- package/runtime/include/jsstring.h +161 -0
- package/runtime/include/jsvalue.h +142 -0
- package/runtime/src/arguments.c +115 -0
- package/runtime/src/array.c +1145 -0
- package/runtime/src/arraybuffer.c +608 -0
- package/runtime/src/async_iter.c +479 -0
- package/runtime/src/atoms.c +157 -0
- package/runtime/src/base64.c +107 -0
- package/runtime/src/bigint.c +1189 -0
- package/runtime/src/blob.c +371 -0
- package/runtime/src/buffer.c +1357 -0
- package/runtime/src/builtin_table.c +100 -0
- package/runtime/src/builtins.c +987 -0
- package/runtime/src/builtins_util.h +53 -0
- package/runtime/src/collections.c +912 -0
- package/runtime/src/components.c +28 -0
- package/runtime/src/console.c +637 -0
- package/runtime/src/convert.c +82 -0
- package/runtime/src/core_all.c +21 -0
- package/runtime/src/crypto.c +116 -0
- package/runtime/src/crypto_asym.c +644 -0
- package/runtime/src/crypto_cipher.c +671 -0
- package/runtime/src/crypto_hash.c +260 -0
- package/runtime/src/crypto_host.c +414 -0
- package/runtime/src/crypto_internal.h +304 -0
- package/runtime/src/crypto_kdf.c +143 -0
- package/runtime/src/crypto_key.c +171 -0
- package/runtime/src/crypto_pkey.c +794 -0
- package/runtime/src/crypto_subtle.c +1675 -0
- package/runtime/src/date.c +940 -0
- package/runtime/src/domexception.c +169 -0
- package/runtime/src/elements.c +312 -0
- package/runtime/src/elements.h +45 -0
- package/runtime/src/encoding.c +485 -0
- package/runtime/src/error.c +297 -0
- package/runtime/src/events.c +793 -0
- package/runtime/src/exception.c +56 -0
- package/runtime/src/fetch.c +772 -0
- package/runtime/src/function.c +530 -0
- package/runtime/src/gc.c +803 -0
- package/runtime/src/generator.c +218 -0
- package/runtime/src/global.c +119 -0
- package/runtime/src/headers.c +557 -0
- package/runtime/src/inspect.c +1792 -0
- package/runtime/src/internal.h +80 -0
- package/runtime/src/iterate.c +94 -0
- package/runtime/src/iterator.c +409 -0
- package/runtime/src/jobs.c +337 -0
- package/runtime/src/jsnum.c +353 -0
- package/runtime/src/json.c +1028 -0
- package/runtime/src/math.c +243 -0
- package/runtime/src/module.c +336 -0
- package/runtime/src/number.c +176 -0
- package/runtime/src/object.c +1265 -0
- package/runtime/src/ops.c +322 -0
- package/runtime/src/os.c +196 -0
- package/runtime/src/os.h +29 -0
- package/runtime/src/process.c +432 -0
- package/runtime/src/promise.c +721 -0
- package/runtime/src/proxy.c +570 -0
- package/runtime/src/reflect.c +194 -0
- package/runtime/src/regexp.c +1141 -0
- package/runtime/src/regexp_anchor.h +34 -0
- package/runtime/src/regexp_message.h +32 -0
- package/runtime/src/shape.c +294 -0
- package/runtime/src/shape.h +46 -0
- package/runtime/src/streams.c +1046 -0
- package/runtime/src/streams.h +47 -0
- package/runtime/src/string.c +364 -0
- package/runtime/src/string_builtins.c +837 -0
- package/runtime/src/symbol.c +143 -0
- package/runtime/src/test_host.c +59 -0
- package/runtime/src/typedarray.c +1330 -0
- package/runtime/src/tznames.gen.h +712 -0
- package/runtime/src/uri.c +169 -0
- package/runtime/src/url.c +2116 -0
- package/runtime/src/weak.c +486 -0
- package/runtime/src/web.c +214 -0
- package/runtime/src/wrapper.c +59 -0
- package/runtime/src/writable.c +1486 -0
- package/runtime/third_party/ada-idna/LICENSE-MIT +18 -0
- package/runtime/third_party/ada-idna/README.md +27 -0
- package/runtime/third_party/ada-idna/convert.mjs +83 -0
- package/runtime/third_party/ada-idna/idna.c +416 -0
- package/runtime/third_party/ada-idna/idna.h +15 -0
- package/runtime/third_party/ada-idna/idna_tables.h +2657 -0
- package/runtime/third_party/bearssl/LICENSE.txt +21 -0
- package/runtime/third_party/bearssl/README.txt +136 -0
- package/runtime/third_party/bearssl/VERSION +1 -0
- package/runtime/third_party/bearssl/inc/bearssl.h +183 -0
- package/runtime/third_party/bearssl/inc/bearssl_aead.h +1059 -0
- package/runtime/third_party/bearssl/inc/bearssl_block.h +2618 -0
- package/runtime/third_party/bearssl/inc/bearssl_ec.h +967 -0
- package/runtime/third_party/bearssl/inc/bearssl_hash.h +1346 -0
- package/runtime/third_party/bearssl/inc/bearssl_hmac.h +241 -0
- package/runtime/third_party/bearssl/inc/bearssl_kdf.h +284 -0
- package/runtime/third_party/bearssl/inc/bearssl_pem.h +294 -0
- package/runtime/third_party/bearssl/inc/bearssl_prf.h +150 -0
- package/runtime/third_party/bearssl/inc/bearssl_rand.h +397 -0
- package/runtime/third_party/bearssl/inc/bearssl_rsa.h +1655 -0
- package/runtime/third_party/bearssl/inc/bearssl_ssl.h +4296 -0
- package/runtime/third_party/bearssl/inc/bearssl_x509.h +1474 -0
- package/runtime/third_party/bearssl/src/aead/ccm.c +346 -0
- package/runtime/third_party/bearssl/src/aead/eax.c +525 -0
- package/runtime/third_party/bearssl/src/aead/gcm.c +318 -0
- package/runtime/third_party/bearssl/src/codec/ccopy.c +44 -0
- package/runtime/third_party/bearssl/src/codec/dec16be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/dec16le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/dec32be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/dec32le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/dec64be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/dec64le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc16be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc16le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc32be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc32le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc64be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc64le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/pemdec.c +526 -0
- package/runtime/third_party/bearssl/src/codec/pemdec.t0 +314 -0
- package/runtime/third_party/bearssl/src/codec/pemenc.c +173 -0
- package/runtime/third_party/bearssl/src/config.h +247 -0
- package/runtime/third_party/bearssl/src/ec/ec_all_m15.c +121 -0
- package/runtime/third_party/bearssl/src/ec/ec_all_m31.c +171 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_i15.c +398 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_i31.c +390 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_m15.c +1478 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_m31.c +800 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_m62.c +605 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_m64.c +831 -0
- package/runtime/third_party/bearssl/src/ec/ec_curve25519.c +46 -0
- package/runtime/third_party/bearssl/src/ec/ec_default.c +36 -0
- package/runtime/third_party/bearssl/src/ec/ec_keygen.c +86 -0
- package/runtime/third_party/bearssl/src/ec/ec_p256_m15.c +2124 -0
- package/runtime/third_party/bearssl/src/ec/ec_p256_m31.c +1469 -0
- package/runtime/third_party/bearssl/src/ec/ec_p256_m62.c +1765 -0
- package/runtime/third_party/bearssl/src/ec/ec_p256_m64.c +1781 -0
- package/runtime/third_party/bearssl/src/ec/ec_prime_i15.c +824 -0
- package/runtime/third_party/bearssl/src/ec/ec_prime_i31.c +826 -0
- package/runtime/third_party/bearssl/src/ec/ec_pubkey.c +85 -0
- package/runtime/third_party/bearssl/src/ec/ec_secp256r1.c +51 -0
- package/runtime/third_party/bearssl/src/ec/ec_secp384r1.c +57 -0
- package/runtime/third_party/bearssl/src/ec/ec_secp521r1.c +64 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_atr.c +134 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_default_sign_asn1.c +36 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_default_sign_raw.c +36 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_default_vrfy_asn1.c +36 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_default_vrfy_raw.c +36 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_bits.c +47 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_sign_asn1.c +45 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_sign_raw.c +174 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_vrfy_asn1.c +48 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_vrfy_raw.c +166 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_bits.c +47 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_sign_asn1.c +45 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_sign_raw.c +173 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_vrfy_asn1.c +48 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_vrfy_raw.c +165 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_rta.c +121 -0
- package/runtime/third_party/bearssl/src/hash/dig_oid.c +84 -0
- package/runtime/third_party/bearssl/src/hash/dig_size.c +50 -0
- package/runtime/third_party/bearssl/src/hash/ghash_ctmul.c +345 -0
- package/runtime/third_party/bearssl/src/hash/ghash_ctmul32.c +251 -0
- package/runtime/third_party/bearssl/src/hash/ghash_ctmul64.c +154 -0
- package/runtime/third_party/bearssl/src/hash/ghash_pclmul.c +389 -0
- package/runtime/third_party/bearssl/src/hash/ghash_pwr8.c +411 -0
- package/runtime/third_party/bearssl/src/hash/md5.c +208 -0
- package/runtime/third_party/bearssl/src/hash/md5sha1.c +141 -0
- package/runtime/third_party/bearssl/src/hash/mgf1.c +56 -0
- package/runtime/third_party/bearssl/src/hash/multihash.c +166 -0
- package/runtime/third_party/bearssl/src/hash/sha1.c +191 -0
- package/runtime/third_party/bearssl/src/hash/sha2big.c +285 -0
- package/runtime/third_party/bearssl/src/hash/sha2small.c +341 -0
- package/runtime/third_party/bearssl/src/inner.h +2577 -0
- package/runtime/third_party/bearssl/src/int/i15_add.c +46 -0
- package/runtime/third_party/bearssl/src/int/i15_bitlen.c +44 -0
- package/runtime/third_party/bearssl/src/int/i15_decmod.c +124 -0
- package/runtime/third_party/bearssl/src/int/i15_decode.c +56 -0
- package/runtime/third_party/bearssl/src/int/i15_decred.c +100 -0
- package/runtime/third_party/bearssl/src/int/i15_encode.c +56 -0
- package/runtime/third_party/bearssl/src/int/i15_fmont.c +59 -0
- package/runtime/third_party/bearssl/src/int/i15_iszero.c +39 -0
- package/runtime/third_party/bearssl/src/int/i15_moddiv.c +465 -0
- package/runtime/third_party/bearssl/src/int/i15_modpow.c +50 -0
- package/runtime/third_party/bearssl/src/int/i15_modpow2.c +160 -0
- package/runtime/third_party/bearssl/src/int/i15_montmul.c +184 -0
- package/runtime/third_party/bearssl/src/int/i15_mulacc.c +61 -0
- package/runtime/third_party/bearssl/src/int/i15_muladd.c +173 -0
- package/runtime/third_party/bearssl/src/int/i15_ninv15.c +38 -0
- package/runtime/third_party/bearssl/src/int/i15_reduce.c +66 -0
- package/runtime/third_party/bearssl/src/int/i15_rshift.c +47 -0
- package/runtime/third_party/bearssl/src/int/i15_sub.c +46 -0
- package/runtime/third_party/bearssl/src/int/i15_tmont.c +36 -0
- package/runtime/third_party/bearssl/src/int/i31_add.c +46 -0
- package/runtime/third_party/bearssl/src/int/i31_bitlen.c +44 -0
- package/runtime/third_party/bearssl/src/int/i31_decmod.c +124 -0
- package/runtime/third_party/bearssl/src/int/i31_decode.c +57 -0
- package/runtime/third_party/bearssl/src/int/i31_decred.c +103 -0
- package/runtime/third_party/bearssl/src/int/i31_encode.c +79 -0
- package/runtime/third_party/bearssl/src/int/i31_fmont.c +60 -0
- package/runtime/third_party/bearssl/src/int/i31_iszero.c +39 -0
- package/runtime/third_party/bearssl/src/int/i31_moddiv.c +488 -0
- package/runtime/third_party/bearssl/src/int/i31_modpow.c +65 -0
- package/runtime/third_party/bearssl/src/int/i31_modpow2.c +160 -0
- package/runtime/third_party/bearssl/src/int/i31_montmul.c +127 -0
- package/runtime/third_party/bearssl/src/int/i31_mulacc.c +74 -0
- package/runtime/third_party/bearssl/src/int/i31_muladd.c +157 -0
- package/runtime/third_party/bearssl/src/int/i31_ninv31.c +39 -0
- package/runtime/third_party/bearssl/src/int/i31_reduce.c +66 -0
- package/runtime/third_party/bearssl/src/int/i31_rshift.c +47 -0
- package/runtime/third_party/bearssl/src/int/i31_sub.c +46 -0
- package/runtime/third_party/bearssl/src/int/i31_tmont.c +36 -0
- package/runtime/third_party/bearssl/src/int/i32_add.c +51 -0
- package/runtime/third_party/bearssl/src/int/i32_bitlen.c +44 -0
- package/runtime/third_party/bearssl/src/int/i32_decmod.c +77 -0
- package/runtime/third_party/bearssl/src/int/i32_decode.c +63 -0
- package/runtime/third_party/bearssl/src/int/i32_decred.c +107 -0
- package/runtime/third_party/bearssl/src/int/i32_div32.c +56 -0
- package/runtime/third_party/bearssl/src/int/i32_encode.c +72 -0
- package/runtime/third_party/bearssl/src/int/i32_fmont.c +60 -0
- package/runtime/third_party/bearssl/src/int/i32_iszero.c +39 -0
- package/runtime/third_party/bearssl/src/int/i32_modpow.c +65 -0
- package/runtime/third_party/bearssl/src/int/i32_montmul.c +69 -0
- package/runtime/third_party/bearssl/src/int/i32_mulacc.c +56 -0
- package/runtime/third_party/bearssl/src/int/i32_muladd.c +138 -0
- package/runtime/third_party/bearssl/src/int/i32_ninv32.c +39 -0
- package/runtime/third_party/bearssl/src/int/i32_reduce.c +66 -0
- package/runtime/third_party/bearssl/src/int/i32_sub.c +51 -0
- package/runtime/third_party/bearssl/src/int/i32_tmont.c +36 -0
- package/runtime/third_party/bearssl/src/int/i62_modpow2.c +493 -0
- package/runtime/third_party/bearssl/src/kdf/hkdf.c +107 -0
- package/runtime/third_party/bearssl/src/kdf/shake.c +590 -0
- package/runtime/third_party/bearssl/src/mac/hmac.c +122 -0
- package/runtime/third_party/bearssl/src/mac/hmac_ct.c +193 -0
- package/runtime/third_party/bearssl/src/rand/aesctr_drbg.c +206 -0
- package/runtime/third_party/bearssl/src/rand/hmac_drbg.c +157 -0
- package/runtime/third_party/bearssl/src/rand/sysrng.c +252 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_keygen.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_modulus.c +36 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_oaep_decrypt.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_oaep_encrypt.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pkcs1_sign.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pkcs1_vrfy.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_priv.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_privexp.c +36 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pss_sign.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pss_vrfy.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pub.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pubexp.c +36 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_keygen.c +583 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_modulus.c +99 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_oaep_decrypt.c +41 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_oaep_encrypt.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pkcs1_sign.c +37 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pkcs1_vrfy.c +43 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_priv.c +209 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_privexp.c +320 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pss_sign.c +40 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pss_vrfy.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pub.c +113 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pubexp.c +152 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_keygen.c +37 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_keygen_inner.c +608 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_modulus.c +99 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_oaep_decrypt.c +41 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_oaep_encrypt.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pkcs1_sign.c +37 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pkcs1_vrfy.c +43 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_priv.c +203 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_privexp.c +318 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pss_sign.c +40 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pss_vrfy.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pub.c +106 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pubexp.c +152 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_oaep_decrypt.c +41 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_oaep_encrypt.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pkcs1_sign.c +37 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pkcs1_vrfy.c +43 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_priv.c +160 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pss_sign.c +40 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pss_vrfy.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pub.c +77 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_keygen.c +57 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_oaep_decrypt.c +61 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_oaep_encrypt.c +64 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pkcs1_sign.c +57 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pkcs1_vrfy.c +63 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_priv.c +223 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pss_sign.c +60 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pss_vrfy.c +64 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pub.c +125 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_oaep_pad.c +112 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_oaep_unpad.c +145 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_pkcs1_sig_pad.c +100 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_pkcs1_sig_unpad.c +121 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_pss_sig_pad.c +106 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_pss_sig_unpad.c +121 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_ssl_decrypt.c +52 -0
- package/runtime/third_party/bearssl/src/settings.c +306 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_cbcdec.c +69 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_cbcenc.c +67 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_ctr.c +84 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_ctrcbc.c +142 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_dec.c +254 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_enc.c +157 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_common.c +112 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct.c +328 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64.c +398 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_cbcdec.c +104 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_cbcenc.c +81 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_ctr.c +114 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_ctrcbc.c +433 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_dec.c +159 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_enc.c +115 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_cbcdec.c +111 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_cbcenc.c +91 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_ctr.c +116 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_ctrcbc.c +422 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_dec.c +170 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_enc.c +112 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8.c +445 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_cbcdec.c +670 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_cbcenc.c +417 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_ctr.c +717 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_ctrcbc.c +946 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_cbcdec.c +69 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_cbcenc.c +67 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_ctr.c +84 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_ctrcbc.c +142 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_dec.c +176 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_enc.c +129 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni.c +240 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_cbcdec.c +223 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_cbcenc.c +122 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_ctr.c +211 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_ctrcbc.c +596 -0
- package/runtime/third_party/bearssl/src/symcipher/chacha20_ct.c +106 -0
- package/runtime/third_party/bearssl/src/symcipher/chacha20_sse2.c +237 -0
- package/runtime/third_party/bearssl/src/symcipher/des_ct.c +411 -0
- package/runtime/third_party/bearssl/src/symcipher/des_ct_cbcdec.c +87 -0
- package/runtime/third_party/bearssl/src/symcipher/des_ct_cbcenc.c +69 -0
- package/runtime/third_party/bearssl/src/symcipher/des_support.c +166 -0
- package/runtime/third_party/bearssl/src/symcipher/des_tab.c +310 -0
- package/runtime/third_party/bearssl/src/symcipher/des_tab_cbcdec.c +85 -0
- package/runtime/third_party/bearssl/src/symcipher/des_tab_cbcenc.c +67 -0
- package/runtime/third_party/bearssl/src/symcipher/poly1305_ctmul.c +260 -0
- package/runtime/third_party/bearssl/src/symcipher/poly1305_ctmul32.c +297 -0
- package/runtime/third_party/bearssl/src/symcipher/poly1305_ctmulq.c +475 -0
- package/runtime/third_party/bearssl/src/symcipher/poly1305_i15.c +221 -0
- package/runtime/third_party/bearssl/src/x509/asn1.t0 +757 -0
- package/runtime/third_party/bearssl/src/x509/asn1enc.c +93 -0
- package/runtime/third_party/bearssl/src/x509/encode_ec_pk8der.c +110 -0
- package/runtime/third_party/bearssl/src/x509/encode_ec_rawder.c +161 -0
- package/runtime/third_party/bearssl/src/x509/encode_rsa_pk8der.c +97 -0
- package/runtime/third_party/bearssl/src/x509/encode_rsa_rawder.c +96 -0
- package/runtime/third_party/bearssl/src/x509/skey_decoder.c +653 -0
- package/runtime/third_party/bearssl/src/x509/skey_decoder.t0 +376 -0
- package/runtime/third_party/bearssl/src/x509/x509_decoder.c +776 -0
- package/runtime/third_party/bearssl/src/x509/x509_decoder.t0 +324 -0
- package/runtime/third_party/bearssl/src/x509/x509_knownkey.c +105 -0
- package/runtime/third_party/bearssl/src/x509/x509_minimal.c +1722 -0
- package/runtime/third_party/bearssl/src/x509/x509_minimal.t0 +1526 -0
- package/runtime/third_party/bearssl/src/x509/x509_minimal_full.c +59 -0
- package/runtime/third_party/quickjs-dtoa/LICENSE +22 -0
- package/runtime/third_party/quickjs-dtoa/README.md +23 -0
- package/runtime/third_party/quickjs-dtoa/dtoa.c +1640 -0
- package/runtime/third_party/quickjs-dtoa/dtoa.h +83 -0
- package/runtime/third_party/quickjs-dtoa/dtoa_compat.h +89 -0
- package/runtime/third_party/quickjs-regexp/LICENSE +22 -0
- package/runtime/third_party/quickjs-regexp/README.md +22 -0
- package/runtime/third_party/quickjs-regexp/cutils.c +641 -0
- package/runtime/third_party/quickjs-regexp/cutils.h +457 -0
- package/runtime/third_party/quickjs-regexp/libregexp-opcode.h +73 -0
- package/runtime/third_party/quickjs-regexp/libregexp.c +3448 -0
- package/runtime/third_party/quickjs-regexp/libregexp.h +65 -0
- package/runtime/third_party/quickjs-regexp/libunicode-table.h +5206 -0
- package/runtime/third_party/quickjs-regexp/libunicode.c +2124 -0
- package/runtime/third_party/quickjs-regexp/libunicode.h +196 -0
- package/runtime/third_party/v8-ieee754/LICENSE +61 -0
- package/runtime/third_party/v8-ieee754/README.md +22 -0
- package/runtime/third_party/v8-ieee754/convert.py +84 -0
- package/runtime/third_party/v8-ieee754/ieee754.c +3030 -0
- package/runtime/third_party/v8-ieee754/ieee754.h +27 -0
- package/runtime/tools/regexp_compile.c +90 -0
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
|
|
3
|
+
* Copyright (c) 1996-1999 by Internet Software Consortium.
|
|
4
|
+
*
|
|
5
|
+
* Permission to use, copy, modify, and distribute this software for any
|
|
6
|
+
* purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
* copyright notice and this permission notice appear in all copies.
|
|
8
|
+
*
|
|
9
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
|
|
10
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
|
|
12
|
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
|
15
|
+
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#include <stdio.h>
|
|
19
|
+
#include <string.h>
|
|
20
|
+
#include <stdint.h>
|
|
21
|
+
|
|
22
|
+
#include "uv.h"
|
|
23
|
+
#include "uv-common.h"
|
|
24
|
+
|
|
25
|
+
#define UV__INET_ADDRSTRLEN 16
|
|
26
|
+
#define UV__INET6_ADDRSTRLEN 46
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
static int inet_ntop4(const unsigned char *src, char *dst, size_t size);
|
|
30
|
+
static int inet_ntop6(const unsigned char *src, char *dst, size_t size);
|
|
31
|
+
static int inet_pton4(const char *src, unsigned char *dst);
|
|
32
|
+
static int inet_pton6(const char *src, unsigned char *dst);
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
int uv_inet_ntop(int af, const void* src, char* dst, size_t size) {
|
|
36
|
+
switch (af) {
|
|
37
|
+
case AF_INET:
|
|
38
|
+
return (inet_ntop4(src, dst, size));
|
|
39
|
+
case AF_INET6:
|
|
40
|
+
return (inet_ntop6(src, dst, size));
|
|
41
|
+
default:
|
|
42
|
+
return UV_EAFNOSUPPORT;
|
|
43
|
+
}
|
|
44
|
+
/* NOTREACHED */
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
static int inet_ntop4(const unsigned char *src, char *dst, size_t size) {
|
|
49
|
+
static const char fmt[] = "%u.%u.%u.%u";
|
|
50
|
+
char tmp[UV__INET_ADDRSTRLEN];
|
|
51
|
+
int l;
|
|
52
|
+
|
|
53
|
+
l = snprintf(tmp, sizeof(tmp), fmt, src[0], src[1], src[2], src[3]);
|
|
54
|
+
if (l <= 0 || (size_t) l >= size) {
|
|
55
|
+
return UV_ENOSPC;
|
|
56
|
+
}
|
|
57
|
+
uv__strscpy(dst, tmp, size);
|
|
58
|
+
return 0;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
static int inet_ntop6(const unsigned char *src, char *dst, size_t size) {
|
|
63
|
+
/*
|
|
64
|
+
* Note that int32_t and int16_t need only be "at least" large enough
|
|
65
|
+
* to contain a value of the specified size. On some systems, like
|
|
66
|
+
* Crays, there is no such thing as an integer variable with 16 bits.
|
|
67
|
+
* Keep this in mind if you think this function should have been coded
|
|
68
|
+
* to use pointer overlays. All the world's not a VAX.
|
|
69
|
+
*/
|
|
70
|
+
char tmp[UV__INET6_ADDRSTRLEN], *tp;
|
|
71
|
+
struct { int base, len; } best, cur;
|
|
72
|
+
unsigned int words[sizeof(struct in6_addr) / sizeof(uint16_t)];
|
|
73
|
+
int i;
|
|
74
|
+
|
|
75
|
+
/*
|
|
76
|
+
* Preprocess:
|
|
77
|
+
* Copy the input (bytewise) array into a wordwise array.
|
|
78
|
+
* Find the longest run of 0x00's in src[] for :: shorthanding.
|
|
79
|
+
*/
|
|
80
|
+
memset(words, '\0', sizeof words);
|
|
81
|
+
for (i = 0; i < (int) sizeof(struct in6_addr); i++)
|
|
82
|
+
words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
|
|
83
|
+
best.base = -1;
|
|
84
|
+
best.len = 0;
|
|
85
|
+
cur.base = -1;
|
|
86
|
+
cur.len = 0;
|
|
87
|
+
for (i = 0; i < (int) ARRAY_SIZE(words); i++) {
|
|
88
|
+
if (words[i] == 0) {
|
|
89
|
+
if (cur.base == -1)
|
|
90
|
+
cur.base = i, cur.len = 1;
|
|
91
|
+
else
|
|
92
|
+
cur.len++;
|
|
93
|
+
} else {
|
|
94
|
+
if (cur.base != -1) {
|
|
95
|
+
if (best.base == -1 || cur.len > best.len)
|
|
96
|
+
best = cur;
|
|
97
|
+
cur.base = -1;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (cur.base != -1) {
|
|
102
|
+
if (best.base == -1 || cur.len > best.len)
|
|
103
|
+
best = cur;
|
|
104
|
+
}
|
|
105
|
+
if (best.base != -1 && best.len < 2)
|
|
106
|
+
best.base = -1;
|
|
107
|
+
|
|
108
|
+
/*
|
|
109
|
+
* Format the result.
|
|
110
|
+
*/
|
|
111
|
+
tp = tmp;
|
|
112
|
+
for (i = 0; i < (int) ARRAY_SIZE(words); i++) {
|
|
113
|
+
/* Are we inside the best run of 0x00's? */
|
|
114
|
+
if (best.base != -1 && i >= best.base &&
|
|
115
|
+
i < (best.base + best.len)) {
|
|
116
|
+
if (i == best.base)
|
|
117
|
+
*tp++ = ':';
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
/* Are we following an initial run of 0x00s or any real hex? */
|
|
121
|
+
if (i != 0)
|
|
122
|
+
*tp++ = ':';
|
|
123
|
+
/* Is this address an encapsulated IPv4? */
|
|
124
|
+
if (i == 6 && best.base == 0 && (best.len == 6 ||
|
|
125
|
+
(best.len == 7 && words[7] != 0x0001) ||
|
|
126
|
+
(best.len == 5 && words[5] == 0xffff))) {
|
|
127
|
+
int err = inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp));
|
|
128
|
+
if (err)
|
|
129
|
+
return err;
|
|
130
|
+
tp += strlen(tp);
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
tp += snprintf(tp, sizeof tmp - (tp - tmp), "%x", words[i]);
|
|
134
|
+
}
|
|
135
|
+
/* Was it a trailing run of 0x00's? */
|
|
136
|
+
if (best.base != -1 && (best.base + best.len) == ARRAY_SIZE(words))
|
|
137
|
+
*tp++ = ':';
|
|
138
|
+
*tp++ = '\0';
|
|
139
|
+
if ((size_t) (tp - tmp) > size)
|
|
140
|
+
return UV_ENOSPC;
|
|
141
|
+
uv__strscpy(dst, tmp, size);
|
|
142
|
+
return 0;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
int uv_inet_pton(int af, const char* src, void* dst) {
|
|
147
|
+
if (src == NULL || dst == NULL)
|
|
148
|
+
return UV_EINVAL;
|
|
149
|
+
|
|
150
|
+
switch (af) {
|
|
151
|
+
case AF_INET:
|
|
152
|
+
return (inet_pton4(src, dst));
|
|
153
|
+
case AF_INET6: {
|
|
154
|
+
int len;
|
|
155
|
+
char tmp[UV__INET6_ADDRSTRLEN], *s, *p;
|
|
156
|
+
s = (char*) src;
|
|
157
|
+
p = strchr(src, '%');
|
|
158
|
+
if (p != NULL) {
|
|
159
|
+
s = tmp;
|
|
160
|
+
len = p - src;
|
|
161
|
+
if (len > UV__INET6_ADDRSTRLEN-1)
|
|
162
|
+
return UV_EINVAL;
|
|
163
|
+
memcpy(s, src, len);
|
|
164
|
+
s[len] = '\0';
|
|
165
|
+
}
|
|
166
|
+
return inet_pton6(s, dst);
|
|
167
|
+
}
|
|
168
|
+
default:
|
|
169
|
+
return UV_EAFNOSUPPORT;
|
|
170
|
+
}
|
|
171
|
+
/* NOTREACHED */
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
static int inet_pton4(const char *src, unsigned char *dst) {
|
|
176
|
+
static const char digits[] = "0123456789";
|
|
177
|
+
int saw_digit, octets, ch;
|
|
178
|
+
unsigned char tmp[sizeof(struct in_addr)], *tp;
|
|
179
|
+
|
|
180
|
+
saw_digit = 0;
|
|
181
|
+
octets = 0;
|
|
182
|
+
*(tp = tmp) = 0;
|
|
183
|
+
while ((ch = *src++) != '\0') {
|
|
184
|
+
const char *pch;
|
|
185
|
+
|
|
186
|
+
if ((pch = strchr(digits, ch)) != NULL) {
|
|
187
|
+
unsigned int nw = *tp * 10 + (pch - digits);
|
|
188
|
+
|
|
189
|
+
if (saw_digit && *tp == 0)
|
|
190
|
+
return UV_EINVAL;
|
|
191
|
+
if (nw > 255)
|
|
192
|
+
return UV_EINVAL;
|
|
193
|
+
*tp = nw;
|
|
194
|
+
if (!saw_digit) {
|
|
195
|
+
if (++octets > 4)
|
|
196
|
+
return UV_EINVAL;
|
|
197
|
+
saw_digit = 1;
|
|
198
|
+
}
|
|
199
|
+
} else if (ch == '.' && saw_digit) {
|
|
200
|
+
if (octets == 4)
|
|
201
|
+
return UV_EINVAL;
|
|
202
|
+
*++tp = 0;
|
|
203
|
+
saw_digit = 0;
|
|
204
|
+
} else
|
|
205
|
+
return UV_EINVAL;
|
|
206
|
+
}
|
|
207
|
+
if (octets < 4)
|
|
208
|
+
return UV_EINVAL;
|
|
209
|
+
memcpy(dst, tmp, sizeof(struct in_addr));
|
|
210
|
+
return 0;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
static int inet_pton6(const char *src, unsigned char *dst) {
|
|
215
|
+
static const char xdigits_l[] = "0123456789abcdef",
|
|
216
|
+
xdigits_u[] = "0123456789ABCDEF";
|
|
217
|
+
unsigned char tmp[sizeof(struct in6_addr)], *tp, *endp, *colonp;
|
|
218
|
+
const char *xdigits, *curtok;
|
|
219
|
+
int ch, seen_xdigits;
|
|
220
|
+
unsigned int val;
|
|
221
|
+
|
|
222
|
+
memset((tp = tmp), '\0', sizeof tmp);
|
|
223
|
+
endp = tp + sizeof tmp;
|
|
224
|
+
colonp = NULL;
|
|
225
|
+
/* Leading :: requires some special handling. */
|
|
226
|
+
if (*src == ':')
|
|
227
|
+
if (*++src != ':')
|
|
228
|
+
return UV_EINVAL;
|
|
229
|
+
curtok = src;
|
|
230
|
+
seen_xdigits = 0;
|
|
231
|
+
val = 0;
|
|
232
|
+
while ((ch = *src++) != '\0') {
|
|
233
|
+
const char *pch;
|
|
234
|
+
|
|
235
|
+
if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
|
|
236
|
+
pch = strchr((xdigits = xdigits_u), ch);
|
|
237
|
+
if (pch != NULL) {
|
|
238
|
+
val <<= 4;
|
|
239
|
+
val |= (pch - xdigits);
|
|
240
|
+
if (++seen_xdigits > 4)
|
|
241
|
+
return UV_EINVAL;
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
if (ch == ':') {
|
|
245
|
+
curtok = src;
|
|
246
|
+
if (!seen_xdigits) {
|
|
247
|
+
if (colonp)
|
|
248
|
+
return UV_EINVAL;
|
|
249
|
+
colonp = tp;
|
|
250
|
+
continue;
|
|
251
|
+
} else if (*src == '\0') {
|
|
252
|
+
return UV_EINVAL;
|
|
253
|
+
}
|
|
254
|
+
if (tp + sizeof(uint16_t) > endp)
|
|
255
|
+
return UV_EINVAL;
|
|
256
|
+
*tp++ = (unsigned char) (val >> 8) & 0xff;
|
|
257
|
+
*tp++ = (unsigned char) val & 0xff;
|
|
258
|
+
seen_xdigits = 0;
|
|
259
|
+
val = 0;
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
if (ch == '.' && ((tp + sizeof(struct in_addr)) <= endp)) {
|
|
263
|
+
int err = inet_pton4(curtok, tp);
|
|
264
|
+
if (err == 0) {
|
|
265
|
+
tp += sizeof(struct in_addr);
|
|
266
|
+
seen_xdigits = 0;
|
|
267
|
+
break; /*%< '\\0' was seen by inet_pton4(). */
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return UV_EINVAL;
|
|
271
|
+
}
|
|
272
|
+
if (seen_xdigits) {
|
|
273
|
+
if (tp + sizeof(uint16_t) > endp)
|
|
274
|
+
return UV_EINVAL;
|
|
275
|
+
*tp++ = (unsigned char) (val >> 8) & 0xff;
|
|
276
|
+
*tp++ = (unsigned char) val & 0xff;
|
|
277
|
+
}
|
|
278
|
+
if (colonp != NULL) {
|
|
279
|
+
/*
|
|
280
|
+
* Since some memmove()'s erroneously fail to handle
|
|
281
|
+
* overlapping regions, we'll do the shift by hand.
|
|
282
|
+
*/
|
|
283
|
+
const int n = tp - colonp;
|
|
284
|
+
int i;
|
|
285
|
+
|
|
286
|
+
if (tp == endp)
|
|
287
|
+
return UV_EINVAL;
|
|
288
|
+
for (i = 1; i <= n; i++) {
|
|
289
|
+
endp[- i] = colonp[n - i];
|
|
290
|
+
colonp[n - i] = 0;
|
|
291
|
+
}
|
|
292
|
+
tp = endp;
|
|
293
|
+
}
|
|
294
|
+
if (tp != endp)
|
|
295
|
+
return UV_EINVAL;
|
|
296
|
+
memcpy(dst, tmp, sizeof tmp);
|
|
297
|
+
return 0;
|
|
298
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/* Copyright (c) 2013, Ben Noordhuis <info@bnoordhuis.nl>
|
|
2
|
+
*
|
|
3
|
+
* Permission to use, copy, modify, and/or distribute this software for any
|
|
4
|
+
* purpose with or without fee is hereby granted, provided that the above
|
|
5
|
+
* copyright notice and this permission notice appear in all copies.
|
|
6
|
+
*
|
|
7
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
8
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
9
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
10
|
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
11
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
12
|
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
13
|
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
#ifndef QUEUE_H_
|
|
17
|
+
#define QUEUE_H_
|
|
18
|
+
|
|
19
|
+
#include <stddef.h>
|
|
20
|
+
|
|
21
|
+
#define uv__queue_data(pointer, type, field) \
|
|
22
|
+
((type*) ((char*) (pointer) - offsetof(type, field)))
|
|
23
|
+
|
|
24
|
+
#define uv__queue_foreach(q, h) \
|
|
25
|
+
for ((q) = (h)->next; (q) != (h); (q) = (q)->next)
|
|
26
|
+
|
|
27
|
+
static inline void uv__queue_init(struct uv__queue* q) {
|
|
28
|
+
q->next = q;
|
|
29
|
+
q->prev = q;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static inline int uv__queue_empty(const struct uv__queue* q) {
|
|
33
|
+
return q == q->next;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static inline struct uv__queue* uv__queue_head(const struct uv__queue* q) {
|
|
37
|
+
return q->next;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static inline struct uv__queue* uv__queue_next(const struct uv__queue* q) {
|
|
41
|
+
return q->next;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static inline void uv__queue_add(struct uv__queue* h, struct uv__queue* n) {
|
|
45
|
+
h->prev->next = n->next;
|
|
46
|
+
n->next->prev = h->prev;
|
|
47
|
+
h->prev = n->prev;
|
|
48
|
+
h->prev->next = h;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
static inline void uv__queue_split(struct uv__queue* h,
|
|
52
|
+
struct uv__queue* q,
|
|
53
|
+
struct uv__queue* n) {
|
|
54
|
+
n->prev = h->prev;
|
|
55
|
+
n->prev->next = n;
|
|
56
|
+
n->next = q;
|
|
57
|
+
h->prev = q->prev;
|
|
58
|
+
h->prev->next = h;
|
|
59
|
+
q->prev = n;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static inline void uv__queue_move(struct uv__queue* h, struct uv__queue* n) {
|
|
63
|
+
if (uv__queue_empty(h))
|
|
64
|
+
uv__queue_init(n);
|
|
65
|
+
else
|
|
66
|
+
uv__queue_split(h, h->next, n);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static inline void uv__queue_insert_head(struct uv__queue* h,
|
|
70
|
+
struct uv__queue* q) {
|
|
71
|
+
q->next = h->next;
|
|
72
|
+
q->prev = h;
|
|
73
|
+
q->next->prev = q;
|
|
74
|
+
h->next = q;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
static inline void uv__queue_insert_tail(struct uv__queue* h,
|
|
78
|
+
struct uv__queue* q) {
|
|
79
|
+
q->next = h;
|
|
80
|
+
q->prev = h->prev;
|
|
81
|
+
q->prev->next = q;
|
|
82
|
+
h->prev = q;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static inline void uv__queue_remove(struct uv__queue* q) {
|
|
86
|
+
q->prev->next = q->next;
|
|
87
|
+
q->next->prev = q->prev;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
#endif /* QUEUE_H_ */
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/* Copyright libuv contributors. All rights reserved.
|
|
2
|
+
*
|
|
3
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
* of this software and associated documentation files (the "Software"), to
|
|
5
|
+
* deal in the Software without restriction, including without limitation the
|
|
6
|
+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
7
|
+
* sell copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
* furnished to do so, subject to the following conditions:
|
|
9
|
+
*
|
|
10
|
+
* The above copyright notice and this permission notice shall be included in
|
|
11
|
+
* all copies or substantial portions of the Software.
|
|
12
|
+
*
|
|
13
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
18
|
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
19
|
+
* IN THE SOFTWARE.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
#include "uv.h"
|
|
23
|
+
#include "uv-common.h"
|
|
24
|
+
|
|
25
|
+
#ifdef _WIN32
|
|
26
|
+
# include "win/internal.h"
|
|
27
|
+
#else
|
|
28
|
+
# include "unix/internal.h"
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
static int uv__random(void* buf, size_t buflen) {
|
|
32
|
+
int rc;
|
|
33
|
+
|
|
34
|
+
#if defined(__PASE__)
|
|
35
|
+
rc = uv__random_readpath("/dev/urandom", buf, buflen);
|
|
36
|
+
#elif defined(_AIX) || defined(__QNX__)
|
|
37
|
+
rc = uv__random_readpath("/dev/random", buf, buflen);
|
|
38
|
+
#elif defined(__APPLE__) || defined(__OpenBSD__) || \
|
|
39
|
+
(defined(__ANDROID_API__) && __ANDROID_API__ >= 28)
|
|
40
|
+
rc = uv__random_getentropy(buf, buflen);
|
|
41
|
+
if (rc == UV_ENOSYS)
|
|
42
|
+
rc = uv__random_devurandom(buf, buflen);
|
|
43
|
+
#elif defined(__NetBSD__)
|
|
44
|
+
rc = uv__random_sysctl(buf, buflen);
|
|
45
|
+
#elif defined(__FreeBSD__) || defined(__linux__)
|
|
46
|
+
rc = uv__random_getrandom(buf, buflen);
|
|
47
|
+
if (rc == UV_ENOSYS)
|
|
48
|
+
rc = uv__random_devurandom(buf, buflen);
|
|
49
|
+
# if defined(__linux__)
|
|
50
|
+
switch (rc) {
|
|
51
|
+
case UV_EACCES:
|
|
52
|
+
case UV_EIO:
|
|
53
|
+
case UV_ELOOP:
|
|
54
|
+
case UV_EMFILE:
|
|
55
|
+
case UV_ENFILE:
|
|
56
|
+
case UV_ENOENT:
|
|
57
|
+
case UV_EPERM:
|
|
58
|
+
rc = uv__random_sysctl(buf, buflen);
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
# endif
|
|
62
|
+
#elif defined(_WIN32)
|
|
63
|
+
uv__once_init();
|
|
64
|
+
rc = uv__random_rtlgenrandom(buf, buflen);
|
|
65
|
+
#else
|
|
66
|
+
rc = uv__random_devurandom(buf, buflen);
|
|
67
|
+
#endif
|
|
68
|
+
|
|
69
|
+
return rc;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
static void uv__random_work(struct uv__work* w) {
|
|
74
|
+
uv_random_t* req;
|
|
75
|
+
|
|
76
|
+
req = container_of(w, uv_random_t, work_req);
|
|
77
|
+
req->status = uv__random(req->buf, req->buflen);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
static void uv__random_done(struct uv__work* w, int status) {
|
|
82
|
+
uv_random_t* req;
|
|
83
|
+
|
|
84
|
+
req = container_of(w, uv_random_t, work_req);
|
|
85
|
+
uv__req_unregister(req->loop);
|
|
86
|
+
|
|
87
|
+
if (status == 0)
|
|
88
|
+
status = req->status;
|
|
89
|
+
|
|
90
|
+
req->cb(req, status, req->buf, req->buflen);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
int uv_random(uv_loop_t* loop,
|
|
95
|
+
uv_random_t* req,
|
|
96
|
+
void *buf,
|
|
97
|
+
size_t buflen,
|
|
98
|
+
unsigned flags,
|
|
99
|
+
uv_random_cb cb) {
|
|
100
|
+
if (buflen > 0x7FFFFFFFu)
|
|
101
|
+
return UV_E2BIG;
|
|
102
|
+
|
|
103
|
+
if (flags != 0)
|
|
104
|
+
return UV_EINVAL;
|
|
105
|
+
|
|
106
|
+
if (cb == NULL)
|
|
107
|
+
return uv__random(buf, buflen);
|
|
108
|
+
|
|
109
|
+
uv__req_init(loop, req, UV_RANDOM);
|
|
110
|
+
req->loop = loop;
|
|
111
|
+
req->status = 0;
|
|
112
|
+
req->cb = cb;
|
|
113
|
+
req->buf = buf;
|
|
114
|
+
req->buflen = buflen;
|
|
115
|
+
|
|
116
|
+
uv__work_submit(loop,
|
|
117
|
+
&req->work_req,
|
|
118
|
+
UV__WORK_CPU,
|
|
119
|
+
uv__random_work,
|
|
120
|
+
uv__random_done);
|
|
121
|
+
|
|
122
|
+
return 0;
|
|
123
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* Copyright libuv project contributors. All rights reserved.
|
|
2
|
+
*
|
|
3
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
* of this software and associated documentation files (the "Software"), to
|
|
5
|
+
* deal in the Software without restriction, including without limitation the
|
|
6
|
+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
7
|
+
* sell copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
* furnished to do so, subject to the following conditions:
|
|
9
|
+
*
|
|
10
|
+
* The above copyright notice and this permission notice shall be included in
|
|
11
|
+
* all copies or substantial portions of the Software.
|
|
12
|
+
*
|
|
13
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
18
|
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
19
|
+
* IN THE SOFTWARE.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
#include "strscpy.h"
|
|
23
|
+
#include <limits.h> /* SSIZE_MAX */
|
|
24
|
+
|
|
25
|
+
ssize_t uv__strscpy(char* d, const char* s, size_t n) {
|
|
26
|
+
size_t i;
|
|
27
|
+
|
|
28
|
+
for (i = 0; i < n; i++)
|
|
29
|
+
if ('\0' == (d[i] = s[i]))
|
|
30
|
+
return i > SSIZE_MAX ? UV_E2BIG : (ssize_t) i;
|
|
31
|
+
|
|
32
|
+
if (i == 0)
|
|
33
|
+
return 0;
|
|
34
|
+
|
|
35
|
+
d[--i] = '\0';
|
|
36
|
+
|
|
37
|
+
return UV_E2BIG;
|
|
38
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/* Copyright libuv project contributors. All rights reserved.
|
|
2
|
+
*
|
|
3
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
* of this software and associated documentation files (the "Software"), to
|
|
5
|
+
* deal in the Software without restriction, including without limitation the
|
|
6
|
+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
7
|
+
* sell copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
* furnished to do so, subject to the following conditions:
|
|
9
|
+
*
|
|
10
|
+
* The above copyright notice and this permission notice shall be included in
|
|
11
|
+
* all copies or substantial portions of the Software.
|
|
12
|
+
*
|
|
13
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
18
|
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
19
|
+
* IN THE SOFTWARE.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
#ifndef UV_STRSCPY_H_
|
|
23
|
+
#define UV_STRSCPY_H_
|
|
24
|
+
|
|
25
|
+
/* Include uv.h for its definitions of size_t and ssize_t.
|
|
26
|
+
* size_t can be obtained directly from <stddef.h> but ssize_t requires
|
|
27
|
+
* some hoop jumping on Windows that I didn't want to duplicate here.
|
|
28
|
+
*/
|
|
29
|
+
#include "uv.h"
|
|
30
|
+
|
|
31
|
+
/* Copies up to |n-1| bytes from |s| to |d| and always zero-terminates
|
|
32
|
+
* the result, except when |n==0|. Returns the number of bytes copied
|
|
33
|
+
* or UV_E2BIG if |d| is too small.
|
|
34
|
+
*
|
|
35
|
+
* See https://www.kernel.org/doc/htmldocs/kernel-api/API-strscpy.html
|
|
36
|
+
*/
|
|
37
|
+
ssize_t uv__strscpy(char* d, const char* s, size_t n);
|
|
38
|
+
|
|
39
|
+
#endif /* UV_STRSCPY_H_ */
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/* Copyright libuv project contributors. All rights reserved.
|
|
2
|
+
*
|
|
3
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
* of this software and associated documentation files (the "Software"), to
|
|
5
|
+
* deal in the Software without restriction, including without limitation the
|
|
6
|
+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
7
|
+
* sell copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
* furnished to do so, subject to the following conditions:
|
|
9
|
+
*
|
|
10
|
+
* The above copyright notice and this permission notice shall be included in
|
|
11
|
+
* all copies or substantial portions of the Software.
|
|
12
|
+
*
|
|
13
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
18
|
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
19
|
+
* IN THE SOFTWARE.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
#include <stdlib.h>
|
|
23
|
+
#include "strtok.h"
|
|
24
|
+
|
|
25
|
+
char* uv__strtok(char* str, const char* sep, char** itr) {
|
|
26
|
+
const char* sep_itr;
|
|
27
|
+
char* tmp;
|
|
28
|
+
char* start;
|
|
29
|
+
|
|
30
|
+
if (str == NULL)
|
|
31
|
+
start = tmp = *itr;
|
|
32
|
+
else
|
|
33
|
+
start = tmp = str;
|
|
34
|
+
|
|
35
|
+
if (tmp == NULL)
|
|
36
|
+
return NULL;
|
|
37
|
+
|
|
38
|
+
while (*tmp != '\0') {
|
|
39
|
+
sep_itr = sep;
|
|
40
|
+
while (*sep_itr != '\0') {
|
|
41
|
+
if (*tmp == *sep_itr) {
|
|
42
|
+
*itr = tmp + 1;
|
|
43
|
+
*tmp = '\0';
|
|
44
|
+
return start;
|
|
45
|
+
}
|
|
46
|
+
sep_itr++;
|
|
47
|
+
}
|
|
48
|
+
tmp++;
|
|
49
|
+
}
|
|
50
|
+
*itr = NULL;
|
|
51
|
+
return start;
|
|
52
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* Copyright libuv project contributors. All rights reserved.
|
|
2
|
+
*
|
|
3
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
* of this software and associated documentation files (the "Software"), to
|
|
5
|
+
* deal in the Software without restriction, including without limitation the
|
|
6
|
+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
7
|
+
* sell copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
* furnished to do so, subject to the following conditions:
|
|
9
|
+
*
|
|
10
|
+
* The above copyright notice and this permission notice shall be included in
|
|
11
|
+
* all copies or substantial portions of the Software.
|
|
12
|
+
*
|
|
13
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
18
|
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
19
|
+
* IN THE SOFTWARE.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
#ifndef UV_STRTOK_H_
|
|
23
|
+
#define UV_STRTOK_H_
|
|
24
|
+
|
|
25
|
+
char* uv__strtok(char* str, const char* sep, char** itr);
|
|
26
|
+
|
|
27
|
+
#endif /* UV_STRTOK_H_ */
|