27#define MAGIC 0x53415645u
29int main(
int argc,
char* argv[]) {
30 (void)argc; (void)argv;
50 const unsigned char* bytes = (
const unsigned char*)
bj_stream_peek(save, 0, 4);
52 bj_info(
"First bytes: %c%c%c%c", bytes[0], bytes[1], bytes[2], bytes[3]);
65 bj_info(
"Version %u, score %lu, position %d", (
unsigned)version, (
unsigned long)score, (
int)position);
72 bj_info(
"Past the record, the status is %s",
struct bj_stream bj_stream
uint32_t bj_bool
Boolean type used throughout the Banjo API.
#define bj_info(...)
Log a message using the BJ_LOG_INFO level.
#define bj_err(...)
Log a message using the BJ_LOG_ERROR level.
bj_bool bj_write_stream_i16_le(struct bj_stream *stream, int16_t value)
Writes a little-endian int16_t.
size_t bj_seek_stream(struct bj_stream *stream, ptrdiff_t position, enum bj_seek_origin from)
Seeks to a new position in the stream relative to a specified origin.
size_t bj_stream_length(struct bj_stream *stream)
Return the total size of the stream, in bytes.
bj_bool bj_read_stream_u8(struct bj_stream *stream, uint8_t *value)
Reads one byte.
const void * bj_stream_peek(struct bj_stream *stream, size_t offset, size_t length)
Points at bytes of the stream without moving the cursor.
bj_bool bj_write_stream_u16_le(struct bj_stream *stream, uint16_t value)
Writes a little-endian uint16_t.
void bj_destroy_stream(struct bj_stream *stream)
Destroy a stream and release its memory.
bj_bool bj_read_stream_u16_le(struct bj_stream *stream, uint16_t *value)
Reads a little-endian uint16_t.
bj_bool bj_read_stream_u32_le(struct bj_stream *stream, uint32_t *value)
Reads a little-endian uint32_t.
bj_bool bj_write_stream_u32_le(struct bj_stream *stream, uint32_t value)
Writes a little-endian uint32_t.
bj_bool bj_write_stream_u32_be(struct bj_stream *stream, uint32_t value)
Writes a big-endian uint32_t.
struct bj_stream * bj_create_stream(void)
Create an empty stream in memory, which reads and writes, and grows as it is written.
bj_bool bj_read_stream_i16_le(struct bj_stream *stream, int16_t *value)
Reads a little-endian int16_t.
bj_bool bj_read_stream_u32_be(struct bj_stream *stream, uint32_t *value)
Reads a big-endian uint32_t.
bj_stream_status
Why the last read or write of a stream fell short.
@ BJ_SEEK_BEGIN
The beginning of the stream.
@ BJ_STREAM_STATUS_END
The data ran out, or a fixed-size stream is full.
Logging utility functions.
Portable main() replacement with platform-aware entry shim.
Header file for struct bj_stream struct and related functions.