ruby-magic 0.3.0 → 0.5.0

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.
data/ext/magic/extconf.rb CHANGED
@@ -1,42 +1,195 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'find'
3
4
  require 'mkmf'
4
- require 'digest'
5
- require 'open-uri'
6
-
7
- LIBMAGIC_TAG = '5.39'.freeze
8
-
9
- workdir = Dir.pwd
10
- libdir = File.join(workdir, 'file-' + LIBMAGIC_TAG)
11
- gemdir = File.expand_path(File.join(__dir__, '../..'))
12
- gem_ext_dir = File.join(gemdir, 'lib', 'ext')
13
- gem_include_dir = File.join(gem_ext_dir, 'include')
14
- gem_lib_dir = File.join(gem_ext_dir, 'lib')
15
- build_lib_dir = File.join(libdir, 'src', '.libs')
16
-
17
- expected_sha256 = 'f05d286a76d9556243d0cb05814929c2ecf3a5ba07963f8f70bfaaa70517fad1'
18
- filename = "#{workdir}/file.tar.gz"
19
-
20
- unless File.exist?(filename)
21
- File.open(filename, 'wb') do |target_file|
22
- URI.open("https://fossies.org/linux/misc/file-#{LIBMAGIC_TAG}.tar.gz", 'rb') do |read_file|
23
- target_file.write(read_file.read)
5
+ require 'pathname'
6
+
7
+ # helpful constants
8
+ PACKAGE_ROOT_DIR = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
9
+
10
+ # The gem version constraint in the Rakefile is not respected at install time.
11
+ # Keep this version in sync with the one in the Rakefile !
12
+ REQUIRED_MINI_PORTILE_VERSION = "~> 2.6"
13
+
14
+ MAGIC_HELP_MESSAGE = <<~HELP
15
+ USAGE: ruby #{$0} [options]
16
+
17
+ Flags that are always valid:
18
+
19
+ --use-system-libraries
20
+ --enable-system-libraries
21
+ Use system libraries instead of building and using the packaged libraries.
22
+
23
+ --disable-system-libraries
24
+ Use the packaged libraries, and ignore the system libraries. This is the default on most
25
+ platforms, and overrides `--use-system-libraries` and the environment variable
26
+ `MAGIC_USE_SYSTEM_LIBRARIES`.
27
+
28
+ --disable-clean
29
+ Do not clean out intermediate files after successful build.
30
+
31
+ Flags only used when building and using the packaged libraries:
32
+
33
+ --disable-static
34
+ Do not statically link packaged libraries, instead use shared libraries.
35
+
36
+ --enable-cross-build
37
+ Enable cross-build mode. (You probably do not want to set this manually.)
38
+
39
+ Flags only used when using system libraries:
40
+
41
+ Related to libmagic:
42
+
43
+ --with-magic-dir=DIRECTORY
44
+ Look for libmagic headers and library in DIRECTORY.
45
+
46
+ --with-magic-lib=DIRECTORY
47
+ Look for libmagic library in DIRECTORY.
48
+
49
+ --with-magic-include=DIRECTORY
50
+ Look for libmagic headers in DIRECTORY.
51
+
52
+ Environment variables used:
53
+
54
+ CC
55
+ Use this path to invoke the compiler instead of `RbConfig::CONFIG['CC']`
56
+
57
+ CPPFLAGS
58
+ If this string is accepted by the C preprocessor, add it to the flags passed to the C preprocessor
59
+
60
+ CFLAGS
61
+ If this string is accepted by the compiler, add it to the flags passed to the compiler
62
+
63
+ LDFLAGS
64
+ If this string is accepted by the linker, add it to the flags passed to the linker
65
+
66
+ LIBS
67
+ Add this string to the flags passed to the linker
68
+ HELP
69
+
70
+ def process_recipe(name, version, static_p, cross_p)
71
+ require 'rubygems'
72
+ gem('mini_portile2', REQUIRED_MINI_PORTILE_VERSION)
73
+ require 'mini_portile2'
74
+ message("Using mini_portile version #{MiniPortile::VERSION}\n")
75
+
76
+ MiniPortile.new(name, version).tap do |recipe|
77
+ # Prefer host_alias over host in order to use i586-mingw32msvc as
78
+ # correct compiler prefix for cross build, but use host if not set.
79
+ recipe.host = RbConfig::CONFIG["host_alias"].empty? ? RbConfig::CONFIG["host"] : RbConfig::CONFIG["host_alias"]
80
+ recipe.target = File.join(PACKAGE_ROOT_DIR, "ports")
81
+ recipe.patch_files = Dir[File.join(PACKAGE_ROOT_DIR, "patches", name, "*.patch")].sort
82
+ recipe.configure_options << "--libdir=#{File.join(recipe.path, 'lib')}"
83
+
84
+ yield recipe
85
+
86
+ env = Hash.new do |hash, key|
87
+ hash[key] = (ENV[key]).to_s
24
88
  end
