Data Structures | Defines | Typedefs | Enumerations | Functions

Basic facilities.

Data Structures

struct  hpgs_point_st
 A 2D point. More...
struct  hpgs_color_st
 An application level RGB color. More...
struct  hpgs_palette_color_st
 A screen RGB color as stored in a palette. More...
struct  hpgs_paint_color_st
 An image RGB color with an optional palette index. More...
struct  hpgs_bbox_st
 A bounding box. More...
struct  hpgs_matrix_st
 A transformation matrix for 2D points. More...
struct  hpgs_istream_vtable_st
 A table of virtual function implementing hpgs_istream. More...
struct  hpgs_istream_st
 A virtual input stream for the HPGL reader. More...
struct  hpgs_ostream_vtable_st
 A table of virtual function implementing hpgs_istream. More...
struct  hpgs_ostream_st
 A virtual output stream for the HPGL reader. More...

Defines

#define HPGS_TRUE   1
#define HPGS_FALSE   0
#define HPGS_MIN(a, b)   ((a)<(b)?(a):(b))
#define HPGS_MAX(a, b)   ((a)>(b)?(a):(b))
#define HPGS_INIT_ARRAY(st, type, pmemb, nmemb, szmemb, insz)   (st->szmemb=insz,st->nmemb=0,(st->pmemb=(type*)malloc(sizeof(type)*insz))?0:-1)
#define HPGS_GROW_ARRAY_FOR_PUSH(st, type, pmemb, nmemb, szmemb)   ((st->nmemb >= st->szmemb)?hpgs_array_safe_resize(sizeof(type),(void **)(&st->pmemb),&st->szmemb,st->szmemb*2):(0))
#define HPGS_GROW_ARRAY_MIN_SIZE(st, type, pmemb, nmemb, szmemb, msz)   ((st->nmemb>=st->szmemb||st->szmemb<msz)?hpgs_array_safe_resize(sizeof(type),(void **)(&st->pmemb),&st->szmemb,HPGS_MAX(st->szmemb*2,msz)):(0))
#define HPGS_PATH_SEPARATOR   '/'

Typedefs

typedef int hpgs_bool
typedef void(* hpgs_logger_func_t )(const char *fmt, va_list ap)
typedef struct hpgs_point_st hpgs_point
 A 2D point.
typedef struct hpgs_color_st hpgs_color
 An application level RGB color.
typedef struct
hpgs_palette_color_st 
hpgs_palette_color
typedef void(* hpgs_rop3_func_t )(unsigned char *, unsigned char, unsigned char)
typedef unsigned(* hpgs_xrop3_func_t )(unsigned char, unsigned char)
typedef struct hpgs_paint_color_st hpgs_paint_color
typedef struct hpgs_bbox_st hpgs_bbox
typedef struct hpgs_matrix_st hpgs_matrix
typedef struct hpgs_istream_st hpgs_istream
typedef struct
hpgs_istream_vtable_st 
hpgs_istream_vtable
typedef int(* hpgs_istream_getc_func_t )(void *)
typedef int(* hpgs_istream_ungetc_func_t )(int, void *)
typedef int(* hpgs_istream_close_func_t )(void *)
typedef int(* hpgs_istream_iseof_func_t )(void *)
typedef int(* hpgs_istream_iserror_func_t )(void *)
typedef int(* hpgs_istream_seek_func_t )(void *, size_t)
typedef int(* hpgs_istream_tell_func_t )(void *, size_t *)
typedef size_t(* hpgs_istream_read_func_t )(void *, size_t, size_t, void *)
typedef int(* hpgs_istream_seekend_func_t )(void *, size_t)
typedef struct hpgs_ostream_st hpgs_ostream
typedef struct
hpgs_ostream_vtable_st 
hpgs_ostream_vtable
typedef int(* hpgs_ostream_putc_func_t )(int, void *)
typedef size_t(* hpgs_ostream_write_func_t )(const void *, size_t, size_t, void *)
typedef int(* hpgs_ostream_vprintf_func_t )(void *, const char *, va_list)
typedef int(* hpgs_ostream_flush_func_t )(void *)
typedef int(* hpgs_ostream_close_func_t )(void *)
typedef int(* hpgs_ostream_iserror_func_t )(void *)
typedef hpgs_istream *(* hpgs_ostream_getbuf_func_t )(void *)
typedef int(* hpgs_ostream_tell_func_t )(void *, int layer, size_t *)
typedef int(* hpgs_ostream_seek_func_t )(void *, size_t)

Enumerations

enum  hpgs_line_cap { hpgs_cap_butt = 0, hpgs_cap_round = 1, hpgs_cap_square = 2 }
enum  hpgs_line_join { hpgs_join_miter = 0, hpgs_join_round = 1, hpgs_join_bevel = 2 }

Functions

HPGS_API int hpgs_array_safe_resize (size_t itemsz, void **pptr, size_t *psz, size_t nsz)
HPGS_API void hpgs_init (const char *prefix)
HPGS_API const char * hpgs_get_prefix ()
HPGS_API void hpgs_cleanup (void)
HPGS_API char * hpgs_share_filename (const char *rel_filename)
HPGS_API char * hpgs_vsprintf_malloc (const char *fmt, va_list ap)
HPGS_PRINTF1_API char * hpgs_sprintf_malloc (const char *fmt,...)
HPGS_PRINTF1_API int hpgs_set_error (const char *fmt,...)
HPGS_PRINTF1_API int hpgs_error_ctxt (const char *fmt,...)
HPGS_API int hpgs_set_verror (const char *fmt, va_list ap)
HPGS_API int hpgs_verror_ctxt (const char *fmt, va_list ap)
HPGS_API const char * hpgs_get_error ()
HPGS_API hpgs_bool hpgs_have_error ()
HPGS_API void hpgs_clear_error ()
HPGS_API int hpgs_next_utf8 (const char **p)
HPGS_API int hpgs_utf8_strlen (const char *p, int n)
HPGS_I18N_API const char * hpgs_i18n (const char *msg)
HPGS_I18N_N_API const char * hpgs_i18n_n (const char *msg, const char *msg_plural, unsigned long n)
HPGS_API void hpgs_set_logger (hpgs_logger_func_t func)
HPGS_PRINTF1_API void hpgs_log (const char *fmt,...)
HPGS_API void hpgs_vlog (const char *fmt, va_list ap)
HPGS_API hpgs_bool hpgs_get_arg_value (const char *opt, const char *argv[], const char **value, int *narg)
HPGS_API hpgs_rop3_func_t hpgs_rop3_func (int rop3, hpgs_bool src_transparency, hpgs_bool pattern_transparency)
HPGS_API hpgs_xrop3_func_t hpgs_xrop3_func (int rop3, hpgs_bool src_transparency, hpgs_bool pattern_transparency)
HPGS_API hpgs_bool hpgs_bbox_isequal (const hpgs_bbox *bb1, const hpgs_bbox *bb2)
HPGS_API hpgs_bool hpgs_bbox_isnull (const hpgs_bbox *bb)
HPGS_API hpgs_bool hpgs_bbox_isempty (const hpgs_bbox *bb)
HPGS_API void hpgs_bbox_distance (hpgs_point *d, const hpgs_bbox *bb1, const hpgs_bbox *bb2)
HPGS_API void hpgs_bbox_null (hpgs_bbox *bb)
HPGS_API void hpgs_bbox_expand (hpgs_bbox *bb1, const hpgs_bbox *bb2)
HPGS_API void hpgs_bbox_intersect (hpgs_bbox *bb1, const hpgs_bbox *bb2)
static void hpgs_bbox_addborder (hpgs_bbox *bb, double border)
static void hpgs_bbox_add (hpgs_bbox *bb, const hpgs_point *p)
HPGS_API void hpgs_matrix_set_identity (hpgs_matrix *m)
HPGS_API void hpgs_matrix_xform (hpgs_point *res, const hpgs_matrix *m, const hpgs_point *p)
HPGS_API void hpgs_matrix_ixform (hpgs_point *res, const hpgs_point *p, const hpgs_matrix *m)
HPGS_API void hpgs_matrix_scale (hpgs_point *res, const hpgs_matrix *m, const hpgs_point *p)
HPGS_API void hpgs_matrix_iscale (hpgs_point *res, const hpgs_point *p, const hpgs_matrix *m)
HPGS_API void hpgs_matrix_concat (hpgs_matrix *res, const hpgs_matrix *a, const hpgs_matrix *b)
HPGS_API void hpgs_matrix_invert (hpgs_matrix *res, const hpgs_matrix *m)
HPGS_API void hpgs_matrix_xform_bbox (hpgs_bbox *res, const hpgs_matrix *m, const hpgs_bbox *bb)
HPGS_API void hpgs_matrix_ixform_bbox (hpgs_bbox *res, const hpgs_bbox *bb, const hpgs_matrix *m)
HPGS_API hpgs_istreamhpgs_new_file_istream (const char *fn)
HPGS_API hpgs_istreamhpgs_new_mem_istream (const unsigned char *data, size_t data_size, hpgs_bool dup)
static int hpgs_getc (hpgs_istream *_this)
static int hpgs_ungetc (int c, hpgs_istream *_this)
static int hpgs_istream_close (hpgs_istream *_this)
static int hpgs_istream_iseof (hpgs_istream *_this)
static int hpgs_istream_iserror (hpgs_istream *_this)
static int hpgs_istream_seek (hpgs_istream *_this, size_t pos)
static int hpgs_istream_seekend (hpgs_istream *_this, size_t pos)
static int hpgs_istream_tell (hpgs_istream *_this, size_t *pos)
static size_t hpgs_istream_read (void *ptr, size_t size, size_t nmemb, hpgs_istream *_this)
HPGS_API hpgs_ostreamhpgs_new_file_ostream (const char *fn)
HPGS_API hpgs_ostreamhpgs_new_mem_ostream (size_t data_reserve)
HPGS_API hpgs_ostreamhpgs_new_z_ostream (hpgs_ostream *base, int compression, hpgs_bool take_base)
HPGS_API int hpgs_copy_streams (hpgs_ostream *out, hpgs_istream *in)
HPGS_PRINTF2_API int hpgs_ostream_printf (hpgs_ostream *_this, const char *msg,...)
HPGS_API int hpgs_ostream_vprintf (hpgs_ostream *_this, const char *msg, va_list ap)
static int hpgs_ostream_putc (int c, hpgs_ostream *_this)
static size_t hpgs_ostream_write (const void *ptr, size_t size, size_t nmemb, hpgs_ostream *_this)
static int hpgs_ostream_flush (hpgs_ostream *_this)
static int hpgs_ostream_close (hpgs_ostream *_this)
static int hpgs_ostream_iserror (hpgs_ostream *_this)
static hpgs_istreamhpgs_ostream_getbuf (hpgs_ostream *_this)
static int hpgs_ostream_tell (hpgs_ostream *_this, int layer, size_t *pos)
static int hpgs_ostream_seek (hpgs_ostream *_this, size_t pos)
HPGS_API int hpgs_parse_papersize (const char *str, double *pt_width, double *pt_height)
HPGS_API int hpgs_parse_length (const char *str, double *pt_length)

