|
|
@ -23,9 +23,12 @@ |
|
|
|
#include <stdio.h> |
|
|
|
#include <stdlib.h> |
|
|
|
#include <getopt.h> |
|
|
|
#include <locale.h> |
|
|
|
#include <ctype.h> |
|
|
|
#include <time.h> |
|
|
|
|
|
|
|
#include <gpgme.h> |
|
|
|
|
|
|
|
#include <sbuffer.h> |
|
|
|
|
|
|
|
|
|
|
@ -43,6 +46,11 @@ Read a mail from standard input and send it.\n"); |
|
|
|
-v, --version Display the version message.\n\ |
|
|
|
"); |
|
|
|
|
|
|
|
puts("\ |
|
|
|
Cryptography options:\n\ |
|
|
|
-s, --sign Sign the message.\n\ |
|
|
|
"); |
|
|
|
|
|
|
|
printf("Report bugs to <%s>.\n", PACKAGE_BUGREPORT); |
|
|
|
|
|
|
|
exit(status); |
|
|
@ -167,6 +175,27 @@ process_text_body(FILE *in, FILE *out) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Signing stuff. */ |
|
|
|
|
|
|
|
gpgme_ctx_t |
|
|
|
initialize_gpgme(void) |
|
|
|
{ |
|
|
|
gpgme_ctx_t ctx; |
|
|
|
gpg_error_t gerr; |
|
|
|
|
|
|
|
gpgme_check_version(NULL); |
|
|
|
gpgme_set_locale(NULL, LC_CTYPE, setlocale(LC_CTYPE, NULL)); |
|
|
|
gpgme_set_locale(NULL, LC_MESSAGES, setlocale(LC_MESSAGES, NULL)); |
|
|
|
|
|
|
|
if ( (gerr = gpgme_new(&ctx)) != GPG_ERR_NO_ERROR ) |
|
|
|
errx(EXIT_FAILURE, "cannot initialize GPGME: %s", |
|
|
|
gpgme_strerror(gerr)); |
|
|
|
|
|
|
|
return ctx; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Main function. */ |
|
|
|
|
|
|
|
int |
|
|
@ -174,17 +203,22 @@ main(int argc, char *argv[]) |
|
|
|
{ |
|
|
|
char c; |
|
|
|
string_buffer_t *headers; |
|
|
|
gpgme_ctx_t sign_ctx; |
|
|
|
|
|
|
|
struct option options[] = { |
|
|
|
{ "help", 0, NULL, 'h' }, |
|
|
|
{ "version", 0, NULL, 'v' }, |
|
|
|
{ "sign", 0, NULL, 's' }, |
|
|
|
{ NULL, 0, NULL, 0 } |
|
|
|
}; |
|
|
|
|
|
|
|
setprogname(argv[0]); |
|
|
|
setlocale(LC_ALL, ""); |
|
|
|
|
|
|
|
headers = sb_new(0); |
|
|
|
sign_ctx = NULL; |
|
|
|
|
|
|
|
while ( (c = getopt_long(argc, argv, "hv", |
|
|
|
while ( (c = getopt_long(argc, argv, "hvs", |
|
|
|
options, NULL)) != -1 ) { |
|
|
|
switch ( c ) { |
|
|
|
case 'h': |
|
|
@ -198,6 +232,10 @@ main(int argc, char *argv[]) |
|
|
|
case 'v': |
|
|
|
info(); |
|
|
|
break; |
|
|
|
|
|
|
|
case 's': |
|
|
|
sign_ctx = initialize_gpgme(); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -214,5 +252,9 @@ main(int argc, char *argv[]) |
|
|
|
/* Write encoded body. */ |
|
|
|
process_text_body(stdin, stdout); |
|
|
|
|
|
|
|
/* Clean-up. */ |
|
|
|
if ( sign_ctx ) |
|
|
|
gpgme_release(sign_ctx); |
|
|
|
|
|
|
|
return EXIT_SUCCESS; |
|
|
|
} |