LibT2FS 0.1
C API for accessing TEngine data in memory.
Loading...
Searching...
No Matches
t2fs.h File Reference
#include <stdint.h>
#include <stdio.h>
#include "config.h"
#include "schema.h"
#include "rnc.h"

Go to the source code of this file.

Data Structures

struct  s_t2fsInput
 object to handle input reading More...
struct  s_t2fsNode
 This is the core object to describe a path inside the tree. More...
struct  s_t2fsNodePath
struct  s_t2fs
 This is the core LibT2FS object that you will be passing around. More...

Macros

#define T2FS_NODE_SANE_MAX_COUNT   65000
#define T2FS_NODE_SANE_MIN_OFFSET   0x10
#define T2FS_PRINT_ERROR_NODE(node, ...)
#define T2FS_PRINT_WARN_NODE(node, ...)
#define T2FS_PRINT_DEBUG_NODE(node, ...)
#define NODE_MAX_LEVEL   64
#define NODE_PATH_END   (uint32_t)-1

Typedefs

typedef enum e_t2fsReadSize t2fsReadSize
 To handle swapping endianness.
typedef struct s_t2fs t_t2fs
 This is the core LibT2FS object that you will be passing around.
typedef struct s_t2fsInput t2fsInput
 object to handle input reading
typedef size_t t2fs_read_callback(t2fsInput *input, void *dest, size_t size)
typedef size_t t2fs_read_value_callback(t2fsInput *input, void *dest, t2fsReadSize size)
typedef int t2fs_seek_callback(t2fsInput *input, long offset, int whence)
typedef struct s_t2fsNode t2fsNode
 This is the core object to describe a path inside the tree.
typedef struct s_t2fsNodePath t2fsNodePath

Enumerations

enum  e_t2fsReadSize { T2FS_READ_16 = 2 , T2FS_READ_32 = 4 }
 To handle swapping endianness. More...
enum  t2fsStatus { T2FS_OK = 0 , T2FS_ERROR = 1 }

Functions

void t2fs_node_init (t2fsNode *node)
void t2fs_node_free_childeren (t2fsNode *node)
 This should be called after successfully call to t2fs_node_read_branch().
int t2fs_node_read_data (t2fsNode *node)
 Read node data.
int t2fs_node_read_branch (t_t2fs *lib, t2fsNode *node)
 Read child branch node(s).
int t2fs_node_read_recurse (t_t2fs *lib, t2fsNode *node, uint8_t loadData)
 Recursive read all child branch node(s) and optionally load the endpoint(s) data.
uint8_t t2fs_node_has_index (const t2fsNode *const node, uint32_t index)
 Check if the node has a child node with the given index.
t2fsNodet2fs_node_find_by_name (t2fsNode *start, const char *name, uint32_t level, uint32_t maxLevel)
 Find child node by schema name.
void t2fs_node_print_recursive (const t2fsNode *const node, uint32_t indent)
int t2fs_node_guess_read_recursive (t_t2fs *lib, t2fsNode *node, uint8_t loadData, uint8_t decompress)
void t2fs_node_path_init (t2fsNodePath *np)
void t2fs_node_path_parse (t2fsNodePath *np, t2fsNode *node)
void t2fs_node_path_print (const t_t2fs *const lib, const t2fsNodePath *const np)
int t2fs_node_path_to_string (const t2fsNodePath *const np, char *buf, size_t bufsize)
void t2fs_print_error_node (int printType, const char *const func, t2fsNode *node, const char *const fmt,...)
void t2fs_init (t_t2fs *lib)
 Always initialize your t_t2fs object.
t2fsStatus t2fs_open (t_t2fs *lib, const char *const filepath, const char *const schemaPath, uint8_t searchSchema)
 Open .dat/.lss/.lsm file.
void t2fs_close (t_t2fs *lib)
 Close opened file and free all allocated node/data memory.

Detailed Description