25
- end
26
89
 
27
- checksum = Digest::SHA256.hexdigest(File.read(filename))
90
+ recipe.configure_options.flatten!
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
+
106
+ recipe.configure_options = [
107
+ "--disable-silent-rules",
108
+ "--disable-dependency-tracking",
109
+ "--enable-fsect-man5"
110
+ ]
111
+
112
+ if static_p
113
+ recipe.configure_options += [
114
+ "--disable-shared",
115
+ "--enable-static",
116
+ ]
117
+ env["CFLAGS"] = concat_flags(env["CFLAGS"], "-fPIC")
118
+ else
119
+ recipe.configure_options += [
120
+ "--enable-shared",
121
+ "--disable-static",
122
+ ]
123
+ end
124
+
125
+ if cross_p
126
+ recipe.configure_options += [
127
+ "--target=#{recipe.host}",
128
+ "--host=#{recipe.host}",
129
+ ]
130
+ end
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
+
140
+ recipe.configure_options += env.map do |key, value|
141
+ "#{key}=#{value.strip}"
142
+ end
143
+
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
28
154
 
29
- if checksum != expected_sha256
30
- raise "SHA256 of #{filename} does not match: got #{checksum}, expected #{expected_sha256}"
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
+
168
+ recipe.activate
31
169
  end
32
170
  end
33
171
 
34
- system("tar -xzf #{filename}") || raise('ERROR')
35
- system("cd #{libdir} && ./configure --prefix=#{gem_ext_dir} && make install") || raise('ERROR')
172
+ #
173
+ # utility functions
174
+ #
175
+ def config_clean?
176
+ enable_config('clean', true)
177
+ end
178
+
179
+ def config_static?
180
+ default_static = !truffle?
181
+ enable_config("static", default_static)
182
+ end
183
+
184
+ def config_cross_build?
185
+ enable_config("cross-build")
186
+ end
36
187
 
37
- $LOCAL_LIBS << '-lmagic'
38
- $LIBPATH << gem_lib_dir
39
- $CFLAGS << " -I #{libdir}/src"
188
+ def config_system_libraries?
189
+ enable_config("system-libraries", ENV.key?("MAGIC_USE_SYSTEM_LIBRARIES")) do |_, default|
190
+ arg_config('--use-system-libraries', default)
191
+ end
192
+ end
40
193
 
41
194
  def darwin?
42
195
  RbConfig::CONFIG['target_os'] =~ /darwin/
@@ -46,38 +199,144 @@ def windows?
46
199
  RbConfig::CONFIG['target_os'] =~ /mswin|mingw32|windows/
47
200
  end
48
201
 
