2001-11-06 16:42:37 +01:00
|
|
|
/* assuan-defs.c - Internal definitions to Assuan
|
|
|
|
* Copyright (C) 2001 Free Software Foundation, Inc.
|
|
|
|
*
|
|
|
|
* This file is part of GnuPG.
|
|
|
|
*
|
|
|
|
* GnuPG is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* GnuPG is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ASSUAN_DEFS_H
|
|
|
|
#define ASSUAN_DEFS_H
|
|
|
|
|
2001-11-19 13:09:50 +01:00
|
|
|
#include <sys/types.h>
|
2001-11-06 16:42:37 +01:00
|
|
|
#include "assuan.h"
|
|
|
|
|
2001-12-14 00:20:02 +01:00
|
|
|
#define LINELENGTH ASSUAN_LINELENGTH
|
2001-11-07 18:43:05 +01:00
|
|
|
|
|
|
|
struct cmdtbl_s {
|
|
|
|
const char *name;
|
|
|
|
int cmd_id;
|
|
|
|
int (*handler)(ASSUAN_CONTEXT, char *line);
|
|
|
|
};
|
2001-11-06 16:42:37 +01:00
|
|
|
|
|
|
|
struct assuan_context_s {
|
|
|
|
AssuanError err_no;
|
|
|
|
const char *err_str;
|
2002-01-19 19:20:15 +01:00
|
|
|
int os_errno; /* last system error number used with certain error codes*/
|
2001-12-06 00:45:01 +01:00
|
|
|
|
2002-01-19 19:20:15 +01:00
|
|
|
int confidential;
|
2001-12-06 00:45:01 +01:00
|
|
|
int is_server; /* set if this is context belongs to a server */
|
|
|
|
int in_inquire;
|
2001-12-12 10:17:23 +01:00
|
|
|
char *hello_line;
|
2002-01-10 20:46:04 +01:00
|
|
|
char *okay_line; /* see assan_set_okay_line() */
|
2001-11-19 13:40:30 +01:00
|
|
|
|
|
|
|
void *user_pointer; /* for assuan_[gs]et_pointer () */
|
2001-11-06 16:42:37 +01:00
|
|
|
|
2002-01-19 19:20:15 +01:00
|
|
|
FILE *log_fp;
|
|
|
|
|
2001-11-06 16:42:37 +01:00
|
|
|
struct {
|
|
|
|
int fd;
|
2001-11-07 18:43:05 +01:00
|
|
|
int eof;
|
|
|
|
char line[LINELENGTH];
|
|
|
|
int linelen; /* w/o CR, LF - might not be the same as
|
|
|
|
strlen(line) due to embedded nuls. However a nul
|
|
|
|
is always written at this pos */
|
2001-11-24 22:10:22 +01:00
|
|
|
struct {
|
|
|
|
char line[LINELENGTH];
|
|
|
|
int linelen ;
|
2001-12-12 10:17:23 +01:00
|
|
|
int pending; /* i.e. at least one line is available in the attic */
|
2001-11-24 22:10:22 +01:00
|
|
|
} attic;
|
2001-11-06 16:42:37 +01:00
|
|
|
} inbound;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
int fd;
|
2001-11-19 17:15:43 +01:00
|
|
|
struct {
|
|
|
|
FILE *fp;
|
|
|
|
char line[LINELENGTH];
|
|
|
|
int linelen;
|
|
|
|
int error;
|
|
|
|
} data;
|
2001-11-06 16:42:37 +01:00
|
|
|
} outbound;
|
|
|
|
|
2001-11-07 18:43:05 +01:00
|
|
|
int pipe_mode; /* We are in pipe mode, i.e. we can handle just one
|
|
|
|
connection and must terminate then */
|
2002-01-21 13:03:14 +01:00
|
|
|
pid_t pid; /* In pipe mode, the pid of the child server process.
|
|
|
|
In socket mode, the pid of the server */
|
2002-01-19 19:20:15 +01:00
|
|
|
int listen_fd; /* The fd we are listening on (used by socket servers) */
|
2002-05-23 11:07:12 +02:00
|
|
|
int connected_fd; /* helper */
|
2002-01-19 19:20:15 +01:00
|
|
|
|
2002-02-18 21:45:52 +01:00
|
|
|
pid_t client_pid; /* for a socket server the PID of the client or -1
|
|
|
|
if not available */
|
|
|
|
|
2002-01-19 19:20:15 +01:00
|
|
|
void (*deinit_handler)(ASSUAN_CONTEXT);
|
|
|
|
int (*accept_handler)(ASSUAN_CONTEXT);
|
|
|
|
int (*finish_handler)(ASSUAN_CONTEXT);
|
2001-11-07 18:43:05 +01:00
|
|
|
|
|
|
|
struct cmdtbl_s *cmdtbl;
|
|
|
|
size_t cmdtbl_used; /* used entries */
|
|
|
|
size_t cmdtbl_size; /* allocated size of table */
|
|
|
|
|
2001-11-25 15:53:39 +01:00
|
|
|
void (*bye_notify_fnc)(ASSUAN_CONTEXT);
|
|
|
|
void (*reset_notify_fnc)(ASSUAN_CONTEXT);
|
2001-11-27 18:39:09 +01:00
|
|
|
void (*cancel_notify_fnc)(ASSUAN_CONTEXT);
|
2002-01-20 17:49:34 +01:00
|
|
|
int (*option_handler_fnc)(ASSUAN_CONTEXT,const char*, const char*);
|
2001-11-27 18:39:09 +01:00
|
|
|
void (*input_notify_fnc)(ASSUAN_CONTEXT, const char *);
|
|
|
|
void (*output_notify_fnc)(ASSUAN_CONTEXT, const char *);
|
2001-11-25 15:53:39 +01:00
|
|
|
|
2001-11-06 16:42:37 +01:00
|
|
|
int input_fd; /* set by INPUT command */
|
|
|
|
int output_fd; /* set by OUTPUT command */
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-05-23 11:07:12 +02:00
|
|
|
|
2002-01-21 13:03:14 +01:00
|
|
|
/*-- assuan-pipe-server.c --*/
|
|
|
|
int _assuan_new_context (ASSUAN_CONTEXT *r_ctx);
|
|
|
|
void _assuan_release_context (ASSUAN_CONTEXT ctx);
|
|
|
|
|
|
|
|
|
2001-11-06 16:42:37 +01:00
|
|
|
/*-- assuan-handler.c --*/
|
|
|
|
int _assuan_register_std_commands (ASSUAN_CONTEXT ctx);
|
|
|
|
|
2001-11-07 18:43:05 +01:00
|
|
|
/*-- assuan-buffer.c --*/
|
|
|
|
int _assuan_read_line (ASSUAN_CONTEXT ctx);
|
2001-11-19 17:15:43 +01:00
|
|
|
int _assuan_cookie_write_data (void *cookie, const char *buffer, size_t size);
|
|
|
|
int _assuan_cookie_write_flush (void *cookie);
|
|
|
|
|
2001-12-12 10:17:23 +01:00
|
|
|
/*-- assuan-client.c --*/
|
|
|
|
AssuanError _assuan_read_from_server (ASSUAN_CONTEXT ctx, int *okay, int *off);
|
2001-11-07 18:43:05 +01:00
|
|
|
|
2001-11-06 16:42:37 +01:00
|
|
|
|
|
|
|
/*-- assuan-util.c --*/
|
2002-05-23 11:07:12 +02:00
|
|
|
extern ssize_t (*_assuan_read_wrapper)(int,void*,size_t);
|
|
|
|
extern ssize_t (*_assuan_write_wrapper)(int,const void*,size_t);
|
|
|
|
|
2001-11-06 16:42:37 +01:00
|
|
|
void *_assuan_malloc (size_t n);
|
|
|
|
void *_assuan_calloc (size_t n, size_t m);
|
|
|
|
void *_assuan_realloc (void *p, size_t n);
|
|
|
|
void _assuan_free (void *p);
|
|
|
|
|
|
|
|
#define xtrymalloc(a) _assuan_malloc ((a))
|
|
|
|
#define xtrycalloc(a,b) _assuan_calloc ((a),(b))
|
|
|
|
#define xtryrealloc(a,b) _assuan_realloc((a),(b))
|
|
|
|
#define xfree(a) _assuan_free ((a))
|
|
|
|
|
2001-11-07 18:43:05 +01:00
|
|
|
#define set_error(c,e,t) assuan_set_error ((c), ASSUAN_ ## e, (t))
|
2001-11-06 16:42:37 +01:00
|
|
|
|
2002-01-19 19:20:15 +01:00
|
|
|
void _assuan_log_print_buffer (FILE *fp, const void *buffer, size_t length);
|
2002-01-21 13:03:14 +01:00
|
|
|
void _assuan_log_sanitized_string (const char *string);
|
2002-01-19 19:20:15 +01:00
|
|
|
|
2001-11-06 16:42:37 +01:00
|
|
|
|
|
|
|
#endif /*ASSUAN_DEFS_H*/
|
|
|
|
|