Binary Snapshot Hex I/O and Corruption Patching Utilities (modeled on SQLite's src/test_hexio.c).
More...
#include <stdint.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
Go to the source code of this file.
|
| static int | impulse_hexio_nibble (char c) |
| static int | impulse_hexio_read_buf (const uint8_t *buf, size_t buf_len, size_t offset, size_t count, char *out_hex, size_t out_hex_cap) |
| static int | impulse_hexio_write_buf (uint8_t *buf, size_t buf_len, size_t offset, const char *hex_str) |
| static int | impulse_hexio_read_file (const char *path, size_t offset, size_t count, char *out_hex, size_t out_hex_cap) |
| static int | impulse_hexio_write_file (const char *path, size_t offset, const char *hex_str) |
| static void | impulse_hexio_render_u16_le (uint16_t val, char out_hex[5]) |
| static void | impulse_hexio_render_u32_le (uint32_t val, char out_hex[9]) |
| static void | impulse_hexio_render_u64_le (uint64_t val, char out_hex[17]) |
Binary Snapshot Hex I/O and Corruption Patching Utilities (modeled on SQLite's src/test_hexio.c).
Enables tests to build a valid .imps snapshot via official Impulse Graph APIs and apply targeted byte-level hex reads, writes, and little-endian integer patches in memory or on disk without committing binary blobs to Git (Rule 3.6 & 3.17).
◆ impulse_hexio_nibble()
| int impulse_hexio_nibble |
( |
char | c | ) |
|
|
inlinestatic |
◆ impulse_hexio_read_buf()
| int impulse_hexio_read_buf |
( |
const uint8_t * | buf, |
|
|
size_t | buf_len, |
|
|
size_t | offset, |
|
|
size_t | count, |
|
|
char * | out_hex, |
|
|
size_t | out_hex_cap ) |
|
inlinestatic |
Reads count bytes from buf (of size buf_len) at offset and formats as uppercase hexadecimal into out_hex (which must have capacity >= 2 * count + 1). Returns the number of bytes read, or -1 on out-of-bounds.
◆ impulse_hexio_read_file()
| int impulse_hexio_read_file |
( |
const char * | path, |
|
|
size_t | offset, |
|
|
size_t | count, |
|
|
char * | out_hex, |
|
|
size_t | out_hex_cap ) |
|
inlinestatic |
Reads count bytes from file path at offset and writes uppercase hex into out_hex.
◆ impulse_hexio_render_u16_le()
| void impulse_hexio_render_u16_le |
( |
uint16_t | val, |
|
|
char | out_hex[5] ) |
|
inlinestatic |
Renders a 16-bit integer as 4-char uppercase Little-Endian hex (e.g., 0x0009 -> "0900").
◆ impulse_hexio_render_u32_le()
| void impulse_hexio_render_u32_le |
( |
uint32_t | val, |
|
|
char | out_hex[9] ) |
|
inlinestatic |
Renders a 32-bit integer as 8-char uppercase Little-Endian hex.
◆ impulse_hexio_render_u64_le()
| void impulse_hexio_render_u64_le |
( |
uint64_t | val, |
|
|
char | out_hex[17] ) |
|
inlinestatic |
Renders a 64-bit integer as 16-char uppercase Little-Endian hex.
◆ impulse_hexio_write_buf()
| int impulse_hexio_write_buf |
( |
uint8_t * | buf, |
|
|
size_t | buf_len, |
|
|
size_t | offset, |
|
|
const char * | hex_str ) |
|
inlinestatic |
Decodes hex_str (ignoring ASCII whitespace) and writes the resulting bytes into buf (of size buf_len) starting at offset. Returns the number of bytes written, or -1 on invalid hex or out-of-bounds.
◆ impulse_hexio_write_file()
| int impulse_hexio_write_file |
( |
const char * | path, |
|
|
size_t | offset, |
|
|
const char * | hex_str ) |
|
inlinestatic |
Patches file path in-place at byte offset with the decoded bytes of hex_str.