#define PRISM_EXPORTED_FUNCTION
By default, we compile with -fvisibility=hidden.
Platform detection for mmap and filesystem support.
#define PRISM_NODISCARD
Mark the return value of a function as important so that the compiler warns if a caller ignores it.
#define PRISM_NONNULL(...)
Mark the parameters of a function as non-null.
PRISM_EXPORTED_FUNCTION const uint8_t * pm_source_source(const pm_source_t *source) PRISM_NONNULL(1)
Returns a pointer to the source data.
PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_source_t * pm_source_file_new(const char *filepath, pm_source_init_result_t *result) PRISM_NONNULL(1
Create a new source by reading a file into a heap-allocated buffer.
int() pm_source_stream_feof_t(void *stream)
This function is used to check whether a stream is at EOF.
PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_source_t PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_source_t PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_source_t * pm_source_stream_new(void *stream, pm_source_stream_fgets_t *fgets, pm_source_stream_feof_t *feof)
Create a new source by reading from a stream using the provided callbacks.
PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_source_t * pm_source_constant_new(const uint8_t *data, size_t length)
Create a new source that wraps existing constant memory.
PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_source_t * pm_source_owned_new(uint8_t *data, size_t length)
Create a new source that owns its memory.
char *() pm_source_stream_fgets_t(char *string, int size, void *stream)
This function is used to retrieve a line of input from a stream.
PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_source_t PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_source_t * pm_source_mapped_new(const char *filepath, int open_flags, pm_source_init_result_t *result) PRISM_NONNULL(1
Create a new source by memory-mapping a file.
PRISM_EXPORTED_FUNCTION size_t pm_source_length(const pm_source_t *source) PRISM_NONNULL(1)
Returns the length of the source data in bytes.
PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_source_t * pm_source_shared_new(const uint8_t *data, size_t length)
Create a new source that wraps existing shared memory.
PRISM_EXPORTED_FUNCTION void pm_source_free(pm_source_t *source) PRISM_NONNULL(1)
Free the given source and any memory it owns.
pm_source_init_result_t
Represents the result of initializing a source from a file.
@ PM_SOURCE_INIT_ERROR_GENERIC
Indicates a generic error from a source init function, where the type of error should be read from er...
@ PM_SOURCE_INIT_SUCCESS
Indicates that the source was successfully initialized.
@ PM_SOURCE_INIT_ERROR_NON_REGULAR
Indicates that the file is not a regular file (e.g.
@ PM_SOURCE_INIT_ERROR_DIRECTORY
Indicates that the file that was attempted to be opened was a directory.