summaryrefslogtreecommitdiff
path: root/src/ostree/ot-builtin-checksum.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ostree/ot-builtin-checksum.c')
-rw-r--r--src/ostree/ot-builtin-checksum.c49
1 files changed, 24 insertions, 25 deletions
diff --git a/src/ostree/ot-builtin-checksum.c b/src/ostree/ot-builtin-checksum.c
index 576fbfde..b3b15c26 100644
--- a/src/ostree/ot-builtin-checksum.c
+++ b/src/ostree/ot-builtin-checksum.c
@@ -21,9 +21,9 @@
#include "config.h"
-#include "ot-main.h"
-#include "ot-builtins.h"
#include "ostree.h"
+#include "ot-builtins.h"
+#include "ot-main.h"
#include <string.h>
@@ -34,30 +34,28 @@
static gboolean opt_ignore_xattrs;
-static GOptionEntry options[] = {
- { "ignore-xattrs", 0, 0, G_OPTION_ARG_NONE, &opt_ignore_xattrs, "Don't include xattrs in checksum", NULL },
- { NULL }
-};
+static GOptionEntry options[] = { { "ignore-xattrs", 0, 0, G_OPTION_ARG_NONE, &opt_ignore_xattrs,
+ "Don't include xattrs in checksum", NULL },
+ { NULL } };
-typedef struct {
+typedef struct
+{
GError **error;
gboolean success;
GMainLoop *loop;
} AsyncChecksumData;
static void
-on_checksum_received (GObject *obj,
- GAsyncResult *result,
- gpointer user_data)
+on_checksum_received (GObject *obj, GAsyncResult *result, gpointer user_data)
{
AsyncChecksumData *data = user_data;
g_autofree guchar *csum_bytes = NULL;
- data->success =
- ostree_checksum_file_async_finish ((GFile*)obj, result, &csum_bytes, data->error);
+ data->success
+ = ostree_checksum_file_async_finish ((GFile *)obj, result, &csum_bytes, data->error);
if (data->success)
{
- char csum[OSTREE_SHA256_STRING_LEN+1];
+ char csum[OSTREE_SHA256_STRING_LEN + 1];
ostree_checksum_inplace_from_bytes (csum_bytes, csum);
g_print ("%s\n", csum);
}
@@ -66,12 +64,12 @@ on_checksum_received (GObject *obj,
}
gboolean
-ostree_builtin_checksum (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ostree_builtin_checksum (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context =
- g_option_context_new ("PATH");
- if (!ostree_option_context_parse (context, options, &argc, &argv,
- invocation, NULL, cancellable, error))
+ g_autoptr (GOptionContext) context = g_option_context_new ("PATH");
+ if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, NULL, cancellable,
+ error))
return FALSE;
if (argc < 2)
@@ -81,23 +79,24 @@ ostree_builtin_checksum (int argc, char **argv, OstreeCommandInvocation *invocat
/* for test coverage, use the async API if no flags are needed */
if (!opt_ignore_xattrs)
{
- g_autoptr(GFile) f = g_file_new_for_path (path);
- g_autoptr(GMainLoop) loop = g_main_loop_new (NULL, FALSE);
+ g_autoptr (GFile) f = g_file_new_for_path (path);
+ g_autoptr (GMainLoop) loop = g_main_loop_new (NULL, FALSE);
- AsyncChecksumData data = { 0, };
+ AsyncChecksumData data = {
+ 0,
+ };
data.loop = loop;
data.error = error;
- ostree_checksum_file_async (f, OSTREE_OBJECT_TYPE_FILE, G_PRIORITY_DEFAULT,
- cancellable, on_checksum_received, &data);
+ ostree_checksum_file_async (f, OSTREE_OBJECT_TYPE_FILE, G_PRIORITY_DEFAULT, cancellable,
+ on_checksum_received, &data);
g_main_loop_run (data.loop);
return data.success;
}
g_autofree char *checksum = NULL;
if (!ostree_checksum_file_at (AT_FDCWD, path, NULL, OSTREE_OBJECT_TYPE_FILE,
- OSTREE_CHECKSUM_FLAGS_IGNORE_XATTRS, &checksum,
- cancellable, error))
+ OSTREE_CHECKSUM_FLAGS_IGNORE_XATTRS, &checksum, cancellable, error))
return FALSE;
g_print ("%s\n", checksum);