ruby-magic 0.0.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/AUTHORS +1 -1
- data/CHANGELOG.md +60 -0
- data/CONTRIBUTORS.md +17 -0
- data/COPYRIGHT +1 -1
- data/NOTICE +505 -0
- data/README.md +49 -0
- data/dependencies.yml +93 -0
- data/ext/magic/common.h +130 -59
- data/ext/magic/extconf.rb +404 -64
- data/ext/magic/functions.c +265 -187
- data/ext/magic/functions.h +46 -79
- data/ext/magic/ruby-magic.c +1288 -641
- data/ext/magic/ruby-magic.h +383 -173
- data/kwilczynski-public.pem +25 -0
- data/lib/magic.rb +86 -87
- data/lib/magic/core/file.rb +8 -66
- data/lib/magic/core/string.rb +4 -47
- data/lib/magic/version.rb +14 -48
- 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 +36 -99
- data/CHANGES +0 -5
- data/CHANGES.rdoc +0 -5
- data/README +0 -1
- data/README.rdoc +0 -7
- data/Rakefile +0 -78
- data/TODO +0 -21
- data/VERSION +0 -1
- data/bin/magic +0 -33
- data/ruby-magic.gemspec +0 -68
- data/test/test_constants.rb +0 -47
- data/test/test_magic.rb +0 -260
data/ext/magic/ruby-magic.h
CHANGED
@@ -1,23 +1,3 @@
|
|
1
|
-
/* :enddoc: */
|
2
|
-
|
3
|
-
/*
|
4
|
-
* ruby-magic.h
|
5
|
-
*
|
6
|
-
* Copyright 2013-2014 Krzysztof Wilczynski
|
7
|
-
*
|
8
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
-
* you may not use this file except in compliance with the License.
|
10
|
-
* You may obtain a copy of the License at
|
11
|
-
*
|
12
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
13
|
-
*
|
14
|
-
* Unless required by applicable law or agreed to in writing, software
|
15
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
-
* See the License for the specific language governing permissions and
|
18
|
-
* limitations under the License.
|
19
|
-
*/
|
20
|
-
|
21
1
|
#if !defined(_RUBY_MAGIC_H)
|
22
2
|
#define _RUBY_MAGIC_H 1
|
23
3
|
|
@@ -28,217 +8,447 @@ extern "C" {
|
|
28
8
|
#include "common.h"
|
29
9
|
#include "functions.h"
|
30
10
|
|
31
|
-
#define
|
32
|
-
#define STRING_P(x) (TYPE(x) == T_STRING)
|
33
|
-
#define ARRAY_P(x) (TYPE(x) == T_ARRAY)
|
11
|
+
#define MAGIC_SYNCHRONIZED(f, d) magic_lock(object, (f), (d))
|
34
12
|
|
35
|
-
#
|
36
|
-
|
37
|
-
#endif
|
13
|
+
#define MAGIC_OBJECT(o) \
|
14
|
+
TypedData_Get_Struct(object, magic_object_t, &rb_magic_type, (o))
|
38
15
|
|
39
|
-
#
|
40
|
-
|
41
|
-
#endif
|
16
|
+
#define MAGIC_COOKIE(o, c) \
|
17
|
+
((c) = MAGIC_OBJECT((o))->cookie)
|
42
18
|
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#endif
|
19
|
+
#define MAGIC_CLOSED_P(o) RTEST(rb_mgc_close_p((o)))
|
20
|
+
#define MAGIC_LOADED_P(o) RTEST(rb_mgc_load_p((o)))
|
46
21
|
|
47
|
-
#
|
48
|
-
|
49
|
-
|
22
|
+
#define MAGIC_WARNING(i, ...) \
|
23
|
+
do { \
|
24
|
+
if (!(i) || !(rb_mgc_warning & BIT(i))) { \
|
25
|
+
rb_mgc_warning |= BIT(i); \
|
26
|
+
rb_warn(__VA_ARGS__); \
|
27
|
+
} \
|
28
|
+
} while(0)
|
50
29
|
|
51
|
-
#
|
52
|
-
|
53
|
-
#endif
|
30
|
+
#define MAGIC_ARGUMENT_TYPE_ERROR(o, ...) \
|
31
|
+
rb_raise(rb_eTypeError, error(E_ARGUMENT_TYPE_INVALID), CLASS_NAME((o)), __VA_ARGS__)
|
54
32
|
|
55
|
-
#
|
56
|
-
|
57
|
-
#endif
|
33
|
+
#define MAGIC_GENERIC_ERROR(k, e, m) \
|
34
|
+
rb_exc_raise(magic_generic_error((k), (e), error(m)))
|
58
35
|
|
59
|
-
#define
|
60
|
-
|
61
|
-
#define RARRAY_FIRST(a) (RARRAY_EMPTY_P(a) ? Qnil : RARRAY_PTR(a)[0])
|
62
|
-
|
63
|
-
#define NOGVL_FUNCTION (VALUE (*)(void *))
|
64
|
-
|
65
|
-
#if defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL) && \
|
66
|
-
defined(HAVE_RUBY_THREAD_H) && HAVE_RUBY_THREAD_H
|
67
|
-
# include <ruby/thread.h>
|
68
|
-
# define NOGVL(f, d) \
|
69
|
-
rb_thread_call_without_gvl((f), (d), RUBY_UBF_IO, NULL)
|
70
|
-
#elif defined(HAVE_RB_THREAD_BLOCKING_REGION)
|
71
|
-
# define NOGVL(f, d) \
|
72
|
-
rb_thread_blocking_region(NOGVL_FUNCTION(f), (d), RUBY_UBF_IO, NULL)
|
73
|
-
#else
|
74
|
-
# include <rubysig.h>
|
75
|
-
static inline VALUE
|
76
|
-
fake_blocking_region(VALUE (*f)(ANYARGS), void *data)
|
77
|
-
{
|
78
|
-
VALUE rv;
|
36
|
+
#define MAGIC_LIBRARY_ERROR(c) \
|
37
|
+
rb_exc_raise(magic_library_error(rb_mgc_eMagicError, (c)))
|
79
38
|
|
80
|
-
|
81
|
-
|
82
|
-
TRAP_END;
|
39
|
+
#define MAGIC_CHECK_INTEGER_TYPE(o) magic_check_type((o), T_FIXNUM)
|
40
|
+
#define MAGIC_CHECK_STRING_TYPE(o) magic_check_type((o), T_STRING)
|
83
41
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
42
|
+
#define MAGIC_CHECK_ARGUMENT_MISSING(t, o) \
|
43
|
+
do { \
|
44
|
+
if ((t) < (o)) \
|
45
|
+
rb_raise(rb_eArgError, error(E_ARGUMENT_MISSING), (t), (o)); \
|
46
|
+
} while(0)
|
88
47
|
|
89
|
-
#define
|
48
|
+
#define MAGIC_CHECK_ARRAY_EMPTY(o) \
|
49
|
+
do { \
|
50
|
+
if (RARRAY_EMPTY_P(o)) \
|
51
|
+
rb_raise(rb_eArgError, "%s", error(E_ARGUMENT_TYPE_ARRAY_EMPTY)); \
|
52
|
+
} while(0)
|
90
53
|
|
91
|
-
#define
|
92
|
-
|
54
|
+
#define MAGIC_CHECK_ARRAY_OF_STRINGS(o) \
|
55
|
+
magic_check_type_array_of_strings((o))
|
93
56
|
|
94
|
-
#define
|
57
|
+
#define MAGIC_CHECK_OPEN(o) \
|
58
|
+
do { \
|
59
|
+
if (MAGIC_CLOSED_P(o)) \
|
60
|
+
MAGIC_GENERIC_ERROR(rb_mgc_eLibraryError, EFAULT, \
|
61
|
+
E_MAGIC_LIBRARY_CLOSED); \
|
62
|
+
} while(0)
|
95
63
|
|
96
|
-
#define
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
64
|
+
#define MAGIC_CHECK_LOADED(o) \
|
65
|
+
do { \
|
66
|
+
if (!MAGIC_LOADED_P(o)) \
|
67
|
+
MAGIC_GENERIC_ERROR(rb_mgc_eMagicError, EFAULT, \
|
68
|
+
E_MAGIC_LIBRARY_NOT_LOADED); \
|
69
|
+
} while(0)
|
101
70
|
|
102
|
-
#define
|
103
|
-
do { \
|
104
|
-
VALUE __e_library = magic_library_error(rb_mgc_eMagicError, (c)); \
|
105
|
-
rb_exc_raise(__e_library); \
|
106
|
-
} while(0)
|
71
|
+
#define MAGIC_STRINGIFY(s) #s
|
107
72
|
|
108
|
-
#define
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
} \
|
114
|
-
} while(0) \
|
73
|
+
#define MAGIC_DEFINE_FLAG(c) \
|
74
|
+
rb_define_const(rb_cMagic, MAGIC_STRINGIFY(c), INT2NUM(MAGIC_##c));
|
75
|
+
|
76
|
+
#define MAGIC_DEFINE_PARAMETER(c) \
|
77
|
+
rb_define_const(rb_cMagic, MAGIC_STRINGIFY(PARAM_##c), INT2NUM(MAGIC_PARAM_##c));
|
115
78
|
|
116
79
|
#define error(t) errors[(t)]
|
117
80
|
|
118
81
|
enum error {
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
82
|
+
E_UNKNOWN = 0,
|
83
|
+
E_NOT_ENOUGH_MEMORY,
|
84
|
+
E_ARGUMENT_MISSING,
|
85
|
+
E_ARGUMENT_TYPE_INVALID,
|
86
|
+
E_ARGUMENT_TYPE_UNKNOWN,
|
87
|
+
E_ARGUMENT_TYPE_ARRAY_EMPTY,
|
88
|
+
E_ARGUMENT_TYPE_ARRAY_STRINGS,
|
89
|
+
E_MAGIC_LIBRARY_INITIALIZE,
|
90
|
+
E_MAGIC_LIBRARY_CLOSED,
|
91
|
+
E_MAGIC_LIBRARY_NOT_LOADED,
|
92
|
+
E_PARAM_INVALID_TYPE,
|
93
|
+
E_PARAM_INVALID_VALUE,
|
94
|
+
E_FLAG_NOT_IMPLEMENTED,
|
95
|
+
E_FLAG_INVALID_TYPE
|
125
96
|
};
|
126
97
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
};
|
98
|
+
typedef struct parameter {
|
99
|
+
size_t value;
|
100
|
+
int tag;
|
101
|
+
} parameter_t;
|
102
|
+
|
103
|
+
typedef union file {
|
104
|
+
const char *path;
|
105
|
+
int fd;
|
106
|
+
} file_t;
|
107
|
+
|
108
|
+
typedef struct buffers {
|
109
|
+
size_t count;
|
110
|
+
size_t *sizes;
|
111
|
+
void **pointers;
|
112
|
+
} buffers_t;
|
113
|
+
|
114
|
+
typedef struct magic_object {
|
115
|
+
magic_t cookie;
|
116
|
+
VALUE mutex;
|
117
|
+
unsigned int database_loaded:1;
|
118
|
+
unsigned int stop_on_errors:1;
|
119
|
+
} magic_object_t;
|
120
|
+
|
121
|
+
typedef struct magic_arguments {
|
122
|
+
union {
|
123
|
+
file_t file;
|
124
|
+
parameter_t parameter;
|
125
|
+
buffers_t buffers;
|
126
|
+
} type;
|
127
|
+
magic_t cookie;
|
128
|
+
const char *result;
|
129
|
+
int flags;
|
130
|
+
int status;
|
131
|
+
unsigned int stop_on_errors:1;
|
132
|
+
} magic_arguments_t;
|
133
|
+
|
134
|
+
typedef struct magic_exception {
|
135
|
+
const char *magic_error;
|
136
|
+
VALUE klass;
|
137
|
+
int magic_errno;
|
138
|
+
} magic_exception_t;
|
131
139
|
|
132
|
-
|
133
|
-
|
134
|
-
|
140
|
+
static const char *errors[] = {
|
141
|
+
[E_UNKNOWN] = "an unknown error has occurred",
|
142
|
+
[E_NOT_ENOUGH_MEMORY] = "cannot allocate memory",
|
143
|
+
[E_ARGUMENT_MISSING] = "wrong number of arguments (given %d, expected %d)",
|
144
|
+
[E_ARGUMENT_TYPE_INVALID] = "wrong argument type %s (expected %s)",
|
145
|
+
[E_ARGUMENT_TYPE_UNKNOWN] = "unknown type 0x%x (0x%x given)",
|
146
|
+
[E_ARGUMENT_TYPE_ARRAY_EMPTY] = "arguments list cannot be empty (expected array of String)",
|
147
|
+
[E_ARGUMENT_TYPE_ARRAY_STRINGS] = "wrong argument type %s in arguments list (expected String)",
|
148
|
+
[E_MAGIC_LIBRARY_INITIALIZE] = "failed to initialize Magic library",
|
149
|
+
[E_MAGIC_LIBRARY_CLOSED] = "Magic library is not open",
|
150
|
+
[E_MAGIC_LIBRARY_NOT_LOADED] = "Magic library not loaded",
|
151
|
+
[E_PARAM_INVALID_TYPE] = "unknown or invalid parameter specified",
|
152
|
+
[E_PARAM_INVALID_VALUE] = "invalid parameter value specified",
|
153
|
+
[E_FLAG_NOT_IMPLEMENTED] = "flag is not implemented",
|
154
|
+
[E_FLAG_INVALID_TYPE] = "unknown or invalid flag specified",
|
155
|
+
NULL
|
135
156
|
};
|
136
157
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
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
|
147
184
|
};
|
148
185
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
};
|
186
|
+
static const char *
|
187
|
+
magic_ruby_type_name(int type)
|
188
|
+
{
|
189
|
+
const char *name;
|
154
190
|
|
155
|
-
|
156
|
-
|
191
|
+
if (type >= ARRAY_SIZE(ruby_types))
|
192
|
+
return NULL;
|
157
193
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
"flag is not implemented",
|
165
|
-
NULL
|
166
|
-
};
|
194
|
+
name = ruby_types[type];
|
195
|
+
if (name)
|
196
|
+
return name;
|
197
|
+
|
198
|
+
return NULL;
|
199
|
+
}
|
167
200
|
|
168
|
-
|
169
|
-
|
201
|
+
static const char *
|
202
|
+
magic_ruby_class_name(VALUE object)
|
170
203
|
{
|
171
|
-
|
172
|
-
|
173
|
-
|
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
|
+
}
|
174
217
|
|
175
|
-
|
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);
|
176
242
|
}
|
243
|
+
#endif /* MAGIC_CUSTOM_CHECK_TYPE */
|
177
244
|
|
178
|
-
inline
|
245
|
+
static inline VALUE
|
179
246
|
magic_shift(VALUE v)
|
180
247
|
{
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
return Qnil;
|
248
|
+
return ARRAY_P(v) ? \
|
249
|
+
rb_funcall(v, rb_intern("shift"), 0) : \
|
250
|
+
Qnil;
|
186
251
|
}
|
187
252
|
|
188
|
-
inline
|
253
|
+
static inline VALUE
|
189
254
|
magic_split(VALUE a, VALUE b)
|
190
255
|
{
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
return Qnil;
|
256
|
+
return (STRING_P(a) && STRING_P(b)) ? \
|
257
|
+
rb_funcall(a, rb_intern("split"), 1, b) : \
|
258
|
+
Qnil;
|
196
259
|
}
|
197
260
|
|
198
|
-
inline
|
261
|
+
static inline VALUE
|
199
262
|
magic_join(VALUE a, VALUE b)
|
200
263
|
{
|
201
|
-
|
202
|
-
|
203
|
-
|
264
|
+
return (ARRAY_P(a) && STRING_P(b)) ? \
|
265
|
+
rb_funcall(a, rb_intern("join"), 1, b) : \
|
266
|
+
Qnil;
|
267
|
+
}
|
268
|
+
|
269
|
+
static inline VALUE
|
270
|
+
magic_flatten(VALUE v)
|
271
|
+
{
|
272
|
+
return ARRAY_P(v) ? \
|
273
|
+
rb_funcall(v, rb_intern("flatten"), 0) : \
|
274
|
+
Qnil;
|
275
|
+
}
|
276
|
+
|
277
|
+
static int
|
278
|
+
magic_fileno(VALUE object)
|
279
|
+
{
|
280
|
+
int fd;
|
281
|
+
rb_io_t *io;
|
282
|
+
|
283
|
+
if (rb_respond_to(object, rb_intern("fileno"))) {
|
284
|
+
object = rb_funcall(object, rb_intern("fileno"), 0);
|
285
|
+
return NUM2INT(object);
|
286
|
+
}
|
287
|
+
|
288
|
+
if (!FILE_P(object))
|
289
|
+
object = rb_convert_type(object, T_FILE, "IO", "to_io");
|
290
|
+
|
291
|
+
GetOpenFile(object, io);
|
292
|
+
if ((fd = FPTR_TO_FD(io)) < 0)
|
293
|
+
rb_raise(rb_eIOError, "closed stream");
|
294
|
+
|
295
|
+
return fd;
|
296
|
+
}
|
297
|
+
|
298
|
+
static inline VALUE
|
299
|
+
magic_path(VALUE object)
|
300
|
+
{
|
301
|
+
if (STRING_P(object))
|
302
|
+
return object;
|
303
|
+
|
304
|
+
if (rb_respond_to(object, rb_intern("to_path")))
|
305
|
+
return rb_funcall(object, rb_intern("to_path"), 0);
|
306
|
+
|
307
|
+
if (rb_respond_to(object, rb_intern("path")))
|
308
|
+
return rb_funcall(object, rb_intern("path"), 0);
|
309
|
+
|
310
|
+
if (rb_respond_to(object, rb_intern("to_s")))
|
311
|
+
return rb_funcall(object, rb_intern("to_s"), 0);
|
312
|
+
|
313
|
+
return Qnil;
|
314
|
+
}
|
315
|
+
|
316
|
+
static inline void
|
317
|
+
magic_check_type(VALUE object, RVALUE_TYPE type)
|
318
|
+
{
|
319
|
+
VALUE boolean = Qundef;
|
320
|
+
|
321
|
+
boolean = rb_obj_is_kind_of(object, T_INTEGER);
|
322
|
+
if (type == T_FIXNUM && !RVAL2CBOOL(boolean))
|
323
|
+
MAGIC_ARGUMENT_TYPE_ERROR(object, rb_class2name(T_INTEGER));
|
324
|
+
|
325
|
+
MAGIC_CHECK_RUBY_TYPE(object, type);
|
326
|
+
}
|
204
327
|
|
205
|
-
|
328
|
+
static inline void
|
329
|
+
magic_check_type_array_of_strings(VALUE object)
|
330
|
+
{
|
331
|
+
VALUE value = Qundef;
|
332
|
+
|
333
|
+
for (int i = 0; i < RARRAY_LEN(object); i++) {
|
334
|
+
value = RARRAY_AREF(object, (long)i);
|
335
|
+
if (NIL_P(value) || !STRING_P(value))
|
336
|
+
rb_raise(rb_eTypeError,
|
337
|
+
error(E_ARGUMENT_TYPE_ARRAY_STRINGS),
|
338
|
+
CLASS_NAME(value));
|
339
|
+
}
|
206
340
|
}
|
207
341
|
|
208
|
-
|
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;
|
209
359
|
|
210
|
-
|
360
|
+
void Init_magic(void);
|
211
361
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
RUBY_EXTERN VALUE rb_mgc_eNotImplementedError;
|
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);
|
217
366
|
|
218
|
-
|
367
|
+
VALUE rb_mgc_initialize(VALUE object, VALUE arguments);
|
219
368
|
|
220
|
-
|
221
|
-
|
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);
|
222
371
|
|
223
|
-
|
372
|
+
VALUE rb_mgc_open_p(VALUE object);
|
373
|
+
VALUE rb_mgc_close(VALUE object);
|
374
|
+
VALUE rb_mgc_close_p(VALUE object);
|
224
375
|
|
225
|
-
|
226
|
-
RUBY_EXTERN VALUE rb_mgc_set_flags(VALUE object, VALUE value);
|
376
|
+
VALUE rb_mgc_get_paths(VALUE object);
|
227
377
|
|
228
|
-
|
229
|
-
|
230
|
-
RUBY_EXTERN VALUE rb_mgc_check(VALUE object, VALUE arguments);
|
378
|
+
VALUE rb_mgc_get_parameter(VALUE object, VALUE tag);
|
379
|
+
VALUE rb_mgc_set_parameter(VALUE object, VALUE tag, VALUE value);
|
231
380
|
|
232
|
-
|
233
|
-
|
234
|
-
RUBY_EXTERN VALUE rb_mgc_descriptor(VALUE object, VALUE value);
|
381
|
+
VALUE rb_mgc_get_flags(VALUE object);
|
382
|
+
VALUE rb_mgc_set_flags(VALUE object, VALUE value);
|
235
383
|
|
236
|
-
|
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);
|
393
|
+
VALUE rb_mgc_descriptor(VALUE object, VALUE value);
|
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);
|
237
449
|
|
238
450
|
#if defined(__cplusplus)
|
239
451
|
}
|
240
452
|
#endif
|
241
453
|
|
242
454
|
#endif /* _RUBY_MAGIC_H */
|
243
|
-
|
244
|
-
/* vim: set ts=8 sw=4 sts=2 et : */
|