summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore0
-rw-r--r--.idea/.gitignore5
-rw-r--r--.idea/ArgonCDN.iml12
-rw-r--r--.idea/jsLibraryMappings.xml6
-rw-r--r--.idea/modules.xml8
-rw-r--r--.idea/vcs.xml6
-rw-r--r--index.js147
-rw-r--r--node_modules/.package-lock.json51
-rw-r--r--node_modules/mime-db/HISTORY.md499
-rw-r--r--node_modules/mime-db/LICENSE22
-rw-r--r--node_modules/mime-db/README.md100
-rw-r--r--node_modules/mime-db/db.json8471
-rw-r--r--node_modules/mime-db/index.js11
-rw-r--r--node_modules/mime-db/package.json59
-rw-r--r--node_modules/mime-types/HISTORY.md388
-rw-r--r--node_modules/mime-types/LICENSE23
-rw-r--r--node_modules/mime-types/README.md113
-rw-r--r--node_modules/mime-types/index.js188
-rw-r--r--node_modules/mime-types/package.json44
-rw-r--r--node_modules/mmmagic/.travis.yml28
-rw-r--r--node_modules/mmmagic/LICENSE19
-rw-r--r--node_modules/mmmagic/README.md110
-rw-r--r--node_modules/mmmagic/appveyor.yml42
-rw-r--r--node_modules/mmmagic/binding.gyp33
-rw-r--r--node_modules/mmmagic/build/Makefile347
-rw-r--r--node_modules/mmmagic/build/Release/.deps/Release/magic.a.d1
-rw-r--r--node_modules/mmmagic/build/Release/.deps/Release/magic.node.d1
-rw-r--r--node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/apprentice.o.d8
-rw-r--r--node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/apptype.o.d7
-rw-r--r--node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/ascmagic.o.d8
-rw-r--r--node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/cdf.o.d8
-rw-r--r--node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/cdf_time.o.d8
-rw-r--r--node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/compress.o.d8
-rw-r--r--node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/der.o.d10
-rw-r--r--node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/encoding.o.d8
-rw-r--r--node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/fsmagic.o.d8
-rw-r--r--node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/funcs.o.d8
-rw-r--r--node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/is_tar.o.d10
-rw-r--r--node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/magic.o.d8
-rw-r--r--node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/print.o.d8
-rw-r--r--node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/readcdf.o.d10
-rw-r--r--node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/readelf.o.d11
-rw-r--r--node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/softmagic.o.d10
-rw-r--r--node_modules/mmmagic/build/Release/.deps/Release/obj.target/magic/src/binding.o.d142
-rw-r--r--node_modules/mmmagic/build/Release/magic.abin0 -> 560272 bytes
-rwxr-xr-xnode_modules/mmmagic/build/Release/magic.nodebin0 -> 197223 bytes
-rw-r--r--node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/apprentice.obin0 -> 116672 bytes
-rw-r--r--node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/apptype.obin0 -> 1880 bytes
-rw-r--r--node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/ascmagic.obin0 -> 14888 bytes
-rw-r--r--node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/cdf.obin0 -> 71632 bytes
-rw-r--r--node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/cdf_time.obin0 -> 9096 bytes
-rw-r--r--node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/compress.obin0 -> 30992 bytes
-rw-r--r--node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/der.obin0 -> 14776 bytes
-rw-r--r--node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/encoding.obin0 -> 15840 bytes
-rw-r--r--node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/fsmagic.obin0 -> 17160 bytes
-rw-r--r--node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/funcs.obin0 -> 32336 bytes
-rw-r--r--node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/is_tar.obin0 -> 12904 bytes
-rw-r--r--node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/magic.obin0 -> 22552 bytes
-rw-r--r--node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/print.obin0 -> 13208 bytes
-rw-r--r--node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/readcdf.obin0 -> 34144 bytes
-rw-r--r--node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/readelf.obin0 -> 76640 bytes
-rw-r--r--node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/softmagic.obin0 -> 71768 bytes
-rw-r--r--node_modules/mmmagic/build/Release/obj.target/magic/src/binding.obin0 -> 327496 bytes
-rw-r--r--node_modules/mmmagic/build/binding.Makefile6
-rw-r--r--node_modules/mmmagic/build/config.gypi372
-rw-r--r--node_modules/mmmagic/build/deps/libmagic/libmagic.Makefile6
-rw-r--r--node_modules/mmmagic/build/deps/libmagic/libmagic.target.mk211
-rwxr-xr-xnode_modules/mmmagic/build/gyp-mac-tool772
-rw-r--r--node_modules/mmmagic/build/magic.target.mk195
-rw-r--r--node_modules/mmmagic/deps/libmagic/AUTHORS1
-rw-r--r--node_modules/mmmagic/deps/libmagic/COPYING29
-rw-r--r--node_modules/mmmagic/deps/libmagic/ChangeLog1716
-rw-r--r--node_modules/mmmagic/deps/libmagic/INSTALL365
-rw-r--r--node_modules/mmmagic/deps/libmagic/MAINT44
-rw-r--r--node_modules/mmmagic/deps/libmagic/NEWS1
-rw-r--r--node_modules/mmmagic/deps/libmagic/README161
-rw-r--r--node_modules/mmmagic/deps/libmagic/TODO36
-rw-r--r--node_modules/mmmagic/deps/libmagic/config/freebsd/config.h365
-rw-r--r--node_modules/mmmagic/deps/libmagic/config/linux/config.h405
-rw-r--r--node_modules/mmmagic/deps/libmagic/config/mac/config.h360
-rw-r--r--node_modules/mmmagic/deps/libmagic/config/openbsd/config.h334
-rw-r--r--node_modules/mmmagic/deps/libmagic/config/sunos/config.h370
-rw-r--r--node_modules/mmmagic/deps/libmagic/config/win/config.h367
-rw-r--r--node_modules/mmmagic/deps/libmagic/libmagic.gyp85
-rw-r--r--node_modules/mmmagic/deps/libmagic/msvc/dirent.h372
-rw-r--r--node_modules/mmmagic/deps/libmagic/msvc/inttypes.h305
-rw-r--r--node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/COPYING.LIB510
-rw-r--r--node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/Makefile41
-rw-r--r--node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/README33
-rw-r--r--node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/README.md10
-rw-r--r--node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/regcomp.c3800
-rw-r--r--node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/regex.c74
-rw-r--r--node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/regex.h556
-rw-r--r--node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/regex_internal.c1717
-rw-r--r--node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/regex_internal.h778
-rw-r--r--node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/regexec.c4329
-rw-r--r--node_modules/mmmagic/deps/libmagic/msvc/stdint.h247
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/BNF151
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/apprentice.c3429
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/apptype.c169
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/ascmagic.c361
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/asctime_r.c19
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/asprintf.c45
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/cdf.c1629
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/cdf.h352
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/cdf_time.c198
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/compress.c762
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/ctime_r.c19
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/der.c409
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/der.h28
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/dprintf.c61
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/elfclass.h82
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/encoding.c529
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/file.c640
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/file.h653
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/file_opts.h58
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/fmtcheck.c251
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/fsmagic.c418
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/funcs.c603
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/getline.c107
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/getopt_long.c498
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/gmtime_r.c19
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/is_tar.c159
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/localtime_r.c19
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/magic.c662
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/magic.h156
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/mygetopt.h68
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/pread.c26
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/print.c264
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/readcdf.c680
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/readelf.c1640
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/readelf.h433
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/snprintf.c26
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/softmagic.c2076
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/strcasestr.c84
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/strlcat.c58
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/strlcpy.c54
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/tar.h73
-rw-r--r--node_modules/mmmagic/deps/libmagic/src/vasprintf.c27
-rw-r--r--node_modules/mmmagic/lib/index.js28
-rw-r--r--node_modules/mmmagic/magic/magic.mgcbin0 -> 4964608 bytes
-rw-r--r--node_modules/mmmagic/package.json35
-rw-r--r--node_modules/mmmagic/src/binding.cc416
-rw-r--r--node_modules/mmmagic/test/fixtures/tést.txt8
-rw-r--r--node_modules/mmmagic/test/test.js134
-rw-r--r--node_modules/nan/CHANGELOG.md541
-rw-r--r--node_modules/nan/LICENSE.md13
-rw-r--r--node_modules/nan/README.md456
-rw-r--r--node_modules/nan/doc/asyncworker.md146
-rw-r--r--node_modules/nan/doc/buffers.md54
-rw-r--r--node_modules/nan/doc/callback.md76
-rw-r--r--node_modules/nan/doc/converters.md41
-rw-r--r--node_modules/nan/doc/errors.md226
-rw-r--r--node_modules/nan/doc/json.md62
-rw-r--r--node_modules/nan/doc/maybe_types.md583
-rw-r--r--node_modules/nan/doc/methods.md664
-rw-r--r--node_modules/nan/doc/new.md147
-rw-r--r--node_modules/nan/doc/node_misc.md123
-rw-r--r--node_modules/nan/doc/object_wrappers.md263
-rw-r--r--node_modules/nan/doc/persistent.md296
-rw-r--r--node_modules/nan/doc/scopes.md73
-rw-r--r--node_modules/nan/doc/script.md58
-rw-r--r--node_modules/nan/doc/string_bytes.md62
-rw-r--r--node_modules/nan/doc/v8_internals.md199
-rw-r--r--node_modules/nan/doc/v8_misc.md85
-rw-r--r--node_modules/nan/include_dirs.js1
-rw-r--r--node_modules/nan/nan.h2904
-rw-r--r--node_modules/nan/nan_callbacks.h88
-rw-r--r--node_modules/nan/nan_callbacks_12_inl.h514
-rw-r--r--node_modules/nan/nan_callbacks_pre_12_inl.h520
-rw-r--r--node_modules/nan/nan_converters.h72
-rw-r--r--node_modules/nan/nan_converters_43_inl.h68
-rw-r--r--node_modules/nan/nan_converters_pre_43_inl.h42
-rw-r--r--node_modules/nan/nan_define_own_property_helper.h29
-rw-r--r--node_modules/nan/nan_implementation_12_inl.h430
-rw-r--r--node_modules/nan/nan_implementation_pre_12_inl.h263
-rw-r--r--node_modules/nan/nan_json.h166
-rw-r--r--node_modules/nan/nan_maybe_43_inl.h356
-rw-r--r--node_modules/nan/nan_maybe_pre_43_inl.h268
-rw-r--r--node_modules/nan/nan_new.h340
-rw-r--r--node_modules/nan/nan_object_wrap.h156
-rw-r--r--node_modules/nan/nan_persistent_12_inl.h132
-rw-r--r--node_modules/nan/nan_persistent_pre_12_inl.h242
-rw-r--r--node_modules/nan/nan_private.h73
-rw-r--r--node_modules/nan/nan_scriptorigin.h76
-rw-r--r--node_modules/nan/nan_string_bytes.h305
-rw-r--r--node_modules/nan/nan_typedarray_contents.h96
-rw-r--r--node_modules/nan/nan_weak.h437
-rw-r--r--node_modules/nan/package.json37
-rwxr-xr-xnode_modules/nan/tools/1to2.js412
-rw-r--r--node_modules/nan/tools/README.md14
-rw-r--r--node_modules/nan/tools/package.json19
-rw-r--r--node_modules/uuid-v4/index.js28
-rw-r--r--node_modules/uuid-v4/package.json13
-rw-r--r--node_modules/uuid-v4/readme.md33
-rw-r--r--package-lock.json91
-rw-r--r--package.json7
197 files changed, 61003 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.gitignore
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..b58b603
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,5 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
diff --git a/.idea/ArgonCDN.iml b/.idea/ArgonCDN.iml
new file mode 100644
index 0000000..0c8867d
--- /dev/null
+++ b/.idea/ArgonCDN.iml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="WEB_MODULE" version="4">
+ <component name="NewModuleRootManager">
+ <content url="file://$MODULE_DIR$">
+ <excludeFolder url="file://$MODULE_DIR$/temp" />
+ <excludeFolder url="file://$MODULE_DIR$/.tmp" />
+ <excludeFolder url="file://$MODULE_DIR$/tmp" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ </component>
+</module> \ No newline at end of file
diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml
new file mode 100644
index 0000000..d23208f
--- /dev/null
+++ b/.idea/jsLibraryMappings.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="JavaScriptLibraryMappings">
+ <includedPredefinedLibrary name="Node.js Core" />
+ </component>
+</project> \ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..0ec45a1
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="ProjectModuleManager">
+ <modules>
+ <module fileurl="file://$PROJECT_DIR$/.idea/ArgonCDN.iml" filepath="$PROJECT_DIR$/.idea/ArgonCDN.iml" />
+ </modules>
+ </component>
+</project> \ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="VcsDirectoryMappings">
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
+ </component>
+</project> \ No newline at end of file
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..4b79fce
--- /dev/null
+++ b/index.js
@@ -0,0 +1,147 @@
+const http = require('http');
+const https = require('https');
+const fs = require('fs');
+const crypto = require('crypto');
+const path = require('path');
+const uuid = require('uuid-v4');
+const mime = require('mime-types')
+
+global.streams = [];
+
+function fallback(req, res) {
+ res.writeHead(400);
+ res.end("400 Bad Request");
+}
+
+function missing(req, res) {
+ res.writeHead(400);
+ res.end('400 Bad Request');
+}
+
+function forbid(req, res) {
+ res.writeHead(425);
+ res.end('403 Forbidden');
+}
+
+function notfound(req, res) {
+ res.writeHead(404);
+ res.end('404 Not Found');
+}
+
+function invalid(req, res) {
+ res.writeHead(401);
+ res.end('400 Bad Request');
+}
+
+function placeholder(req, res) {
+ res.writeHead(302);
+ res.end("302 Found");
+}
+
+const requestListener = function(req, res) {
+ let uid = uuid();
+ console.log(uid);
+ temp[uid] = {};
+
+ req.on('end', () => {
+ process.stdout.write("-");
+ delete temp[uid];
+ process.stdout.write("-\n");
+ })
+
+ let userIp;
+ userIp = req.socket.address().address;
+ if (req.headers["x-forwarded-for"] !== undefined) {
+ userIp = req.headers["x-forwarded-for"]
+ }
+
+ temp[uid].parts = req.url.split("/").filter(i => i.trim() !== "");
+ console.log(temp[uid].parts, req.headers["user-agent"], req.socket.address().address);
+
+ if (temp[uid].parts.length >= 2) {
+ if (temp[uid].parts.length === 3 && temp[uid].parts[0] === "authorize") {
+ let song = temp[uid].parts[1].replace(/[^0-9a-f]/gm, "");
+ let quality = temp[uid].parts[2].replace(/[^a-z]/gm, "");
+ let ua
+ try {
+ ua = temp[uid].parts[3].replace(/[^a-z]/gm, "");
+ } catch (e) {
+ ua = Buffer.from(req.headers["user-agent"]).toString("base64");
+ }
+ let ip
+ try {
+ ip = temp[uid].parts[4].replace(/[^a-z]/gm, "");
+ } catch (e) {
+ ip = Buffer.from(req.socket.address().address).toString("base64");
+ }
+ let id = crypto.createHash('sha512').update(crypto.randomBytes(128).toString("base64")).digest('hex');
+ streams.push({
+ song,
+ quality: crypto.createHash('md5').update(quality).digest('hex'),
+ id,
+ user: Buffer.from(ua, "base64").toString(),
+ ip: Buffer.from(ip, "base64").toString(),
+ created: new Date()
+ })
+ res.write("/stream/" + song + "/" + crypto.createHash('md5').update(quality).digest('hex') + "/" + id);
+ res.end();
+ } else if (temp[uid].parts.length === 4 && temp[uid].parts[0] === "stream") {
+ let song = temp[uid].parts[1].replace(/[^0-9a-f]/gm, "");
+ let quality = temp[uid].parts[2].replace(/[^0-9a-f]/gm, "");
+ let stream = temp[uid].parts[3].replace(/[^0-9a-f]/gm, "");
+
+ if (fs.existsSync("./files/" + song)) {
+ console.log(fs.readdirSync("./files/" + song).filter((i) => i.split(".")[0].split("-")[1] !== undefined).map((i) => { return [ i, i.split(".")[0].split("-")[1], crypto.createHash('md5').update(i.split(".")[0].split("-")[1]).digest('hex') ] }));
+ let selected = fs.readdirSync("./files/" + song).filter((i) => i.split(".")[0].split("-")[1] !== undefined).filter((i) => crypto.createHash('md5').update(i.split(".")[0].split("-")[1]).digest('hex') === quality);
+
+ if (selected.length > 0) {
+ if (streams.map((i) => { return i.id; }).includes(stream)) {
+ if (streams.filter(i => i.id === stream)[0].user === req.headers["user-agent"] && streams.filter(i => i.id === stream)[0].ip === req.socket.address().address && streams.filter(i => i.id === stream)[0].song === song && streams.filter(i => i.id === stream)[0].quality === quality) {
+ streams.filter(i => i.id === stream)[0].created = new Date();
+ res.writeHead(200, {
+ 'Content-Type': mime.lookup(selected[0]) || 'application/octet-stream',
+ 'Cache-Control': 'no-cache, must-revalidate',
+ 'Content-Disposition': 'inline',
+ 'Expires': '0',
+ 'Content-Length': fs.statSync("./files/" + song + "/" + selected[0]).size
+ });
+
+ let readStream = fs.createReadStream("./files/" + song + "/" + selected[0]);
+ readStream.pipe(res);
+ } else {
+ forbid(req, res);
+ }
+ } else {
+ forbid(req, res);
+ }
+ } else {
+ notfound(req, res);
+ }
+ } else {
+ notfound(req, res);
+ }
+ } else {
+ invalid(req, res);
+ }
+ } else {
+ invalid(req, res);
+ }
+}
+
+const server = http.createServer((req, res) => {
+ global.temp = {};
+ console.log("Listening")
+
+ setInterval(() => {
+ global.streams = streams.filter(i => new Date() - i.created < 3600000);
+ }, 10000)
+
+ try {
+ requestListener(req, res);
+ } catch (e) {
+ console.error(e);
+ res.writeHead(500);
+ res.end('500 Internal Server Error');
+ }
+});
+server.listen(8875); \ No newline at end of file
diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json
new file mode 100644
index 0000000..7dbb1dc
--- /dev/null
+++ b/node_modules/.package-lock.json
@@ -0,0 +1,51 @@
+{
+ "name": "ArgonCDN",
+ "lockfileVersion": 2,
+ "requires": true,
+ "packages": {
+ "node_modules/mime-db": {
+ "version": "1.51.0",
+ "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz",
+ "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/mime-types": {
+ "version": "2.1.34",
+ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz",
+ "integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==",
+ "dependencies": {
+ "mime-db": "1.51.0"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/mmmagic": {
+ "version": "0.5.3",
+ "resolved": "https://registry.npmjs.org/mmmagic/-/mmmagic-0.5.3.tgz",
+ "integrity": "sha512-xLqCu7GJYTzJczg0jafXFuh+iPzQL/ru0YYf4GiTTz8Cehru/wiXtUS8Pp8Xi77zNaiVndJ0OO1yAFci6iHyFg==",
+ "hasInstallScript": true,
+ "dependencies": {
+ "nan": "^2.13.2"
+ },
+ "engines": {
+ "node": ">=4.0.0"
+ }
+ },
+ "node_modules/nan": {
+ "version": "2.15.0",
+ "resolved": "https://registry.npmjs.org/nan/-/nan-2.15.0.tgz",
+ "integrity": "sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ=="
+ },
+ "node_modules/uuid-v4": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/uuid-v4/-/uuid-v4-0.1.0.tgz",
+ "integrity": "sha1-YtezEEBvbOz+oVKMafHo4LzsWjo=",
+ "engines": {
+ "node": "*"
+ }
+ }
+ }
+}
diff --git a/node_modules/mime-db/HISTORY.md b/node_modules/mime-db/HISTORY.md
new file mode 100644
index 0000000..68428f1
--- /dev/null
+++ b/node_modules/mime-db/HISTORY.md
@@ -0,0 +1,499 @@
+1.51.0 / 2021-11-08
+===================
+
+ * Add new upstream MIME types
+ * Mark `image/vnd.microsoft.icon` as compressible
+ * Mark `image/vnd.ms-dds` as compressible
+
+1.50.0 / 2021-09-15
+===================
+
+ * Add deprecated iWorks mime types and extensions
+ * Add new upstream MIME types
+
+1.49.0 / 2021-07-26
+===================
+
+ * Add extension `.trig` to `application/trig`
+ * Add new upstream MIME types
+
+1.48.0 / 2021-05-30
+===================
+
+ * Add extension `.mvt` to `application/vnd.mapbox-vector-tile`
+ * Add new upstream MIME types
+ * Mark `text/yaml` as compressible
+
+1.47.0 / 2021-04-01
+===================
+
+ * Add new upstream MIME types
+ * Remove ambigious extensions from IANA for `application/*+xml` types
+ * Update primary extension to `.es` for `application/ecmascript`
+
+1.46.0 / 2021-02-13
+===================
+
+ * Add extension `.amr` to `audio/amr`
+ * Add extension `.m4s` to `video/iso.segment`
+ * Add extension `.opus` to `audio/ogg`
+ * Add new upstream MIME types
+
+1.45.0 / 2020-09-22
+===================
+
+ * Add `application/ubjson` with extension `.ubj`
+ * Add `image/avif` with extension `.avif`
+ * Add `image/ktx2` with extension `.ktx2`
+ * Add extension `.dbf` to `application/vnd.dbf`
+ * Add extension `.rar` to `application/vnd.rar`
+ * Add extension `.td` to `application/urc-targetdesc+xml`
+ * Add new upstream MIME types
+ * Fix extension of `application/vnd.apple.keynote` to be `.key`
+
+1.44.0 / 2020-04-22
+===================
+
+ * Add charsets from IANA
+ * Add extension `.cjs` to `application/node`
+ * Add new upstream MIME types
+
+1.43.0 / 2020-01-05
+===================
+
+ * Add `application/x-keepass2` with extension `.kdbx`
+ * Add extension `.mxmf` to `audio/mobile-xmf`
+ * Add extensions from IANA for `application/*+xml` types
+ * Add new upstream MIME types
+
+1.42.0 / 2019-09-25
+===================
+
+ * Add `image/vnd.ms-dds` with extension `.dds`
+ * Add new upstream MIME types
+ * Remove compressible from `multipart/mixed`
+
+1.41.0 / 2019-08-30
+===================
+
+ * Add new upstream MIME types
+ * Add `application/toml` with extension `.toml`
+ * Mark `font/ttf` as compressible
+
+1.40.0 / 2019-04-20
+===================
+
+ * Add extensions from IANA for `model/*` types
+ * Add `text/mdx` with extension `.mdx`
+
+1.39.0 / 2019-04-04
+===================
+
+ * Add extensions `.siv` and `.sieve` to `application/sieve`
+ * Add new upstream MIME types
+
+1.38.0 / 2019-02-04
+===================
+
+ * Add extension `.nq` to `application/n-quads`
+ * Add extension `.nt` to `application/n-triples`
+ * Add new upstream MIME types
+ * Mark `text/less` as compressible
+
+1.37.0 / 2018-10-19
+===================
+
+ * Add extensions to HEIC image types
+ * Add new upstream MIME types
+
+1.36.0 / 2018-08-20
+===================
+
+ * Add Apple file extensions from IANA
+ * Add extensions from IANA for `image/*` types
+ * Add new upstream MIME types
+
+1.35.0 / 2018-07-15
+===================
+
+ * Add extension `.owl` to `application/rdf+xml`
+ * Add new upstream MIME types
+ - Removes extension `.woff` from `application/font-woff`
+
+1.34.0 / 2018-06-03
+===================
+
+ * Add extension `.csl` to `application/vnd.citationstyles.style+xml`
+ * Add extension `.es` to `application/ecmascript`
+ * Add new upstream MIME types
+ * Add `UTF-8` as default charset for `text/turtle`
+ * Mark all XML-derived types as compressible
+
+1.33.0 / 2018-02-15
+===================
+
+ * Add extensions from IANA for `message/*` types
+ * Add new upstream MIME types
+ * Fix some incorrect OOXML types
+ * Remove `application/font-woff2`
+
+1.32.0 / 2017-11-29
+===================
+
+ * Add new upstream MIME types
+ * Update `text/hjson` to registered `application/hjson`
+ * Add `text/shex` with extension `.shex`
+
+1.31.0 / 2017-10-25
+===================
+
+ * Add `application/raml+yaml` with extension `.raml`
+ * Add `application/wasm` with extension `.wasm`
+ * Add new `font` type from IANA
+ * Add new upstream font extensions
+ * Add new upstream MIME types
+ * Add extensions for JPEG-2000 images
+
+1.30.0 / 2017-08-27
+===================
+
+ * Add `application/vnd.ms-outlook`
+ * Add `application/x-arj`
+ * Add extension `.mjs` to `application/javascript`
+ * Add glTF types and extensions
+ * Add new upstream MIME types
+ * Add `text/x-org`
+ * Add VirtualBox MIME types
+ * Fix `source` records for `video/*` types that are IANA
+ * Update `font/opentype` to registered `font/otf`
+
+1.29.0 / 2017-07-10
+===================
+
+ * Add `application/fido.trusted-apps+json`
+ * Add extension `.wadl` to `application/vnd.sun.wadl+xml`
+ * Add new upstream MIME types
+ * Add `UTF-8` as default charset for `text/css`
+
+1.28.0 / 2017-05-14
+===================
+
+ * Add new upstream MIME types
+ * Add extension `.gz` to `application/gzip`
+ * Update extensions `.md` and `.markdown` to be `text/markdown`
+
+1.27.0 / 2017-03-16
+===================
+
+ * Add new upstream MIME types
+ * Add `image/apng` with extension `.apng`
+
+1.26.0 / 2017-01-14
+===================
+
+ * Add new upstream MIME types
+ * Add extension `.geojson` to `application/geo+json`
+
+1.25.0 / 2016-11-11
+===================
+
+ * Add new upstream MIME types
+
+1.24.0 / 2016-09-18
+===================
+
+ * Add `audio/mp3`
+ * Add new upstream MIME types
+
+1.23.0 / 2016-05-01
+===================
+
+ * Add new upstream MIME types
+ * Add extension `.3gpp` to `audio/3gpp`
+
+1.22.0 / 2016-02-15
+===================
+
+ * Add `text/slim`
+ * Add extension `.rng` to `application/xml`
+ * Add new upstream MIME types
+ * Fix extension of `application/dash+xml` to be `.mpd`
+ * Update primary extension to `.m4a` for `audio/mp4`
+
+1.21.0 / 2016-01-06
+===================
+
+ * Add Google document types
+ * Add new upstream MIME types
+
+1.20.0 / 2015-11-10
+===================
+
+ * Add `text/x-suse-ymp`
+ * Add new upstream MIME types
+
+1.19.0 / 2015-09-17
+===================
+
+ * Add `application/vnd.apple.pkpass`
+ * Add new upstream MIME types
+
+1.18.0 / 2015-09-03
+===================
+
+ * Add new upstream MIME types
+
+1.17.0 / 2015-08-13
+===================
+
+ * Add `application/x-msdos-program`
+ * Add `audio/g711-0`
+ * Add `image/vnd.mozilla.apng`
+ * Add extension `.exe` to `application/x-msdos-program`
+
+1.16.0 / 2015-07-29
+===================
+
+ * Add `application/vnd.uri-map`
+
+1.15.0 / 2015-07-13
+===================
+
+ * Add `application/x-httpd-php`
+
+1.14.0 / 2015-06-25
+===================
+
+ * Add `application/scim+json`
+ * Add `application/vnd.3gpp.ussd+xml`
+ * Add `application/vnd.biopax.rdf+xml`
+ * Add `text/x-processing`
+
+1.13.0 / 2015-06-07
+===================
+
+ * Add nginx as a source
+ * Add `application/x-cocoa`
+ * Add `application/x-java-archive-diff`
+ * Add `application/x-makeself`
+ * Add `application/x-perl`
+ * Add `application/x-pilot`
+ * Add `application/x-redhat-package-manager`
+ * Add `application/x-sea`
+ * Add `audio/x-m4a`
+ * Add `audio/x-realaudio`
+ * Add `image/x-jng`
+ * Add `text/mathml`
+
+1.12.0 / 2015-06-05
+===================
+
+ * Add `application/bdoc`
+ * Add `application/vnd.hyperdrive+json`
+ * Add `application/x-bdoc`
+ * Add extension `.rtf` to `text/rtf`
+
+1.11.0 / 2015-05-31
+===================
+
+ * Add `audio/wav`
+ * Add `audio/wave`
+ * Add extension `.litcoffee` to `text/coffeescript`
+ * Add extension `.sfd-hdstx` to `application/vnd.hydrostatix.sof-data`
+ * Add extension `.n-gage` to `application/vnd.nokia.n-gage.symbian.install`
+
+1.10.0 / 2015-05-19
+===================
+
+ * Add `application/vnd.balsamiq.bmpr`
+ * Add `application/vnd.microsoft.portable-executable`
+ * Add `application/x-ns-proxy-autoconfig`
+
+1.9.1 / 2015-04-19
+==================
+
+ * Remove `.json` extension from `application/manifest+json`
+ - This is causing bugs downstream
+
+1.9.0 / 2015-04-19
+==================
+
+ * Add `application/manifest+json`
+ * Add `application/vnd.micro+json`
+ * Add `image/vnd.zbrush.pcx`
+ * Add `image/x-ms-bmp`
+
+1.8.0 / 2015-03-13
+==================
+
+ * Add `application/vnd.citationstyles.style+xml`
+ * Add `application/vnd.fastcopy-disk-image`
+ * Add `application/vnd.gov.sk.xmldatacontainer+xml`
+ * Add extension `.jsonld` to `application/ld+json`
+
+1.7.0 / 2015-02-08
+==================
+
+ * Add `application/vnd.gerber`
+ * Add `application/vnd.msa-disk-image`
+
+1.6.1 / 2015-02-05
+==================
+
+ * Community extensions ownership transferred from `node-mime`
+
+1.6.0 / 2015-01-29
+==================
+
+ * Add `application/jose`
+ * Add `application/jose+json`
+ * Add `application/json-seq`
+ * Add `application/jwk+json`
+ * Add `application/jwk-set+json`
+ * Add `application/jwt`
+ * Add `application/rdap+json`
+ * Add `application/vnd.gov.sk.e-form+xml`
+ * Add `application/vnd.ims.imsccv1p3`
+
+1.5.0 / 2014-12-30
+==================
+
+ * Add `application/vnd.oracle.resource+json`
+ * Fix various invalid MIME type entries
+ - `application/mbox+xml`
+ - `application/oscp-response`
+ - `application/vwg-multiplexed`
+ - `audio/g721`
+
+1.4.0 / 2014-12-21
+==================
+
+ * Add `application/vnd.ims.imsccv1p2`
+ * Fix various invalid MIME type entries
+ - `application/vnd-acucobol`
+ - `application/vnd-curl`
+ - `application/vnd-dart`
+ - `application/vnd-dxr`
+ - `application/vnd-fdf`
+ - `application/vnd-mif`
+ - `application/vnd-sema`
+ - `application/vnd-wap-wmlc`
+ - `application/vnd.adobe.flash-movie`
+ - `application/vnd.dece-zip`
+ - `application/vnd.dvb_service`
+ - `application/vnd.micrografx-igx`
+ - `application/vnd.sealed-doc`
+ - `application/vnd.sealed-eml`
+ - `application/vnd.sealed-mht`
+ - `application/vnd.sealed-ppt`
+ - `application/vnd.sealed-tiff`
+ - `application/vnd.sealed-xls`
+ - `application/vnd.sealedmedia.softseal-html`
+ - `application/vnd.sealedmedia.softseal-pdf`
+ - `application/vnd.wap-slc`
+ - `application/vnd.wap-wbxml`
+ - `audio/vnd.sealedmedia.softseal-mpeg`
+ - `image/vnd-djvu`
+ - `image/vnd-svf`
+ - `image/vnd-wap-wbmp`
+ - `image/vnd.sealed-png`
+ - `image/vnd.sealedmedia.softseal-gif`
+ - `image/vnd.sealedmedia.softseal-jpg`
+ - `model/vnd-dwf`
+ - `model/vnd.parasolid.transmit-binary`
+ - `model/vnd.parasolid.transmit-text`
+ - `text/vnd-a`
+ - `text/vnd-curl`
+ - `text/vnd.wap-wml`
+ * Remove example template MIME types
+ - `application/example`
+ - `audio/example`
+ - `image/example`
+ - `message/example`
+ - `model/example`
+ - `multipart/example`
+ - `text/example`
+ - `video/example`
+
+1.3.1 / 2014-12-16
+==================
+
+ * Fix missing extensions
+ - `application/json5`
+ - `text/hjson`
+
+1.3.0 / 2014-12-07
+==================
+
+ * Add `application/a2l`
+ * Add `application/aml`
+ * Add `application/atfx`
+ * Add `application/atxml`
+ * Add `application/cdfx+xml`
+ * Add `application/dii`
+ * Add `application/json5`
+ * Add `application/lxf`
+ * Add `application/mf4`
+ * Add `application/vnd.apache.thrift.compact`
+ * Add `application/vnd.apache.thrift.json`
+ * Add `application/vnd.coffeescript`
+ * Add `application/vnd.enphase.envoy`
+ * Add `application/vnd.ims.imsccv1p1`
+ * Add `text/csv-schema`
+ * Add `text/hjson`
+ * Add `text/markdown`
+ * Add `text/yaml`
+
+1.2.0 / 2014-11-09
+==================
+
+ * Add `application/cea`
+ * Add `application/dit`
+ * Add `application/vnd.gov.sk.e-form+zip`
+ * Add `application/vnd.tmd.mediaflex.api+xml`
+ * Type `application/epub+zip` is now IANA-registered
+
+1.1.2 / 2014-10-23
+==================
+
+ * Rebuild database for `application/x-www-form-urlencoded` change
+
+1.1.1 / 2014-10-20
+==================
+
+ * Mark `application/x-www-form-urlencoded` as compressible.
+
+1.1.0 / 2014-09-28
+==================
+
+ * Add `application/font-woff2`
+
+1.0.3 / 2014-09-25
+==================
+
+ * Fix engine requirement in package
+
+1.0.2 / 2014-09-25
+==================
+
+ * Add `application/coap-group+json`
+ * Add `application/dcd`
+ * Add `application/vnd.apache.thrift.binary`
+ * Add `image/vnd.tencent.tap`
+ * Mark all JSON-derived types as compressible
+ * Update `text/vtt` data
+
+1.0.1 / 2014-08-30
+==================
+
+ * Fix extension ordering
+
+1.0.0 / 2014-08-30
+==================
+
+ * Add `application/atf`
+ * Add `application/merge-patch+json`
+ * Add `multipart/x-mixed-replace`
+ * Add `source: 'apache'` metadata
+ * Add `source: 'iana'` metadata
+ * Remove badly-assumed charset data
diff --git a/node_modules/mime-db/LICENSE b/node_modules/mime-db/LICENSE
new file mode 100644
index 0000000..a7ae8ee
--- /dev/null
+++ b/node_modules/mime-db/LICENSE
@@ -0,0 +1,22 @@
+
+The MIT License (MIT)
+
+Copyright (c) 2014 Jonathan Ong me@jongleberry.com
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/node_modules/mime-db/README.md b/node_modules/mime-db/README.md
new file mode 100644
index 0000000..41c696a
--- /dev/null
+++ b/node_modules/mime-db/README.md
@@ -0,0 +1,100 @@
+# mime-db
+
+[![NPM Version][npm-version-image]][npm-url]
+[![NPM Downloads][npm-downloads-image]][npm-url]
+[![Node.js Version][node-image]][node-url]
+[![Build Status][ci-image]][ci-url]
+[![Coverage Status][coveralls-image]][coveralls-url]
+
+This is a database of all mime types.
+It consists of a single, public JSON file and does not include any logic,
+allowing it to remain as un-opinionated as possible with an API.
+It aggregates data from the following sources:
+
+- http://www.iana.org/assignments/media-types/media-types.xhtml
+- http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
+- http://hg.nginx.org/nginx/raw-file/default/conf/mime.types
+
+## Installation
+
+```bash
+npm install mime-db
+```
+
+### Database Download
+
+If you're crazy enough to use this in the browser, you can just grab the
+JSON file using [jsDelivr](https://www.jsdelivr.com/). It is recommended to
+replace `master` with [a release tag](https://github.com/jshttp/mime-db/tags)
+as the JSON format may change in the future.
+
+```
+https://cdn.jsdelivr.net/gh/jshttp/mime-db@master/db.json
+```
+
+## Usage
+
+```js
+var db = require('mime-db')
+
+// grab data on .js files
+var data = db['application/javascript']
+```
+
+## Data Structure
+
+The JSON file is a map lookup for lowercased mime types.
+Each mime type has the following properties:
+
+- `.source` - where the mime type is defined.
+ If not set, it's probably a custom media type.
+ - `apache` - [Apache common media types](http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types)
+ - `iana` - [IANA-defined media types](http://www.iana.org/assignments/media-types/media-types.xhtml)
+ - `nginx` - [nginx media types](http://hg.nginx.org/nginx/raw-file/default/conf/mime.types)
+- `.extensions[]` - known extensions associated with this mime type.
+- `.compressible` - whether a file of this type can be gzipped.
+- `.charset` - the default charset associated with this type, if any.
+
+If unknown, every property could be `undefined`.
+
+## Contributing
+
+To edit the database, only make PRs against `src/custom-types.json` or
+`src/custom-suffix.json`.
+
+The `src/custom-types.json` file is a JSON object with the MIME type as the
+keys and the values being an object with the following keys:
+
+- `compressible` - leave out if you don't know, otherwise `true`/`false` to
+ indicate whether the data represented by the type is typically compressible.
+- `extensions` - include an array of file extensions that are associated with
+ the type.
+- `notes` - human-readable notes about the type, typically what the type is.
+- `sources` - include an array of URLs of where the MIME type and the associated
+ extensions are sourced from. This needs to be a [primary source](https://en.wikipedia.org/wiki/Primary_source);
+ links to type aggregating sites and Wikipedia are _not acceptable_.
+
+To update the build, run `npm run build`.
+
+### Adding Custom Media Types
+
+The best way to get new media types included in this library is to register
+them with the IANA. The community registration procedure is outlined in
+[RFC 6838 section 5](http://tools.ietf.org/html/rfc6838#section-5). Types
+registered with the IANA are automatically pulled into this library.
+
+If that is not possible / feasible, they can be added directly here as a
+"custom" type. To do this, it is required to have a primary source that
+definitively lists the media type. If an extension is going to be listed as
+associateed with this media type, the source must definitively link the
+media type and extension as well.
+
+[ci-image]: https://badgen.net/github/checks/jshttp/mime-db/master?label=ci
+[ci-url]: https://github.com/jshttp/mime-db/actions?query=workflow%3Aci
+[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/mime-db/master
+[coveralls-url]: https://coveralls.io/r/jshttp/mime-db?branch=master
+[node-image]: https://badgen.net/npm/node/mime-db
+[node-url]: https://nodejs.org/en/download
+[npm-downloads-image]: https://badgen.net/npm/dm/mime-db
+[npm-url]: https://npmjs.org/package/mime-db
+[npm-version-image]: https://badgen.net/npm/v/mime-db
diff --git a/node_modules/mime-db/db.json b/node_modules/mime-db/db.json
new file mode 100644
index 0000000..a31a6e5
--- /dev/null
+++ b/node_modules/mime-db/db.json
@@ -0,0 +1,8471 @@
+{
+ "application/1d-interleaved-parityfec": {
+ "source": "iana"
+ },
+ "application/3gpdash-qoe-report+xml": {
+ "source": "iana",
+ "charset": "UTF-8",
+ "compressible": true
+ },
+ "application/3gpp-ims+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/3gpphal+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/3gpphalforms+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/a2l": {
+ "source": "iana"
+ },
+ "application/ace+cbor": {
+ "source": "iana"
+ },
+ "application/activemessage": {
+ "source": "iana"
+ },
+ "application/activity+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/alto-costmap+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/alto-costmapfilter+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/alto-directory+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/alto-endpointcost+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/alto-endpointcostparams+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/alto-endpointprop+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/alto-endpointpropparams+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/alto-error+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/alto-networkmap+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/alto-networkmapfilter+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/alto-updatestreamcontrol+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/alto-updatestreamparams+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/aml": {
+ "source": "iana"
+ },
+ "application/andrew-inset": {
+ "source": "iana",
+ "extensions": ["ez"]
+ },
+ "application/applefile": {
+ "source": "iana"
+ },
+ "application/applixware": {
+ "source": "apache",
+ "extensions": ["aw"]
+ },
+ "application/at+jwt": {
+ "source": "iana"
+ },
+ "application/atf": {
+ "source": "iana"
+ },
+ "application/atfx": {
+ "source": "iana"
+ },
+ "application/atom+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["atom"]
+ },
+ "application/atomcat+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["atomcat"]
+ },
+ "application/atomdeleted+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["atomdeleted"]
+ },
+ "application/atomicmail": {
+ "source": "iana"
+ },
+ "application/atomsvc+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["atomsvc"]
+ },
+ "application/atsc-dwd+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["dwd"]
+ },
+ "application/atsc-dynamic-event-message": {
+ "source": "iana"
+ },
+ "application/atsc-held+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["held"]
+ },
+ "application/atsc-rdt+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/atsc-rsat+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["rsat"]
+ },
+ "application/atxml": {
+ "source": "iana"
+ },
+ "application/auth-policy+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/bacnet-xdd+zip": {
+ "source": "iana",
+ "compressible": false
+ },
+ "application/batch-smtp": {
+ "source": "iana"
+ },
+ "application/bdoc": {
+ "compressible": false,
+ "extensions": ["bdoc"]
+ },
+ "application/beep+xml": {
+ "source": "iana",
+ "charset": "UTF-8",
+ "compressible": true
+ },
+ "application/calendar+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/calendar+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["xcs"]
+ },
+ "application/call-completion": {
+ "source": "iana"
+ },
+ "application/cals-1840": {
+ "source": "iana"
+ },
+ "application/captive+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/cbor": {
+ "source": "iana"
+ },
+ "application/cbor-seq": {
+ "source": "iana"
+ },
+ "application/cccex": {
+ "source": "iana"
+ },
+ "application/ccmp+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/ccxml+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["ccxml"]
+ },
+ "application/cdfx+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["cdfx"]
+ },
+ "application/cdmi-capability": {
+ "source": "iana",
+ "extensions": ["cdmia"]
+ },
+ "application/cdmi-container": {
+ "source": "iana",
+ "extensions": ["cdmic"]
+ },
+ "application/cdmi-domain": {
+ "source": "iana",
+ "extensions": ["cdmid"]
+ },
+ "application/cdmi-object": {
+ "source": "iana",
+ "extensions": ["cdmio"]
+ },
+ "application/cdmi-queue": {
+ "source": "iana",
+ "extensions": ["cdmiq"]
+ },
+ "application/cdni": {
+ "source": "iana"
+ },
+ "application/cea": {
+ "source": "iana"
+ },
+ "application/cea-2018+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/cellml+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/cfw": {
+ "source": "iana"
+ },
+ "application/clr": {
+ "source": "iana"
+ },
+ "application/clue+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/clue_info+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/cms": {
+ "source": "iana"
+ },
+ "application/cnrp+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/coap-group+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/coap-payload": {
+ "source": "iana"
+ },
+ "application/commonground": {
+ "source": "iana"
+ },
+ "application/conference-info+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/cose": {
+ "source": "iana"
+ },
+ "application/cose-key": {
+ "source": "iana"
+ },
+ "application/cose-key-set": {
+ "source": "iana"
+ },
+ "application/cpl+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/csrattrs": {
+ "source": "iana"
+ },
+ "application/csta+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/cstadata+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/csvm+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/cu-seeme": {
+ "source": "apache",
+ "extensions": ["cu"]
+ },
+ "application/cwt": {
+ "source": "iana"
+ },
+ "application/cybercash": {
+ "source": "iana"
+ },
+ "application/dart": {
+ "compressible": true
+ },
+ "application/dash+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["mpd"]
+ },
+ "application/dashdelta": {
+ "source": "iana"
+ },
+ "application/davmount+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["davmount"]
+ },
+ "application/dca-rft": {
+ "source": "iana"
+ },
+ "application/dcd": {
+ "source": "iana"
+ },
+ "application/dec-dx": {
+ "source": "iana"
+ },
+ "application/dialog-info+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/dicom": {
+ "source": "iana"
+ },
+ "application/dicom+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/dicom+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/dii": {
+ "source": "iana"
+ },
+ "application/dit": {
+ "source": "iana"
+ },
+ "application/dns": {
+ "source": "iana"
+ },
+ "application/dns+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/dns-message": {
+ "source": "iana"
+ },
+ "application/docbook+xml": {
+ "source": "apache",
+ "compressible": true,
+ "extensions": ["dbk"]
+ },
+ "application/dots+cbor": {
+ "source": "iana"
+ },
+ "application/dskpp+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/dssc+der": {
+ "source": "iana",
+ "extensions": ["dssc"]
+ },
+ "application/dssc+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["xdssc"]
+ },
+ "application/dvcs": {
+ "source": "iana"
+ },
+ "application/ecmascript": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["es","ecma"]
+ },
+ "application/edi-consent": {
+ "source": "iana"
+ },
+ "application/edi-x12": {
+ "source": "iana",
+ "compressible": false
+ },
+ "application/edifact": {
+ "source": "iana",
+ "compressible": false
+ },
+ "application/efi": {
+ "source": "iana"
+ },
+ "application/elm+json": {
+ "source": "iana",
+ "charset": "UTF-8",
+ "compressible": true
+ },
+ "application/elm+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/emergencycalldata.cap+xml": {
+ "source": "iana",
+ "charset": "UTF-8",
+ "compressible": true
+ },
+ "application/emergencycalldata.comment+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/emergencycalldata.control+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/emergencycalldata.deviceinfo+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/emergencycalldata.ecall.msd": {
+ "source": "iana"
+ },
+ "application/emergencycalldata.providerinfo+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/emergencycalldata.serviceinfo+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/emergencycalldata.subscriberinfo+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/emergencycalldata.veds+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/emma+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["emma"]
+ },
+ "application/emotionml+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["emotionml"]
+ },
+ "application/encaprtp": {
+ "source": "iana"
+ },
+ "application/epp+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/epub+zip": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["epub"]
+ },
+ "application/eshop": {
+ "source": "iana"
+ },
+ "application/exi": {
+ "source": "iana",
+ "extensions": ["exi"]
+ },
+ "application/expect-ct-report+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/express": {
+ "source": "iana",
+ "extensions": ["exp"]
+ },
+ "application/fastinfoset": {
+ "source": "iana"
+ },
+ "application/fastsoap": {
+ "source": "iana"
+ },
+ "application/fdt+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["fdt"]
+ },
+ "application/fhir+json": {
+ "source": "iana",
+ "charset": "UTF-8",
+ "compressible": true
+ },
+ "application/fhir+xml": {
+ "source": "iana",
+ "charset": "UTF-8",
+ "compressible": true
+ },
+ "application/fido.trusted-apps+json": {
+ "compressible": true
+ },
+ "application/fits": {
+ "source": "iana"
+ },
+ "application/flexfec": {
+ "source": "iana"
+ },
+ "application/font-sfnt": {
+ "source": "iana"
+ },
+ "application/font-tdpfr": {
+ "source": "iana",
+ "extensions": ["pfr"]
+ },
+ "application/font-woff": {
+ "source": "iana",
+ "compressible": false
+ },
+ "application/framework-attributes+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/geo+json": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["geojson"]
+ },
+ "application/geo+json-seq": {
+ "source": "iana"
+ },
+ "application/geopackage+sqlite3": {
+ "source": "iana"
+ },
+ "application/geoxacml+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/gltf-buffer": {
+ "source": "iana"
+ },
+ "application/gml+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["gml"]
+ },
+ "application/gpx+xml": {
+ "source": "apache",
+ "compressible": true,
+ "extensions": ["gpx"]
+ },
+ "application/gxf": {
+ "source": "apache",
+ "extensions": ["gxf"]
+ },
+ "application/gzip": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["gz"]
+ },
+ "application/h224": {
+ "source": "iana"
+ },
+ "application/held+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/hjson": {
+ "extensions": ["hjson"]
+ },
+ "application/http": {
+ "source": "iana"
+ },
+ "application/hyperstudio": {
+ "source": "iana",
+ "extensions": ["stk"]
+ },
+ "application/ibe-key-request+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/ibe-pkg-reply+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/ibe-pp-data": {
+ "source": "iana"
+ },
+ "application/iges": {
+ "source": "iana"
+ },
+ "application/im-iscomposing+xml": {
+ "source": "iana",
+ "charset": "UTF-8",
+ "compressible": true
+ },
+ "application/index": {
+ "source": "iana"
+ },
+ "application/index.cmd": {
+ "source": "iana"
+ },
+ "application/index.obj": {
+ "source": "iana"
+ },
+ "application/index.response": {
+ "source": "iana"
+ },
+ "application/index.vnd": {
+ "source": "iana"
+ },
+ "application/inkml+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["ink","inkml"]
+ },
+ "application/iotp": {
+ "source": "iana"
+ },
+ "application/ipfix": {
+ "source": "iana",
+ "extensions": ["ipfix"]
+ },
+ "application/ipp": {
+ "source": "iana"
+ },
+ "application/isup": {
+ "source": "iana"
+ },
+ "application/its+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["its"]
+ },
+ "application/java-archive": {
+ "source": "apache",
+ "compressible": false,
+ "extensions": ["jar","war","ear"]
+ },
+ "application/java-serialized-object": {
+ "source": "apache",
+ "compressible": false,
+ "extensions": ["ser"]
+ },
+ "application/java-vm": {
+ "source": "apache",
+ "compressible": false,
+ "extensions": ["class"]
+ },
+ "application/javascript": {
+ "source": "iana",
+ "charset": "UTF-8",
+ "compressible": true,
+ "extensions": ["js","mjs"]
+ },
+ "application/jf2feed+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/jose": {
+ "source": "iana"
+ },
+ "application/jose+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/jrd+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/jscalendar+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/json": {
+ "source": "iana",
+ "charset": "UTF-8",
+ "compressible": true,
+ "extensions": ["json","map"]
+ },
+ "application/json-patch+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/json-seq": {
+ "source": "iana"
+ },
+ "application/json5": {
+ "extensions": ["json5"]
+ },
+ "application/jsonml+json": {
+ "source": "apache",
+ "compressible": true,
+ "extensions": ["jsonml"]
+ },
+ "application/jwk+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/jwk-set+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/jwt": {
+ "source": "iana"
+ },
+ "application/kpml-request+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/kpml-response+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/ld+json": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["jsonld"]
+ },
+ "application/lgr+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["lgr"]
+ },
+ "application/link-format": {
+ "source": "iana"
+ },
+ "application/load-control+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/lost+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["lostxml"]
+ },
+ "application/lostsync+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/lpf+zip": {
+ "source": "iana",
+ "compressible": false
+ },
+ "application/lxf": {
+ "source": "iana"
+ },
+ "application/mac-binhex40": {
+ "source": "iana",
+ "extensions": ["hqx"]
+ },
+ "application/mac-compactpro": {
+ "source": "apache",
+ "extensions": ["cpt"]
+ },
+ "application/macwriteii": {
+ "source": "iana"
+ },
+ "application/mads+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["mads"]
+ },
+ "application/manifest+json": {
+ "source": "iana",
+ "charset": "UTF-8",
+ "compressible": true,
+ "extensions": ["webmanifest"]
+ },
+ "application/marc": {
+ "source": "iana",
+ "extensions": ["mrc"]
+ },
+ "application/marcxml+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["mrcx"]
+ },
+ "application/mathematica": {
+ "source": "iana",
+ "extensions": ["ma","nb","mb"]
+ },
+ "application/mathml+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["mathml"]
+ },
+ "application/mathml-content+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/mathml-presentation+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/mbms-associated-procedure-description+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/mbms-deregister+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/mbms-envelope+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/mbms-msk+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/mbms-msk-response+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/mbms-protection-description+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/mbms-reception-report+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/mbms-register+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/mbms-register-response+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/mbms-schedule+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/mbms-user-service-description+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/mbox": {
+ "source": "iana",
+ "extensions": ["mbox"]
+ },
+ "application/media-policy-dataset+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/media_control+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/mediaservercontrol+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["mscml"]
+ },
+ "application/merge-patch+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/metalink+xml": {
+ "source": "apache",
+ "compressible": true,
+ "extensions": ["metalink"]
+ },
+ "application/metalink4+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["meta4"]
+ },
+ "application/mets+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["mets"]
+ },
+ "application/mf4": {
+ "source": "iana"
+ },
+ "application/mikey": {
+ "source": "iana"
+ },
+ "application/mipc": {
+ "source": "iana"
+ },
+ "application/missing-blocks+cbor-seq": {
+ "source": "iana"
+ },
+ "application/mmt-aei+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["maei"]
+ },
+ "application/mmt-usd+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["musd"]
+ },
+ "application/mods+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["mods"]
+ },
+ "application/moss-keys": {
+ "source": "iana"
+ },
+ "application/moss-signature": {
+ "source": "iana"
+ },
+ "application/mosskey-data": {
+ "source": "iana"
+ },
+ "application/mosskey-request": {
+ "source": "iana"
+ },
+ "application/mp21": {
+ "source": "iana",
+ "extensions": ["m21","mp21"]
+ },
+ "application/mp4": {
+ "source": "iana",
+ "extensions": ["mp4s","m4p"]
+ },
+ "application/mpeg4-generic": {
+ "source": "iana"
+ },
+ "application/mpeg4-iod": {
+ "source": "iana"
+ },
+ "application/mpeg4-iod-xmt": {
+ "source": "iana"
+ },
+ "application/mrb-consumer+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/mrb-publish+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/msc-ivr+xml": {
+ "source": "iana",
+ "charset": "UTF-8",
+ "compressible": true
+ },
+ "application/msc-mixer+xml": {
+ "source": "iana",
+ "charset": "UTF-8",
+ "compressible": true
+ },
+ "application/msword": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["doc","dot"]
+ },
+ "application/mud+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/multipart-core": {
+ "source": "iana"
+ },
+ "application/mxf": {
+ "source": "iana",
+ "extensions": ["mxf"]
+ },
+ "application/n-quads": {
+ "source": "iana",
+ "extensions": ["nq"]
+ },
+ "application/n-triples": {
+ "source": "iana",
+ "extensions": ["nt"]
+ },
+ "application/nasdata": {
+ "source": "iana"
+ },
+ "application/news-checkgroups": {
+ "source": "iana",
+ "charset": "US-ASCII"
+ },
+ "application/news-groupinfo": {
+ "source": "iana",
+ "charset": "US-ASCII"
+ },
+ "application/news-transmission": {
+ "source": "iana"
+ },
+ "application/nlsml+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/node": {
+ "source": "iana",
+ "extensions": ["cjs"]
+ },
+ "application/nss": {
+ "source": "iana"
+ },
+ "application/oauth-authz-req+jwt": {
+ "source": "iana"
+ },
+ "application/ocsp-request": {
+ "source": "iana"
+ },
+ "application/ocsp-response": {
+ "source": "iana"
+ },
+ "application/octet-stream": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"]
+ },
+ "application/oda": {
+ "source": "iana",
+ "extensions": ["oda"]
+ },
+ "application/odm+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/odx": {
+ "source": "iana"
+ },
+ "application/oebps-package+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["opf"]
+ },
+ "application/ogg": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["ogx"]
+ },
+ "application/omdoc+xml": {
+ "source": "apache",
+ "compressible": true,
+ "extensions": ["omdoc"]
+ },
+ "application/onenote": {
+ "source": "apache",
+ "extensions": ["onetoc","onetoc2","onetmp","onepkg"]
+ },
+ "application/opc-nodeset+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/oscore": {
+ "source": "iana"
+ },
+ "application/oxps": {
+ "source": "iana",
+ "extensions": ["oxps"]
+ },
+ "application/p21": {
+ "source": "iana"
+ },
+ "application/p21+zip": {
+ "source": "iana",
+ "compressible": false
+ },
+ "application/p2p-overlay+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["relo"]
+ },
+ "application/parityfec": {
+ "source": "iana"
+ },
+ "application/passport": {
+ "source": "iana"
+ },
+ "application/patch-ops-error+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["xer"]
+ },
+ "application/pdf": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["pdf"]
+ },
+ "application/pdx": {
+ "source": "iana"
+ },
+ "application/pem-certificate-chain": {
+ "source": "iana"
+ },
+ "application/pgp-encrypted": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["pgp"]
+ },
+ "application/pgp-keys": {
+ "source": "iana"
+ },
+ "application/pgp-signature": {
+ "source": "iana",
+ "extensions": ["asc","sig"]
+ },
+ "application/pics-rules": {
+ "source": "apache",
+ "extensions": ["prf"]
+ },
+ "application/pidf+xml": {
+ "source": "iana",
+ "charset": "UTF-8",
+ "compressible": true
+ },
+ "application/pidf-diff+xml": {
+ "source": "iana",
+ "charset": "UTF-8",
+ "compressible": true
+ },
+ "application/pkcs10": {
+ "source": "iana",
+ "extensions": ["p10"]
+ },
+ "application/pkcs12": {
+ "source": "iana"
+ },
+ "application/pkcs7-mime": {
+ "source": "iana",
+ "extensions": ["p7m","p7c"]
+ },
+ "application/pkcs7-signature": {
+ "source": "iana",
+ "extensions": ["p7s"]
+ },
+ "application/pkcs8": {
+ "source": "iana",
+ "extensions": ["p8"]
+ },
+ "application/pkcs8-encrypted": {
+ "source": "iana"
+ },
+ "application/pkix-attr-cert": {
+ "source": "iana",
+ "extensions": ["ac"]
+ },
+ "application/pkix-cert": {
+ "source": "iana",
+ "extensions": ["cer"]
+ },
+ "application/pkix-crl": {
+ "source": "iana",
+ "extensions": ["crl"]
+ },
+ "application/pkix-pkipath": {
+ "source": "iana",
+ "extensions": ["pkipath"]
+ },
+ "application/pkixcmp": {
+ "source": "iana",
+ "extensions": ["pki"]
+ },
+ "application/pls+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["pls"]
+ },
+ "application/poc-settings+xml": {
+ "source": "iana",
+ "charset": "UTF-8",
+ "compressible": true
+ },
+ "application/postscript": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["ai","eps","ps"]
+ },
+ "application/ppsp-tracker+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/problem+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/problem+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/provenance+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["provx"]
+ },
+ "application/prs.alvestrand.titrax-sheet": {
+ "source": "iana"
+ },
+ "application/prs.cww": {
+ "source": "iana",
+ "extensions": ["cww"]
+ },
+ "application/prs.cyn": {
+ "source": "iana",
+ "charset": "7-BIT"
+ },
+ "application/prs.hpub+zip": {
+ "source": "iana",
+ "compressible": false
+ },
+ "application/prs.nprend": {
+ "source": "iana"
+ },
+ "application/prs.plucker": {
+ "source": "iana"
+ },
+ "application/prs.rdf-xml-crypt": {
+ "source": "iana"
+ },
+ "application/prs.xsf+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/pskc+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["pskcxml"]
+ },
+ "application/pvd+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/qsig": {
+ "source": "iana"
+ },
+ "application/raml+yaml": {
+ "compressible": true,
+ "extensions": ["raml"]
+ },
+ "application/raptorfec": {
+ "source": "iana"
+ },
+ "application/rdap+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/rdf+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["rdf","owl"]
+ },
+ "application/reginfo+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["rif"]
+ },
+ "application/relax-ng-compact-syntax": {
+ "source": "iana",
+ "extensions": ["rnc"]
+ },
+ "application/remote-printing": {
+ "source": "iana"
+ },
+ "application/reputon+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/resource-lists+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["rl"]
+ },
+ "application/resource-lists-diff+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["rld"]
+ },
+ "application/rfc+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/riscos": {
+ "source": "iana"
+ },
+ "application/rlmi+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/rls-services+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["rs"]
+ },
+ "application/route-apd+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["rapd"]
+ },
+ "application/route-s-tsid+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["sls"]
+ },
+ "application/route-usd+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["rusd"]
+ },
+ "application/rpki-ghostbusters": {
+ "source": "iana",
+ "extensions": ["gbr"]
+ },
+ "application/rpki-manifest": {
+ "source": "iana",
+ "extensions": ["mft"]
+ },
+ "application/rpki-publication": {
+ "source": "iana"
+ },
+ "application/rpki-roa": {
+ "source": "iana",
+ "extensions": ["roa"]
+ },
+ "application/rpki-updown": {
+ "source": "iana"
+ },
+ "application/rsd+xml": {
+ "source": "apache",
+ "compressible": true,
+ "extensions": ["rsd"]
+ },
+ "application/rss+xml": {
+ "source": "apache",
+ "compressible": true,
+ "extensions": ["rss"]
+ },
+ "application/rtf": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["rtf"]
+ },
+ "application/rtploopback": {
+ "source": "iana"
+ },
+ "application/rtx": {
+ "source": "iana"
+ },
+ "application/samlassertion+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/samlmetadata+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/sarif+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/sarif-external-properties+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/sbe": {
+ "source": "iana"
+ },
+ "application/sbml+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["sbml"]
+ },
+ "application/scaip+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/scim+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/scvp-cv-request": {
+ "source": "iana",
+ "extensions": ["scq"]
+ },
+ "application/scvp-cv-response": {
+ "source": "iana",
+ "extensions": ["scs"]
+ },
+ "application/scvp-vp-request": {
+ "source": "iana",
+ "extensions": ["spq"]
+ },
+ "application/scvp-vp-response": {
+ "source": "iana",
+ "extensions": ["spp"]
+ },
+ "application/sdp": {
+ "source": "iana",
+ "extensions": ["sdp"]
+ },
+ "application/secevent+jwt": {
+ "source": "iana"
+ },
+ "application/senml+cbor": {
+ "source": "iana"
+ },
+ "application/senml+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/senml+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["senmlx"]
+ },
+ "application/senml-etch+cbor": {
+ "source": "iana"
+ },
+ "application/senml-etch+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/senml-exi": {
+ "source": "iana"
+ },
+ "application/sensml+cbor": {
+ "source": "iana"
+ },
+ "application/sensml+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/sensml+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["sensmlx"]
+ },
+ "application/sensml-exi": {
+ "source": "iana"
+ },
+ "application/sep+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/sep-exi": {
+ "source": "iana"
+ },
+ "application/session-info": {
+ "source": "iana"
+ },
+ "application/set-payment": {
+ "source": "iana"
+ },
+ "application/set-payment-initiation": {
+ "source": "iana",
+ "extensions": ["setpay"]
+ },
+ "application/set-registration": {
+ "source": "iana"
+ },
+ "application/set-registration-initiation": {
+ "source": "iana",
+ "extensions": ["setreg"]
+ },
+ "application/sgml": {
+ "source": "iana"
+ },
+ "application/sgml-open-catalog": {
+ "source": "iana"
+ },
+ "application/shf+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["shf"]
+ },
+ "application/sieve": {
+ "source": "iana",
+ "extensions": ["siv","sieve"]
+ },
+ "application/simple-filter+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/simple-message-summary": {
+ "source": "iana"
+ },
+ "application/simplesymbolcontainer": {
+ "source": "iana"
+ },
+ "application/sipc": {
+ "source": "iana"
+ },
+ "application/slate": {
+ "source": "iana"
+ },
+ "application/smil": {
+ "source": "iana"
+ },
+ "application/smil+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["smi","smil"]
+ },
+ "application/smpte336m": {
+ "source": "iana"
+ },
+ "application/soap+fastinfoset": {
+ "source": "iana"
+ },
+ "application/soap+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/sparql-query": {
+ "source": "iana",
+ "extensions": ["rq"]
+ },
+ "application/sparql-results+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["srx"]
+ },
+ "application/spdx+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/spirits-event+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/sql": {
+ "source": "iana"
+ },
+ "application/srgs": {
+ "source": "iana",
+ "extensions": ["gram"]
+ },
+ "application/srgs+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["grxml"]
+ },
+ "application/sru+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["sru"]
+ },
+ "application/ssdl+xml": {
+ "source": "apache",
+ "compressible": true,
+ "extensions": ["ssdl"]
+ },
+ "application/ssml+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["ssml"]
+ },
+ "application/stix+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/swid+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["swidtag"]
+ },
+ "application/tamp-apex-update": {
+ "source": "iana"
+ },
+ "application/tamp-apex-update-confirm": {
+ "source": "iana"
+ },
+ "application/tamp-community-update": {
+ "source": "iana"
+ },
+ "application/tamp-community-update-confirm": {
+ "source": "iana"
+ },
+ "application/tamp-error": {
+ "source": "iana"
+ },
+ "application/tamp-sequence-adjust": {
+ "source": "iana"
+ },
+ "application/tamp-sequence-adjust-confirm": {
+ "source": "iana"
+ },
+ "application/tamp-status-query": {
+ "source": "iana"
+ },
+ "application/tamp-status-response": {
+ "source": "iana"
+ },
+ "application/tamp-update": {
+ "source": "iana"
+ },
+ "application/tamp-update-confirm": {
+ "source": "iana"
+ },
+ "application/tar": {
+ "compressible": true
+ },
+ "application/taxii+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/td+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/tei+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["tei","teicorpus"]
+ },
+ "application/tetra_isi": {
+ "source": "iana"
+ },
+ "application/thraud+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["tfi"]
+ },
+ "application/timestamp-query": {
+ "source": "iana"
+ },
+ "application/timestamp-reply": {
+ "source": "iana"
+ },
+ "application/timestamped-data": {
+ "source": "iana",
+ "extensions": ["tsd"]
+ },
+ "application/tlsrpt+gzip": {
+ "source": "iana"
+ },
+ "application/tlsrpt+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/tnauthlist": {
+ "source": "iana"
+ },
+ "application/token-introspection+jwt": {
+ "source": "iana"
+ },
+ "application/toml": {
+ "compressible": true,
+ "extensions": ["toml"]
+ },
+ "application/trickle-ice-sdpfrag": {
+ "source": "iana"
+ },
+ "application/trig": {
+ "source": "iana",
+ "extensions": ["trig"]
+ },
+ "application/ttml+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["ttml"]
+ },
+ "application/tve-trigger": {
+ "source": "iana"
+ },
+ "application/tzif": {
+ "source": "iana"
+ },
+ "application/tzif-leap": {
+ "source": "iana"
+ },
+ "application/ubjson": {
+ "compressible": false,
+ "extensions": ["ubj"]
+ },
+ "application/ulpfec": {
+ "source": "iana"
+ },
+ "application/urc-grpsheet+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/urc-ressheet+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["rsheet"]
+ },
+ "application/urc-targetdesc+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["td"]
+ },
+ "application/urc-uisocketdesc+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vcard+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vcard+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vemmi": {
+ "source": "iana"
+ },
+ "application/vividence.scriptfile": {
+ "source": "apache"
+ },
+ "application/vnd.1000minds.decision-model+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["1km"]
+ },
+ "application/vnd.3gpp-prose+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp-prose-pc3ch+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp-v2x-local-service-information": {
+ "source": "iana"
+ },
+ "application/vnd.3gpp.5gnas": {
+ "source": "iana"
+ },
+ "application/vnd.3gpp.access-transfer-events+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.bsf+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.gmop+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.gtpc": {
+ "source": "iana"
+ },
+ "application/vnd.3gpp.interworking-data": {
+ "source": "iana"
+ },
+ "application/vnd.3gpp.lpp": {
+ "source": "iana"
+ },
+ "application/vnd.3gpp.mc-signalling-ear": {
+ "source": "iana"
+ },
+ "application/vnd.3gpp.mcdata-affiliation-command+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.mcdata-info+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.mcdata-payload": {
+ "source": "iana"
+ },
+ "application/vnd.3gpp.mcdata-service-config+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.mcdata-signalling": {
+ "source": "iana"
+ },
+ "application/vnd.3gpp.mcdata-ue-config+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.mcdata-user-profile+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.mcptt-affiliation-command+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.mcptt-floor-request+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.mcptt-info+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.mcptt-location-info+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.mcptt-mbms-usage-info+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.mcptt-service-config+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.mcptt-signed+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.mcptt-ue-config+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.mcptt-ue-init-config+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.mcptt-user-profile+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.mcvideo-affiliation-command+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.mcvideo-affiliation-info+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.mcvideo-info+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.mcvideo-location-info+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.mcvideo-mbms-usage-info+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.mcvideo-service-config+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.mcvideo-transmission-request+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.mcvideo-ue-config+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.mcvideo-user-profile+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.mid-call+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.ngap": {
+ "source": "iana"
+ },
+ "application/vnd.3gpp.pfcp": {
+ "source": "iana"
+ },
+ "application/vnd.3gpp.pic-bw-large": {
+ "source": "iana",
+ "extensions": ["plb"]
+ },
+ "application/vnd.3gpp.pic-bw-small": {
+ "source": "iana",
+ "extensions": ["psb"]
+ },
+ "application/vnd.3gpp.pic-bw-var": {
+ "source": "iana",
+ "extensions": ["pvb"]
+ },
+ "application/vnd.3gpp.s1ap": {
+ "source": "iana"
+ },
+ "application/vnd.3gpp.sms": {
+ "source": "iana"
+ },
+ "application/vnd.3gpp.sms+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.srvcc-ext+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.srvcc-info+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.state-and-event-info+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp.ussd+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp2.bcmcsinfo+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.3gpp2.sms": {
+ "source": "iana"
+ },
+ "application/vnd.3gpp2.tcap": {
+ "source": "iana",
+ "extensions": ["tcap"]
+ },
+ "application/vnd.3lightssoftware.imagescal": {
+ "source": "iana"
+ },
+ "application/vnd.3m.post-it-notes": {
+ "source": "iana",
+ "extensions": ["pwn"]
+ },
+ "application/vnd.accpac.simply.aso": {
+ "source": "iana",
+ "extensions": ["aso"]
+ },
+ "application/vnd.accpac.simply.imp": {
+ "source": "iana",
+ "extensions": ["imp"]
+ },
+ "application/vnd.acucobol": {
+ "source": "iana",
+ "extensions": ["acu"]
+ },
+ "application/vnd.acucorp": {
+ "source": "iana",
+ "extensions": ["atc","acutc"]
+ },
+ "application/vnd.adobe.air-application-installer-package+zip": {
+ "source": "apache",
+ "compressible": false,
+ "extensions": ["air"]
+ },
+ "application/vnd.adobe.flash.movie": {
+ "source": "iana"
+ },
+ "application/vnd.adobe.formscentral.fcdt": {
+ "source": "iana",
+ "extensions": ["fcdt"]
+ },
+ "application/vnd.adobe.fxp": {
+ "source": "iana",
+ "extensions": ["fxp","fxpl"]
+ },
+ "application/vnd.adobe.partial-upload": {
+ "source": "iana"
+ },
+ "application/vnd.adobe.xdp+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["xdp"]
+ },
+ "application/vnd.adobe.xfdf": {
+ "source": "iana",
+ "extensions": ["xfdf"]
+ },
+ "application/vnd.aether.imp": {
+ "source": "iana"
+ },
+ "application/vnd.afpc.afplinedata": {
+ "source": "iana"
+ },
+ "application/vnd.afpc.afplinedata-pagedef": {
+ "source": "iana"
+ },
+ "application/vnd.afpc.cmoca-cmresource": {
+ "source": "iana"
+ },
+ "application/vnd.afpc.foca-charset": {
+ "source": "iana"
+ },
+ "application/vnd.afpc.foca-codedfont": {
+ "source": "iana"
+ },
+ "application/vnd.afpc.foca-codepage": {
+ "source": "iana"
+ },
+ "application/vnd.afpc.modca": {
+ "source": "iana"
+ },
+ "application/vnd.afpc.modca-cmtable": {
+ "source": "iana"
+ },
+ "application/vnd.afpc.modca-formdef": {
+ "source": "iana"
+ },
+ "application/vnd.afpc.modca-mediummap": {
+ "source": "iana"
+ },
+ "application/vnd.afpc.modca-objectcontainer": {
+ "source": "iana"
+ },
+ "application/vnd.afpc.modca-overlay": {
+ "source": "iana"
+ },
+ "application/vnd.afpc.modca-pagesegment": {
+ "source": "iana"
+ },
+ "application/vnd.age": {
+ "source": "iana",
+ "extensions": ["age"]
+ },
+ "application/vnd.ah-barcode": {
+ "source": "iana"
+ },
+ "application/vnd.ahead.space": {
+ "source": "iana",
+ "extensions": ["ahead"]
+ },
+ "application/vnd.airzip.filesecure.azf": {
+ "source": "iana",
+ "extensions": ["azf"]
+ },
+ "application/vnd.airzip.filesecure.azs": {
+ "source": "iana",
+ "extensions": ["azs"]
+ },
+ "application/vnd.amadeus+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.amazon.ebook": {
+ "source": "apache",
+ "extensions": ["azw"]
+ },
+ "application/vnd.amazon.mobi8-ebook": {
+ "source": "iana"
+ },
+ "application/vnd.americandynamics.acc": {
+ "source": "iana",
+ "extensions": ["acc"]
+ },
+ "application/vnd.amiga.ami": {
+ "source": "iana",
+ "extensions": ["ami"]
+ },
+ "application/vnd.amundsen.maze+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.android.ota": {
+ "source": "iana"
+ },
+ "application/vnd.android.package-archive": {
+ "source": "apache",
+ "compressible": false,
+ "extensions": ["apk"]
+ },
+ "application/vnd.anki": {
+ "source": "iana"
+ },
+ "application/vnd.anser-web-certificate-issue-initiation": {
+ "source": "iana",
+ "extensions": ["cii"]
+ },
+ "application/vnd.anser-web-funds-transfer-initiation": {
+ "source": "apache",
+ "extensions": ["fti"]
+ },
+ "application/vnd.antix.game-component": {
+ "source": "iana",
+ "extensions": ["atx"]
+ },
+ "application/vnd.apache.arrow.file": {
+ "source": "iana"
+ },
+ "application/vnd.apache.arrow.stream": {
+ "source": "iana"
+ },
+ "application/vnd.apache.thrift.binary": {
+ "source": "iana"
+ },
+ "application/vnd.apache.thrift.compact": {
+ "source": "iana"
+ },
+ "application/vnd.apache.thrift.json": {
+ "source": "iana"
+ },
+ "application/vnd.api+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.aplextor.warrp+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.apothekende.reservation+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.apple.installer+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["mpkg"]
+ },
+ "application/vnd.apple.keynote": {
+ "source": "iana",
+ "extensions": ["key"]
+ },
+ "application/vnd.apple.mpegurl": {
+ "source": "iana",
+ "extensions": ["m3u8"]
+ },
+ "application/vnd.apple.numbers": {
+ "source": "iana",
+ "extensions": ["numbers"]
+ },
+ "application/vnd.apple.pages": {
+ "source": "iana",
+ "extensions": ["pages"]
+ },
+ "application/vnd.apple.pkpass": {
+ "compressible": false,
+ "extensions": ["pkpass"]
+ },
+ "application/vnd.arastra.swi": {
+ "source": "iana"
+ },
+ "application/vnd.aristanetworks.swi": {
+ "source": "iana",
+ "extensions": ["swi"]
+ },
+ "application/vnd.artisan+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.artsquare": {
+ "source": "iana"
+ },
+ "application/vnd.astraea-software.iota": {
+ "source": "iana",
+ "extensions": ["iota"]
+ },
+ "application/vnd.audiograph": {
+ "source": "iana",
+ "extensions": ["aep"]
+ },
+ "application/vnd.autopackage": {
+ "source": "iana"
+ },
+ "application/vnd.avalon+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.avistar+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.balsamiq.bmml+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["bmml"]
+ },
+ "application/vnd.balsamiq.bmpr": {
+ "source": "iana"
+ },
+ "application/vnd.banana-accounting": {
+ "source": "iana"
+ },
+ "application/vnd.bbf.usp.error": {
+ "source": "iana"
+ },
+ "application/vnd.bbf.usp.msg": {
+ "source": "iana"
+ },
+ "application/vnd.bbf.usp.msg+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.bekitzur-stech+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.bint.med-content": {
+ "source": "iana"
+ },
+ "application/vnd.biopax.rdf+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.blink-idb-value-wrapper": {
+ "source": "iana"
+ },
+ "application/vnd.blueice.multipass": {
+ "source": "iana",
+ "extensions": ["mpm"]
+ },
+ "application/vnd.bluetooth.ep.oob": {
+ "source": "iana"
+ },
+ "application/vnd.bluetooth.le.oob": {
+ "source": "iana"
+ },
+ "application/vnd.bmi": {
+ "source": "iana",
+ "extensions": ["bmi"]
+ },
+ "application/vnd.bpf": {
+ "source": "iana"
+ },
+ "application/vnd.bpf3": {
+ "source": "iana"
+ },
+ "application/vnd.businessobjects": {
+ "source": "iana",
+ "extensions": ["rep"]
+ },
+ "application/vnd.byu.uapi+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.cab-jscript": {
+ "source": "iana"
+ },
+ "application/vnd.canon-cpdl": {
+ "source": "iana"
+ },
+ "application/vnd.canon-lips": {
+ "source": "iana"
+ },
+ "application/vnd.capasystems-pg+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.cendio.thinlinc.clientconf": {
+ "source": "iana"
+ },
+ "application/vnd.century-systems.tcp_stream": {
+ "source": "iana"
+ },
+ "application/vnd.chemdraw+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["cdxml"]
+ },
+ "application/vnd.chess-pgn": {
+ "source": "iana"
+ },
+ "application/vnd.chipnuts.karaoke-mmd": {
+ "source": "iana",
+ "extensions": ["mmd"]
+ },
+ "application/vnd.ciedi": {
+ "source": "iana"
+ },
+ "application/vnd.cinderella": {
+ "source": "iana",
+ "extensions": ["cdy"]
+ },
+ "application/vnd.cirpack.isdn-ext": {
+ "source": "iana"
+ },
+ "application/vnd.citationstyles.style+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["csl"]
+ },
+ "application/vnd.claymore": {
+ "source": "iana",
+ "extensions": ["cla"]
+ },
+ "application/vnd.cloanto.rp9": {
+ "source": "iana",
+ "extensions": ["rp9"]
+ },
+ "application/vnd.clonk.c4group": {
+ "source": "iana",
+ "extensions": ["c4g","c4d","c4f","c4p","c4u"]
+ },
+ "application/vnd.cluetrust.cartomobile-config": {
+ "source": "iana",
+ "extensions": ["c11amc"]
+ },
+ "application/vnd.cluetrust.cartomobile-config-pkg": {
+ "source": "iana",
+ "extensions": ["c11amz"]
+ },
+ "application/vnd.coffeescript": {
+ "source": "iana"
+ },
+ "application/vnd.collabio.xodocuments.document": {
+ "source": "iana"
+ },
+ "application/vnd.collabio.xodocuments.document-template": {
+ "source": "iana"
+ },
+ "application/vnd.collabio.xodocuments.presentation": {
+ "source": "iana"
+ },
+ "application/vnd.collabio.xodocuments.presentation-template": {
+ "source": "iana"
+ },
+ "application/vnd.collabio.xodocuments.spreadsheet": {
+ "source": "iana"
+ },
+ "application/vnd.collabio.xodocuments.spreadsheet-template": {
+ "source": "iana"
+ },
+ "application/vnd.collection+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.collection.doc+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.collection.next+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.comicbook+zip": {
+ "source": "iana",
+ "compressible": false
+ },
+ "application/vnd.comicbook-rar": {
+ "source": "iana"
+ },
+ "application/vnd.commerce-battelle": {
+ "source": "iana"
+ },
+ "application/vnd.commonspace": {
+ "source": "iana",
+ "extensions": ["csp"]
+ },
+ "application/vnd.contact.cmsg": {
+ "source": "iana",
+ "extensions": ["cdbcmsg"]
+ },
+ "application/vnd.coreos.ignition+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.cosmocaller": {
+ "source": "iana",
+ "extensions": ["cmc"]
+ },
+ "application/vnd.crick.clicker": {
+ "source": "iana",
+ "extensions": ["clkx"]
+ },
+ "application/vnd.crick.clicker.keyboard": {
+ "source": "iana",
+ "extensions": ["clkk"]
+ },
+ "application/vnd.crick.clicker.palette": {
+ "source": "iana",
+ "extensions": ["clkp"]
+ },
+ "application/vnd.crick.clicker.template": {
+ "source": "iana",
+ "extensions": ["clkt"]
+ },
+ "application/vnd.crick.clicker.wordbank": {
+ "source": "iana",
+ "extensions": ["clkw"]
+ },
+ "application/vnd.criticaltools.wbs+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["wbs"]
+ },
+ "application/vnd.cryptii.pipe+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.crypto-shade-file": {
+ "source": "iana"
+ },
+ "application/vnd.cryptomator.encrypted": {
+ "source": "iana"
+ },
+ "application/vnd.cryptomator.vault": {
+ "source": "iana"
+ },
+ "application/vnd.ctc-posml": {
+ "source": "iana",
+ "extensions": ["pml"]
+ },
+ "application/vnd.ctct.ws+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.cups-pdf": {
+ "source": "iana"
+ },
+ "application/vnd.cups-postscript": {
+ "source": "iana"
+ },
+ "application/vnd.cups-ppd": {
+ "source": "iana",
+ "extensions": ["ppd"]
+ },
+ "application/vnd.cups-raster": {
+ "source": "iana"
+ },
+ "application/vnd.cups-raw": {
+ "source": "iana"
+ },
+ "application/vnd.curl": {
+ "source": "iana"
+ },
+ "application/vnd.curl.car": {
+ "source": "apache",
+ "extensions": ["car"]
+ },
+ "application/vnd.curl.pcurl": {
+ "source": "apache",
+ "extensions": ["pcurl"]
+ },
+ "application/vnd.cyan.dean.root+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.cybank": {
+ "source": "iana"
+ },
+ "application/vnd.cyclonedx+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.cyclonedx+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.d2l.coursepackage1p0+zip": {
+ "source": "iana",
+ "compressible": false
+ },
+ "application/vnd.d3m-dataset": {
+ "source": "iana"
+ },
+ "application/vnd.d3m-problem": {
+ "source": "iana"
+ },
+ "application/vnd.dart": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["dart"]
+ },
+ "application/vnd.data-vision.rdz": {
+ "source": "iana",
+ "extensions": ["rdz"]
+ },
+ "application/vnd.datapackage+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.dataresource+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.dbf": {
+ "source": "iana",
+ "extensions": ["dbf"]
+ },
+ "application/vnd.debian.binary-package": {
+ "source": "iana"
+ },
+ "application/vnd.dece.data": {
+ "source": "iana",
+ "extensions": ["uvf","uvvf","uvd","uvvd"]
+ },
+ "application/vnd.dece.ttml+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["uvt","uvvt"]
+ },
+ "application/vnd.dece.unspecified": {
+ "source": "iana",
+ "extensions": ["uvx","uvvx"]
+ },
+ "application/vnd.dece.zip": {
+ "source": "iana",
+ "extensions": ["uvz","uvvz"]
+ },
+ "application/vnd.denovo.fcselayout-link": {
+ "source": "iana",
+ "extensions": ["fe_launch"]
+ },
+ "application/vnd.desmume.movie": {
+ "source": "iana"
+ },
+ "application/vnd.dir-bi.plate-dl-nosuffix": {
+ "source": "iana"
+ },
+ "application/vnd.dm.delegation+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.dna": {
+ "source": "iana",
+ "extensions": ["dna"]
+ },
+ "application/vnd.document+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.dolby.mlp": {
+ "source": "apache",
+ "extensions": ["mlp"]
+ },
+ "application/vnd.dolby.mobile.1": {
+ "source": "iana"
+ },
+ "application/vnd.dolby.mobile.2": {
+ "source": "iana"
+ },
+ "application/vnd.doremir.scorecloud-binary-document": {
+ "source": "iana"
+ },
+ "application/vnd.dpgraph": {
+ "source": "iana",
+ "extensions": ["dpg"]
+ },
+ "application/vnd.dreamfactory": {
+ "source": "iana",
+ "extensions": ["dfac"]
+ },
+ "application/vnd.drive+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.ds-keypoint": {
+ "source": "apache",
+ "extensions": ["kpxx"]
+ },
+ "application/vnd.dtg.local": {
+ "source": "iana"
+ },
+ "application/vnd.dtg.local.flash": {
+ "source": "iana"
+ },
+ "application/vnd.dtg.local.html": {
+ "source": "iana"
+ },
+ "application/vnd.dvb.ait": {
+ "source": "iana",
+ "extensions": ["ait"]
+ },
+ "application/vnd.dvb.dvbisl+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.dvb.dvbj": {
+ "source": "iana"
+ },
+ "application/vnd.dvb.esgcontainer": {
+ "source": "iana"
+ },
+ "application/vnd.dvb.ipdcdftnotifaccess": {
+ "source": "iana"
+ },
+ "application/vnd.dvb.ipdcesgaccess": {
+ "source": "iana"
+ },
+ "application/vnd.dvb.ipdcesgaccess2": {
+ "source": "iana"
+ },
+ "application/vnd.dvb.ipdcesgpdd": {
+ "source": "iana"
+ },
+ "application/vnd.dvb.ipdcroaming": {
+ "source": "iana"
+ },
+ "application/vnd.dvb.iptv.alfec-base": {
+ "source": "iana"
+ },
+ "application/vnd.dvb.iptv.alfec-enhancement": {
+ "source": "iana"
+ },
+ "application/vnd.dvb.notif-aggregate-root+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.dvb.notif-container+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.dvb.notif-generic+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.dvb.notif-ia-msglist+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.dvb.notif-ia-registration-request+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.dvb.notif-ia-registration-response+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.dvb.notif-init+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.dvb.pfr": {
+ "source": "iana"
+ },
+ "application/vnd.dvb.service": {
+ "source": "iana",
+ "extensions": ["svc"]
+ },
+ "application/vnd.dxr": {
+ "source": "iana"
+ },
+ "application/vnd.dynageo": {
+ "source": "iana",
+ "extensions": ["geo"]
+ },
+ "application/vnd.dzr": {
+ "source": "iana"
+ },
+ "application/vnd.easykaraoke.cdgdownload": {
+ "source": "iana"
+ },
+ "application/vnd.ecdis-update": {
+ "source": "iana"
+ },
+ "application/vnd.ecip.rlp": {
+ "source": "iana"
+ },
+ "application/vnd.ecowin.chart": {
+ "source": "iana",
+ "extensions": ["mag"]
+ },
+ "application/vnd.ecowin.filerequest": {
+ "source": "iana"
+ },
+ "application/vnd.ecowin.fileupdate": {
+ "source": "iana"
+ },
+ "application/vnd.ecowin.series": {
+ "source": "iana"
+ },
+ "application/vnd.ecowin.seriesrequest": {
+ "source": "iana"
+ },
+ "application/vnd.ecowin.seriesupdate": {
+ "source": "iana"
+ },
+ "application/vnd.efi.img": {
+ "source": "iana"
+ },
+ "application/vnd.efi.iso": {
+ "source": "iana"
+ },
+ "application/vnd.emclient.accessrequest+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.enliven": {
+ "source": "iana",
+ "extensions": ["nml"]
+ },
+ "application/vnd.enphase.envoy": {
+ "source": "iana"
+ },
+ "application/vnd.eprints.data+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.epson.esf": {
+ "source": "iana",
+ "extensions": ["esf"]
+ },
+ "application/vnd.epson.msf": {
+ "source": "iana",
+ "extensions": ["msf"]
+ },
+ "application/vnd.epson.quickanime": {
+ "source": "iana",
+ "extensions": ["qam"]
+ },
+ "application/vnd.epson.salt": {
+ "source": "iana",
+ "extensions": ["slt"]
+ },
+ "application/vnd.epson.ssf": {
+ "source": "iana",
+ "extensions": ["ssf"]
+ },
+ "application/vnd.ericsson.quickcall": {
+ "source": "iana"
+ },
+ "application/vnd.espass-espass+zip": {
+ "source": "iana",
+ "compressible": false
+ },
+ "application/vnd.eszigno3+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["es3","et3"]
+ },
+ "application/vnd.etsi.aoc+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.etsi.asic-e+zip": {
+ "source": "iana",
+ "compressible": false
+ },
+ "application/vnd.etsi.asic-s+zip": {
+ "source": "iana",
+ "compressible": false
+ },
+ "application/vnd.etsi.cug+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.etsi.iptvcommand+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.etsi.iptvdiscovery+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.etsi.iptvprofile+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.etsi.iptvsad-bc+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.etsi.iptvsad-cod+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.etsi.iptvsad-npvr+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.etsi.iptvservice+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.etsi.iptvsync+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.etsi.iptvueprofile+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.etsi.mcid+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.etsi.mheg5": {
+ "source": "iana"
+ },
+ "application/vnd.etsi.overload-control-policy-dataset+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.etsi.pstn+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.etsi.sci+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.etsi.simservs+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.etsi.timestamp-token": {
+ "source": "iana"
+ },
+ "application/vnd.etsi.tsl+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.etsi.tsl.der": {
+ "source": "iana"
+ },
+ "application/vnd.eudora.data": {
+ "source": "iana"
+ },
+ "application/vnd.evolv.ecig.profile": {
+ "source": "iana"
+ },
+ "application/vnd.evolv.ecig.settings": {
+ "source": "iana"
+ },
+ "application/vnd.evolv.ecig.theme": {
+ "source": "iana"
+ },
+ "application/vnd.exstream-empower+zip": {
+ "source": "iana",
+ "compressible": false
+ },
+ "application/vnd.exstream-package": {
+ "source": "iana"
+ },
+ "application/vnd.ezpix-album": {
+ "source": "iana",
+ "extensions": ["ez2"]
+ },
+ "application/vnd.ezpix-package": {
+ "source": "iana",
+ "extensions": ["ez3"]
+ },
+ "application/vnd.f-secure.mobile": {
+ "source": "iana"
+ },
+ "application/vnd.fastcopy-disk-image": {
+ "source": "iana"
+ },
+ "application/vnd.fdf": {
+ "source": "iana",
+ "extensions": ["fdf"]
+ },
+ "application/vnd.fdsn.mseed": {
+ "source": "iana",
+ "extensions": ["mseed"]
+ },
+ "application/vnd.fdsn.seed": {
+ "source": "iana",
+ "extensions": ["seed","dataless"]
+ },
+ "application/vnd.ffsns": {
+ "source": "iana"
+ },
+ "application/vnd.ficlab.flb+zip": {
+ "source": "iana",
+ "compressible": false
+ },
+ "application/vnd.filmit.zfc": {
+ "source": "iana"
+ },
+ "application/vnd.fints": {
+ "source": "iana"
+ },
+ "application/vnd.firemonkeys.cloudcell": {
+ "source": "iana"
+ },
+ "application/vnd.flographit": {
+ "source": "iana",
+ "extensions": ["gph"]
+ },
+ "application/vnd.fluxtime.clip": {
+ "source": "iana",
+ "extensions": ["ftc"]
+ },
+ "application/vnd.font-fontforge-sfd": {
+ "source": "iana"
+ },
+ "application/vnd.framemaker": {
+ "source": "iana",
+ "extensions": ["fm","frame","maker","book"]
+ },
+ "application/vnd.frogans.fnc": {
+ "source": "iana",
+ "extensions": ["fnc"]
+ },
+ "application/vnd.frogans.ltf": {
+ "source": "iana",
+ "extensions": ["ltf"]
+ },
+ "application/vnd.fsc.weblaunch": {
+ "source": "iana",
+ "extensions": ["fsc"]
+ },
+ "application/vnd.fujifilm.fb.docuworks": {
+ "source": "iana"
+ },
+ "application/vnd.fujifilm.fb.docuworks.binder": {
+ "source": "iana"
+ },
+ "application/vnd.fujifilm.fb.docuworks.container": {
+ "source": "iana"
+ },
+ "application/vnd.fujifilm.fb.jfi+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.fujitsu.oasys": {
+ "source": "iana",
+ "extensions": ["oas"]
+ },
+ "application/vnd.fujitsu.oasys2": {
+ "source": "iana",
+ "extensions": ["oa2"]
+ },
+ "application/vnd.fujitsu.oasys3": {
+ "source": "iana",
+ "extensions": ["oa3"]
+ },
+ "application/vnd.fujitsu.oasysgp": {
+ "source": "iana",
+ "extensions": ["fg5"]
+ },
+ "application/vnd.fujitsu.oasysprs": {
+ "source": "iana",
+ "extensions": ["bh2"]
+ },
+ "application/vnd.fujixerox.art-ex": {
+ "source": "iana"
+ },
+ "application/vnd.fujixerox.art4": {
+ "source": "iana"
+ },
+ "application/vnd.fujixerox.ddd": {
+ "source": "iana",
+ "extensions": ["ddd"]
+ },
+ "application/vnd.fujixerox.docuworks": {
+ "source": "iana",
+ "extensions": ["xdw"]
+ },
+ "application/vnd.fujixerox.docuworks.binder": {
+ "source": "iana",
+ "extensions": ["xbd"]
+ },
+ "application/vnd.fujixerox.docuworks.container": {
+ "source": "iana"
+ },
+ "application/vnd.fujixerox.hbpl": {
+ "source": "iana"
+ },
+ "application/vnd.fut-misnet": {
+ "source": "iana"
+ },
+ "application/vnd.futoin+cbor": {
+ "source": "iana"
+ },
+ "application/vnd.futoin+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.fuzzysheet": {
+ "source": "iana",
+ "extensions": ["fzs"]
+ },
+ "application/vnd.genomatix.tuxedo": {
+ "source": "iana",
+ "extensions": ["txd"]
+ },
+ "application/vnd.gentics.grd+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.geo+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.geocube+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.geogebra.file": {
+ "source": "iana",
+ "extensions": ["ggb"]
+ },
+ "application/vnd.geogebra.slides": {
+ "source": "iana"
+ },
+ "application/vnd.geogebra.tool": {
+ "source": "iana",
+ "extensions": ["ggt"]
+ },
+ "application/vnd.geometry-explorer": {
+ "source": "iana",
+ "extensions": ["gex","gre"]
+ },
+ "application/vnd.geonext": {
+ "source": "iana",
+ "extensions": ["gxt"]
+ },
+ "application/vnd.geoplan": {
+ "source": "iana",
+ "extensions": ["g2w"]
+ },
+ "application/vnd.geospace": {
+ "source": "iana",
+ "extensions": ["g3w"]
+ },
+ "application/vnd.gerber": {
+ "source": "iana"
+ },
+ "application/vnd.globalplatform.card-content-mgt": {
+ "source": "iana"
+ },
+ "application/vnd.globalplatform.card-content-mgt-response": {
+ "source": "iana"
+ },
+ "application/vnd.gmx": {
+ "source": "iana",
+ "extensions": ["gmx"]
+ },
+ "application/vnd.google-apps.document": {
+ "compressible": false,
+ "extensions": ["gdoc"]
+ },
+ "application/vnd.google-apps.presentation": {
+ "compressible": false,
+ "extensions": ["gslides"]
+ },
+ "application/vnd.google-apps.spreadsheet": {
+ "compressible": false,
+ "extensions": ["gsheet"]
+ },
+ "application/vnd.google-earth.kml+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["kml"]
+ },
+ "application/vnd.google-earth.kmz": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["kmz"]
+ },
+ "application/vnd.gov.sk.e-form+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.gov.sk.e-form+zip": {
+ "source": "iana",
+ "compressible": false
+ },
+ "application/vnd.gov.sk.xmldatacontainer+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.grafeq": {
+ "source": "iana",
+ "extensions": ["gqf","gqs"]
+ },
+ "application/vnd.gridmp": {
+ "source": "iana"
+ },
+ "application/vnd.groove-account": {
+ "source": "iana",
+ "extensions": ["gac"]
+ },
+ "application/vnd.groove-help": {
+ "source": "iana",
+ "extensions": ["ghf"]
+ },
+ "application/vnd.groove-identity-message": {
+ "source": "iana",
+ "extensions": ["gim"]
+ },
+ "application/vnd.groove-injector": {
+ "source": "iana",
+ "extensions": ["grv"]
+ },
+ "application/vnd.groove-tool-message": {
+ "source": "iana",
+ "extensions": ["gtm"]
+ },
+ "application/vnd.groove-tool-template": {
+ "source": "iana",
+ "extensions": ["tpl"]
+ },
+ "application/vnd.groove-vcard": {
+ "source": "iana",
+ "extensions": ["vcg"]
+ },
+ "application/vnd.hal+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.hal+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["hal"]
+ },
+ "application/vnd.handheld-entertainment+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["zmm"]
+ },
+ "application/vnd.hbci": {
+ "source": "iana",
+ "extensions": ["hbci"]
+ },
+ "application/vnd.hc+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.hcl-bireports": {
+ "source": "iana"
+ },
+ "application/vnd.hdt": {
+ "source": "iana"
+ },
+ "application/vnd.heroku+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.hhe.lesson-player": {
+ "source": "iana",
+ "extensions": ["les"]
+ },
+ "application/vnd.hp-hpgl": {
+ "source": "iana",
+ "extensions": ["hpgl"]
+ },
+ "application/vnd.hp-hpid": {
+ "source": "iana",
+ "extensions": ["hpid"]
+ },
+ "application/vnd.hp-hps": {
+ "source": "iana",
+ "extensions": ["hps"]
+ },
+ "application/vnd.hp-jlyt": {
+ "source": "iana",
+ "extensions": ["jlt"]
+ },
+ "application/vnd.hp-pcl": {
+ "source": "iana",
+ "extensions": ["pcl"]
+ },
+ "application/vnd.hp-pclxl": {
+ "source": "iana",
+ "extensions": ["pclxl"]
+ },
+ "application/vnd.httphone": {
+ "source": "iana"
+ },
+ "application/vnd.hydrostatix.sof-data": {
+ "source": "iana",
+ "extensions": ["sfd-hdstx"]
+ },
+ "application/vnd.hyper+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.hyper-item+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.hyperdrive+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.hzn-3d-crossword": {
+ "source": "iana"
+ },
+ "application/vnd.ibm.afplinedata": {
+ "source": "iana"
+ },
+ "application/vnd.ibm.electronic-media": {
+ "source": "iana"
+ },
+ "application/vnd.ibm.minipay": {
+ "source": "iana",
+ "extensions": ["mpy"]
+ },
+ "application/vnd.ibm.modcap": {
+ "source": "iana",
+ "extensions": ["afp","listafp","list3820"]
+ },
+ "application/vnd.ibm.rights-management": {
+ "source": "iana",
+ "extensions": ["irm"]
+ },
+ "application/vnd.ibm.secure-container": {
+ "source": "iana",
+ "extensions": ["sc"]
+ },
+ "application/vnd.iccprofile": {
+ "source": "iana",
+ "extensions": ["icc","icm"]
+ },
+ "application/vnd.ieee.1905": {
+ "source": "iana"
+ },
+ "application/vnd.igloader": {
+ "source": "iana",
+ "extensions": ["igl"]
+ },
+ "application/vnd.imagemeter.folder+zip": {
+ "source": "iana",
+ "compressible": false
+ },
+ "application/vnd.imagemeter.image+zip": {
+ "source": "iana",
+ "compressible": false
+ },
+ "application/vnd.immervision-ivp": {
+ "source": "iana",
+ "extensions": ["ivp"]
+ },
+ "application/vnd.immervision-ivu": {
+ "source": "iana",
+ "extensions": ["ivu"]
+ },
+ "application/vnd.ims.imsccv1p1": {
+ "source": "iana"
+ },
+ "application/vnd.ims.imsccv1p2": {
+ "source": "iana"
+ },
+ "application/vnd.ims.imsccv1p3": {
+ "source": "iana"
+ },
+ "application/vnd.ims.lis.v2.result+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.ims.lti.v2.toolconsumerprofile+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.ims.lti.v2.toolproxy+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.ims.lti.v2.toolproxy.id+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.ims.lti.v2.toolsettings+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.ims.lti.v2.toolsettings.simple+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.informedcontrol.rms+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.informix-visionary": {
+ "source": "iana"
+ },
+ "application/vnd.infotech.project": {
+ "source": "iana"
+ },
+ "application/vnd.infotech.project+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.innopath.wamp.notification": {
+ "source": "iana"
+ },
+ "application/vnd.insors.igm": {
+ "source": "iana",
+ "extensions": ["igm"]
+ },
+ "application/vnd.intercon.formnet": {
+ "source": "iana",
+ "extensions": ["xpw","xpx"]
+ },
+ "application/vnd.intergeo": {
+ "source": "iana",
+ "extensions": ["i2g"]
+ },
+ "application/vnd.intertrust.digibox": {
+ "source": "iana"
+ },
+ "application/vnd.intertrust.nncp": {
+ "source": "iana"
+ },
+ "application/vnd.intu.qbo": {
+ "source": "iana",
+ "extensions": ["qbo"]
+ },
+ "application/vnd.intu.qfx": {
+ "source": "iana",
+ "extensions": ["qfx"]
+ },
+ "application/vnd.iptc.g2.catalogitem+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.iptc.g2.conceptitem+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.iptc.g2.knowledgeitem+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.iptc.g2.newsitem+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.iptc.g2.newsmessage+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.iptc.g2.packageitem+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.iptc.g2.planningitem+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.ipunplugged.rcprofile": {
+ "source": "iana",
+ "extensions": ["rcprofile"]
+ },
+ "application/vnd.irepository.package+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["irp"]
+ },
+ "application/vnd.is-xpr": {
+ "source": "iana",
+ "extensions": ["xpr"]
+ },
+ "application/vnd.isac.fcs": {
+ "source": "iana",
+ "extensions": ["fcs"]
+ },
+ "application/vnd.iso11783-10+zip": {
+ "source": "iana",
+ "compressible": false
+ },
+ "application/vnd.jam": {
+ "source": "iana",
+ "extensions": ["jam"]
+ },
+ "application/vnd.japannet-directory-service": {
+ "source": "iana"
+ },
+ "application/vnd.japannet-jpnstore-wakeup": {
+ "source": "iana"
+ },
+ "application/vnd.japannet-payment-wakeup": {
+ "source": "iana"
+ },
+ "application/vnd.japannet-registration": {
+ "source": "iana"
+ },
+ "application/vnd.japannet-registration-wakeup": {
+ "source": "iana"
+ },
+ "application/vnd.japannet-setstore-wakeup": {
+ "source": "iana"
+ },
+ "application/vnd.japannet-verification": {
+ "source": "iana"
+ },
+ "application/vnd.japannet-verification-wakeup": {
+ "source": "iana"
+ },
+ "application/vnd.jcp.javame.midlet-rms": {
+ "source": "iana",
+ "extensions": ["rms"]
+ },
+ "application/vnd.jisp": {
+ "source": "iana",
+ "extensions": ["jisp"]
+ },
+ "application/vnd.joost.joda-archive": {
+ "source": "iana",
+ "extensions": ["joda"]
+ },
+ "application/vnd.jsk.isdn-ngn": {
+ "source": "iana"
+ },
+ "application/vnd.kahootz": {
+ "source": "iana",
+ "extensions": ["ktz","ktr"]
+ },
+ "application/vnd.kde.karbon": {
+ "source": "iana",
+ "extensions": ["karbon"]
+ },
+ "application/vnd.kde.kchart": {
+ "source": "iana",
+ "extensions": ["chrt"]
+ },
+ "application/vnd.kde.kformula": {
+ "source": "iana",
+ "extensions": ["kfo"]
+ },
+ "application/vnd.kde.kivio": {
+ "source": "iana",
+ "extensions": ["flw"]
+ },
+ "application/vnd.kde.kontour": {
+ "source": "iana",
+ "extensions": ["kon"]
+ },
+ "application/vnd.kde.kpresenter": {
+ "source": "iana",
+ "extensions": ["kpr","kpt"]
+ },
+ "application/vnd.kde.kspread": {
+ "source": "iana",
+ "extensions": ["ksp"]
+ },
+ "application/vnd.kde.kword": {
+ "source": "iana",
+ "extensions": ["kwd","kwt"]
+ },
+ "application/vnd.kenameaapp": {
+ "source": "iana",
+ "extensions": ["htke"]
+ },
+ "application/vnd.kidspiration": {
+ "source": "iana",
+ "extensions": ["kia"]
+ },
+ "application/vnd.kinar": {
+ "source": "iana",
+ "extensions": ["kne","knp"]
+ },
+ "application/vnd.koan": {
+ "source": "iana",
+ "extensions": ["skp","skd","skt","skm"]
+ },
+ "application/vnd.kodak-descriptor": {
+ "source": "iana",
+ "extensions": ["sse"]
+ },
+ "application/vnd.las": {
+ "source": "iana"
+ },
+ "application/vnd.las.las+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.las.las+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["lasxml"]
+ },
+ "application/vnd.laszip": {
+ "source": "iana"
+ },
+ "application/vnd.leap+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.liberty-request+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.llamagraphics.life-balance.desktop": {
+ "source": "iana",
+ "extensions": ["lbd"]
+ },
+ "application/vnd.llamagraphics.life-balance.exchange+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["lbe"]
+ },
+ "application/vnd.logipipe.circuit+zip": {
+ "source": "iana",
+ "compressible": false
+ },
+ "application/vnd.loom": {
+ "source": "iana"
+ },
+ "application/vnd.lotus-1-2-3": {
+ "source": "iana",
+ "extensions": ["123"]
+ },
+ "application/vnd.lotus-approach": {
+ "source": "iana",
+ "extensions": ["apr"]
+ },
+ "application/vnd.lotus-freelance": {
+ "source": "iana",
+ "extensions": ["pre"]
+ },
+ "application/vnd.lotus-notes": {
+ "source": "iana",
+ "extensions": ["nsf"]
+ },
+ "application/vnd.lotus-organizer": {
+ "source": "iana",
+ "extensions": ["org"]
+ },
+ "application/vnd.lotus-screencam": {
+ "source": "iana",
+ "extensions": ["scm"]
+ },
+ "application/vnd.lotus-wordpro": {
+ "source": "iana",
+ "extensions": ["lwp"]
+ },
+ "application/vnd.macports.portpkg": {
+ "source": "iana",
+ "extensions": ["portpkg"]
+ },
+ "application/vnd.mapbox-vector-tile": {
+ "source": "iana",
+ "extensions": ["mvt"]
+ },
+ "application/vnd.marlin.drm.actiontoken+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.marlin.drm.conftoken+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.marlin.drm.license+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.marlin.drm.mdcf": {
+ "source": "iana"
+ },
+ "application/vnd.mason+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.maxmind.maxmind-db": {
+ "source": "iana"
+ },
+ "application/vnd.mcd": {
+ "source": "iana",
+ "extensions": ["mcd"]
+ },
+ "application/vnd.medcalcdata": {
+ "source": "iana",
+ "extensions": ["mc1"]
+ },
+ "application/vnd.mediastation.cdkey": {
+ "source": "iana",
+ "extensions": ["cdkey"]
+ },
+ "application/vnd.meridian-slingshot": {
+ "source": "iana"
+ },
+ "application/vnd.mfer": {
+ "source": "iana",
+ "extensions": ["mwf"]
+ },
+ "application/vnd.mfmp": {
+ "source": "iana",
+ "extensions": ["mfm"]
+ },
+ "application/vnd.micro+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.micrografx.flo": {
+ "source": "iana",
+ "extensions": ["flo"]
+ },
+ "application/vnd.micrografx.igx": {
+ "source": "iana",
+ "extensions": ["igx"]
+ },
+ "application/vnd.microsoft.portable-executable": {
+ "source": "iana"
+ },
+ "application/vnd.microsoft.windows.thumbnail-cache": {
+ "source": "iana"
+ },
+ "application/vnd.miele+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.mif": {
+ "source": "iana",
+ "extensions": ["mif"]
+ },
+ "application/vnd.minisoft-hp3000-save": {
+ "source": "iana"
+ },
+ "application/vnd.mitsubishi.misty-guard.trustweb": {
+ "source": "iana"
+ },
+ "application/vnd.mobius.daf": {
+ "source": "iana",
+ "extensions": ["daf"]
+ },
+ "application/vnd.mobius.dis": {
+ "source": "iana",
+ "extensions": ["dis"]
+ },
+ "application/vnd.mobius.mbk": {
+ "source": "iana",
+ "extensions": ["mbk"]
+ },
+ "application/vnd.mobius.mqy": {
+ "source": "iana",
+ "extensions": ["mqy"]
+ },
+ "application/vnd.mobius.msl": {
+ "source": "iana",
+ "extensions": ["msl"]
+ },
+ "application/vnd.mobius.plc": {
+ "source": "iana",
+ "extensions": ["plc"]
+ },
+ "application/vnd.mobius.txf": {
+ "source": "iana",
+ "extensions": ["txf"]
+ },
+ "application/vnd.mophun.application": {
+ "source": "iana",
+ "extensions": ["mpn"]
+ },
+ "application/vnd.mophun.certificate": {
+ "source": "iana",
+ "extensions": ["mpc"]
+ },
+ "application/vnd.motorola.flexsuite": {
+ "source": "iana"
+ },
+ "application/vnd.motorola.flexsuite.adsi": {
+ "source": "iana"
+ },
+ "application/vnd.motorola.flexsuite.fis": {
+ "source": "iana"
+ },
+ "application/vnd.motorola.flexsuite.gotap": {
+ "source": "iana"
+ },
+ "application/vnd.motorola.flexsuite.kmr": {
+ "source": "iana"
+ },
+ "application/vnd.motorola.flexsuite.ttc": {
+ "source": "iana"
+ },
+ "application/vnd.motorola.flexsuite.wem": {
+ "source": "iana"
+ },
+ "application/vnd.motorola.iprm": {
+ "source": "iana"
+ },
+ "application/vnd.mozilla.xul+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["xul"]
+ },
+ "application/vnd.ms-3mfdocument": {
+ "source": "iana"
+ },
+ "application/vnd.ms-artgalry": {
+ "source": "iana",
+ "extensions": ["cil"]
+ },
+ "application/vnd.ms-asf": {
+ "source": "iana"
+ },
+ "application/vnd.ms-cab-compressed": {
+ "source": "iana",
+ "extensions": ["cab"]
+ },
+ "application/vnd.ms-color.iccprofile": {
+ "source": "apache"
+ },
+ "application/vnd.ms-excel": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["xls","xlm","xla","xlc","xlt","xlw"]
+ },
+ "application/vnd.ms-excel.addin.macroenabled.12": {
+ "source": "iana",
+ "extensions": ["xlam"]
+ },
+ "application/vnd.ms-excel.sheet.binary.macroenabled.12": {
+ "source": "iana",
+ "extensions": ["xlsb"]
+ },
+ "application/vnd.ms-excel.sheet.macroenabled.12": {
+ "source": "iana",
+ "extensions": ["xlsm"]
+ },
+ "application/vnd.ms-excel.template.macroenabled.12": {
+ "source": "iana",
+ "extensions": ["xltm"]
+ },
+ "application/vnd.ms-fontobject": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["eot"]
+ },
+ "application/vnd.ms-htmlhelp": {
+ "source": "iana",
+ "extensions": ["chm"]
+ },
+ "application/vnd.ms-ims": {
+ "source": "iana",
+ "extensions": ["ims"]
+ },
+ "application/vnd.ms-lrm": {
+ "source": "iana",
+ "extensions": ["lrm"]
+ },
+ "application/vnd.ms-office.activex+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.ms-officetheme": {
+ "source": "iana",
+ "extensions": ["thmx"]
+ },
+ "application/vnd.ms-opentype": {
+ "source": "apache",
+ "compressible": true
+ },
+ "application/vnd.ms-outlook": {
+ "compressible": false,
+ "extensions": ["msg"]
+ },
+ "application/vnd.ms-package.obfuscated-opentype": {
+ "source": "apache"
+ },
+ "application/vnd.ms-pki.seccat": {
+ "source": "apache",
+ "extensions": ["cat"]
+ },
+ "application/vnd.ms-pki.stl": {
+ "source": "apache",
+ "extensions": ["stl"]
+ },
+ "application/vnd.ms-playready.initiator+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.ms-powerpoint": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["ppt","pps","pot"]
+ },
+ "application/vnd.ms-powerpoint.addin.macroenabled.12": {
+ "source": "iana",
+ "extensions": ["ppam"]
+ },
+ "application/vnd.ms-powerpoint.presentation.macroenabled.12": {
+ "source": "iana",
+ "extensions": ["pptm"]
+ },
+ "application/vnd.ms-powerpoint.slide.macroenabled.12": {
+ "source": "iana",
+ "extensions": ["sldm"]
+ },
+ "application/vnd.ms-powerpoint.slideshow.macroenabled.12": {
+ "source": "iana",
+ "extensions": ["ppsm"]
+ },
+ "application/vnd.ms-powerpoint.template.macroenabled.12": {
+ "source": "iana",
+ "extensions": ["potm"]
+ },
+ "application/vnd.ms-printdevicecapabilities+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.ms-printing.printticket+xml": {
+ "source": "apache",
+ "compressible": true
+ },
+ "application/vnd.ms-printschematicket+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.ms-project": {
+ "source": "iana",
+ "extensions": ["mpp","mpt"]
+ },
+ "application/vnd.ms-tnef": {
+ "source": "iana"
+ },
+ "application/vnd.ms-windows.devicepairing": {
+ "source": "iana"
+ },
+ "application/vnd.ms-windows.nwprinting.oob": {
+ "source": "iana"
+ },
+ "application/vnd.ms-windows.printerpairing": {
+ "source": "iana"
+ },
+ "application/vnd.ms-windows.wsd.oob": {
+ "source": "iana"
+ },
+ "application/vnd.ms-wmdrm.lic-chlg-req": {
+ "source": "iana"
+ },
+ "application/vnd.ms-wmdrm.lic-resp": {
+ "source": "iana"
+ },
+ "application/vnd.ms-wmdrm.meter-chlg-req": {
+ "source": "iana"
+ },
+ "application/vnd.ms-wmdrm.meter-resp": {
+ "source": "iana"
+ },
+ "application/vnd.ms-word.document.macroenabled.12": {
+ "source": "iana",
+ "extensions": ["docm"]
+ },
+ "application/vnd.ms-word.template.macroenabled.12": {
+ "source": "iana",
+ "extensions": ["dotm"]
+ },
+ "application/vnd.ms-works": {
+ "source": "iana",
+ "extensions": ["wps","wks","wcm","wdb"]
+ },
+ "application/vnd.ms-wpl": {
+ "source": "iana",
+ "extensions": ["wpl"]
+ },
+ "application/vnd.ms-xpsdocument": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["xps"]
+ },
+ "application/vnd.msa-disk-image": {
+ "source": "iana"
+ },
+ "application/vnd.mseq": {
+ "source": "iana",
+ "extensions": ["mseq"]
+ },
+ "application/vnd.msign": {
+ "source": "iana"
+ },
+ "application/vnd.multiad.creator": {
+ "source": "iana"
+ },
+ "application/vnd.multiad.creator.cif": {
+ "source": "iana"
+ },
+ "application/vnd.music-niff": {
+ "source": "iana"
+ },
+ "application/vnd.musician": {
+ "source": "iana",
+ "extensions": ["mus"]
+ },
+ "application/vnd.muvee.style": {
+ "source": "iana",
+ "extensions": ["msty"]
+ },
+ "application/vnd.mynfc": {
+ "source": "iana",
+ "extensions": ["taglet"]
+ },
+ "application/vnd.nacamar.ybrid+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.ncd.control": {
+ "source": "iana"
+ },
+ "application/vnd.ncd.reference": {
+ "source": "iana"
+ },
+ "application/vnd.nearst.inv+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.nebumind.line": {
+ "source": "iana"
+ },
+ "application/vnd.nervana": {
+ "source": "iana"
+ },
+ "application/vnd.netfpx": {
+ "source": "iana"
+ },
+ "application/vnd.neurolanguage.nlu": {
+ "source": "iana",
+ "extensions": ["nlu"]
+ },
+ "application/vnd.nimn": {
+ "source": "iana"
+ },
+ "application/vnd.nintendo.nitro.rom": {
+ "source": "iana"
+ },
+ "application/vnd.nintendo.snes.rom": {
+ "source": "iana"
+ },
+ "application/vnd.nitf": {
+ "source": "iana",
+ "extensions": ["ntf","nitf"]
+ },
+ "application/vnd.noblenet-directory": {
+ "source": "iana",
+ "extensions": ["nnd"]
+ },
+ "application/vnd.noblenet-sealer": {
+ "source": "iana",
+ "extensions": ["nns"]
+ },
+ "application/vnd.noblenet-web": {
+ "source": "iana",
+ "extensions": ["nnw"]
+ },
+ "application/vnd.nokia.catalogs": {
+ "source": "iana"
+ },
+ "application/vnd.nokia.conml+wbxml": {
+ "source": "iana"
+ },
+ "application/vnd.nokia.conml+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.nokia.iptv.config+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.nokia.isds-radio-presets": {
+ "source": "iana"
+ },
+ "application/vnd.nokia.landmark+wbxml": {
+ "source": "iana"
+ },
+ "application/vnd.nokia.landmark+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.nokia.landmarkcollection+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.nokia.n-gage.ac+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["ac"]
+ },
+ "application/vnd.nokia.n-gage.data": {
+ "source": "iana",
+ "extensions": ["ngdat"]
+ },
+ "application/vnd.nokia.n-gage.symbian.install": {
+ "source": "iana",
+ "extensions": ["n-gage"]
+ },
+ "application/vnd.nokia.ncd": {
+ "source": "iana"
+ },
+ "application/vnd.nokia.pcd+wbxml": {
+ "source": "iana"
+ },
+ "application/vnd.nokia.pcd+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.nokia.radio-preset": {
+ "source": "iana",
+ "extensions": ["rpst"]
+ },
+ "application/vnd.nokia.radio-presets": {
+ "source": "iana",
+ "extensions": ["rpss"]
+ },
+ "application/vnd.novadigm.edm": {
+ "source": "iana",
+ "extensions": ["edm"]
+ },
+ "application/vnd.novadigm.edx": {
+ "source": "iana",
+ "extensions": ["edx"]
+ },
+ "application/vnd.novadigm.ext": {
+ "source": "iana",
+ "extensions": ["ext"]
+ },
+ "application/vnd.ntt-local.content-share": {
+ "source": "iana"
+ },
+ "application/vnd.ntt-local.file-transfer": {
+ "source": "iana"
+ },
+ "application/vnd.ntt-local.ogw_remote-access": {
+ "source": "iana"
+ },
+ "application/vnd.ntt-local.sip-ta_remote": {
+ "source": "iana"
+ },
+ "application/vnd.ntt-local.sip-ta_tcp_stream": {
+ "source": "iana"
+ },
+ "application/vnd.oasis.opendocument.chart": {
+ "source": "iana",
+ "extensions": ["odc"]
+ },
+ "application/vnd.oasis.opendocument.chart-template": {
+ "source": "iana",
+ "extensions": ["otc"]
+ },
+ "application/vnd.oasis.opendocument.database": {
+ "source": "iana",
+ "extensions": ["odb"]
+ },
+ "application/vnd.oasis.opendocument.formula": {
+ "source": "iana",
+ "extensions": ["odf"]
+ },
+ "application/vnd.oasis.opendocument.formula-template": {
+ "source": "iana",
+ "extensions": ["odft"]
+ },
+ "application/vnd.oasis.opendocument.graphics": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["odg"]
+ },
+ "application/vnd.oasis.opendocument.graphics-template": {
+ "source": "iana",
+ "extensions": ["otg"]
+ },
+ "application/vnd.oasis.opendocument.image": {
+ "source": "iana",
+ "extensions": ["odi"]
+ },
+ "application/vnd.oasis.opendocument.image-template": {
+ "source": "iana",
+ "extensions": ["oti"]
+ },
+ "application/vnd.oasis.opendocument.presentation": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["odp"]
+ },
+ "application/vnd.oasis.opendocument.presentation-template": {
+ "source": "iana",
+ "extensions": ["otp"]
+ },
+ "application/vnd.oasis.opendocument.spreadsheet": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["ods"]
+ },
+ "application/vnd.oasis.opendocument.spreadsheet-template": {
+ "source": "iana",
+ "extensions": ["ots"]
+ },
+ "application/vnd.oasis.opendocument.text": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["odt"]
+ },
+ "application/vnd.oasis.opendocument.text-master": {
+ "source": "iana",
+ "extensions": ["odm"]
+ },
+ "application/vnd.oasis.opendocument.text-template": {
+ "source": "iana",
+ "extensions": ["ott"]
+ },
+ "application/vnd.oasis.opendocument.text-web": {
+ "source": "iana",
+ "extensions": ["oth"]
+ },
+ "application/vnd.obn": {
+ "source": "iana"
+ },
+ "application/vnd.ocf+cbor": {
+ "source": "iana"
+ },
+ "application/vnd.oci.image.manifest.v1+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oftn.l10n+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oipf.contentaccessdownload+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oipf.contentaccessstreaming+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oipf.cspg-hexbinary": {
+ "source": "iana"
+ },
+ "application/vnd.oipf.dae.svg+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oipf.dae.xhtml+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oipf.mippvcontrolmessage+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oipf.pae.gem": {
+ "source": "iana"
+ },
+ "application/vnd.oipf.spdiscovery+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oipf.spdlist+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oipf.ueprofile+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oipf.userprofile+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.olpc-sugar": {
+ "source": "iana",
+ "extensions": ["xo"]
+ },
+ "application/vnd.oma-scws-config": {
+ "source": "iana"
+ },
+ "application/vnd.oma-scws-http-request": {
+ "source": "iana"
+ },
+ "application/vnd.oma-scws-http-response": {
+ "source": "iana"
+ },
+ "application/vnd.oma.bcast.associated-procedure-parameter+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oma.bcast.drm-trigger+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oma.bcast.imd+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oma.bcast.ltkm": {
+ "source": "iana"
+ },
+ "application/vnd.oma.bcast.notification+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oma.bcast.provisioningtrigger": {
+ "source": "iana"
+ },
+ "application/vnd.oma.bcast.sgboot": {
+ "source": "iana"
+ },
+ "application/vnd.oma.bcast.sgdd+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oma.bcast.sgdu": {
+ "source": "iana"
+ },
+ "application/vnd.oma.bcast.simple-symbol-container": {
+ "source": "iana"
+ },
+ "application/vnd.oma.bcast.smartcard-trigger+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oma.bcast.sprov+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oma.bcast.stkm": {
+ "source": "iana"
+ },
+ "application/vnd.oma.cab-address-book+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oma.cab-feature-handler+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oma.cab-pcc+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oma.cab-subs-invite+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oma.cab-user-prefs+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oma.dcd": {
+ "source": "iana"
+ },
+ "application/vnd.oma.dcdc": {
+ "source": "iana"
+ },
+ "application/vnd.oma.dd2+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["dd2"]
+ },
+ "application/vnd.oma.drm.risd+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oma.group-usage-list+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oma.lwm2m+cbor": {
+ "source": "iana"
+ },
+ "application/vnd.oma.lwm2m+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oma.lwm2m+tlv": {
+ "source": "iana"
+ },
+ "application/vnd.oma.pal+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oma.poc.detailed-progress-report+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oma.poc.final-report+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oma.poc.groups+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oma.poc.invocation-descriptor+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oma.poc.optimized-progress-report+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oma.push": {
+ "source": "iana"
+ },
+ "application/vnd.oma.scidm.messages+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oma.xcap-directory+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.omads-email+xml": {
+ "source": "iana",
+ "charset": "UTF-8",
+ "compressible": true
+ },
+ "application/vnd.omads-file+xml": {
+ "source": "iana",
+ "charset": "UTF-8",
+ "compressible": true
+ },
+ "application/vnd.omads-folder+xml": {
+ "source": "iana",
+ "charset": "UTF-8",
+ "compressible": true
+ },
+ "application/vnd.omaloc-supl-init": {
+ "source": "iana"
+ },
+ "application/vnd.onepager": {
+ "source": "iana"
+ },
+ "application/vnd.onepagertamp": {
+ "source": "iana"
+ },
+ "application/vnd.onepagertamx": {
+ "source": "iana"
+ },
+ "application/vnd.onepagertat": {
+ "source": "iana"
+ },
+ "application/vnd.onepagertatp": {
+ "source": "iana"
+ },
+ "application/vnd.onepagertatx": {
+ "source": "iana"
+ },
+ "application/vnd.openblox.game+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["obgx"]
+ },
+ "application/vnd.openblox.game-binary": {
+ "source": "iana"
+ },
+ "application/vnd.openeye.oeb": {
+ "source": "iana"
+ },
+ "application/vnd.openofficeorg.extension": {
+ "source": "apache",
+ "extensions": ["oxt"]
+ },
+ "application/vnd.openstreetmap.data+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["osm"]
+ },
+ "application/vnd.opentimestamps.ots": {
+ "source": "iana"
+ },
+ "application/vnd.openxmlformats-officedocument.custom-properties+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.customxmlproperties+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.drawing+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.drawingml.chart+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.drawingml.diagramcolors+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.drawingml.diagramdata+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.drawingml.diagramlayout+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.drawingml.diagramstyle+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.extended-properties+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.presentationml.commentauthors+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.presentationml.comments+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.presentationml.handoutmaster+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.presentationml.notesmaster+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.presentationml.notesslide+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["pptx"]
+ },
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.presentationml.presprops+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.presentationml.slide": {
+ "source": "iana",
+ "extensions": ["sldx"]
+ },
+ "application/vnd.openxmlformats-officedocument.presentationml.slide+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.presentationml.slidelayout+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.presentationml.slidemaster+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.presentationml.slideshow": {
+ "source": "iana",
+ "extensions": ["ppsx"]
+ },
+ "application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.presentationml.slideupdateinfo+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.presentationml.tablestyles+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.presentationml.tags+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.presentationml.template": {
+ "source": "iana",
+ "extensions": ["potx"]
+ },
+ "application/vnd.openxmlformats-officedocument.presentationml.template.main+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.presentationml.viewprops+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.calcchain+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.externallink+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcachedefinition+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcacherecords+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.pivottable+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.querytable+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.revisionheaders+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.revisionlog+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedstrings+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["xlsx"]
+ },
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheetmetadata+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.tablesinglecells+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.template": {
+ "source": "iana",
+ "extensions": ["xltx"]
+ },
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.usernames+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.volatiledependencies+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.theme+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.themeoverride+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.vmldrawing": {
+ "source": "iana"
+ },
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["docx"]
+ },
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.fonttable+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.template": {
+ "source": "iana",
+ "extensions": ["dotx"]
+ },
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.websettings+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-package.core-properties+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.openxmlformats-package.relationships+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oracle.resource+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.orange.indata": {
+ "source": "iana"
+ },
+ "application/vnd.osa.netdeploy": {
+ "source": "iana"
+ },
+ "application/vnd.osgeo.mapguide.package": {
+ "source": "iana",
+ "extensions": ["mgp"]
+ },
+ "application/vnd.osgi.bundle": {
+ "source": "iana"
+ },
+ "application/vnd.osgi.dp": {
+ "source": "iana",
+ "extensions": ["dp"]
+ },
+ "application/vnd.osgi.subsystem": {
+ "source": "iana",
+ "extensions": ["esa"]
+ },
+ "application/vnd.otps.ct-kip+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.oxli.countgraph": {
+ "source": "iana"
+ },
+ "application/vnd.pagerduty+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.palm": {
+ "source": "iana",
+ "extensions": ["pdb","pqa","oprc"]
+ },
+ "application/vnd.panoply": {
+ "source": "iana"
+ },
+ "application/vnd.paos.xml": {
+ "source": "iana"
+ },
+ "application/vnd.patentdive": {
+ "source": "iana"
+ },
+ "application/vnd.patientecommsdoc": {
+ "source": "iana"
+ },
+ "application/vnd.pawaafile": {
+ "source": "iana",
+ "extensions": ["paw"]
+ },
+ "application/vnd.pcos": {
+ "source": "iana"
+ },
+ "application/vnd.pg.format": {
+ "source": "iana",
+ "extensions": ["str"]
+ },
+ "application/vnd.pg.osasli": {
+ "source": "iana",
+ "extensions": ["ei6"]
+ },
+ "application/vnd.piaccess.application-licence": {
+ "source": "iana"
+ },
+ "application/vnd.picsel": {
+ "source": "iana",
+ "extensions": ["efif"]
+ },
+ "application/vnd.pmi.widget": {
+ "source": "iana",
+ "extensions": ["wg"]
+ },
+ "application/vnd.poc.group-advertisement+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.pocketlearn": {
+ "source": "iana",
+ "extensions": ["plf"]
+ },
+ "application/vnd.powerbuilder6": {
+ "source": "iana",
+ "extensions": ["pbd"]
+ },
+ "application/vnd.powerbuilder6-s": {
+ "source": "iana"
+ },
+ "application/vnd.powerbuilder7": {
+ "source": "iana"
+ },
+ "application/vnd.powerbuilder7-s": {
+ "source": "iana"
+ },
+ "application/vnd.powerbuilder75": {
+ "source": "iana"
+ },
+ "application/vnd.powerbuilder75-s": {
+ "source": "iana"
+ },
+ "application/vnd.preminet": {
+ "source": "iana"
+ },
+ "application/vnd.previewsystems.box": {
+ "source": "iana",
+ "extensions": ["box"]
+ },
+ "application/vnd.proteus.magazine": {
+ "source": "iana",
+ "extensions": ["mgz"]
+ },
+ "application/vnd.psfs": {
+ "source": "iana"
+ },
+ "application/vnd.publishare-delta-tree": {
+ "source": "iana",
+ "extensions": ["qps"]
+ },
+ "application/vnd.pvi.ptid1": {
+ "source": "iana",
+ "extensions": ["ptid"]
+ },
+ "application/vnd.pwg-multiplexed": {
+ "source": "iana"
+ },
+ "application/vnd.pwg-xhtml-print+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.qualcomm.brew-app-res": {
+ "source": "iana"
+ },
+ "application/vnd.quarantainenet": {
+ "source": "iana"
+ },
+ "application/vnd.quark.quarkxpress": {
+ "source": "iana",
+ "extensions": ["qxd","qxt","qwd","qwt","qxl","qxb"]
+ },
+ "application/vnd.quobject-quoxdocument": {
+ "source": "iana"
+ },
+ "application/vnd.radisys.moml+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.radisys.msml+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.radisys.msml-audit+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.radisys.msml-audit-conf+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.radisys.msml-audit-conn+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.radisys.msml-audit-dialog+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.radisys.msml-audit-stream+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.radisys.msml-conf+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.radisys.msml-dialog+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.radisys.msml-dialog-base+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.radisys.msml-dialog-fax-detect+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.radisys.msml-dialog-fax-sendrecv+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.radisys.msml-dialog-group+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.radisys.msml-dialog-speech+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.radisys.msml-dialog-transform+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.rainstor.data": {
+ "source": "iana"
+ },
+ "application/vnd.rapid": {
+ "source": "iana"
+ },
+ "application/vnd.rar": {
+ "source": "iana",
+ "extensions": ["rar"]
+ },
+ "application/vnd.realvnc.bed": {
+ "source": "iana",
+ "extensions": ["bed"]
+ },
+ "application/vnd.recordare.musicxml": {
+ "source": "iana",
+ "extensions": ["mxl"]
+ },
+ "application/vnd.recordare.musicxml+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["musicxml"]
+ },
+ "application/vnd.renlearn.rlprint": {
+ "source": "iana"
+ },
+ "application/vnd.resilient.logic": {
+ "source": "iana"
+ },
+ "application/vnd.restful+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.rig.cryptonote": {
+ "source": "iana",
+ "extensions": ["cryptonote"]
+ },
+ "application/vnd.rim.cod": {
+ "source": "apache",
+ "extensions": ["cod"]
+ },
+ "application/vnd.rn-realmedia": {
+ "source": "apache",
+ "extensions": ["rm"]
+ },
+ "application/vnd.rn-realmedia-vbr": {
+ "source": "apache",
+ "extensions": ["rmvb"]
+ },
+ "application/vnd.route66.link66+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["link66"]
+ },
+ "application/vnd.rs-274x": {
+ "source": "iana"
+ },
+ "application/vnd.ruckus.download": {
+ "source": "iana"
+ },
+ "application/vnd.s3sms": {
+ "source": "iana"
+ },
+ "application/vnd.sailingtracker.track": {
+ "source": "iana",
+ "extensions": ["st"]
+ },
+ "application/vnd.sar": {
+ "source": "iana"
+ },
+ "application/vnd.sbm.cid": {
+ "source": "iana"
+ },
+ "application/vnd.sbm.mid2": {
+ "source": "iana"
+ },
+ "application/vnd.scribus": {
+ "source": "iana"
+ },
+ "application/vnd.sealed.3df": {
+ "source": "iana"
+ },
+ "application/vnd.sealed.csf": {
+ "source": "iana"
+ },
+ "application/vnd.sealed.doc": {
+ "source": "iana"
+ },
+ "application/vnd.sealed.eml": {
+ "source": "iana"
+ },
+ "application/vnd.sealed.mht": {
+ "source": "iana"
+ },
+ "application/vnd.sealed.net": {
+ "source": "iana"
+ },
+ "application/vnd.sealed.ppt": {
+ "source": "iana"
+ },
+ "application/vnd.sealed.tiff": {
+ "source": "iana"
+ },
+ "application/vnd.sealed.xls": {
+ "source": "iana"
+ },
+ "application/vnd.sealedmedia.softseal.html": {
+ "source": "iana"
+ },
+ "application/vnd.sealedmedia.softseal.pdf": {
+ "source": "iana"
+ },
+ "application/vnd.seemail": {
+ "source": "iana",
+ "extensions": ["see"]
+ },
+ "application/vnd.seis+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.sema": {
+ "source": "iana",
+ "extensions": ["sema"]
+ },
+ "application/vnd.semd": {
+ "source": "iana",
+ "extensions": ["semd"]
+ },
+ "application/vnd.semf": {
+ "source": "iana",
+ "extensions": ["semf"]
+ },
+ "application/vnd.shade-save-file": {
+ "source": "iana"
+ },
+ "application/vnd.shana.informed.formdata": {
+ "source": "iana",
+ "extensions": ["ifm"]
+ },
+ "application/vnd.shana.informed.formtemplate": {
+ "source": "iana",
+ "extensions": ["itp"]
+ },
+ "application/vnd.shana.informed.interchange": {
+ "source": "iana",
+ "extensions": ["iif"]
+ },
+ "application/vnd.shana.informed.package": {
+ "source": "iana",
+ "extensions": ["ipk"]
+ },
+ "application/vnd.shootproof+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.shopkick+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.shp": {
+ "source": "iana"
+ },
+ "application/vnd.shx": {
+ "source": "iana"
+ },
+ "application/vnd.sigrok.session": {
+ "source": "iana"
+ },
+ "application/vnd.simtech-mindmapper": {
+ "source": "iana",
+ "extensions": ["twd","twds"]
+ },
+ "application/vnd.siren+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.smaf": {
+ "source": "iana",
+ "extensions": ["mmf"]
+ },
+ "application/vnd.smart.notebook": {
+ "source": "iana"
+ },
+ "application/vnd.smart.teacher": {
+ "source": "iana",
+ "extensions": ["teacher"]
+ },
+ "application/vnd.snesdev-page-table": {
+ "source": "iana"
+ },
+ "application/vnd.software602.filler.form+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["fo"]
+ },
+ "application/vnd.software602.filler.form-xml-zip": {
+ "source": "iana"
+ },
+ "application/vnd.solent.sdkm+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["sdkm","sdkd"]
+ },
+ "application/vnd.spotfire.dxp": {
+ "source": "iana",
+ "extensions": ["dxp"]
+ },
+ "application/vnd.spotfire.sfs": {
+ "source": "iana",
+ "extensions": ["sfs"]
+ },
+ "application/vnd.sqlite3": {
+ "source": "iana"
+ },
+ "application/vnd.sss-cod": {
+ "source": "iana"
+ },
+ "application/vnd.sss-dtf": {
+ "source": "iana"
+ },
+ "application/vnd.sss-ntf": {
+ "source": "iana"
+ },
+ "application/vnd.stardivision.calc": {
+ "source": "apache",
+ "extensions": ["sdc"]
+ },
+ "application/vnd.stardivision.draw": {
+ "source": "apache",
+ "extensions": ["sda"]
+ },
+ "application/vnd.stardivision.impress": {
+ "source": "apache",
+ "extensions": ["sdd"]
+ },
+ "application/vnd.stardivision.math": {
+ "source": "apache",
+ "extensions": ["smf"]
+ },
+ "application/vnd.stardivision.writer": {
+ "source": "apache",
+ "extensions": ["sdw","vor"]
+ },
+ "application/vnd.stardivision.writer-global": {
+ "source": "apache",
+ "extensions": ["sgl"]
+ },
+ "application/vnd.stepmania.package": {
+ "source": "iana",
+ "extensions": ["smzip"]
+ },
+ "application/vnd.stepmania.stepchart": {
+ "source": "iana",
+ "extensions": ["sm"]
+ },
+ "application/vnd.street-stream": {
+ "source": "iana"
+ },
+ "application/vnd.sun.wadl+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["wadl"]
+ },
+ "application/vnd.sun.xml.calc": {
+ "source": "apache",
+ "extensions": ["sxc"]
+ },
+ "application/vnd.sun.xml.calc.template": {
+ "source": "apache",
+ "extensions": ["stc"]
+ },
+ "application/vnd.sun.xml.draw": {
+ "source": "apache",
+ "extensions": ["sxd"]
+ },
+ "application/vnd.sun.xml.draw.template": {
+ "source": "apache",
+ "extensions": ["std"]
+ },
+ "application/vnd.sun.xml.impress": {
+ "source": "apache",
+ "extensions": ["sxi"]
+ },
+ "application/vnd.sun.xml.impress.template": {
+ "source": "apache",
+ "extensions": ["sti"]
+ },
+ "application/vnd.sun.xml.math": {
+ "source": "apache",
+ "extensions": ["sxm"]
+ },
+ "application/vnd.sun.xml.writer": {
+ "source": "apache",
+ "extensions": ["sxw"]
+ },
+ "application/vnd.sun.xml.writer.global": {
+ "source": "apache",
+ "extensions": ["sxg"]
+ },
+ "application/vnd.sun.xml.writer.template": {
+ "source": "apache",
+ "extensions": ["stw"]
+ },
+ "application/vnd.sus-calendar": {
+ "source": "iana",
+ "extensions": ["sus","susp"]
+ },
+ "application/vnd.svd": {
+ "source": "iana",
+ "extensions": ["svd"]
+ },
+ "application/vnd.swiftview-ics": {
+ "source": "iana"
+ },
+ "application/vnd.sycle+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.symbian.install": {
+ "source": "apache",
+ "extensions": ["sis","sisx"]
+ },
+ "application/vnd.syncml+xml": {
+ "source": "iana",
+ "charset": "UTF-8",
+ "compressible": true,
+ "extensions": ["xsm"]
+ },
+ "application/vnd.syncml.dm+wbxml": {
+ "source": "iana",
+ "charset": "UTF-8",
+ "extensions": ["bdm"]
+ },
+ "application/vnd.syncml.dm+xml": {
+ "source": "iana",
+ "charset": "UTF-8",
+ "compressible": true,
+ "extensions": ["xdm"]
+ },
+ "application/vnd.syncml.dm.notification": {
+ "source": "iana"
+ },
+ "application/vnd.syncml.dmddf+wbxml": {
+ "source": "iana"
+ },
+ "application/vnd.syncml.dmddf+xml": {
+ "source": "iana",
+ "charset": "UTF-8",
+ "compressible": true,
+ "extensions": ["ddf"]
+ },
+ "application/vnd.syncml.dmtnds+wbxml": {
+ "source": "iana"
+ },
+ "application/vnd.syncml.dmtnds+xml": {
+ "source": "iana",
+ "charset": "UTF-8",
+ "compressible": true
+ },
+ "application/vnd.syncml.ds.notification": {
+ "source": "iana"
+ },
+ "application/vnd.tableschema+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.tao.intent-module-archive": {
+ "source": "iana",
+ "extensions": ["tao"]
+ },
+ "application/vnd.tcpdump.pcap": {
+ "source": "iana",
+ "extensions": ["pcap","cap","dmp"]
+ },
+ "application/vnd.think-cell.ppttc+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.tmd.mediaflex.api+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.tml": {
+ "source": "iana"
+ },
+ "application/vnd.tmobile-livetv": {
+ "source": "iana",
+ "extensions": ["tmo"]
+ },
+ "application/vnd.tri.onesource": {
+ "source": "iana"
+ },
+ "application/vnd.trid.tpt": {
+ "source": "iana",
+ "extensions": ["tpt"]
+ },
+ "application/vnd.triscape.mxs": {
+ "source": "iana",
+ "extensions": ["mxs"]
+ },
+ "application/vnd.trueapp": {
+ "source": "iana",
+ "extensions": ["tra"]
+ },
+ "application/vnd.truedoc": {
+ "source": "iana"
+ },
+ "application/vnd.ubisoft.webplayer": {
+ "source": "iana"
+ },
+ "application/vnd.ufdl": {
+ "source": "iana",
+ "extensions": ["ufd","ufdl"]
+ },
+ "application/vnd.uiq.theme": {
+ "source": "iana",
+ "extensions": ["utz"]
+ },
+ "application/vnd.umajin": {
+ "source": "iana",
+ "extensions": ["umj"]
+ },
+ "application/vnd.unity": {
+ "source": "iana",
+ "extensions": ["unityweb"]
+ },
+ "application/vnd.uoml+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["uoml"]
+ },
+ "application/vnd.uplanet.alert": {
+ "source": "iana"
+ },
+ "application/vnd.uplanet.alert-wbxml": {
+ "source": "iana"
+ },
+ "application/vnd.uplanet.bearer-choice": {
+ "source": "iana"
+ },
+ "application/vnd.uplanet.bearer-choice-wbxml": {
+ "source": "iana"
+ },
+ "application/vnd.uplanet.cacheop": {
+ "source": "iana"
+ },
+ "application/vnd.uplanet.cacheop-wbxml": {
+ "source": "iana"
+ },
+ "application/vnd.uplanet.channel": {
+ "source": "iana"
+ },
+ "application/vnd.uplanet.channel-wbxml": {
+ "source": "iana"
+ },
+ "application/vnd.uplanet.list": {
+ "source": "iana"
+ },
+ "application/vnd.uplanet.list-wbxml": {
+ "source": "iana"
+ },
+ "application/vnd.uplanet.listcmd": {
+ "source": "iana"
+ },
+ "application/vnd.uplanet.listcmd-wbxml": {
+ "source": "iana"
+ },
+ "application/vnd.uplanet.signal": {
+ "source": "iana"
+ },
+ "application/vnd.uri-map": {
+ "source": "iana"
+ },
+ "application/vnd.valve.source.material": {
+ "source": "iana"
+ },
+ "application/vnd.vcx": {
+ "source": "iana",
+ "extensions": ["vcx"]
+ },
+ "application/vnd.vd-study": {
+ "source": "iana"
+ },
+ "application/vnd.vectorworks": {
+ "source": "iana"
+ },
+ "application/vnd.vel+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.verimatrix.vcas": {
+ "source": "iana"
+ },
+ "application/vnd.veritone.aion+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.veryant.thin": {
+ "source": "iana"
+ },
+ "application/vnd.ves.encrypted": {
+ "source": "iana"
+ },
+ "application/vnd.vidsoft.vidconference": {
+ "source": "iana"
+ },
+ "application/vnd.visio": {
+ "source": "iana",
+ "extensions": ["vsd","vst","vss","vsw"]
+ },
+ "application/vnd.visionary": {
+ "source": "iana",
+ "extensions": ["vis"]
+ },
+ "application/vnd.vividence.scriptfile": {
+ "source": "iana"
+ },
+ "application/vnd.vsf": {
+ "source": "iana",
+ "extensions": ["vsf"]
+ },
+ "application/vnd.wap.sic": {
+ "source": "iana"
+ },
+ "application/vnd.wap.slc": {
+ "source": "iana"
+ },
+ "application/vnd.wap.wbxml": {
+ "source": "iana",
+ "charset": "UTF-8",
+ "extensions": ["wbxml"]
+ },
+ "application/vnd.wap.wmlc": {
+ "source": "iana",
+ "extensions": ["wmlc"]
+ },
+ "application/vnd.wap.wmlscriptc": {
+ "source": "iana",
+ "extensions": ["wmlsc"]
+ },
+ "application/vnd.webturbo": {
+ "source": "iana",
+ "extensions": ["wtb"]
+ },
+ "application/vnd.wfa.dpp": {
+ "source": "iana"
+ },
+ "application/vnd.wfa.p2p": {
+ "source": "iana"
+ },
+ "application/vnd.wfa.wsc": {
+ "source": "iana"
+ },
+ "application/vnd.windows.devicepairing": {
+ "source": "iana"
+ },
+ "application/vnd.wmc": {
+ "source": "iana"
+ },
+ "application/vnd.wmf.bootstrap": {
+ "source": "iana"
+ },
+ "application/vnd.wolfram.mathematica": {
+ "source": "iana"
+ },
+ "application/vnd.wolfram.mathematica.package": {
+ "source": "iana"
+ },
+ "application/vnd.wolfram.player": {
+ "source": "iana",
+ "extensions": ["nbp"]
+ },
+ "application/vnd.wordperfect": {
+ "source": "iana",
+ "extensions": ["wpd"]
+ },
+ "application/vnd.wqd": {
+ "source": "iana",
+ "extensions": ["wqd"]
+ },
+ "application/vnd.wrq-hp3000-labelled": {
+ "source": "iana"
+ },
+ "application/vnd.wt.stf": {
+ "source": "iana",
+ "extensions": ["stf"]
+ },
+ "application/vnd.wv.csp+wbxml": {
+ "source": "iana"
+ },
+ "application/vnd.wv.csp+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.wv.ssp+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.xacml+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.xara": {
+ "source": "iana",
+ "extensions": ["xar"]
+ },
+ "application/vnd.xfdl": {
+ "source": "iana",
+ "extensions": ["xfdl"]
+ },
+ "application/vnd.xfdl.webform": {
+ "source": "iana"
+ },
+ "application/vnd.xmi+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vnd.xmpie.cpkg": {
+ "source": "iana"
+ },
+ "application/vnd.xmpie.dpkg": {
+ "source": "iana"
+ },
+ "application/vnd.xmpie.plan": {
+ "source": "iana"
+ },
+ "application/vnd.xmpie.ppkg": {
+ "source": "iana"
+ },
+ "application/vnd.xmpie.xlim": {
+ "source": "iana"
+ },
+ "application/vnd.yamaha.hv-dic": {
+ "source": "iana",
+ "extensions": ["hvd"]
+ },
+ "application/vnd.yamaha.hv-script": {
+ "source": "iana",
+ "extensions": ["hvs"]
+ },
+ "application/vnd.yamaha.hv-voice": {
+ "source": "iana",
+ "extensions": ["hvp"]
+ },
+ "application/vnd.yamaha.openscoreformat": {
+ "source": "iana",
+ "extensions": ["osf"]
+ },
+ "application/vnd.yamaha.openscoreformat.osfpvg+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["osfpvg"]
+ },
+ "application/vnd.yamaha.remote-setup": {
+ "source": "iana"
+ },
+ "application/vnd.yamaha.smaf-audio": {
+ "source": "iana",
+ "extensions": ["saf"]
+ },
+ "application/vnd.yamaha.smaf-phrase": {
+ "source": "iana",
+ "extensions": ["spf"]
+ },
+ "application/vnd.yamaha.through-ngn": {
+ "source": "iana"
+ },
+ "application/vnd.yamaha.tunnel-udpencap": {
+ "source": "iana"
+ },
+ "application/vnd.yaoweme": {
+ "source": "iana"
+ },
+ "application/vnd.yellowriver-custom-menu": {
+ "source": "iana",
+ "extensions": ["cmp"]
+ },
+ "application/vnd.youtube.yt": {
+ "source": "iana"
+ },
+ "application/vnd.zul": {
+ "source": "iana",
+ "extensions": ["zir","zirz"]
+ },
+ "application/vnd.zzazz.deck+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["zaz"]
+ },
+ "application/voicexml+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["vxml"]
+ },
+ "application/voucher-cms+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/vq-rtcpxr": {
+ "source": "iana"
+ },
+ "application/wasm": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["wasm"]
+ },
+ "application/watcherinfo+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/webpush-options+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/whoispp-query": {
+ "source": "iana"
+ },
+ "application/whoispp-response": {
+ "source": "iana"
+ },
+ "application/widget": {
+ "source": "iana",
+ "extensions": ["wgt"]
+ },
+ "application/winhlp": {
+ "source": "apache",
+ "extensions": ["hlp"]
+ },
+ "application/wita": {
+ "source": "iana"
+ },
+ "application/wordperfect5.1": {
+ "source": "iana"
+ },
+ "application/wsdl+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["wsdl"]
+ },
+ "application/wspolicy+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["wspolicy"]
+ },
+ "application/x-7z-compressed": {
+ "source": "apache",
+ "compressible": false,
+ "extensions": ["7z"]
+ },
+ "application/x-abiword": {
+ "source": "apache",
+ "extensions": ["abw"]
+ },
+ "application/x-ace-compressed": {
+ "source": "apache",
+ "extensions": ["ace"]
+ },
+ "application/x-amf": {
+ "source": "apache"
+ },
+ "application/x-apple-diskimage": {
+ "source": "apache",
+ "extensions": ["dmg"]
+ },
+ "application/x-arj": {
+ "compressible": false,
+ "extensions": ["arj"]
+ },
+ "application/x-authorware-bin": {
+ "source": "apache",
+ "extensions": ["aab","x32","u32","vox"]
+ },
+ "application/x-authorware-map": {
+ "source": "apache",
+ "extensions": ["aam"]
+ },
+ "application/x-authorware-seg": {
+ "source": "apache",
+ "extensions": ["aas"]
+ },
+ "application/x-bcpio": {
+ "source": "apache",
+ "extensions": ["bcpio"]
+ },
+ "application/x-bdoc": {
+ "compressible": false,
+ "extensions": ["bdoc"]
+ },
+ "application/x-bittorrent": {
+ "source": "apache",
+ "extensions": ["torrent"]
+ },
+ "application/x-blorb": {
+ "source": "apache",
+ "extensions": ["blb","blorb"]
+ },
+ "application/x-bzip": {
+ "source": "apache",
+ "compressible": false,
+ "extensions": ["bz"]
+ },
+ "application/x-bzip2": {
+ "source": "apache",
+ "compressible": false,
+ "extensions": ["bz2","boz"]
+ },
+ "application/x-cbr": {
+ "source": "apache",
+ "extensions": ["cbr","cba","cbt","cbz","cb7"]
+ },
+ "application/x-cdlink": {
+ "source": "apache",
+ "extensions": ["vcd"]
+ },
+ "application/x-cfs-compressed": {
+ "source": "apache",
+ "extensions": ["cfs"]
+ },
+ "application/x-chat": {
+ "source": "apache",
+ "extensions": ["chat"]
+ },
+ "application/x-chess-pgn": {
+ "source": "apache",
+ "extensions": ["pgn"]
+ },
+ "application/x-chrome-extension": {
+ "extensions": ["crx"]
+ },
+ "application/x-cocoa": {
+ "source": "nginx",
+ "extensions": ["cco"]
+ },
+ "application/x-compress": {
+ "source": "apache"
+ },
+ "application/x-conference": {
+ "source": "apache",
+ "extensions": ["nsc"]
+ },
+ "application/x-cpio": {
+ "source": "apache",
+ "extensions": ["cpio"]
+ },
+ "application/x-csh": {
+ "source": "apache",
+ "extensions": ["csh"]
+ },
+ "application/x-deb": {
+ "compressible": false
+ },
+ "application/x-debian-package": {
+ "source": "apache",
+ "extensions": ["deb","udeb"]
+ },
+ "application/x-dgc-compressed": {
+ "source": "apache",
+ "extensions": ["dgc"]
+ },
+ "application/x-director": {
+ "source": "apache",
+ "extensions": ["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"]
+ },
+ "application/x-doom": {
+ "source": "apache",
+ "extensions": ["wad"]
+ },
+ "application/x-dtbncx+xml": {
+ "source": "apache",
+ "compressible": true,
+ "extensions": ["ncx"]
+ },
+ "application/x-dtbook+xml": {
+ "source": "apache",
+ "compressible": true,
+ "extensions": ["dtb"]
+ },
+ "application/x-dtbresource+xml": {
+ "source": "apache",
+ "compressible": true,
+ "extensions": ["res"]
+ },
+ "application/x-dvi": {
+ "source": "apache",
+ "compressible": false,
+ "extensions": ["dvi"]
+ },
+ "application/x-envoy": {
+ "source": "apache",
+ "extensions": ["evy"]
+ },
+ "application/x-eva": {
+ "source": "apache",
+ "extensions": ["eva"]
+ },
+ "application/x-font-bdf": {
+ "source": "apache",
+ "extensions": ["bdf"]
+ },
+ "application/x-font-dos": {
+ "source": "apache"
+ },
+ "application/x-font-framemaker": {
+ "source": "apache"
+ },
+ "application/x-font-ghostscript": {
+ "source": "apache",
+ "extensions": ["gsf"]
+ },
+ "application/x-font-libgrx": {
+ "source": "apache"
+ },
+ "application/x-font-linux-psf": {
+ "source": "apache",
+ "extensions": ["psf"]
+ },
+ "application/x-font-pcf": {
+ "source": "apache",
+ "extensions": ["pcf"]
+ },
+ "application/x-font-snf": {
+ "source": "apache",
+ "extensions": ["snf"]
+ },
+ "application/x-font-speedo": {
+ "source": "apache"
+ },
+ "application/x-font-sunos-news": {
+ "source": "apache"
+ },
+ "application/x-font-type1": {
+ "source": "apache",
+ "extensions": ["pfa","pfb","pfm","afm"]
+ },
+ "application/x-font-vfont": {
+ "source": "apache"
+ },
+ "application/x-freearc": {
+ "source": "apache",
+ "extensions": ["arc"]
+ },
+ "application/x-futuresplash": {
+ "source": "apache",
+ "extensions": ["spl"]
+ },
+ "application/x-gca-compressed": {
+ "source": "apache",
+ "extensions": ["gca"]
+ },
+ "application/x-glulx": {
+ "source": "apache",
+ "extensions": ["ulx"]
+ },
+ "application/x-gnumeric": {
+ "source": "apache",
+ "extensions": ["gnumeric"]
+ },
+ "application/x-gramps-xml": {
+ "source": "apache",
+ "extensions": ["gramps"]
+ },
+ "application/x-gtar": {
+ "source": "apache",
+ "extensions": ["gtar"]
+ },
+ "application/x-gzip": {
+ "source": "apache"
+ },
+ "application/x-hdf": {
+ "source": "apache",
+ "extensions": ["hdf"]
+ },
+ "application/x-httpd-php": {
+ "compressible": true,
+ "extensions": ["php"]
+ },
+ "application/x-install-instructions": {
+ "source": "apache",
+ "extensions": ["install"]
+ },
+ "application/x-iso9660-image": {
+ "source": "apache",
+ "extensions": ["iso"]
+ },
+ "application/x-iwork-keynote-sffkey": {
+ "extensions": ["key"]
+ },
+ "application/x-iwork-numbers-sffnumbers": {
+ "extensions": ["numbers"]
+ },
+ "application/x-iwork-pages-sffpages": {
+ "extensions": ["pages"]
+ },
+ "application/x-java-archive-diff": {
+ "source": "nginx",
+ "extensions": ["jardiff"]
+ },
+ "application/x-java-jnlp-file": {
+ "source": "apache",
+ "compressible": false,
+ "extensions": ["jnlp"]
+ },
+ "application/x-javascript": {
+ "compressible": true
+ },
+ "application/x-keepass2": {
+ "extensions": ["kdbx"]
+ },
+ "application/x-latex": {
+ "source": "apache",
+ "compressible": false,
+ "extensions": ["latex"]
+ },
+ "application/x-lua-bytecode": {
+ "extensions": ["luac"]
+ },
+ "application/x-lzh-compressed": {
+ "source": "apache",
+ "extensions": ["lzh","lha"]
+ },
+ "application/x-makeself": {
+ "source": "nginx",
+ "extensions": ["run"]
+ },
+ "application/x-mie": {
+ "source": "apache",
+ "extensions": ["mie"]
+ },
+ "application/x-mobipocket-ebook": {
+ "source": "apache",
+ "extensions": ["prc","mobi"]
+ },
+ "application/x-mpegurl": {
+ "compressible": false
+ },
+ "application/x-ms-application": {
+ "source": "apache",
+ "extensions": ["application"]
+ },
+ "application/x-ms-shortcut": {
+ "source": "apache",
+ "extensions": ["lnk"]
+ },
+ "application/x-ms-wmd": {
+ "source": "apache",
+ "extensions": ["wmd"]
+ },
+ "application/x-ms-wmz": {
+ "source": "apache",
+ "extensions": ["wmz"]
+ },
+ "application/x-ms-xbap": {
+ "source": "apache",
+ "extensions": ["xbap"]
+ },
+ "application/x-msaccess": {
+ "source": "apache",
+ "extensions": ["mdb"]
+ },
+ "application/x-msbinder": {
+ "source": "apache",
+ "extensions": ["obd"]
+ },
+ "application/x-mscardfile": {
+ "source": "apache",
+ "extensions": ["crd"]
+ },
+ "application/x-msclip": {
+ "source": "apache",
+ "extensions": ["clp"]
+ },
+ "application/x-msdos-program": {
+ "extensions": ["exe"]
+ },
+ "application/x-msdownload": {
+ "source": "apache",
+ "extensions": ["exe","dll","com","bat","msi"]
+ },
+ "application/x-msmediaview": {
+ "source": "apache",
+ "extensions": ["mvb","m13","m14"]
+ },
+ "application/x-msmetafile": {
+ "source": "apache",
+ "extensions": ["wmf","wmz","emf","emz"]
+ },
+ "application/x-msmoney": {
+ "source": "apache",
+ "extensions": ["mny"]
+ },
+ "application/x-mspublisher": {
+ "source": "apache",
+ "extensions": ["pub"]
+ },
+ "application/x-msschedule": {
+ "source": "apache",
+ "extensions": ["scd"]
+ },
+ "application/x-msterminal": {
+ "source": "apache",
+ "extensions": ["trm"]
+ },
+ "application/x-mswrite": {
+ "source": "apache",
+ "extensions": ["wri"]
+ },
+ "application/x-netcdf": {
+ "source": "apache",
+ "extensions": ["nc","cdf"]
+ },
+ "application/x-ns-proxy-autoconfig": {
+ "compressible": true,
+ "extensions": ["pac"]
+ },
+ "application/x-nzb": {
+ "source": "apache",
+ "extensions": ["nzb"]
+ },
+ "application/x-perl": {
+ "source": "nginx",
+ "extensions": ["pl","pm"]
+ },
+ "application/x-pilot": {
+ "source": "nginx",
+ "extensions": ["prc","pdb"]
+ },
+ "application/x-pkcs12": {
+ "source": "apache",
+ "compressible": false,
+ "extensions": ["p12","pfx"]
+ },
+ "application/x-pkcs7-certificates": {
+ "source": "apache",
+ "extensions": ["p7b","spc"]
+ },
+ "application/x-pkcs7-certreqresp": {
+ "source": "apache",
+ "extensions": ["p7r"]
+ },
+ "application/x-pki-message": {
+ "source": "iana"
+ },
+ "application/x-rar-compressed": {
+ "source": "apache",
+ "compressible": false,
+ "extensions": ["rar"]
+ },
+ "application/x-redhat-package-manager": {
+ "source": "nginx",
+ "extensions": ["rpm"]
+ },
+ "application/x-research-info-systems": {
+ "source": "apache",
+ "extensions": ["ris"]
+ },
+ "application/x-sea": {
+ "source": "nginx",
+ "extensions": ["sea"]
+ },
+ "application/x-sh": {
+ "source": "apache",
+ "compressible": true,
+ "extensions": ["sh"]
+ },
+ "application/x-shar": {
+ "source": "apache",
+ "extensions": ["shar"]
+ },
+ "application/x-shockwave-flash": {
+ "source": "apache",
+ "compressible": false,
+ "extensions": ["swf"]
+ },
+ "application/x-silverlight-app": {
+ "source": "apache",
+ "extensions": ["xap"]
+ },
+ "application/x-sql": {
+ "source": "apache",
+ "extensions": ["sql"]
+ },
+ "application/x-stuffit": {
+ "source": "apache",
+ "compressible": false,
+ "extensions": ["sit"]
+ },
+ "application/x-stuffitx": {
+ "source": "apache",
+ "extensions": ["sitx"]
+ },
+ "application/x-subrip": {
+ "source": "apache",
+ "extensions": ["srt"]
+ },
+ "application/x-sv4cpio": {
+ "source": "apache",
+ "extensions": ["sv4cpio"]
+ },
+ "application/x-sv4crc": {
+ "source": "apache",
+ "extensions": ["sv4crc"]
+ },
+ "application/x-t3vm-image": {
+ "source": "apache",
+ "extensions": ["t3"]
+ },
+ "application/x-tads": {
+ "source": "apache",
+ "extensions": ["gam"]
+ },
+ "application/x-tar": {
+ "source": "apache",
+ "compressible": true,
+ "extensions": ["tar"]
+ },
+ "application/x-tcl": {
+ "source": "apache",
+ "extensions": ["tcl","tk"]
+ },
+ "application/x-tex": {
+ "source": "apache",
+ "extensions": ["tex"]
+ },
+ "application/x-tex-tfm": {
+ "source": "apache",
+ "extensions": ["tfm"]
+ },
+ "application/x-texinfo": {
+ "source": "apache",
+ "extensions": ["texinfo","texi"]
+ },
+ "application/x-tgif": {
+ "source": "apache",
+ "extensions": ["obj"]
+ },
+ "application/x-ustar": {
+ "source": "apache",
+ "extensions": ["ustar"]
+ },
+ "application/x-virtualbox-hdd": {
+ "compressible": true,
+ "extensions": ["hdd"]
+ },
+ "application/x-virtualbox-ova": {
+ "compressible": true,
+ "extensions": ["ova"]
+ },
+ "application/x-virtualbox-ovf": {
+ "compressible": true,
+ "extensions": ["ovf"]
+ },
+ "application/x-virtualbox-vbox": {
+ "compressible": true,
+ "extensions": ["vbox"]
+ },
+ "application/x-virtualbox-vbox-extpack": {
+ "compressible": false,
+ "extensions": ["vbox-extpack"]
+ },
+ "application/x-virtualbox-vdi": {
+ "compressible": true,
+ "extensions": ["vdi"]
+ },
+ "application/x-virtualbox-vhd": {
+ "compressible": true,
+ "extensions": ["vhd"]
+ },
+ "application/x-virtualbox-vmdk": {
+ "compressible": true,
+ "extensions": ["vmdk"]
+ },
+ "application/x-wais-source": {
+ "source": "apache",
+ "extensions": ["src"]
+ },
+ "application/x-web-app-manifest+json": {
+ "compressible": true,
+ "extensions": ["webapp"]
+ },
+ "application/x-www-form-urlencoded": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/x-x509-ca-cert": {
+ "source": "iana",
+ "extensions": ["der","crt","pem"]
+ },
+ "application/x-x509-ca-ra-cert": {
+ "source": "iana"
+ },
+ "application/x-x509-next-ca-cert": {
+ "source": "iana"
+ },
+ "application/x-xfig": {
+ "source": "apache",
+ "extensions": ["fig"]
+ },
+ "application/x-xliff+xml": {
+ "source": "apache",
+ "compressible": true,
+ "extensions": ["xlf"]
+ },
+ "application/x-xpinstall": {
+ "source": "apache",
+ "compressible": false,
+ "extensions": ["xpi"]
+ },
+ "application/x-xz": {
+ "source": "apache",
+ "extensions": ["xz"]
+ },
+ "application/x-zmachine": {
+ "source": "apache",
+ "extensions": ["z1","z2","z3","z4","z5","z6","z7","z8"]
+ },
+ "application/x400-bp": {
+ "source": "iana"
+ },
+ "application/xacml+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/xaml+xml": {
+ "source": "apache",
+ "compressible": true,
+ "extensions": ["xaml"]
+ },
+ "application/xcap-att+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["xav"]
+ },
+ "application/xcap-caps+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["xca"]
+ },
+ "application/xcap-diff+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["xdf"]
+ },
+ "application/xcap-el+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["xel"]
+ },
+ "application/xcap-error+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/xcap-ns+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["xns"]
+ },
+ "application/xcon-conference-info+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/xcon-conference-info-diff+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/xenc+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["xenc"]
+ },
+ "application/xhtml+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["xhtml","xht"]
+ },
+ "application/xhtml-voice+xml": {
+ "source": "apache",
+ "compressible": true
+ },
+ "application/xliff+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["xlf"]
+ },
+ "application/xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["xml","xsl","xsd","rng"]
+ },
+ "application/xml-dtd": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["dtd"]
+ },
+ "application/xml-external-parsed-entity": {
+ "source": "iana"
+ },
+ "application/xml-patch+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/xmpp+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/xop+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["xop"]
+ },
+ "application/xproc+xml": {
+ "source": "apache",
+ "compressible": true,
+ "extensions": ["xpl"]
+ },
+ "application/xslt+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["xsl","xslt"]
+ },
+ "application/xspf+xml": {
+ "source": "apache",
+ "compressible": true,
+ "extensions": ["xspf"]
+ },
+ "application/xv+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["mxml","xhvml","xvml","xvm"]
+ },
+ "application/yang": {
+ "source": "iana",
+ "extensions": ["yang"]
+ },
+ "application/yang-data+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/yang-data+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/yang-patch+json": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/yang-patch+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "application/yin+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["yin"]
+ },
+ "application/zip": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["zip"]
+ },
+ "application/zlib": {
+ "source": "iana"
+ },
+ "application/zstd": {
+ "source": "iana"
+ },
+ "audio/1d-interleaved-parityfec": {
+ "source": "iana"
+ },
+ "audio/32kadpcm": {
+ "source": "iana"
+ },
+ "audio/3gpp": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["3gpp"]
+ },
+ "audio/3gpp2": {
+ "source": "iana"
+ },
+ "audio/aac": {
+ "source": "iana"
+ },
+ "audio/ac3": {
+ "source": "iana"
+ },
+ "audio/adpcm": {
+ "source": "apache",
+ "extensions": ["adp"]
+ },
+ "audio/amr": {
+ "source": "iana",
+ "extensions": ["amr"]
+ },
+ "audio/amr-wb": {
+ "source": "iana"
+ },
+ "audio/amr-wb+": {
+ "source": "iana"
+ },
+ "audio/aptx": {
+ "source": "iana"
+ },
+ "audio/asc": {
+ "source": "iana"
+ },
+ "audio/atrac-advanced-lossless": {
+ "source": "iana"
+ },
+ "audio/atrac-x": {
+ "source": "iana"
+ },
+ "audio/atrac3": {
+ "source": "iana"
+ },
+ "audio/basic": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["au","snd"]
+ },
+ "audio/bv16": {
+ "source": "iana"
+ },
+ "audio/bv32": {
+ "source": "iana"
+ },
+ "audio/clearmode": {
+ "source": "iana"
+ },
+ "audio/cn": {
+ "source": "iana"
+ },
+ "audio/dat12": {
+ "source": "iana"
+ },
+ "audio/dls": {
+ "source": "iana"
+ },
+ "audio/dsr-es201108": {
+ "source": "iana"
+ },
+ "audio/dsr-es202050": {
+ "source": "iana"
+ },
+ "audio/dsr-es202211": {
+ "source": "iana"
+ },
+ "audio/dsr-es202212": {
+ "source": "iana"
+ },
+ "audio/dv": {
+ "source": "iana"
+ },
+ "audio/dvi4": {
+ "source": "iana"
+ },
+ "audio/eac3": {
+ "source": "iana"
+ },
+ "audio/encaprtp": {
+ "source": "iana"
+ },
+ "audio/evrc": {
+ "source": "iana"
+ },
+ "audio/evrc-qcp": {
+ "source": "iana"
+ },
+ "audio/evrc0": {
+ "source": "iana"
+ },
+ "audio/evrc1": {
+ "source": "iana"
+ },
+ "audio/evrcb": {
+ "source": "iana"
+ },
+ "audio/evrcb0": {
+ "source": "iana"
+ },
+ "audio/evrcb1": {
+ "source": "iana"
+ },
+ "audio/evrcnw": {
+ "source": "iana"
+ },
+ "audio/evrcnw0": {
+ "source": "iana"
+ },
+ "audio/evrcnw1": {
+ "source": "iana"
+ },
+ "audio/evrcwb": {
+ "source": "iana"
+ },
+ "audio/evrcwb0": {
+ "source": "iana"
+ },
+ "audio/evrcwb1": {
+ "source": "iana"
+ },
+ "audio/evs": {
+ "source": "iana"
+ },
+ "audio/flexfec": {
+ "source": "iana"
+ },
+ "audio/fwdred": {
+ "source": "iana"
+ },
+ "audio/g711-0": {
+ "source": "iana"
+ },
+ "audio/g719": {
+ "source": "iana"
+ },
+ "audio/g722": {
+ "source": "iana"
+ },
+ "audio/g7221": {
+ "source": "iana"
+ },
+ "audio/g723": {
+ "source": "iana"
+ },
+ "audio/g726-16": {
+ "source": "iana"
+ },
+ "audio/g726-24": {
+ "source": "iana"
+ },
+ "audio/g726-32": {
+ "source": "iana"
+ },
+ "audio/g726-40": {
+ "source": "iana"
+ },
+ "audio/g728": {
+ "source": "iana"
+ },
+ "audio/g729": {
+ "source": "iana"
+ },
+ "audio/g7291": {
+ "source": "iana"
+ },
+ "audio/g729d": {
+ "source": "iana"
+ },
+ "audio/g729e": {
+ "source": "iana"
+ },
+ "audio/gsm": {
+ "source": "iana"
+ },
+ "audio/gsm-efr": {
+ "source": "iana"
+ },
+ "audio/gsm-hr-08": {
+ "source": "iana"
+ },
+ "audio/ilbc": {
+ "source": "iana"
+ },
+ "audio/ip-mr_v2.5": {
+ "source": "iana"
+ },
+ "audio/isac": {
+ "source": "apache"
+ },
+ "audio/l16": {
+ "source": "iana"
+ },
+ "audio/l20": {
+ "source": "iana"
+ },
+ "audio/l24": {
+ "source": "iana",
+ "compressible": false
+ },
+ "audio/l8": {
+ "source": "iana"
+ },
+ "audio/lpc": {
+ "source": "iana"
+ },
+ "audio/melp": {
+ "source": "iana"
+ },
+ "audio/melp1200": {
+ "source": "iana"
+ },
+ "audio/melp2400": {
+ "source": "iana"
+ },
+ "audio/melp600": {
+ "source": "iana"
+ },
+ "audio/mhas": {
+ "source": "iana"
+ },
+ "audio/midi": {
+ "source": "apache",
+ "extensions": ["mid","midi","kar","rmi"]
+ },
+ "audio/mobile-xmf": {
+ "source": "iana",
+ "extensions": ["mxmf"]
+ },
+ "audio/mp3": {
+ "compressible": false,
+ "extensions": ["mp3"]
+ },
+ "audio/mp4": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["m4a","mp4a"]
+ },
+ "audio/mp4a-latm": {
+ "source": "iana"
+ },
+ "audio/mpa": {
+ "source": "iana"
+ },
+ "audio/mpa-robust": {
+ "source": "iana"
+ },
+ "audio/mpeg": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["mpga","mp2","mp2a","mp3","m2a","m3a"]
+ },
+ "audio/mpeg4-generic": {
+ "source": "iana"
+ },
+ "audio/musepack": {
+ "source": "apache"
+ },
+ "audio/ogg": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["oga","ogg","spx","opus"]
+ },
+ "audio/opus": {
+ "source": "iana"
+ },
+ "audio/parityfec": {
+ "source": "iana"
+ },
+ "audio/pcma": {
+ "source": "iana"
+ },
+ "audio/pcma-wb": {
+ "source": "iana"
+ },
+ "audio/pcmu": {
+ "source": "iana"
+ },
+ "audio/pcmu-wb": {
+ "source": "iana"
+ },
+ "audio/prs.sid": {
+ "source": "iana"
+ },
+ "audio/qcelp": {
+ "source": "iana"
+ },
+ "audio/raptorfec": {
+ "source": "iana"
+ },
+ "audio/red": {
+ "source": "iana"
+ },
+ "audio/rtp-enc-aescm128": {
+ "source": "iana"
+ },
+ "audio/rtp-midi": {
+ "source": "iana"
+ },
+ "audio/rtploopback": {
+ "source": "iana"
+ },
+ "audio/rtx": {
+ "source": "iana"
+ },
+ "audio/s3m": {
+ "source": "apache",
+ "extensions": ["s3m"]
+ },
+ "audio/scip": {
+ "source": "iana"
+ },
+ "audio/silk": {
+ "source": "apache",
+ "extensions": ["sil"]
+ },
+ "audio/smv": {
+ "source": "iana"
+ },
+ "audio/smv-qcp": {
+ "source": "iana"
+ },
+ "audio/smv0": {
+ "source": "iana"
+ },
+ "audio/sofa": {
+ "source": "iana"
+ },
+ "audio/sp-midi": {
+ "source": "iana"
+ },
+ "audio/speex": {
+ "source": "iana"
+ },
+ "audio/t140c": {
+ "source": "iana"
+ },
+ "audio/t38": {
+ "source": "iana"
+ },
+ "audio/telephone-event": {
+ "source": "iana"
+ },
+ "audio/tetra_acelp": {
+ "source": "iana"
+ },
+ "audio/tetra_acelp_bb": {
+ "source": "iana"
+ },
+ "audio/tone": {
+ "source": "iana"
+ },
+ "audio/tsvcis": {
+ "source": "iana"
+ },
+ "audio/uemclip": {
+ "source": "iana"
+ },
+ "audio/ulpfec": {
+ "source": "iana"
+ },
+ "audio/usac": {
+ "source": "iana"
+ },
+ "audio/vdvi": {
+ "source": "iana"
+ },
+ "audio/vmr-wb": {
+ "source": "iana"
+ },
+ "audio/vnd.3gpp.iufp": {
+ "source": "iana"
+ },
+ "audio/vnd.4sb": {
+ "source": "iana"
+ },
+ "audio/vnd.audiokoz": {
+ "source": "iana"
+ },
+ "audio/vnd.celp": {
+ "source": "iana"
+ },
+ "audio/vnd.cisco.nse": {
+ "source": "iana"
+ },
+ "audio/vnd.cmles.radio-events": {
+ "source": "iana"
+ },
+ "audio/vnd.cns.anp1": {
+ "source": "iana"
+ },
+ "audio/vnd.cns.inf1": {
+ "source": "iana"
+ },
+ "audio/vnd.dece.audio": {
+ "source": "iana",
+ "extensions": ["uva","uvva"]
+ },
+ "audio/vnd.digital-winds": {
+ "source": "iana",
+ "extensions": ["eol"]
+ },
+ "audio/vnd.dlna.adts": {
+ "source": "iana"
+ },
+ "audio/vnd.dolby.heaac.1": {
+ "source": "iana"
+ },
+ "audio/vnd.dolby.heaac.2": {
+ "source": "iana"
+ },
+ "audio/vnd.dolby.mlp": {
+ "source": "iana"
+ },
+ "audio/vnd.dolby.mps": {
+ "source": "iana"
+ },
+ "audio/vnd.dolby.pl2": {
+ "source": "iana"
+ },
+ "audio/vnd.dolby.pl2x": {
+ "source": "iana"
+ },
+ "audio/vnd.dolby.pl2z": {
+ "source": "iana"
+ },
+ "audio/vnd.dolby.pulse.1": {
+ "source": "iana"
+ },
+ "audio/vnd.dra": {
+ "source": "iana",
+ "extensions": ["dra"]
+ },
+ "audio/vnd.dts": {
+ "source": "iana",
+ "extensions": ["dts"]
+ },
+ "audio/vnd.dts.hd": {
+ "source": "iana",
+ "extensions": ["dtshd"]
+ },
+ "audio/vnd.dts.uhd": {
+ "source": "iana"
+ },
+ "audio/vnd.dvb.file": {
+ "source": "iana"
+ },
+ "audio/vnd.everad.plj": {
+ "source": "iana"
+ },
+ "audio/vnd.hns.audio": {
+ "source": "iana"
+ },
+ "audio/vnd.lucent.voice": {
+ "source": "iana",
+ "extensions": ["lvp"]
+ },
+ "audio/vnd.ms-playready.media.pya": {
+ "source": "iana",
+ "extensions": ["pya"]
+ },
+ "audio/vnd.nokia.mobile-xmf": {
+ "source": "iana"
+ },
+ "audio/vnd.nortel.vbk": {
+ "source": "iana"
+ },
+ "audio/vnd.nuera.ecelp4800": {
+ "source": "iana",
+ "extensions": ["ecelp4800"]
+ },
+ "audio/vnd.nuera.ecelp7470": {
+ "source": "iana",
+ "extensions": ["ecelp7470"]
+ },
+ "audio/vnd.nuera.ecelp9600": {
+ "source": "iana",
+ "extensions": ["ecelp9600"]
+ },
+ "audio/vnd.octel.sbc": {
+ "source": "iana"
+ },
+ "audio/vnd.presonus.multitrack": {
+ "source": "iana"
+ },
+ "audio/vnd.qcelp": {
+ "source": "iana"
+ },
+ "audio/vnd.rhetorex.32kadpcm": {
+ "source": "iana"
+ },
+ "audio/vnd.rip": {
+ "source": "iana",
+ "extensions": ["rip"]
+ },
+ "audio/vnd.rn-realaudio": {
+ "compressible": false
+ },
+ "audio/vnd.sealedmedia.softseal.mpeg": {
+ "source": "iana"
+ },
+ "audio/vnd.vmx.cvsd": {
+ "source": "iana"
+ },
+ "audio/vnd.wave": {
+ "compressible": false
+ },
+ "audio/vorbis": {
+ "source": "iana",
+ "compressible": false
+ },
+ "audio/vorbis-config": {
+ "source": "iana"
+ },
+ "audio/wav": {
+ "compressible": false,
+ "extensions": ["wav"]
+ },
+ "audio/wave": {
+ "compressible": false,
+ "extensions": ["wav"]
+ },
+ "audio/webm": {
+ "source": "apache",
+ "compressible": false,
+ "extensions": ["weba"]
+ },
+ "audio/x-aac": {
+ "source": "apache",
+ "compressible": false,
+ "extensions": ["aac"]
+ },
+ "audio/x-aiff": {
+ "source": "apache",
+ "extensions": ["aif","aiff","aifc"]
+ },
+ "audio/x-caf": {
+ "source": "apache",
+ "compressible": false,
+ "extensions": ["caf"]
+ },
+ "audio/x-flac": {
+ "source": "apache",
+ "extensions": ["flac"]
+ },
+ "audio/x-m4a": {
+ "source": "nginx",
+ "extensions": ["m4a"]
+ },
+ "audio/x-matroska": {
+ "source": "apache",
+ "extensions": ["mka"]
+ },
+ "audio/x-mpegurl": {
+ "source": "apache",
+ "extensions": ["m3u"]
+ },
+ "audio/x-ms-wax": {
+ "source": "apache",
+ "extensions": ["wax"]
+ },
+ "audio/x-ms-wma": {
+ "source": "apache",
+ "extensions": ["wma"]
+ },
+ "audio/x-pn-realaudio": {
+ "source": "apache",
+ "extensions": ["ram","ra"]
+ },
+ "audio/x-pn-realaudio-plugin": {
+ "source": "apache",
+ "extensions": ["rmp"]
+ },
+ "audio/x-realaudio": {
+ "source": "nginx",
+ "extensions": ["ra"]
+ },
+ "audio/x-tta": {
+ "source": "apache"
+ },
+ "audio/x-wav": {
+ "source": "apache",
+ "extensions": ["wav"]
+ },
+ "audio/xm": {
+ "source": "apache",
+ "extensions": ["xm"]
+ },
+ "chemical/x-cdx": {
+ "source": "apache",
+ "extensions": ["cdx"]
+ },
+ "chemical/x-cif": {
+ "source": "apache",
+ "extensions": ["cif"]
+ },
+ "chemical/x-cmdf": {
+ "source": "apache",
+ "extensions": ["cmdf"]
+ },
+ "chemical/x-cml": {
+ "source": "apache",
+ "extensions": ["cml"]
+ },
+ "chemical/x-csml": {
+ "source": "apache",
+ "extensions": ["csml"]
+ },
+ "chemical/x-pdb": {
+ "source": "apache"
+ },
+ "chemical/x-xyz": {
+ "source": "apache",
+ "extensions": ["xyz"]
+ },
+ "font/collection": {
+ "source": "iana",
+ "extensions": ["ttc"]
+ },
+ "font/otf": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["otf"]
+ },
+ "font/sfnt": {
+ "source": "iana"
+ },
+ "font/ttf": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["ttf"]
+ },
+ "font/woff": {
+ "source": "iana",
+ "extensions": ["woff"]
+ },
+ "font/woff2": {
+ "source": "iana",
+ "extensions": ["woff2"]
+ },
+ "image/aces": {
+ "source": "iana",
+ "extensions": ["exr"]
+ },
+ "image/apng": {
+ "compressible": false,
+ "extensions": ["apng"]
+ },
+ "image/avci": {
+ "source": "iana"
+ },
+ "image/avcs": {
+ "source": "iana"
+ },
+ "image/avif": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["avif"]
+ },
+ "image/bmp": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["bmp"]
+ },
+ "image/cgm": {
+ "source": "iana",
+ "extensions": ["cgm"]
+ },
+ "image/dicom-rle": {
+ "source": "iana",
+ "extensions": ["drle"]
+ },
+ "image/emf": {
+ "source": "iana",
+ "extensions": ["emf"]
+ },
+ "image/fits": {
+ "source": "iana",
+ "extensions": ["fits"]
+ },
+ "image/g3fax": {
+ "source": "iana",
+ "extensions": ["g3"]
+ },
+ "image/gif": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["gif"]
+ },
+ "image/heic": {
+ "source": "iana",
+ "extensions": ["heic"]
+ },
+ "image/heic-sequence": {
+ "source": "iana",
+ "extensions": ["heics"]
+ },
+ "image/heif": {
+ "source": "iana",
+ "extensions": ["heif"]
+ },
+ "image/heif-sequence": {
+ "source": "iana",
+ "extensions": ["heifs"]
+ },
+ "image/hej2k": {
+ "source": "iana",
+ "extensions": ["hej2"]
+ },
+ "image/hsj2": {
+ "source": "iana",
+ "extensions": ["hsj2"]
+ },
+ "image/ief": {
+ "source": "iana",
+ "extensions": ["ief"]
+ },
+ "image/jls": {
+ "source": "iana",
+ "extensions": ["jls"]
+ },
+ "image/jp2": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["jp2","jpg2"]
+ },
+ "image/jpeg": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["jpeg","jpg","jpe"]
+ },
+ "image/jph": {
+ "source": "iana",
+ "extensions": ["jph"]
+ },
+ "image/jphc": {
+ "source": "iana",
+ "extensions": ["jhc"]
+ },
+ "image/jpm": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["jpm"]
+ },
+ "image/jpx": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["jpx","jpf"]
+ },
+ "image/jxr": {
+ "source": "iana",
+ "extensions": ["jxr"]
+ },
+ "image/jxra": {
+ "source": "iana",
+ "extensions": ["jxra"]
+ },
+ "image/jxrs": {
+ "source": "iana",
+ "extensions": ["jxrs"]
+ },
+ "image/jxs": {
+ "source": "iana",
+ "extensions": ["jxs"]
+ },
+ "image/jxsc": {
+ "source": "iana",
+ "extensions": ["jxsc"]
+ },
+ "image/jxsi": {
+ "source": "iana",
+ "extensions": ["jxsi"]
+ },
+ "image/jxss": {
+ "source": "iana",
+ "extensions": ["jxss"]
+ },
+ "image/ktx": {
+ "source": "iana",
+ "extensions": ["ktx"]
+ },
+ "image/ktx2": {
+ "source": "iana",
+ "extensions": ["ktx2"]
+ },
+ "image/naplps": {
+ "source": "iana"
+ },
+ "image/pjpeg": {
+ "compressible": false
+ },
+ "image/png": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["png"]
+ },
+ "image/prs.btif": {
+ "source": "iana",
+ "extensions": ["btif"]
+ },
+ "image/prs.pti": {
+ "source": "iana",
+ "extensions": ["pti"]
+ },
+ "image/pwg-raster": {
+ "source": "iana"
+ },
+ "image/sgi": {
+ "source": "apache",
+ "extensions": ["sgi"]
+ },
+ "image/svg+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["svg","svgz"]
+ },
+ "image/t38": {
+ "source": "iana",
+ "extensions": ["t38"]
+ },
+ "image/tiff": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["tif","tiff"]
+ },
+ "image/tiff-fx": {
+ "source": "iana",
+ "extensions": ["tfx"]
+ },
+ "image/vnd.adobe.photoshop": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["psd"]
+ },
+ "image/vnd.airzip.accelerator.azv": {
+ "source": "iana",
+ "extensions": ["azv"]
+ },
+ "image/vnd.cns.inf2": {
+ "source": "iana"
+ },
+ "image/vnd.dece.graphic": {
+ "source": "iana",
+ "extensions": ["uvi","uvvi","uvg","uvvg"]
+ },
+ "image/vnd.djvu": {
+ "source": "iana",
+ "extensions": ["djvu","djv"]
+ },
+ "image/vnd.dvb.subtitle": {
+ "source": "iana",
+ "extensions": ["sub"]
+ },
+ "image/vnd.dwg": {
+ "source": "iana",
+ "extensions": ["dwg"]
+ },
+ "image/vnd.dxf": {
+ "source": "iana",
+ "extensions": ["dxf"]
+ },
+ "image/vnd.fastbidsheet": {
+ "source": "iana",
+ "extensions": ["fbs"]
+ },
+ "image/vnd.fpx": {
+ "source": "iana",
+ "extensions": ["fpx"]
+ },
+ "image/vnd.fst": {
+ "source": "iana",
+ "extensions": ["fst"]
+ },
+ "image/vnd.fujixerox.edmics-mmr": {
+ "source": "iana",
+ "extensions": ["mmr"]
+ },
+ "image/vnd.fujixerox.edmics-rlc": {
+ "source": "iana",
+ "extensions": ["rlc"]
+ },
+ "image/vnd.globalgraphics.pgb": {
+ "source": "iana"
+ },
+ "image/vnd.microsoft.icon": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["ico"]
+ },
+ "image/vnd.mix": {
+ "source": "iana"
+ },
+ "image/vnd.mozilla.apng": {
+ "source": "iana"
+ },
+ "image/vnd.ms-dds": {
+ "compressible": true,
+ "extensions": ["dds"]
+ },
+ "image/vnd.ms-modi": {
+ "source": "iana",
+ "extensions": ["mdi"]
+ },
+ "image/vnd.ms-photo": {
+ "source": "apache",
+ "extensions": ["wdp"]
+ },
+ "image/vnd.net-fpx": {
+ "source": "iana",
+ "extensions": ["npx"]
+ },
+ "image/vnd.pco.b16": {
+ "source": "iana",
+ "extensions": ["b16"]
+ },
+ "image/vnd.radiance": {
+ "source": "iana"
+ },
+ "image/vnd.sealed.png": {
+ "source": "iana"
+ },
+ "image/vnd.sealedmedia.softseal.gif": {
+ "source": "iana"
+ },
+ "image/vnd.sealedmedia.softseal.jpg": {
+ "source": "iana"
+ },
+ "image/vnd.svf": {
+ "source": "iana"
+ },
+ "image/vnd.tencent.tap": {
+ "source": "iana",
+ "extensions": ["tap"]
+ },
+ "image/vnd.valve.source.texture": {
+ "source": "iana",
+ "extensions": ["vtf"]
+ },
+ "image/vnd.wap.wbmp": {
+ "source": "iana",
+ "extensions": ["wbmp"]
+ },
+ "image/vnd.xiff": {
+ "source": "iana",
+ "extensions": ["xif"]
+ },
+ "image/vnd.zbrush.pcx": {
+ "source": "iana",
+ "extensions": ["pcx"]
+ },
+ "image/webp": {
+ "source": "apache",
+ "extensions": ["webp"]
+ },
+ "image/wmf": {
+ "source": "iana",
+ "extensions": ["wmf"]
+ },
+ "image/x-3ds": {
+ "source": "apache",
+ "extensions": ["3ds"]
+ },
+ "image/x-cmu-raster": {
+ "source": "apache",
+ "extensions": ["ras"]
+ },
+ "image/x-cmx": {
+ "source": "apache",
+ "extensions": ["cmx"]
+ },
+ "image/x-freehand": {
+ "source": "apache",
+ "extensions": ["fh","fhc","fh4","fh5","fh7"]
+ },
+ "image/x-icon": {
+ "source": "apache",
+ "compressible": true,
+ "extensions": ["ico"]
+ },
+ "image/x-jng": {
+ "source": "nginx",
+ "extensions": ["jng"]
+ },
+ "image/x-mrsid-image": {
+ "source": "apache",
+ "extensions": ["sid"]
+ },
+ "image/x-ms-bmp": {
+ "source": "nginx",
+ "compressible": true,
+ "extensions": ["bmp"]
+ },
+ "image/x-pcx": {
+ "source": "apache",
+ "extensions": ["pcx"]
+ },
+ "image/x-pict": {
+ "source": "apache",
+ "extensions": ["pic","pct"]
+ },
+ "image/x-portable-anymap": {
+ "source": "apache",
+ "extensions": ["pnm"]
+ },
+ "image/x-portable-bitmap": {
+ "source": "apache",
+ "extensions": ["pbm"]
+ },
+ "image/x-portable-graymap": {
+ "source": "apache",
+ "extensions": ["pgm"]
+ },
+ "image/x-portable-pixmap": {
+ "source": "apache",
+ "extensions": ["ppm"]
+ },
+ "image/x-rgb": {
+ "source": "apache",
+ "extensions": ["rgb"]
+ },
+ "image/x-tga": {
+ "source": "apache",
+ "extensions": ["tga"]
+ },
+ "image/x-xbitmap": {
+ "source": "apache",
+ "extensions": ["xbm"]
+ },
+ "image/x-xcf": {
+ "compressible": false
+ },
+ "image/x-xpixmap": {
+ "source": "apache",
+ "extensions": ["xpm"]
+ },
+ "image/x-xwindowdump": {
+ "source": "apache",
+ "extensions": ["xwd"]
+ },
+ "message/cpim": {
+ "source": "iana"
+ },
+ "message/delivery-status": {
+ "source": "iana"
+ },
+ "message/disposition-notification": {
+ "source": "iana",
+ "extensions": [
+ "disposition-notification"
+ ]
+ },
+ "message/external-body": {
+ "source": "iana"
+ },
+ "message/feedback-report": {
+ "source": "iana"
+ },
+ "message/global": {
+ "source": "iana",
+ "extensions": ["u8msg"]
+ },
+ "message/global-delivery-status": {
+ "source": "iana",
+ "extensions": ["u8dsn"]
+ },
+ "message/global-disposition-notification": {
+ "source": "iana",
+ "extensions": ["u8mdn"]
+ },
+ "message/global-headers": {
+ "source": "iana",
+ "extensions": ["u8hdr"]
+ },
+ "message/http": {
+ "source": "iana",
+ "compressible": false
+ },
+ "message/imdn+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "message/news": {
+ "source": "iana"
+ },
+ "message/partial": {
+ "source": "iana",
+ "compressible": false
+ },
+ "message/rfc822": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["eml","mime"]
+ },
+ "message/s-http": {
+ "source": "iana"
+ },
+ "message/sip": {
+ "source": "iana"
+ },
+ "message/sipfrag": {
+ "source": "iana"
+ },
+ "message/tracking-status": {
+ "source": "iana"
+ },
+ "message/vnd.si.simp": {
+ "source": "iana"
+ },
+ "message/vnd.wfa.wsc": {
+ "source": "iana",
+ "extensions": ["wsc"]
+ },
+ "model/3mf": {
+ "source": "iana",
+ "extensions": ["3mf"]
+ },
+ "model/e57": {
+ "source": "iana"
+ },
+ "model/gltf+json": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["gltf"]
+ },
+ "model/gltf-binary": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["glb"]
+ },
+ "model/iges": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["igs","iges"]
+ },
+ "model/mesh": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["msh","mesh","silo"]
+ },
+ "model/mtl": {
+ "source": "iana",
+ "extensions": ["mtl"]
+ },
+ "model/obj": {
+ "source": "iana",
+ "extensions": ["obj"]
+ },
+ "model/step": {
+ "source": "iana"
+ },
+ "model/step+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["stpx"]
+ },
+ "model/step+zip": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["stpz"]
+ },
+ "model/step-xml+zip": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["stpxz"]
+ },
+ "model/stl": {
+ "source": "iana",
+ "extensions": ["stl"]
+ },
+ "model/vnd.collada+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["dae"]
+ },
+ "model/vnd.dwf": {
+ "source": "iana",
+ "extensions": ["dwf"]
+ },
+ "model/vnd.flatland.3dml": {
+ "source": "iana"
+ },
+ "model/vnd.gdl": {
+ "source": "iana",
+ "extensions": ["gdl"]
+ },
+ "model/vnd.gs-gdl": {
+ "source": "apache"
+ },
+ "model/vnd.gs.gdl": {
+ "source": "iana"
+ },
+ "model/vnd.gtw": {
+ "source": "iana",
+ "extensions": ["gtw"]
+ },
+ "model/vnd.moml+xml": {
+ "source": "iana",
+ "compressible": true
+ },
+ "model/vnd.mts": {
+ "source": "iana",
+ "extensions": ["mts"]
+ },
+ "model/vnd.opengex": {
+ "source": "iana",
+ "extensions": ["ogex"]
+ },
+ "model/vnd.parasolid.transmit.binary": {
+ "source": "iana",
+ "extensions": ["x_b"]
+ },
+ "model/vnd.parasolid.transmit.text": {
+ "source": "iana",
+ "extensions": ["x_t"]
+ },
+ "model/vnd.pytha.pyox": {
+ "source": "iana"
+ },
+ "model/vnd.rosette.annotated-data-model": {
+ "source": "iana"
+ },
+ "model/vnd.sap.vds": {
+ "source": "iana",
+ "extensions": ["vds"]
+ },
+ "model/vnd.usdz+zip": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["usdz"]
+ },
+ "model/vnd.valve.source.compiled-map": {
+ "source": "iana",
+ "extensions": ["bsp"]
+ },
+ "model/vnd.vtu": {
+ "source": "iana",
+ "extensions": ["vtu"]
+ },
+ "model/vrml": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["wrl","vrml"]
+ },
+ "model/x3d+binary": {
+ "source": "apache",
+ "compressible": false,
+ "extensions": ["x3db","x3dbz"]
+ },
+ "model/x3d+fastinfoset": {
+ "source": "iana",
+ "extensions": ["x3db"]
+ },
+ "model/x3d+vrml": {
+ "source": "apache",
+ "compressible": false,
+ "extensions": ["x3dv","x3dvz"]
+ },
+ "model/x3d+xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["x3d","x3dz"]
+ },
+ "model/x3d-vrml": {
+ "source": "iana",
+ "extensions": ["x3dv"]
+ },
+ "multipart/alternative": {
+ "source": "iana",
+ "compressible": false
+ },
+ "multipart/appledouble": {
+ "source": "iana"
+ },
+ "multipart/byteranges": {
+ "source": "iana"
+ },
+ "multipart/digest": {
+ "source": "iana"
+ },
+ "multipart/encrypted": {
+ "source": "iana",
+ "compressible": false
+ },
+ "multipart/form-data": {
+ "source": "iana",
+ "compressible": false
+ },
+ "multipart/header-set": {
+ "source": "iana"
+ },
+ "multipart/mixed": {
+ "source": "iana"
+ },
+ "multipart/multilingual": {
+ "source": "iana"
+ },
+ "multipart/parallel": {
+ "source": "iana"
+ },
+ "multipart/related": {
+ "source": "iana",
+ "compressible": false
+ },
+ "multipart/report": {
+ "source": "iana"
+ },
+ "multipart/signed": {
+ "source": "iana",
+ "compressible": false
+ },
+ "multipart/vnd.bint.med-plus": {
+ "source": "iana"
+ },
+ "multipart/voice-message": {
+ "source": "iana"
+ },
+ "multipart/x-mixed-replace": {
+ "source": "iana"
+ },
+ "text/1d-interleaved-parityfec": {
+ "source": "iana"
+ },
+ "text/cache-manifest": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["appcache","manifest"]
+ },
+ "text/calendar": {
+ "source": "iana",
+ "extensions": ["ics","ifb"]
+ },
+ "text/calender": {
+ "compressible": true
+ },
+ "text/cmd": {
+ "compressible": true
+ },
+ "text/coffeescript": {
+ "extensions": ["coffee","litcoffee"]
+ },
+ "text/cql": {
+ "source": "iana"
+ },
+ "text/cql-expression": {
+ "source": "iana"
+ },
+ "text/cql-identifier": {
+ "source": "iana"
+ },
+ "text/css": {
+ "source": "iana",
+ "charset": "UTF-8",
+ "compressible": true,
+ "extensions": ["css"]
+ },
+ "text/csv": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["csv"]
+ },
+ "text/csv-schema": {
+ "source": "iana"
+ },
+ "text/directory": {
+ "source": "iana"
+ },
+ "text/dns": {
+ "source": "iana"
+ },
+ "text/ecmascript": {
+ "source": "iana"
+ },
+ "text/encaprtp": {
+ "source": "iana"
+ },
+ "text/enriched": {
+ "source": "iana"
+ },
+ "text/fhirpath": {
+ "source": "iana"
+ },
+ "text/flexfec": {
+ "source": "iana"
+ },
+ "text/fwdred": {
+ "source": "iana"
+ },
+ "text/gff3": {
+ "source": "iana"
+ },
+ "text/grammar-ref-list": {
+ "source": "iana"
+ },
+ "text/html": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["html","htm","shtml"]
+ },
+ "text/jade": {
+ "extensions": ["jade"]
+ },
+ "text/javascript": {
+ "source": "iana",
+ "compressible": true
+ },
+ "text/jcr-cnd": {
+ "source": "iana"
+ },
+ "text/jsx": {
+ "compressible": true,
+ "extensions": ["jsx"]
+ },
+ "text/less": {
+ "compressible": true,
+ "extensions": ["less"]
+ },
+ "text/markdown": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["markdown","md"]
+ },
+ "text/mathml": {
+ "source": "nginx",
+ "extensions": ["mml"]
+ },
+ "text/mdx": {
+ "compressible": true,
+ "extensions": ["mdx"]
+ },
+ "text/mizar": {
+ "source": "iana"
+ },
+ "text/n3": {
+ "source": "iana",
+ "charset": "UTF-8",
+ "compressible": true,
+ "extensions": ["n3"]
+ },
+ "text/parameters": {
+ "source": "iana",
+ "charset": "UTF-8"
+ },
+ "text/parityfec": {
+ "source": "iana"
+ },
+ "text/plain": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["txt","text","conf","def","list","log","in","ini"]
+ },
+ "text/provenance-notation": {
+ "source": "iana",
+ "charset": "UTF-8"
+ },
+ "text/prs.fallenstein.rst": {
+ "source": "iana"
+ },
+ "text/prs.lines.tag": {
+ "source": "iana",
+ "extensions": ["dsc"]
+ },
+ "text/prs.prop.logic": {
+ "source": "iana"
+ },
+ "text/raptorfec": {
+ "source": "iana"
+ },
+ "text/red": {
+ "source": "iana"
+ },
+ "text/rfc822-headers": {
+ "source": "iana"
+ },
+ "text/richtext": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["rtx"]
+ },
+ "text/rtf": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["rtf"]
+ },
+ "text/rtp-enc-aescm128": {
+ "source": "iana"
+ },
+ "text/rtploopback": {
+ "source": "iana"
+ },
+ "text/rtx": {
+ "source": "iana"
+ },
+ "text/sgml": {
+ "source": "iana",
+ "extensions": ["sgml","sgm"]
+ },
+ "text/shaclc": {
+ "source": "iana"
+ },
+ "text/shex": {
+ "source": "iana",
+ "extensions": ["shex"]
+ },
+ "text/slim": {
+ "extensions": ["slim","slm"]
+ },
+ "text/spdx": {
+ "source": "iana",
+ "extensions": ["spdx"]
+ },
+ "text/strings": {
+ "source": "iana"
+ },
+ "text/stylus": {
+ "extensions": ["stylus","styl"]
+ },
+ "text/t140": {
+ "source": "iana"
+ },
+ "text/tab-separated-values": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["tsv"]
+ },
+ "text/troff": {
+ "source": "iana",
+ "extensions": ["t","tr","roff","man","me","ms"]
+ },
+ "text/turtle": {
+ "source": "iana",
+ "charset": "UTF-8",
+ "extensions": ["ttl"]
+ },
+ "text/ulpfec": {
+ "source": "iana"
+ },
+ "text/uri-list": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["uri","uris","urls"]
+ },
+ "text/vcard": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["vcard"]
+ },
+ "text/vnd.a": {
+ "source": "iana"
+ },
+ "text/vnd.abc": {
+ "source": "iana"
+ },
+ "text/vnd.ascii-art": {
+ "source": "iana"
+ },
+ "text/vnd.curl": {
+ "source": "iana",
+ "extensions": ["curl"]
+ },
+ "text/vnd.curl.dcurl": {
+ "source": "apache",
+ "extensions": ["dcurl"]
+ },
+ "text/vnd.curl.mcurl": {
+ "source": "apache",
+ "extensions": ["mcurl"]
+ },
+ "text/vnd.curl.scurl": {
+ "source": "apache",
+ "extensions": ["scurl"]
+ },
+ "text/vnd.debian.copyright": {
+ "source": "iana",
+ "charset": "UTF-8"
+ },
+ "text/vnd.dmclientscript": {
+ "source": "iana"
+ },
+ "text/vnd.dvb.subtitle": {
+ "source": "iana",
+ "extensions": ["sub"]
+ },
+ "text/vnd.esmertec.theme-descriptor": {
+ "source": "iana",
+ "charset": "UTF-8"
+ },
+ "text/vnd.familysearch.gedcom": {
+ "source": "iana",
+ "extensions": ["ged"]
+ },
+ "text/vnd.ficlab.flt": {
+ "source": "iana"
+ },
+ "text/vnd.fly": {
+ "source": "iana",
+ "extensions": ["fly"]
+ },
+ "text/vnd.fmi.flexstor": {
+ "source": "iana",
+ "extensions": ["flx"]
+ },
+ "text/vnd.gml": {
+ "source": "iana"
+ },
+ "text/vnd.graphviz": {
+ "source": "iana",
+ "extensions": ["gv"]
+ },
+ "text/vnd.hans": {
+ "source": "iana"
+ },
+ "text/vnd.hgl": {
+ "source": "iana"
+ },
+ "text/vnd.in3d.3dml": {
+ "source": "iana",
+ "extensions": ["3dml"]
+ },
+ "text/vnd.in3d.spot": {
+ "source": "iana",
+ "extensions": ["spot"]
+ },
+ "text/vnd.iptc.newsml": {
+ "source": "iana"
+ },
+ "text/vnd.iptc.nitf": {
+ "source": "iana"
+ },
+ "text/vnd.latex-z": {
+ "source": "iana"
+ },
+ "text/vnd.motorola.reflex": {
+ "source": "iana"
+ },
+ "text/vnd.ms-mediapackage": {
+ "source": "iana"
+ },
+ "text/vnd.net2phone.commcenter.command": {
+ "source": "iana"
+ },
+ "text/vnd.radisys.msml-basic-layout": {
+ "source": "iana"
+ },
+ "text/vnd.senx.warpscript": {
+ "source": "iana"
+ },
+ "text/vnd.si.uricatalogue": {
+ "source": "iana"
+ },
+ "text/vnd.sosi": {
+ "source": "iana"
+ },
+ "text/vnd.sun.j2me.app-descriptor": {
+ "source": "iana",
+ "charset": "UTF-8",
+ "extensions": ["jad"]
+ },
+ "text/vnd.trolltech.linguist": {
+ "source": "iana",
+ "charset": "UTF-8"
+ },
+ "text/vnd.wap.si": {
+ "source": "iana"
+ },
+ "text/vnd.wap.sl": {
+ "source": "iana"
+ },
+ "text/vnd.wap.wml": {
+ "source": "iana",
+ "extensions": ["wml"]
+ },
+ "text/vnd.wap.wmlscript": {
+ "source": "iana",
+ "extensions": ["wmls"]
+ },
+ "text/vtt": {
+ "source": "iana",
+ "charset": "UTF-8",
+ "compressible": true,
+ "extensions": ["vtt"]
+ },
+ "text/x-asm": {
+ "source": "apache",
+ "extensions": ["s","asm"]
+ },
+ "text/x-c": {
+ "source": "apache",
+ "extensions": ["c","cc","cxx","cpp","h","hh","dic"]
+ },
+ "text/x-component": {
+ "source": "nginx",
+ "extensions": ["htc"]
+ },
+ "text/x-fortran": {
+ "source": "apache",
+ "extensions": ["f","for","f77","f90"]
+ },
+ "text/x-gwt-rpc": {
+ "compressible": true
+ },
+ "text/x-handlebars-template": {
+ "extensions": ["hbs"]
+ },
+ "text/x-java-source": {
+ "source": "apache",
+ "extensions": ["java"]
+ },
+ "text/x-jquery-tmpl": {
+ "compressible": true
+ },
+ "text/x-lua": {
+ "extensions": ["lua"]
+ },
+ "text/x-markdown": {
+ "compressible": true,
+ "extensions": ["mkd"]
+ },
+ "text/x-nfo": {
+ "source": "apache",
+ "extensions": ["nfo"]
+ },
+ "text/x-opml": {
+ "source": "apache",
+ "extensions": ["opml"]
+ },
+ "text/x-org": {
+ "compressible": true,
+ "extensions": ["org"]
+ },
+ "text/x-pascal": {
+ "source": "apache",
+ "extensions": ["p","pas"]
+ },
+ "text/x-processing": {
+ "compressible": true,
+ "extensions": ["pde"]
+ },
+ "text/x-sass": {
+ "extensions": ["sass"]
+ },
+ "text/x-scss": {
+ "extensions": ["scss"]
+ },
+ "text/x-setext": {
+ "source": "apache",
+ "extensions": ["etx"]
+ },
+ "text/x-sfv": {
+ "source": "apache",
+ "extensions": ["sfv"]
+ },
+ "text/x-suse-ymp": {
+ "compressible": true,
+ "extensions": ["ymp"]
+ },
+ "text/x-uuencode": {
+ "source": "apache",
+ "extensions": ["uu"]
+ },
+ "text/x-vcalendar": {
+ "source": "apache",
+ "extensions": ["vcs"]
+ },
+ "text/x-vcard": {
+ "source": "apache",
+ "extensions": ["vcf"]
+ },
+ "text/xml": {
+ "source": "iana",
+ "compressible": true,
+ "extensions": ["xml"]
+ },
+ "text/xml-external-parsed-entity": {
+ "source": "iana"
+ },
+ "text/yaml": {
+ "compressible": true,
+ "extensions": ["yaml","yml"]
+ },
+ "video/1d-interleaved-parityfec": {
+ "source": "iana"
+ },
+ "video/3gpp": {
+ "source": "iana",
+ "extensions": ["3gp","3gpp"]
+ },
+ "video/3gpp-tt": {
+ "source": "iana"
+ },
+ "video/3gpp2": {
+ "source": "iana",
+ "extensions": ["3g2"]
+ },
+ "video/av1": {
+ "source": "iana"
+ },
+ "video/bmpeg": {
+ "source": "iana"
+ },
+ "video/bt656": {
+ "source": "iana"
+ },
+ "video/celb": {
+ "source": "iana"
+ },
+ "video/dv": {
+ "source": "iana"
+ },
+ "video/encaprtp": {
+ "source": "iana"
+ },
+ "video/ffv1": {
+ "source": "iana"
+ },
+ "video/flexfec": {
+ "source": "iana"
+ },
+ "video/h261": {
+ "source": "iana",
+ "extensions": ["h261"]
+ },
+ "video/h263": {
+ "source": "iana",
+ "extensions": ["h263"]
+ },
+ "video/h263-1998": {
+ "source": "iana"
+ },
+ "video/h263-2000": {
+ "source": "iana"
+ },
+ "video/h264": {
+ "source": "iana",
+ "extensions": ["h264"]
+ },
+ "video/h264-rcdo": {
+ "source": "iana"
+ },
+ "video/h264-svc": {
+ "source": "iana"
+ },
+ "video/h265": {
+ "source": "iana"
+ },
+ "video/iso.segment": {
+ "source": "iana",
+ "extensions": ["m4s"]
+ },
+ "video/jpeg": {
+ "source": "iana",
+ "extensions": ["jpgv"]
+ },
+ "video/jpeg2000": {
+ "source": "iana"
+ },
+ "video/jpm": {
+ "source": "apache",
+ "extensions": ["jpm","jpgm"]
+ },
+ "video/jxsv": {
+ "source": "iana"
+ },
+ "video/mj2": {
+ "source": "iana",
+ "extensions": ["mj2","mjp2"]
+ },
+ "video/mp1s": {
+ "source": "iana"
+ },
+ "video/mp2p": {
+ "source": "iana"
+ },
+ "video/mp2t": {
+ "source": "iana",
+ "extensions": ["ts"]
+ },
+ "video/mp4": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["mp4","mp4v","mpg4"]
+ },
+ "video/mp4v-es": {
+ "source": "iana"
+ },
+ "video/mpeg": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["mpeg","mpg","mpe","m1v","m2v"]
+ },
+ "video/mpeg4-generic": {
+ "source": "iana"
+ },
+ "video/mpv": {
+ "source": "iana"
+ },
+ "video/nv": {
+ "source": "iana"
+ },
+ "video/ogg": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["ogv"]
+ },
+ "video/parityfec": {
+ "source": "iana"
+ },
+ "video/pointer": {
+ "source": "iana"
+ },
+ "video/quicktime": {
+ "source": "iana",
+ "compressible": false,
+ "extensions": ["qt","mov"]
+ },
+ "video/raptorfec": {
+ "source": "iana"
+ },
+ "video/raw": {
+ "source": "iana"
+ },
+ "video/rtp-enc-aescm128": {
+ "source": "iana"
+ },
+ "video/rtploopback": {
+ "source": "iana"
+ },
+ "video/rtx": {
+ "source": "iana"
+ },
+ "video/scip": {
+ "source": "iana"
+ },
+ "video/smpte291": {
+ "source": "iana"
+ },
+ "video/smpte292m": {
+ "source": "iana"
+ },
+ "video/ulpfec": {
+ "source": "iana"
+ },
+ "video/vc1": {
+ "source": "iana"
+ },
+ "video/vc2": {
+ "source": "iana"
+ },
+ "video/vnd.cctv": {
+ "source": "iana"
+ },
+ "video/vnd.dece.hd": {
+ "source": "iana",
+ "extensions": ["uvh","uvvh"]
+ },
+ "video/vnd.dece.mobile": {
+ "source": "iana",
+ "extensions": ["uvm","uvvm"]
+ },
+ "video/vnd.dece.mp4": {
+ "source": "iana"
+ },
+ "video/vnd.dece.pd": {
+ "source": "iana",
+ "extensions": ["uvp","uvvp"]
+ },
+ "video/vnd.dece.sd": {
+ "source": "iana",
+ "extensions": ["uvs","uvvs"]
+ },
+ "video/vnd.dece.video": {
+ "source": "iana",
+ "extensions": ["uvv","uvvv"]
+ },
+ "video/vnd.directv.mpeg": {
+ "source": "iana"
+ },
+ "video/vnd.directv.mpeg-tts": {
+ "source": "iana"
+ },
+ "video/vnd.dlna.mpeg-tts": {
+ "source": "iana"
+ },
+ "video/vnd.dvb.file": {
+ "source": "iana",
+ "extensions": ["dvb"]
+ },
+ "video/vnd.fvt": {
+ "source": "iana",
+ "extensions": ["fvt"]
+ },
+ "video/vnd.hns.video": {
+ "source": "iana"
+ },
+ "video/vnd.iptvforum.1dparityfec-1010": {
+ "source": "iana"
+ },
+ "video/vnd.iptvforum.1dparityfec-2005": {
+ "source": "iana"
+ },
+ "video/vnd.iptvforum.2dparityfec-1010": {
+ "source": "iana"
+ },
+ "video/vnd.iptvforum.2dparityfec-2005": {
+ "source": "iana"
+ },
+ "video/vnd.iptvforum.ttsavc": {
+ "source": "iana"
+ },
+ "video/vnd.iptvforum.ttsmpeg2": {
+ "source": "iana"
+ },
+ "video/vnd.motorola.video": {
+ "source": "iana"
+ },
+ "video/vnd.motorola.videop": {
+ "source": "iana"
+ },
+ "video/vnd.mpegurl": {
+ "source": "iana",
+ "extensions": ["mxu","m4u"]
+ },
+ "video/vnd.ms-playready.media.pyv": {
+ "source": "iana",
+ "extensions": ["pyv"]
+ },
+ "video/vnd.nokia.interleaved-multimedia": {
+ "source": "iana"
+ },
+ "video/vnd.nokia.mp4vr": {
+ "source": "iana"
+ },
+ "video/vnd.nokia.videovoip": {
+ "source": "iana"
+ },
+ "video/vnd.objectvideo": {
+ "source": "iana"
+ },
+ "video/vnd.radgamettools.bink": {
+ "source": "iana"
+ },
+ "video/vnd.radgamettools.smacker": {
+ "source": "iana"
+ },
+ "video/vnd.sealed.mpeg1": {
+ "source": "iana"
+ },
+ "video/vnd.sealed.mpeg4": {
+ "source": "iana"
+ },
+ "video/vnd.sealed.swf": {
+ "source": "iana"
+ },
+ "video/vnd.sealedmedia.softseal.mov": {
+ "source": "iana"
+ },
+ "video/vnd.uvvu.mp4": {
+ "source": "iana",
+ "extensions": ["uvu","uvvu"]
+ },
+ "video/vnd.vivo": {
+ "source": "iana",
+ "extensions": ["viv"]
+ },
+ "video/vnd.youtube.yt": {
+ "source": "iana"
+ },
+ "video/vp8": {
+ "source": "iana"
+ },
+ "video/vp9": {
+ "source": "iana"
+ },
+ "video/webm": {
+ "source": "apache",
+ "compressible": false,
+ "extensions": ["webm"]
+ },
+ "video/x-f4v": {
+ "source": "apache",
+ "extensions": ["f4v"]
+ },
+ "video/x-fli": {
+ "source": "apache",
+ "extensions": ["fli"]
+ },
+ "video/x-flv": {
+ "source": "apache",
+ "compressible": false,
+ "extensions": ["flv"]
+ },
+ "video/x-m4v": {
+ "source": "apache",
+ "extensions": ["m4v"]
+ },
+ "video/x-matroska": {
+ "source": "apache",
+ "compressible": false,
+ "extensions": ["mkv","mk3d","mks"]
+ },
+ "video/x-mng": {
+ "source": "apache",
+ "extensions": ["mng"]
+ },
+ "video/x-ms-asf": {
+ "source": "apache",
+ "extensions": ["asf","asx"]
+ },
+ "video/x-ms-vob": {
+ "source": "apache",
+ "extensions": ["vob"]
+ },
+ "video/x-ms-wm": {
+ "source": "apache",
+ "extensions": ["wm"]
+ },
+ "video/x-ms-wmv": {
+ "source": "apache",
+ "compressible": false,
+ "extensions": ["wmv"]
+ },
+ "video/x-ms-wmx": {
+ "source": "apache",
+ "extensions": ["wmx"]
+ },
+ "video/x-ms-wvx": {
+ "source": "apache",
+ "extensions": ["wvx"]
+ },
+ "video/x-msvideo": {
+ "source": "apache",
+ "extensions": ["avi"]
+ },
+ "video/x-sgi-movie": {
+ "source": "apache",
+ "extensions": ["movie"]
+ },
+ "video/x-smv": {
+ "source": "apache",
+ "extensions": ["smv"]
+ },
+ "x-conference/x-cooltalk": {
+ "source": "apache",
+ "extensions": ["ice"]
+ },
+ "x-shader/x-fragment": {
+ "compressible": true
+ },
+ "x-shader/x-vertex": {
+ "compressible": true
+ }
+}
diff --git a/node_modules/mime-db/index.js b/node_modules/mime-db/index.js
new file mode 100644
index 0000000..551031f
--- /dev/null
+++ b/node_modules/mime-db/index.js
@@ -0,0 +1,11 @@
+/*!
+ * mime-db
+ * Copyright(c) 2014 Jonathan Ong
+ * MIT Licensed
+ */
+
+/**
+ * Module exports.
+ */
+
+module.exports = require('./db.json')
diff --git a/node_modules/mime-db/package.json b/node_modules/mime-db/package.json
new file mode 100644
index 0000000..6d023ba
--- /dev/null
+++ b/node_modules/mime-db/package.json
@@ -0,0 +1,59 @@
+{
+ "name": "mime-db",
+ "description": "Media Type Database",
+ "version": "1.51.0",
+ "contributors": [
+ "Douglas Christopher Wilson <doug@somethingdoug.com>",
+ "Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)",
+ "Robert Kieffer <robert@broofa.com> (http://github.com/broofa)"
+ ],
+ "license": "MIT",
+ "keywords": [
+ "mime",
+ "db",
+ "type",
+ "types",
+ "database",
+ "charset",
+ "charsets"
+ ],
+ "repository": "jshttp/mime-db",
+ "devDependencies": {
+ "bluebird": "3.7.2",
+ "co": "4.6.0",
+ "cogent": "1.0.1",
+ "csv-parse": "4.16.3",
+ "eslint": "7.32.0",
+ "eslint-config-standard": "15.0.1",
+ "eslint-plugin-import": "2.25.2",
+ "eslint-plugin-markdown": "2.2.1",
+ "eslint-plugin-node": "11.1.0",
+ "eslint-plugin-promise": "5.1.1",
+ "eslint-plugin-standard": "4.1.0",
+ "gnode": "0.1.2",
+ "mocha": "9.1.3",
+ "nyc": "15.1.0",
+ "raw-body": "2.4.1",
+ "stream-to-array": "2.3.0"
+ },
+ "files": [
+ "HISTORY.md",
+ "LICENSE",
+ "README.md",
+ "db.json",
+ "index.js"
+ ],
+ "engines": {
+ "node": ">= 0.6"
+ },
+ "scripts": {
+ "build": "node scripts/build",
+ "fetch": "node scripts/fetch-apache && gnode scripts/fetch-iana && node scripts/fetch-nginx",
+ "lint": "eslint .",
+ "test": "mocha --reporter spec --bail --check-leaks test/",
+ "test-ci": "nyc --reporter=lcov --reporter=text npm test",
+ "test-cov": "nyc --reporter=html --reporter=text npm test",
+ "update": "npm run fetch && npm run build",
+ "version": "node scripts/version-history.js && git add HISTORY.md"
+ }
+}
diff --git a/node_modules/mime-types/HISTORY.md b/node_modules/mime-types/HISTORY.md
new file mode 100644
index 0000000..7484cf4
--- /dev/null
+++ b/node_modules/mime-types/HISTORY.md
@@ -0,0 +1,388 @@
+2.1.34 / 2021-11-08
+===================
+
+ * deps: mime-db@1.51.0
+ - Add new upstream MIME types
+
+2.1.33 / 2021-10-01
+===================
+
+ * deps: mime-db@1.50.0
+ - Add deprecated iWorks mime types and extensions
+ - Add new upstream MIME types
+
+2.1.32 / 2021-07-27
+===================
+
+ * deps: mime-db@1.49.0
+ - Add extension `.trig` to `application/trig`
+ - Add new upstream MIME types
+
+2.1.31 / 2021-06-01
+===================
+
+ * deps: mime-db@1.48.0
+ - Add extension `.mvt` to `application/vnd.mapbox-vector-tile`
+ - Add new upstream MIME types
+
+2.1.30 / 2021-04-02
+===================
+
+ * deps: mime-db@1.47.0
+ - Add extension `.amr` to `audio/amr`
+ - Remove ambigious extensions from IANA for `application/*+xml` types
+ - Update primary extension to `.es` for `application/ecmascript`
+
+2.1.29 / 2021-02-17
+===================
+
+ * deps: mime-db@1.46.0
+ - Add extension `.amr` to `audio/amr`
+ - Add extension `.m4s` to `video/iso.segment`
+ - Add extension `.opus` to `audio/ogg`
+ - Add new upstream MIME types
+
+2.1.28 / 2021-01-01
+===================
+
+ * deps: mime-db@1.45.0
+ - Add `application/ubjson` with extension `.ubj`
+ - Add `image/avif` with extension `.avif`
+ - Add `image/ktx2` with extension `.ktx2`
+ - Add extension `.dbf` to `application/vnd.dbf`
+ - Add extension `.rar` to `application/vnd.rar`
+ - Add extension `.td` to `application/urc-targetdesc+xml`
+ - Add new upstream MIME types
+ - Fix extension of `application/vnd.apple.keynote` to be `.key`
+
+2.1.27 / 2020-04-23
+===================
+
+ * deps: mime-db@1.44.0
+ - Add charsets from IANA
+ - Add extension `.cjs` to `application/node`
+ - Add new upstream MIME types
+
+2.1.26 / 2020-01-05
+===================
+
+ * deps: mime-db@1.43.0
+ - Add `application/x-keepass2` with extension `.kdbx`
+ - Add extension `.mxmf` to `audio/mobile-xmf`
+ - Add extensions from IANA for `application/*+xml` types
+ - Add new upstream MIME types
+
+2.1.25 / 2019-11-12
+===================
+
+ * deps: mime-db@1.42.0
+ - Add new upstream MIME types
+ - Add `application/toml` with extension `.toml`
+ - Add `image/vnd.ms-dds` with extension `.dds`
+
+2.1.24 / 2019-04-20
+===================
+
+ * deps: mime-db@1.40.0
+ - Add extensions from IANA for `model/*` types
+ - Add `text/mdx` with extension `.mdx`
+
+2.1.23 / 2019-04-17
+===================
+
+ * deps: mime-db@~1.39.0
+ - Add extensions `.siv` and `.sieve` to `application/sieve`
+ - Add new upstream MIME types
+
+2.1.22 / 2019-02-14
+===================
+
+ * deps: mime-db@~1.38.0
+ - Add extension `.nq` to `application/n-quads`
+ - Add extension `.nt` to `application/n-triples`
+ - Add new upstream MIME types
+
+2.1.21 / 2018-10-19
+===================
+
+ * deps: mime-db@~1.37.0
+ - Add extensions to HEIC image types
+ - Add new upstream MIME types
+
+2.1.20 / 2018-08-26
+===================
+
+ * deps: mime-db@~1.36.0
+ - Add Apple file extensions from IANA
+ - Add extensions from IANA for `image/*` types
+ - Add new upstream MIME types
+
+2.1.19 / 2018-07-17
+===================
+
+ * deps: mime-db@~1.35.0
+ - Add extension `.csl` to `application/vnd.citationstyles.style+xml`
+ - Add extension `.es` to `application/ecmascript`
+ - Add extension `.owl` to `application/rdf+xml`
+ - Add new upstream MIME types
+ - Add UTF-8 as default charset for `text/turtle`
+
+2.1.18 / 2018-02-16
+===================
+
+ * deps: mime-db@~1.33.0
+ - Add `application/raml+yaml` with extension `.raml`
+ - Add `application/wasm` with extension `.wasm`
+ - Add `text/shex` with extension `.shex`
+ - Add extensions for JPEG-2000 images
+ - Add extensions from IANA for `message/*` types
+ - Add new upstream MIME types
+ - Update font MIME types
+ - Update `text/hjson` to registered `application/hjson`
+
+2.1.17 / 2017-09-01
+===================
+
+ * deps: mime-db@~1.30.0
+ - Add `application/vnd.ms-outlook`
+ - Add `application/x-arj`
+ - Add extension `.mjs` to `application/javascript`
+ - Add glTF types and extensions
+ - Add new upstream MIME types
+ - Add `text/x-org`
+ - Add VirtualBox MIME types
+ - Fix `source` records for `video/*` types that are IANA
+ - Update `font/opentype` to registered `font/otf`
+
+2.1.16 / 2017-07-24
+===================
+
+ * deps: mime-db@~1.29.0
+ - Add `application/fido.trusted-apps+json`
+ - Add extension `.wadl` to `application/vnd.sun.wadl+xml`
+ - Add extension `.gz` to `application/gzip`
+ - Add new upstream MIME types
+ - Update extensions `.md` and `.markdown` to be `text/markdown`
+
+2.1.15 / 2017-03-23
+===================
+
+ * deps: mime-db@~1.27.0
+ - Add new mime types
+ - Add `image/apng`
+
+2.1.14 / 2017-01-14
+===================
+
+ * deps: mime-db@~1.26.0
+ - Add new mime types
+
+2.1.13 / 2016-11-18
+===================
+
+ * deps: mime-db@~1.25.0
+ - Add new mime types
+
+2.1.12 / 2016-09-18
+===================
+
+ * deps: mime-db@~1.24.0
+ - Add new mime types
+ - Add `audio/mp3`
+
+2.1.11 / 2016-05-01
+===================
+
+ * deps: mime-db@~1.23.0
+ - Add new mime types
+
+2.1.10 / 2016-02-15
+===================
+
+ * deps: mime-db@~1.22.0
+ - Add new mime types
+ - Fix extension of `application/dash+xml`
+ - Update primary extension for `audio/mp4`
+
+2.1.9 / 2016-01-06
+==================
+
+ * deps: mime-db@~1.21.0
+ - Add new mime types
+
+2.1.8 / 2015-11-30
+==================
+
+ * deps: mime-db@~1.20.0
+ - Add new mime types
+
+2.1.7 / 2015-09-20
+==================
+
+ * deps: mime-db@~1.19.0
+ - Add new mime types
+
+2.1.6 / 2015-09-03
+==================
+
+ * deps: mime-db@~1.18.0
+ - Add new mime types
+
+2.1.5 / 2015-08-20
+==================
+
+ * deps: mime-db@~1.17.0
+ - Add new mime types
+
+2.1.4 / 2015-07-30
+==================
+
+ * deps: mime-db@~1.16.0
+ - Add new mime types
+
+2.1.3 / 2015-07-13
+==================
+
+ * deps: mime-db@~1.15.0
+ - Add new mime types
+
+2.1.2 / 2015-06-25
+==================
+
+ * deps: mime-db@~1.14.0
+ - Add new mime types
+
+2.1.1 / 2015-06-08
+==================
+
+ * perf: fix deopt during mapping
+
+2.1.0 / 2015-06-07
+==================
+
+ * Fix incorrectly treating extension-less file name as extension
+ - i.e. `'path/to/json'` will no longer return `application/json`
+ * Fix `.charset(type)` to accept parameters
+ * Fix `.charset(type)` to match case-insensitive
+ * Improve generation of extension to MIME mapping
+ * Refactor internals for readability and no argument reassignment
+ * Prefer `application/*` MIME types from the same source
+ * Prefer any type over `application/octet-stream`
+ * deps: mime-db@~1.13.0
+ - Add nginx as a source
+ - Add new mime types
+
+2.0.14 / 2015-06-06
+===================
+
+ * deps: mime-db@~1.12.0
+ - Add new mime types
+
+2.0.13 / 2015-05-31
+===================
+
+ * deps: mime-db@~1.11.0
+ - Add new mime types
+
+2.0.12 / 2015-05-19
+===================
+
+ * deps: mime-db@~1.10.0
+ - Add new mime types
+
+2.0.11 / 2015-05-05
+===================
+
+ * deps: mime-db@~1.9.1
+ - Add new mime types
+
+2.0.10 / 2015-03-13
+===================
+
+ * deps: mime-db@~1.8.0
+ - Add new mime types
+
+2.0.9 / 2015-02-09
+==================
+
+ * deps: mime-db@~1.7.0
+ - Add new mime types
+ - Community extensions ownership transferred from `node-mime`
+
+2.0.8 / 2015-01-29
+==================
+
+ * deps: mime-db@~1.6.0
+ - Add new mime types
+
+2.0.7 / 2014-12-30
+==================
+
+ * deps: mime-db@~1.5.0
+ - Add new mime types
+ - Fix various invalid MIME type entries
+
+2.0.6 / 2014-12-30
+==================
+
+ * deps: mime-db@~1.4.0
+ - Add new mime types
+ - Fix various invalid MIME type entries
+ - Remove example template MIME types
+
+2.0.5 / 2014-12-29
+==================
+
+ * deps: mime-db@~1.3.1
+ - Fix missing extensions
+
+2.0.4 / 2014-12-10
+==================
+
+ * deps: mime-db@~1.3.0
+ - Add new mime types
+
+2.0.3 / 2014-11-09
+==================
+
+ * deps: mime-db@~1.2.0
+ - Add new mime types
+
+2.0.2 / 2014-09-28
+==================
+
+ * deps: mime-db@~1.1.0
+ - Add new mime types
+ - Update charsets
+
+2.0.1 / 2014-09-07
+==================
+
+ * Support Node.js 0.6
+
+2.0.0 / 2014-09-02
+==================
+
+ * Use `mime-db`
+ * Remove `.define()`
+
+1.0.2 / 2014-08-04
+==================
+
+ * Set charset=utf-8 for `text/javascript`
+
+1.0.1 / 2014-06-24
+==================
+
+ * Add `text/jsx` type
+
+1.0.0 / 2014-05-12
+==================
+
+ * Return `false` for unknown types
+ * Set charset=utf-8 for `application/json`
+
+0.1.0 / 2014-05-02
+==================
+
+ * Initial release
diff --git a/node_modules/mime-types/LICENSE b/node_modules/mime-types/LICENSE
new file mode 100644
index 0000000..0616607
--- /dev/null
+++ b/node_modules/mime-types/LICENSE
@@ -0,0 +1,23 @@
+(The MIT License)
+
+Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
+Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com>
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/mime-types/README.md b/node_modules/mime-types/README.md
new file mode 100644
index 0000000..c978ac2
--- /dev/null
+++ b/node_modules/mime-types/README.md
@@ -0,0 +1,113 @@
+# mime-types
+
+[![NPM Version][npm-version-image]][npm-url]
+[![NPM Downloads][npm-downloads-image]][npm-url]
+[![Node.js Version][node-version-image]][node-version-url]
+[![Build Status][ci-image]][ci-url]
+[![Test Coverage][coveralls-image]][coveralls-url]
+
+The ultimate javascript content-type utility.
+
+Similar to [the `mime@1.x` module](https://www.npmjs.com/package/mime), except:
+
+- __No fallbacks.__ Instead of naively returning the first available type,
+ `mime-types` simply returns `false`, so do
+ `var type = mime.lookup('unrecognized') || 'application/octet-stream'`.
+- No `new Mime()` business, so you could do `var lookup = require('mime-types').lookup`.
+- No `.define()` functionality
+- Bug fixes for `.lookup(path)`
+
+Otherwise, the API is compatible with `mime` 1.x.
+
+## Install
+
+This is a [Node.js](https://nodejs.org/en/) module available through the
+[npm registry](https://www.npmjs.com/). Installation is done using the
+[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
+
+```sh
+$ npm install mime-types
+```
+
+## Adding Types
+
+All mime types are based on [mime-db](https://www.npmjs.com/package/mime-db),
+so open a PR there if you'd like to add mime types.
+
+## API
+
+```js
+var mime = require('mime-types')
+```
+
+All functions return `false` if input is invalid or not found.
+
+### mime.lookup(path)
+
+Lookup the content-type associated with a file.
+
+```js
+mime.lookup('json') // 'application/json'
+mime.lookup('.md') // 'text/markdown'
+mime.lookup('file.html') // 'text/html'
+mime.lookup('folder/file.js') // 'application/javascript'
+mime.lookup('folder/.htaccess') // false
+
+mime.lookup('cats') // false
+```
+
+### mime.contentType(type)
+
+Create a full content-type header given a content-type or extension.
+When given an extension, `mime.lookup` is used to get the matching
+content-type, otherwise the given content-type is used. Then if the
+content-type does not already have a `charset` parameter, `mime.charset`
+is used to get the default charset and add to the returned content-type.
+
+```js
+mime.contentType('markdown') // 'text/x-markdown; charset=utf-8'
+mime.contentType('file.json') // 'application/json; charset=utf-8'
+mime.contentType('text/html') // 'text/html; charset=utf-8'
+mime.contentType('text/html; charset=iso-8859-1') // 'text/html; charset=iso-8859-1'
+
+// from a full path
+mime.contentType(path.extname('/path/to/file.json')) // 'application/json; charset=utf-8'
+```
+
+### mime.extension(type)
+
+Get the default extension for a content-type.
+
+```js
+mime.extension('application/octet-stream') // 'bin'
+```
+
+### mime.charset(type)
+
+Lookup the implied default charset of a content-type.
+
+```js
+mime.charset('text/markdown') // 'UTF-8'
+```
+
+### var type = mime.types[extension]
+
+A map of content-types by extension.
+
+### [extensions...] = mime.extensions[type]
+
+A map of extensions by content-type.
+
+## License
+
+[MIT](LICENSE)
+
+[ci-image]: https://badgen.net/github/checks/jshttp/mime-types/master?label=ci
+[ci-url]: https://github.com/jshttp/mime-types/actions?query=workflow%3Aci
+[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/mime-types/master
+[coveralls-url]: https://coveralls.io/r/jshttp/mime-types?branch=master
+[node-version-image]: https://badgen.net/npm/node/mime-types
+[node-version-url]: https://nodejs.org/en/download
+[npm-downloads-image]: https://badgen.net/npm/dm/mime-types
+[npm-url]: https://npmjs.org/package/mime-types
+[npm-version-image]: https://badgen.net/npm/v/mime-types
diff --git a/node_modules/mime-types/index.js b/node_modules/mime-types/index.js
new file mode 100644
index 0000000..b9f34d5
--- /dev/null
+++ b/node_modules/mime-types/index.js
@@ -0,0 +1,188 @@
+/*!
+ * mime-types
+ * Copyright(c) 2014 Jonathan Ong
+ * Copyright(c) 2015 Douglas Christopher Wilson
+ * MIT Licensed
+ */
+
+'use strict'
+
+/**
+ * Module dependencies.
+ * @private
+ */
+
+var db = require('mime-db')
+var extname = require('path').extname
+
+/**
+ * Module variables.
+ * @private
+ */
+
+var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/
+var TEXT_TYPE_REGEXP = /^text\//i
+
+/**
+ * Module exports.
+ * @public
+ */
+
+exports.charset = charset
+exports.charsets = { lookup: charset }
+exports.contentType = contentType
+exports.extension = extension
+exports.extensions = Object.create(null)
+exports.lookup = lookup
+exports.types = Object.create(null)
+
+// Populate the extensions/types maps
+populateMaps(exports.extensions, exports.types)
+
+/**
+ * Get the default charset for a MIME type.
+ *
+ * @param {string} type
+ * @return {boolean|string}
+ */
+
+function charset (type) {
+ if (!type || typeof type !== 'string') {
+ return false
+ }
+
+ // TODO: use media-typer
+ var match = EXTRACT_TYPE_REGEXP.exec(type)
+ var mime = match && db[match[1].toLowerCase()]
+
+ if (mime && mime.charset) {
+ return mime.charset
+ }
+
+ // default text/* to utf-8
+ if (match && TEXT_TYPE_REGEXP.test(match[1])) {
+ return 'UTF-8'
+ }
+
+ return false
+}
+
+/**
+ * Create a full Content-Type header given a MIME type or extension.
+ *
+ * @param {string} str
+ * @return {boolean|string}
+ */
+
+function contentType (str) {
+ // TODO: should this even be in this module?
+ if (!str || typeof str !== 'string') {
+ return false
+ }
+
+ var mime = str.indexOf('/') === -1
+ ? exports.lookup(str)
+ : str
+
+ if (!mime) {
+ return false
+ }
+
+ // TODO: use content-type or other module
+ if (mime.indexOf('charset') === -1) {
+ var charset = exports.charset(mime)
+ if (charset) mime += '; charset=' + charset.toLowerCase()
+ }
+
+ return mime
+}
+
+/**
+ * Get the default extension for a MIME type.
+ *
+ * @param {string} type
+ * @return {boolean|string}
+ */
+
+function extension (type) {
+ if (!type || typeof type !== 'string') {
+ return false
+ }
+
+ // TODO: use media-typer
+ var match = EXTRACT_TYPE_REGEXP.exec(type)
+
+ // get extensions
+ var exts = match && exports.extensions[match[1].toLowerCase()]
+
+ if (!exts || !exts.length) {
+ return false
+ }
+
+ return exts[0]
+}
+
+/**
+ * Lookup the MIME type for a file path/extension.
+ *
+ * @param {string} path
+ * @return {boolean|string}
+ */
+
+function lookup (path) {
+ if (!path || typeof path !== 'string') {
+ return false
+ }
+
+ // get the extension ("ext" or ".ext" or full path)
+ var extension = extname('x.' + path)
+ .toLowerCase()
+ .substr(1)
+
+ if (!extension) {
+ return false
+ }
+
+ return exports.types[extension] || false
+}
+
+/**
+ * Populate the extensions and types maps.
+ * @private
+ */
+
+function populateMaps (extensions, types) {
+ // source preference (least -> most)
+ var preference = ['nginx', 'apache', undefined, 'iana']
+
+ Object.keys(db).forEach(function forEachMimeType (type) {
+ var mime = db[type]
+ var exts = mime.extensions
+
+ if (!exts || !exts.length) {
+ return
+ }
+
+ // mime -> extensions
+ extensions[type] = exts
+
+ // extension -> mime
+ for (var i = 0; i < exts.length; i++) {
+ var extension = exts[i]
+
+ if (types[extension]) {
+ var from = preference.indexOf(db[types[extension]].source)
+ var to = preference.indexOf(mime.source)
+
+ if (types[extension] !== 'application/octet-stream' &&
+ (from > to || (from === to && types[extension].substr(0, 12) === 'application/'))) {
+ // skip the remapping
+ continue
+ }
+ }
+
+ // set the extension -> mime
+ types[extension] = type
+ }
+ })
+}
diff --git a/node_modules/mime-types/package.json b/node_modules/mime-types/package.json
new file mode 100644
index 0000000..f1d282e
--- /dev/null
+++ b/node_modules/mime-types/package.json
@@ -0,0 +1,44 @@
+{
+ "name": "mime-types",
+ "description": "The ultimate javascript content-type utility.",
+ "version": "2.1.34",
+ "contributors": [
+ "Douglas Christopher Wilson <doug@somethingdoug.com>",
+ "Jeremiah Senkpiel <fishrock123@rocketmail.com> (https://searchbeam.jit.su)",
+ "Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"
+ ],
+ "license": "MIT",
+ "keywords": [
+ "mime",
+ "types"
+ ],
+ "repository": "jshttp/mime-types",
+ "dependencies": {
+ "mime-db": "1.51.0"
+ },
+ "devDependencies": {
+ "eslint": "7.32.0",
+ "eslint-config-standard": "14.1.1",
+ "eslint-plugin-import": "2.25.2",
+ "eslint-plugin-markdown": "2.2.1",
+ "eslint-plugin-node": "11.1.0",
+ "eslint-plugin-promise": "5.1.1",
+ "eslint-plugin-standard": "4.1.0",
+ "mocha": "9.1.3",
+ "nyc": "15.1.0"
+ },
+ "files": [
+ "HISTORY.md",
+ "LICENSE",
+ "index.js"
+ ],
+ "engines": {
+ "node": ">= 0.6"
+ },
+ "scripts": {
+ "lint": "eslint .",
+ "test": "mocha --reporter spec test/test.js",
+ "test-ci": "nyc --reporter=lcov --reporter=text npm test",
+ "test-cov": "nyc --reporter=html --reporter=text npm test"
+ }
+}
diff --git a/node_modules/mmmagic/.travis.yml b/node_modules/mmmagic/.travis.yml
new file mode 100644
index 0000000..7b007d2
--- /dev/null
+++ b/node_modules/mmmagic/.travis.yml
@@ -0,0 +1,28 @@
+os:
+ - linux
+ - osx
+sudo: false
+language: cpp
+addons:
+ apt:
+ sources:
+ - ubuntu-toolchain-r-test
+ packages:
+ - g++-8
+notifications:
+ email: false
+env:
+ matrix:
+ - TRAVIS_NODE_VERSION="4"
+ - TRAVIS_NODE_VERSION="6"
+ - TRAVIS_NODE_VERSION="8"
+ - TRAVIS_NODE_VERSION="10"
+ - TRAVIS_NODE_VERSION="12"
+install:
+ - rm -rf ~/.nvm && git clone https://github.com/nvm-sh/nvm.git ~/.nvm && source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION
+ - node --version
+ - npm --version
+ - if [[ $TRAVIS_OS_NAME == "linux" ]]; then export CXX=g++-8; export CC=gcc-8; fi
+ - $CXX --version
+ - npm install
+script: npm test
diff --git a/node_modules/mmmagic/LICENSE b/node_modules/mmmagic/LICENSE
new file mode 100644
index 0000000..9ea90e0
--- /dev/null
+++ b/node_modules/mmmagic/LICENSE
@@ -0,0 +1,19 @@
+Copyright Brian White. All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to
+deal in the Software without restriction, including without limitation the
+rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+IN THE SOFTWARE. \ No newline at end of file
diff --git a/node_modules/mmmagic/README.md b/node_modules/mmmagic/README.md
new file mode 100644
index 0000000..0da014b
--- /dev/null
+++ b/node_modules/mmmagic/README.md
@@ -0,0 +1,110 @@
+
+Description
+===========
+
+An async libmagic binding for [node.js](http://nodejs.org/) for detecting content types by data inspection.
+
+[![Build Status](https://travis-ci.org/mscdex/mmmagic.svg?branch=master)](https://travis-ci.org/mscdex/mmmagic)
+[![Build status](https://ci.appveyor.com/api/projects/status/mva462lka1ap5a3t)](https://ci.appveyor.com/project/mscdex/mmmagic)
+
+
+Requirements
+============
+
+* [node.js](http://nodejs.org/) -- v4.0.0 or newer
+
+
+Install
+=======
+
+ npm install mmmagic
+
+
+Examples
+========
+
+* Get general description of a file:
+```javascript
+ var Magic = require('mmmagic').Magic;
+
+ var magic = new Magic();
+ magic.detectFile('node_modules/mmmagic/build/Release/magic.node', function(err, result) {
+ if (err) throw err;
+ console.log(result);
+ // output on Windows with 32-bit node:
+ // PE32 executable (DLL) (GUI) Intel 80386, for MS Windows
+ });
+```
+* Get mime type for a file:
+```javascript
+ var mmm = require('mmmagic'),
+ Magic = mmm.Magic;
+
+ var magic = new Magic(mmm.MAGIC_MIME_TYPE);
+ magic.detectFile('node_modules/mmmagic/build/Release/magic.node', function(err, result) {
+ if (err) throw err;
+ console.log(result);
+ // output on Windows with 32-bit node:
+ // application/x-dosexec
+ });
+```
+* Get mime type and mime encoding for a file:
+```javascript
+ var mmm = require('mmmagic'),
+ Magic = mmm.Magic;
+
+ var magic = new Magic(mmm.MAGIC_MIME_TYPE | mmm.MAGIC_MIME_ENCODING);
+ // the above flags can also be shortened down to just: mmm.MAGIC_MIME
+ magic.detectFile('node_modules/mmmagic/build/Release/magic.node', function(err, result) {
+ if (err) throw err;
+ console.log(result);
+ // output on Windows with 32-bit node:
+ // application/x-dosexec; charset=binary
+ });
+```
+* Get general description of the contents of a Buffer:
+```javascript
+ var Magic = require('mmmagic').Magic;
+
+ var magic = new Magic(),
+ buf = new Buffer('import Options\nfrom os import unlink, symlink');
+
+ magic.detect(buf, function(err, result) {
+ if (err) throw err;
+ console.log(result);
+ // output: Python script, ASCII text executable
+ });
+```
+
+API
+===
+
+Magic methods
+-------------
+
+* **(constructor)**([< _mixed_ >magicSource][, < _Integer_ >flags]) - Creates and returns a new Magic instance. `magicSource` (if specified) can either be a path string that points to a (compatible) magic file to use *or* it can be a _Buffer_ containing the contents of a (compatible) magic file. If `magicSource` is not a string and not `false`, the bundled magic file will be used. If `magicSource` is `false`, mmmagic will default to searching for a magic file to use (order of magic file searching: `MAGIC` env var -> various file system paths (see `man file`)). flags is a bitmask with the following valid values (available as constants on `require('mmmagic')`):
+
+ * **MAGIC\_NONE** - No flags set
+ * **MAGIC\_DEBUG** - Turn on debugging
+ * **MAGIC\_SYMLINK** - Follow symlinks **(default for non-Windows)**
+ * **MAGIC\_DEVICES** - Look at the contents of devices
+ * **MAGIC\_MIME_TYPE** - Return the MIME type
+ * **MAGIC\_CONTINUE** - Return all matches (returned as an array of strings)
+ * **MAGIC\_CHECK** - Print warnings to stderr
+ * **MAGIC\_PRESERVE\_ATIME** - Restore access time on exit
+ * **MAGIC\_RAW** - Don't translate unprintable chars
+ * **MAGIC\_MIME\_ENCODING** - Return the MIME encoding
+ * **MAGIC\_MIME** - (**MAGIC\_MIME\_TYPE** | **MAGIC\_MIME\_ENCODING**)
+ * **MAGIC\_APPLE** - Return the Apple creator and type
+ * **MAGIC\_NO\_CHECK\_TAR** - Don't check for tar files
+ * **MAGIC\_NO\_CHECK\_SOFT** - Don't check magic entries
+ * **MAGIC\_NO\_CHECK\_APPTYPE** - Don't check application type
+ * **MAGIC\_NO\_CHECK\_ELF** - Don't check for elf details
+ * **MAGIC\_NO\_CHECK\_TEXT** - Don't check for text files
+ * **MAGIC\_NO\_CHECK\_CDF** - Don't check for cdf files
+ * **MAGIC\_NO\_CHECK\_TOKENS** - Don't check tokens
+ * **MAGIC\_NO\_CHECK\_ENCODING** - Don't check text encodings
+
+* **detectFile**(< _String_ >path, < _Function_ >callback) - _(void)_ - Inspects the file pointed at by path. The callback receives two arguments: an < _Error_ > object in case of error (null otherwise), and a < _String_ > containing the result of the inspection.
+
+* **detect**(< _Buffer_ >data, < _Function_ >callback) - _(void)_ - Inspects the contents of data. The callback receives two arguments: an < _Error_ > object in case of error (null otherwise), and a < _String_ > containing the result of the inspection.
diff --git a/node_modules/mmmagic/appveyor.yml b/node_modules/mmmagic/appveyor.yml
new file mode 100644
index 0000000..11761a3
--- /dev/null
+++ b/node_modules/mmmagic/appveyor.yml
@@ -0,0 +1,42 @@
+environment:
+ matrix:
+ - nodejs_version: "4"
+ APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
+ GYP_MSVS_VERSION: "2013"
+ - nodejs_version: "4"
+ APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
+ GYP_MSVS_VERSION: "2015"
+ - nodejs_version: "6"
+ APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
+ GYP_MSVS_VERSION: "2013"
+ - nodejs_version: "6"
+ APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
+ GYP_MSVS_VERSION: "2015"
+ - nodejs_version: "8"
+ APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
+ GYP_MSVS_VERSION: "2013"
+ - nodejs_version: "8"
+ APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
+ GYP_MSVS_VERSION: "2015"
+ - nodejs_version: "10"
+ APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
+ GYP_MSVS_VERSION: "2015"
+ - nodejs_version: "12"
+ APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
+ GYP_MSVS_VERSION: "2017"
+
+
+install:
+ - ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version) x64
+ - set CL=-DDELAYIMP_INSECURE_WRITABLE_HOOKS
+ - npm install
+
+test_script:
+ - echo %APPVEYOR_BUILD_WORKER_IMAGE%
+ - node --version
+ - npm --version
+ - npm test
+
+build: off
+shallow_clone: true
+version: "{build}"
diff --git a/node_modules/mmmagic/binding.gyp b/node_modules/mmmagic/binding.gyp
new file mode 100644
index 0000000..8280a81
--- /dev/null
+++ b/node_modules/mmmagic/binding.gyp
@@ -0,0 +1,33 @@
+{
+ 'targets': [
+ {
+ 'target_name': 'magic',
+ 'sources': [
+ 'src/binding.cc',
+ ],
+ 'include_dirs': [
+ 'deps/libmagic/src',
+ "<!(node -e \"require('nan')\")"
+ ],
+ 'cflags!': [ '-O2' ],
+ 'cflags+': [ '-O3' ],
+ 'cflags_cc!': [ '-O2' ],
+ 'cflags_cc+': [ '-O3' ],
+ 'cflags_c!': [ '-O2' ],
+ 'cflags_c+': [ '-O3' ],
+ 'dependencies': [
+ 'deps/libmagic/libmagic.gyp:libmagic',
+ ],
+ 'conditions': [
+ ['OS=="mac"', {
+ 'xcode_settings': {
+ 'MACOSX_DEPLOYMENT_TARGET': '10.7',
+ 'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
+ 'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++1y', # -std=gnu++1y
+ 'CLANG_CXX_LIBRARY': 'libc++',
+ }
+ }],
+ ],
+ },
+ ],
+}
diff --git a/node_modules/mmmagic/build/Makefile b/node_modules/mmmagic/build/Makefile
new file mode 100644
index 0000000..80ade31
--- /dev/null
+++ b/node_modules/mmmagic/build/Makefile
@@ -0,0 +1,347 @@
+# We borrow heavily from the kernel build setup, though we are simpler since
+# we don't have Kconfig tweaking settings on us.
+
+# The implicit make rules have it looking for RCS files, among other things.
+# We instead explicitly write all the rules we care about.
+# It's even quicker (saves ~200ms) to pass -r on the command line.
+MAKEFLAGS=-r
+
+# The source directory tree.
+srcdir := ..
+abs_srcdir := $(abspath $(srcdir))
+
+# The name of the builddir.
+builddir_name ?= .
+
+# The V=1 flag on command line makes us verbosely print command lines.
+ifdef V
+ quiet=
+else
+ quiet=quiet_
+endif
+
+# Specify BUILDTYPE=Release on the command line for a release build.
+BUILDTYPE ?= Release
+
+# Directory all our build output goes into.
+# Note that this must be two directories beneath src/ for unit tests to pass,
+# as they reach into the src/ directory for data with relative paths.
+builddir ?= $(builddir_name)/$(BUILDTYPE)
+abs_builddir := $(abspath $(builddir))
+depsdir := $(builddir)/.deps
+
+# Object output directory.
+obj := $(builddir)/obj
+abs_obj := $(abspath $(obj))
+
+# We build up a list of every single one of the targets so we can slurp in the
+# generated dependency rule Makefiles in one pass.
+all_deps :=
+
+
+
+CC.target ?= $(CC)
+CFLAGS.target ?= $(CPPFLAGS) $(CFLAGS)
+CXX.target ?= $(CXX)
+CXXFLAGS.target ?= $(CPPFLAGS) $(CXXFLAGS)
+LINK.target ?= $(LINK)
+LDFLAGS.target ?= $(LDFLAGS)
+AR.target ?= $(AR)
+
+# C++ apps need to be linked with g++.
+LINK ?= $(CXX.target)
+
+# TODO(evan): move all cross-compilation logic to gyp-time so we don't need
+# to replicate this environment fallback in make as well.
+CC.host ?= gcc
+CFLAGS.host ?= $(CPPFLAGS_host) $(CFLAGS_host)
+CXX.host ?= g++
+CXXFLAGS.host ?= $(CPPFLAGS_host) $(CXXFLAGS_host)
+LINK.host ?= $(CXX.host)
+LDFLAGS.host ?= $(LDFLAGS_host)
+AR.host ?= ar
+
+# Define a dir function that can handle spaces.
+# http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions
+# "leading spaces cannot appear in the text of the first argument as written.
+# These characters can be put into the argument value by variable substitution."
+empty :=
+space := $(empty) $(empty)
+
+# http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces
+replace_spaces = $(subst $(space),?,$1)
+unreplace_spaces = $(subst ?,$(space),$1)
+dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1)))
+
+# Flags to make gcc output dependency info. Note that you need to be
+# careful here to use the flags that ccache and distcc can understand.
+# We write to a dep file on the side first and then rename at the end
+# so we can't end up with a broken dep file.
+depfile = $(depsdir)/$(call replace_spaces,$@).d
+DEPFLAGS = -MMD -MF $(depfile).raw
+
+# We have to fixup the deps output in a few ways.
+# (1) the file output should mention the proper .o file.
+# ccache or distcc lose the path to the target, so we convert a rule of
+# the form:
+# foobar.o: DEP1 DEP2
+# into
+# path/to/foobar.o: DEP1 DEP2
+# (2) we want missing files not to cause us to fail to build.
+# We want to rewrite
+# foobar.o: DEP1 DEP2 \
+# DEP3
+# to
+# DEP1:
+# DEP2:
+# DEP3:
+# so if the files are missing, they're just considered phony rules.
+# We have to do some pretty insane escaping to get those backslashes
+# and dollar signs past make, the shell, and sed at the same time.
+# Doesn't work with spaces, but that's fine: .d files have spaces in
+# their names replaced with other characters.
+define fixup_dep
+# The depfile may not exist if the input file didn't have any #includes.
+touch $(depfile).raw
+# Fixup path as in (1).
+sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile)
+# Add extra rules as in (2).
+# We remove slashes and replace spaces with new lines;
+# remove blank lines;
+# delete the first line and append a colon to the remaining lines.
+sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\
+ grep -v '^$$' |\
+ sed -e 1d -e 's|$$|:|' \
+ >> $(depfile)
+rm $(depfile).raw
+endef
+
+# Command definitions:
+# - cmd_foo is the actual command to run;
+# - quiet_cmd_foo is the brief-output summary of the command.
+
+quiet_cmd_cc = CC($(TOOLSET)) $@
+cmd_cc = $(CC.$(TOOLSET)) -o $@ $< $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c
+
+quiet_cmd_cxx = CXX($(TOOLSET)) $@
+cmd_cxx = $(CXX.$(TOOLSET)) -o $@ $< $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c
+
+quiet_cmd_objc = CXX($(TOOLSET)) $@
+cmd_objc = $(CC.$(TOOLSET)) $(GYP_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $<
+
+quiet_cmd_objcxx = CXX($(TOOLSET)) $@
+cmd_objcxx = $(CXX.$(TOOLSET)) $(GYP_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $<
+
+# Commands for precompiled header files.
+quiet_cmd_pch_c = CXX($(TOOLSET)) $@
+cmd_pch_c = $(CC.$(TOOLSET)) $(GYP_PCH_CFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $<
+quiet_cmd_pch_cc = CXX($(TOOLSET)) $@
+cmd_pch_cc = $(CC.$(TOOLSET)) $(GYP_PCH_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $<
+quiet_cmd_pch_m = CXX($(TOOLSET)) $@
+cmd_pch_m = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $<
+quiet_cmd_pch_mm = CXX($(TOOLSET)) $@
+cmd_pch_mm = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $<
+
+# gyp-mac-tool is written next to the root Makefile by gyp.
+# Use $(4) for the command, since $(2) and $(3) are used as flag by do_cmd
+# already.
+quiet_cmd_mac_tool = MACTOOL $(4) $<
+cmd_mac_tool = ./gyp-mac-tool $(4) $< "$@"
+
+quiet_cmd_mac_package_framework = PACKAGE FRAMEWORK $@
+cmd_mac_package_framework = ./gyp-mac-tool package-framework "$@" $(4)
+
+quiet_cmd_infoplist = INFOPLIST $@
+cmd_infoplist = $(CC.$(TOOLSET)) -E -P -Wno-trigraphs -x c $(INFOPLIST_DEFINES) "$<" -o "$@"
+
+quiet_cmd_touch = TOUCH $@
+cmd_touch = touch $@
+
+quiet_cmd_copy = COPY $@
+# send stderr to /dev/null to ignore messages when linking directories.
+cmd_copy = ln -f "$<" "$@" 2>/dev/null || (rm -rf "$@" && cp -af "$<" "$@")
+
+quiet_cmd_alink = LIBTOOL-STATIC $@
+cmd_alink = rm -f $@ && ./gyp-mac-tool filter-libtool libtool $(GYP_LIBTOOLFLAGS) -static -o $@ $(filter %.o,$^)
+
+quiet_cmd_link = LINK($(TOOLSET)) $@
+cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS)
+
+quiet_cmd_solink = SOLINK($(TOOLSET)) $@
+cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS)
+
+quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
+cmd_solink_module = $(LINK.$(TOOLSET)) -bundle $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS)
+
+
+# Define an escape_quotes function to escape single quotes.
+# This allows us to handle quotes properly as long as we always use
+# use single quotes and escape_quotes.
+escape_quotes = $(subst ','\'',$(1))
+# This comment is here just to include a ' to unconfuse syntax highlighting.
+# Define an escape_vars function to escape '$' variable syntax.
+# This allows us to read/write command lines with shell variables (e.g.
+# $LD_LIBRARY_PATH), without triggering make substitution.
+escape_vars = $(subst $$,$$$$,$(1))
+# Helper that expands to a shell command to echo a string exactly as it is in
+# make. This uses printf instead of echo because printf's behaviour with respect
+# to escape sequences is more portable than echo's across different shells
+# (e.g., dash, bash).
+exact_echo = printf '%s\n' '$(call escape_quotes,$(1))'
+
+# Helper to compare the command we're about to run against the command
+# we logged the last time we ran the command. Produces an empty
+# string (false) when the commands match.
+# Tricky point: Make has no string-equality test function.
+# The kernel uses the following, but it seems like it would have false
+# positives, where one string reordered its arguments.
+# arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \
+# $(filter-out $(cmd_$@), $(cmd_$(1))))
+# We instead substitute each for the empty string into the other, and
+# say they're equal if both substitutions produce the empty string.
+# .d files contain ? instead of spaces, take that into account.
+command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\
+ $(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1))))
+
+# Helper that is non-empty when a prerequisite changes.
+# Normally make does this implicitly, but we force rules to always run
+# so we can check their command lines.
+# $? -- new prerequisites
+# $| -- order-only dependencies
+prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?))
+
+# Helper that executes all postbuilds until one fails.
+define do_postbuilds
+ @E=0;\
+ for p in $(POSTBUILDS); do\
+ eval $$p;\
+ E=$$?;\
+ if [ $$E -ne 0 ]; then\
+ break;\
+ fi;\
+ done;\
+ if [ $$E -ne 0 ]; then\
+ rm -rf "$@";\
+ exit $$E;\
+ fi
+endef
+
+# do_cmd: run a command via the above cmd_foo names, if necessary.
+# Should always run for a given target to handle command-line changes.
+# Second argument, if non-zero, makes it do asm/C/C++ dependency munging.
+# Third argument, if non-zero, makes it do POSTBUILDS processing.
+# Note: We intentionally do NOT call dirx for depfile, since it contains ? for
+# spaces already and dirx strips the ? characters.
+define do_cmd
+$(if $(or $(command_changed),$(prereq_changed)),
+ @$(call exact_echo, $($(quiet)cmd_$(1)))
+ @mkdir -p "$(call dirx,$@)" "$(dir $(depfile))"
+ $(if $(findstring flock,$(word 2,$(cmd_$1))),
+ @$(cmd_$(1))
+ @echo " $(quiet_cmd_$(1)): Finished",
+ @$(cmd_$(1))
+ )
+ @$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile)
+ @$(if $(2),$(fixup_dep))
+ $(if $(and $(3), $(POSTBUILDS)),
+ $(call do_postbuilds)
+ )
+)
+endef
+
+# Declare the "all" target first so it is the default,
+# even though we don't have the deps yet.
+.PHONY: all
+all:
+
+# make looks for ways to re-generate included makefiles, but in our case, we
+# don't have a direct way. Explicitly telling make that it has nothing to do
+# for them makes it go faster.
+%.d: ;
+
+# Use FORCE_DO_CMD to force a target to run. Should be coupled with
+# do_cmd.
+.PHONY: FORCE_DO_CMD
+FORCE_DO_CMD:
+
+TOOLSET := target
+# Suffix rules, putting all outputs into $(obj).
+$(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD
+ @$(call do_cmd,cc,1)
+$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD
+ @$(call do_cmd,cxx,1)
+$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD
+ @$(call do_cmd,cxx,1)
+$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cxx FORCE_DO_CMD
+ @$(call do_cmd,cxx,1)
+$(obj).$(TOOLSET)/%.o: $(srcdir)/%.m FORCE_DO_CMD
+ @$(call do_cmd,objc,1)
+$(obj).$(TOOLSET)/%.o: $(srcdir)/%.mm FORCE_DO_CMD
+ @$(call do_cmd,objcxx,1)
+$(obj).$(TOOLSET)/%.o: $(srcdir)/%.s FORCE_DO_CMD
+ @$(call do_cmd,cc,1)
+$(obj).$(TOOLSET)/%.o: $(srcdir)/%.S FORCE_DO_CMD
+ @$(call do_cmd,cc,1)
+
+# Try building from generated source, too.
+$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD
+ @$(call do_cmd,cc,1)
+$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD
+ @$(call do_cmd,cxx,1)
+$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD
+ @$(call do_cmd,cxx,1)
+$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cxx FORCE_DO_CMD
+ @$(call do_cmd,cxx,1)
+$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.m FORCE_DO_CMD
+ @$(call do_cmd,objc,1)
+$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.mm FORCE_DO_CMD
+ @$(call do_cmd,objcxx,1)
+$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.s FORCE_DO_CMD
+ @$(call do_cmd,cc,1)
+$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.S FORCE_DO_CMD
+ @$(call do_cmd,cc,1)
+
+$(obj).$(TOOLSET)/%.o: $(obj)/%.c FORCE_DO_CMD
+ @$(call do_cmd,cc,1)
+$(obj).$(TOOLSET)/%.o: $(obj)/%.cc FORCE_DO_CMD
+ @$(call do_cmd,cxx,1)
+$(obj).$(TOOLSET)/%.o: $(obj)/%.cpp FORCE_DO_CMD
+ @$(call do_cmd,cxx,1)
+$(obj).$(TOOLSET)/%.o: $(obj)/%.cxx FORCE_DO_CMD
+ @$(call do_cmd,cxx,1)
+$(obj).$(TOOLSET)/%.o: $(obj)/%.m FORCE_DO_CMD
+ @$(call do_cmd,objc,1)
+$(obj).$(TOOLSET)/%.o: $(obj)/%.mm FORCE_DO_CMD
+ @$(call do_cmd,objcxx,1)
+$(obj).$(TOOLSET)/%.o: $(obj)/%.s FORCE_DO_CMD
+ @$(call do_cmd,cc,1)
+$(obj).$(TOOLSET)/%.o: $(obj)/%.S FORCE_DO_CMD
+ @$(call do_cmd,cc,1)
+
+
+ifeq ($(strip $(foreach prefix,$(NO_LOAD),\
+ $(findstring $(join ^,$(prefix)),\
+ $(join ^,deps/libmagic/libmagic.target.mk)))),)
+ include deps/libmagic/libmagic.target.mk
+endif
+ifeq ($(strip $(foreach prefix,$(NO_LOAD),\
+ $(findstring $(join ^,$(prefix)),\
+ $(join ^,magic.target.mk)))),)
+ include magic.target.mk
+endif
+
+quiet_cmd_regen_makefile = ACTION Regenerating $@
+cmd_regen_makefile = cd $(srcdir); /usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py -fmake --ignore-environment "-Dlibrary=shared_library" "-Dvisibility=default" "-Dnode_root_dir=/Users/minteck/Library/Caches/node-gyp/17.5.0" "-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp" "-Dnode_lib_file=/Users/minteck/Library/Caches/node-gyp/17.5.0/<(target_arch)/node.lib" "-Dmodule_root_dir=/Users/minteck/Code/ArgonCDN/node_modules/mmmagic" "-Dnode_engine=v8" "--depth=." "-Goutput_dir=." "--generator-output=build" -I/Users/minteck/Code/ArgonCDN/node_modules/mmmagic/build/config.gypi -I/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi -I/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/common.gypi "--toplevel-dir=." binding.gyp
+Makefile: $(srcdir)/deps/libmagic/libmagic.gyp $(srcdir)/build/config.gypi $(srcdir)/binding.gyp $(srcdir)/../../../../Library/Caches/node-gyp/17.5.0/include/node/common.gypi $(srcdir)/../../../../../../usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi
+ $(call do_cmd,regen_makefile)
+
+# "all" is a concatenation of the "all" targets from all the included
+# sub-makefiles. This is just here to clarify.
+all:
+
+# Add in dependency-tracking rules. $(all_deps) is the list of every single
+# target in our tree. Only consider the ones with .d (dependency) info:
+d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d))
+ifneq ($(d_files),)
+ include $(d_files)
+endif
diff --git a/node_modules/mmmagic/build/Release/.deps/Release/magic.a.d b/node_modules/mmmagic/build/Release/.deps/Release/magic.a.d
new file mode 100644
index 0000000..98d0b65
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/.deps/Release/magic.a.d
@@ -0,0 +1 @@
+cmd_Release/magic.a := rm -f Release/magic.a && ./gyp-mac-tool filter-libtool libtool -static -o Release/magic.a Release/obj.target/libmagic/deps/libmagic/src/apprentice.o Release/obj.target/libmagic/deps/libmagic/src/apptype.o Release/obj.target/libmagic/deps/libmagic/src/ascmagic.o Release/obj.target/libmagic/deps/libmagic/src/cdf.o Release/obj.target/libmagic/deps/libmagic/src/cdf_time.o Release/obj.target/libmagic/deps/libmagic/src/compress.o Release/obj.target/libmagic/deps/libmagic/src/der.o Release/obj.target/libmagic/deps/libmagic/src/encoding.o Release/obj.target/libmagic/deps/libmagic/src/fsmagic.o Release/obj.target/libmagic/deps/libmagic/src/funcs.o Release/obj.target/libmagic/deps/libmagic/src/is_tar.o Release/obj.target/libmagic/deps/libmagic/src/magic.o Release/obj.target/libmagic/deps/libmagic/src/print.o Release/obj.target/libmagic/deps/libmagic/src/readcdf.o Release/obj.target/libmagic/deps/libmagic/src/readelf.o Release/obj.target/libmagic/deps/libmagic/src/softmagic.o
diff --git a/node_modules/mmmagic/build/Release/.deps/Release/magic.node.d b/node_modules/mmmagic/build/Release/.deps/Release/magic.node.d
new file mode 100644
index 0000000..0258db2
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/.deps/Release/magic.node.d
@@ -0,0 +1 @@
+cmd_Release/magic.node := c++ -bundle -undefined dynamic_lookup -Wl,-search_paths_first -mmacosx-version-min=10.7 -arch arm64 -L./Release -stdlib=libc++ -o Release/magic.node Release/obj.target/magic/src/binding.o Release/magic.a
diff --git a/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/apprentice.o.d b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/apprentice.o.d
new file mode 100644
index 0000000..e20733f
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/apprentice.o.d
@@ -0,0 +1,8 @@
+cmd_Release/obj.target/libmagic/deps/libmagic/src/apprentice.o := cc -o Release/obj.target/libmagic/deps/libmagic/src/apprentice.o ../deps/libmagic/src/apprentice.c '-DNODE_GYP_MODULE_NAME=libmagic' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DHAVE_CONFIG_H' '-DVERSION="5.32"' -I/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node -I/Users/minteck/Library/Caches/node-gyp/17.5.0/src -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/config -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/openssl/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/uv/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/zlib -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/v8/include -I../deps/libmagic -I../deps/libmagic/src -I../deps/libmagic/config/mac -O3 -gdwarf-2 -mmacosx-version-min=10.13 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -fno-strict-aliasing -MMD -MF ./Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/apprentice.o.d.raw -c
+Release/obj.target/libmagic/deps/libmagic/src/apprentice.o: \
+ ../deps/libmagic/src/apprentice.c ../deps/libmagic/src/file.h \
+ ../deps/libmagic/config/mac/config.h ../deps/libmagic/src/magic.h
+../deps/libmagic/src/apprentice.c:
+../deps/libmagic/src/file.h:
+../deps/libmagic/config/mac/config.h:
+../deps/libmagic/src/magic.h:
diff --git a/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/apptype.o.d b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/apptype.o.d
new file mode 100644
index 0000000..9195b38
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/apptype.o.d
@@ -0,0 +1,7 @@
+cmd_Release/obj.target/libmagic/deps/libmagic/src/apptype.o := cc -o Release/obj.target/libmagic/deps/libmagic/src/apptype.o ../deps/libmagic/src/apptype.c '-DNODE_GYP_MODULE_NAME=libmagic' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DHAVE_CONFIG_H' '-DVERSION="5.32"' -I/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node -I/Users/minteck/Library/Caches/node-gyp/17.5.0/src -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/config -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/openssl/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/uv/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/zlib -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/v8/include -I../deps/libmagic -I../deps/libmagic/src -I../deps/libmagic/config/mac -O3 -gdwarf-2 -mmacosx-version-min=10.13 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -fno-strict-aliasing -MMD -MF ./Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/apptype.o.d.raw -c
+Release/obj.target/libmagic/deps/libmagic/src/apptype.o: \
+ ../deps/libmagic/src/apptype.c ../deps/libmagic/src/file.h \
+ ../deps/libmagic/config/mac/config.h
+../deps/libmagic/src/apptype.c:
+../deps/libmagic/src/file.h:
+../deps/libmagic/config/mac/config.h:
diff --git a/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/ascmagic.o.d b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/ascmagic.o.d
new file mode 100644
index 0000000..90016d4
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/ascmagic.o.d
@@ -0,0 +1,8 @@
+cmd_Release/obj.target/libmagic/deps/libmagic/src/ascmagic.o := cc -o Release/obj.target/libmagic/deps/libmagic/src/ascmagic.o ../deps/libmagic/src/ascmagic.c '-DNODE_GYP_MODULE_NAME=libmagic' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DHAVE_CONFIG_H' '-DVERSION="5.32"' -I/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node -I/Users/minteck/Library/Caches/node-gyp/17.5.0/src -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/config -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/openssl/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/uv/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/zlib -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/v8/include -I../deps/libmagic -I../deps/libmagic/src -I../deps/libmagic/config/mac -O3 -gdwarf-2 -mmacosx-version-min=10.13 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -fno-strict-aliasing -MMD -MF ./Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/ascmagic.o.d.raw -c
+Release/obj.target/libmagic/deps/libmagic/src/ascmagic.o: \
+ ../deps/libmagic/src/ascmagic.c ../deps/libmagic/src/file.h \
+ ../deps/libmagic/config/mac/config.h ../deps/libmagic/src/magic.h
+../deps/libmagic/src/ascmagic.c:
+../deps/libmagic/src/file.h:
+../deps/libmagic/config/mac/config.h:
+../deps/libmagic/src/magic.h:
diff --git a/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/cdf.o.d b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/cdf.o.d
new file mode 100644
index 0000000..c014679
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/cdf.o.d
@@ -0,0 +1,8 @@
+cmd_Release/obj.target/libmagic/deps/libmagic/src/cdf.o := cc -o Release/obj.target/libmagic/deps/libmagic/src/cdf.o ../deps/libmagic/src/cdf.c '-DNODE_GYP_MODULE_NAME=libmagic' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DHAVE_CONFIG_H' '-DVERSION="5.32"' -I/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node -I/Users/minteck/Library/Caches/node-gyp/17.5.0/src -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/config -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/openssl/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/uv/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/zlib -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/v8/include -I../deps/libmagic -I../deps/libmagic/src -I../deps/libmagic/config/mac -O3 -gdwarf-2 -mmacosx-version-min=10.13 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -fno-strict-aliasing -MMD -MF ./Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/cdf.o.d.raw -c
+Release/obj.target/libmagic/deps/libmagic/src/cdf.o: \
+ ../deps/libmagic/src/cdf.c ../deps/libmagic/src/file.h \
+ ../deps/libmagic/config/mac/config.h ../deps/libmagic/src/cdf.h
+../deps/libmagic/src/cdf.c:
+../deps/libmagic/src/file.h:
+../deps/libmagic/config/mac/config.h:
+../deps/libmagic/src/cdf.h:
diff --git a/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/cdf_time.o.d b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/cdf_time.o.d
new file mode 100644
index 0000000..7effba7
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/cdf_time.o.d
@@ -0,0 +1,8 @@
+cmd_Release/obj.target/libmagic/deps/libmagic/src/cdf_time.o := cc -o Release/obj.target/libmagic/deps/libmagic/src/cdf_time.o ../deps/libmagic/src/cdf_time.c '-DNODE_GYP_MODULE_NAME=libmagic' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DHAVE_CONFIG_H' '-DVERSION="5.32"' -I/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node -I/Users/minteck/Library/Caches/node-gyp/17.5.0/src -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/config -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/openssl/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/uv/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/zlib -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/v8/include -I../deps/libmagic -I../deps/libmagic/src -I../deps/libmagic/config/mac -O3 -gdwarf-2 -mmacosx-version-min=10.13 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -fno-strict-aliasing -MMD -MF ./Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/cdf_time.o.d.raw -c
+Release/obj.target/libmagic/deps/libmagic/src/cdf_time.o: \
+ ../deps/libmagic/src/cdf_time.c ../deps/libmagic/src/file.h \
+ ../deps/libmagic/config/mac/config.h ../deps/libmagic/src/cdf.h
+../deps/libmagic/src/cdf_time.c:
+../deps/libmagic/src/file.h:
+../deps/libmagic/config/mac/config.h:
+../deps/libmagic/src/cdf.h:
diff --git a/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/compress.o.d b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/compress.o.d
new file mode 100644
index 0000000..606229c
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/compress.o.d
@@ -0,0 +1,8 @@
+cmd_Release/obj.target/libmagic/deps/libmagic/src/compress.o := cc -o Release/obj.target/libmagic/deps/libmagic/src/compress.o ../deps/libmagic/src/compress.c '-DNODE_GYP_MODULE_NAME=libmagic' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DHAVE_CONFIG_H' '-DVERSION="5.32"' -I/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node -I/Users/minteck/Library/Caches/node-gyp/17.5.0/src -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/config -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/openssl/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/uv/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/zlib -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/v8/include -I../deps/libmagic -I../deps/libmagic/src -I../deps/libmagic/config/mac -O3 -gdwarf-2 -mmacosx-version-min=10.13 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -fno-strict-aliasing -MMD -MF ./Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/compress.o.d.raw -c
+Release/obj.target/libmagic/deps/libmagic/src/compress.o: \
+ ../deps/libmagic/src/compress.c ../deps/libmagic/src/file.h \
+ ../deps/libmagic/config/mac/config.h ../deps/libmagic/src/magic.h
+../deps/libmagic/src/compress.c:
+../deps/libmagic/src/file.h:
+../deps/libmagic/config/mac/config.h:
+../deps/libmagic/src/magic.h:
diff --git a/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/der.o.d b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/der.o.d
new file mode 100644
index 0000000..52c2500
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/der.o.d
@@ -0,0 +1,10 @@
+cmd_Release/obj.target/libmagic/deps/libmagic/src/der.o := cc -o Release/obj.target/libmagic/deps/libmagic/src/der.o ../deps/libmagic/src/der.c '-DNODE_GYP_MODULE_NAME=libmagic' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DHAVE_CONFIG_H' '-DVERSION="5.32"' -I/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node -I/Users/minteck/Library/Caches/node-gyp/17.5.0/src -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/config -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/openssl/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/uv/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/zlib -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/v8/include -I../deps/libmagic -I../deps/libmagic/src -I../deps/libmagic/config/mac -O3 -gdwarf-2 -mmacosx-version-min=10.13 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -fno-strict-aliasing -MMD -MF ./Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/der.o.d.raw -c
+Release/obj.target/libmagic/deps/libmagic/src/der.o: \
+ ../deps/libmagic/src/der.c ../deps/libmagic/src/file.h \
+ ../deps/libmagic/config/mac/config.h ../deps/libmagic/src/magic.h \
+ ../deps/libmagic/src/der.h
+../deps/libmagic/src/der.c:
+../deps/libmagic/src/file.h:
+../deps/libmagic/config/mac/config.h:
+../deps/libmagic/src/magic.h:
+../deps/libmagic/src/der.h:
diff --git a/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/encoding.o.d b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/encoding.o.d
new file mode 100644
index 0000000..8470b57
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/encoding.o.d
@@ -0,0 +1,8 @@
+cmd_Release/obj.target/libmagic/deps/libmagic/src/encoding.o := cc -o Release/obj.target/libmagic/deps/libmagic/src/encoding.o ../deps/libmagic/src/encoding.c '-DNODE_GYP_MODULE_NAME=libmagic' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DHAVE_CONFIG_H' '-DVERSION="5.32"' -I/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node -I/Users/minteck/Library/Caches/node-gyp/17.5.0/src -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/config -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/openssl/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/uv/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/zlib -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/v8/include -I../deps/libmagic -I../deps/libmagic/src -I../deps/libmagic/config/mac -O3 -gdwarf-2 -mmacosx-version-min=10.13 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -fno-strict-aliasing -MMD -MF ./Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/encoding.o.d.raw -c
+Release/obj.target/libmagic/deps/libmagic/src/encoding.o: \
+ ../deps/libmagic/src/encoding.c ../deps/libmagic/src/file.h \
+ ../deps/libmagic/config/mac/config.h ../deps/libmagic/src/magic.h
+../deps/libmagic/src/encoding.c:
+../deps/libmagic/src/file.h:
+../deps/libmagic/config/mac/config.h:
+../deps/libmagic/src/magic.h:
diff --git a/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/fsmagic.o.d b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/fsmagic.o.d
new file mode 100644
index 0000000..1ec58d0
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/fsmagic.o.d
@@ -0,0 +1,8 @@
+cmd_Release/obj.target/libmagic/deps/libmagic/src/fsmagic.o := cc -o Release/obj.target/libmagic/deps/libmagic/src/fsmagic.o ../deps/libmagic/src/fsmagic.c '-DNODE_GYP_MODULE_NAME=libmagic' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DHAVE_CONFIG_H' '-DVERSION="5.32"' -I/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node -I/Users/minteck/Library/Caches/node-gyp/17.5.0/src -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/config -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/openssl/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/uv/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/zlib -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/v8/include -I../deps/libmagic -I../deps/libmagic/src -I../deps/libmagic/config/mac -O3 -gdwarf-2 -mmacosx-version-min=10.13 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -fno-strict-aliasing -MMD -MF ./Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/fsmagic.o.d.raw -c
+Release/obj.target/libmagic/deps/libmagic/src/fsmagic.o: \
+ ../deps/libmagic/src/fsmagic.c ../deps/libmagic/src/file.h \
+ ../deps/libmagic/config/mac/config.h ../deps/libmagic/src/magic.h
+../deps/libmagic/src/fsmagic.c:
+../deps/libmagic/src/file.h:
+../deps/libmagic/config/mac/config.h:
+../deps/libmagic/src/magic.h:
diff --git a/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/funcs.o.d b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/funcs.o.d
new file mode 100644
index 0000000..c61a2f0
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/funcs.o.d
@@ -0,0 +1,8 @@
+cmd_Release/obj.target/libmagic/deps/libmagic/src/funcs.o := cc -o Release/obj.target/libmagic/deps/libmagic/src/funcs.o ../deps/libmagic/src/funcs.c '-DNODE_GYP_MODULE_NAME=libmagic' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DHAVE_CONFIG_H' '-DVERSION="5.32"' -I/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node -I/Users/minteck/Library/Caches/node-gyp/17.5.0/src -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/config -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/openssl/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/uv/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/zlib -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/v8/include -I../deps/libmagic -I../deps/libmagic/src -I../deps/libmagic/config/mac -O3 -gdwarf-2 -mmacosx-version-min=10.13 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -fno-strict-aliasing -MMD -MF ./Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/funcs.o.d.raw -c
+Release/obj.target/libmagic/deps/libmagic/src/funcs.o: \
+ ../deps/libmagic/src/funcs.c ../deps/libmagic/src/file.h \
+ ../deps/libmagic/config/mac/config.h ../deps/libmagic/src/magic.h
+../deps/libmagic/src/funcs.c:
+../deps/libmagic/src/file.h:
+../deps/libmagic/config/mac/config.h:
+../deps/libmagic/src/magic.h:
diff --git a/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/is_tar.o.d b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/is_tar.o.d
new file mode 100644
index 0000000..d971a8e
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/is_tar.o.d
@@ -0,0 +1,10 @@
+cmd_Release/obj.target/libmagic/deps/libmagic/src/is_tar.o := cc -o Release/obj.target/libmagic/deps/libmagic/src/is_tar.o ../deps/libmagic/src/is_tar.c '-DNODE_GYP_MODULE_NAME=libmagic' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DHAVE_CONFIG_H' '-DVERSION="5.32"' -I/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node -I/Users/minteck/Library/Caches/node-gyp/17.5.0/src -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/config -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/openssl/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/uv/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/zlib -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/v8/include -I../deps/libmagic -I../deps/libmagic/src -I../deps/libmagic/config/mac -O3 -gdwarf-2 -mmacosx-version-min=10.13 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -fno-strict-aliasing -MMD -MF ./Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/is_tar.o.d.raw -c
+Release/obj.target/libmagic/deps/libmagic/src/is_tar.o: \
+ ../deps/libmagic/src/is_tar.c ../deps/libmagic/src/file.h \
+ ../deps/libmagic/config/mac/config.h ../deps/libmagic/src/magic.h \
+ ../deps/libmagic/src/tar.h
+../deps/libmagic/src/is_tar.c:
+../deps/libmagic/src/file.h:
+../deps/libmagic/config/mac/config.h:
+../deps/libmagic/src/magic.h:
+../deps/libmagic/src/tar.h:
diff --git a/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/magic.o.d b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/magic.o.d
new file mode 100644
index 0000000..a8e43f7
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/magic.o.d
@@ -0,0 +1,8 @@
+cmd_Release/obj.target/libmagic/deps/libmagic/src/magic.o := cc -o Release/obj.target/libmagic/deps/libmagic/src/magic.o ../deps/libmagic/src/magic.c '-DNODE_GYP_MODULE_NAME=libmagic' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DHAVE_CONFIG_H' '-DVERSION="5.32"' -I/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node -I/Users/minteck/Library/Caches/node-gyp/17.5.0/src -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/config -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/openssl/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/uv/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/zlib -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/v8/include -I../deps/libmagic -I../deps/libmagic/src -I../deps/libmagic/config/mac -O3 -gdwarf-2 -mmacosx-version-min=10.13 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -fno-strict-aliasing -MMD -MF ./Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/magic.o.d.raw -c
+Release/obj.target/libmagic/deps/libmagic/src/magic.o: \
+ ../deps/libmagic/src/magic.c ../deps/libmagic/src/file.h \
+ ../deps/libmagic/config/mac/config.h ../deps/libmagic/src/magic.h
+../deps/libmagic/src/magic.c:
+../deps/libmagic/src/file.h:
+../deps/libmagic/config/mac/config.h:
+../deps/libmagic/src/magic.h:
diff --git a/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/print.o.d b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/print.o.d
new file mode 100644
index 0000000..ac0ab61
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/print.o.d
@@ -0,0 +1,8 @@
+cmd_Release/obj.target/libmagic/deps/libmagic/src/print.o := cc -o Release/obj.target/libmagic/deps/libmagic/src/print.o ../deps/libmagic/src/print.c '-DNODE_GYP_MODULE_NAME=libmagic' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DHAVE_CONFIG_H' '-DVERSION="5.32"' -I/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node -I/Users/minteck/Library/Caches/node-gyp/17.5.0/src -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/config -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/openssl/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/uv/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/zlib -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/v8/include -I../deps/libmagic -I../deps/libmagic/src -I../deps/libmagic/config/mac -O3 -gdwarf-2 -mmacosx-version-min=10.13 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -fno-strict-aliasing -MMD -MF ./Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/print.o.d.raw -c
+Release/obj.target/libmagic/deps/libmagic/src/print.o: \
+ ../deps/libmagic/src/print.c ../deps/libmagic/src/file.h \
+ ../deps/libmagic/config/mac/config.h ../deps/libmagic/src/cdf.h
+../deps/libmagic/src/print.c:
+../deps/libmagic/src/file.h:
+../deps/libmagic/config/mac/config.h:
+../deps/libmagic/src/cdf.h:
diff --git a/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/readcdf.o.d b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/readcdf.o.d
new file mode 100644
index 0000000..9a1b585
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/readcdf.o.d
@@ -0,0 +1,10 @@
+cmd_Release/obj.target/libmagic/deps/libmagic/src/readcdf.o := cc -o Release/obj.target/libmagic/deps/libmagic/src/readcdf.o ../deps/libmagic/src/readcdf.c '-DNODE_GYP_MODULE_NAME=libmagic' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DHAVE_CONFIG_H' '-DVERSION="5.32"' -I/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node -I/Users/minteck/Library/Caches/node-gyp/17.5.0/src -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/config -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/openssl/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/uv/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/zlib -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/v8/include -I../deps/libmagic -I../deps/libmagic/src -I../deps/libmagic/config/mac -O3 -gdwarf-2 -mmacosx-version-min=10.13 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -fno-strict-aliasing -MMD -MF ./Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/readcdf.o.d.raw -c
+Release/obj.target/libmagic/deps/libmagic/src/readcdf.o: \
+ ../deps/libmagic/src/readcdf.c ../deps/libmagic/src/file.h \
+ ../deps/libmagic/config/mac/config.h ../deps/libmagic/src/cdf.h \
+ ../deps/libmagic/src/magic.h
+../deps/libmagic/src/readcdf.c:
+../deps/libmagic/src/file.h:
+../deps/libmagic/config/mac/config.h:
+../deps/libmagic/src/cdf.h:
+../deps/libmagic/src/magic.h:
diff --git a/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/readelf.o.d b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/readelf.o.d
new file mode 100644
index 0000000..f09a4d8
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/readelf.o.d
@@ -0,0 +1,11 @@
+cmd_Release/obj.target/libmagic/deps/libmagic/src/readelf.o := cc -o Release/obj.target/libmagic/deps/libmagic/src/readelf.o ../deps/libmagic/src/readelf.c '-DNODE_GYP_MODULE_NAME=libmagic' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DHAVE_CONFIG_H' '-DVERSION="5.32"' -I/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node -I/Users/minteck/Library/Caches/node-gyp/17.5.0/src -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/config -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/openssl/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/uv/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/zlib -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/v8/include -I../deps/libmagic -I../deps/libmagic/src -I../deps/libmagic/config/mac -O3 -gdwarf-2 -mmacosx-version-min=10.13 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -fno-strict-aliasing -MMD -MF ./Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/readelf.o.d.raw -c
+Release/obj.target/libmagic/deps/libmagic/src/readelf.o: \
+ ../deps/libmagic/src/readelf.c ../deps/libmagic/src/file.h \
+ ../deps/libmagic/config/mac/config.h ../deps/libmagic/src/readelf.h \
+ ../deps/libmagic/src/magic.h ../deps/libmagic/src/elfclass.h
+../deps/libmagic/src/readelf.c:
+../deps/libmagic/src/file.h:
+../deps/libmagic/config/mac/config.h:
+../deps/libmagic/src/readelf.h:
+../deps/libmagic/src/magic.h:
+../deps/libmagic/src/elfclass.h:
diff --git a/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/softmagic.o.d b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/softmagic.o.d
new file mode 100644
index 0000000..0772a6f
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/softmagic.o.d
@@ -0,0 +1,10 @@
+cmd_Release/obj.target/libmagic/deps/libmagic/src/softmagic.o := cc -o Release/obj.target/libmagic/deps/libmagic/src/softmagic.o ../deps/libmagic/src/softmagic.c '-DNODE_GYP_MODULE_NAME=libmagic' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DHAVE_CONFIG_H' '-DVERSION="5.32"' -I/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node -I/Users/minteck/Library/Caches/node-gyp/17.5.0/src -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/config -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/openssl/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/uv/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/zlib -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/v8/include -I../deps/libmagic -I../deps/libmagic/src -I../deps/libmagic/config/mac -O3 -gdwarf-2 -mmacosx-version-min=10.13 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -fno-strict-aliasing -MMD -MF ./Release/.deps/Release/obj.target/libmagic/deps/libmagic/src/softmagic.o.d.raw -c
+Release/obj.target/libmagic/deps/libmagic/src/softmagic.o: \
+ ../deps/libmagic/src/softmagic.c ../deps/libmagic/src/file.h \
+ ../deps/libmagic/config/mac/config.h ../deps/libmagic/src/magic.h \
+ ../deps/libmagic/src/der.h
+../deps/libmagic/src/softmagic.c:
+../deps/libmagic/src/file.h:
+../deps/libmagic/config/mac/config.h:
+../deps/libmagic/src/magic.h:
+../deps/libmagic/src/der.h:
diff --git a/node_modules/mmmagic/build/Release/.deps/Release/obj.target/magic/src/binding.o.d b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/magic/src/binding.o.d
new file mode 100644
index 0000000..ad20d9f
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/.deps/Release/obj.target/magic/src/binding.o.d
@@ -0,0 +1,142 @@
+cmd_Release/obj.target/magic/src/binding.o := c++ -o Release/obj.target/magic/src/binding.o ../src/binding.cc '-DNODE_GYP_MODULE_NAME=magic' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DBUILDING_NODE_EXTENSION' -I/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node -I/Users/minteck/Library/Caches/node-gyp/17.5.0/src -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/config -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/openssl/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/uv/include -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/zlib -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/v8/include -I../deps/libmagic/src -I../../nan -O3 -gdwarf-2 -mmacosx-version-min=10.7 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -std=gnu++1y -stdlib=libc++ -fno-rtti -fno-exceptions -fno-strict-aliasing -MMD -MF ./Release/.deps/Release/obj.target/magic/src/binding.o.d.raw -c
+Release/obj.target/magic/src/binding.o: ../src/binding.cc \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/node.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/cppgc/common.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8config.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-array-buffer.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-local-handle.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-internal.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-version.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-object.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-maybe.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-persistent-handle.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-weak-callback-info.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-primitive.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-data.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-value.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-traced-handle.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-container.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-context.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-snapshot.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-date.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-debug.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-exception.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-extension.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-external.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-function.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-function-callback.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-message.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-template.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-memory-span.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-initialization.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-isolate.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-callbacks.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-embedder-heap.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-microtask.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-statistics.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-promise.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-unwinder.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-platform.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-json.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-locker.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-microtask-queue.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-primitive-object.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-proxy.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-regexp.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-script.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-typed-array.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-value-serializer.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-wasm.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/node_version.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/node_buffer.h \
+ ../../nan/nan.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/uv.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/uv/errno.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/uv/version.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/uv/unix.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/uv/threadpool.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/uv/darwin.h \
+ /Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/node_object_wrap.h \
+ ../../nan/nan_callbacks.h ../../nan/nan_callbacks_12_inl.h \
+ ../../nan/nan_maybe_43_inl.h ../../nan/nan_converters.h \
+ ../../nan/nan_converters_43_inl.h ../../nan/nan_new.h \
+ ../../nan/nan_implementation_12_inl.h \
+ ../../nan/nan_persistent_12_inl.h ../../nan/nan_weak.h \
+ ../../nan/nan_object_wrap.h ../../nan/nan_private.h \
+ ../../nan/nan_typedarray_contents.h ../../nan/nan_json.h \
+ ../../nan/nan_scriptorigin.h ../deps/libmagic/src/magic.h
+../src/binding.cc:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/node.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/cppgc/common.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8config.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-array-buffer.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-local-handle.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-internal.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-version.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-object.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-maybe.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-persistent-handle.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-weak-callback-info.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-primitive.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-data.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-value.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-traced-handle.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-container.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-context.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-snapshot.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-date.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-debug.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-exception.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-extension.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-external.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-function.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-function-callback.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-message.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-template.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-memory-span.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-initialization.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-isolate.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-callbacks.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-embedder-heap.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-microtask.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-statistics.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-promise.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-unwinder.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-platform.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-json.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-locker.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-microtask-queue.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-primitive-object.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-proxy.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-regexp.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-script.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-typed-array.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-value-serializer.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/v8-wasm.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/node_version.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/node_buffer.h:
+../../nan/nan.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/uv.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/uv/errno.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/uv/version.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/uv/unix.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/uv/threadpool.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/uv/darwin.h:
+/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node/node_object_wrap.h:
+../../nan/nan_callbacks.h:
+../../nan/nan_callbacks_12_inl.h:
+../../nan/nan_maybe_43_inl.h:
+../../nan/nan_converters.h:
+../../nan/nan_converters_43_inl.h:
+../../nan/nan_new.h:
+../../nan/nan_implementation_12_inl.h:
+../../nan/nan_persistent_12_inl.h:
+../../nan/nan_weak.h:
+../../nan/nan_object_wrap.h:
+../../nan/nan_private.h:
+../../nan/nan_typedarray_contents.h:
+../../nan/nan_json.h:
+../../nan/nan_scriptorigin.h:
+../deps/libmagic/src/magic.h:
diff --git a/node_modules/mmmagic/build/Release/magic.a b/node_modules/mmmagic/build/Release/magic.a
new file mode 100644
index 0000000..a998b0b
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/magic.a
Binary files differ
diff --git a/node_modules/mmmagic/build/Release/magic.node b/node_modules/mmmagic/build/Release/magic.node
new file mode 100755
index 0000000..d1bee8a
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/magic.node
Binary files differ
diff --git a/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/apprentice.o b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/apprentice.o
new file mode 100644
index 0000000..e7ac5be
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/apprentice.o
Binary files differ
diff --git a/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/apptype.o b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/apptype.o
new file mode 100644
index 0000000..a277fbb
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/apptype.o
Binary files differ
diff --git a/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/ascmagic.o b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/ascmagic.o
new file mode 100644
index 0000000..5678893
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/ascmagic.o
Binary files differ
diff --git a/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/cdf.o b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/cdf.o
new file mode 100644
index 0000000..e048fe0
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/cdf.o
Binary files differ
diff --git a/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/cdf_time.o b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/cdf_time.o
new file mode 100644
index 0000000..c24839b
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/cdf_time.o
Binary files differ
diff --git a/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/compress.o b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/compress.o
new file mode 100644
index 0000000..5162f86
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/compress.o
Binary files differ
diff --git a/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/der.o b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/der.o
new file mode 100644
index 0000000..8b58410
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/der.o
Binary files differ
diff --git a/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/encoding.o b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/encoding.o
new file mode 100644
index 0000000..de2f6d0
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/encoding.o
Binary files differ
diff --git a/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/fsmagic.o b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/fsmagic.o
new file mode 100644
index 0000000..7c5196c
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/fsmagic.o
Binary files differ
diff --git a/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/funcs.o b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/funcs.o
new file mode 100644
index 0000000..a30488b
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/funcs.o
Binary files differ
diff --git a/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/is_tar.o b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/is_tar.o
new file mode 100644
index 0000000..84967e6
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/is_tar.o
Binary files differ
diff --git a/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/magic.o b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/magic.o
new file mode 100644
index 0000000..82c27d1
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/magic.o
Binary files differ
diff --git a/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/print.o b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/print.o
new file mode 100644
index 0000000..a101126
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/print.o
Binary files differ
diff --git a/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/readcdf.o b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/readcdf.o
new file mode 100644
index 0000000..39a41e0
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/readcdf.o
Binary files differ
diff --git a/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/readelf.o b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/readelf.o
new file mode 100644
index 0000000..886ff4d
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/readelf.o
Binary files differ
diff --git a/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/softmagic.o b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/softmagic.o
new file mode 100644
index 0000000..f54a52c
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/obj.target/libmagic/deps/libmagic/src/softmagic.o
Binary files differ
diff --git a/node_modules/mmmagic/build/Release/obj.target/magic/src/binding.o b/node_modules/mmmagic/build/Release/obj.target/magic/src/binding.o
new file mode 100644
index 0000000..be0ab47
--- /dev/null
+++ b/node_modules/mmmagic/build/Release/obj.target/magic/src/binding.o
Binary files differ
diff --git a/node_modules/mmmagic/build/binding.Makefile b/node_modules/mmmagic/build/binding.Makefile
new file mode 100644
index 0000000..5a97753
--- /dev/null
+++ b/node_modules/mmmagic/build/binding.Makefile
@@ -0,0 +1,6 @@
+# This file is generated by gyp; do not edit.
+
+export builddir_name ?= ./build/.
+.PHONY: all
+all:
+ $(MAKE) magic
diff --git a/node_modules/mmmagic/build/config.gypi b/node_modules/mmmagic/build/config.gypi
new file mode 100644
index 0000000..afb4a9a
--- /dev/null
+++ b/node_modules/mmmagic/build/config.gypi
@@ -0,0 +1,372 @@
+# Do not edit. File was generated by node-gyp's "configure" step
+{
+ "target_defaults": {
+ "cflags": [],
+ "default_configuration": "Release",
+ "defines": [],
+ "include_dirs": [],
+ "libraries": [],
+ "msvs_configuration_platform": "ARM64",
+ "xcode_configuration_platform": "arm64"
+ },
+ "variables": {
+ "asan": 0,
+ "coverage": "false",
+ "dcheck_always_on": 0,
+ "debug_nghttp2": "false",
+ "debug_node": "false",
+ "enable_lto": "false",
+ "enable_pgo_generate": "false",
+ "enable_pgo_use": "false",
+ "error_on_warn": "false",
+ "force_dynamic_crt": 0,
+ "host_arch": "arm64",
+ "icu_data_in": "../../deps/icu-tmp/icudt70l.dat",
+ "icu_endianness": "l",
+ "icu_gyp_path": "tools/icu/icu-generic.gyp",
+ "icu_path": "deps/icu-small",
+ "icu_small": "false",
+ "icu_ver_major": "70",
+ "is_debug": 0,
+ "llvm_version": "12.0",
+ "napi_build_version": "8",
+ "node_byteorder": "little",
+ "node_debug_lib": "false",
+ "node_enable_d8": "false",
+ "node_fipsinstall": "false",
+ "node_install_corepack": "true",
+ "node_install_npm": "true",
+ "node_library_files": [
+ "lib/constants.js",
+ "lib/net.js",
+ "lib/trace_events.js",
+ "lib/events.js",
+ "lib/repl.js",
+ "lib/util.js",
+ "lib/dgram.js",
+ "lib/vm.js",
+ "lib/stream.js",
+ "lib/child_process.js",
+ "lib/assert.js",
+ "lib/_tls_wrap.js",
+ "lib/http2.js",
+ "lib/inspector.js",
+ "lib/os.js",
+ "lib/_http_server.js",
+ "lib/console.js",
+ "lib/perf_hooks.js",
+ "lib/readline.js",
+ "lib/punycode.js",
+ "lib/_http_incoming.js",
+ "lib/https.js",
+ "lib/_stream_wrap.js",
+ "lib/domain.js",
+ "lib/dns.js",
+ "lib/_http_client.js",
+ "lib/diagnostics_channel.js",
+ "lib/tty.js",
+ "lib/_http_agent.js",
+ "lib/timers.js",
+ "lib/_http_outgoing.js",
+ "lib/querystring.js",
+ "lib/_tls_common.js",
+ "lib/module.js",
+ "lib/_stream_passthrough.js",
+ "lib/_stream_transform.js",
+ "lib/worker_threads.js",
+ "lib/sys.js",
+ "lib/_stream_duplex.js",
+ "lib/path.js",
+ "lib/_http_common.js",
+ "lib/string_decoder.js",
+ "lib/cluster.js",
+ "lib/v8.js",
+ "lib/crypto.js",
+ "lib/wasi.js",
+ "lib/_stream_readable.js",
+ "lib/zlib.js",
+ "lib/url.js",
+ "lib/tls.js",
+ "lib/_stream_writable.js",
+ "lib/async_hooks.js",
+ "lib/process.js",
+ "lib/http.js",
+ "lib/buffer.js",
+ "lib/fs.js",
+ "lib/util/types.js",
+ "lib/timers/promises.js",
+ "lib/path/win32.js",
+ "lib/path/posix.js",
+ "lib/stream/consumers.js",
+ "lib/stream/promises.js",
+ "lib/stream/web.js",
+ "lib/readline/promises.js",
+ "lib/internal/constants.js",
+ "lib/internal/abort_controller.js",
+ "lib/internal/net.js",
+ "lib/internal/v8_prof_processor.js",
+ "lib/internal/event_target.js",
+ "lib/internal/inspector_async_hook.js",
+ "lib/internal/validators.js",
+ "lib/internal/linkedlist.js",
+ "lib/internal/cli_table.js",
+ "lib/internal/repl.js",
+ "lib/internal/util.js",
+ "lib/internal/histogram.js",
+ "lib/internal/error_serdes.js",
+ "lib/internal/dgram.js",
+ "lib/internal/structured_clone.js",
+ "lib/internal/child_process.js",
+ "lib/internal/assert.js",
+ "lib/internal/fixed_queue.js",
+ "lib/internal/blocklist.js",
+ "lib/internal/v8_prof_polyfill.js",
+ "lib/internal/options.js",
+ "lib/internal/worker.js",
+ "lib/internal/dtrace.js",
+ "lib/internal/idna.js",
+ "lib/internal/watchdog.js",
+ "lib/internal/encoding.js",
+ "lib/internal/tty.js",
+ "lib/internal/freeze_intrinsics.js",
+ "lib/internal/timers.js",
+ "lib/internal/heap_utils.js",
+ "lib/internal/querystring.js",
+ "lib/internal/js_stream_socket.js",
+ "lib/internal/errors.js",
+ "lib/internal/priority_queue.js",
+ "lib/internal/freelist.js",
+ "lib/internal/blob.js",
+ "lib/internal/socket_list.js",
+ "lib/internal/socketaddress.js",
+ "lib/internal/promise_hooks.js",
+ "lib/internal/stream_base_commons.js",
+ "lib/internal/url.js",
+ "lib/internal/async_hooks.js",
+ "lib/internal/http.js",
+ "lib/internal/buffer.js",
+ "lib/internal/trace_events_async_hooks.js",
+ "lib/internal/crypto/sig.js",
+ "lib/internal/crypto/rsa.js",
+ "lib/internal/crypto/aes.js",
+ "lib/internal/crypto/util.js",
+ "lib/internal/crypto/scrypt.js",
+ "lib/internal/crypto/random.js",
+ "lib/internal/crypto/keys.js",
+ "lib/internal/crypto/x509.js",
+ "lib/internal/crypto/certificate.js",
+ "lib/internal/crypto/ec.js",
+ "lib/internal/crypto/keygen.js",
+ "lib/internal/crypto/mac.js",
+ "lib/internal/crypto/diffiehellman.js",
+ "lib/internal/crypto/hkdf.js",
+ "lib/internal/crypto/cipher.js",
+ "lib/internal/crypto/hash.js",
+ "lib/internal/crypto/pbkdf2.js",
+ "lib/internal/crypto/webcrypto.js",
+ "lib/internal/crypto/dsa.js",
+ "lib/internal/crypto/hashnames.js",
+ "lib/internal/cluster/shared_handle.js",
+ "lib/internal/cluster/round_robin_handle.js",
+ "lib/internal/cluster/worker.js",
+ "lib/internal/cluster/primary.js",
+ "lib/internal/cluster/utils.js",
+ "lib/internal/cluster/child.js",
+ "lib/internal/webstreams/compression.js",
+ "lib/internal/webstreams/util.js",
+ "lib/internal/webstreams/writablestream.js",
+ "lib/internal/webstreams/readablestream.js",
+ "lib/internal/webstreams/queuingstrategies.js",
+ "lib/internal/webstreams/encoding.js",
+ "lib/internal/webstreams/transformstream.js",
+ "lib/internal/webstreams/adapters.js",
+ "lib/internal/webstreams/transfer.js",
+ "lib/internal/bootstrap/loaders.js",
+ "lib/internal/bootstrap/pre_execution.js",
+ "lib/internal/bootstrap/node.js",
+ "lib/internal/bootstrap/environment.js",
+ "lib/internal/bootstrap/switches/does_not_own_process_state.js",
+ "lib/internal/bootstrap/switches/is_not_main_thread.js",
+ "lib/internal/bootstrap/switches/does_own_process_state.js",
+ "lib/internal/bootstrap/switches/is_main_thread.js",
+ "lib/internal/test/binding.js",
+ "lib/internal/test/transfer.js",
+ "lib/internal/util/types.js",
+ "lib/internal/util/inspector.js",
+ "lib/internal/util/comparisons.js",
+ "lib/internal/util/debuglog.js",
+ "lib/internal/util/inspect.js",
+ "lib/internal/util/iterable_weak_map.js",
+ "lib/internal/streams/add-abort-signal.js",
+ "lib/internal/streams/compose.js",
+ "lib/internal/streams/duplexify.js",
+ "lib/internal/streams/destroy.js",
+ "lib/internal/streams/legacy.js",
+ "lib/internal/streams/passthrough.js",
+ "lib/internal/streams/operators.js",
+ "lib/internal/streams/readable.js",
+ "lib/internal/streams/from.js",
+ "lib/internal/streams/writable.js",
+ "lib/internal/streams/state.js",
+ "lib/internal/streams/buffer_list.js",
+ "lib/internal/streams/end-of-stream.js",
+ "lib/internal/streams/utils.js",
+ "lib/internal/streams/transform.js",
+ "lib/internal/streams/lazy_transform.js",
+ "lib/internal/streams/duplex.js",
+ "lib/internal/streams/pipeline.js",
+ "lib/internal/readline/interface.js",
+ "lib/internal/readline/promises.js",
+ "lib/internal/readline/utils.js",
+ "lib/internal/readline/emitKeypressEvents.js",
+ "lib/internal/readline/callbacks.js",
+ "lib/internal/repl/history.js",
+ "lib/internal/repl/utils.js",
+ "lib/internal/repl/await.js",
+ "lib/internal/legacy/processbinding.js",
+ "lib/internal/assert/calltracker.js",
+ "lib/internal/assert/assertion_error.js",
+ "lib/internal/http2/util.js",
+ "lib/internal/http2/core.js",
+ "lib/internal/http2/compat.js",
+ "lib/internal/per_context/messageport.js",
+ "lib/internal/per_context/primordials.js",
+ "lib/internal/per_context/domexception.js",
+ "lib/internal/vm/module.js",
+ "lib/internal/tls/secure-pair.js",
+ "lib/internal/tls/parse-cert-string.js",
+ "lib/internal/tls/secure-context.js",
+ "lib/internal/child_process/serialization.js",
+ "lib/internal/debugger/inspect_repl.js",
+ "lib/internal/debugger/inspect_client.js",
+ "lib/internal/debugger/inspect.js",
+ "lib/internal/worker/io.js",
+ "lib/internal/worker/js_transferable.js",
+ "lib/internal/main/repl.js",
+ "lib/internal/main/print_help.js",
+ "lib/internal/main/eval_string.js",
+ "lib/internal/main/check_syntax.js",
+ "lib/internal/main/prof_process.js",
+ "lib/internal/main/worker_thread.js",
+ "lib/internal/main/inspect.js",
+ "lib/internal/main/eval_stdin.js",
+ "lib/internal/main/run_main_module.js",
+ "lib/internal/modules/run_main.js",
+ "lib/internal/modules/package_json_reader.js",
+ "lib/internal/modules/esm/module_job.js",
+ "lib/internal/modules/esm/assert.js",
+ "lib/internal/modules/esm/get_source.js",
+ "lib/internal/modules/esm/translators.js",
+ "lib/internal/modules/esm/resolve.js",
+ "lib/internal/modules/esm/create_dynamic_module.js",
+ "lib/internal/modules/esm/load.js",
+ "lib/internal/modules/esm/handle_process_exit.js",
+ "lib/internal/modules/esm/initialize_import_meta.js",
+ "lib/internal/modules/esm/module_map.js",
+ "lib/internal/modules/esm/get_format.js",
+ "lib/internal/modules/esm/loader.js",
+ "lib/internal/modules/cjs/helpers.js",
+ "lib/internal/modules/cjs/loader.js",
+ "lib/internal/source_map/source_map.js",
+ "lib/internal/source_map/prepare_stack_trace.js",
+ "lib/internal/source_map/source_map_cache.js",
+ "lib/internal/dns/promises.js",
+ "lib/internal/dns/utils.js",
+ "lib/internal/fs/watchers.js",
+ "lib/internal/fs/promises.js",
+ "lib/internal/fs/read_file_context.js",
+ "lib/internal/fs/rimraf.js",
+ "lib/internal/fs/sync_write_stream.js",
+ "lib/internal/fs/dir.js",
+ "lib/internal/fs/streams.js",
+ "lib/internal/fs/utils.js",
+ "lib/internal/fs/cp/cp.js",
+ "lib/internal/fs/cp/cp-sync.js",
+ "lib/internal/perf/nodetiming.js",
+ "lib/internal/perf/usertiming.js",
+ "lib/internal/perf/performance_entry.js",
+ "lib/internal/perf/performance.js",
+ "lib/internal/perf/timerify.js",
+ "lib/internal/perf/utils.js",
+ "lib/internal/perf/observe.js",
+ "lib/internal/perf/event_loop_delay.js",
+ "lib/internal/perf/event_loop_utilization.js",
+ "lib/internal/policy/manifest.js",
+ "lib/internal/policy/sri.js",
+ "lib/internal/process/task_queues.js",
+ "lib/internal/process/per_thread.js",
+ "lib/internal/process/warning.js",
+ "lib/internal/process/policy.js",
+ "lib/internal/process/promises.js",
+ "lib/internal/process/signal.js",
+ "lib/internal/process/execution.js",
+ "lib/internal/process/esm_loader.js",
+ "lib/internal/process/report.js",
+ "lib/internal/process/worker_thread_only.js",
+ "lib/internal/console/constructor.js",
+ "lib/internal/console/global.js",
+ "lib/assert/strict.js",
+ "lib/dns/promises.js",
+ "lib/fs/promises.js"
+ ],
+ "node_module_version": 102,
+ "node_no_browser_globals": "false",
+ "node_prefix": "/usr/local",
+ "node_release_urlbase": "https://nodejs.org/download/release/",
+ "node_shared": "false",
+ "node_shared_brotli": "false",
+ "node_shared_cares": "false",
+ "node_shared_http_parser": "false",
+ "node_shared_libuv": "false",
+ "node_shared_nghttp2": "false",
+ "node_shared_nghttp3": "false",
+ "node_shared_ngtcp2": "false",
+ "node_shared_openssl": "false",
+ "node_shared_zlib": "false",
+ "node_tag": "",
+ "node_target_type": "executable",
+ "node_use_bundled_v8": "true",
+ "node_use_dtrace": "true",
+ "node_use_etw": "false",
+ "node_use_node_code_cache": "true",
+ "node_use_node_snapshot": "true",
+ "node_use_openssl": "true",
+ "node_use_v8_platform": "true",
+ "node_with_ltcg": "false",
+ "node_without_node_options": "false",
+ "openssl_is_fips": "false",
+ "openssl_quic": "true",
+ "ossfuzz": "false",
+ "shlib_suffix": "102.dylib",
+ "target_arch": "arm64",
+ "v8_enable_31bit_smis_on_64bit_arch": 0,
+ "v8_enable_gdbjit": 0,
+ "v8_enable_hugepage": 0,
+ "v8_enable_i18n_support": 1,
+ "v8_enable_inspector": 1,
+ "v8_enable_lite_mode": 0,
+ "v8_enable_object_print": 1,
+ "v8_enable_pointer_compression": 0,
+ "v8_enable_webassembly": 1,
+ "v8_no_strict_aliasing": 1,
+ "v8_optimized_debug": 1,
+ "v8_promise_internal_field_count": 1,
+ "v8_random_seed": 0,
+ "v8_trace_maps": 0,
+ "v8_use_siphash": 1,
+ "want_separate_host_toolset": 0,
+ "xcode_version": "12.0",
+ "nodedir": "/Users/minteck/Library/Caches/node-gyp/17.5.0",
+ "standalone_static_library": 1,
+ "metrics_registry": "https://registry.npmjs.org/",
+ "global_prefix": "/usr/local",
+ "local_prefix": "/Users/minteck/Code/ArgonCDN",
+ "globalconfig": "/usr/local/etc/npmrc",
+ "init_module": "/Users/minteck/.npm-init.js",
+ "userconfig": "/Users/minteck/.npmrc",
+ "node_gyp": "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",
+ "cache": "/Users/minteck/.npm",
+ "user_agent": "npm/8.4.1 node/v17.5.0 darwin arm64 workspaces/false",
+ "prefix": "/usr/local"
+ }
+}
diff --git a/node_modules/mmmagic/build/deps/libmagic/libmagic.Makefile b/node_modules/mmmagic/build/deps/libmagic/libmagic.Makefile
new file mode 100644
index 0000000..c4908f1
--- /dev/null
+++ b/node_modules/mmmagic/build/deps/libmagic/libmagic.Makefile
@@ -0,0 +1,6 @@
+# This file is generated by gyp; do not edit.
+
+export builddir_name ?= ./build/deps/libmagic/.
+.PHONY: all
+all:
+ $(MAKE) -C ../.. libmagic
diff --git a/node_modules/mmmagic/build/deps/libmagic/libmagic.target.mk b/node_modules/mmmagic/build/deps/libmagic/libmagic.target.mk
new file mode 100644
index 0000000..9c881d3
--- /dev/null
+++ b/node_modules/mmmagic/build/deps/libmagic/libmagic.target.mk
@@ -0,0 +1,211 @@
+# This file is generated by gyp; do not edit.
+
+TOOLSET := target
+TARGET := libmagic
+DEFS_Debug := \
+ '-DNODE_GYP_MODULE_NAME=libmagic' \
+ '-DUSING_UV_SHARED=1' \
+ '-DUSING_V8_SHARED=1' \
+ '-DV8_DEPRECATION_WARNINGS=1' \
+ '-DV8_DEPRECATION_WARNINGS' \
+ '-DV8_IMMINENT_DEPRECATION_WARNINGS' \
+ '-D_GLIBCXX_USE_CXX11_ABI=1' \
+ '-D_DARWIN_USE_64_BIT_INODE=1' \
+ '-D_LARGEFILE_SOURCE' \
+ '-D_FILE_OFFSET_BITS=64' \
+ '-DOPENSSL_NO_PINSHARED' \
+ '-DOPENSSL_THREADS' \
+ '-DHAVE_CONFIG_H' \
+ '-DVERSION="5.32"' \
+ '-DDEBUG' \
+ '-D_DEBUG' \
+ '-DV8_ENABLE_CHECKS'
+
+# Flags passed to all source files.
+CFLAGS_Debug := \
+ -O0 \
+ -gdwarf-2 \
+ -mmacosx-version-min=10.13 \
+ -arch arm64 \
+ -Wall \
+ -Wendif-labels \
+ -W \
+ -Wno-unused-parameter
+
+# Flags passed to only C files.
+CFLAGS_C_Debug := \
+ -fno-strict-aliasing
+
+# Flags passed to only C++ files.
+CFLAGS_CC_Debug := \
+ -std=gnu++17 \
+ -stdlib=libc++ \
+ -fno-rtti \
+ -fno-exceptions \
+ -fno-strict-aliasing
+
+# Flags passed to only ObjC files.
+CFLAGS_OBJC_Debug :=
+
+# Flags passed to only ObjC++ files.
+CFLAGS_OBJCC_Debug :=
+
+INCS_Debug := \
+ -I/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node \
+ -I/Users/minteck/Library/Caches/node-gyp/17.5.0/src \
+ -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/config \
+ -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/openssl/include \
+ -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/uv/include \
+ -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/zlib \
+ -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/v8/include \
+ -I$(srcdir)/deps/libmagic \
+ -I$(srcdir)/deps/libmagic/src \
+ -I$(srcdir)/deps/libmagic/config/mac
+
+DEFS_Release := \
+ '-DNODE_GYP_MODULE_NAME=libmagic' \
+ '-DUSING_UV_SHARED=1' \
+ '-DUSING_V8_SHARED=1' \
+ '-DV8_DEPRECATION_WARNINGS=1' \
+ '-DV8_DEPRECATION_WARNINGS' \
+ '-DV8_IMMINENT_DEPRECATION_WARNINGS' \
+ '-D_GLIBCXX_USE_CXX11_ABI=1' \
+ '-D_DARWIN_USE_64_BIT_INODE=1' \
+ '-D_LARGEFILE_SOURCE' \
+ '-D_FILE_OFFSET_BITS=64' \
+ '-DOPENSSL_NO_PINSHARED' \
+ '-DOPENSSL_THREADS' \
+ '-DHAVE_CONFIG_H' \
+ '-DVERSION="5.32"'
+
+# Flags passed to all source files.
+CFLAGS_Release := \
+ -O3 \
+ -gdwarf-2 \
+ -mmacosx-version-min=10.13 \
+ -arch arm64 \
+ -Wall \
+ -Wendif-labels \
+ -W \
+ -Wno-unused-parameter
+
+# Flags passed to only C files.
+CFLAGS_C_Release := \
+ -fno-strict-aliasing
+
+# Flags passed to only C++ files.
+CFLAGS_CC_Release := \
+ -std=gnu++17 \
+ -stdlib=libc++ \
+ -fno-rtti \
+ -fno-exceptions \
+ -fno-strict-aliasing
+
+# Flags passed to only ObjC files.
+CFLAGS_OBJC_Release :=
+
+# Flags passed to only ObjC++ files.
+CFLAGS_OBJCC_Release :=
+
+INCS_Release := \
+ -I/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node \
+ -I/Users/minteck/Library/Caches/node-gyp/17.5.0/src \
+ -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/config \
+ -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/openssl/include \
+ -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/uv/include \
+ -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/zlib \
+ -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/v8/include \
+ -I$(srcdir)/deps/libmagic \
+ -I$(srcdir)/deps/libmagic/src \
+ -I$(srcdir)/deps/libmagic/config/mac
+
+OBJS := \
+ $(obj).target/$(TARGET)/deps/libmagic/src/apprentice.o \
+ $(obj).target/$(TARGET)/deps/libmagic/src/apptype.o \
+ $(obj).target/$(TARGET)/deps/libmagic/src/ascmagic.o \
+ $(obj).target/$(TARGET)/deps/libmagic/src/cdf.o \
+ $(obj).target/$(TARGET)/deps/libmagic/src/cdf_time.o \
+ $(obj).target/$(TARGET)/deps/libmagic/src/compress.o \
+ $(obj).target/$(TARGET)/deps/libmagic/src/der.o \
+ $(obj).target/$(TARGET)/deps/libmagic/src/encoding.o \
+ $(obj).target/$(TARGET)/deps/libmagic/src/fsmagic.o \
+ $(obj).target/$(TARGET)/deps/libmagic/src/funcs.o \
+ $(obj).target/$(TARGET)/deps/libmagic/src/is_tar.o \
+ $(obj).target/$(TARGET)/deps/libmagic/src/magic.o \
+ $(obj).target/$(TARGET)/deps/libmagic/src/print.o \
+ $(obj).target/$(TARGET)/deps/libmagic/src/readcdf.o \
+ $(obj).target/$(TARGET)/deps/libmagic/src/readelf.o \
+ $(obj).target/$(TARGET)/deps/libmagic/src/softmagic.o
+
+# Add to the list of files we specially track dependencies for.
+all_deps += $(OBJS)
+
+# CFLAGS et al overrides must be target-local.
+# See "Target-specific Variable Values" in the GNU Make manual.
+$(OBJS): TOOLSET := $(TOOLSET)
+$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE))
+$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE))
+$(OBJS): GYP_OBJCFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE))
+$(OBJS): GYP_OBJCXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE))
+
+# Suffix rules, putting all outputs into $(obj).
+
+$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD
+ @$(call do_cmd,cc,1)
+
+# Try building from generated source, too.
+
+$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD
+ @$(call do_cmd,cc,1)
+
+$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD
+ @$(call do_cmd,cc,1)
+
+# End of this set of suffix rules
+### Rules for final target.
+LDFLAGS_Debug := \
+ -mmacosx-version-min=10.13 \
+ -arch arm64 \
+ -L$(builddir) \
+ -stdlib=libc++
+
+LIBTOOLFLAGS_Debug :=
+
+LDFLAGS_Release := \
+ -mmacosx-version-min=10.13 \
+ -arch arm64 \
+ -L$(builddir) \
+ -stdlib=libc++
+
+LIBTOOLFLAGS_Release :=
+
+LIBS :=
+
+$(builddir)/magic.a: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))
+$(builddir)/magic.a: LIBS := $(LIBS)
+$(builddir)/magic.a: GYP_LIBTOOLFLAGS := $(LIBTOOLFLAGS_$(BUILDTYPE))
+$(builddir)/magic.a: TOOLSET := $(TOOLSET)
+$(builddir)/magic.a: $(OBJS) FORCE_DO_CMD
+ $(call do_cmd,alink)
+
+all_deps += $(builddir)/magic.a
+# Add target alias
+.PHONY: libmagic
+libmagic: $(builddir)/magic.a
+
+# Add target alias to "all" target.
+.PHONY: all
+all: libmagic
+
+# Add target alias
+.PHONY: libmagic
+libmagic: $(builddir)/magic.a
+
+# Short alias for building this static library.
+.PHONY: magic.a
+magic.a: $(builddir)/magic.a
+
+# Add static library to "all" target.
+.PHONY: all
+all: $(builddir)/magic.a
+
diff --git a/node_modules/mmmagic/build/gyp-mac-tool b/node_modules/mmmagic/build/gyp-mac-tool
new file mode 100755
index 0000000..ffef860
--- /dev/null
+++ b/node_modules/mmmagic/build/gyp-mac-tool
@@ -0,0 +1,772 @@
+#!/usr/bin/env python3
+# Generated by gyp. Do not edit.
+# Copyright (c) 2012 Google Inc. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Utility functions to perform Xcode-style build steps.
+
+These functions are executed via gyp-mac-tool when using the Makefile generator.
+"""
+
+
+import fcntl
+import fnmatch
+import glob
+import json
+import os
+import plistlib
+import re
+import shutil
+import struct
+import subprocess
+import sys
+import tempfile
+
+
+def main(args):
+ executor = MacTool()
+ exit_code = executor.Dispatch(args)
+ if exit_code is not None:
+ sys.exit(exit_code)
+
+
+class MacTool:
+ """This class performs all the Mac tooling steps. The methods can either be
+ executed directly, or dispatched from an argument list."""
+
+ def Dispatch(self, args):
+ """Dispatches a string command to a method."""
+ if len(args) < 1:
+ raise Exception("Not enough arguments")
+
+ method = "Exec%s" % self._CommandifyName(args[0])
+ return getattr(self, method)(*args[1:])
+
+ def _CommandifyName(self, name_string):
+ """Transforms a tool name like copy-info-plist to CopyInfoPlist"""
+ return name_string.title().replace("-", "")
+
+ def ExecCopyBundleResource(self, source, dest, convert_to_binary):
+ """Copies a resource file to the bundle/Resources directory, performing any
+ necessary compilation on each resource."""
+ convert_to_binary = convert_to_binary == "True"
+ extension = os.path.splitext(source)[1].lower()
+ if os.path.isdir(source):
+ # Copy tree.
+ # TODO(thakis): This copies file attributes like mtime, while the
+ # single-file branch below doesn't. This should probably be changed to
+ # be consistent with the single-file branch.
+ if os.path.exists(dest):
+ shutil.rmtree(dest)
+ shutil.copytree(source, dest)
+ elif extension == ".xib":
+ return self._CopyXIBFile(source, dest)
+ elif extension == ".storyboard":
+ return self._CopyXIBFile(source, dest)
+ elif extension == ".strings" and not convert_to_binary:
+ self._CopyStringsFile(source, dest)
+ else:
+ if os.path.exists(dest):
+ os.unlink(dest)
+ shutil.copy(source, dest)
+
+ if convert_to_binary and extension in (".plist", ".strings"):
+ self._ConvertToBinary(dest)
+
+ def _CopyXIBFile(self, source, dest):
+ """Compiles a XIB file with ibtool into a binary plist in the bundle."""
+
+ # ibtool sometimes crashes with relative paths. See crbug.com/314728.
+ base = os.path.dirname(os.path.realpath(__file__))
+ if os.path.relpath(source):
+ source = os.path.join(base, source)
+ if os.path.relpath(dest):
+ dest = os.path.join(base, dest)
+
+ args = ["xcrun", "ibtool", "--errors", "--warnings", "--notices"]
+
+ if os.environ["XCODE_VERSION_ACTUAL"] > "0700":
+ args.extend(["--auto-activate-custom-fonts"])
+ if "IPHONEOS_DEPLOYMENT_TARGET" in os.environ:
+ args.extend(
+ [
+ "--target-device",
+ "iphone",
+ "--target-device",
+ "ipad",
+ "--minimum-deployment-target",
+ os.environ["IPHONEOS_DEPLOYMENT_TARGET"],
+ ]
+ )
+ else:
+ args.extend(
+ [
+ "--target-device",
+ "mac",
+ "--minimum-deployment-target",
+ os.environ["MACOSX_DEPLOYMENT_TARGET"],
+ ]
+ )
+
+ args.extend(
+ ["--output-format", "human-readable-text", "--compile", dest, source]
+ )
+
+ ibtool_section_re = re.compile(r"/\*.*\*/")
+ ibtool_re = re.compile(r".*note:.*is clipping its content")
+ try:
+ stdout = subprocess.check_output(args)
+ except subprocess.CalledProcessError as e:
+ print(e.output)
+ raise
+ current_section_header = None
+ for line in stdout.splitlines():
+ if ibtool_section_re.match(line):
+ current_section_header = line
+ elif not ibtool_re.match(line):
+ if current_section_header:
+ print(current_section_header)
+ current_section_header = None
+ print(line)
+ return 0
+
+ def _ConvertToBinary(self, dest):
+ subprocess.check_call(
+ ["xcrun", "plutil", "-convert", "binary1", "-o", dest, dest]
+ )
+
+ def _CopyStringsFile(self, source, dest):
+ """Copies a .strings file using iconv to reconvert the input into UTF-16."""
+ input_code = self._DetectInputEncoding(source) or "UTF-8"
+
+ # Xcode's CpyCopyStringsFile / builtin-copyStrings seems to call
+ # CFPropertyListCreateFromXMLData() behind the scenes; at least it prints
+ # CFPropertyListCreateFromXMLData(): Old-style plist parser: missing
+ # semicolon in dictionary.
+ # on invalid files. Do the same kind of validation.
+ import CoreFoundation
+
+ with open(source, "rb") as in_file:
+ s = in_file.read()
+ d = CoreFoundation.CFDataCreate(None, s, len(s))
+ _, error = CoreFoundation.CFPropertyListCreateFromXMLData(None, d, 0, None)
+ if error:
+ return
+
+ with open(dest, "wb") as fp:
+ fp.write(s.decode(input_code).encode("UTF-16"))
+
+ def _DetectInputEncoding(self, file_name):
+ """Reads the first few bytes from file_name and tries to guess the text
+ encoding. Returns None as a guess if it can't detect it."""
+ with open(file_name, "rb") as fp:
+ try:
+ header = fp.read(3)
+ except Exception:
+ return None
+ if header.startswith(b"\xFE\xFF"):
+ return "UTF-16"
+ elif header.startswith(b"\xFF\xFE"):
+ return "UTF-16"
+ elif header.startswith(b"\xEF\xBB\xBF"):
+ return "UTF-8"
+ else:
+ return None
+
+ def ExecCopyInfoPlist(self, source, dest, convert_to_binary, *keys):
+ """Copies the |source| Info.plist to the destination directory |dest|."""
+ # Read the source Info.plist into memory.
+ with open(source) as fd:
+ lines = fd.read()
+
+ # Insert synthesized key/value pairs (e.g. BuildMachineOSBuild).
+ plist = plistlib.readPlistFromString(lines)
+ if keys:
+ plist.update(json.loads(keys[0]))
+ lines = plistlib.writePlistToString(plist)
+
+ # Go through all the environment variables and replace them as variables in
+ # the file.
+ IDENT_RE = re.compile(r"[_/\s]")
+ for key in os.environ:
+ if key.startswith("_"):
+ continue
+ evar = "${%s}" % key
+ evalue = os.environ[key]
+ lines = lines.replace(lines, evar, evalue)
+
+ # Xcode supports various suffices on environment variables, which are
+ # all undocumented. :rfc1034identifier is used in the standard project
+ # template these days, and :identifier was used earlier. They are used to
+ # convert non-url characters into things that look like valid urls --
+ # except that the replacement character for :identifier, '_' isn't valid
+ # in a URL either -- oops, hence :rfc1034identifier was born.
+ evar = "${%s:identifier}" % key
+ evalue = IDENT_RE.sub("_", os.environ[key])
+ lines = lines.replace(lines, evar, evalue)
+
+ evar = "${%s:rfc1034identifier}" % key
+ evalue = IDENT_RE.sub("-", os.environ[key])
+ lines = lines.replace(lines, evar, evalue)
+
+ # Remove any keys with values that haven't been replaced.
+ lines = lines.splitlines()
+ for i in range(len(lines)):
+ if lines[i].strip().startswith("<string>${"):
+ lines[i] = None
+ lines[i - 1] = None
+ lines = "\n".join(line for line in lines if line is not None)
+
+ # Write out the file with variables replaced.
+ with open(dest, "w") as fd:
+ fd.write(lines)
+
+ # Now write out PkgInfo file now that the Info.plist file has been
+ # "compiled".
+ self._WritePkgInfo(dest)
+
+ if convert_to_binary == "True":
+ self._ConvertToBinary(dest)
+
+ def _WritePkgInfo(self, info_plist):
+ """This writes the PkgInfo file from the data stored in Info.plist."""
+ plist = plistlib.readPlist(info_plist)
+ if not plist:
+ return
+
+ # Only create PkgInfo for executable types.
+ package_type = plist["CFBundlePackageType"]
+ if package_type != "APPL":
+ return
+
+ # The format of PkgInfo is eight characters, representing the bundle type
+ # and bundle signature, each four characters. If that is missing, four
+ # '?' characters are used instead.
+ signature_code = plist.get("CFBundleSignature", "????")
+ if len(signature_code) != 4: # Wrong length resets everything, too.
+ signature_code = "?" * 4
+
+ dest = os.path.join(os.path.dirname(info_plist), "PkgInfo")
+ with open(dest, "w") as fp:
+ fp.write(f"{package_type}{signature_code}")
+
+ def ExecFlock(self, lockfile, *cmd_list):
+ """Emulates the most basic behavior of Linux's flock(1)."""
+ # Rely on exception handling to report errors.
+ fd = os.open(lockfile, os.O_RDONLY | os.O_NOCTTY | os.O_CREAT, 0o666)
+ fcntl.flock(fd, fcntl.LOCK_EX)
+ return subprocess.call(cmd_list)
+
+ def ExecFilterLibtool(self, *cmd_list):
+ """Calls libtool and filters out '/path/to/libtool: file: foo.o has no
+ symbols'."""
+ libtool_re = re.compile(
+ r"^.*libtool: (?:for architecture: \S* )?" r"file: .* has no symbols$"
+ )
+ libtool_re5 = re.compile(
+ r"^.*libtool: warning for library: "
+ + r".* the table of contents is empty "
+ + r"\(no object file members in the library define global symbols\)$"
+ )
+ env = os.environ.copy()
+ # Ref:
+ # http://www.opensource.apple.com/source/cctools/cctools-809/misc/libtool.c
+ # The problem with this flag is that it resets the file mtime on the file to
+ # epoch=0, e.g. 1970-1-1 or 1969-12-31 depending on timezone.
+ env["ZERO_AR_DATE"] = "1"
+ libtoolout = subprocess.Popen(cmd_list, stderr=subprocess.PIPE, env=env)
+ err = libtoolout.communicate()[1].decode("utf-8")
+ for line in err.splitlines():
+ if not libtool_re.match(line) and not libtool_re5.match(line):
+ print(line, file=sys.stderr)
+ # Unconditionally touch the output .a file on the command line if present
+ # and the command succeeded. A bit hacky.
+ if not libtoolout.returncode:
+ for i in range(len(cmd_list) - 1):
+ if cmd_list[i] == "-o" and cmd_list[i + 1].endswith(".a"):
+ os.utime(cmd_list[i + 1], None)
+ break
+ return libtoolout.returncode
+
+ def ExecPackageIosFramework(self, framework):
+ # Find the name of the binary based on the part before the ".framework".
+ binary = os.path.basename(framework).split(".")[0]
+ module_path = os.path.join(framework, "Modules")
+ if not os.path.exists(module_path):
+ os.mkdir(module_path)
+ module_template = (
+ "framework module %s {\n"
+ ' umbrella header "%s.h"\n'
+ "\n"
+ " export *\n"
+ " module * { export * }\n"
+ "}\n" % (binary, binary)
+ )
+
+ with open(os.path.join(module_path, "module.modulemap"), "w") as module_file:
+ module_file.write(module_template)
+
+ def ExecPackageFramework(self, framework, version):
+ """Takes a path to Something.framework and the Current version of that and
+ sets up all the symlinks."""
+ # Find the name of the binary based on the part before the ".framework".
+ binary = os.path.basename(framework).split(".")[0]
+
+ CURRENT = "Current"
+ RESOURCES = "Resources"
+ VERSIONS = "Versions"
+
+ if not os.path.exists(os.path.join(framework, VERSIONS, version, binary)):
+ # Binary-less frameworks don't seem to contain symlinks (see e.g.
+ # chromium's out/Debug/org.chromium.Chromium.manifest/ bundle).
+ return
+
+ # Move into the framework directory to set the symlinks correctly.
+ pwd = os.getcwd()
+ os.chdir(framework)
+
+ # Set up the Current version.
+ self._Relink(version, os.path.join(VERSIONS, CURRENT))
+
+ # Set up the root symlinks.
+ self._Relink(os.path.join(VERSIONS, CURRENT, binary), binary)
+ self._Relink(os.path.join(VERSIONS, CURRENT, RESOURCES), RESOURCES)
+
+ # Back to where we were before!
+ os.chdir(pwd)
+
+ def _Relink(self, dest, link):
+ """Creates a symlink to |dest| named |link|. If |link| already exists,
+ it is overwritten."""
+ if os.path.lexists(link):
+ os.remove(link)
+ os.symlink(dest, link)
+
+ def ExecCompileIosFrameworkHeaderMap(self, out, framework, *all_headers):
+ framework_name = os.path.basename(framework).split(".")[0]
+ all_headers = [os.path.abspath(header) for header in all_headers]
+ filelist = {}
+ for header in all_headers:
+ filename = os.path.basename(header)
+ filelist[filename] = header
+ filelist[os.path.join(framework_name, filename)] = header
+ WriteHmap(out, filelist)
+
+ def ExecCopyIosFrameworkHeaders(self, framework, *copy_headers):
+ header_path = os.path.join(framework, "Headers")
+ if not os.path.exists(header_path):
+ os.makedirs(header_path)
+ for header in copy_headers:
+ shutil.copy(header, os.path.join(header_path, os.path.basename(header)))
+
+ def ExecCompileXcassets(self, keys, *inputs):
+ """Compiles multiple .xcassets files into a single .car file.
+
+ This invokes 'actool' to compile all the inputs .xcassets files. The
+ |keys| arguments is a json-encoded dictionary of extra arguments to
+ pass to 'actool' when the asset catalogs contains an application icon
+ or a launch image.
+
+ Note that 'actool' does not create the Assets.car file if the asset
+ catalogs does not contains imageset.
+ """
+ command_line = [
+ "xcrun",
+ "actool",
+ "--output-format",
+ "human-readable-text",
+ "--compress-pngs",
+ "--notices",
+ "--warnings",
+ "--errors",
+ ]
+ is_iphone_target = "IPHONEOS_DEPLOYMENT_TARGET" in os.environ
+ if is_iphone_target:
+ platform = os.environ["CONFIGURATION"].split("-")[-1]
+ if platform not in ("iphoneos", "iphonesimulator"):
+ platform = "iphonesimulator"
+ command_line.extend(
+ [
+ "--platform",
+ platform,
+ "--target-device",
+ "iphone",
+ "--target-device",
+ "ipad",
+ "--minimum-deployment-target",
+ os.environ["IPHONEOS_DEPLOYMENT_TARGET"],
+ "--compile",
+ os.path.abspath(os.environ["CONTENTS_FOLDER_PATH"]),
+ ]
+ )
+ else:
+ command_line.extend(
+ [
+ "--platform",
+ "macosx",
+ "--target-device",
+ "mac",
+ "--minimum-deployment-target",
+ os.environ["MACOSX_DEPLOYMENT_TARGET"],
+ "--compile",
+ os.path.abspath(os.environ["UNLOCALIZED_RESOURCES_FOLDER_PATH"]),
+ ]
+ )
+ if keys:
+ keys = json.loads(keys)
+ for key, value in keys.items():
+ arg_name = "--" + key
+ if isinstance(value, bool):
+ if value:
+ command_line.append(arg_name)
+ elif isinstance(value, list):
+ for v in value:
+ command_line.append(arg_name)
+ command_line.append(str(v))
+ else:
+ command_line.append(arg_name)
+ command_line.append(str(value))
+ # Note: actool crashes if inputs path are relative, so use os.path.abspath
+ # to get absolute path name for inputs.
+ command_line.extend(map(os.path.abspath, inputs))
+ subprocess.check_call(command_line)
+
+ def ExecMergeInfoPlist(self, output, *inputs):
+ """Merge multiple .plist files into a single .plist file."""
+ merged_plist = {}
+ for path in inputs:
+ plist = self._LoadPlistMaybeBinary(path)
+ self._MergePlist(merged_plist, plist)
+ plistlib.writePlist(merged_plist, output)
+
+ def ExecCodeSignBundle(self, key, entitlements, provisioning, path, preserve):
+ """Code sign a bundle.
+
+ This function tries to code sign an iOS bundle, following the same
+ algorithm as Xcode:
+ 1. pick the provisioning profile that best match the bundle identifier,
+ and copy it into the bundle as embedded.mobileprovision,
+ 2. copy Entitlements.plist from user or SDK next to the bundle,
+ 3. code sign the bundle.
+ """
+ substitutions, overrides = self._InstallProvisioningProfile(
+ provisioning, self._GetCFBundleIdentifier()
+ )
+ entitlements_path = self._InstallEntitlements(
+ entitlements, substitutions, overrides
+ )
+
+ args = ["codesign", "--force", "--sign", key]
+ if preserve == "True":
+ args.extend(["--deep", "--preserve-metadata=identifier,entitlements"])
+ else:
+ args.extend(["--entitlements", entitlements_path])
+ args.extend(["--timestamp=none", path])
+ subprocess.check_call(args)
+
+ def _InstallProvisioningProfile(self, profile, bundle_identifier):
+ """Installs embedded.mobileprovision into the bundle.
+
+ Args:
+ profile: string, optional, short name of the .mobileprovision file
+ to use, if empty or the file is missing, the best file installed
+ will be used
+ bundle_identifier: string, value of CFBundleIdentifier from Info.plist
+
+ Returns:
+ A tuple containing two dictionary: variables substitutions and values
+ to overrides when generating the entitlements file.
+ """
+ source_path, provisioning_data, team_id = self._FindProvisioningProfile(
+ profile, bundle_identifier
+ )
+ target_path = os.path.join(
+ os.environ["BUILT_PRODUCTS_DIR"],
+ os.environ["CONTENTS_FOLDER_PATH"],
+ "embedded.mobileprovision",
+ )
+ shutil.copy2(source_path, target_path)
+ substitutions = self._GetSubstitutions(bundle_identifier, team_id + ".")
+ return substitutions, provisioning_data["Entitlements"]
+
+ def _FindProvisioningProfile(self, profile, bundle_identifier):
+ """Finds the .mobileprovision file to use for signing the bundle.
+
+ Checks all the installed provisioning profiles (or if the user specified
+ the PROVISIONING_PROFILE variable, only consult it) and select the most
+ specific that correspond to the bundle identifier.
+
+ Args:
+ profile: string, optional, short name of the .mobileprovision file
+ to use, if empty or the file is missing, the best file installed
+ will be used
+ bundle_identifier: string, value of CFBundleIdentifier from Info.plist
+
+ Returns:
+ A tuple of the path to the selected provisioning profile, the data of
+ the embedded plist in the provisioning profile and the team identifier
+ to use for code signing.
+
+ Raises:
+ SystemExit: if no .mobileprovision can be used to sign the bundle.
+ """
+ profiles_dir = os.path.join(
+ os.environ["HOME"], "Library", "MobileDevice", "Provisioning Profiles"
+ )
+ if not os.path.isdir(profiles_dir):
+ print(
+ "cannot find mobile provisioning for %s" % (bundle_identifier),
+ file=sys.stderr,
+ )
+ sys.exit(1)
+ provisioning_profiles = None
+ if profile:
+ profile_path = os.path.join(profiles_dir, profile + ".mobileprovision")
+ if os.path.exists(profile_path):
+ provisioning_profiles = [profile_path]
+ if not provisioning_profiles:
+ provisioning_profiles = glob.glob(
+ os.path.join(profiles_dir, "*.mobileprovision")
+ )
+ valid_provisioning_profiles = {}
+ for profile_path in provisioning_profiles:
+ profile_data = self._LoadProvisioningProfile(profile_path)
+ app_id_pattern = profile_data.get("Entitlements", {}).get(
+ "application-identifier", ""
+ )
+ for team_identifier in profile_data.get("TeamIdentifier", []):
+ app_id = f"{team_identifier}.{bundle_identifier}"
+ if fnmatch.fnmatch(app_id, app_id_pattern):
+ valid_provisioning_profiles[app_id_pattern] = (
+ profile_path,
+ profile_data,
+ team_identifier,
+ )
+ if not valid_provisioning_profiles:
+ print(
+ "cannot find mobile provisioning for %s" % (bundle_identifier),
+ file=sys.stderr,
+ )
+ sys.exit(1)
+ # If the user has multiple provisioning profiles installed that can be
+ # used for ${bundle_identifier}, pick the most specific one (ie. the
+ # provisioning profile whose pattern is the longest).
+ selected_key = max(valid_provisioning_profiles, key=lambda v: len(v))
+ return valid_provisioning_profiles[selected_key]
+
+ def _LoadProvisioningProfile(self, profile_path):
+ """Extracts the plist embedded in a provisioning profile.
+
+ Args:
+ profile_path: string, path to the .mobileprovision file
+
+ Returns:
+ Content of the plist embedded in the provisioning profile as a dictionary.
+ """
+ with tempfile.NamedTemporaryFile() as temp:
+ subprocess.check_call(
+ ["security", "cms", "-D", "-i", profile_path, "-o", temp.name]
+ )
+ return self._LoadPlistMaybeBinary(temp.name)
+
+ def _MergePlist(self, merged_plist, plist):
+ """Merge |plist| into |merged_plist|."""
+ for key, value in plist.items():
+ if isinstance(value, dict):
+ merged_value = merged_plist.get(key, {})
+ if isinstance(merged_value, dict):
+ self._MergePlist(merged_value, value)
+ merged_plist[key] = merged_value
+ else:
+ merged_plist[key] = value
+ else:
+ merged_plist[key] = value
+
+ def _LoadPlistMaybeBinary(self, plist_path):
+ """Loads into a memory a plist possibly encoded in binary format.
+
+ This is a wrapper around plistlib.readPlist that tries to convert the
+ plist to the XML format if it can't be parsed (assuming that it is in
+ the binary format).
+
+ Args:
+ plist_path: string, path to a plist file, in XML or binary format
+
+ Returns:
+ Content of the plist as a dictionary.
+ """
+ try:
+ # First, try to read the file using plistlib that only supports XML,
+ # and if an exception is raised, convert a temporary copy to XML and
+ # load that copy.
+ return plistlib.readPlist(plist_path)
+ except Exception:
+ pass
+ with tempfile.NamedTemporaryFile() as temp:
+ shutil.copy2(plist_path, temp.name)
+ subprocess.check_call(["plutil", "-convert", "xml1", temp.name])
+ return plistlib.readPlist(temp.name)
+
+ def _GetSubstitutions(self, bundle_identifier, app_identifier_prefix):
+ """Constructs a dictionary of variable substitutions for Entitlements.plist.
+
+ Args:
+ bundle_identifier: string, value of CFBundleIdentifier from Info.plist
+ app_identifier_prefix: string, value for AppIdentifierPrefix
+
+ Returns:
+ Dictionary of substitutions to apply when generating Entitlements.plist.
+ """
+ return {
+ "CFBundleIdentifier": bundle_identifier,
+ "AppIdentifierPrefix": app_identifier_prefix,
+ }
+
+ def _GetCFBundleIdentifier(self):
+ """Extracts CFBundleIdentifier value from Info.plist in the bundle.
+
+ Returns:
+ Value of CFBundleIdentifier in the Info.plist located in the bundle.
+ """
+ info_plist_path = os.path.join(
+ os.environ["TARGET_BUILD_DIR"], os.environ["INFOPLIST_PATH"]
+ )
+ info_plist_data = self._LoadPlistMaybeBinary(info_plist_path)
+ return info_plist_data["CFBundleIdentifier"]
+
+ def _InstallEntitlements(self, entitlements, substitutions, overrides):
+ """Generates and install the ${BundleName}.xcent entitlements file.
+
+ Expands variables "$(variable)" pattern in the source entitlements file,
+ add extra entitlements defined in the .mobileprovision file and the copy
+ the generated plist to "${BundlePath}.xcent".
+
+ Args:
+ entitlements: string, optional, path to the Entitlements.plist template
+ to use, defaults to "${SDKROOT}/Entitlements.plist"
+ substitutions: dictionary, variable substitutions
+ overrides: dictionary, values to add to the entitlements
+
+ Returns:
+ Path to the generated entitlements file.
+ """
+ source_path = entitlements
+ target_path = os.path.join(
+ os.environ["BUILT_PRODUCTS_DIR"], os.environ["PRODUCT_NAME"] + ".xcent"
+ )
+ if not source_path:
+ source_path = os.path.join(os.environ["SDKROOT"], "Entitlements.plist")
+ shutil.copy2(source_path, target_path)
+ data = self._LoadPlistMaybeBinary(target_path)
+ data = self._ExpandVariables(data, substitutions)
+ if overrides:
+ for key in overrides:
+ if key not in data:
+ data[key] = overrides[key]
+ plistlib.writePlist(data, target_path)
+ return target_path
+
+ def _ExpandVariables(self, data, substitutions):
+ """Expands variables "$(variable)" in data.
+
+ Args:
+ data: object, can be either string, list or dictionary
+ substitutions: dictionary, variable substitutions to perform
+
+ Returns:
+ Copy of data where each references to "$(variable)" has been replaced
+ by the corresponding value found in substitutions, or left intact if
+ the key was not found.
+ """
+ if isinstance(data, str):
+ for key, value in substitutions.items():
+ data = data.replace("$(%s)" % key, value)
+ return data
+ if isinstance(data, list):
+ return [self._ExpandVariables(v, substitutions) for v in data]
+ if isinstance(data, dict):
+ return {k: self._ExpandVariables(data[k], substitutions) for k in data}
+ return data
+
+
+def NextGreaterPowerOf2(x):
+ return 2 ** (x).bit_length()
+
+
+def WriteHmap(output_name, filelist):
+ """Generates a header map based on |filelist|.
+
+ Per Mark Mentovai:
+ A header map is structured essentially as a hash table, keyed by names used
+ in #includes, and providing pathnames to the actual files.
+
+ The implementation below and the comment above comes from inspecting:
+ http://www.opensource.apple.com/source/distcc/distcc-2503/distcc_dist/include_server/headermap.py?txt
+ while also looking at the implementation in clang in:
+ https://llvm.org/svn/llvm-project/cfe/trunk/lib/Lex/HeaderMap.cpp
+ """
+ magic = 1751998832
+ version = 1
+ _reserved = 0
+ count = len(filelist)
+ capacity = NextGreaterPowerOf2(count)
+ strings_offset = 24 + (12 * capacity)
+ max_value_length = max(len(value) for value in filelist.values())
+
+ out = open(output_name, "wb")
+ out.write(
+ struct.pack(
+ "<LHHLLLL",
+ magic,
+ version,
+ _reserved,
+ strings_offset,
+ count,
+ capacity,
+ max_value_length,
+ )
+ )
+
+ # Create empty hashmap buckets.
+ buckets = [None] * capacity
+ for file, path in filelist.items():
+ key = 0
+ for c in file:
+ key += ord(c.lower()) * 13
+
+ # Fill next empty bucket.
+ while buckets[key & capacity - 1] is not None:
+ key = key + 1
+ buckets[key & capacity - 1] = (file, path)
+
+ next_offset = 1
+ for bucket in buckets:
+ if bucket is None:
+ out.write(struct.pack("<LLL", 0, 0, 0))
+ else:
+ (file, path) = bucket
+ key_offset = next_offset
+ prefix_offset = key_offset + len(file) + 1
+ suffix_offset = prefix_offset + len(os.path.dirname(path) + os.sep) + 1
+ next_offset = suffix_offset + len(os.path.basename(path)) + 1
+ out.write(struct.pack("<LLL", key_offset, prefix_offset, suffix_offset))
+
+ # Pad byte since next offset starts at 1.
+ out.write(struct.pack("<x"))
+
+ for bucket in buckets:
+ if bucket is not None:
+ (file, path) = bucket
+ out.write(struct.pack("<%ds" % len(file), file))
+ out.write(struct.pack("<s", "\0"))
+ base = os.path.dirname(path) + os.sep
+ out.write(struct.pack("<%ds" % len(base), base))
+ out.write(struct.pack("<s", "\0"))
+ path = os.path.basename(path)
+ out.write(struct.pack("<%ds" % len(path), path))
+ out.write(struct.pack("<s", "\0"))
+
+
+if __name__ == "__main__":
+ sys.exit(main(sys.argv[1:]))
diff --git a/node_modules/mmmagic/build/magic.target.mk b/node_modules/mmmagic/build/magic.target.mk
new file mode 100644
index 0000000..c1c4c10
--- /dev/null
+++ b/node_modules/mmmagic/build/magic.target.mk
@@ -0,0 +1,195 @@
+# This file is generated by gyp; do not edit.
+
+TOOLSET := target
+TARGET := magic
+DEFS_Debug := \
+ '-DNODE_GYP_MODULE_NAME=magic' \
+ '-DUSING_UV_SHARED=1' \
+ '-DUSING_V8_SHARED=1' \
+ '-DV8_DEPRECATION_WARNINGS=1' \
+ '-DV8_DEPRECATION_WARNINGS' \
+ '-DV8_IMMINENT_DEPRECATION_WARNINGS' \
+ '-D_GLIBCXX_USE_CXX11_ABI=1' \
+ '-D_DARWIN_USE_64_BIT_INODE=1' \
+ '-D_LARGEFILE_SOURCE' \
+ '-D_FILE_OFFSET_BITS=64' \
+ '-DOPENSSL_NO_PINSHARED' \
+ '-DOPENSSL_THREADS' \
+ '-DBUILDING_NODE_EXTENSION' \
+ '-DDEBUG' \
+ '-D_DEBUG' \
+ '-DV8_ENABLE_CHECKS'
+
+# Flags passed to all source files.
+CFLAGS_Debug := \
+ -O0 \
+ -gdwarf-2 \
+ -mmacosx-version-min=10.7 \
+ -arch arm64 \
+ -Wall \
+ -Wendif-labels \
+ -W \
+ -Wno-unused-parameter
+
+# Flags passed to only C files.
+CFLAGS_C_Debug := \
+ -fno-strict-aliasing
+
+# Flags passed to only C++ files.
+CFLAGS_CC_Debug := \
+ -std=gnu++1y \
+ -stdlib=libc++ \
+ -fno-rtti \
+ -fno-exceptions \
+ -fno-strict-aliasing
+
+# Flags passed to only ObjC files.
+CFLAGS_OBJC_Debug :=
+
+# Flags passed to only ObjC++ files.
+CFLAGS_OBJCC_Debug :=
+
+INCS_Debug := \
+ -I/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node \
+ -I/Users/minteck/Library/Caches/node-gyp/17.5.0/src \
+ -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/config \
+ -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/openssl/include \
+ -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/uv/include \
+ -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/zlib \
+ -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/v8/include \
+ -I$(srcdir)/deps/libmagic/src \
+ -I$(srcdir)/../nan
+
+DEFS_Release := \
+ '-DNODE_GYP_MODULE_NAME=magic' \
+ '-DUSING_UV_SHARED=1' \
+ '-DUSING_V8_SHARED=1' \
+ '-DV8_DEPRECATION_WARNINGS=1' \
+ '-DV8_DEPRECATION_WARNINGS' \
+ '-DV8_IMMINENT_DEPRECATION_WARNINGS' \
+ '-D_GLIBCXX_USE_CXX11_ABI=1' \
+ '-D_DARWIN_USE_64_BIT_INODE=1' \
+ '-D_LARGEFILE_SOURCE' \
+ '-D_FILE_OFFSET_BITS=64' \
+ '-DOPENSSL_NO_PINSHARED' \
+ '-DOPENSSL_THREADS' \
+ '-DBUILDING_NODE_EXTENSION'
+
+# Flags passed to all source files.
+CFLAGS_Release := \
+ -O3 \
+ -gdwarf-2 \
+ -mmacosx-version-min=10.7 \
+ -arch arm64 \
+ -Wall \
+ -Wendif-labels \
+ -W \
+ -Wno-unused-parameter
+
+# Flags passed to only C files.
+CFLAGS_C_Release := \
+ -fno-strict-aliasing
+
+# Flags passed to only C++ files.
+CFLAGS_CC_Release := \
+ -std=gnu++1y \
+ -stdlib=libc++ \
+ -fno-rtti \
+ -fno-exceptions \
+ -fno-strict-aliasing
+
+# Flags passed to only ObjC files.
+CFLAGS_OBJC_Release :=
+
+# Flags passed to only ObjC++ files.
+CFLAGS_OBJCC_Release :=
+
+INCS_Release := \
+ -I/Users/minteck/Library/Caches/node-gyp/17.5.0/include/node \
+ -I/Users/minteck/Library/Caches/node-gyp/17.5.0/src \
+ -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/config \
+ -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/openssl/openssl/include \
+ -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/uv/include \
+ -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/zlib \
+ -I/Users/minteck/Library/Caches/node-gyp/17.5.0/deps/v8/include \
+ -I$(srcdir)/deps/libmagic/src \
+ -I$(srcdir)/../nan
+
+OBJS := \
+ $(obj).target/$(TARGET)/src/binding.o
+
+# Add to the list of files we specially track dependencies for.
+all_deps += $(OBJS)
+
+# Make sure our dependencies are built before any of us.
+$(OBJS): | $(builddir)/magic.a
+
+# CFLAGS et al overrides must be target-local.
+# See "Target-specific Variable Values" in the GNU Make manual.
+$(OBJS): TOOLSET := $(TOOLSET)
+$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE))
+$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE))
+$(OBJS): GYP_OBJCFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE))
+$(OBJS): GYP_OBJCXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE))
+
+# Suffix rules, putting all outputs into $(obj).
+
+$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD
+ @$(call do_cmd,cxx,1)
+
+# Try building from generated source, too.
+
+$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD
+ @$(call do_cmd,cxx,1)
+
+$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.cc FORCE_DO_CMD
+ @$(call do_cmd,cxx,1)
+
+# End of this set of suffix rules
+### Rules for final target.
+LDFLAGS_Debug := \
+ -undefined dynamic_lookup \
+ -Wl,-search_paths_first \
+ -mmacosx-version-min=10.7 \
+ -arch arm64 \
+ -L$(builddir) \
+ -stdlib=libc++
+
+LIBTOOLFLAGS_Debug := \
+ -undefined dynamic_lookup \
+ -Wl,-search_paths_first
+
+LDFLAGS_Release := \
+ -undefined dynamic_lookup \
+ -Wl,-search_paths_first \
+ -mmacosx-version-min=10.7 \
+ -arch arm64 \
+ -L$(builddir) \
+ -stdlib=libc++
+
+LIBTOOLFLAGS_Release := \
+ -undefined dynamic_lookup \
+ -Wl,-search_paths_first
+
+LIBS :=
+
+$(builddir)/magic.node: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))
+$(builddir)/magic.node: LIBS := $(LIBS)
+$(builddir)/magic.node: GYP_LIBTOOLFLAGS := $(LIBTOOLFLAGS_$(BUILDTYPE))
+$(builddir)/magic.node: TOOLSET := $(TOOLSET)
+$(builddir)/magic.node: $(OBJS) $(builddir)/magic.a FORCE_DO_CMD
+ $(call do_cmd,solink_module)
+
+all_deps += $(builddir)/magic.node
+# Add target alias
+.PHONY: magic
+magic: $(builddir)/magic.node
+
+# Short alias for building this executable.
+.PHONY: magic.node
+magic.node: $(builddir)/magic.node
+
+# Add executable to "all" target.
+.PHONY: all
+all: $(builddir)/magic.node
+
diff --git a/node_modules/mmmagic/deps/libmagic/AUTHORS b/node_modules/mmmagic/deps/libmagic/AUTHORS
new file mode 100644
index 0000000..3d3d34a
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/AUTHORS
@@ -0,0 +1 @@
+See COPYING. \ No newline at end of file
diff --git a/node_modules/mmmagic/deps/libmagic/COPYING b/node_modules/mmmagic/deps/libmagic/COPYING
new file mode 100644
index 0000000..b3db8b2
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/COPYING
@@ -0,0 +1,29 @@
+$File: COPYING,v 1.1 2008/02/05 19:08:11 christos Exp $
+Copyright (c) Ian F. Darwin 1986, 1987, 1989, 1990, 1991, 1992, 1994, 1995.
+Software written by Ian F. Darwin and others;
+maintained 1994- Christos Zoulas.
+
+This software is not subject to any export provision of the United States
+Department of Commerce, and may be exported to any country or planet.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice immediately at the beginning of the file, without modification,
+ this list of conditions, and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
diff --git a/node_modules/mmmagic/deps/libmagic/ChangeLog b/node_modules/mmmagic/deps/libmagic/ChangeLog
new file mode 100644
index 0000000..2063a23
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/ChangeLog
@@ -0,0 +1,1716 @@
+2017-09-02 11:53 Christos Zoulas <christos@zoulas.com>
+
+ * release 5.32
+
+2017-08-28 16:37 Christos Zoulas <christos@zoulas.com>
+
+ * Always reset state in {file,buffer}_apprentice (Krzysztof Wilczynski)
+
+2017-08-27 03:55 Christos Zoulas <christos@zoulas.com>
+
+ * Fix always true condition (Thomas Jarosch)
+
+2017-05-24 17:30 Christos Zoulas <christos@zoulas.com>
+
+ * pickier parsing of numeric values in magic files.
+
+2017-05-23 17:55 Christos Zoulas <christos@zoulas.com>
+
+ * PR/615 add magic_getflags()
+
+2017-05-23 13:55 Christos Zoulas <christos@zoulas.com>
+
+ * release 5.31
+
+2017-03-17 20:32 Christos Zoulas <christos@zoulas.com>
+
+ * remove trailing spaces from magic files
+ * refactor is_tar
+ * better bounds checks for cdf
+
+2017-02-10 12:24 Christos Zoulas <christos@zoulas.com>
+
+ * release 5.30
+
+2017-02-07 23:27 Christos Zoulas <christos@zoulas.com>
+
+ * If we exceeded the offset in a search return no match
+ (Christoph Biedl)
+ * Be more lenient on corrupt CDF files (Christoph Biedl)
+
+2017-02-04 16:46 Christos Zoulas <christos@zoulas.com>
+
+ * pacify ubsan sign extension (oss-fuzz/524)
+
+2017-02-01 12:42 Christos Zoulas <christos@zoulas.com>
+
+ * off by one in cdf parsing (PR/593)
+ * report debugging sections in elf (PR/591)
+
+2016-11-06 10:52 Christos Zoulas <christos@zoulas.com>
+
+ * Allow @@@ in extensions
+ * Add missing overflow check in der magic (Jonas Wagner)
+
+2016-10-25 10:40 Christos Zoulas <christos@zoulas.com>
+
+ * release 5.29
+
+2016-10-24 11:20 Christos Zoulas <christos@zoulas.com>
+
+ * der getlength overflow (Jonas Wagner)
+ * multiple magic file load failure (Christoph Biedl)
+
+2016-10-17 11:26 Christos Zoulas <christos@zoulas.com>
+
+ * CDF parsing improvements (Guy Helmer)
+
+2016-07-20 7:26 Christos Zoulas <christos@zoulas.com>
+
+ * Add support for signed indirect offsets
+
+2016-07-18 7:41 Christos Zoulas <christos@zoulas.com>
+
+ * cat /dev/null | file - should print empty (Christoph Biedl)
+
+2016-07-05 15:20 Christos Zoulas <christos@zoulas.com>
+
+ * Bump string size from 64 to 96.
+
+2016-06-13 20:20 Christos Zoulas <christos@zoulas.com>
+
+ * PR/556: Fix separators on annotations.
+
+2016-06-13 19:40 Christos Zoulas <christos@zoulas.com>
+
+ * release 5.28
+ * fix leak on allocation failure
+
+2016-06-01 1:20 Christos Zoulas <christos@zoulas.com>
+
+ * PR/555: Avoid overflow for offset > nbytes
+ * PR/550: Segv on DER parsing:
+ - use the correct variable for length
+ - set offset to 0 on failure.
+
+2016-05-13 12:00 Christos Zoulas <christos@zoulas.com>
+
+ * release 5.27
+
+2016-04-18 9:35 Christos Zoulas <christos@zoulas.com>
+
+ * Errors comparing DER entries or computing offsets
+ are just indications of malformed non-DER files.
+ Don't print them.
+ * Offset comparison was off-by-one.
+ * Fix compression code (Werner Fink)
+ * Put new bytes constant in the right file (not the generated one)
+
+2016-04-16 18:34 Christos Zoulas <christos@zoulas.com>
+
+ * release 5.26
+
+2016-03-31 13:50 Christos Zoulas <christos@zoulas.com>
+
+ * make the number of bytes read from files configurable.
+
+2016-03-21 13:40 Christos Zoulas <christos@zoulas.com>
+
+ * Add bounds checks for DER code (discovered by Thomas Jarosch)
+ * Change indirect recursion limit to indirect use count and
+ bump from 15 to 50 to prevent abuse.
+
+2016-03-13 20:39 Christos Zoulas <christos@zoulas.com>
+
+ * Add -00 which prints filename\0description\0
+
+2016-03-01 13:28 Christos Zoulas <christos@zoulas.com>
+
+ * Fix ID3 indirect parsing
+
+2016-01-19 10:18 Christos Zoulas <christos@zoulas.com>
+
+ * add DER parsing capability
+
+2015-11-13 10:35 Christos Zoulas <christos@zoulas.com>
+
+ * provide dprintf(3) for the OS's that don't have it.
+
+2015-11-11 16:25 Christos Zoulas <christos@zoulas.com>
+
+ * redo the compression code report decompression errors
+
+2015-11-10 23:25 Christos Zoulas <christos@zoulas.com>
+
+ * REG_STARTEND code is not working as expected, delete it.
+
+2015-11-09 16:05 Christos Zoulas <christos@zoulas.com>
+
+ * Add zlib support if we have it.
+
+2015-11-05 11:22 Christos Zoulas <christos@zoulas.com>
+
+ * PR/492: compression forking was broken with magic_buffer.
+
+2015-09-16 9:50 Christos Zoulas <christos@zoulas.com>
+
+ * release 5.25
+
+2015-09-11 13:25 Christos Zoulas <christos@zoulas.com>
+
+ * add a limit to the length of regex searches
+
+2015-09-08 9:50 Christos Zoulas <christos@zoulas.com>
+
+ * fix problems with --parameter (Christoph Biedl)
+
+2015-07-11 10:35 Christos Zoulas <christos@zoulas.com>
+
+ * Windows fixes PR/466 (Jason Hood)
+
+2015-07-09 10:35 Christos Zoulas <christos@zoulas.com>
+
+ * release 5.24
+
+2015-06-11 8:52 Christos Zoulas <christos@zoulas.com>
+
+ * redo long option encoding to fix off-by-one in 5.23
+
+2015-06-10 13:50 Christos Zoulas <christos@zoulas.com>
+
+ * release 5.23
+
+2015-06-09 16:10 Christos Zoulas <christos@zoulas.com>
+
+ * Fix issue with regex range for magic with offset
+ * Always return true from mget with USE (success to mget not match
+ indication). Fixes mime evaluation after USE magic
+ * PR/459: Don't insert magic entries to the list if there are parsing
+ errors for them.
+
+2015-06-03 16:00 Christos Zoulas <christos@zoulas.com>
+
+ * PR/455: Add utf-7 encoding
+
+2015-06-03 14:30 Christos Zoulas <christos@zoulas.com>
+
+ * PR/455: Implement -Z, look inside, but don't report on compression
+ * PR/454: Fix allocation error on bad magic.
+
+2015-05-29 10:30 Christos Zoulas <christos@zoulas.com>
+
+ * handle MAGIC_CONTINUE everywhere, not just in softmagic
+
+2015-05-21 14:30 Christos Zoulas <christos@zoulas.com>
+
+ * don't print descriptions for NAME types when mime.
+
+2015-04-09 15:59 Christos Zoulas <christos@zoulas.com>
+
+ * Add --extension to list the known extensions for this file type
+ Idea by Andrew J Roazen
+
+2015-02-14 12:23 Christos Zoulas <christos@zoulas.com>
+
+ * Bump file search buffer size to 1M.
+
+2015-01-09 14:35 Christos Zoulas <christos@zoulas.com>
+
+ * Fix multiple issues with date formats reported by Christoph Biedl:
+ - T_LOCAL meaning was reversed
+ - Arithmetic did not work
+ Also stop adjusting daylight savings for gmt printing.
+
+2015-01-05 13:00 Christos Zoulas <christos@zoulas.com>
+
+ * PR/411: Fix memory corruption from corrupt cdf file.
+
+2015-01-02 15:15 Christos Zoulas <christos@zoulas.com>
+
+ * release 5.22
+
+2015-01-01 12:01 Christos Zoulas <christos@zoulas.com>
+
+ * add indirect relative for TIFF/Exif
+
+2014-12-16 18:10 Christos Zoulas <christos@zoulas.com>
+
+ * restructure elf note printing to avoid repeated messages
+ * add note limit, suggested by Alexander Cherepanov
+
+2014-12-16 16:53 Christos Zoulas <christos@zoulas.com>
+
+ * Bail out on partial pread()'s (Alexander Cherepanov)
+ * Fix incorrect bounds check in file_printable (Alexander Cherepanov)
+
+2014-12-11 20:01 Christos Zoulas <christos@zoulas.com>
+
+ * PR/405: ignore SIGPIPE from uncompress programs
+ * change printable -> file_printable and use it in
+ more places for safety
+ * in ELF, instead of "(uses dynamic libraries)" when PT_INTERP
+ is present print the interpreter name.
+
+2014-12-10 20:01 Christos Zoulas <christos@zoulas.com>
+
+ * release 5.21
+
+2014-11-27 18:40 Christos Zoulas <christos@zoulas.com>
+
+ * Allow setting more parameters from the command line.
+ * Split name/use and indirect magic recursion limits.
+
+2014-11-27 11:12 Christos Zoulas <christos@zoulas.com>
+
+ * Adjust ELF parameters and the default recursion
+ level.
+ * Allow setting the recursion level dynamically.
+
+2014-11-24 8:55 Christos Zoulas <christos@zoulas.com>
+
+ * The following fixes resulted from Thomas Jarosch's fuzzing
+ tests that revealed severe performance issues on pathological
+ input:
+ - limit number of elf program and sections processing
+ - abort elf note processing quickly
+ - reduce the number of recursion levels from 20 to 10
+ - preserve error messages in indirect magic handling
+
+ This is tracked as CVE-2014-8116 and CVE-2014-8117
+
+2014-11-12 10:30 Christos Zoulas <christos@zoulas.com>
+
+ * fix bogus free in the user buffer case.
+
+2014-11-11 12:35 Christos Zoulas <christos@zoulas.com>
+
+ * fix out of bounds read for pascal strings
+ * fix memory leak (not freeing the head of each mlist)
+
+2014-11-07 10:25 Christos Zoulas <christos@zoulas.com>
+
+ * When printing strings from a file, convert them to printable
+ on a byte by byte basis, so that we don't get issues with
+ locale's trying to interpret random byte streams as UTF-8 and
+ having printf error out with EILSEQ.
+
+2014-10-17 11:48 Christos Zoulas <christos@zoulas.com>
+
+ * fix bounds in note reading (Francisco Alonso / Red Hat)
+
+2014-10-11 15:02 Christos Zoulas <christos@zoulas.com>
+
+ * fix autoconf glue for setlocale and locale_t; some OS's
+ have locale_t in xlocale.h
+
+2014-10-10 15:01 Christos Zoulas <christos@zoulas.com>
+
+ * release 5.20
+
+2014-08-17 10:01 Christos Zoulas <christos@zoulas.com>
+
+ * recognize encrypted CDF documents
+
+2014-08-04 9:18 Christos Zoulas <christos@zoulas.com>
+
+ * add magic_load_buffers from Brooks Davis
+
+2014-07-24 16:40 Christos Zoulas <christos@zoulas.com>
+
+ * add thumbs.db support
+
+2014-06-12 12:28 Christos Zoulas <christos@zoulas.com>
+
+ * release 5.19
+
+2014-06-09 9:04 Christos Zoulas <christos@zoulas.com>
+
+ * Misc buffer overruns and missing buffer size tests in cdf parsing
+ (Francisco Alonso, Jan Kaluza)
+
+2014-06-02 14:50 Christos Zoulas <christos@zoulas.com>
+
+ * Enforce limit of 8K on regex searches that have no limits
+ * Allow the l modifier for regex to mean line count. Default
+ to byte count. If line count is specified, assume a max
+ of 80 characters per line to limit the byte count.
+ * Don't allow conversions to be used for dates, allowing
+ the mask field to be used as an offset.
+
+2014-05-30 12:51 Christos Zoulas <christos@zoulas.com>
+
+ * Make the range operator limit the length of the
+ regex search.
+
+2014-05-14 19:23 Christos Zoulas <christos@zoulas.com>
+
+ * PR/347: Windows fixes
+ * PR/352: Hangul word processor recognition
+ * PR/354: Encoding irregularities in text files
+
+2014-05-06 6:12 Christos Zoulas <christos@zoulas.com>
+
+ * Fix uninitialized title in CDF files (Jan Kaluza)
+
+2014-05-04 14:55 Christos Zoulas <christos@zoulas.com>
+
+ * PR/351: Fix compilation of empty files
+
+2014-04-30 17:39 Christos Zoulas <christos@zoulas.com>
+
+ * Fix integer formats: We don't specify 'l' or
+ 'h' and 'hh' specifiers anymore, only 'll' for
+ quads and nothing for the rest. This is so that
+ magic writing is simpler.
+
+2014-04-01 15:25 Christos Zoulas <christos@zoulas.com>
+
+ * PR/341: Jan Kaluza, fix memory leak
+ * PR/342: Jan Kaluza, fix out of bounds read
+
+2014-03-28 15:25 Christos Zoulas <christos@zoulas.com>
+
+ * Fix issue with long formats not matching fmtcheck
+
+2014-03-26 11:25 Christos Zoulas <christos@zoulas.com>
+
+ * release 5.18
+
+2014-03-15 17:45 Christos Zoulas <christos@zoulas.com>
+
+ * add fmtcheck(3) for those who don't have it
+
+2014-03-14 15:12 Christos Zoulas <christos@zoulas.com>
+
+ * prevent mime entries from being attached to magic
+ entries with no descriptions
+
+ * adjust magic strength for regex type
+
+ * remove superfluous ascmagic with encoding test
+
+2014-03-06 12:01 Christos Zoulas <christos@zoulas.com>
+
+ * fix regression fix echo -ne "\012\013\014" | file -i -
+ which printed "binary" instead of "application/octet-stream"
+
+ * add size_t overflow check for magic file size
+
+2014-02-27 16:01 Christos Zoulas <christos@zoulas.com>
+
+ * experimental support for matching with CFD CLSID
+
+2014-02-18 13:04 Kimmo Suominen (kimmo@suominen.com)
+
+ * Cache old LC_CTYPE locale before setting it to "C", so
+ we can use it to restore LC_CTYPE instead of asking
+ setlocale() to scan the environment variables.
+
+2014-02-12 18:21 Christos Zoulas <christos@zoulas.com>
+
+ * Count recursion levels through indirect magic
+
+2014-02-11 10:40 Christos Zoulas <christos@zoulas.com>
+
+ * Prevent infinite recursion on files with indirect offsets of 0
+
+2014-01-30 21:00 Christos Zoulas <christos@zoulas.com>
+
+ * Add -E flag that makes file print filesystem errors to stderr
+ and exit.
+
+2014-01-08 17:20 Christos Zoulas <christos@zoulas.com>
+
+ * mime printing could print results from multiple magic entries
+ if there were multiple matches.
+ * in some cases overflow was not detected when computing offsets
+ in softmagic.
+
+2013-12-05 12:00 Christos Zoulas <christos@zoulas.com>
+
+ * use strcasestr() to for cdf strings
+ * reset to the "C" locale while doing regex operations, or case
+ insensitive comparisons; this is provisional
+
+2013-11-19 20:10 Christos Zoulas <christos@zoulas.com>
+
+ * always leave magic file loaded, don't unload for magic_check, etc.
+ * fix default encoding to binary instead of unknown which broke recently
+ * handle empty and one byte files, less specially so that
+ --mime-encoding does not break completely.
+ `
+2013-11-06 14:40 Christos Zoulas <christos@zoulas.com>
+
+ * fix erroneous non-zero exit code from non-existent file and message
+
+2013-10-29 14:25 Christos Zoulas <christos@zoulas.com>
+
+ * add CDF MSI file detection (Guy Helmer)
+
+2013-09-03 11:56 Christos Zoulas <christos@zoulas.com>
+
+ * Don't mix errors and regular output if there was an error
+ * in magic_descriptor() don't close the file and try to restore
+ its position
+
+2013-05-30 17:25 Christos Zoulas <christos@zoulas.com>
+
+ * Don't treat magic as an error if offset was past EOF (Christoph Biedl)
+
+2013-05-28 17:25 Christos Zoulas <christos@zoulas.com>
+
+ * Fix spacing issues in softmagic and elf (Jan Kaluza)
+
+2013-05-02 18:00 Christos Zoulas <christos@zoulas.com>
+
+ * Fix segmentation fault with multiple magic_load commands.
+
+2013-04-22 11:20 Christos Zoulas <christos@zoulas.com>
+
+ * The way "default" was implemented was not very useful
+ because the "if something was printed at that level"
+ was not easily controlled by the user, and the format
+ was bound to a string which is too restrictive. Add
+ a "clear" for that level keyword and make "default"
+ void. This way one can do:
+
+ >>13 clear x
+ >>13 lelong 1 foo
+ >>13 lelong 2 bar
+ >>13 default x
+ >>>13 lelong x unknown %x
+
+2013-03-25 13:20 Christos Zoulas <christos@zoulas.com>
+
+ * disallow strength setting in "name" entries
+
+2013-03-06 21:24 Christos Zoulas <christos@zoulas.com>
+
+ * fix recursive magic separator printing
+
+2013-02-26 19:28 Christos Zoulas <christos@zoulas.com>
+
+ * limit recursion level for mget
+ * fix pread() related breakage in cdf
+ * handle offsets properly in recursive "use"
+
+2013-02-18 10:39 Christos Zoulas <christos@zoulas.com>
+
+ * add elf reading of debug info to determine if file is stripped
+ (Jan Kaluza)
+ * use pread()
+
+2013-01-25 18:05 Christos Zoulas <christos@zoulas.com>
+
+ * change mime description size from 64 to 80 to accommodate OOXML.
+
+2013-01-11 14:50 Christos Zoulas <christos@zoulas.com>
+
+ * Warn about inconsistent continuation levels.
+ * Change fsmagic to add a space after it prints.
+
+2013-01-10 21:00 Christos Zoulas <christos@zoulas.com>
+
+ * Make getline public so that file can link against it.
+ Perhaps it is better to rename it, or hide it differently.
+ Fixes builds on platforms that do not provide it.
+
+2013-01-07 16:30 Christos Zoulas <christos@zoulas.com>
+
+ * Add SuS d{,1,2,4,8}, u{,1,2,4,8} and document
+ what long, int, short, etc is (Guy Harris)
+
+2013-01-06 11:20 Christos Zoulas <christos@zoulas.com>
+
+ * add magic_version function and constant
+ * Redo memory allocation and de-allocation.
+ (prevents double frees on non mmap platforms)
+ * Fix bug with name/use having to do with passing
+ found state from the parent to the child and back.
+
+2012-12-19 8:47 Christos Zoulas <christos@zoulas.com>
+
+ * Only print elf capabilities for archs we know (Jan Kaluza)
+
+2012-10-30 19:14 Christos Zoulas <christos@zoulas.com>
+
+ * Add "name" and "use" file types in order to look
+ inside mach-o files.
+
+2012-09-06 10:40 Christos Zoulas <christos@zoulas.com>
+
+ * make --version exit 0 (Matthew Schultz)
+ * add string/T (Jan Kaluza)
+
+2012-08-09 2:15 Christos Zoulas <christos@zoulas.com>
+
+ * add z and t modifiers for our own vasprintf
+ * search for $HOME/.magic.mgc if it is there first
+ * fix reads from a pipe, and preserve errno
+
+2012-05-15 13:12 Christos Zoulas <christos@zoulas.com>
+
+ * use ctime_r, asctime_r
+
+2012-04-06 17:18 Christos Zoulas <christos@zoulas.com>
+
+ * Fixes for indirect offsets to handle apple disk formats
+
+2012-04-03 18:26 Christos Zoulas <christos@zoulas.com>
+
+ * Add windows date field types
+ * More info for windows shortcuts (incomplete)
+
+2012-02-20 17:33 Christos Zoulas <christos@zoulas.com>
+
+ * Fix CDF parsing issues found by CERT's fuzzing tool (Will Dormann)
+
+2011-12-15 12:17 Chris Metcalf <cmetcalf@tilera.com>
+
+ * Support Tilera architectures (tile64, tilepro, tilegx).
+
+2011-12-16 16:33 Reuben Thomas <rrt@sc3d.org>
+
+ * Add magic for /usr/bin/env Perl scripts
+ * Weaken generic script magic to avoid clashing with
+ language-specific magic.
+
+2011-12-08 13:37 Reuben Thomas <rrt@sc3d.org>
+
+ * Simplify if (p) free(p) to free(p).
+
+2011-12-08 13:07 Reuben Thomas <rrt@sc3d.org>
+
+ * Remove hardwired token finding (names.h), turning it into soft
+ magic. Patterns are either anchored regexs or search/8192. English
+ language detection and PL/1 detection have been removed as they
+ were too fragile. -e tokens is still accepted for backwards
+ compatibility.
+ * Move 3ds patterns (which are commented out anyway) into autodesk
+ (they were, oddly, in c-lang).
+
+2011-12-06 00:16 Reuben Thomas <rrt@sc3d.org>
+
+ * Tweak strength of generic hash-bang detectors to be less than
+ specific ones.
+ * Make an inconsistent description of Python scripts consistent.
+
+2011-12-05 23:58 Reuben Thomas <rrt@sc3d.org>
+
+ * Fix minor error in file(1).
+
+2011-11-05 00:00 Reuben Thomas <rrt@sc3d.org>
+
+ * Fix issue #150 (I hope).
+
+2011-09-22 12:57 Christos Zoulas <christos@zoulas.com>
+
+ * Python3 binding fixes from Kelly Anderson
+
+2011-09-20 11:32 Christos Zoulas <christos@zoulas.com>
+
+ * If a string type magic entry is marked as text or binary
+ only match text files against text entries and binary
+ files against binary entries.
+
+2011-09-01 12:12 Christos Zoulas <christos@zoulas.com>
+
+ * Don't wait for any subprocess, just the one we forked.
+
+2011-08-26 16:40 Christos Zoulas <christos@zoulas.com>
+
+ * If the application name is not set in a cdf file, try to see
+ if it has a directory with the application name on it.
+
+2011-08-17 14:32 Christos Zoulas <christos@zoulas.com>
+
+ * Fix ELF lseek(2) madness. Inspired by PR/134 by Jan Kaluza
+
+2011-08-14 09:03 Christos Zoulas <christos@zoulas.com>
+
+ * Don't use variable string formats.
+
+2011-07-12 12:32 Reuben Thomas <rrt@sc3d.org>
+
+ * Fix detection of Zip files (Mantis #128).
+ * Make some minor improvements to file(1).
+ * Rename MIME types for filesystem objects for consistency with
+ xdg-utils. Typically this means that application/x-foo becomes
+ inode/foo, but some names also change slightly, e.g.
+ application/x-character-device becomes inode/chardevice.
+
+2011-05-10 20:57 Christos Zoulas <christos@zoulas.com>
+
+ * fix mingw compilation (Abradoks)
+
+2011-05-10 20:57 Christos Zoulas <christos@zoulas.com>
+
+ * remove patchlevel.h
+ * Fix read past allocated memory caused by double-incrementing
+ a pointer in a loop (reported by Roberto Maar)
+
+2011-03-30 15:45 Christos Zoulas <christos@zoulas.com>
+
+ * Fix cdf string buffer setting (Sven Anders)
+
+2011-03-20 16:35 Christos Zoulas <christos@zoulas.com>
+
+ * Eliminate MAXPATHLEN and use dynamic allocation for
+ path and file buffers.
+
+2011-03-15 18:15 Christos Zoulas <christos@zoulas.com>
+
+ * binary tests on magic entries with masks could spuriously
+ get converted to ascii.
+
+2011-03-12 18:06 Reuben Thomas <rrt@sc3d.org>
+
+ * Improve file.man (remove BUGS, present email addresses consistently).
+
+2011-03-07 19:38 Christos Zoulas <christos@zoulas.com>
+
+ * add lrzip support (from Ville Skytta)
+
+2011-02-10 16:36 Christos Zoulas <christos@zoulas.com>
+
+ * fix CDF bounds checking (Guy Helmer)
+
+2011-02-10 12:03 Christos Zoulas <christos@zoulas.com>
+
+ * add cdf_ctime() that prints a meaningful error when time cannot
+ be converted.
+
+2011-02-02 20:40 Christos Zoulas <christos@zoulas.com>
+
+ * help and version output to stdout.
+
+ * When matching softmagic for ascii files, don't just print
+ the softmagic classification, keep going and print the
+ text classification too. This fixes broken troff files when
+ we moved them from keyword recognition to softmagic
+ (they stopped printing "with CRLF" etc.)
+ Reported by Doug McIlroy.
+
+2011-01-16 19:31 Reuben Thomas <rrt@sc3d.org>
+
+ * Fix two potential buffer overruns in apprentice_list.
+
+2011-01-14 22:33 Reuben Thomas <rrt@sc3d.org>
+
+ * New Python binding in pure Python.
+ * Update libmagic(3).
+
+2011-01-06 21:40 Reuben Thomas <rrt@sc3d.org>
+
+ * Fix Python bindings (including recent Python 3 compatibility
+ update).
+
+2011-01-04 18:43 Reuben Thomas <rrt@sc3d.org>
+
+ * magic/Makefile.am: make it easier to recover from magic build failures.
+ * Fix pstring length specifier parsing to avoid generating invalid
+ magic files.
+ * Add pstring length "J" (for "JPEG") to specify that the length
+ include itself.
+ * Fix JPEG comment parsing at last using pstring/HJ!
+ * Ignore section 5 man pages in doc/.cvsignore.
+
+2010-12-22 13:12 Christos Zoulas <christos@zoulas.com>
+
+ * Add pstring/BHhLl to specify the type of the length of pascal
+ strings.
+
+2010-11-26 18:39 Reuben Thomas <rrt@sc3d.org>
+
+ * Fix "-e soft": it was ignored when softmagic was called
+ during asciimagic.
+ * Improve comments and use "unsigned char" in tar.h/is_tar.c.
+
+2010-11-05 17:26 Reuben Thomas <rrt@sc3d.org>
+
+ * Make bug reporting addresses more visible.
+
+2010-11-01 18:35 Reuben Thomas <rrt@sc3d.org>
+
+ * Add tcl magic from Gustaf Neumann
+
+2010-10-24 10:42 Christos Zoulas <christos@zoulas.com>
+
+ * Fix the whitespace comparing code (Christopher Chittleborough)
+
+2010-10-06 21:05 Christos Zoulas <christos@zoulas.com>
+
+ * allow string/t to work (Jan Kaluza)
+
+2010-09-20 22:11 Reuben Thomas <rrt@sc3d.org>
+
+ * Apply some patches from Ubuntu and Fedora.
+
+2010-09-20 21:16 Reuben Thomas <rrt@sc3d.org>
+
+ * Apply all patches from Debian package 5.04-6 which have not
+ already been applied and are not Debian-specific.
+
+2010-09-20 15:24 Reuben Thomas <rrt@sc3d.org>
+
+ * Minor security fix to softmagic.c (don't use untrusted
+ string as printf format).
+
+2010-07-21 12:20 Christos Zoulas <christos@zoulas.com>
+
+ * MINGW32 portability from LRN
+
+ * Don't warn about escaping magic regex chars when we are in a regex.
+
+2010-07-19 10:55 Christos Zoulas <christos@zoulas.com>
+
+ * Only try to print prpsinfo for core files. (Jan Kaluza)
+
+2010-04-22 12:55 Christos Zoulas <christos@zoulas.com>
+
+ * Try more elf offsets for Debian core files. (Arnaud Giersch)
+
+2010-02-20 15:18 Reuben Thomas <rrt@sc3d.org>
+
+ * Clarify which sort of CDF we mean.
+
+2010-02-14 22:58 Reuben Thomas <rrt@sc3d.org>
+
+ * Re-jig Zip file type magic so that unsupported special
+ Zip types (those with "mimetype" at offset 30) can be
+ recognized.
+
+2010-02-02 21:50 Reuben Thomas <rrt@sc3d.org>
+
+ * Add support for OCF (EPUB) files (application/epub+zip)
+
+2010-01-28 18:25 Christos Zoulas <christos@zoulas.com>
+
+ * Fix core-dump from unbound loop:
+ https://bugzilla.redhat.com/show_bug.cgi?id=533245
+
+2010-01-22 15:45 Christos Zoulas <christos@zoulas.com>
+
+ * print proper mime for crystal reports file
+
+ * print the last summary information of a cdf document, not the
+ first so that nested documents print the right info
+
+2010-01-16 18:42 Charles Longeau <chl@tuxfamily.org>
+
+ * bring back some fixes from OpenBSD:
+ - make gcc2 builds file
+ - fix typos in a magic file comment
+
+2009-11-17 18:35 Christos Zoulas <christos@zoulas.com>
+
+ * ctime/asctime can return NULL on some OS's although
+ they should not (Toshit Antani)
+
+2009-09-14 13:49 Christos Zoulas <christos@zoulas.com>
+
+ * Centralize magic path handling routines and remove the
+ special-casing from file.c so that the python module for
+ example comes up with the same magic path (Fixes ~/.magic
+ handling) (from Gab)
+
+2009-09-11 23:38 Reuben Thomas <rrt@sc3d.org>
+
+ * When magic argument is a directory, read the files in
+ strcmp-sorted order (fixes Debian bug #488562 and our own FIXME).
+
+2009-09-11 13:11 Reuben Thomas <rrt@sc3d.org>
+
+ * Combine overlapping epoc and psion magic files into one (epoc).
+
+ * Add some more EPOC MIME types.
+
+2009-08-19 15:55 Christos Zoulas <christos@zoulas.com>
+
+ * Fix 3 bugs (From Ian Darwin):
+ - file_showstr could move one past the end of the array
+ - parse_apple did not nul terminate the string in the overflow case
+ - parse_mime truncated the wrong string in the overflow case
+
+2009-08-12 12:28 Robert Byrnes <byrnes@wildpumpkin.net>
+
+ * Include Localstuff when compiling magic.
+
+2009-07-15 10:05 Christos Zoulas <christos@zoulas.com>
+
+ * Fix logic for including mygetopts.h
+
+ * Make cdf.c compile again with debugging
+
+ * Add the necessary field handling for crystal reports files to work
+
+2009-06-23 01:34 Reuben Thomas <rrt@sc3d.org>
+
+ * Stop "(if" identifying Lisp files, that's plain dumb!
+
+2009-06-09 22:13 Reuben Thomas <rrt@sc3d.org>
+
+ * Add a couple of missing MP3 MIME types.
+
+2009-05-27 23:00 Reuben Thomas <rrt@sc3d.org>
+
+ * Add full range of hash-bang tests for Python and Ruby.
+
+ * Add MIME types for Python and Ruby scripts.
+
+2009-05-13 10:44 Christos Zoulas <christos@zoulas.com>
+
+ * off by one in parsing hw capabilities in elf
+ (Cheng Renquan)
+
+2009-05-08 13:40 Christos Zoulas <christos@zoulas.com>
+
+ * lint fixes and more from NetBSD
+
+2009-05-06 10:25 Christos Zoulas <christos@zoulas.com>
+
+ * Avoid null dereference in cdf code (Drew Yao)
+
+ * More cdf bounds checks and overflow checks
+
+2009-05-01 18:37 Christos Zoulas <christos@zoulas.com>
+
+ * Buffer overflow fixes from Drew Yao
+
+2009-04-30 17:10 Christos Zoulas <christos@zoulas.com>
+
+ * Fix more cdf lossage. All the documents I have
+ right now print the correct information.
+
+2009-03-27 18:43 Christos Zoulas <christos@zoulas.com>
+
+ * don't print \012- separators in the same magic entry
+ if it consists of multiple magic printing lines.
+
+2009-03-23 10:20 Christos Zoulas <christos@zoulas.com>
+
+ * Avoid file descriptor leak in compress code from
+ (Daniel Novotny)
+
+2009-03-18 16:50 Christos Zoulas <christos@zoulas.com>
+
+ * Allow escaping of relation characters, so that we can say \^[A-Z]
+ and the ^ is not eaten as a relation char.
+
+ * Fix troff and fortran to their previous glory using
+ regex. This was broken since their removel from ascmagic.
+
+2009-03-10 16:50 Christos Zoulas <christos@zoulas.com>
+
+ * don't use strlen in strndup() (Toby Peterson)
+
+2009-03-10 7:45 Christos Zoulas <christos@zoulas.com>
+
+ * avoid c99 syntax.
+
+2009-02-23 15:45 Christos Zoulas <christos@zoulas.com>
+
+ * make the cdf code use the buffer first if available,
+ and then the fd code.
+
+2009-02-13 13:45 Christos Zoulas <christos@zoulas.com>
+
+ * look for struct option to determine if getopt.h is usable for IRIX.
+
+ * sanitize cdf document strings
+
+2009-02-04 13:25 Christos Zoulas <christos@zoulas.com>
+
+ * fix OS/2 warnings.
+
+2008-12-12 15:50 Christos Zoulas <christos@zoulas.com>
+
+ * fix initial offset calculation for non 4K sector files
+
+ * add loop limits to avoid DoS attacks by constructing
+ looping sector references.
+
+2008-12-03 13:05 Christos Zoulas <christos@zoulas.com>
+
+ * fix memory botches on cdf file parsing.
+
+ * exit with non-zero value for any error, not just for the last
+ file processed.
+
+2008-11-09 20:42 Charles Longeau <chl@tuxfamily.org>
+
+ * Replace all str{cpy,cat} functions with strl{cpy,cat}
+ * Ensure that strl{cpy,cat} are included in libmagic,
+ as needed.
+
+2008-11-06 18:18 Christos Zoulas <christos@zoulas.com>
+
+ * Handle ID3 format files.
+
+2008-11-06 23:00 Reuben Thomas <rrt@sc3d.org>
+
+ * Fix --mime, --mime-type and --mime-encoding under new scheme.
+
+ * Rename "ascii" to "text" and add "encoding" test.
+
+ * Return a precise ("utf-16le" or "utf-16be") MIME charset for
+ UTF-16.
+
+ * Fix error in comment caused by automatic indentation adding
+ words!
+
+2008-11-06 10:35 Christos Zoulas <christos@astron.com>
+
+ * use memchr instead of strchr because the string
+ might not be NUL terminated (Scott MacVicar)
+
+2008-11-03 07:31 Reuben Thomas <rrt@sc3d.org>
+
+ * Fix a printf with a non-literal format string.
+
+ * Fix formatting and punctuation of help for "--apple".
+
+2008-10-30 11:00 Reuben Thomas <rrt@sc3d.org>
+
+ * Correct words counts in comments of struct magic.
+
+ * Fix handle_annotation to allow both Apple and MIME types to be
+ printed, and to return correct code if MIME type is
+ printed (1, not 0) or if there's an error (-1 not 1).
+
+ * Fix output of charset for MIME type (precede with semi-colon;
+ fixes Debian bug #501460).
+
+ * Fix potential attacks via conversion specifications in magic
+ strings.
+
+ * Add a FIXME for Debian bug #488562 (magic files should be
+ read in a defined order, by sorting the names).
+
+2008-10-18 16:45 Christos Zoulas <christos@astron.com>
+
+ * Added APPLE file creator/type
+
+2008-10-12 10:20 Christos Zoulas <christos@astron.com>
+
+ * Added CDF parsing
+
+2008-10-09 16:40 Christos Zoulas <christos@astron.com>
+
+ * filesystem and msdos patches (Joerg Jenderek)
+
+2008-10-09 13:20 Christos Zoulas <christos@astron.com>
+
+ * correct --exclude documentation issues: remove troff and fortran
+ and rename "token" to "tokens". (Randy McMurchy)
+
+2008-10-01 10:30 Christos Zoulas <christos@astron.com>
+
+ * Read ~/.magic in addition to the default magic file not instead
+ of, as documented in the man page.
+
+2008-09-10 21:30 Reuben Thomas <rrt@sc3d.org>
+
+ * Comment out graphviz patterns, as they match too many files.
+
+2008-08-30 12:54 Christos Zoulas <christos@astron.com>
+
+ * Don't eat trailing \n in magic enties.
+
+ * Cast defines to allow compilation using a c++ compiler.
+
+2008-08-25 23:56 Reuben Thomas <rrt@sc3d.org>
+
+ * Add text/x-lua MIME type for Lua scripts.
+
+ * Escape { in regex in graphviz patterns.
+
+2008-07-26 00:59 Reuben Thomas <rrt@sc3d.org>
+
+ * Add MIME types for special files.
+
+ * Use access to give more accurate information for files that
+ can't be opened.
+
+ * Add a TODO list.
+
+2008-07-02 11:15 Christos Zoulas <christos@astron.com>
+
+ * add !:strength op to adjust magic strength (experimental)
+
+2008-06-16 21:41 Reuben Thomas <rrt@sc3d.org>
+
+ * Fix automake error in configure.ac.
+
+ * Add MIME type for Psion Sketch files.
+
+2008-06-05 08:59 Christos Zoulas <christos@astron.com>
+
+ * Don't print warnings about bad namesize in stripped
+ binaries with PT_NOTE is still there, and the actual
+ note is gone (Jakub Jelinek)
+
+2008-05-28 15:12 Robert Byrnes <byrnes@wildpumpkin.net>
+
+ * magic/Magdir/elf:
+ Note invalid byte order for little-endian SPARC32PLUS.
+ Add SPARC V9 vendor extensions and memory model.
+
+ * src/elfclass.h:
+ Pass target machine to doshn (for Solaris hardware capabilities).
+
+ * src/readelf.c (doshn):
+ Add support for Solaris hardware/software capabilities.
+
+ * src/readelf.h:
+ Ditto.
+
+ * src/vasprintf.c (dispatch):
+ Add support for ll modifier.
+
+2008-05-16 10:25 Christos Zoulas <christos@astron.com>
+
+ * Fix compiler warnings.
+
+ * remove stray printf, and fix a vprintf bug. (Martin Dorey)
+
+2008-05-06 00:13 Robert Byrnes <byrnes@wildpumpkin.net>
+
+ * src/Makefile.am:
+ Ensure that getopt_long and [v]asprintf are included in libmagic,
+ as needed.
+
+ Remove unnecessary EXTRA_DIST.
+
+ * src/Makefile.in:
+ Rerun automake.
+
+ * src/vasprintf.c (dispatch):
+ Fix variable precision bug: be sure to step past '*'.
+
+ * src/vasprintf.c (core):
+ Remove unreachable code.
+
+ * src/apprentice.c (set_test_type):
+ Add cast to avoid compiler warning.
+
+2008-04-22 23:45 Christos Zoulas <christos@astron.com>
+
+ * Add magic submission guidelines (Abel Cheung)
+
+ * split msdos and windows magic (Abel Cheung)
+
+2008-04-04 11:00 Christos Zoulas <christos@astron.com>
+
+ * >= <= is not supported, so fix the magic and warn about it.
+ reported by: Thien-Thi Nguyen <ttn@gnuvola.org>
+
+2008-03-27 16:16 Robert Byrnes <byrnes@wildpumpkin.net>
+
+ * src/readelf.c (donote):
+ ELF core file command name/line bug fixes and enhancements:
+
+ Try larger offsets first to avoid false matches
+ from earlier data that happen to look like strings;
+ this primarily affected SunOS 5.x 32-bit Intel core files.
+
+ Add support for command line (instead of just short name)
+ for SunOS 5.x.
+
+ Add information about NT_PSINFO for SunOS 5.x.
+
+ Only trim whitespace from end of command line.
+
+2007-02-11 01:36 Reuben Thomas <rrt@sc3d.org>
+
+ * Change strength of ! from MULT to 0, as it matches almost
+ anything (Reuben Thomas)
+
+ * Debian fixes (Reuben Thomas)
+
+2007-02-11 00:17 Reuben Thomas <rrt@sc3d.org>
+
+ * Clarify UTF-8 BOM message (Reuben Thomas)
+
+ * Add HTML comment to token list in names.h
+
+2007-02-04 15:50 Christos Zoulas <christos@astron.com>
+
+ * Debian fixes (Reuben Thomas)
+
+2007-02-04 11:31 Christos Zoulas <christos@astron.com>
+
+ * !:mime annotations in magic files (Reuben Thomas)
+
+2007-01-29 15:35 Christos Zoulas <christos@astron.com>
+
+ * zero out utime/utimes structs (Gavin Atkinson)
+
+2007-01-26 13:45 Christos Zoulas <christos@astron.com>
+
+ * reduce writable data from Diego "Flameeyes" Petten
+
+2007-12-28 15:06 Christos Zoulas <christos@astron.com>
+
+ * strtof detection
+
+ * remove bogus regex magic that could cause a DoS
+
+ * better mismatch version message
+
+2007-12-27 11:35 Christos Zoulas <christos@astron.com>
+
+ * bring back some fixes from OpenBSD
+
+ * treat ELF dynamic objects as executables
+
+ * fix gcc warnings
+
+2007-12-01 19:55 Christos Zoulas <christos@astron.com>
+
+ * make sure we have zlib.h and libz to compile the builtin
+ decompress code
+
+2007-10-28 20:48 Christos Zoulas <christos@astron.com>
+
+ * float and double magic support (Behan Webster)
+
+2007-10-28 20:48 Christos Zoulas <christos@astron.com>
+
+ * Convert fortran to a soft test (Reuben Thomas)
+
+2007-10-23 5:25 Christos Zoulas <christos@astron.com>
+
+ * Add --with-filename, and --no-filename (Reuben Thomas)
+
+2007-10-23 3:59 Christos Zoulas <christos@astron.com>
+
+ * Rest of the mime split (Reuben Thomas)
+
+ * Make usage message generated from the flags so that
+ they stay consistent (Reuben Thomas)
+
+2007-10-20 3:06 Christos Zoulas <christos@astron.com>
+
+ * typo in comment, missing ifdef QUICK, remove unneeded code
+ (Charles Longeau)
+
+2007-10-17 3:33 Christos Zoulas <christos@astron.com>
+
+ * Fix problem printing -\012 in some entries
+
+ * Separate magic type and encoding flags (Reuben Thomas)
+
+2007-10-09 3:55 Christos Zoulas <christos@astron.com>
+
+ * configure fix for int64 and strndup (Reuben Thomas)
+
+2007-09-26 4:45 Christos Zoulas <christos@astron.com>
+
+ * Add magic_descriptor() function.
+
+ * Fix regression in elf reading code where the core name was
+ not being printed.
+
+ * Don't convert NUL's to spaces in {l,b}estring16 (Daniel Dawson)
+
+2007-08-19 6:30 Christos Zoulas <christos@astron.com>
+
+ * Make mime format consistent so that it can
+ be easily parsed:
+ mimetype [charset=character-set] [encoding=encoding-mime-type]
+
+ Remove spurious extra text from some MIME type printouts
+ (mostly in is_tar).
+
+ Fix one case where -i produced nothing at all (for a 1-byte file,
+ which is now classed as application/octet-stream).
+
+ Remove 7/8bit classifications, since they were arbitrary
+ and not based on the file data.
+
+ This work was done by Reuben Thomas
+
+2007-05-24 10:00 Christos Zoulas <christos@astron.com>
+
+ * Fix another integer overflow (Colin Percival)
+
+2007-03-26 13:58 Christos Zoulas <christos@astron.com>
+
+ * make sure that all of struct magic_set is initialized appropriately
+ (Brett)
+
+2007-03-25 17:44 Christos Zoulas <christos@astron.com>
+
+ * reset left bytes in the buffer (Dmitry V. Levin)
+
+ * compilation failed with COMPILE_ONLY and ENABLE_CONDITIONALS
+ (Peter Avalos)
+
+2007-03-15 10:51 Christos Zoulas <christos@astron.com>
+
+ * fix fortran and nroff reversed tests (Dmitry V. Levin)
+
+ * fix exclude option (Dmitry V. Levin)
+
+2007-02-08 17:30 Christos Zoulas <christos@astron.com>
+
+ * fix integer underflow in file_printf which can lead to
+ to exploitable heap overflow (Jean-Sebastien Guay-Lero)
+
+2007-02-05 11:35 Christos Zoulas <christos@astron.com>
+
+ * make socket/pipe reading more robust
+
+2007-01-25 16:01 Christos Zoulas <christos@astron.com>
+
+ * Centralize all the tests in file_buffer.
+
+ * Add exclude flag.
+
+2007-01-18 05:29 Anon Ymous <do@not.spam.me>
+
+ * Move the "type" detection code from parse() into its own table
+ driven routine. This avoids maintaining multiple lists in
+ file.h.
+
+ * Add an optional conditional field (ust before the type field).
+ This code is wrapped in "#ifdef ENABLE_CONDITIONALS" as it is
+ likely to go away.
+
+2007-01-16 23:24 Anon Ymous <do@not.spam.me>
+
+ * Fix an initialization bug in check_mem().
+
+2007-01-16 14:58 Anon Ymous <do@not.spam.me>
+
+ * Add a "default" type to print a message if nothing previously
+ matched at that level or since the last default at that
+ level. This is useful for setting up switch-like statements.
+ It can also be used to do if/else constructions without a
+ redundant second test.
+
+ * Fix the "x" special case test so that one can test for that
+ string with "=x".
+
+ * Allow "search" to search the entire buffer if the "/N"
+ search count is missing.
+
+ * Make "regex" work! It now starts its search at the
+ specified offset and takes an (optional) "/N" line count to
+ specify the search range; otherwise it searches to the end
+ of the file. The match is now grabbed correctly for format
+ strings and the offset set to the end of the match.
+
+ * Add a "/s" flag to "regex" and "search" to set the offset to
+ the start of the match. By default the offset is set to the
+ end of the match, as it is with other tests. This is mostly
+ useful for "regex".
+
+ * Make "search", "string" and "pstring" use the same
+ file_strncmp() routine so that they support the same flags;
+ "bestring16" and "lestring16" call the same routine, but
+ with flags = 0. Also add a "/C" flag (in analogy to "/c")
+ to ignore the case on uppercase (lowercase) characters in
+ the test string.
+
+ * Strict adherence to C style string escapes. A warnings are
+ printed when compiling. Note: previously "\a" was
+ incorrectly translated to 'a' instead of an <alert> (i.e.,
+ BELL, typically 0x07).
+
+ * Make this compile with "-Wall -Wextra" and all the warning
+ flags used with WARNS=4 in the NetBSD source. Also make it
+ pass lint.
+
+ * Many "cleanups" and hopefully not too many new bugs!
+
+2007-01-16 14:56 Anon Ymous <do@not.spam.me>
+
+ * make several more files compile with gcc warnings
+ on and also make them pass lint.
+
+2007-01-16 14:54 Anon Ymous <do@not.spam.me>
+
+ * fix a puts()/putc() usage goof in file.c
+
+ * make file.c compile with gcc warnings and pass lint
+
+2006-12-11 16:49 Christos Zoulas <christos@astron.com>
+
+ * fix byteswapping issue
+
+ * report the number of bytes we tried to
+ allocate when allocation fails
+
+ * add a few missed cases in the strength routine
+
+2006-12-08 16:32 Christos Zoulas <christos@astron.com>
+
+ * store and print the line number of the magic
+ entry for debugging.
+
+ * if the magic entry did not print anything,
+ don't treat it as a match
+
+ * change the magic strength algorithm to take
+ into account the relationship op.
+
+ * fix a bug in search where we could accidentally
+ return a match.
+
+ * propagate the error return from match to
+ file_softmagic.
+
+2006-11-25 13:35 Christos Zoulas <christos@astron.com>
+
+ * Don't store the current offset in the magic
+ struct, because it needs to be restored and
+ it was not done properly all the time. Bug
+ found by: Arkadiusz Miskiewicz
+
+ * Fix problem in the '\0' separator; and don't
+ print it as an additional separator; print
+ it as the only separator.
+
+2006-11-17 10:51 Christos Zoulas <christos@astron.com>
+
+ * Added a -0 option to print a '\0' separator
+ Etienne Buira <etienne.buira@free.fr>
+
+2006-10-31 15:14 Christos Zoulas <christos@astron.com>
+
+ * Check offset before copying (Mike Frysinger)
+
+ * merge duplicated code
+
+ * add quad date support
+
+ * make sure that we nul terminate desc (Ryoji Kanai)
+
+ * don't process elf notes multiple times
+
+ * allow -z to report empty compressed files
+
+ * use calloc to initialize the ascii buffers (Jos van den Oever)
+
+2006-06-08 11:11 Christos Zoulas <christos@astron.com>
+
+ * QNX fixes (Mike Gorchak)
+
+ * Add quad support.
+
+ * FIFO checks (Dr. Werner Fink)
+
+ * Linux ELF fixes (Dr. Werner Fink)
+
+ * Magic format checks (Dr. Werner Fink)
+
+ * Magic format function improvent (Karl Chen)
+
+2006-05-03 11:11 Christos Zoulas <christos@astron.com>
+
+ * Pick up some elf changes and some constant fixes from SUSE
+
+ * Identify gnu tar vs. posix tar
+
+ * When keep going, don't print spurious newlines (Radek Vokal)
+
+2006-04-01 12:02 Christos Zoulas <christos@astron.com>
+
+ * Use calloc instead of malloc (Mike Frysinger)
+
+ * Fix configure script to detect wctypes.h (Mike Frysinger)
+
+2006-03-02 16:06 Christos Zoulas <christos@astron.com>
+
+ * Print empty if the file is (Mike Frysinger)
+
+ * Don't try to read past the end of the buffer (Mike Frysinger)
+
+ * Sort magic entries by strength [experimental]
+
+2005-11-29 13:26 Christos Zoulas <christos@astron.com>
+
+ * Use iswprint() to convert the output string.
+ (Bastien Nocera)
+
+2005-10-31 8:54 Christos Zoulas <christos@astron.com>
+
+ * Fix regression where the core info was not completely processed
+ (Radek Vokal)
+
+2005-10-20 11:15 Christos Zoulas <christos@astron.com>
+
+ * Middle Endian magic (Diomidis Spinellis)
+
+2005-10-17 11:15 Christos Zoulas <christos@astron.com>
+
+ * Open with O_BINARY for CYGWIN (Corinna Vinschen)
+
+ * Don't close stdin (Arkadiusz Miskiewicz)
+
+ * Look for note sections in non executables.
+
+2005-09-20 13:33 Christos Zoulas <christos@astron.com>
+
+ * Don't print SVR4 Style in core files multiple times
+ (Radek Vokal)
+
+2005-08-27 04:09 Christos Zoulas <christos@astron.com>
+
+ * Cygwin changes Corinna Vinschen
+
+2005-08-18 09:53 Christos Zoulas <christos@astron.com>
+
+ * Remove erroreous mention of /etc/magic in the file man page
+ This is gentoo bug 101639. (Mike Frysinger)
+
+ * Cross-compile support and detection (Mike Frysinger)
+
+2005-08-12 10:17 Christos Zoulas <christos@astron.com>
+
+ * Add -h flag and dereference symlinks if POSIXLY_CORRECT
+ is set.
+
+2005-07-29 13:57 Christos Zoulas <christos@astron.com>
+
+ * Avoid search and regex buffer overflows (Kelledin)
+
+2005-07-12 11:48 Christos Zoulas <christos@astron.com>
+
+ * Provide stub implementations for {v,}nsprintf() for older
+ OS's that don't have them.
+ * Change mbstate_t autoconf detection macro from AC_MBSTATE_T
+ to AC_TYPE_MBSTATE_T.
+
+2005-06-25 11:48 Christos Zoulas <christos@astron.com>
+
+ * Dynamically allocate the string buffers and make the
+ default read size 256K.
+
+2005-06-01 00:00 Joerg Sonnenberger <joerg@britannica.bec.de>
+
+ * Dragonfly ELF note support
+
+2005-03-14 00:00 Giuliano Bertoletti <gb@symbolic.it>
+
+ * Avoid NULL pointer dereference in time conversion.
+
+2005-03-06 00:00 Joerg Walter <jwalt@mail.garni.ch>
+
+ * Add indirect magic offset support, and search mode.
+
+2005-01-12 00:00 Stepan Kasal <kasal@ucw.cz>
+
+ * src/ascmagic.c (file_ascmagic): Fix three bugs about text files:
+ If a CRLF text file happens to have CR at offset HOWMANY - 1
+ (currently 0xffff), it should not be counted as CR line
+ terminator.
+ If a line has length exactly MAXLINELEN, it should not yet be
+ treated as a ``very long line'', as MAXLINELEN is ``longest sane
+ line length''.
+ With CRLF, the line length was not computed correctly, and even
+ lines of length MAXLINELEN - 1 were treated as ``very long''.
+
+2004-12-07 14:15 Christos Zoulas <christos@astron.com>
+
+ * bzip2 needs a lot of input buffer space on some files
+ before it can begin uncompressing. This makes file -z
+ fail on some bz2 files. Fix it by giving it a copy of
+ the file descriptor to read as much as it wants if we
+ have access to it. <christos@astron.com>
+
+2004-11-24 12:39 Christos Zoulas <christos@astron.com>
+
+ * Stack smash fix, and ELF more conservative reading.
+ Jakub Bogusz <qboosh@pld-linux.org>
+
+2004-11-20 18:50 Christos Zoulas <christos@astron.com>
+
+ * New FreeBSD version parsing code:
+ Jon Noack <noackjr@alumni.rice.edu>
+
+ * Hackish support for ucs16 strings <christos@astron.com>
+
+2004-11-13 03:07 Christos Zoulas <christos@astron.com>
+
+ * print the file name and line number in syntax errors.
+
+2004 10-12 10:50 Christos Zoulas <christos@astron.com>
+
+ * Fix stack overwriting on 0 length strings: Tim Waugh
+ <twaugh@redhat.com> Ned Ludd <solar@gentoo.org>
+
+2004-09-27 11:30 Christos Zoulas <christos@astron.com>
+
+ * Remove 3rd and 4th copyright clause; approved by Ian Darwin.
+
+ * Fix small memory leaks; caught by: Tamas Sarlos
+ <stamas@csillag.ilab.sztaki.hu>
+
+2004-07-24 16:33 Christos Zoulas <christos@astron.com>
+
+ * magic.mime update Danny Milosavljevic <danny.milo@gmx.net>
+
+ * FreeBSD version update Oliver Eikemeier <eikemeier@fillmore-labs.com>
+
+ * utime/utimes detection Ian Lance Taylor <ian@wasabisystems.com>
+
+ * errors reading elf magic Jakub Bogusz <qboosh@pld-linux.org>
+
+2004-04-12 10:55 Christos Zoulas <christos@astron.com>
+
+ * make sure that magic formats match magic types during compilation
+
+ * fix broken sgi magic file
+
+2004-04-06 20:36 Christos Zoulas <christos@astron.com>
+
+ * detect present of mbstate_t Petter Reinholdtsen <pere@hungry.com>
+
+ * magic fixes
+
+2004-03-22 15:25 Christos Zoulas <christos@astron.com>
+
+ * Lots of mime fixes
+ (Joerg Ostertag) <ostertag@rechengilde.de>
+
+ * FreeBSD ELF version handling
+ (Edwin Groothuis) <edwin@mavetju.org>
+
+ * correct cleanup in all cases; don't just close the file.
+ (Christos Zoulas) <christos@astron.com>
+
+ * add gettext message catalogue support
+ (Michael Piefel) <piefel@debian.org>
+
+ * better printout for unreadable files
+ (Michael Piefel) <piefel@debian.org>
+
+ * compensate for missing MAXPATHLEN
+ (Michael Piefel) <piefel@debian.org>
+
+ * add wide character string length computation
+ (Michael Piefel) <piefel@debian.org>
+
+ * Avoid infinite loops caused by bad elf alignments
+ or name and description note sizes. Reported by
+ (Mikael Magnusson) <mmikael@comhem.se>
+
+2004-03-09 13:55 Christos Zoulas <christos@astron.com>
+
+ * Fix possible memory leak on error and add missing regfree
+ (Dmitry V. Levin) <ldv@altlinux.org>
+
+2003-12-23 12:12 Christos Zoulas <christos@astron.com>
+
+ * fix -k flag (Maciej W. Rozycki)
+
+2003-11-18 14:10 Christos Zoulas <christos@astron.com>
+
+ * Try to give us much info as possible on corrupt elf files.
+ (Willy Tarreau) <willy@w.ods.org>
+ * Updated python bindings (Brett Funderburg)
+ <brettf@deepfile.com>
+
+2003-11-11 15:03 Christos Zoulas <christos@astron.com>
+
+ * Include file.h first, because it includes config.h
+ breaks largefile test macros otherwise.
+ (Paul Eggert <eggert@CS.UCLA.EDU> via
+ Lars Hecking <lhecking@nmrc.ie>)
+
+2003-10-14 21:39 Christos Zoulas <christos@astron.com>
+
+ * Python bindings (Brett Funderburg) <brettf@deepfile.com>
+ * Don't lookup past the end of the buffer
+ (Chad Hanson) <chanson@tcs-sec.com>
+ * Add MAGIC_ERROR and api on magic_errno()
+
+2003-10-08 12:40 Christos Zoulas <christos@astron.com>
+
+ * handle error conditions from compile as fatal
+ (Antti Kantee) <pooka@netbsd.org>
+ * handle magic filename parsing sanely
+ * more magic fixes.
+ * fix a memory leak (Illes Marton) <illes.marton@balabit.hu>
+ * describe magic file handling
+ (Bryan Henderson) <bryanh@giraffe-data.com>
+
+2003-09-12 15:09 Christos Zoulas <christos@astron.com>
+
+ * update magic files.
+ * remove largefile support from file.h; it breaks things on most OS's
+
+2003-08-10 10:25 Christos Zoulas <christos@astron.com>
+
+ * fix unmapping'ing of mmaped files.
+
+2003-07-10 12:03 Christos Zoulas <christos@astron.com>
+
+ * don't exit with -1 on error; always exit 1 (Marty Leisner)
+ * restore utimes code.
+
+2003-06-10 17:03 Christos Zoulas <christos@astron.com>
+
+ * make sure we don't access uninitialized memory.
+ * pass lint
+ * #ifdef __cplusplus in magic.h
+
+2003-05-25 19:23 Christos Zoulas <christos@astron.com>
+
+ * rename cvs magic file to revision to deal with
+ case insensitive filesystems.
+
+2003-05-23 17:03 Christos Zoulas <christos@astron.com>
+
+ * documentation fixes from Michael Piefel <piefel@debian.org>
+ * magic fixes (various)
+ * revert basename magic in .mgc name determination
+ * buffer protection in uncompress,
+ signness issues,
+ close files
+ Maciej W. Rozycki <macro@ds2.pg.gda.pl
+
+2003-04-21 20:12 Christos Zoulas <christos@astron.com>
+
+ * fix zsh magic
+
+2003-04-04 16:59 Christos Zoulas <christos@astron.com>
+
+ * fix operand sort order in string.
+
+2003-04-02 17:30 Christos Zoulas <christos@astron.com>
+
+ * cleanup namespace in magic.h
+
+2003-04-02 13:50 Christos Zoulas <christos@astron.com>
+
+ * Magic additions (Alex Ott)
+ * Fix bug that broke VPATH compilation (Peter Breitenlohner)
+
+2003-03-28 16:03 Christos Zoulas <christos@astron.com>
+
+ * remove packed attribute from magic struct.
+ * make the magic struct properly aligned.
+ * bump version number of compiled files to 2.
+
+2003-03-27 13:10 Christos Zoulas <christos@astron.com>
+
+ * separate tar detection and run it before softmagic.
+ * fix reversed symlink test.
+ * fix version printing.
+ * make separator a string instead of a char.
+ * update manual page and sort options.
+
+2003-03-26 11:00 Christos Zoulas <christos@astron.com>
+
+ * Pass lint
+ * make NULL in magic_file mean stdin
+ * Fix "-" argument to file to pass NULL to magic_file
+ * avoid pointer casts by using memcpy
+ * rename magic_buf -> magic_buffer
+ * keep only the first error
+ * manual page: new sentence, new line
+ * fix typo in api function (magic_buf -> magic_buffer)
diff --git a/node_modules/mmmagic/deps/libmagic/INSTALL b/node_modules/mmmagic/deps/libmagic/INSTALL
new file mode 100644
index 0000000..7d1c323
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/INSTALL
@@ -0,0 +1,365 @@
+Installation Instructions
+*************************
+
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+
+ Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved. This file is offered as-is,
+without warranty of any kind.
+
+Basic Installation
+==================
+
+ Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package. The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package. Some packages provide this
+`INSTALL' file but do not implement all of the features documented
+below. The lack of an optional feature in a given package is not
+necessarily a bug. More recommendations for GNU packages can be found
+in *note Makefile Conventions: (standards)Makefile Conventions.
+
+ The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation. It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions. Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+ It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring. Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.
+
+ If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release. If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+ The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'. You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
+
+ The simplest way to compile this package is:
+
+ 1. `cd' to the directory containing the package's source code and type
+ `./configure' to configure the package for your system.
+
+ Running `configure' might take a while. While running, it prints
+ some messages telling which features it is checking for.
+
+ 2. Type `make' to compile the package.
+
+ 3. Optionally, type `make check' to run any self-tests that come with
+ the package, generally using the just-built uninstalled binaries.
+
+ 4. Type `make install' to install the programs and any data files and
+ documentation. When installing into a prefix owned by root, it is
+ recommended that the package be configured and built as a regular
+ user, and only the `make install' phase executed with root
+ privileges.
+
+ 5. Optionally, type `make installcheck' to repeat any self-tests, but
+ this time using the binaries in their final installed location.
+ This target does not install anything. Running this target as a
+ regular user, particularly if the prior `make install' required
+ root privileges, verifies that the installation completed
+ correctly.
+
+ 6. You can remove the program binaries and object files from the
+ source code directory by typing `make clean'. To also remove the
+ files that `configure' created (so you can compile the package for
+ a different kind of computer), type `make distclean'. There is
+ also a `make maintainer-clean' target, but that is intended mainly
+ for the package's developers. If you use it, you may have to get
+ all sorts of other programs in order to regenerate files that came
+ with the distribution.
+
+ 7. Often, you can also type `make uninstall' to remove the installed
+ files again. In practice, not all packages have tested that
+ uninstallation works correctly, even though it is required by the
+ GNU Coding Standards.
+
+ 8. Some packages, particularly those that use Automake, provide `make
+ distcheck', which can by used by developers to test that all other
+ targets like `make install' and `make uninstall' work correctly.
+ This target is generally not run by end users.
+
+Compilers and Options
+=====================
+
+ Some systems require unusual options for compilation or linking that
+the `configure' script does not know about. Run `./configure --help'
+for details on some of the pertinent environment variables.
+
+ You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment. Here
+is an example:
+
+ ./configure CC=c99 CFLAGS=-g LIBS=-lposix
+
+ *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+ You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory. To do this, you can use GNU `make'. `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script. `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'. This
+is known as a "VPATH" build.
+
+ With a non-GNU `make', it is safer to compile the package for one
+architecture at a time in the source code directory. After you have
+installed the package for one architecture, use `make distclean' before
+reconfiguring for another architecture.
+
+ On MacOS X 10.5 and later systems, you can create libraries and
+executables that work on multiple system types--known as "fat" or
+"universal" binaries--by specifying multiple `-arch' options to the
+compiler but only a single `-arch' option to the preprocessor. Like
+this:
+
+ ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+ CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+ CPP="gcc -E" CXXCPP="g++ -E"
+
+ This is not guaranteed to produce working output in all cases, you
+may have to build one architecture at a time and combine the results
+using the `lipo' tool if you have problems.
+
+Installation Names
+==================
+
+ By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc. You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX', where PREFIX must be an
+absolute file name.
+
+ You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files. If you
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
+
+ In addition, if you use an unusual directory layout you can give
+options like `--bindir=DIR' to specify different values for particular
+kinds of files. Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them. In general, the
+default for these options is expressed in terms of `${prefix}', so that
+specifying just `--prefix' will affect all of the other directory
+specifications that were not explicitly provided.
+
+ The most portable way to affect installation locations is to pass the
+correct locations to `configure'; however, many packages provide one or
+both of the following shortcuts of passing variable assignments to the
+`make install' command line to change installation locations without
+having to reconfigure or recompile.
+
+ The first method involves providing an override variable for each
+affected directory. For example, `make install
+prefix=/alternate/directory' will choose an alternate location for all
+directory configuration variables that were expressed in terms of
+`${prefix}'. Any directories that were specified during `configure',
+but not in terms of `${prefix}', must each be overridden at install
+time for the entire installation to be relocated. The approach of
+makefile variable overrides for each directory variable is required by
+the GNU Coding Standards, and ideally causes no recompilation.
+However, some platforms have known limitations with the semantics of
+shared libraries that end up requiring recompilation when using this
+method, particularly noticeable in packages that use GNU Libtool.
+
+ The second method involves providing the `DESTDIR' variable. For
+example, `make install DESTDIR=/alternate/directory' will prepend
+`/alternate/directory' before all installation names. The approach of
+`DESTDIR' overrides is not required by the GNU Coding Standards, and
+does not work on platforms that have drive letters. On the other hand,
+it does better at avoiding recompilation issues, and works well even
+when some directory options were not specified in terms of `${prefix}'
+at `configure' time.
+
+Optional Features
+=================
+
+ If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+ Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System). The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+ For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+ Some packages offer the ability to configure how verbose the
+execution of `make' will be. For these packages, running `./configure
+--enable-silent-rules' sets the default to minimal output, which can be
+overridden with `make V=1'; while running `./configure
+--disable-silent-rules' sets the default to verbose, which can be
+overridden with `make V=0'.
+
+Particular systems
+==================
+
+ On HP-UX, the default C compiler is not ANSI C compatible. If GNU
+CC is not installed, it is recommended to use the following options in
+order to use an ANSI C compiler:
+
+ ./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
+
+and if that doesn't work, install pre-built binaries of GCC for HP-UX.
+
+ On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
+parse its `<wchar.h>' header file. The option `-nodtk' can be used as
+a workaround. If GNU CC is not installed, it is therefore recommended
+to try
+
+ ./configure CC="cc"
+
+and if that doesn't work, try
+
+ ./configure CC="cc -nodtk"
+
+ On Solaris, don't put `/usr/ucb' early in your `PATH'. This
+directory contains several dysfunctional programs; working variants of
+these programs are available in `/usr/bin'. So, if you need `/usr/ucb'
+in your `PATH', put it _after_ `/usr/bin'.
+
+ On Haiku, software installed for all users goes in `/boot/common',
+not `/usr/local'. It is recommended to use the following options:
+
+ ./configure --prefix=/boot/common
+
+Specifying the System Type
+==========================
+
+ There may be some features `configure' cannot figure out
+automatically, but needs to determine by the type of machine the package
+will run on. Usually, assuming the package is built to be run on the
+_same_ architectures, `configure' can figure that out, but if it prints
+a message saying it cannot guess the machine type, give it the
+`--build=TYPE' option. TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+ CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+ OS
+ KERNEL-OS
+
+ See the file `config.sub' for the possible values of each field. If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+ If you are _building_ compiler tools for cross-compiling, you should
+use the option `--target=TYPE' to select the type of system they will
+produce code for.
+
+ If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+Sharing Defaults
+================
+
+ If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists. Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+ Variables not defined in a site shell script can be set in the
+environment passed to `configure'. However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost. In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'. For example:
+
+ ./configure CC=/usr/local2/bin/gcc
+
+causes the specified `gcc' to be used as the C compiler (unless it is
+overridden in the site shell script).
+
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf bug. Until the bug is fixed you can use this workaround:
+
+ CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+`configure' Invocation
+======================
+
+ `configure' recognizes the following options to control how it
+operates.
+
+`--help'
+`-h'
+ Print a summary of all of the options to `configure', and exit.
+
+`--help=short'
+`--help=recursive'
+ Print a summary of the options unique to this package's
+ `configure', and exit. The `short' variant lists options used
+ only in the top level, while the `recursive' variant lists options
+ also present in any nested packages.
+
+`--version'
+`-V'
+ Print the version of Autoconf used to generate the `configure'
+ script, and exit.
+
+`--cache-file=FILE'
+ Enable the cache: use and save the results of the tests in FILE,
+ traditionally `config.cache'. FILE defaults to `/dev/null' to
+ disable caching.
+
+`--config-cache'
+`-C'
+ Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+ Do not print messages saying which checks are being made. To
+ suppress all normal output, redirect it to `/dev/null' (any error
+ messages will still be shown).
+
+`--srcdir=DIR'
+ Look for the package's source code in directory DIR. Usually
+ `configure' can determine that directory automatically.
+
+`--prefix=DIR'
+ Use DIR as the installation prefix. *note Installation Names::
+ for more details, including other options available for fine-tuning
+ the installation locations.
+
+`--no-create'
+`-n'
+ Run the configure checks, but stop before creating any output
+ files.
+
+`configure' also accepts some other, not widely useful, options. Run
+`configure --help' for more details.
+
diff --git a/node_modules/mmmagic/deps/libmagic/MAINT b/node_modules/mmmagic/deps/libmagic/MAINT
new file mode 100644
index 0000000..b881615
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/MAINT
@@ -0,0 +1,44 @@
+$File: MAINT,v 1.10 2008/02/05 19:08:11 christos Exp $
+
+Maintenance notes:
+
+I am continuing to maintain the file command. I welcome your help,
+but to make my life easier I'd like to request the following:
+
+- Do not distribute changed versions.
+
+People trying to be helpful occasionally put up their hacked versions
+of the file command for anonymous FTP, and people all over the
+world get copies of the hacked versions. Within a day or two I am
+getting email from around the world asking me why "my" file command
+won't compile!!! Needless to say this detracts from the limited
+time I have available to work on the actual software. Therefore I
+ask you again to please NOT distribute your changed version. If
+you need to make changes, please add a patch file next to the
+distribution tar, and a README file that clearly explains what you
+are trying to fix.
+
+Thank you for your assistance and cooperation.
+
+Code Overview
+
+This is a rough idea of the control flow from the main program:
+
+file.c main()
+file.c process (called for each file)
+ printf file name
+magic.c magic_file()
+fsmagic.c file_fsmagic()
+ (handles statbuf modes for DEV)
+ (handles statbuf modes for executable &c.
+ reads data from file.
+funcs.c: file_buffer()
+compress.c file_zmagic()
+is_tar.c file_is_tar()
+softmagic.c file_softmagic()
+ match() - looks for match against main magic database
+ascmagic.c file_ascmagic()
+readelf.c file_tryelf()
+ "unknown"
+
+Christos Zoulas (see README for email address)
diff --git a/node_modules/mmmagic/deps/libmagic/NEWS b/node_modules/mmmagic/deps/libmagic/NEWS
new file mode 100644
index 0000000..939a279
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/NEWS
@@ -0,0 +1 @@
+See ChangeLog. \ No newline at end of file
diff --git a/node_modules/mmmagic/deps/libmagic/README b/node_modules/mmmagic/deps/libmagic/README
new file mode 100644
index 0000000..bb8186f
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/README
@@ -0,0 +1,161 @@
+## README for file(1) Command ##
+
+ @(#) $File: README,v 1.50 2016/04/16 22:40:54 christos Exp $
+
+Mailing List: file@mx.gw.com
+Mailing List archives: http://mx.gw.com/pipermail/file/
+Bug tracker: http://bugs.gw.com/
+E-mail: christos@astron.com
+
+[![Build Status](https://travis-ci.org/file/file.png?branch=master)](https://travis-ci.org/file/file)
+
+Phone: Do not even think of telephoning me about this program. Send cash first!
+
+This is Release 5.x of Ian Darwin's (copyright but distributable)
+file(1) command, an implementation of the Unix File(1) command.
+It knows the 'magic number' of several thousands of file types.
+This version is the standard "file" command for Linux,
+*BSD, and other systems. (See "patchlevel.h" for the exact release number).
+
+You can download the latest version of the original sources for file from:
+
+ ftp://ftp.astron.com/pub/file/
+
+A public read-only git repository of the same sources is available at:
+
+ https://github.com/file/file
+
+The major changes for 5.x are CDF file parsing, indirect magic, name/use
+(recursion) and overhaul in mime and ascii encoding handling.
+
+The major feature of 4.x is the refactoring of the code into a library,
+and the re-write of the file command in terms of that library. The library
+itself, libmagic can be used by 3rd party programs that wish to identify
+file types without having to fork() and exec() file. The prime contributor
+for 4.0 was Mans Rullgard.
+
+UNIX is a trademark of UNIX System Laboratories.
+
+The prime contributor to Release 3.8 was Guy Harris, who put in megachanges
+including byte-order independence.
+
+The prime contributor to Release 3.0 was Christos Zoulas, who put
+in hundreds of lines of source code changes, including his own
+ANSIfication of the code (I liked my own ANSIfication better, but
+his (__P()) is the "Berkeley standard" way of doing it, and I wanted UCB
+to include the code...), his HP-like "indirection" (a feature of
+the HP file command, I think), and his mods that finally got the
+uncompress (-z) mode finished and working.
+
+This release has compiled in numerous environments; see PORTING
+for a list and problems.
+
+This fine freeware file(1) follows the USG (System V) model of the file
+command, rather than the Research (V7) version or the V7-derived 4.[23]
+Berkeley one. That is, the file /etc/magic contains much of the ritual
+information that is the source of this program's power. My version
+knows a little more magic (including tar archives) than System V; the
+/etc/magic parsing seems to be compatible with the (poorly documented)
+System V /etc/magic format (with one exception; see the man page).
+
+In addition, the /etc/magic file is built from a subdirectory
+for easier(?) maintenance. I will act as a clearinghouse for
+magic numbers assigned to all sorts of data files that
+are in reasonable circulation. Send your magic numbers,
+in magic(5) format please, to the maintainer, Christos Zoulas.
+
+COPYING - read this first.
+README - read this second (you are currently reading this file).
+INSTALL - read on how to install
+src/localtime_r.c
+src/magic.c
+src/magic.h
+src/mygetopt.h
+src/newtest2.c
+src/newtest3.c
+src/pread.c
+src/print.c
+src/readcdf.c
+src/readelf.c
+src/readelf.h
+src/regex.c
+src/regex2.c
+src/softmagic.c
+src/strcasestr.c
+src/strlcat.c
+src/strlcpy.c
+src/strndup.c
+src/tar.h
+src/teststrchr.c
+src/vasprintf.c
+src/x.c
+src/apprentice.c - parses /etc/magic to learn magic
+src/apptype.c - used for OS/2 specific application type magic
+src/ascmagic.c - third & last set of tests, based on hardwired assumptions.
+src/asctime_r.c - replacement for OS's that don't have it.
+src/asprintf.c - replacement for OS's that don't have it.
+src/asctime_r.c - replacement for OS's that don't have it.
+src/asprintf.c - replacement for OS's that don't have it.
+src/cdf.[ch] - parser for Microsoft Compound Document Files
+src/cdf_time.c - time converter for CDF.
+src/compress.c - handles decompressing files to look inside.
+src/ctime_r.c - replacement for OS's that don't have it.
+src/der.[ch] - parser for Distinguished Encoding Rules
+src/dprintf.c - replacement for OS's that don't have it.
+src/elfclass.h - common code for elf 32/64.
+src/encoding.c - handles unicode encodings
+src/file.c - the main program
+src/file.h - header file
+src/file_opts.h - list of options
+src/fmtcheck.c - replacement for OS's that don't have it.
+src/fsmagic.c - first set of tests the program runs, based on filesystem info
+src/funcs.c - utilility functions
+src/getline.c - replacement for OS's that don't have it.
+src/getopt_long.c - replacement for OS's that don't have it.
+src/gmtime_r.c - replacement for OS's that don't have it.
+src/is_tar.c, tar.h - knows about Tape ARchive format (courtesy John Gilmore).
+src/localtime_r.c - replacement for OS's that don't have it.
+src/magic.h.in - source file for magic.h
+src/mygetopt.h - replacement for OS's that don't have it.
+src/magic.c - the libmagic api
+src/names.h - header file for ascmagic.c
+src/pread.c - replacement for OS's that don't have it.
+src/print.c - print results, errors, warnings.
+src/readcdf.c - CDF wrapper.
+src/readelf.[ch] - Stand-alone elf parsing code.
+src/softmagic.c - 2nd set of tests, based on /etc/magic
+src/mygetopt.h - replacement for OS's that don't have it.
+src/strcasestr.c - replacement for OS's that don't have it.
+src/strlcat.c - replacement for OS's that don't have it.
+src/strlcpy.c - replacement for OS's that don't have it.
+src/tar.h - tar file definitions
+src/vasprintf.c - for systems that don't have it.
+doc/file.man - man page for the command
+doc/magic.man - man page for the magic file, courtesy Guy Harris.
+ Install as magic.4 on USG and magic.5 on V7 or Berkeley; cf Makefile.
+
+Magdir - directory of /etc/magic pieces
+------------------------------------------------------------------------------
+
+If you submit a new magic entry please make sure you read the following
+guidelines:
+
+- Initial match is preferably at least 32 bits long, and is a _unique_ match
+- If this is not feasible, use additional check
+- Match of <= 16 bits are not accepted
+- Delay printing string as much as possible, don't print output too early
+- Avoid printf arbitrary byte as string, which can be a source of
+ crash and buffer overflow
+
+- Provide complete information with entry:
+ * One line short summary
+ * Optional long description
+ * File extension, if applicable
+ * Full name and contact method (for discussion when entry has problem)
+ * Further reference, such as documentation of format
+
+------------------------------------------------------------------------------
+
+Parts of this software were developed at SoftQuad Inc., developers
+of SGML/HTML/XML publishing software, in Toronto, Canada.
+SoftQuad was swallowed up by Corel in 2002 and does not exist any longer.
diff --git a/node_modules/mmmagic/deps/libmagic/TODO b/node_modules/mmmagic/deps/libmagic/TODO
new file mode 100644
index 0000000..78890cf
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/TODO
@@ -0,0 +1,36 @@
+Most TODOs live in the TODO section of doc/file.man (i.e. file(1)).
+They are more visible there, so please add any further TODOs to that
+file, not here. More speculative material can live here.
+
+(This change was made when Reuben Thomas noticed that all the bugs
+listed in the BUGS section of the man page had been fixed!)
+
+---
+It would be nice to simplify file considerably. For example,
+reimplement the apprentice and non-pattern magic methods in Python,
+and compile the magic patterns to a giant regex (or something similar;
+maybe using Ragel (http://www.complang.org/ragel/)) so that only a
+small amount of C is needed (because fast execution is typically only
+required for soft magic, not the more detailed information given by
+hard-wired routines). In this regard, note that hplip, which is
+BSD-licensed, has a magic reimplementation in Python.
+---
+Read the kerberos magic entry for more ideas.
+---
+Write a string merger to make magic entry sizes dynamic.
+Strings will be converted to offsets from the string table.
+---
+Programming language support, we can introduce the concept of a group
+of rules where n rules need to match before the rule is positive. This
+could require structural changes to the matching code :-(
+
+0 group 2 # require 2 matches
+# rule 1
+>0 ....
+...
+# rule 2
+>0 ....
+...
+
+christos
+
diff --git a/node_modules/mmmagic/deps/libmagic/config/freebsd/config.h b/node_modules/mmmagic/deps/libmagic/config/freebsd/config.h
new file mode 100644
index 0000000..b0173f2
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/config/freebsd/config.h
@@ -0,0 +1,365 @@
+/* Define in built-in ELF support is used */
+#define BUILTIN_ELF 1
+
+/* Define for ELF core file support */
+#define ELFCORE 1
+
+/* Define to 1 if you have the `asctime_r' function. */
+#define HAVE_ASCTIME_R 1
+
+/* Define to 1 if you have the `asprintf' function. */
+#define HAVE_ASPRINTF 1
+
+/* Define to 1 if you have the `ctime_r' function. */
+#define HAVE_CTIME_R 1
+
+/* HAVE_DAYLIGHT */
+/* #undef HAVE_DAYLIGHT */
+
+/* Define to 1 if you have the declaration of `daylight', and to 0 if you
+ don't. */
+#define HAVE_DECL_DAYLIGHT 0
+
+/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't.
+ */
+#define HAVE_DECL_TZNAME 1
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define to 1 if you have the `dprintf' function. */
+#define HAVE_DPRINTF 1
+
+/* Define to 1 if you have the <err.h> header file. */
+#define HAVE_ERR_H 1
+
+/* Define to 1 if you have the <dirent.h> header file. */
+#define HAVE_DIRENT_H 1
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define to 1 if you have the `fmtcheck' function. */
+#define HAVE_FMTCHECK 1
+
+/* Define to 1 if you have the `fork' function. */
+#define HAVE_FORK 1
+
+/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
+#define HAVE_FSEEKO 1
+
+/* Define to 1 if you have the `getline' function. */
+#define HAVE_GETLINE 1
+
+/* Define to 1 if you have the <getopt.h> header file. */
+#define HAVE_GETOPT_H 1
+
+/* Define to 1 if you have the `getopt_long' function. */
+#define HAVE_GETOPT_LONG 1
+
+/* Define to 1 if you have the `getpagesize' function. */
+#define HAVE_GETPAGESIZE 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the `gnurx' library (-lgnurx). */
+/* #undef HAVE_LIBGNURX */
+
+/* Define to 1 if you have the `z' library (-lz). */
+/* #define HAVE_LIBZ 1 */
+
+/* Define to 1 if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 1
+
+/* Define to 1 if you have the <locale.h> header file. */
+#define HAVE_LOCALE_H 1
+
+/* Define to 1 if mbrtowc and mbstate_t are properly declared. */
+#define HAVE_MBRTOWC 1
+
+/* Define to 1 if <wchar.h> declares mbstate_t. */
+#define HAVE_MBSTATE_T 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the `mkostemp' function. */
+/* #undef HAVE_MKOSTEMP */
+
+/* Define to 1 if you have the `mkstemp' function. */
+#define HAVE_MKSTEMP 1
+
+/* Define to 1 if you have a working `mmap' system call. */
+#define HAVE_MMAP 1
+
+/* Define to 1 if you have the `pread' function. */
+#define HAVE_PREAD 1
+
+/* Define to 1 if you have the <stddef.h> header file. */
+#define HAVE_STDDEF_H 1
+
+/* Define to 1 if the system has the type `pid_t'. */
+#define HAVE_PID_T 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the `strcasestr' function. */
+#define HAVE_STRCASESTR 1
+
+/* Define to 1 if you have the `strerror' function. */
+#define HAVE_STRERROR 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the `strlcat' function. */
+#define HAVE_STRLCAT 1
+
+/* Define to 1 if you have the `strlcpy' function. */
+#define HAVE_STRLCPY 1
+
+/* Define to 1 if you have the `strndup' function. */
+#define HAVE_STRNDUP 1
+
+/* Define to 1 if you have the `strtof' function. */
+#define HAVE_STRTOF 1
+
+/* Define to 1 if you have the `strtoul' function. */
+#define HAVE_STRTOUL 1
+
+/* HAVE_STRUCT_OPTION */
+#define HAVE_STRUCT_OPTION 1
+
+/* Define to 1 if `st_rdev' is a member of `struct stat'. */
+#define HAVE_STRUCT_STAT_ST_RDEV 1
+
+/* Define to 1 if `tm_gmtoff' is a member of `struct tm'. */
+#define HAVE_STRUCT_TM_TM_GMTOFF 1
+
+/* Define to 1 if `tm_zone' is a member of `struct tm'. */
+#define HAVE_STRUCT_TM_TM_ZONE 1
+
+/* Define to 1 if you have the <sys/mman.h> header file. */
+#define HAVE_SYS_MMAN_H 1
+
+/* Define to 1 if you have the <sys/param.h> header file. */
+#define HAVE_SYS_PARAM_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#define HAVE_SYS_TIME_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <sys/utime.h> header file. */
+/* #undef HAVE_SYS_UTIME_H */
+
+/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
+#define HAVE_SYS_WAIT_H 1
+
+/* HAVE_TM_ISDST */
+#define HAVE_TM_ISDST 1
+
+/* HAVE_TM_ZONE */
+#define HAVE_TM_ZONE 1
+
+/* HAVE_TZNAME */
+#define HAVE_TZNAME 1
+
+/* Define to 1 if the system has the type `int32_t'. */
+#define HAVE_INT32_T 1
+
+/* Define to 1 if the system has the type `int64_t'. */
+#define HAVE_INT64_T 1
+
+/* Define to 1 if the system has the type `uint16_t'. */
+#define HAVE_UINT16_T 1
+
+/* Define to 1 if the system has the type `uint32_t'. */
+#define HAVE_UINT32_T 1
+
+/* Define to 1 if the system has the type `uint64_t'. */
+#define HAVE_UINT64_T 1
+
+/* Define to 1 if the system has the type `uint8_t'. */
+#define HAVE_UINT8_T 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to 1 if you have the `utime' function. */
+#define HAVE_UTIME 1
+
+/* Define to 1 if you have the `utimes' function. */
+#define HAVE_UTIMES 1
+
+/* Define to 1 if you have the <utime.h> header file. */
+#define HAVE_UTIME_H 1
+
+/* Define to 1 if you have the `vasprintf' function. */
+#define HAVE_VASPRINTF 1
+
+/* Define to 1 if you have the `vfork' function. */
+#define HAVE_VFORK 1
+
+/* Define to 1 if you have the <vfork.h> header file. */
+/* #undef HAVE_VFORK_H */
+
+/* Define to 1 or 0, depending whether the compiler supports simple visibility
+ declarations. */
+#define HAVE_VISIBILITY 1
+
+/* Define to 1 if you have the <wchar.h> header file. */
+#define HAVE_WCHAR_H 1
+
+/* Define to 1 if you have the <wctype.h> header file. */
+#define HAVE_WCTYPE_H 1
+
+/* Define to 1 if you have the `wcwidth' function. */
+#define HAVE_WCWIDTH 1
+
+/* Define to 1 if `fork' works. */
+#define HAVE_WORKING_FORK 1
+
+/* Define to 1 if `vfork' works. */
+#define HAVE_WORKING_VFORK 1
+
+/* Define to 1 if you have the <zlib.h> header file. */
+/* #define HAVE_ZLIB_H 1 */
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+ */
+#define LT_OBJDIR ".libs/"
+
+/* Define to 1 if `major', `minor', and `makedev' are declared in <mkdev.h>.
+ */
+/* #undef MAJOR_IN_MKDEV */
+
+/* Define to 1 if `major', `minor', and `makedev' are declared in
+ <sysmacros.h>. */
+/* #undef MAJOR_IN_SYSMACROS */
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* The size of `long long', as computed by sizeof. */
+#define SIZEOF_LONG_LONG 8
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define to 1 if your <sys/time.h> declares `struct tm'. */
+/* #undef TM_IN_SYS_TIME */
+
+/* Enable extensions on AIX 3, Interix. */
+#ifndef _ALL_SOURCE
+# define _ALL_SOURCE 1
+#endif
+/* Enable GNU extensions on systems that have them. */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+/* Enable threading extensions on Solaris. */
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# define _POSIX_PTHREAD_SEMANTICS 1
+#endif
+/* Enable extensions on HP NonStop. */
+#ifndef _TANDEM_SOURCE
+# define _TANDEM_SOURCE 1
+#endif
+/* Enable general extensions on Solaris. */
+#ifndef __EXTENSIONS__
+# define __EXTENSIONS__ 1
+#endif
+
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+/* #undef _FILE_OFFSET_BITS */
+
+/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
+/* #undef _LARGEFILE_SOURCE */
+
+/* Define for large files, on AIX-style hosts. */
+/* #undef _LARGE_FILES */
+
+/* Define to 1 if on MINIX. */
+/* #undef _MINIX */
+
+/* Define to 2 if the system does not provide POSIX.1 features except with
+ this defined. */
+/* #undef _POSIX_1_SOURCE */
+
+/* Define to 1 if you need to in order for `stat' and other things to work. */
+/* #undef _POSIX_SOURCE */
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef const */
+
+/* Define to a type if <wchar.h> does not define. */
+/* #undef mbstate_t */
+
+/* Define to `long int' if <sys/types.h> does not define. */
+/* #undef off_t */
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+/* #undef size_t */
+
+
+#ifndef HAVE_UINT8_T
+typedef unsigned char uint8_t;
+#endif
+#ifndef HAVE_UINT16_T
+typedef unsigned short uint16_t;
+#endif
+#ifndef HAVE_UINT32_T
+typedef unsigned int uint32_t;
+#endif
+#ifndef HAVE_INT32_T
+typedef int int32_t;
+#endif
+#ifndef HAVE_UINT64_T
+#if SIZEOF_LONG_LONG == 8
+typedef unsigned long long uint64_t;
+#else
+typedef unsigned long uint64_t;
+#endif
+#endif
+#ifndef HAVE_INT64_T
+#if SIZEOF_LONG_LONG == 8
+typedef long long int64_t;
+#else
+typedef long int64_t;
+#endif
+#endif
+
+/* Define as `fork' if `vfork' does not work. */
+/* #undef vfork */
diff --git a/node_modules/mmmagic/deps/libmagic/config/linux/config.h b/node_modules/mmmagic/deps/libmagic/config/linux/config.h
new file mode 100644
index 0000000..639c0e4
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/config/linux/config.h
@@ -0,0 +1,405 @@
+/* Define in built-in ELF support is used */
+#define BUILTIN_ELF 1
+
+/* Define for ELF core file support */
+#define ELFCORE 1
+
+/* Define to 1 if you have the `asctime_r' function. */
+#define HAVE_ASCTIME_R 1
+
+/* Define to 1 if you have the `asprintf' function. */
+#define HAVE_ASPRINTF 1
+
+/* Define to 1 if you have the `ctime_r' function. */
+#define HAVE_CTIME_R 1
+
+/* HAVE_DAYLIGHT */
+#define HAVE_DAYLIGHT 1
+
+/* Define to 1 if you have the declaration of `daylight', and to 0 if you
+ don't. */
+#define HAVE_DECL_DAYLIGHT 1
+
+/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't.
+ */
+#define HAVE_DECL_TZNAME 1
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define to 1 if you have the `dprintf' function. */
+#define HAVE_DPRINTF 1
+
+/* Define to 1 if you have the <err.h> header file. */
+#define HAVE_ERR_H 1
+
+/* Define to 1 if you have the <dirent.h> header file. */
+#define HAVE_DIRENT_H 1
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define to 1 if you have the `fmtcheck' function. */
+/* #undef HAVE_FMTCHECK */
+
+/* Define to 1 if you have the `fork' function. */
+#define HAVE_FORK 1
+
+/* Define to 1 if you have the `freelocale' function. */
+#define HAVE_FREELOCALE 1
+
+/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
+#define HAVE_FSEEKO 1
+
+/* Define to 1 if you have the `getline' function. */
+#define HAVE_GETLINE 1
+
+/* Define to 1 if you have the <getopt.h> header file. */
+#define HAVE_GETOPT_H 1
+
+/* Define to 1 if you have the `getopt_long' function. */
+#define HAVE_GETOPT_LONG 1
+
+/* Define to 1 if you have the `getpagesize' function. */
+#define HAVE_GETPAGESIZE 1
+
+/* Define to 1 if you have the `gmtime_r' function. */
+#define HAVE_GMTIME_R 1
+
+/* Define to 1 if the system has the type `intptr_t'. */
+#define HAVE_INTPTR_T 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the `gnurx' library (-lgnurx). */
+/* #undef HAVE_LIBGNURX */
+
+/* Define to 1 if you have the `z' library (-lz). */
+/* #define HAVE_LIBZ 1 */
+
+/* Define to 1 if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 1
+
+/* Define to 1 if you have the <locale.h> header file. */
+#define HAVE_LOCALE_H 1
+
+/* Define to 1 if you have the `localtime_r' function. */
+#define HAVE_LOCALTIME_R 1
+
+/* Define to 1 if mbrtowc and mbstate_t are properly declared. */
+#define HAVE_MBRTOWC 1
+
+/* Define to 1 if <wchar.h> declares mbstate_t. */
+#define HAVE_MBSTATE_T 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the `mkostemp' function. */
+#define HAVE_MKOSTEMP 1
+
+/* Define to 1 if you have the `mkstemp' function. */
+#define HAVE_MKSTEMP 1
+
+/* Define to 1 if you have a working `mmap' system call. */
+#define HAVE_MMAP 1
+
+/* Define to 1 if you have the `newlocale' function. */
+#define HAVE_NEWLOCALE 1
+
+/* Define to 1 if you have the `pread' function. */
+#define HAVE_PREAD 1
+
+/* Define to 1 if you have the `setlocale' function. */
+#define HAVE_SETLOCALE 1
+
+/* Define to 1 if you have the <signal.h> header file. */
+#define HAVE_SIGNAL_H 1
+
+/* Have sig_t type */
+#define HAVE_SIG_T 1
+
+/* Define to 1 if you have the <stddef.h> header file. */
+#define HAVE_STDDEF_H 1
+
+/* Define to 1 if the system has the type `pid_t'. */
+#define HAVE_PID_T 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the `strcasestr' function. */
+#define HAVE_STRCASESTR 1
+
+/* Define to 1 if you have the `strerror' function. */
+#define HAVE_STRERROR 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the `strlcat' function. */
+/* #undef HAVE_STRLCAT */
+
+/* Define to 1 if you have the `strlcpy' function. */
+/* #undef HAVE_STRLCPY */
+
+/* Define to 1 if you have the `strndup' function. */
+#define HAVE_STRNDUP 1
+
+/* Define to 1 if you have the `strtof' function. */
+#define HAVE_STRTOF 1
+
+/* Define to 1 if you have the `strtoul' function. */
+#define HAVE_STRTOUL 1
+
+/* HAVE_STRUCT_OPTION */
+#define HAVE_STRUCT_OPTION 1
+
+/* Define to 1 if `st_rdev' is a member of `struct stat'. */
+#define HAVE_STRUCT_STAT_ST_RDEV 1
+
+/* Define to 1 if `tm_gmtoff' is a member of `struct tm'. */
+/* #undef HAVE_STRUCT_TM_TM_GMTOFF */
+
+/* Define to 1 if `tm_zone' is a member of `struct tm'. */
+#define HAVE_STRUCT_TM_TM_ZONE 1
+
+/* Define to 1 if you have the <sys/mman.h> header file. */
+#define HAVE_SYS_MMAN_H 1
+
+/* Define to 1 if you have the <sys/param.h> header file. */
+#define HAVE_SYS_PARAM_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#define HAVE_SYS_TIME_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <sys/utime.h> header file. */
+/* #undef HAVE_SYS_UTIME_H */
+
+/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
+#define HAVE_SYS_WAIT_H 1
+
+/* HAVE_TM_ISDST */
+#define HAVE_TM_ISDST 1
+
+/* HAVE_TM_ZONE */
+#define HAVE_TM_ZONE 1
+
+/* HAVE_TZNAME */
+#define HAVE_TZNAME 1
+
+/* Define to 1 if the system has the type `int32_t'. */
+#define HAVE_INT32_T 1
+
+/* Define to 1 if the system has the type `int64_t'. */
+#define HAVE_INT64_T 1
+
+/* Define to 1 if the system has the type `uint16_t'. */
+#define HAVE_UINT16_T 1
+
+/* Define to 1 if the system has the type `uint32_t'. */
+#define HAVE_UINT32_T 1
+
+/* Define to 1 if the system has the type `uint64_t'. */
+#define HAVE_UINT64_T 1
+
+/* Define to 1 if the system has the type `uint8_t'. */
+#define HAVE_UINT8_T 1
+
+/* Define to 1 if the system has the type `uintptr_t'. */
+#define HAVE_UINTPTR_T 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to 1 if you have the `uselocale' function. */
+#define HAVE_USELOCALE 1
+
+/* Define to 1 if you have the `utime' function. */
+#define HAVE_UTIME 1
+
+/* Define to 1 if you have the `utimes' function. */
+#define HAVE_UTIMES 1
+
+/* Define to 1 if you have the <utime.h> header file. */
+#define HAVE_UTIME_H 1
+
+/* Define to 1 if you have the `vasprintf' function. */
+#define HAVE_VASPRINTF 1
+
+/* Define to 1 if you have the `vfork' function. */
+#define HAVE_VFORK 1
+
+/* Define to 1 if you have the <vfork.h> header file. */
+/* #undef HAVE_VFORK_H */
+
+/* Define to 1 or 0, depending whether the compiler supports simple visibility
+ declarations. */
+#define HAVE_VISIBILITY 1
+
+/* Define to 1 if you have the <wchar.h> header file. */
+#define HAVE_WCHAR_H 1
+
+/* Define to 1 if you have the <wctype.h> header file. */
+#define HAVE_WCTYPE_H 1
+
+/* Define to 1 if you have the `wcwidth' function. */
+#define HAVE_WCWIDTH 1
+
+/* Define to 1 if `fork' works. */
+#define HAVE_WORKING_FORK 1
+
+/* Define to 1 if `vfork' works. */
+#define HAVE_WORKING_VFORK 1
+
+/* Define to 1 if you have the <xlocale.h> header file. */
+#if defined(__has_include)
+# if __has_include(<xlocale.h>)
+# define HAVE_XLOCALE_H 1
+# endif
+#else
+// Assume header available for older compilers
+# define HAVE_XLOCALE_H 1
+#endif
+
+/* Define to 1 if you have the <zlib.h> header file. */
+/* #define HAVE_ZLIB_H 1 */
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+ */
+#define LT_OBJDIR ".libs/"
+
+/* Define to 1 if `major', `minor', and `makedev' are declared in <mkdev.h>.
+ */
+/* #undef MAJOR_IN_MKDEV */
+
+/* Define to 1 if `major', `minor', and `makedev' are declared in
+ <sysmacros.h>. */
+/* #undef MAJOR_IN_SYSMACROS */
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* The size of `long long', as computed by sizeof. */
+#define SIZEOF_LONG_LONG 8
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define to 1 if your <sys/time.h> declares `struct tm'. */
+/* #undef TM_IN_SYS_TIME */
+
+/* Enable extensions on AIX 3, Interix. */
+#ifndef _ALL_SOURCE
+# define _ALL_SOURCE 1
+#endif
+/* Enable GNU extensions on systems that have them. */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+/* Enable threading extensions on Solaris. */
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# define _POSIX_PTHREAD_SEMANTICS 1
+#endif
+/* Enable extensions on HP NonStop. */
+#ifndef _TANDEM_SOURCE
+# define _TANDEM_SOURCE 1
+#endif
+/* Enable general extensions on Solaris. */
+#ifndef __EXTENSIONS__
+# define __EXTENSIONS__ 1
+#endif
+
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+/* #undef _FILE_OFFSET_BITS */
+
+/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
+/* #undef _LARGEFILE_SOURCE */
+
+/* Define for large files, on AIX-style hosts. */
+/* #undef _LARGE_FILES */
+
+/* Define to 1 if on MINIX. */
+/* #undef _MINIX */
+
+/* Define to 2 if the system does not provide POSIX.1 features except with
+ this defined. */
+/* #undef _POSIX_1_SOURCE */
+
+/* Define to 1 if you need to in order for `stat' and other things to work. */
+/* #undef _POSIX_SOURCE */
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef const */
+
+/* Define to a type if <wchar.h> does not define. */
+/* #undef mbstate_t */
+
+/* Define to `long int' if <sys/types.h> does not define. */
+/* #undef off_t */
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+/* #undef size_t */
+
+
+#ifndef HAVE_UINT8_T
+typedef unsigned char uint8_t;
+#endif
+#ifndef HAVE_UINT16_T
+typedef unsigned short uint16_t;
+#endif
+#ifndef HAVE_UINT32_T
+typedef unsigned int uint32_t;
+#endif
+#ifndef HAVE_INT32_T
+typedef int int32_t;
+#endif
+#ifndef HAVE_UINT64_T
+#if SIZEOF_LONG_LONG == 8
+typedef unsigned long long uint64_t;
+#else
+typedef unsigned long uint64_t;
+#endif
+#endif
+#ifndef HAVE_INT64_T
+#if SIZEOF_LONG_LONG == 8
+typedef long long int64_t;
+#else
+typedef long int64_t;
+#endif
+#endif
+
+/* Define as `fork' if `vfork' does not work. */
+/* #undef vfork */
diff --git a/node_modules/mmmagic/deps/libmagic/config/mac/config.h b/node_modules/mmmagic/deps/libmagic/config/mac/config.h
new file mode 100644
index 0000000..415f2a3
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/config/mac/config.h
@@ -0,0 +1,360 @@
+/* Define in built-in ELF support is used */
+#define BUILTIN_ELF 1
+
+/* Define for ELF core file support */
+#define ELFCORE 1
+
+/* Define to 1 if you have the `asctime_r' function. */
+#define HAVE_ASCTIME_R 1
+
+/* Define to 1 if you have the `asprintf' function. */
+#define HAVE_ASPRINTF 1
+
+/* Define to 1 if you have the `ctime_r' function. */
+#define HAVE_CTIME_R 1
+
+/* HAVE_DAYLIGHT */
+#define HAVE_DAYLIGHT 1
+
+/* Define to 1 if you have the declaration of `daylight', and to 0 if you
+ don't. */
+#define HAVE_DECL_DAYLIGHT 1
+
+/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't.
+ */
+#define HAVE_DECL_TZNAME 1
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define to 1 if you have the `dprintf' function. */
+#define HAVE_DPRINTF 1
+
+/* Define to 1 if you have the <err.h> header file. */
+#define HAVE_ERR_H 1
+
+/* Define to 1 if you have the <dirent.h> header file. */
+#define HAVE_DIRENT_H 1
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define to 1 if you have the `fmtcheck' function. */
+#define HAVE_FMTCHECK 1
+
+/* Define to 1 if you have the `fork' function. */
+#define HAVE_FORK 1
+
+/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
+#define HAVE_FSEEKO 1
+
+/* Define to 1 if you have the `getline' function. */
+/* #undef HAVE_GETLINE */
+
+/* Define to 1 if you have the <getopt.h> header file. */
+#define HAVE_GETOPT_H 1
+
+/* Define to 1 if you have the `getopt_long' function. */
+#define HAVE_GETOPT_LONG 1
+
+/* Define to 1 if you have the `getpagesize' function. */
+#define HAVE_GETPAGESIZE 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the `gnurx' library (-lgnurx). */
+/* #undef HAVE_LIBGNURX */
+
+/* Define to 1 if you have the `z' library (-lz). */
+/* #define HAVE_LIBZ 1 */
+
+/* Define to 1 if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 1
+
+/* Define to 1 if you have the <locale.h> header file. */
+#define HAVE_LOCALE_H 1
+
+/* Define to 1 if mbrtowc and mbstate_t are properly declared. */
+#define HAVE_MBRTOWC 1
+
+/* Define to 1 if <wchar.h> declares mbstate_t. */
+#define HAVE_MBSTATE_T 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the `mkostemp' function. */
+/* #undef HAVE_MKOSTEMP */
+
+/* Define to 1 if you have the `mkstemp' function. */
+#define HAVE_MKSTEMP 1
+
+/* Define to 1 if you have a working `mmap' system call. */
+#define HAVE_MMAP 1
+
+/* Define to 1 if you have the `pread' function. */
+#define HAVE_PREAD 1
+
+/* Define to 1 if you have the <stddef.h> header file. */
+#define HAVE_STDDEF_H 1
+
+/* Define to 1 if the system has the type `pid_t'. */
+#define HAVE_PID_T 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the `strcasestr' function. */
+#define HAVE_STRCASESTR 1
+
+/* Define to 1 if you have the `strerror' function. */
+#define HAVE_STRERROR 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the `strlcat' function. */
+#define HAVE_STRLCAT 1
+
+/* Define to 1 if you have the `strlcpy' function. */
+#define HAVE_STRLCPY 1
+
+/* Define to 1 if you have the `strndup' function. */
+/* #undef HAVE_STRNDUP */
+
+/* Define to 1 if you have the `strtof' function. */
+#define HAVE_STRTOF 1
+
+/* Define to 1 if you have the `strtoul' function. */
+#define HAVE_STRTOUL 1
+
+/* HAVE_STRUCT_OPTION */
+#define HAVE_STRUCT_OPTION 1
+
+/* Define to 1 if `st_rdev' is a member of `struct stat'. */
+#define HAVE_STRUCT_STAT_ST_RDEV 1
+
+/* Define to 1 if `tm_gmtoff' is a member of `struct tm'. */
+/* #undef HAVE_STRUCT_TM_TM_GMTOFF */
+
+/* Define to 1 if `tm_zone' is a member of `struct tm'. */
+/* #undef HAVE_STRUCT_TM_TM_ZONE */
+
+/* Define to 1 if you have the <sys/mman.h> header file. */
+#define HAVE_SYS_MMAN_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#define HAVE_SYS_TIME_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <sys/utime.h> header file. */
+/* #undef HAVE_SYS_UTIME_H */
+
+/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
+#define HAVE_SYS_WAIT_H 1
+
+/* HAVE_TM_ISDST */
+#define HAVE_TM_ISDST 1
+
+/* HAVE_TM_ZONE */
+#define HAVE_TM_ZONE 1
+
+/* HAVE_TZNAME */
+#define HAVE_TZNAME 1
+
+/* Define to 1 if the system has the type `int32_t'. */
+#define HAVE_INT32_T 1
+
+/* Define to 1 if the system has the type `int64_t'. */
+#define HAVE_INT64_T 1
+
+/* Define to 1 if the system has the type `uint16_t'. */
+#define HAVE_UINT16_T 1
+
+/* Define to 1 if the system has the type `uint32_t'. */
+#define HAVE_UINT32_T 1
+
+/* Define to 1 if the system has the type `uint64_t'. */
+#define HAVE_UINT64_T 1
+
+/* Define to 1 if the system has the type `uint8_t'. */
+#define HAVE_UINT8_T 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to 1 if you have the `utime' function. */
+#define HAVE_UTIME 1
+
+/* Define to 1 if you have the `utimes' function. */
+#define HAVE_UTIMES 1
+
+/* Define to 1 if you have the <utime.h> header file. */
+#define HAVE_UTIME_H 1
+
+/* Define to 1 if you have the `vasprintf' function. */
+#define HAVE_VASPRINTF 1
+
+/* Define to 1 if you have the `vfork' function. */
+#define HAVE_VFORK 1
+
+/* Define to 1 if you have the <vfork.h> header file. */
+/* #undef HAVE_VFORK_H */
+
+/* Define to 1 or 0, depending whether the compiler supports simple visibility
+ declarations. */
+#define HAVE_VISIBILITY 1
+
+/* Define to 1 if you have the <wchar.h> header file. */
+#define HAVE_WCHAR_H 1
+
+/* Define to 1 if you have the <wctype.h> header file. */
+#define HAVE_WCTYPE_H 1
+
+/* Define to 1 if you have the `wcwidth' function. */
+#define HAVE_WCWIDTH 1
+
+/* Define to 1 if you have the <zlib.h> header file. */
+/* #define HAVE_ZLIB_H 1 */
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+ */
+#define LT_OBJDIR ".libs/"
+
+/* Define to 1 if `major', `minor', and `makedev' are declared in <mkdev.h>.
+ */
+/* #undef MAJOR_IN_MKDEV */
+
+/* Define to 1 if `major', `minor', and `makedev' are declared in
+ <sysmacros.h>. */
+/* #undef MAJOR_IN_SYSMACROS */
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* The size of `long long', as computed by sizeof. */
+#define SIZEOF_LONG_LONG 8
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define to 1 if your <sys/time.h> declares `struct tm'. */
+/* #undef TM_IN_SYS_TIME */
+
+/* Enable extensions on AIX 3, Interix. */
+#ifndef _ALL_SOURCE
+# define _ALL_SOURCE 1
+#endif
+/* Enable GNU extensions on systems that have them. */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+/* Enable threading extensions on Solaris. */
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# define _POSIX_PTHREAD_SEMANTICS 1
+#endif
+/* Enable extensions on HP NonStop. */
+#ifndef _TANDEM_SOURCE
+# define _TANDEM_SOURCE 1
+#endif
+/* Enable general extensions on Solaris. */
+#ifndef __EXTENSIONS__
+# define __EXTENSIONS__ 1
+#endif
+
+/* Enable large inode numbers on Mac OS X 10.5. */
+#ifndef _DARWIN_USE_64_BIT_INODE
+# define _DARWIN_USE_64_BIT_INODE 1
+#endif
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+/* #undef _FILE_OFFSET_BITS */
+
+/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
+/* #undef _LARGEFILE_SOURCE */
+
+/* Define for large files, on AIX-style hosts. */
+/* #undef _LARGE_FILES */
+
+/* Define to 1 if on MINIX. */
+/* #undef _MINIX */
+
+/* Define to 2 if the system does not provide POSIX.1 features except with
+ this defined. */
+/* #undef _POSIX_1_SOURCE */
+
+/* Define to 1 if you need to in order for `stat' and other things to work. */
+/* #undef _POSIX_SOURCE */
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef const */
+
+/* Define to a type if <wchar.h> does not define. */
+/* #undef mbstate_t */
+
+/* Define to `long int' if <sys/types.h> does not define. */
+/* #undef off_t */
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+/* #undef size_t */
+
+
+#ifndef HAVE_UINT8_T
+typedef unsigned char uint8_t;
+#endif
+#ifndef HAVE_UINT16_T
+typedef unsigned short uint16_t;
+#endif
+#ifndef HAVE_UINT32_T
+typedef unsigned int uint32_t;
+#endif
+#ifndef HAVE_INT32_T
+typedef int int32_t;
+#endif
+#ifndef HAVE_UINT64_T
+#if SIZEOF_LONG_LONG == 8
+typedef unsigned long long uint64_t;
+#else
+typedef unsigned long uint64_t;
+#endif
+#endif
+#ifndef HAVE_INT64_T
+#if SIZEOF_LONG_LONG == 8
+typedef long long int64_t;
+#else
+typedef long int64_t;
+#endif
+#endif
+
+/* Define as `fork' if `vfork' does not work. */
+/* #undef vfork */
diff --git a/node_modules/mmmagic/deps/libmagic/config/openbsd/config.h b/node_modules/mmmagic/deps/libmagic/config/openbsd/config.h
new file mode 100644
index 0000000..b67c413
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/config/openbsd/config.h
@@ -0,0 +1,334 @@
+/* Define in built-in ELF support is used */
+#define BUILTIN_ELF 1
+
+/* Define for ELF core file support */
+#define ELFCORE 1
+
+/* Define to 1 if you have the `asctime_r' function. */
+#define HAVE_ASCTIME_R 1
+
+/* Define to 1 if you have the `asprintf' function. */
+#define HAVE_ASPRINTF 1
+
+/* Define to 1 if you have the `ctime_r' function. */
+#define HAVE_CTIME_R 1
+
+/* HAVE_DAYLIGHT */
+/* #undef HAVE_DAYLIGHT */
+
+/* Define to 1 if you have the declaration of `daylight', and to 0 if you
+ don't. */
+#define HAVE_DECL_DAYLIGHT 0
+
+/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't.
+ */
+#define HAVE_DECL_TZNAME 1
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define to 1 if you have the `dprintf' function. */
+#define HAVE_DPRINTF 1
+
+/* Define to 1 if you have the <err.h> header file. */
+#define HAVE_ERR_H 1
+
+/* Define to 1 if you have the <dirent.h> header file. */
+#define HAVE_DIRENT_H 1
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define to 1 if you have the `fmtcheck' function. */
+/* #undef HAVE_FMTCHECK */
+
+/* Define to 1 if you have the `fork' function. */
+#define HAVE_FORK 1
+
+/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
+#define HAVE_FSEEKO 1
+
+/* Define to 1 if you have the `getline' function. */
+#define HAVE_GETLINE 1
+
+/* Define to 1 if you have the <getopt.h> header file. */
+#define HAVE_GETOPT_H 1
+
+/* Define to 1 if you have the `getopt_long' function. */
+#define HAVE_GETOPT_LONG 1
+
+/* Define to 1 if you have the `getpagesize' function. */
+#define HAVE_GETPAGESIZE 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the `gnurx' library (-lgnurx). */
+/* #undef HAVE_LIBGNURX */
+
+/* Define to 1 if you have the `z' library (-lz). */
+/* #define HAVE_LIBZ 1 */
+
+/* Define to 1 if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 1
+
+/* Define to 1 if you have the <locale.h> header file. */
+#define HAVE_LOCALE_H 1
+
+/* Define to 1 if mbrtowc and mbstate_t are properly declared. */
+#define HAVE_MBRTOWC 1
+
+/* Define to 1 if <wchar.h> declares mbstate_t. */
+#define HAVE_MBSTATE_T 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the `mkostemp' function. */
+/* #undef HAVE_MKOSTEMP */
+
+/* Define to 1 if you have the `mkstemp' function. */
+#define HAVE_MKSTEMP 1
+
+/* Define to 1 if you have a working `mmap' system call. */
+#define HAVE_MMAP 1
+
+/* Define to 1 if you have the `pread' function. */
+#define HAVE_PREAD 1
+
+/* Define to 1 if you have the <stddef.h> header file. */
+#define HAVE_STDDEF_H 1
+
+/* Define to 1 if the system has the type `pid_t'. */
+#define HAVE_PID_T 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the `strcasestr' function. */
+#define HAVE_STRCASESTR 1
+
+/* Define to 1 if you have the `strerror' function. */
+#define HAVE_STRERROR 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the `strlcat' function. */
+#define HAVE_STRLCAT 1
+
+/* Define to 1 if you have the `strlcpy' function. */
+#define HAVE_STRLCPY 1
+
+/* Define to 1 if you have the `strndup' function. */
+#define HAVE_STRNDUP 1
+
+/* Define to 1 if you have the `strtof' function. */
+#define HAVE_STRTOF 1
+
+/* Define to 1 if you have the `strtoul' function. */
+#define HAVE_STRTOUL 1
+
+/* HAVE_STRUCT_OPTION */
+#define HAVE_STRUCT_OPTION 1
+
+/* Define to 1 if `st_rdev' is a member of `struct stat'. */
+#define HAVE_STRUCT_STAT_ST_RDEV 1
+
+/* Define to 1 if `tm_gmtoff' is a member of `struct tm'. */
+#define HAVE_STRUCT_TM_TM_GMTOFF 1
+
+/* Define to 1 if `tm_zone' is a member of `struct tm'. */
+#define HAVE_STRUCT_TM_TM_ZONE 1
+
+/* Define to 1 if you have the <sys/mman.h> header file. */
+#define HAVE_SYS_MMAN_H 1
+
+/* Define to 1 if you have the <sys/param.h> header file. */
+#define HAVE_SYS_PARAM_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#define HAVE_SYS_TIME_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <sys/utime.h> header file. */
+/* #undef HAVE_SYS_UTIME_H */
+
+/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
+#define HAVE_SYS_WAIT_H 1
+
+/* HAVE_TM_ISDST */
+#define HAVE_TM_ISDST 1
+
+/* HAVE_TM_ZONE */
+#define HAVE_TM_ZONE 1
+
+/* HAVE_TZNAME */
+#define HAVE_TZNAME 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to 1 if you have the `utime' function. */
+#define HAVE_UTIME 1
+
+/* Define to 1 if you have the `utimes' function. */
+#define HAVE_UTIMES 1
+
+/* Define to 1 if you have the <utime.h> header file. */
+#define HAVE_UTIME_H 1
+
+/* Define to 1 if you have the `vasprintf' function. */
+#define HAVE_VASPRINTF 1
+
+/* Define to 1 if you have the `vfork' function. */
+#define HAVE_VFORK 1
+
+/* Define to 1 if you have the <vfork.h> header file. */
+/* #undef HAVE_VFORK_H */
+
+/* Define to 1 or 0, depending whether the compiler supports simple visibility
+ declarations. */
+#define HAVE_VISIBILITY 1
+
+/* Define to 1 if you have the <wchar.h> header file. */
+#define HAVE_WCHAR_H 1
+
+/* Define to 1 if you have the <wctype.h> header file. */
+#define HAVE_WCTYPE_H 1
+
+/* Define to 1 if you have the `wcwidth' function. */
+#define HAVE_WCWIDTH 1
+
+/* Define to 1 if `fork' works. */
+#define HAVE_WORKING_FORK 1
+
+/* Define to 1 if `vfork' works. */
+#define HAVE_WORKING_VFORK 1
+
+/* Define to 1 if you have the <zlib.h> header file. */
+/* #define HAVE_ZLIB_H 1 */
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+ */
+#define LT_OBJDIR ".libs/"
+
+/* Define to 1 if `major', `minor', and `makedev' are declared in <mkdev.h>.
+ */
+/* #undef MAJOR_IN_MKDEV */
+
+/* Define to 1 if `major', `minor', and `makedev' are declared in
+ <sysmacros.h>. */
+/* #undef MAJOR_IN_SYSMACROS */
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define to 1 if your <sys/time.h> declares `struct tm'. */
+/* #undef TM_IN_SYS_TIME */
+
+/* Enable extensions on AIX 3, Interix. */
+#ifndef _ALL_SOURCE
+# define _ALL_SOURCE 1
+#endif
+/* Enable GNU extensions on systems that have them. */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+/* Enable threading extensions on Solaris. */
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# define _POSIX_PTHREAD_SEMANTICS 1
+#endif
+/* Enable extensions on HP NonStop. */
+#ifndef _TANDEM_SOURCE
+# define _TANDEM_SOURCE 1
+#endif
+/* Enable general extensions on Solaris. */
+#ifndef __EXTENSIONS__
+# define __EXTENSIONS__ 1
+#endif
+
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+/* #undef _FILE_OFFSET_BITS */
+
+/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
+/* #undef _LARGEFILE_SOURCE */
+
+/* Define for large files, on AIX-style hosts. */
+/* #undef _LARGE_FILES */
+
+/* Define to 1 if on MINIX. */
+/* #undef _MINIX */
+
+/* Define to 2 if the system does not provide POSIX.1 features except with
+ this defined. */
+/* #undef _POSIX_1_SOURCE */
+
+/* Define to 1 if you need to in order for `stat' and other things to work. */
+/* #undef _POSIX_SOURCE */
+
+/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
+ <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+ #define below would cause a syntax error. */
+/* #undef _UINT32_T */
+
+/* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
+ <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+ #define below would cause a syntax error. */
+/* #undef _UINT64_T */
+
+/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
+ <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+ #define below would cause a syntax error. */
+/* #undef _UINT8_T */
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef const */
+
+/* Define to the type of a signed integer type of width exactly 32 bits if
+ such a type exists and the standard includes do not define it. */
+/* #undef int32_t */
+
+/* Define to the type of a signed integer type of width exactly 64 bits if
+ such a type exists and the standard includes do not define it. */
+/* #undef int64_t */
+
+/* Define to a type if <wchar.h> does not define. */
+/* #undef mbstate_t */
+
+/* Define to `long int' if <sys/types.h> does not define. */
+/* #undef off_t */
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+/* #undef size_t */
+
+/* Define to the type of an unsigned integer type of width exactly 16 bits if
+ such a type exists and the standard includes do not define it. */
+/* #undef uint16_t */
+
+/* Define to the type of an unsigned integer type of width exactly 32 bits if
+ such a type exists and the standard includes do not define it. */
+/* #undef uint32_t */
+
+/* Define to the type of an unsigned integer type of width exactly 64 bits if
+ such a type exists and the standard includes do not define it. */
+/* #undef uint64_t */
+
+/* Define to the type of an unsigned integer type of width exactly 8 bits if
+ such a type exists and the standard includes do not define it. */
+/* #undef uint8_t */
+
+/* Define as `fork' if `vfork' does not work. */
+/* #undef vfork */
diff --git a/node_modules/mmmagic/deps/libmagic/config/sunos/config.h b/node_modules/mmmagic/deps/libmagic/config/sunos/config.h
new file mode 100644
index 0000000..e5e64c6
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/config/sunos/config.h
@@ -0,0 +1,370 @@
+/* Define in built-in ELF support is used */
+#define BUILTIN_ELF 1
+
+/* Define for ELF core file support */
+#define ELFCORE 1
+
+/* Define to 1 if you have the `asctime_r' function. */
+#define HAVE_ASCTIME_R 1
+
+/* Define to 1 if you have the `asprintf' function. */
+#define HAVE_ASPRINTF 1
+
+/* Define to 1 if you have the `ctime_r' function. */
+#define HAVE_CTIME_R 1
+
+/* HAVE_DAYLIGHT */
+#define HAVE_DAYLIGHT 1
+
+/* Define to 1 if you have the declaration of `daylight', and to 0 if you
+ don't. */
+#define HAVE_DECL_DAYLIGHT 1
+
+/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't.
+ */
+#define HAVE_DECL_TZNAME 1
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define to 1 if you have the `dprintf' function. */
+#define HAVE_DPRINTF 1
+
+/* Define to 1 if you have the <err.h> header file. */
+#define HAVE_ERR_H 1
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define to 1 if you have the `fmtcheck' function. */
+/*#undef HAVE_FMTCHECK*/
+
+/* Define to 1 if you have the `fork' function. */
+#define HAVE_FORK 1
+
+/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
+#define HAVE_FSEEKO 1
+
+/* Define to 1 if you have the `getline' function. */
+#define HAVE_GETLINE 1
+
+/* Define to 1 if you have the <getopt.h> header file. */
+#define HAVE_GETOPT_H 1
+
+/* Define to 1 if you have the `getopt_long' function. */
+#define HAVE_GETOPT_LONG 1
+
+/* Define to 1 if you have the `getpagesize' function. */
+#define HAVE_GETPAGESIZE 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the `gnurx' library (-lgnurx). */
+/* #undef HAVE_LIBGNURX */
+
+/* Define to 1 if you have the `z' library (-lz). */
+/* #undef HAVE_LIBZ */
+
+/* Define to 1 if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 1
+
+/* Define to 1 if you have the <locale.h> header file. */
+#define HAVE_LOCALE_H 1
+
+/* Define to 1 if mbrtowc and mbstate_t are properly declared. */
+#define HAVE_MBRTOWC 1
+
+/* Define to 1 if <wchar.h> declares mbstate_t. */
+#define HAVE_MBSTATE_T 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the `mkostemp' function. */
+#define HAVE_MKOSTEMP 1
+
+/* Define to 1 if you have the `mkstemp' function. */
+#define HAVE_MKSTEMP 1
+
+/* Define to 1 if you have a working `mmap' system call. */
+#define HAVE_MMAP 1
+
+/* Define to 1 if you have the `pread' function. */
+#define HAVE_PREAD 1
+
+/* Define to 1 if you have the <stddef.h> header file. */
+#define HAVE_STDDEF_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the `strcasestr' function. */
+#define HAVE_STRCASESTR 1
+
+/* Define to 1 if you have the `strerror' function. */
+#define HAVE_STRERROR 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the `strlcat' function. */
+#define HAVE_STRLCAT 1
+
+/* Define to 1 if you have the `strlcpy' function. */
+#define HAVE_STRLCPY 1
+
+/* Define to 1 if you have the `strndup' function. */
+#define HAVE_STRNDUP 1
+
+/* Define to 1 if you have the `strtof' function. */
+#define HAVE_STRTOF 1
+
+/* Define to 1 if you have the `strtoul' function. */
+#define HAVE_STRTOUL 1
+
+/* HAVE_STRUCT_OPTION */
+#define HAVE_STRUCT_OPTION 1
+
+/* Define to 1 if `st_rdev' is a member of `struct stat'. */
+#define HAVE_STRUCT_STAT_ST_RDEV 1
+
+/* Define to 1 if `tm_gmtoff' is a member of `struct tm'. */
+/* #undef HAVE_STRUCT_TM_TM_GMTOFF */
+
+/* Define to 1 if `tm_zone' is a member of `struct tm'. */
+/* #undef HAVE_STRUCT_TM_TM_ZONE */
+
+/* Define to 1 if you have the <sys/mman.h> header file. */
+#define HAVE_SYS_MMAN_H 1
+
+/* Define to 1 if you have the <sys/param.h> header file. */
+#define HAVE_SYS_PARAM_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#define HAVE_SYS_TIME_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <sys/utime.h> header file. */
+#define HAVE_SYS_UTIME_H 1
+
+/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
+#define HAVE_SYS_WAIT_H 1
+
+/* HAVE_TM_ISDST */
+#define HAVE_TM_ISDST 1
+
+/* HAVE_TM_ZONE */
+/* #undef HAVE_TM_ZONE */
+
+/* HAVE_TZNAME */
+#define HAVE_TZNAME 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to 1 if you have the `utime' function. */
+#define HAVE_UTIME 1
+
+/* Define to 1 if you have the `utimes' function. */
+#define HAVE_UTIMES 1
+
+/* Define to 1 if you have the <utime.h> header file. */
+#define HAVE_UTIME_H 1
+
+/* Define to 1 if you have the `vasprintf' function. */
+#define HAVE_VASPRINTF 1
+
+/* Define to 1 if you have the `vfork' function. */
+#define HAVE_VFORK 1
+
+/* Define to 1 if you have the <vfork.h> header file. */
+/* #undef HAVE_VFORK_H */
+
+/* Define to 1 or 0, depending whether the compiler supports simple visibility
+ declarations. */
+#define HAVE_VISIBILITY 1
+
+/* Define to 1 if you have the <wchar.h> header file. */
+#define HAVE_WCHAR_H 1
+
+/* Define to 1 if you have the <wctype.h> header file. */
+#define HAVE_WCTYPE_H 1
+
+/* Define to 1 if you have the `wcwidth' function. */
+#define HAVE_WCWIDTH 1
+
+/* Define to 1 if `fork' works. */
+#define HAVE_WORKING_FORK 1
+
+/* Define to 1 if `vfork' works. */
+#define HAVE_WORKING_VFORK 1
+
+/* Define to 1 if you have the <zlib.h> header file. */
+/* #undef HAVE_ZLIB_H */
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+ */
+#define LT_OBJDIR ".libs/"
+
+/* Define to 1 if `major', `minor', and `makedev' are declared in <mkdev.h>.
+ */
+#define MAJOR_IN_MKDEV 1
+
+/* Define to 1 if `major', `minor', and `makedev' are declared in
+ <sysmacros.h>. */
+/* #undef MAJOR_IN_SYSMACROS */
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define to 1 if your <sys/time.h> declares `struct tm'. */
+/* #undef TM_IN_SYS_TIME */
+
+/* Enable extensions on AIX 3, Interix. */
+#ifndef _ALL_SOURCE
+# define _ALL_SOURCE 1
+#endif
+/* Enable GNU extensions on systems that have them. */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+/* Enable threading extensions on Solaris. */
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# define _POSIX_PTHREAD_SEMANTICS 1
+#endif
+/* Enable extensions on HP NonStop. */
+#ifndef _TANDEM_SOURCE
+# define _TANDEM_SOURCE 1
+#endif
+/* Enable general extensions on Solaris. */
+#ifndef __EXTENSIONS__
+# define __EXTENSIONS__ 1
+#endif
+
+/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
+ significant byte first (like Motorola and SPARC, unlike Intel). */
+#if defined AC_APPLE_UNIVERSAL_BUILD
+# if defined __BIG_ENDIAN__
+# define WORDS_BIGENDIAN 1
+# endif
+#else
+# ifndef WORDS_BIGENDIAN
+/* # undef WORDS_BIGENDIAN */
+# endif
+#endif
+
+/* Enable large inode numbers on Mac OS X 10.5. */
+#ifndef _DARWIN_USE_64_BIT_INODE
+# define _DARWIN_USE_64_BIT_INODE 1
+#endif
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+#define _FILE_OFFSET_BITS 64
+
+/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
+/* #undef _LARGEFILE_SOURCE */
+
+/* Define for large files, on AIX-style hosts. */
+/* #undef _LARGE_FILES */
+
+/* Define to 1 if on MINIX. */
+/* #undef _MINIX */
+
+/* Define to 2 if the system does not provide POSIX.1 features except with
+ this defined. */
+/* #undef _POSIX_1_SOURCE */
+
+/* Define to 1 if you need to in order for `stat' and other things to work. */
+/* #undef _POSIX_SOURCE */
+
+/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
+ <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+ #define below would cause a syntax error. */
+/* #undef _UINT32_T */
+
+/* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
+ <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+ #define below would cause a syntax error. */
+/* #undef _UINT64_T */
+
+/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
+ <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+ #define below would cause a syntax error. */
+/* #undef _UINT8_T */
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef const */
+
+/* Define to the type of a signed integer type of width exactly 32 bits if
+ such a type exists and the standard includes do not define it. */
+/* #undef int32_t */
+
+/* Define to the type of a signed integer type of width exactly 64 bits if
+ such a type exists and the standard includes do not define it. */
+/* #undef int64_t */
+
+/* Define to a type if <wchar.h> does not define. */
+/* #undef mbstate_t */
+
+/* Define to `long int' if <sys/types.h> does not define. */
+/* #undef off_t */
+
+/* Define to `int' if <sys/types.h> does not define. */
+/* #undef pid_t */
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+/* #undef size_t */
+
+/* Define to the type of an unsigned integer type of width exactly 16 bits if
+ such a type exists and the standard includes do not define it. */
+/* #undef uint16_t */
+
+/* Define to the type of an unsigned integer type of width exactly 32 bits if
+ such a type exists and the standard includes do not define it. */
+/* #undef uint32_t */
+
+/* Define to the type of an unsigned integer type of width exactly 64 bits if
+ such a type exists and the standard includes do not define it. */
+/* #undef uint64_t */
+
+/* Define to the type of an unsigned integer type of width exactly 8 bits if
+ such a type exists and the standard includes do not define it. */
+/* #undef uint8_t */
+
+/* Define as `fork' if `vfork' does not work. */
+/* #undef vfork */
+
+#define HAVE_DIRENT_H 1
diff --git a/node_modules/mmmagic/deps/libmagic/config/win/config.h b/node_modules/mmmagic/deps/libmagic/config/win/config.h
new file mode 100644
index 0000000..546f560
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/config/win/config.h
@@ -0,0 +1,367 @@
+/* Define in built-in ELF support is used */
+#define BUILTIN_ELF 1
+
+/* Define for ELF core file support */
+#define ELFCORE 1
+
+/* Define to 1 if you have the `asctime_r' function. */
+#undef HAVE_ASCTIME_R
+
+/* Define to 1 if you have the `asprintf' function. */
+#undef HAVE_ASPRINTF
+
+/* Define to 1 if you have the `ctime_r' function. */
+#undef HAVE_CTIME_R
+
+/* HAVE_DAYLIGHT */
+#define HAVE_DAYLIGHT 1
+
+/* Define to 1 if you have the declaration of `daylight', and to 0 if you
+ don't. */
+#undef HAVE_DECL_DAYLIGHT
+
+/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't.
+ */
+#undef HAVE_DECL_TZNAME
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you have the `dprintf' function. */
+#undef HAVE_DPRINTF
+
+/* Define to 1 if you have the <err.h> header file. */
+#undef HAVE_ERR_H
+
+/* Define to 1 if you have the <dirent.h> header file. */
+#undef HAVE_DIRENT_H
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define to 1 if you have the `fmtcheck' function. */
+/*#undef HAVE_FMTCHECK*/
+
+/* Define to 1 if you have the `fork' function. */
+#undef HAVE_FORK
+
+/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
+#undef HAVE_FSEEKO
+
+/* Define to 1 if you have the `getline' function. */
+#undef HAVE_GETLINE
+
+/* Define to 1 if you have the <getopt.h> header file. */
+#undef HAVE_GETOPT_H
+
+/* Define to 1 if you have the `getopt_long' function. */
+#undef HAVE_GETOPT_LONG
+
+/* Define to 1 if you have the `getpagesize' function. */
+#undef HAVE_GETPAGESIZE
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the `gnurx' library (-lgnurx). */
+#undef HAVE_LIBGNURX
+
+/* Define to 1 if you have the `z' library (-lz). */
+/* #undef HAVE_LIBZ */
+
+/* Define to 1 if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 1
+
+/* Define to 1 if you have the <locale.h> header file. */
+#define HAVE_LOCALE_H 1
+
+/* Define to 1 if mbrtowc and mbstate_t are properly declared. */
+#define HAVE_MBRTOWC 1
+
+/* Define to 1 if <wchar.h> declares mbstate_t. */
+#define HAVE_MBSTATE_T 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the `mkostemp' function. */
+#undef HAVE_MKOSTEMP
+
+/* Define to 1 if you have the `mkstemp' function. */
+#undef HAVE_MKSTEMP
+
+/* Define to 1 if you have a working `mmap' system call. */
+#undef HAVE_MMAP
+
+/* Define to 1 if you have the `pread' function. */
+#undef HAVE_PREAD
+
+/* Define to 1 if you have the <stddef.h> header file. */
+#define HAVE_STDDEF_H 1
+
+/* Define to 1 if the system has the type `pid_t'. */
+#undef HAVE_PID_T
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the `strcasestr' function. */
+#define HAVE_STRCASESTR 1
+
+/* Define to 1 if you have the `strerror' function. */
+#define HAVE_STRERROR 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the `strlcat' function. */
+#undef HAVE_STRLCAT
+
+/* Define to 1 if you have the `strlcpy' function. */
+#undef HAVE_STRLCPY
+
+/* Define to 1 if you have the `strndup' function. */
+#undef HAVE_STRNDUP
+
+/* Define to 1 if you have the `strtof' function. */
+#undef HAVE_STRTOF
+
+/* Define to 1 if you have the `strtoul' function. */
+#define HAVE_STRTOUL 1
+
+/* HAVE_STRUCT_OPTION */
+#undef HAVE_STRUCT_OPTION
+
+/* Define to 1 if `st_rdev' is a member of `struct stat'. */
+#undef HAVE_STRUCT_STAT_ST_RDEV
+
+/* Define to 1 if `tm_gmtoff' is a member of `struct tm'. */
+#undef HAVE_STRUCT_TM_TM_GMTOFF
+
+/* Define to 1 if `tm_zone' is a member of `struct tm'. */
+#undef HAVE_STRUCT_TM_TM_ZONE
+
+/* Define to 1 if you have the <sys/mman.h> header file. */
+#undef HAVE_SYS_MMAN_H
+
+/* Define to 1 if you have the <sys/param.h> header file. */
+#undef HAVE_SYS_PARAM_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#undef HAVE_SYS_TIME_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <sys/utime.h> header file. */
+#define HAVE_SYS_UTIME_H 1
+
+/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
+#undef HAVE_SYS_WAIT_H
+
+/* HAVE_TM_ISDST */
+#undef HAVE_TM_ISDST
+
+/* HAVE_TM_ZONE */
+#undef HAVE_TM_ZONE
+
+/* HAVE_TZNAME */
+#undef HAVE_TZNAME
+
+/* Define to 1 if the system has the type `int32_t'. */
+#define HAVE_INT32_T 1
+
+/* Define to 1 if the system has the type `int64_t'. */
+#define HAVE_INT64_T 1
+
+/* Define to 1 if the system has the type `uint16_t'. */
+#define HAVE_UINT16_T 1
+
+/* Define to 1 if the system has the type `uint32_t'. */
+#define HAVE_UINT32_T 1
+
+/* Define to 1 if the system has the type `uint64_t'. */
+#define HAVE_UINT64_T 1
+
+/* Define to 1 if the system has the type `uint8_t'. */
+#define HAVE_UINT8_T 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to 1 if you have the `utime' function. */
+#undef HAVE_UTIME
+
+/* Define to 1 if you have the `utimes' function. */
+#undef HAVE_UTIMES
+
+/* Define to 1 if you have the <utime.h> header file. */
+#undef HAVE_UTIME_H
+
+/* Define to 1 if you have the `vasprintf' function. */
+#undef HAVE_VASPRINTF
+
+/* Define to 1 if you have the `vfork' function. */
+#undef HAVE_VFORK
+
+/* Define to 1 if you have the <vfork.h> header file. */
+/* #undef HAVE_VFORK_H */
+
+/* Define to 1 or 0, depending whether the compiler supports simple visibility
+ declarations. */
+#undef HAVE_VISIBILITY
+
+/* Define to 1 if you have the <wchar.h> header file. */
+#define HAVE_WCHAR_H 1
+
+/* Define to 1 if you have the <wctype.h> header file. */
+#define HAVE_WCTYPE_H 1
+
+/* Define to 1 if you have the `wcwidth' function. */
+#undef HAVE_WCWIDTH
+
+/* Define to 1 if `fork' works. */
+#undef HAVE_WORKING_FORK
+
+/* Define to 1 if `vfork' works. */
+#undef HAVE_WORKING_VFORK
+
+/* Define to 1 if you have the <zlib.h> header file. */
+/* #undef HAVE_ZLIB_H */
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+ */
+#undef LT_OBJDIR
+
+/* Define to 1 if `major', `minor', and `makedev' are declared in <mkdev.h>.
+ */
+#undef MAJOR_IN_MKDEV
+
+/* Define to 1 if `major', `minor', and `makedev' are declared in
+ <sysmacros.h>. */
+#undef MAJOR_IN_SYSMACROS
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* The size of `long long', as computed by sizeof. */
+#undef SIZEOF_LONG_LONG
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define to 1 if your <sys/time.h> declares `struct tm'. */
+#undef TM_IN_SYS_TIME
+
+/* Enable extensions on AIX 3, Interix. */
+#ifndef _ALL_SOURCE
+# undef _ALL_SOURCE
+#endif
+/* Enable GNU extensions on systems that have them. */
+#ifndef _GNU_SOURCE
+# undef _GNU_SOURCE
+#endif
+/* Enable threading extensions on Solaris. */
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# undef _POSIX_PTHREAD_SEMANTICS
+#endif
+/* Enable extensions on HP NonStop. */
+#ifndef _TANDEM_SOURCE
+# undef _TANDEM_SOURCE
+#endif
+/* Enable general extensions on Solaris. */
+#ifndef __EXTENSIONS__
+# undef __EXTENSIONS__
+#endif
+
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+#undef _FILE_OFFSET_BITS
+
+/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
+#undef _LARGEFILE_SOURCE
+
+/* Define for large files, on AIX-style hosts. */
+#undef _LARGE_FILES
+
+/* Define to 1 if on MINIX. */
+#undef _MINIX
+
+/* Define to 2 if the system does not provide POSIX.1 features except with
+ this defined. */
+#undef _POSIX_1_SOURCE
+
+/* Define to 1 if you need to in order for `stat' and other things to work. */
+#undef _POSIX_SOURCE
+
+/* Define to empty if `const' does not conform to ANSI C. */
+//#define const
+
+/* Define to a type if <wchar.h> does not define. */
+//#undef mbstate_t
+
+/* Define to `long int' if <sys/types.h> does not define. */
+//#undef off_t
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+//#undef size_t
+
+
+#ifndef HAVE_UINT8_T
+typedef unsigned char uint8_t;
+#endif
+#ifndef HAVE_UINT16_T
+typedef unsigned short uint16_t;
+#endif
+#ifndef HAVE_UINT32_T
+typedef unsigned int uint32_t;
+#endif
+#ifndef HAVE_INT32_T
+typedef int int32_t;
+#endif
+#ifndef HAVE_UINT64_T
+#if SIZEOF_LONG_LONG == 8
+typedef unsigned long long uint64_t;
+#else
+typedef unsigned long uint64_t;
+#endif
+#endif
+#ifndef HAVE_INT64_T
+#if SIZEOF_LONG_LONG == 8
+typedef long long int64_t;
+#else
+typedef long int64_t;
+#endif
+#endif
+
+#include <crtdefs.h>
+
+/* Define as `fork' if `vfork' does not work. */
+/* #undef vfork */
diff --git a/node_modules/mmmagic/deps/libmagic/libmagic.gyp b/node_modules/mmmagic/deps/libmagic/libmagic.gyp
new file mode 100644
index 0000000..76be697
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/libmagic.gyp
@@ -0,0 +1,85 @@
+{
+ 'targets': [
+ {
+ 'target_name': 'libmagic',
+ 'type': 'static_library',
+ 'include_dirs': [ '.', 'src' ],
+ 'defines': [ 'HAVE_CONFIG_H', 'VERSION="5.32"' ],
+ 'conditions': [
+ [ 'OS!="freebsd" and OS!="mac"', {
+ 'sources': [ 'src/fmtcheck.c' ],
+ }],
+ [ 'OS=="win"', {
+ 'sources': [
+ 'src/asctime_r.c',
+ 'src/asprintf.c',
+ 'src/ctime_r.c',
+ 'src/dprintf.c',
+ 'src/getline.c',
+ 'src/gmtime_r.c',
+ 'src/localtime_r.c',
+ 'src/pread.c',
+ 'src/snprintf.c',
+ 'src/strcasestr.c',
+ 'src/strlcat.c',
+ 'src/strlcpy.c',
+ 'src/vasprintf.c',
+ # POSIX regex implementation
+ 'msvc/libgnurx-2.5/regex.c',
+ ],
+ 'include_dirs': [ 'config/win', 'msvc', 'msvc/libgnurx-2.5' ],
+ 'link_settings': {
+ 'libraries': [
+ '-lshlwapi.lib',
+ ]
+ },
+ }, { # POSIX
+ 'cflags': [ '-std=c99' ],
+ }],
+ [ 'OS=="linux"', {
+ 'sources': [
+ 'src/strlcat.c',
+ 'src/strlcpy.c',
+ ],
+ 'include_dirs': [ 'config/linux' ],
+ }],
+ [ 'OS=="mac"', {
+ 'include_dirs': [ 'config/mac' ],
+ }],
+ [ 'OS=="freebsd"', {
+ 'include_dirs': [ 'config/freebsd' ],
+ }],
+ [ 'OS=="openbsd"', {
+ 'include_dirs': [ 'config/openbsd' ],
+ }],
+ [ 'OS=="solaris"', {
+ 'include_dirs': [ 'config/sunos' ],
+ }],
+ ],
+ 'cflags!': [ '-O2' ],
+ 'cflags+': [ '-O3' ],
+ 'cflags_cc!': [ '-O2' ],
+ 'cflags_cc+': [ '-O3' ],
+ 'cflags_c!': [ '-O2' ],
+ 'cflags_c+': [ '-O3' ],
+ 'sources': [
+ 'src/apprentice.c',
+ 'src/apptype.c',
+ 'src/ascmagic.c',
+ 'src/cdf.c',
+ 'src/cdf_time.c',
+ 'src/compress.c',
+ 'src/der.c',
+ 'src/encoding.c',
+ 'src/fsmagic.c',
+ 'src/funcs.c',
+ 'src/is_tar.c',
+ 'src/magic.c',
+ 'src/print.c',
+ 'src/readcdf.c',
+ 'src/readelf.c',
+ 'src/softmagic.c',
+ ],
+ },
+ ]
+}
diff --git a/node_modules/mmmagic/deps/libmagic/msvc/dirent.h b/node_modules/mmmagic/deps/libmagic/msvc/dirent.h
new file mode 100644
index 0000000..445d040
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/msvc/dirent.h
@@ -0,0 +1,372 @@
+/*****************************************************************************
+ * dirent.h - dirent API for Microsoft Visual Studio
+ *
+ * Copyright (C) 2006 Toni Ronkko
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * ``Software''), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL TONI RONKKO BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Mar 15, 2011, Toni Ronkko
+ * Defined FILE_ATTRIBUTE_DEVICE for MSVC 6.0.
+ *
+ * Aug 11, 2010, Toni Ronkko
+ * Added d_type and d_namlen fields to dirent structure. The former is
+ * especially useful for determining whether directory entry represents a
+ * file or a directory. For more information, see
+ * http://www.delorie.com/gnu/docs/glibc/libc_270.html
+ *
+ * Aug 11, 2010, Toni Ronkko
+ * Improved conformance to the standards. For example, errno is now set
+ * properly on failure and assert() is never used. Thanks to Peter Brockam
+ * for suggestions.
+ *
+ * Aug 11, 2010, Toni Ronkko
+ * Fixed a bug in rewinddir(): when using relative directory names, change
+ * of working directory no longer causes rewinddir() to fail.
+ *
+ * Dec 15, 2009, John Cunningham
+ * Added rewinddir member function
+ *
+ * Jan 18, 2008, Toni Ronkko
+ * Using FindFirstFileA and WIN32_FIND_DATAA to avoid converting string
+ * between multi-byte and unicode representations. This makes the
+ * code simpler and also allows the code to be compiled under MingW. Thanks
+ * to Azriel Fasten for the suggestion.
+ *
+ * Mar 4, 2007, Toni Ronkko
+ * Bug fix: due to the strncpy_s() function this file only compiled in
+ * Visual Studio 2005. Using the new string functions only when the
+ * compiler version allows.
+ *
+ * Nov 2, 2006, Toni Ronkko
+ * Major update: removed support for Watcom C, MS-DOS and Turbo C to
+ * simplify the file, updated the code to compile cleanly on Visual
+ * Studio 2005 with both unicode and multi-byte character strings,
+ * removed rewinddir() as it had a bug.
+ *
+ * Aug 20, 2006, Toni Ronkko
+ * Removed all remarks about MSVC 1.0, which is antiqued now. Simplified
+ * comments by removing SGML tags.
+ *
+ * May 14 2002, Toni Ronkko
+ * Embedded the function definitions directly to the header so that no
+ * source modules need to be included in the Visual Studio project. Removed
+ * all the dependencies to other projects so that this very header can be
+ * used independently.
+ *
+ * May 28 1998, Toni Ronkko
+ * First version.
+ *****************************************************************************/
+#ifndef DIRENT_H
+#define DIRENT_H
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+/* Entries missing from MSVC 6.0 */
+#if !defined(FILE_ATTRIBUTE_DEVICE)
+# define FILE_ATTRIBUTE_DEVICE 0x40
+#endif
+
+/* File type and permission flags for stat() */
+#if defined(_MSC_VER) && !defined(S_IREAD)
+# define S_IFMT _S_IFMT /* file type mask */
+# define S_IFDIR _S_IFDIR /* directory */
+# define S_IFCHR _S_IFCHR /* character device */
+# define S_IFFIFO _S_IFFIFO /* pipe */
+# define S_IFREG _S_IFREG /* regular file */
+# define S_IREAD _S_IREAD /* read permission */
+# define S_IWRITE _S_IWRITE /* write permission */
+# define S_IEXEC _S_IEXEC /* execute permission */
+#endif
+#define S_IFBLK 0 /* block device */
+#define S_IFLNK 0 /* link */
+#define S_IFSOCK 0 /* socket */
+
+#if defined(_MSC_VER)
+# define S_IRUSR S_IREAD /* read, user */
+# define S_IWUSR S_IWRITE /* write, user */
+# define S_IXUSR 0 /* execute, user */
+# define S_IRGRP 0 /* read, group */
+# define S_IWGRP 0 /* write, group */
+# define S_IXGRP 0 /* execute, group */
+# define S_IROTH 0 /* read, others */
+# define S_IWOTH 0 /* write, others */
+# define S_IXOTH 0 /* execute, others */
+#endif
+
+/* Indicates that d_type field is available in dirent structure */
+#define _DIRENT_HAVE_D_TYPE
+
+/* File type flags for d_type */
+#define DT_UNKNOWN 0
+#define DT_REG S_IFREG
+#define DT_DIR S_IFDIR
+#define DT_FIFO S_IFFIFO
+#define DT_SOCK S_IFSOCK
+#define DT_CHR S_IFCHR
+#define DT_BLK S_IFBLK
+
+/* Macros for converting between st_mode and d_type */
+#define IFTODT(mode) ((mode) & S_IFMT)
+#define DTTOIF(type) (type)
+
+/*
+ * File type macros. Note that block devices, sockets and links cannot be
+ * distinguished on Windows and the macros S_ISBLK, S_ISSOCK and S_ISLNK are
+ * only defined for compatibility. These macros should always return false
+ * on Windows.
+ */
+#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFFIFO)
+#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
+#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
+#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
+#define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
+#define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
+#define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+typedef struct dirent
+{
+ char d_name[MAX_PATH + 1]; /* File name */
+ size_t d_namlen; /* Length of name without \0 */
+ int d_type; /* File type */
+} dirent;
+
+
+typedef struct DIR
+{
+ dirent curentry; /* Current directory entry */
+ WIN32_FIND_DATAA find_data; /* Private file data */
+ int cached; /* True if data is valid */
+ HANDLE search_handle; /* Win32 search handle */
+ char patt[MAX_PATH + 3]; /* Initial directory name */
+} DIR;
+
+
+/* Forward declarations */
+static DIR *opendir(const char *dirname);
+static struct dirent *readdir(DIR *dirp);
+static int closedir(DIR *dirp);
+static void rewinddir(DIR* dirp);
+
+
+/* Use the new safe string functions introduced in Visual Studio 2005 */
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+# define DIRENT_STRNCPY(dest,src,size) strncpy_s((dest),(size),(src),_TRUNCATE)
+#else
+# define DIRENT_STRNCPY(dest,src,size) strncpy((dest),(src),(size))
+#endif
+
+/* Set errno variable */
+#if defined(_MSC_VER)
+#define DIRENT_SET_ERRNO(x) _set_errno (x)
+#else
+#define DIRENT_SET_ERRNO(x) (errno = (x))
+#endif
+
+
+/*****************************************************************************
+ * Open directory stream DIRNAME for read and return a pointer to the
+ * internal working area that is used to retrieve individual directory
+ * entries.
+ */
+static DIR *opendir(const char *dirname)
+{
+ DIR *dirp;
+
+ /* ensure that the resulting search pattern will be a valid file name */
+ if (dirname == NULL) {
+ DIRENT_SET_ERRNO (ENOENT);
+ return NULL;
+ }
+ if (strlen (dirname) + 3 >= MAX_PATH) {
+ DIRENT_SET_ERRNO (ENAMETOOLONG);
+ return NULL;
+ }
+
+ /* construct new DIR structure */
+ dirp = (DIR*) malloc (sizeof (struct DIR));
+ if (dirp != NULL) {
+ int error;
+
+ /*
+ * Convert relative directory name to an absolute one. This
+ * allows rewinddir() to function correctly when the current working
+ * directory is changed between opendir() and rewinddir().
+ */
+ if (GetFullPathNameA (dirname, MAX_PATH, dirp->patt, NULL)) {
+ char *p;
+
+ /* append the search pattern "\\*\0" to the directory name */
+ p = strchr (dirp->patt, '\0');
+ if (dirp->patt < p && *(p-1) != '\\' && *(p-1) != ':') {
+ *p++ = '\\';
+ }
+ *p++ = '*';
+ *p = '\0';
+
+ /* open directory stream and retrieve the first entry */
+ dirp->search_handle = FindFirstFileA (dirp->patt, &dirp->find_data);
+ if (dirp->search_handle != INVALID_HANDLE_VALUE) {
+ /* a directory entry is now waiting in memory */
+ dirp->cached = 1;
+ error = 0;
+ } else {
+ /* search pattern is not a directory name? */
+ DIRENT_SET_ERRNO (ENOENT);
+ error = 1;
+ }
+ } else {
+ /* buffer too small */
+ DIRENT_SET_ERRNO (ENOMEM);
+ error = 1;
+ }
+
+ if (error) {
+ free (dirp);
+ dirp = NULL;
+ }
+ }
+
+ return dirp;
+}
+
+
+/*****************************************************************************
+ * Read a directory entry, and return a pointer to a dirent structure
+ * containing the name of the entry in d_name field. Individual directory
+ * entries returned by this very function include regular files,
+ * sub-directories, pseudo-directories "." and "..", but also volume labels,
+ * hidden files and system files may be returned.
+ */
+static struct dirent *readdir(DIR *dirp)
+{
+ DWORD attr;
+ if (dirp == NULL) {
+ /* directory stream did not open */
+ DIRENT_SET_ERRNO (EBADF);
+ return NULL;
+ }
+
+ /* get next directory entry */
+ if (dirp->cached != 0) {
+ /* a valid directory entry already in memory */
+ dirp->cached = 0;
+ } else {
+ /* get the next directory entry from stream */
+ if (dirp->search_handle == INVALID_HANDLE_VALUE) {
+ return NULL;
+ }
+ if (FindNextFileA (dirp->search_handle, &dirp->find_data) == FALSE) {
+ /* the very last entry has been processed or an error occured */
+ FindClose (dirp->search_handle);
+ dirp->search_handle = INVALID_HANDLE_VALUE;
+ return NULL;
+ }
+ }
+
+ /* copy as a multibyte character string */
+ DIRENT_STRNCPY ( dirp->curentry.d_name,
+ dirp->find_data.cFileName,
+ sizeof(dirp->curentry.d_name) );
+ dirp->curentry.d_name[MAX_PATH] = '\0';
+
+ /* compute the length of name */
+ dirp->curentry.d_namlen = strlen (dirp->curentry.d_name);
+
+ /* determine file type */
+ attr = dirp->find_data.dwFileAttributes;
+ if ((attr & FILE_ATTRIBUTE_DEVICE) != 0) {
+ dirp->curentry.d_type = DT_CHR;
+ } else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
+ dirp->curentry.d_type = DT_DIR;
+ } else {
+ dirp->curentry.d_type = DT_REG;
+ }
+ return &dirp->curentry;
+}
+
+
+/*****************************************************************************
+ * Close directory stream opened by opendir() function. Close of the
+ * directory stream invalidates the DIR structure as well as any previously
+ * read directory entry.
+ */
+static int closedir(DIR *dirp)
+{
+ if (dirp == NULL) {
+ /* invalid directory stream */
+ DIRENT_SET_ERRNO (EBADF);
+ return -1;
+ }
+
+ /* release search handle */
+ if (dirp->search_handle != INVALID_HANDLE_VALUE) {
+ FindClose (dirp->search_handle);
+ dirp->search_handle = INVALID_HANDLE_VALUE;
+ }
+
+ /* release directory structure */
+ free (dirp);
+ return 0;
+}
+
+
+/*****************************************************************************
+ * Resets the position of the directory stream to which dirp refers to the
+ * beginning of the directory. It also causes the directory stream to refer
+ * to the current state of the corresponding directory, as a call to opendir()
+ * would have done. If dirp does not refer to a directory stream, the effect
+ * is undefined.
+ */
+static void rewinddir(DIR* dirp)
+{
+ if (dirp != NULL) {
+ /* release search handle */
+ if (dirp->search_handle != INVALID_HANDLE_VALUE) {
+ FindClose (dirp->search_handle);
+ }
+
+ /* open new search handle and retrieve the first entry */
+ dirp->search_handle = FindFirstFileA (dirp->patt, &dirp->find_data);
+ if (dirp->search_handle != INVALID_HANDLE_VALUE) {
+ /* a directory entry is now waiting in memory */
+ dirp->cached = 1;
+ } else {
+ /* failed to re-open directory: no directory entry in memory */
+ dirp->cached = 0;
+ }
+ }
+}
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /*DIRENT_H*/
diff --git a/node_modules/mmmagic/deps/libmagic/msvc/inttypes.h b/node_modules/mmmagic/deps/libmagic/msvc/inttypes.h
new file mode 100644
index 0000000..4b3828a
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/msvc/inttypes.h
@@ -0,0 +1,305 @@
+// ISO C9x compliant inttypes.h for Microsoft Visual Studio
+// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
+//
+// Copyright (c) 2006 Alexander Chemeris
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// 3. The name of the author may be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _MSC_VER // [
+#error "Use this header only with Microsoft Visual C++ compilers!"
+#endif // _MSC_VER ]
+
+#ifndef _MSC_INTTYPES_H_ // [
+#define _MSC_INTTYPES_H_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif
+
+#include "stdint.h"
+
+// 7.8 Format conversion of integer types
+
+typedef struct {
+ intmax_t quot;
+ intmax_t rem;
+} imaxdiv_t;
+
+// 7.8.1 Macros for format specifiers
+
+#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [ See footnote 185 at page 198
+
+// The fprintf macros for signed integers are:
+#define PRId8 "d"
+#define PRIi8 "i"
+#define PRIdLEAST8 "d"
+#define PRIiLEAST8 "i"
+#define PRIdFAST8 "d"
+#define PRIiFAST8 "i"
+
+#define PRId16 "hd"
+#define PRIi16 "hi"
+#define PRIdLEAST16 "hd"
+#define PRIiLEAST16 "hi"
+#define PRIdFAST16 "hd"
+#define PRIiFAST16 "hi"
+
+#define PRId32 "I32d"
+#define PRIi32 "I32i"
+#define PRIdLEAST32 "I32d"
+#define PRIiLEAST32 "I32i"
+#define PRIdFAST32 "I32d"
+#define PRIiFAST32 "I32i"
+
+#define PRId64 "I64d"
+#define PRIi64 "I64i"
+#define PRIdLEAST64 "I64d"
+#define PRIiLEAST64 "I64i"
+#define PRIdFAST64 "I64d"
+#define PRIiFAST64 "I64i"
+
+#define PRIdMAX "I64d"
+#define PRIiMAX "I64i"
+
+#define PRIdPTR "Id"
+#define PRIiPTR "Ii"
+
+// The fprintf macros for unsigned integers are:
+#define PRIo8 "o"
+#define PRIu8 "u"
+#define PRIx8 "x"
+#define PRIX8 "X"
+#define PRIoLEAST8 "o"
+#define PRIuLEAST8 "u"
+#define PRIxLEAST8 "x"
+#define PRIXLEAST8 "X"
+#define PRIoFAST8 "o"
+#define PRIuFAST8 "u"
+#define PRIxFAST8 "x"
+#define PRIXFAST8 "X"
+
+#define PRIo16 "ho"
+#define PRIu16 "hu"
+#define PRIx16 "hx"
+#define PRIX16 "hX"
+#define PRIoLEAST16 "ho"
+#define PRIuLEAST16 "hu"
+#define PRIxLEAST16 "hx"
+#define PRIXLEAST16 "hX"
+#define PRIoFAST16 "ho"
+#define PRIuFAST16 "hu"
+#define PRIxFAST16 "hx"
+#define PRIXFAST16 "hX"
+
+#define PRIo32 "I32o"
+#define PRIu32 "I32u"
+#define PRIx32 "I32x"
+#define PRIX32 "I32X"
+#define PRIoLEAST32 "I32o"
+#define PRIuLEAST32 "I32u"
+#define PRIxLEAST32 "I32x"
+#define PRIXLEAST32 "I32X"
+#define PRIoFAST32 "I32o"
+#define PRIuFAST32 "I32u"
+#define PRIxFAST32 "I32x"
+#define PRIXFAST32 "I32X"
+
+#define PRIo64 "I64o"
+#define PRIu64 "I64u"
+#define PRIx64 "I64x"
+#define PRIX64 "I64X"
+#define PRIoLEAST64 "I64o"
+#define PRIuLEAST64 "I64u"
+#define PRIxLEAST64 "I64x"
+#define PRIXLEAST64 "I64X"
+#define PRIoFAST64 "I64o"
+#define PRIuFAST64 "I64u"
+#define PRIxFAST64 "I64x"
+#define PRIXFAST64 "I64X"
+
+#define PRIoMAX "I64o"
+#define PRIuMAX "I64u"
+#define PRIxMAX "I64x"
+#define PRIXMAX "I64X"
+
+#define PRIoPTR "Io"
+#define PRIuPTR "Iu"
+#define PRIxPTR "Ix"
+#define PRIXPTR "IX"
+
+// The fscanf macros for signed integers are:
+#define SCNd8 "d"
+#define SCNi8 "i"
+#define SCNdLEAST8 "d"
+#define SCNiLEAST8 "i"
+#define SCNdFAST8 "d"
+#define SCNiFAST8 "i"
+
+#define SCNd16 "hd"
+#define SCNi16 "hi"
+#define SCNdLEAST16 "hd"
+#define SCNiLEAST16 "hi"
+#define SCNdFAST16 "hd"
+#define SCNiFAST16 "hi"
+
+#define SCNd32 "ld"
+#define SCNi32 "li"
+#define SCNdLEAST32 "ld"
+#define SCNiLEAST32 "li"
+#define SCNdFAST32 "ld"
+#define SCNiFAST32 "li"
+
+#define SCNd64 "I64d"
+#define SCNi64 "I64i"
+#define SCNdLEAST64 "I64d"
+#define SCNiLEAST64 "I64i"
+#define SCNdFAST64 "I64d"
+#define SCNiFAST64 "I64i"
+
+#define SCNdMAX "I64d"
+#define SCNiMAX "I64i"
+
+#ifdef _WIN64 // [
+# define SCNdPTR "I64d"
+# define SCNiPTR "I64i"
+#else // _WIN64 ][
+# define SCNdPTR "ld"
+# define SCNiPTR "li"
+#endif // _WIN64 ]
+
+// The fscanf macros for unsigned integers are:
+#define SCNo8 "o"
+#define SCNu8 "u"
+#define SCNx8 "x"
+#define SCNX8 "X"
+#define SCNoLEAST8 "o"
+#define SCNuLEAST8 "u"
+#define SCNxLEAST8 "x"
+#define SCNXLEAST8 "X"
+#define SCNoFAST8 "o"
+#define SCNuFAST8 "u"
+#define SCNxFAST8 "x"
+#define SCNXFAST8 "X"
+
+#define SCNo16 "ho"
+#define SCNu16 "hu"
+#define SCNx16 "hx"
+#define SCNX16 "hX"
+#define SCNoLEAST16 "ho"
+#define SCNuLEAST16 "hu"
+#define SCNxLEAST16 "hx"
+#define SCNXLEAST16 "hX"
+#define SCNoFAST16 "ho"
+#define SCNuFAST16 "hu"
+#define SCNxFAST16 "hx"
+#define SCNXFAST16 "hX"
+
+#define SCNo32 "lo"
+#define SCNu32 "lu"
+#define SCNx32 "lx"
+#define SCNX32 "lX"
+#define SCNoLEAST32 "lo"
+#define SCNuLEAST32 "lu"
+#define SCNxLEAST32 "lx"
+#define SCNXLEAST32 "lX"
+#define SCNoFAST32 "lo"
+#define SCNuFAST32 "lu"
+#define SCNxFAST32 "lx"
+#define SCNXFAST32 "lX"
+
+#define SCNo64 "I64o"
+#define SCNu64 "I64u"
+#define SCNx64 "I64x"
+#define SCNX64 "I64X"
+#define SCNoLEAST64 "I64o"
+#define SCNuLEAST64 "I64u"
+#define SCNxLEAST64 "I64x"
+#define SCNXLEAST64 "I64X"
+#define SCNoFAST64 "I64o"
+#define SCNuFAST64 "I64u"
+#define SCNxFAST64 "I64x"
+#define SCNXFAST64 "I64X"
+
+#define SCNoMAX "I64o"
+#define SCNuMAX "I64u"
+#define SCNxMAX "I64x"
+#define SCNXMAX "I64X"
+
+#ifdef _WIN64 // [
+# define SCNoPTR "I64o"
+# define SCNuPTR "I64u"
+# define SCNxPTR "I64x"
+# define SCNXPTR "I64X"
+#else // _WIN64 ][
+# define SCNoPTR "lo"
+# define SCNuPTR "lu"
+# define SCNxPTR "lx"
+# define SCNXPTR "lX"
+#endif // _WIN64 ]
+
+#endif // __STDC_FORMAT_MACROS ]
+
+// 7.8.2 Functions for greatest-width integer types
+
+// 7.8.2.1 The imaxabs function
+#define imaxabs _abs64
+
+// 7.8.2.2 The imaxdiv function
+
+// This is modified version of div() function from Microsoft's div.c found
+// in %MSVC.NET%\crt\src\div.c
+#ifdef STATIC_IMAXDIV // [
+static
+#else // STATIC_IMAXDIV ][
+_inline
+#endif // STATIC_IMAXDIV ]
+imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom)
+{
+ imaxdiv_t result;
+
+ result.quot = numer / denom;
+ result.rem = numer % denom;
+
+ if (numer < 0 && result.rem > 0) {
+ // did division wrong; must fix up
+ ++result.quot;
+ result.rem -= denom;
+ }
+
+ return result;
+}
+
+// 7.8.2.3 The strtoimax and strtoumax functions
+#define strtoimax _strtoi64
+#define strtoumax _strtoui64
+
+// 7.8.2.4 The wcstoimax and wcstoumax functions
+#define wcstoimax _wcstoi64
+#define wcstoumax _wcstoui64
+
+
+#endif // _MSC_INTTYPES_H_ ]
diff --git a/node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/COPYING.LIB b/node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/COPYING.LIB
new file mode 100644
index 0000000..cf9b6b9
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/COPYING.LIB
@@ -0,0 +1,510 @@
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations
+below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+^L
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it
+becomes a de-facto standard. To achieve this, non-free programs must
+be allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+^L
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control
+compilation and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+^L
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+^L
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at least
+ three years, to give the same user the materials specified in
+ Subsection 6a, above, for a charge no more than the cost of
+ performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+^L
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+^L
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply, and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License
+may add an explicit geographical distribution limitation excluding those
+countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+^L
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+^L
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms
+of the ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library.
+It is safest to attach them to the start of each source file to most
+effectively convey the exclusion of warranty; and each file should
+have at least the "copyright" line and a pointer to where the full
+notice is found.
+
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or
+your school, if any, to sign a "copyright disclaimer" for the library,
+if necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James
+ Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/Makefile b/node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/Makefile
new file mode 100644
index 0000000..f777eea
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/Makefile
@@ -0,0 +1,41 @@
+all: libgnurx-0.dll libgnurx.dll.a libregex.a
+
+THIS = libgnurx
+VERSION = 2.5
+
+CC = x86_64-w64-mingw32-gcc -mthreads
+CFLAGS = -I .
+
+SOURCES = $(wildcard *.c *.h)
+OBJECTS = regex.o
+
+libgnurx-0.dll libgnurx.dll.a: $(OBJECTS) Makefile
+ $(CC) -shared -o libgnurx-0.dll -Wl,--enable-auto-image-base -Wl,--out-implib,libgnurx.dll.a -Wl,--output-def,libgnurx.def $(OBJECTS)
+
+libregex.a: libgnurx.dll.a
+ cp -p libgnurx.dll.a $@
+
+dist: $(THIS)-$(VERSION).zip $(THIS)-dev-$(VERSION).zip $(THIS)-src-$(VERSION).zip
+
+$(THIS)-$(VERSION).zip: libgnurx-0.dll
+ mkdir -p runtime/bin
+ cp -p libgnurx-0.dll runtime/bin
+ (cd runtime; zip -r ../$(THIS)-$(VERSION).zip bin)
+ rm -rf runtime
+
+$(THIS)-dev-$(VERSION).zip: regex.h libgnurx.dll.a libregex.a
+ mkdir -p dev/include dev/lib
+ cp -p regex.h dev/include
+ cp -p libgnurx.dll.a libregex.a gnurx.lib dev/lib
+ (cd dev; zip -r ../$(THIS)-dev-$(VERSION).zip .)
+ rm -rf dev
+
+$(THIS)-src-$(VERSION).zip: Makefile README COPYING.LIB $(SOURCES)
+ mkdir $(THIS)-$(VERSION)
+ cp -p Makefile README COPYING.LIB $(SOURCES) $(THIS)-$(VERSION)
+ zip -r $@ $(THIS)-$(VERSION$)
+ rm -rf $(THIS)-$(VERSION$)
+
+clean:
+ rm -f *~ *.o *.dll *.def *.exp *.a *.zip
+ rm -rf runtime dev $(THIS)-$(VERSION)
diff --git a/node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/README b/node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/README
new file mode 100644
index 0000000..534cc3c
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/README
@@ -0,0 +1,33 @@
+This is the regex functionality from glibc 2.5 extracted into a
+separate library, for Win32.
+
+I call the DLL libgnurx-0.dll which hopefully should be unique. At
+least it isn't "regex.dll" which has been used by the
+gnuwin32.sourceforge.net site for *two* incompatible DLLs. (That mess,
+and the mess with their build of Henry Spencer's regex library, was
+what lead me to build my own GNU regex library. See the gnuwin32-users mailing list archives from December 2006.)
+
+The "-0" is so that if at some point I build a release that isn't
+binary compatible, I can then increment that and use a different name.
+
+The import library for gcc is called libgnurx.dll.a, but I also
+distribute a copy of it called libregex.a so that configure scripts
+that look for -lregex will work.
+
+Note that none of the wide-character and i18n functionality which is
+built when this is part of glibc gets compiled. Thus things like
+character classes most probably work only for single-byte codepages.
+
+Compiling that stuff would drag in lots of glibc's locale handling
+stuff which is completely incompatible with Microsoft's C library's
+locale handling anyway. Also, I am not sure whether the GNU regex code
+is prepared to handle a two-byte wchar_t, or does it assume that
+wchar_t is int as it is on Linux? Hmm, actually there is lots of
+sizeof(wchar_t) in glibc, so maybe it *is* prepared? Maybe
+later... But anyway, it would presumably mean we should have not just
+the regex functionality but a larger subset of glibc that would
+include all locale, ctype, wchar, mbs, etc stuff, presumably ending up
+with a very large part of glibc (not the system calls,
+obviously). Indeed, something to save for later, or never...
+
+--Tor Lillqvist <tml@iki.fi>, <tml@novell.com>
diff --git a/node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/README.md b/node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/README.md
new file mode 100644
index 0000000..6e761b1
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/README.md
@@ -0,0 +1,10 @@
+This version of libgnurx was taken from https://github.com/nscaife/file-windows/tree/master/libgnurx-2.5.
+
+Only one modification has been made to the code taken from the above source: regexec.c contained a ternary expression with a missing expression, which is not supported by the Visual C compiler, so the missing expression has been re-added.
+
+Original README.md below
+========================
+
+The contents of this directory are from http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/.
+
+I have made a few modifications to the Makefile to disable creation of gnurx.lib. The creation of this file relies on lib.exe from Visual Studio (forcing a Windows build environment), and is not needed to build libmagic or file.
diff --git a/node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/regcomp.c b/node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/regcomp.c
new file mode 100644
index 0000000..78a1218
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/regcomp.c
@@ -0,0 +1,3800 @@
+/* Extended regular expression matching and search library.
+ Copyright (C) 2002,2003,2004,2005,2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern,
+ size_t length, reg_syntax_t syntax);
+static void re_compile_fastmap_iter (regex_t *bufp,
+ const re_dfastate_t *init_state,
+ char *fastmap);
+static reg_errcode_t init_dfa (re_dfa_t *dfa, size_t pat_len);
+#ifdef RE_ENABLE_I18N
+static void free_charset (re_charset_t *cset);
+#endif /* RE_ENABLE_I18N */
+static void free_workarea_compile (regex_t *preg);
+static reg_errcode_t create_initial_state (re_dfa_t *dfa);
+#ifdef RE_ENABLE_I18N
+static void optimize_utf8 (re_dfa_t *dfa);
+#endif
+static reg_errcode_t analyze (regex_t *preg);
+static reg_errcode_t preorder (bin_tree_t *root,
+ reg_errcode_t (fn (void *, bin_tree_t *)),
+ void *extra);
+static reg_errcode_t postorder (bin_tree_t *root,
+ reg_errcode_t (fn (void *, bin_tree_t *)),
+ void *extra);
+static reg_errcode_t optimize_subexps (void *extra, bin_tree_t *node);
+static reg_errcode_t lower_subexps (void *extra, bin_tree_t *node);
+static bin_tree_t *lower_subexp (reg_errcode_t *err, regex_t *preg,
+ bin_tree_t *node);
+static reg_errcode_t calc_first (void *extra, bin_tree_t *node);
+static reg_errcode_t calc_next (void *extra, bin_tree_t *node);
+static reg_errcode_t link_nfa_nodes (void *extra, bin_tree_t *node);
+static int duplicate_node (re_dfa_t *dfa, int org_idx, unsigned int constraint);
+static int search_duplicated_node (const re_dfa_t *dfa, int org_node,
+ unsigned int constraint);
+static reg_errcode_t calc_eclosure (re_dfa_t *dfa);
+static reg_errcode_t calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa,
+ int node, int root);
+static reg_errcode_t calc_inveclosure (re_dfa_t *dfa);
+static int fetch_number (re_string_t *input, re_token_t *token,
+ reg_syntax_t syntax);
+static int peek_token (re_token_t *token, re_string_t *input,
+ reg_syntax_t syntax) internal_function;
+static bin_tree_t *parse (re_string_t *regexp, regex_t *preg,
+ reg_syntax_t syntax, reg_errcode_t *err);
+static bin_tree_t *parse_reg_exp (re_string_t *regexp, regex_t *preg,
+ re_token_t *token, reg_syntax_t syntax,
+ int nest, reg_errcode_t *err);
+static bin_tree_t *parse_branch (re_string_t *regexp, regex_t *preg,
+ re_token_t *token, reg_syntax_t syntax,
+ int nest, reg_errcode_t *err);
+static bin_tree_t *parse_expression (re_string_t *regexp, regex_t *preg,
+ re_token_t *token, reg_syntax_t syntax,
+ int nest, reg_errcode_t *err);
+static bin_tree_t *parse_sub_exp (re_string_t *regexp, regex_t *preg,
+ re_token_t *token, reg_syntax_t syntax,
+ int nest, reg_errcode_t *err);
+static bin_tree_t *parse_dup_op (bin_tree_t *dup_elem, re_string_t *regexp,
+ re_dfa_t *dfa, re_token_t *token,
+ reg_syntax_t syntax, reg_errcode_t *err);
+static bin_tree_t *parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa,
+ re_token_t *token, reg_syntax_t syntax,
+ reg_errcode_t *err);
+static reg_errcode_t parse_bracket_element (bracket_elem_t *elem,
+ re_string_t *regexp,
+ re_token_t *token, int token_len,
+ re_dfa_t *dfa,
+ reg_syntax_t syntax,
+ int accept_hyphen);
+static reg_errcode_t parse_bracket_symbol (bracket_elem_t *elem,
+ re_string_t *regexp,
+ re_token_t *token);
+#ifdef RE_ENABLE_I18N
+static reg_errcode_t build_equiv_class (bitset_t sbcset,
+ re_charset_t *mbcset,
+ int *equiv_class_alloc,
+ const unsigned char *name);
+static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans,
+ bitset_t sbcset,
+ re_charset_t *mbcset,
+ int *char_class_alloc,
+ const unsigned char *class_name,
+ reg_syntax_t syntax);
+#else /* not RE_ENABLE_I18N */
+static reg_errcode_t build_equiv_class (bitset_t sbcset,
+ const unsigned char *name);
+static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans,
+ bitset_t sbcset,
+ const unsigned char *class_name,
+ reg_syntax_t syntax);
+#endif /* not RE_ENABLE_I18N */
+static bin_tree_t *build_charclass_op (re_dfa_t *dfa,
+ RE_TRANSLATE_TYPE trans,
+ const unsigned char *class_name,
+ const unsigned char *extra,
+ int non_match, reg_errcode_t *err);
+static bin_tree_t *create_tree (re_dfa_t *dfa,
+ bin_tree_t *left, bin_tree_t *right,
+ re_token_type_t type);
+static bin_tree_t *create_token_tree (re_dfa_t *dfa,
+ bin_tree_t *left, bin_tree_t *right,
+ const re_token_t *token);
+static bin_tree_t *duplicate_tree (const bin_tree_t *src, re_dfa_t *dfa);
+static void free_token (re_token_t *node);
+static reg_errcode_t free_tree (void *extra, bin_tree_t *node);
+static reg_errcode_t mark_opt_subexp (void *extra, bin_tree_t *node);
+
+/* This table gives an error message for each of the error codes listed
+ in regex.h. Obviously the order here has to be same as there.
+ POSIX doesn't require that we do anything for REG_NOERROR,
+ but why not be nice? */
+
+const char __re_error_msgid[] attribute_hidden =
+ {
+#define REG_NOERROR_IDX 0
+ gettext_noop ("Success") /* REG_NOERROR */
+ "\0"
+#define REG_NOMATCH_IDX (REG_NOERROR_IDX + sizeof "Success")
+ gettext_noop ("No match") /* REG_NOMATCH */
+ "\0"
+#define REG_BADPAT_IDX (REG_NOMATCH_IDX + sizeof "No match")
+ gettext_noop ("Invalid regular expression") /* REG_BADPAT */
+ "\0"
+#define REG_ECOLLATE_IDX (REG_BADPAT_IDX + sizeof "Invalid regular expression")
+ gettext_noop ("Invalid collation character") /* REG_ECOLLATE */
+ "\0"
+#define REG_ECTYPE_IDX (REG_ECOLLATE_IDX + sizeof "Invalid collation character")
+ gettext_noop ("Invalid character class name") /* REG_ECTYPE */
+ "\0"
+#define REG_EESCAPE_IDX (REG_ECTYPE_IDX + sizeof "Invalid character class name")
+ gettext_noop ("Trailing backslash") /* REG_EESCAPE */
+ "\0"
+#define REG_ESUBREG_IDX (REG_EESCAPE_IDX + sizeof "Trailing backslash")
+ gettext_noop ("Invalid back reference") /* REG_ESUBREG */
+ "\0"
+#define REG_EBRACK_IDX (REG_ESUBREG_IDX + sizeof "Invalid back reference")
+ gettext_noop ("Unmatched [ or [^") /* REG_EBRACK */
+ "\0"
+#define REG_EPAREN_IDX (REG_EBRACK_IDX + sizeof "Unmatched [ or [^")
+ gettext_noop ("Unmatched ( or \\(") /* REG_EPAREN */
+ "\0"
+#define REG_EBRACE_IDX (REG_EPAREN_IDX + sizeof "Unmatched ( or \\(")
+ gettext_noop ("Unmatched \\{") /* REG_EBRACE */
+ "\0"
+#define REG_BADBR_IDX (REG_EBRACE_IDX + sizeof "Unmatched \\{")
+ gettext_noop ("Invalid content of \\{\\}") /* REG_BADBR */
+ "\0"
+#define REG_ERANGE_IDX (REG_BADBR_IDX + sizeof "Invalid content of \\{\\}")
+ gettext_noop ("Invalid range end") /* REG_ERANGE */
+ "\0"
+#define REG_ESPACE_IDX (REG_ERANGE_IDX + sizeof "Invalid range end")
+ gettext_noop ("Memory exhausted") /* REG_ESPACE */
+ "\0"
+#define REG_BADRPT_IDX (REG_ESPACE_IDX + sizeof "Memory exhausted")
+ gettext_noop ("Invalid preceding regular expression") /* REG_BADRPT */
+ "\0"
+#define REG_EEND_IDX (REG_BADRPT_IDX + sizeof "Invalid preceding regular expression")
+ gettext_noop ("Premature end of regular expression") /* REG_EEND */
+ "\0"
+#define REG_ESIZE_IDX (REG_EEND_IDX + sizeof "Premature end of regular expression")
+ gettext_noop ("Regular expression too big") /* REG_ESIZE */
+ "\0"
+#define REG_ERPAREN_IDX (REG_ESIZE_IDX + sizeof "Regular expression too big")
+ gettext_noop ("Unmatched ) or \\)") /* REG_ERPAREN */
+ };
+
+const size_t __re_error_msgid_idx[] attribute_hidden =
+ {
+ REG_NOERROR_IDX,
+ REG_NOMATCH_IDX,
+ REG_BADPAT_IDX,
+ REG_ECOLLATE_IDX,
+ REG_ECTYPE_IDX,
+ REG_EESCAPE_IDX,
+ REG_ESUBREG_IDX,
+ REG_EBRACK_IDX,
+ REG_EPAREN_IDX,
+ REG_EBRACE_IDX,
+ REG_BADBR_IDX,
+ REG_ERANGE_IDX,
+ REG_ESPACE_IDX,
+ REG_BADRPT_IDX,
+ REG_EEND_IDX,
+ REG_ESIZE_IDX,
+ REG_ERPAREN_IDX
+ };
+
+/* Entry points for GNU code. */
+
+/* re_compile_pattern is the GNU regular expression compiler: it
+ compiles PATTERN (of length LENGTH) and puts the result in BUFP.
+ Returns 0 if the pattern was valid, otherwise an error string.
+
+ Assumes the `allocated' (and perhaps `buffer') and `translate' fields
+ are set in BUFP on entry. */
+
+const char *
+re_compile_pattern (pattern, length, bufp)
+ const char *pattern;
+ size_t length;
+ struct re_pattern_buffer *bufp;
+{
+ reg_errcode_t ret;
+
+ /* And GNU code determines whether or not to get register information
+ by passing null for the REGS argument to re_match, etc., not by
+ setting no_sub, unless RE_NO_SUB is set. */
+ bufp->no_sub = !!(re_syntax_options & RE_NO_SUB);
+
+ /* Match anchors at newline. */
+ bufp->newline_anchor = 1;
+
+ ret = re_compile_internal (bufp, pattern, length, re_syntax_options);
+
+ if (!ret)
+ return NULL;
+ return gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]);
+}
+#ifdef _LIBC
+weak_alias (__re_compile_pattern, re_compile_pattern)
+#endif
+
+/* Set by `re_set_syntax' to the current regexp syntax to recognize. Can
+ also be assigned to arbitrarily: each pattern buffer stores its own
+ syntax, so it can be changed between regex compilations. */
+/* This has no initializer because initialized variables in Emacs
+ become read-only after dumping. */
+reg_syntax_t re_syntax_options;
+
+
+/* Specify the precise syntax of regexps for compilation. This provides
+ for compatibility for various utilities which historically have
+ different, incompatible syntaxes.
+
+ The argument SYNTAX is a bit mask comprised of the various bits
+ defined in regex.h. We return the old syntax. */
+
+reg_syntax_t
+re_set_syntax (syntax)
+ reg_syntax_t syntax;
+{
+ reg_syntax_t ret = re_syntax_options;
+
+ re_syntax_options = syntax;
+ return ret;
+}
+#ifdef _LIBC
+weak_alias (__re_set_syntax, re_set_syntax)
+#endif
+
+int
+re_compile_fastmap (bufp)
+ struct re_pattern_buffer *bufp;
+{
+ re_dfa_t *dfa = (re_dfa_t *) bufp->buffer;
+ char *fastmap = bufp->fastmap;
+
+ memset (fastmap, '\0', sizeof (char) * SBC_MAX);
+ re_compile_fastmap_iter (bufp, dfa->init_state, fastmap);
+ if (dfa->init_state != dfa->init_state_word)
+ re_compile_fastmap_iter (bufp, dfa->init_state_word, fastmap);
+ if (dfa->init_state != dfa->init_state_nl)
+ re_compile_fastmap_iter (bufp, dfa->init_state_nl, fastmap);
+ if (dfa->init_state != dfa->init_state_begbuf)
+ re_compile_fastmap_iter (bufp, dfa->init_state_begbuf, fastmap);
+ bufp->fastmap_accurate = 1;
+ return 0;
+}
+#ifdef _LIBC
+weak_alias (__re_compile_fastmap, re_compile_fastmap)
+#endif
+
+static inline void
+__attribute ((always_inline))
+re_set_fastmap (char *fastmap, int icase, int ch)
+{
+ fastmap[ch] = 1;
+ if (icase)
+ fastmap[tolower (ch)] = 1;
+}
+
+/* Helper function for re_compile_fastmap.
+ Compile fastmap for the initial_state INIT_STATE. */
+
+static void
+re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
+ char *fastmap)
+{
+ re_dfa_t *dfa = (re_dfa_t *) bufp->buffer;
+ int node_cnt;
+ int icase = (dfa->mb_cur_max == 1 && (bufp->syntax & RE_ICASE));
+ for (node_cnt = 0; node_cnt < init_state->nodes.nelem; ++node_cnt)
+ {
+ int node = init_state->nodes.elems[node_cnt];
+ re_token_type_t type = dfa->nodes[node].type;
+
+ if (type == CHARACTER)
+ {
+ re_set_fastmap (fastmap, icase, dfa->nodes[node].opr.c);
+#ifdef RE_ENABLE_I18N
+ if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1)
+ {
+ unsigned char *buf = alloca (dfa->mb_cur_max), *p;
+ wchar_t wc;
+ mbstate_t state;
+
+ p = buf;
+ *p++ = dfa->nodes[node].opr.c;
+ while (++node < dfa->nodes_len
+ && dfa->nodes[node].type == CHARACTER
+ && dfa->nodes[node].mb_partial)
+ *p++ = dfa->nodes[node].opr.c;
+ memset (&state, '\0', sizeof (state));
+ if (mbrtowc (&wc, (const char *) buf, p - buf,
+ &state) == p - buf
+ && (__wcrtomb ((char *) buf, towlower (wc), &state)
+ != (size_t) -1))
+ re_set_fastmap (fastmap, 0, buf[0]);
+ }
+#endif
+ }
+ else if (type == SIMPLE_BRACKET)
+ {
+ int i, ch;
+ for (i = 0, ch = 0; i < BITSET_WORDS; ++i)
+ {
+ int j;
+ bitset_word_t w = dfa->nodes[node].opr.sbcset[i];
+ for (j = 0; j < BITSET_WORD_BITS; ++j, ++ch)
+ if (w & ((bitset_word_t) 1 << j))
+ re_set_fastmap (fastmap, icase, ch);
+ }
+ }
+#ifdef RE_ENABLE_I18N
+ else if (type == COMPLEX_BRACKET)
+ {
+ int i;
+ re_charset_t *cset = dfa->nodes[node].opr.mbcset;
+ if (cset->non_match || cset->ncoll_syms || cset->nequiv_classes
+ || cset->nranges || cset->nchar_classes)
+ {
+# ifdef _LIBC
+ if (_NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES) != 0)
+ {
+ /* In this case we want to catch the bytes which are
+ the first byte of any collation elements.
+ e.g. In da_DK, we want to catch 'a' since "aa"
+ is a valid collation element, and don't catch
+ 'b' since 'b' is the only collation element
+ which starts from 'b'. */
+ const int32_t *table = (const int32_t *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
+ for (i = 0; i < SBC_MAX; ++i)
+ if (table[i] < 0)
+ re_set_fastmap (fastmap, icase, i);
+ }
+# else
+ if (dfa->mb_cur_max > 1)
+ for (i = 0; i < SBC_MAX; ++i)
+ if (__btowc (i) == WEOF)
+ re_set_fastmap (fastmap, icase, i);
+# endif /* not _LIBC */
+ }
+ for (i = 0; i < cset->nmbchars; ++i)
+ {
+ char buf[256];
+ mbstate_t state;
+ memset (&state, '\0', sizeof (state));
+ if (__wcrtomb (buf, cset->mbchars[i], &state) != (size_t) -1)
+ re_set_fastmap (fastmap, icase, *(unsigned char *) buf);
+ if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1)
+ {
+ if (__wcrtomb (buf, towlower (cset->mbchars[i]), &state)
+ != (size_t) -1)
+ re_set_fastmap (fastmap, 0, *(unsigned char *) buf);
+ }
+ }
+ }
+#endif /* RE_ENABLE_I18N */
+ else if (type == OP_PERIOD
+#ifdef RE_ENABLE_I18N
+ || type == OP_UTF8_PERIOD
+#endif /* RE_ENABLE_I18N */
+ || type == END_OF_RE)
+ {
+ memset (fastmap, '\1', sizeof (char) * SBC_MAX);
+ if (type == END_OF_RE)
+ bufp->can_be_null = 1;
+ return;
+ }
+ }
+}
+
+/* Entry point for POSIX code. */
+/* regcomp takes a regular expression as a string and compiles it.
+
+ PREG is a regex_t *. We do not expect any fields to be initialized,
+ since POSIX says we shouldn't. Thus, we set
+
+ `buffer' to the compiled pattern;
+ `used' to the length of the compiled pattern;
+ `syntax' to RE_SYNTAX_POSIX_EXTENDED if the
+ REG_EXTENDED bit in CFLAGS is set; otherwise, to
+ RE_SYNTAX_POSIX_BASIC;
+ `newline_anchor' to REG_NEWLINE being set in CFLAGS;
+ `fastmap' to an allocated space for the fastmap;
+ `fastmap_accurate' to zero;
+ `re_nsub' to the number of subexpressions in PATTERN.
+
+ PATTERN is the address of the pattern string.
+
+ CFLAGS is a series of bits which affect compilation.
+
+ If REG_EXTENDED is set, we use POSIX extended syntax; otherwise, we
+ use POSIX basic syntax.
+
+ If REG_NEWLINE is set, then . and [^...] don't match newline.
+ Also, regexec will try a match beginning after every newline.
+
+ If REG_ICASE is set, then we considers upper- and lowercase
+ versions of letters to be equivalent when matching.
+
+ If REG_NOSUB is set, then when PREG is passed to regexec, that
+ routine will report only success or failure, and nothing about the
+ registers.
+
+ It returns 0 if it succeeds, nonzero if it doesn't. (See regex.h for
+ the return codes and their meanings.) */
+
+int
+regcomp (preg, pattern, cflags)
+ regex_t *__restrict preg;
+ const char *__restrict pattern;
+ int cflags;
+{
+ reg_errcode_t ret;
+ reg_syntax_t syntax = ((cflags & REG_EXTENDED) ? RE_SYNTAX_POSIX_EXTENDED
+ : RE_SYNTAX_POSIX_BASIC);
+
+ preg->buffer = NULL;
+ preg->allocated = 0;
+ preg->used = 0;
+
+ /* Try to allocate space for the fastmap. */
+ preg->fastmap = re_malloc (char, SBC_MAX);
+ if (BE (preg->fastmap == NULL, 0))
+ return REG_ESPACE;
+
+ syntax |= (cflags & REG_ICASE) ? RE_ICASE : 0;
+
+ /* If REG_NEWLINE is set, newlines are treated differently. */
+ if (cflags & REG_NEWLINE)
+ { /* REG_NEWLINE implies neither . nor [^...] match newline. */
+ syntax &= ~RE_DOT_NEWLINE;
+ syntax |= RE_HAT_LISTS_NOT_NEWLINE;
+ /* It also changes the matching behavior. */
+ preg->newline_anchor = 1;
+ }
+ else
+ preg->newline_anchor = 0;
+ preg->no_sub = !!(cflags & REG_NOSUB);
+ preg->translate = NULL;
+
+ ret = re_compile_internal (preg, pattern, strlen (pattern), syntax);
+
+ /* POSIX doesn't distinguish between an unmatched open-group and an
+ unmatched close-group: both are REG_EPAREN. */
+ if (ret == REG_ERPAREN)
+ ret = REG_EPAREN;
+
+ /* We have already checked preg->fastmap != NULL. */
+ if (BE (ret == REG_NOERROR, 1))
+ /* Compute the fastmap now, since regexec cannot modify the pattern
+ buffer. This function never fails in this implementation. */
+ (void) re_compile_fastmap (preg);
+ else
+ {
+ /* Some error occurred while compiling the expression. */
+ re_free (preg->fastmap);
+ preg->fastmap = NULL;
+ }
+
+ return (int) ret;
+}
+#ifdef _LIBC
+weak_alias (__regcomp, regcomp)
+#endif
+
+/* Returns a message corresponding to an error code, ERRCODE, returned
+ from either regcomp or regexec. We don't use PREG here. */
+
+size_t
+regerror (errcode, preg, errbuf, errbuf_size)
+ int errcode;
+ const regex_t *__restrict preg;
+ char *__restrict errbuf;
+ size_t errbuf_size;
+{
+ const char *msg;
+ size_t msg_size;
+
+ if (BE (errcode < 0
+ || errcode >= (int) (sizeof (__re_error_msgid_idx)
+ / sizeof (__re_error_msgid_idx[0])), 0))
+ /* Only error codes returned by the rest of the code should be passed
+ to this routine. If we are given anything else, or if other regex
+ code generates an invalid error code, then the program has a bug.
+ Dump core so we can fix it. */
+ abort ();
+
+ msg = gettext (__re_error_msgid + __re_error_msgid_idx[errcode]);
+
+ msg_size = strlen (msg) + 1; /* Includes the null. */
+
+ if (BE (errbuf_size != 0, 1))
+ {
+ if (BE (msg_size > errbuf_size, 0))
+ {
+#if defined HAVE_MEMPCPY || defined _LIBC
+ *((char *) __mempcpy (errbuf, msg, errbuf_size - 1)) = '\0';
+#else
+ memcpy (errbuf, msg, errbuf_size - 1);
+ errbuf[errbuf_size - 1] = 0;
+#endif
+ }
+ else
+ memcpy (errbuf, msg, msg_size);
+ }
+
+ return msg_size;
+}
+#ifdef _LIBC
+weak_alias (__regerror, regerror)
+#endif
+
+
+#ifdef RE_ENABLE_I18N
+/* This static array is used for the map to single-byte characters when
+ UTF-8 is used. Otherwise we would allocate memory just to initialize
+ it the same all the time. UTF-8 is the preferred encoding so this is
+ a worthwhile optimization. */
+static const bitset_t utf8_sb_map =
+{
+ /* Set the first 128 bits. */
+ [0 ... 0x80 / BITSET_WORD_BITS - 1] = BITSET_WORD_MAX
+};
+#endif
+
+
+static void
+free_dfa_content (re_dfa_t *dfa)
+{
+ int i, j;
+
+ if (dfa->nodes)
+ for (i = 0; i < dfa->nodes_len; ++i)
+ free_token (dfa->nodes + i);
+ re_free (dfa->nexts);
+ for (i = 0; i < dfa->nodes_len; ++i)
+ {
+ if (dfa->eclosures != NULL)
+ re_node_set_free (dfa->eclosures + i);
+ if (dfa->inveclosures != NULL)
+ re_node_set_free (dfa->inveclosures + i);
+ if (dfa->edests != NULL)
+ re_node_set_free (dfa->edests + i);
+ }
+ re_free (dfa->edests);
+ re_free (dfa->eclosures);
+ re_free (dfa->inveclosures);
+ re_free (dfa->nodes);
+
+ if (dfa->state_table)
+ for (i = 0; i <= dfa->state_hash_mask; ++i)
+ {
+ struct re_state_table_entry *entry = dfa->state_table + i;
+ for (j = 0; j < entry->num; ++j)
+ {
+ re_dfastate_t *state = entry->array[j];
+ free_state (state);
+ }
+ re_free (entry->array);
+ }
+ re_free (dfa->state_table);
+#ifdef RE_ENABLE_I18N
+ if (dfa->sb_char != utf8_sb_map)
+ re_free (dfa->sb_char);
+#endif
+ re_free (dfa->subexp_map);
+#ifdef DEBUG
+ re_free (dfa->re_str);
+#endif
+
+ re_free (dfa);
+}
+
+
+/* Free dynamically allocated space used by PREG. */
+
+void
+regfree (preg)
+ regex_t *preg;
+{
+ re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+ if (BE (dfa != NULL, 1))
+ free_dfa_content (dfa);
+ preg->buffer = NULL;
+ preg->allocated = 0;
+
+ re_free (preg->fastmap);
+ preg->fastmap = NULL;
+
+ re_free (preg->translate);
+ preg->translate = NULL;
+}
+#ifdef _LIBC
+weak_alias (__regfree, regfree)
+#endif
+
+/* Entry points compatible with 4.2 BSD regex library. We don't define
+ them unless specifically requested. */
+
+#if defined _REGEX_RE_COMP || defined _LIBC
+
+/* BSD has one and only one pattern buffer. */
+static struct re_pattern_buffer re_comp_buf;
+
+char *
+# ifdef _LIBC
+/* Make these definitions weak in libc, so POSIX programs can redefine
+ these names if they don't use our functions, and still use
+ regcomp/regexec above without link errors. */
+weak_function
+# endif
+re_comp (s)
+ const char *s;
+{
+ reg_errcode_t ret;
+ char *fastmap;
+
+ if (!s)
+ {
+ if (!re_comp_buf.buffer)
+ return gettext ("No previous regular expression");
+ return 0;
+ }
+
+ if (re_comp_buf.buffer)
+ {
+ fastmap = re_comp_buf.fastmap;
+ re_comp_buf.fastmap = NULL;
+ __regfree (&re_comp_buf);
+ memset (&re_comp_buf, '\0', sizeof (re_comp_buf));
+ re_comp_buf.fastmap = fastmap;
+ }
+
+ if (re_comp_buf.fastmap == NULL)
+ {
+ re_comp_buf.fastmap = (char *) malloc (SBC_MAX);
+ if (re_comp_buf.fastmap == NULL)
+ return (char *) gettext (__re_error_msgid
+ + __re_error_msgid_idx[(int) REG_ESPACE]);
+ }
+
+ /* Since `re_exec' always passes NULL for the `regs' argument, we
+ don't need to initialize the pattern buffer fields which affect it. */
+
+ /* Match anchors at newlines. */
+ re_comp_buf.newline_anchor = 1;
+
+ ret = re_compile_internal (&re_comp_buf, s, strlen (s), re_syntax_options);
+
+ if (!ret)
+ return NULL;
+
+ /* Yes, we're discarding `const' here if !HAVE_LIBINTL. */
+ return (char *) gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]);
+}
+
+#ifdef _LIBC
+libc_freeres_fn (free_mem)
+{
+ __regfree (&re_comp_buf);
+}
+#endif
+
+#endif /* _REGEX_RE_COMP */
+
+/* Internal entry point.
+ Compile the regular expression PATTERN, whose length is LENGTH.
+ SYNTAX indicate regular expression's syntax. */
+
+static reg_errcode_t
+re_compile_internal (regex_t *preg, const char * pattern, size_t length,
+ reg_syntax_t syntax)
+{
+ reg_errcode_t err = REG_NOERROR;
+ re_dfa_t *dfa;
+ re_string_t regexp;
+
+ /* Initialize the pattern buffer. */
+ preg->fastmap_accurate = 0;
+ preg->syntax = syntax;
+ preg->not_bol = preg->not_eol = 0;
+ preg->used = 0;
+ preg->re_nsub = 0;
+ preg->can_be_null = 0;
+ preg->regs_allocated = REGS_UNALLOCATED;
+
+ /* Initialize the dfa. */
+ dfa = (re_dfa_t *) preg->buffer;
+ if (BE (preg->allocated < sizeof (re_dfa_t), 0))
+ {
+ /* If zero allocated, but buffer is non-null, try to realloc
+ enough space. This loses if buffer's address is bogus, but
+ that is the user's responsibility. If ->buffer is NULL this
+ is a simple allocation. */
+ dfa = re_realloc (preg->buffer, re_dfa_t, 1);
+ if (dfa == NULL)
+ return REG_ESPACE;
+ preg->allocated = sizeof (re_dfa_t);
+ preg->buffer = (unsigned char *) dfa;
+ }
+ preg->used = sizeof (re_dfa_t);
+
+ err = init_dfa (dfa, length);
+ if (BE (err != REG_NOERROR, 0))
+ {
+ free_dfa_content (dfa);
+ preg->buffer = NULL;
+ preg->allocated = 0;
+ return err;
+ }
+#ifdef DEBUG
+ /* Note: length+1 will not overflow since it is checked in init_dfa. */
+ dfa->re_str = re_malloc (char, length + 1);
+ strncpy (dfa->re_str, pattern, length + 1);
+#endif
+
+ __libc_lock_init (dfa->lock);
+
+ err = re_string_construct (&regexp, pattern, length, preg->translate,
+ syntax & RE_ICASE, dfa);
+ if (BE (err != REG_NOERROR, 0))
+ {
+ re_compile_internal_free_return:
+ free_workarea_compile (preg);
+ re_string_destruct (&regexp);
+ free_dfa_content (dfa);
+ preg->buffer = NULL;
+ preg->allocated = 0;
+ return err;
+ }
+
+ /* Parse the regular expression, and build a structure tree. */
+ preg->re_nsub = 0;
+ dfa->str_tree = parse (&regexp, preg, syntax, &err);
+ if (BE (dfa->str_tree == NULL, 0))
+ goto re_compile_internal_free_return;
+
+ /* Analyze the tree and create the nfa. */
+ err = analyze (preg);
+ if (BE (err != REG_NOERROR, 0))
+ goto re_compile_internal_free_return;
+
+#ifdef RE_ENABLE_I18N
+ /* If possible, do searching in single byte encoding to speed things up. */
+ if (dfa->is_utf8 && !(syntax & RE_ICASE) && preg->translate == NULL)
+ optimize_utf8 (dfa);
+#endif
+
+ /* Then create the initial state of the dfa. */
+ err = create_initial_state (dfa);
+
+ /* Release work areas. */
+ free_workarea_compile (preg);
+ re_string_destruct (&regexp);
+
+ if (BE (err != REG_NOERROR, 0))
+ {
+ free_dfa_content (dfa);
+ preg->buffer = NULL;
+ preg->allocated = 0;
+ }
+
+ return err;
+}
+
+/* Initialize DFA. We use the length of the regular expression PAT_LEN
+ as the initial length of some arrays. */
+
+static reg_errcode_t
+init_dfa (re_dfa_t *dfa, size_t pat_len)
+{
+ unsigned int table_size;
+#ifndef _LIBC
+ char *codeset_name;
+#endif
+
+ memset (dfa, '\0', sizeof (re_dfa_t));
+
+ /* Force allocation of str_tree_storage the first time. */
+ dfa->str_tree_storage_idx = BIN_TREE_STORAGE_SIZE;
+
+ /* Avoid overflows. */
+ if (pat_len == SIZE_MAX)
+ return REG_ESPACE;
+
+ dfa->nodes_alloc = pat_len + 1;
+ dfa->nodes = re_malloc (re_token_t, dfa->nodes_alloc);
+
+ /* table_size = 2 ^ ceil(log pat_len) */
+ for (table_size = 1; ; table_size <<= 1)
+ if (table_size > pat_len)
+ break;
+
+ dfa->state_table = calloc (sizeof (struct re_state_table_entry), table_size);
+ dfa->state_hash_mask = table_size - 1;
+
+ dfa->mb_cur_max = MB_CUR_MAX;
+#ifdef _LIBC
+ if (dfa->mb_cur_max == 6
+ && strcmp (_NL_CURRENT (LC_CTYPE, _NL_CTYPE_CODESET_NAME), "UTF-8") == 0)
+ dfa->is_utf8 = 1;
+ dfa->map_notascii = (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MAP_TO_NONASCII)
+ != 0);
+#else
+# ifdef HAVE_LANGINFO_CODESET
+ codeset_name = nl_langinfo (CODESET);
+# else
+ codeset_name = getenv ("LC_ALL");
+ if (codeset_name == NULL || codeset_name[0] == '\0')
+ codeset_name = getenv ("LC_CTYPE");
+ if (codeset_name == NULL || codeset_name[0] == '\0')
+ codeset_name = getenv ("LANG");
+ if (codeset_name == NULL)
+ codeset_name = "";
+ else if (strchr (codeset_name, '.') != NULL)
+ codeset_name = strchr (codeset_name, '.') + 1;
+# endif
+
+ if (strcasecmp (codeset_name, "UTF-8") == 0
+ || strcasecmp (codeset_name, "UTF8") == 0)
+ dfa->is_utf8 = 1;
+
+ /* We check exhaustively in the loop below if this charset is a
+ superset of ASCII. */
+ dfa->map_notascii = 0;
+#endif
+
+#ifdef RE_ENABLE_I18N
+ if (dfa->mb_cur_max > 1)
+ {
+ if (dfa->is_utf8)
+ dfa->sb_char = (re_bitset_ptr_t) utf8_sb_map;
+ else
+ {
+ int i, j, ch;
+
+ dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
+ if (BE (dfa->sb_char == NULL, 0))
+ return REG_ESPACE;
+
+ /* Set the bits corresponding to single byte chars. */
+ for (i = 0, ch = 0; i < BITSET_WORDS; ++i)
+ for (j = 0; j < BITSET_WORD_BITS; ++j, ++ch)
+ {
+ wint_t wch = __btowc (ch);
+ if (wch != WEOF)
+ dfa->sb_char[i] |= (bitset_word_t) 1 << j;
+# ifndef _LIBC
+ if (isascii (ch) && wch != ch)
+ dfa->map_notascii = 1;
+# endif
+ }
+ }
+ }
+#endif
+
+ if (BE (dfa->nodes == NULL || dfa->state_table == NULL, 0))
+ return REG_ESPACE;
+ return REG_NOERROR;
+}
+
+/* Initialize WORD_CHAR table, which indicate which character is
+ "word". In this case "word" means that it is the word construction
+ character used by some operators like "\<", "\>", etc. */
+
+static void
+internal_function
+init_word_char (re_dfa_t *dfa)
+{
+ int i, j, ch;
+ dfa->word_ops_used = 1;
+ for (i = 0, ch = 0; i < BITSET_WORDS; ++i)
+ for (j = 0; j < BITSET_WORD_BITS; ++j, ++ch)
+ if (isalnum (ch) || ch == '_')
+ dfa->word_char[i] |= (bitset_word_t) 1 << j;
+}
+
+/* Free the work area which are only used while compiling. */
+
+static void
+free_workarea_compile (regex_t *preg)
+{
+ re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+ bin_tree_storage_t *storage, *next;
+ for (storage = dfa->str_tree_storage; storage; storage = next)
+ {
+ next = storage->next;
+ re_free (storage);
+ }
+ dfa->str_tree_storage = NULL;
+ dfa->str_tree_storage_idx = BIN_TREE_STORAGE_SIZE;
+ dfa->str_tree = NULL;
+ re_free (dfa->org_indices);
+ dfa->org_indices = NULL;
+}
+
+/* Create initial states for all contexts. */
+
+static reg_errcode_t
+create_initial_state (re_dfa_t *dfa)
+{
+ int first, i;
+ reg_errcode_t err;
+ re_node_set init_nodes;
+
+ /* Initial states have the epsilon closure of the node which is
+ the first node of the regular expression. */
+ first = dfa->str_tree->first->node_idx;
+ dfa->init_node = first;
+ err = re_node_set_init_copy (&init_nodes, dfa->eclosures + first);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+
+ /* The back-references which are in initial states can epsilon transit,
+ since in this case all of the subexpressions can be null.
+ Then we add epsilon closures of the nodes which are the next nodes of
+ the back-references. */
+ if (dfa->nbackref > 0)
+ for (i = 0; i < init_nodes.nelem; ++i)
+ {
+ int node_idx = init_nodes.elems[i];
+ re_token_type_t type = dfa->nodes[node_idx].type;
+
+ int clexp_idx;
+ if (type != OP_BACK_REF)
+ continue;
+ for (clexp_idx = 0; clexp_idx < init_nodes.nelem; ++clexp_idx)
+ {
+ re_token_t *clexp_node;
+ clexp_node = dfa->nodes + init_nodes.elems[clexp_idx];
+ if (clexp_node->type == OP_CLOSE_SUBEXP
+ && clexp_node->opr.idx == dfa->nodes[node_idx].opr.idx)
+ break;
+ }
+ if (clexp_idx == init_nodes.nelem)
+ continue;
+
+ if (type == OP_BACK_REF)
+ {
+ int dest_idx = dfa->edests[node_idx].elems[0];
+ if (!re_node_set_contains (&init_nodes, dest_idx))
+ {
+ re_node_set_merge (&init_nodes, dfa->eclosures + dest_idx);
+ i = 0;
+ }
+ }
+ }
+
+ /* It must be the first time to invoke acquire_state. */
+ dfa->init_state = re_acquire_state_context (&err, dfa, &init_nodes, 0);
+ /* We don't check ERR here, since the initial state must not be NULL. */
+ if (BE (dfa->init_state == NULL, 0))
+ return err;
+ if (dfa->init_state->has_constraint)
+ {
+ dfa->init_state_word = re_acquire_state_context (&err, dfa, &init_nodes,
+ CONTEXT_WORD);
+ dfa->init_state_nl = re_acquire_state_context (&err, dfa, &init_nodes,
+ CONTEXT_NEWLINE);
+ dfa->init_state_begbuf = re_acquire_state_context (&err, dfa,
+ &init_nodes,
+ CONTEXT_NEWLINE
+ | CONTEXT_BEGBUF);
+ if (BE (dfa->init_state_word == NULL || dfa->init_state_nl == NULL
+ || dfa->init_state_begbuf == NULL, 0))
+ return err;
+ }
+ else
+ dfa->init_state_word = dfa->init_state_nl
+ = dfa->init_state_begbuf = dfa->init_state;
+
+ re_node_set_free (&init_nodes);
+ return REG_NOERROR;
+}
+
+#ifdef RE_ENABLE_I18N
+/* If it is possible to do searching in single byte encoding instead of UTF-8
+ to speed things up, set dfa->mb_cur_max to 1, clear is_utf8 and change
+ DFA nodes where needed. */
+
+static void
+optimize_utf8 (re_dfa_t *dfa)
+{
+ int node, i, mb_chars = 0, has_period = 0;
+
+ for (node = 0; node < dfa->nodes_len; ++node)
+ switch (dfa->nodes[node].type)
+ {
+ case CHARACTER:
+ if (dfa->nodes[node].opr.c >= 0x80)
+ mb_chars = 1;
+ break;
+ case ANCHOR:
+ switch (dfa->nodes[node].opr.idx)
+ {
+ case LINE_FIRST:
+ case LINE_LAST:
+ case BUF_FIRST:
+ case BUF_LAST:
+ break;
+ default:
+ /* Word anchors etc. cannot be handled. */
+ return;
+ }
+ break;
+ case OP_PERIOD:
+ has_period = 1;
+ break;
+ case OP_BACK_REF:
+ case OP_ALT:
+ case END_OF_RE:
+ case OP_DUP_ASTERISK:
+ case OP_OPEN_SUBEXP:
+ case OP_CLOSE_SUBEXP:
+ break;
+ case COMPLEX_BRACKET:
+ return;
+ case SIMPLE_BRACKET:
+ /* Just double check. The non-ASCII range starts at 0x80. */
+ assert (0x80 % BITSET_WORD_BITS == 0);
+ for (i = 0x80 / BITSET_WORD_BITS; i < BITSET_WORDS; ++i)
+ if (dfa->nodes[node].opr.sbcset[i])
+ return;
+ break;
+ default:
+ abort ();
+ }
+
+ if (mb_chars || has_period)
+ for (node = 0; node < dfa->nodes_len; ++node)
+ {
+ if (dfa->nodes[node].type == CHARACTER
+ && dfa->nodes[node].opr.c >= 0x80)
+ dfa->nodes[node].mb_partial = 0;
+ else if (dfa->nodes[node].type == OP_PERIOD)
+ dfa->nodes[node].type = OP_UTF8_PERIOD;
+ }
+
+ /* The search can be in single byte locale. */
+ dfa->mb_cur_max = 1;
+ dfa->is_utf8 = 0;
+ dfa->has_mb_node = dfa->nbackref > 0 || has_period;
+}
+#endif
+
+/* Analyze the structure tree, and calculate "first", "next", "edest",
+ "eclosure", and "inveclosure". */
+
+static reg_errcode_t
+analyze (regex_t *preg)
+{
+ re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+ reg_errcode_t ret;
+
+ /* Allocate arrays. */
+ dfa->nexts = re_malloc (int, dfa->nodes_alloc);
+ dfa->org_indices = re_malloc (int, dfa->nodes_alloc);
+ dfa->edests = re_malloc (re_node_set, dfa->nodes_alloc);
+ dfa->eclosures = re_malloc (re_node_set, dfa->nodes_alloc);
+ if (BE (dfa->nexts == NULL || dfa->org_indices == NULL || dfa->edests == NULL
+ || dfa->eclosures == NULL, 0))
+ return REG_ESPACE;
+
+ dfa->subexp_map = re_malloc (int, preg->re_nsub);
+ if (dfa->subexp_map != NULL)
+ {
+ int i;
+ for (i = 0; i < preg->re_nsub; i++)
+ dfa->subexp_map[i] = i;
+ preorder (dfa->str_tree, optimize_subexps, dfa);
+ for (i = 0; i < preg->re_nsub; i++)
+ if (dfa->subexp_map[i] != i)
+ break;
+ if (i == preg->re_nsub)
+ {
+ free (dfa->subexp_map);
+ dfa->subexp_map = NULL;
+ }
+ }
+
+ ret = postorder (dfa->str_tree, lower_subexps, preg);
+ if (BE (ret != REG_NOERROR, 0))
+ return ret;
+ ret = postorder (dfa->str_tree, calc_first, dfa);
+ if (BE (ret != REG_NOERROR, 0))
+ return ret;
+ preorder (dfa->str_tree, calc_next, dfa);
+ ret = preorder (dfa->str_tree, link_nfa_nodes, dfa);
+ if (BE (ret != REG_NOERROR, 0))
+ return ret;
+ ret = calc_eclosure (dfa);
+ if (BE (ret != REG_NOERROR, 0))
+ return ret;
+
+ /* We only need this during the prune_impossible_nodes pass in regexec.c;
+ skip it if p_i_n will not run, as calc_inveclosure can be quadratic. */
+ if ((!preg->no_sub && preg->re_nsub > 0 && dfa->has_plural_match)
+ || dfa->nbackref)
+ {
+ dfa->inveclosures = re_malloc (re_node_set, dfa->nodes_len);
+ if (BE (dfa->inveclosures == NULL, 0))
+ return REG_ESPACE;
+ ret = calc_inveclosure (dfa);
+ }
+
+ return ret;
+}
+
+/* Our parse trees are very unbalanced, so we cannot use a stack to
+ implement parse tree visits. Instead, we use parent pointers and
+ some hairy code in these two functions. */
+static reg_errcode_t
+postorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)),
+ void *extra)
+{
+ bin_tree_t *node, *prev;
+
+ for (node = root; ; )
+ {
+ /* Descend down the tree, preferably to the left (or to the right
+ if that's the only child). */
+ while (node->left || node->right)
+ if (node->left)
+ node = node->left;
+ else
+ node = node->right;
+
+ do
+ {
+ reg_errcode_t err = fn (extra, node);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+ if (node->parent == NULL)
+ return REG_NOERROR;
+ prev = node;
+ node = node->parent;
+ }
+ /* Go up while we have a node that is reached from the right. */
+ while (node->right == prev || node->right == NULL);
+ node = node->right;
+ }
+}
+
+static reg_errcode_t
+preorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)),
+ void *extra)
+{
+ bin_tree_t *node;
+
+ for (node = root; ; )
+ {
+ reg_errcode_t err = fn (extra, node);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+
+ /* Go to the left node, or up and to the right. */
+ if (node->left)
+ node = node->left;
+ else
+ {
+ bin_tree_t *prev = NULL;
+ while (node->right == prev || node->right == NULL)
+ {
+ prev = node;
+ node = node->parent;
+ if (!node)
+ return REG_NOERROR;
+ }
+ node = node->right;
+ }
+ }
+}
+
+/* Optimization pass: if a SUBEXP is entirely contained, strip it and tell
+ re_search_internal to map the inner one's opr.idx to this one's. Adjust
+ backreferences as well. Requires a preorder visit. */
+static reg_errcode_t
+optimize_subexps (void *extra, bin_tree_t *node)
+{
+ re_dfa_t *dfa = (re_dfa_t *) extra;
+
+ if (node->token.type == OP_BACK_REF && dfa->subexp_map)
+ {
+ int idx = node->token.opr.idx;
+ node->token.opr.idx = dfa->subexp_map[idx];
+ dfa->used_bkref_map |= 1 << node->token.opr.idx;
+ }
+
+ else if (node->token.type == SUBEXP
+ && node->left && node->left->token.type == SUBEXP)
+ {
+ int other_idx = node->left->token.opr.idx;
+
+ node->left = node->left->left;
+ if (node->left)
+ node->left->parent = node;
+
+ dfa->subexp_map[other_idx] = dfa->subexp_map[node->token.opr.idx];
+ if (other_idx < BITSET_WORD_BITS)
+ dfa->used_bkref_map &= ~((bitset_word_t) 1 << other_idx);
+ }
+
+ return REG_NOERROR;
+}
+
+/* Lowering pass: Turn each SUBEXP node into the appropriate concatenation
+ of OP_OPEN_SUBEXP, the body of the SUBEXP (if any) and OP_CLOSE_SUBEXP. */
+static reg_errcode_t
+lower_subexps (void *extra, bin_tree_t *node)
+{
+ regex_t *preg = (regex_t *) extra;
+ reg_errcode_t err = REG_NOERROR;
+
+ if (node->left && node->left->token.type == SUBEXP)
+ {
+ node->left = lower_subexp (&err, preg, node->left);
+ if (node->left)
+ node->left->parent = node;
+ }
+ if (node->right && node->right->token.type == SUBEXP)
+ {
+ node->right = lower_subexp (&err, preg, node->right);
+ if (node->right)
+ node->right->parent = node;
+ }
+
+ return err;
+}
+
+static bin_tree_t *
+lower_subexp (reg_errcode_t *err, regex_t *preg, bin_tree_t *node)
+{
+ re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+ bin_tree_t *body = node->left;
+ bin_tree_t *op, *cls, *tree1, *tree;
+
+ if (preg->no_sub
+ /* We do not optimize empty subexpressions, because otherwise we may
+ have bad CONCAT nodes with NULL children. This is obviously not
+ very common, so we do not lose much. An example that triggers
+ this case is the sed "script" /\(\)/x. */
+ && node->left != NULL
+ && (node->token.opr.idx >= BITSET_WORD_BITS
+ || !(dfa->used_bkref_map
+ & ((bitset_word_t) 1 << node->token.opr.idx))))
+ return node->left;
+
+ /* Convert the SUBEXP node to the concatenation of an
+ OP_OPEN_SUBEXP, the contents, and an OP_CLOSE_SUBEXP. */
+ op = create_tree (dfa, NULL, NULL, OP_OPEN_SUBEXP);
+ cls = create_tree (dfa, NULL, NULL, OP_CLOSE_SUBEXP);
+ tree1 = body ? create_tree (dfa, body, cls, CONCAT) : cls;
+ tree = create_tree (dfa, op, tree1, CONCAT);
+ if (BE (tree == NULL || tree1 == NULL || op == NULL || cls == NULL, 0))
+ {
+ *err = REG_ESPACE;
+ return NULL;
+ }
+
+ op->token.opr.idx = cls->token.opr.idx = node->token.opr.idx;
+ op->token.opt_subexp = cls->token.opt_subexp = node->token.opt_subexp;
+ return tree;
+}
+
+/* Pass 1 in building the NFA: compute FIRST and create unlinked automaton
+ nodes. Requires a postorder visit. */
+static reg_errcode_t
+calc_first (void *extra, bin_tree_t *node)
+{
+ re_dfa_t *dfa = (re_dfa_t *) extra;
+ if (node->token.type == CONCAT)
+ {
+ node->first = node->left->first;
+ node->node_idx = node->left->node_idx;
+ }
+ else
+ {
+ node->first = node;
+ node->node_idx = re_dfa_add_node (dfa, node->token);
+ if (BE (node->node_idx == -1, 0))
+ return REG_ESPACE;
+ }
+ return REG_NOERROR;
+}
+
+/* Pass 2: compute NEXT on the tree. Preorder visit. */
+static reg_errcode_t
+calc_next (void *extra, bin_tree_t *node)
+{
+ switch (node->token.type)
+ {
+ case OP_DUP_ASTERISK:
+ node->left->next = node;
+ break;
+ case CONCAT:
+ node->left->next = node->right->first;
+ node->right->next = node->next;
+ break;
+ default:
+ if (node->left)
+ node->left->next = node->next;
+ if (node->right)
+ node->right->next = node->next;
+ break;
+ }
+ return REG_NOERROR;
+}
+
+/* Pass 3: link all DFA nodes to their NEXT node (any order will do). */
+static reg_errcode_t
+link_nfa_nodes (void *extra, bin_tree_t *node)
+{
+ re_dfa_t *dfa = (re_dfa_t *) extra;
+ int idx = node->node_idx;
+ reg_errcode_t err = REG_NOERROR;
+
+ switch (node->token.type)
+ {
+ case CONCAT:
+ break;
+
+ case END_OF_RE:
+ assert (node->next == NULL);
+ break;
+
+ case OP_DUP_ASTERISK:
+ case OP_ALT:
+ {
+ int left, right;
+ dfa->has_plural_match = 1;
+ if (node->left != NULL)
+ left = node->left->first->node_idx;
+ else
+ left = node->next->node_idx;
+ if (node->right != NULL)
+ right = node->right->first->node_idx;
+ else
+ right = node->next->node_idx;
+ assert (left > -1);
+ assert (right > -1);
+ err = re_node_set_init_2 (dfa->edests + idx, left, right);
+ }
+ break;
+
+ case ANCHOR:
+ case OP_OPEN_SUBEXP:
+ case OP_CLOSE_SUBEXP:
+ err = re_node_set_init_1 (dfa->edests + idx, node->next->node_idx);
+ break;
+
+ case OP_BACK_REF:
+ dfa->nexts[idx] = node->next->node_idx;
+ if (node->token.type == OP_BACK_REF)
+ re_node_set_init_1 (dfa->edests + idx, dfa->nexts[idx]);
+ break;
+
+ default:
+ assert (!IS_EPSILON_NODE (node->token.type));
+ dfa->nexts[idx] = node->next->node_idx;
+ break;
+ }
+
+ return err;
+}
+
+/* Duplicate the epsilon closure of the node ROOT_NODE.
+ Note that duplicated nodes have constraint INIT_CONSTRAINT in addition
+ to their own constraint. */
+
+static reg_errcode_t
+internal_function
+duplicate_node_closure (re_dfa_t *dfa, int top_org_node, int top_clone_node,
+ int root_node, unsigned int init_constraint)
+{
+ int org_node, clone_node, ret;
+ unsigned int constraint = init_constraint;
+ for (org_node = top_org_node, clone_node = top_clone_node;;)
+ {
+ int org_dest, clone_dest;
+ if (dfa->nodes[org_node].type == OP_BACK_REF)
+ {
+ /* If the back reference epsilon-transit, its destination must
+ also have the constraint. Then duplicate the epsilon closure
+ of the destination of the back reference, and store it in
+ edests of the back reference. */
+ org_dest = dfa->nexts[org_node];
+ re_node_set_empty (dfa->edests + clone_node);
+ clone_dest = duplicate_node (dfa, org_dest, constraint);
+ if (BE (clone_dest == -1, 0))
+ return REG_ESPACE;
+ dfa->nexts[clone_node] = dfa->nexts[org_node];
+ ret = re_node_set_insert (dfa->edests + clone_node, clone_dest);
+ if (BE (ret < 0, 0))
+ return REG_ESPACE;
+ }
+ else if (dfa->edests[org_node].nelem == 0)
+ {
+ /* In case of the node can't epsilon-transit, don't duplicate the
+ destination and store the original destination as the
+ destination of the node. */
+ dfa->nexts[clone_node] = dfa->nexts[org_node];
+ break;
+ }
+ else if (dfa->edests[org_node].nelem == 1)
+ {
+ /* In case of the node can epsilon-transit, and it has only one
+ destination. */
+ org_dest = dfa->edests[org_node].elems[0];
+ re_node_set_empty (dfa->edests + clone_node);
+ if (dfa->nodes[org_node].type == ANCHOR)
+ {
+ /* In case of the node has another constraint, append it. */
+ if (org_node == root_node && clone_node != org_node)
+ {
+ /* ...but if the node is root_node itself, it means the
+ epsilon closure have a loop, then tie it to the
+ destination of the root_node. */
+ ret = re_node_set_insert (dfa->edests + clone_node,
+ org_dest);
+ if (BE (ret < 0, 0))
+ return REG_ESPACE;
+ break;
+ }
+ constraint |= dfa->nodes[org_node].opr.ctx_type;
+ }
+ clone_dest = duplicate_node (dfa, org_dest, constraint);
+ if (BE (clone_dest == -1, 0))
+ return REG_ESPACE;
+ ret = re_node_set_insert (dfa->edests + clone_node, clone_dest);
+ if (BE (ret < 0, 0))
+ return REG_ESPACE;
+ }
+ else /* dfa->edests[org_node].nelem == 2 */
+ {
+ /* In case of the node can epsilon-transit, and it has two
+ destinations. In the bin_tree_t and DFA, that's '|' and '*'. */
+ org_dest = dfa->edests[org_node].elems[0];
+ re_node_set_empty (dfa->edests + clone_node);
+ /* Search for a duplicated node which satisfies the constraint. */
+ clone_dest = search_duplicated_node (dfa, org_dest, constraint);
+ if (clone_dest == -1)
+ {
+ /* There are no such a duplicated node, create a new one. */
+ reg_errcode_t err;
+ clone_dest = duplicate_node (dfa, org_dest, constraint);
+ if (BE (clone_dest == -1, 0))
+ return REG_ESPACE;
+ ret = re_node_set_insert (dfa->edests + clone_node, clone_dest);
+ if (BE (ret < 0, 0))
+ return REG_ESPACE;
+ err = duplicate_node_closure (dfa, org_dest, clone_dest,
+ root_node, constraint);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+ }
+ else
+ {
+ /* There are a duplicated node which satisfy the constraint,
+ use it to avoid infinite loop. */
+ ret = re_node_set_insert (dfa->edests + clone_node, clone_dest);
+ if (BE (ret < 0, 0))
+ return REG_ESPACE;
+ }
+
+ org_dest = dfa->edests[org_node].elems[1];
+ clone_dest = duplicate_node (dfa, org_dest, constraint);
+ if (BE (clone_dest == -1, 0))
+ return REG_ESPACE;
+ ret = re_node_set_insert (dfa->edests + clone_node, clone_dest);
+ if (BE (ret < 0, 0))
+ return REG_ESPACE;
+ }
+ org_node = org_dest;
+ clone_node = clone_dest;
+ }
+ return REG_NOERROR;
+}
+
+/* Search for a node which is duplicated from the node ORG_NODE, and
+ satisfies the constraint CONSTRAINT. */
+
+static int
+search_duplicated_node (const re_dfa_t *dfa, int org_node,
+ unsigned int constraint)
+{
+ int idx;
+ for (idx = dfa->nodes_len - 1; dfa->nodes[idx].duplicated && idx > 0; --idx)
+ {
+ if (org_node == dfa->org_indices[idx]
+ && constraint == dfa->nodes[idx].constraint)
+ return idx; /* Found. */
+ }
+ return -1; /* Not found. */
+}
+
+/* Duplicate the node whose index is ORG_IDX and set the constraint CONSTRAINT.
+ Return the index of the new node, or -1 if insufficient storage is
+ available. */
+
+static int
+duplicate_node (re_dfa_t *dfa, int org_idx, unsigned int constraint)
+{
+ int dup_idx = re_dfa_add_node (dfa, dfa->nodes[org_idx]);
+ if (BE (dup_idx != -1, 1))
+ {
+ dfa->nodes[dup_idx].constraint = constraint;
+ if (dfa->nodes[org_idx].type == ANCHOR)
+ dfa->nodes[dup_idx].constraint |= dfa->nodes[org_idx].opr.ctx_type;
+ dfa->nodes[dup_idx].duplicated = 1;
+
+ /* Store the index of the original node. */
+ dfa->org_indices[dup_idx] = org_idx;
+ }
+ return dup_idx;
+}
+
+static reg_errcode_t
+calc_inveclosure (re_dfa_t *dfa)
+{
+ int src, idx, ret;
+ for (idx = 0; idx < dfa->nodes_len; ++idx)
+ re_node_set_init_empty (dfa->inveclosures + idx);
+
+ for (src = 0; src < dfa->nodes_len; ++src)
+ {
+ int *elems = dfa->eclosures[src].elems;
+ for (idx = 0; idx < dfa->eclosures[src].nelem; ++idx)
+ {
+ ret = re_node_set_insert_last (dfa->inveclosures + elems[idx], src);
+ if (BE (ret == -1, 0))
+ return REG_ESPACE;
+ }
+ }
+
+ return REG_NOERROR;
+}
+
+/* Calculate "eclosure" for all the node in DFA. */
+
+static reg_errcode_t
+calc_eclosure (re_dfa_t *dfa)
+{
+ int node_idx, incomplete;
+#ifdef DEBUG
+ assert (dfa->nodes_len > 0);
+#endif
+ incomplete = 0;
+ /* For each nodes, calculate epsilon closure. */
+ for (node_idx = 0; ; ++node_idx)
+ {
+ reg_errcode_t err;
+ re_node_set eclosure_elem;
+ if (node_idx == dfa->nodes_len)
+ {
+ if (!incomplete)
+ break;
+ incomplete = 0;
+ node_idx = 0;
+ }
+
+#ifdef DEBUG
+ assert (dfa->eclosures[node_idx].nelem != -1);
+#endif
+
+ /* If we have already calculated, skip it. */
+ if (dfa->eclosures[node_idx].nelem != 0)
+ continue;
+ /* Calculate epsilon closure of `node_idx'. */
+ err = calc_eclosure_iter (&eclosure_elem, dfa, node_idx, 1);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+
+ if (dfa->eclosures[node_idx].nelem == 0)
+ {
+ incomplete = 1;
+ re_node_set_free (&eclosure_elem);
+ }
+ }
+ return REG_NOERROR;
+}
+
+/* Calculate epsilon closure of NODE. */
+
+static reg_errcode_t
+calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, int node, int root)
+{
+ reg_errcode_t err;
+ unsigned int constraint;
+ int i, incomplete;
+ re_node_set eclosure;
+ incomplete = 0;
+ err = re_node_set_alloc (&eclosure, dfa->edests[node].nelem + 1);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+
+ /* This indicates that we are calculating this node now.
+ We reference this value to avoid infinite loop. */
+ dfa->eclosures[node].nelem = -1;
+
+ constraint = ((dfa->nodes[node].type == ANCHOR)
+ ? dfa->nodes[node].opr.ctx_type : 0);
+ /* If the current node has constraints, duplicate all nodes.
+ Since they must inherit the constraints. */
+ if (constraint
+ && dfa->edests[node].nelem
+ && !dfa->nodes[dfa->edests[node].elems[0]].duplicated)
+ {
+ err = duplicate_node_closure (dfa, node, node, node, constraint);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+ }
+
+ /* Expand each epsilon destination nodes. */
+ if (IS_EPSILON_NODE(dfa->nodes[node].type))
+ for (i = 0; i < dfa->edests[node].nelem; ++i)
+ {
+ re_node_set eclosure_elem;
+ int edest = dfa->edests[node].elems[i];
+ /* If calculating the epsilon closure of `edest' is in progress,
+ return intermediate result. */
+ if (dfa->eclosures[edest].nelem == -1)
+ {
+ incomplete = 1;
+ continue;
+ }
+ /* If we haven't calculated the epsilon closure of `edest' yet,
+ calculate now. Otherwise use calculated epsilon closure. */
+ if (dfa->eclosures[edest].nelem == 0)
+ {
+ err = calc_eclosure_iter (&eclosure_elem, dfa, edest, 0);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+ }
+ else
+ eclosure_elem = dfa->eclosures[edest];
+ /* Merge the epsilon closure of `edest'. */
+ re_node_set_merge (&eclosure, &eclosure_elem);
+ /* If the epsilon closure of `edest' is incomplete,
+ the epsilon closure of this node is also incomplete. */
+ if (dfa->eclosures[edest].nelem == 0)
+ {
+ incomplete = 1;
+ re_node_set_free (&eclosure_elem);
+ }
+ }
+
+ /* Epsilon closures include itself. */
+ re_node_set_insert (&eclosure, node);
+ if (incomplete && !root)
+ dfa->eclosures[node].nelem = 0;
+ else
+ dfa->eclosures[node] = eclosure;
+ *new_set = eclosure;
+ return REG_NOERROR;
+}
+
+/* Functions for token which are used in the parser. */
+
+/* Fetch a token from INPUT.
+ We must not use this function inside bracket expressions. */
+
+static void
+internal_function
+fetch_token (re_token_t *result, re_string_t *input, reg_syntax_t syntax)
+{
+ re_string_skip_bytes (input, peek_token (result, input, syntax));
+}
+
+/* Peek a token from INPUT, and return the length of the token.
+ We must not use this function inside bracket expressions. */
+
+static int
+internal_function
+peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
+{
+ unsigned char c;
+
+ if (re_string_eoi (input))
+ {
+ token->type = END_OF_RE;
+ return 0;
+ }
+
+ c = re_string_peek_byte (input, 0);
+ token->opr.c = c;
+
+ token->word_char = 0;
+#ifdef RE_ENABLE_I18N
+ token->mb_partial = 0;
+ if (input->mb_cur_max > 1 &&
+ !re_string_first_byte (input, re_string_cur_idx (input)))
+ {
+ token->type = CHARACTER;
+ token->mb_partial = 1;
+ return 1;
+ }
+#endif
+ if (c == '\\')
+ {
+ unsigned char c2;
+ if (re_string_cur_idx (input) + 1 >= re_string_length (input))
+ {
+ token->type = BACK_SLASH;
+ return 1;
+ }
+
+ c2 = re_string_peek_byte_case (input, 1);
+ token->opr.c = c2;
+ token->type = CHARACTER;
+#ifdef RE_ENABLE_I18N
+ if (input->mb_cur_max > 1)
+ {
+ wint_t wc = re_string_wchar_at (input,
+ re_string_cur_idx (input) + 1);
+ token->word_char = IS_WIDE_WORD_CHAR (wc) != 0;
+ }
+ else
+#endif
+ token->word_char = IS_WORD_CHAR (c2) != 0;
+
+ switch (c2)
+ {
+ case '|':
+ if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_NO_BK_VBAR))
+ token->type = OP_ALT;
+ break;
+ case '1': case '2': case '3': case '4': case '5':
+ case '6': case '7': case '8': case '9':
+ if (!(syntax & RE_NO_BK_REFS))
+ {
+ token->type = OP_BACK_REF;
+ token->opr.idx = c2 - '1';
+ }
+ break;
+ case '<':
+ if (!(syntax & RE_NO_GNU_OPS))
+ {
+ token->type = ANCHOR;
+ token->opr.ctx_type = WORD_FIRST;
+ }
+ break;
+ case '>':
+ if (!(syntax & RE_NO_GNU_OPS))
+ {
+ token->type = ANCHOR;
+ token->opr.ctx_type = WORD_LAST;
+ }
+ break;
+ case 'b':
+ if (!(syntax & RE_NO_GNU_OPS))
+ {
+ token->type = ANCHOR;
+ token->opr.ctx_type = WORD_DELIM;
+ }
+ break;
+ case 'B':
+ if (!(syntax & RE_NO_GNU_OPS))
+ {
+ token->type = ANCHOR;
+ token->opr.ctx_type = NOT_WORD_DELIM;
+ }
+ break;
+ case 'w':
+ if (!(syntax & RE_NO_GNU_OPS))
+ token->type = OP_WORD;
+ break;
+ case 'W':
+ if (!(syntax & RE_NO_GNU_OPS))
+ token->type = OP_NOTWORD;
+ break;
+ case 's':
+ if (!(syntax & RE_NO_GNU_OPS))
+ token->type = OP_SPACE;
+ break;
+ case 'S':
+ if (!(syntax & RE_NO_GNU_OPS))
+ token->type = OP_NOTSPACE;
+ break;
+ case '`':
+ if (!(syntax & RE_NO_GNU_OPS))
+ {
+ token->type = ANCHOR;
+ token->opr.ctx_type = BUF_FIRST;
+ }
+ break;
+ case '\'':
+ if (!(syntax & RE_NO_GNU_OPS))
+ {
+ token->type = ANCHOR;
+ token->opr.ctx_type = BUF_LAST;
+ }
+ break;
+ case '(':
+ if (!(syntax & RE_NO_BK_PARENS))
+ token->type = OP_OPEN_SUBEXP;
+ break;
+ case ')':
+ if (!(syntax & RE_NO_BK_PARENS))
+ token->type = OP_CLOSE_SUBEXP;
+ break;
+ case '+':
+ if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_BK_PLUS_QM))
+ token->type = OP_DUP_PLUS;
+ break;
+ case '?':
+ if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_BK_PLUS_QM))
+ token->type = OP_DUP_QUESTION;
+ break;
+ case '{':
+ if ((syntax & RE_INTERVALS) && (!(syntax & RE_NO_BK_BRACES)))
+ token->type = OP_OPEN_DUP_NUM;
+ break;
+ case '}':
+ if ((syntax & RE_INTERVALS) && (!(syntax & RE_NO_BK_BRACES)))
+ token->type = OP_CLOSE_DUP_NUM;
+ break;
+ default:
+ break;
+ }
+ return 2;
+ }
+
+ token->type = CHARACTER;
+#ifdef RE_ENABLE_I18N
+ if (input->mb_cur_max > 1)
+ {
+ wint_t wc = re_string_wchar_at (input, re_string_cur_idx (input));
+ token->word_char = IS_WIDE_WORD_CHAR (wc) != 0;
+ }
+ else
+#endif
+ token->word_char = IS_WORD_CHAR (token->opr.c);
+
+ switch (c)
+ {
+ case '\n':
+ if (syntax & RE_NEWLINE_ALT)
+ token->type = OP_ALT;
+ break;
+ case '|':
+ if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_NO_BK_VBAR))
+ token->type = OP_ALT;
+ break;
+ case '*':
+ token->type = OP_DUP_ASTERISK;
+ break;
+ case '+':
+ if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_BK_PLUS_QM))
+ token->type = OP_DUP_PLUS;
+ break;
+ case '?':
+ if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_BK_PLUS_QM))
+ token->type = OP_DUP_QUESTION;
+ break;
+ case '{':
+ if ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES))
+ token->type = OP_OPEN_DUP_NUM;
+ break;
+ case '}':
+ if ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES))
+ token->type = OP_CLOSE_DUP_NUM;
+ break;
+ case '(':
+ if (syntax & RE_NO_BK_PARENS)
+ token->type = OP_OPEN_SUBEXP;
+ break;
+ case ')':
+ if (syntax & RE_NO_BK_PARENS)
+ token->type = OP_CLOSE_SUBEXP;
+ break;
+ case '[':
+ token->type = OP_OPEN_BRACKET;
+ break;
+ case '.':
+ token->type = OP_PERIOD;
+ break;
+ case '^':
+ if (!(syntax & (RE_CONTEXT_INDEP_ANCHORS | RE_CARET_ANCHORS_HERE)) &&
+ re_string_cur_idx (input) != 0)
+ {
+ char prev = re_string_peek_byte (input, -1);
+ if (!(syntax & RE_NEWLINE_ALT) || prev != '\n')
+ break;
+ }
+ token->type = ANCHOR;
+ token->opr.ctx_type = LINE_FIRST;
+ break;
+ case '$':
+ if (!(syntax & RE_CONTEXT_INDEP_ANCHORS) &&
+ re_string_cur_idx (input) + 1 != re_string_length (input))
+ {
+ re_token_t next;
+ re_string_skip_bytes (input, 1);
+ peek_token (&next, input, syntax);
+ re_string_skip_bytes (input, -1);
+ if (next.type != OP_ALT && next.type != OP_CLOSE_SUBEXP)
+ break;
+ }
+ token->type = ANCHOR;
+ token->opr.ctx_type = LINE_LAST;
+ break;
+ default:
+ break;
+ }
+ return 1;
+}
+
+/* Peek a token from INPUT, and return the length of the token.
+ We must not use this function out of bracket expressions. */
+
+static int
+internal_function
+peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
+{
+ unsigned char c;
+ if (re_string_eoi (input))
+ {
+ token->type = END_OF_RE;
+ return 0;
+ }
+ c = re_string_peek_byte (input, 0);
+ token->opr.c = c;
+
+#ifdef RE_ENABLE_I18N
+ if (input->mb_cur_max > 1 &&
+ !re_string_first_byte (input, re_string_cur_idx (input)))
+ {
+ token->type = CHARACTER;
+ return 1;
+ }
+#endif /* RE_ENABLE_I18N */
+
+ if (c == '\\' && (syntax & RE_BACKSLASH_ESCAPE_IN_LISTS)
+ && re_string_cur_idx (input) + 1 < re_string_length (input))
+ {
+ /* In this case, '\' escape a character. */
+ unsigned char c2;
+ re_string_skip_bytes (input, 1);
+ c2 = re_string_peek_byte (input, 0);
+ token->opr.c = c2;
+ token->type = CHARACTER;
+ return 1;
+ }
+ if (c == '[') /* '[' is a special char in a bracket exps. */
+ {
+ unsigned char c2;
+ int token_len;
+ if (re_string_cur_idx (input) + 1 < re_string_length (input))
+ c2 = re_string_peek_byte (input, 1);
+ else
+ c2 = 0;
+ token->opr.c = c2;
+ token_len = 2;
+ switch (c2)
+ {
+ case '.':
+ token->type = OP_OPEN_COLL_ELEM;
+ break;
+ case '=':
+ token->type = OP_OPEN_EQUIV_CLASS;
+ break;
+ case ':':
+ if (syntax & RE_CHAR_CLASSES)
+ {
+ token->type = OP_OPEN_CHAR_CLASS;
+ break;
+ }
+ /* else fall through. */
+ default:
+ token->type = CHARACTER;
+ token->opr.c = c;
+ token_len = 1;
+ break;
+ }
+ return token_len;
+ }
+ switch (c)
+ {
+ case '-':
+ token->type = OP_CHARSET_RANGE;
+ break;
+ case ']':
+ token->type = OP_CLOSE_BRACKET;
+ break;
+ case '^':
+ token->type = OP_NON_MATCH_LIST;
+ break;
+ default:
+ token->type = CHARACTER;
+ }
+ return 1;
+}
+
+/* Functions for parser. */
+
+/* Entry point of the parser.
+ Parse the regular expression REGEXP and return the structure tree.
+ If an error is occured, ERR is set by error code, and return NULL.
+ This function build the following tree, from regular expression <reg_exp>:
+ CAT
+ / \
+ / \
+ <reg_exp> EOR
+
+ CAT means concatenation.
+ EOR means end of regular expression. */
+
+static bin_tree_t *
+parse (re_string_t *regexp, regex_t *preg, reg_syntax_t syntax,
+ reg_errcode_t *err)
+{
+ re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+ bin_tree_t *tree, *eor, *root;
+ re_token_t current_token;
+ dfa->syntax = syntax;
+ fetch_token (&current_token, regexp, syntax | RE_CARET_ANCHORS_HERE);
+ tree = parse_reg_exp (regexp, preg, &current_token, syntax, 0, err);
+ if (BE (*err != REG_NOERROR && tree == NULL, 0))
+ return NULL;
+ eor = create_tree (dfa, NULL, NULL, END_OF_RE);
+ if (tree != NULL)
+ root = create_tree (dfa, tree, eor, CONCAT);
+ else
+ root = eor;
+ if (BE (eor == NULL || root == NULL, 0))
+ {
+ *err = REG_ESPACE;
+ return NULL;
+ }
+ return root;
+}
+
+/* This function build the following tree, from regular expression
+ <branch1>|<branch2>:
+ ALT
+ / \
+ / \
+ <branch1> <branch2>
+
+ ALT means alternative, which represents the operator `|'. */
+
+static bin_tree_t *
+parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
+ reg_syntax_t syntax, int nest, reg_errcode_t *err)
+{
+ re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+ bin_tree_t *tree, *branch = NULL;
+ tree = parse_branch (regexp, preg, token, syntax, nest, err);
+ if (BE (*err != REG_NOERROR && tree == NULL, 0))
+ return NULL;
+
+ while (token->type == OP_ALT)
+ {
+ fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE);
+ if (token->type != OP_ALT && token->type != END_OF_RE
+ && (nest == 0 || token->type != OP_CLOSE_SUBEXP))
+ {
+ branch = parse_branch (regexp, preg, token, syntax, nest, err);
+ if (BE (*err != REG_NOERROR && branch == NULL, 0))
+ return NULL;
+ }
+ else
+ branch = NULL;
+ tree = create_tree (dfa, tree, branch, OP_ALT);
+ if (BE (tree == NULL, 0))
+ {
+ *err = REG_ESPACE;
+ return NULL;
+ }
+ }
+ return tree;
+}
+
+/* This function build the following tree, from regular expression
+ <exp1><exp2>:
+ CAT
+ / \
+ / \
+ <exp1> <exp2>
+
+ CAT means concatenation. */
+
+static bin_tree_t *
+parse_branch (re_string_t *regexp, regex_t *preg, re_token_t *token,
+ reg_syntax_t syntax, int nest, reg_errcode_t *err)
+{
+ bin_tree_t *tree, *exp;
+ re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+ tree = parse_expression (regexp, preg, token, syntax, nest, err);
+ if (BE (*err != REG_NOERROR && tree == NULL, 0))
+ return NULL;
+
+ while (token->type != OP_ALT && token->type != END_OF_RE
+ && (nest == 0 || token->type != OP_CLOSE_SUBEXP))
+ {
+ exp = parse_expression (regexp, preg, token, syntax, nest, err);
+ if (BE (*err != REG_NOERROR && exp == NULL, 0))
+ {
+ return NULL;
+ }
+ if (tree != NULL && exp != NULL)
+ {
+ tree = create_tree (dfa, tree, exp, CONCAT);
+ if (tree == NULL)
+ {
+ *err = REG_ESPACE;
+ return NULL;
+ }
+ }
+ else if (tree == NULL)
+ tree = exp;
+ /* Otherwise exp == NULL, we don't need to create new tree. */
+ }
+ return tree;
+}
+
+/* This function build the following tree, from regular expression a*:
+ *
+ |
+ a
+*/
+
+static bin_tree_t *
+parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
+ reg_syntax_t syntax, int nest, reg_errcode_t *err)
+{
+ re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+ bin_tree_t *tree;
+ switch (token->type)
+ {
+ case CHARACTER:
+ tree = create_token_tree (dfa, NULL, NULL, token);
+ if (BE (tree == NULL, 0))
+ {
+ *err = REG_ESPACE;
+ return NULL;
+ }
+#ifdef RE_ENABLE_I18N
+ if (dfa->mb_cur_max > 1)
+ {
+ while (!re_string_eoi (regexp)
+ && !re_string_first_byte (regexp, re_string_cur_idx (regexp)))
+ {
+ bin_tree_t *mbc_remain;
+ fetch_token (token, regexp, syntax);
+ mbc_remain = create_token_tree (dfa, NULL, NULL, token);
+ tree = create_tree (dfa, tree, mbc_remain, CONCAT);
+ if (BE (mbc_remain == NULL || tree == NULL, 0))
+ {
+ *err = REG_ESPACE;
+ return NULL;
+ }
+ }
+ }
+#endif
+ break;
+ case OP_OPEN_SUBEXP:
+ tree = parse_sub_exp (regexp, preg, token, syntax, nest + 1, err);
+ if (BE (*err != REG_NOERROR && tree == NULL, 0))
+ return NULL;
+ break;
+ case OP_OPEN_BRACKET:
+ tree = parse_bracket_exp (regexp, dfa, token, syntax, err);
+ if (BE (*err != REG_NOERROR && tree == NULL, 0))
+ return NULL;
+ break;
+ case OP_BACK_REF:
+ if (!BE (dfa->completed_bkref_map & (1 << token->opr.idx), 1))
+ {
+ *err = REG_ESUBREG;
+ return NULL;
+ }
+ dfa->used_bkref_map |= 1 << token->opr.idx;
+ tree = create_token_tree (dfa, NULL, NULL, token);
+ if (BE (tree == NULL, 0))
+ {
+ *err = REG_ESPACE;
+ return NULL;
+ }
+ ++dfa->nbackref;
+ dfa->has_mb_node = 1;
+ break;
+ case OP_OPEN_DUP_NUM:
+ if (syntax & RE_CONTEXT_INVALID_DUP)
+ {
+ *err = REG_BADRPT;
+ return NULL;
+ }
+ /* FALLTHROUGH */
+ case OP_DUP_ASTERISK:
+ case OP_DUP_PLUS:
+ case OP_DUP_QUESTION:
+ if (syntax & RE_CONTEXT_INVALID_OPS)
+ {
+ *err = REG_BADRPT;
+ return NULL;
+ }
+ else if (syntax & RE_CONTEXT_INDEP_OPS)
+ {
+ fetch_token (token, regexp, syntax);
+ return parse_expression (regexp, preg, token, syntax, nest, err);
+ }
+ /* else fall through */
+ case OP_CLOSE_SUBEXP:
+ if ((token->type == OP_CLOSE_SUBEXP) &&
+ !(syntax & RE_UNMATCHED_RIGHT_PAREN_ORD))
+ {
+ *err = REG_ERPAREN;
+ return NULL;
+ }
+ /* else fall through */
+ case OP_CLOSE_DUP_NUM:
+ /* We treat it as a normal character. */
+
+ /* Then we can these characters as normal characters. */
+ token->type = CHARACTER;
+ /* mb_partial and word_char bits should be initialized already
+ by peek_token. */
+ tree = create_token_tree (dfa, NULL, NULL, token);
+ if (BE (tree == NULL, 0))
+ {
+ *err = REG_ESPACE;
+ return NULL;
+ }
+ break;
+ case ANCHOR:
+ if ((token->opr.ctx_type
+ & (WORD_DELIM | NOT_WORD_DELIM | WORD_FIRST | WORD_LAST))
+ && dfa->word_ops_used == 0)
+ init_word_char (dfa);
+ if (token->opr.ctx_type == WORD_DELIM
+ || token->opr.ctx_type == NOT_WORD_DELIM)
+ {
+ bin_tree_t *tree_first, *tree_last;
+ if (token->opr.ctx_type == WORD_DELIM)
+ {
+ token->opr.ctx_type = WORD_FIRST;
+ tree_first = create_token_tree (dfa, NULL, NULL, token);
+ token->opr.ctx_type = WORD_LAST;
+ }
+ else
+ {
+ token->opr.ctx_type = INSIDE_WORD;
+ tree_first = create_token_tree (dfa, NULL, NULL, token);
+ token->opr.ctx_type = INSIDE_NOTWORD;
+ }
+ tree_last = create_token_tree (dfa, NULL, NULL, token);
+ tree = create_tree (dfa, tree_first, tree_last, OP_ALT);
+ if (BE (tree_first == NULL || tree_last == NULL || tree == NULL, 0))
+ {
+ *err = REG_ESPACE;
+ return NULL;
+ }
+ }
+ else
+ {
+ tree = create_token_tree (dfa, NULL, NULL, token);
+ if (BE (tree == NULL, 0))
+ {
+ *err = REG_ESPACE;
+ return NULL;
+ }
+ }
+ /* We must return here, since ANCHORs can't be followed
+ by repetition operators.
+ eg. RE"^*" is invalid or "<ANCHOR(^)><CHAR(*)>",
+ it must not be "<ANCHOR(^)><REPEAT(*)>". */
+ fetch_token (token, regexp, syntax);
+ return tree;
+ case OP_PERIOD:
+ tree = create_token_tree (dfa, NULL, NULL, token);
+ if (BE (tree == NULL, 0))
+ {
+ *err = REG_ESPACE;
+ return NULL;
+ }
+ if (dfa->mb_cur_max > 1)
+ dfa->has_mb_node = 1;
+ break;
+ case OP_WORD:
+ case OP_NOTWORD:
+ tree = build_charclass_op (dfa, regexp->trans,
+ (const unsigned char *) "alnum",
+ (const unsigned char *) "_",
+ token->type == OP_NOTWORD, err);
+ if (BE (*err != REG_NOERROR && tree == NULL, 0))
+ return NULL;
+ break;
+ case OP_SPACE:
+ case OP_NOTSPACE:
+ tree = build_charclass_op (dfa, regexp->trans,
+ (const unsigned char *) "space",
+ (const unsigned char *) "",
+ token->type == OP_NOTSPACE, err);
+ if (BE (*err != REG_NOERROR && tree == NULL, 0))
+ return NULL;
+ break;
+ case OP_ALT:
+ case END_OF_RE:
+ return NULL;
+ case BACK_SLASH:
+ *err = REG_EESCAPE;
+ return NULL;
+ default:
+ /* Must not happen? */
+#ifdef DEBUG
+ assert (0);
+#endif
+ return NULL;
+ }
+ fetch_token (token, regexp, syntax);
+
+ while (token->type == OP_DUP_ASTERISK || token->type == OP_DUP_PLUS
+ || token->type == OP_DUP_QUESTION || token->type == OP_OPEN_DUP_NUM)
+ {
+ tree = parse_dup_op (tree, regexp, dfa, token, syntax, err);
+ if (BE (*err != REG_NOERROR && tree == NULL, 0))
+ return NULL;
+ /* In BRE consecutive duplications are not allowed. */
+ if ((syntax & RE_CONTEXT_INVALID_DUP)
+ && (token->type == OP_DUP_ASTERISK
+ || token->type == OP_OPEN_DUP_NUM))
+ {
+ *err = REG_BADRPT;
+ return NULL;
+ }
+ }
+
+ return tree;
+}
+
+/* This function build the following tree, from regular expression
+ (<reg_exp>):
+ SUBEXP
+ |
+ <reg_exp>
+*/
+
+static bin_tree_t *
+parse_sub_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
+ reg_syntax_t syntax, int nest, reg_errcode_t *err)
+{
+ re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+ bin_tree_t *tree;
+ size_t cur_nsub;
+ cur_nsub = preg->re_nsub++;
+
+ fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE);
+
+ /* The subexpression may be a null string. */
+ if (token->type == OP_CLOSE_SUBEXP)
+ tree = NULL;
+ else
+ {
+ tree = parse_reg_exp (regexp, preg, token, syntax, nest, err);
+ if (BE (*err == REG_NOERROR && token->type != OP_CLOSE_SUBEXP, 0))
+ *err = REG_EPAREN;
+ if (BE (*err != REG_NOERROR, 0))
+ return NULL;
+ }
+
+ if (cur_nsub <= '9' - '1')
+ dfa->completed_bkref_map |= 1 << cur_nsub;
+
+ tree = create_tree (dfa, tree, NULL, SUBEXP);
+ if (BE (tree == NULL, 0))
+ {
+ *err = REG_ESPACE;
+ return NULL;
+ }
+ tree->token.opr.idx = cur_nsub;
+ return tree;
+}
+
+/* This function parse repetition operators like "*", "+", "{1,3}" etc. */
+
+static bin_tree_t *
+parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
+ re_token_t *token, reg_syntax_t syntax, reg_errcode_t *err)
+{
+ bin_tree_t *tree = NULL, *old_tree = NULL;
+ int i, start, end, start_idx = re_string_cur_idx (regexp);
+ re_token_t start_token = *token;
+
+ if (token->type == OP_OPEN_DUP_NUM)
+ {
+ end = 0;
+ start = fetch_number (regexp, token, syntax);
+ if (start == -1)
+ {
+ if (token->type == CHARACTER && token->opr.c == ',')
+ start = 0; /* We treat "{,m}" as "{0,m}". */
+ else
+ {
+ *err = REG_BADBR; /* <re>{} is invalid. */
+ return NULL;
+ }
+ }
+ if (BE (start != -2, 1))
+ {
+ /* We treat "{n}" as "{n,n}". */
+ end = ((token->type == OP_CLOSE_DUP_NUM) ? start
+ : ((token->type == CHARACTER && token->opr.c == ',')
+ ? fetch_number (regexp, token, syntax) : -2));
+ }
+ if (BE (start == -2 || end == -2, 0))
+ {
+ /* Invalid sequence. */
+ if (BE (!(syntax & RE_INVALID_INTERVAL_ORD), 0))
+ {
+ if (token->type == END_OF_RE)
+ *err = REG_EBRACE;
+ else
+ *err = REG_BADBR;
+
+ return NULL;
+ }
+
+ /* If the syntax bit is set, rollback. */
+ re_string_set_index (regexp, start_idx);
+ *token = start_token;
+ token->type = CHARACTER;
+ /* mb_partial and word_char bits should be already initialized by
+ peek_token. */
+ return elem;
+ }
+
+ if (BE (end != -1 && start > end, 0))
+ {
+ /* First number greater than second. */
+ *err = REG_BADBR;
+ return NULL;
+ }
+ }
+ else
+ {
+ start = (token->type == OP_DUP_PLUS) ? 1 : 0;
+ end = (token->type == OP_DUP_QUESTION) ? 1 : -1;
+ }
+
+ fetch_token (token, regexp, syntax);
+
+ if (BE (elem == NULL, 0))
+ return NULL;
+ if (BE (start == 0 && end == 0, 0))
+ {
+ postorder (elem, free_tree, NULL);
+ return NULL;
+ }
+
+ /* Extract "<re>{n,m}" to "<re><re>...<re><re>{0,<m-n>}". */
+ if (BE (start > 0, 0))
+ {
+ tree = elem;
+ for (i = 2; i <= start; ++i)
+ {
+ elem = duplicate_tree (elem, dfa);
+ tree = create_tree (dfa, tree, elem, CONCAT);
+ if (BE (elem == NULL || tree == NULL, 0))
+ goto parse_dup_op_espace;
+ }
+
+ if (start == end)
+ return tree;
+
+ /* Duplicate ELEM before it is marked optional. */
+ elem = duplicate_tree (elem, dfa);
+ old_tree = tree;
+ }
+ else
+ old_tree = NULL;
+
+ if (elem->token.type == SUBEXP)
+ postorder (elem, mark_opt_subexp, (void *) (long) elem->token.opr.idx);
+
+ tree = create_tree (dfa, elem, NULL, (end == -1 ? OP_DUP_ASTERISK : OP_ALT));
+ if (BE (tree == NULL, 0))
+ goto parse_dup_op_espace;
+
+ /* This loop is actually executed only when end != -1,
+ to rewrite <re>{0,n} as (<re>(<re>...<re>?)?)?... We have
+ already created the start+1-th copy. */
+ for (i = start + 2; i <= end; ++i)
+ {
+ elem = duplicate_tree (elem, dfa);
+ tree = create_tree (dfa, tree, elem, CONCAT);
+ if (BE (elem == NULL || tree == NULL, 0))
+ goto parse_dup_op_espace;
+
+ tree = create_tree (dfa, tree, NULL, OP_ALT);
+ if (BE (tree == NULL, 0))
+ goto parse_dup_op_espace;
+ }
+
+ if (old_tree)
+ tree = create_tree (dfa, old_tree, tree, CONCAT);
+
+ return tree;
+
+ parse_dup_op_espace:
+ *err = REG_ESPACE;
+ return NULL;
+}
+
+/* Size of the names for collating symbol/equivalence_class/character_class.
+ I'm not sure, but maybe enough. */
+#define BRACKET_NAME_BUF_SIZE 32
+
+#ifndef _LIBC
+ /* Local function for parse_bracket_exp only used in case of NOT _LIBC.
+ Build the range expression which starts from START_ELEM, and ends
+ at END_ELEM. The result are written to MBCSET and SBCSET.
+ RANGE_ALLOC is the allocated size of mbcset->range_starts, and
+ mbcset->range_ends, is a pointer argument sinse we may
+ update it. */
+
+static reg_errcode_t
+internal_function
+# ifdef RE_ENABLE_I18N
+build_range_exp (bitset_t sbcset, re_charset_t *mbcset, int *range_alloc,
+ bracket_elem_t *start_elem, bracket_elem_t *end_elem)
+# else /* not RE_ENABLE_I18N */
+build_range_exp (bitset_t sbcset, bracket_elem_t *start_elem,
+ bracket_elem_t *end_elem)
+# endif /* not RE_ENABLE_I18N */
+{
+ unsigned int start_ch, end_ch;
+ /* Equivalence Classes and Character Classes can't be a range start/end. */
+ if (BE (start_elem->type == EQUIV_CLASS || start_elem->type == CHAR_CLASS
+ || end_elem->type == EQUIV_CLASS || end_elem->type == CHAR_CLASS,
+ 0))
+ return REG_ERANGE;
+
+ /* We can handle no multi character collating elements without libc
+ support. */
+ if (BE ((start_elem->type == COLL_SYM
+ && strlen ((char *) start_elem->opr.name) > 1)
+ || (end_elem->type == COLL_SYM
+ && strlen ((char *) end_elem->opr.name) > 1), 0))
+ return REG_ECOLLATE;
+
+# ifdef RE_ENABLE_I18N
+ {
+ wchar_t wc;
+ wint_t start_wc;
+ wint_t end_wc;
+ wchar_t cmp_buf[6] = {L'\0', L'\0', L'\0', L'\0', L'\0', L'\0'};
+
+ start_ch = ((start_elem->type == SB_CHAR) ? start_elem->opr.ch
+ : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0]
+ : 0));
+ end_ch = ((end_elem->type == SB_CHAR) ? end_elem->opr.ch
+ : ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0]
+ : 0));
+ start_wc = ((start_elem->type == SB_CHAR || start_elem->type == COLL_SYM)
+ ? __btowc (start_ch) : start_elem->opr.wch);
+ end_wc = ((end_elem->type == SB_CHAR || end_elem->type == COLL_SYM)
+ ? __btowc (end_ch) : end_elem->opr.wch);
+ if (start_wc == WEOF || end_wc == WEOF)
+ return REG_ECOLLATE;
+ cmp_buf[0] = start_wc;
+ cmp_buf[4] = end_wc;
+ if (wcscoll (cmp_buf, cmp_buf + 4) > 0)
+ return REG_ERANGE;
+
+ /* Got valid collation sequence values, add them as a new entry.
+ However, for !_LIBC we have no collation elements: if the
+ character set is single byte, the single byte character set
+ that we build below suffices. parse_bracket_exp passes
+ no MBCSET if dfa->mb_cur_max == 1. */
+ if (mbcset)
+ {
+ /* Check the space of the arrays. */
+ if (BE (*range_alloc == mbcset->nranges, 0))
+ {
+ /* There is not enough space, need realloc. */
+ wchar_t *new_array_start, *new_array_end;
+ int new_nranges;
+
+ /* +1 in case of mbcset->nranges is 0. */
+ new_nranges = 2 * mbcset->nranges + 1;
+ /* Use realloc since mbcset->range_starts and mbcset->range_ends
+ are NULL if *range_alloc == 0. */
+ new_array_start = re_realloc (mbcset->range_starts, wchar_t,
+ new_nranges);
+ new_array_end = re_realloc (mbcset->range_ends, wchar_t,
+ new_nranges);
+
+ if (BE (new_array_start == NULL || new_array_end == NULL, 0))
+ return REG_ESPACE;
+
+ mbcset->range_starts = new_array_start;
+ mbcset->range_ends = new_array_end;
+ *range_alloc = new_nranges;
+ }
+
+ mbcset->range_starts[mbcset->nranges] = start_wc;
+ mbcset->range_ends[mbcset->nranges++] = end_wc;
+ }
+
+ /* Build the table for single byte characters. */
+ for (wc = 0; wc < SBC_MAX; ++wc)
+ {
+ cmp_buf[2] = wc;
+ if (wcscoll (cmp_buf, cmp_buf + 2) <= 0
+ && wcscoll (cmp_buf + 2, cmp_buf + 4) <= 0)
+ bitset_set (sbcset, wc);
+ }
+ }
+# else /* not RE_ENABLE_I18N */
+ {
+ unsigned int ch;
+ start_ch = ((start_elem->type == SB_CHAR ) ? start_elem->opr.ch
+ : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0]
+ : 0));
+ end_ch = ((end_elem->type == SB_CHAR ) ? end_elem->opr.ch
+ : ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0]
+ : 0));
+ if (start_ch > end_ch)
+ return REG_ERANGE;
+ /* Build the table for single byte characters. */
+ for (ch = 0; ch < SBC_MAX; ++ch)
+ if (start_ch <= ch && ch <= end_ch)
+ bitset_set (sbcset, ch);
+ }
+# endif /* not RE_ENABLE_I18N */
+ return REG_NOERROR;
+}
+#endif /* not _LIBC */
+
+#ifndef _LIBC
+/* Helper function for parse_bracket_exp only used in case of NOT _LIBC..
+ Build the collating element which is represented by NAME.
+ The result are written to MBCSET and SBCSET.
+ COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a
+ pointer argument since we may update it. */
+
+static reg_errcode_t
+internal_function
+# ifdef RE_ENABLE_I18N
+build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset,
+ int *coll_sym_alloc, const unsigned char *name)
+# else /* not RE_ENABLE_I18N */
+build_collating_symbol (bitset_t sbcset, const unsigned char *name)
+# endif /* not RE_ENABLE_I18N */
+{
+ size_t name_len = strlen ((const char *) name);
+ if (BE (name_len != 1, 0))
+ return REG_ECOLLATE;
+ else
+ {
+ bitset_set (sbcset, name[0]);
+ return REG_NOERROR;
+ }
+}
+#endif /* not _LIBC */
+
+/* This function parse bracket expression like "[abc]", "[a-c]",
+ "[[.a-a.]]" etc. */
+
+static bin_tree_t *
+parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
+ reg_syntax_t syntax, reg_errcode_t *err)
+{
+#ifdef _LIBC
+ const unsigned char *collseqmb;
+ const char *collseqwc;
+ uint32_t nrules;
+ int32_t table_size;
+ const int32_t *symb_table;
+ const unsigned char *extra;
+
+ /* Local function for parse_bracket_exp used in _LIBC environement.
+ Seek the collating symbol entry correspondings to NAME.
+ Return the index of the symbol in the SYMB_TABLE. */
+
+ auto inline int32_t
+ __attribute ((always_inline))
+ seek_collating_symbol_entry (name, name_len)
+ const unsigned char *name;
+ size_t name_len;
+ {
+ int32_t hash = elem_hash ((const char *) name, name_len);
+ int32_t elem = hash % table_size;
+ if (symb_table[2 * elem] != 0)
+ {
+ int32_t second = hash % (table_size - 2) + 1;
+
+ do
+ {
+ /* First compare the hashing value. */
+ if (symb_table[2 * elem] == hash
+ /* Compare the length of the name. */
+ && name_len == extra[symb_table[2 * elem + 1]]
+ /* Compare the name. */
+ && memcmp (name, &extra[symb_table[2 * elem + 1] + 1],
+ name_len) == 0)
+ {
+ /* Yep, this is the entry. */
+ break;
+ }
+
+ /* Next entry. */
+ elem += second;
+ }
+ while (symb_table[2 * elem] != 0);
+ }
+ return elem;
+ }
+
+ /* Local function for parse_bracket_exp used in _LIBC environement.
+ Look up the collation sequence value of BR_ELEM.
+ Return the value if succeeded, UINT_MAX otherwise. */
+
+ auto inline unsigned int
+ __attribute ((always_inline))
+ lookup_collation_sequence_value (br_elem)
+ bracket_elem_t *br_elem;
+ {
+ if (br_elem->type == SB_CHAR)
+ {
+ /*
+ if (MB_CUR_MAX == 1)
+ */
+ if (nrules == 0)
+ return collseqmb[br_elem->opr.ch];
+ else
+ {
+ wint_t wc = __btowc (br_elem->opr.ch);
+ return __collseq_table_lookup (collseqwc, wc);
+ }
+ }
+ else if (br_elem->type == MB_CHAR)
+ {
+ return __collseq_table_lookup (collseqwc, br_elem->opr.wch);
+ }
+ else if (br_elem->type == COLL_SYM)
+ {
+ size_t sym_name_len = strlen ((char *) br_elem->opr.name);
+ if (nrules != 0)
+ {
+ int32_t elem, idx;
+ elem = seek_collating_symbol_entry (br_elem->opr.name,
+ sym_name_len);
+ if (symb_table[2 * elem] != 0)
+ {
+ /* We found the entry. */
+ idx = symb_table[2 * elem + 1];
+ /* Skip the name of collating element name. */
+ idx += 1 + extra[idx];
+ /* Skip the byte sequence of the collating element. */
+ idx += 1 + extra[idx];
+ /* Adjust for the alignment. */
+ idx = (idx + 3) & ~3;
+ /* Skip the multibyte collation sequence value. */
+ idx += sizeof (unsigned int);
+ /* Skip the wide char sequence of the collating element. */
+ idx += sizeof (unsigned int) *
+ (1 + *(unsigned int *) (extra + idx));
+ /* Return the collation sequence value. */
+ return *(unsigned int *) (extra + idx);
+ }
+ else if (symb_table[2 * elem] == 0 && sym_name_len == 1)
+ {
+ /* No valid character. Match it as a single byte
+ character. */
+ return collseqmb[br_elem->opr.name[0]];
+ }
+ }
+ else if (sym_name_len == 1)
+ return collseqmb[br_elem->opr.name[0]];
+ }
+ return UINT_MAX;
+ }
+
+ /* Local function for parse_bracket_exp used in _LIBC environement.
+ Build the range expression which starts from START_ELEM, and ends
+ at END_ELEM. The result are written to MBCSET and SBCSET.
+ RANGE_ALLOC is the allocated size of mbcset->range_starts, and
+ mbcset->range_ends, is a pointer argument sinse we may
+ update it. */
+
+ auto inline reg_errcode_t
+ __attribute ((always_inline))
+ build_range_exp (sbcset, mbcset, range_alloc, start_elem, end_elem)
+ re_charset_t *mbcset;
+ int *range_alloc;
+ bitset_t sbcset;
+ bracket_elem_t *start_elem, *end_elem;
+ {
+ unsigned int ch;
+ uint32_t start_collseq;
+ uint32_t end_collseq;
+
+ /* Equivalence Classes and Character Classes can't be a range
+ start/end. */
+ if (BE (start_elem->type == EQUIV_CLASS || start_elem->type == CHAR_CLASS
+ || end_elem->type == EQUIV_CLASS || end_elem->type == CHAR_CLASS,
+ 0))
+ return REG_ERANGE;
+
+ start_collseq = lookup_collation_sequence_value (start_elem);
+ end_collseq = lookup_collation_sequence_value (end_elem);
+ /* Check start/end collation sequence values. */
+ if (BE (start_collseq == UINT_MAX || end_collseq == UINT_MAX, 0))
+ return REG_ECOLLATE;
+ if (BE ((syntax & RE_NO_EMPTY_RANGES) && start_collseq > end_collseq, 0))
+ return REG_ERANGE;
+
+ /* Got valid collation sequence values, add them as a new entry.
+ However, if we have no collation elements, and the character set
+ is single byte, the single byte character set that we
+ build below suffices. */
+ if (nrules > 0 || dfa->mb_cur_max > 1)
+ {
+ /* Check the space of the arrays. */
+ if (BE (*range_alloc == mbcset->nranges, 0))
+ {
+ /* There is not enough space, need realloc. */
+ uint32_t *new_array_start;
+ uint32_t *new_array_end;
+ int new_nranges;
+
+ /* +1 in case of mbcset->nranges is 0. */
+ new_nranges = 2 * mbcset->nranges + 1;
+ new_array_start = re_realloc (mbcset->range_starts, uint32_t,
+ new_nranges);
+ new_array_end = re_realloc (mbcset->range_ends, uint32_t,
+ new_nranges);
+
+ if (BE (new_array_start == NULL || new_array_end == NULL, 0))
+ return REG_ESPACE;
+
+ mbcset->range_starts = new_array_start;
+ mbcset->range_ends = new_array_end;
+ *range_alloc = new_nranges;
+ }
+
+ mbcset->range_starts[mbcset->nranges] = start_collseq;
+ mbcset->range_ends[mbcset->nranges++] = end_collseq;
+ }
+
+ /* Build the table for single byte characters. */
+ for (ch = 0; ch < SBC_MAX; ch++)
+ {
+ uint32_t ch_collseq;
+ /*
+ if (MB_CUR_MAX == 1)
+ */
+ if (nrules == 0)
+ ch_collseq = collseqmb[ch];
+ else
+ ch_collseq = __collseq_table_lookup (collseqwc, __btowc (ch));
+ if (start_collseq <= ch_collseq && ch_collseq <= end_collseq)
+ bitset_set (sbcset, ch);
+ }
+ return REG_NOERROR;
+ }
+
+ /* Local function for parse_bracket_exp used in _LIBC environement.
+ Build the collating element which is represented by NAME.
+ The result are written to MBCSET and SBCSET.
+ COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a
+ pointer argument sinse we may update it. */
+
+ auto inline reg_errcode_t
+ __attribute ((always_inline))
+ build_collating_symbol (sbcset, mbcset, coll_sym_alloc, name)
+ re_charset_t *mbcset;
+ int *coll_sym_alloc;
+ bitset_t sbcset;
+ const unsigned char *name;
+ {
+ int32_t elem, idx;
+ size_t name_len = strlen ((const char *) name);
+ if (nrules != 0)
+ {
+ elem = seek_collating_symbol_entry (name, name_len);
+ if (symb_table[2 * elem] != 0)
+ {
+ /* We found the entry. */
+ idx = symb_table[2 * elem + 1];
+ /* Skip the name of collating element name. */
+ idx += 1 + extra[idx];
+ }
+ else if (symb_table[2 * elem] == 0 && name_len == 1)
+ {
+ /* No valid character, treat it as a normal
+ character. */
+ bitset_set (sbcset, name[0]);
+ return REG_NOERROR;
+ }
+ else
+ return REG_ECOLLATE;
+
+ /* Got valid collation sequence, add it as a new entry. */
+ /* Check the space of the arrays. */
+ if (BE (*coll_sym_alloc == mbcset->ncoll_syms, 0))
+ {
+ /* Not enough, realloc it. */
+ /* +1 in case of mbcset->ncoll_syms is 0. */
+ int new_coll_sym_alloc = 2 * mbcset->ncoll_syms + 1;
+ /* Use realloc since mbcset->coll_syms is NULL
+ if *alloc == 0. */
+ int32_t *new_coll_syms = re_realloc (mbcset->coll_syms, int32_t,
+ new_coll_sym_alloc);
+ if (BE (new_coll_syms == NULL, 0))
+ return REG_ESPACE;
+ mbcset->coll_syms = new_coll_syms;
+ *coll_sym_alloc = new_coll_sym_alloc;
+ }
+ mbcset->coll_syms[mbcset->ncoll_syms++] = idx;
+ return REG_NOERROR;
+ }
+ else
+ {
+ if (BE (name_len != 1, 0))
+ return REG_ECOLLATE;
+ else
+ {
+ bitset_set (sbcset, name[0]);
+ return REG_NOERROR;
+ }
+ }
+ }
+#endif
+
+ re_token_t br_token;
+ re_bitset_ptr_t sbcset;
+#ifdef RE_ENABLE_I18N
+ re_charset_t *mbcset;
+ int coll_sym_alloc = 0, range_alloc = 0, mbchar_alloc = 0;
+ int equiv_class_alloc = 0, char_class_alloc = 0;
+#endif /* not RE_ENABLE_I18N */
+ int non_match = 0;
+ bin_tree_t *work_tree;
+ int token_len;
+ int first_round = 1;
+#ifdef _LIBC
+ collseqmb = (const unsigned char *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQMB);
+ nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
+ if (nrules)
+ {
+ /*
+ if (MB_CUR_MAX > 1)
+ */
+ collseqwc = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQWC);
+ table_size = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_SYMB_HASH_SIZEMB);
+ symb_table = (const int32_t *) _NL_CURRENT (LC_COLLATE,
+ _NL_COLLATE_SYMB_TABLEMB);
+ extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE,
+ _NL_COLLATE_SYMB_EXTRAMB);
+ }
+#endif
+ sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
+#ifdef RE_ENABLE_I18N
+ mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
+#endif /* RE_ENABLE_I18N */
+#ifdef RE_ENABLE_I18N
+ if (BE (sbcset == NULL || mbcset == NULL, 0))
+#else
+ if (BE (sbcset == NULL, 0))
+#endif /* RE_ENABLE_I18N */
+ {
+ *err = REG_ESPACE;
+ return NULL;
+ }
+
+ token_len = peek_token_bracket (token, regexp, syntax);
+ if (BE (token->type == END_OF_RE, 0))
+ {
+ *err = REG_BADPAT;
+ goto parse_bracket_exp_free_return;
+ }
+ if (token->type == OP_NON_MATCH_LIST)
+ {
+#ifdef RE_ENABLE_I18N
+ mbcset->non_match = 1;
+#endif /* not RE_ENABLE_I18N */
+ non_match = 1;
+ if (syntax & RE_HAT_LISTS_NOT_NEWLINE)
+ bitset_set (sbcset, '\0');
+ re_string_skip_bytes (regexp, token_len); /* Skip a token. */
+ token_len = peek_token_bracket (token, regexp, syntax);
+ if (BE (token->type == END_OF_RE, 0))
+ {
+ *err = REG_BADPAT;
+ goto parse_bracket_exp_free_return;
+ }
+ }
+
+ /* We treat the first ']' as a normal character. */
+ if (token->type == OP_CLOSE_BRACKET)
+ token->type = CHARACTER;
+
+ while (1)
+ {
+ bracket_elem_t start_elem, end_elem;
+ unsigned char start_name_buf[BRACKET_NAME_BUF_SIZE];
+ unsigned char end_name_buf[BRACKET_NAME_BUF_SIZE];
+ reg_errcode_t ret;
+ int token_len2 = 0, is_range_exp = 0;
+ re_token_t token2;
+
+ start_elem.opr.name = start_name_buf;
+ ret = parse_bracket_element (&start_elem, regexp, token, token_len, dfa,
+ syntax, first_round);
+ if (BE (ret != REG_NOERROR, 0))
+ {
+ *err = ret;
+ goto parse_bracket_exp_free_return;
+ }
+ first_round = 0;
+
+ /* Get information about the next token. We need it in any case. */
+ token_len = peek_token_bracket (token, regexp, syntax);
+
+ /* Do not check for ranges if we know they are not allowed. */
+ if (start_elem.type != CHAR_CLASS && start_elem.type != EQUIV_CLASS)
+ {
+ if (BE (token->type == END_OF_RE, 0))
+ {
+ *err = REG_EBRACK;
+ goto parse_bracket_exp_free_return;
+ }
+ if (token->type == OP_CHARSET_RANGE)
+ {
+ re_string_skip_bytes (regexp, token_len); /* Skip '-'. */
+ token_len2 = peek_token_bracket (&token2, regexp, syntax);
+ if (BE (token2.type == END_OF_RE, 0))
+ {
+ *err = REG_EBRACK;
+ goto parse_bracket_exp_free_return;
+ }
+ if (token2.type == OP_CLOSE_BRACKET)
+ {
+ /* We treat the last '-' as a normal character. */
+ re_string_skip_bytes (regexp, -token_len);
+ token->type = CHARACTER;
+ }
+ else
+ is_range_exp = 1;
+ }
+ }
+
+ if (is_range_exp == 1)
+ {
+ end_elem.opr.name = end_name_buf;
+ ret = parse_bracket_element (&end_elem, regexp, &token2, token_len2,
+ dfa, syntax, 1);
+ if (BE (ret != REG_NOERROR, 0))
+ {
+ *err = ret;
+ goto parse_bracket_exp_free_return;
+ }
+
+ token_len = peek_token_bracket (token, regexp, syntax);
+
+#ifdef _LIBC
+ *err = build_range_exp (sbcset, mbcset, &range_alloc,
+ &start_elem, &end_elem);
+#else
+# ifdef RE_ENABLE_I18N
+ *err = build_range_exp (sbcset,
+ dfa->mb_cur_max > 1 ? mbcset : NULL,
+ &range_alloc, &start_elem, &end_elem);
+# else
+ *err = build_range_exp (sbcset, &start_elem, &end_elem);
+# endif
+#endif /* RE_ENABLE_I18N */
+ if (BE (*err != REG_NOERROR, 0))
+ goto parse_bracket_exp_free_return;
+ }
+ else
+ {
+ switch (start_elem.type)
+ {
+ case SB_CHAR:
+ bitset_set (sbcset, start_elem.opr.ch);
+ break;
+#ifdef RE_ENABLE_I18N
+ case MB_CHAR:
+ /* Check whether the array has enough space. */
+ if (BE (mbchar_alloc == mbcset->nmbchars, 0))
+ {
+ wchar_t *new_mbchars;
+ /* Not enough, realloc it. */
+ /* +1 in case of mbcset->nmbchars is 0. */
+ mbchar_alloc = 2 * mbcset->nmbchars + 1;
+ /* Use realloc since array is NULL if *alloc == 0. */
+ new_mbchars = re_realloc (mbcset->mbchars, wchar_t,
+ mbchar_alloc);
+ if (BE (new_mbchars == NULL, 0))
+ goto parse_bracket_exp_espace;
+ mbcset->mbchars = new_mbchars;
+ }
+ mbcset->mbchars[mbcset->nmbchars++] = start_elem.opr.wch;
+ break;
+#endif /* RE_ENABLE_I18N */
+ case EQUIV_CLASS:
+ *err = build_equiv_class (sbcset,
+#ifdef RE_ENABLE_I18N
+ mbcset, &equiv_class_alloc,
+#endif /* RE_ENABLE_I18N */
+ start_elem.opr.name);
+ if (BE (*err != REG_NOERROR, 0))
+ goto parse_bracket_exp_free_return;
+ break;
+ case COLL_SYM:
+ *err = build_collating_symbol (sbcset,
+#ifdef RE_ENABLE_I18N
+ mbcset, &coll_sym_alloc,
+#endif /* RE_ENABLE_I18N */
+ start_elem.opr.name);
+ if (BE (*err != REG_NOERROR, 0))
+ goto parse_bracket_exp_free_return;
+ break;
+ case CHAR_CLASS:
+ *err = build_charclass (regexp->trans, sbcset,
+#ifdef RE_ENABLE_I18N
+ mbcset, &char_class_alloc,
+#endif /* RE_ENABLE_I18N */
+ start_elem.opr.name, syntax);
+ if (BE (*err != REG_NOERROR, 0))
+ goto parse_bracket_exp_free_return;
+ break;
+ default:
+ assert (0);
+ break;
+ }
+ }
+ if (BE (token->type == END_OF_RE, 0))
+ {
+ *err = REG_EBRACK;
+ goto parse_bracket_exp_free_return;
+ }
+ if (token->type == OP_CLOSE_BRACKET)
+ break;
+ }
+
+ re_string_skip_bytes (regexp, token_len); /* Skip a token. */
+
+ /* If it is non-matching list. */
+ if (non_match)
+ bitset_not (sbcset);
+
+#ifdef RE_ENABLE_I18N
+ /* Ensure only single byte characters are set. */
+ if (dfa->mb_cur_max > 1)
+ bitset_mask (sbcset, dfa->sb_char);
+
+ if (mbcset->nmbchars || mbcset->ncoll_syms || mbcset->nequiv_classes
+ || mbcset->nranges || (dfa->mb_cur_max > 1 && (mbcset->nchar_classes
+ || mbcset->non_match)))
+ {
+ bin_tree_t *mbc_tree;
+ int sbc_idx;
+ /* Build a tree for complex bracket. */
+ dfa->has_mb_node = 1;
+ br_token.type = COMPLEX_BRACKET;
+ br_token.opr.mbcset = mbcset;
+ mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token);
+ if (BE (mbc_tree == NULL, 0))
+ goto parse_bracket_exp_espace;
+ for (sbc_idx = 0; sbc_idx < BITSET_WORDS; ++sbc_idx)
+ if (sbcset[sbc_idx])
+ break;
+ /* If there are no bits set in sbcset, there is no point
+ of having both SIMPLE_BRACKET and COMPLEX_BRACKET. */
+ if (sbc_idx < BITSET_WORDS)
+ {
+ /* Build a tree for simple bracket. */
+ br_token.type = SIMPLE_BRACKET;
+ br_token.opr.sbcset = sbcset;
+ work_tree = create_token_tree (dfa, NULL, NULL, &br_token);
+ if (BE (work_tree == NULL, 0))
+ goto parse_bracket_exp_espace;
+
+ /* Then join them by ALT node. */
+ work_tree = create_tree (dfa, work_tree, mbc_tree, OP_ALT);
+ if (BE (work_tree == NULL, 0))
+ goto parse_bracket_exp_espace;
+ }
+ else
+ {
+ re_free (sbcset);
+ work_tree = mbc_tree;
+ }
+ }
+ else
+#endif /* not RE_ENABLE_I18N */
+ {
+#ifdef RE_ENABLE_I18N
+ free_charset (mbcset);
+#endif
+ /* Build a tree for simple bracket. */
+ br_token.type = SIMPLE_BRACKET;
+ br_token.opr.sbcset = sbcset;
+ work_tree = create_token_tree (dfa, NULL, NULL, &br_token);
+ if (BE (work_tree == NULL, 0))
+ goto parse_bracket_exp_espace;
+ }
+ return work_tree;
+
+ parse_bracket_exp_espace:
+ *err = REG_ESPACE;
+ parse_bracket_exp_free_return:
+ re_free (sbcset);
+#ifdef RE_ENABLE_I18N
+ free_charset (mbcset);
+#endif /* RE_ENABLE_I18N */
+ return NULL;
+}
+
+/* Parse an element in the bracket expression. */
+
+static reg_errcode_t
+parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp,
+ re_token_t *token, int token_len, re_dfa_t *dfa,
+ reg_syntax_t syntax, int accept_hyphen)
+{
+#ifdef RE_ENABLE_I18N
+ int cur_char_size;
+ cur_char_size = re_string_char_size_at (regexp, re_string_cur_idx (regexp));
+ if (cur_char_size > 1)
+ {
+ elem->type = MB_CHAR;
+ elem->opr.wch = re_string_wchar_at (regexp, re_string_cur_idx (regexp));
+ re_string_skip_bytes (regexp, cur_char_size);
+ return REG_NOERROR;
+ }
+#endif /* RE_ENABLE_I18N */
+ re_string_skip_bytes (regexp, token_len); /* Skip a token. */
+ if (token->type == OP_OPEN_COLL_ELEM || token->type == OP_OPEN_CHAR_CLASS
+ || token->type == OP_OPEN_EQUIV_CLASS)
+ return parse_bracket_symbol (elem, regexp, token);
+ if (BE (token->type == OP_CHARSET_RANGE, 0) && !accept_hyphen)
+ {
+ /* A '-' must only appear as anything but a range indicator before
+ the closing bracket. Everything else is an error. */
+ re_token_t token2;
+ (void) peek_token_bracket (&token2, regexp, syntax);
+ if (token2.type != OP_CLOSE_BRACKET)
+ /* The actual error value is not standardized since this whole
+ case is undefined. But ERANGE makes good sense. */
+ return REG_ERANGE;
+ }
+ elem->type = SB_CHAR;
+ elem->opr.ch = token->opr.c;
+ return REG_NOERROR;
+}
+
+/* Parse a bracket symbol in the bracket expression. Bracket symbols are
+ such as [:<character_class>:], [.<collating_element>.], and
+ [=<equivalent_class>=]. */
+
+static reg_errcode_t
+parse_bracket_symbol (bracket_elem_t *elem, re_string_t *regexp,
+ re_token_t *token)
+{
+ unsigned char ch, delim = token->opr.c;
+ int i = 0;
+ if (re_string_eoi(regexp))
+ return REG_EBRACK;
+ for (;; ++i)
+ {
+ if (i >= BRACKET_NAME_BUF_SIZE)
+ return REG_EBRACK;
+ if (token->type == OP_OPEN_CHAR_CLASS)
+ ch = re_string_fetch_byte_case (regexp);
+ else
+ ch = re_string_fetch_byte (regexp);
+ if (re_string_eoi(regexp))
+ return REG_EBRACK;
+ if (ch == delim && re_string_peek_byte (regexp, 0) == ']')
+ break;
+ elem->opr.name[i] = ch;
+ }
+ re_string_skip_bytes (regexp, 1);
+ elem->opr.name[i] = '\0';
+ switch (token->type)
+ {
+ case OP_OPEN_COLL_ELEM:
+ elem->type = COLL_SYM;
+ break;
+ case OP_OPEN_EQUIV_CLASS:
+ elem->type = EQUIV_CLASS;
+ break;
+ case OP_OPEN_CHAR_CLASS:
+ elem->type = CHAR_CLASS;
+ break;
+ default:
+ break;
+ }
+ return REG_NOERROR;
+}
+
+ /* Helper function for parse_bracket_exp.
+ Build the equivalence class which is represented by NAME.
+ The result are written to MBCSET and SBCSET.
+ EQUIV_CLASS_ALLOC is the allocated size of mbcset->equiv_classes,
+ is a pointer argument sinse we may update it. */
+
+static reg_errcode_t
+#ifdef RE_ENABLE_I18N
+build_equiv_class (bitset_t sbcset, re_charset_t *mbcset,
+ int *equiv_class_alloc, const unsigned char *name)
+#else /* not RE_ENABLE_I18N */
+build_equiv_class (bitset_t sbcset, const unsigned char *name)
+#endif /* not RE_ENABLE_I18N */
+{
+#ifdef _LIBC
+ uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
+ if (nrules != 0)
+ {
+ const int32_t *table, *indirect;
+ const unsigned char *weights, *extra, *cp;
+ unsigned char char_buf[2];
+ int32_t idx1, idx2;
+ unsigned int ch;
+ size_t len;
+ /* This #include defines a local function! */
+# include <locale/weight.h>
+ /* Calculate the index for equivalence class. */
+ cp = name;
+ table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
+ weights = (const unsigned char *) _NL_CURRENT (LC_COLLATE,
+ _NL_COLLATE_WEIGHTMB);
+ extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE,
+ _NL_COLLATE_EXTRAMB);
+ indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE,
+ _NL_COLLATE_INDIRECTMB);
+ idx1 = findidx (&cp);
+ if (BE (idx1 == 0 || cp < name + strlen ((const char *) name), 0))
+ /* This isn't a valid character. */
+ return REG_ECOLLATE;
+
+ /* Build single byte matcing table for this equivalence class. */
+ char_buf[1] = (unsigned char) '\0';
+ len = weights[idx1];
+ for (ch = 0; ch < SBC_MAX; ++ch)
+ {
+ char_buf[0] = ch;
+ cp = char_buf;
+ idx2 = findidx (&cp);
+/*
+ idx2 = table[ch];
+*/
+ if (idx2 == 0)
+ /* This isn't a valid character. */
+ continue;
+ if (len == weights[idx2])
+ {
+ int cnt = 0;
+ while (cnt <= len &&
+ weights[idx1 + 1 + cnt] == weights[idx2 + 1 + cnt])
+ ++cnt;
+
+ if (cnt > len)
+ bitset_set (sbcset, ch);
+ }
+ }
+ /* Check whether the array has enough space. */
+ if (BE (*equiv_class_alloc == mbcset->nequiv_classes, 0))
+ {
+ /* Not enough, realloc it. */
+ /* +1 in case of mbcset->nequiv_classes is 0. */
+ int new_equiv_class_alloc = 2 * mbcset->nequiv_classes + 1;
+ /* Use realloc since the array is NULL if *alloc == 0. */
+ int32_t *new_equiv_classes = re_realloc (mbcset->equiv_classes,
+ int32_t,
+ new_equiv_class_alloc);
+ if (BE (new_equiv_classes == NULL, 0))
+ return REG_ESPACE;
+ mbcset->equiv_classes = new_equiv_classes;
+ *equiv_class_alloc = new_equiv_class_alloc;
+ }
+ mbcset->equiv_classes[mbcset->nequiv_classes++] = idx1;
+ }
+ else
+#endif /* _LIBC */
+ {
+ if (BE (strlen ((const char *) name) != 1, 0))
+ return REG_ECOLLATE;
+ bitset_set (sbcset, *name);
+ }
+ return REG_NOERROR;
+}
+
+ /* Helper function for parse_bracket_exp.
+ Build the character class which is represented by NAME.
+ The result are written to MBCSET and SBCSET.
+ CHAR_CLASS_ALLOC is the allocated size of mbcset->char_classes,
+ is a pointer argument sinse we may update it. */
+
+static reg_errcode_t
+#ifdef RE_ENABLE_I18N
+build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
+ re_charset_t *mbcset, int *char_class_alloc,
+ const unsigned char *class_name, reg_syntax_t syntax)
+#else /* not RE_ENABLE_I18N */
+build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
+ const unsigned char *class_name, reg_syntax_t syntax)
+#endif /* not RE_ENABLE_I18N */
+{
+ int i;
+ const char *name = (const char *) class_name;
+
+ /* In case of REG_ICASE "upper" and "lower" match the both of
+ upper and lower cases. */
+ if ((syntax & RE_ICASE)
+ && (strcmp (name, "upper") == 0 || strcmp (name, "lower") == 0))
+ name = "alpha";
+
+#ifdef RE_ENABLE_I18N
+ /* Check the space of the arrays. */
+ if (BE (*char_class_alloc == mbcset->nchar_classes, 0))
+ {
+ /* Not enough, realloc it. */
+ /* +1 in case of mbcset->nchar_classes is 0. */
+ int new_char_class_alloc = 2 * mbcset->nchar_classes + 1;
+ /* Use realloc since array is NULL if *alloc == 0. */
+ wctype_t *new_char_classes = re_realloc (mbcset->char_classes, wctype_t,
+ new_char_class_alloc);
+ if (BE (new_char_classes == NULL, 0))
+ return REG_ESPACE;
+ mbcset->char_classes = new_char_classes;
+ *char_class_alloc = new_char_class_alloc;
+ }
+ mbcset->char_classes[mbcset->nchar_classes++] = __wctype (name);
+#endif /* RE_ENABLE_I18N */
+
+#define BUILD_CHARCLASS_LOOP(ctype_func) \
+ do { \
+ if (BE (trans != NULL, 0)) \
+ { \
+ for (i = 0; i < SBC_MAX; ++i) \
+ if (ctype_func (i)) \
+ bitset_set (sbcset, trans[i]); \
+ } \
+ else \
+ { \
+ for (i = 0; i < SBC_MAX; ++i) \
+ if (ctype_func (i)) \
+ bitset_set (sbcset, i); \
+ } \
+ } while (0)
+
+ if (strcmp (name, "alnum") == 0)
+ BUILD_CHARCLASS_LOOP (isalnum);
+ else if (strcmp (name, "cntrl") == 0)
+ BUILD_CHARCLASS_LOOP (iscntrl);
+ else if (strcmp (name, "lower") == 0)
+ BUILD_CHARCLASS_LOOP (islower);
+ else if (strcmp (name, "space") == 0)
+ BUILD_CHARCLASS_LOOP (isspace);
+ else if (strcmp (name, "alpha") == 0)
+ BUILD_CHARCLASS_LOOP (isalpha);
+ else if (strcmp (name, "digit") == 0)
+ BUILD_CHARCLASS_LOOP (isdigit);
+ else if (strcmp (name, "print") == 0)
+ BUILD_CHARCLASS_LOOP (isprint);
+ else if (strcmp (name, "upper") == 0)
+ BUILD_CHARCLASS_LOOP (isupper);
+ else if (strcmp (name, "blank") == 0)
+ BUILD_CHARCLASS_LOOP (isblank);
+ else if (strcmp (name, "graph") == 0)
+ BUILD_CHARCLASS_LOOP (isgraph);
+ else if (strcmp (name, "punct") == 0)
+ BUILD_CHARCLASS_LOOP (ispunct);
+ else if (strcmp (name, "xdigit") == 0)
+ BUILD_CHARCLASS_LOOP (isxdigit);
+ else
+ return REG_ECTYPE;
+
+ return REG_NOERROR;
+}
+
+static bin_tree_t *
+build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
+ const unsigned char *class_name,
+ const unsigned char *extra, int non_match,
+ reg_errcode_t *err)
+{
+ re_bitset_ptr_t sbcset;
+#ifdef RE_ENABLE_I18N
+ re_charset_t *mbcset;
+ int alloc = 0;
+#endif /* not RE_ENABLE_I18N */
+ reg_errcode_t ret;
+ re_token_t br_token;
+ bin_tree_t *tree;
+
+ sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
+#ifdef RE_ENABLE_I18N
+ mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
+#endif /* RE_ENABLE_I18N */
+
+#ifdef RE_ENABLE_I18N
+ if (BE (sbcset == NULL || mbcset == NULL, 0))
+#else /* not RE_ENABLE_I18N */
+ if (BE (sbcset == NULL, 0))
+#endif /* not RE_ENABLE_I18N */
+ {
+ *err = REG_ESPACE;
+ return NULL;
+ }
+
+ if (non_match)
+ {
+#ifdef RE_ENABLE_I18N
+ /*
+ if (syntax & RE_HAT_LISTS_NOT_NEWLINE)
+ bitset_set(cset->sbcset, '\0');
+ */
+ mbcset->non_match = 1;
+#endif /* not RE_ENABLE_I18N */
+ }
+
+ /* We don't care the syntax in this case. */
+ ret = build_charclass (trans, sbcset,
+#ifdef RE_ENABLE_I18N
+ mbcset, &alloc,
+#endif /* RE_ENABLE_I18N */
+ class_name, 0);
+
+ if (BE (ret != REG_NOERROR, 0))
+ {
+ re_free (sbcset);
+#ifdef RE_ENABLE_I18N
+ free_charset (mbcset);
+#endif /* RE_ENABLE_I18N */
+ *err = ret;
+ return NULL;
+ }
+ /* \w match '_' also. */
+ for (; *extra; extra++)
+ bitset_set (sbcset, *extra);
+
+ /* If it is non-matching list. */
+ if (non_match)
+ bitset_not (sbcset);
+
+#ifdef RE_ENABLE_I18N
+ /* Ensure only single byte characters are set. */
+ if (dfa->mb_cur_max > 1)
+ bitset_mask (sbcset, dfa->sb_char);
+#endif
+
+ /* Build a tree for simple bracket. */
+ br_token.type = SIMPLE_BRACKET;
+ br_token.opr.sbcset = sbcset;
+ tree = create_token_tree (dfa, NULL, NULL, &br_token);
+ if (BE (tree == NULL, 0))
+ goto build_word_op_espace;
+
+#ifdef RE_ENABLE_I18N
+ if (dfa->mb_cur_max > 1)
+ {
+ bin_tree_t *mbc_tree;
+ /* Build a tree for complex bracket. */
+ br_token.type = COMPLEX_BRACKET;
+ br_token.opr.mbcset = mbcset;
+ dfa->has_mb_node = 1;
+ mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token);
+ if (BE (mbc_tree == NULL, 0))
+ goto build_word_op_espace;
+ /* Then join them by ALT node. */
+ tree = create_tree (dfa, tree, mbc_tree, OP_ALT);
+ if (BE (mbc_tree != NULL, 1))
+ return tree;
+ }
+ else
+ {
+ free_charset (mbcset);
+ return tree;
+ }
+#else /* not RE_ENABLE_I18N */
+ return tree;
+#endif /* not RE_ENABLE_I18N */
+
+ build_word_op_espace:
+ re_free (sbcset);
+#ifdef RE_ENABLE_I18N
+ free_charset (mbcset);
+#endif /* RE_ENABLE_I18N */
+ *err = REG_ESPACE;
+ return NULL;
+}
+
+/* This is intended for the expressions like "a{1,3}".
+ Fetch a number from `input', and return the number.
+ Return -1, if the number field is empty like "{,1}".
+ Return -2, If an error is occured. */
+
+static int
+fetch_number (re_string_t *input, re_token_t *token, reg_syntax_t syntax)
+{
+ int num = -1;
+ unsigned char c;
+ while (1)
+ {
+ fetch_token (token, input, syntax);
+ c = token->opr.c;
+ if (BE (token->type == END_OF_RE, 0))
+ return -2;
+ if (token->type == OP_CLOSE_DUP_NUM || c == ',')
+ break;
+ num = ((token->type != CHARACTER || c < '0' || '9' < c || num == -2)
+ ? -2 : ((num == -1) ? c - '0' : num * 10 + c - '0'));
+ num = (num > RE_DUP_MAX) ? -2 : num;
+ }
+ return num;
+}
+
+#ifdef RE_ENABLE_I18N
+static void
+free_charset (re_charset_t *cset)
+{
+ re_free (cset->mbchars);
+# ifdef _LIBC
+ re_free (cset->coll_syms);
+ re_free (cset->equiv_classes);
+ re_free (cset->range_starts);
+ re_free (cset->range_ends);
+# endif
+ re_free (cset->char_classes);
+ re_free (cset);
+}
+#endif /* RE_ENABLE_I18N */
+
+/* Functions for binary tree operation. */
+
+/* Create a tree node. */
+
+static bin_tree_t *
+create_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
+ re_token_type_t type)
+{
+ re_token_t t;
+ t.type = type;
+ return create_token_tree (dfa, left, right, &t);
+}
+
+static bin_tree_t *
+create_token_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
+ const re_token_t *token)
+{
+ bin_tree_t *tree;
+ if (BE (dfa->str_tree_storage_idx == BIN_TREE_STORAGE_SIZE, 0))
+ {
+ bin_tree_storage_t *storage = re_malloc (bin_tree_storage_t, 1);
+
+ if (storage == NULL)
+ return NULL;
+ storage->next = dfa->str_tree_storage;
+ dfa->str_tree_storage = storage;
+ dfa->str_tree_storage_idx = 0;
+ }
+ tree = &dfa->str_tree_storage->data[dfa->str_tree_storage_idx++];
+
+ tree->parent = NULL;
+ tree->left = left;
+ tree->right = right;
+ tree->token = *token;
+ tree->token.duplicated = 0;
+ tree->token.opt_subexp = 0;
+ tree->first = NULL;
+ tree->next = NULL;
+ tree->node_idx = -1;
+
+ if (left != NULL)
+ left->parent = tree;
+ if (right != NULL)
+ right->parent = tree;
+ return tree;
+}
+
+/* Mark the tree SRC as an optional subexpression.
+ To be called from preorder or postorder. */
+
+static reg_errcode_t
+mark_opt_subexp (void *extra, bin_tree_t *node)
+{
+ int idx = (int) (long) extra;
+ if (node->token.type == SUBEXP && node->token.opr.idx == idx)
+ node->token.opt_subexp = 1;
+
+ return REG_NOERROR;
+}
+
+/* Free the allocated memory inside NODE. */
+
+static void
+free_token (re_token_t *node)
+{
+#ifdef RE_ENABLE_I18N
+ if (node->type == COMPLEX_BRACKET && node->duplicated == 0)
+ free_charset (node->opr.mbcset);
+ else
+#endif /* RE_ENABLE_I18N */
+ if (node->type == SIMPLE_BRACKET && node->duplicated == 0)
+ re_free (node->opr.sbcset);
+}
+
+/* Worker function for tree walking. Free the allocated memory inside NODE
+ and its children. */
+
+static reg_errcode_t
+free_tree (void *extra, bin_tree_t *node)
+{
+ free_token (&node->token);
+ return REG_NOERROR;
+}
+
+
+/* Duplicate the node SRC, and return new node. This is a preorder
+ visit similar to the one implemented by the generic visitor, but
+ we need more infrastructure to maintain two parallel trees --- so,
+ it's easier to duplicate. */
+
+static bin_tree_t *
+duplicate_tree (const bin_tree_t *root, re_dfa_t *dfa)
+{
+ const bin_tree_t *node;
+ bin_tree_t *dup_root;
+ bin_tree_t **p_new = &dup_root, *dup_node = root->parent;
+
+ for (node = root; ; )
+ {
+ /* Create a new tree and link it back to the current parent. */
+ *p_new = create_token_tree (dfa, NULL, NULL, &node->token);
+ if (*p_new == NULL)
+ return NULL;
+ (*p_new)->parent = dup_node;
+ (*p_new)->token.duplicated = 1;
+ dup_node = *p_new;
+
+ /* Go to the left node, or up and to the right. */
+ if (node->left)
+ {
+ node = node->left;
+ p_new = &dup_node->left;
+ }
+ else
+ {
+ const bin_tree_t *prev = NULL;
+ while (node->right == prev || node->right == NULL)
+ {
+ prev = node;
+ node = node->parent;
+ dup_node = dup_node->parent;
+ if (!node)
+ return dup_root;
+ }
+ node = node->right;
+ p_new = &dup_node->right;
+ }
+ }
+}
diff --git a/node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/regex.c b/node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/regex.c
new file mode 100644
index 0000000..d2d4f28
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/regex.c
@@ -0,0 +1,74 @@
+/* Extended regular expression matching and search library.
+ Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+/* Make sure noone compiles this code with a C++ compiler. */
+#ifdef __cplusplus
+# error "This is C code, use a C compiler"
+#endif
+
+#ifdef _LIBC
+/* We have to keep the namespace clean. */
+# define regfree(preg) __regfree (preg)
+# define regexec(pr, st, nm, pm, ef) __regexec (pr, st, nm, pm, ef)
+# define regcomp(preg, pattern, cflags) __regcomp (preg, pattern, cflags)
+# define regerror(errcode, preg, errbuf, errbuf_size) \
+ __regerror(errcode, preg, errbuf, errbuf_size)
+# define re_set_registers(bu, re, nu, st, en) \
+ __re_set_registers (bu, re, nu, st, en)
+# define re_match_2(bufp, string1, size1, string2, size2, pos, regs, stop) \
+ __re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
+# define re_match(bufp, string, size, pos, regs) \
+ __re_match (bufp, string, size, pos, regs)
+# define re_search(bufp, string, size, startpos, range, regs) \
+ __re_search (bufp, string, size, startpos, range, regs)
+# define re_compile_pattern(pattern, length, bufp) \
+ __re_compile_pattern (pattern, length, bufp)
+# define re_set_syntax(syntax) __re_set_syntax (syntax)
+# define re_search_2(bufp, st1, s1, st2, s2, startpos, range, regs, stop) \
+ __re_search_2 (bufp, st1, s1, st2, s2, startpos, range, regs, stop)
+# define re_compile_fastmap(bufp) __re_compile_fastmap (bufp)
+
+# include "../locale/localeinfo.h"
+#endif
+
+/* On some systems, limits.h sets RE_DUP_MAX to a lower value than
+ GNU regex allows. Include it before <regex.h>, which correctly
+ #undefs RE_DUP_MAX and sets it to the right value. */
+#include <limits.h>
+
+#include <regex.h>
+#include "regex_internal.h"
+
+#include "regex_internal.c"
+#include "regcomp.c"
+#include "regexec.c"
+
+/* Binary backward compatibility. */
+#if _LIBC
+# include <shlib-compat.h>
+# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3)
+link_warning (re_max_failures, "the 're_max_failures' variable is obsolete and will go away.")
+int re_max_failures = 2000;
+# endif
+#endif
diff --git a/node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/regex.h b/node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/regex.h
new file mode 100644
index 0000000..807c404
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/regex.h
@@ -0,0 +1,556 @@
+/* Definitions for data structures and routines for the regular
+ expression library.
+ Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003,2005,2006
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _REGEX_H
+#define _REGEX_H 1
+
+#include <sys/types.h>
+
+/* Allow the use in C++ code. */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* The following two types have to be signed and unsigned integer type
+ wide enough to hold a value of a pointer. For most ANSI compilers
+ ptrdiff_t and size_t should be likely OK. Still size of these two
+ types is 2 for Microsoft C. Ugh... */
+typedef long int s_reg_t;
+typedef unsigned long int active_reg_t;
+
+/* The following bits are used to determine the regexp syntax we
+ recognize. The set/not-set meanings are chosen so that Emacs syntax
+ remains the value 0. The bits are given in alphabetical order, and
+ the definitions shifted by one from the previous bit; thus, when we
+ add or remove a bit, only one other definition need change. */
+typedef unsigned long int reg_syntax_t;
+
+/* If this bit is not set, then \ inside a bracket expression is literal.
+ If set, then such a \ quotes the following character. */
+#define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1)
+
+/* If this bit is not set, then + and ? are operators, and \+ and \? are
+ literals.
+ If set, then \+ and \? are operators and + and ? are literals. */
+#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
+
+/* If this bit is set, then character classes are supported. They are:
+ [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:],
+ [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
+ If not set, then character classes are not supported. */
+#define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1)
+
+/* If this bit is set, then ^ and $ are always anchors (outside bracket
+ expressions, of course).
+ If this bit is not set, then it depends:
+ ^ is an anchor if it is at the beginning of a regular
+ expression or after an open-group or an alternation operator;
+ $ is an anchor if it is at the end of a regular expression, or
+ before a close-group or an alternation operator.
+
+ This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because
+ POSIX draft 11.2 says that * etc. in leading positions is undefined.
+ We already implemented a previous draft which made those constructs
+ invalid, though, so we haven't changed the code back. */
+#define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1)
+
+/* If this bit is set, then special characters are always special
+ regardless of where they are in the pattern.
+ If this bit is not set, then special characters are special only in
+ some contexts; otherwise they are ordinary. Specifically,
+ * + ? and intervals are only special when not after the beginning,
+ open-group, or alternation operator. */
+#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
+
+/* If this bit is set, then *, +, ?, and { cannot be first in an re or
+ immediately after an alternation or begin-group operator. */
+#define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1)
+
+/* If this bit is set, then . matches newline.
+ If not set, then it doesn't. */
+#define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1)
+
+/* If this bit is set, then . doesn't match NUL.
+ If not set, then it does. */
+#define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1)
+
+/* If this bit is set, nonmatching lists [^...] do not match newline.
+ If not set, they do. */
+#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
+
+/* If this bit is set, either \{...\} or {...} defines an
+ interval, depending on RE_NO_BK_BRACES.
+ If not set, \{, \}, {, and } are literals. */
+#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
+
+/* If this bit is set, +, ? and | aren't recognized as operators.
+ If not set, they are. */
+#define RE_LIMITED_OPS (RE_INTERVALS << 1)
+
+/* If this bit is set, newline is an alternation operator.
+ If not set, newline is literal. */
+#define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1)
+
+/* If this bit is set, then `{...}' defines an interval, and \{ and \}
+ are literals.
+ If not set, then `\{...\}' defines an interval. */
+#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)
+
+/* If this bit is set, (...) defines a group, and \( and \) are literals.
+ If not set, \(...\) defines a group, and ( and ) are literals. */
+#define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1)
+
+/* If this bit is set, then \<digit> matches <digit>.
+ If not set, then \<digit> is a back-reference. */
+#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
+
+/* If this bit is set, then | is an alternation operator, and \| is literal.
+ If not set, then \| is an alternation operator, and | is literal. */
+#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
+
+/* If this bit is set, then an ending range point collating higher
+ than the starting range point, as in [z-a], is invalid.
+ If not set, then when ending range point collates higher than the
+ starting range point, the range is ignored. */
+#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1)
+
+/* If this bit is set, then an unmatched ) is ordinary.
+ If not set, then an unmatched ) is invalid. */
+#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1)
+
+/* If this bit is set, succeed as soon as we match the whole pattern,
+ without further backtracking. */
+#define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1)
+
+/* If this bit is set, do not process the GNU regex operators.
+ If not set, then the GNU regex operators are recognized. */
+#define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1)
+
+/* If this bit is set, turn on internal regex debugging.
+ If not set, and debugging was on, turn it off.
+ This only works if regex.c is compiled -DDEBUG.
+ We define this bit always, so that all that's needed to turn on
+ debugging is to recompile regex.c; the calling code can always have
+ this bit set, and it won't affect anything in the normal case. */
+#define RE_DEBUG (RE_NO_GNU_OPS << 1)
+
+/* If this bit is set, a syntactically invalid interval is treated as
+ a string of ordinary characters. For example, the ERE 'a{1' is
+ treated as 'a\{1'. */
+#define RE_INVALID_INTERVAL_ORD (RE_DEBUG << 1)
+
+/* If this bit is set, then ignore case when matching.
+ If not set, then case is significant. */
+#define RE_ICASE (RE_INVALID_INTERVAL_ORD << 1)
+
+/* This bit is used internally like RE_CONTEXT_INDEP_ANCHORS but only
+ for ^, because it is difficult to scan the regex backwards to find
+ whether ^ should be special. */
+#define RE_CARET_ANCHORS_HERE (RE_ICASE << 1)
+
+/* If this bit is set, then \{ cannot be first in an bre or
+ immediately after an alternation or begin-group operator. */
+#define RE_CONTEXT_INVALID_DUP (RE_CARET_ANCHORS_HERE << 1)
+
+/* If this bit is set, then no_sub will be set to 1 during
+ re_compile_pattern. */
+#define RE_NO_SUB (RE_CONTEXT_INVALID_DUP << 1)
+
+/* This global variable defines the particular regexp syntax to use (for
+ some interfaces). When a regexp is compiled, the syntax used is
+ stored in the pattern buffer, so changing this does not affect
+ already-compiled regexps. */
+extern reg_syntax_t re_syntax_options;
+
+/* Define combinations of the above bits for the standard possibilities.
+ (The [[[ comments delimit what gets put into the Texinfo file, so
+ don't delete them!) */
+/* [[[begin syntaxes]]] */
+#define RE_SYNTAX_EMACS 0
+
+#define RE_SYNTAX_AWK \
+ (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \
+ | RE_NO_BK_PARENS | RE_NO_BK_REFS \
+ | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \
+ | RE_DOT_NEWLINE | RE_CONTEXT_INDEP_ANCHORS \
+ | RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS)
+
+#define RE_SYNTAX_GNU_AWK \
+ ((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DEBUG) \
+ & ~(RE_DOT_NOT_NULL | RE_INTERVALS | RE_CONTEXT_INDEP_OPS \
+ | RE_CONTEXT_INVALID_OPS ))
+
+#define RE_SYNTAX_POSIX_AWK \
+ (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \
+ | RE_INTERVALS | RE_NO_GNU_OPS)
+
+#define RE_SYNTAX_GREP \
+ (RE_BK_PLUS_QM | RE_CHAR_CLASSES \
+ | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \
+ | RE_NEWLINE_ALT)
+
+#define RE_SYNTAX_EGREP \
+ (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \
+ | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \
+ | RE_NEWLINE_ALT | RE_NO_BK_PARENS \
+ | RE_NO_BK_VBAR)
+
+#define RE_SYNTAX_POSIX_EGREP \
+ (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES \
+ | RE_INVALID_INTERVAL_ORD)
+
+/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */
+#define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC
+
+#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC
+
+/* Syntax bits common to both basic and extended POSIX regex syntax. */
+#define _RE_SYNTAX_POSIX_COMMON \
+ (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \
+ | RE_INTERVALS | RE_NO_EMPTY_RANGES)
+
+#define RE_SYNTAX_POSIX_BASIC \
+ (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM | RE_CONTEXT_INVALID_DUP)
+
+/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes
+ RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this
+ isn't minimal, since other operators, such as \`, aren't disabled. */
+#define RE_SYNTAX_POSIX_MINIMAL_BASIC \
+ (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS)
+
+#define RE_SYNTAX_POSIX_EXTENDED \
+ (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
+ | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \
+ | RE_NO_BK_PARENS | RE_NO_BK_VBAR \
+ | RE_CONTEXT_INVALID_OPS | RE_UNMATCHED_RIGHT_PAREN_ORD)
+
+/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INDEP_OPS is
+ removed and RE_NO_BK_REFS is added. */
+#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \
+ (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
+ | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \
+ | RE_NO_BK_PARENS | RE_NO_BK_REFS \
+ | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD)
+/* [[[end syntaxes]]] */
+
+/* Maximum number of duplicates an interval can allow. Some systems
+ (erroneously) define this in other header files, but we want our
+ value, so remove any previous define. */
+#ifdef RE_DUP_MAX
+# undef RE_DUP_MAX
+#endif
+/* If sizeof(int) == 2, then ((1 << 15) - 1) overflows. */
+#define RE_DUP_MAX (0x7fff)
+
+
+/* POSIX `cflags' bits (i.e., information for `regcomp'). */
+
+/* If this bit is set, then use extended regular expression syntax.
+ If not set, then use basic regular expression syntax. */
+#define REG_EXTENDED 1
+
+/* If this bit is set, then ignore case when matching.
+ If not set, then case is significant. */
+#define REG_ICASE (REG_EXTENDED << 1)
+
+/* If this bit is set, then anchors do not match at newline
+ characters in the string.
+ If not set, then anchors do match at newlines. */
+#define REG_NEWLINE (REG_ICASE << 1)
+
+/* If this bit is set, then report only success or fail in regexec.
+ If not set, then returns differ between not matching and errors. */
+#define REG_NOSUB (REG_NEWLINE << 1)
+
+
+/* POSIX `eflags' bits (i.e., information for regexec). */
+
+/* If this bit is set, then the beginning-of-line operator doesn't match
+ the beginning of the string (presumably because it's not the
+ beginning of a line).
+ If not set, then the beginning-of-line operator does match the
+ beginning of the string. */
+#define REG_NOTBOL 1
+
+/* Like REG_NOTBOL, except for the end-of-line. */
+#define REG_NOTEOL (1 << 1)
+
+/* Use PMATCH[0] to delimit the start and end of the search in the
+ buffer. */
+#define REG_STARTEND (1 << 2)
+
+
+/* If any error codes are removed, changed, or added, update the
+ `re_error_msg' table in regex.c. */
+typedef enum
+{
+#ifdef _XOPEN_SOURCE
+ REG_ENOSYS = -1, /* This will never happen for this implementation. */
+#endif
+
+ REG_NOERROR = 0, /* Success. */
+ REG_NOMATCH, /* Didn't find a match (for regexec). */
+
+ /* POSIX regcomp return error codes. (In the order listed in the
+ standard.) */
+ REG_BADPAT, /* Invalid pattern. */
+ REG_ECOLLATE, /* Inalid collating element. */
+ REG_ECTYPE, /* Invalid character class name. */
+ REG_EESCAPE, /* Trailing backslash. */
+ REG_ESUBREG, /* Invalid back reference. */
+ REG_EBRACK, /* Unmatched left bracket. */
+ REG_EPAREN, /* Parenthesis imbalance. */
+ REG_EBRACE, /* Unmatched \{. */
+ REG_BADBR, /* Invalid contents of \{\}. */
+ REG_ERANGE, /* Invalid range end. */
+ REG_ESPACE, /* Ran out of memory. */
+ REG_BADRPT, /* No preceding re for repetition op. */
+
+ /* Error codes we've added. */
+ REG_EEND, /* Premature end. */
+ REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */
+ REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */
+} reg_errcode_t;
+
+/* This data structure represents a compiled pattern. Before calling
+ the pattern compiler, the fields `buffer', `allocated', `fastmap',
+ `translate', and `no_sub' can be set. After the pattern has been
+ compiled, the `re_nsub' field is available. All other fields are
+ private to the regex routines. */
+
+#ifndef RE_TRANSLATE_TYPE
+# define RE_TRANSLATE_TYPE unsigned char *
+#endif
+
+struct re_pattern_buffer
+{
+ /* Space that holds the compiled pattern. It is declared as
+ `unsigned char *' because its elements are sometimes used as
+ array indexes. */
+ unsigned char *buffer;
+
+ /* Number of bytes to which `buffer' points. */
+ unsigned long int allocated;
+
+ /* Number of bytes actually used in `buffer'. */
+ unsigned long int used;
+
+ /* Syntax setting with which the pattern was compiled. */
+ reg_syntax_t syntax;
+
+ /* Pointer to a fastmap, if any, otherwise zero. re_search uses the
+ fastmap, if there is one, to skip over impossible starting points
+ for matches. */
+ char *fastmap;
+
+ /* Either a translate table to apply to all characters before
+ comparing them, or zero for no translation. The translation is
+ applied to a pattern when it is compiled and to a string when it
+ is matched. */
+ RE_TRANSLATE_TYPE translate;
+
+ /* Number of subexpressions found by the compiler. */
+ size_t re_nsub;
+
+ /* Zero if this pattern cannot match the empty string, one else.
+ Well, in truth it's used only in `re_search_2', to see whether or
+ not we should use the fastmap, so we don't set this absolutely
+ perfectly; see `re_compile_fastmap' (the `duplicate' case). */
+ unsigned can_be_null : 1;
+
+ /* If REGS_UNALLOCATED, allocate space in the `regs' structure
+ for `max (RE_NREGS, re_nsub + 1)' groups.
+ If REGS_REALLOCATE, reallocate space if necessary.
+ If REGS_FIXED, use what's there. */
+#define REGS_UNALLOCATED 0
+#define REGS_REALLOCATE 1
+#define REGS_FIXED 2
+ unsigned regs_allocated : 2;
+
+ /* Set to zero when `regex_compile' compiles a pattern; set to one
+ by `re_compile_fastmap' if it updates the fastmap. */
+ unsigned fastmap_accurate : 1;
+
+ /* If set, `re_match_2' does not return information about
+ subexpressions. */
+ unsigned no_sub : 1;
+
+ /* If set, a beginning-of-line anchor doesn't match at the beginning
+ of the string. */
+ unsigned not_bol : 1;
+
+ /* Similarly for an end-of-line anchor. */
+ unsigned not_eol : 1;
+
+ /* If true, an anchor at a newline matches. */
+ unsigned newline_anchor : 1;
+};
+
+typedef struct re_pattern_buffer regex_t;
+
+/* Type for byte offsets within the string. POSIX mandates this. */
+typedef int regoff_t;
+
+
+/* This is the structure we store register match data in. See
+ regex.texinfo for a full description of what registers match. */
+struct re_registers
+{
+ unsigned num_regs;
+ regoff_t *start;
+ regoff_t *end;
+};
+
+
+/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
+ `re_match_2' returns information about at least this many registers
+ the first time a `regs' structure is passed. */
+#ifndef RE_NREGS
+# define RE_NREGS 30
+#endif
+
+
+/* POSIX specification for registers. Aside from the different names than
+ `re_registers', POSIX uses an array of structures, instead of a
+ structure of arrays. */
+typedef struct
+{
+ regoff_t rm_so; /* Byte offset from string's start to substring's start. */
+ regoff_t rm_eo; /* Byte offset from string's start to substring's end. */
+} regmatch_t;
+
+/* Declarations for routines. */
+
+/* Sets the current default syntax to SYNTAX, and return the old syntax.
+ You can also simply assign to the `re_syntax_options' variable. */
+extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax);
+
+/* Compile the regular expression PATTERN, with length LENGTH
+ and syntax given by the global `re_syntax_options', into the buffer
+ BUFFER. Return NULL if successful, and an error string if not. */
+extern const char *re_compile_pattern (const char *__pattern, size_t __length,
+ struct re_pattern_buffer *__buffer);
+
+
+/* Compile a fastmap for the compiled pattern in BUFFER; used to
+ accelerate searches. Return 0 if successful and -2 if was an
+ internal error. */
+extern int re_compile_fastmap (struct re_pattern_buffer *__buffer);
+
+
+/* Search in the string STRING (with length LENGTH) for the pattern
+ compiled into BUFFER. Start searching at position START, for RANGE
+ characters. Return the starting position of the match, -1 for no
+ match, or -2 for an internal error. Also return register
+ information in REGS (if REGS and BUFFER->no_sub are nonzero). */
+extern int re_search (struct re_pattern_buffer *__buffer, const char *__string,
+ int __length, int __start, int __range,
+ struct re_registers *__regs);
+
+
+/* Like `re_search', but search in the concatenation of STRING1 and
+ STRING2. Also, stop searching at index START + STOP. */
+extern int re_search_2 (struct re_pattern_buffer *__buffer,
+ const char *__string1, int __length1,
+ const char *__string2, int __length2, int __start,
+ int __range, struct re_registers *__regs, int __stop);
+
+
+/* Like `re_search', but return how many characters in STRING the regexp
+ in BUFFER matched, starting at position START. */
+extern int re_match (struct re_pattern_buffer *__buffer, const char *__string,
+ int __length, int __start, struct re_registers *__regs);
+
+
+/* Relates to `re_match' as `re_search_2' relates to `re_search'. */
+extern int re_match_2 (struct re_pattern_buffer *__buffer,
+ const char *__string1, int __length1,
+ const char *__string2, int __length2, int __start,
+ struct re_registers *__regs, int __stop);
+
+
+/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
+ ENDS. Subsequent matches using BUFFER and REGS will use this memory
+ for recording register information. STARTS and ENDS must be
+ allocated with malloc, and must each be at least `NUM_REGS * sizeof
+ (regoff_t)' bytes long.
+
+ If NUM_REGS == 0, then subsequent matches should allocate their own
+ register data.
+
+ Unless this function is called, the first search or match using
+ PATTERN_BUFFER will allocate its own register data, without
+ freeing the old data. */
+extern void re_set_registers (struct re_pattern_buffer *__buffer,
+ struct re_registers *__regs,
+ unsigned int __num_regs,
+ regoff_t *__starts, regoff_t *__ends);
+
+#if defined _REGEX_RE_COMP || defined _LIBC
+# ifndef _CRAY
+/* 4.2 bsd compatibility. */
+extern char *re_comp (const char *);
+extern int re_exec (const char *);
+# endif
+#endif
+
+/* GCC 2.95 and later have "__restrict"; C99 compilers have
+ "restrict", and "configure" may have defined "restrict". */
+#ifndef __restrict
+# if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__))
+# if defined restrict || 199901L <= __STDC_VERSION__
+# define __restrict restrict
+# else
+# define __restrict
+# endif
+# endif
+#endif
+/* gcc 3.1 and up support the [restrict] syntax. */
+#ifndef __restrict_arr
+# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) \
+ && !defined __GNUG__
+# define __restrict_arr __restrict
+# else
+# define __restrict_arr
+# endif
+#endif
+
+/* POSIX compatibility. */
+extern int regcomp (regex_t *__restrict __preg,
+ const char *__restrict __pattern,
+ int __cflags);
+
+extern int regexec (const regex_t *__restrict __preg,
+ const char *__restrict __string, size_t __nmatch,
+ regmatch_t __pmatch[__restrict_arr],
+ int __eflags);
+
+extern size_t regerror (int __errcode, const regex_t *__restrict __preg,
+ char *__restrict __errbuf, size_t __errbuf_size);
+
+extern void regfree (regex_t *__preg);
+
+
+#ifdef __cplusplus
+}
+#endif /* C++ */
+
+#endif /* regex.h */
diff --git a/node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/regex_internal.c b/node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/regex_internal.c
new file mode 100644
index 0000000..66154e0
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/regex_internal.c
@@ -0,0 +1,1717 @@
+/* Extended regular expression matching and search library.
+ Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+static void re_string_construct_common (const char *str, int len,
+ re_string_t *pstr,
+ RE_TRANSLATE_TYPE trans, int icase,
+ const re_dfa_t *dfa) internal_function;
+static re_dfastate_t *create_ci_newstate (const re_dfa_t *dfa,
+ const re_node_set *nodes,
+ unsigned int hash) internal_function;
+static re_dfastate_t *create_cd_newstate (const re_dfa_t *dfa,
+ const re_node_set *nodes,
+ unsigned int context,
+ unsigned int hash) internal_function;
+
+/* Functions for string operation. */
+
+/* This function allocate the buffers. It is necessary to call
+ re_string_reconstruct before using the object. */
+
+static reg_errcode_t
+internal_function
+re_string_allocate (re_string_t *pstr, const char *str, int len, int init_len,
+ RE_TRANSLATE_TYPE trans, int icase, const re_dfa_t *dfa)
+{
+ reg_errcode_t ret;
+ int init_buf_len;
+
+ /* Ensure at least one character fits into the buffers. */
+ if (init_len < dfa->mb_cur_max)
+ init_len = dfa->mb_cur_max;
+ init_buf_len = (len + 1 < init_len) ? len + 1: init_len;
+ re_string_construct_common (str, len, pstr, trans, icase, dfa);
+
+ ret = re_string_realloc_buffers (pstr, init_buf_len);
+ if (BE (ret != REG_NOERROR, 0))
+ return ret;
+
+ pstr->word_char = dfa->word_char;
+ pstr->word_ops_used = dfa->word_ops_used;
+ pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str;
+ pstr->valid_len = (pstr->mbs_allocated || dfa->mb_cur_max > 1) ? 0 : len;
+ pstr->valid_raw_len = pstr->valid_len;
+ return REG_NOERROR;
+}
+
+/* This function allocate the buffers, and initialize them. */
+
+static reg_errcode_t
+internal_function
+re_string_construct (re_string_t *pstr, const char *str, int len,
+ RE_TRANSLATE_TYPE trans, int icase, const re_dfa_t *dfa)
+{
+ reg_errcode_t ret;
+ memset (pstr, '\0', sizeof (re_string_t));
+ re_string_construct_common (str, len, pstr, trans, icase, dfa);
+
+ if (len > 0)
+ {
+ ret = re_string_realloc_buffers (pstr, len + 1);
+ if (BE (ret != REG_NOERROR, 0))
+ return ret;
+ }
+ pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str;
+
+ if (icase)
+ {
+#ifdef RE_ENABLE_I18N
+ if (dfa->mb_cur_max > 1)
+ {
+ while (1)
+ {
+ ret = build_wcs_upper_buffer (pstr);
+ if (BE (ret != REG_NOERROR, 0))
+ return ret;
+ if (pstr->valid_raw_len >= len)
+ break;
+ if (pstr->bufs_len > pstr->valid_len + dfa->mb_cur_max)
+ break;
+ ret = re_string_realloc_buffers (pstr, pstr->bufs_len * 2);
+ if (BE (ret != REG_NOERROR, 0))
+ return ret;
+ }
+ }
+ else
+#endif /* RE_ENABLE_I18N */
+ build_upper_buffer (pstr);
+ }
+ else
+ {
+#ifdef RE_ENABLE_I18N
+ if (dfa->mb_cur_max > 1)
+ build_wcs_buffer (pstr);
+ else
+#endif /* RE_ENABLE_I18N */
+ {
+ if (trans != NULL)
+ re_string_translate_buffer (pstr);
+ else
+ {
+ pstr->valid_len = pstr->bufs_len;
+ pstr->valid_raw_len = pstr->bufs_len;
+ }
+ }
+ }
+
+ return REG_NOERROR;
+}
+
+/* Helper functions for re_string_allocate, and re_string_construct. */
+
+static reg_errcode_t
+internal_function
+re_string_realloc_buffers (re_string_t *pstr, int new_buf_len)
+{
+#ifdef RE_ENABLE_I18N
+ if (pstr->mb_cur_max > 1)
+ {
+ wint_t *new_wcs = re_realloc (pstr->wcs, wint_t, new_buf_len);
+ if (BE (new_wcs == NULL, 0))
+ return REG_ESPACE;
+ pstr->wcs = new_wcs;
+ if (pstr->offsets != NULL)
+ {
+ int *new_offsets = re_realloc (pstr->offsets, int, new_buf_len);
+ if (BE (new_offsets == NULL, 0))
+ return REG_ESPACE;
+ pstr->offsets = new_offsets;
+ }
+ }
+#endif /* RE_ENABLE_I18N */
+ if (pstr->mbs_allocated)
+ {
+ unsigned char *new_mbs = re_realloc (pstr->mbs, unsigned char,
+ new_buf_len);
+ if (BE (new_mbs == NULL, 0))
+ return REG_ESPACE;
+ pstr->mbs = new_mbs;
+ }
+ pstr->bufs_len = new_buf_len;
+ return REG_NOERROR;
+}
+
+
+static void
+internal_function
+re_string_construct_common (const char *str, int len, re_string_t *pstr,
+ RE_TRANSLATE_TYPE trans, int icase,
+ const re_dfa_t *dfa)
+{
+ pstr->raw_mbs = (const unsigned char *) str;
+ pstr->len = len;
+ pstr->raw_len = len;
+ pstr->trans = trans;
+ pstr->icase = icase ? 1 : 0;
+ pstr->mbs_allocated = (trans != NULL || icase);
+ pstr->mb_cur_max = dfa->mb_cur_max;
+ pstr->is_utf8 = dfa->is_utf8;
+ pstr->map_notascii = dfa->map_notascii;
+ pstr->stop = pstr->len;
+ pstr->raw_stop = pstr->stop;
+}
+
+#ifdef RE_ENABLE_I18N
+
+/* Build wide character buffer PSTR->WCS.
+ If the byte sequence of the string are:
+ <mb1>(0), <mb1>(1), <mb2>(0), <mb2>(1), <sb3>
+ Then wide character buffer will be:
+ <wc1> , WEOF , <wc2> , WEOF , <wc3>
+ We use WEOF for padding, they indicate that the position isn't
+ a first byte of a multibyte character.
+
+ Note that this function assumes PSTR->VALID_LEN elements are already
+ built and starts from PSTR->VALID_LEN. */
+
+static void
+internal_function
+build_wcs_buffer (re_string_t *pstr)
+{
+#ifdef _LIBC
+ unsigned char buf[MB_LEN_MAX];
+ assert (MB_LEN_MAX >= pstr->mb_cur_max);
+#else
+ unsigned char buf[64];
+#endif
+ mbstate_t prev_st;
+ int byte_idx, end_idx, remain_len;
+ size_t mbclen;
+
+ /* Build the buffers from pstr->valid_len to either pstr->len or
+ pstr->bufs_len. */
+ end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len;
+ for (byte_idx = pstr->valid_len; byte_idx < end_idx;)
+ {
+ wchar_t wc;
+ const char *p;
+
+ remain_len = end_idx - byte_idx;
+ prev_st = pstr->cur_state;
+ /* Apply the translation if we need. */
+ if (BE (pstr->trans != NULL, 0))
+ {
+ int i, ch;
+
+ for (i = 0; i < pstr->mb_cur_max && i < remain_len; ++i)
+ {
+ ch = pstr->raw_mbs [pstr->raw_mbs_idx + byte_idx + i];
+ buf[i] = pstr->mbs[byte_idx + i] = pstr->trans[ch];
+ }
+ p = (const char *) buf;
+ }
+ else
+ p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx;
+ mbclen = mbrtowc (&wc, p, remain_len, &pstr->cur_state);
+ if (BE (mbclen == (size_t) -2, 0))
+ {
+ /* The buffer doesn't have enough space, finish to build. */
+ pstr->cur_state = prev_st;
+ break;
+ }
+ else if (BE (mbclen == (size_t) -1 || mbclen == 0, 0))
+ {
+ /* We treat these cases as a singlebyte character. */
+ mbclen = 1;
+ wc = (wchar_t) pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx];
+ if (BE (pstr->trans != NULL, 0))
+ wc = pstr->trans[wc];
+ pstr->cur_state = prev_st;
+ }
+
+ /* Write wide character and padding. */
+ pstr->wcs[byte_idx++] = wc;
+ /* Write paddings. */
+ for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;)
+ pstr->wcs[byte_idx++] = WEOF;
+ }
+ pstr->valid_len = byte_idx;
+ pstr->valid_raw_len = byte_idx;
+}
+
+/* Build wide character buffer PSTR->WCS like build_wcs_buffer,
+ but for REG_ICASE. */
+
+static reg_errcode_t
+internal_function
+build_wcs_upper_buffer (re_string_t *pstr)
+{
+ mbstate_t prev_st;
+ int src_idx, byte_idx, end_idx, remain_len;
+ size_t mbclen;
+#ifdef _LIBC
+ char buf[MB_LEN_MAX];
+ assert (MB_LEN_MAX >= pstr->mb_cur_max);
+#else
+ char buf[64];
+#endif
+
+ byte_idx = pstr->valid_len;
+ end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len;
+
+ /* The following optimization assumes that ASCII characters can be
+ mapped to wide characters with a simple cast. */
+ if (! pstr->map_notascii && pstr->trans == NULL && !pstr->offsets_needed)
+ {
+ while (byte_idx < end_idx)
+ {
+ wchar_t wc;
+
+ if (isascii (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx])
+ && mbsinit (&pstr->cur_state))
+ {
+ /* In case of a singlebyte character. */
+ pstr->mbs[byte_idx]
+ = toupper (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]);
+ /* The next step uses the assumption that wchar_t is encoded
+ ASCII-safe: all ASCII values can be converted like this. */
+ pstr->wcs[byte_idx] = (wchar_t) pstr->mbs[byte_idx];
+ ++byte_idx;
+ continue;
+ }
+
+ remain_len = end_idx - byte_idx;
+ prev_st = pstr->cur_state;
+ mbclen = mbrtowc (&wc,
+ ((const char *) pstr->raw_mbs + pstr->raw_mbs_idx
+ + byte_idx), remain_len, &pstr->cur_state);
+ if (BE (mbclen + 2 > 2, 1))
+ {
+ wchar_t wcu = wc;
+ if (iswlower (wc))
+ {
+ size_t mbcdlen;
+
+ wcu = towupper (wc);
+ mbcdlen = wcrtomb (buf, wcu, &prev_st);
+ if (BE (mbclen == mbcdlen, 1))
+ memcpy (pstr->mbs + byte_idx, buf, mbclen);
+ else
+ {
+ src_idx = byte_idx;
+ goto offsets_needed;
+ }
+ }
+ else
+ memcpy (pstr->mbs + byte_idx,
+ pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx, mbclen);
+ pstr->wcs[byte_idx++] = wcu;
+ /* Write paddings. */
+ for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;)
+ pstr->wcs[byte_idx++] = WEOF;
+ }
+ else if (mbclen == (size_t) -1 || mbclen == 0)
+ {
+ /* It is an invalid character or '\0'. Just use the byte. */
+ int ch = pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx];
+ pstr->mbs[byte_idx] = ch;
+ /* And also cast it to wide char. */
+ pstr->wcs[byte_idx++] = (wchar_t) ch;
+ if (BE (mbclen == (size_t) -1, 0))
+ pstr->cur_state = prev_st;
+ }
+ else
+ {
+ /* The buffer doesn't have enough space, finish to build. */
+ pstr->cur_state = prev_st;
+ break;
+ }
+ }
+ pstr->valid_len = byte_idx;
+ pstr->valid_raw_len = byte_idx;
+ return REG_NOERROR;
+ }
+ else
+ for (src_idx = pstr->valid_raw_len; byte_idx < end_idx;)
+ {
+ wchar_t wc;
+ const char *p;
+ offsets_needed:
+ remain_len = end_idx - byte_idx;
+ prev_st = pstr->cur_state;
+ if (BE (pstr->trans != NULL, 0))
+ {
+ int i, ch;
+
+ for (i = 0; i < pstr->mb_cur_max && i < remain_len; ++i)
+ {
+ ch = pstr->raw_mbs [pstr->raw_mbs_idx + src_idx + i];
+ buf[i] = pstr->trans[ch];
+ }
+ p = (const char *) buf;
+ }
+ else
+ p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + src_idx;
+ mbclen = mbrtowc (&wc, p, remain_len, &pstr->cur_state);
+ if (BE (mbclen + 2 > 2, 1))
+ {
+ wchar_t wcu = wc;
+ if (iswlower (wc))
+ {
+ size_t mbcdlen;
+
+ wcu = towupper (wc);
+ mbcdlen = wcrtomb ((char *) buf, wcu, &prev_st);
+ if (BE (mbclen == mbcdlen, 1))
+ memcpy (pstr->mbs + byte_idx, buf, mbclen);
+ else if (mbcdlen != (size_t) -1)
+ {
+ size_t i;
+
+ if (byte_idx + mbcdlen > pstr->bufs_len)
+ {
+ pstr->cur_state = prev_st;
+ break;
+ }
+
+ if (pstr->offsets == NULL)
+ {
+ pstr->offsets = re_malloc (int, pstr->bufs_len);
+
+ if (pstr->offsets == NULL)
+ return REG_ESPACE;
+ }
+ if (!pstr->offsets_needed)
+ {
+ for (i = 0; i < (size_t) byte_idx; ++i)
+ pstr->offsets[i] = i;
+ pstr->offsets_needed = 1;
+ }
+
+ memcpy (pstr->mbs + byte_idx, buf, mbcdlen);
+ pstr->wcs[byte_idx] = wcu;
+ pstr->offsets[byte_idx] = src_idx;
+ for (i = 1; i < mbcdlen; ++i)
+ {
+ pstr->offsets[byte_idx + i]
+ = src_idx + (i < mbclen ? i : mbclen - 1);
+ pstr->wcs[byte_idx + i] = WEOF;
+ }
+ pstr->len += mbcdlen - mbclen;
+ if (pstr->raw_stop > src_idx)
+ pstr->stop += mbcdlen - mbclen;
+ end_idx = (pstr->bufs_len > pstr->len)
+ ? pstr->len : pstr->bufs_len;
+ byte_idx += mbcdlen;
+ src_idx += mbclen;
+ continue;
+ }
+ else
+ memcpy (pstr->mbs + byte_idx, p, mbclen);
+ }
+ else
+ memcpy (pstr->mbs + byte_idx, p, mbclen);
+
+ if (BE (pstr->offsets_needed != 0, 0))
+ {
+ size_t i;
+ for (i = 0; i < mbclen; ++i)
+ pstr->offsets[byte_idx + i] = src_idx + i;
+ }
+ src_idx += mbclen;
+
+ pstr->wcs[byte_idx++] = wcu;
+ /* Write paddings. */
+ for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;)
+ pstr->wcs[byte_idx++] = WEOF;
+ }
+ else if (mbclen == (size_t) -1 || mbclen == 0)
+ {
+ /* It is an invalid character or '\0'. Just use the byte. */
+ int ch = pstr->raw_mbs[pstr->raw_mbs_idx + src_idx];
+
+ if (BE (pstr->trans != NULL, 0))
+ ch = pstr->trans [ch];
+ pstr->mbs[byte_idx] = ch;
+
+ if (BE (pstr->offsets_needed != 0, 0))
+ pstr->offsets[byte_idx] = src_idx;
+ ++src_idx;
+
+ /* And also cast it to wide char. */
+ pstr->wcs[byte_idx++] = (wchar_t) ch;
+ if (BE (mbclen == (size_t) -1, 0))
+ pstr->cur_state = prev_st;
+ }
+ else
+ {
+ /* The buffer doesn't have enough space, finish to build. */
+ pstr->cur_state = prev_st;
+ break;
+ }
+ }
+ pstr->valid_len = byte_idx;
+ pstr->valid_raw_len = src_idx;
+ return REG_NOERROR;
+}
+
+/* Skip characters until the index becomes greater than NEW_RAW_IDX.
+ Return the index. */
+
+static int
+internal_function
+re_string_skip_chars (re_string_t *pstr, int new_raw_idx, wint_t *last_wc)
+{
+ mbstate_t prev_st;
+ int rawbuf_idx;
+ size_t mbclen;
+ wchar_t wc = WEOF;
+
+ /* Skip the characters which are not necessary to check. */
+ for (rawbuf_idx = pstr->raw_mbs_idx + pstr->valid_raw_len;
+ rawbuf_idx < new_raw_idx;)
+ {
+ int remain_len;
+ remain_len = pstr->len - rawbuf_idx;
+ prev_st = pstr->cur_state;
+ mbclen = mbrtowc (&wc, (const char *) pstr->raw_mbs + rawbuf_idx,
+ remain_len, &pstr->cur_state);
+ if (BE (mbclen == (size_t) -2 || mbclen == (size_t) -1 || mbclen == 0, 0))
+ {
+ /* We treat these cases as a single byte character. */
+ if (mbclen == 0 || remain_len == 0)
+ wc = L'\0';
+ else
+ wc = *(unsigned char *) (pstr->raw_mbs + rawbuf_idx);
+ mbclen = 1;
+ pstr->cur_state = prev_st;
+ }
+ /* Then proceed the next character. */
+ rawbuf_idx += mbclen;
+ }
+ *last_wc = (wint_t) wc;
+ return rawbuf_idx;
+}
+#endif /* RE_ENABLE_I18N */
+
+/* Build the buffer PSTR->MBS, and apply the translation if we need.
+ This function is used in case of REG_ICASE. */
+
+static void
+internal_function
+build_upper_buffer (re_string_t *pstr)
+{
+ int char_idx, end_idx;
+ end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len;
+
+ for (char_idx = pstr->valid_len; char_idx < end_idx; ++char_idx)
+ {
+ int ch = pstr->raw_mbs[pstr->raw_mbs_idx + char_idx];
+ if (BE (pstr->trans != NULL, 0))
+ ch = pstr->trans[ch];
+ if (islower (ch))
+ pstr->mbs[char_idx] = toupper (ch);
+ else
+ pstr->mbs[char_idx] = ch;
+ }
+ pstr->valid_len = char_idx;
+ pstr->valid_raw_len = char_idx;
+}
+
+/* Apply TRANS to the buffer in PSTR. */
+
+static void
+internal_function
+re_string_translate_buffer (re_string_t *pstr)
+{
+ int buf_idx, end_idx;
+ end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len;
+
+ for (buf_idx = pstr->valid_len; buf_idx < end_idx; ++buf_idx)
+ {
+ int ch = pstr->raw_mbs[pstr->raw_mbs_idx + buf_idx];
+ pstr->mbs[buf_idx] = pstr->trans[ch];
+ }
+
+ pstr->valid_len = buf_idx;
+ pstr->valid_raw_len = buf_idx;
+}
+
+/* This function re-construct the buffers.
+ Concretely, convert to wide character in case of pstr->mb_cur_max > 1,
+ convert to upper case in case of REG_ICASE, apply translation. */
+
+static reg_errcode_t
+internal_function
+re_string_reconstruct (re_string_t *pstr, int idx, int eflags)
+{
+ int offset = idx - pstr->raw_mbs_idx;
+ if (BE (offset < 0, 0))
+ {
+ /* Reset buffer. */
+#ifdef RE_ENABLE_I18N
+ if (pstr->mb_cur_max > 1)
+ memset (&pstr->cur_state, '\0', sizeof (mbstate_t));
+#endif /* RE_ENABLE_I18N */
+ pstr->len = pstr->raw_len;
+ pstr->stop = pstr->raw_stop;
+ pstr->valid_len = 0;
+ pstr->raw_mbs_idx = 0;
+ pstr->valid_raw_len = 0;
+ pstr->offsets_needed = 0;
+ pstr->tip_context = ((eflags & REG_NOTBOL) ? CONTEXT_BEGBUF
+ : CONTEXT_NEWLINE | CONTEXT_BEGBUF);
+ if (!pstr->mbs_allocated)
+ pstr->mbs = (unsigned char *) pstr->raw_mbs;
+ offset = idx;
+ }
+
+ if (BE (offset != 0, 1))
+ {
+ /* Should the already checked characters be kept? */
+ if (BE (offset < pstr->valid_raw_len, 1))
+ {
+ /* Yes, move them to the front of the buffer. */
+#ifdef RE_ENABLE_I18N
+ if (BE (pstr->offsets_needed, 0))
+ {
+ int low = 0, high = pstr->valid_len, mid;
+ do
+ {
+ mid = (high + low) / 2;
+ if (pstr->offsets[mid] > offset)
+ high = mid;
+ else if (pstr->offsets[mid] < offset)
+ low = mid + 1;
+ else
+ break;
+ }
+ while (low < high);
+ if (pstr->offsets[mid] < offset)
+ ++mid;
+ pstr->tip_context = re_string_context_at (pstr, mid - 1,
+ eflags);
+ /* This can be quite complicated, so handle specially
+ only the common and easy case where the character with
+ different length representation of lower and upper
+ case is present at or after offset. */
+ if (pstr->valid_len > offset
+ && mid == offset && pstr->offsets[mid] == offset)
+ {
+ memmove (pstr->wcs, pstr->wcs + offset,
+ (pstr->valid_len - offset) * sizeof (wint_t));
+ memmove (pstr->mbs, pstr->mbs + offset, pstr->valid_len - offset);
+ pstr->valid_len -= offset;
+ pstr->valid_raw_len -= offset;
+ for (low = 0; low < pstr->valid_len; low++)
+ pstr->offsets[low] = pstr->offsets[low + offset] - offset;
+ }
+ else
+ {
+ /* Otherwise, just find out how long the partial multibyte
+ character at offset is and fill it with WEOF/255. */
+ pstr->len = pstr->raw_len - idx + offset;
+ pstr->stop = pstr->raw_stop - idx + offset;
+ pstr->offsets_needed = 0;
+ while (mid > 0 && pstr->offsets[mid - 1] == offset)
+ --mid;
+ while (mid < pstr->valid_len)
+ if (pstr->wcs[mid] != WEOF)
+ break;
+ else
+ ++mid;
+ if (mid == pstr->valid_len)
+ pstr->valid_len = 0;
+ else
+ {
+ pstr->valid_len = pstr->offsets[mid] - offset;
+ if (pstr->valid_len)
+ {
+ for (low = 0; low < pstr->valid_len; ++low)
+ pstr->wcs[low] = WEOF;
+ memset (pstr->mbs, 255, pstr->valid_len);
+ }
+ }
+ pstr->valid_raw_len = pstr->valid_len;
+ }
+ }
+ else
+#endif
+ {
+ pstr->tip_context = re_string_context_at (pstr, offset - 1,
+ eflags);
+#ifdef RE_ENABLE_I18N
+ if (pstr->mb_cur_max > 1)
+ memmove (pstr->wcs, pstr->wcs + offset,
+ (pstr->valid_len - offset) * sizeof (wint_t));
+#endif /* RE_ENABLE_I18N */
+ if (BE (pstr->mbs_allocated, 0))
+ memmove (pstr->mbs, pstr->mbs + offset,
+ pstr->valid_len - offset);
+ pstr->valid_len -= offset;
+ pstr->valid_raw_len -= offset;
+#if DEBUG
+ assert (pstr->valid_len > 0);
+#endif
+ }
+ }
+ else
+ {
+ /* No, skip all characters until IDX. */
+ int prev_valid_len = pstr->valid_len;
+
+#ifdef RE_ENABLE_I18N
+ if (BE (pstr->offsets_needed, 0))
+ {
+ pstr->len = pstr->raw_len - idx + offset;
+ pstr->stop = pstr->raw_stop - idx + offset;
+ pstr->offsets_needed = 0;
+ }
+#endif
+ pstr->valid_len = 0;
+#ifdef RE_ENABLE_I18N
+ if (pstr->mb_cur_max > 1)
+ {
+ int wcs_idx;
+ wint_t wc = WEOF;
+
+ if (pstr->is_utf8)
+ {
+ const unsigned char *raw, *p, *q, *end;
+
+ /* Special case UTF-8. Multi-byte chars start with any
+ byte other than 0x80 - 0xbf. */
+ raw = pstr->raw_mbs + pstr->raw_mbs_idx;
+ end = raw + (offset - pstr->mb_cur_max);
+ if (end < pstr->raw_mbs)
+ end = pstr->raw_mbs;
+ p = raw + offset - 1;
+#ifdef _LIBC
+ /* We know the wchar_t encoding is UCS4, so for the simple
+ case, ASCII characters, skip the conversion step. */
+ if (isascii (*p) && BE (pstr->trans == NULL, 1))
+ {
+ memset (&pstr->cur_state, '\0', sizeof (mbstate_t));
+ /* pstr->valid_len = 0; */
+ wc = (wchar_t) *p;
+ }
+ else
+#endif
+ for (; p >= end; --p)
+ if ((*p & 0xc0) != 0x80)
+ {
+ mbstate_t cur_state;
+ wchar_t wc2;
+ int mlen = raw + pstr->len - p;
+ unsigned char buf[6];
+ size_t mbclen;
+
+ q = p;
+ if (BE (pstr->trans != NULL, 0))
+ {
+ int i = mlen < 6 ? mlen : 6;
+ while (--i >= 0)
+ buf[i] = pstr->trans[p[i]];
+ q = buf;
+ }
+ /* XXX Don't use mbrtowc, we know which conversion
+ to use (UTF-8 -> UCS4). */
+ memset (&cur_state, 0, sizeof (cur_state));
+ mbclen = mbrtowc (&wc2, (const char *) p, mlen,
+ &cur_state);
+ if (raw + offset - p <= mbclen
+ && mbclen < (size_t) -2)
+ {
+ memset (&pstr->cur_state, '\0',
+ sizeof (mbstate_t));
+ pstr->valid_len = mbclen - (raw + offset - p);
+ wc = wc2;
+ }
+ break;
+ }
+ }
+
+ if (wc == WEOF)
+ pstr->valid_len = re_string_skip_chars (pstr, idx, &wc) - idx;
+ if (wc == WEOF)
+ pstr->tip_context
+ = re_string_context_at (pstr, prev_valid_len - 1, eflags);
+ else
+ pstr->tip_context = ((BE (pstr->word_ops_used != 0, 0)
+ && IS_WIDE_WORD_CHAR (wc))
+ ? CONTEXT_WORD
+ : ((IS_WIDE_NEWLINE (wc)
+ && pstr->newline_anchor)
+ ? CONTEXT_NEWLINE : 0));
+ if (BE (pstr->valid_len, 0))
+ {
+ for (wcs_idx = 0; wcs_idx < pstr->valid_len; ++wcs_idx)
+ pstr->wcs[wcs_idx] = WEOF;
+ if (pstr->mbs_allocated)
+ memset (pstr->mbs, 255, pstr->valid_len);
+ }
+ pstr->valid_raw_len = pstr->valid_len;
+ }
+ else
+#endif /* RE_ENABLE_I18N */
+ {
+ int c = pstr->raw_mbs[pstr->raw_mbs_idx + offset - 1];
+ pstr->valid_raw_len = 0;
+ if (pstr->trans)
+ c = pstr->trans[c];
+ pstr->tip_context = (bitset_contain (pstr->word_char, c)
+ ? CONTEXT_WORD
+ : ((IS_NEWLINE (c) && pstr->newline_anchor)
+ ? CONTEXT_NEWLINE : 0));
+ }
+ }
+ if (!BE (pstr->mbs_allocated, 0))
+ pstr->mbs += offset;
+ }
+ pstr->raw_mbs_idx = idx;
+ pstr->len -= offset;
+ pstr->stop -= offset;
+
+ /* Then build the buffers. */
+#ifdef RE_ENABLE_I18N
+ if (pstr->mb_cur_max > 1)
+ {
+ if (pstr->icase)
+ {
+ reg_errcode_t ret = build_wcs_upper_buffer (pstr);
+ if (BE (ret != REG_NOERROR, 0))
+ return ret;
+ }
+ else
+ build_wcs_buffer (pstr);
+ }
+ else
+#endif /* RE_ENABLE_I18N */
+ if (BE (pstr->mbs_allocated, 0))
+ {
+ if (pstr->icase)
+ build_upper_buffer (pstr);
+ else if (pstr->trans != NULL)
+ re_string_translate_buffer (pstr);
+ }
+ else
+ pstr->valid_len = pstr->len;
+
+ pstr->cur_idx = 0;
+ return REG_NOERROR;
+}
+
+static unsigned char
+internal_function __attribute ((pure))
+re_string_peek_byte_case (const re_string_t *pstr, int idx)
+{
+ int ch, off;
+
+ /* Handle the common (easiest) cases first. */
+ if (BE (!pstr->mbs_allocated, 1))
+ return re_string_peek_byte (pstr, idx);
+
+#ifdef RE_ENABLE_I18N
+ if (pstr->mb_cur_max > 1
+ && ! re_string_is_single_byte_char (pstr, pstr->cur_idx + idx))
+ return re_string_peek_byte (pstr, idx);
+#endif
+
+ off = pstr->cur_idx + idx;
+#ifdef RE_ENABLE_I18N
+ if (pstr->offsets_needed)
+ off = pstr->offsets[off];
+#endif
+
+ ch = pstr->raw_mbs[pstr->raw_mbs_idx + off];
+
+#ifdef RE_ENABLE_I18N
+ /* Ensure that e.g. for tr_TR.UTF-8 BACKSLASH DOTLESS SMALL LETTER I
+ this function returns CAPITAL LETTER I instead of first byte of
+ DOTLESS SMALL LETTER I. The latter would confuse the parser,
+ since peek_byte_case doesn't advance cur_idx in any way. */
+ if (pstr->offsets_needed && !isascii (ch))
+ return re_string_peek_byte (pstr, idx);
+#endif
+
+ return ch;
+}
+
+static unsigned char
+internal_function __attribute ((pure))
+re_string_fetch_byte_case (re_string_t *pstr)
+{
+ if (BE (!pstr->mbs_allocated, 1))
+ return re_string_fetch_byte (pstr);
+
+#ifdef RE_ENABLE_I18N
+ if (pstr->offsets_needed)
+ {
+ int off, ch;
+
+ /* For tr_TR.UTF-8 [[:islower:]] there is
+ [[: CAPITAL LETTER I WITH DOT lower:]] in mbs. Skip
+ in that case the whole multi-byte character and return
+ the original letter. On the other side, with
+ [[: DOTLESS SMALL LETTER I return [[:I, as doing
+ anything else would complicate things too much. */
+
+ if (!re_string_first_byte (pstr, pstr->cur_idx))
+ return re_string_fetch_byte (pstr);
+
+ off = pstr->offsets[pstr->cur_idx];
+ ch = pstr->raw_mbs[pstr->raw_mbs_idx + off];
+
+ if (! isascii (ch))
+ return re_string_fetch_byte (pstr);
+
+ re_string_skip_bytes (pstr,
+ re_string_char_size_at (pstr, pstr->cur_idx));
+ return ch;
+ }
+#endif
+
+ return pstr->raw_mbs[pstr->raw_mbs_idx + pstr->cur_idx++];
+}
+
+static void
+internal_function
+re_string_destruct (re_string_t *pstr)
+{
+#ifdef RE_ENABLE_I18N
+ re_free (pstr->wcs);
+ re_free (pstr->offsets);
+#endif /* RE_ENABLE_I18N */
+ if (pstr->mbs_allocated)
+ re_free (pstr->mbs);
+}
+
+/* Return the context at IDX in INPUT. */
+
+static unsigned int
+internal_function
+re_string_context_at (const re_string_t *input, int idx, int eflags)
+{
+ int c;
+ if (BE (idx < 0, 0))
+ /* In this case, we use the value stored in input->tip_context,
+ since we can't know the character in input->mbs[-1] here. */
+ return input->tip_context;
+ if (BE (idx == input->len, 0))
+ return ((eflags & REG_NOTEOL) ? CONTEXT_ENDBUF
+ : CONTEXT_NEWLINE | CONTEXT_ENDBUF);
+#ifdef RE_ENABLE_I18N
+ if (input->mb_cur_max > 1)
+ {
+ wint_t wc;
+ int wc_idx = idx;
+ while(input->wcs[wc_idx] == WEOF)
+ {
+#ifdef DEBUG
+ /* It must not happen. */
+ assert (wc_idx >= 0);
+#endif
+ --wc_idx;
+ if (wc_idx < 0)
+ return input->tip_context;
+ }
+ wc = input->wcs[wc_idx];
+ if (BE (input->word_ops_used != 0, 0) && IS_WIDE_WORD_CHAR (wc))
+ return CONTEXT_WORD;
+ return (IS_WIDE_NEWLINE (wc) && input->newline_anchor
+ ? CONTEXT_NEWLINE : 0);
+ }
+ else
+#endif
+ {
+ c = re_string_byte_at (input, idx);
+ if (bitset_contain (input->word_char, c))
+ return CONTEXT_WORD;
+ return IS_NEWLINE (c) && input->newline_anchor ? CONTEXT_NEWLINE : 0;
+ }
+}
+
+/* Functions for set operation. */
+
+static reg_errcode_t
+internal_function
+re_node_set_alloc (re_node_set *set, int size)
+{
+ set->alloc = size;
+ set->nelem = 0;
+ set->elems = re_malloc (int, size);
+ if (BE (set->elems == NULL, 0))
+ return REG_ESPACE;
+ return REG_NOERROR;
+}
+
+static reg_errcode_t
+internal_function
+re_node_set_init_1 (re_node_set *set, int elem)
+{
+ set->alloc = 1;
+ set->nelem = 1;
+ set->elems = re_malloc (int, 1);
+ if (BE (set->elems == NULL, 0))
+ {
+ set->alloc = set->nelem = 0;
+ return REG_ESPACE;
+ }
+ set->elems[0] = elem;
+ return REG_NOERROR;
+}
+
+static reg_errcode_t
+internal_function
+re_node_set_init_2 (re_node_set *set, int elem1, int elem2)
+{
+ set->alloc = 2;
+ set->elems = re_malloc (int, 2);
+ if (BE (set->elems == NULL, 0))
+ return REG_ESPACE;
+ if (elem1 == elem2)
+ {
+ set->nelem = 1;
+ set->elems[0] = elem1;
+ }
+ else
+ {
+ set->nelem = 2;
+ if (elem1 < elem2)
+ {
+ set->elems[0] = elem1;
+ set->elems[1] = elem2;
+ }
+ else
+ {
+ set->elems[0] = elem2;
+ set->elems[1] = elem1;
+ }
+ }
+ return REG_NOERROR;
+}
+
+static reg_errcode_t
+internal_function
+re_node_set_init_copy (re_node_set *dest, const re_node_set *src)
+{
+ dest->nelem = src->nelem;
+ if (src->nelem > 0)
+ {
+ dest->alloc = dest->nelem;
+ dest->elems = re_malloc (int, dest->alloc);
+ if (BE (dest->elems == NULL, 0))
+ {
+ dest->alloc = dest->nelem = 0;
+ return REG_ESPACE;
+ }
+ memcpy (dest->elems, src->elems, src->nelem * sizeof (int));
+ }
+ else
+ re_node_set_init_empty (dest);
+ return REG_NOERROR;
+}
+
+/* Calculate the intersection of the sets SRC1 and SRC2. And merge it to
+ DEST. Return value indicate the error code or REG_NOERROR if succeeded.
+ Note: We assume dest->elems is NULL, when dest->alloc is 0. */
+
+static reg_errcode_t
+internal_function
+re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
+ const re_node_set *src2)
+{
+ int i1, i2, is, id, delta, sbase;
+ if (src1->nelem == 0 || src2->nelem == 0)
+ return REG_NOERROR;
+
+ /* We need dest->nelem + 2 * elems_in_intersection; this is a
+ conservative estimate. */
+ if (src1->nelem + src2->nelem + dest->nelem > dest->alloc)
+ {
+ int new_alloc = src1->nelem + src2->nelem + dest->alloc;
+ int *new_elems = re_realloc (dest->elems, int, new_alloc);
+ if (BE (new_elems == NULL, 0))
+ return REG_ESPACE;
+ dest->elems = new_elems;
+ dest->alloc = new_alloc;
+ }
+
+ /* Find the items in the intersection of SRC1 and SRC2, and copy
+ into the top of DEST those that are not already in DEST itself. */
+ sbase = dest->nelem + src1->nelem + src2->nelem;
+ i1 = src1->nelem - 1;
+ i2 = src2->nelem - 1;
+ id = dest->nelem - 1;
+ for (;;)
+ {
+ if (src1->elems[i1] == src2->elems[i2])
+ {
+ /* Try to find the item in DEST. Maybe we could binary search? */
+ while (id >= 0 && dest->elems[id] > src1->elems[i1])
+ --id;
+
+ if (id < 0 || dest->elems[id] != src1->elems[i1])
+ dest->elems[--sbase] = src1->elems[i1];
+
+ if (--i1 < 0 || --i2 < 0)
+ break;
+ }
+
+ /* Lower the highest of the two items. */
+ else if (src1->elems[i1] < src2->elems[i2])
+ {
+ if (--i2 < 0)
+ break;
+ }
+ else
+ {
+ if (--i1 < 0)
+ break;
+ }
+ }
+
+ id = dest->nelem - 1;
+ is = dest->nelem + src1->nelem + src2->nelem - 1;
+ delta = is - sbase + 1;
+
+ /* Now copy. When DELTA becomes zero, the remaining
+ DEST elements are already in place; this is more or
+ less the same loop that is in re_node_set_merge. */
+ dest->nelem += delta;
+ if (delta > 0 && id >= 0)
+ for (;;)
+ {
+ if (dest->elems[is] > dest->elems[id])
+ {
+ /* Copy from the top. */
+ dest->elems[id + delta--] = dest->elems[is--];
+ if (delta == 0)
+ break;
+ }
+ else
+ {
+ /* Slide from the bottom. */
+ dest->elems[id + delta] = dest->elems[id];
+ if (--id < 0)
+ break;
+ }
+ }
+
+ /* Copy remaining SRC elements. */
+ memcpy (dest->elems, dest->elems + sbase, delta * sizeof (int));
+
+ return REG_NOERROR;
+}
+
+/* Calculate the union set of the sets SRC1 and SRC2. And store it to
+ DEST. Return value indicate the error code or REG_NOERROR if succeeded. */
+
+static reg_errcode_t
+internal_function
+re_node_set_init_union (re_node_set *dest, const re_node_set *src1,
+ const re_node_set *src2)
+{
+ int i1, i2, id;
+ if (src1 != NULL && src1->nelem > 0 && src2 != NULL && src2->nelem > 0)
+ {
+ dest->alloc = src1->nelem + src2->nelem;
+ dest->elems = re_malloc (int, dest->alloc);
+ if (BE (dest->elems == NULL, 0))
+ return REG_ESPACE;
+ }
+ else
+ {
+ if (src1 != NULL && src1->nelem > 0)
+ return re_node_set_init_copy (dest, src1);
+ else if (src2 != NULL && src2->nelem > 0)
+ return re_node_set_init_copy (dest, src2);
+ else
+ re_node_set_init_empty (dest);
+ return REG_NOERROR;
+ }
+ for (i1 = i2 = id = 0 ; i1 < src1->nelem && i2 < src2->nelem ;)
+ {
+ if (src1->elems[i1] > src2->elems[i2])
+ {
+ dest->elems[id++] = src2->elems[i2++];
+ continue;
+ }
+ if (src1->elems[i1] == src2->elems[i2])
+ ++i2;
+ dest->elems[id++] = src1->elems[i1++];
+ }
+ if (i1 < src1->nelem)
+ {
+ memcpy (dest->elems + id, src1->elems + i1,
+ (src1->nelem - i1) * sizeof (int));
+ id += src1->nelem - i1;
+ }
+ else if (i2 < src2->nelem)
+ {
+ memcpy (dest->elems + id, src2->elems + i2,
+ (src2->nelem - i2) * sizeof (int));
+ id += src2->nelem - i2;
+ }
+ dest->nelem = id;
+ return REG_NOERROR;
+}
+
+/* Calculate the union set of the sets DEST and SRC. And store it to
+ DEST. Return value indicate the error code or REG_NOERROR if succeeded. */
+
+static reg_errcode_t
+internal_function
+re_node_set_merge (re_node_set *dest, const re_node_set *src)
+{
+ int is, id, sbase, delta;
+ if (src == NULL || src->nelem == 0)
+ return REG_NOERROR;
+ if (dest->alloc < 2 * src->nelem + dest->nelem)
+ {
+ int new_alloc = 2 * (src->nelem + dest->alloc);
+ int *new_buffer = re_realloc (dest->elems, int, new_alloc);
+ if (BE (new_buffer == NULL, 0))
+ return REG_ESPACE;
+ dest->elems = new_buffer;
+ dest->alloc = new_alloc;
+ }
+
+ if (BE (dest->nelem == 0, 0))
+ {
+ dest->nelem = src->nelem;
+ memcpy (dest->elems, src->elems, src->nelem * sizeof (int));
+ return REG_NOERROR;
+ }
+
+ /* Copy into the top of DEST the items of SRC that are not
+ found in DEST. Maybe we could binary search in DEST? */
+ for (sbase = dest->nelem + 2 * src->nelem,
+ is = src->nelem - 1, id = dest->nelem - 1; is >= 0 && id >= 0; )
+ {
+ if (dest->elems[id] == src->elems[is])
+ is--, id--;
+ else if (dest->elems[id] < src->elems[is])
+ dest->elems[--sbase] = src->elems[is--];
+ else /* if (dest->elems[id] > src->elems[is]) */
+ --id;
+ }
+
+ if (is >= 0)
+ {
+ /* If DEST is exhausted, the remaining items of SRC must be unique. */
+ sbase -= is + 1;
+ memcpy (dest->elems + sbase, src->elems, (is + 1) * sizeof (int));
+ }
+
+ id = dest->nelem - 1;
+ is = dest->nelem + 2 * src->nelem - 1;
+ delta = is - sbase + 1;
+ if (delta == 0)
+ return REG_NOERROR;
+
+ /* Now copy. When DELTA becomes zero, the remaining
+ DEST elements are already in place. */
+ dest->nelem += delta;
+ for (;;)
+ {
+ if (dest->elems[is] > dest->elems[id])
+ {
+ /* Copy from the top. */
+ dest->elems[id + delta--] = dest->elems[is--];
+ if (delta == 0)
+ break;
+ }
+ else
+ {
+ /* Slide from the bottom. */
+ dest->elems[id + delta] = dest->elems[id];
+ if (--id < 0)
+ {
+ /* Copy remaining SRC elements. */
+ memcpy (dest->elems, dest->elems + sbase,
+ delta * sizeof (int));
+ break;
+ }
+ }
+ }
+
+ return REG_NOERROR;
+}
+
+/* Insert the new element ELEM to the re_node_set* SET.
+ SET should not already have ELEM.
+ return -1 if an error is occured, return 1 otherwise. */
+
+static int
+internal_function
+re_node_set_insert (re_node_set *set, int elem)
+{
+ int idx;
+ /* In case the set is empty. */
+ if (set->alloc == 0)
+ {
+ if (BE (re_node_set_init_1 (set, elem) == REG_NOERROR, 1))
+ return 1;
+ else
+ return -1;
+ }
+
+ if (BE (set->nelem, 0) == 0)
+ {
+ /* We already guaranteed above that set->alloc != 0. */
+ set->elems[0] = elem;
+ ++set->nelem;
+ return 1;
+ }
+
+ /* Realloc if we need. */
+ if (set->alloc == set->nelem)
+ {
+ int *new_elems;
+ set->alloc = set->alloc * 2;
+ new_elems = re_realloc (set->elems, int, set->alloc);
+ if (BE (new_elems == NULL, 0))
+ return -1;
+ set->elems = new_elems;
+ }
+
+ /* Move the elements which follows the new element. Test the
+ first element separately to skip a check in the inner loop. */
+ if (elem < set->elems[0])
+ {
+ idx = 0;
+ for (idx = set->nelem; idx > 0; idx--)
+ set->elems[idx] = set->elems[idx - 1];
+ }
+ else
+ {
+ for (idx = set->nelem; set->elems[idx - 1] > elem; idx--)
+ set->elems[idx] = set->elems[idx - 1];
+ }
+
+ /* Insert the new element. */
+ set->elems[idx] = elem;
+ ++set->nelem;
+ return 1;
+}
+
+/* Insert the new element ELEM to the re_node_set* SET.
+ SET should not already have any element greater than or equal to ELEM.
+ Return -1 if an error is occured, return 1 otherwise. */
+
+static int
+internal_function
+re_node_set_insert_last (re_node_set *set, int elem)
+{
+ /* Realloc if we need. */
+ if (set->alloc == set->nelem)
+ {
+ int *new_elems;
+ set->alloc = (set->alloc + 1) * 2;
+ new_elems = re_realloc (set->elems, int, set->alloc);
+ if (BE (new_elems == NULL, 0))
+ return -1;
+ set->elems = new_elems;
+ }
+
+ /* Insert the new element. */
+ set->elems[set->nelem++] = elem;
+ return 1;
+}
+
+/* Compare two node sets SET1 and SET2.
+ return 1 if SET1 and SET2 are equivalent, return 0 otherwise. */
+
+static int
+internal_function __attribute ((pure))
+re_node_set_compare (const re_node_set *set1, const re_node_set *set2)
+{
+ int i;
+ if (set1 == NULL || set2 == NULL || set1->nelem != set2->nelem)
+ return 0;
+ for (i = set1->nelem ; --i >= 0 ; )
+ if (set1->elems[i] != set2->elems[i])
+ return 0;
+ return 1;
+}
+
+/* Return (idx + 1) if SET contains the element ELEM, return 0 otherwise. */
+
+static int
+internal_function __attribute ((pure))
+re_node_set_contains (const re_node_set *set, int elem)
+{
+ unsigned int idx, right, mid;
+ if (set->nelem <= 0)
+ return 0;
+
+ /* Binary search the element. */
+ idx = 0;
+ right = set->nelem - 1;
+ while (idx < right)
+ {
+ mid = (idx + right) / 2;
+ if (set->elems[mid] < elem)
+ idx = mid + 1;
+ else
+ right = mid;
+ }
+ return set->elems[idx] == elem ? idx + 1 : 0;
+}
+
+static void
+internal_function
+re_node_set_remove_at (re_node_set *set, int idx)
+{
+ if (idx < 0 || idx >= set->nelem)
+ return;
+ --set->nelem;
+ for (; idx < set->nelem; idx++)
+ set->elems[idx] = set->elems[idx + 1];
+}
+
+
+/* Add the token TOKEN to dfa->nodes, and return the index of the token.
+ Or return -1, if an error will be occured. */
+
+static int
+internal_function
+re_dfa_add_node (re_dfa_t *dfa, re_token_t token)
+{
+ int type = token.type;
+ if (BE (dfa->nodes_len >= dfa->nodes_alloc, 0))
+ {
+ size_t new_nodes_alloc = dfa->nodes_alloc * 2;
+ int *new_nexts, *new_indices;
+ re_node_set *new_edests, *new_eclosures;
+ re_token_t *new_nodes;
+
+ /* Avoid overflows. */
+ if (BE (new_nodes_alloc < dfa->nodes_alloc, 0))
+ return -1;
+
+ new_nodes = re_realloc (dfa->nodes, re_token_t, new_nodes_alloc);
+ if (BE (new_nodes == NULL, 0))
+ return -1;
+ dfa->nodes = new_nodes;
+ new_nexts = re_realloc (dfa->nexts, int, new_nodes_alloc);
+ new_indices = re_realloc (dfa->org_indices, int, new_nodes_alloc);
+ new_edests = re_realloc (dfa->edests, re_node_set, new_nodes_alloc);
+ new_eclosures = re_realloc (dfa->eclosures, re_node_set, new_nodes_alloc);
+ if (BE (new_nexts == NULL || new_indices == NULL
+ || new_edests == NULL || new_eclosures == NULL, 0))
+ return -1;
+ dfa->nexts = new_nexts;
+ dfa->org_indices = new_indices;
+ dfa->edests = new_edests;
+ dfa->eclosures = new_eclosures;
+ dfa->nodes_alloc = new_nodes_alloc;
+ }
+ dfa->nodes[dfa->nodes_len] = token;
+ dfa->nodes[dfa->nodes_len].constraint = 0;
+#ifdef RE_ENABLE_I18N
+ dfa->nodes[dfa->nodes_len].accept_mb =
+ (type == OP_PERIOD && dfa->mb_cur_max > 1) || type == COMPLEX_BRACKET;
+#endif
+ dfa->nexts[dfa->nodes_len] = -1;
+ re_node_set_init_empty (dfa->edests + dfa->nodes_len);
+ re_node_set_init_empty (dfa->eclosures + dfa->nodes_len);
+ return dfa->nodes_len++;
+}
+
+static inline unsigned int
+internal_function
+calc_state_hash (const re_node_set *nodes, unsigned int context)
+{
+ unsigned int hash = nodes->nelem + context;
+ int i;
+ for (i = 0 ; i < nodes->nelem ; i++)
+ hash += nodes->elems[i];
+ return hash;
+}
+
+/* Search for the state whose node_set is equivalent to NODES.
+ Return the pointer to the state, if we found it in the DFA.
+ Otherwise create the new one and return it. In case of an error
+ return NULL and set the error code in ERR.
+ Note: - We assume NULL as the invalid state, then it is possible that
+ return value is NULL and ERR is REG_NOERROR.
+ - We never return non-NULL value in case of any errors, it is for
+ optimization. */
+
+static re_dfastate_t *
+internal_function
+re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa,
+ const re_node_set *nodes)
+{
+ unsigned int hash;
+ re_dfastate_t *new_state;
+ struct re_state_table_entry *spot;
+ int i;
+ if (BE (nodes->nelem == 0, 0))
+ {
+ *err = REG_NOERROR;
+ return NULL;
+ }
+ hash = calc_state_hash (nodes, 0);
+ spot = dfa->state_table + (hash & dfa->state_hash_mask);
+
+ for (i = 0 ; i < spot->num ; i++)
+ {
+ re_dfastate_t *state = spot->array[i];
+ if (hash != state->hash)
+ continue;
+ if (re_node_set_compare (&state->nodes, nodes))
+ return state;
+ }
+
+ /* There are no appropriate state in the dfa, create the new one. */
+ new_state = create_ci_newstate (dfa, nodes, hash);
+ if (BE (new_state == NULL, 0))
+ *err = REG_ESPACE;
+
+ return new_state;
+}
+
+/* Search for the state whose node_set is equivalent to NODES and
+ whose context is equivalent to CONTEXT.
+ Return the pointer to the state, if we found it in the DFA.
+ Otherwise create the new one and return it. In case of an error
+ return NULL and set the error code in ERR.
+ Note: - We assume NULL as the invalid state, then it is possible that
+ return value is NULL and ERR is REG_NOERROR.
+ - We never return non-NULL value in case of any errors, it is for
+ optimization. */
+
+static re_dfastate_t *
+internal_function
+re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa,
+ const re_node_set *nodes, unsigned int context)
+{
+ unsigned int hash;
+ re_dfastate_t *new_state;
+ struct re_state_table_entry *spot;
+ int i;
+ if (nodes->nelem == 0)
+ {
+ *err = REG_NOERROR;
+ return NULL;
+ }
+ hash = calc_state_hash (nodes, context);
+ spot = dfa->state_table + (hash & dfa->state_hash_mask);
+
+ for (i = 0 ; i < spot->num ; i++)
+ {
+ re_dfastate_t *state = spot->array[i];
+ if (state->hash == hash
+ && state->context == context
+ && re_node_set_compare (state->entrance_nodes, nodes))
+ return state;
+ }
+ /* There are no appropriate state in `dfa', create the new one. */
+ new_state = create_cd_newstate (dfa, nodes, context, hash);
+ if (BE (new_state == NULL, 0))
+ *err = REG_ESPACE;
+
+ return new_state;
+}
+
+/* Finish initialization of the new state NEWSTATE, and using its hash value
+ HASH put in the appropriate bucket of DFA's state table. Return value
+ indicates the error code if failed. */
+
+static reg_errcode_t
+register_state (const re_dfa_t *dfa, re_dfastate_t *newstate,
+ unsigned int hash)
+{
+ struct re_state_table_entry *spot;
+ reg_errcode_t err;
+ int i;
+
+ newstate->hash = hash;
+ err = re_node_set_alloc (&newstate->non_eps_nodes, newstate->nodes.nelem);
+ if (BE (err != REG_NOERROR, 0))
+ return REG_ESPACE;
+ for (i = 0; i < newstate->nodes.nelem; i++)
+ {
+ int elem = newstate->nodes.elems[i];
+ if (!IS_EPSILON_NODE (dfa->nodes[elem].type))
+ re_node_set_insert_last (&newstate->non_eps_nodes, elem);
+ }
+
+ spot = dfa->state_table + (hash & dfa->state_hash_mask);
+ if (BE (spot->alloc <= spot->num, 0))
+ {
+ int new_alloc = 2 * spot->num + 2;
+ re_dfastate_t **new_array = re_realloc (spot->array, re_dfastate_t *,
+ new_alloc);
+ if (BE (new_array == NULL, 0))
+ return REG_ESPACE;
+ spot->array = new_array;
+ spot->alloc = new_alloc;
+ }
+ spot->array[spot->num++] = newstate;
+ return REG_NOERROR;
+}
+
+static void
+free_state (re_dfastate_t *state)
+{
+ re_node_set_free (&state->non_eps_nodes);
+ re_node_set_free (&state->inveclosure);
+ if (state->entrance_nodes != &state->nodes)
+ {
+ re_node_set_free (state->entrance_nodes);
+ re_free (state->entrance_nodes);
+ }
+ re_node_set_free (&state->nodes);
+ re_free (state->word_trtable);
+ re_free (state->trtable);
+ re_free (state);
+}
+
+/* Create the new state which is independ of contexts.
+ Return the new state if succeeded, otherwise return NULL. */
+
+static re_dfastate_t *
+internal_function
+create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
+ unsigned int hash)
+{
+ int i;
+ reg_errcode_t err;
+ re_dfastate_t *newstate;
+
+ newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
+ if (BE (newstate == NULL, 0))
+ return NULL;
+ err = re_node_set_init_copy (&newstate->nodes, nodes);
+ if (BE (err != REG_NOERROR, 0))
+ {
+ re_free (newstate);
+ return NULL;
+ }
+
+ newstate->entrance_nodes = &newstate->nodes;
+ for (i = 0 ; i < nodes->nelem ; i++)
+ {
+ re_token_t *node = dfa->nodes + nodes->elems[i];
+ re_token_type_t type = node->type;
+ if (type == CHARACTER && !node->constraint)
+ continue;
+#ifdef RE_ENABLE_I18N
+ newstate->accept_mb |= node->accept_mb;
+#endif /* RE_ENABLE_I18N */
+
+ /* If the state has the halt node, the state is a halt state. */
+ if (type == END_OF_RE)
+ newstate->halt = 1;
+ else if (type == OP_BACK_REF)
+ newstate->has_backref = 1;
+ else if (type == ANCHOR || node->constraint)
+ newstate->has_constraint = 1;
+ }
+ err = register_state (dfa, newstate, hash);
+ if (BE (err != REG_NOERROR, 0))
+ {
+ free_state (newstate);
+ newstate = NULL;
+ }
+ return newstate;
+}
+
+/* Create the new state which is depend on the context CONTEXT.
+ Return the new state if succeeded, otherwise return NULL. */
+
+static re_dfastate_t *
+internal_function
+create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
+ unsigned int context, unsigned int hash)
+{
+ int i, nctx_nodes = 0;
+ reg_errcode_t err;
+ re_dfastate_t *newstate;
+
+ newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
+ if (BE (newstate == NULL, 0))
+ return NULL;
+ err = re_node_set_init_copy (&newstate->nodes, nodes);
+ if (BE (err != REG_NOERROR, 0))
+ {
+ re_free (newstate);
+ return NULL;
+ }
+
+ newstate->context = context;
+ newstate->entrance_nodes = &newstate->nodes;
+
+ for (i = 0 ; i < nodes->nelem ; i++)
+ {
+ unsigned int constraint = 0;
+ re_token_t *node = dfa->nodes + nodes->elems[i];
+ re_token_type_t type = node->type;
+ if (node->constraint)
+ constraint = node->constraint;
+
+ if (type == CHARACTER && !constraint)
+ continue;
+#ifdef RE_ENABLE_I18N
+ newstate->accept_mb |= node->accept_mb;
+#endif /* RE_ENABLE_I18N */
+
+ /* If the state has the halt node, the state is a halt state. */
+ if (type == END_OF_RE)
+ newstate->halt = 1;
+ else if (type == OP_BACK_REF)
+ newstate->has_backref = 1;
+ else if (type == ANCHOR)
+ constraint = node->opr.ctx_type;
+
+ if (constraint)
+ {
+ if (newstate->entrance_nodes == &newstate->nodes)
+ {
+ newstate->entrance_nodes = re_malloc (re_node_set, 1);
+ if (BE (newstate->entrance_nodes == NULL, 0))
+ {
+ free_state (newstate);
+ return NULL;
+ }
+ re_node_set_init_copy (newstate->entrance_nodes, nodes);
+ nctx_nodes = 0;
+ newstate->has_constraint = 1;
+ }
+
+ if (NOT_SATISFY_PREV_CONSTRAINT (constraint,context))
+ {
+ re_node_set_remove_at (&newstate->nodes, i - nctx_nodes);
+ ++nctx_nodes;
+ }
+ }
+ }
+ err = register_state (dfa, newstate, hash);
+ if (BE (err != REG_NOERROR, 0))
+ {
+ free_state (newstate);
+ newstate = NULL;
+ }
+ return newstate;
+}
diff --git a/node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/regex_internal.h b/node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/regex_internal.h
new file mode 100644
index 0000000..b0c4d35
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/regex_internal.h
@@ -0,0 +1,778 @@
+/* Extended regular expression matching and search library.
+ Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _REGEX_INTERNAL_H
+#define _REGEX_INTERNAL_H 1
+
+#include <assert.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#if defined(__MINGW32_VERSION) || defined(_MSC_VER)
+#define strcasecmp stricmp
+#endif
+
+#if defined HAVE_LANGINFO_H || defined HAVE_LANGINFO_CODESET || defined _LIBC
+# include <langinfo.h>
+#endif
+#if defined HAVE_LOCALE_H || defined _LIBC
+# include <locale.h>
+#endif
+#if defined HAVE_WCHAR_H || defined _LIBC
+# include <wchar.h>
+#endif /* HAVE_WCHAR_H || _LIBC */
+#if defined HAVE_WCTYPE_H || defined _LIBC
+# include <wctype.h>
+#endif /* HAVE_WCTYPE_H || _LIBC */
+#if defined HAVE_STDBOOL_H || defined _LIBC
+# include <stdbool.h>
+#else
+typedef enum { false, true } bool;
+#endif /* HAVE_STDBOOL_H || _LIBC */
+#if defined HAVE_STDINT_H || defined _LIBC
+# include <stdint.h>
+#endif /* HAVE_STDINT_H || _LIBC */
+#if defined _LIBC
+# include <bits/libc-lock.h>
+#else
+# define __libc_lock_define(CLASS,NAME)
+# define __libc_lock_init(NAME) do { } while (0)
+# define __libc_lock_lock(NAME) do { } while (0)
+# define __libc_lock_unlock(NAME) do { } while (0)
+#endif
+
+/* In case that the system doesn't have isblank(). */
+#if !defined _LIBC && !defined HAVE_ISBLANK && !defined isblank
+# define isblank(ch) ((ch) == ' ' || (ch) == '\t')
+#endif
+
+#ifdef _LIBC
+# ifndef _RE_DEFINE_LOCALE_FUNCTIONS
+# define _RE_DEFINE_LOCALE_FUNCTIONS 1
+# include <locale/localeinfo.h>
+# include <locale/elem-hash.h>
+# include <locale/coll-lookup.h>
+# endif
+#endif
+
+/* This is for other GNU distributions with internationalized messages. */
+#if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC
+# include <libintl.h>
+# ifdef _LIBC
+# undef gettext
+# define gettext(msgid) \
+ INTUSE(__dcgettext) (_libc_intl_domainname, msgid, LC_MESSAGES)
+# endif
+#else
+# define gettext(msgid) (msgid)
+#endif
+
+#ifndef gettext_noop
+/* This define is so xgettext can find the internationalizable
+ strings. */
+# define gettext_noop(String) String
+#endif
+
+/* For loser systems without the definition. */
+#ifndef SIZE_MAX
+# define SIZE_MAX ((size_t) -1)
+#endif
+
+#if (defined MB_CUR_MAX && HAVE_LOCALE_H && HAVE_WCTYPE_H && HAVE_WCHAR_H && HAVE_WCRTOMB && HAVE_MBRTOWC && HAVE_WCSCOLL) || _LIBC
+# define RE_ENABLE_I18N
+#endif
+
+#if __GNUC__ >= 3
+# define BE(expr, val) __builtin_expect (expr, val)
+#else
+# define BE(expr, val) (expr)
+# define inline
+#endif
+
+/* Number of single byte character. */
+#define SBC_MAX 256
+
+#define COLL_ELEM_LEN_MAX 8
+
+/* The character which represents newline. */
+#define NEWLINE_CHAR '\n'
+#define WIDE_NEWLINE_CHAR L'\n'
+
+/* Rename to standard API for using out of glibc. */
+#ifndef _LIBC
+# define __wctype wctype
+# define __iswctype iswctype
+# define __btowc btowc
+# define __mempcpy mempcpy
+# define __wcrtomb wcrtomb
+# define __regfree regfree
+# define attribute_hidden
+#endif /* not _LIBC */
+
+#ifdef __GNUC__
+# define __attribute(arg) __attribute__ (arg)
+#else
+# define __attribute(arg)
+#endif
+
+extern const char __re_error_msgid[] attribute_hidden;
+extern const size_t __re_error_msgid_idx[] attribute_hidden;
+
+/* An integer used to represent a set of bits. It must be unsigned,
+ and must be at least as wide as unsigned int. */
+typedef unsigned long int bitset_word_t;
+/* All bits set in a bitset_word_t. */
+#define BITSET_WORD_MAX ULONG_MAX
+/* Number of bits in a bitset_word_t. */
+#define BITSET_WORD_BITS (sizeof (bitset_word_t) * CHAR_BIT)
+/* Number of bitset_word_t in a bit_set. */
+#define BITSET_WORDS (SBC_MAX / BITSET_WORD_BITS)
+typedef bitset_word_t bitset_t[BITSET_WORDS];
+typedef bitset_word_t *re_bitset_ptr_t;
+typedef const bitset_word_t *re_const_bitset_ptr_t;
+
+#define bitset_set(set,i) \
+ (set[i / BITSET_WORD_BITS] |= (bitset_word_t) 1 << i % BITSET_WORD_BITS)
+#define bitset_clear(set,i) \
+ (set[i / BITSET_WORD_BITS] &= ~((bitset_word_t) 1 << i % BITSET_WORD_BITS))
+#define bitset_contain(set,i) \
+ (set[i / BITSET_WORD_BITS] & ((bitset_word_t) 1 << i % BITSET_WORD_BITS))
+#define bitset_empty(set) memset (set, '\0', sizeof (bitset_t))
+#define bitset_set_all(set) memset (set, '\xff', sizeof (bitset_t))
+#define bitset_copy(dest,src) memcpy (dest, src, sizeof (bitset_t))
+
+#define PREV_WORD_CONSTRAINT 0x0001
+#define PREV_NOTWORD_CONSTRAINT 0x0002
+#define NEXT_WORD_CONSTRAINT 0x0004
+#define NEXT_NOTWORD_CONSTRAINT 0x0008
+#define PREV_NEWLINE_CONSTRAINT 0x0010
+#define NEXT_NEWLINE_CONSTRAINT 0x0020
+#define PREV_BEGBUF_CONSTRAINT 0x0040
+#define NEXT_ENDBUF_CONSTRAINT 0x0080
+#define WORD_DELIM_CONSTRAINT 0x0100
+#define NOT_WORD_DELIM_CONSTRAINT 0x0200
+
+typedef enum
+{
+ INSIDE_WORD = PREV_WORD_CONSTRAINT | NEXT_WORD_CONSTRAINT,
+ WORD_FIRST = PREV_NOTWORD_CONSTRAINT | NEXT_WORD_CONSTRAINT,
+ WORD_LAST = PREV_WORD_CONSTRAINT | NEXT_NOTWORD_CONSTRAINT,
+ INSIDE_NOTWORD = PREV_NOTWORD_CONSTRAINT | NEXT_NOTWORD_CONSTRAINT,
+ LINE_FIRST = PREV_NEWLINE_CONSTRAINT,
+ LINE_LAST = NEXT_NEWLINE_CONSTRAINT,
+ BUF_FIRST = PREV_BEGBUF_CONSTRAINT,
+ BUF_LAST = NEXT_ENDBUF_CONSTRAINT,
+ WORD_DELIM = WORD_DELIM_CONSTRAINT,
+ NOT_WORD_DELIM = NOT_WORD_DELIM_CONSTRAINT
+} re_context_type;
+
+typedef struct
+{
+ int alloc;
+ int nelem;
+ int *elems;
+} re_node_set;
+
+typedef enum
+{
+ NON_TYPE = 0,
+
+ /* Node type, These are used by token, node, tree. */
+ CHARACTER = 1,
+ END_OF_RE = 2,
+ SIMPLE_BRACKET = 3,
+ OP_BACK_REF = 4,
+ OP_PERIOD = 5,
+#ifdef RE_ENABLE_I18N
+ COMPLEX_BRACKET = 6,
+ OP_UTF8_PERIOD = 7,
+#endif /* RE_ENABLE_I18N */
+
+ /* We define EPSILON_BIT as a macro so that OP_OPEN_SUBEXP is used
+ when the debugger shows values of this enum type. */
+#define EPSILON_BIT 8
+ OP_OPEN_SUBEXP = EPSILON_BIT | 0,
+ OP_CLOSE_SUBEXP = EPSILON_BIT | 1,
+ OP_ALT = EPSILON_BIT | 2,
+ OP_DUP_ASTERISK = EPSILON_BIT | 3,
+ ANCHOR = EPSILON_BIT | 4,
+
+ /* Tree type, these are used only by tree. */
+ CONCAT = 16,
+ SUBEXP = 17,
+
+ /* Token type, these are used only by token. */
+ OP_DUP_PLUS = 18,
+ OP_DUP_QUESTION,
+ OP_OPEN_BRACKET,
+ OP_CLOSE_BRACKET,
+ OP_CHARSET_RANGE,
+ OP_OPEN_DUP_NUM,
+ OP_CLOSE_DUP_NUM,
+ OP_NON_MATCH_LIST,
+ OP_OPEN_COLL_ELEM,
+ OP_CLOSE_COLL_ELEM,
+ OP_OPEN_EQUIV_CLASS,
+ OP_CLOSE_EQUIV_CLASS,
+ OP_OPEN_CHAR_CLASS,
+ OP_CLOSE_CHAR_CLASS,
+ OP_WORD,
+ OP_NOTWORD,
+ OP_SPACE,
+ OP_NOTSPACE,
+ BACK_SLASH
+
+} re_token_type_t;
+
+#ifdef RE_ENABLE_I18N
+typedef struct
+{
+ /* Multibyte characters. */
+ wchar_t *mbchars;
+
+ /* Collating symbols. */
+# ifdef _LIBC
+ int32_t *coll_syms;
+# endif
+
+ /* Equivalence classes. */
+# ifdef _LIBC
+ int32_t *equiv_classes;
+# endif
+
+ /* Range expressions. */
+# ifdef _LIBC
+ uint32_t *range_starts;
+ uint32_t *range_ends;
+# else /* not _LIBC */
+ wchar_t *range_starts;
+ wchar_t *range_ends;
+# endif /* not _LIBC */
+
+ /* Character classes. */
+ wctype_t *char_classes;
+
+ /* If this character set is the non-matching list. */
+ unsigned int non_match : 1;
+
+ /* # of multibyte characters. */
+ int nmbchars;
+
+ /* # of collating symbols. */
+ int ncoll_syms;
+
+ /* # of equivalence classes. */
+ int nequiv_classes;
+
+ /* # of range expressions. */
+ int nranges;
+
+ /* # of character classes. */
+ int nchar_classes;
+} re_charset_t;
+#endif /* RE_ENABLE_I18N */
+
+typedef struct
+{
+ union
+ {
+ unsigned char c; /* for CHARACTER */
+ re_bitset_ptr_t sbcset; /* for SIMPLE_BRACKET */
+#ifdef RE_ENABLE_I18N
+ re_charset_t *mbcset; /* for COMPLEX_BRACKET */
+#endif /* RE_ENABLE_I18N */
+ int idx; /* for BACK_REF */
+ re_context_type ctx_type; /* for ANCHOR */
+ } opr;
+#if __GNUC__ >= 2
+ re_token_type_t type : 8;
+#else
+ re_token_type_t type;
+#endif
+ unsigned int constraint : 10; /* context constraint */
+ unsigned int duplicated : 1;
+ unsigned int opt_subexp : 1;
+#ifdef RE_ENABLE_I18N
+ unsigned int accept_mb : 1;
+ /* These 2 bits can be moved into the union if needed (e.g. if running out
+ of bits; move opr.c to opr.c.c and move the flags to opr.c.flags). */
+ unsigned int mb_partial : 1;
+#endif
+ unsigned int word_char : 1;
+} re_token_t;
+
+#define IS_EPSILON_NODE(type) ((type) & EPSILON_BIT)
+
+struct re_string_t
+{
+ /* Indicate the raw buffer which is the original string passed as an
+ argument of regexec(), re_search(), etc.. */
+ const unsigned char *raw_mbs;
+ /* Store the multibyte string. In case of "case insensitive mode" like
+ REG_ICASE, upper cases of the string are stored, otherwise MBS points
+ the same address that RAW_MBS points. */
+ unsigned char *mbs;
+#ifdef RE_ENABLE_I18N
+ /* Store the wide character string which is corresponding to MBS. */
+ wint_t *wcs;
+ int *offsets;
+ mbstate_t cur_state;
+#endif
+ /* Index in RAW_MBS. Each character mbs[i] corresponds to
+ raw_mbs[raw_mbs_idx + i]. */
+ int raw_mbs_idx;
+ /* The length of the valid characters in the buffers. */
+ int valid_len;
+ /* The corresponding number of bytes in raw_mbs array. */
+ int valid_raw_len;
+ /* The length of the buffers MBS and WCS. */
+ int bufs_len;
+ /* The index in MBS, which is updated by re_string_fetch_byte. */
+ int cur_idx;
+ /* length of RAW_MBS array. */
+ int raw_len;
+ /* This is RAW_LEN - RAW_MBS_IDX + VALID_LEN - VALID_RAW_LEN. */
+ int len;
+ /* End of the buffer may be shorter than its length in the cases such
+ as re_match_2, re_search_2. Then, we use STOP for end of the buffer
+ instead of LEN. */
+ int raw_stop;
+ /* This is RAW_STOP - RAW_MBS_IDX adjusted through OFFSETS. */
+ int stop;
+
+ /* The context of mbs[0]. We store the context independently, since
+ the context of mbs[0] may be different from raw_mbs[0], which is
+ the beginning of the input string. */
+ unsigned int tip_context;
+ /* The translation passed as a part of an argument of re_compile_pattern. */
+ RE_TRANSLATE_TYPE trans;
+ /* Copy of re_dfa_t's word_char. */
+ re_const_bitset_ptr_t word_char;
+ /* 1 if REG_ICASE. */
+ unsigned char icase;
+ unsigned char is_utf8;
+ unsigned char map_notascii;
+ unsigned char mbs_allocated;
+ unsigned char offsets_needed;
+ unsigned char newline_anchor;
+ unsigned char word_ops_used;
+ int mb_cur_max;
+};
+typedef struct re_string_t re_string_t;
+
+
+struct re_dfa_t;
+typedef struct re_dfa_t re_dfa_t;
+
+#ifndef _LIBC
+# ifdef __i386__
+# define internal_function __attribute ((regparm (3), stdcall))
+# else
+# define internal_function
+# endif
+#endif
+
+static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr,
+ int new_buf_len)
+ internal_function;
+#ifdef RE_ENABLE_I18N
+static void build_wcs_buffer (re_string_t *pstr) internal_function;
+static int build_wcs_upper_buffer (re_string_t *pstr) internal_function;
+#endif /* RE_ENABLE_I18N */
+static void build_upper_buffer (re_string_t *pstr) internal_function;
+static void re_string_translate_buffer (re_string_t *pstr) internal_function;
+static unsigned int re_string_context_at (const re_string_t *input, int idx,
+ int eflags)
+ internal_function __attribute ((pure));
+#define re_string_peek_byte(pstr, offset) \
+ ((pstr)->mbs[(pstr)->cur_idx + offset])
+#define re_string_fetch_byte(pstr) \
+ ((pstr)->mbs[(pstr)->cur_idx++])
+#define re_string_first_byte(pstr, idx) \
+ ((idx) == (pstr)->valid_len || (pstr)->wcs[idx] != WEOF)
+#define re_string_is_single_byte_char(pstr, idx) \
+ ((pstr)->wcs[idx] != WEOF && ((pstr)->valid_len == (idx) + 1 \
+ || (pstr)->wcs[(idx) + 1] != WEOF))
+#define re_string_eoi(pstr) ((pstr)->stop <= (pstr)->cur_idx)
+#define re_string_cur_idx(pstr) ((pstr)->cur_idx)
+#define re_string_get_buffer(pstr) ((pstr)->mbs)
+#define re_string_length(pstr) ((pstr)->len)
+#define re_string_byte_at(pstr,idx) ((pstr)->mbs[idx])
+#define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx))
+#define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx))
+
+#ifdef __GNUC__
+# define alloca(size) __builtin_alloca (size)
+# define HAVE_ALLOCA 1
+#elif defined(_MSC_VER)
+# include <malloc.h>
+# define alloca _alloca
+# define HAVE_ALLOCA 1
+#else
+# error No alloca()
+#endif
+
+#ifndef _LIBC
+# if HAVE_ALLOCA
+/* The OS usually guarantees only one guard page at the bottom of the stack,
+ and a page size can be as small as 4096 bytes. So we cannot safely
+ allocate anything larger than 4096 bytes. Also care for the possibility
+ of a few compiler-allocated temporary stack slots. */
+# define __libc_use_alloca(n) ((n) < 4032)
+# else
+/* alloca is implemented with malloc, so just use malloc. */
+# define __libc_use_alloca(n) 0
+# endif
+#endif
+
+#define re_malloc(t,n) ((t *) malloc ((n) * sizeof (t)))
+#define re_realloc(p,t,n) ((t *) realloc (p, (n) * sizeof (t)))
+#define re_free(p) free (p)
+
+struct bin_tree_t
+{
+ struct bin_tree_t *parent;
+ struct bin_tree_t *left;
+ struct bin_tree_t *right;
+ struct bin_tree_t *first;
+ struct bin_tree_t *next;
+
+ re_token_t token;
+
+ /* `node_idx' is the index in dfa->nodes, if `type' == 0.
+ Otherwise `type' indicate the type of this node. */
+ int node_idx;
+};
+typedef struct bin_tree_t bin_tree_t;
+
+#define BIN_TREE_STORAGE_SIZE \
+ ((1024 - sizeof (void *)) / sizeof (bin_tree_t))
+
+struct bin_tree_storage_t
+{
+ struct bin_tree_storage_t *next;
+ bin_tree_t data[BIN_TREE_STORAGE_SIZE];
+};
+typedef struct bin_tree_storage_t bin_tree_storage_t;
+
+#define CONTEXT_WORD 1
+#define CONTEXT_NEWLINE (CONTEXT_WORD << 1)
+#define CONTEXT_BEGBUF (CONTEXT_NEWLINE << 1)
+#define CONTEXT_ENDBUF (CONTEXT_BEGBUF << 1)
+
+#define IS_WORD_CONTEXT(c) ((c) & CONTEXT_WORD)
+#define IS_NEWLINE_CONTEXT(c) ((c) & CONTEXT_NEWLINE)
+#define IS_BEGBUF_CONTEXT(c) ((c) & CONTEXT_BEGBUF)
+#define IS_ENDBUF_CONTEXT(c) ((c) & CONTEXT_ENDBUF)
+#define IS_ORDINARY_CONTEXT(c) ((c) == 0)
+
+#define IS_WORD_CHAR(ch) (isalnum (ch) || (ch) == '_')
+#define IS_NEWLINE(ch) ((ch) == NEWLINE_CHAR)
+#define IS_WIDE_WORD_CHAR(ch) (iswalnum (ch) || (ch) == L'_')
+#define IS_WIDE_NEWLINE(ch) ((ch) == WIDE_NEWLINE_CHAR)
+
+#define NOT_SATISFY_PREV_CONSTRAINT(constraint,context) \
+ ((((constraint) & PREV_WORD_CONSTRAINT) && !IS_WORD_CONTEXT (context)) \
+ || ((constraint & PREV_NOTWORD_CONSTRAINT) && IS_WORD_CONTEXT (context)) \
+ || ((constraint & PREV_NEWLINE_CONSTRAINT) && !IS_NEWLINE_CONTEXT (context))\
+ || ((constraint & PREV_BEGBUF_CONSTRAINT) && !IS_BEGBUF_CONTEXT (context)))
+
+#define NOT_SATISFY_NEXT_CONSTRAINT(constraint,context) \
+ ((((constraint) & NEXT_WORD_CONSTRAINT) && !IS_WORD_CONTEXT (context)) \
+ || (((constraint) & NEXT_NOTWORD_CONSTRAINT) && IS_WORD_CONTEXT (context)) \
+ || (((constraint) & NEXT_NEWLINE_CONSTRAINT) && !IS_NEWLINE_CONTEXT (context)) \
+ || (((constraint) & NEXT_ENDBUF_CONSTRAINT) && !IS_ENDBUF_CONTEXT (context)))
+
+struct re_dfastate_t
+{
+ unsigned int hash;
+ re_node_set nodes;
+ re_node_set non_eps_nodes;
+ re_node_set inveclosure;
+ re_node_set *entrance_nodes;
+ struct re_dfastate_t **trtable, **word_trtable;
+ unsigned int context : 4;
+ unsigned int halt : 1;
+ /* If this state can accept `multi byte'.
+ Note that we refer to multibyte characters, and multi character
+ collating elements as `multi byte'. */
+ unsigned int accept_mb : 1;
+ /* If this state has backreference node(s). */
+ unsigned int has_backref : 1;
+ unsigned int has_constraint : 1;
+};
+typedef struct re_dfastate_t re_dfastate_t;
+
+struct re_state_table_entry
+{
+ int num;
+ int alloc;
+ re_dfastate_t **array;
+};
+
+/* Array type used in re_sub_match_last_t and re_sub_match_top_t. */
+
+typedef struct
+{
+ int next_idx;
+ int alloc;
+ re_dfastate_t **array;
+} state_array_t;
+
+/* Store information about the node NODE whose type is OP_CLOSE_SUBEXP. */
+
+typedef struct
+{
+ int node;
+ int str_idx; /* The position NODE match at. */
+ state_array_t path;
+} re_sub_match_last_t;
+
+/* Store information about the node NODE whose type is OP_OPEN_SUBEXP.
+ And information about the node, whose type is OP_CLOSE_SUBEXP,
+ corresponding to NODE is stored in LASTS. */
+
+typedef struct
+{
+ int str_idx;
+ int node;
+ state_array_t *path;
+ int alasts; /* Allocation size of LASTS. */
+ int nlasts; /* The number of LASTS. */
+ re_sub_match_last_t **lasts;
+} re_sub_match_top_t;
+
+struct re_backref_cache_entry
+{
+ int node;
+ int str_idx;
+ int subexp_from;
+ int subexp_to;
+ char more;
+ char unused;
+ unsigned short int eps_reachable_subexps_map;
+};
+
+typedef struct
+{
+ /* The string object corresponding to the input string. */
+ re_string_t input;
+#if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
+ const re_dfa_t *const dfa;
+#else
+ const re_dfa_t *dfa;
+#endif
+ /* EFLAGS of the argument of regexec. */
+ int eflags;
+ /* Where the matching ends. */
+ int match_last;
+ int last_node;
+ /* The state log used by the matcher. */
+ re_dfastate_t **state_log;
+ int state_log_top;
+ /* Back reference cache. */
+ int nbkref_ents;
+ int abkref_ents;
+ struct re_backref_cache_entry *bkref_ents;
+ int max_mb_elem_len;
+ int nsub_tops;
+ int asub_tops;
+ re_sub_match_top_t **sub_tops;
+} re_match_context_t;
+
+typedef struct
+{
+ re_dfastate_t **sifted_states;
+ re_dfastate_t **limited_states;
+ int last_node;
+ int last_str_idx;
+ re_node_set limits;
+} re_sift_context_t;
+
+struct re_fail_stack_ent_t
+{
+ int idx;
+ int node;
+ regmatch_t *regs;
+ re_node_set eps_via_nodes;
+};
+
+struct re_fail_stack_t
+{
+ int num;
+ int alloc;
+ struct re_fail_stack_ent_t *stack;
+};
+
+struct re_dfa_t
+{
+ re_token_t *nodes;
+ size_t nodes_alloc;
+ size_t nodes_len;
+ int *nexts;
+ int *org_indices;
+ re_node_set *edests;
+ re_node_set *eclosures;
+ re_node_set *inveclosures;
+ struct re_state_table_entry *state_table;
+ re_dfastate_t *init_state;
+ re_dfastate_t *init_state_word;
+ re_dfastate_t *init_state_nl;
+ re_dfastate_t *init_state_begbuf;
+ bin_tree_t *str_tree;
+ bin_tree_storage_t *str_tree_storage;
+ re_bitset_ptr_t sb_char;
+ int str_tree_storage_idx;
+
+ /* number of subexpressions `re_nsub' is in regex_t. */
+ unsigned int state_hash_mask;
+ int init_node;
+ int nbackref; /* The number of backreference in this dfa. */
+
+ /* Bitmap expressing which backreference is used. */
+ bitset_word_t used_bkref_map;
+ bitset_word_t completed_bkref_map;
+
+ unsigned int has_plural_match : 1;
+ /* If this dfa has "multibyte node", which is a backreference or
+ a node which can accept multibyte character or multi character
+ collating element. */
+ unsigned int has_mb_node : 1;
+ unsigned int is_utf8 : 1;
+ unsigned int map_notascii : 1;
+ unsigned int word_ops_used : 1;
+ int mb_cur_max;
+ bitset_t word_char;
+ reg_syntax_t syntax;
+ int *subexp_map;
+#ifdef DEBUG
+ char* re_str;
+#endif
+ __libc_lock_define (, lock)
+};
+
+#define re_node_set_init_empty(set) memset (set, '\0', sizeof (re_node_set))
+#define re_node_set_remove(set,id) \
+ (re_node_set_remove_at (set, re_node_set_contains (set, id) - 1))
+#define re_node_set_empty(p) ((p)->nelem = 0)
+#define re_node_set_free(set) re_free ((set)->elems)
+
+
+typedef enum
+{
+ SB_CHAR,
+ MB_CHAR,
+ EQUIV_CLASS,
+ COLL_SYM,
+ CHAR_CLASS
+} bracket_elem_type;
+
+typedef struct
+{
+ bracket_elem_type type;
+ union
+ {
+ unsigned char ch;
+ unsigned char *name;
+ wchar_t wch;
+ } opr;
+} bracket_elem_t;
+
+
+/* Inline functions for bitset operation. */
+static inline void
+bitset_not (bitset_t set)
+{
+ int bitset_i;
+ for (bitset_i = 0; bitset_i < BITSET_WORDS; ++bitset_i)
+ set[bitset_i] = ~set[bitset_i];
+}
+
+static inline void
+bitset_merge (bitset_t dest, const bitset_t src)
+{
+ int bitset_i;
+ for (bitset_i = 0; bitset_i < BITSET_WORDS; ++bitset_i)
+ dest[bitset_i] |= src[bitset_i];
+}
+
+static inline void
+bitset_mask (bitset_t dest, const bitset_t src)
+{
+ int bitset_i;
+ for (bitset_i = 0; bitset_i < BITSET_WORDS; ++bitset_i)
+ dest[bitset_i] &= src[bitset_i];
+}
+
+#ifdef RE_ENABLE_I18N
+/* Inline functions for re_string. */
+static inline int
+internal_function __attribute ((pure))
+re_string_char_size_at (const re_string_t *pstr, int idx)
+{
+ int byte_idx;
+ if (pstr->mb_cur_max == 1)
+ return 1;
+ for (byte_idx = 1; idx + byte_idx < pstr->valid_len; ++byte_idx)
+ if (pstr->wcs[idx + byte_idx] != WEOF)
+ break;
+ return byte_idx;
+}
+
+static inline wint_t
+internal_function __attribute ((pure))
+re_string_wchar_at (const re_string_t *pstr, int idx)
+{
+ if (pstr->mb_cur_max == 1)
+ return (wint_t) pstr->mbs[idx];
+ return (wint_t) pstr->wcs[idx];
+}
+
+static int
+internal_function __attribute ((pure))
+re_string_elem_size_at (const re_string_t *pstr, int idx)
+{
+# ifdef _LIBC
+ const unsigned char *p, *extra;
+ const int32_t *table, *indirect;
+ int32_t tmp;
+# include <locale/weight.h>
+ uint_fast32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
+
+ if (nrules != 0)
+ {
+ table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
+ extra = (const unsigned char *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB);
+ indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE,
+ _NL_COLLATE_INDIRECTMB);
+ p = pstr->mbs + idx;
+ tmp = findidx (&p);
+ return p - pstr->mbs - idx;
+ }
+ else
+# endif /* _LIBC */
+ return 1;
+}
+#endif /* RE_ENABLE_I18N */
+
+#endif /* _REGEX_INTERNAL_H */
diff --git a/node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/regexec.c b/node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/regexec.c
new file mode 100644
index 0000000..3c41f54
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/msvc/libgnurx-2.5/regexec.c
@@ -0,0 +1,4329 @@
+/* Extended regular expression matching and search library.
+ Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags,
+ int n) internal_function;
+static void match_ctx_clean (re_match_context_t *mctx) internal_function;
+static void match_ctx_free (re_match_context_t *cache) internal_function;
+static reg_errcode_t match_ctx_add_entry (re_match_context_t *cache, int node,
+ int str_idx, int from, int to)
+ internal_function;
+static int search_cur_bkref_entry (const re_match_context_t *mctx, int str_idx)
+ internal_function;
+static reg_errcode_t match_ctx_add_subtop (re_match_context_t *mctx, int node,
+ int str_idx) internal_function;
+static re_sub_match_last_t * match_ctx_add_sublast (re_sub_match_top_t *subtop,
+ int node, int str_idx)
+ internal_function;
+static void sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t **sifted_sts,
+ re_dfastate_t **limited_sts, int last_node,
+ int last_str_idx)
+ internal_function;
+static reg_errcode_t re_search_internal (const regex_t *preg,
+ const char *string, int length,
+ int start, int range, int stop,
+ size_t nmatch, regmatch_t pmatch[],
+ int eflags) internal_function;
+static int re_search_2_stub (struct re_pattern_buffer *bufp,
+ const char *string1, int length1,
+ const char *string2, int length2,
+ int start, int range, struct re_registers *regs,
+ int stop, int ret_len) internal_function;
+static int re_search_stub (struct re_pattern_buffer *bufp,
+ const char *string, int length, int start,
+ int range, int stop, struct re_registers *regs,
+ int ret_len) internal_function;
+static unsigned re_copy_regs (struct re_registers *regs, regmatch_t *pmatch,
+ int nregs, int regs_allocated) internal_function;
+static reg_errcode_t prune_impossible_nodes (re_match_context_t *mctx)
+ internal_function;
+static int check_matching (re_match_context_t *mctx, int fl_longest_match,
+ int *p_match_first) internal_function;
+static int check_halt_state_context (const re_match_context_t *mctx,
+ const re_dfastate_t *state, int idx)
+ internal_function;
+static void update_regs (const re_dfa_t *dfa, regmatch_t *pmatch,
+ regmatch_t *prev_idx_match, int cur_node,
+ int cur_idx, int nmatch) internal_function;
+static reg_errcode_t push_fail_stack (struct re_fail_stack_t *fs,
+ int str_idx, int dest_node, int nregs,
+ regmatch_t *regs,
+ re_node_set *eps_via_nodes)
+ internal_function;
+static reg_errcode_t set_regs (const regex_t *preg,
+ const re_match_context_t *mctx,
+ size_t nmatch, regmatch_t *pmatch,
+ int fl_backtrack) internal_function;
+static reg_errcode_t free_fail_stack_return (struct re_fail_stack_t *fs)
+ internal_function;
+
+#ifdef RE_ENABLE_I18N
+static int sift_states_iter_mb (const re_match_context_t *mctx,
+ re_sift_context_t *sctx,
+ int node_idx, int str_idx, int max_str_idx)
+ internal_function;
+#endif /* RE_ENABLE_I18N */
+static reg_errcode_t sift_states_backward (const re_match_context_t *mctx,
+ re_sift_context_t *sctx)
+ internal_function;
+static reg_errcode_t build_sifted_states (const re_match_context_t *mctx,
+ re_sift_context_t *sctx, int str_idx,
+ re_node_set *cur_dest)
+ internal_function;
+static reg_errcode_t update_cur_sifted_state (const re_match_context_t *mctx,
+ re_sift_context_t *sctx,
+ int str_idx,
+ re_node_set *dest_nodes)
+ internal_function;
+static reg_errcode_t add_epsilon_src_nodes (const re_dfa_t *dfa,
+ re_node_set *dest_nodes,
+ const re_node_set *candidates)
+ internal_function;
+static int check_dst_limits (const re_match_context_t *mctx,
+ re_node_set *limits,
+ int dst_node, int dst_idx, int src_node,
+ int src_idx) internal_function;
+static int check_dst_limits_calc_pos_1 (const re_match_context_t *mctx,
+ int boundaries, int subexp_idx,
+ int from_node, int bkref_idx)
+ internal_function;
+static int check_dst_limits_calc_pos (const re_match_context_t *mctx,
+ int limit, int subexp_idx,
+ int node, int str_idx,
+ int bkref_idx) internal_function;
+static reg_errcode_t check_subexp_limits (const re_dfa_t *dfa,
+ re_node_set *dest_nodes,
+ const re_node_set *candidates,
+ re_node_set *limits,
+ struct re_backref_cache_entry *bkref_ents,
+ int str_idx) internal_function;
+static reg_errcode_t sift_states_bkref (const re_match_context_t *mctx,
+ re_sift_context_t *sctx,
+ int str_idx, const re_node_set *candidates)
+ internal_function;
+static reg_errcode_t merge_state_array (const re_dfa_t *dfa,
+ re_dfastate_t **dst,
+ re_dfastate_t **src, int num)
+ internal_function;
+static re_dfastate_t *find_recover_state (reg_errcode_t *err,
+ re_match_context_t *mctx) internal_function;
+static re_dfastate_t *transit_state (reg_errcode_t *err,
+ re_match_context_t *mctx,
+ re_dfastate_t *state) internal_function;
+static re_dfastate_t *merge_state_with_log (reg_errcode_t *err,
+ re_match_context_t *mctx,
+ re_dfastate_t *next_state)
+ internal_function;
+static reg_errcode_t check_subexp_matching_top (re_match_context_t *mctx,
+ re_node_set *cur_nodes,
+ int str_idx) internal_function;
+#if 0
+static re_dfastate_t *transit_state_sb (reg_errcode_t *err,
+ re_match_context_t *mctx,
+ re_dfastate_t *pstate)
+ internal_function;
+#endif
+#ifdef RE_ENABLE_I18N
+static reg_errcode_t transit_state_mb (re_match_context_t *mctx,
+ re_dfastate_t *pstate)
+ internal_function;
+#endif /* RE_ENABLE_I18N */
+static reg_errcode_t transit_state_bkref (re_match_context_t *mctx,
+ const re_node_set *nodes)
+ internal_function;
+static reg_errcode_t get_subexp (re_match_context_t *mctx,
+ int bkref_node, int bkref_str_idx)
+ internal_function;
+static reg_errcode_t get_subexp_sub (re_match_context_t *mctx,
+ const re_sub_match_top_t *sub_top,
+ re_sub_match_last_t *sub_last,
+ int bkref_node, int bkref_str)
+ internal_function;
+static int find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes,
+ int subexp_idx, int type) internal_function;
+static reg_errcode_t check_arrival (re_match_context_t *mctx,
+ state_array_t *path, int top_node,
+ int top_str, int last_node, int last_str,
+ int type) internal_function;
+static reg_errcode_t check_arrival_add_next_nodes (re_match_context_t *mctx,
+ int str_idx,
+ re_node_set *cur_nodes,
+ re_node_set *next_nodes)
+ internal_function;
+static reg_errcode_t check_arrival_expand_ecl (const re_dfa_t *dfa,
+ re_node_set *cur_nodes,
+ int ex_subexp, int type)
+ internal_function;
+static reg_errcode_t check_arrival_expand_ecl_sub (const re_dfa_t *dfa,
+ re_node_set *dst_nodes,
+ int target, int ex_subexp,
+ int type) internal_function;
+static reg_errcode_t expand_bkref_cache (re_match_context_t *mctx,
+ re_node_set *cur_nodes, int cur_str,
+ int subexp_num, int type)
+ internal_function;
+static int build_trtable (const re_dfa_t *dfa,
+ re_dfastate_t *state) internal_function;
+#ifdef RE_ENABLE_I18N
+static int check_node_accept_bytes (const re_dfa_t *dfa, int node_idx,
+ const re_string_t *input, int idx)
+ internal_function;
+# ifdef _LIBC
+static unsigned int find_collation_sequence_value (const unsigned char *mbs,
+ size_t name_len)
+ internal_function;
+# endif /* _LIBC */
+#endif /* RE_ENABLE_I18N */
+static int group_nodes_into_DFAstates (const re_dfa_t *dfa,
+ const re_dfastate_t *state,
+ re_node_set *states_node,
+ bitset_t *states_ch) internal_function;
+static int check_node_accept (const re_match_context_t *mctx,
+ const re_token_t *node, int idx)
+ internal_function;
+static reg_errcode_t extend_buffers (re_match_context_t *mctx)
+ internal_function;
+
+/* Entry point for POSIX code. */
+
+/* regexec searches for a given pattern, specified by PREG, in the
+ string STRING.
+
+ If NMATCH is zero or REG_NOSUB was set in the cflags argument to
+ `regcomp', we ignore PMATCH. Otherwise, we assume PMATCH has at
+ least NMATCH elements, and we set them to the offsets of the
+ corresponding matched substrings.
+
+ EFLAGS specifies `execution flags' which affect matching: if
+ REG_NOTBOL is set, then ^ does not match at the beginning of the
+ string; if REG_NOTEOL is set, then $ does not match at the end.
+
+ We return 0 if we find a match and REG_NOMATCH if not. */
+
+int
+regexec (preg, string, nmatch, pmatch, eflags)
+ const regex_t *__restrict preg;
+ const char *__restrict string;
+ size_t nmatch;
+ regmatch_t pmatch[];
+ int eflags;
+{
+ reg_errcode_t err;
+ int start, length;
+ re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+
+ if (eflags & ~(REG_NOTBOL | REG_NOTEOL | REG_STARTEND))
+ return REG_BADPAT;
+
+ if (eflags & REG_STARTEND)
+ {
+ start = pmatch[0].rm_so;
+ length = pmatch[0].rm_eo;
+ }
+ else
+ {
+ start = 0;
+ length = strlen (string);
+ }
+
+ __libc_lock_lock (dfa->lock);
+ if (preg->no_sub)
+ err = re_search_internal (preg, string, length, start, length - start,
+ length, 0, NULL, eflags);
+ else
+ err = re_search_internal (preg, string, length, start, length - start,
+ length, nmatch, pmatch, eflags);
+ __libc_lock_unlock (dfa->lock);
+ return err != REG_NOERROR;
+}
+
+#ifdef _LIBC
+# include <shlib-compat.h>
+versioned_symbol (libc, __regexec, regexec, GLIBC_2_3_4);
+
+# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3_4)
+__typeof__ (__regexec) __compat_regexec;
+
+int
+attribute_compat_text_section
+__compat_regexec (const regex_t *__restrict preg,
+ const char *__restrict string, size_t nmatch,
+ regmatch_t pmatch[], int eflags)
+{
+ return regexec (preg, string, nmatch, pmatch,
+ eflags & (REG_NOTBOL | REG_NOTEOL));
+}
+compat_symbol (libc, __compat_regexec, regexec, GLIBC_2_0);
+# endif
+#endif
+
+/* Entry points for GNU code. */
+
+/* re_match, re_search, re_match_2, re_search_2
+
+ The former two functions operate on STRING with length LENGTH,
+ while the later two operate on concatenation of STRING1 and STRING2
+ with lengths LENGTH1 and LENGTH2, respectively.
+
+ re_match() matches the compiled pattern in BUFP against the string,
+ starting at index START.
+
+ re_search() first tries matching at index START, then it tries to match
+ starting from index START + 1, and so on. The last start position tried
+ is START + RANGE. (Thus RANGE = 0 forces re_search to operate the same
+ way as re_match().)
+
+ The parameter STOP of re_{match,search}_2 specifies that no match exceeding
+ the first STOP characters of the concatenation of the strings should be
+ concerned.
+
+ If REGS is not NULL, and BUFP->no_sub is not set, the offsets of the match
+ and all groups is stroed in REGS. (For the "_2" variants, the offsets are
+ computed relative to the concatenation, not relative to the individual
+ strings.)
+
+ On success, re_match* functions return the length of the match, re_search*
+ return the position of the start of the match. Return value -1 means no
+ match was found and -2 indicates an internal error. */
+
+int
+re_match (bufp, string, length, start, regs)
+ struct re_pattern_buffer *bufp;
+ const char *string;
+ int length, start;
+ struct re_registers *regs;
+{
+ return re_search_stub (bufp, string, length, start, 0, length, regs, 1);
+}
+#ifdef _LIBC
+weak_alias (__re_match, re_match)
+#endif
+
+int
+re_search (bufp, string, length, start, range, regs)
+ struct re_pattern_buffer *bufp;
+ const char *string;
+ int length, start, range;
+ struct re_registers *regs;
+{
+ return re_search_stub (bufp, string, length, start, range, length, regs, 0);
+}
+#ifdef _LIBC
+weak_alias (__re_search, re_search)
+#endif
+
+int
+re_match_2 (bufp, string1, length1, string2, length2, start, regs, stop)
+ struct re_pattern_buffer *bufp;
+ const char *string1, *string2;
+ int length1, length2, start, stop;
+ struct re_registers *regs;
+{
+ return re_search_2_stub (bufp, string1, length1, string2, length2,
+ start, 0, regs, stop, 1);
+}
+#ifdef _LIBC
+weak_alias (__re_match_2, re_match_2)
+#endif
+
+int
+re_search_2 (bufp, string1, length1, string2, length2, start, range, regs, stop)
+ struct re_pattern_buffer *bufp;
+ const char *string1, *string2;
+ int length1, length2, start, range, stop;
+ struct re_registers *regs;
+{
+ return re_search_2_stub (bufp, string1, length1, string2, length2,
+ start, range, regs, stop, 0);
+}
+#ifdef _LIBC
+weak_alias (__re_search_2, re_search_2)
+#endif
+
+static int
+re_search_2_stub (bufp, string1, length1, string2, length2, start, range, regs,
+ stop, ret_len)
+ struct re_pattern_buffer *bufp;
+ const char *string1, *string2;
+ int length1, length2, start, range, stop, ret_len;
+ struct re_registers *regs;
+{
+ const char *str;
+ int rval;
+ int len = length1 + length2;
+ int free_str = 0;
+
+ if (BE (length1 < 0 || length2 < 0 || stop < 0, 0))
+ return -2;
+
+ /* Concatenate the strings. */
+ if (length2 > 0)
+ if (length1 > 0)
+ {
+ char *s = re_malloc (char, len);
+
+ if (BE (s == NULL, 0))
+ return -2;
+#ifdef _LIBC
+ memcpy (__mempcpy (s, string1, length1), string2, length2);
+#else
+ memcpy (s, string1, length1);
+ memcpy (s + length1, string2, length2);
+#endif
+ str = s;
+ free_str = 1;
+ }
+ else
+ str = string2;
+ else
+ str = string1;
+
+ rval = re_search_stub (bufp, str, len, start, range, stop, regs,
+ ret_len);
+ if (free_str)
+ re_free ((char *) str);
+ return rval;
+}
+
+/* The parameters have the same meaning as those of re_search.
+ Additional parameters:
+ If RET_LEN is nonzero the length of the match is returned (re_match style);
+ otherwise the position of the match is returned. */
+
+static int
+re_search_stub (bufp, string, length, start, range, stop, regs, ret_len)
+ struct re_pattern_buffer *bufp;
+ const char *string;
+ int length, start, range, stop, ret_len;
+ struct re_registers *regs;
+{
+ reg_errcode_t result;
+ regmatch_t *pmatch;
+ int nregs, rval;
+ int eflags = 0;
+ re_dfa_t *dfa = (re_dfa_t *) bufp->buffer;
+
+ /* Check for out-of-range. */
+ if (BE (start < 0 || start > length, 0))
+ return -1;
+ if (BE (start + range > length, 0))
+ range = length - start;
+ else if (BE (start + range < 0, 0))
+ range = -start;
+
+ __libc_lock_lock (dfa->lock);
+
+ eflags |= (bufp->not_bol) ? REG_NOTBOL : 0;
+ eflags |= (bufp->not_eol) ? REG_NOTEOL : 0;
+
+ /* Compile fastmap if we haven't yet. */
+ if (range > 0 && bufp->fastmap != NULL && !bufp->fastmap_accurate)
+ re_compile_fastmap (bufp);
+
+ if (BE (bufp->no_sub, 0))
+ regs = NULL;
+
+ /* We need at least 1 register. */
+ if (regs == NULL)
+ nregs = 1;
+ else if (BE (bufp->regs_allocated == REGS_FIXED &&
+ regs->num_regs < bufp->re_nsub + 1, 0))
+ {
+ nregs = regs->num_regs;
+ if (BE (nregs < 1, 0))
+ {
+ /* Nothing can be copied to regs. */
+ regs = NULL;
+ nregs = 1;
+ }
+ }
+ else
+ nregs = bufp->re_nsub + 1;
+ pmatch = re_malloc (regmatch_t, nregs);
+ if (BE (pmatch == NULL, 0))
+ {
+ rval = -2;
+ goto out;
+ }
+
+ result = re_search_internal (bufp, string, length, start, range, stop,
+ nregs, pmatch, eflags);
+
+ rval = 0;
+
+ /* I hope we needn't fill ther regs with -1's when no match was found. */
+ if (result != REG_NOERROR)
+ rval = -1;
+ else if (regs != NULL)
+ {
+ /* If caller wants register contents data back, copy them. */
+ bufp->regs_allocated = re_copy_regs (regs, pmatch, nregs,
+ bufp->regs_allocated);
+ if (BE (bufp->regs_allocated == REGS_UNALLOCATED, 0))
+ rval = -2;
+ }
+
+ if (BE (rval == 0, 1))
+ {
+ if (ret_len)
+ {
+ assert (pmatch[0].rm_so == start);
+ rval = pmatch[0].rm_eo - start;
+ }
+ else
+ rval = pmatch[0].rm_so;
+ }
+ re_free (pmatch);
+ out:
+ __libc_lock_unlock (dfa->lock);
+ return rval;
+}
+
+static unsigned
+re_copy_regs (regs, pmatch, nregs, regs_allocated)
+ struct re_registers *regs;
+ regmatch_t *pmatch;
+ int nregs, regs_allocated;
+{
+ int rval = REGS_REALLOCATE;
+ int i;
+ int need_regs = nregs + 1;
+ /* We need one extra element beyond `num_regs' for the `-1' marker GNU code
+ uses. */
+
+ /* Have the register data arrays been allocated? */
+ if (regs_allocated == REGS_UNALLOCATED)
+ { /* No. So allocate them with malloc. */
+ regs->start = re_malloc (regoff_t, need_regs);
+ regs->end = re_malloc (regoff_t, need_regs);
+ if (BE (regs->start == NULL, 0) || BE (regs->end == NULL, 0))
+ return REGS_UNALLOCATED;
+ regs->num_regs = need_regs;
+ }
+ else if (regs_allocated == REGS_REALLOCATE)
+ { /* Yes. If we need more elements than were already
+ allocated, reallocate them. If we need fewer, just
+ leave it alone. */
+ if (BE (need_regs > regs->num_regs, 0))
+ {
+ regoff_t *new_start = re_realloc (regs->start, regoff_t, need_regs);
+ regoff_t *new_end = re_realloc (regs->end, regoff_t, need_regs);
+ if (BE (new_start == NULL, 0) || BE (new_end == NULL, 0))
+ return REGS_UNALLOCATED;
+ regs->start = new_start;
+ regs->end = new_end;
+ regs->num_regs = need_regs;
+ }
+ }
+ else
+ {
+ assert (regs_allocated == REGS_FIXED);
+ /* This function may not be called with REGS_FIXED and nregs too big. */
+ assert (regs->num_regs >= nregs);
+ rval = REGS_FIXED;
+ }
+
+ /* Copy the regs. */
+ for (i = 0; i < nregs; ++i)
+ {
+ regs->start[i] = pmatch[i].rm_so;
+ regs->end[i] = pmatch[i].rm_eo;
+ }
+ for ( ; i < regs->num_regs; ++i)
+ regs->start[i] = regs->end[i] = -1;
+
+ return rval;
+}
+
+/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
+ ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use
+ this memory for recording register information. STARTS and ENDS
+ must be allocated using the malloc library routine, and must each
+ be at least NUM_REGS * sizeof (regoff_t) bytes long.
+
+ If NUM_REGS == 0, then subsequent matches should allocate their own
+ register data.
+
+ Unless this function is called, the first search or match using
+ PATTERN_BUFFER will allocate its own register data, without
+ freeing the old data. */
+
+void
+re_set_registers (bufp, regs, num_regs, starts, ends)
+ struct re_pattern_buffer *bufp;
+ struct re_registers *regs;
+ unsigned num_regs;
+ regoff_t *starts, *ends;
+{
+ if (num_regs)
+ {
+ bufp->regs_allocated = REGS_REALLOCATE;
+ regs->num_regs = num_regs;
+ regs->start = starts;
+ regs->end = ends;
+ }
+ else
+ {
+ bufp->regs_allocated = REGS_UNALLOCATED;
+ regs->num_regs = 0;
+ regs->start = regs->end = (regoff_t *) 0;
+ }
+}
+#ifdef _LIBC
+weak_alias (__re_set_registers, re_set_registers)
+#endif
+
+/* Entry points compatible with 4.2 BSD regex library. We don't define
+ them unless specifically requested. */
+
+#if defined _REGEX_RE_COMP || defined _LIBC
+int
+# ifdef _LIBC
+weak_function
+# endif
+re_exec (s)
+ const char *s;
+{
+ return 0 == regexec (&re_comp_buf, s, 0, NULL, 0);
+}
+#endif /* _REGEX_RE_COMP */
+
+/* Internal entry point. */
+
+/* Searches for a compiled pattern PREG in the string STRING, whose
+ length is LENGTH. NMATCH, PMATCH, and EFLAGS have the same
+ mingings with regexec. START, and RANGE have the same meanings
+ with re_search.
+ Return REG_NOERROR if we find a match, and REG_NOMATCH if not,
+ otherwise return the error code.
+ Note: We assume front end functions already check ranges.
+ (START + RANGE >= 0 && START + RANGE <= LENGTH) */
+
+static reg_errcode_t
+re_search_internal (preg, string, length, start, range, stop, nmatch, pmatch,
+ eflags)
+ const regex_t *preg;
+ const char *string;
+ int length, start, range, stop, eflags;
+ size_t nmatch;
+ regmatch_t pmatch[];
+{
+ reg_errcode_t err;
+ const re_dfa_t *dfa = (const re_dfa_t *) preg->buffer;
+ int left_lim, right_lim, incr;
+ int fl_longest_match, match_first, match_kind, match_last = -1;
+ int extra_nmatch;
+ int sb, ch;
+#if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
+ re_match_context_t mctx = { .dfa = dfa };
+#else
+ re_match_context_t mctx;
+#endif
+ char *fastmap = (preg->fastmap != NULL && preg->fastmap_accurate
+ && range && !preg->can_be_null) ? preg->fastmap : NULL;
+ RE_TRANSLATE_TYPE t = preg->translate;
+
+#if !(defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
+ memset (&mctx, '\0', sizeof (re_match_context_t));
+ mctx.dfa = dfa;
+#endif
+
+ extra_nmatch = (nmatch > preg->re_nsub) ? nmatch - (preg->re_nsub + 1) : 0;
+ nmatch -= extra_nmatch;
+
+ /* Check if the DFA haven't been compiled. */
+ if (BE (preg->used == 0 || dfa->init_state == NULL
+ || dfa->init_state_word == NULL || dfa->init_state_nl == NULL
+ || dfa->init_state_begbuf == NULL, 0))
+ return REG_NOMATCH;
+
+#ifdef DEBUG
+ /* We assume front-end functions already check them. */
+ assert (start + range >= 0 && start + range <= length);
+#endif
+
+ /* If initial states with non-begbuf contexts have no elements,
+ the regex must be anchored. If preg->newline_anchor is set,
+ we'll never use init_state_nl, so do not check it. */
+ if (dfa->init_state->nodes.nelem == 0
+ && dfa->init_state_word->nodes.nelem == 0
+ && (dfa->init_state_nl->nodes.nelem == 0
+ || !preg->newline_anchor))
+ {
+ if (start != 0 && start + range != 0)
+ return REG_NOMATCH;
+ start = range = 0;
+ }
+
+ /* We must check the longest matching, if nmatch > 0. */
+ fl_longest_match = (nmatch != 0 || dfa->nbackref);
+
+ err = re_string_allocate (&mctx.input, string, length, dfa->nodes_len + 1,
+ preg->translate, preg->syntax & RE_ICASE, dfa);
+ if (BE (err != REG_NOERROR, 0))
+ goto free_return;
+ mctx.input.stop = stop;
+ mctx.input.raw_stop = stop;
+ mctx.input.newline_anchor = preg->newline_anchor;
+
+ err = match_ctx_init (&mctx, eflags, dfa->nbackref * 2);
+ if (BE (err != REG_NOERROR, 0))
+ goto free_return;
+
+ /* We will log all the DFA states through which the dfa pass,
+ if nmatch > 1, or this dfa has "multibyte node", which is a
+ back-reference or a node which can accept multibyte character or
+ multi character collating element. */
+ if (nmatch > 1 || dfa->has_mb_node)
+ {
+ mctx.state_log = re_malloc (re_dfastate_t *, mctx.input.bufs_len + 1);
+ if (BE (mctx.state_log == NULL, 0))
+ {
+ err = REG_ESPACE;
+ goto free_return;
+ }
+ }
+ else
+ mctx.state_log = NULL;
+
+ match_first = start;
+ mctx.input.tip_context = (eflags & REG_NOTBOL) ? CONTEXT_BEGBUF
+ : CONTEXT_NEWLINE | CONTEXT_BEGBUF;
+
+ /* Check incrementally whether of not the input string match. */
+ incr = (range < 0) ? -1 : 1;
+ left_lim = (range < 0) ? start + range : start;
+ right_lim = (range < 0) ? start : start + range;
+ sb = dfa->mb_cur_max == 1;
+ match_kind =
+ (fastmap
+ ? ((sb || !(preg->syntax & RE_ICASE || t) ? 4 : 0)
+ | (range >= 0 ? 2 : 0)
+ | (t != NULL ? 1 : 0))
+ : 8);
+
+ for (;; match_first += incr)
+ {
+ err = REG_NOMATCH;
+ if (match_first < left_lim || right_lim < match_first)
+ goto free_return;
+
+ /* Advance as rapidly as possible through the string, until we
+ find a plausible place to start matching. This may be done
+ with varying efficiency, so there are various possibilities:
+ only the most common of them are specialized, in order to
+ save on code size. We use a switch statement for speed. */
+ switch (match_kind)
+ {
+ case 8:
+ /* No fastmap. */
+ break;
+
+ case 7:
+ /* Fastmap with single-byte translation, match forward. */
+ while (BE (match_first < right_lim, 1)
+ && !fastmap[t[(unsigned char) string[match_first]]])
+ ++match_first;
+ goto forward_match_found_start_or_reached_end;
+
+ case 6:
+ /* Fastmap without translation, match forward. */
+ while (BE (match_first < right_lim, 1)
+ && !fastmap[(unsigned char) string[match_first]])
+ ++match_first;
+
+ forward_match_found_start_or_reached_end:
+ if (BE (match_first == right_lim, 0))
+ {
+ ch = match_first >= length
+ ? 0 : (unsigned char) string[match_first];
+ if (!fastmap[t ? t[ch] : ch])
+ goto free_return;
+ }
+ break;
+
+ case 4:
+ case 5:
+ /* Fastmap without multi-byte translation, match backwards. */
+ while (match_first >= left_lim)
+ {
+ ch = match_first >= length
+ ? 0 : (unsigned char) string[match_first];
+ if (fastmap[t ? t[ch] : ch])
+ break;
+ --match_first;
+ }
+ if (match_first < left_lim)
+ goto free_return;
+ break;
+
+ default:
+ /* In this case, we can't determine easily the current byte,
+ since it might be a component byte of a multibyte
+ character. Then we use the constructed buffer instead. */
+ for (;;)
+ {
+ /* If MATCH_FIRST is out of the valid range, reconstruct the
+ buffers. */
+ unsigned int offset = match_first - mctx.input.raw_mbs_idx;
+ if (BE (offset >= (unsigned int) mctx.input.valid_raw_len, 0))
+ {
+ err = re_string_reconstruct (&mctx.input, match_first,
+ eflags);
+ if (BE (err != REG_NOERROR, 0))
+ goto free_return;
+
+ offset = match_first - mctx.input.raw_mbs_idx;
+ }
+ /* If MATCH_FIRST is out of the buffer, leave it as '\0'.
+ Note that MATCH_FIRST must not be smaller than 0. */
+ ch = (match_first >= length
+ ? 0 : re_string_byte_at (&mctx.input, offset));
+ if (fastmap[ch])
+ break;
+ match_first += incr;
+ if (match_first < left_lim || match_first > right_lim)
+ {
+ err = REG_NOMATCH;
+ goto free_return;
+ }
+ }
+ break;
+ }
+
+ /* Reconstruct the buffers so that the matcher can assume that
+ the matching starts from the beginning of the buffer. */
+ err = re_string_reconstruct (&mctx.input, match_first, eflags);
+ if (BE (err != REG_NOERROR, 0))
+ goto free_return;
+
+#ifdef RE_ENABLE_I18N
+ /* Don't consider this char as a possible match start if it part,
+ yet isn't the head, of a multibyte character. */
+ if (!sb && !re_string_first_byte (&mctx.input, 0))
+ continue;
+#endif
+
+ /* It seems to be appropriate one, then use the matcher. */
+ /* We assume that the matching starts from 0. */
+ mctx.state_log_top = mctx.nbkref_ents = mctx.max_mb_elem_len = 0;
+ match_last = check_matching (&mctx, fl_longest_match,
+ range >= 0 ? &match_first : NULL);
+ if (match_last != -1)
+ {
+ if (BE (match_last == -2, 0))
+ {
+ err = REG_ESPACE;
+ goto free_return;
+ }
+ else
+ {
+ mctx.match_last = match_last;
+ if ((!preg->no_sub && nmatch > 1) || dfa->nbackref)
+ {
+ re_dfastate_t *pstate = mctx.state_log[match_last];
+ mctx.last_node = check_halt_state_context (&mctx, pstate,
+ match_last);
+ }
+ if ((!preg->no_sub && nmatch > 1 && dfa->has_plural_match)
+ || dfa->nbackref)
+ {
+ err = prune_impossible_nodes (&mctx);
+ if (err == REG_NOERROR)
+ break;
+ if (BE (err != REG_NOMATCH, 0))
+ goto free_return;
+ match_last = -1;
+ }
+ else
+ break; /* We found a match. */
+ }
+ }
+
+ match_ctx_clean (&mctx);
+ }
+
+#ifdef DEBUG
+ assert (match_last != -1);
+ assert (err == REG_NOERROR);
+#endif
+
+ /* Set pmatch[] if we need. */
+ if (nmatch > 0)
+ {
+ int reg_idx;
+
+ /* Initialize registers. */
+ for (reg_idx = 1; reg_idx < nmatch; ++reg_idx)
+ pmatch[reg_idx].rm_so = pmatch[reg_idx].rm_eo = -1;
+
+ /* Set the points where matching start/end. */
+ pmatch[0].rm_so = 0;
+ pmatch[0].rm_eo = mctx.match_last;
+
+ if (!preg->no_sub && nmatch > 1)
+ {
+ err = set_regs (preg, &mctx, nmatch, pmatch,
+ dfa->has_plural_match && dfa->nbackref > 0);
+ if (BE (err != REG_NOERROR, 0))
+ goto free_return;
+ }
+
+ /* At last, add the offset to the each registers, since we slided
+ the buffers so that we could assume that the matching starts
+ from 0. */
+ for (reg_idx = 0; reg_idx < nmatch; ++reg_idx)
+ if (pmatch[reg_idx].rm_so != -1)
+ {
+#ifdef RE_ENABLE_I18N
+ if (BE (mctx.input.offsets_needed != 0, 0))
+ {
+ pmatch[reg_idx].rm_so =
+ (pmatch[reg_idx].rm_so == mctx.input.valid_len
+ ? mctx.input.valid_raw_len
+ : mctx.input.offsets[pmatch[reg_idx].rm_so]);
+ pmatch[reg_idx].rm_eo =
+ (pmatch[reg_idx].rm_eo == mctx.input.valid_len
+ ? mctx.input.valid_raw_len
+ : mctx.input.offsets[pmatch[reg_idx].rm_eo]);
+ }
+#else
+ assert (mctx.input.offsets_needed == 0);
+#endif
+ pmatch[reg_idx].rm_so += match_first;
+ pmatch[reg_idx].rm_eo += match_first;
+ }
+ for (reg_idx = 0; reg_idx < extra_nmatch; ++reg_idx)
+ {
+ pmatch[nmatch + reg_idx].rm_so = -1;
+ pmatch[nmatch + reg_idx].rm_eo = -1;
+ }
+
+ if (dfa->subexp_map)
+ for (reg_idx = 0; reg_idx + 1 < nmatch; reg_idx++)
+ if (dfa->subexp_map[reg_idx] != reg_idx)
+ {
+ pmatch[reg_idx + 1].rm_so
+ = pmatch[dfa->subexp_map[reg_idx] + 1].rm_so;
+ pmatch[reg_idx + 1].rm_eo
+ = pmatch[dfa->subexp_map[reg_idx] + 1].rm_eo;
+ }
+ }
+
+ free_return:
+ re_free (mctx.state_log);
+ if (dfa->nbackref)
+ match_ctx_free (&mctx);
+ re_string_destruct (&mctx.input);
+ return err;
+}
+
+static reg_errcode_t
+prune_impossible_nodes (mctx)
+ re_match_context_t *mctx;
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ int halt_node, match_last;
+ reg_errcode_t ret;
+ re_dfastate_t **sifted_states;
+ re_dfastate_t **lim_states = NULL;
+ re_sift_context_t sctx;
+#ifdef DEBUG
+ assert (mctx->state_log != NULL);
+#endif
+ match_last = mctx->match_last;
+ halt_node = mctx->last_node;
+ sifted_states = re_malloc (re_dfastate_t *, match_last + 1);
+ if (BE (sifted_states == NULL, 0))
+ {
+ ret = REG_ESPACE;
+ goto free_return;
+ }
+ if (dfa->nbackref)
+ {
+ lim_states = re_malloc (re_dfastate_t *, match_last + 1);
+ if (BE (lim_states == NULL, 0))
+ {
+ ret = REG_ESPACE;
+ goto free_return;
+ }
+ while (1)
+ {
+ memset (lim_states, '\0',
+ sizeof (re_dfastate_t *) * (match_last + 1));
+ sift_ctx_init (&sctx, sifted_states, lim_states, halt_node,
+ match_last);
+ ret = sift_states_backward (mctx, &sctx);
+ re_node_set_free (&sctx.limits);
+ if (BE (ret != REG_NOERROR, 0))
+ goto free_return;
+ if (sifted_states[0] != NULL || lim_states[0] != NULL)
+ break;
+ do
+ {
+ --match_last;
+ if (match_last < 0)
+ {
+ ret = REG_NOMATCH;
+ goto free_return;
+ }
+ } while (mctx->state_log[match_last] == NULL
+ || !mctx->state_log[match_last]->halt);
+ halt_node = check_halt_state_context (mctx,
+ mctx->state_log[match_last],
+ match_last);
+ }
+ ret = merge_state_array (dfa, sifted_states, lim_states,
+ match_last + 1);
+ re_free (lim_states);
+ lim_states = NULL;
+ if (BE (ret != REG_NOERROR, 0))
+ goto free_return;
+ }
+ else
+ {
+ sift_ctx_init (&sctx, sifted_states, lim_states, halt_node, match_last);
+ ret = sift_states_backward (mctx, &sctx);
+ re_node_set_free (&sctx.limits);
+ if (BE (ret != REG_NOERROR, 0))
+ goto free_return;
+ }
+ re_free (mctx->state_log);
+ mctx->state_log = sifted_states;
+ sifted_states = NULL;
+ mctx->last_node = halt_node;
+ mctx->match_last = match_last;
+ ret = REG_NOERROR;
+ free_return:
+ re_free (sifted_states);
+ re_free (lim_states);
+ return ret;
+}
+
+/* Acquire an initial state and return it.
+ We must select appropriate initial state depending on the context,
+ since initial states may have constraints like "\<", "^", etc.. */
+
+static inline re_dfastate_t *
+__attribute ((always_inline)) internal_function
+acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx,
+ int idx)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ if (dfa->init_state->has_constraint)
+ {
+ unsigned int context;
+ context = re_string_context_at (&mctx->input, idx - 1, mctx->eflags);
+ if (IS_WORD_CONTEXT (context))
+ return dfa->init_state_word;
+ else if (IS_ORDINARY_CONTEXT (context))
+ return dfa->init_state;
+ else if (IS_BEGBUF_CONTEXT (context) && IS_NEWLINE_CONTEXT (context))
+ return dfa->init_state_begbuf;
+ else if (IS_NEWLINE_CONTEXT (context))
+ return dfa->init_state_nl;
+ else if (IS_BEGBUF_CONTEXT (context))
+ {
+ /* It is relatively rare case, then calculate on demand. */
+ return re_acquire_state_context (err, dfa,
+ dfa->init_state->entrance_nodes,
+ context);
+ }
+ else
+ /* Must not happen? */
+ return dfa->init_state;
+ }
+ else
+ return dfa->init_state;
+}
+
+/* Check whether the regular expression match input string INPUT or not,
+ and return the index where the matching end, return -1 if not match,
+ or return -2 in case of an error.
+ FL_LONGEST_MATCH means we want the POSIX longest matching.
+ If P_MATCH_FIRST is not NULL, and the match fails, it is set to the
+ next place where we may want to try matching.
+ Note that the matcher assume that the maching starts from the current
+ index of the buffer. */
+
+static int
+internal_function
+check_matching (re_match_context_t *mctx, int fl_longest_match,
+ int *p_match_first)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ reg_errcode_t err;
+ int match = 0;
+ int match_last = -1;
+ int cur_str_idx = re_string_cur_idx (&mctx->input);
+ re_dfastate_t *cur_state;
+ int at_init_state = p_match_first != NULL;
+ int next_start_idx = cur_str_idx;
+
+ err = REG_NOERROR;
+ cur_state = acquire_init_state_context (&err, mctx, cur_str_idx);
+ /* An initial state must not be NULL (invalid). */
+ if (BE (cur_state == NULL, 0))
+ {
+ assert (err == REG_ESPACE);
+ return -2;
+ }
+
+ if (mctx->state_log != NULL)
+ {
+ mctx->state_log[cur_str_idx] = cur_state;
+
+ /* Check OP_OPEN_SUBEXP in the initial state in case that we use them
+ later. E.g. Processing back references. */
+ if (BE (dfa->nbackref, 0))
+ {
+ at_init_state = 0;
+ err = check_subexp_matching_top (mctx, &cur_state->nodes, 0);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+
+ if (cur_state->has_backref)
+ {
+ err = transit_state_bkref (mctx, &cur_state->nodes);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+ }
+ }
+ }
+
+ /* If the RE accepts NULL string. */
+ if (BE (cur_state->halt, 0))
+ {
+ if (!cur_state->has_constraint
+ || check_halt_state_context (mctx, cur_state, cur_str_idx))
+ {
+ if (!fl_longest_match)
+ return cur_str_idx;
+ else
+ {
+ match_last = cur_str_idx;
+ match = 1;
+ }
+ }
+ }
+
+ while (!re_string_eoi (&mctx->input))
+ {
+ re_dfastate_t *old_state = cur_state;
+ int next_char_idx = re_string_cur_idx (&mctx->input) + 1;
+
+ if (BE (next_char_idx >= mctx->input.bufs_len, 0)
+ || (BE (next_char_idx >= mctx->input.valid_len, 0)
+ && mctx->input.valid_len < mctx->input.len))
+ {
+ err = extend_buffers (mctx);
+ if (BE (err != REG_NOERROR, 0))
+ {
+ assert (err == REG_ESPACE);
+ return -2;
+ }
+ }
+
+ cur_state = transit_state (&err, mctx, cur_state);
+ if (mctx->state_log != NULL)
+ cur_state = merge_state_with_log (&err, mctx, cur_state);
+
+ if (cur_state == NULL)
+ {
+ /* Reached the invalid state or an error. Try to recover a valid
+ state using the state log, if available and if we have not
+ already found a valid (even if not the longest) match. */
+ if (BE (err != REG_NOERROR, 0))
+ return -2;
+
+ if (mctx->state_log == NULL
+ || (match && !fl_longest_match)
+ || (cur_state = find_recover_state (&err, mctx)) == NULL)
+ break;
+ }
+
+ if (BE (at_init_state, 0))
+ {
+ if (old_state == cur_state)
+ next_start_idx = next_char_idx;
+ else
+ at_init_state = 0;
+ }
+
+ if (cur_state->halt)
+ {
+ /* Reached a halt state.
+ Check the halt state can satisfy the current context. */
+ if (!cur_state->has_constraint
+ || check_halt_state_context (mctx, cur_state,
+ re_string_cur_idx (&mctx->input)))
+ {
+ /* We found an appropriate halt state. */
+ match_last = re_string_cur_idx (&mctx->input);
+ match = 1;
+
+ /* We found a match, do not modify match_first below. */
+ p_match_first = NULL;
+ if (!fl_longest_match)
+ break;
+ }
+ }
+ }
+
+ if (p_match_first)
+ *p_match_first += next_start_idx;
+
+ return match_last;
+}
+
+/* Check NODE match the current context. */
+
+static int
+internal_function
+check_halt_node_context (const re_dfa_t *dfa, int node, unsigned int context)
+{
+ re_token_type_t type = dfa->nodes[node].type;
+ unsigned int constraint = dfa->nodes[node].constraint;
+ if (type != END_OF_RE)
+ return 0;
+ if (!constraint)
+ return 1;
+ if (NOT_SATISFY_NEXT_CONSTRAINT (constraint, context))
+ return 0;
+ return 1;
+}
+
+/* Check the halt state STATE match the current context.
+ Return 0 if not match, if the node, STATE has, is a halt node and
+ match the context, return the node. */
+
+static int
+internal_function
+check_halt_state_context (const re_match_context_t *mctx,
+ const re_dfastate_t *state, int idx)
+{
+ int i;
+ unsigned int context;
+#ifdef DEBUG
+ assert (state->halt);
+#endif
+ context = re_string_context_at (&mctx->input, idx, mctx->eflags);
+ for (i = 0; i < state->nodes.nelem; ++i)
+ if (check_halt_node_context (mctx->dfa, state->nodes.elems[i], context))
+ return state->nodes.elems[i];
+ return 0;
+}
+
+/* Compute the next node to which "NFA" transit from NODE("NFA" is a NFA
+ corresponding to the DFA).
+ Return the destination node, and update EPS_VIA_NODES, return -1 in case
+ of errors. */
+
+static int
+internal_function
+proceed_next_node (const re_match_context_t *mctx, int nregs, regmatch_t *regs,
+ int *pidx, int node, re_node_set *eps_via_nodes,
+ struct re_fail_stack_t *fs)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ int i, err;
+ if (IS_EPSILON_NODE (dfa->nodes[node].type))
+ {
+ re_node_set *cur_nodes = &mctx->state_log[*pidx]->nodes;
+ re_node_set *edests = &dfa->edests[node];
+ int dest_node;
+ err = re_node_set_insert (eps_via_nodes, node);
+ if (BE (err < 0, 0))
+ return -2;
+ /* Pick up a valid destination, or return -1 if none is found. */
+ for (dest_node = -1, i = 0; i < edests->nelem; ++i)
+ {
+ int candidate = edests->elems[i];
+ if (!re_node_set_contains (cur_nodes, candidate))
+ continue;
+ if (dest_node == -1)
+ dest_node = candidate;
+
+ else
+ {
+ /* In order to avoid infinite loop like "(a*)*", return the second
+ epsilon-transition if the first was already considered. */
+ if (re_node_set_contains (eps_via_nodes, dest_node))
+ return candidate;
+
+ /* Otherwise, push the second epsilon-transition on the fail stack. */
+ else if (fs != NULL
+ && push_fail_stack (fs, *pidx, candidate, nregs, regs,
+ eps_via_nodes))
+ return -2;
+
+ /* We know we are going to exit. */
+ break;
+ }
+ }
+ return dest_node;
+ }
+ else
+ {
+ int naccepted = 0;
+ re_token_type_t type = dfa->nodes[node].type;
+
+#ifdef RE_ENABLE_I18N
+ if (dfa->nodes[node].accept_mb)
+ naccepted = check_node_accept_bytes (dfa, node, &mctx->input, *pidx);
+ else
+#endif /* RE_ENABLE_I18N */
+ if (type == OP_BACK_REF)
+ {
+ int subexp_idx = dfa->nodes[node].opr.idx + 1;
+ naccepted = regs[subexp_idx].rm_eo - regs[subexp_idx].rm_so;
+ if (fs != NULL)
+ {
+ if (regs[subexp_idx].rm_so == -1 || regs[subexp_idx].rm_eo == -1)
+ return -1;
+ else if (naccepted)
+ {
+ char *buf = (char *) re_string_get_buffer (&mctx->input);
+ if (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx,
+ naccepted) != 0)
+ return -1;
+ }
+ }
+
+ if (naccepted == 0)
+ {
+ int dest_node;
+ err = re_node_set_insert (eps_via_nodes, node);
+ if (BE (err < 0, 0))
+ return -2;
+ dest_node = dfa->edests[node].elems[0];
+ if (re_node_set_contains (&mctx->state_log[*pidx]->nodes,
+ dest_node))
+ return dest_node;
+ }
+ }
+
+ if (naccepted != 0
+ || check_node_accept (mctx, dfa->nodes + node, *pidx))
+ {
+ int dest_node = dfa->nexts[node];
+ *pidx = (naccepted == 0) ? *pidx + 1 : *pidx + naccepted;
+ if (fs && (*pidx > mctx->match_last || mctx->state_log[*pidx] == NULL
+ || !re_node_set_contains (&mctx->state_log[*pidx]->nodes,
+ dest_node)))
+ return -1;
+ re_node_set_empty (eps_via_nodes);
+ return dest_node;
+ }
+ }
+ return -1;
+}
+
+static reg_errcode_t
+internal_function
+push_fail_stack (struct re_fail_stack_t *fs, int str_idx, int dest_node,
+ int nregs, regmatch_t *regs, re_node_set *eps_via_nodes)
+{
+ reg_errcode_t err;
+ int num = fs->num++;
+ if (fs->num == fs->alloc)
+ {
+ struct re_fail_stack_ent_t *new_array;
+ new_array = realloc (fs->stack, (sizeof (struct re_fail_stack_ent_t)
+ * fs->alloc * 2));
+ if (new_array == NULL)
+ return REG_ESPACE;
+ fs->alloc *= 2;
+ fs->stack = new_array;
+ }
+ fs->stack[num].idx = str_idx;
+ fs->stack[num].node = dest_node;
+ fs->stack[num].regs = re_malloc (regmatch_t, nregs);
+ if (fs->stack[num].regs == NULL)
+ return REG_ESPACE;
+ memcpy (fs->stack[num].regs, regs, sizeof (regmatch_t) * nregs);
+ err = re_node_set_init_copy (&fs->stack[num].eps_via_nodes, eps_via_nodes);
+ return err;
+}
+
+static int
+internal_function
+pop_fail_stack (struct re_fail_stack_t *fs, int *pidx, int nregs,
+ regmatch_t *regs, re_node_set *eps_via_nodes)
+{
+ int num = --fs->num;
+ assert (num >= 0);
+ *pidx = fs->stack[num].idx;
+ memcpy (regs, fs->stack[num].regs, sizeof (regmatch_t) * nregs);
+ re_node_set_free (eps_via_nodes);
+ re_free (fs->stack[num].regs);
+ *eps_via_nodes = fs->stack[num].eps_via_nodes;
+ return fs->stack[num].node;
+}
+
+/* Set the positions where the subexpressions are starts/ends to registers
+ PMATCH.
+ Note: We assume that pmatch[0] is already set, and
+ pmatch[i].rm_so == pmatch[i].rm_eo == -1 for 0 < i < nmatch. */
+
+static reg_errcode_t
+internal_function
+set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch,
+ regmatch_t *pmatch, int fl_backtrack)
+{
+ const re_dfa_t *dfa = (const re_dfa_t *) preg->buffer;
+ int idx, cur_node;
+ re_node_set eps_via_nodes;
+ struct re_fail_stack_t *fs;
+ struct re_fail_stack_t fs_body = { 0, 2, NULL };
+ regmatch_t *prev_idx_match;
+ int prev_idx_match_malloced = 0;
+
+#ifdef DEBUG
+ assert (nmatch > 1);
+ assert (mctx->state_log != NULL);
+#endif
+ if (fl_backtrack)
+ {
+ fs = &fs_body;
+ fs->stack = re_malloc (struct re_fail_stack_ent_t, fs->alloc);
+ if (fs->stack == NULL)
+ return REG_ESPACE;
+ }
+ else
+ fs = NULL;
+
+ cur_node = dfa->init_node;
+ re_node_set_init_empty (&eps_via_nodes);
+
+ if (__libc_use_alloca (nmatch * sizeof (regmatch_t)))
+ prev_idx_match = (regmatch_t *) alloca (nmatch * sizeof (regmatch_t));
+ else
+ {
+ prev_idx_match = re_malloc (regmatch_t, nmatch);
+ if (prev_idx_match == NULL)
+ {
+ free_fail_stack_return (fs);
+ return REG_ESPACE;
+ }
+ prev_idx_match_malloced = 1;
+ }
+ memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch);
+
+ for (idx = pmatch[0].rm_so; idx <= pmatch[0].rm_eo ;)
+ {
+ update_regs (dfa, pmatch, prev_idx_match, cur_node, idx, nmatch);
+
+ if (idx == pmatch[0].rm_eo && cur_node == mctx->last_node)
+ {
+ int reg_idx;
+ if (fs)
+ {
+ for (reg_idx = 0; reg_idx < nmatch; ++reg_idx)
+ if (pmatch[reg_idx].rm_so > -1 && pmatch[reg_idx].rm_eo == -1)
+ break;
+ if (reg_idx == nmatch)
+ {
+ re_node_set_free (&eps_via_nodes);
+ if (prev_idx_match_malloced)
+ re_free (prev_idx_match);
+ return free_fail_stack_return (fs);
+ }
+ cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch,
+ &eps_via_nodes);
+ }
+ else
+ {
+ re_node_set_free (&eps_via_nodes);
+ if (prev_idx_match_malloced)
+ re_free (prev_idx_match);
+ return REG_NOERROR;
+ }
+ }
+
+ /* Proceed to next node. */
+ cur_node = proceed_next_node (mctx, nmatch, pmatch, &idx, cur_node,
+ &eps_via_nodes, fs);
+
+ if (BE (cur_node < 0, 0))
+ {
+ if (BE (cur_node == -2, 0))
+ {
+ re_node_set_free (&eps_via_nodes);
+ if (prev_idx_match_malloced)
+ re_free (prev_idx_match);
+ free_fail_stack_return (fs);
+ return REG_ESPACE;
+ }
+ if (fs)
+ cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch,
+ &eps_via_nodes);
+ else
+ {
+ re_node_set_free (&eps_via_nodes);
+ if (prev_idx_match_malloced)
+ re_free (prev_idx_match);
+ return REG_NOMATCH;
+ }
+ }
+ }
+ re_node_set_free (&eps_via_nodes);
+ if (prev_idx_match_malloced)
+ re_free (prev_idx_match);
+ return free_fail_stack_return (fs);
+}
+
+static reg_errcode_t
+internal_function
+free_fail_stack_return (struct re_fail_stack_t *fs)
+{
+ if (fs)
+ {
+ int fs_idx;
+ for (fs_idx = 0; fs_idx < fs->num; ++fs_idx)
+ {
+ re_node_set_free (&fs->stack[fs_idx].eps_via_nodes);
+ re_free (fs->stack[fs_idx].regs);
+ }
+ re_free (fs->stack);
+ }
+ return REG_NOERROR;
+}
+
+static void
+internal_function
+update_regs (const re_dfa_t *dfa, regmatch_t *pmatch,
+ regmatch_t *prev_idx_match, int cur_node, int cur_idx, int nmatch)
+{
+ int type = dfa->nodes[cur_node].type;
+ if (type == OP_OPEN_SUBEXP)
+ {
+ int reg_num = dfa->nodes[cur_node].opr.idx + 1;
+
+ /* We are at the first node of this sub expression. */
+ if (reg_num < nmatch)
+ {
+ pmatch[reg_num].rm_so = cur_idx;
+ pmatch[reg_num].rm_eo = -1;
+ }
+ }
+ else if (type == OP_CLOSE_SUBEXP)
+ {
+ int reg_num = dfa->nodes[cur_node].opr.idx + 1;
+ if (reg_num < nmatch)
+ {
+ /* We are at the last node of this sub expression. */
+ if (pmatch[reg_num].rm_so < cur_idx)
+ {
+ pmatch[reg_num].rm_eo = cur_idx;
+ /* This is a non-empty match or we are not inside an optional
+ subexpression. Accept this right away. */
+ memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch);
+ }
+ else
+ {
+ if (dfa->nodes[cur_node].opt_subexp
+ && prev_idx_match[reg_num].rm_so != -1)
+ /* We transited through an empty match for an optional
+ subexpression, like (a?)*, and this is not the subexp's
+ first match. Copy back the old content of the registers
+ so that matches of an inner subexpression are undone as
+ well, like in ((a?))*. */
+ memcpy (pmatch, prev_idx_match, sizeof (regmatch_t) * nmatch);
+ else
+ /* We completed a subexpression, but it may be part of
+ an optional one, so do not update PREV_IDX_MATCH. */
+ pmatch[reg_num].rm_eo = cur_idx;
+ }
+ }
+ }
+}
+
+/* This function checks the STATE_LOG from the SCTX->last_str_idx to 0
+ and sift the nodes in each states according to the following rules.
+ Updated state_log will be wrote to STATE_LOG.
+
+ Rules: We throw away the Node `a' in the STATE_LOG[STR_IDX] if...
+ 1. When STR_IDX == MATCH_LAST(the last index in the state_log):
+ If `a' isn't the LAST_NODE and `a' can't epsilon transit to
+ the LAST_NODE, we throw away the node `a'.
+ 2. When 0 <= STR_IDX < MATCH_LAST and `a' accepts
+ string `s' and transit to `b':
+ i. If 'b' isn't in the STATE_LOG[STR_IDX+strlen('s')], we throw
+ away the node `a'.
+ ii. If 'b' is in the STATE_LOG[STR_IDX+strlen('s')] but 'b' is
+ thrown away, we throw away the node `a'.
+ 3. When 0 <= STR_IDX < MATCH_LAST and 'a' epsilon transit to 'b':
+ i. If 'b' isn't in the STATE_LOG[STR_IDX], we throw away the
+ node `a'.
+ ii. If 'b' is in the STATE_LOG[STR_IDX] but 'b' is thrown away,
+ we throw away the node `a'. */
+
+#define STATE_NODE_CONTAINS(state,node) \
+ ((state) != NULL && re_node_set_contains (&(state)->nodes, node))
+
+static reg_errcode_t
+internal_function
+sift_states_backward (const re_match_context_t *mctx, re_sift_context_t *sctx)
+{
+ reg_errcode_t err;
+ int null_cnt = 0;
+ int str_idx = sctx->last_str_idx;
+ re_node_set cur_dest;
+
+#ifdef DEBUG
+ assert (mctx->state_log != NULL && mctx->state_log[str_idx] != NULL);
+#endif
+
+ /* Build sifted state_log[str_idx]. It has the nodes which can epsilon
+ transit to the last_node and the last_node itself. */
+ err = re_node_set_init_1 (&cur_dest, sctx->last_node);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+ err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest);
+ if (BE (err != REG_NOERROR, 0))
+ goto free_return;
+
+ /* Then check each states in the state_log. */
+ while (str_idx > 0)
+ {
+ /* Update counters. */
+ null_cnt = (sctx->sifted_states[str_idx] == NULL) ? null_cnt + 1 : 0;
+ if (null_cnt > mctx->max_mb_elem_len)
+ {
+ memset (sctx->sifted_states, '\0',
+ sizeof (re_dfastate_t *) * str_idx);
+ re_node_set_free (&cur_dest);
+ return REG_NOERROR;
+ }
+ re_node_set_empty (&cur_dest);
+ --str_idx;
+
+ if (mctx->state_log[str_idx])
+ {
+ err = build_sifted_states (mctx, sctx, str_idx, &cur_dest);
+ if (BE (err != REG_NOERROR, 0))
+ goto free_return;
+ }
+
+ /* Add all the nodes which satisfy the following conditions:
+ - It can epsilon transit to a node in CUR_DEST.
+ - It is in CUR_SRC.
+ And update state_log. */
+ err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest);
+ if (BE (err != REG_NOERROR, 0))
+ goto free_return;
+ }
+ err = REG_NOERROR;
+ free_return:
+ re_node_set_free (&cur_dest);
+ return err;
+}
+
+static reg_errcode_t
+internal_function
+build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx,
+ int str_idx, re_node_set *cur_dest)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ const re_node_set *cur_src = &mctx->state_log[str_idx]->non_eps_nodes;
+ int i;
+
+ /* Then build the next sifted state.
+ We build the next sifted state on `cur_dest', and update
+ `sifted_states[str_idx]' with `cur_dest'.
+ Note:
+ `cur_dest' is the sifted state from `state_log[str_idx + 1]'.
+ `cur_src' points the node_set of the old `state_log[str_idx]'
+ (with the epsilon nodes pre-filtered out). */
+ for (i = 0; i < cur_src->nelem; i++)
+ {
+ int prev_node = cur_src->elems[i];
+ int naccepted = 0;
+ int ret;
+
+#ifdef DEBUG
+ re_token_type_t type = dfa->nodes[prev_node].type;
+ assert (!IS_EPSILON_NODE (type));
+#endif
+#ifdef RE_ENABLE_I18N
+ /* If the node may accept `multi byte'. */
+ if (dfa->nodes[prev_node].accept_mb)
+ naccepted = sift_states_iter_mb (mctx, sctx, prev_node,
+ str_idx, sctx->last_str_idx);
+#endif /* RE_ENABLE_I18N */
+
+ /* We don't check backreferences here.
+ See update_cur_sifted_state(). */
+ if (!naccepted
+ && check_node_accept (mctx, dfa->nodes + prev_node, str_idx)
+ && STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + 1],
+ dfa->nexts[prev_node]))
+ naccepted = 1;
+
+ if (naccepted == 0)
+ continue;
+
+ if (sctx->limits.nelem)
+ {
+ int to_idx = str_idx + naccepted;
+ if (check_dst_limits (mctx, &sctx->limits,
+ dfa->nexts[prev_node], to_idx,
+ prev_node, str_idx))
+ continue;
+ }
+ ret = re_node_set_insert (cur_dest, prev_node);
+ if (BE (ret == -1, 0))
+ return REG_ESPACE;
+ }
+
+ return REG_NOERROR;
+}
+
+/* Helper functions. */
+
+static reg_errcode_t
+internal_function
+clean_state_log_if_needed (re_match_context_t *mctx, int next_state_log_idx)
+{
+ int top = mctx->state_log_top;
+
+ if (next_state_log_idx >= mctx->input.bufs_len
+ || (next_state_log_idx >= mctx->input.valid_len
+ && mctx->input.valid_len < mctx->input.len))
+ {
+ reg_errcode_t err;
+ err = extend_buffers (mctx);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+ }
+
+ if (top < next_state_log_idx)
+ {
+ memset (mctx->state_log + top + 1, '\0',
+ sizeof (re_dfastate_t *) * (next_state_log_idx - top));
+ mctx->state_log_top = next_state_log_idx;
+ }
+ return REG_NOERROR;
+}
+
+static reg_errcode_t
+internal_function
+merge_state_array (const re_dfa_t *dfa, re_dfastate_t **dst,
+ re_dfastate_t **src, int num)
+{
+ int st_idx;
+ reg_errcode_t err;
+ for (st_idx = 0; st_idx < num; ++st_idx)
+ {
+ if (dst[st_idx] == NULL)
+ dst[st_idx] = src[st_idx];
+ else if (src[st_idx] != NULL)
+ {
+ re_node_set merged_set;
+ err = re_node_set_init_union (&merged_set, &dst[st_idx]->nodes,
+ &src[st_idx]->nodes);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+ dst[st_idx] = re_acquire_state (&err, dfa, &merged_set);
+ re_node_set_free (&merged_set);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+ }
+ }
+ return REG_NOERROR;
+}
+
+static reg_errcode_t
+internal_function
+update_cur_sifted_state (const re_match_context_t *mctx,
+ re_sift_context_t *sctx, int str_idx,
+ re_node_set *dest_nodes)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ reg_errcode_t err = REG_NOERROR;
+ const re_node_set *candidates;
+ candidates = ((mctx->state_log[str_idx] == NULL) ? NULL
+ : &mctx->state_log[str_idx]->nodes);
+
+ if (dest_nodes->nelem == 0)
+ sctx->sifted_states[str_idx] = NULL;
+ else
+ {
+ if (candidates)
+ {
+ /* At first, add the nodes which can epsilon transit to a node in
+ DEST_NODE. */
+ err = add_epsilon_src_nodes (dfa, dest_nodes, candidates);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+
+ /* Then, check the limitations in the current sift_context. */
+ if (sctx->limits.nelem)
+ {
+ err = check_subexp_limits (dfa, dest_nodes, candidates, &sctx->limits,
+ mctx->bkref_ents, str_idx);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+ }
+ }
+
+ sctx->sifted_states[str_idx] = re_acquire_state (&err, dfa, dest_nodes);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+ }
+
+ if (candidates && mctx->state_log[str_idx]->has_backref)
+ {
+ err = sift_states_bkref (mctx, sctx, str_idx, candidates);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+ }
+ return REG_NOERROR;
+}
+
+static reg_errcode_t
+internal_function
+add_epsilon_src_nodes (const re_dfa_t *dfa, re_node_set *dest_nodes,
+ const re_node_set *candidates)
+{
+ reg_errcode_t err = REG_NOERROR;
+ int i;
+
+ re_dfastate_t *state = re_acquire_state (&err, dfa, dest_nodes);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+
+ if (!state->inveclosure.alloc)
+ {
+ err = re_node_set_alloc (&state->inveclosure, dest_nodes->nelem);
+ if (BE (err != REG_NOERROR, 0))
+ return REG_ESPACE;
+ for (i = 0; i < dest_nodes->nelem; i++)
+ re_node_set_merge (&state->inveclosure,
+ dfa->inveclosures + dest_nodes->elems[i]);
+ }
+ return re_node_set_add_intersect (dest_nodes, candidates,
+ &state->inveclosure);
+}
+
+static reg_errcode_t
+internal_function
+sub_epsilon_src_nodes (const re_dfa_t *dfa, int node, re_node_set *dest_nodes,
+ const re_node_set *candidates)
+{
+ int ecl_idx;
+ reg_errcode_t err;
+ re_node_set *inv_eclosure = dfa->inveclosures + node;
+ re_node_set except_nodes;
+ re_node_set_init_empty (&except_nodes);
+ for (ecl_idx = 0; ecl_idx < inv_eclosure->nelem; ++ecl_idx)
+ {
+ int cur_node = inv_eclosure->elems[ecl_idx];
+ if (cur_node == node)
+ continue;
+ if (IS_EPSILON_NODE (dfa->nodes[cur_node].type))
+ {
+ int edst1 = dfa->edests[cur_node].elems[0];
+ int edst2 = ((dfa->edests[cur_node].nelem > 1)
+ ? dfa->edests[cur_node].elems[1] : -1);
+ if ((!re_node_set_contains (inv_eclosure, edst1)
+ && re_node_set_contains (dest_nodes, edst1))
+ || (edst2 > 0
+ && !re_node_set_contains (inv_eclosure, edst2)
+ && re_node_set_contains (dest_nodes, edst2)))
+ {
+ err = re_node_set_add_intersect (&except_nodes, candidates,
+ dfa->inveclosures + cur_node);
+ if (BE (err != REG_NOERROR, 0))
+ {
+ re_node_set_free (&except_nodes);
+ return err;
+ }
+ }
+ }
+ }
+ for (ecl_idx = 0; ecl_idx < inv_eclosure->nelem; ++ecl_idx)
+ {
+ int cur_node = inv_eclosure->elems[ecl_idx];
+ if (!re_node_set_contains (&except_nodes, cur_node))
+ {
+ int idx = re_node_set_contains (dest_nodes, cur_node) - 1;
+ re_node_set_remove_at (dest_nodes, idx);
+ }
+ }
+ re_node_set_free (&except_nodes);
+ return REG_NOERROR;
+}
+
+static int
+internal_function
+check_dst_limits (const re_match_context_t *mctx, re_node_set *limits,
+ int dst_node, int dst_idx, int src_node, int src_idx)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ int lim_idx, src_pos, dst_pos;
+
+ int dst_bkref_idx = search_cur_bkref_entry (mctx, dst_idx);
+ int src_bkref_idx = search_cur_bkref_entry (mctx, src_idx);
+ for (lim_idx = 0; lim_idx < limits->nelem; ++lim_idx)
+ {
+ int subexp_idx;
+ struct re_backref_cache_entry *ent;
+ ent = mctx->bkref_ents + limits->elems[lim_idx];
+ subexp_idx = dfa->nodes[ent->node].opr.idx;
+
+ dst_pos = check_dst_limits_calc_pos (mctx, limits->elems[lim_idx],
+ subexp_idx, dst_node, dst_idx,
+ dst_bkref_idx);
+ src_pos = check_dst_limits_calc_pos (mctx, limits->elems[lim_idx],
+ subexp_idx, src_node, src_idx,
+ src_bkref_idx);
+
+ /* In case of:
+ <src> <dst> ( <subexp> )
+ ( <subexp> ) <src> <dst>
+ ( <subexp1> <src> <subexp2> <dst> <subexp3> ) */
+ if (src_pos == dst_pos)
+ continue; /* This is unrelated limitation. */
+ else
+ return 1;
+ }
+ return 0;
+}
+
+static int
+internal_function
+check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, int boundaries,
+ int subexp_idx, int from_node, int bkref_idx)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ const re_node_set *eclosures = dfa->eclosures + from_node;
+ int node_idx;
+
+ /* Else, we are on the boundary: examine the nodes on the epsilon
+ closure. */
+ for (node_idx = 0; node_idx < eclosures->nelem; ++node_idx)
+ {
+ int node = eclosures->elems[node_idx];
+ switch (dfa->nodes[node].type)
+ {
+ case OP_BACK_REF:
+ if (bkref_idx != -1)
+ {
+ struct re_backref_cache_entry *ent = mctx->bkref_ents + bkref_idx;
+ do
+ {
+ int dst, cpos;
+
+ if (ent->node != node)
+ continue;
+
+ if (subexp_idx < BITSET_WORD_BITS
+ && !(ent->eps_reachable_subexps_map
+ & ((bitset_word_t) 1 << subexp_idx)))
+ continue;
+
+ /* Recurse trying to reach the OP_OPEN_SUBEXP and
+ OP_CLOSE_SUBEXP cases below. But, if the
+ destination node is the same node as the source
+ node, don't recurse because it would cause an
+ infinite loop: a regex that exhibits this behavior
+ is ()\1*\1* */
+ dst = dfa->edests[node].elems[0];
+ if (dst == from_node)
+ {
+ if (boundaries & 1)
+ return -1;
+ else /* if (boundaries & 2) */
+ return 0;
+ }
+
+ cpos =
+ check_dst_limits_calc_pos_1 (mctx, boundaries, subexp_idx,
+ dst, bkref_idx);
+ if (cpos == -1 /* && (boundaries & 1) */)
+ return -1;
+ if (cpos == 0 && (boundaries & 2))
+ return 0;
+
+ if (subexp_idx < BITSET_WORD_BITS)
+ ent->eps_reachable_subexps_map
+ &= ~((bitset_word_t) 1 << subexp_idx);
+ }
+ while (ent++->more);
+ }
+ break;
+
+ case OP_OPEN_SUBEXP:
+ if ((boundaries & 1) && subexp_idx == dfa->nodes[node].opr.idx)
+ return -1;
+ break;
+
+ case OP_CLOSE_SUBEXP:
+ if ((boundaries & 2) && subexp_idx == dfa->nodes[node].opr.idx)
+ return 0;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ return (boundaries & 2) ? 1 : 0;
+}
+
+static int
+internal_function
+check_dst_limits_calc_pos (const re_match_context_t *mctx, int limit,
+ int subexp_idx, int from_node, int str_idx,
+ int bkref_idx)
+{
+ struct re_backref_cache_entry *lim = mctx->bkref_ents + limit;
+ int boundaries;
+
+ /* If we are outside the range of the subexpression, return -1 or 1. */
+ if (str_idx < lim->subexp_from)
+ return -1;
+
+ if (lim->subexp_to < str_idx)
+ return 1;
+
+ /* If we are within the subexpression, return 0. */
+ boundaries = (str_idx == lim->subexp_from);
+ boundaries |= (str_idx == lim->subexp_to) << 1;
+ if (boundaries == 0)
+ return 0;
+
+ /* Else, examine epsilon closure. */
+ return check_dst_limits_calc_pos_1 (mctx, boundaries, subexp_idx,
+ from_node, bkref_idx);
+}
+
+/* Check the limitations of sub expressions LIMITS, and remove the nodes
+ which are against limitations from DEST_NODES. */
+
+static reg_errcode_t
+internal_function
+check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes,
+ const re_node_set *candidates, re_node_set *limits,
+ struct re_backref_cache_entry *bkref_ents, int str_idx)
+{
+ reg_errcode_t err;
+ int node_idx, lim_idx;
+
+ for (lim_idx = 0; lim_idx < limits->nelem; ++lim_idx)
+ {
+ int subexp_idx;
+ struct re_backref_cache_entry *ent;
+ ent = bkref_ents + limits->elems[lim_idx];
+
+ if (str_idx <= ent->subexp_from || ent->str_idx < str_idx)
+ continue; /* This is unrelated limitation. */
+
+ subexp_idx = dfa->nodes[ent->node].opr.idx;
+ if (ent->subexp_to == str_idx)
+ {
+ int ops_node = -1;
+ int cls_node = -1;
+ for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx)
+ {
+ int node = dest_nodes->elems[node_idx];
+ re_token_type_t type = dfa->nodes[node].type;
+ if (type == OP_OPEN_SUBEXP
+ && subexp_idx == dfa->nodes[node].opr.idx)
+ ops_node = node;
+ else if (type == OP_CLOSE_SUBEXP
+ && subexp_idx == dfa->nodes[node].opr.idx)
+ cls_node = node;
+ }
+
+ /* Check the limitation of the open subexpression. */
+ /* Note that (ent->subexp_to = str_idx != ent->subexp_from). */
+ if (ops_node >= 0)
+ {
+ err = sub_epsilon_src_nodes (dfa, ops_node, dest_nodes,
+ candidates);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+ }
+
+ /* Check the limitation of the close subexpression. */
+ if (cls_node >= 0)
+ for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx)
+ {
+ int node = dest_nodes->elems[node_idx];
+ if (!re_node_set_contains (dfa->inveclosures + node,
+ cls_node)
+ && !re_node_set_contains (dfa->eclosures + node,
+ cls_node))
+ {
+ /* It is against this limitation.
+ Remove it form the current sifted state. */
+ err = sub_epsilon_src_nodes (dfa, node, dest_nodes,
+ candidates);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+ --node_idx;
+ }
+ }
+ }
+ else /* (ent->subexp_to != str_idx) */
+ {
+ for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx)
+ {
+ int node = dest_nodes->elems[node_idx];
+ re_token_type_t type = dfa->nodes[node].type;
+ if (type == OP_CLOSE_SUBEXP || type == OP_OPEN_SUBEXP)
+ {
+ if (subexp_idx != dfa->nodes[node].opr.idx)
+ continue;
+ /* It is against this limitation.
+ Remove it form the current sifted state. */
+ err = sub_epsilon_src_nodes (dfa, node, dest_nodes,
+ candidates);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+ }
+ }
+ }
+ }
+ return REG_NOERROR;
+}
+
+static reg_errcode_t
+internal_function
+sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx,
+ int str_idx, const re_node_set *candidates)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ reg_errcode_t err;
+ int node_idx, node;
+ re_sift_context_t local_sctx;
+ int first_idx = search_cur_bkref_entry (mctx, str_idx);
+
+ if (first_idx == -1)
+ return REG_NOERROR;
+
+ local_sctx.sifted_states = NULL; /* Mark that it hasn't been initialized. */
+
+ for (node_idx = 0; node_idx < candidates->nelem; ++node_idx)
+ {
+ int enabled_idx;
+ re_token_type_t type;
+ struct re_backref_cache_entry *entry;
+ node = candidates->elems[node_idx];
+ type = dfa->nodes[node].type;
+ /* Avoid infinite loop for the REs like "()\1+". */
+ if (node == sctx->last_node && str_idx == sctx->last_str_idx)
+ continue;
+ if (type != OP_BACK_REF)
+ continue;
+
+ entry = mctx->bkref_ents + first_idx;
+ enabled_idx = first_idx;
+ do
+ {
+ int subexp_len;
+ int to_idx;
+ int dst_node;
+ int ret;
+ re_dfastate_t *cur_state;
+
+ if (entry->node != node)
+ continue;
+ subexp_len = entry->subexp_to - entry->subexp_from;
+ to_idx = str_idx + subexp_len;
+ dst_node = (subexp_len ? dfa->nexts[node]
+ : dfa->edests[node].elems[0]);
+
+ if (to_idx > sctx->last_str_idx
+ || sctx->sifted_states[to_idx] == NULL
+ || !STATE_NODE_CONTAINS (sctx->sifted_states[to_idx], dst_node)
+ || check_dst_limits (mctx, &sctx->limits, node,
+ str_idx, dst_node, to_idx))
+ continue;
+
+ if (local_sctx.sifted_states == NULL)
+ {
+ local_sctx = *sctx;
+ err = re_node_set_init_copy (&local_sctx.limits, &sctx->limits);
+ if (BE (err != REG_NOERROR, 0))
+ goto free_return;
+ }
+ local_sctx.last_node = node;
+ local_sctx.last_str_idx = str_idx;
+ ret = re_node_set_insert (&local_sctx.limits, enabled_idx);
+ if (BE (ret < 0, 0))
+ {
+ err = REG_ESPACE;
+ goto free_return;
+ }
+ cur_state = local_sctx.sifted_states[str_idx];
+ err = sift_states_backward (mctx, &local_sctx);
+ if (BE (err != REG_NOERROR, 0))
+ goto free_return;
+ if (sctx->limited_states != NULL)
+ {
+ err = merge_state_array (dfa, sctx->limited_states,
+ local_sctx.sifted_states,
+ str_idx + 1);
+ if (BE (err != REG_NOERROR, 0))
+ goto free_return;
+ }
+ local_sctx.sifted_states[str_idx] = cur_state;
+ re_node_set_remove (&local_sctx.limits, enabled_idx);
+
+ /* mctx->bkref_ents may have changed, reload the pointer. */
+ entry = mctx->bkref_ents + enabled_idx;
+ }
+ while (enabled_idx++, entry++->more);
+ }
+ err = REG_NOERROR;
+ free_return:
+ if (local_sctx.sifted_states != NULL)
+ {
+ re_node_set_free (&local_sctx.limits);
+ }
+
+ return err;
+}
+
+
+#ifdef RE_ENABLE_I18N
+static int
+internal_function
+sift_states_iter_mb (const re_match_context_t *mctx, re_sift_context_t *sctx,
+ int node_idx, int str_idx, int max_str_idx)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ int naccepted;
+ /* Check the node can accept `multi byte'. */
+ naccepted = check_node_accept_bytes (dfa, node_idx, &mctx->input, str_idx);
+ if (naccepted > 0 && str_idx + naccepted <= max_str_idx &&
+ !STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + naccepted],
+ dfa->nexts[node_idx]))
+ /* The node can't accept the `multi byte', or the
+ destination was already thrown away, then the node
+ could't accept the current input `multi byte'. */
+ naccepted = 0;
+ /* Otherwise, it is sure that the node could accept
+ `naccepted' bytes input. */
+ return naccepted;
+}
+#endif /* RE_ENABLE_I18N */
+
+
+/* Functions for state transition. */
+
+/* Return the next state to which the current state STATE will transit by
+ accepting the current input byte, and update STATE_LOG if necessary.
+ If STATE can accept a multibyte char/collating element/back reference
+ update the destination of STATE_LOG. */
+
+static re_dfastate_t *
+internal_function
+transit_state (reg_errcode_t *err, re_match_context_t *mctx,
+ re_dfastate_t *state)
+{
+ re_dfastate_t **trtable;
+ unsigned char ch;
+
+#ifdef RE_ENABLE_I18N
+ /* If the current state can accept multibyte. */
+ if (BE (state->accept_mb, 0))
+ {
+ *err = transit_state_mb (mctx, state);
+ if (BE (*err != REG_NOERROR, 0))
+ return NULL;
+ }
+#endif /* RE_ENABLE_I18N */
+
+ /* Then decide the next state with the single byte. */
+#if 0
+ if (0)
+ /* don't use transition table */
+ return transit_state_sb (err, mctx, state);
+#endif
+
+ /* Use transition table */
+ ch = re_string_fetch_byte (&mctx->input);
+ for (;;)
+ {
+ trtable = state->trtable;
+ if (BE (trtable != NULL, 1))
+ return trtable[ch];
+
+ trtable = state->word_trtable;
+ if (BE (trtable != NULL, 1))
+ {
+ unsigned int context;
+ context
+ = re_string_context_at (&mctx->input,
+ re_string_cur_idx (&mctx->input) - 1,
+ mctx->eflags);
+ if (IS_WORD_CONTEXT (context))
+ return trtable[ch + SBC_MAX];
+ else
+ return trtable[ch];
+ }
+
+ if (!build_trtable (mctx->dfa, state))
+ {
+ *err = REG_ESPACE;
+ return NULL;
+ }
+
+ /* Retry, we now have a transition table. */
+ }
+}
+
+/* Update the state_log if we need */
+re_dfastate_t *
+internal_function
+merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
+ re_dfastate_t *next_state)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ int cur_idx = re_string_cur_idx (&mctx->input);
+
+ if (cur_idx > mctx->state_log_top)
+ {
+ mctx->state_log[cur_idx] = next_state;
+ mctx->state_log_top = cur_idx;
+ }
+ else if (mctx->state_log[cur_idx] == 0)
+ {
+ mctx->state_log[cur_idx] = next_state;
+ }
+ else
+ {
+ re_dfastate_t *pstate;
+ unsigned int context;
+ re_node_set next_nodes, *log_nodes, *table_nodes = NULL;
+ /* If (state_log[cur_idx] != 0), it implies that cur_idx is
+ the destination of a multibyte char/collating element/
+ back reference. Then the next state is the union set of
+ these destinations and the results of the transition table. */
+ pstate = mctx->state_log[cur_idx];
+ log_nodes = pstate->entrance_nodes;
+ if (next_state != NULL)
+ {
+ table_nodes = next_state->entrance_nodes;
+ *err = re_node_set_init_union (&next_nodes, table_nodes,
+ log_nodes);
+ if (BE (*err != REG_NOERROR, 0))
+ return NULL;
+ }
+ else
+ next_nodes = *log_nodes;
+ /* Note: We already add the nodes of the initial state,
+ then we don't need to add them here. */
+
+ context = re_string_context_at (&mctx->input,
+ re_string_cur_idx (&mctx->input) - 1,
+ mctx->eflags);
+ next_state = mctx->state_log[cur_idx]
+ = re_acquire_state_context (err, dfa, &next_nodes, context);
+ /* We don't need to check errors here, since the return value of
+ this function is next_state and ERR is already set. */
+
+ if (table_nodes != NULL)
+ re_node_set_free (&next_nodes);
+ }
+
+ if (BE (dfa->nbackref, 0) && next_state != NULL)
+ {
+ /* Check OP_OPEN_SUBEXP in the current state in case that we use them
+ later. We must check them here, since the back references in the
+ next state might use them. */
+ *err = check_subexp_matching_top (mctx, &next_state->nodes,
+ cur_idx);
+ if (BE (*err != REG_NOERROR, 0))
+ return NULL;
+
+ /* If the next state has back references. */
+ if (next_state->has_backref)
+ {
+ *err = transit_state_bkref (mctx, &next_state->nodes);
+ if (BE (*err != REG_NOERROR, 0))
+ return NULL;
+ next_state = mctx->state_log[cur_idx];
+ }
+ }
+
+ return next_state;
+}
+
+/* Skip bytes in the input that correspond to part of a
+ multi-byte match, then look in the log for a state
+ from which to restart matching. */
+re_dfastate_t *
+internal_function
+find_recover_state (reg_errcode_t *err, re_match_context_t *mctx)
+{
+ re_dfastate_t *cur_state;
+ do
+ {
+ int max = mctx->state_log_top;
+ int cur_str_idx = re_string_cur_idx (&mctx->input);
+
+ do
+ {
+ if (++cur_str_idx > max)
+ return NULL;
+ re_string_skip_bytes (&mctx->input, 1);
+ }
+ while (mctx->state_log[cur_str_idx] == NULL);
+
+ cur_state = merge_state_with_log (err, mctx, NULL);
+ }
+ while (*err == REG_NOERROR && cur_state == NULL);
+ return cur_state;
+}
+
+/* Helper functions for transit_state. */
+
+/* From the node set CUR_NODES, pick up the nodes whose types are
+ OP_OPEN_SUBEXP and which have corresponding back references in the regular
+ expression. And register them to use them later for evaluating the
+ correspoding back references. */
+
+static reg_errcode_t
+internal_function
+check_subexp_matching_top (re_match_context_t *mctx, re_node_set *cur_nodes,
+ int str_idx)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ int node_idx;
+ reg_errcode_t err;
+
+ /* TODO: This isn't efficient.
+ Because there might be more than one nodes whose types are
+ OP_OPEN_SUBEXP and whose index is SUBEXP_IDX, we must check all
+ nodes.
+ E.g. RE: (a){2} */
+ for (node_idx = 0; node_idx < cur_nodes->nelem; ++node_idx)
+ {
+ int node = cur_nodes->elems[node_idx];
+ if (dfa->nodes[node].type == OP_OPEN_SUBEXP
+ && dfa->nodes[node].opr.idx < BITSET_WORD_BITS
+ && (dfa->used_bkref_map
+ & ((bitset_word_t) 1 << dfa->nodes[node].opr.idx)))
+ {
+ err = match_ctx_add_subtop (mctx, node, str_idx);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+ }
+ }
+ return REG_NOERROR;
+}
+
+#if 0
+/* Return the next state to which the current state STATE will transit by
+ accepting the current input byte. */
+
+static re_dfastate_t *
+transit_state_sb (reg_errcode_t *err, re_match_context_t *mctx,
+ re_dfastate_t *state)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ re_node_set next_nodes;
+ re_dfastate_t *next_state;
+ int node_cnt, cur_str_idx = re_string_cur_idx (&mctx->input);
+ unsigned int context;
+
+ *err = re_node_set_alloc (&next_nodes, state->nodes.nelem + 1);
+ if (BE (*err != REG_NOERROR, 0))
+ return NULL;
+ for (node_cnt = 0; node_cnt < state->nodes.nelem; ++node_cnt)
+ {
+ int cur_node = state->nodes.elems[node_cnt];
+ if (check_node_accept (mctx, dfa->nodes + cur_node, cur_str_idx))
+ {
+ *err = re_node_set_merge (&next_nodes,
+ dfa->eclosures + dfa->nexts[cur_node]);
+ if (BE (*err != REG_NOERROR, 0))
+ {
+ re_node_set_free (&next_nodes);
+ return NULL;
+ }
+ }
+ }
+ context = re_string_context_at (&mctx->input, cur_str_idx, mctx->eflags);
+ next_state = re_acquire_state_context (err, dfa, &next_nodes, context);
+ /* We don't need to check errors here, since the return value of
+ this function is next_state and ERR is already set. */
+
+ re_node_set_free (&next_nodes);
+ re_string_skip_bytes (&mctx->input, 1);
+ return next_state;
+}
+#endif
+
+#ifdef RE_ENABLE_I18N
+static reg_errcode_t
+internal_function
+transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ reg_errcode_t err;
+ int i;
+
+ for (i = 0; i < pstate->nodes.nelem; ++i)
+ {
+ re_node_set dest_nodes, *new_nodes;
+ int cur_node_idx = pstate->nodes.elems[i];
+ int naccepted, dest_idx;
+ unsigned int context;
+ re_dfastate_t *dest_state;
+
+ if (!dfa->nodes[cur_node_idx].accept_mb)
+ continue;
+
+ if (dfa->nodes[cur_node_idx].constraint)
+ {
+ context = re_string_context_at (&mctx->input,
+ re_string_cur_idx (&mctx->input),
+ mctx->eflags);
+ if (NOT_SATISFY_NEXT_CONSTRAINT (dfa->nodes[cur_node_idx].constraint,
+ context))
+ continue;
+ }
+
+ /* How many bytes the node can accept? */
+ naccepted = check_node_accept_bytes (dfa, cur_node_idx, &mctx->input,
+ re_string_cur_idx (&mctx->input));
+ if (naccepted == 0)
+ continue;
+
+ /* The node can accepts `naccepted' bytes. */
+ dest_idx = re_string_cur_idx (&mctx->input) + naccepted;
+ mctx->max_mb_elem_len = ((mctx->max_mb_elem_len < naccepted) ? naccepted
+ : mctx->max_mb_elem_len);
+ err = clean_state_log_if_needed (mctx, dest_idx);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+#ifdef DEBUG
+ assert (dfa->nexts[cur_node_idx] != -1);
+#endif
+ new_nodes = dfa->eclosures + dfa->nexts[cur_node_idx];
+
+ dest_state = mctx->state_log[dest_idx];
+ if (dest_state == NULL)
+ dest_nodes = *new_nodes;
+ else
+ {
+ err = re_node_set_init_union (&dest_nodes,
+ dest_state->entrance_nodes, new_nodes);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+ }
+ context = re_string_context_at (&mctx->input, dest_idx - 1,
+ mctx->eflags);
+ mctx->state_log[dest_idx]
+ = re_acquire_state_context (&err, dfa, &dest_nodes, context);
+ if (dest_state != NULL)
+ re_node_set_free (&dest_nodes);
+ if (BE (mctx->state_log[dest_idx] == NULL && err != REG_NOERROR, 0))
+ return err;
+ }
+ return REG_NOERROR;
+}
+#endif /* RE_ENABLE_I18N */
+
+static reg_errcode_t
+internal_function
+transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ reg_errcode_t err;
+ int i;
+ int cur_str_idx = re_string_cur_idx (&mctx->input);
+
+ for (i = 0; i < nodes->nelem; ++i)
+ {
+ int dest_str_idx, prev_nelem, bkc_idx;
+ int node_idx = nodes->elems[i];
+ unsigned int context;
+ const re_token_t *node = dfa->nodes + node_idx;
+ re_node_set *new_dest_nodes;
+
+ /* Check whether `node' is a backreference or not. */
+ if (node->type != OP_BACK_REF)
+ continue;
+
+ if (node->constraint)
+ {
+ context = re_string_context_at (&mctx->input, cur_str_idx,
+ mctx->eflags);
+ if (NOT_SATISFY_NEXT_CONSTRAINT (node->constraint, context))
+ continue;
+ }
+
+ /* `node' is a backreference.
+ Check the substring which the substring matched. */
+ bkc_idx = mctx->nbkref_ents;
+ err = get_subexp (mctx, node_idx, cur_str_idx);
+ if (BE (err != REG_NOERROR, 0))
+ goto free_return;
+
+ /* And add the epsilon closures (which is `new_dest_nodes') of
+ the backreference to appropriate state_log. */
+#ifdef DEBUG
+ assert (dfa->nexts[node_idx] != -1);
+#endif
+ for (; bkc_idx < mctx->nbkref_ents; ++bkc_idx)
+ {
+ int subexp_len;
+ re_dfastate_t *dest_state;
+ struct re_backref_cache_entry *bkref_ent;
+ bkref_ent = mctx->bkref_ents + bkc_idx;
+ if (bkref_ent->node != node_idx || bkref_ent->str_idx != cur_str_idx)
+ continue;
+ subexp_len = bkref_ent->subexp_to - bkref_ent->subexp_from;
+ new_dest_nodes = (subexp_len == 0
+ ? dfa->eclosures + dfa->edests[node_idx].elems[0]
+ : dfa->eclosures + dfa->nexts[node_idx]);
+ dest_str_idx = (cur_str_idx + bkref_ent->subexp_to
+ - bkref_ent->subexp_from);
+ context = re_string_context_at (&mctx->input, dest_str_idx - 1,
+ mctx->eflags);
+ dest_state = mctx->state_log[dest_str_idx];
+ prev_nelem = ((mctx->state_log[cur_str_idx] == NULL) ? 0
+ : mctx->state_log[cur_str_idx]->nodes.nelem);
+ /* Add `new_dest_node' to state_log. */
+ if (dest_state == NULL)
+ {
+ mctx->state_log[dest_str_idx]
+ = re_acquire_state_context (&err, dfa, new_dest_nodes,
+ context);
+ if (BE (mctx->state_log[dest_str_idx] == NULL
+ && err != REG_NOERROR, 0))
+ goto free_return;
+ }
+ else
+ {
+ re_node_set dest_nodes;
+ err = re_node_set_init_union (&dest_nodes,
+ dest_state->entrance_nodes,
+ new_dest_nodes);
+ if (BE (err != REG_NOERROR, 0))
+ {
+ re_node_set_free (&dest_nodes);
+ goto free_return;
+ }
+ mctx->state_log[dest_str_idx]
+ = re_acquire_state_context (&err, dfa, &dest_nodes, context);
+ re_node_set_free (&dest_nodes);
+ if (BE (mctx->state_log[dest_str_idx] == NULL
+ && err != REG_NOERROR, 0))
+ goto free_return;
+ }
+ /* We need to check recursively if the backreference can epsilon
+ transit. */
+ if (subexp_len == 0
+ && mctx->state_log[cur_str_idx]->nodes.nelem > prev_nelem)
+ {
+ err = check_subexp_matching_top (mctx, new_dest_nodes,
+ cur_str_idx);
+ if (BE (err != REG_NOERROR, 0))
+ goto free_return;
+ err = transit_state_bkref (mctx, new_dest_nodes);
+ if (BE (err != REG_NOERROR, 0))
+ goto free_return;
+ }
+ }
+ }
+ err = REG_NOERROR;
+ free_return:
+ return err;
+}
+
+/* Enumerate all the candidates which the backreference BKREF_NODE can match
+ at BKREF_STR_IDX, and register them by match_ctx_add_entry().
+ Note that we might collect inappropriate candidates here.
+ However, the cost of checking them strictly here is too high, then we
+ delay these checking for prune_impossible_nodes(). */
+
+static reg_errcode_t
+internal_function
+get_subexp (re_match_context_t *mctx, int bkref_node, int bkref_str_idx)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ int subexp_num, sub_top_idx;
+ const char *buf = (const char *) re_string_get_buffer (&mctx->input);
+ /* Return if we have already checked BKREF_NODE at BKREF_STR_IDX. */
+ int cache_idx = search_cur_bkref_entry (mctx, bkref_str_idx);
+ if (cache_idx != -1)
+ {
+ const struct re_backref_cache_entry *entry
+ = mctx->bkref_ents + cache_idx;
+ do
+ if (entry->node == bkref_node)
+ return REG_NOERROR; /* We already checked it. */
+ while (entry++->more);
+ }
+
+ subexp_num = dfa->nodes[bkref_node].opr.idx;
+
+ /* For each sub expression */
+ for (sub_top_idx = 0; sub_top_idx < mctx->nsub_tops; ++sub_top_idx)
+ {
+ reg_errcode_t err;
+ re_sub_match_top_t *sub_top = mctx->sub_tops[sub_top_idx];
+ re_sub_match_last_t *sub_last;
+ int sub_last_idx, sl_str, bkref_str_off;
+
+ if (dfa->nodes[sub_top->node].opr.idx != subexp_num)
+ continue; /* It isn't related. */
+
+ sl_str = sub_top->str_idx;
+ bkref_str_off = bkref_str_idx;
+ /* At first, check the last node of sub expressions we already
+ evaluated. */
+ for (sub_last_idx = 0; sub_last_idx < sub_top->nlasts; ++sub_last_idx)
+ {
+ int sl_str_diff;
+ sub_last = sub_top->lasts[sub_last_idx];
+ sl_str_diff = sub_last->str_idx - sl_str;
+ /* The matched string by the sub expression match with the substring
+ at the back reference? */
+ if (sl_str_diff > 0)
+ {
+ if (BE (bkref_str_off + sl_str_diff > mctx->input.valid_len, 0))
+ {
+ /* Not enough chars for a successful match. */
+ if (bkref_str_off + sl_str_diff > mctx->input.len)
+ break;
+
+ err = clean_state_log_if_needed (mctx,
+ bkref_str_off
+ + sl_str_diff);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+ buf = (const char *) re_string_get_buffer (&mctx->input);
+ }
+ if (memcmp (buf + bkref_str_off, buf + sl_str, sl_str_diff) != 0)
+ /* We don't need to search this sub expression any more. */
+ break;
+ }
+ bkref_str_off += sl_str_diff;
+ sl_str += sl_str_diff;
+ err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node,
+ bkref_str_idx);
+
+ /* Reload buf, since the preceding call might have reallocated
+ the buffer. */
+ buf = (const char *) re_string_get_buffer (&mctx->input);
+
+ if (err == REG_NOMATCH)
+ continue;
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+ }
+
+ if (sub_last_idx < sub_top->nlasts)
+ continue;
+ if (sub_last_idx > 0)
+ ++sl_str;
+ /* Then, search for the other last nodes of the sub expression. */
+ for (; sl_str <= bkref_str_idx; ++sl_str)
+ {
+ int cls_node, sl_str_off;
+ const re_node_set *nodes;
+ sl_str_off = sl_str - sub_top->str_idx;
+ /* The matched string by the sub expression match with the substring
+ at the back reference? */
+ if (sl_str_off > 0)
+ {
+ if (BE (bkref_str_off >= mctx->input.valid_len, 0))
+ {
+ /* If we are at the end of the input, we cannot match. */
+ if (bkref_str_off >= mctx->input.len)
+ break;
+
+ err = extend_buffers (mctx);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+
+ buf = (const char *) re_string_get_buffer (&mctx->input);
+ }
+ if (buf [bkref_str_off++] != buf[sl_str - 1])
+ break; /* We don't need to search this sub expression
+ any more. */
+ }
+ if (mctx->state_log[sl_str] == NULL)
+ continue;
+ /* Does this state have a ')' of the sub expression? */
+ nodes = &mctx->state_log[sl_str]->nodes;
+ cls_node = find_subexp_node (dfa, nodes, subexp_num,
+ OP_CLOSE_SUBEXP);
+ if (cls_node == -1)
+ continue; /* No. */
+ if (sub_top->path == NULL)
+ {
+ sub_top->path = calloc (sizeof (state_array_t),
+ sl_str - sub_top->str_idx + 1);
+ if (sub_top->path == NULL)
+ return REG_ESPACE;
+ }
+ /* Can the OP_OPEN_SUBEXP node arrive the OP_CLOSE_SUBEXP node
+ in the current context? */
+ err = check_arrival (mctx, sub_top->path, sub_top->node,
+ sub_top->str_idx, cls_node, sl_str,
+ OP_CLOSE_SUBEXP);
+ if (err == REG_NOMATCH)
+ continue;
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+ sub_last = match_ctx_add_sublast (sub_top, cls_node, sl_str);
+ if (BE (sub_last == NULL, 0))
+ return REG_ESPACE;
+ err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node,
+ bkref_str_idx);
+ if (err == REG_NOMATCH)
+ continue;
+ }
+ }
+ return REG_NOERROR;
+}
+
+/* Helper functions for get_subexp(). */
+
+/* Check SUB_LAST can arrive to the back reference BKREF_NODE at BKREF_STR.
+ If it can arrive, register the sub expression expressed with SUB_TOP
+ and SUB_LAST. */
+
+static reg_errcode_t
+internal_function
+get_subexp_sub (re_match_context_t *mctx, const re_sub_match_top_t *sub_top,
+ re_sub_match_last_t *sub_last, int bkref_node, int bkref_str)
+{
+ reg_errcode_t err;
+ int to_idx;
+ /* Can the subexpression arrive the back reference? */
+ err = check_arrival (mctx, &sub_last->path, sub_last->node,
+ sub_last->str_idx, bkref_node, bkref_str,
+ OP_OPEN_SUBEXP);
+ if (err != REG_NOERROR)
+ return err;
+ err = match_ctx_add_entry (mctx, bkref_node, bkref_str, sub_top->str_idx,
+ sub_last->str_idx);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+ to_idx = bkref_str + sub_last->str_idx - sub_top->str_idx;
+ return clean_state_log_if_needed (mctx, to_idx);
+}
+
+/* Find the first node which is '(' or ')' and whose index is SUBEXP_IDX.
+ Search '(' if FL_OPEN, or search ')' otherwise.
+ TODO: This function isn't efficient...
+ Because there might be more than one nodes whose types are
+ OP_OPEN_SUBEXP and whose index is SUBEXP_IDX, we must check all
+ nodes.
+ E.g. RE: (a){2} */
+
+static int
+internal_function
+find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes,
+ int subexp_idx, int type)
+{
+ int cls_idx;
+ for (cls_idx = 0; cls_idx < nodes->nelem; ++cls_idx)
+ {
+ int cls_node = nodes->elems[cls_idx];
+ const re_token_t *node = dfa->nodes + cls_node;
+ if (node->type == type
+ && node->opr.idx == subexp_idx)
+ return cls_node;
+ }
+ return -1;
+}
+
+/* Check whether the node TOP_NODE at TOP_STR can arrive to the node
+ LAST_NODE at LAST_STR. We record the path onto PATH since it will be
+ heavily reused.
+ Return REG_NOERROR if it can arrive, or REG_NOMATCH otherwise. */
+
+static reg_errcode_t
+internal_function
+check_arrival (re_match_context_t *mctx, state_array_t *path, int top_node,
+ int top_str, int last_node, int last_str, int type)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ reg_errcode_t err = REG_NOERROR;
+ int subexp_num, backup_cur_idx, str_idx, null_cnt;
+ re_dfastate_t *cur_state = NULL;
+ re_node_set *cur_nodes, next_nodes;
+ re_dfastate_t **backup_state_log;
+ unsigned int context;
+
+ subexp_num = dfa->nodes[top_node].opr.idx;
+ /* Extend the buffer if we need. */
+ if (BE (path->alloc < last_str + mctx->max_mb_elem_len + 1, 0))
+ {
+ re_dfastate_t **new_array;
+ int old_alloc = path->alloc;
+ path->alloc += last_str + mctx->max_mb_elem_len + 1;
+ new_array = re_realloc (path->array, re_dfastate_t *, path->alloc);
+ if (BE (new_array == NULL, 0))
+ {
+ path->alloc = old_alloc;
+ return REG_ESPACE;
+ }
+ path->array = new_array;
+ memset (new_array + old_alloc, '\0',
+ sizeof (re_dfastate_t *) * (path->alloc - old_alloc));
+ }
+
+ str_idx = path->next_idx ? path->next_idx : top_str;
+
+ /* Temporary modify MCTX. */
+ backup_state_log = mctx->state_log;
+ backup_cur_idx = mctx->input.cur_idx;
+ mctx->state_log = path->array;
+ mctx->input.cur_idx = str_idx;
+
+ /* Setup initial node set. */
+ context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags);
+ if (str_idx == top_str)
+ {
+ err = re_node_set_init_1 (&next_nodes, top_node);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+ err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type);
+ if (BE (err != REG_NOERROR, 0))
+ {
+ re_node_set_free (&next_nodes);
+ return err;
+ }
+ }
+ else
+ {
+ cur_state = mctx->state_log[str_idx];
+ if (cur_state && cur_state->has_backref)
+ {
+ err = re_node_set_init_copy (&next_nodes, &cur_state->nodes);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+ }
+ else
+ re_node_set_init_empty (&next_nodes);
+ }
+ if (str_idx == top_str || (cur_state && cur_state->has_backref))
+ {
+ if (next_nodes.nelem)
+ {
+ err = expand_bkref_cache (mctx, &next_nodes, str_idx,
+ subexp_num, type);
+ if (BE (err != REG_NOERROR, 0))
+ {
+ re_node_set_free (&next_nodes);
+ return err;
+ }
+ }
+ cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context);
+ if (BE (cur_state == NULL && err != REG_NOERROR, 0))
+ {
+ re_node_set_free (&next_nodes);
+ return err;
+ }
+ mctx->state_log[str_idx] = cur_state;
+ }
+
+ for (null_cnt = 0; str_idx < last_str && null_cnt <= mctx->max_mb_elem_len;)
+ {
+ re_node_set_empty (&next_nodes);
+ if (mctx->state_log[str_idx + 1])
+ {
+ err = re_node_set_merge (&next_nodes,
+ &mctx->state_log[str_idx + 1]->nodes);
+ if (BE (err != REG_NOERROR, 0))
+ {
+ re_node_set_free (&next_nodes);
+ return err;
+ }
+ }
+ if (cur_state)
+ {
+ err = check_arrival_add_next_nodes (mctx, str_idx,
+ &cur_state->non_eps_nodes,
+ &next_nodes);
+ if (BE (err != REG_NOERROR, 0))
+ {
+ re_node_set_free (&next_nodes);
+ return err;
+ }
+ }
+ ++str_idx;
+ if (next_nodes.nelem)
+ {
+ err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type);
+ if (BE (err != REG_NOERROR, 0))
+ {
+ re_node_set_free (&next_nodes);
+ return err;
+ }
+ err = expand_bkref_cache (mctx, &next_nodes, str_idx,
+ subexp_num, type);
+ if (BE (err != REG_NOERROR, 0))
+ {
+ re_node_set_free (&next_nodes);
+ return err;
+ }
+ }
+ context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags);
+ cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context);
+ if (BE (cur_state == NULL && err != REG_NOERROR, 0))
+ {
+ re_node_set_free (&next_nodes);
+ return err;
+ }
+ mctx->state_log[str_idx] = cur_state;
+ null_cnt = cur_state == NULL ? null_cnt + 1 : 0;
+ }
+ re_node_set_free (&next_nodes);
+ cur_nodes = (mctx->state_log[last_str] == NULL ? NULL
+ : &mctx->state_log[last_str]->nodes);
+ path->next_idx = str_idx;
+
+ /* Fix MCTX. */
+ mctx->state_log = backup_state_log;
+ mctx->input.cur_idx = backup_cur_idx;
+
+ /* Then check the current node set has the node LAST_NODE. */
+ if (cur_nodes != NULL && re_node_set_contains (cur_nodes, last_node))
+ return REG_NOERROR;
+
+ return REG_NOMATCH;
+}
+
+/* Helper functions for check_arrival. */
+
+/* Calculate the destination nodes of CUR_NODES at STR_IDX, and append them
+ to NEXT_NODES.
+ TODO: This function is similar to the functions transit_state*(),
+ however this function has many additional works.
+ Can't we unify them? */
+
+static reg_errcode_t
+internal_function
+check_arrival_add_next_nodes (re_match_context_t *mctx, int str_idx,
+ re_node_set *cur_nodes, re_node_set *next_nodes)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ int result;
+ int cur_idx;
+ reg_errcode_t err = REG_NOERROR;
+ re_node_set union_set;
+ re_node_set_init_empty (&union_set);
+ for (cur_idx = 0; cur_idx < cur_nodes->nelem; ++cur_idx)
+ {
+ int naccepted = 0;
+ int cur_node = cur_nodes->elems[cur_idx];
+#ifdef DEBUG
+ re_token_type_t type = dfa->nodes[cur_node].type;
+ assert (!IS_EPSILON_NODE (type));
+#endif
+#ifdef RE_ENABLE_I18N
+ /* If the node may accept `multi byte'. */
+ if (dfa->nodes[cur_node].accept_mb)
+ {
+ naccepted = check_node_accept_bytes (dfa, cur_node, &mctx->input,
+ str_idx);
+ if (naccepted > 1)
+ {
+ re_dfastate_t *dest_state;
+ int next_node = dfa->nexts[cur_node];
+ int next_idx = str_idx + naccepted;
+ dest_state = mctx->state_log[next_idx];
+ re_node_set_empty (&union_set);
+ if (dest_state)
+ {
+ err = re_node_set_merge (&union_set, &dest_state->nodes);
+ if (BE (err != REG_NOERROR, 0))
+ {
+ re_node_set_free (&union_set);
+ return err;
+ }
+ }
+ result = re_node_set_insert (&union_set, next_node);
+ if (BE (result < 0, 0))
+ {
+ re_node_set_free (&union_set);
+ return REG_ESPACE;
+ }
+ mctx->state_log[next_idx] = re_acquire_state (&err, dfa,
+ &union_set);
+ if (BE (mctx->state_log[next_idx] == NULL
+ && err != REG_NOERROR, 0))
+ {
+ re_node_set_free (&union_set);
+ return err;
+ }
+ }
+ }
+#endif /* RE_ENABLE_I18N */
+ if (naccepted
+ || check_node_accept (mctx, dfa->nodes + cur_node, str_idx))
+ {
+ result = re_node_set_insert (next_nodes, dfa->nexts[cur_node]);
+ if (BE (result < 0, 0))
+ {
+ re_node_set_free (&union_set);
+ return REG_ESPACE;
+ }
+ }
+ }
+ re_node_set_free (&union_set);
+ return REG_NOERROR;
+}
+
+/* For all the nodes in CUR_NODES, add the epsilon closures of them to
+ CUR_NODES, however exclude the nodes which are:
+ - inside the sub expression whose number is EX_SUBEXP, if FL_OPEN.
+ - out of the sub expression whose number is EX_SUBEXP, if !FL_OPEN.
+*/
+
+static reg_errcode_t
+internal_function
+check_arrival_expand_ecl (const re_dfa_t *dfa, re_node_set *cur_nodes,
+ int ex_subexp, int type)
+{
+ reg_errcode_t err;
+ int idx, outside_node;
+ re_node_set new_nodes;
+#ifdef DEBUG
+ assert (cur_nodes->nelem);
+#endif
+ err = re_node_set_alloc (&new_nodes, cur_nodes->nelem);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+ /* Create a new node set NEW_NODES with the nodes which are epsilon
+ closures of the node in CUR_NODES. */
+
+ for (idx = 0; idx < cur_nodes->nelem; ++idx)
+ {
+ int cur_node = cur_nodes->elems[idx];
+ const re_node_set *eclosure = dfa->eclosures + cur_node;
+ outside_node = find_subexp_node (dfa, eclosure, ex_subexp, type);
+ if (outside_node == -1)
+ {
+ /* There are no problematic nodes, just merge them. */
+ err = re_node_set_merge (&new_nodes, eclosure);
+ if (BE (err != REG_NOERROR, 0))
+ {
+ re_node_set_free (&new_nodes);
+ return err;
+ }
+ }
+ else
+ {
+ /* There are problematic nodes, re-calculate incrementally. */
+ err = check_arrival_expand_ecl_sub (dfa, &new_nodes, cur_node,
+ ex_subexp, type);
+ if (BE (err != REG_NOERROR, 0))
+ {
+ re_node_set_free (&new_nodes);
+ return err;
+ }
+ }
+ }
+ re_node_set_free (cur_nodes);
+ *cur_nodes = new_nodes;
+ return REG_NOERROR;
+}
+
+/* Helper function for check_arrival_expand_ecl.
+ Check incrementally the epsilon closure of TARGET, and if it isn't
+ problematic append it to DST_NODES. */
+
+static reg_errcode_t
+internal_function
+check_arrival_expand_ecl_sub (const re_dfa_t *dfa, re_node_set *dst_nodes,
+ int target, int ex_subexp, int type)
+{
+ int cur_node;
+ for (cur_node = target; !re_node_set_contains (dst_nodes, cur_node);)
+ {
+ int err;
+
+ if (dfa->nodes[cur_node].type == type
+ && dfa->nodes[cur_node].opr.idx == ex_subexp)
+ {
+ if (type == OP_CLOSE_SUBEXP)
+ {
+ err = re_node_set_insert (dst_nodes, cur_node);
+ if (BE (err == -1, 0))
+ return REG_ESPACE;
+ }
+ break;
+ }
+ err = re_node_set_insert (dst_nodes, cur_node);
+ if (BE (err == -1, 0))
+ return REG_ESPACE;
+ if (dfa->edests[cur_node].nelem == 0)
+ break;
+ if (dfa->edests[cur_node].nelem == 2)
+ {
+ err = check_arrival_expand_ecl_sub (dfa, dst_nodes,
+ dfa->edests[cur_node].elems[1],
+ ex_subexp, type);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+ }
+ cur_node = dfa->edests[cur_node].elems[0];
+ }
+ return REG_NOERROR;
+}
+
+
+/* For all the back references in the current state, calculate the
+ destination of the back references by the appropriate entry
+ in MCTX->BKREF_ENTS. */
+
+static reg_errcode_t
+internal_function
+expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes,
+ int cur_str, int subexp_num, int type)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ reg_errcode_t err;
+ int cache_idx_start = search_cur_bkref_entry (mctx, cur_str);
+ struct re_backref_cache_entry *ent;
+
+ if (cache_idx_start == -1)
+ return REG_NOERROR;
+
+ restart:
+ ent = mctx->bkref_ents + cache_idx_start;
+ do
+ {
+ int to_idx, next_node;
+
+ /* Is this entry ENT is appropriate? */
+ if (!re_node_set_contains (cur_nodes, ent->node))
+ continue; /* No. */
+
+ to_idx = cur_str + ent->subexp_to - ent->subexp_from;
+ /* Calculate the destination of the back reference, and append it
+ to MCTX->STATE_LOG. */
+ if (to_idx == cur_str)
+ {
+ /* The backreference did epsilon transit, we must re-check all the
+ node in the current state. */
+ re_node_set new_dests;
+ reg_errcode_t err2, err3;
+ next_node = dfa->edests[ent->node].elems[0];
+ if (re_node_set_contains (cur_nodes, next_node))
+ continue;
+ err = re_node_set_init_1 (&new_dests, next_node);
+ err2 = check_arrival_expand_ecl (dfa, &new_dests, subexp_num, type);
+ err3 = re_node_set_merge (cur_nodes, &new_dests);
+ re_node_set_free (&new_dests);
+ if (BE (err != REG_NOERROR || err2 != REG_NOERROR
+ || err3 != REG_NOERROR, 0))
+ {
+ err = (err != REG_NOERROR ? err
+ : (err2 != REG_NOERROR ? err2 : err3));
+ return err;
+ }
+ /* TODO: It is still inefficient... */
+ goto restart;
+ }
+ else
+ {
+ re_node_set union_set;
+ next_node = dfa->nexts[ent->node];
+ if (mctx->state_log[to_idx])
+ {
+ int ret;
+ if (re_node_set_contains (&mctx->state_log[to_idx]->nodes,
+ next_node))
+ continue;
+ err = re_node_set_init_copy (&union_set,
+ &mctx->state_log[to_idx]->nodes);
+ ret = re_node_set_insert (&union_set, next_node);
+ if (BE (err != REG_NOERROR || ret < 0, 0))
+ {
+ re_node_set_free (&union_set);
+ err = err != REG_NOERROR ? err : REG_ESPACE;
+ return err;
+ }
+ }
+ else
+ {
+ err = re_node_set_init_1 (&union_set, next_node);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+ }
+ mctx->state_log[to_idx] = re_acquire_state (&err, dfa, &union_set);
+ re_node_set_free (&union_set);
+ if (BE (mctx->state_log[to_idx] == NULL
+ && err != REG_NOERROR, 0))
+ return err;
+ }
+ }
+ while (ent++->more);
+ return REG_NOERROR;
+}
+
+/* Build transition table for the state.
+ Return 1 if succeeded, otherwise return NULL. */
+
+static int
+internal_function
+build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
+{
+ reg_errcode_t err;
+ int i, j, ch, need_word_trtable = 0;
+ bitset_word_t elem, mask;
+ bool dests_node_malloced = false;
+ bool dest_states_malloced = false;
+ int ndests; /* Number of the destination states from `state'. */
+ re_dfastate_t **trtable;
+ re_dfastate_t **dest_states = NULL, **dest_states_word, **dest_states_nl;
+ re_node_set follows, *dests_node;
+ bitset_t *dests_ch;
+ bitset_t acceptable;
+
+ struct dests_alloc
+ {
+ re_node_set dests_node[SBC_MAX];
+ bitset_t dests_ch[SBC_MAX];
+ } *dests_alloc;
+
+ /* We build DFA states which corresponds to the destination nodes
+ from `state'. `dests_node[i]' represents the nodes which i-th
+ destination state contains, and `dests_ch[i]' represents the
+ characters which i-th destination state accepts. */
+ if (__libc_use_alloca (sizeof (struct dests_alloc)))
+ dests_alloc = (struct dests_alloc *) alloca (sizeof (struct dests_alloc));
+ else
+ {
+ dests_alloc = re_malloc (struct dests_alloc, 1);
+ if (BE (dests_alloc == NULL, 0))
+ return 0;
+ dests_node_malloced = true;
+ }
+ dests_node = dests_alloc->dests_node;
+ dests_ch = dests_alloc->dests_ch;
+
+ /* Initialize transiton table. */
+ state->word_trtable = state->trtable = NULL;
+
+ /* At first, group all nodes belonging to `state' into several
+ destinations. */
+ ndests = group_nodes_into_DFAstates (dfa, state, dests_node, dests_ch);
+ if (BE (ndests <= 0, 0))
+ {
+ if (dests_node_malloced)
+ free (dests_alloc);
+ /* Return 0 in case of an error, 1 otherwise. */
+ if (ndests == 0)
+ {
+ state->trtable = (re_dfastate_t **)
+ calloc (sizeof (re_dfastate_t *), SBC_MAX);
+ return 1;
+ }
+ return 0;
+ }
+
+ err = re_node_set_alloc (&follows, ndests + 1);
+ if (BE (err != REG_NOERROR, 0))
+ goto out_free;
+
+ if (__libc_use_alloca ((sizeof (re_node_set) + sizeof (bitset_t)) * SBC_MAX
+ + ndests * 3 * sizeof (re_dfastate_t *)))
+ dest_states = (re_dfastate_t **)
+ alloca (ndests * 3 * sizeof (re_dfastate_t *));
+ else
+ {
+ dest_states = (re_dfastate_t **)
+ malloc (ndests * 3 * sizeof (re_dfastate_t *));
+ if (BE (dest_states == NULL, 0))
+ {
+out_free:
+ if (dest_states_malloced)
+ free (dest_states);
+ re_node_set_free (&follows);
+ for (i = 0; i < ndests; ++i)
+ re_node_set_free (dests_node + i);
+ if (dests_node_malloced)
+ free (dests_alloc);
+ return 0;
+ }
+ dest_states_malloced = true;
+ }
+ dest_states_word = dest_states + ndests;
+ dest_states_nl = dest_states_word + ndests;
+ bitset_empty (acceptable);
+
+ /* Then build the states for all destinations. */
+ for (i = 0; i < ndests; ++i)
+ {
+ int next_node;
+ re_node_set_empty (&follows);
+ /* Merge the follows of this destination states. */
+ for (j = 0; j < dests_node[i].nelem; ++j)
+ {
+ next_node = dfa->nexts[dests_node[i].elems[j]];
+ if (next_node != -1)
+ {
+ err = re_node_set_merge (&follows, dfa->eclosures + next_node);
+ if (BE (err != REG_NOERROR, 0))
+ goto out_free;
+ }
+ }
+ dest_states[i] = re_acquire_state_context (&err, dfa, &follows, 0);
+ if (BE (dest_states[i] == NULL && err != REG_NOERROR, 0))
+ goto out_free;
+ /* If the new state has context constraint,
+ build appropriate states for these contexts. */
+ if (dest_states[i]->has_constraint)
+ {
+ dest_states_word[i] = re_acquire_state_context (&err, dfa, &follows,
+ CONTEXT_WORD);
+ if (BE (dest_states_word[i] == NULL && err != REG_NOERROR, 0))
+ goto out_free;
+
+ if (dest_states[i] != dest_states_word[i] && dfa->mb_cur_max > 1)
+ need_word_trtable = 1;
+
+ dest_states_nl[i] = re_acquire_state_context (&err, dfa, &follows,
+ CONTEXT_NEWLINE);
+ if (BE (dest_states_nl[i] == NULL && err != REG_NOERROR, 0))
+ goto out_free;
+ }
+ else
+ {
+ dest_states_word[i] = dest_states[i];
+ dest_states_nl[i] = dest_states[i];
+ }
+ bitset_merge (acceptable, dests_ch[i]);
+ }
+
+ if (!BE (need_word_trtable, 0))
+ {
+ /* We don't care about whether the following character is a word
+ character, or we are in a single-byte character set so we can
+ discern by looking at the character code: allocate a
+ 256-entry transition table. */
+ trtable = state->trtable =
+ (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), SBC_MAX);
+ if (BE (trtable == NULL, 0))
+ goto out_free;
+
+ /* For all characters ch...: */
+ for (i = 0; i < BITSET_WORDS; ++i)
+ for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1;
+ elem;
+ mask <<= 1, elem >>= 1, ++ch)
+ if (BE (elem & 1, 0))
+ {
+ /* There must be exactly one destination which accepts
+ character ch. See group_nodes_into_DFAstates. */
+ for (j = 0; (dests_ch[j][i] & mask) == 0; ++j)
+ ;
+
+ /* j-th destination accepts the word character ch. */
+ if (dfa->word_char[i] & mask)
+ trtable[ch] = dest_states_word[j];
+ else
+ trtable[ch] = dest_states[j];
+ }
+ }
+ else
+ {
+ /* We care about whether the following character is a word
+ character, and we are in a multi-byte character set: discern
+ by looking at the character code: build two 256-entry
+ transition tables, one starting at trtable[0] and one
+ starting at trtable[SBC_MAX]. */
+ trtable = state->word_trtable =
+ (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), 2 * SBC_MAX);
+ if (BE (trtable == NULL, 0))
+ goto out_free;
+
+ /* For all characters ch...: */
+ for (i = 0; i < BITSET_WORDS; ++i)
+ for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1;
+ elem;
+ mask <<= 1, elem >>= 1, ++ch)
+ if (BE (elem & 1, 0))
+ {
+ /* There must be exactly one destination which accepts
+ character ch. See group_nodes_into_DFAstates. */
+ for (j = 0; (dests_ch[j][i] & mask) == 0; ++j)
+ ;
+
+ /* j-th destination accepts the word character ch. */
+ trtable[ch] = dest_states[j];
+ trtable[ch + SBC_MAX] = dest_states_word[j];
+ }
+ }
+
+ /* new line */
+ if (bitset_contain (acceptable, NEWLINE_CHAR))
+ {
+ /* The current state accepts newline character. */
+ for (j = 0; j < ndests; ++j)
+ if (bitset_contain (dests_ch[j], NEWLINE_CHAR))
+ {
+ /* k-th destination accepts newline character. */
+ trtable[NEWLINE_CHAR] = dest_states_nl[j];
+ if (need_word_trtable)
+ trtable[NEWLINE_CHAR + SBC_MAX] = dest_states_nl[j];
+ /* There must be only one destination which accepts
+ newline. See group_nodes_into_DFAstates. */
+ break;
+ }
+ }
+
+ if (dest_states_malloced)
+ free (dest_states);
+
+ re_node_set_free (&follows);
+ for (i = 0; i < ndests; ++i)
+ re_node_set_free (dests_node + i);
+
+ if (dests_node_malloced)
+ free (dests_alloc);
+
+ return 1;
+}
+
+/* Group all nodes belonging to STATE into several destinations.
+ Then for all destinations, set the nodes belonging to the destination
+ to DESTS_NODE[i] and set the characters accepted by the destination
+ to DEST_CH[i]. This function return the number of destinations. */
+
+static int
+internal_function
+group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
+ re_node_set *dests_node, bitset_t *dests_ch)
+{
+ reg_errcode_t err;
+ int result;
+ int i, j, k;
+ int ndests; /* Number of the destinations from `state'. */
+ bitset_t accepts; /* Characters a node can accept. */
+ const re_node_set *cur_nodes = &state->nodes;
+ bitset_empty (accepts);
+ ndests = 0;
+
+ /* For all the nodes belonging to `state', */
+ for (i = 0; i < cur_nodes->nelem; ++i)
+ {
+ re_token_t *node = &dfa->nodes[cur_nodes->elems[i]];
+ re_token_type_t type = node->type;
+ unsigned int constraint = node->constraint;
+
+ /* Enumerate all single byte character this node can accept. */
+ if (type == CHARACTER)
+ bitset_set (accepts, node->opr.c);
+ else if (type == SIMPLE_BRACKET)
+ {
+ bitset_merge (accepts, node->opr.sbcset);
+ }
+ else if (type == OP_PERIOD)
+ {
+#ifdef RE_ENABLE_I18N
+ if (dfa->mb_cur_max > 1)
+ bitset_merge (accepts, dfa->sb_char);
+ else
+#endif
+ bitset_set_all (accepts);
+ if (!(dfa->syntax & RE_DOT_NEWLINE))
+ bitset_clear (accepts, '\n');
+ if (dfa->syntax & RE_DOT_NOT_NULL)
+ bitset_clear (accepts, '\0');
+ }
+#ifdef RE_ENABLE_I18N
+ else if (type == OP_UTF8_PERIOD)
+ {
+ memset (accepts, '\xff', sizeof (bitset_t) / 2);
+ if (!(dfa->syntax & RE_DOT_NEWLINE))
+ bitset_clear (accepts, '\n');
+ if (dfa->syntax & RE_DOT_NOT_NULL)
+ bitset_clear (accepts, '\0');
+ }
+#endif
+ else
+ continue;
+
+ /* Check the `accepts' and sift the characters which are not
+ match it the context. */
+ if (constraint)
+ {
+ if (constraint & NEXT_NEWLINE_CONSTRAINT)
+ {
+ bool accepts_newline = bitset_contain (accepts, NEWLINE_CHAR);
+ bitset_empty (accepts);
+ if (accepts_newline)
+ bitset_set (accepts, NEWLINE_CHAR);
+ else
+ continue;
+ }
+ if (constraint & NEXT_ENDBUF_CONSTRAINT)
+ {
+ bitset_empty (accepts);
+ continue;
+ }
+
+ if (constraint & NEXT_WORD_CONSTRAINT)
+ {
+ bitset_word_t any_set = 0;
+ if (type == CHARACTER && !node->word_char)
+ {
+ bitset_empty (accepts);
+ continue;
+ }
+#ifdef RE_ENABLE_I18N
+ if (dfa->mb_cur_max > 1)
+ for (j = 0; j < BITSET_WORDS; ++j)
+ any_set |= (accepts[j] &= (dfa->word_char[j] | ~dfa->sb_char[j]));
+ else
+#endif
+ for (j = 0; j < BITSET_WORDS; ++j)
+ any_set |= (accepts[j] &= dfa->word_char[j]);
+ if (!any_set)
+ continue;
+ }
+ if (constraint & NEXT_NOTWORD_CONSTRAINT)
+ {
+ bitset_word_t any_set = 0;
+ if (type == CHARACTER && node->word_char)
+ {
+ bitset_empty (accepts);
+ continue;
+ }
+#ifdef RE_ENABLE_I18N
+ if (dfa->mb_cur_max > 1)
+ for (j = 0; j < BITSET_WORDS; ++j)
+ any_set |= (accepts[j] &= ~(dfa->word_char[j] & dfa->sb_char[j]));
+ else
+#endif
+ for (j = 0; j < BITSET_WORDS; ++j)
+ any_set |= (accepts[j] &= ~dfa->word_char[j]);
+ if (!any_set)
+ continue;
+ }
+ }
+
+ /* Then divide `accepts' into DFA states, or create a new
+ state. Above, we make sure that accepts is not empty. */
+ for (j = 0; j < ndests; ++j)
+ {
+ bitset_t intersec; /* Intersection sets, see below. */
+ bitset_t remains;
+ /* Flags, see below. */
+ bitset_word_t has_intersec, not_subset, not_consumed;
+
+ /* Optimization, skip if this state doesn't accept the character. */
+ if (type == CHARACTER && !bitset_contain (dests_ch[j], node->opr.c))
+ continue;
+
+ /* Enumerate the intersection set of this state and `accepts'. */
+ has_intersec = 0;
+ for (k = 0; k < BITSET_WORDS; ++k)
+ has_intersec |= intersec[k] = accepts[k] & dests_ch[j][k];
+ /* And skip if the intersection set is empty. */
+ if (!has_intersec)
+ continue;
+
+ /* Then check if this state is a subset of `accepts'. */
+ not_subset = not_consumed = 0;
+ for (k = 0; k < BITSET_WORDS; ++k)
+ {
+ not_subset |= remains[k] = ~accepts[k] & dests_ch[j][k];
+ not_consumed |= accepts[k] = accepts[k] & ~dests_ch[j][k];
+ }
+
+ /* If this state isn't a subset of `accepts', create a
+ new group state, which has the `remains'. */
+ if (not_subset)
+ {
+ bitset_copy (dests_ch[ndests], remains);
+ bitset_copy (dests_ch[j], intersec);
+ err = re_node_set_init_copy (dests_node + ndests, &dests_node[j]);
+ if (BE (err != REG_NOERROR, 0))
+ goto error_return;
+ ++ndests;
+ }
+
+ /* Put the position in the current group. */
+ result = re_node_set_insert (&dests_node[j], cur_nodes->elems[i]);
+ if (BE (result < 0, 0))
+ goto error_return;
+
+ /* If all characters are consumed, go to next node. */
+ if (!not_consumed)
+ break;
+ }
+ /* Some characters remain, create a new group. */
+ if (j == ndests)
+ {
+ bitset_copy (dests_ch[ndests], accepts);
+ err = re_node_set_init_1 (dests_node + ndests, cur_nodes->elems[i]);
+ if (BE (err != REG_NOERROR, 0))
+ goto error_return;
+ ++ndests;
+ bitset_empty (accepts);
+ }
+ }
+ return ndests;
+ error_return:
+ for (j = 0; j < ndests; ++j)
+ re_node_set_free (dests_node + j);
+ return -1;
+}
+
+#ifdef RE_ENABLE_I18N
+/* Check how many bytes the node `dfa->nodes[node_idx]' accepts.
+ Return the number of the bytes the node accepts.
+ STR_IDX is the current index of the input string.
+
+ This function handles the nodes which can accept one character, or
+ one collating element like '.', '[a-z]', opposite to the other nodes
+ can only accept one byte. */
+
+static int
+internal_function
+check_node_accept_bytes (const re_dfa_t *dfa, int node_idx,
+ const re_string_t *input, int str_idx)
+{
+ const re_token_t *node = dfa->nodes + node_idx;
+ int char_len, elem_len;
+ int i;
+
+ if (BE (node->type == OP_UTF8_PERIOD, 0))
+ {
+ unsigned char c = re_string_byte_at (input, str_idx), d;
+ if (BE (c < 0xc2, 1))
+ return 0;
+
+ if (str_idx + 2 > input->len)
+ return 0;
+
+ d = re_string_byte_at (input, str_idx + 1);
+ if (c < 0xe0)
+ return (d < 0x80 || d > 0xbf) ? 0 : 2;
+ else if (c < 0xf0)
+ {
+ char_len = 3;
+ if (c == 0xe0 && d < 0xa0)
+ return 0;
+ }
+ else if (c < 0xf8)
+ {
+ char_len = 4;
+ if (c == 0xf0 && d < 0x90)
+ return 0;
+ }
+ else if (c < 0xfc)
+ {
+ char_len = 5;
+ if (c == 0xf8 && d < 0x88)
+ return 0;
+ }
+ else if (c < 0xfe)
+ {
+ char_len = 6;
+ if (c == 0xfc && d < 0x84)
+ return 0;
+ }
+ else
+ return 0;
+
+ if (str_idx + char_len > input->len)
+ return 0;
+
+ for (i = 1; i < char_len; ++i)
+ {
+ d = re_string_byte_at (input, str_idx + i);
+ if (d < 0x80 || d > 0xbf)
+ return 0;
+ }
+ return char_len;
+ }
+
+ char_len = re_string_char_size_at (input, str_idx);
+ if (node->type == OP_PERIOD)
+ {
+ if (char_len <= 1)
+ return 0;
+ /* FIXME: I don't think this if is needed, as both '\n'
+ and '\0' are char_len == 1. */
+ /* '.' accepts any one character except the following two cases. */
+ if ((!(dfa->syntax & RE_DOT_NEWLINE) &&
+ re_string_byte_at (input, str_idx) == '\n') ||
+ ((dfa->syntax & RE_DOT_NOT_NULL) &&
+ re_string_byte_at (input, str_idx) == '\0'))
+ return 0;
+ return char_len;
+ }
+
+ elem_len = re_string_elem_size_at (input, str_idx);
+ if ((elem_len <= 1 && char_len <= 1) || char_len == 0)
+ return 0;
+
+ if (node->type == COMPLEX_BRACKET)
+ {
+ const re_charset_t *cset = node->opr.mbcset;
+# ifdef _LIBC
+ const unsigned char *pin
+ = ((const unsigned char *) re_string_get_buffer (input) + str_idx);
+ int j;
+ uint32_t nrules;
+# endif /* _LIBC */
+ int match_len = 0;
+ wchar_t wc = ((cset->nranges || cset->nchar_classes || cset->nmbchars)
+ ? re_string_wchar_at (input, str_idx) : 0);
+
+ /* match with multibyte character? */
+ for (i = 0; i < cset->nmbchars; ++i)
+ if (wc == cset->mbchars[i])
+ {
+ match_len = char_len;
+ goto check_node_accept_bytes_match;
+ }
+ /* match with character_class? */
+ for (i = 0; i < cset->nchar_classes; ++i)
+ {
+ wctype_t wt = cset->char_classes[i];
+ if (__iswctype (wc, wt))
+ {
+ match_len = char_len;
+ goto check_node_accept_bytes_match;
+ }
+ }
+
+# ifdef _LIBC
+ nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
+ if (nrules != 0)
+ {
+ unsigned int in_collseq = 0;
+ const int32_t *table, *indirect;
+ const unsigned char *weights, *extra;
+ const char *collseqwc;
+ int32_t idx;
+ /* This #include defines a local function! */
+# include <locale/weight.h>
+
+ /* match with collating_symbol? */
+ if (cset->ncoll_syms)
+ extra = (const unsigned char *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB);
+ for (i = 0; i < cset->ncoll_syms; ++i)
+ {
+ const unsigned char *coll_sym = extra + cset->coll_syms[i];
+ /* Compare the length of input collating element and
+ the length of current collating element. */
+ if (*coll_sym != elem_len)
+ continue;
+ /* Compare each bytes. */
+ for (j = 0; j < *coll_sym; j++)
+ if (pin[j] != coll_sym[1 + j])
+ break;
+ if (j == *coll_sym)
+ {
+ /* Match if every bytes is equal. */
+ match_len = j;
+ goto check_node_accept_bytes_match;
+ }
+ }
+
+ if (cset->nranges)
+ {
+ if (elem_len <= char_len)
+ {
+ collseqwc = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQWC);
+ in_collseq = __collseq_table_lookup (collseqwc, wc);
+ }
+ else
+ in_collseq = find_collation_sequence_value (pin, elem_len);
+ }
+ /* match with range expression? */
+ for (i = 0; i < cset->nranges; ++i)
+ if (cset->range_starts[i] <= in_collseq
+ && in_collseq <= cset->range_ends[i])
+ {
+ match_len = elem_len;
+ goto check_node_accept_bytes_match;
+ }
+
+ /* match with equivalence_class? */
+ if (cset->nequiv_classes)
+ {
+ const unsigned char *cp = pin;
+ table = (const int32_t *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
+ weights = (const unsigned char *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTMB);
+ extra = (const unsigned char *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB);
+ indirect = (const int32_t *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB);
+ idx = findidx (&cp);
+ if (idx > 0)
+ for (i = 0; i < cset->nequiv_classes; ++i)
+ {
+ int32_t equiv_class_idx = cset->equiv_classes[i];
+ size_t weight_len = weights[idx];
+ if (weight_len == weights[equiv_class_idx])
+ {
+ int cnt = 0;
+ while (cnt <= weight_len
+ && (weights[equiv_class_idx + 1 + cnt]
+ == weights[idx + 1 + cnt]))
+ ++cnt;
+ if (cnt > weight_len)
+ {
+ match_len = elem_len;
+ goto check_node_accept_bytes_match;
+ }
+ }
+ }
+ }
+ }
+ else
+# endif /* _LIBC */
+ {
+ /* match with range expression? */
+#if __GNUC__ >= 2
+ wchar_t cmp_buf[] = {L'\0', L'\0', wc, L'\0', L'\0', L'\0'};
+#else
+ wchar_t cmp_buf[] = {L'\0', L'\0', L'\0', L'\0', L'\0', L'\0'};
+ cmp_buf[2] = wc;
+#endif
+ for (i = 0; i < cset->nranges; ++i)
+ {
+ cmp_buf[0] = cset->range_starts[i];
+ cmp_buf[4] = cset->range_ends[i];
+ if (wcscoll (cmp_buf, cmp_buf + 2) <= 0
+ && wcscoll (cmp_buf + 2, cmp_buf + 4) <= 0)
+ {
+ match_len = char_len;
+ goto check_node_accept_bytes_match;
+ }
+ }
+ }
+ check_node_accept_bytes_match:
+ if (!cset->non_match)
+ return match_len;
+ else
+ {
+ if (match_len > 0)
+ return 0;
+ else
+ return (elem_len > char_len) ? elem_len : char_len;
+ }
+ }
+ return 0;
+}
+
+# ifdef _LIBC
+static unsigned int
+internal_function
+find_collation_sequence_value (const unsigned char *mbs, size_t mbs_len)
+{
+ uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
+ if (nrules == 0)
+ {
+ if (mbs_len == 1)
+ {
+ /* No valid character. Match it as a single byte character. */
+ const unsigned char *collseq = (const unsigned char *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQMB);
+ return collseq[mbs[0]];
+ }
+ return UINT_MAX;
+ }
+ else
+ {
+ int32_t idx;
+ const unsigned char *extra = (const unsigned char *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB);
+ int32_t extrasize = (const unsigned char *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB + 1) - extra;
+
+ for (idx = 0; idx < extrasize;)
+ {
+ int mbs_cnt, found = 0;
+ int32_t elem_mbs_len;
+ /* Skip the name of collating element name. */
+ idx = idx + extra[idx] + 1;
+ elem_mbs_len = extra[idx++];
+ if (mbs_len == elem_mbs_len)
+ {
+ for (mbs_cnt = 0; mbs_cnt < elem_mbs_len; ++mbs_cnt)
+ if (extra[idx + mbs_cnt] != mbs[mbs_cnt])
+ break;
+ if (mbs_cnt == elem_mbs_len)
+ /* Found the entry. */
+ found = 1;
+ }
+ /* Skip the byte sequence of the collating element. */
+ idx += elem_mbs_len;
+ /* Adjust for the alignment. */
+ idx = (idx + 3) & ~3;
+ /* Skip the collation sequence value. */
+ idx += sizeof (uint32_t);
+ /* Skip the wide char sequence of the collating element. */
+ idx = idx + sizeof (uint32_t) * (extra[idx] + 1);
+ /* If we found the entry, return the sequence value. */
+ if (found)
+ return *(uint32_t *) (extra + idx);
+ /* Skip the collation sequence value. */
+ idx += sizeof (uint32_t);
+ }
+ return UINT_MAX;
+ }
+}
+# endif /* _LIBC */
+#endif /* RE_ENABLE_I18N */
+
+/* Check whether the node accepts the byte which is IDX-th
+ byte of the INPUT. */
+
+static int
+internal_function
+check_node_accept (const re_match_context_t *mctx, const re_token_t *node,
+ int idx)
+{
+ unsigned char ch;
+ ch = re_string_byte_at (&mctx->input, idx);
+ switch (node->type)
+ {
+ case CHARACTER:
+ if (node->opr.c != ch)
+ return 0;
+ break;
+
+ case SIMPLE_BRACKET:
+ if (!bitset_contain (node->opr.sbcset, ch))
+ return 0;
+ break;
+
+#ifdef RE_ENABLE_I18N
+ case OP_UTF8_PERIOD:
+ if (ch >= 0x80)
+ return 0;
+ /* FALLTHROUGH */
+#endif
+ case OP_PERIOD:
+ if ((ch == '\n' && !(mctx->dfa->syntax & RE_DOT_NEWLINE))
+ || (ch == '\0' && (mctx->dfa->syntax & RE_DOT_NOT_NULL)))
+ return 0;
+ break;
+
+ default:
+ return 0;
+ }
+
+ if (node->constraint)
+ {
+ /* The node has constraints. Check whether the current context
+ satisfies the constraints. */
+ unsigned int context = re_string_context_at (&mctx->input, idx,
+ mctx->eflags);
+ if (NOT_SATISFY_NEXT_CONSTRAINT (node->constraint, context))
+ return 0;
+ }
+
+ return 1;
+}
+
+/* Extend the buffers, if the buffers have run out. */
+
+static reg_errcode_t
+internal_function
+extend_buffers (re_match_context_t *mctx)
+{
+ reg_errcode_t ret;
+ re_string_t *pstr = &mctx->input;
+
+ /* Double the lengthes of the buffers. */
+ ret = re_string_realloc_buffers (pstr, pstr->bufs_len * 2);
+ if (BE (ret != REG_NOERROR, 0))
+ return ret;
+
+ if (mctx->state_log != NULL)
+ {
+ /* And double the length of state_log. */
+ /* XXX We have no indication of the size of this buffer. If this
+ allocation fail we have no indication that the state_log array
+ does not have the right size. */
+ re_dfastate_t **new_array = re_realloc (mctx->state_log, re_dfastate_t *,
+ pstr->bufs_len + 1);
+ if (BE (new_array == NULL, 0))
+ return REG_ESPACE;
+ mctx->state_log = new_array;
+ }
+
+ /* Then reconstruct the buffers. */
+ if (pstr->icase)
+ {
+#ifdef RE_ENABLE_I18N
+ if (pstr->mb_cur_max > 1)
+ {
+ ret = build_wcs_upper_buffer (pstr);
+ if (BE (ret != REG_NOERROR, 0))
+ return ret;
+ }
+ else
+#endif /* RE_ENABLE_I18N */
+ build_upper_buffer (pstr);
+ }
+ else
+ {
+#ifdef RE_ENABLE_I18N
+ if (pstr->mb_cur_max > 1)
+ build_wcs_buffer (pstr);
+ else
+#endif /* RE_ENABLE_I18N */
+ {
+ if (pstr->trans != NULL)
+ re_string_translate_buffer (pstr);
+ }
+ }
+ return REG_NOERROR;
+}
+
+
+/* Functions for matching context. */
+
+/* Initialize MCTX. */
+
+static reg_errcode_t
+internal_function
+match_ctx_init (re_match_context_t *mctx, int eflags, int n)
+{
+ mctx->eflags = eflags;
+ mctx->match_last = -1;
+ if (n > 0)
+ {
+ mctx->bkref_ents = re_malloc (struct re_backref_cache_entry, n);
+ mctx->sub_tops = re_malloc (re_sub_match_top_t *, n);
+ if (BE (mctx->bkref_ents == NULL || mctx->sub_tops == NULL, 0))
+ return REG_ESPACE;
+ }
+ /* Already zero-ed by the caller.
+ else
+ mctx->bkref_ents = NULL;
+ mctx->nbkref_ents = 0;
+ mctx->nsub_tops = 0; */
+ mctx->abkref_ents = n;
+ mctx->max_mb_elem_len = 1;
+ mctx->asub_tops = n;
+ return REG_NOERROR;
+}
+
+/* Clean the entries which depend on the current input in MCTX.
+ This function must be invoked when the matcher changes the start index
+ of the input, or changes the input string. */
+
+static void
+internal_function
+match_ctx_clean (re_match_context_t *mctx)
+{
+ int st_idx;
+ for (st_idx = 0; st_idx < mctx->nsub_tops; ++st_idx)
+ {
+ int sl_idx;
+ re_sub_match_top_t *top = mctx->sub_tops[st_idx];
+ for (sl_idx = 0; sl_idx < top->nlasts; ++sl_idx)
+ {
+ re_sub_match_last_t *last = top->lasts[sl_idx];
+ re_free (last->path.array);
+ re_free (last);
+ }
+ re_free (top->lasts);
+ if (top->path)
+ {
+ re_free (top->path->array);
+ re_free (top->path);
+ }
+ free (top);
+ }
+
+ mctx->nsub_tops = 0;
+ mctx->nbkref_ents = 0;
+}
+
+/* Free all the memory associated with MCTX. */
+
+static void
+internal_function
+match_ctx_free (re_match_context_t *mctx)
+{
+ /* First, free all the memory associated with MCTX->SUB_TOPS. */
+ match_ctx_clean (mctx);
+ re_free (mctx->sub_tops);
+ re_free (mctx->bkref_ents);
+}
+
+/* Add a new backreference entry to MCTX.
+ Note that we assume that caller never call this function with duplicate
+ entry, and call with STR_IDX which isn't smaller than any existing entry.
+*/
+
+static reg_errcode_t
+internal_function
+match_ctx_add_entry (re_match_context_t *mctx, int node, int str_idx, int from,
+ int to)
+{
+ if (mctx->nbkref_ents >= mctx->abkref_ents)
+ {
+ struct re_backref_cache_entry* new_entry;
+ new_entry = re_realloc (mctx->bkref_ents, struct re_backref_cache_entry,
+ mctx->abkref_ents * 2);
+ if (BE (new_entry == NULL, 0))
+ {
+ re_free (mctx->bkref_ents);
+ return REG_ESPACE;
+ }
+ mctx->bkref_ents = new_entry;
+ memset (mctx->bkref_ents + mctx->nbkref_ents, '\0',
+ sizeof (struct re_backref_cache_entry) * mctx->abkref_ents);
+ mctx->abkref_ents *= 2;
+ }
+ if (mctx->nbkref_ents > 0
+ && mctx->bkref_ents[mctx->nbkref_ents - 1].str_idx == str_idx)
+ mctx->bkref_ents[mctx->nbkref_ents - 1].more = 1;
+
+ mctx->bkref_ents[mctx->nbkref_ents].node = node;
+ mctx->bkref_ents[mctx->nbkref_ents].str_idx = str_idx;
+ mctx->bkref_ents[mctx->nbkref_ents].subexp_from = from;
+ mctx->bkref_ents[mctx->nbkref_ents].subexp_to = to;
+
+ /* This is a cache that saves negative results of check_dst_limits_calc_pos.
+ If bit N is clear, means that this entry won't epsilon-transition to
+ an OP_OPEN_SUBEXP or OP_CLOSE_SUBEXP for the N+1-th subexpression. If
+ it is set, check_dst_limits_calc_pos_1 will recurse and try to find one
+ such node.
+
+ A backreference does not epsilon-transition unless it is empty, so set
+ to all zeros if FROM != TO. */
+ mctx->bkref_ents[mctx->nbkref_ents].eps_reachable_subexps_map
+ = (from == to ? ~0 : 0);
+
+ mctx->bkref_ents[mctx->nbkref_ents++].more = 0;
+ if (mctx->max_mb_elem_len < to - from)
+ mctx->max_mb_elem_len = to - from;
+ return REG_NOERROR;
+}
+
+/* Search for the first entry which has the same str_idx, or -1 if none is
+ found. Note that MCTX->BKREF_ENTS is already sorted by MCTX->STR_IDX. */
+
+static int
+internal_function
+search_cur_bkref_entry (const re_match_context_t *mctx, int str_idx)
+{
+ int left, right, mid, last;
+ last = right = mctx->nbkref_ents;
+ for (left = 0; left < right;)
+ {
+ mid = (left + right) / 2;
+ if (mctx->bkref_ents[mid].str_idx < str_idx)
+ left = mid + 1;
+ else
+ right = mid;
+ }
+ if (left < last && mctx->bkref_ents[left].str_idx == str_idx)
+ return left;
+ else
+ return -1;
+}
+
+/* Register the node NODE, whose type is OP_OPEN_SUBEXP, and which matches
+ at STR_IDX. */
+
+static reg_errcode_t
+internal_function
+match_ctx_add_subtop (re_match_context_t *mctx, int node, int str_idx)
+{
+#ifdef DEBUG
+ assert (mctx->sub_tops != NULL);
+ assert (mctx->asub_tops > 0);
+#endif
+ if (BE (mctx->nsub_tops == mctx->asub_tops, 0))
+ {
+ int new_asub_tops = mctx->asub_tops * 2;
+ re_sub_match_top_t **new_array = re_realloc (mctx->sub_tops,
+ re_sub_match_top_t *,
+ new_asub_tops);
+ if (BE (new_array == NULL, 0))
+ return REG_ESPACE;
+ mctx->sub_tops = new_array;
+ mctx->asub_tops = new_asub_tops;
+ }
+ mctx->sub_tops[mctx->nsub_tops] = calloc (1, sizeof (re_sub_match_top_t));
+ if (BE (mctx->sub_tops[mctx->nsub_tops] == NULL, 0))
+ return REG_ESPACE;
+ mctx->sub_tops[mctx->nsub_tops]->node = node;
+ mctx->sub_tops[mctx->nsub_tops++]->str_idx = str_idx;
+ return REG_NOERROR;
+}
+
+/* Register the node NODE, whose type is OP_CLOSE_SUBEXP, and which matches
+ at STR_IDX, whose corresponding OP_OPEN_SUBEXP is SUB_TOP. */
+
+static re_sub_match_last_t *
+internal_function
+match_ctx_add_sublast (re_sub_match_top_t *subtop, int node, int str_idx)
+{
+ re_sub_match_last_t *new_entry;
+ if (BE (subtop->nlasts == subtop->alasts, 0))
+ {
+ int new_alasts = 2 * subtop->alasts + 1;
+ re_sub_match_last_t **new_array = re_realloc (subtop->lasts,
+ re_sub_match_last_t *,
+ new_alasts);
+ if (BE (new_array == NULL, 0))
+ return NULL;
+ subtop->lasts = new_array;
+ subtop->alasts = new_alasts;
+ }
+ new_entry = calloc (1, sizeof (re_sub_match_last_t));
+ if (BE (new_entry != NULL, 1))
+ {
+ subtop->lasts[subtop->nlasts] = new_entry;
+ new_entry->node = node;
+ new_entry->str_idx = str_idx;
+ ++subtop->nlasts;
+ }
+ return new_entry;
+}
+
+static void
+internal_function
+sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t **sifted_sts,
+ re_dfastate_t **limited_sts, int last_node, int last_str_idx)
+{
+ sctx->sifted_states = sifted_sts;
+ sctx->limited_states = limited_sts;
+ sctx->last_node = last_node;
+ sctx->last_str_idx = last_str_idx;
+ re_node_set_init_empty (&sctx->limits);
+}
diff --git a/node_modules/mmmagic/deps/libmagic/msvc/stdint.h b/node_modules/mmmagic/deps/libmagic/msvc/stdint.h
new file mode 100644
index 0000000..d02608a
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/msvc/stdint.h
@@ -0,0 +1,247 @@
+// ISO C9x compliant stdint.h for Microsoft Visual Studio
+// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
+//
+// Copyright (c) 2006-2008 Alexander Chemeris
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// 3. The name of the author may be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _MSC_VER // [
+#error "Use this header only with Microsoft Visual C++ compilers!"
+#endif // _MSC_VER ]
+
+#ifndef _MSC_STDINT_H_ // [
+#define _MSC_STDINT_H_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif
+
+#include <limits.h>
+
+// For Visual Studio 6 in C++ mode and for many Visual Studio versions when
+// compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
+// or compiler give many errors like this:
+// error C2733: second C linkage of overloaded function 'wmemchr' not allowed
+#ifdef __cplusplus
+extern "C" {
+#endif
+# include <wchar.h>
+#ifdef __cplusplus
+}
+#endif
+
+// Define _W64 macros to mark types changing their size, like intptr_t.
+#ifndef _W64
+# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
+# define _W64 __w64
+# else
+# define _W64
+# endif
+#endif
+
+
+// 7.18.1 Integer types
+
+// 7.18.1.1 Exact-width integer types
+
+// Visual Studio 6 and Embedded Visual C++ 4 doesn't
+// realize that, e.g. char has the same size as __int8
+// so we give up on __intX for them.
+#if (_MSC_VER < 1300)
+ typedef signed char int8_t;
+ typedef signed short int16_t;
+ typedef signed int int32_t;
+ typedef unsigned char uint8_t;
+ typedef unsigned short uint16_t;
+ typedef unsigned int uint32_t;
+#else
+ typedef signed __int8 int8_t;
+ typedef signed __int16 int16_t;
+ typedef signed __int32 int32_t;
+ typedef unsigned __int8 uint8_t;
+ typedef unsigned __int16 uint16_t;
+ typedef unsigned __int32 uint32_t;
+#endif
+typedef signed __int64 int64_t;
+typedef unsigned __int64 uint64_t;
+
+
+// 7.18.1.2 Minimum-width integer types
+typedef int8_t int_least8_t;
+typedef int16_t int_least16_t;
+typedef int32_t int_least32_t;
+typedef int64_t int_least64_t;
+typedef uint8_t uint_least8_t;
+typedef uint16_t uint_least16_t;
+typedef uint32_t uint_least32_t;
+typedef uint64_t uint_least64_t;
+
+// 7.18.1.3 Fastest minimum-width integer types
+typedef int8_t int_fast8_t;
+typedef int16_t int_fast16_t;
+typedef int32_t int_fast32_t;
+typedef int64_t int_fast64_t;
+typedef uint8_t uint_fast8_t;
+typedef uint16_t uint_fast16_t;
+typedef uint32_t uint_fast32_t;
+typedef uint64_t uint_fast64_t;
+
+// 7.18.1.4 Integer types capable of holding object pointers
+#ifdef _WIN64 // [
+ typedef signed __int64 intptr_t;
+ typedef unsigned __int64 uintptr_t;
+#else // _WIN64 ][
+ typedef _W64 signed int intptr_t;
+ typedef _W64 unsigned int uintptr_t;
+#endif // _WIN64 ]
+
+// 7.18.1.5 Greatest-width integer types
+typedef int64_t intmax_t;
+typedef uint64_t uintmax_t;
+
+
+// 7.18.2 Limits of specified-width integer types
+
+#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
+
+// 7.18.2.1 Limits of exact-width integer types
+#define INT8_MIN ((int8_t)_I8_MIN)
+#define INT8_MAX _I8_MAX
+#define INT16_MIN ((int16_t)_I16_MIN)
+#define INT16_MAX _I16_MAX
+#define INT32_MIN ((int32_t)_I32_MIN)
+#define INT32_MAX _I32_MAX
+#define INT64_MIN ((int64_t)_I64_MIN)
+#define INT64_MAX _I64_MAX
+#define UINT8_MAX _UI8_MAX
+#define UINT16_MAX _UI16_MAX
+#define UINT32_MAX _UI32_MAX
+#define UINT64_MAX _UI64_MAX
+
+// 7.18.2.2 Limits of minimum-width integer types
+#define INT_LEAST8_MIN INT8_MIN
+#define INT_LEAST8_MAX INT8_MAX
+#define INT_LEAST16_MIN INT16_MIN
+#define INT_LEAST16_MAX INT16_MAX
+#define INT_LEAST32_MIN INT32_MIN
+#define INT_LEAST32_MAX INT32_MAX
+#define INT_LEAST64_MIN INT64_MIN
+#define INT_LEAST64_MAX INT64_MAX
+#define UINT_LEAST8_MAX UINT8_MAX
+#define UINT_LEAST16_MAX UINT16_MAX
+#define UINT_LEAST32_MAX UINT32_MAX
+#define UINT_LEAST64_MAX UINT64_MAX
+
+// 7.18.2.3 Limits of fastest minimum-width integer types
+#define INT_FAST8_MIN INT8_MIN
+#define INT_FAST8_MAX INT8_MAX
+#define INT_FAST16_MIN INT16_MIN
+#define INT_FAST16_MAX INT16_MAX
+#define INT_FAST32_MIN INT32_MIN
+#define INT_FAST32_MAX INT32_MAX
+#define INT_FAST64_MIN INT64_MIN
+#define INT_FAST64_MAX INT64_MAX
+#define UINT_FAST8_MAX UINT8_MAX
+#define UINT_FAST16_MAX UINT16_MAX
+#define UINT_FAST32_MAX UINT32_MAX
+#define UINT_FAST64_MAX UINT64_MAX
+
+// 7.18.2.4 Limits of integer types capable of holding object pointers
+#ifdef _WIN64 // [
+# define INTPTR_MIN INT64_MIN
+# define INTPTR_MAX INT64_MAX
+# define UINTPTR_MAX UINT64_MAX
+#else // _WIN64 ][
+# define INTPTR_MIN INT32_MIN
+# define INTPTR_MAX INT32_MAX
+# define UINTPTR_MAX UINT32_MAX
+#endif // _WIN64 ]
+
+// 7.18.2.5 Limits of greatest-width integer types
+#define INTMAX_MIN INT64_MIN
+#define INTMAX_MAX INT64_MAX
+#define UINTMAX_MAX UINT64_MAX
+
+// 7.18.3 Limits of other integer types
+
+#ifdef _WIN64 // [
+# define PTRDIFF_MIN _I64_MIN
+# define PTRDIFF_MAX _I64_MAX
+#else // _WIN64 ][
+# define PTRDIFF_MIN _I32_MIN
+# define PTRDIFF_MAX _I32_MAX
+#endif // _WIN64 ]
+
+#define SIG_ATOMIC_MIN INT_MIN
+#define SIG_ATOMIC_MAX INT_MAX
+
+#ifndef SIZE_MAX // [
+# ifdef _WIN64 // [
+# define SIZE_MAX _UI64_MAX
+# else // _WIN64 ][
+# define SIZE_MAX _UI32_MAX
+# endif // _WIN64 ]
+#endif // SIZE_MAX ]
+
+// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
+#ifndef WCHAR_MIN // [
+# define WCHAR_MIN 0
+#endif // WCHAR_MIN ]
+#ifndef WCHAR_MAX // [
+# define WCHAR_MAX _UI16_MAX
+#endif // WCHAR_MAX ]
+
+#define WINT_MIN 0
+#define WINT_MAX _UI16_MAX
+
+#endif // __STDC_LIMIT_MACROS ]
+
+
+// 7.18.4 Limits of other integer types
+
+#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
+
+// 7.18.4.1 Macros for minimum-width integer constants
+
+#define INT8_C(val) val##i8
+#define INT16_C(val) val##i16
+#define INT32_C(val) val##i32
+#define INT64_C(val) val##i64
+
+#define UINT8_C(val) val##ui8
+#define UINT16_C(val) val##ui16
+#define UINT32_C(val) val##ui32
+#define UINT64_C(val) val##ui64
+
+// 7.18.4.2 Macros for greatest-width integer constants
+#define INTMAX_C INT64_C
+#define UINTMAX_C UINT64_C
+
+#endif // __STDC_CONSTANT_MACROS ]
+
+
+#endif // _MSC_STDINT_H_ ]
diff --git a/node_modules/mmmagic/deps/libmagic/src/BNF b/node_modules/mmmagic/deps/libmagic/src/BNF
new file mode 100644
index 0000000..243532f
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/BNF
@@ -0,0 +1,151 @@
+This is a first attempt to document the grammar used by magic(5), with
+hopes of eventually incorporating something like this into the manpage.
+
+Note: Currently, the parser varies slightly from this, but only in
+very minor ways, e.g., the strflags maybe separated by '/' characters
+and at most one strcount is allowed; likewise for regflags.
+
+------------------------------------------------------------------------
+magic = 1*query
+
+query = line *( 1*level line )
+
+level = ">" ;; Increment the level by 1.
+ ;; The first line of a query is at level 0.
+
+line = offset HWS type HWS test HWS message EOL
+
+------------------------------------------------------------------------
+offset = absoffset | reloffset | indoffset
+ ;; The offset in the file at which to apply
+ ;; the <test>.
+
+absoffset = NUMBER ;; An absolute offset from the start of the file.
+
+reloffset = "&" NUMBER ;; The offset relative to the last match offset
+ ;; at one level up.
+ ;; Not allowed at level == 0.
+
+indoffset = indoff | relindoff
+
+indoff = "(" offset1 [ "." size ] [ op disp ] ")"
+ ;; Read the file at <offset1> of width <size>.
+ ;; If size is not specified, assume a long.
+ ;; If <op> is given, then preform that
+ ;; operation on the result and the <disp>.
+
+offset1 = absoffset | reloffset
+
+size = byte | leshort | beshort | lelong | belong | melong
+
+byte = "B" | "b" | "C" | "c" ;; A one-byte value.
+leshort = "s" | "h" ;; A two-byte little-endian value.
+beshort = "S" | "H" ;; A two-byte big-endian value.
+lelong = "l" ;; A four-byte little-endian value.
+belong = "L" ;; A four-byte big-endian value.
+melong = "m" ;; A four-byte middle-endian value.
+
+op = [ invert ] ( "+" | "-" | "*" | "/" | "%" | "&" | "|" | "^" )
+
+invert = "~" ;; Flip the bits on result of the <op>.
+
+disp = NUMBER | memvalue
+
+memvalue = "(" NUMBER ")"
+ ;; NUMBER is interpreted as an absolute or
+ ;; relative offset matching that of <offset1>.
+ ;; Read the file at the resulting offset with
+ ;; the same size as <offset1>
+
+relindoff = "&" indoff ;; add <indoff> to the last match offset at
+ ;; one level up.
+
+------------------------------------------------------------------------
+type = [ unsigned ] ( numeric | strtype | default )
+
+unsigned = "u" ;; The value is unsigned.
+ ;; This affects the sign extension of numeric
+ ;; types and the '<' and '>' compares. It is
+ ;; intended for numeric types, but allowed on
+ ;; all types.
+
+numeric = ( numtype | datatype ) [ nummask ]
+
+numtype = byte | short | long | quad
+
+byte = "byte"
+short = "short" | "beshort" | "leshort"
+long = "long" | "lelong" | "belong" | "melong"
+quad = "quad" | "lequad" | "bequad"
+
+datetype = udate32 | ldate32 | udate64 | ldate64
+
+udate32 = "date" | "bedate" | "ledate" | "medate" ;; UTC dates
+ldate32 = "ldate" | "beldate" | "leldate" | "meldate" ;; local dates
+udate64 = "qdate" | "leqdate" | "beqdate" ;; UTC dates
+ldate64 = "qldate" | "leqldate" | "beqldate" ;; local dates
+
+nummask = op NUMBER
+
+strtype = regex | search | string8 | string16
+
+regex = "regex" [ "/" 1*regflag ]
+
+regflag = "c" | "s" | linecnt
+
+linecnt = NUMBER ;; The number of lines to search. If this
+ ;; is missing or zero, the rest of the
+ ;; file is searched.
+
+search = "string" [ "/" 1*srchflag ]
+
+srchflag = strflag | srchcnt
+
+srchcnt = NUMBER ;; The number of search tries. If this
+ ;; is missing or zero, the rest of the
+ ;; file is searched.
+
+string8 = ( "string" | "pstring" ) [ "/" 1*strflag ]
+
+strflag = "b" | "B" | "c" | "C"
+
+string16 = "bestring16" | "lestring16"
+
+default = "default" ;; This is intended to be used with the
+ ;; <truetest> ("x" below). It is matched if
+ ;; there has been no previous match at its
+ ;; level or none since the last default at
+ ;; that level. It is useful for implementing
+ ;; switch-like and if/else constructions.
+
+------------------------------------------------------------------------
+test = numtest | strtest | truetest
+ ;; Test to preform on <type> read from file.
+
+numtest = [ compare ] NUMBER ;; If compare is missing, "=" is assumed.
+
+strtest = [ compare ] STRING ;; If compare is missing, "=" is assumed.
+ ;; Note: If the STRING begins with a <compare>
+ ;; character, the <compare> field cannot be
+ ;; omitted.
+
+compare = "=" | "!" | "<" | ">" | "&" | "^"
+
+truetest = "x" ;; This always returns true.
+ ;; To test for the string "x" use "=x".
+
+------------------------------------------------------------------------
+message = [ nospflag ] ( STRING | FMT_STRING )
+ ;; Message to print if test result is true.
+
+nospflag = %x08 | "\\b" ;; Do not insert a space before the message.
+ ;; By default, messages are separated by a " ".
+
+------------------------------------------------------------------------
+HWS = <horizontal white space>
+EOL = <end of line marker>
+NUMBER = <C-style unsigned number>
+STRING = <C-style string without delimiting quotes>
+FMTSTR = <printf format string with exactly one % construct>
+
+------------------------------------------------------------------------
diff --git a/node_modules/mmmagic/deps/libmagic/src/apprentice.c b/node_modules/mmmagic/deps/libmagic/src/apprentice.c
new file mode 100644
index 0000000..8197f65
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/apprentice.c
@@ -0,0 +1,3429 @@
+/*
+ * Copyright (c) Ian F. Darwin 1986-1995.
+ * Software written by Ian F. Darwin and others;
+ * maintained 1995-present by Christos Zoulas and others.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice immediately at the beginning of the file, without modification,
+ * this list of conditions, and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+/*
+ * apprentice - make one pass through /etc/magic, learning its secrets.
+ */
+
+#include "file.h"
+
+#ifndef lint
+FILE_RCSID("@(#)$File: apprentice.c,v 1.262 2017/08/28 13:39:18 christos Exp $")
+#endif /* lint */
+
+#include "magic.h"
+#include <stdlib.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_STDDEF_H
+#include <stddef.h>
+#endif
+#include <string.h>
+#include <assert.h>
+#include <ctype.h>
+#include <fcntl.h>
+#ifdef QUICK
+#include <sys/mman.h>
+#endif
+// XXX: change by mscdex
+#ifdef HAVE_DIRENT_H
+#include <dirent.h>
+#endif
+#if defined(HAVE_LIMITS_H)
+#include <limits.h>
+#endif
+
+#ifndef SSIZE_MAX
+#define MAXMAGIC_SIZE ((ssize_t)0x7fffffff)
+#else
+#define MAXMAGIC_SIZE SSIZE_MAX
+#endif
+
+#define EATAB {while (isascii((unsigned char) *l) && \
+ isspace((unsigned char) *l)) ++l;}
+#define LOWCASE(l) (isupper((unsigned char) (l)) ? \
+ tolower((unsigned char) (l)) : (l))
+/*
+ * Work around a bug in headers on Digital Unix.
+ * At least confirmed for: OSF1 V4.0 878
+ */
+#if defined(__osf__) && defined(__DECC)
+#ifdef MAP_FAILED
+#undef MAP_FAILED
+#endif
+#endif
+
+#ifndef MAP_FAILED
+#define MAP_FAILED (void *) -1
+#endif
+
+#ifndef MAP_FILE
+#define MAP_FILE 0
+#endif
+
+#define ALLOC_CHUNK (size_t)10
+#define ALLOC_INCR (size_t)200
+
+#define MAP_TYPE_USER 0
+#define MAP_TYPE_MALLOC 1
+#define MAP_TYPE_MMAP 2
+
+struct magic_entry {
+ struct magic *mp;
+ uint32_t cont_count;
+ uint32_t max_count;
+};
+
+struct magic_entry_set {
+ struct magic_entry *me;
+ uint32_t count;
+ uint32_t max;
+};
+
+struct magic_map {
+ void *p;
+ size_t len;
+ int type;
+ struct magic *magic[MAGIC_SETS];
+ uint32_t nmagic[MAGIC_SETS];
+};
+
+int file_formats[FILE_NAMES_SIZE];
+const size_t file_nformats = FILE_NAMES_SIZE;
+const char *file_names[FILE_NAMES_SIZE];
+const size_t file_nnames = FILE_NAMES_SIZE;
+
+private int getvalue(struct magic_set *ms, struct magic *, const char **, int);
+private int hextoint(int);
+private const char *getstr(struct magic_set *, struct magic *, const char *,
+ int);
+private int parse(struct magic_set *, struct magic_entry *, const char *,
+ size_t, int);
+private void eatsize(const char **);
+private int apprentice_1(struct magic_set *, const char *, int);
+private size_t apprentice_magic_strength(const struct magic *);
+private int apprentice_sort(const void *, const void *);
+private void apprentice_list(struct mlist *, int );
+private struct magic_map *apprentice_load(struct magic_set *,
+ const char *, int);
+private struct mlist *mlist_alloc(void);
+private void mlist_free(struct mlist *);
+private void byteswap(struct magic *, uint32_t);
+private void bs1(struct magic *);
+private uint16_t swap2(uint16_t);
+private uint32_t swap4(uint32_t);
+private uint64_t swap8(uint64_t);
+private char *mkdbname(struct magic_set *, const char *, int);
+private struct magic_map *apprentice_buf(struct magic_set *, struct magic *,
+ size_t);
+private struct magic_map *apprentice_map(struct magic_set *, const char *);
+private int check_buffer(struct magic_set *, struct magic_map *, const char *);
+private void apprentice_unmap(struct magic_map *);
+private int apprentice_compile(struct magic_set *, struct magic_map *,
+ const char *);
+private int check_format_type(const char *, int, const char **);
+private int check_format(struct magic_set *, struct magic *);
+private int get_op(char);
+private int parse_mime(struct magic_set *, struct magic_entry *, const char *);
+private int parse_strength(struct magic_set *, struct magic_entry *, const char *);
+private int parse_apple(struct magic_set *, struct magic_entry *, const char *);
+private int parse_ext(struct magic_set *, struct magic_entry *, const char *);
+
+
+private size_t magicsize = sizeof(struct magic);
+
+private const char usg_hdr[] = "cont\toffset\ttype\topcode\tmask\tvalue\tdesc";
+
+private struct {
+ const char *name;
+ size_t len;
+ int (*fun)(struct magic_set *, struct magic_entry *, const char *);
+} bang[] = {
+#define DECLARE_FIELD(name) { # name, sizeof(# name) - 1, parse_ ## name }
+ DECLARE_FIELD(mime),
+ DECLARE_FIELD(apple),
+ DECLARE_FIELD(ext),
+ DECLARE_FIELD(strength),
+#undef DECLARE_FIELD
+ { NULL, 0, NULL }
+};
+
+#ifdef COMPILE_ONLY
+
+int main(int, char *[]);
+
+int
+main(int argc, char *argv[])
+{
+ int ret;
+ struct magic_set *ms;
+ char *progname;
+
+ if ((progname = strrchr(argv[0], '/')) != NULL)
+ progname++;
+ else
+ progname = argv[0];
+
+ if (argc != 2) {
+ (void)fprintf(stderr, "Usage: %s file\n", progname);
+ return 1;
+ }
+
+ if ((ms = magic_open(MAGIC_CHECK)) == NULL) {
+ (void)fprintf(stderr, "%s: %s\n", progname, strerror(errno));
+ return 1;
+ }
+ ret = magic_compile(ms, argv[1]) == -1 ? 1 : 0;
+ if (ret == 1)
+ (void)fprintf(stderr, "%s: %s\n", progname, magic_error(ms));
+ magic_close(ms);
+ return ret;
+}
+#endif /* COMPILE_ONLY */
+
+struct type_tbl_s {
+ const char name[16];
+ const size_t len;
+ const int type;
+ const int format;
+};
+
+/*
+ * XXX - the actual Single UNIX Specification says that "long" means "long",
+ * as in the C data type, but we treat it as meaning "4-byte integer".
+ * Given that the OS X version of file 5.04 did the same, I guess that passes
+ * the actual test; having "long" be dependent on how big a "long" is on
+ * the machine running "file" is silly.
+ */
+static const struct type_tbl_s type_tbl[] = {
+# define XX(s) s, (sizeof(s) - 1)
+# define XX_NULL "", 0
+ { XX("invalid"), FILE_INVALID, FILE_FMT_NONE },
+ { XX("byte"), FILE_BYTE, FILE_FMT_NUM },
+ { XX("short"), FILE_SHORT, FILE_FMT_NUM },
+ { XX("default"), FILE_DEFAULT, FILE_FMT_NONE },
+ { XX("long"), FILE_LONG, FILE_FMT_NUM },
+ { XX("string"), FILE_STRING, FILE_FMT_STR },
+ { XX("date"), FILE_DATE, FILE_FMT_STR },
+ { XX("beshort"), FILE_BESHORT, FILE_FMT_NUM },
+ { XX("belong"), FILE_BELONG, FILE_FMT_NUM },
+ { XX("bedate"), FILE_BEDATE, FILE_FMT_STR },
+ { XX("leshort"), FILE_LESHORT, FILE_FMT_NUM },
+ { XX("lelong"), FILE_LELONG, FILE_FMT_NUM },
+ { XX("ledate"), FILE_LEDATE, FILE_FMT_STR },
+ { XX("pstring"), FILE_PSTRING, FILE_FMT_STR },
+ { XX("ldate"), FILE_LDATE, FILE_FMT_STR },
+ { XX("beldate"), FILE_BELDATE, FILE_FMT_STR },
+ { XX("leldate"), FILE_LELDATE, FILE_FMT_STR },
+ { XX("regex"), FILE_REGEX, FILE_FMT_STR },
+ { XX("bestring16"), FILE_BESTRING16, FILE_FMT_STR },
+ { XX("lestring16"), FILE_LESTRING16, FILE_FMT_STR },
+ { XX("search"), FILE_SEARCH, FILE_FMT_STR },
+ { XX("medate"), FILE_MEDATE, FILE_FMT_STR },
+ { XX("meldate"), FILE_MELDATE, FILE_FMT_STR },
+ { XX("melong"), FILE_MELONG, FILE_FMT_NUM },
+ { XX("quad"), FILE_QUAD, FILE_FMT_QUAD },
+ { XX("lequad"), FILE_LEQUAD, FILE_FMT_QUAD },
+ { XX("bequad"), FILE_BEQUAD, FILE_FMT_QUAD },
+ { XX("qdate"), FILE_QDATE, FILE_FMT_STR },
+ { XX("leqdate"), FILE_LEQDATE, FILE_FMT_STR },
+ { XX("beqdate"), FILE_BEQDATE, FILE_FMT_STR },
+ { XX("qldate"), FILE_QLDATE, FILE_FMT_STR },
+ { XX("leqldate"), FILE_LEQLDATE, FILE_FMT_STR },
+ { XX("beqldate"), FILE_BEQLDATE, FILE_FMT_STR },
+ { XX("float"), FILE_FLOAT, FILE_FMT_FLOAT },
+ { XX("befloat"), FILE_BEFLOAT, FILE_FMT_FLOAT },
+ { XX("lefloat"), FILE_LEFLOAT, FILE_FMT_FLOAT },
+ { XX("double"), FILE_DOUBLE, FILE_FMT_DOUBLE },
+ { XX("bedouble"), FILE_BEDOUBLE, FILE_FMT_DOUBLE },
+ { XX("ledouble"), FILE_LEDOUBLE, FILE_FMT_DOUBLE },
+ { XX("leid3"), FILE_LEID3, FILE_FMT_NUM },
+ { XX("beid3"), FILE_BEID3, FILE_FMT_NUM },
+ { XX("indirect"), FILE_INDIRECT, FILE_FMT_NUM },
+ { XX("qwdate"), FILE_QWDATE, FILE_FMT_STR },
+ { XX("leqwdate"), FILE_LEQWDATE, FILE_FMT_STR },
+ { XX("beqwdate"), FILE_BEQWDATE, FILE_FMT_STR },
+ { XX("name"), FILE_NAME, FILE_FMT_NONE },
+ { XX("use"), FILE_USE, FILE_FMT_NONE },
+ { XX("clear"), FILE_CLEAR, FILE_FMT_NONE },
+ { XX("der"), FILE_DER, FILE_FMT_STR },
+ { XX_NULL, FILE_INVALID, FILE_FMT_NONE },
+};
+
+/*
+ * These are not types, and cannot be preceded by "u" to make them
+ * unsigned.
+ */
+static const struct type_tbl_s special_tbl[] = {
+ { XX("der"), FILE_DER, FILE_FMT_STR },
+ { XX("name"), FILE_NAME, FILE_FMT_STR },
+ { XX("use"), FILE_USE, FILE_FMT_STR },
+ { XX_NULL, FILE_INVALID, FILE_FMT_NONE },
+};
+# undef XX
+# undef XX_NULL
+
+private int
+get_type(const struct type_tbl_s *tbl, const char *l, const char **t)
+{
+ const struct type_tbl_s *p;
+
+ for (p = tbl; p->len; p++) {
+ if (strncmp(l, p->name, p->len) == 0) {
+ if (t)
+ *t = l + p->len;
+ break;
+ }
+ }
+ return p->type;
+}
+
+private int
+get_standard_integer_type(const char *l, const char **t)
+{
+ int type;
+
+ if (isalpha((unsigned char)l[1])) {
+ switch (l[1]) {
+ case 'C':
+ /* "dC" and "uC" */
+ type = FILE_BYTE;
+ break;
+ case 'S':
+ /* "dS" and "uS" */
+ type = FILE_SHORT;
+ break;
+ case 'I':
+ case 'L':
+ /*
+ * "dI", "dL", "uI", and "uL".
+ *
+ * XXX - the actual Single UNIX Specification says
+ * that "L" means "long", as in the C data type,
+ * but we treat it as meaning "4-byte integer".
+ * Given that the OS X version of file 5.04 did
+ * the same, I guess that passes the actual SUS
+ * validation suite; having "dL" be dependent on
+ * how big a "long" is on the machine running
+ * "file" is silly.
+ */
+ type = FILE_LONG;
+ break;
+ case 'Q':
+ /* "dQ" and "uQ" */
+ type = FILE_QUAD;
+ break;
+ default:
+ /* "d{anything else}", "u{anything else}" */
+ return FILE_INVALID;
+ }
+ l += 2;
+ } else if (isdigit((unsigned char)l[1])) {
+ /*
+ * "d{num}" and "u{num}"; we only support {num} values
+ * of 1, 2, 4, and 8 - the Single UNIX Specification
+ * doesn't say anything about whether arbitrary
+ * values should be supported, but both the Solaris 10
+ * and OS X Mountain Lion versions of file passed the
+ * Single UNIX Specification validation suite, and
+ * neither of them support values bigger than 8 or
+ * non-power-of-2 values.
+ */
+ if (isdigit((unsigned char)l[2])) {
+ /* Multi-digit, so > 9 */
+ return FILE_INVALID;
+ }
+ switch (l[1]) {
+ case '1':
+ type = FILE_BYTE;
+ break;
+ case '2':
+ type = FILE_SHORT;
+ break;
+ case '4':
+ type = FILE_LONG;
+ break;
+ case '8':
+ type = FILE_QUAD;
+ break;
+ default:
+ /* XXX - what about 3, 5, 6, or 7? */
+ return FILE_INVALID;
+ }
+ l += 2;
+ } else {
+ /*
+ * "d" or "u" by itself.
+ */
+ type = FILE_LONG;
+ ++l;
+ }
+ if (t)
+ *t = l;
+ return type;
+}
+
+private void
+init_file_tables(void)
+{
+ static int done = 0;
+ const struct type_tbl_s *p;
+
+ if (done)
+ return;
+ done++;
+
+ for (p = type_tbl; p->len; p++) {
+ assert(p->type < FILE_NAMES_SIZE);
+ file_names[p->type] = p->name;
+ file_formats[p->type] = p->format;
+ }
+ assert(p - type_tbl == FILE_NAMES_SIZE);
+}
+
+private int
+add_mlist(struct mlist *mlp, struct magic_map *map, size_t idx)
+{
+ struct mlist *ml;
+
+ mlp->map = NULL;
+ if ((ml = CAST(struct mlist *, malloc(sizeof(*ml)))) == NULL)
+ return -1;
+
+ ml->map = idx == 0 ? map : NULL;
+ ml->magic = map->magic[idx];
+ ml->nmagic = map->nmagic[idx];
+
+ mlp->prev->next = ml;
+ ml->prev = mlp->prev;
+ ml->next = mlp;
+ mlp->prev = ml;
+ return 0;
+}
+
+/*
+ * Handle one file or directory.
+ */
+private int
+apprentice_1(struct magic_set *ms, const char *fn, int action)
+{
+ struct magic_map *map;
+#ifndef COMPILE_ONLY
+ struct mlist *ml;
+ size_t i;
+#endif
+
+ if (magicsize != FILE_MAGICSIZE) {
+ file_error(ms, 0, "magic element size %lu != %lu",
+ (unsigned long)sizeof(*map->magic[0]),
+ (unsigned long)FILE_MAGICSIZE);
+ return -1;
+ }
+
+ if (action == FILE_COMPILE) {
+ map = apprentice_load(ms, fn, action);
+ if (map == NULL)
+ return -1;
+ return apprentice_compile(ms, map, fn);
+ }
+
+#ifndef COMPILE_ONLY
+ map = apprentice_map(ms, fn);
+ if (map == (struct magic_map *)-1)
+ return -1;
+ if (map == NULL) {
+ if (ms->flags & MAGIC_CHECK)
+ file_magwarn(ms, "using regular magic file `%s'", fn);
+ map = apprentice_load(ms, fn, action);
+ if (map == NULL)
+ return -1;
+ }
+
+ for (i = 0; i < MAGIC_SETS; i++) {
+ if (add_mlist(ms->mlist[i], map, i) == -1) {
+ file_oomem(ms, sizeof(*ml));
+ return -1;
+ }
+ }
+
+ if (action == FILE_LIST) {
+ for (i = 0; i < MAGIC_SETS; i++) {
+ printf("Set %" SIZE_T_FORMAT "u:\nBinary patterns:\n",
+ i);
+ apprentice_list(ms->mlist[i], BINTEST);
+ printf("Text patterns:\n");
+ apprentice_list(ms->mlist[i], TEXTTEST);
+ }
+ }
+ return 0;
+#else
+ return 0;
+#endif /* COMPILE_ONLY */
+}
+
+protected void
+file_ms_free(struct magic_set *ms)
+{
+ size_t i;
+ if (ms == NULL)
+ return;
+ for (i = 0; i < MAGIC_SETS; i++)
+ mlist_free(ms->mlist[i]);
+ free(ms->o.pbuf);
+ free(ms->o.buf);
+ free(ms->c.li);
+ free(ms);
+}
+
+protected struct magic_set *
+file_ms_alloc(int flags)
+{
+ struct magic_set *ms;
+ size_t i, len;
+
+ if ((ms = CAST(struct magic_set *, calloc((size_t)1,
+ sizeof(struct magic_set)))) == NULL)
+ return NULL;
+
+ if (magic_setflags(ms, flags) == -1) {
+ errno = EINVAL;
+ goto free;
+ }
+
+ ms->o.buf = ms->o.pbuf = NULL;
+ len = (ms->c.len = 10) * sizeof(*ms->c.li);
+
+ if ((ms->c.li = CAST(struct level_info *, malloc(len))) == NULL)
+ goto free;
+
+ ms->event_flags = 0;
+ ms->error = -1;
+ for (i = 0; i < MAGIC_SETS; i++)
+ ms->mlist[i] = NULL;
+ ms->file = "unknown";
+ ms->line = 0;
+ ms->indir_max = FILE_INDIR_MAX;
+ ms->name_max = FILE_NAME_MAX;
+ ms->elf_shnum_max = FILE_ELF_SHNUM_MAX;
+ ms->elf_phnum_max = FILE_ELF_PHNUM_MAX;
+ ms->elf_notes_max = FILE_ELF_NOTES_MAX;
+ ms->regex_max = FILE_REGEX_MAX;
+ ms->bytes_max = FILE_BYTES_MAX;
+ return ms;
+free:
+ free(ms);
+ return NULL;
+}
+
+private void
+apprentice_unmap(struct magic_map *map)
+{
+ size_t i;
+ if (map == NULL)
+ return;
+
+ switch (map->type) {
+ case MAP_TYPE_USER:
+ break;
+ case MAP_TYPE_MALLOC:
+ for (i = 0; i < MAGIC_SETS; i++) {
+ void *b = map->magic[i];
+ void *p = map->p;
+ if (CAST(char *, b) >= CAST(char *, p) &&
+ CAST(char *, b) <= CAST(char *, p) + map->len)
+ continue;
+ free(map->magic[i]);
+ }
+ free(map->p);
+ break;
+#ifdef QUICK
+ case MAP_TYPE_MMAP:
+ if (map->p && map->p != MAP_FAILED)
+ (void)munmap(map->p, map->len);
+ break;
+#endif
+ default:
+ abort();
+ }
+ free(map);
+}
+
+private struct mlist *
+mlist_alloc(void)
+{
+ struct mlist *mlist;
+ if ((mlist = CAST(struct mlist *, calloc(1, sizeof(*mlist)))) == NULL) {
+ return NULL;
+ }
+ mlist->next = mlist->prev = mlist;
+ return mlist;
+}
+
+private void
+mlist_free(struct mlist *mlist)
+{
+ struct mlist *ml, *next;
+
+ if (mlist == NULL)
+ return;
+
+ ml = mlist->next;
+ for (ml = mlist->next; (next = ml->next) != NULL; ml = next) {
+ if (ml->map)
+ apprentice_unmap(CAST(struct magic_map *, ml->map));
+ free(ml);
+ if (ml == mlist)
+ break;
+ }
+}
+
+#ifndef COMPILE_ONLY
+/* void **bufs: an array of compiled magic files */
+protected int
+buffer_apprentice(struct magic_set *ms, struct magic **bufs,
+ size_t *sizes, size_t nbufs)
+{
+ size_t i, j;
+ struct mlist *ml;
+ struct magic_map *map;
+
+ if (nbufs == 0)
+ return -1;
+
+ (void)file_reset(ms, 0);
+
+ init_file_tables();
+
+ for (i = 0; i < MAGIC_SETS; i++) {
+ mlist_free(ms->mlist[i]);
+ if ((ms->mlist[i] = mlist_alloc()) == NULL) {
+ file_oomem(ms, sizeof(*ms->mlist[i]));
+ goto fail;
+ }
+ }
+
+ for (i = 0; i < nbufs; i++) {
+ map = apprentice_buf(ms, bufs[i], sizes[i]);
+ if (map == NULL)
+ goto fail;
+
+ for (j = 0; j < MAGIC_SETS; j++) {
+ if (add_mlist(ms->mlist[j], map, j) == -1) {
+ file_oomem(ms, sizeof(*ml));
+ goto fail;
+ }
+ }
+ }
+
+ return 0;
+fail:
+ for (i = 0; i < MAGIC_SETS; i++) {
+ mlist_free(ms->mlist[i]);
+ ms->mlist[i] = NULL;
+ }
+ return -1;
+}
+#endif
+
+/* const char *fn: list of magic files and directories */
+protected int
+file_apprentice(struct magic_set *ms, const char *fn, int action)
+{
+ char *p, *mfn;
+ int file_err, errs = -1;
+ size_t i;
+
+ (void)file_reset(ms, 0);
+
+ if ((fn = magic_getpath(fn, action)) == NULL)
+ return -1;
+
+ init_file_tables();
+
+ if ((mfn = strdup(fn)) == NULL) {
+ file_oomem(ms, strlen(fn));
+ return -1;
+ }
+
+ for (i = 0; i < MAGIC_SETS; i++) {
+ mlist_free(ms->mlist[i]);
+ if ((ms->mlist[i] = mlist_alloc()) == NULL) {
+ file_oomem(ms, sizeof(*ms->mlist[i]));
+ while (i-- > 0) {
+ mlist_free(ms->mlist[i]);
+ ms->mlist[i] = NULL;
+ }
+ free(mfn);
+ return -1;
+ }
+ }
+ fn = mfn;
+
+ while (fn) {
+ p = strchr(fn, PATHSEP);
+ if (p)
+ *p++ = '\0';
+ if (*fn == '\0')
+ break;
+ file_err = apprentice_1(ms, fn, action);
+ errs = MAX(errs, file_err);
+ fn = p;
+ }
+
+ free(mfn);
+
+ if (errs == -1) {
+ for (i = 0; i < MAGIC_SETS; i++) {
+ mlist_free(ms->mlist[i]);
+ ms->mlist[i] = NULL;
+ }
+ // XXX: change by mscdex
+ file_error(ms, 0, "could not load any valid magic files!");
+ return -1;
+ }
+
+#if 0
+ /*
+ * Always leave the database loaded
+ */
+ if (action == FILE_LOAD)
+ return 0;
+
+ for (i = 0; i < MAGIC_SETS; i++) {
+ mlist_free(ms->mlist[i]);
+ ms->mlist[i] = NULL;
+ }
+#endif
+
+ switch (action) {
+ case FILE_LOAD:
+ case FILE_COMPILE:
+ case FILE_CHECK:
+ case FILE_LIST:
+ return 0;
+ default:
+ file_error(ms, 0, "Invalid action %d", action);
+ return -1;
+ }
+}
+
+/*
+ * Compute the real length of a magic expression, for the purposes
+ * of determining how "strong" a magic expression is (approximating
+ * how specific its matches are):
+ * - magic characters count 0 unless escaped.
+ * - [] expressions count 1
+ * - {} expressions count 0
+ * - regular characters or escaped magic characters count 1
+ * - 0 length expressions count as one
+ */
+private size_t
+nonmagic(const char *str)
+{
+ const char *p;
+ size_t rv = 0;
+
+ for (p = str; *p; p++)
+ switch (*p) {
+ case '\\': /* Escaped anything counts 1 */
+ if (!*++p)
+ p--;
+ rv++;
+ continue;
+ case '?': /* Magic characters count 0 */
+ case '*':
+ case '.':
+ case '+':
+ case '^':
+ case '$':
+ continue;
+ case '[': /* Bracketed expressions count 1 the ']' */
+ while (*p && *p != ']')
+ p++;
+ p--;
+ continue;
+ case '{': /* Braced expressions count 0 */
+ while (*p && *p != '}')
+ p++;
+ if (!*p)
+ p--;
+ continue;
+ default: /* Anything else counts 1 */
+ rv++;
+ continue;
+ }
+
+ return rv == 0 ? 1 : rv; /* Return at least 1 */
+}
+
+
+private size_t
+typesize(int type)
+{
+ switch (type) {
+ case FILE_BYTE:
+ return 1;
+
+ case FILE_SHORT:
+ case FILE_LESHORT:
+ case FILE_BESHORT:
+ return 2;
+
+ case FILE_LONG:
+ case FILE_LELONG:
+ case FILE_BELONG:
+ case FILE_MELONG:
+ return 4;
+
+ case FILE_DATE:
+ case FILE_LEDATE:
+ case FILE_BEDATE:
+ case FILE_MEDATE:
+ case FILE_LDATE:
+ case FILE_LELDATE:
+ case FILE_BELDATE:
+ case FILE_MELDATE:
+ case FILE_FLOAT:
+ case FILE_BEFLOAT:
+ case FILE_LEFLOAT:
+ return 4;
+
+ case FILE_QUAD:
+ case FILE_BEQUAD:
+ case FILE_LEQUAD:
+ case FILE_QDATE:
+ case FILE_LEQDATE:
+ case FILE_BEQDATE:
+ case FILE_QLDATE:
+ case FILE_LEQLDATE:
+ case FILE_BEQLDATE:
+ case FILE_QWDATE:
+ case FILE_LEQWDATE:
+ case FILE_BEQWDATE:
+ case FILE_DOUBLE:
+ case FILE_BEDOUBLE:
+ case FILE_LEDOUBLE:
+ return 8;
+ default:
+ return (size_t)~0;
+ }
+}
+
+/*
+ * Get weight of this magic entry, for sorting purposes.
+ */
+private size_t
+apprentice_magic_strength(const struct magic *m)
+{
+#define MULT 10
+ size_t ts, v, val = 2 * MULT; /* baseline strength */
+
+ switch (m->type) {
+ case FILE_DEFAULT: /* make sure this sorts last */
+ if (m->factor_op != FILE_FACTOR_OP_NONE)
+ abort();
+ return 0;
+
+ case FILE_BYTE:
+ case FILE_SHORT:
+ case FILE_LESHORT:
+ case FILE_BESHORT:
+ case FILE_LONG:
+ case FILE_LELONG:
+ case FILE_BELONG:
+ case FILE_MELONG:
+ case FILE_DATE:
+ case FILE_LEDATE:
+ case FILE_BEDATE:
+ case FILE_MEDATE:
+ case FILE_LDATE:
+ case FILE_LELDATE:
+ case FILE_BELDATE:
+ case FILE_MELDATE:
+ case FILE_FLOAT:
+ case FILE_BEFLOAT:
+ case FILE_LEFLOAT:
+ case FILE_QUAD:
+ case FILE_BEQUAD:
+ case FILE_LEQUAD:
+ case FILE_QDATE:
+ case FILE_LEQDATE:
+ case FILE_BEQDATE:
+ case FILE_QLDATE:
+ case FILE_LEQLDATE:
+ case FILE_BEQLDATE:
+ case FILE_QWDATE:
+ case FILE_LEQWDATE:
+ case FILE_BEQWDATE:
+ case FILE_DOUBLE:
+ case FILE_BEDOUBLE:
+ case FILE_LEDOUBLE:
+ ts = typesize(m->type);
+ if (ts == (size_t)~0)
+ abort();
+ val += ts * MULT;
+ break;
+
+ case FILE_PSTRING:
+ case FILE_STRING:
+ val += m->vallen * MULT;
+ break;
+
+ case FILE_BESTRING16:
+ case FILE_LESTRING16:
+ val += m->vallen * MULT / 2;
+ break;
+
+ case FILE_SEARCH:
+ val += m->vallen * MAX(MULT / m->vallen, 1);
+ break;
+
+ case FILE_REGEX:
+ v = nonmagic(m->value.s);
+ val += v * MAX(MULT / v, 1);
+ break;
+
+ case FILE_INDIRECT:
+ case FILE_NAME:
+ case FILE_USE:
+ break;
+
+ case FILE_DER:
+ val += MULT;
+ break;
+
+ default:
+ (void)fprintf(stderr, "Bad type %d\n", m->type);
+ abort();
+ }
+
+ switch (m->reln) {
+ case 'x': /* matches anything penalize */
+ case '!': /* matches almost anything penalize */
+ val = 0;
+ break;
+
+ case '=': /* Exact match, prefer */
+ val += MULT;
+ break;
+
+ case '>':
+ case '<': /* comparison match reduce strength */
+ val -= 2 * MULT;
+ break;
+
+ case '^':
+ case '&': /* masking bits, we could count them too */
+ val -= MULT;
+ break;
+
+ default:
+ (void)fprintf(stderr, "Bad relation %c\n", m->reln);
+ abort();
+ }
+
+ if (val == 0) /* ensure we only return 0 for FILE_DEFAULT */
+ val = 1;
+
+ switch (m->factor_op) {
+ case FILE_FACTOR_OP_NONE:
+ break;
+ case FILE_FACTOR_OP_PLUS:
+ val += m->factor;
+ break;
+ case FILE_FACTOR_OP_MINUS:
+ val -= m->factor;
+ break;
+ case FILE_FACTOR_OP_TIMES:
+ val *= m->factor;
+ break;
+ case FILE_FACTOR_OP_DIV:
+ val /= m->factor;
+ break;
+ default:
+ abort();
+ }
+
+ /*
+ * Magic entries with no description get a bonus because they depend
+ * on subsequent magic entries to print something.
+ */
+ if (m->desc[0] == '\0')
+ val++;
+ return val;
+}
+
+/*
+ * Sort callback for sorting entries by "strength" (basically length)
+ */
+private int
+apprentice_sort(const void *a, const void *b)
+{
+ const struct magic_entry *ma = CAST(const struct magic_entry *, a);
+ const struct magic_entry *mb = CAST(const struct magic_entry *, b);
+ size_t sa = apprentice_magic_strength(ma->mp);
+ size_t sb = apprentice_magic_strength(mb->mp);
+ if (sa == sb)
+ return 0;
+ else if (sa > sb)
+ return -1;
+ else
+ return 1;
+}
+
+/*
+ * Shows sorted patterns list in the order which is used for the matching
+ */
+private void
+apprentice_list(struct mlist *mlist, int mode)
+{
+ uint32_t magindex = 0;
+ struct mlist *ml;
+ for (ml = mlist->next; ml != mlist; ml = ml->next) {
+ for (magindex = 0; magindex < ml->nmagic; magindex++) {
+ struct magic *m = &ml->magic[magindex];
+ if ((m->flag & mode) != mode) {
+ /* Skip sub-tests */
+ while (magindex + 1 < ml->nmagic &&
+ ml->magic[magindex + 1].cont_level != 0)
+ ++magindex;
+ continue; /* Skip to next top-level test*/
+ }
+
+ /*
+ * Try to iterate over the tree until we find item with
+ * description/mimetype.
+ */
+ while (magindex + 1 < ml->nmagic &&
+ ml->magic[magindex + 1].cont_level != 0 &&
+ *ml->magic[magindex].desc == '\0' &&
+ *ml->magic[magindex].mimetype == '\0')
+ magindex++;
+
+ printf("Strength = %3" SIZE_T_FORMAT "u@%u: %s [%s]\n",
+ apprentice_magic_strength(m),
+ ml->magic[magindex].lineno,
+ ml->magic[magindex].desc,
+ ml->magic[magindex].mimetype);
+ }
+ }
+}
+
+private void
+set_test_type(struct magic *mstart, struct magic *m)
+{
+ switch (m->type) {
+ case FILE_BYTE:
+ case FILE_SHORT:
+ case FILE_LONG:
+ case FILE_DATE:
+ case FILE_BESHORT:
+ case FILE_BELONG:
+ case FILE_BEDATE:
+ case FILE_LESHORT:
+ case FILE_LELONG:
+ case FILE_LEDATE:
+ case FILE_LDATE:
+ case FILE_BELDATE:
+ case FILE_LELDATE:
+ case FILE_MEDATE:
+ case FILE_MELDATE:
+ case FILE_MELONG:
+ case FILE_QUAD:
+ case FILE_LEQUAD:
+ case FILE_BEQUAD:
+ case FILE_QDATE:
+ case FILE_LEQDATE:
+ case FILE_BEQDATE:
+ case FILE_QLDATE:
+ case FILE_LEQLDATE:
+ case FILE_BEQLDATE:
+ case FILE_QWDATE:
+ case FILE_LEQWDATE:
+ case FILE_BEQWDATE:
+ case FILE_FLOAT:
+ case FILE_BEFLOAT:
+ case FILE_LEFLOAT:
+ case FILE_DOUBLE:
+ case FILE_BEDOUBLE:
+ case FILE_LEDOUBLE:
+ case FILE_DER:
+ mstart->flag |= BINTEST;
+ break;
+ case FILE_STRING:
+ case FILE_PSTRING:
+ case FILE_BESTRING16:
+ case FILE_LESTRING16:
+ /* Allow text overrides */
+ if (mstart->str_flags & STRING_TEXTTEST)
+ mstart->flag |= TEXTTEST;
+ else
+ mstart->flag |= BINTEST;
+ break;
+ case FILE_REGEX:
+ case FILE_SEARCH:
+ /* Check for override */
+ if (mstart->str_flags & STRING_BINTEST)
+ mstart->flag |= BINTEST;
+ if (mstart->str_flags & STRING_TEXTTEST)
+ mstart->flag |= TEXTTEST;
+
+ if (mstart->flag & (TEXTTEST|BINTEST))
+ break;
+
+ /* binary test if pattern is not text */
+ if (file_looks_utf8(m->value.us, (size_t)m->vallen, NULL,
+ NULL) <= 0)
+ mstart->flag |= BINTEST;
+ else
+ mstart->flag |= TEXTTEST;
+ break;
+ case FILE_DEFAULT:
+ /* can't deduce anything; we shouldn't see this at the
+ top level anyway */
+ break;
+ case FILE_INVALID:
+ default:
+ /* invalid search type, but no need to complain here */
+ break;
+ }
+}
+
+private int
+addentry(struct magic_set *ms, struct magic_entry *me,
+ struct magic_entry_set *mset)
+{
+ size_t i = me->mp->type == FILE_NAME ? 1 : 0;
+ if (mset[i].count == mset[i].max) {
+ struct magic_entry *mp;
+
+ mset[i].max += ALLOC_INCR;
+ if ((mp = CAST(struct magic_entry *,
+ realloc(mset[i].me, sizeof(*mp) * mset[i].max))) ==
+ NULL) {
+ file_oomem(ms, sizeof(*mp) * mset[i].max);
+ return -1;
+ }
+ (void)memset(&mp[mset[i].count], 0, sizeof(*mp) *
+ ALLOC_INCR);
+ mset[i].me = mp;
+ }
+ mset[i].me[mset[i].count++] = *me;
+ memset(me, 0, sizeof(*me));
+ return 0;
+}
+
+/*
+ * Load and parse one file.
+ */
+private void
+load_1(struct magic_set *ms, int action, const char *fn, int *errs,
+ struct magic_entry_set *mset)
+{
+ size_t lineno = 0, llen = 0;
+ char *line = NULL;
+ ssize_t len;
+ struct magic_entry me;
+
+ FILE *f = fopen(ms->file = fn, "r");
+ if (f == NULL) {
+ if (errno != ENOENT)
+ file_error(ms, errno, "cannot read magic file `%s'",
+ fn);
+ (*errs)++;
+ return;
+ }
+
+ memset(&me, 0, sizeof(me));
+ /* read and parse this file */
+ for (ms->line = 1; (len = getline(&line, &llen, f)) != -1;
+ ms->line++) {
+ if (len == 0) /* null line, garbage, etc */
+ continue;
+ if (line[len - 1] == '\n') {
+ lineno++;
+ line[len - 1] = '\0'; /* delete newline */
+ }
+ switch (line[0]) {
+ case '\0': /* empty, do not parse */
+ case '#': /* comment, do not parse */
+ continue;
+ case '!':
+ if (line[1] == ':') {
+ size_t i;
+
+ for (i = 0; bang[i].name != NULL; i++) {
+ if ((size_t)(len - 2) > bang[i].len &&
+ memcmp(bang[i].name, line + 2,
+ bang[i].len) == 0)
+ break;
+ }
+ if (bang[i].name == NULL) {
+ file_error(ms, 0,
+ "Unknown !: entry `%s'", line);
+ (*errs)++;
+ continue;
+ }
+ if (me.mp == NULL) {
+ file_error(ms, 0,
+ "No current entry for :!%s type",
+ bang[i].name);
+ (*errs)++;
+ continue;
+ }
+ if ((*bang[i].fun)(ms, &me,
+ line + bang[i].len + 2) != 0) {
+ (*errs)++;
+ continue;
+ }
+ continue;
+ }
+ /*FALLTHROUGH*/
+ default:
+ again:
+ switch (parse(ms, &me, line, lineno, action)) {
+ case 0:
+ continue;
+ case 1:
+ (void)addentry(ms, &me, mset);
+ goto again;
+ default:
+ (*errs)++;
+ break;
+ }
+ }
+ }
+ if (me.mp)
+ (void)addentry(ms, &me, mset);
+ free(line);
+ (void)fclose(f);
+}
+
+/*
+ * parse a file or directory of files
+ * const char *fn: name of magic file or directory
+ */
+private int
+cmpstrp(const void *p1, const void *p2)
+{
+ return strcmp(*(char *const *)p1, *(char *const *)p2);
+}
+
+
+private uint32_t
+set_text_binary(struct magic_set *ms, struct magic_entry *me, uint32_t nme,
+ uint32_t starttest)
+{
+ static const char text[] = "text";
+ static const char binary[] = "binary";
+ static const size_t len = sizeof(text);
+
+ uint32_t i = starttest;
+
+ do {
+ set_test_type(me[starttest].mp, me[i].mp);
+ if ((ms->flags & MAGIC_DEBUG) == 0)
+ continue;
+ (void)fprintf(stderr, "%s%s%s: %s\n",
+ me[i].mp->mimetype,
+ me[i].mp->mimetype[0] == '\0' ? "" : "; ",
+ me[i].mp->desc[0] ? me[i].mp->desc : "(no description)",
+ me[i].mp->flag & BINTEST ? binary : text);
+ if (me[i].mp->flag & BINTEST) {
+ char *p = strstr(me[i].mp->desc, text);
+ if (p && (p == me[i].mp->desc ||
+ isspace((unsigned char)p[-1])) &&
+ (p + len - me[i].mp->desc == MAXstring
+ || (p[len] == '\0' ||
+ isspace((unsigned char)p[len]))))
+ (void)fprintf(stderr, "*** Possible "
+ "binary test for text type\n");
+ }
+ } while (++i < nme && me[i].mp->cont_level != 0);
+ return i;
+}
+
+private void
+set_last_default(struct magic_set *ms, struct magic_entry *me, uint32_t nme)
+{
+ uint32_t i;
+ for (i = 0; i < nme; i++) {
+ if (me[i].mp->cont_level == 0 &&
+ me[i].mp->type == FILE_DEFAULT) {
+ while (++i < nme)
+ if (me[i].mp->cont_level == 0)
+ break;
+ if (i != nme) {
+ /* XXX - Ugh! */
+ ms->line = me[i].mp->lineno;
+ file_magwarn(ms,
+ "level 0 \"default\" did not sort last");
+ }
+ return;
+ }
+ }
+}
+
+private int
+coalesce_entries(struct magic_set *ms, struct magic_entry *me, uint32_t nme,
+ struct magic **ma, uint32_t *nma)
+{
+ uint32_t i, mentrycount = 0;
+ size_t slen;
+
+ for (i = 0; i < nme; i++)
+ mentrycount += me[i].cont_count;
+
+ slen = sizeof(**ma) * mentrycount;
+ if ((*ma = CAST(struct magic *, malloc(slen))) == NULL) {
+ file_oomem(ms, slen);
+ return -1;
+ }
+
+ mentrycount = 0;
+ for (i = 0; i < nme; i++) {
+ (void)memcpy(*ma + mentrycount, me[i].mp,
+ me[i].cont_count * sizeof(**ma));
+ mentrycount += me[i].cont_count;
+ }
+ *nma = mentrycount;
+ return 0;
+}
+
+private void
+magic_entry_free(struct magic_entry *me, uint32_t nme)
+{
+ uint32_t i;
+ if (me == NULL)
+ return;
+ for (i = 0; i < nme; i++)
+ free(me[i].mp);
+ free(me);
+}
+
+private struct magic_map *
+apprentice_load(struct magic_set *ms, const char *fn, int action)
+{
+ int errs = 0;
+ uint32_t i, j;
+ size_t files = 0, maxfiles = 0;
+ char **filearr = NULL, *mfn;
+ struct stat st;
+ struct magic_map *map;
+ struct magic_entry_set mset[MAGIC_SETS];
+ DIR *dir;
+ struct dirent *d;
+
+ memset(mset, 0, sizeof(mset));
+ // XXX: change by mscdex
+ //ms->flags |= MAGIC_CHECK; /* Enable checks for parsed files */
+
+
+ if ((map = CAST(struct magic_map *, calloc(1, sizeof(*map)))) == NULL)
+ {
+ file_oomem(ms, sizeof(*map));
+ return NULL;
+ }
+ map->type = MAP_TYPE_MALLOC;
+
+ /* print silly verbose header for USG compat. */
+ if (action == FILE_CHECK)
+ (void)fprintf(stderr, "%s\n", usg_hdr);
+
+ /* load directory or file */
+ if (stat(fn, &st) == 0 && S_ISDIR(st.st_mode)) {
+ dir = opendir(fn);
+ if (!dir) {
+ errs++;
+ goto out;
+ }
+ while ((d = readdir(dir)) != NULL) {
+ if (d->d_name[0] == '.')
+ continue;
+ if (asprintf(&mfn, "%s/%s", fn, d->d_name) < 0) {
+ file_oomem(ms,
+ strlen(fn) + strlen(d->d_name) + 2);
+ errs++;
+ closedir(dir);
+ goto out;
+ }
+ if (stat(mfn, &st) == -1 || !S_ISREG(st.st_mode)) {
+ free(mfn);
+ continue;
+ }
+ if (files >= maxfiles) {
+ size_t mlen;
+ maxfiles = (maxfiles + 1) * 2;
+ mlen = maxfiles * sizeof(*filearr);
+ if ((filearr = CAST(char **,
+ realloc(filearr, mlen))) == NULL) {
+ file_oomem(ms, mlen);
+ free(mfn);
+ closedir(dir);
+ errs++;
+ goto out;
+ }
+ }
+ filearr[files++] = mfn;
+ }
+ closedir(dir);
+ qsort(filearr, files, sizeof(*filearr), cmpstrp);
+ for (i = 0; i < files; i++) {
+ load_1(ms, action, filearr[i], &errs, mset);
+ free(filearr[i]);
+ }
+ free(filearr);
+ } else
+ load_1(ms, action, fn, &errs, mset);
+ if (errs)
+ goto out;
+
+ for (j = 0; j < MAGIC_SETS; j++) {
+ /* Set types of tests */
+ for (i = 0; i < mset[j].count; ) {
+ if (mset[j].me[i].mp->cont_level != 0) {
+ i++;
+ continue;
+ }
+ i = set_text_binary(ms, mset[j].me, mset[j].count, i);
+ }
+ if (mset[j].me)
+ qsort(mset[j].me, mset[j].count, sizeof(*mset[j].me),
+ apprentice_sort);
+
+ /*
+ * Make sure that any level 0 "default" line is last
+ * (if one exists).
+ */
+ set_last_default(ms, mset[j].me, mset[j].count);
+
+ /* coalesce per file arrays into a single one */
+ if (coalesce_entries(ms, mset[j].me, mset[j].count,
+ &map->magic[j], &map->nmagic[j]) == -1) {
+ errs++;
+ goto out;
+ }
+ }
+
+out:
+ for (j = 0; j < MAGIC_SETS; j++)
+ magic_entry_free(mset[j].me, mset[j].count);
+
+ if (errs) {
+ apprentice_unmap(map);
+ return NULL;
+ }
+ return map;
+}
+
+/*
+ * extend the sign bit if the comparison is to be signed
+ */
+protected uint64_t
+file_signextend(struct magic_set *ms, struct magic *m, uint64_t v)
+{
+ if (!(m->flag & UNSIGNED)) {
+ switch(m->type) {
+ /*
+ * Do not remove the casts below. They are
+ * vital. When later compared with the data,
+ * the sign extension must have happened.
+ */
+ case FILE_BYTE:
+ v = (signed char) v;
+ break;
+ case FILE_SHORT:
+ case FILE_BESHORT:
+ case FILE_LESHORT:
+ v = (short) v;
+ break;
+ case FILE_DATE:
+ case FILE_BEDATE:
+ case FILE_LEDATE:
+ case FILE_MEDATE:
+ case FILE_LDATE:
+ case FILE_BELDATE:
+ case FILE_LELDATE:
+ case FILE_MELDATE:
+ case FILE_LONG:
+ case FILE_BELONG:
+ case FILE_LELONG:
+ case FILE_MELONG:
+ case FILE_FLOAT:
+ case FILE_BEFLOAT:
+ case FILE_LEFLOAT:
+ v = (int32_t) v;
+ break;
+ case FILE_QUAD:
+ case FILE_BEQUAD:
+ case FILE_LEQUAD:
+ case FILE_QDATE:
+ case FILE_QLDATE:
+ case FILE_QWDATE:
+ case FILE_BEQDATE:
+ case FILE_BEQLDATE:
+ case FILE_BEQWDATE:
+ case FILE_LEQDATE:
+ case FILE_LEQLDATE:
+ case FILE_LEQWDATE:
+ case FILE_DOUBLE:
+ case FILE_BEDOUBLE:
+ case FILE_LEDOUBLE:
+ v = (int64_t) v;
+ break;
+ case FILE_STRING:
+ case FILE_PSTRING:
+ case FILE_BESTRING16:
+ case FILE_LESTRING16:
+ case FILE_REGEX:
+ case FILE_SEARCH:
+ case FILE_DEFAULT:
+ case FILE_INDIRECT:
+ case FILE_NAME:
+ case FILE_USE:
+ case FILE_CLEAR:
+ case FILE_DER:
+ break;
+ default:
+ if (ms->flags & MAGIC_CHECK)
+ file_magwarn(ms, "cannot happen: m->type=%d\n",
+ m->type);
+ return ~0U;
+ }
+ }
+ return v;
+}
+
+private int
+string_modifier_check(struct magic_set *ms, struct magic *m)
+{
+ if ((ms->flags & MAGIC_CHECK) == 0)
+ return 0;
+
+ if ((m->type != FILE_REGEX || (m->str_flags & REGEX_LINE_COUNT) == 0) &&
+ (m->type != FILE_PSTRING && (m->str_flags & PSTRING_LEN) != 0)) {
+ file_magwarn(ms,
+ "'/BHhLl' modifiers are only allowed for pascal strings\n");
+ return -1;
+ }
+ switch (m->type) {
+ case FILE_BESTRING16:
+ case FILE_LESTRING16:
+ if (m->str_flags != 0) {
+ file_magwarn(ms,
+ "no modifiers allowed for 16-bit strings\n");
+ return -1;
+ }
+ break;
+ case FILE_STRING:
+ case FILE_PSTRING:
+ if ((m->str_flags & REGEX_OFFSET_START) != 0) {
+ file_magwarn(ms,
+ "'/%c' only allowed on regex and search\n",
+ CHAR_REGEX_OFFSET_START);
+ return -1;
+ }
+ break;
+ case FILE_SEARCH:
+ if (m->str_range == 0) {
+ file_magwarn(ms,
+ "missing range; defaulting to %d\n",
+ STRING_DEFAULT_RANGE);
+ m->str_range = STRING_DEFAULT_RANGE;
+ return -1;
+ }
+ break;
+ case FILE_REGEX:
+ if ((m->str_flags & STRING_COMPACT_WHITESPACE) != 0) {
+ file_magwarn(ms, "'/%c' not allowed on regex\n",
+ CHAR_COMPACT_WHITESPACE);
+ return -1;
+ }
+ if ((m->str_flags & STRING_COMPACT_OPTIONAL_WHITESPACE) != 0) {
+ file_magwarn(ms, "'/%c' not allowed on regex\n",
+ CHAR_COMPACT_OPTIONAL_WHITESPACE);
+ return -1;
+ }
+ break;
+ default:
+ file_magwarn(ms, "coding error: m->type=%d\n",
+ m->type);
+ return -1;
+ }
+ return 0;
+}
+
+private int
+get_op(char c)
+{
+ switch (c) {
+ case '&':
+ return FILE_OPAND;
+ case '|':
+ return FILE_OPOR;
+ case '^':
+ return FILE_OPXOR;
+ case '+':
+ return FILE_OPADD;
+ case '-':
+ return FILE_OPMINUS;
+ case '*':
+ return FILE_OPMULTIPLY;
+ case '/':
+ return FILE_OPDIVIDE;
+ case '%':
+ return FILE_OPMODULO;
+ default:
+ return -1;
+ }
+}
+
+#ifdef ENABLE_CONDITIONALS
+private int
+get_cond(const char *l, const char **t)
+{
+ static const struct cond_tbl_s {
+ char name[8];
+ size_t len;
+ int cond;
+ } cond_tbl[] = {
+ { "if", 2, COND_IF },
+ { "elif", 4, COND_ELIF },
+ { "else", 4, COND_ELSE },
+ { "", 0, COND_NONE },
+ };
+ const struct cond_tbl_s *p;
+
+ for (p = cond_tbl; p->len; p++) {
+ if (strncmp(l, p->name, p->len) == 0 &&
+ isspace((unsigned char)l[p->len])) {
+ if (t)
+ *t = l + p->len;
+ break;
+ }
+ }
+ return p->cond;
+}
+
+private int
+check_cond(struct magic_set *ms, int cond, uint32_t cont_level)
+{
+ int last_cond;
+ last_cond = ms->c.li[cont_level].last_cond;
+
+ switch (cond) {
+ case COND_IF:
+ if (last_cond != COND_NONE && last_cond != COND_ELIF) {
+ if (ms->flags & MAGIC_CHECK)
+ file_magwarn(ms, "syntax error: `if'");
+ return -1;
+ }
+ last_cond = COND_IF;
+ break;
+
+ case COND_ELIF:
+ if (last_cond != COND_IF && last_cond != COND_ELIF) {
+ if (ms->flags & MAGIC_CHECK)
+ file_magwarn(ms, "syntax error: `elif'");
+ return -1;
+ }
+ last_cond = COND_ELIF;
+ break;
+
+ case COND_ELSE:
+ if (last_cond != COND_IF && last_cond != COND_ELIF) {
+ if (ms->flags & MAGIC_CHECK)
+ file_magwarn(ms, "syntax error: `else'");
+ return -1;
+ }
+ last_cond = COND_NONE;
+ break;
+
+ case COND_NONE:
+ last_cond = COND_NONE;
+ break;
+ }
+
+ ms->c.li[cont_level].last_cond = last_cond;
+ return 0;
+}
+#endif /* ENABLE_CONDITIONALS */
+
+private int
+parse_indirect_modifier(struct magic_set *ms, struct magic *m, const char **lp)
+{
+ const char *l = *lp;
+
+ while (!isspace((unsigned char)*++l))
+ switch (*l) {
+ case CHAR_INDIRECT_RELATIVE:
+ m->str_flags |= INDIRECT_RELATIVE;
+ break;
+ default:
+ if (ms->flags & MAGIC_CHECK)
+ file_magwarn(ms, "indirect modifier `%c' "
+ "invalid", *l);
+ *lp = l;
+ return -1;
+ }
+ *lp = l;
+ return 0;
+}
+
+private void
+parse_op_modifier(struct magic_set *ms, struct magic *m, const char **lp,
+ int op)
+{
+ const char *l = *lp;
+ char *t;
+ uint64_t val;
+
+ ++l;
+ m->mask_op |= op;
+ val = (uint64_t)strtoull(l, &t, 0);
+ l = t;
+ m->num_mask = file_signextend(ms, m, val);
+ eatsize(&l);
+ *lp = l;
+}
+
+private int
+parse_string_modifier(struct magic_set *ms, struct magic *m, const char **lp)
+{
+ const char *l = *lp;
+ char *t;
+ int have_range = 0;
+
+ while (!isspace((unsigned char)*++l)) {
+ switch (*l) {
+ case '0': case '1': case '2':
+ case '3': case '4': case '5':
+ case '6': case '7': case '8':
+ case '9':
+ if (have_range && (ms->flags & MAGIC_CHECK))
+ file_magwarn(ms, "multiple ranges");
+ have_range = 1;
+ m->str_range = CAST(uint32_t, strtoul(l, &t, 0));
+ if (m->str_range == 0)
+ file_magwarn(ms, "zero range");
+ l = t - 1;
+ break;
+ case CHAR_COMPACT_WHITESPACE:
+ m->str_flags |= STRING_COMPACT_WHITESPACE;
+ break;
+ case CHAR_COMPACT_OPTIONAL_WHITESPACE:
+ m->str_flags |= STRING_COMPACT_OPTIONAL_WHITESPACE;
+ break;
+ case CHAR_IGNORE_LOWERCASE:
+ m->str_flags |= STRING_IGNORE_LOWERCASE;
+ break;
+ case CHAR_IGNORE_UPPERCASE:
+ m->str_flags |= STRING_IGNORE_UPPERCASE;
+ break;
+ case CHAR_REGEX_OFFSET_START:
+ m->str_flags |= REGEX_OFFSET_START;
+ break;
+ case CHAR_BINTEST:
+ m->str_flags |= STRING_BINTEST;
+ break;
+ case CHAR_TEXTTEST:
+ m->str_flags |= STRING_TEXTTEST;
+ break;
+ case CHAR_TRIM:
+ m->str_flags |= STRING_TRIM;
+ break;
+ case CHAR_PSTRING_1_LE:
+#define SET_LENGTH(a) m->str_flags = (m->str_flags & ~PSTRING_LEN) | (a)
+ if (m->type != FILE_PSTRING)
+ goto bad;
+ SET_LENGTH(PSTRING_1_LE);
+ break;
+ case CHAR_PSTRING_2_BE:
+ if (m->type != FILE_PSTRING)
+ goto bad;
+ SET_LENGTH(PSTRING_2_BE);
+ break;
+ case CHAR_PSTRING_2_LE:
+ if (m->type != FILE_PSTRING)
+ goto bad;
+ SET_LENGTH(PSTRING_2_LE);
+ break;
+ case CHAR_PSTRING_4_BE:
+ if (m->type != FILE_PSTRING)
+ goto bad;
+ SET_LENGTH(PSTRING_4_BE);
+ break;
+ case CHAR_PSTRING_4_LE:
+ switch (m->type) {
+ case FILE_PSTRING:
+ case FILE_REGEX:
+ break;
+ default:
+ goto bad;
+ }
+ SET_LENGTH(PSTRING_4_LE);
+ break;
+ case CHAR_PSTRING_LENGTH_INCLUDES_ITSELF:
+ if (m->type != FILE_PSTRING)
+ goto bad;
+ m->str_flags |= PSTRING_LENGTH_INCLUDES_ITSELF;
+ break;
+ default:
+ bad:
+ if (ms->flags & MAGIC_CHECK)
+ file_magwarn(ms, "string modifier `%c' "
+ "invalid", *l);
+ goto out;
+ }
+ /* allow multiple '/' for readability */
+ if (l[1] == '/' && !isspace((unsigned char)l[2]))
+ l++;
+ }
+ if (string_modifier_check(ms, m) == -1)
+ goto out;
+ *lp = l;
+ return 0;
+out:
+ *lp = l;
+ return -1;
+}
+
+/*
+ * parse one line from magic file, put into magic[index++] if valid
+ */
+private int
+parse(struct magic_set *ms, struct magic_entry *me, const char *line,
+ size_t lineno, int action)
+{
+#ifdef ENABLE_CONDITIONALS
+ static uint32_t last_cont_level = 0;
+#endif
+ size_t i;
+ struct magic *m;
+ const char *l = line;
+ char *t;
+ int op;
+ uint32_t cont_level;
+ int32_t diff;
+
+ cont_level = 0;
+
+ /*
+ * Parse the offset.
+ */
+ while (*l == '>') {
+ ++l; /* step over */
+ cont_level++;
+ }
+#ifdef ENABLE_CONDITIONALS
+ if (cont_level == 0 || cont_level > last_cont_level)
+ if (file_check_mem(ms, cont_level) == -1)
+ return -1;
+ last_cont_level = cont_level;
+#endif
+ if (cont_level != 0) {
+ if (me->mp == NULL) {
+ file_magerror(ms, "No current entry for continuation");
+ return -1;
+ }
+ if (me->cont_count == 0) {
+ file_magerror(ms, "Continuations present with 0 count");
+ return -1;
+ }
+ m = &me->mp[me->cont_count - 1];
+ diff = (int32_t)cont_level - (int32_t)m->cont_level;
+ if (diff > 1)
+ file_magwarn(ms, "New continuation level %u is more "
+ "than one larger than current level %u", cont_level,
+ m->cont_level);
+ if (me->cont_count == me->max_count) {
+ struct magic *nm;
+ size_t cnt = me->max_count + ALLOC_CHUNK;
+ if ((nm = CAST(struct magic *, realloc(me->mp,
+ sizeof(*nm) * cnt))) == NULL) {
+ file_oomem(ms, sizeof(*nm) * cnt);
+ return -1;
+ }
+ me->mp = m = nm;
+ me->max_count = CAST(uint32_t, cnt);
+ }
+ m = &me->mp[me->cont_count++];
+ (void)memset(m, 0, sizeof(*m));
+ m->cont_level = cont_level;
+ } else {
+ static const size_t len = sizeof(*m) * ALLOC_CHUNK;
+ if (me->mp != NULL)
+ return 1;
+ if ((m = CAST(struct magic *, malloc(len))) == NULL) {
+ file_oomem(ms, len);
+ return -1;
+ }
+ me->mp = m;
+ me->max_count = ALLOC_CHUNK;
+ (void)memset(m, 0, sizeof(*m));
+ m->factor_op = FILE_FACTOR_OP_NONE;
+ m->cont_level = 0;
+ me->cont_count = 1;
+ }
+ m->lineno = CAST(uint32_t, lineno);
+
+ if (*l == '&') { /* m->cont_level == 0 checked below. */
+ ++l; /* step over */
+ m->flag |= OFFADD;
+ }
+ if (*l == '(') {
+ ++l; /* step over */
+ m->flag |= INDIR;
+ if (m->flag & OFFADD)
+ m->flag = (m->flag & ~OFFADD) | INDIROFFADD;
+
+ if (*l == '&') { /* m->cont_level == 0 checked below */
+ ++l; /* step over */
+ m->flag |= OFFADD;
+ }
+ }
+ /* Indirect offsets are not valid at level 0. */
+ if (m->cont_level == 0 && (m->flag & (OFFADD | INDIROFFADD))) {
+ if (ms->flags & MAGIC_CHECK)
+ file_magwarn(ms, "relative offset at level 0");
+ return -1;
+ }
+
+ /* get offset, then skip over it */
+ m->offset = (uint32_t)strtoul(l, &t, 0);
+ if (l == t) {
+ if (ms->flags & MAGIC_CHECK)
+ file_magwarn(ms, "offset `%s' invalid", l);
+ return -1;
+ }
+ l = t;
+
+ if (m->flag & INDIR) {
+ m->in_type = FILE_LONG;
+ m->in_offset = 0;
+ m->in_op = 0;
+ /*
+ * read [.,lbs][+-]nnnnn)
+ */
+ if (*l == '.' || *l == ',') {
+ if (*l == ',')
+ m->in_op |= FILE_OPSIGNED;
+ l++;
+ switch (*l) {
+ case 'l':
+ m->in_type = FILE_LELONG;
+ break;
+ case 'L':
+ m->in_type = FILE_BELONG;
+ break;
+ case 'm':
+ m->in_type = FILE_MELONG;
+ break;
+ case 'h':
+ case 's':
+ m->in_type = FILE_LESHORT;
+ break;
+ case 'H':
+ case 'S':
+ m->in_type = FILE_BESHORT;
+ break;
+ case 'c':
+ case 'b':
+ case 'C':
+ case 'B':
+ m->in_type = FILE_BYTE;
+ break;
+ case 'e':
+ case 'f':
+ case 'g':
+ m->in_type = FILE_LEDOUBLE;
+ break;
+ case 'E':
+ case 'F':
+ case 'G':
+ m->in_type = FILE_BEDOUBLE;
+ break;
+ case 'i':
+ m->in_type = FILE_LEID3;
+ break;
+ case 'I':
+ m->in_type = FILE_BEID3;
+ break;
+ default:
+ if (ms->flags & MAGIC_CHECK)
+ file_magwarn(ms,
+ "indirect offset type `%c' invalid",
+ *l);
+ return -1;
+ }
+ l++;
+ }
+
+ if (*l == '~') {
+ m->in_op |= FILE_OPINVERSE;
+ l++;
+ }
+ if ((op = get_op(*l)) != -1) {
+ m->in_op |= op;
+ l++;
+ }
+ if (*l == '(') {
+ m->in_op |= FILE_OPINDIRECT;
+ l++;
+ }
+ if (isdigit((unsigned char)*l) || *l == '-') {
+ m->in_offset = (int32_t)strtol(l, &t, 0);
+ if (l == t) {
+ if (ms->flags & MAGIC_CHECK)
+ file_magwarn(ms,
+ "in_offset `%s' invalid", l);
+ return -1;
+ }
+ l = t;
+ }
+ if (*l++ != ')' ||
+ ((m->in_op & FILE_OPINDIRECT) && *l++ != ')')) {
+ if (ms->flags & MAGIC_CHECK)
+ file_magwarn(ms,
+ "missing ')' in indirect offset");
+ return -1;
+ }
+ }
+ EATAB;
+
+#ifdef ENABLE_CONDITIONALS
+ m->cond = get_cond(l, &l);
+ if (check_cond(ms, m->cond, cont_level) == -1)
+ return -1;
+
+ EATAB;
+#endif
+
+ /*
+ * Parse the type.
+ */
+ if (*l == 'u') {
+ /*
+ * Try it as a keyword type prefixed by "u"; match what
+ * follows the "u". If that fails, try it as an SUS
+ * integer type.
+ */
+ m->type = get_type(type_tbl, l + 1, &l);
+ if (m->type == FILE_INVALID) {
+ /*
+ * Not a keyword type; parse it as an SUS type,
+ * 'u' possibly followed by a number or C/S/L.
+ */
+ m->type = get_standard_integer_type(l, &l);
+ }
+ /* It's unsigned. */
+ if (m->type != FILE_INVALID)
+ m->flag |= UNSIGNED;
+ } else {
+ /*
+ * Try it as a keyword type. If that fails, try it as
+ * an SUS integer type if it begins with "d" or as an
+ * SUS string type if it begins with "s". In any case,
+ * it's not unsigned.
+ */
+ m->type = get_type(type_tbl, l, &l);
+ if (m->type == FILE_INVALID) {
+ /*
+ * Not a keyword type; parse it as an SUS type,
+ * either 'd' possibly followed by a number or
+ * C/S/L, or just 's'.
+ */
+ if (*l == 'd')
+ m->type = get_standard_integer_type(l, &l);
+ else if (*l == 's' && !isalpha((unsigned char)l[1])) {
+ m->type = FILE_STRING;
+ ++l;
+ }
+ }
+ }
+
+ if (m->type == FILE_INVALID) {
+ /* Not found - try it as a special keyword. */
+ m->type = get_type(special_tbl, l, &l);
+ }
+
+ if (m->type == FILE_INVALID) {
+ if (ms->flags & MAGIC_CHECK)
+ file_magwarn(ms, "type `%s' invalid", l);
+ return -1;
+ }
+
+ /* New-style anding: "0 byte&0x80 =0x80 dynamically linked" */
+ /* New and improved: ~ & | ^ + - * / % -- exciting, isn't it? */
+
+ m->mask_op = 0;
+ if (*l == '~') {
+ if (!IS_STRING(m->type))
+ m->mask_op |= FILE_OPINVERSE;
+ else if (ms->flags & MAGIC_CHECK)
+ file_magwarn(ms, "'~' invalid for string types");
+ ++l;
+ }
+ m->str_range = 0;
+ m->str_flags = m->type == FILE_PSTRING ? PSTRING_1_LE : 0;
+ if ((op = get_op(*l)) != -1) {
+ if (IS_STRING(m->type)) {
+ int r;
+
+ if (op != FILE_OPDIVIDE) {
+ if (ms->flags & MAGIC_CHECK)
+ file_magwarn(ms,
+ "invalid string/indirect op: "
+ "`%c'", *t);
+ return -1;
+ }
+
+ if (m->type == FILE_INDIRECT)
+ r = parse_indirect_modifier(ms, m, &l);
+ else
+ r = parse_string_modifier(ms, m, &l);
+ if (r == -1)
+ return -1;
+ } else
+ parse_op_modifier(ms, m, &l, op);
+ }
+
+ /*
+ * We used to set mask to all 1's here, instead let's just not do
+ * anything if mask = 0 (unless you have a better idea)
+ */
+ EATAB;
+
+ switch (*l) {
+ case '>':
+ case '<':
+ m->reln = *l;
+ ++l;
+ if (*l == '=') {
+ if (ms->flags & MAGIC_CHECK) {
+ file_magwarn(ms, "%c= not supported",
+ m->reln);
+ return -1;
+ }
+ ++l;
+ }
+ break;
+ /* Old-style anding: "0 byte &0x80 dynamically linked" */
+ case '&':
+ case '^':
+ case '=':
+ m->reln = *l;
+ ++l;
+ if (*l == '=') {
+ /* HP compat: ignore &= etc. */
+ ++l;
+ }
+ break;
+ case '!':
+ m->reln = *l;
+ ++l;
+ break;
+ default:
+ m->reln = '='; /* the default relation */
+ if (*l == 'x' && ((isascii((unsigned char)l[1]) &&
+ isspace((unsigned char)l[1])) || !l[1])) {
+ m->reln = *l;
+ ++l;
+ }
+ break;
+ }
+ /*
+ * Grab the value part, except for an 'x' reln.
+ */
+ if (m->reln != 'x' && getvalue(ms, m, &l, action))
+ return -1;
+
+ /*
+ * TODO finish this macro and start using it!
+ * #define offsetcheck {if (offset > ms->bytes_max -1)
+ * magwarn("offset too big"); }
+ */
+
+ /*
+ * Now get last part - the description
+ */
+ EATAB;
+ if (l[0] == '\b') {
+ ++l;
+ m->flag |= NOSPACE;
+ } else if ((l[0] == '\\') && (l[1] == 'b')) {
+ ++l;
+ ++l;
+ m->flag |= NOSPACE;
+ }
+ for (i = 0; (m->desc[i++] = *l++) != '\0' && i < sizeof(m->desc); )
+ continue;
+ if (i == sizeof(m->desc)) {
+ m->desc[sizeof(m->desc) - 1] = '\0';
+ if (ms->flags & MAGIC_CHECK)
+ file_magwarn(ms, "description `%s' truncated", m->desc);
+ }
+
+ /*
+ * We only do this check while compiling, or if any of the magic
+ * files were not compiled.
+ */
+ if (ms->flags & MAGIC_CHECK) {
+ if (check_format(ms, m) == -1)
+ return -1;
+ }
+#ifndef COMPILE_ONLY
+ if (action == FILE_CHECK) {
+ file_mdump(m);
+ }
+#endif
+ m->mimetype[0] = '\0'; /* initialise MIME type to none */
+ return 0;
+}
+
+/*
+ * parse a STRENGTH annotation line from magic file, put into magic[index - 1]
+ * if valid
+ */
+private int
+parse_strength(struct magic_set *ms, struct magic_entry *me, const char *line)
+{
+ const char *l = line;
+ char *el;
+ unsigned long factor;
+ struct magic *m = &me->mp[0];
+
+ if (m->factor_op != FILE_FACTOR_OP_NONE) {
+ file_magwarn(ms,
+ "Current entry already has a strength type: %c %d",
+ m->factor_op, m->factor);
+ return -1;
+ }
+ if (m->type == FILE_NAME) {
+ file_magwarn(ms, "%s: Strength setting is not supported in "
+ "\"name\" magic entries", m->value.s);
+ return -1;
+ }
+ EATAB;
+ switch (*l) {
+ case FILE_FACTOR_OP_NONE:
+ case FILE_FACTOR_OP_PLUS:
+ case FILE_FACTOR_OP_MINUS:
+ case FILE_FACTOR_OP_TIMES:
+ case FILE_FACTOR_OP_DIV:
+ m->factor_op = *l++;
+ break;
+ default:
+ file_magwarn(ms, "Unknown factor op `%c'", *l);
+ return -1;
+ }
+ EATAB;
+ factor = strtoul(l, &el, 0);
+ if (factor > 255) {
+ file_magwarn(ms, "Too large factor `%lu'", factor);
+ goto out;
+ }
+ if (*el && !isspace((unsigned char)*el)) {
+ file_magwarn(ms, "Bad factor `%s'", l);
+ goto out;
+ }
+ m->factor = (uint8_t)factor;
+ if (m->factor == 0 && m->factor_op == FILE_FACTOR_OP_DIV) {
+ file_magwarn(ms, "Cannot have factor op `%c' and factor %u",
+ m->factor_op, m->factor);
+ goto out;
+ }
+ return 0;
+out:
+ m->factor_op = FILE_FACTOR_OP_NONE;
+ m->factor = 0;
+ return -1;
+}
+
+private int
+goodchar(unsigned char x, const char *extra)
+{
+ return (isascii(x) && isalnum(x)) || strchr(extra, x);
+}
+
+private int
+parse_extra(struct magic_set *ms, struct magic_entry *me, const char *line,
+ off_t off, size_t len, const char *name, const char *extra, int nt)
+{
+ size_t i;
+ const char *l = line;
+ struct magic *m = &me->mp[me->cont_count == 0 ? 0 : me->cont_count - 1];
+ char *buf = CAST(char *, CAST(void *, m)) + off;
+
+ if (buf[0] != '\0') {
+ len = nt ? strlen(buf) : len;
+ file_magwarn(ms, "Current entry already has a %s type "
+ "`%.*s', new type `%s'", name, (int)len, buf, l);
+ return -1;
+ }
+
+ if (*m->desc == '\0') {
+ file_magwarn(ms, "Current entry does not yet have a "
+ "description for adding a %s type", name);
+ return -1;
+ }
+
+ EATAB;
+ for (i = 0; *l && i < len && goodchar(*l, extra); buf[i++] = *l++)
+ continue;
+
+ if (i == len && *l) {
+ if (nt)
+ buf[len - 1] = '\0';
+ if (ms->flags & MAGIC_CHECK)
+ file_magwarn(ms, "%s type `%s' truncated %"
+ SIZE_T_FORMAT "u", name, line, i);
+ } else {
+ if (!isspace((unsigned char)*l) && !goodchar(*l, extra))
+ file_magwarn(ms, "%s type `%s' has bad char '%c'",
+ name, line, *l);
+ if (nt)
+ buf[i] = '\0';
+ }
+
+ if (i > 0)
+ return 0;
+
+ file_magerror(ms, "Bad magic entry '%s'", line);
+ return -1;
+}
+
+/*
+ * Parse an Apple CREATOR/TYPE annotation from magic file and put it into
+ * magic[index - 1]
+ */
+private int
+parse_apple(struct magic_set *ms, struct magic_entry *me, const char *line)
+{
+ struct magic *m = &me->mp[0];
+
+ return parse_extra(ms, me, line,
+ CAST(off_t, offsetof(struct magic, apple)),
+ sizeof(m->apple), "APPLE", "!+-./?", 0);
+}
+
+/*
+ * Parse a comma-separated list of extensions
+ */
+private int
+parse_ext(struct magic_set *ms, struct magic_entry *me, const char *line)
+{
+ struct magic *m = &me->mp[0];
+
+ return parse_extra(ms, me, line,
+ CAST(off_t, offsetof(struct magic, ext)),
+ sizeof(m->ext), "EXTENSION", ",!+-/@", 0);
+}
+
+/*
+ * parse a MIME annotation line from magic file, put into magic[index - 1]
+ * if valid
+ */
+private int
+parse_mime(struct magic_set *ms, struct magic_entry *me, const char *line)
+{
+ struct magic *m = &me->mp[0];
+
+ return parse_extra(ms, me, line,
+ CAST(off_t, offsetof(struct magic, mimetype)),
+ sizeof(m->mimetype), "MIME", "+-/.", 1);
+}
+
+private int
+check_format_type(const char *ptr, int type, const char **estr)
+{
+ int quad = 0, h;
+ size_t len, cnt;
+ if (*ptr == '\0') {
+ /* Missing format string; bad */
+ *estr = "missing format spec";
+ return -1;
+ }
+
+ switch (file_formats[type]) {
+ case FILE_FMT_QUAD:
+ quad = 1;
+ /*FALLTHROUGH*/
+ case FILE_FMT_NUM:
+ if (quad == 0) {
+ switch (type) {
+ case FILE_BYTE:
+ h = 2;
+ break;
+ case FILE_SHORT:
+ case FILE_BESHORT:
+ case FILE_LESHORT:
+ h = 1;
+ break;
+ case FILE_LONG:
+ case FILE_BELONG:
+ case FILE_LELONG:
+ case FILE_MELONG:
+ case FILE_LEID3:
+ case FILE_BEID3:
+ case FILE_INDIRECT:
+ h = 0;
+ break;
+ default:
+ abort();
+ }
+ } else
+ h = 0;
+ if (*ptr == '-')
+ ptr++;
+ if (*ptr == '.')
+ ptr++;
+ if (*ptr == '#')
+ ptr++;
+#define CHECKLEN() do { \
+ for (len = cnt = 0; isdigit((unsigned char)*ptr); ptr++, cnt++) \
+ len = len * 10 + (*ptr - '0'); \
+ if (cnt > 5 || len > 1024) \
+ goto toolong; \
+} while (/*CONSTCOND*/0)
+
+ CHECKLEN();
+ if (*ptr == '.')
+ ptr++;
+ CHECKLEN();
+ if (quad) {
+ if (*ptr++ != 'l')
+ goto invalid;
+ if (*ptr++ != 'l')
+ goto invalid;
+ }
+
+ switch (*ptr++) {
+#ifdef STRICT_FORMAT /* "long" formats are int formats for us */
+ /* so don't accept the 'l' modifier */
+ case 'l':
+ switch (*ptr++) {
+ case 'i':
+ case 'd':
+ case 'u':
+ case 'o':
+ case 'x':
+ case 'X':
+ if (h == 0)
+ return 0;
+ /*FALLTHROUGH*/
+ default:
+ goto invalid;
+ }
+
+ /*
+ * Don't accept h and hh modifiers. They make writing
+ * magic entries more complicated, for very little benefit
+ */
+ case 'h':
+ if (h-- <= 0)
+ goto invalid;
+ switch (*ptr++) {
+ case 'h':
+ if (h-- <= 0)
+ goto invalid;
+ switch (*ptr++) {
+ case 'i':
+ case 'd':
+ case 'u':
+ case 'o':
+ case 'x':
+ case 'X':
+ return 0;
+ default:
+ goto invalid;
+ }
+ case 'i':
+ case 'd':
+ case 'u':
+ case 'o':
+ case 'x':
+ case 'X':
+ if (h == 0)
+ return 0;
+ /*FALLTHROUGH*/
+ default:
+ goto invalid;
+ }
+#endif
+ case 'c':
+ if (h == 2)
+ return 0;
+ goto invalid;
+ case 'i':
+ case 'd':
+ case 'u':
+ case 'o':
+ case 'x':
+ case 'X':
+#ifdef STRICT_FORMAT
+ if (h == 0)
+ return 0;
+ /*FALLTHROUGH*/
+#else
+ return 0;
+#endif
+ default:
+ goto invalid;
+ }
+
+ case FILE_FMT_FLOAT:
+ case FILE_FMT_DOUBLE:
+ if (*ptr == '-')
+ ptr++;
+ if (*ptr == '.')
+ ptr++;
+ CHECKLEN();
+ if (*ptr == '.')
+ ptr++;
+ CHECKLEN();
+ switch (*ptr++) {
+ case 'e':
+ case 'E':
+ case 'f':
+ case 'F':
+ case 'g':
+ case 'G':
+ return 0;
+
+ default:
+ goto invalid;
+ }
+
+
+ case FILE_FMT_STR:
+ if (*ptr == '-')
+ ptr++;
+ while (isdigit((unsigned char )*ptr))
+ ptr++;
+ if (*ptr == '.') {
+ ptr++;
+ while (isdigit((unsigned char )*ptr))
+ ptr++;
+ }
+
+ switch (*ptr++) {
+ case 's':
+ return 0;
+ default:
+ goto invalid;
+ }
+
+ default:
+ /* internal error */
+ abort();
+ }
+invalid:
+ *estr = "not valid";
+toolong:
+ *estr = "too long";
+ return -1;
+}
+
+/*
+ * Check that the optional printf format in description matches
+ * the type of the magic.
+ */
+private int
+check_format(struct magic_set *ms, struct magic *m)
+{
+ char *ptr;
+ const char *estr;
+
+ for (ptr = m->desc; *ptr; ptr++)
+ if (*ptr == '%')
+ break;
+ if (*ptr == '\0') {
+ /* No format string; ok */
+ return 1;
+ }
+
+ assert(file_nformats == file_nnames);
+
+ if (m->type >= file_nformats) {
+ file_magwarn(ms, "Internal error inconsistency between "
+ "m->type and format strings");
+ return -1;
+ }
+ if (file_formats[m->type] == FILE_FMT_NONE) {
+ file_magwarn(ms, "No format string for `%s' with description "
+ "`%s'", m->desc, file_names[m->type]);
+ return -1;
+ }
+
+ ptr++;
+ if (check_format_type(ptr, m->type, &estr) == -1) {
+ /*
+ * TODO: this error message is unhelpful if the format
+ * string is not one character long
+ */
+ file_magwarn(ms, "Printf format is %s for type "
+ "`%s' in description `%s'", estr,
+ file_names[m->type], m->desc);
+ return -1;
+ }
+
+ for (; *ptr; ptr++) {
+ if (*ptr == '%') {
+ file_magwarn(ms,
+ "Too many format strings (should have at most one) "
+ "for `%s' with description `%s'",
+ file_names[m->type], m->desc);
+ return -1;
+ }
+ }
+ return 0;
+}
+
+/*
+ * Read a numeric value from a pointer, into the value union of a magic
+ * pointer, according to the magic type. Update the string pointer to point
+ * just after the number read. Return 0 for success, non-zero for failure.
+ */
+private int
+getvalue(struct magic_set *ms, struct magic *m, const char **p, int action)
+{
+ switch (m->type) {
+ case FILE_BESTRING16:
+ case FILE_LESTRING16:
+ case FILE_STRING:
+ case FILE_PSTRING:
+ case FILE_REGEX:
+ case FILE_SEARCH:
+ case FILE_NAME:
+ case FILE_USE:
+ case FILE_DER:
+ *p = getstr(ms, m, *p, action == FILE_COMPILE);
+ if (*p == NULL) {
+ if (ms->flags & MAGIC_CHECK)
+ file_magwarn(ms, "cannot get string from `%s'",
+ m->value.s);
+ return -1;
+ }
+ if (m->type == FILE_REGEX) {
+ file_regex_t rx;
+ int rc = file_regcomp(&rx, m->value.s, REG_EXTENDED);
+ if (rc) {
+ if (ms->flags & MAGIC_CHECK)
+ file_regerror(&rx, rc, ms);
+ }
+ file_regfree(&rx);
+ return rc ? -1 : 0;
+ }
+ return 0;
+ case FILE_FLOAT:
+ case FILE_BEFLOAT:
+ case FILE_LEFLOAT:
+ if (m->reln != 'x') {
+ char *ep;
+ errno = 0;
+#ifdef HAVE_STRTOF
+ m->value.f = strtof(*p, &ep);
+#else
+ m->value.f = (float)strtod(*p, &ep);
+#endif
+ if (errno == 0)
+ *p = ep;
+ }
+ return 0;
+ case FILE_DOUBLE:
+ case FILE_BEDOUBLE:
+ case FILE_LEDOUBLE:
+ if (m->reln != 'x') {
+ char *ep;
+ errno = 0;
+ m->value.d = strtod(*p, &ep);
+ if (errno == 0)
+ *p = ep;
+ }
+ return 0;
+ default:
+ if (m->reln != 'x') {
+ char *ep;
+ uint64_t ull;
+ errno = 0;
+ ull = (uint64_t)strtoull(*p, &ep, 0);
+ m->value.q = file_signextend(ms, m, ull);
+ if (*p == ep) {
+ file_magwarn(ms, "Unparseable number `%s'", *p);
+ } else {
+ size_t ts = typesize(m->type);
+ uint64_t x;
+ const char *q;
+
+ if (ts == (size_t)~0) {
+ file_magwarn(ms, "Expected numeric type got `%s'",
+ type_tbl[m->type].name);
+ }
+ for (q = *p; isspace((unsigned char)*q); q++)
+ continue;
+ if (*q == '-')
+ ull = -(int64_t)ull;
+ switch (ts) {
+ case 1:
+ x = ull & ~0xffULL;
+ break;
+ case 2:
+ x = ull & ~0xffffULL;
+ break;
+ case 4:
+ x = ull & ~0xffffffffULL;
+ break;
+ case 8:
+ x = 0;
+ break;
+ default:
+ abort();
+ }
+ if (x) {
+ file_magwarn(ms, "Overflow for numeric type `%s' value %#" PRIx64,
+ type_tbl[m->type].name, ull);
+ }
+ }
+ if (errno == 0) {
+ *p = ep;
+ eatsize(p);
+ }
+ }
+ return 0;
+ }
+}
+
+/*
+ * Convert a string containing C character escapes. Stop at an unescaped
+ * space or tab.
+ * Copy the converted version to "m->value.s", and the length in m->vallen.
+ * Return updated scan pointer as function result. Warn if set.
+ */
+private const char *
+getstr(struct magic_set *ms, struct magic *m, const char *s, int warn)
+{
+ const char *origs = s;
+ char *p = m->value.s;
+ size_t plen = sizeof(m->value.s);
+ char *origp = p;
+ char *pmax = p + plen - 1;
+ int c;
+ int val;
+
+ while ((c = *s++) != '\0') {
+ if (isspace((unsigned char) c))
+ break;
+ if (p >= pmax) {
+ file_error(ms, 0, "string too long: `%s'", origs);
+ return NULL;
+ }
+ if (c == '\\') {
+ switch(c = *s++) {
+
+ case '\0':
+ if (warn)
+ file_magwarn(ms, "incomplete escape");
+ s--;
+ goto out;
+
+ case '\t':
+ if (warn) {
+ file_magwarn(ms,
+ "escaped tab found, use \\t instead");
+ warn = 0; /* already did */
+ }
+ /*FALLTHROUGH*/
+ default:
+ if (warn) {
+ if (isprint((unsigned char)c)) {
+ /* Allow escaping of
+ * ``relations'' */
+ if (strchr("<>&^=!", c) == NULL
+ && (m->type != FILE_REGEX ||
+ strchr("[]().*?^$|{}", c)
+ == NULL)) {
+ file_magwarn(ms, "no "
+ "need to escape "
+ "`%c'", c);
+ }
+ } else {
+ file_magwarn(ms,
+ "unknown escape sequence: "
+ "\\%03o", c);
+ }
+ }
+ /*FALLTHROUGH*/
+ /* space, perhaps force people to use \040? */
+ case ' ':
+#if 0
+ /*
+ * Other things people escape, but shouldn't need to,
+ * so we disallow them
+ */
+ case '\'':
+ case '"':
+ case '?':
+#endif
+ /* Relations */
+ case '>':
+ case '<':
+ case '&':
+ case '^':
+ case '=':
+ case '!':
+ /* and baskslash itself */
+ case '\\':
+ *p++ = (char) c;
+ break;
+
+ case 'a':
+ *p++ = '\a';
+ break;
+
+ case 'b':
+ *p++ = '\b';
+ break;
+
+ case 'f':
+ *p++ = '\f';
+ break;
+
+ case 'n':
+ *p++ = '\n';
+ break;
+
+ case 'r':
+ *p++ = '\r';
+ break;
+
+ case 't':
+ *p++ = '\t';
+ break;
+
+ case 'v':
+ *p++ = '\v';
+ break;
+
+ /* \ and up to 3 octal digits */
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ val = c - '0';
+ c = *s++; /* try for 2 */
+ if (c >= '0' && c <= '7') {
+ val = (val << 3) | (c - '0');
+ c = *s++; /* try for 3 */
+ if (c >= '0' && c <= '7')
+ val = (val << 3) | (c-'0');
+ else
+ --s;
+ }
+ else
+ --s;
+ *p++ = (char)val;
+ break;
+
+ /* \x and up to 2 hex digits */
+ case 'x':
+ val = 'x'; /* Default if no digits */
+ c = hextoint(*s++); /* Get next char */
+ if (c >= 0) {
+ val = c;
+ c = hextoint(*s++);
+ if (c >= 0)
+ val = (val << 4) + c;
+ else
+ --s;
+ } else
+ --s;
+ *p++ = (char)val;
+ break;
+ }
+ } else
+ *p++ = (char)c;
+ }
+ --s;
+out:
+ *p = '\0';
+ m->vallen = CAST(unsigned char, (p - origp));
+ if (m->type == FILE_PSTRING)
+ m->vallen += (unsigned char)file_pstring_length_size(m);
+ return s;
+}
+
+
+/* Single hex char to int; -1 if not a hex char. */
+private int
+hextoint(int c)
+{
+ if (!isascii((unsigned char) c))
+ return -1;
+ if (isdigit((unsigned char) c))
+ return c - '0';
+ if ((c >= 'a') && (c <= 'f'))
+ return c + 10 - 'a';
+ if (( c>= 'A') && (c <= 'F'))
+ return c + 10 - 'A';
+ return -1;
+}
+
+
+/*
+ * Print a string containing C character escapes.
+ */
+protected void
+file_showstr(FILE *fp, const char *s, size_t len)
+{
+ char c;
+
+ for (;;) {
+ if (len == ~0U) {
+ c = *s++;
+ if (c == '\0')
+ break;
+ }
+ else {
+ if (len-- == 0)
+ break;
+ c = *s++;
+ }
+ if (c >= 040 && c <= 0176) /* TODO isprint && !iscntrl */
+ (void) fputc(c, fp);
+ else {
+ (void) fputc('\\', fp);
+ switch (c) {
+ case '\a':
+ (void) fputc('a', fp);
+ break;
+
+ case '\b':
+ (void) fputc('b', fp);
+ break;
+
+ case '\f':
+ (void) fputc('f', fp);
+ break;
+
+ case '\n':
+ (void) fputc('n', fp);
+ break;
+
+ case '\r':
+ (void) fputc('r', fp);
+ break;
+
+ case '\t':
+ (void) fputc('t', fp);
+ break;
+
+ case '\v':
+ (void) fputc('v', fp);
+ break;
+
+ default:
+ (void) fprintf(fp, "%.3o", c & 0377);
+ break;
+ }
+ }
+ }
+}
+
+/*
+ * eatsize(): Eat the size spec from a number [eg. 10UL]
+ */
+private void
+eatsize(const char **p)
+{
+ const char *l = *p;
+
+ if (LOWCASE(*l) == 'u')
+ l++;
+
+ switch (LOWCASE(*l)) {
+ case 'l': /* long */
+ case 's': /* short */
+ case 'h': /* short */
+ case 'b': /* char/byte */
+ case 'c': /* char/byte */
+ l++;
+ /*FALLTHROUGH*/
+ default:
+ break;
+ }
+
+ *p = l;
+}
+
+/*
+ * handle a buffer containing a compiled file.
+ */
+private struct magic_map *
+apprentice_buf(struct magic_set *ms, struct magic *buf, size_t len)
+{
+ struct magic_map *map;
+
+ if ((map = CAST(struct magic_map *, calloc(1, sizeof(*map)))) == NULL) {
+ file_oomem(ms, sizeof(*map));
+ return NULL;
+ }
+ map->len = len;
+ map->p = buf;
+ map->type = MAP_TYPE_USER;
+ if (check_buffer(ms, map, "buffer") != 0) {
+ apprentice_unmap(map);
+ return NULL;
+ }
+ return map;
+}
+
+/*
+ * handle a compiled file.
+ */
+
+private struct magic_map *
+apprentice_map(struct magic_set *ms, const char *fn)
+{
+ int fd;
+ struct stat st;
+ char *dbname = NULL;
+ struct magic_map *map;
+ struct magic_map *rv = NULL;
+
+ fd = -1;
+ if ((map = CAST(struct magic_map *, calloc(1, sizeof(*map)))) == NULL) {
+ file_oomem(ms, sizeof(*map));
+ goto error;
+ }
+ map->type = MAP_TYPE_USER; /* unspecified */
+
+ dbname = mkdbname(ms, fn, 0);
+ if (dbname == NULL)
+ goto error;
+
+ if ((fd = open(dbname, O_RDONLY|O_BINARY)) == -1)
+ goto error;
+
+ if (fstat(fd, &st) == -1) {
+ file_error(ms, errno, "cannot stat `%s'", dbname);
+ goto error;
+ }
+ if (st.st_size < 8 || st.st_size > MAXMAGIC_SIZE) {
+ file_error(ms, 0, "file `%s' is too %s", dbname,
+ st.st_size < 8 ? "small" : "large");
+ goto error;
+ }
+
+ map->len = (size_t)st.st_size;
+#ifdef QUICK
+ map->type = MAP_TYPE_MMAP;
+ if ((map->p = mmap(0, (size_t)st.st_size, PROT_READ|PROT_WRITE,
+ MAP_PRIVATE|MAP_FILE, fd, (off_t)0)) == MAP_FAILED) {
+ file_error(ms, errno, "cannot map `%s'", dbname);
+ goto error;
+ }
+#else
+ map->type = MAP_TYPE_MALLOC;
+ if ((map->p = CAST(void *, malloc(map->len))) == NULL) {
+ file_oomem(ms, map->len);
+ goto error;
+ }
+ if (read(fd, map->p, map->len) != (ssize_t)map->len) {
+ file_badread(ms);
+ goto error;
+ }
+#define RET 1
+#endif
+ (void)close(fd);
+ fd = -1;
+
+ if (check_buffer(ms, map, dbname) != 0) {
+ rv = (struct magic_map *)-1;
+ goto error;
+ }
+#ifdef QUICK
+ if (mprotect(map->p, (size_t)st.st_size, PROT_READ) == -1) {
+ file_error(ms, errno, "cannot mprotect `%s'", dbname);
+ goto error;
+ }
+#endif
+
+ free(dbname);
+ return map;
+
+error:
+ if (fd != -1)
+ (void)close(fd);
+ apprentice_unmap(map);
+ free(dbname);
+ return rv;
+}
+
+private int
+check_buffer(struct magic_set *ms, struct magic_map *map, const char *dbname)
+{
+ uint32_t *ptr;
+ uint32_t entries, nentries;
+ uint32_t version;
+ int i, needsbyteswap;
+
+ ptr = CAST(uint32_t *, map->p);
+ if (*ptr != MAGICNO) {
+ if (swap4(*ptr) != MAGICNO) {
+ file_error(ms, 0, "bad magic in `%s'", dbname);
+ return -1;
+ }
+ needsbyteswap = 1;
+ } else
+ needsbyteswap = 0;
+ if (needsbyteswap)
+ version = swap4(ptr[1]);
+ else
+ version = ptr[1];
+ if (version != VERSIONNO) {
+ file_error(ms, 0, "File %s supports only version %d magic "
+ "files. `%s' is version %d", VERSION,
+ VERSIONNO, dbname, version);
+ return -1;
+ }
+ entries = (uint32_t)(map->len / sizeof(struct magic));
+ if ((entries * sizeof(struct magic)) != map->len) {
+ file_error(ms, 0, "Size of `%s' %" SIZE_T_FORMAT "u is not "
+ "a multiple of %" SIZE_T_FORMAT "u",
+ dbname, map->len, sizeof(struct magic));
+ return -1;
+ }
+ map->magic[0] = CAST(struct magic *, map->p) + 1;
+ nentries = 0;
+ for (i = 0; i < MAGIC_SETS; i++) {
+ if (needsbyteswap)
+ map->nmagic[i] = swap4(ptr[i + 2]);
+ else
+ map->nmagic[i] = ptr[i + 2];
+ if (i != MAGIC_SETS - 1)
+ map->magic[i + 1] = map->magic[i] + map->nmagic[i];
+ nentries += map->nmagic[i];
+ }
+ if (entries != nentries + 1) {
+ file_error(ms, 0, "Inconsistent entries in `%s' %u != %u",
+ dbname, entries, nentries + 1);
+ return -1;
+ }
+ if (needsbyteswap)
+ for (i = 0; i < MAGIC_SETS; i++)
+ byteswap(map->magic[i], map->nmagic[i]);
+ return 0;
+}
+
+/*
+ * handle an mmaped file.
+ */
+private int
+apprentice_compile(struct magic_set *ms, struct magic_map *map, const char *fn)
+{
+ static const size_t nm = sizeof(*map->nmagic) * MAGIC_SETS;
+ static const size_t m = sizeof(**map->magic);
+ int fd = -1;
+ size_t len;
+ char *dbname;
+ int rv = -1;
+ uint32_t i;
+ union {
+ struct magic m;
+ uint32_t h[2 + MAGIC_SETS];
+ } hdr;
+
+ dbname = mkdbname(ms, fn, 1);
+
+ if (dbname == NULL)
+ goto out;
+
+ if ((fd = open(dbname, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0644)) == -1)
+ {
+ file_error(ms, errno, "cannot open `%s'", dbname);
+ goto out;
+ }
+ memset(&hdr, 0, sizeof(hdr));
+ hdr.h[0] = MAGICNO;
+ hdr.h[1] = VERSIONNO;
+ memcpy(hdr.h + 2, map->nmagic, nm);
+
+ if (write(fd, &hdr, sizeof(hdr)) != (ssize_t)sizeof(hdr)) {
+ file_error(ms, errno, "error writing `%s'", dbname);
+ goto out;
+ }
+
+ for (i = 0; i < MAGIC_SETS; i++) {
+ len = m * map->nmagic[i];
+ if (write(fd, map->magic[i], len) != (ssize_t)len) {
+ file_error(ms, errno, "error writing `%s'", dbname);
+ goto out;
+ }
+ }
+
+ if (fd != -1)
+ (void)close(fd);
+ rv = 0;
+out:
+ apprentice_unmap(map);
+ free(dbname);
+ return rv;
+}
+
+private const char ext[] = ".mgc";
+/*
+ * make a dbname
+ */
+private char *
+mkdbname(struct magic_set *ms, const char *fn, int strip)
+{
+ const char *p, *q;
+ char *buf;
+
+ if (strip) {
+ if ((p = strrchr(fn, '/')) != NULL)
+ fn = ++p;
+ }
+
+ for (q = fn; *q; q++)
+ continue;
+ /* Look for .mgc */
+ for (p = ext + sizeof(ext) - 1; p >= ext && q >= fn; p--, q--)
+ if (*p != *q)
+ break;
+
+ /* Did not find .mgc, restore q */
+ if (p >= ext)
+ while (*q)
+ q++;
+
+ q++;
+ /* Compatibility with old code that looked in .mime */
+ if (ms->flags & MAGIC_MIME) {
+ if (asprintf(&buf, "%.*s.mime%s", (int)(q - fn), fn, ext) < 0)
+ return NULL;
+ if (access(buf, R_OK) != -1) {
+ ms->flags &= MAGIC_MIME_TYPE;
+ return buf;
+ }
+ free(buf);
+ }
+ if (asprintf(&buf, "%.*s%s", (int)(q - fn), fn, ext) < 0)
+ return NULL;
+
+ /* Compatibility with old code that looked in .mime */
+ if (strstr(fn, ".mime") != NULL)
+ ms->flags &= MAGIC_MIME_TYPE;
+ return buf;
+}
+
+/*
+ * Byteswap an mmap'ed file if needed
+ */
+private void
+byteswap(struct magic *magic, uint32_t nmagic)
+{
+ uint32_t i;
+ for (i = 0; i < nmagic; i++)
+ bs1(&magic[i]);
+}
+
+/*
+ * swap a short
+ */
+private uint16_t
+swap2(uint16_t sv)
+{
+ uint16_t rv;
+ uint8_t *s = (uint8_t *)(void *)&sv;
+ uint8_t *d = (uint8_t *)(void *)&rv;
+ d[0] = s[1];
+ d[1] = s[0];
+ return rv;
+}
+
+/*
+ * swap an int
+ */
+private uint32_t
+swap4(uint32_t sv)
+{
+ uint32_t rv;
+ uint8_t *s = (uint8_t *)(void *)&sv;
+ uint8_t *d = (uint8_t *)(void *)&rv;
+ d[0] = s[3];
+ d[1] = s[2];
+ d[2] = s[1];
+ d[3] = s[0];
+ return rv;
+}
+
+/*
+ * swap a quad
+ */
+private uint64_t
+swap8(uint64_t sv)
+{
+ uint64_t rv;
+ uint8_t *s = (uint8_t *)(void *)&sv;
+ uint8_t *d = (uint8_t *)(void *)&rv;
+#if 0
+ d[0] = s[3];
+ d[1] = s[2];
+ d[2] = s[1];
+ d[3] = s[0];
+ d[4] = s[7];
+ d[5] = s[6];
+ d[6] = s[5];
+ d[7] = s[4];
+#else
+ d[0] = s[7];
+ d[1] = s[6];
+ d[2] = s[5];
+ d[3] = s[4];
+ d[4] = s[3];
+ d[5] = s[2];
+ d[6] = s[1];
+ d[7] = s[0];
+#endif
+ return rv;
+}
+
+/*
+ * byteswap a single magic entry
+ */
+private void
+bs1(struct magic *m)
+{
+ m->cont_level = swap2(m->cont_level);
+ m->offset = swap4((uint32_t)m->offset);
+ m->in_offset = swap4((uint32_t)m->in_offset);
+ m->lineno = swap4((uint32_t)m->lineno);
+ if (IS_STRING(m->type)) {
+ m->str_range = swap4(m->str_range);
+ m->str_flags = swap4(m->str_flags);
+ }
+ else {
+ m->value.q = swap8(m->value.q);
+ m->num_mask = swap8(m->num_mask);
+ }
+}
+
+protected size_t
+file_pstring_length_size(const struct magic *m)
+{
+ switch (m->str_flags & PSTRING_LEN) {
+ case PSTRING_1_LE:
+ return 1;
+ case PSTRING_2_LE:
+ case PSTRING_2_BE:
+ return 2;
+ case PSTRING_4_LE:
+ case PSTRING_4_BE:
+ return 4;
+ default:
+ abort(); /* Impossible */
+ return 1;
+ }
+}
+protected size_t
+file_pstring_get_length(const struct magic *m, const char *ss)
+{
+ size_t len = 0;
+ const unsigned char *s = (const unsigned char *)ss;
+ unsigned int s3, s2, s1, s0;
+
+ switch (m->str_flags & PSTRING_LEN) {
+ case PSTRING_1_LE:
+ len = *s;
+ break;
+ case PSTRING_2_LE:
+ s0 = s[0];
+ s1 = s[1];
+ len = (s1 << 8) | s0;
+ break;
+ case PSTRING_2_BE:
+ s0 = s[0];
+ s1 = s[1];
+ len = (s0 << 8) | s1;
+ break;
+ case PSTRING_4_LE:
+ s0 = s[0];
+ s1 = s[1];
+ s2 = s[2];
+ s3 = s[3];
+ len = (s3 << 24) | (s2 << 16) | (s1 << 8) | s0;
+ break;
+ case PSTRING_4_BE:
+ s0 = s[0];
+ s1 = s[1];
+ s2 = s[2];
+ s3 = s[3];
+ len = (s0 << 24) | (s1 << 16) | (s2 << 8) | s3;
+ break;
+ default:
+ abort(); /* Impossible */
+ }
+
+ if (m->str_flags & PSTRING_LENGTH_INCLUDES_ITSELF)
+ len -= file_pstring_length_size(m);
+
+ return len;
+}
+
+protected int
+file_magicfind(struct magic_set *ms, const char *name, struct mlist *v)
+{
+ uint32_t i, j;
+ struct mlist *mlist, *ml;
+
+ mlist = ms->mlist[1];
+
+ for (ml = mlist->next; ml != mlist; ml = ml->next) {
+ struct magic *ma = ml->magic;
+ uint32_t nma = ml->nmagic;
+ for (i = 0; i < nma; i++) {
+ if (ma[i].type != FILE_NAME)
+ continue;
+ if (strcmp(ma[i].value.s, name) == 0) {
+ v->magic = &ma[i];
+ for (j = i + 1; j < nma; j++)
+ if (ma[j].cont_level == 0)
+ break;
+ v->nmagic = j - i;
+ return 0;
+ }
+ }
+ }
+ return -1;
+}
diff --git a/node_modules/mmmagic/deps/libmagic/src/apptype.c b/node_modules/mmmagic/deps/libmagic/src/apptype.c
new file mode 100644
index 0000000..fcd764e
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/apptype.c
@@ -0,0 +1,169 @@
+/*
+ * Adapted from: apptype.c, Written by Eberhard Mattes and put into the
+ * public domain
+ *
+ * Notes: 1. Qualify the filename so that DosQueryAppType does not do extraneous
+ * searches.
+ *
+ * 2. DosQueryAppType will return FAPPTYP_DOS on a file ending with ".com"
+ * (other than an OS/2 exe or Win exe with this name). Eberhard Mattes
+ * remarks Tue, 6 Apr 93: Moreover, it reports the type of the (new and very
+ * bug ridden) Win Emacs as "OS/2 executable".
+ *
+ * 3. apptype() uses the filename if given, otherwise a tmp file is created with
+ * the contents of buf. If buf is not the complete file, apptype can
+ * incorrectly identify the exe type. The "-z" option of "file" is the reason
+ * for this ugly code.
+ */
+
+/*
+ * amai: Darrel Hankerson did the changes described here.
+ *
+ * It remains to check the validity of comments (2.) since it's referred to an
+ * "old" OS/2 version.
+ *
+ */
+
+#include "file.h"
+
+#ifndef lint
+FILE_RCSID("@(#)$File: apptype.c,v 1.13 2011/09/07 21:57:15 christos Exp $")
+#endif /* lint */
+
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef __EMX__
+#include <io.h>
+#define INCL_DOSSESMGR
+#define INCL_DOSERRORS
+#define INCL_DOSFILEMGR
+#include <os2.h>
+typedef ULONG APPTYPE;
+
+protected int
+file_os2_apptype(struct magic_set *ms, const char *fn, const void *buf,
+ size_t nb)
+{
+ APPTYPE rc, type;
+ char path[_MAX_PATH], drive[_MAX_DRIVE], dir[_MAX_DIR],
+ fname[_MAX_FNAME], ext[_MAX_EXT];
+ char *filename;
+ FILE *fp;
+
+ if (fn)
+ filename = strdup(fn);
+ else if ((filename = tempnam("./", "tmp")) == NULL) {
+ file_error(ms, errno, "cannot create tempnam");
+ return -1;
+ }
+ /* qualify the filename to prevent extraneous searches */
+ _splitpath(filename, drive, dir, fname, ext);
+ (void)sprintf(path, "%s%s%s%s", drive,
+ (*dir == '\0') ? "./" : dir,
+ fname,
+ (*ext == '\0') ? "." : ext);
+
+ if (fn == NULL) {
+ if ((fp = fopen(path, "wb")) == NULL) {
+ file_error(ms, errno, "cannot open tmp file `%s'", path);
+ return -1;
+ }
+ if (fwrite(buf, 1, nb, fp) != nb) {
+ file_error(ms, errno, "cannot write tmp file `%s'",
+ path);
+ (void)fclose(fp);
+ return -1;
+ }
+ (void)fclose(fp);
+ }
+ rc = DosQueryAppType((unsigned char *)path, &type);
+
+ if (fn == NULL) {
+ unlink(path);
+ free(filename);
+ }
+#if 0
+ if (rc == ERROR_INVALID_EXE_SIGNATURE)
+ printf("%s: not an executable file\n", fname);
+ else if (rc == ERROR_FILE_NOT_FOUND)
+ printf("%s: not found\n", fname);
+ else if (rc == ERROR_ACCESS_DENIED)
+ printf("%s: access denied\n", fname);
+ else if (rc != 0)
+ printf("%s: error code = %lu\n", fname, rc);
+ else
+#else
+
+ /*
+ * for our purpose here it's sufficient to just ignore the error and
+ * return w/o success (=0)
+ */
+
+ if (rc)
+ return (0);
+
+#endif
+
+ if (type & FAPPTYP_32BIT)
+ if (file_printf(ms, "32-bit ") == -1)
+ return -1;
+ if (type & FAPPTYP_PHYSDRV) {
+ if (file_printf(ms, "physical device driver") == -1)
+ return -1;
+ } else if (type & FAPPTYP_VIRTDRV) {
+ if (file_printf(ms, "virtual device driver") == -1)
+ return -1;
+ } else if (type & FAPPTYP_DLL) {
+ if (type & FAPPTYP_PROTDLL)
+ if (file_printf(ms, "protected ") == -1)
+ return -1;
+ if (file_printf(ms, "DLL") == -1)
+ return -1;
+ } else if (type & (FAPPTYP_WINDOWSREAL | FAPPTYP_WINDOWSPROT)) {
+ if (file_printf(ms, "Windows executable") == -1)
+ return -1;
+ } else if (type & FAPPTYP_DOS) {
+ /*
+ * The API routine is partially broken on filenames ending
+ * ".com".
+ */
+ if (stricmp(ext, ".com") == 0)
+ if (strncmp((const char *)buf, "MZ", 2))
+ return (0);
+ if (file_printf(ms, "DOS executable") == -1)
+ return -1;
+ /* ---------------------------------------- */
+ /* Might learn more from the magic(4) entry */
+ if (file_printf(ms, ", magic(4)-> ") == -1)
+ return -1;
+ return (0);
+ /* ---------------------------------------- */
+ } else if (type & FAPPTYP_BOUND) {
+ if (file_printf(ms, "bound executable") == -1)
+ return -1;
+ } else if ((type & 7) == FAPPTYP_WINDOWAPI) {
+ if (file_printf(ms, "PM executable") == -1)
+ return -1;
+ } else if (file_printf(ms, "OS/2 executable") == -1)
+ return -1;
+
+ switch (type & (FAPPTYP_NOTWINDOWCOMPAT |
+ FAPPTYP_WINDOWCOMPAT |
+ FAPPTYP_WINDOWAPI)) {
+ case FAPPTYP_NOTWINDOWCOMPAT:
+ if (file_printf(ms, " [NOTWINDOWCOMPAT]") == -1)
+ return -1;
+ break;
+ case FAPPTYP_WINDOWCOMPAT:
+ if (file_printf(ms, " [WINDOWCOMPAT]") == -1)
+ return -1;
+ break;
+ case FAPPTYP_WINDOWAPI:
+ if (file_printf(ms, " [WINDOWAPI]") == -1)
+ return -1;
+ break;
+ }
+ return 1;
+}
+#endif
diff --git a/node_modules/mmmagic/deps/libmagic/src/ascmagic.c b/node_modules/mmmagic/deps/libmagic/src/ascmagic.c
new file mode 100644
index 0000000..85a973e
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/ascmagic.c
@@ -0,0 +1,361 @@
+/*
+ * Copyright (c) Ian F. Darwin 1986-1995.
+ * Software written by Ian F. Darwin and others;
+ * maintained 1995-present by Christos Zoulas and others.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice immediately at the beginning of the file, without modification,
+ * this list of conditions, and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+/*
+ * ASCII magic -- try to detect text encoding.
+ *
+ * Extensively modified by Eric Fischer <enf@pobox.com> in July, 2000,
+ * to handle character codes other than ASCII on a unified basis.
+ */
+
+#include "file.h"
+
+#ifndef lint
+FILE_RCSID("@(#)$File: ascmagic.c,v 1.97 2016/06/27 20:56:25 christos Exp $")
+#endif /* lint */
+
+#include "magic.h"
+#include <string.h>
+#include <memory.h>
+#include <ctype.h>
+#include <stdlib.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#define MAXLINELEN 300 /* longest sane line length */
+#define ISSPC(x) ((x) == ' ' || (x) == '\t' || (x) == '\r' || (x) == '\n' \
+ || (x) == 0x85 || (x) == '\f')
+
+private unsigned char *encode_utf8(unsigned char *, size_t, unichar *, size_t);
+private size_t trim_nuls(const unsigned char *, size_t);
+
+/*
+ * Undo the NUL-termination kindly provided by process()
+ * but leave at least one byte to look at
+ */
+private size_t
+trim_nuls(const unsigned char *buf, size_t nbytes)
+{
+ while (nbytes > 1 && buf[nbytes - 1] == '\0')
+ nbytes--;
+
+ return nbytes;
+}
+
+protected int
+file_ascmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes,
+ int text)
+{
+ unichar *ubuf = NULL;
+ size_t ulen = 0;
+ int rv = 1;
+
+ const char *code = NULL;
+ const char *code_mime = NULL;
+ const char *type = NULL;
+
+ nbytes = trim_nuls(buf, nbytes);
+
+ /* If file doesn't look like any sort of text, give up. */
+ if (file_encoding(ms, buf, nbytes, &ubuf, &ulen, &code, &code_mime,
+ &type) == 0)
+ rv = 0;
+ else
+ rv = file_ascmagic_with_encoding(ms, buf, nbytes, ubuf, ulen, code,
+ type, text);
+
+ free(ubuf);
+
+ return rv;
+}
+
+protected int
+file_ascmagic_with_encoding(struct magic_set *ms, const unsigned char *buf,
+ size_t nbytes, unichar *ubuf, size_t ulen, const char *code,
+ const char *type, int text)
+{
+ unsigned char *utf8_buf = NULL, *utf8_end;
+ size_t mlen, i;
+ int rv = -1;
+ int mime = ms->flags & MAGIC_MIME;
+
+ const char *subtype = NULL;
+ const char *subtype_mime = NULL;
+
+ int has_escapes = 0;
+ int has_backspace = 0;
+ int seen_cr = 0;
+
+ int n_crlf = 0;
+ int n_lf = 0;
+ int n_cr = 0;
+ int n_nel = 0;
+ int executable = 0;
+
+ size_t last_line_end = (size_t)-1;
+ int has_long_lines = 0;
+
+ nbytes = trim_nuls(buf, nbytes);
+
+ /* If we have fewer than 2 bytes, give up. */
+ if (nbytes <= 1) {
+ rv = 0;
+ goto done;
+ }
+
+ if (ulen > 0 && (ms->flags & MAGIC_NO_CHECK_SOFT) == 0) {
+ /* Convert ubuf to UTF-8 and try text soft magic */
+ /* malloc size is a conservative overestimate; could be
+ improved, or at least realloced after conversion. */
+ mlen = ulen * 6;
+ if ((utf8_buf = CAST(unsigned char *, malloc(mlen))) == NULL) {
+ file_oomem(ms, mlen);
+ goto done;
+ }
+ if ((utf8_end = encode_utf8(utf8_buf, mlen, ubuf, ulen))
+ == NULL)
+ goto done;
+ if ((rv = file_softmagic(ms, utf8_buf,
+ (size_t)(utf8_end - utf8_buf), NULL, NULL,
+ TEXTTEST, text)) == 0)
+ rv = -1;
+ if ((ms->flags & (MAGIC_APPLE|MAGIC_EXTENSION))) {
+ rv = rv == -1 ? 0 : 1;
+ goto done;
+ }
+ }
+ if ((ms->flags & (MAGIC_APPLE|MAGIC_EXTENSION)))
+ return 0;
+
+ /* Now try to discover other details about the file. */
+ for (i = 0; i < ulen; i++) {
+ if (ubuf[i] == '\n') {
+ if (seen_cr)
+ n_crlf++;
+ else
+ n_lf++;
+ last_line_end = i;
+ } else if (seen_cr)
+ n_cr++;
+
+ seen_cr = (ubuf[i] == '\r');
+ if (seen_cr)
+ last_line_end = i;
+
+ if (ubuf[i] == 0x85) { /* X3.64/ECMA-43 "next line" character */
+ n_nel++;
+ last_line_end = i;
+ }
+
+ /* If this line is _longer_ than MAXLINELEN, remember it. */
+ if (i > last_line_end + MAXLINELEN)
+ has_long_lines = 1;
+
+ if (ubuf[i] == '\033')
+ has_escapes = 1;
+ if (ubuf[i] == '\b')
+ has_backspace = 1;
+ }
+
+ /* Beware, if the data has been truncated, the final CR could have
+ been followed by a LF. If we have ms->bytes_max bytes, it indicates
+ that the data might have been truncated, probably even before
+ this function was called. */
+ if (seen_cr && nbytes < ms->bytes_max)
+ n_cr++;
+
+ if (strcmp(type, "binary") == 0) {
+ rv = 0;
+ goto done;
+ }
+ if (mime) {
+ if (!file_printedlen(ms) && (mime & MAGIC_MIME_TYPE) != 0) {
+ if (subtype_mime) {
+ if (file_printf(ms, "%s", subtype_mime) == -1)
+ goto done;
+ } else {
+ if (file_printf(ms, "text/plain") == -1)
+ goto done;
+ }
+ }
+ } else {
+ if (file_printedlen(ms)) {
+ switch (file_replace(ms, " text$", ", ")) {
+ case 0:
+ switch (file_replace(ms, " text executable$",
+ ", ")) {
+ case 0:
+ if (file_printf(ms, ", ") == -1)
+ goto done;
+ break;
+ case -1:
+ goto done;
+ default:
+ executable = 1;
+ break;
+ }
+ break;
+ case -1:
+ goto done;
+ default:
+ break;
+ }
+ }
+
+ if (file_printf(ms, "%s", code) == -1)
+ goto done;
+
+ if (subtype) {
+ if (file_printf(ms, " %s", subtype) == -1)
+ goto done;
+ }
+
+ if (file_printf(ms, " %s", type) == -1)
+ goto done;
+
+ if (executable)
+ if (file_printf(ms, " executable") == -1)
+ goto done;
+
+ if (has_long_lines)
+ if (file_printf(ms, ", with very long lines") == -1)
+ goto done;
+
+ /*
+ * Only report line terminators if we find one other than LF,
+ * or if we find none at all.
+ */
+ if ((n_crlf == 0 && n_cr == 0 && n_nel == 0 && n_lf == 0) ||
+ (n_crlf != 0 || n_cr != 0 || n_nel != 0)) {
+ if (file_printf(ms, ", with") == -1)
+ goto done;
+
+ if (n_crlf == 0 && n_cr == 0 && n_nel == 0 && n_lf == 0) {
+ if (file_printf(ms, " no") == -1)
+ goto done;
+ } else {
+ if (n_crlf) {
+ if (file_printf(ms, " CRLF") == -1)
+ goto done;
+ if (n_cr || n_lf || n_nel)
+ if (file_printf(ms, ",") == -1)
+ goto done;
+ }
+ if (n_cr) {
+ if (file_printf(ms, " CR") == -1)
+ goto done;
+ if (n_lf || n_nel)
+ if (file_printf(ms, ",") == -1)
+ goto done;
+ }
+ if (n_lf) {
+ if (file_printf(ms, " LF") == -1)
+ goto done;
+ if (n_nel)
+ if (file_printf(ms, ",") == -1)
+ goto done;
+ }
+ if (n_nel)
+ if (file_printf(ms, " NEL") == -1)
+ goto done;
+ }
+
+ if (file_printf(ms, " line terminators") == -1)
+ goto done;
+ }
+
+ if (has_escapes)
+ if (file_printf(ms, ", with escape sequences") == -1)
+ goto done;
+ if (has_backspace)
+ if (file_printf(ms, ", with overstriking") == -1)
+ goto done;
+ }
+ rv = 1;
+done:
+ free(utf8_buf);
+
+ return rv;
+}
+
+/*
+ * Encode Unicode string as UTF-8, returning pointer to character
+ * after end of string, or NULL if an invalid character is found.
+ */
+private unsigned char *
+encode_utf8(unsigned char *buf, size_t len, unichar *ubuf, size_t ulen)
+{
+ size_t i;
+ unsigned char *end = buf + len;
+
+ for (i = 0; i < ulen; i++) {
+ if (ubuf[i] <= 0x7f) {
+ if (end - buf < 1)
+ return NULL;
+ *buf++ = (unsigned char)ubuf[i];
+ } else if (ubuf[i] <= 0x7ff) {
+ if (end - buf < 2)
+ return NULL;
+ *buf++ = (unsigned char)((ubuf[i] >> 6) + 0xc0);
+ *buf++ = (unsigned char)((ubuf[i] & 0x3f) + 0x80);
+ } else if (ubuf[i] <= 0xffff) {
+ if (end - buf < 3)
+ return NULL;
+ *buf++ = (unsigned char)((ubuf[i] >> 12) + 0xe0);
+ *buf++ = (unsigned char)(((ubuf[i] >> 6) & 0x3f) + 0x80);
+ *buf++ = (unsigned char)((ubuf[i] & 0x3f) + 0x80);
+ } else if (ubuf[i] <= 0x1fffff) {
+ if (end - buf < 4)
+ return NULL;
+ *buf++ = (unsigned char)((ubuf[i] >> 18) + 0xf0);
+ *buf++ = (unsigned char)(((ubuf[i] >> 12) & 0x3f) + 0x80);
+ *buf++ = (unsigned char)(((ubuf[i] >> 6) & 0x3f) + 0x80);
+ *buf++ = (unsigned char)((ubuf[i] & 0x3f) + 0x80);
+ } else if (ubuf[i] <= 0x3ffffff) {
+ if (end - buf < 5)
+ return NULL;
+ *buf++ = (unsigned char)((ubuf[i] >> 24) + 0xf8);
+ *buf++ = (unsigned char)(((ubuf[i] >> 18) & 0x3f) + 0x80);
+ *buf++ = (unsigned char)(((ubuf[i] >> 12) & 0x3f) + 0x80);
+ *buf++ = (unsigned char)(((ubuf[i] >> 6) & 0x3f) + 0x80);
+ *buf++ = (unsigned char)((ubuf[i] & 0x3f) + 0x80);
+ } else if (ubuf[i] <= 0x7fffffff) {
+ if (end - buf < 6)
+ return NULL;
+ *buf++ = (unsigned char)((ubuf[i] >> 30) + 0xfc);
+ *buf++ = (unsigned char)(((ubuf[i] >> 24) & 0x3f) + 0x80);
+ *buf++ = (unsigned char)(((ubuf[i] >> 18) & 0x3f) + 0x80);
+ *buf++ = (unsigned char)(((ubuf[i] >> 12) & 0x3f) + 0x80);
+ *buf++ = (unsigned char)(((ubuf[i] >> 6) & 0x3f) + 0x80);
+ *buf++ = (unsigned char)((ubuf[i] & 0x3f) + 0x80);
+ } else /* Invalid character */
+ return NULL;
+ }
+
+ return buf;
+}
diff --git a/node_modules/mmmagic/deps/libmagic/src/asctime_r.c b/node_modules/mmmagic/deps/libmagic/src/asctime_r.c
new file mode 100644
index 0000000..3a0ec04
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/asctime_r.c
@@ -0,0 +1,19 @@
+/* $File: asctime_r.c,v 1.1 2012/05/15 17:14:36 christos Exp $ */
+
+#include "file.h"
+#ifndef lint
+FILE_RCSID("@(#)$File: asctime_r.c,v 1.1 2012/05/15 17:14:36 christos Exp $")
+#endif /* lint */
+#include <time.h>
+#include <string.h>
+
+/* asctime_r is not thread-safe anyway */
+char *
+asctime_r(const struct tm *t, char *dst)
+{
+ char *p = asctime(t);
+ if (p == NULL)
+ return NULL;
+ memcpy(dst, p, 26);
+ return dst;
+}
diff --git a/node_modules/mmmagic/deps/libmagic/src/asprintf.c b/node_modules/mmmagic/deps/libmagic/src/asprintf.c
new file mode 100644
index 0000000..30852d2
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/asprintf.c
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) Ian F. Darwin 1986-1995.
+ * Software written by Ian F. Darwin and others;
+ * maintained 1995-present by Christos Zoulas and others.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice immediately at the beginning of the file, without modification,
+ * this list of conditions, and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "file.h"
+
+#ifndef lint
+FILE_RCSID("@(#)$File: asprintf.c,v 1.4 2010/07/21 16:47:17 christos Exp $")
+#endif
+
+int asprintf(char **ptr, const char *fmt, ...)
+{
+ va_list vargs;
+ int retval;
+
+ va_start(vargs, fmt);
+ retval = vasprintf(ptr, fmt, vargs);
+ va_end(vargs);
+
+ return retval;
+}
diff --git a/node_modules/mmmagic/deps/libmagic/src/cdf.c b/node_modules/mmmagic/deps/libmagic/src/cdf.c
new file mode 100644
index 0000000..0bb22e6
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/cdf.c
@@ -0,0 +1,1629 @@
+/*-
+ * Copyright (c) 2008 Christos Zoulas
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * Parse Composite Document Files, the format used in Microsoft Office
+ * document files before they switched to zipped XML.
+ * Info from: http://sc.openoffice.org/compdocfileformat.pdf
+ *
+ * N.B. This is the "Composite Document File" format, and not the
+ * "Compound Document Format", nor the "Channel Definition Format".
+ */
+
+#include "file.h"
+
+#ifndef lint
+FILE_RCSID("@(#)$File: cdf.c,v 1.106 2017/04/30 17:05:02 christos Exp $")
+#endif
+
+#include <assert.h>
+#ifdef CDF_DEBUG
+#include <err.h>
+#endif
+#include <stdlib.h>
+// XXX: change by mscdex
+//#include <unistd.h>
+#include <string.h>
+#include <time.h>
+#include <ctype.h>
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+
+#ifndef EFTYPE
+#define EFTYPE EINVAL
+#endif
+
+#include "cdf.h"
+
+#ifdef CDF_DEBUG
+#define DPRINTF(a) printf a, fflush(stdout)
+#else
+#define DPRINTF(a)
+#endif
+
+static union {
+ char s[4];
+ uint32_t u;
+} cdf_bo;
+
+#define NEED_SWAP (cdf_bo.u == (uint32_t)0x01020304)
+
+#define CDF_TOLE8(x) ((uint64_t)(NEED_SWAP ? _cdf_tole8(x) : (uint64_t)(x)))
+#define CDF_TOLE4(x) ((uint32_t)(NEED_SWAP ? _cdf_tole4(x) : (uint32_t)(x)))
+#define CDF_TOLE2(x) ((uint16_t)(NEED_SWAP ? _cdf_tole2(x) : (uint16_t)(x)))
+#define CDF_TOLE(x) (/*CONSTCOND*/sizeof(x) == 2 ? \
+ CDF_TOLE2(CAST(uint16_t, x)) : \
+ (/*CONSTCOND*/sizeof(x) == 4 ? \
+ CDF_TOLE4(CAST(uint32_t, x)) : \
+ CDF_TOLE8(CAST(uint64_t, x))))
+#define CDF_GETUINT32(x, y) cdf_getuint32(x, y)
+
+#define CDF_MALLOC(n) cdf_malloc(__FILE__, __LINE__, (n))
+#define CDF_REALLOC(p, n) cdf_realloc(__FILE__, __LINE__, (p), (n))
+#define CDF_CALLOC(n, u) cdf_calloc(__FILE__, __LINE__, (n), (u))
+
+
+static void *
+cdf_malloc(const char *file __attribute__((__unused__)),
+ size_t line __attribute__((__unused__)), size_t n)
+{
+ DPRINTF(("%s,%zu: %s %zu\n", file, line, __func__, n));
+ return malloc(n);
+}
+
+static void *
+cdf_realloc(const char *file __attribute__((__unused__)),
+ size_t line __attribute__((__unused__)), void *p, size_t n)
+{
+ DPRINTF(("%s,%zu: %s %zu\n", file, line, __func__, n));
+ return realloc(p, n);
+}
+
+static void *
+cdf_calloc(const char *file __attribute__((__unused__)),
+ size_t line __attribute__((__unused__)), size_t n, size_t u)
+{
+ DPRINTF(("%s,%zu: %s %zu %zu\n", file, line, __func__, n, u));
+ return calloc(n, u);
+}
+
+/*
+ * swap a short
+ */
+static uint16_t
+_cdf_tole2(uint16_t sv)
+{
+ uint16_t rv;
+ uint8_t *s = (uint8_t *)(void *)&sv;
+ uint8_t *d = (uint8_t *)(void *)&rv;
+ d[0] = s[1];
+ d[1] = s[0];
+ return rv;
+}
+
+/*
+ * swap an int
+ */
+static uint32_t
+_cdf_tole4(uint32_t sv)
+{
+ uint32_t rv;
+ uint8_t *s = (uint8_t *)(void *)&sv;
+ uint8_t *d = (uint8_t *)(void *)&rv;
+ d[0] = s[3];
+ d[1] = s[2];
+ d[2] = s[1];
+ d[3] = s[0];
+ return rv;
+}
+
+/*
+ * swap a quad
+ */
+static uint64_t
+_cdf_tole8(uint64_t sv)
+{
+ uint64_t rv;
+ uint8_t *s = (uint8_t *)(void *)&sv;
+ uint8_t *d = (uint8_t *)(void *)&rv;
+ d[0] = s[7];
+ d[1] = s[6];
+ d[2] = s[5];
+ d[3] = s[4];
+ d[4] = s[3];
+ d[5] = s[2];
+ d[6] = s[1];
+ d[7] = s[0];
+ return rv;
+}
+
+/*
+ * grab a uint32_t from a possibly unaligned address, and return it in
+ * the native host order.
+ */
+static uint32_t
+cdf_getuint32(const uint8_t *p, size_t offs)
+{
+ uint32_t rv;
+ (void)memcpy(&rv, p + offs * sizeof(uint32_t), sizeof(rv));
+ return CDF_TOLE4(rv);
+}
+
+#define CDF_UNPACK(a) \
+ (void)memcpy(&(a), &buf[len], sizeof(a)), len += sizeof(a)
+#define CDF_UNPACKA(a) \
+ (void)memcpy((a), &buf[len], sizeof(a)), len += sizeof(a)
+
+uint16_t
+cdf_tole2(uint16_t sv)
+{
+ return CDF_TOLE2(sv);
+}
+
+uint32_t
+cdf_tole4(uint32_t sv)
+{
+ return CDF_TOLE4(sv);
+}
+
+uint64_t
+cdf_tole8(uint64_t sv)
+{
+ return CDF_TOLE8(sv);
+}
+
+void
+cdf_swap_header(cdf_header_t *h)
+{
+ size_t i;
+
+ h->h_magic = CDF_TOLE8(h->h_magic);
+ h->h_uuid[0] = CDF_TOLE8(h->h_uuid[0]);
+ h->h_uuid[1] = CDF_TOLE8(h->h_uuid[1]);
+ h->h_revision = CDF_TOLE2(h->h_revision);
+ h->h_version = CDF_TOLE2(h->h_version);
+ h->h_byte_order = CDF_TOLE2(h->h_byte_order);
+ h->h_sec_size_p2 = CDF_TOLE2(h->h_sec_size_p2);
+ h->h_short_sec_size_p2 = CDF_TOLE2(h->h_short_sec_size_p2);
+ h->h_num_sectors_in_sat = CDF_TOLE4(h->h_num_sectors_in_sat);
+ h->h_secid_first_directory = CDF_TOLE4(h->h_secid_first_directory);
+ h->h_min_size_standard_stream =
+ CDF_TOLE4(h->h_min_size_standard_stream);
+ h->h_secid_first_sector_in_short_sat =
+ CDF_TOLE4((uint32_t)h->h_secid_first_sector_in_short_sat);
+ h->h_num_sectors_in_short_sat =
+ CDF_TOLE4(h->h_num_sectors_in_short_sat);
+ h->h_secid_first_sector_in_master_sat =
+ CDF_TOLE4((uint32_t)h->h_secid_first_sector_in_master_sat);
+ h->h_num_sectors_in_master_sat =
+ CDF_TOLE4(h->h_num_sectors_in_master_sat);
+ for (i = 0; i < __arraycount(h->h_master_sat); i++)
+ h->h_master_sat[i] = CDF_TOLE4((uint32_t)h->h_master_sat[i]);
+}
+
+void
+cdf_unpack_header(cdf_header_t *h, char *buf)
+{
+ size_t i;
+ size_t len = 0;
+
+ CDF_UNPACK(h->h_magic);
+ CDF_UNPACKA(h->h_uuid);
+ CDF_UNPACK(h->h_revision);
+ CDF_UNPACK(h->h_version);
+ CDF_UNPACK(h->h_byte_order);
+ CDF_UNPACK(h->h_sec_size_p2);
+ CDF_UNPACK(h->h_short_sec_size_p2);
+ CDF_UNPACKA(h->h_unused0);
+ CDF_UNPACK(h->h_num_sectors_in_sat);
+ CDF_UNPACK(h->h_secid_first_directory);
+ CDF_UNPACKA(h->h_unused1);
+ CDF_UNPACK(h->h_min_size_standard_stream);
+ CDF_UNPACK(h->h_secid_first_sector_in_short_sat);
+ CDF_UNPACK(h->h_num_sectors_in_short_sat);
+ CDF_UNPACK(h->h_secid_first_sector_in_master_sat);
+ CDF_UNPACK(h->h_num_sectors_in_master_sat);
+ for (i = 0; i < __arraycount(h->h_master_sat); i++)
+ CDF_UNPACK(h->h_master_sat[i]);
+}
+
+void
+cdf_swap_dir(cdf_directory_t *d)
+{
+ d->d_namelen = CDF_TOLE2(d->d_namelen);
+ d->d_left_child = CDF_TOLE4((uint32_t)d->d_left_child);
+ d->d_right_child = CDF_TOLE4((uint32_t)d->d_right_child);
+ d->d_storage = CDF_TOLE4((uint32_t)d->d_storage);
+ d->d_storage_uuid[0] = CDF_TOLE8(d->d_storage_uuid[0]);
+ d->d_storage_uuid[1] = CDF_TOLE8(d->d_storage_uuid[1]);
+ d->d_flags = CDF_TOLE4(d->d_flags);
+ d->d_created = CDF_TOLE8((uint64_t)d->d_created);
+ d->d_modified = CDF_TOLE8((uint64_t)d->d_modified);
+ d->d_stream_first_sector = CDF_TOLE4((uint32_t)d->d_stream_first_sector);
+ d->d_size = CDF_TOLE4(d->d_size);
+}
+
+void
+cdf_swap_class(cdf_classid_t *d)
+{
+ d->cl_dword = CDF_TOLE4(d->cl_dword);
+ d->cl_word[0] = CDF_TOLE2(d->cl_word[0]);
+ d->cl_word[1] = CDF_TOLE2(d->cl_word[1]);
+}
+
+void
+cdf_unpack_dir(cdf_directory_t *d, char *buf)
+{
+ size_t len = 0;
+
+ CDF_UNPACKA(d->d_name);
+ CDF_UNPACK(d->d_namelen);
+ CDF_UNPACK(d->d_type);
+ CDF_UNPACK(d->d_color);
+ CDF_UNPACK(d->d_left_child);
+ CDF_UNPACK(d->d_right_child);
+ CDF_UNPACK(d->d_storage);
+ CDF_UNPACKA(d->d_storage_uuid);
+ CDF_UNPACK(d->d_flags);
+ CDF_UNPACK(d->d_created);
+ CDF_UNPACK(d->d_modified);
+ CDF_UNPACK(d->d_stream_first_sector);
+ CDF_UNPACK(d->d_size);
+ CDF_UNPACK(d->d_unused0);
+}
+
+int
+cdf_zero_stream(cdf_stream_t *scn)
+{
+ scn->sst_len = 0;
+ scn->sst_dirlen = 0;
+ scn->sst_ss = 0;
+ free(scn->sst_tab);
+ scn->sst_tab = NULL;
+ return -1;
+}
+
+static size_t
+cdf_check_stream(const cdf_stream_t *sst, const cdf_header_t *h)
+{
+ size_t ss = sst->sst_dirlen < h->h_min_size_standard_stream ?
+ CDF_SHORT_SEC_SIZE(h) : CDF_SEC_SIZE(h);
+ assert(ss == sst->sst_ss);
+ return sst->sst_ss;
+}
+
+static int
+cdf_check_stream_offset(const cdf_stream_t *sst, const cdf_header_t *h,
+ const void *p, size_t tail, int line)
+{
+ const char *b = (const char *)sst->sst_tab;
+ const char *e = ((const char *)p) + tail;
+ size_t ss = cdf_check_stream(sst, h);
+ /*LINTED*/(void)&line;
+ if (e >= b && (size_t)(e - b) <= ss * sst->sst_len)
+ return 0;
+ DPRINTF(("%d: offset begin %p < end %p || %" SIZE_T_FORMAT "u"
+ " > %" SIZE_T_FORMAT "u [%" SIZE_T_FORMAT "u %"
+ SIZE_T_FORMAT "u]\n", line, b, e, (size_t)(e - b),
+ ss * sst->sst_len, ss, sst->sst_len));
+ errno = EFTYPE;
+ return -1;
+}
+
+static ssize_t
+cdf_read(const cdf_info_t *info, off_t off, void *buf, size_t len)
+{
+ size_t siz = (size_t)off + len;
+
+ if ((off_t)(off + len) != (off_t)siz)
+ goto out;
+
+ if (info->i_buf != NULL && info->i_len >= siz) {
+ (void)memcpy(buf, &info->i_buf[off], len);
+ return (ssize_t)len;
+ }
+
+ if (info->i_fd == -1)
+ goto out;
+
+ if (pread(info->i_fd, buf, len, off) != (ssize_t)len)
+ return -1;
+
+ return (ssize_t)len;
+out:
+ errno = EINVAL;
+ return -1;
+}
+
+int
+cdf_read_header(const cdf_info_t *info, cdf_header_t *h)
+{
+ char buf[512];
+
+ (void)memcpy(cdf_bo.s, "\01\02\03\04", 4);
+ if (cdf_read(info, (off_t)0, buf, sizeof(buf)) == -1)
+ return -1;
+ cdf_unpack_header(h, buf);
+ cdf_swap_header(h);
+ if (h->h_magic != CDF_MAGIC) {
+ DPRINTF(("Bad magic %#" INT64_T_FORMAT "x != %#"
+ INT64_T_FORMAT "x\n",
+ (unsigned long long)h->h_magic,
+ (unsigned long long)CDF_MAGIC));
+ goto out;
+ }
+ if (h->h_sec_size_p2 > 20) {
+ DPRINTF(("Bad sector size %hu\n", h->h_sec_size_p2));
+ goto out;
+ }
+ if (h->h_short_sec_size_p2 > 20) {
+ DPRINTF(("Bad short sector size %hu\n",
+ h->h_short_sec_size_p2));
+ goto out;
+ }
+ return 0;
+out:
+ errno = EFTYPE;
+ return -1;
+}
+
+
+ssize_t
+cdf_read_sector(const cdf_info_t *info, void *buf, size_t offs, size_t len,
+ const cdf_header_t *h, cdf_secid_t id)
+{
+ size_t ss = CDF_SEC_SIZE(h);
+ size_t pos = CDF_SEC_POS(h, id);
+ assert(ss == len);
+ return cdf_read(info, (off_t)pos, ((char *)buf) + offs, len);
+}
+
+ssize_t
+cdf_read_short_sector(const cdf_stream_t *sst, void *buf, size_t offs,
+ size_t len, const cdf_header_t *h, cdf_secid_t id)
+{
+ size_t ss = CDF_SHORT_SEC_SIZE(h);
+ size_t pos = CDF_SHORT_SEC_POS(h, id);
+ assert(ss == len);
+ if (pos + len > CDF_SEC_SIZE(h) * sst->sst_len) {
+ DPRINTF(("Out of bounds read %" SIZE_T_FORMAT "u > %"
+ SIZE_T_FORMAT "u\n",
+ pos + len, CDF_SEC_SIZE(h) * sst->sst_len));
+ goto out;
+ }
+ (void)memcpy(((char *)buf) + offs,
+ ((const char *)sst->sst_tab) + pos, len);
+ return len;
+out:
+ errno = EFTYPE;
+ return -1;
+}
+
+/*
+ * Read the sector allocation table.
+ */
+int
+cdf_read_sat(const cdf_info_t *info, cdf_header_t *h, cdf_sat_t *sat)
+{
+ size_t i, j, k;
+ size_t ss = CDF_SEC_SIZE(h);
+ cdf_secid_t *msa, mid, sec;
+ size_t nsatpersec = (ss / sizeof(mid)) - 1;
+
+ for (i = 0; i < __arraycount(h->h_master_sat); i++)
+ if (h->h_master_sat[i] == CDF_SECID_FREE)
+ break;
+
+#define CDF_SEC_LIMIT (UINT32_MAX / (8 * ss))
+ if ((nsatpersec > 0 &&
+ h->h_num_sectors_in_master_sat > CDF_SEC_LIMIT / nsatpersec) ||
+ i > CDF_SEC_LIMIT) {
+ DPRINTF(("Number of sectors in master SAT too big %u %"
+ SIZE_T_FORMAT "u\n", h->h_num_sectors_in_master_sat, i));
+ errno = EFTYPE;
+ return -1;
+ }
+
+ sat->sat_len = h->h_num_sectors_in_master_sat * nsatpersec + i;
+ DPRINTF(("sat_len = %" SIZE_T_FORMAT "u ss = %" SIZE_T_FORMAT "u\n",
+ sat->sat_len, ss));
+ if ((sat->sat_tab = CAST(cdf_secid_t *, CDF_CALLOC(sat->sat_len, ss)))
+ == NULL)
+ return -1;
+
+ for (i = 0; i < __arraycount(h->h_master_sat); i++) {
+ if (h->h_master_sat[i] < 0)
+ break;
+ if (cdf_read_sector(info, sat->sat_tab, ss * i, ss, h,
+ h->h_master_sat[i]) != (ssize_t)ss) {
+ DPRINTF(("Reading sector %d", h->h_master_sat[i]));
+ goto out1;
+ }
+ }
+
+ if ((msa = CAST(cdf_secid_t *, CDF_CALLOC(1, ss))) == NULL)
+ goto out1;
+
+ mid = h->h_secid_first_sector_in_master_sat;
+ for (j = 0; j < h->h_num_sectors_in_master_sat; j++) {
+ if (mid < 0)
+ goto out;
+ if (j >= CDF_LOOP_LIMIT) {
+ DPRINTF(("Reading master sector loop limit"));
+ goto out3;
+ }
+ if (cdf_read_sector(info, msa, 0, ss, h, mid) != (ssize_t)ss) {
+ DPRINTF(("Reading master sector %d", mid));
+ goto out2;
+ }
+ for (k = 0; k < nsatpersec; k++, i++) {
+ sec = CDF_TOLE4((uint32_t)msa[k]);
+ if (sec < 0)
+ goto out;
+ if (i >= sat->sat_len) {
+ DPRINTF(("Out of bounds reading MSA %" SIZE_T_FORMAT
+ "u >= %" SIZE_T_FORMAT "u", i, sat->sat_len));
+ goto out3;
+ }
+ if (cdf_read_sector(info, sat->sat_tab, ss * i, ss, h,
+ sec) != (ssize_t)ss) {
+ DPRINTF(("Reading sector %d",
+ CDF_TOLE4(msa[k])));
+ goto out2;
+ }
+ }
+ mid = CDF_TOLE4((uint32_t)msa[nsatpersec]);
+ }
+out:
+ sat->sat_len = i;
+ free(msa);
+ return 0;
+out3:
+ errno = EFTYPE;
+out2:
+ free(msa);
+out1:
+ free(sat->sat_tab);
+ return -1;
+}
+
+size_t
+cdf_count_chain(const cdf_sat_t *sat, cdf_secid_t sid, size_t size)
+{
+ size_t i, j;
+ cdf_secid_t maxsector = (cdf_secid_t)((sat->sat_len * size)
+ / sizeof(maxsector));
+
+ DPRINTF(("Chain:"));
+ if (sid == CDF_SECID_END_OF_CHAIN) {
+ /* 0-length chain. */
+ DPRINTF((" empty\n"));
+ return 0;
+ }
+
+ for (j = i = 0; sid >= 0; i++, j++) {
+ DPRINTF((" %d", sid));
+ if (j >= CDF_LOOP_LIMIT) {
+ DPRINTF(("Counting chain loop limit"));
+ goto out;
+ }
+ if (sid >= maxsector) {
+ DPRINTF(("Sector %d >= %d\n", sid, maxsector));
+ goto out;
+ }
+ sid = CDF_TOLE4((uint32_t)sat->sat_tab[sid]);
+ }
+ if (i == 0) {
+ DPRINTF((" none, sid: %d\n", sid));
+ goto out;
+
+ }
+ DPRINTF(("\n"));
+ return i;
+out:
+ errno = EFTYPE;
+ return (size_t)-1;
+}
+
+int
+cdf_read_long_sector_chain(const cdf_info_t *info, const cdf_header_t *h,
+ const cdf_sat_t *sat, cdf_secid_t sid, size_t len, cdf_stream_t *scn)
+{
+ size_t ss = CDF_SEC_SIZE(h), i, j;
+ ssize_t nr;
+ scn->sst_tab = NULL;
+ scn->sst_len = cdf_count_chain(sat, sid, ss);
+ scn->sst_dirlen = MAX(h->h_min_size_standard_stream, len);
+ scn->sst_ss = ss;
+
+ if (sid == CDF_SECID_END_OF_CHAIN || len == 0)
+ return cdf_zero_stream(scn);
+
+ if (scn->sst_len == (size_t)-1)
+ goto out;
+
+ scn->sst_tab = CDF_CALLOC(scn->sst_len, ss);
+ if (scn->sst_tab == NULL)
+ return cdf_zero_stream(scn);
+
+ for (j = i = 0; sid >= 0; i++, j++) {
+ if (j >= CDF_LOOP_LIMIT) {
+ DPRINTF(("Read long sector chain loop limit"));
+ goto out;
+ }
+ if (i >= scn->sst_len) {
+ DPRINTF(("Out of bounds reading long sector chain "
+ "%" SIZE_T_FORMAT "u > %" SIZE_T_FORMAT "u\n", i,
+ scn->sst_len));
+ goto out;
+ }
+ if ((nr = cdf_read_sector(info, scn->sst_tab, i * ss, ss, h,
+ sid)) != (ssize_t)ss) {
+ if (i == scn->sst_len - 1 && nr > 0) {
+ /* Last sector might be truncated */
+ return 0;
+ }
+ DPRINTF(("Reading long sector chain %d", sid));
+ goto out;
+ }
+ sid = CDF_TOLE4((uint32_t)sat->sat_tab[sid]);
+ }
+ return 0;
+out:
+ errno = EFTYPE;
+ return cdf_zero_stream(scn);
+}
+
+int
+cdf_read_short_sector_chain(const cdf_header_t *h,
+ const cdf_sat_t *ssat, const cdf_stream_t *sst,
+ cdf_secid_t sid, size_t len, cdf_stream_t *scn)
+{
+ size_t ss = CDF_SHORT_SEC_SIZE(h), i, j;
+ scn->sst_tab = NULL;
+ scn->sst_len = cdf_count_chain(ssat, sid, CDF_SEC_SIZE(h));
+ scn->sst_dirlen = len;
+ scn->sst_ss = ss;
+
+ if (scn->sst_len == (size_t)-1)
+ goto out;
+
+ scn->sst_tab = CDF_CALLOC(scn->sst_len, ss);
+ if (scn->sst_tab == NULL)
+ return cdf_zero_stream(scn);
+
+ for (j = i = 0; sid >= 0; i++, j++) {
+ if (j >= CDF_LOOP_LIMIT) {
+ DPRINTF(("Read short sector chain loop limit"));
+ goto out;
+ }
+ if (i >= scn->sst_len) {
+ DPRINTF(("Out of bounds reading short sector chain "
+ "%" SIZE_T_FORMAT "u > %" SIZE_T_FORMAT "u\n",
+ i, scn->sst_len));
+ goto out;
+ }
+ if (cdf_read_short_sector(sst, scn->sst_tab, i * ss, ss, h,
+ sid) != (ssize_t)ss) {
+ DPRINTF(("Reading short sector chain %d", sid));
+ goto out;
+ }
+ sid = CDF_TOLE4((uint32_t)ssat->sat_tab[sid]);
+ }
+ return 0;
+out:
+ errno = EFTYPE;
+ return cdf_zero_stream(scn);
+}
+
+int
+cdf_read_sector_chain(const cdf_info_t *info, const cdf_header_t *h,
+ const cdf_sat_t *sat, const cdf_sat_t *ssat, const cdf_stream_t *sst,
+ cdf_secid_t sid, size_t len, cdf_stream_t *scn)
+{
+
+ if (len < h->h_min_size_standard_stream && sst->sst_tab != NULL)
+ return cdf_read_short_sector_chain(h, ssat, sst, sid, len,
+ scn);
+ else
+ return cdf_read_long_sector_chain(info, h, sat, sid, len, scn);
+}
+
+int
+cdf_read_dir(const cdf_info_t *info, const cdf_header_t *h,
+ const cdf_sat_t *sat, cdf_dir_t *dir)
+{
+ size_t i, j;
+ size_t ss = CDF_SEC_SIZE(h), ns, nd;
+ char *buf;
+ cdf_secid_t sid = h->h_secid_first_directory;
+
+ ns = cdf_count_chain(sat, sid, ss);
+ if (ns == (size_t)-1)
+ return -1;
+
+ nd = ss / CDF_DIRECTORY_SIZE;
+
+ dir->dir_len = ns * nd;
+ dir->dir_tab = CAST(cdf_directory_t *,
+ CDF_CALLOC(dir->dir_len, sizeof(dir->dir_tab[0])));
+ if (dir->dir_tab == NULL)
+ return -1;
+
+ if ((buf = CAST(char *, CDF_MALLOC(ss))) == NULL) {
+ free(dir->dir_tab);
+ return -1;
+ }
+
+ for (j = i = 0; i < ns; i++, j++) {
+ if (j >= CDF_LOOP_LIMIT) {
+ DPRINTF(("Read dir loop limit"));
+ goto out;
+ }
+ if (cdf_read_sector(info, buf, 0, ss, h, sid) != (ssize_t)ss) {
+ DPRINTF(("Reading directory sector %d", sid));
+ goto out;
+ }
+ for (j = 0; j < nd; j++) {
+ cdf_unpack_dir(&dir->dir_tab[i * nd + j],
+ &buf[j * CDF_DIRECTORY_SIZE]);
+ }
+ sid = CDF_TOLE4((uint32_t)sat->sat_tab[sid]);
+ }
+ if (NEED_SWAP)
+ for (i = 0; i < dir->dir_len; i++)
+ cdf_swap_dir(&dir->dir_tab[i]);
+ free(buf);
+ return 0;
+out:
+ free(dir->dir_tab);
+ free(buf);
+ errno = EFTYPE;
+ return -1;
+}
+
+
+int
+cdf_read_ssat(const cdf_info_t *info, const cdf_header_t *h,
+ const cdf_sat_t *sat, cdf_sat_t *ssat)
+{
+ size_t i, j;
+ size_t ss = CDF_SEC_SIZE(h);
+ cdf_secid_t sid = h->h_secid_first_sector_in_short_sat;
+
+ ssat->sat_tab = NULL;
+ ssat->sat_len = cdf_count_chain(sat, sid, ss);
+ if (ssat->sat_len == (size_t)-1)
+ goto out;
+
+ ssat->sat_tab = CAST(cdf_secid_t *, CDF_CALLOC(ssat->sat_len, ss));
+ if (ssat->sat_tab == NULL)
+ goto out1;
+
+ for (j = i = 0; sid >= 0; i++, j++) {
+ if (j >= CDF_LOOP_LIMIT) {
+ DPRINTF(("Read short sat sector loop limit"));
+ goto out;
+ }
+ if (i >= ssat->sat_len) {
+ DPRINTF(("Out of bounds reading short sector chain "
+ "%" SIZE_T_FORMAT "u > %" SIZE_T_FORMAT "u\n", i,
+ ssat->sat_len));
+ goto out;
+ }
+ if (cdf_read_sector(info, ssat->sat_tab, i * ss, ss, h, sid) !=
+ (ssize_t)ss) {
+ DPRINTF(("Reading short sat sector %d", sid));
+ goto out1;
+ }
+ sid = CDF_TOLE4((uint32_t)sat->sat_tab[sid]);
+ }
+ return 0;
+out:
+ errno = EFTYPE;
+out1:
+ free(ssat->sat_tab);
+ return -1;
+}
+
+int
+cdf_read_short_stream(const cdf_info_t *info, const cdf_header_t *h,
+ const cdf_sat_t *sat, const cdf_dir_t *dir, cdf_stream_t *scn,
+ const cdf_directory_t **root)
+{
+ size_t i;
+ const cdf_directory_t *d;
+
+ *root = NULL;
+ for (i = 0; i < dir->dir_len; i++)
+ if (dir->dir_tab[i].d_type == CDF_DIR_TYPE_ROOT_STORAGE)
+ break;
+
+ /* If the it is not there, just fake it; some docs don't have it */
+ if (i == dir->dir_len) {
+ DPRINTF(("Cannot find root storage dir\n"));
+ goto out;
+ }
+ d = &dir->dir_tab[i];
+ *root = d;
+
+ /* If the it is not there, just fake it; some docs don't have it */
+ if (d->d_stream_first_sector < 0) {
+ DPRINTF(("No first secror in dir\n"));
+ goto out;
+ }
+
+ return cdf_read_long_sector_chain(info, h, sat,
+ d->d_stream_first_sector, d->d_size, scn);
+out:
+ scn->sst_tab = NULL;
+ (void)cdf_zero_stream(scn);
+ return 0;
+}
+
+static int
+cdf_namecmp(const char *d, const uint16_t *s, size_t l)
+{
+ for (; l--; d++, s++)
+ if (*d != CDF_TOLE2(*s))
+ return (unsigned char)*d - CDF_TOLE2(*s);
+ return 0;
+}
+
+int
+cdf_read_doc_summary_info(const cdf_info_t *info, const cdf_header_t *h,
+ const cdf_sat_t *sat, const cdf_sat_t *ssat, const cdf_stream_t *sst,
+ const cdf_dir_t *dir, cdf_stream_t *scn)
+{
+ return cdf_read_user_stream(info, h, sat, ssat, sst, dir,
+ "\05DocumentSummaryInformation", scn);
+}
+
+int
+cdf_read_summary_info(const cdf_info_t *info, const cdf_header_t *h,
+ const cdf_sat_t *sat, const cdf_sat_t *ssat, const cdf_stream_t *sst,
+ const cdf_dir_t *dir, cdf_stream_t *scn)
+{
+ return cdf_read_user_stream(info, h, sat, ssat, sst, dir,
+ "\05SummaryInformation", scn);
+}
+
+int
+cdf_read_user_stream(const cdf_info_t *info, const cdf_header_t *h,
+ const cdf_sat_t *sat, const cdf_sat_t *ssat, const cdf_stream_t *sst,
+ const cdf_dir_t *dir, const char *name, cdf_stream_t *scn)
+{
+ const cdf_directory_t *d;
+ int i = cdf_find_stream(dir, name, CDF_DIR_TYPE_USER_STREAM);
+
+ if (i <= 0) {
+ memset(scn, 0, sizeof(*scn));
+ return -1;
+ }
+
+ d = &dir->dir_tab[i - 1];
+ return cdf_read_sector_chain(info, h, sat, ssat, sst,
+ d->d_stream_first_sector, d->d_size, scn);
+}
+
+int
+cdf_find_stream(const cdf_dir_t *dir, const char *name, int type)
+{
+ size_t i, name_len = strlen(name) + 1;
+
+ for (i = dir->dir_len; i > 0; i--)
+ if (dir->dir_tab[i - 1].d_type == type &&
+ cdf_namecmp(name, dir->dir_tab[i - 1].d_name, name_len)
+ == 0)
+ break;
+ if (i > 0)
+ return CAST(int, i);
+
+ DPRINTF(("Cannot find type %d `%s'\n", type, name));
+ errno = ESRCH;
+ return 0;
+}
+
+#define CDF_SHLEN_LIMIT (UINT32_MAX / 8)
+#define CDF_PROP_LIMIT (UINT32_MAX / (8 * sizeof(cdf_property_info_t)))
+
+static const void *
+cdf_offset(const void *p, size_t l)
+{
+ return CAST(const void *, CAST(const uint8_t *, p) + l);
+}
+
+static const uint8_t *
+cdf_get_property_info_pos(const cdf_stream_t *sst, const cdf_header_t *h,
+ const uint8_t *p, const uint8_t *e, size_t i)
+{
+ size_t tail = (i << 1) + 1;
+ size_t ofs;
+ const uint8_t *q;
+
+ if (p >= e) {
+ DPRINTF(("Past end %p < %p\n", e, p));
+ return NULL;
+ }
+ if (cdf_check_stream_offset(sst, h, p, (tail + 1) * sizeof(uint32_t),
+ __LINE__) == -1)
+ return NULL;
+ ofs = CDF_GETUINT32(p, tail);
+ q = CAST(const uint8_t *, cdf_offset(CAST(const void *, p),
+ ofs - 2 * sizeof(uint32_t)));
+
+ if (q < p) {
+ DPRINTF(("Wrapped around %p < %p\n", q, p));
+ return NULL;
+ }
+
+ if (q >= e) {
+ DPRINTF(("Ran off the end %p >= %p\n", q, e));
+ return NULL;
+ }
+ return q;
+}
+
+static cdf_property_info_t *
+cdf_grow_info(cdf_property_info_t **info, size_t *maxcount, size_t incr)
+{
+ cdf_property_info_t *inp;
+ size_t newcount = *maxcount + incr;
+
+ if (newcount > CDF_PROP_LIMIT) {
+ DPRINTF(("exceeded property limit %zu > %zu\n",
+ newcount, CDF_PROP_LIMIT));
+ goto out;
+ }
+ inp = CAST(cdf_property_info_t *,
+ CDF_REALLOC(*info, newcount * sizeof(*inp)));
+ if (inp == NULL)
+ goto out;
+
+ *info = inp;
+ *maxcount = newcount;
+ return inp;
+out:
+ free(*info);
+ *maxcount = 0;
+ *info = NULL;
+ return NULL;
+}
+
+static int
+cdf_copy_info(cdf_property_info_t *inp, const void *p, const void *e,
+ size_t len)
+{
+ if (inp->pi_type & CDF_VECTOR)
+ return 0;
+
+ if ((size_t)(CAST(const char *, e) - CAST(const char *, p)) < len)
+ return 0;
+
+ (void)memcpy(&inp->pi_val, p, len);
+
+ switch (len) {
+ case 2:
+ inp->pi_u16 = CDF_TOLE2(inp->pi_u16);
+ break;
+ case 4:
+ inp->pi_u32 = CDF_TOLE4(inp->pi_u32);
+ break;
+ case 8:
+ inp->pi_u64 = CDF_TOLE8(inp->pi_u64);
+ break;
+ default:
+ abort();
+ }
+ return 1;
+}
+
+int
+cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h,
+ uint32_t offs, cdf_property_info_t **info, size_t *count, size_t *maxcount)
+{
+ const cdf_section_header_t *shp;
+ cdf_section_header_t sh;
+ const uint8_t *p, *q, *e;
+ size_t i, o4, nelements, j, slen, left;
+ cdf_property_info_t *inp;
+
+ if (offs > UINT32_MAX / 4) {
+ errno = EFTYPE;
+ goto out;
+ }
+ shp = CAST(const cdf_section_header_t *,
+ cdf_offset(sst->sst_tab, offs));
+ if (cdf_check_stream_offset(sst, h, shp, sizeof(*shp), __LINE__) == -1)
+ goto out;
+ sh.sh_len = CDF_TOLE4(shp->sh_len);
+ if (sh.sh_len > CDF_SHLEN_LIMIT) {
+ errno = EFTYPE;
+ goto out;
+ }
+
+ if (cdf_check_stream_offset(sst, h, shp, sh.sh_len, __LINE__) == -1)
+ goto out;
+
+ sh.sh_properties = CDF_TOLE4(shp->sh_properties);
+ DPRINTF(("section len: %u properties %u\n", sh.sh_len,
+ sh.sh_properties));
+ if (sh.sh_properties > CDF_PROP_LIMIT)
+ goto out;
+ inp = cdf_grow_info(info, maxcount, sh.sh_properties);
+ if (inp == NULL)
+ goto out;
+ inp += *count;
+ *count += sh.sh_properties;
+ p = CAST(const uint8_t *, cdf_offset(sst->sst_tab, offs + sizeof(sh)));
+ e = CAST(const uint8_t *, cdf_offset(shp, sh.sh_len));
+ if (p >= e || cdf_check_stream_offset(sst, h, e, 0, __LINE__) == -1)
+ goto out;
+
+ for (i = 0; i < sh.sh_properties; i++) {
+ if ((q = cdf_get_property_info_pos(sst, h, p, e, i)) == NULL)
+ goto out;
+ inp[i].pi_id = CDF_GETUINT32(p, i << 1);
+ left = CAST(size_t, e - q);
+ if (left < sizeof(uint32_t)) {
+ DPRINTF(("short info (no type)_\n"));
+ goto out;
+ }
+ inp[i].pi_type = CDF_GETUINT32(q, 0);
+ DPRINTF(("%" SIZE_T_FORMAT "u) id=%#x type=%#x offs=%#tx,%#x\n",
+ i, inp[i].pi_id, inp[i].pi_type, q - p, offs));
+ if (inp[i].pi_type & CDF_VECTOR) {
+ if (left < sizeof(uint32_t) * 2) {
+ DPRINTF(("missing CDF_VECTOR length\n"));
+ goto out;
+ }
+ nelements = CDF_GETUINT32(q, 1);
+ if (nelements == 0) {
+ DPRINTF(("CDF_VECTOR with nelements == 0\n"));
+ goto out;
+ }
+ slen = 2;
+ } else {
+ nelements = 1;
+ slen = 1;
+ }
+ o4 = slen * sizeof(uint32_t);
+ if (inp[i].pi_type & (CDF_ARRAY|CDF_BYREF|CDF_RESERVED))
+ goto unknown;
+ switch (inp[i].pi_type & CDF_TYPEMASK) {
+ case CDF_NULL:
+ case CDF_EMPTY:
+ break;
+ case CDF_SIGNED16:
+ if (!cdf_copy_info(&inp[i], &q[o4], e, sizeof(int16_t)))
+ goto unknown;
+ break;
+ case CDF_SIGNED32:
+ case CDF_BOOL:
+ case CDF_UNSIGNED32:
+ case CDF_FLOAT:
+ if (!cdf_copy_info(&inp[i], &q[o4], e, sizeof(int32_t)))
+ goto unknown;
+ break;
+ case CDF_SIGNED64:
+ case CDF_UNSIGNED64:
+ case CDF_DOUBLE:
+ case CDF_FILETIME:
+ if (!cdf_copy_info(&inp[i], &q[o4], e, sizeof(int64_t)))
+ goto unknown;
+ break;
+ case CDF_LENGTH32_STRING:
+ case CDF_LENGTH32_WSTRING:
+ if (nelements > 1) {
+ size_t nelem = inp - *info;
+ inp = cdf_grow_info(info, maxcount, nelements);
+ if (inp == NULL)
+ goto out;
+ inp += nelem;
+ }
+ DPRINTF(("nelements = %" SIZE_T_FORMAT "u\n",
+ nelements));
+ for (j = 0; j < nelements && i < sh.sh_properties;
+ j++, i++)
+ {
+ uint32_t l;
+
+ if (o4 + sizeof(uint32_t) > left)
+ goto out;
+
+ l = CDF_GETUINT32(q, slen);
+ o4 += sizeof(uint32_t);
+ if (o4 + l > left)
+ goto out;
+
+ inp[i].pi_str.s_len = l;
+ inp[i].pi_str.s_buf = CAST(const char *,
+ CAST(const void *, &q[o4]));
+
+ DPRINTF(("o=%zu l=%d(%" SIZE_T_FORMAT
+ "u), t=%zu s=%s\n", o4, l,
+ CDF_ROUND(l, sizeof(l)), left,
+ inp[i].pi_str.s_buf));
+
+ if (l & 1)
+ l++;
+
+ slen += l >> 1;
+ o4 = slen * sizeof(uint32_t);
+ }
+ i--;
+ break;
+ case CDF_CLIPBOARD:
+ if (inp[i].pi_type & CDF_VECTOR)
+ goto unknown;
+ break;
+ default:
+ unknown:
+ memset(&inp[i].pi_val, 0, sizeof(inp[i].pi_val));
+ DPRINTF(("Don't know how to deal with %#x\n",
+ inp[i].pi_type));
+ break;
+ }
+ }
+ return 0;
+out:
+ free(*info);
+ *info = NULL;
+ *count = 0;
+ *maxcount = 0;
+ errno = EFTYPE;
+ return -1;
+}
+
+int
+cdf_unpack_summary_info(const cdf_stream_t *sst, const cdf_header_t *h,
+ cdf_summary_info_header_t *ssi, cdf_property_info_t **info, size_t *count)
+{
+ size_t maxcount;
+ const cdf_summary_info_header_t *si =
+ CAST(const cdf_summary_info_header_t *, sst->sst_tab);
+ const cdf_section_declaration_t *sd =
+ CAST(const cdf_section_declaration_t *, (const void *)
+ ((const char *)sst->sst_tab + CDF_SECTION_DECLARATION_OFFSET));
+
+ if (cdf_check_stream_offset(sst, h, si, sizeof(*si), __LINE__) == -1 ||
+ cdf_check_stream_offset(sst, h, sd, sizeof(*sd), __LINE__) == -1)
+ return -1;
+ ssi->si_byte_order = CDF_TOLE2(si->si_byte_order);
+ ssi->si_os_version = CDF_TOLE2(si->si_os_version);
+ ssi->si_os = CDF_TOLE2(si->si_os);
+ ssi->si_class = si->si_class;
+ cdf_swap_class(&ssi->si_class);
+ ssi->si_count = CDF_TOLE4(si->si_count);
+ *count = 0;
+ maxcount = 0;
+ *info = NULL;
+ if (cdf_read_property_info(sst, h, CDF_TOLE4(sd->sd_offset), info,
+ count, &maxcount) == -1)
+ return -1;
+ return 0;
+}
+
+
+#define extract_catalog_field(t, f, l) \
+ if (b + l + sizeof(cep->f) > eb) { \
+ cep->ce_namlen = 0; \
+ break; \
+ } \
+ memcpy(&cep->f, b + (l), sizeof(cep->f)); \
+ ce[i].f = CAST(t, CDF_TOLE(cep->f))
+
+int
+cdf_unpack_catalog(const cdf_header_t *h, const cdf_stream_t *sst,
+ cdf_catalog_t **cat)
+{
+ size_t ss = cdf_check_stream(sst, h);
+ const char *b = CAST(const char *, sst->sst_tab);
+ const char *nb, *eb = b + ss * sst->sst_len;
+ size_t nr, i, j, k;
+ cdf_catalog_entry_t *ce;
+ uint16_t reclen;
+ const uint16_t *np;
+
+ for (nr = 0;; nr++) {
+ memcpy(&reclen, b, sizeof(reclen));
+ reclen = CDF_TOLE2(reclen);
+ if (reclen == 0)
+ break;
+ b += reclen;
+ if (b > eb)
+ break;
+ }
+ if (nr == 0)
+ return -1;
+ nr--;
+ *cat = CAST(cdf_catalog_t *,
+ CDF_MALLOC(sizeof(cdf_catalog_t) + nr * sizeof(*ce)));
+ if (*cat == NULL)
+ return -1;
+ ce = (*cat)->cat_e;
+ memset(ce, 0, nr * sizeof(*ce));
+ b = CAST(const char *, sst->sst_tab);
+ for (j = i = 0; i < nr; b += reclen) {
+ cdf_catalog_entry_t *cep = &ce[j];
+ uint16_t rlen;
+
+ extract_catalog_field(uint16_t, ce_namlen, 0);
+ extract_catalog_field(uint16_t, ce_num, 4);
+ extract_catalog_field(uint64_t, ce_timestamp, 8);
+ reclen = cep->ce_namlen;
+
+ if (reclen < 14) {
+ cep->ce_namlen = 0;
+ continue;
+ }
+
+ cep->ce_namlen = __arraycount(cep->ce_name) - 1;
+ rlen = reclen - 14;
+ if (cep->ce_namlen > rlen)
+ cep->ce_namlen = rlen;
+
+ np = CAST(const uint16_t *, CAST(const void *, (b + 16)));
+ nb = CAST(const char *, CAST(const void *,
+ (np + cep->ce_namlen)));
+ if (nb > eb) {
+ cep->ce_namlen = 0;
+ break;
+ }
+
+ for (k = 0; k < cep->ce_namlen; k++)
+ cep->ce_name[k] = np[k]; /* XXX: CDF_TOLE2? */
+ cep->ce_name[cep->ce_namlen] = 0;
+ j = i;
+ i++;
+ }
+ (*cat)->cat_num = j;
+ return 0;
+}
+
+int
+cdf_print_classid(char *buf, size_t buflen, const cdf_classid_t *id)
+{
+ return snprintf(buf, buflen, "%.8x-%.4x-%.4x-%.2x%.2x-"
+ "%.2x%.2x%.2x%.2x%.2x%.2x", id->cl_dword, id->cl_word[0],
+ id->cl_word[1], id->cl_two[0], id->cl_two[1], id->cl_six[0],
+ id->cl_six[1], id->cl_six[2], id->cl_six[3], id->cl_six[4],
+ id->cl_six[5]);
+}
+
+static const struct {
+ uint32_t v;
+ const char *n;
+} vn[] = {
+ { CDF_PROPERTY_CODE_PAGE, "Code page" },
+ { CDF_PROPERTY_TITLE, "Title" },
+ { CDF_PROPERTY_SUBJECT, "Subject" },
+ { CDF_PROPERTY_AUTHOR, "Author" },
+ { CDF_PROPERTY_KEYWORDS, "Keywords" },
+ { CDF_PROPERTY_COMMENTS, "Comments" },
+ { CDF_PROPERTY_TEMPLATE, "Template" },
+ { CDF_PROPERTY_LAST_SAVED_BY, "Last Saved By" },
+ { CDF_PROPERTY_REVISION_NUMBER, "Revision Number" },
+ { CDF_PROPERTY_TOTAL_EDITING_TIME, "Total Editing Time" },
+ { CDF_PROPERTY_LAST_PRINTED, "Last Printed" },
+ { CDF_PROPERTY_CREATE_TIME, "Create Time/Date" },
+ { CDF_PROPERTY_LAST_SAVED_TIME, "Last Saved Time/Date" },
+ { CDF_PROPERTY_NUMBER_OF_PAGES, "Number of Pages" },
+ { CDF_PROPERTY_NUMBER_OF_WORDS, "Number of Words" },
+ { CDF_PROPERTY_NUMBER_OF_CHARACTERS, "Number of Characters" },
+ { CDF_PROPERTY_THUMBNAIL, "Thumbnail" },
+ { CDF_PROPERTY_NAME_OF_APPLICATION, "Name of Creating Application" },
+ { CDF_PROPERTY_SECURITY, "Security" },
+ { CDF_PROPERTY_LOCALE_ID, "Locale ID" },
+};
+
+int
+cdf_print_property_name(char *buf, size_t bufsiz, uint32_t p)
+{
+ size_t i;
+
+ for (i = 0; i < __arraycount(vn); i++)
+ if (vn[i].v == p)
+ return snprintf(buf, bufsiz, "%s", vn[i].n);
+ return snprintf(buf, bufsiz, "%#x", p);
+}
+
+int
+cdf_print_elapsed_time(char *buf, size_t bufsiz, cdf_timestamp_t ts)
+{
+ int len = 0;
+ int days, hours, mins, secs;
+
+ ts /= CDF_TIME_PREC;
+ secs = (int)(ts % 60);
+ ts /= 60;
+ mins = (int)(ts % 60);
+ ts /= 60;
+ hours = (int)(ts % 24);
+ ts /= 24;
+ days = (int)ts;
+
+ if (days) {
+ len += snprintf(buf + len, bufsiz - len, "%dd+", days);
+ if ((size_t)len >= bufsiz)
+ return len;
+ }
+
+ if (days || hours) {
+ len += snprintf(buf + len, bufsiz - len, "%.2d:", hours);
+ if ((size_t)len >= bufsiz)
+ return len;
+ }
+
+ len += snprintf(buf + len, bufsiz - len, "%.2d:", mins);
+ if ((size_t)len >= bufsiz)
+ return len;
+
+ len += snprintf(buf + len, bufsiz - len, "%.2d", secs);
+ return len;
+}
+
+char *
+cdf_u16tos8(char *buf, size_t len, const uint16_t *p)
+{
+ size_t i;
+ for (i = 0; i < len && p[i]; i++)
+ buf[i] = (char)p[i];
+ buf[i] = '\0';
+ return buf;
+}
+
+#ifdef CDF_DEBUG
+void
+cdf_dump_header(const cdf_header_t *h)
+{
+ size_t i;
+
+#define DUMP(a, b) (void)fprintf(stderr, "%40.40s = " a "\n", # b, h->h_ ## b)
+#define DUMP2(a, b) (void)fprintf(stderr, "%40.40s = " a " (" a ")\n", # b, \
+ h->h_ ## b, 1 << h->h_ ## b)
+ DUMP("%d", revision);
+ DUMP("%d", version);
+ DUMP("%#x", byte_order);
+ DUMP2("%d", sec_size_p2);
+ DUMP2("%d", short_sec_size_p2);
+ DUMP("%d", num_sectors_in_sat);
+ DUMP("%d", secid_first_directory);
+ DUMP("%d", min_size_standard_stream);
+ DUMP("%d", secid_first_sector_in_short_sat);
+ DUMP("%d", num_sectors_in_short_sat);
+ DUMP("%d", secid_first_sector_in_master_sat);
+ DUMP("%d", num_sectors_in_master_sat);
+ for (i = 0; i < __arraycount(h->h_master_sat); i++) {
+ if (h->h_master_sat[i] == CDF_SECID_FREE)
+ break;
+ (void)fprintf(stderr, "%35.35s[%.3" SIZE_T_FORMAT "u] = %d\n",
+ "master_sat", i, h->h_master_sat[i]);
+ }
+}
+
+void
+cdf_dump_sat(const char *prefix, const cdf_sat_t *sat, size_t size)
+{
+ size_t i, j, s = size / sizeof(cdf_secid_t);
+
+ for (i = 0; i < sat->sat_len; i++) {
+ (void)fprintf(stderr, "%s[%" SIZE_T_FORMAT "u]:\n%.6"
+ SIZE_T_FORMAT "u: ", prefix, i, i * s);
+ for (j = 0; j < s; j++) {
+ (void)fprintf(stderr, "%5d, ",
+ CDF_TOLE4(sat->sat_tab[s * i + j]));
+ if ((j + 1) % 10 == 0)
+ (void)fprintf(stderr, "\n%.6" SIZE_T_FORMAT
+ "u: ", i * s + j + 1);
+ }
+ (void)fprintf(stderr, "\n");
+ }
+}
+
+void
+cdf_dump(const void *v, size_t len)
+{
+ size_t i, j;
+ const unsigned char *p = v;
+ char abuf[16];
+
+ (void)fprintf(stderr, "%.4x: ", 0);
+ for (i = 0, j = 0; i < len; i++, p++) {
+ (void)fprintf(stderr, "%.2x ", *p);
+ abuf[j++] = isprint(*p) ? *p : '.';
+ if (j == 16) {
+ j = 0;
+ abuf[15] = '\0';
+ (void)fprintf(stderr, "%s\n%.4" SIZE_T_FORMAT "x: ",
+ abuf, i + 1);
+ }
+ }
+ (void)fprintf(stderr, "\n");
+}
+
+void
+cdf_dump_stream(const cdf_stream_t *sst)
+{
+ size_t ss = sst->sst_ss;
+ cdf_dump(sst->sst_tab, ss * sst->sst_len);
+}
+
+void
+cdf_dump_dir(const cdf_info_t *info, const cdf_header_t *h,
+ const cdf_sat_t *sat, const cdf_sat_t *ssat, const cdf_stream_t *sst,
+ const cdf_dir_t *dir)
+{
+ size_t i, j;
+ cdf_directory_t *d;
+ char name[__arraycount(d->d_name)];
+ cdf_stream_t scn;
+ struct timespec ts;
+
+ static const char *types[] = { "empty", "user storage",
+ "user stream", "lockbytes", "property", "root storage" };
+
+ for (i = 0; i < dir->dir_len; i++) {
+ char buf[26];
+ d = &dir->dir_tab[i];
+ for (j = 0; j < sizeof(name); j++)
+ name[j] = (char)CDF_TOLE2(d->d_name[j]);
+ (void)fprintf(stderr, "Directory %" SIZE_T_FORMAT "u: %s\n",
+ i, name);
+ if (d->d_type < __arraycount(types))
+ (void)fprintf(stderr, "Type: %s\n", types[d->d_type]);
+ else
+ (void)fprintf(stderr, "Type: %d\n", d->d_type);
+ (void)fprintf(stderr, "Color: %s\n",
+ d->d_color ? "black" : "red");
+ (void)fprintf(stderr, "Left child: %d\n", d->d_left_child);
+ (void)fprintf(stderr, "Right child: %d\n", d->d_right_child);
+ (void)fprintf(stderr, "Flags: %#x\n", d->d_flags);
+ cdf_timestamp_to_timespec(&ts, d->d_created);
+ (void)fprintf(stderr, "Created %s", cdf_ctime(&ts.tv_sec, buf));
+ cdf_timestamp_to_timespec(&ts, d->d_modified);
+ (void)fprintf(stderr, "Modified %s",
+ cdf_ctime(&ts.tv_sec, buf));
+ (void)fprintf(stderr, "Stream %d\n", d->d_stream_first_sector);
+ (void)fprintf(stderr, "Size %d\n", d->d_size);
+ switch (d->d_type) {
+ case CDF_DIR_TYPE_USER_STORAGE:
+ (void)fprintf(stderr, "Storage: %d\n", d->d_storage);
+ break;
+ case CDF_DIR_TYPE_USER_STREAM:
+ if (sst == NULL)
+ break;
+ if (cdf_read_sector_chain(info, h, sat, ssat, sst,
+ d->d_stream_first_sector, d->d_size, &scn) == -1) {
+ warn("Can't read stream for %s at %d len %d",
+ name, d->d_stream_first_sector, d->d_size);
+ break;
+ }
+ cdf_dump_stream(&scn);
+ free(scn.sst_tab);
+ break;
+ default:
+ break;
+ }
+
+ }
+}
+
+void
+cdf_dump_property_info(const cdf_property_info_t *info, size_t count)
+{
+ cdf_timestamp_t tp;
+ struct timespec ts;
+ char buf[64];
+ size_t i, j;
+
+ for (i = 0; i < count; i++) {
+ cdf_print_property_name(buf, sizeof(buf), info[i].pi_id);
+ (void)fprintf(stderr, "%" SIZE_T_FORMAT "u) %s: ", i, buf);
+ switch (info[i].pi_type) {
+ case CDF_NULL:
+ break;
+ case CDF_SIGNED16:
+ (void)fprintf(stderr, "signed 16 [%hd]\n",
+ info[i].pi_s16);
+ break;
+ case CDF_SIGNED32:
+ (void)fprintf(stderr, "signed 32 [%d]\n",
+ info[i].pi_s32);
+ break;
+ case CDF_UNSIGNED32:
+ (void)fprintf(stderr, "unsigned 32 [%u]\n",
+ info[i].pi_u32);
+ break;
+ case CDF_FLOAT:
+ (void)fprintf(stderr, "float [%g]\n",
+ info[i].pi_f);
+ break;
+ case CDF_DOUBLE:
+ (void)fprintf(stderr, "double [%g]\n",
+ info[i].pi_d);
+ break;
+ case CDF_LENGTH32_STRING:
+ (void)fprintf(stderr, "string %u [%.*s]\n",
+ info[i].pi_str.s_len,
+ info[i].pi_str.s_len, info[i].pi_str.s_buf);
+ break;
+ case CDF_LENGTH32_WSTRING:
+ (void)fprintf(stderr, "string %u [",
+ info[i].pi_str.s_len);
+ for (j = 0; j < info[i].pi_str.s_len - 1; j++)
+ (void)fputc(info[i].pi_str.s_buf[j << 1], stderr);
+ (void)fprintf(stderr, "]\n");
+ break;
+ case CDF_FILETIME:
+ tp = info[i].pi_tp;
+ if (tp < 1000000000000000LL) {
+ cdf_print_elapsed_time(buf, sizeof(buf), tp);
+ (void)fprintf(stderr, "timestamp %s\n", buf);
+ } else {
+ char tbuf[26];
+ cdf_timestamp_to_timespec(&ts, tp);
+ (void)fprintf(stderr, "timestamp %s",
+ cdf_ctime(&ts.tv_sec, tbuf));
+ }
+ break;
+ case CDF_CLIPBOARD:
+ (void)fprintf(stderr, "CLIPBOARD %u\n", info[i].pi_u32);
+ break;
+ default:
+ DPRINTF(("Don't know how to deal with %#x\n",
+ info[i].pi_type));
+ break;
+ }
+ }
+}
+
+
+void
+cdf_dump_summary_info(const cdf_header_t *h, const cdf_stream_t *sst)
+{
+ char buf[128];
+ cdf_summary_info_header_t ssi;
+ cdf_property_info_t *info;
+ size_t count;
+
+ (void)&h;
+ if (cdf_unpack_summary_info(sst, h, &ssi, &info, &count) == -1)
+ return;
+ (void)fprintf(stderr, "Endian: %#x\n", ssi.si_byte_order);
+ (void)fprintf(stderr, "Os Version %d.%d\n", ssi.si_os_version & 0xff,
+ ssi.si_os_version >> 8);
+ (void)fprintf(stderr, "Os %d\n", ssi.si_os);
+ cdf_print_classid(buf, sizeof(buf), &ssi.si_class);
+ (void)fprintf(stderr, "Class %s\n", buf);
+ (void)fprintf(stderr, "Count %d\n", ssi.si_count);
+ cdf_dump_property_info(info, count);
+ free(info);
+}
+
+
+void
+cdf_dump_catalog(const cdf_header_t *h, const cdf_stream_t *sst)
+{
+ cdf_catalog_t *cat;
+ cdf_unpack_catalog(h, sst, &cat);
+ const cdf_catalog_entry_t *ce = cat->cat_e;
+ struct timespec ts;
+ char tbuf[64], sbuf[256];
+ size_t i;
+
+ printf("Catalog:\n");
+ for (i = 0; i < cat->cat_num; i++) {
+ cdf_timestamp_to_timespec(&ts, ce[i].ce_timestamp);
+ printf("\t%d %s %s", ce[i].ce_num,
+ cdf_u16tos8(sbuf, ce[i].ce_namlen, ce[i].ce_name),
+ cdf_ctime(&ts.tv_sec, tbuf));
+ }
+ free(cat);
+}
+
+#endif
+
+#ifdef TEST
+int
+main(int argc, char *argv[])
+{
+ int i;
+ cdf_header_t h;
+ cdf_sat_t sat, ssat;
+ cdf_stream_t sst, scn;
+ cdf_dir_t dir;
+ cdf_info_t info;
+ const cdf_directory_t *root;
+#ifdef __linux__
+#define getprogname() __progname
+ extern char *__progname;
+#endif
+ if (argc < 2) {
+ (void)fprintf(stderr, "Usage: %s <filename>\n", getprogname());
+ return -1;
+ }
+
+ info.i_buf = NULL;
+ info.i_len = 0;
+ for (i = 1; i < argc; i++) {
+ if ((info.i_fd = open(argv[1], O_RDONLY)) == -1)
+ err(1, "Cannot open `%s'", argv[1]);
+
+ if (cdf_read_header(&info, &h) == -1)
+ err(1, "Cannot read header");
+#ifdef CDF_DEBUG
+ cdf_dump_header(&h);
+#endif
+
+ if (cdf_read_sat(&info, &h, &sat) == -1)
+ err(1, "Cannot read sat");
+#ifdef CDF_DEBUG
+ cdf_dump_sat("SAT", &sat, CDF_SEC_SIZE(&h));
+#endif
+
+ if (cdf_read_ssat(&info, &h, &sat, &ssat) == -1)
+ err(1, "Cannot read ssat");
+#ifdef CDF_DEBUG
+ cdf_dump_sat("SSAT", &ssat, CDF_SHORT_SEC_SIZE(&h));
+#endif
+
+ if (cdf_read_dir(&info, &h, &sat, &dir) == -1)
+ err(1, "Cannot read dir");
+
+ if (cdf_read_short_stream(&info, &h, &sat, &dir, &sst, &root)
+ == -1)
+ err(1, "Cannot read short stream");
+#ifdef CDF_DEBUG
+ cdf_dump_stream(&sst);
+#endif
+
+#ifdef CDF_DEBUG
+ cdf_dump_dir(&info, &h, &sat, &ssat, &sst, &dir);
+#endif
+
+
+ if (cdf_read_summary_info(&info, &h, &sat, &ssat, &sst, &dir,
+ &scn) == -1)
+ warn("Cannot read summary info");
+#ifdef CDF_DEBUG
+ else
+ cdf_dump_summary_info(&h, &scn);
+#endif
+ if (cdf_read_user_stream(&info, &h, &sat, &ssat, &sst,
+ &dir, "Catalog", &scn) == -1)
+ warn("Cannot read catalog");
+#ifdef CDF_DEBUG
+ else
+ cdf_dump_catalog(&h, &scn);
+#endif
+
+ (void)close(info.i_fd);
+ }
+
+ return 0;
+}
+#endif
diff --git a/node_modules/mmmagic/deps/libmagic/src/cdf.h b/node_modules/mmmagic/deps/libmagic/src/cdf.h
new file mode 100644
index 0000000..f2df830
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/cdf.h
@@ -0,0 +1,352 @@
+/*-
+ * Copyright (c) 2008 Christos Zoulas
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * Parse Composite Document Files, the format used in Microsoft Office
+ * document files before they switched to zipped XML.
+ * Info from: http://sc.openoffice.org/compdocfileformat.pdf
+ *
+ * N.B. This is the "Composite Document File" format, and not the
+ * "Compound Document Format", nor the "Channel Definition Format".
+ */
+
+#ifndef _H_CDF_
+#define _H_CDF_
+
+#ifdef WIN32
+#include <winsock2.h>
+#define timespec timeval
+#define tv_nsec tv_usec
+#endif
+#ifdef __DJGPP__
+#define timespec timeval
+#define tv_nsec tv_usec
+#endif
+
+typedef int32_t cdf_secid_t;
+
+#define CDF_LOOP_LIMIT 10000
+
+#define CDF_SECID_NULL 0
+#define CDF_SECID_FREE -1
+#define CDF_SECID_END_OF_CHAIN -2
+#define CDF_SECID_SECTOR_ALLOCATION_TABLE -3
+#define CDF_SECID_MASTER_SECTOR_ALLOCATION_TABLE -4
+
+typedef struct {
+ uint64_t h_magic;
+#define CDF_MAGIC 0xE11AB1A1E011CFD0LL
+ uint64_t h_uuid[2];
+ uint16_t h_revision;
+ uint16_t h_version;
+ uint16_t h_byte_order;
+ uint16_t h_sec_size_p2;
+ uint16_t h_short_sec_size_p2;
+ uint8_t h_unused0[10];
+ uint32_t h_num_sectors_in_sat;
+ uint32_t h_secid_first_directory;
+ uint8_t h_unused1[4];
+ uint32_t h_min_size_standard_stream;
+ cdf_secid_t h_secid_first_sector_in_short_sat;
+ uint32_t h_num_sectors_in_short_sat;
+ cdf_secid_t h_secid_first_sector_in_master_sat;
+ uint32_t h_num_sectors_in_master_sat;
+ cdf_secid_t h_master_sat[436/4];
+} cdf_header_t;
+
+#define CDF_SEC_SIZE(h) ((size_t)(1 << (h)->h_sec_size_p2))
+#define CDF_SEC_POS(h, secid) (CDF_SEC_SIZE(h) + (secid) * CDF_SEC_SIZE(h))
+#define CDF_SHORT_SEC_SIZE(h) ((size_t)(1 << (h)->h_short_sec_size_p2))
+#define CDF_SHORT_SEC_POS(h, secid) ((secid) * CDF_SHORT_SEC_SIZE(h))
+
+typedef int32_t cdf_dirid_t;
+#define CDF_DIRID_NULL -1
+
+typedef int64_t cdf_timestamp_t;
+#define CDF_BASE_YEAR 1601
+#define CDF_TIME_PREC 10000000
+
+typedef struct {
+ uint16_t d_name[32];
+ uint16_t d_namelen;
+ uint8_t d_type;
+#define CDF_DIR_TYPE_EMPTY 0
+#define CDF_DIR_TYPE_USER_STORAGE 1
+#define CDF_DIR_TYPE_USER_STREAM 2
+#define CDF_DIR_TYPE_LOCKBYTES 3
+#define CDF_DIR_TYPE_PROPERTY 4
+#define CDF_DIR_TYPE_ROOT_STORAGE 5
+ uint8_t d_color;
+#define CDF_DIR_COLOR_READ 0
+#define CDF_DIR_COLOR_BLACK 1
+ cdf_dirid_t d_left_child;
+ cdf_dirid_t d_right_child;
+ cdf_dirid_t d_storage;
+ uint64_t d_storage_uuid[2];
+ uint32_t d_flags;
+ cdf_timestamp_t d_created;
+ cdf_timestamp_t d_modified;
+ cdf_secid_t d_stream_first_sector;
+ uint32_t d_size;
+ uint32_t d_unused0;
+} cdf_directory_t;
+
+#define CDF_DIRECTORY_SIZE 128
+
+typedef struct {
+ cdf_secid_t *sat_tab;
+ size_t sat_len;
+} cdf_sat_t;
+
+typedef struct {
+ cdf_directory_t *dir_tab;
+ size_t dir_len;
+} cdf_dir_t;
+
+typedef struct {
+ void *sst_tab;
+ size_t sst_len; /* Number of sectors */
+ size_t sst_dirlen; /* Directory sector size */
+ size_t sst_ss; /* Sector size */
+} cdf_stream_t;
+
+typedef struct {
+ uint32_t cl_dword;
+ uint16_t cl_word[2];
+ uint8_t cl_two[2];
+ uint8_t cl_six[6];
+} cdf_classid_t;
+
+typedef struct {
+ uint16_t si_byte_order;
+ uint16_t si_zero;
+ uint16_t si_os_version;
+ uint16_t si_os;
+ cdf_classid_t si_class;
+ uint32_t si_count;
+} cdf_summary_info_header_t;
+
+#define CDF_SECTION_DECLARATION_OFFSET 0x1c
+
+typedef struct {
+ cdf_classid_t sd_class;
+ uint32_t sd_offset;
+} cdf_section_declaration_t;
+
+typedef struct {
+ uint32_t sh_len;
+ uint32_t sh_properties;
+} cdf_section_header_t;
+
+typedef struct {
+ uint32_t pi_id;
+ uint32_t pi_type;
+ union {
+ uint16_t _pi_u16;
+ int16_t _pi_s16;
+ uint32_t _pi_u32;
+ int32_t _pi_s32;
+ uint64_t _pi_u64;
+ int64_t _pi_s64;
+ cdf_timestamp_t _pi_tp;
+ float _pi_f;
+ double _pi_d;
+ struct {
+ uint32_t s_len;
+ const char *s_buf;
+ } _pi_str;
+ } pi_val;
+#define pi_u64 pi_val._pi_u64
+#define pi_s64 pi_val._pi_s64
+#define pi_u32 pi_val._pi_u32
+#define pi_s32 pi_val._pi_s32
+#define pi_u16 pi_val._pi_u16
+#define pi_s16 pi_val._pi_s16
+#define pi_f pi_val._pi_f
+#define pi_d pi_val._pi_d
+#define pi_tp pi_val._pi_tp
+#define pi_str pi_val._pi_str
+} cdf_property_info_t;
+
+#define CDF_ROUND(val, by) (((val) + (by) - 1) & ~((by) - 1))
+
+/* Variant type definitions */
+#define CDF_EMPTY 0x00000000
+#define CDF_NULL 0x00000001
+#define CDF_SIGNED16 0x00000002
+#define CDF_SIGNED32 0x00000003
+#define CDF_FLOAT 0x00000004
+#define CDF_DOUBLE 0x00000005
+#define CDF_CY 0x00000006
+#define CDF_DATE 0x00000007
+#define CDF_BSTR 0x00000008
+#define CDF_DISPATCH 0x00000009
+#define CDF_ERROR 0x0000000a
+#define CDF_BOOL 0x0000000b
+#define CDF_VARIANT 0x0000000c
+#define CDF_UNKNOWN 0x0000000d
+#define CDF_DECIMAL 0x0000000e
+#define CDF_SIGNED8 0x00000010
+#define CDF_UNSIGNED8 0x00000011
+#define CDF_UNSIGNED16 0x00000012
+#define CDF_UNSIGNED32 0x00000013
+#define CDF_SIGNED64 0x00000014
+#define CDF_UNSIGNED64 0x00000015
+#define CDF_INT 0x00000016
+#define CDF_UINT 0x00000017
+#define CDF_VOID 0x00000018
+#define CDF_HRESULT 0x00000019
+#define CDF_PTR 0x0000001a
+#define CDF_SAFEARRAY 0x0000001b
+#define CDF_CARRAY 0x0000001c
+#define CDF_USERDEFINED 0x0000001d
+#define CDF_LENGTH32_STRING 0x0000001e
+#define CDF_LENGTH32_WSTRING 0x0000001f
+#define CDF_FILETIME 0x00000040
+#define CDF_BLOB 0x00000041
+#define CDF_STREAM 0x00000042
+#define CDF_STORAGE 0x00000043
+#define CDF_STREAMED_OBJECT 0x00000044
+#define CDF_STORED_OBJECT 0x00000045
+#define CDF_BLOB_OBJECT 0x00000046
+#define CDF_CLIPBOARD 0x00000047
+#define CDF_CLSID 0x00000048
+#define CDF_VECTOR 0x00001000
+#define CDF_ARRAY 0x00002000
+#define CDF_BYREF 0x00004000
+#define CDF_RESERVED 0x00008000
+#define CDF_ILLEGAL 0x0000ffff
+#define CDF_ILLEGALMASKED 0x00000fff
+#define CDF_TYPEMASK 0x00000fff
+
+#define CDF_PROPERTY_CODE_PAGE 0x00000001
+#define CDF_PROPERTY_TITLE 0x00000002
+#define CDF_PROPERTY_SUBJECT 0x00000003
+#define CDF_PROPERTY_AUTHOR 0x00000004
+#define CDF_PROPERTY_KEYWORDS 0x00000005
+#define CDF_PROPERTY_COMMENTS 0x00000006
+#define CDF_PROPERTY_TEMPLATE 0x00000007
+#define CDF_PROPERTY_LAST_SAVED_BY 0x00000008
+#define CDF_PROPERTY_REVISION_NUMBER 0x00000009
+#define CDF_PROPERTY_TOTAL_EDITING_TIME 0x0000000a
+#define CDF_PROPERTY_LAST_PRINTED 0X0000000b
+#define CDF_PROPERTY_CREATE_TIME 0x0000000c
+#define CDF_PROPERTY_LAST_SAVED_TIME 0x0000000d
+#define CDF_PROPERTY_NUMBER_OF_PAGES 0x0000000e
+#define CDF_PROPERTY_NUMBER_OF_WORDS 0x0000000f
+#define CDF_PROPERTY_NUMBER_OF_CHARACTERS 0x00000010
+#define CDF_PROPERTY_THUMBNAIL 0x00000011
+#define CDF_PROPERTY_NAME_OF_APPLICATION 0x00000012
+#define CDF_PROPERTY_SECURITY 0x00000013
+#define CDF_PROPERTY_LOCALE_ID 0x80000000
+
+typedef struct {
+ int i_fd;
+ const unsigned char *i_buf;
+ size_t i_len;
+} cdf_info_t;
+
+
+typedef struct {
+ uint16_t ce_namlen;
+ uint32_t ce_num;
+ uint64_t ce_timestamp;
+ uint16_t ce_name[256];
+} cdf_catalog_entry_t;
+
+typedef struct {
+ size_t cat_num;
+ cdf_catalog_entry_t cat_e[1];
+} cdf_catalog_t;
+
+struct timespec;
+int cdf_timestamp_to_timespec(struct timespec *, cdf_timestamp_t);
+int cdf_timespec_to_timestamp(cdf_timestamp_t *, const struct timespec *);
+int cdf_read_header(const cdf_info_t *, cdf_header_t *);
+void cdf_swap_header(cdf_header_t *);
+void cdf_unpack_header(cdf_header_t *, char *);
+void cdf_swap_dir(cdf_directory_t *);
+void cdf_unpack_dir(cdf_directory_t *, char *);
+void cdf_swap_class(cdf_classid_t *);
+ssize_t cdf_read_sector(const cdf_info_t *, void *, size_t, size_t,
+ const cdf_header_t *, cdf_secid_t);
+ssize_t cdf_read_short_sector(const cdf_stream_t *, void *, size_t, size_t,
+ const cdf_header_t *, cdf_secid_t);
+int cdf_read_sat(const cdf_info_t *, cdf_header_t *, cdf_sat_t *);
+size_t cdf_count_chain(const cdf_sat_t *, cdf_secid_t, size_t);
+int cdf_read_long_sector_chain(const cdf_info_t *, const cdf_header_t *,
+ const cdf_sat_t *, cdf_secid_t, size_t, cdf_stream_t *);
+int cdf_read_short_sector_chain(const cdf_header_t *, const cdf_sat_t *,
+ const cdf_stream_t *, cdf_secid_t, size_t, cdf_stream_t *);
+int cdf_read_sector_chain(const cdf_info_t *, const cdf_header_t *,
+ const cdf_sat_t *, const cdf_sat_t *, const cdf_stream_t *, cdf_secid_t,
+ size_t, cdf_stream_t *);
+int cdf_read_dir(const cdf_info_t *, const cdf_header_t *, const cdf_sat_t *,
+ cdf_dir_t *);
+int cdf_read_ssat(const cdf_info_t *, const cdf_header_t *, const cdf_sat_t *,
+ cdf_sat_t *);
+int cdf_read_short_stream(const cdf_info_t *, const cdf_header_t *,
+ const cdf_sat_t *, const cdf_dir_t *, cdf_stream_t *,
+ const cdf_directory_t **);
+int cdf_read_property_info(const cdf_stream_t *, const cdf_header_t *, uint32_t,
+ cdf_property_info_t **, size_t *, size_t *);
+int cdf_read_user_stream(const cdf_info_t *, const cdf_header_t *,
+ const cdf_sat_t *, const cdf_sat_t *, const cdf_stream_t *,
+ const cdf_dir_t *, const char *, cdf_stream_t *);
+int cdf_find_stream(const cdf_dir_t *, const char *, int);
+int cdf_zero_stream(cdf_stream_t *);
+int cdf_read_doc_summary_info(const cdf_info_t *, const cdf_header_t *,
+ const cdf_sat_t *, const cdf_sat_t *, const cdf_stream_t *,
+ const cdf_dir_t *, cdf_stream_t *);
+int cdf_read_summary_info(const cdf_info_t *, const cdf_header_t *,
+ const cdf_sat_t *, const cdf_sat_t *, const cdf_stream_t *,
+ const cdf_dir_t *, cdf_stream_t *);
+int cdf_unpack_summary_info(const cdf_stream_t *, const cdf_header_t *,
+ cdf_summary_info_header_t *, cdf_property_info_t **, size_t *);
+int cdf_unpack_catalog(const cdf_header_t *, const cdf_stream_t *,
+ cdf_catalog_t **);
+int cdf_print_classid(char *, size_t, const cdf_classid_t *);
+int cdf_print_property_name(char *, size_t, uint32_t);
+int cdf_print_elapsed_time(char *, size_t, cdf_timestamp_t);
+uint16_t cdf_tole2(uint16_t);
+uint32_t cdf_tole4(uint32_t);
+uint64_t cdf_tole8(uint64_t);
+char *cdf_ctime(const time_t *, char *);
+char *cdf_u16tos8(char *, size_t, const uint16_t *);
+
+#ifdef CDF_DEBUG
+void cdf_dump_header(const cdf_header_t *);
+void cdf_dump_sat(const char *, const cdf_sat_t *, size_t);
+void cdf_dump(const void *, size_t);
+void cdf_dump_stream(const cdf_stream_t *);
+void cdf_dump_dir(const cdf_info_t *, const cdf_header_t *, const cdf_sat_t *,
+ const cdf_sat_t *, const cdf_stream_t *, const cdf_dir_t *);
+void cdf_dump_property_info(const cdf_property_info_t *, size_t);
+void cdf_dump_summary_info(const cdf_header_t *, const cdf_stream_t *);
+void cdf_dump_catalog(const cdf_header_t *, const cdf_stream_t *);
+#endif
+
+
+#endif /* _H_CDF_ */
diff --git a/node_modules/mmmagic/deps/libmagic/src/cdf_time.c b/node_modules/mmmagic/deps/libmagic/src/cdf_time.c
new file mode 100644
index 0000000..2bdcd2a
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/cdf_time.c
@@ -0,0 +1,198 @@
+/*-
+ * Copyright (c) 2008 Christos Zoulas
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "file.h"
+
+#ifndef lint
+FILE_RCSID("@(#)$File: cdf_time.c,v 1.16 2017/03/29 15:57:48 christos Exp $")
+#endif
+
+#include <time.h>
+#ifdef TEST
+#include <err.h>
+#endif
+#include <string.h>
+
+#include "cdf.h"
+
+#define isleap(y) ((((y) % 4) == 0) && \
+ ((((y) % 100) != 0) || (((y) % 400) == 0)))
+
+static const int mdays[] = {
+ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
+};
+
+/*
+ * Return the number of days between jan 01 1601 and jan 01 of year.
+ */
+static int
+cdf_getdays(int year)
+{
+ int days = 0;
+ int y;
+
+ for (y = CDF_BASE_YEAR; y < year; y++)
+ days += isleap(y) + 365;
+
+ return days;
+}
+
+/*
+ * Return the day within the month
+ */
+static int
+cdf_getday(int year, int days)
+{
+ size_t m;
+
+ for (m = 0; m < sizeof(mdays) / sizeof(mdays[0]); m++) {
+ int sub = mdays[m] + (m == 1 && isleap(year));
+ if (days < sub)
+ return days;
+ days -= sub;
+ }
+ return days;
+}
+
+/*
+ * Return the 0...11 month number.
+ */
+static int
+cdf_getmonth(int year, int days)
+{
+ size_t m;
+
+ for (m = 0; m < sizeof(mdays) / sizeof(mdays[0]); m++) {
+ days -= mdays[m];
+ if (m == 1 && isleap(year))
+ days--;
+ if (days <= 0)
+ return (int)m;
+ }
+ return (int)m;
+}
+
+int
+cdf_timestamp_to_timespec(struct timespec *ts, cdf_timestamp_t t)
+{
+ struct tm tm;
+#ifdef HAVE_STRUCT_TM_TM_ZONE
+ static char UTC[] = "UTC";
+#endif
+ int rdays;
+
+ /* Unit is 100's of nanoseconds */
+ ts->tv_nsec = (t % CDF_TIME_PREC) * 100;
+
+ t /= CDF_TIME_PREC;
+ tm.tm_sec = (int)(t % 60);
+ t /= 60;
+
+ tm.tm_min = (int)(t % 60);
+ t /= 60;
+
+ tm.tm_hour = (int)(t % 24);
+ t /= 24;
+
+ /* XXX: Approx */
+ tm.tm_year = (int)(CDF_BASE_YEAR + (t / 365));
+
+ rdays = cdf_getdays(tm.tm_year);
+ t -= rdays - 1;
+ tm.tm_mday = cdf_getday(tm.tm_year, (int)t);
+ tm.tm_mon = cdf_getmonth(tm.tm_year, (int)t);
+ tm.tm_wday = 0;
+ tm.tm_yday = 0;
+ tm.tm_isdst = 0;
+#ifdef HAVE_STRUCT_TM_TM_GMTOFF
+ tm.tm_gmtoff = 0;
+#endif
+#ifdef HAVE_STRUCT_TM_TM_ZONE
+ tm.tm_zone = UTC;
+#endif
+ tm.tm_year -= 1900;
+ ts->tv_sec = mktime(&tm);
+ if (ts->tv_sec == -1) {
+ errno = EINVAL;
+ return -1;
+ }
+ return 0;
+}
+
+int
+/*ARGSUSED*/
+cdf_timespec_to_timestamp(cdf_timestamp_t *t, const struct timespec *ts)
+{
+#ifndef __lint__
+ (void)&t;
+ (void)&ts;
+#endif
+#ifdef notyet
+ struct tm tm;
+ if (gmtime_r(&ts->ts_sec, &tm) == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+ *t = (ts->ts_nsec / 100) * CDF_TIME_PREC;
+ *t = tm.tm_sec;
+ *t += tm.tm_min * 60;
+ *t += tm.tm_hour * 60 * 60;
+ *t += tm.tm_mday * 60 * 60 * 24;
+#endif
+ return 0;
+}
+
+char *
+cdf_ctime(const time_t *sec, char *buf)
+{
+ char *ptr = ctime_r(sec, buf);
+ if (ptr != NULL)
+ return buf;
+ (void)snprintf(buf, 26, "*Bad* %#16.16" INT64_T_FORMAT "x\n",
+ (long long)*sec);
+ return buf;
+}
+
+
+#ifdef TEST_TIME
+int
+main(int argc, char *argv[])
+{
+ struct timespec ts;
+ char buf[25];
+ static const cdf_timestamp_t tst = 0x01A5E403C2D59C00ULL;
+ static const char *ref = "Sat Apr 23 01:30:00 1977";
+ char *p, *q;
+
+ cdf_timestamp_to_timespec(&ts, tst);
+ p = cdf_ctime(&ts.tv_sec, buf);
+ if ((q = strchr(p, '\n')) != NULL)
+ *q = '\0';
+ if (strcmp(ref, p) != 0)
+ errx(1, "Error date %s != %s\n", ref, p);
+ return 0;
+}
+#endif
diff --git a/node_modules/mmmagic/deps/libmagic/src/compress.c b/node_modules/mmmagic/deps/libmagic/src/compress.c
new file mode 100644
index 0000000..2f789cd
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/compress.c
@@ -0,0 +1,762 @@
+/*
+ * Copyright (c) Ian F. Darwin 1986-1995.
+ * Software written by Ian F. Darwin and others;
+ * maintained 1995-present by Christos Zoulas and others.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice immediately at the beginning of the file, without modification,
+ * this list of conditions, and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+/*
+ * compress routines:
+ * zmagic() - returns 0 if not recognized, uncompresses and prints
+ * information if recognized
+ * uncompress(method, old, n, newch) - uncompress old into new,
+ * using method, return sizeof new
+ */
+#include "file.h"
+
+#ifndef lint
+FILE_RCSID("@(#)$File: compress.c,v 1.105 2017/05/25 00:13:03 christos Exp $")
+#endif
+
+#include "magic.h"
+#include <stdlib.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <string.h>
+#include <errno.h>
+#include <ctype.h>
+#include <stdarg.h>
+#ifdef HAVE_SIGNAL_H
+#include <signal.h>
+# ifndef HAVE_SIG_T
+typedef void (*sig_t)(int);
+# endif /* HAVE_SIG_T */
+#endif
+#if !defined(__MINGW32__) && !defined(WIN32)
+#include <sys/ioctl.h>
+#endif
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
+#if defined(HAVE_SYS_TIME_H)
+#include <sys/time.h>
+#endif
+#if defined(HAVE_ZLIB_H) && defined(ZLIBSUPPORT)
+#define BUILTIN_DECOMPRESS
+#include <zlib.h>
+#endif
+#ifdef DEBUG
+int tty = -1;
+#define DPRINTF(...) do { \
+ if (tty == -1) \
+ tty = open("/dev/tty", O_RDWR); \
+ if (tty == -1) \
+ abort(); \
+ dprintf(tty, __VA_ARGS__); \
+} while (/*CONSTCOND*/0)
+#else
+#define DPRINTF(...)
+#endif
+
+#ifdef ZLIBSUPPORT
+/*
+ * The following python code is not really used because ZLIBSUPPORT is only
+ * defined if we have a built-in zlib, and the built-in zlib handles that.
+ * That is not true for android where we have zlib.h and not -lz.
+ */
+static const char zlibcode[] =
+ "import sys, zlib; sys.stdout.write(zlib.decompress(sys.stdin.read()))";
+
+static const char *zlib_args[] = { "python", "-c", zlibcode, NULL };
+
+static int
+zlibcmp(const unsigned char *buf)
+{
+ unsigned short x = 1;
+ unsigned char *s = CAST(unsigned char *, CAST(void *, &x));
+
+ if ((buf[0] & 0xf) != 8 || (buf[0] & 0x80) != 0)
+ return 0;
+ if (s[0] != 1) /* endianness test */
+ x = buf[0] | (buf[1] << 8);
+ else
+ x = buf[1] | (buf[0] << 8);
+ if (x % 31)
+ return 0;
+ return 1;
+}
+#endif
+
+#define gzip_flags "-cd"
+#define lrzip_flags "-do"
+#define lzip_flags gzip_flags
+
+static const char *gzip_args[] = {
+ "gzip", gzip_flags, NULL
+};
+static const char *uncompress_args[] = {
+ "uncompress", "-c", NULL
+};
+static const char *bzip2_args[] = {
+ "bzip2", "-cd", NULL
+};
+static const char *lzip_args[] = {
+ "lzip", lzip_flags, NULL
+};
+static const char *xz_args[] = {
+ "xz", "-cd", NULL
+};
+static const char *lrzip_args[] = {
+ "lrzip", lrzip_flags, NULL
+};
+static const char *lz4_args[] = {
+ "lz4", "-cd", NULL
+};
+static const char *zstd_args[] = {
+ "zstd", "-cd", NULL
+};
+
+private const struct {
+ const void *magic;
+ size_t maglen;
+ const char **argv;
+} compr[] = {
+ { "\037\235", 2, gzip_args }, /* compressed */
+ /* Uncompress can get stuck; so use gzip first if we have it
+ * Idea from Damien Clark, thanks! */
+ { "\037\235", 2, uncompress_args }, /* compressed */
+ { "\037\213", 2, gzip_args }, /* gzipped */
+ { "\037\236", 2, gzip_args }, /* frozen */
+ { "\037\240", 2, gzip_args }, /* SCO LZH */
+ /* the standard pack utilities do not accept standard input */
+ { "\037\036", 2, gzip_args }, /* packed */
+ { "PK\3\4", 4, gzip_args }, /* pkzipped, */
+ /* ...only first file examined */
+ { "BZh", 3, bzip2_args }, /* bzip2-ed */
+ { "LZIP", 4, lzip_args }, /* lzip-ed */
+ { "\3757zXZ\0", 6, xz_args }, /* XZ Utils */
+ { "LRZI", 4, lrzip_args }, /* LRZIP */
+ { "\004\"M\030",4, lz4_args }, /* LZ4 */
+ { "\x28\xB5\x2F\xFD", 4, zstd_args }, /* zstd */
+#ifdef ZLIBSUPPORT
+ { RCAST(const void *, zlibcmp), 0, zlib_args }, /* zlib */
+#endif
+};
+
+#define OKDATA 0
+#define NODATA 1
+#define ERRDATA 2
+
+private ssize_t swrite(int, const void *, size_t);
+#if HAVE_FORK
+private size_t ncompr = sizeof(compr) / sizeof(compr[0]);
+private int uncompressbuf(int, size_t, size_t, const unsigned char *,
+ unsigned char **, size_t *);
+#ifdef BUILTIN_DECOMPRESS
+private int uncompresszlib(const unsigned char *, unsigned char **, size_t,
+ size_t *, int);
+private int uncompressgzipped(const unsigned char *, unsigned char **, size_t,
+ size_t *);
+#endif
+static int makeerror(unsigned char **, size_t *, const char *, ...)
+ __attribute__((__format__(__printf__, 3, 4)));
+private const char *methodname(size_t);
+
+protected int
+file_zmagic(struct magic_set *ms, int fd, const char *name,
+ const unsigned char *buf, size_t nbytes)
+{
+ unsigned char *newbuf = NULL;
+ size_t i, nsz;
+ char *rbuf;
+ file_pushbuf_t *pb;
+ int urv, prv, rv = 0;
+ int mime = ms->flags & MAGIC_MIME;
+#ifdef HAVE_SIGNAL_H
+ sig_t osigpipe;
+#endif
+
+ if ((ms->flags & MAGIC_COMPRESS) == 0)
+ return 0;
+
+#ifdef HAVE_SIGNAL_H
+ osigpipe = signal(SIGPIPE, SIG_IGN);
+#endif
+ for (i = 0; i < ncompr; i++) {
+ int zm;
+ if (nbytes < compr[i].maglen)
+ continue;
+#ifdef ZLIBSUPPORT
+ if (compr[i].maglen == 0)
+ zm = (RCAST(int (*)(const unsigned char *),
+ CCAST(void *, compr[i].magic)))(buf);
+ else
+#endif
+ zm = memcmp(buf, compr[i].magic, compr[i].maglen) == 0;
+
+ if (!zm)
+ continue;
+ nsz = nbytes;
+ urv = uncompressbuf(fd, ms->bytes_max, i, buf, &newbuf, &nsz);
+ DPRINTF("uncompressbuf = %d, %s, %zu\n", urv, (char *)newbuf,
+ nsz);
+ switch (urv) {
+ case OKDATA:
+ case ERRDATA:
+
+ ms->flags &= ~MAGIC_COMPRESS;
+ if (urv == ERRDATA)
+ prv = file_printf(ms, "%s ERROR: %s",
+ methodname(i), newbuf);
+ else
+ prv = file_buffer(ms, -1, name, newbuf, nsz);
+ if (prv == -1)
+ goto error;
+ rv = 1;
+ if ((ms->flags & MAGIC_COMPRESS_TRANSP) != 0)
+ goto out;
+ if (mime != MAGIC_MIME && mime != 0)
+ goto out;
+ if ((file_printf(ms,
+ mime ? " compressed-encoding=" : " (")) == -1)
+ goto error;
+ if ((pb = file_push_buffer(ms)) == NULL)
+ goto error;
+ /*
+ * XXX: If file_buffer fails here, we overwrite
+ * the compressed text. FIXME.
+ */
+ if (file_buffer(ms, -1, NULL, buf, nbytes) == -1)
+ goto error;
+ if ((rbuf = file_pop_buffer(ms, pb)) != NULL) {
+ if (file_printf(ms, "%s", rbuf) == -1) {
+ free(rbuf);
+ goto error;
+ }
+ free(rbuf);
+ }
+ if (!mime && file_printf(ms, ")") == -1)
+ goto error;
+ /*FALLTHROUGH*/
+ case NODATA:
+ break;
+ default:
+ abort();
+ /*NOTREACHED*/
+ error:
+ rv = -1;
+ break;
+ }
+ }
+out:
+ DPRINTF("rv = %d\n", rv);
+
+#ifdef HAVE_SIGNAL_H
+ (void)signal(SIGPIPE, osigpipe);
+#endif
+ free(newbuf);
+ ms->flags |= MAGIC_COMPRESS;
+ DPRINTF("Zmagic returns %d\n", rv);
+ return rv;
+}
+#endif
+/*
+ * `safe' write for sockets and pipes.
+ */
+private ssize_t
+swrite(int fd, const void *buf, size_t n)
+{
+ ssize_t rv;
+ size_t rn = n;
+
+ do
+ switch (rv = write(fd, buf, n)) {
+ case -1:
+ if (errno == EINTR)
+ continue;
+ return -1;
+ default:
+ n -= rv;
+ buf = CAST(const char *, buf) + rv;
+ break;
+ }
+ while (n > 0);
+ return rn;
+}
+
+
+/*
+ * `safe' read for sockets and pipes.
+ */
+protected ssize_t
+sread(int fd, void *buf, size_t n, int canbepipe __attribute__((__unused__)))
+{
+ ssize_t rv;
+#ifdef FIONREAD
+ int t = 0;
+#endif
+ size_t rn = n;
+
+ if (fd == STDIN_FILENO)
+ goto nocheck;
+
+#ifdef FIONREAD
+ if (canbepipe && (ioctl(fd, FIONREAD, &t) == -1 || t == 0)) {
+#ifdef FD_ZERO
+ ssize_t cnt;
+ for (cnt = 0;; cnt++) {
+ fd_set check;
+ struct timeval tout = {0, 100 * 1000};
+ int selrv;
+
+ FD_ZERO(&check);
+ FD_SET(fd, &check);
+
+ /*
+ * Avoid soft deadlock: do not read if there
+ * is nothing to read from sockets and pipes.
+ */
+ selrv = select(fd + 1, &check, NULL, NULL, &tout);
+ if (selrv == -1) {
+ if (errno == EINTR || errno == EAGAIN)
+ continue;
+ } else if (selrv == 0 && cnt >= 5) {
+ return 0;
+ } else
+ break;
+ }
+#endif
+ (void)ioctl(fd, FIONREAD, &t);
+ }
+
+ if (t > 0 && (size_t)t < n) {
+ n = t;
+ rn = n;
+ }
+#endif
+
+nocheck:
+ do
+ switch ((rv = read(fd, buf, n))) {
+ case -1:
+ if (errno == EINTR)
+ continue;
+ return -1;
+ case 0:
+ return rn - n;
+ default:
+ n -= rv;
+ buf = CAST(char *, CCAST(void *, buf)) + rv;
+ break;
+ }
+ while (n > 0);
+ return rn;
+}
+
+protected int
+file_pipe2file(struct magic_set *ms, int fd, const void *startbuf,
+ size_t nbytes)
+{
+ char buf[4096];
+ ssize_t r;
+ int tfd;
+
+ (void)strlcpy(buf, "/tmp/file.XXXXXX", sizeof buf);
+#ifndef HAVE_MKSTEMP
+ {
+ char *ptr = mktemp(buf);
+ tfd = open(ptr, O_RDWR|O_TRUNC|O_EXCL|O_CREAT, 0600);
+ r = errno;
+ (void)unlink(ptr);
+ errno = r;
+ }
+#else
+ {
+ int te;
+ tfd = mkstemp(buf);
+ te = errno;
+ (void)unlink(buf);
+ errno = te;
+ }
+#endif
+ if (tfd == -1) {
+ file_error(ms, errno,
+ "cannot create temporary file for pipe copy");
+ return -1;
+ }
+
+ if (swrite(tfd, startbuf, nbytes) != (ssize_t)nbytes)
+ r = 1;
+ else {
+ while ((r = sread(fd, buf, sizeof(buf), 1)) > 0)
+ if (swrite(tfd, buf, (size_t)r) != r)
+ break;
+ }
+
+ switch (r) {
+ case -1:
+ file_error(ms, errno, "error copying from pipe to temp file");
+ return -1;
+ case 0:
+ break;
+ default:
+ file_error(ms, errno, "error while writing to temp file");
+ return -1;
+ }
+
+ /*
+ * We duplicate the file descriptor, because fclose on a
+ * tmpfile will delete the file, but any open descriptors
+ * can still access the phantom inode.
+ */
+ if ((fd = dup2(tfd, fd)) == -1) {
+ file_error(ms, errno, "could not dup descriptor for temp file");
+ return -1;
+ }
+ (void)close(tfd);
+ if (lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) {
+ file_badseek(ms);
+ return -1;
+ }
+ return fd;
+}
+#if HAVE_FORK
+#ifdef BUILTIN_DECOMPRESS
+
+#define FHCRC (1 << 1)
+#define FEXTRA (1 << 2)
+#define FNAME (1 << 3)
+#define FCOMMENT (1 << 4)
+
+
+private int
+uncompressgzipped(const unsigned char *old, unsigned char **newch,
+ size_t bytes_max, size_t *n)
+{
+ unsigned char flg = old[3];
+ size_t data_start = 10;
+
+ if (flg & FEXTRA) {
+ if (data_start + 1 >= *n)
+ goto err;
+ data_start += 2 + old[data_start] + old[data_start + 1] * 256;
+ }
+ if (flg & FNAME) {
+ while(data_start < *n && old[data_start])
+ data_start++;
+ data_start++;
+ }
+ if (flg & FCOMMENT) {
+ while(data_start < *n && old[data_start])
+ data_start++;
+ data_start++;
+ }
+ if (flg & FHCRC)
+ data_start += 2;
+
+ if (data_start >= *n)
+ goto err;
+
+ *n -= data_start;
+ old += data_start;
+ return uncompresszlib(old, newch, bytes_max, n, 0);
+err:
+ return makeerror(newch, n, "File too short");
+}
+
+private int
+uncompresszlib(const unsigned char *old, unsigned char **newch,
+ size_t bytes_max, size_t *n, int zlib)
+{
+ int rc;
+ z_stream z;
+
+ if ((*newch = CAST(unsigned char *, malloc(bytes_max + 1))) == NULL)
+ return makeerror(newch, n, "No buffer, %s", strerror(errno));
+
+ z.next_in = CCAST(Bytef *, old);
+ z.avail_in = CAST(uint32_t, *n);
+ z.next_out = *newch;
+ z.avail_out = CAST(unsigned int, bytes_max);
+ z.zalloc = Z_NULL;
+ z.zfree = Z_NULL;
+ z.opaque = Z_NULL;
+
+ /* LINTED bug in header macro */
+ rc = zlib ? inflateInit(&z) : inflateInit2(&z, -15);
+ if (rc != Z_OK)
+ goto err;
+
+ rc = inflate(&z, Z_SYNC_FLUSH);
+ if (rc != Z_OK && rc != Z_STREAM_END)
+ goto err;
+
+ *n = (size_t)z.total_out;
+ rc = inflateEnd(&z);
+ if (rc != Z_OK)
+ goto err;
+
+ /* let's keep the nul-terminate tradition */
+ (*newch)[*n] = '\0';
+
+ return OKDATA;
+err:
+ strlcpy((char *)*newch, z.msg ? z.msg : zError(rc), bytes_max);
+ *n = strlen((char *)*newch);
+ return ERRDATA;
+}
+#endif
+
+static int
+makeerror(unsigned char **buf, size_t *len, const char *fmt, ...)
+{
+ char *msg;
+ va_list ap;
+ int rv;
+
+ va_start(ap, fmt);
+ rv = vasprintf(&msg, fmt, ap);
+ va_end(ap);
+ if (rv < 0) {
+ *buf = NULL;
+ *len = 0;
+ return NODATA;
+ }
+ *buf = (unsigned char *)msg;
+ *len = strlen(msg);
+ return ERRDATA;
+}
+
+static void
+closefd(int *fd, size_t i)
+{
+ if (fd[i] == -1)
+ return;
+ (void) close(fd[i]);
+ fd[i] = -1;
+}
+
+static void
+closep(int *fd)
+{
+ size_t i;
+ for (i = 0; i < 2; i++)
+ closefd(fd, i);
+}
+
+static void
+copydesc(int i, int *fd)
+{
+ int j = fd[i == STDIN_FILENO ? 0 : 1];
+ if (j == i)
+ return;
+ if (dup2(j, i) == -1) {
+ DPRINTF("dup(%d, %d) failed (%s)\n", j, i, strerror(errno));
+ exit(1);
+ }
+ closep(fd);
+}
+
+static void
+writechild(int fdp[3][2], const void *old, size_t n)
+{
+ int status;
+
+ closefd(fdp[STDIN_FILENO], 0);
+ /*
+ * fork again, to avoid blocking because both
+ * pipes filled
+ */
+ switch (fork()) {
+ case 0: /* child */
+ closefd(fdp[STDOUT_FILENO], 0);
+ if (swrite(fdp[STDIN_FILENO][1], old, n) != (ssize_t)n) {
+ DPRINTF("Write failed (%s)\n", strerror(errno));
+ exit(1);
+ }
+ exit(0);
+ /*NOTREACHED*/
+
+ case -1:
+ DPRINTF("Fork failed (%s)\n", strerror(errno));
+ exit(1);
+ /*NOTREACHED*/
+
+ default: /* parent */
+ if (wait(&status) == -1) {
+ DPRINTF("Wait failed (%s)\n", strerror(errno));
+ exit(1);
+ }
+ DPRINTF("Grandchild wait return %#x\n", status);
+ }
+ closefd(fdp[STDIN_FILENO], 1);
+}
+
+static ssize_t
+filter_error(unsigned char *ubuf, ssize_t n)
+{
+ char *p;
+ char *buf;
+
+ ubuf[n] = '\0';
+ buf = (char *)ubuf;
+ while (isspace((unsigned char)*buf))
+ buf++;
+ DPRINTF("Filter error[[[%s]]]\n", buf);
+ if ((p = strchr((char *)buf, '\n')) != NULL)
+ *p = '\0';
+ if ((p = strchr((char *)buf, ';')) != NULL)
+ *p = '\0';
+ if ((p = strrchr((char *)buf, ':')) != NULL) {
+ ++p;
+ while (isspace((unsigned char)*p))
+ p++;
+ n = strlen(p);
+ memmove(ubuf, p, CAST(size_t, n + 1));
+ }
+ DPRINTF("Filter error after[[[%s]]]\n", (char *)ubuf);
+ if (islower(*ubuf))
+ *ubuf = toupper(*ubuf);
+ return n;
+}
+
+private const char *
+methodname(size_t method)
+{
+#ifdef BUILTIN_DECOMPRESS
+ /* FIXME: This doesn't cope with bzip2 */
+ if (method == 2 || compr[method].maglen == 0)
+ return "zlib";
+#endif
+ return compr[method].argv[0];
+}
+
+private int
+uncompressbuf(int fd, size_t bytes_max, size_t method, const unsigned char *old,
+ unsigned char **newch, size_t* n)
+{
+ int fdp[3][2];
+ int status, rv;
+ size_t i;
+ ssize_t r;
+
+#ifdef BUILTIN_DECOMPRESS
+ /* FIXME: This doesn't cope with bzip2 */
+ if (method == 2)
+ return uncompressgzipped(old, newch, bytes_max, n);
+ if (compr[method].maglen == 0)
+ return uncompresszlib(old, newch, bytes_max, n, 1);
+#endif
+ (void)fflush(stdout);
+ (void)fflush(stderr);
+
+ for (i = 0; i < __arraycount(fdp); i++)
+ fdp[i][0] = fdp[i][1] = -1;
+
+ if ((fd == -1 && pipe(fdp[STDIN_FILENO]) == -1) ||
+ pipe(fdp[STDOUT_FILENO]) == -1 || pipe(fdp[STDERR_FILENO]) == -1) {
+ closep(fdp[STDIN_FILENO]);
+ closep(fdp[STDOUT_FILENO]);
+ return makeerror(newch, n, "Cannot create pipe, %s",
+ strerror(errno));
+ }
+ switch (fork()) {
+ case 0: /* child */
+ if (fd != -1) {
+ fdp[STDIN_FILENO][0] = fd;
+ (void) lseek(fd, (off_t)0, SEEK_SET);
+ }
+
+ for (i = 0; i < __arraycount(fdp); i++)
+ copydesc(CAST(int, i), fdp[i]);
+
+ (void)execvp(compr[method].argv[0],
+ (char *const *)(intptr_t)compr[method].argv);
+ dprintf(STDERR_FILENO, "exec `%s' failed, %s",
+ compr[method].argv[0], strerror(errno));
+ exit(1);
+ /*NOTREACHED*/
+ case -1:
+ return makeerror(newch, n, "Cannot fork, %s",
+ strerror(errno));
+
+ default: /* parent */
+ for (i = 1; i < __arraycount(fdp); i++)
+ closefd(fdp[i], 1);
+
+ /* Write the buffer data to the child, if we don't have fd */
+ if (fd == -1)
+ writechild(fdp, old, *n);
+
+ *newch = CAST(unsigned char *, malloc(bytes_max + 1));
+ if (*newch == NULL) {
+ rv = makeerror(newch, n, "No buffer, %s",
+ strerror(errno));
+ goto err;
+ }
+ rv = OKDATA;
+ if ((r = sread(fdp[STDOUT_FILENO][0], *newch, bytes_max, 0)) > 0)
+ break;
+ DPRINTF("Read stdout failed %d (%s)\n", fdp[STDOUT_FILENO][0],
+ r != -1 ? strerror(errno) : "no data");
+
+ rv = ERRDATA;
+ if (r == 0 &&
+ (r = sread(fdp[STDERR_FILENO][0], *newch, bytes_max, 0)) > 0)
+ {
+ r = filter_error(*newch, r);
+ break;
+ }
+ free(*newch);
+ if (r == 0)
+ rv = makeerror(newch, n, "Read failed, %s",
+ strerror(errno));
+ else
+ rv = makeerror(newch, n, "No data");
+ goto err;
+ }
+
+ *n = r;
+ /* NUL terminate, as every buffer is handled here. */
+ (*newch)[*n] = '\0';
+err:
+ closefd(fdp[STDIN_FILENO], 1);
+ closefd(fdp[STDOUT_FILENO], 0);
+ closefd(fdp[STDERR_FILENO], 0);
+ if (wait(&status) == -1) {
+ free(*newch);
+ rv = makeerror(newch, n, "Wait failed, %s", strerror(errno));
+ DPRINTF("Child wait return %#x\n", status);
+ } else if (!WIFEXITED(status)) {
+ DPRINTF("Child not exited (%#x)\n", status);
+ } else if (WEXITSTATUS(status) != 0) {
+ DPRINTF("Child exited (%#x)\n", WEXITSTATUS(status));
+ }
+
+ closefd(fdp[STDIN_FILENO], 0);
+ DPRINTF("Returning %p n=%zu rv=%d\n", *newch, *n, rv);
+
+ return rv;
+}
+#endif
diff --git a/node_modules/mmmagic/deps/libmagic/src/ctime_r.c b/node_modules/mmmagic/deps/libmagic/src/ctime_r.c
new file mode 100644
index 0000000..ca7ad2f
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/ctime_r.c
@@ -0,0 +1,19 @@
+/* $File: ctime_r.c,v 1.1 2012/05/15 17:14:36 christos Exp $ */
+
+#include "file.h"
+#ifndef lint
+FILE_RCSID("@(#)$File: ctime_r.c,v 1.1 2012/05/15 17:14:36 christos Exp $")
+#endif /* lint */
+#include <time.h>
+#include <string.h>
+
+/* ctime_r is not thread-safe anyway */
+char *
+ctime_r(const time_t *t, char *dst)
+{
+ char *p = ctime(t);
+ if (p == NULL)
+ return NULL;
+ memcpy(dst, p, 26);
+ return dst;
+}
diff --git a/node_modules/mmmagic/deps/libmagic/src/der.c b/node_modules/mmmagic/deps/libmagic/src/der.c
new file mode 100644
index 0000000..e7ca16e
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/der.c
@@ -0,0 +1,409 @@
+/*-
+ * Copyright (c) 2016 Christos Zoulas
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * DER (Distinguished Encoding Rules) Parser
+ *
+ * Sources:
+ * https://en.wikipedia.org/wiki/X.690
+ * http://fm4dd.com/openssl/certexamples.htm
+ * http://blog.engelke.com/2014/10/17/parsing-ber-and-der-encoded-asn-1-objects/
+ */
+#ifndef TEST_DER
+#include "file.h"
+
+#ifndef lint
+FILE_RCSID("@(#)$File: der.c,v 1.12 2017/02/10 18:14:01 christos Exp $")
+#endif
+#endif
+
+#include <sys/types.h>
+
+#include <stdio.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+// XXX: addition by mscdex
+#ifdef _MSC_VER
+#define __func__ __FUNCTION__
+#endif
+
+#ifndef TEST_DER
+#include "magic.h"
+#include "der.h"
+#else
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <err.h>
+#endif
+
+#define DER_BAD ((uint32_t)-1)
+
+#define DER_CLASS_UNIVERSAL 0
+#define DER_CLASS_APPLICATION 1
+#define DER_CLASS_CONTEXT 2
+#define DER_CLASS_PRIVATE 3
+#ifdef DEBUG_DER
+static const char der_class[] = "UACP";
+#endif
+
+#define DER_TYPE_PRIMITIVE 0
+#define DER_TYPE_CONSTRUCTED 1
+#ifdef DEBUG_DER
+static const char der_type[] = "PC";
+#endif
+
+#define DER_TAG_EOC 0x00
+#define DER_TAG_BOOLEAN 0x01
+#define DER_TAG_INTEGER 0x02
+#define DER_TAG_BIT STRING 0x03
+#define DER_TAG_OCTET_STRING 0x04
+#define DER_TAG_NULL 0x05
+#define DER_TAG_OBJECT_IDENTIFIER 0x06
+#define DER_TAG_OBJECT_DESCRIPTOR 0x07
+#define DER_TAG_EXTERNAL 0x08
+#define DER_TAG_REAL 0x09
+#define DER_TAG_ENUMERATED 0x0a
+#define DER_TAG_EMBEDDED_PDV 0x0b
+#define DER_TAG_UTF8_STRING 0x0c
+#define DER_TAG_RELATIVE_OID 0x0d
+#define DER_TAG_RESERVED_1 0x0e
+#define DER_TAG_RESERVED_2 0x0f
+#define DER_TAG_SEQUENCE 0x10
+#define DER_TAG_SET 0x11
+#define DER_TAG_NUMERIC_STRING 0x12
+#define DER_TAG_PRINTABLE_STRING 0x13
+#define DER_TAG_T61_STRING 0x14
+#define DER_TAG_VIDEOTEX_STRING 0x15
+#define DER_TAG_IA5_STRING 0x16
+#define DER_TAG_UTCTIME 0x17
+#define DER_TAG_GENERALIZED_TIME 0x18
+#define DER_TAG_GRAPHIC_STRING 0x19
+#define DER_TAG_VISIBLE_STRING 0x1a
+#define DER_TAG_GENERAL_STRING 0x1b
+#define DER_TAG_UNIVERSAL_STRING 0x1c
+#define DER_TAG_CHARACTER_STRING 0x1d
+#define DER_TAG_BMP_STRING 0x1e
+#define DER_TAG_LONG 0x1f
+
+static const char *der__tag[] = {
+ "eoc", "bool", "int", "bit_str", "octet_str",
+ "null", "obj_id", "obj_desc", "ext", "real",
+ "enum", "embed", "utf8_str", "oid", "res1",
+ "res2", "seq", "set", "num_str", "prt_str",
+ "t61_str", "vid_str", "ia5_str", "utc_time",
+ "gen_time", "gr_str", "vis_str", "gen_str",
+ "char_str", "bmp_str", "long"
+};
+
+#ifdef DEBUG_DER
+#define DPRINTF(a) printf a
+#else
+#define DPRINTF(a)
+#endif
+
+#ifdef TEST_DER
+static uint8_t
+getclass(uint8_t c)
+{
+ return c >> 6;
+}
+
+static uint8_t
+gettype(uint8_t c)
+{
+ return (c >> 5) & 1;
+}
+#endif
+
+static uint32_t
+gettag(const uint8_t *c, size_t *p, size_t l)
+{
+ uint32_t tag;
+
+ if (*p >= l)
+ return DER_BAD;
+
+ tag = c[(*p)++] & 0x1f;
+
+ if (tag != 0x1f)
+ return tag;
+
+ if (*p >= l)
+ return DER_BAD;
+
+ while (c[*p] >= 0x80) {
+ tag = tag * 128 + c[(*p)++] - 0x80;
+ if (*p >= l)
+ return DER_BAD;
+ }
+ return tag;
+}
+
+/*
+ * Read the length of a DER tag from the input.
+ *
+ * `c` is the input, `p` is an output parameter that specifies how much of the
+ * input we consumed, and `l` is the maximum input length.
+ *
+ * Returns the length, or DER_BAD if the end of the input is reached or the
+ * length exceeds the remaining input.
+ */
+static uint32_t
+getlength(const uint8_t *c, size_t *p, size_t l)
+{
+ uint8_t digits, i;
+ size_t len;
+ int is_onebyte_result;
+
+ if (*p >= l)
+ return DER_BAD;
+
+ /*
+ * Digits can either be 0b0 followed by the result, or 0b1
+ * followed by the number of digits of the result. In either case,
+ * we verify that we can read so many bytes from the input.
+ */
+ is_onebyte_result = (c[*p] & 0x80) == 0;
+ digits = c[(*p)++] & 0x7f;
+ if (*p + digits >= l)
+ return DER_BAD;
+
+ if (is_onebyte_result)
+ return digits;
+
+ /*
+ * Decode len. We've already verified that we're allowed to read
+ * `digits` bytes.
+ */
+ len = 0;
+ for (i = 0; i < digits; i++)
+ len = (len << 8) | c[(*p)++];
+
+ if (*p + len >= l)
+ return DER_BAD;
+ return CAST(uint32_t, len);
+}
+
+static const char *
+der_tag(char *buf, size_t len, uint32_t tag)
+{
+ if (tag < DER_TAG_LONG)
+ strlcpy(buf, der__tag[tag], len);
+ else
+ snprintf(buf, len, "%#x", tag);
+ return buf;
+}
+
+#ifndef TEST_DER
+static int
+der_data(char *buf, size_t blen, uint32_t tag, const void *q, uint32_t len)
+{
+ const uint8_t *d = CAST(const uint8_t *, q);
+ switch (tag) {
+ case DER_TAG_PRINTABLE_STRING:
+ case DER_TAG_UTF8_STRING:
+ case DER_TAG_IA5_STRING:
+ case DER_TAG_UTCTIME:
+ return snprintf(buf, blen, "%.*s", len, (const char *)q);
+ default:
+ break;
+ }
+
+ for (uint32_t i = 0; i < len; i++) {
+ uint32_t z = i << 1;
+ if (z < blen - 2)
+ snprintf(buf + z, blen - z, "%.2x", d[i]);
+ }
+ return len * 2;
+}
+
+int32_t
+der_offs(struct magic_set *ms, struct magic *m, size_t nbytes)
+{
+ const uint8_t *b = RCAST(const uint8_t *, ms->search.s);
+ size_t offs = 0, len = ms->search.s_len ? ms->search.s_len : nbytes;
+
+ if (gettag(b, &offs, len) == DER_BAD)
+ return -1;
+ DPRINTF(("%s1: %d %zu %u\n", __func__, ms->offset, offs, m->offset));
+
+ uint32_t tlen = getlength(b, &offs, len);
+ if (tlen == DER_BAD)
+ return -1;
+ DPRINTF(("%s2: %d %zu %u\n", __func__, ms->offset, offs, tlen));
+
+ offs += ms->offset + m->offset;
+ DPRINTF(("cont_level = %d\n", m->cont_level));
+#ifdef DEBUG_DER
+ for (size_t i = 0; i < m->cont_level; i++)
+ printf("cont_level[%zu] = %u\n", i, ms->c.li[i].off);
+#endif
+ if (m->cont_level != 0) {
+ if (offs + tlen > nbytes)
+ return -1;
+ ms->c.li[m->cont_level - 1].off = CAST(int, offs + tlen);
+ DPRINTF(("cont_level[%u] = %u\n", m->cont_level - 1,
+ ms->c.li[m->cont_level - 1].off));
+ }
+ return CAST(int32_t, offs);
+}
+
+int
+der_cmp(struct magic_set *ms, struct magic *m)
+{
+ const uint8_t *b = RCAST(const uint8_t *, ms->search.s);
+ const char *s = m->value.s;
+ size_t offs = 0, len = ms->search.s_len;
+ uint32_t tag, tlen;
+ char buf[128];
+
+ tag = gettag(b, &offs, len);
+ if (tag == DER_BAD)
+ return -1;
+
+ tlen = getlength(b, &offs, len);
+ if (tlen == DER_BAD)
+ return -1;
+
+ der_tag(buf, sizeof(buf), tag);
+ if ((ms->flags & MAGIC_DEBUG) != 0)
+ fprintf(stderr, "%s: tag %p got=%s exp=%s\n", __func__, b,
+ buf, s);
+ size_t slen = strlen(buf);
+
+ if (strncmp(buf, s, slen) != 0)
+ return 0;
+
+ s += slen;
+
+again:
+ switch (*s) {
+ case '\0':
+ return 1;
+ case '=':
+ s++;
+ goto val;
+ default:
+ if (!isdigit((unsigned char)*s))
+ return 0;
+
+ slen = 0;
+ do
+ slen = slen * 10 + *s - '0';
+ while (isdigit((unsigned char)*++s));
+ if ((ms->flags & MAGIC_DEBUG) != 0)
+ fprintf(stderr, "%s: len %zu %u\n", __func__,
+ slen, tlen);
+ if (tlen != slen)
+ return 0;
+ goto again;
+ }
+val:
+ DPRINTF(("%s: before data %zu %u\n", __func__, offs, tlen));
+ der_data(buf, sizeof(buf), tag, b + offs, tlen);
+ if ((ms->flags & MAGIC_DEBUG) != 0)
+ fprintf(stderr, "%s: data %s %s\n", __func__, buf, s);
+ if (strcmp(buf, s) != 0 && strcmp("x", s) != 0)
+ return 0;
+ strlcpy(ms->ms_value.s, buf, sizeof(ms->ms_value.s));
+ return 1;
+}
+#endif
+
+#ifdef TEST_DER
+static void
+printtag(uint32_t tag, const void *q, uint32_t len)
+{
+ const uint8_t *d = q;
+ switch (tag) {
+ case DER_TAG_PRINTABLE_STRING:
+ case DER_TAG_UTF8_STRING:
+ printf("%.*s\n", len, (const char *)q);
+ return;
+ default:
+ break;
+ }
+
+ for (uint32_t i = 0; i < len; i++)
+ printf("%.2x", d[i]);
+ printf("\n");
+}
+
+static void
+printdata(size_t level, const void *v, size_t x, size_t l)
+{
+ const uint8_t *p = v, *ep = p + l;
+ size_t ox;
+ char buf[128];
+
+ while (p + x < ep) {
+ const uint8_t *q;
+ uint8_t c = getclass(p[x]);
+ uint8_t t = gettype(p[x]);
+ ox = x;
+ if (x != 0)
+ printf("%.2x %.2x %.2x\n", p[x - 1], p[x], p[x + 1]);
+ uint32_t tag = gettag(p, &x, ep - p + x);
+ if (p + x >= ep)
+ break;
+ uint32_t len = getlength(p, &x, ep - p + x);
+
+ printf("%zu %zu-%zu %c,%c,%s,%u:", level, ox, x,
+ der_class[c], der_type[t],
+ der_tag(buf, sizeof(buf), tag), len);
+ q = p + x;
+ if (p + len > ep)
+ errx(EXIT_FAILURE, "corrupt der");
+ printtag(tag, q, len);
+ if (t != DER_TYPE_PRIMITIVE)
+ printdata(level + 1, p, x, len + x);
+ x += len;
+ }
+}
+
+int
+main(int argc, char *argv[])
+{
+ int fd;
+ struct stat st;
+ size_t l;
+ void *p;
+
+ if ((fd = open(argv[1], O_RDONLY)) == -1)
+ err(EXIT_FAILURE, "open `%s'", argv[1]);
+ if (fstat(fd, &st) == -1)
+ err(EXIT_FAILURE, "stat `%s'", argv[1]);
+ l = (size_t)st.st_size;
+ if ((p = mmap(NULL, l, PROT_READ, MAP_FILE, fd, 0)) == MAP_FAILED)
+ err(EXIT_FAILURE, "mmap `%s'", argv[1]);
+
+ printdata(0, p, 0, l);
+ munmap(p, l);
+ return 0;
+}
+#endif
diff --git a/node_modules/mmmagic/deps/libmagic/src/der.h b/node_modules/mmmagic/deps/libmagic/src/der.h
new file mode 100644
index 0000000..3333239
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/der.h
@@ -0,0 +1,28 @@
+/*-
+ * Copyright (c) 2016 Christos Zoulas
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+extern int der_offs(struct magic_set *, struct magic *, size_t);
+extern int der_cmp(struct magic_set *, struct magic *);
diff --git a/node_modules/mmmagic/deps/libmagic/src/dprintf.c b/node_modules/mmmagic/deps/libmagic/src/dprintf.c
new file mode 100644
index 0000000..425bacd
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/dprintf.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) Ian F. Darwin 1986-1995.
+ * Software written by Ian F. Darwin and others;
+ * maintained 1995-present by Christos Zoulas and others.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice immediately at the beginning of the file, without modification,
+ * this list of conditions, and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#include "file.h"
+
+#ifndef lint
+FILE_RCSID("@(#)$File: dprintf.c,v 1.1 2015/11/13 15:36:14 christos Exp $")
+#endif /* lint */
+
+#include <assert.h>
+// XXX: change by mscdex
+#ifndef _MSC_VER
+# include <unistd.h>
+#endif
+#include <stdio.h>
+#include <stdarg.h>
+
+int
+dprintf(int fd, const char *fmt, ...)
+{
+ va_list ap;
+ /* Simpler than using vasprintf() here, since we never need more */
+ char buf[1024];
+ int len;
+
+ va_start(ap, fmt);
+ len = vsnprintf(buf, sizeof(buf), fmt, ap);
+ va_end(ap);
+
+ if ((size_t)len >= sizeof(buf))
+ return -1;
+
+ if (write(fd, buf, (size_t)len) != len)
+ return -1;
+
+ return len;
+}
diff --git a/node_modules/mmmagic/deps/libmagic/src/elfclass.h b/node_modules/mmmagic/deps/libmagic/src/elfclass.h
new file mode 100644
index 0000000..5360b0b
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/elfclass.h
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) Christos Zoulas 2008.
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice immediately at the beginning of the file, without modification,
+ * this list of conditions, and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+ if (nbytes <= sizeof(elfhdr))
+ return 0;
+
+ u.l = 1;
+ (void)memcpy(&elfhdr, buf, sizeof elfhdr);
+ swap = (u.c[sizeof(int32_t) - 1] + 1) != elfhdr.e_ident[EI_DATA];
+
+ type = elf_getu16(swap, elfhdr.e_type);
+ notecount = ms->elf_notes_max;
+ switch (type) {
+#ifdef ELFCORE
+ case ET_CORE:
+ phnum = elf_getu16(swap, elfhdr.e_phnum);
+ if (phnum > ms->elf_phnum_max)
+ return toomany(ms, "program headers", phnum);
+ flags |= FLAGS_IS_CORE;
+ if (dophn_core(ms, clazz, swap, fd,
+ (off_t)elf_getu(swap, elfhdr.e_phoff), phnum,
+ (size_t)elf_getu16(swap, elfhdr.e_phentsize),
+ fsize, &flags, &notecount) == -1)
+ return -1;
+ break;
+#endif
+ case ET_EXEC:
+ case ET_DYN:
+ phnum = elf_getu16(swap, elfhdr.e_phnum);
+ if (phnum > ms->elf_phnum_max)
+ return toomany(ms, "program", phnum);
+ shnum = elf_getu16(swap, elfhdr.e_shnum);
+ if (shnum > ms->elf_shnum_max)
+ return toomany(ms, "section", shnum);
+ if (dophn_exec(ms, clazz, swap, fd,
+ (off_t)elf_getu(swap, elfhdr.e_phoff), phnum,
+ (size_t)elf_getu16(swap, elfhdr.e_phentsize),
+ fsize, shnum, &flags, &notecount) == -1)
+ return -1;
+ /*FALLTHROUGH*/
+ case ET_REL:
+ shnum = elf_getu16(swap, elfhdr.e_shnum);
+ if (shnum > ms->elf_shnum_max)
+ return toomany(ms, "section headers", shnum);
+ if (doshn(ms, clazz, swap, fd,
+ (off_t)elf_getu(swap, elfhdr.e_shoff), shnum,
+ (size_t)elf_getu16(swap, elfhdr.e_shentsize),
+ fsize, elf_getu16(swap, elfhdr.e_machine),
+ (int)elf_getu16(swap, elfhdr.e_shstrndx),
+ &flags, &notecount) == -1)
+ return -1;
+ break;
+
+ default:
+ break;
+ }
+ if (notecount == 0)
+ return toomany(ms, "notes", ms->elf_notes_max);
+ return 1;
diff --git a/node_modules/mmmagic/deps/libmagic/src/encoding.c b/node_modules/mmmagic/deps/libmagic/src/encoding.c
new file mode 100644
index 0000000..3c116cd
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/encoding.c
@@ -0,0 +1,529 @@
+/*
+ * Copyright (c) Ian F. Darwin 1986-1995.
+ * Software written by Ian F. Darwin and others;
+ * maintained 1995-present by Christos Zoulas and others.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice immediately at the beginning of the file, without modification,
+ * this list of conditions, and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+/*
+ * Encoding -- determine the character encoding of a text file.
+ *
+ * Joerg Wunsch <joerg@freebsd.org> wrote the original support for 8-bit
+ * international characters.
+ */
+
+#include "file.h"
+
+#ifndef lint
+FILE_RCSID("@(#)$File: encoding.c,v 1.13 2015/06/04 19:16:28 christos Exp $")
+#endif /* lint */
+
+#include "magic.h"
+#include <string.h>
+#include <memory.h>
+#include <stdlib.h>
+
+
+private int looks_ascii(const unsigned char *, size_t, unichar *, size_t *);
+private int looks_utf8_with_BOM(const unsigned char *, size_t, unichar *,
+ size_t *);
+private int looks_utf7(const unsigned char *, size_t, unichar *, size_t *);
+private int looks_ucs16(const unsigned char *, size_t, unichar *, size_t *);
+private int looks_latin1(const unsigned char *, size_t, unichar *, size_t *);
+private int looks_extended(const unsigned char *, size_t, unichar *, size_t *);
+private void from_ebcdic(const unsigned char *, size_t, unsigned char *);
+
+#ifdef DEBUG_ENCODING
+#define DPRINTF(a) printf a
+#else
+#define DPRINTF(a)
+#endif
+
+/*
+ * Try to determine whether text is in some character code we can
+ * identify. Each of these tests, if it succeeds, will leave
+ * the text converted into one-unichar-per-character Unicode in
+ * ubuf, and the number of characters converted in ulen.
+ */
+protected int
+file_encoding(struct magic_set *ms, const unsigned char *buf, size_t nbytes, unichar **ubuf, size_t *ulen, const char **code, const char **code_mime, const char **type)
+{
+ size_t mlen;
+ int rv = 1, ucs_type;
+ unsigned char *nbuf = NULL;
+
+ *type = "text";
+ *ulen = 0;
+ *code = "unknown";
+ *code_mime = "binary";
+
+ mlen = (nbytes + 1) * sizeof((*ubuf)[0]);
+ if ((*ubuf = CAST(unichar *, calloc((size_t)1, mlen))) == NULL) {
+ file_oomem(ms, mlen);
+ goto done;
+ }
+ mlen = (nbytes + 1) * sizeof(nbuf[0]);
+ if ((nbuf = CAST(unsigned char *, calloc((size_t)1, mlen))) == NULL) {
+ file_oomem(ms, mlen);
+ goto done;
+ }
+
+ if (looks_ascii(buf, nbytes, *ubuf, ulen)) {
+ if (looks_utf7(buf, nbytes, *ubuf, ulen) > 0) {
+ DPRINTF(("utf-7 %" SIZE_T_FORMAT "u\n", *ulen));
+ *code = "UTF-7 Unicode";
+ *code_mime = "utf-7";
+ } else {
+ DPRINTF(("ascii %" SIZE_T_FORMAT "u\n", *ulen));
+ *code = "ASCII";
+ *code_mime = "us-ascii";
+ }
+ } else if (looks_utf8_with_BOM(buf, nbytes, *ubuf, ulen) > 0) {
+ DPRINTF(("utf8/bom %" SIZE_T_FORMAT "u\n", *ulen));
+ *code = "UTF-8 Unicode (with BOM)";
+ *code_mime = "utf-8";
+ } else if (file_looks_utf8(buf, nbytes, *ubuf, ulen) > 1) {
+ DPRINTF(("utf8 %" SIZE_T_FORMAT "u\n", *ulen));
+ *code = "UTF-8 Unicode";
+ *code_mime = "utf-8";
+ } else if ((ucs_type = looks_ucs16(buf, nbytes, *ubuf, ulen)) != 0) {
+ if (ucs_type == 1) {
+ *code = "Little-endian UTF-16 Unicode";
+ *code_mime = "utf-16le";
+ } else {
+ *code = "Big-endian UTF-16 Unicode";
+ *code_mime = "utf-16be";
+ }
+ DPRINTF(("ucs16 %" SIZE_T_FORMAT "u\n", *ulen));
+ } else if (looks_latin1(buf, nbytes, *ubuf, ulen)) {
+ DPRINTF(("latin1 %" SIZE_T_FORMAT "u\n", *ulen));
+ *code = "ISO-8859";
+ *code_mime = "iso-8859-1";
+ } else if (looks_extended(buf, nbytes, *ubuf, ulen)) {
+ DPRINTF(("extended %" SIZE_T_FORMAT "u\n", *ulen));
+ *code = "Non-ISO extended-ASCII";
+ *code_mime = "unknown-8bit";
+ } else {
+ from_ebcdic(buf, nbytes, nbuf);
+
+ if (looks_ascii(nbuf, nbytes, *ubuf, ulen)) {
+ DPRINTF(("ebcdic %" SIZE_T_FORMAT "u\n", *ulen));
+ *code = "EBCDIC";
+ *code_mime = "ebcdic";
+ } else if (looks_latin1(nbuf, nbytes, *ubuf, ulen)) {
+ DPRINTF(("ebcdic/international %" SIZE_T_FORMAT "u\n",
+ *ulen));
+ *code = "International EBCDIC";
+ *code_mime = "ebcdic";
+ } else { /* Doesn't look like text at all */
+ DPRINTF(("binary\n"));
+ rv = 0;
+ *type = "binary";
+ }
+ }
+
+ done:
+ free(nbuf);
+
+ return rv;
+}
+
+/*
+ * This table reflects a particular philosophy about what constitutes
+ * "text," and there is room for disagreement about it.
+ *
+ * Version 3.31 of the file command considered a file to be ASCII if
+ * each of its characters was approved by either the isascii() or
+ * isalpha() function. On most systems, this would mean that any
+ * file consisting only of characters in the range 0x00 ... 0x7F
+ * would be called ASCII text, but many systems might reasonably
+ * consider some characters outside this range to be alphabetic,
+ * so the file command would call such characters ASCII. It might
+ * have been more accurate to call this "considered textual on the
+ * local system" than "ASCII."
+ *
+ * It considered a file to be "International language text" if each
+ * of its characters was either an ASCII printing character (according
+ * to the real ASCII standard, not the above test), a character in
+ * the range 0x80 ... 0xFF, or one of the following control characters:
+ * backspace, tab, line feed, vertical tab, form feed, carriage return,
+ * escape. No attempt was made to determine the language in which files
+ * of this type were written.
+ *
+ *
+ * The table below considers a file to be ASCII if all of its characters
+ * are either ASCII printing characters (again, according to the X3.4
+ * standard, not isascii()) or any of the following controls: bell,
+ * backspace, tab, line feed, form feed, carriage return, esc, nextline.
+ *
+ * I include bell because some programs (particularly shell scripts)
+ * use it literally, even though it is rare in normal text. I exclude
+ * vertical tab because it never seems to be used in real text. I also
+ * include, with hesitation, the X3.64/ECMA-43 control nextline (0x85),
+ * because that's what the dd EBCDIC->ASCII table maps the EBCDIC newline
+ * character to. It might be more appropriate to include it in the 8859
+ * set instead of the ASCII set, but it's got to be included in *something*
+ * we recognize or EBCDIC files aren't going to be considered textual.
+ * Some old Unix source files use SO/SI (^N/^O) to shift between Greek
+ * and Latin characters, so these should possibly be allowed. But they
+ * make a real mess on VT100-style displays if they're not paired properly,
+ * so we are probably better off not calling them text.
+ *
+ * A file is considered to be ISO-8859 text if its characters are all
+ * either ASCII, according to the above definition, or printing characters
+ * from the ISO-8859 8-bit extension, characters 0xA0 ... 0xFF.
+ *
+ * Finally, a file is considered to be international text from some other
+ * character code if its characters are all either ISO-8859 (according to
+ * the above definition) or characters in the range 0x80 ... 0x9F, which
+ * ISO-8859 considers to be control characters but the IBM PC and Macintosh
+ * consider to be printing characters.
+ */
+
+#define F 0 /* character never appears in text */
+#define T 1 /* character appears in plain ASCII text */
+#define I 2 /* character appears in ISO-8859 text */
+#define X 3 /* character appears in non-ISO extended ASCII (Mac, IBM PC) */
+
+private char text_chars[256] = {
+ /* BEL BS HT LF VT FF CR */
+ F, F, F, F, F, F, F, T, T, T, T, T, T, T, F, F, /* 0x0X */
+ /* ESC */
+ F, F, F, F, F, F, F, F, F, F, F, T, F, F, F, F, /* 0x1X */
+ T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x2X */
+ T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x3X */
+ T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x4X */
+ T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x5X */
+ T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x6X */
+ T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, F, /* 0x7X */
+ /* NEL */
+ X, X, X, X, X, T, X, X, X, X, X, X, X, X, X, X, /* 0x8X */
+ X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, /* 0x9X */
+ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xaX */
+ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xbX */
+ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xcX */
+ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xdX */
+ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xeX */
+ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I /* 0xfX */
+};
+
+private int
+looks_ascii(const unsigned char *buf, size_t nbytes, unichar *ubuf,
+ size_t *ulen)
+{
+ size_t i;
+
+ *ulen = 0;
+
+ for (i = 0; i < nbytes; i++) {
+ int t = text_chars[buf[i]];
+
+ if (t != T)
+ return 0;
+
+ ubuf[(*ulen)++] = buf[i];
+ }
+
+ return 1;
+}
+
+private int
+looks_latin1(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen)
+{
+ size_t i;
+
+ *ulen = 0;
+
+ for (i = 0; i < nbytes; i++) {
+ int t = text_chars[buf[i]];
+
+ if (t != T && t != I)
+ return 0;
+
+ ubuf[(*ulen)++] = buf[i];
+ }
+
+ return 1;
+}
+
+private int
+looks_extended(const unsigned char *buf, size_t nbytes, unichar *ubuf,
+ size_t *ulen)
+{
+ size_t i;
+
+ *ulen = 0;
+
+ for (i = 0; i < nbytes; i++) {
+ int t = text_chars[buf[i]];
+
+ if (t != T && t != I && t != X)
+ return 0;
+
+ ubuf[(*ulen)++] = buf[i];
+ }
+
+ return 1;
+}
+
+/*
+ * Decide whether some text looks like UTF-8. Returns:
+ *
+ * -1: invalid UTF-8
+ * 0: uses odd control characters, so doesn't look like text
+ * 1: 7-bit text
+ * 2: definitely UTF-8 text (valid high-bit set bytes)
+ *
+ * If ubuf is non-NULL on entry, text is decoded into ubuf, *ulen;
+ * ubuf must be big enough!
+ */
+protected int
+file_looks_utf8(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen)
+{
+ size_t i;
+ int n;
+ unichar c;
+ int gotone = 0, ctrl = 0;
+
+ if (ubuf)
+ *ulen = 0;
+
+ for (i = 0; i < nbytes; i++) {
+ if ((buf[i] & 0x80) == 0) { /* 0xxxxxxx is plain ASCII */
+ /*
+ * Even if the whole file is valid UTF-8 sequences,
+ * still reject it if it uses weird control characters.
+ */
+
+ if (text_chars[buf[i]] != T)
+ ctrl = 1;
+
+ if (ubuf)
+ ubuf[(*ulen)++] = buf[i];
+ } else if ((buf[i] & 0x40) == 0) { /* 10xxxxxx never 1st byte */
+ return -1;
+ } else { /* 11xxxxxx begins UTF-8 */
+ int following;
+
+ if ((buf[i] & 0x20) == 0) { /* 110xxxxx */
+ c = buf[i] & 0x1f;
+ following = 1;
+ } else if ((buf[i] & 0x10) == 0) { /* 1110xxxx */
+ c = buf[i] & 0x0f;
+ following = 2;
+ } else if ((buf[i] & 0x08) == 0) { /* 11110xxx */
+ c = buf[i] & 0x07;
+ following = 3;
+ } else if ((buf[i] & 0x04) == 0) { /* 111110xx */
+ c = buf[i] & 0x03;
+ following = 4;
+ } else if ((buf[i] & 0x02) == 0) { /* 1111110x */
+ c = buf[i] & 0x01;
+ following = 5;
+ } else
+ return -1;
+
+ for (n = 0; n < following; n++) {
+ i++;
+ if (i >= nbytes)
+ goto done;
+
+ if ((buf[i] & 0x80) == 0 || (buf[i] & 0x40))
+ return -1;
+
+ c = (c << 6) + (buf[i] & 0x3f);
+ }
+
+ if (ubuf)
+ ubuf[(*ulen)++] = c;
+ gotone = 1;
+ }
+ }
+done:
+ return ctrl ? 0 : (gotone ? 2 : 1);
+}
+
+/*
+ * Decide whether some text looks like UTF-8 with BOM. If there is no
+ * BOM, return -1; otherwise return the result of looks_utf8 on the
+ * rest of the text.
+ */
+private int
+looks_utf8_with_BOM(const unsigned char *buf, size_t nbytes, unichar *ubuf,
+ size_t *ulen)
+{
+ if (nbytes > 3 && buf[0] == 0xef && buf[1] == 0xbb && buf[2] == 0xbf)
+ return file_looks_utf8(buf + 3, nbytes - 3, ubuf, ulen);
+ else
+ return -1;
+}
+
+private int
+looks_utf7(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen)
+{
+ if (nbytes > 4 && buf[0] == '+' && buf[1] == '/' && buf[2] == 'v')
+ switch (buf[3]) {
+ case '8':
+ case '9':
+ case '+':
+ case '/':
+ if (ubuf)
+ *ulen = 0;
+ return 1;
+ default:
+ return -1;
+ }
+ else
+ return -1;
+}
+
+private int
+looks_ucs16(const unsigned char *buf, size_t nbytes, unichar *ubuf,
+ size_t *ulen)
+{
+ int bigend;
+ size_t i;
+
+ if (nbytes < 2)
+ return 0;
+
+ if (buf[0] == 0xff && buf[1] == 0xfe)
+ bigend = 0;
+ else if (buf[0] == 0xfe && buf[1] == 0xff)
+ bigend = 1;
+ else
+ return 0;
+
+ *ulen = 0;
+
+ for (i = 2; i + 1 < nbytes; i += 2) {
+ /* XXX fix to properly handle chars > 65536 */
+
+ if (bigend)
+ ubuf[(*ulen)++] = buf[i + 1] + 256 * buf[i];
+ else
+ ubuf[(*ulen)++] = buf[i] + 256 * buf[i + 1];
+
+ if (ubuf[*ulen - 1] == 0xfffe)
+ return 0;
+ if (ubuf[*ulen - 1] < 128 &&
+ text_chars[(size_t)ubuf[*ulen - 1]] != T)
+ return 0;
+ }
+
+ return 1 + bigend;
+}
+
+#undef F
+#undef T
+#undef I
+#undef X
+
+/*
+ * This table maps each EBCDIC character to an (8-bit extended) ASCII
+ * character, as specified in the rationale for the dd(1) command in
+ * draft 11.2 (September, 1991) of the POSIX P1003.2 standard.
+ *
+ * Unfortunately it does not seem to correspond exactly to any of the
+ * five variants of EBCDIC documented in IBM's _Enterprise Systems
+ * Architecture/390: Principles of Operation_, SA22-7201-06, Seventh
+ * Edition, July, 1999, pp. I-1 - I-4.
+ *
+ * Fortunately, though, all versions of EBCDIC, including this one, agree
+ * on most of the printing characters that also appear in (7-bit) ASCII.
+ * Of these, only '|', '!', '~', '^', '[', and ']' are in question at all.
+ *
+ * Fortunately too, there is general agreement that codes 0x00 through
+ * 0x3F represent control characters, 0x41 a nonbreaking space, and the
+ * remainder printing characters.
+ *
+ * This is sufficient to allow us to identify EBCDIC text and to distinguish
+ * between old-style and internationalized examples of text.
+ */
+
+private unsigned char ebcdic_to_ascii[] = {
+ 0, 1, 2, 3, 156, 9, 134, 127, 151, 141, 142, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 157, 133, 8, 135, 24, 25, 146, 143, 28, 29, 30, 31,
+128, 129, 130, 131, 132, 10, 23, 27, 136, 137, 138, 139, 140, 5, 6, 7,
+144, 145, 22, 147, 148, 149, 150, 4, 152, 153, 154, 155, 20, 21, 158, 26,
+' ', 160, 161, 162, 163, 164, 165, 166, 167, 168, 213, '.', '<', '(', '+', '|',
+'&', 169, 170, 171, 172, 173, 174, 175, 176, 177, '!', '$', '*', ')', ';', '~',
+'-', '/', 178, 179, 180, 181, 182, 183, 184, 185, 203, ',', '%', '_', '>', '?',
+186, 187, 188, 189, 190, 191, 192, 193, 194, '`', ':', '#', '@', '\'','=', '"',
+195, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 196, 197, 198, 199, 200, 201,
+202, 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', '^', 204, 205, 206, 207, 208,
+209, 229, 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 210, 211, 212, '[', 214, 215,
+216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, ']', 230, 231,
+'{', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 232, 233, 234, 235, 236, 237,
+'}', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 238, 239, 240, 241, 242, 243,
+'\\',159, 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 244, 245, 246, 247, 248, 249,
+'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 250, 251, 252, 253, 254, 255
+};
+
+#ifdef notdef
+/*
+ * The following EBCDIC-to-ASCII table may relate more closely to reality,
+ * or at least to modern reality. It comes from
+ *
+ * http://ftp.s390.ibm.com/products/oe/bpxqp9.html
+ *
+ * and maps the characters of EBCDIC code page 1047 (the code used for
+ * Unix-derived software on IBM's 390 systems) to the corresponding
+ * characters from ISO 8859-1.
+ *
+ * If this table is used instead of the above one, some of the special
+ * cases for the NEL character can be taken out of the code.
+ */
+
+private unsigned char ebcdic_1047_to_8859[] = {
+0x00,0x01,0x02,0x03,0x9C,0x09,0x86,0x7F,0x97,0x8D,0x8E,0x0B,0x0C,0x0D,0x0E,0x0F,
+0x10,0x11,0x12,0x13,0x9D,0x0A,0x08,0x87,0x18,0x19,0x92,0x8F,0x1C,0x1D,0x1E,0x1F,
+0x80,0x81,0x82,0x83,0x84,0x85,0x17,0x1B,0x88,0x89,0x8A,0x8B,0x8C,0x05,0x06,0x07,
+0x90,0x91,0x16,0x93,0x94,0x95,0x96,0x04,0x98,0x99,0x9A,0x9B,0x14,0x15,0x9E,0x1A,
+0x20,0xA0,0xE2,0xE4,0xE0,0xE1,0xE3,0xE5,0xE7,0xF1,0xA2,0x2E,0x3C,0x28,0x2B,0x7C,
+0x26,0xE9,0xEA,0xEB,0xE8,0xED,0xEE,0xEF,0xEC,0xDF,0x21,0x24,0x2A,0x29,0x3B,0x5E,
+0x2D,0x2F,0xC2,0xC4,0xC0,0xC1,0xC3,0xC5,0xC7,0xD1,0xA6,0x2C,0x25,0x5F,0x3E,0x3F,
+0xF8,0xC9,0xCA,0xCB,0xC8,0xCD,0xCE,0xCF,0xCC,0x60,0x3A,0x23,0x40,0x27,0x3D,0x22,
+0xD8,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0xAB,0xBB,0xF0,0xFD,0xFE,0xB1,
+0xB0,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,0x70,0x71,0x72,0xAA,0xBA,0xE6,0xB8,0xC6,0xA4,
+0xB5,0x7E,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0xA1,0xBF,0xD0,0x5B,0xDE,0xAE,
+0xAC,0xA3,0xA5,0xB7,0xA9,0xA7,0xB6,0xBC,0xBD,0xBE,0xDD,0xA8,0xAF,0x5D,0xB4,0xD7,
+0x7B,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0xAD,0xF4,0xF6,0xF2,0xF3,0xF5,
+0x7D,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,0x50,0x51,0x52,0xB9,0xFB,0xFC,0xF9,0xFA,0xFF,
+0x5C,0xF7,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0xB2,0xD4,0xD6,0xD2,0xD3,0xD5,
+0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0xB3,0xDB,0xDC,0xD9,0xDA,0x9F
+};
+#endif
+
+/*
+ * Copy buf[0 ... nbytes-1] into out[], translating EBCDIC to ASCII.
+ */
+private void
+from_ebcdic(const unsigned char *buf, size_t nbytes, unsigned char *out)
+{
+ size_t i;
+
+ for (i = 0; i < nbytes; i++) {
+ out[i] = ebcdic_to_ascii[buf[i]];
+ }
+}
diff --git a/node_modules/mmmagic/deps/libmagic/src/file.c b/node_modules/mmmagic/deps/libmagic/src/file.c
new file mode 100644
index 0000000..861a824
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/file.c
@@ -0,0 +1,640 @@
+/*
+ * Copyright (c) Ian F. Darwin 1986-1995.
+ * Software written by Ian F. Darwin and others;
+ * maintained 1995-present by Christos Zoulas and others.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice immediately at the beginning of the file, without modification,
+ * this list of conditions, and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+/*
+ * file - find type of a file or files - main program.
+ */
+
+#include "file.h"
+
+#ifndef lint
+FILE_RCSID("@(#)$File: file.c,v 1.172 2016/10/24 15:21:07 christos Exp $")
+#endif /* lint */
+
+#include "magic.h"
+
+#include <stdlib.h>
+// XXX: change by mscdex
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <string.h>
+#ifdef RESTORE_TIME
+# if (__COHERENT__ >= 0x420)
+# include <sys/utime.h>
+# else
+# ifdef USE_UTIMES
+# include <sys/time.h>
+# else
+# include <utime.h>
+# endif
+# endif
+#endif
+// XXX: change by mscdex
+#ifdef HAVE_UNISTD_H
+#include <unistd.h> /* for read() */
+#endif
+#ifdef HAVE_LOCALE_H
+#include <locale.h>
+#endif
+#ifdef HAVE_WCHAR_H
+#include <wchar.h>
+#endif
+
+#if defined(HAVE_GETOPT_H) && defined(HAVE_STRUCT_OPTION)
+#include <getopt.h>
+#ifndef HAVE_GETOPT_LONG
+int getopt_long(int argc, char * const *argv, const char *optstring, const struct option *longopts, int *longindex);
+#endif
+#else
+#include "mygetopt.h"
+#endif
+
+#ifdef S_IFLNK
+#define FILE_FLAGS "-bcEhikLlNnprsvzZ0"
+#else
+#define FILE_FLAGS "-bcEiklNnprsvzZ0"
+#endif
+
+# define USAGE \
+ "Usage: %s [" FILE_FLAGS \
+ "] [--apple] [--extension] [--mime-encoding] [--mime-type]\n" \
+ " [-e testname] [-F separator] [-f namefile] [-m magicfiles] " \
+ "file ...\n" \
+ " %s -C [-m magicfiles]\n" \
+ " %s [--help]\n"
+
+private int /* Global command-line options */
+ bflag = 0, /* brief output format */
+ nopad = 0, /* Don't pad output */
+ nobuffer = 0, /* Do not buffer stdout */
+ nulsep = 0; /* Append '\0' to the separator */
+
+private const char *separator = ":"; /* Default field separator */
+private const struct option long_options[] = {
+#define OPT_HELP 1
+#define OPT_APPLE 2
+#define OPT_EXTENSIONS 3
+#define OPT_MIME_TYPE 4
+#define OPT_MIME_ENCODING 5
+#define OPT(shortname, longname, opt, def, doc) \
+ {longname, opt, NULL, shortname},
+#define OPT_LONGONLY(longname, opt, def, doc, id) \
+ {longname, opt, NULL, id},
+#include "file_opts.h"
+#undef OPT
+#undef OPT_LONGONLY
+ {0, 0, NULL, 0}
+};
+#define OPTSTRING "bcCde:Ef:F:hiklLm:nNpP:rsvzZ0"
+
+private const struct {
+ const char *name;
+ int value;
+} nv[] = {
+ { "apptype", MAGIC_NO_CHECK_APPTYPE },
+ { "ascii", MAGIC_NO_CHECK_ASCII },
+ { "cdf", MAGIC_NO_CHECK_CDF },
+ { "compress", MAGIC_NO_CHECK_COMPRESS },
+ { "elf", MAGIC_NO_CHECK_ELF },
+ { "encoding", MAGIC_NO_CHECK_ENCODING },
+ { "soft", MAGIC_NO_CHECK_SOFT },
+ { "tar", MAGIC_NO_CHECK_TAR },
+ { "text", MAGIC_NO_CHECK_TEXT }, /* synonym for ascii */
+ { "tokens", MAGIC_NO_CHECK_TOKENS }, /* OBSOLETE: ignored for backwards compatibility */
+};
+
+private struct {
+ const char *name;
+ int tag;
+ size_t value;
+} pm[] = {
+ { "indir", MAGIC_PARAM_INDIR_MAX, 0 },
+ { "name", MAGIC_PARAM_NAME_MAX, 0 },
+ { "elf_phnum", MAGIC_PARAM_ELF_PHNUM_MAX, 0 },
+ { "elf_shnum", MAGIC_PARAM_ELF_SHNUM_MAX, 0 },
+ { "elf_notes", MAGIC_PARAM_ELF_NOTES_MAX, 0 },
+ { "regex", MAGIC_PARAM_REGEX_MAX, 0 },
+ { "bytes", MAGIC_PARAM_BYTES_MAX, 0 },
+};
+
+private char *progname; /* used throughout */
+private int posixly;
+
+#ifdef __dead
+__dead
+#endif
+private void usage(void);
+private void docprint(const char *, int);
+#ifdef __dead
+__dead
+#endif
+private void help(void);
+
+private int unwrap(struct magic_set *, const char *);
+private int process(struct magic_set *ms, const char *, int);
+private struct magic_set *load(const char *, int);
+private void setparam(const char *);
+private void applyparam(magic_t);
+
+
+/*
+ * main - parse arguments and handle options
+ */
+int
+main(int argc, char *argv[])
+{
+ int c;
+ size_t i;
+ int action = 0, didsomefiles = 0, errflg = 0;
+ int flags = 0, e = 0;
+ struct magic_set *magic = NULL;
+ int longindex;
+ const char *magicfile = NULL; /* where the magic is */
+
+ /* makes islower etc work for other langs */
+#ifdef HAVE_SETLOCALE
+ (void)setlocale(LC_CTYPE, "");
+#endif
+
+#ifdef __EMX__
+ /* sh-like wildcard expansion! Shouldn't hurt at least ... */
+ _wildcard(&argc, &argv);
+#endif
+
+ if ((progname = strrchr(argv[0], '/')) != NULL)
+ progname++;
+ else
+ progname = argv[0];
+
+#ifdef S_IFLNK
+ posixly = getenv("POSIXLY_CORRECT") != NULL;
+ flags |= posixly ? MAGIC_SYMLINK : 0;
+#endif
+ while ((c = getopt_long(argc, argv, OPTSTRING, long_options,
+ &longindex)) != -1)
+ switch (c) {
+ case OPT_HELP:
+ help();
+ break;
+ case OPT_APPLE:
+ flags |= MAGIC_APPLE;
+ break;
+ case OPT_EXTENSIONS:
+ flags |= MAGIC_EXTENSION;
+ break;
+ case OPT_MIME_TYPE:
+ flags |= MAGIC_MIME_TYPE;
+ break;
+ case OPT_MIME_ENCODING:
+ flags |= MAGIC_MIME_ENCODING;
+ break;
+ case '0':
+ nulsep++;
+ break;
+ case 'b':
+ bflag++;
+ break;
+ case 'c':
+ action = FILE_CHECK;
+ break;
+ case 'C':
+ action = FILE_COMPILE;
+ break;
+ case 'd':
+ flags |= MAGIC_DEBUG|MAGIC_CHECK;
+ break;
+ case 'E':
+ flags |= MAGIC_ERROR;
+ break;
+ case 'e':
+ for (i = 0; i < sizeof(nv) / sizeof(nv[0]); i++)
+ if (strcmp(nv[i].name, optarg) == 0)
+ break;
+
+ if (i == sizeof(nv) / sizeof(nv[0]))
+ errflg++;
+ else
+ flags |= nv[i].value;
+ break;
+
+ case 'f':
+ if(action)
+ usage();
+ if (magic == NULL)
+ if ((magic = load(magicfile, flags)) == NULL)
+ return 1;
+ applyparam(magic);
+ e |= unwrap(magic, optarg);
+ ++didsomefiles;
+ break;
+ case 'F':
+ separator = optarg;
+ break;
+ case 'i':
+ flags |= MAGIC_MIME;
+ break;
+ case 'k':
+ flags |= MAGIC_CONTINUE;
+ break;
+ case 'l':
+ action = FILE_LIST;
+ break;
+ case 'm':
+ magicfile = optarg;
+ break;
+ case 'n':
+ ++nobuffer;
+ break;
+ case 'N':
+ ++nopad;
+ break;
+#if defined(HAVE_UTIME) || defined(HAVE_UTIMES)
+ case 'p':
+ flags |= MAGIC_PRESERVE_ATIME;
+ break;
+#endif
+ case 'P':
+ setparam(optarg);
+ break;
+ case 'r':
+ flags |= MAGIC_RAW;
+ break;
+ case 's':
+ flags |= MAGIC_DEVICES;
+ break;
+ case 'v':
+ if (magicfile == NULL)
+ magicfile = magic_getpath(magicfile, action);
+ (void)fprintf(stdout, "%s-%s\n", progname, VERSION);
+ (void)fprintf(stdout, "magic file from %s\n",
+ magicfile);
+ return 0;
+ case 'z':
+ flags |= MAGIC_COMPRESS;
+ break;
+
+ case 'Z':
+ flags |= MAGIC_COMPRESS|MAGIC_COMPRESS_TRANSP;
+ break;
+#ifdef S_IFLNK
+ case 'L':
+ flags |= MAGIC_SYMLINK;
+ break;
+ case 'h':
+ flags &= ~MAGIC_SYMLINK;
+ break;
+#endif
+ case '?':
+ default:
+ errflg++;
+ break;
+ }
+
+ if (errflg) {
+ usage();
+ }
+ if (e)
+ return e;
+
+ if (MAGIC_VERSION != magic_version())
+ (void)fprintf(stderr, "%s: compiled magic version [%d] "
+ "does not match with shared library magic version [%d]\n",
+ progname, MAGIC_VERSION, magic_version());
+
+ switch(action) {
+ case FILE_CHECK:
+ case FILE_COMPILE:
+ case FILE_LIST:
+ /*
+ * Don't try to check/compile ~/.magic unless we explicitly
+ * ask for it.
+ */
+ magic = magic_open(flags|MAGIC_CHECK);
+ if (magic == NULL) {
+ (void)fprintf(stderr, "%s: %s\n", progname,
+ strerror(errno));
+ return 1;
+ }
+
+
+ switch(action) {
+ case FILE_CHECK:
+ c = magic_check(magic, magicfile);
+ break;
+ case FILE_COMPILE:
+ c = magic_compile(magic, magicfile);
+ break;
+ case FILE_LIST:
+ c = magic_list(magic, magicfile);
+ break;
+ default:
+ abort();
+ }
+ if (c == -1) {
+ (void)fprintf(stderr, "%s: %s\n", progname,
+ magic_error(magic));
+ e = 1;
+ goto out;
+ }
+ goto out;
+ default:
+ if (magic == NULL)
+ if ((magic = load(magicfile, flags)) == NULL)
+ return 1;
+ applyparam(magic);
+ }
+
+ if (optind == argc) {
+ if (!didsomefiles)
+ usage();
+ }
+ else {
+ size_t j, wid, nw;
+ for (wid = 0, j = (size_t)optind; j < (size_t)argc; j++) {
+ nw = file_mbswidth(argv[j]);
+ if (nw > wid)
+ wid = nw;
+ }
+ /*
+ * If bflag is only set twice, set it depending on
+ * number of files [this is undocumented, and subject to change]
+ */
+ if (bflag == 2) {
+ bflag = optind >= argc - 1;
+ }
+ for (; optind < argc; optind++)
+ e |= process(magic, argv[optind], wid);
+ }
+
+out:
+ if (magic)
+ magic_close(magic);
+ return e;
+}
+
+private void
+applyparam(magic_t magic)
+{
+ size_t i;
+
+ for (i = 0; i < __arraycount(pm); i++) {
+ if (pm[i].value == 0)
+ continue;
+ if (magic_setparam(magic, pm[i].tag, &pm[i].value) == -1) {
+ (void)fprintf(stderr, "%s: Can't set %s %s\n", progname,
+ pm[i].name, strerror(errno));
+ exit(1);
+ }
+ }
+}
+
+private void
+setparam(const char *p)
+{
+ size_t i;
+ char *s;
+
+ if ((s = strchr(p, '=')) == NULL)
+ goto badparm;
+
+ for (i = 0; i < __arraycount(pm); i++) {
+ if (strncmp(p, pm[i].name, s - p) != 0)
+ continue;
+ pm[i].value = atoi(s + 1);
+ return;
+ }
+badparm:
+ (void)fprintf(stderr, "%s: Unknown param %s\n", progname, p);
+ exit(1);
+}
+
+private struct magic_set *
+/*ARGSUSED*/
+load(const char *magicfile, int flags)
+{
+ struct magic_set *magic = magic_open(flags);
+ const char *e;
+
+ if (magic == NULL) {
+ (void)fprintf(stderr, "%s: %s\n", progname, strerror(errno));
+ return NULL;
+ }
+ if (magic_load(magic, magicfile) == -1) {
+ (void)fprintf(stderr, "%s: %s\n",
+ progname, magic_error(magic));
+ magic_close(magic);
+ return NULL;
+ }
+ if ((e = magic_error(magic)) != NULL)
+ (void)fprintf(stderr, "%s: Warning: %s\n", progname, e);
+ return magic;
+}
+
+/*
+ * unwrap -- read a file of filenames, do each one.
+ */
+private int
+unwrap(struct magic_set *ms, const char *fn)
+{
+ FILE *f;
+ ssize_t len;
+ char *line = NULL;
+ size_t llen = 0;
+ int wid = 0, cwid;
+ int e = 0;
+
+ if (strcmp("-", fn) == 0) {
+ f = stdin;
+ wid = 1;
+ } else {
+ if ((f = fopen(fn, "r")) == NULL) {
+ (void)fprintf(stderr, "%s: Cannot open `%s' (%s).\n",
+ progname, fn, strerror(errno));
+ return 1;
+ }
+
+ while ((len = getline(&line, &llen, f)) > 0) {
+ if (line[len - 1] == '\n')
+ line[len - 1] = '\0';
+ cwid = file_mbswidth(line);
+ if (cwid > wid)
+ wid = cwid;
+ }
+
+ rewind(f);
+ }
+
+ while ((len = getline(&line, &llen, f)) > 0) {
+ if (line[len - 1] == '\n')
+ line[len - 1] = '\0';
+ e |= process(ms, line, wid);
+ if(nobuffer)
+ (void)fflush(stdout);
+ }
+
+ free(line);
+ (void)fclose(f);
+ return e;
+}
+
+/*
+ * Called for each input file on the command line (or in a list of files)
+ */
+private int
+process(struct magic_set *ms, const char *inname, int wid)
+{
+ const char *type, c = nulsep > 1 ? '\0' : '\n';
+ int std_in = strcmp(inname, "-") == 0;
+
+ if (wid > 0 && !bflag) {
+ (void)printf("%s", std_in ? "/dev/stdin" : inname);
+ if (nulsep)
+ (void)putc('\0', stdout);
+ if (nulsep < 2) {
+ (void)printf("%s", separator);
+ (void)printf("%*s ",
+ (int) (nopad ? 0 : (wid - file_mbswidth(inname))),
+ "");
+ }
+ }
+
+ type = magic_file(ms, std_in ? NULL : inname);
+
+ if (type == NULL) {
+ (void)printf("ERROR: %s%c", magic_error(ms), c);
+ return 1;
+ } else {
+ (void)printf("%s%c", type, c);
+ return 0;
+ }
+}
+
+protected size_t
+file_mbswidth(const char *s)
+{
+#if defined(HAVE_WCHAR_H) && defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH)
+ size_t bytesconsumed, old_n, n, width = 0;
+ mbstate_t state;
+ wchar_t nextchar;
+ (void)memset(&state, 0, sizeof(mbstate_t));
+ old_n = n = strlen(s);
+
+ while (n > 0) {
+ bytesconsumed = mbrtowc(&nextchar, s, n, &state);
+ if (bytesconsumed == (size_t)(-1) ||
+ bytesconsumed == (size_t)(-2)) {
+ /* Something went wrong, return something reasonable */
+ return old_n;
+ }
+ if (s[0] == '\n') {
+ /*
+ * do what strlen() would do, so that caller
+ * is always right
+ */
+ width++;
+ } else {
+ int w = wcwidth(nextchar);
+ if (w > 0)
+ width += w;
+ }
+
+ s += bytesconsumed, n -= bytesconsumed;
+ }
+ return width;
+#else
+ return strlen(s);
+#endif
+}
+
+private void
+usage(void)
+{
+ (void)fprintf(stderr, USAGE, progname, progname, progname);
+ exit(1);
+}
+
+private void
+defprint(int def)
+{
+ if (!def)
+ return;
+ if (((def & 1) && posixly) || ((def & 2) && !posixly))
+ fprintf(stdout, " (default)");
+ fputc('\n', stdout);
+}
+
+private void
+docprint(const char *opts, int def)
+{
+ size_t i;
+ int comma;
+ char *sp, *p;
+
+ p = strstr(opts, "%o");
+ if (p == NULL) {
+ fprintf(stdout, "%s", opts);
+ defprint(def);
+ return;
+ }
+
+ for (sp = p - 1; sp > opts && *sp == ' '; sp--)
+ continue;
+
+ fprintf(stdout, "%.*s", (int)(p - opts), opts);
+
+ comma = 0;
+ for (i = 0; i < __arraycount(nv); i++) {
+ fprintf(stdout, "%s%s", comma++ ? ", " : "", nv[i].name);
+ if (i && i % 5 == 0) {
+ fprintf(stdout, ",\n%*s", (int)(p - sp - 1), "");
+ comma = 0;
+ }
+ }
+
+ fprintf(stdout, "%s", opts + (p - opts) + 2);
+}
+
+private void
+help(void)
+{
+ (void)fputs(
+"Usage: file [OPTION...] [FILE...]\n"
+"Determine type of FILEs.\n"
+"\n", stdout);
+#define OPT(shortname, longname, opt, def, doc) \
+ fprintf(stdout, " -%c, --" longname, shortname), \
+ docprint(doc, def);
+#define OPT_LONGONLY(longname, opt, def, doc, id) \
+ fprintf(stdout, " --" longname), \
+ docprint(doc, def);
+#include "file_opts.h"
+#undef OPT
+#undef OPT_LONGONLY
+ fprintf(stdout, "\nReport bugs to http://bugs.gw.com/\n");
+ exit(0);
+}
diff --git a/node_modules/mmmagic/deps/libmagic/src/file.h b/node_modules/mmmagic/deps/libmagic/src/file.h
new file mode 100644
index 0000000..9930710
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/file.h
@@ -0,0 +1,653 @@
+/*
+ * Copyright (c) Ian F. Darwin 1986-1995.
+ * Software written by Ian F. Darwin and others;
+ * maintained 1995-present by Christos Zoulas and others.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice immediately at the beginning of the file, without modification,
+ * this list of conditions, and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+/*
+ * file.h - definitions for file(1) program
+ * @(#)$File: file.h,v 1.183 2017/08/28 13:39:18 christos Exp $
+ */
+
+#ifndef __file_h__
+#define __file_h__
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef HAVE_STDINT_H
+#ifndef __STDC_LIMIT_MACROS
+#define __STDC_LIMIT_MACROS
+#endif
+
+// XXX: change by mscdex
+#ifdef _MSC_VER
+typedef unsigned int mode_t;
+# ifdef _WIN64
+ typedef __int64 ssize_t;
+ typedef unsigned __int64 size_t;
+# else
+ typedef _W64 int ssize_t;
+ typedef _W64 unsigned int size_t;
+# endif
+# include <io.h>
+# define access _access
+# define lseek _lseek
+# define read _read
+# define X_OK 1 /* MS access() doesn't check for execute permission. */
+# define W_OK 2 /* Check for write permission */
+# define R_OK 4 /* Check for read permission */
+# include <sys/utime.h>
+# include <dirent.h>
+# undef S_IFLNK
+# undef S_IFSOCK
+# ifndef S_IFFIFO
+# ifdef _S_IFIFO
+# define S_IFFIFO _S_IFIFO
+# else
+# define S_IFFIFO 0
+# endif
+# endif
+# define strtoull _strtoui64
+# define STDIN_FILENO 0
+#else
+# include <unistd.h>
+#endif
+
+#ifdef WIN32
+ #ifdef _WIN64
+ #define SIZE_T_FORMAT "I64"
+ #else
+ #define SIZE_T_FORMAT ""
+ #endif
+ #define INT64_T_FORMAT "I64"
+ #define INTMAX_T_FORMAT "I64"
+#else
+ #define SIZE_T_FORMAT "z"
+ #define INT64_T_FORMAT "ll"
+ #define INTMAX_T_FORMAT "j"
+#endif
+#include <stdint.h>
+#endif
+
+#include <stdio.h> /* Include that here, to make sure __P gets defined */
+#include <errno.h>
+#include <fcntl.h> /* For open and flags */
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
+#include <regex.h>
+#include <time.h>
+#include <sys/types.h>
+// XXX: change by mscdex
+#ifndef _MSC_VER
+#include <sys/param.h>
+#endif
+/* Do this here and now, because struct stat gets re-defined on solaris */
+#include <sys/stat.h>
+#include <stdarg.h>
+
+#define ENABLE_CONDITIONALS
+
+#ifndef MAGIC
+#define MAGIC "/etc/magic"
+#endif
+
+#if defined(__EMX__) || defined (WIN32)
+#define PATHSEP ';'
+#else
+#define PATHSEP ':'
+#endif
+
+#define private static
+
+#if HAVE_VISIBILITY && !defined(WIN32)
+#define public __attribute__ ((__visibility__("default")))
+#ifndef protected
+#define protected __attribute__ ((__visibility__("hidden")))
+#endif
+#else
+#define public
+#ifndef protected
+#define protected
+#endif
+#endif
+
+#ifndef __arraycount
+#define __arraycount(a) (sizeof(a) / sizeof(a[0]))
+#endif
+
+#ifndef __GNUC_PREREQ__
+#ifdef __GNUC__
+#define __GNUC_PREREQ__(x, y) \
+ ((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) || \
+ (__GNUC__ > (x)))
+#else
+#define __GNUC_PREREQ__(x, y) 0
+#endif
+#endif
+
+#ifndef __GNUC__
+#ifndef __attribute__
+#define __attribute__(a)
+#endif
+#endif
+
+#ifndef MIN
+#define MIN(a,b) (((a) < (b)) ? (a) : (b))
+#endif
+
+#ifndef MAX
+#define MAX(a,b) (((a) > (b)) ? (a) : (b))
+#endif
+
+#ifndef FILE_BYTES_MAX
+# define FILE_BYTES_MAX (1024 * 1024) /* how much of the file to look at */
+#endif
+#define MAXMAGIS 8192 /* max entries in any one magic file
+ or directory */
+#define MAXDESC 64 /* max len of text description/MIME type */
+#define MAXMIME 80 /* max len of text MIME type */
+#define MAXstring 96 /* max len of "string" types */
+
+#define MAGICNO 0xF11E041C
+#define VERSIONNO 14
+#define FILE_MAGICSIZE 344
+
+#define FILE_LOAD 0
+#define FILE_CHECK 1
+#define FILE_COMPILE 2
+#define FILE_LIST 3
+
+union VALUETYPE {
+ uint8_t b;
+ uint16_t h;
+ uint32_t l;
+ uint64_t q;
+ uint8_t hs[2]; /* 2 bytes of a fixed-endian "short" */
+ uint8_t hl[4]; /* 4 bytes of a fixed-endian "long" */
+ uint8_t hq[8]; /* 8 bytes of a fixed-endian "quad" */
+ char s[MAXstring]; /* the search string or regex pattern */
+ unsigned char us[MAXstring];
+ float f;
+ double d;
+};
+
+struct magic {
+ /* Word 1 */
+ uint16_t cont_level; /* level of ">" */
+ uint8_t flag;
+#define INDIR 0x01 /* if '(...)' appears */
+#define OFFADD 0x02 /* if '>&' or '>...(&' appears */
+#define INDIROFFADD 0x04 /* if '>&(' appears */
+#define UNSIGNED 0x08 /* comparison is unsigned */
+#define NOSPACE 0x10 /* suppress space character before output */
+#define BINTEST 0x20 /* test is for a binary type (set only
+ for top-level tests) */
+#define TEXTTEST 0x40 /* for passing to file_softmagic */
+
+ uint8_t factor;
+
+ /* Word 2 */
+ uint8_t reln; /* relation (0=eq, '>'=gt, etc) */
+ uint8_t vallen; /* length of string value, if any */
+ uint8_t type; /* comparison type (FILE_*) */
+ uint8_t in_type; /* type of indirection */
+#define FILE_INVALID 0
+#define FILE_BYTE 1
+#define FILE_SHORT 2
+#define FILE_DEFAULT 3
+#define FILE_LONG 4
+#define FILE_STRING 5
+#define FILE_DATE 6
+#define FILE_BESHORT 7
+#define FILE_BELONG 8
+#define FILE_BEDATE 9
+#define FILE_LESHORT 10
+#define FILE_LELONG 11
+#define FILE_LEDATE 12
+#define FILE_PSTRING 13
+#define FILE_LDATE 14
+#define FILE_BELDATE 15
+#define FILE_LELDATE 16
+#define FILE_REGEX 17
+#define FILE_BESTRING16 18
+#define FILE_LESTRING16 19
+#define FILE_SEARCH 20
+#define FILE_MEDATE 21
+#define FILE_MELDATE 22
+#define FILE_MELONG 23
+#define FILE_QUAD 24
+#define FILE_LEQUAD 25
+#define FILE_BEQUAD 26
+#define FILE_QDATE 27
+#define FILE_LEQDATE 28
+#define FILE_BEQDATE 29
+#define FILE_QLDATE 30
+#define FILE_LEQLDATE 31
+#define FILE_BEQLDATE 32
+#define FILE_FLOAT 33
+#define FILE_BEFLOAT 34
+#define FILE_LEFLOAT 35
+#define FILE_DOUBLE 36
+#define FILE_BEDOUBLE 37
+#define FILE_LEDOUBLE 38
+#define FILE_BEID3 39
+#define FILE_LEID3 40
+#define FILE_INDIRECT 41
+#define FILE_QWDATE 42
+#define FILE_LEQWDATE 43
+#define FILE_BEQWDATE 44
+#define FILE_NAME 45
+#define FILE_USE 46
+#define FILE_CLEAR 47
+#define FILE_DER 48
+#define FILE_NAMES_SIZE 49 /* size of array to contain all names */
+
+#define IS_STRING(t) \
+ ((t) == FILE_STRING || \
+ (t) == FILE_PSTRING || \
+ (t) == FILE_BESTRING16 || \
+ (t) == FILE_LESTRING16 || \
+ (t) == FILE_REGEX || \
+ (t) == FILE_SEARCH || \
+ (t) == FILE_INDIRECT || \
+ (t) == FILE_NAME || \
+ (t) == FILE_USE)
+
+#define FILE_FMT_NONE 0
+#define FILE_FMT_NUM 1 /* "cduxXi" */
+#define FILE_FMT_STR 2 /* "s" */
+#define FILE_FMT_QUAD 3 /* "ll" */
+#define FILE_FMT_FLOAT 4 /* "eEfFgG" */
+#define FILE_FMT_DOUBLE 5 /* "eEfFgG" */
+
+ /* Word 3 */
+ uint8_t in_op; /* operator for indirection */
+ uint8_t mask_op; /* operator for mask */
+#ifdef ENABLE_CONDITIONALS
+ uint8_t cond; /* conditional type */
+#else
+ uint8_t dummy;
+#endif
+ uint8_t factor_op;
+#define FILE_FACTOR_OP_PLUS '+'
+#define FILE_FACTOR_OP_MINUS '-'
+#define FILE_FACTOR_OP_TIMES '*'
+#define FILE_FACTOR_OP_DIV '/'
+#define FILE_FACTOR_OP_NONE '\0'
+
+#define FILE_OPS "&|^+-*/%"
+#define FILE_OPAND 0
+#define FILE_OPOR 1
+#define FILE_OPXOR 2
+#define FILE_OPADD 3
+#define FILE_OPMINUS 4
+#define FILE_OPMULTIPLY 5
+#define FILE_OPDIVIDE 6
+#define FILE_OPMODULO 7
+#define FILE_OPS_MASK 0x07 /* mask for above ops */
+#define FILE_UNUSED_1 0x08
+#define FILE_UNUSED_2 0x10
+#define FILE_OPSIGNED 0x20
+#define FILE_OPINVERSE 0x40
+#define FILE_OPINDIRECT 0x80
+
+#ifdef ENABLE_CONDITIONALS
+#define COND_NONE 0
+#define COND_IF 1
+#define COND_ELIF 2
+#define COND_ELSE 3
+#endif /* ENABLE_CONDITIONALS */
+
+ /* Word 4 */
+ uint32_t offset; /* offset to magic number */
+ /* Word 5 */
+ int32_t in_offset; /* offset from indirection */
+ /* Word 6 */
+ uint32_t lineno; /* line number in magic file */
+ /* Word 7,8 */
+ union {
+ uint64_t _mask; /* for use with numeric and date types */
+ struct {
+ uint32_t _count; /* repeat/line count */
+ uint32_t _flags; /* modifier flags */
+ } _s; /* for use with string types */
+ } _u;
+#define num_mask _u._mask
+#define str_range _u._s._count
+#define str_flags _u._s._flags
+ /* Words 9-24 */
+ union VALUETYPE value; /* either number or string */
+ /* Words 25-40 */
+ char desc[MAXDESC]; /* description */
+ /* Words 41-60 */
+ char mimetype[MAXMIME]; /* MIME type */
+ /* Words 61-62 */
+ char apple[8]; /* APPLE CREATOR/TYPE */
+ /* Words 63-78 */
+ char ext[64]; /* Popular extensions */
+};
+
+#define BIT(A) (1 << (A))
+#define STRING_COMPACT_WHITESPACE BIT(0)
+#define STRING_COMPACT_OPTIONAL_WHITESPACE BIT(1)
+#define STRING_IGNORE_LOWERCASE BIT(2)
+#define STRING_IGNORE_UPPERCASE BIT(3)
+#define REGEX_OFFSET_START BIT(4)
+#define STRING_TEXTTEST BIT(5)
+#define STRING_BINTEST BIT(6)
+#define PSTRING_1_BE BIT(7)
+#define PSTRING_1_LE BIT(7)
+#define PSTRING_2_BE BIT(8)
+#define PSTRING_2_LE BIT(9)
+#define PSTRING_4_BE BIT(10)
+#define PSTRING_4_LE BIT(11)
+#define REGEX_LINE_COUNT BIT(11)
+#define PSTRING_LEN \
+ (PSTRING_1_BE|PSTRING_2_LE|PSTRING_2_BE|PSTRING_4_LE|PSTRING_4_BE)
+#define PSTRING_LENGTH_INCLUDES_ITSELF BIT(12)
+#define STRING_TRIM BIT(13)
+#define CHAR_COMPACT_WHITESPACE 'W'
+#define CHAR_COMPACT_OPTIONAL_WHITESPACE 'w'
+#define CHAR_IGNORE_LOWERCASE 'c'
+#define CHAR_IGNORE_UPPERCASE 'C'
+#define CHAR_REGEX_OFFSET_START 's'
+#define CHAR_TEXTTEST 't'
+#define CHAR_TRIM 'T'
+#define CHAR_BINTEST 'b'
+#define CHAR_PSTRING_1_BE 'B'
+#define CHAR_PSTRING_1_LE 'B'
+#define CHAR_PSTRING_2_BE 'H'
+#define CHAR_PSTRING_2_LE 'h'
+#define CHAR_PSTRING_4_BE 'L'
+#define CHAR_PSTRING_4_LE 'l'
+#define CHAR_PSTRING_LENGTH_INCLUDES_ITSELF 'J'
+#define STRING_IGNORE_CASE (STRING_IGNORE_LOWERCASE|STRING_IGNORE_UPPERCASE)
+#define STRING_DEFAULT_RANGE 100
+
+#define INDIRECT_RELATIVE BIT(0)
+#define CHAR_INDIRECT_RELATIVE 'r'
+
+/* list of magic entries */
+struct mlist {
+ struct magic *magic; /* array of magic entries */
+ uint32_t nmagic; /* number of entries in array */
+ void *map; /* internal resources used by entry */
+ struct mlist *next, *prev;
+};
+
+#ifdef __cplusplus
+#define CAST(T, b) static_cast<T>(b)
+#define RCAST(T, b) reinterpret_cast<T>(b)
+#define CCAST(T, b) const_cast<T>(b)
+#else
+#define CAST(T, b) ((T)(b))
+#define RCAST(T, b) ((T)(b))
+#define CCAST(T, b) ((T)(uintptr_t)(b))
+#endif
+
+struct level_info {
+ int32_t off;
+ int got_match;
+#ifdef ENABLE_CONDITIONALS
+ int last_match;
+ int last_cond; /* used for error checking by parse() */
+#endif
+};
+
+#define MAGIC_SETS 2
+
+struct magic_set {
+ struct mlist *mlist[MAGIC_SETS]; /* list of regular entries */
+ struct cont {
+ size_t len;
+ struct level_info *li;
+ } c;
+ struct out {
+ char *buf; /* Accumulation buffer */
+ char *pbuf; /* Printable buffer */
+ } o;
+ uint32_t offset;
+ int error;
+ int flags; /* Control magic tests. */
+ int event_flags; /* Note things that happened. */
+#define EVENT_HAD_ERR 0x01
+ const char *file;
+ size_t line; /* current magic line number */
+
+ /* data for searches */
+ struct {
+ const char *s; /* start of search in original source */
+ size_t s_len; /* length of search region */
+ size_t offset; /* starting offset in source: XXX - should this be off_t? */
+ size_t rm_len; /* match length */
+ } search;
+
+ /* FIXME: Make the string dynamically allocated so that e.g.
+ strings matched in files can be longer than MAXstring */
+ union VALUETYPE ms_value; /* either number or string */
+ uint16_t indir_max;
+ uint16_t name_max;
+ uint16_t elf_shnum_max;
+ uint16_t elf_phnum_max;
+ uint16_t elf_notes_max;
+ uint16_t regex_max;
+ size_t bytes_max; /* number of bytes to read from file */
+#define FILE_INDIR_MAX 50
+#define FILE_NAME_MAX 30
+#define FILE_ELF_SHNUM_MAX 32768
+#define FILE_ELF_PHNUM_MAX 2048
+#define FILE_ELF_NOTES_MAX 256
+#define FILE_REGEX_MAX 8192
+};
+
+/* Type for Unicode characters */
+typedef unsigned long unichar;
+
+struct stat;
+#define FILE_T_LOCAL 1
+#define FILE_T_WINDOWS 2
+protected const char *file_fmttime(uint64_t, int, char *);
+protected struct magic_set *file_ms_alloc(int);
+protected void file_ms_free(struct magic_set *);
+protected int file_buffer(struct magic_set *, int, const char *, const void *,
+ size_t);
+protected int file_fsmagic(struct magic_set *, const char *, struct stat *);
+protected int file_pipe2file(struct magic_set *, int, const void *, size_t);
+protected int file_vprintf(struct magic_set *, const char *, va_list)
+ __attribute__((__format__(__printf__, 2, 0)));
+protected size_t file_printedlen(const struct magic_set *);
+protected int file_replace(struct magic_set *, const char *, const char *);
+protected int file_printf(struct magic_set *, const char *, ...)
+ __attribute__((__format__(__printf__, 2, 3)));
+protected int file_reset(struct magic_set *, int);
+protected int file_tryelf(struct magic_set *, int, const unsigned char *,
+ size_t);
+protected int file_trycdf(struct magic_set *, int, const unsigned char *,
+ size_t);
+#if HAVE_FORK
+protected int file_zmagic(struct magic_set *, int, const char *,
+ const unsigned char *, size_t);
+#endif
+protected int file_ascmagic(struct magic_set *, const unsigned char *, size_t,
+ int);
+protected int file_ascmagic_with_encoding(struct magic_set *,
+ const unsigned char *, size_t, unichar *, size_t, const char *,
+ const char *, int);
+protected int file_encoding(struct magic_set *, const unsigned char *, size_t,
+ unichar **, size_t *, const char **, const char **, const char **);
+protected int file_is_tar(struct magic_set *, const unsigned char *, size_t);
+protected int file_softmagic(struct magic_set *, const unsigned char *, size_t,
+ uint16_t *, uint16_t *, int, int);
+protected int file_apprentice(struct magic_set *, const char *, int);
+protected int buffer_apprentice(struct magic_set *, struct magic **,
+ size_t *, size_t);
+protected int file_magicfind(struct magic_set *, const char *, struct mlist *);
+protected uint64_t file_signextend(struct magic_set *, struct magic *,
+ uint64_t);
+protected void file_badread(struct magic_set *);
+protected void file_badseek(struct magic_set *);
+protected void file_oomem(struct magic_set *, size_t);
+protected void file_error(struct magic_set *, int, const char *, ...)
+ __attribute__((__format__(__printf__, 3, 4)));
+protected void file_magerror(struct magic_set *, const char *, ...)
+ __attribute__((__format__(__printf__, 2, 3)));
+protected void file_magwarn(struct magic_set *, const char *, ...)
+ __attribute__((__format__(__printf__, 2, 3)));
+protected void file_mdump(struct magic *);
+protected void file_showstr(FILE *, const char *, size_t);
+protected size_t file_mbswidth(const char *);
+protected const char *file_getbuffer(struct magic_set *);
+protected ssize_t sread(int, void *, size_t, int);
+protected int file_check_mem(struct magic_set *, unsigned int);
+protected int file_looks_utf8(const unsigned char *, size_t, unichar *,
+ size_t *);
+protected size_t file_pstring_length_size(const struct magic *);
+protected size_t file_pstring_get_length(const struct magic *, const char *);
+protected char * file_printable(char *, size_t, const char *);
+#ifdef __EMX__
+protected int file_os2_apptype(struct magic_set *, const char *, const void *,
+ size_t);
+#endif /* __EMX__ */
+
+#if defined(HAVE_LOCALE_H)
+#include <locale.h>
+#endif
+#if defined(HAVE_XLOCALE_H)
+#include <xlocale.h>
+#endif
+
+typedef struct {
+ const char *pat;
+#if defined(HAVE_NEWLOCALE) && defined(HAVE_USELOCALE) && defined(HAVE_FREELOCALE)
+#define USE_C_LOCALE
+ locale_t old_lc_ctype;
+ locale_t c_lc_ctype;
+#else
+ char *old_lc_ctype;
+#endif
+ int rc;
+ regex_t rx;
+} file_regex_t;
+
+protected int file_regcomp(file_regex_t *, const char *, int);
+protected int file_regexec(file_regex_t *, const char *, size_t, regmatch_t *,
+ int);
+protected void file_regfree(file_regex_t *);
+protected void file_regerror(file_regex_t *, int, struct magic_set *);
+
+typedef struct {
+ char *buf;
+ uint32_t offset;
+} file_pushbuf_t;
+
+protected file_pushbuf_t *file_push_buffer(struct magic_set *);
+protected char *file_pop_buffer(struct magic_set *, file_pushbuf_t *);
+
+#ifndef COMPILE_ONLY
+extern const char *file_names[];
+extern const size_t file_nnames;
+#endif
+
+#ifndef HAVE_STRERROR
+extern int sys_nerr;
+extern char *sys_errlist[];
+#define strerror(e) \
+ (((e) >= 0 && (e) < sys_nerr) ? sys_errlist[(e)] : "Unknown error")
+#endif
+
+#ifndef HAVE_STRTOUL
+#define strtoul(a, b, c) strtol(a, b, c)
+#endif
+
+#ifndef HAVE_PREAD
+ssize_t pread(int, void *, size_t, off_t);
+#endif
+#ifndef HAVE_VASPRINTF
+int vasprintf(char **, const char *, va_list);
+#endif
+#ifndef HAVE_ASPRINTF
+int asprintf(char **, const char *, ...);
+#endif
+#ifndef HAVE_DPRINTF
+int dprintf(int, const char *, ...);
+#endif
+
+#ifndef HAVE_STRLCPY
+size_t strlcpy(char *, const char *, size_t);
+#endif
+#ifndef HAVE_STRLCAT
+size_t strlcat(char *, const char *, size_t);
+#endif
+#ifndef HAVE_STRCASESTR
+char *strcasestr(const char *, const char *);
+#endif
+#ifndef HAVE_GETLINE
+ssize_t getline(char **, size_t *, FILE *);
+ssize_t getdelim(char **, size_t *, int, FILE *);
+#endif
+#ifndef HAVE_CTIME_R
+char *ctime_r(const time_t *, char *);
+#endif
+#ifndef HAVE_ASCTIME_R
+char *asctime_r(const struct tm *, char *);
+#endif
+#ifndef HAVE_GMTIME_R
+struct tm *gmtime_r(const time_t *, struct tm *);
+#endif
+#ifndef HAVE_LOCALTIME_R
+struct tm *localtime_r(const time_t *, struct tm *);
+#endif
+#ifndef HAVE_FMTCHECK
+const char *fmtcheck(const char *, const char *)
+ __attribute__((__format_arg__(2)));
+#endif
+
+#if defined(HAVE_MMAP) && defined(HAVE_SYS_MMAN_H) && !defined(QUICK)
+#define QUICK
+#endif
+
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
+#ifndef __cplusplus
+#if defined(__GNUC__) && (__GNUC__ >= 3)
+#define FILE_RCSID(id) \
+static const char rcsid[] __attribute__((__used__)) = id;
+#else
+#define FILE_RCSID(id) \
+static const char *rcsid(const char *p) { \
+ return rcsid(p = id); \
+}
+#endif
+#else
+#define FILE_RCSID(id)
+#endif
+#ifndef __RCSID
+#define __RCSID(a)
+#endif
+
+#endif /* __file_h__ */
diff --git a/node_modules/mmmagic/deps/libmagic/src/file_opts.h b/node_modules/mmmagic/deps/libmagic/src/file_opts.h
new file mode 100644
index 0000000..52ace18
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/file_opts.h
@@ -0,0 +1,58 @@
+/*
+ * Table of command-line options
+ *
+ * The first column specifies the short name, if any, or 0 if none.
+ * The second column specifies the long name.
+ * The third column specifies whether it takes a parameter.
+ * The fourth column is the documentation.
+ *
+ * N.B. The long options' order must correspond to the code in file.c,
+ * and OPTSTRING must be kept up-to-date with the short options.
+ * Pay particular attention to the numbers of long-only options in the
+ * switch statement!
+ */
+
+OPT_LONGONLY("help", 0, 0, " display this help and exit\n", OPT_HELP)
+OPT('v', "version", 0, 0, " output version information and exit\n")
+OPT('m', "magic-file", 1, 0, " LIST use LIST as a colon-separated list of magic\n"
+ " number files\n")
+OPT('z', "uncompress", 0, 0, " try to look inside compressed files\n")
+OPT('Z', "uncompress-noreport", 0, 0, " only print the contents of compressed files\n")
+OPT('b', "brief", 0, 0, " do not prepend filenames to output lines\n")
+OPT('c', "checking-printout", 0, 0, " print the parsed form of the magic file, use in\n"
+ " conjunction with -m to debug a new magic file\n"
+ " before installing it\n")
+OPT('e', "exclude", 1, 0, " TEST exclude TEST from the list of test to be\n"
+ " performed for file. Valid tests are:\n"
+ " %o\n")
+OPT('f', "files-from", 1, 0, " FILE read the filenames to be examined from FILE\n")
+OPT('F', "separator", 1, 0, " STRING use string as separator instead of `:'\n")
+OPT('i', "mime", 0, 0, " output MIME type strings (--mime-type and\n"
+ " --mime-encoding)\n")
+OPT_LONGONLY("apple", 0, 0, " output the Apple CREATOR/TYPE\n", OPT_APPLE)
+OPT_LONGONLY("extension", 0, 0, " output a slash-separated list of extensions\n", OPT_EXTENSIONS)
+OPT_LONGONLY("mime-type", 0, 0, " output the MIME type\n", OPT_MIME_TYPE)
+OPT_LONGONLY("mime-encoding", 0, 0, " output the MIME encoding\n", OPT_MIME_ENCODING)
+OPT('k', "keep-going", 0, 0, " don't stop at the first match\n")
+OPT('l', "list", 0, 0, " list magic strength\n")
+#ifdef S_IFLNK
+OPT('L', "dereference", 0, 1, " follow symlinks")
+OPT('h', "no-dereference", 0, 2, " don't follow symlinks")
+#endif
+OPT('n', "no-buffer", 0, 0, " do not buffer output\n")
+OPT('N', "no-pad", 0, 0, " do not pad output\n")
+OPT('0', "print0", 0, 0, " terminate filenames with ASCII NUL\n")
+#if defined(HAVE_UTIME) || defined(HAVE_UTIMES)
+OPT('p', "preserve-date", 0, 0, " preserve access times on files\n")
+#endif
+OPT('P', "parameter", 1, 0, " set file engine parameter limits\n"
+ " indir 15 recursion limit for indirection\n"
+ " name 30 use limit for name/use magic\n"
+ " elf_notes 256 max ELF notes processed\n"
+ " elf_phnum 128 max ELF prog sections processed\n"
+ " elf_shnum 32768 max ELF sections processed\n")
+OPT('r', "raw", 0, 0, " don't translate unprintable chars to \\ooo\n")
+OPT('s', "special-files", 0, 0, " treat special (block/char devices) files as\n"
+ " ordinary ones\n")
+OPT('C', "compile", 0, 0, " compile file specified by -m\n")
+OPT('d', "debug", 0, 0, " print debugging messages\n")
diff --git a/node_modules/mmmagic/deps/libmagic/src/fmtcheck.c b/node_modules/mmmagic/deps/libmagic/src/fmtcheck.c
new file mode 100644
index 0000000..486aa08
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/fmtcheck.c
@@ -0,0 +1,251 @@
+/* $NetBSD: fmtcheck.c,v 1.8 2008/04/28 20:22:59 martin Exp $ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code was contributed to The NetBSD Foundation by Allen Briggs.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "file.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+
+enum __e_fmtcheck_types {
+ FMTCHECK_START,
+ FMTCHECK_SHORT,
+ FMTCHECK_INT,
+ FMTCHECK_LONG,
+ FMTCHECK_QUAD,
+ FMTCHECK_SHORTPOINTER,
+ FMTCHECK_INTPOINTER,
+ FMTCHECK_LONGPOINTER,
+ FMTCHECK_QUADPOINTER,
+ FMTCHECK_DOUBLE,
+ FMTCHECK_LONGDOUBLE,
+ FMTCHECK_STRING,
+ FMTCHECK_WIDTH,
+ FMTCHECK_PRECISION,
+ FMTCHECK_DONE,
+ FMTCHECK_UNKNOWN
+};
+typedef enum __e_fmtcheck_types EFT;
+
+#define RETURN(pf,f,r) do { \
+ *(pf) = (f); \
+ return r; \
+ } /*NOTREACHED*/ /*CONSTCOND*/ while (0)
+
+static EFT
+get_next_format_from_precision(const char **pf)
+{
+ int sh, lg, quad, longdouble;
+ const char *f;
+
+ sh = lg = quad = longdouble = 0;
+
+ f = *pf;
+ switch (*f) {
+ case 'h':
+ f++;
+ sh = 1;
+ break;
+ case 'l':
+ f++;
+ if (!*f) RETURN(pf,f,FMTCHECK_UNKNOWN);
+ if (*f == 'l') {
+ f++;
+ quad = 1;
+ } else {
+ lg = 1;
+ }
+ break;
+ case 'q':
+ f++;
+ quad = 1;
+ break;
+ case 'L':
+ f++;
+ longdouble = 1;
+ break;
+#ifdef WIN32
+ case 'I':
+ f++;
+ if (!*f) RETURN(pf,f,FMTCHECK_UNKNOWN);
+ if (*f == '3' && f[1] == '2') {
+ f += 2;
+ } else if (*f == '6' && f[1] == '4') {
+ f += 2;
+ quad = 1;
+ }
+#ifdef _WIN64
+ else {
+ quad = 1;
+ }
+#endif
+ break;
+#endif
+ default:
+ break;
+ }
+ if (!*f) RETURN(pf,f,FMTCHECK_UNKNOWN);
+ if (strchr("diouxX", *f)) {
+ if (longdouble)
+ RETURN(pf,f,FMTCHECK_UNKNOWN);
+ if (lg)
+ RETURN(pf,f,FMTCHECK_LONG);
+ if (quad)
+ RETURN(pf,f,FMTCHECK_QUAD);
+ RETURN(pf,f,FMTCHECK_INT);
+ }
+ if (*f == 'n') {
+ if (longdouble)
+ RETURN(pf,f,FMTCHECK_UNKNOWN);
+ if (sh)
+ RETURN(pf,f,FMTCHECK_SHORTPOINTER);
+ if (lg)
+ RETURN(pf,f,FMTCHECK_LONGPOINTER);
+ if (quad)
+ RETURN(pf,f,FMTCHECK_QUADPOINTER);
+ RETURN(pf,f,FMTCHECK_INTPOINTER);
+ }
+ if (strchr("DOU", *f)) {
+ if (sh + lg + quad + longdouble)
+ RETURN(pf,f,FMTCHECK_UNKNOWN);
+ RETURN(pf,f,FMTCHECK_LONG);
+ }
+ if (strchr("eEfg", *f)) {
+ if (longdouble)
+ RETURN(pf,f,FMTCHECK_LONGDOUBLE);
+ if (sh + lg + quad)
+ RETURN(pf,f,FMTCHECK_UNKNOWN);
+ RETURN(pf,f,FMTCHECK_DOUBLE);
+ }
+ if (*f == 'c') {
+ if (sh + lg + quad + longdouble)
+ RETURN(pf,f,FMTCHECK_UNKNOWN);
+ RETURN(pf,f,FMTCHECK_INT);
+ }
+ if (*f == 's') {
+ if (sh + lg + quad + longdouble)
+ RETURN(pf,f,FMTCHECK_UNKNOWN);
+ RETURN(pf,f,FMTCHECK_STRING);
+ }
+ if (*f == 'p') {
+ if (sh + lg + quad + longdouble)
+ RETURN(pf,f,FMTCHECK_UNKNOWN);
+ RETURN(pf,f,FMTCHECK_LONG);
+ }
+ RETURN(pf,f,FMTCHECK_UNKNOWN);
+ /*NOTREACHED*/
+}
+
+static EFT
+get_next_format_from_width(const char **pf)
+{
+ const char *f;
+
+ f = *pf;
+ if (*f == '.') {
+ f++;
+ if (*f == '*') {
+ RETURN(pf,f,FMTCHECK_PRECISION);
+ }
+ /* eat any precision (empty is allowed) */
+ while (isdigit((unsigned char)*f)) f++;
+ if (!*f) RETURN(pf,f,FMTCHECK_UNKNOWN);
+ }
+ RETURN(pf,f,get_next_format_from_precision(pf));
+ /*NOTREACHED*/
+}
+
+static EFT
+get_next_format(const char **pf, EFT eft)
+{
+ int infmt;
+ const char *f;
+
+ if (eft == FMTCHECK_WIDTH) {
+ (*pf)++;
+ return get_next_format_from_width(pf);
+ } else if (eft == FMTCHECK_PRECISION) {
+ (*pf)++;
+ return get_next_format_from_precision(pf);
+ }
+
+ f = *pf;
+ infmt = 0;
+ while (!infmt) {
+ f = strchr(f, '%');
+ if (f == NULL)
+ RETURN(pf,f,FMTCHECK_DONE);
+ f++;
+ if (!*f)
+ RETURN(pf,f,FMTCHECK_UNKNOWN);
+ if (*f != '%')
+ infmt = 1;
+ else
+ f++;
+ }
+
+ /* Eat any of the flags */
+ while (*f && (strchr("#0- +", *f)))
+ f++;
+
+ if (*f == '*') {
+ RETURN(pf,f,FMTCHECK_WIDTH);
+ }
+ /* eat any width */
+ while (isdigit((unsigned char)*f)) f++;
+ if (!*f) {
+ RETURN(pf,f,FMTCHECK_UNKNOWN);
+ }
+
+ RETURN(pf,f,get_next_format_from_width(pf));
+ /*NOTREACHED*/
+}
+
+const char *
+fmtcheck(const char *f1, const char *f2)
+{
+ const char *f1p, *f2p;
+ EFT f1t, f2t;
+
+ if (!f1) return f2;
+
+ f1p = f1;
+ f1t = FMTCHECK_START;
+ f2p = f2;
+ f2t = FMTCHECK_START;
+ while ((f1t = get_next_format(&f1p, f1t)) != FMTCHECK_DONE) {
+ if (f1t == FMTCHECK_UNKNOWN)
+ return f2;
+ f2t = get_next_format(&f2p, f2t);
+ if (f1t != f2t)
+ return f2;
+ }
+ return f1;
+}
diff --git a/node_modules/mmmagic/deps/libmagic/src/fsmagic.c b/node_modules/mmmagic/deps/libmagic/src/fsmagic.c
new file mode 100644
index 0000000..f84a10e
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/fsmagic.c
@@ -0,0 +1,418 @@
+/*
+ * Copyright (c) Ian F. Darwin 1986-1995.
+ * Software written by Ian F. Darwin and others;
+ * maintained 1995-present by Christos Zoulas and others.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice immediately at the beginning of the file, without modification,
+ * this list of conditions, and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+/*
+ * fsmagic - magic based on filesystem info - directory, special files, etc.
+ */
+
+#include "file.h"
+
+#ifndef lint
+FILE_RCSID("@(#)$File: fsmagic.c,v 1.77 2017/05/24 19:17:50 christos Exp $")
+#endif /* lint */
+
+#include "magic.h"
+#include <string.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <stdlib.h>
+/* Since major is a function on SVR4, we cannot use `ifndef major'. */
+#ifdef MAJOR_IN_MKDEV
+# include <sys/mkdev.h>
+# define HAVE_MAJOR
+#endif
+#ifdef MAJOR_IN_SYSMACROS
+# include <sys/sysmacros.h>
+# define HAVE_MAJOR
+#endif
+#ifdef major /* Might be defined in sys/types.h. */
+# define HAVE_MAJOR
+#endif
+#ifdef WIN32
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+// XXX: change by mscdex
+# define S_IFIFO _S_IFIFO
+#endif
+
+#ifndef HAVE_MAJOR
+# define major(dev) (((dev) >> 8) & 0xff)
+# define minor(dev) ((dev) & 0xff)
+#endif
+#undef HAVE_MAJOR
+#ifdef S_IFLNK
+private int
+bad_link(struct magic_set *ms, int err, char *buf)
+{
+ int mime = ms->flags & MAGIC_MIME;
+ if ((mime & MAGIC_MIME_TYPE) &&
+ file_printf(ms, "inode/symlink")
+ == -1)
+ return -1;
+ else if (!mime) {
+ if (ms->flags & MAGIC_ERROR) {
+ file_error(ms, err,
+ "broken symbolic link to %s", buf);
+ return -1;
+ }
+ if (file_printf(ms, "broken symbolic link to %s", buf) == -1)
+ return -1;
+ }
+ return 1;
+}
+#endif
+private int
+handle_mime(struct magic_set *ms, int mime, const char *str)
+{
+ if ((mime & MAGIC_MIME_TYPE)) {
+ if (file_printf(ms, "inode/%s", str) == -1)
+ return -1;
+ if ((mime & MAGIC_MIME_ENCODING) && file_printf(ms,
+ "; charset=") == -1)
+ return -1;
+ }
+ if ((mime & MAGIC_MIME_ENCODING) && file_printf(ms, "binary") == -1)
+ return -1;
+ return 0;
+}
+
+protected int
+file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
+{
+ int ret, did = 0;
+ int mime = ms->flags & MAGIC_MIME;
+ int silent = ms->flags & (MAGIC_APPLE|MAGIC_EXTENSION);
+#ifdef S_IFLNK
+ char buf[BUFSIZ+4];
+ ssize_t nch;
+ struct stat tstatbuf;
+#endif
+
+ if (fn == NULL)
+ return 0;
+
+#define COMMA (did++ ? ", " : "")
+ /*
+ * Fstat is cheaper but fails for files you don't have read perms on.
+ * On 4.2BSD and similar systems, use lstat() to identify symlinks.
+ */
+#ifdef S_IFLNK
+ if ((ms->flags & MAGIC_SYMLINK) == 0)
+ ret = lstat(fn, sb);
+ else
+#endif
+ ret = stat(fn, sb); /* don't merge into if; see "ret =" above */
+
+#ifdef WIN32
+ {
+ HANDLE hFile = CreateFile((LPCSTR)fn, 0, FILE_SHARE_DELETE |
+ FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0,
+ NULL);
+ if (hFile != INVALID_HANDLE_VALUE) {
+ /*
+ * Stat failed, but we can still open it - assume it's
+ * a block device, if nothing else.
+ */
+ if (ret) {
+ sb->st_mode = S_IFBLK;
+ ret = 0;
+ }
+ switch (GetFileType(hFile)) {
+ case FILE_TYPE_CHAR:
+ sb->st_mode |= S_IFCHR;
+ sb->st_mode &= ~S_IFREG;
+ break;
+ case FILE_TYPE_PIPE:
+ sb->st_mode |= S_IFIFO;
+ sb->st_mode &= ~S_IFREG;
+ break;
+ }
+ CloseHandle(hFile);
+ }
+ }
+#endif
+
+ if (ret) {
+ if (ms->flags & MAGIC_ERROR) {
+ file_error(ms, errno, "cannot stat `%s'", fn);
+ return -1;
+ }
+ if (file_printf(ms, "cannot open `%s' (%s)",
+ fn, strerror(errno)) == -1)
+ return -1;
+ return 0;
+ }
+
+ ret = 1;
+ if (!mime && !silent) {
+#ifdef S_ISUID
+ if (sb->st_mode & S_ISUID)
+ if (file_printf(ms, "%ssetuid", COMMA) == -1)
+ return -1;
+#endif
+#ifdef S_ISGID
+ if (sb->st_mode & S_ISGID)
+ if (file_printf(ms, "%ssetgid", COMMA) == -1)
+ return -1;
+#endif
+#ifdef S_ISVTX
+ if (sb->st_mode & S_ISVTX)
+ if (file_printf(ms, "%ssticky", COMMA) == -1)
+ return -1;
+#endif
+ }
+
+ switch (sb->st_mode & S_IFMT) {
+ case S_IFDIR:
+ if (mime) {
+ if (handle_mime(ms, mime, "directory") == -1)
+ return -1;
+ } else if (silent) {
+ } else if (file_printf(ms, "%sdirectory", COMMA) == -1)
+ return -1;
+ break;
+#ifdef S_IFCHR
+ case S_IFCHR:
+ /*
+ * If -s has been specified, treat character special files
+ * like ordinary files. Otherwise, just report that they
+ * are block special files and go on to the next file.
+ */
+ if ((ms->flags & MAGIC_DEVICES) != 0) {
+ ret = 0;
+ break;
+ }
+ if (mime) {
+ if (handle_mime(ms, mime, "chardevice") == -1)
+ return -1;
+ } else if (silent) {
+ } else {
+#ifdef HAVE_STRUCT_STAT_ST_RDEV
+# ifdef dv_unit
+ if (file_printf(ms, "%scharacter special (%d/%d/%d)",
+ COMMA, major(sb->st_rdev), dv_unit(sb->st_rdev),
+ dv_subunit(sb->st_rdev)) == -1)
+ return -1;
+# else
+ if (file_printf(ms, "%scharacter special (%ld/%ld)",
+ COMMA, (long)major(sb->st_rdev),
+ (long)minor(sb->st_rdev)) == -1)
+ return -1;
+# endif
+#else
+ if (file_printf(ms, "%scharacter special", COMMA) == -1)
+ return -1;
+#endif
+ }
+ break;
+#endif
+#ifdef S_IFBLK
+ case S_IFBLK:
+ /*
+ * If -s has been specified, treat block special files
+ * like ordinary files. Otherwise, just report that they
+ * are block special files and go on to the next file.
+ */
+ if ((ms->flags & MAGIC_DEVICES) != 0) {
+ ret = 0;
+ break;
+ }
+ if (mime) {
+ if (handle_mime(ms, mime, "blockdevice") == -1)
+ return -1;
+ } else if (silent) {
+ } else {
+#ifdef HAVE_STRUCT_STAT_ST_RDEV
+# ifdef dv_unit
+ if (file_printf(ms, "%sblock special (%d/%d/%d)",
+ COMMA, major(sb->st_rdev), dv_unit(sb->st_rdev),
+ dv_subunit(sb->st_rdev)) == -1)
+ return -1;
+# else
+ if (file_printf(ms, "%sblock special (%ld/%ld)",
+ COMMA, (long)major(sb->st_rdev),
+ (long)minor(sb->st_rdev)) == -1)
+ return -1;
+# endif
+#else
+ if (file_printf(ms, "%sblock special", COMMA) == -1)
+ return -1;
+#endif
+ }
+ break;
+#endif
+ /* TODO add code to handle V7 MUX and Blit MUX files */
+#ifdef S_IFIFO
+ case S_IFIFO:
+ if((ms->flags & MAGIC_DEVICES) != 0)
+ break;
+ if (mime) {
+ if (handle_mime(ms, mime, "fifo") == -1)
+ return -1;
+ } else if (silent) {
+ } else if (file_printf(ms, "%sfifo (named pipe)", COMMA) == -1)
+ return -1;
+ break;
+#endif
+#ifdef S_IFDOOR
+ case S_IFDOOR:
+ if (mime) {
+ if (handle_mime(ms, mime, "door") == -1)
+ return -1;
+ } else if (silent) {
+ } else if (file_printf(ms, "%sdoor", COMMA) == -1)
+ return -1;
+ break;
+#endif
+#ifdef S_IFLNK
+ case S_IFLNK:
+ if ((nch = readlink(fn, buf, BUFSIZ-1)) <= 0) {
+ if (ms->flags & MAGIC_ERROR) {
+ file_error(ms, errno, "unreadable symlink `%s'",
+ fn);
+ return -1;
+ }
+ if (mime) {
+ if (handle_mime(ms, mime, "symlink") == -1)
+ return -1;
+ } else if (silent) {
+ } else if (file_printf(ms,
+ "%sunreadable symlink `%s' (%s)", COMMA, fn,
+ strerror(errno)) == -1)
+ return -1;
+ break;
+ }
+ buf[nch] = '\0'; /* readlink(2) does not do this */
+
+ /* If broken symlink, say so and quit early. */
+ if (*buf == '/') {
+ if (stat(buf, &tstatbuf) < 0)
+ return bad_link(ms, errno, buf);
+ } else {
+ char *tmp;
+ char buf2[BUFSIZ+BUFSIZ+4];
+
+ if ((tmp = strrchr(fn, '/')) == NULL) {
+ tmp = buf; /* in current directory anyway */
+ } else {
+ if (tmp - fn + 1 > BUFSIZ) {
+ if (ms->flags & MAGIC_ERROR) {
+ file_error(ms, 0,
+ "path too long: `%s'", buf);
+ return -1;
+ }
+ if (mime) {
+ if (handle_mime(ms, mime,
+ "x-path-too-long") == -1)
+ return -1;
+ } else if (silent) {
+ } else if (file_printf(ms,
+ "%spath too long: `%s'", COMMA,
+ fn) == -1)
+ return -1;
+ break;
+ }
+ /* take dir part */
+ (void)strlcpy(buf2, fn, sizeof buf2);
+ buf2[tmp - fn + 1] = '\0';
+ /* plus (rel) link */
+ (void)strlcat(buf2, buf, sizeof buf2);
+ tmp = buf2;
+ }
+ if (stat(tmp, &tstatbuf) < 0)
+ return bad_link(ms, errno, buf);
+ }
+
+ /* Otherwise, handle it. */
+ if ((ms->flags & MAGIC_SYMLINK) != 0) {
+ const char *p;
+ ms->flags &= MAGIC_SYMLINK;
+ p = magic_file(ms, buf);
+ ms->flags |= MAGIC_SYMLINK;
+ if (p == NULL)
+ return -1;
+ } else { /* just print what it points to */
+ if (mime) {
+ if (handle_mime(ms, mime, "symlink") == -1)
+ return -1;
+ } else if (silent) {
+ } else if (file_printf(ms, "%ssymbolic link to %s",
+ COMMA, buf) == -1)
+ return -1;
+ }
+ break;
+#endif
+#ifdef S_IFSOCK
+#ifndef __COHERENT__
+ case S_IFSOCK:
+ if (mime) {
+ if (handle_mime(ms, mime, "socket") == -1)
+ return -1;
+ } else if (silent) {
+ } else if (file_printf(ms, "%ssocket", COMMA) == -1)
+ return -1;
+ break;
+#endif
+#endif
+ case S_IFREG:
+ /*
+ * regular file, check next possibility
+ *
+ * If stat() tells us the file has zero length, report here that
+ * the file is empty, so we can skip all the work of opening and
+ * reading the file.
+ * But if the -s option has been given, we skip this
+ * optimization, since on some systems, stat() reports zero
+ * size for raw disk partitions. (If the block special device
+ * really has zero length, the fact that it is empty will be
+ * detected and reported correctly when we read the file.)
+ */
+ if ((ms->flags & MAGIC_DEVICES) == 0 && sb->st_size == 0) {
+ if (mime) {
+ if (handle_mime(ms, mime, "x-empty") == -1)
+ return -1;
+ } else if (silent) {
+ } else if (file_printf(ms, "%sempty", COMMA) == -1)
+ return -1;
+ break;
+ }
+ ret = 0;
+ break;
+
+ default:
+ file_error(ms, 0, "invalid mode 0%o", sb->st_mode);
+ return -1;
+ /*NOTREACHED*/
+ }
+
+ if (!silent && !mime && did && ret == 0) {
+ if (file_printf(ms, " ") == -1)
+ return -1;
+ }
+ return ret;
+}
diff --git a/node_modules/mmmagic/deps/libmagic/src/funcs.c b/node_modules/mmmagic/deps/libmagic/src/funcs.c
new file mode 100644
index 0000000..d7a18f4
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/funcs.c
@@ -0,0 +1,603 @@
+/*
+ * Copyright (c) Christos Zoulas 2003.
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice immediately at the beginning of the file, without modification,
+ * this list of conditions, and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#include "file.h"
+
+#ifndef lint
+FILE_RCSID("@(#)$File: funcs.c,v 1.93 2017/08/28 13:39:18 christos Exp $")
+#endif /* lint */
+
+#include "magic.h"
+#include <assert.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#if defined(HAVE_WCHAR_H)
+#include <wchar.h>
+#endif
+#if defined(HAVE_WCTYPE_H)
+#include <wctype.h>
+#endif
+#if defined(HAVE_LIMITS_H)
+#include <limits.h>
+#endif
+
+#ifndef SIZE_MAX
+#define SIZE_MAX ((size_t)~0)
+#endif
+
+/*
+ * Like printf, only we append to a buffer.
+ */
+protected int
+file_vprintf(struct magic_set *ms, const char *fmt, va_list ap)
+{
+ int len;
+ char *buf, *newstr;
+
+ if (ms->event_flags & EVENT_HAD_ERR)
+ return 0;
+ len = vasprintf(&buf, fmt, ap);
+ if (len < 0)
+ goto out;
+
+ if (ms->o.buf != NULL) {
+ len = asprintf(&newstr, "%s%s", ms->o.buf, buf);
+ free(buf);
+ if (len < 0)
+ goto out;
+ free(ms->o.buf);
+ buf = newstr;
+ }
+ ms->o.buf = buf;
+ return 0;
+out:
+ fprintf(stderr, "vasprintf failed (%s)", strerror(errno));
+ return -1;
+}
+
+protected int
+file_printf(struct magic_set *ms, const char *fmt, ...)
+{
+ int rv;
+ va_list ap;
+
+ va_start(ap, fmt);
+ rv = file_vprintf(ms, fmt, ap);
+ va_end(ap);
+ return rv;
+}
+
+/*
+ * error - print best error message possible
+ */
+/*VARARGS*/
+__attribute__((__format__(__printf__, 3, 0)))
+private void
+file_error_core(struct magic_set *ms, int error, const char *f, va_list va,
+ size_t lineno)
+{
+ /* Only the first error is ok */
+ if (ms->event_flags & EVENT_HAD_ERR)
+ return;
+ if (lineno != 0) {
+ free(ms->o.buf);
+ ms->o.buf = NULL;
+ file_printf(ms, "line %" SIZE_T_FORMAT "u:", lineno);
+ }
+ if (ms->o.buf && *ms->o.buf)
+ file_printf(ms, " ");
+ file_vprintf(ms, f, va);
+ if (error > 0)
+ file_printf(ms, " (%s)", strerror(error));
+ ms->event_flags |= EVENT_HAD_ERR;
+ ms->error = error;
+}
+
+/*VARARGS*/
+protected void
+file_error(struct magic_set *ms, int error, const char *f, ...)
+{
+ va_list va;
+ va_start(va, f);
+ file_error_core(ms, error, f, va, 0);
+ va_end(va);
+}
+
+/*
+ * Print an error with magic line number.
+ */
+/*VARARGS*/
+protected void
+file_magerror(struct magic_set *ms, const char *f, ...)
+{
+ va_list va;
+ va_start(va, f);
+ file_error_core(ms, 0, f, va, ms->line);
+ va_end(va);
+}
+
+protected void
+file_oomem(struct magic_set *ms, size_t len)
+{
+ file_error(ms, errno, "cannot allocate %" SIZE_T_FORMAT "u bytes",
+ len);
+}
+
+protected void
+file_badseek(struct magic_set *ms)
+{
+ file_error(ms, errno, "error seeking");
+}
+
+protected void
+file_badread(struct magic_set *ms)
+{
+ file_error(ms, errno, "error reading");
+}
+
+#ifndef COMPILE_ONLY
+
+static int
+checkdone(struct magic_set *ms, int *rv)
+{
+ if ((ms->flags & MAGIC_CONTINUE) == 0)
+ return 1;
+ if (file_printf(ms, "\n- ") == -1)
+ *rv = -1;
+ return 0;
+}
+
+/*ARGSUSED*/
+protected int
+file_buffer(struct magic_set *ms, int fd, const char *inname __attribute__ ((__unused__)),
+ const void *buf, size_t nb)
+{
+ int m = 0, rv = 0, looks_text = 0;
+ const unsigned char *ubuf = CAST(const unsigned char *, buf);
+ unichar *u8buf = NULL;
+ size_t ulen;
+ const char *code = NULL;
+ const char *code_mime = "binary";
+ const char *type = "application/octet-stream";
+ const char *def = "data";
+ const char *ftype = NULL;
+
+ if (nb == 0) {
+ def = "empty";
+ type = "application/x-empty";
+ goto simple;
+ } else if (nb == 1) {
+ def = "very short file (no magic)";
+ goto simple;
+ }
+
+ if ((ms->flags & MAGIC_NO_CHECK_ENCODING) == 0) {
+ looks_text = file_encoding(ms, ubuf, nb, &u8buf, &ulen,
+ &code, &code_mime, &ftype);
+ }
+
+#ifdef __EMX__
+ if ((ms->flags & MAGIC_NO_CHECK_APPTYPE) == 0 && inname) {
+ m = file_os2_apptype(ms, inname, buf, nb);
+ if ((ms->flags & MAGIC_DEBUG) != 0)
+ (void)fprintf(stderr, "[try os2_apptype %d]\n", m);
+ switch (m) {
+ case -1:
+ return -1;
+ case 0:
+ break;
+ default:
+ return 1;
+ }
+ }
+#endif
+#if HAVE_FORK
+ /* try compression stuff */
+ if ((ms->flags & MAGIC_NO_CHECK_COMPRESS) == 0) {
+ m = file_zmagic(ms, fd, inname, ubuf, nb);
+ if ((ms->flags & MAGIC_DEBUG) != 0)
+ (void)fprintf(stderr, "[try zmagic %d]\n", m);
+ if (m) {
+ goto done_encoding;
+ }
+ }
+#endif
+ /* Check if we have a tar file */
+ if ((ms->flags & MAGIC_NO_CHECK_TAR) == 0) {
+ m = file_is_tar(ms, ubuf, nb);
+ if ((ms->flags & MAGIC_DEBUG) != 0)
+ (void)fprintf(stderr, "[try tar %d]\n", m);
+ if (m) {
+ if (checkdone(ms, &rv))
+ goto done;
+ }
+ }
+
+ /* Check if we have a CDF file */
+ if ((ms->flags & MAGIC_NO_CHECK_CDF) == 0) {
+ m = file_trycdf(ms, fd, ubuf, nb);
+ if ((ms->flags & MAGIC_DEBUG) != 0)
+ (void)fprintf(stderr, "[try cdf %d]\n", m);
+ if (m) {
+ if (checkdone(ms, &rv))
+ goto done;
+ }
+ }
+
+ /* try soft magic tests */
+ if ((ms->flags & MAGIC_NO_CHECK_SOFT) == 0) {
+ m = file_softmagic(ms, ubuf, nb, NULL, NULL, BINTEST,
+ looks_text);
+ if ((ms->flags & MAGIC_DEBUG) != 0)
+ (void)fprintf(stderr, "[try softmagic %d]\n", m);
+ if (m) {
+#ifdef BUILTIN_ELF
+ if ((ms->flags & MAGIC_NO_CHECK_ELF) == 0 && m == 1 &&
+ nb > 5 && fd != -1) {
+ /*
+ * We matched something in the file, so this
+ * *might* be an ELF file, and the file is at
+ * least 5 bytes long, so if it's an ELF file
+ * it has at least one byte past the ELF magic
+ * number - try extracting information from the
+ * ELF headers that cannot easily * be
+ * extracted with rules in the magic file.
+ */
+ m = file_tryelf(ms, fd, ubuf, nb);
+ if ((ms->flags & MAGIC_DEBUG) != 0)
+ (void)fprintf(stderr, "[try elf %d]\n",
+ m);
+ }
+#endif
+ if (checkdone(ms, &rv))
+ goto done;
+ }
+ }
+
+ /* try text properties */
+ if ((ms->flags & MAGIC_NO_CHECK_TEXT) == 0) {
+
+ m = file_ascmagic(ms, ubuf, nb, looks_text);
+ if ((ms->flags & MAGIC_DEBUG) != 0)
+ (void)fprintf(stderr, "[try ascmagic %d]\n", m);
+ if (m) {
+ if (checkdone(ms, &rv))
+ goto done;
+ }
+ }
+
+simple:
+ /* give up */
+ m = 1;
+ if (ms->flags & MAGIC_MIME) {
+ if ((ms->flags & MAGIC_MIME_TYPE) &&
+ file_printf(ms, "%s", type) == -1)
+ rv = -1;
+ } else if (ms->flags & MAGIC_APPLE) {
+ if (file_printf(ms, "UNKNUNKN") == -1)
+ rv = -1;
+ } else if (ms->flags & MAGIC_EXTENSION) {
+ if (file_printf(ms, "???") == -1)
+ rv = -1;
+ } else {
+ if (file_printf(ms, "%s", def) == -1)
+ rv = -1;
+ }
+ done:
+ if ((ms->flags & MAGIC_MIME_ENCODING) != 0) {
+ if (ms->flags & MAGIC_MIME_TYPE)
+ if (file_printf(ms, "; charset=") == -1)
+ rv = -1;
+ if (file_printf(ms, "%s", code_mime) == -1)
+ rv = -1;
+ }
+#if HAVE_FORK
+ done_encoding:
+#endif
+ free(u8buf);
+ if (rv)
+ return rv;
+
+ return m;
+}
+#endif
+
+protected int
+file_reset(struct magic_set *ms, int checkloaded)
+{
+ if (checkloaded && ms->mlist[0] == NULL) {
+ file_error(ms, 0, "no magic files loaded");
+ return -1;
+ }
+ if (ms->o.buf) {
+ free(ms->o.buf);
+ ms->o.buf = NULL;
+ }
+ if (ms->o.pbuf) {
+ free(ms->o.pbuf);
+ ms->o.pbuf = NULL;
+ }
+ ms->event_flags &= ~EVENT_HAD_ERR;
+ ms->error = -1;
+ return 0;
+}
+
+#define OCTALIFY(n, o) \
+ /*LINTED*/ \
+ (void)(*(n)++ = '\\', \
+ *(n)++ = (((uint32_t)*(o) >> 6) & 3) + '0', \
+ *(n)++ = (((uint32_t)*(o) >> 3) & 7) + '0', \
+ *(n)++ = (((uint32_t)*(o) >> 0) & 7) + '0', \
+ (o)++)
+
+protected const char *
+file_getbuffer(struct magic_set *ms)
+{
+ char *pbuf, *op, *np;
+ size_t psize, len;
+
+ if (ms->event_flags & EVENT_HAD_ERR)
+ return NULL;
+
+ if (ms->flags & MAGIC_RAW)
+ return ms->o.buf;
+
+ if (ms->o.buf == NULL)
+ return NULL;
+
+ /* * 4 is for octal representation, + 1 is for NUL */
+ len = strlen(ms->o.buf);
+ if (len > (SIZE_MAX - 1) / 4) {
+ file_oomem(ms, len);
+ return NULL;
+ }
+ psize = len * 4 + 1;
+ if ((pbuf = CAST(char *, realloc(ms->o.pbuf, psize))) == NULL) {
+ file_oomem(ms, psize);
+ return NULL;
+ }
+ ms->o.pbuf = pbuf;
+
+#if defined(HAVE_WCHAR_H) && defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH)
+ {
+ mbstate_t state;
+ wchar_t nextchar;
+ int mb_conv = 1;
+ size_t bytesconsumed;
+ char *eop;
+ (void)memset(&state, 0, sizeof(mbstate_t));
+
+ np = ms->o.pbuf;
+ op = ms->o.buf;
+ eop = op + len;
+
+ while (op < eop) {
+ bytesconsumed = mbrtowc(&nextchar, op,
+ (size_t)(eop - op), &state);
+ if (bytesconsumed == (size_t)(-1) ||
+ bytesconsumed == (size_t)(-2)) {
+ mb_conv = 0;
+ break;
+ }
+
+ if (iswprint(nextchar)) {
+ (void)memcpy(np, op, bytesconsumed);
+ op += bytesconsumed;
+ np += bytesconsumed;
+ } else {
+ while (bytesconsumed-- > 0)
+ OCTALIFY(np, op);
+ }
+ }
+ *np = '\0';
+
+ /* Parsing succeeded as a multi-byte sequence */
+ if (mb_conv != 0)
+ return ms->o.pbuf;
+ }
+#endif
+
+ for (np = ms->o.pbuf, op = ms->o.buf; *op;) {
+ if (isprint((unsigned char)*op)) {
+ *np++ = *op++;
+ } else {
+ OCTALIFY(np, op);
+ }
+ }
+ *np = '\0';
+ return ms->o.pbuf;
+}
+
+protected int
+file_check_mem(struct magic_set *ms, unsigned int level)
+{
+ size_t len;
+
+ if (level >= ms->c.len) {
+ len = (ms->c.len = 20 + level) * sizeof(*ms->c.li);
+ ms->c.li = CAST(struct level_info *, (ms->c.li == NULL) ?
+ malloc(len) :
+ realloc(ms->c.li, len));
+ if (ms->c.li == NULL) {
+ file_oomem(ms, len);
+ return -1;
+ }
+ }
+ ms->c.li[level].got_match = 0;
+#ifdef ENABLE_CONDITIONALS
+ ms->c.li[level].last_match = 0;
+ ms->c.li[level].last_cond = COND_NONE;
+#endif /* ENABLE_CONDITIONALS */
+ return 0;
+}
+
+protected size_t
+file_printedlen(const struct magic_set *ms)
+{
+ return ms->o.buf == NULL ? 0 : strlen(ms->o.buf);
+}
+
+protected int
+file_replace(struct magic_set *ms, const char *pat, const char *rep)
+{
+ file_regex_t rx;
+ int rc, rv = -1;
+
+ rc = file_regcomp(&rx, pat, REG_EXTENDED);
+ if (rc) {
+ file_regerror(&rx, rc, ms);
+ } else {
+ regmatch_t rm;
+ int nm = 0;
+ while (file_regexec(&rx, ms->o.buf, 1, &rm, 0) == 0) {
+ ms->o.buf[rm.rm_so] = '\0';
+ if (file_printf(ms, "%s%s", rep,
+ rm.rm_eo != 0 ? ms->o.buf + rm.rm_eo : "") == -1)
+ goto out;
+ nm++;
+ }
+ rv = nm;
+ }
+out:
+ file_regfree(&rx);
+ return rv;
+}
+
+protected int
+file_regcomp(file_regex_t *rx, const char *pat, int flags)
+{
+#ifdef USE_C_LOCALE
+ rx->c_lc_ctype = newlocale(LC_CTYPE_MASK, "C", 0);
+ assert(rx->c_lc_ctype != NULL);
+ rx->old_lc_ctype = uselocale(rx->c_lc_ctype);
+ assert(rx->old_lc_ctype != NULL);
+#else
+ rx->old_lc_ctype = setlocale(LC_CTYPE, "C");
+#endif
+ rx->pat = pat;
+
+ return rx->rc = regcomp(&rx->rx, pat, flags);
+}
+
+protected int
+file_regexec(file_regex_t *rx, const char *str, size_t nmatch,
+ regmatch_t* pmatch, int eflags)
+{
+ assert(rx->rc == 0);
+ /* XXX: force initialization because glibc does not always do this */
+ memset(pmatch, 0, nmatch * sizeof(*pmatch));
+ return regexec(&rx->rx, str, nmatch, pmatch, eflags);
+}
+
+protected void
+file_regfree(file_regex_t *rx)
+{
+ if (rx->rc == 0)
+ regfree(&rx->rx);
+#ifdef USE_C_LOCALE
+ (void)uselocale(rx->old_lc_ctype);
+ freelocale(rx->c_lc_ctype);
+#else
+ (void)setlocale(LC_CTYPE, rx->old_lc_ctype);
+#endif
+}
+
+protected void
+file_regerror(file_regex_t *rx, int rc, struct magic_set *ms)
+{
+ char errmsg[512];
+
+ (void)regerror(rc, &rx->rx, errmsg, sizeof(errmsg));
+ file_magerror(ms, "regex error %d for `%s', (%s)", rc, rx->pat,
+ errmsg);
+}
+
+protected file_pushbuf_t *
+file_push_buffer(struct magic_set *ms)
+{
+ file_pushbuf_t *pb;
+
+ if (ms->event_flags & EVENT_HAD_ERR)
+ return NULL;
+
+ if ((pb = (CAST(file_pushbuf_t *, malloc(sizeof(*pb))))) == NULL)
+ return NULL;
+
+ pb->buf = ms->o.buf;
+ pb->offset = ms->offset;
+
+ ms->o.buf = NULL;
+ ms->offset = 0;
+
+ return pb;
+}
+
+protected char *
+file_pop_buffer(struct magic_set *ms, file_pushbuf_t *pb)
+{
+ char *rbuf;
+
+ if (ms->event_flags & EVENT_HAD_ERR) {
+ free(pb->buf);
+ free(pb);
+ return NULL;
+ }
+
+ rbuf = ms->o.buf;
+
+ ms->o.buf = pb->buf;
+ ms->offset = pb->offset;
+
+ free(pb);
+ return rbuf;
+}
+
+/*
+ * convert string to ascii printable format.
+ */
+protected char *
+file_printable(char *buf, size_t bufsiz, const char *str)
+{
+ char *ptr, *eptr;
+ const unsigned char *s = (const unsigned char *)str;
+
+ for (ptr = buf, eptr = ptr + bufsiz - 1; ptr < eptr && *s; s++) {
+ if (isprint(*s)) {
+ *ptr++ = *s;
+ continue;
+ }
+ if (ptr >= eptr - 3)
+ break;
+ *ptr++ = '\\';
+ *ptr++ = ((CAST(unsigned int, *s) >> 6) & 7) + '0';
+ *ptr++ = ((CAST(unsigned int, *s) >> 3) & 7) + '0';
+ *ptr++ = ((CAST(unsigned int, *s) >> 0) & 7) + '0';
+ }
+ *ptr = '\0';
+ return buf;
+}
diff --git a/node_modules/mmmagic/deps/libmagic/src/getline.c b/node_modules/mmmagic/deps/libmagic/src/getline.c
new file mode 100644
index 0000000..67bd006
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/getline.c
@@ -0,0 +1,107 @@
+/* $NetBSD: getline.c,v 1.2 2014/09/16 17:23:50 christos Exp $ */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "file.h"
+#if !HAVE_GETLINE
+#include <stdlib.h>
+#include <stdio.h>
+// XXX: change by mscdex
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <errno.h>
+#include <string.h>
+
+public ssize_t
+getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp)
+{
+ char *ptr, *eptr;
+
+
+ if (*buf == NULL || *bufsiz == 0) {
+ *bufsiz = BUFSIZ;
+ if ((*buf = malloc(*bufsiz)) == NULL)
+ return -1;
+ }
+
+ for (ptr = *buf, eptr = *buf + *bufsiz;;) {
+ int c = fgetc(fp);
+ if (c == -1) {
+ if (feof(fp)) {
+ ssize_t diff = (ssize_t)(ptr - *buf);
+ if (diff != 0) {
+ *ptr = '\0';
+ return diff;
+ }
+ }
+ return -1;
+ }
+ *ptr++ = c;
+ if (c == delimiter) {
+ *ptr = '\0';
+ return ptr - *buf;
+ }
+ if (ptr + 2 >= eptr) {
+ char *nbuf;
+ size_t nbufsiz = *bufsiz * 2;
+ ssize_t d = ptr - *buf;
+ if ((nbuf = realloc(*buf, nbufsiz)) == NULL)
+ return -1;
+ *buf = nbuf;
+ *bufsiz = nbufsiz;
+ eptr = nbuf + nbufsiz;
+ ptr = nbuf + d;
+ }
+ }
+}
+
+public ssize_t
+getline(char **buf, size_t *bufsiz, FILE *fp)
+{
+ return getdelim(buf, bufsiz, '\n', fp);
+}
+
+#endif
+
+#ifdef TEST
+int
+main(int argc, char *argv[])
+{
+ char *p = NULL;
+ ssize_t len;
+ size_t n = 0;
+
+ while ((len = getline(&p, &n, stdin)) != -1)
+ (void)printf("%" SIZE_T_FORMAT "d %s", len, p);
+ free(p);
+ return 0;
+}
+#endif
diff --git a/node_modules/mmmagic/deps/libmagic/src/getopt_long.c b/node_modules/mmmagic/deps/libmagic/src/getopt_long.c
new file mode 100644
index 0000000..d357dc3
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/getopt_long.c
@@ -0,0 +1,498 @@
+/* $NetBSD: getopt_long.c,v 1.21.4.1 2008/01/09 01:34:14 matt Exp $ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Dieter Baron and Thomas Klausner.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "file.h"
+
+#ifndef lint
+FILE_RCSID("@(#)$File: getopt_long.c,v 1.6 2009/02/13 18:48:05 christos Exp $")
+#endif /* lint */
+
+#include <assert.h>
+#ifdef HAVE_ERR_H
+#include <err.h>
+#else
+#define warnx printf
+#endif
+#include <errno.h>
+#if defined(HAVE_GETOPT_H) && defined(HAVE_STRUCT_OPTION)
+#include <getopt.h>
+#else
+#include "mygetopt.h"
+#endif
+#include <stdlib.h>
+#include <string.h>
+
+#define REPLACE_GETOPT
+
+#ifndef _DIAGASSERT
+#define _DIAGASSERT assert
+#endif
+
+#ifdef REPLACE_GETOPT
+#ifdef __weak_alias
+__weak_alias(getopt,_getopt)
+#endif
+int opterr = 1; /* if error message should be printed */
+int optind = 1; /* index into parent argv vector */
+int optopt = '?'; /* character checked for validity */
+int optreset; /* reset getopt */
+char *optarg; /* argument associated with option */
+#elif HAVE_NBTOOL_CONFIG_H && !HAVE_DECL_OPTRESET
+static int optreset;
+#endif
+
+#ifdef __weak_alias
+__weak_alias(getopt_long,_getopt_long)
+#endif
+
+#define IGNORE_FIRST (*options == '-' || *options == '+')
+#define PRINT_ERROR ((opterr) && ((*options != ':') \
+ || (IGNORE_FIRST && options[1] != ':')))
+#define IS_POSIXLY_CORRECT (getenv("POSIXLY_CORRECT") != NULL)
+#define PERMUTE (!IS_POSIXLY_CORRECT && !IGNORE_FIRST)
+/* XXX: GNU ignores PC if *options == '-' */
+#define IN_ORDER (!IS_POSIXLY_CORRECT && *options == '-')
+
+/* return values */
+#define BADCH (int)'?'
+#define BADARG ((IGNORE_FIRST && options[1] == ':') \
+ || (*options == ':') ? (int)':' : (int)'?')
+#define INORDER (int)1
+
+#define EMSG ""
+
+static int getopt_internal(int, char **, const char *);
+static int gcd(int, int);
+static void permute_args(int, int, int, char **);
+
+static const char *place = EMSG; /* option letter processing */
+
+/* XXX: set optreset to 1 rather than these two */
+static int nonopt_start = -1; /* first non option argument (for permute) */
+static int nonopt_end = -1; /* first option after non options (for permute) */
+
+/* Error messages */
+static const char recargchar[] = "option requires an argument -- %c";
+static const char recargstring[] = "option requires an argument -- %s";
+static const char ambig[] = "ambiguous option -- %.*s";
+static const char noarg[] = "option doesn't take an argument -- %.*s";
+static const char illoptchar[] = "unknown option -- %c";
+static const char illoptstring[] = "unknown option -- %s";
+
+
+/*
+ * Compute the greatest common divisor of a and b.
+ */
+static int
+gcd(a, b)
+ int a;
+ int b;
+{
+ int c;
+
+ c = a % b;
+ while (c != 0) {
+ a = b;
+ b = c;
+ c = a % b;
+ }
+
+ return b;
+}
+
+/*
+ * Exchange the block from nonopt_start to nonopt_end with the block
+ * from nonopt_end to opt_end (keeping the same order of arguments
+ * in each block).
+ */
+static void
+permute_args(panonopt_start, panonopt_end, opt_end, nargv)
+ int panonopt_start;
+ int panonopt_end;
+ int opt_end;
+ char **nargv;
+{
+ int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos;
+ char *swap;
+
+ _DIAGASSERT(nargv != NULL);
+
+ /*
+ * compute lengths of blocks and number and size of cycles
+ */
+ nnonopts = panonopt_end - panonopt_start;
+ nopts = opt_end - panonopt_end;
+ ncycle = gcd(nnonopts, nopts);
+ cyclelen = (opt_end - panonopt_start) / ncycle;
+
+ for (i = 0; i < ncycle; i++) {
+ cstart = panonopt_end+i;
+ pos = cstart;
+ for (j = 0; j < cyclelen; j++) {
+ if (pos >= panonopt_end)
+ pos -= nnonopts;
+ else
+ pos += nopts;
+ swap = nargv[pos];
+ nargv[pos] = nargv[cstart];
+ nargv[cstart] = swap;
+ }
+ }
+}
+
+/*
+ * getopt_internal --
+ * Parse argc/argv argument vector. Called by user level routines.
+ * Returns -2 if -- is found (can be long option or end of options marker).
+ */
+static int
+getopt_internal(nargc, nargv, options)
+ int nargc;
+ char **nargv;
+ const char *options;
+{
+ char *oli; /* option letter list index */
+ int optchar;
+
+ _DIAGASSERT(nargv != NULL);
+ _DIAGASSERT(options != NULL);
+
+ optarg = NULL;
+
+ /*
+ * XXX Some programs (like rsyncd) expect to be able to
+ * XXX re-initialize optind to 0 and have getopt_long(3)
+ * XXX properly function again. Work around this braindamage.
+ */
+ if (optind == 0)
+ optind = 1;
+
+ if (optreset)
+ nonopt_start = nonopt_end = -1;
+start:
+ if (optreset || !*place) { /* update scanning pointer */
+ optreset = 0;
+ if (optind >= nargc) { /* end of argument vector */
+ place = EMSG;
+ if (nonopt_end != -1) {
+ /* do permutation, if we have to */
+ permute_args(nonopt_start, nonopt_end,
+ optind, nargv);
+ optind -= nonopt_end - nonopt_start;
+ }
+ else if (nonopt_start != -1) {
+ /*
+ * If we skipped non-options, set optind
+ * to the first of them.
+ */
+ optind = nonopt_start;
+ }
+ nonopt_start = nonopt_end = -1;
+ return -1;
+ }
+ if ((*(place = nargv[optind]) != '-')
+ || (place[1] == '\0')) { /* found non-option */
+ place = EMSG;
+ if (IN_ORDER) {
+ /*
+ * GNU extension:
+ * return non-option as argument to option 1
+ */
+ optarg = nargv[optind++];
+ return INORDER;
+ }
+ if (!PERMUTE) {
+ /*
+ * if no permutation wanted, stop parsing
+ * at first non-option
+ */
+ return -1;
+ }
+ /* do permutation */
+ if (nonopt_start == -1)
+ nonopt_start = optind;
+ else if (nonopt_end != -1) {
+ permute_args(nonopt_start, nonopt_end,
+ optind, nargv);
+ nonopt_start = optind -
+ (nonopt_end - nonopt_start);
+ nonopt_end = -1;
+ }
+ optind++;
+ /* process next argument */
+ goto start;
+ }
+ if (nonopt_start != -1 && nonopt_end == -1)
+ nonopt_end = optind;
+ if (place[1] && *++place == '-') { /* found "--" */
+ place++;
+ return -2;
+ }
+ }
+ if ((optchar = (int)*place++) == (int)':' ||
+ (oli = strchr(options + (IGNORE_FIRST ? 1 : 0), optchar)) == NULL) {
+ /* option letter unknown or ':' */
+ if (!*place)
+ ++optind;
+ if (PRINT_ERROR)
+ warnx(illoptchar, optchar);
+ optopt = optchar;
+ return BADCH;
+ }
+ if (optchar == 'W' && oli[1] == ';') { /* -W long-option */
+ /* XXX: what if no long options provided (called by getopt)? */
+ if (*place)
+ return -2;
+
+ if (++optind >= nargc) { /* no arg */
+ place = EMSG;
+ if (PRINT_ERROR)
+ warnx(recargchar, optchar);
+ optopt = optchar;
+ return BADARG;
+ } else /* white space */
+ place = nargv[optind];
+ /*
+ * Handle -W arg the same as --arg (which causes getopt to
+ * stop parsing).
+ */
+ return -2;
+ }
+ if (*++oli != ':') { /* doesn't take argument */
+ if (!*place)
+ ++optind;
+ } else { /* takes (optional) argument */
+ optarg = NULL;
+ if (*place) /* no white space */
+ optarg = (char *)place;
+ /* XXX: disable test for :: if PC? (GNU doesn't) */
+ else if (oli[1] != ':') { /* arg not optional */
+ if (++optind >= nargc) { /* no arg */
+ place = EMSG;
+ if (PRINT_ERROR)
+ warnx(recargchar, optchar);
+ optopt = optchar;
+ return BADARG;
+ } else
+ optarg = nargv[optind];
+ }
+ place = EMSG;
+ ++optind;
+ }
+ /* dump back option letter */
+ return optchar;
+}
+
+#ifdef REPLACE_GETOPT
+/*
+ * getopt --
+ * Parse argc/argv argument vector.
+ *
+ * [eventually this will replace the real getopt]
+ */
+int
+getopt(nargc, nargv, options)
+ int nargc;
+ char * const *nargv;
+ const char *options;
+{
+ int retval;
+
+ _DIAGASSERT(nargv != NULL);
+ _DIAGASSERT(options != NULL);
+
+ retval = getopt_internal(nargc, (char **)nargv, options);
+ if (retval == -2) {
+ ++optind;
+ /*
+ * We found an option (--), so if we skipped non-options,
+ * we have to permute.
+ */
+ if (nonopt_end != -1) {
+ permute_args(nonopt_start, nonopt_end, optind,
+ (char **)nargv);
+ optind -= nonopt_end - nonopt_start;
+ }
+ nonopt_start = nonopt_end = -1;
+ retval = -1;
+ }
+ return retval;
+}
+#endif
+
+/*
+ * getopt_long --
+ * Parse argc/argv argument vector.
+ */
+int
+getopt_long(nargc, nargv, options, long_options, idx)
+ int nargc;
+ char * const *nargv;
+ const char *options;
+ const struct option *long_options;
+ int *idx;
+{
+ int retval;
+
+#define IDENTICAL_INTERPRETATION(_x, _y) \
+ (long_options[(_x)].has_arg == long_options[(_y)].has_arg && \
+ long_options[(_x)].flag == long_options[(_y)].flag && \
+ long_options[(_x)].val == long_options[(_y)].val)
+
+ _DIAGASSERT(nargv != NULL);
+ _DIAGASSERT(options != NULL);
+ _DIAGASSERT(long_options != NULL);
+ /* idx may be NULL */
+
+ retval = getopt_internal(nargc, (char **)nargv, options);
+ if (retval == -2) {
+ char *current_argv, *has_equal;
+ size_t current_argv_len;
+ int i, ambiguous, match;
+
+ current_argv = (char *)place;
+ match = -1;
+ ambiguous = 0;
+
+ optind++;
+ place = EMSG;
+
+ if (*current_argv == '\0') { /* found "--" */
+ /*
+ * We found an option (--), so if we skipped
+ * non-options, we have to permute.
+ */
+ if (nonopt_end != -1) {
+ permute_args(nonopt_start, nonopt_end,
+ optind, (char **)nargv);
+ optind -= nonopt_end - nonopt_start;
+ }
+ nonopt_start = nonopt_end = -1;
+ return -1;
+ }
+ if ((has_equal = strchr(current_argv, '=')) != NULL) {
+ /* argument found (--option=arg) */
+ current_argv_len = has_equal - current_argv;
+ has_equal++;
+ } else
+ current_argv_len = strlen(current_argv);
+
+ for (i = 0; long_options[i].name; i++) {
+ /* find matching long option */
+ if (strncmp(current_argv, long_options[i].name,
+ current_argv_len))
+ continue;
+
+ if (strlen(long_options[i].name) ==
+ (unsigned)current_argv_len) {
+ /* exact match */
+ match = i;
+ ambiguous = 0;
+ break;
+ }
+ if (match == -1) /* partial match */
+ match = i;
+ else if (!IDENTICAL_INTERPRETATION(i, match))
+ ambiguous = 1;
+ }
+ if (ambiguous) {
+ /* ambiguous abbreviation */
+ if (PRINT_ERROR)
+ warnx(ambig, (int)current_argv_len,
+ current_argv);
+ optopt = 0;
+ return BADCH;
+ }
+ if (match != -1) { /* option found */
+ if (long_options[match].has_arg == no_argument
+ && has_equal) {
+ if (PRINT_ERROR)
+ warnx(noarg, (int)current_argv_len,
+ current_argv);
+ /*
+ * XXX: GNU sets optopt to val regardless of
+ * flag
+ */
+ if (long_options[match].flag == NULL)
+ optopt = long_options[match].val;
+ else
+ optopt = 0;
+ return BADARG;
+ }
+ if (long_options[match].has_arg == required_argument ||
+ long_options[match].has_arg == optional_argument) {
+ if (has_equal)
+ optarg = has_equal;
+ else if (long_options[match].has_arg ==
+ required_argument) {
+ /*
+ * optional argument doesn't use
+ * next nargv
+ */
+ optarg = nargv[optind++];
+ }
+ }
+ if ((long_options[match].has_arg == required_argument)
+ && (optarg == NULL)) {
+ /*
+ * Missing argument; leading ':'
+ * indicates no error should be generated
+ */
+ if (PRINT_ERROR)
+ warnx(recargstring, current_argv);
+ /*
+ * XXX: GNU sets optopt to val regardless
+ * of flag
+ */
+ if (long_options[match].flag == NULL)
+ optopt = long_options[match].val;
+ else
+ optopt = 0;
+ --optind;
+ return BADARG;
+ }
+ } else { /* unknown option */
+ if (PRINT_ERROR)
+ warnx(illoptstring, current_argv);
+ optopt = 0;
+ return BADCH;
+ }
+ if (long_options[match].flag) {
+ *long_options[match].flag = long_options[match].val;
+ retval = 0;
+ } else
+ retval = long_options[match].val;
+ if (idx)
+ *idx = match;
+ }
+ return retval;
+#undef IDENTICAL_INTERPRETATION
+}
diff --git a/node_modules/mmmagic/deps/libmagic/src/gmtime_r.c b/node_modules/mmmagic/deps/libmagic/src/gmtime_r.c
new file mode 100644
index 0000000..469ec65
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/gmtime_r.c
@@ -0,0 +1,19 @@
+/* $File: gmtime_r.c,v 1.2 2015/07/11 14:41:37 christos Exp $ */
+
+#include "file.h"
+#ifndef lint
+FILE_RCSID("@(#)$File: gmtime_r.c,v 1.2 2015/07/11 14:41:37 christos Exp $")
+#endif /* lint */
+#include <time.h>
+#include <string.h>
+
+/* asctime_r is not thread-safe anyway */
+struct tm *
+gmtime_r(const time_t *t, struct tm *tm)
+{
+ struct tm *tmp = gmtime(t);
+ if (tmp == NULL)
+ return NULL;
+ memcpy(tm, tmp, sizeof(*tm));
+ return tmp;
+}
diff --git a/node_modules/mmmagic/deps/libmagic/src/is_tar.c b/node_modules/mmmagic/deps/libmagic/src/is_tar.c
new file mode 100644
index 0000000..1953a7f
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/is_tar.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) Ian F. Darwin 1986-1995.
+ * Software written by Ian F. Darwin and others;
+ * maintained 1995-present by Christos Zoulas and others.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice immediately at the beginning of the file, without modification,
+ * this list of conditions, and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+/*
+ * is_tar() -- figure out whether file is a tar archive.
+ *
+ * Stolen (by the author!) from the public domain tar program:
+ * Public Domain version written 26 Aug 1985 John Gilmore (ihnp4!hoptoad!gnu).
+ *
+ * @(#)list.c 1.18 9/23/86 Public Domain - gnu
+ *
+ * Comments changed and some code/comments reformatted
+ * for file command by Ian Darwin.
+ */
+
+#include "file.h"
+
+#ifndef lint
+FILE_RCSID("@(#)$File: is_tar.c,v 1.39 2017/03/17 20:45:01 christos Exp $")
+#endif
+
+#include "magic.h"
+#include <string.h>
+#include <ctype.h>
+#include "tar.h"
+
+#define isodigit(c) ( ((c) >= '0') && ((c) <= '7') )
+
+private int is_tar(const unsigned char *, size_t);
+private int from_oct(const char *, size_t); /* Decode octal number */
+
+static const char tartype[][32] = {
+ "tar archive",
+ "POSIX tar archive",
+ "POSIX tar archive (GNU)",
+};
+
+protected int
+file_is_tar(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
+{
+ /*
+ * Do the tar test first, because if the first file in the tar
+ * archive starts with a dot, we can confuse it with an nroff file.
+ */
+ int tar;
+ int mime = ms->flags & MAGIC_MIME;
+
+ if ((ms->flags & (MAGIC_APPLE|MAGIC_EXTENSION)) != 0)
+ return 0;
+
+ tar = is_tar(buf, nbytes);
+ if (tar < 1 || tar > 3)
+ return 0;
+
+ if (file_printf(ms, "%s", mime ? "application/x-tar" :
+ tartype[tar - 1]) == -1)
+ return -1;
+ return 1;
+}
+
+/*
+ * Return
+ * 0 if the checksum is bad (i.e., probably not a tar archive),
+ * 1 for old UNIX tar file,
+ * 2 for Unix Std (POSIX) tar file,
+ * 3 for GNU tar file.
+ */
+private int
+is_tar(const unsigned char *buf, size_t nbytes)
+{
+ const union record *header = (const union record *)(const void *)buf;
+ size_t i;
+ int sum, recsum;
+ const unsigned char *p, *ep;
+
+ if (nbytes < sizeof(*header))
+ return 0;
+
+ recsum = from_oct(header->header.chksum, sizeof(header->header.chksum));
+
+ sum = 0;
+ p = header->charptr;
+ ep = header->charptr + sizeof(*header);
+ while (p < ep)
+ sum += *p++;
+
+ /* Adjust checksum to count the "chksum" field as blanks. */
+ for (i = 0; i < sizeof(header->header.chksum); i++)
+ sum -= header->header.chksum[i];
+ sum += ' ' * sizeof(header->header.chksum);
+
+ if (sum != recsum)
+ return 0; /* Not a tar archive */
+
+ if (strncmp(header->header.magic, GNUTMAGIC,
+ sizeof(header->header.magic)) == 0)
+ return 3; /* GNU Unix Standard tar archive */
+
+ if (strncmp(header->header.magic, TMAGIC,
+ sizeof(header->header.magic)) == 0)
+ return 2; /* Unix Standard tar archive */
+
+ return 1; /* Old fashioned tar archive */
+}
+
+
+/*
+ * Quick and dirty octal conversion.
+ *
+ * Result is -1 if the field is invalid (all blank, or non-octal).
+ */
+private int
+from_oct(const char *where, size_t digs)
+{
+ int value;
+
+ if (digs == 0)
+ return -1;
+
+ while (isspace((unsigned char)*where)) { /* Skip spaces */
+ where++;
+ if (digs-- == 0)
+ return -1; /* All blank field */
+ }
+ value = 0;
+ while (digs > 0 && isodigit(*where)) { /* Scan til non-octal */
+ value = (value << 3) | (*where++ - '0');
+ digs--;
+ }
+
+ if (digs > 0 && *where && !isspace((unsigned char)*where))
+ return -1; /* Ended on non-(space/NUL) */
+
+ return value;
+}
diff --git a/node_modules/mmmagic/deps/libmagic/src/localtime_r.c b/node_modules/mmmagic/deps/libmagic/src/localtime_r.c
new file mode 100644
index 0000000..b0d996d
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/localtime_r.c
@@ -0,0 +1,19 @@
+/* $File: localtime_r.c,v 1.2 2015/07/11 14:41:37 christos Exp $ */
+
+#include "file.h"
+#ifndef lint
+FILE_RCSID("@(#)$File: localtime_r.c,v 1.2 2015/07/11 14:41:37 christos Exp $")
+#endif /* lint */
+#include <time.h>
+#include <string.h>
+
+/* asctime_r is not thread-safe anyway */
+struct tm *
+localtime_r(const time_t *t, struct tm *tm)
+{
+ struct tm *tmp = localtime(t);
+ if (tmp == NULL)
+ return NULL;
+ memcpy(tm, tmp, sizeof(*tm));
+ return tmp;
+}
diff --git a/node_modules/mmmagic/deps/libmagic/src/magic.c b/node_modules/mmmagic/deps/libmagic/src/magic.c
new file mode 100644
index 0000000..91c9d82
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/magic.c
@@ -0,0 +1,662 @@
+/*
+ * Copyright (c) Christos Zoulas 2003.
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice immediately at the beginning of the file, without modification,
+ * this list of conditions, and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+// XXX: change by mscdex
+#ifdef _MSC_VER
+#include <windows.h>
+#include <shlwapi.h>
+#endif
+
+#include "file.h"
+
+#ifndef lint
+FILE_RCSID("@(#)$File: magic.c,v 1.102 2017/08/28 13:39:18 christos Exp $")
+#endif /* lint */
+
+#include "magic.h"
+
+#include <stdlib.h>
+// XXX: change by mscdex
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <string.h>
+#ifdef QUICK
+#include <sys/mman.h>
+#endif
+#ifdef HAVE_LIMITS_H
+#include <limits.h> /* for PIPE_BUF */
+#endif
+
+#if defined(HAVE_UTIMES)
+# include <sys/time.h>
+#elif defined(HAVE_UTIME)
+# if defined(HAVE_SYS_UTIME_H)
+# include <sys/utime.h>
+# elif defined(HAVE_UTIME_H)
+# include <utime.h>
+# endif
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h> /* for read() */
+#endif
+
+#ifndef PIPE_BUF
+/* Get the PIPE_BUF from pathconf */
+#ifdef _PC_PIPE_BUF
+#define PIPE_BUF pathconf(".", _PC_PIPE_BUF)
+#else
+#define PIPE_BUF 512
+#endif
+#endif
+
+private void close_and_restore(const struct magic_set *, const char *, int,
+ const struct stat *);
+private int unreadable_info(struct magic_set *, mode_t, const char *);
+private const char* get_default_magic(void);
+#ifndef COMPILE_ONLY
+private const char *file_or_fd(struct magic_set *, const char *, int);
+#endif
+
+#ifndef STDIN_FILENO
+#define STDIN_FILENO 0
+#endif
+
+#ifdef WIN32
+/* HINSTANCE of this shared library. Needed for get_default_magic() */
+static HINSTANCE _w32_dll_instance = NULL;
+
+static void
+_w32_append_path(char **hmagicpath, const char *fmt, ...)
+{
+ char *tmppath;
+ char *newpath;
+ va_list ap;
+
+ va_start(ap, fmt);
+ if (vasprintf(&tmppath, fmt, ap) < 0) {
+ va_end(ap);
+ return;
+ }
+ va_end(ap);
+
+ if (access(tmppath, R_OK) == -1)
+ goto out;
+
+ if (*hmagicpath == NULL) {
+ *hmagicpath = tmppath;
+ return;
+ }
+
+ if (asprintf(&newpath, "%s%c%s", *hmagicpath, PATHSEP, tmppath) < 0)
+ goto out;
+
+ free(*hmagicpath);
+ free(tmppath);
+ *hmagicpath = newpath;
+ return;
+out:
+ free(tmppath);
+}
+
+static void
+_w32_get_magic_relative_to(char **hmagicpath, HINSTANCE module)
+{
+ static const char *trypaths[] = {
+ "%s/share/misc/magic.mgc",
+ "%s/magic.mgc",
+ };
+ LPSTR dllpath;
+ size_t sp;
+
+ dllpath = calloc(MAX_PATH + 1, sizeof(*dllpath));
+
+ if (!GetModuleFileNameA(module, dllpath, MAX_PATH))
+ goto out;
+
+ PathRemoveFileSpecA(dllpath);
+
+ if (module) {
+ char exepath[MAX_PATH];
+ GetModuleFileNameA(NULL, exepath, MAX_PATH);
+ PathRemoveFileSpecA(exepath);
+ if (stricmp(exepath, dllpath) == 0)
+ goto out;
+ }
+
+ sp = strlen(dllpath);
+ if (sp > 3 && stricmp(&dllpath[sp - 3], "bin") == 0) {
+ _w32_append_path(hmagicpath,
+ "%s/../share/misc/magic.mgc", dllpath);
+ goto out;
+ }
+
+ for (sp = 0; sp < __arraycount(trypaths); sp++)
+ _w32_append_path(hmagicpath, trypaths[sp], dllpath);
+out:
+ free(dllpath);
+}
+
+/* Placate GCC by offering a sacrificial previous prototype */
+BOOL WINAPI DllMain(HINSTANCE, DWORD, LPVOID);
+
+BOOL WINAPI
+DllMain(HINSTANCE hinstDLL, DWORD fdwReason,
+ LPVOID lpvReserved __attribute__((__unused__)))
+{
+ if (fdwReason == DLL_PROCESS_ATTACH)
+ _w32_dll_instance = hinstDLL;
+ return 1;
+}
+#endif
+
+private const char *
+get_default_magic(void)
+{
+ static const char hmagic[] = "/.magic/magic.mgc";
+ static char *default_magic;
+ char *home, *hmagicpath;
+
+#ifndef WIN32
+ struct stat st;
+
+ if (default_magic) {
+ free(default_magic);
+ default_magic = NULL;
+ }
+ if ((home = getenv("HOME")) == NULL)
+ return MAGIC;
+
+ if (asprintf(&hmagicpath, "%s/.magic.mgc", home) < 0)
+ return MAGIC;
+ if (stat(hmagicpath, &st) == -1) {
+ free(hmagicpath);
+ if (asprintf(&hmagicpath, "%s/.magic", home) < 0)
+ return MAGIC;
+ if (stat(hmagicpath, &st) == -1)
+ goto out;
+ if (S_ISDIR(st.st_mode)) {
+ free(hmagicpath);
+ if (asprintf(&hmagicpath, "%s/%s", home, hmagic) < 0)
+ return MAGIC;
+ if (access(hmagicpath, R_OK) == -1)
+ goto out;
+ }
+ }
+
+ if (asprintf(&default_magic, "%s:%s", hmagicpath, MAGIC) < 0)
+ goto out;
+ free(hmagicpath);
+ return default_magic;
+out:
+ default_magic = NULL;
+ free(hmagicpath);
+ return MAGIC;
+#else
+ hmagicpath = NULL;
+
+ if (default_magic) {
+ free(default_magic);
+ default_magic = NULL;
+ }
+
+ /* First, try to get a magic file from user-application data */
+ if ((home = getenv("LOCALAPPDATA")) != NULL)
+ _w32_append_path(&hmagicpath, "%s%s", home, hmagic);
+
+ /* Second, try to get a magic file from the user profile data */
+ if ((home = getenv("USERPROFILE")) != NULL)
+ _w32_append_path(&hmagicpath,
+ "%s/Local Settings/Application Data%s", home, hmagic);
+
+ /* Third, try to get a magic file from Common Files */
+ if ((home = getenv("COMMONPROGRAMFILES")) != NULL)
+ _w32_append_path(&hmagicpath, "%s%s", home, hmagic);
+
+ /* Fourth, try to get magic file relative to exe location */
+ _w32_get_magic_relative_to(&hmagicpath, NULL);
+
+ /* Fifth, try to get magic file relative to dll location */
+ _w32_get_magic_relative_to(&hmagicpath, _w32_dll_instance);
+
+ /* Avoid MAGIC constant - it likely points to a file within MSys tree */
+ default_magic = hmagicpath;
+ return default_magic;
+#endif
+}
+
+public const char *
+magic_getpath(const char *magicfile, int action)
+{
+ if (magicfile != NULL)
+ return magicfile;
+
+ magicfile = getenv("MAGIC");
+ if (magicfile != NULL)
+ return magicfile;
+
+ return action == FILE_LOAD ? get_default_magic() : MAGIC;
+}
+
+public struct magic_set *
+magic_open(int flags)
+{
+ return file_ms_alloc(flags);
+}
+
+private int
+unreadable_info(struct magic_set *ms, mode_t md, const char *file)
+{
+ if (file) {
+ /* We cannot open it, but we were able to stat it. */
+ if (access(file, W_OK) == 0)
+ if (file_printf(ms, "writable, ") == -1)
+ return -1;
+ if (access(file, X_OK) == 0)
+ if (file_printf(ms, "executable, ") == -1)
+ return -1;
+ }
+ if (S_ISREG(md))
+ if (file_printf(ms, "regular file, ") == -1)
+ return -1;
+ if (file_printf(ms, "no read permission") == -1)
+ return -1;
+ return 0;
+}
+
+public void
+magic_close(struct magic_set *ms)
+{
+ if (ms == NULL)
+ return;
+ file_ms_free(ms);
+}
+
+/*
+ * load a magic file
+ */
+public int
+magic_load(struct magic_set *ms, const char *magicfile)
+{
+ if (ms == NULL)
+ return -1;
+ return file_apprentice(ms, magicfile, FILE_LOAD);
+}
+
+#ifndef COMPILE_ONLY
+/*
+ * Install a set of compiled magic buffers.
+ */
+public int
+magic_load_buffers(struct magic_set *ms, void **bufs, size_t *sizes,
+ size_t nbufs)
+{
+ if (ms == NULL)
+ return -1;
+ return buffer_apprentice(ms, (struct magic **)bufs, sizes, nbufs);
+}
+#endif
+
+public int
+magic_compile(struct magic_set *ms, const char *magicfile)
+{
+ if (ms == NULL)
+ return -1;
+ return file_apprentice(ms, magicfile, FILE_COMPILE);
+}
+
+public int
+magic_check(struct magic_set *ms, const char *magicfile)
+{
+ if (ms == NULL)
+ return -1;
+ return file_apprentice(ms, magicfile, FILE_CHECK);
+}
+
+public int
+magic_list(struct magic_set *ms, const char *magicfile)
+{
+ if (ms == NULL)
+ return -1;
+ return file_apprentice(ms, magicfile, FILE_LIST);
+}
+
+private void
+close_and_restore(const struct magic_set *ms, const char *name, int fd,
+ const struct stat *sb)
+{
+ if (fd == STDIN_FILENO || name == NULL)
+ return;
+ (void) close(fd);
+
+ if ((ms->flags & MAGIC_PRESERVE_ATIME) != 0) {
+ /*
+ * Try to restore access, modification times if read it.
+ * This is really *bad* because it will modify the status
+ * time of the file... And of course this will affect
+ * backup programs
+ */
+#ifdef HAVE_UTIMES
+ struct timeval utsbuf[2];
+ (void)memset(utsbuf, 0, sizeof(utsbuf));
+ utsbuf[0].tv_sec = sb->st_atime;
+ utsbuf[1].tv_sec = sb->st_mtime;
+
+ (void) utimes(name, utsbuf); /* don't care if loses */
+#elif defined(HAVE_UTIME_H) || defined(HAVE_SYS_UTIME_H)
+ struct utimbuf utbuf;
+
+ (void)memset(&utbuf, 0, sizeof(utbuf));
+ utbuf.actime = sb->st_atime;
+ utbuf.modtime = sb->st_mtime;
+ (void) utime(name, &utbuf); /* don't care if loses */
+#endif
+ }
+}
+
+#ifndef COMPILE_ONLY
+
+/*
+ * find type of descriptor
+ */
+public const char *
+magic_descriptor(struct magic_set *ms, int fd)
+{
+ if (ms == NULL)
+ return NULL;
+ return file_or_fd(ms, NULL, fd);
+}
+
+/*
+ * find type of named file
+ */
+public const char *
+magic_file(struct magic_set *ms, const char *inname)
+{
+ if (ms == NULL)
+ return NULL;
+ return file_or_fd(ms, inname, STDIN_FILENO);
+}
+
+private const char *
+file_or_fd(struct magic_set *ms, const char *inname, int fd)
+{
+ int rv = -1;
+ unsigned char *buf;
+ struct stat sb;
+ ssize_t nbytes = 0; /* number of bytes read from a datafile */
+ int ispipe = 0;
+ off_t pos = (off_t)-1;
+
+ if (file_reset(ms, 1) == -1)
+ goto out;
+
+ /*
+ * one extra for terminating '\0', and
+ * some overlapping space for matches near EOF
+ */
+#define SLOP (1 + sizeof(union VALUETYPE))
+ if ((buf = CAST(unsigned char *, malloc(ms->bytes_max + SLOP))) == NULL)
+ return NULL;
+
+ switch (file_fsmagic(ms, inname, &sb)) {
+ case -1: /* error */
+ goto done;
+ case 0: /* nothing found */
+ break;
+ default: /* matched it and printed type */
+ rv = 0;
+ goto done;
+ }
+
+#ifdef WIN32
+ /* Place stdin in binary mode, so EOF (Ctrl+Z) doesn't stop early. */
+ if (fd == STDIN_FILENO)
+ _setmode(STDIN_FILENO, O_BINARY);
+#endif
+
+ if (inname == NULL) {
+ if (fstat(fd, &sb) == 0 && S_ISFIFO(sb.st_mode))
+ ispipe = 1;
+ else
+ pos = lseek(fd, (off_t)0, SEEK_CUR);
+ } else {
+ int flags = O_RDONLY|O_BINARY;
+ int okstat = stat(inname, &sb) == 0;
+
+ if (okstat && S_ISFIFO(sb.st_mode)) {
+#ifdef O_NONBLOCK
+ flags |= O_NONBLOCK;
+#endif
+ ispipe = 1;
+ }
+
+ errno = 0;
+ if ((fd = open(inname, flags)) < 0) {
+#ifdef WIN32
+ /*
+ * Can't stat, can't open. It may have been opened in
+ * fsmagic, so if the user doesn't have read permission,
+ * allow it to say so; otherwise an error was probably
+ * displayed in fsmagic.
+ */
+ if (!okstat && errno == EACCES) {
+ sb.st_mode = S_IFBLK;
+ okstat = 1;
+ }
+#endif
+ if (okstat &&
+ unreadable_info(ms, sb.st_mode, inname) == -1)
+ goto done;
+ rv = 0;
+ goto done;
+ }
+#ifdef O_NONBLOCK
+ if ((flags = fcntl(fd, F_GETFL)) != -1) {
+ flags &= ~O_NONBLOCK;
+ (void)fcntl(fd, F_SETFL, flags);
+ }
+#endif
+ }
+
+ /*
+ * try looking at the first ms->bytes_max bytes
+ */
+ if (ispipe) {
+ ssize_t r = 0;
+
+ while ((r = sread(fd, (void *)&buf[nbytes],
+ (size_t)(ms->bytes_max - nbytes), 1)) > 0) {
+ nbytes += r;
+ if (r < PIPE_BUF) break;
+ }
+
+ if (nbytes == 0 && inname) {
+ /* We can not read it, but we were able to stat it. */
+ if (unreadable_info(ms, sb.st_mode, inname) == -1)
+ goto done;
+ rv = 0;
+ goto done;
+ }
+
+ } else {
+ /* Windows refuses to read from a big console buffer. */
+ size_t howmany =
+#if defined(WIN32)
+ _isatty(fd) ? 8 * 1024 :
+#endif
+ ms->bytes_max;
+ if ((nbytes = read(fd, (char *)buf, howmany)) == -1) {
+ if (inname == NULL && fd != STDIN_FILENO)
+ file_error(ms, errno, "cannot read fd %d", fd);
+ else
+ file_error(ms, errno, "cannot read `%s'",
+ inname == NULL ? "/dev/stdin" : inname);
+ goto done;
+ }
+ }
+
+ (void)memset(buf + nbytes, 0, SLOP); /* NUL terminate */
+ if (file_buffer(ms, fd, inname, buf, (size_t)nbytes) == -1)
+ goto done;
+ rv = 0;
+done:
+ free(buf);
+ if (fd != -1) {
+ if (pos != (off_t)-1)
+ (void)lseek(fd, pos, SEEK_SET);
+ close_and_restore(ms, inname, fd, &sb);
+ }
+out:
+ return rv == 0 ? file_getbuffer(ms) : NULL;
+}
+
+
+public const char *
+magic_buffer(struct magic_set *ms, const void *buf, size_t nb)
+{
+ if (ms == NULL)
+ return NULL;
+ if (file_reset(ms, 1) == -1)
+ return NULL;
+ /*
+ * The main work is done here!
+ * We have the file name and/or the data buffer to be identified.
+ */
+ if (file_buffer(ms, -1, NULL, buf, nb) == -1) {
+ return NULL;
+ }
+ return file_getbuffer(ms);
+}
+#endif
+
+public const char *
+magic_error(struct magic_set *ms)
+{
+ if (ms == NULL)
+ return "Magic database is not open";
+ return (ms->event_flags & EVENT_HAD_ERR) ? ms->o.buf : NULL;
+}
+
+public int
+magic_errno(struct magic_set *ms)
+{
+ if (ms == NULL)
+ return EINVAL;
+ return (ms->event_flags & EVENT_HAD_ERR) ? ms->error : 0;
+}
+
+public int
+magic_getflags(struct magic_set *ms)
+{
+ if (ms == NULL)
+ return -1;
+
+ return ms->flags;
+}
+
+public int
+magic_setflags(struct magic_set *ms, int flags)
+{
+ if (ms == NULL)
+ return -1;
+#if !defined(HAVE_UTIME) && !defined(HAVE_UTIMES)
+ if (flags & MAGIC_PRESERVE_ATIME)
+ return -1;
+#endif
+ ms->flags = flags;
+ return 0;
+}
+
+public int
+magic_version(void)
+{
+ return MAGIC_VERSION;
+}
+
+public int
+magic_setparam(struct magic_set *ms, int param, const void *val)
+{
+ switch (param) {
+ case MAGIC_PARAM_INDIR_MAX:
+ ms->indir_max = (uint16_t)*(const size_t *)val;
+ return 0;
+ case MAGIC_PARAM_NAME_MAX:
+ ms->name_max = (uint16_t)*(const size_t *)val;
+ return 0;
+ case MAGIC_PARAM_ELF_PHNUM_MAX:
+ ms->elf_phnum_max = (uint16_t)*(const size_t *)val;
+ return 0;
+ case MAGIC_PARAM_ELF_SHNUM_MAX:
+ ms->elf_shnum_max = (uint16_t)*(const size_t *)val;
+ return 0;
+ case MAGIC_PARAM_ELF_NOTES_MAX:
+ ms->elf_notes_max = (uint16_t)*(const size_t *)val;
+ return 0;
+ case MAGIC_PARAM_REGEX_MAX:
+ ms->elf_notes_max = (uint16_t)*(const size_t *)val;
+ return 0;
+ case MAGIC_PARAM_BYTES_MAX:
+ ms->bytes_max = *(const size_t *)val;
+ return 0;
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+}
+
+public int
+magic_getparam(struct magic_set *ms, int param, void *val)
+{
+ switch (param) {
+ case MAGIC_PARAM_INDIR_MAX:
+ *(size_t *)val = ms->indir_max;
+ return 0;
+ case MAGIC_PARAM_NAME_MAX:
+ *(size_t *)val = ms->name_max;
+ return 0;
+ case MAGIC_PARAM_ELF_PHNUM_MAX:
+ *(size_t *)val = ms->elf_phnum_max;
+ return 0;
+ case MAGIC_PARAM_ELF_SHNUM_MAX:
+ *(size_t *)val = ms->elf_shnum_max;
+ return 0;
+ case MAGIC_PARAM_ELF_NOTES_MAX:
+ *(size_t *)val = ms->elf_notes_max;
+ return 0;
+ case MAGIC_PARAM_REGEX_MAX:
+ *(size_t *)val = ms->regex_max;
+ return 0;
+ case MAGIC_PARAM_BYTES_MAX:
+ *(size_t *)val = ms->bytes_max;
+ return 0;
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+}
diff --git a/node_modules/mmmagic/deps/libmagic/src/magic.h b/node_modules/mmmagic/deps/libmagic/src/magic.h
new file mode 100644
index 0000000..2d707d5
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/magic.h
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) Christos Zoulas 2003.
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice immediately at the beginning of the file, without modification,
+ * this list of conditions, and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#ifndef _MAGIC_H
+#define _MAGIC_H
+
+#include <sys/types.h>
+
+#define MAGIC_NONE 0x0000000 /* No flags */
+#define MAGIC_DEBUG 0x0000001 /* Turn on debugging */
+#define MAGIC_SYMLINK 0x0000002 /* Follow symlinks */
+#define MAGIC_COMPRESS 0x0000004 /* Check inside compressed files */
+#define MAGIC_DEVICES 0x0000008 /* Look at the contents of devices */
+#define MAGIC_MIME_TYPE 0x0000010 /* Return the MIME type */
+#define MAGIC_CONTINUE 0x0000020 /* Return all matches */
+#define MAGIC_CHECK 0x0000040 /* Print warnings to stderr */
+#define MAGIC_PRESERVE_ATIME 0x0000080 /* Restore access time on exit */
+#define MAGIC_RAW 0x0000100 /* Don't convert unprintable chars */
+#define MAGIC_ERROR 0x0000200 /* Handle ENOENT etc as real errors */
+#define MAGIC_MIME_ENCODING 0x0000400 /* Return the MIME encoding */
+#define MAGIC_MIME (MAGIC_MIME_TYPE|MAGIC_MIME_ENCODING)
+#define MAGIC_APPLE 0x0000800 /* Return the Apple creator/type */
+#define MAGIC_EXTENSION 0x1000000 /* Return a /-separated list of
+ * extensions */
+#define MAGIC_COMPRESS_TRANSP 0x2000000 /* Check inside compressed files
+ * but not report compression */
+#define MAGIC_NODESC (MAGIC_EXTENSION|MAGIC_MIME|MAGIC_APPLE)
+
+#define MAGIC_NO_CHECK_COMPRESS 0x0001000 /* Don't check for compressed files */
+#define MAGIC_NO_CHECK_TAR 0x0002000 /* Don't check for tar files */
+#define MAGIC_NO_CHECK_SOFT 0x0004000 /* Don't check magic entries */
+#define MAGIC_NO_CHECK_APPTYPE 0x0008000 /* Don't check application type */
+#define MAGIC_NO_CHECK_ELF 0x0010000 /* Don't check for elf details */
+#define MAGIC_NO_CHECK_TEXT 0x0020000 /* Don't check for text files */
+#define MAGIC_NO_CHECK_CDF 0x0040000 /* Don't check for cdf files */
+#define MAGIC_NO_CHECK_TOKENS 0x0100000 /* Don't check tokens */
+#define MAGIC_NO_CHECK_ENCODING 0x0200000 /* Don't check text encodings */
+
+/* No built-in tests; only consult the magic file */
+#define MAGIC_NO_CHECK_BUILTIN ( \
+ MAGIC_NO_CHECK_COMPRESS | \
+ MAGIC_NO_CHECK_TAR | \
+/* MAGIC_NO_CHECK_SOFT | */ \
+ MAGIC_NO_CHECK_APPTYPE | \
+ MAGIC_NO_CHECK_ELF | \
+ MAGIC_NO_CHECK_TEXT | \
+ MAGIC_NO_CHECK_CDF | \
+ MAGIC_NO_CHECK_TOKENS | \
+ MAGIC_NO_CHECK_ENCODING | \
+ 0 \
+)
+
+#define MAGIC_SNPRINTB "\177\020\
+b\0debug\0\
+b\1symlink\0\
+b\2compress\0\
+b\3devices\0\
+b\4mime_type\0\
+b\5continue\0\
+b\6check\0\
+b\7preserve_atime\0\
+b\10raw\0\
+b\11error\0\
+b\12mime_encoding\0\
+b\13apple\0\
+b\14no_check_compress\0\
+b\15no_check_tar\0\
+b\16no_check_soft\0\
+b\17no_check_sapptype\0\
+b\20no_check_elf\0\
+b\21no_check_text\0\
+b\22no_check_cdf\0\
+b\23no_check_reserved0\0\
+b\24no_check_tokens\0\
+b\25no_check_encoding\0\
+b\26no_check_reserved1\0\
+b\27no_check_reserved2\0\
+b\30extension\0\
+b\31transp_compression\0\
+"
+
+/* Defined for backwards compatibility (renamed) */
+#define MAGIC_NO_CHECK_ASCII MAGIC_NO_CHECK_TEXT
+
+/* Defined for backwards compatibility; do nothing */
+#define MAGIC_NO_CHECK_FORTRAN 0x000000 /* Don't check ascii/fortran */
+#define MAGIC_NO_CHECK_TROFF 0x000000 /* Don't check ascii/troff */
+
+#define MAGIC_VERSION 532 /* This implementation */
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct magic_set *magic_t;
+magic_t magic_open(int);
+void magic_close(magic_t);
+
+const char *magic_getpath(const char *, int);
+const char *magic_file(magic_t, const char *);
+const char *magic_descriptor(magic_t, int);
+const char *magic_buffer(magic_t, const void *, size_t);
+
+const char *magic_error(magic_t);
+int magic_getflags(magic_t);
+int magic_setflags(magic_t, int);
+
+int magic_version(void);
+int magic_load(magic_t, const char *);
+int magic_load_buffers(magic_t, void **, size_t *, size_t);
+
+int magic_compile(magic_t, const char *);
+int magic_check(magic_t, const char *);
+int magic_list(magic_t, const char *);
+int magic_errno(magic_t);
+
+#define MAGIC_PARAM_INDIR_MAX 0
+#define MAGIC_PARAM_NAME_MAX 1
+#define MAGIC_PARAM_ELF_PHNUM_MAX 2
+#define MAGIC_PARAM_ELF_SHNUM_MAX 3
+#define MAGIC_PARAM_ELF_NOTES_MAX 4
+#define MAGIC_PARAM_REGEX_MAX 5
+#define MAGIC_PARAM_BYTES_MAX 6
+
+int magic_setparam(magic_t, int, const void *);
+int magic_getparam(magic_t, int, void *);
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif /* _MAGIC_H */
diff --git a/node_modules/mmmagic/deps/libmagic/src/mygetopt.h b/node_modules/mmmagic/deps/libmagic/src/mygetopt.h
new file mode 100644
index 0000000..ef87525
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/mygetopt.h
@@ -0,0 +1,68 @@
+/* $NetBSD: getopt.h,v 1.8 2007/11/06 19:21:18 christos Exp $ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Dieter Baron and Thomas Klausner.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _GETOPT_H_
+#define _GETOPT_H_
+
+#include <unistd.h>
+
+/*
+ * Gnu like getopt_long() and BSD4.4 getsubopt()/optreset extensions
+ */
+#define no_argument 0
+#define required_argument 1
+#define optional_argument 2
+
+struct option {
+ /* name of long option */
+ const char *name;
+ /*
+ * one of no_argument, required_argument, and optional_argument:
+ * whether option takes an argument
+ */
+ int has_arg;
+ /* if not NULL, set *flag to val when option found */
+ int *flag;
+ /* if flag not NULL, value to set *flag to; else return value */
+ int val;
+};
+
+int getopt_long(int, char * const *, const char *,
+ const struct option *, int *);
+
+#endif /* !_GETOPT_H_ */
diff --git a/node_modules/mmmagic/deps/libmagic/src/pread.c b/node_modules/mmmagic/deps/libmagic/src/pread.c
new file mode 100644
index 0000000..0de518f
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/pread.c
@@ -0,0 +1,26 @@
+#include "file.h"
+#ifndef lint
+FILE_RCSID("@(#)$File: pread.c,v 1.3 2014/09/15 19:11:25 christos Exp $")
+#endif /* lint */
+#include <fcntl.h>
+// XXX: change by mscdex
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+ssize_t
+pread(int fd, void *buf, size_t len, off_t off) {
+ off_t old;
+ ssize_t rv;
+
+ if ((old = lseek(fd, off, SEEK_SET)) == -1)
+ return -1;
+
+ if ((rv = read(fd, buf, len)) == -1)
+ return -1;
+
+ if (lseek(fd, old, SEEK_SET) == -1)
+ return -1;
+
+ return rv;
+}
diff --git a/node_modules/mmmagic/deps/libmagic/src/print.c b/node_modules/mmmagic/deps/libmagic/src/print.c
new file mode 100644
index 0000000..0b91863
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/print.c
@@ -0,0 +1,264 @@
+/*
+ * Copyright (c) Ian F. Darwin 1986-1995.
+ * Software written by Ian F. Darwin and others;
+ * maintained 1995-present by Christos Zoulas and others.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice immediately at the beginning of the file, without modification,
+ * this list of conditions, and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+/*
+ * print.c - debugging printout routines
+ */
+
+#include "file.h"
+
+#ifndef lint
+FILE_RCSID("@(#)$File: print.c,v 1.82 2017/02/10 18:14:01 christos Exp $")
+#endif /* lint */
+
+#include <string.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <time.h>
+
+#define SZOF(a) (sizeof(a) / sizeof(a[0]))
+
+#include "cdf.h"
+
+#ifndef COMPILE_ONLY
+protected void
+file_mdump(struct magic *m)
+{
+ static const char optyp[] = { FILE_OPS };
+ char tbuf[26];
+
+ (void) fprintf(stderr, "%u: %.*s %u", m->lineno,
+ (m->cont_level & 7) + 1, ">>>>>>>>", m->offset);
+
+ if (m->flag & INDIR) {
+ (void) fprintf(stderr, "(%s,",
+ /* Note: type is unsigned */
+ (m->in_type < file_nnames) ? file_names[m->in_type] :
+ "*bad in_type*");
+ if (m->in_op & FILE_OPINVERSE)
+ (void) fputc('~', stderr);
+ (void) fprintf(stderr, "%c%u),",
+ ((size_t)(m->in_op & FILE_OPS_MASK) <
+ SZOF(optyp)) ? optyp[m->in_op & FILE_OPS_MASK] : '?',
+ m->in_offset);
+ }
+ (void) fprintf(stderr, " %s%s", (m->flag & UNSIGNED) ? "u" : "",
+ /* Note: type is unsigned */
+ (m->type < file_nnames) ? file_names[m->type] : "*bad type");
+ if (m->mask_op & FILE_OPINVERSE)
+ (void) fputc('~', stderr);
+
+ if (IS_STRING(m->type)) {
+ if (m->str_flags) {
+ (void) fputc('/', stderr);
+ if (m->str_flags & STRING_COMPACT_WHITESPACE)
+ (void) fputc(CHAR_COMPACT_WHITESPACE, stderr);
+ if (m->str_flags & STRING_COMPACT_OPTIONAL_WHITESPACE)
+ (void) fputc(CHAR_COMPACT_OPTIONAL_WHITESPACE,
+ stderr);
+ if (m->str_flags & STRING_IGNORE_LOWERCASE)
+ (void) fputc(CHAR_IGNORE_LOWERCASE, stderr);
+ if (m->str_flags & STRING_IGNORE_UPPERCASE)
+ (void) fputc(CHAR_IGNORE_UPPERCASE, stderr);
+ if (m->str_flags & REGEX_OFFSET_START)
+ (void) fputc(CHAR_REGEX_OFFSET_START, stderr);
+ if (m->str_flags & STRING_TEXTTEST)
+ (void) fputc(CHAR_TEXTTEST, stderr);
+ if (m->str_flags & STRING_BINTEST)
+ (void) fputc(CHAR_BINTEST, stderr);
+ if (m->str_flags & PSTRING_1_BE)
+ (void) fputc(CHAR_PSTRING_1_BE, stderr);
+ if (m->str_flags & PSTRING_2_BE)
+ (void) fputc(CHAR_PSTRING_2_BE, stderr);
+ if (m->str_flags & PSTRING_2_LE)
+ (void) fputc(CHAR_PSTRING_2_LE, stderr);
+ if (m->str_flags & PSTRING_4_BE)
+ (void) fputc(CHAR_PSTRING_4_BE, stderr);
+ if (m->str_flags & PSTRING_4_LE)
+ (void) fputc(CHAR_PSTRING_4_LE, stderr);
+ if (m->str_flags & PSTRING_LENGTH_INCLUDES_ITSELF)
+ (void) fputc(
+ CHAR_PSTRING_LENGTH_INCLUDES_ITSELF,
+ stderr);
+ }
+ if (m->str_range)
+ (void) fprintf(stderr, "/%u", m->str_range);
+ }
+ else {
+ if ((size_t)(m->mask_op & FILE_OPS_MASK) < SZOF(optyp))
+ (void) fputc(optyp[m->mask_op & FILE_OPS_MASK], stderr);
+ else
+ (void) fputc('?', stderr);
+
+ if (m->num_mask) {
+ (void) fprintf(stderr, "%.8llx",
+ (unsigned long long)m->num_mask);
+ }
+ }
+ (void) fprintf(stderr, ",%c", m->reln);
+
+ if (m->reln != 'x') {
+ switch (m->type) {
+ case FILE_BYTE:
+ case FILE_SHORT:
+ case FILE_LONG:
+ case FILE_LESHORT:
+ case FILE_LELONG:
+ case FILE_MELONG:
+ case FILE_BESHORT:
+ case FILE_BELONG:
+ case FILE_INDIRECT:
+ (void) fprintf(stderr, "%d", m->value.l);
+ break;
+ case FILE_BEQUAD:
+ case FILE_LEQUAD:
+ case FILE_QUAD:
+ (void) fprintf(stderr, "%" INT64_T_FORMAT "d",
+ (unsigned long long)m->value.q);
+ break;
+ case FILE_PSTRING:
+ case FILE_STRING:
+ case FILE_REGEX:
+ case FILE_BESTRING16:
+ case FILE_LESTRING16:
+ case FILE_SEARCH:
+ file_showstr(stderr, m->value.s, (size_t)m->vallen);
+ break;
+ case FILE_DATE:
+ case FILE_LEDATE:
+ case FILE_BEDATE:
+ case FILE_MEDATE:
+ (void)fprintf(stderr, "%s,",
+ file_fmttime(m->value.l, 0, tbuf));
+ break;
+ case FILE_LDATE:
+ case FILE_LELDATE:
+ case FILE_BELDATE:
+ case FILE_MELDATE:
+ (void)fprintf(stderr, "%s,",
+ file_fmttime(m->value.l, FILE_T_LOCAL, tbuf));
+ break;
+ case FILE_QDATE:
+ case FILE_LEQDATE:
+ case FILE_BEQDATE:
+ (void)fprintf(stderr, "%s,",
+ file_fmttime(m->value.q, 0, tbuf));
+ break;
+ case FILE_QLDATE:
+ case FILE_LEQLDATE:
+ case FILE_BEQLDATE:
+ (void)fprintf(stderr, "%s,",
+ file_fmttime(m->value.q, FILE_T_LOCAL, tbuf));
+ break;
+ case FILE_QWDATE:
+ case FILE_LEQWDATE:
+ case FILE_BEQWDATE:
+ (void)fprintf(stderr, "%s,",
+ file_fmttime(m->value.q, FILE_T_WINDOWS, tbuf));
+ break;
+ case FILE_FLOAT:
+ case FILE_BEFLOAT:
+ case FILE_LEFLOAT:
+ (void) fprintf(stderr, "%G", m->value.f);
+ break;
+ case FILE_DOUBLE:
+ case FILE_BEDOUBLE:
+ case FILE_LEDOUBLE:
+ (void) fprintf(stderr, "%G", m->value.d);
+ break;
+ case FILE_DEFAULT:
+ /* XXX - do anything here? */
+ break;
+ case FILE_USE:
+ case FILE_NAME:
+ case FILE_DER:
+ (void) fprintf(stderr, "'%s'", m->value.s);
+ break;
+ default:
+ (void) fprintf(stderr, "*bad type %d*", m->type);
+ break;
+ }
+ }
+ (void) fprintf(stderr, ",\"%s\"]\n", m->desc);
+}
+#endif
+
+/*VARARGS*/
+protected void
+file_magwarn(struct magic_set *ms, const char *f, ...)
+{
+ va_list va;
+
+ /* cuz we use stdout for most, stderr here */
+ (void) fflush(stdout);
+
+ if (ms->file)
+ (void) fprintf(stderr, "%s, %lu: ", ms->file,
+ (unsigned long)ms->line);
+ (void) fprintf(stderr, "Warning: ");
+ va_start(va, f);
+ (void) vfprintf(stderr, f, va);
+ va_end(va);
+ (void) fputc('\n', stderr);
+}
+
+protected const char *
+file_fmttime(uint64_t v, int flags, char *buf)
+{
+ char *pp;
+ time_t t;
+ struct tm *tm, tmz;
+
+ if (flags & FILE_T_WINDOWS) {
+ struct timespec ts;
+ cdf_timestamp_to_timespec(&ts, CAST(cdf_timestamp_t, v));
+ t = ts.tv_sec;
+ } else {
+ // XXX: perhaps detect and print something if overflow
+ // on 32 bit time_t?
+ t = (time_t)v;
+ }
+
+ if (flags & FILE_T_LOCAL) {
+ tm = localtime_r(&t, &tmz);
+ } else {
+ tm = gmtime_r(&t, &tmz);
+ }
+ if (tm == NULL)
+ goto out;
+ pp = asctime_r(tm, buf);
+
+ if (pp == NULL)
+ goto out;
+ pp[strcspn(pp, "\n")] = '\0';
+ return pp;
+out:
+ return strcpy(buf, "*Invalid time*");
+}
diff --git a/node_modules/mmmagic/deps/libmagic/src/readcdf.c b/node_modules/mmmagic/deps/libmagic/src/readcdf.c
new file mode 100644
index 0000000..3d251d4
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/readcdf.c
@@ -0,0 +1,680 @@
+/*-
+ * Copyright (c) 2008, 2016 Christos Zoulas
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "file.h"
+
+#ifndef lint
+FILE_RCSID("@(#)$File: readcdf.c,v 1.65 2017/04/08 20:58:03 christos Exp $")
+#endif
+
+#include <assert.h>
+#include <stdlib.h>
+// XXX: change by mscdex
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#include <string.h>
+#include <time.h>
+#include <ctype.h>
+
+#include "cdf.h"
+#include "magic.h"
+
+#ifndef __arraycount
+#define __arraycount(a) (sizeof(a) / sizeof(a[0]))
+#endif
+
+#define NOTMIME(ms) (((ms)->flags & MAGIC_MIME) == 0)
+
+static const struct nv {
+ const char *pattern;
+ const char *mime;
+} app2mime[] = {
+ { "Word", "msword", },
+ { "Excel", "vnd.ms-excel", },
+ { "Powerpoint", "vnd.ms-powerpoint", },
+ { "Crystal Reports", "x-rpt", },
+ { "Advanced Installer", "vnd.ms-msi", },
+ { "InstallShield", "vnd.ms-msi", },
+ { "Microsoft Patch Compiler", "vnd.ms-msi", },
+ { "NAnt", "vnd.ms-msi", },
+ { "Windows Installer", "vnd.ms-msi", },
+ { NULL, NULL, },
+}, name2mime[] = {
+ { "Book", "vnd.ms-excel", },
+ { "Workbook", "vnd.ms-excel", },
+ { "WordDocument", "msword", },
+ { "PowerPoint", "vnd.ms-powerpoint", },
+ { "DigitalSignature", "vnd.ms-msi", },
+ { NULL, NULL, },
+}, name2desc[] = {
+ { "Book", "Microsoft Excel", },
+ { "Workbook", "Microsoft Excel", },
+ { "WordDocument", "Microsoft Word", },
+ { "PowerPoint", "Microsoft PowerPoint", },
+ { "DigitalSignature", "Microsoft Installer", },
+ { NULL, NULL, },
+};
+
+static const struct cv {
+ uint64_t clsid[2];
+ const char *mime;
+} clsid2mime[] = {
+ {
+ { 0x00000000000c1084ULL, 0x46000000000000c0ULL },
+ "x-msi",
+ },
+ { { 0, 0 },
+ NULL,
+ },
+}, clsid2desc[] = {
+ {
+ { 0x00000000000c1084ULL, 0x46000000000000c0ULL },
+ "MSI Installer",
+ },
+ { { 0, 0 },
+ NULL,
+ },
+};
+
+private const char *
+cdf_clsid_to_mime(const uint64_t clsid[2], const struct cv *cv)
+{
+ size_t i;
+ for (i = 0; cv[i].mime != NULL; i++) {
+ if (clsid[0] == cv[i].clsid[0] && clsid[1] == cv[i].clsid[1])
+ return cv[i].mime;
+ }
+#ifdef CDF_DEBUG
+ fprintf(stderr, "unknown mime %" PRIx64 ", %" PRIx64 "\n", clsid[0],
+ clsid[1]);
+#endif
+ return NULL;
+}
+
+private const char *
+cdf_app_to_mime(const char *vbuf, const struct nv *nv)
+{
+ size_t i;
+ const char *rv = NULL;
+#ifdef USE_C_LOCALE
+ locale_t old_lc_ctype, c_lc_ctype;
+
+ c_lc_ctype = newlocale(LC_CTYPE_MASK, "C", 0);
+ assert(c_lc_ctype != NULL);
+ old_lc_ctype = uselocale(c_lc_ctype);
+ assert(old_lc_ctype != NULL);
+#else
+ char *old_lc_ctype = setlocale(LC_CTYPE, "C");
+#endif
+ for (i = 0; nv[i].pattern != NULL; i++)
+ if (strcasestr(vbuf, nv[i].pattern) != NULL) {
+ rv = nv[i].mime;
+ break;
+ }
+#ifdef CDF_DEBUG
+ fprintf(stderr, "unknown app %s\n", vbuf);
+#endif
+#ifdef USE_C_LOCALE
+ (void)uselocale(old_lc_ctype);
+ freelocale(c_lc_ctype);
+#else
+ setlocale(LC_CTYPE, old_lc_ctype);
+#endif
+ return rv;
+}
+
+private int
+cdf_file_property_info(struct magic_set *ms, const cdf_property_info_t *info,
+ size_t count, const cdf_directory_t *root_storage)
+{
+ size_t i;
+ cdf_timestamp_t tp;
+ struct timespec ts;
+ char buf[64];
+ const char *str = NULL;
+ const char *s, *e;
+ int len;
+
+ if (!NOTMIME(ms) && root_storage)
+ str = cdf_clsid_to_mime(root_storage->d_storage_uuid,
+ clsid2mime);
+
+ for (i = 0; i < count; i++) {
+ cdf_print_property_name(buf, sizeof(buf), info[i].pi_id);
+ switch (info[i].pi_type) {
+ case CDF_NULL:
+ break;
+ case CDF_SIGNED16:
+ if (NOTMIME(ms) && file_printf(ms, ", %s: %hd", buf,
+ info[i].pi_s16) == -1)
+ return -1;
+ break;
+ case CDF_SIGNED32:
+ if (NOTMIME(ms) && file_printf(ms, ", %s: %d", buf,
+ info[i].pi_s32) == -1)
+ return -1;
+ break;
+ case CDF_UNSIGNED32:
+ if (NOTMIME(ms) && file_printf(ms, ", %s: %u", buf,
+ info[i].pi_u32) == -1)
+ return -1;
+ break;
+ case CDF_FLOAT:
+ if (NOTMIME(ms) && file_printf(ms, ", %s: %g", buf,
+ info[i].pi_f) == -1)
+ return -1;
+ break;
+ case CDF_DOUBLE:
+ if (NOTMIME(ms) && file_printf(ms, ", %s: %g", buf,
+ info[i].pi_d) == -1)
+ return -1;
+ break;
+ case CDF_LENGTH32_STRING:
+ case CDF_LENGTH32_WSTRING:
+ len = info[i].pi_str.s_len;
+ if (len > 1) {
+ char vbuf[1024];
+ size_t j, k = 1;
+
+ if (info[i].pi_type == CDF_LENGTH32_WSTRING)
+ k++;
+ s = info[i].pi_str.s_buf;
+ e = info[i].pi_str.s_buf + len;
+ for (j = 0; s < e && j < sizeof(vbuf)
+ && len--; s += k) {
+ if (*s == '\0')
+ break;
+ if (isprint((unsigned char)*s))
+ vbuf[j++] = *s;
+ }
+ if (j == sizeof(vbuf))
+ --j;
+ vbuf[j] = '\0';
+ if (NOTMIME(ms)) {
+ if (vbuf[0]) {
+ if (file_printf(ms, ", %s: %s",
+ buf, vbuf) == -1)
+ return -1;
+ }
+ } else if (str == NULL && info[i].pi_id ==
+ CDF_PROPERTY_NAME_OF_APPLICATION) {
+ str = cdf_app_to_mime(vbuf, app2mime);
+ }
+ }
+ break;
+ case CDF_FILETIME:
+ tp = info[i].pi_tp;
+ if (tp != 0) {
+ char tbuf[64];
+ if (tp < 1000000000000000LL) {
+ cdf_print_elapsed_time(tbuf,
+ sizeof(tbuf), tp);
+ if (NOTMIME(ms) && file_printf(ms,
+ ", %s: %s", buf, tbuf) == -1)
+ return -1;
+ } else {
+ char *c, *ec;
+ cdf_timestamp_to_timespec(&ts, tp);
+ c = cdf_ctime(&ts.tv_sec, tbuf);
+ if (c != NULL &&
+ (ec = strchr(c, '\n')) != NULL)
+ *ec = '\0';
+
+ if (NOTMIME(ms) && file_printf(ms,
+ ", %s: %s", buf, c) == -1)
+ return -1;
+ }
+ }
+ break;
+ case CDF_CLIPBOARD:
+ break;
+ default:
+ return -1;
+ }
+ }
+ if (!NOTMIME(ms)) {
+ if (str == NULL)
+ return 0;
+ if (file_printf(ms, "application/%s", str) == -1)
+ return -1;
+ }
+ return 1;
+}
+
+private int
+cdf_file_catalog(struct magic_set *ms, const cdf_header_t *h,
+ const cdf_stream_t *sst)
+{
+ cdf_catalog_t *cat;
+ size_t i;
+ char buf[256];
+ cdf_catalog_entry_t *ce;
+
+ if (NOTMIME(ms)) {
+ if (file_printf(ms, "Microsoft Thumbs.db [") == -1)
+ return -1;
+ if (cdf_unpack_catalog(h, sst, &cat) == -1)
+ return -1;
+ ce = cat->cat_e;
+ /* skip first entry since it has a , or paren */
+ for (i = 1; i < cat->cat_num; i++)
+ if (file_printf(ms, "%s%s",
+ cdf_u16tos8(buf, ce[i].ce_namlen, ce[i].ce_name),
+ i == cat->cat_num - 1 ? "]" : ", ") == -1) {
+ free(cat);
+ return -1;
+ }
+ free(cat);
+ } else {
+ if (file_printf(ms, "application/CDFV2") == -1)
+ return -1;
+ }
+ return 1;
+}
+
+private int
+cdf_file_summary_info(struct magic_set *ms, const cdf_header_t *h,
+ const cdf_stream_t *sst, const cdf_directory_t *root_storage)
+{
+ cdf_summary_info_header_t si;
+ cdf_property_info_t *info;
+ size_t count;
+ int m;
+
+ if (cdf_unpack_summary_info(sst, h, &si, &info, &count) == -1)
+ return -1;
+
+ if (NOTMIME(ms)) {
+ const char *str;
+
+ if (file_printf(ms, "Composite Document File V2 Document")
+ == -1)
+ return -1;
+
+ if (file_printf(ms, ", %s Endian",
+ si.si_byte_order == 0xfffe ? "Little" : "Big") == -1)
+ return -2;
+ switch (si.si_os) {
+ case 2:
+ if (file_printf(ms, ", Os: Windows, Version %d.%d",
+ si.si_os_version & 0xff,
+ (uint32_t)si.si_os_version >> 8) == -1)
+ return -2;
+ break;
+ case 1:
+ if (file_printf(ms, ", Os: MacOS, Version %d.%d",
+ (uint32_t)si.si_os_version >> 8,
+ si.si_os_version & 0xff) == -1)
+ return -2;
+ break;
+ default:
+ if (file_printf(ms, ", Os %d, Version: %d.%d", si.si_os,
+ si.si_os_version & 0xff,
+ (uint32_t)si.si_os_version >> 8) == -1)
+ return -2;
+ break;
+ }
+ if (root_storage) {
+ str = cdf_clsid_to_mime(root_storage->d_storage_uuid,
+ clsid2desc);
+ if (str) {
+ if (file_printf(ms, ", %s", str) == -1)
+ return -2;
+ }
+ }
+ }
+
+ m = cdf_file_property_info(ms, info, count, root_storage);
+ free(info);
+
+ return m == -1 ? -2 : m;
+}
+
+#ifdef notdef
+private char *
+format_clsid(char *buf, size_t len, const uint64_t uuid[2]) {
+ snprintf(buf, len, "%.8" PRIx64 "-%.4" PRIx64 "-%.4" PRIx64 "-%.4"
+ PRIx64 "-%.12" PRIx64,
+ (uuid[0] >> 32) & (uint64_t)0x000000000ffffffffULL,
+ (uuid[0] >> 16) & (uint64_t)0x0000000000000ffffULL,
+ (uuid[0] >> 0) & (uint64_t)0x0000000000000ffffULL,
+ (uuid[1] >> 48) & (uint64_t)0x0000000000000ffffULL,
+ (uuid[1] >> 0) & (uint64_t)0x0000fffffffffffffULL);
+ return buf;
+}
+#endif
+
+private int
+cdf_file_catalog_info(struct magic_set *ms, const cdf_info_t *info,
+ const cdf_header_t *h, const cdf_sat_t *sat, const cdf_sat_t *ssat,
+ const cdf_stream_t *sst, const cdf_dir_t *dir, cdf_stream_t *scn)
+{
+ int i;
+
+ if ((i = cdf_read_user_stream(info, h, sat, ssat, sst,
+ dir, "Catalog", scn)) == -1)
+ return i;
+#ifdef CDF_DEBUG
+ cdf_dump_catalog(h, scn);
+#endif
+ if ((i = cdf_file_catalog(ms, h, scn)) == -1)
+ return -1;
+ return i;
+}
+
+private int
+cdf_check_summary_info(struct magic_set *ms, const cdf_info_t *info,
+ const cdf_header_t *h, const cdf_sat_t *sat, const cdf_sat_t *ssat,
+ const cdf_stream_t *sst, const cdf_dir_t *dir, cdf_stream_t *scn,
+ const cdf_directory_t *root_storage, const char **expn)
+{
+ int i;
+ const char *str = NULL;
+ cdf_directory_t *d;
+ char name[__arraycount(d->d_name)];
+ size_t j, k;
+
+#ifdef CDF_DEBUG
+ cdf_dump_summary_info(h, scn);
+#endif
+ if ((i = cdf_file_summary_info(ms, h, scn, root_storage)) < 0) {
+ *expn = "Can't expand summary_info";
+ return i;
+ }
+ if (i == 1)
+ return i;
+ for (j = 0; str == NULL && j < dir->dir_len; j++) {
+ d = &dir->dir_tab[j];
+ for (k = 0; k < sizeof(name); k++)
+ name[k] = (char)cdf_tole2(d->d_name[k]);
+ str = cdf_app_to_mime(name,
+ NOTMIME(ms) ? name2desc : name2mime);
+ }
+ if (NOTMIME(ms)) {
+ if (str != NULL) {
+ if (file_printf(ms, "%s", str) == -1)
+ return -1;
+ i = 1;
+ }
+ } else {
+ if (str == NULL)
+ str = "vnd.ms-office";
+ if (file_printf(ms, "application/%s", str) == -1)
+ return -1;
+ i = 1;
+ }
+ if (i <= 0) {
+ i = cdf_file_catalog_info(ms, info, h, sat, ssat, sst,
+ dir, scn);
+ }
+ return i;
+}
+
+private struct sinfo {
+ const char *name;
+ const char *mime;
+ const char *sections[5];
+ const int types[5];
+} sectioninfo[] = {
+ { "Encrypted", "encrypted",
+ {
+ "EncryptedPackage", "EncryptedSummary",
+ NULL, NULL, NULL,
+ },
+ {
+ CDF_DIR_TYPE_USER_STREAM,
+ CDF_DIR_TYPE_USER_STREAM,
+ 0, 0, 0,
+
+ },
+ },
+ { "QuickBooks", "quickbooks",
+ {
+#if 0
+ "TaxForms", "PDFTaxForms", "modulesInBackup",
+#endif
+ "mfbu_header", NULL, NULL, NULL, NULL,
+ },
+ {
+#if 0
+ CDF_DIR_TYPE_USER_STORAGE,
+ CDF_DIR_TYPE_USER_STORAGE,
+ CDF_DIR_TYPE_USER_STREAM,
+#endif
+ CDF_DIR_TYPE_USER_STREAM,
+ 0, 0, 0, 0
+ },
+ },
+ { "Microsoft Excel", "vnd.ms-excel",
+ {
+ "Book", "Workbook", NULL, NULL, NULL,
+ },
+ {
+ CDF_DIR_TYPE_USER_STREAM,
+ CDF_DIR_TYPE_USER_STREAM,
+ 0, 0, 0,
+ },
+ },
+ { "Microsoft Word", "msword",
+ {
+ "WordDocument", NULL, NULL, NULL, NULL,
+ },
+ {
+ CDF_DIR_TYPE_USER_STREAM,
+ 0, 0, 0, 0,
+ },
+ },
+ { "Microsoft PowerPoint", "vnd.ms-powerpoint",
+ {
+ "PowerPoint", NULL, NULL, NULL, NULL,
+ },
+ {
+ CDF_DIR_TYPE_USER_STREAM,
+ 0, 0, 0, 0,
+ },
+ },
+ { "Microsoft Outlook Message", "vnd.ms-outlook",
+ {
+ "__properties_version1.0",
+ "__recip_version1.0_#00000000",
+ NULL, NULL, NULL,
+ },
+ {
+ CDF_DIR_TYPE_USER_STREAM,
+ CDF_DIR_TYPE_USER_STORAGE,
+ 0, 0, 0,
+ },
+ },
+};
+
+private int
+cdf_file_dir_info(struct magic_set *ms, const cdf_dir_t *dir)
+{
+ size_t sd, j;
+
+ for (sd = 0; sd < __arraycount(sectioninfo); sd++) {
+ const struct sinfo *si = &sectioninfo[sd];
+ for (j = 0; si->sections[j]; j++) {
+ if (cdf_find_stream(dir, si->sections[j], si->types[j])
+ > 0)
+ break;
+#ifdef CDF_DEBUG
+ fprintf(stderr, "Can't read %s\n", si->sections[j]);
+#endif
+ }
+ if (si->sections[j] == NULL)
+ continue;
+ if (NOTMIME(ms)) {
+ if (file_printf(ms, "CDFV2 %s", si->name) == -1)
+ return -1;
+ } else {
+ if (file_printf(ms, "application/%s", si->mime) == -1)
+ return -1;
+ }
+ return 1;
+ }
+ return -1;
+}
+
+protected int
+file_trycdf(struct magic_set *ms, int fd, const unsigned char *buf,
+ size_t nbytes)
+{
+ cdf_info_t info;
+ cdf_header_t h;
+ cdf_sat_t sat, ssat;
+ cdf_stream_t sst, scn;
+ cdf_dir_t dir;
+ int i;
+ const char *expn = "";
+ const cdf_directory_t *root_storage;
+
+ scn.sst_tab = NULL;
+ info.i_fd = fd;
+ info.i_buf = buf;
+ info.i_len = nbytes;
+ if (ms->flags & (MAGIC_APPLE|MAGIC_EXTENSION))
+ return 0;
+ if (cdf_read_header(&info, &h) == -1)
+ return 0;
+#ifdef CDF_DEBUG
+ cdf_dump_header(&h);
+#endif
+
+ if ((i = cdf_read_sat(&info, &h, &sat)) == -1) {
+ expn = "Can't read SAT";
+ goto out0;
+ }
+#ifdef CDF_DEBUG
+ cdf_dump_sat("SAT", &sat, CDF_SEC_SIZE(&h));
+#endif
+
+ if ((i = cdf_read_ssat(&info, &h, &sat, &ssat)) == -1) {
+ expn = "Can't read SSAT";
+ goto out1;
+ }
+#ifdef CDF_DEBUG
+ cdf_dump_sat("SSAT", &ssat, CDF_SHORT_SEC_SIZE(&h));
+#endif
+
+ if ((i = cdf_read_dir(&info, &h, &sat, &dir)) == -1) {
+ expn = "Can't read directory";
+ goto out2;
+ }
+
+ if ((i = cdf_read_short_stream(&info, &h, &sat, &dir, &sst,
+ &root_storage)) == -1) {
+ expn = "Cannot read short stream";
+ goto out3;
+ }
+#ifdef CDF_DEBUG
+ cdf_dump_dir(&info, &h, &sat, &ssat, &sst, &dir);
+#endif
+#ifdef notdef
+ if (root_storage) {
+ if (NOTMIME(ms)) {
+ char clsbuf[128];
+ if (file_printf(ms, "CLSID %s, ",
+ format_clsid(clsbuf, sizeof(clsbuf),
+ root_storage->d_storage_uuid)) == -1)
+ return -1;
+ }
+ }
+#endif
+
+ if ((i = cdf_read_user_stream(&info, &h, &sat, &ssat, &sst, &dir,
+ "FileHeader", &scn)) != -1) {
+#define HWP5_SIGNATURE "HWP Document File"
+ if (scn.sst_len * scn.sst_ss >= sizeof(HWP5_SIGNATURE) - 1
+ && memcmp(scn.sst_tab, HWP5_SIGNATURE,
+ sizeof(HWP5_SIGNATURE) - 1) == 0) {
+ if (NOTMIME(ms)) {
+ if (file_printf(ms,
+ "Hangul (Korean) Word Processor File 5.x") == -1)
+ return -1;
+ } else {
+ if (file_printf(ms, "application/x-hwp") == -1)
+ return -1;
+ }
+ i = 1;
+ goto out5;
+ } else {
+ cdf_zero_stream(&scn);
+ }
+ }
+
+ if ((i = cdf_read_summary_info(&info, &h, &sat, &ssat, &sst, &dir,
+ &scn)) == -1) {
+ if (errno != ESRCH) {
+ expn = "Cannot read summary info";
+ }
+ } else {
+ i = cdf_check_summary_info(ms, &info, &h,
+ &sat, &ssat, &sst, &dir, &scn, root_storage, &expn);
+ cdf_zero_stream(&scn);
+ }
+ if (i <= 0) {
+ if ((i = cdf_read_doc_summary_info(&info, &h, &sat, &ssat,
+ &sst, &dir, &scn)) == -1) {
+ if (errno != ESRCH) {
+ expn = "Cannot read summary info";
+ }
+ } else {
+ i = cdf_check_summary_info(ms, &info, &h, &sat, &ssat,
+ &sst, &dir, &scn, root_storage, &expn);
+ }
+ }
+ if (i <= 0) {
+ i = cdf_file_dir_info(ms, &dir);
+ if (i < 0)
+ expn = "Cannot read section info";
+ }
+out5:
+ cdf_zero_stream(&scn);
+ cdf_zero_stream(&sst);
+out3:
+ free(dir.dir_tab);
+out2:
+ free(ssat.sat_tab);
+out1:
+ free(sat.sat_tab);
+out0:
+ if (i == -1) {
+ if (NOTMIME(ms)) {
+ if (file_printf(ms,
+ "Composite Document File V2 Document") == -1)
+ return -1;
+ if (*expn)
+ if (file_printf(ms, ", %s", expn) == -1)
+ return -1;
+ } else {
+ if (file_printf(ms, "application/CDFV2") == -1)
+ return -1;
+ }
+ i = 1;
+ }
+ return i;
+}
diff --git a/node_modules/mmmagic/deps/libmagic/src/readelf.c b/node_modules/mmmagic/deps/libmagic/src/readelf.c
new file mode 100644
index 0000000..5f425c9
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/readelf.c
@@ -0,0 +1,1640 @@
+/*
+ * Copyright (c) Christos Zoulas 2003.
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice immediately at the beginning of the file, without modification,
+ * this list of conditions, and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#include "file.h"
+
+#ifndef lint
+FILE_RCSID("@(#)$File: readelf.c,v 1.138 2017/08/27 07:55:02 christos Exp $")
+#endif
+
+#ifdef BUILTIN_ELF
+#include <string.h>
+#include <ctype.h>
+#include <stdlib.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include "readelf.h"
+#include "magic.h"
+
+#ifdef ELFCORE
+private int dophn_core(struct magic_set *, int, int, int, off_t, int, size_t,
+ off_t, int *, uint16_t *);
+#endif
+private int dophn_exec(struct magic_set *, int, int, int, off_t, int, size_t,
+ off_t, int, int *, uint16_t *);
+private int doshn(struct magic_set *, int, int, int, off_t, int, size_t,
+ off_t, int, int, int *, uint16_t *);
+private size_t donote(struct magic_set *, void *, size_t, size_t, int,
+ int, size_t, int *, uint16_t *, int, off_t, int, off_t);
+
+#define ELF_ALIGN(a) ((((a) + align - 1) / align) * align)
+
+#define isquote(c) (strchr("'\"`", (c)) != NULL)
+
+private uint16_t getu16(int, uint16_t);
+private uint32_t getu32(int, uint32_t);
+private uint64_t getu64(int, uint64_t);
+
+#define MAX_PHNUM 128
+#define MAX_SHNUM 32768
+#define SIZE_UNKNOWN ((off_t)-1)
+
+private int
+toomany(struct magic_set *ms, const char *name, uint16_t num)
+{
+ if (file_printf(ms, ", too many %s (%u)", name, num
+ ) == -1)
+ return -1;
+ return 0;
+}
+
+private uint16_t
+getu16(int swap, uint16_t value)
+{
+ union {
+ uint16_t ui;
+ char c[2];
+ } retval, tmpval;
+
+ if (swap) {
+ tmpval.ui = value;
+
+ retval.c[0] = tmpval.c[1];
+ retval.c[1] = tmpval.c[0];
+
+ return retval.ui;
+ } else
+ return value;
+}
+
+private uint32_t
+getu32(int swap, uint32_t value)
+{
+ union {
+ uint32_t ui;
+ char c[4];
+ } retval, tmpval;
+
+ if (swap) {
+ tmpval.ui = value;
+
+ retval.c[0] = tmpval.c[3];
+ retval.c[1] = tmpval.c[2];
+ retval.c[2] = tmpval.c[1];
+ retval.c[3] = tmpval.c[0];
+
+ return retval.ui;
+ } else
+ return value;
+}
+
+private uint64_t
+getu64(int swap, uint64_t value)
+{
+ union {
+ uint64_t ui;
+ char c[8];
+ } retval, tmpval;
+
+ if (swap) {
+ tmpval.ui = value;
+
+ retval.c[0] = tmpval.c[7];
+ retval.c[1] = tmpval.c[6];
+ retval.c[2] = tmpval.c[5];
+ retval.c[3] = tmpval.c[4];
+ retval.c[4] = tmpval.c[3];
+ retval.c[5] = tmpval.c[2];
+ retval.c[6] = tmpval.c[1];
+ retval.c[7] = tmpval.c[0];
+
+ return retval.ui;
+ } else
+ return value;
+}
+
+#define elf_getu16(swap, value) getu16(swap, value)
+#define elf_getu32(swap, value) getu32(swap, value)
+#define elf_getu64(swap, value) getu64(swap, value)
+
+#define xsh_addr (clazz == ELFCLASS32 \
+ ? (void *)&sh32 \
+ : (void *)&sh64)
+#define xsh_sizeof (clazz == ELFCLASS32 \
+ ? sizeof(sh32) \
+ : sizeof(sh64))
+#define xsh_size (size_t)(clazz == ELFCLASS32 \
+ ? elf_getu32(swap, sh32.sh_size) \
+ : elf_getu64(swap, sh64.sh_size))
+#define xsh_offset (off_t)(clazz == ELFCLASS32 \
+ ? elf_getu32(swap, sh32.sh_offset) \
+ : elf_getu64(swap, sh64.sh_offset))
+#define xsh_type (clazz == ELFCLASS32 \
+ ? elf_getu32(swap, sh32.sh_type) \
+ : elf_getu32(swap, sh64.sh_type))
+#define xsh_name (clazz == ELFCLASS32 \
+ ? elf_getu32(swap, sh32.sh_name) \
+ : elf_getu32(swap, sh64.sh_name))
+#define xph_addr (clazz == ELFCLASS32 \
+ ? (void *) &ph32 \
+ : (void *) &ph64)
+#define xph_sizeof (clazz == ELFCLASS32 \
+ ? sizeof(ph32) \
+ : sizeof(ph64))
+#define xph_type (clazz == ELFCLASS32 \
+ ? elf_getu32(swap, ph32.p_type) \
+ : elf_getu32(swap, ph64.p_type))
+#define xph_offset (off_t)(clazz == ELFCLASS32 \
+ ? elf_getu32(swap, ph32.p_offset) \
+ : elf_getu64(swap, ph64.p_offset))
+#define xph_align (size_t)((clazz == ELFCLASS32 \
+ ? (off_t) (ph32.p_align ? \
+ elf_getu32(swap, ph32.p_align) : 4) \
+ : (off_t) (ph64.p_align ? \
+ elf_getu64(swap, ph64.p_align) : 4)))
+#define xph_vaddr (size_t)((clazz == ELFCLASS32 \
+ ? (off_t) (ph32.p_vaddr ? \
+ elf_getu32(swap, ph32.p_vaddr) : 4) \
+ : (off_t) (ph64.p_vaddr ? \
+ elf_getu64(swap, ph64.p_vaddr) : 4)))
+#define xph_filesz (size_t)((clazz == ELFCLASS32 \
+ ? elf_getu32(swap, ph32.p_filesz) \
+ : elf_getu64(swap, ph64.p_filesz)))
+#define xnh_addr (clazz == ELFCLASS32 \
+ ? (void *)&nh32 \
+ : (void *)&nh64)
+#define xph_memsz (size_t)((clazz == ELFCLASS32 \
+ ? elf_getu32(swap, ph32.p_memsz) \
+ : elf_getu64(swap, ph64.p_memsz)))
+#define xnh_sizeof (clazz == ELFCLASS32 \
+ ? sizeof(nh32) \
+ : sizeof(nh64))
+#define xnh_type (clazz == ELFCLASS32 \
+ ? elf_getu32(swap, nh32.n_type) \
+ : elf_getu32(swap, nh64.n_type))
+#define xnh_namesz (clazz == ELFCLASS32 \
+ ? elf_getu32(swap, nh32.n_namesz) \
+ : elf_getu32(swap, nh64.n_namesz))
+#define xnh_descsz (clazz == ELFCLASS32 \
+ ? elf_getu32(swap, nh32.n_descsz) \
+ : elf_getu32(swap, nh64.n_descsz))
+#define prpsoffsets(i) (clazz == ELFCLASS32 \
+ ? prpsoffsets32[i] \
+ : prpsoffsets64[i])
+#define xcap_addr (clazz == ELFCLASS32 \
+ ? (void *)&cap32 \
+ : (void *)&cap64)
+#define xcap_sizeof (clazz == ELFCLASS32 \
+ ? sizeof cap32 \
+ : sizeof cap64)
+#define xcap_tag (clazz == ELFCLASS32 \
+ ? elf_getu32(swap, cap32.c_tag) \
+ : elf_getu64(swap, cap64.c_tag))
+#define xcap_val (clazz == ELFCLASS32 \
+ ? elf_getu32(swap, cap32.c_un.c_val) \
+ : elf_getu64(swap, cap64.c_un.c_val))
+#define xauxv_addr (clazz == ELFCLASS32 \
+ ? (void *)&auxv32 \
+ : (void *)&auxv64)
+#define xauxv_sizeof (clazz == ELFCLASS32 \
+ ? sizeof(auxv32) \
+ : sizeof(auxv64))
+#define xauxv_type (clazz == ELFCLASS32 \
+ ? elf_getu32(swap, auxv32.a_type) \
+ : elf_getu64(swap, auxv64.a_type))
+#define xauxv_val (clazz == ELFCLASS32 \
+ ? elf_getu32(swap, auxv32.a_v) \
+ : elf_getu64(swap, auxv64.a_v))
+
+#ifdef ELFCORE
+/*
+ * Try larger offsets first to avoid false matches
+ * from earlier data that happen to look like strings.
+ */
+static const size_t prpsoffsets32[] = {
+#ifdef USE_NT_PSINFO
+ 104, /* SunOS 5.x (command line) */
+ 88, /* SunOS 5.x (short name) */
+#endif /* USE_NT_PSINFO */
+
+ 100, /* SunOS 5.x (command line) */
+ 84, /* SunOS 5.x (short name) */
+
+ 44, /* Linux (command line) */
+ 28, /* Linux 2.0.36 (short name) */
+
+ 8, /* FreeBSD */
+};
+
+static const size_t prpsoffsets64[] = {
+#ifdef USE_NT_PSINFO
+ 152, /* SunOS 5.x (command line) */
+ 136, /* SunOS 5.x (short name) */
+#endif /* USE_NT_PSINFO */
+
+ 136, /* SunOS 5.x, 64-bit (command line) */
+ 120, /* SunOS 5.x, 64-bit (short name) */
+
+ 56, /* Linux (command line) */
+ 40, /* Linux (tested on core from 2.4.x, short name) */
+
+ 16, /* FreeBSD, 64-bit */
+};
+
+#define NOFFSETS32 (sizeof prpsoffsets32 / sizeof prpsoffsets32[0])
+#define NOFFSETS64 (sizeof prpsoffsets64 / sizeof prpsoffsets64[0])
+
+#define NOFFSETS (clazz == ELFCLASS32 ? NOFFSETS32 : NOFFSETS64)
+
+/*
+ * Look through the program headers of an executable image, searching
+ * for a PT_NOTE section of type NT_PRPSINFO, with a name "CORE" or
+ * "FreeBSD"; if one is found, try looking in various places in its
+ * contents for a 16-character string containing only printable
+ * characters - if found, that string should be the name of the program
+ * that dropped core. Note: right after that 16-character string is,
+ * at least in SunOS 5.x (and possibly other SVR4-flavored systems) and
+ * Linux, a longer string (80 characters, in 5.x, probably other
+ * SVR4-flavored systems, and Linux) containing the start of the
+ * command line for that program.
+ *
+ * SunOS 5.x core files contain two PT_NOTE sections, with the types
+ * NT_PRPSINFO (old) and NT_PSINFO (new). These structs contain the
+ * same info about the command name and command line, so it probably
+ * isn't worthwhile to look for NT_PSINFO, but the offsets are provided
+ * above (see USE_NT_PSINFO), in case we ever decide to do so. The
+ * NT_PRPSINFO and NT_PSINFO sections are always in order and adjacent;
+ * the SunOS 5.x file command relies on this (and prefers the latter).
+ *
+ * The signal number probably appears in a section of type NT_PRSTATUS,
+ * but that's also rather OS-dependent, in ways that are harder to
+ * dissect with heuristics, so I'm not bothering with the signal number.
+ * (I suppose the signal number could be of interest in situations where
+ * you don't have the binary of the program that dropped core; if you
+ * *do* have that binary, the debugger will probably tell you what
+ * signal it was.)
+ */
+
+#define OS_STYLE_SVR4 0
+#define OS_STYLE_FREEBSD 1
+#define OS_STYLE_NETBSD 2
+
+private const char os_style_names[][8] = {
+ "SVR4",
+ "FreeBSD",
+ "NetBSD",
+};
+
+#define FLAGS_CORE_STYLE 0x003
+
+#define FLAGS_DID_CORE 0x004
+#define FLAGS_DID_OS_NOTE 0x008
+#define FLAGS_DID_BUILD_ID 0x010
+#define FLAGS_DID_CORE_STYLE 0x020
+#define FLAGS_DID_NETBSD_PAX 0x040
+#define FLAGS_DID_NETBSD_MARCH 0x080
+#define FLAGS_DID_NETBSD_CMODEL 0x100
+#define FLAGS_DID_NETBSD_UNKNOWN 0x200
+#define FLAGS_IS_CORE 0x400
+#define FLAGS_DID_AUXV 0x800
+
+private int
+dophn_core(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
+ int num, size_t size, off_t fsize, int *flags, uint16_t *notecount)
+{
+ Elf32_Phdr ph32;
+ Elf64_Phdr ph64;
+ size_t offset, len;
+ unsigned char nbuf[BUFSIZ];
+ ssize_t bufsize;
+ off_t ph_off = off;
+ int ph_num = num;
+
+ if (size != xph_sizeof) {
+ if (file_printf(ms, ", corrupted program header size") == -1)
+ return -1;
+ return 0;
+ }
+
+ /*
+ * Loop through all the program headers.
+ */
+ for ( ; num; num--) {
+ if (pread(fd, xph_addr, xph_sizeof, off) < (ssize_t)xph_sizeof) {
+ file_badread(ms);
+ return -1;
+ }
+ off += size;
+
+ if (fsize != SIZE_UNKNOWN && xph_offset > fsize) {
+ /* Perhaps warn here */
+ continue;
+ }
+
+ if (xph_type != PT_NOTE)
+ continue;
+
+ /*
+ * This is a PT_NOTE section; loop through all the notes
+ * in the section.
+ */
+ len = xph_filesz < sizeof(nbuf) ? xph_filesz : sizeof(nbuf);
+ if ((bufsize = pread(fd, nbuf, len, xph_offset)) == -1) {
+ file_badread(ms);
+ return -1;
+ }
+ offset = 0;
+ for (;;) {
+ if (offset >= (size_t)bufsize)
+ break;
+ offset = donote(ms, nbuf, offset, (size_t)bufsize,
+ clazz, swap, 4, flags, notecount, fd, ph_off,
+ ph_num, fsize);
+ if (offset == 0)
+ break;
+
+ }
+ }
+ return 0;
+}
+#endif
+
+static void
+do_note_netbsd_version(struct magic_set *ms, int swap, void *v)
+{
+ uint32_t desc;
+ (void)memcpy(&desc, v, sizeof(desc));
+ desc = elf_getu32(swap, desc);
+
+ if (file_printf(ms, ", for NetBSD") == -1)
+ return;
+ /*
+ * The version number used to be stuck as 199905, and was thus
+ * basically content-free. Newer versions of NetBSD have fixed
+ * this and now use the encoding of __NetBSD_Version__:
+ *
+ * MMmmrrpp00
+ *
+ * M = major version
+ * m = minor version
+ * r = release ["",A-Z,Z[A-Z] but numeric]
+ * p = patchlevel
+ */
+ if (desc > 100000000U) {
+ uint32_t ver_patch = (desc / 100) % 100;
+ uint32_t ver_rel = (desc / 10000) % 100;
+ uint32_t ver_min = (desc / 1000000) % 100;
+ uint32_t ver_maj = desc / 100000000;
+
+ if (file_printf(ms, " %u.%u", ver_maj, ver_min) == -1)
+ return;
+ if (ver_rel == 0 && ver_patch != 0) {
+ if (file_printf(ms, ".%u", ver_patch) == -1)
+ return;
+ } else if (ver_rel != 0) {
+ while (ver_rel > 26) {
+ if (file_printf(ms, "Z") == -1)
+ return;
+ ver_rel -= 26;
+ }
+ if (file_printf(ms, "%c", 'A' + ver_rel - 1)
+ == -1)
+ return;
+ }
+ }
+}
+
+static void
+do_note_freebsd_version(struct magic_set *ms, int swap, void *v)
+{
+ uint32_t desc;
+
+ (void)memcpy(&desc, v, sizeof(desc));
+ desc = elf_getu32(swap, desc);
+ if (file_printf(ms, ", for FreeBSD") == -1)
+ return;
+
+ /*
+ * Contents is __FreeBSD_version, whose relation to OS
+ * versions is defined by a huge table in the Porter's
+ * Handbook. This is the general scheme:
+ *
+ * Releases:
+ * Mmp000 (before 4.10)
+ * Mmi0p0 (before 5.0)
+ * Mmm0p0
+ *
+ * Development branches:
+ * Mmpxxx (before 4.6)
+ * Mmp1xx (before 4.10)
+ * Mmi1xx (before 5.0)
+ * M000xx (pre-M.0)
+ * Mmm1xx
+ *
+ * M = major version
+ * m = minor version
+ * i = minor version increment (491000 -> 4.10)
+ * p = patchlevel
+ * x = revision
+ *
+ * The first release of FreeBSD to use ELF by default
+ * was version 3.0.
+ */
+ if (desc == 460002) {
+ if (file_printf(ms, " 4.6.2") == -1)
+ return;
+ } else if (desc < 460100) {
+ if (file_printf(ms, " %d.%d", desc / 100000,
+ desc / 10000 % 10) == -1)
+ return;
+ if (desc / 1000 % 10 > 0)
+ if (file_printf(ms, ".%d", desc / 1000 % 10) == -1)
+ return;
+ if ((desc % 1000 > 0) || (desc % 100000 == 0))
+ if (file_printf(ms, " (%d)", desc) == -1)
+ return;
+ } else if (desc < 500000) {
+ if (file_printf(ms, " %d.%d", desc / 100000,
+ desc / 10000 % 10 + desc / 1000 % 10) == -1)
+ return;
+ if (desc / 100 % 10 > 0) {
+ if (file_printf(ms, " (%d)", desc) == -1)
+ return;
+ } else if (desc / 10 % 10 > 0) {
+ if (file_printf(ms, ".%d", desc / 10 % 10) == -1)
+ return;
+ }
+ } else {
+ if (file_printf(ms, " %d.%d", desc / 100000,
+ desc / 1000 % 100) == -1)
+ return;
+ if ((desc / 100 % 10 > 0) ||
+ (desc % 100000 / 100 == 0)) {
+ if (file_printf(ms, " (%d)", desc) == -1)
+ return;
+ } else if (desc / 10 % 10 > 0) {
+ if (file_printf(ms, ".%d", desc / 10 % 10) == -1)
+ return;
+ }
+ }
+}
+
+private int
+/*ARGSUSED*/
+do_bid_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type,
+ int swap __attribute__((__unused__)), uint32_t namesz, uint32_t descsz,
+ size_t noff, size_t doff, int *flags)
+{
+ if (namesz == 4 && strcmp((char *)&nbuf[noff], "GNU") == 0 &&
+ type == NT_GNU_BUILD_ID && (descsz >= 4 && descsz <= 20)) {
+ uint8_t desc[20];
+ const char *btype;
+ uint32_t i;
+ *flags |= FLAGS_DID_BUILD_ID;
+ switch (descsz) {
+ case 8:
+ btype = "xxHash";
+ break;
+ case 16:
+ btype = "md5/uuid";
+ break;
+ case 20:
+ btype = "sha1";
+ break;
+ default:
+ btype = "unknown";
+ break;
+ }
+ if (file_printf(ms, ", BuildID[%s]=", btype) == -1)
+ return 1;
+ (void)memcpy(desc, &nbuf[doff], descsz);
+ for (i = 0; i < descsz; i++)
+ if (file_printf(ms, "%02x", desc[i]) == -1)
+ return 1;
+ return 1;
+ }
+ return 0;
+}
+
+private int
+do_os_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type,
+ int swap, uint32_t namesz, uint32_t descsz,
+ size_t noff, size_t doff, int *flags)
+{
+ if (namesz == 5 && strcmp((char *)&nbuf[noff], "SuSE") == 0 &&
+ type == NT_GNU_VERSION && descsz == 2) {
+ *flags |= FLAGS_DID_OS_NOTE;
+ file_printf(ms, ", for SuSE %d.%d", nbuf[doff], nbuf[doff + 1]);
+ return 1;
+ }
+
+ if (namesz == 4 && strcmp((char *)&nbuf[noff], "GNU") == 0 &&
+ type == NT_GNU_VERSION && descsz == 16) {
+ uint32_t desc[4];
+ (void)memcpy(desc, &nbuf[doff], sizeof(desc));
+
+ *flags |= FLAGS_DID_OS_NOTE;
+ if (file_printf(ms, ", for GNU/") == -1)
+ return 1;
+ switch (elf_getu32(swap, desc[0])) {
+ case GNU_OS_LINUX:
+ if (file_printf(ms, "Linux") == -1)
+ return 1;
+ break;
+ case GNU_OS_HURD:
+ if (file_printf(ms, "Hurd") == -1)
+ return 1;
+ break;
+ case GNU_OS_SOLARIS:
+ if (file_printf(ms, "Solaris") == -1)
+ return 1;
+ break;
+ case GNU_OS_KFREEBSD:
+ if (file_printf(ms, "kFreeBSD") == -1)
+ return 1;
+ break;
+ case GNU_OS_KNETBSD:
+ if (file_printf(ms, "kNetBSD") == -1)
+ return 1;
+ break;
+ default:
+ if (file_printf(ms, "<unknown>") == -1)
+ return 1;
+ }
+ if (file_printf(ms, " %d.%d.%d", elf_getu32(swap, desc[1]),
+ elf_getu32(swap, desc[2]), elf_getu32(swap, desc[3])) == -1)
+ return 1;
+ return 1;
+ }
+
+ if (namesz == 7 && strcmp((char *)&nbuf[noff], "NetBSD") == 0) {
+ if (type == NT_NETBSD_VERSION && descsz == 4) {
+ *flags |= FLAGS_DID_OS_NOTE;
+ do_note_netbsd_version(ms, swap, &nbuf[doff]);
+ return 1;
+ }
+ }
+
+ if (namesz == 8 && strcmp((char *)&nbuf[noff], "FreeBSD") == 0) {
+ if (type == NT_FREEBSD_VERSION && descsz == 4) {
+ *flags |= FLAGS_DID_OS_NOTE;
+ do_note_freebsd_version(ms, swap, &nbuf[doff]);
+ return 1;
+ }
+ }
+
+ if (namesz == 8 && strcmp((char *)&nbuf[noff], "OpenBSD") == 0 &&
+ type == NT_OPENBSD_VERSION && descsz == 4) {
+ *flags |= FLAGS_DID_OS_NOTE;
+ if (file_printf(ms, ", for OpenBSD") == -1)
+ return 1;
+ /* Content of note is always 0 */
+ return 1;
+ }
+
+ if (namesz == 10 && strcmp((char *)&nbuf[noff], "DragonFly") == 0 &&
+ type == NT_DRAGONFLY_VERSION && descsz == 4) {
+ uint32_t desc;
+ *flags |= FLAGS_DID_OS_NOTE;
+ if (file_printf(ms, ", for DragonFly") == -1)
+ return 1;
+ (void)memcpy(&desc, &nbuf[doff], sizeof(desc));
+ desc = elf_getu32(swap, desc);
+ if (file_printf(ms, " %d.%d.%d", desc / 100000,
+ desc / 10000 % 10, desc % 10000) == -1)
+ return 1;
+ return 1;
+ }
+ return 0;
+}
+
+private int
+do_pax_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type,
+ int swap, uint32_t namesz, uint32_t descsz,
+ size_t noff, size_t doff, int *flags)
+{
+ if (namesz == 4 && strcmp((char *)&nbuf[noff], "PaX") == 0 &&
+ type == NT_NETBSD_PAX && descsz == 4) {
+ static const char *pax[] = {
+ "+mprotect",
+ "-mprotect",
+ "+segvguard",
+ "-segvguard",
+ "+ASLR",
+ "-ASLR",
+ };
+ uint32_t desc;
+ size_t i;
+ int did = 0;
+
+ *flags |= FLAGS_DID_NETBSD_PAX;
+ (void)memcpy(&desc, &nbuf[doff], sizeof(desc));
+ desc = elf_getu32(swap, desc);
+
+ if (desc && file_printf(ms, ", PaX: ") == -1)
+ return 1;
+
+ for (i = 0; i < __arraycount(pax); i++) {
+ if (((1 << (int)i) & desc) == 0)
+ continue;
+ if (file_printf(ms, "%s%s", did++ ? "," : "",
+ pax[i]) == -1)
+ return 1;
+ }
+ return 1;
+ }
+ return 0;
+}
+
+private int
+do_core_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type,
+ int swap, uint32_t namesz, uint32_t descsz,
+ size_t noff, size_t doff, int *flags, size_t size, int clazz)
+{
+#ifdef ELFCORE
+ int os_style = -1;
+ /*
+ * Sigh. The 2.0.36 kernel in Debian 2.1, at
+ * least, doesn't correctly implement name
+ * sections, in core dumps, as specified by
+ * the "Program Linking" section of "UNIX(R) System
+ * V Release 4 Programmer's Guide: ANSI C and
+ * Programming Support Tools", because my copy
+ * clearly says "The first 'namesz' bytes in 'name'
+ * contain a *null-terminated* [emphasis mine]
+ * character representation of the entry's owner
+ * or originator", but the 2.0.36 kernel code
+ * doesn't include the terminating null in the
+ * name....
+ */
+ if ((namesz == 4 && strncmp((char *)&nbuf[noff], "CORE", 4) == 0) ||
+ (namesz == 5 && strcmp((char *)&nbuf[noff], "CORE") == 0)) {
+ os_style = OS_STYLE_SVR4;
+ }
+
+ if ((namesz == 8 && strcmp((char *)&nbuf[noff], "FreeBSD") == 0)) {
+ os_style = OS_STYLE_FREEBSD;
+ }
+
+ if ((namesz >= 11 && strncmp((char *)&nbuf[noff], "NetBSD-CORE", 11)
+ == 0)) {
+ os_style = OS_STYLE_NETBSD;
+ }
+
+ if (os_style != -1 && (*flags & FLAGS_DID_CORE_STYLE) == 0) {
+ if (file_printf(ms, ", %s-style", os_style_names[os_style])
+ == -1)
+ return 1;
+ *flags |= FLAGS_DID_CORE_STYLE;
+ *flags |= os_style;
+ }
+
+ switch (os_style) {
+ case OS_STYLE_NETBSD:
+ if (type == NT_NETBSD_CORE_PROCINFO) {
+ char sbuf[512];
+ struct NetBSD_elfcore_procinfo pi;
+ memset(&pi, 0, sizeof(pi));
+ memcpy(&pi, nbuf + doff, descsz);
+
+ if (file_printf(ms, ", from '%.31s', pid=%u, uid=%u, "
+ "gid=%u, nlwps=%u, lwp=%u (signal %u/code %u)",
+ file_printable(sbuf, sizeof(sbuf),
+ CAST(char *, pi.cpi_name)),
+ elf_getu32(swap, pi.cpi_pid),
+ elf_getu32(swap, pi.cpi_euid),
+ elf_getu32(swap, pi.cpi_egid),
+ elf_getu32(swap, pi.cpi_nlwps),
+ elf_getu32(swap, pi.cpi_siglwp),
+ elf_getu32(swap, pi.cpi_signo),
+ elf_getu32(swap, pi.cpi_sigcode)) == -1)
+ return 1;
+
+ *flags |= FLAGS_DID_CORE;
+ return 1;
+ }
+ break;
+
+ default:
+ if (type == NT_PRPSINFO && *flags & FLAGS_IS_CORE) {
+ size_t i, j;
+ unsigned char c;
+ /*
+ * Extract the program name. We assume
+ * it to be 16 characters (that's what it
+ * is in SunOS 5.x and Linux).
+ *
+ * Unfortunately, it's at a different offset
+ * in various OSes, so try multiple offsets.
+ * If the characters aren't all printable,
+ * reject it.
+ */
+ for (i = 0; i < NOFFSETS; i++) {
+ unsigned char *cname, *cp;
+ size_t reloffset = prpsoffsets(i);
+ size_t noffset = doff + reloffset;
+ size_t k;
+ for (j = 0; j < 16; j++, noffset++,
+ reloffset++) {
+ /*
+ * Make sure we're not past
+ * the end of the buffer; if
+ * we are, just give up.
+ */
+ if (noffset >= size)
+ goto tryanother;
+
+ /*
+ * Make sure we're not past
+ * the end of the contents;
+ * if we are, this obviously
+ * isn't the right offset.
+ */
+ if (reloffset >= descsz)
+ goto tryanother;
+
+ c = nbuf[noffset];
+ if (c == '\0') {
+ /*
+ * A '\0' at the
+ * beginning is
+ * obviously wrong.
+ * Any other '\0'
+ * means we're done.
+ */
+ if (j == 0)
+ goto tryanother;
+ else
+ break;
+ } else {
+ /*
+ * A nonprintable
+ * character is also
+ * wrong.
+ */
+ if (!isprint(c) || isquote(c))
+ goto tryanother;
+ }
+ }
+ /*
+ * Well, that worked.
+ */
+
+ /*
+ * Try next offsets, in case this match is
+ * in the middle of a string.
+ */
+ for (k = i + 1 ; k < NOFFSETS; k++) {
+ size_t no;
+ int adjust = 1;
+ if (prpsoffsets(k) >= prpsoffsets(i))
+ continue;
+ for (no = doff + prpsoffsets(k);
+ no < doff + prpsoffsets(i); no++)
+ adjust = adjust
+ && isprint(nbuf[no]);
+ if (adjust)
+ i = k;
+ }
+
+ cname = (unsigned char *)
+ &nbuf[doff + prpsoffsets(i)];
+ for (cp = cname; *cp && isprint(*cp); cp++)
+ continue;
+ /*
+ * Linux apparently appends a space at the end
+ * of the command line: remove it.
+ */
+ while (cp > cname && isspace(cp[-1]))
+ cp--;
+ if (file_printf(ms, ", from '%.*s'",
+ (int)(cp - cname), cname) == -1)
+ return 1;
+ *flags |= FLAGS_DID_CORE;
+ return 1;
+
+ tryanother:
+ ;
+ }
+ }
+ break;
+ }
+#endif
+ return 0;
+}
+
+private off_t
+get_offset_from_virtaddr(struct magic_set *ms, int swap, int clazz, int fd,
+ off_t off, int num, off_t fsize, uint64_t virtaddr)
+{
+ Elf32_Phdr ph32;
+ Elf64_Phdr ph64;
+
+ /*
+ * Loop through all the program headers and find the header with
+ * virtual address in which the "virtaddr" belongs to.
+ */
+ for ( ; num; num--) {
+ if (pread(fd, xph_addr, xph_sizeof, off) < (ssize_t)xph_sizeof) {
+ file_badread(ms);
+ return -1;
+ }
+ off += xph_sizeof;
+
+ if (fsize != SIZE_UNKNOWN && xph_offset > fsize) {
+ /* Perhaps warn here */
+ continue;
+ }
+
+ if (virtaddr >= xph_vaddr && virtaddr < xph_vaddr + xph_filesz)
+ return xph_offset + (virtaddr - xph_vaddr);
+ }
+ return 0;
+}
+
+private size_t
+get_string_on_virtaddr(struct magic_set *ms,
+ int swap, int clazz, int fd, off_t ph_off, int ph_num,
+ off_t fsize, uint64_t virtaddr, char *buf, ssize_t buflen)
+{
+ char *bptr;
+ off_t offset;
+
+ if (buflen == 0)
+ return 0;
+
+ offset = get_offset_from_virtaddr(ms, swap, clazz, fd, ph_off, ph_num,
+ fsize, virtaddr);
+ if ((buflen = pread(fd, buf, CAST(size_t, buflen), offset)) <= 0) {
+ file_badread(ms);
+ return 0;
+ }
+
+ buf[buflen - 1] = '\0';
+
+ /* We expect only printable characters, so return if buffer contains
+ * non-printable character before the '\0' or just '\0'. */
+ for (bptr = buf; *bptr && isprint((unsigned char)*bptr); bptr++)
+ continue;
+ if (*bptr != '\0')
+ return 0;
+
+ return bptr - buf;
+}
+
+
+private int
+do_auxv_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type,
+ int swap, uint32_t namesz __attribute__((__unused__)),
+ uint32_t descsz __attribute__((__unused__)),
+ size_t noff __attribute__((__unused__)), size_t doff,
+ int *flags, size_t size __attribute__((__unused__)), int clazz,
+ int fd, off_t ph_off, int ph_num, off_t fsize)
+{
+#ifdef ELFCORE
+ Aux32Info auxv32;
+ Aux64Info auxv64;
+ size_t elsize = xauxv_sizeof;
+ const char *tag;
+ int is_string;
+ size_t nval;
+
+ if ((*flags & (FLAGS_IS_CORE|FLAGS_DID_CORE_STYLE)) !=
+ (FLAGS_IS_CORE|FLAGS_DID_CORE_STYLE))
+ return 0;
+
+ switch (*flags & FLAGS_CORE_STYLE) {
+ case OS_STYLE_SVR4:
+ if (type != NT_AUXV)
+ return 0;
+ break;
+#ifdef notyet
+ case OS_STYLE_NETBSD:
+ if (type != NT_NETBSD_CORE_AUXV)
+ return 0;
+ break;
+ case OS_STYLE_FREEBSD:
+ if (type != NT_FREEBSD_PROCSTAT_AUXV)
+ return 0;
+ break;
+#endif
+ default:
+ return 0;
+ }
+
+ *flags |= FLAGS_DID_AUXV;
+
+ nval = 0;
+ for (size_t off = 0; off + elsize <= descsz; off += elsize) {
+ (void)memcpy(xauxv_addr, &nbuf[doff + off], xauxv_sizeof);
+ /* Limit processing to 50 vector entries to prevent DoS */
+ if (nval++ >= 50) {
+ file_error(ms, 0, "Too many ELF Auxv elements");
+ return 1;
+ }
+
+ switch(xauxv_type) {
+ case AT_LINUX_EXECFN:
+ is_string = 1;
+ tag = "execfn";
+ break;
+ case AT_LINUX_PLATFORM:
+ is_string = 1;
+ tag = "platform";
+ break;
+ case AT_LINUX_UID:
+ is_string = 0;
+ tag = "real uid";
+ break;
+ case AT_LINUX_GID:
+ is_string = 0;
+ tag = "real gid";
+ break;
+ case AT_LINUX_EUID:
+ is_string = 0;
+ tag = "effective uid";
+ break;
+ case AT_LINUX_EGID:
+ is_string = 0;
+ tag = "effective gid";
+ break;
+ default:
+ is_string = 0;
+ tag = NULL;
+ break;
+ }
+
+ if (tag == NULL)
+ continue;
+
+ if (is_string) {
+ char buf[256];
+ ssize_t buflen;
+ buflen = get_string_on_virtaddr(ms, swap, clazz, fd,
+ ph_off, ph_num, fsize, xauxv_val, buf, sizeof(buf));
+
+ if (buflen == 0)
+ continue;
+
+ if (file_printf(ms, ", %s: '%s'", tag, buf) == -1)
+ return 0;
+ } else {
+ if (file_printf(ms, ", %s: %d", tag, (int) xauxv_val)
+ == -1)
+ return 0;
+ }
+ }
+ return 1;
+#else
+ return 0;
+#endif
+}
+
+private size_t
+donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size,
+ int clazz, int swap, size_t align, int *flags, uint16_t *notecount,
+ int fd, off_t ph_off, int ph_num, off_t fsize)
+{
+ Elf32_Nhdr nh32;
+ Elf64_Nhdr nh64;
+ size_t noff, doff;
+ uint32_t namesz, descsz;
+ unsigned char *nbuf = CAST(unsigned char *, vbuf);
+
+ if (*notecount == 0)
+ return 0;
+ --*notecount;
+
+ if (xnh_sizeof + offset > size) {
+ /*
+ * We're out of note headers.
+ */
+ return xnh_sizeof + offset;
+ }
+
+ (void)memcpy(xnh_addr, &nbuf[offset], xnh_sizeof);
+ offset += xnh_sizeof;
+
+ namesz = xnh_namesz;
+ descsz = xnh_descsz;
+
+ if ((namesz == 0) && (descsz == 0)) {
+ /*
+ * We're out of note headers.
+ */
+ return (offset >= size) ? offset : size;
+ }
+
+ if (namesz & 0x80000000) {
+ (void)file_printf(ms, ", bad note name size %#lx",
+ (unsigned long)namesz);
+ return 0;
+ }
+
+ if (descsz & 0x80000000) {
+ (void)file_printf(ms, ", bad note description size %#lx",
+ (unsigned long)descsz);
+ return 0;
+ }
+
+ noff = offset;
+ doff = ELF_ALIGN(offset + namesz);
+
+ if (offset + namesz > size) {
+ /*
+ * We're past the end of the buffer.
+ */
+ return doff;
+ }
+
+ offset = ELF_ALIGN(doff + descsz);
+ if (doff + descsz > size) {
+ /*
+ * We're past the end of the buffer.
+ */
+ return (offset >= size) ? offset : size;
+ }
+
+
+ if ((*flags & FLAGS_DID_OS_NOTE) == 0) {
+ if (do_os_note(ms, nbuf, xnh_type, swap,
+ namesz, descsz, noff, doff, flags))
+ return offset;
+ }
+
+ if ((*flags & FLAGS_DID_BUILD_ID) == 0) {
+ if (do_bid_note(ms, nbuf, xnh_type, swap,
+ namesz, descsz, noff, doff, flags))
+ return offset;
+ }
+
+ if ((*flags & FLAGS_DID_NETBSD_PAX) == 0) {
+ if (do_pax_note(ms, nbuf, xnh_type, swap,
+ namesz, descsz, noff, doff, flags))
+ return offset;
+ }
+
+ if ((*flags & FLAGS_DID_CORE) == 0) {
+ if (do_core_note(ms, nbuf, xnh_type, swap,
+ namesz, descsz, noff, doff, flags, size, clazz))
+ return offset;
+ }
+
+ if ((*flags & FLAGS_DID_AUXV) == 0) {
+ if (do_auxv_note(ms, nbuf, xnh_type, swap,
+ namesz, descsz, noff, doff, flags, size, clazz,
+ fd, ph_off, ph_num, fsize))
+ return offset;
+ }
+
+ if (namesz == 7 && strcmp((char *)&nbuf[noff], "NetBSD") == 0) {
+ if (descsz > 100)
+ descsz = 100;
+ switch (xnh_type) {
+ case NT_NETBSD_VERSION:
+ return offset;
+ case NT_NETBSD_MARCH:
+ if (*flags & FLAGS_DID_NETBSD_MARCH)
+ return offset;
+ *flags |= FLAGS_DID_NETBSD_MARCH;
+ if (file_printf(ms, ", compiled for: %.*s",
+ (int)descsz, (const char *)&nbuf[doff]) == -1)
+ return offset;
+ break;
+ case NT_NETBSD_CMODEL:
+ if (*flags & FLAGS_DID_NETBSD_CMODEL)
+ return offset;
+ *flags |= FLAGS_DID_NETBSD_CMODEL;
+ if (file_printf(ms, ", compiler model: %.*s",
+ (int)descsz, (const char *)&nbuf[doff]) == -1)
+ return offset;
+ break;
+ default:
+ if (*flags & FLAGS_DID_NETBSD_UNKNOWN)
+ return offset;
+ *flags |= FLAGS_DID_NETBSD_UNKNOWN;
+ if (file_printf(ms, ", note=%u", xnh_type) == -1)
+ return offset;
+ break;
+ }
+ return offset;
+ }
+
+ return offset;
+}
+
+/* SunOS 5.x hardware capability descriptions */
+typedef struct cap_desc {
+ uint64_t cd_mask;
+ const char *cd_name;
+} cap_desc_t;
+
+static const cap_desc_t cap_desc_sparc[] = {
+ { AV_SPARC_MUL32, "MUL32" },
+ { AV_SPARC_DIV32, "DIV32" },
+ { AV_SPARC_FSMULD, "FSMULD" },
+ { AV_SPARC_V8PLUS, "V8PLUS" },
+ { AV_SPARC_POPC, "POPC" },
+ { AV_SPARC_VIS, "VIS" },
+ { AV_SPARC_VIS2, "VIS2" },
+ { AV_SPARC_ASI_BLK_INIT, "ASI_BLK_INIT" },
+ { AV_SPARC_FMAF, "FMAF" },
+ { AV_SPARC_FJFMAU, "FJFMAU" },
+ { AV_SPARC_IMA, "IMA" },
+ { 0, NULL }
+};
+
+static const cap_desc_t cap_desc_386[] = {
+ { AV_386_FPU, "FPU" },
+ { AV_386_TSC, "TSC" },
+ { AV_386_CX8, "CX8" },
+ { AV_386_SEP, "SEP" },
+ { AV_386_AMD_SYSC, "AMD_SYSC" },
+ { AV_386_CMOV, "CMOV" },
+ { AV_386_MMX, "MMX" },
+ { AV_386_AMD_MMX, "AMD_MMX" },
+ { AV_386_AMD_3DNow, "AMD_3DNow" },
+ { AV_386_AMD_3DNowx, "AMD_3DNowx" },
+ { AV_386_FXSR, "FXSR" },
+ { AV_386_SSE, "SSE" },
+ { AV_386_SSE2, "SSE2" },
+ { AV_386_PAUSE, "PAUSE" },
+ { AV_386_SSE3, "SSE3" },
+ { AV_386_MON, "MON" },
+ { AV_386_CX16, "CX16" },
+ { AV_386_AHF, "AHF" },
+ { AV_386_TSCP, "TSCP" },
+ { AV_386_AMD_SSE4A, "AMD_SSE4A" },
+ { AV_386_POPCNT, "POPCNT" },
+ { AV_386_AMD_LZCNT, "AMD_LZCNT" },
+ { AV_386_SSSE3, "SSSE3" },
+ { AV_386_SSE4_1, "SSE4.1" },
+ { AV_386_SSE4_2, "SSE4.2" },
+ { 0, NULL }
+};
+
+private int
+doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
+ size_t size, off_t fsize, int mach, int strtab, int *flags,
+ uint16_t *notecount)
+{
+ Elf32_Shdr sh32;
+ Elf64_Shdr sh64;
+ int stripped = 1, has_debug_info = 0;
+ size_t nbadcap = 0;
+ void *nbuf;
+ off_t noff, coff, name_off;
+ uint64_t cap_hw1 = 0; /* SunOS 5.x hardware capabilities */
+ uint64_t cap_sf1 = 0; /* SunOS 5.x software capabilities */
+ char name[50];
+ ssize_t namesize;
+
+ if (size != xsh_sizeof) {
+ if (file_printf(ms, ", corrupted section header size") == -1)
+ return -1;
+ return 0;
+ }
+
+ /* Read offset of name section to be able to read section names later */
+ if (pread(fd, xsh_addr, xsh_sizeof, CAST(off_t, (off + size * strtab)))
+ < (ssize_t)xsh_sizeof) {
+ if (file_printf(ms, ", missing section headers") == -1)
+ return -1;
+ return 0;
+ }
+ name_off = xsh_offset;
+
+ for ( ; num; num--) {
+ /* Read the name of this section. */
+ if ((namesize = pread(fd, name, sizeof(name) - 1, name_off + xsh_name)) == -1) {
+ file_badread(ms);
+ return -1;
+ }
+ name[namesize] = '\0';
+ if (strcmp(name, ".debug_info") == 0) {
+ has_debug_info = 1;
+ stripped = 0;
+ }
+
+ if (pread(fd, xsh_addr, xsh_sizeof, off) < (ssize_t)xsh_sizeof) {
+ file_badread(ms);
+ return -1;
+ }
+ off += size;
+
+ /* Things we can determine before we seek */
+ switch (xsh_type) {
+ case SHT_SYMTAB:
+#if 0
+ case SHT_DYNSYM:
+#endif
+ stripped = 0;
+ break;
+ default:
+ if (fsize != SIZE_UNKNOWN && xsh_offset > fsize) {
+ /* Perhaps warn here */
+ continue;
+ }
+ break;
+ }
+
+
+ /* Things we can determine when we seek */
+ switch (xsh_type) {
+ case SHT_NOTE:
+ if ((uintmax_t)(xsh_size + xsh_offset) >
+ (uintmax_t)fsize) {
+ if (file_printf(ms,
+ ", note offset/size %#" INTMAX_T_FORMAT
+ "x+%#" INTMAX_T_FORMAT "x exceeds"
+ " file size %#" INTMAX_T_FORMAT "x",
+ (uintmax_t)xsh_offset, (uintmax_t)xsh_size,
+ (uintmax_t)fsize) == -1)
+ return -1;
+ return 0;
+ }
+ if ((nbuf = malloc(xsh_size)) == NULL) {
+ file_error(ms, errno, "Cannot allocate memory"
+ " for note");
+ return -1;
+ }
+ if (pread(fd, nbuf, xsh_size, xsh_offset) <
+ (ssize_t)xsh_size) {
+ file_badread(ms);
+ free(nbuf);
+ return -1;
+ }
+
+ noff = 0;
+ for (;;) {
+ if (noff >= (off_t)xsh_size)
+ break;
+ noff = donote(ms, nbuf, (size_t)noff,
+ xsh_size, clazz, swap, 4, flags, notecount,
+ fd, 0, 0, 0);
+ if (noff == 0)
+ break;
+ }
+ free(nbuf);
+ break;
+ case SHT_SUNW_cap:
+ switch (mach) {
+ case EM_SPARC:
+ case EM_SPARCV9:
+ case EM_IA_64:
+ case EM_386:
+ case EM_AMD64:
+ break;
+ default:
+ goto skip;
+ }
+
+ if (nbadcap > 5)
+ break;
+ if (lseek(fd, xsh_offset, SEEK_SET) == (off_t)-1) {
+ file_badseek(ms);
+ return -1;
+ }
+ coff = 0;
+ for (;;) {
+ Elf32_Cap cap32;
+ Elf64_Cap cap64;
+ char cbuf[/*CONSTCOND*/
+ MAX(sizeof cap32, sizeof cap64)];
+ if ((coff += xcap_sizeof) > (off_t)xsh_size)
+ break;
+ if (read(fd, cbuf, (size_t)xcap_sizeof) !=
+ (ssize_t)xcap_sizeof) {
+ file_badread(ms);
+ return -1;
+ }
+ if (cbuf[0] == 'A') {
+#ifdef notyet
+ char *p = cbuf + 1;
+ uint32_t len, tag;
+ memcpy(&len, p, sizeof(len));
+ p += 4;
+ len = getu32(swap, len);
+ if (memcmp("gnu", p, 3) != 0) {
+ if (file_printf(ms,
+ ", unknown capability %.3s", p)
+ == -1)
+ return -1;
+ break;
+ }
+ p += strlen(p) + 1;
+ tag = *p++;
+ memcpy(&len, p, sizeof(len));
+ p += 4;
+ len = getu32(swap, len);
+ if (tag != 1) {
+ if (file_printf(ms, ", unknown gnu"
+ " capability tag %d", tag)
+ == -1)
+ return -1;
+ break;
+ }
+ // gnu attributes
+#endif
+ break;
+ }
+ (void)memcpy(xcap_addr, cbuf, xcap_sizeof);
+ switch (xcap_tag) {
+ case CA_SUNW_NULL:
+ break;
+ case CA_SUNW_HW_1:
+ cap_hw1 |= xcap_val;
+ break;
+ case CA_SUNW_SF_1:
+ cap_sf1 |= xcap_val;
+ break;
+ default:
+ if (file_printf(ms,
+ ", with unknown capability "
+ "%#" INT64_T_FORMAT "x = %#"
+ INT64_T_FORMAT "x",
+ (unsigned long long)xcap_tag,
+ (unsigned long long)xcap_val) == -1)
+ return -1;
+ if (nbadcap++ > 2)
+ coff = xsh_size;
+ break;
+ }
+ }
+ /*FALLTHROUGH*/
+ skip:
+ default:
+ break;
+ }
+ }
+
+ if (has_debug_info) {
+ if (file_printf(ms, ", with debug_info") == -1)
+ return -1;
+ }
+ if (file_printf(ms, ", %sstripped", stripped ? "" : "not ") == -1)
+ return -1;
+ if (cap_hw1) {
+ const cap_desc_t *cdp;
+ switch (mach) {
+ case EM_SPARC:
+ case EM_SPARC32PLUS:
+ case EM_SPARCV9:
+ cdp = cap_desc_sparc;
+ break;
+ case EM_386:
+ case EM_IA_64:
+ case EM_AMD64:
+ cdp = cap_desc_386;
+ break;
+ default:
+ cdp = NULL;
+ break;
+ }
+ if (file_printf(ms, ", uses") == -1)
+ return -1;
+ if (cdp) {
+ while (cdp->cd_name) {
+ if (cap_hw1 & cdp->cd_mask) {
+ if (file_printf(ms,
+ " %s", cdp->cd_name) == -1)
+ return -1;
+ cap_hw1 &= ~cdp->cd_mask;
+ }
+ ++cdp;
+ }
+ if (cap_hw1)
+ if (file_printf(ms,
+ " unknown hardware capability %#"
+ INT64_T_FORMAT "x",
+ (unsigned long long)cap_hw1) == -1)
+ return -1;
+ } else {
+ if (file_printf(ms,
+ " hardware capability %#" INT64_T_FORMAT "x",
+ (unsigned long long)cap_hw1) == -1)
+ return -1;
+ }
+ }
+ if (cap_sf1) {
+ if (cap_sf1 & SF1_SUNW_FPUSED) {
+ if (file_printf(ms,
+ (cap_sf1 & SF1_SUNW_FPKNWN)
+ ? ", uses frame pointer"
+ : ", not known to use frame pointer") == -1)
+ return -1;
+ }
+ cap_sf1 &= ~SF1_SUNW_MASK;
+ if (cap_sf1)
+ if (file_printf(ms,
+ ", with unknown software capability %#"
+ INT64_T_FORMAT "x",
+ (unsigned long long)cap_sf1) == -1)
+ return -1;
+ }
+ return 0;
+}
+
+/*
+ * Look through the program headers of an executable image, searching
+ * for a PT_INTERP section; if one is found, it's dynamically linked,
+ * otherwise it's statically linked.
+ */
+private int
+dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
+ int num, size_t size, off_t fsize, int sh_num, int *flags,
+ uint16_t *notecount)
+{
+ Elf32_Phdr ph32;
+ Elf64_Phdr ph64;
+ const char *linking_style = "statically";
+ const char *interp = "";
+ unsigned char nbuf[BUFSIZ];
+ char ibuf[BUFSIZ];
+ ssize_t bufsize;
+ size_t offset, align, len;
+
+ if (size != xph_sizeof) {
+ if (file_printf(ms, ", corrupted program header size") == -1)
+ return -1;
+ return 0;
+ }
+
+ for ( ; num; num--) {
+ if (pread(fd, xph_addr, xph_sizeof, off) < (ssize_t)xph_sizeof) {
+ file_badread(ms);
+ return -1;
+ }
+
+ off += size;
+ bufsize = 0;
+ align = 4;
+
+ /* Things we can determine before we seek */
+ switch (xph_type) {
+ case PT_DYNAMIC:
+ linking_style = "dynamically";
+ break;
+ case PT_NOTE:
+ if (sh_num) /* Did this through section headers */
+ continue;
+ if (((align = xph_align) & 0x80000000UL) != 0 ||
+ align < 4) {
+ if (file_printf(ms,
+ ", invalid note alignment %#lx",
+ (unsigned long)align) == -1)
+ return -1;
+ align = 4;
+ }
+ /*FALLTHROUGH*/
+ case PT_INTERP:
+ len = xph_filesz < sizeof(nbuf) ? xph_filesz
+ : sizeof(nbuf);
+ bufsize = pread(fd, nbuf, len, xph_offset);
+ if (bufsize == -1) {
+ file_badread(ms);
+ return -1;
+ }
+ break;
+ default:
+ if (fsize != SIZE_UNKNOWN && xph_offset > fsize) {
+ /* Maybe warn here? */
+ continue;
+ }
+ break;
+ }
+
+ /* Things we can determine when we seek */
+ switch (xph_type) {
+ case PT_INTERP:
+ if (bufsize && nbuf[0]) {
+ nbuf[bufsize - 1] = '\0';
+ interp = (const char *)nbuf;
+ } else
+ interp = "*empty*";
+ break;
+ case PT_NOTE:
+ /*
+ * This is a PT_NOTE section; loop through all the notes
+ * in the section.
+ */
+ offset = 0;
+ for (;;) {
+ if (offset >= (size_t)bufsize)
+ break;
+ offset = donote(ms, nbuf, offset,
+ (size_t)bufsize, clazz, swap, align,
+ flags, notecount, fd, 0, 0, 0);
+ if (offset == 0)
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ if (file_printf(ms, ", %s linked", linking_style)
+ == -1)
+ return -1;
+ if (interp[0])
+ if (file_printf(ms, ", interpreter %s",
+ file_printable(ibuf, sizeof(ibuf), interp)) == -1)
+ return -1;
+ return 0;
+}
+
+
+protected int
+file_tryelf(struct magic_set *ms, int fd, const unsigned char *buf,
+ size_t nbytes)
+{
+ union {
+ int32_t l;
+ char c[sizeof (int32_t)];
+ } u;
+ int clazz;
+ int swap;
+ struct stat st;
+ off_t fsize;
+ int flags = 0;
+ Elf32_Ehdr elf32hdr;
+ Elf64_Ehdr elf64hdr;
+ uint16_t type, phnum, shnum, notecount;
+
+ if (ms->flags & (MAGIC_MIME|MAGIC_APPLE|MAGIC_EXTENSION))
+ return 0;
+ /*
+ * ELF executables have multiple section headers in arbitrary
+ * file locations and thus file(1) cannot determine it from easily.
+ * Instead we traverse thru all section headers until a symbol table
+ * one is found or else the binary is stripped.
+ * Return immediately if it's not ELF (so we avoid pipe2file unless needed).
+ */
+ if (buf[EI_MAG0] != ELFMAG0
+ || (buf[EI_MAG1] != ELFMAG1 && buf[EI_MAG1] != OLFMAG1)
+ || buf[EI_MAG2] != ELFMAG2 || buf[EI_MAG3] != ELFMAG3)
+ return 0;
+
+ /*
+ * If we cannot seek, it must be a pipe, socket or fifo.
+ */
+ if((lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) && (errno == ESPIPE))
+ fd = file_pipe2file(ms, fd, buf, nbytes);
+
+ if (fstat(fd, &st) == -1) {
+ file_badread(ms);
+ return -1;
+ }
+ if (S_ISREG(st.st_mode) || st.st_size != 0)
+ fsize = st.st_size;
+ else
+ fsize = SIZE_UNKNOWN;
+
+ clazz = buf[EI_CLASS];
+
+ switch (clazz) {
+ case ELFCLASS32:
+#undef elf_getu
+#define elf_getu(a, b) elf_getu32(a, b)
+#undef elfhdr
+#define elfhdr elf32hdr
+#include "elfclass.h"
+ case ELFCLASS64:
+#undef elf_getu
+#define elf_getu(a, b) elf_getu64(a, b)
+#undef elfhdr
+#define elfhdr elf64hdr
+#include "elfclass.h"
+ default:
+ if (file_printf(ms, ", unknown class %d", clazz) == -1)
+ return -1;
+ break;
+ }
+ return 0;
+}
+#endif
diff --git a/node_modules/mmmagic/deps/libmagic/src/readelf.h b/node_modules/mmmagic/deps/libmagic/src/readelf.h
new file mode 100644
index 0000000..ef880b9
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/readelf.h
@@ -0,0 +1,433 @@
+/*
+ * Copyright (c) Christos Zoulas 2003.
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice immediately at the beginning of the file, without modification,
+ * this list of conditions, and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+/*
+ * @(#)Id: readelf.h,v 1.9 2002/05/16 18:45:56 christos Exp
+ *
+ * Provide elf data structures for non-elf machines, allowing file
+ * non-elf hosts to determine if an elf binary is stripped.
+ * Note: cobbled from the linux header file, with modifications
+ */
+#ifndef __fake_elf_h__
+#define __fake_elf_h__
+
+#if HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
+typedef uint32_t Elf32_Addr;
+typedef uint32_t Elf32_Off;
+typedef uint16_t Elf32_Half;
+typedef uint32_t Elf32_Word;
+typedef uint8_t Elf32_Char;
+
+typedef uint64_t Elf64_Addr;
+typedef uint64_t Elf64_Off;
+typedef uint64_t Elf64_Xword;
+typedef uint16_t Elf64_Half;
+typedef uint32_t Elf64_Word;
+typedef uint8_t Elf64_Char;
+
+#define EI_NIDENT 16
+
+typedef struct {
+ Elf32_Word a_type; /* 32-bit id */
+ Elf32_Word a_v; /* 32-bit id */
+} Aux32Info;
+
+typedef struct {
+ Elf64_Xword a_type; /* 64-bit id */
+ Elf64_Xword a_v; /* 64-bit id */
+} Aux64Info;
+
+#define AT_NULL 0 /* end of vector */
+#define AT_IGNORE 1 /* entry should be ignored */
+#define AT_EXECFD 2 /* file descriptor of program */
+#define AT_PHDR 3 /* program headers for program */
+#define AT_PHENT 4 /* size of program header entry */
+#define AT_PHNUM 5 /* number of program headers */
+#define AT_PAGESZ 6 /* system page size */
+#define AT_BASE 7 /* base address of interpreter */
+#define AT_FLAGS 8 /* flags */
+#define AT_ENTRY 9 /* entry point of program */
+#define AT_LINUX_NOTELF 10 /* program is not ELF */
+#define AT_LINUX_UID 11 /* real uid */
+#define AT_LINUX_EUID 12 /* effective uid */
+#define AT_LINUX_GID 13 /* real gid */
+#define AT_LINUX_EGID 14 /* effective gid */
+#define AT_LINUX_PLATFORM 15 /* string identifying CPU for optimizations */
+#define AT_LINUX_HWCAP 16 /* arch dependent hints at CPU capabilities */
+#define AT_LINUX_CLKTCK 17 /* frequency at which times() increments */
+/* AT_* values 18 through 22 are reserved */
+#define AT_LINUX_SECURE 23 /* secure mode boolean */
+#define AT_LINUX_BASE_PLATFORM 24 /* string identifying real platform, may
+ * differ from AT_PLATFORM. */
+#define AT_LINUX_RANDOM 25 /* address of 16 random bytes */
+#define AT_LINUX_HWCAP2 26 /* extension of AT_HWCAP */
+#define AT_LINUX_EXECFN 31 /* filename of program */
+
+typedef struct {
+ Elf32_Char e_ident[EI_NIDENT];
+ Elf32_Half e_type;
+ Elf32_Half e_machine;
+ Elf32_Word e_version;
+ Elf32_Addr e_entry; /* Entry point */
+ Elf32_Off e_phoff;
+ Elf32_Off e_shoff;
+ Elf32_Word e_flags;
+ Elf32_Half e_ehsize;
+ Elf32_Half e_phentsize;
+ Elf32_Half e_phnum;
+ Elf32_Half e_shentsize;
+ Elf32_Half e_shnum;
+ Elf32_Half e_shstrndx;
+} Elf32_Ehdr;
+
+typedef struct {
+ Elf64_Char e_ident[EI_NIDENT];
+ Elf64_Half e_type;
+ Elf64_Half e_machine;
+ Elf64_Word e_version;
+ Elf64_Addr e_entry; /* Entry point */
+ Elf64_Off e_phoff;
+ Elf64_Off e_shoff;
+ Elf64_Word e_flags;
+ Elf64_Half e_ehsize;
+ Elf64_Half e_phentsize;
+ Elf64_Half e_phnum;
+ Elf64_Half e_shentsize;
+ Elf64_Half e_shnum;
+ Elf64_Half e_shstrndx;
+} Elf64_Ehdr;
+
+/* e_type */
+#define ET_REL 1
+#define ET_EXEC 2
+#define ET_DYN 3
+#define ET_CORE 4
+
+/* e_machine (used only for SunOS 5.x hardware capabilities) */
+#define EM_SPARC 2
+#define EM_386 3
+#define EM_SPARC32PLUS 18
+#define EM_SPARCV9 43
+#define EM_IA_64 50
+#define EM_AMD64 62
+
+/* sh_type */
+#define SHT_SYMTAB 2
+#define SHT_NOTE 7
+#define SHT_DYNSYM 11
+#define SHT_SUNW_cap 0x6ffffff5 /* SunOS 5.x hw/sw capabilities */
+
+/* elf type */
+#define ELFDATANONE 0 /* e_ident[EI_DATA] */
+#define ELFDATA2LSB 1
+#define ELFDATA2MSB 2
+
+/* elf class */
+#define ELFCLASSNONE 0
+#define ELFCLASS32 1
+#define ELFCLASS64 2
+
+/* magic number */
+#define EI_MAG0 0 /* e_ident[] indexes */
+#define EI_MAG1 1
+#define EI_MAG2 2
+#define EI_MAG3 3
+#define EI_CLASS 4
+#define EI_DATA 5
+#define EI_VERSION 6
+#define EI_PAD 7
+
+#define ELFMAG0 0x7f /* EI_MAG */
+#define ELFMAG1 'E'
+#define ELFMAG2 'L'
+#define ELFMAG3 'F'
+#define ELFMAG "\177ELF"
+
+#define OLFMAG1 'O'
+#define OLFMAG "\177OLF"
+
+typedef struct {
+ Elf32_Word p_type;
+ Elf32_Off p_offset;
+ Elf32_Addr p_vaddr;
+ Elf32_Addr p_paddr;
+ Elf32_Word p_filesz;
+ Elf32_Word p_memsz;
+ Elf32_Word p_flags;
+ Elf32_Word p_align;
+} Elf32_Phdr;
+
+typedef struct {
+ Elf64_Word p_type;
+ Elf64_Word p_flags;
+ Elf64_Off p_offset;
+ Elf64_Addr p_vaddr;
+ Elf64_Addr p_paddr;
+ Elf64_Xword p_filesz;
+ Elf64_Xword p_memsz;
+ Elf64_Xword p_align;
+} Elf64_Phdr;
+
+#define PT_NULL 0 /* p_type */
+#define PT_LOAD 1
+#define PT_DYNAMIC 2
+#define PT_INTERP 3
+#define PT_NOTE 4
+#define PT_SHLIB 5
+#define PT_PHDR 6
+#define PT_NUM 7
+
+typedef struct {
+ Elf32_Word sh_name;
+ Elf32_Word sh_type;
+ Elf32_Word sh_flags;
+ Elf32_Addr sh_addr;
+ Elf32_Off sh_offset;
+ Elf32_Word sh_size;
+ Elf32_Word sh_link;
+ Elf32_Word sh_info;
+ Elf32_Word sh_addralign;
+ Elf32_Word sh_entsize;
+} Elf32_Shdr;
+
+typedef struct {
+ Elf64_Word sh_name;
+ Elf64_Word sh_type;
+ Elf64_Off sh_flags;
+ Elf64_Addr sh_addr;
+ Elf64_Off sh_offset;
+ Elf64_Off sh_size;
+ Elf64_Word sh_link;
+ Elf64_Word sh_info;
+ Elf64_Off sh_addralign;
+ Elf64_Off sh_entsize;
+} Elf64_Shdr;
+
+#define NT_NETBSD_CORE_PROCINFO 1
+#define NT_NETBSD_CORE_AUXV 2
+
+struct NetBSD_elfcore_procinfo {
+ /* Version 1 fields start here. */
+ uint32_t cpi_version; /* our version */
+ uint32_t cpi_cpisize; /* sizeof(this struct) */
+ uint32_t cpi_signo; /* killing signal */
+ uint32_t cpi_sigcode; /* signal code */
+ uint32_t cpi_sigpend[4]; /* pending signals */
+ uint32_t cpi_sigmask[4]; /* blocked signals */
+ uint32_t cpi_sigignore[4]; /* ignored signals */
+ uint32_t cpi_sigcatch[4]; /* caught signals */
+ int32_t cpi_pid; /* process ID */
+ int32_t cpi_ppid; /* parent process ID */
+ int32_t cpi_pgrp; /* process group ID */
+ int32_t cpi_sid; /* session ID */
+ uint32_t cpi_ruid; /* real user ID */
+ uint32_t cpi_euid; /* effective user ID */
+ uint32_t cpi_svuid; /* saved user ID */
+ uint32_t cpi_rgid; /* real group ID */
+ uint32_t cpi_egid; /* effective group ID */
+ uint32_t cpi_svgid; /* saved group ID */
+ uint32_t cpi_nlwps; /* number of LWPs */
+ int8_t cpi_name[32]; /* copy of p->p_comm */
+ /* Add version 2 fields below here. */
+ int32_t cpi_siglwp; /* LWP target of killing signal */
+};
+
+/* Note header in a PT_NOTE section */
+typedef struct elf_note {
+ Elf32_Word n_namesz; /* Name size */
+ Elf32_Word n_descsz; /* Content size */
+ Elf32_Word n_type; /* Content type */
+} Elf32_Nhdr;
+
+typedef struct {
+ Elf64_Word n_namesz;
+ Elf64_Word n_descsz;
+ Elf64_Word n_type;
+} Elf64_Nhdr;
+
+/* Notes used in ET_CORE */
+#define NT_PRSTATUS 1
+#define NT_PRFPREG 2
+#define NT_PRPSINFO 3
+#define NT_PRXREG 4
+#define NT_TASKSTRUCT 4
+#define NT_PLATFORM 5
+#define NT_AUXV 6
+
+/* Note types used in executables */
+/* NetBSD executables (name = "NetBSD") */
+#define NT_NETBSD_VERSION 1
+#define NT_NETBSD_EMULATION 2
+#define NT_FREEBSD_VERSION 1
+#define NT_OPENBSD_VERSION 1
+#define NT_DRAGONFLY_VERSION 1
+/*
+ * GNU executables (name = "GNU")
+ * word[0]: GNU OS tags
+ * word[1]: major version
+ * word[2]: minor version
+ * word[3]: tiny version
+ */
+#define NT_GNU_VERSION 1
+
+/* GNU OS tags */
+#define GNU_OS_LINUX 0
+#define GNU_OS_HURD 1
+#define GNU_OS_SOLARIS 2
+#define GNU_OS_KFREEBSD 3
+#define GNU_OS_KNETBSD 4
+
+/*
+ * GNU Hardware capability information
+ * word[0]: Number of entries
+ * word[1]: Bitmask of enabled entries
+ * Followed by a byte id, and a NUL terminated string per entry
+ */
+#define NT_GNU_HWCAP 2
+
+/*
+ * GNU Build ID generated by ld
+ * 160 bit SHA1 [default]
+ * 128 bit md5 or uuid
+ */
+#define NT_GNU_BUILD_ID 3
+
+/*
+ * NetBSD-specific note type: PaX.
+ * There should be 1 NOTE per executable.
+ * name: PaX\0
+ * namesz: 4
+ * desc:
+ * word[0]: capability bitmask
+ * descsz: 4
+ */
+#define NT_NETBSD_PAX 3
+#define NT_NETBSD_PAX_MPROTECT 0x01 /* Force enable Mprotect */
+#define NT_NETBSD_PAX_NOMPROTECT 0x02 /* Force disable Mprotect */
+#define NT_NETBSD_PAX_GUARD 0x04 /* Force enable Segvguard */
+#define NT_NETBSD_PAX_NOGUARD 0x08 /* Force disable Servguard */
+#define NT_NETBSD_PAX_ASLR 0x10 /* Force enable ASLR */
+#define NT_NETBSD_PAX_NOASLR 0x20 /* Force disable ASLR */
+
+/*
+ * NetBSD-specific note type: MACHINE_ARCH.
+ * There should be 1 NOTE per executable.
+ * name: NetBSD\0
+ * namesz: 7
+ * desc: string
+ * descsz: variable
+ */
+#define NT_NETBSD_MARCH 5
+
+/*
+ * NetBSD-specific note type: COMPILER MODEL.
+ * There should be 1 NOTE per executable.
+ * name: NetBSD\0
+ * namesz: 7
+ * desc: string
+ * descsz: variable
+ */
+#define NT_NETBSD_CMODEL 6
+
+/*
+ * FreeBSD specific notes
+ */
+#define NT_FREEBSD_PROCSTAT_AUXV 16
+
+#if !defined(ELFSIZE) && defined(ARCH_ELFSIZE)
+#define ELFSIZE ARCH_ELFSIZE
+#endif
+/* SunOS 5.x hardware/software capabilities */
+typedef struct {
+ Elf32_Word c_tag;
+ union {
+ Elf32_Word c_val;
+ Elf32_Addr c_ptr;
+ } c_un;
+} Elf32_Cap;
+
+typedef struct {
+ Elf64_Xword c_tag;
+ union {
+ Elf64_Xword c_val;
+ Elf64_Addr c_ptr;
+ } c_un;
+} Elf64_Cap;
+
+/* SunOS 5.x hardware/software capability tags */
+#define CA_SUNW_NULL 0
+#define CA_SUNW_HW_1 1
+#define CA_SUNW_SF_1 2
+
+/* SunOS 5.x software capabilities */
+#define SF1_SUNW_FPKNWN 0x01
+#define SF1_SUNW_FPUSED 0x02
+#define SF1_SUNW_MASK 0x03
+
+/* SunOS 5.x hardware capabilities: sparc */
+#define AV_SPARC_MUL32 0x0001
+#define AV_SPARC_DIV32 0x0002
+#define AV_SPARC_FSMULD 0x0004
+#define AV_SPARC_V8PLUS 0x0008
+#define AV_SPARC_POPC 0x0010
+#define AV_SPARC_VIS 0x0020
+#define AV_SPARC_VIS2 0x0040
+#define AV_SPARC_ASI_BLK_INIT 0x0080
+#define AV_SPARC_FMAF 0x0100
+#define AV_SPARC_FJFMAU 0x4000
+#define AV_SPARC_IMA 0x8000
+
+/* SunOS 5.x hardware capabilities: 386 */
+#define AV_386_FPU 0x00000001
+#define AV_386_TSC 0x00000002
+#define AV_386_CX8 0x00000004
+#define AV_386_SEP 0x00000008
+#define AV_386_AMD_SYSC 0x00000010
+#define AV_386_CMOV 0x00000020
+#define AV_386_MMX 0x00000040
+#define AV_386_AMD_MMX 0x00000080
+#define AV_386_AMD_3DNow 0x00000100
+#define AV_386_AMD_3DNowx 0x00000200
+#define AV_386_FXSR 0x00000400
+#define AV_386_SSE 0x00000800
+#define AV_386_SSE2 0x00001000
+#define AV_386_PAUSE 0x00002000
+#define AV_386_SSE3 0x00004000
+#define AV_386_MON 0x00008000
+#define AV_386_CX16 0x00010000
+#define AV_386_AHF 0x00020000
+#define AV_386_TSCP 0x00040000
+#define AV_386_AMD_SSE4A 0x00080000
+#define AV_386_POPCNT 0x00100000
+#define AV_386_AMD_LZCNT 0x00200000
+#define AV_386_SSSE3 0x00400000
+#define AV_386_SSE4_1 0x00800000
+#define AV_386_SSE4_2 0x01000000
+
+#endif
diff --git a/node_modules/mmmagic/deps/libmagic/src/snprintf.c b/node_modules/mmmagic/deps/libmagic/src/snprintf.c
new file mode 100644
index 0000000..37e22c4
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/snprintf.c
@@ -0,0 +1,26 @@
+// XXX: added by mscdex
+// MSVS prior to version 2015 do not have a proper snprintf implementation
+#include <stdio.h>
+#include <stdarg.h>
+#if defined(_MSC_VER) && _MSC_VER < 1900
+ int vsnprintf(char *outBuf, size_t size, const char *format, va_list ap) {
+ int count = -1;
+
+ if (size != 0)
+ count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
+ if (count == -1)
+ count = _vscprintf(format, ap);
+
+ return count;
+ }
+ int snprintf(char *outBuf, size_t size, const char *format, ...) {
+ int count;
+ va_list ap;
+
+ va_start(ap, format);
+ count = vsnprintf(outBuf, size, format, ap);
+ va_end(ap);
+
+ return count;
+ }
+#endif
diff --git a/node_modules/mmmagic/deps/libmagic/src/softmagic.c b/node_modules/mmmagic/deps/libmagic/src/softmagic.c
new file mode 100644
index 0000000..b9e9753
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/softmagic.c
@@ -0,0 +1,2076 @@
+/*
+ * Copyright (c) Ian F. Darwin 1986-1995.
+ * Software written by Ian F. Darwin and others;
+ * maintained 1995-present by Christos Zoulas and others.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice immediately at the beginning of the file, without modification,
+ * this list of conditions, and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+/*
+ * softmagic - interpret variable magic from MAGIC
+ */
+
+#include "file.h"
+
+#ifndef lint
+FILE_RCSID("@(#)$File: softmagic.c,v 1.249 2017/06/19 18:30:25 christos Exp $")
+#endif /* lint */
+
+#include "magic.h"
+#include <assert.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <time.h>
+#include "der.h"
+
+private int match(struct magic_set *, struct magic *, uint32_t,
+ const unsigned char *, size_t, size_t, int, int, int, uint16_t *,
+ uint16_t *, int *, int *, int *);
+private int mget(struct magic_set *, const unsigned char *,
+ struct magic *, size_t, size_t, unsigned int, int, int, int, uint16_t *,
+ uint16_t *, int *, int *, int *);
+private int magiccheck(struct magic_set *, struct magic *);
+private int32_t mprint(struct magic_set *, struct magic *);
+private int moffset(struct magic_set *, struct magic *, size_t, int32_t *);
+private void mdebug(uint32_t, const char *, size_t);
+private int mcopy(struct magic_set *, union VALUETYPE *, int, int,
+ const unsigned char *, uint32_t, size_t, struct magic *);
+private int mconvert(struct magic_set *, struct magic *, int);
+private int print_sep(struct magic_set *, int);
+private int handle_annotation(struct magic_set *, struct magic *, int);
+private int cvt_8(union VALUETYPE *, const struct magic *);
+private int cvt_16(union VALUETYPE *, const struct magic *);
+private int cvt_32(union VALUETYPE *, const struct magic *);
+private int cvt_64(union VALUETYPE *, const struct magic *);
+
+#define OFFSET_OOB(n, o, i) ((n) < (uint32_t)(o) || (i) > ((n) - (o)))
+#define BE64(p) (((uint64_t)(p)->hq[0]<<56)|((uint64_t)(p)->hq[1]<<48)| \
+ ((uint64_t)(p)->hq[2]<<40)|((uint64_t)(p)->hq[3]<<32)| \
+ ((uint64_t)(p)->hq[4]<<24)|((uint64_t)(p)->hq[5]<<16)| \
+ ((uint64_t)(p)->hq[6]<<8)|((uint64_t)(p)->hq[7]))
+#define LE64(p) (((uint64_t)(p)->hq[7]<<56)|((uint64_t)(p)->hq[6]<<48)| \
+ ((uint64_t)(p)->hq[5]<<40)|((uint64_t)(p)->hq[4]<<32)| \
+ ((uint64_t)(p)->hq[3]<<24)|((uint64_t)(p)->hq[2]<<16)| \
+ ((uint64_t)(p)->hq[1]<<8)|((uint64_t)(p)->hq[0]))
+#define LE32(p) (((uint32_t)(p)->hl[3]<<24)|((uint32_t)(p)->hl[2]<<16)| \
+ ((uint32_t)(p)->hl[1]<<8)|((uint32_t)(p)->hl[0]))
+#define BE32(p) (((uint32_t)(p)->hl[0]<<24)|((uint32_t)(p)->hl[1]<<16)| \
+ ((uint32_t)(p)->hl[2]<<8)|((uint32_t)(p)->hl[3]))
+#define ME32(p) (((uint32_t)(p)->hl[1]<<24)|((uint32_t)(p)->hl[0]<<16)| \
+ ((uint32_t)(p)->hl[3]<<8)|((uint32_t)(p)->hl[2]))
+#define BE16(p) (((uint16_t)(p)->hs[0]<<8)|((uint16_t)(p)->hs[1]))
+#define LE16(p) (((uint16_t)(p)->hs[1]<<8)|((uint16_t)(p)->hs[0]))
+#define SEXT(s,v,p) ((s)?(intmax_t)(int##v##_t)(p):(intmax_t)(uint##v##_t)(p))
+
+/*
+ * softmagic - lookup one file in parsed, in-memory copy of database
+ * Passed the name and FILE * of one file to be typed.
+ */
+/*ARGSUSED1*/ /* nbytes passed for regularity, maybe need later */
+protected int
+file_softmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes,
+ uint16_t *indir_count, uint16_t *name_count, int mode, int text)
+{
+ struct mlist *ml;
+ int rv, printed_something = 0, need_separator = 0;
+ uint16_t nc, ic;
+
+ if (name_count == NULL) {
+ nc = 0;
+ name_count = &nc;
+ }
+ if (indir_count == NULL) {
+ ic = 0;
+ indir_count = &ic;
+ }
+
+ for (ml = ms->mlist[0]->next; ml != ms->mlist[0]; ml = ml->next)
+ if ((rv = match(ms, ml->magic, ml->nmagic, buf, nbytes, 0, mode,
+ text, 0, indir_count, name_count,
+ &printed_something, &need_separator, NULL)) != 0)
+ return rv;
+
+ return 0;
+}
+
+#define FILE_FMTDEBUG
+#ifdef FILE_FMTDEBUG
+#define F(a, b, c) file_fmtcheck((a), (b), (c), __FILE__, __LINE__)
+
+private const char * __attribute__((__format_arg__(3)))
+file_fmtcheck(struct magic_set *ms, const struct magic *m, const char *def,
+ const char *file, size_t line)
+{
+ const char *ptr = fmtcheck(m->desc, def);
+ if (ptr == def)
+ file_magerror(ms,
+ "%s, %" SIZE_T_FORMAT "u: format `%s' does not match"
+ " with `%s'", file, line, m->desc, def);
+ return ptr;
+}
+#else
+#define F(a, b, c) fmtcheck((b)->desc, (c))
+#endif
+
+/*
+ * Go through the whole list, stopping if you find a match. Process all
+ * the continuations of that match before returning.
+ *
+ * We support multi-level continuations:
+ *
+ * At any time when processing a successful top-level match, there is a
+ * current continuation level; it represents the level of the last
+ * successfully matched continuation.
+ *
+ * Continuations above that level are skipped as, if we see one, it
+ * means that the continuation that controls them - i.e, the
+ * lower-level continuation preceding them - failed to match.
+ *
+ * Continuations below that level are processed as, if we see one,
+ * it means we've finished processing or skipping higher-level
+ * continuations under the control of a successful or unsuccessful
+ * lower-level continuation, and are now seeing the next lower-level
+ * continuation and should process it. The current continuation
+ * level reverts to the level of the one we're seeing.
+ *
+ * Continuations at the current level are processed as, if we see
+ * one, there's no lower-level continuation that may have failed.
+ *
+ * If a continuation matches, we bump the current continuation level
+ * so that higher-level continuations are processed.
+ */
+private int
+match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
+ const unsigned char *s, size_t nbytes, size_t offset, int mode, int text,
+ int flip, uint16_t *indir_count, uint16_t *name_count,
+ int *printed_something, int *need_separator, int *returnval)
+{
+ uint32_t magindex = 0;
+ unsigned int cont_level = 0;
+ int returnvalv = 0, e; /* if a match is found it is set to 1*/
+ int firstline = 1; /* a flag to print X\n X\n- X */
+ int print = (ms->flags & MAGIC_NODESC) == 0;
+
+ if (returnval == NULL)
+ returnval = &returnvalv;
+
+ if (file_check_mem(ms, cont_level) == -1)
+ return -1;
+
+ for (magindex = 0; magindex < nmagic; magindex++) {
+ int flush = 0;
+ struct magic *m = &magic[magindex];
+
+ if (m->type != FILE_NAME)
+ if ((IS_STRING(m->type) &&
+#define FLT (STRING_BINTEST | STRING_TEXTTEST)
+ ((text && (m->str_flags & FLT) == STRING_BINTEST) ||
+ (!text && (m->str_flags & FLT) == STRING_TEXTTEST))) ||
+ (m->flag & mode) != mode) {
+flush:
+ /* Skip sub-tests */
+ while (magindex < nmagic - 1 &&
+ magic[magindex + 1].cont_level != 0)
+ magindex++;
+ cont_level = 0;
+ continue; /* Skip to next top-level test*/
+ }
+
+ ms->offset = m->offset;
+ ms->line = m->lineno;
+
+ /* if main entry matches, print it... */
+ switch (mget(ms, s, m, nbytes, offset, cont_level, mode, text,
+ flip, indir_count, name_count,
+ printed_something, need_separator, returnval)) {
+ case -1:
+ return -1;
+ case 0:
+ flush = m->reln != '!';
+ break;
+ default:
+ if (m->type == FILE_INDIRECT)
+ *returnval = 1;
+
+ switch (magiccheck(ms, m)) {
+ case -1:
+ return -1;
+ case 0:
+ flush++;
+ break;
+ default:
+ flush = 0;
+ break;
+ }
+ break;
+ }
+ if (flush) {
+ /*
+ * main entry didn't match,
+ * flush its continuations
+ */
+ goto flush;
+ }
+
+ if ((e = handle_annotation(ms, m, firstline)) != 0) {
+ *need_separator = 1;
+ *printed_something = 1;
+ *returnval = 1;
+ return e;
+ }
+
+ /*
+ * If we are going to print something, we'll need to print
+ * a blank before we print something else.
+ */
+ if (*m->desc) {
+ *need_separator = 1;
+ *printed_something = 1;
+ if (print_sep(ms, firstline) == -1)
+ return -1;
+ }
+
+
+ if (print && mprint(ms, m) == -1)
+ return -1;
+
+ switch (moffset(ms, m, nbytes, &ms->c.li[cont_level].off)) {
+ case -1:
+ case 0:
+ goto flush;
+ default:
+ break;
+ }
+
+ /* and any continuations that match */
+ if (file_check_mem(ms, ++cont_level) == -1)
+ return -1;
+
+ while (magindex + 1 < nmagic &&
+ magic[magindex + 1].cont_level != 0) {
+ m = &magic[++magindex];
+ ms->line = m->lineno; /* for messages */
+
+ if (cont_level < m->cont_level)
+ continue;
+ if (cont_level > m->cont_level) {
+ /*
+ * We're at the end of the level
+ * "cont_level" continuations.
+ */
+ cont_level = m->cont_level;
+ }
+ ms->offset = m->offset;
+ if (m->flag & OFFADD) {
+ ms->offset +=
+ ms->c.li[cont_level - 1].off;
+ }
+
+#ifdef ENABLE_CONDITIONALS
+ if (m->cond == COND_ELSE ||
+ m->cond == COND_ELIF) {
+ if (ms->c.li[cont_level].last_match == 1)
+ continue;
+ }
+#endif
+ switch (mget(ms, s, m, nbytes, offset, cont_level, mode,
+ text, flip, indir_count, name_count,
+ printed_something, need_separator, returnval)) {
+ case -1:
+ return -1;
+ case 0:
+ if (m->reln != '!')
+ continue;
+ flush = 1;
+ break;
+ default:
+ if (m->type == FILE_INDIRECT)
+ *returnval = 1;
+ flush = 0;
+ break;
+ }
+
+ switch (flush ? 1 : magiccheck(ms, m)) {
+ case -1:
+ return -1;
+ case 0:
+#ifdef ENABLE_CONDITIONALS
+ ms->c.li[cont_level].last_match = 0;
+#endif
+ break;
+ default:
+#ifdef ENABLE_CONDITIONALS
+ ms->c.li[cont_level].last_match = 1;
+#endif
+ if (m->type == FILE_CLEAR)
+ ms->c.li[cont_level].got_match = 0;
+ else if (ms->c.li[cont_level].got_match) {
+ if (m->type == FILE_DEFAULT)
+ break;
+ } else
+ ms->c.li[cont_level].got_match = 1;
+
+ if ((e = handle_annotation(ms, m, firstline)) != 0) {
+ *need_separator = 1;
+ *printed_something = 1;
+ *returnval = 1;
+ return e;
+ }
+ /*
+ * If we are going to print something,
+ * make sure that we have a separator first.
+ */
+ if (*m->desc) {
+ if (!*printed_something) {
+ *printed_something = 1;
+ if (print_sep(ms, firstline)
+ == -1)
+ return -1;
+ }
+ }
+ /*
+ * This continuation matched. Print
+ * its message, with a blank before it
+ * if the previous item printed and
+ * this item isn't empty.
+ */
+ /* space if previous printed */
+ if (*need_separator
+ && ((m->flag & NOSPACE) == 0)
+ && *m->desc) {
+ if (print &&
+ file_printf(ms, " ") == -1)
+ return -1;
+ *need_separator = 0;
+ }
+ if (print && mprint(ms, m) == -1)
+ return -1;
+
+ switch (moffset(ms, m, nbytes,
+ &ms->c.li[cont_level].off)) {
+ case -1:
+ case 0:
+ flush = 1;
+ cont_level--;
+ break;
+ default:
+ break;
+ }
+
+ if (*m->desc)
+ *need_separator = 1;
+
+ /*
+ * If we see any continuations
+ * at a higher level,
+ * process them.
+ */
+ if (file_check_mem(ms, ++cont_level) == -1)
+ return -1;
+ break;
+ }
+ }
+ if (*printed_something) {
+ firstline = 0;
+ if (print)
+ *returnval = 1;
+ }
+ if ((ms->flags & MAGIC_CONTINUE) == 0 && *printed_something) {
+ return *returnval; /* don't keep searching */
+ }
+ cont_level = 0;
+ }
+ return *returnval; /* This is hit if -k is set or there is no match */
+}
+
+private int
+check_fmt(struct magic_set *ms, struct magic *m)
+{
+ file_regex_t rx;
+ int rc, rv = -1;
+
+ if (strchr(m->desc, '%') == NULL)
+ return 0;
+
+ rc = file_regcomp(&rx, "%[-0-9\\.]*s", REG_EXTENDED|REG_NOSUB);
+ if (rc) {
+ file_regerror(&rx, rc, ms);
+ } else {
+ rc = file_regexec(&rx, m->desc, 0, 0, 0);
+ rv = !rc;
+ }
+ file_regfree(&rx);
+ return rv;
+}
+
+#ifndef HAVE_STRNDUP
+char * strndup(const char *, size_t);
+
+char *
+strndup(const char *str, size_t n)
+{
+ size_t len;
+ char *copy;
+
+ for (len = 0; len < n && str[len]; len++)
+ continue;
+ if ((copy = malloc(len + 1)) == NULL)
+ return NULL;
+ (void)memcpy(copy, str, len);
+ copy[len] = '\0';
+ return copy;
+}
+#endif /* HAVE_STRNDUP */
+
+private int32_t
+mprint(struct magic_set *ms, struct magic *m)
+{
+ uint64_t v;
+ float vf;
+ double vd;
+ int64_t t = 0;
+ char buf[128], tbuf[26], sbuf[512];
+ union VALUETYPE *p = &ms->ms_value;
+
+ switch (m->type) {
+ case FILE_BYTE:
+ v = file_signextend(ms, m, (uint64_t)p->b);
+ switch (check_fmt(ms, m)) {
+ case -1:
+ return -1;
+ case 1:
+ (void)snprintf(buf, sizeof(buf), "%d",
+ (unsigned char)v);
+ if (file_printf(ms, F(ms, m, "%s"), buf) == -1)
+ return -1;
+ break;
+ default:
+ if (file_printf(ms, F(ms, m, "%d"),
+ (unsigned char) v) == -1)
+ return -1;
+ break;
+ }
+ t = ms->offset + sizeof(char);
+ break;
+
+ case FILE_SHORT:
+ case FILE_BESHORT:
+ case FILE_LESHORT:
+ v = file_signextend(ms, m, (uint64_t)p->h);
+ switch (check_fmt(ms, m)) {
+ case -1:
+ return -1;
+ case 1:
+ (void)snprintf(buf, sizeof(buf), "%u",
+ (unsigned short)v);
+ if (file_printf(ms, F(ms, m, "%s"), buf) == -1)
+ return -1;
+ break;
+ default:
+ if (file_printf(ms, F(ms, m, "%u"),
+ (unsigned short) v) == -1)
+ return -1;
+ break;
+ }
+ t = ms->offset + sizeof(short);
+ break;
+
+ case FILE_LONG:
+ case FILE_BELONG:
+ case FILE_LELONG:
+ case FILE_MELONG:
+ v = file_signextend(ms, m, (uint64_t)p->l);
+ switch (check_fmt(ms, m)) {
+ case -1:
+ return -1;
+ case 1:
+ (void)snprintf(buf, sizeof(buf), "%u", (uint32_t) v);
+ if (file_printf(ms, F(ms, m, "%s"), buf) == -1)
+ return -1;
+ break;
+ default:
+ if (file_printf(ms, F(ms, m, "%u"), (uint32_t) v) == -1)
+ return -1;
+ break;
+ }
+ t = ms->offset + sizeof(int32_t);
+ break;
+
+ case FILE_QUAD:
+ case FILE_BEQUAD:
+ case FILE_LEQUAD:
+ v = file_signextend(ms, m, p->q);
+ switch (check_fmt(ms, m)) {
+ case -1:
+ return -1;
+ case 1:
+ (void)snprintf(buf, sizeof(buf), "%" INT64_T_FORMAT "u",
+ (unsigned long long)v);
+ if (file_printf(ms, F(ms, m, "%s"), buf) == -1)
+ return -1;
+ break;
+ default:
+ if (file_printf(ms, F(ms, m, "%" INT64_T_FORMAT "u"),
+ (unsigned long long) v) == -1)
+ return -1;
+ break;
+ }
+ t = ms->offset + sizeof(int64_t);
+ break;
+
+ case FILE_STRING:
+ case FILE_PSTRING:
+ case FILE_BESTRING16:
+ case FILE_LESTRING16:
+ if (m->reln == '=' || m->reln == '!') {
+ if (file_printf(ms, F(ms, m, "%s"),
+ file_printable(sbuf, sizeof(sbuf), m->value.s))
+ == -1)
+ return -1;
+ t = ms->offset + m->vallen;
+ }
+ else {
+ char *str = p->s;
+
+ /* compute t before we mangle the string? */
+ t = ms->offset + strlen(str);
+
+ if (*m->value.s == '\0')
+ str[strcspn(str, "\r\n")] = '\0';
+
+ if (m->str_flags & STRING_TRIM) {
+ char *last;
+ while (isspace((unsigned char)*str))
+ str++;
+ last = str;
+ while (*last)
+ last++;
+ --last;
+ while (isspace((unsigned char)*last))
+ last--;
+ *++last = '\0';
+ }
+
+ if (file_printf(ms, F(ms, m, "%s"),
+ file_printable(sbuf, sizeof(sbuf), str)) == -1)
+ return -1;
+
+ if (m->type == FILE_PSTRING)
+ t += file_pstring_length_size(m);
+ }
+ break;
+
+ case FILE_DATE:
+ case FILE_BEDATE:
+ case FILE_LEDATE:
+ case FILE_MEDATE:
+ if (file_printf(ms, F(ms, m, "%s"),
+ file_fmttime(p->l, 0, tbuf)) == -1)
+ return -1;
+ t = ms->offset + sizeof(uint32_t);
+ break;
+
+ case FILE_LDATE:
+ case FILE_BELDATE:
+ case FILE_LELDATE:
+ case FILE_MELDATE:
+ if (file_printf(ms, F(ms, m, "%s"),
+ file_fmttime(p->l, FILE_T_LOCAL, tbuf)) == -1)
+ return -1;
+ t = ms->offset + sizeof(uint32_t);
+ break;
+
+ case FILE_QDATE:
+ case FILE_BEQDATE:
+ case FILE_LEQDATE:
+ if (file_printf(ms, F(ms, m, "%s"),
+ file_fmttime(p->q, 0, tbuf)) == -1)
+ return -1;
+ t = ms->offset + sizeof(uint64_t);
+ break;
+
+ case FILE_QLDATE:
+ case FILE_BEQLDATE:
+ case FILE_LEQLDATE:
+ if (file_printf(ms, F(ms, m, "%s"),
+ file_fmttime(p->q, FILE_T_LOCAL, tbuf)) == -1)
+ return -1;
+ t = ms->offset + sizeof(uint64_t);
+ break;
+
+ case FILE_QWDATE:
+ case FILE_BEQWDATE:
+ case FILE_LEQWDATE:
+ if (file_printf(ms, F(ms, m, "%s"),
+ file_fmttime(p->q, FILE_T_WINDOWS, tbuf)) == -1)
+ return -1;
+ t = ms->offset + sizeof(uint64_t);
+ break;
+
+ case FILE_FLOAT:
+ case FILE_BEFLOAT:
+ case FILE_LEFLOAT:
+ vf = p->f;
+ switch (check_fmt(ms, m)) {
+ case -1:
+ return -1;
+ case 1:
+ (void)snprintf(buf, sizeof(buf), "%g", vf);
+ if (file_printf(ms, F(ms, m, "%s"), buf) == -1)
+ return -1;
+ break;
+ default:
+ if (file_printf(ms, F(ms, m, "%g"), vf) == -1)
+ return -1;
+ break;
+ }
+ t = ms->offset + sizeof(float);
+ break;
+
+ case FILE_DOUBLE:
+ case FILE_BEDOUBLE:
+ case FILE_LEDOUBLE:
+ vd = p->d;
+ switch (check_fmt(ms, m)) {
+ case -1:
+ return -1;
+ case 1:
+ (void)snprintf(buf, sizeof(buf), "%g", vd);
+ if (file_printf(ms, F(ms, m, "%s"), buf) == -1)
+ return -1;
+ break;
+ default:
+ if (file_printf(ms, F(ms, m, "%g"), vd) == -1)
+ return -1;
+ break;
+ }
+ t = ms->offset + sizeof(double);
+ break;
+
+ case FILE_SEARCH:
+ case FILE_REGEX: {
+ char *cp;
+ int rval;
+
+ cp = strndup((const char *)ms->search.s, ms->search.rm_len);
+ if (cp == NULL) {
+ file_oomem(ms, ms->search.rm_len);
+ return -1;
+ }
+ rval = file_printf(ms, F(ms, m, "%s"),
+ file_printable(sbuf, sizeof(sbuf), cp));
+ free(cp);
+
+ if (rval == -1)
+ return -1;
+
+ if ((m->str_flags & REGEX_OFFSET_START))
+ t = ms->search.offset;
+ else
+ t = ms->search.offset + ms->search.rm_len;
+ break;
+ }
+
+ case FILE_DEFAULT:
+ case FILE_CLEAR:
+ if (file_printf(ms, "%s", m->desc) == -1)
+ return -1;
+ t = ms->offset;
+ break;
+
+ case FILE_INDIRECT:
+ case FILE_USE:
+ case FILE_NAME:
+ t = ms->offset;
+ break;
+ case FILE_DER:
+ if (file_printf(ms, F(ms, m, "%s"),
+ file_printable(sbuf, sizeof(sbuf), ms->ms_value.s)) == -1)
+ return -1;
+ t = ms->offset;
+ break;
+ default:
+ file_magerror(ms, "invalid m->type (%d) in mprint()", m->type);
+ return -1;
+ }
+ return (int32_t)t;
+}
+
+private int
+moffset(struct magic_set *ms, struct magic *m, size_t nbytes, int32_t *op)
+{
+ int32_t o;
+
+ switch (m->type) {
+ case FILE_BYTE:
+ o = CAST(int32_t, (ms->offset + sizeof(char)));
+ break;
+
+ case FILE_SHORT:
+ case FILE_BESHORT:
+ case FILE_LESHORT:
+ o = CAST(int32_t, (ms->offset + sizeof(short)));
+ break;
+
+ case FILE_LONG:
+ case FILE_BELONG:
+ case FILE_LELONG:
+ case FILE_MELONG:
+ o = CAST(int32_t, (ms->offset + sizeof(int32_t)));
+ break;
+
+ case FILE_QUAD:
+ case FILE_BEQUAD:
+ case FILE_LEQUAD:
+ o = CAST(int32_t, (ms->offset + sizeof(int64_t)));
+ break;
+
+ case FILE_STRING:
+ case FILE_PSTRING:
+ case FILE_BESTRING16:
+ case FILE_LESTRING16:
+ if (m->reln == '=' || m->reln == '!') {
+ o = ms->offset + m->vallen;
+ } else {
+ union VALUETYPE *p = &ms->ms_value;
+
+ if (*m->value.s == '\0')
+ p->s[strcspn(p->s, "\r\n")] = '\0';
+ o = CAST(uint32_t, (ms->offset + strlen(p->s)));
+ if (m->type == FILE_PSTRING)
+ o += (uint32_t)file_pstring_length_size(m);
+ }
+ break;
+
+ case FILE_DATE:
+ case FILE_BEDATE:
+ case FILE_LEDATE:
+ case FILE_MEDATE:
+ o = CAST(int32_t, (ms->offset + sizeof(uint32_t)));
+ break;
+
+ case FILE_LDATE:
+ case FILE_BELDATE:
+ case FILE_LELDATE:
+ case FILE_MELDATE:
+ o = CAST(int32_t, (ms->offset + sizeof(uint32_t)));
+ break;
+
+ case FILE_QDATE:
+ case FILE_BEQDATE:
+ case FILE_LEQDATE:
+ o = CAST(int32_t, (ms->offset + sizeof(uint64_t)));
+ break;
+
+ case FILE_QLDATE:
+ case FILE_BEQLDATE:
+ case FILE_LEQLDATE:
+ o = CAST(int32_t, (ms->offset + sizeof(uint64_t)));
+ break;
+
+ case FILE_FLOAT:
+ case FILE_BEFLOAT:
+ case FILE_LEFLOAT:
+ o = CAST(int32_t, (ms->offset + sizeof(float)));
+ break;
+
+ case FILE_DOUBLE:
+ case FILE_BEDOUBLE:
+ case FILE_LEDOUBLE:
+ o = CAST(int32_t, (ms->offset + sizeof(double)));
+ break;
+
+ case FILE_REGEX:
+ if ((m->str_flags & REGEX_OFFSET_START) != 0)
+ o = CAST(int32_t, ms->search.offset);
+ else
+ o = CAST(int32_t,
+ (ms->search.offset + ms->search.rm_len));
+ break;
+
+ case FILE_SEARCH:
+ if ((m->str_flags & REGEX_OFFSET_START) != 0)
+ o = CAST(int32_t, ms->search.offset);
+ else
+ o = CAST(int32_t, (ms->search.offset + m->vallen));
+ break;
+
+ case FILE_CLEAR:
+ case FILE_DEFAULT:
+ case FILE_INDIRECT:
+ o = ms->offset;
+ break;
+
+ case FILE_DER:
+ {
+ o = der_offs(ms, m, nbytes);
+ if (o == -1 || (size_t)o > nbytes) {
+ if ((ms->flags & MAGIC_DEBUG) != 0) {
+ (void)fprintf(stderr,
+ "Bad DER offset %d nbytes=%zu",
+ o, nbytes);
+ }
+ *op = 0;
+ return 0;
+ }
+ break;
+ }
+
+ default:
+ o = 0;
+ break;
+ }
+
+ if ((size_t)o > nbytes) {
+#if 0
+ file_error(ms, 0, "Offset out of range %zu > %zu",
+ (size_t)o, nbytes);
+#endif
+ return -1;
+ }
+ *op = o;
+ return 1;
+}
+
+private uint32_t
+cvt_id3(struct magic_set *ms, uint32_t v)
+{
+ v = ((((v >> 0) & 0x7f) << 0) |
+ (((v >> 8) & 0x7f) << 7) |
+ (((v >> 16) & 0x7f) << 14) |
+ (((v >> 24) & 0x7f) << 21));
+ if ((ms->flags & MAGIC_DEBUG) != 0)
+ fprintf(stderr, "id3 offs=%u\n", v);
+ return v;
+}
+
+private int
+cvt_flip(int type, int flip)
+{
+ if (flip == 0)
+ return type;
+ switch (type) {
+ case FILE_BESHORT:
+ return FILE_LESHORT;
+ case FILE_BELONG:
+ return FILE_LELONG;
+ case FILE_BEDATE:
+ return FILE_LEDATE;
+ case FILE_BELDATE:
+ return FILE_LELDATE;
+ case FILE_BEQUAD:
+ return FILE_LEQUAD;
+ case FILE_BEQDATE:
+ return FILE_LEQDATE;
+ case FILE_BEQLDATE:
+ return FILE_LEQLDATE;
+ case FILE_BEQWDATE:
+ return FILE_LEQWDATE;
+ case FILE_LESHORT:
+ return FILE_BESHORT;
+ case FILE_LELONG:
+ return FILE_BELONG;
+ case FILE_LEDATE:
+ return FILE_BEDATE;
+ case FILE_LELDATE:
+ return FILE_BELDATE;
+ case FILE_LEQUAD:
+ return FILE_BEQUAD;
+ case FILE_LEQDATE:
+ return FILE_BEQDATE;
+ case FILE_LEQLDATE:
+ return FILE_BEQLDATE;
+ case FILE_LEQWDATE:
+ return FILE_BEQWDATE;
+ case FILE_BEFLOAT:
+ return FILE_LEFLOAT;
+ case FILE_LEFLOAT:
+ return FILE_BEFLOAT;
+ case FILE_BEDOUBLE:
+ return FILE_LEDOUBLE;
+ case FILE_LEDOUBLE:
+ return FILE_BEDOUBLE;
+ default:
+ return type;
+ }
+}
+#define DO_CVT(fld, cast) \
+ if (m->num_mask) \
+ switch (m->mask_op & FILE_OPS_MASK) { \
+ case FILE_OPAND: \
+ p->fld &= cast m->num_mask; \
+ break; \
+ case FILE_OPOR: \
+ p->fld |= cast m->num_mask; \
+ break; \
+ case FILE_OPXOR: \
+ p->fld ^= cast m->num_mask; \
+ break; \
+ case FILE_OPADD: \
+ p->fld += cast m->num_mask; \
+ break; \
+ case FILE_OPMINUS: \
+ p->fld -= cast m->num_mask; \
+ break; \
+ case FILE_OPMULTIPLY: \
+ p->fld *= cast m->num_mask; \
+ break; \
+ case FILE_OPDIVIDE: \
+ if (cast m->num_mask == 0) \
+ return -1; \
+ p->fld /= cast m->num_mask; \
+ break; \
+ case FILE_OPMODULO: \
+ if (cast m->num_mask == 0) \
+ return -1; \
+ p->fld %= cast m->num_mask; \
+ break; \
+ } \
+ if (m->mask_op & FILE_OPINVERSE) \
+ p->fld = ~p->fld \
+
+private int
+cvt_8(union VALUETYPE *p, const struct magic *m)
+{
+ DO_CVT(b, (uint8_t));
+ return 0;
+}
+
+private int
+cvt_16(union VALUETYPE *p, const struct magic *m)
+{
+ DO_CVT(h, (uint16_t));
+ return 0;
+}
+
+private int
+cvt_32(union VALUETYPE *p, const struct magic *m)
+{
+ DO_CVT(l, (uint32_t));
+ return 0;
+}
+
+private int
+cvt_64(union VALUETYPE *p, const struct magic *m)
+{
+ DO_CVT(q, (uint64_t));
+ return 0;
+}
+
+#define DO_CVT2(fld, cast) \
+ if (m->num_mask) \
+ switch (m->mask_op & FILE_OPS_MASK) { \
+ case FILE_OPADD: \
+ p->fld += cast m->num_mask; \
+ break; \
+ case FILE_OPMINUS: \
+ p->fld -= cast m->num_mask; \
+ break; \
+ case FILE_OPMULTIPLY: \
+ p->fld *= cast m->num_mask; \
+ break; \
+ case FILE_OPDIVIDE: \
+ if (cast m->num_mask == 0) \
+ return -1; \
+ p->fld /= cast m->num_mask; \
+ break; \
+ } \
+
+private int
+cvt_float(union VALUETYPE *p, const struct magic *m)
+{
+ DO_CVT2(f, (float));
+ return 0;
+}
+
+private int
+cvt_double(union VALUETYPE *p, const struct magic *m)
+{
+ DO_CVT2(d, (double));
+ return 0;
+}
+
+/*
+ * Convert the byte order of the data we are looking at
+ * While we're here, let's apply the mask operation
+ * (unless you have a better idea)
+ */
+private int
+mconvert(struct magic_set *ms, struct magic *m, int flip)
+{
+ union VALUETYPE *p = &ms->ms_value;
+
+ switch (cvt_flip(m->type, flip)) {
+ case FILE_BYTE:
+ if (cvt_8(p, m) == -1)
+ goto out;
+ return 1;
+ case FILE_SHORT:
+ if (cvt_16(p, m) == -1)
+ goto out;
+ return 1;
+ case FILE_LONG:
+ case FILE_DATE:
+ case FILE_LDATE:
+ if (cvt_32(p, m) == -1)
+ goto out;
+ return 1;
+ case FILE_QUAD:
+ case FILE_QDATE:
+ case FILE_QLDATE:
+ case FILE_QWDATE:
+ if (cvt_64(p, m) == -1)
+ goto out;
+ return 1;
+ case FILE_STRING:
+ case FILE_BESTRING16:
+ case FILE_LESTRING16: {
+ /* Null terminate and eat *trailing* return */
+ p->s[sizeof(p->s) - 1] = '\0';
+ return 1;
+ }
+ case FILE_PSTRING: {
+ size_t sz = file_pstring_length_size(m);
+ char *ptr1 = p->s, *ptr2 = ptr1 + sz;
+ size_t len = file_pstring_get_length(m, ptr1);
+ sz = sizeof(p->s) - sz; /* maximum length of string */
+ if (len >= sz) {
+ /*
+ * The size of the pascal string length (sz)
+ * is 1, 2, or 4. We need at least 1 byte for NUL
+ * termination, but we've already truncated the
+ * string by p->s, so we need to deduct sz.
+ * Because we can use one of the bytes of the length
+ * after we shifted as NUL termination.
+ */
+ len = sz;
+ }
+ while (len--)
+ *ptr1++ = *ptr2++;
+ *ptr1 = '\0';
+ return 1;
+ }
+ case FILE_BESHORT:
+ p->h = (short)BE16(p);
+ if (cvt_16(p, m) == -1)
+ goto out;
+ return 1;
+ case FILE_BELONG:
+ case FILE_BEDATE:
+ case FILE_BELDATE:
+ p->l = (int32_t)BE32(p);
+ if (cvt_32(p, m) == -1)
+ goto out;
+ return 1;
+ case FILE_BEQUAD:
+ case FILE_BEQDATE:
+ case FILE_BEQLDATE:
+ case FILE_BEQWDATE:
+ p->q = (uint64_t)BE64(p);
+ if (cvt_64(p, m) == -1)
+ goto out;
+ return 1;
+ case FILE_LESHORT:
+ p->h = (short)LE16(p);
+ if (cvt_16(p, m) == -1)
+ goto out;
+ return 1;
+ case FILE_LELONG:
+ case FILE_LEDATE:
+ case FILE_LELDATE:
+ p->l = (int32_t)LE32(p);
+ if (cvt_32(p, m) == -1)
+ goto out;
+ return 1;
+ case FILE_LEQUAD:
+ case FILE_LEQDATE:
+ case FILE_LEQLDATE:
+ case FILE_LEQWDATE:
+ p->q = (uint64_t)LE64(p);
+ if (cvt_64(p, m) == -1)
+ goto out;
+ return 1;
+ case FILE_MELONG:
+ case FILE_MEDATE:
+ case FILE_MELDATE:
+ p->l = (int32_t)ME32(p);
+ if (cvt_32(p, m) == -1)
+ goto out;
+ return 1;
+ case FILE_FLOAT:
+ if (cvt_float(p, m) == -1)
+ goto out;
+ return 1;
+ case FILE_BEFLOAT:
+ p->l = BE32(p);
+ if (cvt_float(p, m) == -1)
+ goto out;
+ return 1;
+ case FILE_LEFLOAT:
+ p->l = LE32(p);
+ if (cvt_float(p, m) == -1)
+ goto out;
+ return 1;
+ case FILE_DOUBLE:
+ if (cvt_double(p, m) == -1)
+ goto out;
+ return 1;
+ case FILE_BEDOUBLE:
+ p->q = BE64(p);
+ if (cvt_double(p, m) == -1)
+ goto out;
+ return 1;
+ case FILE_LEDOUBLE:
+ p->q = LE64(p);
+ if (cvt_double(p, m) == -1)
+ goto out;
+ return 1;
+ case FILE_REGEX:
+ case FILE_SEARCH:
+ case FILE_DEFAULT:
+ case FILE_CLEAR:
+ case FILE_NAME:
+ case FILE_USE:
+ case FILE_DER:
+ return 1;
+ default:
+ file_magerror(ms, "invalid type %d in mconvert()", m->type);
+ return 0;
+ }
+out:
+ file_magerror(ms, "zerodivide in mconvert()");
+ return 0;
+}
+
+
+private void
+mdebug(uint32_t offset, const char *str, size_t len)
+{
+ (void) fprintf(stderr, "mget/%" SIZE_T_FORMAT "u @%d: ", len, offset);
+ file_showstr(stderr, str, len);
+ (void) fputc('\n', stderr);
+ (void) fputc('\n', stderr);
+}
+
+private int
+mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
+ const unsigned char *s, uint32_t offset, size_t nbytes, struct magic *m)
+{
+ /*
+ * Note: FILE_SEARCH and FILE_REGEX do not actually copy
+ * anything, but setup pointers into the source
+ */
+ if (indir == 0) {
+ switch (type) {
+ case FILE_DER:
+ case FILE_SEARCH:
+ if (offset > nbytes)
+ offset = CAST(uint32_t, nbytes);
+ ms->search.s = RCAST(const char *, s) + offset;
+ ms->search.s_len = nbytes - offset;
+ ms->search.offset = offset;
+ return 0;
+
+ case FILE_REGEX: {
+ const char *b;
+ const char *c;
+ const char *last; /* end of search region */
+ const char *buf; /* start of search region */
+ const char *end;
+ size_t lines, linecnt, bytecnt;
+
+ if (s == NULL || nbytes < offset) {
+ ms->search.s_len = 0;
+ ms->search.s = NULL;
+ return 0;
+ }
+
+ if (m->str_flags & REGEX_LINE_COUNT) {
+ linecnt = m->str_range;
+ bytecnt = linecnt * 80;
+ } else {
+ linecnt = 0;
+ bytecnt = m->str_range;
+ }
+
+ if (bytecnt == 0 || bytecnt > nbytes - offset)
+ bytecnt = nbytes - offset;
+ if (bytecnt > ms->regex_max)
+ bytecnt = ms->regex_max;
+
+ buf = RCAST(const char *, s) + offset;
+ end = last = RCAST(const char *, s) + bytecnt + offset;
+ /* mget() guarantees buf <= last */
+ for (lines = linecnt, b = buf; lines && b < end &&
+ ((b = CAST(const char *,
+ memchr(c = b, '\n', CAST(size_t, (end - b)))))
+ || (b = CAST(const char *,
+ memchr(c, '\r', CAST(size_t, (end - c))))));
+ lines--, b++) {
+ last = b;
+ if (b < end - 1 && b[0] == '\r' && b[1] == '\n')
+ b++;
+ }
+ if (lines)
+ last = RCAST(const char *, s) + bytecnt;
+
+ ms->search.s = buf;
+ ms->search.s_len = last - buf;
+ ms->search.offset = offset;
+ ms->search.rm_len = 0;
+ return 0;
+ }
+ case FILE_BESTRING16:
+ case FILE_LESTRING16: {
+ const unsigned char *src = s + offset;
+ const unsigned char *esrc = s + nbytes;
+ char *dst = p->s;
+ char *edst = &p->s[sizeof(p->s) - 1];
+
+ if (type == FILE_BESTRING16)
+ src++;
+
+ /* check that offset is within range */
+ if (offset >= nbytes)
+ break;
+ for (/*EMPTY*/; src < esrc; src += 2, dst++) {
+ if (dst < edst)
+ *dst = *src;
+ else
+ break;
+ if (*dst == '\0') {
+ if (type == FILE_BESTRING16 ?
+ *(src - 1) != '\0' :
+ ((src + 1 < esrc) &&
+ *(src + 1) != '\0'))
+ *dst = ' ';
+ }
+ }
+ *edst = '\0';
+ return 0;
+ }
+ case FILE_STRING: /* XXX - these two should not need */
+ case FILE_PSTRING: /* to copy anything, but do anyway. */
+ default:
+ break;
+ }
+ }
+
+ if (offset >= nbytes) {
+ (void)memset(p, '\0', sizeof(*p));
+ return 0;
+ }
+ if (nbytes - offset < sizeof(*p))
+ nbytes = nbytes - offset;
+ else
+ nbytes = sizeof(*p);
+
+ (void)memcpy(p, s + offset, nbytes);
+
+ /*
+ * the usefulness of padding with zeroes eludes me, it
+ * might even cause problems
+ */
+ if (nbytes < sizeof(*p))
+ (void)memset(((char *)(void *)p) + nbytes, '\0',
+ sizeof(*p) - nbytes);
+ return 0;
+}
+
+private uint32_t
+do_ops(struct magic *m, intmax_t lhs, intmax_t off)
+{
+ intmax_t offset;
+ if (off) {
+ switch (m->in_op & FILE_OPS_MASK) {
+ case FILE_OPAND:
+ offset = lhs & off;
+ break;
+ case FILE_OPOR:
+ offset = lhs | off;
+ break;
+ case FILE_OPXOR:
+ offset = lhs ^ off;
+ break;
+ case FILE_OPADD:
+ offset = lhs + off;
+ break;
+ case FILE_OPMINUS:
+ offset = lhs - off;
+ break;
+ case FILE_OPMULTIPLY:
+ offset = lhs * off;
+ break;
+ case FILE_OPDIVIDE:
+ offset = lhs / off;
+ break;
+ case FILE_OPMODULO:
+ offset = lhs % off;
+ break;
+ }
+ } else
+ offset = lhs;
+ if (m->in_op & FILE_OPINVERSE)
+ offset = ~offset;
+
+ return (uint32_t)offset;
+}
+
+private int
+mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
+ size_t nbytes, size_t o, unsigned int cont_level, int mode, int text,
+ int flip, uint16_t *indir_count, uint16_t *name_count,
+ int *printed_something, int *need_separator, int *returnval)
+{
+ uint32_t offset = ms->offset;
+ intmax_t lhs;
+ file_pushbuf_t *pb;
+ int rv, oneed_separator, in_type;
+ char *rbuf;
+ union VALUETYPE *p = &ms->ms_value;
+ struct mlist ml;
+
+ if (*indir_count >= ms->indir_max) {
+ file_error(ms, 0, "indirect count (%hu) exceeded",
+ *indir_count);
+ return -1;
+ }
+
+ if (*name_count >= ms->name_max) {
+ file_error(ms, 0, "name use count (%hu) exceeded",
+ *name_count);
+ return -1;
+ }
+
+ if (mcopy(ms, p, m->type, m->flag & INDIR, s, (uint32_t)(offset + o),
+ (uint32_t)nbytes, m) == -1)
+ return -1;
+
+ if ((ms->flags & MAGIC_DEBUG) != 0) {
+ fprintf(stderr, "mget(type=%d, flag=%#x, offset=%u, o=%"
+ SIZE_T_FORMAT "u, " "nbytes=%" SIZE_T_FORMAT
+ "u, il=%hu, nc=%hu)\n",
+ m->type, m->flag, offset, o, nbytes,
+ *indir_count, *name_count);
+ mdebug(offset, (char *)(void *)p, sizeof(union VALUETYPE));
+#ifndef COMPILE_ONLY
+ file_mdump(m);
+#endif
+ }
+
+ if (m->flag & INDIR) {
+ intmax_t off = m->in_offset;
+ const int sgn = m->in_op & FILE_OPSIGNED;
+ if (m->in_op & FILE_OPINDIRECT) {
+ const union VALUETYPE *q = CAST(const union VALUETYPE *,
+ ((const void *)(s + offset + off)));
+ if (OFFSET_OOB(nbytes, offset + off, sizeof(*q)))
+ return 0;
+ switch (cvt_flip(m->in_type, flip)) {
+ case FILE_BYTE:
+ off = SEXT(sgn,8,q->b);
+ break;
+ case FILE_SHORT:
+ off = SEXT(sgn,16,q->h);
+ break;
+ case FILE_BESHORT:
+ off = SEXT(sgn,16,BE16(q));
+ break;
+ case FILE_LESHORT:
+ off = SEXT(sgn,16,LE16(q));
+ break;
+ case FILE_LONG:
+ off = SEXT(sgn,32,q->l);
+ break;
+ case FILE_BELONG:
+ case FILE_BEID3:
+ off = SEXT(sgn,32,BE32(q));
+ break;
+ case FILE_LEID3:
+ case FILE_LELONG:
+ off = SEXT(sgn,32,LE32(q));
+ break;
+ case FILE_MELONG:
+ off = SEXT(sgn,32,ME32(q));
+ break;
+ }
+ if ((ms->flags & MAGIC_DEBUG) != 0)
+ fprintf(stderr, "indirect offs=%jd\n", off);
+ }
+ switch (in_type = cvt_flip(m->in_type, flip)) {
+ case FILE_BYTE:
+ if (OFFSET_OOB(nbytes, offset, 1))
+ return 0;
+ offset = do_ops(m, SEXT(sgn,8,p->b), off);
+ break;
+ case FILE_BESHORT:
+ if (OFFSET_OOB(nbytes, offset, 2))
+ return 0;
+ offset = do_ops(m, SEXT(sgn,16,BE16(p)), off);
+ break;
+ case FILE_LESHORT:
+ if (OFFSET_OOB(nbytes, offset, 2))
+ return 0;
+ offset = do_ops(m, SEXT(sgn,16,LE16(p)), off);
+ break;
+ case FILE_SHORT:
+ if (OFFSET_OOB(nbytes, offset, 2))
+ return 0;
+ offset = do_ops(m, SEXT(sgn,16,p->h), off);
+ break;
+ case FILE_BELONG:
+ case FILE_BEID3:
+ if (OFFSET_OOB(nbytes, offset, 4))
+ return 0;
+ lhs = BE32(p);
+ if (in_type == FILE_BEID3)
+ lhs = cvt_id3(ms, (uint32_t)lhs);
+ offset = do_ops(m, SEXT(sgn,32,lhs), off);
+ break;
+ case FILE_LELONG:
+ case FILE_LEID3:
+ if (OFFSET_OOB(nbytes, offset, 4))
+ return 0;
+ lhs = LE32(p);
+ if (in_type == FILE_LEID3)
+ lhs = cvt_id3(ms, (uint32_t)lhs);
+ offset = do_ops(m, SEXT(sgn,32,lhs), off);
+ break;
+ case FILE_MELONG:
+ if (OFFSET_OOB(nbytes, offset, 4))
+ return 0;
+ offset = do_ops(m, SEXT(sgn,32,ME32(p)), off);
+ break;
+ case FILE_LONG:
+ if (OFFSET_OOB(nbytes, offset, 4))
+ return 0;
+ offset = do_ops(m, SEXT(sgn,32,p->l), off);
+ break;
+ default:
+ break;
+ }
+
+ if (m->flag & INDIROFFADD) {
+ offset += ms->c.li[cont_level-1].off;
+ if (offset == 0) {
+ if ((ms->flags & MAGIC_DEBUG) != 0)
+ fprintf(stderr,
+ "indirect *zero* offset\n");
+ return 0;
+ }
+ if ((ms->flags & MAGIC_DEBUG) != 0)
+ fprintf(stderr, "indirect +offs=%u\n", offset);
+ }
+ if (mcopy(ms, p, m->type, 0, s, offset, nbytes, m) == -1)
+ return -1;
+ ms->offset = offset;
+
+ if ((ms->flags & MAGIC_DEBUG) != 0) {
+ mdebug(offset, (char *)(void *)p,
+ sizeof(union VALUETYPE));
+#ifndef COMPILE_ONLY
+ file_mdump(m);
+#endif
+ }
+ }
+
+ /* Verify we have enough data to match magic type */
+ switch (m->type) {
+ case FILE_BYTE:
+ if (OFFSET_OOB(nbytes, offset, 1))
+ return 0;
+ break;
+
+ case FILE_SHORT:
+ case FILE_BESHORT:
+ case FILE_LESHORT:
+ if (OFFSET_OOB(nbytes, offset, 2))
+ return 0;
+ break;
+
+ case FILE_LONG:
+ case FILE_BELONG:
+ case FILE_LELONG:
+ case FILE_MELONG:
+ case FILE_DATE:
+ case FILE_BEDATE:
+ case FILE_LEDATE:
+ case FILE_MEDATE:
+ case FILE_LDATE:
+ case FILE_BELDATE:
+ case FILE_LELDATE:
+ case FILE_MELDATE:
+ case FILE_FLOAT:
+ case FILE_BEFLOAT:
+ case FILE_LEFLOAT:
+ if (OFFSET_OOB(nbytes, offset, 4))
+ return 0;
+ break;
+
+ case FILE_DOUBLE:
+ case FILE_BEDOUBLE:
+ case FILE_LEDOUBLE:
+ if (OFFSET_OOB(nbytes, offset, 8))
+ return 0;
+ break;
+
+ case FILE_STRING:
+ case FILE_PSTRING:
+ case FILE_SEARCH:
+ if (OFFSET_OOB(nbytes, offset, m->vallen))
+ return 0;
+ break;
+
+ case FILE_REGEX:
+ if (nbytes < offset)
+ return 0;
+ break;
+
+ case FILE_INDIRECT:
+ if (m->str_flags & INDIRECT_RELATIVE)
+ offset += CAST(uint32_t, o);
+ if (offset == 0)
+ return 0;
+
+ if (nbytes < offset)
+ return 0;
+
+ if ((pb = file_push_buffer(ms)) == NULL)
+ return -1;
+
+ (*indir_count)++;
+ rv = file_softmagic(ms, s + offset, nbytes - offset,
+ indir_count, name_count, BINTEST, text);
+
+ if ((ms->flags & MAGIC_DEBUG) != 0)
+ fprintf(stderr, "indirect @offs=%u[%d]\n", offset, rv);
+
+ rbuf = file_pop_buffer(ms, pb);
+ if (rbuf == NULL && ms->event_flags & EVENT_HAD_ERR)
+ return -1;
+
+ if (rv == 1) {
+ if ((ms->flags & MAGIC_NODESC) == 0 &&
+ file_printf(ms, F(ms, m, "%u"), offset) == -1) {
+ free(rbuf);
+ return -1;
+ }
+ if (file_printf(ms, "%s", rbuf) == -1) {
+ free(rbuf);
+ return -1;
+ }
+ }
+ free(rbuf);
+ return rv;
+
+ case FILE_USE:
+ if (nbytes < offset)
+ return 0;
+ rbuf = m->value.s;
+ if (*rbuf == '^') {
+ rbuf++;
+ flip = !flip;
+ }
+ if (file_magicfind(ms, rbuf, &ml) == -1) {
+ file_error(ms, 0, "cannot find entry `%s'", rbuf);
+ return -1;
+ }
+ (*name_count)++;
+ oneed_separator = *need_separator;
+ if (m->flag & NOSPACE)
+ *need_separator = 0;
+ rv = match(ms, ml.magic, ml.nmagic, s, nbytes, offset + o,
+ mode, text, flip, indir_count, name_count,
+ printed_something, need_separator, returnval);
+ if (rv != 1)
+ *need_separator = oneed_separator;
+ return 1;
+
+ case FILE_NAME:
+ if (ms->flags & MAGIC_NODESC)
+ return 1;
+ if (file_printf(ms, "%s", m->desc) == -1)
+ return -1;
+ return 1;
+ case FILE_DER:
+ case FILE_DEFAULT: /* nothing to check */
+ case FILE_CLEAR:
+ default:
+ break;
+ }
+ if (!mconvert(ms, m, flip))
+ return 0;
+ return 1;
+}
+
+private uint64_t
+file_strncmp(const char *s1, const char *s2, size_t len, uint32_t flags)
+{
+ /*
+ * Convert the source args to unsigned here so that (1) the
+ * compare will be unsigned as it is in strncmp() and (2) so
+ * the ctype functions will work correctly without extra
+ * casting.
+ */
+ const unsigned char *a = (const unsigned char *)s1;
+ const unsigned char *b = (const unsigned char *)s2;
+ const unsigned char *eb = b + len;
+ uint64_t v;
+
+ /*
+ * What we want here is v = strncmp(s1, s2, len),
+ * but ignoring any nulls.
+ */
+ v = 0;
+ if (0L == flags) { /* normal string: do it fast */
+ while (len-- > 0)
+ if ((v = *b++ - *a++) != '\0')
+ break;
+ }
+ else { /* combine the others */
+ while (len-- > 0) {
+ if (b >= eb) {
+ v = 1;
+ break;
+ }
+ if ((flags & STRING_IGNORE_LOWERCASE) &&
+ islower(*a)) {
+ if ((v = tolower(*b++) - *a++) != '\0')
+ break;
+ }
+ else if ((flags & STRING_IGNORE_UPPERCASE) &&
+ isupper(*a)) {
+ if ((v = toupper(*b++) - *a++) != '\0')
+ break;
+ }
+ else if ((flags & STRING_COMPACT_WHITESPACE) &&
+ isspace(*a)) {
+ a++;
+ if (isspace(*b++)) {
+ if (!isspace(*a))
+ while (b < eb && isspace(*b))
+ b++;
+ }
+ else {
+ v = 1;
+ break;
+ }
+ }
+ else if ((flags & STRING_COMPACT_OPTIONAL_WHITESPACE) &&
+ isspace(*a)) {
+ a++;
+ while (b < eb && isspace(*b))
+ b++;
+ }
+ else {
+ if ((v = *b++ - *a++) != '\0')
+ break;
+ }
+ }
+ }
+ return v;
+}
+
+private uint64_t
+file_strncmp16(const char *a, const char *b, size_t len, uint32_t flags)
+{
+ /*
+ * XXX - The 16-bit string compare probably needs to be done
+ * differently, especially if the flags are to be supported.
+ * At the moment, I am unsure.
+ */
+ flags = 0;
+ return file_strncmp(a, b, len, flags);
+}
+
+private int
+magiccheck(struct magic_set *ms, struct magic *m)
+{
+ uint64_t l = m->value.q;
+ uint64_t v;
+ float fl, fv;
+ double dl, dv;
+ int matched;
+ union VALUETYPE *p = &ms->ms_value;
+
+ switch (m->type) {
+ case FILE_BYTE:
+ v = p->b;
+ break;
+
+ case FILE_SHORT:
+ case FILE_BESHORT:
+ case FILE_LESHORT:
+ v = p->h;
+ break;
+
+ case FILE_LONG:
+ case FILE_BELONG:
+ case FILE_LELONG:
+ case FILE_MELONG:
+ case FILE_DATE:
+ case FILE_BEDATE:
+ case FILE_LEDATE:
+ case FILE_MEDATE:
+ case FILE_LDATE:
+ case FILE_BELDATE:
+ case FILE_LELDATE:
+ case FILE_MELDATE:
+ v = p->l;
+ break;
+
+ case FILE_QUAD:
+ case FILE_LEQUAD:
+ case FILE_BEQUAD:
+ case FILE_QDATE:
+ case FILE_BEQDATE:
+ case FILE_LEQDATE:
+ case FILE_QLDATE:
+ case FILE_BEQLDATE:
+ case FILE_LEQLDATE:
+ case FILE_QWDATE:
+ case FILE_BEQWDATE:
+ case FILE_LEQWDATE:
+ v = p->q;
+ break;
+
+ case FILE_FLOAT:
+ case FILE_BEFLOAT:
+ case FILE_LEFLOAT:
+ fl = m->value.f;
+ fv = p->f;
+ switch (m->reln) {
+ case 'x':
+ matched = 1;
+ break;
+
+ case '!':
+ matched = fv != fl;
+ break;
+
+ case '=':
+ matched = fv == fl;
+ break;
+
+ case '>':
+ matched = fv > fl;
+ break;
+
+ case '<':
+ matched = fv < fl;
+ break;
+
+ default:
+ file_magerror(ms, "cannot happen with float: invalid relation `%c'",
+ m->reln);
+ return -1;
+ }
+ return matched;
+
+ case FILE_DOUBLE:
+ case FILE_BEDOUBLE:
+ case FILE_LEDOUBLE:
+ dl = m->value.d;
+ dv = p->d;
+ switch (m->reln) {
+ case 'x':
+ matched = 1;
+ break;
+
+ case '!':
+ matched = dv != dl;
+ break;
+
+ case '=':
+ matched = dv == dl;
+ break;
+
+ case '>':
+ matched = dv > dl;
+ break;
+
+ case '<':
+ matched = dv < dl;
+ break;
+
+ default:
+ file_magerror(ms, "cannot happen with double: invalid relation `%c'", m->reln);
+ return -1;
+ }
+ return matched;
+
+ case FILE_DEFAULT:
+ case FILE_CLEAR:
+ l = 0;
+ v = 0;
+ break;
+
+ case FILE_STRING:
+ case FILE_PSTRING:
+ l = 0;
+ v = file_strncmp(m->value.s, p->s, (size_t)m->vallen, m->str_flags);
+ break;
+
+ case FILE_BESTRING16:
+ case FILE_LESTRING16:
+ l = 0;
+ v = file_strncmp16(m->value.s, p->s, (size_t)m->vallen, m->str_flags);
+ break;
+
+ case FILE_SEARCH: { /* search ms->search.s for the string m->value.s */
+ size_t slen;
+ size_t idx;
+
+ if (ms->search.s == NULL)
+ return 0;
+
+ slen = MIN(m->vallen, sizeof(m->value.s));
+ l = 0;
+ v = 0;
+
+ for (idx = 0; m->str_range == 0 || idx < m->str_range; idx++) {
+ if (slen + idx > ms->search.s_len)
+ return 0;
+
+ v = file_strncmp(m->value.s, ms->search.s + idx, slen,
+ m->str_flags);
+ if (v == 0) { /* found match */
+ ms->search.offset += idx;
+ ms->search.rm_len = ms->search.s_len - idx;
+ break;
+ }
+ }
+ break;
+ }
+ case FILE_REGEX: {
+ int rc;
+ file_regex_t rx;
+ const char *search;
+
+ if (ms->search.s == NULL)
+ return 0;
+
+ l = 0;
+ rc = file_regcomp(&rx, m->value.s,
+ REG_EXTENDED|REG_NEWLINE|
+ ((m->str_flags & STRING_IGNORE_CASE) ? REG_ICASE : 0));
+ if (rc) {
+ file_regerror(&rx, rc, ms);
+ v = (uint64_t)-1;
+ } else {
+ regmatch_t pmatch;
+ size_t slen = ms->search.s_len;
+ char *copy;
+ if (slen != 0) {
+ copy = CAST(char *, malloc(slen));
+ if (copy == NULL) {
+ file_regfree(&rx);
+ file_error(ms, errno,
+ "can't allocate %" SIZE_T_FORMAT "u bytes",
+ slen);
+ return -1;
+ }
+ memcpy(copy, ms->search.s, slen);
+ copy[--slen] = '\0';
+ search = copy;
+ } else {
+ search = CCAST(char *, "");
+ copy = NULL;
+ }
+ rc = file_regexec(&rx, (const char *)search,
+ 1, &pmatch, 0);
+ free(copy);
+ switch (rc) {
+ case 0:
+ ms->search.s += (int)pmatch.rm_so;
+ ms->search.offset += (size_t)pmatch.rm_so;
+ ms->search.rm_len =
+ (size_t)(pmatch.rm_eo - pmatch.rm_so);
+ v = 0;
+ break;
+
+ case REG_NOMATCH:
+ v = 1;
+ break;
+
+ default:
+ file_regerror(&rx, rc, ms);
+ v = (uint64_t)-1;
+ break;
+ }
+ }
+ file_regfree(&rx);
+ if (v == (uint64_t)-1)
+ return -1;
+ break;
+ }
+ case FILE_INDIRECT:
+ case FILE_USE:
+ case FILE_NAME:
+ return 1;
+ case FILE_DER:
+ matched = der_cmp(ms, m);
+ if (matched == -1) {
+ if ((ms->flags & MAGIC_DEBUG) != 0) {
+ (void) fprintf(stderr,
+ "EOF comparing DER entries");
+ }
+ return 0;
+ }
+ return matched;
+ default:
+ file_magerror(ms, "invalid type %d in magiccheck()", m->type);
+ return -1;
+ }
+
+ v = file_signextend(ms, m, v);
+
+ switch (m->reln) {
+ case 'x':
+ if ((ms->flags & MAGIC_DEBUG) != 0)
+ (void) fprintf(stderr, "%" INT64_T_FORMAT
+ "u == *any* = 1\n", (unsigned long long)v);
+ matched = 1;
+ break;
+
+ case '!':
+ matched = v != l;
+ if ((ms->flags & MAGIC_DEBUG) != 0)
+ (void) fprintf(stderr, "%" INT64_T_FORMAT "u != %"
+ INT64_T_FORMAT "u = %d\n", (unsigned long long)v,
+ (unsigned long long)l, matched);
+ break;
+
+ case '=':
+ matched = v == l;
+ if ((ms->flags & MAGIC_DEBUG) != 0)
+ (void) fprintf(stderr, "%" INT64_T_FORMAT "u == %"
+ INT64_T_FORMAT "u = %d\n", (unsigned long long)v,
+ (unsigned long long)l, matched);
+ break;
+
+ case '>':
+ if (m->flag & UNSIGNED) {
+ matched = v > l;
+ if ((ms->flags & MAGIC_DEBUG) != 0)
+ (void) fprintf(stderr, "%" INT64_T_FORMAT
+ "u > %" INT64_T_FORMAT "u = %d\n",
+ (unsigned long long)v,
+ (unsigned long long)l, matched);
+ }
+ else {
+ matched = (int64_t) v > (int64_t) l;
+ if ((ms->flags & MAGIC_DEBUG) != 0)
+ (void) fprintf(stderr, "%" INT64_T_FORMAT
+ "d > %" INT64_T_FORMAT "d = %d\n",
+ (long long)v, (long long)l, matched);
+ }
+ break;
+
+ case '<':
+ if (m->flag & UNSIGNED) {
+ matched = v < l;
+ if ((ms->flags & MAGIC_DEBUG) != 0)
+ (void) fprintf(stderr, "%" INT64_T_FORMAT
+ "u < %" INT64_T_FORMAT "u = %d\n",
+ (unsigned long long)v,
+ (unsigned long long)l, matched);
+ }
+ else {
+ matched = (int64_t) v < (int64_t) l;
+ if ((ms->flags & MAGIC_DEBUG) != 0)
+ (void) fprintf(stderr, "%" INT64_T_FORMAT
+ "d < %" INT64_T_FORMAT "d = %d\n",
+ (long long)v, (long long)l, matched);
+ }
+ break;
+
+ case '&':
+ matched = (v & l) == l;
+ if ((ms->flags & MAGIC_DEBUG) != 0)
+ (void) fprintf(stderr, "((%" INT64_T_FORMAT "x & %"
+ INT64_T_FORMAT "x) == %" INT64_T_FORMAT
+ "x) = %d\n", (unsigned long long)v,
+ (unsigned long long)l, (unsigned long long)l,
+ matched);
+ break;
+
+ case '^':
+ matched = (v & l) != l;
+ if ((ms->flags & MAGIC_DEBUG) != 0)
+ (void) fprintf(stderr, "((%" INT64_T_FORMAT "x & %"
+ INT64_T_FORMAT "x) != %" INT64_T_FORMAT
+ "x) = %d\n", (unsigned long long)v,
+ (unsigned long long)l, (unsigned long long)l,
+ matched);
+ break;
+
+ default:
+ file_magerror(ms, "cannot happen: invalid relation `%c'",
+ m->reln);
+ return -1;
+ }
+
+ return matched;
+}
+
+private int
+handle_annotation(struct magic_set *ms, struct magic *m, int firstline)
+{
+ if ((ms->flags & MAGIC_APPLE) && m->apple[0]) {
+ if (!firstline && file_printf(ms, "\n- ") == -1)
+ return -1;
+ if (file_printf(ms, "%.8s", m->apple) == -1)
+ return -1;
+ return 1;
+ }
+ if ((ms->flags & MAGIC_EXTENSION) && m->ext[0]) {
+ if (!firstline && file_printf(ms, "\n- ") == -1)
+ return -1;
+ if (file_printf(ms, "%s", m->ext) == -1)
+ return -1;
+ return 1;
+ }
+ if ((ms->flags & MAGIC_MIME_TYPE) && m->mimetype[0]) {
+ if (!firstline && file_printf(ms, "\n- ") == -1)
+ return -1;
+ if (file_printf(ms, "%s", m->mimetype) == -1)
+ return -1;
+ return 1;
+ }
+ return 0;
+}
+
+private int
+print_sep(struct magic_set *ms, int firstline)
+{
+// if (ms->flags & MAGIC_NODESC)
+// return 0;
+ if (firstline)
+ return 0;
+ /*
+ * we found another match
+ * put a newline and '-' to do some simple formatting
+ */
+ return file_printf(ms, "\n- ");
+}
diff --git a/node_modules/mmmagic/deps/libmagic/src/strcasestr.c b/node_modules/mmmagic/deps/libmagic/src/strcasestr.c
new file mode 100644
index 0000000..3db407f
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/strcasestr.c
@@ -0,0 +1,84 @@
+/* $NetBSD: strcasestr.c,v 1.3 2005/11/29 03:12:00 christos Exp $ */
+
+/*-
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: strcasestr.c,v 1.3 2005/11/29 03:12:00 christos Exp $");
+__RCSID("$NetBSD: strncasecmp.c,v 1.2 2007/06/04 18:19:27 christos Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include "file.h"
+
+#include <assert.h>
+#include <ctype.h>
+#include <string.h>
+
+static int
+_strncasecmp(const char *s1, const char *s2, size_t n)
+{
+ if (n != 0) {
+ const unsigned char *us1 = (const unsigned char *)s1,
+ *us2 = (const unsigned char *)s2;
+
+ do {
+ if (tolower(*us1) != tolower(*us2++))
+ return tolower(*us1) - tolower(*--us2);
+ if (*us1++ == '\0')
+ break;
+ } while (--n != 0);
+ }
+ return 0;
+}
+
+/*
+ * Find the first occurrence of find in s, ignore case.
+ */
+char *
+strcasestr(const char *s, const char *find)
+{
+ char c, sc;
+ size_t len;
+
+ if ((c = *find++) != 0) {
+ c = tolower((unsigned char)c);
+ len = strlen(find);
+ do {
+ do {
+ if ((sc = *s++) == 0)
+ return (NULL);
+ } while ((char)tolower((unsigned char)sc) != c);
+ } while (_strncasecmp(s, find, len) != 0);
+ s--;
+ }
+ return (char *)(intptr_t)(s);
+}
diff --git a/node_modules/mmmagic/deps/libmagic/src/strlcat.c b/node_modules/mmmagic/deps/libmagic/src/strlcat.c
new file mode 100644
index 0000000..9692bc1
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/strlcat.c
@@ -0,0 +1,58 @@
+/* $OpenBSD: strlcat.c,v 1.13 2005/08/08 08:05:37 espie Exp $ */
+
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* OPENBSD ORIGINAL: lib/libc/string/strlcat.c */
+#include "file.h"
+
+#include <sys/types.h>
+#include <string.h>
+
+/*
+ * Appends src to string dst of size siz (unlike strncat, siz is the
+ * full size of dst, not space left). At most siz-1 characters
+ * will be copied. Always NUL terminates (unless siz <= strlen(dst)).
+ * Returns strlen(src) + MIN(siz, strlen(initial dst)).
+ * If retval >= siz, truncation occurred.
+ */
+size_t
+strlcat(char *dst, const char *src, size_t siz)
+{
+ char *d = dst;
+ const char *s = src;
+ size_t n = siz;
+ size_t dlen;
+
+ /* Find the end of dst and adjust bytes left but don't go past end */
+ while (n-- != 0 && *d != '\0')
+ d++;
+ dlen = d - dst;
+ n = siz - dlen;
+
+ if (n == 0)
+ return(dlen + strlen(s));
+ while (*s != '\0') {
+ if (n != 1) {
+ *d++ = *s;
+ n--;
+ }
+ s++;
+ }
+ *d = '\0';
+
+ return(dlen + (s - src)); /* count does not include NUL */
+}
diff --git a/node_modules/mmmagic/deps/libmagic/src/strlcpy.c b/node_modules/mmmagic/deps/libmagic/src/strlcpy.c
new file mode 100644
index 0000000..992501c
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/strlcpy.c
@@ -0,0 +1,54 @@
+/* $OpenBSD: strlcpy.c,v 1.10 2005/08/08 08:05:37 espie Exp $ */
+
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* OPENBSD ORIGINAL: lib/libc/string/strlcpy.c */
+#include "file.h"
+
+#include <sys/types.h>
+#include <string.h>
+
+/*
+ * Copy src to string dst of size siz. At most siz-1 characters
+ * will be copied. Always NUL terminates (unless siz == 0).
+ * Returns strlen(src); if retval >= siz, truncation occurred.
+ */
+size_t
+strlcpy(char *dst, const char *src, size_t siz)
+{
+ char *d = dst;
+ const char *s = src;
+ size_t n = siz;
+
+ /* Copy as many bytes as will fit */
+ if (n != 0 && --n != 0) {
+ do {
+ if ((*d++ = *s++) == 0)
+ break;
+ } while (--n != 0);
+ }
+
+ /* Not enough room in dst, add NUL and traverse rest of src */
+ if (n == 0) {
+ if (siz != 0)
+ *d = '\0'; /* NUL-terminate dst */
+ while (*s++)
+ ;
+ }
+
+ return(s - src - 1); /* count does not include NUL */
+}
diff --git a/node_modules/mmmagic/deps/libmagic/src/tar.h b/node_modules/mmmagic/deps/libmagic/src/tar.h
new file mode 100644
index 0000000..854d455
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/tar.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) Ian F. Darwin 1986-1995.
+ * Software written by Ian F. Darwin and others;
+ * maintained 1995-present by Christos Zoulas and others.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice immediately at the beginning of the file, without modification,
+ * this list of conditions, and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+/*
+ * Header file for public domain tar (tape archive) program.
+ *
+ * @(#)tar.h 1.20 86/10/29 Public Domain.
+ *
+ * Created 25 August 1985 by John Gilmore, ihnp4!hoptoad!gnu.
+ *
+ * $File: tar.h,v 1.13 2010/11/30 14:58:53 rrt Exp $ # checkin only
+ */
+
+/*
+ * Header block on tape.
+ *
+ * I'm going to use traditional DP naming conventions here.
+ * A "block" is a big chunk of stuff that we do I/O on.
+ * A "record" is a piece of info that we care about.
+ * Typically many "record"s fit into a "block".
+ */
+#define RECORDSIZE 512
+#define NAMSIZ 100
+#define TUNMLEN 32
+#define TGNMLEN 32
+
+union record {
+ unsigned char charptr[RECORDSIZE];
+ struct header {
+ char name[NAMSIZ];
+ char mode[8];
+ char uid[8];
+ char gid[8];
+ char size[12];
+ char mtime[12];
+ char chksum[8];
+ char linkflag;
+ char linkname[NAMSIZ];
+ char magic[8];
+ char uname[TUNMLEN];
+ char gname[TGNMLEN];
+ char devmajor[8];
+ char devminor[8];
+ } header;
+};
+
+/* The magic field is filled with this if uname and gname are valid. */
+#define TMAGIC "ustar" /* 5 chars and a null */
+#define GNUTMAGIC "ustar " /* 7 chars and a null */
diff --git a/node_modules/mmmagic/deps/libmagic/src/vasprintf.c b/node_modules/mmmagic/deps/libmagic/src/vasprintf.c
new file mode 100644
index 0000000..9548fd8
--- /dev/null
+++ b/node_modules/mmmagic/deps/libmagic/src/vasprintf.c
@@ -0,0 +1,27 @@
+// XXX: change by mscdex
+// from mingw-w64-crt project
+
+#include <errno.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+int vasprintf(char ** ret, const char * format, va_list ap) {
+ int len;
+ /* Get Length */
+ len = _vsnprintf(NULL, 0, format, ap);
+ if (len < 0)
+ return -1;
+ /* +1 for \0 terminator. */
+ *ret = malloc(len + 1);
+ /* Check malloc fail*/
+ if (!*ret) {
+ errno = ENOMEM;
+ return -1;
+ }
+ /* Write String */
+ _vsnprintf(*ret, len + 1, format, ap);
+ /* Terminate explicitly */
+ (*ret)[len] = '\0';
+ return len;
+}
diff --git a/node_modules/mmmagic/lib/index.js b/node_modules/mmmagic/lib/index.js
new file mode 100644
index 0000000..bd18a4b
--- /dev/null
+++ b/node_modules/mmmagic/lib/index.js
@@ -0,0 +1,28 @@
+var Magic = require('../build/Release/magic');
+var fbpath = require('path').join(__dirname, '..', 'magic', 'magic');
+Magic.setFallback(fbpath);
+
+module.exports = {
+ Magic: Magic.Magic,
+ MAGIC_NONE: 0x000000, /* No flags (default for Windows) */
+ MAGIC_DEBUG: 0x000001, /* Turn on debugging */
+ MAGIC_SYMLINK: 0x000002, /* Follow symlinks (default for *nix) */
+ MAGIC_DEVICES: 0x000008, /* Look at the contents of devices */
+ MAGIC_MIME_TYPE: 0x000010, /* Return the MIME type */
+ MAGIC_CONTINUE: 0x000020, /* Return all matches */
+ MAGIC_CHECK: 0x000040, /* Print warnings to stderr */
+ MAGIC_PRESERVE_ATIME: 0x000080, /* Restore access time on exit */
+ MAGIC_RAW: 0x000100, /* Don't translate unprintable chars */
+ MAGIC_MIME_ENCODING: 0x000400, /* Return the MIME encoding */
+ MAGIC_MIME: (0x000010|0x000400), /*(MAGIC_MIME_TYPE|MAGIC_MIME_ENCODING)*/
+ MAGIC_APPLE: 0x000800, /* Return the Apple creator and type */
+
+ MAGIC_NO_CHECK_TAR: 0x002000, /* Don't check for tar files */
+ MAGIC_NO_CHECK_SOFT: 0x004000, /* Don't check magic entries */
+ MAGIC_NO_CHECK_APPTYPE: 0x008000, /* Don't check application type */
+ MAGIC_NO_CHECK_ELF: 0x010000, /* Don't check for elf details */
+ MAGIC_NO_CHECK_TEXT: 0x020000, /* Don't check for text files */
+ MAGIC_NO_CHECK_CDF: 0x040000, /* Don't check for cdf files */
+ MAGIC_NO_CHECK_TOKENS: 0x100000, /* Don't check tokens */
+ MAGIC_NO_CHECK_ENCODING: 0x200000 /* Don't check text encodings */
+};
diff --git a/node_modules/mmmagic/magic/magic.mgc b/node_modules/mmmagic/magic/magic.mgc
new file mode 100644
index 0000000..2fdc46d
--- /dev/null
+++ b/node_modules/mmmagic/magic/magic.mgc
Binary files differ
diff --git a/node_modules/mmmagic/package.json b/node_modules/mmmagic/package.json
new file mode 100644
index 0000000..68a8afa
--- /dev/null
+++ b/node_modules/mmmagic/package.json
@@ -0,0 +1,35 @@
+{
+ "name": "mmmagic",
+ "version": "0.5.3",
+ "author": "Brian White <mscdex@mscdex.net>",
+ "description": "An async libmagic binding for node.js for detecting content types by data inspection",
+ "main": "./lib/index",
+ "dependencies": {
+ "nan": "^2.13.2"
+ },
+ "scripts": {
+ "install": "node-gyp rebuild",
+ "test": "node test/test.js"
+ },
+ "engines": {
+ "node": ">=4.0.0"
+ },
+ "keywords": [
+ "magic",
+ "libmagic",
+ "file",
+ "filetype",
+ "mime",
+ "mimetype"
+ ],
+ "licenses": [
+ {
+ "type": "MIT",
+ "url": "http://github.com/mscdex/mmmagic/raw/master/LICENSE"
+ }
+ ],
+ "repository": {
+ "type": "git",
+ "url": "http://github.com/mscdex/mmmagic.git"
+ }
+}
diff --git a/node_modules/mmmagic/src/binding.cc b/node_modules/mmmagic/src/binding.cc
new file mode 100644
index 0000000..8f97da0
--- /dev/null
+++ b/node_modules/mmmagic/src/binding.cc
@@ -0,0 +1,416 @@
+#include <node.h>
+#include <node_buffer.h>
+#include <nan.h>
+#include <string.h>
+#include <stdlib.h>
+
+#ifdef _WIN32
+# include <io.h>
+# include <fcntl.h>
+# include <wchar.h>
+#endif
+
+#include "magic.h"
+
+using namespace node;
+using namespace v8;
+
+class DetectRequest : public Nan::AsyncResource {
+public:
+ DetectRequest(Local<Function> callback_, const char* magic_source_,
+ size_t source_len_, bool source_is_path_, int flags_)
+ : Nan::AsyncResource("mmmagic:DetectRequest"),
+ magic_source(magic_source_),
+ source_len(source_len_),
+ source_is_path(source_is_path_),
+ flags(flags_) {
+ callback.Reset(callback_);
+
+ request.data = this;
+ free_error = true;
+ error_message = nullptr;
+ result = nullptr;
+ }
+
+ ~DetectRequest() {
+ callback.Reset();
+ data_buffer.Reset();
+ if (data_is_path)
+ free(data);
+ if (free_error)
+ free(error_message);
+ free((void*)result);
+ }
+
+ uv_work_t request;
+ Nan::Persistent<Function> callback;
+
+ char* data;
+ size_t data_len;
+ bool data_is_path;
+ Nan::Persistent<Object> data_buffer;
+
+ // libmagic info
+ const char* magic_source;
+ size_t source_len;
+ bool source_is_path;
+ int flags;
+
+ bool free_error;
+ char* error_message;
+
+ const char* result;
+};
+
+static Nan::Persistent<Function> constructor;
+static const char* fallbackPath;
+
+class Magic : public ObjectWrap {
+public:
+ Nan::Persistent<Object> mgc_buffer;
+ size_t mgc_buffer_len;
+ const char* msource;
+ int mflags;
+
+ Magic(const char* path, int flags) {
+ if (path != nullptr) {
+ /* Windows blows up trying to look up the path '(null)' returned by
+ magic_getpath() */
+ if (strncmp(path, "(null)", 6) == 0)
+ path = nullptr;
+ }
+ msource = (path == nullptr ? strdup(fallbackPath) : path);
+
+ // When returning multiple matches, MAGIC_RAW needs to be set so that we
+ // can more easily parse the output into an array for the end user
+ if (flags & MAGIC_CONTINUE)
+ flags |= MAGIC_RAW;
+
+ mflags = flags;
+ }
+
+ Magic(Local<Object> buffer, int flags) {
+ mgc_buffer.Reset(buffer);
+ mgc_buffer_len = Buffer::Length(buffer);
+ msource = Buffer::Data(buffer);
+
+ // When returning multiple matches, MAGIC_RAW needs to be set so that we
+ // can more easily parse the output into an array for the end user
+ if (flags & MAGIC_CONTINUE)
+ flags |= MAGIC_RAW;
+
+ mflags = flags;
+ }
+
+ ~Magic() {
+ if (!mgc_buffer.IsEmpty())
+ mgc_buffer.Reset();
+ else if (msource != nullptr)
+ free((void*)msource);
+ msource = nullptr;
+ }
+
+ static void New(const Nan::FunctionCallbackInfo<v8::Value>& args) {
+ Nan::HandleScope();
+#ifndef _WIN32
+ int magic_flags = MAGIC_SYMLINK;
+#else
+ int magic_flags = MAGIC_NONE;
+#endif
+ Magic* obj;
+
+ if (!args.IsConstructCall())
+ return Nan::ThrowTypeError("Use `new` to create instances of this object.");
+
+ if (args.Length() > 1) {
+ if (args[1]->IsInt32())
+ magic_flags = Nan::To<int32_t>(args[1]).FromJust();
+ else
+ return Nan::ThrowTypeError("Second argument must be an integer");
+ }
+
+ if (args.Length() > 0) {
+ if (args[0]->IsString()) {
+ Nan::Utf8String str(args[0]);
+ char* path = strdup((const char*)(*str));
+ obj = new Magic(path, magic_flags);
+ } else if (Buffer::HasInstance(args[0])) {
+ obj = new Magic(args[0].As<Object>(), magic_flags);
+ } else if (args[0]->IsInt32()) {
+ magic_flags = Nan::To<int32_t>(args[0]).FromJust();
+ obj = new Magic(nullptr, magic_flags);
+ } else if (args[0]->IsBoolean() && !Nan::To<bool>(args[0]).FromJust()) {
+ char* path = strdup(magic_getpath(nullptr, 0/*FILE_LOAD*/));
+ obj = new Magic(path, magic_flags);
+ } else {
+ return Nan::ThrowTypeError(
+ "First argument must be a string, Buffer, or integer"
+ );
+ }
+ } else {
+ obj = new Magic(nullptr, magic_flags);
+ }
+
+ obj->Wrap(args.This());
+ obj->Ref();
+
+ return args.GetReturnValue().Set(args.This());
+ }
+
+ static void DetectFile(const Nan::FunctionCallbackInfo<v8::Value>& args) {
+ Nan::HandleScope();
+ Magic* obj = ObjectWrap::Unwrap<Magic>(args.This());
+
+ if (!args[0]->IsString())
+ return Nan::ThrowTypeError("First argument must be a string");
+ if (!args[1]->IsFunction())
+ return Nan::ThrowTypeError("Second argument must be a callback function");
+
+ Local<Function> callback = Local<Function>::Cast(args[1]);
+
+ Nan::Utf8String str(args[0]);
+
+ DetectRequest* detect_req = new DetectRequest(callback,
+ obj->msource,
+ obj->mgc_buffer_len,
+ obj->mgc_buffer.IsEmpty(),
+ obj->mflags);
+ detect_req->data = strdup((const char*)*str);
+ detect_req->data_is_path = true;
+
+ int status = uv_queue_work(uv_default_loop(),
+ &detect_req->request,
+ Magic::DetectWork,
+ (uv_after_work_cb)Magic::DetectAfter);
+ assert(status == 0);
+
+ args.GetReturnValue().Set(Nan::Undefined());
+ }
+
+ static void Detect(const Nan::FunctionCallbackInfo<v8::Value>& args) {
+ Nan::HandleScope();
+ Magic* obj = ObjectWrap::Unwrap<Magic>(args.This());
+
+ if (args.Length() < 2)
+ return Nan::ThrowTypeError("Expecting 2 arguments");
+ if (!Buffer::HasInstance(args[0]))
+ return Nan::ThrowTypeError("First argument must be a Buffer");
+ if (!args[1]->IsFunction())
+ return Nan::ThrowTypeError("Second argument must be a callback function");
+
+ Local<Function> callback = Local<Function>::Cast(args[1]);
+ Local<Object> buffer_obj = args[0].As<Object>();
+
+ DetectRequest* detect_req = new DetectRequest(callback,
+ obj->msource,
+ obj->mgc_buffer_len,
+ obj->mgc_buffer.IsEmpty(),
+ obj->mflags);
+ detect_req->data = Buffer::Data(buffer_obj);
+ detect_req->data_len = Buffer::Length(buffer_obj);
+ detect_req->data_buffer.Reset(buffer_obj);
+ detect_req->data_is_path = false;
+
+ int status = uv_queue_work(uv_default_loop(),
+ &detect_req->request,
+ Magic::DetectWork,
+ (uv_after_work_cb)Magic::DetectAfter);
+ assert(status == 0);
+
+ return args.GetReturnValue().Set(args.This());
+ }
+
+ static void DetectWork(uv_work_t* req) {
+ DetectRequest* detect_req = static_cast<DetectRequest*>(req->data);
+ const char* result;
+ struct magic_set* magic = magic_open(detect_req->flags
+ | MAGIC_NO_CHECK_COMPRESS
+ | MAGIC_ERROR);
+
+ if (magic == nullptr) {
+#if NODE_MODULE_VERSION <= 0x000B
+ detect_req->error_message =
+ strdup(uv_strerror(uv_last_error(uv_default_loop())));
+#else
+// XXX libuv 1.x currently has no public cross-platform function to convert an
+// OS-specific error number to a libuv error number. `-errno` should work
+// for *nix, but just passing GetLastError() on Windows will not work ...
+# ifdef _MSC_VER
+ detect_req->error_message = strdup(uv_strerror(GetLastError()));
+# else
+ detect_req->error_message = strdup(uv_strerror(-errno));
+# endif
+#endif
+ } else if (detect_req->source_is_path) {
+ if (magic_load(magic, detect_req->magic_source) == -1
+ && magic_load(magic, fallbackPath) == -1) {
+ detect_req->error_message = strdup(magic_error(magic));
+ magic_close(magic);
+ magic = nullptr;
+ }
+ } else if (magic_load_buffers(magic,
+ (void**)&detect_req->magic_source,
+ &detect_req->source_len,
+ 1) == -1) {
+ detect_req->error_message = strdup(magic_error(magic));
+ magic_close(magic);
+ magic = nullptr;
+ }
+
+ if (magic == nullptr)
+ return;
+
+ if (detect_req->data_is_path) {
+#ifdef _WIN32
+ // open the file manually to help cope with potential unicode characters
+ // in filename
+ const char* ofn = detect_req->data;
+ int flags = O_RDONLY | O_BINARY;
+ int fd = -1;
+ int wLen;
+ wLen = MultiByteToWideChar(CP_UTF8, 0, ofn, -1, nullptr, 0);
+ if (wLen > 0) {
+ wchar_t* wfn = (wchar_t*)malloc(wLen * sizeof(wchar_t));
+ if (wfn) {
+ int wret = MultiByteToWideChar(CP_UTF8, 0, ofn, -1, wfn, wLen);
+ if (wret != 0)
+ _wsopen_s(&fd, wfn, flags, _SH_DENYNO, _S_IREAD);
+ free(wfn);
+ wfn = nullptr;
+ }
+ }
+ if (fd == -1) {
+ detect_req->free_error = false;
+ detect_req->error_message = "Error while opening file";
+ magic_close(magic);
+ return;
+ }
+ result = magic_descriptor(magic, fd);
+ _close(fd);
+#else
+ result = magic_file(magic, detect_req->data);
+#endif
+ } else {
+ result = magic_buffer(magic,
+ (const void*)detect_req->data,
+ detect_req->data_len);
+ }
+
+ if (result == nullptr) {
+ const char* error = magic_error(magic);
+ if (error)
+ detect_req->error_message = strdup(error);
+ } else {
+ detect_req->result = strdup(result);
+ }
+
+ magic_close(magic);
+ }
+
+ static void DetectAfter(uv_work_t* req) {
+ Nan::HandleScope scope;
+ DetectRequest* detect_req = static_cast<DetectRequest*>(req->data);
+ Local<Function> callback = Nan::New(detect_req->callback);
+ Local<Object> target = Nan::New<Object>();
+
+ if (detect_req->error_message) {
+ Local<Value> err = Nan::Error(detect_req->error_message);
+ Local<Value> argv[1] = { err };
+ detect_req->runInAsyncScope(target, callback, 1, argv);
+ } else {
+ Local<Value> argv[2];
+ int multi_result_flags =
+ (detect_req->flags & (MAGIC_CONTINUE | MAGIC_RAW));
+
+ argv[0] = Nan::Null();
+
+ if (multi_result_flags == (MAGIC_CONTINUE | MAGIC_RAW)) {
+ Local<Array> results = Nan::New<Array>();
+ if (detect_req->result) {
+ uint32_t i = 0;
+ const char* result_end =
+ detect_req->result + strlen(detect_req->result);
+ const char* last_match = detect_req->result;
+ const char* cur_match;
+ while (true) {
+ if (!(cur_match = strstr(last_match, "\n- "))) {
+ // Append remainder string
+ if (last_match < result_end) {
+ Nan::Set(Local<Object>::Cast(results),
+ i,
+ Nan::New<String>(last_match).ToLocalChecked());
+ }
+ break;
+ }
+
+ size_t match_len = (cur_match - last_match);
+ char* match = new char[match_len + 1];
+ strncpy(match, last_match, match_len);
+ match[match_len] = '\0';
+
+ Nan::Set(Local<Object>::Cast(results),
+ i++,
+ Nan::New<String>(match).ToLocalChecked());
+
+ delete[] match;
+ last_match = cur_match + 3;
+ }
+ }
+ argv[1] = Local<Value>(results);
+ } else if (detect_req->result) {
+ argv[1] =
+ Local<Value>(Nan::New<String>(detect_req->result).ToLocalChecked());
+ } else {
+ argv[1] = Local<Value>(Nan::New<String>().ToLocalChecked());
+ }
+
+ detect_req->runInAsyncScope(target, callback, 2, argv);
+ }
+
+ delete detect_req;
+ }
+
+ static void SetFallback(const Nan::FunctionCallbackInfo<v8::Value>& args) {
+ if (fallbackPath)
+ free((void*)fallbackPath);
+
+ fallbackPath = nullptr;
+ if (args.Length() > 0 && args[0]->IsString()) {
+ Nan::Utf8String str(args[0]);
+ if (str.length() > 0)
+ fallbackPath = strdup((const char*)(*str));
+ }
+
+ return args.GetReturnValue().Set(args.This());
+ }
+
+ static void Initialize(Local<Object> target) {
+
+ Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
+
+ tpl->InstanceTemplate()->SetInternalFieldCount(1);
+ tpl->SetClassName(Nan::New<String>("Magic").ToLocalChecked());
+ Nan::SetPrototypeMethod(tpl, "detectFile", DetectFile);
+ Nan::SetPrototypeMethod(tpl, "detect", Detect);
+
+ constructor.Reset(Nan::GetFunction(tpl).ToLocalChecked());
+ Nan::Set(target,
+ Nan::New<String>("setFallback").ToLocalChecked(),
+ Nan::GetFunction(
+ Nan::New<FunctionTemplate>(SetFallback)
+ ).ToLocalChecked()).FromJust();
+
+ Nan::Set(target,
+ Nan::New<String>("Magic").ToLocalChecked(),
+ Nan::GetFunction(tpl).ToLocalChecked()).FromJust();
+ }
+};
+
+extern "C" {
+ void init(Local<Object> target) {
+ Nan::HandleScope();
+ Magic::Initialize(target);
+ }
+
+ NODE_MODULE(magic, init);
+}
diff --git a/node_modules/mmmagic/test/fixtures/tést.txt b/node_modules/mmmagic/test/fixtures/tést.txt
new file mode 100644
index 0000000..4983e95
--- /dev/null
+++ b/node_modules/mmmagic/test/fixtures/tést.txt
@@ -0,0 +1,8 @@
+class Foo {
+public:
+ int bar;
+ Foo() {
+ }
+ ~Foo() {
+ }
+}
diff --git a/node_modules/mmmagic/test/test.js b/node_modules/mmmagic/test/test.js
new file mode 100644
index 0000000..934b011
--- /dev/null
+++ b/node_modules/mmmagic/test/test.js
@@ -0,0 +1,134 @@
+var mmm = require('../lib/index');
+
+var path = require('path');
+var assert = require('assert');
+var fs = require('fs');
+var format = require('util').format;
+
+var t = -1;
+var group = path.basename(__filename, '.js') + '/';
+var timeout;
+
+var tests = [
+ { run: function() {
+ var magic = new mmm.Magic(mmm.MAGIC_MIME_TYPE);
+ magic.detectFile(path.join(__dirname, '..', 'src', 'binding.cc'),
+ function(err, result) {
+ assert.strictEqual(err, null);
+ assert.strictEqual(result, 'text/x-c++');
+ next();
+ });
+ },
+ what: 'detectFile - Normal operation, mime type'
+ },
+ { run: function() {
+ var magic = new mmm.Magic(mmm.MAGIC_MIME_ENCODING);
+ magic.detectFile(path.join(__dirname, '..', 'src', 'binding.cc'),
+ function(err, result) {
+ assert.strictEqual(err, null);
+ assert.strictEqual(result, 'us-ascii');
+ next();
+ });
+ },
+ what: 'detectFile - Normal operation, encoding'
+ },
+ { run: function() {
+ var magic = new mmm.Magic(mmm.MAGIC_MIME);
+ magic.detectFile(path.join(__dirname, '..', 'src', 'binding.cc'),
+ function(err, result) {
+ assert.strictEqual(err, null);
+ assert.strictEqual(result, 'text/x-c++; charset=us-ascii');
+ next();
+ });
+ },
+ what: 'detectFile - Normal operation, mime type + encoding'
+ },
+ { run: function() {
+ var magic = new mmm.Magic();
+ magic.detectFile(path.join(__dirname, '..', 'src', 'binding.cc'),
+ function(err, result) {
+ assert.strictEqual(err, null);
+ assert.strictEqual(/^C\+\+ source, ASCII text/.test(result), true);
+ next();
+ });
+ },
+ what: 'detectFile - Normal operation, description'
+ },
+ { run: function() {
+ var magic = new mmm.Magic(mmm.MAGIC_MIME_TYPE | mmm.MAGIC_CONTINUE);
+ magic.detectFile(path.join(__dirname, '..', 'src', 'binding.cc'),
+ function(err, result) {
+ assert.strictEqual(err, null);
+ assert.strictEqual(Array.isArray(result), true);
+ assert.strictEqual(result[0], 'text/x-c++');
+ next();
+ });
+ },
+ what: 'detectFile - Normal operation, find all matches'
+ },
+ { run: function() {
+ var magic = new mmm.Magic(mmm.MAGIC_MIME_TYPE);
+ magic.detectFile('/no/such/path1234567', function(err, result) {
+ assert(err);
+ assert.strictEqual(result, undefined);
+ next();
+ });
+ },
+ what: 'detectFile - Nonexistent file'
+ },
+ { run: function() {
+ var magic = new mmm.Magic(mmm.MAGIC_MIME_TYPE);
+ magic.detectFile(path.join(__dirname, 'fixtures', 'tést.txt'),
+ function(err, result) {
+ assert.strictEqual(err, null);
+ assert.strictEqual(result, 'text/x-c++');
+ next();
+ });
+ },
+ what: 'detectFile - UTF-8 filename'
+ },
+ { run: function() {
+ var buf = fs.readFileSync(path.join(__dirname, '..', 'src', 'binding.cc'));
+ var magic = new mmm.Magic(mmm.MAGIC_MIME_TYPE);
+ magic.detect(buf, function(err, result) {
+ assert.strictEqual(err, null);
+ assert.strictEqual(result, 'text/x-c++');
+ next();
+ });
+ },
+ what: 'detect - Normal operation, mime type'
+ },
+];
+
+function next() {
+ clearTimeout(timeout);
+ if (t > -1)
+ console.log('Finished %j', tests[t].what)
+ if (t === tests.length - 1)
+ return;
+ var v = tests[++t];
+ timeout = setTimeout(function() {
+ throw new Error(format('Test case %j timed out', v.what));
+ }, 10 * 1000);
+ console.log('Executing %j', v.what);
+ v.run.call(v);
+}
+
+function makeMsg(msg) {
+ var fmtargs = ['[%s]: ' + msg, tests[t].what];
+ for (var i = 1; i < arguments.length; ++i)
+ fmtargs.push(arguments[i]);
+ return format.apply(null, fmtargs);
+}
+
+process.once('uncaughtException', function(err) {
+ if (t > -1 && !/(?:^|\n)AssertionError: /i.test(''+err))
+ console.error(makeMsg('Unexpected Exception:'));
+
+ throw err;
+}).once('exit', function() {
+ assert(t === tests.length - 1,
+ makeMsg('Only finished %d/%d tests', (t + 1), tests.length));
+});
+
+next();
diff --git a/node_modules/nan/CHANGELOG.md b/node_modules/nan/CHANGELOG.md
new file mode 100644
index 0000000..2838f1a
--- /dev/null
+++ b/node_modules/nan/CHANGELOG.md
@@ -0,0 +1,541 @@
+# NAN ChangeLog
+
+**Version 2.15.0: current Node 16.6.1, Node 0.12: 0.12.18, Node 0.10: 0.10.48, iojs: 3.3.1**
+
+### 2.15.0 Aug 4 2021
+
+ - Feature: add ScriptOrigin (#918) d09debf9eeedcb7ca4073e84ffe5fbb455ecb709
+
+### 2.14.2 Oct 13 2020
+
+ - Bugfix: fix gcc 8 function cast warning (#899) 35f0fab205574b2cbda04e6347c8b2db755e124f
+
+### 2.14.1 Apr 21 2020
+
+ - Bugfix: use GetBackingStore() instead of GetContents() (#888) 2c023bd447661a61071da318b0ff4003c3858d39
+
+### 2.14.0 May 16 2019
+
+ - Feature: Add missing methods to Nan::Maybe<T> (#852) 4e962489fb84a184035b9fa74f245f650249aca6
+
+### 2.13.2 Mar 24 2019
+
+ - Bugfix: remove usage of deprecated `IsNearDeath` (#842) fbaf42252af279c3d867c6b193571f9711c39847
+
+### 2.13.1 Mar 14 2019
+
+ - Bugfix: check V8 version directly instead of inferring from NMV (#840) 12f9df9f393285de8fb4a8cd01478dc4fe3b089d
+
+### 2.13.0 Mar 13 2019
+
+ - Feature: add support for node master (#831) 113c0282072e7ff4f9dfc98b432fd894b798c2c
+
+### 2.12.1 Dec 18 2018
+
+ - Bugfix: Fix build breakage with Node.js 10.0.0-10.9.0. (#833) 625e90e8fef8d39ffa7247250a76a100b2487474
+
+### 2.12.0 Dec 16 2018
+
+ - Bugfix: Add scope.Escape() to Call() (#817) 2e5ed4fc3a8ac80a6ef1f2a55099ab3ac8800dc6
+ - Bugfix: Fix Node.js v10.12.0 deprecation warnings. 509859cc23b1770376b56550a027840a2ce0f73d
+ - Feature: Allow SetWeak() for non-object persistent handles. (#824) e6ef6a48e7e671fe3e4b7dddaa8912a3f8262ecd
+
+### 2.11.1 Sep 29 2018
+
+ - Fix: adapt to V8 7.0 24a22c3b25eeeec2016c6ec239bdd6169e985447
+
+### 2.11.0 Aug 25 2018
+
+ - Removal: remove `FunctionCallbackInfo::Callee` for nodejs `>= 10` 1a56c0a6efd4fac944cb46c30912a8e023bda7d4
+ - Bugfix: Fix `AsyncProgressWorkerBase::WorkProgress` sends invalid data b0c764d1dab11e9f8b37ffb81e2560a4498aad5e
+ - Feature: Introduce `GetCurrentEventLoop` b4911b0bb1f6d47d860e10ec014d941c51efac5e
+ - Feature: Add `NAN_MODULE_WORKER_ENABLED` macro as a replacement for `NAN_MODULE` b058fb047d18a58250e66ae831444441c1f2ac7a
+
+### 2.10.0 Mar 16 2018
+
+ - Deprecation: Deprecate `MakeCallback` 5e92b19a59e194241d6a658bd6ff7bfbda372950
+ - Feature: add `Nan::Call` overload 4482e1242fe124d166fc1a5b2be3c1cc849fe452
+ - Feature: add more `Nan::Call` overloads 8584e63e6d04c7d2eb8c4a664e4ef57d70bf672b
+ - Feature: Fix deprecation warnings for Node 10 1caf258243b0602ed56922bde74f1c91b0cbcb6a
+
+### 2.9.2 Feb 22 2018
+
+ - Bugfix: Bandaid for async hooks 212bd2f849be14ef1b02fc85010b053daa24252b
+
+### 2.9.1 Feb 22 2018
+
+ - Bugfix: Avoid deprecation warnings in deprecated `Nan::Callback::operator()` 372b14d91289df4604b0f81780709708c45a9aa4
+ - Bugfix: Avoid deprecation warnings in `Nan::JSON` 3bc294bce0b7d0a3ee4559926303e5ed4866fda2
+
+### 2.9.0 Feb 22 2018
+
+ - Deprecation: Deprecate legacy `Callback::Call` 6dd5fa690af61ca3523004b433304c581b3ea309
+ - Feature: introduce `AsyncResource` class 90c0a179c0d8cb5fd26f1a7d2b1d6231eb402d48o
+ - Feature: Add context aware `Nan::Callback::Call` functions 7169e09fb088418b6e388222e88b4c13f07ebaee
+ - Feature: Make `AsyncWorker` context aware 066ba21a6fb9e2b5230c9ed3a6fc51f1211736a4
+ - Feature: add `Callback` overload to `Nan::Call` 5328daf66e202658c1dc0d916c3aaba99b3cc606
+ - Bugfix: fix warning: suggest parentheses around `&&` within `||` b2bb63d68b8ae623a526b542764e1ac82319cb2c
+ - Bugfix: Fix compilation on io.js 3 d06114dba0a522fb436f0c5f47b994210968cd7b
+
+### 2.8.0 Nov 15 2017
+
+ - Deprecation: Deprecate `Nan::ForceSet` in favor of `Nan::DefineOwnProperty()` 95cbb976d6fbbba88ba0f86dd188223a8591b4e7
+ - Feature: Add `Nan::AsyncProgressQueueWorker` a976636ecc2ef617d1b061ce4a6edf39923691cb
+ - Feature: Add `Nan::DefineOwnProperty()` 95cbb976d6fbbba88ba0f86dd188223a8591b4e7
+ - Bugfix: Fix compiling on io.js 1 & 2 82705a64503ce60c62e98df5bd02972bba090900
+ - Bugfix: Use DefineOwnProperty instead of ForceSet 95cbb976d6fbbba88ba0f86dd188223a8591b4e7
+
+### 2.7.0 Aug 30 2017
+
+ - Feature: Add `Nan::To<v8::Function>()` overload. b93280670c9f6da42ed4cf6cbf085ffdd87bd65b
+ - Bugfix: Fix ternary in `Nan::MaybeLocal<T>::FromMaybe<S>()`. 79a26f7d362e756a9524e672a82c3d603b542867
+
+### 2.6.2 Apr 12 2017
+
+ - Bugfix: Fix v8::JSON::Parse() deprecation warning. 87f6a3c65815fa062296a994cc863e2fa124867d
+
+### 2.6.1 Apr 6 2017
+
+ - Bugfix: nan_json.h: fix build breakage in Node 6 ac8d47dc3c10bfbf3f15a6b951633120c0ee6d51
+
+### 2.6.0 Apr 6 2017
+
+ - Feature: nan: add support for JSON::Parse & Stringify b533226c629cce70e1932a873bb6f849044a56c5
+
+### 2.5.1 Jan 23 2017
+
+ - Bugfix: Fix disappearing handle for private value 6a80995694f162ef63dbc9948fbefd45d4485aa0
+ - Bugfix: Add missing scopes a93b8bae6bc7d32a170db6e89228b7f60ee57112
+ - Bugfix: Use string::data instead of string::front in NewOneByteString d5f920371e67e1f3b268295daee6e83af86b6e50
+
+### 2.5.0 Dec 21 2016
+
+ - Feature: Support Private accessors a86255cb357e8ad8ccbf1f6a4a901c921e39a178
+ - Bugfix: Abort in delete operators that shouldn't be called 0fe38215ff8581703967dfd26c12793feb960018
+
+### 2.4.0 Jul 10 2016
+
+ - Feature: Rewrite Callback to add Callback::Reset c4cf44d61f8275cd5f7b0c911d7a806d4004f649
+ - Feature: AsyncProgressWorker: add template types for .send 1242c9a11a7ed481c8f08ec06316385cacc513d0
+ - Bugfix: Add constness to old Persistent comparison operators bd43cb9982c7639605d60fd073efe8cae165d9b2
+
+### 2.3.5 May 31 2016
+
+ - Bugfix: Replace NAN_INLINE with 'inline' keyword. 71819d8725f822990f439479c9aba3b240804909
+
+### 2.3.4 May 31 2016
+
+ - Bugfix: Remove V8 deprecation warnings 0592fb0a47f3a1c7763087ebea8e1138829f24f9
+ - Bugfix: Fix new versions not to use WeakCallbackInfo::IsFirstPass 615c19d9e03d4be2049c10db0151edbc3b229246
+ - Bugfix: Make ObjectWrap::handle() const d19af99595587fe7a26bd850af6595c2a7145afc
+ - Bugfix: Fix compilation errors related to 0592fb0a47f3a1c7763087ebea8e1138829f24f9 e9191c525b94f652718325e28610a1adcf90fed8
+
+### 2.3.3 May 4 2016
+
+ - Bugfix: Refactor SetMethod() to deal with v8::Templates (#566) b9083cf6d5de6ebe6bcb49c7502fbb7c0d9ddda8
+
+### 2.3.2 Apr 27 2016
+
+ - Bugfix: Fix compilation on outdated versions due to Handle removal f8b7c875d04d425a41dfd4f3f8345bc3a11e6c52
+
+### 2.3.1 Apr 27 2016
+
+ - Bugfix: Don't use deprecated v8::Template::Set() in SetMethod a90951e9ea70fa1b3836af4b925322919159100e
+
+### 2.3.0 Apr 27 2016
+
+ - Feature: added Signal() for invoking async callbacks without sending data from AsyncProgressWorker d8adba45f20e077d00561b20199133620c990b38
+ - Bugfix: Don't use deprecated v8::Template::Set() 00dacf0a4b86027415867fa7f1059acc499dcece
+
+### 2.2.1 Mar 29 2016
+
+ - Bugfix: Use NewFromUnsigned in ReturnValue<T>::Set(uint32_t i) for pre_12 3a18f9bdce29826e0e4c217854bc476918241a58
+ - Performance: Remove unneeeded nullptr checks b715ef44887931c94f0d1605b3b1a4156eebece9
+
+### 2.2.0 Jan 9 2016
+
+ - Feature: Add Function::Call wrapper 4c157474dacf284d125c324177b45aa5dabc08c6
+ - Feature: Rename GC*logueCallback to GCCallback for > 4.0 3603435109f981606d300eb88004ca101283acec
+ - Bugfix: Fix Global::Pass for old versions 367e82a60fbaa52716232cc89db1cc3f685d77d9
+ - Bugfix: Remove weird MaybeLocal wrapping of what already is a MaybeLocal 23b4590db10c2ba66aee2338aebe9751c4cb190b
+
+### 2.1.0 Oct 8 2015
+
+ - Deprecation: Deprecate NanErrnoException in favor of ErrnoException 0af1ca4cf8b3f0f65ed31bc63a663ab3319da55c
+ - Feature: added helper class for accessing contents of typedarrays 17b51294c801e534479d5463697a73462d0ca555
+ - Feature: [Maybe types] Add MakeMaybe(...) 48d7b53d9702b0c7a060e69ea10fea8fb48d814d
+ - Feature: new: allow utf16 string with length 66ac6e65c8ab9394ef588adfc59131b3b9d8347b
+ - Feature: Introduce SetCallHandler and SetCallAsFunctionHandler 7764a9a115d60ba10dc24d86feb0fbc9b4f75537
+ - Bugfix: Enable creating Locals from Globals under Node 0.10. 9bf9b8b190821af889790fdc18ace57257e4f9ff
+ - Bugfix: Fix issue #462 where PropertyCallbackInfo data is not stored safely. 55f50adedd543098526c7b9f4fffd607d3f9861f
+
+### 2.0.9 Sep 8 2015
+
+ - Bugfix: EscapableHandleScope in Nan::NewBuffer for Node 0.8 and 0.10 b1654d7
+
+### 2.0.8 Aug 28 2015
+
+ - Work around duplicate linking bug in clang 11902da
+
+### 2.0.7 Aug 26 2015
+
+ - Build: Repackage
+
+### 2.0.6 Aug 26 2015
+
+ - Bugfix: Properly handle null callback in FunctionTemplate factory 6e99cb1
+ - Bugfix: Remove unused static std::map instances 525bddc
+ - Bugfix: Make better use of maybe versions of APIs bfba85b
+ - Bugfix: Fix shadowing issues with handle in ObjectWrap 0a9072d
+
+### 2.0.5 Aug 10 2015
+
+ - Bugfix: Reimplement weak callback in ObjectWrap 98d38c1
+ - Bugfix: Make sure callback classes are not assignable, copyable or movable 81f9b1d
+
+### 2.0.4 Aug 6 2015
+
+ - Build: Repackage
+
+### 2.0.3 Aug 6 2015
+
+ - Bugfix: Don't use clang++ / g++ syntax extension. 231450e
+
+### 2.0.2 Aug 6 2015
+
+ - Build: Repackage
+
+### 2.0.1 Aug 6 2015
+
+ - Bugfix: Add workaround for missing REPLACE_INVALID_UTF8 60d6687
+ - Bugfix: Reimplement ObjectWrap from scratch to prevent memory leaks 6484601
+ - Bugfix: Fix Persistent leak in FunctionCallbackInfo and PropertyCallbackInfo 641ef5f
+ - Bugfix: Add missing overload for Nan::NewInstance that takes argc/argv 29450ed
+
+### 2.0.0 Jul 31 2015
+
+ - Change: Renamed identifiers with leading underscores b5932b4
+ - Change: Replaced NanObjectWrapHandle with class NanObjectWrap 464f1e1
+ - Change: Replace NanScope and NanEscpableScope macros with classes 47751c4
+ - Change: Rename NanNewBufferHandle to NanNewBuffer 6745f99
+ - Change: Rename NanBufferUse to NanNewBuffer 3e8b0a5
+ - Change: Rename NanNewBuffer to NanCopyBuffer d6af78d
+ - Change: Remove Nan prefix from all names 72d1f67
+ - Change: Update Buffer API for new upstream changes d5d3291
+ - Change: Rename Scope and EscapableScope to HandleScope and EscapableHandleScope 21a7a6a
+ - Change: Get rid of Handles e6c0daf
+ - Feature: Support io.js 3 with V8 4.4
+ - Feature: Introduce NanPersistent 7fed696
+ - Feature: Introduce NanGlobal 4408da1
+ - Feature: Added NanTryCatch 10f1ca4
+ - Feature: Update for V8 v4.3 4b6404a
+ - Feature: Introduce NanNewOneByteString c543d32
+ - Feature: Introduce namespace Nan 67ed1b1
+ - Removal: Remove NanLocker and NanUnlocker dd6e401
+ - Removal: Remove string converters, except NanUtf8String, which now follows the node implementation b5d00a9
+ - Removal: Remove NanReturn* macros d90a25c
+ - Removal: Remove HasInstance e8f84fe
+
+
+### 1.9.0 Jul 31 2015
+
+ - Feature: Added `NanFatalException` 81d4a2c
+ - Feature: Added more error types 4265f06
+ - Feature: Added dereference and function call operators to NanCallback c4b2ed0
+ - Feature: Added indexed GetFromPersistent and SaveToPersistent edd510c
+ - Feature: Added more overloads of SaveToPersistent and GetFromPersistent 8b1cef6
+ - Feature: Added NanErrnoException dd87d9e
+ - Correctness: Prevent assign, copy, and move for classes that do not support it 1f55c59, 4b808cb, c96d9b2, fba4a29, 3357130
+ - Deprecation: Deprecate `NanGetPointerSafe` and `NanSetPointerSafe` 81d4a2c
+ - Deprecation: Deprecate `NanBooleanOptionValue` and `NanUInt32OptionValue` 0ad254b
+
+### 1.8.4 Apr 26 2015
+
+ - Build: Repackage
+
+### 1.8.3 Apr 26 2015
+
+ - Bugfix: Include missing header 1af8648
+
+### 1.8.2 Apr 23 2015
+
+ - Build: Repackage
+
+### 1.8.1 Apr 23 2015
+
+ - Bugfix: NanObjectWrapHandle should take a pointer 155f1d3
+
+### 1.8.0 Apr 23 2015
+
+ - Feature: Allow primitives with NanReturnValue 2e4475e
+ - Feature: Added comparison operators to NanCallback 55b075e
+ - Feature: Backport thread local storage 15bb7fa
+ - Removal: Remove support for signatures with arguments 8a2069d
+ - Correcteness: Replaced NanObjectWrapHandle macro with function 0bc6d59
+
+### 1.7.0 Feb 28 2015
+
+ - Feature: Made NanCallback::Call accept optional target 8d54da7
+ - Feature: Support atom-shell 0.21 0b7f1bb
+
+### 1.6.2 Feb 6 2015
+
+ - Bugfix: NanEncode: fix argument type for node::Encode on io.js 2be8639
+
+### 1.6.1 Jan 23 2015
+
+ - Build: version bump
+
+### 1.5.3 Jan 23 2015
+
+ - Build: repackage
+
+### 1.6.0 Jan 23 2015
+
+ - Deprecated `NanNewContextHandle` in favor of `NanNew<Context>` 49259af
+ - Support utility functions moved in newer v8 versions (Node 0.11.15, io.js 1.0) a0aa179
+ - Added `NanEncode`, `NanDecodeBytes` and `NanDecodeWrite` 75e6fb9
+
+### 1.5.2 Jan 23 2015
+
+ - Bugfix: Fix non-inline definition build error with clang++ 21d96a1, 60fadd4
+ - Bugfix: Readded missing String constructors 18d828f
+ - Bugfix: Add overload handling NanNew<FunctionTemplate>(..) 5ef813b
+ - Bugfix: Fix uv_work_cb versioning 997e4ae
+ - Bugfix: Add function factory and test 4eca89c
+ - Bugfix: Add object template factory and test cdcb951
+ - Correctness: Lifted an io.js related typedef c9490be
+ - Correctness: Make explicit downcasts of String lengths 00074e6
+ - Windows: Limit the scope of disabled warning C4530 83d7deb
+
+### 1.5.1 Jan 15 2015
+
+ - Build: version bump
+
+### 1.4.3 Jan 15 2015
+
+ - Build: version bump
+
+### 1.4.2 Jan 15 2015
+
+ - Feature: Support io.js 0dbc5e8
+
+### 1.5.0 Jan 14 2015
+
+ - Feature: Support io.js b003843
+ - Correctness: Improved NanNew internals 9cd4f6a
+ - Feature: Implement progress to NanAsyncWorker 8d6a160
+
+### 1.4.1 Nov 8 2014
+
+ - Bugfix: Handle DEBUG definition correctly
+ - Bugfix: Accept int as Boolean
+
+### 1.4.0 Nov 1 2014
+
+ - Feature: Added NAN_GC_CALLBACK 6a5c245
+ - Performance: Removed unnecessary local handle creation 18a7243, 41fe2f8
+ - Correctness: Added constness to references in NanHasInstance 02c61cd
+ - Warnings: Fixed spurious warnings from -Wundef and -Wshadow, 541b122, 99d8cb6
+ - Windoze: Shut Visual Studio up when compiling 8d558c1
+ - License: Switch to plain MIT from custom hacked MIT license 11de983
+ - Build: Added test target to Makefile e232e46
+ - Performance: Removed superfluous scope in NanAsyncWorker f4b7821
+ - Sugar/Feature: Added NanReturnThis() and NanReturnHolder() shorthands 237a5ff, d697208
+ - Feature: Added suitable overload of NanNew for v8::Integer::NewFromUnsigned b27b450
+
+### 1.3.0 Aug 2 2014
+
+ - Added NanNew<v8::String, std::string>(std::string)
+ - Added NanNew<v8::String, std::string&>(std::string&)
+ - Added NanAsciiString helper class
+ - Added NanUtf8String helper class
+ - Added NanUcs2String helper class
+ - Deprecated NanRawString()
+ - Deprecated NanCString()
+ - Added NanGetIsolateData(v8::Isolate *isolate)
+ - Added NanMakeCallback(v8::Handle<v8::Object> target, v8::Handle<v8::Function> func, int argc, v8::Handle<v8::Value>* argv)
+ - Added NanMakeCallback(v8::Handle<v8::Object> target, v8::Handle<v8::String> symbol, int argc, v8::Handle<v8::Value>* argv)
+ - Added NanMakeCallback(v8::Handle<v8::Object> target, const char* method, int argc, v8::Handle<v8::Value>* argv)
+ - Added NanSetTemplate(v8::Handle<v8::Template> templ, v8::Handle<v8::String> name , v8::Handle<v8::Data> value, v8::PropertyAttribute attributes)
+ - Added NanSetPrototypeTemplate(v8::Local<v8::FunctionTemplate> templ, v8::Handle<v8::String> name, v8::Handle<v8::Data> value, v8::PropertyAttribute attributes)
+ - Added NanSetInstanceTemplate(v8::Local<v8::FunctionTemplate> templ, const char *name, v8::Handle<v8::Data> value)
+ - Added NanSetInstanceTemplate(v8::Local<v8::FunctionTemplate> templ, v8::Handle<v8::String> name, v8::Handle<v8::Data> value, v8::PropertyAttribute attributes)
+
+### 1.2.0 Jun 5 2014
+
+ - Add NanSetPrototypeTemplate
+ - Changed NAN_WEAK_CALLBACK internals, switched _NanWeakCallbackData to class,
+ introduced _NanWeakCallbackDispatcher
+ - Removed -Wno-unused-local-typedefs from test builds
+ - Made test builds Windows compatible ('Sleep()')
+
+### 1.1.2 May 28 2014
+
+ - Release to fix more stuff-ups in 1.1.1
+
+### 1.1.1 May 28 2014
+
+ - Release to fix version mismatch in nan.h and lack of changelog entry for 1.1.0
+
+### 1.1.0 May 25 2014
+
+ - Remove nan_isolate, use v8::Isolate::GetCurrent() internally instead
+ - Additional explicit overloads for NanNew(): (char*,int), (uint8_t*[,int]),
+ (uint16_t*[,int), double, int, unsigned int, bool, v8::String::ExternalStringResource*,
+ v8::String::ExternalAsciiStringResource*
+ - Deprecate NanSymbol()
+ - Added SetErrorMessage() and ErrorMessage() to NanAsyncWorker
+
+### 1.0.0 May 4 2014
+
+ - Heavy API changes for V8 3.25 / Node 0.11.13
+ - Use cpplint.py
+ - Removed NanInitPersistent
+ - Removed NanPersistentToLocal
+ - Removed NanFromV8String
+ - Removed NanMakeWeak
+ - Removed NanNewLocal
+ - Removed NAN_WEAK_CALLBACK_OBJECT
+ - Removed NAN_WEAK_CALLBACK_DATA
+ - Introduce NanNew, replaces NanNewLocal, NanPersistentToLocal, adds many overloaded typed versions
+ - Introduce NanUndefined, NanNull, NanTrue and NanFalse
+ - Introduce NanEscapableScope and NanEscapeScope
+ - Introduce NanMakeWeakPersistent (requires a special callback to work on both old and new node)
+ - Introduce NanMakeCallback for node::MakeCallback
+ - Introduce NanSetTemplate
+ - Introduce NanGetCurrentContext
+ - Introduce NanCompileScript and NanRunScript
+ - Introduce NanAdjustExternalMemory
+ - Introduce NanAddGCEpilogueCallback, NanAddGCPrologueCallback, NanRemoveGCEpilogueCallback, NanRemoveGCPrologueCallback
+ - Introduce NanGetHeapStatistics
+ - Rename NanAsyncWorker#SavePersistent() to SaveToPersistent()
+
+### 0.8.0 Jan 9 2014
+
+ - NanDispose -> NanDisposePersistent, deprecate NanDispose
+ - Extract _NAN_*_RETURN_TYPE, pull up NAN_*()
+
+### 0.7.1 Jan 9 2014
+
+ - Fixes to work against debug builds of Node
+ - Safer NanPersistentToLocal (avoid reinterpret_cast)
+ - Speed up common NanRawString case by only extracting flattened string when necessary
+
+### 0.7.0 Dec 17 2013
+
+ - New no-arg form of NanCallback() constructor.
+ - NanCallback#Call takes Handle rather than Local
+ - Removed deprecated NanCallback#Run method, use NanCallback#Call instead
+ - Split off _NAN_*_ARGS_TYPE from _NAN_*_ARGS
+ - Restore (unofficial) Node 0.6 compatibility at NanCallback#Call()
+ - Introduce NanRawString() for char* (or appropriate void*) from v8::String
+ (replacement for NanFromV8String)
+ - Introduce NanCString() for null-terminated char* from v8::String
+
+### 0.6.0 Nov 21 2013
+
+ - Introduce NanNewLocal<T>(v8::Handle<T> value) for use in place of
+ v8::Local<T>::New(...) since v8 started requiring isolate in Node 0.11.9
+
+### 0.5.2 Nov 16 2013
+
+ - Convert SavePersistent and GetFromPersistent in NanAsyncWorker from protected and public
+
+### 0.5.1 Nov 12 2013
+
+ - Use node::MakeCallback() instead of direct v8::Function::Call()
+
+### 0.5.0 Nov 11 2013
+
+ - Added @TooTallNate as collaborator
+ - New, much simpler, "include_dirs" for binding.gyp
+ - Added full range of NAN_INDEX_* macros to match NAN_PROPERTY_* macros
+
+### 0.4.4 Nov 2 2013
+
+ - Isolate argument from v8::Persistent::MakeWeak removed for 0.11.8+
+
+### 0.4.3 Nov 2 2013
+
+ - Include node_object_wrap.h, removed from node.h for Node 0.11.8.
+
+### 0.4.2 Nov 2 2013
+
+ - Handle deprecation of v8::Persistent::Dispose(v8::Isolate* isolate)) for
+ Node 0.11.8 release.
+
+### 0.4.1 Sep 16 2013
+
+ - Added explicit `#include <uv.h>` as it was removed from node.h for v0.11.8
+
+### 0.4.0 Sep 2 2013
+
+ - Added NAN_INLINE and NAN_DEPRECATED and made use of them
+ - Added NanError, NanTypeError and NanRangeError
+ - Cleaned up code
+
+### 0.3.2 Aug 30 2013
+
+ - Fix missing scope declaration in GetFromPersistent() and SaveToPersistent
+ in NanAsyncWorker
+
+### 0.3.1 Aug 20 2013
+
+ - fix "not all control paths return a value" compile warning on some platforms
+
+### 0.3.0 Aug 19 2013
+
+ - Made NAN work with NPM
+ - Lots of fixes to NanFromV8String, pulling in features from new Node core
+ - Changed node::encoding to Nan::Encoding in NanFromV8String to unify the API
+ - Added optional error number argument for NanThrowError()
+ - Added NanInitPersistent()
+ - Added NanReturnNull() and NanReturnEmptyString()
+ - Added NanLocker and NanUnlocker
+ - Added missing scopes
+ - Made sure to clear disposed Persistent handles
+ - Changed NanAsyncWorker to allocate error messages on the heap
+ - Changed NanThrowError(Local<Value>) to NanThrowError(Handle<Value>)
+ - Fixed leak in NanAsyncWorker when errmsg is used
+
+### 0.2.2 Aug 5 2013
+
+ - Fixed usage of undefined variable with node::BASE64 in NanFromV8String()
+
+### 0.2.1 Aug 5 2013
+
+ - Fixed 0.8 breakage, node::BUFFER encoding type not available in 0.8 for
+ NanFromV8String()
+
+### 0.2.0 Aug 5 2013
+
+ - Added NAN_PROPERTY_GETTER, NAN_PROPERTY_SETTER, NAN_PROPERTY_ENUMERATOR,
+ NAN_PROPERTY_DELETER, NAN_PROPERTY_QUERY
+ - Extracted _NAN_METHOD_ARGS, _NAN_GETTER_ARGS, _NAN_SETTER_ARGS,
+ _NAN_PROPERTY_GETTER_ARGS, _NAN_PROPERTY_SETTER_ARGS,
+ _NAN_PROPERTY_ENUMERATOR_ARGS, _NAN_PROPERTY_DELETER_ARGS,
+ _NAN_PROPERTY_QUERY_ARGS
+ - Added NanGetInternalFieldPointer, NanSetInternalFieldPointer
+ - Added NAN_WEAK_CALLBACK, NAN_WEAK_CALLBACK_OBJECT,
+ NAN_WEAK_CALLBACK_DATA, NanMakeWeak
+ - Renamed THROW_ERROR to _NAN_THROW_ERROR
+ - Added NanNewBufferHandle(char*, size_t, node::smalloc::FreeCallback, void*)
+ - Added NanBufferUse(char*, uint32_t)
+ - Added NanNewContextHandle(v8::ExtensionConfiguration*,
+ v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::Value>)
+ - Fixed broken NanCallback#GetFunction()
+ - Added optional encoding and size arguments to NanFromV8String()
+ - Added NanGetPointerSafe() and NanSetPointerSafe()
+ - Added initial test suite (to be expanded)
+ - Allow NanUInt32OptionValue to convert any Number object
+
+### 0.1.0 Jul 21 2013
+
+ - Added `NAN_GETTER`, `NAN_SETTER`
+ - Added `NanThrowError` with single Local<Value> argument
+ - Added `NanNewBufferHandle` with single uint32_t argument
+ - Added `NanHasInstance(Persistent<FunctionTemplate>&, Handle<Value>)`
+ - Added `Local<Function> NanCallback#GetFunction()`
+ - Added `NanCallback#Call(int, Local<Value>[])`
+ - Deprecated `NanCallback#Run(int, Local<Value>[])` in favour of Call
diff --git a/node_modules/nan/LICENSE.md b/node_modules/nan/LICENSE.md
new file mode 100644
index 0000000..dddd13d
--- /dev/null
+++ b/node_modules/nan/LICENSE.md
@@ -0,0 +1,13 @@
+The MIT License (MIT)
+=====================
+
+Copyright (c) 2018 NAN contributors
+-----------------------------------
+
+*NAN contributors listed at <https://github.com/nodejs/nan#contributors>*
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/nan/README.md b/node_modules/nan/README.md
new file mode 100644
index 0000000..8988a09
--- /dev/null
+++ b/node_modules/nan/README.md
@@ -0,0 +1,456 @@
+Native Abstractions for Node.js
+===============================
+
+**A header file filled with macro and utility goodness for making add-on development for Node.js easier across versions 0.8, 0.10, 0.12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 and 16.**
+
+***Current version: 2.15.0***
+
+*(See [CHANGELOG.md](https://github.com/nodejs/nan/blob/master/CHANGELOG.md) for complete ChangeLog)*
+
+[![NPM](https://nodei.co/npm/nan.png?downloads=true&downloadRank=true)](https://nodei.co/npm/nan/) [![NPM](https://nodei.co/npm-dl/nan.png?months=6&height=3)](https://nodei.co/npm/nan/)
+
+[![Build Status](https://api.travis-ci.com/nodejs/nan.svg?branch=master)](https://travis-ci.com/nodejs/nan)
+[![Build status](https://ci.appveyor.com/api/projects/status/kh73pbm9dsju7fgh)](https://ci.appveyor.com/project/RodVagg/nan)
+
+Thanks to the crazy changes in V8 (and some in Node core), keeping native addons compiling happily across versions, particularly 0.10 to 0.12 to 4.0, is a minor nightmare. The goal of this project is to store all logic necessary to develop native Node.js addons without having to inspect `NODE_MODULE_VERSION` and get yourself into a macro-tangle.
+
+This project also contains some helper utilities that make addon development a bit more pleasant.
+
+ * **[News & Updates](#news)**
+ * **[Usage](#usage)**
+ * **[Example](#example)**
+ * **[API](#api)**
+ * **[Tests](#tests)**
+ * **[Known issues](#issues)**
+ * **[Governance & Contributing](#governance)**
+
+<a name="news"></a>
+
+## News & Updates
+
+<a name="usage"></a>
+
+## Usage
+
+Simply add **NAN** as a dependency in the *package.json* of your Node addon:
+
+``` bash
+$ npm install --save nan
+```
+
+Pull in the path to **NAN** in your *binding.gyp* so that you can use `#include <nan.h>` in your *.cpp* files:
+
+``` python
+"include_dirs" : [
+ "<!(node -e \"require('nan')\")"
+]
+```
+
+This works like a `-I<path-to-NAN>` when compiling your addon.
+
+<a name="example"></a>
+
+## Example
+
+Just getting started with Nan? Take a look at the **[Node Add-on Examples](https://github.com/nodejs/node-addon-examples)**.
+
+Refer to a [quick-start **Nan** Boilerplate](https://github.com/fcanas/node-native-boilerplate) for a ready-to-go project that utilizes basic Nan functionality.
+
+For a simpler example, see the **[async pi estimation example](https://github.com/nodejs/nan/tree/master/examples/async_pi_estimate)** in the examples directory for full code and an explanation of what this Monte Carlo Pi estimation example does. Below are just some parts of the full example that illustrate the use of **NAN**.
+
+Yet another example is **[nan-example-eol](https://github.com/CodeCharmLtd/nan-example-eol)**. It shows newline detection implemented as a native addon.
+
+Also take a look at our comprehensive **[C++ test suite](https://github.com/nodejs/nan/tree/master/test/cpp)** which has a plethora of code snippets for your pasting pleasure.
+
+<a name="api"></a>
+
+## API
+
+Additional to the NAN documentation below, please consult:
+
+* [The V8 Getting Started * Guide](https://v8.dev/docs/embed)
+* [V8 API Documentation](https://v8docs.nodesource.com/)
+* [Node Add-on Documentation](https://nodejs.org/api/addons.html)
+
+<!-- START API -->
+
+### JavaScript-accessible methods
+
+A _template_ is a blueprint for JavaScript functions and objects in a context. You can use a template to wrap C++ functions and data structures within JavaScript objects so that they can be manipulated from JavaScript. See the V8 Embedders Guide section on [Templates](https://github.com/v8/v8/wiki/Embedder%27s-Guide#templates) for further information.
+
+In order to expose functionality to JavaScript via a template, you must provide it to V8 in a form that it understands. Across the versions of V8 supported by NAN, JavaScript-accessible method signatures vary widely, NAN fully abstracts method declaration and provides you with an interface that is similar to the most recent V8 API but is backward-compatible with older versions that still use the now-deceased `v8::Argument` type.
+
+* **Method argument types**
+ - <a href="doc/methods.md#api_nan_function_callback_info"><b><code>Nan::FunctionCallbackInfo</code></b></a>
+ - <a href="doc/methods.md#api_nan_property_callback_info"><b><code>Nan::PropertyCallbackInfo</code></b></a>
+ - <a href="doc/methods.md#api_nan_return_value"><b><code>Nan::ReturnValue</code></b></a>
+* **Method declarations**
+ - <a href="doc/methods.md#api_nan_method"><b>Method declaration</b></a>
+ - <a href="doc/methods.md#api_nan_getter"><b>Getter declaration</b></a>
+ - <a href="doc/methods.md#api_nan_setter"><b>Setter declaration</b></a>
+ - <a href="doc/methods.md#api_nan_property_getter"><b>Property getter declaration</b></a>
+ - <a href="doc/methods.md#api_nan_property_setter"><b>Property setter declaration</b></a>
+ - <a href="doc/methods.md#api_nan_property_enumerator"><b>Property enumerator declaration</b></a>
+ - <a href="doc/methods.md#api_nan_property_deleter"><b>Property deleter declaration</b></a>
+ - <a href="doc/methods.md#api_nan_property_query"><b>Property query declaration</b></a>
+ - <a href="doc/methods.md#api_nan_index_getter"><b>Index getter declaration</b></a>
+ - <a href="doc/methods.md#api_nan_index_setter"><b>Index setter declaration</b></a>
+ - <a href="doc/methods.md#api_nan_index_enumerator"><b>Index enumerator declaration</b></a>
+ - <a href="doc/methods.md#api_nan_index_deleter"><b>Index deleter declaration</b></a>
+ - <a href="doc/methods.md#api_nan_index_query"><b>Index query declaration</b></a>
+* Method and template helpers
+ - <a href="doc/methods.md#api_nan_set_method"><b><code>Nan::SetMethod()</code></b></a>
+ - <a href="doc/methods.md#api_nan_set_prototype_method"><b><code>Nan::SetPrototypeMethod()</code></b></a>
+ - <a href="doc/methods.md#api_nan_set_accessor"><b><code>Nan::SetAccessor()</code></b></a>
+ - <a href="doc/methods.md#api_nan_set_named_property_handler"><b><code>Nan::SetNamedPropertyHandler()</code></b></a>
+ - <a href="doc/methods.md#api_nan_set_indexed_property_handler"><b><code>Nan::SetIndexedPropertyHandler()</code></b></a>
+ - <a href="doc/methods.md#api_nan_set_template"><b><code>Nan::SetTemplate()</code></b></a>
+ - <a href="doc/methods.md#api_nan_set_prototype_template"><b><code>Nan::SetPrototypeTemplate()</code></b></a>
+ - <a href="doc/methods.md#api_nan_set_instance_template"><b><code>Nan::SetInstanceTemplate()</code></b></a>
+ - <a href="doc/methods.md#api_nan_set_call_handler"><b><code>Nan::SetCallHandler()</code></b></a>
+ - <a href="doc/methods.md#api_nan_set_call_as_function_handler"><b><code>Nan::SetCallAsFunctionHandler()</code></b></a>
+
+### Scopes
+
+A _local handle_ is a pointer to an object. All V8 objects are accessed using handles, they are necessary because of the way the V8 garbage collector works.
+
+A handle scope can be thought of as a container for any number of handles. When you've finished with your handles, instead of deleting each one individually you can simply delete their scope.
+
+The creation of `HandleScope` objects is different across the supported versions of V8. Therefore, NAN provides its own implementations that can be used safely across these.
+
+ - <a href="doc/scopes.md#api_nan_handle_scope"><b><code>Nan::HandleScope</code></b></a>
+ - <a href="doc/scopes.md#api_nan_escapable_handle_scope"><b><code>Nan::EscapableHandleScope</code></b></a>
+
+Also see the V8 Embedders Guide section on [Handles and Garbage Collection](https://github.com/v8/v8/wiki/Embedder%27s%20Guide#handles-and-garbage-collection).
+
+### Persistent references
+
+An object reference that is independent of any `HandleScope` is a _persistent_ reference. Where a `Local` handle only lives as long as the `HandleScope` in which it was allocated, a `Persistent` handle remains valid until it is explicitly disposed.
+
+Due to the evolution of the V8 API, it is necessary for NAN to provide a wrapper implementation of the `Persistent` classes to supply compatibility across the V8 versions supported.
+
+ - <a href="doc/persistent.md#api_nan_persistent_base"><b><code>Nan::PersistentBase & v8::PersistentBase</code></b></a>
+ - <a href="doc/persistent.md#api_nan_non_copyable_persistent_traits"><b><code>Nan::NonCopyablePersistentTraits & v8::NonCopyablePersistentTraits</code></b></a>
+ - <a href="doc/persistent.md#api_nan_copyable_persistent_traits"><b><code>Nan::CopyablePersistentTraits & v8::CopyablePersistentTraits</code></b></a>
+ - <a href="doc/persistent.md#api_nan_persistent"><b><code>Nan::Persistent</code></b></a>
+ - <a href="doc/persistent.md#api_nan_global"><b><code>Nan::Global</code></b></a>
+ - <a href="doc/persistent.md#api_nan_weak_callback_info"><b><code>Nan::WeakCallbackInfo</code></b></a>
+ - <a href="doc/persistent.md#api_nan_weak_callback_type"><b><code>Nan::WeakCallbackType</code></b></a>
+
+Also see the V8 Embedders Guide section on [Handles and Garbage Collection](https://developers.google.com/v8/embed#handles).
+
+### New
+
+NAN provides a `Nan::New()` helper for the creation of new JavaScript objects in a way that's compatible across the supported versions of V8.
+
+ - <a href="doc/new.md#api_nan_new"><b><code>Nan::New()</code></b></a>
+ - <a href="doc/new.md#api_nan_undefined"><b><code>Nan::Undefined()</code></b></a>
+ - <a href="doc/new.md#api_nan_null"><b><code>Nan::Null()</code></b></a>
+ - <a href="doc/new.md#api_nan_true"><b><code>Nan::True()</code></b></a>
+ - <a href="doc/new.md#api_nan_false"><b><code>Nan::False()</code></b></a>
+ - <a href="doc/new.md#api_nan_empty_string"><b><code>Nan::EmptyString()</code></b></a>
+
+
+### Converters
+
+NAN contains functions that convert `v8::Value`s to other `v8::Value` types and native types. Since type conversion is not guaranteed to succeed, they return `Nan::Maybe` types. These converters can be used in place of `value->ToX()` and `value->XValue()` (where `X` is one of the types, e.g. `Boolean`) in a way that provides a consistent interface across V8 versions. Newer versions of V8 use the new `v8::Maybe` and `v8::MaybeLocal` types for these conversions, older versions don't have this functionality so it is provided by NAN.
+
+ - <a href="doc/converters.md#api_nan_to"><b><code>Nan::To()</code></b></a>
+
+### Maybe Types
+
+The `Nan::MaybeLocal` and `Nan::Maybe` types are monads that encapsulate `v8::Local` handles that _may be empty_.
+
+* **Maybe Types**
+ - <a href="doc/maybe_types.md#api_nan_maybe_local"><b><code>Nan::MaybeLocal</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_maybe"><b><code>Nan::Maybe</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_nothing"><b><code>Nan::Nothing</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_just"><b><code>Nan::Just</code></b></a>
+* **Maybe Helpers**
+ - <a href="doc/maybe_types.md#api_nan_call"><b><code>Nan::Call()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_to_detail_string"><b><code>Nan::ToDetailString()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_to_array_index"><b><code>Nan::ToArrayIndex()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_equals"><b><code>Nan::Equals()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_new_instance"><b><code>Nan::NewInstance()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_get_function"><b><code>Nan::GetFunction()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_set"><b><code>Nan::Set()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_define_own_property"><b><code>Nan::DefineOwnProperty()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_force_set"><del><b><code>Nan::ForceSet()</code></b></del></a>
+ - <a href="doc/maybe_types.md#api_nan_get"><b><code>Nan::Get()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_get_property_attribute"><b><code>Nan::GetPropertyAttributes()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_has"><b><code>Nan::Has()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_delete"><b><code>Nan::Delete()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_get_property_names"><b><code>Nan::GetPropertyNames()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_get_own_property_names"><b><code>Nan::GetOwnPropertyNames()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_set_prototype"><b><code>Nan::SetPrototype()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_object_proto_to_string"><b><code>Nan::ObjectProtoToString()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_has_own_property"><b><code>Nan::HasOwnProperty()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_has_real_named_property"><b><code>Nan::HasRealNamedProperty()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_has_real_indexed_property"><b><code>Nan::HasRealIndexedProperty()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_has_real_named_callback_property"><b><code>Nan::HasRealNamedCallbackProperty()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_get_real_named_property_in_prototype_chain"><b><code>Nan::GetRealNamedPropertyInPrototypeChain()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_get_real_named_property"><b><code>Nan::GetRealNamedProperty()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_call_as_function"><b><code>Nan::CallAsFunction()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_call_as_constructor"><b><code>Nan::CallAsConstructor()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_get_source_line"><b><code>Nan::GetSourceLine()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_get_line_number"><b><code>Nan::GetLineNumber()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_get_start_column"><b><code>Nan::GetStartColumn()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_get_end_column"><b><code>Nan::GetEndColumn()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_clone_element_at"><b><code>Nan::CloneElementAt()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_has_private"><b><code>Nan::HasPrivate()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_get_private"><b><code>Nan::GetPrivate()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_set_private"><b><code>Nan::SetPrivate()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_delete_private"><b><code>Nan::DeletePrivate()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_make_maybe"><b><code>Nan::MakeMaybe()</code></b></a>
+
+### Script
+
+NAN provides `v8::Script` helpers as the API has changed over the supported versions of V8.
+
+ - <a href="doc/script.md#api_nan_compile_script"><b><code>Nan::CompileScript()</code></b></a>
+ - <a href="doc/script.md#api_nan_run_script"><b><code>Nan::RunScript()</code></b></a>
+ - <a href="doc/script.md#api_nan_script_origin"><b><code>Nan::ScriptOrigin</code></b></a>
+
+
+### JSON
+
+The _JSON_ object provides the C++ versions of the methods offered by the `JSON` object in javascript. V8 exposes these methods via the `v8::JSON` object.
+
+ - <a href="doc/json.md#api_nan_json_parse"><b><code>Nan::JSON.Parse</code></b></a>
+ - <a href="doc/json.md#api_nan_json_stringify"><b><code>Nan::JSON.Stringify</code></b></a>
+
+Refer to the V8 JSON object in the [V8 documentation](https://v8docs.nodesource.com/node-8.16/da/d6f/classv8_1_1_j_s_o_n.html) for more information about these methods and their arguments.
+
+### Errors
+
+NAN includes helpers for creating, throwing and catching Errors as much of this functionality varies across the supported versions of V8 and must be abstracted.
+
+Note that an Error object is simply a specialized form of `v8::Value`.
+
+Also consult the V8 Embedders Guide section on [Exceptions](https://developers.google.com/v8/embed#exceptions) for more information.
+
+ - <a href="doc/errors.md#api_nan_error"><b><code>Nan::Error()</code></b></a>
+ - <a href="doc/errors.md#api_nan_range_error"><b><code>Nan::RangeError()</code></b></a>
+ - <a href="doc/errors.md#api_nan_reference_error"><b><code>Nan::ReferenceError()</code></b></a>
+ - <a href="doc/errors.md#api_nan_syntax_error"><b><code>Nan::SyntaxError()</code></b></a>
+ - <a href="doc/errors.md#api_nan_type_error"><b><code>Nan::TypeError()</code></b></a>
+ - <a href="doc/errors.md#api_nan_throw_error"><b><code>Nan::ThrowError()</code></b></a>
+ - <a href="doc/errors.md#api_nan_throw_range_error"><b><code>Nan::ThrowRangeError()</code></b></a>
+ - <a href="doc/errors.md#api_nan_throw_reference_error"><b><code>Nan::ThrowReferenceError()</code></b></a>
+ - <a href="doc/errors.md#api_nan_throw_syntax_error"><b><code>Nan::ThrowSyntaxError()</code></b></a>
+ - <a href="doc/errors.md#api_nan_throw_type_error"><b><code>Nan::ThrowTypeError()</code></b></a>
+ - <a href="doc/errors.md#api_nan_fatal_exception"><b><code>Nan::FatalException()</code></b></a>
+ - <a href="doc/errors.md#api_nan_errno_exception"><b><code>Nan::ErrnoException()</code></b></a>
+ - <a href="doc/errors.md#api_nan_try_catch"><b><code>Nan::TryCatch</code></b></a>
+
+
+### Buffers
+
+NAN's `node::Buffer` helpers exist as the API has changed across supported Node versions. Use these methods to ensure compatibility.
+
+ - <a href="doc/buffers.md#api_nan_new_buffer"><b><code>Nan::NewBuffer()</code></b></a>
+ - <a href="doc/buffers.md#api_nan_copy_buffer"><b><code>Nan::CopyBuffer()</code></b></a>
+ - <a href="doc/buffers.md#api_nan_free_callback"><b><code>Nan::FreeCallback()</code></b></a>
+
+### Nan::Callback
+
+`Nan::Callback` makes it easier to use `v8::Function` handles as callbacks. A class that wraps a `v8::Function` handle, protecting it from garbage collection and making it particularly useful for storage and use across asynchronous execution.
+
+ - <a href="doc/callback.md#api_nan_callback"><b><code>Nan::Callback</code></b></a>
+
+### Asynchronous work helpers
+
+`Nan::AsyncWorker`, `Nan::AsyncProgressWorker` and `Nan::AsyncProgressQueueWorker` are helper classes that make working with asynchronous code easier.
+
+ - <a href="doc/asyncworker.md#api_nan_async_worker"><b><code>Nan::AsyncWorker</code></b></a>
+ - <a href="doc/asyncworker.md#api_nan_async_progress_worker"><b><code>Nan::AsyncProgressWorkerBase &amp; Nan::AsyncProgressWorker</code></b></a>
+ - <a href="doc/asyncworker.md#api_nan_async_progress_queue_worker"><b><code>Nan::AsyncProgressQueueWorker</code></b></a>
+ - <a href="doc/asyncworker.md#api_nan_async_queue_worker"><b><code>Nan::AsyncQueueWorker</code></b></a>
+
+### Strings & Bytes
+
+Miscellaneous string & byte encoding and decoding functionality provided for compatibility across supported versions of V8 and Node. Implemented by NAN to ensure that all encoding types are supported, even for older versions of Node where they are missing.
+
+ - <a href="doc/string_bytes.md#api_nan_encoding"><b><code>Nan::Encoding</code></b></a>
+ - <a href="doc/string_bytes.md#api_nan_encode"><b><code>Nan::Encode()</code></b></a>
+ - <a href="doc/string_bytes.md#api_nan_decode_bytes"><b><code>Nan::DecodeBytes()</code></b></a>
+ - <a href="doc/string_bytes.md#api_nan_decode_write"><b><code>Nan::DecodeWrite()</code></b></a>
+
+
+### Object Wrappers
+
+The `ObjectWrap` class can be used to make wrapped C++ objects and a factory of wrapped objects.
+
+ - <a href="doc/object_wrappers.md#api_nan_object_wrap"><b><code>Nan::ObjectWrap</code></b></a>
+
+
+### V8 internals
+
+The hooks to access V8 internals—including GC and statistics—are different across the supported versions of V8, therefore NAN provides its own hooks that call the appropriate V8 methods.
+
+ - <a href="doc/v8_internals.md#api_nan_gc_callback"><b><code>NAN_GC_CALLBACK()</code></b></a>
+ - <a href="doc/v8_internals.md#api_nan_add_gc_epilogue_callback"><b><code>Nan::AddGCEpilogueCallback()</code></b></a>
+ - <a href="doc/v8_internals.md#api_nan_remove_gc_epilogue_callback"><b><code>Nan::RemoveGCEpilogueCallback()</code></b></a>
+ - <a href="doc/v8_internals.md#api_nan_add_gc_prologue_callback"><b><code>Nan::AddGCPrologueCallback()</code></b></a>
+ - <a href="doc/v8_internals.md#api_nan_remove_gc_prologue_callback"><b><code>Nan::RemoveGCPrologueCallback()</code></b></a>
+ - <a href="doc/v8_internals.md#api_nan_get_heap_statistics"><b><code>Nan::GetHeapStatistics()</code></b></a>
+ - <a href="doc/v8_internals.md#api_nan_set_counter_function"><b><code>Nan::SetCounterFunction()</code></b></a>
+ - <a href="doc/v8_internals.md#api_nan_set_create_histogram_function"><b><code>Nan::SetCreateHistogramFunction()</code></b></a>
+ - <a href="doc/v8_internals.md#api_nan_set_add_histogram_sample_function"><b><code>Nan::SetAddHistogramSampleFunction()</code></b></a>
+ - <a href="doc/v8_internals.md#api_nan_idle_notification"><b><code>Nan::IdleNotification()</code></b></a>
+ - <a href="doc/v8_internals.md#api_nan_low_memory_notification"><b><code>Nan::LowMemoryNotification()</code></b></a>
+ - <a href="doc/v8_internals.md#api_nan_context_disposed_notification"><b><code>Nan::ContextDisposedNotification()</code></b></a>
+ - <a href="doc/v8_internals.md#api_nan_get_internal_field_pointer"><b><code>Nan::GetInternalFieldPointer()</code></b></a>
+ - <a href="doc/v8_internals.md#api_nan_set_internal_field_pointer"><b><code>Nan::SetInternalFieldPointer()</code></b></a>
+ - <a href="doc/v8_internals.md#api_nan_adjust_external_memory"><b><code>Nan::AdjustExternalMemory()</code></b></a>
+
+
+### Miscellaneous V8 Helpers
+
+ - <a href="doc/v8_misc.md#api_nan_utf8_string"><b><code>Nan::Utf8String</code></b></a>
+ - <a href="doc/v8_misc.md#api_nan_get_current_context"><b><code>Nan::GetCurrentContext()</code></b></a>
+ - <a href="doc/v8_misc.md#api_nan_set_isolate_data"><b><code>Nan::SetIsolateData()</code></b></a>
+ - <a href="doc/v8_misc.md#api_nan_get_isolate_data"><b><code>Nan::GetIsolateData()</code></b></a>
+ - <a href="doc/v8_misc.md#api_nan_typedarray_contents"><b><code>Nan::TypedArrayContents</code></b></a>
+
+
+### Miscellaneous Node Helpers
+
+ - <a href="doc/node_misc.md#api_nan_asyncresource"><b><code>Nan::AsyncResource</code></b></a>
+ - <a href="doc/node_misc.md#api_nan_make_callback"><b><code>Nan::MakeCallback()</code></b></a>
+ - <a href="doc/node_misc.md#api_nan_module_init"><b><code>NAN_MODULE_INIT()</code></b></a>
+ - <a href="doc/node_misc.md#api_nan_export"><b><code>Nan::Export()</code></b></a>
+
+<!-- END API -->
+
+
+<a name="tests"></a>
+
+### Tests
+
+To run the NAN tests do:
+
+``` sh
+npm install
+npm run-script rebuild-tests
+npm test
+```
+
+Or just:
+
+``` sh
+npm install
+make test
+```
+
+<a name="issues"></a>
+
+## Known issues
+
+### Compiling against Node.js 0.12 on OSX
+
+With new enough compilers available on OSX, the versions of V8 headers corresponding to Node.js 0.12
+do not compile anymore. The error looks something like:
+
+```
+❯ CXX(target) Release/obj.target/accessors/cpp/accessors.o
+In file included from ../cpp/accessors.cpp:9:
+In file included from ../../nan.h:51:
+In file included from /Users/ofrobots/.node-gyp/0.12.18/include/node/node.h:61:
+/Users/ofrobots/.node-gyp/0.12.18/include/node/v8.h:5800:54: error: 'CreateHandle' is a protected member of 'v8::HandleScope'
+ return Handle<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
+ ~~~~~~~~~~~~~^~~~~~~~~~~~
+```
+
+This can be worked around by patching your local versions of v8.h corresponding to Node 0.12 to make
+`v8::Handle` a friend of `v8::HandleScope`. Since neither Node.js not V8 support this release line anymore
+this patch cannot be released by either project in an official release.
+
+For this reason, we do not test against Node.js 0.12 on OSX in this project's CI. If you need to support
+that configuration, you will need to either get an older compiler, or apply a source patch to the version
+of V8 headers as a workaround.
+
+<a name="governance"></a>
+
+## Governance & Contributing
+
+NAN is governed by the [Node.js Addon API Working Group](https://github.com/nodejs/CTC/blob/master/WORKING_GROUPS.md#addon-api)
+
+### Addon API Working Group (WG)
+
+The NAN project is jointly governed by a Working Group which is responsible for high-level guidance of the project.
+
+Members of the WG are also known as Collaborators, there is no distinction between the two, unlike other Node.js projects.
+
+The WG has final authority over this project including:
+
+* Technical direction
+* Project governance and process (including this policy)
+* Contribution policy
+* GitHub repository hosting
+* Maintaining the list of additional Collaborators
+
+For the current list of WG members, see the project [README.md](./README.md#collaborators).
+
+Individuals making significant and valuable contributions are made members of the WG and given commit-access to the project. These individuals are identified by the WG and their addition to the WG is discussed via GitHub and requires unanimous consensus amongst those WG members participating in the discussion with a quorum of 50% of WG members required for acceptance of the vote.
+
+_Note:_ If you make a significant contribution and are not considered for commit-access log an issue or contact a WG member directly.
+
+For the current list of WG members / Collaborators, see the project [README.md](./README.md#collaborators).
+
+### Consensus Seeking Process
+
+The WG follows a [Consensus Seeking](https://en.wikipedia.org/wiki/Consensus-seeking_decision-making) decision making model.
+
+Modifications of the contents of the NAN repository are made on a collaborative basis. Anybody with a GitHub account may propose a modification via pull request and it will be considered by the WG. All pull requests must be reviewed and accepted by a WG member with sufficient expertise who is able to take full responsibility for the change. In the case of pull requests proposed by an existing WG member, an additional WG member is required for sign-off. Consensus should be sought if additional WG members participate and there is disagreement around a particular modification.
+
+If a change proposal cannot reach a consensus, a WG member can call for a vote amongst the members of the WG. Simple majority wins.
+
+<a id="developers-certificate-of-origin"></a>
+
+## Developer's Certificate of Origin 1.1
+
+By making a contribution to this project, I certify that:
+
+* (a) The contribution was created in whole or in part by me and I
+ have the right to submit it under the open source license
+ indicated in the file; or
+
+* (b) The contribution is based upon previous work that, to the best
+ of my knowledge, is covered under an appropriate open source
+ license and I have the right under that license to submit that
+ work with modifications, whether created in whole or in part
+ by me, under the same open source license (unless I am
+ permitted to submit under a different license), as indicated
+ in the file; or
+
+* (c) The contribution was provided directly to me by some other
+ person who certified (a), (b) or (c) and I have not modified
+ it.
+
+* (d) I understand and agree that this project and the contribution
+ are public and that a record of the contribution (including all
+ personal information I submit with it, including my sign-off) is
+ maintained indefinitely and may be redistributed consistent with
+ this project or the open source license(s) involved.
+
+<a name="collaborators"></a>
+
+### WG Members / Collaborators
+
+<table><tbody>
+<tr><th align="left">Rod Vagg</th><td><a href="https://github.com/rvagg">GitHub/rvagg</a></td><td><a href="http://twitter.com/rvagg">Twitter/@rvagg</a></td></tr>
+<tr><th align="left">Benjamin Byholm</th><td><a href="https://github.com/kkoopa/">GitHub/kkoopa</a></td><td>-</td></tr>
+<tr><th align="left">Trevor Norris</th><td><a href="https://github.com/trevnorris">GitHub/trevnorris</a></td><td><a href="http://twitter.com/trevnorris">Twitter/@trevnorris</a></td></tr>
+<tr><th align="left">Nathan Rajlich</th><td><a href="https://github.com/TooTallNate">GitHub/TooTallNate</a></td><td><a href="http://twitter.com/TooTallNate">Twitter/@TooTallNate</a></td></tr>
+<tr><th align="left">Brett Lawson</th><td><a href="https://github.com/brett19">GitHub/brett19</a></td><td><a href="http://twitter.com/brett19x">Twitter/@brett19x</a></td></tr>
+<tr><th align="left">Ben Noordhuis</th><td><a href="https://github.com/bnoordhuis">GitHub/bnoordhuis</a></td><td><a href="http://twitter.com/bnoordhuis">Twitter/@bnoordhuis</a></td></tr>
+<tr><th align="left">David Siegel</th><td><a href="https://github.com/agnat">GitHub/agnat</a></td><td><a href="http://twitter.com/agnat">Twitter/@agnat</a></td></tr>
+<tr><th align="left">Michael Ira Krufky</th><td><a href="https://github.com/mkrufky">GitHub/mkrufky</a></td><td><a href="http://twitter.com/mkrufky">Twitter/@mkrufky</a></td></tr>
+</tbody></table>
+
+## Licence &amp; copyright
+
+Copyright (c) 2018 NAN WG Members / Collaborators (listed above).
+
+Native Abstractions for Node.js is licensed under an MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.
diff --git a/node_modules/nan/doc/asyncworker.md b/node_modules/nan/doc/asyncworker.md
new file mode 100644
index 0000000..04231f8
--- /dev/null
+++ b/node_modules/nan/doc/asyncworker.md
@@ -0,0 +1,146 @@
+## Asynchronous work helpers
+
+`Nan::AsyncWorker`, `Nan::AsyncProgressWorker` and `Nan::AsyncProgressQueueWorker` are helper classes that make working with asynchronous code easier.
+
+ - <a href="#api_nan_async_worker"><b><code>Nan::AsyncWorker</code></b></a>
+ - <a href="#api_nan_async_progress_worker"><b><code>Nan::AsyncProgressWorkerBase &amp; Nan::AsyncProgressWorker</code></b></a>
+ - <a href="#api_nan_async_progress_queue_worker"><b><code>Nan::AsyncProgressQueueWorker</code></b></a>
+ - <a href="#api_nan_async_queue_worker"><b><code>Nan::AsyncQueueWorker</code></b></a>
+
+<a name="api_nan_async_worker"></a>
+### Nan::AsyncWorker
+
+`Nan::AsyncWorker` is an _abstract_ class that you can subclass to have much of the annoying asynchronous queuing and handling taken care of for you. It can even store arbitrary V8 objects for you and have them persist while the asynchronous work is in progress.
+
+This class internally handles the details of creating an [`AsyncResource`][AsyncResource], and running the callback in the
+correct async context. To be able to identify the async resources created by this class in async-hooks, provide a
+`resource_name` to the constructor. It is recommended that the module name be used as a prefix to the `resource_name` to avoid
+collisions in the names. For more details see [`AsyncResource`][AsyncResource] documentation. The `resource_name` needs to stay valid for the lifetime of the worker instance.
+
+Definition:
+
+```c++
+class AsyncWorker {
+ public:
+ explicit AsyncWorker(Callback *callback_, const char* resource_name = "nan:AsyncWorker");
+
+ virtual ~AsyncWorker();
+
+ virtual void WorkComplete();
+
+ void SaveToPersistent(const char *key, const v8::Local<v8::Value> &value);
+
+ void SaveToPersistent(const v8::Local<v8::String> &key,
+ const v8::Local<v8::Value> &value);
+
+ void SaveToPersistent(uint32_t index,
+ const v8::Local<v8::Value> &value);
+
+ v8::Local<v8::Value> GetFromPersistent(const char *key) const;
+
+ v8::Local<v8::Value> GetFromPersistent(const v8::Local<v8::String> &key) const;
+
+ v8::Local<v8::Value> GetFromPersistent(uint32_t index) const;
+
+ virtual void Execute() = 0;
+
+ uv_work_t request;
+
+ virtual void Destroy();
+
+ protected:
+ Persistent<v8::Object> persistentHandle;
+
+ Callback *callback;
+
+ virtual void HandleOKCallback();
+
+ virtual void HandleErrorCallback();
+
+ void SetErrorMessage(const char *msg);
+
+ const char* ErrorMessage();
+};
+```
+
+<a name="api_nan_async_progress_worker"></a>
+### Nan::AsyncProgressWorkerBase &amp; Nan::AsyncProgressWorker
+
+`Nan::AsyncProgressWorkerBase` is an _abstract_ class template that extends `Nan::AsyncWorker` and adds additional progress reporting callbacks that can be used during the asynchronous work execution to provide progress data back to JavaScript.
+
+Previously the definition of `Nan::AsyncProgressWorker` only allowed sending `const char` data. Now extending `Nan::AsyncProgressWorker` will yield an instance of the implicit `Nan::AsyncProgressWorkerBase` template with type `<char>` for compatibility.
+
+`Nan::AsyncProgressWorkerBase` &amp; `Nan::AsyncProgressWorker` is intended for best-effort delivery of nonessential progress messages, e.g. a progress bar. The last event sent before the main thread is woken will be delivered.
+
+Definition:
+
+```c++
+template<class T>
+class AsyncProgressWorkerBase<T> : public AsyncWorker {
+ public:
+ explicit AsyncProgressWorkerBase(Callback *callback_, const char* resource_name = ...);
+
+ virtual ~AsyncProgressWorkerBase();
+
+ void WorkProgress();
+
+ class ExecutionProgress {
+ public:
+ void Signal() const;
+ void Send(const T* data, size_t count) const;
+ };
+
+ virtual void Execute(const ExecutionProgress& progress) = 0;
+
+ virtual void HandleProgressCallback(const T *data, size_t count) = 0;
+
+ virtual void Destroy();
+};
+
+typedef AsyncProgressWorkerBase<T> AsyncProgressWorker;
+```
+
+<a name="api_nan_async_progress_queue_worker"></a>
+### Nan::AsyncProgressQueueWorker
+
+`Nan::AsyncProgressQueueWorker` is an _abstract_ class template that extends `Nan::AsyncWorker` and adds additional progress reporting callbacks that can be used during the asynchronous work execution to provide progress data back to JavaScript.
+
+`Nan::AsyncProgressQueueWorker` behaves exactly the same as `Nan::AsyncProgressWorker`, except all events are queued and delivered to the main thread.
+
+Definition:
+
+```c++
+template<class T>
+class AsyncProgressQueueWorker<T> : public AsyncWorker {
+ public:
+ explicit AsyncProgressQueueWorker(Callback *callback_, const char* resource_name = "nan:AsyncProgressQueueWorker");
+
+ virtual ~AsyncProgressQueueWorker();
+
+ void WorkProgress();
+
+ class ExecutionProgress {
+ public:
+ void Send(const T* data, size_t count) const;
+ };
+
+ virtual void Execute(const ExecutionProgress& progress) = 0;
+
+ virtual void HandleProgressCallback(const T *data, size_t count) = 0;
+
+ virtual void Destroy();
+};
+```
+
+<a name="api_nan_async_queue_worker"></a>
+### Nan::AsyncQueueWorker
+
+`Nan::AsyncQueueWorker` will run a `Nan::AsyncWorker` asynchronously via libuv. Both the `execute` and `after_work` steps are taken care of for you. Most of the logic for this is embedded in `Nan::AsyncWorker`.
+
+Definition:
+
+```c++
+void AsyncQueueWorker(AsyncWorker *);
+```
+
+[AsyncResource]: node_misc.md#api_nan_asyncresource
diff --git a/node_modules/nan/doc/buffers.md b/node_modules/nan/doc/buffers.md
new file mode 100644
index 0000000..8d8d25c
--- /dev/null
+++ b/node_modules/nan/doc/buffers.md
@@ -0,0 +1,54 @@
+## Buffers
+
+NAN's `node::Buffer` helpers exist as the API has changed across supported Node versions. Use these methods to ensure compatibility.
+
+ - <a href="#api_nan_new_buffer"><b><code>Nan::NewBuffer()</code></b></a>
+ - <a href="#api_nan_copy_buffer"><b><code>Nan::CopyBuffer()</code></b></a>
+ - <a href="#api_nan_free_callback"><b><code>Nan::FreeCallback()</code></b></a>
+
+<a name="api_nan_new_buffer"></a>
+### Nan::NewBuffer()
+
+Allocate a new `node::Buffer` object with the specified size and optional data. Calls `node::Buffer::New()`.
+
+Note that when creating a `Buffer` using `Nan::NewBuffer()` and an existing `char*`, it is assumed that the ownership of the pointer is being transferred to the new `Buffer` for management.
+When a `node::Buffer` instance is garbage collected and a `FreeCallback` has not been specified, `data` will be disposed of via a call to `free()`.
+You _must not_ free the memory space manually once you have created a `Buffer` in this way.
+
+Signature:
+
+```c++
+Nan::MaybeLocal<v8::Object> Nan::NewBuffer(uint32_t size)
+Nan::MaybeLocal<v8::Object> Nan::NewBuffer(char* data, uint32_t size)
+Nan::MaybeLocal<v8::Object> Nan::NewBuffer(char *data,
+ size_t length,
+ Nan::FreeCallback callback,
+ void *hint)
+```
+
+
+<a name="api_nan_copy_buffer"></a>
+### Nan::CopyBuffer()
+
+Similar to [`Nan::NewBuffer()`](#api_nan_new_buffer) except that an implicit memcpy will occur within Node. Calls `node::Buffer::Copy()`.
+
+Management of the `char*` is left to the user, you should manually free the memory space if necessary as the new `Buffer` will have its own copy.
+
+Signature:
+
+```c++
+Nan::MaybeLocal<v8::Object> Nan::CopyBuffer(const char *data, uint32_t size)
+```
+
+
+<a name="api_nan_free_callback"></a>
+### Nan::FreeCallback()
+
+A free callback that can be provided to [`Nan::NewBuffer()`](#api_nan_new_buffer).
+The supplied callback will be invoked when the `Buffer` undergoes garbage collection.
+
+Signature:
+
+```c++
+typedef void (*FreeCallback)(char *data, void *hint);
+```
diff --git a/node_modules/nan/doc/callback.md b/node_modules/nan/doc/callback.md
new file mode 100644
index 0000000..f7af0bf
--- /dev/null
+++ b/node_modules/nan/doc/callback.md
@@ -0,0 +1,76 @@
+## Nan::Callback
+
+`Nan::Callback` makes it easier to use `v8::Function` handles as callbacks. A class that wraps a `v8::Function` handle, protecting it from garbage collection and making it particularly useful for storage and use across asynchronous execution.
+
+ - <a href="#api_nan_callback"><b><code>Nan::Callback</code></b></a>
+
+<a name="api_nan_callback"></a>
+### Nan::Callback
+
+```c++
+class Callback {
+ public:
+ Callback();
+
+ explicit Callback(const v8::Local<v8::Function> &fn);
+
+ ~Callback();
+
+ bool operator==(const Callback &other) const;
+
+ bool operator!=(const Callback &other) const;
+
+ v8::Local<v8::Function> operator*() const;
+
+ MaybeLocal<v8::Value> operator()(AsyncResource* async_resource,
+ v8::Local<v8::Object> target,
+ int argc = 0,
+ v8::Local<v8::Value> argv[] = 0) const;
+
+ MaybeLocal<v8::Value> operator()(AsyncResource* async_resource,
+ int argc = 0,
+ v8::Local<v8::Value> argv[] = 0) const;
+
+ void SetFunction(const v8::Local<v8::Function> &fn);
+
+ v8::Local<v8::Function> GetFunction() const;
+
+ bool IsEmpty() const;
+
+ void Reset(const v8::Local<v8::Function> &fn);
+
+ void Reset();
+
+ MaybeLocal<v8::Value> Call(v8::Local<v8::Object> target,
+ int argc,
+ v8::Local<v8::Value> argv[],
+ AsyncResource* async_resource) const;
+ MaybeLocal<v8::Value> Call(int argc,
+ v8::Local<v8::Value> argv[],
+ AsyncResource* async_resource) const;
+
+ // Deprecated versions. Use the versions that accept an async_resource instead
+ // as they run the callback in the correct async context as specified by the
+ // resource. If you want to call a synchronous JS function (i.e. on a
+ // non-empty JS stack), you can use Nan::Call instead.
+ v8::Local<v8::Value> operator()(v8::Local<v8::Object> target,
+ int argc = 0,
+ v8::Local<v8::Value> argv[] = 0) const;
+
+ v8::Local<v8::Value> operator()(int argc = 0,
+ v8::Local<v8::Value> argv[] = 0) const;
+ v8::Local<v8::Value> Call(v8::Local<v8::Object> target,
+ int argc,
+ v8::Local<v8::Value> argv[]) const;
+
+ v8::Local<v8::Value> Call(int argc, v8::Local<v8::Value> argv[]) const;
+};
+```
+
+Example usage:
+
+```c++
+v8::Local<v8::Function> function;
+Nan::Callback callback(function);
+callback.Call(0, 0);
+```
diff --git a/node_modules/nan/doc/converters.md b/node_modules/nan/doc/converters.md
new file mode 100644
index 0000000..d20861b
--- /dev/null
+++ b/node_modules/nan/doc/converters.md
@@ -0,0 +1,41 @@
+## Converters
+
+NAN contains functions that convert `v8::Value`s to other `v8::Value` types and native types. Since type conversion is not guaranteed to succeed, they return `Nan::Maybe` types. These converters can be used in place of `value->ToX()` and `value->XValue()` (where `X` is one of the types, e.g. `Boolean`) in a way that provides a consistent interface across V8 versions. Newer versions of V8 use the new `v8::Maybe` and `v8::MaybeLocal` types for these conversions, older versions don't have this functionality so it is provided by NAN.
+
+ - <a href="#api_nan_to"><b><code>Nan::To()</code></b></a>
+
+<a name="api_nan_to"></a>
+### Nan::To()
+
+Converts a `v8::Local<v8::Value>` to a different subtype of `v8::Value` or to a native data type. Returns a `Nan::MaybeLocal<>` or a `Nan::Maybe<>` accordingly.
+
+See [maybe_types.md](./maybe_types.md) for more information on `Nan::Maybe` types.
+
+Signatures:
+
+```c++
+// V8 types
+Nan::MaybeLocal<v8::Boolean> Nan::To<v8::Boolean>(v8::Local<v8::Value> val);
+Nan::MaybeLocal<v8::Int32> Nan::To<v8::Int32>(v8::Local<v8::Value> val);
+Nan::MaybeLocal<v8::Integer> Nan::To<v8::Integer>(v8::Local<v8::Value> val);
+Nan::MaybeLocal<v8::Object> Nan::To<v8::Object>(v8::Local<v8::Value> val);
+Nan::MaybeLocal<v8::Number> Nan::To<v8::Number>(v8::Local<v8::Value> val);
+Nan::MaybeLocal<v8::String> Nan::To<v8::String>(v8::Local<v8::Value> val);
+Nan::MaybeLocal<v8::Uint32> Nan::To<v8::Uint32>(v8::Local<v8::Value> val);
+
+// Native types
+Nan::Maybe<bool> Nan::To<bool>(v8::Local<v8::Value> val);
+Nan::Maybe<double> Nan::To<double>(v8::Local<v8::Value> val);
+Nan::Maybe<int32_t> Nan::To<int32_t>(v8::Local<v8::Value> val);
+Nan::Maybe<int64_t> Nan::To<int64_t>(v8::Local<v8::Value> val);
+Nan::Maybe<uint32_t> Nan::To<uint32_t>(v8::Local<v8::Value> val);
+```
+
+### Example
+
+```c++
+v8::Local<v8::Value> val;
+Nan::MaybeLocal<v8::String> str = Nan::To<v8::String>(val);
+Nan::Maybe<double> d = Nan::To<double>(val);
+```
+
diff --git a/node_modules/nan/doc/errors.md b/node_modules/nan/doc/errors.md
new file mode 100644
index 0000000..843435b
--- /dev/null
+++ b/node_modules/nan/doc/errors.md
@@ -0,0 +1,226 @@
+## Errors
+
+NAN includes helpers for creating, throwing and catching Errors as much of this functionality varies across the supported versions of V8 and must be abstracted.
+
+Note that an Error object is simply a specialized form of `v8::Value`.
+
+Also consult the V8 Embedders Guide section on [Exceptions](https://developers.google.com/v8/embed#exceptions) for more information.
+
+ - <a href="#api_nan_error"><b><code>Nan::Error()</code></b></a>
+ - <a href="#api_nan_range_error"><b><code>Nan::RangeError()</code></b></a>
+ - <a href="#api_nan_reference_error"><b><code>Nan::ReferenceError()</code></b></a>
+ - <a href="#api_nan_syntax_error"><b><code>Nan::SyntaxError()</code></b></a>
+ - <a href="#api_nan_type_error"><b><code>Nan::TypeError()</code></b></a>
+ - <a href="#api_nan_throw_error"><b><code>Nan::ThrowError()</code></b></a>
+ - <a href="#api_nan_throw_range_error"><b><code>Nan::ThrowRangeError()</code></b></a>
+ - <a href="#api_nan_throw_reference_error"><b><code>Nan::ThrowReferenceError()</code></b></a>
+ - <a href="#api_nan_throw_syntax_error"><b><code>Nan::ThrowSyntaxError()</code></b></a>
+ - <a href="#api_nan_throw_type_error"><b><code>Nan::ThrowTypeError()</code></b></a>
+ - <a href="#api_nan_fatal_exception"><b><code>Nan::FatalException()</code></b></a>
+ - <a href="#api_nan_errno_exception"><b><code>Nan::ErrnoException()</code></b></a>
+ - <a href="#api_nan_try_catch"><b><code>Nan::TryCatch</code></b></a>
+
+
+<a name="api_nan_error"></a>
+### Nan::Error()
+
+Create a new Error object using the [v8::Exception](https://v8docs.nodesource.com/node-8.16/da/d6a/classv8_1_1_exception.html) class in a way that is compatible across the supported versions of V8.
+
+Note that an Error object is simply a specialized form of `v8::Value`.
+
+Signature:
+
+```c++
+v8::Local<v8::Value> Nan::Error(const char *msg);
+v8::Local<v8::Value> Nan::Error(v8::Local<v8::String> msg);
+```
+
+
+<a name="api_nan_range_error"></a>
+### Nan::RangeError()
+
+Create a new RangeError object using the [v8::Exception](https://v8docs.nodesource.com/node-8.16/da/d6a/classv8_1_1_exception.html) class in a way that is compatible across the supported versions of V8.
+
+Note that an RangeError object is simply a specialized form of `v8::Value`.
+
+Signature:
+
+```c++
+v8::Local<v8::Value> Nan::RangeError(const char *msg);
+v8::Local<v8::Value> Nan::RangeError(v8::Local<v8::String> msg);
+```
+
+
+<a name="api_nan_reference_error"></a>
+### Nan::ReferenceError()
+
+Create a new ReferenceError object using the [v8::Exception](https://v8docs.nodesource.com/node-8.16/da/d6a/classv8_1_1_exception.html) class in a way that is compatible across the supported versions of V8.
+
+Note that an ReferenceError object is simply a specialized form of `v8::Value`.
+
+Signature:
+
+```c++
+v8::Local<v8::Value> Nan::ReferenceError(const char *msg);
+v8::Local<v8::Value> Nan::ReferenceError(v8::Local<v8::String> msg);
+```
+
+
+<a name="api_nan_syntax_error"></a>
+### Nan::SyntaxError()
+
+Create a new SyntaxError object using the [v8::Exception](https://v8docs.nodesource.com/node-8.16/da/d6a/classv8_1_1_exception.html) class in a way that is compatible across the supported versions of V8.
+
+Note that an SyntaxError object is simply a specialized form of `v8::Value`.
+
+Signature:
+
+```c++
+v8::Local<v8::Value> Nan::SyntaxError(const char *msg);
+v8::Local<v8::Value> Nan::SyntaxError(v8::Local<v8::String> msg);
+```
+
+
+<a name="api_nan_type_error"></a>
+### Nan::TypeError()
+
+Create a new TypeError object using the [v8::Exception](https://v8docs.nodesource.com/node-8.16/da/d6a/classv8_1_1_exception.html) class in a way that is compatible across the supported versions of V8.
+
+Note that an TypeError object is simply a specialized form of `v8::Value`.
+
+Signature:
+
+```c++
+v8::Local<v8::Value> Nan::TypeError(const char *msg);
+v8::Local<v8::Value> Nan::TypeError(v8::Local<v8::String> msg);
+```
+
+
+<a name="api_nan_throw_error"></a>
+### Nan::ThrowError()
+
+Throw an Error object (a specialized `v8::Value` as above) in the current context. If a `msg` is provided, a new Error object will be created.
+
+Signature:
+
+```c++
+void Nan::ThrowError(const char *msg);
+void Nan::ThrowError(v8::Local<v8::String> msg);
+void Nan::ThrowError(v8::Local<v8::Value> error);
+```
+
+
+<a name="api_nan_throw_range_error"></a>
+### Nan::ThrowRangeError()
+
+Throw an RangeError object (a specialized `v8::Value` as above) in the current context. If a `msg` is provided, a new RangeError object will be created.
+
+Signature:
+
+```c++
+void Nan::ThrowRangeError(const char *msg);
+void Nan::ThrowRangeError(v8::Local<v8::String> msg);
+void Nan::ThrowRangeError(v8::Local<v8::Value> error);
+```
+
+
+<a name="api_nan_throw_reference_error"></a>
+### Nan::ThrowReferenceError()
+
+Throw an ReferenceError object (a specialized `v8::Value` as above) in the current context. If a `msg` is provided, a new ReferenceError object will be created.
+
+Signature:
+
+```c++
+void Nan::ThrowReferenceError(const char *msg);
+void Nan::ThrowReferenceError(v8::Local<v8::String> msg);
+void Nan::ThrowReferenceError(v8::Local<v8::Value> error);
+```
+
+
+<a name="api_nan_throw_syntax_error"></a>
+### Nan::ThrowSyntaxError()
+
+Throw an SyntaxError object (a specialized `v8::Value` as above) in the current context. If a `msg` is provided, a new SyntaxError object will be created.
+
+Signature:
+
+```c++
+void Nan::ThrowSyntaxError(const char *msg);
+void Nan::ThrowSyntaxError(v8::Local<v8::String> msg);
+void Nan::ThrowSyntaxError(v8::Local<v8::Value> error);
+```
+
+
+<a name="api_nan_throw_type_error"></a>
+### Nan::ThrowTypeError()
+
+Throw an TypeError object (a specialized `v8::Value` as above) in the current context. If a `msg` is provided, a new TypeError object will be created.
+
+Signature:
+
+```c++
+void Nan::ThrowTypeError(const char *msg);
+void Nan::ThrowTypeError(v8::Local<v8::String> msg);
+void Nan::ThrowTypeError(v8::Local<v8::Value> error);
+```
+
+<a name="api_nan_fatal_exception"></a>
+### Nan::FatalException()
+
+Replaces `node::FatalException()` which has a different API across supported versions of Node. For use with [`Nan::TryCatch`](#api_nan_try_catch).
+
+Signature:
+
+```c++
+void Nan::FatalException(const Nan::TryCatch& try_catch);
+```
+
+<a name="api_nan_errno_exception"></a>
+### Nan::ErrnoException()
+
+Replaces `node::ErrnoException()` which has a different API across supported versions of Node.
+
+Signature:
+
+```c++
+v8::Local<v8::Value> Nan::ErrnoException(int errorno,
+ const char* syscall = NULL,
+ const char* message = NULL,
+ const char* path = NULL);
+```
+
+
+<a name="api_nan_try_catch"></a>
+### Nan::TryCatch
+
+A simple wrapper around [`v8::TryCatch`](https://v8docs.nodesource.com/node-8.16/d4/dc6/classv8_1_1_try_catch.html) compatible with all supported versions of V8. Can be used as a direct replacement in most cases. See also [`Nan::FatalException()`](#api_nan_fatal_exception) for an internal use compatible with `node::FatalException`.
+
+Signature:
+
+```c++
+class Nan::TryCatch {
+ public:
+ Nan::TryCatch();
+
+ bool HasCaught() const;
+
+ bool CanContinue() const;
+
+ v8::Local<v8::Value> ReThrow();
+
+ v8::Local<v8::Value> Exception() const;
+
+ // Nan::MaybeLocal for older versions of V8
+ v8::MaybeLocal<v8::Value> StackTrace() const;
+
+ v8::Local<v8::Message> Message() const;
+
+ void Reset();
+
+ void SetVerbose(bool value);
+
+ void SetCaptureMessage(bool value);
+};
+```
+
diff --git a/node_modules/nan/doc/json.md b/node_modules/nan/doc/json.md
new file mode 100644
index 0000000..55beb26
--- /dev/null
+++ b/node_modules/nan/doc/json.md
@@ -0,0 +1,62 @@
+## JSON
+
+The _JSON_ object provides the C++ versions of the methods offered by the `JSON` object in javascript. V8 exposes these methods via the `v8::JSON` object.
+
+ - <a href="#api_nan_json_parse"><b><code>Nan::JSON.Parse</code></b></a>
+ - <a href="#api_nan_json_stringify"><b><code>Nan::JSON.Stringify</code></b></a>
+
+Refer to the V8 JSON object in the [V8 documentation](https://v8docs.nodesource.com/node-8.16/da/d6f/classv8_1_1_j_s_o_n.html) for more information about these methods and their arguments.
+
+<a name="api_nan_json_parse"></a>
+
+### Nan::JSON.Parse
+
+A simple wrapper around [`v8::JSON::Parse`](https://v8docs.nodesource.com/node-8.16/da/d6f/classv8_1_1_j_s_o_n.html#a936310d2540fb630ed37d3ee3ffe4504).
+
+Definition:
+
+```c++
+Nan::MaybeLocal<v8::Value> Nan::JSON::Parse(v8::Local<v8::String> json_string);
+```
+
+Use `JSON.Parse(json_string)` to parse a string into a `v8::Value`.
+
+Example:
+
+```c++
+v8::Local<v8::String> json_string = Nan::New("{ \"JSON\": \"object\" }").ToLocalChecked();
+
+Nan::JSON NanJSON;
+Nan::MaybeLocal<v8::Value> result = NanJSON.Parse(json_string);
+if (!result.IsEmpty()) {
+ v8::Local<v8::Value> val = result.ToLocalChecked();
+}
+```
+
+<a name="api_nan_json_stringify"></a>
+
+### Nan::JSON.Stringify
+
+A simple wrapper around [`v8::JSON::Stringify`](https://v8docs.nodesource.com/node-8.16/da/d6f/classv8_1_1_j_s_o_n.html#a44b255c3531489ce43f6110209138860).
+
+Definition:
+
+```c++
+Nan::MaybeLocal<v8::String> Nan::JSON::Stringify(v8::Local<v8::Object> json_object, v8::Local<v8::String> gap = v8::Local<v8::String>());
+```
+
+Use `JSON.Stringify(value)` to stringify a `v8::Object`.
+
+Example:
+
+```c++
+// using `v8::Local<v8::Value> val` from the `JSON::Parse` example
+v8::Local<v8::Object> obj = Nan::To<v8::Object>(val).ToLocalChecked();
+
+Nan::JSON NanJSON;
+Nan::MaybeLocal<v8::String> result = NanJSON.Stringify(obj);
+if (!result.IsEmpty()) {
+ v8::Local<v8::String> stringified = result.ToLocalChecked();
+}
+```
+
diff --git a/node_modules/nan/doc/maybe_types.md b/node_modules/nan/doc/maybe_types.md
new file mode 100644
index 0000000..142851a
--- /dev/null
+++ b/node_modules/nan/doc/maybe_types.md
@@ -0,0 +1,583 @@
+## Maybe Types
+
+The `Nan::MaybeLocal` and `Nan::Maybe` types are monads that encapsulate `v8::Local` handles that _may be empty_.
+
+* **Maybe Types**
+ - <a href="#api_nan_maybe_local"><b><code>Nan::MaybeLocal</code></b></a>
+ - <a href="#api_nan_maybe"><b><code>Nan::Maybe</code></b></a>
+ - <a href="#api_nan_nothing"><b><code>Nan::Nothing</code></b></a>
+ - <a href="#api_nan_just"><b><code>Nan::Just</code></b></a>
+* **Maybe Helpers**
+ - <a href="#api_nan_call"><b><code>Nan::Call()</code></b></a>
+ - <a href="#api_nan_to_detail_string"><b><code>Nan::ToDetailString()</code></b></a>
+ - <a href="#api_nan_to_array_index"><b><code>Nan::ToArrayIndex()</code></b></a>
+ - <a href="#api_nan_equals"><b><code>Nan::Equals()</code></b></a>
+ - <a href="#api_nan_new_instance"><b><code>Nan::NewInstance()</code></b></a>
+ - <a href="#api_nan_get_function"><b><code>Nan::GetFunction()</code></b></a>
+ - <a href="#api_nan_set"><b><code>Nan::Set()</code></b></a>
+ - <a href="#api_nan_define_own_property"><b><code>Nan::DefineOwnProperty()</code></b></a>
+ - <a href="#api_nan_force_set"><del><b><code>Nan::ForceSet()</code></b></del></a>
+ - <a href="#api_nan_get"><b><code>Nan::Get()</code></b></a>
+ - <a href="#api_nan_get_property_attribute"><b><code>Nan::GetPropertyAttributes()</code></b></a>
+ - <a href="#api_nan_has"><b><code>Nan::Has()</code></b></a>
+ - <a href="#api_nan_delete"><b><code>Nan::Delete()</code></b></a>
+ - <a href="#api_nan_get_property_names"><b><code>Nan::GetPropertyNames()</code></b></a>
+ - <a href="#api_nan_get_own_property_names"><b><code>Nan::GetOwnPropertyNames()</code></b></a>
+ - <a href="#api_nan_set_prototype"><b><code>Nan::SetPrototype()</code></b></a>
+ - <a href="#api_nan_object_proto_to_string"><b><code>Nan::ObjectProtoToString()</code></b></a>
+ - <a href="#api_nan_has_own_property"><b><code>Nan::HasOwnProperty()</code></b></a>
+ - <a href="#api_nan_has_real_named_property"><b><code>Nan::HasRealNamedProperty()</code></b></a>
+ - <a href="#api_nan_has_real_indexed_property"><b><code>Nan::HasRealIndexedProperty()</code></b></a>
+ - <a href="#api_nan_has_real_named_callback_property"><b><code>Nan::HasRealNamedCallbackProperty()</code></b></a>
+ - <a href="#api_nan_get_real_named_property_in_prototype_chain"><b><code>Nan::GetRealNamedPropertyInPrototypeChain()</code></b></a>
+ - <a href="#api_nan_get_real_named_property"><b><code>Nan::GetRealNamedProperty()</code></b></a>
+ - <a href="#api_nan_call_as_function"><b><code>Nan::CallAsFunction()</code></b></a>
+ - <a href="#api_nan_call_as_constructor"><b><code>Nan::CallAsConstructor()</code></b></a>
+ - <a href="#api_nan_get_source_line"><b><code>Nan::GetSourceLine()</code></b></a>
+ - <a href="#api_nan_get_line_number"><b><code>Nan::GetLineNumber()</code></b></a>
+ - <a href="#api_nan_get_start_column"><b><code>Nan::GetStartColumn()</code></b></a>
+ - <a href="#api_nan_get_end_column"><b><code>Nan::GetEndColumn()</code></b></a>
+ - <a href="#api_nan_clone_element_at"><b><code>Nan::CloneElementAt()</code></b></a>
+ - <a href="#api_nan_has_private"><b><code>Nan::HasPrivate()</code></b></a>
+ - <a href="#api_nan_get_private"><b><code>Nan::GetPrivate()</code></b></a>
+ - <a href="#api_nan_set_private"><b><code>Nan::SetPrivate()</code></b></a>
+ - <a href="#api_nan_delete_private"><b><code>Nan::DeletePrivate()</code></b></a>
+ - <a href="#api_nan_make_maybe"><b><code>Nan::MakeMaybe()</code></b></a>
+
+<a name="api_nan_maybe_local"></a>
+### Nan::MaybeLocal
+
+A `Nan::MaybeLocal<T>` is a wrapper around [`v8::Local<T>`](https://v8docs.nodesource.com/node-8.16/de/deb/classv8_1_1_local.html) that enforces a check that determines whether the `v8::Local<T>` is empty before it can be used.
+
+If an API method returns a `Nan::MaybeLocal`, the API method can potentially fail either because an exception is thrown, or because an exception is pending, e.g. because a previous API call threw an exception that hasn't been caught yet, or because a `v8::TerminateExecution` exception was thrown. In that case, an empty `Nan::MaybeLocal` is returned.
+
+Definition:
+
+```c++
+template<typename T> class Nan::MaybeLocal {
+ public:
+ MaybeLocal();
+
+ template<typename S> MaybeLocal(v8::Local<S> that);
+
+ bool IsEmpty() const;
+
+ template<typename S> bool ToLocal(v8::Local<S> *out);
+
+ // Will crash if the MaybeLocal<> is empty.
+ v8::Local<T> ToLocalChecked();
+
+ template<typename S> v8::Local<S> FromMaybe(v8::Local<S> default_value) const;
+};
+```
+
+See the documentation for [`v8::MaybeLocal`](https://v8docs.nodesource.com/node-8.16/d8/d7d/classv8_1_1_maybe_local.html) for further details.
+
+<a name="api_nan_maybe"></a>
+### Nan::Maybe
+
+A simple `Nan::Maybe` type, representing an object which may or may not have a value, see https://hackage.haskell.org/package/base/docs/Data-Maybe.html.
+
+If an API method returns a `Nan::Maybe<>`, the API method can potentially fail either because an exception is thrown, or because an exception is pending, e.g. because a previous API call threw an exception that hasn't been caught yet, or because a `v8::TerminateExecution` exception was thrown. In that case, a "Nothing" value is returned.
+
+Definition:
+
+```c++
+template<typename T> class Nan::Maybe {
+ public:
+ bool IsNothing() const;
+ bool IsJust() const;
+
+ // Will crash if the Maybe<> is nothing.
+ T FromJust();
+
+ T FromMaybe(const T& default_value);
+
+ bool operator==(const Maybe &other);
+
+ bool operator!=(const Maybe &other);
+};
+```
+
+See the documentation for [`v8::Maybe`](https://v8docs.nodesource.com/node-8.16/d9/d4b/classv8_1_1_maybe.html) for further details.
+
+<a name="api_nan_nothing"></a>
+### Nan::Nothing
+
+Construct an empty `Nan::Maybe` type representing _nothing_.
+
+```c++
+template<typename T> Nan::Maybe<T> Nan::Nothing();
+```
+
+<a name="api_nan_just"></a>
+### Nan::Just
+
+Construct a `Nan::Maybe` type representing _just_ a value.
+
+```c++
+template<typename T> Nan::Maybe<T> Nan::Just(const T &t);
+```
+
+<a name="api_nan_call"></a>
+### Nan::Call()
+
+A helper method for calling a synchronous [`v8::Function#Call()`](https://v8docs.nodesource.com/node-8.16/d5/d54/classv8_1_1_function.html#a9c3d0e4e13ddd7721fce238aa5b94a11) in a way compatible across supported versions of V8.
+
+For asynchronous callbacks, use Nan::Callback::Call along with an AsyncResource.
+
+Signature:
+
+```c++
+Nan::MaybeLocal<v8::Value> Nan::Call(v8::Local<v8::Function> fun, v8::Local<v8::Object> recv, int argc, v8::Local<v8::Value> argv[]);
+Nan::MaybeLocal<v8::Value> Nan::Call(const Nan::Callback& callback, v8::Local<v8::Object> recv,
+ int argc, v8::Local<v8::Value> argv[]);
+Nan::MaybeLocal<v8::Value> Nan::Call(const Nan::Callback& callback, int argc, v8::Local<v8::Value> argv[]);
+```
+
+
+<a name="api_nan_to_detail_string"></a>
+### Nan::ToDetailString()
+
+A helper method for calling [`v8::Value#ToDetailString()`](https://v8docs.nodesource.com/node-8.16/dc/d0a/classv8_1_1_value.html#a2f9770296dc2c8d274bc8cc0dca243e5) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::MaybeLocal<v8::String> Nan::ToDetailString(v8::Local<v8::Value> val);
+```
+
+
+<a name="api_nan_to_array_index"></a>
+### Nan::ToArrayIndex()
+
+A helper method for calling [`v8::Value#ToArrayIndex()`](https://v8docs.nodesource.com/node-8.16/dc/d0a/classv8_1_1_value.html#acc5bbef3c805ec458470c0fcd6f13493) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::MaybeLocal<v8::Uint32> Nan::ToArrayIndex(v8::Local<v8::Value> val);
+```
+
+
+<a name="api_nan_equals"></a>
+### Nan::Equals()
+
+A helper method for calling [`v8::Value#Equals()`](https://v8docs.nodesource.com/node-8.16/dc/d0a/classv8_1_1_value.html#a08fba1d776a59bbf6864b25f9152c64b) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::Maybe<bool> Nan::Equals(v8::Local<v8::Value> a, v8::Local<v8::Value>(b));
+```
+
+
+<a name="api_nan_new_instance"></a>
+### Nan::NewInstance()
+
+A helper method for calling [`v8::Function#NewInstance()`](https://v8docs.nodesource.com/node-8.16/d5/d54/classv8_1_1_function.html#ae477558b10c14b76ed00e8dbab44ce5b) and [`v8::ObjectTemplate#NewInstance()`](https://v8docs.nodesource.com/node-8.16/db/d5f/classv8_1_1_object_template.html#ad605a7543cfbc5dab54cdb0883d14ae4) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::MaybeLocal<v8::Object> Nan::NewInstance(v8::Local<v8::Function> h);
+Nan::MaybeLocal<v8::Object> Nan::NewInstance(v8::Local<v8::Function> h, int argc, v8::Local<v8::Value> argv[]);
+Nan::MaybeLocal<v8::Object> Nan::NewInstance(v8::Local<v8::ObjectTemplate> h);
+```
+
+
+<a name="api_nan_get_function"></a>
+### Nan::GetFunction()
+
+A helper method for calling [`v8::FunctionTemplate#GetFunction()`](https://v8docs.nodesource.com/node-8.16/d8/d83/classv8_1_1_function_template.html#a56d904662a86eca78da37d9bb0ed3705) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::MaybeLocal<v8::Function> Nan::GetFunction(v8::Local<v8::FunctionTemplate> t);
+```
+
+
+<a name="api_nan_set"></a>
+### Nan::Set()
+
+A helper method for calling [`v8::Object#Set()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#a67604ea3734f170c66026064ea808f20) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::Maybe<bool> Nan::Set(v8::Local<v8::Object> obj,
+ v8::Local<v8::Value> key,
+ v8::Local<v8::Value> value)
+Nan::Maybe<bool> Nan::Set(v8::Local<v8::Object> obj,
+ uint32_t index,
+ v8::Local<v8::Value> value);
+```
+
+
+<a name="api_nan_define_own_property"></a>
+### Nan::DefineOwnProperty()
+
+A helper method for calling [`v8::Object#DefineOwnProperty()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#a6f76b2ed605cb8f9185b92de0033a820) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::Maybe<bool> Nan::DefineOwnProperty(v8::Local<v8::Object> obj,
+ v8::Local<v8::String> key,
+ v8::Local<v8::Value> value,
+ v8::PropertyAttribute attribs = v8::None);
+```
+
+
+<a name="api_nan_force_set"></a>
+### <del>Nan::ForceSet()</del>
+
+Deprecated, use <a href="#api_nan_define_own_property"><code>Nan::DefineOwnProperty()</code></a>.
+
+<del>A helper method for calling [`v8::Object#ForceSet()`](https://v8docs.nodesource.com/node-0.12/db/d85/classv8_1_1_object.html#acfbdfd7427b516ebdb5c47c4df5ed96c) in a way compatible across supported versions of V8.</del>
+
+Signature:
+
+```c++
+NAN_DEPRECATED Nan::Maybe<bool> Nan::ForceSet(v8::Local<v8::Object> obj,
+ v8::Local<v8::Value> key,
+ v8::Local<v8::Value> value,
+ v8::PropertyAttribute attribs = v8::None);
+```
+
+
+<a name="api_nan_get"></a>
+### Nan::Get()
+
+A helper method for calling [`v8::Object#Get()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#a2565f03e736694f6b1e1cf22a0b4eac2) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::MaybeLocal<v8::Value> Nan::Get(v8::Local<v8::Object> obj,
+ v8::Local<v8::Value> key);
+Nan::MaybeLocal<v8::Value> Nan::Get(v8::Local<v8::Object> obj, uint32_t index);
+```
+
+
+<a name="api_nan_get_property_attribute"></a>
+### Nan::GetPropertyAttributes()
+
+A helper method for calling [`v8::Object#GetPropertyAttributes()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#a9b898894da3d1db2714fd9325a54fe57) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::Maybe<v8::PropertyAttribute> Nan::GetPropertyAttributes(
+ v8::Local<v8::Object> obj,
+ v8::Local<v8::Value> key);
+```
+
+
+<a name="api_nan_has"></a>
+### Nan::Has()
+
+A helper method for calling [`v8::Object#Has()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#ab3c3d89ea7c2f9afd08965bd7299a41d) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::Maybe<bool> Nan::Has(v8::Local<v8::Object> obj, v8::Local<v8::String> key);
+Nan::Maybe<bool> Nan::Has(v8::Local<v8::Object> obj, uint32_t index);
+```
+
+
+<a name="api_nan_delete"></a>
+### Nan::Delete()
+
+A helper method for calling [`v8::Object#Delete()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#a48e4a19b2cedff867eecc73ddb7d377f) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::Maybe<bool> Nan::Delete(v8::Local<v8::Object> obj,
+ v8::Local<v8::String> key);
+Nan::Maybe<bool> Nan::Delete(v8::Local<v8::Object> obj, uint32_t index);
+```
+
+
+<a name="api_nan_get_property_names"></a>
+### Nan::GetPropertyNames()
+
+A helper method for calling [`v8::Object#GetPropertyNames()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#aced885270cfd2c956367b5eedc7fbfe8) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::MaybeLocal<v8::Array> Nan::GetPropertyNames(v8::Local<v8::Object> obj);
+```
+
+
+<a name="api_nan_get_own_property_names"></a>
+### Nan::GetOwnPropertyNames()
+
+A helper method for calling [`v8::Object#GetOwnPropertyNames()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#a79a6e4d66049b9aa648ed4dfdb23e6eb) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::MaybeLocal<v8::Array> Nan::GetOwnPropertyNames(v8::Local<v8::Object> obj);
+```
+
+
+<a name="api_nan_set_prototype"></a>
+### Nan::SetPrototype()
+
+A helper method for calling [`v8::Object#SetPrototype()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#a442706b22fceda6e6d1f632122a9a9f4) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::Maybe<bool> Nan::SetPrototype(v8::Local<v8::Object> obj,
+ v8::Local<v8::Value> prototype);
+```
+
+
+<a name="api_nan_object_proto_to_string"></a>
+### Nan::ObjectProtoToString()
+
+A helper method for calling [`v8::Object#ObjectProtoToString()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#ab7a92b4dcf822bef72f6c0ac6fea1f0b) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::MaybeLocal<v8::String> Nan::ObjectProtoToString(v8::Local<v8::Object> obj);
+```
+
+
+<a name="api_nan_has_own_property"></a>
+### Nan::HasOwnProperty()
+
+A helper method for calling [`v8::Object#HasOwnProperty()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#ab7b7245442ca6de1e1c145ea3fd653ff) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::Maybe<bool> Nan::HasOwnProperty(v8::Local<v8::Object> obj,
+ v8::Local<v8::String> key);
+```
+
+
+<a name="api_nan_has_real_named_property"></a>
+### Nan::HasRealNamedProperty()
+
+A helper method for calling [`v8::Object#HasRealNamedProperty()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#ad8b80a59c9eb3c1e6c3cd6c84571f767) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::Maybe<bool> Nan::HasRealNamedProperty(v8::Local<v8::Object> obj,
+ v8::Local<v8::String> key);
+```
+
+
+<a name="api_nan_has_real_indexed_property"></a>
+### Nan::HasRealIndexedProperty()
+
+A helper method for calling [`v8::Object#HasRealIndexedProperty()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#af94fc1135a5e74a2193fb72c3a1b9855) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::Maybe<bool> Nan::HasRealIndexedProperty(v8::Local<v8::Object> obj,
+ uint32_t index);
+```
+
+
+<a name="api_nan_has_real_named_callback_property"></a>
+### Nan::HasRealNamedCallbackProperty()
+
+A helper method for calling [`v8::Object#HasRealNamedCallbackProperty()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#af743b7ea132b89f84d34d164d0668811) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::Maybe<bool> Nan::HasRealNamedCallbackProperty(
+ v8::Local<v8::Object> obj,
+ v8::Local<v8::String> key);
+```
+
+
+<a name="api_nan_get_real_named_property_in_prototype_chain"></a>
+### Nan::GetRealNamedPropertyInPrototypeChain()
+
+A helper method for calling [`v8::Object#GetRealNamedPropertyInPrototypeChain()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#a8700b1862e6b4783716964ba4d5e6172) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::MaybeLocal<v8::Value> Nan::GetRealNamedPropertyInPrototypeChain(
+ v8::Local<v8::Object> obj,
+ v8::Local<v8::String> key);
+```
+
+
+<a name="api_nan_get_real_named_property"></a>
+### Nan::GetRealNamedProperty()
+
+A helper method for calling [`v8::Object#GetRealNamedProperty()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#a84471a824576a5994fdd0ffcbf99ccc0) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::MaybeLocal<v8::Value> Nan::GetRealNamedProperty(v8::Local<v8::Object> obj,
+ v8::Local<v8::String> key);
+```
+
+
+<a name="api_nan_call_as_function"></a>
+### Nan::CallAsFunction()
+
+A helper method for calling [`v8::Object#CallAsFunction()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#ad3ffc36f3dfc3592ce2a96bc047ee2cd) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::MaybeLocal<v8::Value> Nan::CallAsFunction(v8::Local<v8::Object> obj,
+ v8::Local<v8::Object> recv,
+ int argc,
+ v8::Local<v8::Value> argv[]);
+```
+
+
+<a name="api_nan_call_as_constructor"></a>
+### Nan::CallAsConstructor()
+
+A helper method for calling [`v8::Object#CallAsConstructor()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#a50d571de50d0b0dfb28795619d07a01b) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::MaybeLocal<v8::Value> Nan::CallAsConstructor(v8::Local<v8::Object> obj,
+ int argc,
+ v8::Local<v8::Value> argv[]);
+```
+
+
+<a name="api_nan_get_source_line"></a>
+### Nan::GetSourceLine()
+
+A helper method for calling [`v8::Message#GetSourceLine()`](https://v8docs.nodesource.com/node-8.16/d9/d28/classv8_1_1_message.html#a849f7a6c41549d83d8159825efccd23a) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::MaybeLocal<v8::String> Nan::GetSourceLine(v8::Local<v8::Message> msg);
+```
+
+
+<a name="api_nan_get_line_number"></a>
+### Nan::GetLineNumber()
+
+A helper method for calling [`v8::Message#GetLineNumber()`](https://v8docs.nodesource.com/node-8.16/d9/d28/classv8_1_1_message.html#adbe46c10a88a6565f2732a2d2adf99b9) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::Maybe<int> Nan::GetLineNumber(v8::Local<v8::Message> msg);
+```
+
+
+<a name="api_nan_get_start_column"></a>
+### Nan::GetStartColumn()
+
+A helper method for calling [`v8::Message#GetStartColumn()`](https://v8docs.nodesource.com/node-8.16/d9/d28/classv8_1_1_message.html#a60ede616ba3822d712e44c7a74487ba6) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::Maybe<int> Nan::GetStartColumn(v8::Local<v8::Message> msg);
+```
+
+
+<a name="api_nan_get_end_column"></a>
+### Nan::GetEndColumn()
+
+A helper method for calling [`v8::Message#GetEndColumn()`](https://v8docs.nodesource.com/node-8.16/d9/d28/classv8_1_1_message.html#aaa004cf19e529da980bc19fcb76d93be) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::Maybe<int> Nan::GetEndColumn(v8::Local<v8::Message> msg);
+```
+
+
+<a name="api_nan_clone_element_at"></a>
+### Nan::CloneElementAt()
+
+A helper method for calling [`v8::Array#CloneElementAt()`](https://v8docs.nodesource.com/node-4.8/d3/d32/classv8_1_1_array.html#a1d3a878d4c1c7cae974dd50a1639245e) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::MaybeLocal<v8::Object> Nan::CloneElementAt(v8::Local<v8::Array> array, uint32_t index);
+```
+
+<a name="api_nan_has_private"></a>
+### Nan::HasPrivate()
+
+A helper method for calling [`v8::Object#HasPrivate()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#af68a0b98066cfdeb8f943e98a40ba08d) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::Maybe<bool> Nan::HasPrivate(v8::Local<v8::Object> object, v8::Local<v8::String> key);
+```
+
+<a name="api_nan_get_private"></a>
+### Nan::GetPrivate()
+
+A helper method for calling [`v8::Object#GetPrivate()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#a169f2da506acbec34deadd9149a1925a) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::MaybeLocal<v8::Value> Nan::GetPrivate(v8::Local<v8::Object> object, v8::Local<v8::String> key);
+```
+
+<a name="api_nan_set_private"></a>
+### Nan::SetPrivate()
+
+A helper method for calling [`v8::Object#SetPrivate()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#ace1769b0f3b86bfe9fda1010916360ee) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::Maybe<bool> Nan::SetPrivate(v8::Local<v8::Object> object, v8::Local<v8::String> key, v8::Local<v8::Value> value);
+```
+
+<a name="api_nan_delete_private"></a>
+### Nan::DeletePrivate()
+
+A helper method for calling [`v8::Object#DeletePrivate()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#a138bb32a304f3982be02ad499693b8fd) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::Maybe<bool> Nan::DeletePrivate(v8::Local<v8::Object> object, v8::Local<v8::String> key);
+```
+
+<a name="api_nan_make_maybe"></a>
+### Nan::MakeMaybe()
+
+Wraps a `v8::Local<>` in a `Nan::MaybeLocal<>`. When called with a `Nan::MaybeLocal<>` it just returns its argument. This is useful in generic template code that builds on NAN.
+
+Synopsis:
+
+```c++
+ MaybeLocal<v8::Number> someNumber = MakeMaybe(New<v8::Number>(3.141592654));
+ MaybeLocal<v8::String> someString = MakeMaybe(New<v8::String>("probably"));
+```
+
+Signature:
+
+```c++
+template <typename T, template <typename> class MaybeMaybe>
+Nan::MaybeLocal<T> Nan::MakeMaybe(MaybeMaybe<T> v);
+```
diff --git a/node_modules/nan/doc/methods.md b/node_modules/nan/doc/methods.md
new file mode 100644
index 0000000..9642d02
--- /dev/null
+++ b/node_modules/nan/doc/methods.md
@@ -0,0 +1,664 @@
+## JavaScript-accessible methods
+
+A _template_ is a blueprint for JavaScript functions and objects in a context. You can use a template to wrap C++ functions and data structures within JavaScript objects so that they can be manipulated from JavaScript. See the V8 Embedders Guide section on [Templates](https://github.com/v8/v8/wiki/Embedder%27s-Guide#templates) for further information.
+
+In order to expose functionality to JavaScript via a template, you must provide it to V8 in a form that it understands. Across the versions of V8 supported by NAN, JavaScript-accessible method signatures vary widely, NAN fully abstracts method declaration and provides you with an interface that is similar to the most recent V8 API but is backward-compatible with older versions that still use the now-deceased `v8::Argument` type.
+
+* **Method argument types**
+ - <a href="#api_nan_function_callback_info"><b><code>Nan::FunctionCallbackInfo</code></b></a>
+ - <a href="#api_nan_property_callback_info"><b><code>Nan::PropertyCallbackInfo</code></b></a>
+ - <a href="#api_nan_return_value"><b><code>Nan::ReturnValue</code></b></a>
+* **Method declarations**
+ - <a href="#api_nan_method"><b>Method declaration</b></a>
+ - <a href="#api_nan_getter"><b>Getter declaration</b></a>
+ - <a href="#api_nan_setter"><b>Setter declaration</b></a>
+ - <a href="#api_nan_property_getter"><b>Property getter declaration</b></a>
+ - <a href="#api_nan_property_setter"><b>Property setter declaration</b></a>
+ - <a href="#api_nan_property_enumerator"><b>Property enumerator declaration</b></a>
+ - <a href="#api_nan_property_deleter"><b>Property deleter declaration</b></a>
+ - <a href="#api_nan_property_query"><b>Property query declaration</b></a>
+ - <a href="#api_nan_index_getter"><b>Index getter declaration</b></a>
+ - <a href="#api_nan_index_setter"><b>Index setter declaration</b></a>
+ - <a href="#api_nan_index_enumerator"><b>Index enumerator declaration</b></a>
+ - <a href="#api_nan_index_deleter"><b>Index deleter declaration</b></a>
+ - <a href="#api_nan_index_query"><b>Index query declaration</b></a>
+* Method and template helpers
+ - <a href="#api_nan_set_method"><b><code>Nan::SetMethod()</code></b></a>
+ - <a href="#api_nan_set_prototype_method"><b><code>Nan::SetPrototypeMethod()</code></b></a>
+ - <a href="#api_nan_set_accessor"><b><code>Nan::SetAccessor()</code></b></a>
+ - <a href="#api_nan_set_named_property_handler"><b><code>Nan::SetNamedPropertyHandler()</code></b></a>
+ - <a href="#api_nan_set_indexed_property_handler"><b><code>Nan::SetIndexedPropertyHandler()</code></b></a>
+ - <a href="#api_nan_set_template"><b><code>Nan::SetTemplate()</code></b></a>
+ - <a href="#api_nan_set_prototype_template"><b><code>Nan::SetPrototypeTemplate()</code></b></a>
+ - <a href="#api_nan_set_instance_template"><b><code>Nan::SetInstanceTemplate()</code></b></a>
+ - <a href="#api_nan_set_call_handler"><b><code>Nan::SetCallHandler()</code></b></a>
+ - <a href="#api_nan_set_call_as_function_handler"><b><code>Nan::SetCallAsFunctionHandler()</code></b></a>
+
+<a name="api_nan_function_callback_info"></a>
+### Nan::FunctionCallbackInfo
+
+`Nan::FunctionCallbackInfo` should be used in place of [`v8::FunctionCallbackInfo`](https://v8docs.nodesource.com/node-8.16/dd/d0d/classv8_1_1_function_callback_info.html), even with older versions of Node where `v8::FunctionCallbackInfo` does not exist.
+
+Definition:
+
+```c++
+template<typename T> class FunctionCallbackInfo {
+ public:
+ ReturnValue<T> GetReturnValue() const;
+ v8::Local<v8::Function> Callee(); // NOTE: Not available in NodeJS >= 10.0.0
+ v8::Local<v8::Value> Data();
+ v8::Local<v8::Object> Holder();
+ bool IsConstructCall();
+ int Length() const;
+ v8::Local<v8::Value> operator[](int i) const;
+ v8::Local<v8::Object> This() const;
+ v8::Isolate *GetIsolate() const;
+};
+```
+
+See the [`v8::FunctionCallbackInfo`](https://v8docs.nodesource.com/node-8.16/dd/d0d/classv8_1_1_function_callback_info.html) documentation for usage details on these. See [`Nan::ReturnValue`](#api_nan_return_value) for further information on how to set a return value from methods.
+
+**Note:** `FunctionCallbackInfo::Callee` is removed in Node.js after `10.0.0` because it is was deprecated in V8. Consider using `info.Data()` to pass any information you need.
+
+<a name="api_nan_property_callback_info"></a>
+### Nan::PropertyCallbackInfo
+
+`Nan::PropertyCallbackInfo` should be used in place of [`v8::PropertyCallbackInfo`](https://v8docs.nodesource.com/node-8.16/d7/dc5/classv8_1_1_property_callback_info.html), even with older versions of Node where `v8::PropertyCallbackInfo` does not exist.
+
+Definition:
+
+```c++
+template<typename T> class PropertyCallbackInfo : public PropertyCallbackInfoBase<T> {
+ public:
+ ReturnValue<T> GetReturnValue() const;
+ v8::Isolate* GetIsolate() const;
+ v8::Local<v8::Value> Data() const;
+ v8::Local<v8::Object> This() const;
+ v8::Local<v8::Object> Holder() const;
+};
+```
+
+See the [`v8::PropertyCallbackInfo`](https://v8docs.nodesource.com/node-8.16/d7/dc5/classv8_1_1_property_callback_info.html) documentation for usage details on these. See [`Nan::ReturnValue`](#api_nan_return_value) for further information on how to set a return value from property accessor methods.
+
+<a name="api_nan_return_value"></a>
+### Nan::ReturnValue
+
+`Nan::ReturnValue` is used in place of [`v8::ReturnValue`](https://v8docs.nodesource.com/node-8.16/da/da7/classv8_1_1_return_value.html) on both [`Nan::FunctionCallbackInfo`](#api_nan_function_callback_info) and [`Nan::PropertyCallbackInfo`](#api_nan_property_callback_info) as the return type of `GetReturnValue()`.
+
+Example usage:
+
+```c++
+void EmptyArray(const Nan::FunctionCallbackInfo<v8::Value>& info) {
+ info.GetReturnValue().Set(Nan::New<v8::Array>());
+}
+```
+
+Definition:
+
+```c++
+template<typename T> class ReturnValue {
+ public:
+ // Handle setters
+ template <typename S> void Set(const v8::Local<S> &handle);
+ template <typename S> void Set(const Nan::Global<S> &handle);
+
+ // Fast primitive setters
+ void Set(bool value);
+ void Set(double i);
+ void Set(int32_t i);
+ void Set(uint32_t i);
+
+ // Fast JS primitive setters
+ void SetNull();
+ void SetUndefined();
+ void SetEmptyString();
+
+ // Convenience getter for isolate
+ v8::Isolate *GetIsolate() const;
+};
+```
+
+See the documentation on [`v8::ReturnValue`](https://v8docs.nodesource.com/node-8.16/da/da7/classv8_1_1_return_value.html) for further information on this.
+
+<a name="api_nan_method"></a>
+### Method declaration
+
+JavaScript-accessible methods should be declared with the following signature to form a `Nan::FunctionCallback`:
+
+```c++
+typedef void(*FunctionCallback)(const FunctionCallbackInfo<v8::Value>&);
+```
+
+Example:
+
+```c++
+void MethodName(const Nan::FunctionCallbackInfo<v8::Value>& info) {
+ ...
+}
+```
+
+You do not need to declare a new `HandleScope` within a method as one is implicitly created for you.
+
+**Example usage**
+
+```c++
+// .h:
+class Foo : public Nan::ObjectWrap {
+ ...
+
+ static void Bar(const Nan::FunctionCallbackInfo<v8::Value>& info);
+ static void Baz(const Nan::FunctionCallbackInfo<v8::Value>& info);
+}
+
+
+// .cc:
+void Foo::Bar(const Nan::FunctionCallbackInfo<v8::Value>& info) {
+ ...
+}
+
+void Foo::Baz(const Nan::FunctionCallbackInfo<v8::Value>& info) {
+ ...
+}
+```
+
+A helper macro `NAN_METHOD(methodname)` exists, compatible with NAN v1 method declarations.
+
+**Example usage with `NAN_METHOD(methodname)`**
+
+```c++
+// .h:
+class Foo : public Nan::ObjectWrap {
+ ...
+
+ static NAN_METHOD(Bar);
+ static NAN_METHOD(Baz);
+}
+
+
+// .cc:
+NAN_METHOD(Foo::Bar) {
+ ...
+}
+
+NAN_METHOD(Foo::Baz) {
+ ...
+}
+```
+
+Use [`Nan::SetPrototypeMethod`](#api_nan_set_prototype_method) to attach a method to a JavaScript function prototype or [`Nan::SetMethod`](#api_nan_set_method) to attach a method directly on a JavaScript object.
+
+<a name="api_nan_getter"></a>
+### Getter declaration
+
+JavaScript-accessible getters should be declared with the following signature to form a `Nan::GetterCallback`:
+
+```c++
+typedef void(*GetterCallback)(v8::Local<v8::String>,
+ const PropertyCallbackInfo<v8::Value>&);
+```
+
+Example:
+
+```c++
+void GetterName(v8::Local<v8::String> property,
+ const Nan::PropertyCallbackInfo<v8::Value>& info) {
+ ...
+}
+```
+
+You do not need to declare a new `HandleScope` within a getter as one is implicitly created for you.
+
+A helper macro `NAN_GETTER(methodname)` exists, compatible with NAN v1 method declarations.
+
+Also see the V8 Embedders Guide documentation on [Accessors](https://developers.google.com/v8/embed#accesssors).
+
+<a name="api_nan_setter"></a>
+### Setter declaration
+
+JavaScript-accessible setters should be declared with the following signature to form a <b><code>Nan::SetterCallback</code></b>:
+
+```c++
+typedef void(*SetterCallback)(v8::Local<v8::String>,
+ v8::Local<v8::Value>,
+ const PropertyCallbackInfo<void>&);
+```
+
+Example:
+
+```c++
+void SetterName(v8::Local<v8::String> property,
+ v8::Local<v8::Value> value,
+ const Nan::PropertyCallbackInfo<void>& info) {
+ ...
+}
+```
+
+You do not need to declare a new `HandleScope` within a setter as one is implicitly created for you.
+
+A helper macro `NAN_SETTER(methodname)` exists, compatible with NAN v1 method declarations.
+
+Also see the V8 Embedders Guide documentation on [Accessors](https://developers.google.com/v8/embed#accesssors).
+
+<a name="api_nan_property_getter"></a>
+### Property getter declaration
+
+JavaScript-accessible property getters should be declared with the following signature to form a <b><code>Nan::PropertyGetterCallback</code></b>:
+
+```c++
+typedef void(*PropertyGetterCallback)(v8::Local<v8::String>,
+ const PropertyCallbackInfo<v8::Value>&);
+```
+
+Example:
+
+```c++
+void PropertyGetterName(v8::Local<v8::String> property,
+ const Nan::PropertyCallbackInfo<v8::Value>& info) {
+ ...
+}
+```
+
+You do not need to declare a new `HandleScope` within a property getter as one is implicitly created for you.
+
+A helper macro `NAN_PROPERTY_GETTER(methodname)` exists, compatible with NAN v1 method declarations.
+
+Also see the V8 Embedders Guide documentation on named property [Interceptors](https://developers.google.com/v8/embed#interceptors).
+
+<a name="api_nan_property_setter"></a>
+### Property setter declaration
+
+JavaScript-accessible property setters should be declared with the following signature to form a <b><code>Nan::PropertySetterCallback</code></b>:
+
+```c++
+typedef void(*PropertySetterCallback)(v8::Local<v8::String>,
+ v8::Local<v8::Value>,
+ const PropertyCallbackInfo<v8::Value>&);
+```
+
+Example:
+
+```c++
+void PropertySetterName(v8::Local<v8::String> property,
+ v8::Local<v8::Value> value,
+ const Nan::PropertyCallbackInfo<v8::Value>& info);
+```
+
+You do not need to declare a new `HandleScope` within a property setter as one is implicitly created for you.
+
+A helper macro `NAN_PROPERTY_SETTER(methodname)` exists, compatible with NAN v1 method declarations.
+
+Also see the V8 Embedders Guide documentation on named property [Interceptors](https://developers.google.com/v8/embed#interceptors).
+
+<a name="api_nan_property_enumerator"></a>
+### Property enumerator declaration
+
+JavaScript-accessible property enumerators should be declared with the following signature to form a <b><code>Nan::PropertyEnumeratorCallback</code></b>:
+
+```c++
+typedef void(*PropertyEnumeratorCallback)(const PropertyCallbackInfo<v8::Array>&);
+```
+
+Example:
+
+```c++
+void PropertyEnumeratorName(const Nan::PropertyCallbackInfo<v8::Array>& info);
+```
+
+You do not need to declare a new `HandleScope` within a property enumerator as one is implicitly created for you.
+
+A helper macro `NAN_PROPERTY_ENUMERATOR(methodname)` exists, compatible with NAN v1 method declarations.
+
+Also see the V8 Embedders Guide documentation on named property [Interceptors](https://developers.google.com/v8/embed#interceptors).
+
+<a name="api_nan_property_deleter"></a>
+### Property deleter declaration
+
+JavaScript-accessible property deleters should be declared with the following signature to form a <b><code>Nan::PropertyDeleterCallback</code></b>:
+
+```c++
+typedef void(*PropertyDeleterCallback)(v8::Local<v8::String>,
+ const PropertyCallbackInfo<v8::Boolean>&);
+```
+
+Example:
+
+```c++
+void PropertyDeleterName(v8::Local<v8::String> property,
+ const Nan::PropertyCallbackInfo<v8::Boolean>& info);
+```
+
+You do not need to declare a new `HandleScope` within a property deleter as one is implicitly created for you.
+
+A helper macro `NAN_PROPERTY_DELETER(methodname)` exists, compatible with NAN v1 method declarations.
+
+Also see the V8 Embedders Guide documentation on named property [Interceptors](https://developers.google.com/v8/embed#interceptors).
+
+<a name="api_nan_property_query"></a>
+### Property query declaration
+
+JavaScript-accessible property query methods should be declared with the following signature to form a <b><code>Nan::PropertyQueryCallback</code></b>:
+
+```c++
+typedef void(*PropertyQueryCallback)(v8::Local<v8::String>,
+ const PropertyCallbackInfo<v8::Integer>&);
+```
+
+Example:
+
+```c++
+void PropertyQueryName(v8::Local<v8::String> property,
+ const Nan::PropertyCallbackInfo<v8::Integer>& info);
+```
+
+You do not need to declare a new `HandleScope` within a property query method as one is implicitly created for you.
+
+A helper macro `NAN_PROPERTY_QUERY(methodname)` exists, compatible with NAN v1 method declarations.
+
+Also see the V8 Embedders Guide documentation on named property [Interceptors](https://developers.google.com/v8/embed#interceptors).
+
+<a name="api_nan_index_getter"></a>
+### Index getter declaration
+
+JavaScript-accessible index getter methods should be declared with the following signature to form a <b><code>Nan::IndexGetterCallback</code></b>:
+
+```c++
+typedef void(*IndexGetterCallback)(uint32_t,
+ const PropertyCallbackInfo<v8::Value>&);
+```
+
+Example:
+
+```c++
+void IndexGetterName(uint32_t index, const PropertyCallbackInfo<v8::Value>& info);
+```
+
+You do not need to declare a new `HandleScope` within a index getter as one is implicitly created for you.
+
+A helper macro `NAN_INDEX_GETTER(methodname)` exists, compatible with NAN v1 method declarations.
+
+Also see the V8 Embedders Guide documentation on indexed property [Interceptors](https://developers.google.com/v8/embed#interceptors).
+
+<a name="api_nan_index_setter"></a>
+### Index setter declaration
+
+JavaScript-accessible index setter methods should be declared with the following signature to form a <b><code>Nan::IndexSetterCallback</code></b>:
+
+```c++
+typedef void(*IndexSetterCallback)(uint32_t,
+ v8::Local<v8::Value>,
+ const PropertyCallbackInfo<v8::Value>&);
+```
+
+Example:
+
+```c++
+void IndexSetterName(uint32_t index,
+ v8::Local<v8::Value> value,
+ const PropertyCallbackInfo<v8::Value>& info);
+```
+
+You do not need to declare a new `HandleScope` within a index setter as one is implicitly created for you.
+
+A helper macro `NAN_INDEX_SETTER(methodname)` exists, compatible with NAN v1 method declarations.
+
+Also see the V8 Embedders Guide documentation on indexed property [Interceptors](https://developers.google.com/v8/embed#interceptors).
+
+<a name="api_nan_index_enumerator"></a>
+### Index enumerator declaration
+
+JavaScript-accessible index enumerator methods should be declared with the following signature to form a <b><code>Nan::IndexEnumeratorCallback</code></b>:
+
+```c++
+typedef void(*IndexEnumeratorCallback)(const PropertyCallbackInfo<v8::Array>&);
+```
+
+Example:
+
+```c++
+void IndexEnumeratorName(const PropertyCallbackInfo<v8::Array>& info);
+```
+
+You do not need to declare a new `HandleScope` within a index enumerator as one is implicitly created for you.
+
+A helper macro `NAN_INDEX_ENUMERATOR(methodname)` exists, compatible with NAN v1 method declarations.
+
+Also see the V8 Embedders Guide documentation on indexed property [Interceptors](https://developers.google.com/v8/embed#interceptors).
+
+<a name="api_nan_index_deleter"></a>
+### Index deleter declaration
+
+JavaScript-accessible index deleter methods should be declared with the following signature to form a <b><code>Nan::IndexDeleterCallback</code></b>:
+
+```c++
+typedef void(*IndexDeleterCallback)(uint32_t,
+ const PropertyCallbackInfo<v8::Boolean>&);
+```
+
+Example:
+
+```c++
+void IndexDeleterName(uint32_t index, const PropertyCallbackInfo<v8::Boolean>& info);
+```
+
+You do not need to declare a new `HandleScope` within a index deleter as one is implicitly created for you.
+
+A helper macro `NAN_INDEX_DELETER(methodname)` exists, compatible with NAN v1 method declarations.
+
+Also see the V8 Embedders Guide documentation on indexed property [Interceptors](https://developers.google.com/v8/embed#interceptors).
+
+<a name="api_nan_index_query"></a>
+### Index query declaration
+
+JavaScript-accessible index query methods should be declared with the following signature to form a <b><code>Nan::IndexQueryCallback</code></b>:
+
+```c++
+typedef void(*IndexQueryCallback)(uint32_t,
+ const PropertyCallbackInfo<v8::Integer>&);
+```
+
+Example:
+
+```c++
+void IndexQueryName(uint32_t index, const PropertyCallbackInfo<v8::Integer>& info);
+```
+
+You do not need to declare a new `HandleScope` within a index query method as one is implicitly created for you.
+
+A helper macro `NAN_INDEX_QUERY(methodname)` exists, compatible with NAN v1 method declarations.
+
+Also see the V8 Embedders Guide documentation on indexed property [Interceptors](https://developers.google.com/v8/embed#interceptors).
+
+<a name="api_nan_set_method"></a>
+### Nan::SetMethod()
+
+Sets a method with a given name directly on a JavaScript object where the method has the `Nan::FunctionCallback` signature (see <a href="#api_nan_method">Method declaration</a>).
+
+Signature:
+
+```c++
+void Nan::SetMethod(v8::Local<v8::Object> recv,
+ const char *name,
+ Nan::FunctionCallback callback,
+ v8::Local<v8::Value> data = v8::Local<v8::Value>())
+void Nan::SetMethod(v8::Local<v8::Template> templ,
+ const char *name,
+ Nan::FunctionCallback callback,
+ v8::Local<v8::Value> data = v8::Local<v8::Value>())
+```
+
+<a name="api_nan_set_prototype_method"></a>
+### Nan::SetPrototypeMethod()
+
+Sets a method with a given name on a `FunctionTemplate`'s prototype where the method has the `Nan::FunctionCallback` signature (see <a href="#api_nan_method">Method declaration</a>).
+
+Signature:
+
+```c++
+void Nan::SetPrototypeMethod(v8::Local<v8::FunctionTemplate> recv,
+ const char* name,
+ Nan::FunctionCallback callback,
+ v8::Local<v8::Value> data = v8::Local<v8::Value>())
+```
+
+<a name="api_nan_set_accessor"></a>
+### Nan::SetAccessor()
+
+Sets getters and setters for a property with a given name on an `ObjectTemplate` or a plain `Object`. Accepts getters with the `Nan::GetterCallback` signature (see <a href="#api_nan_getter">Getter declaration</a>) and setters with the `Nan::SetterCallback` signature (see <a href="#api_nan_setter">Setter declaration</a>).
+
+Signature:
+
+```c++
+void SetAccessor(v8::Local<v8::ObjectTemplate> tpl,
+ v8::Local<v8::String> name,
+ Nan::GetterCallback getter,
+ Nan::SetterCallback setter = 0,
+ v8::Local<v8::Value> data = v8::Local<v8::Value>(),
+ v8::AccessControl settings = v8::DEFAULT,
+ v8::PropertyAttribute attribute = v8::None,
+ imp::Sig signature = imp::Sig());
+bool SetAccessor(v8::Local<v8::Object> obj,
+ v8::Local<v8::String> name,
+ Nan::GetterCallback getter,
+ Nan::SetterCallback setter = 0,
+ v8::Local<v8::Value> data = v8::Local<v8::Value>(),
+ v8::AccessControl settings = v8::DEFAULT,
+ v8::PropertyAttribute attribute = v8::None)
+```
+
+See the V8 [`ObjectTemplate#SetAccessor()`](https://v8docs.nodesource.com/node-8.16/db/d5f/classv8_1_1_object_template.html#aca0ed196f8a9adb1f68b1aadb6c9cd77) and [`Object#SetAccessor()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#ae91b3b56b357f285288c89fbddc46d1b) for further information about how to use `Nan::SetAccessor()`.
+
+<a name="api_nan_set_named_property_handler"></a>
+### Nan::SetNamedPropertyHandler()
+
+Sets named property getters, setters, query, deleter and enumerator methods on an `ObjectTemplate`. Accepts:
+
+* Property getters with the `Nan::PropertyGetterCallback` signature (see <a href="#api_nan_property_getter">Property getter declaration</a>)
+* Property setters with the `Nan::PropertySetterCallback` signature (see <a href="#api_nan_property_setter">Property setter declaration</a>)
+* Property query methods with the `Nan::PropertyQueryCallback` signature (see <a href="#api_nan_property_query">Property query declaration</a>)
+* Property deleters with the `Nan::PropertyDeleterCallback` signature (see <a href="#api_nan_property_deleter">Property deleter declaration</a>)
+* Property enumerators with the `Nan::PropertyEnumeratorCallback` signature (see <a href="#api_nan_property_enumerator">Property enumerator declaration</a>)
+
+Signature:
+
+```c++
+void SetNamedPropertyHandler(v8::Local<v8::ObjectTemplate> tpl,
+ Nan::PropertyGetterCallback getter,
+ Nan::PropertySetterCallback setter = 0,
+ Nan::PropertyQueryCallback query = 0,
+ Nan::PropertyDeleterCallback deleter = 0,
+ Nan::PropertyEnumeratorCallback enumerator = 0,
+ v8::Local<v8::Value> data = v8::Local<v8::Value>())
+```
+
+See the V8 [`ObjectTemplate#SetNamedPropertyHandler()`](https://v8docs.nodesource.com/node-8.16/db/d5f/classv8_1_1_object_template.html#a33b3ebd7de641f6cc6414b7de01fc1c7) for further information about how to use `Nan::SetNamedPropertyHandler()`.
+
+<a name="api_nan_set_indexed_property_handler"></a>
+### Nan::SetIndexedPropertyHandler()
+
+Sets indexed property getters, setters, query, deleter and enumerator methods on an `ObjectTemplate`. Accepts:
+
+* Indexed property getters with the `Nan::IndexGetterCallback` signature (see <a href="#api_nan_index_getter">Index getter declaration</a>)
+* Indexed property setters with the `Nan::IndexSetterCallback` signature (see <a href="#api_nan_index_setter">Index setter declaration</a>)
+* Indexed property query methods with the `Nan::IndexQueryCallback` signature (see <a href="#api_nan_index_query">Index query declaration</a>)
+* Indexed property deleters with the `Nan::IndexDeleterCallback` signature (see <a href="#api_nan_index_deleter">Index deleter declaration</a>)
+* Indexed property enumerators with the `Nan::IndexEnumeratorCallback` signature (see <a href="#api_nan_index_enumerator">Index enumerator declaration</a>)
+
+Signature:
+
+```c++
+void SetIndexedPropertyHandler(v8::Local<v8::ObjectTemplate> tpl,
+ Nan::IndexGetterCallback getter,
+ Nan::IndexSetterCallback setter = 0,
+ Nan::IndexQueryCallback query = 0,
+ Nan::IndexDeleterCallback deleter = 0,
+ Nan::IndexEnumeratorCallback enumerator = 0,
+ v8::Local<v8::Value> data = v8::Local<v8::Value>())
+```
+
+See the V8 [`ObjectTemplate#SetIndexedPropertyHandler()`](https://v8docs.nodesource.com/node-8.16/db/d5f/classv8_1_1_object_template.html#ac89f06d634add0e890452033f7d17ff1) for further information about how to use `Nan::SetIndexedPropertyHandler()`.
+
+<a name="api_nan_set_template"></a>
+### Nan::SetTemplate()
+
+Adds properties on an `Object`'s or `Function`'s template.
+
+Signature:
+
+```c++
+void Nan::SetTemplate(v8::Local<v8::Template> templ,
+ const char *name,
+ v8::Local<v8::Data> value);
+void Nan::SetTemplate(v8::Local<v8::Template> templ,
+ v8::Local<v8::String> name,
+ v8::Local<v8::Data> value,
+ v8::PropertyAttribute attributes)
+```
+
+Calls the `Template`'s [`Set()`](https://v8docs.nodesource.com/node-8.16/db/df7/classv8_1_1_template.html#ae3fbaff137557aa6a0233bc7e52214ac).
+
+<a name="api_nan_set_prototype_template"></a>
+### Nan::SetPrototypeTemplate()
+
+Adds properties on an `Object`'s or `Function`'s prototype template.
+
+Signature:
+
+```c++
+void Nan::SetPrototypeTemplate(v8::Local<v8::FunctionTemplate> templ,
+ const char *name,
+ v8::Local<v8::Data> value);
+void Nan::SetPrototypeTemplate(v8::Local<v8::FunctionTemplate> templ,
+ v8::Local<v8::String> name,
+ v8::Local<v8::Data> value,
+ v8::PropertyAttribute attributes)
+```
+
+Calls the `FunctionTemplate`'s _PrototypeTemplate's_ [`Set()`](https://v8docs.nodesource.com/node-8.16/db/df7/classv8_1_1_template.html#a2db6a56597bf23c59659c0659e564ddf).
+
+<a name="api_nan_set_instance_template"></a>
+### Nan::SetInstanceTemplate()
+
+Use to add instance properties on `FunctionTemplate`'s.
+
+Signature:
+
+```c++
+void Nan::SetInstanceTemplate(v8::Local<v8::FunctionTemplate> templ,
+ const char *name,
+ v8::Local<v8::Data> value);
+void Nan::SetInstanceTemplate(v8::Local<v8::FunctionTemplate> templ,
+ v8::Local<v8::String> name,
+ v8::Local<v8::Data> value,
+ v8::PropertyAttribute attributes)
+```
+
+Calls the `FunctionTemplate`'s _InstanceTemplate's_ [`Set()`](https://v8docs.nodesource.com/node-8.16/db/df7/classv8_1_1_template.html#a2db6a56597bf23c59659c0659e564ddf).
+
+<a name="api_nan_set_call_handler"></a>
+### Nan::SetCallHandler()
+
+Set the call-handler callback for a `v8::FunctionTemplate`.
+This callback is called whenever the function created from this FunctionTemplate is called.
+
+Signature:
+
+```c++
+void Nan::SetCallHandler(v8::Local<v8::FunctionTemplate> templ, Nan::FunctionCallback callback, v8::Local<v8::Value> data = v8::Local<v8::Value>())
+```
+
+Calls the `FunctionTemplate`'s [`SetCallHandler()`](https://v8docs.nodesource.com/node-8.16/d8/d83/classv8_1_1_function_template.html#ab7574b298db3c27fbc2ed465c08ea2f8).
+
+<a name="api_nan_set_call_as_function_handler"></a>
+### Nan::SetCallAsFunctionHandler()
+
+Sets the callback to be used when calling instances created from the `v8::ObjectTemplate` as a function.
+If no callback is set, instances behave like normal JavaScript objects that cannot be called as a function.
+
+Signature:
+
+```c++
+void Nan::SetCallAsFunctionHandler(v8::Local<v8::ObjectTemplate> templ, Nan::FunctionCallback callback, v8::Local<v8::Value> data = v8::Local<v8::Value>())
+```
+
+Calls the `ObjectTemplate`'s [`SetCallAsFunctionHandler()`](https://v8docs.nodesource.com/node-8.16/db/d5f/classv8_1_1_object_template.html#a5e9612fc80bf6db8f2da199b9b0bd04e).
+
diff --git a/node_modules/nan/doc/new.md b/node_modules/nan/doc/new.md
new file mode 100644
index 0000000..0f28a0e
--- /dev/null
+++ b/node_modules/nan/doc/new.md
@@ -0,0 +1,147 @@
+## New
+
+NAN provides a `Nan::New()` helper for the creation of new JavaScript objects in a way that's compatible across the supported versions of V8.
+
+ - <a href="#api_nan_new"><b><code>Nan::New()</code></b></a>
+ - <a href="#api_nan_undefined"><b><code>Nan::Undefined()</code></b></a>
+ - <a href="#api_nan_null"><b><code>Nan::Null()</code></b></a>
+ - <a href="#api_nan_true"><b><code>Nan::True()</code></b></a>
+ - <a href="#api_nan_false"><b><code>Nan::False()</code></b></a>
+ - <a href="#api_nan_empty_string"><b><code>Nan::EmptyString()</code></b></a>
+
+
+<a name="api_nan_new"></a>
+### Nan::New()
+
+`Nan::New()` should be used to instantiate new JavaScript objects.
+
+Refer to the specific V8 type in the [V8 documentation](https://v8docs.nodesource.com/node-8.16/d1/d83/classv8_1_1_data.html) for information on the types of arguments required for instantiation.
+
+Signatures:
+
+Return types are mostly omitted from the signatures for simplicity. In most cases the type will be contained within a `v8::Local<T>`. The following types will be contained within a `Nan::MaybeLocal<T>`: `v8::String`, `v8::Date`, `v8::RegExp`, `v8::Script`, `v8::UnboundScript`.
+
+Empty objects:
+
+```c++
+Nan::New<T>();
+```
+
+Generic single and multiple-argument:
+
+```c++
+Nan::New<T>(A0 arg0);
+Nan::New<T>(A0 arg0, A1 arg1);
+Nan::New<T>(A0 arg0, A1 arg1, A2 arg2);
+Nan::New<T>(A0 arg0, A1 arg1, A2 arg2, A3 arg3);
+```
+
+For creating `v8::FunctionTemplate` and `v8::Function` objects:
+
+_The definition of `Nan::FunctionCallback` can be found in the [Method declaration](./methods.md#api_nan_method) documentation._
+
+```c++
+Nan::New<T>(Nan::FunctionCallback callback,
+ v8::Local<v8::Value> data = v8::Local<v8::Value>());
+Nan::New<T>(Nan::FunctionCallback callback,
+ v8::Local<v8::Value> data = v8::Local<v8::Value>(),
+ A2 a2 = A2());
+```
+
+Native number types:
+
+```c++
+v8::Local<v8::Boolean> Nan::New<T>(bool value);
+v8::Local<v8::Int32> Nan::New<T>(int32_t value);
+v8::Local<v8::Uint32> Nan::New<T>(uint32_t value);
+v8::Local<v8::Number> Nan::New<T>(double value);
+```
+
+String types:
+
+```c++
+Nan::MaybeLocal<v8::String> Nan::New<T>(std::string const& value);
+Nan::MaybeLocal<v8::String> Nan::New<T>(const char * value, int length);
+Nan::MaybeLocal<v8::String> Nan::New<T>(const char * value);
+Nan::MaybeLocal<v8::String> Nan::New<T>(const uint16_t * value);
+Nan::MaybeLocal<v8::String> Nan::New<T>(const uint16_t * value, int length);
+```
+
+Specialized types:
+
+```c++
+v8::Local<v8::String> Nan::New<T>(v8::String::ExternalStringResource * value);
+v8::Local<v8::String> Nan::New<T>(Nan::ExternalOneByteStringResource * value);
+v8::Local<v8::RegExp> Nan::New<T>(v8::Local<v8::String> pattern, v8::RegExp::Flags flags);
+```
+
+Note that `Nan::ExternalOneByteStringResource` maps to [`v8::String::ExternalOneByteStringResource`](https://v8docs.nodesource.com/node-8.16/d9/db3/classv8_1_1_string_1_1_external_one_byte_string_resource.html), and `v8::String::ExternalAsciiStringResource` in older versions of V8.
+
+
+<a name="api_nan_undefined"></a>
+### Nan::Undefined()
+
+A helper method to reference the `v8::Undefined` object in a way that is compatible across all supported versions of V8.
+
+Signature:
+
+```c++
+v8::Local<v8::Primitive> Nan::Undefined()
+```
+
+<a name="api_nan_null"></a>
+### Nan::Null()
+
+A helper method to reference the `v8::Null` object in a way that is compatible across all supported versions of V8.
+
+Signature:
+
+```c++
+v8::Local<v8::Primitive> Nan::Null()
+```
+
+<a name="api_nan_true"></a>
+### Nan::True()
+
+A helper method to reference the `v8::Boolean` object representing the `true` value in a way that is compatible across all supported versions of V8.
+
+Signature:
+
+```c++
+v8::Local<v8::Boolean> Nan::True()
+```
+
+<a name="api_nan_false"></a>
+### Nan::False()
+
+A helper method to reference the `v8::Boolean` object representing the `false` value in a way that is compatible across all supported versions of V8.
+
+Signature:
+
+```c++
+v8::Local<v8::Boolean> Nan::False()
+```
+
+<a name="api_nan_empty_string"></a>
+### Nan::EmptyString()
+
+Call [`v8::String::Empty`](https://v8docs.nodesource.com/node-8.16/d2/db3/classv8_1_1_string.html#a7c1bc8886115d7ee46f1d571dd6ebc6d) to reference the empty string in a way that is compatible across all supported versions of V8.
+
+Signature:
+
+```c++
+v8::Local<v8::String> Nan::EmptyString()
+```
+
+
+<a name="api_nan_new_one_byte_string"></a>
+### Nan::NewOneByteString()
+
+An implementation of [`v8::String::NewFromOneByte()`](https://v8docs.nodesource.com/node-8.16/d2/db3/classv8_1_1_string.html#a5264d50b96d2c896ce525a734dc10f09) provided for consistent availability and API across supported versions of V8. Allocates a new string from Latin-1 data.
+
+Signature:
+
+```c++
+Nan::MaybeLocal<v8::String> Nan::NewOneByteString(const uint8_t * value,
+ int length = -1)
+```
diff --git a/node_modules/nan/doc/node_misc.md b/node_modules/nan/doc/node_misc.md
new file mode 100644
index 0000000..17578e3
--- /dev/null
+++ b/node_modules/nan/doc/node_misc.md
@@ -0,0 +1,123 @@
+## Miscellaneous Node Helpers
+
+ - <a href="#api_nan_asyncresource"><b><code>Nan::AsyncResource</code></b></a>
+ - <a href="#api_nan_make_callback"><b><code>Nan::MakeCallback()</code></b></a>
+ - <a href="#api_nan_module_init"><b><code>NAN_MODULE_INIT()</code></b></a>
+ - <a href="#api_nan_export"><b><code>Nan::Export()</code></b></a>
+
+<a name="api_nan_asyncresource"></a>
+### Nan::AsyncResource
+
+This class is analogous to the `AsyncResource` JavaScript class exposed by Node's [async_hooks][] API.
+
+When calling back into JavaScript asynchronously, special care must be taken to ensure that the runtime can properly track
+async hops. `Nan::AsyncResource` is a class that provides an RAII wrapper around `node::EmitAsyncInit`, `node::EmitAsyncDestroy`,
+and `node::MakeCallback`. Using this mechanism to call back into JavaScript, as opposed to `Nan::MakeCallback` or
+`v8::Function::Call` ensures that the callback is executed in the correct async context. This ensures that async mechanisms
+such as domains and [async_hooks][] function correctly.
+
+Definition:
+
+```c++
+class AsyncResource {
+ public:
+ AsyncResource(v8::Local<v8::String> name,
+ v8::Local<v8::Object> resource = New<v8::Object>());
+ AsyncResource(const char* name,
+ v8::Local<v8::Object> resource = New<v8::Object>());
+ ~AsyncResource();
+
+ v8::MaybeLocal<v8::Value> runInAsyncScope(v8::Local<v8::Object> target,
+ v8::Local<v8::Function> func,
+ int argc,
+ v8::Local<v8::Value>* argv);
+ v8::MaybeLocal<v8::Value> runInAsyncScope(v8::Local<v8::Object> target,
+ v8::Local<v8::String> symbol,
+ int argc,
+ v8::Local<v8::Value>* argv);
+ v8::MaybeLocal<v8::Value> runInAsyncScope(v8::Local<v8::Object> target,
+ const char* method,
+ int argc,
+ v8::Local<v8::Value>* argv);
+};
+```
+
+* `name`: Identifier for the kind of resource that is being provided for diagnostics information exposed by the [async_hooks][]
+ API. This will be passed to the possible `init` hook as the `type`. To avoid name collisions with other modules we recommend
+ that the name include the name of the owning module as a prefix. For example `mysql` module could use something like
+ `mysql:batch-db-query-resource`.
+* `resource`: An optional object associated with the async work that will be passed to the possible [async_hooks][]
+ `init` hook. If this parameter is omitted, or an empty handle is provided, this object will be created automatically.
+* When calling JS on behalf of this resource, one can use `runInAsyncScope`. This will ensure that the callback runs in the
+ correct async execution context.
+* `AsyncDestroy` is automatically called when an AsyncResource object is destroyed.
+
+For more details, see the Node [async_hooks][] documentation. You might also want to take a look at the documentation for the
+[N-API counterpart][napi]. For example usage, see the `asyncresource.cpp` example in the `test/cpp` directory.
+
+<a name="api_nan_make_callback"></a>
+### Nan::MakeCallback()
+
+Deprecated wrappers around the legacy `node::MakeCallback()` APIs. Node.js 10+
+has deprecated these legacy APIs as they do not provide a mechanism to preserve
+async context.
+
+We recommend that you use the `AsyncResource` class and `AsyncResource::runInAsyncScope` instead of using `Nan::MakeCallback` or
+`v8::Function#Call()` directly. `AsyncResource` properly takes care of running the callback in the correct async execution
+context – something that is essential for functionality like domains, async_hooks and async debugging.
+
+Signatures:
+
+```c++
+NAN_DEPRECATED
+v8::Local<v8::Value> Nan::MakeCallback(v8::Local<v8::Object> target,
+ v8::Local<v8::Function> func,
+ int argc,
+ v8::Local<v8::Value>* argv);
+NAN_DEPRECATED
+v8::Local<v8::Value> Nan::MakeCallback(v8::Local<v8::Object> target,
+ v8::Local<v8::String> symbol,
+ int argc,
+ v8::Local<v8::Value>* argv);
+NAN_DEPRECATED
+v8::Local<v8::Value> Nan::MakeCallback(v8::Local<v8::Object> target,
+ const char* method,
+ int argc,
+ v8::Local<v8::Value>* argv);
+```
+
+
+<a name="api_nan_module_init"></a>
+### NAN_MODULE_INIT()
+
+Used to define the entry point function to a Node add-on. Creates a function with a given `name` that receives a `target` object representing the equivalent of the JavaScript `exports` object.
+
+See example below.
+
+<a name="api_nan_export"></a>
+### Nan::Export()
+
+A simple helper to register a `v8::FunctionTemplate` from a JavaScript-accessible method (see [Methods](./methods.md)) as a property on an object. Can be used in a way similar to assigning properties to `module.exports` in JavaScript.
+
+Signature:
+
+```c++
+void Export(v8::Local<v8::Object> target, const char *name, Nan::FunctionCallback f)
+```
+
+Also available as the shortcut `NAN_EXPORT` macro.
+
+Example:
+
+```c++
+NAN_METHOD(Foo) {
+ ...
+}
+
+NAN_MODULE_INIT(Init) {
+ NAN_EXPORT(target, Foo);
+}
+```
+
+[async_hooks]: https://nodejs.org/dist/latest-v9.x/docs/api/async_hooks.html
+[napi]: https://nodejs.org/dist/latest-v9.x/docs/api/n-api.html#n_api_custom_asynchronous_operations
diff --git a/node_modules/nan/doc/object_wrappers.md b/node_modules/nan/doc/object_wrappers.md
new file mode 100644
index 0000000..07d8c05
--- /dev/null
+++ b/node_modules/nan/doc/object_wrappers.md
@@ -0,0 +1,263 @@
+## Object Wrappers
+
+The `ObjectWrap` class can be used to make wrapped C++ objects and a factory of wrapped objects.
+
+ - <a href="#api_nan_object_wrap"><b><code>Nan::ObjectWrap</code></b></a>
+
+
+<a name="api_nan_object_wrap"></a>
+### Nan::ObjectWrap()
+
+A reimplementation of `node::ObjectWrap` that adds some API not present in older versions of Node. Should be preferred over `node::ObjectWrap` in all cases for consistency.
+
+Definition:
+
+```c++
+class ObjectWrap {
+ public:
+ ObjectWrap();
+
+ virtual ~ObjectWrap();
+
+ template <class T>
+ static inline T* Unwrap(v8::Local<v8::Object> handle);
+
+ inline v8::Local<v8::Object> handle();
+
+ inline Nan::Persistent<v8::Object>& persistent();
+
+ protected:
+ inline void Wrap(v8::Local<v8::Object> handle);
+
+ inline void MakeWeak();
+
+ /* Ref() marks the object as being attached to an event loop.
+ * Refed objects will not be garbage collected, even if
+ * all references are lost.
+ */
+ virtual void Ref();
+
+ /* Unref() marks an object as detached from the event loop. This is its
+ * default state. When an object with a "weak" reference changes from
+ * attached to detached state it will be freed. Be careful not to access
+ * the object after making this call as it might be gone!
+ * (A "weak reference" means an object that only has a
+ * persistent handle.)
+ *
+ * DO NOT CALL THIS FROM DESTRUCTOR
+ */
+ virtual void Unref();
+
+ int refs_; // ro
+};
+```
+
+See the Node documentation on [Wrapping C++ Objects](https://nodejs.org/api/addons.html#addons_wrapping_c_objects) for more details.
+
+### This vs. Holder
+
+When calling `Unwrap`, it is important that the argument is indeed some JavaScript object which got wrapped by a `Wrap` call for this class or any derived class.
+The `Signature` installed by [`Nan::SetPrototypeMethod()`](methods.md#api_nan_set_prototype_method) does ensure that `info.Holder()` is just such an instance.
+In Node 0.12 and later, `info.This()` will also be of such a type, since otherwise the invocation will get rejected.
+However, in Node 0.10 and before it was possible to invoke a method on a JavaScript object which just had the extension type in its prototype chain.
+In such a situation, calling `Unwrap` on `info.This()` will likely lead to a failed assertion causing a crash, but could lead to even more serious corruption.
+
+On the other hand, calling `Unwrap` in an [accessor](methods.md#api_nan_set_accessor) should not use `Holder()` if the accessor is defined on the prototype.
+So either define your accessors on the instance template,
+or use `This()` after verifying that it is indeed a valid object.
+
+### Examples
+
+#### Basic
+
+```c++
+class MyObject : public Nan::ObjectWrap {
+ public:
+ static NAN_MODULE_INIT(Init) {
+ v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
+ tpl->SetClassName(Nan::New("MyObject").ToLocalChecked());
+ tpl->InstanceTemplate()->SetInternalFieldCount(1);
+
+ Nan::SetPrototypeMethod(tpl, "getHandle", GetHandle);
+ Nan::SetPrototypeMethod(tpl, "getValue", GetValue);
+
+ constructor().Reset(Nan::GetFunction(tpl).ToLocalChecked());
+ Nan::Set(target, Nan::New("MyObject").ToLocalChecked(),
+ Nan::GetFunction(tpl).ToLocalChecked());
+ }
+
+ private:
+ explicit MyObject(double value = 0) : value_(value) {}
+ ~MyObject() {}
+
+ static NAN_METHOD(New) {
+ if (info.IsConstructCall()) {
+ double value = info[0]->IsUndefined() ? 0 : Nan::To<double>(info[0]).FromJust();
+ MyObject *obj = new MyObject(value);
+ obj->Wrap(info.This());
+ info.GetReturnValue().Set(info.This());
+ } else {
+ const int argc = 1;
+ v8::Local<v8::Value> argv[argc] = {info[0]};
+ v8::Local<v8::Function> cons = Nan::New(constructor());
+ info.GetReturnValue().Set(Nan::NewInstance(cons, argc, argv).ToLocalChecked());
+ }
+ }
+
+ static NAN_METHOD(GetHandle) {
+ MyObject* obj = Nan::ObjectWrap::Unwrap<MyObject>(info.Holder());
+ info.GetReturnValue().Set(obj->handle());
+ }
+
+ static NAN_METHOD(GetValue) {
+ MyObject* obj = Nan::ObjectWrap::Unwrap<MyObject>(info.Holder());
+ info.GetReturnValue().Set(obj->value_);
+ }
+
+ static inline Nan::Persistent<v8::Function> & constructor() {
+ static Nan::Persistent<v8::Function> my_constructor;
+ return my_constructor;
+ }
+
+ double value_;
+};
+
+NODE_MODULE(objectwrapper, MyObject::Init)
+```
+
+To use in Javascript:
+
+```Javascript
+var objectwrapper = require('bindings')('objectwrapper');
+
+var obj = new objectwrapper.MyObject(5);
+console.log('Should be 5: ' + obj.getValue());
+```
+
+#### Factory of wrapped objects
+
+```c++
+class MyFactoryObject : public Nan::ObjectWrap {
+ public:
+ static NAN_MODULE_INIT(Init) {
+ v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
+ tpl->InstanceTemplate()->SetInternalFieldCount(1);
+
+ Nan::SetPrototypeMethod(tpl, "getValue", GetValue);
+
+ constructor().Reset(Nan::GetFunction(tpl).ToLocalChecked());
+ }
+
+ static NAN_METHOD(NewInstance) {
+ v8::Local<v8::Function> cons = Nan::New(constructor());
+ double value = info[0]->IsNumber() ? Nan::To<double>(info[0]).FromJust() : 0;
+ const int argc = 1;
+ v8::Local<v8::Value> argv[1] = {Nan::New(value)};
+ info.GetReturnValue().Set(Nan::NewInstance(cons, argc, argv).ToLocalChecked());
+ }
+
+ // Needed for the next example:
+ inline double value() const {
+ return value_;
+ }
+
+ private:
+ explicit MyFactoryObject(double value = 0) : value_(value) {}
+ ~MyFactoryObject() {}
+
+ static NAN_METHOD(New) {
+ if (info.IsConstructCall()) {
+ double value = info[0]->IsNumber() ? Nan::To<double>(info[0]).FromJust() : 0;
+ MyFactoryObject * obj = new MyFactoryObject(value);
+ obj->Wrap(info.This());
+ info.GetReturnValue().Set(info.This());
+ } else {
+ const int argc = 1;
+ v8::Local<v8::Value> argv[argc] = {info[0]};
+ v8::Local<v8::Function> cons = Nan::New(constructor());
+ info.GetReturnValue().Set(Nan::NewInstance(cons, argc, argv).ToLocalChecked());
+ }
+ }
+
+ static NAN_METHOD(GetValue) {
+ MyFactoryObject* obj = ObjectWrap::Unwrap<MyFactoryObject>(info.Holder());
+ info.GetReturnValue().Set(obj->value_);
+ }
+
+ static inline Nan::Persistent<v8::Function> & constructor() {
+ static Nan::Persistent<v8::Function> my_constructor;
+ return my_constructor;
+ }
+
+ double value_;
+};
+
+NAN_MODULE_INIT(Init) {
+ MyFactoryObject::Init(target);
+ Nan::Set(target,
+ Nan::New<v8::String>("newFactoryObjectInstance").ToLocalChecked(),
+ Nan::GetFunction(
+ Nan::New<v8::FunctionTemplate>(MyFactoryObject::NewInstance)).ToLocalChecked()
+ );
+}
+
+NODE_MODULE(wrappedobjectfactory, Init)
+```
+
+To use in Javascript:
+
+```Javascript
+var wrappedobjectfactory = require('bindings')('wrappedobjectfactory');
+
+var obj = wrappedobjectfactory.newFactoryObjectInstance(10);
+console.log('Should be 10: ' + obj.getValue());
+```
+
+#### Passing wrapped objects around
+
+Use the `MyFactoryObject` class above along with the following:
+
+```c++
+static NAN_METHOD(Sum) {
+ Nan::MaybeLocal<v8::Object> maybe1 = Nan::To<v8::Object>(info[0]);
+ Nan::MaybeLocal<v8::Object> maybe2 = Nan::To<v8::Object>(info[1]);
+
+ // Quick check:
+ if (maybe1.IsEmpty() || maybe2.IsEmpty()) {
+ // return value is undefined by default
+ return;
+ }
+
+ MyFactoryObject* obj1 =
+ Nan::ObjectWrap::Unwrap<MyFactoryObject>(maybe1.ToLocalChecked());
+ MyFactoryObject* obj2 =
+ Nan::ObjectWrap::Unwrap<MyFactoryObject>(maybe2.ToLocalChecked());
+
+ info.GetReturnValue().Set(Nan::New<v8::Number>(obj1->value() + obj2->value()));
+}
+
+NAN_MODULE_INIT(Init) {
+ MyFactoryObject::Init(target);
+ Nan::Set(target,
+ Nan::New<v8::String>("newFactoryObjectInstance").ToLocalChecked(),
+ Nan::GetFunction(
+ Nan::New<v8::FunctionTemplate>(MyFactoryObject::NewInstance)).ToLocalChecked()
+ );
+ Nan::Set(target,
+ Nan::New<v8::String>("sum").ToLocalChecked(),
+ Nan::GetFunction(Nan::New<v8::FunctionTemplate>(Sum)).ToLocalChecked()
+ );
+}
+
+NODE_MODULE(myaddon, Init)
+```
+
+To use in Javascript:
+
+```Javascript
+var myaddon = require('bindings')('myaddon');
+
+var obj1 = myaddon.newFactoryObjectInstance(5);
+var obj2 = myaddon.newFactoryObjectInstance(10);
+console.log('sum of object values: ' + myaddon.sum(obj1, obj2));
+```
diff --git a/node_modules/nan/doc/persistent.md b/node_modules/nan/doc/persistent.md
new file mode 100644
index 0000000..2e13f6b
--- /dev/null
+++ b/node_modules/nan/doc/persistent.md
@@ -0,0 +1,296 @@
+## Persistent references
+
+An object reference that is independent of any `HandleScope` is a _persistent_ reference. Where a `Local` handle only lives as long as the `HandleScope` in which it was allocated, a `Persistent` handle remains valid until it is explicitly disposed.
+
+Due to the evolution of the V8 API, it is necessary for NAN to provide a wrapper implementation of the `Persistent` classes to supply compatibility across the V8 versions supported.
+
+ - <a href="#api_nan_persistent_base"><b><code>Nan::PersistentBase & v8::PersistentBase</code></b></a>
+ - <a href="#api_nan_non_copyable_persistent_traits"><b><code>Nan::NonCopyablePersistentTraits & v8::NonCopyablePersistentTraits</code></b></a>
+ - <a href="#api_nan_copyable_persistent_traits"><b><code>Nan::CopyablePersistentTraits & v8::CopyablePersistentTraits</code></b></a>
+ - <a href="#api_nan_persistent"><b><code>Nan::Persistent</code></b></a>
+ - <a href="#api_nan_global"><b><code>Nan::Global</code></b></a>
+ - <a href="#api_nan_weak_callback_info"><b><code>Nan::WeakCallbackInfo</code></b></a>
+ - <a href="#api_nan_weak_callback_type"><b><code>Nan::WeakCallbackType</code></b></a>
+
+Also see the V8 Embedders Guide section on [Handles and Garbage Collection](https://developers.google.com/v8/embed#handles).
+
+<a name="api_nan_persistent_base"></a>
+### Nan::PersistentBase & v8::PersistentBase
+
+A persistent handle contains a reference to a storage cell in V8 which holds an object value and which is updated by the garbage collector whenever the object is moved. A new storage cell can be created using the constructor or `Nan::PersistentBase::Reset()`. Existing handles can be disposed using an argument-less `Nan::PersistentBase::Reset()`.
+
+Definition:
+
+_(note: this is implemented as `Nan::PersistentBase` for older versions of V8 and the native `v8::PersistentBase` is used for newer versions of V8)_
+
+```c++
+template<typename T> class PersistentBase {
+ public:
+ /**
+ * If non-empty, destroy the underlying storage cell
+ */
+ void Reset();
+
+ /**
+ * If non-empty, destroy the underlying storage cell and create a new one with
+ * the contents of another if it is also non-empty
+ */
+ template<typename S> void Reset(const v8::Local<S> &other);
+
+ /**
+ * If non-empty, destroy the underlying storage cell and create a new one with
+ * the contents of another if it is also non-empty
+ */
+ template<typename S> void Reset(const PersistentBase<S> &other);
+
+ /** Returns true if the handle is empty. */
+ bool IsEmpty() const;
+
+ /**
+ * If non-empty, destroy the underlying storage cell
+ * IsEmpty() will return true after this call.
+ */
+ void Empty();
+
+ template<typename S> bool operator==(const PersistentBase<S> &that);
+
+ template<typename S> bool operator==(const v8::Local<S> &that);
+
+ template<typename S> bool operator!=(const PersistentBase<S> &that);
+
+ template<typename S> bool operator!=(const v8::Local<S> &that);
+
+ /**
+ * Install a finalization callback on this object.
+ * NOTE: There is no guarantee as to *when* or even *if* the callback is
+ * invoked. The invocation is performed solely on a best effort basis.
+ * As always, GC-based finalization should *not* be relied upon for any
+ * critical form of resource management! At the moment you can either
+ * specify a parameter for the callback or the location of two internal
+ * fields in the dying object.
+ */
+ template<typename P>
+ void SetWeak(P *parameter,
+ typename WeakCallbackInfo<P>::Callback callback,
+ WeakCallbackType type);
+
+ void ClearWeak();
+
+ /**
+ * Marks the reference to this object independent. Garbage collector is free
+ * to ignore any object groups containing this object. Weak callback for an
+ * independent handle should not assume that it will be preceded by a global
+ * GC prologue callback or followed by a global GC epilogue callback.
+ */
+ void MarkIndependent() const;
+
+ bool IsIndependent() const;
+
+ /** Checks if the handle holds the only reference to an object. */
+ bool IsNearDeath() const;
+
+ /** Returns true if the handle's reference is weak. */
+ bool IsWeak() const
+};
+```
+
+See the V8 documentation for [`PersistentBase`](https://v8docs.nodesource.com/node-8.16/d4/dca/classv8_1_1_persistent_base.html) for further information.
+
+**Tip:** To get a `v8::Local` reference to the original object back from a `PersistentBase` or `Persistent` object:
+
+```c++
+v8::Local<v8::Object> object = Nan::New(persistent);
+```
+
+<a name="api_nan_non_copyable_persistent_traits"></a>
+### Nan::NonCopyablePersistentTraits & v8::NonCopyablePersistentTraits
+
+Default traits for `Nan::Persistent`. This class does not allow use of the a copy constructor or assignment operator. At present `kResetInDestructor` is not set, but that will change in a future version.
+
+Definition:
+
+_(note: this is implemented as `Nan::NonCopyablePersistentTraits` for older versions of V8 and the native `v8::NonCopyablePersistentTraits` is used for newer versions of V8)_
+
+```c++
+template<typename T> class NonCopyablePersistentTraits {
+ public:
+ typedef Persistent<T, NonCopyablePersistentTraits<T> > NonCopyablePersistent;
+
+ static const bool kResetInDestructor = false;
+
+ template<typename S, typename M>
+ static void Copy(const Persistent<S, M> &source,
+ NonCopyablePersistent *dest);
+
+ template<typename O> static void Uncompilable();
+};
+```
+
+See the V8 documentation for [`NonCopyablePersistentTraits`](https://v8docs.nodesource.com/node-8.16/de/d73/classv8_1_1_non_copyable_persistent_traits.html) for further information.
+
+<a name="api_nan_copyable_persistent_traits"></a>
+### Nan::CopyablePersistentTraits & v8::CopyablePersistentTraits
+
+A helper class of traits to allow copying and assignment of `Persistent`. This will clone the contents of storage cell, but not any of the flags, etc..
+
+Definition:
+
+_(note: this is implemented as `Nan::CopyablePersistentTraits` for older versions of V8 and the native `v8::NonCopyablePersistentTraits` is used for newer versions of V8)_
+
+```c++
+template<typename T>
+class CopyablePersistentTraits {
+ public:
+ typedef Persistent<T, CopyablePersistentTraits<T> > CopyablePersistent;
+
+ static const bool kResetInDestructor = true;
+
+ template<typename S, typename M>
+ static void Copy(const Persistent<S, M> &source,
+ CopyablePersistent *dest);
+};
+```
+
+See the V8 documentation for [`CopyablePersistentTraits`](https://v8docs.nodesource.com/node-8.16/da/d5c/structv8_1_1_copyable_persistent_traits.html) for further information.
+
+<a name="api_nan_persistent"></a>
+### Nan::Persistent
+
+A type of `PersistentBase` which allows copy and assignment. Copy, assignment and destructor behavior is controlled by the traits class `M`.
+
+Definition:
+
+```c++
+template<typename T, typename M = NonCopyablePersistentTraits<T> >
+class Persistent;
+
+template<typename T, typename M> class Persistent : public PersistentBase<T> {
+ public:
+ /**
+ * A Persistent with no storage cell.
+ */
+ Persistent();
+
+ /**
+ * Construct a Persistent from a v8::Local. When the v8::Local is non-empty, a
+ * new storage cell is created pointing to the same object, and no flags are
+ * set.
+ */
+ template<typename S> Persistent(v8::Local<S> that);
+
+ /**
+ * Construct a Persistent from a Persistent. When the Persistent is non-empty,
+ * a new storage cell is created pointing to the same object, and no flags are
+ * set.
+ */
+ Persistent(const Persistent &that);
+
+ /**
+ * The copy constructors and assignment operator create a Persistent exactly
+ * as the Persistent constructor, but the Copy function from the traits class
+ * is called, allowing the setting of flags based on the copied Persistent.
+ */
+ Persistent &operator=(const Persistent &that);
+
+ template <typename S, typename M2>
+ Persistent &operator=(const Persistent<S, M2> &that);
+
+ /**
+ * The destructor will dispose the Persistent based on the kResetInDestructor
+ * flags in the traits class. Since not calling dispose can result in a
+ * memory leak, it is recommended to always set this flag.
+ */
+ ~Persistent();
+};
+```
+
+See the V8 documentation for [`Persistent`](https://v8docs.nodesource.com/node-8.16/d2/d78/classv8_1_1_persistent.html) for further information.
+
+<a name="api_nan_global"></a>
+### Nan::Global
+
+A type of `PersistentBase` which has move semantics.
+
+```c++
+template<typename T> class Global : public PersistentBase<T> {
+ public:
+ /**
+ * A Global with no storage cell.
+ */
+ Global();
+
+ /**
+ * Construct a Global from a v8::Local. When the v8::Local is non-empty, a new
+ * storage cell is created pointing to the same object, and no flags are set.
+ */
+ template<typename S> Global(v8::Local<S> that);
+ /**
+ * Construct a Global from a PersistentBase. When the Persistent is non-empty,
+ * a new storage cell is created pointing to the same object, and no flags are
+ * set.
+ */
+ template<typename S> Global(const PersistentBase<S> &that);
+
+ /**
+ * Pass allows returning globals from functions, etc.
+ */
+ Global Pass();
+};
+```
+
+See the V8 documentation for [`Global`](https://v8docs.nodesource.com/node-8.16/d5/d40/classv8_1_1_global.html) for further information.
+
+<a name="api_nan_weak_callback_info"></a>
+### Nan::WeakCallbackInfo
+
+`Nan::WeakCallbackInfo` is used as an argument when setting a persistent reference as weak. You may need to free any external resources attached to the object. It is a mirror of `v8:WeakCallbackInfo` as found in newer versions of V8.
+
+Definition:
+
+```c++
+template<typename T> class WeakCallbackInfo {
+ public:
+ typedef void (*Callback)(const WeakCallbackInfo<T>& data);
+
+ v8::Isolate *GetIsolate() const;
+
+ /**
+ * Get the parameter that was associated with the weak handle.
+ */
+ T *GetParameter() const;
+
+ /**
+ * Get pointer from internal field, index can be 0 or 1.
+ */
+ void *GetInternalField(int index) const;
+};
+```
+
+Example usage:
+
+```c++
+void weakCallback(const WeakCallbackInfo<int> &data) {
+ int *parameter = data.GetParameter();
+ delete parameter;
+}
+
+Persistent<v8::Object> obj;
+int *data = new int(0);
+obj.SetWeak(data, callback, WeakCallbackType::kParameter);
+```
+
+See the V8 documentation for [`WeakCallbackInfo`](https://v8docs.nodesource.com/node-8.16/d8/d06/classv8_1_1_weak_callback_info.html) for further information.
+
+<a name="api_nan_weak_callback_type"></a>
+### Nan::WeakCallbackType
+
+Represents the type of a weak callback.
+A weak callback of type `kParameter` makes the supplied parameter to `Nan::PersistentBase::SetWeak` available through `WeakCallbackInfo::GetParameter`.
+A weak callback of type `kInternalFields` uses up to two internal fields at indices 0 and 1 on the `Nan::PersistentBase<v8::Object>` being made weak.
+Note that only `v8::Object`s and derivatives can have internal fields.
+
+Definition:
+
+```c++
+enum class WeakCallbackType { kParameter, kInternalFields };
+```
diff --git a/node_modules/nan/doc/scopes.md b/node_modules/nan/doc/scopes.md
new file mode 100644
index 0000000..84000ee
--- /dev/null
+++ b/node_modules/nan/doc/scopes.md
@@ -0,0 +1,73 @@
+## Scopes
+
+A _local handle_ is a pointer to an object. All V8 objects are accessed using handles, they are necessary because of the way the V8 garbage collector works.
+
+A handle scope can be thought of as a container for any number of handles. When you've finished with your handles, instead of deleting each one individually you can simply delete their scope.
+
+The creation of `HandleScope` objects is different across the supported versions of V8. Therefore, NAN provides its own implementations that can be used safely across these.
+
+ - <a href="#api_nan_handle_scope"><b><code>Nan::HandleScope</code></b></a>
+ - <a href="#api_nan_escapable_handle_scope"><b><code>Nan::EscapableHandleScope</code></b></a>
+
+Also see the V8 Embedders Guide section on [Handles and Garbage Collection](https://github.com/v8/v8/wiki/Embedder%27s%20Guide#handles-and-garbage-collection).
+
+<a name="api_nan_handle_scope"></a>
+### Nan::HandleScope
+
+A simple wrapper around [`v8::HandleScope`](https://v8docs.nodesource.com/node-8.16/d3/d95/classv8_1_1_handle_scope.html).
+
+Definition:
+
+```c++
+class Nan::HandleScope {
+ public:
+ Nan::HandleScope();
+ static int NumberOfHandles();
+};
+```
+
+Allocate a new `Nan::HandleScope` whenever you are creating new V8 JavaScript objects. Note that an implicit `HandleScope` is created for you on JavaScript-accessible methods so you do not need to insert one yourself.
+
+Example:
+
+```c++
+// new object is created, it needs a new scope:
+void Pointless() {
+ Nan::HandleScope scope;
+ v8::Local<v8::Object> obj = Nan::New<v8::Object>();
+}
+
+// JavaScript-accessible method already has a HandleScope
+NAN_METHOD(Pointless2) {
+ v8::Local<v8::Object> obj = Nan::New<v8::Object>();
+}
+```
+
+<a name="api_nan_escapable_handle_scope"></a>
+### Nan::EscapableHandleScope
+
+Similar to [`Nan::HandleScope`](#api_nan_handle_scope) but should be used in cases where a function needs to return a V8 JavaScript type that has been created within it.
+
+Definition:
+
+```c++
+class Nan::EscapableHandleScope {
+ public:
+ Nan::EscapableHandleScope();
+ static int NumberOfHandles();
+ template<typename T> v8::Local<T> Escape(v8::Local<T> value);
+}
+```
+
+Use `Escape(value)` to return the object.
+
+Example:
+
+```c++
+v8::Local<v8::Object> EmptyObj() {
+ Nan::EscapableHandleScope scope;
+ v8::Local<v8::Object> obj = Nan::New<v8::Object>();
+ return scope.Escape(obj);
+}
+```
+
diff --git a/node_modules/nan/doc/script.md b/node_modules/nan/doc/script.md
new file mode 100644
index 0000000..301c1b3
--- /dev/null
+++ b/node_modules/nan/doc/script.md
@@ -0,0 +1,58 @@
+## Script
+
+NAN provides `v8::Script` helpers as the API has changed over the supported versions of V8.
+
+ - <a href="#api_nan_compile_script"><b><code>Nan::CompileScript()</code></b></a>
+ - <a href="#api_nan_run_script"><b><code>Nan::RunScript()</code></b></a>
+ - <a href="#api_nan_script_origin"><b><code>Nan::ScriptOrigin</code></b></a>
+
+
+<a name="api_nan_compile_script"></a>
+### Nan::CompileScript()
+
+A wrapper around [`v8::ScriptCompiler::Compile()`](https://v8docs.nodesource.com/node-8.16/da/da5/classv8_1_1_script_compiler.html#a93f5072a0db55d881b969e9fc98e564b).
+
+Note that `Nan::BoundScript` is an alias for `v8::Script`.
+
+Signature:
+
+```c++
+Nan::MaybeLocal<Nan::BoundScript> Nan::CompileScript(
+ v8::Local<v8::String> s,
+ const v8::ScriptOrigin& origin);
+Nan::MaybeLocal<Nan::BoundScript> Nan::CompileScript(v8::Local<v8::String> s);
+```
+
+
+<a name="api_nan_run_script"></a>
+### Nan::RunScript()
+
+Calls `script->Run()` or `script->BindToCurrentContext()->Run(Nan::GetCurrentContext())`.
+
+Note that `Nan::BoundScript` is an alias for `v8::Script` and `Nan::UnboundScript` is an alias for `v8::UnboundScript` where available and `v8::Script` on older versions of V8.
+
+Signature:
+
+```c++
+Nan::MaybeLocal<v8::Value> Nan::RunScript(v8::Local<Nan::UnboundScript> script)
+Nan::MaybeLocal<v8::Value> Nan::RunScript(v8::Local<Nan::BoundScript> script)
+```
+
+<a name="api_nan_script_origin"></a>
+### Nan::ScriptOrigin
+
+A class transparently extending [`v8::ScriptOrigin`](https://v8docs.nodesource.com/node-16.0/db/d84/classv8_1_1_script_origin.html#pub-methods)
+to provide backwards compatibility. Only the listed methods are guaranteed to
+be available on all versions of Node.
+
+Declaration:
+
+```c++
+class Nan::ScriptOrigin : public v8::ScriptOrigin {
+ public:
+ ScriptOrigin(v8::Local<v8::Value> name, v8::Local<v8::Integer> line = v8::Local<v8::Integer>(), v8::Local<v8::Integer> column = v8::Local<v8::Integer>())
+ v8::Local<v8::Value> ResourceName() const;
+ v8::Local<v8::Integer> ResourceLineOffset() const;
+ v8::Local<v8::Integer> ResourceColumnOffset() const;
+}
+```
diff --git a/node_modules/nan/doc/string_bytes.md b/node_modules/nan/doc/string_bytes.md
new file mode 100644
index 0000000..7c1bd32
--- /dev/null
+++ b/node_modules/nan/doc/string_bytes.md
@@ -0,0 +1,62 @@
+## Strings & Bytes
+
+Miscellaneous string & byte encoding and decoding functionality provided for compatibility across supported versions of V8 and Node. Implemented by NAN to ensure that all encoding types are supported, even for older versions of Node where they are missing.
+
+ - <a href="#api_nan_encoding"><b><code>Nan::Encoding</code></b></a>
+ - <a href="#api_nan_encode"><b><code>Nan::Encode()</code></b></a>
+ - <a href="#api_nan_decode_bytes"><b><code>Nan::DecodeBytes()</code></b></a>
+ - <a href="#api_nan_decode_write"><b><code>Nan::DecodeWrite()</code></b></a>
+
+
+<a name="api_nan_encoding"></a>
+### Nan::Encoding
+
+An enum representing the supported encoding types. A copy of `node::encoding` that is consistent across versions of Node.
+
+Definition:
+
+```c++
+enum Nan::Encoding { ASCII, UTF8, BASE64, UCS2, BINARY, HEX, BUFFER }
+```
+
+
+<a name="api_nan_encode"></a>
+### Nan::Encode()
+
+A wrapper around `node::Encode()` that provides a consistent implementation across supported versions of Node.
+
+Signature:
+
+```c++
+v8::Local<v8::Value> Nan::Encode(const void *buf,
+ size_t len,
+ enum Nan::Encoding encoding = BINARY);
+```
+
+
+<a name="api_nan_decode_bytes"></a>
+### Nan::DecodeBytes()
+
+A wrapper around `node::DecodeBytes()` that provides a consistent implementation across supported versions of Node.
+
+Signature:
+
+```c++
+ssize_t Nan::DecodeBytes(v8::Local<v8::Value> val,
+ enum Nan::Encoding encoding = BINARY);
+```
+
+
+<a name="api_nan_decode_write"></a>
+### Nan::DecodeWrite()
+
+A wrapper around `node::DecodeWrite()` that provides a consistent implementation across supported versions of Node.
+
+Signature:
+
+```c++
+ssize_t Nan::DecodeWrite(char *buf,
+ size_t len,
+ v8::Local<v8::Value> val,
+ enum Nan::Encoding encoding = BINARY);
+```
diff --git a/node_modules/nan/doc/v8_internals.md b/node_modules/nan/doc/v8_internals.md
new file mode 100644
index 0000000..08dd6d0
--- /dev/null
+++ b/node_modules/nan/doc/v8_internals.md
@@ -0,0 +1,199 @@
+## V8 internals
+
+The hooks to access V8 internals—including GC and statistics—are different across the supported versions of V8, therefore NAN provides its own hooks that call the appropriate V8 methods.
+
+ - <a href="#api_nan_gc_callback"><b><code>NAN_GC_CALLBACK()</code></b></a>
+ - <a href="#api_nan_add_gc_epilogue_callback"><b><code>Nan::AddGCEpilogueCallback()</code></b></a>
+ - <a href="#api_nan_remove_gc_epilogue_callback"><b><code>Nan::RemoveGCEpilogueCallback()</code></b></a>
+ - <a href="#api_nan_add_gc_prologue_callback"><b><code>Nan::AddGCPrologueCallback()</code></b></a>
+ - <a href="#api_nan_remove_gc_prologue_callback"><b><code>Nan::RemoveGCPrologueCallback()</code></b></a>
+ - <a href="#api_nan_get_heap_statistics"><b><code>Nan::GetHeapStatistics()</code></b></a>
+ - <a href="#api_nan_set_counter_function"><b><code>Nan::SetCounterFunction()</code></b></a>
+ - <a href="#api_nan_set_create_histogram_function"><b><code>Nan::SetCreateHistogramFunction()</code></b></a>
+ - <a href="#api_nan_set_add_histogram_sample_function"><b><code>Nan::SetAddHistogramSampleFunction()</code></b></a>
+ - <a href="#api_nan_idle_notification"><b><code>Nan::IdleNotification()</code></b></a>
+ - <a href="#api_nan_low_memory_notification"><b><code>Nan::LowMemoryNotification()</code></b></a>
+ - <a href="#api_nan_context_disposed_notification"><b><code>Nan::ContextDisposedNotification()</code></b></a>
+ - <a href="#api_nan_get_internal_field_pointer"><b><code>Nan::GetInternalFieldPointer()</code></b></a>
+ - <a href="#api_nan_set_internal_field_pointer"><b><code>Nan::SetInternalFieldPointer()</code></b></a>
+ - <a href="#api_nan_adjust_external_memory"><b><code>Nan::AdjustExternalMemory()</code></b></a>
+
+
+<a name="api_nan_gc_callback"></a>
+### NAN_GC_CALLBACK(callbackname)
+
+Use `NAN_GC_CALLBACK` to declare your callbacks for `Nan::AddGCPrologueCallback()` and `Nan::AddGCEpilogueCallback()`. Your new method receives the arguments `v8::GCType type` and `v8::GCCallbackFlags flags`.
+
+```c++
+static Nan::Persistent<Function> callback;
+
+NAN_GC_CALLBACK(gcPrologueCallback) {
+ v8::Local<Value> argv[] = { Nan::New("prologue").ToLocalChecked() };
+ Nan::MakeCallback(Nan::GetCurrentContext()->Global(), Nan::New(callback), 1, argv);
+}
+
+NAN_METHOD(Hook) {
+ callback.Reset(To<Function>(args[0]).ToLocalChecked());
+ Nan::AddGCPrologueCallback(gcPrologueCallback);
+ info.GetReturnValue().Set(info.Holder());
+}
+```
+
+<a name="api_nan_add_gc_epilogue_callback"></a>
+### Nan::AddGCEpilogueCallback()
+
+Signature:
+
+```c++
+void Nan::AddGCEpilogueCallback(v8::Isolate::GCEpilogueCallback callback, v8::GCType gc_type_filter = v8::kGCTypeAll)
+```
+
+Calls V8's [`AddGCEpilogueCallback()`](https://v8docs.nodesource.com/node-8.16/d5/dda/classv8_1_1_isolate.html#a580f976e4290cead62c2fc4dd396be3e).
+
+<a name="api_nan_remove_gc_epilogue_callback"></a>
+### Nan::RemoveGCEpilogueCallback()
+
+Signature:
+
+```c++
+void Nan::RemoveGCEpilogueCallback(v8::Isolate::GCEpilogueCallback callback)
+```
+
+Calls V8's [`RemoveGCEpilogueCallback()`](https://v8docs.nodesource.com/node-8.16/d5/dda/classv8_1_1_isolate.html#adca9294555a3908e9f23c7bb0f0f284c).
+
+<a name="api_nan_add_gc_prologue_callback"></a>
+### Nan::AddGCPrologueCallback()
+
+Signature:
+
+```c++
+void Nan::AddGCPrologueCallback(v8::Isolate::GCPrologueCallback, v8::GCType gc_type_filter callback)
+```
+
+Calls V8's [`AddGCPrologueCallback()`](https://v8docs.nodesource.com/node-8.16/d5/dda/classv8_1_1_isolate.html#a6dbef303603ebdb03da6998794ea05b8).
+
+<a name="api_nan_remove_gc_prologue_callback"></a>
+### Nan::RemoveGCPrologueCallback()
+
+Signature:
+
+```c++
+void Nan::RemoveGCPrologueCallback(v8::Isolate::GCPrologueCallback callback)
+```
+
+Calls V8's [`RemoveGCPrologueCallback()`](https://v8docs.nodesource.com/node-8.16/d5/dda/classv8_1_1_isolate.html#a5f72c7cda21415ce062bbe5c58abe09e).
+
+<a name="api_nan_get_heap_statistics"></a>
+### Nan::GetHeapStatistics()
+
+Signature:
+
+```c++
+void Nan::GetHeapStatistics(v8::HeapStatistics *heap_statistics)
+```
+
+Calls V8's [`GetHeapStatistics()`](https://v8docs.nodesource.com/node-8.16/d5/dda/classv8_1_1_isolate.html#a5593ac74687b713095c38987e5950b34).
+
+<a name="api_nan_set_counter_function"></a>
+### Nan::SetCounterFunction()
+
+Signature:
+
+```c++
+void Nan::SetCounterFunction(v8::CounterLookupCallback cb)
+```
+
+Calls V8's [`SetCounterFunction()`](https://v8docs.nodesource.com/node-8.16/d5/dda/classv8_1_1_isolate.html#a045d7754e62fa0ec72ae6c259b29af94).
+
+<a name="api_nan_set_create_histogram_function"></a>
+### Nan::SetCreateHistogramFunction()
+
+Signature:
+
+```c++
+void Nan::SetCreateHistogramFunction(v8::CreateHistogramCallback cb)
+```
+
+Calls V8's [`SetCreateHistogramFunction()`](https://v8docs.nodesource.com/node-8.16/d5/dda/classv8_1_1_isolate.html#a542d67e85089cb3f92aadf032f99e732).
+
+<a name="api_nan_set_add_histogram_sample_function"></a>
+### Nan::SetAddHistogramSampleFunction()
+
+Signature:
+
+```c++
+void Nan::SetAddHistogramSampleFunction(v8::AddHistogramSampleCallback cb)
+```
+
+Calls V8's [`SetAddHistogramSampleFunction()`](https://v8docs.nodesource.com/node-8.16/d5/dda/classv8_1_1_isolate.html#aeb420b690bc2c216882d6fdd00ddd3ea).
+
+<a name="api_nan_idle_notification"></a>
+### Nan::IdleNotification()
+
+Signature:
+
+```c++
+bool Nan::IdleNotification(int idle_time_in_ms)
+```
+
+Calls V8's [`IdleNotification()` or `IdleNotificationDeadline()`](https://v8docs.nodesource.com/node-8.16/d5/dda/classv8_1_1_isolate.html#ad6a2a02657f5425ad460060652a5a118) depending on V8 version.
+
+<a name="api_nan_low_memory_notification"></a>
+### Nan::LowMemoryNotification()
+
+Signature:
+
+```c++
+void Nan::LowMemoryNotification()
+```
+
+Calls V8's [`LowMemoryNotification()`](https://v8docs.nodesource.com/node-8.16/d5/dda/classv8_1_1_isolate.html#a24647f61d6b41f69668094bdcd6ea91f).
+
+<a name="api_nan_context_disposed_notification"></a>
+### Nan::ContextDisposedNotification()
+
+Signature:
+
+```c++
+void Nan::ContextDisposedNotification()
+```
+
+Calls V8's [`ContextDisposedNotification()`](https://v8docs.nodesource.com/node-8.16/d5/dda/classv8_1_1_isolate.html#ad7f5dc559866343fe6cd8db1f134d48b).
+
+<a name="api_nan_get_internal_field_pointer"></a>
+### Nan::GetInternalFieldPointer()
+
+Gets a pointer to the internal field with at `index` from a V8 `Object` handle.
+
+Signature:
+
+```c++
+void* Nan::GetInternalFieldPointer(v8::Local<v8::Object> object, int index)
+```
+
+Calls the Object's [`GetAlignedPointerFromInternalField()` or `GetPointerFromInternalField()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#a580ea84afb26c005d6762eeb9e3c308f) depending on the version of V8.
+
+<a name="api_nan_set_internal_field_pointer"></a>
+### Nan::SetInternalFieldPointer()
+
+Sets the value of the internal field at `index` on a V8 `Object` handle.
+
+Signature:
+
+```c++
+void Nan::SetInternalFieldPointer(v8::Local<v8::Object> object, int index, void* value)
+```
+
+Calls the Object's [`SetAlignedPointerInInternalField()` or `SetPointerInInternalField()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#ab3c57184263cf29963ef0017bec82281) depending on the version of V8.
+
+<a name="api_nan_adjust_external_memory"></a>
+### Nan::AdjustExternalMemory()
+
+Signature:
+
+```c++
+int Nan::AdjustExternalMemory(int bytesChange)
+```
+
+Calls V8's [`AdjustAmountOfExternalAllocatedMemory()`](https://v8docs.nodesource.com/node-8.16/d5/dda/classv8_1_1_isolate.html#ae1a59cac60409d3922582c4af675473e).
+
diff --git a/node_modules/nan/doc/v8_misc.md b/node_modules/nan/doc/v8_misc.md
new file mode 100644
index 0000000..1bd46d3
--- /dev/null
+++ b/node_modules/nan/doc/v8_misc.md
@@ -0,0 +1,85 @@
+## Miscellaneous V8 Helpers
+
+ - <a href="#api_nan_utf8_string"><b><code>Nan::Utf8String</code></b></a>
+ - <a href="#api_nan_get_current_context"><b><code>Nan::GetCurrentContext()</code></b></a>
+ - <a href="#api_nan_set_isolate_data"><b><code>Nan::SetIsolateData()</code></b></a>
+ - <a href="#api_nan_get_isolate_data"><b><code>Nan::GetIsolateData()</code></b></a>
+ - <a href="#api_nan_typedarray_contents"><b><code>Nan::TypedArrayContents</code></b></a>
+
+
+<a name="api_nan_utf8_string"></a>
+### Nan::Utf8String
+
+Converts an object to a UTF-8-encoded character array. If conversion to a string fails (e.g. due to an exception in the toString() method of the object) then the length() method returns 0 and the * operator returns NULL. The underlying memory used for this object is managed by the object.
+
+An implementation of [`v8::String::Utf8Value`](https://v8docs.nodesource.com/node-8.16/d4/d1b/classv8_1_1_string_1_1_utf8_value.html) that is consistent across all supported versions of V8.
+
+Definition:
+
+```c++
+class Nan::Utf8String {
+ public:
+ Nan::Utf8String(v8::Local<v8::Value> from);
+
+ int length() const;
+
+ char* operator*();
+ const char* operator*() const;
+};
+```
+
+<a name="api_nan_get_current_context"></a>
+### Nan::GetCurrentContext()
+
+A call to [`v8::Isolate::GetCurrent()->GetCurrentContext()`](https://v8docs.nodesource.com/node-8.16/d5/dda/classv8_1_1_isolate.html#a81c7a1ed7001ae2a65e89107f75fd053) that works across all supported versions of V8.
+
+Signature:
+
+```c++
+v8::Local<v8::Context> Nan::GetCurrentContext()
+```
+
+<a name="api_nan_set_isolate_data"></a>
+### Nan::SetIsolateData()
+
+A helper to provide a consistent API to [`v8::Isolate#SetData()`](https://v8docs.nodesource.com/node-8.16/d5/dda/classv8_1_1_isolate.html#a7acadfe7965997e9c386a05f098fbe36).
+
+Signature:
+
+```c++
+void Nan::SetIsolateData(v8::Isolate *isolate, T *data)
+```
+
+
+<a name="api_nan_get_isolate_data"></a>
+### Nan::GetIsolateData()
+
+A helper to provide a consistent API to [`v8::Isolate#GetData()`](https://v8docs.nodesource.com/node-8.16/d5/dda/classv8_1_1_isolate.html#aabd223436bc1100a787dadaa024c6257).
+
+Signature:
+
+```c++
+T *Nan::GetIsolateData(v8::Isolate *isolate)
+```
+
+<a name="api_nan_typedarray_contents"></a>
+### Nan::TypedArrayContents<T>
+
+A helper class for accessing the contents of an ArrayBufferView (aka a typedarray) from C++. If the input array is not a valid typedarray, then the data pointer of TypedArrayContents will default to `NULL` and the length will be 0. If the data pointer is not compatible with the alignment requirements of type, an assertion error will fail.
+
+Note that you must store a reference to the `array` object while you are accessing its contents.
+
+Definition:
+
+```c++
+template<typename T>
+class Nan::TypedArrayContents {
+ public:
+ TypedArrayContents(v8::Local<Value> array);
+
+ size_t length() const;
+
+ T* const operator*();
+ const T* const operator*() const;
+};
+```
diff --git a/node_modules/nan/include_dirs.js b/node_modules/nan/include_dirs.js
new file mode 100644
index 0000000..4f1dfb4
--- /dev/null
+++ b/node_modules/nan/include_dirs.js
@@ -0,0 +1 @@
+console.log(require('path').relative('.', __dirname));
diff --git a/node_modules/nan/nan.h b/node_modules/nan/nan.h
new file mode 100644
index 0000000..6c8356c
--- /dev/null
+++ b/node_modules/nan/nan.h
@@ -0,0 +1,2904 @@
+/*********************************************************************
+ * NAN - Native Abstractions for Node.js
+ *
+ * Copyright (c) 2018 NAN contributors:
+ * - Rod Vagg <https://github.com/rvagg>
+ * - Benjamin Byholm <https://github.com/kkoopa>
+ * - Trevor Norris <https://github.com/trevnorris>
+ * - Nathan Rajlich <https://github.com/TooTallNate>
+ * - Brett Lawson <https://github.com/brett19>
+ * - Ben Noordhuis <https://github.com/bnoordhuis>
+ * - David Siegel <https://github.com/agnat>
+ * - Michael Ira Krufky <https://github.com/mkrufky>
+ *
+ * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
+ *
+ * Version 2.15.0: current Node 16.6.1, Node 0.12: 0.12.18, Node 0.10: 0.10.48, iojs: 3.3.1
+ *
+ * See https://github.com/nodejs/nan for the latest update to this file
+ **********************************************************************************/
+
+#ifndef NAN_H_
+#define NAN_H_
+
+#include <node_version.h>
+
+#define NODE_0_10_MODULE_VERSION 11
+#define NODE_0_12_MODULE_VERSION 14
+#define ATOM_0_21_MODULE_VERSION 41
+#define IOJS_1_0_MODULE_VERSION 42
+#define IOJS_1_1_MODULE_VERSION 43
+#define IOJS_2_0_MODULE_VERSION 44
+#define IOJS_3_0_MODULE_VERSION 45
+#define NODE_4_0_MODULE_VERSION 46
+#define NODE_5_0_MODULE_VERSION 47
+#define NODE_6_0_MODULE_VERSION 48
+#define NODE_7_0_MODULE_VERSION 51
+#define NODE_8_0_MODULE_VERSION 57
+#define NODE_9_0_MODULE_VERSION 59
+#define NODE_10_0_MODULE_VERSION 64
+#define NODE_11_0_MODULE_VERSION 67
+#define NODE_12_0_MODULE_VERSION 72
+#define NODE_13_0_MODULE_VERSION 79
+#define NODE_14_0_MODULE_VERSION 83
+#define NODE_15_0_MODULE_VERSION 88
+#define NODE_16_0_MODULE_VERSION 93
+
+#ifdef _MSC_VER
+# define NAN_HAS_CPLUSPLUS_11 (_MSC_VER >= 1800)
+#else
+# define NAN_HAS_CPLUSPLUS_11 (__cplusplus >= 201103L)
+#endif
+
+#if NODE_MODULE_VERSION >= IOJS_3_0_MODULE_VERSION && !NAN_HAS_CPLUSPLUS_11
+# error This version of node/NAN/v8 requires a C++11 compiler
+#endif
+
+#include <uv.h>
+#include <node.h>
+#include <node_buffer.h>
+#include <node_object_wrap.h>
+#include <algorithm>
+#include <cstring>
+#include <climits>
+#include <cstdlib>
+#include <utility>
+#if defined(_MSC_VER)
+# pragma warning( push )
+# pragma warning( disable : 4530 )
+# include <queue>
+# include <string>
+# include <vector>
+# pragma warning( pop )
+#else
+# include <queue>
+# include <string>
+# include <vector>
+#endif
+
+// uv helpers
+#ifdef UV_VERSION_MAJOR
+# ifndef UV_VERSION_PATCH
+# define UV_VERSION_PATCH 0
+# endif
+# define NAUV_UVVERSION ((UV_VERSION_MAJOR << 16) | \
+ (UV_VERSION_MINOR << 8) | \
+ (UV_VERSION_PATCH))
+#else
+# define NAUV_UVVERSION 0x000b00
+#endif
+
+#if NAUV_UVVERSION < 0x000b0b
+# ifdef WIN32
+# include <windows.h>
+# else
+# include <pthread.h>
+# endif
+#endif
+
+namespace Nan {
+
+#define NAN_CONCAT(a, b) NAN_CONCAT_HELPER(a, b)
+#define NAN_CONCAT_HELPER(a, b) a##b
+
+#define NAN_INLINE inline // TODO(bnoordhuis) Remove in v3.0.0.
+
+#if defined(__GNUC__) && \
+ !(defined(V8_DISABLE_DEPRECATIONS) && V8_DISABLE_DEPRECATIONS)
+# define NAN_DEPRECATED __attribute__((deprecated))
+#elif defined(_MSC_VER) && \
+ !(defined(V8_DISABLE_DEPRECATIONS) && V8_DISABLE_DEPRECATIONS)
+# define NAN_DEPRECATED __declspec(deprecated)
+#else
+# define NAN_DEPRECATED
+#endif
+
+#if NAN_HAS_CPLUSPLUS_11
+# define NAN_DISALLOW_ASSIGN(CLASS) void operator=(const CLASS&) = delete;
+# define NAN_DISALLOW_COPY(CLASS) CLASS(const CLASS&) = delete;
+# define NAN_DISALLOW_MOVE(CLASS) \
+ CLASS(CLASS&&) = delete; /* NOLINT(build/c++11) */ \
+ void operator=(CLASS&&) = delete;
+#else
+# define NAN_DISALLOW_ASSIGN(CLASS) void operator=(const CLASS&);
+# define NAN_DISALLOW_COPY(CLASS) CLASS(const CLASS&);
+# define NAN_DISALLOW_MOVE(CLASS)
+#endif
+
+#define NAN_DISALLOW_ASSIGN_COPY(CLASS) \
+ NAN_DISALLOW_ASSIGN(CLASS) \
+ NAN_DISALLOW_COPY(CLASS)
+
+#define NAN_DISALLOW_ASSIGN_MOVE(CLASS) \
+ NAN_DISALLOW_ASSIGN(CLASS) \
+ NAN_DISALLOW_MOVE(CLASS)
+
+#define NAN_DISALLOW_COPY_MOVE(CLASS) \
+ NAN_DISALLOW_COPY(CLASS) \
+ NAN_DISALLOW_MOVE(CLASS)
+
+#define NAN_DISALLOW_ASSIGN_COPY_MOVE(CLASS) \
+ NAN_DISALLOW_ASSIGN(CLASS) \
+ NAN_DISALLOW_COPY(CLASS) \
+ NAN_DISALLOW_MOVE(CLASS)
+
+#define TYPE_CHECK(T, S) \
+ while (false) { \
+ *(static_cast<T *volatile *>(0)) = static_cast<S*>(0); \
+ }
+
+//=== RegistrationFunction =====================================================
+
+#if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION
+ typedef v8::Handle<v8::Object> ADDON_REGISTER_FUNCTION_ARGS_TYPE;
+#else
+ typedef v8::Local<v8::Object> ADDON_REGISTER_FUNCTION_ARGS_TYPE;
+#endif
+
+#define NAN_MODULE_INIT(name) \
+ void name(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target)
+
+#if NODE_MAJOR_VERSION >= 10 || \
+ NODE_MAJOR_VERSION == 9 && NODE_MINOR_VERSION >= 3
+#define NAN_MODULE_WORKER_ENABLED(module_name, registration) \
+ extern "C" NODE_MODULE_EXPORT void \
+ NAN_CONCAT(node_register_module_v, NODE_MODULE_VERSION)( \
+ v8::Local<v8::Object> exports, v8::Local<v8::Value> module, \
+ v8::Local<v8::Context> context) \
+ { \
+ registration(exports); \
+ }
+#else
+#define NAN_MODULE_WORKER_ENABLED(module_name, registration) \
+ NODE_MODULE(module_name, registration)
+#endif
+
+//=== CallbackInfo =============================================================
+
+#include "nan_callbacks.h" // NOLINT(build/include)
+
+//==============================================================================
+
+#if (NODE_MODULE_VERSION < NODE_0_12_MODULE_VERSION)
+typedef v8::Script UnboundScript;
+typedef v8::Script BoundScript;
+#else
+typedef v8::UnboundScript UnboundScript;
+typedef v8::Script BoundScript;
+#endif
+
+#if (NODE_MODULE_VERSION < ATOM_0_21_MODULE_VERSION)
+typedef v8::String::ExternalAsciiStringResource
+ ExternalOneByteStringResource;
+#else
+typedef v8::String::ExternalOneByteStringResource
+ ExternalOneByteStringResource;
+#endif
+
+#if (NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION)
+template<typename T>
+class NonCopyablePersistentTraits :
+ public v8::NonCopyablePersistentTraits<T> {};
+template<typename T>
+class CopyablePersistentTraits :
+ public v8::CopyablePersistentTraits<T> {};
+
+template<typename T>
+class PersistentBase :
+ public v8::PersistentBase<T> {};
+
+template<typename T, typename M = v8::NonCopyablePersistentTraits<T> >
+class Persistent;
+#else
+template<typename T> class NonCopyablePersistentTraits;
+template<typename T> class PersistentBase;
+template<typename T, typename P> class WeakCallbackData;
+template<typename T, typename M = NonCopyablePersistentTraits<T> >
+class Persistent;
+#endif // NODE_MODULE_VERSION
+
+template<typename T>
+class Maybe {
+ public:
+ inline bool IsNothing() const { return !has_value_; }
+ inline bool IsJust() const { return has_value_; }
+
+ inline T ToChecked() const { return FromJust(); }
+ inline void Check() const { FromJust(); }
+
+ inline bool To(T* out) const {
+ if (IsJust()) *out = value_;
+ return IsJust();
+ }
+
+ inline T FromJust() const {
+#if defined(V8_ENABLE_CHECKS)
+ assert(IsJust() && "FromJust is Nothing");
+#endif // V8_ENABLE_CHECKS
+ return value_;
+ }
+
+ inline T FromMaybe(const T& default_value) const {
+ return has_value_ ? value_ : default_value;
+ }
+
+ inline bool operator==(const Maybe &other) const {
+ return (IsJust() == other.IsJust()) &&
+ (!IsJust() || FromJust() == other.FromJust());
+ }
+
+ inline bool operator!=(const Maybe &other) const {
+ return !operator==(other);
+ }
+
+#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
+ (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
+ // Allow implicit conversions from v8::Maybe<T> to Nan::Maybe<T>.
+ Maybe(const v8::Maybe<T>& that) // NOLINT(runtime/explicit)
+ : has_value_(that.IsJust())
+ , value_(that.FromMaybe(T())) {}
+#endif
+
+ private:
+ Maybe() : has_value_(false) {}
+ explicit Maybe(const T& t) : has_value_(true), value_(t) {}
+ bool has_value_;
+ T value_;
+
+ template<typename U>
+ friend Maybe<U> Nothing();
+ template<typename U>
+ friend Maybe<U> Just(const U& u);
+};
+
+template<typename T>
+inline Maybe<T> Nothing() {
+ return Maybe<T>();
+}
+
+template<typename T>
+inline Maybe<T> Just(const T& t) {
+ return Maybe<T>(t);
+}
+
+#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
+ (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
+# include "nan_maybe_43_inl.h" // NOLINT(build/include)
+#else
+# include "nan_maybe_pre_43_inl.h" // NOLINT(build/include)
+#endif
+
+#include "nan_converters.h" // NOLINT(build/include)
+#include "nan_new.h" // NOLINT(build/include)
+
+#if NAUV_UVVERSION < 0x000b17
+#define NAUV_WORK_CB(func) \
+ void func(uv_async_t *async, int)
+#else
+#define NAUV_WORK_CB(func) \
+ void func(uv_async_t *async)
+#endif
+
+#if NAUV_UVVERSION >= 0x000b0b
+
+typedef uv_key_t nauv_key_t;
+
+inline int nauv_key_create(nauv_key_t *key) {
+ return uv_key_create(key);
+}
+
+inline void nauv_key_delete(nauv_key_t *key) {
+ uv_key_delete(key);
+}
+
+inline void* nauv_key_get(nauv_key_t *key) {
+ return uv_key_get(key);
+}
+
+inline void nauv_key_set(nauv_key_t *key, void *value) {
+ uv_key_set(key, value);
+}
+
+#else
+
+/* Implement thread local storage for older versions of libuv.
+ * This is essentially a backport of libuv commit 5d2434bf
+ * written by Ben Noordhuis, adjusted for names and inline.
+ */
+
+#ifndef WIN32
+
+typedef pthread_key_t nauv_key_t;
+
+inline int nauv_key_create(nauv_key_t* key) {
+ return -pthread_key_create(key, NULL);
+}
+
+inline void nauv_key_delete(nauv_key_t* key) {
+ if (pthread_key_delete(*key))
+ abort();
+}
+
+inline void* nauv_key_get(nauv_key_t* key) {
+ return pthread_getspecific(*key);
+}
+
+inline void nauv_key_set(nauv_key_t* key, void* value) {
+ if (pthread_setspecific(*key, value))
+ abort();
+}
+
+#else
+
+typedef struct {
+ DWORD tls_index;
+} nauv_key_t;
+
+inline int nauv_key_create(nauv_key_t* key) {
+ key->tls_index = TlsAlloc();
+ if (key->tls_index == TLS_OUT_OF_INDEXES)
+ return UV_ENOMEM;
+ return 0;
+}
+
+inline void nauv_key_delete(nauv_key_t* key) {
+ if (TlsFree(key->tls_index) == FALSE)
+ abort();
+ key->tls_index = TLS_OUT_OF_INDEXES;
+}
+
+inline void* nauv_key_get(nauv_key_t* key) {
+ void* value = TlsGetValue(key->tls_index);
+ if (value == NULL)
+ if (GetLastError() != ERROR_SUCCESS)
+ abort();
+ return value;
+}
+
+inline void nauv_key_set(nauv_key_t* key, void* value) {
+ if (TlsSetValue(key->tls_index, value) == FALSE)
+ abort();
+}
+
+#endif
+#endif
+
+#if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION
+template<typename T>
+v8::Local<T> New(v8::Handle<T>);
+#endif
+
+#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
+ (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
+ typedef v8::WeakCallbackType WeakCallbackType;
+#else
+struct WeakCallbackType {
+ enum E {kParameter, kInternalFields};
+ E type;
+ WeakCallbackType(E other) : type(other) {} // NOLINT(runtime/explicit)
+ inline bool operator==(E other) { return other == this->type; }
+ inline bool operator!=(E other) { return !operator==(other); }
+};
+#endif
+
+template<typename P> class WeakCallbackInfo;
+
+#if NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
+# include "nan_persistent_12_inl.h" // NOLINT(build/include)
+#else
+# include "nan_persistent_pre_12_inl.h" // NOLINT(build/include)
+#endif
+
+namespace imp {
+ static const size_t kMaxLength = 0x3fffffff;
+ // v8::String::REPLACE_INVALID_UTF8 was introduced
+ // in node.js v0.10.29 and v0.8.27.
+#if NODE_MAJOR_VERSION > 0 || \
+ NODE_MINOR_VERSION > 10 || \
+ NODE_MINOR_VERSION == 10 && NODE_PATCH_VERSION >= 29 || \
+ NODE_MINOR_VERSION == 8 && NODE_PATCH_VERSION >= 27
+ static const unsigned kReplaceInvalidUtf8 = v8::String::REPLACE_INVALID_UTF8;
+#else
+ static const unsigned kReplaceInvalidUtf8 = 0;
+#endif
+} // end of namespace imp
+
+//=== HandleScope ==============================================================
+
+class HandleScope {
+ v8::HandleScope scope;
+
+ public:
+#if NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
+ inline HandleScope() : scope(v8::Isolate::GetCurrent()) {}
+ inline static int NumberOfHandles() {
+ return v8::HandleScope::NumberOfHandles(v8::Isolate::GetCurrent());
+ }
+#else
+ inline HandleScope() : scope() {}
+ inline static int NumberOfHandles() {
+ return v8::HandleScope::NumberOfHandles();
+ }
+#endif
+
+ private:
+ // Make it hard to create heap-allocated or illegal handle scopes by
+ // disallowing certain operations.
+ HandleScope(const HandleScope &);
+ void operator=(const HandleScope &);
+ void *operator new(size_t size);
+ void operator delete(void *, size_t) {
+ abort();
+ }
+};
+
+class EscapableHandleScope {
+ public:
+#if NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
+ inline EscapableHandleScope() : scope(v8::Isolate::GetCurrent()) {}
+
+ inline static int NumberOfHandles() {
+ return v8::EscapableHandleScope::NumberOfHandles(v8::Isolate::GetCurrent());
+ }
+
+ template<typename T>
+ inline v8::Local<T> Escape(v8::Local<T> value) {
+ return scope.Escape(value);
+ }
+
+ private:
+ v8::EscapableHandleScope scope;
+#else
+ inline EscapableHandleScope() : scope() {}
+
+ inline static int NumberOfHandles() {
+ return v8::HandleScope::NumberOfHandles();
+ }
+
+ template<typename T>
+ inline v8::Local<T> Escape(v8::Local<T> value) {
+ return scope.Close(value);
+ }
+
+ private:
+ v8::HandleScope scope;
+#endif
+
+ private:
+ // Make it hard to create heap-allocated or illegal handle scopes by
+ // disallowing certain operations.
+ EscapableHandleScope(const EscapableHandleScope &);
+ void operator=(const EscapableHandleScope &);
+ void *operator new(size_t size);
+ void operator delete(void *, size_t) {
+ abort();
+ }
+};
+
+//=== TryCatch =================================================================
+
+class TryCatch {
+ v8::TryCatch try_catch_;
+ friend void FatalException(const TryCatch&);
+
+ public:
+#if NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION
+ TryCatch() : try_catch_(v8::Isolate::GetCurrent()) {}
+#endif
+
+ inline bool HasCaught() const { return try_catch_.HasCaught(); }
+
+ inline bool CanContinue() const { return try_catch_.CanContinue(); }
+
+ inline v8::Local<v8::Value> ReThrow() {
+#if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION
+ return New(try_catch_.ReThrow());
+#else
+ return try_catch_.ReThrow();
+#endif
+ }
+
+ inline v8::Local<v8::Value> Exception() const {
+ return try_catch_.Exception();
+ }
+
+#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
+ (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
+ inline v8::MaybeLocal<v8::Value> StackTrace() const {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ return scope.Escape(try_catch_.StackTrace(isolate->GetCurrentContext())
+ .FromMaybe(v8::Local<v8::Value>()));
+ }
+#else
+ inline MaybeLocal<v8::Value> StackTrace() const {
+ return try_catch_.StackTrace();
+ }
+#endif
+
+ inline v8::Local<v8::Message> Message() const {
+ return try_catch_.Message();
+ }
+
+ inline void Reset() { try_catch_.Reset(); }
+
+ inline void SetVerbose(bool value) { try_catch_.SetVerbose(value); }
+
+ inline void SetCaptureMessage(bool value) {
+ try_catch_.SetCaptureMessage(value);
+ }
+};
+
+v8::Local<v8::Value> MakeCallback(v8::Local<v8::Object> target,
+ v8::Local<v8::Function> func,
+ int argc,
+ v8::Local<v8::Value>* argv);
+v8::Local<v8::Value> MakeCallback(v8::Local<v8::Object> target,
+ v8::Local<v8::String> symbol,
+ int argc,
+ v8::Local<v8::Value>* argv);
+v8::Local<v8::Value> MakeCallback(v8::Local<v8::Object> target,
+ const char* method,
+ int argc,
+ v8::Local<v8::Value>* argv);
+
+// === AsyncResource ===========================================================
+
+class AsyncResource {
+ public:
+ AsyncResource(
+ v8::Local<v8::String> name
+ , v8::Local<v8::Object> resource = New<v8::Object>()) {
+#if NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+
+ if (resource.IsEmpty()) {
+ resource = New<v8::Object>();
+ }
+
+ context = node::EmitAsyncInit(isolate, resource, name);
+#endif
+ }
+
+ AsyncResource(
+ const char* name
+ , v8::Local<v8::Object> resource = New<v8::Object>()) {
+#if NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+
+ if (resource.IsEmpty()) {
+ resource = New<v8::Object>();
+ }
+
+ v8::Local<v8::String> name_string =
+ New<v8::String>(name).ToLocalChecked();
+ context = node::EmitAsyncInit(isolate, resource, name_string);
+#endif
+ }
+
+ ~AsyncResource() {
+#if NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ node::EmitAsyncDestroy(isolate, context);
+#endif
+ }
+
+ inline MaybeLocal<v8::Value> runInAsyncScope(
+ v8::Local<v8::Object> target
+ , v8::Local<v8::Function> func
+ , int argc
+ , v8::Local<v8::Value>* argv) {
+#if NODE_MODULE_VERSION < NODE_9_0_MODULE_VERSION
+ return MakeCallback(target, func, argc, argv);
+#else
+ return node::MakeCallback(
+ v8::Isolate::GetCurrent(), target, func, argc, argv, context);
+#endif
+ }
+
+ inline MaybeLocal<v8::Value> runInAsyncScope(
+ v8::Local<v8::Object> target
+ , v8::Local<v8::String> symbol
+ , int argc
+ , v8::Local<v8::Value>* argv) {
+#if NODE_MODULE_VERSION < NODE_9_0_MODULE_VERSION
+ return MakeCallback(target, symbol, argc, argv);
+#else
+ return node::MakeCallback(
+ v8::Isolate::GetCurrent(), target, symbol, argc, argv, context);
+#endif
+ }
+
+ inline MaybeLocal<v8::Value> runInAsyncScope(
+ v8::Local<v8::Object> target
+ , const char* method
+ , int argc
+ , v8::Local<v8::Value>* argv) {
+#if NODE_MODULE_VERSION < NODE_9_0_MODULE_VERSION
+ return MakeCallback(target, method, argc, argv);
+#else
+ return node::MakeCallback(
+ v8::Isolate::GetCurrent(), target, method, argc, argv, context);
+#endif
+ }
+
+ private:
+ NAN_DISALLOW_ASSIGN_COPY_MOVE(AsyncResource)
+#if NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
+ node::async_context context;
+#endif
+};
+
+inline uv_loop_t* GetCurrentEventLoop() {
+#if NODE_MAJOR_VERSION >= 10 || \
+ NODE_MAJOR_VERSION == 9 && NODE_MINOR_VERSION >= 3 || \
+ NODE_MAJOR_VERSION == 8 && NODE_MINOR_VERSION >= 10
+ return node::GetCurrentEventLoop(v8::Isolate::GetCurrent());
+#else
+ return uv_default_loop();
+#endif
+}
+
+//============ =================================================================
+
+/* node 0.12 */
+#if NODE_MODULE_VERSION >= NODE_0_12_MODULE_VERSION
+ inline
+ void SetCounterFunction(v8::CounterLookupCallback cb) {
+ v8::Isolate::GetCurrent()->SetCounterFunction(cb);
+ }
+
+ inline
+ void SetCreateHistogramFunction(v8::CreateHistogramCallback cb) {
+ v8::Isolate::GetCurrent()->SetCreateHistogramFunction(cb);
+ }
+
+ inline
+ void SetAddHistogramSampleFunction(v8::AddHistogramSampleCallback cb) {
+ v8::Isolate::GetCurrent()->SetAddHistogramSampleFunction(cb);
+ }
+
+#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
+ (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
+ inline bool IdleNotification(int idle_time_in_ms) {
+ return v8::Isolate::GetCurrent()->IdleNotificationDeadline(
+ idle_time_in_ms * 0.001);
+ }
+# else
+ inline bool IdleNotification(int idle_time_in_ms) {
+ return v8::Isolate::GetCurrent()->IdleNotification(idle_time_in_ms);
+ }
+#endif
+
+ inline void LowMemoryNotification() {
+ v8::Isolate::GetCurrent()->LowMemoryNotification();
+ }
+
+ inline void ContextDisposedNotification() {
+ v8::Isolate::GetCurrent()->ContextDisposedNotification();
+ }
+#else
+ inline
+ void SetCounterFunction(v8::CounterLookupCallback cb) {
+ v8::V8::SetCounterFunction(cb);
+ }
+
+ inline
+ void SetCreateHistogramFunction(v8::CreateHistogramCallback cb) {
+ v8::V8::SetCreateHistogramFunction(cb);
+ }
+
+ inline
+ void SetAddHistogramSampleFunction(v8::AddHistogramSampleCallback cb) {
+ v8::V8::SetAddHistogramSampleFunction(cb);
+ }
+
+ inline bool IdleNotification(int idle_time_in_ms) {
+ return v8::V8::IdleNotification(idle_time_in_ms);
+ }
+
+ inline void LowMemoryNotification() {
+ v8::V8::LowMemoryNotification();
+ }
+
+ inline void ContextDisposedNotification() {
+ v8::V8::ContextDisposedNotification();
+ }
+#endif
+
+#if (NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION) // Node 0.12
+ inline v8::Local<v8::Primitive> Undefined() {
+# if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION
+ EscapableHandleScope scope;
+ return scope.Escape(New(v8::Undefined(v8::Isolate::GetCurrent())));
+# else
+ return v8::Undefined(v8::Isolate::GetCurrent());
+# endif
+ }
+
+ inline v8::Local<v8::Primitive> Null() {
+# if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION
+ EscapableHandleScope scope;
+ return scope.Escape(New(v8::Null(v8::Isolate::GetCurrent())));
+# else
+ return v8::Null(v8::Isolate::GetCurrent());
+# endif
+ }
+
+ inline v8::Local<v8::Boolean> True() {
+# if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION
+ EscapableHandleScope scope;
+ return scope.Escape(New(v8::True(v8::Isolate::GetCurrent())));
+# else
+ return v8::True(v8::Isolate::GetCurrent());
+# endif
+ }
+
+ inline v8::Local<v8::Boolean> False() {
+# if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION
+ EscapableHandleScope scope;
+ return scope.Escape(New(v8::False(v8::Isolate::GetCurrent())));
+# else
+ return v8::False(v8::Isolate::GetCurrent());
+# endif
+ }
+
+ inline v8::Local<v8::String> EmptyString() {
+ return v8::String::Empty(v8::Isolate::GetCurrent());
+ }
+
+ inline int AdjustExternalMemory(int bc) {
+ return static_cast<int>(
+ v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(bc));
+ }
+
+ inline void SetTemplate(
+ v8::Local<v8::Template> templ
+ , const char *name
+ , v8::Local<v8::Data> value) {
+ templ->Set(v8::Isolate::GetCurrent(), name, value);
+ }
+
+ inline void SetTemplate(
+ v8::Local<v8::Template> templ
+ , v8::Local<v8::String> name
+ , v8::Local<v8::Data> value
+ , v8::PropertyAttribute attributes) {
+ templ->Set(name, value, attributes);
+ }
+
+ inline v8::Local<v8::Context> GetCurrentContext() {
+ return v8::Isolate::GetCurrent()->GetCurrentContext();
+ }
+
+ inline void* GetInternalFieldPointer(
+ v8::Local<v8::Object> object
+ , int index) {
+ return object->GetAlignedPointerFromInternalField(index);
+ }
+
+ inline void SetInternalFieldPointer(
+ v8::Local<v8::Object> object
+ , int index
+ , void* value) {
+ object->SetAlignedPointerInInternalField(index, value);
+ }
+
+# define NAN_GC_CALLBACK(name) \
+ void name(v8::Isolate *isolate, v8::GCType type, v8::GCCallbackFlags flags)
+
+#if NODE_MODULE_VERSION <= NODE_4_0_MODULE_VERSION
+ typedef v8::Isolate::GCEpilogueCallback GCEpilogueCallback;
+ typedef v8::Isolate::GCPrologueCallback GCPrologueCallback;
+#else
+ typedef v8::Isolate::GCCallback GCEpilogueCallback;
+ typedef v8::Isolate::GCCallback GCPrologueCallback;
+#endif
+
+ inline void AddGCEpilogueCallback(
+ GCEpilogueCallback callback
+ , v8::GCType gc_type_filter = v8::kGCTypeAll) {
+ v8::Isolate::GetCurrent()->AddGCEpilogueCallback(callback, gc_type_filter);
+ }
+
+ inline void RemoveGCEpilogueCallback(
+ GCEpilogueCallback callback) {
+ v8::Isolate::GetCurrent()->RemoveGCEpilogueCallback(callback);
+ }
+
+ inline void AddGCPrologueCallback(
+ GCPrologueCallback callback
+ , v8::GCType gc_type_filter = v8::kGCTypeAll) {
+ v8::Isolate::GetCurrent()->AddGCPrologueCallback(callback, gc_type_filter);
+ }
+
+ inline void RemoveGCPrologueCallback(
+ GCPrologueCallback callback) {
+ v8::Isolate::GetCurrent()->RemoveGCPrologueCallback(callback);
+ }
+
+ inline void GetHeapStatistics(
+ v8::HeapStatistics *heap_statistics) {
+ v8::Isolate::GetCurrent()->GetHeapStatistics(heap_statistics);
+ }
+
+# define X(NAME) \
+ inline v8::Local<v8::Value> NAME(const char *msg) { \
+ EscapableHandleScope scope; \
+ return scope.Escape(v8::Exception::NAME(New(msg).ToLocalChecked())); \
+ } \
+ \
+ inline \
+ v8::Local<v8::Value> NAME(v8::Local<v8::String> msg) { \
+ return v8::Exception::NAME(msg); \
+ } \
+ \
+ inline void Throw ## NAME(const char *msg) { \
+ HandleScope scope; \
+ v8::Isolate::GetCurrent()->ThrowException( \
+ v8::Exception::NAME(New(msg).ToLocalChecked())); \
+ } \
+ \
+ inline void Throw ## NAME(v8::Local<v8::String> msg) { \
+ HandleScope scope; \
+ v8::Isolate::GetCurrent()->ThrowException( \
+ v8::Exception::NAME(msg)); \
+ }
+
+ X(Error)
+ X(RangeError)
+ X(ReferenceError)
+ X(SyntaxError)
+ X(TypeError)
+
+# undef X
+
+ inline void ThrowError(v8::Local<v8::Value> error) {
+ v8::Isolate::GetCurrent()->ThrowException(error);
+ }
+
+ inline MaybeLocal<v8::Object> NewBuffer(
+ char *data
+ , size_t length
+#if NODE_MODULE_VERSION > IOJS_2_0_MODULE_VERSION
+ , node::Buffer::FreeCallback callback
+#else
+ , node::smalloc::FreeCallback callback
+#endif
+ , void *hint
+ ) {
+ // arbitrary buffer lengths requires
+ // NODE_MODULE_VERSION >= IOJS_3_0_MODULE_VERSION
+ assert(length <= imp::kMaxLength && "too large buffer");
+#if NODE_MODULE_VERSION > IOJS_2_0_MODULE_VERSION
+ return node::Buffer::New(
+ v8::Isolate::GetCurrent(), data, length, callback, hint);
+#else
+ return node::Buffer::New(v8::Isolate::GetCurrent(), data, length, callback,
+ hint);
+#endif
+ }
+
+ inline MaybeLocal<v8::Object> CopyBuffer(
+ const char *data
+ , uint32_t size
+ ) {
+ // arbitrary buffer lengths requires
+ // NODE_MODULE_VERSION >= IOJS_3_0_MODULE_VERSION
+ assert(size <= imp::kMaxLength && "too large buffer");
+#if NODE_MODULE_VERSION > IOJS_2_0_MODULE_VERSION
+ return node::Buffer::Copy(
+ v8::Isolate::GetCurrent(), data, size);
+#else
+ return node::Buffer::New(v8::Isolate::GetCurrent(), data, size);
+#endif
+ }
+
+ inline MaybeLocal<v8::Object> NewBuffer(uint32_t size) {
+ // arbitrary buffer lengths requires
+ // NODE_MODULE_VERSION >= IOJS_3_0_MODULE_VERSION
+ assert(size <= imp::kMaxLength && "too large buffer");
+#if NODE_MODULE_VERSION > IOJS_2_0_MODULE_VERSION
+ return node::Buffer::New(
+ v8::Isolate::GetCurrent(), size);
+#else
+ return node::Buffer::New(v8::Isolate::GetCurrent(), size);
+#endif
+ }
+
+ inline MaybeLocal<v8::Object> NewBuffer(
+ char* data
+ , uint32_t size
+ ) {
+ // arbitrary buffer lengths requires
+ // NODE_MODULE_VERSION >= IOJS_3_0_MODULE_VERSION
+ assert(size <= imp::kMaxLength && "too large buffer");
+#if NODE_MODULE_VERSION > IOJS_2_0_MODULE_VERSION
+ return node::Buffer::New(v8::Isolate::GetCurrent(), data, size);
+#else
+ return node::Buffer::Use(v8::Isolate::GetCurrent(), data, size);
+#endif
+ }
+
+#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
+ (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
+ inline MaybeLocal<v8::String>
+ NewOneByteString(const uint8_t * value, int length = -1) {
+ return v8::String::NewFromOneByte(v8::Isolate::GetCurrent(), value,
+ v8::NewStringType::kNormal, length);
+ }
+
+ inline MaybeLocal<BoundScript> CompileScript(
+ v8::Local<v8::String> s
+ , const v8::ScriptOrigin& origin
+ ) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ v8::ScriptCompiler::Source source(s, origin);
+ return scope.Escape(
+ v8::ScriptCompiler::Compile(isolate->GetCurrentContext(), &source)
+ .FromMaybe(v8::Local<BoundScript>()));
+ }
+
+ inline MaybeLocal<BoundScript> CompileScript(
+ v8::Local<v8::String> s
+ ) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ v8::ScriptCompiler::Source source(s);
+ return scope.Escape(
+ v8::ScriptCompiler::Compile(isolate->GetCurrentContext(), &source)
+ .FromMaybe(v8::Local<BoundScript>()));
+ }
+
+ inline MaybeLocal<v8::Value> RunScript(
+ v8::Local<UnboundScript> script
+ ) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ return scope.Escape(script->BindToCurrentContext()
+ ->Run(isolate->GetCurrentContext())
+ .FromMaybe(v8::Local<v8::Value>()));
+ }
+
+ inline MaybeLocal<v8::Value> RunScript(
+ v8::Local<BoundScript> script
+ ) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ return scope.Escape(script->Run(isolate->GetCurrentContext())
+ .FromMaybe(v8::Local<v8::Value>()));
+ }
+#else
+ inline MaybeLocal<v8::String>
+ NewOneByteString(const uint8_t * value, int length = -1) {
+ return v8::String::NewFromOneByte(v8::Isolate::GetCurrent(), value,
+ v8::String::kNormalString, length);
+ }
+
+ inline MaybeLocal<BoundScript> CompileScript(
+ v8::Local<v8::String> s
+ , const v8::ScriptOrigin& origin
+ ) {
+ v8::ScriptCompiler::Source source(s, origin);
+ return v8::ScriptCompiler::Compile(v8::Isolate::GetCurrent(), &source);
+ }
+
+ inline MaybeLocal<BoundScript> CompileScript(
+ v8::Local<v8::String> s
+ ) {
+ v8::ScriptCompiler::Source source(s);
+ return v8::ScriptCompiler::Compile(v8::Isolate::GetCurrent(), &source);
+ }
+
+ inline MaybeLocal<v8::Value> RunScript(
+ v8::Local<UnboundScript> script
+ ) {
+ EscapableHandleScope scope;
+ return scope.Escape(script->BindToCurrentContext()->Run());
+ }
+
+ inline MaybeLocal<v8::Value> RunScript(
+ v8::Local<BoundScript> script
+ ) {
+ return script->Run();
+ }
+#endif
+
+ NAN_DEPRECATED inline v8::Local<v8::Value> MakeCallback(
+ v8::Local<v8::Object> target
+ , v8::Local<v8::Function> func
+ , int argc
+ , v8::Local<v8::Value>* argv) {
+#if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION
+ EscapableHandleScope scope;
+ return scope.Escape(New(node::MakeCallback(
+ v8::Isolate::GetCurrent(), target, func, argc, argv)));
+#else
+# if NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
+ AsyncResource res("nan:makeCallback");
+ return res.runInAsyncScope(target, func, argc, argv)
+ .FromMaybe(v8::Local<v8::Value>());
+# else
+ return node::MakeCallback(
+ v8::Isolate::GetCurrent(), target, func, argc, argv);
+# endif // NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
+#endif // NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION
+ }
+
+ NAN_DEPRECATED inline v8::Local<v8::Value> MakeCallback(
+ v8::Local<v8::Object> target
+ , v8::Local<v8::String> symbol
+ , int argc
+ , v8::Local<v8::Value>* argv) {
+#if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION
+ EscapableHandleScope scope;
+ return scope.Escape(New(node::MakeCallback(
+ v8::Isolate::GetCurrent(), target, symbol, argc, argv)));
+#else
+# if NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
+ AsyncResource res("nan:makeCallback");
+ return res.runInAsyncScope(target, symbol, argc, argv)
+ .FromMaybe(v8::Local<v8::Value>());
+# else
+ return node::MakeCallback(
+ v8::Isolate::GetCurrent(), target, symbol, argc, argv);
+# endif // NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
+#endif // NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION
+ }
+
+ NAN_DEPRECATED inline v8::Local<v8::Value> MakeCallback(
+ v8::Local<v8::Object> target
+ , const char* method
+ , int argc
+ , v8::Local<v8::Value>* argv) {
+#if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION
+ EscapableHandleScope scope;
+ return scope.Escape(New(node::MakeCallback(
+ v8::Isolate::GetCurrent(), target, method, argc, argv)));
+#else
+# if NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
+ AsyncResource res("nan:makeCallback");
+ return res.runInAsyncScope(target, method, argc, argv)
+ .FromMaybe(v8::Local<v8::Value>());
+# else
+ return node::MakeCallback(
+ v8::Isolate::GetCurrent(), target, method, argc, argv);
+# endif // NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
+#endif // NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION
+ }
+
+ inline void FatalException(const TryCatch& try_catch) {
+ node::FatalException(v8::Isolate::GetCurrent(), try_catch.try_catch_);
+ }
+
+ inline v8::Local<v8::Value> ErrnoException(
+ int errorno
+ , const char* syscall = NULL
+ , const char* message = NULL
+ , const char* path = NULL) {
+ return node::ErrnoException(v8::Isolate::GetCurrent(), errorno, syscall,
+ message, path);
+ }
+
+ NAN_DEPRECATED inline v8::Local<v8::Value> NanErrnoException(
+ int errorno
+ , const char* syscall = NULL
+ , const char* message = NULL
+ , const char* path = NULL) {
+ return ErrnoException(errorno, syscall, message, path);
+ }
+
+ template<typename T>
+ inline void SetIsolateData(
+ v8::Isolate *isolate
+ , T *data
+ ) {
+ isolate->SetData(0, data);
+ }
+
+ template<typename T>
+ inline T *GetIsolateData(
+ v8::Isolate *isolate
+ ) {
+ return static_cast<T*>(isolate->GetData(0));
+ }
+
+class Utf8String {
+ public:
+ inline explicit Utf8String(v8::Local<v8::Value> from) :
+ length_(0), str_(str_st_) {
+ HandleScope scope;
+ if (!from.IsEmpty()) {
+#if NODE_MAJOR_VERSION >= 10
+ v8::Local<v8::Context> context = GetCurrentContext();
+ v8::Local<v8::String> string =
+ from->ToString(context).FromMaybe(v8::Local<v8::String>());
+#else
+ v8::Local<v8::String> string = from->ToString();
+#endif
+ if (!string.IsEmpty()) {
+ size_t len = 3 * string->Length() + 1;
+ assert(len <= INT_MAX);
+ if (len > sizeof (str_st_)) {
+ str_ = static_cast<char*>(malloc(len));
+ assert(str_ != 0);
+ }
+ const int flags =
+ v8::String::NO_NULL_TERMINATION | imp::kReplaceInvalidUtf8;
+#if NODE_MAJOR_VERSION >= 11
+ length_ = string->WriteUtf8(v8::Isolate::GetCurrent(), str_,
+ static_cast<int>(len), 0, flags);
+#else
+ // See https://github.com/nodejs/nan/issues/832.
+ // Disable the warning as there is no way around it.
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable : 4996)
+#endif
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+ length_ = string->WriteUtf8(str_, static_cast<int>(len), 0, flags);
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+#endif // NODE_MAJOR_VERSION < 11
+ str_[length_] = '\0';
+ }
+ }
+ }
+
+ inline int length() const {
+ return length_;
+ }
+
+ inline char* operator*() { return str_; }
+ inline const char* operator*() const { return str_; }
+
+ inline ~Utf8String() {
+ if (str_ != str_st_) {
+ free(str_);
+ }
+ }
+
+ private:
+ NAN_DISALLOW_ASSIGN_COPY_MOVE(Utf8String)
+
+ int length_;
+ char *str_;
+ char str_st_[1024];
+};
+
+#else // Node 0.8 and 0.10
+ inline v8::Local<v8::Primitive> Undefined() {
+ EscapableHandleScope scope;
+ return scope.Escape(New(v8::Undefined()));
+ }
+
+ inline v8::Local<v8::Primitive> Null() {
+ EscapableHandleScope scope;
+ return scope.Escape(New(v8::Null()));
+ }
+
+ inline v8::Local<v8::Boolean> True() {
+ EscapableHandleScope scope;
+ return scope.Escape(New(v8::True()));
+ }
+
+ inline v8::Local<v8::Boolean> False() {
+ EscapableHandleScope scope;
+ return scope.Escape(New(v8::False()));
+ }
+
+ inline v8::Local<v8::String> EmptyString() {
+ return v8::String::Empty();
+ }
+
+ inline int AdjustExternalMemory(int bc) {
+ return static_cast<int>(v8::V8::AdjustAmountOfExternalAllocatedMemory(bc));
+ }
+
+ inline void SetTemplate(
+ v8::Local<v8::Template> templ
+ , const char *name
+ , v8::Local<v8::Data> value) {
+ templ->Set(name, value);
+ }
+
+ inline void SetTemplate(
+ v8::Local<v8::Template> templ
+ , v8::Local<v8::String> name
+ , v8::Local<v8::Data> value
+ , v8::PropertyAttribute attributes) {
+ templ->Set(name, value, attributes);
+ }
+
+ inline v8::Local<v8::Context> GetCurrentContext() {
+ return v8::Context::GetCurrent();
+ }
+
+ inline void* GetInternalFieldPointer(
+ v8::Local<v8::Object> object
+ , int index) {
+ return object->GetPointerFromInternalField(index);
+ }
+
+ inline void SetInternalFieldPointer(
+ v8::Local<v8::Object> object
+ , int index
+ , void* value) {
+ object->SetPointerInInternalField(index, value);
+ }
+
+# define NAN_GC_CALLBACK(name) \
+ void name(v8::GCType type, v8::GCCallbackFlags flags)
+
+ inline void AddGCEpilogueCallback(
+ v8::GCEpilogueCallback callback
+ , v8::GCType gc_type_filter = v8::kGCTypeAll) {
+ v8::V8::AddGCEpilogueCallback(callback, gc_type_filter);
+ }
+ inline void RemoveGCEpilogueCallback(
+ v8::GCEpilogueCallback callback) {
+ v8::V8::RemoveGCEpilogueCallback(callback);
+ }
+ inline void AddGCPrologueCallback(
+ v8::GCPrologueCallback callback
+ , v8::GCType gc_type_filter = v8::kGCTypeAll) {
+ v8::V8::AddGCPrologueCallback(callback, gc_type_filter);
+ }
+ inline void RemoveGCPrologueCallback(
+ v8::GCPrologueCallback callback) {
+ v8::V8::RemoveGCPrologueCallback(callback);
+ }
+ inline void GetHeapStatistics(
+ v8::HeapStatistics *heap_statistics) {
+ v8::V8::GetHeapStatistics(heap_statistics);
+ }
+
+# define X(NAME) \
+ inline v8::Local<v8::Value> NAME(const char *msg) { \
+ EscapableHandleScope scope; \
+ return scope.Escape(v8::Exception::NAME(New(msg).ToLocalChecked())); \
+ } \
+ \
+ inline \
+ v8::Local<v8::Value> NAME(v8::Local<v8::String> msg) { \
+ return v8::Exception::NAME(msg); \
+ } \
+ \
+ inline void Throw ## NAME(const char *msg) { \
+ HandleScope scope; \
+ v8::ThrowException(v8::Exception::NAME(New(msg).ToLocalChecked())); \
+ } \
+ \
+ inline \
+ void Throw ## NAME(v8::Local<v8::String> errmsg) { \
+ HandleScope scope; \
+ v8::ThrowException(v8::Exception::NAME(errmsg)); \
+ }
+
+ X(Error)
+ X(RangeError)
+ X(ReferenceError)
+ X(SyntaxError)
+ X(TypeError)
+
+# undef X
+
+ inline void ThrowError(v8::Local<v8::Value> error) {
+ v8::ThrowException(error);
+ }
+
+ inline MaybeLocal<v8::Object> NewBuffer(
+ char *data
+ , size_t length
+ , node::Buffer::free_callback callback
+ , void *hint
+ ) {
+ EscapableHandleScope scope;
+ // arbitrary buffer lengths requires
+ // NODE_MODULE_VERSION >= IOJS_3_0_MODULE_VERSION
+ assert(length <= imp::kMaxLength && "too large buffer");
+ return scope.Escape(
+ New(node::Buffer::New(data, length, callback, hint)->handle_));
+ }
+
+ inline MaybeLocal<v8::Object> CopyBuffer(
+ const char *data
+ , uint32_t size
+ ) {
+ EscapableHandleScope scope;
+ // arbitrary buffer lengths requires
+ // NODE_MODULE_VERSION >= IOJS_3_0_MODULE_VERSION
+ assert(size <= imp::kMaxLength && "too large buffer");
+#if NODE_MODULE_VERSION >= NODE_0_10_MODULE_VERSION
+ return scope.Escape(New(node::Buffer::New(data, size)->handle_));
+#else
+ return scope.Escape(
+ New(node::Buffer::New(const_cast<char *>(data), size)->handle_));
+#endif
+ }
+
+ inline MaybeLocal<v8::Object> NewBuffer(uint32_t size) {
+ // arbitrary buffer lengths requires
+ // NODE_MODULE_VERSION >= IOJS_3_0_MODULE_VERSION
+ EscapableHandleScope scope;
+ assert(size <= imp::kMaxLength && "too large buffer");
+ return scope.Escape(New(node::Buffer::New(size)->handle_));
+ }
+
+ inline void FreeData(char *data, void *hint) {
+ (void) hint; // unused
+ delete[] data;
+ }
+
+ inline MaybeLocal<v8::Object> NewBuffer(
+ char* data
+ , uint32_t size
+ ) {
+ EscapableHandleScope scope;
+ // arbitrary buffer lengths requires
+ // NODE_MODULE_VERSION >= IOJS_3_0_MODULE_VERSION
+ assert(size <= imp::kMaxLength && "too large buffer");
+ return scope.Escape(
+ New(node::Buffer::New(data, size, FreeData, NULL)->handle_));
+ }
+
+namespace imp {
+inline void
+widenString(std::vector<uint16_t> *ws, const uint8_t *s, int l) {
+ size_t len = static_cast<size_t>(l);
+ if (l < 0) {
+ len = strlen(reinterpret_cast<const char*>(s));
+ }
+ assert(len <= INT_MAX && "string too long");
+ ws->resize(len);
+ std::copy(s, s + len, ws->begin()); // NOLINT(build/include_what_you_use)
+}
+} // end of namespace imp
+
+ inline MaybeLocal<v8::String>
+ NewOneByteString(const uint8_t * value, int length = -1) {
+ std::vector<uint16_t> wideString; // NOLINT(build/include_what_you_use)
+ imp::widenString(&wideString, value, length);
+ return v8::String::New(wideString.data(),
+ static_cast<int>(wideString.size()));
+ }
+
+ inline MaybeLocal<BoundScript> CompileScript(
+ v8::Local<v8::String> s
+ , const v8::ScriptOrigin& origin
+ ) {
+ return v8::Script::Compile(s, const_cast<v8::ScriptOrigin *>(&origin));
+ }
+
+ inline MaybeLocal<BoundScript> CompileScript(
+ v8::Local<v8::String> s
+ ) {
+ return v8::Script::Compile(s);
+ }
+
+ inline
+ MaybeLocal<v8::Value> RunScript(v8::Local<v8::Script> script) {
+ return script->Run();
+ }
+
+ inline v8::Local<v8::Value> MakeCallback(
+ v8::Local<v8::Object> target
+ , v8::Local<v8::Function> func
+ , int argc
+ , v8::Local<v8::Value>* argv) {
+ v8::HandleScope scope;
+ return scope.Close(New(node::MakeCallback(target, func, argc, argv)));
+ }
+
+ inline v8::Local<v8::Value> MakeCallback(
+ v8::Local<v8::Object> target
+ , v8::Local<v8::String> symbol
+ , int argc
+ , v8::Local<v8::Value>* argv) {
+ v8::HandleScope scope;
+ return scope.Close(New(node::MakeCallback(target, symbol, argc, argv)));
+ }
+
+ inline v8::Local<v8::Value> MakeCallback(
+ v8::Local<v8::Object> target
+ , const char* method
+ , int argc
+ , v8::Local<v8::Value>* argv) {
+ v8::HandleScope scope;
+ return scope.Close(New(node::MakeCallback(target, method, argc, argv)));
+ }
+
+ inline void FatalException(const TryCatch& try_catch) {
+ node::FatalException(const_cast<v8::TryCatch &>(try_catch.try_catch_));
+ }
+
+ inline v8::Local<v8::Value> ErrnoException(
+ int errorno
+ , const char* syscall = NULL
+ , const char* message = NULL
+ , const char* path = NULL) {
+ return node::ErrnoException(errorno, syscall, message, path);
+ }
+
+ NAN_DEPRECATED inline v8::Local<v8::Value> NanErrnoException(
+ int errorno
+ , const char* syscall = NULL
+ , const char* message = NULL
+ , const char* path = NULL) {
+ return ErrnoException(errorno, syscall, message, path);
+ }
+
+
+ template<typename T>
+ inline void SetIsolateData(
+ v8::Isolate *isolate
+ , T *data
+ ) {
+ isolate->SetData(data);
+ }
+
+ template<typename T>
+ inline T *GetIsolateData(
+ v8::Isolate *isolate
+ ) {
+ return static_cast<T*>(isolate->GetData());
+ }
+
+class Utf8String {
+ public:
+ inline explicit Utf8String(v8::Local<v8::Value> from) :
+ length_(0), str_(str_st_) {
+ v8::HandleScope scope;
+ if (!from.IsEmpty()) {
+ v8::Local<v8::String> string = from->ToString();
+ if (!string.IsEmpty()) {
+ size_t len = 3 * string->Length() + 1;
+ assert(len <= INT_MAX);
+ if (len > sizeof (str_st_)) {
+ str_ = static_cast<char*>(malloc(len));
+ assert(str_ != 0);
+ }
+ const int flags =
+ v8::String::NO_NULL_TERMINATION | imp::kReplaceInvalidUtf8;
+ length_ = string->WriteUtf8(str_, static_cast<int>(len), 0, flags);
+ str_[length_] = '\0';
+ }
+ }
+ }
+
+ inline int length() const {
+ return length_;
+ }
+
+ inline char* operator*() { return str_; }
+ inline const char* operator*() const { return str_; }
+
+ inline ~Utf8String() {
+ if (str_ != str_st_) {
+ free(str_);
+ }
+ }
+
+ private:
+ NAN_DISALLOW_ASSIGN_COPY_MOVE(Utf8String)
+
+ int length_;
+ char *str_;
+ char str_st_[1024];
+};
+
+#endif // NODE_MODULE_VERSION
+
+typedef void (*FreeCallback)(char *data, void *hint);
+
+typedef const FunctionCallbackInfo<v8::Value>& NAN_METHOD_ARGS_TYPE;
+typedef void NAN_METHOD_RETURN_TYPE;
+
+typedef const PropertyCallbackInfo<v8::Value>& NAN_GETTER_ARGS_TYPE;
+typedef void NAN_GETTER_RETURN_TYPE;
+
+typedef const PropertyCallbackInfo<void>& NAN_SETTER_ARGS_TYPE;
+typedef void NAN_SETTER_RETURN_TYPE;
+
+typedef const PropertyCallbackInfo<v8::Value>&
+ NAN_PROPERTY_GETTER_ARGS_TYPE;
+typedef void NAN_PROPERTY_GETTER_RETURN_TYPE;
+
+typedef const PropertyCallbackInfo<v8::Value>&
+ NAN_PROPERTY_SETTER_ARGS_TYPE;
+typedef void NAN_PROPERTY_SETTER_RETURN_TYPE;
+
+typedef const PropertyCallbackInfo<v8::Array>&
+ NAN_PROPERTY_ENUMERATOR_ARGS_TYPE;
+typedef void NAN_PROPERTY_ENUMERATOR_RETURN_TYPE;
+
+typedef const PropertyCallbackInfo<v8::Boolean>&
+ NAN_PROPERTY_DELETER_ARGS_TYPE;
+typedef void NAN_PROPERTY_DELETER_RETURN_TYPE;
+
+typedef const PropertyCallbackInfo<v8::Integer>&
+ NAN_PROPERTY_QUERY_ARGS_TYPE;
+typedef void NAN_PROPERTY_QUERY_RETURN_TYPE;
+
+typedef const PropertyCallbackInfo<v8::Value>& NAN_INDEX_GETTER_ARGS_TYPE;
+typedef void NAN_INDEX_GETTER_RETURN_TYPE;
+
+typedef const PropertyCallbackInfo<v8::Value>& NAN_INDEX_SETTER_ARGS_TYPE;
+typedef void NAN_INDEX_SETTER_RETURN_TYPE;
+
+typedef const PropertyCallbackInfo<v8::Array>&
+ NAN_INDEX_ENUMERATOR_ARGS_TYPE;
+typedef void NAN_INDEX_ENUMERATOR_RETURN_TYPE;
+
+typedef const PropertyCallbackInfo<v8::Boolean>&
+ NAN_INDEX_DELETER_ARGS_TYPE;
+typedef void NAN_INDEX_DELETER_RETURN_TYPE;
+
+typedef const PropertyCallbackInfo<v8::Integer>&
+ NAN_INDEX_QUERY_ARGS_TYPE;
+typedef void NAN_INDEX_QUERY_RETURN_TYPE;
+
+#define NAN_METHOD(name) \
+ Nan::NAN_METHOD_RETURN_TYPE name(Nan::NAN_METHOD_ARGS_TYPE info)
+#define NAN_GETTER(name) \
+ Nan::NAN_GETTER_RETURN_TYPE name( \
+ v8::Local<v8::String> property \
+ , Nan::NAN_GETTER_ARGS_TYPE info)
+#define NAN_SETTER(name) \
+ Nan::NAN_SETTER_RETURN_TYPE name( \
+ v8::Local<v8::String> property \
+ , v8::Local<v8::Value> value \
+ , Nan::NAN_SETTER_ARGS_TYPE info)
+#define NAN_PROPERTY_GETTER(name) \
+ Nan::NAN_PROPERTY_GETTER_RETURN_TYPE name( \
+ v8::Local<v8::String> property \
+ , Nan::NAN_PROPERTY_GETTER_ARGS_TYPE info)
+#define NAN_PROPERTY_SETTER(name) \
+ Nan::NAN_PROPERTY_SETTER_RETURN_TYPE name( \
+ v8::Local<v8::String> property \
+ , v8::Local<v8::Value> value \
+ , Nan::NAN_PROPERTY_SETTER_ARGS_TYPE info)
+#define NAN_PROPERTY_ENUMERATOR(name) \
+ Nan::NAN_PROPERTY_ENUMERATOR_RETURN_TYPE name( \
+ Nan::NAN_PROPERTY_ENUMERATOR_ARGS_TYPE info)
+#define NAN_PROPERTY_DELETER(name) \
+ Nan::NAN_PROPERTY_DELETER_RETURN_TYPE name( \
+ v8::Local<v8::String> property \
+ , Nan::NAN_PROPERTY_DELETER_ARGS_TYPE info)
+#define NAN_PROPERTY_QUERY(name) \
+ Nan::NAN_PROPERTY_QUERY_RETURN_TYPE name( \
+ v8::Local<v8::String> property \
+ , Nan::NAN_PROPERTY_QUERY_ARGS_TYPE info)
+# define NAN_INDEX_GETTER(name) \
+ Nan::NAN_INDEX_GETTER_RETURN_TYPE name( \
+ uint32_t index \
+ , Nan::NAN_INDEX_GETTER_ARGS_TYPE info)
+#define NAN_INDEX_SETTER(name) \
+ Nan::NAN_INDEX_SETTER_RETURN_TYPE name( \
+ uint32_t index \
+ , v8::Local<v8::Value> value \
+ , Nan::NAN_INDEX_SETTER_ARGS_TYPE info)
+#define NAN_INDEX_ENUMERATOR(name) \
+ Nan::NAN_INDEX_ENUMERATOR_RETURN_TYPE \
+ name(Nan::NAN_INDEX_ENUMERATOR_ARGS_TYPE info)
+#define NAN_INDEX_DELETER(name) \
+ Nan::NAN_INDEX_DELETER_RETURN_TYPE name( \
+ uint32_t index \
+ , Nan::NAN_INDEX_DELETER_ARGS_TYPE info)
+#define NAN_INDEX_QUERY(name) \
+ Nan::NAN_INDEX_QUERY_RETURN_TYPE name( \
+ uint32_t index \
+ , Nan::NAN_INDEX_QUERY_ARGS_TYPE info)
+
+class Callback {
+ public:
+ Callback() {}
+
+ explicit Callback(const v8::Local<v8::Function> &fn) : handle_(fn) {}
+
+ ~Callback() {
+ handle_.Reset();
+ }
+
+ bool operator==(const Callback &other) const {
+ return handle_ == other.handle_;
+ }
+
+ bool operator!=(const Callback &other) const {
+ return !operator==(other);
+ }
+
+ inline
+ v8::Local<v8::Function> operator*() const { return GetFunction(); }
+
+ NAN_DEPRECATED inline v8::Local<v8::Value> operator()(
+ v8::Local<v8::Object> target
+ , int argc = 0
+ , v8::Local<v8::Value> argv[] = 0) const {
+#if NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+# if NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
+ AsyncResource async("nan:Callback:operator()");
+ return Call_(isolate, target, argc, argv, &async)
+ .FromMaybe(v8::Local<v8::Value>());
+# else
+ return Call_(isolate, target, argc, argv);
+# endif // NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
+#else
+ return Call_(target, argc, argv);
+#endif // NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
+ }
+
+ NAN_DEPRECATED inline v8::Local<v8::Value> operator()(
+ int argc = 0
+ , v8::Local<v8::Value> argv[] = 0) const {
+#if NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+# if NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
+ AsyncResource async("nan:Callback:operator()");
+ return scope.Escape(Call_(isolate, isolate->GetCurrentContext()->Global(),
+ argc, argv, &async)
+ .FromMaybe(v8::Local<v8::Value>()));
+# else
+ return scope.Escape(
+ Call_(isolate, isolate->GetCurrentContext()->Global(), argc, argv));
+# endif // NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
+#else
+ v8::HandleScope scope;
+ return scope.Close(Call_(v8::Context::GetCurrent()->Global(), argc, argv));
+#endif // NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
+ }
+
+ inline MaybeLocal<v8::Value> operator()(
+ AsyncResource* resource
+ , int argc = 0
+ , v8::Local<v8::Value> argv[] = 0) const {
+ return this->Call(argc, argv, resource);
+ }
+
+ inline MaybeLocal<v8::Value> operator()(
+ AsyncResource* resource
+ , v8::Local<v8::Object> target
+ , int argc = 0
+ , v8::Local<v8::Value> argv[] = 0) const {
+ return this->Call(target, argc, argv, resource);
+ }
+
+ // TODO(kkoopa): remove
+ inline void SetFunction(const v8::Local<v8::Function> &fn) {
+ Reset(fn);
+ }
+
+ inline void Reset(const v8::Local<v8::Function> &fn) {
+ handle_.Reset(fn);
+ }
+
+ inline void Reset() {
+ handle_.Reset();
+ }
+
+ inline v8::Local<v8::Function> GetFunction() const {
+ return New(handle_);
+ }
+
+ inline bool IsEmpty() const {
+ return handle_.IsEmpty();
+ }
+
+ // Deprecated: For async callbacks Use the versions that accept an
+ // AsyncResource. If this callback does not correspond to an async resource,
+ // that is, it is a synchronous function call on a non-empty JS stack, you
+ // should Nan::Call instead.
+ NAN_DEPRECATED inline v8::Local<v8::Value>
+ Call(v8::Local<v8::Object> target
+ , int argc
+ , v8::Local<v8::Value> argv[]) const {
+#if NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+# if NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
+ AsyncResource async("nan:Callback:Call");
+ return Call_(isolate, target, argc, argv, &async)
+ .FromMaybe(v8::Local<v8::Value>());
+# else
+ return Call_(isolate, target, argc, argv);
+# endif // NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
+#else
+ return Call_(target, argc, argv);
+#endif
+ }
+
+ // Deprecated: For async callbacks Use the versions that accept an
+ // AsyncResource. If this callback does not correspond to an async resource,
+ // that is, it is a synchronous function call on a non-empty JS stack, you
+ // should Nan::Call instead.
+ NAN_DEPRECATED inline v8::Local<v8::Value>
+ Call(int argc, v8::Local<v8::Value> argv[]) const {
+#if NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+# if NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
+ AsyncResource async("nan:Callback:Call");
+ return scope.Escape(Call_(isolate, isolate->GetCurrentContext()->Global(),
+ argc, argv, &async)
+ .FromMaybe(v8::Local<v8::Value>()));
+# else
+ return scope.Escape(
+ Call_(isolate, isolate->GetCurrentContext()->Global(), argc, argv));
+# endif // NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
+#else
+ v8::HandleScope scope;
+ return scope.Close(Call_(v8::Context::GetCurrent()->Global(), argc, argv));
+#endif
+ }
+
+ inline MaybeLocal<v8::Value>
+ Call(v8::Local<v8::Object> target
+ , int argc
+ , v8::Local<v8::Value> argv[]
+ , AsyncResource* resource) const {
+#if NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ return Call_(isolate, target, argc, argv, resource);
+#elif NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ return Call_(isolate, target, argc, argv);
+#else
+ return Call_(target, argc, argv);
+#endif
+ }
+
+ inline MaybeLocal<v8::Value>
+ Call(int argc, v8::Local<v8::Value> argv[], AsyncResource* resource) const {
+#if NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ return Call(isolate->GetCurrentContext()->Global(), argc, argv, resource);
+#elif NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ return scope.Escape(
+ Call_(isolate, isolate->GetCurrentContext()->Global(), argc, argv));
+#else
+ v8::HandleScope scope;
+ return scope.Close(Call_(v8::Context::GetCurrent()->Global(), argc, argv));
+#endif
+ }
+
+ private:
+ NAN_DISALLOW_ASSIGN_COPY_MOVE(Callback)
+ Persistent<v8::Function> handle_;
+
+#if NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
+ MaybeLocal<v8::Value> Call_(v8::Isolate *isolate
+ , v8::Local<v8::Object> target
+ , int argc
+ , v8::Local<v8::Value> argv[]
+ , AsyncResource* resource) const {
+ EscapableHandleScope scope;
+ v8::Local<v8::Function> func = New(handle_);
+ auto maybe = resource->runInAsyncScope(target, func, argc, argv);
+ v8::Local<v8::Value> local;
+ if (!maybe.ToLocal(&local)) return MaybeLocal<v8::Value>();
+ return scope.Escape(local);
+ }
+#elif NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
+ v8::Local<v8::Value> Call_(v8::Isolate *isolate
+ , v8::Local<v8::Object> target
+ , int argc
+ , v8::Local<v8::Value> argv[]) const {
+ EscapableHandleScope scope;
+
+ v8::Local<v8::Function> callback = New(handle_);
+# if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION
+ return scope.Escape(New(node::MakeCallback(
+ isolate
+ , target
+ , callback
+ , argc
+ , argv
+ )));
+# else
+ return scope.Escape(node::MakeCallback(
+ isolate
+ , target
+ , callback
+ , argc
+ , argv
+ ));
+# endif
+ }
+#else
+ v8::Local<v8::Value> Call_(v8::Local<v8::Object> target
+ , int argc
+ , v8::Local<v8::Value> argv[]) const {
+ EscapableHandleScope scope;
+
+ v8::Local<v8::Function> callback = New(handle_);
+ return scope.Escape(New(node::MakeCallback(
+ target
+ , callback
+ , argc
+ , argv
+ )));
+ }
+#endif
+};
+
+inline MaybeLocal<v8::Value> Call(
+ const Nan::Callback& callback
+ , v8::Local<v8::Object> recv
+ , int argc
+ , v8::Local<v8::Value> argv[]) {
+ return Call(*callback, recv, argc, argv);
+}
+
+inline MaybeLocal<v8::Value> Call(
+ const Nan::Callback& callback
+ , int argc
+ , v8::Local<v8::Value> argv[]) {
+#if NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ return scope.Escape(
+ Call(*callback, isolate->GetCurrentContext()->Global(), argc, argv)
+ .FromMaybe(v8::Local<v8::Value>()));
+#else
+ EscapableHandleScope scope;
+ return scope.Escape(
+ Call(*callback, v8::Context::GetCurrent()->Global(), argc, argv)
+ .FromMaybe(v8::Local<v8::Value>()));
+#endif
+}
+
+inline MaybeLocal<v8::Value> Call(
+ v8::Local<v8::String> symbol
+ , v8::Local<v8::Object> recv
+ , int argc
+ , v8::Local<v8::Value> argv[]) {
+ EscapableHandleScope scope;
+ v8::Local<v8::Value> fn_v =
+ Get(recv, symbol).FromMaybe(v8::Local<v8::Value>());
+ if (fn_v.IsEmpty() || !fn_v->IsFunction()) return v8::Local<v8::Value>();
+ v8::Local<v8::Function> fn = fn_v.As<v8::Function>();
+ return scope.Escape(
+ Call(fn, recv, argc, argv).FromMaybe(v8::Local<v8::Value>()));
+}
+
+inline MaybeLocal<v8::Value> Call(
+ const char* method
+ , v8::Local<v8::Object> recv
+ , int argc
+ , v8::Local<v8::Value> argv[]) {
+ EscapableHandleScope scope;
+ v8::Local<v8::String> method_string =
+ New<v8::String>(method).ToLocalChecked();
+ return scope.Escape(
+ Call(method_string, recv, argc, argv).FromMaybe(v8::Local<v8::Value>()));
+}
+
+/* abstract */ class AsyncWorker {
+ public:
+ explicit AsyncWorker(Callback *callback_,
+ const char* resource_name = "nan:AsyncWorker")
+ : callback(callback_), errmsg_(NULL) {
+ request.data = this;
+
+ HandleScope scope;
+ v8::Local<v8::Object> obj = New<v8::Object>();
+ persistentHandle.Reset(obj);
+ async_resource = new AsyncResource(resource_name, obj);
+ }
+
+ virtual ~AsyncWorker() {
+ HandleScope scope;
+
+ if (!persistentHandle.IsEmpty())
+ persistentHandle.Reset();
+ delete callback;
+ delete[] errmsg_;
+ delete async_resource;
+ }
+
+ virtual void WorkComplete() {
+ HandleScope scope;
+
+ if (errmsg_ == NULL)
+ HandleOKCallback();
+ else
+ HandleErrorCallback();
+ delete callback;
+ callback = NULL;
+ }
+
+ inline void SaveToPersistent(
+ const char *key, const v8::Local<v8::Value> &value) {
+ HandleScope scope;
+ Set(New(persistentHandle), New(key).ToLocalChecked(), value).FromJust();
+ }
+
+ inline void SaveToPersistent(
+ const v8::Local<v8::String> &key, const v8::Local<v8::Value> &value) {
+ HandleScope scope;
+ Set(New(persistentHandle), key, value).FromJust();
+ }
+
+ inline void SaveToPersistent(
+ uint32_t index, const v8::Local<v8::Value> &value) {
+ HandleScope scope;
+ Set(New(persistentHandle), index, value).FromJust();
+ }
+
+ inline v8::Local<v8::Value> GetFromPersistent(const char *key) const {
+ EscapableHandleScope scope;
+ return scope.Escape(
+ Get(New(persistentHandle), New(key).ToLocalChecked())
+ .FromMaybe(v8::Local<v8::Value>()));
+ }
+
+ inline v8::Local<v8::Value>
+ GetFromPersistent(const v8::Local<v8::String> &key) const {
+ EscapableHandleScope scope;
+ return scope.Escape(
+ Get(New(persistentHandle), key)
+ .FromMaybe(v8::Local<v8::Value>()));
+ }
+
+ inline v8::Local<v8::Value> GetFromPersistent(uint32_t index) const {
+ EscapableHandleScope scope;
+ return scope.Escape(
+ Get(New(persistentHandle), index)
+ .FromMaybe(v8::Local<v8::Value>()));
+ }
+
+ virtual void Execute() = 0;
+
+ uv_work_t request;
+
+ virtual void Destroy() {
+ delete this;
+ }
+
+ protected:
+ Persistent<v8::Object> persistentHandle;
+ Callback *callback;
+ AsyncResource *async_resource;
+
+ virtual void HandleOKCallback() {
+ HandleScope scope;
+
+ callback->Call(0, NULL, async_resource);
+ }
+
+ virtual void HandleErrorCallback() {
+ HandleScope scope;
+
+ v8::Local<v8::Value> argv[] = {
+ v8::Exception::Error(New<v8::String>(ErrorMessage()).ToLocalChecked())
+ };
+ callback->Call(1, argv, async_resource);
+ }
+
+ void SetErrorMessage(const char *msg) {
+ delete[] errmsg_;
+
+ size_t size = strlen(msg) + 1;
+ errmsg_ = new char[size];
+ memcpy(errmsg_, msg, size);
+ }
+
+ const char* ErrorMessage() const {
+ return errmsg_;
+ }
+
+ private:
+ NAN_DISALLOW_ASSIGN_COPY_MOVE(AsyncWorker)
+ char *errmsg_;
+};
+
+/* abstract */ class AsyncBareProgressWorkerBase : public AsyncWorker {
+ public:
+ explicit AsyncBareProgressWorkerBase(
+ Callback *callback_,
+ const char* resource_name = "nan:AsyncBareProgressWorkerBase")
+ : AsyncWorker(callback_, resource_name) {
+ uv_async_init(
+ GetCurrentEventLoop()
+ , &async
+ , AsyncProgress_
+ );
+ async.data = this;
+ }
+
+ virtual ~AsyncBareProgressWorkerBase() {
+ }
+
+ virtual void WorkProgress() = 0;
+
+ virtual void Destroy() {
+ uv_close(reinterpret_cast<uv_handle_t*>(&async), AsyncClose_);
+ }
+
+ private:
+ inline static NAUV_WORK_CB(AsyncProgress_) {
+ AsyncBareProgressWorkerBase *worker =
+ static_cast<AsyncBareProgressWorkerBase*>(async->data);
+ worker->WorkProgress();
+ }
+
+ inline static void AsyncClose_(uv_handle_t* handle) {
+ AsyncBareProgressWorkerBase *worker =
+ static_cast<AsyncBareProgressWorkerBase*>(handle->data);
+ delete worker;
+ }
+
+ protected:
+ uv_async_t async;
+};
+
+template<class T>
+/* abstract */
+class AsyncBareProgressWorker : public AsyncBareProgressWorkerBase {
+ public:
+ explicit AsyncBareProgressWorker(
+ Callback *callback_,
+ const char* resource_name = "nan:AsyncBareProgressWorker")
+ : AsyncBareProgressWorkerBase(callback_, resource_name) {
+ uv_mutex_init(&async_lock);
+ }
+
+ virtual ~AsyncBareProgressWorker() {
+ uv_mutex_destroy(&async_lock);
+ }
+
+ class ExecutionProgress {
+ friend class AsyncBareProgressWorker;
+ public:
+ void Signal() const {
+ uv_mutex_lock(&that_->async_lock);
+ uv_async_send(&that_->async);
+ uv_mutex_unlock(&that_->async_lock);
+ }
+
+ void Send(const T* data, size_t count) const {
+ that_->SendProgress_(data, count);
+ }
+
+ private:
+ explicit ExecutionProgress(AsyncBareProgressWorker *that) : that_(that) {}
+ NAN_DISALLOW_ASSIGN_COPY_MOVE(ExecutionProgress)
+ AsyncBareProgressWorker* const that_;
+ };
+
+ virtual void Execute(const ExecutionProgress& progress) = 0;
+ virtual void HandleProgressCallback(const T *data, size_t size) = 0;
+
+ protected:
+ uv_mutex_t async_lock;
+
+ private:
+ void Execute() /*final override*/ {
+ ExecutionProgress progress(this);
+ Execute(progress);
+ }
+
+ virtual void SendProgress_(const T *data, size_t count) = 0;
+};
+
+template<class T>
+/* abstract */
+class AsyncProgressWorkerBase : public AsyncBareProgressWorker<T> {
+ public:
+ explicit AsyncProgressWorkerBase(
+ Callback *callback_,
+ const char* resource_name = "nan:AsyncProgressWorkerBase")
+ : AsyncBareProgressWorker<T>(callback_, resource_name), asyncdata_(NULL),
+ asyncsize_(0) {
+ }
+
+ virtual ~AsyncProgressWorkerBase() {
+ delete[] asyncdata_;
+ }
+
+ void WorkProgress() {
+ uv_mutex_lock(&this->async_lock);
+ T *data = asyncdata_;
+ size_t size = asyncsize_;
+ asyncdata_ = NULL;
+ asyncsize_ = 0;
+ uv_mutex_unlock(&this->async_lock);
+
+ // Don't send progress events after we've already completed.
+ if (this->callback) {
+ this->HandleProgressCallback(data, size);
+ }
+ delete[] data;
+ }
+
+ private:
+ void SendProgress_(const T *data, size_t count) {
+ T *new_data = new T[count];
+ std::copy(data, data + count, new_data);
+
+ uv_mutex_lock(&this->async_lock);
+ T *old_data = asyncdata_;
+ asyncdata_ = new_data;
+ asyncsize_ = count;
+ uv_async_send(&this->async);
+ uv_mutex_unlock(&this->async_lock);
+
+ delete[] old_data;
+ }
+
+ T *asyncdata_;
+ size_t asyncsize_;
+};
+
+// This ensures compatibility to the previous un-templated AsyncProgressWorker
+// class definition.
+typedef AsyncProgressWorkerBase<char> AsyncProgressWorker;
+
+template<class T>
+/* abstract */
+class AsyncBareProgressQueueWorker : public AsyncBareProgressWorkerBase {
+ public:
+ explicit AsyncBareProgressQueueWorker(
+ Callback *callback_,
+ const char* resource_name = "nan:AsyncBareProgressQueueWorker")
+ : AsyncBareProgressWorkerBase(callback_, resource_name) {
+ }
+
+ virtual ~AsyncBareProgressQueueWorker() {
+ }
+
+ class ExecutionProgress {
+ friend class AsyncBareProgressQueueWorker;
+ public:
+ void Send(const T* data, size_t count) const {
+ that_->SendProgress_(data, count);
+ }
+
+ private:
+ explicit ExecutionProgress(AsyncBareProgressQueueWorker *that)
+ : that_(that) {}
+ NAN_DISALLOW_ASSIGN_COPY_MOVE(ExecutionProgress)
+ AsyncBareProgressQueueWorker* const that_;
+ };
+
+ virtual void Execute(const ExecutionProgress& progress) = 0;
+ virtual void HandleProgressCallback(const T *data, size_t size) = 0;
+
+ private:
+ void Execute() /*final override*/ {
+ ExecutionProgress progress(this);
+ Execute(progress);
+ }
+
+ virtual void SendProgress_(const T *data, size_t count) = 0;
+};
+
+template<class T>
+/* abstract */
+class AsyncProgressQueueWorker : public AsyncBareProgressQueueWorker<T> {
+ public:
+ explicit AsyncProgressQueueWorker(
+ Callback *callback_,
+ const char* resource_name = "nan:AsyncProgressQueueWorker")
+ : AsyncBareProgressQueueWorker<T>(callback_) {
+ uv_mutex_init(&async_lock);
+ }
+
+ virtual ~AsyncProgressQueueWorker() {
+ uv_mutex_lock(&async_lock);
+
+ while (!asyncdata_.empty()) {
+ std::pair<T*, size_t> &datapair = asyncdata_.front();
+ T *data = datapair.first;
+
+ asyncdata_.pop();
+
+ delete[] data;
+ }
+
+ uv_mutex_unlock(&async_lock);
+ uv_mutex_destroy(&async_lock);
+ }
+
+ void WorkComplete() {
+ WorkProgress();
+ AsyncWorker::WorkComplete();
+ }
+
+ void WorkProgress() {
+ uv_mutex_lock(&async_lock);
+
+ while (!asyncdata_.empty()) {
+ std::pair<T*, size_t> &datapair = asyncdata_.front();
+
+ T *data = datapair.first;
+ size_t size = datapair.second;
+
+ asyncdata_.pop();
+ uv_mutex_unlock(&async_lock);
+
+ // Don't send progress events after we've already completed.
+ if (this->callback) {
+ this->HandleProgressCallback(data, size);
+ }
+
+ delete[] data;
+
+ uv_mutex_lock(&async_lock);
+ }
+
+ uv_mutex_unlock(&async_lock);
+ }
+
+ private:
+ void SendProgress_(const T *data, size_t count) {
+ T *new_data = new T[count];
+ std::copy(data, data + count, new_data);
+
+ uv_mutex_lock(&async_lock);
+ asyncdata_.push(std::pair<T*, size_t>(new_data, count));
+ uv_mutex_unlock(&async_lock);
+
+ uv_async_send(&this->async);
+ }
+
+ uv_mutex_t async_lock;
+ std::queue<std::pair<T*, size_t> > asyncdata_;
+};
+
+inline void AsyncExecute (uv_work_t* req) {
+ AsyncWorker *worker = static_cast<AsyncWorker*>(req->data);
+ worker->Execute();
+}
+
+/* uv_after_work_cb has 1 argument before node-v0.9.4 and
+ * 2 arguments since node-v0.9.4
+ * https://github.com/libuv/libuv/commit/92fb84b751e18f032c02609467f44bfe927b80c5
+ */
+inline void AsyncExecuteComplete(uv_work_t *req) {
+ AsyncWorker* worker = static_cast<AsyncWorker*>(req->data);
+ worker->WorkComplete();
+ worker->Destroy();
+}
+inline void AsyncExecuteComplete (uv_work_t* req, int status) {
+ AsyncExecuteComplete(req);
+}
+
+inline void AsyncQueueWorker (AsyncWorker* worker) {
+ uv_queue_work(
+ GetCurrentEventLoop()
+ , &worker->request
+ , AsyncExecute
+ , AsyncExecuteComplete
+ );
+}
+
+namespace imp {
+
+inline
+ExternalOneByteStringResource const*
+GetExternalResource(v8::Local<v8::String> str) {
+#if NODE_MODULE_VERSION < ATOM_0_21_MODULE_VERSION
+ return str->GetExternalAsciiStringResource();
+#else
+ return str->GetExternalOneByteStringResource();
+#endif
+}
+
+inline
+bool
+IsExternal(v8::Local<v8::String> str) {
+#if NODE_MODULE_VERSION < ATOM_0_21_MODULE_VERSION
+ return str->IsExternalAscii();
+#else
+ return str->IsExternalOneByte();
+#endif
+}
+
+} // end of namespace imp
+
+enum Encoding {ASCII, UTF8, BASE64, UCS2, BINARY, HEX, BUFFER};
+
+#if NODE_MODULE_VERSION < NODE_0_10_MODULE_VERSION
+# include "nan_string_bytes.h" // NOLINT(build/include)
+#endif
+
+inline v8::Local<v8::Value> Encode(
+ const void *buf, size_t len, enum Encoding encoding = BINARY) {
+#if (NODE_MODULE_VERSION >= ATOM_0_21_MODULE_VERSION)
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ node::encoding node_enc = static_cast<node::encoding>(encoding);
+
+ if (encoding == UCS2) {
+ return node::Encode(
+ isolate
+ , reinterpret_cast<const uint16_t *>(buf)
+ , len / 2);
+ } else {
+ return node::Encode(
+ isolate
+ , reinterpret_cast<const char *>(buf)
+ , len
+ , node_enc);
+ }
+#elif (NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION)
+ return node::Encode(
+ v8::Isolate::GetCurrent()
+ , buf, len
+ , static_cast<node::encoding>(encoding));
+#else
+# if NODE_MODULE_VERSION >= NODE_0_10_MODULE_VERSION
+ return node::Encode(buf, len, static_cast<node::encoding>(encoding));
+# else
+ return imp::Encode(reinterpret_cast<const char*>(buf), len, encoding);
+# endif
+#endif
+}
+
+inline ssize_t DecodeBytes(
+ v8::Local<v8::Value> val, enum Encoding encoding = BINARY) {
+#if (NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION)
+ return node::DecodeBytes(
+ v8::Isolate::GetCurrent()
+ , val
+ , static_cast<node::encoding>(encoding));
+#else
+# if (NODE_MODULE_VERSION < NODE_0_10_MODULE_VERSION)
+ if (encoding == BUFFER) {
+ return node::DecodeBytes(val, node::BINARY);
+ }
+# endif
+ return node::DecodeBytes(val, static_cast<node::encoding>(encoding));
+#endif
+}
+
+inline ssize_t DecodeWrite(
+ char *buf
+ , size_t len
+ , v8::Local<v8::Value> val
+ , enum Encoding encoding = BINARY) {
+#if (NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION)
+ return node::DecodeWrite(
+ v8::Isolate::GetCurrent()
+ , buf
+ , len
+ , val
+ , static_cast<node::encoding>(encoding));
+#else
+# if (NODE_MODULE_VERSION < NODE_0_10_MODULE_VERSION)
+ if (encoding == BUFFER) {
+ return node::DecodeWrite(buf, len, val, node::BINARY);
+ }
+# endif
+ return node::DecodeWrite(
+ buf
+ , len
+ , val
+ , static_cast<node::encoding>(encoding));
+#endif
+}
+
+inline void SetPrototypeTemplate(
+ v8::Local<v8::FunctionTemplate> templ
+ , const char *name
+ , v8::Local<v8::Data> value
+) {
+ HandleScope scope;
+ SetTemplate(templ->PrototypeTemplate(), name, value);
+}
+
+inline void SetPrototypeTemplate(
+ v8::Local<v8::FunctionTemplate> templ
+ , v8::Local<v8::String> name
+ , v8::Local<v8::Data> value
+ , v8::PropertyAttribute attributes
+) {
+ HandleScope scope;
+ SetTemplate(templ->PrototypeTemplate(), name, value, attributes);
+}
+
+inline void SetInstanceTemplate(
+ v8::Local<v8::FunctionTemplate> templ
+ , const char *name
+ , v8::Local<v8::Data> value
+) {
+ HandleScope scope;
+ SetTemplate(templ->InstanceTemplate(), name, value);
+}
+
+inline void SetInstanceTemplate(
+ v8::Local<v8::FunctionTemplate> templ
+ , v8::Local<v8::String> name
+ , v8::Local<v8::Data> value
+ , v8::PropertyAttribute attributes
+) {
+ HandleScope scope;
+ SetTemplate(templ->InstanceTemplate(), name, value, attributes);
+}
+
+namespace imp {
+
+// Note(@agnat): Helper to distinguish different receiver types. The first
+// version deals with receivers derived from v8::Template. The second version
+// handles everything else. The final argument only serves as discriminator and
+// is unused.
+template <typename T>
+inline
+void
+SetMethodAux(T recv,
+ v8::Local<v8::String> name,
+ v8::Local<v8::FunctionTemplate> tpl,
+ v8::Template *) {
+ recv->Set(name, tpl);
+}
+
+template <typename T>
+inline
+void
+SetMethodAux(T recv,
+ v8::Local<v8::String> name,
+ v8::Local<v8::FunctionTemplate> tpl,
+ ...) {
+ Set(recv, name, GetFunction(tpl).ToLocalChecked());
+}
+
+} // end of namespace imp
+
+template <typename T, template <typename> class HandleType>
+inline void SetMethod(
+ HandleType<T> recv
+ , const char *name
+ , FunctionCallback callback
+ , v8::Local<v8::Value> data = v8::Local<v8::Value>()) {
+ HandleScope scope;
+ v8::Local<v8::FunctionTemplate> t = New<v8::FunctionTemplate>(callback, data);
+ v8::Local<v8::String> fn_name = New(name).ToLocalChecked();
+ t->SetClassName(fn_name);
+ // Note(@agnat): Pass an empty T* as discriminator. See note on
+ // SetMethodAux(...) above
+ imp::SetMethodAux(recv, fn_name, t, static_cast<T*>(0));
+}
+
+inline void SetPrototypeMethod(
+ v8::Local<v8::FunctionTemplate> recv
+ , const char* name
+ , FunctionCallback callback
+ , v8::Local<v8::Value> data = v8::Local<v8::Value>()) {
+ HandleScope scope;
+ v8::Local<v8::FunctionTemplate> t = New<v8::FunctionTemplate>(
+ callback
+ , data
+ , New<v8::Signature>(recv));
+ v8::Local<v8::String> fn_name = New(name).ToLocalChecked();
+ recv->PrototypeTemplate()->Set(fn_name, t);
+ t->SetClassName(fn_name);
+}
+
+//=== Accessors and Such =======================================================
+
+inline void SetAccessor(
+ v8::Local<v8::ObjectTemplate> tpl
+ , v8::Local<v8::String> name
+ , GetterCallback getter
+ , SetterCallback setter = 0
+ , v8::Local<v8::Value> data = v8::Local<v8::Value>()
+ , v8::AccessControl settings = v8::DEFAULT
+ , v8::PropertyAttribute attribute = v8::None
+ , imp::Sig signature = imp::Sig()) {
+ HandleScope scope;
+
+ imp::NativeGetter getter_ =
+ imp::GetterCallbackWrapper;
+ imp::NativeSetter setter_ =
+ setter ? imp::SetterCallbackWrapper : 0;
+
+ v8::Local<v8::ObjectTemplate> otpl = New<v8::ObjectTemplate>();
+ otpl->SetInternalFieldCount(imp::kAccessorFieldCount);
+ v8::Local<v8::Object> obj = NewInstance(otpl).ToLocalChecked();
+
+ obj->SetInternalField(
+ imp::kGetterIndex
+ , New<v8::External>(reinterpret_cast<void *>(getter)));
+
+ if (setter != 0) {
+ obj->SetInternalField(
+ imp::kSetterIndex
+ , New<v8::External>(reinterpret_cast<void *>(setter)));
+ }
+
+ if (!data.IsEmpty()) {
+ obj->SetInternalField(imp::kDataIndex, data);
+ }
+
+ tpl->SetAccessor(
+ name
+ , getter_
+ , setter_
+ , obj
+ , settings
+ , attribute
+ , signature);
+}
+
+inline bool SetAccessor(
+ v8::Local<v8::Object> obj
+ , v8::Local<v8::String> name
+ , GetterCallback getter
+ , SetterCallback setter = 0
+ , v8::Local<v8::Value> data = v8::Local<v8::Value>()
+ , v8::AccessControl settings = v8::DEFAULT
+ , v8::PropertyAttribute attribute = v8::None) {
+ HandleScope scope;
+
+ imp::NativeGetter getter_ =
+ imp::GetterCallbackWrapper;
+ imp::NativeSetter setter_ =
+ setter ? imp::SetterCallbackWrapper : 0;
+
+ v8::Local<v8::ObjectTemplate> otpl = New<v8::ObjectTemplate>();
+ otpl->SetInternalFieldCount(imp::kAccessorFieldCount);
+ v8::Local<v8::Object> dataobj = NewInstance(otpl).ToLocalChecked();
+
+ dataobj->SetInternalField(
+ imp::kGetterIndex
+ , New<v8::External>(reinterpret_cast<void *>(getter)));
+
+ if (!data.IsEmpty()) {
+ dataobj->SetInternalField(imp::kDataIndex, data);
+ }
+
+ if (setter) {
+ dataobj->SetInternalField(
+ imp::kSetterIndex
+ , New<v8::External>(reinterpret_cast<void *>(setter)));
+ }
+
+#if (NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION)
+ return obj->SetAccessor(
+ GetCurrentContext()
+ , name
+ , getter_
+ , setter_
+ , dataobj
+ , settings
+ , attribute).FromMaybe(false);
+#else
+ return obj->SetAccessor(
+ name
+ , getter_
+ , setter_
+ , dataobj
+ , settings
+ , attribute);
+#endif
+}
+
+inline void SetNamedPropertyHandler(
+ v8::Local<v8::ObjectTemplate> tpl
+ , PropertyGetterCallback getter
+ , PropertySetterCallback setter = 0
+ , PropertyQueryCallback query = 0
+ , PropertyDeleterCallback deleter = 0
+ , PropertyEnumeratorCallback enumerator = 0
+ , v8::Local<v8::Value> data = v8::Local<v8::Value>()) {
+ HandleScope scope;
+
+ imp::NativePropertyGetter getter_ =
+ imp::PropertyGetterCallbackWrapper;
+ imp::NativePropertySetter setter_ =
+ setter ? imp::PropertySetterCallbackWrapper : 0;
+ imp::NativePropertyQuery query_ =
+ query ? imp::PropertyQueryCallbackWrapper : 0;
+ imp::NativePropertyDeleter *deleter_ =
+ deleter ? imp::PropertyDeleterCallbackWrapper : 0;
+ imp::NativePropertyEnumerator enumerator_ =
+ enumerator ? imp::PropertyEnumeratorCallbackWrapper : 0;
+
+ v8::Local<v8::ObjectTemplate> otpl = New<v8::ObjectTemplate>();
+ otpl->SetInternalFieldCount(imp::kPropertyFieldCount);
+ v8::Local<v8::Object> obj = NewInstance(otpl).ToLocalChecked();
+ obj->SetInternalField(
+ imp::kPropertyGetterIndex
+ , New<v8::External>(reinterpret_cast<void *>(getter)));
+
+ if (setter) {
+ obj->SetInternalField(
+ imp::kPropertySetterIndex
+ , New<v8::External>(reinterpret_cast<void *>(setter)));
+ }
+
+ if (query) {
+ obj->SetInternalField(
+ imp::kPropertyQueryIndex
+ , New<v8::External>(reinterpret_cast<void *>(query)));
+ }
+
+ if (deleter) {
+ obj->SetInternalField(
+ imp::kPropertyDeleterIndex
+ , New<v8::External>(reinterpret_cast<void *>(deleter)));
+ }
+
+ if (enumerator) {
+ obj->SetInternalField(
+ imp::kPropertyEnumeratorIndex
+ , New<v8::External>(reinterpret_cast<void *>(enumerator)));
+ }
+
+ if (!data.IsEmpty()) {
+ obj->SetInternalField(imp::kDataIndex, data);
+ }
+
+#if NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION
+ tpl->SetHandler(v8::NamedPropertyHandlerConfiguration(
+ getter_, setter_, query_, deleter_, enumerator_, obj));
+#else
+ tpl->SetNamedPropertyHandler(
+ getter_
+ , setter_
+ , query_
+ , deleter_
+ , enumerator_
+ , obj);
+#endif
+}
+
+inline void SetIndexedPropertyHandler(
+ v8::Local<v8::ObjectTemplate> tpl
+ , IndexGetterCallback getter
+ , IndexSetterCallback setter = 0
+ , IndexQueryCallback query = 0
+ , IndexDeleterCallback deleter = 0
+ , IndexEnumeratorCallback enumerator = 0
+ , v8::Local<v8::Value> data = v8::Local<v8::Value>()) {
+ HandleScope scope;
+
+ imp::NativeIndexGetter getter_ =
+ imp::IndexGetterCallbackWrapper;
+ imp::NativeIndexSetter setter_ =
+ setter ? imp::IndexSetterCallbackWrapper : 0;
+ imp::NativeIndexQuery query_ =
+ query ? imp::IndexQueryCallbackWrapper : 0;
+ imp::NativeIndexDeleter deleter_ =
+ deleter ? imp::IndexDeleterCallbackWrapper : 0;
+ imp::NativeIndexEnumerator enumerator_ =
+ enumerator ? imp::IndexEnumeratorCallbackWrapper : 0;
+
+ v8::Local<v8::ObjectTemplate> otpl = New<v8::ObjectTemplate>();
+ otpl->SetInternalFieldCount(imp::kIndexPropertyFieldCount);
+ v8::Local<v8::Object> obj = NewInstance(otpl).ToLocalChecked();
+ obj->SetInternalField(
+ imp::kIndexPropertyGetterIndex
+ , New<v8::External>(reinterpret_cast<void *>(getter)));
+
+ if (setter) {
+ obj->SetInternalField(
+ imp::kIndexPropertySetterIndex
+ , New<v8::External>(reinterpret_cast<void *>(setter)));
+ }
+
+ if (query) {
+ obj->SetInternalField(
+ imp::kIndexPropertyQueryIndex
+ , New<v8::External>(reinterpret_cast<void *>(query)));
+ }
+
+ if (deleter) {
+ obj->SetInternalField(
+ imp::kIndexPropertyDeleterIndex
+ , New<v8::External>(reinterpret_cast<void *>(deleter)));
+ }
+
+ if (enumerator) {
+ obj->SetInternalField(
+ imp::kIndexPropertyEnumeratorIndex
+ , New<v8::External>(reinterpret_cast<void *>(enumerator)));
+ }
+
+ if (!data.IsEmpty()) {
+ obj->SetInternalField(imp::kDataIndex, data);
+ }
+
+#if NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION
+ tpl->SetHandler(v8::IndexedPropertyHandlerConfiguration(
+ getter_, setter_, query_, deleter_, enumerator_, obj));
+#else
+ tpl->SetIndexedPropertyHandler(
+ getter_
+ , setter_
+ , query_
+ , deleter_
+ , enumerator_
+ , obj);
+#endif
+}
+
+inline void SetCallHandler(
+ v8::Local<v8::FunctionTemplate> tpl
+ , FunctionCallback callback
+ , v8::Local<v8::Value> data = v8::Local<v8::Value>()) {
+ HandleScope scope;
+
+ v8::Local<v8::ObjectTemplate> otpl = New<v8::ObjectTemplate>();
+ otpl->SetInternalFieldCount(imp::kFunctionFieldCount);
+ v8::Local<v8::Object> obj = NewInstance(otpl).ToLocalChecked();
+
+ obj->SetInternalField(
+ imp::kFunctionIndex
+ , New<v8::External>(reinterpret_cast<void *>(callback)));
+
+ if (!data.IsEmpty()) {
+ obj->SetInternalField(imp::kDataIndex, data);
+ }
+
+ tpl->SetCallHandler(imp::FunctionCallbackWrapper, obj);
+}
+
+
+inline void SetCallAsFunctionHandler(
+ v8::Local<v8::ObjectTemplate> tpl,
+ FunctionCallback callback,
+ v8::Local<v8::Value> data = v8::Local<v8::Value>()) {
+ HandleScope scope;
+
+ v8::Local<v8::ObjectTemplate> otpl = New<v8::ObjectTemplate>();
+ otpl->SetInternalFieldCount(imp::kFunctionFieldCount);
+ v8::Local<v8::Object> obj = NewInstance(otpl).ToLocalChecked();
+
+ obj->SetInternalField(
+ imp::kFunctionIndex
+ , New<v8::External>(reinterpret_cast<void *>(callback)));
+
+ if (!data.IsEmpty()) {
+ obj->SetInternalField(imp::kDataIndex, data);
+ }
+
+ tpl->SetCallAsFunctionHandler(imp::FunctionCallbackWrapper, obj);
+}
+
+//=== Weak Persistent Handling =================================================
+
+#include "nan_weak.h" // NOLINT(build/include)
+
+//=== ObjectWrap ===============================================================
+
+#include "nan_object_wrap.h" // NOLINT(build/include)
+
+//=== HiddenValue/Private ======================================================
+
+#include "nan_private.h" // NOLINT(build/include)
+
+//=== Export ==================================================================
+
+inline
+void
+Export(ADDON_REGISTER_FUNCTION_ARGS_TYPE target, const char *name,
+ FunctionCallback f) {
+ HandleScope scope;
+
+ Set(target, New<v8::String>(name).ToLocalChecked(),
+ GetFunction(New<v8::FunctionTemplate>(f)).ToLocalChecked());
+}
+
+//=== Tap Reverse Binding =====================================================
+
+struct Tap {
+ explicit Tap(v8::Local<v8::Value> t) : t_() {
+ HandleScope scope;
+
+ t_.Reset(To<v8::Object>(t).ToLocalChecked());
+ }
+
+ ~Tap() { t_.Reset(); } // not sure if necessary
+
+ inline void plan(int i) {
+ HandleScope scope;
+ v8::Local<v8::Value> arg = New(i);
+ Call("plan", New(t_), 1, &arg);
+ }
+
+ inline void ok(bool isOk, const char *msg = NULL) {
+ HandleScope scope;
+ v8::Local<v8::Value> args[2];
+ args[0] = New(isOk);
+ if (msg) args[1] = New(msg).ToLocalChecked();
+ Call("ok", New(t_), msg ? 2 : 1, args);
+ }
+
+ inline void pass(const char * msg = NULL) {
+ HandleScope scope;
+ v8::Local<v8::Value> hmsg;
+ if (msg) hmsg = New(msg).ToLocalChecked();
+ Call("pass", New(t_), msg ? 1 : 0, &hmsg);
+ }
+
+ inline void end() {
+ HandleScope scope;
+ Call("end", New(t_), 0, NULL);
+ }
+
+ private:
+ Persistent<v8::Object> t_;
+};
+
+#define NAN_STRINGIZE2(x) #x
+#define NAN_STRINGIZE(x) NAN_STRINGIZE2(x)
+#define NAN_TEST_EXPRESSION(expression) \
+ ( expression ), __FILE__ ":" NAN_STRINGIZE(__LINE__) ": " #expression
+
+#define NAN_EXPORT(target, function) Export(target, #function, function)
+
+#undef TYPE_CHECK
+
+//=== Generic Maybefication ===================================================
+
+namespace imp {
+
+template <typename T> struct Maybefier;
+
+template <typename T> struct Maybefier<v8::Local<T> > {
+ inline static MaybeLocal<T> convert(v8::Local<T> v) {
+ return v;
+ }
+};
+
+template <typename T> struct Maybefier<MaybeLocal<T> > {
+ inline static MaybeLocal<T> convert(MaybeLocal<T> v) {
+ return v;
+ }
+};
+
+} // end of namespace imp
+
+template <typename T, template <typename> class MaybeMaybe>
+inline MaybeLocal<T>
+MakeMaybe(MaybeMaybe<T> v) {
+ return imp::Maybefier<MaybeMaybe<T> >::convert(v);
+}
+
+//=== TypedArrayContents =======================================================
+
+#include "nan_typedarray_contents.h" // NOLINT(build/include)
+
+//=== JSON =====================================================================
+
+#include "nan_json.h" // NOLINT(build/include)
+
+//=== ScriptOrigin =============================================================
+
+#include "nan_scriptorigin.h" // NOLINT(build/include)
+
+} // end of namespace Nan
+
+#endif // NAN_H_
diff --git a/node_modules/nan/nan_callbacks.h b/node_modules/nan/nan_callbacks.h
new file mode 100644
index 0000000..53ede84
--- /dev/null
+++ b/node_modules/nan/nan_callbacks.h
@@ -0,0 +1,88 @@
+/*********************************************************************
+ * NAN - Native Abstractions for Node.js
+ *
+ * Copyright (c) 2018 NAN contributors
+ *
+ * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
+ ********************************************************************/
+
+#ifndef NAN_CALLBACKS_H_
+#define NAN_CALLBACKS_H_
+
+template<typename T> class FunctionCallbackInfo;
+template<typename T> class PropertyCallbackInfo;
+template<typename T> class Global;
+
+typedef void(*FunctionCallback)(const FunctionCallbackInfo<v8::Value>&);
+typedef void(*GetterCallback)
+ (v8::Local<v8::String>, const PropertyCallbackInfo<v8::Value>&);
+typedef void(*SetterCallback)(
+ v8::Local<v8::String>,
+ v8::Local<v8::Value>,
+ const PropertyCallbackInfo<void>&);
+typedef void(*PropertyGetterCallback)(
+ v8::Local<v8::String>,
+ const PropertyCallbackInfo<v8::Value>&);
+typedef void(*PropertySetterCallback)(
+ v8::Local<v8::String>,
+ v8::Local<v8::Value>,
+ const PropertyCallbackInfo<v8::Value>&);
+typedef void(*PropertyEnumeratorCallback)
+ (const PropertyCallbackInfo<v8::Array>&);
+typedef void(*PropertyDeleterCallback)(
+ v8::Local<v8::String>,
+ const PropertyCallbackInfo<v8::Boolean>&);
+typedef void(*PropertyQueryCallback)(
+ v8::Local<v8::String>,
+ const PropertyCallbackInfo<v8::Integer>&);
+typedef void(*IndexGetterCallback)(
+ uint32_t,
+ const PropertyCallbackInfo<v8::Value>&);
+typedef void(*IndexSetterCallback)(
+ uint32_t,
+ v8::Local<v8::Value>,
+ const PropertyCallbackInfo<v8::Value>&);
+typedef void(*IndexEnumeratorCallback)
+ (const PropertyCallbackInfo<v8::Array>&);
+typedef void(*IndexDeleterCallback)(
+ uint32_t,
+ const PropertyCallbackInfo<v8::Boolean>&);
+typedef void(*IndexQueryCallback)(
+ uint32_t,
+ const PropertyCallbackInfo<v8::Integer>&);
+
+namespace imp {
+typedef v8::Local<v8::AccessorSignature> Sig;
+
+static const int kDataIndex = 0;
+
+static const int kFunctionIndex = 1;
+static const int kFunctionFieldCount = 2;
+
+static const int kGetterIndex = 1;
+static const int kSetterIndex = 2;
+static const int kAccessorFieldCount = 3;
+
+static const int kPropertyGetterIndex = 1;
+static const int kPropertySetterIndex = 2;
+static const int kPropertyEnumeratorIndex = 3;
+static const int kPropertyDeleterIndex = 4;
+static const int kPropertyQueryIndex = 5;
+static const int kPropertyFieldCount = 6;
+
+static const int kIndexPropertyGetterIndex = 1;
+static const int kIndexPropertySetterIndex = 2;
+static const int kIndexPropertyEnumeratorIndex = 3;
+static const int kIndexPropertyDeleterIndex = 4;
+static const int kIndexPropertyQueryIndex = 5;
+static const int kIndexPropertyFieldCount = 6;
+
+} // end of namespace imp
+
+#if NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
+# include "nan_callbacks_12_inl.h" // NOLINT(build/include)
+#else
+# include "nan_callbacks_pre_12_inl.h" // NOLINT(build/include)
+#endif
+
+#endif // NAN_CALLBACKS_H_
diff --git a/node_modules/nan/nan_callbacks_12_inl.h b/node_modules/nan/nan_callbacks_12_inl.h
new file mode 100644
index 0000000..c27b18d
--- /dev/null
+++ b/node_modules/nan/nan_callbacks_12_inl.h
@@ -0,0 +1,514 @@
+/*********************************************************************
+ * NAN - Native Abstractions for Node.js
+ *
+ * Copyright (c) 2018 NAN contributors
+ *
+ * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
+ ********************************************************************/
+
+#ifndef NAN_CALLBACKS_12_INL_H_
+#define NAN_CALLBACKS_12_INL_H_
+
+template<typename T>
+class ReturnValue {
+ v8::ReturnValue<T> value_;
+
+ public:
+ template <class S>
+ explicit inline ReturnValue(const v8::ReturnValue<S> &value) :
+ value_(value) {}
+ template <class S>
+ explicit inline ReturnValue(const ReturnValue<S>& that)
+ : value_(that.value_) {
+ TYPE_CHECK(T, S);
+ }
+
+ // Handle setters
+ template <typename S> inline void Set(const v8::Local<S> &handle) {
+ TYPE_CHECK(T, S);
+ value_.Set(handle);
+ }
+
+ template <typename S> inline void Set(const Global<S> &handle) {
+ TYPE_CHECK(T, S);
+#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
+ (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && \
+ (V8_MINOR_VERSION > 5 || (V8_MINOR_VERSION == 5 && \
+ defined(V8_BUILD_NUMBER) && V8_BUILD_NUMBER >= 8))))
+ value_.Set(handle);
+#else
+ value_.Set(*reinterpret_cast<const v8::Persistent<S>*>(&handle));
+ const_cast<Global<S> &>(handle).Reset();
+#endif
+ }
+
+ // Fast primitive setters
+ inline void Set(bool value) {
+ TYPE_CHECK(T, v8::Boolean);
+ value_.Set(value);
+ }
+
+ inline void Set(double i) {
+ TYPE_CHECK(T, v8::Number);
+ value_.Set(i);
+ }
+
+ inline void Set(int32_t i) {
+ TYPE_CHECK(T, v8::Integer);
+ value_.Set(i);
+ }
+
+ inline void Set(uint32_t i) {
+ TYPE_CHECK(T, v8::Integer);
+ value_.Set(i);
+ }
+
+ // Fast JS primitive setters
+ inline void SetNull() {
+ TYPE_CHECK(T, v8::Primitive);
+ value_.SetNull();
+ }
+
+ inline void SetUndefined() {
+ TYPE_CHECK(T, v8::Primitive);
+ value_.SetUndefined();
+ }
+
+ inline void SetEmptyString() {
+ TYPE_CHECK(T, v8::String);
+ value_.SetEmptyString();
+ }
+
+ // Convenience getter for isolate
+ inline v8::Isolate *GetIsolate() const {
+ return value_.GetIsolate();
+ }
+
+ // Pointer setter: Uncompilable to prevent inadvertent misuse.
+ template<typename S>
+ inline void Set(S *whatever) { TYPE_CHECK(S*, v8::Primitive); }
+};
+
+template<typename T>
+class FunctionCallbackInfo {
+ const v8::FunctionCallbackInfo<T> &info_;
+ const v8::Local<v8::Value> data_;
+
+ public:
+ explicit inline FunctionCallbackInfo(
+ const v8::FunctionCallbackInfo<T> &info
+ , v8::Local<v8::Value> data) :
+ info_(info)
+ , data_(data) {}
+
+ inline ReturnValue<T> GetReturnValue() const {
+ return ReturnValue<T>(info_.GetReturnValue());
+ }
+
+#if NODE_MAJOR_VERSION < 10
+ inline v8::Local<v8::Function> Callee() const { return info_.Callee(); }
+#endif
+ inline v8::Local<v8::Value> Data() const { return data_; }
+ inline v8::Local<v8::Object> Holder() const { return info_.Holder(); }
+ inline bool IsConstructCall() const { return info_.IsConstructCall(); }
+ inline int Length() const { return info_.Length(); }
+ inline v8::Local<v8::Value> operator[](int i) const { return info_[i]; }
+ inline v8::Local<v8::Object> This() const { return info_.This(); }
+ inline v8::Isolate *GetIsolate() const { return info_.GetIsolate(); }
+
+
+ protected:
+ static const int kHolderIndex = 0;
+ static const int kIsolateIndex = 1;
+ static const int kReturnValueDefaultValueIndex = 2;
+ static const int kReturnValueIndex = 3;
+ static const int kDataIndex = 4;
+ static const int kCalleeIndex = 5;
+ static const int kContextSaveIndex = 6;
+ static const int kArgsLength = 7;
+
+ private:
+ NAN_DISALLOW_ASSIGN_COPY_MOVE(FunctionCallbackInfo)
+};
+
+template<typename T>
+class PropertyCallbackInfo {
+ const v8::PropertyCallbackInfo<T> &info_;
+ const v8::Local<v8::Value> data_;
+
+ public:
+ explicit inline PropertyCallbackInfo(
+ const v8::PropertyCallbackInfo<T> &info
+ , const v8::Local<v8::Value> data) :
+ info_(info)
+ , data_(data) {}
+
+ inline v8::Isolate* GetIsolate() const { return info_.GetIsolate(); }
+ inline v8::Local<v8::Value> Data() const { return data_; }
+ inline v8::Local<v8::Object> This() const { return info_.This(); }
+ inline v8::Local<v8::Object> Holder() const { return info_.Holder(); }
+ inline ReturnValue<T> GetReturnValue() const {
+ return ReturnValue<T>(info_.GetReturnValue());
+ }
+
+ protected:
+ static const int kHolderIndex = 0;
+ static const int kIsolateIndex = 1;
+ static const int kReturnValueDefaultValueIndex = 2;
+ static const int kReturnValueIndex = 3;
+ static const int kDataIndex = 4;
+ static const int kThisIndex = 5;
+ static const int kArgsLength = 6;
+
+ private:
+ NAN_DISALLOW_ASSIGN_COPY_MOVE(PropertyCallbackInfo)
+};
+
+namespace imp {
+static
+void FunctionCallbackWrapper(const v8::FunctionCallbackInfo<v8::Value> &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ FunctionCallback callback = reinterpret_cast<FunctionCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kFunctionIndex).As<v8::External>()->Value()));
+ FunctionCallbackInfo<v8::Value>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ callback(cbinfo);
+}
+
+typedef void (*NativeFunction)(const v8::FunctionCallbackInfo<v8::Value> &);
+
+#if NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION
+static
+void GetterCallbackWrapper(
+ v8::Local<v8::Name> property
+ , const v8::PropertyCallbackInfo<v8::Value> &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Value>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ GetterCallback callback = reinterpret_cast<GetterCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kGetterIndex).As<v8::External>()->Value()));
+ callback(property.As<v8::String>(), cbinfo);
+}
+
+typedef void (*NativeGetter)
+ (v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value> &);
+
+static
+void SetterCallbackWrapper(
+ v8::Local<v8::Name> property
+ , v8::Local<v8::Value> value
+ , const v8::PropertyCallbackInfo<void> &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<void>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ SetterCallback callback = reinterpret_cast<SetterCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kSetterIndex).As<v8::External>()->Value()));
+ callback(property.As<v8::String>(), value, cbinfo);
+}
+
+typedef void (*NativeSetter)(
+ v8::Local<v8::Name>
+ , v8::Local<v8::Value>
+ , const v8::PropertyCallbackInfo<void> &);
+#else
+static
+void GetterCallbackWrapper(
+ v8::Local<v8::String> property
+ , const v8::PropertyCallbackInfo<v8::Value> &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Value>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ GetterCallback callback = reinterpret_cast<GetterCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kGetterIndex).As<v8::External>()->Value()));
+ callback(property, cbinfo);
+}
+
+typedef void (*NativeGetter)
+ (v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value> &);
+
+static
+void SetterCallbackWrapper(
+ v8::Local<v8::String> property
+ , v8::Local<v8::Value> value
+ , const v8::PropertyCallbackInfo<void> &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<void>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ SetterCallback callback = reinterpret_cast<SetterCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kSetterIndex).As<v8::External>()->Value()));
+ callback(property, value, cbinfo);
+}
+
+typedef void (*NativeSetter)(
+ v8::Local<v8::String>
+ , v8::Local<v8::Value>
+ , const v8::PropertyCallbackInfo<void> &);
+#endif
+
+#if NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION
+static
+void PropertyGetterCallbackWrapper(
+ v8::Local<v8::Name> property
+ , const v8::PropertyCallbackInfo<v8::Value> &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Value>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ PropertyGetterCallback callback = reinterpret_cast<PropertyGetterCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kPropertyGetterIndex)
+ .As<v8::External>()->Value()));
+ callback(property.As<v8::String>(), cbinfo);
+}
+
+typedef void (*NativePropertyGetter)
+ (v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value> &);
+
+static
+void PropertySetterCallbackWrapper(
+ v8::Local<v8::Name> property
+ , v8::Local<v8::Value> value
+ , const v8::PropertyCallbackInfo<v8::Value> &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Value>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ PropertySetterCallback callback = reinterpret_cast<PropertySetterCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kPropertySetterIndex)
+ .As<v8::External>()->Value()));
+ callback(property.As<v8::String>(), value, cbinfo);
+}
+
+typedef void (*NativePropertySetter)(
+ v8::Local<v8::Name>
+ , v8::Local<v8::Value>
+ , const v8::PropertyCallbackInfo<v8::Value> &);
+
+static
+void PropertyEnumeratorCallbackWrapper(
+ const v8::PropertyCallbackInfo<v8::Array> &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Array>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ PropertyEnumeratorCallback callback =
+ reinterpret_cast<PropertyEnumeratorCallback>(reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kPropertyEnumeratorIndex)
+ .As<v8::External>()->Value()));
+ callback(cbinfo);
+}
+
+typedef void (*NativePropertyEnumerator)
+ (const v8::PropertyCallbackInfo<v8::Array> &);
+
+static
+void PropertyDeleterCallbackWrapper(
+ v8::Local<v8::Name> property
+ , const v8::PropertyCallbackInfo<v8::Boolean> &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Boolean>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ PropertyDeleterCallback callback = reinterpret_cast<PropertyDeleterCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kPropertyDeleterIndex)
+ .As<v8::External>()->Value()));
+ callback(property.As<v8::String>(), cbinfo);
+}
+
+typedef void (NativePropertyDeleter)
+ (v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Boolean> &);
+
+static
+void PropertyQueryCallbackWrapper(
+ v8::Local<v8::Name> property
+ , const v8::PropertyCallbackInfo<v8::Integer> &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Integer>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ PropertyQueryCallback callback = reinterpret_cast<PropertyQueryCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kPropertyQueryIndex)
+ .As<v8::External>()->Value()));
+ callback(property.As<v8::String>(), cbinfo);
+}
+
+typedef void (*NativePropertyQuery)
+ (v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Integer> &);
+#else
+static
+void PropertyGetterCallbackWrapper(
+ v8::Local<v8::String> property
+ , const v8::PropertyCallbackInfo<v8::Value> &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Value>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ PropertyGetterCallback callback = reinterpret_cast<PropertyGetterCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kPropertyGetterIndex)
+ .As<v8::External>()->Value()));
+ callback(property, cbinfo);
+}
+
+typedef void (*NativePropertyGetter)
+ (v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value> &);
+
+static
+void PropertySetterCallbackWrapper(
+ v8::Local<v8::String> property
+ , v8::Local<v8::Value> value
+ , const v8::PropertyCallbackInfo<v8::Value> &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Value>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ PropertySetterCallback callback = reinterpret_cast<PropertySetterCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kPropertySetterIndex)
+ .As<v8::External>()->Value()));
+ callback(property, value, cbinfo);
+}
+
+typedef void (*NativePropertySetter)(
+ v8::Local<v8::String>
+ , v8::Local<v8::Value>
+ , const v8::PropertyCallbackInfo<v8::Value> &);
+
+static
+void PropertyEnumeratorCallbackWrapper(
+ const v8::PropertyCallbackInfo<v8::Array> &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Array>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ PropertyEnumeratorCallback callback =
+ reinterpret_cast<PropertyEnumeratorCallback>(reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kPropertyEnumeratorIndex)
+ .As<v8::External>()->Value()));
+ callback(cbinfo);
+}
+
+typedef void (*NativePropertyEnumerator)
+ (const v8::PropertyCallbackInfo<v8::Array> &);
+
+static
+void PropertyDeleterCallbackWrapper(
+ v8::Local<v8::String> property
+ , const v8::PropertyCallbackInfo<v8::Boolean> &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Boolean>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ PropertyDeleterCallback callback = reinterpret_cast<PropertyDeleterCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kPropertyDeleterIndex)
+ .As<v8::External>()->Value()));
+ callback(property, cbinfo);
+}
+
+typedef void (NativePropertyDeleter)
+ (v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Boolean> &);
+
+static
+void PropertyQueryCallbackWrapper(
+ v8::Local<v8::String> property
+ , const v8::PropertyCallbackInfo<v8::Integer> &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Integer>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ PropertyQueryCallback callback = reinterpret_cast<PropertyQueryCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kPropertyQueryIndex)
+ .As<v8::External>()->Value()));
+ callback(property, cbinfo);
+}
+
+typedef void (*NativePropertyQuery)
+ (v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Integer> &);
+#endif
+
+static
+void IndexGetterCallbackWrapper(
+ uint32_t index, const v8::PropertyCallbackInfo<v8::Value> &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Value>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ IndexGetterCallback callback = reinterpret_cast<IndexGetterCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kIndexPropertyGetterIndex)
+ .As<v8::External>()->Value()));
+ callback(index, cbinfo);
+}
+
+typedef void (*NativeIndexGetter)
+ (uint32_t, const v8::PropertyCallbackInfo<v8::Value> &);
+
+static
+void IndexSetterCallbackWrapper(
+ uint32_t index
+ , v8::Local<v8::Value> value
+ , const v8::PropertyCallbackInfo<v8::Value> &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Value>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ IndexSetterCallback callback = reinterpret_cast<IndexSetterCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kIndexPropertySetterIndex)
+ .As<v8::External>()->Value()));
+ callback(index, value, cbinfo);
+}
+
+typedef void (*NativeIndexSetter)(
+ uint32_t
+ , v8::Local<v8::Value>
+ , const v8::PropertyCallbackInfo<v8::Value> &);
+
+static
+void IndexEnumeratorCallbackWrapper(
+ const v8::PropertyCallbackInfo<v8::Array> &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Array>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ IndexEnumeratorCallback callback = reinterpret_cast<IndexEnumeratorCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(
+ kIndexPropertyEnumeratorIndex).As<v8::External>()->Value()));
+ callback(cbinfo);
+}
+
+typedef void (*NativeIndexEnumerator)
+ (const v8::PropertyCallbackInfo<v8::Array> &);
+
+static
+void IndexDeleterCallbackWrapper(
+ uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean> &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Boolean>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ IndexDeleterCallback callback = reinterpret_cast<IndexDeleterCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kIndexPropertyDeleterIndex)
+ .As<v8::External>()->Value()));
+ callback(index, cbinfo);
+}
+
+typedef void (*NativeIndexDeleter)
+ (uint32_t, const v8::PropertyCallbackInfo<v8::Boolean> &);
+
+static
+void IndexQueryCallbackWrapper(
+ uint32_t index, const v8::PropertyCallbackInfo<v8::Integer> &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Integer>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ IndexQueryCallback callback = reinterpret_cast<IndexQueryCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kIndexPropertyQueryIndex)
+ .As<v8::External>()->Value()));
+ callback(index, cbinfo);
+}
+
+typedef void (*NativeIndexQuery)
+ (uint32_t, const v8::PropertyCallbackInfo<v8::Integer> &);
+} // end of namespace imp
+
+#endif // NAN_CALLBACKS_12_INL_H_
diff --git a/node_modules/nan/nan_callbacks_pre_12_inl.h b/node_modules/nan/nan_callbacks_pre_12_inl.h
new file mode 100644
index 0000000..c9ba499
--- /dev/null
+++ b/node_modules/nan/nan_callbacks_pre_12_inl.h
@@ -0,0 +1,520 @@
+/*********************************************************************
+ * NAN - Native Abstractions for Node.js
+ *
+ * Copyright (c) 2018 NAN contributors
+ *
+ * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
+ ********************************************************************/
+
+#ifndef NAN_CALLBACKS_PRE_12_INL_H_
+#define NAN_CALLBACKS_PRE_12_INL_H_
+
+namespace imp {
+template<typename T> class ReturnValueImp;
+} // end of namespace imp
+
+template<typename T>
+class ReturnValue {
+ v8::Isolate *isolate_;
+ v8::Persistent<T> *value_;
+ friend class imp::ReturnValueImp<T>;
+
+ public:
+ template <class S>
+ explicit inline ReturnValue(v8::Isolate *isolate, v8::Persistent<S> *p) :
+ isolate_(isolate), value_(p) {}
+ template <class S>
+ explicit inline ReturnValue(const ReturnValue<S>& that)
+ : isolate_(that.isolate_), value_(that.value_) {
+ TYPE_CHECK(T, S);
+ }
+
+ // Handle setters
+ template <typename S> inline void Set(const v8::Local<S> &handle) {
+ TYPE_CHECK(T, S);
+ value_->Dispose();
+ *value_ = v8::Persistent<T>::New(handle);
+ }
+
+ template <typename S> inline void Set(const Global<S> &handle) {
+ TYPE_CHECK(T, S);
+ value_->Dispose();
+ *value_ = v8::Persistent<T>::New(handle.persistent);
+ const_cast<Global<S> &>(handle).Reset();
+ }
+
+ // Fast primitive setters
+ inline void Set(bool value) {
+ v8::HandleScope scope;
+
+ TYPE_CHECK(T, v8::Boolean);
+ value_->Dispose();
+ *value_ = v8::Persistent<T>::New(v8::Boolean::New(value));
+ }
+
+ inline void Set(double i) {
+ v8::HandleScope scope;
+
+ TYPE_CHECK(T, v8::Number);
+ value_->Dispose();
+ *value_ = v8::Persistent<T>::New(v8::Number::New(i));
+ }
+
+ inline void Set(int32_t i) {
+ v8::HandleScope scope;
+
+ TYPE_CHECK(T, v8::Integer);
+ value_->Dispose();
+ *value_ = v8::Persistent<T>::New(v8::Int32::New(i));
+ }
+
+ inline void Set(uint32_t i) {
+ v8::HandleScope scope;
+
+ TYPE_CHECK(T, v8::Integer);
+ value_->Dispose();
+ *value_ = v8::Persistent<T>::New(v8::Uint32::NewFromUnsigned(i));
+ }
+
+ // Fast JS primitive setters
+ inline void SetNull() {
+ v8::HandleScope scope;
+
+ TYPE_CHECK(T, v8::Primitive);
+ value_->Dispose();
+ *value_ = v8::Persistent<T>::New(v8::Null());
+ }
+
+ inline void SetUndefined() {
+ v8::HandleScope scope;
+
+ TYPE_CHECK(T, v8::Primitive);
+ value_->Dispose();
+ *value_ = v8::Persistent<T>::New(v8::Undefined());
+ }
+
+ inline void SetEmptyString() {
+ v8::HandleScope scope;
+
+ TYPE_CHECK(T, v8::String);
+ value_->Dispose();
+ *value_ = v8::Persistent<T>::New(v8::String::Empty());
+ }
+
+ // Convenience getter for isolate
+ inline v8::Isolate *GetIsolate() const {
+ return isolate_;
+ }
+
+ // Pointer setter: Uncompilable to prevent inadvertent misuse.
+ template<typename S>
+ inline void Set(S *whatever) { TYPE_CHECK(S*, v8::Primitive); }
+};
+
+template<typename T>
+class FunctionCallbackInfo {
+ const v8::Arguments &args_;
+ v8::Local<v8::Value> data_;
+ ReturnValue<T> return_value_;
+ v8::Persistent<T> retval_;
+
+ public:
+ explicit inline FunctionCallbackInfo(
+ const v8::Arguments &args
+ , v8::Local<v8::Value> data) :
+ args_(args)
+ , data_(data)
+ , return_value_(args.GetIsolate(), &retval_)
+ , retval_(v8::Persistent<T>::New(v8::Undefined())) {}
+
+ inline ~FunctionCallbackInfo() {
+ retval_.Dispose();
+ retval_.Clear();
+ }
+
+ inline ReturnValue<T> GetReturnValue() const {
+ return ReturnValue<T>(return_value_);
+ }
+
+ inline v8::Local<v8::Function> Callee() const { return args_.Callee(); }
+ inline v8::Local<v8::Value> Data() const { return data_; }
+ inline v8::Local<v8::Object> Holder() const { return args_.Holder(); }
+ inline bool IsConstructCall() const { return args_.IsConstructCall(); }
+ inline int Length() const { return args_.Length(); }
+ inline v8::Local<v8::Value> operator[](int i) const { return args_[i]; }
+ inline v8::Local<v8::Object> This() const { return args_.This(); }
+ inline v8::Isolate *GetIsolate() const { return args_.GetIsolate(); }
+
+
+ protected:
+ static const int kHolderIndex = 0;
+ static const int kIsolateIndex = 1;
+ static const int kReturnValueDefaultValueIndex = 2;
+ static const int kReturnValueIndex = 3;
+ static const int kDataIndex = 4;
+ static const int kCalleeIndex = 5;
+ static const int kContextSaveIndex = 6;
+ static const int kArgsLength = 7;
+
+ private:
+ NAN_DISALLOW_ASSIGN_COPY_MOVE(FunctionCallbackInfo)
+};
+
+template<typename T>
+class PropertyCallbackInfoBase {
+ const v8::AccessorInfo &info_;
+ const v8::Local<v8::Value> data_;
+
+ public:
+ explicit inline PropertyCallbackInfoBase(
+ const v8::AccessorInfo &info
+ , const v8::Local<v8::Value> data) :
+ info_(info)
+ , data_(data) {}
+
+ inline v8::Isolate* GetIsolate() const { return info_.GetIsolate(); }
+ inline v8::Local<v8::Value> Data() const { return data_; }
+ inline v8::Local<v8::Object> This() const { return info_.This(); }
+ inline v8::Local<v8::Object> Holder() const { return info_.Holder(); }
+
+ protected:
+ static const int kHolderIndex = 0;
+ static const int kIsolateIndex = 1;
+ static const int kReturnValueDefaultValueIndex = 2;
+ static const int kReturnValueIndex = 3;
+ static const int kDataIndex = 4;
+ static const int kThisIndex = 5;
+ static const int kArgsLength = 6;
+
+ private:
+ NAN_DISALLOW_ASSIGN_COPY_MOVE(PropertyCallbackInfoBase)
+};
+
+template<typename T>
+class PropertyCallbackInfo : public PropertyCallbackInfoBase<T> {
+ ReturnValue<T> return_value_;
+ v8::Persistent<T> retval_;
+
+ public:
+ explicit inline PropertyCallbackInfo(
+ const v8::AccessorInfo &info
+ , const v8::Local<v8::Value> data) :
+ PropertyCallbackInfoBase<T>(info, data)
+ , return_value_(info.GetIsolate(), &retval_)
+ , retval_(v8::Persistent<T>::New(v8::Undefined())) {}
+
+ inline ~PropertyCallbackInfo() {
+ retval_.Dispose();
+ retval_.Clear();
+ }
+
+ inline ReturnValue<T> GetReturnValue() const { return return_value_; }
+};
+
+template<>
+class PropertyCallbackInfo<v8::Array> :
+ public PropertyCallbackInfoBase<v8::Array> {
+ ReturnValue<v8::Array> return_value_;
+ v8::Persistent<v8::Array> retval_;
+
+ public:
+ explicit inline PropertyCallbackInfo(
+ const v8::AccessorInfo &info
+ , const v8::Local<v8::Value> data) :
+ PropertyCallbackInfoBase<v8::Array>(info, data)
+ , return_value_(info.GetIsolate(), &retval_)
+ , retval_(v8::Persistent<v8::Array>::New(v8::Local<v8::Array>())) {}
+
+ inline ~PropertyCallbackInfo() {
+ retval_.Dispose();
+ retval_.Clear();
+ }
+
+ inline ReturnValue<v8::Array> GetReturnValue() const {
+ return return_value_;
+ }
+};
+
+template<>
+class PropertyCallbackInfo<v8::Boolean> :
+ public PropertyCallbackInfoBase<v8::Boolean> {
+ ReturnValue<v8::Boolean> return_value_;
+ v8::Persistent<v8::Boolean> retval_;
+
+ public:
+ explicit inline PropertyCallbackInfo(
+ const v8::AccessorInfo &info
+ , const v8::Local<v8::Value> data) :
+ PropertyCallbackInfoBase<v8::Boolean>(info, data)
+ , return_value_(info.GetIsolate(), &retval_)
+ , retval_(v8::Persistent<v8::Boolean>::New(v8::Local<v8::Boolean>())) {}
+
+ inline ~PropertyCallbackInfo() {
+ retval_.Dispose();
+ retval_.Clear();
+ }
+
+ inline ReturnValue<v8::Boolean> GetReturnValue() const {
+ return return_value_;
+ }
+};
+
+template<>
+class PropertyCallbackInfo<v8::Integer> :
+ public PropertyCallbackInfoBase<v8::Integer> {
+ ReturnValue<v8::Integer> return_value_;
+ v8::Persistent<v8::Integer> retval_;
+
+ public:
+ explicit inline PropertyCallbackInfo(
+ const v8::AccessorInfo &info
+ , const v8::Local<v8::Value> data) :
+ PropertyCallbackInfoBase<v8::Integer>(info, data)
+ , return_value_(info.GetIsolate(), &retval_)
+ , retval_(v8::Persistent<v8::Integer>::New(v8::Local<v8::Integer>())) {}
+
+ inline ~PropertyCallbackInfo() {
+ retval_.Dispose();
+ retval_.Clear();
+ }
+
+ inline ReturnValue<v8::Integer> GetReturnValue() const {
+ return return_value_;
+ }
+};
+
+namespace imp {
+template<typename T>
+class ReturnValueImp : public ReturnValue<T> {
+ public:
+ explicit ReturnValueImp(ReturnValue<T> that) :
+ ReturnValue<T>(that) {}
+ inline v8::Handle<T> Value() {
+ return *ReturnValue<T>::value_;
+ }
+};
+
+static
+v8::Handle<v8::Value> FunctionCallbackWrapper(const v8::Arguments &args) {
+ v8::Local<v8::Object> obj = args.Data().As<v8::Object>();
+ FunctionCallback callback = reinterpret_cast<FunctionCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kFunctionIndex).As<v8::External>()->Value()));
+ FunctionCallbackInfo<v8::Value>
+ cbinfo(args, obj->GetInternalField(kDataIndex));
+ callback(cbinfo);
+ return ReturnValueImp<v8::Value>(cbinfo.GetReturnValue()).Value();
+}
+
+typedef v8::Handle<v8::Value> (*NativeFunction)(const v8::Arguments &);
+
+static
+v8::Handle<v8::Value> GetterCallbackWrapper(
+ v8::Local<v8::String> property, const v8::AccessorInfo &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Value>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ GetterCallback callback = reinterpret_cast<GetterCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kGetterIndex).As<v8::External>()->Value()));
+ callback(property, cbinfo);
+ return ReturnValueImp<v8::Value>(cbinfo.GetReturnValue()).Value();
+}
+
+typedef v8::Handle<v8::Value> (*NativeGetter)
+ (v8::Local<v8::String>, const v8::AccessorInfo &);
+
+static
+void SetterCallbackWrapper(
+ v8::Local<v8::String> property
+ , v8::Local<v8::Value> value
+ , const v8::AccessorInfo &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<void>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ SetterCallback callback = reinterpret_cast<SetterCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kSetterIndex).As<v8::External>()->Value()));
+ callback(property, value, cbinfo);
+}
+
+typedef void (*NativeSetter)
+ (v8::Local<v8::String>, v8::Local<v8::Value>, const v8::AccessorInfo &);
+
+static
+v8::Handle<v8::Value> PropertyGetterCallbackWrapper(
+ v8::Local<v8::String> property, const v8::AccessorInfo &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Value>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ PropertyGetterCallback callback = reinterpret_cast<PropertyGetterCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kPropertyGetterIndex)
+ .As<v8::External>()->Value()));
+ callback(property, cbinfo);
+ return ReturnValueImp<v8::Value>(cbinfo.GetReturnValue()).Value();
+}
+
+typedef v8::Handle<v8::Value> (*NativePropertyGetter)
+ (v8::Local<v8::String>, const v8::AccessorInfo &);
+
+static
+v8::Handle<v8::Value> PropertySetterCallbackWrapper(
+ v8::Local<v8::String> property
+ , v8::Local<v8::Value> value
+ , const v8::AccessorInfo &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Value>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ PropertySetterCallback callback = reinterpret_cast<PropertySetterCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kPropertySetterIndex)
+ .As<v8::External>()->Value()));
+ callback(property, value, cbinfo);
+ return ReturnValueImp<v8::Value>(cbinfo.GetReturnValue()).Value();
+}
+
+typedef v8::Handle<v8::Value> (*NativePropertySetter)
+ (v8::Local<v8::String>, v8::Local<v8::Value>, const v8::AccessorInfo &);
+
+static
+v8::Handle<v8::Array> PropertyEnumeratorCallbackWrapper(
+ const v8::AccessorInfo &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Array>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ PropertyEnumeratorCallback callback =
+ reinterpret_cast<PropertyEnumeratorCallback>(reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kPropertyEnumeratorIndex)
+ .As<v8::External>()->Value()));
+ callback(cbinfo);
+ return ReturnValueImp<v8::Array>(cbinfo.GetReturnValue()).Value();
+}
+
+typedef v8::Handle<v8::Array> (*NativePropertyEnumerator)
+ (const v8::AccessorInfo &);
+
+static
+v8::Handle<v8::Boolean> PropertyDeleterCallbackWrapper(
+ v8::Local<v8::String> property
+ , const v8::AccessorInfo &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Boolean>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ PropertyDeleterCallback callback = reinterpret_cast<PropertyDeleterCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kPropertyDeleterIndex)
+ .As<v8::External>()->Value()));
+ callback(property, cbinfo);
+ return ReturnValueImp<v8::Boolean>(cbinfo.GetReturnValue()).Value();
+}
+
+typedef v8::Handle<v8::Boolean> (NativePropertyDeleter)
+ (v8::Local<v8::String>, const v8::AccessorInfo &);
+
+static
+v8::Handle<v8::Integer> PropertyQueryCallbackWrapper(
+ v8::Local<v8::String> property, const v8::AccessorInfo &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Integer>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ PropertyQueryCallback callback = reinterpret_cast<PropertyQueryCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kPropertyQueryIndex)
+ .As<v8::External>()->Value()));
+ callback(property, cbinfo);
+ return ReturnValueImp<v8::Integer>(cbinfo.GetReturnValue()).Value();
+}
+
+typedef v8::Handle<v8::Integer> (*NativePropertyQuery)
+ (v8::Local<v8::String>, const v8::AccessorInfo &);
+
+static
+v8::Handle<v8::Value> IndexGetterCallbackWrapper(
+ uint32_t index, const v8::AccessorInfo &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Value>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ IndexGetterCallback callback = reinterpret_cast<IndexGetterCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kIndexPropertyGetterIndex)
+ .As<v8::External>()->Value()));
+ callback(index, cbinfo);
+ return ReturnValueImp<v8::Value>(cbinfo.GetReturnValue()).Value();
+}
+
+typedef v8::Handle<v8::Value> (*NativeIndexGetter)
+ (uint32_t, const v8::AccessorInfo &);
+
+static
+v8::Handle<v8::Value> IndexSetterCallbackWrapper(
+ uint32_t index
+ , v8::Local<v8::Value> value
+ , const v8::AccessorInfo &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Value>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ IndexSetterCallback callback = reinterpret_cast<IndexSetterCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kIndexPropertySetterIndex)
+ .As<v8::External>()->Value()));
+ callback(index, value, cbinfo);
+ return ReturnValueImp<v8::Value>(cbinfo.GetReturnValue()).Value();
+}
+
+typedef v8::Handle<v8::Value> (*NativeIndexSetter)
+ (uint32_t, v8::Local<v8::Value>, const v8::AccessorInfo &);
+
+static
+v8::Handle<v8::Array> IndexEnumeratorCallbackWrapper(
+ const v8::AccessorInfo &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Array>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ IndexEnumeratorCallback callback = reinterpret_cast<IndexEnumeratorCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kIndexPropertyEnumeratorIndex)
+ .As<v8::External>()->Value()));
+ callback(cbinfo);
+ return ReturnValueImp<v8::Array>(cbinfo.GetReturnValue()).Value();
+}
+
+typedef v8::Handle<v8::Array> (*NativeIndexEnumerator)
+ (const v8::AccessorInfo &);
+
+static
+v8::Handle<v8::Boolean> IndexDeleterCallbackWrapper(
+ uint32_t index, const v8::AccessorInfo &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Boolean>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ IndexDeleterCallback callback = reinterpret_cast<IndexDeleterCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kIndexPropertyDeleterIndex)
+ .As<v8::External>()->Value()));
+ callback(index, cbinfo);
+ return ReturnValueImp<v8::Boolean>(cbinfo.GetReturnValue()).Value();
+}
+
+typedef v8::Handle<v8::Boolean> (*NativeIndexDeleter)
+ (uint32_t, const v8::AccessorInfo &);
+
+static
+v8::Handle<v8::Integer> IndexQueryCallbackWrapper(
+ uint32_t index, const v8::AccessorInfo &info) {
+ v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
+ PropertyCallbackInfo<v8::Integer>
+ cbinfo(info, obj->GetInternalField(kDataIndex));
+ IndexQueryCallback callback = reinterpret_cast<IndexQueryCallback>(
+ reinterpret_cast<intptr_t>(
+ obj->GetInternalField(kIndexPropertyQueryIndex)
+ .As<v8::External>()->Value()));
+ callback(index, cbinfo);
+ return ReturnValueImp<v8::Integer>(cbinfo.GetReturnValue()).Value();
+}
+
+typedef v8::Handle<v8::Integer> (*NativeIndexQuery)
+ (uint32_t, const v8::AccessorInfo &);
+} // end of namespace imp
+
+#endif // NAN_CALLBACKS_PRE_12_INL_H_
diff --git a/node_modules/nan/nan_converters.h b/node_modules/nan/nan_converters.h
new file mode 100644
index 0000000..c0b3272
--- /dev/null
+++ b/node_modules/nan/nan_converters.h
@@ -0,0 +1,72 @@
+/*********************************************************************
+ * NAN - Native Abstractions for Node.js
+ *
+ * Copyright (c) 2018 NAN contributors
+ *
+ * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
+ ********************************************************************/
+
+#ifndef NAN_CONVERTERS_H_
+#define NAN_CONVERTERS_H_
+
+namespace imp {
+template<typename T> struct ToFactoryBase {
+ typedef MaybeLocal<T> return_t;
+};
+template<typename T> struct ValueFactoryBase { typedef Maybe<T> return_t; };
+
+template<typename T> struct ToFactory;
+
+template<>
+struct ToFactory<v8::Function> : ToFactoryBase<v8::Function> {
+ static inline return_t convert(v8::Local<v8::Value> val) {
+ if (val.IsEmpty() || !val->IsFunction()) return MaybeLocal<v8::Function>();
+ return MaybeLocal<v8::Function>(val.As<v8::Function>());
+ }
+};
+
+#define X(TYPE) \
+ template<> \
+ struct ToFactory<v8::TYPE> : ToFactoryBase<v8::TYPE> { \
+ static inline return_t convert(v8::Local<v8::Value> val); \
+ };
+
+X(Boolean)
+X(Number)
+X(String)
+X(Object)
+X(Integer)
+X(Uint32)
+X(Int32)
+
+#undef X
+
+#define X(TYPE) \
+ template<> \
+ struct ToFactory<TYPE> : ValueFactoryBase<TYPE> { \
+ static inline return_t convert(v8::Local<v8::Value> val); \
+ };
+
+X(bool)
+X(double)
+X(int64_t)
+X(uint32_t)
+X(int32_t)
+
+#undef X
+} // end of namespace imp
+
+template<typename T>
+inline
+typename imp::ToFactory<T>::return_t To(v8::Local<v8::Value> val) {
+ return imp::ToFactory<T>::convert(val);
+}
+
+#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
+ (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
+# include "nan_converters_43_inl.h"
+#else
+# include "nan_converters_pre_43_inl.h"
+#endif
+
+#endif // NAN_CONVERTERS_H_
diff --git a/node_modules/nan/nan_converters_43_inl.h b/node_modules/nan/nan_converters_43_inl.h
new file mode 100644
index 0000000..41b72de
--- /dev/null
+++ b/node_modules/nan/nan_converters_43_inl.h
@@ -0,0 +1,68 @@
+/*********************************************************************
+ * NAN - Native Abstractions for Node.js
+ *
+ * Copyright (c) 2018 NAN contributors
+ *
+ * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
+ ********************************************************************/
+
+#ifndef NAN_CONVERTERS_43_INL_H_
+#define NAN_CONVERTERS_43_INL_H_
+
+#define X(TYPE) \
+imp::ToFactory<v8::TYPE>::return_t \
+imp::ToFactory<v8::TYPE>::convert(v8::Local<v8::Value> val) { \
+ v8::Isolate *isolate = v8::Isolate::GetCurrent(); \
+ v8::EscapableHandleScope scope(isolate); \
+ return scope.Escape( \
+ val->To ## TYPE(isolate->GetCurrentContext()) \
+ .FromMaybe(v8::Local<v8::TYPE>())); \
+}
+
+X(Number)
+X(String)
+X(Object)
+X(Integer)
+X(Uint32)
+X(Int32)
+// V8 <= 7.0
+#if V8_MAJOR_VERSION < 7 || (V8_MAJOR_VERSION == 7 && V8_MINOR_VERSION == 0)
+X(Boolean)
+#else
+imp::ToFactory<v8::Boolean>::return_t \
+imp::ToFactory<v8::Boolean>::convert(v8::Local<v8::Value> val) { \
+ v8::Isolate *isolate = v8::Isolate::GetCurrent(); \
+ v8::EscapableHandleScope scope(isolate); \
+ return scope.Escape(val->ToBoolean(isolate)); \
+}
+#endif
+
+#undef X
+
+#define X(TYPE, NAME) \
+imp::ToFactory<TYPE>::return_t \
+imp::ToFactory<TYPE>::convert(v8::Local<v8::Value> val) { \
+ v8::Isolate *isolate = v8::Isolate::GetCurrent(); \
+ v8::HandleScope scope(isolate); \
+ return val->NAME ## Value(isolate->GetCurrentContext()); \
+}
+
+X(double, Number)
+X(int64_t, Integer)
+X(uint32_t, Uint32)
+X(int32_t, Int32)
+// V8 <= 7.0
+#if V8_MAJOR_VERSION < 7 || (V8_MAJOR_VERSION == 7 && V8_MINOR_VERSION == 0)
+X(bool, Boolean)
+#else
+imp::ToFactory<bool>::return_t \
+imp::ToFactory<bool>::convert(v8::Local<v8::Value> val) { \
+ v8::Isolate *isolate = v8::Isolate::GetCurrent(); \
+ v8::HandleScope scope(isolate); \
+ return Just<bool>(val->BooleanValue(isolate)); \
+}
+#endif
+
+#undef X
+
+#endif // NAN_CONVERTERS_43_INL_H_
diff --git a/node_modules/nan/nan_converters_pre_43_inl.h b/node_modules/nan/nan_converters_pre_43_inl.h
new file mode 100644
index 0000000..ae0518a
--- /dev/null
+++ b/node_modules/nan/nan_converters_pre_43_inl.h
@@ -0,0 +1,42 @@
+/*********************************************************************
+ * NAN - Native Abstractions for Node.js
+ *
+ * Copyright (c) 2018 NAN contributors
+ *
+ * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
+ ********************************************************************/
+
+#ifndef NAN_CONVERTERS_PRE_43_INL_H_
+#define NAN_CONVERTERS_PRE_43_INL_H_
+
+#define X(TYPE) \
+imp::ToFactory<v8::TYPE>::return_t \
+imp::ToFactory<v8::TYPE>::convert(v8::Local<v8::Value> val) { \
+ return val->To ## TYPE(); \
+}
+
+X(Boolean)
+X(Number)
+X(String)
+X(Object)
+X(Integer)
+X(Uint32)
+X(Int32)
+
+#undef X
+
+#define X(TYPE, NAME) \
+imp::ToFactory<TYPE>::return_t \
+imp::ToFactory<TYPE>::convert(v8::Local<v8::Value> val) { \
+ return Just(val->NAME ## Value()); \
+}
+
+X(bool, Boolean)
+X(double, Number)
+X(int64_t, Integer)
+X(uint32_t, Uint32)
+X(int32_t, Int32)
+
+#undef X
+
+#endif // NAN_CONVERTERS_PRE_43_INL_H_
diff --git a/node_modules/nan/nan_define_own_property_helper.h b/node_modules/nan/nan_define_own_property_helper.h
new file mode 100644
index 0000000..d710ef2
--- /dev/null
+++ b/node_modules/nan/nan_define_own_property_helper.h
@@ -0,0 +1,29 @@
+/*********************************************************************
+ * NAN - Native Abstractions for Node.js
+ *
+ * Copyright (c) 2018 NAN contributors
+ *
+ * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
+ ********************************************************************/
+
+#ifndef NAN_DEFINE_OWN_PROPERTY_HELPER_H_
+#define NAN_DEFINE_OWN_PROPERTY_HELPER_H_
+
+namespace imp {
+
+inline Maybe<bool> DefineOwnPropertyHelper(
+ v8::PropertyAttribute current
+ , v8::Handle<v8::Object> obj
+ , v8::Handle<v8::String> key
+ , v8::Handle<v8::Value> value
+ , v8::PropertyAttribute attribs = v8::None) {
+ return !(current & v8::DontDelete) || // configurable OR
+ (!(current & v8::ReadOnly) && // writable AND
+ !((attribs ^ current) & ~v8::ReadOnly)) // same excluding RO
+ ? Just<bool>(obj->ForceSet(key, value, attribs))
+ : Nothing<bool>();
+}
+
+} // end of namespace imp
+
+#endif // NAN_DEFINE_OWN_PROPERTY_HELPER_H_
diff --git a/node_modules/nan/nan_implementation_12_inl.h b/node_modules/nan/nan_implementation_12_inl.h
new file mode 100644
index 0000000..255293a
--- /dev/null
+++ b/node_modules/nan/nan_implementation_12_inl.h
@@ -0,0 +1,430 @@
+/*********************************************************************
+ * NAN - Native Abstractions for Node.js
+ *
+ * Copyright (c) 2018 NAN contributors
+ *
+ * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
+ ********************************************************************/
+
+#ifndef NAN_IMPLEMENTATION_12_INL_H_
+#define NAN_IMPLEMENTATION_12_INL_H_
+//==============================================================================
+// node v0.11 implementation
+//==============================================================================
+
+namespace imp {
+
+//=== Array ====================================================================
+
+Factory<v8::Array>::return_t
+Factory<v8::Array>::New() {
+ return v8::Array::New(v8::Isolate::GetCurrent());
+}
+
+Factory<v8::Array>::return_t
+Factory<v8::Array>::New(int length) {
+ return v8::Array::New(v8::Isolate::GetCurrent(), length);
+}
+
+//=== Boolean ==================================================================
+
+Factory<v8::Boolean>::return_t
+Factory<v8::Boolean>::New(bool value) {
+ return v8::Boolean::New(v8::Isolate::GetCurrent(), value);
+}
+
+//=== Boolean Object ===========================================================
+
+Factory<v8::BooleanObject>::return_t
+Factory<v8::BooleanObject>::New(bool value) {
+#if (NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION)
+ return v8::BooleanObject::New(
+ v8::Isolate::GetCurrent(), value).As<v8::BooleanObject>();
+#else
+ return v8::BooleanObject::New(value).As<v8::BooleanObject>();
+#endif
+}
+
+//=== Context ==================================================================
+
+Factory<v8::Context>::return_t
+Factory<v8::Context>::New( v8::ExtensionConfiguration* extensions
+ , v8::Local<v8::ObjectTemplate> tmpl
+ , v8::Local<v8::Value> obj) {
+ return v8::Context::New(v8::Isolate::GetCurrent(), extensions, tmpl, obj);
+}
+
+//=== Date =====================================================================
+
+#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
+ (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
+Factory<v8::Date>::return_t
+Factory<v8::Date>::New(double value) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ return scope.Escape(v8::Date::New(isolate->GetCurrentContext(), value)
+ .FromMaybe(v8::Local<v8::Value>()).As<v8::Date>());
+}
+#else
+Factory<v8::Date>::return_t
+Factory<v8::Date>::New(double value) {
+ return v8::Date::New(v8::Isolate::GetCurrent(), value).As<v8::Date>();
+}
+#endif
+
+//=== External =================================================================
+
+Factory<v8::External>::return_t
+Factory<v8::External>::New(void * value) {
+ return v8::External::New(v8::Isolate::GetCurrent(), value);
+}
+
+//=== Function =================================================================
+
+Factory<v8::Function>::return_t
+Factory<v8::Function>::New( FunctionCallback callback
+ , v8::Local<v8::Value> data) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ v8::Local<v8::ObjectTemplate> tpl = v8::ObjectTemplate::New(isolate);
+ tpl->SetInternalFieldCount(imp::kFunctionFieldCount);
+ v8::Local<v8::Object> obj = NewInstance(tpl).ToLocalChecked();
+
+ obj->SetInternalField(
+ imp::kFunctionIndex
+ , v8::External::New(isolate, reinterpret_cast<void *>(callback)));
+
+ v8::Local<v8::Value> val = v8::Local<v8::Value>::New(isolate, data);
+
+ if (!val.IsEmpty()) {
+ obj->SetInternalField(imp::kDataIndex, val);
+ }
+
+#if NODE_MAJOR_VERSION >= 10
+ v8::Local<v8::Context> context = isolate->GetCurrentContext();
+ v8::Local<v8::Function> function =
+ v8::Function::New(context, imp::FunctionCallbackWrapper, obj)
+ .ToLocalChecked();
+#else
+ v8::Local<v8::Function> function =
+ v8::Function::New(isolate, imp::FunctionCallbackWrapper, obj);
+#endif
+
+ return scope.Escape(function);
+}
+
+//=== Function Template ========================================================
+
+Factory<v8::FunctionTemplate>::return_t
+Factory<v8::FunctionTemplate>::New( FunctionCallback callback
+ , v8::Local<v8::Value> data
+ , v8::Local<v8::Signature> signature) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ if (callback) {
+ v8::EscapableHandleScope scope(isolate);
+ v8::Local<v8::ObjectTemplate> tpl = v8::ObjectTemplate::New(isolate);
+ tpl->SetInternalFieldCount(imp::kFunctionFieldCount);
+ v8::Local<v8::Object> obj = NewInstance(tpl).ToLocalChecked();
+
+ obj->SetInternalField(
+ imp::kFunctionIndex
+ , v8::External::New(isolate, reinterpret_cast<void *>(callback)));
+ v8::Local<v8::Value> val = v8::Local<v8::Value>::New(isolate, data);
+
+ if (!val.IsEmpty()) {
+ obj->SetInternalField(imp::kDataIndex, val);
+ }
+
+ return scope.Escape(v8::FunctionTemplate::New( isolate
+ , imp::FunctionCallbackWrapper
+ , obj
+ , signature));
+ } else {
+ return v8::FunctionTemplate::New(isolate, 0, data, signature);
+ }
+}
+
+//=== Number ===================================================================
+
+Factory<v8::Number>::return_t
+Factory<v8::Number>::New(double value) {
+ return v8::Number::New(v8::Isolate::GetCurrent(), value);
+}
+
+//=== Number Object ============================================================
+
+Factory<v8::NumberObject>::return_t
+Factory<v8::NumberObject>::New(double value) {
+ return v8::NumberObject::New( v8::Isolate::GetCurrent()
+ , value).As<v8::NumberObject>();
+}
+
+//=== Integer, Int32 and Uint32 ================================================
+
+template <typename T>
+typename IntegerFactory<T>::return_t
+IntegerFactory<T>::New(int32_t value) {
+ return To<T>(T::New(v8::Isolate::GetCurrent(), value));
+}
+
+template <typename T>
+typename IntegerFactory<T>::return_t
+IntegerFactory<T>::New(uint32_t value) {
+ return To<T>(T::NewFromUnsigned(v8::Isolate::GetCurrent(), value));
+}
+
+Factory<v8::Uint32>::return_t
+Factory<v8::Uint32>::New(int32_t value) {
+ return To<v8::Uint32>(
+ v8::Uint32::NewFromUnsigned(v8::Isolate::GetCurrent(), value));
+}
+
+Factory<v8::Uint32>::return_t
+Factory<v8::Uint32>::New(uint32_t value) {
+ return To<v8::Uint32>(
+ v8::Uint32::NewFromUnsigned(v8::Isolate::GetCurrent(), value));
+}
+
+//=== Object ===================================================================
+
+Factory<v8::Object>::return_t
+Factory<v8::Object>::New() {
+ return v8::Object::New(v8::Isolate::GetCurrent());
+}
+
+//=== Object Template ==========================================================
+
+Factory<v8::ObjectTemplate>::return_t
+Factory<v8::ObjectTemplate>::New() {
+ return v8::ObjectTemplate::New(v8::Isolate::GetCurrent());
+}
+
+//=== RegExp ===================================================================
+
+#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
+ (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
+Factory<v8::RegExp>::return_t
+Factory<v8::RegExp>::New(
+ v8::Local<v8::String> pattern
+ , v8::RegExp::Flags flags) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ return scope.Escape(
+ v8::RegExp::New(isolate->GetCurrentContext(), pattern, flags)
+ .FromMaybe(v8::Local<v8::RegExp>()));
+}
+#else
+Factory<v8::RegExp>::return_t
+Factory<v8::RegExp>::New(
+ v8::Local<v8::String> pattern
+ , v8::RegExp::Flags flags) {
+ return v8::RegExp::New(pattern, flags);
+}
+#endif
+
+//=== Script ===================================================================
+
+#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
+ (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
+Factory<v8::Script>::return_t
+Factory<v8::Script>::New( v8::Local<v8::String> source) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ v8::ScriptCompiler::Source src(source);
+ return scope.Escape(
+ v8::ScriptCompiler::Compile(isolate->GetCurrentContext(), &src)
+ .FromMaybe(v8::Local<v8::Script>()));
+}
+
+Factory<v8::Script>::return_t
+Factory<v8::Script>::New( v8::Local<v8::String> source
+ , v8::ScriptOrigin const& origin) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ v8::ScriptCompiler::Source src(source, origin);
+ return scope.Escape(
+ v8::ScriptCompiler::Compile(isolate->GetCurrentContext(), &src)
+ .FromMaybe(v8::Local<v8::Script>()));
+}
+#else
+Factory<v8::Script>::return_t
+Factory<v8::Script>::New( v8::Local<v8::String> source) {
+ v8::ScriptCompiler::Source src(source);
+ return v8::ScriptCompiler::Compile(v8::Isolate::GetCurrent(), &src);
+}
+
+Factory<v8::Script>::return_t
+Factory<v8::Script>::New( v8::Local<v8::String> source
+ , v8::ScriptOrigin const& origin) {
+ v8::ScriptCompiler::Source src(source, origin);
+ return v8::ScriptCompiler::Compile(v8::Isolate::GetCurrent(), &src);
+}
+#endif
+
+//=== Signature ================================================================
+
+Factory<v8::Signature>::return_t
+Factory<v8::Signature>::New(Factory<v8::Signature>::FTH receiver) {
+ return v8::Signature::New(v8::Isolate::GetCurrent(), receiver);
+}
+
+//=== String ===================================================================
+
+Factory<v8::String>::return_t
+Factory<v8::String>::New() {
+ return v8::String::Empty(v8::Isolate::GetCurrent());
+}
+
+#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
+ (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
+Factory<v8::String>::return_t
+Factory<v8::String>::New(const char * value, int length) {
+ return v8::String::NewFromUtf8(
+ v8::Isolate::GetCurrent(), value, v8::NewStringType::kNormal, length);
+}
+
+Factory<v8::String>::return_t
+Factory<v8::String>::New(std::string const& value) {
+ assert(value.size() <= INT_MAX && "string too long");
+ return v8::String::NewFromUtf8(v8::Isolate::GetCurrent(),
+ value.data(), v8::NewStringType::kNormal, static_cast<int>(value.size()));
+}
+
+Factory<v8::String>::return_t
+Factory<v8::String>::New(const uint16_t * value, int length) {
+ return v8::String::NewFromTwoByte(v8::Isolate::GetCurrent(), value,
+ v8::NewStringType::kNormal, length);
+}
+
+Factory<v8::String>::return_t
+Factory<v8::String>::New(v8::String::ExternalStringResource * value) {
+ return v8::String::NewExternalTwoByte(v8::Isolate::GetCurrent(), value);
+}
+
+Factory<v8::String>::return_t
+Factory<v8::String>::New(ExternalOneByteStringResource * value) {
+ return v8::String::NewExternalOneByte(v8::Isolate::GetCurrent(), value);
+}
+#else
+Factory<v8::String>::return_t
+Factory<v8::String>::New(const char * value, int length) {
+ return v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), value,
+ v8::String::kNormalString, length);
+}
+
+Factory<v8::String>::return_t
+Factory<v8::String>::New(
+ std::string const& value) /* NOLINT(build/include_what_you_use) */ {
+ assert(value.size() <= INT_MAX && "string too long");
+ return v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), value.data(),
+ v8::String::kNormalString,
+ static_cast<int>(value.size()));
+}
+
+Factory<v8::String>::return_t
+Factory<v8::String>::New(const uint16_t * value, int length) {
+ return v8::String::NewFromTwoByte(v8::Isolate::GetCurrent(), value,
+ v8::String::kNormalString, length);
+}
+
+Factory<v8::String>::return_t
+Factory<v8::String>::New(v8::String::ExternalStringResource * value) {
+ return v8::String::NewExternal(v8::Isolate::GetCurrent(), value);
+}
+
+Factory<v8::String>::return_t
+Factory<v8::String>::New(ExternalOneByteStringResource * value) {
+ return v8::String::NewExternal(v8::Isolate::GetCurrent(), value);
+}
+#endif
+
+//=== String Object ============================================================
+
+// See https://github.com/nodejs/nan/pull/811#discussion_r224594980.
+// Disable the warning as there is no way around it.
+// TODO(bnoordhuis) Use isolate-based version in Node.js v12.
+Factory<v8::StringObject>::return_t
+Factory<v8::StringObject>::New(v8::Local<v8::String> value) {
+// V8 > 7.0
+#if V8_MAJOR_VERSION > 7 || (V8_MAJOR_VERSION == 7 && V8_MINOR_VERSION > 0)
+ return v8::StringObject::New(v8::Isolate::GetCurrent(), value)
+ .As<v8::StringObject>();
+#else
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable : 4996)
+#endif
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+ return v8::StringObject::New(value).As<v8::StringObject>();
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+#endif
+}
+
+//=== Unbound Script ===========================================================
+
+#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
+ (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
+Factory<v8::UnboundScript>::return_t
+Factory<v8::UnboundScript>::New(v8::Local<v8::String> source) {
+ v8::ScriptCompiler::Source src(source);
+ return v8::ScriptCompiler::CompileUnboundScript(
+ v8::Isolate::GetCurrent(), &src);
+}
+
+Factory<v8::UnboundScript>::return_t
+Factory<v8::UnboundScript>::New( v8::Local<v8::String> source
+ , v8::ScriptOrigin const& origin) {
+ v8::ScriptCompiler::Source src(source, origin);
+ return v8::ScriptCompiler::CompileUnboundScript(
+ v8::Isolate::GetCurrent(), &src);
+}
+#else
+Factory<v8::UnboundScript>::return_t
+Factory<v8::UnboundScript>::New(v8::Local<v8::String> source) {
+ v8::ScriptCompiler::Source src(source);
+ return v8::ScriptCompiler::CompileUnbound(v8::Isolate::GetCurrent(), &src);
+}
+
+Factory<v8::UnboundScript>::return_t
+Factory<v8::UnboundScript>::New( v8::Local<v8::String> source
+ , v8::ScriptOrigin const& origin) {
+ v8::ScriptCompiler::Source src(source, origin);
+ return v8::ScriptCompiler::CompileUnbound(v8::Isolate::GetCurrent(), &src);
+}
+#endif
+
+} // end of namespace imp
+
+//=== Presistents and Handles ==================================================
+
+#if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION
+template <typename T>
+inline v8::Local<T> New(v8::Handle<T> h) {
+ return v8::Local<T>::New(v8::Isolate::GetCurrent(), h);
+}
+#endif
+
+template <typename T, typename M>
+inline v8::Local<T> New(v8::Persistent<T, M> const& p) {
+ return v8::Local<T>::New(v8::Isolate::GetCurrent(), p);
+}
+
+template <typename T, typename M>
+inline v8::Local<T> New(Persistent<T, M> const& p) {
+ return v8::Local<T>::New(v8::Isolate::GetCurrent(), p);
+}
+
+template <typename T>
+inline v8::Local<T> New(Global<T> const& p) {
+ return v8::Local<T>::New(v8::Isolate::GetCurrent(), p);
+}
+
+#endif // NAN_IMPLEMENTATION_12_INL_H_
diff --git a/node_modules/nan/nan_implementation_pre_12_inl.h b/node_modules/nan/nan_implementation_pre_12_inl.h
new file mode 100644
index 0000000..1472421
--- /dev/null
+++ b/node_modules/nan/nan_implementation_pre_12_inl.h
@@ -0,0 +1,263 @@
+/*********************************************************************
+ * NAN - Native Abstractions for Node.js
+ *
+ * Copyright (c) 2018 NAN contributors
+ *
+ * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
+ ********************************************************************/
+
+#ifndef NAN_IMPLEMENTATION_PRE_12_INL_H_
+#define NAN_IMPLEMENTATION_PRE_12_INL_H_
+
+//==============================================================================
+// node v0.10 implementation
+//==============================================================================
+
+namespace imp {
+
+//=== Array ====================================================================
+
+Factory<v8::Array>::return_t
+Factory<v8::Array>::New() {
+ return v8::Array::New();
+}
+
+Factory<v8::Array>::return_t
+Factory<v8::Array>::New(int length) {
+ return v8::Array::New(length);
+}
+
+//=== Boolean ==================================================================
+
+Factory<v8::Boolean>::return_t
+Factory<v8::Boolean>::New(bool value) {
+ return v8::Boolean::New(value)->ToBoolean();
+}
+
+//=== Boolean Object ===========================================================
+
+Factory<v8::BooleanObject>::return_t
+Factory<v8::BooleanObject>::New(bool value) {
+ return v8::BooleanObject::New(value).As<v8::BooleanObject>();
+}
+
+//=== Context ==================================================================
+
+Factory<v8::Context>::return_t
+Factory<v8::Context>::New( v8::ExtensionConfiguration* extensions
+ , v8::Local<v8::ObjectTemplate> tmpl
+ , v8::Local<v8::Value> obj) {
+ v8::Persistent<v8::Context> ctx = v8::Context::New(extensions, tmpl, obj);
+ v8::Local<v8::Context> lctx = v8::Local<v8::Context>::New(ctx);
+ ctx.Dispose();
+ return lctx;
+}
+
+//=== Date =====================================================================
+
+Factory<v8::Date>::return_t
+Factory<v8::Date>::New(double value) {
+ return v8::Date::New(value).As<v8::Date>();
+}
+
+//=== External =================================================================
+
+Factory<v8::External>::return_t
+Factory<v8::External>::New(void * value) {
+ return v8::External::New(value);
+}
+
+//=== Function =================================================================
+
+Factory<v8::Function>::return_t
+Factory<v8::Function>::New( FunctionCallback callback
+ , v8::Local<v8::Value> data) {
+ v8::HandleScope scope;
+
+ return scope.Close(Factory<v8::FunctionTemplate>::New(
+ callback, data, v8::Local<v8::Signature>())
+ ->GetFunction());
+}
+
+
+//=== FunctionTemplate =========================================================
+
+Factory<v8::FunctionTemplate>::return_t
+Factory<v8::FunctionTemplate>::New( FunctionCallback callback
+ , v8::Local<v8::Value> data
+ , v8::Local<v8::Signature> signature) {
+ if (callback) {
+ v8::HandleScope scope;
+
+ v8::Local<v8::ObjectTemplate> tpl = v8::ObjectTemplate::New();
+ tpl->SetInternalFieldCount(imp::kFunctionFieldCount);
+ v8::Local<v8::Object> obj = tpl->NewInstance();
+
+ obj->SetInternalField(
+ imp::kFunctionIndex
+ , v8::External::New(reinterpret_cast<void *>(callback)));
+
+ v8::Local<v8::Value> val = v8::Local<v8::Value>::New(data);
+
+ if (!val.IsEmpty()) {
+ obj->SetInternalField(imp::kDataIndex, val);
+ }
+
+ // Note(agnat): Emulate length argument here. Unfortunately, I couldn't find
+ // a way. Have at it though...
+ return scope.Close(
+ v8::FunctionTemplate::New(imp::FunctionCallbackWrapper
+ , obj
+ , signature));
+ } else {
+ return v8::FunctionTemplate::New(0, data, signature);
+ }
+}
+
+//=== Number ===================================================================
+
+Factory<v8::Number>::return_t
+Factory<v8::Number>::New(double value) {
+ return v8::Number::New(value);
+}
+
+//=== Number Object ============================================================
+
+Factory<v8::NumberObject>::return_t
+Factory<v8::NumberObject>::New(double value) {
+ return v8::NumberObject::New(value).As<v8::NumberObject>();
+}
+
+//=== Integer, Int32 and Uint32 ================================================
+
+template <typename T>
+typename IntegerFactory<T>::return_t
+IntegerFactory<T>::New(int32_t value) {
+ return To<T>(T::New(value));
+}
+
+template <typename T>
+typename IntegerFactory<T>::return_t
+IntegerFactory<T>::New(uint32_t value) {
+ return To<T>(T::NewFromUnsigned(value));
+}
+
+Factory<v8::Uint32>::return_t
+Factory<v8::Uint32>::New(int32_t value) {
+ return To<v8::Uint32>(v8::Uint32::NewFromUnsigned(value));
+}
+
+Factory<v8::Uint32>::return_t
+Factory<v8::Uint32>::New(uint32_t value) {
+ return To<v8::Uint32>(v8::Uint32::NewFromUnsigned(value));
+}
+
+
+//=== Object ===================================================================
+
+Factory<v8::Object>::return_t
+Factory<v8::Object>::New() {
+ return v8::Object::New();
+}
+
+//=== Object Template ==========================================================
+
+Factory<v8::ObjectTemplate>::return_t
+Factory<v8::ObjectTemplate>::New() {
+ return v8::ObjectTemplate::New();
+}
+
+//=== RegExp ===================================================================
+
+Factory<v8::RegExp>::return_t
+Factory<v8::RegExp>::New(
+ v8::Local<v8::String> pattern
+ , v8::RegExp::Flags flags) {
+ return v8::RegExp::New(pattern, flags);
+}
+
+//=== Script ===================================================================
+
+Factory<v8::Script>::return_t
+Factory<v8::Script>::New( v8::Local<v8::String> source) {
+ return v8::Script::New(source);
+}
+Factory<v8::Script>::return_t
+Factory<v8::Script>::New( v8::Local<v8::String> source
+ , v8::ScriptOrigin const& origin) {
+ return v8::Script::New(source, const_cast<v8::ScriptOrigin*>(&origin));
+}
+
+//=== Signature ================================================================
+
+Factory<v8::Signature>::return_t
+Factory<v8::Signature>::New(Factory<v8::Signature>::FTH receiver) {
+ return v8::Signature::New(receiver);
+}
+
+//=== String ===================================================================
+
+Factory<v8::String>::return_t
+Factory<v8::String>::New() {
+ return v8::String::Empty();
+}
+
+Factory<v8::String>::return_t
+Factory<v8::String>::New(const char * value, int length) {
+ return v8::String::New(value, length);
+}
+
+Factory<v8::String>::return_t
+Factory<v8::String>::New(
+ std::string const& value) /* NOLINT(build/include_what_you_use) */ {
+ assert(value.size() <= INT_MAX && "string too long");
+ return v8::String::New(value.data(), static_cast<int>(value.size()));
+}
+
+Factory<v8::String>::return_t
+Factory<v8::String>::New(const uint16_t * value, int length) {
+ return v8::String::New(value, length);
+}
+
+Factory<v8::String>::return_t
+Factory<v8::String>::New(v8::String::ExternalStringResource * value) {
+ return v8::String::NewExternal(value);
+}
+
+Factory<v8::String>::return_t
+Factory<v8::String>::New(v8::String::ExternalAsciiStringResource * value) {
+ return v8::String::NewExternal(value);
+}
+
+//=== String Object ============================================================
+
+Factory<v8::StringObject>::return_t
+Factory<v8::StringObject>::New(v8::Local<v8::String> value) {
+ return v8::StringObject::New(value).As<v8::StringObject>();
+}
+
+} // end of namespace imp
+
+//=== Presistents and Handles ==================================================
+
+template <typename T>
+inline v8::Local<T> New(v8::Handle<T> h) {
+ return v8::Local<T>::New(h);
+}
+
+template <typename T>
+inline v8::Local<T> New(v8::Persistent<T> const& p) {
+ return v8::Local<T>::New(p);
+}
+
+template <typename T, typename M>
+inline v8::Local<T> New(Persistent<T, M> const& p) {
+ return v8::Local<T>::New(p.persistent);
+}
+
+template <typename T>
+inline v8::Local<T> New(Global<T> const& p) {
+ return v8::Local<T>::New(p.persistent);
+}
+
+#endif // NAN_IMPLEMENTATION_PRE_12_INL_H_
diff --git a/node_modules/nan/nan_json.h b/node_modules/nan/nan_json.h
new file mode 100644
index 0000000..33ac8ba
--- /dev/null
+++ b/node_modules/nan/nan_json.h
@@ -0,0 +1,166 @@
+/*********************************************************************
+ * NAN - Native Abstractions for Node.js
+ *
+ * Copyright (c) 2018 NAN contributors
+ *
+ * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
+ ********************************************************************/
+
+#ifndef NAN_JSON_H_
+#define NAN_JSON_H_
+
+#if NODE_MODULE_VERSION < NODE_0_12_MODULE_VERSION
+#define NAN_JSON_H_NEED_PARSE 1
+#else
+#define NAN_JSON_H_NEED_PARSE 0
+#endif // NODE_MODULE_VERSION < NODE_0_12_MODULE_VERSION
+
+#if NODE_MODULE_VERSION >= NODE_7_0_MODULE_VERSION
+#define NAN_JSON_H_NEED_STRINGIFY 0
+#else
+#define NAN_JSON_H_NEED_STRINGIFY 1
+#endif // NODE_MODULE_VERSION >= NODE_7_0_MODULE_VERSION
+
+class JSON {
+ public:
+ JSON() {
+#if NAN_JSON_H_NEED_PARSE + NAN_JSON_H_NEED_STRINGIFY
+ Nan::HandleScope scope;
+
+ Nan::MaybeLocal<v8::Value> maybe_global_json = Nan::Get(
+ Nan::GetCurrentContext()->Global(),
+ Nan::New("JSON").ToLocalChecked()
+ );
+
+ assert(!maybe_global_json.IsEmpty() && "global JSON is empty");
+ v8::Local<v8::Value> val_global_json = maybe_global_json.ToLocalChecked();
+
+ assert(val_global_json->IsObject() && "global JSON is not an object");
+ Nan::MaybeLocal<v8::Object> maybe_obj_global_json =
+ Nan::To<v8::Object>(val_global_json);
+
+ assert(!maybe_obj_global_json.IsEmpty() && "global JSON object is empty");
+ v8::Local<v8::Object> global_json = maybe_obj_global_json.ToLocalChecked();
+
+#if NAN_JSON_H_NEED_PARSE
+ Nan::MaybeLocal<v8::Value> maybe_parse_method = Nan::Get(
+ global_json, Nan::New("parse").ToLocalChecked()
+ );
+
+ assert(!maybe_parse_method.IsEmpty() && "JSON.parse is empty");
+ v8::Local<v8::Value> parse_method = maybe_parse_method.ToLocalChecked();
+
+ assert(parse_method->IsFunction() && "JSON.parse is not a function");
+ parse_cb_.Reset(parse_method.As<v8::Function>());
+#endif // NAN_JSON_H_NEED_PARSE
+
+#if NAN_JSON_H_NEED_STRINGIFY
+ Nan::MaybeLocal<v8::Value> maybe_stringify_method = Nan::Get(
+ global_json, Nan::New("stringify").ToLocalChecked()
+ );
+
+ assert(!maybe_stringify_method.IsEmpty() && "JSON.stringify is empty");
+ v8::Local<v8::Value> stringify_method =
+ maybe_stringify_method.ToLocalChecked();
+
+ assert(
+ stringify_method->IsFunction() && "JSON.stringify is not a function"
+ );
+ stringify_cb_.Reset(stringify_method.As<v8::Function>());
+#endif // NAN_JSON_H_NEED_STRINGIFY
+#endif // NAN_JSON_H_NEED_PARSE + NAN_JSON_H_NEED_STRINGIFY
+ }
+
+ inline
+ Nan::MaybeLocal<v8::Value> Parse(v8::Local<v8::String> json_string) {
+ Nan::EscapableHandleScope scope;
+#if NAN_JSON_H_NEED_PARSE
+ return scope.Escape(parse(json_string));
+#else
+ Nan::MaybeLocal<v8::Value> result;
+#if NODE_MODULE_VERSION >= NODE_0_12_MODULE_VERSION && \
+ NODE_MODULE_VERSION <= IOJS_2_0_MODULE_VERSION
+ result = v8::JSON::Parse(json_string);
+#else
+#if NODE_MODULE_VERSION > NODE_6_0_MODULE_VERSION
+ v8::Local<v8::Context> context_or_isolate = Nan::GetCurrentContext();
+#else
+ v8::Isolate* context_or_isolate = v8::Isolate::GetCurrent();
+#endif // NODE_MODULE_VERSION > NODE_6_0_MODULE_VERSION
+ result = v8::JSON::Parse(context_or_isolate, json_string);
+#endif // NODE_MODULE_VERSION >= NODE_0_12_MODULE_VERSION &&
+ // NODE_MODULE_VERSION <= IOJS_2_0_MODULE_VERSION
+ if (result.IsEmpty()) return v8::Local<v8::Value>();
+ return scope.Escape(result.ToLocalChecked());
+#endif // NAN_JSON_H_NEED_PARSE
+ }
+
+ inline
+ Nan::MaybeLocal<v8::String> Stringify(v8::Local<v8::Object> json_object) {
+ Nan::EscapableHandleScope scope;
+ Nan::MaybeLocal<v8::String> result =
+#if NAN_JSON_H_NEED_STRINGIFY
+ Nan::To<v8::String>(stringify(json_object));
+#else
+ v8::JSON::Stringify(Nan::GetCurrentContext(), json_object);
+#endif // NAN_JSON_H_NEED_STRINGIFY
+ if (result.IsEmpty()) return v8::Local<v8::String>();
+ return scope.Escape(result.ToLocalChecked());
+ }
+
+ inline
+ Nan::MaybeLocal<v8::String> Stringify(v8::Local<v8::Object> json_object,
+ v8::Local<v8::String> gap) {
+ Nan::EscapableHandleScope scope;
+ Nan::MaybeLocal<v8::String> result =
+#if NAN_JSON_H_NEED_STRINGIFY
+ Nan::To<v8::String>(stringify(json_object, gap));
+#else
+ v8::JSON::Stringify(Nan::GetCurrentContext(), json_object, gap);
+#endif // NAN_JSON_H_NEED_STRINGIFY
+ if (result.IsEmpty()) return v8::Local<v8::String>();
+ return scope.Escape(result.ToLocalChecked());
+ }
+
+ private:
+ NAN_DISALLOW_ASSIGN_COPY_MOVE(JSON)
+#if NAN_JSON_H_NEED_PARSE
+ Nan::Callback parse_cb_;
+#endif // NAN_JSON_H_NEED_PARSE
+#if NAN_JSON_H_NEED_STRINGIFY
+ Nan::Callback stringify_cb_;
+#endif // NAN_JSON_H_NEED_STRINGIFY
+
+#if NAN_JSON_H_NEED_PARSE
+ inline v8::Local<v8::Value> parse(v8::Local<v8::Value> arg) {
+ assert(!parse_cb_.IsEmpty() && "parse_cb_ is empty");
+ AsyncResource resource("nan:JSON.parse");
+ return parse_cb_.Call(1, &arg, &resource).FromMaybe(v8::Local<v8::Value>());
+ }
+#endif // NAN_JSON_H_NEED_PARSE
+
+#if NAN_JSON_H_NEED_STRINGIFY
+ inline v8::Local<v8::Value> stringify(v8::Local<v8::Value> arg) {
+ assert(!stringify_cb_.IsEmpty() && "stringify_cb_ is empty");
+ AsyncResource resource("nan:JSON.stringify");
+ return stringify_cb_.Call(1, &arg, &resource)
+ .FromMaybe(v8::Local<v8::Value>());
+ }
+
+ inline v8::Local<v8::Value> stringify(v8::Local<v8::Value> arg,
+ v8::Local<v8::String> gap) {
+ assert(!stringify_cb_.IsEmpty() && "stringify_cb_ is empty");
+
+ v8::Local<v8::Value> argv[] = {
+ arg,
+ Nan::Null(),
+ gap
+ };
+ AsyncResource resource("nan:JSON.stringify");
+ return stringify_cb_.Call(3, argv, &resource)
+ .FromMaybe(v8::Local<v8::Value>());
+ }
+#endif // NAN_JSON_H_NEED_STRINGIFY
+};
+
+#endif // NAN_JSON_H_
diff --git a/node_modules/nan/nan_maybe_43_inl.h b/node_modules/nan/nan_maybe_43_inl.h
new file mode 100644
index 0000000..c04ce30
--- /dev/null
+++ b/node_modules/nan/nan_maybe_43_inl.h
@@ -0,0 +1,356 @@
+/*********************************************************************
+ * NAN - Native Abstractions for Node.js
+ *
+ * Copyright (c) 2018 NAN contributors
+ *
+ * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
+ ********************************************************************/
+
+#ifndef NAN_MAYBE_43_INL_H_
+#define NAN_MAYBE_43_INL_H_
+
+template<typename T>
+using MaybeLocal = v8::MaybeLocal<T>;
+
+inline
+MaybeLocal<v8::String> ToDetailString(v8::Local<v8::Value> val) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ return scope.Escape(val->ToDetailString(isolate->GetCurrentContext())
+ .FromMaybe(v8::Local<v8::String>()));
+}
+
+inline
+MaybeLocal<v8::Uint32> ToArrayIndex(v8::Local<v8::Value> val) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ return scope.Escape(val->ToArrayIndex(isolate->GetCurrentContext())
+ .FromMaybe(v8::Local<v8::Uint32>()));
+}
+
+inline
+Maybe<bool> Equals(v8::Local<v8::Value> a, v8::Local<v8::Value>(b)) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
+ return a->Equals(isolate->GetCurrentContext(), b);
+}
+
+inline
+MaybeLocal<v8::Object> NewInstance(v8::Local<v8::Function> h) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ return scope.Escape(h->NewInstance(isolate->GetCurrentContext())
+ .FromMaybe(v8::Local<v8::Object>()));
+}
+
+inline
+MaybeLocal<v8::Object> NewInstance(
+ v8::Local<v8::Function> h
+ , int argc
+ , v8::Local<v8::Value> argv[]) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ return scope.Escape(h->NewInstance(isolate->GetCurrentContext(), argc, argv)
+ .FromMaybe(v8::Local<v8::Object>()));
+}
+
+inline
+MaybeLocal<v8::Object> NewInstance(v8::Local<v8::ObjectTemplate> h) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ return scope.Escape(h->NewInstance(isolate->GetCurrentContext())
+ .FromMaybe(v8::Local<v8::Object>()));
+}
+
+
+inline MaybeLocal<v8::Function> GetFunction(
+ v8::Local<v8::FunctionTemplate> t) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ return scope.Escape(t->GetFunction(isolate->GetCurrentContext())
+ .FromMaybe(v8::Local<v8::Function>()));
+}
+
+inline Maybe<bool> Set(
+ v8::Local<v8::Object> obj
+ , v8::Local<v8::Value> key
+ , v8::Local<v8::Value> value) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
+ return obj->Set(isolate->GetCurrentContext(), key, value);
+}
+
+inline Maybe<bool> Set(
+ v8::Local<v8::Object> obj
+ , uint32_t index
+ , v8::Local<v8::Value> value) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
+ return obj->Set(isolate->GetCurrentContext(), index, value);
+}
+
+#if NODE_MODULE_VERSION < NODE_4_0_MODULE_VERSION
+#include "nan_define_own_property_helper.h" // NOLINT(build/include)
+#endif
+
+inline Maybe<bool> DefineOwnProperty(
+ v8::Local<v8::Object> obj
+ , v8::Local<v8::String> key
+ , v8::Local<v8::Value> value
+ , v8::PropertyAttribute attribs = v8::None) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
+#if NODE_MODULE_VERSION >= NODE_4_0_MODULE_VERSION
+ return obj->DefineOwnProperty(isolate->GetCurrentContext(), key, value,
+ attribs);
+#else
+ Maybe<v8::PropertyAttribute> maybeCurrent =
+ obj->GetPropertyAttributes(isolate->GetCurrentContext(), key);
+ if (maybeCurrent.IsNothing()) {
+ return Nothing<bool>();
+ }
+ v8::PropertyAttribute current = maybeCurrent.FromJust();
+ return imp::DefineOwnPropertyHelper(current, obj, key, value, attribs);
+#endif
+}
+
+NAN_DEPRECATED inline Maybe<bool> ForceSet(
+ v8::Local<v8::Object> obj
+ , v8::Local<v8::Value> key
+ , v8::Local<v8::Value> value
+ , v8::PropertyAttribute attribs = v8::None) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
+#if NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
+ return key->IsName()
+ ? obj->DefineOwnProperty(isolate->GetCurrentContext(),
+ key.As<v8::Name>(), value, attribs)
+ : Nothing<bool>();
+#else
+ return obj->ForceSet(isolate->GetCurrentContext(), key, value, attribs);
+#endif
+}
+
+inline MaybeLocal<v8::Value> Get(
+ v8::Local<v8::Object> obj
+ , v8::Local<v8::Value> key) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ return scope.Escape(obj->Get(isolate->GetCurrentContext(), key)
+ .FromMaybe(v8::Local<v8::Value>()));
+}
+
+inline
+MaybeLocal<v8::Value> Get(v8::Local<v8::Object> obj, uint32_t index) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ return scope.Escape(obj->Get(isolate->GetCurrentContext(), index)
+ .FromMaybe(v8::Local<v8::Value>()));
+}
+
+inline v8::PropertyAttribute GetPropertyAttributes(
+ v8::Local<v8::Object> obj
+ , v8::Local<v8::Value> key) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
+ return obj->GetPropertyAttributes(isolate->GetCurrentContext(), key)
+ .FromJust();
+}
+
+inline Maybe<bool> Has(
+ v8::Local<v8::Object> obj
+ , v8::Local<v8::String> key) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
+ return obj->Has(isolate->GetCurrentContext(), key);
+}
+
+inline Maybe<bool> Has(v8::Local<v8::Object> obj, uint32_t index) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
+ return obj->Has(isolate->GetCurrentContext(), index);
+}
+
+inline Maybe<bool> Delete(
+ v8::Local<v8::Object> obj
+ , v8::Local<v8::String> key) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
+ return obj->Delete(isolate->GetCurrentContext(), key);
+}
+
+inline
+Maybe<bool> Delete(v8::Local<v8::Object> obj, uint32_t index) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
+ return obj->Delete(isolate->GetCurrentContext(), index);
+}
+
+inline
+MaybeLocal<v8::Array> GetPropertyNames(v8::Local<v8::Object> obj) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ return scope.Escape(obj->GetPropertyNames(isolate->GetCurrentContext())
+ .FromMaybe(v8::Local<v8::Array>()));
+}
+
+inline
+MaybeLocal<v8::Array> GetOwnPropertyNames(v8::Local<v8::Object> obj) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ return scope.Escape(obj->GetOwnPropertyNames(isolate->GetCurrentContext())
+ .FromMaybe(v8::Local<v8::Array>()));
+}
+
+inline Maybe<bool> SetPrototype(
+ v8::Local<v8::Object> obj
+ , v8::Local<v8::Value> prototype) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
+ return obj->SetPrototype(isolate->GetCurrentContext(), prototype);
+}
+
+inline MaybeLocal<v8::String> ObjectProtoToString(
+ v8::Local<v8::Object> obj) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ return scope.Escape(obj->ObjectProtoToString(isolate->GetCurrentContext())
+ .FromMaybe(v8::Local<v8::String>()));
+}
+
+inline Maybe<bool> HasOwnProperty(
+ v8::Local<v8::Object> obj
+ , v8::Local<v8::String> key) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
+ return obj->HasOwnProperty(isolate->GetCurrentContext(), key);
+}
+
+inline Maybe<bool> HasRealNamedProperty(
+ v8::Local<v8::Object> obj
+ , v8::Local<v8::String> key) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
+ return obj->HasRealNamedProperty(isolate->GetCurrentContext(), key);
+}
+
+inline Maybe<bool> HasRealIndexedProperty(
+ v8::Local<v8::Object> obj
+ , uint32_t index) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
+ return obj->HasRealIndexedProperty(isolate->GetCurrentContext(), index);
+}
+
+inline Maybe<bool> HasRealNamedCallbackProperty(
+ v8::Local<v8::Object> obj
+ , v8::Local<v8::String> key) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
+ return obj->HasRealNamedCallbackProperty(isolate->GetCurrentContext(), key);
+}
+
+inline MaybeLocal<v8::Value> GetRealNamedPropertyInPrototypeChain(
+ v8::Local<v8::Object> obj
+ , v8::Local<v8::String> key) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ return scope.Escape(obj->GetRealNamedPropertyInPrototypeChain(
+ isolate->GetCurrentContext(), key)
+ .FromMaybe(v8::Local<v8::Value>()));
+}
+
+inline MaybeLocal<v8::Value> GetRealNamedProperty(
+ v8::Local<v8::Object> obj
+ , v8::Local<v8::String> key) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ return scope.Escape(
+ obj->GetRealNamedProperty(isolate->GetCurrentContext(), key)
+ .FromMaybe(v8::Local<v8::Value>()));
+}
+
+inline MaybeLocal<v8::Value> CallAsFunction(
+ v8::Local<v8::Object> obj
+ , v8::Local<v8::Object> recv
+ , int argc
+ , v8::Local<v8::Value> argv[]) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ return scope.Escape(
+ obj->CallAsFunction(isolate->GetCurrentContext(), recv, argc, argv)
+ .FromMaybe(v8::Local<v8::Value>()));
+}
+
+inline MaybeLocal<v8::Value> CallAsConstructor(
+ v8::Local<v8::Object> obj
+ , int argc, v8::Local<v8::Value> argv[]) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ return scope.Escape(
+ obj->CallAsConstructor(isolate->GetCurrentContext(), argc, argv)
+ .FromMaybe(v8::Local<v8::Value>()));
+}
+
+inline
+MaybeLocal<v8::String> GetSourceLine(v8::Local<v8::Message> msg) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ return scope.Escape(msg->GetSourceLine(isolate->GetCurrentContext())
+ .FromMaybe(v8::Local<v8::String>()));
+}
+
+inline Maybe<int> GetLineNumber(v8::Local<v8::Message> msg) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
+ return msg->GetLineNumber(isolate->GetCurrentContext());
+}
+
+inline Maybe<int> GetStartColumn(v8::Local<v8::Message> msg) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
+ return msg->GetStartColumn(isolate->GetCurrentContext());
+}
+
+inline Maybe<int> GetEndColumn(v8::Local<v8::Message> msg) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
+ return msg->GetEndColumn(isolate->GetCurrentContext());
+}
+
+inline MaybeLocal<v8::Object> CloneElementAt(
+ v8::Local<v8::Array> array
+ , uint32_t index) {
+#if (NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION)
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ v8::Local<v8::Context> context = isolate->GetCurrentContext();
+ v8::Local<v8::Value> elem;
+ v8::Local<v8::Object> obj;
+ if (!array->Get(context, index).ToLocal(&elem)) {
+ return scope.Escape(obj);
+ }
+ if (!elem->ToObject(context).ToLocal(&obj)) {
+ return scope.Escape(v8::Local<v8::Object>());
+ }
+ return scope.Escape(obj->Clone());
+#else
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ return scope.Escape(array->CloneElementAt(isolate->GetCurrentContext(), index)
+ .FromMaybe(v8::Local<v8::Object>()));
+#endif
+}
+
+inline MaybeLocal<v8::Value> Call(
+ v8::Local<v8::Function> fun
+ , v8::Local<v8::Object> recv
+ , int argc
+ , v8::Local<v8::Value> argv[]) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ return scope.Escape(fun->Call(isolate->GetCurrentContext(), recv, argc, argv)
+ .FromMaybe(v8::Local<v8::Value>()));
+}
+
+#endif // NAN_MAYBE_43_INL_H_
diff --git a/node_modules/nan/nan_maybe_pre_43_inl.h b/node_modules/nan/nan_maybe_pre_43_inl.h
new file mode 100644
index 0000000..83325ae
--- /dev/null
+++ b/node_modules/nan/nan_maybe_pre_43_inl.h
@@ -0,0 +1,268 @@
+/*********************************************************************
+ * NAN - Native Abstractions for Node.js
+ *
+ * Copyright (c) 2018 NAN contributors
+ *
+ * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
+ ********************************************************************/
+
+#ifndef NAN_MAYBE_PRE_43_INL_H_
+#define NAN_MAYBE_PRE_43_INL_H_
+
+template<typename T>
+class MaybeLocal {
+ public:
+ inline MaybeLocal() : val_(v8::Local<T>()) {}
+
+ template<typename S>
+# if NODE_MODULE_VERSION >= NODE_0_12_MODULE_VERSION
+ inline
+ MaybeLocal(v8::Local<S> that) : val_(that) {} // NOLINT(runtime/explicit)
+# else
+ inline
+ MaybeLocal(v8::Local<S> that) : // NOLINT(runtime/explicit)
+ val_(*reinterpret_cast<v8::Local<T>*>(&that)) {}
+# endif
+
+ inline bool IsEmpty() const { return val_.IsEmpty(); }
+
+ template<typename S>
+ inline bool ToLocal(v8::Local<S> *out) const {
+ *out = val_;
+ return !IsEmpty();
+ }
+
+ inline v8::Local<T> ToLocalChecked() const {
+#if defined(V8_ENABLE_CHECKS)
+ assert(!IsEmpty() && "ToLocalChecked is Empty");
+#endif // V8_ENABLE_CHECKS
+ return val_;
+ }
+
+ template<typename S>
+ inline v8::Local<S> FromMaybe(v8::Local<S> default_value) const {
+ return IsEmpty() ? default_value : v8::Local<S>(val_);
+ }
+
+ private:
+ v8::Local<T> val_;
+};
+
+inline
+MaybeLocal<v8::String> ToDetailString(v8::Handle<v8::Value> val) {
+ return MaybeLocal<v8::String>(val->ToDetailString());
+}
+
+inline
+MaybeLocal<v8::Uint32> ToArrayIndex(v8::Handle<v8::Value> val) {
+ return MaybeLocal<v8::Uint32>(val->ToArrayIndex());
+}
+
+inline
+Maybe<bool> Equals(v8::Handle<v8::Value> a, v8::Handle<v8::Value>(b)) {
+ return Just<bool>(a->Equals(b));
+}
+
+inline
+MaybeLocal<v8::Object> NewInstance(v8::Handle<v8::Function> h) {
+ return MaybeLocal<v8::Object>(h->NewInstance());
+}
+
+inline
+MaybeLocal<v8::Object> NewInstance(
+ v8::Local<v8::Function> h
+ , int argc
+ , v8::Local<v8::Value> argv[]) {
+ return MaybeLocal<v8::Object>(h->NewInstance(argc, argv));
+}
+
+inline
+MaybeLocal<v8::Object> NewInstance(v8::Handle<v8::ObjectTemplate> h) {
+ return MaybeLocal<v8::Object>(h->NewInstance());
+}
+
+inline
+MaybeLocal<v8::Function> GetFunction(v8::Handle<v8::FunctionTemplate> t) {
+ return MaybeLocal<v8::Function>(t->GetFunction());
+}
+
+inline Maybe<bool> Set(
+ v8::Handle<v8::Object> obj
+ , v8::Handle<v8::Value> key
+ , v8::Handle<v8::Value> value) {
+ return Just<bool>(obj->Set(key, value));
+}
+
+inline Maybe<bool> Set(
+ v8::Handle<v8::Object> obj
+ , uint32_t index
+ , v8::Handle<v8::Value> value) {
+ return Just<bool>(obj->Set(index, value));
+}
+
+#include "nan_define_own_property_helper.h" // NOLINT(build/include)
+
+inline Maybe<bool> DefineOwnProperty(
+ v8::Handle<v8::Object> obj
+ , v8::Handle<v8::String> key
+ , v8::Handle<v8::Value> value
+ , v8::PropertyAttribute attribs = v8::None) {
+ v8::PropertyAttribute current = obj->GetPropertyAttributes(key);
+ return imp::DefineOwnPropertyHelper(current, obj, key, value, attribs);
+}
+
+NAN_DEPRECATED inline Maybe<bool> ForceSet(
+ v8::Handle<v8::Object> obj
+ , v8::Handle<v8::Value> key
+ , v8::Handle<v8::Value> value
+ , v8::PropertyAttribute attribs = v8::None) {
+ return Just<bool>(obj->ForceSet(key, value, attribs));
+}
+
+inline MaybeLocal<v8::Value> Get(
+ v8::Handle<v8::Object> obj
+ , v8::Handle<v8::Value> key) {
+ return MaybeLocal<v8::Value>(obj->Get(key));
+}
+
+inline MaybeLocal<v8::Value> Get(
+ v8::Handle<v8::Object> obj
+ , uint32_t index) {
+ return MaybeLocal<v8::Value>(obj->Get(index));
+}
+
+inline Maybe<v8::PropertyAttribute> GetPropertyAttributes(
+ v8::Handle<v8::Object> obj
+ , v8::Handle<v8::Value> key) {
+ return Just<v8::PropertyAttribute>(obj->GetPropertyAttributes(key));
+}
+
+inline Maybe<bool> Has(
+ v8::Handle<v8::Object> obj
+ , v8::Handle<v8::String> key) {
+ return Just<bool>(obj->Has(key));
+}
+
+inline Maybe<bool> Has(
+ v8::Handle<v8::Object> obj
+ , uint32_t index) {
+ return Just<bool>(obj->Has(index));
+}
+
+inline Maybe<bool> Delete(
+ v8::Handle<v8::Object> obj
+ , v8::Handle<v8::String> key) {
+ return Just<bool>(obj->Delete(key));
+}
+
+inline Maybe<bool> Delete(
+ v8::Handle<v8::Object> obj
+ , uint32_t index) {
+ return Just<bool>(obj->Delete(index));
+}
+
+inline
+MaybeLocal<v8::Array> GetPropertyNames(v8::Handle<v8::Object> obj) {
+ return MaybeLocal<v8::Array>(obj->GetPropertyNames());
+}
+
+inline
+MaybeLocal<v8::Array> GetOwnPropertyNames(v8::Handle<v8::Object> obj) {
+ return MaybeLocal<v8::Array>(obj->GetOwnPropertyNames());
+}
+
+inline Maybe<bool> SetPrototype(
+ v8::Handle<v8::Object> obj
+ , v8::Handle<v8::Value> prototype) {
+ return Just<bool>(obj->SetPrototype(prototype));
+}
+
+inline MaybeLocal<v8::String> ObjectProtoToString(
+ v8::Handle<v8::Object> obj) {
+ return MaybeLocal<v8::String>(obj->ObjectProtoToString());
+}
+
+inline Maybe<bool> HasOwnProperty(
+ v8::Handle<v8::Object> obj
+ , v8::Handle<v8::String> key) {
+ return Just<bool>(obj->HasOwnProperty(key));
+}
+
+inline Maybe<bool> HasRealNamedProperty(
+ v8::Handle<v8::Object> obj
+ , v8::Handle<v8::String> key) {
+ return Just<bool>(obj->HasRealNamedProperty(key));
+}
+
+inline Maybe<bool> HasRealIndexedProperty(
+ v8::Handle<v8::Object> obj
+ , uint32_t index) {
+ return Just<bool>(obj->HasRealIndexedProperty(index));
+}
+
+inline Maybe<bool> HasRealNamedCallbackProperty(
+ v8::Handle<v8::Object> obj
+ , v8::Handle<v8::String> key) {
+ return Just<bool>(obj->HasRealNamedCallbackProperty(key));
+}
+
+inline MaybeLocal<v8::Value> GetRealNamedPropertyInPrototypeChain(
+ v8::Handle<v8::Object> obj
+ , v8::Handle<v8::String> key) {
+ return MaybeLocal<v8::Value>(
+ obj->GetRealNamedPropertyInPrototypeChain(key));
+}
+
+inline MaybeLocal<v8::Value> GetRealNamedProperty(
+ v8::Handle<v8::Object> obj
+ , v8::Handle<v8::String> key) {
+ return MaybeLocal<v8::Value>(obj->GetRealNamedProperty(key));
+}
+
+inline MaybeLocal<v8::Value> CallAsFunction(
+ v8::Handle<v8::Object> obj
+ , v8::Handle<v8::Object> recv
+ , int argc
+ , v8::Handle<v8::Value> argv[]) {
+ return MaybeLocal<v8::Value>(obj->CallAsFunction(recv, argc, argv));
+}
+
+inline MaybeLocal<v8::Value> CallAsConstructor(
+ v8::Handle<v8::Object> obj
+ , int argc
+ , v8::Local<v8::Value> argv[]) {
+ return MaybeLocal<v8::Value>(obj->CallAsConstructor(argc, argv));
+}
+
+inline
+MaybeLocal<v8::String> GetSourceLine(v8::Handle<v8::Message> msg) {
+ return MaybeLocal<v8::String>(msg->GetSourceLine());
+}
+
+inline Maybe<int> GetLineNumber(v8::Handle<v8::Message> msg) {
+ return Just<int>(msg->GetLineNumber());
+}
+
+inline Maybe<int> GetStartColumn(v8::Handle<v8::Message> msg) {
+ return Just<int>(msg->GetStartColumn());
+}
+
+inline Maybe<int> GetEndColumn(v8::Handle<v8::Message> msg) {
+ return Just<int>(msg->GetEndColumn());
+}
+
+inline MaybeLocal<v8::Object> CloneElementAt(
+ v8::Handle<v8::Array> array
+ , uint32_t index) {
+ return MaybeLocal<v8::Object>(array->CloneElementAt(index));
+}
+
+inline MaybeLocal<v8::Value> Call(
+ v8::Local<v8::Function> fun
+ , v8::Local<v8::Object> recv
+ , int argc
+ , v8::Local<v8::Value> argv[]) {
+ return MaybeLocal<v8::Value>(fun->Call(recv, argc, argv));
+}
+
+#endif // NAN_MAYBE_PRE_43_INL_H_
diff --git a/node_modules/nan/nan_new.h b/node_modules/nan/nan_new.h
new file mode 100644
index 0000000..cdf8bbe
--- /dev/null
+++ b/node_modules/nan/nan_new.h
@@ -0,0 +1,340 @@
+/*********************************************************************
+ * NAN - Native Abstractions for Node.js
+ *
+ * Copyright (c) 2018 NAN contributors
+ *
+ * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
+ ********************************************************************/
+
+#ifndef NAN_NEW_H_
+#define NAN_NEW_H_
+
+namespace imp { // scnr
+
+// TODO(agnat): Generalize
+template <typename T> v8::Local<T> To(v8::Local<v8::Integer> i);
+
+template <>
+inline
+v8::Local<v8::Integer>
+To<v8::Integer>(v8::Local<v8::Integer> i) {
+ return Nan::To<v8::Integer>(i).ToLocalChecked();
+}
+
+template <>
+inline
+v8::Local<v8::Int32>
+To<v8::Int32>(v8::Local<v8::Integer> i) {
+ return Nan::To<v8::Int32>(i).ToLocalChecked();
+}
+
+template <>
+inline
+v8::Local<v8::Uint32>
+To<v8::Uint32>(v8::Local<v8::Integer> i) {
+ return Nan::To<v8::Uint32>(i).ToLocalChecked();
+}
+
+template <typename T> struct FactoryBase {
+ typedef v8::Local<T> return_t;
+};
+
+template <typename T> struct MaybeFactoryBase {
+ typedef MaybeLocal<T> return_t;
+};
+
+template <typename T> struct Factory;
+
+template <>
+struct Factory<v8::Array> : FactoryBase<v8::Array> {
+ static inline return_t New();
+ static inline return_t New(int length);
+};
+
+template <>
+struct Factory<v8::Boolean> : FactoryBase<v8::Boolean> {
+ static inline return_t New(bool value);
+};
+
+template <>
+struct Factory<v8::BooleanObject> : FactoryBase<v8::BooleanObject> {
+ static inline return_t New(bool value);
+};
+
+template <>
+struct Factory<v8::Context> : FactoryBase<v8::Context> {
+ static inline
+ return_t
+ New( v8::ExtensionConfiguration* extensions = NULL
+ , v8::Local<v8::ObjectTemplate> tmpl = v8::Local<v8::ObjectTemplate>()
+ , v8::Local<v8::Value> obj = v8::Local<v8::Value>());
+};
+
+template <>
+struct Factory<v8::Date> : MaybeFactoryBase<v8::Date> {
+ static inline return_t New(double value);
+};
+
+template <>
+struct Factory<v8::External> : FactoryBase<v8::External> {
+ static inline return_t New(void *value);
+};
+
+template <>
+struct Factory<v8::Function> : FactoryBase<v8::Function> {
+ static inline
+ return_t
+ New( FunctionCallback callback
+ , v8::Local<v8::Value> data = v8::Local<v8::Value>());
+};
+
+template <>
+struct Factory<v8::FunctionTemplate> : FactoryBase<v8::FunctionTemplate> {
+ static inline
+ return_t
+ New( FunctionCallback callback = NULL
+ , v8::Local<v8::Value> data = v8::Local<v8::Value>()
+ , v8::Local<v8::Signature> signature = v8::Local<v8::Signature>());
+};
+
+template <>
+struct Factory<v8::Number> : FactoryBase<v8::Number> {
+ static inline return_t New(double value);
+};
+
+template <>
+struct Factory<v8::NumberObject> : FactoryBase<v8::NumberObject> {
+ static inline return_t New(double value);
+};
+
+template <typename T>
+struct IntegerFactory : FactoryBase<T> {
+ typedef typename FactoryBase<T>::return_t return_t;
+ static inline return_t New(int32_t value);
+ static inline return_t New(uint32_t value);
+};
+
+template <>
+struct Factory<v8::Integer> : IntegerFactory<v8::Integer> {};
+
+template <>
+struct Factory<v8::Int32> : IntegerFactory<v8::Int32> {};
+
+template <>
+struct Factory<v8::Uint32> : FactoryBase<v8::Uint32> {
+ static inline return_t New(int32_t value);
+ static inline return_t New(uint32_t value);
+};
+
+template <>
+struct Factory<v8::Object> : FactoryBase<v8::Object> {
+ static inline return_t New();
+};
+
+template <>
+struct Factory<v8::ObjectTemplate> : FactoryBase<v8::ObjectTemplate> {
+ static inline return_t New();
+};
+
+template <>
+struct Factory<v8::RegExp> : MaybeFactoryBase<v8::RegExp> {
+ static inline return_t New(
+ v8::Local<v8::String> pattern, v8::RegExp::Flags flags);
+};
+
+template <>
+struct Factory<v8::Script> : MaybeFactoryBase<v8::Script> {
+ static inline return_t New( v8::Local<v8::String> source);
+ static inline return_t New( v8::Local<v8::String> source
+ , v8::ScriptOrigin const& origin);
+};
+
+template <>
+struct Factory<v8::Signature> : FactoryBase<v8::Signature> {
+ typedef v8::Local<v8::FunctionTemplate> FTH;
+ static inline return_t New(FTH receiver = FTH());
+};
+
+template <>
+struct Factory<v8::String> : MaybeFactoryBase<v8::String> {
+ static inline return_t New();
+ static inline return_t New(const char *value, int length = -1);
+ static inline return_t New(const uint16_t *value, int length = -1);
+ static inline return_t New(std::string const& value);
+
+ static inline return_t New(v8::String::ExternalStringResource * value);
+ static inline return_t New(ExternalOneByteStringResource * value);
+};
+
+template <>
+struct Factory<v8::StringObject> : FactoryBase<v8::StringObject> {
+ static inline return_t New(v8::Local<v8::String> value);
+};
+
+} // end of namespace imp
+
+#if (NODE_MODULE_VERSION >= 12)
+
+namespace imp {
+
+template <>
+struct Factory<v8::UnboundScript> : MaybeFactoryBase<v8::UnboundScript> {
+ static inline return_t New( v8::Local<v8::String> source);
+ static inline return_t New( v8::Local<v8::String> source
+ , v8::ScriptOrigin const& origin);
+};
+
+} // end of namespace imp
+
+# include "nan_implementation_12_inl.h"
+
+#else // NODE_MODULE_VERSION >= 12
+
+# include "nan_implementation_pre_12_inl.h"
+
+#endif
+
+//=== API ======================================================================
+
+template <typename T>
+typename imp::Factory<T>::return_t
+New() {
+ return imp::Factory<T>::New();
+}
+
+template <typename T, typename A0>
+typename imp::Factory<T>::return_t
+New(A0 arg0) {
+ return imp::Factory<T>::New(arg0);
+}
+
+template <typename T, typename A0, typename A1>
+typename imp::Factory<T>::return_t
+New(A0 arg0, A1 arg1) {
+ return imp::Factory<T>::New(arg0, arg1);
+}
+
+template <typename T, typename A0, typename A1, typename A2>
+typename imp::Factory<T>::return_t
+New(A0 arg0, A1 arg1, A2 arg2) {
+ return imp::Factory<T>::New(arg0, arg1, arg2);
+}
+
+template <typename T, typename A0, typename A1, typename A2, typename A3>
+typename imp::Factory<T>::return_t
+New(A0 arg0, A1 arg1, A2 arg2, A3 arg3) {
+ return imp::Factory<T>::New(arg0, arg1, arg2, arg3);
+}
+
+// Note(agnat): When passing overloaded function pointers to template functions
+// as generic arguments the compiler needs help in picking the right overload.
+// These two functions handle New<Function> and New<FunctionTemplate> with
+// all argument variations.
+
+// v8::Function and v8::FunctionTemplate with one or two arguments
+template <typename T>
+typename imp::Factory<T>::return_t
+New( FunctionCallback callback
+ , v8::Local<v8::Value> data = v8::Local<v8::Value>()) {
+ return imp::Factory<T>::New(callback, data);
+}
+
+// v8::Function and v8::FunctionTemplate with three arguments
+template <typename T, typename A2>
+typename imp::Factory<T>::return_t
+New( FunctionCallback callback
+ , v8::Local<v8::Value> data = v8::Local<v8::Value>()
+ , A2 a2 = A2()) {
+ return imp::Factory<T>::New(callback, data, a2);
+}
+
+// Convenience
+
+#if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION
+template <typename T> inline v8::Local<T> New(v8::Handle<T> h);
+#endif
+
+#if NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
+template <typename T, typename M>
+ inline v8::Local<T> New(v8::Persistent<T, M> const& p);
+#else
+template <typename T> inline v8::Local<T> New(v8::Persistent<T> const& p);
+#endif
+template <typename T, typename M>
+inline v8::Local<T> New(Persistent<T, M> const& p);
+template <typename T>
+inline v8::Local<T> New(Global<T> const& p);
+
+inline
+imp::Factory<v8::Boolean>::return_t
+New(bool value) {
+ return New<v8::Boolean>(value);
+}
+
+inline
+imp::Factory<v8::Int32>::return_t
+New(int32_t value) {
+ return New<v8::Int32>(value);
+}
+
+inline
+imp::Factory<v8::Uint32>::return_t
+New(uint32_t value) {
+ return New<v8::Uint32>(value);
+}
+
+inline
+imp::Factory<v8::Number>::return_t
+New(double value) {
+ return New<v8::Number>(value);
+}
+
+inline
+imp::Factory<v8::String>::return_t
+New(std::string const& value) { // NOLINT(build/include_what_you_use)
+ return New<v8::String>(value);
+}
+
+inline
+imp::Factory<v8::String>::return_t
+New(const char * value, int length) {
+ return New<v8::String>(value, length);
+}
+
+inline
+imp::Factory<v8::String>::return_t
+New(const uint16_t * value, int length) {
+ return New<v8::String>(value, length);
+}
+
+inline
+imp::Factory<v8::String>::return_t
+New(const char * value) {
+ return New<v8::String>(value);
+}
+
+inline
+imp::Factory<v8::String>::return_t
+New(const uint16_t * value) {
+ return New<v8::String>(value);
+}
+
+inline
+imp::Factory<v8::String>::return_t
+New(v8::String::ExternalStringResource * value) {
+ return New<v8::String>(value);
+}
+
+inline
+imp::Factory<v8::String>::return_t
+New(ExternalOneByteStringResource * value) {
+ return New<v8::String>(value);
+}
+
+inline
+imp::Factory<v8::RegExp>::return_t
+New(v8::Local<v8::String> pattern, v8::RegExp::Flags flags) {
+ return New<v8::RegExp>(pattern, flags);
+}
+
+#endif // NAN_NEW_H_
diff --git a/node_modules/nan/nan_object_wrap.h b/node_modules/nan/nan_object_wrap.h
new file mode 100644
index 0000000..78712f9
--- /dev/null
+++ b/node_modules/nan/nan_object_wrap.h
@@ -0,0 +1,156 @@
+/*********************************************************************
+ * NAN - Native Abstractions for Node.js
+ *
+ * Copyright (c) 2018 NAN contributors
+ *
+ * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
+ ********************************************************************/
+
+#ifndef NAN_OBJECT_WRAP_H_
+#define NAN_OBJECT_WRAP_H_
+
+class ObjectWrap {
+ public:
+ ObjectWrap() {
+ refs_ = 0;
+ }
+
+
+ virtual ~ObjectWrap() {
+ if (persistent().IsEmpty()) {
+ return;
+ }
+
+ persistent().ClearWeak();
+ persistent().Reset();
+ }
+
+
+ template <class T>
+ static inline T* Unwrap(v8::Local<v8::Object> object) {
+ assert(!object.IsEmpty());
+ assert(object->InternalFieldCount() > 0);
+ // Cast to ObjectWrap before casting to T. A direct cast from void
+ // to T won't work right when T has more than one base class.
+ void* ptr = GetInternalFieldPointer(object, 0);
+ ObjectWrap* wrap = static_cast<ObjectWrap*>(ptr);
+ return static_cast<T*>(wrap);
+ }
+
+
+ inline v8::Local<v8::Object> handle() const {
+ return New(handle_);
+ }
+
+
+ inline Persistent<v8::Object>& persistent() {
+ return handle_;
+ }
+
+
+ protected:
+ inline void Wrap(v8::Local<v8::Object> object) {
+ assert(persistent().IsEmpty());
+ assert(object->InternalFieldCount() > 0);
+ SetInternalFieldPointer(object, 0, this);
+ persistent().Reset(object);
+ MakeWeak();
+ }
+
+#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
+ (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
+
+ inline void MakeWeak() {
+ persistent().v8::PersistentBase<v8::Object>::SetWeak(
+ this, WeakCallback, v8::WeakCallbackType::kParameter);
+#if NODE_MAJOR_VERSION < 10
+ // FIXME(bnoordhuis) Probably superfluous in older Node.js versions too.
+ persistent().MarkIndependent();
+#endif
+ }
+
+#elif NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
+
+ inline void MakeWeak() {
+ persistent().v8::PersistentBase<v8::Object>::SetWeak(this, WeakCallback);
+ persistent().MarkIndependent();
+ }
+
+#else
+
+ inline void MakeWeak() {
+ persistent().persistent.MakeWeak(this, WeakCallback);
+ persistent().MarkIndependent();
+ }
+
+#endif
+
+ /* Ref() marks the object as being attached to an event loop.
+ * Refed objects will not be garbage collected, even if
+ * all references are lost.
+ */
+ virtual void Ref() {
+ assert(!persistent().IsEmpty());
+ persistent().ClearWeak();
+ refs_++;
+ }
+
+ /* Unref() marks an object as detached from the event loop. This is its
+ * default state. When an object with a "weak" reference changes from
+ * attached to detached state it will be freed. Be careful not to access
+ * the object after making this call as it might be gone!
+ * (A "weak reference" means an object that only has a
+ * persistent handle.)
+ *
+ * DO NOT CALL THIS FROM DESTRUCTOR
+ */
+ virtual void Unref() {
+ assert(!persistent().IsEmpty());
+ assert(!persistent().IsWeak());
+ assert(refs_ > 0);
+ if (--refs_ == 0)
+ MakeWeak();
+ }
+
+ int refs_; // ro
+
+ private:
+ NAN_DISALLOW_ASSIGN_COPY_MOVE(ObjectWrap)
+#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
+ (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
+
+ static void
+ WeakCallback(v8::WeakCallbackInfo<ObjectWrap> const& info) {
+ ObjectWrap* wrap = info.GetParameter();
+ assert(wrap->refs_ == 0);
+ wrap->handle_.Reset();
+ delete wrap;
+ }
+
+#elif NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
+
+ static void
+ WeakCallback(v8::WeakCallbackData<v8::Object, ObjectWrap> const& data) {
+ ObjectWrap* wrap = data.GetParameter();
+ assert(wrap->refs_ == 0);
+ assert(wrap->handle_.IsNearDeath());
+ wrap->handle_.Reset();
+ delete wrap;
+ }
+
+#else
+
+ static void WeakCallback(v8::Persistent<v8::Value> value, void *data) {
+ ObjectWrap *wrap = static_cast<ObjectWrap*>(data);
+ assert(wrap->refs_ == 0);
+ assert(wrap->handle_.IsNearDeath());
+ wrap->handle_.Reset();
+ delete wrap;
+ }
+
+#endif
+ Persistent<v8::Object> handle_;
+};
+
+
+#endif // NAN_OBJECT_WRAP_H_
diff --git a/node_modules/nan/nan_persistent_12_inl.h b/node_modules/nan/nan_persistent_12_inl.h
new file mode 100644
index 0000000..d9649e8
--- /dev/null
+++ b/node_modules/nan/nan_persistent_12_inl.h
@@ -0,0 +1,132 @@
+/*********************************************************************
+ * NAN - Native Abstractions for Node.js
+ *
+ * Copyright (c) 2018 NAN contributors
+ *
+ * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
+ ********************************************************************/
+
+#ifndef NAN_PERSISTENT_12_INL_H_
+#define NAN_PERSISTENT_12_INL_H_
+
+template<typename T, typename M> class Persistent :
+ public v8::Persistent<T, M> {
+ public:
+ inline Persistent() : v8::Persistent<T, M>() {}
+
+ template<typename S> inline Persistent(v8::Local<S> that) :
+ v8::Persistent<T, M>(v8::Isolate::GetCurrent(), that) {}
+
+ template<typename S, typename M2>
+ inline
+ Persistent(const v8::Persistent<S, M2> &that) : // NOLINT(runtime/explicit)
+ v8::Persistent<T, M2>(v8::Isolate::GetCurrent(), that) {}
+
+ inline void Reset() { v8::PersistentBase<T>::Reset(); }
+
+ template <typename S>
+ inline void Reset(const v8::Local<S> &other) {
+ v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
+ }
+
+ template <typename S>
+ inline void Reset(const v8::PersistentBase<S> &other) {
+ v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
+ }
+
+ template<typename P>
+ inline void SetWeak(
+ P *parameter
+ , typename WeakCallbackInfo<P>::Callback callback
+ , WeakCallbackType type);
+
+ private:
+ inline T *operator*() const { return *PersistentBase<T>::persistent; }
+
+ template<typename S, typename M2>
+ inline void Copy(const Persistent<S, M2> &that) {
+ TYPE_CHECK(T, S);
+
+ this->Reset();
+
+ if (!that.IsEmpty()) {
+ this->Reset(that);
+ M::Copy(that, this);
+ }
+ }
+};
+
+#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
+ (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
+template<typename T>
+class Global : public v8::Global<T> {
+ public:
+ inline Global() : v8::Global<T>() {}
+
+ template<typename S> inline Global(v8::Local<S> that) :
+ v8::Global<T>(v8::Isolate::GetCurrent(), that) {}
+
+ template<typename S>
+ inline
+ Global(const v8::PersistentBase<S> &that) : // NOLINT(runtime/explicit)
+ v8::Global<S>(v8::Isolate::GetCurrent(), that) {}
+
+ inline void Reset() { v8::PersistentBase<T>::Reset(); }
+
+ template <typename S>
+ inline void Reset(const v8::Local<S> &other) {
+ v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
+ }
+
+ template <typename S>
+ inline void Reset(const v8::PersistentBase<S> &other) {
+ v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
+ }
+
+ template<typename P>
+ inline void SetWeak(
+ P *parameter
+ , typename WeakCallbackInfo<P>::Callback callback
+ , WeakCallbackType type) {
+ reinterpret_cast<Persistent<T>*>(this)->SetWeak(
+ parameter, callback, type);
+ }
+};
+#else
+template<typename T>
+class Global : public v8::UniquePersistent<T> {
+ public:
+ inline Global() : v8::UniquePersistent<T>() {}
+
+ template<typename S> inline Global(v8::Local<S> that) :
+ v8::UniquePersistent<T>(v8::Isolate::GetCurrent(), that) {}
+
+ template<typename S>
+ inline
+ Global(const v8::PersistentBase<S> &that) : // NOLINT(runtime/explicit)
+ v8::UniquePersistent<S>(v8::Isolate::GetCurrent(), that) {}
+
+ inline void Reset() { v8::PersistentBase<T>::Reset(); }
+
+ template <typename S>
+ inline void Reset(const v8::Local<S> &other) {
+ v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
+ }
+
+ template <typename S>
+ inline void Reset(const v8::PersistentBase<S> &other) {
+ v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
+ }
+
+ template<typename P>
+ inline void SetWeak(
+ P *parameter
+ , typename WeakCallbackInfo<P>::Callback callback
+ , WeakCallbackType type) {
+ reinterpret_cast<Persistent<T>*>(this)->SetWeak(
+ parameter, callback, type);
+ }
+};
+#endif
+
+#endif // NAN_PERSISTENT_12_INL_H_
diff --git a/node_modules/nan/nan_persistent_pre_12_inl.h b/node_modules/nan/nan_persistent_pre_12_inl.h
new file mode 100644
index 0000000..4c9c59d
--- /dev/null
+++ b/node_modules/nan/nan_persistent_pre_12_inl.h
@@ -0,0 +1,242 @@
+/*********************************************************************
+ * NAN - Native Abstractions for Node.js
+ *
+ * Copyright (c) 2018 NAN contributors
+ *
+ * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
+ ********************************************************************/
+
+#ifndef NAN_PERSISTENT_PRE_12_INL_H_
+#define NAN_PERSISTENT_PRE_12_INL_H_
+
+template<typename T>
+class PersistentBase {
+ v8::Persistent<T> persistent;
+ template<typename U>
+ friend v8::Local<U> New(const PersistentBase<U> &p);
+ template<typename U, typename M>
+ friend v8::Local<U> New(const Persistent<U, M> &p);
+ template<typename U>
+ friend v8::Local<U> New(const Global<U> &p);
+ template<typename S> friend class ReturnValue;
+
+ public:
+ inline PersistentBase() :
+ persistent() {}
+
+ inline void Reset() {
+ persistent.Dispose();
+ persistent.Clear();
+ }
+
+ template<typename S>
+ inline void Reset(const v8::Local<S> &other) {
+ TYPE_CHECK(T, S);
+
+ if (!persistent.IsEmpty()) {
+ persistent.Dispose();
+ }
+
+ if (other.IsEmpty()) {
+ persistent.Clear();
+ } else {
+ persistent = v8::Persistent<T>::New(other);
+ }
+ }
+
+ template<typename S>
+ inline void Reset(const PersistentBase<S> &other) {
+ TYPE_CHECK(T, S);
+
+ if (!persistent.IsEmpty()) {
+ persistent.Dispose();
+ }
+
+ if (other.IsEmpty()) {
+ persistent.Clear();
+ } else {
+ persistent = v8::Persistent<T>::New(other.persistent);
+ }
+ }
+
+ inline bool IsEmpty() const { return persistent.IsEmpty(); }
+
+ inline void Empty() { persistent.Clear(); }
+
+ template<typename S>
+ inline bool operator==(const PersistentBase<S> &that) const {
+ return this->persistent == that.persistent;
+ }
+
+ template<typename S>
+ inline bool operator==(const v8::Local<S> &that) const {
+ return this->persistent == that;
+ }
+
+ template<typename S>
+ inline bool operator!=(const PersistentBase<S> &that) const {
+ return !operator==(that);
+ }
+
+ template<typename S>
+ inline bool operator!=(const v8::Local<S> &that) const {
+ return !operator==(that);
+ }
+
+ template<typename P>
+ inline void SetWeak(
+ P *parameter
+ , typename WeakCallbackInfo<P>::Callback callback
+ , WeakCallbackType type);
+
+ inline void ClearWeak() { persistent.ClearWeak(); }
+
+ inline void MarkIndependent() { persistent.MarkIndependent(); }
+
+ inline bool IsIndependent() const { return persistent.IsIndependent(); }
+
+ inline bool IsNearDeath() const { return persistent.IsNearDeath(); }
+
+ inline bool IsWeak() const { return persistent.IsWeak(); }
+
+ private:
+ inline explicit PersistentBase(v8::Persistent<T> that) :
+ persistent(that) { }
+ inline explicit PersistentBase(T *val) : persistent(val) {}
+ template<typename S, typename M> friend class Persistent;
+ template<typename S> friend class Global;
+ friend class ObjectWrap;
+};
+
+template<typename T>
+class NonCopyablePersistentTraits {
+ public:
+ typedef Persistent<T, NonCopyablePersistentTraits<T> >
+ NonCopyablePersistent;
+ static const bool kResetInDestructor = false;
+ template<typename S, typename M>
+ inline static void Copy(const Persistent<S, M> &source,
+ NonCopyablePersistent *dest) {
+ Uncompilable<v8::Object>();
+ }
+
+ template<typename O> inline static void Uncompilable() {
+ TYPE_CHECK(O, v8::Primitive);
+ }
+};
+
+template<typename T>
+struct CopyablePersistentTraits {
+ typedef Persistent<T, CopyablePersistentTraits<T> > CopyablePersistent;
+ static const bool kResetInDestructor = true;
+ template<typename S, typename M>
+ static inline void Copy(const Persistent<S, M> &source,
+ CopyablePersistent *dest) {}
+};
+
+template<typename T, typename M> class Persistent :
+ public PersistentBase<T> {
+ public:
+ inline Persistent() {}
+
+ template<typename S> inline Persistent(v8::Handle<S> that)
+ : PersistentBase<T>(v8::Persistent<T>::New(that)) {
+ TYPE_CHECK(T, S);
+ }
+
+ inline Persistent(const Persistent &that) : PersistentBase<T>() {
+ Copy(that);
+ }
+
+ template<typename S, typename M2>
+ inline Persistent(const Persistent<S, M2> &that) :
+ PersistentBase<T>() {
+ Copy(that);
+ }
+
+ inline Persistent &operator=(const Persistent &that) {
+ Copy(that);
+ return *this;
+ }
+
+ template <class S, class M2>
+ inline Persistent &operator=(const Persistent<S, M2> &that) {
+ Copy(that);
+ return *this;
+ }
+
+ inline ~Persistent() {
+ if (M::kResetInDestructor) this->Reset();
+ }
+
+ private:
+ inline T *operator*() const { return *PersistentBase<T>::persistent; }
+
+ template<typename S, typename M2>
+ inline void Copy(const Persistent<S, M2> &that) {
+ TYPE_CHECK(T, S);
+
+ this->Reset();
+
+ if (!that.IsEmpty()) {
+ this->persistent = v8::Persistent<T>::New(that.persistent);
+ M::Copy(that, this);
+ }
+ }
+};
+
+template<typename T>
+class Global : public PersistentBase<T> {
+ struct RValue {
+ inline explicit RValue(Global* obj) : object(obj) {}
+ Global* object;
+ };
+
+ public:
+ inline Global() : PersistentBase<T>(0) { }
+
+ template <typename S>
+ inline Global(v8::Local<S> that) // NOLINT(runtime/explicit)
+ : PersistentBase<T>(v8::Persistent<T>::New(that)) {
+ TYPE_CHECK(T, S);
+ }
+
+ template <typename S>
+ inline Global(const PersistentBase<S> &that) // NOLINT(runtime/explicit)
+ : PersistentBase<T>(that) {
+ TYPE_CHECK(T, S);
+ }
+ /**
+ * Move constructor.
+ */
+ inline Global(RValue rvalue) // NOLINT(runtime/explicit)
+ : PersistentBase<T>(rvalue.object->persistent) {
+ rvalue.object->Reset();
+ }
+ inline ~Global() { this->Reset(); }
+ /**
+ * Move via assignment.
+ */
+ template<typename S>
+ inline Global &operator=(Global<S> rhs) {
+ TYPE_CHECK(T, S);
+ this->Reset(rhs.persistent);
+ rhs.Reset();
+ return *this;
+ }
+ /**
+ * Cast operator for moves.
+ */
+ inline operator RValue() { return RValue(this); }
+ /**
+ * Pass allows returning uniques from functions, etc.
+ */
+ Global Pass() { return Global(RValue(this)); }
+
+ private:
+ Global(Global &);
+ void operator=(Global &);
+ template<typename S> friend class ReturnValue;
+};
+
+#endif // NAN_PERSISTENT_PRE_12_INL_H_
diff --git a/node_modules/nan/nan_private.h b/node_modules/nan/nan_private.h
new file mode 100644
index 0000000..15f44cc
--- /dev/null
+++ b/node_modules/nan/nan_private.h
@@ -0,0 +1,73 @@
+/*********************************************************************
+ * NAN - Native Abstractions for Node.js
+ *
+ * Copyright (c) 2018 NAN contributors
+ *
+ * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
+ ********************************************************************/
+
+#ifndef NAN_PRIVATE_H_
+#define NAN_PRIVATE_H_
+
+inline Maybe<bool>
+HasPrivate(v8::Local<v8::Object> object, v8::Local<v8::String> key) {
+ HandleScope scope;
+#if NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::Local<v8::Context> context = isolate->GetCurrentContext();
+ v8::Local<v8::Private> private_key = v8::Private::ForApi(isolate, key);
+ return object->HasPrivate(context, private_key);
+#else
+ return Just(!object->GetHiddenValue(key).IsEmpty());
+#endif
+}
+
+inline MaybeLocal<v8::Value>
+GetPrivate(v8::Local<v8::Object> object, v8::Local<v8::String> key) {
+#if NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::EscapableHandleScope scope(isolate);
+ v8::Local<v8::Context> context = isolate->GetCurrentContext();
+ v8::Local<v8::Private> private_key = v8::Private::ForApi(isolate, key);
+ v8::MaybeLocal<v8::Value> v = object->GetPrivate(context, private_key);
+ return scope.Escape(v.ToLocalChecked());
+#else
+ EscapableHandleScope scope;
+ v8::Local<v8::Value> v = object->GetHiddenValue(key);
+ if (v.IsEmpty()) {
+ v = Undefined();
+ }
+ return scope.Escape(v);
+#endif
+}
+
+inline Maybe<bool> SetPrivate(
+ v8::Local<v8::Object> object,
+ v8::Local<v8::String> key,
+ v8::Local<v8::Value> value) {
+#if NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION
+ HandleScope scope;
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::Local<v8::Context> context = isolate->GetCurrentContext();
+ v8::Local<v8::Private> private_key = v8::Private::ForApi(isolate, key);
+ return object->SetPrivate(context, private_key, value);
+#else
+ return Just(object->SetHiddenValue(key, value));
+#endif
+}
+
+inline Maybe<bool> DeletePrivate(
+ v8::Local<v8::Object> object,
+ v8::Local<v8::String> key) {
+#if NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION
+ HandleScope scope;
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::Local<v8::Private> private_key = v8::Private::ForApi(isolate, key);
+ return object->DeletePrivate(isolate->GetCurrentContext(), private_key);
+#else
+ return Just(object->DeleteHiddenValue(key));
+#endif
+}
+
+#endif // NAN_PRIVATE_H_
+
diff --git a/node_modules/nan/nan_scriptorigin.h b/node_modules/nan/nan_scriptorigin.h
new file mode 100644
index 0000000..ce79cdf
--- /dev/null
+++ b/node_modules/nan/nan_scriptorigin.h
@@ -0,0 +1,76 @@
+/*********************************************************************
+ * NAN - Native Abstractions for Node.js
+ *
+ * Copyright (c) 2021 NAN contributors
+ *
+ * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
+ ********************************************************************/
+
+#ifndef NAN_SCRIPTORIGIN_H_
+#define NAN_SCRIPTORIGIN_H_
+
+class ScriptOrigin : public v8::ScriptOrigin {
+ public:
+#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 9 || \
+ (V8_MAJOR_VERSION == 9 && (defined(V8_MINOR_VERSION) && (V8_MINOR_VERSION > 0\
+ || (V8_MINOR_VERSION == 0 && defined(V8_BUILD_NUMBER) \
+ && V8_BUILD_NUMBER >= 1)))))
+ explicit ScriptOrigin(v8::Local<v8::Value> name) :
+ v8::ScriptOrigin(v8::Isolate::GetCurrent(), name) {}
+
+ ScriptOrigin(v8::Local<v8::Value> name
+ , v8::Local<v8::Integer> line) :
+ v8::ScriptOrigin(v8::Isolate::GetCurrent()
+ , name
+ , To<int32_t>(line).FromMaybe(0)) {}
+
+ ScriptOrigin(v8::Local<v8::Value> name
+ , v8::Local<v8::Integer> line
+ , v8::Local<v8::Integer> column) :
+ v8::ScriptOrigin(v8::Isolate::GetCurrent()
+ , name
+ , To<int32_t>(line).FromMaybe(0)
+ , To<int32_t>(column).FromMaybe(0)) {}
+#elif defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 8 || \
+ (V8_MAJOR_VERSION == 8 && (defined(V8_MINOR_VERSION) && (V8_MINOR_VERSION > 9\
+ || (V8_MINOR_VERSION == 9 && defined(V8_BUILD_NUMBER) \
+ && V8_BUILD_NUMBER >= 45)))))
+ explicit ScriptOrigin(v8::Local<v8::Value> name) : v8::ScriptOrigin(name) {}
+
+ ScriptOrigin(v8::Local<v8::Value> name
+ , v8::Local<v8::Integer> line) :
+ v8::ScriptOrigin(name, To<int32_t>(line).FromMaybe(0)) {}
+
+ ScriptOrigin(v8::Local<v8::Value> name
+ , v8::Local<v8::Integer> line
+ , v8::Local<v8::Integer> column) :
+ v8::ScriptOrigin(name
+ , To<int32_t>(line).FromMaybe(0)
+ , To<int32_t>(column).FromMaybe(0)) {}
+#else
+ explicit ScriptOrigin(v8::Local<v8::Value> name) : v8::ScriptOrigin(name) {}
+
+ ScriptOrigin(v8::Local<v8::Value> name
+ , v8::Local<v8::Integer> line) : v8::ScriptOrigin(name, line) {}
+
+ ScriptOrigin(v8::Local<v8::Value> name
+ , v8::Local<v8::Integer> line
+ , v8::Local<v8::Integer> column) :
+ v8::ScriptOrigin(name, line, column) {}
+#endif
+
+#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 8 || \
+ (V8_MAJOR_VERSION == 8 && (defined(V8_MINOR_VERSION) && (V8_MINOR_VERSION > 9\
+ || (V8_MINOR_VERSION == 9 && defined(V8_BUILD_NUMBER) \
+ && V8_BUILD_NUMBER >= 45)))))
+ v8::Local<v8::Integer> ResourceLineOffset() const {
+ return New(LineOffset());
+ }
+
+ v8::Local<v8::Integer> ResourceColumnOffset() const {
+ return New(ColumnOffset());
+ }
+#endif
+};
+
+#endif // NAN_SCRIPTORIGIN_H_
diff --git a/node_modules/nan/nan_string_bytes.h b/node_modules/nan/nan_string_bytes.h
new file mode 100644
index 0000000..a2e6437
--- /dev/null
+++ b/node_modules/nan/nan_string_bytes.h
@@ -0,0 +1,305 @@
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+#ifndef NAN_STRING_BYTES_H_
+#define NAN_STRING_BYTES_H_
+
+// Decodes a v8::Local<v8::String> or Buffer to a raw char*
+
+namespace imp {
+
+using v8::Local;
+using v8::Object;
+using v8::String;
+using v8::Value;
+
+
+//// Base 64 ////
+
+#define base64_encoded_size(size) ((size + 2 - ((size + 2) % 3)) / 3 * 4)
+
+
+
+//// HEX ////
+
+static bool contains_non_ascii_slow(const char* buf, size_t len) {
+ for (size_t i = 0; i < len; ++i) {
+ if (buf[i] & 0x80) return true;
+ }
+ return false;
+}
+
+
+static bool contains_non_ascii(const char* src, size_t len) {
+ if (len < 16) {
+ return contains_non_ascii_slow(src, len);
+ }
+
+ const unsigned bytes_per_word = sizeof(void*);
+ const unsigned align_mask = bytes_per_word - 1;
+ const unsigned unaligned = reinterpret_cast<uintptr_t>(src) & align_mask;
+
+ if (unaligned > 0) {
+ const unsigned n = bytes_per_word - unaligned;
+ if (contains_non_ascii_slow(src, n)) return true;
+ src += n;
+ len -= n;
+ }
+
+
+#if defined(__x86_64__) || defined(_WIN64)
+ const uintptr_t mask = 0x8080808080808080ll;
+#else
+ const uintptr_t mask = 0x80808080l;
+#endif
+
+ const uintptr_t* srcw = reinterpret_cast<const uintptr_t*>(src);
+
+ for (size_t i = 0, n = len / bytes_per_word; i < n; ++i) {
+ if (srcw[i] & mask) return true;
+ }
+
+ const unsigned remainder = len & align_mask;
+ if (remainder > 0) {
+ const size_t offset = len - remainder;
+ if (contains_non_ascii_slow(src + offset, remainder)) return true;
+ }
+
+ return false;
+}
+
+
+static void force_ascii_slow(const char* src, char* dst, size_t len) {
+ for (size_t i = 0; i < len; ++i) {
+ dst[i] = src[i] & 0x7f;
+ }
+}
+
+
+static void force_ascii(const char* src, char* dst, size_t len) {
+ if (len < 16) {
+ force_ascii_slow(src, dst, len);
+ return;
+ }
+
+ const unsigned bytes_per_word = sizeof(void*);
+ const unsigned align_mask = bytes_per_word - 1;
+ const unsigned src_unalign = reinterpret_cast<uintptr_t>(src) & align_mask;
+ const unsigned dst_unalign = reinterpret_cast<uintptr_t>(dst) & align_mask;
+
+ if (src_unalign > 0) {
+ if (src_unalign == dst_unalign) {
+ const unsigned unalign = bytes_per_word - src_unalign;
+ force_ascii_slow(src, dst, unalign);
+ src += unalign;
+ dst += unalign;
+ len -= src_unalign;
+ } else {
+ force_ascii_slow(src, dst, len);
+ return;
+ }
+ }
+
+#if defined(__x86_64__) || defined(_WIN64)
+ const uintptr_t mask = ~0x8080808080808080ll;
+#else
+ const uintptr_t mask = ~0x80808080l;
+#endif
+
+ const uintptr_t* srcw = reinterpret_cast<const uintptr_t*>(src);
+ uintptr_t* dstw = reinterpret_cast<uintptr_t*>(dst);
+
+ for (size_t i = 0, n = len / bytes_per_word; i < n; ++i) {
+ dstw[i] = srcw[i] & mask;
+ }
+
+ const unsigned remainder = len & align_mask;
+ if (remainder > 0) {
+ const size_t offset = len - remainder;
+ force_ascii_slow(src + offset, dst + offset, remainder);
+ }
+}
+
+
+static size_t base64_encode(const char* src,
+ size_t slen,
+ char* dst,
+ size_t dlen) {
+ // We know how much we'll write, just make sure that there's space.
+ assert(dlen >= base64_encoded_size(slen) &&
+ "not enough space provided for base64 encode");
+
+ dlen = base64_encoded_size(slen);
+
+ unsigned a;
+ unsigned b;
+ unsigned c;
+ unsigned i;
+ unsigned k;
+ unsigned n;
+
+ static const char table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz"
+ "0123456789+/";
+
+ i = 0;
+ k = 0;
+ n = slen / 3 * 3;
+
+ while (i < n) {
+ a = src[i + 0] & 0xff;
+ b = src[i + 1] & 0xff;
+ c = src[i + 2] & 0xff;
+
+ dst[k + 0] = table[a >> 2];
+ dst[k + 1] = table[((a & 3) << 4) | (b >> 4)];
+ dst[k + 2] = table[((b & 0x0f) << 2) | (c >> 6)];
+ dst[k + 3] = table[c & 0x3f];
+
+ i += 3;
+ k += 4;
+ }
+
+ if (n != slen) {
+ switch (slen - n) {
+ case 1:
+ a = src[i + 0] & 0xff;
+ dst[k + 0] = table[a >> 2];
+ dst[k + 1] = table[(a & 3) << 4];
+ dst[k + 2] = '=';
+ dst[k + 3] = '=';
+ break;
+
+ case 2:
+ a = src[i + 0] & 0xff;
+ b = src[i + 1] & 0xff;
+ dst[k + 0] = table[a >> 2];
+ dst[k + 1] = table[((a & 3) << 4) | (b >> 4)];
+ dst[k + 2] = table[(b & 0x0f) << 2];
+ dst[k + 3] = '=';
+ break;
+ }
+ }
+
+ return dlen;
+}
+
+
+static size_t hex_encode(const char* src, size_t slen, char* dst, size_t dlen) {
+ // We know how much we'll write, just make sure that there's space.
+ assert(dlen >= slen * 2 &&
+ "not enough space provided for hex encode");
+
+ dlen = slen * 2;
+ for (uint32_t i = 0, k = 0; k < dlen; i += 1, k += 2) {
+ static const char hex[] = "0123456789abcdef";
+ uint8_t val = static_cast<uint8_t>(src[i]);
+ dst[k + 0] = hex[val >> 4];
+ dst[k + 1] = hex[val & 15];
+ }
+
+ return dlen;
+}
+
+
+
+static Local<Value> Encode(const char* buf,
+ size_t buflen,
+ enum Encoding encoding) {
+ assert(buflen <= node::Buffer::kMaxLength);
+ if (!buflen && encoding != BUFFER)
+ return New("").ToLocalChecked();
+
+ Local<String> val;
+ switch (encoding) {
+ case BUFFER:
+ return CopyBuffer(buf, buflen).ToLocalChecked();
+
+ case ASCII:
+ if (contains_non_ascii(buf, buflen)) {
+ char* out = new char[buflen];
+ force_ascii(buf, out, buflen);
+ val = New<String>(out, buflen).ToLocalChecked();
+ delete[] out;
+ } else {
+ val = New<String>(buf, buflen).ToLocalChecked();
+ }
+ break;
+
+ case UTF8:
+ val = New<String>(buf, buflen).ToLocalChecked();
+ break;
+
+ case BINARY: {
+ // TODO(isaacs) use ExternalTwoByteString?
+ const unsigned char *cbuf = reinterpret_cast<const unsigned char*>(buf);
+ uint16_t * twobytebuf = new uint16_t[buflen];
+ for (size_t i = 0; i < buflen; i++) {
+ // XXX is the following line platform independent?
+ twobytebuf[i] = cbuf[i];
+ }
+ val = New<String>(twobytebuf, buflen).ToLocalChecked();
+ delete[] twobytebuf;
+ break;
+ }
+
+ case BASE64: {
+ size_t dlen = base64_encoded_size(buflen);
+ char* dst = new char[dlen];
+
+ size_t written = base64_encode(buf, buflen, dst, dlen);
+ assert(written == dlen);
+
+ val = New<String>(dst, dlen).ToLocalChecked();
+ delete[] dst;
+ break;
+ }
+
+ case UCS2: {
+ const uint16_t* data = reinterpret_cast<const uint16_t*>(buf);
+ val = New<String>(data, buflen / 2).ToLocalChecked();
+ break;
+ }
+
+ case HEX: {
+ size_t dlen = buflen * 2;
+ char* dst = new char[dlen];
+ size_t written = hex_encode(buf, buflen, dst, dlen);
+ assert(written == dlen);
+
+ val = New<String>(dst, dlen).ToLocalChecked();
+ delete[] dst;
+ break;
+ }
+
+ default:
+ assert(0 && "unknown encoding");
+ break;
+ }
+
+ return val;
+}
+
+#undef base64_encoded_size
+
+} // end of namespace imp
+
+#endif // NAN_STRING_BYTES_H_
diff --git a/node_modules/nan/nan_typedarray_contents.h b/node_modules/nan/nan_typedarray_contents.h
new file mode 100644
index 0000000..c6ac8a4
--- /dev/null
+++ b/node_modules/nan/nan_typedarray_contents.h
@@ -0,0 +1,96 @@
+/*********************************************************************
+ * NAN - Native Abstractions for Node.js
+ *
+ * Copyright (c) 2018 NAN contributors
+ *
+ * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
+ ********************************************************************/
+
+#ifndef NAN_TYPEDARRAY_CONTENTS_H_
+#define NAN_TYPEDARRAY_CONTENTS_H_
+
+template<typename T>
+class TypedArrayContents {
+ public:
+ inline explicit TypedArrayContents(v8::Local<v8::Value> from) :
+ length_(0), data_(NULL) {
+ HandleScope scope;
+
+ size_t length = 0;
+ void* data = NULL;
+
+#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
+ (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
+
+ if (from->IsArrayBufferView()) {
+ v8::Local<v8::ArrayBufferView> array =
+ v8::Local<v8::ArrayBufferView>::Cast(from);
+
+ const size_t byte_length = array->ByteLength();
+ const ptrdiff_t byte_offset = array->ByteOffset();
+ v8::Local<v8::ArrayBuffer> buffer = array->Buffer();
+
+ length = byte_length / sizeof(T);
+// Actually it's 7.9 here but this would lead to ABI issues with Node.js 13
+// using 7.8 till 13.2.0.
+#if (V8_MAJOR_VERSION >= 8)
+ data = static_cast<char*>(buffer->GetBackingStore()->Data()) + byte_offset;
+#else
+ data = static_cast<char*>(buffer->GetContents().Data()) + byte_offset;
+#endif
+ }
+
+#else
+
+ if (from->IsObject() && !from->IsNull()) {
+ v8::Local<v8::Object> array = v8::Local<v8::Object>::Cast(from);
+
+ MaybeLocal<v8::Value> buffer = Get(array,
+ New<v8::String>("buffer").ToLocalChecked());
+ MaybeLocal<v8::Value> byte_length = Get(array,
+ New<v8::String>("byteLength").ToLocalChecked());
+ MaybeLocal<v8::Value> byte_offset = Get(array,
+ New<v8::String>("byteOffset").ToLocalChecked());
+
+ if (!buffer.IsEmpty() &&
+ !byte_length.IsEmpty() && byte_length.ToLocalChecked()->IsUint32() &&
+ !byte_offset.IsEmpty() && byte_offset.ToLocalChecked()->IsUint32()) {
+ data = array->GetIndexedPropertiesExternalArrayData();
+ if(data) {
+ length = byte_length.ToLocalChecked()->Uint32Value() / sizeof(T);
+ }
+ }
+ }
+
+#endif
+
+#if defined(_MSC_VER) && _MSC_VER >= 1900 || __cplusplus >= 201103L
+ assert(reinterpret_cast<uintptr_t>(data) % alignof (T) == 0);
+#elif defined(_MSC_VER) && _MSC_VER >= 1600 || defined(__GNUC__)
+ assert(reinterpret_cast<uintptr_t>(data) % __alignof(T) == 0);
+#else
+ assert(reinterpret_cast<uintptr_t>(data) % sizeof (T) == 0);
+#endif
+
+ length_ = length;
+ data_ = static_cast<T*>(data);
+ }
+
+ inline size_t length() const { return length_; }
+ inline T* operator*() { return data_; }
+ inline const T* operator*() const { return data_; }
+
+ private:
+ NAN_DISALLOW_ASSIGN_COPY_MOVE(TypedArrayContents)
+
+ //Disable heap allocation
+ void *operator new(size_t size);
+ void operator delete(void *, size_t) {
+ abort();
+ }
+
+ size_t length_;
+ T* data_;
+};
+
+#endif // NAN_TYPEDARRAY_CONTENTS_H_
diff --git a/node_modules/nan/nan_weak.h b/node_modules/nan/nan_weak.h
new file mode 100644
index 0000000..7e7ab07
--- /dev/null
+++ b/node_modules/nan/nan_weak.h
@@ -0,0 +1,437 @@
+/*********************************************************************
+ * NAN - Native Abstractions for Node.js
+ *
+ * Copyright (c) 2018 NAN contributors
+ *
+ * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
+ ********************************************************************/
+
+#ifndef NAN_WEAK_H_
+#define NAN_WEAK_H_
+
+static const int kInternalFieldsInWeakCallback = 2;
+static const int kNoInternalFieldIndex = -1;
+
+#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
+ (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
+# define NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ \
+ v8::WeakCallbackInfo<WeakCallbackInfo<T> > const&
+# define NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_ \
+ NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_
+# define NAN_WEAK_PARAMETER_CALLBACK_SIG_ NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_
+# define NAN_WEAK_TWOFIELD_CALLBACK_SIG_ NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_
+#elif NODE_MODULE_VERSION > IOJS_1_1_MODULE_VERSION
+# define NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ \
+ v8::PhantomCallbackData<WeakCallbackInfo<T> > const&
+# define NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_ \
+ NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_
+# define NAN_WEAK_PARAMETER_CALLBACK_SIG_ NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_
+# define NAN_WEAK_TWOFIELD_CALLBACK_SIG_ NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_
+#elif NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION
+# define NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ \
+ v8::PhantomCallbackData<WeakCallbackInfo<T> > const&
+# define NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_ \
+ v8::InternalFieldsCallbackData<WeakCallbackInfo<T>, void> const&
+# define NAN_WEAK_PARAMETER_CALLBACK_SIG_ NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_
+# define NAN_WEAK_TWOFIELD_CALLBACK_SIG_ NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_
+#elif NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
+# define NAN_WEAK_CALLBACK_DATA_TYPE_ \
+ v8::WeakCallbackData<S, WeakCallbackInfo<T> > const&
+# define NAN_WEAK_CALLBACK_SIG_ NAN_WEAK_CALLBACK_DATA_TYPE_
+#else
+# define NAN_WEAK_CALLBACK_DATA_TYPE_ void *
+# define NAN_WEAK_CALLBACK_SIG_ \
+ v8::Persistent<v8::Value>, NAN_WEAK_CALLBACK_DATA_TYPE_
+#endif
+
+template<typename T>
+class WeakCallbackInfo {
+ public:
+ typedef void (*Callback)(const WeakCallbackInfo<T>& data);
+ WeakCallbackInfo(
+ Persistent<v8::Value> *persistent
+ , Callback callback
+ , void *parameter
+ , void *field1 = 0
+ , void *field2 = 0) :
+ callback_(callback), isolate_(0), parameter_(parameter) {
+ std::memcpy(&persistent_, persistent, sizeof (v8::Persistent<v8::Value>));
+ internal_fields_[0] = field1;
+ internal_fields_[1] = field2;
+ }
+ inline v8::Isolate *GetIsolate() const { return isolate_; }
+ inline T *GetParameter() const { return static_cast<T*>(parameter_); }
+ inline void *GetInternalField(int index) const {
+ assert((index == 0 || index == 1) && "internal field index out of bounds");
+ if (index == 0) {
+ return internal_fields_[0];
+ } else {
+ return internal_fields_[1];
+ }
+ }
+
+ private:
+ NAN_DISALLOW_ASSIGN_COPY_MOVE(WeakCallbackInfo)
+ Callback callback_;
+ v8::Isolate *isolate_;
+ void *parameter_;
+ void *internal_fields_[kInternalFieldsInWeakCallback];
+ v8::Persistent<v8::Value> persistent_;
+ template<typename S, typename M> friend class Persistent;
+ template<typename S> friend class PersistentBase;
+#if NODE_MODULE_VERSION <= NODE_0_12_MODULE_VERSION
+# if NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
+ template<typename S>
+ static void invoke(NAN_WEAK_CALLBACK_SIG_ data);
+ template<typename S>
+ static WeakCallbackInfo *unwrap(NAN_WEAK_CALLBACK_DATA_TYPE_ data);
+# else
+ static void invoke(NAN_WEAK_CALLBACK_SIG_ data);
+ static WeakCallbackInfo *unwrap(NAN_WEAK_CALLBACK_DATA_TYPE_ data);
+# endif
+#else
+# if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
+ (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
+ template<bool isFirstPass>
+ static void invokeparameter(NAN_WEAK_PARAMETER_CALLBACK_SIG_ data);
+ template<bool isFirstPass>
+ static void invoketwofield(NAN_WEAK_TWOFIELD_CALLBACK_SIG_ data);
+# else
+ static void invokeparameter(NAN_WEAK_PARAMETER_CALLBACK_SIG_ data);
+ static void invoketwofield(NAN_WEAK_TWOFIELD_CALLBACK_SIG_ data);
+# endif
+ static WeakCallbackInfo *unwrapparameter(
+ NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ data);
+ static WeakCallbackInfo *unwraptwofield(
+ NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_ data);
+#endif
+};
+
+
+#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
+ (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
+
+template<typename T>
+template<bool isFirstPass>
+void
+WeakCallbackInfo<T>::invokeparameter(NAN_WEAK_PARAMETER_CALLBACK_SIG_ data) {
+ WeakCallbackInfo<T> *cbinfo = unwrapparameter(data);
+ if (isFirstPass) {
+ cbinfo->persistent_.Reset();
+ data.SetSecondPassCallback(invokeparameter<false>);
+ } else {
+ cbinfo->callback_(*cbinfo);
+ delete cbinfo;
+ }
+}
+
+template<typename T>
+template<bool isFirstPass>
+void
+WeakCallbackInfo<T>::invoketwofield(NAN_WEAK_TWOFIELD_CALLBACK_SIG_ data) {
+ WeakCallbackInfo<T> *cbinfo = unwraptwofield(data);
+ if (isFirstPass) {
+ cbinfo->persistent_.Reset();
+ data.SetSecondPassCallback(invoketwofield<false>);
+ } else {
+ cbinfo->callback_(*cbinfo);
+ delete cbinfo;
+ }
+}
+
+template<typename T>
+WeakCallbackInfo<T> *WeakCallbackInfo<T>::unwrapparameter(
+ NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ data) {
+ WeakCallbackInfo<T> *cbinfo =
+ static_cast<WeakCallbackInfo<T>*>(data.GetParameter());
+ cbinfo->isolate_ = data.GetIsolate();
+ return cbinfo;
+}
+
+template<typename T>
+WeakCallbackInfo<T> *WeakCallbackInfo<T>::unwraptwofield(
+ NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_ data) {
+ WeakCallbackInfo<T> *cbinfo =
+ static_cast<WeakCallbackInfo<T>*>(data.GetInternalField(0));
+ cbinfo->isolate_ = data.GetIsolate();
+ return cbinfo;
+}
+
+#undef NAN_WEAK_PARAMETER_CALLBACK_SIG_
+#undef NAN_WEAK_TWOFIELD_CALLBACK_SIG_
+#undef NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_
+#undef NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_
+# elif NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION
+
+template<typename T>
+void
+WeakCallbackInfo<T>::invokeparameter(NAN_WEAK_PARAMETER_CALLBACK_SIG_ data) {
+ WeakCallbackInfo<T> *cbinfo = unwrapparameter(data);
+ cbinfo->persistent_.Reset();
+ cbinfo->callback_(*cbinfo);
+ delete cbinfo;
+}
+
+template<typename T>
+void
+WeakCallbackInfo<T>::invoketwofield(NAN_WEAK_TWOFIELD_CALLBACK_SIG_ data) {
+ WeakCallbackInfo<T> *cbinfo = unwraptwofield(data);
+ cbinfo->persistent_.Reset();
+ cbinfo->callback_(*cbinfo);
+ delete cbinfo;
+}
+
+template<typename T>
+WeakCallbackInfo<T> *WeakCallbackInfo<T>::unwrapparameter(
+ NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ data) {
+ WeakCallbackInfo<T> *cbinfo =
+ static_cast<WeakCallbackInfo<T>*>(data.GetParameter());
+ cbinfo->isolate_ = data.GetIsolate();
+ return cbinfo;
+}
+
+template<typename T>
+WeakCallbackInfo<T> *WeakCallbackInfo<T>::unwraptwofield(
+ NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_ data) {
+ WeakCallbackInfo<T> *cbinfo =
+ static_cast<WeakCallbackInfo<T>*>(data.GetInternalField1());
+ cbinfo->isolate_ = data.GetIsolate();
+ return cbinfo;
+}
+
+#undef NAN_WEAK_PARAMETER_CALLBACK_SIG_
+#undef NAN_WEAK_TWOFIELD_CALLBACK_SIG_
+#undef NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_
+#undef NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_
+#elif NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
+
+template<typename T>
+template<typename S>
+void WeakCallbackInfo<T>::invoke(NAN_WEAK_CALLBACK_SIG_ data) {
+ WeakCallbackInfo<T> *cbinfo = unwrap(data);
+ cbinfo->persistent_.Reset();
+ cbinfo->callback_(*cbinfo);
+ delete cbinfo;
+}
+
+template<typename T>
+template<typename S>
+WeakCallbackInfo<T> *WeakCallbackInfo<T>::unwrap(
+ NAN_WEAK_CALLBACK_DATA_TYPE_ data) {
+ void *parameter = data.GetParameter();
+ WeakCallbackInfo<T> *cbinfo =
+ static_cast<WeakCallbackInfo<T>*>(parameter);
+ cbinfo->isolate_ = data.GetIsolate();
+ return cbinfo;
+}
+
+#undef NAN_WEAK_CALLBACK_SIG_
+#undef NAN_WEAK_CALLBACK_DATA_TYPE_
+#else
+
+template<typename T>
+void WeakCallbackInfo<T>::invoke(NAN_WEAK_CALLBACK_SIG_ data) {
+ WeakCallbackInfo<T> *cbinfo = unwrap(data);
+ cbinfo->persistent_.Dispose();
+ cbinfo->persistent_.Clear();
+ cbinfo->callback_(*cbinfo);
+ delete cbinfo;
+}
+
+template<typename T>
+WeakCallbackInfo<T> *WeakCallbackInfo<T>::unwrap(
+ NAN_WEAK_CALLBACK_DATA_TYPE_ data) {
+ WeakCallbackInfo<T> *cbinfo =
+ static_cast<WeakCallbackInfo<T>*>(data);
+ cbinfo->isolate_ = v8::Isolate::GetCurrent();
+ return cbinfo;
+}
+
+#undef NAN_WEAK_CALLBACK_SIG_
+#undef NAN_WEAK_CALLBACK_DATA_TYPE_
+#endif
+
+#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
+ (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
+template<typename T, typename M>
+template<typename P>
+inline void Persistent<T, M>::SetWeak(
+ P *parameter
+ , typename WeakCallbackInfo<P>::Callback callback
+ , WeakCallbackType type) {
+ WeakCallbackInfo<P> *wcbd;
+ if (type == WeakCallbackType::kParameter) {
+ wcbd = new WeakCallbackInfo<P>(
+ reinterpret_cast<Persistent<v8::Value>*>(this)
+ , callback
+ , parameter);
+ v8::PersistentBase<T>::SetWeak(
+ wcbd
+ , WeakCallbackInfo<P>::template invokeparameter<true>
+ , type);
+ } else {
+ v8::Local<v8::Value>* self_v(reinterpret_cast<v8::Local<v8::Value>*>(this));
+ assert((*self_v)->IsObject());
+ v8::Local<v8::Object> self((*self_v).As<v8::Object>());
+ int count = self->InternalFieldCount();
+ void *internal_fields[kInternalFieldsInWeakCallback] = {0, 0};
+ for (int i = 0; i < count && i < kInternalFieldsInWeakCallback; i++) {
+ internal_fields[i] = self->GetAlignedPointerFromInternalField(i);
+ }
+ wcbd = new WeakCallbackInfo<P>(
+ reinterpret_cast<Persistent<v8::Value>*>(this)
+ , callback
+ , 0
+ , internal_fields[0]
+ , internal_fields[1]);
+ self->SetAlignedPointerInInternalField(0, wcbd);
+ v8::PersistentBase<T>::SetWeak(
+ static_cast<WeakCallbackInfo<P>*>(0)
+ , WeakCallbackInfo<P>::template invoketwofield<true>
+ , type);
+ }
+}
+#elif NODE_MODULE_VERSION > IOJS_1_1_MODULE_VERSION
+template<typename T, typename M>
+template<typename P>
+inline void Persistent<T, M>::SetWeak(
+ P *parameter
+ , typename WeakCallbackInfo<P>::Callback callback
+ , WeakCallbackType type) {
+ WeakCallbackInfo<P> *wcbd;
+ if (type == WeakCallbackType::kParameter) {
+ wcbd = new WeakCallbackInfo<P>(
+ reinterpret_cast<Persistent<v8::Value>*>(this)
+ , callback
+ , parameter);
+ v8::PersistentBase<T>::SetPhantom(
+ wcbd
+ , WeakCallbackInfo<P>::invokeparameter);
+ } else {
+ v8::Local<v8::Value>* self_v(reinterpret_cast<v8::Local<v8::Value>*>(this));
+ assert((*self_v)->IsObject());
+ v8::Local<v8::Object> self((*self_v).As<v8::Object>());
+ int count = self->InternalFieldCount();
+ void *internal_fields[kInternalFieldsInWeakCallback] = {0, 0};
+ for (int i = 0; i < count && i < kInternalFieldsInWeakCallback; i++) {
+ internal_fields[i] = self->GetAlignedPointerFromInternalField(i);
+ }
+ wcbd = new WeakCallbackInfo<P>(
+ reinterpret_cast<Persistent<v8::Value>*>(this)
+ , callback
+ , 0
+ , internal_fields[0]
+ , internal_fields[1]);
+ self->SetAlignedPointerInInternalField(0, wcbd);
+ v8::PersistentBase<T>::SetPhantom(
+ static_cast<WeakCallbackInfo<P>*>(0)
+ , WeakCallbackInfo<P>::invoketwofield
+ , 0
+ , count > 1 ? 1 : kNoInternalFieldIndex);
+ }
+}
+#elif NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION
+template<typename T, typename M>
+template<typename P>
+inline void Persistent<T, M>::SetWeak(
+ P *parameter
+ , typename WeakCallbackInfo<P>::Callback callback
+ , WeakCallbackType type) {
+ WeakCallbackInfo<P> *wcbd;
+ if (type == WeakCallbackType::kParameter) {
+ wcbd = new WeakCallbackInfo<P>(
+ reinterpret_cast<Persistent<v8::Value>*>(this)
+ , callback
+ , parameter);
+ v8::PersistentBase<T>::SetPhantom(
+ wcbd
+ , WeakCallbackInfo<P>::invokeparameter);
+ } else {
+ v8::Local<v8::Value>* self_v(reinterpret_cast<v8::Local<v8::Value>*>(this));
+ assert((*self_v)->IsObject());
+ v8::Local<v8::Object> self((*self_v).As<v8::Object>());
+ int count = self->InternalFieldCount();
+ void *internal_fields[kInternalFieldsInWeakCallback] = {0, 0};
+ for (int i = 0; i < count && i < kInternalFieldsInWeakCallback; i++) {
+ internal_fields[i] = self->GetAlignedPointerFromInternalField(i);
+ }
+ wcbd = new WeakCallbackInfo<P>(
+ reinterpret_cast<Persistent<v8::Value>*>(this)
+ , callback
+ , 0
+ , internal_fields[0]
+ , internal_fields[1]);
+ self->SetAlignedPointerInInternalField(0, wcbd);
+ v8::PersistentBase<T>::SetPhantom(
+ WeakCallbackInfo<P>::invoketwofield
+ , 0
+ , count > 1 ? 1 : kNoInternalFieldIndex);
+ }
+}
+#elif NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
+template<typename T, typename M>
+template<typename P>
+inline void Persistent<T, M>::SetWeak(
+ P *parameter
+ , typename WeakCallbackInfo<P>::Callback callback
+ , WeakCallbackType type) {
+ WeakCallbackInfo<P> *wcbd;
+ if (type == WeakCallbackType::kParameter) {
+ wcbd = new WeakCallbackInfo<P>(
+ reinterpret_cast<Persistent<v8::Value>*>(this)
+ , callback
+ , parameter);
+ v8::PersistentBase<T>::SetWeak(wcbd, WeakCallbackInfo<P>::invoke);
+ } else {
+ v8::Local<v8::Value>* self_v(reinterpret_cast<v8::Local<v8::Value>*>(this));
+ assert((*self_v)->IsObject());
+ v8::Local<v8::Object> self((*self_v).As<v8::Object>());
+ int count = self->InternalFieldCount();
+ void *internal_fields[kInternalFieldsInWeakCallback] = {0, 0};
+ for (int i = 0; i < count && i < kInternalFieldsInWeakCallback; i++) {
+ internal_fields[i] = self->GetAlignedPointerFromInternalField(i);
+ }
+ wcbd = new WeakCallbackInfo<P>(
+ reinterpret_cast<Persistent<v8::Value>*>(this)
+ , callback
+ , 0
+ , internal_fields[0]
+ , internal_fields[1]);
+ v8::PersistentBase<T>::SetWeak(wcbd, WeakCallbackInfo<P>::invoke);
+ }
+}
+#else
+template<typename T>
+template<typename P>
+inline void PersistentBase<T>::SetWeak(
+ P *parameter
+ , typename WeakCallbackInfo<P>::Callback callback
+ , WeakCallbackType type) {
+ WeakCallbackInfo<P> *wcbd;
+ if (type == WeakCallbackType::kParameter) {
+ wcbd = new WeakCallbackInfo<P>(
+ reinterpret_cast<Persistent<v8::Value>*>(this)
+ , callback
+ , parameter);
+ persistent.MakeWeak(wcbd, WeakCallbackInfo<P>::invoke);
+ } else {
+ v8::Local<v8::Value>* self_v(reinterpret_cast<v8::Local<v8::Value>*>(this));
+ assert((*self_v)->IsObject());
+ v8::Local<v8::Object> self((*self_v).As<v8::Object>());
+ int count = self->InternalFieldCount();
+ void *internal_fields[kInternalFieldsInWeakCallback] = {0, 0};
+ for (int i = 0; i < count && i < kInternalFieldsInWeakCallback; i++) {
+ internal_fields[i] = self->GetPointerFromInternalField(i);
+ }
+ wcbd = new WeakCallbackInfo<P>(
+ reinterpret_cast<Persistent<v8::Value>*>(this)
+ , callback
+ , 0
+ , internal_fields[0]
+ , internal_fields[1]);
+ persistent.MakeWeak(wcbd, WeakCallbackInfo<P>::invoke);
+ }
+}
+#endif
+
+#endif // NAN_WEAK_H_
diff --git a/node_modules/nan/package.json b/node_modules/nan/package.json
new file mode 100644
index 0000000..3cb78a1
--- /dev/null
+++ b/node_modules/nan/package.json
@@ -0,0 +1,37 @@
+{
+ "name": "nan",
+ "version": "2.15.0",
+ "description": "Native Abstractions for Node.js: C++ header for Node 0.8 -> 14 compatibility",
+ "main": "include_dirs.js",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/nodejs/nan.git"
+ },
+ "scripts": {
+ "test": "tap --gc --stderr test/js/*-test.js",
+ "test:worker": "node --experimental-worker test/tap-as-worker.js --gc --stderr test/js/*-test.js",
+ "rebuild-tests": "node-gyp rebuild --msvs_version=2015 --directory test",
+ "docs": "doc/.build.sh"
+ },
+ "contributors": [
+ "Rod Vagg <r@va.gg> (https://github.com/rvagg)",
+ "Benjamin Byholm <bbyholm@abo.fi> (https://github.com/kkoopa/)",
+ "Trevor Norris <trev.norris@gmail.com> (https://github.com/trevnorris)",
+ "Nathan Rajlich <nathan@tootallnate.net> (https://github.com/TooTallNate)",
+ "Brett Lawson <brett19@gmail.com> (https://github.com/brett19)",
+ "Ben Noordhuis <info@bnoordhuis.nl> (https://github.com/bnoordhuis)",
+ "David Siegel <david@artcom.de> (https://github.com/agnat)",
+ "Michael Ira Krufky <mkrufky@gmail.com> (https://github.com/mkrufky)"
+ ],
+ "devDependencies": {
+ "bindings": "~1.2.1",
+ "commander": "^2.8.1",
+ "glob": "^5.0.14",
+ "request": "=2.81.0",
+ "node-gyp": "~3.6.2",
+ "readable-stream": "^2.1.4",
+ "tap": "~0.7.1",
+ "xtend": "~4.0.0"
+ },
+ "license": "MIT"
+}
diff --git a/node_modules/nan/tools/1to2.js b/node_modules/nan/tools/1to2.js
new file mode 100755
index 0000000..6af2505
--- /dev/null
+++ b/node_modules/nan/tools/1to2.js
@@ -0,0 +1,412 @@
+#!/usr/bin/env node
+/*********************************************************************
+ * NAN - Native Abstractions for Node.js
+ *
+ * Copyright (c) 2018 NAN contributors
+ *
+ * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
+ ********************************************************************/
+
+var commander = require('commander'),
+ fs = require('fs'),
+ glob = require('glob'),
+ groups = [],
+ total = 0,
+ warning1 = '/* ERROR: Rewrite using Buffer */\n',
+ warning2 = '\\/\\* ERROR\\: Rewrite using Buffer \\*\\/\\n',
+ length,
+ i;
+
+fs.readFile(__dirname + '/package.json', 'utf8', function (err, data) {
+ if (err) {
+ throw err;
+ }
+
+ commander
+ .version(JSON.parse(data).version)
+ .usage('[options] <file ...>')
+ .parse(process.argv);
+
+ if (!process.argv.slice(2).length) {
+ commander.outputHelp();
+ }
+});
+
+/* construct strings representing regular expressions
+ each expression contains a unique group allowing for identification of the match
+ the index of this key group, relative to the regular expression in question,
+ is indicated by the first array member */
+
+/* simple substistutions, key group is the entire match, 0 */
+groups.push([0, [
+ '_NAN_',
+ 'NODE_SET_METHOD',
+ 'NODE_SET_PROTOTYPE_METHOD',
+ 'NanAsciiString',
+ 'NanEscapeScope',
+ 'NanReturnValue',
+ 'NanUcs2String'].join('|')]);
+
+/* substitutions of parameterless macros, key group is 1 */
+groups.push([1, ['(', [
+ 'NanEscapableScope',
+ 'NanReturnNull',
+ 'NanReturnUndefined',
+ 'NanScope'].join('|'), ')\\(\\)'].join('')]);
+
+/* replace TryCatch with NanTryCatch once, gobbling possible namespace, key group 2 */
+groups.push([2, '(?:(?:v8\\:\\:)?|(Nan)?)(TryCatch)']);
+
+/* NanNew("string") will likely not fail a ToLocalChecked(), key group 1 */
+groups.push([1, ['(NanNew)', '(\\("[^\\"]*"[^\\)]*\\))(?!\\.ToLocalChecked\\(\\))'].join('')]);
+
+/* Removed v8 APIs, warn that the code needs rewriting using node::Buffer, key group 2 */
+groups.push([2, ['(', warning2, ')?', '^.*?(', [
+ 'GetIndexedPropertiesExternalArrayDataLength',
+ 'GetIndexedPropertiesExternalArrayData',
+ 'GetIndexedPropertiesExternalArrayDataType',
+ 'GetIndexedPropertiesPixelData',
+ 'GetIndexedPropertiesPixelDataLength',
+ 'HasIndexedPropertiesInExternalArrayData',
+ 'HasIndexedPropertiesInPixelData',
+ 'SetIndexedPropertiesToExternalArrayData',
+ 'SetIndexedPropertiesToPixelData'].join('|'), ')'].join('')]);
+
+/* No need for NanScope in V8-exposed methods, key group 2 */
+groups.push([2, ['((', [
+ 'NAN_METHOD',
+ 'NAN_GETTER',
+ 'NAN_SETTER',
+ 'NAN_PROPERTY_GETTER',
+ 'NAN_PROPERTY_SETTER',
+ 'NAN_PROPERTY_ENUMERATOR',
+ 'NAN_PROPERTY_DELETER',
+ 'NAN_PROPERTY_QUERY',
+ 'NAN_INDEX_GETTER',
+ 'NAN_INDEX_SETTER',
+ 'NAN_INDEX_ENUMERATOR',
+ 'NAN_INDEX_DELETER',
+ 'NAN_INDEX_QUERY'].join('|'), ')\\([^\\)]*\\)\\s*\\{)\\s*NanScope\\(\\)\\s*;'].join('')]);
+
+/* v8::Value::ToXXXXXXX returns v8::MaybeLocal<T>, key group 3 */
+groups.push([3, ['([\\s\\(\\)])([^\\s\\(\\)]+)->(', [
+ 'Boolean',
+ 'Number',
+ 'String',
+ 'Object',
+ 'Integer',
+ 'Uint32',
+ 'Int32'].join('|'), ')\\('].join('')]);
+
+/* v8::Value::XXXXXXXValue returns v8::Maybe<T>, key group 3 */
+groups.push([3, ['([\\s\\(\\)])([^\\s\\(\\)]+)->((?:', [
+ 'Boolean',
+ 'Number',
+ 'Integer',
+ 'Uint32',
+ 'Int32'].join('|'), ')Value)\\('].join('')]);
+
+/* NAN_WEAK_CALLBACK macro was removed, write out callback definition, key group 1 */
+groups.push([1, '(NAN_WEAK_CALLBACK)\\(([^\\s\\)]+)\\)']);
+
+/* node::ObjectWrap and v8::Persistent have been replaced with Nan implementations, key group 1 */
+groups.push([1, ['(', [
+ 'NanDisposePersistent',
+ 'NanObjectWrapHandle'].join('|'), ')\\s*\\(\\s*([^\\s\\)]+)'].join('')]);
+
+/* Since NanPersistent there is no need for NanMakeWeakPersistent, key group 1 */
+groups.push([1, '(NanMakeWeakPersistent)\\s*\\(\\s*([^\\s,]+)\\s*,\\s*']);
+
+/* Many methods of v8::Object and others now return v8::MaybeLocal<T>, key group 3 */
+groups.push([3, ['([\\s])([^\\s]+)->(', [
+ 'GetEndColumn',
+ 'GetFunction',
+ 'GetLineNumber',
+ 'NewInstance',
+ 'GetPropertyNames',
+ 'GetOwnPropertyNames',
+ 'GetSourceLine',
+ 'GetStartColumn',
+ 'ObjectProtoToString',
+ 'ToArrayIndex',
+ 'ToDetailString',
+ 'CallAsConstructor',
+ 'CallAsFunction',
+ 'CloneElementAt',
+ 'Delete',
+ 'ForceSet',
+ 'Get',
+ 'GetPropertyAttributes',
+ 'GetRealNamedProperty',
+ 'GetRealNamedPropertyInPrototypeChain',
+ 'Has',
+ 'HasOwnProperty',
+ 'HasRealIndexedProperty',
+ 'HasRealNamedCallbackProperty',
+ 'HasRealNamedProperty',
+ 'Set',
+ 'SetAccessor',
+ 'SetIndexedPropertyHandler',
+ 'SetNamedPropertyHandler',
+ 'SetPrototype'].join('|'), ')\\('].join('')]);
+
+/* You should get an error if any of these fail anyways,
+ or handle the error better, it is indicated either way, key group 2 */
+groups.push([2, ['NanNew(<(?:v8\\:\\:)?(', ['Date', 'String', 'RegExp'].join('|'), ')>)(\\([^\\)]*\\))(?!\\.ToLocalChecked\\(\\))'].join('')]);
+
+/* v8::Value::Equals now returns a v8::Maybe, key group 3 */
+groups.push([3, '([\\s\\(\\)])([^\\s\\(\\)]+)->(Equals)\\(([^\\s\\)]+)']);
+
+/* NanPersistent makes this unnecessary, key group 1 */
+groups.push([1, '(NanAssignPersistent)(?:<v8\\:\\:[^>]+>)?\\(([^,]+),\\s*']);
+
+/* args has been renamed to info, key group 2 */
+groups.push([2, '(\\W)(args)(\\W)'])
+
+/* node::ObjectWrap was replaced with NanObjectWrap, key group 2 */
+groups.push([2, '(\\W)(?:node\\:\\:)?(ObjectWrap)(\\W)']);
+
+/* v8::Persistent was replaced with NanPersistent, key group 2 */
+groups.push([2, '(\\W)(?:v8\\:\\:)?(Persistent)(\\W)']);
+
+/* counts the number of capturing groups in a well-formed regular expression,
+ ignoring non-capturing groups and escaped parentheses */
+function groupcount(s) {
+ var positive = s.match(/\((?!\?)/g),
+ negative = s.match(/\\\(/g);
+ return (positive ? positive.length : 0) - (negative ? negative.length : 0);
+}
+
+/* compute the absolute position of each key group in the joined master RegExp */
+for (i = 1, length = groups.length; i < length; i++) {
+ total += groupcount(groups[i - 1][1]);
+ groups[i][0] += total;
+}
+
+/* create the master RegExp, whis is the union of all the groups' expressions */
+master = new RegExp(groups.map(function (a) { return a[1]; }).join('|'), 'gm');
+
+/* replacement function for String.replace, receives 21 arguments */
+function replace() {
+ /* simple expressions */
+ switch (arguments[groups[0][0]]) {
+ case '_NAN_':
+ return 'NAN_';
+ case 'NODE_SET_METHOD':
+ return 'NanSetMethod';
+ case 'NODE_SET_PROTOTYPE_METHOD':
+ return 'NanSetPrototypeMethod';
+ case 'NanAsciiString':
+ return 'NanUtf8String';
+ case 'NanEscapeScope':
+ return 'scope.Escape';
+ case 'NanReturnNull':
+ return 'info.GetReturnValue().SetNull';
+ case 'NanReturnValue':
+ return 'info.GetReturnValue().Set';
+ case 'NanUcs2String':
+ return 'v8::String::Value';
+ default:
+ }
+
+ /* macros without arguments */
+ switch (arguments[groups[1][0]]) {
+ case 'NanEscapableScope':
+ return 'NanEscapableScope scope'
+ case 'NanReturnUndefined':
+ return 'return';
+ case 'NanScope':
+ return 'NanScope scope';
+ default:
+ }
+
+ /* TryCatch, emulate negative backref */
+ if (arguments[groups[2][0]] === 'TryCatch') {
+ return arguments[groups[2][0] - 1] ? arguments[0] : 'NanTryCatch';
+ }
+
+ /* NanNew("foo") --> NanNew("foo").ToLocalChecked() */
+ if (arguments[groups[3][0]] === 'NanNew') {
+ return [arguments[0], '.ToLocalChecked()'].join('');
+ }
+
+ /* insert warning for removed functions as comment on new line above */
+ switch (arguments[groups[4][0]]) {
+ case 'GetIndexedPropertiesExternalArrayData':
+ case 'GetIndexedPropertiesExternalArrayDataLength':
+ case 'GetIndexedPropertiesExternalArrayDataType':
+ case 'GetIndexedPropertiesPixelData':
+ case 'GetIndexedPropertiesPixelDataLength':
+ case 'HasIndexedPropertiesInExternalArrayData':
+ case 'HasIndexedPropertiesInPixelData':
+ case 'SetIndexedPropertiesToExternalArrayData':
+ case 'SetIndexedPropertiesToPixelData':
+ return arguments[groups[4][0] - 1] ? arguments[0] : [warning1, arguments[0]].join('');
+ default:
+ }
+
+ /* remove unnecessary NanScope() */
+ switch (arguments[groups[5][0]]) {
+ case 'NAN_GETTER':
+ case 'NAN_METHOD':
+ case 'NAN_SETTER':
+ case 'NAN_INDEX_DELETER':
+ case 'NAN_INDEX_ENUMERATOR':
+ case 'NAN_INDEX_GETTER':
+ case 'NAN_INDEX_QUERY':
+ case 'NAN_INDEX_SETTER':
+ case 'NAN_PROPERTY_DELETER':
+ case 'NAN_PROPERTY_ENUMERATOR':
+ case 'NAN_PROPERTY_GETTER':
+ case 'NAN_PROPERTY_QUERY':
+ case 'NAN_PROPERTY_SETTER':
+ return arguments[groups[5][0] - 1];
+ default:
+ }
+
+ /* Value conversion */
+ switch (arguments[groups[6][0]]) {
+ case 'Boolean':
+ case 'Int32':
+ case 'Integer':
+ case 'Number':
+ case 'Object':
+ case 'String':
+ case 'Uint32':
+ return [arguments[groups[6][0] - 2], 'NanTo<v8::', arguments[groups[6][0]], '>(', arguments[groups[6][0] - 1]].join('');
+ default:
+ }
+
+ /* other value conversion */
+ switch (arguments[groups[7][0]]) {
+ case 'BooleanValue':
+ return [arguments[groups[7][0] - 2], 'NanTo<bool>(', arguments[groups[7][0] - 1]].join('');
+ case 'Int32Value':
+ return [arguments[groups[7][0] - 2], 'NanTo<int32_t>(', arguments[groups[7][0] - 1]].join('');
+ case 'IntegerValue':
+ return [arguments[groups[7][0] - 2], 'NanTo<int64_t>(', arguments[groups[7][0] - 1]].join('');
+ case 'Uint32Value':
+ return [arguments[groups[7][0] - 2], 'NanTo<uint32_t>(', arguments[groups[7][0] - 1]].join('');
+ default:
+ }
+
+ /* NAN_WEAK_CALLBACK */
+ if (arguments[groups[8][0]] === 'NAN_WEAK_CALLBACK') {
+ return ['template<typename T>\nvoid ',
+ arguments[groups[8][0] + 1], '(const NanWeakCallbackInfo<T> &data)'].join('');
+ }
+
+ /* use methods on NAN classes instead */
+ switch (arguments[groups[9][0]]) {
+ case 'NanDisposePersistent':
+ return [arguments[groups[9][0] + 1], '.Reset('].join('');
+ case 'NanObjectWrapHandle':
+ return [arguments[groups[9][0] + 1], '->handle('].join('');
+ default:
+ }
+
+ /* use method on NanPersistent instead */
+ if (arguments[groups[10][0]] === 'NanMakeWeakPersistent') {
+ return arguments[groups[10][0] + 1] + '.SetWeak(';
+ }
+
+ /* These return Maybes, the upper ones take no arguments */
+ switch (arguments[groups[11][0]]) {
+ case 'GetEndColumn':
+ case 'GetFunction':
+ case 'GetLineNumber':
+ case 'GetOwnPropertyNames':
+ case 'GetPropertyNames':
+ case 'GetSourceLine':
+ case 'GetStartColumn':
+ case 'NewInstance':
+ case 'ObjectProtoToString':
+ case 'ToArrayIndex':
+ case 'ToDetailString':
+ return [arguments[groups[11][0] - 2], 'Nan', arguments[groups[11][0]], '(', arguments[groups[11][0] - 1]].join('');
+ case 'CallAsConstructor':
+ case 'CallAsFunction':
+ case 'CloneElementAt':
+ case 'Delete':
+ case 'ForceSet':
+ case 'Get':
+ case 'GetPropertyAttributes':
+ case 'GetRealNamedProperty':
+ case 'GetRealNamedPropertyInPrototypeChain':
+ case 'Has':
+ case 'HasOwnProperty':
+ case 'HasRealIndexedProperty':
+ case 'HasRealNamedCallbackProperty':
+ case 'HasRealNamedProperty':
+ case 'Set':
+ case 'SetAccessor':
+ case 'SetIndexedPropertyHandler':
+ case 'SetNamedPropertyHandler':
+ case 'SetPrototype':
+ return [arguments[groups[11][0] - 2], 'Nan', arguments[groups[11][0]], '(', arguments[groups[11][0] - 1], ', '].join('');
+ default:
+ }
+
+ /* Automatic ToLocalChecked(), take it or leave it */
+ switch (arguments[groups[12][0]]) {
+ case 'Date':
+ case 'String':
+ case 'RegExp':
+ return ['NanNew', arguments[groups[12][0] - 1], arguments[groups[12][0] + 1], '.ToLocalChecked()'].join('');
+ default:
+ }
+
+ /* NanEquals is now required for uniformity */
+ if (arguments[groups[13][0]] === 'Equals') {
+ return [arguments[groups[13][0] - 1], 'NanEquals(', arguments[groups[13][0] - 1], ', ', arguments[groups[13][0] + 1]].join('');
+ }
+
+ /* use method on replacement class instead */
+ if (arguments[groups[14][0]] === 'NanAssignPersistent') {
+ return [arguments[groups[14][0] + 1], '.Reset('].join('');
+ }
+
+ /* args --> info */
+ if (arguments[groups[15][0]] === 'args') {
+ return [arguments[groups[15][0] - 1], 'info', arguments[groups[15][0] + 1]].join('');
+ }
+
+ /* ObjectWrap --> NanObjectWrap */
+ if (arguments[groups[16][0]] === 'ObjectWrap') {
+ return [arguments[groups[16][0] - 1], 'NanObjectWrap', arguments[groups[16][0] + 1]].join('');
+ }
+
+ /* Persistent --> NanPersistent */
+ if (arguments[groups[17][0]] === 'Persistent') {
+ return [arguments[groups[17][0] - 1], 'NanPersistent', arguments[groups[17][0] + 1]].join('');
+ }
+
+ /* This should not happen. A switch is probably missing a case if it does. */
+ throw 'Unhandled match: ' + arguments[0];
+}
+
+/* reads a file, runs replacement and writes it back */
+function processFile(file) {
+ fs.readFile(file, {encoding: 'utf8'}, function (err, data) {
+ if (err) {
+ throw err;
+ }
+
+ /* run replacement twice, might need more runs */
+ fs.writeFile(file, data.replace(master, replace).replace(master, replace), function (err) {
+ if (err) {
+ throw err;
+ }
+ });
+ });
+}
+
+/* process file names from command line and process the identified files */
+for (i = 2, length = process.argv.length; i < length; i++) {
+ glob(process.argv[i], function (err, matches) {
+ if (err) {
+ throw err;
+ }
+ matches.forEach(processFile);
+ });
+}
diff --git a/node_modules/nan/tools/README.md b/node_modules/nan/tools/README.md
new file mode 100644
index 0000000..7f07e4b
--- /dev/null
+++ b/node_modules/nan/tools/README.md
@@ -0,0 +1,14 @@
+1to2 naively converts source code files from NAN 1 to NAN 2. There will be erroneous conversions,
+false positives and missed opportunities. The input files are rewritten in place. Make sure that
+you have backups. You will have to manually review the changes afterwards and do some touchups.
+
+```sh
+$ tools/1to2.js
+
+ Usage: 1to2 [options] <file ...>
+
+ Options:
+
+ -h, --help output usage information
+ -V, --version output the version number
+```
diff --git a/node_modules/nan/tools/package.json b/node_modules/nan/tools/package.json
new file mode 100644
index 0000000..2dcdd78
--- /dev/null
+++ b/node_modules/nan/tools/package.json
@@ -0,0 +1,19 @@
+{
+ "name": "1to2",
+ "version": "1.0.0",
+ "description": "NAN 1 -> 2 Migration Script",
+ "main": "1to2.js",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/nodejs/nan.git"
+ },
+ "contributors": [
+ "Benjamin Byholm <bbyholm@abo.fi> (https://github.com/kkoopa/)",
+ "Mathias Küsel (https://github.com/mathiask88/)"
+ ],
+ "dependencies": {
+ "glob": "~5.0.10",
+ "commander": "~2.8.1"
+ },
+ "license": "MIT"
+}
diff --git a/node_modules/uuid-v4/index.js b/node_modules/uuid-v4/index.js
new file mode 100644
index 0000000..ce0a0bb
--- /dev/null
+++ b/node_modules/uuid-v4/index.js
@@ -0,0 +1,28 @@
+
+exports = module.exports = function() {
+ var ret = '', value;
+ for (var i = 0; i < 32; i++) {
+ value = exports.random() * 16 | 0;
+ // Insert the hypens
+ if (i > 4 && i < 21 && ! (i % 4)) {
+ ret += '-';
+ }
+ // Add the next random character
+ ret += (
+ (i === 12) ? 4 : (
+ (i === 16) ? (value & 3 | 8) : value
+ )
+ ).toString(16);
+ }
+ return ret;
+};
+
+var uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
+exports.isUUID = function(uuid) {
+ return uuidRegex.test(uuid);
+};
+
+exports.random = function() {
+ return Math.random();
+};
+
diff --git a/node_modules/uuid-v4/package.json b/node_modules/uuid-v4/package.json
new file mode 100644
index 0000000..4badb74
--- /dev/null
+++ b/node_modules/uuid-v4/package.json
@@ -0,0 +1,13 @@
+{
+ "author": "James Brumond <james@jbrumond.me> (http://jbrumond.me)",
+ "name": "uuid-v4",
+ "description": "A simple v4 UUID generator",
+ "version": "0.1.0",
+ "main": "index.js",
+ "dependencies": {},
+ "devDependencies": {},
+ "optionalDependencies": {},
+ "engines": {
+ "node": "*"
+ }
+}
diff --git a/node_modules/uuid-v4/readme.md b/node_modules/uuid-v4/readme.md
new file mode 100644
index 0000000..0b8110f
--- /dev/null
+++ b/node_modules/uuid-v4/readme.md
@@ -0,0 +1,33 @@
+# uuid-v4
+
+A Node.js module for generating and validation V4 UUIDs
+
+## Install
+
+```bash
+$ npm install uuid-v4
+```
+
+## Usage
+
+```javascript
+var uuid = require('uuid-v4');
+
+// Generate a new UUID
+var myUUID = uuid();
+
+// Validate a UUID as proper V4 format
+uuid.isUUID(myUUID); // true
+```
+
+## MIT License
+
+Copyright (c) 2012 James Brumond
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
diff --git a/package-lock.json b/package-lock.json
new file mode 100644
index 0000000..51bd2e6
--- /dev/null
+++ b/package-lock.json
@@ -0,0 +1,91 @@
+{
+ "name": "ArgonCDN",
+ "lockfileVersion": 2,
+ "requires": true,
+ "packages": {
+ "": {
+ "dependencies": {
+ "mime-types": "^2.1.34",
+ "mmmagic": "^0.5.3",
+ "uuid-v4": "^0.1.0"
+ }
+ },
+ "node_modules/mime-db": {
+ "version": "1.51.0",
+ "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz",
+ "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/mime-types": {
+ "version": "2.1.34",
+ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz",
+ "integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==",
+ "dependencies": {
+ "mime-db": "1.51.0"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/mmmagic": {
+ "version": "0.5.3",
+ "resolved": "https://registry.npmjs.org/mmmagic/-/mmmagic-0.5.3.tgz",
+ "integrity": "sha512-xLqCu7GJYTzJczg0jafXFuh+iPzQL/ru0YYf4GiTTz8Cehru/wiXtUS8Pp8Xi77zNaiVndJ0OO1yAFci6iHyFg==",
+ "hasInstallScript": true,
+ "dependencies": {
+ "nan": "^2.13.2"
+ },
+ "engines": {
+ "node": ">=4.0.0"
+ }
+ },
+ "node_modules/nan": {
+ "version": "2.15.0",
+ "resolved": "https://registry.npmjs.org/nan/-/nan-2.15.0.tgz",
+ "integrity": "sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ=="
+ },
+ "node_modules/uuid-v4": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/uuid-v4/-/uuid-v4-0.1.0.tgz",
+ "integrity": "sha1-YtezEEBvbOz+oVKMafHo4LzsWjo=",
+ "engines": {
+ "node": "*"
+ }
+ }
+ },
+ "dependencies": {
+ "mime-db": {
+ "version": "1.51.0",
+ "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz",
+ "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g=="
+ },
+ "mime-types": {
+ "version": "2.1.34",
+ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz",
+ "integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==",
+ "requires": {
+ "mime-db": "1.51.0"
+ }
+ },
+ "mmmagic": {
+ "version": "0.5.3",
+ "resolved": "https://registry.npmjs.org/mmmagic/-/mmmagic-0.5.3.tgz",
+ "integrity": "sha512-xLqCu7GJYTzJczg0jafXFuh+iPzQL/ru0YYf4GiTTz8Cehru/wiXtUS8Pp8Xi77zNaiVndJ0OO1yAFci6iHyFg==",
+ "requires": {
+ "nan": "^2.13.2"
+ }
+ },
+ "nan": {
+ "version": "2.15.0",
+ "resolved": "https://registry.npmjs.org/nan/-/nan-2.15.0.tgz",
+ "integrity": "sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ=="
+ },
+ "uuid-v4": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/uuid-v4/-/uuid-v4-0.1.0.tgz",
+ "integrity": "sha1-YtezEEBvbOz+oVKMafHo4LzsWjo="
+ }
+ }
+}
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..86102c0
--- /dev/null
+++ b/package.json
@@ -0,0 +1,7 @@
+{
+ "dependencies": {
+ "mime-types": "^2.1.34",
+ "mmmagic": "^0.5.3",
+ "uuid-v4": "^0.1.0"
+ }
+}