*/
/*
* file.h - definitions for file(1) program
- * @(#)$File: file.h,v 1.207 2019/06/08 22:16:24 christos Exp $
+ * @(#)$File: file.h,v 1.208 2019/06/26 20:31:31 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_csv(struct magic_set *, const struct buffer *, int);
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.105 2019/06/08 22:16:24 christos Exp $")
+FILE_RCSID("@(#)$File: funcs.c,v 1.106 2019/06/26 20:31:31 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);
+ m = file_is_csv(ms, &b, looks_text);
if ((ms->flags & MAGIC_DEBUG) != 0)
(void)fprintf(stderr, "[try csv %d]\n", m);
if (m) {
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: is_csv.c,v 1.3 2019/06/24 23:40:03 christos Exp $")
+FILE_RCSID("@(#)$File: is_csv.c,v 1.4 2019/06/26 20:31:31 christos Exp $")
#endif
#include <string.h>
#ifndef TEST
int
-file_is_csv(struct magic_set *ms, const struct buffer *b)
+file_is_csv(struct magic_set *ms, const struct buffer *b, int looks_text)
{
const unsigned char *uc = CAST(const unsigned char *, b->fbuf);
const unsigned char *ue = uc + b->flen;
int mime = ms->flags & MAGIC_MIME;
+ if (!looks_text)
+ return 0;
if ((ms->flags & (MAGIC_APPLE|MAGIC_EXTENSION)) != 0)
return 0;
return 1;
}
- if (file_printf(ms, "CSV data") == -1)
+ if (file_printf(ms, "CSV text") == -1)
return -1;
return 1;