| 1 |
/* FILE: psearch.h |
| 2 |
* PURPOSE: PATH search module |
| 3 |
* VERSION: 1.0 (Oct. 1995) |
| 4 |
* AUTHOR: Piet Tutelaers |
| 5 |
* (see README for license) |
| 6 |
*/ |
| 7 |
|
| 8 |
#include <sys/types.h> |
| 9 |
#include <sys/stat.h> |
| 10 |
|
| 11 |
/* |
| 12 |
* This function initiates a path by using a built-in <deFault> and |
| 13 |
* a PATH environment variable that can be set at run time by the user. |
| 14 |
* A typical usage is |
| 15 |
* userenv = path(".:/someplace", getenv("USERENV")) |
| 16 |
* |
| 17 |
* If USERENV is not set getenv("USERENV") returns NULL and the returned |
| 18 |
* path equals the value of the first argument. Otherwise the returned |
| 19 |
* path is the value of second argument in which empty path elements are |
| 20 |
* replaced by <deFault>. For example when USERENV is set to "~/myplace:" |
| 21 |
* the resulting path will be "~myplace:.:/someplace". |
| 22 |
*/ |
| 23 |
char *path(char *deFault, char *env); |
| 24 |
|
| 25 |
/* |
| 26 |
* This function substitutes the <patterns> encountered in <str> |
| 27 |
* with their corresponding <value>. Recognized patterns are %b, %d, |
| 28 |
* %f, %F and %m. They will be replaced with their corresponding integer |
| 29 |
* (%b, %d) or string values (%f, %F and %m). These values can be used as |
| 30 |
* placeholders for basic resolution (%b), resolution (%d), font name |
| 31 |
* (%f or %F) or mode definition (%m). The %F is a special case for |
| 32 |
* representing the fontname leftadjusted in a string of eight characters. |
| 33 |
*/ |
| 34 |
void substitute(char *str, char *patterns, ...); |
| 35 |
|
| 36 |
#define NONFATAL 0 |
| 37 |
#undef FATAL |
| 38 |
#define FATAL 1 |
| 39 |
/* |
| 40 |
* Look for a <file> in <path>. Return absolute filename if found. |
| 41 |
* If not found return NULL (if <terminate> is NONFATAL) or terminate |
| 42 |
* program with appropriate message (if <terminate> is FATAL). |
| 43 |
* On UNIX ~ or ~someone in paths are evaluated to the proper HOME |
| 44 |
* directories. |
| 45 |
* When the path does contain recursion characters ("//" on UNIX and |
| 46 |
* "!!" on MSDOS) directories are searched recursively. |
| 47 |
*/ |
| 48 |
char *search_file(char *path, char *file, int terminate); |
| 49 |
|
| 50 |
/* set global paramaters for PK font search */ |
| 51 |
void init_pksearch(int bdpi, char *mode, int margin, char *tolerance); |
| 52 |
|
| 53 |
/* |
| 54 |
* Look for a PK <font> of resolution <dpi> in <path>. To avoid floating |
| 55 |
* around lots of different font sizes TeX prefers to work with whole |
| 56 |
* and half magsteps. So instead of using a 330 dpi font for a 11 point |
| 57 |
* version of a 300 dpi font we would prefer the 329 dpi size because |
| 58 |
* this size matches magstep 0.5 of 300 (329 = int(300 * 1.2 ** 0.5). |
| 59 |
* The process of truncating real font sizes to magsteps can be |
| 60 |
* controlled by the global parameter <tolerance> which may be an |
| 61 |
* expression of the actual value of <dpi> itself. The value dvips(1) |
| 62 |
* uses for <tolerance> is 1 + <dpi> / 500 allowing more tolerance in |
| 63 |
* bigger sizes. Due to round-off different DVI drivers choose different |
| 64 |
* <dpi> sizes. With <margin> we can define what font sizes are looked |
| 65 |
* at whenever size <dpi> is wanted. With <margin> set to zero only the |
| 66 |
* exact size is looked at, while a value of one would allow for a |
| 67 |
* round-off of one. Both <margin> and <tolerance> can be set before a |
| 68 |
* search starts otherwise they get their default values (zero) with |
| 69 |
* init_pksearch(). |
| 70 |
* |
| 71 |
* When <path> does contain placeholders like %b, %d, %f, %p and %m |
| 72 |
* they will be substituted by their corresponding values _bdpi, <dpi>, |
| 73 |
* <font>, "pk" and _mode respectivally. This allows to define paths |
| 74 |
* for a whole range of printers. Occurrences off ~ or * ~user in <path> |
| 75 |
* will be substituted by the corresponding HOME directories on UNIX. |
| 76 |
* |
| 77 |
* The result of search_pkfile() is a pointer to the name of <font> when |
| 78 |
* one is found otherwise NULL. |
| 79 |
*/ |
| 80 |
char *search_pkfile(char *path, char *font, int dpi); |
| 81 |
|
| 82 |
/* |
| 83 |
* evaluate <expr> after substituting %d with <dpi>. Return the |
| 84 |
* integer result or abort with message when invalid expression. |
| 85 |
*/ |
| 86 |
int evaluate(char *expr, int dpi); |
| 87 |
|
| 88 |
/* |
| 89 |
* Round <dpi> to a whole or half magstep of <bdpi> if the distance of |
| 90 |
* <dpi> is within a certain <tolerance> from it. The value of <bdpi> and |
| 91 |
* <tolerance> should be set with init_pksearch(). |
| 92 |
*/ |
| 93 |
int nearesthalf(int dpi); |
| 94 |
|
| 95 |
extern int tilde; |
| 96 |
|
| 97 |
/* |
| 98 |
* During scanning of paths we often need to replace ~user with user's |
| 99 |
* HOME directory and ~ with HOME directory. Subtilde() copies the actual |
| 100 |
* value of `~' or `~user' from <path> into <fn>. The pointers <fn> and |
| 101 |
* <path> are `updated'. |
| 102 |
*/ |
| 103 |
void subtilde(char **fn, char **path); |
| 104 |
|
| 105 |
/* Is <name> an absolute filename? */ |
| 106 |
int absname(char *name); |
| 107 |
|
| 108 |
/* |
| 109 |
* Look for font libraries in <path> (ex.: c:\emtex\texfonts;fli_0;fli_1). |
| 110 |
* Run <font()> function for each .fli file found in <path>. Continue |
| 111 |
* if this function returns 0, stop when if this function return a 1. |
| 112 |
* In the last case the name of the FLI file is returned. |
| 113 |
*/ |
| 114 |
char *search_flipath(char *flipath, int (*font)(char *, int)); |
| 115 |
|