xref: /netbsd-src/external/gpl2/groff/dist/src/preproc/pic/pic.h (revision 89a07cf815a29524268025a1139fac4c5190f765)
1 /*	$NetBSD: pic.h,v 1.1.1.1 2016/01/13 18:41:48 christos Exp $	*/
2 
3 // -*- C++ -*-
4 /* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2003, 2005
5    Free Software Foundation, Inc.
6      Written by James Clark (jjc@jclark.com)
7 
8 This file is part of groff.
9 
10 groff is free software; you can redistribute it and/or modify it under
11 the terms of the GNU General Public License as published by the Free
12 Software Foundation; either version 2, or (at your option) any later
13 version.
14 
15 groff is distributed in the hope that it will be useful, but WITHOUT ANY
16 WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
18 for more details.
19 
20 You should have received a copy of the GNU General Public License along
21 with groff; see the file COPYING.  If not, write to the Free Software
22 Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
23 
24 #include "lib.h"
25 
26 #include <math.h>
27 #include <stdlib.h>
28 #include <errno.h>
29 
30 #ifdef NEED_DECLARATION_RAND
31 #undef rand
32 extern "C" {
33   int rand();
34 }
35 #endif /* NEED_DECLARATION_RAND */
36 
37 #ifdef NEED_DECLARATION_SRAND
38 #undef srand
39 extern "C" {
40 #ifdef RET_TYPE_SRAND_IS_VOID
41   void srand(unsigned int);
42 #else
43   int srand(unsigned int);
44 #endif
45 }
46 #endif /* NEED_DECLARATION_SRAND */
47 
48 #ifndef HAVE_FMOD
49 extern "C" {
50   double fmod(double, double);
51 }
52 #endif
53 
54 #include "assert.h"
55 #include "cset.h"
56 #include "stringclass.h"
57 #include "errarg.h"
58 #include "error.h"
59 #include "position.h"
60 #include "text.h"
61 #include "output.h"
62 
63 #ifndef M_SQRT2
64 #define M_SQRT2	1.41421356237309504880
65 #endif
66 
67 #ifndef M_PI
68 #define M_PI 3.14159265358979323846
69 #endif
70 
71 class input {
72   input *next;
73 public:
74   input();
75   virtual ~input();
76   virtual int get() = 0;
77   virtual int peek() = 0;
78   virtual int get_location(const char **, int *);
79   friend class input_stack;
80   friend class copy_rest_thru_input;
81 };
82 
83 class file_input : public input {
84   FILE *fp;
85   const char *filename;
86   int lineno;
87   string line;
88   const char *ptr;
89   int read_line();
90 public:
91   file_input(FILE *, const char *);
92   ~file_input();
93   int get();
94   int peek();
95   int get_location(const char **, int *);
96 };
97 
98 void lex_init(input *);
99 int get_location(char **, int *);
100 
101 void do_copy(const char *file);
102 void parse_init();
103 void parse_cleanup();
104 
105 void lex_error(const char *message,
106 	       const errarg &arg1 = empty_errarg,
107 	       const errarg &arg2 = empty_errarg,
108 	       const errarg &arg3 = empty_errarg);
109 
110 void lex_warning(const char *message,
111 		 const errarg &arg1 = empty_errarg,
112 		 const errarg &arg2 = empty_errarg,
113 		 const errarg &arg3 = empty_errarg);
114 
115 void lex_cleanup();
116 
117 extern int flyback_flag;
118 extern int command_char;
119 // zero_length_line_flag is non-zero if zero-length lines are drawn
120 // as dots by the output device
121 extern int zero_length_line_flag;
122 extern int driver_extension_flag;
123 extern int compatible_flag;
124 extern int safer_flag;
125 extern char *graphname;
126