xref: /original-bsd/contrib/groff-1.08/pic/pic.h (revision 0ac4996f)
1 // -*- C++ -*-
2 /* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
3      Written by James Clark (jjc@jclark.com)
4 
5 This file is part of groff.
6 
7 groff is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
11 
12 groff is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License along
18 with groff; see the file COPYING.  If not, write to the Free Software
19 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
20 
21 #include <stdio.h>
22 #include <unistd.h>
23 #include <string.h>
24 #include <math.h>
25 #include <stdlib.h>
26 #include <errno.h>
27 
28 extern "C" {
29   double hypot(double, double);
30 }
31 
32 #include "assert.h"
33 #include "cset.h"
34 #include "lib.h"
35 #include "stringclass.h"
36 #include "errarg.h"
37 #include "error.h"
38 #include "position.h"
39 #include "text.h"
40 #include "output.h"
41 
42 #ifndef M_SQRT2
43 #define M_SQRT2	1.41421356237309504880
44 #endif
45 
46 #ifndef M_PI
47 #define M_PI 3.14159265358979323846
48 #endif
49 
50 class input {
51   input *next;
52 public:
53   input();
54   virtual ~input();
55   virtual int get() = 0;
56   virtual int peek() = 0;
57   virtual int get_location(const char **, int *);
58   friend class input_stack;
59   friend class copy_rest_thru_input;
60 };
61 
62 class file_input : public input {
63   FILE *fp;
64   const char *filename;
65   int lineno;
66   string line;
67   const char *ptr;
68   int read_line();
69 public:
70   file_input(FILE *, const char *);
71   ~file_input();
72   int get();
73   int peek();
74   int get_location(const char **, int *);
75 };
76 
77 void lex_init(input *);
78 int get_location(char **, int *);
79 
80 void do_copy(const char *file);
81 void parse_init();
82 void parse_cleanup();
83 
84 void lex_error(const char *message,
85 	       const errarg &arg1 = empty_errarg,
86 	       const errarg &arg2 = empty_errarg,
87 	       const errarg &arg3 = empty_errarg);
88 
89 void lex_warning(const char *message,
90 		 const errarg &arg1 = empty_errarg,
91 		 const errarg &arg2 = empty_errarg,
92 		 const errarg &arg3 = empty_errarg);
93 
94 void lex_cleanup();
95 
96 extern int flyback_flag;
97 extern int command_char;
98 // zero_length_line_flag is non-zero if zero-length lines are drawn
99 // as dots by the output device
100 extern int zero_length_line_flag;
101 extern int driver_extension_flag;
102 extern int compatible_flag;
103