Include libassuan statically.
[pwmd.git] / assuan / src / assuan.h
blobed9b4ef681e40c2c280b9768af9d49b7367ca729
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 /* To use this file with libraries the following macros are useful:
37 #define _ASSUAN_EXT_SYM_PREFIX _foo_
39 This prefixes all external symbols with "_foo_".
41 #define _ASSUAN_ONLY_GPG_ERRORS
43 If this is defined all old-style Assuan error codes are made
44 inactive as well as other deprecated stuff.
46 #define _ASSUAN_NO_SOCKET_WRAPPER
48 Do not include the definitions for the socket wrapper feature.
50 The follwing macros are used internally in the implementation of
51 libassuan:
53 #define _ASSUAN_NO_PTH
55 This avoids inclusion of special GNU Pth hacks.
57 #define _ASSUAN_NO_FIXED_SIGNALS
59 This disables changing of certain signal handler; i.e. SIGPIPE.
61 #define _ASSUAN_USE_DOUBLE_FORK
63 Use a double fork approach when connecting to a server through
64 a pipe.
68 #ifdef _ASSUAN_EXT_SYM_PREFIX
69 #define _ASSUAN_PREFIX1(x,y) x ## y
70 #define _ASSUAN_PREFIX2(x,y) _ASSUAN_PREFIX1(x,y)
71 #define _ASSUAN_PREFIX(x) _ASSUAN_PREFIX2(_ASSUAN_EXT_SYM_PREFIX,x)
72 #define assuan_ _ASSUAN_PREFIX(assuan_)
73 #define assuan_register_command _ASSUAN_PREFIX(assuan_register_command)
74 #define assuan_register_post_cmd_notify \
75 _ASSUAN_PREFIX(assuan_register_post_cmd_notify)
76 #define assuan_register_pre_cmd_notify \
77 _ASSUAN_PREFIX(assuan_register_pre_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_disconnect _ASSUAN_PREFIX(assuan_disconnect)
115 #define assuan_get_pid _ASSUAN_PREFIX(assuan_get_pid)
116 #define assuan_get_peercred _ASSUAN_PREFIX(assuan_get_peercred)
117 #define assuan_transact _ASSUAN_PREFIX(assuan_transact)
118 #define assuan_inquire _ASSUAN_PREFIX(assuan_inquire)
119 #define assuan_inquire_ext _ASSUAN_PREFIX(assuan_inquire_ext)
120 #define assuan_read_line _ASSUAN_PREFIX(assuan_read_line)
121 #define assuan_pending_line _ASSUAN_PREFIX(assuan_pending_line)
122 #define assuan_write_line _ASSUAN_PREFIX(assuan_write_line)
123 #define assuan_send_data _ASSUAN_PREFIX(assuan_send_data)
124 #define assuan_sendfd _ASSUAN_PREFIX(assuan_sendfd)
125 #define assuan_receivefd _ASSUAN_PREFIX(assuan_receivefd)
126 #define assuan_set_malloc_hooks _ASSUAN_PREFIX(assuan_set_malloc_hooks)
127 #define assuan_set_io_hooks _ASSUAN_PREFIX(assuan_set_io_hooks)
128 #define assuan_set_log_stream _ASSUAN_PREFIX(assuan_set_log_stream)
129 #define assuan_set_error _ASSUAN_PREFIX(assuan_set_error)
130 #define assuan_set_pointer _ASSUAN_PREFIX(assuan_set_pointer)
131 #define assuan_get_pointer _ASSUAN_PREFIX(assuan_get_pointer)
132 #define assuan_set_io_monitor _ASSUAN_PREFIX(assuan_set_io_monitor)
133 #define assuan_begin_confidential _ASSUAN_PREFIX(assuan_begin_confidential)
134 #define assuan_end_confidential _ASSUAN_PREFIX(assuan_end_confidential)
135 #define assuan_strerror _ASSUAN_PREFIX(assuan_strerror)
136 #define assuan_set_assuan_err_source \
137 _ASSUAN_PREFIX(assuan_set_assuan_err_source)
138 #define assuan_set_assuan_log_stream \
139 _ASSUAN_PREFIX(assuan_set_assuan_log_stream)
140 #define assuan_get_assuan_log_stream \
141 _ASSUAN_PREFIX(assuan_get_assuan_log_stream)
142 #define assuan_get_assuan_log_prefix \
143 _ASSUAN_PREFIX(assuan_get_assuan_log_prefix)
144 #define assuan_set_flag _ASSUAN_PREFIX(assuan_set_flag)
145 #define assuan_get_flag _ASSUAN_PREFIX(assuan_get_flag)
146 #define assuan_pipe_connect2 _ASSUAN_PREFIX(assuan_pipe_connect2)
147 #define assuan_set_assuan_log_prefix \
148 _ASSUAN_PREFIX(assuan_set_assuan_log_prefix)
149 #define assuan_sock_close _ASSUAN_PREFIX(assuan_sock_close)
150 #define assuan_sock_new _ASSUAN_PREFIX(assuan_sock_new)
151 #define assuan_sock_connect _ASSUAN_PREFIX(assuan_sock_connect)
152 #define assuan_sock_bind _ASSUAN_PREFIX(assuan_sock_bind)
153 #define assuan_sock_get_nonce _ASSUAN_PREFIX(assuan_sock_get_nonce)
154 #define assuan_sock_check_nonce _ASSUAN_PREFIX(assuan_sock_check_nonce)
157 /* And now the internal functions, argh... */
158 #define _assuan_read_line _ASSUAN_PREFIX(_assuan_read_line)
159 #define _assuan_cookie_write_data _ASSUAN_PREFIX(_assuan_cookie_write_data)
160 #define _assuan_cookie_write_flush _ASSUAN_PREFIX(_assuan_cookie_write_flush)
161 #define _assuan_read_from_server _ASSUAN_PREFIX(_assuan_read_from_server)
162 #define _assuan_domain_init _ASSUAN_PREFIX(_assuan_domain_init)
163 #define _assuan_register_std_commands \
164 _ASSUAN_PREFIX(_assuan_register_std_commands)
165 #define _assuan_simple_read _ASSUAN_PREFIX(_assuan_simple_read)
166 #define _assuan_simple_write _ASSUAN_PREFIX(_assuan_simple_write)
167 #define _assuan_io_read _ASSUAN_PREFIX(_assuan_io_read)
168 #define _assuan_io_write _ASSUAN_PREFIX(_assuan_io_write)
169 #define _assuan_io_hooks _ASSUAN_PREFIX(_assuan_io_hooks)
170 #define _assuan_new_context _ASSUAN_PREFIX(_assuan_new_context)
171 #define _assuan_release_context _ASSUAN_PREFIX(_assuan_release_context)
172 #define _assuan_malloc _ASSUAN_PREFIX(_assuan_malloc)
173 #define _assuan_realloc _ASSUAN_PREFIX(_assuan_realloc)
174 #define _assuan_calloc _ASSUAN_PREFIX(_assuan_calloc)
175 #define _assuan_free _ASSUAN_PREFIX(_assuan_free)
176 #define _assuan_log_print_buffer _ASSUAN_PREFIX(_assuan_log_print_buffer)
177 #define _assuan_log_sanitized_string \
178 _ASSUAN_PREFIX(_assuan_log_sanitized_string)
179 #define _assuan_log_printf _ASSUAN_PREFIX(_assuan_log_printf)
180 #define _assuan_set_default_log_stream \
181 _ASSUAN_PREFIX(_assuan_set_default_log_stream)
182 #define _assuan_w32_strerror _ASSUAN_PREFIX(_assuan_w32_strerror)
183 #define _assuan_gpg_strerror_r _ASSUAN_PREFIX(_assuan_gpg_strerror_r)
184 #define _assuan_gpg_strsource _ASSUAN_PREFIX(_assuan_gpg_strsource)
185 #define _assuan_write_line _ASSUAN_PREFIX(_assuan_write_line)
186 #define _assuan_error _ASSUAN_PREFIX(_assuan_error)
187 #define _assuan_error_is_eagain _ASSUAN_PREFIX(_assuan_error_is_eagain)
188 #define _assuan_init_uds_io _ASSUAN_PREFIX(_assuan_init_uds_io)
189 #define _assuan_uds_close_fds _ASSUAN_PREFIX(_assuan_uds_close_fds)
190 #define _assuan_uds_deinit _ASSUAN_PREFIX(_assuan_uds_deinit)
191 #define _assuan_simple_recvmsg _ASSUAN_PREFIX(_assuan_simple_recvmsg)
192 #define _assuan_simple_sendmsg _ASSUAN_PREFIX(_assuan_simple_sendmsg)
193 #define _assuan_waitpid _ASSUAN_PREFIX(_assuan_waitpid)
194 #define _assuan_sock_wsa2errno _ASSUAN_PREFIX(_assuan_sock_wsa2errno)
195 #define _assuan_sock_close _ASSUAN_PREFIX(_assuan_sock_close)
196 #define _assuan_sock_new _ASSUAN_PREFIX(_assuan_sock_new)
197 #define _assuan_sock_connect _ASSUAN_PREFIX(_assuan_sock_connect)
198 #define _assuan_sock_bind _ASSUAN_PREFIX(_assuan_sock_bind)
199 #define _assuan_sock_get_nonce _ASSUAN_PREFIX(_assuan_sock_get_nonce)
200 #define _assuan_sock_check_nonce _ASSUAN_PREFIX(_assuan_sock_check_nonce)
202 #endif /*_ASSUAN_EXT_SYM_PREFIX*/
205 #ifdef __cplusplus
206 extern "C"
208 #if 0
210 #endif
211 #endif
214 /* Check for compiler features. */
215 #if __GNUC__
216 #define _ASSUAN_GCC_VERSION (__GNUC__ * 10000 \
217 + __GNUC_MINOR__ * 100 \
218 + __GNUC_PATCHLEVEL__)
220 #if _ASSUAN_GCC_VERSION > 30100
221 #define _ASSUAN_DEPRECATED __attribute__ ((__deprecated__))
222 #endif
223 #endif
224 #ifndef _ASSUAN_DEPRECATED
225 #define _ASSUAN_DEPRECATED
226 #endif
229 /* Assuan error codes. These are only used by old applications or
230 those applications which won't make use of libgpg-error. */
231 #ifndef _ASSUAN_ONLY_GPG_ERRORS
232 #ifndef _ASSUAN_IN_LIBASSUAN
233 #define ASSUAN_No_Error 0
234 #endif
235 #define ASSUAN_General_Error 1
236 #define ASSUAN_Out_Of_Core 2
237 #define ASSUAN_Invalid_Value 3
238 #ifndef _ASSUAN_IN_LIBASSUAN
239 #define ASSUAN_Timeout 4
240 #endif
241 #define ASSUAN_Read_Error 5
242 #define ASSUAN_Write_Error 6
243 #define ASSUAN_Problem_Starting_Server 7
244 #define ASSUAN_Not_A_Server 8
245 #ifndef _ASSUAN_IN_LIBASSUAN
246 #define ASSUAN_Not_A_Client 9
247 #endif
248 #define ASSUAN_Nested_Commands 10
249 #define ASSUAN_Invalid_Response 11
250 #define ASSUAN_No_Data_Callback 12
251 #define ASSUAN_No_Inquire_Callback 13
252 #define ASSUAN_Connect_Failed 14
253 #define ASSUAN_Accept_Failed 15
255 /* Error codes above 99 are meant as status codes */
256 #define ASSUAN_Not_Implemented 100
257 #define ASSUAN_Server_Fault 101
258 #ifndef _ASSUAN_IN_LIBASSUAN
259 #define ASSUAN_Invalid_Command 102
260 #endif
261 #define ASSUAN_Unknown_Command 103
262 #define ASSUAN_Syntax_Error 104
263 #ifndef _ASSUAN_IN_LIBASSUAN
264 #define ASSUAN_Parameter_Error 105
265 #endif
266 #define ASSUAN_Parameter_Conflict 106
267 #define ASSUAN_Line_Too_Long 107
268 #define ASSUAN_Line_Not_Terminated 108
269 #ifndef _ASSUAN_IN_LIBASSUAN
270 #define ASSUAN_No_Input 109
271 #define ASSUAN_No_Output 110
272 #endif
273 #define ASSUAN_Canceled 111
274 #ifndef _ASSUAN_IN_LIBASSUAN
275 #define ASSUAN_Unsupported_Algorithm 112
276 #define ASSUAN_Server_Resource_Problem 113
277 #define ASSUAN_Server_IO_Error 114
278 #define ASSUAN_Server_Bug 115
279 #define ASSUAN_No_Data_Available 116
280 #define ASSUAN_Invalid_Data 117
281 #endif
282 #define ASSUAN_Unexpected_Command 118
283 #define ASSUAN_Too_Much_Data 119
284 #ifndef _ASSUAN_IN_LIBASSUAN
285 #define ASSUAN_Inquire_Unknown 120
286 #define ASSUAN_Inquire_Error 121
287 #define ASSUAN_Invalid_Option 122
288 #define ASSUAN_Invalid_Index 123
289 #define ASSUAN_Unexpected_Status 124
290 #define ASSUAN_Unexpected_Data 125
291 #define ASSUAN_Invalid_Status 126
292 #define ASSUAN_Locale_Problem 127
293 #endif
294 #define ASSUAN_Not_Confirmed 128
296 /* Warning: Don't use the Error codes, below they are deprecated. */
297 #ifndef _ASSUAN_IN_LIBASSUAN
298 #define ASSUAN_Bad_Certificate 201
299 #define ASSUAN_Bad_Certificate_Chain 202
300 #define ASSUAN_Missing_Certificate 203
301 #define ASSUAN_Bad_Signature 204
302 #define ASSUAN_No_Agent 205
303 #define ASSUAN_Agent_Error 206
304 #define ASSUAN_No_Public_Key 207
305 #define ASSUAN_No_Secret_Key 208
306 #define ASSUAN_Invalid_Name 209
308 #define ASSUAN_Cert_Revoked 301
309 #define ASSUAN_No_CRL_For_Cert 302
310 #define ASSUAN_CRL_Too_Old 303
311 #define ASSUAN_Not_Trusted 304
313 #define ASSUAN_Card_Error 401
314 #define ASSUAN_Invalid_Card 402
315 #define ASSUAN_No_PKCS15_App 403
316 #define ASSUAN_Card_Not_Present 404
317 #define ASSUAN_Invalid_Id 405
319 /* Error codes in the range 1000 to 9999 may be used by applications
320 at their own discretion. */
321 #define ASSUAN_USER_ERROR_FIRST 1000
322 #define ASSUAN_USER_ERROR_LAST 9999
323 #endif
325 typedef int assuan_error_t;
327 typedef assuan_error_t AssuanError _ASSUAN_DEPRECATED;
329 /* This is a list of pre-registered ASSUAN commands */
330 /* Note, these command IDs are now deprectated and solely exists for
331 compatibility reasons. */
332 typedef enum
334 ASSUAN_CMD_NOP = 0,
335 ASSUAN_CMD_CANCEL, /* cancel the current request */
336 ASSUAN_CMD_BYE,
337 ASSUAN_CMD_AUTH,
338 ASSUAN_CMD_RESET,
339 ASSUAN_CMD_OPTION,
340 ASSUAN_CMD_DATA,
341 ASSUAN_CMD_END,
342 ASSUAN_CMD_INPUT,
343 ASSUAN_CMD_OUTPUT,
345 ASSUAN_CMD_USER = 256 /* Other commands should be used with this offset*/
346 } AssuanCommand;
349 #else /*!_ASSUAN_ONLY_GPG_ERRORS*/
351 /* Choose a type compatible with gpg_error_t. */
352 typedef unsigned int assuan_error_t;
354 #endif /*!_ASSUAN_ONLY_GPG_ERRORS*/
357 /* Definitions of flags for assuan_set_flag(). */
358 typedef enum
360 /* When using a pipe server, by default Assuan will wait for the
361 forked process to die in assuan_disconnect. In certain cases
362 this is not desirable. By setting this flag, the waitpid will
363 be skipped and the caller is responsible to cleanup a forked
364 process. */
365 ASSUAN_NO_WAITPID = 1,
366 /* This flag indicates whether Assuan logging is in confidential
367 mode. Use assuan_{begin,end}_condidential to change the
368 mode. */
369 ASSUAN_CONFIDENTIAL = 2
371 assuan_flag_t;
373 #define ASSUAN_LINELENGTH 1002 /* 1000 + [CR,]LF */
375 struct assuan_context_s;
376 typedef struct assuan_context_s *assuan_context_t;
377 #ifndef _ASSUAN_ONLY_GPG_ERRORS
378 typedef struct assuan_context_s *ASSUAN_CONTEXT _ASSUAN_DEPRECATED;
379 #endif /*_ASSUAN_ONLY_GPG_ERRORS*/
381 /* Because we use system handles and not libc low level file
382 descriptors on W32, we need to declare them as HANDLE (which
383 actually is a plain pointer). This is required to eventually
384 support 64 bit Windows systems. */
385 #ifdef _WIN32
386 typedef void *assuan_fd_t;
387 #define ASSUAN_INVALID_FD ((void*)(-1))
388 #define ASSUAN_INT2FD(s) ((void *)(s))
389 #define ASSUAN_FD2INT(h) ((unsigned int)(h))
390 #else
391 typedef int assuan_fd_t;
392 #define ASSUAN_INVALID_FD (-1)
393 #define ASSUAN_INT2FD(s) ((s))
394 #define ASSUAN_FD2INT(h) ((h))
395 #endif
398 /* Assuan features an emulation of Unix domain sockets based on a
399 local TCP connections. To implement access permissions based on
400 file permissions a nonce is used which is expected by th server as
401 the first bytes received. This structure is used by the server to
402 save the nonce created initially by bind. On POSIX systems this is
403 a dummy operation. */
404 struct assuan_sock_nonce_s
406 size_t length;
407 #ifdef _WIN32
408 char nonce[16];
409 #endif
411 typedef struct assuan_sock_nonce_s assuan_sock_nonce_t;
413 /* Define the Unix domain socket structure for Windows. */
414 #if defined(_WIN32) && !defined(_ASSUAN_NO_SOCKET_WRAPPER)
415 #ifndef AF_LOCAL
416 #define AF_LOCAL AF_UNIX
417 #endif
418 #define EADDRINUSE WSAEADDRINUSE
419 struct sockaddr_un
421 short sun_family;
422 unsigned short sun_port;
423 struct in_addr sun_addr;
424 char sun_path[108-2-4];
426 #endif
429 /* Definition of hook functions used to conditionally replace the
430 default I/O functions. */
431 struct assuan_io_hooks
433 int (*read_hook)(assuan_context_t, assuan_fd_t, void *, size_t, ssize_t *);
434 int (*write_hook)(assuan_context_t, assuan_fd_t fd,
435 const void *, size_t, ssize_t *);
437 typedef struct assuan_io_hooks *assuan_io_hooks_t;
441 /*-- assuan-handler.c --*/
442 int assuan_register_command (assuan_context_t ctx,
443 const char *cmd_string,
444 int (*handler)(assuan_context_t, char *));
445 int assuan_register_post_cmd_notify (assuan_context_t ctx,
446 void (*fnc)(assuan_context_t, int));
447 int assuan_register_pre_cmd_notify (assuan_context_t ctx,
448 int (*fnc)(assuan_context_t, const char *));
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);
534 /*-- assuan-connect.c --*/
535 void assuan_disconnect (assuan_context_t ctx);
536 pid_t assuan_get_pid (assuan_context_t ctx);
537 #ifndef _WIN32
538 assuan_error_t assuan_get_peercred (assuan_context_t ctx,
539 pid_t *pid, uid_t *uid, gid_t *gid);
540 #endif
542 /*-- assuan-client.c --*/
543 assuan_error_t
544 assuan_transact (assuan_context_t ctx,
545 const char *command,
546 assuan_error_t (*data_cb)(void *, const void *, size_t),
547 void *data_cb_arg,
548 assuan_error_t (*inquire_cb)(void*, const char *),
549 void *inquire_cb_arg,
550 assuan_error_t (*status_cb)(void*, const char *),
551 void *status_cb_arg);
554 /*-- assuan-inquire.c --*/
555 assuan_error_t assuan_inquire (assuan_context_t ctx, const char *keyword,
556 unsigned char **r_buffer, size_t *r_length,
557 size_t maxlen);
558 assuan_error_t assuan_inquire_ext (assuan_context_t ctx, const char *keyword,
559 size_t maxlen,
560 int (*cb) (void *cb_data, int rc,
561 unsigned char *buf,
562 size_t buf_len),
563 void *cb_data);
564 /*-- assuan-buffer.c --*/
565 assuan_error_t assuan_read_line (assuan_context_t ctx,
566 char **line, size_t *linelen);
567 int assuan_pending_line (assuan_context_t ctx);
568 assuan_error_t assuan_write_line (assuan_context_t ctx, const char *line );
569 assuan_error_t assuan_send_data (assuan_context_t ctx,
570 const void *buffer, size_t length);
572 /* The file descriptor must be pending before assuan_receivefd is
573 called. This means that assuan_sendfd should be called *before* the
574 trigger is sent (normally via assuan_write_line ("INPUT FD")). */
575 assuan_error_t assuan_sendfd (assuan_context_t ctx, assuan_fd_t fd);
576 assuan_error_t assuan_receivefd (assuan_context_t ctx, assuan_fd_t *fd);
579 /*-- assuan-util.c --*/
580 void assuan_set_malloc_hooks ( void *(*new_alloc_func)(size_t n),
581 void *(*new_realloc_func)(void *p, size_t n),
582 void (*new_free_func)(void*) );
583 void assuan_set_io_hooks (assuan_io_hooks_t io_hooks);
584 void assuan_set_log_stream (assuan_context_t ctx, FILE *fp);
585 int assuan_set_error (assuan_context_t ctx, int err, const char *text);
586 void assuan_set_pointer (assuan_context_t ctx, void *pointer);
587 void *assuan_get_pointer (assuan_context_t ctx);
589 void assuan_begin_confidential (assuan_context_t ctx);
590 void assuan_end_confidential (assuan_context_t ctx);
592 void assuan_set_io_monitor (assuan_context_t ctx,
593 unsigned int (*monitor)(assuan_context_t ctx,
594 int direction,
595 const char *line,
596 size_t linelen));
598 /* For context CTX, set the flag FLAG to VALUE. Values for flags
599 are usually 1 or 0 but certain flags might allow for other values;
600 see the description of the type assuan_flag_t for details. */
601 void assuan_set_flag (assuan_context_t ctx, assuan_flag_t flag, int value);
603 /* Return the VALUE of FLAG in context CTX. */
604 int assuan_get_flag (assuan_context_t ctx, assuan_flag_t flag);
607 /*-- assuan-errors.c --*/
609 #ifndef _ASSUAN_ONLY_GPG_ERRORS
610 /* Return a string describing the assuan error. The use of this
611 function is deprecated; it is better to call
612 assuan_set_assuan_err_source once and then make use libgpg-error. */
613 const char *assuan_strerror (assuan_error_t err);
614 #endif /*_ASSUAN_ONLY_GPG_ERRORS*/
616 /* Enable gpg-error style error codes. ERRSOURCE is one of gpg-error
617 sources. Note, that this function is not thread-safe and should be
618 used right at startup. Switching back to the old style mode is not
619 supported. */
620 void assuan_set_assuan_err_source (int errsource);
622 /*-- assuan-logging.c --*/
624 /* Set the stream to which assuan should log message not associated
625 with a context. By default, this is stderr. The default value
626 will be changed when the first log stream is associated with a
627 context. Note, that this function is not thread-safe and should
628 in general be used right at startup. */
629 extern void assuan_set_assuan_log_stream (FILE *fp);
631 /* Return the stream which is currently being using for global logging. */
632 extern FILE *assuan_get_assuan_log_stream (void);
634 /* Set the prefix to be used at the start of a line emitted by assuan
635 on the log stream. The default is the empty string. Note, that
636 this function is not thread-safe and should in general be used
637 right at startup. */
638 void assuan_set_assuan_log_prefix (const char *text);
640 /* Return a prefix to be used at the start of a line emitted by assuan
641 on the log stream. The default implementation returns the empty
642 string, i.e. "" */
643 const char *assuan_get_assuan_log_prefix (void);
646 /*-- assuan-socket.c --*/
648 /* These are socket wrapper functions to support an emulation of Unix
649 domain sockets on Windows W32. */
650 int assuan_sock_close (assuan_fd_t fd);
651 assuan_fd_t assuan_sock_new (int domain, int type, int proto);
652 int assuan_sock_connect (assuan_fd_t sockfd,
653 struct sockaddr *addr, int addrlen);
654 int assuan_sock_bind (assuan_fd_t sockfd, struct sockaddr *addr, int addrlen);
655 int assuan_sock_get_nonce (struct sockaddr *addr, int addrlen,
656 assuan_sock_nonce_t *nonce);
657 int assuan_sock_check_nonce (assuan_fd_t fd, assuan_sock_nonce_t *nonce);
660 #ifdef __cplusplus
662 #endif
663 #endif /* ASSUAN_H */