summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--doc/libmagic.man13
-rw-r--r--src/magic.c11
-rw-r--r--src/magic.h.in1
-rw-r--r--tests/test.c3
5 files changed, 28 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index fc55c3e7..ad7dee5c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2017-05-23 17:55 Christos Zoulas <christos@zoulas.com>
+
+ * PR/615 add magic_getflags()
+
2017-05-23 13:55 Christos Zoulas <christos@zoulas.com>
* release 5.31
diff --git a/doc/libmagic.man b/doc/libmagic.man
index 638890af..4c7e42ff 100644
--- a/doc/libmagic.man
+++ b/doc/libmagic.man
@@ -1,4 +1,4 @@
-.\" $File: libmagic.man,v 1.39 2015/10/07 02:36:50 christos Exp $
+.\" $File: libmagic.man,v 1.41 2017/05/23 21:54:07 christos Exp $
.\"
.\" Copyright (c) Christos Zoulas 2003.
.\" All Rights Reserved.
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd September 11, 2015
+.Dd May 23, 2017
.Dt LIBMAGIC 3
.Os
.Sh NAME
@@ -35,6 +35,7 @@
.Nm magic_errno ,
.Nm magic_descriptor ,
.Nm magic_buffer ,
+.Nm magic_getflags ,
.Nm magic_setflags ,
.Nm magic_check ,
.Nm magic_compile ,
@@ -64,6 +65,8 @@
.Ft const char *
.Fn magic_buffer "magic_t cookie" "const void *buffer" "size_t length"
.Ft int
+.Fn magic_getflags "magic_t cookie"
+.Ft int
.Fn magic_setflags "magic_t cookie" "int flags"
.Ft int
.Fn magic_check "magic_t cookie" "const char *filename"
@@ -206,6 +209,12 @@ argument with
bytes size.
.Pp
The
+.Fn magic_getflags
+functions returns a value representing current
+.Ar flags
+set.
+.Pp
+The
.Fn magic_setflags
function sets the
.Ar flags
diff --git a/src/magic.c b/src/magic.c
index a9b7e32a..9ea3f8a1 100644
--- a/src/magic.c
+++ b/src/magic.c
@@ -33,7 +33,7 @@
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: magic.c,v 1.99 2016/05/03 16:09:38 christos Exp $")
+FILE_RCSID("@(#)$File: magic.c,v 1.101 2017/05/23 21:54:07 christos Exp $")
#endif /* lint */
#include "magic.h"
@@ -568,6 +568,15 @@ magic_errno(struct magic_set *ms)
}
public int
+magic_getflags(struct magic_set *ms)
+{
+ if (ms == NULL)
+ return -1;
+
+ return ms->flags;
+}
+
+public int
magic_setflags(struct magic_set *ms, int flags)
{
if (ms == NULL)
diff --git a/src/magic.h.in b/src/magic.h.in
index 3d6954a2..fcfa381d 100644
--- a/src/magic.h.in
+++ b/src/magic.h.in
@@ -97,6 +97,7 @@ const char *magic_descriptor(magic_t, int);
const char *magic_buffer(magic_t, const void *, size_t);
const char *magic_error(magic_t);
+int magic_getflags(magic_t);
int magic_setflags(magic_t, int);
int magic_version(void);
diff --git a/tests/test.c b/tests/test.c
index db91c62f..330a357b 100644
--- a/tests/test.c
+++ b/tests/test.c
@@ -80,7 +80,8 @@ main(int argc, char **argv)
return 10;
}
if (magic_load(ms, NULL) == -1) {
- (void)fprintf(stderr, "ERROR loading with NULL file: %s\n", magic_error(ms));
+ (void)fprintf(stderr, "ERROR loading with NULL file: %s\n",
+ magic_error(ms));
return 11;
}