2 #include "gpg-interface.h"
6 int cmd__delete_gpgsig(int argc
, const char **argv
)
8 struct strbuf buf
= STRBUF_INIT
;
9 const char *pattern
= "gpgsig";
10 const char *bufptr
, *tail
, *eol
;
20 plen
= strlen(pattern
);
21 strbuf_read(&buf
, 0, 0);
23 if (!strcmp(pattern
, "trailer")) {
24 size_t payload_size
= parse_signed_buffer(buf
.buf
, buf
.len
);
25 fwrite(buf
.buf
, 1, payload_size
, stdout
);
31 tail
= bufptr
+ buf
.len
;
33 while (bufptr
< tail
) {
34 /* Find the end of the line */
35 eol
= memchr(bufptr
, '\n', tail
- bufptr
);
39 /* Drop continuation lines */
40 if (deleting
&& (bufptr
< eol
) && (bufptr
[0] == ' ')) {
46 /* Does the line match the prefix? */
47 if (((bufptr
+ plen
) < eol
) &&
48 !memcmp(bufptr
, pattern
, plen
) &&
49 (bufptr
[plen
] == ' ')) {
55 /* Print all other lines */
56 fwrite(bufptr
, 1, (eol
- bufptr
) + 1, stdout
);