Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
assets_preprocessor.h
Go to the documentation of this file.
1#ifndef _ASSETS_PREPROCESSOR_H_
2#define _ASSETS_PREPROCESSOR_H_
3
4#include <stdbool.h>
5#include <stddef.h>
6#include <stdio.h>
7#include <stdint.h>
8
254
255// clang-format off
256
268
269// clang-format on
270
335
336// clang-format off
337
348
349// clang-format on
350
605
609typedef enum
610{
613
617
636
641typedef union
642{
647 FILE* file;
648
652 struct
653 {
655 uint8_t* data;
657 size_t length;
658 };
659
664 struct
665 {
667 char** lines;
669 size_t lineCount;
670 };
671
676 struct
677 {
679 char* text;
681 size_t textSize;
682 };
683
684 const char * fileName;
686
690typedef struct
691{
696 char* section;
697
701 char* name;
702
706 char* value;
707} optPair_t;
708
716typedef struct
717{
722
728
749
755typedef bool (*processFn_t)(processorInput_t* arg);
756
760typedef struct
761{
763 const char* name;
764
767
770
773
774 union
775 {
778
780 const char* exec;
781 };
783
787typedef struct
788{
790 const char* inExt;
791
793 const char* outExt;
794
797
801
803extern const char* inDirName;
804
806extern const char* outDirName;
807
808#endif
const char * outDirName
The path that is provided for output assets on the command line.
Definition assets_preprocessor.c:60
const char * inDirName
The path that is provided for input assets on the command line.
Definition assets_preprocessor.c:59
const char * fileName
Definition assets_preprocessor.h:684
char * text
Buffer holding text data.
processorType_t type
The type of this asset processor.
Definition assets_preprocessor.h:772
bool(* processFn_t)(processorInput_t *arg)
A function that performs asset processing on a file.
Definition assets_preprocessor.h:755
size_t length
Length of binary data.
processorFileData_t out
Holds the output data in whichever format was configured for the processor.
Definition assets_preprocessor.h:741
char * section
The section name only.
Definition assets_preprocessor.h:696
char * value
The value string.
Definition assets_preprocessor.h:706
const char * exec
An executable command to call for processing matching files.
processorFormat_t outFmt
The format this processor returns its output data in. Ignored for exec.
Definition assets_preprocessor.h:769
char * name
The key name.
Definition assets_preprocessor.h:701
FILE * file
Holds file handle for FMT_FILE or FMT_FILE_BIN formats.
Definition assets_preprocessor.h:647
const char * inFilename
Holds the input filename for convenience and error reporting.
Definition assets_preprocessor.h:744
processorFormat_t inFmt
The format this processor accepts its input data in. Ignored for exec.
Definition assets_preprocessor.h:766
optPair_t * pairs
The array of options.
Definition assets_preprocessor.h:726
const assetProcessor_t * processor
A pointer to the processor used to transform the files.
Definition assets_preprocessor.h:796
uint8_t * data
Buffer holding binary data.
const char * name
A name for this asset processor, if referenced.
Definition assets_preprocessor.h:763
char ** lines
Array of string pointers for each line.
const processorOptions_t * options
Holds a pointer to any configuration options in use for this file.
Definition assets_preprocessor.h:747
const char * inExt
The input file extension to match.
Definition assets_preprocessor.h:790
size_t textSize
The size of the text data, including NUL terminator.
const char * outExt
The output file extension to write.
Definition assets_preprocessor.h:793
processFn_t function
A function to call for processing matching files.
processorFormat_t
The format that this asset processor accepts or returns its data in.
Definition assets_preprocessor.h:622
@ FMT_FILE_BIN
An opened file handle (in binary mode) is passed for the file.
Definition assets_preprocessor.h:626
@ FMT_DATA
A buffer containing a file's raw binary data is passed.
Definition assets_preprocessor.h:628
@ FMT_FILENAME
Only provide/use filenames, instead of opening/use them as a file.
Definition assets_preprocessor.h:634
@ FMT_LINES
A text file's data is passed as an array of one string per line.
Definition assets_preprocessor.h:632
@ FMT_FILE
An opened file handle is passed for the file.
Definition assets_preprocessor.h:624
@ FMT_TEXT
A text file's data is passed as an ordinary string.
Definition assets_preprocessor.h:630
const processorFileData_t in
Holds the input data in whichever format was configured for the processor.
Definition assets_preprocessor.h:738
size_t optionCount
The number of options contained in this list.
Definition assets_preprocessor.h:721
size_t lineCount
The number of string pointers in the array.
processorType_t
Specifies which type of asset processor is being defined.
Definition assets_preprocessor.h:610
@ EXEC
Processor that executes a shell command to process assets.
Definition assets_preprocessor.h:615
@ FUNCTION
Processor that calls a function pointer to process assets.
Definition assets_preprocessor.h:612
Defines an asset processor.
Definition assets_preprocessor.h:761
Associates an input and output extension to a processor.
Definition assets_preprocessor.h:788
Holds a single key-value pair.
Definition assets_preprocessor.h:691
Holds the input and output data for a single file processing operation.
Definition assets_preprocessor.h:736
Holds a list of key-value option pairs.
Definition assets_preprocessor.h:717
Holds processor input or output data.
Definition assets_preprocessor.h:642