1 /* $NetBSD: ps.h,v 1.1.1.1 2016/01/13 18:41:49 christos Exp $ */ 2 3 // -*- C++ -*- 4 /* Copyright (C) 1989, 1990, 1991, 1992, 2002, 2003 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 class ps_output { 25 public: 26 ps_output(FILE *, int max_line_length); 27 ps_output &put_string(const char *, int); 28 ps_output &put_number(int); 29 ps_output &put_fix_number(int); 30 ps_output &put_float(double); 31 ps_output &put_symbol(const char *); 32 ps_output &put_color(unsigned int); 33 ps_output &put_literal_symbol(const char *); 34 ps_output &set_fixed_point(int); 35 ps_output &simple_comment(const char *); 36 ps_output &begin_comment(const char *); 37 ps_output &comment_arg(const char *); 38 ps_output &end_comment(); 39 ps_output &set_file(FILE *); 40 ps_output &include_file(FILE *); 41 ps_output ©_file(FILE *); 42 ps_output &end_line(); 43 ps_output &put_delimiter(char); 44 ps_output &special(const char *); 45 FILE *get_file(); 46 private: 47 FILE *fp; 48 int col; 49 int max_line_length; // not including newline 50 int need_space; 51 int fixed_point; 52 }; 53 54 inline FILE *ps_output::get_file() 55 { 56 return fp; 57 } 58 59 enum resource_type { 60 RESOURCE_FONT, 61 RESOURCE_PROCSET, 62 RESOURCE_FILE, 63 RESOURCE_ENCODING, 64 RESOURCE_FORM, 65 RESOURCE_PATTERN 66 }; 67 68 struct resource; 69 70 extern string an_empty_string; 71 72 class resource_manager { 73 public: 74 resource_manager(); 75 ~resource_manager(); 76 void import_file(const char *filename, ps_output &); 77 void need_font(const char *name); 78 void print_header_comments(ps_output &); 79 void document_setup(ps_output &); 80 void output_prolog(ps_output &); 81 private: 82 unsigned extensions; 83 unsigned language_level; 84 resource *procset_resource; 85 resource *resource_list; 86 resource *lookup_resource(resource_type type, string &name, 87 string &version = an_empty_string, 88 unsigned revision = 0); 89 resource *lookup_font(const char *name); 90 void read_download_file(); 91 void supply_resource(resource *r, int rank, FILE *outfp, 92 int is_document = 0); 93 void process_file(int rank, FILE *fp, const char *filename, FILE *outfp); 94 resource *read_file_arg(const char **); 95 resource *read_procset_arg(const char **); 96 resource *read_font_arg(const char **); 97 resource *read_resource_arg(const char **); 98 void print_resources_comment(unsigned flag, FILE *outfp); 99 void print_extensions_comment(FILE *outfp); 100 void print_language_level_comment(FILE *outfp); 101 int do_begin_resource(const char *ptr, int rank, FILE *fp, FILE *outfp); 102 int do_include_resource(const char *ptr, int rank, FILE *fp, FILE *outfp); 103 int do_begin_document(const char *ptr, int rank, FILE *fp, FILE *outfp); 104 int do_include_document(const char *ptr, int rank, FILE *fp, FILE *outfp); 105 int do_begin_procset(const char *ptr, int rank, FILE *fp, FILE *outfp); 106 int do_include_procset(const char *ptr, int rank, FILE *fp, FILE *outfp); 107 int do_begin_font(const char *ptr, int rank, FILE *fp, FILE *outfp); 108 int do_include_font(const char *ptr, int rank, FILE *fp, FILE *outfp); 109 int do_begin_file(const char *ptr, int rank, FILE *fp, FILE *outfp); 110 int do_include_file(const char *ptr, int rank, FILE *fp, FILE *outfp); 111 int change_to_end_resource(const char *ptr, int rank, FILE *fp, FILE *outfp); 112 int do_begin_preview(const char *ptr, int rank, FILE *fp, FILE *outfp); 113 int do_begin_data(const char *ptr, int rank, FILE *fp, FILE *outfp); 114 int do_begin_binary(const char *ptr, int rank, FILE *fp, FILE *outfp); 115 }; 116 117 extern unsigned broken_flags; 118 119 // broken_flags is ored from these 120 121 enum { 122 NO_SETUP_SECTION = 01, 123 STRIP_PERCENT_BANG = 02, 124 STRIP_STRUCTURE_COMMENTS = 04, 125 USE_PS_ADOBE_2_0 = 010, 126 NO_PAPERSIZE = 020 127 }; 128 129 #include "searchpath.h" 130 131 extern search_path include_search_path; 132