Don't use fixed path for perl.
[gedcom-parse.git] / doc / make_gom_xref
1 # $Id$
2 # $Name$
3
4 use strict;
5 use diagnostics;
6
7 my $inputfile ="$ENV{srcdir}/../include/gom.h";
8 my $outputfile ="gomxref.html";
9 my $ext_link = "interface.html";
10 my $generated = "";
11
12 my $main_structs = "";
13 my $sub_structs="";
14 my $index = "";
15 my $section = "";
16
17 open INPUT, $inputfile or die "Can't read $inputfile\n";
18 open OUTPUT, ">$outputfile" or die "Can't read $outputfile\n";
19
20 while (<INPUT>)
21 {
22   $section = "sub"  if m|/\* Sub-structures \*/|;
23   $section = "main" if m|/\* Main structures \*/|;
24   $section = ""     if m|/\* Functions \*/|;
25   $generated = $1   if m|/\* [\$]Id: (.*?) \$ \*/|;
26   next if m|/\*|;
27
28   if ($section ne "") {
29     if (m|^struct (.*) \{|) {
30       s|^struct (.*?) \{|<a name="$1"><B>struct $1</B></a> \{|;
31       if ($section eq "main") {
32         $index .= "  <LI><a href=\"#$1\">struct $1</a><br>\n";
33       }
34     }
35     elsif (m|struct (.*?) \*|) {
36       my $link = "";
37       my $structname = $1;
38       if ($structname =~ /^(date|age|xref)_value$/) {
39         $link = $ext_link;
40       }
41       s|struct (.*?) \*|<a href="$link#$1">struct $1</a> \*|;
42     }
43     
44     if ($section eq "sub") {
45       $sub_structs .= "$_";
46     }
47     else {
48       $main_structs .= "$_";
49     }
50   }
51 }
52
53 print OUTPUT <<"END_OF_HTML";
54 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 FINAL//EN">
55 <html>
56 <head>
57   <title>Gedcom object model in C</title>
58 </head>
59 <body bgcolor="White">
60   
61 <h1 align="center">Gedcom object model in C</h1>
62 This page provides a cross-reference of all objects in the Gedcom object
63 model for C.  The following links are fast links to the main structures
64 in the Gedcom object model:
65
66 <UL>
67 $index
68 </UL>
69 <HR>
70
71 <h2>Main structures</h2>
72 <CODE><PRE>
73 $main_structs
74 </PRE></CODE>
75 <HR>
76
77 <h2>Sub-structures</h2>
78 <CODE><PRE>
79 $sub_structs
80 </PRE></CODE>
81 <HR>
82
83 <SMALL>Generated from: $generated</SMALL>
84 </body>
85 </html>
86 END_OF_HTML
87     
88 close OUTPUT;
89 close INPUT;