202
+ def truffle?
203
+ ::RUBY_ENGINE == 'truffleruby'
204
+ end
205
+
206
+ def concat_flags(*args)
207
+ args.compact.join(" ")
208
+ end
209
+
210
+ def do_help
211
+ print(MAGIC_HELP_MESSAGE)
212
+ exit!(0)
213
+ end
214
+
215
+ def do_clean
216
+ root = Pathname(PACKAGE_ROOT_DIR)
217
+ pwd = Pathname(Dir.pwd)
218
+
219
+ # Skip if this is a development work tree
220
+ unless (root + '.git').exist?
221
+ message("Cleaning files only used during build.\n")
222
+
223
+ # (root + 'tmp') cannot be removed at this stage because
224
+ # libmagic.so is yet to be copied to lib.
225
+
226
+ # clean the ports build directory
227
+ Pathname.glob(pwd.join('tmp', '*', 'ports')) do |dir|
228
+ FileUtils.rm_rf(dir, verbose: true)
229
+ end
230
+
231
+ FileUtils.rm_rf(root + 'ports' + 'archives', verbose: true)
232
+
233
+ # Remove everything but share/ directory
234
+ remove_paths = %w[bin include]
235
+ remove_paths << 'lib' if config_static?
236
+
237
+ Pathname.glob(File.join(root, 'ports', '*', 'libmagic', '*')) do |dir|
238
+ remove_paths.each do |path|
239
+ remove_dir = File.join(dir, path)
240
+ FileUtils.rm_rf(remove_dir, verbose: true)
241
+ end
242
+ end
243
+ end
244
+
245
+ exit!(0)
246
+ end
247
+
248
+ #
249
+ # main
250
+ #
251
+ do_help if arg_config('--help')
252
+ do_clean if arg_config('--clean')
253
+
49
254
  if ENV['CC']
50
255
  RbConfig::CONFIG['CC'] = RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC']
51
256
  end
52
257
 
53
258
  ENV['CC'] = RbConfig::CONFIG['CC']
54
259
 
55
- $CFLAGS += ' -std=c99 -fPIC'
56
- $CFLAGS += ' -Wall -Wextra -pedantic'
260
+ append_cflags(ENV["CFLAGS"].split) if ENV["CFLAGS"]
261
+ append_cppflags(ENV["CPPFLAGS"].split) if ENV["CPPFLAGS"]
262
+ append_ldflags(ENV["LDFLAGS"].split) if ENV["LDFLAGS"]
263
+
264
+ $LIBS = concat_flags($LIBS, ENV["LIBS"]) if ENV["LIBS"]
265
+
266
+ if truffle?
267
+ $CPPFLAGS += " -DMAGIC_CUSTOM_CHECK_TYPE"
268
+ end
269
+
270
+ if config_system_libraries?
271
+ message "Building ruby-magic using system libraries.\n"
272
+
273
+ $CPPFLAGS += " -DMAGIC_SYSTEM_LIBRARIES"
274
+
275
+ dir_config('magic')
276
+ else
277
+ message "Building ruby-magic using packaged libraries.\n"
278
+
279
+ require 'yaml'
280
+ dependencies = YAML.load_file(File.join(PACKAGE_ROOT_DIR, "dependencies.yml"))
281
+
282
+ static_p = config_static?
283
+ message "Static linking is #{static_p ? 'enabled' : 'disabled'}.\n"
284
+ cross_build_p = config_cross_build?
285
+ message "Cross build is #{cross_build_p ? 'enabled' : 'disabled'}.\n"
286
+
287
+ libmagic_recipe = process_recipe('libmagic', dependencies["libmagic"]["version"], static_p, cross_build_p) do |recipe|
288
+ recipe.files = [{
289
+ url: "https://ruby-magic.s3.nl-ams.scw.cloud/file-#{recipe.version}.tar.gz",
290
+ sha256: dependencies["libmagic"]["sha256"],
291
+ }]
292
+ end
293
+
294
+ $LIBPATH = [File.join(libmagic_recipe.path, 'lib')]
295
+ $CFLAGS << " -I#{File.join(libmagic_recipe.path, 'include')} "
296
+ $LDFLAGS += " -Wl,-rpath,#{libmagic_recipe.path}/lib"
297
+
298
+ if static_p
299
+ ENV['PKG_CONFIG_PATH'] = "#{libmagic_recipe.path}/lib/pkgconfig"
300
+ # mkmf appends -- to the first option
301
+ $LIBS += " " + pkg_config('libmagic', 'libs --static')
302
+ $LIBS += " " + File.join(libmagic_recipe.path, 'lib', "libmagic.#{$LIBEXT}")
303
+ end
304
+
305
+ if cross_build_p
306
+ # database files will be packaged up by the cross-compiling callback in the ExtensionTask
307
+ to_path = File.join(PACKAGE_ROOT_DIR, "ext/magic/share")
308
+ FileUtils.rm_rf(to_path, secure: true)
309
+ FileUtils.mkdir(to_path)
310
+ FileUtils.cp_r(Dir[File.join(libmagic_recipe.path, 'share/misc/*.mgc')], to_path)
311
+ end
312
+ end
313
+
314
+ $CFLAGS += ' -std=c99'
57
315
 
