diff options
author | Alexander Larsson <alexl@redhat.com> | 2016-05-06 16:03:27 +0200 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2016-05-06 16:03:27 +0200 |
commit | 1ffdf27d927c7944e3bce9b1cd3c101d823fd826 (patch) | |
tree | b91268da5ea5f1d224977ce4e5bbb75386d9a424 /app | |
parent | afa12a446fcc473eb740146805856e76ad82b4af (diff) | |
download | xdg-app-1ffdf27d927c7944e3bce9b1cd3c101d823fd826.tar.gz |
uncruftify: Initial run, all non-problematic changes
Diffstat (limited to 'app')
-rw-r--r-- | app/xdg-app-builtins-add-remote.c | 12 | ||||
-rw-r--r-- | app/xdg-app-builtins-build-bundle.c | 151 | ||||
-rw-r--r-- | app/xdg-app-builtins-build-export.c | 41 | ||||
-rw-r--r-- | app/xdg-app-builtins-build-finish.c | 36 | ||||
-rw-r--r-- | app/xdg-app-builtins-build-import-bundle.c | 14 | ||||
-rw-r--r-- | app/xdg-app-builtins-build-init.c | 12 | ||||
-rw-r--r-- | app/xdg-app-builtins-build.c | 8 | ||||
-rw-r--r-- | app/xdg-app-builtins-document.c | 62 | ||||
-rw-r--r-- | app/xdg-app-builtins-enter.c | 24 | ||||
-rw-r--r-- | app/xdg-app-builtins-install.c | 13 | ||||
-rw-r--r-- | app/xdg-app-builtins-list-remotes.c | 8 | ||||
-rw-r--r-- | app/xdg-app-builtins-list.c | 17 | ||||
-rw-r--r-- | app/xdg-app-builtins-ls-remote.c | 6 | ||||
-rw-r--r-- | app/xdg-app-builtins-repo-update.c | 16 | ||||
-rw-r--r-- | app/xdg-app-builtins-uninstall.c | 4 | ||||
-rw-r--r-- | app/xdg-app-builtins-update.c | 28 | ||||
-rw-r--r-- | app/xdg-app-builtins.h | 70 | ||||
-rw-r--r-- | app/xdg-app-main.c | 61 |
18 files changed, 312 insertions, 271 deletions
diff --git a/app/xdg-app-builtins-add-remote.c b/app/xdg-app-builtins-add-remote.c index 27d990f..799ee7f 100644 --- a/app/xdg-app-builtins-add-remote.c +++ b/app/xdg-app-builtins-add-remote.c @@ -73,8 +73,8 @@ static GOptionEntry common_options[] = { static gboolean open_source_stream (GInputStream **out_source_stream, - GCancellable *cancellable, - GError **error) + GCancellable *cancellable, + GError **error) { g_autoptr(GInputStream) source_stream = NULL; guint n_keyrings = 0; @@ -98,7 +98,7 @@ open_source_stream (GInputStream **out_source_stream, else { g_autoptr(GFile) file = g_file_new_for_path (opt_gpg_import[ii]); - input_stream = G_INPUT_STREAM(g_file_read (file, cancellable, error)); + input_stream = G_INPUT_STREAM (g_file_read (file, cancellable, error)); if (input_stream == NULL) { @@ -120,10 +120,10 @@ open_source_stream (GInputStream **out_source_stream, } gboolean -import_keys (XdgAppDir *dir, - const char *remote_name, +import_keys (XdgAppDir *dir, + const char *remote_name, GCancellable *cancellable, - GError **error) + GError **error) { if (opt_gpg_import != NULL) { diff --git a/app/xdg-app-builtins-build-bundle.c b/app/xdg-app-builtins-build-bundle.c index 81b3651..7d11757 100644 --- a/app/xdg-app-builtins-build-bundle.c +++ b/app/xdg-app-builtins-build-bundle.c @@ -57,7 +57,7 @@ static GOptionEntry options[] = { static GBytes * read_gpg_data (GCancellable *cancellable, - GError **error) + GError **error) { g_autoptr(GInputStream) source_stream = NULL; guint n_keyrings = 0; @@ -81,7 +81,7 @@ read_gpg_data (GCancellable *cancellable, else { g_autoptr(GFile) file = g_file_new_for_path (opt_gpg_file[ii]); - input_stream = G_INPUT_STREAM(g_file_read (file, cancellable, error)); + input_stream = G_INPUT_STREAM (g_file_read (file, cancellable, error)); if (input_stream == NULL) return NULL; @@ -104,6 +104,7 @@ build_bundle (OstreeRepo *repo, GFile *file, { GVariantBuilder metadata_builder; GVariantBuilder param_builder; + g_autoptr(GKeyFile) keyfile = NULL; g_autoptr(GFile) xmls_dir = NULL; g_autoptr(GFile) metadata_file = NULL; @@ -140,7 +141,7 @@ build_bundle (OstreeRepo *repo, GFile *file, keyfile = g_key_file_new (); - in = (GInputStream*)g_file_read (metadata_file, cancellable, NULL); + in = (GInputStream *) g_file_read (metadata_file, cancellable, NULL); if (in != NULL) { g_autoptr(GBytes) bytes = xdg_app_read_stream (in, TRUE, error); @@ -162,7 +163,7 @@ build_bundle (OstreeRepo *repo, GFile *file, appstream_basename = g_strconcat (name, ".xml.gz", NULL); appstream_file = g_file_get_child (xmls_dir, appstream_basename); - xml_in = (GInputStream*)g_file_read (appstream_file, cancellable, NULL); + xml_in = (GInputStream *) g_file_read (appstream_file, cancellable, NULL); if (xml_in) { g_autoptr(XdgAppXml) appstream_root = NULL; @@ -193,11 +194,11 @@ build_bundle (OstreeRepo *repo, GFile *file, for (i = 0; i < G_N_ELEMENTS (icon_sizes); i++) { - g_autoptr(GFile) size_dir =g_file_get_child (icons_dir, icon_sizes[i]); + g_autoptr(GFile) size_dir = g_file_get_child (icons_dir, icon_sizes[i]); g_autoptr(GFile) icon_file = g_file_get_child (size_dir, icon_name); g_autoptr(GInputStream) png_in = NULL; - png_in = (GInputStream*)g_file_read (icon_file, cancellable, NULL); + png_in = (GInputStream *) g_file_read (icon_file, cancellable, NULL); if (png_in != NULL) { g_autoptr(GBytes) png_data = xdg_app_read_stream (png_in, FALSE, error); @@ -224,11 +225,13 @@ build_bundle (OstreeRepo *repo, GFile *file, } if (gpg_data) - g_variant_builder_add (&metadata_builder, "{sv}", "gpg-keys", - g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, - g_bytes_get_data (gpg_data, NULL), - g_bytes_get_size (gpg_data), - 1)); + { + g_variant_builder_add (&metadata_builder, "{sv}", "gpg-keys", + g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, + g_bytes_get_data (gpg_data, NULL), + g_bytes_get_size (gpg_data), + 1)); + } g_variant_builder_init (¶m_builder, G_VARIANT_TYPE ("a{sv}")); g_variant_builder_add (¶m_builder, "{sv}", "min-fallback-size", g_variant_new_uint32 (0)); @@ -253,20 +256,21 @@ build_bundle (OstreeRepo *repo, GFile *file, #if defined(HAVE_LIBARCHIVE) && defined(HAVE_OSTREE_EXPORT_PATH_PREFIX) -GLNX_DEFINE_CLEANUP_FUNCTION(void*, xdg_app_local_free_read_archive, archive_read_free) -#define free_read_archive __attribute__ ((cleanup(xdg_app_local_free_read_archive))) +GLNX_DEFINE_CLEANUP_FUNCTION (void *, xdg_app_local_free_read_archive, archive_read_free) +#define free_read_archive __attribute__((cleanup (xdg_app_local_free_read_archive))) -GLNX_DEFINE_CLEANUP_FUNCTION(void*, xdg_app_local_free_write_archive, archive_write_free) -#define free_write_archive __attribute__ ((cleanup(xdg_app_local_free_write_archive))) +GLNX_DEFINE_CLEANUP_FUNCTION (void *, xdg_app_local_free_write_archive, archive_write_free) +#define free_write_archive __attribute__((cleanup (xdg_app_local_free_write_archive))) -GLNX_DEFINE_CLEANUP_FUNCTION(void*, xdg_app_local_free_archive_entry, archive_entry_free) -#define free_archive_entry __attribute__ ((cleanup(xdg_app_local_free_archive_entry))) +GLNX_DEFINE_CLEANUP_FUNCTION (void *, xdg_app_local_free_archive_entry, archive_entry_free) +#define free_archive_entry __attribute__((cleanup (xdg_app_local_free_archive_entry))) -typedef struct { +typedef struct +{ GString *str; - int depth; - GList *index; + int depth; + GList *index; } JsonWriter; static void @@ -281,6 +285,7 @@ static void json_writer_indent (JsonWriter *writer) { int i; + for (i = 0; i < writer->depth; i++) g_string_append (writer->str, " "); } @@ -315,20 +320,25 @@ json_writer_add_string (JsonWriter *writer, const gchar *str) case '\b': g_string_append (writer->str, "\\b"); break; + case '\f': g_string_append (writer->str, "\\f"); break; + case '\n': g_string_append (writer->str, "\\n"); break; + case '\r': g_string_append (writer->str, "\\r"); break; + case '\t': g_string_append (writer->str, "\\t"); break; + default: - g_string_append_printf (writer->str, "\\u00%02x", (guint)*p); + g_string_append_printf (writer->str, "\\u00%02x", (guint) * p); break; } } @@ -344,13 +354,14 @@ json_writer_add_string (JsonWriter *writer, const gchar *str) static void json_writer_start_item (JsonWriter *writer) { - int index = GPOINTER_TO_INT(writer->index->data); + int index = GPOINTER_TO_INT (writer->index->data); + if (index != 0) g_string_append (writer->str, ",\n"); else g_string_append (writer->str, "\n"); json_writer_indent (writer); - writer->index->data = GINT_TO_POINTER(index+1); + writer->index->data = GINT_TO_POINTER (index + 1); } static void @@ -364,6 +375,7 @@ static void json_writer_close_scope (JsonWriter *writer) { GList *l; + writer->depth -= 1; l = writer->index; writer->index = g_list_remove_link (writer->index, l); @@ -383,11 +395,12 @@ static void json_writer_close_struct (JsonWriter *writer) { int index; + json_writer_close_scope (writer); g_string_append (writer->str, "}"); /* Last newline in file */ - index = GPOINTER_TO_INT(writer->index->data); + index = GPOINTER_TO_INT (writer->index->data); if (index == 0) g_string_append (writer->str, "\n"); } @@ -457,7 +470,7 @@ json_writer_add_array_struct (JsonWriter *writer) } static gboolean -propagate_libarchive_error (GError **error, +propagate_libarchive_error (GError **error, struct archive *a) { g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, @@ -466,8 +479,8 @@ propagate_libarchive_error (GError **error, } struct archive_entry * -new_entry (struct archive *a, - const char *name, +new_entry (struct archive *a, + const char *name, OstreeRepoExportArchiveOptions *opts) { struct archive_entry *entry = archive_entry_new2 (a); @@ -485,12 +498,13 @@ new_entry (struct archive *a, static gboolean -add_dir (struct archive *a, - const char *name, +add_dir (struct archive *a, + const char *name, OstreeRepoExportArchiveOptions *opts, - GError **error) + GError **error) { g_autofree char *full_name = g_build_filename ("rootfs", name, NULL); + free_archive_entry struct archive_entry *entry = new_entry (a, full_name, opts); archive_entry_set_mode (entry, AE_IFDIR | 0755); @@ -502,13 +516,14 @@ add_dir (struct archive *a, } static gboolean -add_symlink (struct archive *a, - const char *name, - const char *target, +add_symlink (struct archive *a, + const char *name, + const char *target, OstreeRepoExportArchiveOptions *opts, - GError **error) + GError **error) { g_autofree char *full_name = g_build_filename ("rootfs", name, NULL); + free_archive_entry struct archive_entry *entry = new_entry (a, full_name, opts); archive_entry_set_mode (entry, AE_IFLNK | 0755); @@ -521,13 +536,13 @@ add_symlink (struct archive *a, } static gboolean -add_file (struct archive *a, - const char *name, - OstreeRepo *repo, - GFile *file, +add_file (struct archive *a, + const char *name, + OstreeRepo *repo, + GFile *file, OstreeRepoExportArchiveOptions *opts, - GCancellable *cancellable, - GError **error) + GCancellable *cancellable, + GError **error) { free_archive_entry struct archive_entry *entry = new_entry (a, name, opts); guint8 buf[8192]; @@ -535,7 +550,7 @@ add_file (struct archive *a, g_autoptr(GFileInfo) file_info = NULL; const char *checksum; - checksum = ostree_repo_file_get_checksum ((OstreeRepoFile*)file); + checksum = ostree_repo_file_get_checksum ((OstreeRepoFile *) file); if (!ostree_repo_load_file (repo, checksum, &file_in, &file_info, NULL, cancellable, error)) @@ -571,14 +586,14 @@ add_file (struct archive *a, } static gboolean -add_file_from_data (struct archive *a, - const char *name, - OstreeRepo *repo, - const char *data, - gsize size, +add_file_from_data (struct archive *a, + const char *name, + OstreeRepo *repo, + const char *data, + gsize size, OstreeRepoExportArchiveOptions *opts, - GCancellable *cancellable, - GError **error) + GCancellable *cancellable, + GError **error) { free_archive_entry struct archive_entry *entry = new_entry (a, name, opts); ssize_t r; @@ -687,33 +702,33 @@ generate_config_json (const char *arch) json_writer_add_struct_property (&writer, "linux"); { - json_writer_add_string_property (&writer, "rootfsPropagation", "slave"); - json_writer_add_struct_property (&writer, "resources"); + json_writer_add_string_property (&writer, "rootfsPropagation", "slave"); + json_writer_add_struct_property (&writer, "resources"); + { + json_writer_close_struct (&writer); + } + + json_writer_add_array_property (&writer, "namespaces"); + { + json_writer_add_array_struct (&writer); { + json_writer_add_string_property (&writer, "type", "pid"); json_writer_close_struct (&writer); } - - json_writer_add_array_property (&writer, "namespaces"); + json_writer_add_array_struct (&writer); { - json_writer_add_array_struct (&writer); - { - json_writer_add_string_property (&writer, "type", "pid"); - json_writer_close_struct (&writer); - } - json_writer_add_array_struct (&writer); - { - json_writer_add_string_property (&writer, "type", "mount"); - json_writer_close_struct (&writer); - } - json_writer_close_array (&writer); + json_writer_add_string_property (&writer, "type", "mount"); + json_writer_close_struct (&writer); } + json_writer_close_array (&writer); + } - json_writer_close_struct (&writer); + json_writer_close_struct (&writer); } json_writer_add_struct_property (&writer, "annotations"); { - json_writer_close_struct (&writer); + json_writer_close_struct (&writer); } json_writer_close_struct (&writer); @@ -806,18 +821,18 @@ build_oci (OstreeRepo *repo, GFile *file, return FALSE; for (i = 0; i < G_N_ELEMENTS (root_symlinks); i += 2) - if (!add_symlink (a, root_symlinks[i], root_symlinks[i+1], &opts, error)) + if (!add_symlink (a, root_symlinks[i], root_symlinks[i + 1], &opts, error)) return FALSE; } - if (!ostree_repo_export_tree_to_archive (repo, &opts, (OstreeRepoFile*)files, a, + if (!ostree_repo_export_tree_to_archive (repo, &opts, (OstreeRepoFile *) files, a, cancellable, error)) return FALSE; if (!opt_runtime && g_file_query_exists (export, NULL)) { opts.path_prefix = "rootfs/export/"; - if (!ostree_repo_export_tree_to_archive (repo, &opts, (OstreeRepoFile*)export, a, + if (!ostree_repo_export_tree_to_archive (repo, &opts, (OstreeRepoFile *) export, a, cancellable, error)) return FALSE; } diff --git a/app/xdg-app-builtins-build-export.c b/app/xdg-app-builtins-build-export.c index d4b26e9..a1bb18d 100644 --- a/app/xdg-app-builtins-build-export.c +++ b/app/xdg-app-builtins-build-export.c @@ -63,6 +63,7 @@ static gboolean metadata_get_arch (GFile *file, char **out_arch, GError **error) { g_autofree char *path = NULL; + g_autoptr(GKeyFile) keyfile = NULL; g_autofree char *runtime = NULL; g_auto(GStrv) parts = NULL; @@ -115,7 +116,8 @@ is_empty_directory (GFile *file, GCancellable *cancellable) return TRUE; } -typedef struct { +typedef struct +{ const char **exclude; const char **include; } CommitData; @@ -140,7 +142,7 @@ matches_patterns (const char **patterns, const char *path) static OstreeRepoCommitFilterResult commit_filter (OstreeRepo *repo, const char *path, - GFileInfo *file_info, + GFileInfo *file_info, CommitData *commit_data) { guint mode; @@ -167,14 +169,14 @@ commit_filter (OstreeRepo *repo, } gboolean -add_file_to_mtree (GFile *file, - const char *name, - OstreeRepo *repo, +add_file_to_mtree (GFile *file, + const char *name, + OstreeRepo *repo, OstreeMutableTree *mtree, - GCancellable *cancellable, - GError **error) + GCancellable *cancellable, + GError **error) { - g_autoptr (GFileInfo) file_info = NULL; + g_autoptr(GFileInfo) file_info = NULL; g_autoptr(GInputStream) raw_input = NULL; g_autoptr(GInputStream) input = NULL; guint64 length; @@ -193,7 +195,7 @@ add_file_to_mtree (GFile *file, g_file_info_set_attribute_uint32 (file_info, "unix::gid", 0); g_file_info_set_attribute_uint32 (file_info, "unix::mode", 0100644); - raw_input = (GInputStream*)g_file_read (file, cancellable, error); + raw_input = (GInputStream *) g_file_read (file, cancellable, error); if (raw_input == NULL) return FALSE; @@ -218,6 +220,7 @@ gboolean xdg_app_builtin_build_export (int argc, char **argv, GCancellable *cancellable, GError **error) { gboolean ret = FALSE; + g_autoptr(GOptionContext) context = NULL; g_autoptr(GFile) base = NULL; g_autoptr(GFile) files = NULL; @@ -356,12 +359,12 @@ xdg_app_builtin_build_export (int argc, char **argv, GCancellable *cancellable, goto out; modifier = ostree_repo_commit_modifier_new (OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS, - (OstreeRepoCommitFilter)commit_filter, &commit_data, NULL); + (OstreeRepoCommitFilter) commit_filter, &commit_data, NULL); if (opt_runtime) { - commit_data.exclude = (const char **)opt_exclude; - commit_data.include = (const char **)opt_include; + commit_data.exclude = (const char **) opt_exclude; + commit_data.include = (const char **) opt_include; if (!ostree_repo_write_directory_to_mtree (repo, usr, files_mtree, modifier, cancellable, error)) goto out; commit_data.exclude = NULL; @@ -369,8 +372,8 @@ xdg_app_builtin_build_export (int argc, char **argv, GCancellable *cancellable, } else { - commit_data.exclude = (const char **)opt_exclude; - commit_data.include = (const char **)opt_include; + commit_data.exclude = (const char **) opt_exclude; + commit_data.include = (const char **) opt_include; if (!ostree_repo_write_directory_to_mtree (repo, files, files_mtree, modifier, cancellable, error)) goto out; commit_data.exclude = NULL; @@ -421,10 +424,12 @@ xdg_app_builtin_build_export (int argc, char **argv, GCancellable *cancellable, { g_autoptr(GError) my_error = NULL; - if (!xdg_app_repo_generate_appstream (repo, (const char **)opt_gpg_key_ids, opt_gpg_homedir, cancellable, &my_error)) + if (!xdg_app_repo_generate_appstream (repo, (const char **) opt_gpg_key_ids, opt_gpg_homedir, cancellable, &my_error)) { if (g_error_matches (my_error, G_SPAWN_ERROR, G_SPAWN_ERROR_NOENT)) - g_print ("WARNING: Can't find appstream-builder, unable to update appstream branch\n"); + { + g_print ("WARNING: Can't find appstream-builder, unable to update appstream branch\n"); + } else { g_propagate_error (error, g_steal_pointer (&my_error)); @@ -434,7 +439,7 @@ xdg_app_builtin_build_export (int argc, char **argv, GCancellable *cancellable, } if (!xdg_app_repo_update (repo, - (const char **)opt_gpg_key_ids, + (const char **) opt_gpg_key_ids, opt_gpg_homedir, cancellable, error)) @@ -451,7 +456,7 @@ xdg_app_builtin_build_export (int argc, char **argv, GCancellable *cancellable, ret = TRUE; - out: +out: if (repo) ostree_repo_abort_transaction (repo, cancellable, NULL); diff --git a/app/xdg-app-builtins-build-finish.c b/app/xdg-app-builtins-build-finish.c index a6bdf9c..71a3971 100644 --- a/app/xdg-app-builtins-build-finish.c +++ b/app/xdg-app-builtins-build-finish.c @@ -43,16 +43,17 @@ static GOptionEntry options[] = { }; static gboolean -export_dir (int source_parent_fd, - const char *source_name, - const char *source_relpath, - int destination_parent_fd, - const char *destination_name, - const char *required_prefix, - GCancellable *cancellable, - GError **error) +export_dir (int source_parent_fd, + const char *source_name, + const char *source_relpath, + int destination_parent_fd, + const char *destination_name, + const char *required_prefix, + GCancellable *cancellable, + GError **error) { int res; + g_auto(GLnxDirFdIterator) source_iter = {0}; glnx_fd_close int destination_dfd = -1; struct dirent *dent; @@ -91,7 +92,9 @@ export_dir (int source_parent_fd, if (fstatat (source_iter.fd, dent->d_name, &stbuf, AT_SYMLINK_NOFOLLOW) == -1) { if (errno == ENOENT) - continue; + { + continue; + } else { glnx_set_error_from_errno (error); @@ -106,7 +109,7 @@ export_dir (int source_parent_fd, if (S_ISDIR (stbuf.st_mode)) { - g_autofree gchar *child_relpath = g_build_filename(source_relpath, dent->d_name, NULL); + g_autofree gchar *child_relpath = g_build_filename (source_relpath, dent->d_name, NULL); if (!export_dir (source_iter.fd, dent->d_name, child_relpath, destination_dfd, dent->d_name, required_prefix, cancellable, error)) @@ -157,12 +160,12 @@ export_dir (int source_parent_fd, } static gboolean -copy_exports (GFile *source, - GFile *destination, - const char *source_prefix, - const char *required_prefix, - GCancellable *cancellable, - GError **error) +copy_exports (GFile *source, + GFile *destination, + const char *source_prefix, + const char *required_prefix, + GCancellable *cancellable, + GError **error) { if (!gs_file_ensure_directory (destination, TRUE, cancellable, error)) return FALSE; @@ -241,6 +244,7 @@ static gboolean update_metadata (GFile *base, XdgAppContext *arg_context, GCancellable *cancellable, GError **error) { gboolean ret = FALSE; + g_autoptr(GFile) metadata = NULL; g_autofree char *path = NULL; g_autoptr(GKeyFile) keyfile = NULL; diff --git a/app/xdg-app-builtins-build-import-bundle.c b/app/xdg-app-builtins-build-import-bundle.c index 12b9096..4d035e3 100644 --- a/app/xdg-app-builtins-build-import-bundle.c +++ b/app/xdg-app-builtins-build-import-bundle.c @@ -96,7 +96,7 @@ import_oci (OstreeRepo *repo, GFile *file, if (!ostree_repo_write_mtree (repo, archive_mtree, &archive_root, cancellable, error)) return FALSE; - if (!ostree_repo_file_ensure_resolved ((OstreeRepoFile*)archive_root, error)) + if (!ostree_repo_file_ensure_resolved ((OstreeRepoFile *) archive_root, error)) return FALSE; ref = g_file_resolve_relative_path (archive_root, "rootfs/ref"); @@ -172,7 +172,7 @@ import_oci (OstreeRepo *repo, GFile *file, } if (!ostree_mutable_tree_replace_file (mtree, "metadata", - ostree_repo_file_get_checksum ((OstreeRepoFile*) metadata), + ostree_repo_file_get_checksum ((OstreeRepoFile *) metadata), error)) return FALSE; @@ -190,13 +190,13 @@ import_oci (OstreeRepo *repo, GFile *file, tree_metadata_bytes = g_variant_get_child_value (commitv, 7); tree_metadata_checksum = ostree_checksum_from_bytes_v (tree_metadata_bytes); - if (strcmp (tree_contents_checksum, ostree_repo_file_tree_get_contents_checksum ((OstreeRepoFile*) root))) + if (strcmp (tree_contents_checksum, ostree_repo_file_tree_get_contents_checksum ((OstreeRepoFile *) root))) return xdg_app_fail (error, "Imported content checksum (%s) does not match original checksum (%s)", - tree_contents_checksum, ostree_repo_file_tree_get_contents_checksum ((OstreeRepoFile*) root)); + tree_contents_checksum, ostree_repo_file_tree_get_contents_checksum ((OstreeRepoFile *) root)); - if (strcmp (tree_metadata_checksum, ostree_repo_file_tree_get_metadata_checksum ((OstreeRepoFile*) root))) + if (strcmp (tree_metadata_checksum, ostree_repo_file_tree_get_metadata_checksum ((OstreeRepoFile *) root))) return xdg_app_fail (error, "Imported metadata checksum (%s) does not match original checksum (%s)", - tree_metadata_checksum, ostree_repo_file_tree_get_metadata_checksum ((OstreeRepoFile*) root)); + tree_metadata_checksum, ostree_repo_file_tree_get_metadata_checksum ((OstreeRepoFile *) root)); } commitv_metadata = g_variant_get_child_value (commitv, 0); @@ -238,7 +238,7 @@ import_oci (OstreeRepo *repo, GFile *file, static gboolean import_bundle (OstreeRepo *repo, GFile *file, - GCancellable *cancellable, GError **error) + GCancellable *cancellable, GError **error) { g_autoptr(GVariant) metadata = NULL; g_autofree char *bundle_ref = NULL; diff --git a/app/xdg-app-builtins-build-init.c b/app/xdg-app-builtins-build-init.c index a52d399..52714c8 100644 --- a/app/xdg-app-builtins-build-init.c +++ b/app/xdg-app-builtins-build-init.c @@ -192,7 +192,7 @@ xdg_app_builtin_build_init (int argc, char **argv, GCancellable *cancellable, GE } else { - g_list_free_full (extensions, (GDestroyNotify)xdg_app_extension_free); + g_list_free_full (extensions, (GDestroyNotify) xdg_app_extension_free); return xdg_app_fail (error, "Requested extension %s not installed\n", requested_extension); } } @@ -201,7 +201,7 @@ xdg_app_builtin_build_init (int argc, char **argv, GCancellable *cancellable, GE if (!found) return xdg_app_fail (error, "No extension %s in sdk\n", requested_extension); } - g_list_free_full (extensions, (GDestroyNotify)xdg_app_extension_free); + g_list_free_full (extensions, (GDestroyNotify) xdg_app_extension_free); } } @@ -243,10 +243,10 @@ xdg_app_builtin_build_init (int argc, char **argv, GCancellable *cancellable, GE metadata_contents = g_string_new ("[Application]\n"); g_string_append_printf (metadata_contents, - "name=%s\n" - "runtime=%s\n" - "sdk=%s\n", - app_id, runtime_ref, sdk_ref); + "name=%s\n" + "runtime=%s\n" + "sdk=%s\n", + app_id, runtime_ref, sdk_ref); if (opt_tags != NULL) { g_string_append (metadata_contents, "tags="); diff --git a/app/xdg-app-builtins-build.c b/app/xdg-app-builtins-build.c index 91d9827..a07183d 100644 --- a/app/xdg-app-builtins-build.c +++ b/app/xdg-app-builtins-build.c @@ -111,7 +111,7 @@ xdg_app_builtin_build (int argc, char **argv, GCancellable *cancellable, GError directory = argv[rest_argv_start]; if (rest_argc >= 2) - command = argv[rest_argv_start+1]; + command = argv[rest_argv_start + 1]; app_deploy = g_file_new_for_commandline_arg (directory); @@ -160,7 +160,9 @@ xdg_app_builtin_build (int argc, char **argv, GCancellable *cancellable, GError runtime_files = g_object_ref (usr); } else - runtime_files = xdg_app_deploy_get_files (runtime_deploy); + { + runtime_files = xdg_app_deploy_get_files (runtime_deploy); + } add_args (argv_array, custom_usr ? "--bind" : "--ro-bind", gs_file_get_path_cached (runtime_files), "/usr", @@ -220,7 +222,7 @@ xdg_app_builtin_build (int argc, char **argv, GCancellable *cancellable, GError g_ptr_array_add (argv_array, NULL); - if (!execve (xdg_app_get_bwrap (), (char **)argv_array->pdata, envp)) + if (!execve (xdg_app_get_bwrap (), (char **) argv_array->pdata, envp)) { g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno), "Unable to start app"); return FALSE; diff --git a/app/xdg-app-builtins-document.c b/app/xdg-app-builtins-document.c index d066368..58c8f82 100644 --- a/app/xdg-app-builtins-document.c +++ b/app/xdg-app-builtins-document.c @@ -65,10 +65,10 @@ xdg_app_builtin_export_file (int argc, char **argv, g_autoptr(GDBusConnection) session_bus = NULL; g_autoptr(GPtrArray) permissions = NULL; const char *file; - g_autofree char *mountpoint = NULL; - g_autofree char *basename = NULL; - g_autofree char *dirname = NULL; - g_autofree char *doc_path = NULL; + g_autofree char *mountpoint = NULL; + g_autofree char *basename = NULL; + g_autofree char *dirname = NULL; + g_autofree char *doc_path = NULL; XdpDbusDocuments *documents; int fd, fd_id; int i; @@ -120,31 +120,35 @@ xdg_app_builtin_export_file (int argc, char **argv, close (fd); if (opt_noexist) - reply = g_dbus_connection_call_with_unix_fd_list_sync (session_bus, - "org.freedesktop.portal.Documents", - "/org/freedesktop/portal/documents", - "org.freedesktop.portal.Documents", - "AddNamed", - g_variant_new ("(h^aybb)", fd_id, basename, !opt_unique, !opt_transient), - G_VARIANT_TYPE ("(s)"), - G_DBUS_CALL_FLAGS_NONE, - 30000, - fd_list, NULL, - NULL, - error); + { + reply = g_dbus_connection_call_with_unix_fd_list_sync (session_bus, + "org.freedesktop.portal.Documents", + "/org/freedesktop/portal/documents", + "org.freedesktop.portal.Documents", + "AddNamed", + g_variant_new ("(h^aybb)", fd_id, basename, !opt_unique, !opt_transient), + G_VARIANT_TYPE ("(s)"), + G_DBUS_CALL_FLAGS_NONE, + 30000, + fd_list, NULL, + NULL, + error); + } else - reply = g_dbus_connection_call_with_unix_fd_list_sync (session_bus, - "org.freedesktop.portal.Documents", - "/org/freedesktop/portal/documents", - "org.freedesktop.portal.Documents", - "Add", - g_variant_new ("(hbb)", fd_id, !opt_unique, !opt_transient), - G_VARIANT_TYPE ("(s)"), - G_DBUS_CALL_FLAGS_NONE, - 30000, - fd_list, NULL, - NULL, - error); + { + reply = g_dbus_connection_call_with_unix_fd_list_sync (session_bus, + "org.freedesktop.portal.Documents", + "/org/freedesktop/portal/documents", + "org.freedesktop.portal.Documents", + "Add", + g_variant_new ("(hbb)", fd_id, !opt_unique, !opt_transient), + G_VARIANT_TYPE ("(s)"), + G_DBUS_CALL_FLAGS_NONE, + 30000, + fd_list, NULL, + NULL, + error); + } g_object_unref (fd_list); if (reply == NULL) @@ -168,7 +172,7 @@ xdg_app_builtin_export_file (int argc, char **argv, if (!xdp_dbus_documents_call_grant_permissions_sync (documents, doc_id, opt_apps[i], - (const char **)permissions->pdata, + (const char **) permissions->pdata, NULL, error)) return FALSE; diff --git a/app/xdg-app-builtins-enter.c b/app/xdg-app-builtins-enter.c index 6b02bca..43b0308 100644 --- a/app/xdg-app-builtins-enter.c +++ b/app/xdg-app-builtins-enter.c @@ -49,9 +49,9 @@ write_to_file (int fd, const char *content, ssize_t len) { res = write (fd, content, len); if (res < 0 && errno == EINTR) - continue; + continue; if (res <= 0) - return FALSE; + return FALSE; len -= res; content += res; } @@ -117,16 +117,16 @@ child_setup (gpointer user_data) } gboolean -xdg_app_builtin_enter (int argc, - char **argv, +xdg_app_builtin_enter (int argc, + char **argv, GCancellable *cancellable, - GError **error) + GError **error) { g_autoptr(GOptionContext) context = NULL; int rest_argv_start, rest_argc; g_autoptr(XdgAppContext) arg_context = NULL; const char *ns_name[5] = { "user", "ipc", "net", "pid", "mnt" }; - int ns_fd[G_N_ELEMENTS(ns_name)]; + int ns_fd[G_N_ELEMENTS (ns_name)]; char pid_ns[256]; ssize_t pid_ns_len; char self_ns[256]; @@ -184,7 +184,7 @@ xdg_app_builtin_enter (int argc, if (!g_file_get_contents (environment_path, &environment, &environment_len, error)) return FALSE; - for (i = 0; i < G_N_ELEMENTS(ns_name); i++) + for (i = 0; i < G_N_ELEMENTS (ns_name); i++) { g_autofree char *path = g_strdup_printf ("/proc/%d/ns/%s", pid, ns_name[i]); g_autofree char *self_path = g_strdup_printf ("/proc/self/ns/%s", ns_name[i]); @@ -212,7 +212,7 @@ xdg_app_builtin_enter (int argc, } } - for (i = 0; i < G_N_ELEMENTS(ns_fd); i++) + for (i = 0; i < G_N_ELEMENTS (ns_fd); i++) { if (ns_fd[i] != -1) { @@ -241,7 +241,7 @@ xdg_app_builtin_enter (int argc, xdg_runtime_dir = g_strdup_printf ("/run/user/%d", uid); g_ptr_array_add (envp_array, g_strdup_printf ("XDG_RUNTIME_DIR=%s", xdg_runtime_dir)); - + if (g_file_test ("/tmp/.X11-unix/X99", G_FILE_TEST_EXISTS)) g_ptr_array_add (envp_array, g_strdup ("DISPLAY=:99.0")); @@ -258,15 +258,15 @@ xdg_app_builtin_enter (int argc, if (g_file_test ("/run/dbus/system_bus_socket", G_FILE_TEST_EXISTS)) g_ptr_array_add (envp_array, g_strdup ("DBUS_SYSTEM_BUS_ADDRESS=unix:/run/dbus/system_bus_socket")); - + g_ptr_array_add (envp_array, NULL); - + argv_array = g_ptr_array_new_with_free_func (g_free); for (i = 1; i < rest_argc; i++) g_ptr_array_add (argv_array, g_strdup (argv[rest_argv_start + i])); g_ptr_array_add (argv_array, NULL); - if (!g_spawn_sync (NULL, (char **)argv_array->pdata, (char **)envp_array->pdata, + if (!g_spawn_sync (NULL, (char **) argv_array->pdata, (char **) envp_array->pdata, G_SPAWN_SEARCH_PATH_FROM_ENVP | G_SPAWN_CHILD_INHERITS_STDIN, child_setup, NULL, NULL, NULL, diff --git a/app/xdg-app-builtins-install.c b/app/xdg-app-builtins-install.c index 05d18e2..c642419 100644 --- a/app/xdg-app-builtins-install.c +++ b/app/xdg-app-builtins-install.c @@ -57,7 +57,7 @@ static GOptionEntry options[] = { static GBytes * read_gpg_data (GCancellable *cancellable, - GError **error) + GError **error) { g_autoptr(GInputStream) source_stream = NULL; guint n_keyrings = 0; @@ -81,7 +81,7 @@ read_gpg_data (GCancellable *cancellable, else { g_autoptr(GFile) file = g_file_new_for_path (opt_gpg_file[ii]); - input_stream = G_INPUT_STREAM(g_file_read (file, cancellable, error)); + input_stream = G_INPUT_STREAM (g_file_read (file, cancellable, error)); if (input_stream == NULL) return NULL; @@ -105,6 +105,7 @@ install_bundle (XdgAppDir *dir, GError **error) { gboolean ret = FALSE; + g_autoptr(GFile) deploy_base = NULL; g_autoptr(GFile) file = NULL; const char *filename; @@ -186,7 +187,7 @@ install_bundle (XdgAppDir *dir, ret = TRUE; - out: +out: if (added_remote && !ret) ostree_repo_remote_delete (repo, remote, NULL, NULL); @@ -233,10 +234,8 @@ xdg_app_builtin_install (int argc, char **argv, GCancellable *cancellable, GErro opt_app, opt_runtime, &is_app, &my_error); if (installed_ref != NULL) - { - return xdg_app_fail (error, "%s %s, branch %s is already installed", - is_app ? "App" : "Runtime", name, branch ? branch : "master"); - } + return xdg_app_fail (error, "%s %s, branch %s is already installed", + is_app ? "App" : "Runtime", name, branch ? branch : "master"); if (!g_error_matches (my_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) { diff --git a/app/xdg-app-builtins-list-remotes.c b/app/xdg-app-builtins-list-remotes.c index a294e00..7d1b6a4 100644 --- a/app/xdg-app-builtins-list-remotes.c +++ b/app/xdg-app-builtins-list-remotes.c @@ -60,9 +60,7 @@ xdg_app_builtin_list_remotes (int argc, char **argv, GCancellable *cancellable, return FALSE; if (!opt_user && !opt_system) - { - opt_system = TRUE; - } + opt_system = TRUE; if (opt_user) { @@ -136,7 +134,9 @@ xdg_app_builtin_list_remotes (int argc, char **argv, GCancellable *cancellable, xdg_app_table_printer_append_with_comma (printer, dir == user_dir ? "user" : "system"); } else - xdg_app_table_printer_add_column (printer, remote_name); + { + xdg_app_table_printer_add_column (printer, remote_name); + } xdg_app_table_printer_finish_row (printer); } diff --git a/app/xdg-app-builtins-list.c b/app/xdg-app-builtins-list.c index a198c91..5832d61 100644 --- a/app/xdg-app-builtins-list.c +++ b/app/xdg-app-builtins-list.c @@ -75,6 +75,7 @@ static gboolean print_installed_refs (gboolean app, gboolean runtime, gboolean print_system, gboolean print_user, GCancellable *cancellable, GError **error) { g_autofree char *last = NULL; + g_auto(GStrv) system = NULL; g_auto(GStrv) system_app = NULL; g_auto(GStrv) system_runtime = NULL; @@ -145,7 +146,7 @@ print_installed_refs (gboolean app, gboolean runtime, gboolean print_system, gbo } parts = g_strsplit (ref, "/", -1); - partial_ref = strchr(ref, '/') + 1; + partial_ref = strchr (ref, '/') + 1; deploy_data = xdg_app_dir_get_deploy_data (dir, ref, cancellable, error); if (deploy_data == NULL) @@ -170,15 +171,19 @@ print_installed_refs (gboolean app, gboolean runtime, gboolean print_system, gbo latest = g_strdup ("-"); } else - latest[MIN(strlen(latest), 12)] = 0; + { + latest[MIN (strlen (latest), 12)] = 0; + } } else - latest = g_strdup ("?"); + { + latest = g_strdup ("?"); + } xdg_app_table_printer_add_column (printer, partial_ref); xdg_app_table_printer_add_column (printer, repo); - active[MIN(strlen(active), 12)] = 0; + active[MIN (strlen (active), 12)] = 0; xdg_app_table_printer_add_column (printer, active); xdg_app_table_printer_add_column (printer, latest); @@ -207,7 +212,9 @@ print_installed_refs (gboolean app, gboolean runtime, gboolean print_system, gbo subpaths = xdg_app_deploy_data_get_subpaths (deploy_data); if (subpaths[0] == NULL) - xdg_app_table_printer_add_column (printer, ""); + { + xdg_app_table_printer_add_column (printer, ""); + } else { int i; diff --git a/app/xdg-app-builtins-ls-remote.c b/app/xdg-app-builtins-ls-remote.c index a782552..9be0b81 100644 --- a/app/xdg-app-builtins-ls-remote.c +++ b/app/xdg-app-builtins-ls-remote.c @@ -132,13 +132,13 @@ xdg_app_builtin_ls_remote (int argc, char **argv, GCancellable *cancellable, GEr g_hash_table_insert (names, g_strdup (name), g_strdup (checksum)); } - keys = (const char **)g_hash_table_get_keys_as_array (names, &n_keys); - g_qsort_with_data (keys, n_keys, sizeof(char *), (GCompareDataFunc)xdg_app_strcmp0_ptr, NULL); + keys = (const char **) g_hash_table_get_keys_as_array (names, &n_keys); + g_qsort_with_data (keys, n_keys, sizeof (char *), (GCompareDataFunc) xdg_app_strcmp0_ptr, NULL); for (i = 0; i < n_keys; i++) { if (opt_show_details) - g_print ("%s %.12s\n", keys[i], (char *)g_hash_table_lookup (names, keys[i])); + g_print ("%s %.12s\n", keys[i], (char *) g_hash_table_lookup (names, keys[i])); else g_print ("%s\n", keys[i]); } diff --git a/app/xdg-app-builtins-repo-update.c b/app/xdg-app-builtins-repo-update.c index 084f47b..24c5bcc 100644 --- a/app/xdg-app-builtins-repo-update.c +++ b/app/xdg-app-builtins-repo-update.c @@ -79,10 +79,12 @@ xdg_app_builtin_build_update_repo (int argc, char **argv, return FALSE; g_print ("Updating appstream branch\n"); - if (!xdg_app_repo_generate_appstream (repo, (const char **)opt_gpg_key_ids, opt_gpg_homedir, cancellable, &my_error)) + if (!xdg_app_repo_generate_appstream (repo, (const char **) opt_gpg_key_ids, opt_gpg_homedir, cancellable, &my_error)) { if (g_error_matches (my_error, G_SPAWN_ERROR, G_SPAWN_ERROR_NOENT)) - g_print ("WARNING: Can't find appstream-builder, unable to update appstream branch\n"); + { + g_print ("WARNING: Can't find appstream-builder, unable to update appstream branch\n"); + } else { g_propagate_error (error, g_steal_pointer (&my_error)); @@ -116,7 +118,7 @@ xdg_app_builtin_build_update_repo (int argc, char **argv, all_deltas_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); for (i = 0; i < all_deltas->len; i++) { - g_print ("adding %s\n", (char *)g_ptr_array_index (all_deltas, i)); + g_print ("adding %s\n", (char *) g_ptr_array_index (all_deltas, i)); g_hash_table_insert (all_deltas_hash, g_strdup (g_ptr_array_index (all_deltas, i)), NULL); @@ -160,9 +162,9 @@ xdg_app_builtin_build_update_repo (int argc, char **argv, } /* Mark this one as wanted */ - g_hash_table_insert (all_deltas_hash, g_strdup (commit), GINT_TO_POINTER(1)); + g_hash_table_insert (all_deltas_hash, g_strdup (commit), GINT_TO_POINTER (1)); - /* From parent */ + /* From parent */ if (parent_variant != NULL) { from_parent = g_strdup_printf ("%s-%s", parent_commit, commit); @@ -179,13 +181,13 @@ xdg_app_builtin_build_update_repo (int argc, char **argv, } /* Mark this one as wanted */ - g_hash_table_insert (all_deltas_hash, g_strdup (from_parent), GINT_TO_POINTER(1)); + g_hash_table_insert (all_deltas_hash, g_strdup (from_parent), GINT_TO_POINTER (1)); } } } g_print ("Updating summary\n"); - if (!xdg_app_repo_update (repo, (const char **)opt_gpg_key_ids, opt_gpg_homedir, cancellable, error)) + if (!xdg_app_repo_update (repo, (const char **) opt_gpg_key_ids, opt_gpg_homedir, cancellable, error)) return FALSE; if (opt_prune) diff --git a/app/xdg-app-builtins-uninstall.c b/app/xdg-app-builtins-uninstall.c index df738d2..75279f8 100644 --- a/app/xdg-app-builtins-uninstall.c +++ b/app/xdg-app-builtins-uninstall.c @@ -135,9 +135,7 @@ xdg_app_builtin_uninstall (int argc, char **argv, GCancellable *cancellable, GEr if (repository != NULL && g_str_has_suffix (repository, "-origin") && xdg_app_dir_get_remote_noenumerate (dir, repository)) - { - ostree_repo_remote_delete (xdg_app_dir_get_repo (dir), repository, NULL, NULL); - } + ostree_repo_remote_delete (xdg_app_dir_get_repo (dir), repository, NULL, NULL); if (!xdg_app_dir_mark_changed (dir, error)) return FALSE; diff --git a/app/xdg-app-builtins-update.c b/app/xdg-app-builtins-update.c index b55f169..727d2e2 100644 --- a/app/xdg-app-builtins-update.c +++ b/app/xdg-app-builtins-update.c @@ -58,25 +58,27 @@ static gboolean update_appstream (XdgAppDir *dir, const char *remote, GCancellable *cancellable, GError **error) { gboolean changed; + if (!xdg_app_dir_update_appstream (dir, remote, opt_arch, &changed, - NULL, cancellable, error)) + NULL, cancellable, error)) return FALSE; return TRUE; } static gboolean -do_update (XdgAppDir* dir, - const char *name, - const char *branch, - const char *arch, - gboolean check_app, - gboolean check_runtime, +do_update (XdgAppDir * dir, + const char *name, + const char *branch, + const char *arch, + gboolean check_app, + gboolean check_runtime, GCancellable *cancellable, - GError **error) + GError **error) { g_autofree char *ref = NULL; g_autofree char *repository = NULL; + g_auto(GStrv) subpaths = NULL; gboolean is_app; @@ -108,14 +110,14 @@ do_update (XdgAppDir* dir, cancellable, error)) return FALSE; - return TRUE; + return TRUE; } gboolean -xdg_app_builtin_update (int argc, - char **argv, +xdg_app_builtin_update (int argc, + char **argv, GCancellable *cancellable, - GError **error) + GError **error) { g_autoptr(GOptionContext) context = NULL; g_autoptr(XdgAppDir) dir = NULL; @@ -230,5 +232,5 @@ xdg_app_builtin_update (int argc, xdg_app_dir_cleanup_removed (dir, cancellable, NULL); - return TRUE; + return TRUE; } diff --git a/app/xdg-app-builtins.h b/app/xdg-app-builtins.h index 80f14f2..380316c 100644 --- a/app/xdg-app-builtins.h +++ b/app/xdg-app-builtins.h @@ -30,48 +30,48 @@ G_BEGIN_DECLS typedef enum { XDG_APP_BUILTIN_FLAG_NO_DIR = 1 << 0, - XDG_APP_BUILTIN_FLAG_NO_REPO = 1 << 1, + XDG_APP_BUILTIN_FLAG_NO_REPO = 1 << 1, } XdgAppBuiltinFlags; -gboolean xdg_app_option_context_parse (GOptionContext *context, +gboolean xdg_app_option_context_parse (GOptionContext *context, const GOptionEntry *main_entries, - int *argc, - char ***argv, - XdgAppBuiltinFlags flags, - XdgAppDir **out_dir, - GCancellable *cancellable, - GError **error); + int *argc, + char ***argv, + XdgAppBuiltinFlags flags, + XdgAppDir **out_dir, + GCancellable *cancellable, + GError **error); gboolean usage_error (GOptionContext *context, - const char *message, - GError **error); + const char *message, + GError **error); -#define BUILTINPROTO(name) gboolean xdg_app_builtin_ ## name (int argc, char **argv, GCancellable *cancellable, GError **error) +#define BUILTINPROTO(name) gboolean xdg_app_builtin_ ## name (int argc, char **argv, GCancellable * cancellable, GError * *error) -BUILTINPROTO(add_remote); -BUILTINPROTO(modify_remote); -BUILTINPROTO(delete_remote); -BUILTINPROTO(ls_remote); -BUILTINPROTO(list_remotes); -BUILTINPROTO(install); -BUILTINPROTO(update); -BUILTINPROTO(make_current_app); -BUILTINPROTO(uninstall); -BUILTINPROTO(install_bundle); -BUILTINPROTO(list); -BUILTINPROTO(info); -BUILTINPROTO(run); -BUILTINPROTO(enter); -BUILTINPROTO(build_init); -BUILTINPROTO(build); -BUILTINPROTO(build_finish); -BUILTINPROTO(build_sign); -BUILTINPROTO(build_export); -BUILTINPROTO(build_bundle); -BUILTINPROTO(build_import); -BUILTINPROTO(build_update_repo); -BUILTINPROTO(export_file); -BUILTINPROTO(override); +BUILTINPROTO (add_remote); +BUILTINPROTO (modify_remote); +BUILTINPROTO (delete_remote); +BUILTINPROTO (ls_remote); +BUILTINPROTO (list_remotes); +BUILTINPROTO (install); +BUILTINPROTO (update); +BUILTINPROTO (make_current_app); +BUILTINPROTO (uninstall); +BUILTINPROTO (install_bundle); +BUILTINPROTO (list); +BUILTINPROTO (info); +BUILTINPROTO (run); +BUILTINPROTO (enter); +BUILTINPROTO (build_init); +BUILTINPROTO (build); +BUILTINPROTO (build_finish); +BUILTINPROTO (build_sign); +BUILTINPROTO (build_export); +BUILTINPROTO (build_bundle); +BUILTINPROTO (build_import); +BUILTINPROTO (build_update_repo); +BUILTINPROTO (export_file); +BUILTINPROTO (override); #undef BUILTINPROTO diff --git a/app/xdg-app-main.c b/app/xdg-app-main.c index 9cf751e..da50cef 100644 --- a/app/xdg-app-main.c +++ b/app/xdg-app-main.c @@ -37,11 +37,15 @@ static gboolean opt_version; static gboolean opt_default_arch; static gboolean opt_user; -typedef struct { +typedef struct +{ const char *name; - gboolean (*fn) (int argc, char **argv, GCancellable *cancellable, GError **error); + gboolean (*fn)(int argc, + char **argv, + GCancellable *cancellable, + GError **error); const char *description; - gboolean deprecated; + gboolean deprecated; } XdgAppCommand; static XdgAppCommand commands[] = { @@ -93,10 +97,10 @@ static GOptionEntry user_entries[] = { }; static void -message_handler (const gchar *log_domain, +message_handler (const gchar *log_domain, GLogLevelFlags log_level, - const gchar *message, - gpointer user_data) + const gchar *message, + gpointer user_data) { /* Make this look like normal console output */ if (log_level & G_LOG_LEVEL_DEBUG) @@ -123,10 +127,12 @@ xdg_app_option_context_new_with_commands (XdgAppCommand *commands) { g_string_append_printf (summary, "\n %s", commands->name); if (commands->description) - g_string_append_printf (summary, "%*s%s", (int)(20 - strlen (commands->name)), "", commands->description); + g_string_append_printf (summary, "%*s%s", (int) (20 - strlen (commands->name)), "", commands->description); } else - g_string_append_printf (summary, "\n%s", commands->name); + { + g_string_append_printf (summary, "\n%s", commands->name); + } } commands++; } @@ -140,7 +146,7 @@ xdg_app_option_context_new_with_commands (XdgAppCommand *commands) int xdg_app_usage (XdgAppCommand *commands, - gboolean is_error) + gboolean is_error) { GOptionContext *context; g_autofree char *help; @@ -158,18 +164,18 @@ xdg_app_usage (XdgAppCommand *commands, g_option_context_free (context); - return (is_error ? 1 : 0); + return is_error ? 1 : 0; } gboolean -xdg_app_option_context_parse (GOptionContext *context, +xdg_app_option_context_parse (GOptionContext *context, const GOptionEntry *main_entries, - int *argc, - char ***argv, - XdgAppBuiltinFlags flags, - XdgAppDir **out_dir, - GCancellable *cancellable, - GError **error) + int *argc, + char ***argv, + XdgAppBuiltinFlags flags, + XdgAppDir **out_dir, + GCancellable *cancellable, + GError **error) { g_autoptr(XdgAppDir) dir = NULL; @@ -204,7 +210,7 @@ xdg_app_option_context_parse (GOptionContext *context, return FALSE; if (!(flags & XDG_APP_BUILTIN_FLAG_NO_REPO) && - !xdg_app_dir_ensure_repo (dir, cancellable,error)) + !xdg_app_dir_ensure_repo (dir, cancellable, error)) return FALSE; } @@ -221,14 +227,15 @@ gboolean usage_error (GOptionContext *context, const char *message, GError **error) { g_autofree gchar *help = g_option_context_get_help (context, TRUE, NULL); + g_printerr ("%s", help); g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, message); return FALSE; } int -xdg_app_run (int argc, - char **argv, +xdg_app_run (int argc, + char **argv, GError **res_error) { XdgAppCommand *command; @@ -282,15 +289,11 @@ xdg_app_run (int argc, if (xdg_app_option_context_parse (context, NULL, &argc, &argv, XDG_APP_BUILTIN_FLAG_NO_DIR, NULL, cancellable, &error)) { if (command_name == NULL) - { - g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_FAILED, - "No command specified"); - } + g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_FAILED, + "No command specified"); else - { - g_set_error (&error, G_IO_ERROR, G_IO_ERROR_FAILED, - "Unknown command '%s'", command_name); - } + g_set_error (&error, G_IO_ERROR, G_IO_ERROR_FAILED, + "Unknown command '%s'", command_name); } help = g_option_context_get_help (context, FALSE, NULL); @@ -308,7 +311,7 @@ xdg_app_run (int argc, goto out; success = TRUE; - out: +out: g_assert (success || error); if (error) |