pic.h revision 114402
175584Sru// -*- C++ -*-
2114402Sru/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2003
3104862Sru   Free Software Foundation, Inc.
475584Sru     Written by James Clark (jjc@jclark.com)
575584Sru
675584SruThis file is part of groff.
775584Sru
875584Srugroff is free software; you can redistribute it and/or modify it under
975584Sruthe terms of the GNU General Public License as published by the Free
1075584SruSoftware Foundation; either version 2, or (at your option) any later
1175584Sruversion.
1275584Sru
1375584Srugroff is distributed in the hope that it will be useful, but WITHOUT ANY
1475584SruWARRANTY; without even the implied warranty of MERCHANTABILITY or
1575584SruFITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1675584Srufor more details.
1775584Sru
1875584SruYou should have received a copy of the GNU General Public License along
1975584Sruwith groff; see the file COPYING.  If not, write to the Free Software
2075584SruFoundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
2175584Sru
22104862Sru#include "lib.h"
23104862Sru
2475584Sru#include <math.h>
2575584Sru#include <stdlib.h>
2675584Sru#include <errno.h>
2775584Sru
2875584Sru#ifdef NEED_DECLARATION_HYPOT
2975584Sruextern "C" {
3075584Sru  double hypot(double, double);
3175584Sru}
3275584Sru#endif /* NEED_DECLARATION_HYPOT */
3375584Sru
34114402Sru#ifdef NEED_DECLARATION_RAND
35114402Sru#undef rand
36114402Sruextern "C" {
37114402Sru  int rand();
38114402Sru}
39114402Sru#endif /* NEED_DECLARATION_RAND */
40114402Sru
41114402Sru#ifdef NEED_DECLARATION_SRAND
42114402Sru#undef srand
43114402Sruextern "C" {
44114402Sru#ifdef RET_TYPE_SRAND_IS_VOID
45114402Sru  void srand(unsigned int);
46114402Sru#else
47114402Sru  int srand(unsigned int);
48114402Sru#endif
49114402Sru}
50114402Sru#endif /* NEED_DECLARATION_SRAND */
51114402Sru
52114402Sru#ifndef HAVE_FMOD
53114402Sruextern "C" {
54114402Sru  double fmod(double, double);
55114402Sru}
56114402Sru#endif
57114402Sru
5875584Sru#include "assert.h"
5975584Sru#include "cset.h"
6075584Sru#include "stringclass.h"
6175584Sru#include "errarg.h"
6275584Sru#include "error.h"
6375584Sru#include "position.h"
6475584Sru#include "text.h"
6575584Sru#include "output.h"
6675584Sru
6775584Sru#ifndef M_SQRT2
6875584Sru#define M_SQRT2	1.41421356237309504880
6975584Sru#endif
7075584Sru
7175584Sru#ifndef M_PI
7275584Sru#define M_PI 3.14159265358979323846
7375584Sru#endif
7475584Sru
7575584Sruclass input {
7675584Sru  input *next;
7775584Srupublic:
7875584Sru  input();
7975584Sru  virtual ~input();
8075584Sru  virtual int get() = 0;
8175584Sru  virtual int peek() = 0;
8275584Sru  virtual int get_location(const char **, int *);
8375584Sru  friend class input_stack;
8475584Sru  friend class copy_rest_thru_input;
8575584Sru};
8675584Sru
8775584Sruclass file_input : public input {
8875584Sru  FILE *fp;
8975584Sru  const char *filename;
9075584Sru  int lineno;
9175584Sru  string line;
9275584Sru  const char *ptr;
9375584Sru  int read_line();
9475584Srupublic:
9575584Sru  file_input(FILE *, const char *);
9675584Sru  ~file_input();
9775584Sru  int get();
9875584Sru  int peek();
9975584Sru  int get_location(const char **, int *);
10075584Sru};
10175584Sru
10275584Sruvoid lex_init(input *);
10375584Sruint get_location(char **, int *);
10475584Sru
10575584Sruvoid do_copy(const char *file);
10675584Sruvoid parse_init();
10775584Sruvoid parse_cleanup();
10875584Sru
10975584Sruvoid lex_error(const char *message,
11075584Sru	       const errarg &arg1 = empty_errarg,
11175584Sru	       const errarg &arg2 = empty_errarg,
11275584Sru	       const errarg &arg3 = empty_errarg);
11375584Sru
11475584Sruvoid lex_warning(const char *message,
11575584Sru		 const errarg &arg1 = empty_errarg,
11675584Sru		 const errarg &arg2 = empty_errarg,
11775584Sru		 const errarg &arg3 = empty_errarg);
11875584Sru
11975584Sruvoid lex_cleanup();
12075584Sru
12175584Sruextern int flyback_flag;
12275584Sruextern int command_char;
12375584Sru// zero_length_line_flag is non-zero if zero-length lines are drawn
12475584Sru// as dots by the output device
12575584Sruextern int zero_length_line_flag;
12675584Sruextern int driver_extension_flag;
12775584Sruextern int compatible_flag;
12875584Sruextern int safer_flag;
129114402Sruextern char *graphname;
130