Back to index

tetex-bin  3.0
Classes | Defines | Typedefs | Functions | Variables
dmp.c File Reference
#include "config.h"
#include <kpathsea/c-proto.h>
#include <kpathsea/tex-file.h>
#include <kpathsea/c-ctype.h>
#include <kpathsea/c-pathch.h>
#include <math.h>

Go to the source code of this file.

Classes

struct  hcell

Defines

#define PI   3.14159265358979323846
#define POOLMAX   65000 /* total characters in all font and char names */
#define FCOUNT   100 /* maximum number of fonts */
#define SHIFTS   100 /* maximum number of characters with special shifts */
#define line_length   79 /* maximum output line length (must be at least 60) */
#define Hprime   2459 /* much bigger than max(chars/font,fonts/job) */
#define MAXCHARS   2048 /* character codes fall in the range 0..MAXCHARS-1 */
#define LLENGTH   1024 /* one more than maximum line length for troff output */
#define is_specchar(c)   (c<=2) /* does charcode c identify a special char? */
#define LWscale   0.03 /* line width for graphics as a fraction of pointsize */
#define YCORR   12.0 /* V coordinate of reference point in (big) points */
#define tfmpath   kpse_tfm_format
#define dbpath   kpse_mpsupport_format
#define trpath   kpse_troff_font_format
#define new_htab   (Hcell*) calloc((unsigned)Hprime, (unsigned)sizeof(Hcell))
#define special   0 /* the state after printing a `char' expression */
#define normal   1 /* the state value in a quoted string */
#define initial   2 /* initial state */
#define speci   7 /* length of the above string */
#define Speed   ((float) (PI/4.0))

Typedefs

typedef struct hcell Hcell

Functions

void printversionandexit P3H (const_string, const_string, const_string)
void quit P3C (char *, msg1, char *, msg2, char *, msg3)
void add_to_pool P1C (char, c)
int hash P1C (char *, s)
int *hfind P2C (char *, s, Hcell *, htab)
int hfound ()
FILE *fsearch P3C (char *, nam, char *, ext, kpse_file_format_type, format)
void read_fmap P1C (char *, dbase)
void read_char_adj P1C (char *, adjfile)
void read_tfm P1C (int, f)
int scan_desc_line P2C (int, f, char *, lin)
int read_fontdesc P1C (char *, nam)
void print_char P1C (char, cc)
void end_char_string P1C (int, l)
void prepare_font_use ()
void slant_and_ht ()
void finish_last_char ()
void set_num_char P2C (int, f, int, c)
void set_string P1C (char *, cname)
void start_picture ()
void stop_picture ()
void do_font_def P2C (int, n, char *, nam)
float Beval P2C (float *, xx, float, t)
float circangle P1C (float, t)
float circtime P1C (float, a)
void prepare_graphics ()
void do_ellipse P2C (float, a, float, b)
void do_arc P6C (float, cx, float, cy, float, ax, float, ay, float, bx, float, by)
int do_x_cmd P1C (char *, s0)
int do_page ()
void dmp_usage P2C (char *, name, int, status)
int main P2C (int, argc, char **, argv)

Variables

char * banner = "% Written by DMP, Version 0.64"
char * term_banner = "This is DMP, Version 0.64"
char strpool [POOLMAX]
int poolsize = 0
char * texname [FCOUNT]
int font_num [FCOUNT]
float font_design_size [FCOUNT]
struct hcellcharcodes [FCOUNT]
int next_specfnt [FCOUNT]
float charwd [FCOUNT][MAXCHARS]
int nfonts
int shiftchar [SHIFTS]
float shifth [SHIFTS]
float shiftv [SHIFTS]
int shiftptr = 0
int shiftbase [FCOUNT]
int specfnt = FCOUNT
intspecf_tail = &specfnt
FILEtrf
FILEmpxf
struct hcelltrfonts
float unit = 0.0
int h
int v
float cursize
int curfont
float Xslant
float Xheight
char * dbname = "trfonts.map"
char * adjname = "trchars.adj"
int lnno = 0
Hcellfailure
char * arg_tail
int state = initial
int print_col = 0
char font_used [FCOUNT]
int fonts_used
int graphics_used
float str_h1
float str_v
float str_h2
int str_f
float str_size
char specintro [] = "vardef "
Hcellspec_tab = (Hcell*)0
float xx [4] = {1.0, 1.0, 0.8946431597, 0.7071067812}
float yy [4] = {0.0, 0.2652164899, 0.5195704026, 0.7071067812}
float gx
float gy

