1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Fixed tabs

This commit is contained in:
James Booth 2015-03-23 23:41:09 +00:00
parent 475dfebd97
commit 73e1654f28

View File

@ -116,62 +116,62 @@ p_gpg_free_key(ProfPGPKey *key)
char* char*
p_gpg_sign_str(const char * const str, const char * const fp) p_gpg_sign_str(const char * const str, const char * const fp)
{ {
gpgme_ctx_t ctx; gpgme_ctx_t ctx;
gpgme_error_t error = gpgme_new(&ctx); gpgme_error_t error = gpgme_new(&ctx);
if (error) { if (error) {
log_error("GPG: Failed to create gpgme context. %s %s", gpgme_strsource(error), gpgme_strerror(error)); log_error("GPG: Failed to create gpgme context. %s %s", gpgme_strsource(error), gpgme_strerror(error));
return NULL; return NULL;
} }
gpgme_key_t key = NULL; gpgme_key_t key = NULL;
error = gpgme_get_key(ctx, fp, &key, 1); error = gpgme_get_key(ctx, fp, &key, 1);
if (error || key == NULL) { if (error || key == NULL) {
log_error("GPG: Failed to get key. %s %s", gpgme_strsource(error), gpgme_strerror(error)); log_error("GPG: Failed to get key. %s %s", gpgme_strsource(error), gpgme_strerror(error));
gpgme_release (ctx); gpgme_release (ctx);
return NULL; return NULL;
} }
gpgme_signers_clear(ctx); gpgme_signers_clear(ctx);
error = gpgme_signers_add(ctx, key); error = gpgme_signers_add(ctx, key);
if (error) { if (error) {
log_error("GPG: Failed to load signer. %s %s", gpgme_strsource(error), gpgme_strerror(error)); log_error("GPG: Failed to load signer. %s %s", gpgme_strsource(error), gpgme_strerror(error));
gpgme_release(ctx); gpgme_release(ctx);
return NULL; return NULL;
} }
gpgme_data_t str_data; gpgme_data_t str_data;
gpgme_data_t signed_data; gpgme_data_t signed_data;
char *str_or_empty = NULL; char *str_or_empty = NULL;
if (str) { if (str) {
str_or_empty = strdup(str); str_or_empty = strdup(str);
} else { } else {
str_or_empty = strdup(""); str_or_empty = strdup("");
} }
gpgme_data_new_from_mem(&str_data, str_or_empty, strlen(str_or_empty), 1); gpgme_data_new_from_mem(&str_data, str_or_empty, strlen(str_or_empty), 1);
gpgme_data_new(&signed_data); gpgme_data_new(&signed_data);
gpgme_set_armor(ctx,1); gpgme_set_armor(ctx,1);
error = gpgme_op_sign(ctx,str_data,signed_data,GPGME_SIG_MODE_DETACH); error = gpgme_op_sign(ctx,str_data,signed_data,GPGME_SIG_MODE_DETACH);
if (error) { if (error) {
log_error("GPG: Failed to sign string. %s %s", gpgme_strsource(error), gpgme_strerror(error)); log_error("GPG: Failed to sign string. %s %s", gpgme_strsource(error), gpgme_strerror(error));
gpgme_release(ctx); gpgme_release(ctx);
return NULL; return NULL;
} }
char *result = NULL; char *result = NULL;
gpgme_data_release(str_data); gpgme_data_release(str_data);
size_t len = 0; size_t len = 0;
char *signed_str = gpgme_data_release_and_get_mem(signed_data, &len); char *signed_str = gpgme_data_release_and_get_mem(signed_data, &len);
if (signed_str != NULL) { if (signed_str != NULL) {
signed_str[len] = 0; signed_str[len] = 0;
result = _remove_header_footer(signed_str); result = _remove_header_footer(signed_str);
} }
gpgme_free(signed_str); gpgme_free(signed_str);
gpgme_release(ctx); gpgme_release(ctx);
free(str_or_empty); free(str_or_empty);
return result; return result;
} }
static char* static char*