Back to index

texmacs  1.0.7.15
Functions
pdfnames.h File Reference
#include "dpxutil.h"
#include "pdfobj.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

struct ht_tablepdf_new_name_tree (void)
void pdf_delete_name_tree (struct ht_table **names)
int pdf_names_add_object (struct ht_table *names, const void *key, int keylen, pdf_obj *object)
pdf_objpdf_names_lookup_reference (struct ht_table *names, const void *key, int keylen)
pdf_objpdf_names_lookup_object (struct ht_table *names, const void *key, int keylen)
int pdf_names_close_object (struct ht_table *names, const void *key, int keylen)
pdf_objpdf_names_create_tree (struct ht_table *names, long *count, struct ht_table *filter)
char * printable_key (const char *key, int keylen)

Function Documentation

void pdf_delete_name_tree ( struct ht_table **  names)

Definition at line 129 of file pdfnames.c.

{
  ASSERT(names && *names);

  check_objects_defined(*names);

  ht_clear_table(*names);
  RELEASE(*names);
  *names = NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int pdf_names_add_object ( struct ht_table names,
const void *  key,
int  keylen,
pdf_obj object 
)

Definition at line 141 of file pdfnames.c.

{
  struct obj_data *value;

  ASSERT(names && object);

  if (!key || keylen < 1) {
    WARN("Null string used for name tree key.");
    return -1;
  }

  value = ht_lookup_table(names, key, keylen);
  if (!value) {
    value = NEW(1, struct obj_data);
    value->object = object;
    value->closed = 0;
    ht_append_table(names, key, keylen, value);
  } else {
    ASSERT(value->object);
    if (PDF_OBJ_UNDEFINED(value->object)) {
      pdf_transfer_label(object, value->object);
      pdf_release_obj(value->object);
      value->object = object;
    } else {
      WARN("Object @%s already defined.", printable_key(key, keylen));
      pdf_release_obj(object);
      return -1;
    }
  }

  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int pdf_names_close_object ( struct ht_table names,
const void *  key,
int  keylen 
)

Definition at line 220 of file pdfnames.c.

{
  struct obj_data *value;

  ASSERT(names);

  value = ht_lookup_table(names, key, keylen);
  if (!value ||PDF_OBJ_UNDEFINED(value->object) ) {
    WARN("Cannot close undefined object @%s.", printable_key(key, keylen));
    return -1;
  }
  ASSERT(value->object);

  if (value->closed) {
    WARN("Object @%s already closed.", printable_key(key, keylen));
    return -1;
  }

  value->closed = 1;

  return 0;
}

Here is the call graph for this function:

pdf_obj* pdf_names_create_tree ( struct ht_table names,
long *  count,
struct ht_table filter 
)

Definition at line 409 of file pdfnames.c.

{
  pdf_obj *name_tree;
  struct   named_object *flat;

  flat = flat_table(names, count, filter);
  if (!flat)
    name_tree = NULL;
  else {
    qsort(flat, *count, sizeof(struct named_object), cmp_key);
    name_tree = build_name_tree(flat, *count, 1);
    RELEASE(flat);
  }

  return name_tree;
}

Here is the call graph for this function:

Here is the caller graph for this function:

pdf_obj* pdf_names_lookup_object ( struct ht_table names,
const void *  key,
int  keylen 
)

Definition at line 204 of file pdfnames.c.

{
  struct obj_data *value;

  ASSERT(names);

  value = ht_lookup_table(names, key, keylen);
  if (!value || PDF_OBJ_UNDEFINED(value->object))
    return NULL;
  ASSERT(value->object);

  return value->object;
}

Here is the call graph for this function:

pdf_obj* pdf_names_lookup_reference ( struct ht_table names,
const void *  key,
int  keylen 
)

Definition at line 179 of file pdfnames.c.

{
  struct obj_data *value;
  pdf_obj *object;

  ASSERT(names);

  value = ht_lookup_table(names, key, keylen);
  if (value) {
    object = value->object;
  } else {
    /* A null object as dummy would create problems because as value
     * of a dictionary entry, a null object is be equivalent to no entry
     * at all. This matters for optimization of PDF destinations.
     */
    object = pdf_new_undefined();
    pdf_names_add_object(names, key, keylen, object);
  }
  ASSERT(object);

  return pdf_ref_obj(object);
}

Here is the call graph for this function:

struct ht_table* pdf_new_name_tree ( void  ) [read]

Definition at line 94 of file pdfnames.c.

{
  struct ht_table *names;

  names = NEW(1, struct ht_table);
  ht_init_table(names, hval_free);

  return names;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* printable_key ( const char *  key,
int  keylen 
)

Definition at line 52 of file pdfnames.c.

{
#define MAX_KEY 32
  static char pkey[MAX_KEY+4];
  int    i, len;
  unsigned char hi, lo;

  for (i = 0, len = 0;
       i < keylen && len < MAX_KEY; i++) {
    if (isprint(key[i])) {
      pkey[len++] = key[i];
    } else {
      hi = (key[i] >> 4) & 0xff;
      lo =  key[i] & 0xff;
      pkey[len++] = '#';
      pkey[len++] = (hi < 10) ? hi + '0' : (hi - 10) + 'A';
      pkey[len++] = (lo < 10) ? lo + '0' : (lo - 10) + 'A';
    }
  }
  pkey[len] = '\0';

  return (char *) pkey;
}

Here is the caller graph for this function: