xref: /freebsd/contrib/file/magic/Magdir/pack (revision ae316d1d1cffd71ab7751f94e10118777a88e027)
1#------------------------------------------------------------------------------
2# $File: pack,v 1.1 2024/08/30 17:29:28 christos Exp $
3# file(1) magic for things that have PACK as magic
4
50	string	PACK
6# Type: Git pack
7# From: Adam Buchbinder <adam.buchbinder@gmail.com>
8# Update: Joerg Jenderek
9# URL: http://fileformats.archiveteam.org/wiki/Git
10# reference: https://github.com/git/git/blob/master/Documentation/technical/pack-format.txt
11# The actual magic is 'PACK', but that clashes with Doom/Quake packs. However,
12# those have a little-endian offset immediately following the magic 'PACK',
13# the first byte of which is never 0, while the first byte of the Git pack
14# version, since it's a tiny number stored in big-endian format, is always 0.
15# GRR: line above is too general as it matches also PackDir archive ./acorn
16# test for major version. Git 2017 accepts version number 2 or 3
17>4	ubelong	<9
18# Acorn PackDir with method 0 compression has root like ADFS::HardDisc4.$.AsylumSrc
19# or SystemDevice::foobar
20>>9	search/13 ::
21# but in git binary
22>>9	default	x	Git pack
23!:mime	application/x-git
24!:ext	pack
25# 4 GB limit implies unsigned integer
26>>>4	ubelong	x		\b, version %u
27>>>8	ubelong	x		\b, %u objects
28
29# From: Joerg Jenderek
30# URL: https://www.kyzer.me.uk/pack/xad/#PackDir
31# reference: https://www.kyzer.me.uk/pack/xad/xad_PackDir.lha/PackDir.c
32# GRR: line below is too general as it matches also "Git pack" in ./revision
33# check for valid compression method 0-4
34>5	ulelong	<5
35# https://www.riscosopen.org/wiki/documentation/show/Introduction%20To%20Filing%20Systems
36# To skip "Git pack" version 0 test for root directory object like
37# ADFS::RPC.$.websitezip.FONTFIX
38>>9	string	>ADFS\  PackDir archive (RISC OS)
39# TrID labels above as "Acorn PackDir compressed Archive"
40# compression mode y (0 - 4) for GIF LZW with a maximum n bits
41# (y~n,0~12,1~13,2~14,3~15,4~16)
42>>>5	ulelong+12 x	\b, LZW %u-bits compression
43# https://www.filebase.org.uk/filetypes
44# !Packdir compressed archive has three hexadecimal digits code 68E
45!:mime	application/x-acorn-68E
46!:ext	pkd/bin
47# null terminated root directory object like IDEFS::IDE-4.$.Apps.GRAPHICS.!XFMPdemo
48>>>9	string	x	\b, root "%s"
49# load address 0xFFFtttdd, ttt is the object filetype and dddddddddd is time
50>>>>&1	ulelong	x	\b, load address %#x
51# execution address 0xdddddddd dddddddddd is 40 bit unsigned centiseconds since 1.1.1900 UTC
52>>>>&5	ulelong	x	\b, exec address %#x
53# attributes (bits: 0~owner read,1~owner write,3~no delete,4~public read,5~public write)
54>>>>&9	ulelong	x	\b, attributes %#x
55# number of entries in this directory. for root dir 0
56#>>>&13	ulelong	x	\b, entries %#x
57# the entries start here with object name
58>>>>&17	string	x	\b, 1st object "%s"
59
60# Update: Joerg Jenderek
61# URL: http://fileformats.archiveteam.org/wiki/PAK
62# reference: https://quakewiki.org/wiki/.pak
63# GRR: line below is too general as it matches also Acorn PackDir compressed Archive
64# real Quake examples like pak0.pak have only some hundreds like 150 files
65# So test for few files
66>8	ulelong <0x01000000
67# in file version 5.32 test for null terminator is only true for
68# offset ~< FILE_BYTES_MAX = 1 MB defined in ../../src/file.h
69# look for null terminator of 1st entry name
70>>(4.l+55)	ubyte	0	Quake I or II world or extension
71!:mime	application/x-dzip
72!:ext	pak
73#>>>8	ulelong	x	\b, table size %u
74# dividing this by entry size (64) gives number of files
75>>>8	ulelong/64 x	\b, %u files
76# offset to the beginning of the file table
77>>>4	ulelong	x	\b, offset %#x
78# 1st file entry
79>>>(4.l)	use	pak-entry
80# 2nd file entry
81#>>>4	ulelong+64	x	\b, offset %#x
82#>>>(4.l+64)	use	pak-entry
83#
84#	display file table entry of Quake PAK archive
850	name		pak-entry
86# normally entry start after header which implies offset 12 or higher
87>56	ulelong	>11
88# the offset from the beginning of pak to beginning of this entry file contents
89>>56	ulelong	x	at %#x
90# the size of file for this entry
91>>60	ulelong	x	%u bytes
92# 56 byte null-terminated entry name string includes path like maps/e1m1.bsp
93>>0	string	x	'%-.56s'
94# inspect entry content by jumping to entry offset
95>>(56)	indirect x	\b:
96
97#0       string  -1\x0a  Quake I demo
98#>30     string  x        version %.4s
99#>61     string  x        level %s
100
101#0       string  5\x0a   Quake I save
102