-
Notifications
You must be signed in to change notification settings - Fork 0
/
printheader.c
228 lines (217 loc) · 5.2 KB
/
printheader.c
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
/*
* printheader()
*
* Print the header to a file directed by FILE fspo* so it looks kinda
* RFC-822ish. We need to have a "From <address>", and a "Subject: <>"
* line in here for gopher and WAIS indexing.
*
* Copyright 1994 Timothy Pozar
*
*/
#include "anpa.h"
printheader()
{
time(&tc);
if(debug_level > 8)
printf("%s\n",ctime(&tc));
fprintf(fspo,"From %s %s",MAILADDR,ctime(&tc));
if(debug_level > 0){
fprintf(fspo,"Service-Level-Designator: %c = ",hdr.sld);
if(debug_level > 8)
printf("Service-Level-Designator: %c = \n",hdr.sld);
switch(hdr.sld) {
case 'a':
fprintf(fspo,"Expanded APTV Newspaper-syle News");
break;
case 'b':
fprintf(fspo,"APTV Newspaper-style National Feature or Advance");
break;
case 'c':
fprintf(fspo,"Nationwide, selected standing features");
break;
case 'd':
case 'e':
case 'g':
case 'i':
case 'j':
case 'k':
case 'l':
case 'm':
case 'n':
fprintf(fspo,"State and Regional");
break;
case 'f':
fprintf(fspo,"Newspaper-style financial wire");
break;
case 'o':
fprintf(fspo,"Supreme Court Text or State and Regional - New York City, Ohio, Oklahoma Oregon");
break;
case 'p':
fprintf(fspo,"Basic APTV Newspaper-style news");
break;
case 's':
case 't':
fprintf(fspo,"Nationwide Sports");
break;
case 'w':
fprintf(fspo,"AP Alert or State and Regional - Wyoming");
break;
default:
fprintf(fspo,"Not yet defined");
}
fputc('\n',fspo);
fprintf(fspo,"Story-Number: %s\n",hdr.snum);
fprintf(fspo,"Selector-Code: %s\n",hdr.selc);
if(debug_level > 8)
printf("Selector-Code: %s\n",hdr.selc);
fprintf(fspo,"Priority: %c = ",hdr.priority);
if(debug_level > 8)
printf("Priority: %c = \n",hdr.priority);
/* According to the RFCs that extend RFC-822, the data field should contain:
"normal" | "non-urgent" | "urgent"
We should translate the ANPA into these fields and keep the ANPA in "<>". */
switch(hdr.priority) {
case 'f':
fprintf(fspo,"Flash");
break;
case 'b':
fprintf(fspo,"Bulletin");
break;
case 'u':
fprintf(fspo,"Urgent");
break;
case 'r':
fprintf(fspo,"Regular");
break;
case 'd':
case 'h':
fprintf(fspo,"Deferred");
break;
case 'a':
case 's':
fprintf(fspo,"Weekday Advance");
break;
case 'y':
fprintf(fspo,"Rerun");
break;
default:
fprintf(fspo,"Not yet defined");
}
fputc('\n',fspo);
fprintf(fspo,"Category: %c = ",hdr.cat);
if(debug_level > 8)
printf("Category: %c = \n",hdr.cat);
switch(hdr.cat) {
case 'a':
fprintf(fspo,"Domestic, non-Washington, general news stories");
break;
case 'b':
fprintf(fspo,"Special events (Olymipic, special coverage)");
break;
case 'k':
fprintf(fspo,"Commentary/editorial");
break;
case 'w':
fprintf(fspo,"Washington-datelined general news");
break;
case 'd':
fprintf(fspo,"National NewsWatche/Summary");
break;
case 'h':
fprintf(fspo,"National NewsMinute/Headline");
break;
case 'i':
fprintf(fspo,"International");
break;
case 'g':
fprintf(fspo,"State NewsWatch/Summary");
break;
case 'j':
fprintf(fspo,"State NewsMinute/Headline");
break;
case 'n':
fprintf(fspo,"State Regional");
break;
case 'f':
fprintf(fspo,"Business/Financial News");
break;
case 'p':
fprintf(fspo,"Political Story/Results");
break;
case 'c':
fprintf(fspo,"Standing General Feature");
break;
case 'e':
fprintf(fspo,"Entertainment Television and Culture");
break;
case 'm':
fprintf(fspo,"Farm/Agriculture");
break;
case 'q':
fprintf(fspo,"Sports Scores");
break;
case 'o':
fprintf(fspo,"Weather");
break;
case 's':
fprintf(fspo,"Sports Stories");
break;
case 'r':
fprintf(fspo,"Radio Network Billboards");
break;
case 't':
fprintf(fspo,"Television Billboards, Advisory");
break;
case 'v':
fprintf(fspo,"Advisories");
break;
default:
fprintf(fspo,"Not yet defined");
}
fputc('\n',fspo);
fprintf(fspo,"Format-Identifier: ");
switch(hdr.format[0]) {
case DC4:
fprintf(fspo,"Agate");
break;
case DC3:
fprintf(fspo,"Body-Type");
break;
default:
fprintf(fspo,"Not Defined");
}
if ((hdr.format[0] == DC4) || (hdr.format[0] == DC3)) {
switch(hdr.format[1]) {
case DC2:
fprintf(fspo," Tabular");
break;
case DC1:
fprintf(fspo," Text");
break;
}
}
fputc('\n',fspo);
} /* endif debug > 0 */
fprintf(fspo,"Keywords: %s\n",hdr.keyword);
if(debug_level > 0){
/* The version field is varible length. */
if(hdr.vers[0] != '\0')
fprintf(fspo,"Version: %s\n",hdr.vers);
/* The reference field is varible length. */
if(hdr.ref[0] != '\0')
fprintf(fspo,"Reference: %s\n",hdr.ref);
/* The date field is varible length. */
if(hdr.date[0] != '\0')
fprintf(fspo,"Story-Date: %s\n",hdr.date);
fprintf(fspo,"Word-Count: %s\n",hdr.wordcnt);
} /* endif debug > 0 */
if (hdr.priority == 'b')
fprintf(fspo,"Subject: BULLETIN -- %s\n",hdr.subject);
if (hdr.priority == 'u')
fprintf(fspo,"Subject: URGENT -- %s\n",hdr.subject);
if ((hdr.priority != 'b') && (hdr.priority != 'b'))
fprintf(fspo,"Subject: %s\n",hdr.subject);
if(debug_level > 8)
printf("Subject: %s\n",hdr.subject);
fputc('\n',fspo); /* Newline between header and story */
} /* EOF printheader.c */