kernel-doc 50 KB

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