1 |
werner |
36 |
/* w32gpgme.h - W32 specific utility code for GPGME. |
2 |
|
|
* Copyright (C) 2005 Timo Schulz |
3 |
|
|
* |
4 |
|
|
* This file is part of WinPT. |
5 |
|
|
* |
6 |
|
|
* WinPT 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 |
|
|
* WinPT 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 WinPT; if not, write to the Free Software Foundation, |
18 |
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
19 |
|
|
*/ |
20 |
|
|
|
21 |
|
|
#ifndef W32_GPGME_H |
22 |
|
|
#define W32_GPGME_H |
23 |
|
|
|
24 |
|
|
#ifdef __cplusplus |
25 |
|
|
extern "C" { |
26 |
|
|
#endif |
27 |
|
|
|
28 |
|
|
#ifdef WINPT_MODERN_BUILD |
29 |
|
|
#include <gpgme.h> |
30 |
|
|
#else |
31 |
|
|
#include "c:/oss/w32root/include/gpgme.h" |
32 |
|
|
#endif |
33 |
|
|
|
34 |
|
|
struct keycache_s { |
35 |
|
|
struct keycache_s * next; |
36 |
|
|
int flags; |
37 |
|
|
gpgme_key_t key; /* actual key context. */ |
38 |
|
|
struct keycache_s *pubpart; /* corresponding public key. */ |
39 |
|
|
struct { |
40 |
|
|
unsigned int is_protected:1; /* key is protected. */ |
41 |
|
|
unsigned int divert_to_card:1; /* secret key on card. */ |
42 |
|
|
unsigned int has_desig_rev:1; /* has desig. revokers. */ |
43 |
|
|
} gloflags; |
44 |
|
|
struct { |
45 |
|
|
unsigned int used:1; |
46 |
|
|
unsigned char *d; /* attribute (JPG) data. */ |
47 |
|
|
unsigned int len; /* attribute data length. */ |
48 |
|
|
} attrib; |
49 |
|
|
unsigned char *sym_prefs;/* symmetric cipher preferences. */ |
50 |
|
|
char *card_type; /* if != NULL key stored on smart card. */ |
51 |
|
|
}; |
52 |
|
|
|
53 |
|
|
struct gpgme_keycache_s { |
54 |
|
|
struct keycache_s *item; |
55 |
|
|
struct keycache_s *tmp; |
56 |
|
|
int secret; |
57 |
|
|
int pos; |
58 |
|
|
void (*cb) (void *, const char *, int, int, int); |
59 |
|
|
void *cb_value; |
60 |
|
|
int cb_value2; |
61 |
|
|
}; |
62 |
|
|
typedef struct gpgme_keycache_s *gpgme_keycache_t; |
63 |
|
|
typedef struct gpgme_keycache_s *gpg_keycache_t; |
64 |
|
|
|
65 |
|
|
|
66 |
werner |
37 |
typedef enum pgp_type_t gpg_pgptype_t; |
67 |
werner |
36 |
|
68 |
werner |
37 |
|
69 |
werner |
36 |
gpgme_error_t gpg_data_new_from_clipboard (gpgme_data_t *r_dh, int wraplen); |
70 |
|
|
void gpg_data_release_and_set_clipboard (gpgme_data_t dh, int chg_ver); |
71 |
|
|
size_t gpg_data_readline (gpgme_data_t dh, char *line, size_t nbytes); |
72 |
|
|
|
73 |
|
|
gpgme_error_t gpg_data_release_and_set_file (gpgme_data_t dh, const char *fname); |
74 |
|
|
gpgme_error_t gpg_data_mail_quote (gpgme_data_t *r_dh); |
75 |
|
|
gpgme_error_t gpg_data_extract_plaintext (gpgme_data_t sig, gpgme_data_t *r_plain); |
76 |
|
|
|
77 |
|
|
/* Key caching */ |
78 |
|
|
gpgme_error_t gpg_keycache_new (gpgme_keycache_t * r_ctx); |
79 |
|
|
void gpg_keycache_release (gpgme_keycache_t ctx); |
80 |
|
|
void gpg_keycache_set_cb (gpgme_keycache_t ctx, |
81 |
|
|
void (*cb)(void *, const char *, int, int, int), |
82 |
|
|
void * cb_value1, int cb_value2); |
83 |
|
|
void gpg_keycache_rewind (gpgme_keycache_t ctx); |
84 |
|
|
int gpg_keycache_get_size (gpgme_keycache_t ctx); |
85 |
|
|
gpgme_error_t gpg_keycache_add_key (gpgme_keycache_t ctx, gpgme_key_t key, |
86 |
|
|
void **opaque); |
87 |
|
|
gpgme_error_t gpg_keycache_update_key (gpgme_keycache_t ctx, int is_sec, |
88 |
|
|
void *opaque, const char *keyid); |
89 |
|
|
gpgme_error_t gpg_keycache_find_key (gpgme_keycache_t ctx, const char * pattern, |
90 |
|
|
int flags, gpgme_key_t * r_key); |
91 |
|
|
gpgme_error_t gpg_keycache_find_key2 (gpgme_keycache_t ctx, const char *pattern, int flags, |
92 |
|
|
gpgme_key_t *r_key, struct keycache_s **r_item); |
93 |
|
|
gpgme_error_t gpg_keycache_delete_key (gpgme_keycache_t ctx, |
94 |
|
|
const char * pattern); |
95 |
|
|
gpgme_error_t gpg_keycache_init (gpgme_keycache_t ctx, const char * pattern, |
96 |
|
|
int secret); |
97 |
|
|
gpgme_error_t gpg_keycache_next_key (gpgme_keycache_t ctx, int flags, |
98 |
|
|
gpgme_key_t * r_key); |
99 |
|
|
gpgme_error_t gpg_keycache_prepare (gpgme_keycache_t ctx, |
100 |
|
|
const char *pubring, const char * secring); |
101 |
|
|
gpgme_error_t gpg_keycache_prepare_single (gpgme_keycache_t ctx, |
102 |
|
|
const char *keyid, |
103 |
|
|
const char *pubr, |
104 |
|
|
const char *secr); |
105 |
|
|
gpgme_error_t gpg_keycache_sync (gpgme_keycache_t pub, gpgme_keycache_t sec); |
106 |
|
|
|
107 |
|
|
/* XXX */ |
108 |
|
|
gpgme_error_t |
109 |
|
|
_gpg_keycache_find_key2 (gpgme_keycache_t ctx, const char *pattern, int flags, |
110 |
|
|
gpgme_key_t *r_key, struct keycache_s **r_item); |
111 |
|
|
|
112 |
|
|
/* Clipboard interface */ |
113 |
|
|
gpgme_error_t gpg_clip_istext_avail (int *r_rc); |
114 |
|
|
gpgme_error_t gpg_clip_is_secured (gpg_pgptype_t *r_type, int *r_rc); |
115 |
|
|
gpgme_error_t gpg_clip_get_pgptype (gpg_pgptype_t *r_type); |
116 |
|
|
gpgme_error_t gpg_clip_parse_pgpid (const char *data, gpg_pgptype_t *r_type); |
117 |
|
|
gpgme_error_t gpg_clip_do_check (int *r_rc); |
118 |
|
|
|
119 |
|
|
#ifdef __cplusplus |
120 |
|
|
} |
121 |
|
|
#endif |
122 |
|
|
|
123 |
|
|
/* helpers */ |
124 |
|
|
char* strsep (char **stringp, const char *delim); |
125 |
|
|
const char *stristr (const char *buf, const char *sub); |
126 |
|
|
|
127 |
|
|
#endif /*W32_GPGME_H*/ |