head	1.1;
branch	1.1.1;
access;
symbols
	netbsd-11-0-RC4:1.1.1.7
	netbsd-11-0-RC3:1.1.1.7
	netbsd-11-0-RC2:1.1.1.7
	netbsd-11-0-RC1:1.1.1.7
	perseant-exfatfs-base-20250801:1.1.1.7
	netbsd-11:1.1.1.7.0.4
	netbsd-11-base:1.1.1.7
	netbsd-10-1-RELEASE:1.1.1.6
	perseant-exfatfs-base-20240630:1.1.1.7
	perseant-exfatfs:1.1.1.7.0.2
	perseant-exfatfs-base:1.1.1.7
	netbsd-8-3-RELEASE:1.1.1.3
	netbsd-9-4-RELEASE:1.1.1.4
	netbsd-10-0-RELEASE:1.1.1.6
	netbsd-10-0-RC6:1.1.1.6
	netbsd-10-0-RC5:1.1.1.6
	netbsd-10-0-RC4:1.1.1.6
	netbsd-10-0-RC3:1.1.1.6
	netbsd-10-0-RC2:1.1.1.6
	netbsd-10-0-RC1:1.1.1.6
	FILE5_45:1.1.1.7
	netbsd-10:1.1.1.6.0.2
	netbsd-10-base:1.1.1.6
	FILE5_43:1.1.1.6
	netbsd-9-3-RELEASE:1.1.1.4
	cjep_sun2x-base1:1.1.1.5
	cjep_sun2x:1.1.1.5.0.4
	cjep_sun2x-base:1.1.1.5
	cjep_staticlib_x-base1:1.1.1.5
	netbsd-9-2-RELEASE:1.1.1.4
	cjep_staticlib_x:1.1.1.5.0.2
	cjep_staticlib_x-base:1.1.1.5
	FILE5_40:1.1.1.5
	netbsd-9-1-RELEASE:1.1.1.4
	FILE5_39:1.1.1.4
	phil-wifi-20200421:1.1.1.4
	phil-wifi-20200411:1.1.1.4
	is-mlppp:1.1.1.4.0.6
	is-mlppp-base:1.1.1.4
	phil-wifi-20200406:1.1.1.4
	netbsd-8-2-RELEASE:1.1.1.3
	netbsd-9-0-RELEASE:1.1.1.4
	netbsd-9-0-RC2:1.1.1.4
	FILE5_38:1.1.1.4
	netbsd-9-0-RC1:1.1.1.4
	phil-wifi-20191119:1.1.1.4
	netbsd-9:1.1.1.4.0.4
	netbsd-9-base:1.1.1.4
	phil-wifi-20190609:1.1.1.4
	netbsd-8-1-RELEASE:1.1.1.3
	FILE5_37:1.1.1.4
	netbsd-8-1-RC1:1.1.1.3
	pgoyette-compat-merge-20190127:1.1.1.3.10.1
	pgoyette-compat-20190127:1.1.1.4
	pgoyette-compat-20190118:1.1.1.4
	pgoyette-compat-1226:1.1.1.4
	pgoyette-compat-1126:1.1.1.4
	pgoyette-compat-1020:1.1.1.4
	FILE5_35:1.1.1.4
	pgoyette-compat-0930:1.1.1.4
	pgoyette-compat-0906:1.1.1.4
	netbsd-7-2-RELEASE:1.1.1.2
	pgoyette-compat-0728:1.1.1.4
	netbsd-8-0-RELEASE:1.1.1.3
	phil-wifi:1.1.1.4.0.2
	phil-wifi-base:1.1.1.4
	pgoyette-compat-0625:1.1.1.4
	netbsd-8-0-RC2:1.1.1.3
	pgoyette-compat-0521:1.1.1.4
	pgoyette-compat-0502:1.1.1.4
	pgoyette-compat-0422:1.1.1.4
	netbsd-8-0-RC1:1.1.1.3
	FILE5_33:1.1.1.4
	pgoyette-compat-0415:1.1.1.3
	pgoyette-compat-0407:1.1.1.3
	pgoyette-compat-0330:1.1.1.3
	pgoyette-compat-0322:1.1.1.3
	pgoyette-compat-0315:1.1.1.3
	netbsd-7-1-2-RELEASE:1.1.1.2
	pgoyette-compat:1.1.1.3.0.10
	pgoyette-compat-base:1.1.1.3
	netbsd-7-1-1-RELEASE:1.1.1.2
	matt-nb8-mediatek:1.1.1.3.0.8
	matt-nb8-mediatek-base:1.1.1.3
	FILE5_32:1.1.1.3
	perseant-stdc-iso10646:1.1.1.3.0.6
	perseant-stdc-iso10646-base:1.1.1.3
	netbsd-8:1.1.1.3.0.4
	netbsd-8-base:1.1.1.3
	FILE5_31:1.1.1.3
	prg-localcount2-base3:1.1.1.3
	prg-localcount2-base2:1.1.1.3
	prg-localcount2-base1:1.1.1.3
	prg-localcount2:1.1.1.3.0.2
	prg-localcount2-base:1.1.1.3
	pgoyette-localcount-20170426:1.1.1.3
	bouyer-socketcan-base1:1.1.1.3
	pgoyette-localcount-20170320:1.1.1.3
	netbsd-7-1:1.1.1.2.0.34
	netbsd-7-1-RELEASE:1.1.1.2
	netbsd-7-1-RC2:1.1.1.2
	FILE5_30:1.1.1.3
	netbsd-7-nhusb-base-20170116:1.1.1.2
	bouyer-socketcan:1.1.1.2.0.32
	bouyer-socketcan-base:1.1.1.2
	pgoyette-localcount-20170107:1.1.1.2
	netbsd-7-1-RC1:1.1.1.2
	pgoyette-localcount-20161104:1.1.1.2
	netbsd-7-0-2-RELEASE:1.1.1.2
	localcount-20160914:1.1.1.2
	netbsd-7-nhusb:1.1.1.2.0.30
	netbsd-7-nhusb-base:1.1.1.2
	pgoyette-localcount-20160806:1.1.1.2
	pgoyette-localcount-20160726:1.1.1.2
	pgoyette-localcount:1.1.1.2.0.28
	pgoyette-localcount-base:1.1.1.2
	netbsd-7-0-1-RELEASE:1.1.1.2
	netbsd-7-0:1.1.1.2.0.26
	netbsd-7-0-RELEASE:1.1.1.2
	netbsd-7-0-RC3:1.1.1.2
	netbsd-7-0-RC2:1.1.1.2
	netbsd-7-0-RC1:1.1.1.2
	FILE5_22:1.1.1.2
	FILE5_20:1.1.1.2
	netbsd-6-0-6-RELEASE:1.1.1.2
	netbsd-6-1-5-RELEASE:1.1.1.2
	netbsd-7:1.1.1.2.0.24
	netbsd-7-base:1.1.1.2
	FILE5_19:1.1.1.2
	yamt-pagecache-base9:1.1.1.2
	yamt-pagecache-tag8:1.1.1.2
	netbsd-6-1-4-RELEASE:1.1.1.2
	netbsd-6-0-5-RELEASE:1.1.1.2
	tls-earlyentropy:1.1.1.2.0.22
	tls-earlyentropy-base:1.1.1.2
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.1.1.2
	riastradh-drm2-base3:1.1.1.2
	netbsd-6-1-3-RELEASE:1.1.1.2
	netbsd-6-0-4-RELEASE:1.1.1.2
	FILE5_16:1.1.1.2
	netbsd-6-1-2-RELEASE:1.1.1.2
	netbsd-6-0-3-RELEASE:1.1.1.2
	netbsd-6-1-1-RELEASE:1.1.1.2
	riastradh-drm2-base2:1.1.1.2
	riastradh-drm2-base1:1.1.1.2
	riastradh-drm2:1.1.1.2.0.14
	riastradh-drm2-base:1.1.1.2
	netbsd-6-1:1.1.1.2.0.20
	netbsd-6-0-2-RELEASE:1.1.1.2
	netbsd-6-1-RELEASE:1.1.1.2
	khorben-n900:1.1.1.2.0.18
	netbsd-6-1-RC4:1.1.1.2
	netbsd-6-1-RC3:1.1.1.2
	agc-symver:1.1.1.2.0.16
	agc-symver-base:1.1.1.2
	FILE5_14:1.1.1.2
	netbsd-6-1-RC2:1.1.1.2
	netbsd-6-1-RC1:1.1.1.2
	yamt-pagecache-base8:1.1.1.2
	FILE_5_12:1.1.1.2
	netbsd-6-0-1-RELEASE:1.1.1.2
	yamt-pagecache-base7:1.1.1.2
	matt-nb6-plus-nbase:1.1.1.2
	yamt-pagecache-base6:1.1.1.2
	netbsd-6-0:1.1.1.2.0.12
	netbsd-6-0-RELEASE:1.1.1.2
	netbsd-6-0-RC2:1.1.1.2
	tls-maxphys:1.1.1.2.0.10
	tls-maxphys-base:1.1.1.2
	matt-nb6-plus:1.1.1.2.0.8
	matt-nb6-plus-base:1.1.1.2
	netbsd-6-0-RC1:1.1.1.2
	yamt-pagecache-base5:1.1.1.2
	yamt-pagecache-base4:1.1.1.2
	FILE5_11:1.1.1.2
	netbsd-6:1.1.1.2.0.6
	netbsd-6-base:1.1.1.2
	yamt-pagecache-base3:1.1.1.2
	yamt-pagecache-base2:1.1.1.2
	yamt-pagecache:1.1.1.2.0.4
	yamt-pagecache-base:1.1.1.2
	FILE5_09:1.1.1.2
	cherry-xenmp:1.1.1.2.0.2
	cherry-xenmp-base:1.1.1.2
	FILE5_07:1.1.1.2
	bouyer-quota2-nbase:1.1.1.1
	bouyer-quota2:1.1.1.1.0.4
	bouyer-quota2-base:1.1.1.1
	matt-mips64-premerge-20101231:1.1.1.1
	matt-premerge-20091211:1.1.1.1
	jym-xensuspend-base:1.1.1.1
	jym-xensuspend:1.1.1.1.0.2
	jym-xensuspend-nbase:1.1.1.1
	FILE5_03:1.1.1.1
	CHRISTOS:1.1.1;
