31 lines
958 B
C
31 lines
958 B
C
// Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License.
|
|
// See LICENSE.md for license information.
|
|
// SPDX-License-Identifier: MIT
|
|
//
|
|
// toolBuf.h - a growing byte buffer for the JoeyLib host tools: bytes and
|
|
// little- and big-endian numbers appended as a file's structures are built.
|
|
// Running out of memory is fatal (toolFail).
|
|
|
|
#ifndef TOOL_BUF_H
|
|
#define TOOL_BUF_H
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
// An empty buffer is all zeros.
|
|
typedef struct ToolBufT {
|
|
uint8_t *data;
|
|
size_t len;
|
|
size_t cap;
|
|
} ToolBufT;
|
|
|
|
void toolBufAdd(ToolBufT *buf, const void *data, size_t len);
|
|
void toolBufBe16(ToolBufT *buf, uint32_t value);
|
|
void toolBufBe32(ToolBufT *buf, uint32_t value);
|
|
void toolBufByte(ToolBufT *buf, uint32_t value);
|
|
void toolBufFree(ToolBufT *buf);
|
|
void toolBufLe16(ToolBufT *buf, uint32_t value);
|
|
void toolBufLe32(ToolBufT *buf, uint32_t value);
|
|
void toolBufZeros(ToolBufT *buf, size_t count);
|
|
|
|
#endif
|