23 static int N_EPSF_files;
24 static Dict_t *EPSF_contents;
49 int saw_bb, must_inline, rc;
56 us =
dtmatch(EPSF_contents, str);
60 if (!(fp = fopen(str,
"r"))) {
65 saw_bb = must_inline =
FALSE;
66 while (fgets(line,
sizeof(line), fp)) {
68 (line,
"%%%%BoundingBox: %d %d %d %d", &lx, &ly, &ux, &uy) == 4) {
71 if ((line[0] !=
'%') && strstr(line,
"read")) must_inline =
TRUE;
72 if (saw_bb && must_inline)
break;
83 fstat(fileno(fp), &statbuf);
84 contents = us->
data =
N_GNEW(statbuf.st_size + 1,
char);
85 fseek(fp, 0, SEEK_SET);
86 rc = fread(contents, statbuf.st_size, 1, fp);
87 contents[statbuf.st_size] =
'\0';
91 agerr(
AGWARN,
"BoundingBox not found in epsf file %s\n", str);
142 const char **
s, *bp, *p, *
path;
144 boolean use_stdlib =
TRUE;
148 for (i = 0; use_stdlib && ((p = arglib[i])); i++) {
154 for (s = stdlib; *s; s++) {
159 for (i = 0; (p = arglib[i]) != 0; i++) {
166 else if ((fp = fopen(path,
"r"))) {
167 while ((bp =
Fgets(fp)))
172 agerr(
AGWARN,
"can't open library file %s\n", path);
177 #define FILTER_EPSF 1
192 if ((p[0] ==
'%') && (p[1] ==
'%')
199 while ((c = *p) && (c !=
'\r') && (c !=
'\n')) p++;
200 if ((*p ==
'\r') && (*(p+1) ==
'\n')) p += 2;
205 while ((c = *p) && (c !=
'\r') && (c !=
'\n')) {
209 if ((*p ==
'\r') && (*(p+1) ==
'\n')) p += 2;
227 for (us =
dtfirst(EPSF_contents); us; us =
dtnext(EPSF_contents, us)) {
231 gvputs(job,
"%%BeginDocument:\n");
233 gvputs(job,
"%%EndDocument\n");
234 gvputs(job,
"} bind def\n");
250 while ((c = *(
unsigned char*)s++)) {
253 else if ((c & 0xFC) == 0xC0) {
284 switch (charsetOf (ins)) {
293 agerr (
AGWARN,
"UTF-8 input uses non-Latin1 characters which cannot be handled by this PostScript driver\n");
315 if (base != ins) free (base);
int(* Dtcompar_f)(Dt_t *, void *, void *, Dtdisc_t *)
unsigned int(* Dthash_f)(Dt_t *, void *, Dtdisc_t *)
int gvputc(GVJ_t *job, int c)
void *(* Dtmake_f)(Dt_t *, void *, Dtdisc_t *)
CDT_API Dtmethod_t * Dtoset
int agerr(agerrlevel_t level, const char *fmt,...)
char * ps_string(char *ins, int chset)
CDT_API Dt_t * dtopen(Dtdisc_t *, Dtmethod_t *)
#define PS2INCH(a_points)
char * agget(void *obj, char *name)
int gvputs(GVJ_t *job, const char *s)
void epsf_init(node_t *n)
void epsf_define(GVJ_t *job)
void cat_libfile(GVJ_t *job, const char **arglib, const char **stdlib)
int strncasecmp(const char *s1, const char *s2, unsigned int n)
CGRAPH_API char * agnameof(void *)
void epsf_free(node_t *n)
void *(* Dtmemory_f)(Dt_t *, void *, size_t, Dtdisc_t *)
void agxbinit(agxbuf *xb, unsigned int hint, unsigned char *init)
void epsf_emit_body(GVJ_t *job, usershape_t *us)
const char * safefile(const char *filename)
char * utf8ToLatin1(char *s)
int(* Dtevent_f)(Dt_t *, int, void *, Dtdisc_t *)
void(* Dtfree_f)(Dt_t *, void *, Dtdisc_t *)
void gvprintf(GVJ_t *job, const char *format,...)