locks; strict;
comment	@# @;


1.1
date	2009.05.08.16.35.07;	author christos;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2009.05.08.16.35.07;	author christos;	state Exp;
branches
	1.1.1.1.2.1;
next	1.1.1.2;

1.1.1.2
date	2011.05.12.20.46.58;	author christos;	state Exp;
branches
	1.1.1.2.28.1
	1.1.1.2.32.1;
next	1.1.1.3;

1.1.1.3
date	2017.02.10.17.42.57;	author christos;	state Exp;
branches
	1.1.1.3.10.1;
next	1.1.1.4;
commitid	HAP3kn9Hn6ovMqFz;

1.1.1.4
date	2018.04.15.19.32.47;	author christos;	state Exp;
branches;
next	1.1.1.5;
commitid	unKSwpX2g9VqBzyA;

1.1.1.5
date	2021.04.09.18.58.01;	author christos;	state Exp;
branches;
next	1.1.1.6;
commitid	W9ddLLbSkHHinEOC;

1.1.1.6
date	2022.09.24.20.07.53;	author christos;	state Exp;
branches;
next	1.1.1.7;
commitid	Nf6F9kcpc0EPC9VD;

1.1.1.7
date	2023.08.18.18.36.50;	author christos;	state Exp;
branches;
next	;
commitid	IX26ghc1E2S0AiBE;

1.1.1.1.2.1
date	2009.05.08.16.35.07;	author jym;	state dead;
branches;
next	1.1.1.1.2.2;

1.1.1.1.2.2
date	2009.05.13.18.51.55;	author jym;	state Exp;
branches;
next	;

1.1.1.2.28.1
date	2017.03.20.06.52.19;	author pgoyette;	state Exp;
branches;
next	;
commitid	jjw7cAwgyKq7RfKz;

1.1.1.2.32.1
date	2017.04.21.16.51.23;	author bouyer;	state Exp;
branches;
next	;
commitid	dUG7nkTKALCadqOz;

1.1.1.3.10.1
date	2018.04.22.07.20.08;	author pgoyette;	state Exp;
branches;
next	;
commitid	W6xykws0Zbl4kpzA;


desc
@@


1.1
log
@Initial revision
@
text
@#------------------------------------------------------------------------------
# c64:  file(1) magic for various commodore 64 related files
#
# From: Dirk Jagdmann <doj@@cubic.org>

0x16500	belong		0x12014100	D64 Image
0x16500	belong		0x12014180	D71 Image
0x61800 belong		0x28034400	D81 Image
0	string		C64\40CARTRIDGE	CCS C64 Emultar Cartridge Image
0	belong		0x43154164	X64 Image

0	string		GCR-1541	GCR Image
>8	byte		x		version: %i
>9	byte		x		tracks: %i

9	string		PSUR		ARC archive (c64)
2	string		-LH1-		LHA archive (c64)

0	string		C64File		PC64 Emulator file
>8	string		>\0		"%s"
0	string		C64Image	PC64 Freezer Image

0	beshort		0x38CD		C64 PCLink Image
0	string		CBM\144\0\0	Power 64 C64 Emulator Snapshot

0	belong		0xFF424CFF	WRAptor packer (c64)

0	string		C64S\x20tape\x20file	T64 tape Image
>32	leshort		x		Version:0x%x
>36	leshort		!0		Entries:%i
>40	string		x		Name:%.24s

0	string		C64\x20tape\x20image\x20file\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0	T64 tape Image
>32	leshort		x		Version:0x%x
>36	leshort		!0		Entries:%i
>40	string		x		Name:%.24s

0	string		C64S\x20tape\x20image\x20file\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0	T64 tape Image
>32	leshort		x		Version:0x%x
>36	leshort		!0		Entries:%i
>40	string		x		Name:%.24s
@


1.1.1.1
log
@from ftp.astron.com
@
text
@@


1.1.1.2
log
@from ftp.astron.com.
- many security related fixes
- no MAXPATHLEN limits
- fixed missing text specification on ascii magic
- new ``pascal'' style string formats
- whitespace comparison fix
- more magic
@
text
@a0 1

a1 1
# $File: c64,v 1.5 2009/09/19 16:28:08 christos Exp $
@


1.1.1.2.32.1
log
@Sync with HEAD
@
text
@d3 1
a3 1
# $File: c64,v 1.6 2015/08/24 05:17:42 christos Exp $
a43 6

# Raw tape file format (.tap files)
# Esa Hyyti <esa@@netlab.tkk.fi>
0	string		C64-TAPE-RAW	C64 Raw Tape File (.tap),
>0x0c	byte		x		Version:%u,
>0x10   lelong		x		Length:%u cycles
@


1.1.1.2.28.1
log
@Sync with HEAD
@
text
@d3 1
a3 1
# $File: c64,v 1.6 2015/08/24 05:17:42 christos Exp $
a43 6

# Raw tape file format (.tap files)
# Esa Hyyti <esa@@netlab.tkk.fi>
0	string		C64-TAPE-RAW	C64 Raw Tape File (.tap),
>0x0c	byte		x		Version:%u,
>0x10   lelong		x		Length:%u cycles
@


1.1.1.3
log
@2017-02-10  12:24  Christos Zoulas <christos@@zoulas.com>

	* release 5.30

2017-02-07  23:27  Christos Zoulas <christos@@zoulas.com>

	* If we exceeded the offset in a search return no match
	  (Christoph Biedl)
	* Be more lenient on corrupt CDF files (Christoph Biedl)

2017-02-04  16:46  Christos Zoulas <christos@@zoulas.com>

	* pacify ubsan sign extension (oss-fuzz/524)

2017-02-01  12:42  Christos Zoulas <christos@@zoulas.com>

	* off by one in cdf parsing (PR/593)
	* report debugging sections in elf (PR/591)

2016-11-06  10:52  Christos Zoulas <christos@@zoulas.com>

	* Allow @@@@@@ in extensions
	* Add missing overflow check in der magic (Jonas Wagner)

2016-10-25  10:40  Christos Zoulas <christos@@zoulas.com>

	* release 5.29

2016-10-24  11:20  Christos Zoulas <christos@@zoulas.com>

	* der getlength overflow (Jonas Wagner)
	* multiple magic file load failure (Christoph Biedl)

2016-10-17  11:26  Christos Zoulas <christos@@zoulas.com>

	* CDF parsing improvements (Guy Helmer)

2016-07-20   7:26  Christos Zoulas <christos@@zoulas.com>

	* Add support for signed indirect offsets

2016-07-18   7:41  Christos Zoulas <christos@@zoulas.com>

	* cat /dev/null | file - should print empty (Christoph Biedl)

2016-07-05  15:20  Christos Zoulas <christos@@zoulas.com>

	* Bump string size from 64 to 96.

2016-06-13  20:20  Christos Zoulas <christos@@zoulas.com>

	* PR/556: Fix separators on annotations.

2016-06-13  19:40  Christos Zoulas <christos@@zoulas.com>

	* release 5.28
	* fix leak on allocation failure

2016-06-01   1:20  Christos Zoulas <christos@@zoulas.com>

	* PR/555: Avoid overflow for offset > nbytes
	* PR/550: Segv on DER parsing:
	    - use the correct variable for length
	    - set offset to 0 on failure.

2016-05-13  12:00  Christos Zoulas <christos@@zoulas.com>

	* release 5.27

2016-04-18   9:35  Christos Zoulas <christos@@zoulas.com>

	* Errors comparing DER entries or computing offsets
	  are just indications of malformed non-DER files.
	  Don't print them.
	* Offset comparison was off-by-one.
	* Fix compression code (Werner Fink)
	* Put new bytes constant in the right file (not the generated one)

2016-04-16  18:34  Christos Zoulas <christos@@zoulas.com>

	* release 5.26

2016-03-31  13:50  Christos Zoulas <christos@@zoulas.com>

	* make the number of bytes read from files configurable.

2016-03-21  13:40  Christos Zoulas <christos@@zoulas.com>

	* Add bounds checks for DER code (discovered by Thomas Jarosch)
	* Change indirect recursion limit to indirect use count and
	  bump from 15 to 50 to prevent abuse.

2016-03-13  20:39  Christos Zoulas <christos@@zoulas.com>

	* Add -00 which prints filename\0description\0

2016-03-01  13:28  Christos Zoulas <christos@@zoulas.com>

	* Fix ID3 indirect parsing

2016-01-19  10:18  Christos Zoulas <christos@@zoulas.com>

	* add DER parsing capability

2015-11-13  10:35  Christos Zoulas <christos@@zoulas.com>

	* provide dprintf(3) for the OS's that don't have it.

2015-11-11  16:25  Christos Zoulas <christos@@zoulas.com>

	* redo the compression code report decompression errors

2015-11-10  23:25  Christos Zoulas <christos@@zoulas.com>

	* REG_STARTEND code is not working as expected, delete it.

2015-11-09  16:05  Christos Zoulas <christos@@zoulas.com>

	* Add zlib support if we have it.

2015-11-05  11:22  Christos Zoulas <christos@@zoulas.com>

	* PR/492: compression forking was broken with magic_buffer.

2015-09-16   9:50  Christos Zoulas <christos@@zoulas.com>

	* release 5.25

2015-09-11  13:25  Christos Zoulas <christos@@zoulas.com>

	* add a limit to the length of regex searches

2015-09-08   9:50  Christos Zoulas <christos@@zoulas.com>

	* fix problems with --parameter (Christoph Biedl)

2015-07-11  10:35  Christos Zoulas <christos@@zoulas.com>

	* Windows fixes PR/466 (Jason Hood)

2015-07-09  10:35  Christos Zoulas <christos@@zoulas.com>

	* release 5.24

2015-06-11   8:52  Christos Zoulas <christos@@zoulas.com>

	* redo long option encoding to fix off-by-one in 5.23

2015-06-10  13:50  Christos Zoulas <christos@@zoulas.com>

	* release 5.23

2015-06-09  16:10  Christos Zoulas <christos@@zoulas.com>

	* Fix issue with regex range for magic with offset
	* Always return true from mget with USE (success to mget not match
	  indication). Fixes mime evaluation after USE magic
	* PR/459: Don't insert magic entries to the list if there are parsing
	  errors for them.

2015-06-03  16:00  Christos Zoulas <christos@@zoulas.com>

	* PR/455: Add utf-7 encoding

2015-06-03  14:30  Christos Zoulas <christos@@zoulas.com>

	* PR/455: Implement -Z, look inside, but don't report on compression
	* PR/454: Fix allocation error on bad magic.

2015-05-29  10:30  Christos Zoulas <christos@@zoulas.com>

	* handle MAGIC_CONTINUE everywhere, not just in softmagic

2015-05-21  14:30  Christos Zoulas <christos@@zoulas.com>

	* don't print descriptions for NAME types when mime.

2015-04-09  15:59  Christos Zoulas <christos@@zoulas.com>

	* Add --extension to list the known extensions for this file type
	  Idea by Andrew J Roazen

2015-02-14  12:23  Christos Zoulas <christos@@zoulas.com>

	* Bump file search buffer size to 1M.

2015-01-09  14:35  Christos Zoulas <christos@@zoulas.com>

	* Fix multiple issues with date formats reported by Christoph Biedl:
		- T_LOCAL meaning was reversed
		- Arithmetic did not work
	  Also stop adjusting daylight savings for gmt printing.

2015-01-05  13:00  Christos Zoulas <christos@@zoulas.com>

	* PR/411: Fix memory corruption from corrupt cdf file.
@
text
@d3 1
a3 1
# $File: c64,v 1.6 2015/08/24 05:17:42 christos Exp $
a43 6

# Raw tape file format (.tap files)
# Esa Hyyti <esa@@netlab.tkk.fi>
0	string		C64-TAPE-RAW	C64 Raw Tape File (.tap),
>0x0c	byte		x		Version:%u,
>0x10   lelong		x		Length:%u cycles
@


1.1.1.3.10.1
log
@Sync with HEAD
@
text
@d3 1
a3 1
# $File: c64,v 1.7 2017/11/15 12:19:06 christos Exp $
d49 1
a49 10
>0x10	lelong		x		Length:%u cycles

# magic for Goattracker2, http://covertbitops.c64.org/
# from Alex Myczko <alex@@aiei.ch>
0	string		GTS5		GoatTracker 2 song
>4	string		>\0		\b, "%s"
>36	string		>\0		\b by %s
>68	string		>\0		\b (C) %s
>100	byte		>0		\b, %u subsong(s)

@


1.1.1.4
log
@2018-04-15  14:52  Christos Zoulas <christos@@zoulas.com>

	* release 5.33

2018-02-24  14:50  Christos Zoulas <christos@@zoulas.com>

	* extend the support for ${x?:} expansions for magic descriptions

2018-02-21  16:25  Christos Zoulas <christos@@zoulas.com>

	* add support for ${x?:} in mime types to handle
	  pie binaries.

2017-11-03   9:23  Christos Zoulas <christos@@zoulas.com>

	* add support for negative offsets (offsets from the end of file)

2017-09-26   8:22  Christos Zoulas <christos@@zoulas.com>

	* close the file on error when writing magic (Steve Grubb)

2017-09-24  12:02  Christos Zoulas <christos@@zoulas.com>

	* seccomp support (Paul Moore)

2017-09-02  11:53  Christos Zoulas <christos@@zoulas.com>

	* release 5.32

2017-08-28  16:37  Christos Zoulas <christos@@zoulas.com>

	* Always reset state in {file,buffer}_apprentice (Krzysztof Wilczynski)

2017-08-27  03:55  Christos Zoulas <christos@@zoulas.com>

	* Fix always true condition (Thomas Jarosch)

2017-05-24  17:30  Christos Zoulas <christos@@zoulas.com>

	* pickier parsing of numeric values in magic files.

2017-05-23  17:55  Christos Zoulas <christos@@zoulas.com>

	* PR/615 add magic_getflags()
@
text
@d3 1
a3 1
# $File: c64,v 1.7 2017/11/15 12:19:06 christos Exp $
d49 1
a49 10
>0x10	lelong		x		Length:%u cycles

# magic for Goattracker2, http://covertbitops.c64.org/
# from Alex Myczko <alex@@aiei.ch>
0	string		GTS5		GoatTracker 2 song
>4	string		>\0		\b, "%s"
>36	string		>\0		\b by %s
>68	string		>\0		\b (C) %s
>100	byte		>0		\b, %u subsong(s)

@


1.1.1.5
log
@2021-03-30  20:21  Christos Zoulas <christos@@zoulas.com>

	* release 5.40

2021-02-05  16:31  Christos Zoulas <christos@@zoulas.com>

	* PR/234: Add limit to the number of bytes to scan for encoding
	* PR/230: Fix /T (trim flag) for regex

2021-02-01  12:31  Christos Zoulas <christos@@zoulas.com>
	* PR/77: Trim trailing separator.

2020-12-17  15:44  Christos Zoulas <christos@@zoulas.com>

	* PR/211: Convert system read errors from corrupt ELF
	  files into human readable error messages

2020-12-08  16:24  Christos Zoulas <christos@@zoulas.com>

	* fix multithreaded decompression file descriptor issue
	  by using close-on-exec (Denys Vlasenko)

2020-06-27  11:58  Christos Zoulas <christos@@zoulas.com>

	* Exclude surrogate pairs from utf-8 detection (Michael Liu)

2020-06-25  12:53  Christos Zoulas <christos@@zoulas.com>

	* Include # to the list of ignored format chars (Werner Fink)
@
text
@d3 1
a3 1
# $File: c64,v 1.8 2020/12/20 16:17:43 christos Exp $
a58 5
# CBM BASIC (cc65 compiled)
0	leshort		0x0801
>2	leshort		0x080b
>6	string		\x9e		CBM BASIC
>7	string		>\0		\b, SYS %s
@


1.1.1.6
log
@Import file-5.43+; last was file-5.40

2022-09-20  17:12  Christos Zoulas <christos@@zoulas.com>

	* fixed various clustefuzz issues

2022-09-19  15:54  Christos Zoulas <christos@@zoulas.com>

	* Fix error detection for decompression code (Vincent Mihalkovic)

2022-09-15  13:50  Christos Zoulas <christos@@zoulas.com>

	* Add MAGIC_NO_COMPRESS_FORK and use it to produce a more
	  meaningful error message if we are sandboxing.

2022-09-15  10:45  Christos Zoulas <christos@@zoulas.com>

	* Add built-in lzip decompression support (Michal Gorny)

2022-09-14  10:35  Christos Zoulas <christos@@zoulas.com>

	* Add built-in zstd decompression support (Martin Rodriguez Reboredo)

2022-09-13  14:55  Christos Zoulas <christos@@zoulas.com>

	* release 5.43

2022-09-10   9:17  Christos Zoulas <christos@@zoulas.com>

	* Add octal indirect magic (Michal Gorny)

2022-08-17  11:43  Christos Zoulas <christos@@zoulas.com>

	* PR/374: avoid infinite loop in non-wide code (piru)
	* PR/373: Obey MAGIC_CONTINUE with multiple magic files (vismarli)

2022-07-26  11:10  Christos Zoulas <christos@@zoulas.com>

	* Fix bug with large flist (Florian Weimer)

2022-07-07  13:21  Christos Zoulas <christos@@zoulas.com>

        * PR/364: Detect non-nul-terminated core filenames from QEMU
	  (mam-ableton)

2022-07-04  15:45  Christos Zoulas <christos@@zoulas.com>

	* PR/359: Add support for http://ndjson.org/ (darose)
	* PR/362: Fix wide printing (ro-ee)
	* PR/358: Fix width for -f - (jpalus)
	* PR/356: Fix JSON constant parsing (davewhite)

2022-06-10   9:40  Christos Zoulas <christos@@zoulas.com>

	* release 5.42

2022-05-31  14:50   Christos Zoulas <christos@@zoulas.com>

	* PR/348: add missing cases to prevent file from aborting on
	  random magic files.

2022-05-27  21:05   Christos Zoulas <christos@@zoulas.com>

	* PR/351: octalify filenames when not raw before printing.

2022-04-18  17:51   Christos Zoulas <christos@@zoulas.com>

	* fix regex cacheing bug (Dirk Mueller)
	* merge file_regcomp and file_regerror() to simplify the code
	  and reduce memory requirements for storing regexes (Dirk Mueller)

2022-03-19  12:56   Christos Zoulas <christos@@zoulas.com>

	* cache regex (Dirk Mueller)
	* detect filesystem full by flushing output (Dirk Mueller)

2021-11-19  12:36   Christos Zoulas <christos@@zoulas.com>

	* implement running decompressor programs using
	  posix_spawnp(2) instead of vfork(2)

2021-10-24  11:51   Christos Zoulas <christos@@zoulas.com>

	* Add support for msdos dates and times

2021-10-20   9:55   Christos Zoulas <christos@@zoulas.com>

	* use the system byte swapping functions if available (Werner Fink)

2021-10-18  11:57  Christos Zoulas <christos@@zoulas.com>

	* release 5.41

2021-09-23  03:51  Christos Zoulas <christos@@zoulas.com>

	* Avinash Sonawane: Fix tzname detection

2021-09-03  09:17  Christos Zoulas <christos@@zoulas.com>

	* Fix relationship tests with "search" magic, don't short circuit
	  logic

