Whole document tree
    

Whole document tree

api.h File Reference
Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

api.h File Reference


Defines

#define WMF_ERROR(Z, M)   wmf_error (Z,__FILE__,__LINE__,M)
#define WMF_DEBUG(Z, M)
#define WMF_ASSERT(Z, M)
#define WMF_OPT_ALLOC   (1<<0)
#define WMF_OPT_ARGS   (1<<1)
#define WMF_OPT_FONTDIRS   (1<<2)
#define WMF_OPT_FONTMAP   (1<<3)
#define WMF_OPT_SYS_FONTS   (1<<4)
#define WMF_OPT_SYS_FONTMAP   (1<<5)
#define WMF_OPT_XTRA_FONTS   (1<<6)
#define WMF_OPT_XTRA_FONTMAP   (1<<7)
#define WMF_OPT_GS_FONTMAP   (1<<8)
#define WMF_OPT_FUNCTION   (1<<10)
#define WMF_OPT_MODULE   (1<<11)
#define WMF_OPT_MODULE_DIRS   (1<<12)
#define WMF_OPT_IGNORE_NONFATAL   (1<<14)
#define WMF_OPT_NO_ERROR   (1<<15)
#define WMF_OPT_NO_DEBUG   (1<<16)
#define WMF_OPT_LOG_ERROR   (1<<17)
#define WMF_OPT_LOG_DEBUG   (1<<18)
#define WMF_OPT_DIAGNOSTICS   (1<<19)

Functions

wmf_error_t wmf_api_create (wmfAPI **, unsigned long, wmfAPI_Options *)
wmf_error_t wmf_api_destroy (wmfAPI *)
wmf_error_t wmf_header_read (wmfAPI *)
wmf_error_t wmf_scan (wmfAPI *, unsigned long, wmfD_Rect *)
wmf_error_t wmf_play (wmfAPI *, unsigned long, wmfD_Rect *)
wmf_error_t wmf_size (wmfAPI *, float *, float *)
wmf_error_t wmf_bbuf_input (wmfAPI *, wmfRead, wmfSeek, wmfTell, void *)
wmf_error_t wmf_file_open (wmfAPI *, const char *)
wmf_error_t wmf_file_close (wmfAPI *)
wmf_error_t wmf_mem_open (wmfAPI *, unsigned char *, long)
wmf_error_t wmf_mem_close (wmfAPI *)
wmfStreamwmf_ztream_create (wmfAPI *, gzFile)
wmfStreamwmf_stream_create (wmfAPI *, FILE *)
void wmf_ztream_destroy (wmfAPI *, wmfStream *, char **, unsigned long *)
void wmf_stream_destroy (wmfAPI *, wmfStream *, char **, unsigned long *)
int wmf_stream_printf (wmfAPI *, wmfStream *, char *,...)
void * wmf_malloc (wmfAPI *, size_t)
void * wmf_calloc (wmfAPI *, size_t, size_t)
void * wmf_realloc (wmfAPI *, void *, size_t)
void wmf_free (wmfAPI *, void *)
void wmf_detach (wmfAPI *, void *)
char * wmf_strdup (wmfAPI *, char *)
char * wmf_str_append (wmfAPI *, char *, char *)
char * wmf_strstr (const char *, const char *)
unsigned long wmf_strbuf_grow (wmfAPI *)
wmf_error_t wmf_player_init (wmfAPI *)
U16 wmf_aldus_checksum (wmfAPI *)
U16 wmf_read_16 (wmfAPI *)
U32 wmf_read_32 (wmfAPI *, U16 *, U16 *)
int wmf_file_read (void *)
int wmf_file_seek (void *, long)
long wmf_file_tell (void *)
int wmf_mem_read (void *)
int wmf_mem_seek (void *, long)
long wmf_mem_tell (void *)
int wmf_stream_zputs (char *, void *)
int wmf_stream_rezet (void *)
int wmf_stream_sputs (char *, void *)
int wmf_stream_reset (void *)
void wmf_error (wmfAPI *, char *, int, char *)
void wmf_debug (wmfAPI *, char *, int, char *)
void wmf_printf (wmfAPI *, char *,...)
void wmf_assert (wmfAPI *, char *, int)
char * wmf_help (void)
void wmf_set_viewport_origin (wmfAPI *, wmfD_Coord)
void wmf_status_function (wmfAPI *, void *, wmfStatus)

Define Documentation

#define WMF_ASSERT Z, M
 

