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