Back to index

tetex-bin  3.0
Defines | Functions | Variables
enc.c File Reference
#include "dvipng.h"

Go to the source code of this file.

Defines

#define SKIPCOMMENT(x)   if (*x=='%') while (x<max && *x!='\n') x++;

Functions

struct encodingInitEncoding (char *encoding)
struct encodingFindEncoding (char *encoding)
void ClearEncoding (void)

Variables

struct encodingencodingp = NULL

Define Documentation

#define SKIPCOMMENT (   x)    if (*x=='%') while (x<max && *x!='\n') x++;

Function Documentation

Definition at line 116 of file enc.c.

{
  struct encoding *temp=encodingp;

  while(temp!=NULL) {
    encodingp=encodingp->next;
    free(temp);
    temp=encodingp;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct encoding* FindEncoding ( char *  encoding) [read]

Definition at line 99 of file enc.c.

{
  struct encoding *temp=encodingp;

  /* printf("{%s} \n",encoding); */
  while(temp!=NULL && strcmp(encoding,temp->name)!=0) 
    temp=temp->next;
  if (temp==NULL) {
    temp=InitEncoding(encoding);
    if (temp!=NULL) {
      temp->next=encodingp;
      encodingp=temp;
    }
  }
  return(temp);
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct encoding* InitEncoding ( char *  encoding) [read]

Definition at line 30 of file enc.c.

{
  char *pos,*max,*buf,*enc_file;
  int i;
  struct encoding* encp=NULL;
  struct filemmap fmmap;
  
#ifdef HAVE_KPSE_ENC_FORMATS
  TEMPSTR(enc_file,kpse_find_file(encoding,kpse_enc_format,false));
#else
  TEMPSTR(enc_file,kpse_find_file(encoding,kpse_tex_ps_header_format,false));
#endif
  if (enc_file == NULL) {
    Warning("encoding file %s could not be found",encoding);
    return(NULL);
  }
  DEBUG_PRINT((DEBUG_FT|DEBUG_ENC),("\n  OPEN ENCODING:\t'%s'", enc_file));
  if (MmapFile(enc_file,&fmmap)) return(NULL);
  if ((encp = calloc(sizeof(struct encoding)+strlen(encoding)+1
                   +fmmap.size,1))==NULL) {
    Warning("cannot alloc space for encoding",enc_file);
    UnMmapFile(&fmmap);
    return(NULL);
  }
  encp->name=(char*)encp+sizeof(struct encoding);
  strcpy(encp->name,encoding);
  pos=fmmap.mmap;
  max=fmmap.mmap+fmmap.size;
  buf=encp->name+strlen(encoding)+1;
#define SKIPCOMMENT(x) if (*x=='%') while (x<max && *x!='\n') x++;
  while(pos<max && *pos!='/') {
    SKIPCOMMENT(pos);
    pos++;
  }
  pos++;
  encp->charname[256]=buf;
  while(pos<max && *pos!='[' 
       && *pos!=' ' && *pos!='\t' && *pos!='\n' && *pos!='%') 
    *buf++=*pos++;
  *buf++='\0';
  DEBUG_PRINT(DEBUG_ENC,("\n  PS ENCODING '%s'",
                      encp->charname[256])); 
  while (pos < max && *pos!='[') {
    SKIPCOMMENT(pos);
    pos++;
  }
  while(pos<max && *pos!='/') {
    SKIPCOMMENT(pos);
    pos++;
  }
  i=0;
  while(pos<max && *pos!=']') {
    pos++;
    encp->charname[i++]=buf;
    while(pos<max && *pos!=' ' && *pos!='\t' && *pos!='\n' && *pos!='%') 
      *buf++=*pos++;
    *buf++='\0';
    DEBUG_PRINT(DEBUG_ENC,("\n  PS ENCODING %d '%s'",
               i-1,encp->charname[i-1])); 
    while(pos<max && *pos!='/' && *pos!=']') {
      SKIPCOMMENT(pos);
      pos++;
    }
  }
  UnMmapFile(&fmmap);
  return(encp);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

struct encoding* encodingp = NULL

Definition at line 28 of file enc.c.