head	1.1;
branch	1.1.1;
access;
symbols
	perseant-exfatfs:1.1.1.1.0.2
	perseant-exfatfs-base-20261102:1.1.1.1
	FILE5_48:1.1.1.1
	CHRISTOS:1.1.1;
locks; strict;
comment	@# @;


1.1
date	2026.06.10.15.59.14;	author christos;	state Exp;
branches
	1.1.1.1;
next	;
commitid	3UWc0DrzTz7bHgJG;

1.1.1.1
date	2026.06.10.15.59.14;	author christos;	state Exp;
branches
	1.1.1.1.2.1;
next	;
commitid	3UWc0DrzTz7bHgJG;

1.1.1.1.2.1
date	2026.06.10.15.59.14;	author perseant;	state dead;
branches;
next	1.1.1.1.2.2;
commitid	3QTNojfCEH9lUb2H;

1.1.1.1.2.2
date	2026.11.04.22.37.44;	author perseant;	state Exp;
branches;
next	;
commitid	3QTNojfCEH9lUb2H;


desc
@@


1.1
log
@Initial revision
@
text
@
#------------------------------------------------------------------------------
# $File: r,v 1.1 2025/02/10 17:48:42 christos Exp $
#    file(1) magic for R's RDS and RData file formats
#    Copyright (C) 2025 Gert Hulselmans <hulselmansgert@@gmail.com>
#
#    URLS:
#      https://cran.r-project.org/doc/manuals/r-release/R-ints.html#Serialization-Formats
#      https://rdata.readthedocs.io/en/latest/_modules/rdata/parser/_parser.html
#
#    Example files:
#      https://github.com/vnmabus/rdata/tree/develop/rdata/tests/data
#
###############################################################################


###############################################################################
# RDS format
###############################################################################

0	name	RDS
# Check for RDS ASCII formats.
>0	string	A\n2\n	R RDS (ASCII format v2)
>0	string	A\n3\n	R RDS (ASCII format v3)
>0	string	A\r\n2\r\n	R RDS (ASCII CRLF format v2)
>0	string	A\r\n3\r\n	R RDS (ASCII CRLF format v3)
# Check for RDS binary formats with native word order.
>0	string	B\n\0\0\0	R RDS (Native (big-endian) word order format
>>0	use RDS_binary_version_info
>0	string	B\n\2\0\0	R RDS (Native (little-endian) word order format
>>0	use ^RDS_binary_version_info
>0	string	B\n\3\0\0	R RDS (Native (little-endian) word order format
>>0	use ^RDS_binary_version_info
# Check for RDS XDR binary save format.
>0	string	X\n\0\0\0	R RDS (XDR binary save format
>>0	use RDS_binary_version_info


# Parse version numbers from RDS if it was one of the binary versions.
0	name	RDS_binary_version_info
>2	belong	>-1	v%d)
>6	beshort	>-1	\b, written by R v%d.
>8	byte	>-1	\b%d.
>9	byte	>-1	\b%d
>10	beshort	>-1	\b, readable from R v%d.
>12	byte	>-1	\b%d.
>13	byte	>-1	\b%d
>2	belong	>2
>>14	pstring/L	x	\b, %s encoded


# Check if file is one of the RDS ASCII formats.
0	string	A
>0	use RDS	not_printed
!:ext	rds

# Check if file is RDS binary native format.
0	string	B
>0	use RDS	not_printed
!:ext	rds

# Check if file is RDS XDR binary save format.
0	string	X
>0	use RDS	not_printed
!:ext	rds


###############################################################################
# RData file formats: magic bytes followed by RDS container.
###############################################################################

0	string	RDA2\n	R RData version 2 (ASCII),
!:ext	rda/rdata
>5	use	RDS

0	string	RDA3\n	R RData version 3 (ASCII),
!:ext	rda/rdata
>5	use	RDS

0	string	RDX2\n	R RData version 2 (binary),
!:ext	rda/rdata
>5	use	RDS

0	string	RDX3\n	R RData version 3 (binary),
!:ext	rda/rdata
>5	use	RDS
@


1.1.1.1
log
@Import file-5.48 (previous was file-5.45)

2026-05-07  11:32  Christos Zoulas <christos@@zoulas.com>

	* release 5.48

2026-05-11  15:55 Christos Zoulas <christos@@zoulas.com>

	* add landlock support (valoq)

2026-04-19  15:55 Christos Zoulas <christos@@zoulas.com>

	* add BE/LE GUID

2026-04-17  11:05 Christos Zoulas <christos@@zoulas.com>

	* multiple fixes to prevent integer overflow in 32 bits (kerwin)

2026-04-15  12:40 Christos Zoulas <christos@@zoulas.com>

	* PR/745: streamout: Don't flush when trying to set negative offsets
	          on pipes, just continue, fixes 'cat file.zip | file -'
	* PR/753: vmihalko: Fix race is magic_getpath()

2026-03-11  15:14 Christos Zoulas <christos@@zoulas.com>

	* PR/728: Anton Monroe: Reinstate regex/c

2026-02-26  11:32  Christos Zoulas <christos@@zoulas.com>

	* release 5.47

2026-02-04  09:54  Christos Zoulas <christos@@zoulas.com>
	* Better multi-compound document identification by following the
	  order of the directories entries. (Thomas Ledoux)

2026-01-19  14:00  Christos Zoulas <christos@@zoulas.com>
	* if stat fails, don't attempt to restore times (Steven Grubb)

2025-05-28  15:20  Christos Zoulas <christos@@zoulas.com>

	* PR/622: Odd_Bloke: Handle negative offsets in file_buffer(),
	  when fd is not available.

2025-05-28  12:50  Christos Zoulas <christos@@zoulas.com>

	* PR/655: jsummers: Obey str_flags in strings like we do for search
	  and regex
	* PR/659: Pitzl: Apply MAGIC_CONTINUE to annotations; i.e. print
	  only the first, unless -k is specified.

2024-12-19  14:44  Christos Zoulas <christos@@zoulas.com>

	* PR/592: allow + in format strings
	* PR/592: signed operations should be done in signed context

2024-12-05  13:50 Christos Zoulas <christos@@zoulas.com>

	* PR/578: jsummers: Don't crash on cygwin when tm_mon == -1
	* PR/579: net147: Fix stack overrun.

2024-11-27  14:44  Christos Zoulas <christos@@zoulas.com>

	* release 5.46
	* Add OFFPOSITIVE

2024-11-25  13:56  Christos Zoulas <christos@@zoulas.com>

	* avoid leaking symbols in libmagic

2024-11-10  13:56  Christos Zoulas <christos@@zoulas.com>

	* PR/562: jsummers: Search/regex offsets are absolute to the
	  beginning of the file, so adjust them by subtracting the
	  offset that the "use" starts so that we don't double-count it.


2024-11-09  19:30  Christos Zoulas <christos@@zoulas.com>
 	* PR/543: matshch: bump nbuf so we can get the flags into the buffer.


2024-11-02  14:34  Christos Zoulas <christos@@zoulas.com>

 	* Add Android elf notes (enh)

2023-12-29  12:55  Christos Zoulas <christos@@zoulas.com>

	* Add limit for number of magic warnings allowed

2023-07-29  12:55  Christos Zoulas <christos@@zoulas.com>

	* check regex bounds (found by clusterfuzz)
@
text
@@


1.1.1.1.2.1
log
@file r was added on branch perseant-exfatfs on 2026-11-04 22:37:44 +0000
@
text
@d1 86
@


1.1.1.1.2.2
log
@Sync with HEAD
@
text
@a0 86

#------------------------------------------------------------------------------
# $File: r,v 1.1 2025/02/10 17:48:42 christos Exp $
#    file(1) magic for R's RDS and RData file formats
#    Copyright (C) 2025 Gert Hulselmans <hulselmansgert@@gmail.com>
#
#    URLS:
#      https://cran.r-project.org/doc/manuals/r-release/R-ints.html#Serialization-Formats
#      https://rdata.readthedocs.io/en/latest/_modules/rdata/parser/_parser.html
#
#    Example files:
#      https://github.com/vnmabus/rdata/tree/develop/rdata/tests/data
#
###############################################################################


###############################################################################
# RDS format
###############################################################################

0	name	RDS
# Check for RDS ASCII formats.
>0	string	A\n2\n	R RDS (ASCII format v2)
>0	string	A\n3\n	R RDS (ASCII format v3)
>0	string	A\r\n2\r\n	R RDS (ASCII CRLF format v2)
>0	string	A\r\n3\r\n	R RDS (ASCII CRLF format v3)
# Check for RDS binary formats with native word order.
>0	string	B\n\0\0\0	R RDS (Native (big-endian) word order format
>>0	use RDS_binary_version_info
>0	string	B\n\2\0\0	R RDS (Native (little-endian) word order format
>>0	use ^RDS_binary_version_info
>0	string	B\n\3\0\0	R RDS (Native (little-endian) word order format
>>0	use ^RDS_binary_version_info
# Check for RDS XDR binary save format.
>0	string	X\n\0\0\0	R RDS (XDR binary save format
>>0	use RDS_binary_version_info


# Parse version numbers from RDS if it was one of the binary versions.
0	name	RDS_binary_version_info
>2	belong	>-1	v%d)
>6	beshort	>-1	\b, written by R v%d.
>8	byte	>-1	\b%d.
>9	byte	>-1	\b%d
>10	beshort	>-1	\b, readable from R v%d.
>12	byte	>-1	\b%d.
>13	byte	>-1	\b%d
>2	belong	>2
>>14	pstring/L	x	\b, %s encoded


# Check if file is one of the RDS ASCII formats.
0	string	A
>0	use RDS	not_printed
!:ext	rds

# Check if file is RDS binary native format.
0	string	B
>0	use RDS	not_printed
!:ext	rds

# Check if file is RDS XDR binary save format.
0	string	X
>0	use RDS	not_printed
!:ext	rds


###############################################################################
# RData file formats: magic bytes followed by RDS container.
###############################################################################

0	string	RDA2\n	R RData version 2 (ASCII),
!:ext	rda/rdata
>5	use	RDS

0	string	RDA3\n	R RData version 3 (ASCII),
!:ext	rda/rdata
>5	use	RDS

0	string	RDX2\n	R RData version 2 (binary),
!:ext	rda/rdata
>5	use	RDS

0	string	RDX3\n	R RData version 3 (binary),
!:ext	rda/rdata
>5	use	RDS
@


