|
Nyctergatis EPUB (creation of EPUB documents).
More...
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "zip.h"
#include "NE.h"
Go to the source code of this file.
Defines |
#define | kBufferSize 65536L |
#define | kPathSize 512 |
#define | DOCDIR "OPS" |
#define | ROOTDOC "content.opf" |
#define | NCXDOC "toc.ncx" |
#define | COVERDOC "cover.xhtml" |
#define | ENDNOTESDOC "endnotes.xhtml" |
#define | Chk(e) do { err = (e); if (err != kNEErrOk) return err; } while (0) |
Functions |
NEErr | NEStringCopy (char **str, char const *src, int srcLen) |
| Copy a string to a sring allocated by malloc.
|
NEErr | NEStringCat (char **str, char const *src, int srcLen) |
| Concatenate a string to a string allocated by malloc.
|
NEErr | NEStringAdd (char **str, char const *src, int srcLen) |
| Concatenate a string with a linefeed separator character.
|
char const * | NEStringNextPart (char const *str) |
| Find next part after the next linefeed character.
|
int | NEStringPartLength (char const *str) |
NEBoolean | NEStringEq (char const *str, char const *str2, int len2) |
void | NEStringFree (char **str) |
| Deallocated string.
|
NEErr | NEBegin (NEPtr ne, char const *filename) |
| Begin the creation of an EPUB file.
|
NEErr | NEAddMetadata (NEPtr ne, NEMetadataKey key, char const *data, int dataLen) |
| Add metadata.
|
NEErr | NESetCoverImage (NEPtr ne, char const *filename, int filenameLen) |
| Specify an image to be used for the cover.
|
NEErr | NEAddPart (NEPtr ne, char const *filename, NEBoolean auxiliary) |
| Add an XHTML part to the book manifest; its contents should also be added with NEAddFile or NENewFile/NEWriteToFile/NECloseFile.
|
static char const * | SuffixToMimetype (char const *filename, int filenameLen) |
NEErr | NEAddOther (NEPtr ne, char const *filename, int filenameLen, char const *mimetype) |
| Add non-HTML content to the book (images, css, etc.); its contents should also be added with NEAddFile or NENewFile/NEWriteToFile/NECloseFile.
|
void | NEEnumOther (NEPtr ne, char const **filename, int *filenameLength) |
| Enumerate files added by NEAddOther.
|
NEErr | NEAddFile (NEPtr ne, char const *filename, char const *path) |
| Add the contents of a file.
|
NEErr | NEAddTOCEntry (NEPtr ne, char const *title, char const *relativeUrl, int level) |
| Add an entry to the table of contents.
|
NEErr | NENewFile (NEPtr ne, char const *filename) |
| Create a new file in the EPUB.
|
NEErr | NEWriteToFile (NEPtr ne, char const *data, int len) |
| Add data to the file created with NENewFile.
|
NEErr | NECloseFile (NEPtr ne) |
| Close the file opened by NENewFile.
|
NEErr | NEAddEndnote (NEPtr ne, char const *endnote, int len, char const *refDoc, int refDocLen, char const **refLink) |
| Add an endnote.
|
NEErr | NEMakeCover (NEPtr ne) |
static NEErr | WriteMetadata (NEPtr ne, char const *name, char const *attr, char const *str) |
| Write document metadata.
|
static NEErr | WriteMeta (NEPtr ne, char const *name, char const *content) |
| Write a meta element.
|
static NEErr | WriteEndnotes (NEPtr ne) |
| Write the file for endnotes.
|
static NEErr | WriteOPF (NEPtr ne) |
| Write the OPF file.
|
static NEErr | WriteNCX (NEPtr ne) |
| Write the NCX file.
|
NEErr | NEEnd (NEPtr ne) |
| Finish writing the EPUB file and release all resources.
|
Detailed Description
Nyctergatis EPUB (creation of EPUB documents).
- Author:
- Yves Piguet.
- Copyright:
- 2010-2013, Yves Piguet.
Definition in file NE.c.
Function Documentation
NEErr NEAddEndnote |
( |
NEPtr |
ne, |
|
|
char const * |
endnote, |
|
|
int |
len, |
|
|
char const * |
refDoc, |
|
|
int |
refDocLen, |
|
|
char const ** |
refLink |
|
) |
| |
Add an endnote.
- Parameters:
-
[in,out] | ne | reference to EPUB main structure |
[in] | endnote | XHTML code for the endnote (without number) |
[in] | len | length of endnote in bytes |
[in] | refDoc | name of the document containing the reference |
[in] | refDocLen | length of srcDoc in bytes |
[out] | refLink | XHTML code to use as a link to the endnote (null-terminated) |
- Returns:
- kNEErrOk for success, error code for failure
Definition at line 449 of file NE.c.
NEErr NEAddFile |
( |
NEPtr |
ne, |
|
|
char const * |
filename, |
|
|
char const * |
path |
|
) |
| |
Add the contents of a file.
- Parameters:
-
[in,out] | ne | reference to EPUB main structure |
[in] | filename | file name as seen in the EPUB |
[in] | path | path of the original file |
- Returns:
- kNEErrOk for success, error code for failure
Definition at line 323 of file NE.c.
Add metadata.
- Parameters:
-
[in,out] | ne | reference to EPUB main structure |
[in] | key | kind of metadata |
[in] | data | metadata value |
[in] | dataLen | length of data in bytes |
- Returns:
- kNEErrOk for success, error code for failure
Definition at line 205 of file NE.c.
NEErr NEAddOther |
( |
NEPtr |
ne, |
|
|
char const * |
filename, |
|
|
int |
filenameLen, |
|
|
char const * |
mimetype |
|
) |
| |
Add non-HTML content to the book (images, css, etc.); its contents should also be added with NEAddFile or NENewFile/NEWriteToFile/NECloseFile.
- Parameters:
-
[in,out] | ne | reference to EPUB main structure |
[in] | filename | filename |
[in] | filenameLen | length of filename in bytes |
[in] | mimetype | MIME type (NULL to use filename's suffix) |
- Returns:
- kNEErrOk for success, error code for failure
Definition at line 297 of file NE.c.
NEErr NEAddPart |
( |
NEPtr |
ne, |
|
|
char const * |
filename, |
|
|
NEBoolean |
auxiliary |
|
) |
| |
Add an XHTML part to the book manifest; its contents should also be added with NEAddFile or NENewFile/NEWriteToFile/NECloseFile.
- Parameters:
-
[in,out] | ne | reference to EPUB main structure |
[in] | filename | filename |
[in] | auxiliary | TRUE for auxiliary content (referenced via hyperlinks), FALSE for main contents (main line of reading) |
- Returns:
- kNEErrOk for success, error code for failure
Definition at line 253 of file NE.c.
NEErr NEAddTOCEntry |
( |
NEPtr |
ne, |
|
|
char const * |
title, |
|
|
char const * |
relativeUrl, |
|
|
int |
level |
|
) |
| |
Add an entry to the table of contents.
- Parameters:
-
[in,out] | ne | reference to EPUB main structure |
[in] | title | entry text |
[in] | relativeURL | relative URL to the file with an optional anchor |
[in] | level | 1 for top-level entries, 2 for subentries, etc. |
- Returns:
- kNEErrOk for success, error code for failure
Definition at line 374 of file NE.c.
NEErr NEBegin |
( |
NEPtr |
ne, |
|
|
char const * |
filename |
|
) |
| |
Begin the creation of an EPUB file.
- Parameters:
-
[out] | ne | reference to EPUB main structure |
[in] | filename | EPUB file name, or NULL for debug (write to stderr) |
- Returns:
- kNEErrOk for success, error code for failure
Definition at line 143 of file NE.c.
NEErr NECloseFile |
( |
NEPtr |
ne | ) |
|
Close the file opened by NENewFile.
- Returns:
- kNEErrOk for success, error code for failure
Definition at line 442 of file NE.c.
Finish writing the EPUB file and release all resources.
- Returns:
- kNEErrOk for success, error code for failure
Definition at line 858 of file NE.c.
void NEEnumOther |
( |
NEPtr |
ne, |
|
|
char const ** |
filename, |
|
|
int * |
filenameLength |
|
) |
| |
Enumerate files added by NEAddOther.
- Parameters:
-
[in] | ne | reference to EPUB main structure |
[in,out] | filename | previous filename on input (NULL to get the first one), next filename on output (NULL if no more) |
[out] | filenameLength | length of filename in bytes |
Definition at line 308 of file NE.c.
NEErr NENewFile |
( |
NEPtr |
ne, |
|
|
char const * |
filename |
|
) |
| |
Create a new file in the EPUB.
- Parameters:
-
[in,out] | ne | reference to EPUB main structure |
[in] | filename | filename in document subdirectory, or in EPUB root if it starts with "/" |
- Returns:
- kNEErrOk for success, error code for failure
Definition at line 399 of file NE.c.
NEErr NESetCoverImage |
( |
NEPtr |
ne, |
|
|
char const * |
filename, |
|
|
int |
filenameLen |
|
) |
| |
Specify an image to be used for the cover.
- Parameters:
-
[in,out] | ne | reference to EPUB main structure |
[in] | filename | filename of the cover image (should also be added with NENewFile or NEAddFile) |
[in] | filenameLen | length of filename in bytes, or -1 if null-terminated |
- Returns:
- kNEErrOk for success, error code for failure
Definition at line 244 of file NE.c.
NEErr NEStringAdd |
( |
char ** |
str, |
|
|
char const * |
src, |
|
|
int |
srcLen |
|
) |
| |
Concatenate a string with a linefeed separator character.
- Parameters:
-
[out] | str | null-terminated string allocated by malloc, or NULL |
[in] | src | source string to be concatenated |
[in] | srcLen | length of src in bytes, or -1 if null-terminated |
- Returns:
- kNEErrOk for success, error code for failure
Definition at line 77 of file NE.c.
NEErr NEStringCat |
( |
char ** |
str, |
|
|
char const * |
src, |
|
|
int |
srcLen |
|
) |
| |
Concatenate a string to a string allocated by malloc.
- Parameters:
-
[out] | str | null-terminated string allocated by malloc, or NULL |
[in] | src | source string to be concatenated |
[in] | srcLen | length of src in bytes, or -1 if null-terminated |
- Returns:
- kNEErrOk for success, error code for failure
Definition at line 55 of file NE.c.
NEErr NEStringCopy |
( |
char ** |
str, |
|
|
char const * |
src, |
|
|
int |
srcLen |
|
) |
| |
Copy a string to a sring allocated by malloc.
- Parameters:
-
[in,out] | str | null-terminated string allocated by malloc, or NULL |
[in] | src | source string to be copied |
[in] | srcLen | length of src in bytes, or -1 if null-terminated |
- Returns:
- kNEErrOk for success, error code for failure
Definition at line 34 of file NE.c.
void NEStringFree |
( |
char ** |
str | ) |
|
Deallocated string.
- Parameters:
-
[in,out] | str | string to be deallocated, or NULL |
Definition at line 136 of file NE.c.
char const* NEStringNextPart |
( |
char const * |
str | ) |
|
Find next part after the next linefeed character.
- Parameters:
-
[in] | str | input null-terminated string, or NULL |
- Returns:
- address of string following the next (first) line-feed, or NULL if none
Definition at line 100 of file NE.c.
NEErr NEWriteToFile |
( |
NEPtr |
ne, |
|
|
char const * |
data, |
|
|
int |
len |
|
) |
| |
Add data to the file created with NENewFile.
- Parameters:
-
[in,out] | ne | reference to EPUB main structure |
[in] | data | data |
[in] | len | length of data in bytes |
- Returns:
- kNEErrOk for success, error code for failure
Definition at line 428 of file NE.c.
static NEErr WriteEndnotes |
( |
NEPtr |
ne | ) |
[static] |
Write the file for endnotes.
- Parameters:
-
[in,out] | ne | reference to EPUB main structure |
- Returns:
- kNEErrOk for success, error code for failure
Definition at line 641 of file NE.c.
static NEErr WriteMeta |
( |
NEPtr |
ne, |
|
|
char const * |
name, |
|
|
char const * |
content |
|
) |
| [static] |
Write a meta element.
- Parameters:
-
[in,out] | ne | reference to EPUB main structure |
[in] | name | name |
[in] | content | content |
- Returns:
- kNEErrOk for success, error code for failure
Definition at line 623 of file NE.c.
static NEErr WriteMetadata |
( |
NEPtr |
ne, |
|
|
char const * |
name, |
|
|
char const * |
attr, |
|
|
char const * |
str |
|
) |
| [static] |
Write document metadata.
- Parameters:
-
[in,out] | ne | reference to EPUB main structure |
[in] | name | metadata name in the dc namespace (e.g. "title") |
[in] | attr | if not NULL, attributes ("n1=\"v1" n2="v2" etc.", where names have the proper namespace) |
[in] | str | metadata value |
- Returns:
- kNEErrOk for success, error code for failure
Definition at line 592 of file NE.c.
static NEErr WriteNCX |
( |
NEPtr |
ne | ) |
[static] |
Write the NCX file.
- Parameters:
-
[in,out] | ne | reference to EPUB main structure |
- Returns:
- kNEErrOk for success, error code for failure
Definition at line 795 of file NE.c.
static NEErr WriteOPF |
( |
NEPtr |
ne | ) |
[static] |
Write the OPF file.
- Parameters:
-
[in,out] | ne | reference to EPUB main structure |
- Returns:
- kNEErrOk for success, error code for failure
Definition at line 680 of file NE.c.
|
Generated by Doxygen.
Copyright 2007-2013, Yves Piguet.
All rights reserved.
|
|