Richard Hughes | 943d2c9 | 2017-06-21 09:04:39 +0100 | [diff] [blame] | 1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- |
| 2 | * |
| 3 | * Copyright (C) 2017 Richard Hughes <richard@hughsie.com> |
| 4 | * |
Mario Limonciello | 51308e6 | 2018-05-28 20:05:46 -0500 | [diff] [blame] | 5 | * SPDX-License-Identifier: LGPL-2.1+ |
Richard Hughes | 943d2c9 | 2017-06-21 09:04:39 +0100 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #ifndef __FU_COMMON_H__ |
| 9 | #define __FU_COMMON_H__ |
| 10 | |
Richard Hughes | adc9dad | 2017-09-04 13:19:27 +0100 | [diff] [blame] | 11 | #include <gio/gio.h> |
Richard Hughes | 943d2c9 | 2017-06-21 09:04:39 +0100 | [diff] [blame] | 12 | |
Richard Hughes | 5b5f655 | 2018-05-18 10:22:39 +0100 | [diff] [blame] | 13 | typedef enum { |
| 14 | FU_APP_FLAGS_NONE = 0, |
| 15 | FU_APP_FLAGS_NO_IDLE_SOURCES = 1 << 0, |
| 16 | FU_APP_FLAGS_LAST |
| 17 | } FuAppFlags; |
| 18 | |
Richard Hughes | 049ccc8 | 2017-08-09 15:26:56 +0100 | [diff] [blame] | 19 | typedef void (*FuOutputHandler) (const gchar *line, |
| 20 | gpointer user_data); |
| 21 | |
| 22 | gboolean fu_common_spawn_sync (const gchar * const *argv, |
Richard Hughes | 4eada34 | 2017-10-03 21:20:32 +0100 | [diff] [blame] | 23 | FuOutputHandler handler_cb, |
Richard Hughes | 049ccc8 | 2017-08-09 15:26:56 +0100 | [diff] [blame] | 24 | gpointer handler_user_data, |
| 25 | GCancellable *cancellable, |
| 26 | GError **error); |
| 27 | |
Richard Hughes | 954dd9f | 2017-08-08 13:36:25 +0100 | [diff] [blame] | 28 | gboolean fu_common_rmtree (const gchar *directory, |
| 29 | GError **error); |
Richard Hughes | 89e968b | 2018-03-07 10:01:08 +0000 | [diff] [blame] | 30 | GPtrArray *fu_common_get_files_recursive (const gchar *path, |
| 31 | GError **error); |
Richard Hughes | 7ee42fe | 2017-08-15 14:06:21 +0100 | [diff] [blame] | 32 | gboolean fu_common_mkdir_parent (const gchar *filename, |
| 33 | GError **error); |
Richard Hughes | 943d2c9 | 2017-06-21 09:04:39 +0100 | [diff] [blame] | 34 | gboolean fu_common_set_contents_bytes (const gchar *filename, |
Richard Hughes | 4eada34 | 2017-10-03 21:20:32 +0100 | [diff] [blame] | 35 | GBytes *bytes, |
Richard Hughes | 943d2c9 | 2017-06-21 09:04:39 +0100 | [diff] [blame] | 36 | GError **error); |
Richard Hughes | d0d2ae6 | 2017-08-08 12:22:30 +0100 | [diff] [blame] | 37 | GBytes *fu_common_get_contents_bytes (const gchar *filename, |
| 38 | GError **error); |
Richard Hughes | 943d2c9 | 2017-06-21 09:04:39 +0100 | [diff] [blame] | 39 | GBytes *fu_common_get_contents_fd (gint fd, |
| 40 | gsize count, |
| 41 | GError **error); |
Richard Hughes | 94f939a | 2017-08-08 12:21:39 +0100 | [diff] [blame] | 42 | gboolean fu_common_extract_archive (GBytes *blob, |
| 43 | const gchar *dir, |
| 44 | GError **error); |
Richard Hughes | 41cbe2a | 2017-08-08 14:13:35 +0100 | [diff] [blame] | 45 | GBytes *fu_common_firmware_builder (GBytes *bytes, |
| 46 | const gchar *script_fn, |
| 47 | const gchar *output_fn, |
| 48 | GError **error); |
Richard Hughes | e82eef3 | 2018-05-20 10:41:26 +0100 | [diff] [blame] | 49 | GError *fu_common_error_array_get_best (GPtrArray *errors); |
Richard Hughes | 943d2c9 | 2017-06-21 09:04:39 +0100 | [diff] [blame] | 50 | |
Richard Hughes | ae252cd | 2017-12-08 10:48:15 +0000 | [diff] [blame] | 51 | typedef guint FuEndianType; |
| 52 | |
| 53 | void fu_common_write_uint16 (guint8 *buf, |
| 54 | guint16 val_native, |
| 55 | FuEndianType endian); |
| 56 | void fu_common_write_uint32 (guint8 *buf, |
| 57 | guint32 val_native, |
| 58 | FuEndianType endian); |
| 59 | guint16 fu_common_read_uint16 (const guint8 *buf, |
| 60 | FuEndianType endian); |
| 61 | guint32 fu_common_read_uint32 (const guint8 *buf, |
| 62 | FuEndianType endian); |
| 63 | |
Richard Hughes | 943d2c9 | 2017-06-21 09:04:39 +0100 | [diff] [blame] | 64 | #endif /* __FU_COMMON_H__ */ |