"Fossies" - the Fresh Open Source Software Archive 
Member "rman-3.2/contrib/bennett.txt" (26 Jul 2003, 13609 Bytes) of package /linux/www/old/rman-3.2.tar.gz:
As a special service "Fossies" has tried to format the requested text file into HTML format (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
1 *** rman.c.original Tue Jul 16 21:19:49 1996
2 --- rman.c Tue Aug 27 15:59:38 1996
3 ***************
4 *** 1,5 ****
5 --- 1,9 ----
6 static char rcsid[] = "$Header: /home/orodruin/h/bair/phelps/spine/rman/RCS/rman.c,v 1.70 1996/07/17 01:18:19 phelps Exp phelps $";
7
8 + /* ELS: SearchDirs by "Edward L. Sutter" <els@sage.sage.att.com> */
9 + /* AB: HTMLHeader and HTMLFooter by Anne Bennett <anne@alcor.concordia.ca> */
10 + /* AB: SearchDirsPrefix by Anne Bennett <anne@alcor.concordia.ca> */
11 +
12 /*
13 RosettaMan
14
15 ***************
16 *** 265,271 ****
17 --- 269,278 ----
18
19 /*** utility functions ***/
20
21 + /* 1996/08/26 Anne Bennett patched */
22 + int HrefSearch(char *manname, char *section);
23
24 +
25 /* case insensitive versions of strcmp and strncmp */
26
27 int
28 ***************
29 *** 1338,1343 ****
30 --- 1345,1355 ----
31 char *manTitle = MANTITLEPRINTF;
32 char *manRef = MANREFPRINTF;
33 int fmanRef=1; /* valid man ref? */
34 + /* 1996/08/26 Anne Bennett patched */
35 + char *SearchDirs=0; /* ELS: added for smarter external reference generator. */
36 + char *SearchDirsPrefix=0; /* AB: added for HREF prefix to manpage path. */
37 + char *HTMLHeader=0; /* AB: added for HTML header and footer files. */
38 + char *HTMLFooter=0; /* AB: added for HTML header and footer files. */
39
40 /*
41 * HTML
42 ***************
43 *** 1349,1354 ****
44 --- 1361,1373 ----
45 int i,j;
46 int lasttoc;
47 char *p, *p0;
48 + /* 1996/08/26 Anne Bennett patched */
49 + /* AB: To support HTMLHeader and HTMLFooter */
50 + #define SUB_MANNAME "@@MANPAGE_NAME@@"
51 + #define SUB_MANSECT "@@MANPAGE_SECTION@@"
52 + #define STRING_SIZE 1024
53 + char line[STRING_SIZE];
54 + FILE *fp;
55
56 /* always respond to these signals */
57 switch (cmd) {
58 ***************
59 *** 1397,1402 ****
60 --- 1416,1474 ----
61 /* better title possible? */
62 printf("<TITLE>"); printf(manTitle, manName, manSect); printf("</TITLE>\n");
63 printf("</HEAD>\n<BODY>\n");
64 + /* 1996/08/26 Anne Bennett patched */
65 + /* AB: added HTMLHeader file, if -H option is set */
66 + if (HTMLHeader) {
67 + if ((fp = fopen(HTMLHeader,"r")) == NULL) {
68 + fprintf(stderr,"Could not open HTMLHeader file\n");
69 + }
70 + else {
71 + /* Output the header file, replacing strings as needed */
72 + while (fgets(line, STRING_SIZE, fp) != (char *)NULL) {
73 + char *walker, *found;
74 + int i;
75 +
76 + /* replace man section */
77 + walker = line;
78 + while ( ( found = strstr(walker, SUB_MANSECT) ) != NULL ) {
79 + if ( ( strlen(line) + strlen(manSect)
80 + - strlen (SUB_MANSECT) ) > sizeof(line) ) {
81 + fprintf(stderr,"Cannot substitute %s for %s; "
82 + "line would be too long:\n "
83 + "%s\n", manSect, SUB_MANSECT, line);
84 + walker = found + strlen(SUB_MANSECT);
85 + }
86 + else {
87 + (void) memmove(found+strlen(manSect),
88 + found+strlen(SUB_MANSECT),
89 + strlen(found+strlen(SUB_MANSECT))+1);
90 + memcpy(found, manSect, strlen(manSect));
91 + walker = found + strlen(manSect);
92 + }
93 + }
94 + /* replace man name */
95 + walker = line;
96 + while ( ( found = strstr(walker, SUB_MANNAME) ) != NULL ) {
97 + if ( ( strlen(line) + strlen(manName)
98 + - strlen (SUB_MANNAME) ) > sizeof(line) ) {
99 + fprintf(stderr,"Cannot substitute %s for %s; "
100 + "line would be too long:\n "
101 + "%s\n", manName, SUB_MANNAME, line);
102 + walker = found + strlen(SUB_MANNAME);
103 + }
104 + else {
105 + (void) memmove(found+strlen(manName),
106 + found+strlen(SUB_MANNAME),
107 + strlen(found+strlen(SUB_MANNAME))+1);
108 + memcpy(found, manName, strlen(manName));
109 + walker = found + strlen(manName);
110 + }
111 + }
112 + printf("%s", line);
113 + }
114 + fclose(fp);
115 + }
116 + }
117 printf("<A HREF=\"#toc\">%s</A><P>\n", TABLEOFCONTENTS);
118 I=0;
119 break;
120 ***************
121 *** 1424,1429 ****
122 --- 1496,1514 ----
123 if (lasttoc==BEGINSUBSECTION) printf("</UL>");
124 printf("</UL>\n");
125 }
126 + /* 1996/08/26 Anne Bennett patched */
127 + /* AB: added HTMLFooter file, if -F option is set */
128 + if (HTMLFooter) {
129 + if ((fp = fopen(HTMLFooter,"r")) == NULL) {
130 + fprintf(stderr,"Could not open HTMLFooter file\n");
131 + }
132 + else {
133 + /* Output the footer file */
134 + while (fgets(line, STRING_SIZE, fp) != (char *)NULL)
135 + printf("%s", line);
136 + fclose(fp);
137 + }
138 + }
139 printf("</BODY></HTML>\n");
140 break;
141 case BEGINBODY: break;
142 ***************
143 *** 1500,1510 ****
144 *p++='\0'; p0=p;
145 for (; *p && *p!=')'; p++) /* empty */;
146 *p='\0';
147 ! if (fmanRef) { printf("<A HREF=\""); printf(manRef, hitxt, p0); printf("\">"); }
148 else printf("<I>");
149 break;
150 case ENDMANREF:
151 ! if (fmanRef) printf("</A>"); else printf("</I>");
152 break;
153
154 case BEGINSC: case ENDSC:
155 --- 1585,1604 ----
156 *p++='\0'; p0=p;
157 for (; *p && *p!=')'; p++) /* empty */;
158 *p='\0';
159 ! /* 1996/08/26 Anne Bennett patched */
160 ! /* ELS: added a call to HrefSearch() if the -S option is set.. */
161 ! if (SearchDirs)
162 ! HrefSearch(hitxt,p0);
163 ! else if (fmanRef) {
164 ! printf("<A HREF=\"");
165 ! printf(manRef, hitxt, p0);
166 ! printf("\">");
167 ! }
168 else printf("<I>");
169 break;
170 case ENDMANREF:
171 ! /* 1996/08/26 Anne Bennett patched */
172 ! if (fmanRef || SearchDirs) printf("</A>"); else printf("</I>");
173 break;
174
175 case BEGINSC: case ENDSC:
176 ***************
177 *** 2744,2754 ****
178 --- 2838,2856 ----
179 extern char *optarg;
180 extern int optind, opterr;
181
182 + /* 1996/08/26 Anne Bennett patched */
183 + /* ELS: added the -S option: */
184 + /* AB: added the -H and -F options */
185 + /* AB: added the -P option */
186 char strgetopt[80];
187 /* options with an arg must have a '<' in the description */
188 struct { char letter; int arg; char *longnames; char *desc; } option[] = {
189 { 'f', 1, "filter", " <ASCII|roff|TkMan|Tk|Ensemble|Sections|HTML|SGML|MIME|LaTeX|LaTeX2e|RTF|pod>" },
190 { 'r', 1, "reference:manref:ref", " <man reference printf string>" },
191 + { 'S', 1, "searchdirs", " <man reference search directories>" },
192 + { 'P', 1, "prefix", " <prefix for manpage paths in -S>" },
193 + { 'H', 1, "header", " <HTML header file>" },
194 + { 'F', 1, "footer", " <HTML footer file>" },
195 { 'l', 1, "title", " <title printf string>" },
196 { 'b', 0, "subsections:sub", " (show subsections)" },
197 { 'n', 1, "name", "(ame of man page) <string>" },
198 ***************
199 *** 2830,2835 ****
200 --- 2932,2953 ----
201 case 'r': manRef = optarg;
202 if (strlen(manRef)==0 || strcmp(manRef,"-")==0 || strcmp(manRef,"off")==0) fmanRef=0;
203 break;
204 + /* 1996/08/26 Anne Bennett patched */
205 + /* ELS: added the -S option: */
206 + /* AB: added the -H and -F options */
207 + /* AB: added the -P option */
208 + case 'S': SearchDirs = optarg;
209 + if (strlen(SearchDirs)==0 ) SearchDirs=0;
210 + break;
211 + case 'P': SearchDirsPrefix = optarg;
212 + if (strlen(SearchDirsPrefix)==0 ) SearchDirsPrefix=0;
213 + break;
214 + case 'H': HTMLHeader = optarg;
215 + if (strlen(HTMLHeader)==0 ) HTMLHeader=0;
216 + break;
217 + case 'F': HTMLFooter = optarg;
218 + if (strlen(HTMLFooter)==0 ) HTMLFooter=0;
219 + break;
220 case 't': TabStops=atoi(optarg); break;
221 case 'm': fMan=0; break;
222 case 'T': fTable=1; break;
223 ***************
224 *** 2904,2906 ****
225 --- 3022,3126 ----
226 filter();
227 return 0;
228 }
229 +
230 +
231 + /* 1996/08/26 Anne Bennett patched */
232 + /* ELS...
233 + HrefSearch():
234 + Active only with command line option -S...
235 + Called when rman -fHTML has determined that it is going to add a
236 + hypertext link. The user tells rman where to search for the hypertext
237 + links (local machine search only) and if HrefSearch() finds the file
238 +
239 + SRCHDIR/manname.section
240 +
241 + where
242 + SRCHDIR is one of the colon-delimited paths specified with
243 + the -S option;
244 + manname is the text that rman found preceding a "manname(##)"
245 + detection;
246 + section is the string within the parens of the manname spec;
247 +
248 +
249 + then it will use that path to build the HREF line. If not found,
250 + then <A> is all that is inserted.
251 + This is generally only helpful when you are simply attempting to
252 + turn a man directory into an html directory.
253 +
254 + Note that if the first char of SearchDirs is a colon, then if
255 + HrefSearch does not find the reference, it defaults to what rman
256 + used to do (use manRef, -r option); otherwise, it will not add
257 + a hypertext link at all.
258 + */
259 + int HrefSearch(char *manname, char *section)
260 + {
261 + char *dir, *colon, tmp;
262 + int DefaultToManRef;
263 + FILE *fp;
264 + static char path[256];
265 +
266 + tmp = 0;
267 +
268 + again:
269 + if (SearchDirs[0] == ':') {
270 + dir = &SearchDirs[1];
271 + DefaultToManRef = 1;
272 + }
273 + else {
274 + dir = SearchDirs;
275 + DefaultToManRef = 0;
276 + }
277 +
278 + /* Make 2 passes on all search directories... */
279 + /* First pass is with the path dir/manname.section */
280 + /* Second pass is with the path dir/manname.section[0] */
281 + /* This allows the spec manname(3x) to be found as manname.3 */
282 + /* just in cast manname.3x doesn't exist. */
283 + /* Note that the second pass is only necessary if the section */
284 + /* string is more than one character in length. */
285 + while(1) {
286 + colon = strchr(dir,':');
287 + if (colon) *colon = 0;
288 + sprintf(path,"%s/%s.%s.html",dir,manname,section);
289 + /* 1996/08/26 Anne: read-only, not rw, please. */
290 + if ((fp = fopen(path,"r")) != NULL) {
291 + printf("<A HREF=\"");
292 + /* AB: Put in the manpage location prefix */
293 + if (SearchDirsPrefix)
294 + printf("%s",SearchDirsPrefix);
295 + printf("%s",path);
296 + printf("\">");
297 + fclose(fp);
298 + if (colon) *colon = ':';
299 + fprintf(stderr,"HREF @ %s\n",path);
300 + return(1);
301 + }
302 + if (colon) {
303 + *colon = ':';
304 + dir = colon+1;
305 + }
306 + else
307 + break;
308 + }
309 + if (section[1]) {
310 + tmp = section[1];
311 + section[1] = 0;
312 + dir = SearchDirs;
313 + goto again;
314 + }
315 + if (tmp)
316 + section[1] = tmp;
317 +
318 + /* 1996/08/27 Anne Bennett: use manRef only if set */
319 + if (DefaultToManRef && manRef) {
320 + printf("<A HREF=\"");
321 + printf(manRef, manname, section);
322 + printf("\">");
323 + }
324 + else
325 + printf("<A>");
326 + return(1);
327 + }
328 +
329 + /* End ELS additions. */
330 +
331 *** rman.1.original Tue Jul 16 21:19:49 1996
332 --- rman.1 Tue Aug 27 15:16:29 1996
333 ***************
334 *** 75,80 ****
335 --- 75,109 ----
336 or `off', then man page references will not be HREFs, just set
337 in italics.
338 .TP 15
339 + -S|--searchDirs \fIcolon-separated-directories \fR
340 + Valid only with \fI-fHTML \fR, this option modifies the behaviour of
341 + rman when inserting a hyperlink to a referenced manpage.
342 + The directories indicate where to look
343 + for a pre-HTMLized version of the referenced manpage under the name
344 + " \fIname \fR. \fIsection \fR. \fIhtml \fR". If the file is not
345 + found, no hypertext link is added, except if the first character of
346 + the directories list is a colon, in which case a link is added using
347 + manRef, ( \fI-r \fR option).
348 + .TP 15
349 + -P|--prefix \fIstring \fR
350 + Valid only with \fI-S \fR, the string indicates what prefix to add to
351 + the path when constructing the hyperlink for a referenced manpage.
352 + The string will usually be
353 + similar to that given with \fI-r \fR, except that there will be no
354 + printf-style escapes, for example "http://localhost/manpages".
355 + .TP 15
356 + -H|--header \fIfilename \fR
357 + Valid only with \fI-fHTML \fR, the filename refers to a file
358 + containing an HTML "header", which might consist of, for example, a
359 + company logo, or body color specifications. If the strings
360 + "@@MANPAGE_NAME@@" or "@@MANPAGE_SECTION@@" are found in this file,
361 + they are replaced by the appropriate manpage name and section.
362 + .TP 15
363 + -F|--footer \fIfilename \fR
364 + Valid only with \fI-fHTML \fR, the filename refers to a file
365 + containing an HTML "footer", which might consist of, for example, a
366 + link back to the site's home page.
367 + .TP 15
368 -s|section \fI# \fR
369 Set volume (aka section) number of man page (used in roff format).
370 .TP 15
371