|
Defines |
#define | SIZE_FIELD_MAX 64 /**< Max size of sprintf-ed size quantity */ |
| Max size of sprintf-ed size quantity.
|
#define | GUID_RAW_SIZE 16 /**< Binary representation of 128 bits */ |
| Binary representation of 128 bits.
|
#define | GUID_HEX_SIZE 32 /**< Hexadecimal GUID representation */ |
| Hexadecimal GUID representation.
|
#define | g_string_printf g_string_sprintf |
#define | g_strlcpy strlcpy |
#define | g_strlcat strlcat |
#define | CONST_STRLEN(x) (sizeof(x) - 1) |
#define | G_N_ELEMENTS(arr) (sizeof (arr) / sizeof ((arr)[0])) |
#define | set_flags(r, f) (r |= (f)) |
#define | clear_flags(r, f) (r &= ~(f)) |
#define | UINT8_HEX_BUFLEN (sizeof "FF") |
#define | UINT8_DEC_BUFLEN (sizeof "255") |
#define | UINT16_HEX_BUFLEN (sizeof "01234") |
#define | UINT16_DEC_BUFLEN (sizeof "65535") |
#define | UINT32_HEX_BUFLEN (sizeof "012345678") |
#define | UINT32_DEC_BUFLEN (sizeof "4294967295") |
#define | UINT64_HEX_BUFLEN (sizeof "0123456789ABCDEF") |
#define | UINT64_DEC_BUFLEN (sizeof "18446744073709551615") |
#define | IPV4_ADDR_BUFLEN (sizeof "255.255.255.255") |
#define | IPV6_ADDR_BUFLEN (sizeof "0001:0203:0405:0607:0809:1011:255.255.255.255") |
#define | TIMESTAMP_BUF_LEN (sizeof "9999-12-31 23:59:61") |
#define | port_is_valid(port) (port != 0) |
#define | USE_DIFFTIME |
#define | delta_time(a, b) ((gint64) difftime((a), (b))) |
#define | NULL_STRING(s) (NULL != (s) ? (s) : "(null)") |
#define | EMPTY_STRING(s) (NULL != (s) ? (s) : "") |
#define | BINARY_SEARCH(bs_type, bs_key, bs_size, bs_cmp, bs_get_key, bs_found) |
| Perform a binary search over an array.
|
#define | BINARY_ARRAY_SORTED(bs_array, bs_type, bs_field, bs_cmp, bs_field2str) |
| Ensure a table used for binary search is sorted.
|
Typedefs |
typedef void(* | func_ptr_t )(void) |
typedef guint16 | flag_t |
typedef void(* | signal_handler_t )(gint signo) |
typedef void(* | cidr_split_t )(guint32 ip, guint bits, gpointer udata) |
Functions |
size_t | strlcpy (gchar *dst, const gchar *src, size_t dst_size) |
| Needs to be defined if we are not using Glib 2.
|
size_t | strlcat (gchar *dst, const gchar *src, size_t dst_size) |
size_t | concat_strings (gchar *dst, size_t size, const gchar *s,...) WARN_NEED_SENTINEL |
| Concatenates a variable number of NUL-terminated strings into ``dst''.
|
size_t | w_concat_strings (gchar **dst, const gchar *first,...) WARN_NEED_SENTINEL |
| Concatenates a variable number of NUL-terminated strings into buffer which will be allocated using walloc().
|
G_GNUC_CONST WARN_UNUSED_RESULT
gchar * | deconstify_gchar (const gchar *p) |
| Cast a ``const gchar *'' to ``gchar *''.
|
G_GNUC_CONST WARN_UNUSED_RESULT
guint32 * | deconstify_guint32 (const guint32 *p) |
G_GNUC_CONST WARN_UNUSED_RESULT
gpointer | deconstify_gpointer (gconstpointer p) |
G_GNUC_CONST WARN_UNUSED_RESULT
gconstpointer | cast_to_gconstpointer (gconstpointer p) |
G_GNUC_CONST WARN_UNUSED_RESULT
gpointer | cast_to_gpointer (gpointer p) |
G_GNUC_CONST WARN_UNUSED_RESULT
gchar * | cast_to_gchar_ptr (gpointer p) |
G_GNUC_CONST WARN_UNUSED_RESULT
guchar * | cast_to_guchar_ptr (gpointer p) |
G_GNUC_CONST WARN_UNUSED_RESULT
gpointer | cast_func_to_gpointer (func_ptr_t f) |
G_GNUC_CONST WARN_UNUSED_RESULT
func_ptr_t | cast_gpointer_to_func (gconstpointer p) |
gint | ascii_strcasecmp (const gchar *s1, const gchar *s2) |
| Same as strcasecmp() but only case-insensitive for ASCII characters.
|
gint | ascii_strncasecmp (const gchar *s1, const gchar *s2, size_t len) |
| Same as strncasecmp() but only case-insensitive for ASCII characters.
|
gint | hex2int_inline (guchar c) |
| Converts a hexadecimal char (0-9, A-F, a-f) to an integer.
|
gint | dec2int_inline (guchar c) |
| Converts a decimal char (0-9) to an integer.
|
gint | alnum2int_inline (guchar c) |
| Converts an alphanumeric char (0-9, A-Z, a-z) to an integer.
|
G_GNUC_CONST WARN_UNUSED_RESULT
gboolean | is_ascii_blank (gint c) |
| ctype-like functions that allow only ASCII characters whereas the locale would allow others.
|
G_GNUC_CONST WARN_UNUSED_RESULT
gboolean | is_ascii_cntrl (gint c) |
G_GNUC_CONST WARN_UNUSED_RESULT
gboolean | is_ascii_digit (gint c) |
G_GNUC_CONST WARN_UNUSED_RESULT
gboolean | is_ascii_xdigit (gint c) |
G_GNUC_CONST WARN_UNUSED_RESULT
gboolean | is_ascii_upper (gint c) |
G_GNUC_CONST WARN_UNUSED_RESULT
gboolean | is_ascii_lower (gint c) |
G_GNUC_CONST WARN_UNUSED_RESULT
gboolean | is_ascii_alpha (gint c) |
G_GNUC_CONST WARN_UNUSED_RESULT
gboolean | is_ascii_alnum (gint c) |
G_GNUC_CONST WARN_UNUSED_RESULT
gboolean | is_ascii_space (gint c) |
G_GNUC_CONST WARN_UNUSED_RESULT
gboolean | is_ascii_graph (gint c) |
G_GNUC_CONST WARN_UNUSED_RESULT
gboolean | is_ascii_print (gint c) |
G_GNUC_CONST WARN_UNUSED_RESULT
gboolean | is_ascii_punct (gint c) |
G_GNUC_CONST WARN_UNUSED_RESULT
gint | ascii_toupper (gint c) |
G_GNUC_CONST WARN_UNUSED_RESULT
gint | ascii_tolower (gint c) |
WARN_UNUSED_RESULT const gchar * | g_strip_context (const gchar *id, const gchar *val) |
WARN_UNUSED_RESULT gchar * | skip_ascii_spaces (const gchar *s) |
| Skips over all ASCII space characters starting at ``s''.
|
WARN_UNUSED_RESULT gchar * | skip_ascii_blanks (const gchar *s) |
| Skips over all ASCII blank characters starting at ``s''.
|
gboolean | parse_ipv6_addr (const gchar *s, uint8_t *dst, const gchar **endptr) |
const gchar * | ipv6_to_string (const guint8 *ipv6) |
| Prints the IPv6 address ``ipv6'' to a static buffer.
|
size_t | ipv6_to_string_buf (const guint8 *ipv6, gchar *dst, size_t size) |
guint32 | string_to_ip (const gchar *) |
gboolean | string_to_ip_strict (const gchar *s, guint32 *addr, const gchar **ep) |
| A strict string to IP address conversion; when other stuff from misc.[ch] is not sufficient.
|
gboolean | string_to_ip_and_mask (const gchar *str, guint32 *ip, guint32 *netmask) |
| Extracts the IP address into `ip' and the netmask into `netmask'.
|
gboolean | string_to_ip_port (const gchar *str, guint32 *ip, guint16 *port) |
| Decompiles ip:port into ip and port.
|
const gchar * | ip_to_string (guint32) |
const gchar * | ip_to_string2 (guint32) |
size_t | ip_to_string_buf (guint32 ip, gchar *buf, size_t size) |
const gchar * | ip_port_to_string (guint32, guint16) |
const gchar * | hostname_port_to_string (const gchar *hostname, guint16 port) |
const gchar * | local_hostname (void) |
const gchar * | timestamp_to_string (time_t date) |
| Convert time to ISO 8601 date plus time, e.g.
|
const gchar * | timestamp_utc_to_string (time_t date) |
| Convert time to an ISO 8601 timestamp, e.g.
|
const gchar * | timestamp_rfc822_to_string (time_t date) |
| Convert time to RFC-822 style date.
|
const gchar * | timestamp_rfc822_to_string2 (time_t date) |
| Same as date_to_rfc822_gchar(), to be able to use the two in the same printf() line.
|
const gchar * | timestamp_rfc1123_to_string (time_t date) |
| Convert time to RFC-1123 style date.
|
size_t | timestamp_to_string_buf (time_t date, gchar *dst, size_t size) |
| Convert time to ISO 8601 date plus time, e.g.
|
size_t | time_locale_to_string_buf (time_t date, gchar *dst, size_t size) |
| Convert time (without the date) to a human-readable string using the time representation of the current locale.
|
gchar * | short_time (gint s) |
gchar * | short_uptime (gint s) |
| Alternate time formatter for uptime.
|
const gchar * | short_size (guint64 size) |
const gchar * | short_html_size (guint64 size) |
| Like short_size() but with unbreakable space between the digits and unit.
|
const gchar * | short_kb_size (guint64 size) |
const gchar * | short_rate (guint64 rate) |
const gchar * | compact_size (guint64 size) |
const gchar * | compact_rate (guint64 rate) |
const gchar * | compact_kb_size (guint32 size) |
gchar * | short_value (gchar *buf, size_t size, guint64 v) |
gchar * | compact_value (gchar *buf, size_t size, guint64 v) |
gchar * | sha1_base32 (const gchar *sha1) |
| Convert binary SHA1 into a base32 string.
|
gchar * | base32_sha1 (const gchar *base32) |
| Convert base32 string into binary SHA1.
|
gchar * | guid_hex_str (const gchar *guid) |
gboolean | hex_to_guid (const gchar *hexguid, gchar *guid) |
| Converts hexadecimal string into a GUID.
|
gchar * | guid_base32_str (const gchar *guid) |
| Converts GUID into its base32 representation, without the trailing padding.
|
gchar * | base32_to_guid (const gchar *base32) |
| Decode the base32 representation of a GUID.
|
gboolean | is_absolute_path (const char *) |
| Check whether path is an absolute path.
|
gboolean | is_directory (const gchar *) |
| Check whether path is a directory.
|
gboolean | is_regular (const gchar *) |
| Check whether path points to a regular file.
|
gboolean | is_symlink (const gchar *) |
| Check whether path is a symbolic link.
|
gboolean | file_exists (const gchar *) |
| Check for file existence.
|
guint32 | next_pow2 (guint32 n) |
G_GNUC_CONST gboolean | is_pow2 (guint32 value) |
| Checks whether the given value is a power of 2.
|
void | random_init (void) |
| Initialize random number generator.
|
guint32 | random_value (guint32 max) WARN_UNUSED_RESULT |
void | guid_random_fill (gchar *xuid) |
| Generate a new random GUID within given `xuid'.
|
void | misc_init (void) |
gint | str_chomp (gchar *str, gint len) |
| Remove antepenultimate char of string if it is a "\r" followed by "\n".
|
gint | hex2int (guchar c) |
| Converts a hexadecimal char (0-9, A-F, a-f) to an integer.
|
gboolean | is_printable (const gchar *buf, gint len) |
| Check whether buffer contains printable data, suitable for "%s" printing.
|
void | dump_hex (FILE *, const gchar *, gconstpointer, gint) |
| Displays hex & ascii lines to the terminal (for debug) Displays the "title" then the characters in "s", # of bytes to print in "b".
|
void | locale_strlower (gchar *, const gchar *) |
| Copies ``src'' to ``dst'', converting all upper-case characters to lower-case.
|
void | ascii_strlower (gchar *dst, const gchar *src) |
| Copies ``src'' to ``dst'', converting all ASCII upper-case characters to ASCII lower-case.
|
gint | strcmp_delimit (const gchar *a, const gchar *b, const gchar *delimit) |
| Compare two strings case-senstive up to the specified delimiters.
|
gint | strcasecmp_delimit (const gchar *a, const gchar *b, const gchar *delimit) |
| Compare two strings case-insensitive up to the specified delimiters.
|
char * | unique_filename (const gchar *path, const gchar *file, const gchar *ext) |
| Determine unique filename for `file' in `path', with optional trailing extension `ext'.
|
gchar * | hex_escape (const gchar *name, gboolean strict) |
| Escape all non-printable chars into the hexadecimal "\xhh" form.
|
gchar * | control_escape (const gchar *s) |
| Escape all ASCII control chars (except into the hexadecimal "\xhh" form.
|
const gchar * | lazy_string_to_printf_escape (const gchar *src) |
| Escapes a string so that it can be used careless with the POSIX printf tool.
|
gint | highest_bit_set (guint32 n) G_GNUC_CONST |
| Determine the highest bit set in `n', -1 if value was 0.
|
gfloat | force_range (gfloat value, gfloat min, gfloat max) |
| Enforce range boundaries on a given floating point number.
|
gchar * | make_pathname (const gchar *dir, const gchar *file) |
| Create new pathname from the concatenation of the dirname and the basename of the file.
|
gchar * | short_filename (gchar *fullname) |
| Determine stripped down path, removing SRC_PREFIX if present.
|
gchar * | data_hex_str (const gchar *data, size_t len) |
gint | create_directory (const gchar *dir) |
| Creates the given directory including sub-directories if necessary.
|
gboolean | filepath_exists (const gchar *dir, const gchar *file) |
| Check whether file given by its dirname and its basename exists.
|
guint16 | parse_uint16 (const gchar *, gchar const **, guint, gint *) |
guint32 | parse_uint32 (const gchar *, gchar const **, guint, gint *) |
guint64 | parse_uint64 (const gchar *, gchar const **, guint, gint *) |
size_t | uint32_to_string_buf (guint64 v, gchar *dst, size_t size) |
size_t | uint64_to_string_buf (guint64 v, gchar *dst, size_t size) |
const gchar * | uint32_to_string (guint32 v) |
const gchar * | uint64_to_string (guint64 v) |
const gchar * | uint64_to_string2 (guint64 v) |
gint | parse_major_minor (const gchar *src, gchar const **endptr, guint *major, guint *minor) |
gchar * | is_strprefix (const gchar *s, const gchar *prefix) WARN_UNUSED_RESULT |
| Checks whether ``prefix'' is a prefix of ``str''.
|
gchar * | is_strcaseprefix (const gchar *s, const gchar *prefix) WARN_UNUSED_RESULT |
| Checks whether ``prefix'' is a prefix of ``str'' performing an case-insensitive (ASCII only) check.
|
size_t | html_escape (const gchar *src, gchar *dst, size_t dst_size) |
| Copies the NUL-terminated string ``src'' to ``dst'' replacing all characters which are reserved in HTML with a replacement string.
|
gint | canonize_path (gchar *dst, const gchar *path) |
| Creates the canonical representation of a path.
|
guint | compat_max_fd (void) |
gint | compat_mkdir (const gchar *path, mode_t mode) |
size_t | compat_pagesize (void) |
gpointer | compat_page_align (size_t size) |
| Allocates a page-aligned memory chunk.
|
void | compat_page_free (gpointer p, size_t size) |
gboolean | compat_is_superuser (void) |
signal_handler_t | set_signal (gint signo, signal_handler_t handler) |
| Installs a signal handler.
|
gchar * | ascii_strcasestr (const gchar *haystack, const gchar *needle) |
| Same as strstr() but case-insensitive with respect to ASCII characters.
|
G_GNUC_CONST guint32 | swap_guint32 (guint32 i) |
| Swap endianness of a guint32.
|
G_GNUC_CONST WARN_UNUSED_RESULT
guint8 | netmask_to_cidr (guint32 netmask) |
| Converts the given IPv4 netmask in host byte order to a CIDR prefix length.
|
size_t | round_size (size_t align, size_t n) |
| Rounds ``n'' up so that it matches the given alignment ``align''.
|
gint | do_stat (const gchar *path, struct stat *buf) |
| Wrapper for the stat() system call.
|
void | ip_range_split (guint32 lower_ip, guint32 upper_ip, cidr_split_t cb, gpointer udata) |
| Computes the set of CIDR ranges that make up the set of IPs between two boundary IPs, included.
|
Variables |
gint | do_errno |