Back to index

texmacs  1.0.7.15
Defines | Typedefs | Functions
pst.h File Reference
#include <stdio.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define PST_TYPE_UNKNOWN   -1
#define PST_TYPE_NULL   0
#define PST_TYPE_BOOLEAN   1
#define PST_TYPE_INTEGER   2
#define PST_TYPE_REAL   3
#define PST_TYPE_STRING   5
#define PST_TYPE_NAME   6
#define PST_TYPE_MARK   7
#define PST_NAME_LEN_MAX   127
#define PST_STRING_LEN_MAX   4096
#define PST_MAX_DIGITS   10
#define PST_TOKEN_LEN_MAX   PST_STRING_LEN_MAX
#define PST_NULLTYPE(o)   (pst_type_of((o)) == PST_TYPE_NULL)
#define PST_BOOLEANTYPE(o)   (pst_type_of((o)) == PST_TYPE_BOOLEAN)
#define PST_NAMETYPE(o)   (pst_type_of((o)) == PST_TYPE_NAME)
#define PST_STRINGTYPE(o)   (pst_type_of((o)) == PST_TYPE_STRING)
#define PST_INTEGERTYPE(o)   (pst_type_of((o)) == PST_TYPE_INTEGER)
#define PST_REALTYPE(o)   (pst_type_of((o)) == PST_TYPE_REAL)
#define PST_NUMBERTYPE(o)   (PST_INTEGERTYPE((o))||PST_REALTYPE((o)))
#define PST_MARKTYPE(o)   (pst_type_of((o)) == PST_TYPE_MARK)
#define PST_UNKNOWNTYPE(o)   (pst_type_of((o)) < 0)
#define PST_TOKEN_END(s, e)   ((s) == (e) || is_delim(*(s)) || is_space(*(s)))

Typedefs

typedef struct pst_obj
typedef int pst_type

Functions

pst_objpst_get_token (unsigned char **inbuf, unsigned char *inbufend)
pst_objpst_new_obj (pst_type type, void *data)
void pst_release_obj (pst_obj *obj)
pst_objpst_new_mark (void)
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)

Define Documentation

#define PST_BOOLEANTYPE (   o)    (pst_type_of((o)) == PST_TYPE_BOOLEAN)

Definition at line 63 of file pst.h.

#define PST_INTEGERTYPE (   o)    (pst_type_of((o)) == PST_TYPE_INTEGER)

Definition at line 66 of file pst.h.

#define PST_MARKTYPE (   o)    (pst_type_of((o)) == PST_TYPE_MARK)

Definition at line 69 of file pst.h.

#define PST_MAX_DIGITS   10

Definition at line 59 of file pst.h.

#define PST_NAME_LEN_MAX   127

Definition at line 57 of file pst.h.

#define PST_NAMETYPE (   o)    (pst_type_of((o)) == PST_TYPE_NAME)

Definition at line 64 of file pst.h.

#define PST_NULLTYPE (   o)    (pst_type_of((o)) == PST_TYPE_NULL)

Definition at line 62 of file pst.h.

#define PST_NUMBERTYPE (   o)    (PST_INTEGERTYPE((o))||PST_REALTYPE((o)))

Definition at line 68 of file pst.h.

#define PST_REALTYPE (   o)    (pst_type_of((o)) == PST_TYPE_REAL)

Definition at line 67 of file pst.h.

#define PST_STRING_LEN_MAX   4096

Definition at line 58 of file pst.h.

#define PST_STRINGTYPE (   o)    (pst_type_of((o)) == PST_TYPE_STRING)

Definition at line 65 of file pst.h.

#define PST_TOKEN_END (   s,
 
)    ((s) == (e) || is_delim(*(s)) || is_space(*(s)))

Definition at line 72 of file pst.h.

Definition at line 60 of file pst.h.

#define PST_TYPE_BOOLEAN   1

Definition at line 32 of file pst.h.

#define PST_TYPE_INTEGER   2

Definition at line 33 of file pst.h.

#define PST_TYPE_MARK   7

Definition at line 37 of file pst.h.

#define PST_TYPE_NAME   6

Definition at line 36 of file pst.h.

#define PST_TYPE_NULL   0

Definition at line 31 of file pst.h.

#define PST_TYPE_REAL   3

Definition at line 34 of file pst.h.

#define PST_TYPE_STRING   5

Definition at line 35 of file pst.h.

#define PST_TYPE_UNKNOWN   -1

Definition at line 30 of file pst.h.

#define PST_UNKNOWNTYPE (   o)    (pst_type_of((o)) < 0)

Definition at line 70 of file pst.h.


Typedef Documentation

typedef struct pst_obj

Definition at line 39 of file pst.h.

typedef int pst_type

Definition at line 40 of file pst.h.


Function Documentation

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:

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

Definition at line 105 of file pst.c.

{
  pst_obj *obj = NULL;
  unsigned char c;

  ASSERT(*inbuf <= inbufend && !*inbufend);

  skip_white_spaces(inbuf, inbufend);
  skip_comments(inbuf, inbufend);
  if (*inbuf >= inbufend)
    return NULL;
  c = **inbuf;
  switch (c) {
#if 0
  case '%':
    obj = pst_parse_comment(inbuf, inbufend);
    break;
#endif
  case '/':
    obj = pst_parse_name(inbuf, inbufend);
    break;
  case '[': case '{': /* This is wrong */
    obj = pst_new_mark();
    (*inbuf)++;
    break;
  case '<':
    if (*inbuf + 1 >= inbufend)
      return NULL;
    c = *(*inbuf+1);
    if (c == '<') {
      obj = pst_new_mark();
      *inbuf += 2;
    } else if (isxdigit(c))
      obj = pst_parse_string(inbuf, inbufend);
    else if (c == '~') /* ASCII85 */
      obj = pst_parse_string(inbuf, inbufend);
    break;
  case '(':
    obj = pst_parse_string(inbuf, inbufend);
    break;
  case '>':
    if (*inbuf + 1 >= inbufend || *(*inbuf+1) != '>') {
      ERROR("Unexpected end of ASCII hex string marker.");
    } else  {
      char *mark;

      mark = NEW(3, char);
      mark[0] = '>'; mark[1] = '>'; mark[2] = '\0';
      obj = pst_new_obj(PST_TYPE_UNKNOWN, mark);
      (*inbuf) += 2;
    }
    break;
  case ']': case '}': 
    {
      char *mark;

      mark = NEW(2, char);
      mark[0] = c; mark[1] = '\0';
      obj = pst_new_obj(PST_TYPE_UNKNOWN, mark);
      (*inbuf)++;
    }
    break;
  default:
    if (c == 't' || c == 'f')
      obj = pst_parse_boolean(inbuf, inbufend);
    else if (c == 'n')
      obj = pst_parse_null(inbuf, inbufend);
    else if (c == '+' || c == '-' || isdigit(c) || c == '.')
      obj = pst_parse_number(inbuf, inbufend);
    break;
  }

  if (!obj) {
    obj = pst_parse_any(inbuf, inbufend);
  }

  return obj;
}

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:

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:

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:

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:

Definition at line 153 of file pst_obj.c.

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