2021-07-13  01:06  Christos Zoulas <christos@@zoulas.com>

	* Fix memory leak in compile mode

2021-07-01  03:51  Christos Zoulas <christos@@zoulas.com>

	* PR/272: kiefermat: Only set returnval = 1 when we printed something
	  (in all cases print or !print). This simplifies the logic and fixes
	  the issue in the PR with -k and --mime-type there was no continuation
	  printed before the default case.

2021-06-30  13:07  Christos Zoulas <christos@@zoulas.com>

	* PR/270: Don't translate unprintable characters in %s magic formats
	  when -r
	* PR/269: Avoid undefined behavior with clang (adding offset to NULL)

2021-05-09  18:38  Christos Zoulas <christos@@zoulas.com>

	* Add a new flag (f) that requires that the match is a full word,
	   not a partial word match.
	* Add varint types (unused)

2021-04-19  17:17  Christos Zoulas <christos@@zoulas.com>

	* PR/256: mutableVoid: If the file is less than 3 bytes, use the file
	  length to determine type
	* PR/259: aleksandr.v.novichkov: mime printing through indirect magic
	  is not taken into account, use match directly so that it does.

2021-04-04  17:02  Christos Zoulas <christos@@zoulas.com>

	* count the total bytes found not the total byte positions
	  in order to determine encoding (Anatol Belski)
@
text
@d3 1
a3 1
# $File: c64,v 1.12 2022/05/14 20:03:39 christos Exp $
d11 1
a13 138
# C64 (and other CBM) cartridges
# Extended by David Korth <gerbilsoft@@gerbilsoft.com>
# Reference: https://vice-emu.sourceforge.io/vice_17.html#SEC391

0	string		C64\40CARTRIDGE	Commodore 64 cartridge
>0x20	ubyte	0	\b,
>0x20	ubyte	!0
>>0x20	string/T	x	\b: "%.32s",
>0x16	beshort	0
>>0x18	beshort	0x0000	16 KB game
>>0x18	beshort	0x0001	8 KB game
>>0x18	beshort	0x0100	UltiMax mode
>>0x18	beshort	0x0101	RAM/disabled
>0x16	beshort	1	Action Replay
>0x16	beshort	2	KCS Power Cartridge
>0x16	beshort	3	Final Cartridge III
>0x16	beshort	4	Simons' BASIC
>0x16	beshort	5	Ocean type 1
>0x16	beshort	6	Expert Cartridge
>0x16	beshort	7	Fun Play, Power Play
>0x16	beshort	8	Super Games
>0x16	beshort	9	Atomic Power
>0x16	beshort	10	Epyx Fastload
>0x16	beshort	11	Westermann Learning
>0x16	beshort	12	Rex Utility
>0x16	beshort	13	Final Cartridge I
>0x16	beshort	14	Magic Formel
>0x16	beshort	15	C64 Game System, System 3
>0x16	beshort	16	Warp Speed
>0x16	beshort	17	Dinamic
>0x16	beshort	18	Zaxxon / Super Zaxxon (Sega)
>0x16	beshort	19	Magic Desk, Domark, HES Australia
>0x16	beshort	20	Super Snapshot V5
>0x16	beshort	21	Comal-80
>0x16	beshort	22	Structured BASIC
>0x16	beshort	23	Ross
>0x16	beshort	24	Dela EP64
>0x16	beshort	25	Dela EP7x8
>0x16	beshort	26	Dela EP256
>0x16	beshort	27	Rex EP256
>0x16	beshort	28	Mikro Assembler
>0x16	beshort	29	Final Cartridge Plus
>0x16	beshort	30	Action Replay 4
>0x16	beshort	31	Stardos
>0x16	beshort	32	EasyFlash
>0x16	beshort	33	EasyFlash Xbank
>0x16	beshort	34	Capture
>0x16	beshort	35	Action Replay 3
>0x16	beshort	36
>>0x1A	ubyte	1	Nordic Replay
>>0x1A	ubyte	!1	Retro Replay
>0x16	beshort	37	MMC64
>0x16	beshort	38	MMC Replay
>0x16	beshort	39	IDE64
>0x16	beshort	40	Super Snapshot V4
>0x16	beshort	41	IEEE-488
>0x16	beshort	42	Game Killer
>0x16	beshort	43	Prophet64
>0x16	beshort	44	EXOS
>0x16	beshort	45	Freeze Frame
>0x16	beshort	46	Freeze Machine
>0x16	beshort	47	Snapshot64
>0x16	beshort	48	Super Explode V5.0
>0x16	beshort	49	Magic Voice
>0x16	beshort	50	Action Replay 2
>0x16	beshort	51	MACH 5
>0x16	beshort	52	Diashow-Maker
>0x16	beshort	53	Pagefox
>0x16	beshort	54	Kingsoft
>0x16	beshort	55	Silverrock 128K Cartridge
>0x16	beshort	56	Formel 64
>0x16	beshort	57
>>0x1A	ubyte	1	Hucky
>>0x1A	ubyte	!1	RGCD
>0x16	beshort	58	RR-Net MK3
>0x16	beshort	59	EasyCalc
>0x16	beshort	60	GMod2
>0x16	beshort	61	MAX Basic
>0x16	beshort	62	GMod3
>0x16	beshort	63	ZIPP-CODE 48
>0x16	beshort	64	Blackbox V8
>0x16	beshort	65	Blackbox V3
>0x16	beshort	66	Blackbox V4
>0x16	beshort	67	REX RAM-Floppy
>0x16	beshort	68	BIS-Plus
>0x16	beshort	69	SD-BOX
>0x16	beshort	70	MultiMAX
>0x16	beshort	71	Blackbox V9
>0x16	beshort	72	Lt. Kernal Host Adaptor
>0x16	beshort	73	RAMLink
>0x16	beshort	74	H.E.R.O.
>0x16	beshort	75	IEEE Flash! 64
>0x16	beshort	76	Turtle Graphics II
>0x16	beshort	77	Freeze Frame MK2

0	string		C128\40CARTRIDGE	Commodore 128 cartridge
>0x20	ubyte	0	\b,
>0x20	ubyte	!0
>>0x20	string/T	x	\b: "%.32s",
>0x16	beshort	0	generic cartridge
>0x16	beshort	1	Warpspeed128
>>0x1A	ubyte	1	\b, REU support
>>0x1A	ubyte	2	\b, REU support, with I/O and ROM banking

0	string		CBM2\40CARTRIDGE	Commodore CBM-II cartridge
>0x20	ubyte	!0
>>0x20	string/T	x	\b: "%.32s"

0	string		VIC20\40CARTRIDGE	Commodore VIC-20 cartridge
>0x20	ubyte	0	\b,
>0x20	ubyte	!0
>>0x20	string/T	x	\b: "%.32s",
>0x16	beshort	0	generic cartridge
>0x16	beshort	1	Mega-Cart
>0x16	beshort	2	Behr Bonz
>0x16	beshort	3	Vic Flash Plugin
>0x16	beshort	4	UltiMem
>0x16	beshort	5	Final Expansion

0	string		PLUS4\40CARTRIDGE	Commodore 16/Plus4 cartridge
>0x20	ubyte	!0
>>0x20	string/T	x	\b: "%.32s"


# DreamLoad archives see:
# https://www.lemon64.com/forum/viewtopic.php?t=37415\
# &sid=494dc2ca91289e05dadf80a7f8a968fe (at the bottom).
# https://www.c64-wiki.com/wiki/DreamLoad.
# Example HVSC Commodore 64 music collection:
# https://kohina.duckdns.org/HVSC/C64Music/10_Years_HVSC.dfi

