Debian Codegraph @

assuan/assuan-defs.h

raw symbols SCIP
1 /* assuan-defs.c - Internal definitions to Assuan
2 * Copyright (C) 2001 Free Software Foundation, Inc.
3 *
4 * This file is part of GnuPG.
5 *
6 * GnuPG is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * GnuPG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #ifndef ASSUAN_DEFS_H
22 #define ASSUAN_DEFS_H
23
24 #include <sys/types.h>
25 #include "assuan.h"
26
27 #define LINELENGTH ASSUAN_LINELENGTH
28
29 struct cmdtbl_s {
30 const char *name;
31 int cmd_id;
32 int (*handler)(ASSUAN_CONTEXT, char *line);
33 };
34
35 struct assuan_context_s {
36 AssuanError err_no;
37 const char *err_str;
38 int os_errno; /* last system error number used with certain error codes*/
39
40 int confidential;
41 int is_server; /* set if this is context belongs to a server */
42 int in_inquire;
43 char *hello_line;
44 char *okay_line; /* see assan_set_okay_line() */
45
46 void *user_pointer; /* for assuan_[gs]et_pointer () */
47
48 FILE *log_fp;
49
50 struct {
51 int fd;
52 int eof;
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 */
57 struct {
58 char line[LINELENGTH];
59 int linelen ;
60 int pending; /* i.e. at least one line is available in the attic */
61 } attic;
62 } inbound;
63
64 struct {
65 int fd;
66 struct {
67 FILE *fp;
68 char line[LINELENGTH];
69 int linelen;
70 int error;
71 } data;
72 } outbound;
73
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
80 pid_t client_pid; /* for a socket server the PID of the client or -1
81 if not available */
82
83 void (*deinit_handler)(ASSUAN_CONTEXT);
84 int (*accept_handler)(ASSUAN_CONTEXT);
85 int (*finish_handler)(ASSUAN_CONTEXT);
86
87 struct cmdtbl_s *cmdtbl;
88 size_t cmdtbl_used; /* used entries */
89 size_t cmdtbl_size; /* allocated size of table */
90
91 void (*bye_notify_fnc)(ASSUAN_CONTEXT);
92 void (*reset_notify_fnc)(ASSUAN_CONTEXT);
93 void (*cancel_notify_fnc)(ASSUAN_CONTEXT);
94 int (*option_handler_fnc)(ASSUAN_CONTEXT,const char*, const char*);
95 void (*input_notify_fnc)(ASSUAN_CONTEXT, const char *);
96 void (*output_notify_fnc)(ASSUAN_CONTEXT, const char *);
97
98 int input_fd; /* set by INPUT command */
99 int output_fd; /* set by OUTPUT command */
100
101 };
102
103
104 /*-- assuan-pipe-server.c --*/
105 int _assuan_new_context (ASSUAN_CONTEXT *r_ctx);
106 void _assuan_release_context (ASSUAN_CONTEXT ctx);
107
108
109 /*-- assuan-handler.c --*/
110 int _assuan_register_std_commands (ASSUAN_CONTEXT ctx);
111
112 /*-- assuan-buffer.c --*/
113 int _assuan_read_line (ASSUAN_CONTEXT ctx);
114 int _assuan_cookie_write_data (void *cookie, const char *buffer, size_t size);
115 int _assuan_cookie_write_flush (void *cookie);
116
117 /*-- assuan-client.c --*/
118 AssuanError _assuan_read_from_server (ASSUAN_CONTEXT ctx, int *okay, int *off);
119
120
121 /*-- assuan-util.c --*/
122 void *_assuan_malloc (size_t n);
123 void *_assuan_calloc (size_t n, size_t m);
124 void *_assuan_realloc (void *p, size_t n);
125 void _assuan_free (void *p);
126
127 #define xtrymalloc(a) _assuan_malloc ((a))
128 #define xtrycalloc(a,b) _assuan_calloc ((a),(b))
129 #define xtryrealloc(a,b) _assuan_realloc((a),(b))
130 #define xfree(a) _assuan_free ((a))
131
132 #define set_error(c,e,t) assuan_set_error ((c), ASSUAN_ ## e, (t))
133
134 void _assuan_log_print_buffer (FILE *fp, const void *buffer, size_t length);
135 void _assuan_log_sanitized_string (const char *string);
136
137
138 #endif /*ASSUAN_DEFS_H*/
139