summaryrefslogtreecommitdiffstats
path: root/src/devices/grops/ps.h
blob: 5cef694f0d4372efc220c41c0d18dffaf72c0f5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// -*- C++ -*-
/* Copyright (C) 1989-2020 Free Software Foundation, Inc.
     Written by James Clark (jjc@jclark.com)

This file is part of groff.

groff is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or
(at your option) any later version.

groff is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>. */

class ps_output {
public:
  ps_output(FILE *, int max_line_length);
  ps_output &put_string(const char *, int);
  ps_output &put_number(int);
  ps_output &put_fix_number(int);
  ps_output &put_float(double);
  ps_output &put_symbol(const char *);
  ps_output &put_color(unsigned int);
  ps_output &put_literal_symbol(const char *);
  ps_output &set_fixed_point(int);
  ps_output &simple_comment(const char *);
  ps_output &begin_comment(const char *);
  ps_output &comment_arg(const char *);
  ps_output &end_comment();
  ps_output &set_file(FILE *);
  ps_output &include_file(FILE *);
  ps_output &copy_file(FILE *);
  ps_output &end_line();
  ps_output &put_delimiter(char);
  ps_output &special(const char *);
  FILE *get_file();
private:
  FILE *fp;
  int col;
  int max_line_length;		// not including newline
  int need_space;
  int fixed_point;
};

inline FILE *ps_output::get_file()
{
  return fp;
}

// this must stay in sync with 'resource_table' in 'psrm.cpp'
enum resource_type {
  RESOURCE_FONT,
  RESOURCE_FONTSET,
  RESOURCE_PROCSET,
  RESOURCE_FILE,
  RESOURCE_ENCODING,
  RESOURCE_FORM,
  RESOURCE_PATTERN
};

struct resource;

extern string an_empty_string;

class resource_manager {
public:
  resource_manager();
  ~resource_manager();
  void import_file(const char *filename, ps_output &);
  void need_font(const char *name);
  void print_header_comments(ps_output &);
  void document_setup(ps_output &);
  void output_prolog(ps_output &);
private:
  unsigned extensions;
  unsigned language_level;
  resource *procset_resource;
  resource *resource_list;
  resource *lookup_resource(resource_type type, string &name,
			    string &version = an_empty_string,
			    unsigned revision = 0);
  resource *lookup_font(const char *name);
  void read_download_file();
  void supply_resource(resource *r, int rank, FILE *outfp,
		       int is_document = 0);
  void process_file(int rank, FILE *fp, const char *filename, FILE *outfp);
  resource *read_file_arg(const char **);
  resource *read_procset_arg(const char **);
  resource *read_font_arg(const char **);
  resource *read_resource_arg(const char **);
  void print_resources_comment(unsigned flag, FILE *outfp);
  void print_extensions_comment(FILE *outfp);
  void print_language_level_comment(FILE *outfp);
  int do_begin_resource(const char *ptr, int rank, FILE *fp, FILE *outfp);
  int do_include_resource(const char *ptr, int rank, FILE *fp, FILE *outfp);
  int do_begin_document(const char *ptr, int rank, FILE *fp, FILE *outfp);
  int do_include_document(const char *ptr, int rank, FILE *fp, FILE *outfp);
  int do_begin_procset(const char *ptr, int rank, FILE *fp, FILE *outfp);
  int do_include_procset(const char *ptr, int rank, FILE *fp, FILE *outfp);
  int do_begin_font(const char *ptr, int rank, FILE *fp, FILE *outfp);
  int do_include_font(const char *ptr, int rank, FILE *fp, FILE *outfp);
  int do_begin_file(const char *ptr, int rank, FILE *fp, FILE *outfp);
  int do_include_file(const char *ptr, int rank, FILE *fp, FILE *outfp);
  int change_to_end_resource(const char *ptr, int rank, FILE *fp, FILE *outfp);
  int do_begin_preview(const char *ptr, int rank, FILE *fp, FILE *outfp);
  int do_begin_data(const char *ptr, int rank, FILE *fp, FILE *outfp);
  int do_begin_binary(const char *ptr, int rank, FILE *fp, FILE *outfp);
};

extern unsigned broken_flags;

// broken_flags is ored from these

enum {
  NO_SETUP_SECTION = 01,
  STRIP_PERCENT_BANG = 02,
  STRIP_STRUCTURE_COMMENTS = 04,
  USE_PS_ADOBE_2_0 = 010,
  NO_PAPERSIZE = 020
};

#include "searchpath.h"

extern search_path include_search_path;