LibreOffice Module onlineupdate (master) 1
Classes | Functions
mar_create.c File Reference
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <onlineupdate/mar_private.h>
#include <onlineupdate/mar_cmdline.h>
#include <onlineupdate/mar.h>
#include <netinet/in.h>
#include <unistd.h>
Include dependency graph for mar_create.c:

Go to the source code of this file.

Classes

struct  MarItemStack
 

Functions

static int mar_push (struct MarItemStack *stack, uint32_t length, uint32_t flags, const char *name)
 Push a new item onto the stack of items. More...
 
static int mar_concat_file (FILE *fp, const char *path)
 
static int mar_concat_product_info_block (FILE *fp, struct MarItemStack *stack, struct ProductInformationBlock *infoBlock)
 Writes out the product information block to the specified file. More...
 
int refresh_product_info_block (const char *path, struct ProductInformationBlock *infoBlock)
 Refreshes the product information block with the new information. More...
 
int mar_create (const char *dest, int num_files, char **files, struct ProductInformationBlock *infoBlock)
 Create a MAR file from a set of files. More...
 

Function Documentation

◆ mar_concat_file()

static int mar_concat_file ( FILE *  fp,
const char *  path 
)
static

Definition at line 75 of file mar_create.c.

References BLOCKSIZE, FILE, and in.

Referenced by mar_create().

◆ mar_concat_product_info_block()

static int mar_concat_product_info_block ( FILE *  fp,
struct MarItemStack stack,
struct ProductInformationBlock infoBlock 
)
static

Writes out the product information block to the specified file.

Parameters
fpThe opened MAR file being created.
stackA pointer to the MAR item stack being used to create the MAR
infoBlockThe product info block to store in the file.
Returns
0 on success.

Definition at line 109 of file mar_create.c.

References htonl(), MarItemStack::last_offset, ProductInformationBlock::MARChannelID, ntohl(), PIB_MAX_MAR_CHANNEL_ID_SIZE, PIB_MAX_PRODUCT_VERSION_SIZE, and ProductInformationBlock::productVersion.

Referenced by mar_create(), and refresh_product_info_block().

◆ mar_create()

int mar_create ( const char *  dest,
int  num_files,
char **  files,
struct ProductInformationBlock infoBlock 
)

Create a MAR file from a set of files.

Parameters
destThe path to the file to create. This path must be compatible with fopen.
numfilesThe number of files to store in the archive.
filesThe list of null-terminated file paths. Each file path must be compatible with fopen.
infoBlockThe information to store in the product information block.
Returns
A non-zero value if an error occurs.

Definition at line 293 of file mar_create.c.

References FILE, MarItemStack::head, HOST_TO_NETWORK64, htonl(), i, MarItemStack::last_offset, mar_concat_file(), mar_concat_product_info_block(), MAR_ID, MAR_ID_SIZE, mar_push(), MAX_SIZE_OF_MAR_FILE, NETWORK_TO_HOST64, ntohl(), remove(), and MarItemStack::size_used.

Referenced by main().

◆ mar_push()

static int mar_push ( struct MarItemStack stack,
uint32_t  length,
uint32_t  flags,
const char *  name 
)
static

Push a new item onto the stack of items.

The stack is a single block of memory.

Definition at line 34 of file mar_create.c.

References BLOCKSIZE, MarItemStack::head, htonl(), MarItemStack::last_offset, length, MAR_ITEM_SIZE, name, ROUND_UP, size, MarItemStack::size_allocated, and MarItemStack::size_used.

Referenced by mar_create().

◆ refresh_product_info_block()

int refresh_product_info_block ( const char *  path,
struct ProductInformationBlock infoBlock 
)

Refreshes the product information block with the new information.

The input MAR must not be signed or the function call will fail.

Parameters
pathThe path to the MAR file whose product info block should be refreshed.
infoBlockOut parameter for where to store the result to
Returns
0 on success, -1 on failure

Definition at line 193 of file mar_create.c.

References FILE, get_mar_file_info(), i, mar_concat_product_info_block(), ntohl(), NULL, and PRODUCT_INFO_BLOCK_ID.

Referenced by main().