Write the SQLite file header on page 1 with master entries. */
| 1947 | |
| 1948 | /* Write the SQLite file header on page 1 with master entries. */ |
| 1949 | static void write_sqlite_file_header(uint8_t *page1, uint32_t total_pages) { |
| 1950 | memcpy(page1, "SQLite format 3\000", 16); |
| 1951 | put_u16(page1 + HDR_OFF_CBM_PAGE_SIZE, |
| 1952 | CBM_PAGE_SIZE == SQLITE_MAX_PAGE_SIZE ? (uint16_t)SKIP_ONE : (uint16_t)CBM_PAGE_SIZE); |
| 1953 | page1[HDR_OFF_WRITE_VERSION] = FILE_FORMAT; |
| 1954 | page1[HDR_OFF_READ_VERSION] = FILE_FORMAT; |
| 1955 | page1[HDR_OFF_RESERVED] = 0; |
| 1956 | page1[HDR_OFF_MAX_EMBED_FRAC] = MAX_EMBED_FRACTION; |
| 1957 | page1[HDR_OFF_MIN_EMBED_FRAC] = MIN_EMBED_FRACTION; |
| 1958 | page1[HDR_OFF_LEAF_FRAC] = LEAF_PAYLOAD_FRACTION; |
| 1959 | put_u32(page1 + HDR_OFF_FILE_CHANGE, SKIP_ONE); |
| 1960 | put_u32(page1 + HDR_OFF_DB_SIZE, total_pages); |
| 1961 | put_u32(page1 + HDR_OFF_FREELIST_TRUNK, 0); |
| 1962 | put_u32(page1 + HDR_OFF_FREELIST_COUNT, 0); |
| 1963 | put_u32(page1 + HDR_OFF_SCHEMA_COOKIE, SKIP_ONE); |
| 1964 | put_u32(page1 + HDR_OFF_SCHEMA_FORMAT, SCHEMA_FORMAT); |
| 1965 | put_u32(page1 + HDR_OFF_DEFAULT_CACHE, 0); |
| 1966 | put_u32(page1 + HDR_OFF_AUTOVAC_TOP, 0); |
| 1967 | put_u32(page1 + HDR_OFF_TEXT_ENCODING, SKIP_ONE); |
| 1968 | put_u32(page1 + HDR_OFF_USER_VERSION, 0); |
| 1969 | put_u32(page1 + HDR_OFF_INCR_VACUUM, 0); |
| 1970 | put_u32(page1 + HDR_OFF_APP_ID, 0); |
| 1971 | put_u32(page1 + HDR_OFF_VERSION_VALID, SKIP_ONE); |
| 1972 | put_u32(page1 + HDR_OFF_SQLITE_VERSION, SQLITE_VERSION); |
| 1973 | } |
| 1974 | |
| 1975 | /* Build master records, write page 1 B-tree + file header. */ |
| 1976 | static int write_master_page1(FILE *fp, MasterEntry *master, int master_count, uint32_t next_page) { |
no test coverage detected