Merge openssl_disable_ssl2 branch
[exim.git] / doc / doc-scripts / JoinPS
CommitLineData
495ae4b0 1#!/usr/bin/perl
495ae4b0
PH
2
3# Make the basic PostScript file for the Exim spec from the gcode file, then
4# join it together with the contents and the index, to make a single
5# PostScript file, suitable for double-sided printing.
6
7sub blank_page {
8my($title) = shift @_;
9printf(OUT "%%%%Page: %s %d\nxpage\n\n", $title, $pagenumber++);
10}
11
12
13@roman = ("i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix", "x",
14 "xi", "xii", "xiii", "xiv", "xv", "xvi", "xvii", "xviii", "xix");
15
16$pagenumber = 1;
17
18system("sgtops z-gcode -to z-ps") && die "sgtops run failed\n";
19
20open(SPEC, "z-ps") || die "Can't open z-ps\n";
21open(CONTS, "zc-ps") || die "Can't open zc-ps\n";
22open(INDEX, "zi-ps") || die "Can't open zi-ps\n";
23open(OUT, ">spec.ps") || die "Can't open spec.ps\n";
24
25# Copy spec headings etc.
26
27while (<SPEC>)
28 {
29 last if (/^%%Page:/) ;
30 print OUT;
31 }
32
33# Copy the first two pages - the title page, and its blank verso
34
35for ($i = 1; $i < 3; $i++)
36 {
37 printf(OUT "%%%%Page: title%s %d\n", ($i == 1)? "" : "-verso", $pagenumber++);
38 while (<SPEC>)
39 {
40 last if (/^%%Page:/) ;
41 print OUT;
42 }
43 }
44
45# Skip the contents heading
46
47while (<CONTS>)
48 {
49 last if (/^%%Page:/) ;
50 }
51
52# Output the contents pages - fudge the roman numerals as we know there
53# won't be a vast number of them.
54
55$subpagenumber = 0;
56while (!eof CONTS)
57 {
58 printf(OUT "%%%%Page: %s %d\n", $roman[$subpagenumber++], $pagenumber++);
59 while (<CONTS>)
60 {
61 next if (/^%%Pages:/);
62 next if (/^%%Trailer/);
63 last if (/^%%Page:/) ;
64 print OUT;
65 }
66 }
67printf(OUT "\n");
68
69# If contents was an odd number of pages, insert a blank page
70
71&blank_page("contents-pad") if ($pagenumber & 1) == 0;
72
73# Copy the rest of the main file
74
75$subpagenumber = 1;
76
77while (!eof SPEC)
78 {
79 printf(OUT "%%%%Page: %d %d\n", $subpagenumber++, $pagenumber++);
80 while (<SPEC>)
81 {
82 next if (/^%%Pages:/);
83 next if (/^%%Trailer/);
84 last if (/^%%Page:/) ;
85 print OUT;
86 }
87 }
88printf(OUT "\n");
89
90# If contents was an odd number of pages, insert a blank page
91
92&blank_page("body-pad") if ($pagenumber & 1) == 0;
93
94# Skip the index heading
95
96while (<INDEX>)
97 {
98 last if (/^%%Page:/) ;
99 }
100
101# Copy the index pages
102
103$subpagenumber = 1;
104
105while (!eof INDEX)
106 {
107 printf(OUT "%%%%Page: I%d %d\n", $subpagenumber++, $pagenumber++);
108 while (<INDEX>)
109 {
110 next if (/^%%Pages:/);
111 next if (/^%%Trailer/);
112 last if (/^%%Page:/) ;
113 print OUT;
114 }
115 }
116
117# Add final comments
118
119printf(OUT "%%%%Trailer\n");
120printf(OUT "%%%%Pages: %d\n", $pagenumber-1);
121
122# That's it
123
124close(SPEC);
125close(CONTS);
126close(INDEX);
127close(OUT);
128
129# End