| 1 |
This is assuan.info, produced by makeinfo version 6.8 from assuan.texi. |
| 2 |
|
| 3 |
INFO-DIR-SECTION GNU Libraries |
| 4 |
START-INFO-DIR-ENTRY |
| 5 |
* Assuan: (assuan). An IPC library for non-persistent servers. |
| 6 |
END-INFO-DIR-ENTRY |
| 7 |
|
| 8 |
This file documents the use and the internals of Assuan. |
| 9 |
|
| 10 |
This is Edition 3.0.2, last updated 18 June 2024, of 'The 'Developing |
| 11 |
with Assuan' Manual', for Version 3.0.2. |
| 12 |
|
| 13 |
Published by the Free Software Foundation |
| 14 |
51 Franklin Street, Fifth Floor |
| 15 |
Boston, MA 02110-1301 USA |
| 16 |
|
| 17 |
Copyright (C) 2001-2013 Free Software Foundation, Inc. |
| 18 |
Copyright (C) 2001-2015 g10 Code GmbH |
| 19 |
|
| 20 |
Permission is granted to copy, distribute and/or modify this document |
| 21 |
under the terms of the GNU General Public License as published by the |
| 22 |
Free Software Foundation; either version 3 of the License, or (at your |
| 23 |
option) any later version. The text of the license can be found in the |
| 24 |
section entitled "Copying". |
| 25 |
|
| 26 |
|
| 27 |
File: assuan.info, Node: Top, Next: Introduction, Up: (dir) |
| 28 |
|
| 29 |
Introduction |
| 30 |
************ |
| 31 |
|
| 32 |
This manual documents how to exploit the Assuan library, a simple |
| 33 |
interprocess communcation library. |
| 34 |
|
| 35 |
* Menu: |
| 36 |
|
| 37 |
* Introduction:: An introduction to and the motivation behind Assuan. |
| 38 |
* Assuan:: Description of the Assuan protocol. |
| 39 |
* Implementation:: Overview of the implementation. |
| 40 |
* Preparation:: What you should do before using the library. |
| 41 |
* Generalities:: Initialization code and data types used. |
| 42 |
* Client code:: How to develop an Assuan client. |
| 43 |
* Server code:: How to develop an Assuan server. |
| 44 |
* External I/O Loop:: How to use external I/O event loops. |
| 45 |
* Utilities:: Utility functions. |
| 46 |
* Socket wrappers:: Socket wrapper functions. |
| 47 |
|
| 48 |
Miscellaneous |
| 49 |
|
| 50 |
* Library Copying:: GNU Lesser General Public License says |
| 51 |
how you can copy and share Assuan. |
| 52 |
* Copying:: How you can copy and share this manual. |
| 53 |
|
| 54 |
Indices |
| 55 |
|
| 56 |
* Index:: Index of concepts and symbol names. |
| 57 |
|
| 58 |
|
| 59 |
File: assuan.info, Node: Introduction, Next: Assuan, Prev: Top, Up: Top |
| 60 |
|
| 61 |
1 Introduction to Assuan |
| 62 |
************************ |
| 63 |
|
| 64 |
Assuan is an extensible inter-process communication (IPC) protocol and |
| 65 |
library. It is designed for point-to-point communication and it doesn't |
| 66 |
provide a naming system. To contact a server, either the client must |
| 67 |
know how to locate the server, e.g., via a well-known Unix domain |
| 68 |
socket, or, if the server is transient, how to start it. In the latter |
| 69 |
case, Assuan provides functionality to start the server process. |
| 70 |
|
| 71 |
In Assuan, communication is typically either via a pipe or a Unix |
| 72 |
domain socket. This method is neither elegant nor efficient, especially |
| 73 |
when there is a lot of data spread across several transactions. Not |
| 74 |
only is there a penalty for an increased number of context switches, but |
| 75 |
a significant amount of data is MEMCPYed from the client to a file |
| 76 |
descriptor and from the file descriptor to the server. Despite these |
| 77 |
and other disadvantages, this type of client/server communication is |
| 78 |
useful: the client is separated from the server: they run in different |
| 79 |
address spaces. This is especially important in situations where the |
| 80 |
server must have a known degree of reliability and data must be |
| 81 |
protected: as the Assuan protocol is well defined and clients cannot |
| 82 |
corrupt the servers' address space, auditing becomes much easier. |
| 83 |
|
| 84 |
Assuan was developed for use by the GNU Privacy Guard (GnuPG) to |
| 85 |
prevent potentially buggy clients from unwittingly corrupting sensitive |
| 86 |
transactions or compromising data such as a secret key. Assuan permits |
| 87 |
the servers, which do the actual work, e.g., encryption and decryption |
| 88 |
of data using a secret key, to be developed independently of the user |
| 89 |
interfaces, e.g., mail clients and other encryption front ends. Like a |
| 90 |
shared library, the interface is well defined and any number of front |
| 91 |
ends can use it; however, unlike a shared library, the client cannot see |
| 92 |
or touch the server's data. As with any modular system, Assuan helps |
| 93 |
keep the components small, understandable and less error prone. |
| 94 |
|
| 95 |
Assuan is not, however, limited to use with GnuPG servers and |
| 96 |
clients: it was designed to be flexible enough to meet the demands of |
| 97 |
many transaction-based environments. |
| 98 |
|
| 99 |
|
| 100 |
File: assuan.info, Node: Assuan, Next: Implementation, Prev: Introduction, Up: Top |
| 101 |
|
| 102 |
2 Description of the Assuan protocol. |
| 103 |
************************************* |
| 104 |
|
| 105 |
The architecture of the modular GnuPG system is based on several highly |
| 106 |
specialized modules which form a network of clients and servers. A |
| 107 |
common framework for intermodule communication is therefore needed and |
| 108 |
implemented as a library. |
| 109 |
|
| 110 |
Goals: |
| 111 |
|
| 112 |
* Common framework for module communication |
| 113 |
* Easy debugging |
| 114 |
* Easy module testing |
| 115 |
* Extensible |
| 116 |
* Optional authentication and encryption facility |
| 117 |
* Usable to access external hardware |
| 118 |
|
| 119 |
Design criteria: |
| 120 |
|
| 121 |
* Client/Server with back channel |
| 122 |
* Use a mainly text based protocol |
| 123 |
* Escape certain control characters |
| 124 |
* Allow indefinite data length |
| 125 |
* Request confidentiality for parts of the communication |
| 126 |
* Dummy module to allow direct linking of client and server |
| 127 |
* Inline data or descriptor passing for bulk data |
| 128 |
* No protection against DoS needed |
| 129 |
* Subliminal channels are not an issue |
| 130 |
|
| 131 |
|
| 132 |
File: assuan.info, Node: Implementation, Next: Preparation, Prev: Assuan, Up: Top |
| 133 |
|
| 134 |
3 Implementation |
| 135 |
**************** |
| 136 |
|
| 137 |
The implementation is line based with a maximum line size of 1000 |
| 138 |
octets. The default IPC mechanism is Unix Domain Sockets. |
| 139 |
|
| 140 |
On connect, the server responds either with okay or an error status. |
| 141 |
To perform an authentication check, the server may send an Inquiry |
| 142 |
response prior to the first Okay. It may also issue Status messages. |
| 143 |
The server must check that the client is allowed to connect. This is |
| 144 |
done by requesting the credentials for the peer and comparing them with |
| 145 |
the server's credentials. This avoids attacks based on wrong socket |
| 146 |
permissions. |
| 147 |
|
| 148 |
The server may choose to delay the first response in case of an |
| 149 |
error. The server, however, never closes the connection, however, the |
| 150 |
lower protocol may do so after some time of inactivity or when the |
| 151 |
connection enters an error state. |
| 152 |
|
| 153 |
All textual messages are assumed to be in UTF-8 unless otherwise |
| 154 |
noted. |
| 155 |
|
| 156 |
* Menu: |
| 157 |
|
| 158 |
* Server responses:: Description of server responses. |
| 159 |
* Client requests:: Description of client requests. |
| 160 |
* Error codes:: List of error and status codes. |
| 161 |
|
| 162 |
|
| 163 |
File: assuan.info, Node: Server responses, Next: Client requests, Up: Implementation |
| 164 |
|
| 165 |
3.1 Server responses |
| 166 |
==================== |
| 167 |
|
| 168 |
'OK [<arbitrary debugging information>]' |
| 169 |
Request was successful. |
| 170 |
|
| 171 |
'ERR ERRORCODE [<human readable error description>]' |
| 172 |
Request could not be fulfilled. The possible error codes are |
| 173 |
defined by 'libgpg-error'. |
| 174 |
|
| 175 |
'S KEYWORD <status information depending on keyword>' |
| 176 |
Informational output by the server, which is still processing the |
| 177 |
request. A client may not send such lines to the server while |
| 178 |
processing an Inquiry command. KEYWORD shall start with a letter |
| 179 |
or an underscore. |
| 180 |
|
| 181 |
'# <string>' |
| 182 |
Comment line issued only for debugging purposes. Totally ignored. |
| 183 |
|
| 184 |
'D <raw data>' |
| 185 |
Raw data returned to client. There must be exactly one space after |
| 186 |
the 'D'. The values for '%', CR and LF must be percent escaped; |
| 187 |
these are encoded as %25, %0D and %0A, respectively. Only |
| 188 |
uppercase letters should be used in the hexadecimal representation. |
| 189 |
Other characters may be percent escaped for easier debugging. All |
| 190 |
Data lines are considered one data stream up to the OK or ERR |
| 191 |
response. Status and Inquiry Responses may be mixed with the Data |
| 192 |
lines. |
| 193 |
|
| 194 |
'INQUIRE KEYWORD <parameters>' |
| 195 |
The server needs further information from the client. The client |
| 196 |
should respond with data (using the "D" command and terminated by |
| 197 |
"END"). Alternatively, the client may cancel the current operation |
| 198 |
by responding with "CAN". |
| 199 |
|
| 200 |
Consider the following examples (lines prefixed with S indicate text |
| 201 |
that the server sends; lines prefixed with C indicate text that the |
| 202 |
client sends): |
| 203 |
|
| 204 |
S: INQUIRE foo |
| 205 |
C: D foo bar |
| 206 |
C: D bar baz |
| 207 |
C: END |
| 208 |
[Server continues normal work] |
| 209 |
|
| 210 |
This implements a callback to the client: |
| 211 |
|
| 212 |
S: INQUIRE foo |
| 213 |
C: END |
| 214 |
[Server continues] |
| 215 |
|
| 216 |
and: |
| 217 |
|
| 218 |
S: INQUIRE foo |
| 219 |
C: CAN |
| 220 |
[Server terminates the operaion and in most cases returns an ERR to the client.] |
| 221 |
|
| 222 |
But, CAN may also mean "I have no data for you, try to get it from |
| 223 |
elsewhere." |
| 224 |
|
| 225 |
Note: lines longer than 1000 bytes should be treated as a |
| 226 |
communication error. (The rationale for having a line length limit is |
| 227 |
to allow for easier multiplexing of several channels.) |
| 228 |
|
| 229 |
|
| 230 |
File: assuan.info, Node: Client requests, Next: Error codes, Prev: Server responses, Up: Implementation |
| 231 |
|
| 232 |
3.2 Client requests |
| 233 |
=================== |
| 234 |
|
| 235 |
The server waits for client requests after sending an Okay or Error. |
| 236 |
The client should not issue a request in other cases. |
| 237 |
|
| 238 |
COMMAND <parameters> |
| 239 |
|
| 240 |
COMMAND is a one word string without preceding white space. |
| 241 |
Parameters are command specific, CR, LF and the percent signs should be |
| 242 |
percent escaped as described above. To send a backslash as the last |
| 243 |
character it should also be percent escaped. Percent escaping is |
| 244 |
allowed anywhere in the parameters but not in the command. The line |
| 245 |
ends with a CR, LF pair or just a LF. |
| 246 |
|
| 247 |
Not yet implemented feature: If there is a need for a parameter list |
| 248 |
longer than the line length limit (1000 characters including command and |
| 249 |
CR, LF), the last character of the line (right before the CR/LF or LF) |
| 250 |
must be a unescaped (i.e., literal) backslash. The following line is |
| 251 |
then expected to be a continuation of the line with the backslash |
| 252 |
replaced by a blank and the line ending removed. |
| 253 |
|
| 254 |
D <raw data> |
| 255 |
|
| 256 |
Sends raw data to the server. There must be exactly one space after |
| 257 |
the 'D'. The values for '%', CR and LF must be percent escaped. These |
| 258 |
are encoded as %25, %0D and %0A, respectively. Only uppercase letters |
| 259 |
should be used in the hexadecimal representation. Other characters may |
| 260 |
be percent escaped for easier debugging. All Data lines are considered |
| 261 |
one data stream up to the 'OK' or 'ERR' response. Status and Inquiry |
| 262 |
Responses may be mixed with the Data lines. |
| 263 |
|
| 264 |
END |
| 265 |
|
| 266 |
Lines beginning with a '#' or empty lines are ignored. This is |
| 267 |
useful to comment test scripts. |
| 268 |
|
| 269 |
Although the commands are application specific, some of them are used |
| 270 |
by all protocols and partly supported by the Assuan library: |
| 271 |
|
| 272 |
'BYE' |
| 273 |
Close the connection. The server will respond with 'OK'. |
| 274 |
|
| 275 |
'RESET' |
| 276 |
Reset the connection but not any existing authentication. The |
| 277 |
server should release all resources associated with the connection. |
| 278 |
|
| 279 |
'END' |
| 280 |
Used by a client to mark the end of raw data. The server may send |
| 281 |
'END' to indicate a partial end of data. |
| 282 |
|
| 283 |
'HELP' |
| 284 |
Lists all commands that the server understands as comment lines on |
| 285 |
the status channel. |
| 286 |
|
| 287 |
'QUIT' |
| 288 |
Reserved for future extensions. |
| 289 |
|
| 290 |
'OPTION' |
| 291 |
Set options for the connection. The syntax of such a line is |
| 292 |
OPTION NAME [ [=] VALUE ] |
| 293 |
Leading and trailing spaces around NAME and VALUE are allowed but |
| 294 |
should be ignored. For compatibility reasons, NAME may be prefixed |
| 295 |
with two dashes. The use of the equal sign is optional but |
| 296 |
suggested if VALUE is given. |
| 297 |
|
| 298 |
'CANCEL' |
| 299 |
This command is reserved for future extensions. |
| 300 |
|
| 301 |
'AUTH' |
| 302 |
This command is reserved for future extensions. Not yet specified |
| 303 |
as we don't implement it in the first phase. See Werner's mail to |
| 304 |
gpa-dev on 2001-10-25 about the rationale for measurements against |
| 305 |
local attacks. |
| 306 |
|
| 307 |
'NOP' |
| 308 |
No operation. Returns OK without any action. |
| 309 |
|
| 310 |
|
| 311 |
File: assuan.info, Node: Error codes, Prev: Client requests, Up: Implementation |
| 312 |
|
| 313 |
3.3 Error codes |
| 314 |
=============== |
| 315 |
|
| 316 |
Libassuan is used with gpg-error style error codes. It is recommended |
| 317 |
to set the error source to a different value from the default |
| 318 |
'GPG_ERR_SOURCE_UNKNOWN' by calling *note function |
| 319 |
assuan_set_gpg_err_source:: early. |
| 320 |
|
| 321 |
|
| 322 |
File: assuan.info, Node: Preparation, Next: Generalities, Prev: Implementation, Up: Top |
| 323 |
|
| 324 |
4 Preparation |
| 325 |
************* |
| 326 |
|
| 327 |
To use ASSUAN, you have to make some changes to your sources and the |
| 328 |
build system. The necessary changes are small and explained in the |
| 329 |
following sections. |
| 330 |
|
| 331 |
* Menu: |
| 332 |
|
| 333 |
* Header:: What header file you need to include. |
| 334 |
* Building sources:: How to build sources using the library. |
| 335 |
* Automake:: How to build sources with the help of Automake. |
| 336 |
* Multi Threading:: How 'libassuan' can be used in a MT environment. |
| 337 |
|
| 338 |
|
| 339 |
File: assuan.info, Node: Header, Next: Building sources, Up: Preparation |
| 340 |
|
| 341 |
4.1 Header |
| 342 |
========== |
| 343 |
|
| 344 |
All interfaces (data types and functions) of 'libassuan' are defined in |
| 345 |
the header file 'assuan.h'. You must include this in all source files |
| 346 |
using the library, either directly or through some other header file, |
| 347 |
like this: |
| 348 |
|
| 349 |
#include <assuan.h> |
| 350 |
|
| 351 |
The namespace of 'libassuan' is 'assuan_*' for function and type |
| 352 |
names and 'ASSUAN*' for other symbols. In addition the same name |
| 353 |
prefixes with one prepended underscore are reserved for internal use and |
| 354 |
should never be used by an application. |
| 355 |
|
| 356 |
Because 'libassuan' makes use of the GPG Error library, using |
| 357 |
'libassuan' will also use the 'GPG_ERR_*' namespace directly, and the |
| 358 |
'gpg_err*' and 'gpg_str*' namespaces indirectly. |
| 359 |
|
| 360 |
|
| 361 |
File: assuan.info, Node: Building sources, Next: Automake, Prev: Header, Up: Preparation |
| 362 |
|
| 363 |
4.2 Building sources |
| 364 |
==================== |
| 365 |
|
| 366 |
If you want to compile a source file including the 'assuan.h' header |
| 367 |
file, you must make sure that the compiler can find it in the directory |
| 368 |
hierarchy. This is accomplished by adding the path to the directory in |
| 369 |
which the header file is located to the compilers include file search |
| 370 |
path (via the '-I' option). |
| 371 |
|
| 372 |
However, the path to the include file is determined at the time the |
| 373 |
source is configured. To solve this problem, 'libassuan' ships with |
| 374 |
'libassuan.pc' file, that knows the path to the include file and other |
| 375 |
configuration options. The options that need to be added to the |
| 376 |
compiler invocation at compile time are output by the '--cflags' option |
| 377 |
to 'pkg-config libassuan'. The following example shows how it can be |
| 378 |
used at the command line: |
| 379 |
|
| 380 |
gcc -c foo.c $(pkg-config --cflags libassuan) |
| 381 |
|
| 382 |
Adding the output of 'pkg-config --cflags libassuan' to the |
| 383 |
compiler's command line will ensure that the compiler can find the |
| 384 |
'assuan.h' header file. |
| 385 |
|
| 386 |
A similar problem occurs when linking the program with the library. |
| 387 |
Again, the compiler/linker has to find the library files. For this to |
| 388 |
work, the path to the library files has to be added to the library |
| 389 |
search path (via the '-L' option). For this, the option '--libs' to |
| 390 |
'pkg-config libassuan' can be used. For convenience, this option also |
| 391 |
outputs all other options that are required to link the program with the |
| 392 |
'libassuan' libraries (in particular, the '-lassuan' option). The |
| 393 |
example shows how to link 'foo.o' with the 'libassuan' library to a |
| 394 |
program 'foo'. |
| 395 |
|
| 396 |
gcc -o foo foo.o $(pkg-config --libs libassuan) |
| 397 |
|
| 398 |
You can also combine both examples to a single command by specifying |
| 399 |
both options to 'pkg-config libassuan': |
| 400 |
|
| 401 |
gcc -o foo foo.c $(pkg-config --cflags --libs libassuan) |
| 402 |
|
| 403 |
|
| 404 |
File: assuan.info, Node: Automake, Next: Multi Threading, Prev: Building sources, Up: Preparation |
| 405 |
|
| 406 |
4.3 Building sources using Automake |
| 407 |
=================================== |
| 408 |
|
| 409 |
It is much easier if you use GNU Automake instead of writing your own |
| 410 |
Makefiles. If you do that you do not have to worry about finding and |
| 411 |
invoking the 'pkg-config' script at all. |
| 412 |
|
| 413 |
You can use 'PKG_CHECK_MODULES' macro, or, 'libassuan' also provides |
| 414 |
an Automake macro that does all the work for you. |
| 415 |
|
| 416 |
-- Macro: AM_PATH_LIBASSUAN ([MINIMUM-VERSION], [ACTION-IF-FOUND], |
| 417 |
[ACTION-IF-NOT-FOUND]) |
| 418 |
Check whether 'libassuan' (at least version MINIMUM-VERSION, if |
| 419 |
given) exists on the host system. If it is found, execute |
| 420 |
ACTION-IF-FOUND, otherwise do ACTION-IF-NOT-FOUND, if given. |
| 421 |
|
| 422 |
Additionally, the function defines 'LIBASSUAN_CFLAGS' to the flags |
| 423 |
needed for compilation of the program to find the 'assuan.h' header |
| 424 |
file, and 'LIBASSUAN_LIBS' to the linker flags needed to link the |
| 425 |
program to the 'libassuan' library. |
| 426 |
|
| 427 |
You can use the defined Autoconf variables like this in your |
| 428 |
'Makefile.am': |
| 429 |
|
| 430 |
AM_CPPFLAGS = $(LIBASSUAN_CFLAGS) |
| 431 |
LDADD = $(LIBASSUAN_LIBS) |
| 432 |
|
| 433 |
|
| 434 |
File: assuan.info, Node: Multi Threading, Prev: Automake, Up: Preparation |
| 435 |
|
| 436 |
4.4 Multi Threading |
| 437 |
=================== |
| 438 |
|
| 439 |
The 'libassuan' library is designed so that it can be used in a threaded |
| 440 |
application, if some rules are followed. |
| 441 |
|
| 442 |
* Run the initialization functions before you actually start to use |
| 443 |
threads. Specifically, the functions 'assuan_set_gpg_err_source', |
| 444 |
'assuan_set_malloc_hooks' and 'assuan_set_log_cb' should not be |
| 445 |
called concurrently with 'assuan_new'. Use 'assuan_new_ext' |
| 446 |
instead or ensure proper serialization. |
| 447 |
* Only one thread at a time may access an 'libassuan' context. |
| 448 |
* If you use the default log handler, use |
| 449 |
'assuan_set_assuan_log_stream' to setup a default log stream. |
| 450 |
* If you have callback functions shared by multiple functions, the |
| 451 |
callback function must be reentrant for that purpose. 'libassuan' |
| 452 |
does not serialize invocation of callback functions across |
| 453 |
contexts. |
| 454 |
|
| 455 |
|
| 456 |
File: assuan.info, Node: Generalities, Next: Client code, Prev: Preparation, Up: Top |
| 457 |
|
| 458 |
5 Generalities |
| 459 |
************** |
| 460 |
|
| 461 |
* Menu: |
| 462 |
|
| 463 |
* Data Types:: Data types used by 'libassuan'. |
| 464 |
* Initializing the library:: How to initialize the library. |
| 465 |
* Default Log Handler:: How to configure the default log handler. |
| 466 |
* Contexts:: How to work with contexts. |
| 467 |
* Reading and Writing:: How to communicate with the peer. |
| 468 |
|
| 469 |
|
| 470 |
File: assuan.info, Node: Data Types, Next: Initializing the library, Up: Generalities |
| 471 |
|
| 472 |
5.1 Data Types used by the library |
| 473 |
================================== |
| 474 |
|
| 475 |
ASSUAN uses a so-called context to store a connection's state. The |
| 476 |
following data type is used for that: |
| 477 |
|
| 478 |
-- Data type: assuan_context_t |
| 479 |
The 'assuan_context_t' type is a pointer to an object maintained |
| 480 |
internally by the library. Contexts are allocated with |
| 481 |
'assuan_new' or 'assuan_new_ext' and released with |
| 482 |
'assuan_release'. Other functions take this data type to access |
| 483 |
the state created by these functions. |
| 484 |
|
| 485 |
-- Data type: assuan_fd_t |
| 486 |
The 'assuan_fd_t' is a file descriptor (in Unix) or a system handle |
| 487 |
(in Windows). The special value 'ASSUAN_INVALID_FD' is used to |
| 488 |
specify invalid Assuan file descriptors. |
| 489 |
|
| 490 |
-- Function: assuan_fd_t assuan_fdopen (int FD) |
| 491 |
Create an assuan file descriptor from a POSIX (libc) file |
| 492 |
descriptor FD. On Unix, this is equivalent to 'dup', while on |
| 493 |
Windows this will retrieve the underlying system handle with |
| 494 |
'_get_osfhandle' and duplicate that. |
| 495 |
|
| 496 |
|
| 497 |
File: assuan.info, Node: Initializing the library, Next: Default Log Handler, Prev: Data Types, Up: Generalities |
| 498 |
|
| 499 |
5.2 Initializing the library |
| 500 |
============================ |
| 501 |
|
| 502 |
Libassuan makes use of Libgpg-error and assumes that Libgpg-error has |
| 503 |
been initialized. In general 'gpgrt_check_version' should be called to |
| 504 |
guarantee this; the Libgpg-error manual for details. |
| 505 |
|
| 506 |
Libassuan itself requires no initialization. There are however some |
| 507 |
initialization hooks provided which are often useful. These should be |
| 508 |
called as early as possible and in a multi-threaded application before a |
| 509 |
second thread is created. |
| 510 |
|
| 511 |
These functions initialize default values that are used at context |
| 512 |
creation with 'assuan_new'. As there can only be one default, all |
| 513 |
values can also be set directly with 'assuan_new_ext' or with |
| 514 |
context-specific functions after context creation. |
| 515 |
|
| 516 |
If your application uses its own memory allocation functions or |
| 517 |
wrappers it is good idea to tell 'libassuan' about it so it can make use |
| 518 |
of the same functions or wrappers: |
| 519 |
|
| 520 |
-- Data type: struct assuan_malloc_hooks |
| 521 |
This structure is used to store the memory allocation callback |
| 522 |
interface functions. It has the following members, whose semantics |
| 523 |
are identical to the corresponding system functions: |
| 524 |
|
| 525 |
'void *(*malloc) (size_t cnt)' |
| 526 |
This is the function called by ASSUAN to allocate memory for a |
| 527 |
context. |
| 528 |
|
| 529 |
'void *(*realloc) (void *ptr, size_t cnt)' |
| 530 |
This is the function called by ASSUAN to reallocate memory for |
| 531 |
a context. |
| 532 |
|
| 533 |
'void (*free) (void *ptr)' |
| 534 |
This is the function called by ASSUAN to release memory for a |
| 535 |
context. |
| 536 |
|
| 537 |
-- Data type: assuan_malloc_hooks_t |
| 538 |
This is a pointer to a 'struct assuan_malloc_hooks'. |
| 539 |
|
| 540 |
-- Function: void assuan_set_malloc_hooks |
| 541 |
(assuan_malloc_hooks_t MALLOC_HOOKS) |
| 542 |
This function sets the default allocation hooks for new contexts |
| 543 |
allocated with 'assuan_new'. You need to provide all three |
| 544 |
functions. Those functions need to behave exactly as their |
| 545 |
standard counterparts 'malloc', 'realloc' and 'free'. If you write |
| 546 |
your own functions, please take care to set 'errno' whenever an |
| 547 |
error has occurred. |
| 548 |
|
| 549 |
-- Function: assuan_malloc_hooks_t assuan_get_malloc_hooks () |
| 550 |
This function gets the default allocation hooks for new contexts |
| 551 |
allocated with 'assuan_new'. The result structure is statically |
| 552 |
allocated and should not be modified. |
| 553 |
|
| 554 |
The ASSUAN library uses 'libgpg-error' error values, which consist |
| 555 |
and error code and an error source. The default source used by contexts |
| 556 |
allocated with 'assuan_new' can be set with the following function. |
| 557 |
|
| 558 |
-- Function: void assuan_set_gpg_err_source |
| 559 |
(gpg_err_source_t ERR_SOURCE) |
| 560 |
This function sets the default error source for errors generated by |
| 561 |
contexts allocated with 'assuan_new'. |
| 562 |
|
| 563 |
One way to call this function is |
| 564 |
assuan_set_gpg_err_source (GPG_ERR_SOURCE_DEFAULT); |
| 565 |
|
| 566 |
-- Function: gpg_err_source_t assuan_get_gpg_err_source (void) |
| 567 |
This function gets the default error source for errors generated by |
| 568 |
contexts allocated with 'assuan_new'. |
| 569 |
|
| 570 |
To integrate assuan logging and diagnostics into your own logging |
| 571 |
system, you may use the following two functions: |
| 572 |
|
| 573 |
-- Data type: int (*assuan_log_cb_t) (assuan_context_t CTX, |
| 574 |
void *HOOK_VALUE, unsigned int CAT, const char *MSG) |
| 575 |
The user-provided callback function takes a context CTX, for which |
| 576 |
the message MSG was generated, and a hook value HOOK_VALUE that was |
| 577 |
supplied when the log handler was registered for the context with |
| 578 |
'assuan_set_log_cb', and a category CAT. The category is one of: |
| 579 |
|
| 580 |
'ASSUAN_LOG_INIT' |
| 581 |
'ASSUAN_LOG_CTX' |
| 582 |
'ASSUAN_LOG_ENGINE' |
| 583 |
'ASSUAN_LOG_DATA' |
| 584 |
RFU |
| 585 |
'ASSUAN_LOG_SYSIO' |
| 586 |
Log lowlevel I/O data. |
| 587 |
'ASSUAN_LOG_CONTROL' |
| 588 |
Log the control channel. |
| 589 |
|
| 590 |
The user may then, depending on the category, write the message to |
| 591 |
a log file or treat it in some other way. |
| 592 |
|
| 593 |
If MSG is a null pointer, then no message should be logged, but the |
| 594 |
function should return 1 if it is interested in log messages with |
| 595 |
the category CAT. If it is not interested, 0 should be returned. |
| 596 |
This allows 'libassuan' to suppress the generation of expensive |
| 597 |
debug output. |
| 598 |
|
| 599 |
-- Function: void assuan_set_log_cb (assuan_log_cb_t LOG_CB, |
| 600 |
void *LOG_CB_DATA) |
| 601 |
This function sets the default logging handler for log messages |
| 602 |
generated by contexts allocated with 'assuan_new'. |
| 603 |
|
| 604 |
-- Function: void assuan_get_log_cb (assuan_log_cb_t *LOG_CB, |
| 605 |
void **LOG_CB_DATA) |
| 606 |
This function gets the default logging handler for log messages |
| 607 |
generated by contexts allocated with 'assuan_new'. |
| 608 |
|
| 609 |
You do not need to set a log handler, as ASSUAN provides a |
| 610 |
configurable default log handler that should be suitable for most |
| 611 |
purposes. Logging can be disabled completely by setting the log handler |
| 612 |
to a null pointer. |
| 613 |
|
| 614 |
|
| 615 |
File: assuan.info, Node: Default Log Handler, Next: Contexts, Prev: Initializing the library, Up: Generalities |
| 616 |
|
| 617 |
5.3 Default Log Handler |
| 618 |
======================= |
| 619 |
|
| 620 |
The default log handler can be configured by the following functions: |
| 621 |
|
| 622 |
-- Function: void assuan_set_assuan_log_prefix (const char *TEXT) |
| 623 |
Set the prefix to be used at the start of a line emitted by assuan |
| 624 |
on the log stream to TEXT. The default is the empty string. |
| 625 |
|
| 626 |
-- Function: const char * assuan_get_assuan_log_prefix (void) |
| 627 |
Return the prefix to be used at the start of a line emitted by |
| 628 |
assuan on the log stream. The default implementation returns the |
| 629 |
empty string. |
| 630 |
|
| 631 |
-- Function: void assuan_set_assuan_log_stream (FILE *FP) |
| 632 |
This sets the default log stream to which 'libassuan' should log |
| 633 |
messages not associated with a specific context to FP. The default |
| 634 |
is to log to 'stderr'. This default value is also changed by using |
| 635 |
'assuan_set_log_stream' (to set a logging stream for a specific |
| 636 |
context) unless this function has been used. Obviously this is not |
| 637 |
thread-safe and thus it is highly recommended to use this function |
| 638 |
to setup a proper default. |
| 639 |
|
| 640 |
-- Function: FILE * assuan_get_assuan_log_stream (void) |
| 641 |
Return the stream which is currently being using for global |
| 642 |
logging. |
| 643 |
|
| 644 |
The log stream used by the default log handler can also be set on a |
| 645 |
per context basis. |
| 646 |
|
| 647 |
-- Function: void assuan_set_log_stream (assuan_context_t CTX, |
| 648 |
FILE *FP) |
| 649 |
Enable debugging for the context CTX and write all debugging output |
| 650 |
to the stdio stream FP. If the default log stream (used for |
| 651 |
non-context specific events) has not yet been set, a call to this |
| 652 |
functions implicitly sets this stream also to FP. |
| 653 |
|
| 654 |
|
| 655 |
File: assuan.info, Node: Contexts, Next: Reading and Writing, Prev: Default Log Handler, Up: Generalities |
| 656 |
|
| 657 |
5.4 How to work with contexts |
| 658 |
============================= |
| 659 |
|
| 660 |
Some operations work globally on the library, but most operate in a |
| 661 |
context, which saves state across operations. To allow the use of |
| 662 |
'libassuan' in mixed environments, such as in a library using GPGME and |
| 663 |
an application using GPGME, the context is very extensive and covers |
| 664 |
utilitary information like memory allocation callbacks as well as |
| 665 |
specific information associated with client/server operations. |
| 666 |
|
| 667 |
-- Function: gpg_error_t assuan_new (assuan_context_t *CTX_P) |
| 668 |
The function 'assuan_new' creates a new context, using the global |
| 669 |
default memory allocation, log handler and 'libgpg-error' source. |
| 670 |
It is equivalent to |
| 671 |
|
| 672 |
gpg_error_t err; |
| 673 |
assuan_log_cb_t log_cb; |
| 674 |
void *log_cb_data; |
| 675 |
|
| 676 |
assuan_get_log_cb (&log_cb, &log_cb_data); |
| 677 |
err = assuan_new_ext (ctx_p, assuan_get_gpg_err_source (), |
| 678 |
assuan_get_malloc_hooks (), log_cb, log_cb_data); |
| 679 |
|
| 680 |
As you can see, this is not thread-safe. Take care not to modify |
| 681 |
the memory allocation hooks or log callback handler concurrently |
| 682 |
with 'assuan_new'. |
| 683 |
|
| 684 |
The function returns an error if a memory allocation error occurs, |
| 685 |
and 0 with the new context in CTX_P otherwise. |
| 686 |
|
| 687 |
-- Function: gpg_error_t assuan_new_ext (assuan_context_t *CTX_P, |
| 688 |
gpg_err_source_t ERR_SOURCE, |
| 689 |
assuan_malloc_hooks_t MALLOC_HOOKS, assuan_log_cb_t LOG_CB, |
| 690 |
void *LOG_CB_DATA) |
| 691 |
The function 'assuan_new_ext' creates a new context using the |
| 692 |
supplied 'libgpg-error' error source ERR_SOURCE, the memory |
| 693 |
allocation hooks MALLOC_HOOKS and the log handler LOG_CB with the |
| 694 |
user data LOG_CB_DATA. |
| 695 |
|
| 696 |
After the context has been used, it can be destroyed again. |
| 697 |
|
| 698 |
-- Function: void assuan_release (assuan_context_t ctx) |
| 699 |
The function 'assuan_release' destroys the context CTX and releases |
| 700 |
all associated resources. |
| 701 |
|
| 702 |
Other properties of the context beside the memory allocation handler, |
| 703 |
the log handler, and the 'libgpg-error' source can be set after context |
| 704 |
creation. Here are some of them: |
| 705 |
|
| 706 |
-- Function: void assuan_set_pointer (assuan_context_t CTX, |
| 707 |
void *POINTER) |
| 708 |
|
| 709 |
Store the arbitrary pointer value POINTER into the context CTX. |
| 710 |
This is useful to provide command handlers with additional |
| 711 |
application context. |
| 712 |
|
| 713 |
-- Function: void* assuan_get_pointer (assuan_context_t CTX) |
| 714 |
|
| 715 |
This returns the pointer for context CTX which has been set using |
| 716 |
the above function. A common way to use it is by setting the |
| 717 |
pointer before starting the processing loop and to retrieve it |
| 718 |
right at the start of a command handler: |
| 719 |
static int |
| 720 |
cmd_foo (assuan_context_t ctx, char *line) |
| 721 |
{ |
| 722 |
ctrl_t ctrl = assuan_get_pointer (ctx); |
| 723 |
... |
| 724 |
} |
| 725 |
|
| 726 |
-- Function: void assuan_set_flag (assuan_context_t CTX, |
| 727 |
assuan_flag_t FLAG, int VALUE) |
| 728 |
|
| 729 |
Set the the FLAG for context CTX to VALUE. Values for flags are |
| 730 |
usually 1 or 0 but certain flags might need other values. |
| 731 |
|
| 732 |
-- Data type: assuan_flag_t |
| 733 |
The flags are all named and collected in an 'enum' for better |
| 734 |
readability. Available flags are: |
| 735 |
|
| 736 |
'ASSUAN_NO_WAITPID' |
| 737 |
When using a pipe server, by default Libassuan will wait |
| 738 |
for the forked process to die in 'assuan_release'. In |
| 739 |
certain cases this is not desirable. By setting this |
| 740 |
flag, a call to 'waitpid' will be suppressed and the |
| 741 |
caller is responsible to cleanup the child process. |
| 742 |
'ASSUAN_CONFIDENTIAL' |
| 743 |
Use to return the state of the confidential logging mode. |
| 744 |
'ASSUAN_NO_FIXSIGNALS' |
| 745 |
Do not modify signal handler for 'SIGPIPE'. |
| 746 |
'ASSUAN_CONVEY_COMMENTS' |
| 747 |
If enabled comment lines are passed to the status |
| 748 |
callback of the 'assuan_transact'. |
| 749 |
'ASSUAN_FORCE_CLOSE' |
| 750 |
Setting this flag forces the next command to assume that |
| 751 |
the connection has been closed. This breaks the command |
| 752 |
processing loop and may be used as an implicit BYE |
| 753 |
command. VALUE is ignored and thus it is not possible to |
| 754 |
clear this flag. |
| 755 |
|
| 756 |
-- Function: int assuan_get_flag (assuan_context_t CTX, |
| 757 |
assuan_flag_t FLAG) |
| 758 |
Return the value of FLAG in context CTX. |
| 759 |
|
| 760 |
-- Function: void assuan_begin_confidential (assuan_context_t CTX) |
| 761 |
Put the logging feature into confidential mode. This is to avoid |
| 762 |
logging of sensitive data. |
| 763 |
|
| 764 |
This is identical to: |
| 765 |
assuan_set_flag (ctx, ASSUAN_CONFIDENTIAL, 1); |
| 766 |
|
| 767 |
-- Function: void assuan_end_confidential (assuan_context_t CTX) |
| 768 |
Get the logging feature out of confidential mode. All data will be |
| 769 |
logged again (if logging is enabled). |
| 770 |
|
| 771 |
This is identical to: |
| 772 |
assuan_set_flag (ctx, ASSUAN_CONFIDENTIAL, 0); |
| 773 |
|
| 774 |
-- Data type: struct assuan_system_hooks |
| 775 |
This structure is used to store the system callback interface |
| 776 |
functions. It has the following members, whose semantics are |
| 777 |
similar to the corresponding system functions, but not exactly |
| 778 |
equivalent. |
| 779 |
|
| 780 |
'int version' |
| 781 |
The user should set this to 'ASSUAN_SYSTEM_HOOKS_VERSION'. |
| 782 |
This indicates to the library which members of this structure |
| 783 |
are present in case of future extensions. The user should |
| 784 |
initialize the whole structure with zero bytes. |
| 785 |
|
| 786 |
'void (*usleep) (assuan_context_t ctx, unsigned int usec)' |
| 787 |
This is the function called by ASSUAN to sleep for 'USEC' |
| 788 |
microseconds. |
| 789 |
|
| 790 |
'int (*pipe) (assuan_context_t ctx, assuan_fd_t fd[2], int inherit_idx)' |
| 791 |
This is the function called by ASSUAN to create a pipe. The |
| 792 |
returned file descriptor 'fd[inherit_idx]' must be inheritable |
| 793 |
by the child process (under Windows, this requires some extra |
| 794 |
work). |
| 795 |
|
| 796 |
'int (*close) (assuan_context_t ctx, assuan_fd_t fd)' |
| 797 |
This is the function called by ASSUAN to close a file |
| 798 |
descriptor created through the system functions. |
| 799 |
|
| 800 |
'ssize_t (*read) (assuan_context_t ctx, assuan_fd_t fd, void *buffer, size_t size)' |
| 801 |
This is the function called by ASSUAN to read data from a file |
| 802 |
descriptor. It is functionally equivalent to the system |
| 803 |
'read' function. |
| 804 |
|
| 805 |
'ssize_t (*write) (assuan_context_t ctx, assuan_fd_t fd, const void *buffer, size_t size)' |
| 806 |
This is the function called by ASSUAN to write data to a file |
| 807 |
descriptor. It is functionally equivalent to the system |
| 808 |
'write' function. |
| 809 |
|
| 810 |
'int (*recvmsg) (assuan_context_t ctx, assuan_fd_t fd, assuan_msghdr_t msg, int flags)' |
| 811 |
This is the function called by ASSUAN to receive a message |
| 812 |
from a file descriptor. It is functionally equivalent to the |
| 813 |
system 'recvmsg' function. |
| 814 |
|
| 815 |
'int (*sendmsg) (assuan_context_t ctx, assuan_fd_t fd, const assuan_msghdr_t msg, int flags);' |
| 816 |
This is the function called by ASSUAN to send a message to a |
| 817 |
file descriptor. It is functionally equivalent to the system |
| 818 |
'sendmsg' function. |
| 819 |
|
| 820 |
'int (*spawn) (assuan_context_t ctx, assuan_pid_t *r_pid, const char *name, const char **argv, assuan_fd_t fd_in, assuan_fd_t fd_out, assuan_fd_t *fd_child_list, void (*atfork) (void *opaque, int reserved), void *atforkvalue, unsigned int flags)' |
| 821 |
This is the function called by ASSUAN to spawn a child |
| 822 |
process. The 'stdin' and 'stdout' file descriptors are |
| 823 |
provided in 'fd_in' and 'fd_out' respectively, but can be set |
| 824 |
to 'ASSUAN_INVALID_FD', in which case they are set to |
| 825 |
'/dev/null'. On systems which use 'fork' and 'exec', the |
| 826 |
'atfork' function should be called with 'atforkvalue' and '0' |
| 827 |
for flags in the child process right after 'fork' returns. |
| 828 |
'fd_child_list' is a 'ASSUAN_INVALID_FD' terminated array (or |
| 829 |
'NULL') and specifies file descriptors to be inherited by the |
| 830 |
child process. |
| 831 |
|
| 832 |
A special situation occurs if 'name' is a null pointer, in |
| 833 |
which case the process should just fork but not call 'exec'. |
| 834 |
In this case, '*argv' should be set to '"client"' in the |
| 835 |
parent process and '"server"' in the child process. |
| 836 |
|
| 837 |
Flags is the bit-wise OR of some (or none) of the following |
| 838 |
flags: |
| 839 |
|
| 840 |
'ASSUAN_SPAWN_DETACHED' |
| 841 |
If set and there is a need to start the server it will be |
| 842 |
started as a background process. This flag is useful |
| 843 |
under W32 systems, so that no new console is created and |
| 844 |
pops up a console window when starting the server. On |
| 845 |
W32CE systems this flag is ignored. |
| 846 |
|
| 847 |
'assuan_pid_t (*waitpid) (assuan_context_t ctx, assuan_pid_t pid, int action, int *status, int options)' |
| 848 |
This is the function called by ASSUAN to wait for the spawned |
| 849 |
child process PID to exit, or, if ACTION is 1, to just release |
| 850 |
all resources associated with PID (required on Windows |
| 851 |
platforms). If ACTION is 0, this is equivalent to 'waitpid'. |
| 852 |
|
| 853 |
'int (*socketpair) (assuan_context_t ctx, int namespace, int style, int protocol, assuan_fd_t filedes[2])' |
| 854 |
This is the function called by ASSUAN to create a socketpair. |
| 855 |
It is equivalent to 'socketpair'. |
| 856 |
|
| 857 |
-- Function: void assuan_set_system_hooks |
| 858 |
(assuan_system_hooks_t SYSTEM_HOOKS) |
| 859 |
Set the default system hooks to use. There is currently no way to |
| 860 |
reset to the default system hooks. |
| 861 |
|
| 862 |
-- Function: void assuan_sock_set_system_hooks |
| 863 |
(assuan_system_hooks_t SYSTEM_HOOKS) |
| 864 |
The socket subsystem uses an internal context which uses the |
| 865 |
default system hooks. This function allows to change these system |
| 866 |
hooks. The function is not thread-safe and only useful if a |
| 867 |
certain order of assuan and assuan socket initializations are |
| 868 |
required. |
| 869 |
|
| 870 |
-- Function: void assuan_ctx_set_system_hooks (assuan_context_t CTX, |
| 871 |
assuan_system_hooks_t SYSTEM_HOOKS) |
| 872 |
Set the system hooks for context CTX. There is currently no way to |
| 873 |
reset to the default system hooks, create a new context for that. |
| 874 |
|
| 875 |
The following system hook collections are defined by the library for |
| 876 |
your convenience: |
| 877 |
|
| 878 |
'ASSUAN_SYSTEM_NPTH' |
| 879 |
System hooks suitable for use with the nPth library. |
| 880 |
'ASSUAN_SYSTEM_NPTH_IMPL' |
| 881 |
The implementation of system hooks for use with the nPth library. |
| 882 |
This must be invoked once somewhere in the application, and defines |
| 883 |
the structure that is referenced by 'ASSUAN_SYSTEM_NPTH'. |
| 884 |
|
| 885 |
|
| 886 |
File: assuan.info, Node: Reading and Writing, Prev: Contexts, Up: Generalities |
| 887 |
|
| 888 |
5.5 How to communicate with the peer |
| 889 |
==================================== |
| 890 |
|
| 891 |
What would be an IPC library without the ability to read and write data? |
| 892 |
Not very useful. Libassuan has high level functions to take care of of |
| 893 |
the more boring stuff, but eventually data needs to be written and read. |
| 894 |
|
| 895 |
The basic read and write functions are: |
| 896 |
|
| 897 |
-- Function: gpg_error_t assuan_read_line (assuan_context_t CTX, |
| 898 |
char **LINE, size_t *LINELEN) |
| 899 |
|
| 900 |
Read the next line written by the peer to the control channel and |
| 901 |
store a pointer to the buffer holding that line at the address |
| 902 |
LINE. The valid length of the lines is stored at the address of |
| 903 |
LINELEN. This buffer is valid until the next read operation on the |
| 904 |
same context CTX. You may modify the context of this buffer. The |
| 905 |
buffer is invalid (i.e., must not be used) if an error is returned. |
| 906 |
This function returns '0' on success or an error value. |
| 907 |
|
| 908 |
-- Function: gpg_error_t assuan_write_line (assuan_context_t CTX, |
| 909 |
const char *LINE) |
| 910 |
|
| 911 |
Write the string LINE to the other end on the control channel. |
| 912 |
This string needs to be a proper formatted Assuan protocol line and |
| 913 |
should not include a linefeed. Sending linefeed or 'Nul' |
| 914 |
characters is not possible and not allowed by the assuan protocol. |
| 915 |
This function shall not be used for sending data ('D') lines. This |
| 916 |
function returns '0' on success or an error value. |
| 917 |
|
| 918 |
To actually send bulk data lines a specialized function is available: |
| 919 |
|
| 920 |
-- Function: gpg_error_t assuan_send_data (assuan_context_t CTX, |
| 921 |
const void *BUFFER, size_t LENGTH) |
| 922 |
|
| 923 |
This function is used by a server or a client to send LENGTH bytes |
| 924 |
of bulk data in BUFFER to the other end on the control channel. |
| 925 |
The data will be escaped as required by the Assuan protocol and may |
| 926 |
get buffered until a line is full. To flush any pending data, |
| 927 |
BUFFER may be passed as 'NULL' and LENGTH be '0'. |
| 928 |
|
| 929 |
When used by a client, this flush operation does also send the |
| 930 |
'END' command to terminate the response on an 'INQUIRE' request. |
| 931 |
Note that the function 'assuan_transact' takes care of sending this |
| 932 |
'END' itself. |
| 933 |
|
| 934 |
This function returns '0' on success or an error value. |
| 935 |
|
| 936 |
The input and output of data can be controlled at a higher level |
| 937 |
using an I/O monitor. |
| 938 |
|
| 939 |
-- Data type: unsigned int (*assuan_io_monitor_t) |
| 940 |
(assuan_context_t CTX, void *HOOK_VALUE, int INOUT, |
| 941 |
const char *LINE, size_t LINELEN) |
| 942 |
The monitor function is called right after a line has been |
| 943 |
received, if INOUT is 'ASSUAN_IO_FROM_PEER', or just before it is |
| 944 |
send, if INOUT is 'ASSUAN_IO_TO_PEER'. The HOOK_VALUE is provided |
| 945 |
by the user when registering the I/O monitor function with a |
| 946 |
context using 'assuan_set_io_monitor'. The callback function |
| 947 |
should return the bitwise OR of some (or none) of the following |
| 948 |
flags: |
| 949 |
|
| 950 |
'ASSUAN_IO_MONITOR_NOLOG' |
| 951 |
Active logging of this line is suppressed. This can reduce |
| 952 |
debug output in the case of a frequent message. |
| 953 |
'ASSUAN_IO_MONITOR_IGNORE' |
| 954 |
The whole output line is discarded. |
| 955 |
|
| 956 |
-- Function: void assuan_set_io_monitor (assuan_context_t CTX, |
| 957 |
assuan_io_monitor_t IO_MONITOR, void *HOOK_DATA) |
| 958 |
This function registers an I/O monitor IO_MONITOR for the context |
| 959 |
CTX with the hook value HOOK_DATA. |
| 960 |
|
| 961 |
|
| 962 |
File: assuan.info, Node: Client code, Next: Server code, Prev: Generalities, Up: Top |
| 963 |
|
| 964 |
6 How to develop an Assuan client |
| 965 |
********************************* |
| 966 |
|
| 967 |
Depending on the type of the server you want to connect you need to use |
| 968 |
different functions. |
| 969 |
|
| 970 |
If the peer is not a simple pipe server but one using full-duplex |
| 971 |
sockets, the full-fledged variant of the above function should be used: |
| 972 |
|
| 973 |
-- Function: gpg_error_t assuan_pipe_connect |
| 974 |
(assuan_context_t CTX,const char *NAME, const char *ARGV[], |
| 975 |
assuan_fd_t *FD_CHILD_LIST, void (*ATFORK) (void *, int), |
| 976 |
void *ATFORKVALUE, unsigned int FLAGS) |
| 977 |
|
| 978 |
A call to this functions forks the current process and executes the |
| 979 |
program NAME, passing the arguments given in the NULL-terminated |
| 980 |
list ARGV. A list of file descriptors not to be closed may be |
| 981 |
given using the 'ASSUAN_INVALID_FD' terminated array FD_CHILD_LIST. |
| 982 |
|
| 983 |
If NAME is a null pointer, only a fork but no exec is done. Thus |
| 984 |
the child continues to run. However all file descriptors are |
| 985 |
closed and some special environment variables are set. To let the |
| 986 |
caller detect whether the child or the parent continues, the parent |
| 987 |
returns with '"client"' returned in ARGV and the child returns with |
| 988 |
'"server"' in ARGV. This feature is only available on POSIX |
| 989 |
platforms. |
| 990 |
|
| 991 |
If ATFORK is not NULL, this function is called in the child right |
| 992 |
after the fork and the value ATFORKVALUE is passed as the first |
| 993 |
argument. That function should only act if the second argument it |
| 994 |
received is '0'. Such a fork callback is useful to release |
| 995 |
additional resources not to be used by the child. |
| 996 |
|
| 997 |
FLAGS is a bit vector and controls how the function acts: |
| 998 |
|
| 999 |
'ASSUAN_PIPE_CONNECT_FDPASSING' |
| 1000 |
If cleared a simple pipe based server is expected. If set a |
| 1001 |
server based on full-duplex pipes is expected. Such pipes are |
| 1002 |
usually created using the 'socketpair' function. It also |
| 1003 |
enables features only available with such servers. |
| 1004 |
|
| 1005 |
'ASSUAN_PIPE_CONNECT_DETACHED' |
| 1006 |
If set and there is a need to start the server it will be |
| 1007 |
started as a background process. This flag is useful under |
| 1008 |
W32 systems, so that no new console is created and pops up a |
| 1009 |
console window when starting the server. On W32CE systems |
| 1010 |
this flag is ignored. |
| 1011 |
|
| 1012 |
If you are using a long running server listening either on a TCP or a |
| 1013 |
Unix domain socket, the following function is used to connect to the |
| 1014 |
server: |
| 1015 |
|
| 1016 |
-- Function: gpg_error_t assuan_socket_connect (assuan_context_t CTX, |
| 1017 |
const char *NAME, pid_t SERVER_PID, unsigned int FLAGS) |
| 1018 |
|
| 1019 |
Make a connection to the Unix domain socket NAME using the |
| 1020 |
already-initialized Assuan context at CTX. SERVER_PID is currently |
| 1021 |
not used but may become handy in the future; if you don't know the |
| 1022 |
server's process ID (PID), pass 'ASSUAN_INVALID_PID'. With FLAGS |
| 1023 |
set to 'ASSUAN_SOCKET_CONNECT_FDPASSING', 'sendmsg' and 'recvmesg' |
| 1024 |
are used for input and output and thereby enable the use of |
| 1025 |
descriptor passing. |
| 1026 |
|
| 1027 |
Connecting to a TCP server is not yet implemented. Standard URL |
| 1028 |
schemes are reserved for NAME specifying a TCP server. |
| 1029 |
|
| 1030 |
Now that we have a connection to the server, all work may be |
| 1031 |
conveniently done using a couple of callbacks and the transact function: |
| 1032 |
|
| 1033 |
-- Function: gpg_error_t assuan_transact (assuan_context_t CTX, |
| 1034 |
const char *COMMAND, |
| 1035 |
gpg_error_t (*DATA_CB)(void *, const void *, size_t), |
| 1036 |
void *DATA_CB_ARG, |
| 1037 |
gpg_error_t (*INQUIRE_CB)(void*, const char *), |
| 1038 |
void *INQUIRE_CB_ARG, |
| 1039 |
gpg_error_t (*STATUS_CB)(void*, const char *), |
| 1040 |
void *STATUS_CB_ARG) |
| 1041 |
|
| 1042 |
Here CTX is the Assuan context opened by one of the connect calls. |
| 1043 |
COMMAND is the actual Assuan command string. It shall not end with |
| 1044 |
a line feed and its length is limited to 'ASSUAN_LINELENGTH' (~1000 |
| 1045 |
bytes) |
| 1046 |
|
| 1047 |
DATA_CB is called by Libassuan for data lines; DATA_CB_ARG is |
| 1048 |
passed to it along with the data and the length. [FIXME: needs |
| 1049 |
more documentation]. |
| 1050 |
|
| 1051 |
INQUIRE_CB is called by Libassuan when the server requests |
| 1052 |
additional information from the client while processing the |
| 1053 |
command. This callback shall check the provided inquiry name and |
| 1054 |
send the data as requested back using the 'assuan_send_data'. The |
| 1055 |
server passed INQUIRY_CB_ARG along with the inquiry name to the |
| 1056 |
callback. |
| 1057 |
|
| 1058 |
STATUS_CB is called by Libassuan for each status line it receives |
| 1059 |
from the server. STATUS_CB_ARG is passed along with the status |
| 1060 |
line to the callback. |
| 1061 |
|
| 1062 |
The function returns '0' success or an error value. The error |
| 1063 |
value may be the one one returned by the server in error lines or |
| 1064 |
one generated by the callback functions. |
| 1065 |
|
| 1066 |
Libassuan supports descriptor passing on some platforms. The next |
| 1067 |
two functions are used with this feature: |
| 1068 |
|
| 1069 |
-- Function: gpg_error_t assuan_sendfd (assuan_context_t CTX, |
| 1070 |
assuan_fd_t FD) |
| 1071 |
|
| 1072 |
Send the descriptor FD to the peer using the context CTX. The |
| 1073 |
descriptor must be sent before the command is issued that makes use |
| 1074 |
of the descriptor. |
| 1075 |
|
| 1076 |
Note that calling this function with a CTX of 'NULL' and FD of |
| 1077 |
'ASSUAN_INVALID_FD' can be used as a runtime test to check whether |
| 1078 |
descriptor passing is available on the platform: '0' is returned if |
| 1079 |
descriptor passing is available, otherwise an error with the error |
| 1080 |
code 'GPG_ERR_NOT_IMPLEMENTED' is returned. |
| 1081 |
|
| 1082 |
-- Function: gpg_error_t assuan_receivefd (assuan_context_t CTX, |
| 1083 |
assuan_fd_t *FD) |
| 1084 |
|
| 1085 |
Receive a descriptor pending for the context CTX from the peer. |
| 1086 |
The descriptor must be pending before this function is called. To |
| 1087 |
accomplish this, the peer needs to use 'assuan_sendfd' before the |
| 1088 |
trigger is sent (e.g., using 'assuan_write_line ("INPUT FD")'. |
| 1089 |
|
| 1090 |
|
| 1091 |
File: assuan.info, Node: Server code, Next: External I/O Loop, Prev: Client code, Up: Top |
| 1092 |
|
| 1093 |
7 How to develop an Assuan server |
| 1094 |
********************************* |
| 1095 |
|
| 1096 |
Implementing a server for Assuan is a bit more complex than a client. |
| 1097 |
However, it is a straightforward task we are going to explain using a |
| 1098 |
commented example. |
| 1099 |
|
| 1100 |
The list of the implemented server commands is defined by a table like: |
| 1101 |
|
| 1102 |
static struct { |
| 1103 |
const char *name; |
| 1104 |
int (*handler) (assuan_context_t, char *line); |
| 1105 |
} command_table[] = { |
| 1106 |
{ "FOO", cmd_foo }, |
| 1107 |
{ "BAR", cmd_bar }, |
| 1108 |
{ "INPUT", NULL }, |
| 1109 |
{ "OUTPUT", NULL }, |
| 1110 |
{ NULL }}; |
| 1111 |
|
| 1112 |
For convenience this table is usually put after the actual command |
| 1113 |
handlers ('cmd_foo', 'cmd_bar') or even put inside 'command_handler' |
| 1114 |
(see below). Note that the commands 'INPUT' and 'OUTPUT' do not require |
| 1115 |
a handler because Libassuan provides a default handler for them. It is |
| 1116 |
however possible to assign a custom handler. |
| 1117 |
|
| 1118 |
A prerequisite for this example code is that a client has already |
| 1119 |
connected to the server. Often there are two modes combined in one |
| 1120 |
program: A pipe-based server, where a client has forked the server |
| 1121 |
process, or a Unix domain socket based server that is listening on the |
| 1122 |
socket. |
| 1123 |
|
| 1124 |
void |
| 1125 |
command_handler (int fd) |
| 1126 |
{ |
| 1127 |
gpg_error_t rc; |
| 1128 |
int i; |
| 1129 |
assuan_context_t ctx; |
| 1130 |
|
| 1131 |
rc = assuan_new (&ctx); |
| 1132 |
if (rc) |
| 1133 |
{ |
| 1134 |
fprintf (stderr, "server context creation failed: %s\n", |
| 1135 |
gpg_strerror(rc)); |
| 1136 |
return; |
| 1137 |
} |
| 1138 |
|
| 1139 |
if (fd == -1) |
| 1140 |
{ |
| 1141 |
assuan_fd_t filedes[2]; |
| 1142 |
|
| 1143 |
filedes[0] = assuan_fd_from_posix_fd (0); |
| 1144 |
filedes[1] = assuan_fd_from_posix_fd (1); |
| 1145 |
rc = assuan_init_pipe_server (ctx, filedes); |
| 1146 |
} |
| 1147 |
else |
| 1148 |
rc = assuan_init_socket_server (ctx, fd, ASSUAN_SOCKET_SERVER_ACCEPTED); |
| 1149 |
if (rc) |
| 1150 |
{ |
| 1151 |
fprintf (stderr, "server init failed: %s\n", gpg_strerror (rc)); |
| 1152 |
return; |
| 1153 |
} |
| 1154 |
|
| 1155 |
This is the first part of the command handler. We start off by |
| 1156 |
allocating a new Assuan context with 'assuan_new'. *Note function |
| 1157 |
assuan_new::. |
| 1158 |
|
| 1159 |
In case this is called as a pipe based server, FD will be based as FD |
| 1160 |
and the code assumes that the server's 'stdin' and 'stdout' file handles |
| 1161 |
are connected to a pipe. The initialization is thus done using the |
| 1162 |
function: |
| 1163 |
|
| 1164 |
-- Function: gpg_error_t assuan_init_pipe_server (assuan_context_t CTX, |
| 1165 |
assuan_fd_t FILEDES[2]) |
| 1166 |
|
| 1167 |
This function takes the two file descriptors from FILEDES and |
| 1168 |
returns a new Assuan context at R_CTX. As usual, a return value of |
| 1169 |
'0' indicates success and a failure is indicated by returning an |
| 1170 |
error value. In case of error, 'NULL' will be stored at R_CTX. |
| 1171 |
|
| 1172 |
In case the server has been called using a bi-directional pipe |
| 1173 |
(socketpair), FILEDES is ignored and the file descriptor is taken |
| 1174 |
from the environment variable '_assuan_connection_fd'. You |
| 1175 |
generally don't need to know this, because 'assuan_pipe_connect', |
| 1176 |
which is called by the client to connect to such a server, |
| 1177 |
automagically sets this variable. |
| 1178 |
|
| 1179 |
-- Function: gpg_error_t assuan_init_socket_server |
| 1180 |
(assuan_context_t CTX, assuan_fd_t FD, unsigned int FLAGS) |
| 1181 |
|
| 1182 |
This function takes the file descriptor FD, which is expected to be |
| 1183 |
associated with a socket, and an Assuan context CTX. The following |
| 1184 |
bits are currently defined for FLAGS: |
| 1185 |
|
| 1186 |
'ASSUAN_SOCKET_SERVER_FDPASSING' |
| 1187 |
If set, 'sendmsg' and 'recvmesg' are used for input and |
| 1188 |
output, which enables the use of descriptor passing. |
| 1189 |
'ASSUAN_SOCKET_SERVER_ACCEPTED' |
| 1190 |
If set, FD refers to an already accepted socket. That is, |
| 1191 |
Libassuan won't call ACCEPT for it. It is suggested to set |
| 1192 |
this bit as it allows better control of the connection state. |
| 1193 |
|
| 1194 |
As usual, a return value of '0' indicates success and a failure is |
| 1195 |
indicated by returning an error value. |
| 1196 |
|
| 1197 |
On the Windows platform the following function needs to be called after |
| 1198 |
'assuan_init_socket_server': |
| 1199 |
|
| 1200 |
-- Function: void assuan_set_sock_nonce ( assuan_context_t CTX, |
| 1201 |
assuan_sock_nonce_t *NONCE) |
| 1202 |
|
| 1203 |
Save a copy of NONCE in context CTX. This should be used to |
| 1204 |
register the server's nonce with a context established by |
| 1205 |
'assuan_init_socket_server'. It is technically only needed for |
| 1206 |
Windows, but it does no harm to use it on other systems. |
| 1207 |
|
| 1208 |
After error checking, the implemented assuan commands are registered |
| 1209 |
with the server. |
| 1210 |
|
| 1211 |
for (i = 0; command_table[i].name; i++) |
| 1212 |
{ |
| 1213 |
rc = assuan_register_command (ctx, |
| 1214 |
command_table[i].name, |
| 1215 |
command_table[i].handler, NULL); |
| 1216 |
if (rc) |
| 1217 |
{ |
| 1218 |
fprintf (stderr, "register failed: %s\n", gpg_strerror (rc)); |
| 1219 |
assuan_release (ctx); |
| 1220 |
return; |
| 1221 |
} |
| 1222 |
} |
| 1223 |
|
| 1224 |
-- Data type: gpg_error_t (*assuan_handler_t) (assuan_context_t CTX, |
| 1225 |
char *LINE) |
| 1226 |
This is the function invoked by ASSUAN for various command related |
| 1227 |
callback functions. Some of these callback functions have a |
| 1228 |
different type, but most use 'assuan_handler_t'. |
| 1229 |
|
| 1230 |
-- Function: gpg_error_t assuan_register_command (assuan_context_t CTX, |
| 1231 |
const char *CMD_STRING, assuan_handler_t HANDLER, |
| 1232 |
const char *HELP_STRING) |
| 1233 |
|
| 1234 |
This registers the command named CMD_STRING with the Assuan context |
| 1235 |
CTX. HANDLER is the function called by Libassuan if this command |
| 1236 |
is received from the client. NULL may be used for HANDLER to use a |
| 1237 |
default handler (this only works with a few pre-defined commands). |
| 1238 |
Note that several default handlers have already been registered |
| 1239 |
when the context has been created: 'NOP', 'CANCEL', 'OPTION', |
| 1240 |
'BYE', 'AUTH', 'RESET' and 'END'. It is possible, but not |
| 1241 |
recommended, to override these commands. |
| 1242 |
|
| 1243 |
HELP_STRING is a help string that is used for automatic |
| 1244 |
documentation. It should contain a usage line followed by an empty |
| 1245 |
line and a complete description. |
| 1246 |
|
| 1247 |
-- Function: gpg_error_t assuan_register_post_cmd_notify |
| 1248 |
(assuan_context_t CTX, void (*FNC)(assuan_context_t), |
| 1249 |
gpg_error_t ERR) |
| 1250 |
|
| 1251 |
Register a function to be called right after a command has been |
| 1252 |
processed. ERR is the result code from the last internal assuan |
| 1253 |
operation and not the one returned by the handler. It may be used |
| 1254 |
for command-related cleanup. |
| 1255 |
|
| 1256 |
-- Function: gpg_error_t assuan_register_bye_notify |
| 1257 |
(assuan_context_t CTX, assuan_handler_t HANDLER) |
| 1258 |
|
| 1259 |
Register function FNC with context CTX to be called right before |
| 1260 |
the standard handler for the 'BYE' command is being called. |
| 1261 |
|
| 1262 |
-- Function: gpg_error_t assuan_register_reset_notify |
| 1263 |
(assuan_context_t CTX, assuan_handler_t HANDLER) |
| 1264 |
|
| 1265 |
Register function FNC with context CTX to be called right before |
| 1266 |
the standard handler for the 'RESET' command is being called. |
| 1267 |
|
| 1268 |
-- Function: gpg_error_t assuan_register_cancel_notify |
| 1269 |
(assuan_context_t CTX, assuan_handler_t HANDLER) |
| 1270 |
|
| 1271 |
Register function FNC with context CTX to be called right before |
| 1272 |
the standard handler for the 'RESET' command is being called. |
| 1273 |
|
| 1274 |
-- Function: gpg_error_t assuan_register_option_handler |
| 1275 |
(assuan_context_t CTX, |
| 1276 |
gpg_error_t (*FNC)(assuan_context_t, const char*, const char*)) |
| 1277 |
|
| 1278 |
Register function FNC with context CTX for processing options. |
| 1279 |
That function is being called with the context, the name and the |
| 1280 |
value of the option. Leading and trailing spaces are removed from |
| 1281 |
the name and the value. The optional leading two dashes of the |
| 1282 |
name are removed as well. If no value has been given, an empty |
| 1283 |
string is passed. The function needs to return '0' on success or |
| 1284 |
an error code. |
| 1285 |
|
| 1286 |
-- Function: gpg_error_t assuan_register_input_notify |
| 1287 |
(assuan_context_t CTX, assuan_handler_t HANDLER) |
| 1288 |
|
| 1289 |
Although the input function may be overridden with a custom |
| 1290 |
handler, it is often more convenient to use the default handler and |
| 1291 |
to know whether an 'INPUT' command has been seen and successfully |
| 1292 |
parsed. The second argument passed to that function is the entire |
| 1293 |
line. Because that line has already been parsed when the function |
| 1294 |
gets called, a file descriptor set with the 'INPUT' command may |
| 1295 |
already be used. That file descriptor is available by calling |
| 1296 |
'assuan_get_input_fd'. If the notification function returns an |
| 1297 |
error, the input fd does not change. |
| 1298 |
|
| 1299 |
-- Function: gpg_error_t assuan_register_output_notify |
| 1300 |
(assuan_context_t CTX, assuan_handler_t HANDLER) |
| 1301 |
|
| 1302 |
Although the output function may be overridden with a custom |
| 1303 |
handler, it is often more convenient to use the default handler and |
| 1304 |
to know whether an 'OUTPUT' command has been seen and successfully |
| 1305 |
parsed. The second argument passed to that function is the entire |
| 1306 |
line. Because that line has already been parsed when the function |
| 1307 |
gets called, a file descriptor set with the 'OUTPUT' command may |
| 1308 |
already be used. That file descriptor is available by calling |
| 1309 |
'assuan_get_output_fd'. If the notification function returns an |
| 1310 |
error, the output fd does not change. |
| 1311 |
|
| 1312 |
-- Function: gpg_error_t assuan_set_hello_line (assuan_context_t CTX, |
| 1313 |
const char *LINE) |
| 1314 |
|
| 1315 |
This is not actually a register function but may be called also |
| 1316 |
after registering commands. It changes the "Hello" line, sent by |
| 1317 |
the server to the client as a first response, from a default string |
| 1318 |
to the string LINE. For logging purposes, it is often useful to |
| 1319 |
use such a custom hello line which may tell version numbers and |
| 1320 |
such. Linefeeds are allowed in this string, however, each line |
| 1321 |
needs to be shorter than the Assuan line length limit. |
| 1322 |
|
| 1323 |
Now that everything has been setup, we can start to process our clients |
| 1324 |
requests. |
| 1325 |
|
| 1326 |
for (;;) |
| 1327 |
{ |
| 1328 |
rc = assuan_accept (ctx); |
| 1329 |
if (rc == -1) |
| 1330 |
break; |
| 1331 |
else if (rc) |
| 1332 |
{ |
| 1333 |
fprintf (stderr, "accept problem: %s\n", gpg_strerror (rc)); |
| 1334 |
break; |
| 1335 |
} |
| 1336 |
|
| 1337 |
rc = assuan_process (ctx); |
| 1338 |
if (rc) |
| 1339 |
{ |
| 1340 |
fprintf (stderr, "processing failed: %s\n", gpg_strerror (rc)); |
| 1341 |
continue; |
| 1342 |
} |
| 1343 |
} |
| 1344 |
assuan_release (ctx); |
| 1345 |
} |
| 1346 |
|
| 1347 |
For future extensibility and to properly detect the end of the |
| 1348 |
connection the core of the server should loop over the accept and |
| 1349 |
process calls. |
| 1350 |
|
| 1351 |
-- Function: gpg_error_t assuan_accept (assuan_context_t CTX) |
| 1352 |
|
| 1353 |
A call to this function cancel any existing connection and waits |
| 1354 |
for a connection from a client (that might be skipped, depending on |
| 1355 |
the type of the server). The initial handshake is performed which |
| 1356 |
may include an initial authentication or encryption negotiation. |
| 1357 |
On success '0' is returned. An error value will be returned if the |
| 1358 |
connection could for some reason not be established. An error code |
| 1359 |
of 'GPG_ERR_EOF' indicates the end of the connection. |
| 1360 |
|
| 1361 |
-- Function: gpg_error_t assuan_process (assuan_context_t CTX) |
| 1362 |
|
| 1363 |
This function is used to handle the Assuan protocol after a |
| 1364 |
connection has been established using 'assuan_accept'. It is the |
| 1365 |
main protocol handler responsible for reading the client commands |
| 1366 |
and calling the appropriate handlers. The function returns '0' on |
| 1367 |
success or an error value if something went seriously wrong. Error |
| 1368 |
values from the individual command handlers, i.e., operational |
| 1369 |
error, are not seen here. |
| 1370 |
|
| 1371 |
That is all needed for the server code. You only need to come up with |
| 1372 |
the code for the individual command handlers. Take care that the line |
| 1373 |
passed to the command handlers is allocated statically within the |
| 1374 |
context and calls to Assuan functions may modify that line. You are |
| 1375 |
also allowed to modify that line which makes parsing much easier. |
| 1376 |
|
| 1377 |
|
| 1378 |
File: assuan.info, Node: External I/O Loop, Next: Utilities, Prev: Server code, Up: Top |
| 1379 |
|
| 1380 |
8 How to use external I/O event loops |
| 1381 |
************************************* |
| 1382 |
|
| 1383 |
The above implementations of an Assuan client and server are |
| 1384 |
synchronous, insofar as the main routines block until a request or |
| 1385 |
client connection is completely processed. In some programs, for |
| 1386 |
example GUI applications, this is undesirable. Instead, Assuan |
| 1387 |
operations should be non-blocking, and the caller should be able to poll |
| 1388 |
all involved file descriptors to determine when the next Assuan function |
| 1389 |
can be invoked without blocking. |
| 1390 |
|
| 1391 |
To make this possible, client and server have to adhere to some |
| 1392 |
rules: |
| 1393 |
* Either partner should always write full lines. If partial lines |
| 1394 |
are written, the remainder of the line should be sent without |
| 1395 |
delay. |
| 1396 |
* Either partner should eagerly receive status messages. While |
| 1397 |
receiving and sending bulk data may be delayed, the status |
| 1398 |
communication channel is different: Both partners may send status |
| 1399 |
messages in blocking mode at any time the protocol allows them to |
| 1400 |
send such status messages. To ensure that these send operations do |
| 1401 |
not actually block the sender, the recipient must be ready to |
| 1402 |
receive without undue delay. |
| 1403 |
* If descriptor passing is used over a socket, the descriptor must be |
| 1404 |
sent after the corresponding command without undue delay. |
| 1405 |
|
| 1406 |
Together, these restrictions allow to limit the need for asynchronous |
| 1407 |
I/O operations to bulk data and the inbound status file descriptor. |
| 1408 |
|
| 1409 |
In addition to the above rules, client and server should adhere to |
| 1410 |
the following implementation guidelines. |
| 1411 |
|
| 1412 |
* Menu: |
| 1413 |
|
| 1414 |
* External I/O Loop Client:: External I/O event loops in the client. |
| 1415 |
* External I/O Loop Server:: External I/O event loops in the server. |
| 1416 |
|
| 1417 |
|
| 1418 |
File: assuan.info, Node: External I/O Loop Client, Next: External I/O Loop Server, Up: External I/O Loop |
| 1419 |
|
| 1420 |
8.1 External I/O event loops in the client. |
| 1421 |
=========================================== |
| 1422 |
|
| 1423 |
The reference implementation for using external I/O event loops in the |
| 1424 |
client is the GPGME library, which exports its own external I/O event |
| 1425 |
loop mechanism and utilizes the Assuan library transparently for the |
| 1426 |
user. The following steps document how GPGME achieves this. |
| 1427 |
|
| 1428 |
1. Before connecting, set up pipes for bulk data transfer (using the |
| 1429 |
INPUT/OUTPUT commands, for example). These are passed to the |
| 1430 |
server either by inheritance (using a pipe server) or by FD passing |
| 1431 |
(using a socket server). |
| 1432 |
|
| 1433 |
2. Then you need to connect to the server. GPGME uses a pipe server, |
| 1434 |
so it just spawns a server process, which is a non-blocking |
| 1435 |
operation. FIXME: Currently, using a client with external event |
| 1436 |
loop over a socket connection is not supported. It is easy to |
| 1437 |
support (we just need a variation of 'assuan_socket_connect' which |
| 1438 |
takes an already connected socket FD and turns it into an Assuan |
| 1439 |
context), so if you need this let us know. |
| 1440 |
|
| 1441 |
3. After connecting, get the inbound status FD with |
| 1442 |
'assuan_get_active_fds' (the first one returned is the status FD). |
| 1443 |
This FD can be duplicated if it is convenient (GPGME does this to |
| 1444 |
be able to close this FD and associated callback handlers without |
| 1445 |
disrupting Assuan's internals). |
| 1446 |
|
| 1447 |
4. Then register the Assuan inbound status FD and all bulk data FDs |
| 1448 |
with the I/O event mechanism. In general, this requires setting up |
| 1449 |
callback handlers for these FDs and registering them with the main |
| 1450 |
event loop. |
| 1451 |
|
| 1452 |
5. When bulk data FDs become ready, you can simply perform the |
| 1453 |
corresponding read or write operations. When the inbound status FD |
| 1454 |
becomes ready, you can receive the next server line with |
| 1455 |
assuan_read_line(). |
| 1456 |
|
| 1457 |
6. You should close and unregister the bulk data FDs when you wrote |
| 1458 |
all data (for outbound FDs) or receive an EOF (for inbound FDs). |
| 1459 |
When you receive an ERR from the server, or an OK for the final |
| 1460 |
operation, you can unregister the inbound status FD and call |
| 1461 |
'assuan_release'. |
| 1462 |
|
| 1463 |
7. As noted above, all send operations on the outbound status FD are |
| 1464 |
done immediate with blocking. In GPGME, this has never caused any |
| 1465 |
problems. |
| 1466 |
|
| 1467 |
8. The 'INQUIRE' function can be handled in two ways: If the requested |
| 1468 |
data is immediately available, the client can just send the data |
| 1469 |
blockingly. If the requested data needs to be fetched from a |
| 1470 |
blocking source, a callback handler can be registered for the FD |
| 1471 |
with the main event loop. GPGME does not support the 'INQUIRE' |
| 1472 |
function, so we do not have any practical experience with this. |
| 1473 |
|
| 1474 |
Currently, the client can not cancel a pending operation gracefully. |
| 1475 |
It can, however, disconnect from the server at any time. It is the |
| 1476 |
responsibility of the server to periodically send status messages to the |
| 1477 |
client to probe if the connection remains alive. |
| 1478 |
|
| 1479 |
|
| 1480 |
File: assuan.info, Node: External I/O Loop Server, Prev: External I/O Loop Client, Up: External I/O Loop |
| 1481 |
|
| 1482 |
8.2 External I/O event loops in the server. |
| 1483 |
=========================================== |
| 1484 |
|
| 1485 |
Currently, no Assuan server exists which uses external I/O event loops. |
| 1486 |
However, the following guidelines should lead to a usable |
| 1487 |
implementation: |
| 1488 |
|
| 1489 |
1. For socket servers: You can not use 'assuan_accept', so you should |
| 1490 |
just implement the bind/connect/listen/accept stage yourself. You |
| 1491 |
can register the listen FD with your main event loop, accept the |
| 1492 |
connection when it becomes ready, and finally call |
| 1493 |
'assuan_init_socket_server' with the final argument being |
| 1494 |
'ASSUAN_SOCKET_SERVER_ACCEPTED' to create an Assuan context for |
| 1495 |
this connection. This way you can also handle multiple connections |
| 1496 |
in parallel. The reference implementation for this approach is |
| 1497 |
DirMngr. |
| 1498 |
|
| 1499 |
For pipe servers: 'assuan_init_pipe_server' creates an Assuan |
| 1500 |
context valid for the pipe FDs. |
| 1501 |
|
| 1502 |
2. Once you have a context for a single connection, you can get the |
| 1503 |
inbound status FD with 'assuan_get_active_fds' (the first one |
| 1504 |
returned is the status FD). This FD can be duplicated if it is |
| 1505 |
convenient. Every time the inbound status FD is readable, you |
| 1506 |
should invoke the function 'assuan_process_next' (see below) to |
| 1507 |
process the next incoming message. 'assuan_process_next' processes |
| 1508 |
as many status lines as can be received by a single 'read' |
| 1509 |
operation. When it returns, the inbound status FD may still be |
| 1510 |
readable, but Assuan does not check this. |
| 1511 |
|
| 1512 |
The function 'assuan_process_next' returns 0 if it can not make |
| 1513 |
progress reliably, and it returns true in 'done' if the client |
| 1514 |
closed the connection. See below for more information on this |
| 1515 |
function. |
| 1516 |
|
| 1517 |
3. The command will be dispatched by 'assuan_process_next' just as |
| 1518 |
with 'assuan_process', however, you will want to implement the |
| 1519 |
command handlers in such a way that they do not block. For |
| 1520 |
example, the command handler may just register the bulk data FDs |
| 1521 |
with the main event loop and return. |
| 1522 |
|
| 1523 |
When the command is finished, irregardless if this happens directly |
| 1524 |
in the command handler or later, you must call |
| 1525 |
'assuan_process_done' with an appropriate error value (or 0 for |
| 1526 |
success) to return an appropriate status line to the client. You |
| 1527 |
can do this at the end of the command handler, for example by |
| 1528 |
ending it with 'return assuan_process_done (error_code);'. Another |
| 1529 |
possibility is to invoke 'assuan_process_done' from the place in |
| 1530 |
the code which closes the last active bulk FD registered with the |
| 1531 |
main event loop for this operation. |
| 1532 |
|
| 1533 |
It is not possible to use 'assuan_inquire' in a command handler, as |
| 1534 |
this function blocks on receiving the inquired data from the client. |
| 1535 |
Instead, the asynchronous version 'assuan_inquire_ext' needs to be used |
| 1536 |
(see below), which invokes a callback when the client provided the |
| 1537 |
inquired data. A typical usage would be for the command handler to |
| 1538 |
register a continuation with 'assuan_inquire_ext' and return 0. |
| 1539 |
Eventually, the continuation would be invoked by 'assuan_process_next' |
| 1540 |
when the client data arrived. The continuation could complete the |
| 1541 |
command and eventually call 'assuan_process_done'. |
| 1542 |
|
| 1543 |
Cancellation is supported by returning an appropriate error value to |
| 1544 |
the client with 'assuan_process_done'. For long running operations, the |
| 1545 |
server should send progress status messages to the client in regular |
| 1546 |
intervals to notice when the client disconnects. |
| 1547 |
|
| 1548 |
-- Function: gpg_error_t assuan_process_next (assuan_context_t CTX, |
| 1549 |
int *DONE) |
| 1550 |
This is the same as 'assuan_process' but the caller has to provide |
| 1551 |
the outer loop. He should loop as long as the return code is zero |
| 1552 |
and DONE is false. |
| 1553 |
|
| 1554 |
-- Function: gpg_error_t assuan_process_done (assuan_context_t CTX, |
| 1555 |
gpg_error_t RC) |
| 1556 |
Finish a pending command and return the error code RC to the |
| 1557 |
client. |
| 1558 |
|
| 1559 |
-- Function: gpg_error_t assuan_inquire_ext (assuan_context_t CTX, |
| 1560 |
const char *KEYWORD, size_t MAXLEN, |
| 1561 |
gpg_error_t (*CB) (void *cb_data, gpg_error_t rc, unsigned char *buffer, size_t buffer_len), |
| 1562 |
void *CB_DATA) |
| 1563 |
This is similar to 'assuan_inquire' but the caller has to provide |
| 1564 |
the outer loop (using 'assuan_process_next'). The caller should |
| 1565 |
specify a continuation with CB, which receives CB_DATA as its first |
| 1566 |
argument, and the error value as well as the inquired data as its |
| 1567 |
remaining arguments. |
| 1568 |
|
| 1569 |
|
| 1570 |
File: assuan.info, Node: Utilities, Next: Socket wrappers, Prev: External I/O Loop, Up: Top |
| 1571 |
|
| 1572 |
9 Utility functions |
| 1573 |
******************* |
| 1574 |
|
| 1575 |
There are a lot of helper functions to make writing Assuan code easier. |
| 1576 |
Some of these functions provide information not available with the |
| 1577 |
general functions. |
| 1578 |
|
| 1579 |
-- Function: gpg_error_t assuan_write_status (assuan_context_t CTX, |
| 1580 |
const char *KEYWORD, const char *TEXT) |
| 1581 |
|
| 1582 |
This is a convenience function for a server to send a status line. |
| 1583 |
You need to pass it the KEYWORD and the content of the status line |
| 1584 |
in TEXT. |
| 1585 |
|
| 1586 |
-- Function: gpg_error_t assuan_inquire (assuan_context_t CTX, |
| 1587 |
const char *KEYWORD, unsigned char **R_BUFFER, |
| 1588 |
size_t *R_LENGTH, size_t MAXLEN) |
| 1589 |
|
| 1590 |
A server may use this function to request specific data from a |
| 1591 |
client. This function sends an 'INQUIRE' command back to the |
| 1592 |
client and returns the client's response in a newly allocated |
| 1593 |
buffer. You need to pass at least the server's context (CTX) and a |
| 1594 |
description of the required data (KEYWORD). All other parameters |
| 1595 |
may be 'NULL' or '0', but this is rarely useful. |
| 1596 |
|
| 1597 |
On success the result is stored in a newly allocated buffer stored |
| 1598 |
at R_BUFFER. The length of the data is stored at R_LENGTH. If |
| 1599 |
MAXLEN has not been given as '0', it specifies an upper size limit |
| 1600 |
of the expected data. If the client returns too much data the |
| 1601 |
function fails and an error with the error code |
| 1602 |
'GPG_ERR_ASS_TOO_MUCH_DATA' will be returned. |
| 1603 |
|
| 1604 |
-- Function: FILE* assuan_get_data_fp (assuan_context_t CTX) |
| 1605 |
|
| 1606 |
Return a stdio stream for the Assuan context CTX. This stream may |
| 1607 |
then be used for data output (assuan_write_data). The stream is |
| 1608 |
valid until the end of the current handler. Calling 'fclose' for |
| 1609 |
that stream is not required. Assuan does all the buffering needed |
| 1610 |
to insert the status line as well as the required line wrapping and |
| 1611 |
quoting for data lines. |
| 1612 |
|
| 1613 |
This function is only available on systems supporting either |
| 1614 |
'funopen' or 'fopencookie'. If it is not supported 'NULL' is |
| 1615 |
returned and 'errno' is set to 'ENOSYS'. |
| 1616 |
|
| 1617 |
-- Function: gpg_error_t assuan_set_okay_line (assuan_context_t CTX, |
| 1618 |
const char *LINE) |
| 1619 |
|
| 1620 |
Set the text used for the next 'OK' response to LINE. This is |
| 1621 |
sometimes useful to send additional human readable information |
| 1622 |
along with the OK line. The string is automatically reset at the |
| 1623 |
end of the current handler. |
| 1624 |
|
| 1625 |
-- Function: gpg_error_t assuan_command_parse_fd (assuan_context_t CTX, |
| 1626 |
char *LINE, assuan_fd_t *RFD) |
| 1627 |
|
| 1628 |
This is the core of the default 'INPUT' and 'OUTPUT' handler. It |
| 1629 |
may be used in custom commands as well to negotiate a file |
| 1630 |
descriptor. If LINE contains 'FD=N', it returns N in RFD assuming |
| 1631 |
a local file descriptor. If LINE contains just 'FD' it returns a |
| 1632 |
file descriptor at RFD; this file descriptor needs to have been |
| 1633 |
sent by the client right before using 'assuan_sendfd'. |
| 1634 |
|
| 1635 |
On W32 systems the returned file descriptor is a system handle and |
| 1636 |
not a libc low level I/O file descriptor. Thus applications need |
| 1637 |
to use '_open_osfhandle' before they can pass this descriptor to |
| 1638 |
standard functions like 'fdopen' or 'dup'. |
| 1639 |
|
| 1640 |
-- Function: const char * assuan_get_command_name |
| 1641 |
(assuan_context_t CTX) |
| 1642 |
|
| 1643 |
Return the name of the command currently processed by a handler. |
| 1644 |
The returned string is valid until the next call to an Assuan |
| 1645 |
function on the same context. Returns 'NULL' if no handler is |
| 1646 |
executed or the command is not known. |
| 1647 |
|
| 1648 |
-- Function: assuan_fd_t assuan_get_input_fd (assuan_context_t CTX) |
| 1649 |
|
| 1650 |
Return the file descriptor sent by the client using the last |
| 1651 |
'INPUT' command. Returns 'ASSUAN_INVALID_FD' if no file descriptor |
| 1652 |
is available. |
| 1653 |
|
| 1654 |
-- Function: assuan_fd_t assuan_get_output_fd (assuan_context_t CTX) |
| 1655 |
|
| 1656 |
Return the file descriptor sent by the client using the last |
| 1657 |
'OUTPUT' command. Returns 'ASSUAN_INVALID_FD' if no file |
| 1658 |
descriptor is available. |
| 1659 |
|
| 1660 |
-- Function: gpg_error_t assuan_close_input_fd (assuan_context_t CTX) |
| 1661 |
|
| 1662 |
Close the file descriptor set by the last 'INPUT' command. This |
| 1663 |
function has the advantage over a simple 'close' that it can do |
| 1664 |
some sanity checks and make sure that a following |
| 1665 |
'assuan_get_input_fd' won't return an already closed descriptor. |
| 1666 |
|
| 1667 |
-- Function: gpg_error_t assuan_close_output_fd (assuan_context_t CTX) |
| 1668 |
|
| 1669 |
Close the file descriptor set by the last 'OUTPUT' command. This |
| 1670 |
function has the advantage over a simple 'close' that it can do |
| 1671 |
some sanity checks and make sure that a following |
| 1672 |
'assuan_get_input_fd' won't return an already closed descriptor. |
| 1673 |
|
| 1674 |
-- Function: gpg_error_t assuan_set_error (assuan_context_t CTX, |
| 1675 |
gpg_error_t ERR, const char *TEXT) |
| 1676 |
This is a helper to provide a more descriptive error text with |
| 1677 |
'ERR' lines. For this to work, the text needs to be stored in the |
| 1678 |
context CTX while still being in the command handler. This |
| 1679 |
function is commonly called this way |
| 1680 |
return assuan_set_error (ctx, err, "commands needs 5 arguments"); |
| 1681 |
The value ERR is passed through and thus the return value of the |
| 1682 |
command handler in the example. The provided text further explains |
| 1683 |
that error to humans. |
| 1684 |
|
| 1685 |
-- Function: pid_t assuan_get_pid (assuan_context_t CTX) |
| 1686 |
|
| 1687 |
This function returns the pid of the connected connected peer. If |
| 1688 |
that pid is not known 'ASSUAN_INVALID_PID' is returned. Note that |
| 1689 |
it is not always possible to learn the pid of the other process. |
| 1690 |
For a pipe based server the client knows it instantly and a |
| 1691 |
mechanism is in place to let the server learn it. For socket based |
| 1692 |
servers the pid is only available on systems providing the |
| 1693 |
'SO_PEERCRED' socket option (1). |
| 1694 |
|
| 1695 |
-- Data type: assuan_peercred_t |
| 1696 |
This structure is used to store the peer credentials. The |
| 1697 |
available members depend on the operating system. |
| 1698 |
|
| 1699 |
'pid_t pid' |
| 1700 |
The process ID of the peer. |
| 1701 |
|
| 1702 |
'uid_t uid' |
| 1703 |
The user ID of the peer process. |
| 1704 |
|
| 1705 |
'gid_t gid' |
| 1706 |
The group ID of the peer process. |
| 1707 |
|
| 1708 |
-- Function: gpg_error_t assuan_get_peercred (assuan_context_t CTX, |
| 1709 |
assuan_peercred_t *PEERCRED) |
| 1710 |
Return user credentials of the peer. This will work only on |
| 1711 |
certain systems and only when connected over a socket. On success, |
| 1712 |
a pointer to the peer credentials is stored in PEERCRED. The |
| 1713 |
information is only valid as long as the state of the connection is |
| 1714 |
unchanged (at least until the next assuan call to the same |
| 1715 |
context). |
| 1716 |
|
| 1717 |
As of now only the server is able to retrieve this information. |
| 1718 |
Note, that for getting the pid of the peer 'assuan_get_pid' is |
| 1719 |
usually better suited. |
| 1720 |
|
| 1721 |
-- Function: int assuan_get_active_fds (assuan_context_t CTX, int WHAT, |
| 1722 |
assuan_fd_t *FDARRAY, int FDARRAYSIZE) |
| 1723 |
|
| 1724 |
Return all active file descriptors for the context CTX. This |
| 1725 |
function can be used to select on the file descriptors and to call |
| 1726 |
'assuan_process_next' if there is an active one. The first |
| 1727 |
descriptor in the array is the one used for the command connection. |
| 1728 |
Currently WHAT needs to be '0' to return descriptors used for |
| 1729 |
reading, '1' will eventually be used to return descriptors used for |
| 1730 |
writing. FDARRAY is an array of integers provided by the caller; |
| 1731 |
FDARRAYSIZE gives the size of that array. |
| 1732 |
|
| 1733 |
On success the number of active descriptors are returned. These |
| 1734 |
active descriptors are then stored in FDARRAY. On error '-1' is |
| 1735 |
returned; the most likely reason for this is a too small FDARRAY. |
| 1736 |
|
| 1737 |
Note that on W32 systems the returned file descriptor is a system |
| 1738 |
handle and not a libc low level I/O file descriptor. |
| 1739 |
|
| 1740 |
-- Function: int assuan_pending_line (assuan_context_t CTX) |
| 1741 |
A call to this function return true if a full line has been |
| 1742 |
buffered and thus an entire assuan line may be read without |
| 1743 |
triggering any actual I/O. |
| 1744 |
|
| 1745 |
---------- Footnotes ---------- |
| 1746 |
|
| 1747 |
(1) to our knowledge only the Linux kernel has this feature |
| 1748 |
|
| 1749 |
|
| 1750 |
File: assuan.info, Node: Socket wrappers, Next: Library Copying, Prev: Utilities, Up: Top |
| 1751 |
|
| 1752 |
10 Socket wrapper functions |
| 1753 |
*************************** |
| 1754 |
|
| 1755 |
It is sometimes useful to support Unix domain sockets on Windows. To do |
| 1756 |
this in a portable way, Assuan provides a set of wrapper functions which |
| 1757 |
may be used on any system but will enhance Windows to support these |
| 1758 |
socket types. The actual implementation is based on local TCP sockets |
| 1759 |
and fully transparent for the client. Server code needs to utilize two |
| 1760 |
extra functions to check the permissions. |
| 1761 |
|
| 1762 |
-- Function: gpg_error_t assuan_sock_init (void) |
| 1763 |
Initialize the socket wrappers. Must be called once at startup if |
| 1764 |
any of the socket wrapper functions are used. |
| 1765 |
|
| 1766 |
-- Function: gpg_error_t assuan_sock_deinit (void) |
| 1767 |
Deinitialize the socket wrappers. |
| 1768 |
|
| 1769 |
-- Function: int assuan_sock_close (assuan_fd_t FD) |
| 1770 |
Wrapper for close which does a closesocket on Windows if needed. |
| 1771 |
|
| 1772 |
-- Function: assuan_fd_t assuan_sock_new (int DOMAIN, int TYPE, |
| 1773 |
int PROTO); |
| 1774 |
Wrapper around socket. |
| 1775 |
|
| 1776 |
-- Function: assuan_fd_t assuan_sock_accept (assuan_fd_t SOCKFD, |
| 1777 |
struct sockaddr *ADDR, socklen_t *P_ADDRLEN) |
| 1778 |
|
| 1779 |
Wrapper around accept. |
| 1780 |
|
| 1781 |
-- Function: int assuan_sock_connect (assuan_fd_t SOCKFD, |
| 1782 |
struct sockaddr *ADDR, int ADDRLEN) |
| 1783 |
|
| 1784 |
Wrapper around connect. For Unix domain sockets under Windows this |
| 1785 |
function also does a write immediately after the the connect to |
| 1786 |
send the nonce as read from the socket's file. Under Unix this |
| 1787 |
function check whether the socket file is a redirection file and |
| 1788 |
connects to the redirected socket instead; see |
| 1789 |
'assuan_sock_set_sockaddr_un' for details on the redirection file |
| 1790 |
format. |
| 1791 |
|
| 1792 |
-- Function: int assuan_sock_connect_byname (const char * HOST, |
| 1793 |
unsigned short PORT, int TIMEOUT, const char *CREDENTIALS, |
| 1794 |
unsigned int FLAGS) |
| 1795 |
|
| 1796 |
Directly connect to PORT on HOST given as a name. The current |
| 1797 |
implementation requires that FLAGS has either 'ASSUAN_SOCK_SOCKS' |
| 1798 |
or 'ASSUAN_SOCK_TOR' set. On success a new TCP STREAM socket is |
| 1799 |
returned; on error 'ASSUAN_INVALID_FD' and ERRNO set. If |
| 1800 |
CREDENTIALS is not 'NULL', it is a string used for password based |
| 1801 |
SOCKS authentication. Username and password are separated by a |
| 1802 |
colon. TIMEOUT specifies timeout value (in miliseconds) for the |
| 1803 |
connection. TIMEOUT with zero means no timeout (for client side, |
| 1804 |
the SOCKS server may timeout). TIMEOUT with -1 means no wait. To |
| 1805 |
test whether the proxy is available HOST and PORT may be given as |
| 1806 |
NULL/0: If the proxy is available the function returns a valid |
| 1807 |
socket which is in the state after credentials sub-negotiation. |
| 1808 |
The caller now knows that the SOCKS proxy is available and has been |
| 1809 |
authenticated; normally the caller closes the socket then. |
| 1810 |
|
| 1811 |
-- Function: int assuan_sock_bind ( assuan_fd_t SOCKFD, |
| 1812 |
struct sockaddr *ADDR, int ADDRLEN) |
| 1813 |
|
| 1814 |
Wrapper around bind. Under Windows this creates a file and writes |
| 1815 |
the port number and a random nonce to this file. |
| 1816 |
|
| 1817 |
-- Function: int assuan_sock_set_sockaddr_un ( const char *FNAME, |
| 1818 |
struct sockaddr *ADDR, int *R_REDIRECTED) |
| 1819 |
|
| 1820 |
This is a helper function to initialize the Unix socket domain |
| 1821 |
address structure ADDR and store the file name FNAME there. If |
| 1822 |
R_REDIRECTED is not NULL the function checks whether FNAME already |
| 1823 |
exists, is a regular file, and not a socket. In that case FNAME is |
| 1824 |
read to see whether this is a redirection to a socket file. If |
| 1825 |
that is the case 1 is stored at R_REDIRECTED. If the file does not |
| 1826 |
look like a redirection file 0 will be stored there and FNAME will |
| 1827 |
be used in the regular way. |
| 1828 |
|
| 1829 |
The format of a redirection file is |
| 1830 |
|
| 1831 |
%Assuan% |
| 1832 |
socket=NAME |
| 1833 |
|
| 1834 |
With NAME being is the actual socket to use. No white spaces are |
| 1835 |
allowed, both lines must be terminated by a single linefeed, and |
| 1836 |
extra lines are not allowed. Environment variables are interpreted |
| 1837 |
in NAME if given in '${VAR}' notation. No escape characters are |
| 1838 |
defined; if the string '${' shall be used in file name, an |
| 1839 |
environment variable with that content may be used. The length of |
| 1840 |
the redirection file is limited to 511 bytes which is more than |
| 1841 |
sufficient for any known implementation of Unix domain sockets. |
| 1842 |
|
| 1843 |
-- Function: int assuan_sock_get_nonce ( struct sockaddr *ADDR, |
| 1844 |
int ADDRLEN, assuan_sock_nonce_t *NONCE) |
| 1845 |
|
| 1846 |
This is used by the server after a bind to return the random nonce. |
| 1847 |
To keep the code readable this may also be used on POSIX system. |
| 1848 |
|
| 1849 |
-- Function: int assuan_sock_check_nonce ( assuan_fd_t FD, |
| 1850 |
assuan_sock_nonce_t *NONCE) |
| 1851 |
|
| 1852 |
If the option 'ASSUAN_SOCKET_SERVER_ACCEPTED' has been used, |
| 1853 |
Libassuan has no way to check the nonce of the server. Thus an |
| 1854 |
explicit check of the saved nonce using this function is required. |
| 1855 |
If this function fails the server should immediately drop the |
| 1856 |
connection. This function may not be used if Libassuan does the |
| 1857 |
accept call itself (i.e., 'ASSUAN_SOCKET_SERVER_ACCEPTED' has not |
| 1858 |
been used) because in this case Libassuan calls this function |
| 1859 |
internally. See also 'assuan_set_sock_nonce'. |
| 1860 |
|
| 1861 |
Actually this mechanism is only required on Windows but for |
| 1862 |
cleanness of code it may be used on POSIX systems as well, where |
| 1863 |
this function is a nop. |
| 1864 |
|
| 1865 |
To control certain properties of the wrapper two additional functions |
| 1866 |
are provided: |
| 1867 |
|
| 1868 |
-- Function: int assuan_sock_set_flag ( assuan_fd_t FD, |
| 1869 |
const char *NAME, int VALUE) |
| 1870 |
|
| 1871 |
Set the flags NAME for socket FD to VALUE. See below for a list of |
| 1872 |
valid names. Returns 0 on success; on failure sets ERRNO and |
| 1873 |
returns -1. |
| 1874 |
|
| 1875 |
-- Function: int assuan_sock_get_flag ( assuan_fd_t FD, |
| 1876 |
const char *NAME, int *R_VALUE) |
| 1877 |
|
| 1878 |
Store the current value of the flag NAME for socket FD at R_VALUE. |
| 1879 |
See below for a list of valid names. Returns 0 on success; on |
| 1880 |
failure sets ERRNO and returns -1. |
| 1881 |
|
| 1882 |
The supported flags are: |
| 1883 |
|
| 1884 |
'cygwin' |
| 1885 |
This flag has an effect only on Windows. If the value is 1, the |
| 1886 |
socket is set into Cygwin mode so that Cygwin clients can connect |
| 1887 |
to such a socket. This flag needs to be set before a bind and |
| 1888 |
should not be changed during the lifetime of the socket. There is |
| 1889 |
no need to set this flag for connecting to a Cygwin style socket |
| 1890 |
because no state is required at the client. On non-Windows |
| 1891 |
platforms setting this flag is ignored, reading the flag always |
| 1892 |
returns a value of 0. |
| 1893 |
|
| 1894 |
'tor-mode' |
| 1895 |
'socks' |
| 1896 |
If VALUE is 1 globally enable SOCKS5 mode for new connections using |
| 1897 |
IPv6 or IPv4. FD must be set to 'ASSUAN_INVALID_FD' A future |
| 1898 |
extension may allow to disable SOCKS5 mode for a specified socket |
| 1899 |
but globally disabling SOCKS5 mode is not possible. Using the flag |
| 1900 |
"tor-mode" expects the SOCKS5 proxy to listen on port 9050, the |
| 1901 |
flag "socks" expects the proxy to listen on port 1080. |
| 1902 |
|
| 1903 |
Connections to the loopback address are not routed though the SOCKS |
| 1904 |
proxy. UDP requests are not supported at all. The proxy will be |
| 1905 |
connected at address 127.0.0.1; an IPv6 connection to the proxy is |
| 1906 |
not yet supported. |
| 1907 |
|
| 1908 |
|
| 1909 |
File: assuan.info, Node: Library Copying, Next: Copying, Prev: Socket wrappers, Up: Top |
| 1910 |
|
| 1911 |
GNU Lesser General Public License |
| 1912 |
********************************* |
| 1913 |
|
| 1914 |
Version 2.1, February 1999 |
| 1915 |
|
| 1916 |
Copyright (C) 1991, 1999 Free Software Foundation, Inc. |
| 1917 |
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
| 1918 |
|
| 1919 |
Everyone is permitted to copy and distribute verbatim copies |
| 1920 |
of this license document, but changing it is not allowed. |
| 1921 |
|
| 1922 |
[This is the first released version of the Lesser GPL. It also counts |
| 1923 |
as the successor of the GNU Library Public License, version 2, hence the |
| 1924 |
version number 2.1.] |
| 1925 |
|
| 1926 |
Preamble |
| 1927 |
======== |
| 1928 |
|
| 1929 |
The licenses for most software are designed to take away your freedom to |
| 1930 |
share and change it. By contrast, the GNU General Public Licenses are |
| 1931 |
intended to guarantee your freedom to share and change free software--to |
| 1932 |
make sure the software is free for all its users. |
| 1933 |
|
| 1934 |
This license, the Lesser General Public License, applies to some |
| 1935 |
specially designated software--typically libraries--of the Free Software |
| 1936 |
Foundation and other authors who decide to use it. You can use it too, |
| 1937 |
but we suggest you first think carefully about whether this license or |
| 1938 |
the ordinary General Public License is the better strategy to use in any |
| 1939 |
particular case, based on the explanations below. |
| 1940 |
|
| 1941 |
When we speak of free software, we are referring to freedom of use, |
| 1942 |
not price. Our General Public Licenses are designed to make sure that |
| 1943 |
you have the freedom to distribute copies of free software (and charge |
| 1944 |
for this service if you wish); that you receive source code or can get |
| 1945 |
it if you want it; that you can change the software and use pieces of it |
| 1946 |
in new free programs; and that you are informed that you can do these |
| 1947 |
things. |
| 1948 |
|
| 1949 |
To protect your rights, we need to make restrictions that forbid |
| 1950 |
distributors to deny you these rights or to ask you to surrender these |
| 1951 |
rights. These restrictions translate to certain responsibilities for |
| 1952 |
you if you distribute copies of the library or if you modify it. |
| 1953 |
|
| 1954 |
For example, if you distribute copies of the library, whether gratis |
| 1955 |
or for a fee, you must give the recipients all the rights that we gave |
| 1956 |
you. You must make sure that they, too, receive or can get the source |
| 1957 |
code. If you link other code with the library, you must provide |
| 1958 |
complete object files to the recipients, so that they can relink them |
| 1959 |
with the library after making changes to the library and recompiling it. |
| 1960 |
And you must show them these terms so they know their rights. |
| 1961 |
|
| 1962 |
We protect your rights with a two-step method: (1) we copyright the |
| 1963 |
library, and (2) we offer you this license, which gives you legal |
| 1964 |
permission to copy, distribute and/or modify the library. |
| 1965 |
|
| 1966 |
To protect each distributor, we want to make it very clear that there |
| 1967 |
is no warranty for the free library. Also, if the library is modified |
| 1968 |
by someone else and passed on, the recipients should know that what they |
| 1969 |
have is not the original version, so that the original author's |
| 1970 |
reputation will not be affected by problems that might be introduced by |
| 1971 |
others. |
| 1972 |
|
| 1973 |
Finally, software patents pose a constant threat to the existence of |
| 1974 |
any free program. We wish to make sure that a company cannot |
| 1975 |
effectively restrict the users of a free program by obtaining a |
| 1976 |
restrictive license from a patent holder. Therefore, we insist that any |
| 1977 |
patent license obtained for a version of the library must be consistent |
| 1978 |
with the full freedom of use specified in this license. |
| 1979 |
|
| 1980 |
Most GNU software, including some libraries, is covered by the |
| 1981 |
ordinary GNU General Public License. This license, the GNU Lesser |
| 1982 |
General Public License, applies to certain designated libraries, and is |
| 1983 |
quite different from the ordinary General Public License. We use this |
| 1984 |
license for certain libraries in order to permit linking those libraries |
| 1985 |
into non-free programs. |
| 1986 |
|
| 1987 |
When a program is linked with a library, whether statically or using |
| 1988 |
a shared library, the combination of the two is legally speaking a |
| 1989 |
combined work, a derivative of the original library. The ordinary |
| 1990 |
General Public License therefore permits such linking only if the entire |
| 1991 |
combination fits its criteria of freedom. The Lesser General Public |
| 1992 |
License permits more lax criteria for linking other code with the |
| 1993 |
library. |
| 1994 |
|
| 1995 |
We call this license the "Lesser" General Public License because it |
| 1996 |
does _Less_ to protect the user's freedom than the ordinary General |
| 1997 |
Public License. It also provides other free software developers Less of |
| 1998 |
an advantage over competing non-free programs. These disadvantages are |
| 1999 |
the reason we use the ordinary General Public License for many |
| 2000 |
libraries. However, the Lesser license provides advantages in certain |
| 2001 |
special circumstances. |
| 2002 |
|
| 2003 |
For example, on rare occasions, there may be a special need to |
| 2004 |
encourage the widest possible use of a certain library, so that it |
| 2005 |
becomes a de-facto standard. To achieve this, non-free programs must be |
| 2006 |
allowed to use the library. A more frequent case is that a free library |
| 2007 |
does the same job as widely used non-free libraries. In this case, |
| 2008 |
there is little to gain by limiting the free library to free software |
| 2009 |
only, so we use the Lesser General Public License. |
| 2010 |
|
| 2011 |
In other cases, permission to use a particular library in non-free |
| 2012 |
programs enables a greater number of people to use a large body of free |
| 2013 |
software. For example, permission to use the GNU C Library in non-free |
| 2014 |
programs enables many more people to use the whole GNU operating system, |
| 2015 |
as well as its variant, the GNU/Linux operating system. |
| 2016 |
|
| 2017 |
Although the Lesser General Public License is Less protective of the |
| 2018 |
users' freedom, it does ensure that the user of a program that is linked |
| 2019 |
with the Library has the freedom and the wherewithal to run that program |
| 2020 |
using a modified version of the Library. |
| 2021 |
|
| 2022 |
The precise terms and conditions for copying, distribution and |
| 2023 |
modification follow. Pay close attention to the difference between a |
| 2024 |
"work based on the library" and a "work that uses the library". The |
| 2025 |
former contains code derived from the library, whereas the latter must |
| 2026 |
be combined with the library in order to run. |
| 2027 |
|
| 2028 |
GNU LESSER GENERAL PUBLIC LICENSE |
| 2029 |
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION |
| 2030 |
|
| 2031 |
0. This License Agreement applies to any software library or other |
| 2032 |
program which contains a notice placed by the copyright holder or |
| 2033 |
other authorized party saying it may be distributed under the terms |
| 2034 |
of this Lesser General Public License (also called "this License"). |
| 2035 |
Each licensee is addressed as "you". |
| 2036 |
|
| 2037 |
A "library" means a collection of software functions and/or data |
| 2038 |
prepared so as to be conveniently linked with application programs |
| 2039 |
(which use some of those functions and data) to form executables. |
| 2040 |
|
| 2041 |
The "Library", below, refers to any such software library or work |
| 2042 |
which has been distributed under these terms. A "work based on the |
| 2043 |
Library" means either the Library or any derivative work under |
| 2044 |
copyright law: that is to say, a work containing the Library or a |
| 2045 |
portion of it, either verbatim or with modifications and/or |
| 2046 |
translated straightforwardly into another language. (Hereinafter, |
| 2047 |
translation is included without limitation in the term |
| 2048 |
"modification".) |
| 2049 |
|
| 2050 |
"Source code" for a work means the preferred form of the work for |
| 2051 |
making modifications to it. For a library, complete source code |
| 2052 |
means all the source code for all modules it contains, plus any |
| 2053 |
associated interface definition files, plus the scripts used to |
| 2054 |
control compilation and installation of the library. |
| 2055 |
|
| 2056 |
Activities other than copying, distribution and modification are |
| 2057 |
not covered by this License; they are outside its scope. The act |
| 2058 |
of running a program using the Library is not restricted, and |
| 2059 |
output from such a program is covered only if its contents |
| 2060 |
constitute a work based on the Library (independent of the use of |
| 2061 |
the Library in a tool for writing it). Whether that is true |
| 2062 |
depends on what the Library does and what the program that uses the |
| 2063 |
Library does. |
| 2064 |
|
| 2065 |
1. You may copy and distribute verbatim copies of the Library's |
| 2066 |
complete source code as you receive it, in any medium, provided |
| 2067 |
that you conspicuously and appropriately publish on each copy an |
| 2068 |
appropriate copyright notice and disclaimer of warranty; keep |
| 2069 |
intact all the notices that refer to this License and to the |
| 2070 |
absence of any warranty; and distribute a copy of this License |
| 2071 |
along with the Library. |
| 2072 |
|
| 2073 |
You may charge a fee for the physical act of transferring a copy, |
| 2074 |
and you may at your option offer warranty protection in exchange |
| 2075 |
for a fee. |
| 2076 |
|
| 2077 |
2. You may modify your copy or copies of the Library or any portion of |
| 2078 |
it, thus forming a work based on the Library, and copy and |
| 2079 |
distribute such modifications or work under the terms of Section 1 |
| 2080 |
above, provided that you also meet all of these conditions: |
| 2081 |
|
| 2082 |
a. The modified work must itself be a software library. |
| 2083 |
|
| 2084 |
b. You must cause the files modified to carry prominent notices |
| 2085 |
stating that you changed the files and the date of any change. |
| 2086 |
|
| 2087 |
c. You must cause the whole of the work to be licensed at no |
| 2088 |
charge to all third parties under the terms of this License. |
| 2089 |
|
| 2090 |
d. If a facility in the modified Library refers to a function or |
| 2091 |
a table of data to be supplied by an application program that |
| 2092 |
uses the facility, other than as an argument passed when the |
| 2093 |
facility is invoked, then you must make a good faith effort to |
| 2094 |
ensure that, in the event an application does not supply such |
| 2095 |
function or table, the facility still operates, and performs |
| 2096 |
whatever part of its purpose remains meaningful. |
| 2097 |
|
| 2098 |
(For example, a function in a library to compute square roots |
| 2099 |
has a purpose that is entirely well-defined independent of the |
| 2100 |
application. Therefore, Subsection 2d requires that any |
| 2101 |
application-supplied function or table used by this function |
| 2102 |
must be optional: if the application does not supply it, the |
| 2103 |
square root function must still compute square roots.) |
| 2104 |
|
| 2105 |
These requirements apply to the modified work as a whole. If |
| 2106 |
identifiable sections of that work are not derived from the |
| 2107 |
Library, and can be reasonably considered independent and separate |
| 2108 |
works in themselves, then this License, and its terms, do not apply |
| 2109 |
to those sections when you distribute them as separate works. But |
| 2110 |
when you distribute the same sections as part of a whole which is a |
| 2111 |
work based on the Library, the distribution of the whole must be on |
| 2112 |
the terms of this License, whose permissions for other licensees |
| 2113 |
extend to the entire whole, and thus to each and every part |
| 2114 |
regardless of who wrote it. |
| 2115 |
|
| 2116 |
Thus, it is not the intent of this section to claim rights or |
| 2117 |
contest your rights to work written entirely by you; rather, the |
| 2118 |
intent is to exercise the right to control the distribution of |
| 2119 |
derivative or collective works based on the Library. |
| 2120 |
|
| 2121 |
In addition, mere aggregation of another work not based on the |
| 2122 |
Library with the Library (or with a work based on the Library) on a |
| 2123 |
volume of a storage or distribution medium does not bring the other |
| 2124 |
work under the scope of this License. |
| 2125 |
|
| 2126 |
3. You may opt to apply the terms of the ordinary GNU General Public |
| 2127 |
License instead of this License to a given copy of the Library. To |
| 2128 |
do this, you must alter all the notices that refer to this License, |
| 2129 |
so that they refer to the ordinary GNU General Public License, |
| 2130 |
version 2, instead of to this License. (If a newer version than |
| 2131 |
version 2 of the ordinary GNU General Public License has appeared, |
| 2132 |
then you can specify that version instead if you wish.) Do not |
| 2133 |
make any other change in these notices. |
| 2134 |
|
| 2135 |
Once this change is made in a given copy, it is irreversible for |
| 2136 |
that copy, so the ordinary GNU General Public License applies to |
| 2137 |
all subsequent copies and derivative works made from that copy. |
| 2138 |
|
| 2139 |
This option is useful when you wish to copy part of the code of the |
| 2140 |
Library into a program that is not a library. |
| 2141 |
|
| 2142 |
4. You may copy and distribute the Library (or a portion or derivative |
| 2143 |
of it, under Section 2) in object code or executable form under the |
| 2144 |
terms of Sections 1 and 2 above provided that you accompany it with |
| 2145 |
the complete corresponding machine-readable source code, which must |
| 2146 |
be distributed under the terms of Sections 1 and 2 above on a |
| 2147 |
medium customarily used for software interchange. |
| 2148 |
|
| 2149 |
If distribution of object code is made by offering access to copy |
| 2150 |
from a designated place, then offering equivalent access to copy |
| 2151 |
the source code from the same place satisfies the requirement to |
| 2152 |
distribute the source code, even though third parties are not |
| 2153 |
compelled to copy the source along with the object code. |
| 2154 |
|
| 2155 |
5. A program that contains no derivative of any portion of the |
| 2156 |
Library, but is designed to work with the Library by being compiled |
| 2157 |
or linked with it, is called a "work that uses the Library". Such |
| 2158 |
a work, in isolation, is not a derivative work of the Library, and |
| 2159 |
therefore falls outside the scope of this License. |
| 2160 |
|
| 2161 |
However, linking a "work that uses the Library" with the Library |
| 2162 |
creates an executable that is a derivative of the Library (because |
| 2163 |
it contains portions of the Library), rather than a "work that uses |
| 2164 |
the library". The executable is therefore covered by this License. |
| 2165 |
Section 6 states terms for distribution of such executables. |
| 2166 |
|
| 2167 |
When a "work that uses the Library" uses material from a header |
| 2168 |
file that is part of the Library, the object code for the work may |
| 2169 |
be a derivative work of the Library even though the source code is |
| 2170 |
not. Whether this is true is especially significant if the work |
| 2171 |
can be linked without the Library, or if the work is itself a |
| 2172 |
library. The threshold for this to be true is not precisely |
| 2173 |
defined by law. |
| 2174 |
|
| 2175 |
If such an object file uses only numerical parameters, data |
| 2176 |
structure layouts and accessors, and small macros and small inline |
| 2177 |
functions (ten lines or less in length), then the use of the object |
| 2178 |
file is unrestricted, regardless of whether it is legally a |
| 2179 |
derivative work. (Executables containing this object code plus |
| 2180 |
portions of the Library will still fall under Section 6.) |
| 2181 |
|
| 2182 |
Otherwise, if the work is a derivative of the Library, you may |
| 2183 |
distribute the object code for the work under the terms of Section |
| 2184 |
6. Any executables containing that work also fall under Section 6, |
| 2185 |
whether or not they are linked directly with the Library itself. |
| 2186 |
|
| 2187 |
6. As an exception to the Sections above, you may also combine or link |
| 2188 |
a "work that uses the Library" with the Library to produce a work |
| 2189 |
containing portions of the Library, and distribute that work under |
| 2190 |
terms of your choice, provided that the terms permit modification |
| 2191 |
of the work for the customer's own use and reverse engineering for |
| 2192 |
debugging such modifications. |
| 2193 |
|
| 2194 |
You must give prominent notice with each copy of the work that the |
| 2195 |
Library is used in it and that the Library and its use are covered |
| 2196 |
by this License. You must supply a copy of this License. If the |
| 2197 |
work during execution displays copyright notices, you must include |
| 2198 |
the copyright notice for the Library among them, as well as a |
| 2199 |
reference directing the user to the copy of this License. Also, |
| 2200 |
you must do one of these things: |
| 2201 |
|
| 2202 |
a. Accompany the work with the complete corresponding |
| 2203 |
machine-readable source code for the Library including |
| 2204 |
whatever changes were used in the work (which must be |
| 2205 |
distributed under Sections 1 and 2 above); and, if the work is |
| 2206 |
an executable linked with the Library, with the complete |
| 2207 |
machine-readable "work that uses the Library", as object code |
| 2208 |
and/or source code, so that the user can modify the Library |
| 2209 |
and then relink to produce a modified executable containing |
| 2210 |
the modified Library. (It is understood that the user who |
| 2211 |
changes the contents of definitions files in the Library will |
| 2212 |
not necessarily be able to recompile the application to use |
| 2213 |
the modified definitions.) |
| 2214 |
|
| 2215 |
b. Use a suitable shared library mechanism for linking with the |
| 2216 |
Library. A suitable mechanism is one that (1) uses at run |
| 2217 |
time a copy of the library already present on the user's |
| 2218 |
computer system, rather than copying library functions into |
| 2219 |
the executable, and (2) will operate properly with a modified |
| 2220 |
version of the library, if the user installs one, as long as |
| 2221 |
the modified version is interface-compatible with the version |
| 2222 |
that the work was made with. |
| 2223 |
|
| 2224 |
c. Accompany the work with a written offer, valid for at least |
| 2225 |
three years, to give the same user the materials specified in |
| 2226 |
Subsection 6a, above, for a charge no more than the cost of |
| 2227 |
performing this distribution. |
| 2228 |
|
| 2229 |
d. If distribution of the work is made by offering access to copy |
| 2230 |
from a designated place, offer equivalent access to copy the |
| 2231 |
above specified materials from the same place. |
| 2232 |
|
| 2233 |
e. Verify that the user has already received a copy of these |
| 2234 |
materials or that you have already sent this user a copy. |
| 2235 |
|
| 2236 |
For an executable, the required form of the "work that uses the |
| 2237 |
Library" must include any data and utility programs needed for |
| 2238 |
reproducing the executable from it. However, as a special |
| 2239 |
exception, the materials to be distributed need not include |
| 2240 |
anything that is normally distributed (in either source or binary |
| 2241 |
form) with the major components (compiler, kernel, and so on) of |
| 2242 |
the operating system on which the executable runs, unless that |
| 2243 |
component itself accompanies the executable. |
| 2244 |
|
| 2245 |
It may happen that this requirement contradicts the license |
| 2246 |
restrictions of other proprietary libraries that do not normally |
| 2247 |
accompany the operating system. Such a contradiction means you |
| 2248 |
cannot use both them and the Library together in an executable that |
| 2249 |
you distribute. |
| 2250 |
|
| 2251 |
7. You may place library facilities that are a work based on the |
| 2252 |
Library side-by-side in a single library together with other |
| 2253 |
library facilities not covered by this License, and distribute such |
| 2254 |
a combined library, provided that the separate distribution of the |
| 2255 |
work based on the Library and of the other library facilities is |
| 2256 |
otherwise permitted, and provided that you do these two things: |
| 2257 |
|
| 2258 |
a. Accompany the combined library with a copy of the same work |
| 2259 |
based on the Library, uncombined with any other library |
| 2260 |
facilities. This must be distributed under the terms of the |
| 2261 |
Sections above. |
| 2262 |
|
| 2263 |
b. Give prominent notice with the combined library of the fact |
| 2264 |
that part of it is a work based on the Library, and explaining |
| 2265 |
where to find the accompanying uncombined form of the same |
| 2266 |
work. |
| 2267 |
|
| 2268 |
8. You may not copy, modify, sublicense, link with, or distribute the |
| 2269 |
Library except as expressly provided under this License. Any |
| 2270 |
attempt otherwise to copy, modify, sublicense, link with, or |
| 2271 |
distribute the Library is void, and will automatically terminate |
| 2272 |
your rights under this License. However, parties who have received |
| 2273 |
copies, or rights, from you under this License will not have their |
| 2274 |
licenses terminated so long as such parties remain in full |
| 2275 |
compliance. |
| 2276 |
|
| 2277 |
9. You are not required to accept this License, since you have not |
| 2278 |
signed it. However, nothing else grants you permission to modify |
| 2279 |
or distribute the Library or its derivative works. These actions |
| 2280 |
are prohibited by law if you do not accept this License. |
| 2281 |
Therefore, by modifying or distributing the Library (or any work |
| 2282 |
based on the Library), you indicate your acceptance of this License |
| 2283 |
to do so, and all its terms and conditions for copying, |
| 2284 |
distributing or modifying the Library or works based on it. |
| 2285 |
|
| 2286 |
10. Each time you redistribute the Library (or any work based on the |
| 2287 |
Library), the recipient automatically receives a license from the |
| 2288 |
original licensor to copy, distribute, link with or modify the |
| 2289 |
Library subject to these terms and conditions. You may not impose |
| 2290 |
any further restrictions on the recipients' exercise of the rights |
| 2291 |
granted herein. You are not responsible for enforcing compliance |
| 2292 |
by third parties with this License. |
| 2293 |
|
| 2294 |
11. If, as a consequence of a court judgment or allegation of patent |
| 2295 |
infringement or for any other reason (not limited to patent |
| 2296 |
issues), conditions are imposed on you (whether by court order, |
| 2297 |
agreement or otherwise) that contradict the conditions of this |
| 2298 |
License, they do not excuse you from the conditions of this |
| 2299 |
License. If you cannot distribute so as to satisfy simultaneously |
| 2300 |
your obligations under this License and any other pertinent |
| 2301 |
obligations, then as a consequence you may not distribute the |
| 2302 |
Library at all. For example, if a patent license would not permit |
| 2303 |
royalty-free redistribution of the Library by all those who receive |
| 2304 |
copies directly or indirectly through you, then the only way you |
| 2305 |
could satisfy both it and this License would be to refrain entirely |
| 2306 |
from distribution of the Library. |
| 2307 |
|
| 2308 |
If any portion of this section is held invalid or unenforceable |
| 2309 |
under any particular circumstance, the balance of the section is |
| 2310 |
intended to apply, and the section as a whole is intended to apply |
| 2311 |
in other circumstances. |
| 2312 |
|
| 2313 |
It is not the purpose of this section to induce you to infringe any |
| 2314 |
patents or other property right claims or to contest validity of |
| 2315 |
any such claims; this section has the sole purpose of protecting |
| 2316 |
the integrity of the free software distribution system which is |
| 2317 |
implemented by public license practices. Many people have made |
| 2318 |
generous contributions to the wide range of software distributed |
| 2319 |
through that system in reliance on consistent application of that |
| 2320 |
system; it is up to the author/donor to decide if he or she is |
| 2321 |
willing to distribute software through any other system and a |
| 2322 |
licensee cannot impose that choice. |
| 2323 |
|
| 2324 |
This section is intended to make thoroughly clear what is believed |
| 2325 |
to be a consequence of the rest of this License. |
| 2326 |
|
| 2327 |
12. If the distribution and/or use of the Library is restricted in |
| 2328 |
certain countries either by patents or by copyrighted interfaces, |
| 2329 |
the original copyright holder who places the Library under this |
| 2330 |
License may add an explicit geographical distribution limitation |
| 2331 |
excluding those countries, so that distribution is permitted only |
| 2332 |
in or among countries not thus excluded. In such case, this |
| 2333 |
License incorporates the limitation as if written in the body of |
| 2334 |
this License. |
| 2335 |
|
| 2336 |
13. The Free Software Foundation may publish revised and/or new |
| 2337 |
versions of the Lesser General Public License from time to time. |
| 2338 |
Such new versions will be similar in spirit to the present version, |
| 2339 |
but may differ in detail to address new problems or concerns. |
| 2340 |
|
| 2341 |
Each version is given a distinguishing version number. If the |
| 2342 |
Library specifies a version number of this License which applies to |
| 2343 |
it and "any later version", you have the option of following the |
| 2344 |
terms and conditions either of that version or of any later version |
| 2345 |
published by the Free Software Foundation. If the Library does not |
| 2346 |
specify a license version number, you may choose any version ever |
| 2347 |
published by the Free Software Foundation. |
| 2348 |
|
| 2349 |
14. If you wish to incorporate parts of the Library into other free |
| 2350 |
programs whose distribution conditions are incompatible with these, |
| 2351 |
write to the author to ask for permission. For software which is |
| 2352 |
copyrighted by the Free Software Foundation, write to the Free |
| 2353 |
Software Foundation; we sometimes make exceptions for this. Our |
| 2354 |
decision will be guided by the two goals of preserving the free |
| 2355 |
status of all derivatives of our free software and of promoting the |
| 2356 |
sharing and reuse of software generally. |
| 2357 |
|
| 2358 |
NO WARRANTY |
| 2359 |
|
| 2360 |
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO |
| 2361 |
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE |
| 2362 |
LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS |
| 2363 |
AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY |
| 2364 |
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT |
| 2365 |
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 2366 |
FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND |
| 2367 |
PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE |
| 2368 |
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR |
| 2369 |
OR CORRECTION. |
| 2370 |
|
| 2371 |
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN |
| 2372 |
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY |
| 2373 |
MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE |
| 2374 |
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, |
| 2375 |
INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR |
| 2376 |
INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF |
| 2377 |
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU |
| 2378 |
OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY |
| 2379 |
OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN |
| 2380 |
ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
| 2381 |
|
| 2382 |
END OF TERMS AND CONDITIONS |
| 2383 |
|
| 2384 |
How to Apply These Terms to Your New Libraries |
| 2385 |
============================================== |
| 2386 |
|
| 2387 |
If you develop a new library, and you want it to be of the greatest |
| 2388 |
possible use to the public, we recommend making it free software that |
| 2389 |
everyone can redistribute and change. You can do so by permitting |
| 2390 |
redistribution under these terms (or, alternatively, under the terms of |
| 2391 |
the ordinary General Public License). |
| 2392 |
|
| 2393 |
To apply these terms, attach the following notices to the library. |
| 2394 |
It is safest to attach them to the start of each source file to most |
| 2395 |
effectively convey the exclusion of warranty; and each file should have |
| 2396 |
at least the "copyright" line and a pointer to where the full notice is |
| 2397 |
found. |
| 2398 |
|
| 2399 |
ONE LINE TO GIVE THE LIBRARY'S NAME AND AN IDEA OF WHAT IT DOES. |
| 2400 |
Copyright (C) YEAR NAME OF AUTHOR |
| 2401 |
|
| 2402 |
This library is free software; you can redistribute it and/or modify it |
| 2403 |
under the terms of the GNU Lesser General Public License as published by |
| 2404 |
the Free Software Foundation; either version 2.1 of the License, or (at |
| 2405 |
your option) any later version. |
| 2406 |
|
| 2407 |
This library is distributed in the hope that it will be useful, but |
| 2408 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
| 2409 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 2410 |
Lesser General Public License for more details. |
| 2411 |
|
| 2412 |
You should have received a copy of the GNU Lesser General Public |
| 2413 |
License along with this library; if not, write to the Free Software |
| 2414 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, |
| 2415 |
USA. |
| 2416 |
|
| 2417 |
Also add information on how to contact you by electronic and paper |
| 2418 |
mail. |
| 2419 |
|
| 2420 |
You should also get your employer (if you work as a programmer) or |
| 2421 |
your school, if any, to sign a "copyright disclaimer" for the library, |
| 2422 |
if necessary. Here is a sample; alter the names: |
| 2423 |
|
| 2424 |
Yoyodyne, Inc., hereby disclaims all copyright interest in the library |
| 2425 |
`Frob' (a library for tweaking knobs) written by James Random Hacker. |
| 2426 |
|
| 2427 |
SIGNATURE OF TY COON, 1 April 1990 |
| 2428 |
Ty Coon, President of Vice |
| 2429 |
|
| 2430 |
That's all there is to it! |
| 2431 |
|
| 2432 |
|
| 2433 |
File: assuan.info, Node: Copying, Next: Index, Prev: Library Copying, Up: Top |
| 2434 |
|
| 2435 |
GNU General Public License |
| 2436 |
************************** |
| 2437 |
|
| 2438 |
Version 3, 29 June 2007 |
| 2439 |
|
| 2440 |
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> |
| 2441 |
|
| 2442 |
Everyone is permitted to copy and distribute verbatim copies of this |
| 2443 |
license document, but changing it is not allowed. |
| 2444 |
|
| 2445 |
Preamble |
| 2446 |
======== |
| 2447 |
|
| 2448 |
The GNU General Public License is a free, copyleft license for software |
| 2449 |
and other kinds of works. |
| 2450 |
|
| 2451 |
The licenses for most software and other practical works are designed |
| 2452 |
to take away your freedom to share and change the works. By contrast, |
| 2453 |
the GNU General Public License is intended to guarantee your freedom to |
| 2454 |
share and change all versions of a program-to make sure it remains free |
| 2455 |
software for all its users. We, the Free Software Foundation, use the |
| 2456 |
GNU General Public License for most of our software; it applies also to |
| 2457 |
any other work released this way by its authors. You can apply it to |
| 2458 |
your programs, too. |
| 2459 |
|
| 2460 |
When we speak of free software, we are referring to freedom, not |
| 2461 |
price. Our General Public Licenses are designed to make sure that you |
| 2462 |
have the freedom to distribute copies of free software (and charge for |
| 2463 |
them if you wish), that you receive source code or can get it if you |
| 2464 |
want it, that you can change the software or use pieces of it in new |
| 2465 |
free programs, and that you know you can do these things. |
| 2466 |
|
| 2467 |
To protect your rights, we need to prevent others from denying you |
| 2468 |
these rights or asking you to surrender the rights. Therefore, you have |
| 2469 |
certain responsibilities if you distribute copies of the software, or if |
| 2470 |
you modify it: responsibilities to respect the freedom of others. |
| 2471 |
|
| 2472 |
For example, if you distribute copies of such a program, whether |
| 2473 |
gratis or for a fee, you must pass on to the recipients the same |
| 2474 |
freedoms that you received. You must make sure that they, too, receive |
| 2475 |
or can get the source code. And you must show them these terms so they |
| 2476 |
know their rights. |
| 2477 |
|
| 2478 |
Developers that use the GNU GPL protect your rights with two steps: |
| 2479 |
(1) assert copyright on the software, and (2) offer you this License |
| 2480 |
giving you legal permission to copy, distribute and/or modify it. |
| 2481 |
|
| 2482 |
For the developers' and authors' protection, the GPL clearly explains |
| 2483 |
that there is no warranty for this free software. For both users' and |
| 2484 |
authors' sake, the GPL requires that modified versions be marked as |
| 2485 |
changed, so that their problems will not be attributed erroneously to |
| 2486 |
authors of previous versions. |
| 2487 |
|
| 2488 |
Some devices are designed to deny users access to install or run |
| 2489 |
modified versions of the software inside them, although the manufacturer |
| 2490 |
can do so. This is fundamentally incompatible with the aim of |
| 2491 |
protecting users' freedom to change the software. The systematic |
| 2492 |
pattern of such abuse occurs in the area of products for individuals to |
| 2493 |
use, which is precisely where it is most unacceptable. Therefore, we |
| 2494 |
have designed this version of the GPL to prohibit the practice for those |
| 2495 |
products. If such problems arise substantially in other domains, we |
| 2496 |
stand ready to extend this provision to those domains in future versions |
| 2497 |
of the GPL, as needed to protect the freedom of users. |
| 2498 |
|
| 2499 |
Finally, every program is threatened constantly by software patents. |
| 2500 |
States should not allow patents to restrict development and use of |
| 2501 |
software on general-purpose computers, but in those that do, we wish to |
| 2502 |
avoid the special danger that patents applied to a free program could |
| 2503 |
make it effectively proprietary. To prevent this, the GPL assures that |
| 2504 |
patents cannot be used to render the program non-free. |
| 2505 |
|
| 2506 |
The precise terms and conditions for copying, distribution and |
| 2507 |
modification follow. |
| 2508 |
|
| 2509 |
TERMS AND CONDITIONS |
| 2510 |
|
| 2511 |
0. Definitions. |
| 2512 |
|
| 2513 |
"This License" refers to version 3 of the GNU General Public |
| 2514 |
License. |
| 2515 |
|
| 2516 |
"Copyright" also means copyright-like laws that apply to other |
| 2517 |
kinds of works, such as semiconductor masks. |
| 2518 |
|
| 2519 |
"The Program" refers to any copyrightable work licensed under this |
| 2520 |
License. Each licensee is addressed as "you". "Licensees" and |
| 2521 |
"recipients" may be individuals or organizations. |
| 2522 |
|
| 2523 |
To "modify" a work means to copy from or adapt all or part of the |
| 2524 |
work in a fashion requiring copyright permission, other than the |
| 2525 |
making of an exact copy. The resulting work is called a "modified |
| 2526 |
version" of the earlier work or a work "based on" the earlier work. |
| 2527 |
|
| 2528 |
A "covered work" means either the unmodified Program or a work |
| 2529 |
based on the Program. |
| 2530 |
|
| 2531 |
To "propagate" a work means to do anything with it that, without |
| 2532 |
permission, would make you directly or secondarily liable for |
| 2533 |
infringement under applicable copyright law, except executing it on |
| 2534 |
a computer or modifying a private copy. Propagation includes |
| 2535 |
copying, distribution (with or without modification), making |
| 2536 |
available to the public, and in some countries other activities as |
| 2537 |
well. |
| 2538 |
|
| 2539 |
To "convey" a work means any kind of propagation that enables other |
| 2540 |
parties to make or receive copies. Mere interaction with a user |
| 2541 |
through a computer network, with no transfer of a copy, is not |
| 2542 |
conveying. |
| 2543 |
|
| 2544 |
An interactive user interface displays "Appropriate Legal Notices" |
| 2545 |
to the extent that it includes a convenient and prominently visible |
| 2546 |
feature that (1) displays an appropriate copyright notice, and (2) |
| 2547 |
tells the user that there is no warranty for the work (except to |
| 2548 |
the extent that warranties are provided), that licensees may convey |
| 2549 |
the work under this License, and how to view a copy of this |
| 2550 |
License. If the interface presents a list of user commands or |
| 2551 |
options, such as a menu, a prominent item in the list meets this |
| 2552 |
criterion. |
| 2553 |
|
| 2554 |
1. Source Code. |
| 2555 |
|
| 2556 |
The "source code" for a work means the preferred form of the work |
| 2557 |
for making modifications to it. "Object code" means any non-source |
| 2558 |
form of a work. |
| 2559 |
|
| 2560 |
A "Standard Interface" means an interface that either is an |
| 2561 |
official standard defined by a recognized standards body, or, in |
| 2562 |
the case of interfaces specified for a particular programming |
| 2563 |
language, one that is widely used among developers working in that |
| 2564 |
language. |
| 2565 |
|
| 2566 |
The "System Libraries" of an executable work include anything, |
| 2567 |
other than the work as a whole, that (a) is included in the normal |
| 2568 |
form of packaging a Major Component, but which is not part of that |
| 2569 |
Major Component, and (b) serves only to enable use of the work with |
| 2570 |
that Major Component, or to implement a Standard Interface for |
| 2571 |
which an implementation is available to the public in source code |
| 2572 |
form. A "Major Component", in this context, means a major |
| 2573 |
essential component (kernel, window system, and so on) of the |
| 2574 |
specific operating system (if any) on which the executable work |
| 2575 |
runs, or a compiler used to produce the work, or an object code |
| 2576 |
interpreter used to run it. |
| 2577 |
|
| 2578 |
The "Corresponding Source" for a work in object code form means all |
| 2579 |
the source code needed to generate, install, and (for an executable |
| 2580 |
work) run the object code and to modify the work, including scripts |
| 2581 |
to control those activities. However, it does not include the |
| 2582 |
work's System Libraries, or general-purpose tools or generally |
| 2583 |
available free programs which are used unmodified in performing |
| 2584 |
those activities but which are not part of the work. For example, |
| 2585 |
Corresponding Source includes interface definition files associated |
| 2586 |
with source files for the work, and the source code for shared |
| 2587 |
libraries and dynamically linked subprograms that the work is |
| 2588 |
specifically designed to require, such as by intimate data |
| 2589 |
communication or control flow between those subprograms and other |
| 2590 |
parts of the work. |
| 2591 |
|
| 2592 |
The Corresponding Source need not include anything that users can |
| 2593 |
regenerate automatically from other parts of the Corresponding |
| 2594 |
Source. |
| 2595 |
|
| 2596 |
The Corresponding Source for a work in source code form is that |
| 2597 |
same work. |
| 2598 |
|
| 2599 |
2. Basic Permissions. |
| 2600 |
|
| 2601 |
All rights granted under this License are granted for the term of |
| 2602 |
copyright on the Program, and are irrevocable provided the stated |
| 2603 |
conditions are met. This License explicitly affirms your unlimited |
| 2604 |
permission to run the unmodified Program. The output from running |
| 2605 |
a covered work is covered by this License only if the output, given |
| 2606 |
its content, constitutes a covered work. This License acknowledges |
| 2607 |
your rights of fair use or other equivalent, as provided by |
| 2608 |
copyright law. |
| 2609 |
|
| 2610 |
You may make, run and propagate covered works that you do not |
| 2611 |
convey, without conditions so long as your license otherwise |
| 2612 |
remains in force. You may convey covered works to others for the |
| 2613 |
sole purpose of having them make modifications exclusively for you, |
| 2614 |
or provide you with facilities for running those works, provided |
| 2615 |
that you comply with the terms of this License in conveying all |
| 2616 |
material for which you do not control copyright. Those thus making |
| 2617 |
or running the covered works for you must do so exclusively on your |
| 2618 |
behalf, under your direction and control, on terms that prohibit |
| 2619 |
them from making any copies of your copyrighted material outside |
| 2620 |
their relationship with you. |
| 2621 |
|
| 2622 |
Conveying under any other circumstances is permitted solely under |
| 2623 |
the conditions stated below. Sublicensing is not allowed; section |
| 2624 |
10 makes it unnecessary. |
| 2625 |
|
| 2626 |
3. Protecting Users' Legal Rights From Anti-Circumvention Law. |
| 2627 |
|
| 2628 |
No covered work shall be deemed part of an effective technological |
| 2629 |
measure under any applicable law fulfilling obligations under |
| 2630 |
article 11 of the WIPO copyright treaty adopted on 20 December |
| 2631 |
1996, or similar laws prohibiting or restricting circumvention of |
| 2632 |
such measures. |
| 2633 |
|
| 2634 |
When you convey a covered work, you waive any legal power to forbid |
| 2635 |
circumvention of technological measures to the extent such |
| 2636 |
circumvention is effected by exercising rights under this License |
| 2637 |
with respect to the covered work, and you disclaim any intention to |
| 2638 |
limit operation or modification of the work as a means of |
| 2639 |
enforcing, against the work's users, your or third parties' legal |
| 2640 |
rights to forbid circumvention of technological measures. |
| 2641 |
|
| 2642 |
4. Conveying Verbatim Copies. |
| 2643 |
|
| 2644 |
You may convey verbatim copies of the Program's source code as you |
| 2645 |
receive it, in any medium, provided that you conspicuously and |
| 2646 |
appropriately publish on each copy an appropriate copyright notice; |
| 2647 |
keep intact all notices stating that this License and any |
| 2648 |
non-permissive terms added in accord with section 7 apply to the |
| 2649 |
code; keep intact all notices of the absence of any warranty; and |
| 2650 |
give all recipients a copy of this License along with the Program. |
| 2651 |
|
| 2652 |
You may charge any price or no price for each copy that you convey, |
| 2653 |
and you may offer support or warranty protection for a fee. |
| 2654 |
|
| 2655 |
5. Conveying Modified Source Versions. |
| 2656 |
|
| 2657 |
You may convey a work based on the Program, or the modifications to |
| 2658 |
produce it from the Program, in the form of source code under the |
| 2659 |
terms of section 4, provided that you also meet all of these |
| 2660 |
conditions: |
| 2661 |
|
| 2662 |
a. The work must carry prominent notices stating that you |
| 2663 |
modified it, and giving a relevant date. |
| 2664 |
|
| 2665 |
b. The work must carry prominent notices stating that it is |
| 2666 |
released under this License and any conditions added under |
| 2667 |
section 7. This requirement modifies the requirement in |
| 2668 |
section 4 to "keep intact all notices". |
| 2669 |
|
| 2670 |
c. You must license the entire work, as a whole, under this |
| 2671 |
License to anyone who comes into possession of a copy. This |
| 2672 |
License will therefore apply, along with any applicable |
| 2673 |
section 7 additional terms, to the whole of the work, and all |
| 2674 |
its parts, regardless of how they are packaged. This License |
| 2675 |
gives no permission to license the work in any other way, but |
| 2676 |
it does not invalidate such permission if you have separately |
| 2677 |
received it. |
| 2678 |
|
| 2679 |
d. If the work has interactive user interfaces, each must display |
| 2680 |
Appropriate Legal Notices; however, if the Program has |
| 2681 |
interactive interfaces that do not display Appropriate Legal |
| 2682 |
Notices, your work need not make them do so. |
| 2683 |
|
| 2684 |
A compilation of a covered work with other separate and independent |
| 2685 |
works, which are not by their nature extensions of the covered |
| 2686 |
work, and which are not combined with it such as to form a larger |
| 2687 |
program, in or on a volume of a storage or distribution medium, is |
| 2688 |
called an "aggregate" if the compilation and its resulting |
| 2689 |
copyright are not used to limit the access or legal rights of the |
| 2690 |
compilation's users beyond what the individual works permit. |
| 2691 |
Inclusion of a covered work in an aggregate does not cause this |
| 2692 |
License to apply to the other parts of the aggregate. |
| 2693 |
|
| 2694 |
6. Conveying Non-Source Forms. |
| 2695 |
|
| 2696 |
You may convey a covered work in object code form under the terms |
| 2697 |
of sections 4 and 5, provided that you also convey the |
| 2698 |
machine-readable Corresponding Source under the terms of this |
| 2699 |
License, in one of these ways: |
| 2700 |
|
| 2701 |
a. Convey the object code in, or embodied in, a physical product |
| 2702 |
(including a physical distribution medium), accompanied by the |
| 2703 |
Corresponding Source fixed on a durable physical medium |
| 2704 |
customarily used for software interchange. |
| 2705 |
|
| 2706 |
b. Convey the object code in, or embodied in, a physical product |
| 2707 |
(including a physical distribution medium), accompanied by a |
| 2708 |
written offer, valid for at least three years and valid for as |
| 2709 |
long as you offer spare parts or customer support for that |
| 2710 |
product model, to give anyone who possesses the object code |
| 2711 |
either (1) a copy of the Corresponding Source for all the |
| 2712 |
software in the product that is covered by this License, on a |
| 2713 |
durable physical medium customarily used for software |
| 2714 |
interchange, for a price no more than your reasonable cost of |
| 2715 |
physically performing this conveying of source, or (2) access |
| 2716 |
to copy the Corresponding Source from a network server at no |
| 2717 |
charge. |
| 2718 |
|
| 2719 |
c. Convey individual copies of the object code with a copy of the |
| 2720 |
written offer to provide the Corresponding Source. This |
| 2721 |
alternative is allowed only occasionally and noncommercially, |
| 2722 |
and only if you received the object code with such an offer, |
| 2723 |
in accord with subsection 6b. |
| 2724 |
|
| 2725 |
d. Convey the object code by offering access from a designated |
| 2726 |
place (gratis or for a charge), and offer equivalent access to |
| 2727 |
the Corresponding Source in the same way through the same |
| 2728 |
place at no further charge. You need not require recipients |
| 2729 |
to copy the Corresponding Source along with the object code. |
| 2730 |
If the place to copy the object code is a network server, the |
| 2731 |
Corresponding Source may be on a different server (operated by |
| 2732 |
you or a third party) that supports equivalent copying |
| 2733 |
facilities, provided you maintain clear directions next to the |
| 2734 |
object code saying where to find the Corresponding Source. |
| 2735 |
Regardless of what server hosts the Corresponding Source, you |
| 2736 |
remain obligated to ensure that it is available for as long as |
| 2737 |
needed to satisfy these requirements. |
| 2738 |
|
| 2739 |
e. Convey the object code using peer-to-peer transmission, |
| 2740 |
provided you inform other peers where the object code and |
| 2741 |
Corresponding Source of the work are being offered to the |
| 2742 |
general public at no charge under subsection 6d. |
| 2743 |
|
| 2744 |
A separable portion of the object code, whose source code is |
| 2745 |
excluded from the Corresponding Source as a System Library, need |
| 2746 |
not be included in conveying the object code work. |
| 2747 |
|
| 2748 |
A "User Product" is either (1) a "consumer product", which means |
| 2749 |
any tangible personal property which is normally used for personal, |
| 2750 |
family, or household purposes, or (2) anything designed or sold for |
| 2751 |
incorporation into a dwelling. In determining whether a product is |
| 2752 |
a consumer product, doubtful cases shall be resolved in favor of |
| 2753 |
coverage. For a particular product received by a particular user, |
| 2754 |
"normally used" refers to a typical or common use of that class of |
| 2755 |
product, regardless of the status of the particular user or of the |
| 2756 |
way in which the particular user actually uses, or expects or is |
| 2757 |
expected to use, the product. A product is a consumer product |
| 2758 |
regardless of whether the product has substantial commercial, |
| 2759 |
industrial or non-consumer uses, unless such uses represent the |
| 2760 |
only significant mode of use of the product. |
| 2761 |
|
| 2762 |
"Installation Information" for a User Product means any methods, |
| 2763 |
procedures, authorization keys, or other information required to |
| 2764 |
install and execute modified versions of a covered work in that |
| 2765 |
User Product from a modified version of its Corresponding Source. |
| 2766 |
The information must suffice to ensure that the continued |
| 2767 |
functioning of the modified object code is in no case prevented or |
| 2768 |
interfered with solely because modification has been made. |
| 2769 |
|
| 2770 |
If you convey an object code work under this section in, or with, |
| 2771 |
or specifically for use in, a User Product, and the conveying |
| 2772 |
occurs as part of a transaction in which the right of possession |
| 2773 |
and use of the User Product is transferred to the recipient in |
| 2774 |
perpetuity or for a fixed term (regardless of how the transaction |
| 2775 |
is characterized), the Corresponding Source conveyed under this |
| 2776 |
section must be accompanied by the Installation Information. But |
| 2777 |
this requirement does not apply if neither you nor any third party |
| 2778 |
retains the ability to install modified object code on the User |
| 2779 |
Product (for example, the work has been installed in ROM). |
| 2780 |
|
| 2781 |
The requirement to provide Installation Information does not |
| 2782 |
include a requirement to continue to provide support service, |
| 2783 |
warranty, or updates for a work that has been modified or installed |
| 2784 |
by the recipient, or for the User Product in which it has been |
| 2785 |
modified or installed. Access to a network may be denied when the |
| 2786 |
modification itself materially and adversely affects the operation |
| 2787 |
of the network or violates the rules and protocols for |
| 2788 |
communication across the network. |
| 2789 |
|
| 2790 |
Corresponding Source conveyed, and Installation Information |
| 2791 |
provided, in accord with this section must be in a format that is |
| 2792 |
publicly documented (and with an implementation available to the |
| 2793 |
public in source code form), and must require no special password |
| 2794 |
or key for unpacking, reading or copying. |
| 2795 |
|
| 2796 |
7. Additional Terms. |
| 2797 |
|
| 2798 |
"Additional permissions" are terms that supplement the terms of |
| 2799 |
this License by making exceptions from one or more of its |
| 2800 |
conditions. Additional permissions that are applicable to the |
| 2801 |
entire Program shall be treated as though they were included in |
| 2802 |
this License, to the extent that they are valid under applicable |
| 2803 |
law. If additional permissions apply only to part of the Program, |
| 2804 |
that part may be used separately under those permissions, but the |
| 2805 |
entire Program remains governed by this License without regard to |
| 2806 |
the additional permissions. |
| 2807 |
|
| 2808 |
When you convey a copy of a covered work, you may at your option |
| 2809 |
remove any additional permissions from that copy, or from any part |
| 2810 |
of it. (Additional permissions may be written to require their own |
| 2811 |
removal in certain cases when you modify the work.) You may place |
| 2812 |
additional permissions on material, added by you to a covered work, |
| 2813 |
for which you have or can give appropriate copyright permission. |
| 2814 |
|
| 2815 |
Notwithstanding any other provision of this License, for material |
| 2816 |
you add to a covered work, you may (if authorized by the copyright |
| 2817 |
holders of that material) supplement the terms of this License with |
| 2818 |
terms: |
| 2819 |
|
| 2820 |
a. Disclaiming warranty or limiting liability differently from |
| 2821 |
the terms of sections 15 and 16 of this License; or |
| 2822 |
|
| 2823 |
b. Requiring preservation of specified reasonable legal notices |
| 2824 |
or author attributions in that material or in the Appropriate |
| 2825 |
Legal Notices displayed by works containing it; or |
| 2826 |
|
| 2827 |
c. Prohibiting misrepresentation of the origin of that material, |
| 2828 |
or requiring that modified versions of such material be marked |
| 2829 |
in reasonable ways as different from the original version; or |
| 2830 |
|
| 2831 |
d. Limiting the use for publicity purposes of names of licensors |
| 2832 |
or authors of the material; or |
| 2833 |
|
| 2834 |
e. Declining to grant rights under trademark law for use of some |
| 2835 |
trade names, trademarks, or service marks; or |
| 2836 |
|
| 2837 |
f. Requiring indemnification of licensors and authors of that |
| 2838 |
material by anyone who conveys the material (or modified |
| 2839 |
versions of it) with contractual assumptions of liability to |
| 2840 |
the recipient, for any liability that these contractual |
| 2841 |
assumptions directly impose on those licensors and authors. |
| 2842 |
|
| 2843 |
All other non-permissive additional terms are considered "further |
| 2844 |
restrictions" within the meaning of section 10. If the Program as |
| 2845 |
you received it, or any part of it, contains a notice stating that |
| 2846 |
it is governed by this License along with a term that is a further |
| 2847 |
restriction, you may remove that term. If a license document |
| 2848 |
contains a further restriction but permits relicensing or conveying |
| 2849 |
under this License, you may add to a covered work material governed |
| 2850 |
by the terms of that license document, provided that the further |
| 2851 |
restriction does not survive such relicensing or conveying. |
| 2852 |
|
| 2853 |
If you add terms to a covered work in accord with this section, you |
| 2854 |
must place, in the relevant source files, a statement of the |
| 2855 |
additional terms that apply to those files, or a notice indicating |
| 2856 |
where to find the applicable terms. |
| 2857 |
|
| 2858 |
Additional terms, permissive or non-permissive, may be stated in |
| 2859 |
the form of a separately written license, or stated as exceptions; |
| 2860 |
the above requirements apply either way. |
| 2861 |
|
| 2862 |
8. Termination. |
| 2863 |
|
| 2864 |
You may not propagate or modify a covered work except as expressly |
| 2865 |
provided under this License. Any attempt otherwise to propagate or |
| 2866 |
modify it is void, and will automatically terminate your rights |
| 2867 |
under this License (including any patent licenses granted under the |
| 2868 |
third paragraph of section 11). |
| 2869 |
|
| 2870 |
However, if you cease all violation of this License, then your |
| 2871 |
license from a particular copyright holder is reinstated (a) |
| 2872 |
provisionally, unless and until the copyright holder explicitly and |
| 2873 |
finally terminates your license, and (b) permanently, if the |
| 2874 |
copyright holder fails to notify you of the violation by some |
| 2875 |
reasonable means prior to 60 days after the cessation. |
| 2876 |
|
| 2877 |
Moreover, your license from a particular copyright holder is |
| 2878 |
reinstated permanently if the copyright holder notifies you of the |
| 2879 |
violation by some reasonable means, this is the first time you have |
| 2880 |
received notice of violation of this License (for any work) from |
| 2881 |
that copyright holder, and you cure the violation prior to 30 days |
| 2882 |
after your receipt of the notice. |
| 2883 |
|
| 2884 |
Termination of your rights under this section does not terminate |
| 2885 |
the licenses of parties who have received copies or rights from you |
| 2886 |
under this License. If your rights have been terminated and not |
| 2887 |
permanently reinstated, you do not qualify to receive new licenses |
| 2888 |
for the same material under section 10. |
| 2889 |
|
| 2890 |
9. Acceptance Not Required for Having Copies. |
| 2891 |
|
| 2892 |
You are not required to accept this License in order to receive or |
| 2893 |
run a copy of the Program. Ancillary propagation of a covered work |
| 2894 |
occurring solely as a consequence of using peer-to-peer |
| 2895 |
transmission to receive a copy likewise does not require |
| 2896 |
acceptance. However, nothing other than this License grants you |
| 2897 |
permission to propagate or modify any covered work. These actions |
| 2898 |
infringe copyright if you do not accept this License. Therefore, |
| 2899 |
by modifying or propagating a covered work, you indicate your |
| 2900 |
acceptance of this License to do so. |
| 2901 |
|
| 2902 |
10. Automatic Licensing of Downstream Recipients. |
| 2903 |
|
| 2904 |
Each time you convey a covered work, the recipient automatically |
| 2905 |
receives a license from the original licensors, to run, modify and |
| 2906 |
propagate that work, subject to this License. You are not |
| 2907 |
responsible for enforcing compliance by third parties with this |
| 2908 |
License. |
| 2909 |
|
| 2910 |
An "entity transaction" is a transaction transferring control of an |
| 2911 |
organization, or substantially all assets of one, or subdividing an |
| 2912 |
organization, or merging organizations. If propagation of a |
| 2913 |
covered work results from an entity transaction, each party to that |
| 2914 |
transaction who receives a copy of the work also receives whatever |
| 2915 |
licenses to the work the party's predecessor in interest had or |
| 2916 |
could give under the previous paragraph, plus a right to possession |
| 2917 |
of the Corresponding Source of the work from the predecessor in |
| 2918 |
interest, if the predecessor has it or can get it with reasonable |
| 2919 |
efforts. |
| 2920 |
|
| 2921 |
You may not impose any further restrictions on the exercise of the |
| 2922 |
rights granted or affirmed under this License. For example, you |
| 2923 |
may not impose a license fee, royalty, or other charge for exercise |
| 2924 |
of rights granted under this License, and you may not initiate |
| 2925 |
litigation (including a cross-claim or counterclaim in a lawsuit) |
| 2926 |
alleging that any patent claim is infringed by making, using, |
| 2927 |
selling, offering for sale, or importing the Program or any portion |
| 2928 |
of it. |
| 2929 |
|
| 2930 |
11. Patents. |
| 2931 |
|
| 2932 |
A "contributor" is a copyright holder who authorizes use under this |
| 2933 |
License of the Program or a work on which the Program is based. |
| 2934 |
The work thus licensed is called the contributor's "contributor |
| 2935 |
version". |
| 2936 |
|
| 2937 |
A contributor's "essential patent claims" are all patent claims |
| 2938 |
owned or controlled by the contributor, whether already acquired or |
| 2939 |
hereafter acquired, that would be infringed by some manner, |
| 2940 |
permitted by this License, of making, using, or selling its |
| 2941 |
contributor version, but do not include claims that would be |
| 2942 |
infringed only as a consequence of further modification of the |
| 2943 |
contributor version. For purposes of this definition, "control" |
| 2944 |
includes the right to grant patent sublicenses in a manner |
| 2945 |
consistent with the requirements of this License. |
| 2946 |
|
| 2947 |
Each contributor grants you a non-exclusive, worldwide, |
| 2948 |
royalty-free patent license under the contributor's essential |
| 2949 |
patent claims, to make, use, sell, offer for sale, import and |
| 2950 |
otherwise run, modify and propagate the contents of its contributor |
| 2951 |
version. |
| 2952 |
|
| 2953 |
In the following three paragraphs, a "patent license" is any |
| 2954 |
express agreement or commitment, however denominated, not to |
| 2955 |
enforce a patent (such as an express permission to practice a |
| 2956 |
patent or covenant not to sue for patent infringement). To "grant" |
| 2957 |
such a patent license to a party means to make such an agreement or |
| 2958 |
commitment not to enforce a patent against the party. |
| 2959 |
|
| 2960 |
If you convey a covered work, knowingly relying on a patent |
| 2961 |
license, and the Corresponding Source of the work is not available |
| 2962 |
for anyone to copy, free of charge and under the terms of this |
| 2963 |
License, through a publicly available network server or other |
| 2964 |
readily accessible means, then you must either (1) cause the |
| 2965 |
Corresponding Source to be so available, or (2) arrange to deprive |
| 2966 |
yourself of the benefit of the patent license for this particular |
| 2967 |
work, or (3) arrange, in a manner consistent with the requirements |
| 2968 |
of this License, to extend the patent license to downstream |
| 2969 |
recipients. "Knowingly relying" means you have actual knowledge |
| 2970 |
that, but for the patent license, your conveying the covered work |
| 2971 |
in a country, or your recipient's use of the covered work in a |
| 2972 |
country, would infringe one or more identifiable patents in that |
| 2973 |
country that you have reason to believe are valid. |
| 2974 |
|
| 2975 |
If, pursuant to or in connection with a single transaction or |
| 2976 |
arrangement, you convey, or propagate by procuring conveyance of, a |
| 2977 |
covered work, and grant a patent license to some of the parties |
| 2978 |
receiving the covered work authorizing them to use, propagate, |
| 2979 |
modify or convey a specific copy of the covered work, then the |
| 2980 |
patent license you grant is automatically extended to all |
| 2981 |
recipients of the covered work and works based on it. |
| 2982 |
|
| 2983 |
A patent license is "discriminatory" if it does not include within |
| 2984 |
the scope of its coverage, prohibits the exercise of, or is |
| 2985 |
conditioned on the non-exercise of one or more of the rights that |
| 2986 |
are specifically granted under this License. You may not convey a |
| 2987 |
covered work if you are a party to an arrangement with a third |
| 2988 |
party that is in the business of distributing software, under which |
| 2989 |
you make payment to the third party based on the extent of your |
| 2990 |
activity of conveying the work, and under which the third party |
| 2991 |
grants, to any of the parties who would receive the covered work |
| 2992 |
from you, a discriminatory patent license (a) in connection with |
| 2993 |
copies of the covered work conveyed by you (or copies made from |
| 2994 |
those copies), or (b) primarily for and in connection with specific |
| 2995 |
products or compilations that contain the covered work, unless you |
| 2996 |
entered into that arrangement, or that patent license was granted, |
| 2997 |
prior to 28 March 2007. |
| 2998 |
|
| 2999 |
Nothing in this License shall be construed as excluding or limiting |
| 3000 |
any implied license or other defenses to infringement that may |
| 3001 |
otherwise be available to you under applicable patent law. |
| 3002 |
|
| 3003 |
12. No Surrender of Others' Freedom. |
| 3004 |
|
| 3005 |
If conditions are imposed on you (whether by court order, agreement |
| 3006 |
or otherwise) that contradict the conditions of this License, they |
| 3007 |
do not excuse you from the conditions of this License. If you |
| 3008 |
cannot convey a covered work so as to satisfy simultaneously your |
| 3009 |
obligations under this License and any other pertinent obligations, |
| 3010 |
then as a consequence you may not convey it at all. For example, |
| 3011 |
if you agree to terms that obligate you to collect a royalty for |
| 3012 |
further conveying from those to whom you convey the Program, the |
| 3013 |
only way you could satisfy both those terms and this License would |
| 3014 |
be to refrain entirely from conveying the Program. |
| 3015 |
|
| 3016 |
13. Use with the GNU Affero General Public License. |
| 3017 |
|
| 3018 |
Notwithstanding any other provision of this License, you have |
| 3019 |
permission to link or combine any covered work with a work licensed |
| 3020 |
under version 3 of the GNU Affero General Public License into a |
| 3021 |
single combined work, and to convey the resulting work. The terms |
| 3022 |
of this License will continue to apply to the part which is the |
| 3023 |
covered work, but the special requirements of the GNU Affero |
| 3024 |
General Public License, section 13, concerning interaction through |
| 3025 |
a network will apply to the combination as such. |
| 3026 |
|
| 3027 |
14. Revised Versions of this License. |
| 3028 |
|
| 3029 |
The Free Software Foundation may publish revised and/or new |
| 3030 |
versions of the GNU General Public License from time to time. Such |
| 3031 |
new versions will be similar in spirit to the present version, but |
| 3032 |
may differ in detail to address new problems or concerns. |
| 3033 |
|
| 3034 |
Each version is given a distinguishing version number. If the |
| 3035 |
Program specifies that a certain numbered version of the GNU |
| 3036 |
General Public License "or any later version" applies to it, you |
| 3037 |
have the option of following the terms and conditions either of |
| 3038 |
that numbered version or of any later version published by the Free |
| 3039 |
Software Foundation. If the Program does not specify a version |
| 3040 |
number of the GNU General Public License, you may choose any |
| 3041 |
version ever published by the Free Software Foundation. |
| 3042 |
|
| 3043 |
If the Program specifies that a proxy can decide which future |
| 3044 |
versions of the GNU General Public License can be used, that |
| 3045 |
proxy's public statement of acceptance of a version permanently |
| 3046 |
authorizes you to choose that version for the Program. |
| 3047 |
|
| 3048 |
Later license versions may give you additional or different |
| 3049 |
permissions. However, no additional obligations are imposed on any |
| 3050 |
author or copyright holder as a result of your choosing to follow a |
| 3051 |
later version. |
| 3052 |
|
| 3053 |
15. Disclaimer of Warranty. |
| 3054 |
|
| 3055 |
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY |
| 3056 |
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE |
| 3057 |
COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" |
| 3058 |
WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, |
| 3059 |
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 3060 |
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE |
| 3061 |
RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. |
| 3062 |
SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL |
| 3063 |
NECESSARY SERVICING, REPAIR OR CORRECTION. |
| 3064 |
|
| 3065 |
16. Limitation of Liability. |
| 3066 |
|
| 3067 |
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN |
| 3068 |
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES |
| 3069 |
AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR |
| 3070 |
DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR |
| 3071 |
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE |
| 3072 |
THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA |
| 3073 |
BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD |
| 3074 |
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER |
| 3075 |
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF |
| 3076 |
THE POSSIBILITY OF SUCH DAMAGES. |
| 3077 |
|
| 3078 |
17. Interpretation of Sections 15 and 16. |
| 3079 |
|
| 3080 |
If the disclaimer of warranty and limitation of liability provided |
| 3081 |
above cannot be given local legal effect according to their terms, |
| 3082 |
reviewing courts shall apply local law that most closely |
| 3083 |
approximates an absolute waiver of all civil liability in |
| 3084 |
connection with the Program, unless a warranty or assumption of |
| 3085 |
liability accompanies a copy of the Program in return for a fee. |
| 3086 |
|
| 3087 |
END OF TERMS AND CONDITIONS |
| 3088 |
|
| 3089 |
How to Apply These Terms to Your New Programs |
| 3090 |
============================================= |
| 3091 |
|
| 3092 |
If you develop a new program, and you want it to be of the greatest |
| 3093 |
possible use to the public, the best way to achieve this is to make it |
| 3094 |
free software which everyone can redistribute and change under these |
| 3095 |
terms. |
| 3096 |
|
| 3097 |
To do so, attach the following notices to the program. It is safest |
| 3098 |
to attach them to the start of each source file to most effectively |
| 3099 |
state the exclusion of warranty; and each file should have at least the |
| 3100 |
"copyright" line and a pointer to where the full notice is found. |
| 3101 |
ONE LINE TO GIVE THE PROGRAM'S NAME AND A BRIEF IDEA OF WHAT IT DOES. |
| 3102 |
Copyright (C) YEAR NAME OF AUTHOR |
| 3103 |
|
| 3104 |
This program is free software: you can redistribute it and/or modify |
| 3105 |
it under the terms of the GNU General Public License as published by |
| 3106 |
the Free Software Foundation, either version 3 of the License, or (at |
| 3107 |
your option) any later version. |
| 3108 |
|
| 3109 |
This program is distributed in the hope that it will be useful, but |
| 3110 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
| 3111 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 3112 |
General Public License for more details. |
| 3113 |
|
| 3114 |
You should have received a copy of the GNU General Public License |
| 3115 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 3116 |
|
| 3117 |
Also add information on how to contact you by electronic and paper |
| 3118 |
mail. |
| 3119 |
|
| 3120 |
If the program does terminal interaction, make it output a short |
| 3121 |
notice like this when it starts in an interactive mode: |
| 3122 |
|
| 3123 |
PROGRAM Copyright (C) YEAR NAME OF AUTHOR |
| 3124 |
This program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. |
| 3125 |
This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. |
| 3126 |
|
| 3127 |
The hypothetical commands 'show w' and 'show c' should show the |
| 3128 |
appropriate parts of the General Public License. Of course, your |
| 3129 |
program's commands might be different; for a GUI interface, you would |
| 3130 |
use an "about box". |
| 3131 |
|
| 3132 |
You should also get your employer (if you work as a programmer) or |
| 3133 |
school, if any, to sign a "copyright disclaimer" for the program, if |
| 3134 |
necessary. For more information on this, and how to apply and follow |
| 3135 |
the GNU GPL, see <http://www.gnu.org/licenses/>. |
| 3136 |
|
| 3137 |
The GNU General Public License does not permit incorporating your |
| 3138 |
program into proprietary programs. If your program is a subroutine |
| 3139 |
library, you may consider it more useful to permit linking proprietary |
| 3140 |
applications with the library. If this is what you want to do, use the |
| 3141 |
GNU Lesser General Public License instead of this License. But first, |
| 3142 |
please read <http://www.gnu.org/philosophy/why-not-lgpl.html>. |
| 3143 |
|
| 3144 |
|
| 3145 |
File: assuan.info, Node: Index, Prev: Copying, Up: Top |
| 3146 |
|
| 3147 |
Index |
| 3148 |
***** |
| 3149 |
|
| 3150 |
|