17 # include "../config.h"
30 #define STR_HELPER(x) #x
31 #define STR(x) STR_HELPER(x)
33 #define ARRAYSIZE(arr) (sizeof(arr) / sizeof(arr[0]))
35 #if defined(__clang__)
36 # define COMPILER "clang " __VERSION__
37 #elif defined(__SUNPRO_C)
38 # define COMPILER "suncc " STR(__SUNPRO_C)
39 #elif defined(__GNUC__)
40 # if (defined(__MINGW32__) || defined(__MINGW64__))
41 # define COMPILER "gcc (MinGW) " __VERSION__
43 # define COMPILER "gcc " __VERSION__
45 #elif defined(_MSC_VER)
46 # define COMPILER "MSVC++ " STR(_MSC_VER)
48 # define COMPILER "unknown"
51 #if !defined S_ISDIR && defined S_IFDIR
52 # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
55 # error "At least one of S_ISDIR or S_IFDIR macros is required"
58 #define FULLNAME_MAX 1024
60 extern const char separator;
61 extern bool outdir_opt;
62 extern char outdir[FILENAME_MAX];
65 void split_fullpath(
const char *fullpath,
char *dirname,
char *basename,
const size_t buf_len);
67 int create_subdir(
char *newdir,
const size_t buf_len,
const char *parent_dir,
const char *subdir_name);
68 int write_file(
const unsigned char *buffer,
const size_t len,
const char *path);
69 int write_to_dir(
const char *dir,
const char *name,
const unsigned char *buffer,
const size_t len);
void print_exth(const MOBIData *m)
Print all loaded EXTH record tags.
Definition: common.c:433
int write_to_dir(const char *dir, const char *name, const unsigned char *buffer, const size_t len)
Write content to file in directory.
Definition: common.c:188
int set_decryption_key(MOBIData *m, const char *serial, const char *pid)
Set key for decryption. Use user supplied pid or device serial number.
Definition: common.c:554
const char * libmobi_msg(const MOBI_RET ret)
Return message for given libmobi return code.
Definition: common.c:68
bool dir_exists(const char *path)
Check whether given path exists and is a directory.
Definition: common.c:207
void split_fullpath(const char *fullpath, char *dirname, char *basename, const size_t buf_len)
Parse file name into file path and base name. Dirname or basename can be skipped by setting to null.
Definition: common.c:84
void print_summary(const MOBIData *m)
Print summary meta information.
Definition: common.c:244
int create_subdir(char *newdir, const size_t buf_len, const char *parent_dir, const char *subdir_name)
Create subfolder in directory.
Definition: common.c:141
int write_file(const unsigned char *buffer, const size_t len, const char *path)
Open file descriptor and write buffer to it.
Definition: common.c:161
int set_decryption_serial(MOBIData *m, const char *serial)
Set device serial number for decryption.
Definition: common.c:536
int save_mobi(MOBIData *m, const char *fullpath, const char *suffix)
Save mobi file.
Definition: common.c:585
int make_directory(const char *path)
Make directory.
Definition: common.c:123
int set_decryption_pid(MOBIData *m, const char *pid)
Set PID for decryption.
Definition: common.c:519
void normalize_path(char *path)
Make sure we use consistent separators on Windows builds.
Definition: common.c:225
MOBI_RET
Error codes returned by functions.
Definition: mobi.h:59
Main structure holding all metadata and unparsed records data.
Definition: mobi.h:381