aboutsummaryrefslogtreecommitdiffstats
path: root/gpgme/gpgme.h
blob: c32449c4a2974e04df4fcaefdb69edf2fc1ad105 (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/* gpgme.h -  GnuPG Made Easy
 *	Copyright (C) 2000 Werner Koch (dd9jn)
 *
 * This file is part of GPGME.
 *
 * GPGME 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.
 *
 * GPGME 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 GPGME_H
#define GPGME_H
#ifdef __cplusplus
extern "C" { 
#if 0 /* just to make Emacs auto-indent happy */
}
#endif
#endif

struct gpgme_context_s;
typedef struct gpgme_context_s *GpgmeCtx;

struct gpgme_data_s;
typedef struct gpgme_data_s *GpgmeData;

struct gpgme_recipient_set_s;
typedef struct gpgme_recipient_set_s *GpgmeRecipientSet;

struct gpgme_key_s;
typedef struct gpgme_key_s *GpgmeKey;


typedef enum {
    GPGME_EOF = -1,
    GPGME_No_Error = 0,
    GPGME_General_Error = 1,
    GPGME_Out_Of_Core = 2,
    GPGME_Invalid_Value = 3,
    GPGME_Busy = 4,
    GPGME_No_Request = 5,
    GPGME_Exec_Error = 6,
    GPGME_Too_Many_Procs = 7,
    GPGME_Pipe_Error = 8,
    GPGME_No_Recipients = 9,
    GPGME_No_Data = 10,
    GPGME_Conflict = 11,
    GPGME_Not_Implemented = 12,
    GPGME_Read_Error = 13,
    GPGME_Write_Error = 14,
    GPGME_Invalid_Type = 15,
    GPGME_Invalid_Mode = 16,
} GpgmeError;

typedef enum {
    GPGME_DATA_TYPE_NONE = 0,
    GPGME_DATA_TYPE_MEM  = 1,
    GPGME_DATA_TYPE_FD   = 2,
    GPGME_DATA_TYPE_FILE = 3
} GpgmeDataType;


/* Context management */
GpgmeError gpgme_new_context (GpgmeCtx *r_ctx);
void       gpgme_release_context ( GpgmeCtx c );
GpgmeCtx   gpgme_wait ( GpgmeCtx c, int hang );

/* Functions to handle recipients */
GpgmeError   gpgme_new_recipient_set (GpgmeRecipientSet *r_rset);
void         gpgme_release_recipient_set ( GpgmeRecipientSet rset);
GpgmeError   gpgme_add_recipient (GpgmeRecipientSet rset, const char *name);
unsigned int gpgme_count_recipients ( const GpgmeRecipientSet rset );

/* Functions to handle data sources */
GpgmeError gpgme_new_data ( GpgmeData *r_dh,
                                const char *buffer, size_t size, int copy );
void gpgme_release_data ( GpgmeData dh );
GpgmeDataType gpgme_query_data_type ( GpgmeData dh );
GpgmeError gpgme_rewind_data ( GpgmeData dh );
GpgmeError gpgme_read_data ( GpgmeData dh,
                             char *buffer, size_t length, size_t *nread );



/* Basic GnuPG functions */
GpgmeError gpgme_start_encrypt ( GpgmeCtx c, GpgmeRecipientSet recp,
                                 GpgmeData in, GpgmeData out );
GpgmeError gpgme_start_verify ( GpgmeCtx c,  GpgmeData sig, GpgmeData text );


/* Key management functions */
GpgmeError gpgme_keylist_start ( GpgmeCtx c,
                                 const char *pattern, int secret_only );
GpgmeError gpgme_keylist_next ( GpgmeCtx c, GpgmeKey *r_key );






/* Convenience functions for syncronous usage */
GpgmeError gpgme_encrypt ( GpgmeCtx c, GpgmeRecipientSet recp,
                           GpgmeData in, GpgmeData out );
GpgmeError gpgme_verify ( GpgmeCtx c, GpgmeData sig, GpgmeData text );


/* miscellaneous functions */
const char *gpgme_strerror (GpgmeError err);


#ifdef __cplusplus
}
#endif
#endif /* GPGME_H */