Blame doc/gpgrt.texi

Packit fc043f
\input texinfo                  @c -*- Texinfo -*-
Packit fc043f
@c %**start of header
Packit fc043f
@setfilename gpgrt.info
Packit fc043f
@include version.texi
Packit fc043f
@settitle The Libgpg-error Reference Manual
Packit fc043f
@c Unify some of the indices.
Packit fc043f
@syncodeindex tp fn
Packit fc043f
@syncodeindex pg fn
Packit fc043f
@c %**end of header
Packit fc043f
@copying
Packit fc043f
This manual is for Libgpg-error (version @value{VERSION},
Packit fc043f
@value{UPDATED}), which is a library for code used by all GnuPG
Packit fc043f
related packages.
Packit fc043f
Packit fc043f
@noindent
Packit fc043f
Copyright @copyright{} 2014 g10 Code GmbH
Packit fc043f
Packit fc043f
@quotation
Packit fc043f
Permission is granted to copy, distribute and/or modify this document
Packit fc043f
under the terms of the GNU General Public License as published by the
Packit fc043f
Free Software Foundation; either version 2 of the License, or (at your
Packit fc043f
option) any later version. The text of the license can be found in the
Packit fc043f
section entitled ``GNU General Public License''.
Packit fc043f
@end quotation
Packit fc043f
@end copying
Packit fc043f
Packit fc043f
@dircategory Libraries
Packit fc043f
@direntry
Packit fc043f
* libgpg-error: (gnupg).   Error codes and common code for GnuPG.
Packit fc043f
@end direntry
Packit fc043f
Packit fc043f
@c A couple of macros with no effect on texinfo
Packit fc043f
@c but used by the yat2m processor.
Packit fc043f
@macro manpage {a}
Packit fc043f
@end macro
Packit fc043f
@macro mansect {a}
Packit fc043f
@end macro
Packit fc043f
@macro manpause
Packit fc043f
@end macro
Packit fc043f
@macro mancont
Packit fc043f
@end macro
Packit fc043f
Packit fc043f
@c
Packit fc043f
@c Printing stuff taken from gcc.
Packit fc043f
@c
Packit fc043f
@macro gnupgtabopt{body}
Packit fc043f
@code{\body\}
Packit fc043f
@end macro
Packit fc043f
Packit fc043f
Packit fc043f
@c
Packit fc043f
@c Titlepage
Packit fc043f
@c
Packit fc043f
@setchapternewpage odd
Packit fc043f
@titlepage
Packit fc043f
@title The Libgpg-error Reference Manual
Packit fc043f
@subtitle Version @value{VERSION}
Packit fc043f
@subtitle @value{UPDATED}
Packit fc043f
@author Werner Koch (@email{wk@@gnupg.org})
Packit fc043f
Packit fc043f
@page
Packit fc043f
@vskip 0pt plus 1filll
Packit fc043f
@insertcopying
Packit fc043f
@end titlepage
Packit fc043f
Packit fc043f
@ifnothtml
Packit fc043f
@summarycontents
Packit fc043f
@contents
Packit fc043f
@page
Packit fc043f
@end ifnothtml
Packit fc043f
Packit fc043f
Packit fc043f
@ifnottex
Packit fc043f
@node Top
Packit fc043f
@top The Libgpg-error Library
Packit fc043f
@insertcopying
Packit fc043f
@end ifnottex
Packit fc043f
Packit fc043f
Packit fc043f
@menu
Packit fc043f
* Introduction::                 What is Libgpg-error.
Packit fc043f
* Preparation::                  What you should do before using the library.
Packit fc043f
* Generalities::                 General library functions and data types.
Packit fc043f
* Tools::                        Utility tools
Packit fc043f
Packit fc043f
Appendices
Packit fc043f
Packit fc043f
* Library Copying::             The GNU Lesser General Public License
Packit fc043f
                                says how you can copy and share Libgpg-error.
Packit fc043f
* Copying::                     The GNU General Public License says how you
Packit fc043f
                                can copy and share some parts of Libgpg-error.