Detailed Description

This module contains structures for operating on abstract input streams as well as color structures and a 2D point.


Typedef Documentation

typedef struct hpgs_color_st hpgs_color

An application level RGB color.

This structure has a public alias hpgs_color and represents an application level RGB color consisting of double precision r,g and b color values in the range from 0.0 to 1.0.

typedef struct hpgs_point_st hpgs_point

A 2D point.

This structure has a public alias hpgs_point and represents a point consisting of double precision x and y coordinates.


Enumeration Type Documentation

Defines the supported line cap styles.

Enumerator:
hpgs_cap_butt 

Butt line cap.

hpgs_cap_round 

Round line cap.

hpgs_cap_square 

Square line cap.

Defines the supported line join styles.

Enumerator:
hpgs_join_miter 

Miter line join.

hpgs_join_round 

Round line join.

hpgs_join_bevel 

Bevel line join.


Function Documentation

HPGS_API int hpgs_array_safe_resize ( size_t  itemsz,
void **  pptr,
size_t *  psz,
size_t  nsz 
)

This subroutine encapsulates the standard C library function realloc. This is needed in order to aviod hassels when realloc returns a null pointer and the original pointer is still needed for subsequent deallocations.

itemsz is the size of the individual items in the array. pptr is a pointer to the pointer holding te address of the array. On success, *pptr points to the newly allocated array, otherwise *pptr is untouched. psz is a pointer to the allocated size of the array . On success, *psz hold the new size nsz of the array, otherwise *psz is untouched.

