Module Name:    src
Committed By:   tsutsui
Date:           Fri May 31 20:25:41 UTC 2024

Modified Files:
        src/external/gpl2/mkhybrid/dist/libfile: apprentice.c file.h lfile.c
            softmagic.c

Log Message:
Make newer BSD Licensed libfile sources build as tools.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/external/gpl2/mkhybrid/dist/libfile/apprentice.c \
    src/external/gpl2/mkhybrid/dist/libfile/file.h \
    src/external/gpl2/mkhybrid/dist/libfile/lfile.c \
    src/external/gpl2/mkhybrid/dist/libfile/softmagic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/gpl2/mkhybrid/dist/libfile/apprentice.c
diff -u src/external/gpl2/mkhybrid/dist/libfile/apprentice.c:1.1 src/external/gpl2/mkhybrid/dist/libfile/apprentice.c:1.2
--- src/external/gpl2/mkhybrid/dist/libfile/apprentice.c:1.1	Fri May 31 19:52:25 2024
+++ src/external/gpl2/mkhybrid/dist/libfile/apprentice.c	Fri May 31 20:25:41 2024
@@ -1,7 +1,6 @@
 /* @(#)apprentice.c	1.13 09/07/11 joerg */
-#include <schily/mconfig.h>
 #ifndef lint
-static	UConst char sccsid[] =
+static	const char sccsid[] =
 	"@(#)apprentice.c	1.13 09/07/11 joerg";
 #endif
 /*
@@ -44,15 +43,15 @@ static	UConst char sccsid[] =
  * SUCH DAMAGE.
  */
 
-#include <schily/stdio.h>
-#include <schily/stdlib.h>
-#include <schily/string.h>
-#include <schily/ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include "proto.h"
 #include "file.h"
-#include <schily/schily.h>
 
 #ifndef	lint
-static UConst char moduleid[] = 
+static const char moduleid[] = 
 	"@(#)Id: apprentice.c,v 1.25 1997/01/15 17:23:24 christos Exp";
 #endif	/* lint */
 
@@ -73,23 +72,24 @@ struct  magic *__f_magic;	/* array of ma
 			tolower((unsigned char) (l)) : (l))
 
 
-static int getvalue	__PR((struct magic *, char **));
-static int hextoint	__PR((int));
-static char *apgetstr	__PR((char *, char *, int, int *));
-static int parse	__PR((char *, int *, int));
-static void eatsize	__PR((char **));
+static int getvalue	(struct magic *, char **);
+static int hextoint	(int);
+static char *apgetstr	(char *, char *, int, int *);
+static int parse	(char *, int *, int);
+static void eatsize	(char **);
 
 static int maxmagic = 0;
 
-static int apprentice_1	__PR((char *, int));
+static int apprentice_1	(char *, int);
 
 /*
  * init_magic - read magic file and set up mapping
  * based on the original apprentice()
  */
 int
-init_magic(fn)
-char *fn;			/* list of magic files */
+init_magic(
+char *fn			/* list of magic files */
+)
 {
         maxmagic = MAXMAGIS;
 	__f_magic = (struct magic *) calloc(sizeof(struct magic), maxmagic);
@@ -100,9 +100,10 @@ char *fn;			/* list of magic files */
 }
 
 static int