Parameters:
Z   the API handle
M   an <expr>, if zero then call wmf_assert()

(debug build only)

#define WMF_DEBUG Z, M
 

Parameters:
Z   the API handle
M   string to send to the debug stream via wmf_debug()

(debug build only)

#define WMF_ERROR Z, M    wmf_error (Z,__FILE__,__LINE__,M)
 

Parameters:
Z   the API handle
M   string to send to the error stream via wmf_error()

#define WMF_OPT_ALLOC   (1<<0)
 

Option to wmf_api_create()

use provided [*]alloc/free functions

#define WMF_OPT_ARGS   (1<<1)
 

Option to wmf_api_create()

check provided command line for --wmf-<option>

#define WMF_OPT_DIAGNOSTICS   (1<<19)
 

Option to wmf_api_create()

emit diagnostic information --wmf-diagnostics

#define WMF_OPT_FONTDIRS   (1<<2)
 

Option to wmf_api_create()

font directories specified

#define WMF_OPT_FONTMAP   (1<<3)
 

Option to wmf_api_create()

font mappings specified

#define WMF_OPT_FUNCTION   (1<<10)
 

Option to wmf_api_create()

initialize device-layer with supplied function

#define WMF_OPT_GS_FONTMAP   (1<<8)
 

Option to wmf_api_create()

use specified ghostscript fontmap file

#define WMF_OPT_IGNORE_NONFATAL   (1<<14)
 

Option to wmf_api_create()

ignore (some) non-fatal errors --wmf-ignore-nonfatal

#define WMF_OPT_LOG_DEBUG   (1<<18)
 

Option to wmf_api_create()

divert debug reports to specified stream

#define WMF_OPT_LOG_ERROR   (1<<17)
 

Option to wmf_api_create()

divert error reports to specified stream

#define WMF_OPT_MODULE   (1<<11)
 

Option to wmf_api_create()

initialize device-layer with specified module

#define WMF_OPT_MODULE_DIRS   (1<<12)
 

Option to wmf_api_create()

check for module also in specified directories

#define WMF_OPT_NO_DEBUG   (1<<16)
 

Option to wmf_api_create()

suppress all debug reports --wmf-debug

#define WMF_OPT_NO_ERROR   (1<<15)
 

Option to wmf_api_create()

suppress all error reports --wmf-error

#define WMF_OPT_SYS_FONTMAP   (1<<5)
 

Option to wmf_api_create()

use specified XML system fontmap file

#define WMF_OPT_SYS_FONTS   (1<<4)
 

Option to wmf_api_create()

use system fonts, if found

#define WMF_OPT_XTRA_FONTMAP   (1<<7)
 

Option to wmf_api_create()

use specified XML non-system fontmap file

#define WMF_OPT_XTRA_FONTS   (1<<6)
 

Option to wmf_api_create()

use non-system fonts, if found


Function Documentation

U16 wmf_aldus_checksum wmfAPI * API
 

Compute the Aldus checksum of the metafile's header.

Parameters:
API   the API handle

(Must read the header first, either via wmf_scan() or by calling wmf_header_read() directly.)

Returns:
Returns the checksum.

wmf_error_t wmf_api_create wmfAPI ** API_return,
unsigned long flags,
wmfAPI_Options * options
 

Creates and initializes an instance of the libwmf library for a specified device layer.

Parameters:
API_return   pointer to a wmfAPI* (the API handle use henceforth)
flags   bitwise OR of WMF_OPT_ options
options   pointer to wmfAPI_Options structure

This is the first and necessary step when using libwmf. Options are passed via the wmfAPI_Options structure and flags. wmf_api_create allocates the wmfAPI structure and initializes the color and font tables, the metafile player, and the device layer. If successful then the pointer to the wmfAPI structure is returned via API_return, otherwise all allocated memory is released and the library exits with an appropriate error.

Returns:
The error state of the library: wmf_E_None indicates successful creation and initialization of the library, and *API_return will be non-zero. For any other error value *API_return will be zero.

wmf_error_t wmf_api_destroy wmfAPI * API
 

Close the device layer, if open, and release all allocated memory attached to the memory manager.

Parameters:
API   the API handle

Returns:
The final error state of the library.

void wmf_assert wmfAPI * API,
char * file,
int line
 

Set the error state of the library to wmf_E_Assert.

Parameters:
API   the API handle
file   file name
line   line number