Returns 0 upon success or -1 if the system is out of memory.

__inline__ void hpgs_bbox_add ( hpgs_bbox bb,
const hpgs_point p 
) [static]

Expands the bounding box bb in order to comprise the smallest bounding box containing both bb and .

Referenced by hpgs_paint_path_moveto().

__inline__ void hpgs_bbox_addborder ( hpgs_bbox bb,
double  border 
) [static]

Expands the bounding box bb in all directions by the amount of border.

HPGS_API void hpgs_bbox_distance ( hpgs_point d,
const hpgs_bbox bb1,
const hpgs_bbox bb2 
)

Calculates the distance of the two bounding boxes.

References hpgs_bbox_isnull().

HPGS_API void hpgs_bbox_expand ( hpgs_bbox bb1,
const hpgs_bbox bb2 
)

Expands bb1 in order to comprise the smallest bounding box containing both bb1 and bb2

HPGS_API void hpgs_bbox_intersect ( hpgs_bbox bb1,
const hpgs_bbox bb2 
)

Shrinks bb1 in order to comprise the intersection of bb1 and bb2. If the bounding boxes do not intersect, bb1 is set to a null bounding box.

HPGS_API hpgs_bool hpgs_bbox_isempty ( const hpgs_bbox bb  ) 

Returns, whether the bounding box is empty.

HPGS_API hpgs_bool hpgs_bbox_isequal ( const hpgs_bbox bb1,
const hpgs_bbox bb2 
)

Returns, whether the two bounding boxes are equal.

HPGS_API hpgs_bool hpgs_bbox_isnull ( const hpgs_bbox bb  ) 

Returns, whether the bounding box is null. A null bounding box is als empty. An empty bounding box may not be null, if either of the x or y extend of the bounding box is exactly zero.

Referenced by hpgs_bbox_distance().

HPGS_API void hpgs_bbox_null ( hpgs_bbox bb  ) 

Sets this bounding box to an empty bounding box.

Referenced by hpgs_new_paint_path(), hpgs_new_plotsize_device(), and hpgs_paint_path_truncate().

HPGS_API void hpgs_cleanup ( void   ) 

This function has to be called atfer the last usage of hpgs. It cleans up internally allocated resources.

References hpgs_clear_error().

HPGS_API void hpgs_clear_error (  ) 

Clears the error message of the current thread.

Referenced by hpgs_cleanup(), and hpgs_read().

HPGS_PRINTF1_API int hpgs_error_ctxt ( const char *  fmt,
  ... 
)

Prepends the error message of the current thread with the given string. this is useful, if you want to push context information to the error message.

Always returns -1.

References hpgs_verror_ctxt().

Referenced by hpgs_paint_device_fill(), hpgs_read(), and hpgs_reader_do_PCL().

HPGS_API hpgs_bool hpgs_get_arg_value ( const char *  opt,
const char *  argv[],
const char **  value,
int *  narg 
)

Get the value of the command line argument argv[0], if the argument starts with opt.

This subroutine is useful when parsing command lines like in the following loop:

