libmobi
C library for handling MOBI format ebook documents
Macros | Functions
write.c File Reference

Writing functions. More...

#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "write.h"
#include "util.h"
#include "debug.h"

Macros

#define MOBI_HEADER_MAXLEN   280
 
#define MOBI_RECORD0_PADDING   0x2002
 

Functions

MOBI_RET mobi_write_buffer (FILE *file, const MOBIBuffer *buf)
 Write buffer contents to file. More...
 
MOBI_RET mobi_write_pdbheader (FILE *file, const MOBIData *m)
 Write palm database header to file. More...
 
MOBI_RET mobi_serialize_mobiheader (MOBIBuffer *buf, const MOBIData *m, const uint32_t exthsize)
 Serialize mobi header to buffer. More...
 
MOBI_RET mobi_serialize_extheader (MOBIBuffer *buf, const MOBIData *m)
 Serialize exth header to buffer. More...
 
MOBI_RET mobi_update_record0 (MOBIData *m, const size_t seqnumber)
 Serialize record0 and update record in MOBIData structure. More...
 
MOBI_RET mobi_write_records (FILE *file, const MOBIData *m)
 Write palm database records to file. More...
 
MOBI_RET mobi_write_file (FILE *file, MOBIData *m)
 Write mobi document to file. More...
 

Detailed Description

Writing functions.

Copyright (c) 2016 Bartek Fabiszewski http://www.fabiszewski.net

This file is part of libmobi. Licensed under LGPL, either version 3, or any later. See http://www.gnu.org/licenses/

Function Documentation

◆ mobi_serialize_extheader()

MOBI_RET mobi_serialize_extheader ( MOBIBuffer buf,
const MOBIData m 
)

Serialize exth header to buffer.

Parameters
[in,out]bufoutput buffer
[in]mMOBIData structure
Returns
MOBI_RET status code (MOBI_SUCCESS on success)

◆ mobi_serialize_mobiheader()

MOBI_RET mobi_serialize_mobiheader ( MOBIBuffer buf,
const MOBIData m,
const uint32_t  exthsize 
)

Serialize mobi header to buffer.

Parameters
[in,out]bufoutput buffer
[in]mMOBIData structure
[in]exthsizeSize of exth record
Returns
MOBI_RET status code (MOBI_SUCCESS on success)

◆ mobi_update_record0()

MOBI_RET mobi_update_record0 ( MOBIData m,
const size_t  seqnumber 
)

Serialize record0 and update record in MOBIData structure.

Record0 sequential number may be greater than zero in case of hybrid file with two info records

Parameters
[in,out]mMOBIData structure
[in]seqnumberRecord0 sequential number
Returns
MOBI_RET status code (MOBI_SUCCESS on success)

◆ mobi_write_buffer()

MOBI_RET mobi_write_buffer ( FILE *  file,
const MOBIBuffer buf 
)

Write buffer contents to file.

Parameters
[in,out]fileFile descriptor
[in]bufBuffer
Returns
MOBI_RET status code (MOBI_SUCCESS on success)

◆ mobi_write_pdbheader()

MOBI_RET mobi_write_pdbheader ( FILE *  file,
const MOBIData m 
)

Write palm database header to file.

Parameters
[in,out]fileFile descriptor
[in]mMOBIData structure
Returns
MOBI_RET status code (MOBI_SUCCESS on success)

◆ mobi_write_records()

MOBI_RET mobi_write_records ( FILE *  file,
const MOBIData m 
)

Write palm database records to file.

Parameters
[in,out]fileFile descriptor
[in]mMOBIData structure
Returns
MOBI_RET status code (MOBI_SUCCESS on success)