Blame src/builder-utils.h

rpm-build c487f7
/*
rpm-build c487f7
 * Copyright © 2015 Red Hat, Inc
rpm-build c487f7
 *
rpm-build c487f7
 * This program is free software; you can redistribute it and/or
rpm-build c487f7
 * modify it under the terms of the GNU Lesser General Public
rpm-build c487f7
 * License as published by the Free Software Foundation; either
rpm-build c487f7
 * version 2.1 of the License, or (at your option) any later version.
rpm-build c487f7
 *
rpm-build c487f7
 * This library is distributed in the hope that it will be useful,
rpm-build c487f7
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
rpm-build c487f7
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
rpm-build c487f7
 * Lesser General Public License for more details.
rpm-build c487f7
 *
rpm-build c487f7
 * You should have received a copy of the GNU Lesser General Public
rpm-build c487f7
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
rpm-build c487f7
 *
rpm-build c487f7
 * Authors:
rpm-build c487f7
 *       Alexander Larsson <alexl@redhat.com>
rpm-build c487f7
 */
rpm-build c487f7
rpm-build c487f7
#ifndef __BUILDER_UTILS_H__
rpm-build c487f7
#define __BUILDER_UTILS_H__
rpm-build c487f7
rpm-build c487f7
#include <gio/gio.h>
rpm-build c487f7
#include <libsoup/soup.h>
rpm-build c487f7
#include <json-glib/json-glib.h>
rpm-build c487f7
#include <curl/curl.h>
rpm-build c487f7
rpm-build c487f7
#include <libxml/tree.h>
rpm-build c487f7
rpm-build c487f7
G_BEGIN_DECLS
rpm-build c487f7
rpm-build c487f7
#define BUILDER_N_CHECKSUMS 4 /* We currently support 4 checksum types */
rpm-build c487f7
#define BUILDER_CHECKSUMS_LEN (BUILDER_N_CHECKSUMS + 1) /* One more for null termination */
rpm-build c487f7
rpm-build c487f7
typedef struct BuilderUtils BuilderUtils;
rpm-build c487f7
rpm-build c487f7
char *builder_uri_to_filename (const char *uri);
rpm-build c487f7
rpm-build c487f7
gboolean strip (GError **error,
rpm-build c487f7
                ...);
rpm-build c487f7
gboolean eu_strip (GError **error,
rpm-build c487f7
                   ...);
rpm-build c487f7
gboolean eu_elfcompress (GError **error,
rpm-build c487f7
			 ...);
rpm-build c487f7
rpm-build c487f7
gboolean is_elf_file (const char *path,
rpm-build c487f7
                      gboolean   *is_shared,
rpm-build c487f7
                      gboolean   *is_stripped);
rpm-build c487f7
rpm-build c487f7
char ** builder_get_debuginfo_file_references (const char *filename,
rpm-build c487f7
                                               GError    **error);
rpm-build c487f7
rpm-build c487f7
gboolean directory_is_empty (const char *path);
rpm-build c487f7
rpm-build c487f7
gboolean flatpak_matches_path_pattern (const char *path,
rpm-build c487f7
                                       const char *pattern);
rpm-build c487f7
void     flatpak_collect_matches_for_path_pattern (const char *path,
rpm-build c487f7
                                                   const char *pattern,
rpm-build c487f7
                                                   const char *add_prefix,
rpm-build c487f7
                                                   GHashTable *to_remove_ht);
rpm-build c487f7
gboolean builder_migrate_locale_dirs (GFile   *root_dir,
rpm-build c487f7
                                      GError **error);
