*/
/*
* file.h - definitions for file(1) program
- * @(#)$File: file.h,v 1.89 2007/03/01 22:14:54 christos Exp $
+ * @(#)$File: file.h,v 1.90 2007/03/12 15:43:21 christos Exp $
*/
#ifndef __file_h__
protected size_t file_mbswidth(const char *);
protected const char *file_getbuffer(struct magic_set *);
protected ssize_t sread(int, void *, size_t, int);
-#ifdef ENABLE_CONDITIONALS
protected int file_check_mem(struct magic_set *, unsigned int);
-#endif
#ifndef COMPILE_ONLY
extern const char *file_names[];
#endif
#ifndef lint
-FILE_RCSID("@(#)$File: funcs.c,v 1.27 2007/02/05 16:46:40 christos Exp $")
+FILE_RCSID("@(#)$File: funcs.c,v 1.28 2007/03/01 22:14:54 christos Exp $")
#endif /* lint */
#ifndef HAVE_VSNPRINTF
return ms->o.pbuf;
}
+protected int
+file_check_mem(struct magic_set *ms, unsigned int level)
+{
+ size_t len;
+
+ if (level >= ms->c.len) {
+ len = (ms->c.len += 20) * sizeof(*ms->c.li);
+ ms->c.li = (ms->c.li == NULL) ? malloc(len) :
+ realloc(ms->c.li, len);
+ if (ms->c.li == NULL) {
+ file_oomem(ms, len);
+ return -1;
+ }
+ }
+ ms->c.li[level].got_match = 0;
+#ifdef ENABLE_CONDITIONALS
+ ms->c.li[level].last_match = 0;
+ ms->c.li[level].last_cond = COND_NONE;
+#endif /* ENABLE_CONDITIONALS */
+ return 0;
+}
/*
* Yes these wrappers suffer from buffer overflows, but if your OS does not
* have the real functions, maybe you should consider replacing your OS?
#ifndef lint
-FILE_RCSID("@(#)$File: softmagic.c,v 1.95 2007/03/03 19:09:25 christos Exp $")
+FILE_RCSID("@(#)$File: softmagic.c,v 1.96 2007/03/05 02:41:29 christos Exp $")
#endif /* lint */
private int match(struct magic_set *, struct magic *, uint32_t,
return 0;
}
-#ifdef ENABLE_CONDITIONALS
-protected int
-#else
-private int
-#endif
-file_check_mem(struct magic_set *ms, unsigned int level)
-{
- size_t len;
-
- if (level >= ms->c.len) {
- len = (ms->c.len += 20) * sizeof(*ms->c.li);
- ms->c.li = (ms->c.li == NULL) ? malloc(len) :
- realloc(ms->c.li, len);
- if (ms->c.li == NULL) {
- file_oomem(ms, len);
- return -1;
- }
- }
- ms->c.li[level].got_match = 0;
-#ifdef ENABLE_CONDITIONALS
- ms->c.li[level].last_match = 0;
- ms->c.li[level].last_cond = COND_NONE;
-#endif /* ENABLE_CONDITIONALS */
- return 0;
-}
-
/*
* Go through the whole list, stopping if you find a match. Process all
* the continuations of that match before returning.