-apprentice_1(fn, check)
-char *fn;			/* name of magic file */
-int check;			/* non-zero? checking-only run. */
+apprentice_1(
+char *fn,			/* name of magic file */
+int check			/* non-zero? checking-only run. */
+)
 {
 	static const char hdr[] =
 		"cont\toffset\ttype\topcode\tmask\tvalue\tdesc";
@@ -139,9 +140,7 @@ int check;			/* non-zero? checking-only 
  * XXX is uint32 really a good idea XXX JS
  */
 UInt32_t
-signextend(m, v)
-struct magic *m;
-UInt32_t v;
+signextend(struct magic *m, UInt32_t v)
 {
 	if (!(m->flag & UNSIGNED))
 		switch(m->type) {
@@ -178,9 +177,7 @@ UInt32_t v;
  * parse one line from magic file, put into magic[index++] if valid
  */
 static int
-parse(l, ndx, check)
-char *l;
-int *ndx, check;
+parse(char *l, int *ndx, int check)
 {
 	int i = 0, nd = *ndx;
 	struct magic *m;
@@ -402,9 +399,7 @@ GetDesc:
  * just after the number read.  Return 0 for success, non-zero for failure.
  */
 static int
-getvalue(m, p)
-struct magic *m;
-char **p;
+getvalue(struct magic *m, char **p)
 {
 	int slen;
 
@@ -426,10 +421,7 @@ char **p;
  * Return updated scan pointer as function result.
  */
 static char *
-apgetstr(s, p, plen, slen)
-register char	*s;
-register char	*p;
-int	plen, *slen;
+apgetstr(char *s, char *p, int plen, int *slen)
 {
 	char	*origs = s, *origp = p;
 	char	*pmax = p + plen - 1;
@@ -529,8 +521,7 @@ out:
 
 /* Single hex char to int; -1 if not a hex char. */
 static int
-hextoint(c)
-int c;
+hextoint(int c)
 {
 	if (!isascii((unsigned char) c))	return -1;
 	if (isdigit((unsigned char) c))		return c - '0';
@@ -544,10 +535,7 @@ int c;
  * Print a string containing C character escapes.
  */
 void
-showstr(fp, s, len)
-FILE *fp;
-const char *s;
-int len;
+showstr(FILE *fp, const char *s, int len)
 {
 	register char	c;
 
@@ -603,8 +591,7 @@ int len;
  * eatsize(): Eat the size spec from a number [eg. 10UL]
  */
 static void
-eatsize(p)
-char **p;
+eatsize(char **p)
 {
 	char *l = *p;
 
Index: src/external/gpl2/mkhybrid/dist/libfile/file.h
diff -u src/external/gpl2/mkhybrid/dist/libfile/file.h:1.1 src/external/gpl2/mkhybrid/dist/libfile/file.h:1.2
--- src/external/gpl2/mkhybrid/dist/libfile/file.h:1.1	Fri May 31 19:52:25 2024
+++ src/external/gpl2/mkhybrid/dist/libfile/file.h	Fri May 31 20:25:41 2024
@@ -35,10 +35,8 @@
 #ifndef __file_h__
 #define __file_h__
 
-#ifndef	_SCHILY_MCONFIG_H
-#include <schily/mconfig.h>
-#endif
-#include <schily/utypes.h>
+typedef int Int32_t;
+typedef unsigned int UInt32_t;
 
 #ifndef HOWMANY
 # define HOWMANY 8192		/* how much of the file to look at */
@@ -85,29 +83,26 @@ struct magic {
 	char desc[MAXDESC];	/* description */
 };
 
-#include <schily/stdio.h>
+#include <stdio.h>
 
-extern int   init_magic		__PR((char *));
-extern int   ascmagic		__PR((unsigned char *, int));
-/*extern void  error		__PR((const char *, ...));*/
-extern void  ckfputs		__PR((const char *, FILE *));
+extern int   init_magic		(char *);
+extern int   ascmagic		(unsigned char *, int);
+extern void  ckfputs		(const char *, FILE *);
 struct stat;
-extern int   fsmagic		__PR((const char *, struct stat *));
-extern int   is_compress	__PR((const unsigned char *, int *));
-extern int   is_tar		__PR((unsigned char *, int));
-extern void  magwarn		__PR((const char *, ...));
-extern void  mdump		__PR((struct magic *));
-extern char *get_magic_magic	__PR((const char *));
-extern void  showstr		__PR((FILE *, const char *, int));
-extern char *softmagic		__PR((unsigned char *, int));
-extern int   tryit		__PR((unsigned char *, int, int));
-extern int   zmagic		__PR((unsigned char *, int));
-extern void  ckfprintf		__PR((FILE *, const char *, ...));
-#ifndef __BEOS__
-extern UInt32_t signextend	__PR((struct magic *, UInt32_t));
-#endif /* __BEOS__ */
-extern int internatmagic	__PR((unsigned char *, int));
-extern void tryelf		__PR((int, char *, int));
+extern int   fsmagic		(const char *, struct stat *);
+extern int   is_compress	(const unsigned char *, int *);
+extern int   is_tar		(unsigned char *, int);
+extern void  magwarn		(const char *, ...);
+extern void  mdump		(struct magic *);
+extern char *get_magic_magic	(const char *);
+extern void  showstr		(FILE *, const char *, int);
+extern char *softmagic		(unsigned char *, int);
+extern int   tryit		(unsigned char *, int, int);
+extern int   zmagic		(unsigned char *, int);
+extern void  ckfprintf		(FILE *, const char *, ...);
+extern UInt32_t signextend	(struct magic *, UInt32_t);
+extern int internatmagic	(unsigned char *, int);
+extern void tryelf		(int, char *, int);
 
 
 extern char *progname;		/* the program name 			*/
@@ -121,14 +116,6 @@ extern int debug;		/* enable debugging?	
 extern int zflag;		/* process compressed files?		*/
 extern int lflag;		/* follow symbolic links?		*/
 
-#if defined(sun) || defined(__sun__) || defined (__sun)
-# if defined(__svr4) || defined (__SVR4) || defined(__svr4__)
-#  define SOLARIS
-# else
-#  define SUNOS
-# endif
-#endif
-
 
 #ifndef	HAVE_STRERROR
 extern int sys_nerr;
Index: src/external/gpl2/mkhybrid/dist/libfile/lfile.c
diff -u src/external/gpl2/mkhybrid/dist/libfile/lfile.c:1.1 src/external/gpl2/mkhybrid/dist/libfile/lfile.c:1.2
--- src/external/gpl2/mkhybrid/dist/libfile/lfile.c:1.1	Fri May 31 19:52:25 2024
+++ src/external/gpl2/mkhybrid/dist/libfile/lfile.c	Fri May 31 20:25:41 2024
@@ -1,7 +1,6 @@
 /* @(#)file.c	1.10 09/08/04 joerg */
-#include <schily/mconfig.h>
 #ifndef lint
-static	UConst char sccsid[] =
+static	const char sccsid[] =
 	"@(#)file.c	1.10 09/08/04 joerg";
 #endif
 /*
@@ -67,15 +66,15 @@ static	UConst char sccsid[] =
  * SUCH DAMAGE.
  */
 #ifndef	lint
-static UConst char moduleid[] = 
+static const char moduleid[] = 
 	"@(#)Id: file.c,v 1.38 1997/01/15 19:28:35 christos Exp";
 #endif	/* lint */
 
-#include <schily/stdio.h>
-#include <schily/stdlib.h>
-#include <schily/unistd.h>	/* for read() */
-#include <schily/stat.h>
-#include <schily/fcntl.h>	/* for open() */
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>	/* for read() */
+#include <sys/stat.h>
+#include <fcntl.h>	/* for open() */
 
 #ifdef RESTORE_TIME
 #include <schily/utime.h>
@@ -84,10 +83,6 @@ static UConst char moduleid[] = 
 #endif
 #endif
 
-#if 0
-#include <schily/in.h>		/* for byte swapping */
-#endif
-
 #include "patchlevel.h"
 #include "file.h"
 
@@ -107,86 +102,15 @@ char *magicfile;	/* where magic be found
 char *progname;		/* used throughout 			*/
 #endif
 
-char *	get_magic_match	__PR((const char *inname));
-void	clean_magic	__PR((void));
-
-#if 0
-static int	byteconv4	__P((int, int, int));
-static short	byteconv2	__P((int, int, int));
-#endif
-
-#if 0
-/*
- * byteconv4
- * Input:
- *	from		4 byte quantity to convert
- *	same		whether to perform byte swapping
- *	big_endian	whether we are a big endian host
- */
-static int
-byteconv4(from, same, big_endian)
-    int from;
-    int same;
-    int big_endian;
-{
-  if (same)
-    return from;
-  else if (big_endian)		/* lsb -> msb conversion on msb */
-  {
-    union {
-      int i;
-      char c[4];
-    } retval, tmpval;
-
-    tmpval.i = from;
-    retval.c[0] = tmpval.c[3];
-    retval.c[1] = tmpval.c[2];
-    retval.c[2] = tmpval.c[1];
-    retval.c[3] = tmpval.c[0];
-
-    return retval.i;
-  }
-  else
-    return ntohl(from);		/* msb -> lsb conversion on lsb */
-}
-
-/*
- * byteconv2
- * Same as byteconv4, but for shorts
- */
-static short
-byteconv2(from, same, big_endian)
-	int from;
-	int same;
-	int big_endian;
-{
-  if (same)
-    return from;
-  else if (big_endian)		/* lsb -> msb conversion on msb */
-  {
-    union {
-      short s;
-      char c[2];
-    } retval, tmpval;
-
-    tmpval.s = (short) from;
-    retval.c[0] = tmpval.c[1];
-    retval.c[1] = tmpval.c[0];
-
-    return retval.s;
-  }
-  else
-    return ntohs(from);		/* msb -> lsb conversion on lsb */
-}
-#endif
+char *	get_magic_match	(const char *inname);
+void	clean_magic	(void);
 
 /*
  * get_magic_match - get the CREATOR/TYPE string
  * based on the original process()
  */
 char *
-get_magic_match(inname)
-const char	*inname;
+get_magic_match(const char *inname)
 {
 	int	fd = 0;
 	unsigned char	buf[HOWMANY+1];	/* one extra for terminating '\0' */
@@ -247,7 +171,7 @@ const char	*inname;
  * clean_magic - deallocate memory used
  */
 void
-clean_magic()
+clean_magic(void)
 {
 	if (__f_magic)
 		free(__f_magic);
@@ -255,9 +179,7 @@ clean_magic()
 	
 
 #ifdef MAIN
-main(argc, argv)
-int	argc;
-char	**argv;
+main(int argc, char **argv)
 {
 	char	*ret;
 	char	creator[5];
Index: src/external/gpl2/mkhybrid/dist/libfile/softmagic.c
diff -u src/external/gpl2/mkhybrid/dist/libfile/softmagic.c:1.1 src/external/gpl2/mkhybrid/dist/libfile/softmagic.c:1.2
--- src/external/gpl2/mkhybrid/dist/libfile/softmagic.c:1.1	Fri May 31 19:52:25 2024
+++ src/external/gpl2/mkhybrid/dist/libfile/softmagic.c	Fri May 31 20:25:41 2024
@@ -1,7 +1,6 @@
 /* @(#)softmagic.c	1.12 09/07/11 joerg */
-#include <schily/mconfig.h>
 #ifndef lint
-static	UConst char sccsid[] =
+static	const char sccsid[] =
 	"@(#)softmagic.c	1.12 09/07/11 joerg";
 #endif
 /*
@@ -44,15 +43,14 @@ static	UConst char sccsid[] =
  * SUCH DAMAGE.
  */
 
-#include <schily/stdio.h>
-#include <schily/string.h>
-#include <schily/stdlib.h>
-#include <schily/schily.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
 
 #include "file.h"
 
 #ifndef	lint
-static UConst char moduleid[] = 
+static const char moduleid[] = 
 	"@(#)Id: softmagic.c,v 1.34 1997/01/15 19:28:35 christos Exp";
 #endif	/* lint */
 
@@ -62,16 +60,15 @@ int	debug = 1; 	/* debugging 				*/
 #define	debug	0 	/* debugging 				*/
 #endif /* DEBUG */
 
-/* static int match	__PR((unsigned char *, int)); */
-static char *match	__PR((unsigned char *, int));
-static int mget		__PR((union VALUETYPE *,
-			     unsigned char *, struct magic *, int));
+static char *match	(unsigned char *, int);
+static int mget		(union VALUETYPE *,
+			     unsigned char *, struct magic *, int);
 /* QNX has a mcheck() prototyp in a public include file */
-static int magcheck	__PR((union VALUETYPE *, struct magic *));
+static int magcheck	(union VALUETYPE *, struct magic *);
 #ifdef	__used__
-static void mdebug	__PR((Int32_t, char *, int));
+static void mdebug	(Int32_t, char *, int);
 #endif
-static int mconvert	__PR((union VALUETYPE *, struct magic *));
+static int mconvert	(union VALUETYPE *, struct magic *);
 
 /*
  * softmagic - lookup one file in database 
@@ -80,9 +77,7 @@ static int mconvert	__PR((union VALUETYP
  */
 /*ARGSUSED1*/		/* nbytes passed for regularity, maybe need later */
 char *
-softmagic(buf, nbytes)
-unsigned char *buf;
-int nbytes;
+softmagic(unsigned char *buf, int nbytes)
 {
 	return (match(buf, nbytes));
 }
@@ -115,9 +110,7 @@ int nbytes;
  *	so that higher-level continuations are processed.
  */
 static char *
-match(s, nbytes)
-unsigned char	*s;
-int nbytes;
+match(unsigned char *s, int nbytes)
 {
 	int magindex = 0;
 	union VALUETYPE p;
@@ -146,9 +139,7 @@ int nbytes;
  * Convert the byte order of the data we are looking at
  */
 static int
-mconvert(p, m)
-union VALUETYPE *p;
-struct magic *m;
+mconvert(union VALUETYPE *p, struct magic *m)
 {
 	switch (m->type) {
 	case BYTE:
@@ -189,10 +180,7 @@ struct magic *m;
 
 #ifdef	__used__
 static void
-mdebug(offset, str, len)
-Int32_t offset;
-char *str;
-int len;
+mdebug(Int32_t offset, char *str, int len)
 {
 	(void) fprintf(stderr, "mget @%d: ", offset);
 	showstr(stderr, (char *) str, len);
@@ -202,11 +190,7 @@ int len;
 #endif
 
 static int
-mget(p, s, m, nbytes)
-union VALUETYPE* p;
-unsigned char	*s;
-struct magic *m;
-int nbytes;
+mget(union VALUETYPE* p, unsigned char *s, struct magic *m, int nbytes)
 {
 	Int32_t offset = m->offset;
 
@@ -252,9 +236,7 @@ int nbytes;
 }
 
 static int
-magcheck(p, m)
-union VALUETYPE* p;
-struct magic *m;
+magcheck(union VALUETYPE* p, struct magic *m)
 {
 	register UInt32_t l = m->value.l;
 	register UInt32_t v;

Reply via email to