dbda8d6ce9 2007-07-21 drh: <html> dbda8d6ce9 2007-07-21 drh: <head> dbda8d6ce9 2007-07-21 drh: <title>Fossil File Formats</title> dbda8d6ce9 2007-07-21 drh: </head> dbda8d6ce9 2007-07-21 drh: <body bgcolor="white"> dbda8d6ce9 2007-07-21 drh: <h1 align="center"> dbda8d6ce9 2007-07-21 drh: Fossil File Formats dbda8d6ce9 2007-07-21 drh: </h1> dbda8d6ce9 2007-07-21 drh: dbda8d6ce9 2007-07-21 drh: <p> dbda8d6ce9 2007-07-21 drh: The global state of a fossil repository is determined by an unordered dbda8d6ce9 2007-07-21 drh: set of content files. Each of these files has a format which is defined dbda8d6ce9 2007-07-21 drh: by this document. dbda8d6ce9 2007-07-21 drh: </p> dbda8d6ce9 2007-07-21 drh: dbda8d6ce9 2007-07-21 drh: <h2>1.0 General Formatting Rules</h2> dbda8d6ce9 2007-07-21 drh: dbda8d6ce9 2007-07-21 drh: <p> dbda8d6ce9 2007-07-21 drh: Fossil content files consist of a header, a blank line, and optional dbda8d6ce9 2007-07-21 drh: content. dbda8d6ce9 2007-07-21 drh: </p> dbda8d6ce9 2007-07-21 drh: dbda8d6ce9 2007-07-21 drh: <p> dbda8d6ce9 2007-07-21 drh: The header is divided into "properties" by newline ('\n', 0x0a) dbda8d6ce9 2007-07-21 drh: characters. Each header property is divided into tokens by space (' ', 0x20) dbda8d6ce9 2007-07-21 drh: characters. The first token of each property is the property name. dbda8d6ce9 2007-07-21 drh: Subsequent tokens (if any) are arguments to the property. dbda8d6ce9 2007-07-21 drh: </p> dbda8d6ce9 2007-07-21 drh: dbda8d6ce9 2007-07-21 drh: <p> dbda8d6ce9 2007-07-21 drh: The blank line that separates the header from the content can be dbda8d6ce9 2007-07-21 drh: thought of as a property line that contains no tokens. Everything dbda8d6ce9 2007-07-21 drh: that follows the newline character that terminates the blank line dbda8d6ce9 2007-07-21 drh: is content. The blank line is always present but the content is dbda8d6ce9 2007-07-21 drh: optional. dbda8d6ce9 2007-07-21 drh: </p> dbda8d6ce9 2007-07-21 drh: dbda8d6ce9 2007-07-21 drh: <p> dbda8d6ce9 2007-07-21 drh: All tokens in a property line are encoded to escape special characters. dbda8d6ce9 2007-07-21 drh: The encoding is as follows: dbda8d6ce9 2007-07-21 drh: </p> dbda8d6ce9 2007-07-21 drh: dbda8d6ce9 2007-07-21 drh: <blockquote> dbda8d6ce9 2007-07-21 drh: <table border="1"> dbda8d6ce9 2007-07-21 drh: <tr><th>Input Character</th><th>Encoded As</th></tr> dbda8d6ce9 2007-07-21 drh: <tr><td align="center"> space (0x20) </td><td align="center"> \s </td></tr> dbda8d6ce9 2007-07-21 drh: <tr><td align="center"> newline (0x0A) </td><td align="center"> \n </td></tr> dbda8d6ce9 2007-07-21 drh: <tr><td align="center"> carriage return (0x0D) </td><td align="center"> \r </td></tr> dbda8d6ce9 2007-07-21 drh: <tr><td align="center"> tab (0x09) </td><td align="center"> \t </td></tr> dbda8d6ce9 2007-07-21 drh: <tr><td align="center"> vertical tab (0x0B) </td><td align="center"> \v </td></tr> dbda8d6ce9 2007-07-21 drh: <tr><td align="center"> formfeed (0x0C) </td><td align="center"> \f </td></tr> dbda8d6ce9 2007-07-21 drh: <tr><td align="center"> nul (0x00) </td><td align="center"> \0 </td></tr> dbda8d6ce9 2007-07-21 drh: <tr><td align="center"> backslash (0x5C) </td><td align="center"> \\ </td></tr> dbda8d6ce9 2007-07-21 drh: </table> dbda8d6ce9 2007-07-21 drh: </blockquote> dbda8d6ce9 2007-07-21 drh: dbda8d6ce9 2007-07-21 drh: <p> dbda8d6ce9 2007-07-21 drh: Characters other than the ones shown in the table above are passed through dbda8d6ce9 2007-07-21 drh: the encoder without change. dbda8d6ce9 2007-07-21 drh: </p> dbda8d6ce9 2007-07-21 drh: dbda8d6ce9 2007-07-21 drh: <p> dbda8d6ce9 2007-07-21 drh: All properties names are unpunctuated lower-case ASCII strings. dbda8d6ce9 2007-07-21 drh: The properties appear in the header in sorted order (using dbda8d6ce9 2007-07-21 drh: memcpy() as the comparision function) except for the "signature" dbda8d6ce9 2007-07-21 drh: property which always occurs first. dbda8d6ce9 2007-07-21 drh: </p> dbda8d6ce9 2007-07-21 drh: dbda8d6ce9 2007-07-21 drh: <h2>2.0 Common Properties</h2> dbda8d6ce9 2007-07-21 drh: dbda8d6ce9 2007-07-21 drh: <p> dbda8d6ce9 2007-07-21 drh: Every content file has a "time" property. The argument to the dbda8d6ce9 2007-07-21 drh: time property is an integer which is the number of seconds since dbda8d6ce9 2007-07-21 drh: 1970 UTC when the content file was created. For example: dbda8d6ce9 2007-07-21 drh: </p> dbda8d6ce9 2007-07-21 drh: dbda8d6ce9 2007-07-21 drh: <blockquote> dbda8d6ce9 2007-07-21 drh: time 1181404746 dbda8d6ce9 2007-07-21 drh: </blockquote> dbda8d6ce9 2007-07-21 drh: dbda8d6ce9 2007-07-21 drh: <p> dbda8d6ce9 2007-07-21 drh: Every content file has a "type" property. The argument to the dbda8d6ce9 2007-07-21 drh: type property defines the purpose of the content file. The dbda8d6ce9 2007-07-21 drh: argument can be strings like "version", "folder", "file", or "user". dbda8d6ce9 2007-07-21 drh: </p> dbda8d6ce9 2007-07-21 drh: dbda8d6ce9 2007-07-21 drh: <p> dbda8d6ce9 2007-07-21 drh: The first property of a content file is the digital signature. The dbda8d6ce9 2007-07-21 drh: name of the signature property is "signature". There are two arguments. dbda8d6ce9 2007-07-21 drh: The first argument is the SHA256 hash of the content file that defines dbda8d6ce9 2007-07-21 drh: the user who signed this file. User records themselves are self-signed dbda8d6ce9 2007-07-21 drh: and so the first argument is simply "*" for user records. The second dbda8d6ce9 2007-07-21 drh: argument is the digital signature of an SHA256 hash of the entire dbda8d6ce9 2007-07-21 drh: file (header and content) except for the signature line itself. dbda8d6ce9 2007-07-21 drh: </p>