175584Sru// -*- C++ -*-
2114402Sru/* Copyright (C) 1989, 1990, 1991, 1992, 2002, 2003
3114402Sru   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
20151497SruFoundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
2175584Sru
2275584Sruclass ps_output {
2375584Srupublic:
2475584Sru  ps_output(FILE *, int max_line_length);
2575584Sru  ps_output &put_string(const char *, int);
2675584Sru  ps_output &put_number(int);
2775584Sru  ps_output &put_fix_number(int);
2875584Sru  ps_output &put_float(double);
2975584Sru  ps_output &put_symbol(const char *);
30104862Sru  ps_output &put_color(unsigned int);
3175584Sru  ps_output &put_literal_symbol(const char *);
3275584Sru  ps_output &set_fixed_point(int);
3375584Sru  ps_output &simple_comment(const char *);
3475584Sru  ps_output &begin_comment(const char *);
3575584Sru  ps_output &comment_arg(const char *);
3675584Sru  ps_output &end_comment();
3775584Sru  ps_output &set_file(FILE *);
3875584Sru  ps_output &include_file(FILE *);
3975584Sru  ps_output &copy_file(FILE *);
4075584Sru  ps_output &end_line();
4175584Sru  ps_output &put_delimiter(char);
4275584Sru  ps_output &special(const char *);
4375584Sru  FILE *get_file();
4475584Sruprivate:
4575584Sru  FILE *fp;
4675584Sru  int col;
4775584Sru  int max_line_length;		// not including newline
4875584Sru  int need_space;
4975584Sru  int fixed_point;
5075584Sru};
5175584Sru
5275584Sruinline FILE *ps_output::get_file()
5375584Sru{
5475584Sru  return fp;
5575584Sru}
5675584Sru
5775584Sruenum resource_type {
5875584Sru  RESOURCE_FONT,
5975584Sru  RESOURCE_PROCSET,
6075584Sru  RESOURCE_FILE,
6175584Sru  RESOURCE_ENCODING,
6275584Sru  RESOURCE_FORM,
6375584Sru  RESOURCE_PATTERN
6475584Sru  };
6575584Sru
6675584Srustruct resource;
6775584Sru
6875584Sruextern string an_empty_string;
6975584Sru
7075584Sruclass resource_manager {
7175584Srupublic:
7275584Sru  resource_manager();
7375584Sru  ~resource_manager();
7475584Sru  void import_file(const char *filename, ps_output &);
7575584Sru  void need_font(const char *name);
7675584Sru  void print_header_comments(ps_output &);
7775584Sru  void document_setup(ps_output &);
7875584Sru  void output_prolog(ps_output &);
7975584Sruprivate:
8075584Sru  unsigned extensions;
8175584Sru  unsigned language_level;
8275584Sru  resource *procset_resource;
8375584Sru  resource *resource_list;
8475584Sru  resource *lookup_resource(resource_type type, string &name,
8575584Sru			    string &version = an_empty_string,
8675584Sru			    unsigned revision = 0);
8775584Sru  resource *lookup_font(const char *name);
8875584Sru  void read_download_file();
8975584Sru  void supply_resource(resource *r, int rank, FILE *outfp,
9075584Sru		       int is_document = 0);
9175584Sru  void process_file(int rank, FILE *fp, const char *filename, FILE *outfp);
9275584Sru  resource *read_file_arg(const char **);
9375584Sru  resource *read_procset_arg(const char **);
9475584Sru  resource *read_font_arg(const char **);
9575584Sru  resource *read_resource_arg(const char **);
9675584Sru  void print_resources_comment(unsigned flag, FILE *outfp);
9775584Sru  void print_extensions_comment(FILE *outfp);
9875584Sru  void print_language_level_comment(FILE *outfp);
9975584Sru  int do_begin_resource(const char *ptr, int rank, FILE *fp, FILE *outfp);
10075584Sru  int do_include_resource(const char *ptr, int rank, FILE *fp, FILE *outfp);
10175584Sru  int do_begin_document(const char *ptr, int rank, FILE *fp, FILE *outfp);
10275584Sru  int do_include_document(const char *ptr, int rank, FILE *fp, FILE *outfp);
10375584Sru  int do_begin_procset(const char *ptr, int rank, FILE *fp, FILE *outfp);
10475584Sru  int do_include_procset(const char *ptr, int rank, FILE *fp, FILE *outfp);
10575584Sru  int do_begin_font(const char *ptr, int rank, FILE *fp, FILE *outfp);
10675584Sru  int do_include_font(const char *ptr, int rank, FILE *fp, FILE *outfp);
10775584Sru  int do_begin_file(const char *ptr, int rank, FILE *fp, FILE *outfp);
10875584Sru  int do_include_file(const char *ptr, int rank, FILE *fp, FILE *outfp);
10975584Sru  int change_to_end_resource(const char *ptr, int rank, FILE *fp, FILE *outfp);
11075584Sru  int do_begin_preview(const char *ptr, int rank, FILE *fp, FILE *outfp);
11175584Sru  int do_begin_data(const char *ptr, int rank, FILE *fp, FILE *outfp);
11275584Sru  int do_begin_binary(const char *ptr, int rank, FILE *fp, FILE *outfp);
11375584Sru};
11475584Sru
11575584Sruextern unsigned broken_flags;
11675584Sru
11775584Sru// broken_flags is ored from these
11875584Sru
11975584Sruenum {
12075584Sru  NO_SETUP_SECTION = 01,
12175584Sru  STRIP_PERCENT_BANG = 02,
12275584Sru  STRIP_STRUCTURE_COMMENTS = 04,
123114402Sru  USE_PS_ADOBE_2_0 = 010,
124114402Sru  NO_PAPERSIZE = 020
12575584Sru};
126151497Sru
127151497Sru#include "searchpath.h"
128151497Sru
129151497Sruextern search_path include_search_path;
130