-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
- <title>Using the GEDCOM parser library</title>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>Using the GEDCOM parser library</title>
+
- <meta http-equiv="content-type"
- content="text/html; charset=ISO-8859-1">
-</head>
- <body text="#000000" bgcolor="#ffffff" link="#000099" vlink="#990099"
- alink="#000099">
+ <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"></head>
+
+<body text="#000000" bgcolor="#ffffff" link="#000099" vlink="#990099" alink="#000099">
<h1 align="center">Using the GEDCOM parser library</h1>
<br>
As a simple example, we will get some information from the header
of a GEDCOM file. First, have a look at the following piece of code:<br>
-<blockquote><code>Gedcom_ctxt <b>my_header_start_cb</b> (int level, <br>
+<blockquote><code>Gedcom_ctxt <b>my_header_start_cb</b> (Gedcom_rec rec,<br>
+ int level, <br>
Gedcom_val xref, <br>
return (Gedcom_ctxt)1;<br>
}<br>
<br>
- void <b>my_header_end_cb</b> (Gedcom_ctxt self)<br>
+ void <b>my_header_end_cb</b> (Gedcom_rec rec, Gedcom_ctxt self)<br>
{<br>
printf("The header ends, context is %d\n", (int)self);
/* context will print as "1" */<br>
if you are not interested in the end callback. The identifiers
to use as first argument to the function (here <code>REC_HEAD</code>)
are described in the <a href="interface.html#Record_identifiers"> interface
-details</a> .<br>
+details</a> . These are also passed as first argument in the callbacks (the <code>Gedcom_rec</code> argument).<br>
<br>
From the name of the function it becomes clear that this function
is specific to complete records. For the separate elements in records
We will now retrieve the SOUR field (the name of the program that
wrote the file) from the header:<br>
-<blockquote><code>Gedcom_ctxt <b>my_header_source_start_cb</b>(Gedcom_ctxt
+<blockquote><code>Gedcom_ctxt <b>my_header_source_start_cb</b>(Gedcom_elt elt,<br>
+
+ Gedcom_ctxt
parent,<br>
int
return parent;<br>
}<br>
<br>
- void <b>my_header_source_end_cb</b>(Gedcom_ctxt parent,<br>
+ void <b>my_header_source_end_cb</b>(Gedcom_elt elt,<br>
+ Gedcom_ctxt parent,<br>
Gedcom_ctxt self,<br>
can be its own context object of course. The end callback is called
with both the context of the parent and the context of itself, which in this
example will be the same. Again, the list of identifiers to use as
-a first argument for the subscription function are detailed in the <a
- href="interface.html#Element_identifiers"> interface details</a> .<br>
+a first argument for the subscription function are detailed in the <a href="interface.html#Element_identifiers"> interface details</a> . Again, these are passed as first argument in the callback (the <code>Gedcom_elt</code> argument).<br>
<br>
If we look at the other arguments of the start callback, we see the
level number (the initial number of the line in the GEDCOM file), the tag
The <code>Gedcom_val</code> type is meant to be an opaque type. The
only thing that needs to be known about it is that it can contain specific
data types, which have to be retrieved from it using pre-defined macros.
- These data types are described in the <a
- href="interface.html#Gedcom_val_types"> interface details</a>.
+ These data types are described in the <a href="interface.html#Gedcom_val_types"> interface details</a>.
<br>
<br>
Some extra notes:<br>
applications. To preserve this extra data anyway, a default callback
can be registered by the application, as in the following example:<br>
-<blockquote><code>void <b>my_default_cb</b> (Gedcom_ctxt parent, int level,
+<blockquote><code>void <b>my_default_cb</b> (Gedcom_elt elt, Gedcom_ctxt parent, int level,
char* tag, char* raw_value, int parsed_tag)<br>
{<br>
...<br>
char* extra_text;<br>
};<br>
<br>
- Gedcom_ctxt my_header_start_cb(int level, Gedcom_val xref, char* tag,
+ Gedcom_ctxt my_header_start_cb(Gedcom_rec rec, int level, Gedcom_val xref, char* tag,
char *raw_value,<br>
int parsed_tag, Gedcom_val parsed_value)<br>
return (Gedcom_ctxt)head;<br>
}<br>
<br>
- void my_default_cb(Gedcom_ctxt parent, int level, char* tag, char*
+ void my_default_cb(Gedcom_elt elt, Gedcom_ctxt parent, int level, char* tag, char*
raw_value, int parsed_tag)<br>
{<br>
struct header head = (struct header)parent;<br>
implementation, the following steps need to be taken by the application
(more detailed info can be found in the info file of the GNU libc library
in the "Generic Charset Conversion" section under "Character Set Handling"
-or online <a
- href="http://www.gnu.org/manual/glibc-2.2.3/html_chapter/libc_6.html#SEC99">
+or online <a href="http://www.gnu.org/manual/glibc-2.2.3/html_chapter/libc_6.html#SEC99">
here</a>):<br>
<ul>
<li>Skip over the character that
can't be converted and append a "?" to the output buffer, then call <code>
iconv</code> again. Skipping over a UTF-8 character is fairly simple,
- as follows from the <a
- href="http://www.cl.cam.ac.uk/%7Emgk25/unicode.html#utf-8">encoding rules</a>
+ as follows from the <a href="http://www.cl.cam.ac.uk/%7Emgk25/unicode.html#utf-8">encoding rules</a>
:</li>
</ul>
<pre> </pre>
-</body>
-</html>
+<br>
+</body></html>
\ No newline at end of file