Back to index

wims  3.65+svn20090927
Enumerations | Functions | Variables
texgif.c File Reference
#include "texgif.h"
#include "basic.c"
#include "colors.c"
#include "tfm.c"
#include "gf.c"
#include "font.c"
#include "image.c"
#include "dvi.c"

Go to the source code of this file.

Enumerations

enum  { tt_plain, tt_latex }

Functions

void checktextype (char *p)
void tex (void)
void parms (void)
int main (int argc, char *argv[])

Variables

char * progname
char * tmpdir = "/tmp"
char * fontdir = "/tmp"
char * headerfile = ""
char * texstyle = ""
char * outfile = "/tmp/texgif.gif"
char cwd [1024]
double blacker = 0.4
int basedensity = 100
int density
int compressratio = 1
int wrapexec = 0
int currentcolor
FONT wfont [FONT_NUMBER_LIMIT]
int fontcnt
int textype = tt_plain
char * texname = "tex"

Enumeration Type Documentation

anonymous enum
Enumerator:
tt_plain 
tt_latex 

Definition at line 37 of file texgif.c.


Function Documentation

void checktextype ( char *  p)

Definition at line 49 of file texgif.c.

{
    if(strstr(p,"\\begin{")!=NULL ||
       strstr(p,"\\end{")!=NULL ||
       strstr(p,"\\underset")!=NULL ||
       strstr(p,"\\overset")!=NULL ||
       strstr(p,"\\displaystyle")!=NULL) {
       textype=tt_latex; texname="latex";
    }
}

Here is the caller graph for this function:

int main ( int  argc,
char *  argv[] 
)

Definition at line 126 of file texgif.c.

{
    progname=argv[0];
    parms();
    fontcnt=0;
    tex();
    setreuid(geteuid(),geteuid());setregid(getegid(),getegid());
    dvi();
    return 0;
}

Here is the call graph for this function:

void parms ( void  )

Definition at line 107 of file texgif.c.

{
    char *p;
    int t;
    p=getenv("tmp_dir"); if(p!=NULL && *p!=0) tmpdir=p;
    p=getenv("texgif_tmpdir"); if(p!=NULL && *p!=0) tmpdir=p;
    p=getenv("texgif_fontdir"); if(p!=NULL && *p!=0) fontdir=p;
    p=getenv("texgif_outfile"); if(p!=NULL && *p!=0) outfile=p;
    p=getenv("texgif_texheader"); if(p!=NULL && *p!=0) headerfile=p;
    p=getenv("texgif_style"); if(p!=NULL && *p!=0) texstyle=p;
    p=getenv("texgif_density"); if(p!=NULL && *p!=0) {
       t=atoi(p); if(t>10 && t<1000) basedensity=t;
    }
    p=getenv("texgif_compressratio"); if(p!=NULL && *p!=0) {
       t=atoi(p); if(t>1 && t<=5) compressratio=t;
    }
    if(getcwd(cwd,sizeof(cwd))==NULL) cwd[0]=0;
}

Here is the caller graph for this function:

void tex ( void  )

Definition at line 61 of file texgif.c.

{
    char *src;
    char *hd;
    char fbuf[1024], nbuf[2048];
    char *parmbuf[8];
    FILE *f;
    long int l;
    src=getenv("texgif_src");
    if(src==NULL || *src==0) error("No source.");
    checktextype(src);
    snprintf(fbuf,sizeof(fbuf),"%s/texgif.tex",tmpdir);
    if(*headerfile) {
       if(strstr(headerfile,".tex")==NULL)
         snprintf(nbuf,sizeof(nbuf),"%s.%s",headerfile,texname);
       else
         snprintf(nbuf,sizeof(nbuf),"%s",headerfile);
       f=fopen(nbuf,"r");
       if(f!=NULL) {
           fseek(f,0,SEEK_END); l=ftell(f); fseek(f,0,SEEK_SET);
           if(l>0 && l<FILE_LENGTH_LIMIT) {
              hd=xmalloc(l+16); fread(hd,1,l,f);
           }
           else {l=0; hd="";}
           fclose(f); f=fopen(fbuf,"w");
           fwrite(hd,1,l,f); free(hd);
       }
       else f=fopen(fbuf,"w");
    }
    else f=fopen(fbuf,"w");
    if(textype==tt_plain) {
       fprintf(f,"%s %s %s\n\\end\n",texstyle, src, texstyle); fclose(f);
    }
    else {
       fprintf(f,"{\\newpage\\clearpage\n\
%s %s %s\n\
\\clearpage}\n\
\\end{document}\n",texstyle, src, texstyle); fclose(f);
    }
    chdir(tmpdir);
    parmbuf[0]=texname; parmbuf[1]="texgif"; parmbuf[2]=NULL;
    wrapexec=1;
    execredirected(texname,NULL,NULL,NULL,parmbuf);
    if(cwd[0]) chdir(cwd);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

int basedensity = 100

Definition at line 29 of file texgif.c.

double blacker = 0.4

Definition at line 28 of file texgif.c.

int compressratio = 1

Definition at line 30 of file texgif.c.

Definition at line 32 of file texgif.c.

char cwd[1024]

Definition at line 27 of file texgif.c.

int density

Definition at line 29 of file texgif.c.

int fontcnt

Definition at line 35 of file texgif.c.

char* fontdir = "/tmp"

Definition at line 23 of file texgif.c.

char* headerfile = ""

Definition at line 24 of file texgif.c.

char* outfile = "/tmp/texgif.gif"

Definition at line 26 of file texgif.c.

char* progname

Definition at line 21 of file texgif.c.

char* texname = "tex"

Definition at line 39 of file texgif.c.

char* texstyle = ""

Definition at line 25 of file texgif.c.

Definition at line 38 of file texgif.c.

char* tmpdir = "/tmp"

Definition at line 22 of file texgif.c.

Definition at line 34 of file texgif.c.

int wrapexec = 0

Definition at line 31 of file texgif.c.