This should only be called via the macro WMF_ASSERT(API,<expr>) which is defined (for debug builds only) as:
#define WMF_ASSERT(Z,M) if (!(M)) wmf_assert (Z,__FILE__,__LINE__)
i.e., if <expr> evaluates to 0 then call wmf_assert() with current file name and line number.

wmf_error_t wmf_bbuf_input wmfAPI * API,
wmfRead fp_read,
wmfSeek fp_seek,
wmfTell fp_tell,
void * user_data
 

Set custom metafile input-stream handler functions.

Parameters:
API   the API handle
fp_read   function to read a byte
fp_seek   function to set position
fp_tell   function to get position
user_data   handle for user data

libwmf has simple methods for reading either from file or from memory, but many applications will want to use customized variants of these. wmf_bbuf_input() enables this.

typedef int  (*wmfRead) (void* user_data);
typedef int  (*wmfSeek) (void* user_data,long position);
typedef long (*wmfTell) (void* user_data);

wmfRead returns unsigned char cast to int, or EOF (cf. fgetc())

wmfSeek returns (-1) on error, otherwise 0 (cf. fseek())

wmfTell returns (-1) on error, otherwise current position (cf. ftell())

Returns:
Returns the library error state (wmf_E_None on success). Possible library error state of wmf_E_Glitch, if any of the three functions is zero.

void* wmf_calloc wmfAPI * API,
size_t number,
size_t size
 

Allocate memory of specified size and attach to the API's memory manager's internal list.

Parameters:
API   the API handle
number   number or elements
size   size in bytes of memory required by one element

With syntax similar to calloc(), wmf_calloc() allocates number * size bytes of memory and adds a reference to it in the memory manager's list. To free the memory, use wmf_free().

Returns:
Pointer to new memory, or zero on failure. Sets error state wmf_E_InsMem on failure.

void wmf_debug wmfAPI * API,
char * file,
int line,
char * msg
 

Print message to debug stream.

Parameters:
API   the API handle
file   file name
line   line number
msg   message to print

This should only be called via the macro WMF_DEBUG(API,msg) which (in debug builds only) calls wmf_debug() with the current file name and line number.

void wmf_detach wmfAPI * API,
void * mem
 

Detach memory attached to the API's memory manager's internal list.

Parameters:
API   the API handle
mem   pointer to memory previously allocated via the API

This removes the reference in the API's memory manager's internal list, and the memory will not, therefore, be released by wmf_api_destroy(). To free subsequently, use free().

void wmf_error wmfAPI * API,
char * file,
int line,
char * msg
 

Print message to error stream.

Parameters:
API   the API handle
file   file name
line   line number
msg   message to print

This should only be called via the macro WMF_ERROR(API,msg) which calls wmf_error() with the current file name and line number.

wmf_error_t wmf_file_close wmfAPI * API
 

Close metafile input file stream.

Parameters:
API   the API handle

Returns:
Returns the library error state (wmf_E_None on success). Possible library error state of wmf_E_Glitch.

wmf_error_t wmf_file_open wmfAPI * API,
const char * file
 

Open file as metafile.

Parameters:
API   the API handle
file   file name

Simple method for reading from file.

Returns:
Returns the library error state (wmf_E_None on success). Possible library error states of wmf_E_Glitch or wmf_E_BadFile.

int wmf_file_read void * user_data
 

For internal use only.

int wmf_file_seek void * user_data,
long pos
 

For internal use only.

long wmf_file_tell void * user_data
 

For internal use only.

void wmf_free wmfAPI * API,
void * mem
 

Frees memory attached to the API's memory manager's internal list.

Parameters:
API   the API handle
mem   pointer to memory previously allocated via the API

Syntax is similar to free().

wmf_error_t wmf_header_read wmfAPI * API
 

Read the metafile's header.

Parameters:
API   the API handle

(Must read the header first, either via wmf_scan() or by calling wmf_header_read() directly.)

Returns:
Returns the library error state (wmf_E_None on success). Possible library error states of wmf_E_Glitch, wmf_E_BadFormat (bad header), wmf_E_BadFile (no open input stream) and wmf_E_EOF (premature end-of-file).

char* wmf_help void
 

 
Additional wmf-related options:

  --wmf-error[=yes|no]            switch for error reports.
  --wmf-debug[=yes|no]            switch for debug reports, if any.
  --wmf-ignore-nonfatal[=yes|no]  switch to ignore (some) non-fatal errors.
  --wmf-diagnostics               emit diagnostic information.
  --wmf-fontdir=<path>            add <path> to list of font directories.
  --wmf-sys-fonts                 use system fonts, if any found.
  --wmf-sys-fontmap=<file>        use system xml-fontmap file <file>.
  --wmf-xtra-fonts                use non-system fonts, if any found.
  --wmf-xtra-fontmap=<file>       use non-system xml-fontmap file <file>.
  --wmf-gs-fontmap=<file>         use ghostscript file <file>.