Class Documentation

struct hcell

Definition at line 129 of file dmp.c.

Class Members
int datum
char * lab

Define Documentation

Definition at line 98 of file dmp.c.

#define FCOUNT   100 /* maximum number of fonts */

Definition at line 59 of file dmp.c.

#define Hprime   2459 /* much bigger than max(chars/font,fonts/job) */

Definition at line 62 of file dmp.c.

#define initial   2 /* initial state */

Definition at line 542 of file dmp.c.

#define is_specchar (   c)    (c<=2) /* does charcode c identify a special char? */

Definition at line 66 of file dmp.c.

#define line_length   79 /* maximum output line length (must be at least 60) */

Definition at line 61 of file dmp.c.

#define LLENGTH   1024 /* one more than maximum line length for troff output */

Definition at line 64 of file dmp.c.

#define LWscale   0.03 /* line width for graphics as a fraction of pointsize */

Definition at line 67 of file dmp.c.

#define MAXCHARS   2048 /* character codes fall in the range 0..MAXCHARS-1 */

Definition at line 63 of file dmp.c.

#define new_htab   (Hcell*) calloc((unsigned)Hprime, (unsigned)sizeof(Hcell))

Definition at line 134 of file dmp.c.

#define normal   1 /* the state value in a quoted string */

Definition at line 541 of file dmp.c.

#define PI   3.14159265358979323846

Definition at line 55 of file dmp.c.

#define POOLMAX   65000 /* total characters in all font and char names */

Definition at line 58 of file dmp.c.

#define SHIFTS   100 /* maximum number of characters with special shifts */

Definition at line 60 of file dmp.c.

#define speci   7 /* length of the above string */

Definition at line 772 of file dmp.c.

#define special   0 /* the state after printing a `char' expression */

Definition at line 540 of file dmp.c.

#define Speed   ((float) (PI/4.0))

Definition at line 871 of file dmp.c.

#define tfmpath   kpse_tfm_format

Definition at line 97 of file dmp.c.

Definition at line 99 of file dmp.c.

#define YCORR   12.0 /* V coordinate of reference point in (big) points */

Definition at line 68 of file dmp.c.


Typedef Documentation

typedef struct hcell Hcell

Function Documentation

int do_page ( )

Definition at line 1154 of file dmp.c.

{
    char buf[LLENGTH];
    char a, *c, *cc;

    h = v = 0;
    while (fgets(buf,LLENGTH,trf)!=NULL) {
       for (c=buf; *c!='\n'; c++)
           if (*c=='\0') quit("Need to increase LLENGTH","","");
       *c = '\0';
       lnno++;
       c = buf;
       while (*c!='\0') {
           switch(*c) {
           case ' ': case '\t': case 'w':
              c++;
              break;
           case 's':
              cursize = get_float(c+1);
              /* GROFF troff output is scaled
                 groff_out(5): The argument to the s command is in scaled
                       points (units of points/n, where n is the argument
                       to the sizescale command  in the DESC file.)  The
                       argument to the x Height command is also in scaled
                       points.
                   sizescale for groff devps is 1000
              */
              if (unit != 0.0) cursize *= unit;
              else cursize /= 1000.0;
              goto iarg;
           case 'f':
              change_font(get_int(c+1));
              goto iarg;
           case 'c':
              if (c[1]=='\0') quit("Bad c command in troff output","","");
              cc = c+2;
              goto set;
           case 'C':
              cc=c; do cc++; while (*cc!=' ' && *cc!='\t' && *cc!='\0');
              goto set;
           case 'N':
              set_num_char(curfont, get_int(c+1));
              goto iarg;
           case 'H':
              h = get_int(c+1);
              goto iarg;
           case 'V':
              v = get_int(c+1);
              goto iarg;
           case 'h':
              h += get_int(c+1);
              goto iarg;
           case 'v':
              v += get_int(c+1);
              goto iarg;
           case '0': case '1': case '2': case '3': case '4':
           case '5': case '6': case '7': case '8': case '9':
              if (c[1]<'0' || c[1]>'9' || c[2]=='\0')
                  quit("Bad nnc command in troff output","","");
              h += 10*(c[0]-'0') + c[1]-'0';
              c++;
              cc = c+2;
              goto set;
           case 'p':
              return 1;
           case 'n':
              (void) get_int(c+1);
              (void) get_int(arg_tail);
              goto iarg;
           case 'D':
              do_graphic(c+1);
              goto eoln;
           case 'x':
              if (!do_x_cmd(c+1)) return 0;
              goto eoln;
           case '#':
              goto eoln;
           case 'F':
                /* GROFF uses this command to report filename */
                goto eoln;
           case 'm':
                /* GROFF uses this command to control color */
              goto eoln;
           case 'u':
                /* GROFF uses this command to output a word with additional
                   white space between characters, not implemented
                */
              quit("Bad command in troff output\n",
                     "change the DESC file for your GROFF PostScript device, ",
                     "remove tcommand");
           case 't':
                /* GROFF uses this command to output a word */
              cc=c; do cc++; while (*cc!=' ' && *cc!='\t' && *cc!='\0');
              a= *cc; *cc='\0';
              set_string(++c);
              c = cc;
              *c = a;
              continue;
           default:
              quit("Bad command in troff output","","");
           }
           continue;
       set:a= *cc; *cc='\0';
           set_char(++c);
           c = cc;
           *c = a;
           continue;
       iarg:c = arg_tail;
       }
    eoln:/* do nothing */;
    }
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 672 of file dmp.c.

{
    float m,x,y;     /* font scale, MetaPost coords of reference point */

    if (str_f>=0) {
       m = str_size/font_design_size[str_f];
       x = str_h1*unit;
       y = YCORR-str_v*unit;
       if (fabs(x)>=4096.0 || fabs(y)>=4096.0 || m>=4096.0 || m<0) {
           warn("text out of range ignored","","");
           end_char_string(67);
       }
       else end_char_string(47);
       fprintf(mpxf,")infont n%d", font_num[str_f]);
       slant_and_ht();
       fprintf(mpxf,",%.5f,%.4f,%.4f);\n", m, x,y);
       str_f = -1;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int hfound ( )

Definition at line 185 of file dmp.c.

{
    if (failure==(Hcell *)0) return 1;
    failure->lab = NULL;
    return 0;
}

Here is the caller graph for this function:

void add_to_pool P1C ( char  ,
c   
)

Definition at line 116 of file dmp.c.

{
    if (poolsize==POOLMAX) quit("Need to increase POOLMAX","","");
    else strpool[poolsize++] = c;
}
int hash P1C ( char *  ,
s   
)

Definition at line 137 of file dmp.c.

{
    register int r;
    for(r=0; *s!=0; s++) {
        /* GROFF - in font metrics file the character name may be 8bit
           groff_font(5): Groff supports eight bit characters;
           groff_out(5): Note that single characters can have the
               eighth  bit  set, as can the names of fonts and special
               characters.
        */
       r = (r<<1) + *(unsigned char*)s;
       while (r>=Hprime) r-=Hprime;
    }
    return r;
}
void read_fmap P1C ( char *  ,
dbase   
)

Definition at line 324 of file dmp.c.

{
    FILE *fin;
    int c;                  /* last character read */
    char *nam;                     /* a font name being read */

    nfonts = 0;
    fin = fsearch(dbase,"",dbpath);
    trfonts = new_htab;
    while ((c=getc(fin))!=EOF) {
       if (nfonts==FCOUNT) quit("Need to increase FCOUNT","","");
       nam = &strpool[poolsize];
       for (;c!='\t'; c=getc(fin)) add_to_pool(c);
       add_to_pool(0);
       *hfind(nam, trfonts) = nfonts;
       texname[nfonts] = &strpool[poolsize];
       do {
           poolsize = texname[nfonts] - strpool;
           do c=getc(fin); while (c=='\t');
           for (;c!='\t' && c!='\n'; c=getc(fin))
              add_to_pool(c);
           add_to_pool(0);
       } while (c=='\t');
       font_num[nfonts] = -1;             /* indicate font is not mounted */
       nfonts++;
    }
    fclose(fin);
}
void read_char_adj P1C ( char *  ,
adjfile   
)

Definition at line 368 of file dmp.c.

{
    FILE* fin;
    char buf[200];
    int i;

    fin = fsearch(adjfile, "", dbpath);
    for (i=0; i<nfonts; i++)
       shiftbase[i] = 0;
    while (fgets(buf,200,fin)!=NULL) {
       if (shiftptr==SHIFTS-1) quit("Need to increase SHIFTS","","");
       if (buf[0]!=' ' && buf[0]!='\t') {
           for (i=0; buf[i]!='\0'; i++)
              if (buf[i]=='\n') buf[i]='\0';
           shiftchar[shiftptr++] = -1;
           shiftbase[*hfind(buf,trfonts)] = shiftptr;
           if (!hfound()) quit(adjfile," refers to unknown font ",buf);
       } else {
           shiftchar[shiftptr] = get_int(buf);
           shifth[shiftptr] = get_float(arg_tail);
           shiftv[shiftptr] = -get_float(arg_tail);
           if (arg_tail==NULL) quit("Bad shift entry : \"",buf,"\"");
           shiftptr++;
       }
    }
    shiftchar[shiftptr++] = -1;
    fclose(fin);
}

Here is the call graph for this function:

void change_font P1C ( int  ,
f   
)

Definition at line 409 of file dmp.c.

{
    FILE* tf;
    long a = 0;
    int sizes[5];    /* file & header lengths, bc, ec, words in wd table */
    long wd[256];    /* the width table (font size relative, scaled 2^20) */
    int i, j;
    long wtmp;              /* needed to a floating exception on certain machines */

    tf = fsearch(texname[f], ".tfm", tfmpath);
    for (i=0; i<5; i++) {
       sizes[i] = getc(tf);
       sizes[i] = (sizes[i]<<8) | (getc(tf) & 0377);
    }
    if (sizes[1]<2 || sizes[2]<0 || sizes[3]<sizes[2]-1 || sizes[3]>255
           || sizes[0]<sizes[1]+sizes[3]-sizes[2]+sizes[4]+7)
       quit("Bad tfm file: ",texname[f],".tfm");
    for (i=2*5; i<28; i++)
       (void) getc(tf);
    for (i=0; i<4; i++)
       a = (a<<8) | (long) (getc(tf) & 0377);
    font_design_size[f] = ((float) a)/1048576.0;
    fseek(tf, (long)(28+4*(sizes[1]+sizes[3]-sizes[2])), 0);
    for (i=0; i<sizes[4]; i++) {
       wd[i] = 0L;
       for (j=0; j<4; j++)
           wd[i] = (wd[i]<<8) | (long) (getc(tf) & 0377);
    }
    fseek(tf, (long)(24+4*sizes[1]), 0);
    for (i=sizes[2]; i<=sizes[3]; i++) {
       wtmp = wd[getc(tf) & 0377];
       charwd[f][i] = ((double) wtmp)/1048576.0/unit;
       for (j=3; --j>=0;)  (void) getc(tf);
    }
    fclose(tf);
}

Here is the call graph for this function:

int read_fontdesc P1C ( char *  ,
nam   
)

Definition at line 489 of file dmp.c.

{
    char buf[200];
    FILE* fin;                     /* input file */
    int f;                  /* internal font number */

    if (unit==0.0) quit("Resolution is not set soon enough","","");
    f = *hfind(nam, trfonts);
    if (!hfound())
       quit("Font was not in map file","","");
    fin = fsearch(nam, "", trpath);
    for (;;) {
       if (fgets(buf,200,fin)==NULL)
           quit("Description file for ",nam," ends unexpectedly");
       if (strncmp(buf,"special",7)==0) {
           *specf_tail = f;
           next_specfnt[f] = FCOUNT;
           specf_tail = &next_specfnt[f];
       } else if (strncmp(buf,"charset",7)==0)
           break;
    }
    charcodes[f] = new_htab;
    while (fgets(buf,200,fin)!=NULL)
       if (scan_desc_line(f, buf) == 0)
           quit(nam," has a bad line in its description file: ",buf);
    fclose(fin);
    return f;
}

Here is the call graph for this function:

void print_char P1C ( char  ,
cc   
)

Definition at line 551 of file dmp.c.

{
    int printable;   /* nonzero if it is safe to print c */
    int l;           /* number of chars in c or the `char' expression */
    int c;           /* equal to cc mod 256, but always positive */

    c = cc&0377;
    printable = isprint(c) && c<128;      /* avoid high-bit-on Latin-1 chars */
    if (printable) l=1;
    else if (c<10) l=5;
    else if (c<100) l=6;
    else l=7;
    if (print_col+l>line_length-2) {
       if (state==normal) {
           putc('"',mpxf);
           state = special;
       }
       putc('\n',mpxf);
       print_col = 0;
    }
    if (state==normal)
       if (printable) putc(c,mpxf);
       else {
           fprintf(mpxf,"\"&char%d",c);
           print_col += 2;
       }
    else {
       if (state==special) {
           putc('&',mpxf);
           print_col++;
       }
       if (printable) {
           fprintf(mpxf,"\"%c",c);
           print_col++;
       } else
           fprintf(mpxf,"char%d",c);
    }
    print_col += l;
    state = printable ? normal : special;
}

Here is the call graph for this function:

void end_char_string P1C ( int  ,
 
)

Definition at line 596 of file dmp.c.

{
    while (state>special) {
       putc('"',mpxf);
       print_col++;
       state--;
    }
    if (print_col+l>line_length) {
       putc('\n',mpxf);
       print_col = 0;
    }
    state = initial;        /* get ready to print the next string */
}
void set_char P1C ( char *  ,
cname   
)

Definition at line 726 of file dmp.c.

{
    float hh;  /* corrected version of h, current horisontal position */

    if (!*cname) return;
    hh = h;
    set_num_char(curfont,*cname);
    hh+= cursize*charwd[curfont][*cname];
    while (*++cname){
       print_char(*cname);
       hh += cursize*charwd[curfont][*cname];
    }
    h = rint(hh);
    finish_last_char();
}

Here is the call graph for this function:

float circangle P1C ( float  ,
t   
)

Definition at line 895 of file dmp.c.

{
    float ti;

    ti = floor(t);
    t -= ti;
    return (float) atan(Beval(yy,t)/Beval(xx,t)) + ti*Speed;
}

Here is the call graph for this function:

float circtime P1C ( float  ,
a   
)

Definition at line 908 of file dmp.c.

{
    int i;
    float t;
    t = a/Speed;
    for (i=2; --i>=0;)
       t += (a - circangle(t))/Speed;
    return t;
}
int do_x_cmd P1C ( char *  ,
s0   
)

Definition at line 1087 of file dmp.c.

{
    float x;
    int n;
    char *s;

    s = s0;
    while (*s==' ' || *s=='\t') s++;
    switch (*s++) {
    case 'r':
       if (unit!=0.0) quit("Attempt to reset resolution","","");
       while (*s!=' ' && *s!='\t') s++;
       unit = get_float(s);
       if (unit<=0.0) quit("Bad resolution: x",s0,"");
       unit = 72.0/unit;
       break;
    case 'f':
       while (*s!=' ' && *s!='\t') s++;
       n = get_int(s);
       if (arg_tail==NULL) quit("Bad font def: x",s0,"");
       s = arg_tail;
       while (*s==' ' || *s=='\t') s++;
       do_font_def(n, s);
       break;
    case 's':
       return 0;
    case 'H':
       while (*s!=' ' && *s!='\t') s++;
       Xheight = get_float(s);
       /* GROFF troff output is scaled
          groff_out(5): The argument to the s command is in scaled
               points (units of points/n, where n is the argument
               to the sizescale command  in the DESC file.)  The
               argument to the x Height command is also in scaled points.
               sizescale for groff devps is 1000
        */
       if(unit != 0.0) Xheight *= unit;
       else Xheight /= 1000.0;
       if (Xheight==cursize) Xheight=0.0;
       break;
    case 'S':
       while (*s!=' ' && *s!='\t') s++;
       Xslant = get_float(s)*(PI/180.0);
       x = cos(Xslant);
       if (-1e-4<x && x<1e-4) quit("Excessive slant","","");
       Xslant = sin(Xslant)/x;
       break;
    default:
       /* do nothing */;
    }
    return 1;
}
int* hfind P2C ( char *  ,
s  ,
Hcell ,
htab   
)

Definition at line 159 of file dmp.c.

{
    register Hcell *p;
    register int cnt = Hprime;
    failure = (Hcell *) 0;
    p = &htab[hash(s)];
    do {
       if (p->lab==NULL) {
           failure = p;
           if (s<&strpool[0] || s>=&strpool[POOLMAX]) {
              p->lab = &strpool[poolsize];
              do add_to_pool(*s); while (*s++!='\0');
           } else p->lab = s;
           return &p->datum;
       }
       if (strcmp(s, p->lab)==0) return &p->datum;
       if (p==htab) p= &htab[Hprime-1];
       else p--;
    } while (--cnt >= 0);
    quit("Need to increase Hprime","","");
    return (int*)0;         /* keep lint happy */
}

Here is the call graph for this function:

int scan_desc_line P2C ( int  ,
f  ,
char *  ,
lin   
)

Definition at line 463 of file dmp.c.

{
    static int lastcode;
    char *s;

    s = &strpool[poolsize];
    while (*lin!=' ' && *lin!='\t' && *lin!='\0')
       add_to_pool(*lin++);
    add_to_pool('\0');
    while (*lin==' ' || *lin=='\t') lin++;
    if (*lin=='"')
       *hfind(s,charcodes[f]) = lastcode;
    else {
       (void) get_float_map(lin);
       (void) get_int(arg_tail);
       lastcode = get_int_map(arg_tail);
       if (arg_tail==NULL) return 0;
       *hfind(s,charcodes[f]) = lastcode;
       if (lastcode<0 || lastcode>=MAXCHARS) return 0;
    }
    return 1;
}

Here is the call graph for this function:

void set_num_char P2C ( int  ,
f  ,
int  ,
c   
)

Definition at line 695 of file dmp.c.

{
    float hh, vv;           /* corrected versions of h, v */
    int i;

    hh = h;
    vv = v;
    for (i=shiftbase[f]; shiftchar[i]>=0; i++)
       if (shiftchar[i]==c) {
           hh += (cursize/unit)*shifth[i];
           vv += (cursize/unit)*shiftv[i];
           break;
       }
    if (c==0) quit("attempt to typeset an invalid character","","");
    if (hh-str_h2>=1.0 || str_h2-hh>=1.0 || vv-str_v>=1.0 || str_v-vv>=1.0
           || f!=str_f || cursize!=str_size) {
       if (str_f>=0) finish_last_char();
       else if (!fonts_used)
           prepare_font_use();     /* first font usage on this page */
       if (!font_used[f])
           first_use(f);    /* first use of font f on this page */
       fprintf(mpxf,"s((");
       print_col = 3;
       str_f=f; str_v=vv; str_h1=hh;
       str_size = cursize;
    }
    print_char(c);
    str_h2 = hh + cursize*charwd[f][c];
}

Here is the call graph for this function:

void do_font_def P2C ( int  ,
n  ,
char *  ,
nam   
)

Definition at line 849 of file dmp.c.

{
    int f, k;

    f = *hfind(nam, trfonts);
    if (!hfound())
       quit("Font ",nam," was not in map file");
    if (font_design_size[f]==0) {
       read_fontdesc(nam);
       read_tfm(f);
    }
    for (k=0; k<nfonts; k++)
       if (font_num[k]==n) font_num[k]= -1;
    font_num[f] = n;
}

Here is the call graph for this function:

float Beval P2C ( float *  ,
xx  ,
float  ,
t   
)

Definition at line 876 of file dmp.c.

{
    float zz[4];
    register int i, j;
    for (i=0; i<=3; i++) zz[i]=xx[i];
    for (i=3; i>0; i--)
       for (j=0; j<i; j++)
           zz[j] += t*(zz[j+1]-zz[j]);
    return zz[0];
}
void do_ellipse P2C ( float  ,
a  ,
float  ,
b   
)

Definition at line 984 of file dmp.c.

{
    fprintf(mpxf, "makepath(pencircle xscaled %.3f\n yscaled %.3f",
       a*unit, b*unit);
    fprintf(mpxf, " shifted (%.3f,%.3f));\n", (gx+.5*a)*unit, gy*unit);
    gx += a;
}

Here is the call graph for this function:

void dmp_usage P2C ( char *  ,
name  ,
int  ,
status   
)

Definition at line 1273 of file dmp.c.

{
    extern KPSEDLL char *kpse_bug_address;
    FILE *f = status == 0 ? stdout : stderr;
    fputs ("Usage: dmp [OPTION]... DITROFFFILE [MPXFILE]\n\
  Translate DITROFFFILE to the MetaPost MPXFILE or standard output.\n\
\n\
--help      display this help and exit\n\
--version   output version information and exit\n", f);
    putc ('\n', f);
    fputs (kpse_bug_address, f);
    exit(status);
}

Here is the call graph for this function:

int main P2C ( int  ,
argc  ,
char **  ,
argv   
)

Definition at line 1287 of file dmp.c.

{
    int more;

    trf = stdin;
    mpxf = stdout;

    kpse_set_progname (argv[0]);

    if (argc == 1) {
      fputs ("dmp: Need one or two file arguments.\n", stderr);
      fputs ("Try `dmp --help' for more information.\n", stderr);
      exit(1);
    } else if (argc > 1 && strcmp (argv[1], "--help") == 0) {
      dmp_usage (argv[0], 0);
    } else if (argc > 1 && strcmp (argv[1], "--version") == 0) {
      printversionandexit (term_banner,
                           "AT&T Bell Laboratories", "John Hobby");
    }
    if (argc>3) dmp_usage(argv[0], 1);
    if (argc>1) {
       trf = fopen(argv[1], "r");
       if (trf==(FILE*)0) {
         fprintf (stderr, "%s: ", argv[0]);
         perror (argv[1]);
         exit(1);
       }
       if (argc>2) {
           mpxf = fopen(argv[2], "w");
           if (mpxf==(FILE*)0) {
             fprintf (stderr, "%s: ", argv[0]);
             perror (argv[2]);
             exit(1);
           }
       }
    }
    fprintf(mpxf, "%s\n", banner);
    read_fmap(dbname);
    read_char_adj(adjname);
    if (do_page()) {
       do {
           h=0; v=0;
           Xslant = Xheight = 0.0;
           start_picture();
           more = do_page();
           stop_picture();
           fprintf(mpxf,"mpxbreak\n");
       } while (more);
    }
    return 0;
}

Here is the call graph for this function:

void warn P3C ( char *  ,
msg1  ,
char *  ,
msg2  ,
char *  ,
msg3   
)

Definition at line 103 of file dmp.c.

{
    fprintf(stderr,"DMP abort at troff output line %d:\n%s%s%s\n",
       lnno, msg1, msg2, msg3);
    exit(1);
}

Here is the call graph for this function:

FILE* fsearch P3C ( char *  ,
nam  ,
char *  ,
ext  ,
kpse_file_format_type  ,
format   
)

Definition at line 198 of file dmp.c.

{
    FILE *f = NULL;
    
    string fname = kpse_find_file (nam, format, true);
    const_string mode = kpse_format_info[format].binmode
                        ? FOPEN_RBIN_MODE
                        : FOPEN_R_MODE;
    if (fname) {
      f = xfopen (fname, mode);
    }
    if (f==NULL) quit("Cannot find ",nam,ext);
    return f;
}
void printversionandexit P3H ( const_string  ,
const_string  ,
const_string   
)
void do_arc P6C ( float  ,
cx  ,
float  ,
cy  ,
float  ,
ax  ,
float  ,
ay  ,
float  ,
bx  ,
float  ,
by   
)

Definition at line 996 of file dmp.c.

{
    float t1, t2;

    t1 = circtime(atan2(ay, ax));
    t2 = circtime(atan2(by, bx));
    if (t2 < t1) t2 += 8.0;
    fprintf(mpxf, "subpath (%.5f,%.5f) of\n", t1, t2);
    fprintf(mpxf, " makepath(pencircle scaled %.3f shifted (%.3f,%.3f));\n",
       2.0*sqrt(ax*ax+ay*ay)*unit, cx*unit, cy*unit);
    gx = cx + bx;
    gy = cy + by;
}

Here is the call graph for this function:

Definition at line 628 of file dmp.c.

{
    int k;

    for (k=0;k<nfonts;k++) font_used[k]=0;
    fonts_used = 1;
    fprintf(mpxf,"string n[];\n");
    fprintf(mpxf,"vardef s(expr t,m,x,y) =\n");
    fprintf(mpxf,"  addto p also t scaled(m*1.00375) shifted(x,y); enddef;\n");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 926 of file dmp.c.

{
    fprintf(mpxf,"vardef D(expr d)expr q =\n");
    fprintf(mpxf," addto p doublepath q withpen pencircle scaled d; enddef;\n");
    graphics_used = 1;
}

Here is the call graph for this function:

Definition at line 653 of file dmp.c.

{
    int i = 0;

    if (Xslant!=0.0) {
       fprintf(mpxf," slanted%.5f",Xslant);
       i++;
    }
    if (Xheight!=cursize && Xheight!=0.0 && cursize!=0.0) {
       fprintf(mpxf," yscaled%.4f", Xheight/cursize);
       i++;
    }
    if (i>0) fprintf(mpxf, "\n ");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 744 of file dmp.c.

{
    fonts_used = graphics_used = 0;
    str_f = -1;
    str_v = 0.0;
    str_h2 = 0.0;
    str_size = 0.0;
    fprintf(mpxf,"begingroup save C,D,p,s,n; picture p; p=nullpicture;\n");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 754 of file dmp.c.

{
    if (str_f>=0) finish_last_char();
    fprintf(mpxf,"p endgroup\n");
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

char* adjname = "trchars.adj"

Definition at line 96 of file dmp.c.

char* arg_tail

Definition at line 223 of file dmp.c.

char* banner = "% Written by DMP, Version 0.64"

Definition at line 41 of file dmp.c.

Definition at line 76 of file dmp.c.

Definition at line 78 of file dmp.c.

Definition at line 92 of file dmp.c.

float cursize

Definition at line 91 of file dmp.c.

char* dbname = "trfonts.map"

Definition at line 95 of file dmp.c.

Definition at line 157 of file dmp.c.

Definition at line 75 of file dmp.c.

Definition at line 74 of file dmp.c.

Definition at line 616 of file dmp.c.

Definition at line 617 of file dmp.c.

Definition at line 618 of file dmp.c.

float gx

Definition at line 924 of file dmp.c.

float gy

Definition at line 924 of file dmp.c.

int h

Definition at line 90 of file dmp.c.

int lnno = 0

Definition at line 100 of file dmp.c.

Definition at line 87 of file dmp.c.

Definition at line 77 of file dmp.c.

Definition at line 79 of file dmp.c.

Definition at line 71 of file dmp.c.

Definition at line 545 of file dmp.c.

Definition at line 83 of file dmp.c.

Definition at line 80 of file dmp.c.

float shifth[SHIFTS]

Definition at line 81 of file dmp.c.

Definition at line 82 of file dmp.c.

float shiftv[SHIFTS]

Definition at line 81 of file dmp.c.

Definition at line 807 of file dmp.c.

Definition at line 85 of file dmp.c.

Definition at line 84 of file dmp.c.

char specintro[] = "vardef "

Definition at line 771 of file dmp.c.

Definition at line 544 of file dmp.c.

Definition at line 621 of file dmp.c.

float str_h1

Definition at line 619 of file dmp.c.

float str_h2

Definition at line 620 of file dmp.c.

float str_size

Definition at line 622 of file dmp.c.

float str_v

Definition at line 619 of file dmp.c.

Definition at line 70 of file dmp.c.

char* term_banner = "This is DMP, Version 0.64"

Definition at line 42 of file dmp.c.

char* texname[FCOUNT]

Definition at line 73 of file dmp.c.

Definition at line 86 of file dmp.c.

struct hcell* trfonts

Definition at line 88 of file dmp.c.

float unit = 0.0

Definition at line 89 of file dmp.c.

int v

Definition at line 90 of file dmp.c.

float Xheight

Definition at line 94 of file dmp.c.

float Xslant

Definition at line 93 of file dmp.c.

float xx[4] = {1.0, 1.0, 0.8946431597, 0.7071067812}

Definition at line 892 of file dmp.c.

float yy[4] = {0.0, 0.2652164899, 0.5195704026, 0.7071067812}

Definition at line 893 of file dmp.c.