int main(int argc, const char *argv[])
{
  while (argc>1)
    {
      int narg = 1;
      const char *value;
      
      if (hpgs_get_arg_value("-r",argv,&value,&narg))
	{
          ...parse value of option -r...
	}
      else if (hpgs_get_arg_value("-p",argv,&value,&narg))
	{
	  ...parse value of option -p...
	}
      else
	{
	  if (argv[0][0] == '-')
	    {
	      fprintf(stderr,"Error: Unknown option %s given.\n",argv[0]);
	      return usage();
	    }
          break;
	}

      argv+=narg;
      argc-=narg;
    }

Returns HPGS_TRUE, if argv[0] starts with opt. If *narg == 2, argv[0] is exactly opt and *value points to argv[1]. If *narg == 1, argv[0] startwith opt and *value points to argv[0]+strlen(opt).

Returns HPGS_FALSE, if argv[0] does not start with opt.

HPGS_API const char* hpgs_get_error (  ) 

Get the error message of the current thread.

HPGS_API const char* hpgs_get_prefix (  ) 

This function return a pointer to the installation prefix set through hpgs_init. The returned string has any trailing directory separator of the string passed to hpgs_init stripped off.

Referenced by hpgs_share_filename().

__inline__ int hpgs_getc ( hpgs_istream _this  )  [static]
HPGS_API hpgs_bool hpgs_have_error (  ) 

Checks, whther the error message of the current thread has been set.

Referenced by hpgs_paint_device_fill(), and hpgs_read().

HPGS_API void hpgs_init ( const char *  path  ) 

This function has to be called before using any other function of hpgs. It defines the path, where additional files such as the truetype files for HPGL files or plugins are stored.

Truetype fonts are searched in the path <prefix>/share/hpgs

The path is internally duplicated using strdup.

__inline__ int hpgs_istream_close ( hpgs_istream _this  )  [static]

The counterpart of ANSI fclose for hpgs_istream. After calling this function, all allocated resources of the stream are freed.

Referenced by hpgs_destroy_font(), hpgs_destroy_reader(), hpgs_new_reader(), and hpgs_reader_attach().

__inline__ int hpgs_istream_iseof ( hpgs_istream _this  )  [static]

The counterpart of ANSI feof for hpgs_istream.

Referenced by hpgs_read().

__inline__ int hpgs_istream_iserror ( hpgs_istream _this  )  [static]

The counterpart of ANSI ferror for hpgs_istream.

Referenced by hpgs_read().

__inline__ size_t hpgs_istream_read ( void *  ptr,
size_t  size,
size_t  nmemb,
hpgs_istream _this 
) [static]

The counterpart of ANSI fread for hpgs_istream.

__inline__ int hpgs_istream_seek ( hpgs_istream _this,
size_t  pos 
) [static]

The counterpart of ANSI fseek for hpgs_istream.

Referenced by hpgs_read(), hpgs_reader_do_PJL(), and hpgs_reader_imbue().

__inline__ int hpgs_istream_seekend ( hpgs_istream _this,
size_t  pos 
) [static]

The counterpart of ANSI fseek(SEEK_END) for hpgs_istream.

__inline__ int hpgs_istream_tell ( hpgs_istream _this,
size_t *  pos 
) [static]

The counterpart of ANSI ftell for hpgs_istream.

Referenced by hpgs_read(), and hpgs_reader_do_PJL().

HPGS_PRINTF1_API void hpgs_log ( const char *  fmt,
  ... 
)
HPGS_API void hpgs_matrix_concat ( hpgs_matrix res,
const hpgs_matrix a,
const hpgs_matrix b 
)

Concatenates the given matrices a and b. The result is stored in res. Either of the pointer a or may point to the same memory location as the pointer res.

HPGS_API void hpgs_matrix_invert ( hpgs_matrix res,
const hpgs_matrix m 
)

Inverts the given matrix m. The result is stored in res. The pointers m and res may point to the same memory location.

HPGS_API void hpgs_matrix_iscale ( hpgs_point res,
const hpgs_point p,
const hpgs_matrix m 
)

Transforms the given point p with the inverse of the matrix m without applying the translation part of m. This is useful in order to transform delta vectors.

The result is stored in res. The pointers p and res may point to the same memory location.

HPGS_API void hpgs_matrix_ixform ( hpgs_point res,
const hpgs_point p,
const hpgs_matrix m 
)

Transforms the given point p with the inverse of the matrix m. The result is stored in res. The pointers p and res may point to the same memory location.

Referenced by hpgs_matrix_ixform_bbox(), and hpgs_reader_do_PCL().

HPGS_API void hpgs_matrix_ixform_bbox ( hpgs_bbox res,
const hpgs_bbox bb,
const hpgs_matrix m 
)

Transforms the given bounding box bb with the the inverse of the matrix m. The result is the enclosing bounding box of the transformed rectangle of the bounding box and is stored in res. The pointers bb and res may point to the same memory location.

References hpgs_matrix_ixform().

HPGS_API void hpgs_matrix_scale ( hpgs_point res,
const hpgs_matrix m,
const hpgs_point p 
)

Transforms the given point p with the matrix m without applying the translation part of m. This is useful in order to transform delta vectors.

The result is stored in res. The pointers p and res may point to the same memory location.

HPGS_API void hpgs_matrix_set_identity ( hpgs_matrix m  ) 

Sets the given matrix to the identity matrix.

Referenced by hpgs_new_reader().

HPGS_API void hpgs_matrix_xform ( hpgs_point res,
const hpgs_matrix m,
const hpgs_point p 
)

Transforms the given point p with the matrix m. The result is stored in res. The pointers p and res may point to the same memory location.

Referenced by hpgs_matrix_xform_bbox().

HPGS_API void hpgs_matrix_xform_bbox ( hpgs_bbox res,
const hpgs_matrix m,
const hpgs_bbox bb 
)

Transforms the given bounding box bb with the matrix m. The result is the enclosing bounding box of the transformed rectangle of the bounding box and is stored in res. The pointers bb and res may point to the same memory location.

References hpgs_matrix_xform().

HPGS_API hpgs_istream* hpgs_new_file_istream ( const char *  fn  ) 

Returns a new hpgs_istream created on the heap, which operates on a file, which is opened by this call in read-only mode.

Returns a null pointer, when an I/O error occurrs. In this case, details about the the error can be retrieved using errno.

HPGS_API hpgs_ostream* hpgs_new_file_ostream ( const char *  fn  ) 

Returns a new hpgs_ostream created on the heap, which operates on a file, which is opened by this call in write-only mode.

Returns a null pointer, when an I/O error occurrs. In this case, details about the the error can be retrieved using errno.

HPGS_API hpgs_istream* hpgs_new_mem_istream ( const unsigned char *  data,
size_t  data_size,
hpgs_bool  dup 
)

Returns a new hpgs_istream created on the heap, which operates on a chunk of memory in the given location with the given size.

Returns a null pointer, when the system is out of memory.

HPGS_API hpgs_ostream* hpgs_new_mem_ostream ( size_t  data_reserve  ) 

Returns a new hpgs_ostream created on the heap, which operates on a malloced chunk of memory with the preallocated given size.

The memory buffer is realloced when the data grows over the given preallocated size.

Returns a null pointer, when the system is out of memory.

Referenced by hpgs_new_ps_device().

HPGS_API hpgs_ostream* hpgs_new_z_ostream ( hpgs_ostream base,
int  compression,
hpgs_bool  take_base 
)

Returns a new hpgs_ostream created on the heap, which operates on a given hpgs_ostream and writes the given data through a zlib deflate stream using the given compression.

If take_base is false, the stream base is closed, when the returned stream is closed. In this case, don't close it at your own.

Returns a null pointer, when the system is out of memory.

HPGS_API int hpgs_next_utf8 ( const char **  p  ) 

Returns the character code at the given position in an utf-8 string. The pointer (*p) is advanced to the next character after the current position.

Referenced by hpgs_font_decompose_utf8(), hpgs_font_get_utf8_metrics(), and hpgs_utf8_strlen().

__inline__ int hpgs_ostream_close ( hpgs_ostream _this  )  [static]

The counterpart of ANSI fclose for hpgs_ostream. After calling this function, all allocated resources of the stream are freed.

Referenced by hpgs_new_ps_device().

__inline__ int hpgs_ostream_flush ( hpgs_ostream _this  )  [static]

The counterpart of ANSI fflush for hpgs_ostream.

__inline__ hpgs_istream * hpgs_ostream_getbuf ( hpgs_ostream _this  )  [static]

Get the buffer of a hpgs_ostream. This function should only be called after hpgs_ostream_flush.

__inline__ int hpgs_ostream_iserror ( hpgs_ostream _this  )  [static]

The counterpart of ANSI ferror for hpgs_ostream.

HPGS_PRINTF2_API int hpgs_ostream_printf ( hpgs_ostream _this,
const char *  msg,
  ... 
)

The counterpart of ANSI fprintf for hpgs_ostream.

__inline__ int hpgs_ostream_putc ( int  c,
hpgs_ostream _this 
) [static]

The counterpart of ANSI putc for hpgs_ostream.

__inline__ int hpgs_ostream_seek ( hpgs_ostream _this,
size_t  pos 
) [static]

The counterpart of ANSI fseek for hpgs_ostream.

__inline__ int hpgs_ostream_tell ( hpgs_ostream _this,
int  layer,
size_t *  pos 
) [static]

The counterpart of ANSI ftell for hpgs_ostream.

HPGS_API int hpgs_ostream_vprintf ( hpgs_ostream _this,
const char *  msg,
va_list  ap 
)

The counterpart of ANSI fvprintf for hpgs_ostream.

__inline__ size_t hpgs_ostream_write ( const void *  ptr,
size_t  size,
size_t  nmemb,
hpgs_ostream _this 
) [static]

The counterpart of ANSI fwrite for hpgs_ostream.

HPGS_API int hpgs_parse_length ( const char *  str,
double *  pt_length 
)

Parses a physical length with a given unit and returns the length in PostScript pt (1/72 inch).

The following formats are accepted:

     27
     37pt
     4.5inch
     0.37m
     1.5cm
     11.34mm
   

If no unit is specified, PostScript points (1/72 inch) are assumed.

The function returns 0, if the string matches these conventions or -1, if the string is in a wrong format.

Referenced by hpgs_parse_papersize().

HPGS_API int hpgs_parse_papersize ( const char *  str,
double *  pt_width,
double *  pt_height 
)

Parses a physical paper size with a given unit and returns the width and the height of the paper in PostScript pt (1/72 inch).

The standard formats A4,A3,A2,A1 an A0 as well as their landscape counterparts A4l,A3l,A2l,A1l and A0l are accepted.

If the string does not represent a standard paper size, it must be of the format <width>x<height>, where <width> and <height> must follow the convention of hpgs_parse_papersize.

The function returns 0, if the string matches these conventions or -1, if the string is in a wrong format.

References hpgs_parse_length().

HPGS_PRINTF1_API int hpgs_set_error ( const char *  fmt,
  ... 
)
HPGS_API void hpgs_set_logger ( hpgs_logger_func_t  func  ) 

Set the logging function for logging informational messages. If func is NULL, the default logging function, which log to stderr is restored.

Warning: This function is not thread-safe and should be called just after hpgs_init() at the beginning of the program.

HPGS_API int hpgs_set_verror ( const char *  fmt,
va_list  ap 
)

Set the error message of the current thread to the given string.

Always returns -1.

References hpgs_vsprintf_malloc().

Referenced by hpgs_set_error().

HPGS_API char* hpgs_share_filename ( const char *  rel_filename  ) 

Constructs a filename on the heap for a file located in the installation path passed to hpgs_init.

Returns 0, if the system is out of memory.

References hpgs_get_prefix(), and hpgs_sprintf_malloc().

HPGS_PRINTF1_API char* hpgs_sprintf_malloc ( const char *  fmt,
  ... 
)

A counterpart of sprintf, which allocates the result string on the heap an is save against buffer overflows.

Returns 0, if the system is out of memory.

References hpgs_vsprintf_malloc().

Referenced by hpgs_share_filename(), and hpgs_verror_ctxt().

__inline__ int hpgs_ungetc ( int  c,
hpgs_istream _this 
) [static]
HPGS_API int hpgs_utf8_strlen ( const char *  p,
int  n 
)

Returns the number of unicode characters contained in the first n bytes of the given utf-8 string. If the null character is encountered, the interpretation is stopped before the n'th byte.

if n == -1, the string is ultimatively search up to the first occurrence of the null character.

The pointer (*p) is advanced to the next character after the current position.

References hpgs_next_utf8().

Referenced by hpgs_device_stamp().

HPGS_API int hpgs_verror_ctxt ( const char *  fmt,
va_list  ap 
)

Prepends the error message of the current thread with the given string. this is useful, if you want to push context information to the error message.

Always returns -1.

References hpgs_sprintf_malloc(), and hpgs_vsprintf_malloc().

Referenced by hpgs_error_ctxt().

HPGS_API void hpgs_vlog ( const char *  fmt,
va_list  ap 
)

Logs an informational message using the function set with hpgs_set_logger(). If no function is set with hpgs_set_logger(), the message is printed to stderr.

HPGS_API char* hpgs_vsprintf_malloc ( const char *  fmt,
va_list  ap 
)

A counterpart of vsprintf, which allocates the result string on the heap an is save against buffer overflows.

Returns 0, if the system is out of memory.

Referenced by hpgs_set_verror(), hpgs_sprintf_malloc(), and hpgs_verror_ctxt().

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines