~ubuntu-branches/ubuntu/precise/gnupg2/precise-proposed

« back to all changes in this revision

Viewing changes to assuan/assuan.h

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Urlichs
  • Date: 2006-01-24 04:31:42 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060124043142-pbg192or6qxv3yk2
Tags: 1.9.20-1
* New Upstream version. Closes:#306890,#344530
  * Closes:#320490: gpg-protect-tool fails to decrypt PKCS-12 files 
* Depend on libopensc2-dev, not -1-. Closes:#348106

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* assuan.c - Definitions for the Assuan protocol
 
2
 *      Copyright (C) 2001, 2002 Free Software Foundation, Inc.
 
3
 *
 
4
 * This file is part of Assuan.
 
5
 *
 
6
 * Assuan is free software; you can redistribute it and/or modify it
 
7
 * under the terms of the GNU Lesser General Public License as
 
8
 * published by the Free Software Foundation; either version 2.1 of
 
9
 * the License, or (at your option) any later version.
 
10
 *
 
11
 * Assuan is distributed in the hope that it will be useful, but
 
12
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
 * Lesser General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU Lesser General Public
 
17
 * License along with this program; if not, write to the Free Software
 
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 
 
19
 */
 
20
 
 
21
#ifndef ASSUAN_H
 
22
#define ASSUAN_H
 
23
 
 
24
#include <stdio.h>
 
25
#include <sys/types.h>
 
26
#include <unistd.h> /* for ssize_t */
 
27
 
 
28
#ifdef __cplusplus
 
29
extern "C" { 
 
30
#if 0
 
31
 }
 
32
#endif
 
33
#endif
 
34
 
 
35
typedef enum {
 
36
  ASSUAN_No_Error = 0,
 
37
  ASSUAN_General_Error = 1,
 
38
  ASSUAN_Out_Of_Core = 2,
 
39
  ASSUAN_Invalid_Value = 3,
 
40
  ASSUAN_Timeout = 4,  
 
41
  ASSUAN_Read_Error = 5,
 
42
  ASSUAN_Write_Error = 6,
 
43
  ASSUAN_Problem_Starting_Server = 7,
 
44
  ASSUAN_Not_A_Server = 8,
 
45
  ASSUAN_Not_A_Client = 9,
 
46
  ASSUAN_Nested_Commands = 10,
 
47
  ASSUAN_Invalid_Response = 11,
 
48
  ASSUAN_No_Data_Callback = 12,
 
49
  ASSUAN_No_Inquire_Callback = 13,
 
50
  ASSUAN_Connect_Failed = 14,
 
51
  ASSUAN_Accept_Failed = 15,
 
52
 
 
53
  /* error codes above 99 are meant as status codes */
 
54
  ASSUAN_Not_Implemented = 100,
 
55
  ASSUAN_Server_Fault    = 101,
 
56
  ASSUAN_Invalid_Command = 102,
 
57
  ASSUAN_Unknown_Command = 103,
 
58
  ASSUAN_Syntax_Error    = 104,
 
59
  ASSUAN_Parameter_Error = 105,
 
60
  ASSUAN_Parameter_Conflict = 106,
 
61
  ASSUAN_Line_Too_Long = 107,
 
62
  ASSUAN_Line_Not_Terminated = 108,
 
63
  ASSUAN_No_Input = 109,
 
64
  ASSUAN_No_Output = 110,
 
65
  ASSUAN_Canceled = 111,
 
66
  ASSUAN_Unsupported_Algorithm = 112,
 
67
  ASSUAN_Server_Resource_Problem = 113,
 
68
  ASSUAN_Server_IO_Error = 114,
 
69
  ASSUAN_Server_Bug = 115,
 
70
  ASSUAN_No_Data_Available = 116,
 
71
  ASSUAN_Invalid_Data = 117,
 
72
  ASSUAN_Unexpected_Command = 118,
 
73
  ASSUAN_Too_Much_Data = 119,
 
74
  ASSUAN_Inquire_Unknown = 120,
 
75
  ASSUAN_Inquire_Error = 121,
 
76
  ASSUAN_Invalid_Option = 122,
 
77
  ASSUAN_Invalid_Index = 123,
 
78
  ASSUAN_Unexpected_Status = 124,
 
79
  ASSUAN_Unexpected_Data = 125,
 
80
  ASSUAN_Invalid_Status = 126,
 
81
 
 
82
  ASSUAN_Not_Confirmed = 128,
 
83
 
 
84
  ASSUAN_Bad_Certificate = 201,
 
85
  ASSUAN_Bad_Certificate_Chain = 202,
 
86
  ASSUAN_Missing_Certificate = 203,
 
87
  ASSUAN_Bad_Signature = 204,
 
88
  ASSUAN_No_Agent = 205,
 
89
  ASSUAN_Agent_Error = 206,
 
90
  ASSUAN_No_Public_Key = 207,
 
91
  ASSUAN_No_Secret_Key = 208,
 
92
  ASSUAN_Invalid_Name = 209,
 
93
 
 
94
  ASSUAN_Cert_Revoked = 301,
 
95
  ASSUAN_No_CRL_For_Cert = 302,
 
96
  ASSUAN_CRL_Too_Old = 303,
 
97
  ASSUAN_Not_Trusted = 304,
 
98
 
 
99
  ASSUAN_Card_Error = 401,
 
100
  ASSUAN_Invalid_Card = 402,
 
101
  ASSUAN_No_PKCS15_App = 403,
 
102
  ASSUAN_Card_Not_Present = 404,
 
103
  ASSUAN_Invalid_Id = 405
 
104
 
 
105
} AssuanError;
 
