LibreOffice Module onlineupdate (master) 1
|
#include <sys/types.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <onlineupdate/mar_private.h>
#include <onlineupdate/mar.h>
#include <netinet/in.h>
Go to the source code of this file.
Functions | |
static uint32_t | mar_hash_name (const char *name) |
static int | mar_insert_item (MarFile *mar, const char *name, int namelen, uint32_t offset, uint32_t length, uint32_t flags) |
static int | mar_consume_index (MarFile *mar, char **buf, const char *buf_end) |
static int | mar_read_index (MarFile *mar) |
static MarFile * | mar_fpopen (FILE *fp) |
Internal shared code for mar_open and mar_wopen. More... | |
MarFile * | mar_open (const char *path) |
Open a MAR file for reading. More... | |
void | mar_close (MarFile *mar) |
Close a MAR file that was opened using mar_open. More... | |
int | get_mar_file_info_fp (FILE *fp, int *hasSignatureBlock, uint32_t *numSignatures, int *hasAdditionalBlocks, uint32_t *offsetAdditionalBlocks, uint32_t *numAdditionalBlocks) |
Determines the MAR file information. More... | |
int | read_product_info_block (char *path, struct ProductInformationBlock *infoBlock) |
Reads the product info block from the MAR file's additional block section. More... | |
int | mar_read_product_info_block (MarFile *mar, struct ProductInformationBlock *infoBlock) |
Reads the product info block from the MAR file's additional block section. More... | |
const MarItem * | mar_find_item (MarFile *mar, const char *name) |
Find an item in the MAR file by name. More... | |
int | mar_enum_items (MarFile *mar, MarItemCallback callback, void *closure) |
Enumerate all MAR items via callback function. More... | |
int | mar_read (MarFile *mar, const MarItem *item, int offset, char *buf, int bufsize) |
Read from MAR item at given offset up to bufsize bytes. More... | |
int | get_mar_file_info (const char *path, int *hasSignatureBlock, uint32_t *numSignatures, int *hasAdditionalBlocks, uint32_t *offsetAdditionalBlocks, uint32_t *numAdditionalBlocks) |
Determines the MAR file information. More... | |
int get_mar_file_info | ( | const char * | path, |
int * | hasSignatureBlock, | ||
uint32_t * | numSignatures, | ||
int * | hasAdditionalBlocks, | ||
uint32_t * | offsetAdditionalBlocks, | ||
uint32_t * | numAdditionalBlocks | ||
) |
Determines the MAR file information.
Determines MAR file information.
path | The path of the MAR file to check. |
hasSignatureBlock | Optional out parameter specifying if the MAR file has a signature block or not. |
numSignatures | Optional out parameter for storing the number of signatures in the MAR file. |
hasAdditionalBlocks | Optional out parameter specifying if the MAR file has additional blocks or not. |
offsetAdditionalBlocks | Optional out parameter for the offset to the first additional block. Value is only valid if hasAdditionalBlocks is not equal to 0. |
numAdditionalBlocks | Optional out parameter for the number of additional blocks. Value is only valid if has_additional_blocks is not equal to 0. |
Definition at line 551 of file mar_read.c.
References FILE, and get_mar_file_info_fp().
Referenced by main(), mar_repackage_and_sign(), refresh_product_info_block(), and strip_signature_block().
int get_mar_file_info_fp | ( | FILE * | fp, |
int * | hasSignatureBlock, | ||
uint32_t * | numSignatures, | ||
int * | hasAdditionalBlocks, | ||
uint32_t * | offsetAdditionalBlocks, | ||
uint32_t * | numAdditionalBlocks | ||
) |
Determines the MAR file information.
fp | An opened MAR file in read mode. |
hasSignatureBlock | Optional out parameter specifying if the MAR file has a signature block or not. |
numSignatures | Optional out parameter for storing the number of signatures in the MAR file. |
hasAdditionalBlocks | Optional out parameter specifying if the MAR file has additional blocks or not. |
offsetAdditionalBlocks | Optional out parameter for the offset to the first additional block. Value is only valid if hasAdditionalBlocks is not equal to 0. |
numAdditionalBlocks | Optional out parameter for the number of additional blocks. Value is only valid if hasAdditionalBlocks is not equal to 0. |
Definition at line 231 of file mar_read.c.
References i, MAR_ID_SIZE, MAX_SIGNATURES, ntohl(), and SIGNATURE_BLOCK_OFFSET.
Referenced by get_mar_file_info(), and mar_read_product_info_block().
void mar_close | ( | MarFile * | mar | ) |
Close a MAR file that was opened using mar_open.
mar | The MarFile object to close. |
Definition at line 195 of file mar_read.c.
References MarFile_::fp, i, MarFile_::item_table, MarItem_::next, and TABLESIZE.
Referenced by ArchiveReader::Close(), main(), mar_extract(), mar_fpopen(), and mar_test().
Definition at line 60 of file mar_read.c.
References length, mar_insert_item(), name, and ntohl().
Referenced by mar_read_index().
int mar_enum_items | ( | MarFile * | mar, |
MarItemCallback | callback, | ||
void * | data | ||
) |
Enumerate all MAR items via callback function.
mar | The MAR file to enumerate. |
callback | The function to call for each MAR item. |
data | A caller specified value that is passed along to the callback function. |
Definition at line 497 of file mar_read.c.
References i, MarFile_::item_table, MarItem_::next, and TABLESIZE.
Referenced by mar_extract(), and mar_test().
Find an item in the MAR file by name.
mar | The MarFile object to query. |
item | The name of the item to query. |
Definition at line 484 of file mar_read.c.
References MarFile_::item_table, mar_hash_name(), name, MarItem_::name, and MarItem_::next.
Referenced by ArchiveReader::ExtractFile(), and ArchiveReader::ExtractFileToStream().
|
static |
Internal shared code for mar_open and mar_wopen.
On failure, will fclose(fp).
Definition at line 147 of file mar_read.c.
References MarFile_::fp, MarFile_::item_table, mar_close(), mar_read_index(), and NULL.
Referenced by mar_open().
|
static |
Definition at line 22 of file mar_read.c.
References name, and TABLESIZE.
Referenced by mar_find_item(), and mar_insert_item().
|
static |
Definition at line 32 of file mar_read.c.
References MarItem_::flags, MarFile_::item_table, length, MarItem_::length, mar_hash_name(), name, MarItem_::name, MarItem_::next, NULL, and MarItem_::offset.
Referenced by mar_consume_index().
MarFile * mar_open | ( | const char * | path | ) |
Open a MAR file for reading.
path | Specifies the path to the MAR file to open. This path must be compatible with fopen. |
Definition at line 167 of file mar_read.c.
References FILE, mar_fpopen(), and NULL.
Referenced by main(), mar_extract(), mar_test(), and ArchiveReader::Open().
Read from MAR item at given offset up to bufsize bytes.
mar | The MAR file to read. |
item | The MAR item to read. |
offset | The byte offset relative to the start of the item. |
buf | A pointer to a buffer to copy the data into. |
bufsize | The length of the buffer to copy the data into. |
Definition at line 514 of file mar_read.c.
References MarFile_::fp, MarItem_::length, and MarItem_::offset.
Referenced by ArchiveReader::ExtractItemToStream(), and mar_test_callback().
Definition at line 107 of file mar_read.c.
References MarFile_::fp, mar_consume_index(), MAR_ID, MAR_ID_SIZE, and ntohl().
Referenced by mar_fpopen().
int mar_read_product_info_block | ( | MarFile * | mar, |
struct ProductInformationBlock * | infoBlock | ||
) |
Reads the product info block from the MAR file's additional block section.
The caller is responsible for freeing the fields in infoBlock if the return is successful.
infoBlock | Out parameter for where to store the result to |
Definition at line 394 of file mar_read.c.
References MarFile_::fp, get_mar_file_info_fp(), i, ProductInformationBlock::MARChannelID, ntohl(), NULL, PRODUCT_INFO_BLOCK_ID, and ProductInformationBlock::productVersion.
Referenced by read_product_info_block(), and ArchiveReader::VerifyProductInformation().
int read_product_info_block | ( | char * | path, |
struct ProductInformationBlock * | infoBlock | ||
) |
Reads the product info block from the MAR file's additional block section.
The caller is responsible for freeing the fields in infoBlock if the return is successful.
infoBlock | Out parameter for where to store the result to |
Definition at line 369 of file mar_read.c.
References MarFile_::fp, and mar_read_product_info_block().
Referenced by main().