diff options
author | karl <karl> | 2004-04-21 21:20:20 +0000 |
---|---|---|
committer | karl <karl> | 2004-04-21 21:20:20 +0000 |
commit | 4977c8d7c8dfdd285a7ebde805da5c793c1ce04c (patch) | |
tree | 3901313b942eb78f48bb50952d1903ff50d5d61c /include | |
parent | d2ffca200655a89c5d140b66d69001e92173e3da (diff) | |
download | fontutils-4977c8d7c8dfdd285a7ebde805da5c793c1ce04c.tar.gz |
basic compilation
Diffstat (limited to 'include')
55 files changed, 4127 insertions, 0 deletions
diff --git a/include/Bitmap.h b/include/Bitmap.h new file mode 100644 index 0000000..ac1470c --- /dev/null +++ b/include/Bitmap.h @@ -0,0 +1,121 @@ +/* Bitmap.h: public header file for a bitmap widget, implemented as a + subclass of Athena's Label widget. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef BITMAP_WIDGET_H +#define BITMAP_WIDGET_H + +#include "xt-common.h" +#include <X11/Xaw/Label.h> + +#include "bitmap.h" + + +/* Resources (in addition to those in Core, Simple, and Label): + +Name Class RepType Default Value +---- ----- ------- ------------- +bits Bitmap Pointer NULL + A pointer to a `bitmap_type' structure (see `include/bitmap.h') that + is what is actually displayed. I didn't want to name this resource + `bitmap', since there is already a `bitmap' resource in the Label + widget, and the two are different. (In fact, `bits' becomes the + Label's `bitmap'.) + +expansion Expansion Dimension 16 + How many times each pixel in the bitmap is replicated. + +modified Modified Boolean False + This readonly resource says whether or not the bitmap has been modified. + +shadow Bitmap BitmapWidget NULL + A replica of the widget, possibly with a different expansion + (typically, in fact, the shadow bitmap has expansion one). When a + pixel in the widget is changed and repainted via the InvertPixel + action (see the `translations' resource below), the corresponding + pixel in the shadow widget is also changed and repainted. + +translations Translations TranslationTable NULL + The event bindings associated with this widget. The Bitmap widget + provides an action `InvertPixel', which inverts the value of the pixel + the pointer is on. `InvertPixel' takes one parameter, which must be + one of the symbols `Discrete' or `Continuous' (case is significant). + In the latter case, the pixel is only changed if the pointer was 1) not + at that same pixel on the last invocation, and 2) on a pixel that is + of the opposite color as the pixel at the time of the last `Discrete' + invocation. Why? Because it is most useful to be able to move the + pointer and change pixels to either black or white, not invert them. + + The Bitmap widget also provides two related sets of actions for copying + parts of characters. For the purposes of these actions, imagine that + the ``hot spots'' of each pixel in the large bitmap are at the upper + left of the visible square. StartSelection() begins a selection + operation at the nearest pixel above and to the left of the current + point. AdjustSelection() changes the selected rectangle according to + the nearest pixel below and to the right of the current pixel; the + new point can be in any relationship to the initial point. + AcceptSelection() takes the current selection as the final one. + + Once a rectangle has been selected, you can paste it in the same or + another character: StartPaste() shows the selected rectangle and + MovePaste() moves it around. AcceptPaste(Opaque) changes the bitmap + destructively, i.e., each pixel in the selected rectangle overwrites + the pixel in the bitmap. AcceptPaste(Transparent) changes the bitmap + nondestructively, i.e., a black pixel in the bitmap will remain black. + + Aside from pasting the selection, you can also fill it: + FillSelection() fills the current selection with the color of the + pixel the pointer is currently on. + + To abort any selection or paste operation, simply move the pointer + outside the bitmap before finishing the operation. + + By default, no events are bound to the actions. Default bindings + should be put in the app-defaults file. +*/ + +#ifndef XtCBitmap +#define XtCBitmap "Bitmap" +#endif +#define XtCExpansion "Expansion" +#define XtCModified "Modified" + +#define XtNbits "bits" + +#define XtNexpansion "expansion" +#define BITMAP_DEFAULT_EXPANSION 16 + +#define XtNmodified "modified" + +#define XtNshadow "shadow" + +/* Convenience procedures to get the interesting resources. */ +extern unsigned BitmapExpansion (Widget); +extern bitmap_type *BitmapBits (Widget); +extern Boolean BitmapModified (Widget); + + + +/* The class variable, for arguments to XtCreateWidget et al. */ +extern WidgetClass bitmapWidgetClass; + +/* The class record and instance record types. */ +typedef struct _BitmapClassRec *BitmapWidgetClass; +typedef struct _BitmapRec *BitmapWidget; + +#endif /* not BITMAP_WIDGET_H */ diff --git a/include/Item.h b/include/Item.h new file mode 100644 index 0000000..2d9b524 --- /dev/null +++ b/include/Item.h @@ -0,0 +1,72 @@ +/* Item.h: public header file for an ``item widget'': a composite widget + consisting of a label and a (string) value. Both subwidgets are + created by the Item itself, and geometry requests from them are + ignored. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef ITEM_WIDGET_H +#define ITEM_WIDGET_H + +#include "xt-common.h" + +#include <kpathsea/types.h> + + +/* Resources (in addition to those in Core and Composite): + +Name Class RepType Default Value +---- ----- ------- ------------- +callback Callback Callback NULL + These routines are called when the accept_value action (see below) is + performed. The call_data passed is the contents of the `value' + resource. + +label Label String name of widget + A constant string displayed before the editable text. The characters + in this string are copied by the Item widget. + +length Length Dimension 1 + The longest `value' allowed, in characters. + +translations Translations TranslationTable NULL + The event bindings associated with this widget. The Item + provides an action `AcceptValue', which calls the routines in the + `callback' resource. `AcceptValue' does not take any parameters. + + By default, no events are bound to `AcceptValue'. Default bindings + (perhaps to RET and CTRL-M) should be put in the app-defaults file. + +value Value String empty string + The editable text. The longest value allowed is the value of `length'. +*/ + +/* Convenience procedures. */ +extern string ItemGetLabelString (Widget); +extern string ItemGetValueString (Widget); +extern Widget ItemGetValueWidget (Widget); + + + +/* The class variable, for arguments to XtCreateWidget et al. */ +extern WidgetClass itemWidgetClass; + +/* The class and instance record types. */ +typedef struct _ItemClassRec *ItemWidgetClass; +typedef struct _ItemRec *ItemWidget; + +#endif /* not ITEM_WIDGET_H */ diff --git a/include/bb-list.h b/include/bb-list.h new file mode 100644 index 0000000..602cb91 --- /dev/null +++ b/include/bb-list.h @@ -0,0 +1,53 @@ +/* bb-list.h: bounding box lists. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef BB_LIST_H +#define BB_LIST_H + +#include "bounding-box.h" + + +typedef struct +{ + bounding_box_type *data; + unsigned length; +} bb_list_type; + +/* The length of the list. */ +#define BB_LIST_LENGTH(bb_l) ((bb_l).length) + +/* The array of elements as a whole. */ +#define BB_LIST_DATA(bb_l) ((bb_l).data) + +/* The Nth element in the list. */ +#define BB_LIST_ELT(bb_l, n) BB_LIST_DATA (bb_l)[n] + + +/* Initialize a list. */ +extern bb_list_type bb_list_init (void); + +/* Append BB to L. */ +extern void bb_list_append (bb_list_type *l, bounding_box_type bb); + +/* Splice the elements in list B2 onto B1, changing B1. */ +extern void bb_list_splice (bb_list_type *B1, bb_list_type B2); + +/* Free the memory in a list. */ +extern void bb_list_free (bb_list_type *); + +#endif /* not BB_LIST_H */ diff --git a/include/bb-outline.h b/include/bb-outline.h new file mode 100644 index 0000000..9ec8b7b --- /dev/null +++ b/include/bb-outline.h @@ -0,0 +1,37 @@ +/* bb-outline.h: find a list of bounding boxes enclosing outlines. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef BB_OUTLINE_H +#define BB_OUTLINE_H + +#include "bb-list.h" +#include "bitmap.h" +#include <kpathsea/types.h> + + + +/* Find the bounding boxes around the outlines in the bitmap B. If ALL is + true, we find the bounding boxes around all the outlines, including + counterforms. If ALL is false, we find only ``outside'' outlines. + The character `a', for example, would be represented by one bounding + box. We don't look in any of the columns from LEFT to RIGHT, + left-inclusive. */ +extern bb_list_type + find_outline_bbs (bitmap_type b, boolean all, int left, int right); + +#endif /* not BB_OUTLINE_H */ diff --git a/include/bitmap.h b/include/bitmap.h new file mode 100644 index 0000000..bd289da --- /dev/null +++ b/include/bitmap.h @@ -0,0 +1,115 @@ +/* bitmap.h: definition for a bitmap type. No packing is done by + default; each pixel is represented by an entire byte. Among other + things, this means the type can be used for both grayscale and binary + images. + +Copyright (C) 1992, 93 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef BITMAP_H +#define BITMAP_H + +#include <stdio.h> +#include <kpathsea/types.h> +#include "bounding-box.h" + + +/* If the bitmap holds 8-bit values, rather than one-bit, the + definition of BLACK here is wrong. So don't use it in that case! + */ +#define WHITE 0 +#define BLACK 1 + + +/* The basic structure and macros to access it. */ +typedef struct +{ + dimensions_type dimensions; + one_byte *bitmap; +} bitmap_type; + +/* The dimensions of the bitmap, in pixels. */ +#define BITMAP_DIMENSIONS(b) ((b).dimensions) + +/* The pixels, represented as an array of bytes (in contiguous storage). + Each pixel is a single byte, even for binary fonts. */ +#define BITMAP_BITS(b) ((b).bitmap) + +/* These are convenient abbreviations for getting inside the members. */ +#define BITMAP_WIDTH(b) DIMENSIONS_WIDTH (BITMAP_DIMENSIONS (b)) +#define BITMAP_HEIGHT(b) DIMENSIONS_HEIGHT (BITMAP_DIMENSIONS (b)) + +/* This is the address of the first pixel in the row ROW. */ +#define BITMAP_ROW(b, row) (BITMAP_BITS (b) + (row) * BITMAP_WIDTH (b)) + +/* This is the pixel at [ROW,COL]. */ +#define BITMAP_PIXEL(b, row, col) \ + (*(BITMAP_BITS (b) + (row) * BITMAP_WIDTH (b) + (col))) + +#define BITMAP_VALID_PIXEL(b, row, col) \ + (0 <= (row) && (row) < BITMAP_HEIGHT (b) \ + && 0 <= (col) && (col) < BITMAP_WIDTH (b)) + +/* Assume that the pixel at [ROW,COL] itself is black. + If it's not on the bitmap edge and it's surrounded by all black + pixels, then it's interior. +*/ +#define BITMAP_INTERIOR_PIXEL(b, row, col) \ + (0 != (row) && (row) != BITMAP_HEIGHT (b) - 1 \ + && 0 != (col) && (col) != BITMAP_WIDTH (b) - 1 \ + && BITMAP_PIXEL (b, row - 1, col - 1) == BLACK \ + && BITMAP_PIXEL (b, row - 1, col) == BLACK \ + && BITMAP_PIXEL (b, row - 1, col + 1) == BLACK \ + && BITMAP_PIXEL (b, row, col - 1) == BLACK \ + && BITMAP_PIXEL (b, row, col + 1) == BLACK \ + && BITMAP_PIXEL (b, row + 1, col - 1) == BLACK \ + && BITMAP_PIXEL (b, row + 1, col) == BLACK \ + && BITMAP_PIXEL (b, row + 1, col + 1) == BLACK) + +/* Allocate storage for the bits, set them all to white, and return an + initialized structure. */ +extern bitmap_type new_bitmap (dimensions_type); + +/* Free that storage. */ +extern void free_bitmap (bitmap_type *); + +/* Make a fresh copy of BITMAP in a new structure, and return it. */ +extern bitmap_type copy_bitmap (bitmap_type bitmap); + +/* Return the pixels in the bitmap B enclosed by the bounding box BB. + The result is put in newly allocated storage. */ +extern bitmap_type extract_subbitmap (bitmap_type b, bounding_box_type bb); + +/* Consider the dimensions of a bitmap as a bounding box. The bounding + box returned is in bitmap coordinates, rather than Cartesian, and + refers to pixels, rather than edges. Specifically, this means that + the maximum column is one less than results from `dimensions_to_bb + (BITMAP_DIMENSIONS ())'. */ +extern const bounding_box_type bitmap_to_bb (const bitmap_type); + +/* Return a vector of zero-based column numbers marking transitions from + black to white or white to black in ROW, which is of length WIDTH. + The end of the vector is marked with an element of length WIDTH + 1. + The first element always marks a white-to-black transition (or it's + 0, if the first pixel in ROW is black). */ +extern unsigned *bitmap_find_transitions (const one_byte *row, unsigned width); + +/* Print part of or all of a bitmap. */ +extern void print_bounded_bitmap (FILE *, bitmap_type, bounding_box_type); +extern void print_bitmap (FILE *, bitmap_type); + +#endif /* not BITMAP_H */ + diff --git a/include/bounding-box.h b/include/bounding-box.h new file mode 100644 index 0000000..1f89f8f --- /dev/null +++ b/include/bounding-box.h @@ -0,0 +1,63 @@ +/* bounding-box.h: operations on both real- and integer-valued bounding boxes. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef BOUNDING_BOX_H +#define BOUNDING_BOX_H + +#include <kpathsea/types.h> + + +/* The bounding box's numbers are usually in Cartesian/Metafont + coordinates: (0,0) is towards the lower left. */ +typedef struct +{ + signed_4_bytes min_row, max_row; + signed_4_bytes min_col, max_col; +} bounding_box_type; + +typedef struct +{ + real min_row, max_row; + real min_col, max_col; +} real_bounding_box_type; + +/* These accessing macros work for both types of bounding boxes, since + the member names are the same. */ +#define MIN_ROW(bb) ((bb).min_row) +#define MAX_ROW(bb) ((bb).max_row) +#define MIN_COL(bb) ((bb).min_col) +#define MAX_COL(bb) ((bb).max_col) + +/* See the comments at `get_character_bitmap' in gf_input.c for why the + width and height are treated asymetrically. */ +#define BB_WIDTH(bb) (MAX_COL (bb) - MIN_COL (bb)) +#define BB_HEIGHT(bb) (MAX_ROW (bb) - MIN_ROW (bb) + 1) + + +/* Convert a dimensions structure to an integer bounding box, and vice + versa. */ +extern const bounding_box_type dimensions_to_bb (dimensions_type); +extern const dimensions_type bb_to_dimensions (bounding_box_type); + + +/* Update the bounding box BB from the point P. */ +extern void update_real_bounding_box (real_bounding_box_type *bb, + real_coordinate_type p); +extern void update_bounding_box (bounding_box_type *bb, coordinate_type p); + +#endif /* not BOUNDING_BOX_H */ diff --git a/include/bzr.h b/include/bzr.h new file mode 100644 index 0000000..2f267c9 --- /dev/null +++ b/include/bzr.h @@ -0,0 +1,134 @@ +/* bzr.h: manipulate Bezier-format font files. See ../bzr/README + + + for the precise definition of the file format. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef BZR_H +#define BZR_H + +#include <kpathsea/types.h> + +#include "bounding-box.h" +#include "font.h" +#include "spline.h" + + +/* At most one output (and one input) file can be open at a time; + calling either of these routines twice, with no intervening call to + close the file, results in a fatal error. */ +extern boolean bzr_open_output_file (string filename); +extern boolean bzr_open_input_file (string filename); + +/* If no output (or input) file is open, a fatal error results. */ +extern void bzr_close_output_file (void); +extern void bzr_close_input_file (void); + +/* Fontwide information at the beginning of the file. */ +typedef struct +{ + string comment; + real design_size; +} bzr_preamble_type; + +/* The comment usually identifies the creator of the file, but it need + not be anything in particular. */ +#define BZR_COMMENT(p) ((p).comment) + +/* The design size is given in points (72.27pt=1in). */ +#define BZR_DESIGN_SIZE(p) ((p).design_size) + + +/* You should write the preamble before writing anything els. */ +extern void bzr_put_preamble (bzr_preamble_type); + +/* You should be positioned at the beginning of the file (e.g., have + just opened it) before calling this. Furthermore, you should call + this routine before calling any of the other input routines. + (Because this is what reads the design size of the font, and other + values in the file are scaled by that.) */ +extern bzr_preamble_type bzr_get_preamble (void); + +/* Character information. */ + +typedef struct +{ + charcode_type code; + real set_width; + real_bounding_box_type bb; + spline_list_array_type shape; +} bzr_char_type; + + +/* The character code is always in the range 0 to 255. You can use the + `CHARCODE' macro to access it. */ + +/* The set width is given in points. You can use the `CHAR_SET_WIDTH' + macro to access it. */ + +/* The character bounding box is not guaranteed to be the tightest + possible, but it should be close. The values are in points. The + CHAR_HEIGHT, CHAR_DEPTH, CHAR_SET_WIDTH, CHAR_BB, and related macros + in `font.h' all work. */ + +/* The shape is given as a list of lists of lines and cubic splines. + Each element of the outer list represents a closed path. The values + are in points. */ +#define BZR_SHAPE(c) ((c).shape) + + +/* This routine writes the given character. */ +extern void bzr_put_char (bzr_char_type); + +/* This routine returns the next character in the file. If the postamble + is next, it returns NULL. Each spline in the `shape' element is + guaranteed to have degree `LINEAR' or `CUBIC' (see `spline.h'). */ +extern bzr_char_type *bzr_get_next_char (void); + +/* This routine returns the character with the given CODE, or NULL. + Each spline in the `shape' element is guaranteed to have degree + `LINEAR' or `CUBIC' (see `spline.h'). */ +extern bzr_char_type *bzr_get_char (one_byte code); + +/* More fontwide information, this at the end of the file. */ + +typedef struct +{ + real_bounding_box_type font_bb; + one_byte nchars; +} bzr_postamble_type; + +/* The font bounding box is guaranteed to be the tightest possible, + given the character bounding box. The values are in points. */ +#define BZR_FONT_BB(p) ((p).font_bb) + +/* The total number of characters (possibly zero) in the font. */ +#define BZR_NCHARS(p) ((p).nchars) + + +/* The postamble must be written last; the library itself determines the + font bounding box, based on the character bounding boxes, so you do + not supply it as an argument. */ +extern void bzr_put_postamble (void); + +/* And this reads the postamble back. You should be positioned at the + postamble (e.g., `bzr_get_char' should have just returned NULL) before + calling this. */ +extern bzr_postamble_type bzr_get_postamble (void); + +#endif /* not BZR_H */ diff --git a/include/c-auto.h b/include/c-auto.h new file mode 100644 index 0000000..3d38cf4 --- /dev/null +++ b/include/c-auto.h @@ -0,0 +1,71 @@ +/* include/c-auto.h. Generated by configure. */ +/* c-auto.h.in. Generated automatically from configure.in by autoheader. */ + +/* Define to empty if the keyword does not work. */ +/* #undef const */ + +/* Define if you have dirent.h. */ +/* #undef DIRENT */ + +/* Define if you don't have dirent.h, but have ndir.h. */ +/* #undef NDIR */ + +/* Define if you need to in order for stat and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define if you have the ANSI C header files. */ +/* #undef STDC_HEADERS */ + +/* Define if you don't have dirent.h, but have sys/dir.h. */ +/* #undef SYSDIR */ + +/* Define if you don't have dirent.h, but have sys/ndir.h. */ +/* #undef SYSNDIR */ + +/* Define if the closedir function returns void instead of int. */ +/* #undef VOID_CLOSEDIR */ + +/* Define if your putenv doesn't waste space when the same environment + variable is assigned more than once, with different (malloced) + values. This is true only on NetBSD/FreeBSD, as far as I know. See + xputenv.c. */ +/* #undef SMART_PUTENV */ + +/* Define if you have memmove. */ +/* #undef HAVE_MEMMOVE */ + +/* Define if you have putenv. */ +/* #undef HAVE_PUTENV */ + +/* Define if you have the <assert.h> header file. */ +/* #undef HAVE_ASSERT_H */ + +/* Define if you have the <float.h> header file. */ +/* #undef HAVE_FLOAT_H */ + +/* Define if you have the <limits.h> header file. */ +/* #undef HAVE_LIMITS_H */ + +/* Define if you have the <memory.h> header file. */ +/* #undef HAVE_MEMORY_H */ + +/* Define if you have the <pwd.h> header file. */ +/* #undef HAVE_PWD_H */ + +/* Define if you have the <stdlib.h> header file. */ +/* #undef HAVE_STDLIB_H */ + +/* Define if you have the <string.h> header file. */ +/* #undef HAVE_STRING_H */ + +/* Define if you have the <unistd.h> header file. */ +/* #undef HAVE_UNISTD_H */ + +/* Define if you have the dnet library (-ldnet). */ +/* #undef HAVE_LIBDNET */ + +/* Define if you have the dnet_stub library (-ldnet_stub). */ +/* #undef HAVE_LIBDNET_STUB */ + +/* Define if you have the socket library (-lsocket). */ +/* #undef HAVE_LIBSOCKET */ diff --git a/include/c-errno.h b/include/c-errno.h new file mode 100644 index 0000000..5c55be1 --- /dev/null +++ b/include/c-errno.h @@ -0,0 +1,27 @@ +/* c-errno.h: <errno.h> and the errno variable. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef C_ERRNO_H +#define C_ERRNO_H + +#include <errno.h> +#ifndef errno +extern int errno; +#endif + +#endif /* not C_ERRNO_H */ diff --git a/include/c-fopen.h b/include/c-fopen.h new file mode 100644 index 0000000..e7d476e --- /dev/null +++ b/include/c-fopen.h @@ -0,0 +1,53 @@ +/* c-fopen.h: how to open files with fopen. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef C_FOPEN_H +#define C_FOPEN_H + +/* How to open a text file: */ +#ifndef FOPEN_R_MODE +#define FOPEN_R_MODE "r" +#endif + +#ifndef FOPEN_W_MODE +#define FOPEN_W_MODE "w" +#endif + +/* How to open a binary file for reading: */ +#ifndef FOPEN_RBIN_MODE +#if defined (VMS) || defined (DOS) || defined (VMCMS) +#define FOPEN_RBIN_MODE "rb" +#else +#define FOPEN_RBIN_MODE "r" +#endif /* not (VM/CMS or DOS or VMS) */ +#endif /* not FOPEN_RBIN_MODE */ + +/* How to open a binary file for writing: */ +#ifndef FOPEN_WBIN_MODE +#ifdef DOS +#define FOPEN_WBIN_MODE "wb" +#else +#ifdef VMCMS +#define FOPEN_WBIN_MODE "wb, lrecl=1024, recfm=f" +#else +#define FOPEN_WBIN_MODE "w" +#endif /* not VM/CMS */ +#endif /* not DOS */ +#endif /* not FOPEN_WBIN_MODE */ + +#endif /* not C_FOPEN_H */ diff --git a/include/c-limits.h b/include/c-limits.h new file mode 100644 index 0000000..90fc4e3 --- /dev/null +++ b/include/c-limits.h @@ -0,0 +1,34 @@ +/* c-limits.h: include the system parameter file. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef C_LIMITS_H +#define C_LIMITS_H + +#include "c-std.h" + +#ifdef LIMITS_H_MISSING +#include <sys/param.h> +#else +#include <limits.h> +#endif + +#if !defined (FLOAT_H_MISSING) && !defined (FLT_MAX) +#include <float.h> +#endif + +#endif /* not C_LIMITS_H */ diff --git a/include/c-memstr.h b/include/c-memstr.h new file mode 100644 index 0000000..149ff65 --- /dev/null +++ b/include/c-memstr.h @@ -0,0 +1,62 @@ +/* c-memstr.h: memcpy, strchr, etc. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef C_MEMSTR_H +#define C_MEMSTR_H + +#include "c-std.h" + +/* Just to be complete, we make both the system V/ANSI and the BSD + versions of the string functions available. */ +#if STDC_HEADERS || HAVE_STRING_H +#include <string.h> + +/* An ANSI string.h and pre-ANSI memory.h might conflict. */ +#if !STDC_HEADERS && HAVE_MEMORY_H +#include <memory.h> +#endif /* not STDC_HEADERS and HAVE_MEMORY_H */ + +#define index strchr +#define rindex strrchr + +#ifndef bcmp +#define bcmp(s1, s2, len) memcmp ((s1), (s2), (len)) +#endif +#ifndef bcopy +#define bcopy(from, to, len) memcpy ((to), (from), (len)) +#endif +#ifndef bzero +#define bzero(s, len) memset ((s), 0, (len)) +#endif + +#else /* not STDC_HEADERS and not HAVE_STRING_H */ + +#include <strings.h> + +#define strchr index +#define strrchr rindex + +#define memcmp(s1, s2, n) bcmp ((s1), (s2), (n)) +#define memcpy(to, from, len) bcopy ((from), (to), (len)) + +extern char *strtok (); +extern char *strstr (); + +#endif /* not STDC_HEADERS and not HAVE_STRING_H */ + +#endif /* not C_MEMSTR_H */ diff --git a/include/c-minmax.h b/include/c-minmax.h new file mode 100644 index 0000000..71017cc --- /dev/null +++ b/include/c-minmax.h @@ -0,0 +1,84 @@ +/* c-minmax.h: define INT_MIN, etc. Assume a 32-bit machine if the + values aren't defined. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef C_MINMAX_H +#define C_MINMAX_H + +#include "c-limits.h" + +/* Declared in <limits.h> on ANSI C systems. If the system doesn't + define it, we use the minimum ANSI values -- except for `int'; we + assume 32-bit integers. */ + +#ifndef SCHAR_MIN +#define SCHAR_MIN (-127) +#endif +#ifndef SCHAR_MAX +#define SCHAR_MAX 128 +#endif +#ifndef UCHAR_MAX +#define UCHAR_MAX 255 +#endif + +#ifndef SHRT_MIN +#define SHRT_MIN (-32767) +#endif +#ifndef SHRT_MAX +#define SHRT_MAX 32767 +#endif +#ifndef USHRT_MAX +#define USHRT_MAX 65535 +#endif + +#ifndef INT_MIN +#define INT_MIN (-2147483647) +#endif +#ifndef INT_MAX +#define INT_MAX 2147483647 +#endif +#ifndef UINT_MAX +#define UINT_MAX 4294967295 +#endif + +#ifndef LONG_MIN +#define LONG_MIN INT_MIN +#endif +#ifndef LONG_MAX +#define LONG_MAX INT_MAX +#endif +#ifndef ULONG_MAX +#define ULONG_MAX UINT_MAX +#endif + +/* Declared in <float.h> on ANSI C systems. */ +#ifndef DBL_MIN +#define DBL_MIN 1e-37 +#endif +#ifndef DBL_MAX +#define DBL_MAX 1e+37 +#endif + +#ifndef FLT_MIN +#define FLT_MIN 1e-37 +#endif +#ifndef FLT_MAX +#define FLT_MAX 1e+37 +#endif + +#endif /* not C_MINMAX_H */ diff --git a/include/c-namemx.h b/include/c-namemx.h new file mode 100644 index 0000000..f8f6613 --- /dev/null +++ b/include/c-namemx.h @@ -0,0 +1,41 @@ +/* c-name_max.h: define NAME_MAX, the maximum length of a single + component in a pathname. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef C_NAME_MAX_H +#define C_NAME_MAX_H + +#include "c-limits.h" + +#ifdef _POSIX_VERSION +#ifndef NAME_MAX +#define NAME_MAX pathconf ("/", _PC_NAME_MAX) +#endif +#endif /* not _POSIX_VERSION */ + +/* Most likely the system will truncate filenames if it is not POSIX, + and so we can use the BSD value here. */ +#ifndef _POSIX_NAME_MAX +#define _POSIX_NAME_MAX 255 +#endif + +#ifndef NAME_MAX +#define NAME_MAX _POSIX_NAME_MAX +#endif + +#endif /* not C_NAME_MAX_H */ diff --git a/include/c-pathch.h b/include/c-pathch.h new file mode 100644 index 0000000..78c3b24 --- /dev/null +++ b/include/c-pathch.h @@ -0,0 +1,71 @@ +/* c-pathch.h: define the characters which separate components of + pathnames and environment variable paths. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef C_PATHCH_H +#define C_PATHCH_H + +/* What separates pathname components? */ +#ifndef PATH_SEP +#ifdef VMS +#define PATH_SEP ':' +#define PATH_SEP_STRING ":" +#else +#ifdef DOS +#define PATH_SEP '\\' +#define PATH_SEP_STRING "\\" +/* On DOS, it's good to allow both \ and / between directories. */ +#define IS_PATH_SEP(ch) ((ch) == PATH_SEP || (ch) == '/') +#else +#ifdef VMCMS +#define PATH_SEP ' ' +#define PATH_SEP_STRING " " +#else +#define PATH_SEP '/' +#define PATH_SEP_STRING "/" +#endif /* not VM/CMS */ +#endif /* not DOS */ +#endif /* not VMS */ +#endif /* not PATH_SEP */ + +#ifndef IS_PATH_SEP +#define IS_PATH_SEP(ch) ((ch) == PATH_SEP) +#endif + +/* What separates elements in environment variable path lists? */ +#ifndef PATH_DELIMITER +#ifdef VMS +#define PATH_DELIMITER ',' +#define PATH_DELIMITER_STRING "," +#else +#ifdef DOS +#define PATH_DELIMITER ';' +#define PATH_DELIMITER_STRING ";" +#else +#ifdef VMCMS +#define PATH_DELIMITER ' ' +#define PATH_DELIMITER_STRING " " +#else +#define PATH_DELIMITER ':' +#define PATH_DELIMITER_STRING ":" +#endif /* not VM/CMS */ +#endif /* not DOS */ +#endif /* not VMS */ +#endif /* not PATH_DELIMITER */ + +#endif /* not C_PATHCH_H */ diff --git a/include/c-pathmx.h b/include/c-pathmx.h new file mode 100644 index 0000000..4596acc --- /dev/null +++ b/include/c-pathmx.h @@ -0,0 +1,37 @@ +/* c-path_max.h: define PATH_MAX, the maximum length of a pathname. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef C_PATH_MAX_H +#define C_PATH_MAX_H + +#include "c-limits.h" + +#ifndef _POSIX_PATH_MAX +#define _POSIX_PATH_MAX 255 +#endif + +#ifndef PATH_MAX +#ifdef MAXPATHLEN +#define PATH_MAX MAXPATHLEN +#else +#define PATH_MAX _POSIX_PATH_MAX +#endif +#endif /* not PATH_MAX */ + + +#endif /* not C_PATH_MAX_H */ diff --git a/include/c-proto.h b/include/c-proto.h new file mode 100644 index 0000000..5d473d3 --- /dev/null +++ b/include/c-proto.h @@ -0,0 +1,61 @@ +/* c-proto.h: macros to include or discard prototypes. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef C_PROTO_H +#define C_PROTO_H + +/* Although most of the code here is written in GNU C, a few files are + shared with other distributions (TeX, xdvi, dvips), and so need to be + compilable with common C, also. Here are macros which play around + with function declarations to make them work in both cases. The P?H + macros are used for declarations, the P?C for definitions. */ + +#if __STDC__ + +#define P1H(p1) (p1) +#define P2H(p1,p2) (p1, p2) +#define P3H(p1,p2,p3) (p1, p2, p3) +#define P4H(p1,p2,p3,p4) (p1, p2, p3, p4) +#define P5H(p1,p2,p3,p4,p5) (p1, p2, p3, p4, p5) + +#define P1C(t1,n1)(t1 n1) +#define P2C(t1,n1, t2,n2)(t1 n1, t2 n2) +#define P3C(t1,n1, t2,n2, t3,n3)(t1 n1, t2 n2, t3 n3) +#define P4C(t1,n1, t2,n2, t3,n3, t4,n4)(t1 n1, t2 n2, t3 n3, t4 n4) +#define P5C(t1,n1, t2,n2, t3,n3, t4,n4, t5,n5) \ + (t1 n1, t2 n2, t3 n3, t4 n4, t5 n5) + +#else /* not __STDC__ */ + +#define P1H(p1) () +#define P2H(p1, p2) () +#define P3H(p1, p2, p3) () +#define P4H(p1, p2, p3, p4) () +#define P5H(p1, p2, p3, p4, p5) () + +#define P1C(t1,n1) (n1) t1 n1; +#define P2C(t1,n1, t2,n2) (n1, n2) t1 n1; t2 n2; +#define P3C(t1,n1, t2,n2, t3,n3) (n1, n2, n3) t1 n1; t2 n2; t3 n3; +#define P4C(t1,n1, t2,n2, t3,n3, t4,n4) (n1, n2, n3, n4) \ + t1 n1; t2 n2; t3 n3; t4 n4; +#define P5C(t1,n1, t2,n2, t3,n3, t4,n4, t5,n5) (n1, n2, n3, n4, n5) \ + t1 n1; t2 n2; t3 n3; t4 n4; t5 n5; + +#endif /* not __STDC__ */ + +#endif /* not C_PROTO_H */ diff --git a/include/c-std.h b/include/c-std.h new file mode 100644 index 0000000..c1e31da --- /dev/null +++ b/include/c-std.h @@ -0,0 +1,73 @@ +/* c-std.h: the first header files. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef C_STD_H +#define C_STD_H + +/* Header files that essentially all of our sources need, and + that all implementations have. We include these first, to help with + NULL being defined multiple times. */ +#include <math.h> +#include <stdio.h> + +/* POSIX.1 says that <unistd.h> may require <sys/types.h>. */ +#include <sys/types.h> + +/* This is the symbol that X uses to determine if <sys/types.h> has been + read, so we define it. */ +#define __TYPES__ + +/* And X uses this symbol to say whether we have <stddef.h> etc. */ +#ifndef STDC_HEADERS +#define X_NOT_STDC_ENV +#endif + +/* Be sure we have constants from <unistd.h>. */ +#include "c-unistd.h" + +#if STDC_HEADERS +#include <stdlib.h> +/* Include <stdlib.h> first to help avoid NULL redefinitions on some + systems. Now that we no longer include <stdlib.h> it may be + irrelevant. */ +#else +extern char *getenv (); +#ifndef ALLOC_RETURN_TYPE +#ifdef DOS +#define ALLOC_RETURN_TYPE void +#else +#define ALLOC_RETURN_TYPE char +#endif /* not DOS */ +#endif /* not ALLOC_RETURN_TYPE */ +extern ALLOC_RETURN_TYPE *calloc (), *malloc (), *realloc (); +#endif /* not STDC_HEADERS */ + +/* strchr vs. index, memcpy vs. bcopy, etc. */ +#include "c-memstr.h" + +/* Error numbers and errno declaration. */ +#include "c-errno.h" + +/* Numeric minima and maxima. */ +#include "c-minmax.h" + +/* popen is part of POSIX.2, not POSIX.1. So STDC_HEADERS isn't enough. */ +extern FILE *popen (); +extern double hypot (); + +#endif /* not C_STD_H */ diff --git a/include/c-unistd.h b/include/c-unistd.h new file mode 100644 index 0000000..fa2d2c3 --- /dev/null +++ b/include/c-unistd.h @@ -0,0 +1,50 @@ +/* c-unistd.h: ensure we have constants from <unistd.h>. Included from + c-std.h. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef C_UNISTD_H +#define C_UNISTD_H + +#if HAVE_UNISTD_H +#include <unistd.h> +#endif + +#include "c-std.h" + +/* For fseek. */ +#ifndef SEEK_SET +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 +#endif /* not SEEK_SET */ + +/* For access. */ +#ifndef F_OK +#define F_OK 0 +#define X_OK 1 +#define W_OK 2 +#define R_OK 4 +#endif /* not F_OK */ + +#ifndef STDIN_FILENO +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 +#endif /* not STDIN_FILENO */ + +#endif /* not C_UNISTD_H */ diff --git a/include/charspec.h b/include/charspec.h new file mode 100644 index 0000000..a22af23 --- /dev/null +++ b/include/charspec.h @@ -0,0 +1,34 @@ +/* charspec.h: + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef CHARSPEC_H +#define CHARSPEC_H + +#include "encoding.h" +#include <kpathsea/types.h> + + +/* If SPEC starts with a digit, return the result of `xparse_charcode + (SPEC)'. Otherwise, if ENC is NULL and SPEC is exactly one character + long, return that character. Otherwise (ENC is non-NULL), look up + SPEC as a character name in ENC and return the corresponding character + code. If SPEC is NULL, the empty string, an unrecognized name, or + otherwise invalid, give a fatal error. */ +extern charcode_type xparse_charspec (string spec, encoding_info_type *enc); + +#endif /* not CHARSPEC_H */ diff --git a/include/cmdline.h b/include/cmdline.h new file mode 100644 index 0000000..e528d15 --- /dev/null +++ b/include/cmdline.h @@ -0,0 +1,135 @@ +/* cmdline.h: macros to help process command-line arguments. + +Copyright (C) 1992, 2004 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef CMDLINE_H +#define CMDLINE_H + +#include "filename.h" +#include "getopt.h" +#include "global.h" + + +/* Test whether getopt found an option ``A''. + Assumes the option index is in the variable `option_index', and the + option table in a variable `long_options'. */ + +#define ARGUMENT_IS(a) STREQ (long_options[option_index].name, a) + + +/* Read the string S as a percentage, i.e., a number between 0 and 100. */ + +#define GET_PERCENT(s) \ + ({ \ + unsigned temp = atou (s); \ + if (temp > 100) \ + FATAL1 ("GET_PERCENT: The argument %u should be at most 100, since \ +it's a percentage", temp); \ + temp / 100.0; \ + }) + + +/* Read the string S as two character codes separated by a hyphen. Put + the numeric values of the codes into START and END. */ + +#define GET_RANGE(s, start, end) \ + do \ + { \ + string str1 = strtok (s, "-"); \ + if (str1 == NULL) \ + FATAL1 ("GET_RANGE: No character code in argument `%s'", s); \ + start = xparse_charcode (str1); \ + end = xparse_charcode (s + strlen (str1) + 1); \ + } \ + while (0) + + +/* In most programs, we want to deduce the resolution from the filename + given, if possible. But in some we don't. Correspondingly, we want + to remove the suffix if we do deduce the resolution (since the + resolution is the suffix (plus a format)). Assumes lots of + variables. */ + +#ifdef CMDLINE_NO_DPI +#define FIND_CMDLINE_DPI() /* as nothing */ +#define MAYBE_REMOVE_SUFFIX(s) s +#else +#define FIND_CMDLINE_DPI() \ + if (!explicit_dpi) \ + { \ + string test_dpi = find_dpi (argv[optind]); \ + if (test_dpi != NULL) \ + dpi = test_dpi; \ + } +#define MAYBE_REMOVE_SUFFIX(s) remove_suffix (s) +#endif + + +/* Perform common actions at the end of parsing the arguments. Assumes + lots of variables: `printed_version', a boolean for whether the + version number has been printed; `optind', the current option index; + `argc'; `argv'; and `explicit_dpi', for whether the resolution has + been assigned already. */ + +#define FINISH_COMMAND_LINE() \ + do \ + { \ + /* Just wanted to know the version number? */ \ + if (printed_version && optind == argc) exit (0); \ + \ + /* Exactly one (non-empty) argument left? */ \ + if (optind + 1 == argc && *argv[optind] != 0) \ + { \ + FIND_CMDLINE_DPI (); \ + return MAYBE_REMOVE_SUFFIX (argv[optind]); \ + } \ + else \ + { \ + fprintf (stderr, "Usage: %s [options] <font_name>.\n", argv[0]);\ + fprintf (stderr, "(%s.)\n", optind == argc ? "Missing <font_name>"\ + : "Too many <font_name>s"); \ + fputs ("For more information, use ``-help''.\n", stderr); \ + exit (1); \ + } \ + return NULL; /* stop warnings */ \ + } \ + while (0) + +#define GETOPT_USAGE \ +" You can use `--' or `-' to start an option.\n\ + You can use any unambiguous abbreviation for an option name.\n\ + You can separate option names and values with `=' or ` '.\n\ +" + +/* What to pass to `strtok' to separate different arguments to an + option, as in `-option=arg1,arg2,arg3'. It is useful to allow + whitespace as well so that the option value can come from a file, via + the shell construct "`cat file`" (including the quotes). */ +#define ARG_SEP ", \t\n" + + +/* This parses a string of unsigned integers separated by commas, and + returns a vector of the integers (as numbers). A -1 is appended to + mark the end of the list, hence the return type. */ +extern int *scan_unsigned_list (string); + +/* If S has the form <name>.<number><stuff>, as in `foo.1200gf', return + <number>, as a string; otherwise, return NULL. */ +extern string find_dpi (string s); + +#endif /* not CMDLINE_H */ + diff --git a/include/config.h b/include/config.h new file mode 100644 index 0000000..76bbe4d --- /dev/null +++ b/include/config.h @@ -0,0 +1,46 @@ +/* config.h: master configuration file, included first by all compilable + source files (not headers). + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef CONFIG_H +#define CONFIG_H + +/* Standard definitions. */ +#include <kpathsea/config.h> + +/* System dependencies that are figured out by `configure'. */ +#include "c-auto.h" + +/* ``Standard'' headers. */ +#include "c-std.h" + +/* Standard in ANSI C. */ +#include <assert.h> + +/* Usually declared in <math.h>, but not always. */ +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +/* Macros to discard or keep prototypes. */ +#include "c-proto.h" + +/* Some definitions of our own. */ +#include "global.h" + +#endif /* not CONFIG_H */ diff --git a/include/dirio.h b/include/dirio.h new file mode 100644 index 0000000..cb70915 --- /dev/null +++ b/include/dirio.h @@ -0,0 +1,55 @@ +/* dirio.h: checked directory operations. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef DIRIO_H +#define DIRIO_H + +#if DIRENT || _POSIX_VERSION +#include <dirent.h> +#define NLENGTH(dirent) strlen ((dirent)->d_name) +#else /* not (DIRENT or _POSIX_VERSION) */ +#define dirent direct +#define NLENGTH(dirent) ((dirent)->d_namlen) + +#ifdef SYSNDIR +#include <sys/ndir.h> +#endif + +#ifdef NDIR +#include <ndir.h> +#endif + +#ifdef SYSDIR +#include <sys/dir.h> +#endif + +#endif /* not (DIRENT or _POSIX_VERSION) */ + +/* Like opendir, closedir, and chdir, but abort if DIRNAME can't be opened. */ +extern DIR *xopendir P1H(string dirname); +extern void xclosedir P1H(DIR *); + +#if 0 +/* Returns true if FN is a directory (or a symlink to a directory). */ +extern boolean dir_p P1H(string fn); +#endif + +/* Returns true if FN is directory with no subdirectories. */ +extern boolean leaf_dir_p P1H(string fn); + +#endif /* not DIRIO_H */ diff --git a/include/edge.h b/include/edge.h new file mode 100644 index 0000000..83a4a9e --- /dev/null +++ b/include/edge.h @@ -0,0 +1,59 @@ +/* edge.h: declarations for edge traversing. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef EDGE_H +#define EDGE_H + +#include "bitmap.h" + +/* We consider each pixel to consist of four edges, and we travel along + edges, instead of through pixel centers. This is necessary for those + unfortunate times when a single pixel is on both an inside and an + outside outline. + + The numbers chosen here are not arbitrary; the code that figures out + which edge to move to depends on particular values. See the + `TRY_PIXEL' macro in `edge.c'. To emphasize this, I've written in the + numbers we need for each edge value. */ + +typedef enum +{ + top = 1, left = 2, bottom = 3, right = 0, no_edge = 4 +} edge_type; + +/* This choice is also not arbitrary: starting at the top edge makes the + code find outside outlines before inside ones, which is certainly + what we want. */ +#define START_EDGE top + + +/* Return the next outline edge on B in EDGE, ROW, and COL. */ +extern void next_outline_edge (bitmap_type b, edge_type *edge, + unsigned *row, unsigned *col); + +/* Return the next edge after START on the pixel ROW/COL in B that is + unmarked, according to the MARKED array. */ +extern edge_type next_unmarked_outline_edge (unsigned row, unsigned col, + edge_type start, bitmap_type b, + bitmap_type marked); + +/* Mark the edge E at the pixel ROW/COL in MARKED. */ +extern void mark_edge (edge_type e, unsigned row, unsigned col, + bitmap_type *marked); + +#endif /* not EDGE_H */ diff --git a/include/encoding.h b/include/encoding.h new file mode 100644 index 0000000..c464173 --- /dev/null +++ b/include/encoding.h @@ -0,0 +1,85 @@ +/* encoding.h: parse a font encoding (.enc) file. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef ENCODING_H +#define ENCODING_H + +#include "font.h" +#include "list.h" +#include <kpathsea/types.h> + + +/* A single character from the encoding file. Since we usually want to + deal with the entire collection of characters as a group, we don't + define any accessor macros for this structure, but rather the next. */ +typedef struct +{ + string name; + list_type ligature; +} encoding_char_type; + +/* The size of font's encoding vector (PostScript defines this). */ +#define ENCODING_VECTOR_SIZE 256 + +/* The collection of all the information from the file. */ +typedef struct +{ + string coding_scheme; + encoding_char_type encoding_char[ENCODING_VECTOR_SIZE]; +} encoding_info_type; + +/* The name of the encoding scheme in E_I. */ +#define ENCODING_SCHEME_NAME(e_i) ((e_i).coding_scheme) + +/* The Nth encoding character in E_I. */ +#define ENCODING_CHAR_ELT(e_i, n) ((e_i).encoding_char[n]) + +/* The name of the character CODE in the encoding structure E_I, or NULL + if the character doesn't exist. */ +#define ENCODING_CHAR_NAME(e_i, code) (ENCODING_CHAR_ELT (e_i, code).name) + +/* The ligature table for the character code in the encoding structure + E_I. Each element of the list is a pointer to a `tfm_ligature_type'. + The list is garbage if the character doesn't exist. */ +#define ENCODING_CHAR_LIG(e_i, code) (ENCODING_CHAR_ELT (e_i, code).ligature) + + +/* If an encoding file is mandatory for a program to operate, and the + user does not specify one, the program should use this. */ +#define DEFAULT_ENCODING "ascii" + +/* Returns the character code for the character named NAME in E_I, or -1 + if NAME is not present or NULL. */ +extern int encoding_number (encoding_info_type e_i, string name); + + +/* Return the basename for the encoding file in which the encoding + CODINGSCHEME can be found. Reads the library file (see `libfile.h') + `encoding.map'. Case is ignored in the comparison with + CODINGSCHEME. If CODINGSCHEME is not present in `encoding.map', + issue a warning and return some default. */ +extern string coding_scheme_to_filename (string codingscheme); + + +/* Read the library file (see `libfile.h') `FILENAME.enc', and return + the information it contains. If the file cannot be opened, give a + fatal error. */ +extern encoding_info_type read_encoding_file (string filename); + +#endif /* not ENCODING_H */ + diff --git a/include/file-input.h b/include/file-input.h new file mode 100644 index 0000000..cf9d16b --- /dev/null +++ b/include/file-input.h @@ -0,0 +1,51 @@ +/* file-input.h: declarations for file reading. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef FILE_INPUT_H +#define FILE_INPUT_H + +#include <stdio.h> +#include <kpathsea/types.h> + + + +/* Read some number of bytes from the file F. The FILENAME argument + is passed to perror(3), if the read fails, and then the program is + halted. The routines that get more than one byte assume the value is + stored in the file in BigEndian order, regardless of the host + architecture. */ + +extern one_byte get_byte (FILE *f, string filename); +extern two_bytes get_two (FILE *, string); +extern four_bytes get_four (FILE *, string); +extern signed_4_bytes get_signed_four (FILE *, string); +extern address get_n_bytes (unsigned n, FILE *, string); + +/* Back up some number of bytes, then read. */ +extern one_byte get_previous_byte (FILE *, string); +extern two_bytes get_previous_two (FILE *, string); +extern four_bytes get_previous_four (FILE *, string); + +/* Abort if the next or previous byte is not EXPECTED. */ +extern void match_byte (one_byte expected, FILE *, string); +extern void match_previous_byte (one_byte expected, FILE *, string); + +/* Abort if string of bytes is not STRING. */ +extern void match_string_of_bytes (string, FILE *, string); + +#endif /* not FILE_INPUT_H */ diff --git a/include/file-output.h b/include/file-output.h new file mode 100644 index 0000000..0331d6f --- /dev/null +++ b/include/file-output.h @@ -0,0 +1,43 @@ +/* file-output.h: declarations for file reading. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef FILE_OUTPUT_H +#define FILE_OUTPUT_H + +#include <stdio.h> +#include <kpathsea/types.h> + + + +/* Write some number of bytes to the file F. The FILENAME argument + is passed to perror(3), if the write fails, and then the program is + halted. */ +extern void put_byte (one_byte, FILE *f, string filename); +extern void put_two (two_bytes, FILE *, string); +extern void put_three (four_bytes, FILE *, string); +extern void put_four (four_bytes, FILE *, string); +extern void put_n_bytes (unsigned n, address, FILE *, string); + +/* We assume the number is already in two's complement, and so we merely + have to output the bits. */ +#define put_signed_byte put_byte +#define put_signed_two put_two +#define put_signed_three put_three +#define put_signed_four put_four + +#endif /* not FILE_OUTPUT_H */ diff --git a/include/filename.h b/include/filename.h new file mode 100644 index 0000000..67ec609 --- /dev/null +++ b/include/filename.h @@ -0,0 +1,42 @@ +/* filename.h: declarations for manipulating filenames. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef FILENAME_H +#define FILENAME_H + +#include <kpathsea/types.h> + + +/* This searches specifically for the PK font FONT_NAME at resolution + DPI. If FONT_NAME is absolute or explicitly relative, we simply + return whether `FONT_NAME.DPIpk' is readable. Otherwise, we use the + environment variables PKFONTS, then TEXPKS, then TEXFONTS for the + paths to search. We return NULL if the font cannot be found. */ +extern string find_pk_filename (string font_name, unsigned dpi); + +/* Like `find_pk_filename', except search for a GF font named + `FONT_NAME.DPIgf'. The environment variables used are GFFONTS then + TEXFONTS. We return NULL if the font cannot be found. */ +extern string find_gf_filename (string font_name, unsigned dpi); + +/* Like `find_pk_filename', except search for a TFM file named + `FONT_NAME.tfm'. The environment variable used is TEXFONTS. We + return NULL if the font cannot be found. */ +extern string find_tfm_filename (string font_name); + +#endif /* not FILENAME_H */ diff --git a/include/fix-num.h b/include/fix-num.h new file mode 100644 index 0000000..92f9a2c --- /dev/null +++ b/include/fix-num.h @@ -0,0 +1,36 @@ +/* fix-num.h: declarations for ``fix'' numbers, which are a 32-bit + word with 20 bits of fraction. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef FIX_NUM_H +#define FIX_NUM_H + +#include <kpathsea/types.h> + + + +/* The type. */ +typedef long fix_word; + +/* Conversions to and from C floating-point numbers. The conversions + may not be exact, but since we use this to represent physical + quantities, a tiny loss of accuracy does not matter. */ +extern const real fix_to_real (fix_word); +extern const fix_word real_to_fix (real); + +#endif /* not FIX_NUM_H */ diff --git a/include/font.h b/include/font.h new file mode 100644 index 0000000..886b3ce --- /dev/null +++ b/include/font.h @@ -0,0 +1,243 @@ +/* font.h: operations on fonts independent of a particular file format. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef FONT_LIBRARY_H +#define FONT_LIBRARY_H + +#include "bitmap.h" +#include "bounding-box.h" +#include "tfm.h" +#include <kpathsea/types.h> + + + +/* A font is a collection of characters, generally at a particular point + size and resolution. The `bitmap_font_type' structure holds + information that comes entirely from a bitmap file. */ +typedef struct +{ + real design_size; + string comment; + unsigned checksum; + string filename; +} bitmap_font_type; + +/* The design size is given in points. It is not necessarily + related to the actual dimensions of any of the characters in the + font; indeed, usually the design size is quite a bit larger than the + largest characters. */ +#define BITMAP_FONT_DESIGN_SIZE(f) ((f).design_size) + +/* Sometimes a font comes with a comment identifying its source, who + owns the trademark, or some such. */ +#define BITMAP_FONT_COMMENT(f) ((f).comment) + +/* The checksum found in the bitmap file. */ +#define BITMAP_FONT_CHECKSUM(f) ((f).checksum) + +/* The full pathname for the file that we opened. */ +#define BITMAP_FONT_FILENAME(f) ((f).filename) + + +/* Look for a font named FONT_NAME in PK or GF format, at resolution + DPI. This ignores any extension in FONT_NAME; it adds `.<dpi>gf' or + `.<dpi>pk'. The font is looked for using the PKFONTS, GFFONTS, and + TEXFONTS environment variables, just as with the TeX software. If + the font can't be found, this gives a fatal error. */ +extern bitmap_font_type get_bitmap_font (string font_name, unsigned dpi); + +/* `close_font', below, works for bitmap fonts, too. */ + +/* The `font_info_type' holds a `bitmap_font_type', and additional + information that we get from a font metric file. */ +typedef struct +{ + bitmap_font_type bitmap_font; + tfm_global_info_type tfm_font; + string tfm_filename; +} font_info_type; + +/* The bitmap information that is associated with this font. */ +#define FONT_BITMAP_FONT(f) ((f).bitmap_font) + +/* The TFM information. */ +#define FONT_TFM_FONT(f) ((f).tfm_font) + +/* The full pathname for the TFM file that we opened. */ +#define FONT_TFM_FILENAME(f) ((f).tfm_filename) + +/* The design size is given in points. It is not necessarily + related to the actual dimensions of any of the characters in the + font; indeed, usually the design size is quite a bit larger than the + largest characters. */ +#define FONT_DESIGN_SIZE(f) BITMAP_FONT_DESIGN_SIZE ((f).bitmap_font) + +/* Sometimes a font comes with a comment identifying its source, who + owns the trademark, or some such. */ +#define FONT_COMMENT(f) BITMAP_FONT_COMMENT ((f).bitmap_font) + + +/* This calls `get_bitmap_font'; in addition, it looks for FONT_NAME in + TFM format. If either the bitmap file or the metric file can't be + found, this gives a fatal error. */ +extern font_info_type get_font (string font_name, unsigned dpi); + +/* Close any open files associated with FONT_NAME, whether it was opened + with `get_bitmap_font' or `get_font'. */ +extern void close_font (string font_name); + +/* A character is a bitmap image, and is therefore at a particular size + and resolution. It is also at a particular position in a font. + Generally, characters also have `side bearings'---extra space at the + left and/or right of the character. (In some scripts, there is + also displacement above and/or below the character, but we don't take + that into account here.) */ + +typedef struct +{ + charcode_type code; + int set_width; + fix_word tfm_width; + bounding_box_type bb; + bitmap_type bitmap; +} char_info_type; + +/* The character code in our fonts is always between 0 and 255. */ +#define CHARCODE(c) ((c).code) + +/* The set width is given in pixels; it's the sum of the left side + bearing, the bitmap's width, and the right side bearing. */ +#define CHAR_SET_WIDTH(c) ((c).set_width) + +/* The TFM width is the character's true width divided by the design + size (expressed as a fix_word). */ +#define CHAR_TFM_WIDTH(c) ((c).tfm_width) + +/* Unlike the font's bounding box, the character bounding box is + guaranteed to be the tightest possible; i.e., no all-blank rows occur + at the top or bottom, and no all-blank columns occur at the left or + right. */ +#define CHAR_BB(c) ((c).bb) + +/* The pixels. See `bitmap.h'. */ +#define CHAR_BITMAP(c) ((c).bitmap) + + +/* Abbreviations for the width and height of a character's bitmap. */ +#define CHAR_BITMAP_WIDTH(c) BITMAP_WIDTH (CHAR_BITMAP (c)) +#define CHAR_BITMAP_HEIGHT(c) BITMAP_HEIGHT (CHAR_BITMAP (c)) + +/* Abbreviations for the parts of the character's bounding box. */ +#define CHAR_MIN_COL(c) MIN_COL (CHAR_BB (c)) +#define CHAR_MAX_COL(c) MAX_COL (CHAR_BB (c)) +#define CHAR_MIN_ROW(c) MIN_ROW (CHAR_BB (c)) +#define CHAR_MAX_ROW(c) MAX_ROW (CHAR_BB (c)) + + +/* The height of a character is how far it extends above the baseline. */ +#define CHAR_HEIGHT(c) (CHAR_MAX_ROW (c) >= 0 ? CHAR_MAX_ROW (c) : 0) + +/* The depth is far it extends below the baseline (but as a positive + number, e.g., if a character's bitmap goes down to row -4, the depth + is 4). */ +#define CHAR_DEPTH(c) (CHAR_MIN_ROW (c) < 0 ? -CHAR_MIN_ROW (c) : 0) + + +/* Abbreviations for the left and right side bearings, unless someone + else has already defined such macros (in which case they presumably + don't want ours). */ +#ifndef CHAR_LSB +#define CHAR_LSB CHAR_MIN_COL +#endif +#ifndef CHAR_RSB +#define CHAR_RSB(c) (CHAR_SET_WIDTH (c) - CHAR_MAX_COL (c)) +#endif + +/* Return the character numbered CODE in the font FONT_NAME, or NULL if + that character doesn't exist in that font. If `get_font' or + `get_bitmap_font' has not been previously called on FONT_NAME, + `get_char' gives a fatal error. */ +extern char_info_type *get_char (string font_name, charcode_type code); + + +/* Print a plain text representation of the character C to the file F. */ +extern void print_char (FILE *f, char_info_type c); + + +/* Typeset the TEXT in the font FONT_NAME, at a resolution of DPI. */ +extern bitmap_type string_to_bitmap (string text, + string font_name, unsigned dpi); + +/* A raw character is the byte string that defines the character in the + font file, in some format. */ + +typedef enum { pk_format, gf_format } bitmap_format_type; + +typedef struct +{ + bitmap_format_type bitmap_format; + charcode_type code; + one_byte *bytes; + unsigned allocated; + unsigned used; + bounding_box_type bb; + signed_4_bytes h_escapement; + fix_word tfm_width; +} raw_char_type; + +/* CHARCODE works to access the character code of a `raw_char_type' + variable. Likewise for the bounding box, horizontal escapement, and + TFM width. */ + +/* The file format the character definition was read from. */ +#define RAW_CHAR_BITMAP_FORMAT(rc) ((rc).bitmap_format) + +/* The bytes in the file that comprise the character definition. */ +#define RAW_CHAR_BYTES(rc) ((rc).bytes) + +/* The number of allocated bytes to which the buffer points. */ +#define RAW_CHAR_ALLOCATED(rc) ((rc).allocated) + +/* The number of bytes actually used. */ +#define RAW_CHAR_USED(rc) ((rc).used) + +/* A convenience macro for the first unused byte. */ +#define RAW_CHAR_UNUSED_START(rc) RAW_CHAR_BYTES (rc)[RAW_CHAR_USED (rc)] + + +/* Return the raw character numbered CODE in the font named FONT_NAME, + or NULL. The only useful operation on a raw character is to write it + to an output file with the appropriate format. */ +extern raw_char_type *get_raw_char (string font_name, + charcode_type code); + +/* Free all allocated storage in the raw character RAW_CHAR, including + the character itself. */ +extern void free_raw_char (raw_char_type *raw_char); + +/* Miscellanous constants. */ + +/* We will only deal with fonts that have at most this many characters, + although the bitmap formats allow more. */ +#define MAX_CHARCODE 255 + +/* Some font formats have pointers within the file (to other places in + the file). The null value for such pointers is -1. */ +#define NULL_BYTE_PTR (-1) + +#endif /* not FONT_LIBRARY_H */ diff --git a/include/fontmap.h b/include/fontmap.h new file mode 100644 index 0000000..b7e0bc2 --- /dev/null +++ b/include/fontmap.h @@ -0,0 +1,36 @@ +/* fontmap.h: declarations for reading a file to define additional font names. + +Copyright (C) 1993 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef FONTMAP_H +#define FONTMAP_H + +typedef struct map_element_struct +{ + char *key; + char *value; + struct map_element_struct *next; +} map_element_type; + +typedef map_element_type **map_type; + + +extern map_type map_create P1H(string *dir_list); + +extern char *map_lookup P2H(map_type map, char *key); + +#endif /* not FONTMAP_H */ diff --git a/include/gf.h b/include/gf.h new file mode 100644 index 0000000..c0d8bb2 --- /dev/null +++ b/include/gf.h @@ -0,0 +1,156 @@ +/* gf.h: manipulate generic font files. See Metafont: The Program, by + Don Knuth, (Volume D of Computers & Typesetting), chapter 46, among + other places, for the precise definition of this bitmap format. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef GENERIC_FONT_LIBRARY_H +#define GENERIC_FONT_LIBRARY_H + +#include "bitmap.h" +#include "bounding-box.h" +#include "font.h" +#include <kpathsea/types.h> + + + +/* At most one GF file can be open for reading (or writing) at a time. + You must call `gf_open_input_file' before using any of the `gf_get...' + routines; similarly for the output side. */ + +extern boolean gf_open_input_file (string filename); +extern void gf_close_input_file (void); + +extern boolean gf_open_output_file (string filename); +extern void gf_close_output_file (void); + +/* The only interesting information in the preamble is the comment. */ + +extern string gf_get_preamble (void); +extern void gf_put_preamble (string comment); + + +/* An important part of the postamble is the character locators. A + character exists in the GF file if its `char_pointer' member in this + structure is not `NULL_BYTE_PTR'. */ +typedef struct +{ + charcode_type charcode; + signed_4_bytes h_escapement; + fix_word tfm_width; + signed_4_bytes char_pointer; +} gf_char_locator_type; + + +typedef struct +{ + fix_word design_size; + unsigned checksum; + real h_resolution, v_resolution; + bounding_box_type font_bb; + gf_char_locator_type char_loc[MAX_CHARCODE + 1]; +} gf_postamble_type; + +/* The design size is given as a fix_word in TeX points. */ +#define GF_DESIGN_SIZE(p) ((p).design_size) + +/* The GF checksum should match the checksums in the TFM file and/or the + PK file, if they exist. */ +#define GF_CHECKSUM(p) ((p).checksum) + +/* We express the resolutions in pixels per point multiplied by 2^16. */ +#define GF_H_RESOLUTION(p) ((p).h_resolution) +#define GF_V_RESOLUTION(p) ((p).v_resolution) + +/* The font bounding box may not be the tightest possible. */ +#define GF_FONT_BB(p) ((p).font_bb) + +/* An abbreviation for a particular character locator. */ +#define GF_CHAR_LOC(p, code) ((p).char_loc[code]) + + +/* Return the postamble in the input file. */ +extern gf_postamble_type gf_get_postamble (void); + +/* Write the postamble to the output file. The library fills in the + information that is not given as arguments. This must be called + after all the characters have been written. The resolution arguments + should be given in pixels per inch. */ +extern void gf_put_postamble (fix_word design_size, + real h_resolution, real v_resolution); + +/* The characters are the most important information in the GF file. */ + +typedef struct +{ + charcode_type code; + bitmap_type bitmap; + bounding_box_type bb; + signed_4_bytes h_escapement; + fix_word tfm_width; +} gf_char_type; + +/* GF format actually allows character codes to be a full four bytes + long, but we cannot deal with such fonts. */ +#define GF_CHARCODE(gc) ((gc).code) + +/* The pixels. See `bitmap.h'. */ +#define GF_BITMAP(gc) ((gc).bitmap) + +/* GF format does not guarantee that the bounding box is the tightest + possible, but the reading routines do. */ +#define GF_CHAR_BB(gc) ((gc).bb) + +/* The set width, in pixels. */ +#define GF_H_ESCAPEMENT(gc) ((gc).h_escapement) + +/* The character width as a fix_word. */ +#define GF_TFM_WIDTH(gc) ((gc).tfm_width) + +/* Conveniently access each member of the bounding box. */ +#define GF_CHAR_MIN_COL(gc) (MIN_COL (GF_CHAR_BB (gc))) +#define GF_CHAR_MAX_COL(gc) (MAX_COL (GF_CHAR_BB (gc))) +#define GF_CHAR_MIN_ROW(gc) (MIN_ROW (GF_CHAR_BB (gc))) +#define GF_CHAR_MAX_ROW(gc) (MAX_ROW (GF_CHAR_BB (gc))) + +/* An abbreviation for the left side bearing ... */ +#define GF_CHAR_LSB GF_CHAR_MIN_COL + +/* ... and one for the right side bearing. */ +#define GF_CHAR_RSB(c) (GF_H_ESCAPEMENT (c) - GF_CHAR_MAX_COL (c)) + + +/* `gf_get_next_char' reads the next character from the input file and returns + it. It also returns (as an argument) whether a character was + actually found. If not, you've read to the postamble. */ +extern gf_char_type gf_get_next_char (boolean *found); + +/* `gf_get_char' returns a pointer to the character numbered CODE + in the input file, or a null pointer if that character doesn't exist. */ +extern gf_char_type *gf_get_char (charcode_type code); + +/* Read the character CODE but don't interpret it; the result is only + useful as a parameter to `gf_put_raw_char'. */ +extern raw_char_type *gf_get_raw_char (charcode_type code); + +/* Write the given character to the output file. */ +extern void gf_put_char (gf_char_type); + +/* Write the given raw character. */ +extern void gf_put_raw_char (raw_char_type); + +#endif /* not GENERIC_FONT_LIBRARY_H */ diff --git a/include/global.h b/include/global.h new file mode 100644 index 0000000..cb49189 --- /dev/null +++ b/include/global.h @@ -0,0 +1,151 @@ +/* global.h: extend the standard programming environment a little. This + is included from config.h, which everyone includes. + +Copyright (C) 1992, 93 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef GLOBAL_H +#define GLOBAL_H + +#include <kpathsea/lib.h> +#include <kpathsea/types.h> +#include "moretypes.h" + + +/* Define useful abbreviations. */ + +/* Printer's points, as defined by TeX (and good typesetters everywhere). */ +#define POINTS_PER_INCH 72.27 + +/* Convert a number V in pixels to printer's points, and vice versa, + assuming a resolution of DPI pixels per inch. */ +#define PIXELS_TO_POINTS(v, dpi) (POINTS_PER_INCH * (v) / (dpi)) +#define POINTS_TO_REAL_PIXELS(v, dpi) ((v) * (dpi) / POINTS_PER_INCH) +#define POINTS_TO_PIXELS(v, dpi) ((int) (POINTS_TO_REAL_PIXELS (v, dpi) + .5)) + +/* Some simple numeric operations. It is possible to define these much + more cleanly in GNU C, but we haven't done that (yet). */ +#define SQUARE(x) ((x) * (x)) +#define CUBE(x) ((x) * (x) * (x)) +#define SAME_SIGN(u,v) ((u) >= 0 && (v) >= 0 || (u) < 0 && (v) < 0) +#define ROUND(x) ((int) ((x) + .5 * SIGN (x))) +#define SIGN(x) ((x) > 0 ? 1 : (x) < 0 ? -1 : 0) + +#ifndef MAX +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#endif +#ifndef MIN +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif + +/* Too bad C doesn't define operators for these. */ +#define MAX_EQUALS(var, expr) if ((expr) > (var)) (var) = (expr) +#define MIN_EQUALS(var, expr) if ((expr) < (var)) (var) = (expr) + +/* Declarations for commonly-used routines we provide ourselves. The + ones here are only needed by us, so we do not provide them in + unprototyped form. Others are declared both ways in lib.h. */ + +/* Return the current date and time a la date(1). */ +extern string now (void); + +/* Check if a string is a valid floating-point or decimal integer. + Returns false if passed NULL. */ +extern boolean float_ok (string); +extern boolean integer_ok (string); + +/* My converses of atoi, atou, and atof. These all return dynamically + allocated strings. */ +extern string itoa (int); +extern string utoa (unsigned); +extern string xdtoa (double); + +/* Copies the file FROM to the file TO, then unlinks FROM. */ +extern void xrename (string from, string to); + +/* If P or *P is null, abort. Otherwise, call free(3) on P, + and then set *P to NULL. */ +extern void safe_free (address *p); + + +/* Math functions. */ + +/* Says whether V1 and V2 are within REAL_EPSILON of each other. + Fixed-point arithmetic would be better, to guarantee machine + independence, but it's so much more painful to work with. The value + here is smaller than can be represented in either a `fix_word' or a + `scaled_num', so more precision than this will be lost when we + output, anyway. */ +#define REAL_EPSILON 0.00001 +extern const boolean epsilon_equal (real v1, real v2); + +/* Arc cosine, in degrees. */ +extern const real acosd (real); + +/* Return the Euclidean distance between the two points. */ +extern const real distance (real_coordinate_type, real_coordinate_type); +extern const real int_distance (coordinate_type, coordinate_type); + +/* Slope between two points (delta y per unit x). */ +extern const real slope (real_coordinate_type, real_coordinate_type); + +/* Make a real coordinate from an integer one, and vice versa. */ +extern const real_coordinate_type int_to_real_coord (coordinate_type); +extern const coordinate_type real_to_int_coord (real_coordinate_type); + +/* Test if two integer points are adjacent. */ +extern const boolean points_adjacent_p (int row1, int col1, int r2, int c2); + +/* Find the largest and smallest elements of an array. */ +extern void find_bounds (real values[], unsigned value_count, + /* returned: */ real *the_min, real *the_max); + +/* Make all the elements in the array between zero and one. */ +extern real *map_to_unit (real * values, unsigned value_count); + + +/* String functions. */ + +/* Return (a fresh copy of) SOURCE beginning at START and ending at + LIMIT. (Or NULL if LIMIT < START.) */ +extern string substring (string source, const unsigned start, + const unsigned limit); + +/* Change all uppercase letters in S to lowercase. */ +extern string lowercasify (string s); + + +/* Character code parsing. */ + +/* If the string S parses as a character code, this sets *VALID to + `true' and returns the number. If it doesn't, it sets *VALID to + `false' and the return value is garbage. + + We allow any of the following possibilies: a single character, as in + `a' or `0'; a decimal number, as in `21'; an octal number, as in `03' + or `0177'; a hexadecimal number, as in `0x3' or `0xff'. */ +extern charcode_type parse_charcode (string s, boolean *valid); + +/* Like `parse_charcode', but gives a fatal error if the string isn't a + valid character code. */ +extern charcode_type xparse_charcode (string s); + +/* The environment variable name with which to look up auxiliary files. */ +#ifndef LIB_ENVVAR +#define LIB_ENVVAR "FONTUTIL_LIB" +#endif + +#endif /* not GLOBAL_H */ diff --git a/include/hexify.h b/include/hexify.h new file mode 100644 index 0000000..600998c --- /dev/null +++ b/include/hexify.h @@ -0,0 +1,33 @@ +/* hexify.h: change strings to ASCII hex characters. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef HEXIFY_H +#define HEXIFY_H + +#include <kpathsea/types.h> + + + +/* Convert the LENGTH bytes starting at DATA to a string in ASCII + hexadecimal, i.e., a string consisting entirely of the characters 0-9 + and a-f, and terminated with a null. The result is allocated with + malloc. */ +extern string hexify (one_byte *data, unsigned length); + +#endif /* not HEXIFY_H */ + diff --git a/include/identity.h b/include/identity.h new file mode 100644 index 0000000..9f09767 --- /dev/null +++ b/include/identity.h @@ -0,0 +1,26 @@ +/* identity.h. + +Copyright (C) 1995 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef IDENTITY_H +#define IDENTITY_H + +/* Return `hostname:pid' as a string. */ +extern string get_identity (void); + +#endif /* not IDENTITY_H */ + diff --git a/include/libfile.h b/include/libfile.h new file mode 100644 index 0000000..bb83d7a --- /dev/null +++ b/include/libfile.h @@ -0,0 +1,59 @@ +/* libfile.h: read auxiliary data files. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef LIBFILE_H +#define LIBFILE_H + +#include <kpathsea/types.h> + + +/* Open (close) the file `HEAD.SUFFIX' using the library path. Give a + fatal error if the file cannot be (has not been) opened. Only one + file can be open at a time. `libfile_start' returns the resulting + opened FILE structure, although this is commonly ignored by the + caller, in favor of using `libfile_line' (declared below) to read + from the file. */ +extern FILE *libfile_start (string head, string suffix); +extern void libfile_close (void); + + +/* The name (line number) of the currently open library file, or NULL (0). */ +extern string libfilename (void); +extern unsigned libfile_linenumber (void); + + +/* An abbreviation for common error messages. */ +#define LIBFILE_ERROR1(fmt, e1) \ + FATAL3 ("%s:%u: " fmt, libfilename (), libfile_linenumber (), e1); +#define LIBFILE_ERROR2(fmt, e1, e2) \ + FATAL4 ("%s:%u: " fmt, libfilename (), libfile_linenumber (), e1, e2); + +#define LIBFILE_WARN1(fmt, e1) \ + fprintf (stderr, "%s:%u: " fmt "\n", libfilename (), libfile_linenumber (),\ + e1) +#define LIBFILE_WARN2(fmt, e1, e2) \ + fprintf (stderr, "%s:%u: " fmt "\n", libfilename (), libfile_linenumber (),\ + e1, e2) + + +/* Return the next non-blank non-comment line in the currently open + library file, or NULL if at EOF. The terminating newline and any + trailing comment are also removed. */ +extern string libfile_line (void); + +#endif /* not LIBFILE_H */ diff --git a/include/list.h b/include/list.h new file mode 100644 index 0000000..98c9d73 --- /dev/null +++ b/include/list.h @@ -0,0 +1,56 @@ +/* list.h: simple list (represented as arrays) manipulation. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef LIST_H +#define LIST_H + +#include <kpathsea/types.h> + + + +typedef struct +{ + address *list; + unsigned size; +} list_type; + +/* The size of the list L. */ +#define LIST_SIZE(l) ((l).size) + +/* The address of the array of data. */ +#define LIST_DATA(l) ((l).list) + +/* Get the contents of the element at position INDEX in L. */ +#define LIST_ELT(l, index) LIST_DATA (l)[index] + +/* Get the last list element. */ +#define LIST_LAST_ELT(l) LIST_ELT (l, LIST_SIZE (l) - 1) + + +/* Constructor/destructor. */ +extern list_type list_init (void); +extern void list_free (list_type *); + +/* Returns a pointer to ELEMENT_SIZE bytes of memory allocated for the + new element. */ +extern address list_append (list_type *, unsigned element_size); + +/* An abbreviation for the usual case. */ +#define LIST_TAPPEND(l_ptr, type) list_append (l_ptr, sizeof (type)) + +#endif /* not LIST_H */ diff --git a/include/logreport.h b/include/logreport.h new file mode 100644 index 0000000..1909964 --- /dev/null +++ b/include/logreport.h @@ -0,0 +1,52 @@ +/* logreport.h: status reporting routines. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef LOGREPORT_H +#define LOGREPORT_H + +#include <stdio.h> +#include <kpathsea/types.h> + + +/* report.h is a separate file because the programs which use it are a + proper subset of the programs which use us. */ +#include "report.h" + + +/* The file we write information to. */ +extern FILE *log_file; + +/* Only write if this is true. */ +extern boolean logging; + +#define LOG(s) \ + do { if (logging) fputs (s, log_file); } while (0) +#define LOG1(s, e) \ + do { if (logging) fprintf (log_file, s, e); } while (0) +#define LOG2(s, e1, e2) \ + do { if (logging) fprintf (log_file, s, e1, e2); } while (0) +#define LOG3(s, e1, e2, e3) \ + do { if (logging) fprintf (log_file, s, e1, e2, e3); } while (0) +#define LOG4(s, e1, e2, e3, e4) \ + do { if (logging) fprintf (log_file, s, e1, e2, e3, e4); } while (0) +#define LOG5(s, e1, e2, e3, e4, e5) \ + do { if (logging) fprintf (log_file, s, e1, e2, e3, e4, e5); } while (0) + +extern void flush_log_output (void); + +#endif /* not LOGREPORT_H */ diff --git a/include/moretypes.h b/include/moretypes.h new file mode 100644 index 0000000..99b5dd8 --- /dev/null +++ b/include/moretypes.h @@ -0,0 +1,78 @@ +/* moretypes.h: common types beyond types.h. + +Copyright (C) 1993 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef MORETYPES_H +#define MORETYPES_H + +/* We use `real' for our floating-point variables. */ +typedef double real; + +/* A character code. Perhaps someday we will allow for 16-bit + character codes, but for now we are restricted to 256 characters per + font (like TeX and PostScript). */ +typedef unsigned char charcode_type; + + +/* Used in file formats. */ +typedef unsigned char one_byte; +typedef signed char signed_byte; +typedef unsigned short two_bytes; +typedef short signed_2_bytes; +typedef unsigned int four_bytes; +typedef int signed_4_bytes; +typedef int byte_count_type; + +/* These are intended to be used for output in file formats where a + ``byte'' is defined to be eight bits, regardless of the hardware. */ +#define ONE_BYTE_BIG (1 << 8) +#define TWO_BYTES_BIG (1 << 16) +#define THREE_BYTES_BIG (1 << 24) + + +/* Complex numbers. */ +typedef struct +{ + real real; + real imag; +} complex; +typedef enum { first_complex_part, second_complex_part} complex_part_type; +typedef enum { polar_rep, rectangular_rep} complex_rep_type; + + +/* Dimensions of a rectangle. */ +typedef struct +{ + unsigned height, width; +} dimensions_type; + +#define DIMENSIONS_HEIGHT(d) ((d).height) +#define DIMENSIONS_WIDTH(d) ((d).width) + + +/* Cartesian points. */ +typedef struct +{ + int x, y; +} coordinate_type; + +typedef struct +{ + double x, y; +} real_coordinate_type; + +#endif /* not MORETYPES_H */ diff --git a/include/paths.h b/include/paths.h new file mode 100644 index 0000000..69eedcd --- /dev/null +++ b/include/paths.h @@ -0,0 +1,25 @@ +/* Generated from paths.h.in (Wed Apr 21 13:14:26 PDT 2004). */ +/* Paths. */ + +/* If the environment variable `FONTUTIL_LIB' isn't set, use this + path instead to search for auxiliary files. */ +#ifndef DEFAULT_LIB_PATH +#define DEFAULT_LIB_PATH ".:/u/karl/gnu/src/fontutils/data:/usr/local/lib/fontutil" +#endif + +/* The meanings of these paths are described in `filename.h'. They are + exactly the same as those in the TeX distribution. */ + +/* The directories listed in these paths are searched for the various + font files. The current directory is always searched first. */ +#ifndef DEFAULT_TFM_PATH +#define DEFAULT_TFM_PATH ".:/usr/local/lib/tex/fonts//" +#endif + +#ifndef DEFAULT_PK_PATH +#define DEFAULT_PK_PATH ".:/usr/local/lib/tex/fonts//" +#endif + +#ifndef DEFAULT_GF_PATH +#define DEFAULT_GF_PATH ".:/usr/local/lib/tex/fonts//" +#endif diff --git a/include/pathsrch.h b/include/pathsrch.h new file mode 100644 index 0000000..6bda1dd --- /dev/null +++ b/include/pathsrch.h @@ -0,0 +1,53 @@ +/* pathsrch.h: environment-variable path searching for files, possibly + in subdirectories. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef PATHSEARCH_H +#define PATHSEARCH_H + +#include <kpathsea/types.h> + + +/* Look for FILENAME in each of the directories given in the DIR_LIST + array. (Unless DIR_LIST is null, or FILENAME is absolute or + explicitly relative, in which case we just look at FILENAME.) Return + the complete pathname of the first readable file found, or NULL. */ +extern string find_path_filename P2H(string filename, string *dir_list); + +/* Return a NULL-terminated array of all the directory names in the + value of the environment variable ENV_NAME (or DEFAULT_PATH if it is + not set). Each directory in the list ends with the directory separator, + e.g., `/'. + + A leading or trailing path separator (e.g., `:') in the value of + ENV_NAME is replaced by DEFAULT_PATH. + + If any element of the path ends with a double directory separator + (e.g., `foo//'), it is replaced by all its subdirectories. */ +extern string *initialize_path_list P2H(string env_name, string default_path); + +/* Replace a leading or trailing `:' in ENV_PATH with DEFAULT_PATH. If + neither is present, return ENV_PATH if that is non-null, else + DEFAULT_PATH. */ +extern string expand_default P2H(string env_path, string default_path); + +/* Replace a leading ~ or ~name in FILENAME with getenv ("HOME") or + name's home directory. */ +extern string expand_tilde P1H(string filename); + +#endif /* not PATHSEARCH_H */ diff --git a/include/pbm.h b/include/pbm.h new file mode 100644 index 0000000..a1e16f5 --- /dev/null +++ b/include/pbm.h @@ -0,0 +1,46 @@ +/* pbm.h - header file for libpbm portable bitmap library +*/ + +#ifndef _PBM_H_ +#define _PBM_H_ + +#include "pbmplus.h" + +typedef unsigned char bit; +#define PBM_WHITE 0 +#define PBM_BLACK 1 + + +/* Magic constants. */ + +#define PBM_MAGIC1 'P' +#define PBM_MAGIC2 '1' +#define RPBM_MAGIC2 '4' +#define PBM_FORMAT (PBM_MAGIC1 * 256 + PBM_MAGIC2) +#define RPBM_FORMAT (PBM_MAGIC1 * 256 + RPBM_MAGIC2) +#define PBM_TYPE PBM_FORMAT + + +/* Macro for turning a format number into a type number. */ + +#define PBM_FORMAT_TYPE(f) ((f) == PBM_FORMAT || (f) == RPBM_FORMAT ? PBM_TYPE : -1) + + +/* Declarations of routines. */ + +void pbm_init ARGS(( int* argcP, char* argv[] )); + +#define pbm_allocarray( cols, rows ) ((bit**) pm_allocarray( cols, rows, sizeof(bit) )) +#define pbm_allocrow( cols ) ((bit*) pm_allocrow( cols, sizeof(bit) )) +#define pbm_freearray( bits, rows ) pm_freearray( (char**) bits, rows ) +#define pbm_freerow( bitrow ) pm_freerow( (char*) bitrow ) + +bit** pbm_readpbm ARGS(( FILE* file, int* colsP, int* rowsP )); +void pbm_readpbminit ARGS(( FILE* file, int* colsP, int* rowsP, int* formatP )); +void pbm_readpbmrow ARGS(( FILE* file, bit* bitrow, int cols, int format )); + +void pbm_writepbm ARGS(( FILE* file, bit** bits, int cols, int rows, int forceplain )); +void pbm_writepbminit ARGS(( FILE* file, int cols, int rows, int forceplain )); +void pbm_writepbmrow ARGS(( FILE* file, bit* bitrow, int cols, int forceplain )); + +#endif /*_PBM_H_*/ diff --git a/include/pbmplus.h b/include/pbmplus.h new file mode 100644 index 0000000..e001fea --- /dev/null +++ b/include/pbmplus.h @@ -0,0 +1,196 @@ +/* pbmplus.h - header file for PBM, PGM, PPM, and PNM +** +** Copyright (C) 1988, 1989, 1991 by Jef Poskanzer. +** +** Permission to use, copy, modify, and distribute this software and its +** documentation for any purpose and without fee is hereby granted, provided +** that the above copyright notice appear in all copies and that both that +** copyright notice and this permission notice appear in supporting +** documentation. This software is provided "as is" without express or +** implied warranty. + + Configuration options modified for GNU --karl. +*/ + +#ifndef _PBMPLUS_H_ +#define _PBMPLUS_H_ + +#include <sys/types.h> +#include <stdio.h> + +#include "config.h" + + +#if 0 /* karl */ +#if ! ( defined(BSD) || defined(SYSV) || defined(MSDOS)) +/* CONFIGURE: If your system is >= 4.2BSD, set the BSD option; if you're a +** System V site, set the SYSV option; and if you're IBM-compatible, set +** MSDOS. If your compiler is ANSI C, you're probably better off setting +** SYSV. +*/ +#define BSD +/* #define SYSV */ +/* #define MSDOS */ +#endif +#endif + +/* CONFIGURE: If you want to enable writing "raw" files, set this option. +** "Raw" files are smaller, and much faster to read and write, but you +** must have a filesystem that allows all 256 ASCII characters to be read +** and written. You will no longer be able to mail P?M files without +** using uuencode or the equivalent, or running the files through pnmnoraw. +** Note that reading "raw" files works whether writing is enabled or not. +*/ +#define PBMPLUS_RAWBITS + +/* CONFIGURE: On some systems, the putc() macro is broken and will return +** EOF when you write out a 255. For example, ULTRIX does this. This +** only matters if you have defined RAWBITS. To test whether your system +** is broken this way, go ahead and compile things with RAWBITS defined, +** and then try "pbmmake -b 8 1 > file". If it works, fine. If not, +** define BROKENPUTC1 and try again - if that works, good. Otherwise, +** BROKENPUTC2 is guaranteed to work, although it's about twice as slow. +*/ +/* #define PBMPLUS_BROKENPUTC1 */ +/* #define PBMPLUS_BROKENPUTC2 */ + +#ifdef PBMPLUS_BROKENPUTC1 +#undef putc +/* This is a fixed version of putc() that should work on most Unix systems. */ +#define putc(x,p) (--(p)->_cnt>=0? ((int)(unsigned char)(*(p)->_ptr++=(unsigned char)(x))) : _flsbuf((unsigned char)(x),p)) +#endif /*PBMPLUS_BROKENPUTC1*/ +#ifdef PBMPLUS_BROKENPUTC2 +#undef putc +/* For this one, putc() becomes a function, defined in pbm/libpbm1.c. */ +#endif /*PBMPLUS_BROKENPUTC2*/ + +/* CONFIGURE: PGM can store gray values as either bytes or shorts. For most +** applications, bytes will be big enough, and the memory savings can be +** substantial. However, if you need more than 8 bits of resolution, then +** define this symbol. +** +** If you are not making PGM, you can ignore this. +*/ +/* #define PGM_BIGGRAYS */ + +/* CONFIGURE: Normally, PPM handles a pixel as a struct of three grays. +** It can also be configured to pack the three values into a single longword, +** 10 bits each. If you have configured PGM with the PGM_BIGGRAYS option +** (store grays as shorts), AND you don't need more than 10 bits for each +** color component, AND you care more about memory use than speed, then +** this option might be a win. Under these circumstances it will make +** some of the programs use 1.5 times less space, but all of the programs +** will run about 1.4 times slower. +** +** If you are not using PGM_BIGGRAYS, then this option is useless -- it +** doesn't save any space, but it still slows things down. +** +** If you are not making PPM, you can ignore this. +*/ +/* #define PPM_PACKCOLORS */ + +/* CONFIGURE: uncomment this to enable debugging checks. */ +/* #define DEBUG */ + +#if 0 /* karl */ +#ifdef SYSV +#include <string.h> +#define index strchr +#define rindex strrchr +#define srandom srand +#define random rand +#define bzero(dst,len) memset(dst, 0, len) +#define bcopy(src,dst,len) memcpy(dst, src, len) +#define bcmp memcmp +#else /*SYSV*/ +#include <strings.h> +#endif /*SYSV*/ +#endif /* 0 */ + +/* CONFIGURE: On some systems, malloc.h doesn't declare these, so we have +** to do it. On other systems, for example HP/UX, it declares them +** incompatibly. And some systems, for example Dynix, don't have a +** malloc.h at all. A sad situation. If you have compilation problems +** that point here, feel free to tweak or remove these declarations. +*/ +/* Thank you, I did remove them: +#include <malloc.h> +extern char* malloc(); +extern char* realloc(); +extern char* calloc(); +*/ +/* End of configurable definitions. */ + + +#undef max +#define max(a,b) ((a) > (b) ? (a) : (b)) +#undef min +#define min(a,b) ((a) < (b) ? (a) : (b)) +#undef abs +#define abs(a) ((a) >= 0 ? (a) : -(a)) +#undef odd +#define odd(n) ((n) & 1) + + +/* Definitions to make PBMPLUS work with either ANSI C or C Classic. */ + +#if __STDC__ +#define ARGS(alist) alist +#else /*__STDC__*/ +#define ARGS(alist) () +#define const +#endif /*__STDC__*/ + + +/* Initialization. */ + +void pm_init ARGS(( int* argcP, char* argv[] )); + + +/* Variable-sized arrays definitions. */ + +char** pm_allocarray ARGS(( int cols, int rows, int size )); +char* pm_allocrow ARGS(( int cols, int size )); +void pm_freearray ARGS(( char** its, int rows )); +void pm_freerow ARGS(( char* itrow )); + + +/* Case-insensitive keyword matcher. */ + +int pm_keymatch ARGS(( char* str, char* keyword, int minchars )); + + +/* Log base two hacks. */ + +int pm_maxvaltobits ARGS(( int maxval )); +int pm_bitstomaxval ARGS(( int bits )); + + +/* Error handling definitions. */ + +void pm_message( /* char* fmt, char* v1, char* v2, char* v3, char* v4, char* v5 */ ); /* prototypes can't handle this */ +void pm_error( /* char* fmt, char* v1, char* v2, char* v3, char* v4, char* v5 */ ); /* doesn't return */ +void pm_perror ARGS(( char* reason )); /* doesn't return */ +void pm_usage ARGS(( char* usage )); /* doesn't return */ + + +/* File open/close that handles "-" as stdin and checks errors. */ + +FILE* pm_openr ARGS(( char* name )); +FILE* pm_openw ARGS(( char* name )); +void pm_close ARGS(( FILE* f )); + + +/* Endian I/O. */ + +int pm_readbigshort ARGS(( FILE* in, short* sP )); +int pm_writebigshort ARGS(( FILE* out, short s )); +int pm_readbiglong ARGS(( FILE* in, long* lP )); +int pm_writebiglong ARGS(( FILE* out, long l )); +int pm_readlittleshort ARGS(( FILE* in, short* sP )); +int pm_writelittleshort ARGS(( FILE* out, short s )); +int pm_readlittlelong ARGS(( FILE* in, long* lP )); +int pm_writelittlelong ARGS(( FILE* out, long l )); + + +#endif /*_PBMPLUS_H_*/ diff --git a/include/pk.h b/include/pk.h new file mode 100644 index 0000000..1e7fd8b --- /dev/null +++ b/include/pk.h @@ -0,0 +1,95 @@ +/* pk.h: manipulate packed format font files. See the PKtype source + code (by Tomas Rokicki), among other places, for the precise + definition of this bitmap format. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef PACKED_FONT_LIBRARY_H +#define PACKED_FONT_LIBRARY_H + +#include "bounding-box.h" +#include "font.h" +#include <kpathsea/types.h> + + + +/* Prepare and finish off FONT_NAME for reading. */ +extern boolean pk_open_input_file (string font_name); +extern void pk_close_input_file (string font_name); + +/* The global information about the PK file is given in the preamble. */ +typedef struct +{ + string comment; + fix_word design_size; + unsigned checksum; + double h_resolution, v_resolution; +} pk_preamble_type; + +/* This usually indicates the source of the PK file. */ +#define PK_COMMENT(p) ((p).comment) + +/* The font's design size is in TeX points, expressed as a fix_word. */ +#define PK_DESIGN_SIZE(p) ((p).design_size) + +/* The PK checksum should match the checksums in the TFM file and/or the + GF file, if they exist. */ +#define PK_CHECKSUM(p) ((p).checksum) + +/* We express the resolutions in pixels per point multiplied by 2^16. */ +#define PK_H_RESOLUTION(p) ((p).h_resolution) +#define PK_V_RESOLUTION(p) ((p).v_resolution) + +/* Return the above structure for the font FONT_NAME. */ +extern pk_preamble_type pk_get_preamble (string font_name); + + + +/* The characters comprise the bulk of the file. */ +typedef struct +{ + one_byte code; + fix_word tfm_width; + signed_4_bytes h_escapement; + bounding_box_type bb; + bitmap_type bitmap; +} pk_char_type; + +/* The library guarantees that the character code is in the range 0 to + 255 (although the PK format does not require that). */ +#define PK_CHARCODE(c) ((c).code) + +/* The TFM width is the character's true width divided by the design + size (expressed as a fix_word). */ +#define PK_TFM_WIDTH(c) ((c).tfm_width) + +/* The horizontal escapement (i.e., set width) is in pixels. */ +#define PK_H_ESCAPEMENT(c) ((c).h_escapement) + +/* The bounding box is guaranteed to be the tightest possible. */ +#define PK_CHAR_BB(c) ((c).bb) + +/* The bits themselves. See `bitmap.h'. */ +#define PK_BITMAP(c) ((c).bitmap) + + +/* Allocate and return a pointer to the above structure for the + character CODE in the font FONT_NAME, or NULL if that character is + not in that font. */ +extern pk_char_type *pk_get_char (one_byte code, string font_name); + +#endif /* not PACKED_FONT_LIBRARY_H */ diff --git a/include/rand.h b/include/rand.h new file mode 100644 index 0000000..e2d91ae --- /dev/null +++ b/include/rand.h @@ -0,0 +1,35 @@ +/* rand.h: declarations for pseudo-random number generator. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef RAND_H +#define RAND_H + +/* Forgot the system's idea of `RAND_MAX'. (This must therefore be + included after <stdlib.h>.) */ +#ifdef RAND_MAX +#undef RAND_MAX +#endif +#define RAND_MAX ((unsigned) (1 << 31) - 2) + +/* Set the state of the random number generator. */ +extern void seed_rand (unsigned seed); + +/* Return a pseudo-random number between 0 and RAND_MAX. */ +extern int k_rand (void); + +#endif /* not RAND_H */ diff --git a/include/report.h b/include/report.h new file mode 100644 index 0000000..b1d615c --- /dev/null +++ b/include/report.h @@ -0,0 +1,57 @@ +/* report.h: status reporting routines. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef REPORT_H +#define REPORT_H + +#include <stdio.h> +#include <kpathsea/types.h> + + + +/* The file we write information to. */ +extern FILE *report_file; + +/* Only print anything if this is true. */ +extern boolean verbose; + + +#define REPORT(s) \ + do if (verbose) { fputs (s, report_file); fflush (report_file); } \ + while (0) + +#define REPORT1(s, e) \ + do if (verbose) { fprintf (report_file, s, e); fflush (report_file); }\ + while (0) + +#define REPORT2(s, e1, e2) \ + do if (verbose) { fprintf (report_file, s, e1, e2); \ + fflush (report_file); } \ + while (0) + +#define REPORT3(s, e1, e2, e3) \ + do if (verbose) { fprintf (report_file, s, e1, e2, e3); \ + fflush (report_file); } \ + while (0) + +#define REPORT4(s, e1, e2, e3, e4) \ + do if (verbose) { fprintf (report_file, s, e1, e2, e3, e4); \ + fflush (report_file); } \ + while (0) + +#endif /* not REPORT_H */ diff --git a/include/scaled-num.h b/include/scaled-num.h new file mode 100644 index 0000000..d4715a8 --- /dev/null +++ b/include/scaled-num.h @@ -0,0 +1,39 @@ +/* scaled-num.h: declarations for ``scaled'' numbers, which are a 32-bit + word with 16 bits of fraction. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef SCALED_NUM_H +#define SCALED_NUM_H + +#include <kpathsea/types.h> + + + +/* The type. */ +typedef long scaled; + +/* Print a scaled number, rounded to five digits. */ +extern void print_scaled (scaled); + +/* Conversions to and from C floating-point numbers. The conversions + may not be exact, but since we use this to represent physical + quantities, a tiny loss of accuracy does not matter. */ +extern const real scaled_to_real (scaled); +extern const scaled real_to_scaled (real); + +#endif /* not SCALED_NUM_H */ diff --git a/include/spline.h b/include/spline.h new file mode 100644 index 0000000..f6690cb --- /dev/null +++ b/include/spline.h @@ -0,0 +1,128 @@ +/* spline.h: manipulate the spline representation. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef SPLINE_H +#define SPLINE_H + +#include <stdio.h> +#include "bounding-box.h" +#include <kpathsea/types.h> + + + +/* Third degree is the highest we deal with. */ +typedef enum +{ + LINEAR = 1, QUADRATIC = 2, CUBIC = 3 +} polynomial_degree; + + +/* A Bezier spline can be represented as four points in the real plane: + a starting point, ending point, and two control points. The + curve always lies in the convex hull defined by the four points. It + is also convenient to save the divergence of the spline from the + straight line defined by the endpoints. */ +typedef struct +{ + real_coordinate_type v[4]; /* The control points. */ + polynomial_degree degree; + real linearity; +} spline_type; + +#define START_POINT(spl) ((spl).v[0]) +#define CONTROL1(spl) ((spl).v[1]) +#define CONTROL2(spl) ((spl).v[2]) +#define END_POINT(spl) ((spl).v[3]) +#define SPLINE_DEGREE(spl) ((spl).degree) +#define SPLINE_LINEARITY(spl) ((spl).linearity) + + +/* Return a spline structure. */ +extern spline_type new_spline (void); + +/* Print a spline on the given file. */ +extern void print_spline (FILE *, spline_type); + +/* Evaluate SPLINE at the given T value. */ +extern real_coordinate_type evaluate_spline (spline_type spline, real t); + + + +/* Each outline in a character is typically represented by many + splines. So, here is a list structure for that: */ +typedef struct +{ + spline_type *data; + unsigned length; +} spline_list_type; + +/* An empty list will have length zero (and null data). */ +#define SPLINE_LIST_LENGTH(s_l) ((s_l).length) + +/* The address of the beginning of the array of data. */ +#define SPLINE_LIST_DATA(s_l) ((s_l).data) + +/* The element INDEX in S_L. */ +#define SPLINE_LIST_ELT(s_l, index) (SPLINE_LIST_DATA (s_l)[index]) + +/* The last element in S_L. */ +#define LAST_SPLINE_LIST_ELT(s_l) \ + (SPLINE_LIST_DATA (s_l)[SPLINE_LIST_LENGTH (s_l) - 1]) + +/* The previous and next elements to INDEX in S_L. */ +#define NEXT_SPLINE_LIST_ELT(s_l, index) \ + SPLINE_LIST_ELT (s_l, ((index) + 1) % SPLINE_LIST_LENGTH (s_l)) +#define PREV_SPLINE_LIST_ELT(s_l, index) \ + SPLINE_LIST_ELT (s_l, index == 0 \ + ? SPLINE_LIST_LENGTH (s_l) - 1 \ + : index - 1) + +/* Construct and destroy new `spline_list_type' objects. */ +extern spline_list_type *new_spline_list (void); +extern spline_list_type *init_spline_list (spline_type); +extern void free_spline_list (spline_list_type *); + +/* Append the spline S to the list S_LIST. */ +extern void append_spline (spline_list_type *s_list, spline_type s); + +/* Append the elements in list S2 to S1, changing S1. */ +extern void concat_spline_lists (spline_list_type *s1, spline_list_type s2); + + + +/* Each character is in general made up of many outlines. So here is one + more list structure. */ +typedef struct +{ + spline_list_type *data; + unsigned length; +} spline_list_array_type; + +/* Turns out we can use the same definitions for lists of lists as for + just lists. But we define the usual names, just in case. */ +#define SPLINE_LIST_ARRAY_LENGTH SPLINE_LIST_LENGTH +#define SPLINE_LIST_ARRAY_DATA SPLINE_LIST_DATA +#define SPLINE_LIST_ARRAY_ELT SPLINE_LIST_ELT +#define LAST_SPLINE_LIST_ARRAY_ELT LAST_SPLINE_LIST_ELT + +/* The usual routines. */ +extern spline_list_array_type new_spline_list_array (void); +extern void free_spline_list_array (spline_list_array_type *); +extern void append_spline_list (spline_list_array_type *, spline_list_type); + +#endif /* not SPLINE_H */ diff --git a/include/statistics.h b/include/statistics.h new file mode 100644 index 0000000..a2f05c0 --- /dev/null +++ b/include/statistics.h @@ -0,0 +1,45 @@ +/* statistics.h: find the first and second moments. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef STATISTICS_H +#define STATISTICS_H + +#include <kpathsea/types.h> + + + + +typedef struct +{ + real mean; + real variance; +} statistics_type; + +/* Compute the statistics on A. */ +extern statistics_type statistics (real *a, unsigned length, + unsigned pertinent); + +/* Return the mean of the array A, assumed to have length LENGTH -- but + only PERTINENT of the entries really count. */ +extern real mean (real *a, unsigned length, unsigned pertinent); + +/* Similarly, for the standard deviation. */ +extern real standard_deviation (real *, real mean, unsigned length, + unsigned pertinent); + +#endif /* not STATISTICS_H */ diff --git a/include/str-lcase.h b/include/str-lcase.h new file mode 100644 index 0000000..dcc4d98 --- /dev/null +++ b/include/str-lcase.h @@ -0,0 +1,31 @@ +/* str-lcase.h: convert a string to lowercase. + +Copyright (C) 1992 Free Software Foundation, Inc. +This file was part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#ifndef STR_LCASE_H +#define STR_LCASE_H + +#include <kpathsea/types.h> + + +/* Return a malloced copy of S with all its uppercase letters replaced + with their lowercase counterparts. */ +extern string str_to_lower (string s); + +#endif /* not CASE_H */ diff --git a/include/tfm.h b/include/tfm.h new file mode 100644 index 0000000..aa904b7 --- /dev/null +++ b/include/tfm.h @@ -0,0 +1,300 @@ +/* tfm.h: read and write TeX font metric files. See Metafont: The + Program, by Don Knuth, (Volume D of Computers & Typesetting), chapter 45, + among other places, for the precise definition of this format. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef TFM_FONT_LIBRARY_H +#define TFM_FONT_LIBRARY_H + +#include "fix-num.h" +#include "list.h" +#include <kpathsea/types.h> + + + +/* Only one input file may be open at a time. You therefore do not give a + file as a parameter to the routines. */ +extern boolean tfm_open_input_file (string filename); +extern void tfm_close_input_file (void); + +/* The name of the currently open input file, or NULL if none. */ +extern string tfm_input_filename (void); + + +/* We output a property list file, since it is so much easier to deal + with than the binary tfm format. The program PLtoTF, which is part + of the standard TeX distribution, converts from the one to the other. */ +extern boolean tfm_open_pl_output_file (string filename); +extern void tfm_close_pl_output_file (void); + +/* This uses the PL filename to `tfm_open_pl_output_file' and invokes + PLtoTF to output a TFM file with the same root and extension `.tfm', + unless TFM_NAME is non-null, in which it is used. You should not + call `tfm_close_pl_output_file' before calling this. This flushes + all the data written before converting. */ +extern void tfm_convert_pl (string tfm_name, boolean verbose); + + +/* The restriction to 256 characters in a TFM file is part of the file + format, so this number should only be changed in the (very unlikely) + event that the file format changes. */ +#define TFM_SIZE 256 + +/* Fontwide information. All real values are in printer's points: + 72.27 points = 1 inch. */ + +/* TFM_MIN_DESIGNSIZE <= designsize < TFM_MAX_DESIGNSIZE. */ +#define TFM_MIN_DESIGNSIZE 1.0 +#define TFM_MAX_DESIGNSIZE 2048 + +/* Check that a design size's value is in range. */ +#define TFM_CHECK_DESIGN_SIZE(ds) \ +if ((ds) < TFM_MIN_DESIGNSIZE || TFM_MAX_DESIGNSIZE <= (ds)) \ + FATAL3 ("Design size %.2f is outside range %.1f to %d", \ + ds, TFM_MIN_DESIGNSIZE, TFM_MAX_DESIGNSIZE); + +/* The maximum number of global font parameters we allow. */ +#define TFM_MAX_FONTDIMENS 30 + +/* The maximum length of a codingscheme string. */ +#define TFM_MAX_CODINGSCHEME_LENGTH 39 + + +typedef struct +{ + charcode_type first_charcode, last_charcode; + four_bytes checksum; + real design_size; + string coding_scheme; + unsigned parameter_count; + real parameters[TFM_MAX_FONTDIMENS]; +} tfm_global_info_type; + +/* The checksum. */ +#define TFM_CHECKSUM(info) ((info).checksum) + +/* The design size of the font. */ +#define TFM_DESIGN_SIZE(info) ((info).design_size) + +/* The coding scheme. */ +#define TFM_CODING_SCHEME(info) ((info).coding_scheme) + +/* How many parameters are actually being used. */ +#define TFM_FONTDIMEN_COUNT(info) ((info).parameter_count) + +/* The NUMBERth parameter of the `tfm_global_info_type' variable INFO, + in points. Since font parameters are numbered starting at 1, and the + C array starts at 0, we subtract 1 from NUMBER. */ +#define TFM_FONTDIMEN(info, number) ((info).parameters[(number) - 1]) + +/* Like TFM_FONTDIMEN, but if NUMBER is out of range return RET. */ +#define TFM_SAFE_FONTDIMEN(info, number, ret) \ + ((number) - 1 < TFM_FONTDIMEN_COUNT (info) \ + ? TFM_FONTDIMEN (info, number) : (ret)) + +/* Define symbolic names for the numbers of the parameters we + recognize. Some numbers have more than one name. */ +#define TFM_SLANT_PARAMETER 1 +#define TFM_SPACE_PARAMETER 2 +#define TFM_STRETCH_PARAMETER 3 +#define TFM_SHRINK_PARAMETER 4 +#define TFM_XHEIGHT_PARAMETER 5 +#define TFM_QUAD_PARAMETER 6 +#define TFM_EXTRASPACE_PARAMETER 7 +#define TFM_NUM1_PARAMETER 8 +#define TFM_NUM2_PARAMETER 9 +#define TFM_NUM3_PARAMETER 10 +#define TFM_DENOM1_PARAMETER 11 +#define TFM_DENOM2_PARAMETER 12 +#define TFM_SUP1_PARAMETER 13 +#define TFM_SUP2_PARAMETER 14 +#define TFM_SUP3_PARAMETER 15 +#define TFM_SUB1_PARAMETER 16 +#define TFM_SUB2_PARAMETER 17 +#define TFM_SUPDROP_PARAMETER 18 +#define TFM_SUBDROP_PARAMETER 19 +#define TFM_DELIM1_PARAMETER 20 +#define TFM_DELIM2_PARAMETER 21 +#define TFM_AXISHEIGHT_PARAMETER 22 +#define TFM_DEFAULTRULETHICKNESS_PARAMETER 8 +#define TFM_BIGOPSPACING1_PARAMETER 9 +#define TFM_BIGOPSPACING2_PARAMETER 10 +#define TFM_BIGOPSPACING3_PARAMETER 11 +#define TFM_BIGOPSPACING4_PARAMETER 12 +#define TFM_BIGOPSPACING5_PARAMETER 13 + +/* These are not in any of the standard TeX fonts, but the information + is useful nevertheless. */ +#define TFM_LEADINGHEIGHT_PARAMETER 23 +#define TFM_LEADINGDEPTH_PARAMETER 24 +#define TFM_FONTSIZE_PARAMETER 25 +#define TFM_VERSION_PARAMETER 26 + +/* Return the global info from the current input font. */ +extern tfm_global_info_type tfm_get_global_info (void); + +/* We could have more routines here, one for each global quantity. + These call `tfm_get_global_info' for you, so that if all you are + interested in is, say, the interword space, you can get only that. */ +extern unsigned tfm_get_checksum (void); +extern double tfm_get_design_size (void); +extern string tfm_get_coding_scheme (void); +extern double tfm_get_interword_space (void); +extern double tfm_get_x_height (void); + + +/* Return an initialized structure. This doesn't read any files. */ +extern tfm_global_info_type tfm_init_global_info (void); + + +/* The `first_charcode', `last_charcode', and `parameter_count' + members of this structure are computed automatically. The rest of + the structure is output to the PL file. */ +extern void tfm_put_global_info (tfm_global_info_type); + + +/* Set the header in TFM_INFO according to the string S, which + should look like: <header-item>:<value>,<header-item>:<value>,..., + where each <header-item> is <header-item> can be one of the strings + `checksum', `designsize' or `codingscheme', with casefolding. `checksum' + requires <four-bytes>, `designsize' a <real>, with TFM_MIN_DESIGNSIZE + <= <real> <= TFM_MAX_DESIGNSIZE, and `codingscheme' a <string> of + length not greater than TFM_MAX_CODINGSCHEME_LENGTH and containing no + parentheses or commas. */ +extern void tfm_set_header (string s, tfm_global_info_type *tfm_info); + +/* Set the design (and font size) of TFM_INFO to DESIGN_SIZE, if they're + not set already. */ +extern void tfm_set_design_size (real design_size, + tfm_global_info_type *tfm_info); + +/* Set values in INFO according to the specification in S, which should + look like `<fontdimen>:<real>,<fontdimen>:<real>,...', where each + <fontdimen> is either a number between 1 and TFM_MAX_FONTDIMENS + or one of the standard names. */ +extern void tfm_set_fontdimens (string s, tfm_global_info_type *info); + +/* Return the fontdimen number of S if we recognize it as the name of a + fontdimen, else zero. */ +extern unsigned tfm_fontdimen_number (string s); + +/* Return the fontdimen name corresponding to the number N if there is + one, else NULL. The first fontdimen is numbered 1. If there is more + than one name for N, it's arbitrary which is returned. */ +extern string tfm_fontdimen_name (unsigned n); + +/* Set parameter P in INFO to V. Set any intervening parameters + between the previous last parameter set in TFM_INFO and P to zero. */ +extern void tfm_set_fontdimen (tfm_global_info_type *info, unsigned p, real v); + +/* Set the `fontsize' fontdimen in TFM_INFO to the designsize, if the + latter is set. */ +extern void tfm_set_fontsize (tfm_global_info_type *tfm_info); + +/* We store the character dimensions we read as both approximate + floating point values, in printer's points, and as (unscaled by the + design_size) `fix_word' values. On output, we look only at the + former. */ + +typedef struct +{ + boolean exists; + charcode_type code; + real width, height, depth, italic_correction; + fix_word fix_width, fix_height, fix_depth, fix_italic_correction; + list_type kern; + list_type ligature; +} tfm_char_type; + +/* Says whether or not this character was in the TFM file. */ +#define TFM_CHAR_EXISTS(tc) ((tc).exists) + +/* The character code. */ +#define TFM_CHARCODE(tc) ((tc).code) + +/* The (possibly negative) dimensions, in points and fixes. */ +#define TFM_WIDTH(tc) ((tc).width) +#define TFM_FIX_WIDTH(tc) ((tc).fix_width) +#define TFM_HEIGHT(tc) ((tc).height) +#define TFM_FIX_HEIGHT(tc) ((tc).fix_height) +#define TFM_DEPTH(tc) ((tc).depth) +#define TFM_FIX_DEPTH(tc) ((tc).fix_depth) +#define TFM_ITALIC_CORRECTION(tc) ((tc).italic_correction) +#define TFM_FIX_ITALIC_CORRECTION(tc) ((tc).fix_italic_correction) + +/* The kern list. */ +#define TFM_KERN(tc) ((tc).kern) + +/* The ligature list. */ +#define TFM_LIGATURE(tc) ((tc).ligature) + + +/* This allocates and returns an array of `TFM_SIZE' elements, filled + with the information in the input file about each character. */ +extern tfm_char_type *tfm_get_chars (void); + +/* Return a pointer to the TFM information about the single character + CODE, or NULL if the character CODE wasn't in the TFM file. */ +extern tfm_char_type *tfm_get_char (charcode_type code); + +/* Return a single initialized `tfm_char_type' structure, and an + initialized array of `TFM_SIZE' elements, respectively. These are + useful for output. */ +extern tfm_char_type tfm_new_char (void); +extern tfm_char_type *tfm_new_chars (void); + +/* Take an array of `TFM_SIZE' elements and outputs them to + the PL file. The fix_word dimensions aren't looked at. */ +extern void tfm_put_chars (tfm_char_type *); + +/* Output the single TFM character C. */ +extern void tfm_put_char (tfm_char_type c); + +/* When typesetting, the current character + `character' leads to + `ligature'. The TFM format was extended in 1990 to allow for more + complicated ligatures than this, but we do not make those + distinctions. */ +typedef struct +{ + charcode_type character; + charcode_type ligature; +} tfm_ligature_type; + +/* Similarly for kerns. */ +typedef struct +{ + charcode_type character; + real kern; +} tfm_kern_type; + + +/* Return the kern between the characters LEFT and RIGHT; if no such + kern exists, return zero. */ +extern real tfm_get_kern (tfm_char_type left, charcode_type right); + +/* Make the kern for the character RIGHT in the list of `tfm_kern_type's + KERN_LIST be K (taken to be printer's points), replacing any kern + already present. */ +extern void tfm_set_kern (list_type *kern_list, charcode_type right, real k); + +/* Add a ligature in LIG_LIST for the character RIGHT to yield LIGATURE, + replacing any ligature already present. */ +extern void tfm_set_ligature (list_type *lig_list, charcode_type right, + charcode_type ligature); + +#endif /* not TFM_FONT_LIBRARY_H */ diff --git a/include/varstring.h b/include/varstring.h new file mode 100644 index 0000000..0768e4b --- /dev/null +++ b/include/varstring.h @@ -0,0 +1,64 @@ +/* varstring.h: variable-length strings. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef VARSTRING_H +#define VARSTRING_H + +#include <kpathsea/types.h> + + + +/* Initialize a variable-length string. */ +typedef struct +{ + unsigned allocated; + unsigned used; + string data; +} variable_string; + +/* The data characters. */ +#define VS_CHARS(vs) ((vs).data) + +/* This is the number of bytes allocated for the string. */ +#define VS_ALLOCATED(vs) ((vs).allocated) + +/* This is the number of bytes used. */ +#define VS_USED(vs) ((vs).used) + + +/* Create a new structure, initializing the data to a null byte. */ +extern variable_string vs_init (void); + +/* Free the string. */ +extern void vs_free (variable_string *); + + +/* Put NEW_CHAR at position POS in S. POS may be beyond the current + length of S. You are responsible for putting a null at the end of + the string when you are done constructing it, if you want one. */ +extern void vs_set_char (variable_string *s, unsigned pos, char new_char); + +/* Put NEW_CHAR at the end of V. As with `vs_set_char', no null is + appended. */ +extern void vs_append_char (variable_string *v, char new_char); + +/* Return concatenation of VS1 and VS2 in a new variable string. */ +extern variable_string vs_concat (variable_string vs1, variable_string vs2); + +#endif /* not VARSTRING_H */ + diff --git a/include/vector.h b/include/vector.h new file mode 100644 index 0000000..cf58143 --- /dev/null +++ b/include/vector.h @@ -0,0 +1,103 @@ +/* vector.h: operations on vectors and points. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef VECTOR_H +#define VECTOR_H + +#include <kpathsea/types.h> + + +/* Our vectors are represented as displacements along the x and y axes. */ + +typedef struct +{ + real dx, dy; +} vector_type; + + +/* Consider a point as a vector from the origin. */ +extern const vector_type make_vector (const real_coordinate_type); + +/* And a vector as a point, i.e., a displacement from the origin. */ +extern const real_coordinate_type vector_to_point (const vector_type); + + +/* Definitions for these common operations can be found in any decent + linear algebra book, and most calculus books. */ + +extern const real magnitude (const vector_type); +extern const vector_type normalize (const vector_type); + +extern const vector_type Vadd (const vector_type, const vector_type); +extern const real Vdot (const vector_type, const vector_type); +extern const vector_type Vmult_scalar (const vector_type, const real); +extern const real Vangle (const vector_type in, const vector_type out); + +/* These operations could have been named `P..._vector' just as well as + V..._point, so we may as well allow both names. */ +#define Padd_vector Vadd_point +extern const real_coordinate_type Vadd_point + (const real_coordinate_type, const vector_type); + +#define Psubtract_vector Vsubtract_point +extern const real_coordinate_type Vsubtract_point + (const real_coordinate_type, const vector_type); + +/* This returns the rounded sum. */ +#define IPadd_vector Vadd_int_point +extern const coordinate_type Vadd_int_point + (const coordinate_type, const vector_type); + +/* Take the absolute value of both components. */ +extern const vector_type Vabs (const vector_type); + + + +/* Operations on points with real coordinates. It is not orthogonal, + but more convenient, to have the subtraction operator return a + vector, and the addition operator return a point. */ +extern const vector_type Psubtract + (const real_coordinate_type, const real_coordinate_type); + +/* These are heavily used in spline fitting, so we define them as macros + instead of functions. */ +#define Padd(rc1, rc2) \ + ((real_coordinate_type) { (rc1).x + (rc2).x, (rc1).y + (rc2).y }) +#define Pmult_scalar(rc, r) \ + ((real_coordinate_type) { (rc).x * (r), (rc).y * (r) }) + +#if 0 +extern const real_coordinate_type Padd (real_coordinate_type, + real_coordinate_type); +extern const real_coordinate_type Pmult_scalar (real_coordinate_type, real); +#endif + +/* Similarly, for points with integer coordinates; here, a subtraction + operator that does return another point is useful. */ +extern const vector_type IPsubtract + (const coordinate_type, const coordinate_type); +extern const coordinate_type IPsubtractP + (const coordinate_type, const coordinate_type); +extern const coordinate_type IPadd + (const coordinate_type, const coordinate_type); +extern const coordinate_type IPmult_scalar (const coordinate_type, const int); +extern const real_coordinate_type IPmult_real + (const coordinate_type, const real); +extern const boolean IPequal (const coordinate_type, const coordinate_type); + +#endif /* not VECTOR_H */ diff --git a/include/xmessage.h b/include/xmessage.h new file mode 100644 index 0000000..f9a75a3 --- /dev/null +++ b/include/xmessage.h @@ -0,0 +1,35 @@ +/* message.h: temporarily display a message under X11. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef MESSAGE_H +#define MESSAGE_H + +#include <kpathsea/types.h> +#include "xt-common.h" + + +/* Using the widget W as the parent, display the string S in a popup + window, using the Label widget. The ARGS and N_ARGS parameters are + used when the Label is created. */ +extern void x_message + (Widget w, string s, ArgList args, Cardinal n_args); + +/* Equivalent to `x_message (W, s ".", NULL, 0)'. */ +extern void x_warning (Widget w, string s); + +#endif /* not MESSAGE_H */ diff --git a/include/xt-common.h b/include/xt-common.h new file mode 100644 index 0000000..0f05b45 --- /dev/null +++ b/include/xt-common.h @@ -0,0 +1,140 @@ +/* xt-common.h: declarations that all programs using Xt need. + +Copyright (C) 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef XT_COMMON_H +#define XT_COMMON_H + +/* See the kpathsea/INSTALL file for the purpose of the FOIL... */ +#ifndef FOIL_X_WCHAR_T +#define wchar_t foil_x_defining_wchar_t +#define X_WCHAR +#endif +#undef input /* the XWMHints structure has a field named `input' */ +#undef output +#include <X11/Intrinsic.h> +#include <X11/StringDefs.h> + + +/* Our own definitions. */ + +/* It is convenient to have this type for declaring action procedures. */ +typedef void action_proc_type (Widget, XEvent *, String *, Cardinal *); + +/* We virtually always want an arg array and its length together in + parameter lists. */ +#define XTARG(arg_array) (arg_array), XtNumber (arg_array) + +/* Assign a value to an Xt argument. */ +#define XTASSIGN_ARG(arg, val) (arg).value = (XtArgVal) (val) + +/* We use command buttons the same way in all programs, so here are + macros to make it easy to use them. */ + +/* Our buttons only have one procedure associated with them. This macro + expands into an XtCallbackRec array. */ +#define SINGLE_CALLBACK(proc, data) \ + { { (XtCallbackProc) proc, (XtPointer) (data) }, \ + { NULL, NULL } \ + } + +/* This macro declares a command widget. The routine that performs the + action should be named `NAME_command'; it will be passed the + CLIENT_DATA argument. The string TITLE appears in the window. */ +#define DECLARE_BUTTON(name, title, client_data) \ + XtCallbackRec name##_callback_list[] \ + = SINGLE_CALLBACK (name##_command, client_data); \ + Arg name##_args[] \ + = { { XtNfromHoriz, (XtArgVal) NULL }, /* We assign to this below. */\ + { XtNlabel, (XtArgVal) title }, \ + { XtNcallback, (XtArgVal) name##_callback_list }, \ + }; \ + Widget name##_widget /* The invoker supplies the semicolon. */ + + +/* This macro defines a command button NAME, by using the variables + that DECLARE_BUTTON creates. It also keeps track of the widget that + should be to the left of the new one, by assuming a variable + `widget_to_the_left'. */ + +#define DEFINE_BUTTON(name, parent) \ + name##_args[0].value = (XtArgVal) widget_to_the_left; \ + name##_widget = XtCreateManagedWidget (#name, commandWidgetClass, \ + parent, XTARG (name##_args)); \ + widget_to_the_left = name##_widget + /* The invoker supplies the semicolon. */ + + +/* Parse a character code in STR; if invalid, give a warning. If valid, + assign the value to CODE. Return whether it was valid. */ +#define XTPARSE_CHARCODE(code, str, widget) \ + ({ \ + boolean valid; \ + charcode_type test = parse_charcode (str, &valid); \ + \ + if (valid) \ + code = test; \ + else \ + { \ + string s = concat3 ("`", str, "': invalid character code"); \ + x_warning (XtParent (widget), s); \ + free (s); \ + }; \ + valid; \ + }) + + +/* Find the widget whose name is NAME in the widget tree rooted at + TOP. If no such widget can be found, give a fatal error. + + We use the extra variable `root' in case `top' is an expression + involving some other widget named `w'. */ +#define XFIND_WIDGET(top, name) \ + ({ \ + Widget root = top; \ + Widget w = XtNameToWidget (root, name); \ + if (w == NULL) \ + { \ + string s = concat3 ("Cannot find widget `", name, "'."); \ + XtErrorMsg ("noWidget", "FindWidget", "Error", s, NULL, 0); \ + } \ + w; \ + }) + + +/* For consistency, so we can give `Pointer' as a `type' below. */ +typedef XtPointer Pointer; + +/* We define our widget resources in a predictable way. We assume an + `OFFSET' macro has been defined as, e.g., + #define OFFSET(field) XtOffset (BitmapWidget, bitmap.field) +*/ +#define DEFINE_RESOURCE(name, field_name, class_name, type, \ + default_type, default) \ + { XtN##name, XtC##class_name, XtR##type, sizeof (type), \ + OFFSET (field_name), XtR##default_type, (XtPointer) (default) } + +#define IMMEDIATE_RESOURCE2(name, field_name, class_name, type, default)\ + DEFINE_RESOURCE (name, field_name, class_name, type, Immediate, default) + +#define IMMEDIATE_RESOURCE(name, class_name, type, default) \ + IMMEDIATE_RESOURCE2 (name, name, class_name, type, default) + +#define STRING_RESOURCE(name, class_name, default) \ + DEFINE_RESOURCE (name, name, class_name, String, String, default) + +#endif /* not XT_COMMON_H */ |