0	byte	0
>1	string	DREAMLOAD\40FILE\40ARCHIVE
>>0x17	byte	0	DFI Image
>>>0x1a	leshort	x	version: %d.
>>>0x18	leshort	x	\b%d
>>>0x1c	lelong	x	tracks: %d

d31 1
a31 1
>32	leshort		x		Version:%#x
d36 1
a36 1
>32	leshort		x		Version:%#x
d41 1
a41 1
>32	leshort		x		Version:%#x
@


1.1.1.7
log
@Update to file-5.45 (Last was file-5.44)

2023-07-27  15:45  Christos Zoulas <christos@@zoulas.com>

	* release 5.45

2023-07-17  11:53  Christos Zoulas <christos@@zoulas.com>

	* PR/465: psrok1: Avoid muslc asctime_r crash

2023-05-21  13:05  Christos Zoulas <christos@@zoulas.com>

	* add SIMH tape format support

2023-02-09  12:50  Christos Zoulas <christos@@zoulas.com>

	* bump the max size of the elf section notes to be read to 128K
	  and make it configurable

2023-01-08   1:08  Christos Zoulas <christos@@zoulas.com>

	* PR/415: Fix decompression with program returning empty

2022-12-26   1:47  Christos Zoulas <christos@@zoulas.com>

	* PR/408: fix -p with seccomp
	* PR/412: fix MinGW compilation