This header it self only contains stuff to navigate and access cart/ROM data. To get some use out of the data look at the 'higher' level models/*.h API.

Decompression and deinterleaving are handled by LibT2FS so you don't have to worry about those, unless you are helping developing this :-)

Macro Definition Documentation

◆ T2FS_NODE_SANE_MAX_COUNT

#define T2FS_NODE_SANE_MAX_COUNT   65000

◆ T2FS_NODE_SANE_MIN_OFFSET

#define T2FS_NODE_SANE_MIN_OFFSET   0x10

◆ T2FS_PRINT_ERROR_NODE

#define T2FS_PRINT_ERROR_NODE ( node,
... )
Value:
t2fs_print_error_node(T2FS_PRINT_FLAG_ERROR, __func__, node, __VA_ARGS__)
@ T2FS_PRINT_FLAG_ERROR
Definition common.h:32
void t2fs_print_error_node(int printType, const char *const func, t2fsNode *node, const char *const fmt,...)

◆ T2FS_PRINT_WARN_NODE

#define T2FS_PRINT_WARN_NODE ( node,
... )
Value:
t2fs_print_error_node(T2FS_PRINT_FLAG_WARNING, __func__, node, __VA_ARGS__)
@ T2FS_PRINT_FLAG_WARNING
Definition common.h:31

◆ T2FS_PRINT_DEBUG_NODE

#define T2FS_PRINT_DEBUG_NODE ( node,
... )
Value:
t2fs_print_error_node(T2FS_PRINT_FLAG_DEBUG, __func__, node, __VA_ARGS__)
@ T2FS_PRINT_FLAG_DEBUG
Definition common.h:33

◆ NODE_MAX_LEVEL

#define NODE_MAX_LEVEL   64

◆ NODE_PATH_END

#define NODE_PATH_END   (uint32_t)-1

Typedef Documentation

◆ t2fsReadSize

To handle swapping endianness.

◆ t_t2fs

typedef struct s_t2fs t_t2fs

This is the core LibT2FS object that you will be passing around.

◆ t2fsInput

typedef struct s_t2fsInput t2fsInput

object to handle input reading

◆ t2fs_read_callback

typedef size_t t2fs_read_callback(t2fsInput *input, void *dest, size_t size)

◆ t2fs_read_value_callback

typedef size_t t2fs_read_value_callback(t2fsInput *input, void *dest, t2fsReadSize size)

◆ t2fs_seek_callback

typedef int t2fs_seek_callback(t2fsInput *input, long offset, int whence)

◆ t2fsNode

typedef struct s_t2fsNode t2fsNode

This is the core object to describe a path inside the tree.

◆ t2fsNodePath

typedef struct s_t2fsNodePath t2fsNodePath

Enumeration Type Documentation

◆ e_t2fsReadSize

To handle swapping endianness.

Enumerator
T2FS_READ_16 
T2FS_READ_32 

◆ t2fsStatus

enum t2fsStatus
Enumerator
T2FS_OK 
T2FS_ERROR 

Function Documentation

◆ t2fs_node_init()

void t2fs_node_init ( t2fsNode * node)

◆ t2fs_node_free_childeren()

void t2fs_node_free_childeren ( t2fsNode * node)

This should be called after successfully call to t2fs_node_read_branch().

This will recursive free all the child nodes and their potential data.

◆ t2fs_node_read_data()

int t2fs_node_read_data ( t2fsNode * node)

Read node data.

Returns
0 on success, else error.

◆ t2fs_node_read_branch()

int t2fs_node_read_branch ( t_t2fs * lib,
t2fsNode * node )

Read child branch node(s).

Returns
0 on success, else error.

◆ t2fs_node_read_recurse()

int t2fs_node_read_recurse ( t_t2fs * lib,
t2fsNode * node,
uint8_t loadData )

Recursive read all child branch node(s) and optionally load the endpoint(s) data.

Returns
0 on success, else error.

◆ t2fs_node_has_index()

uint8_t t2fs_node_has_index ( const t2fsNode *const node,
uint32_t index )

Check if the node has a child node with the given index.

Returns
0 for false, 1 for true.

◆ t2fs_node_find_by_name()

t2fsNode * t2fs_node_find_by_name ( t2fsNode * start,
const char * name,
uint32_t level,
uint32_t maxLevel )

Find child node by schema name.

Returns
0 on success, else error.

◆ t2fs_node_print_recursive()

void t2fs_node_print_recursive ( const t2fsNode *const node,
uint32_t indent )

◆ t2fs_node_guess_read_recursive()

int t2fs_node_guess_read_recursive ( t_t2fs * lib,
t2fsNode * node,
uint8_t loadData,
uint8_t decompress )

◆ t2fs_node_path_init()

void t2fs_node_path_init ( t2fsNodePath * np)

◆ t2fs_node_path_parse()

void t2fs_node_path_parse ( t2fsNodePath * np,
t2fsNode * node )

◆ t2fs_node_path_print()

void t2fs_node_path_print ( const t_t2fs *const lib,
const t2fsNodePath *const np )

◆ t2fs_node_path_to_string()

int t2fs_node_path_to_string ( const t2fsNodePath *const np,
char * buf,
size_t bufsize )

◆ t2fs_print_error_node()

void t2fs_print_error_node ( int printType,
const char *const func,
t2fsNode * node,
const char *const fmt,
... )

◆ t2fs_init()

void t2fs_init ( t_t2fs * lib)

Always initialize your t_t2fs object.

◆ t2fs_open()

t2fsStatus t2fs_open ( t_t2fs * lib,
const char *const filepath,
const char *const schemaPath,
uint8_t searchSchema )

Open .dat/.lss/.lsm file.

When a schema is given or found it will read the root node, meaning that the root child nodes are set. So for example we can get amount of textures in the textures node. It won't load any data.

Parameters
libYour freshly initialized t_t2fs object.
filepathFilepath to the .dat/.lss/.lsm file, this may NOT be NULL.
schemaPathFilepath to the schema file (.json) to use. Giving NULL is allowed for when you want to automatically detect and find the schema file or for debugging/guessing node operations.
searchSchemaAutomatically try to detect and find the schema file.

◆ t2fs_close()

void t2fs_close ( t_t2fs * lib)

Close opened file and free all allocated node/data memory.