Back to index

texmacs  1.0.7.15
Classes | Defines | Typedefs | Functions | Variables
pst_obj.c File Reference
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include "system.h"
#include "mem.h"
#include "error.h"
#include "dpxutil.h"
#include "pst.h"
#include "pst_obj.h"

Go to the source code of this file.

Classes

struct  pst_obj
struct  pst_boolean
struct  pst_integer
struct  pst_real
struct  pst_name
struct  pst_string

Defines

#define TYPE_ERROR()   ERROR("Operation not defined for this type of object.")

Typedefs

typedef char * pst_null

Functions

static pst_booleanpst_boolean_new (char value)
static void pst_boolean_release (pst_boolean *obj)
static long pst_boolean_IV (pst_boolean *obj)
static double pst_boolean_RV (pst_boolean *obj)
static unsigned char * pst_boolean_SV (pst_boolean *obj)
static long pst_boolean_length (pst_boolean *obj)
static void * pst_boolean_data_ptr (pst_boolean *obj)
static pst_integerpst_integer_new (long value)
static void pst_integer_release (pst_integer *obj)
static long pst_integer_IV (pst_integer *obj)
static double pst_integer_RV (pst_integer *obj)
static unsigned char * pst_integer_SV (pst_integer *obj)
static unsigned int pst_integer_length (pst_integer *obj)
static void * pst_integer_data_ptr (pst_integer *obj)
static pst_realpst_real_new (double value)
static void pst_real_release (pst_real *obj)
static long pst_real_IV (pst_real *obj)
static double pst_real_RV (pst_real *obj)
static unsigned char * pst_real_SV (pst_real *obj)
static void * pst_real_data_ptr (pst_real *obj)
static unsigned int pst_real_length (pst_real *obj)
static pst_namepst_name_new (const char *name)
static void pst_name_release (pst_name *obj)
static long pst_name_IV (pst_name *obj)
static double pst_name_RV (pst_name *obj)
static unsigned char * pst_name_SV (pst_name *obj)
static void * pst_name_data_ptr (pst_name *obj)
static unsigned int pst_name_length (pst_name *obj)
static pst_stringpst_string_parse_literal (unsigned char **inbuf, unsigned char *inbufend)
static pst_stringpst_string_parse_hex (unsigned char **inbuf, unsigned char *inbufend)
static pst_stringpst_string_new (unsigned char *str, unsigned int len)
static void pst_string_release (pst_string *obj)
static long pst_string_IV (pst_string *obj)
static double pst_string_RV (pst_string *obj)
static unsigned char * pst_string_SV (pst_string *obj)
static void * pst_string_data_ptr (pst_string *obj)
static unsigned int pst_string_length (pst_string *obj)
pst_objpst_new_obj (pst_type type, void *data)
pst_objpst_new_mark (void)
void pst_release_obj (pst_obj *obj)
pst_type pst_type_of (pst_obj *obj)
long pst_length_of (pst_obj *obj)
long pst_getIV (pst_obj *obj)
double pst_getRV (pst_obj *obj)
unsigned char * pst_getSV (pst_obj *obj)
void * pst_data_ptr (pst_obj *obj)
pst_objpst_parse_boolean (unsigned char **inbuf, unsigned char *inbufend)
pst_objpst_parse_null (unsigned char **inbuf, unsigned char *inbufend)
pst_objpst_parse_number (unsigned char **inbuf, unsigned char *inbufend)
pst_objpst_parse_name (unsigned char **inbuf, unsigned char *inbufend)
pst_objpst_parse_string (unsigned char **inbuf, unsigned char *inbufend)

Variables

static const char * pst_const_null = "null"
static const char * pst_const_mark = "mark"

Class Documentation

struct pst_obj

Definition at line 36 of file pst_obj.c.

Class Members
void * data
pst_type type
struct pst_boolean

Definition at line 50 of file pst_obj.c.

Class Members
char value
struct pst_integer

Definition at line 51 of file pst_obj.c.

Class Members
long value
struct pst_real

