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

common tools functions More...

#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <errno.h>
#include <mobi.h>
#include "common.h"

Macros

#define LIBMOBI_MSG_COUNT   ARRAYSIZE(libmobi_messages)
 

Functions

const char * libmobi_msg (const MOBI_RET ret)
 Return message for given libmobi return code. More...
 
int mt_mkdir (const char *filename)
 Portable mkdir. More...
 
void split_fullpath (const char *fullpath, char *dirname, char *basename)
 Parse file name into file path and base name. More...
 
bool dir_exists (const char *path)
 Check whether given path exists and is a directory. More...
 
void print_summary (const MOBIData *m)
 Print summary meta information. More...
 
void print_exth (const MOBIData *m)
 Print all loaded EXTH record tags. More...
 
int set_decryption_key (MOBIData *m, const char *serial, const char *pid)
 Set key for decryption. Use user supplied pid or device serial number. More...
 

Variables

const char * libmobi_messages []
 Messages for libmobi return codes For reference see enum MOBI_RET in mobi.h. More...
 
const char separator = '/'
 

Detailed Description

common tools functions

Function Documentation

◆ dir_exists()

bool dir_exists ( const char *  path)

Check whether given path exists and is a directory.

Parameters
[in]pathPath to be tested
Examples:
common.c, and mobitool.c.

◆ libmobi_msg()

const char* libmobi_msg ( const MOBI_RET  ret)

Return message for given libmobi return code.

Parameters
[in]retLibmobi return code
Examples:
common.c, mobimeta.c, and mobitool.c.

◆ mt_mkdir()

int mt_mkdir ( const char *  filename)

Portable mkdir.

Parameters
[in]filenameFile name
Examples:
common.c, and mobitool.c.

◆ print_exth()

void print_exth ( const MOBIData m)

Print all loaded EXTH record tags.

Parameters
[in]mMOBIData structure
Examples:
common.c, mobimeta.c, and mobitool.c.

◆ print_summary()

void print_summary ( const MOBIData m)

Print summary meta information.

Parameters
[in]mMOBIData structure
Examples:
common.c, mobimeta.c, and mobitool.c.

◆ set_decryption_key()

int set_decryption_key ( MOBIData m,
const char *  serial,
const char *  pid 
)

Set key for decryption. Use user supplied pid or device serial number.

Parameters
[in,out]mMOBIData structure
[in]serialSerial number
[in]pidPid
Examples:
common.c, mobimeta.c, and mobitool.c.

◆ split_fullpath()

void split_fullpath ( const char *  fullpath,
char *  dirname,
char *  basename 
)

Parse file name into file path and base name.

Parameters
[in]fullpathFull file path
[in,out]dirnameWill be set to full dirname
[in,out]basenameWill be set to file basename
Examples:
common.c, and mobitool.c.

Variable Documentation

◆ libmobi_messages

const char* libmobi_messages[]
Initial value:
= {
"Success",
"Generic error",
"Wrong function parameter",
"Corrupted data",
"File not found",
"Document is encrypted",
"Unsupported document format",
"Memory allocation error",
"Initialization error",
"Buffer error",
"XML error",
"Invalid DRM pid",
"DRM key not found",
"DRM support not included",
}

Messages for libmobi return codes For reference see enum MOBI_RET in mobi.h.

Examples:
common.c.