29 |
|
|
30 |
#include "wptUtil.h" |
#include "wptUtil.h" |
31 |
#include "wptGPG.h" |
#include "wptGPG.h" |
32 |
|
#include "wptTypes.h" |
33 |
|
|
34 |
|
/* Default buffer size */ |
35 |
|
#define BUFSIZE 128 |
36 |
|
|
37 |
|
|
38 |
/* Implement a word based line break. @inp is the input buffer |
/* Implement a word based line break. @inp is the input buffer |
133 |
gpg_data_mail_quote (gpgme_data_t *r_dh) |
gpg_data_mail_quote (gpgme_data_t *r_dh) |
134 |
{ |
{ |
135 |
gpgme_data_t dh; |
gpgme_data_t dh; |
136 |
char buf[128]; |
char buf[BUFSIZE+1]; |
137 |
|
|
138 |
if (!*r_dh) |
if (!*r_dh) |
139 |
return gpg_error (GPG_ERR_INV_ARG); |
return gpg_error (GPG_ERR_INV_ARG); |
140 |
gpgme_data_new (&dh); |
gpgme_data_new (&dh); |
141 |
while (gpg_data_readline (*r_dh, buf, sizeof (buf)-1)) { |
while (gpg_data_readline (*r_dh, buf, DIM (buf)-1)) { |
142 |
gpgme_data_write (dh, "> ", 2); |
gpgme_data_write (dh, "> ", 2); |
143 |
gpgme_data_write (dh, buf, strlen (buf)); |
gpgme_data_write (dh, buf, strlen (buf)); |
144 |
} |
} |
177 |
{ |
{ |
178 |
gpgme_data_t plain; |
gpgme_data_t plain; |
179 |
gpgme_error_t err; |
gpgme_error_t err; |
180 |
char line[128+32]; |
char line[BUFSIZE+32]; |
181 |
int pos = 0; |
int pos = 0; |
182 |
|
|
183 |
if (r_plain) |
if (r_plain) |
186 |
if (err) |
if (err) |
187 |
return err; |
return err; |
188 |
|
|
189 |
while (gpg_data_readline (sig, line, 128) > 0) { |
while (gpg_data_readline (sig, line, BUFSIZE) > 0) { |
190 |
if (!strncmp (line, "-----BEGIN PGP SIGNED MESSAGE", 29) || |
if (!strncmp (line, "-----BEGIN PGP SIGNED MESSAGE", 29) || |
191 |
is_armor_header (line)) |
is_armor_header (line)) |
192 |
continue; |
continue; |
195 |
} |
} |
196 |
|
|
197 |
/* We just support 1 nesting level. */ |
/* We just support 1 nesting level. */ |
198 |
while (gpg_data_readline (sig, line, 128) > 0 ) { |
while (gpg_data_readline (sig, line, BUFSIZE) > 0 ) { |
199 |
if (!strncmp (line, "-----BEGIN PGP SIGNATURE", 24)) |
if (!strncmp (line, "-----BEGIN PGP SIGNATURE", 24)) |
200 |
break; /* end of plaintext */ |
break; /* end of plaintext */ |
201 |
if (!strncmp (line, "- -", 3)) |
if (!strncmp (line, "- -", 3)) |