Coverage Report

Created: 2025-02-15 06:25

/work/build/epan/ps.c
Line
Count
Source (jump to first uncovered line)
1
/* DO NOT EDIT
2
 *
3
 * Created by rdps.py.
4
 *
5
 * ps.c
6
 * Definitions for generating PostScript(R) packet output.
7
 *
8
 * Wireshark - Network traffic analyzer
9
 * By Gerald Combs <gerald@wireshark.org>
10
 * Copyright 1998 Gerald Combs
11
 *
12
 * SPDX-License-Identifier: GPL-2.0-or-later
13
 */
14
15
#include <stdio.h>
16
17
#include "ps.h"
18
19
static const char ps_preamble[] =
20
  "%!\n"
21
  "%!PS-Adobe-2.0\n"
22
  "%\n"
23
  "% Wireshark - Network traffic analyzer\n"
24
  "% By Gerald Combs <gerald@wireshark.org>\n"
25
  "% Copyright 1998 Gerald Combs\n"
26
  "%\n"
27
  "%%Creator: Wireshark\n"
28
  "%%Title: Wireshark output\n"
29
  "%%DocumentFonts: Helvetica Monaco\n"
30
  "%%EndComments\n"
31
  "%!\n"
32
  "\n"
33
  "%\n"
34
  "% Ghostscript http://ghostscript.com/ can convert postscript to pdf files.\n"
35
  "%\n"
36
  "% To convert this postscript file to pdf, type (for US letter format):\n"
37
  "% ps2pdf filename.ps\n"
38
  "%\n"
39
  "% or (for A4 format):\n"
40
  "% ps2pdf -sPAPERSIZE=a4 filename.ps\n"
41
  "%\n"
42
  "% ... and of course replace filename.ps by your current filename.\n"
43
  "%\n"
44
  "% The pdfmark's below will help converting to a pdf file, and have no\n"
45
  "% effect when printing the postscript directly.\n"
46
  "% \n"
47
  "\n"
48
  "%   This line is necessary if the file should be printable, and not just used\n"
49
  "%   for distilling into PDF:\n"
50
  "%\n"
51
  "/pdfmark where {pop} {userdict /pdfmark /cleartomark load put} ifelse\n"
52
  "%\n"
53
  "%   This tells PDF viewers to display bookmarks when the document is opened:\n"
54
  "%\n"
55
  "[/PageMode /UseOutlines /DOCVIEW pdfmark\n"
56
  "\n"
57
  "% Get the Imagable Area of the page\n"
58
  "clippath pathbbox\n"
59
  "\n"
60
  "% Set vmax to the vertical size of the page,\n"
61
  "% hmax to the horizontal size of the page.\n"
62
  "/vmax exch def\n"
63
  "/hmax exch def\n"
64
  "pop pop    % junk\n"
65
  "\n"
66
  "% 1/2-inch margins\n"
67
  "/lmargin 36 def          % left margin\n"
68
  "/tmargin vmax 56 sub def   % top margin\n"
69
  "/bmargin 36 def          % bottom margin\n"
70
  "/pagenumtab hmax 36 sub def    % right margin\n"
71
  "\n"
72
  "% Counters\n"
73
  "/thispagenum 1 def\n"
74
  "\n"
75
  "% Strings\n"
76
  "/pagenostr 7 string def\n"
77
  "\n"
78
  "\n"
79
  "/formfeed {\n"
80
  " printpagedecorations\n"
81
  " showpage\n"
82
  " \n"
83
  " % we need a new current point after showpage is done\n"
84
  " lmargin   % X\n"
85
  " vpos    % Y\n"
86
  " moveto\n"
87
  " /vpos tmargin def\n"
88
  "} def\n"
89
  "\n"
90
  "% Prints text with possible indenting\n"
91
  "/putline_single {\n"
92
  " exch 10 mul lmargin add   % X\n"
93
  " vpos            % Y\n"
94
  " moveto\n"
