blob: 7b6337a549f0abf7f10c0b327413b3eacfbbc08c [file] [log] [blame]
Richard Hughes02c90d82018-08-09 12:13:03 +01001/*
Richard Hughes943d2c92017-06-21 09:04:39 +01002 * Copyright (C) 2017 Richard Hughes <richard@hughsie.com>
3 *
Mario Limonciello51308e62018-05-28 20:05:46 -05004 * SPDX-License-Identifier: LGPL-2.1+
Richard Hughes943d2c92017-06-21 09:04:39 +01005 */
6
7#ifndef __FU_COMMON_H__
8#define __FU_COMMON_H__
9
Richard Hughesadc9dad2017-09-04 13:19:27 +010010#include <gio/gio.h>
Richard Hughes943d2c92017-06-21 09:04:39 +010011
Richard Hughes5b5f6552018-05-18 10:22:39 +010012typedef enum {
13 FU_APP_FLAGS_NONE = 0,
14 FU_APP_FLAGS_NO_IDLE_SOURCES = 1 << 0,
15 FU_APP_FLAGS_LAST
16} FuAppFlags;
17
Richard Hughes4be17d12018-05-30 20:36:29 +010018typedef enum {
19 FU_PATH_KIND_CACHEDIR_PKG,
20 FU_PATH_KIND_DATADIR_PKG,
Mario Limoncielloe6e2bf92018-07-10 12:11:25 -050021 FU_PATH_KIND_EFIAPPDIR,
Richard Hughes4be17d12018-05-30 20:36:29 +010022 FU_PATH_KIND_LOCALSTATEDIR,
23 FU_PATH_KIND_LOCALSTATEDIR_PKG,
24 FU_PATH_KIND_PLUGINDIR_PKG,
25 FU_PATH_KIND_SYSCONFDIR,
26 FU_PATH_KIND_SYSCONFDIR_PKG,
Richard Hughes282b10d2018-06-22 14:48:00 +010027 FU_PATH_KIND_SYSFSDIR_FW,
Richard Hughes83390f62018-06-22 20:36:46 +010028 FU_PATH_KIND_SYSFSDIR_DRIVERS,
Richard Hughes4be17d12018-05-30 20:36:29 +010029 FU_PATH_KIND_LAST
30} FuPathKind;
31
Richard Hughes049ccc82017-08-09 15:26:56 +010032typedef void (*FuOutputHandler) (const gchar *line,
33 gpointer user_data);
34
35gboolean fu_common_spawn_sync (const gchar * const *argv,
Richard Hughes4eada342017-10-03 21:20:32 +010036 FuOutputHandler handler_cb,
Richard Hughes049ccc82017-08-09 15:26:56 +010037 gpointer handler_user_data,
38 GCancellable *cancellable,
39 GError **error);
40
Richard Hughes4be17d12018-05-30 20:36:29 +010041gchar *fu_common_get_path (FuPathKind path_kind);
Richard Hughes954dd9f2017-08-08 13:36:25 +010042gboolean fu_common_rmtree (const gchar *directory,
43 GError **error);
Richard Hughes89e968b2018-03-07 10:01:08 +000044GPtrArray *fu_common_get_files_recursive (const gchar *path,
45 GError **error);
Richard Hughes7ee42fe2017-08-15 14:06:21 +010046gboolean fu_common_mkdir_parent (const gchar *filename,
47 GError **error);
Richard Hughes943d2c92017-06-21 09:04:39 +010048gboolean fu_common_set_contents_bytes (const gchar *filename,
Richard Hughes4eada342017-10-03 21:20:32 +010049 GBytes *bytes,
Richard Hughes943d2c92017-06-21 09:04:39 +010050 GError **error);
Richard Hughesd0d2ae62017-08-08 12:22:30 +010051GBytes *fu_common_get_contents_bytes (const gchar *filename,
52 GError **error);
Richard Hughes943d2c92017-06-21 09:04:39 +010053GBytes *fu_common_get_contents_fd (gint fd,
54 gsize count,
55 GError **error);
Richard Hughes94f939a2017-08-08 12:21:39 +010056gboolean fu_common_extract_archive (GBytes *blob,
57 const gchar *dir,
58 GError **error);
Richard Hughes41cbe2a2017-08-08 14:13:35 +010059GBytes *fu_common_firmware_builder (GBytes *bytes,
60 const gchar *script_fn,
61 const gchar *output_fn,
62 GError **error);
Richard Hughese82eef32018-05-20 10:41:26 +010063GError *fu_common_error_array_get_best (GPtrArray *errors);
Richard Hughes73bf2332018-08-28 09:38:09 +010064guint64 fu_common_strtoull (const gchar *str);
Richard Hughes943d2c92017-06-21 09:04:39 +010065
Richard Hughesae252cd2017-12-08 10:48:15 +000066typedef guint FuEndianType;
67
68void fu_common_write_uint16 (guint8 *buf,
69 guint16 val_native,
70 FuEndianType endian);
71void fu_common_write_uint32 (guint8 *buf,
72 guint32 val_native,
73 FuEndianType endian);
74guint16 fu_common_read_uint16 (const guint8 *buf,
75 FuEndianType endian);
76guint32 fu_common_read_uint32 (const guint8 *buf,
77 FuEndianType endian);
78
Richard Hughes943d2c92017-06-21 09:04:39 +010079#endif /* __FU_COMMON_H__ */