Add call to gedcom_init().
[gedcom-parse.git] / doc / usage.html
index 00003be0d0b4484dd762b1c4b4e7c0b174d1065f..409ebbf308878bf17f0b2726ade6faf57a8eedb3 100644 (file)
         <li><a href="#Error_treatment">Error treatment</a></li>
         <li><a href="#Compatibility_mode">Compatibility mode</a></li>
                
-  </ul><li><a href="#Converting_character_sets">Converting character sets</a><br>
+  </ul><li><a href="#Converting_character_sets">Converting character sets</a></li><li><a href="#Support_for_configure.in">Support for configure.in</a><br>
   </li>
 
+
       <li><a href="interface.html">Interface details</a><br>
          </li>
          
@@ -452,7 +453,43 @@ All strings passed by the GEDCOM parser to the application are in UTF-8 encoding
 be able to display it.<br>
                     <br>
 The most common case is that the output character set is controlled by the <code>locale</code> mechanism (i.e. via the <code>LANG</code>, <code>LC_ALL</code> or <code>LC_CTYPE</code> environment variables), which also controls the <code>gettext</code>
- mechanism in the application. &nbsp;For this, the following steps need to
+ mechanism in the application. &nbsp;<br>
+                    <br>
+                    <br>
+
+
+                                                                        
+              
+                    The source distribution of <code>gedcom-parse</code> contains an example implementation (<code>utf8-locale.c</code> and <code>utf8-locale.h</code>
+ in the top directory).&nbsp; &nbsp;Feel free to use it in
+your source code (it is not part of the library, and it isn't installed anywhere,
+so you need to take over the source and header file in your application).
+&nbsp;<br>
+                    <br>
+
+Its interface is:<br>
+                    <blockquote><pre><code>char *<b>convert_utf8_to_locale</b> (char *input, int *conv_failures);<br>char *<b>convert_locale_to_utf8</b> (char *input);<br></code></pre></blockquote>
+
+Both functions return a pointer to a static buffer that is overwritten on
+each call. &nbsp;To function properly, the application must first set the
+locale using the <code>setlocale</code> function (the second step detailed below).
+&nbsp;All other steps given below, including setting up and closing down the conversion
+handles, are transparantly handled by the two functions. &nbsp;<br>
+                      <br>
+If you pass a pointer to an integer to the first function, it will be set
+to the number of conversion failures, i.e. characters that couldn't be converted;
+you can also just pass <code>NULL</code> if you are not interested (note that usually, the interesting information is just whether there <i>were</i>
+ conversion failures or not, which is then given by the integer being bigger
+than zero or not). &nbsp;The second function doesn't need this, because any
+locale can be converted to UTF-8.<br>
+                      <br>
+
+You can change the "?" that is output for characters that can't be converted
+to any string you want, using the following function before the conversion
+calls:<br>
+                      <blockquote><pre><code>void <b>convert_set_unknown</b> (const char *unknown);</code></pre></blockquote>
+                        <br>
+If you want to have your own functions for it instead of this example 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">here</a>):<br>
@@ -527,33 +564,48 @@ characters can't be represented in the target character set). &nbsp;The <code>ic
                                           <pre><code>iconv_close(iconv_handle);<br></code></pre>
                                           </blockquote>
                                           </blockquote>
+                                               The example implementation
+mentioned above grows the output buffer dynamically and outputs "?" for characters
+that can't be converted.<br>
+                                              
+                                              <hr width="100%" size="2">
+                                              <h2><a name="Support_for_configure.in"></a>Support for configure.in</h2>
+Programs using the GEDCOM parser library and using autoconf to configure
+their sources can use the following statements in configure.in (the example
+is checking for gedcom-parse, version 1.34):<br>
+                                              <blockquote><code>AC_CHECK_LIB(gedcom, gedcom_parse_file,,<br>
+&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AC_MSG_ERROR(Cannot find libgedcom: Please install gedcom-parse))<br>
+AC_MSG_CHECKING(for libgedcom version)<br>
+AC_TRY_RUN([<br>
+#include &lt;stdio.h&gt;<br>
+#include &lt;stdlib.h&gt;<br>
+#include &lt;gedcom.h&gt;<br>
+int<br>
+main()<br>
+{<br>
+if (GEDCOM_PARSE_VERSION &gt;= 1034) exit(0);<br>
+exit(1);<br>
+}],<br>
+ac_gedcom_version_ok='yes',<br>
+ac_gedcom_version_ok='no',<br>
+ac_gedcom_version_ok='no')<br>
+if test "$ac_gedcom_version_ok" = 'yes' ; then<br>
+&nbsp; AC_MSG_RESULT(ok)<br>
+else<br>
+&nbsp; AC_MSG_RESULT(not ok)<br>
+&nbsp; AC_MSG_ERROR(You need at least version 1.34 of gedcom-parse)<br>
+fi</code><br>
+                                                </blockquote>
 
-                                                                        
-              
-                    The source distribution of <code>gedcom-parse</code> contains an example implementation (<code>utf8-locale.c</code> and <code>utf8-locale.h</code>
- in the top directory) that grows the output buffer dynamically and outputs
-"?" for characters that can't be converted. &nbsp;Feel free to use it in
-your source code (it is not part of the library, and it isn't installed anywhere,
-so you need to take over the source and header file in your application).
-&nbsp;<br>
-                                          <br>
-Its interface is:<br>
-                                          <blockquote>
-                                            <pre><code>char *<b>convert_utf8_to_locale</b> (char *input);<br>char *<b>convert_locale_to_utf8</b> (char *input);<br></code></pre>
-                                            </blockquote>
-Both functions return a pointer to a static buffer that is overwritten on
-each call. &nbsp;To function properly, the application must first set the
-locale using the <code>setlocale</code> function (the second step above).
-&nbsp;All other steps, including setting up and closing down the conversion
-handles, are transparantly handled by the two functions.<br>
-                                            <br>
-You can change the "?" that is output for characters that can't be converted
-to any string you want, using the following function before the conversion
-calls:<br>
-                                            <blockquote>
-                                              <pre><code>void <b>convert_set_unknown</b> (const char *unknown);</code></pre>
-                                              </blockquote>
-                                              <hr width="100%" size="2">                           
+There are three preprocessor symbols defined for version checks in the header:<br>
+                                                <ul>
+                                                  <li><code>GEDCOM_PARSE_VERSION_MAJOR</code></li>
+                                                  <li><code>GEDCOM_PARSE_VERSION_MINOR</code></li>
+                                                  <li><code>GEDCOM_PARSE_VERSION</code><br>
+                                                  </li>
+                                                </ul>
+The last one is equal to <code>(GEDCOM_PARSE_VERSION_MAJOR * 1000) + GEDCOM_PARSE_VERSION_MINOR.</code><br>
+<hr width="100%" size="2">                           
                                    
                     <pre><font size="-1">$Id$<br>$Name$</font><br></pre>