Added pwmd_disconnect() to close the connection without freeing the
[libpwmd.git] / doc / libpwmd.3
blobd3242c43e468d1172cc76d859e68097fd99a9003
1 .TH "libpwmd.h" 3 "13 Apr 2009" "Version 6.0.0" "libpwmd" \" -*- nroff -*-
2 .ad l
3 .nh
4 .SH NAME
5 libpwmd.h - an API for accessing pwmd
6 .SH "Description"
7 .PP 
8 libpwmd is a library making it easy for applications to use the pwmd server.
9 .SH "SSH Details"
10 .PP
11 A remote connection to a pwmd server is possible by using an SSH channel which spawns a shell and executes a proxy server that connects to the pwmd local UNIX domain socket. Authentication is done by using SSH public key (see \fBssh-keygen(1)\fP) authentication and verifying the host key against a local file containing SHA1 hashes of known hosts. It's a lot like how the standard OpenSSH does things only the known_hosts file is in a different format.
12 .PP
13 The server hash can be had by using \fBpwmd_get_hostkey()\fP and storing the result in a file. This file is then used as the \fIknown_hosts\fP argument to the SSH connection functions.
14 .PP
15 Here's an example \fBauthorized_keys(5)\fP entry. The hash portion should be the same as the contents of the \fIidentity.pub\fP file which is passed as a parameter to the SSH connection functions:
16 .PP
17 .PP
18 .nf
19  command='socat gopen:$HOME/.pwmd/socket -' <hash> ...
20 .fi
21 .PP
22 .PP
23 \fBNote:\fP
24 .RS 4
25 Only an SSH identity without a passphrase is supported. For now anyway.
26 .RE
27 .PP
28 \fBTodo\fP
29 .RS 4
30 X11 port forwarding so a remote pinentry can use the local display. 
31 .RE
32 .PP
33 .SH "Pinentry Details"
34 .PP
35 \fBpinentry(1)\fP is a program that prompts the user for input which is normally a passphrase or a confirmation. libpwmd can use this program either locally (X11 forwarding is not yet supported) or have the pwmd server use it's pinentry to retrieve a passphrase when needed. How this is done depends what function gets called and whether the pwmd connection is over an SSH channel.
36 .PP
37 There are a few options that tell pinentry how and where to prompt for a needed passphrase. See the \fBpwmd_option_t\fP section for details. These options are not sent (when using pwmd's pinentry, not the local one) until the pinentry is needed.
38 .PP
39 If using a local pinentry by calling \fBpwmd_open2()\fP, \fBpwmd_save2()\fP, \fBpwmd_open_async2()\fP or \fBpwmd_save_async2()\fP, libpwmd will send the command 'OPTION PINENTRY=0' to the pwmd server. This is needed so pwmd wont try to launch it's own pinentry on passphrase or confirmation failure. So you may need to reset this option manually depending on your needs.
40 .PP
41 Some pinentry options can also be specified in a local configuration file \fI'~/.pwmd/pinentry.conf'\fP. These options are initial values for each pinentry invokation and may be changed by setting the appropriate \fBpwmd_option_t\fP. Each option and value is separated with a '=' on a single line. Unrecognized options are ignored. Here are the recognized options:
42 .PP
43 \fBParameters:\fP
44 .RS 4
45 \fIPATH\fP The full path to the location of the pinentry binary. 
46 .br
47 \fIDISPLAY\fP The X11 display to use. 
48 .br
49 \fITTYNAME\fP The full path to the tty that pinentry should prompt on. 
50 .br
51 \fITTYTYPE\fP The terminal type of the tty which is required if DISPLAY is not set.
52 .RE
53 .PP
54 \fBNote:\fP
55 .RS 4
56 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user.
57 .PP
58 The initial values for the pinentry TTY, TERM and DISPLAY are set during \fBpwmd_new()\fP depending on the current environment. They may need to be reset as needed.
59 .PP
60 After establishing an SSH connection, the pwmd pinentry is disabled by sending the command 'OPTION PINENTRY=0'. This is needed because there currently isn't a way to have the remote pinentry use the local display. You must be careful to use either a local pinentry or set a passphrase manually with \fBpwmd_setopt()\fP when a passphrase is required or needed.
61 .RE
62 .PP
63 \fBTodo\fP
64 .RS 4
65 X11 port forwarding so a remote pinentry can use the local display.
66 .RE
67 .PP
68 \fBSee also:\fP
69 .RS 4
70 \fBSSH Details\fP
71 .RE
72 .PP
73 .SH "Errors"
74 .PP
75 libpwmd uses libgpg-error for all error codes. Some are user defined GPG_ERR_USER_N codes, but most are reused from the existing ones. Error codes can be described by using \fBpwmd_strerror()\fP, or the thread-safe \fBpwmd_strerror_r()\fP.
76 .PP
77 \fBNote:\fP
78 .RS 4
79 Internally, some error codes are a bitmask of an error source. In order to simplify the result codes, libpwmd strips any error source from the error code before returning it.
80 .RE
81 .PP
82 .SH "Example Client"
83 .PP
84 The following example will list the element tree of the data file specified in the first command line argument.
85 .PP
86 .PP
87 .nf
88  #include <stdio.h>
89  #include <stdlib.h>
90  #include <libpwmd.h>
92  int main(int argc, char **argv)
93  {
94      pwm_t *pwm = pwmd_new(NULL);
95      gpg_error_t rc = pwmd_connect(pwm, NULL);
96      char *result;
97      
98      if (!rc) {
99          rc = pwmd_open(pwm, argv[1]);
101          if (!rc) {
102              rc = pwmd_command(pwm, &result, '%s', 'LIST');
104              if (!rc) {
105                  printf('%s', result);
106                  pwmd_free(result);
107              }
108          }
109      }
111      pwmd_close(pwm);
112      
113      if (rc)
114          fprintf(stderr, 'ERR: %s\n', pwmd_strerror(rc));
116      exit(rc ? 1 : 0);
121 .SH SYNOPSIS
124 .SS "Data Structures"
126 .in +1c
127 .ti -1c
128 .RI "struct \fBpwmd_fd_t\fP"
130 .in -1c
131 .SS "Constants"
133 .in +1c
134 .ti -1c
135 .RI "#define \fBLIBPWMD_VERSION\fP   0x600"
137 .ti -1c
138 .RI "#define \fBPWMD_FD_READABLE\fP"
140 .ti -1c
141 .RI "#define \fBPWMD_FD_WRITABLE\fP"
143 .ti -1c
144 .RI "#define \fBEPWMD_ERROR\fP"
146 .ti -1c
147 .RI "#define \fBEPWMD_MAX_SLOTS\fP"
149 .ti -1c
150 .RI "#define \fBEPWMD_LOOP\fP"
152 .ti -1c
153 .RI "#define \fBEPWMD_NO_FILE\fP"
155 .ti -1c
156 .RI "#define \fBEPWMD_LIBXML_ERROR\fP"
158 .ti -1c
159 .RI "#define \fBEPWMD_FILE_MODIFIED\fP"
161 .ti -1c
162 .RI "#define \fBEPWMD_MAX\fP"
164 .in -1c
165 .SS "Typedefs"
167 .in +1c
168 .ti -1c
169 .RI "typedef struct pwm_s \fBpwm_t\fP"
171 .ti -1c
172 .RI "typedef gpg_error_t(* \fBpwmd_passphrase_cb_t\fP )(void *user, char **passphrase)"
174 .ti -1c
175 .RI "typedef int(* \fBpwmd_status_cb_t\fP )(void *user, const char *line)"
177 .ti -1c
178 .RI "typedef gpg_error_t(* \fBpwmd_inquire_cb_t\fP )(void *user, const char *cmd, gpg_error_t rc, char **data, size_t *len)"
180 .in -1c
181 .SS "Enumerations"
183 .in +1c
184 .ti -1c
185 .RI "enum \fBpwmd_async_t\fP { \fBASYNC_INIT\fP, \fBASYNC_PROCESS\fP, \fBASYNC_DONE\fP }"
187 .ti -1c
188 .RI "enum \fBpwmd_ip_version_t\fP { \fBPWMD_IP_ANY\fP, \fBPWMD_IPV4\fP, \fBPWMD_IPV6\fP }"
190 .ti -1c
191 .RI "enum \fBpwmd_socket_t\fP { \fBPWMD_SOCKET_UDS\fP, \fBPWMD_SOCKET_SSH\fP }"
193 .ti -1c
194 .RI "enum \fBpwmd_option_t\fP { \fBPWMD_OPTION_PASSPHRASE_CB\fP, \fBPWMD_OPTION_PASSPHRASE_DATA\fP, \fBPWMD_OPTION_PASSPHRASE\fP, \fBPWMD_OPTION_PINENTRY_TRIES\fP, \fBPWMD_OPTION_PINENTRY_PATH\fP, \fBPWMD_OPTION_PINENTRY_TTY\fP, \fBPWMD_OPTION_PINENTRY_TERM\fP, \fBPWMD_OPTION_PINENTRY_DISPLAY\fP, \fBPWMD_OPTION_PINENTRY_TITLE\fP, \fBPWMD_OPTION_PINENTRY_PROMPT\fP, \fBPWMD_OPTION_PINENTRY_DESC\fP, \fBPWMD_OPTION_PINENTRY_LC_CTYPE\fP, \fBPWMD_OPTION_PINENTRY_LC_MESSAGES\fP, \fBPWMD_OPTION_PINENTRY_TIMEOUT\fP, \fBPWMD_OPTION_STATUS_CB\fP, \fBPWMD_OPTION_STATUS_DATA\fP, \fBPWMD_OPTION_IP_VERSION\fP }"
196 .in -1c
197 .SS "Functions"
199 .in +1c
200 .ti -1c
201 .RI "gpg_error_t \fBpwmd_init\fP (void)"
203 .ti -1c
204 .RI "\fBpwm_t\fP * \fBpwmd_new\fP (const char *name)"
206 .ti -1c
207 .RI "gpg_error_t \fBpwmd_connect\fP (\fBpwm_t\fP *pwm, const char *path)"
209 .ti -1c
210 .RI "gpg_error_t \fBpwmd_ssh_connect\fP (\fBpwm_t\fP *pwm, const char *host, int port, const char *identity, const char *user, const char *known_hosts)"
212 .ti -1c
213 .RI "gpg_error_t \fBpwmd_ssh_connect_async\fP (\fBpwm_t\fP *pwm, const char *host, int port, const char *identity, const char *user, const char *known_hosts)"
215 .ti -1c
216 .RI "gpg_error_t \fBpwmd_connect_url\fP (\fBpwm_t\fP *pwm, const char *url)"
218 .ti -1c
219 .RI "gpg_error_t \fBpwmd_connect_url_async\fP (\fBpwm_t\fP *pwm, const char *url)"
221 .ti -1c
222 .RI "gpg_error_t \fBpwmd_get_hostkey\fP (\fBpwm_t\fP *pwm, const char *host, int port, char **result)"
224 .ti -1c
225 .RI "gpg_error_t \fBpwmd_get_hostkey_async\fP (\fBpwm_t\fP *pwm, const char *host, int port)"
227 .ti -1c
228 .RI "gpg_error_t \fBpwmd_get_fds\fP (\fBpwm_t\fP *pwm, \fBpwmd_fd_t\fP *fds, int *n_fds)"
230 .ti -1c
231 .RI "gpg_error_t \fBpwmd_pending_line\fP (\fBpwm_t\fP *pwm)"
233 .ti -1c
234 .RI "gpg_error_t \fBpwmd_setopt\fP (\fBpwm_t\fP *pwm, \fBpwmd_option_t\fP opt,...)"
236 .ti -1c
237 .RI "gpg_error_t \fBpwmd_open\fP (\fBpwm_t\fP *pwm, const char *filename)"
239 .ti -1c
240 .RI "gpg_error_t \fBpwmd_open2\fP (\fBpwm_t\fP *pwm, const char *filename)"
242 .ti -1c
243 .RI "gpg_error_t \fBpwmd_open_async2\fP (\fBpwm_t\fP *pwm, const char *filename)"
245 .ti -1c
246 .RI "gpg_error_t \fBpwmd_open_async\fP (\fBpwm_t\fP *pwm, const char *filename)"
248 .ti -1c
249 .RI "\fBpwmd_async_t\fP \fBpwmd_process\fP (\fBpwm_t\fP *pwm, gpg_error_t *rc, char **result)"
251 .ti -1c
252 .RI "gpg_error_t \fBpwmd_save\fP (\fBpwm_t\fP *pwm)"
254 .ti -1c
255 .RI "gpg_error_t \fBpwmd_save2\fP (\fBpwm_t\fP *pwm)"
257 .ti -1c
258 .RI "gpg_error_t \fBpwmd_save_async2\fP (\fBpwm_t\fP *pwm)"
260 .ti -1c
261 .RI "gpg_error_t \fBpwmd_save_async\fP (\fBpwm_t\fP *pwm)"
263 .ti -1c
264 .RI "gpg_error_t \fBpwmd_command\fP (\fBpwm_t\fP *pwm, char **result, const char *cmd,...)"
266 .ti -1c
267 .RI "gpg_error_t \fBpwmd_command_ap\fP (\fBpwm_t\fP *pwm, char **result, const char *cmd, va_list ap)"
269 .ti -1c
270 .RI "gpg_error_t \fBpwmd_inquire\fP (\fBpwm_t\fP *pwm, const char *cmd, \fBpwmd_inquire_cb_t\fP func, void *user)"
272 .ti -1c
273 .RI "gpg_error_t \fBpwmd_disconnect\fP (\fBpwm_t\fP *pwm)"
275 .ti -1c
276 .RI "void \fBpwmd_close\fP (\fBpwm_t\fP *pwm)"
278 .ti -1c
279 .RI "gpg_error_t \fBpwmd_socket_type\fP (\fBpwm_t\fP *pwm, \fBpwmd_socket_t\fP *type)"
281 .ti -1c
282 .RI "void \fBpwmd_free\fP (void *ptr)"
284 .ti -1c
285 .RI "void * \fBpwmd_malloc\fP (size_t size)"
287 .ti -1c
288 .RI "void * \fBpwmd_calloc\fP (size_t nmemb, size_t size)"
290 .ti -1c
291 .RI "void * \fBpwmd_realloc\fP (void *ptr, size_t size)"
293 .ti -1c
294 .RI "char * \fBpwmd_strdup\fP (const char *str)"
296 .ti -1c
297 .RI "char * \fBpwmd_strdup_printf\fP (const char *fmt,...)"
299 .ti -1c
300 .RI "const char * \fBpwmd_strerror\fP (gpg_error_t code)"
302 .ti -1c
303 .RI "int \fBpwmd_strerror_r\fP (gpg_error_t code, char *buf, size_t size)"
305 .in -1c
306 .SH "Constant Details"
307 .PP 
308 .SS "#define EPWMD_ERROR"
310 A general pwmd error with no suitable description. 
311 .SS "#define EPWMD_FILE_MODIFIED"
313 The data file was modified either externally or by another client while trying to process a command. 
314 .SS "#define EPWMD_LIBXML_ERROR"
316 An XML parse or other libxml2 error occurred. 
317 .SS "#define EPWMD_LOOP"
319 A recursion loop was detected while processing a 'target' attribute. 
320 .SS "#define EPWMD_MAX_SLOTS"
322 The maximum number of cache slots has been reached. There is no available slot for a new file. 
323 .SS "#define EPWMD_NO_FILE"
325 A command required an open file but no file has yet been opened. 
326 .SS "#define LIBPWMD_VERSION   0x600"
328 The version of this library. 
329 .SS "#define PWMD_FD_READABLE"
331 Set when the file descriptor is readable. 
332 .SS "#define PWMD_FD_WRITABLE"
334 Set when the file descriptor is writable. 
335 .SH "Typedef Details"
336 .PP 
337 .SS "\fBpwm_t\fP"
339 When a handle is mentioned in this documentation it is a pointer of this type. A new handle is created with \fBpwmd_new()\fP. 
340 .SS "\fBpwmd_inquire_cb_t\fP"
342 This is a callback function that gets passed to \fBpwmd_inquire()\fP. It is used for sending data to the server for commands that need to reply to an INQUIRE response (STORE and IMPORT). The reason for this callback is to let the client send as many bytes as it wants rather than the entire chunk at once. It gets called during an internal \fBassuan_transact()\fP from an internal inquire callback function which in turn calls this function by looping over its return value.
344 \fBParameters:\fP
345 .RS 4
346 \fIuser\fP The user data pointer passed to \fBpwmd_inquire()\fP. 
348 \fIcmd\fP The same as the \fIcmd\fP argument to \fBpwmd_inquire()\fP. 
350 \fIrc\fP The result of the last internal call to \fBassuan_send_data()\fP which did the sending of the data to the pwmd server. On the first call to this callback it's value will always be 0 because no data has been sent yet. 
352 \fIdata\fP The next chunk of data to send or NULL. 
354 \fIlen\fP The length of \fIdata\fP or 0.
357 \fBReturn values:\fP
358 .RS 4
359 \fI0\fP There is more data to be sent. 
361 \fIGPG_ERR_EOF\fP No need to call this function again, the current \fIline\fP is the last to send. 
363 \fIcode\fP Any other error code which will terminate the INQUIRE.
366 \fBNote:\fP
367 .RS 4
368 The sent data is processed line-per-line. The line is either newline terminated or is buffered until ASSUAN_LINELENGTH bytes have been allocated. Any remaining bytes are sent after the INQUIRE has finished. 
372 .SS "\fBpwmd_passphrase_cb_t\fP"
374 The value of the option \fBPWMD_OPTION_PASSPHRASE_CB\fP which is set with \fBpwmd_setopt()\fP.
376 \fBParameters:\fP
377 .RS 4
378 \fIuser\fP A user data pointer which is set with \fBPWMD_OPTION_PASSPHRASE_DATA\fP. 
380 \fIpassphrase\fP The passphrase which may be an empty string or NULL. It is not modified by libpwmd but must remain allocated for as long as it is needed. 
383 \fBReturns:\fP
384 .RS 4
385 0 on success or an error code which will cause a command to fail. 
389 .SS "\fBpwmd_status_cb_t\fP"
391 The value of the option \fBPWMD_OPTION_STATUS_CB\fP which is set with \fBpwmd_setopt()\fP.
393 \fBParameters:\fP
394 .RS 4
395 \fIuser\fP A user data pointer which is set with \fBPWMD_OPTION_STATUS_DATA\fP. 
397 \fIline\fP The status message line received from the server. 
400 \fBReturns:\fP
401 .RS 4
402 0 on success or an error code which will cause a command to fail. 
406 .SH "Enumeration Details"
407 .PP 
408 .SS "enum \fBpwmd_async_t\fP"
410 The return code of \fBpwmd_process()\fP which is used for all asynchronous commands. 
412 \fBEnumerator: \fP
413 .in +1c
415 \fB\fIASYNC_INIT \fP\fP
417 \fBFor internal use only.\fP
418 .RS 4
423 \fB\fIASYNC_PROCESS \fP\fP
424 \fBpwmd_process()\fP should be called again. 
426 \fB\fIASYNC_DONE \fP\fP
427 The command has completed. The result code should be checked for an error. 
428 .SS "enum \fBpwmd_ip_version_t\fP"
430 The value of the option \fBPWMD_OPTION_IP_VERSION\fP which is set with \fBpwmd_setopt()\fP. 
432 \fBEnumerator: \fP
433 .in +1c
435 \fB\fIPWMD_IP_ANY \fP\fP
436 Try both IPv6 and IPv4 addresses. Note that IPv6 is tried first. 
438 \fB\fIPWMD_IPV4 \fP\fP
439 Only try IPv4. 
441 \fB\fIPWMD_IPV6 \fP\fP
442 Only try IPv6. 
443 .SS "enum \fBpwmd_option_t\fP"
445 libpwmd options which are set with \fBpwmd_setopt()\fP.
447 \fBNote:\fP
448 .RS 4
449 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user. 
454 \fBEnumerator: \fP
455 .in +1c
457 \fB\fIPWMD_OPTION_PASSPHRASE_CB \fP\fP
458 A custom passphrase retrieval function which, when set, will be used instead of \fBpinentry(1)\fP. This function will not be used when the passphrase is cached on the server or the file is a new one. The value of this option should be a \fBpwmd_passphrase_cb_t\fP.
460 \fBNote:\fP
461 .RS 4
462 An empty string as the passphrase is allowed. 
467 \fB\fIPWMD_OPTION_PASSPHRASE_DATA \fP\fP
468 User supplied data which is passed to the custom passphrase function. 
470 \fB\fIPWMD_OPTION_PASSPHRASE \fP\fP
471 A string to use as the passphrase when doing an open or save. When not NULL, this option has precedence over \fBPWMD_OPTION_PASSPHRASE_CB\fP.
473 \fBNote:\fP
474 .RS 4
475 An empty string as the passphrase is allowed. 
480 \fB\fIPWMD_OPTION_PINENTRY_TRIES \fP\fP
481 An integer value that specifies the number of tries before \fBpinentry(1)\fP will give up when opening a file with the wrong supplied passphrase. The default is 3.
483 \fBNote:\fP
484 .RS 4
485 This option has no effect when trying to save a file. The user must either cancel the pinentry causing the save to fail or enter the correct passphrase during passphrase confirmation. 
490 \fB\fIPWMD_OPTION_PINENTRY_PATH \fP\fP
491 A character string value which specifies the full path of the \fBpinentry(1)\fP binary. For the local \fBpinentry(1)\fP method, the default is specified at compile time.
493 \fBSee also:\fP
494 .RS 4
495 \fBPinentry Details\fP 
500 \fB\fIPWMD_OPTION_PINENTRY_TTY \fP\fP
501 A value which specifies the full path to the tty that \fBpinentry(1)\fP will use to prompt on. When set and no DISPLAY is available, \fBPWMD_OPTION_PINENTRY_TERM\fP must also be set.
503 \fBSee also:\fP
504 .RS 4
505 \fBPinentry Details\fP 
510 \fB\fIPWMD_OPTION_PINENTRY_TERM \fP\fP
511 A value which specifies the terminal type (e.g., vt100) that \fBpinentry(1)\fP will use when no X11 display is available.
513 \fBSee also:\fP
514 .RS 4
515 \fBPinentry Details\fP 
520 \fB\fIPWMD_OPTION_PINENTRY_DISPLAY \fP\fP
521 A value which specifies the X11 display that \fBpinentry(1)\fP will use.
523 \fBSee also:\fP
524 .RS 4
525 \fBPinentry Details\fP 
530 \fB\fIPWMD_OPTION_PINENTRY_TITLE \fP\fP
531 A character string that \fBpinentry(1)\fP will use in it's dialog window. 
533 \fB\fIPWMD_OPTION_PINENTRY_PROMPT \fP\fP
534 A character string that \fBpinentry(1)\fP will use in it's dialog window.  
536 \fB\fIPWMD_OPTION_PINENTRY_DESC \fP\fP
537 A character string that \fBpinentry(1)\fP will use in it's dialog window.  
539 \fB\fIPWMD_OPTION_PINENTRY_LC_CTYPE \fP\fP
540 For \fBpinentry(1)\fP localization. 
542 \fB\fIPWMD_OPTION_PINENTRY_LC_MESSAGES \fP\fP
543 For \fBpinentry(1)\fP localization.  
545 \fB\fIPWMD_OPTION_PINENTRY_TIMEOUT \fP\fP
546 An integer value that specifies the number of seconds \fBpinentry(1)\fP will wait for input before timing out and aborting the current command. If 0, then no timeout will be used. The default is 30. 
548 \fB\fIPWMD_OPTION_STATUS_CB \fP\fP
549 A function of type \fBpwmd_status_cb_t\fP that will process status messages received from the pwmd server. 
551 \fB\fIPWMD_OPTION_STATUS_DATA \fP\fP
552 A user data pointer which is passed to the status message function. 
554 \fB\fIPWMD_OPTION_IP_VERSION \fP\fP
555 The IP version of type \fBpwmd_ip_version_t\fP that \fBpwmd_ssh_connect()\fP and \fBpwmd_ssh_connect_async()\fP will use when connecting to the remote pwmd server.
557 \fBNote:\fP
558 .RS 4
559 This option must be set before a connection is made when not the default. 
563 .SS "enum \fBpwmd_socket_t\fP"
565 For use with \fBpwmd_socket_type()\fP. 
567 \fBEnumerator: \fP
568 .in +1c
570 \fB\fIPWMD_SOCKET_UDS \fP\fP
571 A UNIX domain socket. 
573 \fB\fIPWMD_SOCKET_SSH \fP\fP
574 An SSH connection over a TCP socket. 
575 .SH "Function Details"
576 .PP 
577 .SS "void* pwmd_calloc (size_t nmemb, size_t size)"
579 A wrapper around calloc(). 
581 Like calloc(), but lets libpwmd keep track of the pointer.
583 \fBParameters:\fP
584 .RS 4
585 \fInmemb\fP The number of elements to allocate. 
587 \fIsize\fP The number of bytes to allocate. 
590 \fBReturns:\fP
591 .RS 4
592 A newly allocated pointer or NULL if there wasn't enough memory. 
595 \fBSee also:\fP
596 .RS 4
597 calloc(3), \fBpwmd_free()\fP 
601 .SS "void pwmd_close (\fBpwm_t\fP * pwm)"
603 Close a handle. 
605 This will close the connection to a pwmd server and free any resources associated with it.
607 \fBParameters:\fP
608 .RS 4
609 \fIpwm\fP A handle. 
612 \fBReturns:\fP
613 .RS 4
614 Nothing. 
617 \fBSee also:\fP
618 .RS 4
619 \fBpwmd_disconnect()\fP 
623 .SS "gpg_error_t pwmd_command (\fBpwm_t\fP * pwm, char ** result, const char * cmd,  ...)"
625 Send a command to the pwmd server. 
627 Sends a command to the pwmd server. You should avoid sending the BYE command here because the assuan context will be freed and bad things will happen. Use \fBpwmd_close()\fP instead. For commands that use an INQUIRE to send data to the server (STORE and IMPORT), \fBpwmd_inquire()\fP should be used and not this function.
629 \fBParameters:\fP
630 .RS 4
631 \fIpwm\fP A handle. 
633 \fIresult\fP The result of the command when successful which must be freed with \fBpwmd_free()\fP. Note that not all commands return a result. 
635 \fIcmd\fP The command to send and any following arguments. 
638 \fBReturns:\fP
639 .RS 4
640 0 on success or an error code. 
644 .SS "gpg_error_t pwmd_command_ap (\fBpwm_t\fP * pwm, char ** result, const char * cmd, va_list ap)"
646 Send a command to the pwmd server. 
648 Like \fBpwmd_command()\fP but uses an argument pointer instead.
650 \fBParameters:\fP
651 .RS 4
652 \fIpwm\fP A handle. 
654 \fIresult\fP The result of the command when successful which must be freed with \fBpwmd_free()\fP. Note that not all commands return a result. 
656 \fIcmd\fP The command to send. 
658 \fIap\fP The arguments to \fIcmd\fP. 
661 \fBReturns:\fP
662 .RS 4
663 0 on success or an error code. 
667 .SS "gpg_error_t pwmd_connect (\fBpwm_t\fP * pwm, const char * path)"
669 Connect to a local pwmd server. 
671 Connects to a local unix domain socket.
673 \fBParameters:\fP
674 .RS 4
675 \fIpwm\fP A handle. 
677 \fIpath\fP The socket path to connect to. If NULL, then a default of \fI'~/.pwmd/socket'\fP will be used. 
680 \fBReturns:\fP
681 .RS 4
682 0 on success or an error code. 
685 \fBNote:\fP
686 .RS 4
687 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user. 
690 \fBSee also:\fP
691 .RS 4
692 \fBpwmd_ssh_connect()\fP, \fBpwmd_ssh_connect_async()\fP, \fBpwmd_disconnect()\fP 
696 .SS "gpg_error_t pwmd_connect_url (\fBpwm_t\fP * pwm, const char * url)"
698 Establish a connection by parsing a URL. 
700 This allows for connecting to a pwmd server by parsing the given URL string. Whether the connection is to a remote or local server depends on the contents: 
703  socket://[path/to/local/socket]
705  or
707  ssh[46]://[username@]hostname[:port],identity,known_hosts
712 The parameters in square brackets are optional and if not specified then defaults will be used. If neither socket specification is matched, the \fIurl\fP is assumed to be a socket://.
714 \fBParameters:\fP
715 .RS 4
716 \fIpwm\fP A handle. 
718 \fIurl\fP The string to parse. 
721 \fBNote:\fP
722 .RS 4
723 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user. 
726 \fBReturns:\fP
727 .RS 4
728 0 on success or an error code. 
731 \fBSee also:\fP
732 .RS 4
733 \fBpwmd_socket_type()\fP, \fBpwmd_disconnect()\fP 
737 .SS "gpg_error_t pwmd_connect_url_async (\fBpwm_t\fP * pwm, const char * url)"
739 Establish a connection asynchronously by parsing a URL. 
741 This allows for connecting to a pwmd server by parsing the given URL string. Whether the connection is to a remote or local server depends on the contents: 
744  socket://[path/to/local/socket]
746  or
748  ssh[46]://[username@]hostname[:port],identity,known_hosts
753 The parameters in square brackets are optional and if not specified then defaults will be used. If neither socket specification is matched, the \fIurl\fP is assumed to be a socket://.
755 \fBpwmd_process()\fP should be called until the command completes.
757 \fBParameters:\fP
758 .RS 4
759 \fIpwm\fP A handle. 
761 \fIurl\fP The string to parse. 
764 \fBNote:\fP
765 .RS 4
766 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user. 
769 \fBReturns:\fP
770 .RS 4
771 0 on success or an error code. 
774 \fBSee also:\fP
775 .RS 4
776 \fBpwmd_socket_type()\fP, \fBpwmd_disconnect()\fP 
780 .SS "gpg_error_t pwmd_disconnect (\fBpwm_t\fP * pwm)"
782 Close a connection to the pwmd server. 
784 This will close the connection but keep any previously set options for the specified handle.
786 \fBParameters:\fP
787 .RS 4
788 \fIpwm\fP A handle. 
791 \fBReturns:\fP
792 .RS 4
793 0 on success or an error code. 
796 \fBSee also:\fP
797 .RS 4
798 \fBpwmd_close()\fP 
802 .SS "void pwmd_free (void * ptr)"
804 Free a previously allocated pointer. 
806 Use this function to free resources allocated by the other libpwmd memory functions. Do not use it to free allocations not made by the other libpwmd memory allocators.
808 The difference between the standard free() and this function is that this one will zero out the contents of the pointer before freeing it.
810 \fBParameters:\fP
811 .RS 4
812 \fIptr\fP The pointer to deallocate. 
815 \fBReturns:\fP
816 .RS 4
817 Nothing. 
820 \fBSee also:\fP
821 .RS 4
822 \fBpwmd_malloc()\fP, \fBpwmd_calloc()\fP, \fBpwmd_realloc()\fP, \fBpwmd_strdup()\fP, \fBpwmd_process()\fP, \fBpwmd_command()\fP 
826 .SS "gpg_error_t pwmd_get_fds (\fBpwm_t\fP * pwm, \fBpwmd_fd_t\fP * fds, int * n_fds)"
828 Get the associated file descriptor(s) for a handle. 
830 This function lets the application poll the available file descriptors for the specified handle. It should be called after each asynchronous function call and after each call to \fBpwmd_process()\fP since the polled file descriptors may have been closed since the previous call.
832 After returning, \fIn_fds\fP is set to the number of available file descriptors which are stored in \fIfds\fP. The .flags member of \fBpwmd_fd_t\fP specifies what can be monitored and is a bitmask of \fBPWMD_FD_READABLE\fP and \fBPWMD_FD_WRITABLE\fP. When ready, \fBpwmd_process()\fP should be called.
834 \fBParameters:\fP
835 .RS 4
836 \fIpwm\fP A handle. 
838 \fIfds\fP Set to the file descriptor(s) of the associated handle. 
840 \fIn_fds\fP Initially the size of \fIfds\fP then updated to the number of available file descriptors which are stored in \fIfds\fP. 
843 \fBReturn values:\fP
844 .RS 4
845 \fI0\fP on success or an error code. 
847 \fIGPG_ERR_ERANGE\fP There are more file descriptors than the amount specified in \fIn_fds\fP. \fIfds\fP and \fIn_fds\fP are still usable though. 
850 \fBSee also:\fP
851 .RS 4
852 \fBpwmd_process()\fP 
856 .SS "gpg_error_t pwmd_get_hostkey (\fBpwm_t\fP * pwm, const char * host, int port, char ** result)"
858 Retrieve a remote SSH host key. 
860 This key is needed for host verification of the remote pwmd server. You should be sure that the remote host is really the host that your wanting to connect to and not subject to a man-in-the-middle attack.
862 \fBParameters:\fP
863 .RS 4
864 \fIpwm\fP A handle. 
866 \fIhost\fP The hostname to connect to. 
868 \fIport\fP The port or a default if set to -1. 
870 \fIresult\fP The SHA1 sum of the server host key which must be freed with \fBpwmd_free()\fP. 
873 \fBReturns:\fP
874 .RS 4
875 0 on success or an error code. 
878 \fBSee also:\fP
879 .RS 4
880 \fBpwmd_get_hostkey_async()\fP, \fBSSH Details\fP 
884 .SS "gpg_error_t pwmd_get_hostkey_async (\fBpwm_t\fP * pwm, const char * host, int port)"
886 Retrieve a remote SSH host key asynchronously. 
888 This key is needed for host verification of the remote pwmd server. You should be sure that the remote host is really the host that your wanting to connect to and not subject to a man-in-the-middle attack.
890 \fBpwmd_process()\fP should be called until the command completes.
892 \fBParameters:\fP
893 .RS 4
894 \fIpwm\fP A handle. 
896 \fIhost\fP The hostname to connect to. 
898 \fIport\fP The port or a default if set to -1. 
901 \fBReturns:\fP
902 .RS 4
903 0 on success or an error code. 
906 \fBSee also:\fP
907 .RS 4
908 \fBpwmd_get_hostkey()\fP, \fBpwmd_process()\fP, \fBSSH Details\fP 
912 .SS "gpg_error_t pwmd_init (void)"
914 Initialize the library. 
916 This function must be the first function called in the library before any others. It sets up internationalization among other things.
918 \fBReturns:\fP
919 .RS 4
920 0 Success. 
924 .SS "gpg_error_t pwmd_inquire (\fBpwm_t\fP * pwm, const char * cmd, \fBpwmd_inquire_cb_t\fP func, void * user)"
926 Send data to a pwmd server. 
928 This lets commands that use an INQUIRE (STORE and IMPORT) send the data to the server. Use this function rather than \fBpwmd_command()\fP for these pwmd commands.
930 \fBParameters:\fP
931 .RS 4
932 \fIpwm\fP A handle. 
934 \fIcmd\fP The command (without arguments) to send that uses an INQUIRE. 
936 \fIfunc\fP A callback function which sets the data to be sent. 
938 \fIuser\fP A user data pointer passed to the callback function \fIfunc\fP. 
941 \fBReturns:\fP
942 .RS 4
943 0 on success or an error code.
946 \fBSee also:\fP
947 .RS 4
948 \fBpwmd_inquire_cb_t\fP 
952 .SS "void* pwmd_malloc (size_t size)"
954 A wrapper around malloc. 
956 Like malloc(), but lets libpwmd keep track of the pointer.
958 \fBParameters:\fP
959 .RS 4
960 \fIsize\fP The number of bytes to allocate. 
963 \fBReturns:\fP
964 .RS 4
965 A newly allocated pointer or NULL if there wasn't enough memory. 
968 \fBSee also:\fP
969 .RS 4
970 malloc(3), \fBpwmd_free()\fP 
974 .SS "\fBpwm_t\fP* pwmd_new (const char * name)"
976 Creates a new handle. 
978 Creates a new handle for use with the other functions.
980 \fBParameters:\fP
981 .RS 4
982 \fIname\fP If not NULL, the name of the application. The application name is sent to the pwmd server after successfully connecting.
984 \fIname\fP The application name or NULL. 
987 \fBReturns:\fP
988 .RS 4
989 a new handle or NULL if there was not enough memory. 
993 .SS "gpg_error_t pwmd_open (\fBpwm_t\fP * pwm, const char * filename)"
995 Open a file on the pwmd server. 
997 This will send the OPEN command to the server.
999 \fBParameters:\fP
1000 .RS 4
1001 \fIpwm\fP A handle. 
1003 \fIfilename\fP The filename to open. The \fIfilename\fP is not a full path but the data file only. 
1006 \fBReturns:\fP
1007 .RS 4
1008 0 on success or an error code. 
1011 \fBSee also:\fP
1012 .RS 4
1013 \fBPinentry Details\fP 
1017 .SS "gpg_error_t pwmd_open2 (\fBpwm_t\fP * pwm, const char * filename)"
1019 Open a file on the pwmd server using a local pinentry. 
1021 This will send the OPEN command to the server like \fBpwmd_open()\fP but will use the local pinentry and not pwmd's pinentry.
1023 \fBNote:\fP
1024 .RS 4
1025 This function will catch SIGALRM during the lifetime of the pinentry process and set it to SIG_DFL when finished. This is needed for pinentry timeouts.
1027 This pinentry method is not thread safe. It needs to set a couple of global variables for the pinentry timeout to work properly.
1030 \fBParameters:\fP
1031 .RS 4
1032 \fIpwm\fP A handle. 
1034 \fIfilename\fP The filename to open. The \fIfilename\fP is not a full path but the data file only. 
1037 \fBReturns:\fP
1038 .RS 4
1039 0 on success or an error code. 
1042 \fBReturn values:\fP
1043 .RS 4
1044 \fIGPG_ERR_PIN_BLOCKED\fP Another handle is using the local pinentry. 
1047 \fBSee also:\fP
1048 .RS 4
1049 \fBPinentry Details\fP 
1053 .SS "gpg_error_t pwmd_open_async (\fBpwm_t\fP * pwm, const char * filename)"
1055 Open a file on the pwmd server asynchronously. 
1057 This will send the OPEN command to the pwmd server. The difference from \fBpwmd_open()\fP is that it will not block if a pinentry is needed for passphrase input.
1059 \fBpwmd_process()\fP should be called until the command completes.
1061 \fBParameters:\fP
1062 .RS 4
1063 \fIpwm\fP A handle. 
1065 \fIfilename\fP The filename to open. The \fIfilename\fP is not a full path but the data file only. 
1068 \fBReturns:\fP
1069 .RS 4
1070 0 on success or an error code. 
1073 \fBSee also:\fP
1074 .RS 4
1075 \fBpwmd_process()\fP, \fBPinentry Details\fP 
1079 .SS "gpg_error_t pwmd_open_async2 (\fBpwm_t\fP * pwm, const char * filename)"
1081 Open a file on the pwmd server asynchronously (fork method). 
1083 This will send the OPEN command to the pwmd server. The difference from \fBpwmd_open()\fP is that it will not block if a pinentry is needed for passphrase input.
1085 The difference from \fBpwmd_open_async()\fP is that libpwmd will \fBfork()\fP a pinentry process rather than have pwmd use it's pinentry method. This may be useful if the passphrase isn't cached on a remote pwmd server and a remote \fBpinentry(1)\fP is not possible.
1087 \fBpwmd_process()\fP should be called until the command completes.
1089 \fBNote:\fP
1090 .RS 4
1091 This function will catch SIGALRM during the lifetime of the pinentry process and set it to SIG_DFL when finished. This is needed for pinentry timeouts.
1094 \fBParameters:\fP
1095 .RS 4
1096 \fIpwm\fP A handle. 
1098 \fIfilename\fP The filename to open. The \fIfilename\fP is not a full path but the data file only. 
1101 \fBReturns:\fP
1102 .RS 4
1103 0 on success or an error code. 
1106 \fBSee also:\fP
1107 .RS 4
1108 \fBpwmd_process()\fP, \fBPinentry Details\fP 
1112 .SS "gpg_error_t pwmd_pending_line (\fBpwm_t\fP * pwm)"
1114 Check for a unparsed buffered line. 
1116 A buffered line is a line that was read from the server but has not yet been processed. This function determines if there is such a line.
1118 \fBParameters:\fP
1119 .RS 4
1120 \fIpwm\fP A handle. 
1123 \fBReturn values:\fP
1124 .RS 4
1125 \fI0\fP if there is a pending line. 
1127 \fIGPG_ERR_NO_DATA\fP if there is no pending line. 
1130 \fBSee also:\fP
1131 .RS 4
1132 \fBpwmd_process()\fP 
1136 .SS "\fBpwmd_async_t\fP pwmd_process (\fBpwm_t\fP * pwm, gpg_error_t * rc, char ** result)"
1138 Process an asynchronous function. 
1140 After an asynchronous function has been called and has returned successfully, this function must be called to process the command and retrieve the result or return value.
1142 This function may also be called when not in a command to check for pending status messages sent from the server or to process a pending line.
1144 \fBParameters:\fP
1145 .RS 4
1146 \fIpwm\fP A handle. 
1148 \fIrc\fP Set to the return code of the original command after ASYNC_DONE has been returned. This value must be checked to determine if the command succeeded. 
1150 \fIresult\fP Set to the result of the command when \fIrc\fP is 0. Note that not all commands return a result. 
1153 \fBReturn values:\fP
1154 .RS 4
1155 \fIASYNC_DONE\fP The command has completed. \fIrc\fP should be checked to determine if the command was successful or not. 
1157 \fIASYNC_PROCESS\fP The command is still running and this function should be called again. 
1160 \fBSee also:\fP
1161 .RS 4
1162 \fBpwmd_get_fds()\fP, \fBpwmd_pending_line()\fP 
1166 .SS "void* pwmd_realloc (void * ptr, size_t size)"
1168 A wrapper around realloc(). 
1170 Like realloc(), but lets libpwmd keep track of the pointer. Note that this function will try and allocate the entire \fIsize\fP before freeing the original pointer and returning the new one.
1172 \fBParameters:\fP
1173 .RS 4
1174 \fIptr\fP The pointer to reallocate. 
1176 \fIsize\fP The new number of bytes to allocate. 
1179 \fBReturns:\fP
1180 .RS 4
1181 A newly allocated pointer or NULL if there wasn't enough memory. 
1184 \fBSee also:\fP
1185 .RS 4
1186 realloc(3), \fBpwmd_free()\fP 
1190 .SS "gpg_error_t pwmd_save (\fBpwm_t\fP * pwm)"
1192 Save a file on the pwmd server. 
1194 This will send the SAVE command.
1196 \fBParameters:\fP
1197 .RS 4
1198 \fIpwm\fP A handle. 
1201 \fBReturns:\fP
1202 .RS 4
1203 0 on success or an error code. 
1206 \fBSee also:\fP
1207 .RS 4
1208 \fBPinentry Details\fP 
1212 .SS "gpg_error_t pwmd_save2 (\fBpwm_t\fP * pwm)"
1214 Save a file on the pwmd server using the local pinentry. 
1216 This will send the SAVE command like \fBpwmd_save()\fP but will use a local pinentry and not pwmd's pinentry.
1218 \fBParameters:\fP
1219 .RS 4
1220 \fIpwm\fP A handle. 
1223 \fBReturns:\fP
1224 .RS 4
1225 0 on success or an error code. 
1228 \fBSee also:\fP
1229 .RS 4
1230 \fBPinentry Details\fP 
1234 .SS "gpg_error_t pwmd_save_async (\fBpwm_t\fP * pwm)"
1236 Save changes to a file on the pwmd server asynchronously. 
1238 This will send the SAVE command to the pwmd server. The difference from \fBpwmd_save()\fP is that it will not block if a pinentry is needed for passphrase input.
1240 \fBpwmd_process()\fP should be called until the command completes.
1242 \fBParameters:\fP
1243 .RS 4
1244 \fIpwm\fP A handle. 
1247 \fBReturns:\fP
1248 .RS 4
1249 0 on success or an error code. 
1252 \fBSee also:\fP
1253 .RS 4
1254 \fBpwmd_process()\fP, \fBPinentry Details\fP 
1258 .SS "gpg_error_t pwmd_save_async2 (\fBpwm_t\fP * pwm)"
1260 Save a file on the pwmd server asynchronously (fork method). 
1262 This will send the SAVE command to the pwmd server. The difference from \fBpwmd_save()\fP is that it will not block if a pinentry is needed for passphrase input.
1264 The difference from \fBpwmd_save_async()\fP is that libpwmd will \fBfork()\fP a pinentry process rather than have pwmd use it's pinentry method. This may be useful if the passphrase isn't cached on a remote pwmd server and a remote \fBpinentry(1)\fP is not possible.
1266 \fBpwmd_process()\fP should be called until the command completes.
1268 \fBParameters:\fP
1269 .RS 4
1270 \fIpwm\fP A handle. 
1273 \fBReturns:\fP
1274 .RS 4
1275 0 on success or an error code. 
1278 \fBSee also:\fP
1279 .RS 4
1280 \fBpwmd_process()\fP, \fBPinentry Details\fP 
1284 .SS "gpg_error_t pwmd_setopt (\fBpwm_t\fP * pwm, \fBpwmd_option_t\fP opt,  ...)"
1286 Set handle options. 
1288 See \fBpwmd_option_t\fP for option specific details.
1290 \fBParameters:\fP
1291 .RS 4
1292 \fIpwm\fP A handle. 
1294 \fIopt\fP The option and following value. 
1297 \fBReturns:\fP
1298 .RS 4
1299 0 on success or an error code. 
1303 .SS "gpg_error_t pwmd_socket_type (\fBpwm_t\fP * pwm, \fBpwmd_socket_t\fP * type)"
1305 The type of connection a handle has. 
1307 Useful when you want to know what kind of connection a handle has.
1309 \fBParameters:\fP
1310 .RS 4
1311 \fIpwm\fP A handle. 
1313 \fItype\fP The type of socket. 
1316 \fBReturns:\fP
1317 .RS 4
1318 0 on success or an error code. 
1321 \fBSee also:\fP
1322 .RS 4
1323 \fBpwmd_connect_url()\fP 
1327 .SS "gpg_error_t pwmd_ssh_connect (\fBpwm_t\fP * pwm, const char * host, int port, const char * identity, const char * user, const char * known_hosts)"
1329 Establish a remote connection to a pwmd server. 
1331 Connects to a pwmd server over an SSH channel.
1333 \fBParameters:\fP
1334 .RS 4
1335 \fIpwm\fP A handle. 
1337 \fIhost\fP The hostname to connect to. 
1339 \fIport\fP The port or -1 for the default. 
1341 \fIidentity\fP The SSH identity file to use for authentication. This should specify the private key. The public key is assumed to be \fIidentity.pub\fP. 
1343 \fIuser\fP The username on the SSH server to login as. If NULL then invoking username will be used. 
1345 \fIknown_hosts\fP A file containing the public SSH server key hash in SHA1 format which may be obtained with \fBpwmd_get_hostkey()\fP. 
1348 \fBReturns:\fP
1349 .RS 4
1350 0 on success or an error code. 
1353 \fBNote:\fP
1354 .RS 4
1355 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user. 
1358 \fBSee also:\fP
1359 .RS 4
1360 \fBpwmd_ssh_connect_async()\fP, \fBPWMD_OPTION_IP_VERSION\fP, \fBpwmd_disconnect()\fP, \fBSSH Details\fP 
1364 .SS "gpg_error_t pwmd_ssh_connect_async (\fBpwm_t\fP * pwm, const char * host, int port, const char * identity, const char * user, const char * known_hosts)"
1366 Establish a remote connection to a pwmd server asynchronously. 
1368 This is a variant of \fBpwmd_ssh_connect()\fP that will not block while doing DNS lookups or while connecting.
1370 \fBpwmd_process()\fP should be called until the command completes.
1372 \fBParameters:\fP
1373 .RS 4
1374 \fIpwm\fP A handle. 
1376 \fIhost\fP The hostname to connect to. 
1378 \fIport\fP The port or -1 for the default. 
1380 \fIidentity\fP The SSH identity file to use for authentication. This should specify the private key. The public key is assumed to be \fIidentity.pub\fP. 
1382 \fIuser\fP The username on the SSH server to login as. If NULL, the invoking username will be used. 
1384 \fIknown_hosts\fP A file containing the public SSH server key hash in SHA1 format which may be obtained with \fBpwmd_get_hostkey()\fP. 
1387 \fBReturns:\fP
1388 .RS 4
1389 0 on success or an error code. 
1392 \fBNote:\fP
1393 .RS 4
1394 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user. 
1397 \fBSee also:\fP
1398 .RS 4
1399 \fBpwmd_process()\fP, \fBPWMD_OPTION_IP_VERSION\fP, \fBpwmd_disconnect()\fP, \fBSSH Details\fP 
1403 .SS "char* pwmd_strdup (const char * str)"
1405 A wrapper around strdup(). 
1407 Like strdup(), but lets libpwmd keep track of the pointer.
1409 \fBParameters:\fP
1410 .RS 4
1411 \fIstr\fP The string to duplicate. 
1414 \fBReturns:\fP
1415 .RS 4
1416 A newly allocated character pointer or NULL if there wasn't enough memory. 
1419 \fBSee also:\fP
1420 .RS 4
1421 strdup(3), \fBpwmd_free()\fP 
1425 .SS "char* pwmd_strdup_printf (const char * fmt,  ...)"
1427 Duplicate a formatted string. 
1429 Like sprintf() but returns an allocated string.
1431 \fBParameters:\fP
1432 .RS 4
1433 \fIfmt\fP The formatted string and any following arguments. 
1436 \fBReturns:\fP
1437 .RS 4
1438 A newly allocated character pointer or NULL if there wasn't enough memory. 
1441 \fBSee also:\fP
1442 .RS 4
1443 \fBpwmd_free()\fP 
1447 .SS "const char* pwmd_strerror (gpg_error_t code)"
1449 Return a description of an error code. 
1451 \fBParameters:\fP
1452 .RS 4
1453 \fIcode\fP The error code to describe. 
1456 \fBReturns:\fP
1457 .RS 4
1458 A character description of the error code. 
1461 \fBSee also:\fP
1462 .RS 4
1463 \fBpwmd_strerror_r()\fP 
1467 .SS "int pwmd_strerror_r (gpg_error_t code, char * buf, size_t size)"
1469 Return a description of an error code (thread-safe). 
1471 This is a thread-safe version of \fBpwmd_strerror()\fP.
1473 \fBParameters:\fP
1474 .RS 4
1475 \fIcode\fP The error code to describe. 
1477 \fIbuf\fP An allocated buffer to hold the error description. 
1479 \fIsize\fP The size of the allocated buffer \fIbuf\fP.
1482 \fBReturn values:\fP
1483 .RS 4
1484 \fI0\fP Success. 
1486 \fIERANGE\fP \fIsize\fP was not large enough to hold the entire description and \fIbuf\fP is set to the truncated error string. 
1490 .SH "Author"
1491 .PP 
1492 Generated automatically by Doxygen for libpwmd from the source code.