summaryrefslogtreecommitdiffstats
path: root/gpglib/mimegpgfork.h
blob: cebee6019e57a74261682320b75722d7729871da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef mimegpgfork_h
#define mimegpgfork_h

/*
** Copyright 2001 Double Precision, Inc.  See COPYING for
** distribution information.
*/


#include "config.h"
#include <stdio.h>
#include <signal.h>
#include <sys/types.h>

#ifdef  __cplusplus
extern "C" {
#endif

struct gpgmime_forkinfo {
	int togpg_fd;
	int fromgpg_fd;
	int fromgpg_errfd;

	char gpg_writebuf[BUFSIZ];
	char gpg_errbuf[1024];

	unsigned gpg_writecnt;
	unsigned gpg_errcnt;

	int gpg_errflag;
	pid_t gpg_pid;

	struct sigaction old_pipe_sig;

	int (*gpg_readhandler)(const char *, size_t, void *);
	void *gpg_voidarg;
} ;

int libmail_gpgmime_forksignencrypt(const char *,	/* gpgdir */
				    const char *,	/* passphrase fd */
				    int,	/* Flags: */

#define GPG_SE_SIGN	1
#define	GPG_SE_ENCRYPT	2

				    int, char **,	/* argc/argv */

				    int (*)(const char *, size_t, void *),
				    /* Encrypted output */
				    void *, /* 3rd arg to encrypted output */

				    struct gpgmime_forkinfo *
				    /* Allocated struct */
				    );

int libmail_gpgmime_forkchecksign(const char *,	/* gpgdir */
				  const char *,	/* passphrase fd */
				  const char *,	/* content filename */
				  const char *,	/* signature filename */
				  int, char **,	/* argc/argv */
				  struct gpgmime_forkinfo *);
	/* Allocated struct */

int libmail_gpgmime_forkdecrypt(const char *,	/* gpgdir */
				const char *,	/* passphrase fd */
				int, char **,	/* argc/argv */
				int (*)(const char *, size_t, void *),
				/* Output callback function */
				void *,	/* 3rd arg to callback function */

				struct gpgmime_forkinfo *);
	/* Allocated struct */

void libmail_gpgmime_write(struct gpgmime_forkinfo *, const char *, size_t);
int libmail_gpgmime_finish(struct gpgmime_forkinfo *);

const char *libmail_gpgmime_getoutput(struct gpgmime_forkinfo *);
const char *libmail_gpgmime_getcharset(struct gpgmime_forkinfo *);

#ifdef  __cplusplus
} ;
#endif

#endif