1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
/*
* Copyright 2017 Richard Hughes <richard@hughsie.com>
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#pragma once
#include <fwupd.h>
#include "fu-endian.h"
typedef enum {
FU_INTEGER_BASE_AUTO = 0,
FU_INTEGER_BASE_10 = 10,
FU_INTEGER_BASE_16 = 16,
} FuIntegerBase;
gchar *
fu_strsafe(const gchar *str, gsize maxsz);
gchar *
fu_strsafe_bytes(GBytes *blob, gsize maxsz);
gchar *
fu_strpassmask(const gchar *str) G_GNUC_NON_NULL(1);
gboolean
fu_strtoull(const gchar *str,
guint64 *value,
guint64 min,
guint64 max,
FuIntegerBase base,
GError **error);
gboolean
fu_strtoll(const gchar *str,
gint64 *value,
gint64 min,
gint64 max,
FuIntegerBase base,
GError **error);
gboolean
fu_strtobool(const gchar *str, gboolean *value, GError **error);
gchar *
fu_strstrip(const gchar *str) G_GNUC_NON_NULL(1);
gsize
fu_strwidth(const gchar *text) G_GNUC_NON_NULL(1);
gchar **
fu_strsplit(const gchar *str, gsize sz, const gchar *delimiter, gint max_tokens) G_GNUC_NON_NULL(1);
gchar **
fu_strsplit_bytes(GBytes *blob, const gchar *delimiter, gint max_tokens) G_GNUC_NON_NULL(1);
gchar *
fu_strjoin(const gchar *separator, GPtrArray *array) G_GNUC_NON_NULL(1, 2);
GString *
fu_strdup(const gchar *str, gsize bufsz, gsize offset) G_GNUC_NON_NULL(1);
void
fu_string_strip(GString *str) G_GNUC_NON_NULL(1);
/**
* FuStrsplitFunc:
* @token: a #GString
* @token_idx: the token number
* @user_data: (closure): user data
* @error: a #GError or NULL
*
* The fu_strsplit_full() iteration callback.
*/
typedef gboolean (*FuStrsplitFunc)(GString *token,
guint token_idx,
gpointer user_data,
GError **error);
gboolean
fu_strsplit_full(const gchar *str,
gssize sz,
const gchar *delimiter,
FuStrsplitFunc callback,
gpointer user_data,
GError **error) G_GNUC_NON_NULL(1, 3);
gboolean
fu_strsplit_stream(GInputStream *stream,
gsize offset,
const gchar *delimiter,
FuStrsplitFunc callback,
gpointer user_data,
GError **error) G_GNUC_NON_NULL(1, 3);
/**
* FuUtfConvertFlags:
* @FU_UTF_CONVERT_FLAG_NONE: No flags set
* @FU_UTF_CONVERT_FLAG_APPEND_NUL: Include the trailing `NUL` or `NULw` in the buffer
*
* The flags to use when converting to and from UTF-8.
**/
typedef enum {
FU_UTF_CONVERT_FLAG_NONE = 0,
FU_UTF_CONVERT_FLAG_APPEND_NUL = 1 << 0,
} G_GNUC_FLAG_ENUM FuUtfConvertFlags;
gchar *
fu_utf16_to_utf8_byte_array(GByteArray *array, FuEndianType endian, GError **error)
G_GNUC_NON_NULL(1);
GByteArray *
fu_utf8_to_utf16_byte_array(const gchar *str,
FuEndianType endian,
FuUtfConvertFlags flags,
GError **error) G_GNUC_NON_NULL(1);
gchar *
fu_utf16_to_utf8_bytes(GBytes *bytes, FuEndianType endian, GError **error) G_GNUC_NON_NULL(1);
GBytes *
fu_utf8_to_utf16_bytes(const gchar *str,
FuEndianType endian,
FuUtfConvertFlags flags,
GError **error) G_GNUC_NON_NULL(1);
|