koffi 2.6.11 → 2.6.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@
4
4
 
5
5
  ### Koffi 2.6
6
6
 
7
+ #### Koffi 2.6.12 (2023-12-11)
8
+
9
+ - Fix possible crash introduced in Koffi 2.6.11
10
+
7
11
  #### Koffi 2.6.11 (2023-12-05)
8
12
 
9
13
  - Speed up resolving simple and often used type names
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/index.js CHANGED
@@ -378,8 +378,8 @@ var require_package = __commonJS({
378
378
  "build/dist/src/koffi/package.json"(exports2, module2) {
379
379
  module2.exports = {
380
380
  name: "koffi",
381
- version: "2.6.11",
382
- stable: "2.6.11",
381
+ version: "2.6.12",
382
+ stable: "2.6.12",
383
383
  description: "Fast and simple C FFI (foreign function interface) for Node.js",
384
384
  keywords: [
385
385
  "foreign",
package/indirect.js CHANGED
@@ -378,8 +378,8 @@ var require_package = __commonJS({
378
378
  "build/dist/src/koffi/package.json"(exports2, module2) {
379
379
  module2.exports = {
380
380
  name: "koffi",
381
- version: "2.6.11",
382
- stable: "2.6.11",
381
+ version: "2.6.12",
382
+ stable: "2.6.12",
383
383
  description: "Fast and simple C FFI (foreign function interface) for Node.js",
384
384
  keywords: [
385
385
  "foreign",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koffi",
3
- "version": "2.6.11",
4
- "stable": "2.6.11",
3
+ "version": "2.6.12",
4
+ "stable": "2.6.12",
5
5
  "description": "Fast and simple C FFI (foreign function interface) for Node.js",
6
6
  "keywords": [
7
7
  "foreign",
@@ -8372,4 +8372,72 @@ bool PromptYN(const char *prompt, bool *out_value)
8372
8372
  return prompter.ReadYN(out_value);
8373
8373
  }
8374
8374
 
8375
+ // ------------------------------------------------------------------------
8376
+ // Mime types
8377
+ // ------------------------------------------------------------------------
8378
+
8379
+ const char *GetMimeType(Span<const char> extension, const char *default_type)
8380
+ {
8381
+ static const HashMap<Span<const char>, const char *> mime_types = {
8382
+ #define MIMETYPE(Extension, MimeType) { (Extension), (MimeType) },
8383
+ #include "mimetypes.inc"
8384
+
8385
+ {"", "application/octet-stream"}
8386
+ };
8387
+
8388
+ const char *mime_type = mime_types.FindValue(extension, nullptr);
8389
+
8390
+ if (!mime_type) {
8391
+ LogError("Unknown MIME type for extension '%1'", extension);
8392
+ mime_type = default_type;
8393
+ }
8394
+
8395
+ return mime_type;
8396
+ }
8397
+
8398
+ bool CanCompressFile(const char *filename)
8399
+ {
8400
+ char extension[8];
8401
+ {
8402
+ const char *ptr = GetPathExtension(filename).ptr;
8403
+
8404
+ Size i = 0;
8405
+ while (i < RG_SIZE(extension) - 1 && ptr[i]) {
8406
+ extension[i] = LowerAscii(ptr[i]);
8407
+ i++;
8408
+ }
8409
+ extension[i] = 0;
8410
+ }
8411
+
8412
+ if (TestStrI(extension, ".zip"))
8413
+ return false;
8414
+ if (TestStrI(extension, ".rar"))
8415
+ return false;
8416
+ if (TestStrI(extension, ".7z"))
8417
+ return false;
8418
+ if (TestStrI(extension, ".gz") || TestStrI(extension, ".tgz"))
8419
+ return false;
8420
+ if (TestStrI(extension, ".bz2") || TestStrI(extension, ".tbz2"))
8421
+ return false;
8422
+ if (TestStrI(extension, ".xz") || TestStrI(extension, ".txz"))
8423
+ return false;
8424
+ if (TestStrI(extension, ".zst") || TestStrI(extension, ".tzst"))
8425
+ return false;
8426
+ if (TestStrI(extension, ".woff") || TestStrI(extension, ".woff2"))
8427
+ return false;
8428
+ if (TestStrI(extension, ".db") || TestStrI(extension, ".sqlite3"))
8429
+ return false;
8430
+
8431
+ const char *mime_type = GetMimeType(extension);
8432
+
8433
+ if (StartsWith(mime_type, "video/"))
8434
+ return false;
8435
+ if (StartsWith(mime_type, "audio/"))
8436
+ return false;
8437
+ if (StartsWith(mime_type, "image/") && !TestStr(mime_type, "image/svg+xml"))
8438
+ return false;
8439
+
8440
+ return true;
8441
+ }
8442
+
8375
8443
  }
@@ -5016,4 +5016,12 @@ static inline const char *Prompt(const char *prompt, Allocator *alloc)
5016
5016
  { return Prompt(prompt, nullptr, nullptr, alloc); }
5017
5017
  bool PromptYN(const char *prompt, bool *out_value);
5018
5018
 
5019
+ // ------------------------------------------------------------------------
5020
+ // Mime types
5021
+ // ------------------------------------------------------------------------
5022
+
5023
+ const char *GetMimeType(Span<const char> extension, const char *default_typ = "application/octet-stream");
5024
+
5025
+ bool CanCompressFile(const char *filename);
5026
+
5019
5027
  }