Back to index

tetex-bin  3.0
psearch.h
Go to the documentation of this file.
00001 /*
00002  * FILE:    psearch.h
00003  * PURPOSE: PATH search module
00004  * VERSION: 1.0 (Oct. 1995)
00005  * AUTHOR:  Piet Tutelaers (rcpt@urc.tue.nl)
00006  */
00007 
00008 #include <sys/types.h>
00009 #include <sys/stat.h>
00010 
00011 /*
00012  * This function initiates a path by using a built-in <deFault> and
00013  * a PATH environment variable that can be set at run time by the user.
00014  * A typical usage is
00015  *    userenv = path(".:/someplace", getenv("USERENV"))
00016  *
00017  * If USERENV is not set getenv("USERENV") returns NULL and the returned
00018  * path equals the value of the first argument. Otherwise the returned
00019  * path is the value of second argument in which empty path elements are
00020  * replaced by <deFault>. For example when USERENV is set to "~/myplace:"
00021  * the resulting path will be "~myplace:.:/someplace".
00022  */
00023 char *path(char *deFault, char *env);
00024 
00025 /*
00026  * This function substitutes the <patterns> encountered in <str>
00027  * with their corresponding <value>. Recognized patterns are %b, %d,
00028  * %f, %F and %m. They will be replaced with their corresponding integer
00029  * (%b, %d) or string values (%f, %F and %m). These values can be used as
00030  * placeholders for basic resolution (%b), resolution (%d), font name
00031  * (%f or %F) or mode definition (%m). The %F is a special case for
00032  * representing the fontname leftadjusted in a string of eight characters.
00033  */
00034 void substitute(char *str, char *patterns, ...);
00035 
00036 #define NONFATAL 0
00037 #undef FATAL
00038 #define FATAL    1
00039 /*
00040  * Look for a <file> in <path>. Return absolute filename if found.
00041  * If not found return NULL (if <terminate> is NONFATAL) or terminate
00042  * program with appropriate message (if <terminate> is FATAL).
00043  * On UNIX ~ or ~someone in paths are evaluated to the proper HOME
00044  * directories.
00045  * When the path does contain recursion characters ("//" on UNIX and
00046  * "!!" on MSDOS) directories are searched recursively.
00047  */
00048 char *search_file(char *path, char *file, int terminate);
00049 
00050 /* set global paramaters for PK font search */
00051 void init_pksearch(int bdpi, char *mode, int margin, char *tolerance);
00052 
00053 /*
00054  * Look for a PK <font> of resolution <dpi> in <path>. To avoid floating
00055  * around lots of different font sizes TeX prefers to work with whole
00056  * and half magsteps. So instead of using a 330 dpi font for a 11 point
00057  * version of a 300 dpi font we would prefer the 329 dpi size because
00058  * this size matches magstep 0.5 of 300 (329 = int(300 * 1.2 ** 0.5).
00059  * The process of truncating real font sizes to magsteps can be
00060  * controlled by the global parameter <tolerance> which may be an
00061  * expression of the actual value of <dpi> itself. The value dvips(1)
00062  * uses for <tolerance> is 1 + <dpi> / 500 allowing more tolerance in
00063  * bigger sizes. Due to round-off different DVI drivers choose different
00064  * <dpi> sizes. With <margin> we can define what font sizes are looked
00065  * at whenever size <dpi> is wanted. With <margin> set to zero only the
00066  * exact size is looked at, while a value of one would allow for a
00067  * round-off of one. Both <margin> and <tolerance> can be set before a
00068  * search starts otherwise they get their default values (zero) with
00069  * init_pksearch().
00070  *
00071  * When <path> does contain placeholders like %b, %d, %f, %p and %m
00072  * they will be substituted by their corresponding values _bdpi, <dpi>,
00073  * <font>, "pk" and _mode respectivally. This allows to define paths 
00074  * for a whole range of printers. Occurrences off ~ or * ~user in <path>
00075  * will be substituted by the corresponding HOME directories on UNIX.
00076  * 
00077  * The result of search_pkfile() is a pointer to the name of <font> when
00078  * one is found otherwise NULL.
00079  */
00080 char *search_pkfile(char *path, char *font, int dpi);
00081 
00082 /*
00083  * evaluate <expr> after substituting %d with <dpi>. Return the
00084  * integer result or abort with message when invalid expression.
00085  */
00086 int evaluate(char *expr, int dpi);
00087 
00088 /*
00089  * Round <dpi> to a whole or half magstep of <bdpi> if the distance of
00090  * <dpi> is within a certain <tolerance> from it. The value of <bdpi> and
00091  * <tolerance> should be set with init_pksearch().
00092  */
00093 int nearesthalf(int dpi);
00094 
00095 extern int tilde;
00096 
00097 /*
00098  * During scanning of paths we often need to replace ~user with user's
00099  * HOME directory and ~ with HOME directory. Subtilde() copies the actual
00100  * value of `~' or `~user' from <path> into <fn>. The pointers <fn> and
00101  * <path> are `updated'.
00102  */
00103 void subtilde(char **fn, char **path);
00104 
00105 /* Is <name> an absolute filename? */
00106 int absname(char *name);
00107 
00108 /*
00109  * Look for font libraries in <path> (ex.: c:\emtex\texfonts;fli_0;fli_1).
00110  * Run <font()> function for each .fli file found in <path>. Continue
00111  * if this function returns 0, stop when if this function return a 1.
00112  * In the last case the name of the FLI file is returned.
00113  */
00114 char *search_flipath(char *flipath, int (*font)(char *, int));
00115