xref: /linux/scripts/kernel-doc (revision bd0e88e5174035d69204636289a21dc4c14238ec)
1#!/usr/bin/perl -w
2
3use strict;
4
5## Copyright (c) 1998 Michael Zucchi, All Rights Reserved        ##
6## Copyright (C) 2000, 1  Tim Waugh <twaugh@redhat.com>          ##
7## Copyright (C) 2001  Simon Huggins                             ##
8## Copyright (C) 2005-2007  Randy Dunlap                         ##
9## 								 ##
10## #define enhancements by Armin Kuster <akuster@mvista.com>	 ##
11## Copyright (c) 2000 MontaVista Software, Inc.			 ##
12## 								 ##
13## This software falls under the GNU General Public License.     ##
14## Please read the COPYING file for more information             ##
15
16# w.o. 03-11-2000: added the '-filelist' option.
17
18# 18/01/2001 - 	Cleanups
19# 		Functions prototyped as foo(void) same as foo()
20# 		Stop eval'ing where we don't need to.
21# -- huggie@earth.li
22
23# 27/06/2001 -  Allowed whitespace after initial "/**" and
24#               allowed comments before function declarations.
25# -- Christian Kreibich <ck@whoop.org>
26
27# Still to do:
28# 	- add perldoc documentation
29# 	- Look more closely at some of the scarier bits :)
30
31# 26/05/2001 - 	Support for separate source and object trees.
32#		Return error code.
33# 		Keith Owens <kaos@ocs.com.au>
34
35# 23/09/2001 - Added support for typedefs, structs, enums and unions
36#              Support for Context section; can be terminated using empty line
37#              Small fixes (like spaces vs. \s in regex)
38# -- Tim Jansen <tim@tjansen.de>
39
40
41#
42# This will read a 'c' file and scan for embedded comments in the
43# style of gnome comments (+minor extensions - see below).
44#
45
46# Note: This only supports 'c'.
47
48# usage:
49# kernel-doc [ -docbook | -html | -text | -man ] [ -no-doc-sections ]
50#           [ -function funcname [ -function funcname ...] ] c file(s)s > outputfile
51# or
52#           [ -nofunction funcname [ -function funcname ...] ] c file(s)s > outputfile
53#
54#  Set output format using one of -docbook -html -text or -man.  Default is man.
55#
56#  -no-doc-sections
57#	Do not output DOC: sections
58#
59#  -function funcname
60#	If set, then only generate documentation for the given function(s) or
61#	DOC: section titles.  All other functions and DOC: sections are ignored.
62#
63#  -nofunction funcname
64#	If set, then only generate documentation for the other function(s)/DOC:
65#	sections. Cannot be used together with -function (yes, that's a bug --
66#	perl hackers can fix it 8))
67#
68#  c files - list of 'c' files to process
69#
70#  All output goes to stdout, with errors to stderr.
71
72#
73# format of comments.
74# In the following table, (...)? signifies optional structure.
75#                         (...)* signifies 0 or more structure elements
76# /**
77#  * function_name(:)? (- short description)?
78# (* @parameterx: (description of parameter x)?)*
79# (* a blank line)?
80#  * (Description:)? (Description of function)?
81#  * (section header: (section description)? )*
82#  (*)?*/
83#
84# So .. the trivial example would be:
85#
86# /**
87#  * my_function
88#  **/
89#
90# If the Description: header tag is omitted, then there must be a blank line
91# after the last parameter specification.
92# e.g.
93# /**
94#  * my_function - does my stuff
95#  * @my_arg: its mine damnit
96#  *
97#  * Does my stuff explained.
98#  */
99#
100#  or, could also use:
101# /**
102#  * my_function - does my stuff
103#  * @my_arg: its mine damnit
104#  * Description: Does my stuff explained.
105#  */
106# etc.
107#
108# Beside functions you can also write documentation for structs, unions,
109# enums and typedefs. Instead of the function name you must write the name
110# of the declaration;  the struct/union/enum/typedef must always precede
111# the name. Nesting of declarations is not supported.
112# Use the argument mechanism to document members or constants.
113# e.g.
114# /**
115#  * struct my_struct - short description
116#  * @a: first member
117#  * @b: second member
118#  *
119#  * Longer description
120#  */
121# struct my_struct {
122#     int a;
123#     int b;
124# /* private: */
125#     int c;
126# };
127#
128# All descriptions can be multiline, except the short function description.
129#
130# You can also add additional sections. When documenting kernel functions you
131# should document the "Context:" of the function, e.g. whether the functions
132# can be called form interrupts. Unlike other sections you can end it with an
133# empty line.
134# Example-sections should contain the string EXAMPLE so that they are marked
135# appropriately in DocBook.
136#
137# Example:
138# /**
139#  * user_function - function that can only be called in user context
140#  * @a: some argument
141#  * Context: !in_interrupt()
142#  *
143#  * Some description
144#  * Example:
145#  *    user_function(22);
146#  */
147# ...
148#
149#
150# All descriptive text is further processed, scanning for the following special
151# patterns, which are highlighted appropriately.
152#
153# 'funcname()' - function
154# '$ENVVAR' - environmental variable
155# '&struct_name' - name of a structure (up to two words including 'struct')
156# '@parameter' - name of a parameter
157# '%CONST' - name of a constant.
158
159my $errors = 0;
160my $warnings = 0;
161my $anon_struct_union = 0;
162
163# match expressions used to find embedded type information
164my $type_constant = '\%([-_\w]+)';
165my $type_func = '(\w+)\(\)';
166my $type_param = '\@(\w+)';
167my $type_struct = '\&((struct\s*)*[_\w]+)';
168my $type_struct_xml = '\\&amp;((struct\s*)*[_\w]+)';
169my $type_env = '(\$\w+)';
170
171# Output conversion substitutions.
172#  One for each output format
173
174# these work fairly well
175my %highlights_html = ( $type_constant, "<i>\$1</i>",
176			$type_func, "<b>\$1</b>",
177			$type_struct_xml, "<i>\$1</i>",
178			$type_env, "<b><i>\$1</i></b>",
179			$type_param, "<tt><b>\$1</b></tt>" );
180my $local_lt = "\\\\\\\\lt:";
181my $local_gt = "\\\\\\\\gt:";
182my $blankline_html = $local_lt . "p" . $local_gt;	# was "<p>"
183
184# XML, docbook format
185my %highlights_xml = ( "([^=])\\\"([^\\\"<]+)\\\"", "\$1<quote>\$2</quote>",
186			$type_constant, "<constant>\$1</constant>",
187			$type_func, "<function>\$1</function>",
188			$type_struct_xml, "<structname>\$1</structname>",
189			$type_env, "<envar>\$1</envar>",
190			$type_param, "<parameter>\$1</parameter>" );
191my $blankline_xml = $local_lt . "/para" . $local_gt . $local_lt . "para" . $local_gt . "\n";
192
193# gnome, docbook format
194my %highlights_gnome = ( $type_constant, "<replaceable class=\"option\">\$1</replaceable>",
195			 $type_func, "<function>\$1</function>",
196			 $type_struct, "<structname>\$1</structname>",
197			 $type_env, "<envar>\$1</envar>",
198			 $type_param, "<parameter>\$1</parameter>" );
199my $blankline_gnome = "</para><para>\n";
200
201# these are pretty rough
202my %highlights_man = ( $type_constant, "\$1",
203		       $type_func, "\\\\fB\$1\\\\fP",
204		       $type_struct, "\\\\fI\$1\\\\fP",
205		       $type_param, "\\\\fI\$1\\\\fP" );
206my $blankline_man = "";
207
208# text-mode
209my %highlights_text = ( $type_constant, "\$1",
210			$type_func, "\$1",
211			$type_struct, "\$1",
212			$type_param, "\$1" );
213my $blankline_text = "";
214
215
216sub usage {
217    print "Usage: $0 [ -v ] [ -docbook | -html | -text | -man ] [ -no-doc-sections ]\n";
218    print "         [ -function funcname [ -function funcname ...] ]\n";
219    print "         [ -nofunction funcname [ -nofunction funcname ...] ]\n";
220    print "         c source file(s) > outputfile\n";
221    print "         -v : verbose output, more warnings & other info listed\n";
222    exit 1;
223}
224
225# read arguments
226if ($#ARGV==-1) {
227    usage();
228}
229
230my $verbose = 0;
231my $output_mode = "man";
232my $no_doc_sections = 0;
233my %highlights = %highlights_man;
234my $blankline = $blankline_man;
235my $modulename = "Kernel API";
236my $function_only = 0;
237my $man_date = ('January', 'February', 'March', 'April', 'May', 'June',
238		'July', 'August', 'September', 'October',
239		'November', 'December')[(localtime)[4]] .
240  " " . ((localtime)[5]+1900);
241
242# Essentially these are globals
243# They probably want to be tidied up made more localised or summat.
244# CAVEAT EMPTOR!  Some of the others I localised may not want to be which
245# could cause "use of undefined value" or other bugs.
246my ($function, %function_table,%parametertypes,$declaration_purpose);
247my ($type,$declaration_name,$return_type);
248my ($newsection,$newcontents,$prototype,$filelist, $brcount, %source_map);
249
250if (defined($ENV{'KBUILD_VERBOSE'})) {
251	$verbose = "$ENV{'KBUILD_VERBOSE'}";
252}
253
254# Generated docbook code is inserted in a template at a point where
255# docbook v3.1 requires a non-zero sequence of RefEntry's; see:
256# http://www.oasis-open.org/docbook/documentation/reference/html/refentry.html
257# We keep track of number of generated entries and generate a dummy
258# if needs be to ensure the expanded template can be postprocessed
259# into html.
260my $section_counter = 0;
261
262my $lineprefix="";
263
264# states
265# 0 - normal code
266# 1 - looking for function name
267# 2 - scanning field start.
268# 3 - scanning prototype.
269# 4 - documentation block
270my $state;
271my $in_doc_sect;
272
273#declaration types: can be
274# 'function', 'struct', 'union', 'enum', 'typedef'
275my $decl_type;
276
277my $doc_special = "\@\%\$\&";
278
279my $doc_start = '^/\*\*\s*$'; # Allow whitespace at end of comment start.
280my $doc_end = '\*/';
281my $doc_com = '\s*\*\s*';
282my $doc_decl = $doc_com.'(\w+)';
283my $doc_sect = $doc_com.'(['.$doc_special.']?[\w\s]+):(.*)';
284my $doc_content = $doc_com.'(.*)';
285my $doc_block = $doc_com.'DOC:\s*(.*)?';
286
287my %constants;
288my %parameterdescs;
289my @parameterlist;
290my %sections;
291my @sectionlist;
292
293my $contents = "";
294my $section_default = "Description";	# default section
295my $section_intro = "Introduction";
296my $section = $section_default;
297my $section_context = "Context";
298
299my $undescribed = "-- undescribed --";
300
301reset_state();
302
303while ($ARGV[0] =~ m/^-(.*)/) {
304    my $cmd = shift @ARGV;
305    if ($cmd eq "-html") {
306	$output_mode = "html";
307	%highlights = %highlights_html;
308	$blankline = $blankline_html;
309    } elsif ($cmd eq "-man") {
310	$output_mode = "man";
311	%highlights = %highlights_man;
312	$blankline = $blankline_man;
313    } elsif ($cmd eq "-text") {
314	$output_mode = "text";
315	%highlights = %highlights_text;
316	$blankline = $blankline_text;
317    } elsif ($cmd eq "-docbook") {
318	$output_mode = "xml";
319	%highlights = %highlights_xml;
320	$blankline = $blankline_xml;
321    } elsif ($cmd eq "-gnome") {
322	$output_mode = "gnome";
323	%highlights = %highlights_gnome;
324	$blankline = $blankline_gnome;
325    } elsif ($cmd eq "-module") { # not needed for XML, inherits from calling document
326	$modulename = shift @ARGV;
327    } elsif ($cmd eq "-function") { # to only output specific functions
328	$function_only = 1;
329	$function = shift @ARGV;
330	$function_table{$function} = 1;
331    } elsif ($cmd eq "-nofunction") { # to only output specific functions
332	$function_only = 2;
333	$function = shift @ARGV;
334	$function_table{$function} = 1;
335    } elsif ($cmd eq "-v") {
336	$verbose = 1;
337    } elsif (($cmd eq "-h") || ($cmd eq "--help")) {
338	usage();
339    } elsif ($cmd eq '-filelist') {
340	    $filelist = shift @ARGV;
341    } elsif ($cmd eq '-no-doc-sections') {
342	    $no_doc_sections = 1;
343    }
344}
345
346# get kernel version from env
347sub get_kernel_version() {
348    my $version = 'unknown kernel version';
349
350    if (defined($ENV{'KERNELVERSION'})) {
351	$version = $ENV{'KERNELVERSION'};
352    }
353    return $version;
354}
355my $kernelversion = get_kernel_version();
356
357# generate a sequence of code that will splice in highlighting information
358# using the s// operator.
359my $dohighlight = "";
360foreach my $pattern (keys %highlights) {
361#   print STDERR "scanning pattern:$pattern, highlight:($highlights{$pattern})\n";
362    $dohighlight .=  "\$contents =~ s:$pattern:$highlights{$pattern}:gs;\n";
363}
364
365##
366# dumps section contents to arrays/hashes intended for that purpose.
367#
368sub dump_section {
369    my $name = shift;
370    my $contents = join "\n", @_;
371
372    if ($name =~ m/$type_constant/) {
373	$name = $1;
374#	print STDERR "constant section '$1' = '$contents'\n";
375	$constants{$name} = $contents;
376    } elsif ($name =~ m/$type_param/) {
377#	print STDERR "parameter def '$1' = '$contents'\n";
378	$name = $1;
379	$parameterdescs{$name} = $contents;
380    } else {
381#	print STDERR "other section '$name' = '$contents'\n";
382	$sections{$name} = $contents;
383	push @sectionlist, $name;
384    }
385}
386
387##
388# dump DOC: section after checking that it should go out
389#
390sub dump_doc_section {
391    my $name = shift;
392    my $contents = join "\n", @_;
393
394    if ($no_doc_sections) {
395        return;
396    }
397
398    if (($function_only == 0) ||
399	( $function_only == 1 && defined($function_table{$name})) ||
400	( $function_only == 2 && !defined($function_table{$name})))
401    {
402	dump_section $name, $contents;
403	output_blockhead({'sectionlist' => \@sectionlist,
404			  'sections' => \%sections,
405			  'module' => $modulename,
406			  'content-only' => ($function_only != 0), });
407    }
408}
409
410##
411# output function
412#
413# parameterdescs, a hash.
414#  function => "function name"
415#  parameterlist => @list of parameters
416#  parameterdescs => %parameter descriptions
417#  sectionlist => @list of sections
418#  sections => %section descriptions
419#
420
421sub output_highlight {
422    my $contents = join "\n",@_;
423    my $line;
424
425#   DEBUG
426#   if (!defined $contents) {
427#	use Carp;
428#	confess "output_highlight got called with no args?\n";
429#   }
430
431    if ($output_mode eq "html" || $output_mode eq "xml") {
432	$contents = local_unescape($contents);
433	# convert data read & converted thru xml_escape() into &xyz; format:
434	$contents =~ s/\\\\\\/&/g;
435    }
436#   print STDERR "contents b4:$contents\n";
437    eval $dohighlight;
438    die $@ if $@;
439#   print STDERR "contents af:$contents\n";
440
441    foreach $line (split "\n", $contents) {
442	if ($line eq ""){
443	    print $lineprefix, local_unescape($blankline);
444	} else {
445	    $line =~ s/\\\\\\/\&/g;
446	    if ($output_mode eq "man" && substr($line, 0, 1) eq ".") {
447		print "\\&$line";
448	    } else {
449		print $lineprefix, $line;
450	    }
451	}
452	print "\n";
453    }
454}
455
456#output sections in html
457sub output_section_html(%) {
458    my %args = %{$_[0]};
459    my $section;
460
461    foreach $section (@{$args{'sectionlist'}}) {
462	print "<h3>$section</h3>\n";
463	print "<blockquote>\n";
464	output_highlight($args{'sections'}{$section});
465	print "</blockquote>\n";
466    }
467}
468
469# output enum in html
470sub output_enum_html(%) {
471    my %args = %{$_[0]};
472    my ($parameter);
473    my $count;
474    print "<h2>enum ".$args{'enum'}."</h2>\n";
475
476    print "<b>enum ".$args{'enum'}."</b> {<br>\n";
477    $count = 0;
478    foreach $parameter (@{$args{'parameterlist'}}) {
479	print " <b>".$parameter."</b>";
480	if ($count != $#{$args{'parameterlist'}}) {
481	    $count++;
482	    print ",\n";
483	}
484	print "<br>";
485    }
486    print "};<br>\n";
487
488    print "<h3>Constants</h3>\n";
489    print "<dl>\n";
490    foreach $parameter (@{$args{'parameterlist'}}) {
491	print "<dt><b>".$parameter."</b>\n";
492	print "<dd>";
493	output_highlight($args{'parameterdescs'}{$parameter});
494    }
495    print "</dl>\n";
496    output_section_html(@_);
497    print "<hr>\n";
498}
499
500# output typedef in html
501sub output_typedef_html(%) {
502    my %args = %{$_[0]};
503    my ($parameter);
504    my $count;
505    print "<h2>typedef ".$args{'typedef'}."</h2>\n";
506
507    print "<b>typedef ".$args{'typedef'}."</b>\n";
508    output_section_html(@_);
509    print "<hr>\n";
510}
511
512# output struct in html
513sub output_struct_html(%) {
514    my %args = %{$_[0]};
515    my ($parameter);
516
517    print "<h2>".$args{'type'}." ".$args{'struct'}. " - " .$args{'purpose'}."</h2>\n";
518    print "<b>".$args{'type'}." ".$args{'struct'}."</b> {<br>\n";
519    foreach $parameter (@{$args{'parameterlist'}}) {
520	if ($parameter =~ /^#/) {
521		print "$parameter<br>\n";
522		next;
523	}
524	my $parameter_name = $parameter;
525	$parameter_name =~ s/\[.*//;
526
527	($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
528	$type = $args{'parametertypes'}{$parameter};
529	if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
530	    # pointer-to-function
531	    print "&nbsp; &nbsp; <i>$1</i><b>$parameter</b>) <i>($2)</i>;<br>\n";
532	} elsif ($type =~ m/^(.*?)\s*(:.*)/) {
533	    # bitfield
534	    print "&nbsp; &nbsp; <i>$1</i> <b>$parameter</b>$2;<br>\n";
535	} else {
536	    print "&nbsp; &nbsp; <i>$type</i> <b>$parameter</b>;<br>\n";
537	}
538    }
539    print "};<br>\n";
540
541    print "<h3>Members</h3>\n";
542    print "<dl>\n";
543    foreach $parameter (@{$args{'parameterlist'}}) {
544	($parameter =~ /^#/) && next;
545
546	my $parameter_name = $parameter;
547	$parameter_name =~ s/\[.*//;
548
549	($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
550	print "<dt><b>".$parameter."</b>\n";
551	print "<dd>";
552	output_highlight($args{'parameterdescs'}{$parameter_name});
553    }
554    print "</dl>\n";
555    output_section_html(@_);
556    print "<hr>\n";
557}
558
559# output function in html
560sub output_function_html(%) {
561    my %args = %{$_[0]};
562    my ($parameter, $section);
563    my $count;
564
565    print "<h2>" .$args{'function'}." - ".$args{'purpose'}."</h2>\n";
566    print "<i>".$args{'functiontype'}."</i>\n";
567    print "<b>".$args{'function'}."</b>\n";
568    print "(";
569    $count = 0;
570    foreach $parameter (@{$args{'parameterlist'}}) {
571	$type = $args{'parametertypes'}{$parameter};
572	if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
573	    # pointer-to-function
574	    print "<i>$1</i><b>$parameter</b>) <i>($2)</i>";
575	} else {
576	    print "<i>".$type."</i> <b>".$parameter."</b>";
577	}
578	if ($count != $#{$args{'parameterlist'}}) {
579	    $count++;
580	    print ",\n";
581	}
582    }
583    print ")\n";
584
585    print "<h3>Arguments</h3>\n";
586    print "<dl>\n";
587    foreach $parameter (@{$args{'parameterlist'}}) {
588	my $parameter_name = $parameter;
589	$parameter_name =~ s/\[.*//;
590
591	($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
592	print "<dt><b>".$parameter."</b>\n";
593	print "<dd>";
594	output_highlight($args{'parameterdescs'}{$parameter_name});
595    }
596    print "</dl>\n";
597    output_section_html(@_);
598    print "<hr>\n";
599}
600
601# output DOC: block header in html
602sub output_blockhead_html(%) {
603    my %args = %{$_[0]};
604    my ($parameter, $section);
605    my $count;
606
607    foreach $section (@{$args{'sectionlist'}}) {
608	print "<h3>$section</h3>\n";
609	print "<ul>\n";
610	output_highlight($args{'sections'}{$section});
611	print "</ul>\n";
612    }
613    print "<hr>\n";
614}
615
616sub output_section_xml(%) {
617    my %args = %{$_[0]};
618    my $section;
619    # print out each section
620    $lineprefix="   ";
621    foreach $section (@{$args{'sectionlist'}}) {
622	print "<refsect1>\n";
623	print "<title>$section</title>\n";
624	if ($section =~ m/EXAMPLE/i) {
625	    print "<informalexample><programlisting>\n";
626	} else {
627	    print "<para>\n";
628	}
629	output_highlight($args{'sections'}{$section});
630	if ($section =~ m/EXAMPLE/i) {
631	    print "</programlisting></informalexample>\n";
632	} else {
633	    print "</para>\n";
634	}
635	print "</refsect1>\n";
636    }
637}
638
639# output function in XML DocBook
640sub output_function_xml(%) {
641    my %args = %{$_[0]};
642    my ($parameter, $section);
643    my $count;
644    my $id;
645
646    $id = "API-".$args{'function'};
647    $id =~ s/[^A-Za-z0-9]/-/g;
648
649    print "<refentry id=\"$id\">\n";
650    print "<refentryinfo>\n";
651    print " <title>LINUX</title>\n";
652    print " <productname>Kernel Hackers Manual</productname>\n";
653    print " <date>$man_date</date>\n";
654    print "</refentryinfo>\n";
655    print "<refmeta>\n";
656    print " <refentrytitle><phrase>".$args{'function'}."</phrase></refentrytitle>\n";
657    print " <manvolnum>9</manvolnum>\n";
658    print " <refmiscinfo class=\"version\">" . $kernelversion . "</refmiscinfo>\n";
659    print "</refmeta>\n";
660    print "<refnamediv>\n";
661    print " <refname>".$args{'function'}."</refname>\n";
662    print " <refpurpose>\n";
663    print "  ";
664    output_highlight ($args{'purpose'});
665    print " </refpurpose>\n";
666    print "</refnamediv>\n";
667
668    print "<refsynopsisdiv>\n";
669    print " <title>Synopsis</title>\n";
670    print "  <funcsynopsis><funcprototype>\n";
671    print "   <funcdef>".$args{'functiontype'}." ";
672    print "<function>".$args{'function'}." </function></funcdef>\n";
673
674    $count = 0;
675    if ($#{$args{'parameterlist'}} >= 0) {
676	foreach $parameter (@{$args{'parameterlist'}}) {
677	    $type = $args{'parametertypes'}{$parameter};
678	    if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
679		# pointer-to-function
680		print "   <paramdef>$1<parameter>$parameter</parameter>)\n";
681		print "     <funcparams>$2</funcparams></paramdef>\n";
682	    } else {
683		print "   <paramdef>".$type;
684		print " <parameter>$parameter</parameter></paramdef>\n";
685	    }
686	}
687    } else {
688	print "  <void/>\n";
689    }
690    print "  </funcprototype></funcsynopsis>\n";
691    print "</refsynopsisdiv>\n";
692
693    # print parameters
694    print "<refsect1>\n <title>Arguments</title>\n";
695    if ($#{$args{'parameterlist'}} >= 0) {
696	print " <variablelist>\n";
697	foreach $parameter (@{$args{'parameterlist'}}) {
698	    my $parameter_name = $parameter;
699	    $parameter_name =~ s/\[.*//;
700
701	    print "  <varlistentry>\n   <term><parameter>$parameter</parameter></term>\n";
702	    print "   <listitem>\n    <para>\n";
703	    $lineprefix="     ";
704	    output_highlight($args{'parameterdescs'}{$parameter_name});
705	    print "    </para>\n   </listitem>\n  </varlistentry>\n";
706	}
707	print " </variablelist>\n";
708    } else {
709	print " <para>\n  None\n </para>\n";
710    }
711    print "</refsect1>\n";
712
713    output_section_xml(@_);
714    print "</refentry>\n\n";
715}
716
717# output struct in XML DocBook
718sub output_struct_xml(%) {
719    my %args = %{$_[0]};
720    my ($parameter, $section);
721    my $id;
722
723    $id = "API-struct-".$args{'struct'};
724    $id =~ s/[^A-Za-z0-9]/-/g;
725
726    print "<refentry id=\"$id\">\n";
727    print "<refentryinfo>\n";
728    print " <title>LINUX</title>\n";
729    print " <productname>Kernel Hackers Manual</productname>\n";
730    print " <date>$man_date</date>\n";
731    print "</refentryinfo>\n";
732    print "<refmeta>\n";
733    print " <refentrytitle><phrase>".$args{'type'}." ".$args{'struct'}."</phrase></refentrytitle>\n";
734    print " <manvolnum>9</manvolnum>\n";
735    print " <refmiscinfo class=\"version\">" . $kernelversion . "</refmiscinfo>\n";
736    print "</refmeta>\n";
737    print "<refnamediv>\n";
738    print " <refname>".$args{'type'}." ".$args{'struct'}."</refname>\n";
739    print " <refpurpose>\n";
740    print "  ";
741    output_highlight ($args{'purpose'});
742    print " </refpurpose>\n";
743    print "</refnamediv>\n";
744
745    print "<refsynopsisdiv>\n";
746    print " <title>Synopsis</title>\n";
747    print "  <programlisting>\n";
748    print $args{'type'}." ".$args{'struct'}." {\n";
749    foreach $parameter (@{$args{'parameterlist'}}) {
750	if ($parameter =~ /^#/) {
751	    print "$parameter\n";
752	    next;
753	}
754
755	my $parameter_name = $parameter;
756	$parameter_name =~ s/\[.*//;
757
758	defined($args{'parameterdescs'}{$parameter_name}) || next;
759	($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
760	$type = $args{'parametertypes'}{$parameter};
761	if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
762	    # pointer-to-function
763	    print "  $1 $parameter) ($2);\n";
764	} elsif ($type =~ m/^(.*?)\s*(:.*)/) {
765	    # bitfield
766	    print "  $1 $parameter$2;\n";
767	} else {
768	    print "  ".$type." ".$parameter.";\n";
769	}
770    }
771    print "};";
772    print "  </programlisting>\n";
773    print "</refsynopsisdiv>\n";
774
775    print " <refsect1>\n";
776    print "  <title>Members</title>\n";
777
778    print "  <variablelist>\n";
779    foreach $parameter (@{$args{'parameterlist'}}) {
780      ($parameter =~ /^#/) && next;
781
782      my $parameter_name = $parameter;
783      $parameter_name =~ s/\[.*//;
784
785      defined($args{'parameterdescs'}{$parameter_name}) || next;
786      ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
787      print "    <varlistentry>";
788      print "      <term>$parameter</term>\n";
789      print "      <listitem><para>\n";
790      output_highlight($args{'parameterdescs'}{$parameter_name});
791      print "      </para></listitem>\n";
792      print "    </varlistentry>\n";
793    }
794    print "  </variablelist>\n";
795    print " </refsect1>\n";
796
797    output_section_xml(@_);
798
799    print "</refentry>\n\n";
800}
801
802# output enum in XML DocBook
803sub output_enum_xml(%) {
804    my %args = %{$_[0]};
805    my ($parameter, $section);
806    my $count;
807    my $id;
808
809    $id = "API-enum-".$args{'enum'};
810    $id =~ s/[^A-Za-z0-9]/-/g;
811
812    print "<refentry id=\"$id\">\n";
813    print "<refentryinfo>\n";
814    print " <title>LINUX</title>\n";
815    print " <productname>Kernel Hackers Manual</productname>\n";
816    print " <date>$man_date</date>\n";
817    print "</refentryinfo>\n";
818    print "<refmeta>\n";
819    print " <refentrytitle><phrase>enum ".$args{'enum'}."</phrase></refentrytitle>\n";
820    print " <manvolnum>9</manvolnum>\n";
821    print " <refmiscinfo class=\"version\">" . $kernelversion . "</refmiscinfo>\n";
822    print "</refmeta>\n";
823    print "<refnamediv>\n";
824    print " <refname>enum ".$args{'enum'}."</refname>\n";
825    print " <refpurpose>\n";
826    print "  ";
827    output_highlight ($args{'purpose'});
828    print " </refpurpose>\n";
829    print "</refnamediv>\n";
830
831    print "<refsynopsisdiv>\n";
832    print " <title>Synopsis</title>\n";
833    print "  <programlisting>\n";
834    print "enum ".$args{'enum'}." {\n";
835    $count = 0;
836    foreach $parameter (@{$args{'parameterlist'}}) {
837	print "  $parameter";
838	if ($count != $#{$args{'parameterlist'}}) {
839	    $count++;
840	    print ",";
841	}
842	print "\n";
843    }
844    print "};";
845    print "  </programlisting>\n";
846    print "</refsynopsisdiv>\n";
847
848    print "<refsect1>\n";
849    print " <title>Constants</title>\n";
850    print "  <variablelist>\n";
851    foreach $parameter (@{$args{'parameterlist'}}) {
852      my $parameter_name = $parameter;
853      $parameter_name =~ s/\[.*//;
854
855      print "    <varlistentry>";
856      print "      <term>$parameter</term>\n";
857      print "      <listitem><para>\n";
858      output_highlight($args{'parameterdescs'}{$parameter_name});
859      print "      </para></listitem>\n";
860      print "    </varlistentry>\n";
861    }
862    print "  </variablelist>\n";
863    print "</refsect1>\n";
864
865    output_section_xml(@_);
866
867    print "</refentry>\n\n";
868}
869
870# output typedef in XML DocBook
871sub output_typedef_xml(%) {
872    my %args = %{$_[0]};
873    my ($parameter, $section);
874    my $id;
875
876    $id = "API-typedef-".$args{'typedef'};
877    $id =~ s/[^A-Za-z0-9]/-/g;
878
879    print "<refentry id=\"$id\">\n";
880    print "<refentryinfo>\n";
881    print " <title>LINUX</title>\n";
882    print " <productname>Kernel Hackers Manual</productname>\n";
883    print " <date>$man_date</date>\n";
884    print "</refentryinfo>\n";
885    print "<refmeta>\n";
886    print " <refentrytitle><phrase>typedef ".$args{'typedef'}."</phrase></refentrytitle>\n";
887    print " <manvolnum>9</manvolnum>\n";
888    print "</refmeta>\n";
889    print "<refnamediv>\n";
890    print " <refname>typedef ".$args{'typedef'}."</refname>\n";
891    print " <refpurpose>\n";
892    print "  ";
893    output_highlight ($args{'purpose'});
894    print " </refpurpose>\n";
895    print "</refnamediv>\n";
896
897    print "<refsynopsisdiv>\n";
898    print " <title>Synopsis</title>\n";
899    print "  <synopsis>typedef ".$args{'typedef'}.";</synopsis>\n";
900    print "</refsynopsisdiv>\n";
901
902    output_section_xml(@_);
903
904    print "</refentry>\n\n";
905}
906
907# output in XML DocBook
908sub output_blockhead_xml(%) {
909    my %args = %{$_[0]};
910    my ($parameter, $section);
911    my $count;
912
913    my $id = $args{'module'};
914    $id =~ s/[^A-Za-z0-9]/-/g;
915
916    # print out each section
917    $lineprefix="   ";
918    foreach $section (@{$args{'sectionlist'}}) {
919	if (!$args{'content-only'}) {
920		print "<refsect1>\n <title>$section</title>\n";
921	}
922	if ($section =~ m/EXAMPLE/i) {
923	    print "<example><para>\n";
924	} else {
925	    print "<para>\n";
926	}
927	output_highlight($args{'sections'}{$section});
928	if ($section =~ m/EXAMPLE/i) {
929	    print "</para></example>\n";
930	} else {
931	    print "</para>";
932	}
933	if (!$args{'content-only'}) {
934		print "\n</refsect1>\n";
935	}
936    }
937
938    print "\n\n";
939}
940
941# output in XML DocBook
942sub output_function_gnome {
943    my %args = %{$_[0]};
944    my ($parameter, $section);
945    my $count;
946    my $id;
947
948    $id = $args{'module'}."-".$args{'function'};
949    $id =~ s/[^A-Za-z0-9]/-/g;
950
951    print "<sect2>\n";
952    print " <title id=\"$id\">".$args{'function'}."</title>\n";
953
954    print "  <funcsynopsis>\n";
955    print "   <funcdef>".$args{'functiontype'}." ";
956    print "<function>".$args{'function'}." ";
957    print "</function></funcdef>\n";
958
959    $count = 0;
960    if ($#{$args{'parameterlist'}} >= 0) {
961	foreach $parameter (@{$args{'parameterlist'}}) {
962	    $type = $args{'parametertypes'}{$parameter};
963	    if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
964		# pointer-to-function
965		print "   <paramdef>$1 <parameter>$parameter</parameter>)\n";
966		print "     <funcparams>$2</funcparams></paramdef>\n";
967	    } else {
968		print "   <paramdef>".$type;
969		print " <parameter>$parameter</parameter></paramdef>\n";
970	    }
971	}
972    } else {
973	print "  <void>\n";
974    }
975    print "  </funcsynopsis>\n";
976    if ($#{$args{'parameterlist'}} >= 0) {
977	print " <informaltable pgwide=\"1\" frame=\"none\" role=\"params\">\n";
978	print "<tgroup cols=\"2\">\n";
979	print "<colspec colwidth=\"2*\">\n";
980	print "<colspec colwidth=\"8*\">\n";
981	print "<tbody>\n";
982	foreach $parameter (@{$args{'parameterlist'}}) {
983	    my $parameter_name = $parameter;
984	    $parameter_name =~ s/\[.*//;
985
986	    print "  <row><entry align=\"right\"><parameter>$parameter</parameter></entry>\n";
987	    print "   <entry>\n";
988	    $lineprefix="     ";
989	    output_highlight($args{'parameterdescs'}{$parameter_name});
990	    print "    </entry></row>\n";
991	}
992	print " </tbody></tgroup></informaltable>\n";
993    } else {
994	print " <para>\n  None\n </para>\n";
995    }
996
997    # print out each section
998    $lineprefix="   ";
999    foreach $section (@{$args{'sectionlist'}}) {
1000	print "<simplesect>\n <title>$section</title>\n";
1001	if ($section =~ m/EXAMPLE/i) {
1002	    print "<example><programlisting>\n";
1003	} else {
1004	}
1005	print "<para>\n";
1006	output_highlight($args{'sections'}{$section});
1007	print "</para>\n";
1008	if ($section =~ m/EXAMPLE/i) {
1009	    print "</programlisting></example>\n";
1010	} else {
1011	}
1012	print " </simplesect>\n";
1013    }
1014
1015    print "</sect2>\n\n";
1016}
1017
1018##
1019# output function in man
1020sub output_function_man(%) {
1021    my %args = %{$_[0]};
1022    my ($parameter, $section);
1023    my $count;
1024
1025    print ".TH \"$args{'function'}\" 9 \"$args{'function'}\" \"$man_date\" \"Kernel Hacker's Manual\" LINUX\n";
1026
1027    print ".SH NAME\n";
1028    print $args{'function'}." \\- ".$args{'purpose'}."\n";
1029
1030    print ".SH SYNOPSIS\n";
1031    if ($args{'functiontype'} ne "") {
1032	print ".B \"".$args{'functiontype'}."\" ".$args{'function'}."\n";
1033    } else {
1034	print ".B \"".$args{'function'}."\n";
1035    }
1036    $count = 0;
1037    my $parenth = "(";
1038    my $post = ",";
1039    foreach my $parameter (@{$args{'parameterlist'}}) {
1040	if ($count == $#{$args{'parameterlist'}}) {
1041	    $post = ");";
1042	}
1043	$type = $args{'parametertypes'}{$parameter};
1044	if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
1045	    # pointer-to-function
1046	    print ".BI \"".$parenth.$1."\" ".$parameter." \") (".$2.")".$post."\"\n";
1047	} else {
1048	    $type =~ s/([^\*])$/$1 /;
1049	    print ".BI \"".$parenth.$type."\" ".$parameter." \"".$post."\"\n";
1050	}
1051	$count++;
1052	$parenth = "";
1053    }
1054
1055    print ".SH ARGUMENTS\n";
1056    foreach $parameter (@{$args{'parameterlist'}}) {
1057	my $parameter_name = $parameter;
1058	$parameter_name =~ s/\[.*//;
1059
1060	print ".IP \"".$parameter."\" 12\n";
1061	output_highlight($args{'parameterdescs'}{$parameter_name});
1062    }
1063    foreach $section (@{$args{'sectionlist'}}) {
1064	print ".SH \"", uc $section, "\"\n";
1065	output_highlight($args{'sections'}{$section});
1066    }
1067}
1068
1069##
1070# output enum in man
1071sub output_enum_man(%) {
1072    my %args = %{$_[0]};
1073    my ($parameter, $section);
1074    my $count;
1075
1076    print ".TH \"$args{'module'}\" 9 \"enum $args{'enum'}\" \"$man_date\" \"API Manual\" LINUX\n";
1077
1078    print ".SH NAME\n";
1079    print "enum ".$args{'enum'}." \\- ".$args{'purpose'}."\n";
1080
1081    print ".SH SYNOPSIS\n";
1082    print "enum ".$args{'enum'}." {\n";
1083    $count = 0;
1084    foreach my $parameter (@{$args{'parameterlist'}}) {
1085	print ".br\n.BI \"    $parameter\"\n";
1086	if ($count == $#{$args{'parameterlist'}}) {
1087	    print "\n};\n";
1088	    last;
1089	}
1090	else {
1091	    print ", \n.br\n";
1092	}
1093	$count++;
1094    }
1095
1096    print ".SH Constants\n";
1097    foreach $parameter (@{$args{'parameterlist'}}) {
1098	my $parameter_name = $parameter;
1099	$parameter_name =~ s/\[.*//;
1100
1101	print ".IP \"".$parameter."\" 12\n";
1102	output_highlight($args{'parameterdescs'}{$parameter_name});
1103    }
1104    foreach $section (@{$args{'sectionlist'}}) {
1105	print ".SH \"$section\"\n";
1106	output_highlight($args{'sections'}{$section});
1107    }
1108}
1109
1110##
1111# output struct in man
1112sub output_struct_man(%) {
1113    my %args = %{$_[0]};
1114    my ($parameter, $section);
1115
1116    print ".TH \"$args{'module'}\" 9 \"".$args{'type'}." ".$args{'struct'}."\" \"$man_date\" \"API Manual\" LINUX\n";
1117
1118    print ".SH NAME\n";
1119    print $args{'type'}." ".$args{'struct'}." \\- ".$args{'purpose'}."\n";
1120
1121    print ".SH SYNOPSIS\n";
1122    print $args{'type'}." ".$args{'struct'}." {\n.br\n";
1123
1124    foreach my $parameter (@{$args{'parameterlist'}}) {
1125	if ($parameter =~ /^#/) {
1126	    print ".BI \"$parameter\"\n.br\n";
1127	    next;
1128	}
1129	my $parameter_name = $parameter;
1130	$parameter_name =~ s/\[.*//;
1131
1132	($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
1133	$type = $args{'parametertypes'}{$parameter};
1134	if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
1135	    # pointer-to-function
1136	    print ".BI \"    ".$1."\" ".$parameter." \") (".$2.")"."\"\n;\n";
1137	} elsif ($type =~ m/^(.*?)\s*(:.*)/) {
1138	    # bitfield
1139	    print ".BI \"    ".$1."\ \" ".$parameter.$2." \""."\"\n;\n";
1140	} else {
1141	    $type =~ s/([^\*])$/$1 /;
1142	    print ".BI \"    ".$type."\" ".$parameter." \""."\"\n;\n";
1143	}
1144	print "\n.br\n";
1145    }
1146    print "};\n.br\n";
1147
1148    print ".SH Members\n";
1149    foreach $parameter (@{$args{'parameterlist'}}) {
1150	($parameter =~ /^#/) && next;
1151
1152	my $parameter_name = $parameter;
1153	$parameter_name =~ s/\[.*//;
1154
1155	($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
1156	print ".IP \"".$parameter."\" 12\n";
1157	output_highlight($args{'parameterdescs'}{$parameter_name});
1158    }
1159    foreach $section (@{$args{'sectionlist'}}) {
1160	print ".SH \"$section\"\n";
1161	output_highlight($args{'sections'}{$section});
1162    }
1163}
1164
1165##
1166# output typedef in man
1167sub output_typedef_man(%) {
1168    my %args = %{$_[0]};
1169    my ($parameter, $section);
1170
1171    print ".TH \"$args{'module'}\" 9 \"$args{'typedef'}\" \"$man_date\" \"API Manual\" LINUX\n";
1172
1173    print ".SH NAME\n";
1174    print "typedef ".$args{'typedef'}." \\- ".$args{'purpose'}."\n";
1175
1176    foreach $section (@{$args{'sectionlist'}}) {
1177	print ".SH \"$section\"\n";
1178	output_highlight($args{'sections'}{$section});
1179    }
1180}
1181
1182sub output_blockhead_man(%) {
1183    my %args = %{$_[0]};
1184    my ($parameter, $section);
1185    my $count;
1186
1187    print ".TH \"$args{'module'}\" 9 \"$args{'module'}\" \"$man_date\" \"API Manual\" LINUX\n";
1188
1189    foreach $section (@{$args{'sectionlist'}}) {
1190	print ".SH \"$section\"\n";
1191	output_highlight($args{'sections'}{$section});
1192    }
1193}
1194
1195##
1196# output in text
1197sub output_function_text(%) {
1198    my %args = %{$_[0]};
1199    my ($parameter, $section);
1200    my $start;
1201
1202    print "Name:\n\n";
1203    print $args{'function'}." - ".$args{'purpose'}."\n";
1204
1205    print "\nSynopsis:\n\n";
1206    if ($args{'functiontype'} ne "") {
1207	$start = $args{'functiontype'}." ".$args{'function'}." (";
1208    } else {
1209	$start = $args{'function'}." (";
1210    }
1211    print $start;
1212
1213    my $count = 0;
1214    foreach my $parameter (@{$args{'parameterlist'}}) {
1215	$type = $args{'parametertypes'}{$parameter};
1216	if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
1217	    # pointer-to-function
1218	    print $1.$parameter.") (".$2;
1219	} else {
1220	    print $type." ".$parameter;
1221	}
1222	if ($count != $#{$args{'parameterlist'}}) {
1223	    $count++;
1224	    print ",\n";
1225	    print " " x length($start);
1226	} else {
1227	    print ");\n\n";
1228	}
1229    }
1230
1231    print "Arguments:\n\n";
1232    foreach $parameter (@{$args{'parameterlist'}}) {
1233	my $parameter_name = $parameter;
1234	$parameter_name =~ s/\[.*//;
1235
1236	print $parameter."\n\t".$args{'parameterdescs'}{$parameter_name}."\n";
1237    }
1238    output_section_text(@_);
1239}
1240
1241#output sections in text
1242sub output_section_text(%) {
1243    my %args = %{$_[0]};
1244    my $section;
1245
1246    print "\n";
1247    foreach $section (@{$args{'sectionlist'}}) {
1248	print "$section:\n\n";
1249	output_highlight($args{'sections'}{$section});
1250    }
1251    print "\n\n";
1252}
1253
1254# output enum in text
1255sub output_enum_text(%) {
1256    my %args = %{$_[0]};
1257    my ($parameter);
1258    my $count;
1259    print "Enum:\n\n";
1260
1261    print "enum ".$args{'enum'}." - ".$args{'purpose'}."\n\n";
1262    print "enum ".$args{'enum'}." {\n";
1263    $count = 0;
1264    foreach $parameter (@{$args{'parameterlist'}}) {
1265	print "\t$parameter";
1266	if ($count != $#{$args{'parameterlist'}}) {
1267	    $count++;
1268	    print ",";
1269	}
1270	print "\n";
1271    }
1272    print "};\n\n";
1273
1274    print "Constants:\n\n";
1275    foreach $parameter (@{$args{'parameterlist'}}) {
1276	print "$parameter\n\t";
1277	print $args{'parameterdescs'}{$parameter}."\n";
1278    }
1279
1280    output_section_text(@_);
1281}
1282
1283# output typedef in text
1284sub output_typedef_text(%) {
1285    my %args = %{$_[0]};
1286    my ($parameter);
1287    my $count;
1288    print "Typedef:\n\n";
1289
1290    print "typedef ".$args{'typedef'}." - ".$args{'purpose'}."\n";
1291    output_section_text(@_);
1292}
1293
1294# output struct as text
1295sub output_struct_text(%) {
1296    my %args = %{$_[0]};
1297    my ($parameter);
1298
1299    print $args{'type'}." ".$args{'struct'}." - ".$args{'purpose'}."\n\n";
1300    print $args{'type'}." ".$args{'struct'}." {\n";
1301    foreach $parameter (@{$args{'parameterlist'}}) {
1302	if ($parameter =~ /^#/) {
1303	    print "$parameter\n";
1304	    next;
1305	}
1306
1307	my $parameter_name = $parameter;
1308	$parameter_name =~ s/\[.*//;
1309
1310	($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
1311	$type = $args{'parametertypes'}{$parameter};
1312	if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
1313	    # pointer-to-function
1314	    print "\t$1 $parameter) ($2);\n";
1315	} elsif ($type =~ m/^(.*?)\s*(:.*)/) {
1316	    # bitfield
1317	    print "\t$1 $parameter$2;\n";
1318	} else {
1319	    print "\t".$type." ".$parameter.";\n";
1320	}
1321    }
1322    print "};\n\n";
1323
1324    print "Members:\n\n";
1325    foreach $parameter (@{$args{'parameterlist'}}) {
1326	($parameter =~ /^#/) && next;
1327
1328	my $parameter_name = $parameter;
1329	$parameter_name =~ s/\[.*//;
1330
1331	($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
1332	print "$parameter\n\t";
1333	print $args{'parameterdescs'}{$parameter_name}."\n";
1334    }
1335    print "\n";
1336    output_section_text(@_);
1337}
1338
1339sub output_blockhead_text(%) {
1340    my %args = %{$_[0]};
1341    my ($parameter, $section);
1342
1343    foreach $section (@{$args{'sectionlist'}}) {
1344	print " $section:\n";
1345	print "    -> ";
1346	output_highlight($args{'sections'}{$section});
1347    }
1348}
1349
1350##
1351# generic output function for all types (function, struct/union, typedef, enum);
1352# calls the generated, variable output_ function name based on
1353# functype and output_mode
1354sub output_declaration {
1355    no strict 'refs';
1356    my $name = shift;
1357    my $functype = shift;
1358    my $func = "output_${functype}_$output_mode";
1359    if (($function_only==0) ||
1360	( $function_only == 1 && defined($function_table{$name})) ||
1361	( $function_only == 2 && !defined($function_table{$name})))
1362    {
1363	&$func(@_);
1364	$section_counter++;
1365    }
1366}
1367
1368##
1369# generic output function - calls the right one based on current output mode.
1370sub output_blockhead {
1371    no strict 'refs';
1372    my $func = "output_blockhead_".$output_mode;
1373    &$func(@_);
1374    $section_counter++;
1375}
1376
1377##
1378# takes a declaration (struct, union, enum, typedef) and
1379# invokes the right handler. NOT called for functions.
1380sub dump_declaration($$) {
1381    no strict 'refs';
1382    my ($prototype, $file) = @_;
1383    my $func = "dump_".$decl_type;
1384    &$func(@_);
1385}
1386
1387sub dump_union($$) {
1388    dump_struct(@_);
1389}
1390
1391sub dump_struct($$) {
1392    my $x = shift;
1393    my $file = shift;
1394
1395    if ($x =~/(struct|union)\s+(\w+)\s*{(.*)}/) {
1396	$declaration_name = $2;
1397	my $members = $3;
1398
1399	# ignore embedded structs or unions
1400	$members =~ s/{.*?}//g;
1401
1402	# ignore members marked private:
1403	$members =~ s/\/\*.*?private:.*?public:.*?\*\///gos;
1404	$members =~ s/\/\*.*?private:.*//gos;
1405	# strip comments:
1406	$members =~ s/\/\*.*?\*\///gos;
1407
1408	create_parameterlist($members, ';', $file);
1409
1410	output_declaration($declaration_name,
1411			   'struct',
1412			   {'struct' => $declaration_name,
1413			    'module' => $modulename,
1414			    'parameterlist' => \@parameterlist,
1415			    'parameterdescs' => \%parameterdescs,
1416			    'parametertypes' => \%parametertypes,
1417			    'sectionlist' => \@sectionlist,
1418			    'sections' => \%sections,
1419			    'purpose' => $declaration_purpose,
1420			    'type' => $decl_type
1421			   });
1422    }
1423    else {
1424	print STDERR "Error(${file}:$.): Cannot parse struct or union!\n";
1425	++$errors;
1426    }
1427}
1428
1429sub dump_enum($$) {
1430    my $x = shift;
1431    my $file = shift;
1432
1433    $x =~ s@/\*.*?\*/@@gos;	# strip comments.
1434    if ($x =~ /enum\s+(\w+)\s*{(.*)}/) {
1435	$declaration_name = $1;
1436	my $members = $2;
1437
1438	foreach my $arg (split ',', $members) {
1439	    $arg =~ s/^\s*(\w+).*/$1/;
1440	    push @parameterlist, $arg;
1441	    if (!$parameterdescs{$arg}) {
1442		$parameterdescs{$arg} = $undescribed;
1443		print STDERR "Warning(${file}:$.): Enum value '$arg' ".
1444		    "not described in enum '$declaration_name'\n";
1445	    }
1446
1447	}
1448
1449	output_declaration($declaration_name,
1450			   'enum',
1451			   {'enum' => $declaration_name,
1452			    'module' => $modulename,
1453			    'parameterlist' => \@parameterlist,
1454			    'parameterdescs' => \%parameterdescs,
1455			    'sectionlist' => \@sectionlist,
1456			    'sections' => \%sections,
1457			    'purpose' => $declaration_purpose
1458			   });
1459    }
1460    else {
1461	print STDERR "Error(${file}:$.): Cannot parse enum!\n";
1462	++$errors;
1463    }
1464}
1465
1466sub dump_typedef($$) {
1467    my $x = shift;
1468    my $file = shift;
1469
1470    $x =~ s@/\*.*?\*/@@gos;	# strip comments.
1471    while (($x =~ /\(*.\)\s*;$/) || ($x =~ /\[*.\]\s*;$/)) {
1472	$x =~ s/\(*.\)\s*;$/;/;
1473	$x =~ s/\[*.\]\s*;$/;/;
1474    }
1475
1476    if ($x =~ /typedef.*\s+(\w+)\s*;/) {
1477	$declaration_name = $1;
1478
1479	output_declaration($declaration_name,
1480			   'typedef',
1481			   {'typedef' => $declaration_name,
1482			    'module' => $modulename,
1483			    'sectionlist' => \@sectionlist,
1484			    'sections' => \%sections,
1485			    'purpose' => $declaration_purpose
1486			   });
1487    }
1488    else {
1489	print STDERR "Error(${file}:$.): Cannot parse typedef!\n";
1490	++$errors;
1491    }
1492}
1493
1494sub create_parameterlist($$$) {
1495    my $args = shift;
1496    my $splitter = shift;
1497    my $file = shift;
1498    my $type;
1499    my $param;
1500
1501    # temporarily replace commas inside function pointer definition
1502    while ($args =~ /(\([^\),]+),/) {
1503	$args =~ s/(\([^\),]+),/$1#/g;
1504    }
1505
1506    foreach my $arg (split($splitter, $args)) {
1507	# strip comments
1508	$arg =~ s/\/\*.*\*\///;
1509	# strip leading/trailing spaces
1510	$arg =~ s/^\s*//;
1511	$arg =~ s/\s*$//;
1512	$arg =~ s/\s+/ /;
1513
1514	if ($arg =~ /^#/) {
1515	    # Treat preprocessor directive as a typeless variable just to fill
1516	    # corresponding data structures "correctly". Catch it later in
1517	    # output_* subs.
1518	    push_parameter($arg, "", $file);
1519	} elsif ($arg =~ m/\(.+\)\s*\(/) {
1520	    # pointer-to-function
1521	    $arg =~ tr/#/,/;
1522	    $arg =~ m/[^\(]+\(\*?\s*(\w*)\s*\)/;
1523	    $param = $1;
1524	    $type = $arg;
1525	    $type =~ s/([^\(]+\(\*?)\s*$param/$1/;
1526	    push_parameter($param, $type, $file);
1527	} elsif ($arg) {
1528	    $arg =~ s/\s*:\s*/:/g;
1529	    $arg =~ s/\s*\[/\[/g;
1530
1531	    my @args = split('\s*,\s*', $arg);
1532	    if ($args[0] =~ m/\*/) {
1533		$args[0] =~ s/(\*+)\s*/ $1/;
1534	    }
1535
1536	    my @first_arg;
1537	    if ($args[0] =~ /^(.*\s+)(.*?\[.*\].*)$/) {
1538		    shift @args;
1539		    push(@first_arg, split('\s+', $1));
1540		    push(@first_arg, $2);
1541	    } else {
1542		    @first_arg = split('\s+', shift @args);
1543	    }
1544
1545	    unshift(@args, pop @first_arg);
1546	    $type = join " ", @first_arg;
1547
1548	    foreach $param (@args) {
1549		if ($param =~ m/^(\*+)\s*(.*)/) {
1550		    push_parameter($2, "$type $1", $file);
1551		}
1552		elsif ($param =~ m/(.*?):(\d+)/) {
1553		    push_parameter($1, "$type:$2", $file)
1554		}
1555		else {
1556		    push_parameter($param, $type, $file);
1557		}
1558	    }
1559	}
1560    }
1561}
1562
1563sub push_parameter($$$) {
1564	my $param = shift;
1565	my $type = shift;
1566	my $file = shift;
1567
1568	if (($anon_struct_union == 1) && ($type eq "") &&
1569	    ($param eq "}")) {
1570		return;		# ignore the ending }; from anon. struct/union
1571	}
1572
1573	$anon_struct_union = 0;
1574	my $param_name = $param;
1575	$param_name =~ s/\[.*//;
1576
1577	if ($type eq "" && $param =~ /\.\.\.$/)
1578	{
1579	    $type="";
1580	    $parameterdescs{$param} = "variable arguments";
1581	}
1582	elsif ($type eq "" && ($param eq "" or $param eq "void"))
1583	{
1584	    $type="";
1585	    $param="void";
1586	    $parameterdescs{void} = "no arguments";
1587	}
1588	elsif ($type eq "" && ($param eq "struct" or $param eq "union"))
1589	# handle unnamed (anonymous) union or struct:
1590	{
1591		$type = $param;
1592		$param = "{unnamed_" . $param . "}";
1593		$parameterdescs{$param} = "anonymous\n";
1594		$anon_struct_union = 1;
1595	}
1596
1597	# warn if parameter has no description
1598	# (but ignore ones starting with # as these are not parameters
1599	# but inline preprocessor statements);
1600	# also ignore unnamed structs/unions;
1601	if (!$anon_struct_union) {
1602	if (!defined $parameterdescs{$param_name} && $param_name !~ /^#/) {
1603
1604	    $parameterdescs{$param_name} = $undescribed;
1605
1606	    if (($type eq 'function') || ($type eq 'enum')) {
1607		print STDERR "Warning(${file}:$.): Function parameter ".
1608		    "or member '$param' not " .
1609		    "described in '$declaration_name'\n";
1610	    }
1611	    print STDERR "Warning(${file}:$.):".
1612			 " No description found for parameter '$param'\n";
1613	    ++$warnings;
1614	}
1615	}
1616
1617	push @parameterlist, $param;
1618	$parametertypes{$param} = $type;
1619}
1620
1621##
1622# takes a function prototype and the name of the current file being
1623# processed and spits out all the details stored in the global
1624# arrays/hashes.
1625sub dump_function($$) {
1626    my $prototype = shift;
1627    my $file = shift;
1628
1629    $prototype =~ s/^static +//;
1630    $prototype =~ s/^extern +//;
1631    $prototype =~ s/^asmlinkage +//;
1632    $prototype =~ s/^inline +//;
1633    $prototype =~ s/^__inline__ +//;
1634    $prototype =~ s/^__inline +//;
1635    $prototype =~ s/^__always_inline +//;
1636    $prototype =~ s/^noinline +//;
1637    $prototype =~ s/__devinit +//;
1638    $prototype =~ s/^#define\s+//; #ak added
1639    $prototype =~ s/__attribute__\s*\(\([a-z,]*\)\)//;
1640
1641    # Yes, this truly is vile.  We are looking for:
1642    # 1. Return type (may be nothing if we're looking at a macro)
1643    # 2. Function name
1644    # 3. Function parameters.
1645    #
1646    # All the while we have to watch out for function pointer parameters
1647    # (which IIRC is what the two sections are for), C types (these
1648    # regexps don't even start to express all the possibilities), and
1649    # so on.
1650    #
1651    # If you mess with these regexps, it's a good idea to check that
1652    # the following functions' documentation still comes out right:
1653    # - parport_register_device (function pointer parameters)
1654    # - atomic_set (macro)
1655    # - pci_match_device, __copy_to_user (long return type)
1656
1657    if ($prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
1658	$prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
1659	$prototype =~ m/^(\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
1660	$prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
1661	$prototype =~ m/^(\w+\s+\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
1662	$prototype =~ m/^(\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
1663	$prototype =~ m/^(\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
1664	$prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1665	$prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1666	$prototype =~ m/^(\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1667	$prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1668	$prototype =~ m/^(\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1669	$prototype =~ m/^(\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1670	$prototype =~ m/^(\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1671	$prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1672	$prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1673	$prototype =~ m/^(\w+\s+\w+\s*\*\s*\w+\s*\*\s*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/)  {
1674	$return_type = $1;
1675	$declaration_name = $2;
1676	my $args = $3;
1677
1678	create_parameterlist($args, ',', $file);
1679    } else {
1680	print STDERR "Error(${file}:$.): cannot understand prototype: '$prototype'\n";
1681	++$errors;
1682	return;
1683    }
1684
1685    output_declaration($declaration_name,
1686		       'function',
1687		       {'function' => $declaration_name,
1688			'module' => $modulename,
1689			'functiontype' => $return_type,
1690			'parameterlist' => \@parameterlist,
1691			'parameterdescs' => \%parameterdescs,
1692			'parametertypes' => \%parametertypes,
1693			'sectionlist' => \@sectionlist,
1694			'sections' => \%sections,
1695			'purpose' => $declaration_purpose
1696		       });
1697}
1698
1699sub process_file($);
1700
1701# Read the file that maps relative names to absolute names for
1702# separate source and object directories and for shadow trees.
1703if (open(SOURCE_MAP, "<.tmp_filelist.txt")) {
1704	my ($relname, $absname);
1705	while(<SOURCE_MAP>) {
1706		chop();
1707		($relname, $absname) = (split())[0..1];
1708		$relname =~ s:^/+::;
1709		$source_map{$relname} = $absname;
1710	}
1711	close(SOURCE_MAP);
1712}
1713
1714if ($filelist) {
1715	open(FLIST,"<$filelist") or die "Can't open file list $filelist";
1716	while(<FLIST>) {
1717		chop;
1718		process_file($_);
1719	}
1720}
1721
1722foreach (@ARGV) {
1723    chomp;
1724    process_file($_);
1725}
1726if ($verbose && $errors) {
1727  print STDERR "$errors errors\n";
1728}
1729if ($verbose && $warnings) {
1730  print STDERR "$warnings warnings\n";
1731}
1732
1733exit($errors);
1734
1735sub reset_state {
1736    $function = "";
1737    %constants = ();
1738    %parameterdescs = ();
1739    %parametertypes = ();
1740    @parameterlist = ();
1741    %sections = ();
1742    @sectionlist = ();
1743    $prototype = "";
1744
1745    $state = 0;
1746}
1747
1748sub process_state3_function($$) {
1749    my $x = shift;
1750    my $file = shift;
1751
1752    $x =~ s@\/\/.*$@@gos; # strip C99-style comments to end of line
1753
1754    if ($x =~ m#\s*/\*\s+MACDOC\s*#io || ($x =~ /^#/ && $x !~ /^#define/)) {
1755	# do nothing
1756    }
1757    elsif ($x =~ /([^\{]*)/) {
1758	$prototype .= $1;
1759    }
1760    if (($x =~ /\{/) || ($x =~ /\#define/) || ($x =~ /;/)) {
1761	$prototype =~ s@/\*.*?\*/@@gos;	# strip comments.
1762	$prototype =~ s@[\r\n]+@ @gos; # strip newlines/cr's.
1763	$prototype =~ s@^\s+@@gos; # strip leading spaces
1764	dump_function($prototype,$file);
1765	reset_state();
1766    }
1767}
1768
1769sub process_state3_type($$) {
1770    my $x = shift;
1771    my $file = shift;
1772
1773    $x =~ s@[\r\n]+@ @gos; # strip newlines/cr's.
1774    $x =~ s@^\s+@@gos; # strip leading spaces
1775    $x =~ s@\s+$@@gos; # strip trailing spaces
1776    $x =~ s@\/\/.*$@@gos; # strip C99-style comments to end of line
1777
1778    if ($x =~ /^#/) {
1779	# To distinguish preprocessor directive from regular declaration later.
1780	$x .= ";";
1781    }
1782
1783    while (1) {
1784	if ( $x =~ /([^{};]*)([{};])(.*)/ ) {
1785	    $prototype .= $1 . $2;
1786	    ($2 eq '{') && $brcount++;
1787	    ($2 eq '}') && $brcount--;
1788	    if (($2 eq ';') && ($brcount == 0)) {
1789		dump_declaration($prototype,$file);
1790		reset_state();
1791		last;
1792	    }
1793	    $x = $3;
1794	} else {
1795	    $prototype .= $x;
1796	    last;
1797	}
1798    }
1799}
1800
1801# xml_escape: replace <, >, and & in the text stream;
1802#
1803# however, formatting controls that are generated internally/locally in the
1804# kernel-doc script are not escaped here; instead, they begin life like
1805# $blankline_html (4 of '\' followed by a mnemonic + ':'), then these strings
1806# are converted to their mnemonic-expected output, without the 4 * '\' & ':',
1807# just before actual output; (this is done by local_unescape())
1808sub xml_escape($) {
1809	my $text = shift;
1810	if (($output_mode eq "text") || ($output_mode eq "man")) {
1811		return $text;
1812	}
1813	$text =~ s/\&/\\\\\\amp;/g;
1814	$text =~ s/\</\\\\\\lt;/g;
1815	$text =~ s/\>/\\\\\\gt;/g;
1816	return $text;
1817}
1818
1819# convert local escape strings to html
1820# local escape strings look like:  '\\\\menmonic:' (that's 4 backslashes)
1821sub local_unescape($) {
1822	my $text = shift;
1823	if (($output_mode eq "text") || ($output_mode eq "man")) {
1824		return $text;
1825	}
1826	$text =~ s/\\\\\\\\lt:/</g;
1827	$text =~ s/\\\\\\\\gt:/>/g;
1828	return $text;
1829}
1830
1831sub process_file($) {
1832    my $file;
1833    my $identifier;
1834    my $func;
1835    my $descr;
1836    my $initial_section_counter = $section_counter;
1837
1838    if (defined($ENV{'SRCTREE'})) {
1839	$file = "$ENV{'SRCTREE'}" . "/" . "@_";
1840    }
1841    else {
1842	$file = "@_";
1843    }
1844    if (defined($source_map{$file})) {
1845	$file = $source_map{$file};
1846    }
1847
1848    if (!open(IN,"<$file")) {
1849	print STDERR "Error: Cannot open file $file\n";
1850	++$errors;
1851	return;
1852    }
1853
1854    $section_counter = 0;
1855    while (<IN>) {
1856	if ($state == 0) {
1857	    if (/$doc_start/o) {
1858		$state = 1;		# next line is always the function name
1859		$in_doc_sect = 0;
1860	    }
1861	} elsif ($state == 1) {	# this line is the function name (always)
1862	    if (/$doc_block/o) {
1863		$state = 4;
1864		$contents = "";
1865		if ( $1 eq "" ) {
1866			$section = $section_intro;
1867		} else {
1868			$section = $1;
1869		}
1870	    }
1871	    elsif (/$doc_decl/o) {
1872		$identifier = $1;
1873		if (/\s*([\w\s]+?)\s*-/) {
1874		    $identifier = $1;
1875		}
1876
1877		$state = 2;
1878		if (/-(.*)/) {
1879		    # strip leading/trailing/multiple spaces
1880		    $descr= $1;
1881		    $descr =~ s/^\s*//;
1882		    $descr =~ s/\s*$//;
1883		    $descr =~ s/\s+/ /;
1884		    $declaration_purpose = xml_escape($descr);
1885		} else {
1886		    $declaration_purpose = "";
1887		}
1888
1889		if (($declaration_purpose eq "") && $verbose) {
1890			print STDERR "Warning(${file}:$.): missing initial short description on line:\n";
1891			print STDERR $_;
1892			++$warnings;
1893		}
1894
1895		if ($identifier =~ m/^struct/) {
1896		    $decl_type = 'struct';
1897		} elsif ($identifier =~ m/^union/) {
1898		    $decl_type = 'union';
1899		} elsif ($identifier =~ m/^enum/) {
1900		    $decl_type = 'enum';
1901		} elsif ($identifier =~ m/^typedef/) {
1902		    $decl_type = 'typedef';
1903		} else {
1904		    $decl_type = 'function';
1905		}
1906
1907		if ($verbose) {
1908		    print STDERR "Info(${file}:$.): Scanning doc for $identifier\n";
1909		}
1910	    } else {
1911		print STDERR "Warning(${file}:$.): Cannot understand $_ on line $.",
1912		" - I thought it was a doc line\n";
1913		++$warnings;
1914		$state = 0;
1915	    }
1916	} elsif ($state == 2) {	# look for head: lines, and include content
1917	    if (/$doc_sect/o) {
1918		$newsection = $1;
1919		$newcontents = $2;
1920
1921		if (($contents ne "") && ($contents ne "\n")) {
1922		    if (!$in_doc_sect && $verbose) {
1923			print STDERR "Warning(${file}:$.): contents before sections\n";
1924			++$warnings;
1925		    }
1926		    dump_section($section, xml_escape($contents));
1927		    $section = $section_default;
1928		}
1929
1930		$in_doc_sect = 1;
1931		$contents = $newcontents;
1932		if ($contents ne "") {
1933		    while ((substr($contents, 0, 1) eq " ") ||
1934			substr($contents, 0, 1) eq "\t") {
1935			    $contents = substr($contents, 1);
1936		    }
1937		    $contents .= "\n";
1938		}
1939		$section = $newsection;
1940	    } elsif (/$doc_end/) {
1941
1942		if ($contents ne "") {
1943		    dump_section($section, xml_escape($contents));
1944		    $section = $section_default;
1945		    $contents = "";
1946		}
1947
1948		$prototype = "";
1949		$state = 3;
1950		$brcount = 0;
1951#		print STDERR "end of doc comment, looking for prototype\n";
1952	    } elsif (/$doc_content/) {
1953		# miguel-style comment kludge, look for blank lines after
1954		# @parameter line to signify start of description
1955		if ($1 eq "" &&
1956			($section =~ m/^@/ || $section eq $section_context)) {
1957		    dump_section($section, xml_escape($contents));
1958		    $section = $section_default;
1959		    $contents = "";
1960		} else {
1961		    $contents .= $1."\n";
1962		}
1963	    } else {
1964		# i dont know - bad line?  ignore.
1965		print STDERR "Warning(${file}:$.): bad line: $_";
1966		++$warnings;
1967	    }
1968	} elsif ($state == 3) {	# scanning for function '{' (end of prototype)
1969	    if ($decl_type eq 'function') {
1970		process_state3_function($_, $file);
1971	    } else {
1972		process_state3_type($_, $file);
1973	    }
1974	} elsif ($state == 4) {
1975		# Documentation block
1976		if (/$doc_block/) {
1977			dump_doc_section($section, xml_escape($contents));
1978			$contents = "";
1979			$function = "";
1980			%constants = ();
1981			%parameterdescs = ();
1982			%parametertypes = ();
1983			@parameterlist = ();
1984			%sections = ();
1985			@sectionlist = ();
1986			$prototype = "";
1987			if ( $1 eq "" ) {
1988				$section = $section_intro;
1989			} else {
1990				$section = $1;
1991			}
1992		}
1993		elsif (/$doc_end/)
1994		{
1995			dump_doc_section($section, xml_escape($contents));
1996			$contents = "";
1997			$function = "";
1998			%constants = ();
1999			%parameterdescs = ();
2000			%parametertypes = ();
2001			@parameterlist = ();
2002			%sections = ();
2003			@sectionlist = ();
2004			$prototype = "";
2005			$state = 0;
2006		}
2007		elsif (/$doc_content/)
2008		{
2009			if ( $1 eq "" )
2010			{
2011				$contents .= $blankline;
2012			}
2013			else
2014			{
2015				$contents .= $1 . "\n";
2016			}
2017		}
2018	}
2019    }
2020    if ($initial_section_counter == $section_counter) {
2021	print STDERR "Warning(${file}): no structured comments found\n";
2022	if ($output_mode eq "xml") {
2023	    # The template wants at least one RefEntry here; make one.
2024	    print "<refentry>\n";
2025	    print " <refnamediv>\n";
2026	    print "  <refname>\n";
2027	    print "   ${file}\n";
2028	    print "  </refname>\n";
2029	    print "  <refpurpose>\n";
2030	    print "   Document generation inconsistency\n";
2031	    print "  </refpurpose>\n";
2032	    print " </refnamediv>\n";
2033	    print " <refsect1>\n";
2034	    print "  <title>\n";
2035	    print "   Oops\n";
2036	    print "  </title>\n";
2037	    print "  <warning>\n";
2038	    print "   <para>\n";
2039	    print "    The template for this document tried to insert\n";
2040	    print "    the structured comment from the file\n";
2041	    print "    <filename>${file}</filename> at this point,\n";
2042	    print "    but none was found.\n";
2043	    print "    This dummy section is inserted to allow\n";
2044	    print "    generation to continue.\n";
2045	    print "   </para>\n";
2046	    print "  </warning>\n";
2047	    print " </refsect1>\n";
2048	    print "</refentry>\n";
2049	}
2050    }
2051}
2052