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