Definition at line 52 of file pst_obj.c.

Class Members
double value
struct pst_name

Definition at line 53 of file pst_obj.c.

Class Members
char * value
struct pst_string

Definition at line 54 of file pst_obj.c.

Class Members
long length
unsigned char * value

Define Documentation

#define TYPE_ERROR ( )    ERROR("Operation not defined for this type of object.")

Definition at line 109 of file pst_obj.c.


Typedef Documentation

typedef char* pst_null

Definition at line 49 of file pst_obj.c.


Function Documentation

static void * pst_boolean_data_ptr ( pst_boolean obj) [static]

Definition at line 360 of file pst_obj.c.

{
  ASSERT(obj);
  return (void*) &(obj->value);
}

Here is the caller graph for this function:

static long pst_boolean_IV ( pst_boolean obj) [static]

Definition at line 319 of file pst_obj.c.

{
  ASSERT(obj);
  return (long) obj->value;
}

Here is the caller graph for this function:

static long pst_boolean_length ( pst_boolean obj) [static]

Definition at line 353 of file pst_obj.c.

{
  TYPE_ERROR();
  return 0;
}

Here is the caller graph for this function:

static pst_boolean * pst_boolean_new ( char  value) [static]

Definition at line 303 of file pst_obj.c.

{
  pst_boolean *obj;
  obj = NEW(1, pst_boolean);
  obj->value = value;
  return obj;
}

Here is the caller graph for this function:

static void pst_boolean_release ( pst_boolean obj) [static]

Definition at line 312 of file pst_obj.c.

{
  ASSERT(obj);
  RELEASE(obj);
}

Here is the caller graph for this function:

static double pst_boolean_RV ( pst_boolean obj) [static]

Definition at line 326 of file pst_obj.c.

{
  ASSERT(obj);
  return (double) obj->value;
}

Here is the caller graph for this function:

static unsigned char * pst_boolean_SV ( pst_boolean obj) [static]

Definition at line 333 of file pst_obj.c.

{
  unsigned char *str;

  ASSERT(obj);

  if (obj->value) {
    str = NEW(5, unsigned char);
    memcpy(str, "true", 4);
    str[4] = '\0';
  } else {
    str = NEW(6, unsigned char);
    memcpy(str, "false", 5);
    str[5] = '\0';
  }

  return str;
}

Here is the caller graph for this function:

void* pst_data_ptr ( pst_obj obj)

Definition at line 276 of file pst_obj.c.

{
  char *p = NULL;

  ASSERT(obj);
  switch (obj->type) {
  case PST_TYPE_BOOLEAN: p = pst_boolean_data_ptr(obj->data); break;
  case PST_TYPE_INTEGER: p = pst_integer_data_ptr(obj->data); break;
  case PST_TYPE_REAL:    p = pst_real_data_ptr(obj->data);    break;
  case PST_TYPE_NAME:    p = pst_name_data_ptr(obj->data);    break;
  case PST_TYPE_STRING:  p = pst_string_data_ptr(obj->data);  break;
  case PST_TYPE_NULL:
  case PST_TYPE_MARK: 
    TYPE_ERROR();
    break;
  case PST_TYPE_UNKNOWN:
    p = obj->data;
    break;
  default:
    ERROR("Unrecognized object type: %d", obj->type);
  }

  return (void *)p;
}

Here is the call graph for this function:

Here is the caller graph for this function:

long pst_getIV ( pst_obj obj)

Definition at line 186 of file pst_obj.c.

