30 |
#include "wptCrypto.h" |
#include "wptCrypto.h" |
31 |
#include "wptVersion.h" |
#include "wptVersion.h" |
32 |
#include "wptGPG.h" |
#include "wptGPG.h" |
33 |
|
#include "wptTypes.h" |
34 |
|
|
35 |
|
/* Default buffer size. */ |
36 |
|
#define BUFSIZE 192 |
37 |
|
|
38 |
gpgme_error_t gpg_data_wrap_lines (gpgme_data_t *r_dh, size_t wraplen); |
gpgme_error_t gpg_data_wrap_lines (gpgme_data_t *r_dh, size_t wraplen); |
39 |
|
|
117 |
|
|
118 |
if (!r_val) |
if (!r_val) |
119 |
return gpg_error (GPG_ERR_INV_ARG); |
return gpg_error (GPG_ERR_INV_ARG); |
120 |
if( OpenClipboard (NULL) == FALSE ) |
if (OpenClipboard (NULL) == FALSE) |
121 |
return gpg_error (GPG_ERR_INTERNAL); |
return gpg_error (GPG_ERR_INTERNAL); |
122 |
clipmem = GetClipboardData( CF_TEXT ); |
clipmem = GetClipboardData (CF_TEXT); |
123 |
if( !clipmem ) { |
if (!clipmem) { |
124 |
*r_val = 0; |
*r_val = 0; |
125 |
goto leave; |
goto leave; |
126 |
} |
} |
127 |
clipdata = (char *) GlobalLock( clipmem ); |
clipdata = (char *) GlobalLock (clipmem); |
128 |
if (!clipdata) { |
if (!clipdata) { |
129 |
*r_val = 0; |
*r_val = 0; |
130 |
goto leave; |
goto leave; |
141 |
} |
} |
142 |
|
|
143 |
|
|
144 |
|
/* Return the OpenPGP data format of the clipboard in @r_type. |
145 |
|
Return 0 on success. */ |
146 |
gpgme_error_t |
gpgme_error_t |
147 |
gpg_clip_get_pgptype (int *r_type) |
gpg_clip_get_pgptype (int *r_type) |
148 |
{ |
{ |
267 |
static gpgme_error_t |
static gpgme_error_t |
268 |
gpg_data_change_version (gpgme_data_t *r_dh) |
gpg_data_change_version (gpgme_data_t *r_dh) |
269 |
{ |
{ |
270 |
gpgme_error_t err = 0; |
gpgme_error_t err; |
271 |
gpgme_data_t mdh; |
gpgme_data_t mdh; |
272 |
char line[128+32]; |
const char *s; |
273 |
|
char line[BUFSIZE+32]; |
274 |
int n; |
int n; |
275 |
|
|
276 |
if (!r_dh) |
if (!r_dh) |
280 |
if (err) |
if (err) |
281 |
return err; |
return err; |
282 |
|
|
283 |
|
/* Pattern we search for. */ |
284 |
|
s = "Version: GnuPG"; |
285 |
gpgme_data_rewind (*r_dh); |
gpgme_data_rewind (*r_dh); |
286 |
while ((n=gpg_data_readline (*r_dh, line, 128)) > 0) { |
while ((n=gpg_data_readline (*r_dh, line, BUFSIZE-1)) > 0) { |
287 |
if (strlen (line) > 14 && |
if (strlen (line) > strlen (s) && |
288 |
!strncmp (line, "Version: GnuPG", 14) && |
!strncmp (line, s, strlen (s)) && |
289 |
!strstr (line, "WinPT "PGM_VERSION)) { |
!stristr (line, "WinPT "PGM_VERSION)) { |
290 |
line[strlen (line) - 2] = '\0'; |
/* Do not assume a \r\n sequence. */ |
291 |
strcat (line, " - " ); |
if (strstr (line, "\r\n")) |
292 |
strcat (line, "WinPT "PGM_VERSION); |
line[strlen (line) - 2] = '\0'; |
293 |
strcat (line, "\r\n"); |
if (strstr (line, "\n")) |
294 |
|
line[strlen (line)-1] = '\0'; |
295 |
|
strcat (line, " - WinPT "PGM_VERSION"\r\n"); |
296 |
} |
} |
297 |
gpgme_data_write (mdh, line, strlen (line)); |
gpgme_data_write (mdh, line, strlen (line)); |
298 |
} |
} |
324 |
clip_text = gpgme_data_release_and_get_mem (in, &n); |
clip_text = gpgme_data_release_and_get_mem (in, &n); |
325 |
if (clip_text && *clip_text) { |
if (clip_text && *clip_text) { |
326 |
set_w32_clip_text (clip_text, n); |
set_w32_clip_text (clip_text, n); |
327 |
memset (clip_text, 0xFF, n); |
wipememory (clip_text, n); |
328 |
gpgme_free (clip_text); |
gpgme_free (clip_text); |
329 |
} |
} |
330 |
} |
} |