From f80bee27e3c3fc9085427945f97a2f7756500ea9 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Fri, 13 Apr 2018 15:18:31 -0600 Subject: [PATCH] gpg-interface: modernize function declarations Let's drop "extern" from our declarations, which brings us in line with our modern style guidelines. While we're here, let's wrap some of the overly long lines, and move docstrings for public functions to their declarations, since they document the interface. Signed-off-by: Jeff King Signed-off-by: Ben Toews Signed-off-by: Junio C Hamano --- gpg-interface.c | 17 ---------- gpg-interface.h | 103 +++++++++++++++++++++++++++++++++++--------------------- 2 files changed, 65 insertions(+), 55 deletions(-) rewrite gpg-interface.h (66%) diff --git a/gpg-interface.c b/gpg-interface.c index 61c0690e12..08de0daa41 100644 --- a/gpg-interface.c +++ b/gpg-interface.c @@ -101,12 +101,6 @@ void print_signature_buffer(const struct signature_check *sigc, unsigned flags) fputs(output, stderr); } -/* - * Look at GPG signed content (e.g. a signed tag object), whose - * payload is followed by a detached signature on it. Return the - * offset where the embedded detached signature begins, or the end of - * the data when there is no such signature. - */ size_t parse_signature(const char *buf, unsigned long size) { char *eol; @@ -151,12 +145,6 @@ const char *get_signing_key(void) return git_committer_info(IDENT_STRICT|IDENT_NO_DATE); } -/* - * Create a detached signature for the contents of "buffer" and append - * it after "signature"; "buffer" and "signature" can be the same - * strbuf instance, which would cause the detached signature appended - * at the end. - */ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *signing_key) { struct child_process gpg = CHILD_PROCESS_INIT; @@ -198,11 +186,6 @@ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *sig return 0; } -/* - * Run "gpg" to see if the payload matches the detached signature. - * gpg_output, when set, receives the diagnostic output from GPG. - * gpg_status, when set, receives the status output from GPG. - */ int verify_signed_buffer(const char *payload, size_t payload_size, const char *signature, size_t signature_size, struct strbuf *gpg_output, struct strbuf *gpg_status) diff --git a/gpg-interface.h b/gpg-interface.h dissimilarity index 66% index d2d4fd3a65..2c40a9175f 100644 --- a/gpg-interface.h +++ b/gpg-interface.h @@ -1,38 +1,65 @@ -#ifndef GPG_INTERFACE_H -#define GPG_INTERFACE_H - -#define GPG_VERIFY_VERBOSE 1 -#define GPG_VERIFY_RAW 2 -#define GPG_VERIFY_OMIT_STATUS 4 - -struct signature_check { - char *payload; - char *gpg_output; - char *gpg_status; - - /* - * possible "result": - * 0 (not checked) - * N (checked but no further result) - * U (untrusted good) - * G (good) - * B (bad) - */ - char result; - char *signer; - char *key; -}; - -extern void signature_check_clear(struct signature_check *sigc); -extern size_t parse_signature(const char *buf, unsigned long size); -extern void parse_gpg_output(struct signature_check *); -extern int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *signing_key); -extern int verify_signed_buffer(const char *payload, size_t payload_size, const char *signature, size_t signature_size, struct strbuf *gpg_output, struct strbuf *gpg_status); -extern int git_gpg_config(const char *, const char *, void *); -extern void set_signing_key(const char *); -extern const char *get_signing_key(void); -extern int check_signature(const char *payload, size_t plen, - const char *signature, size_t slen, struct signature_check *sigc); -void print_signature_buffer(const struct signature_check *sigc, unsigned flags); - -#endif +#ifndef GPG_INTERFACE_H +#define GPG_INTERFACE_H + +#define GPG_VERIFY_VERBOSE 1 +#define GPG_VERIFY_RAW 2 +#define GPG_VERIFY_OMIT_STATUS 4 + +struct signature_check { + char *payload; + char *gpg_output; + char *gpg_status; + + /* + * possible "result": + * 0 (not checked) + * N (checked but no further result) + * U (untrusted good) + * G (good) + * B (bad) + */ + char result; + char *signer; + char *key; +}; + +void signature_check_clear(struct signature_check *sigc); + +/* + * Look at GPG signed content (e.g. a signed tag object), whose + * payload is followed by a detached signature on it. Return the + * offset where the embedded detached signature begins, or the end of + * the data when there is no such signature. + */ +size_t parse_signature(const char *buf, unsigned long size); + +void parse_gpg_output(struct signature_check *); + +/* + * Create a detached signature for the contents of "buffer" and append + * it after "signature"; "buffer" and "signature" can be the same + * strbuf instance, which would cause the detached signature appended + * at the end. + */ +int sign_buffer(struct strbuf *buffer, struct strbuf *signature, + const char *signing_key); + +/* + * Run "gpg" to see if the payload matches the detached signature. + * gpg_output, when set, receives the diagnostic output from GPG. + * gpg_status, when set, receives the status output from GPG. + */ +int verify_signed_buffer(const char *payload, size_t payload_size, + const char *signature, size_t signature_size, + struct strbuf *gpg_output, struct strbuf *gpg_status); + +int git_gpg_config(const char *, const char *, void *); +void set_signing_key(const char *); +const char *get_signing_key(void); +int check_signature(const char *payload, size_t plen, + const char *signature, size_t slen, + struct signature_check *sigc); +void print_signature_buffer(const struct signature_check *sigc, + unsigned flags); + +#endif -- 2.11.4.GIT