diff options
Diffstat (limited to 'src/ostree/ot-remote-builtin-gpg-import.c')
-rw-r--r-- | src/ostree/ot-remote-builtin-gpg-import.c | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/src/ostree/ot-remote-builtin-gpg-import.c b/src/ostree/ot-remote-builtin-gpg-import.c index ba4aa3b4..0d9744e5 100644 --- a/src/ostree/ot-remote-builtin-gpg-import.c +++ b/src/ostree/ot-remote-builtin-gpg-import.c @@ -19,8 +19,8 @@ #include "config.h" -#include <libglnx.h> #include <gio/gunixinputstream.h> +#include <libglnx.h> #include "otutil.h" @@ -38,18 +38,16 @@ static char **opt_keyrings; * man page (man/ostree-remote.xml) when changing the option list. */ -static GOptionEntry option_entries[] = { - { "keyring", 'k', 0, G_OPTION_ARG_FILENAME_ARRAY, &opt_keyrings, "Import keys from a keyring file (repeatable)", "FILE" }, - { "stdin", 0, 0, G_OPTION_ARG_NONE, &opt_stdin, "Import keys from standard input", NULL }, - { NULL } -}; +static GOptionEntry option_entries[] + = { { "keyring", 'k', 0, G_OPTION_ARG_FILENAME_ARRAY, &opt_keyrings, + "Import keys from a keyring file (repeatable)", "FILE" }, + { "stdin", 0, 0, G_OPTION_ARG_NONE, &opt_stdin, "Import keys from standard input", NULL }, + { NULL } }; static gboolean -open_source_stream (GInputStream **out_source_stream, - GCancellable *cancellable, - GError **error) +open_source_stream (GInputStream **out_source_stream, GCancellable *cancellable, GError **error) { - g_autoptr(GInputStream) source_stream = NULL; + g_autoptr (GInputStream) source_stream = NULL; guint n_keyrings = 0; gboolean ret = FALSE; @@ -62,14 +60,14 @@ open_source_stream (GInputStream **out_source_stream, } else { - g_autoptr(GPtrArray) streams = NULL; + g_autoptr (GPtrArray) streams = NULL; guint ii; streams = g_ptr_array_new_with_free_func (g_object_unref); for (ii = 0; ii < n_keyrings; ii++) { - g_autoptr(GFile) file = NULL; + g_autoptr (GFile) file = NULL; GFileInputStream *input_stream = NULL; file = g_file_new_for_path (opt_keyrings[ii]); @@ -82,8 +80,8 @@ open_source_stream (GInputStream **out_source_stream, g_ptr_array_add (streams, input_stream); } - /* Chain together all the --keyring options as one long stream. */ - source_stream = (GInputStream *) ostree_chain_input_stream_new (streams); + /* Chain together all the --keyring options as one long stream. */ + source_stream = (GInputStream *)ostree_chain_input_stream_new (streams); } *out_source_stream = g_steal_pointer (&source_stream); @@ -95,20 +93,21 @@ out: } gboolean -ot_remote_builtin_gpg_import (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error) +ot_remote_builtin_gpg_import (int argc, char **argv, OstreeCommandInvocation *invocation, + GCancellable *cancellable, GError **error) { - g_autoptr(GOptionContext) context = NULL; - g_autoptr(OstreeRepo) repo = NULL; - g_autoptr(GInputStream) source_stream = NULL; + g_autoptr (GOptionContext) context = NULL; + g_autoptr (OstreeRepo) repo = NULL; + g_autoptr (GInputStream) source_stream = NULL; const char *remote_name; - const char * const *key_ids; + const char *const *key_ids; guint imported = 0; gboolean ret = FALSE; context = g_option_context_new ("NAME [KEY-ID...]"); - if (!ostree_option_context_parse (context, option_entries, &argc, &argv, - invocation, &repo, cancellable, error)) + if (!ostree_option_context_parse (context, option_entries, &argc, &argv, invocation, &repo, + cancellable, error)) goto out; if (argc < 2) @@ -124,21 +123,21 @@ ot_remote_builtin_gpg_import (int argc, char **argv, OstreeCommandInvocation *in } remote_name = argv[1]; - key_ids = (argc > 2) ? (const char * const *) argv + 2 : NULL; + key_ids = (argc > 2) ? (const char *const *)argv + 2 : NULL; if (!open_source_stream (&source_stream, cancellable, error)) goto out; - if (!ostree_repo_remote_gpg_import (repo, remote_name, source_stream, - key_ids, &imported, cancellable, error)) + if (!ostree_repo_remote_gpg_import (repo, remote_name, source_stream, key_ids, &imported, + cancellable, error)) goto out; /* XXX If we ever add internationalization, use ngettext() here. */ - g_print ("Imported %u GPG key%s to remote \"%s\"\n", - imported, (imported == 1) ? "" : "s", remote_name); + g_print ("Imported %u GPG key%s to remote \"%s\"\n", imported, (imported == 1) ? "" : "s", + remote_name); ret = TRUE; - out: +out: return ret; } |