--I. -DHAVE_CONFIG_H -DSTDC
+-I. -DHAVE_CONFIG_H -DSTDC -D_GNU_SOURCE -D__GLIBC__ -D__STDC__=1 -DHAVE_STRUCT_STAT_ST_RDEV
#+partial
+forcehints
-exportheader # 19
-formatconst # 9
-macroredef # 1 tar.h
--moduncon # 1 getopt_long
--modunconnomods # 12 ctype.h
--mustmod # 1 mman.h
--noparams # 3 getopt_long
-nullderef # 4
-nullpass # 27
-nullptrarith # 1
-redef # 4
-sizeoftype # 29
-uniondef # 6
--usevarargs # 1
# --- +partial artifacts
--exportlocal # 18
# --- not-yet at strict level
-bitwisesigned # 47
-elseifcomplete # 3
--fielduse # 21 tar.h
+#-fielduse # 21 tar.h
-forblock # 6
-ifblock # 231
-incondefs # 36
file_SOURCES = file.c apprentice.c fsmagic.c softmagic.c ascmagic.c \
compress.c is_tar.c readelf.c print.c \
file.h names.h patchlevel.h readelf.h tar.h
+file_LDFLAGS = -all-static
-EXTRA_DIST = LEGAL.NOTICE MAINT PORTING Makefile.std magic2mime \
+EXTRA_DIST = LEGAL.NOTICE MAINT Makefile.std magic2mime \
Localstuff Header $(magic_FRAGMENTS) file.man magic.man
-CLEANFILES = $(man_MANS) magic magic.mgc magic.mime.mgc
+BUILT_SOURCES = $(man_MANS) magic magic.mgc magic.mime.mgc
magic: Header Localstuff $(magic_FRAGMENTS)
cat $(srcdir)/Header $(srcdir)/Localstuff > $@
[ --disable-largefile omit support for large files])
if test "$enable_largefile" != no; then
- AC_CACHE_CHECK([for special C compiler options needed for large files=
-],
+ AC_CACHE_CHECK([for special C compiler options needed for large files],
ac_cv_sys_largefile_CC,
[ac_cv_sys_largefile_CC=no
if test "$GCC" != yes; then
/*@unchecked@*/
#ifdef __EMX__
- char PATHSEP=';';
+ static char PATHSEP=';';
#else
- char PATHSEP=':';
+ static char PATHSEP=':';
#endif
/*@unchecked@*/
return 1;
}
-int
+static int
looks_utf8(const unsigned char *buf, int nbytes,
/*@out@*/ unichar *ubuf, /*@out@*/ int *ulen)
/*@modifies *ubuf, *ulen @*/
*/
/*@unchecked@*/ /*@observer@*/
-unsigned char ebcdic_to_ascii[] = {
+static unsigned char ebcdic_to_ascii[] = {
0, 1, 2, 3, 156, 9, 134, 127, 151, 141, 142, 11, 12, 13, 14, 15,
16, 17, 18, 19, 157, 133, 8, 135, 24, 25, 146, 143, 28, 29, 30, 31,
128, 129, 130, 131, 132, 10, 23, 27, 136, 137, 138, 139, 140, 5, 6, 7,
*/
/*@unchecked@*/ /*@unused@*/ /*@observer@*/
-unsigned char ebcdic_1047_to_8859[] = {
+static unsigned char ebcdic_1047_to_8859[] = {
0x00,0x01,0x02,0x03,0x9C,0x09,0x86,0x7F,0x97,0x8D,0x8E,0x0B,0x0C,0x0D,0x0E,0x0F,
0x10,0x11,0x12,0x13,0x9D,0x0A,0x08,0x87,0x18,0x19,0x92,0x8F,0x1C,0x1D,0x1E,0x1F,
0x80,0x81,0x82,0x83,0x84,0x85,0x17,0x1B,0x88,0x89,0x8A,0x8B,0x8C,0x05,0x06,0x07,
#define MAXPATHLEN 512
#endif
+ /* Global command-line options */
/*@unchecked@*/
-int /* Global command-line options */
- debug = 0, /* debugging */
- lflag = 0, /* follow Symlinks (BSD only) */
- bflag = 0, /* brief output format */
- zflag = 0, /* follow (uncompress) compressed files */
- sflag = 0, /* read block special files */
- iflag = 0,
- nobuffer = 0, /* Do not buffer stdout */
- kflag = 0; /* Keep going after the first match */
+ int debug = 0; /* debugging */
+/*@unchecked@*/
+ int lflag = 0; /* follow Symlinks (BSD only) */
+/*@unchecked@*/
+static int bflag = 0; /* brief output format */
+/*@unchecked@*/
+ int zflag = 0; /* follow (uncompress) compressed files */
+/*@unchecked@*/
+ int sflag = 0; /* read block special files */
+/*@unchecked@*/
+ int iflag = 0;
+/*@unchecked@*/
+static int nobuffer = 0; /* Do not buffer stdout */
+/*@unchecked@*/
+ int kflag = 0; /* Keep going after the first match */
/*@unchecked@*/ /*@null@*/
const char *magicfile = 0; /* where the magic is */
/*@unchecked@*/ /*@observer@*/
-const char *default_magicfile = MAGIC;
+static const char *default_magicfile = MAGIC;
/*@unchecked@*/
char *progname; /* used throughout */
#ifndef HAVE_GETOPT_H
while ((c = getopt(argc, argv, OPTSTRING)) != -1)
#else
+/*@-compdef @*/
while ((c = getopt_long(argc, argv, OPTSTRING, long_options,
&longindex)) != -1)
+/*@=compdef @*/
#endif
{
switch (c) {
/*@unchecked@*/
extern struct mlist mlist; /* list of arrays of magic entries */
+/*@-exportlocal@*/
/*@unchecked@*/
extern int debug; /* enable debugging? */
/*@unchecked@*/
extern int sflag; /* read/analyze block special files? */
/*@unchecked@*/
extern int iflag; /* Output types as mime-types */
-
-#ifdef NEED_GETOPT
-/*@unchecked@*/
-extern int optind; /* From getopt(3) */
/*@unchecked@*/
-extern char *optarg;
-#endif
+extern int kflag; /* Keep going after the first match */
+/*@=exportlocal@*/
/*@mayexit@*/
extern int apprentice(const char *fn, int action)
/*@modifies fil, fileSystem @*/;
struct stat;
extern int fsmagic(const char *fn, /*@out@*/ struct stat *sb)
- /*@globals fileSystem @*/
- /*@modifies *sb, fileSystem @*/;
+ /*@globals fileSystem, internalState @*/
+ /*@modifies *sb, fileSystem, internalState @*/;
/*@observer@*/
extern char *fmttime(long v, int local)
/*@*/;
* Fstat is cheaper but fails for files you don't have read perms on.
* On 4.2BSD and similar systems, use lstat() to identify symlinks.
*/
-#ifdef S_IFLNK
+#if defined(S_IFLNK) || defined(__LCLINT__)
if (!lflag)
ret = lstat(fn, sb);
else
}
}
else {
-#ifdef S_ISUID
+#if defined(S_ISUID) || defined(__LCLINT__)
if (sb->st_mode & S_ISUID) ckfputs("setuid ", stdout);
#endif
-#ifdef S_ISGID
+#if defined(S_ISGID) || defined(__LCLINT__)
if (sb->st_mode & S_ISGID) ckfputs("setgid ", stdout);
#endif
-#ifdef S_ISVTX
+#if defined(S_ISVTX) || defined(__LCLINT__)
if (sb->st_mode & S_ISVTX) ckfputs("sticky ", stdout);
#endif
}
case S_IFDIR:
ckfputs("directory", stdout);
return 1;
-#ifdef S_IFCHR
+#if defined(S_IFCHR) || defined(__LCLINT__)
case S_IFCHR:
/*
* If -s has been specified, treat character special files
*/
if (sflag)
break;
-#ifdef HAVE_ST_RDEV
+#ifdef HAVE_STRUCT_STAT_ST_RDEV
# ifdef dv_unit
(void) printf("character special (%d/%d/%d)",
major(sb->st_rdev),
#endif
return 1;
#endif
-#ifdef S_IFBLK
+#if defined(S_IFBLK) || defined(__LCLINT__)
case S_IFBLK:
/*
* If -s has been specified, treat block special files
*/
if (sflag)
break;
-#ifdef HAVE_ST_RDEV
+#ifdef HAVE_STRUCT_STAT_ST_RDEV
# ifdef dv_unit
(void) printf("block special (%d/%d/%d)",
major(sb->st_rdev),
return 1;
#endif
/* TODO add code to handle V7 MUX and Blit MUX files */
-#ifdef S_IFIFO
+#if defined(S_IFIFO) || defined(__LCLINT__)
case S_IFIFO:
ckfputs("fifo (named pipe)", stdout);
return 1;
#endif
-#ifdef S_IFDOOR
+#if defined(S_IFDOOR)
case S_IFDOOR:
ckfputs("door", stdout);
return 1;
#endif
-#ifdef S_IFLNK
+#if defined(S_IFLNK) || defined(__LCLINT__)
case S_IFLNK:
{
char buf[BUFSIZ+4];
int nch;
struct stat tstatbuf;
+ buf[0] = '\0';
if ((nch = readlink(fn, buf, BUFSIZ-1)) <= 0) {
ckfprintf(stdout, "unreadable symlink (%s).",
strerror(errno));
buf[nch] = '\0'; /* readlink(2) forgets this */
/* If broken symlink, say so and quit early. */
+/*@-branchstate@*/
if (*buf == '/') {
if (stat(buf, &tstatbuf) < 0) {
ckfprintf(stdout,
return 1;
}
}
+/*@=branchstate@*/
/* Otherwise, handle it. */
if (lflag) {
}
return 1;
#endif
-#ifdef S_IFSOCK
+#if defined(S_IFSOCK)
#ifndef __COHERENT__
case S_IFSOCK:
ckfputs("socket", stdout);
/* Adjust checksum to count the "chksum" field as blanks. */
for (i = sizeof(header->header.chksum); --i >= 0;)
sum -= 0xFF & header->header.chksum[i];
- sum += ' '* sizeof header->header.chksum;
+ sum += ' ' * sizeof header->header.chksum;
if (sum != recsum)
return 0; /* Not a tar archive */
- if (0==strcmp(header->header.magic, TMAGIC))
+ if (!strcmp(header->header.magic, TMAGIC))
return 2; /* Unix Standard tar archive */
return 1; /* Old fashioned tar archive */
FILE_RCSID("@(#)Id: softmagic.c,v 1.51 2002/07/03 18:26:38 christos Exp ")
-/*@-redecl@*/
-/*@unchecked@*/
-extern int kflag;
-/*@=redecl@*/
-
static int32_t
mprint(union VALUETYPE *p, struct magic *m)
/*@globals fileSystem @*/
{
struct mlist *ml;
- for (ml = mlist.next; ml != &mlist; ml = ml->next)
+ for (ml = mlist.next; ml != &mlist; ml = ml->next) {
if (match(ml->magic, ml->nmagic, buf, nbytes))
return 1;
+ }
return 0;
}
#if defined (__GLIBC__) && defined(__LCLINT__)
/*@-declundef@*/
+/*@-exportfcn@*/
+extern __const unsigned short int **__ctype_b_loc (void)
+ __attribute__ ((__const)) /*@*/;
+extern __const __int32_t **__ctype_tolower_loc (void)
+ __attribute__ ((__const)) /*@*/;
+extern __const __int32_t **__ctype_toupper_loc (void)
+ __attribute__ ((__const)) /*@*/;
+/*@=exportfcn@*/
+/*@-exportvar@*/
/*@unchecked@*/
extern __const __int32_t *__ctype_tolower;
/*@unchecked@*/
extern __const __int32_t *__ctype_toupper;
+/*@=exportvar@*/
/*@=declundef@*/
#endif
#if defined (__GLIBC__) && defined(__LCLINT__)
/*@-exportlocal@*/
extern int isalnum(int) __THROW /*@*/;
+extern int isalpha(int) __THROW /*@*/;
+extern int isascii(int) __THROW /*@*/;
extern int iscntrl(int) __THROW /*@*/;
+extern int isdigit(int) __THROW /*@*/;
extern int isgraph(int) __THROW /*@*/;
extern int islower(int) __THROW /*@*/;
+extern int isprint(int) __THROW /*@*/;
extern int ispunct(int) __THROW /*@*/;
+extern int isspace(int) __THROW /*@*/;
+extern int isupper(int) __THROW /*@*/;
extern int isxdigit(int) __THROW /*@*/;
-extern int isascii(int) __THROW /*@*/;
extern int toascii(int) __THROW /*@*/;
extern int _toupper(int) __THROW /*@*/;
extern int _tolower(int) __THROW /*@*/;
#undef HAVE_MAJOR
#ifdef HAVE_GETOPT_H
+#if defined(__LCLINT__)
+/*@-declundef -exportfcn @*/
+extern int getopt_long (int ___argc, char *const *___argv,
+ const char *__shortopts, const struct option *__longopts,
+ int * __longind)
+ /*@*/;
+/*@=declundef =exportfcn @*/
+#endif
#include <getopt.h> /* for long options (is this portable?)*/
#endif
+#ifdef NEED_GETOPT
+/*@unchecked@*/
+extern int optind; /* From getopt(3) */
+/*@unchecked@*/
+extern char *optarg;
+#endif
+
#if HAVE_REGEX_H
#include <regex.h>
#endif
#define __tar_h__
/*
- * Kludge for handling systems that can't cope with multiple
- * external definitions of a variable. In ONE routine (tar.c),
- * we #define TAR_EXTERN to null; here, we set it to "extern" if
- * it is not already set.
- */
-#ifndef TAR_EXTERN
-#define TAR_EXTERN extern
-#endif
-
-/*
* Header block on tape.
*
* I'm going to use traditional DP naming conventions here.
#define TUNMLEN 32
#define TGNMLEN 32
+/*@-fielduse@*/
union record {
char charptr[RECORDSIZE];
struct header {
char devminor[8];
} header;
};
+/*@=fielduse@*/
/* The checksum field is filled with this while the checksum is computed. */
#define CHKBLANKS " " /* 8 blanks, no null */
/* The magic field is filled with this if uname and gname are valid. */
#define TMAGIC "ustar " /* 7 chars and a null */
+#if 0
/* The linkflag defines the type of file */
#define LF_OLDNORMAL '\0' /* Normal disk file, Unix compat */
#define LF_NORMAL '0' /* Normal disk file */
#define EX_SYSTEM 4 /* system gave unexpected error */
-#if 0
/*
* Global variables
*/
-TAR_EXTERN union record *ar_block; /* Start of block of archive */
-TAR_EXTERN union record *ar_record; /* Current record of archive */
-TAR_EXTERN union record *ar_last; /* Last+1 record of archive block */
-TAR_EXTERN char ar_reading; /* 0 writing, !0 reading archive */
-TAR_EXTERN int blocking; /* Size of each block, in records */
-TAR_EXTERN int blocksize; /* Size of each block, in bytes */
-TAR_EXTERN char *ar_file; /* File containing archive */
-TAR_EXTERN char *name_file; /* File containing names to work on */
-TAR_EXTERN char *tar; /* Name of this program */
+extern union record *ar_block; /* Start of block of archive */
+extern union record *ar_record; /* Current record of archive */
+extern union record *ar_last; /* Last+1 record of archive block */
+extern char ar_reading; /* 0 writing, !0 reading archive */
+extern int blocking; /* Size of each block, in records */
+extern int blocksize; /* Size of each block, in bytes */
+extern char *ar_file; /* File containing archive */
+extern char *name_file; /* File containing names to work on */
+extern char *tar; /* Name of this program */
/*
* Flags from the command line
*/
-TAR_EXTERN char f_reblock; /* -B */
-TAR_EXTERN char f_create; /* -c */
-TAR_EXTERN char f_debug; /* -d */
-TAR_EXTERN char f_sayblock; /* -D */
-TAR_EXTERN char f_follow_links; /* -h */
-TAR_EXTERN char f_ignorez; /* -i */
-TAR_EXTERN char f_keep; /* -k */
-TAR_EXTERN char f_modified; /* -m */
-TAR_EXTERN char f_oldarch; /* -o */
-TAR_EXTERN char f_use_protection; /* -p */
-TAR_EXTERN char f_sorted_names; /* -s */
-TAR_EXTERN char f_list; /* -t */
-TAR_EXTERN char f_namefile; /* -T */
-TAR_EXTERN char f_verbose; /* -v */
-TAR_EXTERN char f_extract; /* -x */
-TAR_EXTERN char f_compress; /* -z */
-#endif
+extern char f_reblock; /* -B */
+extern char f_create; /* -c */
+extern char f_debug; /* -d */
+extern char f_sayblock; /* -D */
+extern char f_follow_links; /* -h */
+extern char f_ignorez; /* -i */
+extern char f_keep; /* -k */
+extern char f_modified; /* -m */
+extern char f_oldarch; /* -o */
+extern char f_use_protection; /* -p */
+extern char f_sorted_names; /* -s */
+extern char f_list; /* -t */
+extern char f_namefile; /* -T */
+extern char f_verbose; /* -v */
+extern char f_extract; /* -x */
+extern char f_compress; /* -z */
/*
* We now default to Unix Standard format rather than 4.2BSD tar format.
char name[NAMSIZ+1];
};
-#if 0
-TAR_EXTERN struct name *namelist; /* Points to first name in list */
-TAR_EXTERN struct name *namelast; /* Points to last name in list */
+extern struct name *namelist; /* Points to first name in list */
+extern struct name *namelast; /* Points to last name in list */
-TAR_EXTERN int archive; /* File descriptor for archive file */
-TAR_EXTERN int errors; /* # of files in error */
-#endif
+extern int archive; /* File descriptor for archive file */
+extern int errors; /* # of files in error */
/*
*
char name[NAMSIZ+1];
};
-#if 0
-TAR_EXTERN struct link *linklist; /* Points to first link in list */
-
+extern struct link *linklist; /* Points to first link in list */
/*
* Error recovery stuff
*/
-TAR_EXTERN char read_error_flag;
+extern char read_error_flag;
#endif
#endif /* __tar_h__ */