|
Packit Service |
310c69 |
/*
|
|
Packit Service |
310c69 |
* Copyright (c) 2020 Red Hat, Inc.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* This program is free software; you can redistribute it and/or
|
|
Packit Service |
310c69 |
* modify it under the terms of the GNU General Public License
|
|
Packit Service |
310c69 |
* as published by the Free Software Foundation; either version 2
|
|
Packit Service |
310c69 |
* of the License, or (at your option) any later version.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* This program is distributed in the hope that it will be useful,
|
|
Packit Service |
310c69 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
310c69 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
310c69 |
* GNU General Public License for more details.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* You should have received a copy of the GNU General Public License
|
|
Packit Service |
310c69 |
* along with this program; if not, write to the Free Software
|
|
Packit Service |
310c69 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
Packit Service |
310c69 |
* 02110-1301, USA.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* $Id: //eng/uds-releases/jasper/src/uds/chapterIndex.h#4 $
|
|
Packit Service |
310c69 |
*/
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#ifndef CHAPTER_INDEX_H
|
|
Packit Service |
310c69 |
#define CHAPTER_INDEX_H 1
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#include "deltaIndex.h"
|
|
Packit Service |
310c69 |
#include "geometry.h"
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
enum {
|
|
Packit Service |
310c69 |
// The value returned as the record page number when an entry is not found
|
|
Packit Service |
310c69 |
// in the chapter index.
|
|
Packit Service |
310c69 |
NO_CHAPTER_INDEX_ENTRY = -1
|
|
Packit Service |
310c69 |
};
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
typedef struct openChapterIndex {
|
|
Packit Service |
310c69 |
const Geometry *geometry;
|
|
Packit Service |
310c69 |
DeltaIndex deltaIndex;
|
|
Packit Service |
310c69 |
uint64_t virtualChapterNumber;
|
|
Packit Service |
310c69 |
bool headerNativeEndian;
|
|
Packit Service |
310c69 |
uint64_t volumeNonce;
|
|
Packit Service |
310c69 |
} OpenChapterIndex;
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Make a new open chapter index.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param openChapterIndex Location to hold new open chapter index pointer
|
|
Packit Service |
310c69 |
* @param geometry The geometry
|
|
Packit Service |
310c69 |
* @param chapterIndexHeaderNativeEndian chapter index header format
|
|
Packit Service |
310c69 |
* @param volumeNonce The volume nonce.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return error code or UDS_SUCCESS
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int makeOpenChapterIndex(OpenChapterIndex **openChapterIndex,
|
|
Packit Service |
310c69 |
const Geometry *geometry,
|
|
Packit Service |
310c69 |
bool chapterIndexHeaderNativeEndian,
|
|
Packit Service |
310c69 |
uint64_t volumeNonce)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Terminate and clean up an open chapter index.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param openChapterIndex The open chapter index to terminate
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
void freeOpenChapterIndex(OpenChapterIndex *openChapterIndex);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Empty an open chapter index, and prepare it for writing a new virtual
|
|
Packit Service |
310c69 |
* chapter.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param openChapterIndex The open chapter index to empty
|
|
Packit Service |
310c69 |
* @param virtualChapterNumber The virtual chapter number
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
void emptyOpenChapterIndex(OpenChapterIndex *openChapterIndex,
|
|
Packit Service |
310c69 |
uint64_t virtualChapterNumber);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Create a new record in an open chapter index, associating a chunk name with
|
|
Packit Service |
310c69 |
* the number of the record page containing the metadata for the chunk.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param openChapterIndex The open chapter index
|
|
Packit Service |
310c69 |
* @param name The chunk name
|
|
Packit Service |
310c69 |
* @param pageNumber The number of the record page containing the name
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or an error code
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int putOpenChapterIndexRecord(OpenChapterIndex *openChapterIndex,
|
|
Packit Service |
310c69 |
const UdsChunkName *name,
|
|
Packit Service |
310c69 |
unsigned int pageNumber)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Pack a section of an open chapter index into a chapter index page. A
|
|
Packit Service |
310c69 |
* range of delta lists (starting with a specified list index) is copied
|
|
Packit Service |
310c69 |
* from the open chapter index into a memory page. The number of lists
|
|
Packit Service |
310c69 |
* copied onto the page is returned to the caller.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param openChapterIndex The open chapter index
|
|
Packit Service |
310c69 |
* @param memory The memory page to use
|
|
Packit Service |
310c69 |
* @param firstList The first delta list number to be copied
|
|
Packit Service |
310c69 |
* @param lastPage If true, this is the last page of the chapter
|
|
Packit Service |
310c69 |
* index and all the remaining lists must be packed
|
|
Packit Service |
310c69 |
* onto this page
|
|
Packit Service |
310c69 |
* @param numLists The number of delta lists that were copied
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return error code or UDS_SUCCESS. On UDS_SUCCESS, the numLists
|
|
Packit Service |
310c69 |
* argument contains the number of lists copied.
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int packOpenChapterIndexPage(OpenChapterIndex *openChapterIndex,
|
|
Packit Service |
310c69 |
byte *memory,
|
|
Packit Service |
310c69 |
unsigned int firstList,
|
|
Packit Service |
310c69 |
bool lastPage,
|
|
Packit Service |
310c69 |
unsigned int *numLists)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Get the number of records in an open chapter index.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param openChapterIndex The open chapter index
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return The number of records
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int getOpenChapterIndexSize(OpenChapterIndex *openChapterIndex)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Get the number of bytes allocated for the open chapter index.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param openChapterIndex The open chapter index
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return the number of bytes allocated
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
size_t getOpenChapterIndexMemoryAllocated(OpenChapterIndex *openChapterIndex);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Make a new chapter index page, initializing it with the data from the
|
|
Packit Service |
310c69 |
* given buffer.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param chapterIndexPage The new chapter index page
|
|
Packit Service |
310c69 |
* @param geometry The geometry
|
|
Packit Service |
310c69 |
* @param indexPage The memory page to use
|
|
Packit Service |
310c69 |
* @param volumeNonce If non-zero, the volume nonce to verify
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or an error code
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int initializeChapterIndexPage(DeltaIndexPage *chapterIndexPage,
|
|
Packit Service |
310c69 |
const Geometry *geometry,
|
|
Packit Service |
310c69 |
byte *indexPage,
|
|
Packit Service |
310c69 |
uint64_t volumeNonce)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Validate a chapter index page. This is called at rebuild time to ensure
|
|
Packit Service |
310c69 |
* that the volume file contains a coherent chapter index.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param chapterIndexPage The chapter index page
|
|
Packit Service |
310c69 |
* @param geometry The geometry of the volume
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return The result code:
|
|
Packit Service |
310c69 |
* UDS_SUCCESS for a good chapter index page
|
|
Packit Service |
310c69 |
* UDS_CORRUPT_COMPONENT if the chapter index code detects invalid data
|
|
Packit Service |
310c69 |
* UDS_CORRUPT_DATA if there is a problem in a delta list bit stream
|
|
Packit Service |
310c69 |
* UDS_BAD_STATE if the code follows an invalid code path
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int validateChapterIndexPage(const DeltaIndexPage *chapterIndexPage,
|
|
Packit Service |
310c69 |
const Geometry *geometry)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Search a chapter index page for a chunk name, returning the record page
|
|
Packit Service |
310c69 |
* number that may contain the name.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param [in] chapterIndexPage The chapter index page
|
|
Packit Service |
310c69 |
* @param [in] geometry The geometry of the volume
|
|
Packit Service |
310c69 |
* @param [in] name The chunk name
|
|
Packit Service |
310c69 |
* @param [out] recordPagePtr The record page number
|
|
Packit Service |
310c69 |
* or NO_CHAPTER_INDEX_ENTRY if not found
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or an error code
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int searchChapterIndexPage(DeltaIndexPage *chapterIndexPage,
|
|
Packit Service |
310c69 |
const Geometry *geometry,
|
|
Packit Service |
310c69 |
const UdsChunkName *name,
|
|
Packit Service |
310c69 |
int *recordPagePtr)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#endif /* CHAPTER_INDEX_H */
|