{
  long iv = 0;

  ASSERT(obj);
  switch (obj->type) {
  case PST_TYPE_BOOLEAN: iv = pst_boolean_IV(obj->data); break;
  case PST_TYPE_INTEGER: iv = pst_integer_IV(obj->data); break;
  case PST_TYPE_REAL:    iv = pst_real_IV(obj->data);    break;
  case PST_TYPE_NAME:    iv = pst_name_IV(obj->data);    break;
  case PST_TYPE_STRING:  iv = pst_string_IV(obj->data);  break;
  case PST_TYPE_NULL:
  case PST_TYPE_MARK: 
    TYPE_ERROR(); 
    break;
  case PST_TYPE_UNKNOWN:
    ERROR("Cannot convert object of type UNKNOWN to integer value.");
    break;
  default:
    ERROR("Unrecognized object type: %d", obj->type);
  }

  return iv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

double pst_getRV ( pst_obj obj)

Definition at line 212 of file pst_obj.c.

{
  double rv = 0.0;

  ASSERT(obj);
  switch (obj->type) {
  case PST_TYPE_BOOLEAN: rv = pst_boolean_RV(obj->data); break;
  case PST_TYPE_INTEGER: rv = pst_integer_RV(obj->data); break;
  case PST_TYPE_REAL:    rv = pst_real_RV(obj->data);    break;
  case PST_TYPE_NAME:    rv = pst_name_RV(obj->data);    break;
  case PST_TYPE_STRING:  rv = pst_string_RV(obj->data);  break;
  case PST_TYPE_NULL:
  case PST_TYPE_MARK:
    TYPE_ERROR();                  
    break;
  case PST_TYPE_UNKNOWN:
    ERROR("Cannot convert object of type UNKNOWN to real value.");
    break;
  default:
    ERROR("Unrecognized object type: %d", obj->type);
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned char* pst_getSV ( pst_obj obj)

Definition at line 239 of file pst_obj.c.

{
  unsigned char *sv = NULL;

  ASSERT(obj);
  switch (obj->type) {
  case PST_TYPE_BOOLEAN: sv = pst_boolean_SV(obj->data); break;
  case PST_TYPE_INTEGER: sv = pst_integer_SV(obj->data); break;
  case PST_TYPE_REAL:    sv = pst_real_SV(obj->data);    break;
  case PST_TYPE_NAME:    sv = pst_name_SV(obj->data);    break;
  case PST_TYPE_STRING:  sv = pst_string_SV(obj->data);  break;
  case PST_TYPE_NULL:
  case PST_TYPE_MARK:
    TYPE_ERROR(); 
    break;
  case PST_TYPE_UNKNOWN:
    {
      long len;

      len = strlen((char *) obj->data);
      if (len > 0) {
       sv = NEW(len+1, unsigned char);
       memcpy(sv, obj->data, len);
       sv[len] = '\0';
      } else {
       sv = NULL;
      }
      break;
    }
  default:
    ERROR("Unrecognized object type: %d", obj->type);
  }

  return sv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void * pst_integer_data_ptr ( pst_integer obj) [static]

Definition at line 446 of file pst_obj.c.

{
  ASSERT(obj);
  return (void*) &(obj->value);
}

Here is the caller graph for this function:

static long pst_integer_IV ( pst_integer obj) [static]

Definition at line 415 of file pst_obj.c.

{
  ASSERT(obj);
  return (long) obj->value;
}

Here is the caller graph for this function:

static unsigned int pst_integer_length ( pst_integer obj) [static]

Definition at line 453 of file pst_obj.c.

{
  TYPE_ERROR();
  return 0;
}

Here is the caller graph for this function:

static pst_integer * pst_integer_new ( long  value) [static]

Definition at line 399 of file pst_obj.c.

{
  pst_integer *obj;
  obj = NEW(1, pst_integer);
  obj->value = value;
  return obj;
}

Here is the caller graph for this function:

static void pst_integer_release ( pst_integer obj) [static]

Definition at line 408 of file pst_obj.c.

{
  ASSERT(obj);
  RELEASE(obj);
}

Here is the caller graph for this function:

static double pst_integer_RV ( pst_integer obj) [static]

Definition at line 422 of file pst_obj.c.

{
  ASSERT(obj);
  return (double) obj->value;
}

Here is the caller graph for this function:

static unsigned char * pst_integer_SV ( pst_integer obj) [static]

Definition at line 429 of file pst_obj.c.

{
  char *value;
  int   len;
  char  fmt_buf[PST_MAX_DIGITS+5];

  ASSERT(obj);

  len = sprintf(fmt_buf, "%ld", obj->value);

  value = NEW(len, char);
  strcpy(value, fmt_buf);

  return (unsigned char *) value;
}

Here is the caller graph for this function:

long pst_length_of ( pst_obj obj)

Definition at line 160 of file pst_obj.c.

{
  long len = 0;

  ASSERT(obj);
  switch (obj->type) {
  case PST_TYPE_BOOLEAN: len = pst_boolean_length(obj->data); break;
  case PST_TYPE_INTEGER: len = pst_integer_length(obj->data); break;
  case PST_TYPE_REAL:    len = pst_real_length(obj->data);    break;
  case PST_TYPE_NAME:    len = pst_name_length(obj->data);    break;
  case PST_TYPE_STRING:  len = pst_string_length(obj->data);  break;
  case PST_TYPE_NULL:
  case PST_TYPE_MARK:
    TYPE_ERROR();                     
    break;
  case PST_TYPE_UNKNOWN:
    len = strlen(obj->data);
    break;
  default:
    ERROR("Unrecognized object type: %d", obj->type);
  }

  return len;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void * pst_name_data_ptr ( pst_name obj) [static]

Definition at line 697 of file pst_obj.c.

{
  ASSERT(obj);
  return obj->value;
}

Here is the caller graph for this function:

static long pst_name_IV ( pst_name obj) [static]

Definition at line 672 of file pst_obj.c.

{
  TYPE_ERROR();
  return 0;
}

Here is the caller graph for this function:

static unsigned int pst_name_length ( pst_name obj) [static]

Definition at line 704 of file pst_obj.c.

{
  ASSERT(obj);
  return strlen(obj->value);
}

Here is the caller graph for this function:

static pst_name * pst_name_new ( const char *  name) [static]

Definition at line 570 of file pst_obj.c.

{
  pst_name *obj;

  obj = NEW(1, pst_name);
  obj->value = NEW(strlen(name)+1, char);
  strcpy(obj->value, name);

  return obj;
}

Here is the caller graph for this function:

static void pst_name_release ( pst_name obj) [static]

Definition at line 582 of file pst_obj.c.

{
  ASSERT(obj);
  if (obj->value)
    RELEASE(obj->value);
  RELEASE(obj);
}

Here is the caller graph for this function:

static double pst_name_RV ( pst_name obj) [static]

Definition at line 679 of file pst_obj.c.

{
  TYPE_ERROR();
  return 0;
}

Here is the caller graph for this function:

static unsigned char * pst_name_SV ( pst_name obj) [static]

Definition at line 686 of file pst_obj.c.

{
  char *value;

  value = NEW(strlen(obj->value)+1, char);
  strcpy(value, obj->value);

  return (unsigned char *) value;
}

Here is the caller graph for this function:

pst_obj* pst_new_mark ( void  )

Definition at line 124 of file pst_obj.c.

Here is the call graph for this function:

Here is the caller graph for this function:

pst_obj* pst_new_obj ( pst_type  type,
void *  data 
)

Definition at line 112 of file pst_obj.c.

{
  pst_obj *obj;

  obj = NEW(1, struct pst_obj);
  obj->type = type;
  obj->data = data;

  return obj;
}

Here is the caller graph for this function:

pst_obj* pst_parse_boolean ( unsigned char **  inbuf,
unsigned char *  inbufend 
)

Definition at line 367 of file pst_obj.c.

{
  if (*inbuf + 4 <= inbufend &&
      memcmp(*inbuf, "true", 4) == 0 &&
      PST_TOKEN_END(*inbuf + 4, inbufend)) {
    *inbuf += 4;
    return pst_new_obj(PST_TYPE_BOOLEAN, pst_boolean_new(1));
  } else if (*inbuf + 5 <= inbufend &&
            memcmp(*inbuf, "false", 5) == 0 &&
            PST_TOKEN_END(*inbuf + 5, inbufend)) {
    *inbuf += 5;
    return pst_new_obj(PST_TYPE_BOOLEAN, pst_boolean_new(0));
  } else
    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

pst_obj* pst_parse_name ( unsigned char **  inbuf,
unsigned char *  inbufend 
)

Definition at line 633 of file pst_obj.c.

{
  unsigned char  wbuf[PST_NAME_LEN_MAX+1];
  unsigned char  c, *p = wbuf, *cur = *inbuf;
  int     len = 0;

  if (*cur != '/')
    return NULL;
  cur++;

  while (!PST_TOKEN_END(cur, inbufend)) {
    c = *cur++;
    if (c == '#') {
      int val;
      if (cur + 2 >= inbufend) {
       WARN("Premature end of input name string.");
       break;
      }
      val = getxpair(&cur);
      if (val <= 0) {
       WARN("Invalid char for name object. (ignored)");
       continue;
      } else
       c = (unsigned char) val;
    }
    if (len < PST_NAME_LEN_MAX)
      *p++ = c;
    len++;
  }
  *p = '\0';

  if (len > PST_NAME_LEN_MAX)
    WARN("String too long for name object. Output will be truncated.");

  *inbuf = cur;
  return pst_new_obj(PST_TYPE_NAME, pst_name_new((char *)wbuf));
}

Here is the call graph for this function:

Here is the caller graph for this function:

pst_obj* pst_parse_null ( unsigned char **  inbuf,
unsigned char *  inbufend 
)

Definition at line 386 of file pst_obj.c.

{
  if (*inbuf + 4 <= inbufend &&
      memcmp(*inbuf, "null", 4) == 0 &&
      PST_TOKEN_END(*inbuf+4, inbufend)) {
    *inbuf += 4;
    return pst_new_obj(PST_TYPE_NULL, (void*)pst_const_null);
  } else
    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

pst_obj* pst_parse_number ( unsigned char **  inbuf,
unsigned char *  inbufend 
)

Definition at line 527 of file pst_obj.c.

{
  unsigned char  *cur;
  long    lval;
  double  dval;

  errno = 0;
  lval = strtol((char *) *inbuf, (char **) (void *) &cur, 10);
  if (errno || *cur == '.' || *cur == 'e' || *cur == 'E') {
    /* real */
    errno = 0;
    dval = strtod((char *) *inbuf, (char **) (void *) &cur);
    if (!errno && PST_TOKEN_END(cur, inbufend)) {
      *inbuf = cur;
      return pst_new_obj(PST_TYPE_REAL, pst_real_new(dval));
    }
  } else if (cur != *inbuf && PST_TOKEN_END(cur, inbufend)) {
    /* integer */
    *inbuf = cur;
    return pst_new_obj(PST_TYPE_INTEGER, pst_integer_new(lval));
  } else if (lval >= 2 && lval <= 36 && *cur == '#' && isalnum(*++cur) &&
            /* strtod allows leading "0x" for hex numbers, but we don't */
            (lval != 16 || (cur[1] != 'x' && cur[1] != 'X'))) {
    /* integer with radix */
    /* Can the base have a (plus) sign? I think yes. */
    errno = 0;
    lval = strtol((char *) cur, (char **) (void *) &cur, lval);
    if (!errno && PST_TOKEN_END(cur, inbufend)) {
      *inbuf = cur;
      return pst_new_obj(PST_TYPE_INTEGER, pst_integer_new(lval));
    }
  }
  /* error */
  return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

pst_obj* pst_parse_string ( unsigned char **  inbuf,
unsigned char *  inbufend 
)

Definition at line 741 of file pst_obj.c.

{
  if (*inbuf + 2 >= inbufend) {
    return NULL;
  } else if (**inbuf == '(')
    return pst_new_obj(PST_TYPE_STRING, pst_string_parse_literal(inbuf, inbufend));
  else if (**inbuf == '<' && *(*inbuf+1) == '~')
    ERROR("ASCII85 string not supported yet.");
  else if (**inbuf == '<')
    return pst_new_obj(PST_TYPE_STRING, pst_string_parse_hex(inbuf, inbufend));
  return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void * pst_real_data_ptr ( pst_real obj) [static]

Definition at line 510 of file pst_obj.c.

{
  ASSERT(obj);

  return (void*) &(obj->value);
}

Here is the caller graph for this function:

static long pst_real_IV ( pst_real obj) [static]

Definition at line 479 of file pst_obj.c.

{
  ASSERT(obj);
  return (long) obj->value;
}

Here is the caller graph for this function:

static unsigned int pst_real_length ( pst_real obj) [static]

Definition at line 518 of file pst_obj.c.

{
  TYPE_ERROR();
  return 0;
}

Here is the caller graph for this function:

static pst_real * pst_real_new ( double  value) [static]

Definition at line 461 of file pst_obj.c.

{
  pst_real *obj;

  obj = NEW(1, pst_real);
  obj->value = value;

  return obj;
}

Here is the caller graph for this function:

static void pst_real_release ( pst_real obj) [static]

Definition at line 472 of file pst_obj.c.

{
  ASSERT(obj);
  RELEASE(obj);
}

Here is the caller graph for this function:

static double pst_real_RV ( pst_real obj) [static]

Definition at line 486 of file pst_obj.c.

{
  ASSERT(obj);
  return (double) obj->value;
}

Here is the caller graph for this function:

static unsigned char * pst_real_SV ( pst_real obj) [static]

Definition at line 493 of file pst_obj.c.

{
  char *value;
  int   len;
  char  fmt_buf[PST_MAX_DIGITS+5];

  ASSERT(obj);

  len = sprintf(fmt_buf, "%.5g", obj->value);

  value = NEW(len, char);
  strcpy(value, fmt_buf);

  return (unsigned char *) value;
}

Here is the caller graph for this function:

void pst_release_obj ( pst_obj obj)

Definition at line 130 of file pst_obj.c.

{
  ASSERT(obj);
  switch (obj->type) {
  case PST_TYPE_BOOLEAN: pst_boolean_release(obj->data); break;
  case PST_TYPE_INTEGER: pst_integer_release(obj->data); break;
  case PST_TYPE_REAL:    pst_real_release(obj->data);    break;
  case PST_TYPE_NAME:    pst_name_release(obj->data);    break;
  case PST_TYPE_STRING:  pst_string_release(obj->data);  break;
  case PST_TYPE_NULL:
  case PST_TYPE_MARK:
    break;
  case PST_TYPE_UNKNOWN:
    if (obj->data)
      RELEASE(obj->data);
    break;
  default:
    ERROR("Unrecognized object type: %d", obj->type);
  }
  RELEASE(obj);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void * pst_string_data_ptr ( pst_string obj) [static]

Definition at line 883 of file pst_obj.c.

{
  ASSERT(obj);
  return obj->value;
}

Here is the caller graph for this function:

static long pst_string_IV ( pst_string obj) [static]

Definition at line 847 of file pst_obj.c.

{
  return (long) pst_string_RV(obj);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static unsigned int pst_string_length ( pst_string obj) [static]

Definition at line 890 of file pst_obj.c.

{
  ASSERT(obj);
  return obj->length;
}

Here is the caller graph for this function:

static pst_string * pst_string_new ( unsigned char *  str,
unsigned int  len 
) [static]

Definition at line 717 of file pst_obj.c.

{
  pst_string *obj;
  obj = NEW(1, pst_string);
  obj->length  = len;
  obj->value = NULL;
  if (len > 0) {
    obj->value = NEW(len, unsigned char);
    if (str)
      memcpy(obj->value, str, len);
  }
  return obj;
}

Here is the caller graph for this function:

static pst_string * pst_string_parse_hex ( unsigned char **  inbuf,
unsigned char *  inbufend 
) [static]

Definition at line 806 of file pst_obj.c.

{
  unsigned char  wbuf[PST_STRING_LEN_MAX];
  unsigned char *cur = *inbuf;
  unsigned long  len = 0;

  if (cur + 2 > inbufend || *cur != '<' ||
      (*cur == '<' && *(cur+1) == '<'))
    return NULL;

  cur++;
  /* PDF Reference does not specify how to treat invalid char */  
  while (cur < inbufend && len < PST_STRING_LEN_MAX) {
    int    hi, lo;
    skip_white_spaces(&cur, inbufend);
    if (*cur == '>')
      break;
    hi = xtoi(*(cur++));
    if (hi < 0) {
      WARN("Invalid char for hex string <%x> treated as <0>.", *(cur-1));
      hi = 0;
    }
    skip_white_spaces(&cur, inbufend);
    if (*cur == '>')
      break;
    /* 0 is appended if final hex digit is missing */
    lo = (cur < inbufend) ? xtoi(*(cur++)) : 0;
    if (lo < 0) {
      WARN("Invalid char for hex string <%x> treated as <0>.", *(cur-1));
      lo = 0;
    }
    wbuf[len++] = (hi << 4) | lo;
  }
  if (*cur++ != '>')
    return NULL;

  *inbuf = cur;
  return pst_string_new(wbuf, len);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static pst_string * pst_string_parse_literal ( unsigned char **  inbuf,
unsigned char *  inbufend 
) [static]

Definition at line 755 of file pst_obj.c.

{
  unsigned char  wbuf[PST_STRING_LEN_MAX];
  unsigned char *cur = *inbuf, c = 0;
  long    len = 0, balance = 1;

  if (cur + 2 > inbufend || *cur != '(')
    return NULL;

  cur++;
  while (cur < inbufend && len < PST_STRING_LEN_MAX && balance > 0) {
    c = *(cur++);
    switch (c) {
    case '\\':
      {
       unsigned char unescaped, valid;
       unescaped = esctouc(&cur, inbufend, &valid);
       if (valid)
         wbuf[len++] = unescaped;
      }
      break;
    case '(':
      balance++;
      wbuf[len++] = '(';
      break;
    case ')':
      balance--;
      if (balance > 0)
       wbuf[len++] = ')';
      break;
      /*
       * An end-of-line marker (\n, \r or \r\n), not preceeded by a backslash,
       * must be converted to single \n.
       */
    case '\r':
      if (cur < inbufend && *cur == '\n')
       cur++;
      wbuf[len++] = '\n';
      break;
    default:
      wbuf[len++] = c;
    }
  }
  if (c != ')')
    return NULL;

  *inbuf  = cur;
  return pst_string_new(wbuf, len);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void pst_string_release ( pst_string obj) [static]

Definition at line 732 of file pst_obj.c.

{
  ASSERT(obj);
  if (obj->value)
    RELEASE(obj->value);
  RELEASE(obj);
}

Here is the caller graph for this function:

static double pst_string_RV ( pst_string obj) [static]

Definition at line 853 of file pst_obj.c.

{
  pst_obj *nobj;
  unsigned char  *p, *end;
  double   rv;

  ASSERT(obj);
  p   = obj->value;
  end = p + obj->length;
  nobj = pst_parse_number(&p, end);
  if (nobj == NULL || p != end)
    ERROR("Cound not convert string to real value.");
  rv = pst_getRV(nobj);
  pst_release_obj(nobj);

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static unsigned char * pst_string_SV ( pst_string obj) [static]

Definition at line 872 of file pst_obj.c.

{
  unsigned char *str = NULL;
  ASSERT(obj);
  str = NEW(obj->length + 1, unsigned char);
  memcpy(str, obj->value, obj->length);
  str[obj->length] = '\0';
  return str;
}

Here is the caller graph for this function:

Definition at line 153 of file pst_obj.c.

{
  ASSERT(obj);
  return obj->type;
}

Variable Documentation

const char* pst_const_mark = "mark" [static]

Definition at line 43 of file pst_obj.c.

const char* pst_const_null = "null" [static]

Definition at line 42 of file pst_obj.c.