Extracted GOM details to a new file.
[gedcom-parse.git] / doc / make_gom_xref
1 # $Id$
2 # $Name$
3
4 use strict;
5 use diagnostics;
6
7 my $gedcom_ref_doc="http://www.gendex.com/gedcom55/55gcch2.htm";
8 my $inputfile ="$ENV{srcdir}/../include/gom.h";
9 my $outputfile ="gomxref.html";
10 my $ext_link = "interface.html";
11 my $generated = "";
12
13 my $main_structs = "";
14 my $sub_structs="";
15 my $index = "";
16 my $section = "";
17
18 open INPUT, $inputfile or die "Can't read $inputfile\n";
19 open OUTPUT, ">$outputfile" or die "Can't read $outputfile\n";
20
21 sub gedcom_link {
22   my ($sublink) = @_;
23   return "(<A href=\"javascript:popup_gedcom('$sublink')\">?</A>)";
24 }
25
26 while (<INPUT>)
27 {
28   my $gedc_ref = "";
29   $section = "sub"  if m|^/\* Sub-structures \*/|;
30   $section = "main" if m|^/\* Main structures \*/|;
31   $section = ""     if m|^/\* Functions \*/|;
32   $generated = $1   if m|^/\* [\$]Id: (.*?) \$ \*/|;
33   next if m|^/\*|;
34
35   if ($section ne "") {
36     chomp;
37     if (s|\s*/\* (.*?) \*/\s*$||) {
38       $gedc_ref = $1;
39     }
40     if (m|^struct (.*) \{|) {
41       s|^struct (.*?) \{|<a name="$1"><B>struct $1</B></a> \{|;
42       if ($section eq "main") {
43         $index .= "  <LI><a href=\"#$1\">struct $1</a><br>\n";
44       }
45     }
46     elsif (m|struct (.*?) \*|) {
47       my $link = "";
48       my $structname = $1;
49       if ($structname =~ /^(date|age|xref)_value$/) {
50         $link = $ext_link;
51       }
52       s|struct (.*?) \*|<a href="$link#$1">struct $1</a> \*|;
53     }
54     
55     if ($section eq "sub") {
56       $sub_structs .= "$_";
57       if ($gedc_ref) {
58         $sub_structs .= " " . gedcom_link($gedc_ref);
59       }
60       $sub_structs .= "\n";
61     }
62     else {
63       $main_structs .= "$_";
64       if ($gedc_ref) {
65         $main_structs .= " " . gedcom_link($gedc_ref);
66       }
67       $main_structs .= "\n";
68     }
69   }
70 }
71
72 print OUTPUT <<"END_OF_HTML";
73 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 FINAL//EN">
74 <html>
75 <head>
76   <title>Gedcom object model in C</title>
77   <script language="JavaScript" type="text/javascript">
78   <!--
79     function popup_gedcom(sublink) {
80       Gedcom = window.open( '$gedcom_ref_doc' + '#' + sublink,
81                             'Gedcom reference',
82                             'scrollbars=yes,resizable=yes,toolbar=no,height=400, width=400');
83     }
84   // -->
85   </script>
86 </head>
87 <body bgcolor="White">
88   
89 <h1 align="center">Gedcom object model in C</h1>
90 This page provides a cross-reference of all objects in the Gedcom object
91 model for C.  The '(?)' links are links to the
92 <a href="http://www.gendex.com/gedcom55/55gctoc.htm">Gedcom standard</a>
93 giving the meaning of each field.
94 <P>
95 The following links are fast links to the
96 main structures in the Gedcom object model:
97
98 <UL>
99 $index
100 </UL>
101 <HR>
102
103 <h2>Main structures</h2>
104 <CODE><PRE>
105 $main_structs
106 </PRE></CODE>
107 <HR>
108
109 <h2>Sub-structures</h2>
110 <CODE><PRE>
111 $sub_structs
112 </PRE></CODE>
113 <HR>
114
115 <SMALL>Generated from: $generated</SMALL>
116 </body>
117 </html>
118 END_OF_HTML
119     
120 close OUTPUT;
121 close INPUT;