106
 
 
107
/* This is a list of pre-registered ASSUAN commands */
 
108
typedef enum {
 
109
  ASSUAN_CMD_NOP = 0,
 
110
  ASSUAN_CMD_CANCEL,    /* cancel the current request */
 
111
  ASSUAN_CMD_BYE,
 
112
  ASSUAN_CMD_AUTH,
 
113
  ASSUAN_CMD_RESET,
 
114
  ASSUAN_CMD_OPTION,
 
115
  ASSUAN_CMD_DATA,
 
116
  ASSUAN_CMD_END,
 
117
  ASSUAN_CMD_INPUT,
 
118
  ASSUAN_CMD_OUTPUT,
 
119
 
 
120
  ASSUAN_CMD_USER = 256  /* Other commands should be used with this offset*/
 
121
} AssuanCommand;
 
122
 
 
123
#define ASSUAN_LINELENGTH 1002 /* 1000 + [CR,]LF */
 
124
 
 
125
struct assuan_context_s;
 
126
typedef struct assuan_context_s *ASSUAN_CONTEXT;
 
127
 
 
128
/*-- assuan-handler.c --*/
 
129
int assuan_register_command (ASSUAN_CONTEXT ctx,
 
130
                             int cmd_id, const char *cmd_string,
 
131
                             int (*handler)(ASSUAN_CONTEXT, char *));
 
132
int assuan_register_bye_notify (ASSUAN_CONTEXT ctx,
 
133
                                void (*fnc)(ASSUAN_CONTEXT));
 
134
int assuan_register_reset_notify (ASSUAN_CONTEXT ctx,
 
135
                                  void (*fnc)(ASSUAN_CONTEXT));
 
136
int assuan_register_cancel_notify (ASSUAN_CONTEXT ctx,
 
137
                                   void (*fnc)(ASSUAN_CONTEXT));
 
138
int assuan_register_input_notify (ASSUAN_CONTEXT ctx,
 
139
                                  void (*fnc)(ASSUAN_CONTEXT, const char *));
 
140
int assuan_register_output_notify (ASSUAN_CONTEXT ctx,
 
141
                                  void (*fnc)(ASSUAN_CONTEXT, const char *));
 
142
 
 
143
int assuan_register_option_handler (ASSUAN_CONTEXT ctx,
 
144
                                    int (*fnc)(ASSUAN_CONTEXT,
 
145
                                               const char*, const char*));
 
146
 
 
147
int assuan_process (ASSUAN_CONTEXT ctx);
 
148
int assuan_process_next (ASSUAN_CONTEXT ctx);
 
149
int assuan_get_active_fds (ASSUAN_CONTEXT ctx, int what,
 
150
                           int *fdarray, int fdarraysize);
 
151
 
 
152
 
 
153
FILE *assuan_get_data_fp (ASSUAN_CONTEXT ctx);
 
154
AssuanError assuan_set_okay_line (ASSUAN_CONTEXT ctx, const char *line);
 
155
void assuan_write_status (ASSUAN_CONTEXT ctx,
 
156
                          const char *keyword, const char *text);
 
157
 
 
158
 
 
159
/*-- assuan-listen.c --*/
 
