pwmc: always save with the keyfile as key material.
[libpwmd.git] / assuan / assuan.h
blob98be1bf2236d549a1ff541b0c68c223929618a83
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_write_flush _ASSUAN_PREFIX(assuan_write_flush)
125 #define assuan_send_data _ASSUAN_PREFIX(assuan_send_data)
126 #define assuan_sendfd _ASSUAN_PREFIX(assuan_sendfd)
127 #define assuan_receivefd _ASSUAN_PREFIX(assuan_receivefd)
128 #define assuan_set_malloc_hooks _ASSUAN_PREFIX(assuan_set_malloc_hooks)
129 #define assuan_set_io_hooks _ASSUAN_PREFIX(assuan_set_io_hooks)
130 #define assuan_set_log_stream _ASSUAN_PREFIX(assuan_set_log_stream)
131 #define assuan_set_error _ASSUAN_PREFIX(assuan_set_error)
132 #define assuan_set_pointer _ASSUAN_PREFIX(assuan_set_pointer)
133 #define assuan_get_pointer _ASSUAN_PREFIX(assuan_get_pointer)
134 #define assuan_set_finish_handler _ASSUAN_PREFIX(assuan_set_finish_handler)
135 #define assuan_set_io_monitor _ASSUAN_PREFIX(assuan_set_io_monitor)
136 #define assuan_begin_confidential _ASSUAN_PREFIX(assuan_begin_confidential)
137 #define assuan_end_confidential _ASSUAN_PREFIX(assuan_end_confidential)
138 #define assuan_strerror _ASSUAN_PREFIX(assuan_strerror)
139 #define assuan_set_assuan_err_source \
140 _ASSUAN_PREFIX(assuan_set_assuan_err_source)
141 #define assuan_set_assuan_log_stream \
142 _ASSUAN_PREFIX(assuan_set_assuan_log_stream)
143 #define assuan_get_assuan_log_stream \
144 _ASSUAN_PREFIX(assuan_get_assuan_log_stream)
145 #define assuan_get_assuan_log_prefix \
146 _ASSUAN_PREFIX(assuan_get_assuan_log_prefix)
147 #define assuan_set_flag _ASSUAN_PREFIX(assuan_set_flag)
148 #define assuan_get_flag _ASSUAN_PREFIX(assuan_get_flag)
149 #define assuan_pipe_connect2 _ASSUAN_PREFIX(assuan_pipe_connect2)
150 #define assuan_set_assuan_log_prefix \
151 _ASSUAN_PREFIX(assuan_set_assuan_log_prefix)
152 #define assuan_sock_close _ASSUAN_PREFIX(assuan_sock_close)
153 #define assuan_sock_new _ASSUAN_PREFIX(assuan_sock_new)
154 #define assuan_sock_connect _ASSUAN_PREFIX(assuan_sock_connect)
155 #define assuan_sock_bind _ASSUAN_PREFIX(assuan_sock_bind)
156 #define assuan_sock_get_nonce _ASSUAN_PREFIX(assuan_sock_get_nonce)
157 #define assuan_sock_check_nonce _ASSUAN_PREFIX(assuan_sock_check_nonce)
160 /* And now the internal functions, argh... */
161 #define _assuan_read_line _ASSUAN_PREFIX(_assuan_read_line)
162 #define _assuan_cookie_write_data _ASSUAN_PREFIX(_assuan_cookie_write_data)
163 #define _assuan_cookie_write_flush _ASSUAN_PREFIX(_assuan_cookie_write_flush)
164 #define _assuan_read_from_server _ASSUAN_PREFIX(_assuan_read_from_server)
165 #define _assuan_domain_init _ASSUAN_PREFIX(_assuan_domain_init)
166 #define _assuan_register_std_commands \
167 _ASSUAN_PREFIX(_assuan_register_std_commands)
168 #define _assuan_simple_read _ASSUAN_PREFIX(_assuan_simple_read)
169 #define _assuan_simple_write _ASSUAN_PREFIX(_assuan_simple_write)
170 #define _assuan_io_read _ASSUAN_PREFIX(_assuan_io_read)
171 #define _assuan_io_write _ASSUAN_PREFIX(_assuan_io_write)
172 #define _assuan_io_hooks _ASSUAN_PREFIX(_assuan_io_hooks)
173 #define _assuan_new_context _ASSUAN_PREFIX(_assuan_new_context)
174 #define _assuan_release_context _ASSUAN_PREFIX(_assuan_release_context)
175 #define _assuan_malloc _ASSUAN_PREFIX(_assuan_malloc)
176 #define _assuan_realloc _ASSUAN_PREFIX(_assuan_realloc)
177 #define _assuan_calloc _ASSUAN_PREFIX(_assuan_calloc)
178 #define _assuan_free _ASSUAN_PREFIX(_assuan_free)
179 #define _assuan_log_print_buffer _ASSUAN_PREFIX(_assuan_log_print_buffer)
180 #define _assuan_log_sanitized_string \
181 _ASSUAN_PREFIX(_assuan_log_sanitized_string)
182 #define _assuan_log_printf _ASSUAN_PREFIX(_assuan_log_printf)
183 #define _assuan_set_default_log_stream \
184 _ASSUAN_PREFIX(_assuan_set_default_log_stream)
185 #define _assuan_w32_strerror _ASSUAN_PREFIX(_assuan_w32_strerror)
186 #define _assuan_gpg_strerror_r _ASSUAN_PREFIX(_assuan_gpg_strerror_r)
187 #define _assuan_gpg_strsource _ASSUAN_PREFIX(_assuan_gpg_strsource)
188 #define _assuan_write_line _ASSUAN_PREFIX(_assuan_write_line)
189 #define _assuan_write_flush _ASSUAN_PREFIX(_assuan_write_flush)
190 #define _assuan_error _ASSUAN_PREFIX(_assuan_error)
191 #define _assuan_error_is_eagain _ASSUAN_PREFIX(_assuan_error_is_eagain)
192 #define _assuan_init_uds_io _ASSUAN_PREFIX(_assuan_init_uds_io)
193 #define _assuan_uds_close_fds _ASSUAN_PREFIX(_assuan_uds_close_fds)
194 #define _assuan_uds_deinit _ASSUAN_PREFIX(_assuan_uds_deinit)
195 #define _assuan_simple_recvmsg _ASSUAN_PREFIX(_assuan_simple_recvmsg)
196 #define _assuan_simple_sendmsg _ASSUAN_PREFIX(_assuan_simple_sendmsg)
197 #define _assuan_waitpid _ASSUAN_PREFIX(_assuan_waitpid)
198 #define _assuan_sock_wsa2errno _ASSUAN_PREFIX(_assuan_sock_wsa2errno)
199 #define _assuan_sock_close _ASSUAN_PREFIX(_assuan_sock_close)
200 #define _assuan_sock_new _ASSUAN_PREFIX(_assuan_sock_new)
201 #define _assuan_sock_connect _ASSUAN_PREFIX(_assuan_sock_connect)
202 #define _assuan_sock_bind _ASSUAN_PREFIX(_assuan_sock_bind)
203 #define _assuan_sock_get_nonce _ASSUAN_PREFIX(_assuan_sock_get_nonce)
204 #define _assuan_sock_check_nonce _ASSUAN_PREFIX(_assuan_sock_check_nonce)
206 #endif /*_ASSUAN_EXT_SYM_PREFIX*/
209 #ifdef __cplusplus
210 extern "C"
212 #if 0
214 #endif
215 #endif
218 /* Check for compiler features. */
219 #if __GNUC__
220 #define _ASSUAN_GCC_VERSION (__GNUC__ * 10000 \
221 + __GNUC_MINOR__ * 100 \
222 + __GNUC_PATCHLEVEL__)
224 #if _ASSUAN_GCC_VERSION > 30100
225 #define _ASSUAN_DEPRECATED __attribute__ ((__deprecated__))
226 #endif
227 #endif
228 #ifndef _ASSUAN_DEPRECATED
229 #define _ASSUAN_DEPRECATED
230 #endif
233 /* Assuan error codes. These are only used by old applications or
234 those applications which won't make use of libgpg-error. */
235 #ifndef _ASSUAN_ONLY_GPG_ERRORS
236 #ifndef _ASSUAN_IN_LIBASSUAN
237 #define ASSUAN_No_Error 0
238 #endif
239 #define ASSUAN_General_Error 1
240 #define ASSUAN_Out_Of_Core 2
241 #define ASSUAN_Invalid_Value 3
242 #ifndef _ASSUAN_IN_LIBASSUAN
243 #define ASSUAN_Timeout 4
244 #endif
245 #define ASSUAN_Read_Error 5
246 #define ASSUAN_Write_Error 6
247 #define ASSUAN_Problem_Starting_Server 7
248 #define ASSUAN_Not_A_Server 8
249 #ifndef _ASSUAN_IN_LIBASSUAN
250 #define ASSUAN_Not_A_Client 9
251 #endif
252 #define ASSUAN_Nested_Commands 10
253 #define ASSUAN_Invalid_Response 11
254 #define ASSUAN_No_Data_Callback 12
255 #define ASSUAN_No_Inquire_Callback 13
256 #define ASSUAN_Connect_Failed 14
257 #define ASSUAN_Accept_Failed 15
259 /* Error codes above 99 are meant as status codes */
260 #define ASSUAN_Not_Implemented 100
261 #define ASSUAN_Server_Fault 101
262 #ifndef _ASSUAN_IN_LIBASSUAN
263 #define ASSUAN_Invalid_Command 102
264 #endif
265 #define ASSUAN_Unknown_Command 103
266 #define ASSUAN_Syntax_Error 104
267 #ifndef _ASSUAN_IN_LIBASSUAN
268 #define ASSUAN_Parameter_Error 105
269 #endif
270 #define ASSUAN_Parameter_Conflict 106
271 #define ASSUAN_Line_Too_Long 107
272 #define ASSUAN_Line_Not_Terminated 108
273 #ifndef _ASSUAN_IN_LIBASSUAN
274 #define ASSUAN_No_Input 109
275 #define ASSUAN_No_Output 110
276 #endif
277 #define ASSUAN_Canceled 111
278 #ifndef _ASSUAN_IN_LIBASSUAN
279 #define ASSUAN_Unsupported_Algorithm 112
280 #define ASSUAN_Server_Resource_Problem 113
281 #define ASSUAN_Server_IO_Error 114
282 #define ASSUAN_Server_Bug 115
283 #define ASSUAN_No_Data_Available 116
284 #define ASSUAN_Invalid_Data 117
285 #endif
286 #define ASSUAN_Unexpected_Command 118
287 #define ASSUAN_Too_Much_Data 119
288 #ifndef _ASSUAN_IN_LIBASSUAN
289 #define ASSUAN_Inquire_Unknown 120
290 #define ASSUAN_Inquire_Error 121
291 #define ASSUAN_Invalid_Option 122
292 #define ASSUAN_Invalid_Index 123
293 #define ASSUAN_Unexpected_Status 124
294 #define ASSUAN_Unexpected_Data 125
295 #define ASSUAN_Invalid_Status 126
296 #define ASSUAN_Locale_Problem 127
297 #endif
298 #define ASSUAN_Not_Confirmed 128
300 /* Warning: Don't use the Error codes, below they are deprecated. */
301 #ifndef _ASSUAN_IN_LIBASSUAN
302 #define ASSUAN_Bad_Certificate 201
303 #define ASSUAN_Bad_Certificate_Chain 202
304 #define ASSUAN_Missing_Certificate 203
305 #define ASSUAN_Bad_Signature 204
306 #define ASSUAN_No_Agent 205
307 #define ASSUAN_Agent_Error 206
308 #define ASSUAN_No_Public_Key 207
309 #define ASSUAN_No_Secret_Key 208
310 #define ASSUAN_Invalid_Name 209
312 #define ASSUAN_Cert_Revoked 301
313 #define ASSUAN_No_CRL_For_Cert 302
314 #define ASSUAN_CRL_Too_Old 303
315 #define ASSUAN_Not_Trusted 304
317 #define ASSUAN_Card_Error 401
318 #define ASSUAN_Invalid_Card 402
319 #define ASSUAN_No_PKCS15_App 403
320 #define ASSUAN_Card_Not_Present 404
321 #define ASSUAN_Invalid_Id 405
323 /* Error codes in the range 1000 to 9999 may be used by applications
324 at their own discretion. */
325 #define ASSUAN_USER_ERROR_FIRST 1000
326 #define ASSUAN_USER_ERROR_LAST 9999
327 #endif
329 typedef int assuan_error_t;
331 typedef assuan_error_t AssuanError _ASSUAN_DEPRECATED;
333 /* This is a list of pre-registered ASSUAN commands */
334 /* Note, these command IDs are now deprectated and solely exists for
335 compatibility reasons. */
336 typedef enum
338 ASSUAN_CMD_NOP = 0,
339 ASSUAN_CMD_CANCEL, /* cancel the current request */
340 ASSUAN_CMD_BYE,
341 ASSUAN_CMD_AUTH,
342 ASSUAN_CMD_RESET,
343 ASSUAN_CMD_OPTION,
344 ASSUAN_CMD_DATA,
345 ASSUAN_CMD_END,
346 ASSUAN_CMD_INPUT,
347 ASSUAN_CMD_OUTPUT,
349 ASSUAN_CMD_USER = 256 /* Other commands should be used with this offset*/
350 } AssuanCommand;
353 #else /*!_ASSUAN_ONLY_GPG_ERRORS*/
355 /* Choose a type compatible with gpg_error_t. */
356 typedef unsigned int assuan_error_t;
358 #endif /*!_ASSUAN_ONLY_GPG_ERRORS*/
361 /* Definitions of flags for assuan_set_flag(). */
362 typedef enum
364 /* When using a pipe server, by default Assuan will wait for the
365 forked process to die in assuan_disconnect. In certain cases
366 this is not desirable. By setting this flag, the waitpid will
367 be skipped and the caller is responsible to cleanup a forked
368 process. */
369 ASSUAN_NO_WAITPID = 1,
370 /* This flag indicates whether Assuan logging is in confidential
371 mode. Use assuan_{begin,end}_condidential to change the
372 mode. */
373 ASSUAN_CONFIDENTIAL = 2
375 assuan_flag_t;
377 #define ASSUAN_LINELENGTH 1002 /* 1000 + [CR,]LF */
379 struct assuan_context_s;
380 typedef struct assuan_context_s *assuan_context_t;
381 #ifndef _ASSUAN_ONLY_GPG_ERRORS
382 typedef struct assuan_context_s *ASSUAN_CONTEXT _ASSUAN_DEPRECATED;
383 #endif /*_ASSUAN_ONLY_GPG_ERRORS*/
385 /* Because we use system handles and not libc low level file
386 descriptors on W32, we need to declare them as HANDLE (which
387 actually is a plain pointer). This is required to eventually
388 support 64 bit Windows systems. */
389 #ifdef _WIN32
390 typedef void *assuan_fd_t;
391 #define ASSUAN_INVALID_FD ((void*)(-1))
392 #define ASSUAN_INT2FD(s) ((void *)(s))
393 #define ASSUAN_FD2INT(h) ((unsigned int)(h))
394 #else
395 typedef int assuan_fd_t;
396 #define ASSUAN_INVALID_FD (-1)
397 #define ASSUAN_INT2FD(s) ((s))
398 #define ASSUAN_FD2INT(h) ((h))
399 #endif
402 /* Assuan features an emulation of Unix domain sockets based on a
403 local TCP connections. To implement access permissions based on
404 file permissions a nonce is used which is expected by th server as
405 the first bytes received. This structure is used by the server to
406 save the nonce created initially by bind. On POSIX systems this is
407 a dummy operation. */
408 struct assuan_sock_nonce_s
410 size_t length;
411 #ifdef _WIN32
412 char nonce[16];
413 #endif
415 typedef struct assuan_sock_nonce_s assuan_sock_nonce_t;
417 /* Define the Unix domain socket structure for Windows. */
418 #if defined(_WIN32) && !defined(_ASSUAN_NO_SOCKET_WRAPPER)
419 #ifndef AF_LOCAL
420 #define AF_LOCAL AF_UNIX
421 #endif
422 #define EADDRINUSE WSAEADDRINUSE
423 struct sockaddr_un
425 short sun_family;
426 unsigned short sun_port;
427 struct in_addr sun_addr;
428 char sun_path[108-2-4];
430 #endif
433 /* Definition of hook functions used to conditionally replace the
434 default I/O functions. */
435 struct assuan_io_hooks
437 int (*read_hook)(assuan_context_t, assuan_fd_t, void *, size_t, ssize_t *);
438 int (*write_hook)(assuan_context_t, assuan_fd_t fd,
439 const void *, size_t, ssize_t *);
441 typedef struct assuan_io_hooks *assuan_io_hooks_t;
445 /*-- assuan-handler.c --*/
446 int assuan_register_command (assuan_context_t ctx,
447 const char *cmd_string,
448 int (*handler)(assuan_context_t, char *));
449 int assuan_register_post_cmd_notify (assuan_context_t ctx,
450 void (*fnc)(assuan_context_t, int));
451 int assuan_register_bye_notify (assuan_context_t ctx,
452 void (*fnc)(assuan_context_t));
453 int assuan_register_reset_notify (assuan_context_t ctx,
454 void (*fnc)(assuan_context_t));
455 int assuan_register_cancel_notify (assuan_context_t ctx,
456 void (*fnc)(assuan_context_t));
457 int assuan_register_input_notify (assuan_context_t ctx,
458 void (*fnc)(assuan_context_t, const char *));
459 int assuan_register_output_notify (assuan_context_t ctx,
460 void (*fnc)(assuan_context_t, const char *));
462 int assuan_register_option_handler (assuan_context_t ctx,
463 int (*fnc)(assuan_context_t,
464 const char*, const char*));
466 int assuan_process (assuan_context_t ctx);
467 int assuan_process_next (assuan_context_t ctx);
468 int assuan_process_done (assuan_context_t ctx, int rc);
469 int assuan_get_active_fds (assuan_context_t ctx, int what,
470 assuan_fd_t *fdarray, int fdarraysize);
473 FILE *assuan_get_data_fp (assuan_context_t ctx);
474 assuan_error_t assuan_set_okay_line (assuan_context_t ctx, const char *line);
475 assuan_error_t assuan_write_status (assuan_context_t ctx,
476 const char *keyword, const char *text);
478 /* Negotiate a file descriptor. If LINE contains "FD=N", returns N
479 assuming a local file descriptor. If LINE contains "FD" reads a
480 file descriptor via CTX and stores it in *RDF (the CTX must be
481 capable of passing file descriptors). Under W32 the returned FD is
482 a libc-type one. */
483 assuan_error_t assuan_command_parse_fd (assuan_context_t ctx, char *line,
484 assuan_fd_t *rfd);
487 /*-- assuan-listen.c --*/
488 assuan_error_t assuan_set_hello_line (assuan_context_t ctx, const char *line);
489 assuan_error_t assuan_accept (assuan_context_t ctx);
490 assuan_fd_t assuan_get_input_fd (assuan_context_t ctx);
491 assuan_fd_t assuan_get_output_fd (assuan_context_t ctx);
492 assuan_error_t assuan_close_input_fd (assuan_context_t ctx);
493 assuan_error_t assuan_close_output_fd (assuan_context_t ctx);
496 /*-- assuan-pipe-server.c --*/
497 int assuan_init_pipe_server (assuan_context_t *r_ctx, int filedes[2]);
498 void assuan_deinit_server (assuan_context_t ctx);
500 /*-- assuan-socket-server.c --*/
501 int assuan_init_socket_server (assuan_context_t *r_ctx, assuan_fd_t listen_fd);
502 int assuan_init_connected_socket_server (assuan_context_t *r_ctx,
503 assuan_fd_t fd) _ASSUAN_DEPRECATED;
504 int assuan_init_socket_server_ext (assuan_context_t *r_ctx, assuan_fd_t fd,
505 unsigned int flags);
506 void assuan_set_sock_nonce (assuan_context_t ctx, assuan_sock_nonce_t *nonce);
508 /*-- assuan-pipe-connect.c --*/
509 assuan_error_t assuan_pipe_connect (assuan_context_t *ctx,
510 const char *name,
511 const char *const argv[],
512 int *fd_child_list,
513 int flags);
514 assuan_error_t assuan_pipe_connect2 (assuan_context_t *ctx,
515 const char *name,
516 const char *const argv[],
517 int *fd_child_list,
518 void (*atfork) (void*, int),
519 void *atforkvalue) _ASSUAN_DEPRECATED;
520 assuan_error_t assuan_pipe_connect_ext (assuan_context_t *ctx,
521 const char *name,
522 const char *const argv[],
523 int *fd_child_list,
524 void (*atfork) (void *, int),
525 void *atforkvalue,
526 unsigned int flags);
528 /*-- assuan-socket-connect.c --*/
529 assuan_error_t assuan_socket_connect (assuan_context_t *ctx,
530 const char *name,
531 pid_t server_pid);
532 assuan_error_t assuan_socket_connect_ext (assuan_context_t *ctx,
533 const char *name,
534 pid_t server_pid,
535 unsigned int flags);
536 assuan_error_t assuan_socket_connect_fd (assuan_context_t *ctx,
537 assuan_fd_t fd,
538 unsigned int flags, void *data);
540 /*-- assuan-connect.c --*/
541 void assuan_disconnect (assuan_context_t ctx);
542 pid_t assuan_get_pid (assuan_context_t ctx);
543 #ifndef _WIN32
544 assuan_error_t assuan_get_peercred (assuan_context_t ctx,
545 pid_t *pid, uid_t *uid, gid_t *gid);
546 #endif
548 /*-- assuan-client.c --*/
549 assuan_error_t
550 assuan_transact (assuan_context_t ctx,
551 const char *command,
552 assuan_error_t (*data_cb)(void *, const void *, size_t),
553 void *data_cb_arg,
554 assuan_error_t (*inquire_cb)(void*, const char *),
555 void *inquire_cb_arg,
556 assuan_error_t (*status_cb)(void*, const char *),
557 void *status_cb_arg);
560 /*-- assuan-inquire.c --*/
561 assuan_error_t assuan_inquire (assuan_context_t ctx, const char *keyword,
562 unsigned char **r_buffer, size_t *r_length,
563 size_t maxlen);
564 assuan_error_t assuan_inquire_ext (assuan_context_t ctx, const char *keyword,
565 size_t maxlen,
566 int (*cb) (void *cb_data, int rc,
567 unsigned char *buf,
568 size_t buf_len),
569 void *cb_data);
570 /*-- assuan-buffer.c --*/
571 assuan_error_t assuan_read_line (assuan_context_t ctx,
572 char **line, size_t *linelen);
573 int assuan_pending_line (assuan_context_t ctx);
574 assuan_error_t assuan_write_line (assuan_context_t ctx, const char *line );
575 assuan_error_t assuan_write_flush (assuan_context_t ctx );
576 assuan_error_t assuan_send_data (assuan_context_t ctx,
577 const void *buffer, size_t length);
579 /* The file descriptor must be pending before assuan_receivefd is
580 called. This means that assuan_sendfd should be called *before* the
581 trigger is sent (normally via assuan_write_line ("INPUT FD")). */
582 assuan_error_t assuan_sendfd (assuan_context_t ctx, assuan_fd_t fd);
583 assuan_error_t assuan_receivefd (assuan_context_t ctx, assuan_fd_t *fd);
586 /*-- assuan-util.c --*/
587 void assuan_set_malloc_hooks ( void *(*new_alloc_func)(size_t n),
588 void *(*new_realloc_func)(void *p, size_t n),
589 void (*new_free_func)(void*) );
590 void assuan_set_io_hooks (assuan_io_hooks_t io_hooks);
591 void assuan_set_log_stream (assuan_context_t ctx, FILE *fp);
592 int assuan_set_error (assuan_context_t ctx, int err, const char *text);
593 void assuan_set_pointer (assuan_context_t ctx, void *pointer);
594 void *assuan_get_pointer (assuan_context_t ctx);
595 void assuan_set_finish_handler(assuan_context_t ctx, void (*handler)(assuan_context_t));
597 void assuan_begin_confidential (assuan_context_t ctx);
598 void assuan_end_confidential (assuan_context_t ctx);
600 void assuan_set_io_monitor (assuan_context_t ctx,
601 unsigned int (*monitor)(assuan_context_t ctx,
602 int direction,
603 const char *line,
604 size_t linelen));
606 /* For context CTX, set the flag FLAG to VALUE. Values for flags
607 are usually 1 or 0 but certain flags might allow for other values;
608 see the description of the type assuan_flag_t for details. */
609 void assuan_set_flag (assuan_context_t ctx, assuan_flag_t flag, int value);
611 /* Return the VALUE of FLAG in context CTX. */
612 int assuan_get_flag (assuan_context_t ctx, assuan_flag_t flag);
615 /*-- assuan-errors.c --*/
617 #ifndef _ASSUAN_ONLY_GPG_ERRORS
618 /* Return a string describing the assuan error. The use of this
619 function is deprecated; it is better to call
620 assuan_set_assuan_err_source once and then make use libgpg-error. */
621 const char *assuan_strerror (assuan_error_t err);
622 #endif /*_ASSUAN_ONLY_GPG_ERRORS*/
624 /* Enable gpg-error style error codes. ERRSOURCE is one of gpg-error
625 sources. Note, that this function is not thread-safe and should be
626 used right at startup. Switching back to the old style mode is not
627 supported. */
628 void assuan_set_assuan_err_source (int errsource);
630 /*-- assuan-logging.c --*/
632 /* Set the stream to which assuan should log message not associated
633 with a context. By default, this is stderr. The default value
634 will be changed when the first log stream is associated with a
635 context. Note, that this function is not thread-safe and should
636 in general be used right at startup. */
637 extern void assuan_set_assuan_log_stream (FILE *fp);
639 /* Return the stream which is currently being using for global logging. */
640 extern FILE *assuan_get_assuan_log_stream (void);
642 /* Set the prefix to be used at the start of a line emitted by assuan
643 on the log stream. The default is the empty string. Note, that
644 this function is not thread-safe and should in general be used
645 right at startup. */
646 void assuan_set_assuan_log_prefix (const char *text);
648 /* Return a prefix to be used at the start of a line emitted by assuan
649 on the log stream. The default implementation returns the empty
650 string, i.e. "" */
651 const char *assuan_get_assuan_log_prefix (void);
654 /*-- assuan-socket.c --*/
656 /* These are socket wrapper functions to support an emulation of Unix
657 domain sockets on Windows W32. */
658 int assuan_sock_close (assuan_fd_t fd);
659 assuan_fd_t assuan_sock_new (int domain, int type, int proto);
660 int assuan_sock_connect (assuan_fd_t sockfd,
661 struct sockaddr *addr, int addrlen);
662 int assuan_sock_bind (assuan_fd_t sockfd, struct sockaddr *addr, int addrlen);
663 int assuan_sock_get_nonce (struct sockaddr *addr, int addrlen,
664 assuan_sock_nonce_t *nonce);
665 int assuan_sock_check_nonce (assuan_fd_t fd, assuan_sock_nonce_t *nonce);
668 #ifdef __cplusplus
670 #endif
671 #endif /* ASSUAN_H */