Packit fc043f
Packit fc043f
Indices
Packit fc043f
Packit fc043f
@c * Figures and Tables::          Index of figures and tables.
Packit fc043f
* Concept Index::               Index of concepts and programs.
Packit fc043f
* Function and Data Index::     Index of functions, variables and data types.
Packit fc043f
Packit fc043f
@end menu
Packit fc043f
Packit fc043f
@ifhtml
Packit fc043f
@page
Packit fc043f
@summarycontents
Packit fc043f
@contents
Packit fc043f
@end ifhtml
Packit fc043f
Packit fc043f
Packit fc043f
@c **********************************************************
Packit fc043f
@c *******************  Introduction  ***********************
Packit fc043f
@c **********************************************************
Packit fc043f
@node Introduction
Packit fc043f
@chapter Introduction
Packit fc043f
Packit fc043f
Libgpg-error is a library to provide error codes for GnuPG and relates
Packit fc043f
software as well as some other general purpose functions.  It is
Packit fc043f
planned to eventually rename this library to ``gpgrt'' (for GnuPG
Packit fc043f
RunTime).
Packit fc043f
Packit fc043f
@menu
Packit fc043f
* Getting Started::             How to use this manual.
Packit fc043f
* Features::                    A glance at Libgpg-error’s features.
Packit fc043f
* Overview::                    Overview about the library.
Packit fc043f
@end menu
Packit fc043f
Packit fc043f
@node Getting Started
Packit fc043f
@section Getting Started
Packit fc043f
Packit fc043f
This manual documents the Libgpg-error library application programming
Packit fc043f
interface (API).  The goal is to that all functions and data types
Packit fc043f
provided by the library are explained.  However, for now this is only
Packit fc043f
a stub and not very useful.
Packit fc043f
Packit fc043f
Packit fc043f
@node Features
Packit fc043f
@section Features
Packit fc043f
Packit fc043f
TBD
Packit fc043f
Packit fc043f
@node Overview
Packit fc043f
@section Overview
Packit fc043f
Packit fc043f
@noindent
Packit fc043f
The Libgpg-error library is fully thread-safe, where it makes
Packit fc043f
sense to be thread-safe.
Packit fc043f
Packit fc043f
TBD
Packit fc043f
Packit fc043f
@c **********************************************************
Packit fc043f
@c *******************  Preparation  ************************
Packit fc043f
@c **********************************************************
Packit fc043f
@node Preparation
Packit fc043f
@chapter Preparation
Packit fc043f
Packit fc043f
To use Libgpg-error, you have to perform some changes to your
Packit fc043f
sources and the build system.  The necessary changes are small and
Packit fc043f
explained in the following sections.  At the end of this chapter, it
Packit fc043f
is described how the library is initialized, and how the requirements
Packit fc043f
of the library are verified.
Packit fc043f
Packit fc043f
@menu
Packit fc043f
* Header::                      What header file you need to include.
Packit fc043f
* Building sources::            How to build sources using the library.
Packit fc043f
* Building sources using Automake::  How to build sources with the help of Automake.
Packit fc043f
* Initializing the library::    How to initialize the library.
Packit fc043f
* Multi-Threading::             How Libgpg-error can be used in a MT environment.
Packit fc043f
@end menu
Packit fc043f
Packit fc043f
Packit fc043f
@node Header
Packit fc043f
@section Header
Packit fc043f
Packit fc043f
All interfaces (data types and functions) of the library are defined
Packit fc043f
in the header file @file{libgpg-error.h}.  You must include this in all source
Packit fc043f
files using the library, either directly or through some other header
Packit fc043f
file, like this:
Packit fc043f
Packit fc043f
@example
Packit fc043f
#include <libgpg-error.h>
Packit fc043f
@end example
Packit fc043f
Packit fc043f
Note well that the header file is platform specific and may only be
Packit fc043f
used on the platform for which it has been build.
Packit fc043f
Packit fc043f
The name space of Libgpg-error is @code{gpg_*} and @code{gpgrt*}
Packit fc043f
for function and type names and @code{GPG_*} and @code{GPGRT_*}
Packit fc043f
for other symbols.  In addition the same name prefixes with one
Packit fc043f
prepended underscore are reserved for internal use and should never be
Packit fc043f
used by an application.
Packit fc043f
Packit fc043f
@noindent
Packit fc043f
Certain parts of gpg-error.h may be included by defining these macros:
Packit fc043f
Packit fc043f
@table @code
Packit fc043f
@item GPG_ERR_ENABLE_GETTEXT_MACROS
Packit fc043f
Define to provide macros to map the internal gettext API to standard
Packit fc043f
names.  This has only an effect on Windows platforms.
Packit fc043f
Packit fc043f
@item GPGRT_ENABLE_ES_MACROS
Packit fc043f
Define to provide "es_" macros for the estream functions.
Packit fc043f
@end table
Packit fc043f
Packit fc043f
@node Building sources
Packit fc043f
@section Building sources
Packit fc043f
Packit fc043f
If you want to compile a source file including the `gpg-error.h' header
Packit fc043f
file, you must make sure that the compiler can find it in the
Packit fc043f
directory hierarchy.  This is accomplished by adding the path to the
Packit fc043f
directory in which the header file is located to the compilers include
Packit fc043f
file search path (via the @option{-I} option).
Packit fc043f
Packit fc043f
However, the path to the include file is determined at the time the
Packit fc043f
source is configured.  To solve this problem, Libgpg-error ships with
Packit fc043f
the small helper programs @command{gpg-error-config} and
Packit fc043f
@command{gpgrt-config} which both know the path to the include file
Packit fc043f
and other configuration options.  The options that need to be added to
Packit fc043f
the compiler invocation at compile time are output by the
Packit fc043f
@option{--cflags} option to @command{gpg-error-config} (or
Packit fc043f
@command{gpgrt-config}.  The following example shows how it can be
Packit fc043f
used at the command line:
Packit fc043f
Packit fc043f
@example
Packit fc043f
gcc -c foo.c $(gpg-error-config --cflags)
Packit fc043f
@end example
Packit fc043f
Packit fc043f
or with the identical
Packit fc043f
Packit fc043f
@example
Packit fc043f
gcc -c foo.c $(gpgrt-config --cflags)
Packit fc043f
@end example
Packit fc043f
Packit fc043f
Adding the output of @samp{gpg-error-config --cflags} to the
Packit fc043f
compiler’s command line will ensure that the compiler can find the
Packit fc043f
Libgpg-error header file.
Packit fc043f
Packit fc043f
A similar problem occurs when linking the program with the library.
Packit fc043f
Again, the compiler has to find the library files.  For this to work,
Packit fc043f
the path to the library files has to be added to the library search
Packit fc043f
path (via the @option{-L} option).  For this, the option
Packit fc043f
@option{--libs} to @command{gpg-error-config} can be used.  The
Packit fc043f
example shows how to link @file{foo.o} with the Libgpg-error library
Packit fc043f
to a program @command{foo}.
Packit fc043f
Packit fc043f
@example
Packit fc043f
gcc -o foo foo.o $(gpg-error-config --libs)
Packit fc043f
@end example
Packit fc043f
Packit fc043f
Of course you can also combine both examples to a single command by
Packit fc043f
specifying both options to @command{gpg-error-config}:
Packit fc043f
Packit fc043f
@example
Packit fc043f
gcc -o foo foo.c $(gpg-error-config --cflags --libs)
Packit fc043f
@end example
Packit fc043f
Packit fc043f
@node Building sources using Automake
Packit fc043f
@section Building sources using Automake
Packit fc043f
Packit fc043f
It is much easier if you use GNU Automake instead of writing your own
Packit fc043f
Makefiles.  If you do that, you do not have to worry about finding and
Packit fc043f
invoking the @command{gpg-error-config} script at all.  Libgpg-error
Packit fc043f
provides an extension to Automake that does all the work for you.
Packit fc043f
Packit fc043f
@c A simple macro for optional variables.
Packit fc043f
@macro ovar{varname}
Packit fc043f
@r{[}@var{\varname\}@r{]}
Packit fc043f
@end macro
Packit fc043f
@defmac AM_PATH_GPG_ERROR (@ovar{minimum-version}, @ovar{action-if-found}, @ovar{action-if-not-found})
Packit fc043f
Check whether Libgpg-error (at least version @var{minimum-version}, if
Packit fc043f
given) exists on the host system.  If it is found, execute
Packit fc043f
@var{action-if-found}, otherwise do @var{action-if-not-found}, if
Packit fc043f
given.
Packit fc043f
Packit fc043f
Additionally, the function defines @code{GPG_ERROR_CFLAGS} to the
Packit fc043f
flags needed for compilation of the program to find the
Packit fc043f
@file{gpg-error.h} header file, and @code{GPG_ERROR_LIBS} to the
Packit fc043f
linker flags needed to link the program to the Libgpg-error library.  If
Packit fc043f
the used helper script does not match the target type you are building
Packit fc043f
for a warning is printed and the string @code{libgpg-error} is
Packit fc043f
appended to the variable @code{gpg_config_script_warn}.
Packit fc043f
Packit fc043f
This macro searches for @command{gpg-error-config} along the PATH.  If
Packit fc043f
you are cross-compiling, it is useful to set the environment variable
Packit fc043f
@code{SYSROOT} to the top directory of your target.  The macro will
Packit fc043f
then first look for the helper program in the @file{bin} directory
Packit fc043f
below that top directory.  An absolute directory name must be used for
Packit fc043f
@code{SYSROOT}.  Finally, if the configure command line option
Packit fc043f
@code{--with-libgpg-error-prefix} is used, only its value is used for
Packit fc043f
the top directory below which the helper script is expected.
Packit fc043f
Packit fc043f
@end defmac
Packit fc043f
Packit fc043f
You can use the defined Autoconf variables like this in your
Packit fc043f
@file{Makefile.am}:
Packit fc043f
Packit fc043f
@example
Packit fc043f
AM_CPPFLAGS = $(GPG_ERROR_CFLAGS)
Packit fc043f
LDADD = $(GPG_ERROR_LIBS)
Packit fc043f
@end example
Packit fc043f
Packit fc043f
@node Initializing the library
Packit fc043f
@section Initializing the library
Packit fc043f
Packit fc043f
Before the library can be used, it should initialize itself.  This is
Packit fc043f
achieved by invoking the function @code{gpgrt_check_version} described
Packit fc043f
below.
Packit fc043f
Packit fc043f
Also, it is often desirable to check that the version of
Packit fc043f
Libgpg-error used is indeed one which fits all requirements.
Packit fc043f
Even with binary compatibility, new features may have been introduced,
Packit fc043f
but due to problem with the dynamic linker an old version may actually
Packit fc043f
be used.  So you may want to check that the version is okay right
Packit fc043f
after program startup.
Packit fc043f
Packit fc043f
@deftypefun {const char *} gpgrt_check_version (const char *@var{req_version})
Packit fc043f
Packit fc043f
The function @code{gpgrt_check_version} initializes some subsystems used
Packit fc043f
by Libgpg-error and must be invoked before any other function in the
Packit fc043f
library.
Packit fc043f
@xref{Multi-Threading}.
Packit fc043f
Packit fc043f
Furthermore, this function returns the version number of the library.
Packit fc043f
It can also verify that the version number is higher than a certain
Packit fc043f
required version number @var{req_version}, if this value is not a null
Packit fc043f
pointer.
Packit fc043f
@end deftypefun
Packit fc043f
Packit fc043f
Packit fc043f
@node Multi-Threading
Packit fc043f
@section Multi-Threading
Packit fc043f
Packit fc043f
TBD.
Packit fc043f
Packit fc043f
@c **********************************************************
Packit fc043f
@c *******************  General  ****************************
Packit fc043f
@c **********************************************************
Packit fc043f
@node Generalities
Packit fc043f
@chapter Generalities
Packit fc043f
Packit fc043f
TBD.  (Description of the error function may be taken from Libgcrypt.)
Packit fc043f
Packit fc043f
Packit fc043f
Packit fc043f
@c **********************************************************
Packit fc043f
@c *********************  Tools  ****************************
Packit fc043f
@c **********************************************************
Packit fc043f
@node Tools
Packit fc043f
@chapter Tools
Packit fc043f
Packit fc043f
@menu
Packit fc043f
* gpg-error-config::    Print required compiler flags
Packit fc043f
@end menu
Packit fc043f
Packit fc043f
@c The original version of this man page has been written for Debian and was
Packit fc043f
@c contributed to libgpg-error by Daniel Kahn Gillmor <dkg@fifthhorseman.net>.
Packit fc043f
@manpage gpg-error-config.1
Packit fc043f
@node gpg-error-config
Packit fc043f
@section Print required compiler flags
Packit fc043f
@ifset manverb
Packit fc043f
.B gpg-error-config
Packit fc043f
\- Script to get information about the installed version of libgpg-error
Packit fc043f
@end ifset
Packit fc043f
Packit fc043f
@mansect synopsis
Packit fc043f
@ifset manverb
Packit fc043f
.B  gpg-error-config
Packit fc043f
.RI [ options ]
Packit fc043f
@end ifset
Packit fc043f
Packit fc043f
@mansect description
Packit fc043f
@command{gpg-error-config} is a tool that is used to configure to
Packit fc043f
determine the compiler and linker flags that should be used to compile
Packit fc043f
and link programs that use Libgpg-error. It is also used
Packit fc043f
internally to the @code{.m4} macros for GNU autoconf that are included
Packit fc043f
with Libgpg-error.
Packit fc043f
Packit fc043f
@mansect options
Packit fc043f
@noindent
Packit fc043f
@command{gpg-error-config} accepts the following options:
Packit fc043f
Packit fc043f
@table @gnupgtabopt
Packit fc043f
Packit fc043f
@item  --mt
Packit fc043f
Provide output appropriate for multithreaded programs.  @option{--mt}
Packit fc043f
is only useful when combined with other options, and must be the first
Packit fc043f
option if present.
Packit fc043f
Packit fc043f
@item --version
Packit fc043f
Print the currently installed version of Libgpg-error on the
Packit fc043f
standard output.
Packit fc043f
Packit fc043f
@item --libs
Packit fc043f
Print the linker flags that are necessary to link a program using
Packit fc043f
Libgpg-error.
Packit fc043f
Packit fc043f
@item --cflags
Packit fc043f
Print the compiler flags that are necessary to compile a program using
Packit fc043f
Libgpg-error.
Packit fc043f
Packit fc043f
@item --prefix=@var{prefix}
Packit fc043f
If specified, use @var{prefix} instead of the installation prefix that
Packit fc043f
Libgpg-error was built with when computing the output for the
Packit fc043f
@option{--cflags} and @option{--libs} options.  This option is also
Packit fc043f
used for the exec prefix if @option{--exec-prefix} was not specified.
Packit fc043f
This option must be specified before any @option{--libs} or
Packit fc043f
@code{--cflags} options.
Packit fc043f
Packit fc043f
@item --exec-prefix=@var{prefix}
Packit fc043f
If specified, use @var{prefix} instead of the installation exec prefix
Packit fc043f
that Libgpg-error was built with when computing the output for the
Packit fc043f
@option{--cflags} and @option{--libs} options.  This option must be
Packit fc043f
specified before any @option{--libs} or @option{--cflags} options.
Packit fc043f
Packit fc043f
@end table
Packit fc043f
Packit fc043f
@manpause
Packit fc043f
Packit fc043f
Packit fc043f
Packit fc043f
@c **********************************************************
Packit fc043f
@c *************  Appendices (license etc.)  ****************
Packit fc043f
@c **********************************************************
Packit fc043f
@include lgpl.texi
Packit fc043f
Packit fc043f
@include gpl.texi
Packit fc043f
Packit fc043f
@c @node Figures and Tables
Packit fc043f
@c #@unnumbered List of Figures and Tables
Packit fc043f
@c
Packit fc043f
@c @listoffloats Figure
Packit fc043f
@c
Packit fc043f
@c @listoffloats Table
Packit fc043f
Packit fc043f
@node Concept Index
Packit fc043f
@unnumbered Concept Index
Packit fc043f
Packit fc043f
@printindex cp
Packit fc043f
Packit fc043f
@node Function and Data Index
Packit fc043f
@unnumbered Function and Data Index
Packit fc043f
Packit fc043f
@printindex fn
Packit fc043f
Packit fc043f
Packit fc043f
@bye