160
AssuanError assuan_set_hello_line (ASSUAN_CONTEXT ctx, const char *line);
 
161
AssuanError assuan_accept (ASSUAN_CONTEXT ctx);
 
162
int assuan_get_input_fd (ASSUAN_CONTEXT ctx);
 
163
int assuan_get_output_fd (ASSUAN_CONTEXT ctx);
 
164
AssuanError assuan_close_input_fd (ASSUAN_CONTEXT ctx);
 
165
AssuanError assuan_close_output_fd (ASSUAN_CONTEXT ctx);
 
166
 
 
167
 
 
168
/*-- assuan-pipe-server.c --*/
 
169
int assuan_init_pipe_server (ASSUAN_CONTEXT *r_ctx, int filedes[2]);
 
170
void assuan_deinit_server (ASSUAN_CONTEXT ctx);
 
171
 
 
172
/*-- assuan-socket-server.c --*/
 
173
int assuan_init_socket_server (ASSUAN_CONTEXT *r_ctx, int listen_fd);
 
174
int assuan_init_connected_socket_server (ASSUAN_CONTEXT *r_ctx, int fd);
 
175
 
 
176
 
 
177
/*-- assuan-pipe-connect.c --*/
 
178
AssuanError assuan_pipe_connect (ASSUAN_CONTEXT *ctx, const char *name,
 
179
                                 char *const argv[], int *fd_child_list);
 
180
/*-- assuan-socket-connect.c --*/
 
181
AssuanError assuan_socket_connect (ASSUAN_CONTEXT *ctx, const char *name,
 
182
                                   pid_t server_pid);
 
183
 
 
184
/*-- assuan-connect.c --*/
 
185
void assuan_disconnect (ASSUAN_CONTEXT ctx);
 
186
pid_t assuan_get_pid (ASSUAN_CONTEXT ctx);
 
187
 
 
188
/*-- assuan-client.c --*/
 
189
AssuanError 
 
190
assuan_transact (ASSUAN_CONTEXT ctx,
 
191
                 const char *command,
 
192
                 AssuanError (*data_cb)(void *, const void *, size_t),
 
193
                 void *data_cb_arg,
 
194
                 AssuanError (*inquire_cb)(void*, const char *),
 
195
                 void *inquire_cb_arg,
 
196
                 AssuanError (*status_cb)(void*, const char *),
 
197
                 void *status_cb_arg);
 
198
 
 
199
 
 
200
/*-- assuan-inquire.c --*/
 
201
AssuanError assuan_inquire (ASSUAN_CONTEXT ctx, const char *keyword,
 
202
                            char **r_buffer, size_t *r_length, size_t maxlen);
 
203
 
 
204
/*-- assuan-buffer.c --*/
 
205
AssuanError assuan_read_line (ASSUAN_CONTEXT ctx,
 
206
                              char **line, size_t *linelen);
 
207
int assuan_pending_line (ASSUAN_CONTEXT ctx);
 
208
AssuanError assuan_write_line (ASSUAN_CONTEXT ctx, const char *line );
 
209
AssuanError assuan_send_data (ASSUAN_CONTEXT ctx,
 
210
                              const void *buffer, size_t length);
 
211
 
 
212
 
 
213
/*-- assuan-util.c --*/
 
214
void assuan_set_malloc_hooks ( void *(*new_alloc_func)(size_t n),
 
215
                               void *(*new_realloc_func)(void *p, size_t n),
 
216
                               void (*new_free_func)(void*) );
 
217
void assuan_set_io_func (ssize_t (*r)(int,void*,size_t),
 
218
                         ssize_t (*w)(int,const void*,size_t));
 
219
void assuan_set_log_stream (ASSUAN_CONTEXT ctx, FILE *fp);
 
220
int assuan_set_error (ASSUAN_CONTEXT ctx, int err, const char *text);
 
221
void assuan_set_pointer (ASSUAN_CONTEXT ctx, void *pointer);
 
222
void *assuan_get_pointer (ASSUAN_CONTEXT ctx);
 
223
 
 
224
void assuan_begin_confidential (ASSUAN_CONTEXT ctx);
 
225
void assuan_end_confidential (ASSUAN_CONTEXT ctx);
 
226
 
 
227
/*-- assuan-errors.c (built) --*/
 
228
const char *assuan_strerror (AssuanError err);
 
229
 
 
230
 
 
231
#ifdef __cplusplus
 
232
}
 
233
#endif
 
234
#endif /*ASSUAN_H*/