Report bugs to <http://www.wvware.com/>.

Returns:
Returns the above as a string.

void* wmf_malloc wmfAPI * API,
size_t size
 

Allocate memory of specified size and attach to the API's memory manager's internal list.

Parameters:
API   the API handle
size   size in bytes of memory required

With syntax similar to malloc(), wmf_malloc() allocates size bytes of memory and adds a reference to it in the memory manager's list. To free the memory, use wmf_free().

Returns:
Pointer to new memory, or zero on failure. Sets error state wmf_E_InsMem on failure.

wmf_error_t wmf_mem_close wmfAPI * API
 

Close metafile input memory stream.

Parameters:
API   the API handle

Returns:
Returns the library error state (wmf_E_None on success).

wmf_error_t wmf_mem_open wmfAPI * API,
unsigned char * mem,
long length
 

Open metafile in memory.

Parameters:
API   the API handle
mem   the metafile in memory
length   the length in bytes of metafile data

Simple method for reading from memory as array of unsigned char.

Returns:
Returns the library error state (wmf_E_None on success). Possible library error state of wmf_E_Glitch.

int wmf_mem_read void * user_data
 

For internal use only.

int wmf_mem_seek void * user_data,
long pos
 

For internal use only.

long wmf_mem_tell void * user_data
 

For internal use only.

wmf_error_t wmf_play wmfAPI * API,
unsigned long flags,
wmfD_Rect * d_r
 

Play the metafile.

Parameters:
API   the API handle
flags   (unused)
d_r   for bounding-box return

Before the metafile can be played, it must be scanned - see wmf_scan().

The first time (and only the first time) the metafile is played, it first calls device_open() for the device layer specified (and initialized) in wmf_api_create(). Then, and also each subsequent time the metafile is played, it calls device_begin(), plays the metafile (with calls to various other device layer functions), and finally it calls device_end(). device_close() is only ever called via wmf_api_destroy().

d_r is recomputed, but should not change.

Returns:
Returns the library error state (wmf_E_None on success).

wmf_error_t wmf_player_init wmfAPI * API
 

For internal use only.

void wmf_printf wmfAPI * API,
char * msg,
...
 

Print formatted message to debug stream.

Parameters:
API   the API handle
msg   message to print

With syntax similar to printf(), wmf_printf() prints formatted output to the debug stream.

U16 wmf_read_16 wmfAPI * API
 

For internal use only.

U32 wmf_read_32 wmfAPI * API,
U16 * u16a,
U16 * u16b
 

For internal use only.

void* wmf_realloc wmfAPI * API,
void * mem,
size_t size
 

(Re)Allocate memory of specified size and attach to the API's memory manager's internal list.

Parameters:
API   the API handle
mem   pointer to memory previously allocated via the API
size   new size in bytes of memory required

With syntax similar to realloc(), wmf_realloc() allocates size bytes of memory and adds a reference to it in the memory manager's list. To free the memory, use wmf_free(). If mem is zero, this is equivalent to a call to wmf_malloc(). If size is zero, the memory is released via wmf_free().

Returns:
Pointer to new memory, or zero on failure. Sets error state wmf_E_InsMem on failure.

wmf_error_t wmf_scan wmfAPI * API,
unsigned long flags,
wmfD_Rect * d_r
 

Scan the metafile.

Parameters:
API   the API handle
flags   (unused)
d_r   for bounding-box return

Before the metafile can be played, it must be scanned. This is because metafile headers do not always provide image size information. Although the device layer (the graphics exporter) is initialized in wmf_api_create(), the output device is not opened until after the metafile is scanned. By scanning, therefore, the device layer can be provided on opening not only with size information but also a list of colors to expect (not including those in raster images) and of other required resources, if necessary. Finally, if scanning fails, then there's certainly no point in playing the metafile.

The bounding box, in device coordinates, is returned in *d_r.

Returns:
Returns the library error state (wmf_E_None on success).

void wmf_set_viewport_origin wmfAPI * API,
wmfD_Coord d_pt
 

Set the device origin coordinate.

Parameters:
API   the API handle
d_pt   origin in device coordinates

Not really recommended.

