A few documentation updates.
[libpwmd.git] / assuan / assuan.h
blob4ed35044a4608f7e926fe58ff1d4d1d80166b169
1 /* assuan.h - Definitions for the Assuan IPC library
2 * Copyright (C) 2001, 2002, 2003, 2005, 2007,
3 * 2008 Free Software Foundation, Inc.
5 * This file is part of Assuan.
7 * Assuan is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
12 * Assuan is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #ifndef ASSUAN_H
22 #define ASSUAN_H
24 #include <stdio.h>
25 #include <sys/types.h>
26 #include <unistd.h>
27 #ifndef _ASSUAN_NO_SOCKET_WRAPPER
28 #ifdef _WIN32
29 #include <ws2tcpip.h>
30 #else
31 #include <sys/socket.h>
32 #endif
33 #endif /*!_ASSUAN_NO_SOCKET_WRAPPER*/
35 #define _ASSUAN_EXT_SYM_PREFIX _pwmd_
37 /* To use this file with libraries the following macros are useful:
39 #define _ASSUAN_EXT_SYM_PREFIX _foo_
41 This prefixes all external symbols with "_foo_".
43 #define _ASSUAN_ONLY_GPG_ERRORS
45 If this is defined all old-style Assuan error codes are made
46 inactive as well as other deprecated stuff.
48 #define _ASSUAN_NO_SOCKET_WRAPPER
50 Do not include the definitions for the socket wrapper feature.
52 The follwing macros are used internally in the implementation of
53 libassuan:
55 #define _ASSUAN_NO_PTH
57 This avoids inclusion of special GNU Pth hacks.
59 #define _ASSUAN_NO_FIXED_SIGNALS
61 This disables changing of certain signal handler; i.e. SIGPIPE.
63 #define _ASSUAN_USE_DOUBLE_FORK
65 Use a double fork approach when connecting to a server through
66 a pipe.
70 #ifdef _ASSUAN_EXT_SYM_PREFIX
71 #define _ASSUAN_PREFIX1(x,y) x ## y
72 #define _ASSUAN_PREFIX2(x,y) _ASSUAN_PREFIX1(x,y)
73 #define _ASSUAN_PREFIX(x) _ASSUAN_PREFIX2(_ASSUAN_EXT_SYM_PREFIX,x)
74 #define assuan_ _ASSUAN_PREFIX(assuan_)
75 #define assuan_register_command _ASSUAN_PREFIX(assuan_register_command)
76 #define assuan_register_post_cmd_notify \
77 _ASSUAN_PREFIX(assuan_register_post_cmd_notify)
78 #define assuan_register_bye_notify _ASSUAN_PREFIX(assuan_register_bye_notify)
79 #define assuan_register_reset_notify \
80 _ASSUAN_PREFIX(assuan_register_reset_notify)
81 #define assuan_register_cancel_notify \
82 _ASSUAN_PREFIX(assuan_register_cancel_notify)
83 #define assuan_register_input_notify \
84 _ASSUAN_PREFIX(assuan_register_input_notify)
85 #define assuan_register_output_notify \
86 _ASSUAN_PREFIX(assuan_register_output_notify)
87 #define assuan_register_option_handler \
88 _ASSUAN_PREFIX(assuan_register_option_handler)
89 #define assuan_process _ASSUAN_PREFIX(assuan_process)
90 #define assuan_process_next _ASSUAN_PREFIX(assuan_process_next)
91 #define assuan_process_done _ASSUAN_PREFIX(assuan_process_done)
92 #define assuan_get_active_fds _ASSUAN_PREFIX(assuan_get_active_fds)
93 #define assuan_get_data_fp _ASSUAN_PREFIX(assuan_get_data_fp)
94 #define assuan_set_okay_line _ASSUAN_PREFIX(assuan_set_okay_line)
95 #define assuan_write_status _ASSUAN_PREFIX(assuan_write_status)
96 #define assuan_command_parse_fd _ASSUAN_PREFIX(assuan_command_parse_fd)
97 #define assuan_set_hello_line _ASSUAN_PREFIX(assuan_set_hello_line)
98 #define assuan_accept _ASSUAN_PREFIX(assuan_accept)
99 #define assuan_get_input_fd _ASSUAN_PREFIX(assuan_get_input_fd)
100 #define assuan_get_output_fd _ASSUAN_PREFIX(assuan_get_output_fd)
101 #define assuan_close_input_fd _ASSUAN_PREFIX(assuan_close_input_fd)
102 #define assuan_close_output_fd _ASSUAN_PREFIX(assuan_close_output_fd)
103 #define assuan_init_pipe_server _ASSUAN_PREFIX(assuan_init_pipe_server)
104 #define assuan_deinit_server _ASSUAN_PREFIX(assuan_deinit_server)
105 #define assuan_init_socket_server _ASSUAN_PREFIX(assuan_init_socket_server)
106 #define assuan_init_connected_socket_server \
107 _ASSUAN_PREFIX(assuan_init_connected_socket_server)
108 #define assuan_init_socket_server_ext \
109 _ASSUAN_PREFIX(assuan_init_socket_server_ext)
110 #define assuan_pipe_connect _ASSUAN_PREFIX(assuan_pipe_connect)
111 #define assuan_pipe_connect_ext _ASSUAN_PREFIX(assuan_pipe_connect_ext)
112 #define assuan_socket_connect _ASSUAN_PREFIX(assuan_socket_connect)
113 #define assuan_socket_connect_ext _ASSUAN_PREFIX(assuan_socket_connect_ext)
114 #define assuan_socket_connect_fd _ASSUAN_PREFIX(assuan_socket_connect_fd)
115 #define assuan_disconnect _ASSUAN_PREFIX(assuan_disconnect)
116 #define assuan_get_pid _ASSUAN_PREFIX(assuan_get_pid)
117 #define assuan_get_peercred _ASSUAN_PREFIX(assuan_get_peercred)
118 #define assuan_transact _ASSUAN_PREFIX(assuan_transact)
119 #define assuan_inquire _ASSUAN_PREFIX(assuan_inquire)
120 #define assuan_inquire_ext _ASSUAN_PREFIX(assuan_inquire_ext)
121 #define assuan_read_line _ASSUAN_PREFIX(assuan_read_line)
122 #define assuan_pending_line _ASSUAN_PREFIX(assuan_pending_line)
123 #define assuan_write_line _ASSUAN_PREFIX(assuan_write_line)
124 #define assuan_send_data _ASSUAN_PREFIX(assuan_send_data)
125 #define assuan_sendfd _ASSUAN_PREFIX(assuan_sendfd)
126 #define assuan_receivefd _ASSUAN_PREFIX(assuan_receivefd)
127 #define assuan_set_malloc_hooks _ASSUAN_PREFIX(assuan_set_malloc_hooks)
128 #define assuan_set_io_hooks _ASSUAN_PREFIX(assuan_set_io_hooks)
129 #define assuan_set_log_stream _ASSUAN_PREFIX(assuan_set_log_stream)
130 #define assuan_set_error _ASSUAN_PREFIX(assuan_set_error)
131 #define assuan_set_pointer _ASSUAN_PREFIX(assuan_set_pointer)
132 #define assuan_get_pointer _ASSUAN_PREFIX(assuan_get_pointer)
133 #define assuan_set_finish_handler _ASSUAN_PREFIX(assuan_set_finish_handler)
134 #define assuan_set_io_monitor _ASSUAN_PREFIX(assuan_set_io_monitor)
135 #define assuan_begin_confidential _ASSUAN_PREFIX(assuan_begin_confidential)
136 #define assuan_end_confidential _ASSUAN_PREFIX(assuan_end_confidential)
137 #define assuan_strerror _ASSUAN_PREFIX(assuan_strerror)
138 #define assuan_set_assuan_err_source \
139 _ASSUAN_PREFIX(assuan_set_assuan_err_source)
140 #define assuan_set_assuan_log_stream \
141 _ASSUAN_PREFIX(assuan_set_assuan_log_stream)
142 #define assuan_get_assuan_log_stream \
143 _ASSUAN_PREFIX(assuan_get_assuan_log_stream)
144 #define assuan_get_assuan_log_prefix \
145 _ASSUAN_PREFIX(assuan_get_assuan_log_prefix)
146 #define assuan_set_flag _ASSUAN_PREFIX(assuan_set_flag)
147 #define assuan_get_flag _ASSUAN_PREFIX(assuan_get_flag)
148 #define assuan_pipe_connect2 _ASSUAN_PREFIX(assuan_pipe_connect2)
149 #define assuan_set_assuan_log_prefix \
150 _ASSUAN_PREFIX(assuan_set_assuan_log_prefix)
151 #define assuan_sock_close _ASSUAN_PREFIX(assuan_sock_close)
152 #define assuan_sock_new _ASSUAN_PREFIX(assuan_sock_new)
153 #define assuan_sock_connect _ASSUAN_PREFIX(assuan_sock_connect)
154 #define assuan_sock_bind _ASSUAN_PREFIX(assuan_sock_bind)
155 #define assuan_sock_get_nonce _ASSUAN_PREFIX(assuan_sock_get_nonce)
156 #define assuan_sock_check_nonce _ASSUAN_PREFIX(assuan_sock_check_nonce)
159 /* And now the internal functions, argh... */
160 #define _assuan_read_line _ASSUAN_PREFIX(_assuan_read_line)
161 #define _assuan_cookie_write_data _ASSUAN_PREFIX(_assuan_cookie_write_data)
162 #define _assuan_cookie_write_flush _ASSUAN_PREFIX(_assuan_cookie_write_flush)
163 #define _assuan_read_from_server _ASSUAN_PREFIX(_assuan_read_from_server)
164 #define _assuan_domain_init _ASSUAN_PREFIX(_assuan_domain_init)
165 #define _assuan_register_std_commands \
166 _ASSUAN_PREFIX(_assuan_register_std_commands)
167 #define _assuan_simple_read _ASSUAN_PREFIX(_assuan_simple_read)
168 #define _assuan_simple_write _ASSUAN_PREFIX(_assuan_simple_write)
169 #define _assuan_io_read _ASSUAN_PREFIX(_assuan_io_read)
170 #define _assuan_io_write _ASSUAN_PREFIX(_assuan_io_write)
171 #define _assuan_io_hooks _ASSUAN_PREFIX(_assuan_io_hooks)
172 #define _assuan_new_context _ASSUAN_PREFIX(_assuan_new_context)
173 #define _assuan_release_context _ASSUAN_PREFIX(_assuan_release_context)
174 #define _assuan_malloc _ASSUAN_PREFIX(_assuan_malloc)
175 #define _assuan_realloc _ASSUAN_PREFIX(_assuan_realloc)
176 #define _assuan_calloc _ASSUAN_PREFIX(_assuan_calloc)
177 #define _assuan_free _ASSUAN_PREFIX(_assuan_free)
178 #define _assuan_log_print_buffer _ASSUAN_PREFIX(_assuan_log_print_buffer)
179 #define _assuan_log_sanitized_string \
180 _ASSUAN_PREFIX(_assuan_log_sanitized_string)
181 #define _assuan_log_printf _ASSUAN_PREFIX(_assuan_log_printf)
182 #define _assuan_set_default_log_stream \
183 _ASSUAN_PREFIX(_assuan_set_default_log_stream)
184 #define _assuan_w32_strerror _ASSUAN_PREFIX(_assuan_w32_strerror)
185 #define _assuan_gpg_strerror_r _ASSUAN_PREFIX(_assuan_gpg_strerror_r)
186 #define _assuan_gpg_strsource _ASSUAN_PREFIX(_assuan_gpg_strsource)
187 #define _assuan_write_line _ASSUAN_PREFIX(_assuan_write_line)
188 #define _assuan_error _ASSUAN_PREFIX(_assuan_error)
189 #define _assuan_error_is_eagain _ASSUAN_PREFIX(_assuan_error_is_eagain)
190 #define _assuan_init_uds_io _ASSUAN_PREFIX(_assuan_init_uds_io)
191 #define _assuan_uds_close_fds _ASSUAN_PREFIX(_assuan_uds_close_fds)
192 #define _assuan_uds_deinit _ASSUAN_PREFIX(_assuan_uds_deinit)
193 #define _assuan_simple_recvmsg _ASSUAN_PREFIX(_assuan_simple_recvmsg)
194 #define _assuan_simple_sendmsg _ASSUAN_PREFIX(_assuan_simple_sendmsg)
195 #define _assuan_waitpid _ASSUAN_PREFIX(_assuan_waitpid)
196 #define _assuan_sock_wsa2errno _ASSUAN_PREFIX(_assuan_sock_wsa2errno)
197 #define _assuan_sock_close _ASSUAN_PREFIX(_assuan_sock_close)
198 #define _assuan_sock_new _ASSUAN_PREFIX(_assuan_sock_new)
199 #define _assuan_sock_connect _ASSUAN_PREFIX(_assuan_sock_connect)
200 #define _assuan_sock_bind _ASSUAN_PREFIX(_assuan_sock_bind)
201 #define _assuan_sock_get_nonce _ASSUAN_PREFIX(_assuan_sock_get_nonce)
202 #define _assuan_sock_check_nonce _ASSUAN_PREFIX(_assuan_sock_check_nonce)
204 #endif /*_ASSUAN_EXT_SYM_PREFIX*/
207 #ifdef __cplusplus
208 extern "C"
210 #if 0
212 #endif
213 #endif
216 /* Check for compiler features. */
217 #if __GNUC__
218 #define _ASSUAN_GCC_VERSION (__GNUC__ * 10000 \
219 + __GNUC_MINOR__ * 100 \
220 + __GNUC_PATCHLEVEL__)
222 #if _ASSUAN_GCC_VERSION > 30100
223 #define _ASSUAN_DEPRECATED __attribute__ ((__deprecated__))
224 #endif
225 #endif
226 #ifndef _ASSUAN_DEPRECATED
227 #define _ASSUAN_DEPRECATED
228 #endif
231 /* Assuan error codes. These are only used by old applications or
232 those applications which won't make use of libgpg-error. */
233 #ifndef _ASSUAN_ONLY_GPG_ERRORS
234 #ifndef _ASSUAN_IN_LIBASSUAN
235 #define ASSUAN_No_Error 0
236 #endif
237 #define ASSUAN_General_Error 1
238 #define ASSUAN_Out_Of_Core 2
239 #define ASSUAN_Invalid_Value 3
240 #ifndef _ASSUAN_IN_LIBASSUAN
241 #define ASSUAN_Timeout 4
242 #endif
243 #define ASSUAN_Read_Error 5
244 #define ASSUAN_Write_Error 6
245 #define ASSUAN_Problem_Starting_Server 7
246 #define ASSUAN_Not_A_Server 8
247 #ifndef _ASSUAN_IN_LIBASSUAN
248 #define ASSUAN_Not_A_Client 9
249 #endif
250 #define ASSUAN_Nested_Commands 10
251 #define ASSUAN_Invalid_Response 11
252 #define ASSUAN_No_Data_Callback 12
253 #define ASSUAN_No_Inquire_Callback 13
254 #define ASSUAN_Connect_Failed 14
255 #define ASSUAN_Accept_Failed 15
257 /* Error codes above 99 are meant as status codes */
258 #define ASSUAN_Not_Implemented 100
259 #define ASSUAN_Server_Fault 101
260 #ifndef _ASSUAN_IN_LIBASSUAN
261 #define ASSUAN_Invalid_Command 102
262 #endif
263 #define ASSUAN_Unknown_Command 103
264 #define ASSUAN_Syntax_Error 104
265 #ifndef _ASSUAN_IN_LIBASSUAN
266 #define ASSUAN_Parameter_Error 105
267 #endif
268 #define ASSUAN_Parameter_Conflict 106
269 #define ASSUAN_Line_Too_Long 107
270 #define ASSUAN_Line_Not_Terminated 108
271 #ifndef _ASSUAN_IN_LIBASSUAN
272 #define ASSUAN_No_Input 109
273 #define ASSUAN_No_Output 110
274 #endif
275 #define ASSUAN_Canceled 111
276 #ifndef _ASSUAN_IN_LIBASSUAN
277 #define ASSUAN_Unsupported_Algorithm 112
278 #define ASSUAN_Server_Resource_Problem 113
279 #define ASSUAN_Server_IO_Error 114
280 #define ASSUAN_Server_Bug 115
281 #define ASSUAN_No_Data_Available 116
282 #define ASSUAN_Invalid_Data 117
283 #endif
284 #define ASSUAN_Unexpected_Command 118
285 #define ASSUAN_Too_Much_Data 119
286 #ifndef _ASSUAN_IN_LIBASSUAN
287 #define ASSUAN_Inquire_Unknown 120
288 #define ASSUAN_Inquire_Error 121
289 #define ASSUAN_Invalid_Option 122
290 #define ASSUAN_Invalid_Index 123
291 #define ASSUAN_Unexpected_Status 124
292 #define ASSUAN_Unexpected_Data 125
293 #define ASSUAN_Invalid_Status 126
294 #define ASSUAN_Locale_Problem 127
295 #endif
296 #define ASSUAN_Not_Confirmed 128
298 /* Warning: Don't use the Error codes, below they are deprecated. */
299 #ifndef _ASSUAN_IN_LIBASSUAN
300 #define ASSUAN_Bad_Certificate 201
301 #define ASSUAN_Bad_Certificate_Chain 202
302 #define ASSUAN_Missing_Certificate 203
303 #define ASSUAN_Bad_Signature 204
304 #define ASSUAN_No_Agent 205
305 #define ASSUAN_Agent_Error 206
306 #define ASSUAN_No_Public_Key 207
307 #define ASSUAN_No_Secret_Key 208
308 #define ASSUAN_Invalid_Name 209
310 #define ASSUAN_Cert_Revoked 301
311 #define ASSUAN_No_CRL_For_Cert 302
312 #define ASSUAN_CRL_Too_Old 303
313 #define ASSUAN_Not_Trusted 304
315 #define ASSUAN_Card_Error 401
316 #define ASSUAN_Invalid_Card 402
317 #define ASSUAN_No_PKCS15_App 403
318 #define ASSUAN_Card_Not_Present 404
319 #define ASSUAN_Invalid_Id 405
321 /* Error codes in the range 1000 to 9999 may be used by applications
322 at their own discretion. */
323 #define ASSUAN_USER_ERROR_FIRST 1000
324 #define ASSUAN_USER_ERROR_LAST 9999
325 #endif
327 typedef int assuan_error_t;
329 typedef assuan_error_t AssuanError _ASSUAN_DEPRECATED;
331 /* This is a list of pre-registered ASSUAN commands */
332 /* Note, these command IDs are now deprectated and solely exists for
333 compatibility reasons. */
334 typedef enum
336 ASSUAN_CMD_NOP = 0,
337 ASSUAN_CMD_CANCEL, /* cancel the current request */
338 ASSUAN_CMD_BYE,
339 ASSUAN_CMD_AUTH,
340 ASSUAN_CMD_RESET,
341 ASSUAN_CMD_OPTION,
342 ASSUAN_CMD_DATA,
343 ASSUAN_CMD_END,
344 ASSUAN_CMD_INPUT,
345 ASSUAN_CMD_OUTPUT,
347 ASSUAN_CMD_USER = 256 /* Other commands should be used with this offset*/
348 } AssuanCommand;
351 #else /*!_ASSUAN_ONLY_GPG_ERRORS*/
353 /* Choose a type compatible with gpg_error_t. */
354 typedef unsigned int assuan_error_t;
356 #endif /*!_ASSUAN_ONLY_GPG_ERRORS*/
359 /* Definitions of flags for assuan_set_flag(). */
360 typedef enum
362 /* When using a pipe server, by default Assuan will wait for the
363 forked process to die in assuan_disconnect. In certain cases
364 this is not desirable. By setting this flag, the waitpid will
365 be skipped and the caller is responsible to cleanup a forked
366 process. */
367 ASSUAN_NO_WAITPID = 1,
368 /* This flag indicates whether Assuan logging is in confidential
369 mode. Use assuan_{begin,end}_condidential to change the
370 mode. */
371 ASSUAN_CONFIDENTIAL = 2
373 assuan_flag_t;
375 #define ASSUAN_LINELENGTH 1002 /* 1000 + [CR,]LF */
377 struct assuan_context_s;
378 typedef struct assuan_context_s *assuan_context_t;
379 #ifndef _ASSUAN_ONLY_GPG_ERRORS
380 typedef struct assuan_context_s *ASSUAN_CONTEXT _ASSUAN_DEPRECATED;
381 #endif /*_ASSUAN_ONLY_GPG_ERRORS*/
383 /* Because we use system handles and not libc low level file
384 descriptors on W32, we need to declare them as HANDLE (which
385 actually is a plain pointer). This is required to eventually
386 support 64 bit Windows systems. */
387 #ifdef _WIN32
388 typedef void *assuan_fd_t;
389 #define ASSUAN_INVALID_FD ((void*)(-1))
390 #define ASSUAN_INT2FD(s) ((void *)(s))
391 #define ASSUAN_FD2INT(h) ((unsigned int)(h))
392 #else
393 typedef int assuan_fd_t;
394 #define ASSUAN_INVALID_FD (-1)
395 #define ASSUAN_INT2FD(s) ((s))
396 #define ASSUAN_FD2INT(h) ((h))
397 #endif
400 /* Assuan features an emulation of Unix domain sockets based on a
401 local TCP connections. To implement access permissions based on
402 file permissions a nonce is used which is expected by th server as
403 the first bytes received. This structure is used by the server to
404 save the nonce created initially by bind. On POSIX systems this is
405 a dummy operation. */
406 struct assuan_sock_nonce_s
408 size_t length;
409 #ifdef _WIN32
410 char nonce[16];
411 #endif
413 typedef struct assuan_sock_nonce_s assuan_sock_nonce_t;
415 /* Define the Unix domain socket structure for Windows. */
416 #if defined(_WIN32) && !defined(_ASSUAN_NO_SOCKET_WRAPPER)
417 #ifndef AF_LOCAL
418 #define AF_LOCAL AF_UNIX
419 #endif
420 #define EADDRINUSE WSAEADDRINUSE
421 struct sockaddr_un
423 short sun_family;
424 unsigned short sun_port;
425 struct in_addr sun_addr;
426 char sun_path[108-2-4];
428 #endif
431 /* Definition of hook functions used to conditionally replace the
432 default I/O functions. */
433 struct assuan_io_hooks
435 int (*read_hook)(assuan_context_t, assuan_fd_t, void *, size_t, ssize_t *);
436 int (*write_hook)(assuan_context_t, assuan_fd_t fd,
437 const void *, size_t, ssize_t *);
439 typedef struct assuan_io_hooks *assuan_io_hooks_t;
443 /*-- assuan-handler.c --*/
444 int assuan_register_command (assuan_context_t ctx,
445 const char *cmd_string,
446 int (*handler)(assuan_context_t, char *));
447 int assuan_register_post_cmd_notify (assuan_context_t ctx,
448 void (*fnc)(assuan_context_t, int));
449 int assuan_register_bye_notify (assuan_context_t ctx,
450 void (*fnc)(assuan_context_t));
451 int assuan_register_reset_notify (assuan_context_t ctx,
452 void (*fnc)(assuan_context_t));
453 int assuan_register_cancel_notify (assuan_context_t ctx,
454 void (*fnc)(assuan_context_t));
455 int assuan_register_input_notify (assuan_context_t ctx,
456 void (*fnc)(assuan_context_t, const char *));
457 int assuan_register_output_notify (assuan_context_t ctx,
458 void (*fnc)(assuan_context_t, const char *));
460 int assuan_register_option_handler (assuan_context_t ctx,
461 int (*fnc)(assuan_context_t,
462 const char*, const char*));
464 int assuan_process (assuan_context_t ctx);
465 int assuan_process_next (assuan_context_t ctx);
466 int assuan_process_done (assuan_context_t ctx, int rc);
467 int assuan_get_active_fds (assuan_context_t ctx, int what,
468 assuan_fd_t *fdarray, int fdarraysize);
471 FILE *assuan_get_data_fp (assuan_context_t ctx);
472 assuan_error_t assuan_set_okay_line (assuan_context_t ctx, const char *line);
473 assuan_error_t assuan_write_status (assuan_context_t ctx,
474 const char *keyword, const char *text);
476 /* Negotiate a file descriptor. If LINE contains "FD=N", returns N
477 assuming a local file descriptor. If LINE contains "FD" reads a
478 file descriptor via CTX and stores it in *RDF (the CTX must be
479 capable of passing file descriptors). Under W32 the returned FD is
480 a libc-type one. */
481 assuan_error_t assuan_command_parse_fd (assuan_context_t ctx, char *line,
482 assuan_fd_t *rfd);
485 /*-- assuan-listen.c --*/
486 assuan_error_t assuan_set_hello_line (assuan_context_t ctx, const char *line);
487 assuan_error_t assuan_accept (assuan_context_t ctx);
488 assuan_fd_t assuan_get_input_fd (assuan_context_t ctx);
489 assuan_fd_t assuan_get_output_fd (assuan_context_t ctx);
490 assuan_error_t assuan_close_input_fd (assuan_context_t ctx);
491 assuan_error_t assuan_close_output_fd (assuan_context_t ctx);
494 /*-- assuan-pipe-server.c --*/
495 int assuan_init_pipe_server (assuan_context_t *r_ctx, int filedes[2]);
496 void assuan_deinit_server (assuan_context_t ctx);
498 /*-- assuan-socket-server.c --*/
499 int assuan_init_socket_server (assuan_context_t *r_ctx, assuan_fd_t listen_fd);
500 int assuan_init_connected_socket_server (assuan_context_t *r_ctx,
501 assuan_fd_t fd) _ASSUAN_DEPRECATED;
502 int assuan_init_socket_server_ext (assuan_context_t *r_ctx, assuan_fd_t fd,
503 unsigned int flags);
504 void assuan_set_sock_nonce (assuan_context_t ctx, assuan_sock_nonce_t *nonce);
506 /*-- assuan-pipe-connect.c --*/
507 assuan_error_t assuan_pipe_connect (assuan_context_t *ctx,
508 const char *name,
509 const char *const argv[],
510 int *fd_child_list);
511 assuan_error_t assuan_pipe_connect2 (assuan_context_t *ctx,
512 const char *name,
513 const char *const argv[],
514 int *fd_child_list,
515 void (*atfork) (void*, int),
516 void *atforkvalue) _ASSUAN_DEPRECATED;
517 assuan_error_t assuan_pipe_connect_ext (assuan_context_t *ctx,
518 const char *name,
519 const char *const argv[],
520 int *fd_child_list,
521 void (*atfork) (void *, int),
522 void *atforkvalue,
523 unsigned int flags);
525 /*-- assuan-socket-connect.c --*/
526 assuan_error_t assuan_socket_connect (assuan_context_t *ctx,
527 const char *name,
528 pid_t server_pid);
529 assuan_error_t assuan_socket_connect_ext (assuan_context_t *ctx,
530 const char *name,
531 pid_t server_pid,
532 unsigned int flags);
533 assuan_error_t assuan_socket_connect_fd (assuan_context_t *ctx,
534 assuan_fd_t fd,
535 unsigned int flags, void *data);
537 /*-- assuan-connect.c --*/
538 void assuan_disconnect (assuan_context_t ctx);
539 pid_t assuan_get_pid (assuan_context_t ctx);
540 #ifndef _WIN32
541 assuan_error_t assuan_get_peercred (assuan_context_t ctx,
542 pid_t *pid, uid_t *uid, gid_t *gid);
543 #endif
545 /*-- assuan-client.c --*/
546 assuan_error_t
547 assuan_transact (assuan_context_t ctx,
548 const char *command,
549 assuan_error_t (*data_cb)(void *, const void *, size_t),
550 void *data_cb_arg,
551 assuan_error_t (*inquire_cb)(void*, const char *),
552 void *inquire_cb_arg,
553 assuan_error_t (*status_cb)(void*, const char *),
554 void *status_cb_arg);
557 /*-- assuan-inquire.c --*/
558 assuan_error_t assuan_inquire (assuan_context_t ctx, const char *keyword,
559 unsigned char **r_buffer, size_t *r_length,
560 size_t maxlen);
561 assuan_error_t assuan_inquire_ext (assuan_context_t ctx, const char *keyword,
562 size_t maxlen,
563 int (*cb) (void *cb_data, int rc,
564 unsigned char *buf,
565 size_t buf_len),
566 void *cb_data);
567 /*-- assuan-buffer.c --*/
568 assuan_error_t assuan_read_line (assuan_context_t ctx,
569 char **line, size_t *linelen);
570 int assuan_pending_line (assuan_context_t ctx);
571 assuan_error_t assuan_write_line (assuan_context_t ctx, const char *line );
572 assuan_error_t assuan_send_data (assuan_context_t ctx,
573 const void *buffer, size_t length);
575 /* The file descriptor must be pending before assuan_receivefd is
576 called. This means that assuan_sendfd should be called *before* the
577 trigger is sent (normally via assuan_write_line ("INPUT FD")). */
578 assuan_error_t assuan_sendfd (assuan_context_t ctx, assuan_fd_t fd);
579 assuan_error_t assuan_receivefd (assuan_context_t ctx, assuan_fd_t *fd);
582 /*-- assuan-util.c --*/
583 void assuan_set_malloc_hooks ( void *(*new_alloc_func)(size_t n),
584 void *(*new_realloc_func)(void *p, size_t n),
585 void (*new_free_func)(void*) );
586 void assuan_set_io_hooks (assuan_io_hooks_t io_hooks);
587 void assuan_set_log_stream (assuan_context_t ctx, FILE *fp);
588 int assuan_set_error (assuan_context_t ctx, int err, const char *text);
589 void assuan_set_pointer (assuan_context_t ctx, void *pointer);
590 void *assuan_get_pointer (assuan_context_t ctx);
591 void assuan_set_finish_handler(assuan_context_t ctx, void (*handler)(assuan_context_t));
593 void assuan_begin_confidential (assuan_context_t ctx);
594 void assuan_end_confidential (assuan_context_t ctx);
596 void assuan_set_io_monitor (assuan_context_t ctx,
597 unsigned int (*monitor)(assuan_context_t ctx,
598 int direction,
599 const char *line,
600 size_t linelen));
602 /* For context CTX, set the flag FLAG to VALUE. Values for flags
603 are usually 1 or 0 but certain flags might allow for other values;
604 see the description of the type assuan_flag_t for details. */
605 void assuan_set_flag (assuan_context_t ctx, assuan_flag_t flag, int value);
607 /* Return the VALUE of FLAG in context CTX. */
608 int assuan_get_flag (assuan_context_t ctx, assuan_flag_t flag);
611 /*-- assuan-errors.c --*/
613 #ifndef _ASSUAN_ONLY_GPG_ERRORS
614 /* Return a string describing the assuan error. The use of this
615 function is deprecated; it is better to call
616 assuan_set_assuan_err_source once and then make use libgpg-error. */
617 const char *assuan_strerror (assuan_error_t err);
618 #endif /*_ASSUAN_ONLY_GPG_ERRORS*/
620 /* Enable gpg-error style error codes. ERRSOURCE is one of gpg-error
621 sources. Note, that this function is not thread-safe and should be
622 used right at startup. Switching back to the old style mode is not
623 supported. */
624 void assuan_set_assuan_err_source (int errsource);
626 /*-- assuan-logging.c --*/
628 /* Set the stream to which assuan should log message not associated
629 with a context. By default, this is stderr. The default value
630 will be changed when the first log stream is associated with a
631 context. Note, that this function is not thread-safe and should
632 in general be used right at startup. */
633 extern void assuan_set_assuan_log_stream (FILE *fp);
635 /* Return the stream which is currently being using for global logging. */
636 extern FILE *assuan_get_assuan_log_stream (void);
638 /* Set the prefix to be used at the start of a line emitted by assuan
639 on the log stream. The default is the empty string. Note, that
640 this function is not thread-safe and should in general be used
641 right at startup. */
642 void assuan_set_assuan_log_prefix (const char *text);
644 /* Return a prefix to be used at the start of a line emitted by assuan
645 on the log stream. The default implementation returns the empty
646 string, i.e. "" */
647 const char *assuan_get_assuan_log_prefix (void);
650 /*-- assuan-socket.c --*/
652 /* These are socket wrapper functions to support an emulation of Unix
653 domain sockets on Windows W32. */
654 int assuan_sock_close (assuan_fd_t fd);
655 assuan_fd_t assuan_sock_new (int domain, int type, int proto);
656 int assuan_sock_connect (assuan_fd_t sockfd,
657 struct sockaddr *addr, int addrlen);
658 int assuan_sock_bind (assuan_fd_t sockfd, struct sockaddr *addr, int addrlen);
659 int assuan_sock_get_nonce (struct sockaddr *addr, int addrlen,
660 assuan_sock_nonce_t *nonce);
661 int assuan_sock_check_nonce (assuan_fd_t fd, assuan_sock_nonce_t *nonce);
664 #ifdef __cplusplus
666 #endif
667 #endif /* ASSUAN_H */