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 | * |
| 5 | * Licensed under the GNU General Public License Version 2 |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | */ |
| 21 | |
| 22 | #ifndef __FU_COMMON_H__ |
| 23 | #define __FU_COMMON_H__ |
| 24 | |
Richard Hughes | adc9dad | 2017-09-04 13:19:27 +0100 | [diff] [blame] | 25 | #include <gio/gio.h> |
Richard Hughes | 943d2c9 | 2017-06-21 09:04:39 +0100 | [diff] [blame] | 26 | |
Richard Hughes | 5b5f655 | 2018-05-18 10:22:39 +0100 | [diff] [blame^] | 27 | typedef enum { |
| 28 | FU_APP_FLAGS_NONE = 0, |
| 29 | FU_APP_FLAGS_NO_IDLE_SOURCES = 1 << 0, |
| 30 | FU_APP_FLAGS_LAST |
| 31 | } FuAppFlags; |
| 32 | |
Richard Hughes | 049ccc8 | 2017-08-09 15:26:56 +0100 | [diff] [blame] | 33 | typedef void (*FuOutputHandler) (const gchar *line, |
| 34 | gpointer user_data); |
| 35 | |
| 36 | gboolean fu_common_spawn_sync (const gchar * const *argv, |
Richard Hughes | 4eada34 | 2017-10-03 21:20:32 +0100 | [diff] [blame] | 37 | FuOutputHandler handler_cb, |
Richard Hughes | 049ccc8 | 2017-08-09 15:26:56 +0100 | [diff] [blame] | 38 | gpointer handler_user_data, |
| 39 | GCancellable *cancellable, |
| 40 | GError **error); |
| 41 | |
Richard Hughes | 954dd9f | 2017-08-08 13:36:25 +0100 | [diff] [blame] | 42 | gboolean fu_common_rmtree (const gchar *directory, |
| 43 | GError **error); |
Richard Hughes | 89e968b | 2018-03-07 10:01:08 +0000 | [diff] [blame] | 44 | GPtrArray *fu_common_get_files_recursive (const gchar *path, |
| 45 | GError **error); |
Richard Hughes | 7ee42fe | 2017-08-15 14:06:21 +0100 | [diff] [blame] | 46 | gboolean fu_common_mkdir_parent (const gchar *filename, |
| 47 | GError **error); |
Richard Hughes | 943d2c9 | 2017-06-21 09:04:39 +0100 | [diff] [blame] | 48 | gboolean fu_common_set_contents_bytes (const gchar *filename, |
Richard Hughes | 4eada34 | 2017-10-03 21:20:32 +0100 | [diff] [blame] | 49 | GBytes *bytes, |
Richard Hughes | 943d2c9 | 2017-06-21 09:04:39 +0100 | [diff] [blame] | 50 | GError **error); |
Richard Hughes | d0d2ae6 | 2017-08-08 12:22:30 +0100 | [diff] [blame] | 51 | GBytes *fu_common_get_contents_bytes (const gchar *filename, |
| 52 | GError **error); |
Richard Hughes | 943d2c9 | 2017-06-21 09:04:39 +0100 | [diff] [blame] | 53 | GBytes *fu_common_get_contents_fd (gint fd, |
| 54 | gsize count, |
| 55 | GError **error); |
Richard Hughes | 94f939a | 2017-08-08 12:21:39 +0100 | [diff] [blame] | 56 | gboolean fu_common_extract_archive (GBytes *blob, |
| 57 | const gchar *dir, |
| 58 | GError **error); |
Richard Hughes | 41cbe2a | 2017-08-08 14:13:35 +0100 | [diff] [blame] | 59 | GBytes *fu_common_firmware_builder (GBytes *bytes, |
| 60 | const gchar *script_fn, |
| 61 | const gchar *output_fn, |
| 62 | GError **error); |
Richard Hughes | 943d2c9 | 2017-06-21 09:04:39 +0100 | [diff] [blame] | 63 | |
Richard Hughes | ae252cd | 2017-12-08 10:48:15 +0000 | [diff] [blame] | 64 | typedef guint FuEndianType; |
| 65 | |
| 66 | void fu_common_write_uint16 (guint8 *buf, |
| 67 | guint16 val_native, |
| 68 | FuEndianType endian); |
| 69 | void fu_common_write_uint32 (guint8 *buf, |
| 70 | guint32 val_native, |
| 71 | FuEndianType endian); |
| 72 | guint16 fu_common_read_uint16 (const guint8 *buf, |
| 73 | FuEndianType endian); |
| 74 | guint32 fu_common_read_uint32 (const guint8 *buf, |
| 75 | FuEndianType endian); |
| 76 | |
Richard Hughes | 943d2c9 | 2017-06-21 09:04:39 +0100 | [diff] [blame] | 77 | #endif /* __FU_COMMON_H__ */ |