nyctergatis.com

Contact

Projects
Sysquake Remote Live
NME
PDF
Hike
Sudoku
GifBuilder
jpeglib for Palm OS
MySQL Client
Cross-GCC for Mac OS
NE.c File Reference

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.

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]nereference to EPUB main structure
[in]endnoteXHTML code for the endnote (without number)
[in]lenlength of endnote in bytes
[in]refDocname of the document containing the reference
[in]refDocLenlength of srcDoc in bytes
[out]refLinkXHTML 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]nereference to EPUB main structure
[in]filenamefile name as seen in the EPUB
[in]pathpath of the original file
Returns:
kNEErrOk for success, error code for failure

Definition at line 323 of file NE.c.

NEErr NEAddMetadata ( NEPtr  ne,
NEMetadataKey  key,
char const *  data,
int  dataLen 
)

Add metadata.

Parameters:
[in,out]nereference to EPUB main structure
[in]keykind of metadata
[in]datametadata value
[in]dataLenlength 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]nereference to EPUB main structure
[in]filenamefilename
[in]filenameLenlength of filename in bytes
[in]mimetypeMIME 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]nereference to EPUB main structure
[in]filenamefilename
[in]auxiliaryTRUE 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]nereference to EPUB main structure
[in]titleentry text
[in]relativeURLrelative URL to the file with an optional anchor
[in]level1 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]nereference to EPUB main structure
[in]filenameEPUB 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.

NEErr NEEnd ( NEPtr  ne)

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]nereference to EPUB main structure
[in,out]filenameprevious filename on input (NULL to get the first one), next filename on output (NULL if no more)
[out]filenameLengthlength 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]nereference to EPUB main structure
[in]filenamefilename 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]nereference to EPUB main structure
[in]filenamefilename of the cover image (should also be added with NENewFile or NEAddFile)
[in]filenameLenlength 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]strnull-terminated string allocated by malloc, or NULL
[in]srcsource string to be concatenated
[in]srcLenlength 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]strnull-terminated string allocated by malloc, or NULL
[in]srcsource string to be concatenated
[in]srcLenlength 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]strnull-terminated string allocated by malloc, or NULL
[in]srcsource string to be copied
[in]srcLenlength 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]strstring 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]strinput 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]nereference to EPUB main structure
[in]datadata
[in]lenlength 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]nereference 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]nereference to EPUB main structure
[in]namename
[in]contentcontent
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]nereference to EPUB main structure
[in]namemetadata name in the dc namespace (e.g. "title")
[in]attrif not NULL, attributes ("n1=\"v1" n2="v2" etc.", where names have the proper namespace)
[in]strmetadata 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]nereference 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]nereference 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.