rpm-build c487f7
rpm-build c487f7
GQuark builder_curl_error_quark (void);
rpm-build c487f7
#define BUILDER_CURL_ERROR (builder_curl_error_quark ())
rpm-build c487f7
rpm-build c487f7
GQuark builder_yaml_parse_error_quark (void);
rpm-build c487f7
#define BUILDER_YAML_PARSE_ERROR (builder_yaml_parse_error_quark ())
rpm-build c487f7
rpm-build c487f7
JsonNode * builder_json_node_from_data (const char *relpath,
rpm-build c487f7
                                        const char *contents,
rpm-build c487f7
                                        GError    **error);
rpm-build c487f7
rpm-build c487f7
GObject * builder_gobject_from_data (GType       gtype,
rpm-build c487f7
                                     const char *relpath,
rpm-build c487f7
                                     const char *contents,
rpm-build c487f7
                                     GError    **error);
rpm-build c487f7
rpm-build c487f7
gboolean builder_host_spawnv (GFile                *dir,
rpm-build c487f7
                              char                **output,
rpm-build c487f7
                              GSubprocessFlags      flags,
rpm-build c487f7
                              GError              **error,
rpm-build c487f7
                              const gchar * const  *argv);
rpm-build c487f7
gboolean builder_maybe_host_spawnv (GFile                *dir,
rpm-build c487f7
                                    char                **output,
rpm-build c487f7
                                    GSubprocessFlags      flags,
rpm-build c487f7
                                    GError              **error,
rpm-build c487f7
                                    const gchar * const  *argv);
rpm-build c487f7
rpm-build c487f7
gboolean builder_download_uri (SoupURI        *uri,
rpm-build c487f7
                               GFile          *dest,
rpm-build c487f7
                               const char     *checksums[BUILDER_CHECKSUMS_LEN],
rpm-build c487f7
                               GChecksumType   checksums_type[BUILDER_CHECKSUMS_LEN],
rpm-build c487f7
                               CURL           *curl_session,
rpm-build c487f7
                               GError        **error);
rpm-build c487f7
rpm-build c487f7
gsize builder_get_all_checksums (const char *checksums[BUILDER_CHECKSUMS_LEN],
rpm-build c487f7
                                 GChecksumType checksums_type[BUILDER_CHECKSUMS_LEN],
rpm-build c487f7
                                 const char *md5,
rpm-build c487f7
                                 const char *sha1,
rpm-build c487f7
                                 const char *sha256,
rpm-build c487f7
                                 const char *sha512);
rpm-build c487f7
rpm-build c487f7
gboolean builder_verify_checksums (const char *name,
rpm-build c487f7
                                   GFile *file,
rpm-build c487f7
                                   const char *checksums[BUILDER_CHECKSUMS_LEN],
rpm-build c487f7
                                   GChecksumType checksums_type[BUILDER_CHECKSUMS_LEN],
rpm-build c487f7
                                   GError **error);
rpm-build c487f7
rpm-build c487f7
GParamSpec * builder_serializable_find_property (JsonSerializable *serializable,
rpm-build c487f7
                                                 const char       *name);
rpm-build c487f7
GParamSpec ** builder_serializable_list_properties (JsonSerializable *serializable,
rpm-build c487f7
                                                    guint            *n_pspecs);
rpm-build c487f7
gboolean builder_serializable_deserialize_property (JsonSerializable *serializable,
rpm-build c487f7
                                                    const gchar      *property_name,
rpm-build c487f7
                                                    GValue           *value,
rpm-build c487f7
                                                    GParamSpec       *pspec,
rpm-build c487f7
                                                    JsonNode         *property_node);
rpm-build c487f7
JsonNode * builder_serializable_serialize_property (JsonSerializable *serializable,
rpm-build c487f7
                                                    const gchar      *property_name,
rpm-build c487f7
                                                    const GValue     *value,
rpm-build c487f7
                                                    GParamSpec       *pspec);
rpm-build c487f7
void builder_serializable_get_property (JsonSerializable *serializable,
rpm-build c487f7
                                        GParamSpec       *pspec,
rpm-build c487f7
                                        GValue           *value);
