1
/* assuan-defs.c - Internal definitions to Assuan
2
* Copyright (C) 2001, 2002 Free Software Foundation, Inc.
4
* This file is part of Assuan.
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.
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.
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
24
#include <sys/types.h>
27
#define LINELENGTH ASSUAN_LINELENGTH
32
int (*handler)(ASSUAN_CONTEXT, char *line);
35
struct assuan_context_s {
38
int os_errno; /* last system error number used with certain error codes*/
41
int is_server; /* set if this is context belongs to a server */
44
char *okay_line; /* see assan_set_okay_line() */
46
void *user_pointer; /* for assuan_[gs]et_pointer () */
53
char line[LINELENGTH];
54
int linelen; /* w/o CR, LF - might not be the same as
55
strlen(line) due to embedded nuls. However a nul
56
is always written at this pos */
58
char line[LINELENGTH];
60
int pending; /* i.e. at least one line is available in the attic */
68
char line[LINELENGTH];
74
int pipe_mode; /* We are in pipe mode, i.e. we can handle just one
75
connection and must terminate then */
76
pid_t pid; /* In pipe mode, the pid of the child server process.
77
In socket mode, the pid of the server */
78
int listen_fd; /* The fd we are listening on (used by socket servers) */
79
int connected_fd; /* helper */
81
pid_t client_pid; /* for a socket server the PID of the client or -1
84
void (*deinit_handler)(ASSUAN_CONTEXT);
85
int (*accept_handler)(ASSUAN_CONTEXT);
86
int (*finish_handler)(ASSUAN_CONTEXT);
88
struct cmdtbl_s *cmdtbl;
89
size_t cmdtbl_used; /* used entries */
90
size_t cmdtbl_size; /* allocated size of table */
92
void (*bye_notify_fnc)(ASSUAN_CONTEXT);
93
void (*reset_notify_fnc)(ASSUAN_CONTEXT);
94
void (*cancel_notify_fnc)(ASSUAN_CONTEXT);
95
int (*option_handler_fnc)(ASSUAN_CONTEXT,const char*, const char*);
96
void (*input_notify_fnc)(ASSUAN_CONTEXT, const char *);
97
void (*output_notify_fnc)(ASSUAN_CONTEXT, const char *);
99
int input_fd; /* set by INPUT command */
100
int output_fd; /* set by OUTPUT command */
106
/*-- assuan-pipe-server.c --*/
107
int _assuan_new_context (ASSUAN_CONTEXT *r_ctx);
108
void _assuan_release_context (ASSUAN_CONTEXT ctx);
111
/*-- assuan-handler.c --*/
112
int _assuan_register_std_commands (ASSUAN_CONTEXT ctx);
114
/*-- assuan-buffer.c --*/
115
int _assuan_read_line (ASSUAN_CONTEXT ctx);
116
int _assuan_cookie_write_data (void *cookie, const char *buffer, size_t size);
117
int _assuan_cookie_write_flush (void *cookie);
119
/*-- assuan-client.c --*/
120
AssuanError _assuan_read_from_server (ASSUAN_CONTEXT ctx, int *okay, int *off);
123
/*-- assuan-util.c --*/
124
extern ssize_t (*_assuan_read_wrapper)(int,void*,size_t);
125
extern ssize_t (*_assuan_write_wrapper)(int,const void*,size_t);
127
void *_assuan_malloc (size_t n);
128
void *_assuan_calloc (size_t n, size_t m);
129
void *_assuan_realloc (void *p, size_t n);
130
void _assuan_free (void *p);
132
#define xtrymalloc(a) _assuan_malloc ((a))
133
#define xtrycalloc(a,b) _assuan_calloc ((a),(b))
134
#define xtryrealloc(a,b) _assuan_realloc((a),(b))
135
#define xfree(a) _assuan_free ((a))
137
#define set_error(c,e,t) assuan_set_error ((c), ASSUAN_ ## e, (t))
139
void _assuan_log_print_buffer (FILE *fp, const void *buffer, size_t length);
140
void _assuan_log_sanitized_string (const char *string);
143
#endif /*ASSUAN_DEFS_H*/