-.\" $File: file.man,v 1.135 2019/03/03 02:32:40 christos Exp $
-.Dd February 18, 2019
+.\" $File: file.man,v 1.136 2019/06/08 22:16:24 christos Exp $
+.Dd June 8, 2019
.Dt FILE __CSECTION__
.Os
.Sh NAME
Prints details of Compound Document Files.
.It compress
Checks for, and looks inside, compressed files.
+.It csv
+Checks Comma Separated Value files.
.It elf
Prints ELF file details, provided soft magic tests are enabled and the
elf magic is found.
-.\" $File: libmagic.man,v 1.44 2018/09/09 20:33:28 christos Exp $
+.\" $File: libmagic.man,v 1.45 2019/06/08 22:16:24 christos Exp $
.\"
.\" Copyright (c) Christos Zoulas 2003, 2018.
.\" All Rights Reserved.
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd August 18, 2018
+.Dd June 8, 2019
.Dt LIBMAGIC 3
.Os
.Sh NAME
.It Dv MAGIC_NO_CHECK_TOKENS
Don't look for known tokens inside ascii files.
.It Dv MAGIC_NO_CHECK_JSON
-Don't example JSON files.
+Don't examine JSON files.
+.It Dv MAGIC_NO_CHECK_CSV
+Don't examine CSV files.
.El
.Pp
The
AM_CFLAGS = $(CFLAG_VISIBILITY) @WARNINGS@
libmagic_la_SOURCES = buffer.c magic.c apprentice.c softmagic.c ascmagic.c \
- encoding.c compress.c is_json.c is_tar.c readelf.c print.c fsmagic.c \
- funcs.c file.h readelf.h tar.h apptype.c der.c der.h \
+ encoding.c compress.c is_csv.c is_json.c is_tar.c readelf.c print.c \
+ fsmagic.c funcs.c file.h readelf.h tar.h apptype.c der.c der.h \
file_opts.h elfclass.h mygetopt.h cdf.c cdf_time.c readcdf.c cdf.h
libmagic_la_LDFLAGS = -no-undefined -version-info 1:0:0
if MINGW
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: file.c,v 1.181 2019/03/28 20:54:03 christos Exp $")
+FILE_RCSID("@(#)$File: file.c,v 1.182 2019/06/08 22:16:24 christos Exp $")
#endif /* lint */
#include "magic.h"
{ "ascii", MAGIC_NO_CHECK_ASCII },
{ "cdf", MAGIC_NO_CHECK_CDF },
{ "compress", MAGIC_NO_CHECK_COMPRESS },
+ { "csv", MAGIC_NO_CHECK_CSV },
{ "elf", MAGIC_NO_CHECK_ELF },
{ "encoding", MAGIC_NO_CHECK_ENCODING },
{ "soft", MAGIC_NO_CHECK_SOFT },
*/
/*
* file.h - definitions for file(1) program
- * @(#)$File: file.h,v 1.206 2019/05/07 02:27:11 christos Exp $
+ * @(#)$File: file.h,v 1.207 2019/06/08 22:16:24 christos Exp $
*/
#ifndef __file_h__
protected int file_encoding(struct magic_set *, const struct buffer *,
unichar **, size_t *, const char **, const char **, const char **);
protected int file_is_json(struct magic_set *, const struct buffer *);
+protected int file_is_csv(struct magic_set *, const struct buffer *);
protected int file_is_tar(struct magic_set *, const struct buffer *);
protected int file_softmagic(struct magic_set *, const struct buffer *,
uint16_t *, uint16_t *, int, int);
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: funcs.c,v 1.104 2019/05/07 02:27:11 christos Exp $")
+FILE_RCSID("@(#)$File: funcs.c,v 1.105 2019/06/08 22:16:24 christos Exp $")
#endif /* lint */
#include "magic.h"
}
}
+ /* Check if we have a CSV file */
+ if ((ms->flags & MAGIC_NO_CHECK_CSV) == 0) {
+ m = file_is_csv(ms, &b);
+ if ((ms->flags & MAGIC_DEBUG) != 0)
+ (void)fprintf(stderr, "[try csv %d]\n", m);
+ if (m) {
+ if (checkdone(ms, &rv))
+ goto done;
+ }
+ }
+
/* Check if we have a CDF file */
if ((ms->flags & MAGIC_NO_CHECK_CDF) == 0) {
m = file_trycdf(ms, &b);
#define MAGIC_NO_CHECK_ELF 0x0010000 /* Don't check for elf details */
#define MAGIC_NO_CHECK_TEXT 0x0020000 /* Don't check for text files */
#define MAGIC_NO_CHECK_CDF 0x0040000 /* Don't check for cdf files */
+#define MAGIC_NO_CHECK_CSV 0x0080000 /* Don't check for CSV files */
#define MAGIC_NO_CHECK_TOKENS 0x0100000 /* Don't check tokens */
#define MAGIC_NO_CHECK_ENCODING 0x0200000 /* Don't check text encodings */
#define MAGIC_NO_CHECK_JSON 0x0400000 /* Don't check for JSON files */
MAGIC_NO_CHECK_APPTYPE | \
MAGIC_NO_CHECK_ELF | \
MAGIC_NO_CHECK_TEXT | \
+ MAGIC_NO_CHECK_CSV | \
MAGIC_NO_CHECK_CDF | \
MAGIC_NO_CHECK_TOKENS | \
MAGIC_NO_CHECK_ENCODING | \