rpm-build c487f7
void builder_serializable_set_property (JsonSerializable *serializable,
rpm-build c487f7
                                        GParamSpec       *pspec,
rpm-build c487f7
                                        const GValue     *value);
rpm-build c487f7
rpm-build c487f7
void builder_set_term_title (const gchar *format,
rpm-build c487f7
                             ...) G_GNUC_PRINTF (1, 2);
rpm-build c487f7
rpm-build c487f7
static inline void
rpm-build c487f7
xml_autoptr_cleanup_generic_free (void *p)
rpm-build c487f7
{
rpm-build c487f7
  void **pp = (void**)p;
rpm-build c487f7
  if (*pp)
rpm-build c487f7
    xmlFree (*pp);
rpm-build c487f7
}
rpm-build c487f7
rpm-build c487f7
#define xml_autofree _GLIB_CLEANUP(xml_autoptr_cleanup_generic_free)
rpm-build c487f7
rpm-build c487f7
G_DEFINE_AUTOPTR_CLEANUP_FUNC (xmlDoc, xmlFreeDoc)
rpm-build c487f7
rpm-build c487f7
typedef struct FlatpakXml FlatpakXml;
rpm-build c487f7
rpm-build c487f7
struct FlatpakXml
rpm-build c487f7
{
rpm-build c487f7
  gchar      *element_name; /* NULL == text */
rpm-build c487f7
  char      **attribute_names;
rpm-build c487f7
  char      **attribute_values;
rpm-build c487f7
  char       *text;
rpm-build c487f7
  FlatpakXml *parent;
rpm-build c487f7
  FlatpakXml *first_child;
rpm-build c487f7
  FlatpakXml *last_child;
rpm-build c487f7
  FlatpakXml *next_sibling;
rpm-build c487f7
};
rpm-build c487f7
rpm-build c487f7
FlatpakXml *flatpak_xml_new (const gchar *element_name);
rpm-build c487f7
FlatpakXml *flatpak_xml_new_text (const gchar *text);
rpm-build c487f7
void       flatpak_xml_add (FlatpakXml *parent,
rpm-build c487f7
                            FlatpakXml *node);
rpm-build c487f7
void       flatpak_xml_free (FlatpakXml *node);
rpm-build c487f7
FlatpakXml *flatpak_xml_parse (GInputStream *in,
rpm-build c487f7
                               gboolean      compressed,
rpm-build c487f7
                               GCancellable *cancellable,
rpm-build c487f7
                               GError      **error);
rpm-build c487f7
void       flatpak_xml_to_string (FlatpakXml *node,
rpm-build c487f7
                                  GString    *res);
rpm-build c487f7
FlatpakXml *flatpak_xml_unlink (FlatpakXml *node,
rpm-build c487f7
                                FlatpakXml *prev_sibling);
rpm-build c487f7
FlatpakXml *flatpak_xml_find (FlatpakXml  *node,
rpm-build c487f7
                              const char  *type,
rpm-build c487f7
                              FlatpakXml **prev_child_out);
rpm-build c487f7
rpm-build c487f7
GBytes *   flatpak_read_stream (GInputStream *in,
rpm-build c487f7
                                gboolean      null_terminate,
rpm-build c487f7
                                GError      **error);
rpm-build c487f7
GVariant * flatpak_variant_compress (GVariant *variant);
rpm-build c487f7
GVariant * flatpak_variant_uncompress (GVariant *variant, const GVariantType *type);
rpm-build c487f7
rpm-build c487f7
rpm-build c487f7
gboolean flatpak_version_check (int major,
rpm-build c487f7
                                int minor,
rpm-build c487f7
                                int micro);
rpm-build c487f7
rpm-build c487f7
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FlatpakXml, flatpak_xml_free);
rpm-build c487f7
rpm-build c487f7
G_END_DECLS
rpm-build c487f7
rpm-build c487f7
#endif /* __BUILDER_UTILS_H__ */