Back to index

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

Go to the source code of this file.

Defines

#define PDF_RES_FLUSH_IMMEDIATE   1

Functions

void pdf_init_resources (void)
void pdf_close_resources (void)
long pdf_defineresource (const char *category, const char *resname, pdf_obj *object, int flags)
long pdf_findresource (const char *category, const char *resname)
pdf_objpdf_get_resource_reference (long res_id)

Define Documentation

#define PDF_RES_FLUSH_IMMEDIATE   1

Definition at line 30 of file pdfresource.h.


Function Documentation

void pdf_close_resources ( void  )

Definition at line 157 of file pdfresource.c.

{
  int  i;

  for (i = 0;
       i < PDF_NUM_RESOURCE_CATEGORIES; i++) {
    struct res_cache *rc;
    int    j;

    rc = &resources[i];
    for (j = 0; j < rc->count; j++) {
      pdf_flush_resource(&rc->resources[j]);
      pdf_clean_resource(&rc->resources[j]);
    }
    RELEASE(rc->resources);

    rc->count     = 0;
    rc->capacity  = 0;
    rc->resources = NULL;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

long pdf_defineresource ( const char *  category,
const char *  resname,
pdf_obj object,
int  flags 
)

Definition at line 195 of file pdfresource.c.

{
  int      res_id;
  struct res_cache *rc;
  int      cat_id;
  pdf_res *res = NULL;

  ASSERT(category && object);

  cat_id = get_category(category);
  if (cat_id < 0) {
    ERROR("Unknown resource category: %s", category);
    return -1;
  }

  rc = &resources[cat_id];
  if (resname) {
    for (res_id = 0; res_id < rc->count; res_id++) {
      res = &rc->resources[res_id];
      if (!strcmp(resname, res->ident)) {
       WARN("Resource %s (category: %s) already defined...",
            resname, category);
       pdf_flush_resource(res);
       res->flags    = flags;
       if (flags & PDF_RES_FLUSH_IMMEDIATE) {
         res->reference = pdf_ref_obj(object);
         pdf_release_obj(object);
       } else {
         res->object = object;
       }
       return (long) ((cat_id << 16)|(res_id));
      }
    }
  } else {
    res_id = rc->count;
  }

  if (res_id == rc->count) {
    if (rc->count >= rc->capacity) {
      rc->capacity += CACHE_ALLOC_SIZE;
      rc->resources = RENEW(rc->resources, rc->capacity, pdf_res);
    }
    res = &rc->resources[res_id];

    pdf_init_resource(res);
    if (resname && resname[0] != '\0') {
      res->ident = NEW(strlen(resname) + 1, char);
      strcpy(res->ident, resname);
    }
    res->category = cat_id;
    res->flags    = flags;
    if (flags & PDF_RES_FLUSH_IMMEDIATE) {
      res->reference = pdf_ref_obj(object);
      pdf_release_obj(object);
    } else {
      res->object = object;
    }
    rc->count++;
  }

  return (long) ((cat_id << 16)|(res_id));
}

Here is the call graph for this function:

Here is the caller graph for this function:

long pdf_findresource ( const char *  category,
const char *  resname 
)

Definition at line 288 of file pdfresource.c.

{
  pdf_res *res;
  int      res_id, cat_id;
  struct res_cache *rc;

  ASSERT(resname && category);

  cat_id = get_category(category);
  if (cat_id < 0) {
    ERROR("Unknown resource category: %s", category);
    return -1;
  }

  rc = &resources[cat_id];
  for (res_id = 0; res_id < rc->count; res_id++) {
    res = &rc->resources[res_id];
    if (!strcmp(resname, res->ident)) {
      return (long) (cat_id << 16|res_id);
    }
  }

  return -1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 314 of file pdfresource.c.

{
  int  cat_id, res_id;
  struct res_cache *rc;
  pdf_res *res;

  cat_id = (rc_id >> 16) & 0xffff;
  res_id = rc_id & 0xffff;

  if (cat_id < 0 ||
      cat_id >= PDF_NUM_RESOURCE_CATEGORIES) {
    ERROR("Invalid category ID: %d", cat_id);
    return NULL;
  }
  rc  = &resources[cat_id];
  if (res_id < 0 || res_id >= rc->count) {
    ERROR("Invalid resource ID: %d", res_id);
    return NULL;
  }

  res = &rc->resources[res_id];
  if (!res->reference) {
    if (!res->object) {
      ERROR("Undefined object...");
      return NULL;
    } else {
      res->reference = pdf_ref_obj(res->object);
    }
  }

  return pdf_link_obj(res->reference);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pdf_init_resources ( void  )

Definition at line 144 of file pdfresource.c.

{
  int  i;

  for (i = 0;
       i < PDF_NUM_RESOURCE_CATEGORIES; i++) {
    resources[i].count     = 0;
    resources[i].capacity  = 0;
    resources[i].resources = NULL;
  }
}

Here is the caller graph for this function: