ruby-magic 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTORS.md +2 -0
- data/dependencies.yml +93 -0
- data/ext/magic/common.h +30 -16
- data/ext/magic/extconf.rb +58 -8
- data/ext/magic/ruby-magic.c +76 -79
- data/ext/magic/ruby-magic.h +195 -2
- data/lib/magic/version.rb +1 -1
- data/patches/libmagic/0001-Don-t-attempt-to-build-tests-documentation-and-Python-bindings.patch +44 -0
- data/ports/archives/file-5.39.tar.gz +0 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ec6d5053457e958f459236e45b56c3e4f85dd16e8c09f119208619db7332982
|
4
|
+
data.tar.gz: 01bd34ae0c013438354e440ab533f2b8bce0bd693df874043181a365b1980fe3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d41cbbfec82e392dfe5db7d30d51814f852def72c09f766c4cf9f007272fb256fb4669db02963a8c7fc185c4ecbb83d22873e70fadc89fd63ed0098e5a7397f2
|
7
|
+
data.tar.gz: 8537e862c2b421ccf2d301d0a8811f02112f35c53061d3565d15601264e082e61184af80f866dc37a186101268c99684ada8b6949ab7feea81baf02e97f2dee3
|
data/CONTRIBUTORS.md
CHANGED
@@ -8,6 +8,8 @@ Ruby Magic Authors". Copyright is held by the original contributor according to
|
|
8
8
|
the versioning history; see [LICENSE](LICENSE) file.
|
9
9
|
|
10
10
|
|
11
|
+
- Mike Dalessio ([@flavorjones](https://github.com/flavorjones))
|
12
|
+
- Igor Victor ([@gogainda](https://github.com/gogainda))
|
11
13
|
- John Hawthorn ([@jhawthorn](https://github.com/jhawthorn))
|
12
14
|
- Shinya Maeda ([@dosuken123](https://github.com/dosuken123))
|
13
15
|
- Stan Hu ([@stanhu](https://github.com/stanhu))
|
data/dependencies.yml
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
libmagic:
|
2
|
+
version: "5.39"
|
3
|
+
sha256: "f05d286a76d9556243d0cb05814929c2ecf3a5ba07963f8f70bfaaa70517fad1"
|
4
|
+
# Manually verified checksum:
|
5
|
+
#
|
6
|
+
# $ gpg --verify file-5.39.tar.gz.asc file-5.39.tar.gz
|
7
|
+
# gpg: Signature made Mon Jun 15 02:06:08 2020 CEST
|
8
|
+
# gpg: using DSA key 0x71112AB16CB33B3A
|
9
|
+
# gpg: Good signature from "Christos Zoulas (personal key) <christos@zoulas.com>" [unknown]
|
10
|
+
# gpg: aka "Christos Zoulas (NetBSD key) <christos@netbsd.org>" [unknown]
|
11
|
+
# gpg: WARNING: This key is not certified with a trusted signature!
|
12
|
+
# gpg: There is no indication that the signature belongs to the owner.
|
13
|
+
# Primary key fingerprint: BE04 995B A8F9 0ED0 C0C1 76C4 7111 2AB1 6CB3 3B3A
|
14
|
+
#
|
15
|
+
# Using this PGP signature:
|
16
|
+
#
|
17
|
+
# -----BEGIN PGP PUBLIC KEY BLOCK-----
|
18
|
+
# mQGiBEg60Q8RBAC89+Oyi+iU1dMftAqXKh9Ml2PDCRk+Q6gwSY2BwmnKrPYvLSx9/YApjDp4
|
19
|
+
# BzhjaMCiDtDkbVDO3JuLQqUsCUWRJr9UxgfkQPMx3obkgoyCCvUcG5eK9CHeztjz5UK3jOzD
|
20
|
+
# 939UtupUXs+5z4dK1oAFFEL3sV6m5O4cuHyeWpjLCwCg9LYwmG2wIB65/2619W2kRMShDwkD
|
21
|
+
# /1KweB5mmXdQCDpzSg02Q4kGOzWmN2Dpv5kvKd9Lj/qxkj5PFOJ56Rmm04K0lPE6AnDgvEeu
|
22
|
+
# SqO8pkA8OY5IQNIjlgg3tshoMBRdsj9JLKv67smQXy01eQmadJWoiIZFuSLX7nrRLm3x3i1K
|
23
|
+
# 4/tcKorXoD5QBgOWaYFzkOcQ5jrwA/9tn0MEkkVqez88xG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KmITwQYEQIA
|
89
|
+
# DwIbDAUCV7RsRgUJIkWdEAAKCRBxESqxbLM7OiJUAJ4y0+A//pOrp3rjo28Uyt34U+qRqwCe
|
90
|
+
# NqiZtKbSqpUgcLmKNgot+mSEAmmITwQYEQIADwUCSDrSMwIbDAUJDwmcAAAKCRBxESqxbLM7
|
91
|
+
# OnaqAJ0cUAs8+EPXqRYYbdu6ROINhExMkwCgpupi6uEG+b4yo6M+VlcQY7gl2DE=
|
92
|
+
# =XrDo
|
93
|
+
# -----END PGP PUBLIC KEY BLOCK-----
|
data/ext/magic/common.h
CHANGED
@@ -36,27 +36,27 @@ extern "C" {
|
|
36
36
|
# include <ruby/io.h>
|
37
37
|
#else
|
38
38
|
# include <rubyio.h>
|
39
|
-
#endif
|
39
|
+
#endif /* HAVE_RUBY_IO_H */
|
40
40
|
|
41
|
-
#
|
42
|
-
# define BIT(n) (1 << (n))
|
43
|
-
#endif
|
41
|
+
#define BIT(n) (1 << (n))
|
44
42
|
|
45
43
|
#if !defined(UNUSED)
|
46
44
|
# define UNUSED(x) (void)(x)
|
47
|
-
#endif
|
45
|
+
#endif /* UNUSED */
|
46
|
+
|
47
|
+
#define ARRAY_SIZE(a) (int)(sizeof(a) / sizeof((a)[0]))
|
48
48
|
|
49
49
|
#if defined(F_DUPFD_CLOEXEC)
|
50
50
|
# define HAVE_F_DUPFD_CLOEXEC 1
|
51
|
-
#endif
|
51
|
+
#endif /* F_DUPFD_CLOEXEC */
|
52
52
|
|
53
53
|
#if defined(O_CLOEXEC)
|
54
54
|
# define HAVE_O_CLOEXEC 1
|
55
|
-
#endif
|
55
|
+
#endif /* O_CLOEXEC */
|
56
56
|
|
57
57
|
#if defined(POSIX_CLOSE_RESTART)
|
58
58
|
# define HAVE_POSIX_CLOSE_RESTART 1
|
59
|
-
#endif
|
59
|
+
#endif /* POSIX_CLOSE_RESTART */
|
60
60
|
|
61
61
|
#define MAGIC_EXTENSION_SEPARATOR "/"
|
62
62
|
#define MAGIC_CONTINUE_SEPARATOR "\n- "
|
@@ -65,15 +65,21 @@ extern "C" {
|
|
65
65
|
# define MAGIC_STATUS_CHECK(x) x
|
66
66
|
#else
|
67
67
|
# define MAGIC_STATUS_CHECK(x) 1
|
68
|
-
#endif
|
68
|
+
#endif /* MAGIC_SYSTEM_LIBRARIES */
|
69
|
+
|
70
|
+
#if !defined(MAGIC_CUSTOM_CHECK_TYPE)
|
71
|
+
# define MAGIC_CHECK_RUBY_TYPE(o, t) Check_Type((o), (t))
|
72
|
+
#else
|
73
|
+
# define MAGIC_CHECK_RUBY_TYPE(o, t) magic_check_ruby_type((o), (t))
|
74
|
+
#endif /* MAGIC_CUSTOM_CHECK_TYPE */
|
69
75
|
|
70
76
|
#if !defined(MAGIC_NO_CHECK_CSV)
|
71
77
|
# define MAGIC_NO_CHECK_CSV 0
|
72
|
-
#endif
|
78
|
+
#endif /* MAGIC_NO_CHECK_CSV */
|
73
79
|
|
74
80
|
#if !defined(MAGIC_NO_CHECK_JSON)
|
75
81
|
# define MAGIC_NO_CHECK_JSON 0
|
76
|
-
#endif
|
82
|
+
#endif /* MAGIC_NO_CHECK_JSON */
|
77
83
|
|
78
84
|
#define DATA_P(x) (RB_TYPE_P((x), T_DATA))
|
79
85
|
#define BOOLEAN_P(x) (RB_TYPE_P((x), T_TRUE) || RB_TYPE_P((x), T_FALSE))
|
@@ -95,23 +101,30 @@ extern "C" {
|
|
95
101
|
# define RVALUE_TYPE enum ruby_value_type
|
96
102
|
#else
|
97
103
|
# define RVALUE_TYPE int
|
98
|
-
#endif
|
104
|
+
#endif /* RUBY_API_VERSION_CODE > 20700 */
|
105
|
+
|
106
|
+
#if RUBY_API_VERSION_CODE >= 20700
|
107
|
+
# define HAVE_RUBY_GC_COMPACT 1
|
108
|
+
# define MAGIC_GC_MARK(x) rb_gc_mark_movable((x))
|
109
|
+
#else
|
110
|
+
# define MAGIC_GC_MARK(x) rb_gc_mark((x))
|
111
|
+
#endif /* RUBY_API_VERSION_CODE >= 20700 */
|
99
112
|
|
100
113
|
#define CLASS_NAME(o) (NIL_P((o)) ? "nil" : rb_obj_classname((o)))
|
101
114
|
|
102
115
|
#if !defined(T_INTEGER)
|
103
116
|
# define T_INTEGER rb_cInteger
|
104
|
-
#endif
|
117
|
+
#endif /* T_INTEGER */
|
105
118
|
|
106
119
|
#if !defined(HAVE_RB_IO_T)
|
107
120
|
# define rb_io_t OpenFile
|
108
|
-
#endif
|
121
|
+
#endif /* HAVE_RB_IO_T */
|
109
122
|
|
110
123
|
#if !defined(GetReadFile)
|
111
124
|
# define FPTR_TO_FD(p) ((p)->fd)
|
112
125
|
#else
|
113
126
|
# define FPTR_TO_FD(p) (fileno(GetReadFile(p)))
|
114
|
-
#endif
|
127
|
+
#endif /* GetReadFile */
|
115
128
|
|
116
129
|
#define NOGVL_FUNCTION (VALUE (*)(void *))
|
117
130
|
|
@@ -138,7 +151,8 @@ fake_blocking_region(VALUE (*f)(ANYARGS), void *data)
|
|
138
151
|
}
|
139
152
|
# define NOGVL(f, d) \
|
140
153
|
fake_blocking_region(NOGVL_FUNCTION(f), (d))
|
141
|
-
#endif
|
154
|
+
#endif /* HAVE_RB_THREAD_CALL_WITHOUT_GVL
|
155
|
+
HAVE_RUBY_THREAD_H */
|
142
156
|
|
143
157
|
#if defined(__cplusplus)
|
144
158
|
}
|
data/ext/magic/extconf.rb
CHANGED
@@ -4,9 +4,6 @@ require 'find'
|
|
4
4
|
require 'mkmf'
|
5
5
|
require 'pathname'
|
6
6
|
|
7
|
-
LIBMAGIC_TAG = '5.39'
|
8
|
-
LIBIMAGE_SHA256 = 'f05d286a76d9556243d0cb05814929c2ecf3a5ba07963f8f70bfaaa70517fad1'
|
9
|
-
|
10
7
|
# helpful constants
|
11
8
|
PACKAGE_ROOT_DIR = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
12
9
|
|
@@ -81,6 +78,7 @@ def process_recipe(name, version, static_p, cross_p)
|
|
81
78
|
# correct compiler prefix for cross build, but use host if not set.
|
82
79
|
recipe.host = RbConfig::CONFIG["host_alias"].empty? ? RbConfig::CONFIG["host"] : RbConfig::CONFIG["host_alias"]
|
83
80
|
recipe.target = File.join(PACKAGE_ROOT_DIR, "ports")
|
81
|
+
recipe.patch_files = Dir[File.join(PACKAGE_ROOT_DIR, "patches", name, "*.patch")].sort
|
84
82
|
recipe.configure_options << "--libdir=#{File.join(recipe.path, 'lib')}"
|
85
83
|
|
86
84
|
yield recipe
|
@@ -91,6 +89,20 @@ def process_recipe(name, version, static_p, cross_p)
|
|
91
89
|
|
92
90
|
recipe.configure_options.flatten!
|
93
91
|
|
92
|
+
recipe.configure_options.delete_if do |option|
|
93
|
+
case option
|
94
|
+
when /\A(\w+)=(.*)\z/
|
95
|
+
env[Regexp.last_match(1)] = if env.key?(Regexp.last_match(1))
|
96
|
+
concat_flags(env[Regexp.last_match(1)], Regexp.last_match(2))
|
97
|
+
else
|
98
|
+
Regexp.last_match(2)
|
99
|
+
end
|
100
|
+
true
|
101
|
+
else
|
102
|
+
false
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
94
106
|
recipe.configure_options = [
|
95
107
|
"--disable-silent-rules",
|
96
108
|
"--disable-dependency-tracking",
|
@@ -117,11 +129,42 @@ def process_recipe(name, version, static_p, cross_p)
|
|
117
129
|
]
|
118
130
|
end
|
119
131
|
|
132
|
+
if RbConfig::CONFIG['target_cpu'] == 'universal'
|
133
|
+
%w[CFLAGS LDFLAGS].each do |key|
|
134
|
+
unless env[key].include?('-arch')
|
135
|
+
env[key] = concat_flags(env[key], RbConfig::CONFIG['ARCH_FLAG'])
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
120
140
|
recipe.configure_options += env.map do |key, value|
|
121
141
|
"#{key}=#{value.strip}"
|
122
142
|
end
|
123
143
|
|
124
|
-
recipe.
|
144
|
+
checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
|
145
|
+
|
146
|
+
if File.exist?(checkpoint)
|
147
|
+
message("Building Ruby Magic with a packaged version of #{name}-#{version}.\n")
|
148
|
+
else
|
149
|
+
message(<<~EOM)
|
150
|
+
---------- IMPORTANT NOTICE ----------
|
151
|
+
Building Ruby Magic with a packaged version of #{name}-#{version}.
|
152
|
+
Configuration options: #{recipe.configure_options.shelljoin}
|
153
|
+
EOM
|
154
|
+
|
155
|
+
unless recipe.patch_files.empty?
|
156
|
+
message("The following patches are being applied:\n")
|
157
|
+
|
158
|
+
recipe.patch_files.each do |patch|
|
159
|
+
message(" - %s\n" % File.basename(patch))
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
recipe.cook
|
164
|
+
|
165
|
+
FileUtils.touch(checkpoint)
|
166
|
+
end
|
167
|
+
|
125
168
|
recipe.activate
|
126
169
|
end
|
127
170
|
end
|
@@ -220,6 +263,10 @@ append_ldflags(ENV["LDFLAGS"].split) if ENV["LDFLAGS"]
|
|
220
263
|
|
221
264
|
$LIBS = concat_flags($LIBS, ENV["LIBS"]) if ENV["LIBS"]
|
222
265
|
|
266
|
+
if truffle?
|
267
|
+
$CPPFLAGS += " -DMAGIC_CUSTOM_CHECK_TYPE"
|
268
|
+
end
|
269
|
+
|
223
270
|
if config_system_libraries?
|
224
271
|
message "Building ruby-magic using system libraries.\n"
|
225
272
|
|
@@ -229,16 +276,19 @@ if config_system_libraries?
|
|
229
276
|
else
|
230
277
|
message "Building ruby-magic using packaged libraries.\n"
|
231
278
|
|
279
|
+
require 'yaml'
|
280
|
+
dependencies = YAML.load_file(File.join(PACKAGE_ROOT_DIR, "dependencies.yml"))
|
281
|
+
|
232
282
|
static_p = config_static?
|
233
283
|
message "Static linking is #{static_p ? 'enabled' : 'disabled'}.\n"
|
234
284
|
cross_build_p = config_cross_build?
|
235
285
|
message "Cross build is #{cross_build_p ? 'enabled' : 'disabled'}.\n"
|
236
286
|
|
237
|
-
libmagic_recipe = process_recipe('libmagic',
|
287
|
+
libmagic_recipe = process_recipe('libmagic', dependencies["libmagic"]["version"], static_p, cross_build_p) do |recipe|
|
238
288
|
recipe.files = [{
|
239
|
-
|
240
|
-
|
241
|
-
|
289
|
+
url: "https://ruby-magic.s3.nl-ams.scw.cloud/file-#{recipe.version}.tar.gz",
|
290
|
+
sha256: dependencies["libmagic"]["sha256"],
|
291
|
+
}]
|
242
292
|
end
|
243
293
|
|
244
294
|
$LIBPATH = [File.join(libmagic_recipe.path, 'lib')]
|
data/ext/magic/ruby-magic.c
CHANGED
@@ -4,60 +4,6 @@ extern "C" {
|
|
4
4
|
|
5
5
|
#include "ruby-magic.h"
|
6
6
|
|
7
|
-
static int rb_mgc_do_not_auto_load;
|
8
|
-
static int rb_mgc_do_not_stop_on_error;
|
9
|
-
static int rb_mgc_warning;
|
10
|
-
|
11
|
-
static ID id_at_flags;
|
12
|
-
static ID id_at_paths;
|
13
|
-
|
14
|
-
static VALUE rb_cMagic = Qundef;
|
15
|
-
|
16
|
-
static VALUE rb_mgc_eError = Qundef;
|
17
|
-
static VALUE rb_mgc_eMagicError = Qundef;
|
18
|
-
static VALUE rb_mgc_eLibraryError = Qundef;
|
19
|
-
static VALUE rb_mgc_eParameterError = Qundef;
|
20
|
-
static VALUE rb_mgc_eFlagsError = Qundef;
|
21
|
-
static VALUE rb_mgc_eNotImplementedError = Qundef;
|
22
|
-
|
23
|
-
void Init_magic(void);
|
24
|
-
|
25
|
-
static VALUE magic_get_parameter_internal(void *data);
|
26
|
-
static VALUE magic_set_parameter_internal(void *data);
|
27
|
-
static VALUE magic_get_flags_internal(void *data);
|
28
|
-
static VALUE magic_set_flags_internal(void *data);
|
29
|
-
static VALUE magic_load_internal(void *data);
|
30
|
-
static VALUE magic_load_buffers_internal(void *data);
|
31
|
-
static VALUE magic_compile_internal(void *data);
|
32
|
-
static VALUE magic_check_internal(void *data);
|
33
|
-
static VALUE magic_file_internal(void *data);
|
34
|
-
static VALUE magic_buffer_internal(void *data);
|
35
|
-
static VALUE magic_descriptor_internal(void *data);
|
36
|
-
static VALUE magic_close_internal(void *data);
|
37
|
-
|
38
|
-
static void* nogvl_magic_load(void *data);
|
39
|
-
static void* nogvl_magic_compile(void *data);
|
40
|
-
static void* nogvl_magic_check(void *data);
|
41
|
-
static void* nogvl_magic_file(void *data);
|
42
|
-
static void* nogvl_magic_descriptor(void *data);
|
43
|
-
|
44
|
-
static VALUE magic_allocate(VALUE klass);
|
45
|
-
static void magic_mark(void *data);
|
46
|
-
static void magic_free(void *data);
|
47
|
-
static VALUE magic_exception_wrapper(VALUE value);
|
48
|
-
static VALUE magic_exception(void *data);
|
49
|
-
static void magic_library_close(void *data);
|
50
|
-
static VALUE magic_library_error(VALUE klass, void *data);
|
51
|
-
static VALUE magic_generic_error(VALUE klass, int magic_errno,
|
52
|
-
const char *magic_error);
|
53
|
-
static VALUE magic_lock(VALUE object, VALUE (*function)(ANYARGS),
|
54
|
-
void *data);
|
55
|
-
static VALUE magic_unlock(VALUE object);
|
56
|
-
static VALUE magic_return(void *data);
|
57
|
-
static int magic_flags(VALUE object);
|
58
|
-
static int magic_set_flags(VALUE object, VALUE value);
|
59
|
-
static VALUE magic_set_paths(VALUE object, VALUE value);
|
60
|
-
|
61
7
|
/*
|
62
8
|
* call-seq:
|
63
9
|
* Magic.do_not_auto_load -> boolean
|
@@ -539,7 +485,7 @@ rb_mgc_load(VALUE object, VALUE arguments)
|
|
539
485
|
klass, klass);
|
540
486
|
}
|
541
487
|
|
542
|
-
ma.flags =
|
488
|
+
ma.flags = magic_get_flags(object);
|
543
489
|
|
544
490
|
if (!RARRAY_EMPTY_P(arguments)) {
|
545
491
|
value = magic_join(arguments, CSTR2RVAL(":"));
|
@@ -614,7 +560,7 @@ rb_mgc_load_buffers(VALUE object, VALUE arguments)
|
|
614
560
|
sizes[i] = (size_t)RSTRING_LEN(value);
|
615
561
|
}
|
616
562
|
|
617
|
-
ma.flags =
|
563
|
+
ma.flags = magic_get_flags(object);
|
618
564
|
ma.type.buffers.count = count;
|
619
565
|
ma.type.buffers.pointers = pointers;
|
620
566
|
ma.type.buffers.sizes = sizes;
|
@@ -694,7 +640,7 @@ rb_mgc_compile(VALUE object, VALUE value)
|
|
694
640
|
MAGIC_CHECK_OPEN(object);
|
695
641
|
MAGIC_COOKIE(mo, ma.cookie);
|
696
642
|
|
697
|
-
ma.flags =
|
643
|
+
ma.flags = magic_get_flags(object);
|
698
644
|
ma.type.file.path = RVAL2CSTR(value);
|
699
645
|
|
700
646
|
MAGIC_SYNCHRONIZED(magic_compile_internal, &ma);
|
@@ -721,7 +667,7 @@ rb_mgc_check(VALUE object, VALUE value)
|
|
721
667
|
MAGIC_CHECK_OPEN(object);
|
722
668
|
MAGIC_COOKIE(mo, ma.cookie);
|
723
669
|
|
724
|
-
ma.flags =
|
670
|
+
ma.flags = magic_get_flags(object);
|
725
671
|
ma.type.file.path = RVAL2CSTR(value);
|
726
672
|
|
727
673
|
MAGIC_SYNCHRONIZED(magic_check_internal, &ma);
|
@@ -759,7 +705,7 @@ rb_mgc_file(VALUE object, VALUE value)
|
|
759
705
|
goto error;
|
760
706
|
|
761
707
|
ma.stop_on_errors = mo->stop_on_errors;
|
762
|
-
ma.flags =
|
708
|
+
ma.flags = magic_get_flags(object);
|
763
709
|
ma.type.file.path = RVAL2CSTR(value);
|
764
710
|
|
765
711
|
MAGIC_SYNCHRONIZED(magic_file_internal, &ma);
|
@@ -821,7 +767,7 @@ rb_mgc_buffer(VALUE object, VALUE value)
|
|
821
767
|
|
822
768
|
StringValue(value);
|
823
769
|
|
824
|
-
ma.flags =
|
770
|
+
ma.flags = magic_get_flags(object);
|
825
771
|
ma.type.buffers.pointers = (void **)RSTRING_PTR(value);
|
826
772
|
ma.type.buffers.sizes = (size_t *)RSTRING_LEN(value);
|
827
773
|
|
@@ -857,7 +803,7 @@ rb_mgc_descriptor(VALUE object, VALUE value)
|
|
857
803
|
MAGIC_CHECK_LOADED(object);
|
858
804
|
MAGIC_COOKIE(mo, ma.cookie);
|
859
805
|
|
860
|
-
ma.flags =
|
806
|
+
ma.flags = magic_get_flags(object);
|
861
807
|
ma.type.file.fd = NUM2INT(value);
|
862
808
|
|
863
809
|
MAGIC_SYNCHRONIZED(magic_descriptor_internal, &ma);
|
@@ -1142,6 +1088,34 @@ magic_descriptor_internal(void *data)
|
|
1142
1088
|
return (VALUE)NULL;
|
1143
1089
|
}
|
1144
1090
|
|
1091
|
+
static inline void*
|
1092
|
+
magic_library_open(void)
|
1093
|
+
{
|
1094
|
+
magic_t cookie;
|
1095
|
+
|
1096
|
+
cookie = magic_open_wrapper(MAGIC_NONE);
|
1097
|
+
if (!cookie) {
|
1098
|
+
errno = ENOMEM;
|
1099
|
+
return NULL;
|
1100
|
+
}
|
1101
|
+
|
1102
|
+
return cookie;
|
1103
|
+
}
|
1104
|
+
|
1105
|
+
static inline void
|
1106
|
+
magic_library_close(void *data)
|
1107
|
+
{
|
1108
|
+
magic_object_t *mo = data;
|
1109
|
+
|
1110
|
+
assert(mo != NULL && \
|
1111
|
+
"Must be a valid pointer to `magic_object_t' type");
|
1112
|
+
|
1113
|
+
if (mo->cookie)
|
1114
|
+
magic_close_wrapper(mo->cookie);
|
1115
|
+
|
1116
|
+
mo->cookie = NULL;
|
1117
|
+
}
|
1118
|
+
|
1145
1119
|
static VALUE
|
1146
1120
|
magic_allocate(VALUE klass)
|
1147
1121
|
{
|
@@ -1163,8 +1137,8 @@ magic_allocate(VALUE klass)
|
|
1163
1137
|
mo->database_loaded = 0;
|
1164
1138
|
mo->stop_on_errors = 0;
|
1165
1139
|
|
1166
|
-
mo->cookie =
|
1167
|
-
local_errno =
|
1140
|
+
mo->cookie = magic_library_open();
|
1141
|
+
local_errno = errno;
|
1168
1142
|
|
1169
1143
|
if (!mo->cookie) {
|
1170
1144
|
ruby_xfree(mo);
|
@@ -1175,11 +1149,22 @@ magic_allocate(VALUE klass)
|
|
1175
1149
|
E_MAGIC_LIBRARY_INITIALIZE);
|
1176
1150
|
}
|
1177
1151
|
|
1178
|
-
return
|
1152
|
+
return TypedData_Wrap_Struct(klass, &rb_magic_type, mo);
|
1179
1153
|
}
|
1180
1154
|
|
1181
1155
|
static inline void
|
1182
|
-
|
1156
|
+
magic_mark(void *data)
|
1157
|
+
{
|
1158
|
+
magic_object_t *mo = data;
|
1159
|
+
|
1160
|
+
assert(mo != NULL && \
|
1161
|
+
"Must be a valid pointer to `magic_object_t' type");
|
1162
|
+
|
1163
|
+
MAGIC_GC_MARK(mo->mutex);
|
1164
|
+
}
|
1165
|
+
|
1166
|
+
static inline void
|
1167
|
+
magic_free(void *data)
|
1183
1168
|
{
|
1184
1169
|
magic_object_t *mo = data;
|
1185
1170
|
|
@@ -1187,38 +1172,37 @@ magic_library_close(void *data)
|
|
1187
1172
|
"Must be a valid pointer to `magic_object_t' type");
|
1188
1173
|
|
1189
1174
|
if (mo->cookie)
|
1190
|
-
|
1175
|
+
magic_library_close(data);
|
1191
1176
|
|
1192
1177
|
mo->cookie = NULL;
|
1178
|
+
mo->mutex = Qundef;
|
1179
|
+
|
1180
|
+
ruby_xfree(mo);
|
1193
1181
|
}
|
1194
1182
|
|
1195
|
-
static inline
|
1196
|
-
|
1183
|
+
static inline size_t
|
1184
|
+
magic_size(const void *data)
|
1197
1185
|
{
|
1198
|
-
magic_object_t *mo = data;
|
1186
|
+
const magic_object_t *mo = data;
|
1199
1187
|
|
1200
1188
|
assert(mo != NULL && \
|
1201
1189
|
"Must be a valid pointer to `magic_object_t' type");
|
1202
1190
|
|
1203
|
-
|
1191
|
+
return sizeof(*mo);
|
1204
1192
|
}
|
1205
1193
|
|
1194
|
+
#if defined(HAVE_RUBY_GC_COMPACT)
|
1206
1195
|
static inline void
|
1207
|
-
|
1196
|
+
magic_compact(void *data)
|
1208
1197
|
{
|
1209
1198
|
magic_object_t *mo = data;
|
1210
1199
|
|
1211
1200
|
assert(mo != NULL && \
|
1212
1201
|
"Must be a valid pointer to `magic_object_t' type");
|
1213
1202
|
|
1214
|
-
|
1215
|
-
magic_library_close(data);
|
1216
|
-
|
1217
|
-
mo->cookie = NULL;
|
1218
|
-
mo->mutex = Qundef;
|
1219
|
-
|
1220
|
-
ruby_xfree(mo);
|
1203
|
+
mo->mutex = rb_gc_location(mo->mutex);
|
1221
1204
|
}
|
1205
|
+
#endif /* HAVE_RUBY_GC_COMPACT */
|
1222
1206
|
|
1223
1207
|
static inline VALUE
|
1224
1208
|
magic_exception_wrapper(VALUE value)
|
@@ -1362,7 +1346,7 @@ magic_return(void *data)
|
|
1362
1346
|
}
|
1363
1347
|
|
1364
1348
|
static inline int
|
1365
|
-
|
1349
|
+
magic_get_flags(VALUE object)
|
1366
1350
|
{
|
1367
1351
|
return NUM2INT(rb_ivar_get(object, id_at_flags));
|
1368
1352
|
}
|
@@ -1379,6 +1363,19 @@ magic_set_paths(VALUE object, VALUE value)
|
|
1379
1363
|
return rb_ivar_set(object, id_at_paths, value);
|
1380
1364
|
}
|
1381
1365
|
|
1366
|
+
static const rb_data_type_t rb_magic_type = {
|
1367
|
+
.wrap_struct_name = "magic",
|
1368
|
+
.function = {
|
1369
|
+
.dmark = magic_mark,
|
1370
|
+
.dfree = magic_free,
|
1371
|
+
.dsize = magic_size,
|
1372
|
+
#if defined(HAVE_RUBY_GC_COMPACT)
|
1373
|
+
.dcompact = magic_compact,
|
1374
|
+
#endif /* HAVE_RUBY_GC_COMPACT */
|
1375
|
+
},
|
1376
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
|
1377
|
+
};
|
1378
|
+
|
1382
1379
|
void
|
1383
1380
|
Init_magic(void)
|
1384
1381
|
{
|
data/ext/magic/ruby-magic.h
CHANGED
@@ -11,7 +11,7 @@ extern "C" {
|
|
11
11
|
#define MAGIC_SYNCHRONIZED(f, d) magic_lock(object, (f), (d))
|
12
12
|
|
13
13
|
#define MAGIC_OBJECT(o) \
|
14
|
-
|
14
|
+
TypedData_Get_Struct(object, magic_object_t, &rb_magic_type, (o))
|
15
15
|
|
16
16
|
#define MAGIC_COOKIE(o, c) \
|
17
17
|
((c) = MAGIC_OBJECT((o))->cookie)
|
@@ -83,6 +83,7 @@ enum error {
|
|
83
83
|
E_NOT_ENOUGH_MEMORY,
|
84
84
|
E_ARGUMENT_MISSING,
|
85
85
|
E_ARGUMENT_TYPE_INVALID,
|
86
|
+
E_ARGUMENT_TYPE_UNKNOWN,
|
86
87
|
E_ARGUMENT_TYPE_ARRAY_EMPTY,
|
87
88
|
E_ARGUMENT_TYPE_ARRAY_STRINGS,
|
88
89
|
E_MAGIC_LIBRARY_INITIALIZE,
|
@@ -141,6 +142,7 @@ static const char *errors[] = {
|
|
141
142
|
[E_NOT_ENOUGH_MEMORY] = "cannot allocate memory",
|
142
143
|
[E_ARGUMENT_MISSING] = "wrong number of arguments (given %d, expected %d)",
|
143
144
|
[E_ARGUMENT_TYPE_INVALID] = "wrong argument type %s (expected %s)",
|
145
|
+
[E_ARGUMENT_TYPE_UNKNOWN] = "unknown type 0x%x (0x%x given)",
|
144
146
|
[E_ARGUMENT_TYPE_ARRAY_EMPTY] = "arguments list cannot be empty (expected array of String)",
|
145
147
|
[E_ARGUMENT_TYPE_ARRAY_STRINGS] = "wrong argument type %s in arguments list (expected String)",
|
146
148
|
[E_MAGIC_LIBRARY_INITIALIZE] = "failed to initialize Magic library",
|
@@ -153,6 +155,93 @@ static const char *errors[] = {
|
|
153
155
|
NULL
|
154
156
|
};
|
155
157
|
|
158
|
+
#if defined(MAGIC_CUSTOM_CHECK_TYPE)
|
159
|
+
static const char *ruby_types[] = {
|
160
|
+
"", /* Not an object */
|
161
|
+
[T_OBJECT] = "Object",
|
162
|
+
[T_CLASS] = "Class",
|
163
|
+
[T_MODULE] = "Module",
|
164
|
+
[T_FLOAT] = "Float",
|
165
|
+
[T_STRING] = "String",
|
166
|
+
[T_REGEXP] = "Regexp",
|
167
|
+
[T_ARRAY] = "Array",
|
168
|
+
[T_HASH] = "Hash",
|
169
|
+
[T_STRUCT] = "Struct",
|
170
|
+
[T_BIGNUM] = "Integer",
|
171
|
+
[T_FILE] = "File",
|
172
|
+
"", /* Internal use */
|
173
|
+
[T_MATCH] = "MatchData",
|
174
|
+
[T_COMPLEX] = "Complex",
|
175
|
+
[T_RATIONAL] = "Rational",
|
176
|
+
"", /* Internal use */
|
177
|
+
[T_NIL] = "nil",
|
178
|
+
[T_TRUE] = "true",
|
179
|
+
[T_FALSE] = "false",
|
180
|
+
[T_SYMBOL] = "Symbol",
|
181
|
+
[T_FIXNUM] = "Integer",
|
182
|
+
"", /* Internal use */
|
183
|
+
NULL
|
184
|
+
};
|
185
|
+
|
186
|
+
static const char *
|
187
|
+
magic_ruby_type_name(int type)
|
188
|
+
{
|
189
|
+
const char *name;
|
190
|
+
|
191
|
+
if (type >= ARRAY_SIZE(ruby_types))
|
192
|
+
return NULL;
|
193
|
+
|
194
|
+
name = ruby_types[type];
|
195
|
+
if (name)
|
196
|
+
return name;
|
197
|
+
|
198
|
+
return NULL;
|
199
|
+
}
|
200
|
+
|
201
|
+
static const char *
|
202
|
+
magic_ruby_class_name(VALUE object)
|
203
|
+
{
|
204
|
+
const char *name = NULL;
|
205
|
+
|
206
|
+
if (NIL_P(object))
|
207
|
+
name = "nil";
|
208
|
+
else if (RB_TYPE_P(object, T_TRUE))
|
209
|
+
name = "true";
|
210
|
+
else if (RB_TYPE_P(object, T_FALSE))
|
211
|
+
name = "false";
|
212
|
+
else
|
213
|
+
name = CLASS_NAME(object);
|
214
|
+
|
215
|
+
return name;
|
216
|
+
}
|
217
|
+
|
218
|
+
void
|
219
|
+
magic_check_ruby_type(VALUE object, int type)
|
220
|
+
{
|
221
|
+
const char *name;
|
222
|
+
int object_type = TYPE(object);
|
223
|
+
|
224
|
+
if (object == Qundef)
|
225
|
+
rb_bug("invalid type leaked to the Ruby space");
|
226
|
+
|
227
|
+
if (object_type > T_MASK || object_type == T_DATA)
|
228
|
+
goto error;
|
229
|
+
|
230
|
+
if (object_type == type)
|
231
|
+
return;
|
232
|
+
|
233
|
+
name = magic_ruby_type_name(type);
|
234
|
+
if (name)
|
235
|
+
rb_raise(rb_eTypeError, error(E_ARGUMENT_TYPE_INVALID),
|
236
|
+
magic_ruby_class_name(object),
|
237
|
+
name);
|
238
|
+
error:
|
239
|
+
rb_raise(rb_eTypeError, error(E_ARGUMENT_TYPE_UNKNOWN),
|
240
|
+
object_type,
|
241
|
+
type);
|
242
|
+
}
|
243
|
+
#endif /* MAGIC_CUSTOM_CHECK_TYPE */
|
244
|
+
|
156
245
|
static inline VALUE
|
157
246
|
magic_shift(VALUE v)
|
158
247
|
{
|
@@ -233,7 +322,7 @@ magic_check_type(VALUE object, RVALUE_TYPE type)
|
|
233
322
|
if (type == T_FIXNUM && !RVAL2CBOOL(boolean))
|
234
323
|
MAGIC_ARGUMENT_TYPE_ERROR(object, rb_class2name(T_INTEGER));
|
235
324
|
|
236
|
-
|
325
|
+
MAGIC_CHECK_RUBY_TYPE(object, type);
|
237
326
|
}
|
238
327
|
|
239
328
|
static inline void
|
@@ -250,10 +339,114 @@ magic_check_type_array_of_strings(VALUE object)
|
|
250
339
|
}
|
251
340
|
}
|
252
341
|
|
342
|
+
static int rb_mgc_do_not_auto_load;
|
343
|
+
static int rb_mgc_do_not_stop_on_error;
|
344
|
+
static int rb_mgc_warning;
|
345
|
+
|
346
|
+
static ID id_at_flags;
|
347
|
+
static ID id_at_paths;
|
348
|
+
|
349
|
+
static VALUE rb_cMagic;
|
350
|
+
|
351
|
+
static VALUE rb_mgc_eError;
|
352
|
+
static VALUE rb_mgc_eMagicError;
|
353
|
+
static VALUE rb_mgc_eLibraryError;
|
354
|
+
static VALUE rb_mgc_eNotImplementedError;
|
355
|
+
static VALUE rb_mgc_eParameterError;
|
356
|
+
static VALUE rb_mgc_eFlagsError;
|
357
|
+
|
358
|
+
static const rb_data_type_t rb_magic_type;
|
359
|
+
|
360
|
+
void Init_magic(void);
|
361
|
+
|
362
|
+
VALUE rb_mgc_get_do_not_auto_load_global(VALUE object);
|
363
|
+
VALUE rb_mgc_set_do_not_auto_load_global(VALUE object, VALUE value);
|
364
|
+
VALUE rb_mgc_get_do_not_stop_on_error_global(VALUE object);
|
365
|
+
VALUE rb_mgc_set_do_not_stop_on_error_global(VALUE object, VALUE value);
|
366
|
+
|
367
|
+
VALUE rb_mgc_initialize(VALUE object, VALUE arguments);
|
368
|
+
|
369
|
+
VALUE rb_mgc_get_do_not_stop_on_error(VALUE object);
|
370
|
+
VALUE rb_mgc_set_do_not_stop_on_error(VALUE object, VALUE value);
|
371
|
+
|
372
|
+
VALUE rb_mgc_open_p(VALUE object);
|
373
|
+
VALUE rb_mgc_close(VALUE object);
|
253
374
|
VALUE rb_mgc_close_p(VALUE object);
|
375
|
+
|
376
|
+
VALUE rb_mgc_get_paths(VALUE object);
|
377
|
+
|
378
|
+
VALUE rb_mgc_get_parameter(VALUE object, VALUE tag);
|
379
|
+
VALUE rb_mgc_set_parameter(VALUE object, VALUE tag, VALUE value);
|
380
|
+
|
381
|
+
VALUE rb_mgc_get_flags(VALUE object);
|
382
|
+
VALUE rb_mgc_set_flags(VALUE object, VALUE value);
|
383
|
+
|
254
384
|
VALUE rb_mgc_load(VALUE object, VALUE arguments);
|
385
|
+
VALUE rb_mgc_load_buffers(VALUE object, VALUE arguments);
|
386
|
+
VALUE rb_mgc_load_p(VALUE object);
|
387
|
+
|
388
|
+
VALUE rb_mgc_compile(VALUE object, VALUE arguments);
|
389
|
+
VALUE rb_mgc_check(VALUE object, VALUE arguments);
|
390
|
+
|
391
|
+
VALUE rb_mgc_file(VALUE object, VALUE value);
|
392
|
+
VALUE rb_mgc_buffer(VALUE object, VALUE value);
|
255
393
|
VALUE rb_mgc_descriptor(VALUE object, VALUE value);
|
256
394
|
|
395
|
+
VALUE rb_mgc_version(VALUE object);
|
396
|
+
|
397
|
+
static VALUE magic_get_parameter_internal(void *data);
|
398
|
+
static VALUE magic_set_parameter_internal(void *data);
|
399
|
+
|
400
|
+
static VALUE magic_get_flags_internal(void *data);
|
401
|
+
static VALUE magic_set_flags_internal(void *data);
|
402
|
+
|
403
|
+
static VALUE magic_load_internal(void *data);
|
404
|
+
static VALUE magic_load_buffers_internal(void *data);
|
405
|
+
|
406
|
+
static VALUE magic_compile_internal(void *data);
|
407
|
+
static VALUE magic_check_internal(void *data);
|
408
|
+
|
409
|
+
static VALUE magic_file_internal(void *data);
|
410
|
+
static VALUE magic_buffer_internal(void *data);
|
411
|
+
static VALUE magic_descriptor_internal(void *data);
|
412
|
+
|
413
|
+
static VALUE magic_close_internal(void *data);
|
414
|
+
|
415
|
+
static void* nogvl_magic_load(void *data);
|
416
|
+
static void* nogvl_magic_compile(void *data);
|
417
|
+
static void* nogvl_magic_check(void *data);
|
418
|
+
static void* nogvl_magic_file(void *data);
|
419
|
+
static void* nogvl_magic_descriptor(void *data);
|
420
|
+
|
421
|
+
static void* magic_library_open(void);
|
422
|
+
static void magic_library_close(void *data);
|
423
|
+
|
424
|
+
static VALUE magic_allocate(VALUE klass);
|
425
|
+
static void magic_mark(void *data);
|
426
|
+
static void magic_free(void *data);
|
427
|
+
static size_t magic_size(const void *data);
|
428
|
+
#if defined(HAVE_RUBY_GC_COMPACT)
|
429
|
+
static void magic_compact(void *data);
|
430
|
+
#endif
|
431
|
+
|
432
|
+
static VALUE magic_exception_wrapper(VALUE value);
|
433
|
+
static VALUE magic_exception(void *data);
|
434
|
+
|
435
|
+
static VALUE magic_library_error(VALUE klass, void *data);
|
436
|
+
static VALUE magic_generic_error(VALUE klass, int magic_errno,
|
437
|
+
const char *magic_error);
|
438
|
+
|
439
|
+
static VALUE magic_lock(VALUE object, VALUE (*function)(ANYARGS),
|
440
|
+
void *data);
|
441
|
+
static VALUE magic_unlock(VALUE object);
|
442
|
+
|
443
|
+
static VALUE magic_return(void *data);
|
444
|
+
|
445
|
+
static int magic_get_flags(VALUE object);
|
446
|
+
static int magic_set_flags(VALUE object, VALUE value);
|
447
|
+
|
448
|
+
static VALUE magic_set_paths(VALUE object, VALUE value);
|
449
|
+
|
257
450
|
#if defined(__cplusplus)
|
258
451
|
}
|
259
452
|
#endif
|
data/lib/magic/version.rb
CHANGED
data/patches/libmagic/0001-Don-t-attempt-to-build-tests-documentation-and-Python-bindings.patch
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
From 0f2752ad4d7ea65c80d76493899aca67e90be524 Mon Sep 17 00:00:00 2001
|
2
|
+
From: =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= <kw@linux.com>
|
3
|
+
Date: Mon, 5 Apr 2021 16:51:59 +0000
|
4
|
+
Subject: [PATCH] Don't attempt to build tests, documentation and Python
|
5
|
+
bindings
|
6
|
+
MIME-Version: 1.0
|
7
|
+
Content-Type: text/plain; charset=UTF-8
|
8
|
+
Content-Transfer-Encoding: 8bit
|
9
|
+
|
10
|
+
Signed-off-by: Krzysztof Wilczyński <kw@linux.com>
|
11
|
+
---
|
12
|
+
Makefile.am | 2 +-
|
13
|
+
Makefile.in | 2 +-
|
14
|
+
2 files changed, 2 insertions(+), 2 deletions(-)
|
15
|
+
|
16
|
+
diff --git a/Makefile.am b/Makefile.am
|
17
|
+
index 2ab67ed..c7fafeb 100644
|
18
|
+
--- a/Makefile.am
|
19
|
+
+++ b/Makefile.am
|
20
|
+
@@ -2,7 +2,7 @@ ACLOCAL_AMFLAGS = -I m4
|
21
|
+
|
22
|
+
EXTRA_DIST = MAINT
|
23
|
+
|
24
|
+
-SUBDIRS = src magic tests doc python
|
25
|
+
+SUBDIRS = src magic
|
26
|
+
|
27
|
+
# This variable must have 'exec' in its name, in order to be installed
|
28
|
+
# by 'install-exec' target (instead of default 'install-data')
|
29
|
+
diff --git a/Makefile.in b/Makefile.in
|
30
|
+
index e19b15e..dcb5ce6 100644
|
31
|
+
--- a/Makefile.in
|
32
|
+
+++ b/Makefile.in
|
33
|
+
@@ -358,7 +358,7 @@ top_builddir = @top_builddir@
|
34
|
+
top_srcdir = @top_srcdir@
|
35
|
+
ACLOCAL_AMFLAGS = -I m4
|
36
|
+
EXTRA_DIST = MAINT
|
37
|
+
-SUBDIRS = src magic tests doc python
|
38
|
+
+SUBDIRS = src magic
|
39
|
+
|
40
|
+
# This variable must have 'exec' in its name, in order to be installed
|
41
|
+
# by 'install-exec' target (instead of default 'install-data')
|
42
|
+
--
|
43
|
+
2.31.0
|
44
|
+
|
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-magic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Krzysztof Wilczyński
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain:
|
11
11
|
- kwilczynski-public.pem
|
12
|
-
date: 2021-04-
|
12
|
+
date: 2021-04-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mini_portile2
|
@@ -42,6 +42,7 @@ files:
|
|
42
42
|
- LICENSE
|
43
43
|
- NOTICE
|
44
44
|
- README.md
|
45
|
+
- dependencies.yml
|
45
46
|
- ext/magic/common.h
|
46
47
|
- ext/magic/extconf.rb
|
47
48
|
- ext/magic/functions.c
|
@@ -53,6 +54,8 @@ files:
|
|
53
54
|
- lib/magic/core/file.rb
|
54
55
|
- lib/magic/core/string.rb
|
55
56
|
- lib/magic/version.rb
|
57
|
+
- patches/libmagic/0001-Don-t-attempt-to-build-tests-documentation-and-Python-bindings.patch
|
58
|
+
- ports/archives/file-5.39.tar.gz
|
56
59
|
homepage: https://github.com/kwilczynski/ruby-magic
|
57
60
|
licenses:
|
58
61
|
- Apache-2.0
|