58
316
  if RbConfig::CONFIG['CC'] =~ /gcc/
59
317
  $CFLAGS += ' -O3' unless $CFLAGS =~ /-O\d/
60
- $CFLAGS += ' -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline'
318
+ end
319
+
320
+ %w[
321
+ -Wcast-qual
322
+ -Wwrite-strings
323
+ -Wconversion
324
+ -Wmissing-noreturn
325
+ -Winline
326
+ ].select do |flag|
327
+ try_link('int main(void) { return 0; }', flag)
328
+ end.each do |flag|
329
+ $CFLAGS += " " + flag
61
330
  end
62
331
 
63
332
  unless darwin?
64
- $LDFLAGS += ' -Wl,--as-needed -Wl,--no-undefined'
333
+ $LDFLAGS += ' -Wl,--as-needed -Wl,--exclude-libs,ALL'
65
334
  end
66
335
 
67
336
  if windows?
68
337
  $LDFLAGS += ' -static-libgcc'
69
338
  end
70
339
 
71
- %w[
72
- CFLAGS
73
- CXXFLAGS
74
- CPPFLAGS
75
- ].each do |variable|
76
- $CFLAGS += format(' %s', ENV[variable]) if ENV[variable]
77
- end
78
-
79
- $LDFLAGS += format(' %s', ENV['LDFLAGS']) if ENV['LDFLAGS']
80
-
81
340
  unless have_header('ruby.h')
82
341
  abort "\n" + (<<-EOS).gsub(/^[ ]{,3}/, '') + "\n"
83
342
  You appear to be missing Ruby development libraries and/or header
@@ -120,6 +379,13 @@ unless have_header('ruby.h')
120
379
  EOS
121
380
  end
122
381
 
382
+ # these are needed for `rb_thread_call_without_gvl` to be properly detected on some linux systems.
383
+ # specifically, rake-compiler-dock's redhat-based image needs these.
384
+ have_library('pthread')
385
+ have_library('rt')
386
+ have_library('dl')
387
+ have_library('crypt')
388
+
123
389
  have_func('rb_thread_call_without_gvl')
124
390
  have_func('rb_thread_blocking_region')
125
391
 
@@ -188,7 +454,17 @@ end
188
454
  have_func(f)
189
455
  end
190
456
 
191
- dir_config('magic', [gem_include_dir], [gem_lib_dir])
192
-
193
457
  create_header
194
458
  create_makefile('magic/magic')
459
+
460
+ if config_clean?
461
+ # Do not clean if run in a development work tree.
462
+ File.open('Makefile', 'at') do |mk|
463
+ mk.print(<<~EOF)
464
+
465
+ all: clean-ports
466
+ clean-ports: $(DLLIB)
467
+ \t-$(Q)$(RUBY) $(srcdir)/extconf.rb --clean --#{static_p ? 'enable' : 'disable'}-static
468
+ EOF
469
+ end
470
+ end
@@ -4,14 +4,14 @@ extern "C" {
4
4
 
5
5
  #include "functions.h"
6
6
 
7
- int check_fd(int fd);
7
+ static int check_fd(int fd);
8
8
  static int safe_dup(int fd);
9
9
  static int safe_close(int fd);
10
10
  static int safe_cloexec(int fd);
11
- int override_error_output(void *data);
12
- int restore_error_output(void *data);
11
+ static int override_error_output(void *data);
12
+ static int restore_error_output(void *data);
13
13
 
14
- inline int
14
+ static inline int
15
15
  check_fd(int fd)
16
16
  {
17
17
  errno = 0;
@@ -42,6 +42,7 @@ safe_dup(int fd)
42
42
  goto error;
43
43
  }
44
44
  }
45
+
45
46
  if (safe_cloexec(new_fd) < 0) {
46
47
  local_errno = errno;
47
48
  goto error;
@@ -78,6 +79,7 @@ safe_cloexec(int fd)
78
79
  local_errno = errno;
79
80
  goto error;
80
81
  }
82
+
81
83
  if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) < 0) {
82
84
  local_errno = errno;
83
85
  goto error;
@@ -89,18 +91,18 @@ error:
89
91
  return -1;
90
92
  }
