Skip to content

Commit

Permalink
common: Move functions for dealing with AppStream XML to their own file
Browse files Browse the repository at this point in the history
This seems like an obvious set of functionality to be grouped together
in service of the wider goal of making flatpak-utils smaller and more
manageable.

Signed-off-by: Simon McVittie <[email protected]>
  • Loading branch information
smcv committed May 3, 2024
1 parent ad0aa46 commit 6e81bc6
Show file tree
Hide file tree
Showing 8 changed files with 632 additions and 580 deletions.
1 change: 1 addition & 0 deletions app/flatpak-builtins.h
Expand Up @@ -28,6 +28,7 @@
#include "flatpak-tty-utils-private.h"
#include "flatpak-utils-private.h"
#include "flatpak-dir-private.h"
#include "flatpak-xml-utils-private.h"

G_BEGIN_DECLS

Expand Down
1 change: 1 addition & 0 deletions common/flatpak-dir.c
Expand Up @@ -57,6 +57,7 @@
#include "flatpak-utils-base-private.h"
#include "flatpak-variant-private.h"
#include "flatpak-variant-impl-private.h"
#include "flatpak-xml-utils-private.h"
#include "libglnx.h"
#include "system-helper/flatpak-system-helper.h"

Expand Down
1 change: 1 addition & 0 deletions common/flatpak-oci-registry.c
Expand Up @@ -32,6 +32,7 @@
#include "flatpak-utils-private.h"
#include "flatpak-uri-private.h"
#include "flatpak-dir-private.h"
#include "flatpak-xml-utils-private.h"
#include "flatpak-zstd-decompressor-private.h"

#define MAX_JSON_SIZE (1024 * 1024)
Expand Down
46 changes: 0 additions & 46 deletions common/flatpak-utils-private.h
Expand Up @@ -554,58 +554,12 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (FlatpakRepoTransaction, flatpak_repo_transaction_

#define AUTOLOCK(name) G_GNUC_UNUSED __attribute__((cleanup (flatpak_auto_unlock_helper))) GMutex * G_PASTE (auto_unlock, __LINE__) = flatpak_auto_lock_helper (&G_LOCK_NAME (name))

typedef struct FlatpakXml FlatpakXml;

struct FlatpakXml
{
gchar *element_name; /* NULL == text */
char **attribute_names;
char **attribute_values;
char *text;
FlatpakXml *parent;
FlatpakXml *first_child;
FlatpakXml *last_child;
FlatpakXml *next_sibling;
};

FlatpakXml *flatpak_xml_new (const gchar *element_name);
FlatpakXml *flatpak_xml_new_text (const gchar *text);
void flatpak_xml_add (FlatpakXml *parent,
FlatpakXml *node);
void flatpak_xml_free (FlatpakXml *node);
FlatpakXml *flatpak_xml_parse (GInputStream * in,
gboolean compressed,
GCancellable *cancellable,
GError **error);
void flatpak_xml_to_string (FlatpakXml *node,
GString *res);
FlatpakXml *flatpak_xml_unlink (FlatpakXml *node,
FlatpakXml *prev_sibling);
FlatpakXml *flatpak_xml_find (FlatpakXml *node,
const char *type,
FlatpakXml **prev_child_out);

G_DEFINE_AUTOPTR_CLEANUP_FUNC (FlatpakXml, flatpak_xml_free);

FlatpakXml *flatpak_appstream_xml_new (void);
gboolean flatpak_appstream_xml_migrate (FlatpakXml *source,
FlatpakXml *dest,
const char *ref,
const char *id,
GKeyFile *metadata);
gboolean flatpak_appstream_xml_root_to_data (FlatpakXml *appstream_root,
GBytes **uncompressed,
GBytes **compressed,
GError **error);
gboolean flatpak_repo_generate_appstream (OstreeRepo *repo,
const char **gpg_key_ids,
const char *gpg_homedir,
guint64 timestamp,
GCancellable *cancellable,
GError **error);
void flatpak_appstream_xml_filter (FlatpakXml *appstream,
GRegex *allow_refs,
GRegex *deny_refs);

char * flatpak_filter_glob_to_regexp (const char *glob, gboolean runtime_only, GError **error);
gboolean flatpak_parse_filters (const char *data,
Expand Down

0 comments on commit 6e81bc6

Please sign in to comment.