@
text
@d3 1
a3 1
# $File: c64,v 1.14 2023/06/16 19:24:06 christos Exp $
a196 8
# Summary:	binary executable or Basic program for Commodore C64 computers
# Update:	Joerg Jenderek
# URL:		http://fileformats.archiveteam.org/wiki/Commodore_BASIC_tokenized_file
# Reference:	https://www.c64-wiki.com/wiki/BASIC_token
#		https://github.com/thezerobit/bastext/blob/master/bastext.doc
#		http://mark0.net/download/triddefs_xml.7z/defs/p/prg-c64.trid.xml
# TODO:		unify Commodore BASIC/program sub routines
# Note:		"PUCrunch archive data" moved from ./archive and merged with c64-exe
d198 3
a200 344
# display Commodore C64 BASIC program (strength=50) after "Lynx archive" (strength=330) handled by ./archive
#!:strength +0
# if first token is not SYS this implies BASIC program in most cases
>6		ubyte		!0x9e
# but sELF-ExTRACTING-zIP executable unzp6420.prg contains SYS token at end of second BASIC line (at 0x35)
>>23		search/30	\323ELF-E\330TRACTING-\332IP
>>>0		use		c64-exe
>>23		default		x
>>>0		use		c64-prg
# if first token is SYS this implies binary executable
>6		ubyte		=0x9e
>>0		use		c64-exe
# display information about C64 binary executable (memory address, line number, token)
0	name	c64-exe
>0		uleshort	x	Commodore C64
# http://a1bert.kapsi.fi/Dev/pucrunch/
# start address 0801h; next offset 080bh; BASIC line number is 239=00EFh; BASIC instruction is SYS 2061
# the above combination appartly also occur for other Commodore programs like: gunzip111.c64.prg
# and there exist PUCrunch archive for other machines like C16 with other magics
>0		string	\x01\x08\x0b\x08\xef\x00\x9e\x32\x30\x36\x31	program, probably PUCrunch archive data
!:mime	application/x-compress-pucrunch
!:ext	prg/pck
>0		string	!\x01\x08\x0b\x08\xef\x00\x9e\x32\x30\x36\x31	program
!:mime	application/x-commodore-exec
!:ext	prg/
# start address like: 801h
>0		uleshort	!0x0801	\b, start address %#4.4x
# 1st BASIC fragment
>2		use		basic-line
# jump to 1 byte before next BASIC fragment; this must be zero-byte marking the end of line
>(2.s-0x800)	ubyte		x
>>&-1		ubyte		!0	\b, no EOL=%#x
# valid 2nd BASIC fragment found only in sELF-ExTRACTING-zIP executable unzp6420.prg
>>23		search/30	\323ELF-E\330TRACTING-\332IP
# jump again from beginning
>>>(2.s-0x800)	ubyte		x
>>>>&0		use		basic-line
# Zero-byte marking the end of the BASIC line
>-3		ubyte		!0	\b, 3 last bytes %#2.2x
# Two zero-bytes in place of the pointer to next BASIC line indicates the end of the program
>>-2		ubeshort	x	\b%4.4x
# display information about tokenized C64 BASIC program (memory address, line number, token)
0	name	c64-prg
>0		uleshort	x	Commodore C64 BASIC program
!:mime	application/x-commodore-basic
# Tokenized BASIC programs were stored by Commodore as file type program "PRG" in separate field in directory structures.
# So file name can have no suffix like in saveroms; When transferring to other platforms, they are often saved with .prg extensions.
# BAS suffix is typically used for the BASIC source but also found in program pods.bas
!:ext	prg/bas/
# start address like: 801h
>0		uleshort	!0x0801	\b, start address %#4.4x
# 1st BASIC fragment
>2		use		basic-line
# jump to 1 byte before next BASIC fragment; this must be zero-byte marking the end of line
>(2.s-0x0800)	ubyte		x	
>>&-1		ubyte		!0	\b, no EOL=%#x
# 2nd BASIC fragment
>>&0		use		basic-line
# zero-byte marking the end of the BASIC line
>-3		ubyte		!0	\b, 3 last bytes %#2.2x
# Two zero-bytes in place of the pointer to next BASIC line indicates the end of the program
>>-2		ubeshort	x	\b%4.4x
# Summary:	binary executable or Basic program for Commodore C128 computers
# URL:		https://en.wikipedia.org/wiki/Commodore_128
# Reference:	http://mark0.net/download/triddefs_xml.7z/defs/p/prg-c128.trid.xml
# From:		Joerg Jenderek
# Note:		Commodore 128 BASIC 7.0 variant; there exist varaints with different start addresses
0		leshort		0x1C01
!:strength	+1
# GRR: line above with strength 51 (50+1) is too generic because it matches SVr3 curses screen image, big-endian with strength (50) handled by ./terminfo
# probably skip SVr3 curses images with "invalid high" second line offset 
>2		uleshort	<0x1D02
# skip foo with "invalid low" second line offset
>>2		uleshort	>0x1C06
# if first token is not SYS this implies BASIC program
>>>6		ubyte		!0x9e
>>>>0			use	c128-prg
# if first token is SYS this implies binary executable
>>>6		ubyte		=0x9e
>>>>0		use		c128-exe
# Summary:	binary executable or Basic program for Commodore C128 computers
# Note:		Commodore 128 BASIC 7.1 extension by Rick Simon
# start adress 132Dh
#0		leshort		0x132D	THIS_IS_C128_7.1
#>0			use	c128-prg
# Summary:	binary executable or Basic program for Commodore C128 computers
# Note:		Commodore 128 BASIC 7.0 saved with graphics mode enabled
# start adress 4001h
#0		leshort		0x4001	THIS_IS_C128_GRAPHIC
#>0			use	c128-prg
# display information about tokenized C128 BASIC program (memory address, line number, token)
0	name	c128-prg
>0		uleshort	x	Commodore C128 BASIC program
!:mime	application/x-commodore-basic
!:ext	prg
# start address like: 1C01h
>0		uleshort	!0x1C01	\b, start address %#4.4x
# 1st BASIC fragment
>2		use		basic-line
# jump to 1 byte before next BASIC fragment; this must be zero-byte marking the end of line
>(2.s-0x1C00)	ubyte		x
>>&-1		ubyte		!0	\b, no EOL=%#x
# 2nd BASIC fragment
>>&0		use		basic-line
# Zero-byte marking the end of the BASIC line
>-3		ubyte		!0	\b, 3 last bytes %#2.2x
# Two zero-bytes in place of the pointer to next BASIC line indicates the end of the program
>>-2		ubeshort	x	\b%4.4x
# display information about C128 program (memory address, line number, token)
0	name	c128-exe
>0		uleshort	x	Commodore C128 program
!:mime	application/x-commodore-exec
!:ext	prg/
# start address like: 1C01h
>0		uleshort	!0x1C01	\b, start address %#4.4x
# 1st BASIC fragment
>2		use		basic-line
# jump to 1 byte before next BASIC fragment; this must be zero-byte marking the end of line
>(2.s-0x1C00)	ubyte		x
>>&-1		ubyte		!0	\b, no EOL=%#x
# no valid 2nd BASIC fragment in Commodore executables
#>>&0		use		basic-line
# Zero-byte marking the end of the BASIC line
>-3		ubyte		!0	\b, 3 last bytes %#2.2x
# Two zero-bytes in place of the pointer to next BASIC line indicates the end of the program
>>-2		ubeshort	x	\b%4.4x
# Summary:	binary executable or Basic program for Commodore C16/VIC-20/Plus4 computers
# URL:		https://en.wikipedia.org/wiki/Commodore_Plus/4
# Reference:	http://mark0.net/download/triddefs_xml.7z/defs/p/prg-vic20.trid.xml
#		defs/p/prg-plus4.trid.xml
# From:		Joerg Jenderek
# Note:		there exist VIC-20 variants with different start address
# GRR: line below is too generic because it matches Novell LANalyzer capture
# with regular trace header record handled by ./sniffer
0		leshort		0x1001
# skip regular Novell LANalyzer capture (novell-2.tr1 novell-lanalyzer.tr1 novell-win10.tr1) with "invalid low" token value 54h
>6		ubyte		>0x7F
# skip regular Novell LANalyzer capture (novell-2.tr1 novell-lanalyzer.tr1 novell-win10.tr1) with "invalid low" second line offset 4Ch
#>>2		uleshort	>0x1006	OFFSET_NOT_TOO_LOW
# skip foo with "invalid high" second line offset but not for 0x123b (Minefield.prg)
#>>>2		uleshort	<0x1102	OFFSET_NOT_TOO_HIGH
# if first token is not SYS this implies BASIC program
>>6		ubyte		!0x9e
# valid second end of line separator implies BASIC program
>>>(2.s-0x1000)		ubyte	=0
>>>>0			use	c16-prg
# invalid second end of line separator !=0 implies binary executable like: Minefield.prg
>>>(2.s-0x1000)		ubyte	!0
>>>>0			use	c16-exe
# if first token is SYS this implies binary executable
>>6		ubyte		=0x9e
>>>0		use		c16-exe
# display information about C16 program (memory address, line number, token)
0	name	c16-exe
>0		uleshort	x	Commodore C16/VIC-20/Plus4 program
!:mime	application/x-commodore-exec
!:ext	prg/
# start address like: 1001h
>0		uleshort	!0x1001	\b, start address %#4.4x
# 1st BASIC fragment
>2		use		basic-line
# jump to 1 byte before next BASIC fragment; this must be zero-byte marking the end of line
>(2.s-0x1000)	ubyte		x
>>&-1		ubyte		!0	\b, no EOL=%#x
# no valid 2nd BASIC fragment in excutables
#>>&0		use		basic-line
# Zero-byte marking the end of the BASIC line
>-3		ubyte		!0	\b, 3 last bytes %#2.2x
# Two zero-bytes in place of the pointer to next BASIC line indicates the end of the program
>>-2		ubeshort	x	\b%4.4x
# display information about tokenized C16 BASIC program (memory address, line number, token)
0	name	c16-prg
>0		uleshort	x	Commodore C16/VIC-20/Plus4 BASIC program
!:mime	application/x-commodore-basic
!:ext	prg
# start address like: 1001h
>0		uleshort	!0x1001	\b, start address %#4.4x
# 1st BASIC fragment
>2		use		basic-line
# jump to 1 byte before next BASIC fragment; this must be zero-byte marking the end of line
>(2.s-0x1000)	ubyte		x
>>&-1		ubyte		!0	\b, no EOL=%#x
# 2nd BASIC fragment
>>&0		use		basic-line
# Zero-byte marking the end of the BASIC line
>-3		ubyte		!0	\b, 3 last bytes %#2.2x
# Two zero-bytes in place of the pointer to next BASIC line indicates the end of the program
>>-2		ubeshort	x	\b%4.4x
# Summary:	binary executable or Basic program for Commodore VIC-20 computer with 8K RAM expansion
# URL:		https://en.wikipedia.org/wiki/VIC-20
# Reference:	http://mark0.net/download/triddefs_xml.7z/defs/p/prg-vic20-8k.trid.xml
# From:		Joerg Jenderek
# Note:		Basic v2.0 with Basic v4.0 extension (VIC20); there exist VIC-20 variants with different start addresses
# start adress 1201h
0		leshort		0x1201
# if first token is not SYS this implies BASIC program
>6		ubyte		!0x9e
>>0		use		vic-prg
# if first token is SYS this implies binary executable
>6		ubyte		=0x9e
>>0		use		vic-exe
# display information about Commodore VIC-20 BASIC+8K program (memory address, line number, token)
0	name	vic-prg
>0		uleshort	x	Commodore VIC-20 +8K BASIC program
!:mime	application/x-commodore-basic
!:ext	prg
# start address like: 1201h
>0		uleshort	!0x1201	\b, start address %#4.4x
# 1st BASIC fragment
>2		use		basic-line
# jump to 1 byte before next BASIC fragment; this must be zero-byte marking the end of line
>(2.s-0x1200)	ubyte		x
>>&-1		ubyte		!0	\b, no EOL=%#x
# 2nd BASIC fragment
>>&0		use		basic-line
# Zero-byte marking the end of the BASIC line
>-3		ubyte		!0	\b, 3 last bytes %#2.2x
# Two zero-bytes in place of the pointer to next BASIC line indicates the end of the program
>>-2		ubeshort	x	\b%4.4x
# display information about Commodore VIC-20 +8K program (memory address, line number, token)
0	name	vic-exe
>0		uleshort	x	Commodore VIC-20 +8K program
!:mime	application/x-commodore-exec
!:ext	prg/
# start address like: 1201h
>0		uleshort	!0x1201	\b, start address %#4.4x
# 1st BASIC fragment
>2		use		basic-line
# jump to 1 byte before next BASIC fragment; this must be zero-byte marking the end of line
>(2.s-0x0400)	ubyte		x
>>&-1		ubyte		!0	\b, no EOL=%#x
# no valid 2nd BASIC fragment in excutables
#>>&0		use		basic-line
# Zero-byte marking the end of the BASIC line
>-3		ubyte		!0	\b, 3 last bytes %#2.2x
# Two zero-bytes in place of the pointer to next BASIC line indicates the end of the program
>>-2		ubeshort	x	\b%4.4x
# Summary:	binary executable or Basic program for Commodore PET computers
# URL:		https://en.wikipedia.org/wiki/Commodore_PET
# Reference:	http://mark0.net/download/triddefs_xml.7z/defs/p/prg-pet.trid.xml
# From:		Joerg Jenderek
# start adress 0401h
0		leshort		0x0401
!:strength	+1
# GRR: line above with strength 51 (50+1) is too generic because it matches TTComp archive data, ASCII, 1K dictionary
# (strength=48=50-2) handled by ./archive and shared library (strength=50) handled by ./ibm6000
# skip TTComp archive data, ASCII, 1K dictionary ttcomp-ascii-1k.bin with "invalid high" second line offset 4162h
>2		uleshort	<0x0502
# skip foo with "invalid low" second line offset
#>>2		uleshort	>0x0406	OFFSET_NOT_TOO_LOW
# skip bar with "invalid end of line" 
#>>>(2.s-0x0400)	ubyte		=0	END_OF_LINE_OK
# if first token is not SYS this implies BASIC program
>>6		ubyte		!0x9e
>>>0		use		pet-prg
# if first token is SYS this implies binary executable
>>6		ubyte		=0x9e
>>>0		use		pet-exe
# display information about Commodore PET BASIC program (memory address, line number, token)
0	name	pet-prg
>0		uleshort	x	Commodore PET BASIC program
!:mime	application/x-commodore-basic
!:ext	prg
# start address like: 0401h
>0		uleshort	!0x0401	\b, start address %#4.4x
# 1st BASIC fragment
>2		use		basic-line
# jump to 1 byte before next BASIC fragment; this must be zero-byte marking the end of line
>(2.s-0x0400)	ubyte		x
# 2nd BASIC fragment
>>&0		use		basic-line
# zero-byte marking the end of the BASIC line
>-3		ubyte		!0	\b, 3 last bytes %#2.2x
# Two zero-bytes in place of the pointer to next BASIC line indicates the end of the program
>>-2		ubeshort	x	\b%4.4x
# display information about Commodore PET program (memory address, line number, token)
0	name	pet-exe
>0		uleshort	x	Commodore PET program
!:mime	application/x-commodore-exec
!:ext	prg/
# start address like: 0401h
>0		uleshort	!0x0401	\b, start address %#4.4x
# 1st BASIC fragment
>2		use		basic-line
# jump to 1 byte before next BASIC fragment; this must be zero-byte marking the end of line
>(2.s-0x0400)	ubyte		x
>>&-1		ubyte		!0	\b, no EOL=%#x
# no valid 2nd BASIC fragment in excutables
#>>&0		use		basic-line
# Zero-byte marking the end of the BASIC line
>-3		ubyte		!0	\b, 3 last bytes %#2.2x
# Two zero-bytes in place of the pointer to next BASIC line indicates the end of the program
>>-2		ubeshort	x	\b%4.4x
# display information about tokenized BASIC line (memory address, line number, Token)
0	name	basic-line
# pointer to memory address of beginning of "next" BASIC line
# greater then previous offset but maximal 100h difference
>0		uleshort	x	\b, offset %#4.4x
# offset 0x0000 indicates the end of BASIC program; so bytes afterwards may be some other data
>0		uleshort	0
# not line number but first 2 data bytes 
>>2		ubeshort	x	\b, data %#4.4x
# not token but next 2 data bytes 
>>4		ubeshort	x	\b%4.4x
# not token arguments but next data bytes 
>>6		ubequad		x 	\b%16.16llx
>>14		ubequad		x 	\b%16.16llx...
# like 0x0d20352020204c594e5820495820204259205749 "\r 5   LYNX IX  BY WILL CORLEY" for LyNX archive Darkon.lnx handled by ./archive
#>>3		string		x 	"%-0.30s"
>0		uleshort	>0
# BASIC line number with range from 0 to 65520; practice to increment numbers by some value (5, 10 or 100)
>>2		uleshort	x	\b, line %u
# https://www.c64-wiki.com/wiki/BASIC_token
# The "high-bit" bytes from #128-#254 stood for the various BASIC commands and mathematical operators
>>4		ubyte		x	\b, token (%#x)
# https://www.c64-wiki.com/wiki/REM
>>4		string		\x8f	REM
# remark string like: ** SYNTHESIZER BY RICOCHET **
>>>5		string		>\0	%s
#>>>>&1		uleshort	x	\b, NEXT OFFSET %#4.4x
# https://www.c64-wiki.com/wiki/PRINT
>>4		string		\x99	PRINT
# string like: "Hello world" "\021 \323ELF-E\330TRACTING-\332IP (64 ONLY)\016\231":\2362141
>>>5		string		x	%s
#>>>>&0		ubequad		x	AFTER_PRINT=%#16.16llx
# https://www.c64-wiki.com/wiki/POKE
>>4		string		\x97	POKE
# <Memory address>,<number>
>>>5		regex		\^[0-9,\040]+	%s
# BASIC command delimiter colon (:=3Ah)
>>>>&-2		ubyte		=0x3A
# after BASIC command delimiter colon remaining (<255) other tokenized BASIC commands
>>>>>&0		string		x		"%s"
# https://www.c64-wiki.com/wiki/SYS	0x9e=\236
>>4		string		\x9e	SYS
# SYS <Address> parameter is a 16-bit unsigned integer; in the range 0 - 65535
>>>5		regex		\^[0-9]{1,5}	%s
# maybe followed by spaces, "control-characters" or colon (:) followed by next commnds or in victracker.prg
# (\302(43)\252256\254\302(44)\25236) /T.L.R/
#>>>5		string		x	SYS_STRING="%s"
# https://www.c64-wiki.com/wiki/GOSUB
>>4		string		\x8d	GOSUB
# <line>
>>>5		string		>\0	%s
@


1.1.1.1.2.1
log
@file c64 was added on branch jym-xensuspend on 2009-05-13 18:51:55 +0000
@
text
@d1 41
@


1.1.1.1.2.2
log
@Sync with HEAD.

Second commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
@
text
@a0 41
#------------------------------------------------------------------------------
# c64:  file(1) magic for various commodore 64 related files
#
# From: Dirk Jagdmann <doj@@cubic.org>

0x16500	belong		0x12014100	D64 Image
0x16500	belong		0x12014180	D71 Image
0x61800 belong		0x28034400	D81 Image
0	string		C64\40CARTRIDGE	CCS C64 Emultar Cartridge Image
0	belong		0x43154164	X64 Image

0	string		GCR-1541	GCR Image
>8	byte		x		version: %i
>9	byte		x		tracks: %i

9	string		PSUR		ARC archive (c64)
2	string		-LH1-		LHA archive (c64)

0	string		C64File		PC64 Emulator file
>8	string		>\0		"%s"
0	string		C64Image	PC64 Freezer Image

0	beshort		0x38CD		C64 PCLink Image
0	string		CBM\144\0\0	Power 64 C64 Emulator Snapshot

0	belong		0xFF424CFF	WRAptor packer (c64)

0	string		C64S\x20tape\x20file	T64 tape Image
>32	leshort		x		Version:0x%x
>36	leshort		!0		Entries:%i
>40	string		x		Name:%.24s

0	string		C64\x20tape\x20image\x20file\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0	T64 tape Image
>32	leshort		x		Version:0x%x
>36	leshort		!0		Entries:%i
>40	string		x		Name:%.24s

0	string		C64S\x20tape\x20image\x20file\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0	T64 tape Image
>32	leshort		x		Version:0x%x
>36	leshort		!0		Entries:%i
>40	string		x		Name:%.24s
@