91
93
 
92
- int
94
+ static int
93
95
  override_error_output(void *data)
94
96
  {
95
97
  int local_errno;
96
- mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO;
98
+ int flags = O_WRONLY | O_APPEND;
97
99
  save_t *s = data;
98
100
 
99
101
  #if defined(HAVE_O_CLOEXEC)
100
- mode |= O_CLOEXEC;
102
+ flags |= O_CLOEXEC;
101
103
  #endif
102
104
 
103
- assert(s != NULL && \
105
+ assert(s != NULL &&
104
106
  "Must be a valid pointer to `save_t' type");
105
107
 
106
108
  s->file.old_fd = -1;
@@ -116,7 +118,7 @@ override_error_output(void *data)
116
118
  goto error;
117
119
  }
118
120
 
119
- s->file.new_fd = open("/dev/null", O_WRONLY | O_APPEND, mode);
121
+ s->file.new_fd = open("/dev/null", flags, 0222);
120
122
  if (s->file.new_fd < 0) {
121
123
  local_errno = errno;
122
124
 
@@ -128,10 +130,12 @@ override_error_output(void *data)
128
130
  safe_close(s->file.old_fd);
129
131
  goto error;
130
132
  }
133
+
131
134
  if (safe_cloexec(s->file.new_fd) < 0) {
132
135
  local_errno = errno;
133
136
  goto error;
134
137
  }
138
+
135
139
  if (dup2(s->file.new_fd, fileno(stderr)) < 0) {
136
140
  local_errno = errno;
137
141
  goto error;
@@ -146,13 +150,13 @@ error:
146
150
  return -1;
147
151
  }
148
152
 
149
- int
153
+ static int
150
154
  restore_error_output(void *data)
151
155
  {
152
156
  int local_errno;
153
157
  save_t *s = data;
154
158
 
155
- assert(s != NULL && \
159
+ assert(s != NULL &&
156
160
  "Must be a valid pointer to `save_t' type");
157
161
 
158
162
  if (s->file.old_fd < 0 && s->status != 0)
@@ -208,6 +212,14 @@ magic_errno_wrapper(magic_t magic)
208
212
  inline const char*
209
213
  magic_getpath_wrapper(void)
210
214
  {
215
+ /*
216
+ * The second argument translates to same value as the
217
+ * FILE_LOAD constant, which when used results in this
218
+ * function calling the get_default_magic() internally.
219
+ *
220
+ * N.B. magic_getpath() also honors the "MAGIC"
221
+ * environment variable."
222
+ */
211
223
  return magic_getpath(NULL, 0);
212
224
  }
213
225
 
@@ -270,15 +282,21 @@ inline int
270
282
  magic_load_wrapper(magic_t magic, const char *magic_file, int flags)
271
283
  {
272
284
  int rv;
285
+
273
286
  MAGIC_FUNCTION(magic_load, rv, flags, magic, magic_file);
287
+
274
288
  return rv;
275
289
  }
276
290
 
277
291
  inline int
278
- magic_load_buffers_wrapper(magic_t magic, void **buffers, size_t *sizes, size_t count, int flags)
292
+ magic_load_buffers_wrapper(magic_t magic, void **buffers, size_t *sizes,
293
+ size_t count, int flags)
279
294
  {
280
295
  int rv;
281
- MAGIC_FUNCTION(magic_load_buffers, rv, flags, magic, buffers, sizes, count);
296
+
297
+ MAGIC_FUNCTION(magic_load_buffers, rv, flags, magic, buffers, sizes,
298
+ count);
299
+
282
300
  return rv;
283
301
  }
284
302
 
@@ -286,7 +304,9 @@ inline int
286
304
  magic_compile_wrapper(magic_t magic, const char *magic_file, int flags)
287
305
  {
288
306
  int rv;
307
+
289
308
  MAGIC_FUNCTION(magic_compile, rv, flags, magic, magic_file);
309
+
290
310
  return rv;
291
311
  }
292
312
 
@@ -294,15 +314,19 @@ inline int
294
314
  magic_check_wrapper(magic_t magic, const char *magic_file, int flags)
295
315
  {
296
316
  int rv;
317
+
297
318
  MAGIC_FUNCTION(magic_check, rv, flags, magic, magic_file);
319
+
298
320
  return rv;
299
321
  }
300
322
 
301
323
  inline const char*
302
- magic_file_wrapper(magic_t magic, const char* filename, int flags)
324
+ magic_file_wrapper(magic_t magic, const char *filename, int flags)
303
325
  {
304
326
  const char *cstring;
327
+
305
328
  MAGIC_FUNCTION(magic_file, cstring, flags, magic, filename);
329
+
306
330
  return cstring;
307
331
  }
308
332
 
@@ -310,7 +334,9 @@ inline const char*
310
334
  magic_buffer_wrapper(magic_t magic, const void *buffer, size_t size, int flags)
311
335
  {
312
336
  const char *cstring;
337
+
313
338
  MAGIC_FUNCTION(magic_buffer, cstring, flags, magic, buffer, size);
339
+
314
340
  return cstring;
315
341
  }
316
342
 
@@ -9,7 +9,7 @@ extern "C" {
9
9
 
10
10
  #define MAGIC_FUNCTION(f, r, x, ...) \
11
11
  do { \
12
- if ((x) & MAGIC_DEBUG) \
12
+ if ((x) & (MAGIC_DEBUG | MAGIC_CHECK)) \
13
13
  r = f(__VA_ARGS__); \
14
14
  else { \
15
15
  save_t __##f; \
@@ -17,7 +17,7 @@ extern "C" {
17
17
  r = f(__VA_ARGS__); \
18
18
  restore_error_output(&(__##f)); \
19
19
  } \
20
- } while(0)
20
+ } while (0)
21
21
 
22
22
  typedef struct file_data {
23
23
  fpos_t position;
@@ -33,30 +33,36 @@ typedef struct save {
33
33
  extern magic_t magic_open_wrapper(int flags);
34
34
  extern void magic_close_wrapper(magic_t magic);
35
35
 
36
- extern const char* magic_error_wrapper(magic_t magic);
36
+ extern const char *magic_error_wrapper(magic_t magic);
37
37
  extern int magic_errno_wrapper(magic_t magic);
38
38
 
39
- extern const char* magic_getpath_wrapper(void);
39
+ extern const char *magic_getpath_wrapper(void);
40
40
 
41
- extern int magic_getparam_wrapper(magic_t magic, int parameter, void *value);
41
+ extern int magic_getparam_wrapper(magic_t magic, int parameter,
42
+ void *value);
42
43
  extern int magic_setparam_wrapper(magic_t magic, int parameter,
43
44
  const void *value);
44
45
 
45
46
  extern int magic_getflags_wrapper(magic_t magic);
46
47
  extern int magic_setflags_wrapper(magic_t magic, int flags);
47
48
 
48
- extern int magic_load_wrapper(magic_t magic, const char *magic_file, int flags);
49
+ extern int magic_load_wrapper(magic_t magic, const char *magic_file,
50
+ int flags);
49
51
  extern int magic_load_buffers_wrapper(magic_t magic, void **buffers,
50
- size_t *sizes, size_t count, int flags);
52
+ size_t *sizes, size_t count,
53
+ int flags);
51
54
 
52
- extern int magic_compile_wrapper(magic_t magic, const char *magic_file, int flags);
53
- extern int magic_check_wrapper(magic_t magic, const char *magic_file, int flags);
55
+ extern int magic_compile_wrapper(magic_t magic, const char *magic_file,
56
+ int flags);
57
+ extern int magic_check_wrapper(magic_t magic, const char *magic_file,
58
+ int flags);
54
59
 
55
- extern const char* magic_file_wrapper(magic_t magic, const char *filename,
60
+ extern const char *magic_file_wrapper(magic_t magic, const char *filename,
56
61
  int flags);
57
- extern const char* magic_buffer_wrapper(magic_t magic, const void *buffer,
62
+ extern const char *magic_buffer_wrapper(magic_t magic, const void *buffer,
58
63
  size_t size, int flags);
59
- extern const char* magic_descriptor_wrapper(magic_t magic, int fd, int flags);
64
+ extern const char *magic_descriptor_wrapper(magic_t magic, int fd,
65
+ int flags);
60
66
 
61
67
  extern int magic_version_wrapper(void);
62
68