| 1 |
\input texinfo @c -*- Texinfo -*- |
| 2 |
@c %**start of header |
| 3 |
@setfilename gpgrt.info |
| 4 |
@include version.texi |
| 5 |
@settitle The Libgpg-error Reference Manual |
| 6 |
@c Unify some of the indices. |
| 7 |
@syncodeindex tp fn |
| 8 |
@syncodeindex pg fn |
| 9 |
@c %**end of header |
| 10 |
@copying |
| 11 |
This manual is for Libgpg-error (version @value{VERSION}, |
| 12 |
@value{UPDATED}), which is a library for code used by all GnuPG |
| 13 |
related packages. |
| 14 |
|
| 15 |
@noindent |
| 16 |
Copyright @copyright{} 2014, 2022 g10 Code GmbH |
| 17 |
|
| 18 |
@quotation |
| 19 |
Permission is granted to copy, distribute and/or modify this document |
| 20 |
under the terms of the GNU General Public License as published by the |
| 21 |
Free Software Foundation; either version 2 of the License, or (at your |
| 22 |
option) any later version. The text of the license can be found in the |
| 23 |
section entitled ``GNU General Public License''. |
| 24 |
@end quotation |
| 25 |
@end copying |
| 26 |
|
| 27 |
@dircategory Libraries |
| 28 |
@direntry |
| 29 |
* libgpg-error: (gpgrt). Error codes and common code for GnuPG. |
| 30 |
@end direntry |
| 31 |
|
| 32 |
@c A couple of macros with no effect on texinfo |
| 33 |
@c but used by the yat2m processor. |
| 34 |
@macro manpage {a} |
| 35 |
@end macro |
| 36 |
@macro mansect {a} |
| 37 |
@end macro |
| 38 |
@macro manpause |
| 39 |
@end macro |
| 40 |
@macro mancont |
| 41 |
@end macro |
| 42 |
|
| 43 |
@c |
| 44 |
@c Printing stuff taken from gcc. |
| 45 |
@c |
| 46 |
@macro gnupgtabopt{body} |
| 47 |
@code{\body\} |
| 48 |
@end macro |
| 49 |
|
| 50 |
|
| 51 |
@c |
| 52 |
@c Titlepage |
| 53 |
@c |
| 54 |
@setchapternewpage odd |
| 55 |
@titlepage |
| 56 |
@title The Libgpg-error Reference Manual |
| 57 |
@subtitle Version @value{VERSION} |
| 58 |
@subtitle @value{UPDATED} |
| 59 |
@author Werner Koch (@email{wk@@gnupg.org}) |
| 60 |
|
| 61 |
@page |
| 62 |
@vskip 0pt plus 1filll |
| 63 |
@insertcopying |
| 64 |
@end titlepage |
| 65 |
|
| 66 |
@ifnothtml |
| 67 |
@summarycontents |
| 68 |
@contents |
| 69 |
@page |
| 70 |
@end ifnothtml |
| 71 |
|
| 72 |
|
| 73 |
@ifnottex |
| 74 |
@node Top |
| 75 |
@top The Libgpg-error Library |
| 76 |
@insertcopying |
| 77 |
@end ifnottex |
| 78 |
|
| 79 |
|
| 80 |
@menu |
| 81 |
* Introduction:: What is Libgpg-error. |
| 82 |
* Preparation:: What you should do before using the library. |
| 83 |
* Generalities:: General library functions and data types. |
| 84 |
* Tools:: Utility tools |
| 85 |
|
| 86 |
Appendices |
| 87 |
|
| 88 |
* Library Copying:: The GNU Lesser General Public License |
| 89 |
says how you can copy and share Libgpg-error. |
| 90 |
* Copying:: The GNU General Public License says how you |
| 91 |
can copy and share some parts of Libgpg-error. |
| 92 |
|
| 93 |
Indices |
| 94 |
|
| 95 |
@c * Figures and Tables:: Index of figures and tables. |
| 96 |
* Concept Index:: Index of concepts and programs. |
| 97 |
* Function and Data Index:: Index of functions, variables and data types. |
| 98 |
|
| 99 |
@end menu |
| 100 |
|
| 101 |
@ifhtml |
| 102 |
@page |
| 103 |
@summarycontents |
| 104 |
@contents |
| 105 |
@end ifhtml |
| 106 |
|
| 107 |
|
| 108 |
@c ********************************************************** |
| 109 |
@c ******************* Introduction *********************** |
| 110 |
@c ********************************************************** |
| 111 |
@node Introduction |
| 112 |
@chapter Introduction |
| 113 |
|
| 114 |
Libgpg-error is a library to provide error codes for GnuPG and relates |
| 115 |
software as well as some other general purpose functions. It is |
| 116 |
planned to eventually rename this library to ``gpgrt'' (for GnuPG |
| 117 |
RunTime). |
| 118 |
|
| 119 |
@menu |
| 120 |
* Getting Started:: How to use this manual. |
| 121 |
* Features:: A glance at Libgpg-error’s features. |
| 122 |
* Overview:: Overview about the library. |
| 123 |
@end menu |
| 124 |
|
| 125 |
@node Getting Started |
| 126 |
@section Getting Started |
| 127 |
|
| 128 |
This manual documents the Libgpg-error library application programming |
| 129 |
interface (API). The goal is to that all functions and data types |
| 130 |
provided by the library are explained. However, for now this is only |
| 131 |
a stub and not very useful. |
| 132 |
|
| 133 |
|
| 134 |
@node Features |
| 135 |
@section Features |
| 136 |
|
| 137 |
TBD |
| 138 |
|
| 139 |
@node Overview |
| 140 |
@section Overview |
| 141 |
|
| 142 |
@noindent |
| 143 |
The Libgpg-error library is fully thread-safe, where it makes |
| 144 |
sense to be thread-safe. |
| 145 |
|
| 146 |
TBD |
| 147 |
|
| 148 |
@c ********************************************************** |
| 149 |
@c ******************* Preparation ************************ |
| 150 |
@c ********************************************************** |
| 151 |
@node Preparation |
| 152 |
@chapter Preparation |
| 153 |
|
| 154 |
To use Libgpg-error, you have to perform some changes to your |
| 155 |
sources and the build system. The necessary changes are small and |
| 156 |
explained in the following sections. At the end of this chapter, it |
| 157 |
is described how the library is initialized, and how the requirements |
| 158 |
of the library are verified. |
| 159 |
|
| 160 |
@menu |
| 161 |
* Header:: What header file you need to include. |
| 162 |
* Building sources:: How to build sources using the library. |
| 163 |
* Building sources using Automake:: How to build sources with the help of Automake. |
| 164 |
* Initializing the library:: How to initialize the library. |
| 165 |
* Multi-Threading:: How Libgpg-error can be used in a MT environment. |
| 166 |
@end menu |
| 167 |
|
| 168 |
|
| 169 |
@node Header |
| 170 |
@section Header |
| 171 |
|
| 172 |
All interfaces (data types and functions) of the library are defined |
| 173 |
in the header file @file{gpg-error.h}. You must include this in all source |
| 174 |
files using the library, either directly or through some other header |
| 175 |
file, like this: |
| 176 |
|
| 177 |
@example |
| 178 |
#include <gpg-error.h> |
| 179 |
@end example |
| 180 |
|
| 181 |
Note well that the header file is platform specific and may only be |
| 182 |
used on the platform for which it has been build. |
| 183 |
|
| 184 |
The name space of Libgpg-error is @code{gpg_*} and @code{gpgrt*} |
| 185 |
for function and type names and @code{GPG_*} and @code{GPGRT_*} |
| 186 |
for other symbols. In addition the same name prefixes with one |
| 187 |
prepended underscore are reserved for internal use and should never be |
| 188 |
used by an application. |
| 189 |
|
| 190 |
@noindent |
| 191 |
Certain parts of gpg-error.h may be included by defining these macros: |
| 192 |
|
| 193 |
@table @code |
| 194 |
@item GPG_ERR_ENABLE_GETTEXT_MACROS |
| 195 |
Define to provide macros to map the internal gettext API to standard |
| 196 |
names. This has only an effect on Windows platforms. |
| 197 |
|
| 198 |
@item GPGRT_ENABLE_ES_MACROS |
| 199 |
Define to provide "es_" macros for the estream functions. |
| 200 |
@end table |
| 201 |
|
| 202 |
@node Building sources |
| 203 |
@section Building sources |
| 204 |
|
| 205 |
If you want to compile a source file including the `gpg-error.h' header |
| 206 |
file, you must make sure that the compiler can find it in the |
| 207 |
directory hierarchy. This is accomplished by adding the path to the |
| 208 |
directory in which the header file is located to the compilers include |
| 209 |
file search path (via the @option{-I} option). |
| 210 |
|
| 211 |
However, the path to the include file is determined at the time the |
| 212 |
source is configured. To solve this problem, Libgpg-error ships with |
| 213 |
a pkg-config file: gpg-error.pc. |
| 214 |
|
| 215 |
The options that need to be added to the compiler invocation at |
| 216 |
compile time are output by the @option{--cflags} option to |
| 217 |
@command{pkg-config}. The following example shows how it can be used |
| 218 |
at the command line: |
| 219 |
|
| 220 |
@example |
| 221 |
gcc -c foo.c $(pkg-config --cflags gpg-error) |
| 222 |
@end example |
| 223 |
|
| 224 |
Adding the output of @samp{pkg-config --cflags gpg-error} to the |
| 225 |
compiler’s command line will ensure that the compiler can find the |
| 226 |
Libgpg-error header file. |
| 227 |
|
| 228 |
A similar problem occurs when linking the program with the library. |
| 229 |
Again, the compiler has to find the library files. For this to work, |
| 230 |
the path to the library files has to be added to the library search |
| 231 |
path (via the @option{-L} option). For this, the option |
| 232 |
@option{--libs} to @command{pkg-config} can be used. The example |
| 233 |
shows how to link @file{foo.o} with the Libgpg-error library to a |
| 234 |
program @command{foo}. |
| 235 |
|
| 236 |
@example |
| 237 |
gcc -o foo foo.o $(pkg-config --libs gpg-error) |
| 238 |
@end example |
| 239 |
|
| 240 |
Of course you can also combine both examples to a single command by |
| 241 |
specifying both options to @command{pkg-config}: |
| 242 |
|
| 243 |
@example |
| 244 |
gcc -o foo foo.c $(pkg-config --cflags --libs gpg-error) |
| 245 |
@end example |
| 246 |
|
| 247 |
For GnuPG and its friends, which are usually needed to be built |
| 248 |
earlier in a stage of OS bootstrap, Libgpg-error ships the small |
| 249 |
helper program @command{gpgrt-config}. This helper program is a sort |
| 250 |
of @command{pkg-config} replacement for limited environment, |
| 251 |
supporting cross compilation, as well as multilib and multi-arch |
| 252 |
installation. Note that @command{gpgrt-config} is not for general use |
| 253 |
for other programs. @command{gpgrt-config} requires invocation with |
| 254 |
the option @option{--lib=} so that it locates the appropriate path to |
| 255 |
@file{gpg-error.pc}. |
| 256 |
|
| 257 |
|
| 258 |
@node Building sources using Automake |
| 259 |
@section Building sources using Automake |
| 260 |
|
| 261 |
It is much easier if you use GNU Automake instead of writing your own |
| 262 |
Makefiles. If you do that, you do not have to worry about finding and |
| 263 |
invoking the @command{pkg-config} or @command{gpgrt-config} script at |
| 264 |
all. Libgpg-error provides an extension to Automake that does all the |
| 265 |
work for you. That is offered by @file{gpg-error.m4}. |
| 266 |
|
| 267 |
@c A simple macro for optional variables. |
| 268 |
@macro ovar{varname} |
| 269 |
@r{[}@var{\varname\}@r{]} |
| 270 |
@end macro |
| 271 |
@defmac AM_PATH_GPG_ERROR (@ovar{minimum-version}, @ovar{action-if-found}, @ovar{action-if-not-found}) |
| 272 |
Check whether Libgpg-error (at least version @var{minimum-version}, if |
| 273 |
given) exists on the host system. If it is found, execute |
| 274 |
@var{action-if-found}, otherwise do @var{action-if-not-found}, if |
| 275 |
given. |
| 276 |
|
| 277 |
Additionally, the function defines @code{GPG_ERROR_CFLAGS} to the |
| 278 |
flags needed for compilation of the program to find the |
| 279 |
@file{gpg-error.h} header file, and @code{GPG_ERROR_LIBS} to the |
| 280 |
linker flags needed to link the program to the Libgpg-error library. |
| 281 |
|
| 282 |
This macro searches for @command{gpgrt-config} along the PATH. |
| 283 |
|
| 284 |
@end defmac |
| 285 |
|
| 286 |
You can use the defined Autoconf variables like this in your |
| 287 |
@file{Makefile.am}: |
| 288 |
|
| 289 |
@example |
| 290 |
AM_CPPFLAGS = $(GPG_ERROR_CFLAGS) |
| 291 |
LDADD = $(GPG_ERROR_LIBS) |
| 292 |
@end example |
| 293 |
|
| 294 |
@node Initializing the library |
| 295 |
@section Initializing the library |
| 296 |
|
| 297 |
Before the library can be used, it should initialize itself. This is |
| 298 |
achieved by invoking the function @code{gpgrt_check_version} described |
| 299 |
below. |
| 300 |
|
| 301 |
Also, it is often desirable to check that the version of |
| 302 |
Libgpg-error used is indeed one which fits all requirements. |
| 303 |
Even with binary compatibility, new features may have been introduced, |
| 304 |
but due to problem with the dynamic linker an old version may actually |
| 305 |
be used. So you may want to check that the version is okay right |
| 306 |
after program startup. |
| 307 |
|
| 308 |
@deftypefun {const char *} gpgrt_check_version (const char *@var{req_version}) |
| 309 |
|
| 310 |
The function @code{gpgrt_check_version} initializes some subsystems used |
| 311 |
by Libgpg-error and must be invoked before any other function in the |
| 312 |
library. |
| 313 |
@xref{Multi-Threading}. |
| 314 |
|
| 315 |
Furthermore, this function returns the version number of the library. |
| 316 |
It can also verify that the version number is higher than a certain |
| 317 |
required version number @var{req_version}, if this value is not a null |
| 318 |
pointer. |
| 319 |
@end deftypefun |
| 320 |
|
| 321 |
|
| 322 |
@node Multi-Threading |
| 323 |
@section Multi-Threading |
| 324 |
|
| 325 |
TBD. |
| 326 |
|
| 327 |
@c ********************************************************** |
| 328 |
@c ******************* General **************************** |
| 329 |
@c ********************************************************** |
| 330 |
@node Generalities |
| 331 |
@chapter Generalities |
| 332 |
|
| 333 |
TBD. (Description of the error function may be taken from Libgcrypt.) |
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
@c ********************************************************** |
| 338 |
@c ********************* Tools **************************** |
| 339 |
@c ********************************************************** |
| 340 |
@node Tools |
| 341 |
@chapter Tools |
| 342 |
|
| 343 |
@menu |
| 344 |
* gpg-error-config:: Print required compiler flags |
| 345 |
* gpgrt-config:: Helper tool for querying installed libraries |
| 346 |
@end menu |
| 347 |
|
| 348 |
@c The original version of this man page has been written for Debian and was |
| 349 |
@c contributed to libgpg-error by Daniel Kahn Gillmor <[email protected]>. |
| 350 |
@manpage gpg-error-config.1 |
| 351 |
@node gpg-error-config |
| 352 |
@section Print required compiler flags |
| 353 |
@ifset manverb |
| 354 |
.B gpg-error-config |
| 355 |
\- Script to get information about the installed version of libgpg-error |
| 356 |
@end ifset |
| 357 |
|
| 358 |
@mansect synopsis |
| 359 |
@ifset manverb |
| 360 |
.B gpg-error-config |
| 361 |
.RI [ options ] |
| 362 |
@end ifset |
| 363 |
|
| 364 |
@mansect description |
| 365 |
@command{gpg-error-config} is a tool that is used to configure to |
| 366 |
determine the compiler and linker flags that should be used to compile |
| 367 |
and link programs that use Libgpg-error. |
| 368 |
|
| 369 |
This tool is now obsolete. Instead, please use pkg-config with |
| 370 |
gpg-error.pc for your new program, or use gpg-error.m4 which uses |
| 371 |
gpgrt-config and gpg-error.pc internally. |
| 372 |
|
| 373 |
@mansect options |
| 374 |
@noindent |
| 375 |
@command{gpg-error-config} accepts the following options: |
| 376 |
|
| 377 |
@table @gnupgtabopt |
| 378 |
|
| 379 |
@item --mt |
| 380 |
Provide output appropriate for multithreaded programs. @option{--mt} |
| 381 |
is only useful when combined with other options, and must be the first |
| 382 |
option if present. |
| 383 |
|
| 384 |
@item --version |
| 385 |
Print the currently installed version of Libgpg-error on the |
| 386 |
standard output. |
| 387 |
|
| 388 |
@item --libs |
| 389 |
Print the linker flags that are necessary to link a program using |
| 390 |
Libgpg-error. |
| 391 |
|
| 392 |
@item --cflags |
| 393 |
Print the compiler flags that are necessary to compile a program using |
| 394 |
Libgpg-error. |
| 395 |
|
| 396 |
@item --prefix=@var{prefix} |
| 397 |
If specified, use @var{prefix} instead of the installation prefix that |
| 398 |
Libgpg-error was built with when computing the output for the |
| 399 |
@option{--cflags} and @option{--libs} options. This option is also |
| 400 |
used for the exec prefix if @option{--exec-prefix} was not specified. |
| 401 |
This option must be specified before any @option{--libs} or |
| 402 |
@code{--cflags} options. |
| 403 |
|
| 404 |
@item --exec-prefix=@var{prefix} |
| 405 |
If specified, use @var{prefix} instead of the installation exec prefix |
| 406 |
that Libgpg-error was built with when computing the output for the |
| 407 |
@option{--cflags} and @option{--libs} options. This option must be |
| 408 |
specified before any @option{--libs} or @option{--cflags} options. |
| 409 |
|
| 410 |
@end table |
| 411 |
|
| 412 |
@manpause |
| 413 |
|
| 414 |
@manpage gpgrt-config.1 |
| 415 |
@node gpgrt-config |
| 416 |
@section gpgrt-config - Helper tool for querying installed libraries. |
| 417 |
@ifset manverb |
| 418 |
.B gpgrt-config |
| 419 |
\- Helper script to get information about the installed version of gpg libraries |
| 420 |
@end ifset |
| 421 |
|
| 422 |
@mansect synopsis |
| 423 |
@ifset manverb |
| 424 |
.B gpgrt-config |
| 425 |
.RI [ options ] |
| 426 |
.I [ module ] |
| 427 |
@end ifset |
| 428 |
|
| 429 |
@mansect description |
| 430 |
@command{gpgrt-config} is a script tool that is used by the autoconf macros |
| 431 |
shipped with gnupg software (e.g., AM_PATH_GPG_ERROR and AM_PATH_GPGME) to |
| 432 |
determine the compiler and linker flags that should be used to compile |
| 433 |
and link programs that use the specific library (e.g., libgpg-error or |
| 434 |
libgpgme). @command{gpgrt-config} uses pkg-config .pc files as data source. |
| 435 |
|
| 436 |
Apart from options @command{gpgrt-config} accepts a single argument |
| 437 |
@option{module} specifying the basename (without the ".pc"-suffix) of the |
| 438 |
pkg-config file to be used as input. @option{module} will default to |
| 439 |
@option{gpg-error} if it is not specified. |
| 440 |
|
| 441 |
@mansect options |
| 442 |
@noindent |
| 443 |
@command{gpgrt-config} accepts the following options: |
| 444 |
|
| 445 |
@table @gnupgtabopt |
| 446 |
@item --libdir=@var{LIBDIR} |
| 447 |
Parent directory path of pkgconfig file search path. |
| 448 |
e.g., @samp{gpgrt-config --libdir=/usr/lib --exists gpgme} |
| 449 |
will parse @file{/usr/lib/pkgconfig/gpgme.pc}. |
| 450 |
|
| 451 |
@item --exists |
| 452 |
Test whether the pkg-config file @file{module.pc} exist and exits with |
| 453 |
success or error accordingly. |
| 454 |
|
| 455 |
@item --modversion |
| 456 |
Print the currently installed version of @option{module} on the standard output. |
| 457 |
|
| 458 |
@item --libs |
| 459 |
Print the linker flags that are necessary to link a program using the |
| 460 |
@option{module}. |
| 461 |
|
| 462 |
@item --cflags |
| 463 |
Print the compiler flags that are necessary to compile a program using the |
| 464 |
@option{module}. |
| 465 |
|
| 466 |
@item --static |
| 467 |
Modifies output if linking statically instead of dynamically. |
| 468 |
|
| 469 |
@item --variable=@var{VARNAME} |
| 470 |
Output variable VARNAME from the module's pkg-config file. |
| 471 |
|
| 472 |
@end table |
| 473 |
|
| 474 |
@mansect bugs |
| 475 |
@noindent |
| 476 |
@command{gpgrt-config} is tried to be compatible to pkg-config, and to |
| 477 |
support cross build well, but it is not intended to be a replacement. |
| 478 |
|
| 479 |
@manpause |
| 480 |
|
| 481 |
|
| 482 |
@c ********************************************************** |
| 483 |
@c ************* Appendices (license etc.) **************** |
| 484 |
@c ********************************************************** |
| 485 |
@include lgpl.texi |
| 486 |
|
| 487 |
@include gpl.texi |
| 488 |
|
| 489 |
@c @node Figures and Tables |
| 490 |
@c #@unnumbered List of Figures and Tables |
| 491 |
@c |
| 492 |
@c @listoffloats Figure |
| 493 |
@c |
| 494 |
@c @listoffloats Table |
| 495 |
|
| 496 |
@node Concept Index |
| 497 |
@unnumbered Concept Index |
| 498 |
|
| 499 |
@printindex cp |
| 500 |
|
| 501 |
@node Function and Data Index |
| 502 |
@unnumbered Function and Data Index |
| 503 |
|
| 504 |
@printindex fn |
| 505 |
|
| 506 |
|
| 507 |
@bye |