95
  " show\n"
96
  "\n"
97
  " /vpos vpos 10 sub def\n"
98
  "\n"
99
  " vpos 5 sub bmargin le     % is vpos <= bottom margin?\n"
100
  " {\n"
101
  "   formfeed\n"
102
  " }\n"
103
  " if              % then formfeed and start at top\n"
104
  "} def\n"
105
  "\n"
106
  "\n"
107
  "% Prints text with possible indenting and line wrap\n"
108
  "/putline {\n"
109
  " /text exch def\n"
110
  " /indent exch def\n"
111
  " \n"
112
  " % wrapat = width / sizeof font (remember: monospaced font)\n"
113
  " /pagewidth pagenumtab lmargin sub def\n"
114
  " /cwidth (A) stringwidth pop def\n"
115
  " /wrapat pagewidth cwidth div cvi def\n"
116
  "   \n"
117
  " text length wrapat le {\n"
118
  "   % print line\n"
119
  "   indent text 0 text length getinterval putline_single\n"
120
  " }{\n"
121
  "   % print the lines first part\n"
122
  "   indent text 0 wrapat getinterval putline_single\n"
123
  "   % print wrapped rest\n"
124
  "   indent text wrapat text length wrapat sub getinterval putline\n"
125
  " }\n"
126
  " ifelse\n"
127
  "} def\n"
128
  "\n"
129
  "\n"
130
  "% Prints the page number at the top right\n"
131
  "/printpagedecorations {\n"
132
  " gsave\n"
133
  "   % Set the font to 8 point\n"
134
  "   /Helvetica findfont 8 scalefont setfont\n"
135
  "\n"
136
  "   % title\n"
137
  "   lmargin           % X\n"
138
  "   vmax 36 sub         % Y\n"
139
  "   moveto\n"
140
  "   ws_pagetitle show\n"
141
  "\n"
142
  "   % this page number\n"
143
  "   pagenumtab (Page ) stringwidth pop sub thispagenum pagenostr cvs stringwidth pop sub    % X\n"
144
  "   vmax 36 sub         % Y\n"
145
  "   moveto\n"
146
  "   (Page ) show\n"
147
  "   thispagenum pagenostr cvs show\n"
148
  "\n"
149
  "   % thispagenum++\n"
150
  "   /thispagenum thispagenum 1 add def\n"
151
  "   \n"
152
  "   % line at top of page\n"
153
  "   lmargin           % X\n"
154
  "   vmax 38 sub         % Y\n"
155
  "   moveto\n"
156
  "   \n"
157
  "   pagenumtab          % X\n"
158
  "   vmax 38 sub         % Y\n"
159
  "   lineto\n"
160
  "   stroke\n"
161
  "   \n"
162
  "   % line at bottom of page\n"
163
  "   lmargin           % X\n"
164
  "   bmargin           % Y\n"
165
  "   moveto\n"
166
  "   \n"
167
  "   pagenumtab          % X\n"
168
  "   bmargin           % Y\n"
169
  "   lineto\n"
170
  "   stroke\n"
171
  "   \n"
172
  " grestore\n"
173
  "} def\n"
174
  " \n"
175
  "% Reset the vertical position\n"
176
  "/vpos tmargin def\n"
177
  "\n"
178
  "% Set the font to 8 point\n"
179
  "/Monaco findfont 8 scalefont setfont\n"
180
  "\n"
181
;
182
183
0
void print_ps_preamble(FILE *fd) {
184
0
  fwrite(ps_preamble, sizeof ps_preamble - 1, 1, fd);
185
0
}
186
187
188
static const char ps_finale[] =
189
  "\n"
190
  "printpagedecorations\n"
191
  "showpage\n"
192
  "\n"
193
  "%%EOF\n"
194
  "\n"
195
;
196
197
0
void print_ps_finale(FILE *fd) {
198
0
  fwrite(ps_finale, sizeof ps_finale - 1, 1, fd);
199
0
}
200
201