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