libmagic_rb 0.1.0 → 0.1.2.pre.beta
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.
- checksums.yaml +4 -4
- data/README.md +63 -16
- data/ext/libmagic/func.h +22 -14
- data/ext/libmagic/magic.c +16 -7
- data/ext/libmagic/modes.h +69 -4
- data/ext/libmagic/params.h +36 -2
- data/lib/libmagic_rb/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f249db73a864f2f290165eb9dc8d943f8016e25d202e0a592754418510f4110
|
4
|
+
data.tar.gz: c3026e23ac5e7ed0416b0c7e0694982baed1b7f78ec95f3845a5e616076b88b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '065198fe056d97dd295fd472697e0b1dcdef27dee5a995eca8718035beb64bf8b2ed3ca7eff6c6fd4462efcb6892f4f05ed33d8139872a193e2d2296c2e138e1'
|
7
|
+
data.tar.gz: 6a85f647db0401541b18cebdb2020518a3d8421c4e15452f0d47bab17808f8ad950aba613e3d7188b610034f3f3e58ca86b0e53d45939ed7709942630e2f4523
|
data/README.md
CHANGED
@@ -3,33 +3,76 @@ Adds ability to check mime-type of a file using the libmagic ([magic(4)](https:/
|
|
3
3
|
It uses native extensions and it's quite performant.
|
4
4
|
|
5
5
|
## Pre-Installation
|
6
|
-
On Linux, you need to install libmagic.
|
6
|
+
On Linux, you need to install libmagic. The version we recommend is at least 5.36.
|
7
|
+
But if you have an older version of libmagic, it will compile and work flawlessly but with a few caveats:
|
7
8
|
|
8
|
-
|
9
|
+
+ Many constants (modes and params) will be not defined
|
10
|
+
+ LibmagicRb::MAGIC_VERSION constant will be set to 0.
|
11
|
+
+ Few methods will not work.
|
12
|
+
some methods that can return a String or Integer will return nil (like setparam and getparam).
|
13
|
+
|
14
|
+
[ Do note that the minimum tested version is 5.11, older than that may fail to compile the gem ]
|
15
|
+
|
16
|
+
You also need Ruby > 1.9.0 in order to run this gem.
|
17
|
+
|
18
|
+
With that info in mind, let's continue to the installation part for your Linux distributions...
|
19
|
+
|
20
|
+
#### Arch / Manjaro / Archlabs / Garuda Linux / Hefftor Linux & other Arch Based Linux
|
9
21
|
|
10
22
|
```
|
11
|
-
# pacman -S file gcc make
|
23
|
+
# pacman -S ruby file gcc make --needed
|
12
24
|
```
|
13
25
|
|
14
|
-
#### Debian / Ubuntu / Linux Mint /
|
26
|
+
#### Debian / Ubuntu / Linux Mint / Deepin / Pop!_OS / RaspberryPi OS & other Debian Based Linux
|
15
27
|
|
16
28
|
```
|
17
|
-
# apt install libmagic-dev ruby-dev gcc make
|
29
|
+
# apt install ruby libmagic-dev ruby-dev gcc make
|
18
30
|
```
|
19
31
|
|
20
|
-
#### Fedora
|
32
|
+
#### Fedora / Amazon Linux / CentOS & Other RedHat Based Linux
|
21
33
|
|
22
34
|
```
|
23
|
-
# yum install file-devel ruby-devel gcc make
|
35
|
+
# yum install ruby file-devel ruby-devel gcc make
|
24
36
|
```
|
25
37
|
|
26
38
|
#### OpenSUSE
|
27
39
|
|
28
40
|
```
|
29
|
-
zypper in ruby ruby-devel file-devel gcc make
|
41
|
+
# zypper in ruby ruby-devel file-devel gcc make
|
42
|
+
```
|
43
|
+
|
44
|
+
#### Gentoo
|
45
|
+
|
46
|
+
There are already make, and magic.h available for Gentoo. You just need Ruby:
|
47
|
+
|
48
|
+
```
|
49
|
+
# emerge --ask dev-lang/ruby
|
30
50
|
```
|
31
51
|
|
32
|
-
|
52
|
+
#### DragonflyBSD / FreeBSD
|
53
|
+
|
54
|
+
Versions upto 0.1.2 is tested on DragonflyBSD (Version 6.0-SYNTH).
|
55
|
+
|
56
|
+
```
|
57
|
+
# pkg install ruby devel/ruby-gems gcc gmake
|
58
|
+
```
|
59
|
+
|
60
|
+
#### MacOS
|
61
|
+
|
62
|
+
You can install libmagic with homebrew:
|
63
|
+
|
64
|
+
```
|
65
|
+
$ brew install libmagic
|
66
|
+
|
67
|
+
# if the link is already created is going to fail, don't worry about that
|
68
|
+
$ brew link libmagic
|
69
|
+
```
|
70
|
+
|
71
|
+
[ Source: [ eparreno/gist:1845561 ](https://gist.github.com/eparreno/1845561) ]
|
72
|
+
|
73
|
+
#### Windows
|
74
|
+
|
75
|
+
Windows is currently not tested, hence the support is unknown.
|
33
76
|
|
34
77
|
## Installation
|
35
78
|
|
@@ -51,6 +94,9 @@ Or install it yourself as:
|
|
51
94
|
$ gem install libmagic_rb
|
52
95
|
```
|
53
96
|
|
97
|
+
We recommend getting the gem only from Rubygems.org. Do not download this repo as zip, compile to install the gem.
|
98
|
+
A rubygem version is released after various tests. Any branch here including Master branch can be unstable can even segfault your app. You've been warned!
|
99
|
+
|
54
100
|
## Usage
|
55
101
|
The target of this gem is to add mime-type checking easily.
|
56
102
|
|
@@ -162,18 +208,19 @@ cookie.setparam(LibmagicRb::MAGIC_PARAM_REGEX_MAX, 2 ** 14) # => 16384; but can
|
|
162
208
|
|
163
209
|
#### Notes:
|
164
210
|
|
165
|
-
+ To get the parameters, you can refer to the [man page](https://man7.org/linux/man-pages/man3/magic_getflags.3.html).
|
166
|
-
+
|
211
|
+
+ To get the parameters, you can run `LibmagicRb.lsparams()` for description, please refer to the [man page](https://man7.org/linux/man-pages/man3/magic_getflags.3.html).
|
212
|
+
+ `cookie.setparam()` returns the value after getting the param as well. So you don't need to confirm by calling getparam() again.
|
167
213
|
+ The maximum size depends on the parameter. But the value that can be passed should not be more than 2 ** 32.
|
214
|
+
+ On older versions of libmagic, where the function isn't available, both getparam() and setparam() will perform no operations, and return nil!
|
168
215
|
|
169
216
|
## Errors
|
170
217
|
The following errors are implemented and raised on appropriate situation:
|
171
218
|
|
172
|
-
1. LibmagicRb::FileNotFound
|
173
|
-
2. LibmagicRb::FileUnreadable
|
174
|
-
3. LibmagicRb::InvalidDBError
|
175
|
-
4. LibmagicRb::IsDirError
|
176
|
-
5. LibmagicRb::FileClosedError
|
219
|
+
1. `LibmagicRb::FileNotFound`: When the file is not found.
|
220
|
+
2. `LibmagicRb::FileUnreadable`: When the file is unreadable.
|
221
|
+
3. `LibmagicRb::InvalidDBError`: When the database given is invalid.
|
222
|
+
4. `LibmagicRb::IsDirError`: When the database path is a directory.
|
223
|
+
5. `LibmagicRb::FileClosedError`: When the file is already closed (closed?()) but you are trying to access the cookie.
|
177
224
|
|
178
225
|
## Development
|
179
226
|
|
data/ext/libmagic/func.h
CHANGED
@@ -52,29 +52,37 @@ VALUE _checkGlobal_(volatile VALUE self) {
|
|
52
52
|
}
|
53
53
|
|
54
54
|
VALUE _getParamGlobal_(volatile VALUE self, volatile VALUE param) {
|
55
|
-
|
55
|
+
#if MAGIC_VERSION > 525
|
56
|
+
RB_UNWRAP(cookie) ;
|
56
57
|
|
57
|
-
|
58
|
-
|
58
|
+
unsigned int _param = NUM2UINT(param) ;
|
59
|
+
unsigned long value ;
|
59
60
|
|
60
|
-
|
61
|
-
|
62
|
-
|
61
|
+
int status = magic_getparam(*cookie, _param, &value) ;
|
62
|
+
if (status) return Qnil ;
|
63
|
+
return ULONG2NUM(value) ;
|
64
|
+
#else
|
65
|
+
return Qnil ;
|
66
|
+
#endif
|
63
67
|
}
|
64
68
|
|
65
69
|
VALUE _setParamGlobal_(volatile VALUE self, volatile VALUE param, volatile VALUE paramVal) {
|
66
|
-
|
67
|
-
|
70
|
+
#if MAGIC_VERSION > 525
|
71
|
+
unsigned int _param = NUM2UINT(param) ;
|
72
|
+
unsigned long _paramVal = NUM2ULONG(paramVal) ;
|
68
73
|
|
69
|
-
|
74
|
+
RB_UNWRAP(cookie) ;
|
70
75
|
|
71
|
-
|
72
|
-
|
76
|
+
unsigned long value ;
|
77
|
+
magic_setparam(*cookie, _param, &_paramVal) ;
|
73
78
|
|
74
|
-
|
79
|
+
int status = magic_getparam(*cookie, _param, &value) ;
|
80
|
+
if (status) return Qnil ;
|
75
81
|
|
76
|
-
|
77
|
-
|
82
|
+
return ULONG2NUM((int)value) ;
|
83
|
+
#else
|
84
|
+
return Qnil ;
|
85
|
+
#endif
|
78
86
|
}
|
79
87
|
|
80
88
|
VALUE _bufferGlobal_(volatile VALUE self, volatile VALUE string) {
|
data/ext/libmagic/magic.c
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#include <magic.h>
|
2
2
|
#include <stdio.h>
|
3
3
|
#include <unistd.h>
|
4
|
+
#include <sys/stat.h>
|
4
5
|
#include "ruby.h"
|
5
6
|
|
6
7
|
/*
|
@@ -10,6 +11,10 @@
|
|
10
11
|
#include "params.h"
|
11
12
|
#include "definitions.h"
|
12
13
|
|
14
|
+
#ifndef MAGIC_VERSION
|
15
|
+
#define MAGIC_VERSION 0
|
16
|
+
#endif
|
17
|
+
|
13
18
|
/*
|
14
19
|
* Errors
|
15
20
|
*/
|
@@ -39,7 +44,10 @@ static rb_data_type_t fileType = {
|
|
39
44
|
},
|
40
45
|
|
41
46
|
.data = NULL,
|
42
|
-
|
47
|
+
|
48
|
+
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
|
49
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY
|
50
|
+
#endif
|
43
51
|
} ;
|
44
52
|
|
45
53
|
#include "validations.h"
|
@@ -111,14 +119,11 @@ VALUE rb_libmagicRb_initialize(volatile VALUE self, volatile VALUE args) {
|
|
111
119
|
|
112
120
|
VALUE argDBPath = rb_hash_aref(args, ID2SYM(rb_intern("db"))) ;
|
113
121
|
|
114
|
-
char *databasePath ;
|
115
122
|
if (RB_TYPE_P(argDBPath, T_NIL)) {
|
116
|
-
databasePath = NULL ;
|
117
123
|
rb_ivar_set(self, rb_intern("@db"), Qnil) ;
|
118
124
|
} else if (!RB_TYPE_P(argDBPath, T_STRING)) {
|
119
125
|
rb_raise(rb_eArgError, "Database name must be an instance of String.") ;
|
120
126
|
} else {
|
121
|
-
databasePath = StringValuePtr(argDBPath) ;
|
122
127
|
rb_ivar_set(self, rb_intern("@db"), argDBPath) ;
|
123
128
|
}
|
124
129
|
|
@@ -183,9 +188,13 @@ void Init_main() {
|
|
183
188
|
modes(cLibmagicRb) ;
|
184
189
|
params(cLibmagicRb) ;
|
185
190
|
|
186
|
-
|
187
|
-
|
188
|
-
|
191
|
+
#if MAGIC_VERSION > 525
|
192
|
+
char version[6] ;
|
193
|
+
sprintf(version, "%0.2f", magic_version() / 100.0) ;
|
194
|
+
rb_define_const(cLibmagicRb, "MAGIC_VERSION", rb_str_new_cstr(version)) ;
|
195
|
+
#else
|
196
|
+
rb_define_const(cLibmagicRb, "MAGIC_VERSION", rb_str_new_cstr("0")) ;
|
197
|
+
#endif
|
189
198
|
|
190
199
|
/*
|
191
200
|
* Singleton Methods
|
data/ext/libmagic/modes.h
CHANGED
@@ -15,24 +15,57 @@ void modes(volatile VALUE rb_klass) {
|
|
15
15
|
rb_define_const(rb_klass, "MAGIC_RAW", INT2FIX(MAGIC_RAW)) ;
|
16
16
|
rb_define_const(rb_klass, "MAGIC_ERROR", INT2FIX(MAGIC_ERROR)) ;
|
17
17
|
rb_define_const(rb_klass, "MAGIC_APPLE", INT2FIX(MAGIC_APPLE)) ;
|
18
|
+
|
19
|
+
#ifdef MAGIC_EXTENSION
|
18
20
|
rb_define_const(rb_klass, "MAGIC_EXTENSION", INT2FIX(MAGIC_EXTENSION)) ;
|
21
|
+
#endif
|
22
|
+
|
23
|
+
#ifdef MAGIC_COMPRESS_TRANSP
|
19
24
|
rb_define_const(rb_klass, "MAGIC_COMPRESS_TRANSP", INT2FIX(MAGIC_COMPRESS_TRANSP)) ;
|
25
|
+
#endif
|
26
|
+
|
27
|
+
#ifdef MAGIC_NO_CHECK_APPTYPE
|
20
28
|
rb_define_const(rb_klass, "MAGIC_NO_CHECK_APPTYPE", INT2FIX(MAGIC_NO_CHECK_APPTYPE)) ;
|
29
|
+
#endif
|
30
|
+
|
31
|
+
#ifdef MAGIC_NO_CHECK_CDF
|
21
32
|
rb_define_const(rb_klass, "MAGIC_NO_CHECK_CDF", INT2FIX(MAGIC_NO_CHECK_CDF)) ;
|
33
|
+
#endif
|
34
|
+
|
35
|
+
#ifdef MAGIC_NO_CHECK_COMPRESS
|
22
36
|
rb_define_const(rb_klass, "MAGIC_NO_CHECK_COMPRESS", INT2FIX(MAGIC_NO_CHECK_COMPRESS)) ;
|
37
|
+
#endif
|
38
|
+
|
39
|
+
#ifdef MAGIC_NO_CHECK_ELF
|
23
40
|
rb_define_const(rb_klass, "MAGIC_NO_CHECK_ELF", INT2FIX(MAGIC_NO_CHECK_ELF)) ;
|
41
|
+
#endif
|
42
|
+
|
43
|
+
#ifdef MAGIC_NO_CHECK_ENCODING
|
24
44
|
rb_define_const(rb_klass, "MAGIC_NO_CHECK_ENCODING", INT2FIX(MAGIC_NO_CHECK_ENCODING)) ;
|
45
|
+
#endif
|
46
|
+
|
47
|
+
#ifdef MAGIC_NO_CHECK_SOFT
|
25
48
|
rb_define_const(rb_klass, "MAGIC_NO_CHECK_SOFT", INT2FIX(MAGIC_NO_CHECK_SOFT)) ;
|
49
|
+
#endif
|
50
|
+
|
51
|
+
#ifdef MAGIC_NO_CHECK_TAR
|
26
52
|
rb_define_const(rb_klass, "MAGIC_NO_CHECK_TAR", INT2FIX(MAGIC_NO_CHECK_TAR)) ;
|
53
|
+
#endif
|
54
|
+
|
55
|
+
#ifdef MAGIC_NO_CHECK_TEXT
|
27
56
|
rb_define_const(rb_klass, "MAGIC_NO_CHECK_TEXT", INT2FIX(MAGIC_NO_CHECK_TEXT)) ;
|
57
|
+
#endif
|
58
|
+
|
59
|
+
#ifdef MAGIC_NO_CHECK_TOKENS
|
28
60
|
rb_define_const(rb_klass, "MAGIC_NO_CHECK_TOKENS", INT2FIX(MAGIC_NO_CHECK_TOKENS)) ;
|
61
|
+
#endif
|
29
62
|
|
30
63
|
#ifdef MAGIC_NO_CHECK_JSON
|
31
|
-
|
64
|
+
rb_define_const(rb_klass, "MAGIC_NO_CHECK_JSON", INT2FIX(MAGIC_NO_CHECK_JSON)) ;
|
32
65
|
#endif
|
33
66
|
|
34
67
|
#ifdef MAGIC_NO_CHECK_CSV
|
35
|
-
|
68
|
+
rb_define_const(rb_klass, "MAGIC_NO_CHECK_CSV", INT2FIX(MAGIC_NO_CHECK_CSV)) ;
|
36
69
|
#endif
|
37
70
|
}
|
38
71
|
|
@@ -53,24 +86,56 @@ VALUE lsmodes(volatile VALUE obj) {
|
|
53
86
|
rb_hash_aset(hash, ID2SYM(rb_intern("MAGIC_RAW")), INT2FIX(MAGIC_RAW)) ;
|
54
87
|
rb_hash_aset(hash, ID2SYM(rb_intern("MAGIC_ERROR")), INT2FIX(MAGIC_ERROR)) ;
|
55
88
|
rb_hash_aset(hash, ID2SYM(rb_intern("MAGIC_APPLE")), INT2FIX(MAGIC_APPLE)) ;
|
89
|
+
#ifdef MAGIC_EXTENSION
|
56
90
|
rb_hash_aset(hash, ID2SYM(rb_intern("MAGIC_EXTENSION")), INT2FIX(MAGIC_EXTENSION)) ;
|
91
|
+
#endif
|
92
|
+
|
93
|
+
#ifdef MAGIC_COMPRESS_TRANSP
|
57
94
|
rb_hash_aset(hash, ID2SYM(rb_intern("MAGIC_COMPRESS_TRANSP")), INT2FIX(MAGIC_COMPRESS_TRANSP)) ;
|
95
|
+
#endif
|
96
|
+
|
97
|
+
#ifdef MAGIC_NO_CHECK_APPTYPE
|
58
98
|
rb_hash_aset(hash, ID2SYM(rb_intern("MAGIC_NO_CHECK_APPTYPE")), INT2FIX(MAGIC_NO_CHECK_APPTYPE)) ;
|
99
|
+
#endif
|
100
|
+
|
101
|
+
#ifdef MAGIC_NO_CHECK_CDF
|
59
102
|
rb_hash_aset(hash, ID2SYM(rb_intern("MAGIC_NO_CHECK_CDF")), INT2FIX(MAGIC_NO_CHECK_CDF)) ;
|
103
|
+
#endif
|
104
|
+
|
105
|
+
#ifdef MAGIC_NO_CHECK_COMPRESS
|
60
106
|
rb_hash_aset(hash, ID2SYM(rb_intern("MAGIC_NO_CHECK_COMPRESS")), INT2FIX(MAGIC_NO_CHECK_COMPRESS)) ;
|
107
|
+
#endif
|
108
|
+
|
109
|
+
#ifdef MAGIC_NO_CHECK_ELF
|
61
110
|
rb_hash_aset(hash, ID2SYM(rb_intern("MAGIC_NO_CHECK_ELF")), INT2FIX(MAGIC_NO_CHECK_ELF)) ;
|
111
|
+
#endif
|
112
|
+
|
113
|
+
#ifdef MAGIC_NO_CHECK_ENCODING
|
62
114
|
rb_hash_aset(hash, ID2SYM(rb_intern("MAGIC_NO_CHECK_ENCODING")), INT2FIX(MAGIC_NO_CHECK_ENCODING)) ;
|
115
|
+
#endif
|
116
|
+
|
117
|
+
#ifdef MAGIC_NO_CHECK_SOFT
|
63
118
|
rb_hash_aset(hash, ID2SYM(rb_intern("MAGIC_NO_CHECK_SOFT")), INT2FIX(MAGIC_NO_CHECK_SOFT)) ;
|
119
|
+
#endif
|
120
|
+
|
121
|
+
#ifdef MAGIC_NO_CHECK_TAR
|
64
122
|
rb_hash_aset(hash, ID2SYM(rb_intern("MAGIC_NO_CHECK_TAR")), INT2FIX(MAGIC_NO_CHECK_TAR)) ;
|
123
|
+
#endif
|
124
|
+
|
125
|
+
#ifdef MAGIC_NO_CHECK_TEXT
|
65
126
|
rb_hash_aset(hash, ID2SYM(rb_intern("MAGIC_NO_CHECK_TEXT")), INT2FIX(MAGIC_NO_CHECK_TEXT)) ;
|
127
|
+
#endif
|
128
|
+
|
129
|
+
#ifdef MAGIC_NO_CHECK_TOKENS
|
66
130
|
rb_hash_aset(hash, ID2SYM(rb_intern("MAGIC_NO_CHECK_TOKENS")), INT2FIX(MAGIC_NO_CHECK_TOKENS)) ;
|
131
|
+
#endif
|
67
132
|
|
68
133
|
#ifdef MAGIC_NO_CHECK_CSV
|
69
|
-
|
134
|
+
rb_hash_aset(hash, ID2SYM(rb_intern("MAGIC_NO_CHECK_CSV")), INT2FIX(MAGIC_NO_CHECK_CSV)) ;
|
70
135
|
#endif
|
71
136
|
|
72
137
|
#ifdef MAGIC_NO_CHECK_CSV
|
73
|
-
|
138
|
+
rb_hash_aset(hash, ID2SYM(rb_intern("MAGIC_NO_CHECK_JSON")), INT2FIX(MAGIC_NO_CHECK_JSON)) ;
|
74
139
|
#endif
|
75
140
|
|
76
141
|
return hash ;
|
data/ext/libmagic/params.h
CHANGED
@@ -1,28 +1,62 @@
|
|
1
1
|
void params(volatile VALUE rb_klass) {
|
2
|
+
#ifdef MAGIC_PARAM_INDIR_MAX
|
2
3
|
rb_define_const(rb_klass, "MAGIC_PARAM_INDIR_MAX", UINT2NUM(MAGIC_PARAM_INDIR_MAX)) ;
|
4
|
+
#endif
|
5
|
+
|
6
|
+
#ifdef MAGIC_PARAM_NAME_MAX
|
3
7
|
rb_define_const(rb_klass, "MAGIC_PARAM_NAME_MAX", UINT2NUM(MAGIC_PARAM_NAME_MAX)) ;
|
8
|
+
#endif
|
9
|
+
|
10
|
+
#ifdef MAGIC_PARAM_ELF_NOTES_MAX
|
4
11
|
rb_define_const(rb_klass, "MAGIC_PARAM_ELF_NOTES_MAX", UINT2NUM(MAGIC_PARAM_ELF_NOTES_MAX)) ;
|
12
|
+
#endif
|
13
|
+
|
14
|
+
#ifdef MAGIC_PARAM_ELF_PHNUM_MAX
|
5
15
|
rb_define_const(rb_klass, "MAGIC_PARAM_ELF_PHNUM_MAX", UINT2NUM(MAGIC_PARAM_ELF_PHNUM_MAX)) ;
|
16
|
+
#endif
|
17
|
+
|
18
|
+
#ifdef MAGIC_PARAM_ELF_SHNUM_MAX
|
6
19
|
rb_define_const(rb_klass, "MAGIC_PARAM_ELF_SHNUM_MAX", UINT2NUM(MAGIC_PARAM_ELF_SHNUM_MAX)) ;
|
20
|
+
#endif
|
21
|
+
|
22
|
+
#ifdef MAGIC_PARAM_REGEX_MAX
|
7
23
|
rb_define_const(rb_klass, "MAGIC_PARAM_REGEX_MAX", UINT2NUM(MAGIC_PARAM_REGEX_MAX)) ;
|
24
|
+
#endif
|
8
25
|
|
9
26
|
#ifdef MAGIC_PARAM_BYTES_MAX
|
10
|
-
|
27
|
+
rb_define_const(rb_klass, "MAGIC_PARAM_BYTES_MAX", UINT2NUM(MAGIC_PARAM_BYTES_MAX)) ;
|
11
28
|
#endif
|
12
29
|
}
|
13
30
|
|
14
31
|
VALUE lsparams(volatile VALUE obj) {
|
15
32
|
VALUE hash = rb_hash_new() ;
|
16
33
|
|
34
|
+
#ifdef MAGIC_PARAM_INDIR_MAX
|
17
35
|
rb_hash_aset(hash, ID2SYM(rb_intern("MAGIC_PARAM_INDIR_MAX")), UINT2NUM(MAGIC_PARAM_INDIR_MAX)) ;
|
36
|
+
#endif
|
37
|
+
|
38
|
+
#ifdef MAGIC_PARAM_NAME_MAX
|
18
39
|
rb_hash_aset(hash, ID2SYM(rb_intern("MAGIC_PARAM_NAME_MAX")), UINT2NUM(MAGIC_PARAM_NAME_MAX)) ;
|
40
|
+
#endif
|
41
|
+
|
42
|
+
#ifdef MAGIC_PARAM_ELF_NOTES_MAX
|
19
43
|
rb_hash_aset(hash, ID2SYM(rb_intern("MAGIC_PARAM_ELF_NOTES_MAX")), UINT2NUM(MAGIC_PARAM_ELF_NOTES_MAX)) ;
|
44
|
+
#endif
|
45
|
+
|
46
|
+
#ifdef MAGIC_PARAM_ELF_PHNUM_MAX
|
20
47
|
rb_hash_aset(hash, ID2SYM(rb_intern("MAGIC_PARAM_ELF_PHNUM_MAX")), UINT2NUM(MAGIC_PARAM_ELF_PHNUM_MAX)) ;
|
48
|
+
#endif
|
49
|
+
|
50
|
+
#ifdef MAGIC_PARAM_ELF_SHNUM_MAX
|
21
51
|
rb_hash_aset(hash, ID2SYM(rb_intern("MAGIC_PARAM_ELF_SHNUM_MAX")), UINT2NUM(MAGIC_PARAM_ELF_SHNUM_MAX)) ;
|
52
|
+
#endif
|
53
|
+
|
54
|
+
#ifdef MAGIC_PARAM_REGEX_MAX
|
22
55
|
rb_hash_aset(hash, ID2SYM(rb_intern("MAGIC_PARAM_REGEX_MAX")), UINT2NUM(MAGIC_PARAM_REGEX_MAX)) ;
|
56
|
+
#endif
|
23
57
|
|
24
58
|
#ifdef MAGIC_PARAM_BYTES_MAX
|
25
|
-
|
59
|
+
rb_hash_aset(hash, ID2SYM(rb_intern("MAGIC_PARAM_BYTES_MAX")), UINT2NUM(MAGIC_PARAM_BYTES_MAX)) ;
|
26
60
|
#endif
|
27
61
|
|
28
62
|
return hash ;
|
data/lib/libmagic_rb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libmagic_rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2.pre.beta
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cybergizer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Check filetype with libmagic
|
14
14
|
email:
|
@@ -47,9 +47,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
47
47
|
version: 1.9.0
|
48
48
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
49
|
requirements:
|
50
|
-
- - "
|
50
|
+
- - ">"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version:
|
52
|
+
version: 1.3.1
|
53
53
|
requirements: []
|
54
54
|
rubygems_version: 3.2.21
|
55
55
|
signing_key:
|