Back to index

texmacs  1.0.7.15
Functions
cmap_read.h File Reference
#include <stdio.h>
#include "cmap.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int CMap_parse_check_sig (FILE *fp)
int CMap_parse (CMap *cmap, FILE *fp)

Function Documentation

int CMap_parse ( CMap cmap,
FILE *  fp 
)

Definition at line 525 of file cmap_read.c.

{
  pst_obj  *tok1, *tok2;
  ifreader *input;
  int       status = 0, tmpint = -1;

  ASSERT(cmap && fp);

  input = ifreader_create(fp, file_size(fp), INPUT_BUF_SIZE-1);

  while (status >= 0) {
    tok1 = tok2 = NULL;
    ifreader_read(input, INPUT_BUF_SIZE/2);
    tok1 = pst_get_token(&(input->cursor), input->endptr);
    if (tok1 == NULL)
      break;
    else if (MATCH_NAME(tok1, "CMapName")) {
      if ((tok2 = pst_get_token(&(input->cursor), input->endptr)) == NULL ||
         !(PST_NAMETYPE(tok2) || PST_STRINGTYPE(tok2)) ||
         check_next_token(input, "def") < 0)
       status = -1;
      else
       CMap_set_name(cmap, pst_data_ptr(tok2));
    } else if (MATCH_NAME(tok1, "CMapType")) {
      if ((tok2 = pst_get_token(&(input->cursor), input->endptr)) == NULL ||
         !PST_INTEGERTYPE(tok2) ||
         check_next_token(input, "def") < 0)
       status = -1;
      else
       CMap_set_type(cmap, pst_getIV(tok2));
    } else if (MATCH_NAME(tok1, "WMode")) {
      if ((tok2 = pst_get_token(&(input->cursor), input->endptr)) == NULL ||
         !PST_INTEGERTYPE(tok2) ||
         check_next_token(input, "def") < 0)
       status = -1;
      else
       CMap_set_wmode(cmap, pst_getIV(tok2));
    } else if (MATCH_NAME(tok1, "CIDSystemInfo")) {
      status = do_cidsysteminfo(cmap, input);
    } else if (MATCH_NAME(tok1, "Version") ||
              MATCH_NAME(tok1, "UIDOffset") ||
              MATCH_NAME(tok1, "XUID")) {
       /* Ignore */
    } else if (PST_NAMETYPE(tok1)) {
      /* Possibly usecmap comes next */
      if ((tok2 = pst_get_token(&(input->cursor), input->endptr)) != NULL &&
         MATCH_OP(tok2, "usecmap")) {
       int   id;
       CMap *ucmap;
       id = CMap_cache_find(pst_data_ptr(tok1));
       if (id < 0)
         status = -1;
       else {
         ucmap = CMap_cache_get(id);
         CMap_set_usecmap(cmap, ucmap);
       }
      }
    } else if (MATCH_OP(tok1, "begincodespacerange")) {
      status = do_codespacerange(cmap, input, tmpint);
    } else if (MATCH_OP(tok1, "beginnotdefrange")) {
      status = do_notdefrange(cmap, input, tmpint);
    } else if (MATCH_OP(tok1, "beginnotdefchar")) {
      status = do_notdefchar(cmap, input, tmpint);
    } else if (MATCH_OP(tok1, "beginbfrange")) {
      status = do_bfrange(cmap, input, tmpint);
    } else if (MATCH_OP(tok1, "beginbfchar")) {
      status =  do_bfchar(cmap, input, tmpint);
    } else if (MATCH_OP(tok1, "begincidrange")) {
      status = do_cidrange(cmap, input, tmpint);
    } else if (MATCH_OP(tok1, "begincidchar")) {
      status =  do_cidchar(cmap, input, tmpint);
    } else if (PST_INTEGERTYPE(tok1)) {
      tmpint = pst_getIV(tok1);
    } /* else Simply ignore */
    if (tok1)
      pst_release_obj(tok1);
    if (tok2)
      pst_release_obj(tok2);
  }

  ifreader_destroy(input);

  return (status < 0) ? -1 : CMap_is_valid(cmap);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CMap_parse_check_sig ( FILE *  fp)

Definition at line 501 of file cmap_read.c.

{
  int  result = -1;
  char sig[CMAP_SIG_MAX+1];

  if (!fp)
    return -1;

  rewind(fp);
  if (fread(sig, sizeof(char), CMAP_SIG_MAX, fp) != CMAP_SIG_MAX)
    result = -1;
  else {
    sig[CMAP_SIG_MAX] = 0;
    if (strncmp(sig, "%!PS", 4))
      result = -1;
    else if (strstr(sig+4, "Resource-CMap"))
      result = 0;
  }
  rewind(fp);

  return result;
}

Here is the caller graph for this function: