Skip to main content

Module container

Module container 

Source
Expand description

The CSF chunk container (“CSFCHUNK”) that wraps every .clip file.

All numbers are big endian (spec: docs/spec/01-container.md):

file header (24 bytes): "CSFCHUNK"  u64 file size  u64 offset of the first chunk (24)
chunk:                  8-byte tag  u64 body length  body
  CHNKHead  body 40 bytes: u64 256, u64 offset of the CHNKSQLi chunk header,
            u64 16, 16-byte file id
  CHNKExta  body: u64 40, 40-byte external id ("extrnlid" + 32 hex digits), payload
  CHNKSQLi  body: SQLite 3 database image
  CHNKFoot  body: empty; the last chunk

CSP writes Head, every Exta, SQLi, Foot in this order. The table ExternalChunk in the database maps each external id to the file offset of its CHNKExta header. The parser keeps the original bytes, so a file that is not changed is written back byte for byte.

Structs§

Chunk
One chunk: where its header and body are in the file.
Container
A parsed .clip container. Holds the original bytes.
ContainerWriter
Builds a new container: Head, the external chunks in the given order, SQLi, Foot, as CSP writes them.
Head
Contents of the CHNKHead chunk.

Enums§

ChunkKind
Kind of a chunk, from its 8-byte tag.

Constants§

CHUNK_HEADER_SIZE
Size of a chunk header (tag and body length).
EXTERNAL_ID_LENGTH
Length of an external id.
EXTERNAL_ID_PREFIX
How every external id starts.
FILE_HEADER_SIZE
Size of the file header.
FILE_ID_LENGTH
Length of the file id in CHNKHead.
FILE_MAGIC
The first 8 bytes of a .clip.
HEAD_BODY_SIZE
Size of the CHNKHead body.
HEAD_VERSION
First value of the CHNKHead body.
TAG_EXTERNAL
Tag of an external chunk.
TAG_FOOTER
Tag of the last chunk.
TAG_HEAD
Tag of the head chunk.
TAG_SQLITE
Tag of the database chunk.

Functions§

is_external_id
Whether id looks like the ids CSP writes (“extrnlid” + 32 hex digits).