wmf_error_t wmf_size wmfAPI * API,
float * width,
float * height
 

Get image size.

Parameters:
API   the API handle
width   width return
height   height return

wmf_size() returns image width in *width and image height in *height. If supplied, the metafile header values are used, otherwise the width and height found by wmf_scan() are used.

Returns:
Returns the library error state (wmf_E_None on success). Possible library error state of wmf_E_Glitch (the metafile has not been scanned).

void wmf_status_function wmfAPI * API,
void * context,
wmfStatus function
 

Set a status call-back function.

Parameters:
API   the API handle
context   handle for user data
function   call-back function

The metafile player calls the status function after each record.

char* wmf_str_append wmfAPI * API,
char * pre,
char * post
 

Create concatenatation of two strings and attach to the API's memory manager's internal list.

Parameters:
API   the API handle
pre   a string
post   a string

wmf_str_append() allocates the necessary memory via wmf_malloc(), copies pre into the string and appends post. Use wmf_free() to free the string.

Returns:
Pointer to new string, or zero on failure. Sets error state wmf_E_InsMem on failure, or wmf_E_Glitch if str is zero.

unsigned long wmf_strbuf_grow wmfAPI * API
 

Increase the size of the internal string buffer.

Parameters:
API   the API handle

libwmf maintains an internal buffer for string operations. wmf_strbuf_grow() increases the size by 64.

Returns:
Returns the new size of the buffer. Uses wmf_realloc(), so may set wmf_E_InsMem on failure.

char* wmf_strdup wmfAPI * API,
char * str
 

Duplicate string and attach to the API's memory manager's internal list.

Parameters:
API   the API handle
str   a string

With syntax similar to strdup(), wmf_strdup() allocates the necessary memory via wmf_malloc() and copies the string. Use wmf_free() to free the string.

Returns:
Pointer to new string, or zero on failure. Sets error state wmf_E_InsMem on failure, or wmf_E_Glitch if str is zero.

wmfStream* wmf_stream_create wmfAPI * API,
FILE * out
 

Open an uncompressed character output stream.

Parameters:
API   the API handle
out   descriptor for a file stream; or zero to write to memory

wmf_stream_create() creates a wmfStream (a character-based output stream) for output to a file or, if out is zero, to memory.

Returns:
Returns a wmfStream pointer, or zero on failure. Possible library error states of wmf_E_InsMem or wmf_E_BadFile.

void wmf_stream_destroy wmfAPI * API,
wmfStream * stream,
char ** buffer,
unsigned long * length
 

Close an uncompressed character output stream.

Parameters:
API   the API handle
stream   stream handle
buffer   for memory return
length   for length return

In the case of write-to-memory, on return *buffer is an array of length length.

int wmf_stream_printf wmfAPI * API,
wmfStream * stream,
char * format,
...
 

Formatted print to character output stream.

Parameters:
API   the API handle
stream   stream handle
format   print format

With syntax similar to printf(), wmf_stream_printf() prints a formatted message to a wmfStream character stream.

Returns:
Returns the number of characters written, or zero on failure. Possible library error state of wmf_E_InsMem.

int wmf_stream_reset void * context
 

For internal use only.

int wmf_stream_rezet void * context
 

For internal use only.

int wmf_stream_sputs char * str,
void * context
 

For internal use only.

int wmf_stream_zputs char * str,
void * context
 

For internal use only.

char* wmf_strstr const char * haystack,
const char * needle
 

Substring search.

Parameters:
hatstack   a string
needle   a substring to search for in haystack

With syntax identical to strstr(), wmf_strstr() searches for string needle in string haystack.

Returns:
Pointer to substring needle found in haystack, or zero if not found.

wmfStream* wmf_ztream_create wmfAPI * API,
gzFile out
 

Open a compressed character output stream.

Parameters:
API   the API handle
out   descriptor for a zlib compressed file stream

wmf_ztream_create() creates a wmfStream (a character-based output stream) for output to a file opened via zlib. (Writing compressed data to memory is not currently supported.)

Returns:
Returns a wmfStream pointer, or zero on failure. Possible library error state of wmf_E_InsMem.

void wmf_ztream_destroy wmfAPI * API,
wmfStream * stream,
char ** buffer,
unsigned long * length
 

Close a compressed character output stream.

Parameters:
API   the API handle
stream   stream handle
buffer   (unused)
length   (unused)


Generated at Sun Oct 28 12:22:53 2001 for libwmf by doxygen1.2.9.1 written by Dimitri van Heesch, © 1997-2001