blob: c31177b83857105b85f45f6a56cea37bce0f836c [file] [log] [blame]
Richard Hughes943d2c92017-06-21 09:04:39 +01001/* -*- 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 Hughesadc9dad2017-09-04 13:19:27 +010025#include <gio/gio.h>
Richard Hughes943d2c92017-06-21 09:04:39 +010026
Richard Hughes049ccc82017-08-09 15:26:56 +010027typedef void (*FuOutputHandler) (const gchar *line,
28 gpointer user_data);
29
30gboolean fu_common_spawn_sync (const gchar * const *argv,
Richard Hughes4eada342017-10-03 21:20:32 +010031 FuOutputHandler handler_cb,
Richard Hughes049ccc82017-08-09 15:26:56 +010032 gpointer handler_user_data,
33 GCancellable *cancellable,
34 GError **error);
35
Richard Hughes954dd9f2017-08-08 13:36:25 +010036gboolean fu_common_rmtree (const gchar *directory,
37 GError **error);
Richard Hughes7ee42fe2017-08-15 14:06:21 +010038gboolean fu_common_mkdir_parent (const gchar *filename,
39 GError **error);
Richard Hughes943d2c92017-06-21 09:04:39 +010040gboolean fu_common_set_contents_bytes (const gchar *filename,
Richard Hughes4eada342017-10-03 21:20:32 +010041 GBytes *bytes,
Richard Hughes943d2c92017-06-21 09:04:39 +010042 GError **error);
Richard Hughesd0d2ae62017-08-08 12:22:30 +010043GBytes *fu_common_get_contents_bytes (const gchar *filename,
44 GError **error);
Richard Hughes943d2c92017-06-21 09:04:39 +010045GBytes *fu_common_get_contents_fd (gint fd,
46 gsize count,
47 GError **error);
Richard Hughes94f939a2017-08-08 12:21:39 +010048gboolean fu_common_extract_archive (GBytes *blob,
49 const gchar *dir,
50 GError **error);
Richard Hughes41cbe2a2017-08-08 14:13:35 +010051GBytes *fu_common_firmware_builder (GBytes *bytes,
52 const gchar *script_fn,
53 const gchar *output_fn,
54 GError **error);
Richard Hughes943d2c92017-06-21 09:04:39 +010055
Richard Hughesae252cd2017-12-08 10:48:15 +000056typedef guint FuEndianType;
57
58void fu_common_write_uint16 (guint8 *buf,
59 guint16 val_native,
60 FuEndianType endian);
61void fu_common_write_uint32 (guint8 *buf,
62 guint32 val_native,
63 FuEndianType endian);
64guint16 fu_common_read_uint16 (const guint8 *buf,
65 FuEndianType endian);
66guint32 fu_common_read_uint32 (const guint8 *buf,
67 FuEndianType endian);
68
Richard Hughes943d2c92017-06-21 09:04:39 +010069#endif /* __FU_COMMON_H__ */