Parolin 0.7.9 6796
Console (soon DLLs) to do a tar like job
Loading...
Searching...
No Matches
data.h File Reference
#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  data_resource_t
 
struct  data_t
 
struct  data_buffer_t
 
struct  data_buffers_t
 

Enumerations

enum  data_type_t { data_type_file = 1 , data_type_dir = 2 }
 

Functions

int data_has_dict (data_t const *data)
 
int data_init (char const *dir)
 
void data_finish (void)
 
data_buffer_t data_buffer_get_data (data_t const *data)
 
data_buffer_t data_buffer_get_dict (data_t const *data)
 
data_buffer_t data_buffer_read (char const *filename)
 
data_buffer_t data_buffer_create (size_t capacity)
 
int data_buffer_compare (data_buffer_t buffer1, data_buffer_t buffer2)
 
void data_buffer_free (data_buffer_t buffer)
 
data_buffers_t data_buffers_get (data_t const *data)
 
void data_buffers_free (data_buffers_t buffers)
 

Variables

data_t const *constdata
 

Enumeration Type Documentation

◆ data_type_t

Enumerator
data_type_file 

This data is a file. *.zst

data_type_dir 

This data is a directory. *.tar.zst

Function Documentation

◆ data_buffer_compare()

int data_buffer_compare ( data_buffer_t buffer1,
data_buffer_t buffer2 )

Calls memcmp() on the contents [0, size) of both buffers.

◆ data_buffer_create()

data_buffer_t data_buffer_create ( size_t const capacity)

Create a buffer with the specified capacity.

Returns
The buffer, which is NULL on failure.

data buffer helper functions (documented in header).

◆ data_buffer_free()

void data_buffer_free ( data_buffer_t buffer)

Frees an allocated buffer.

◆ data_buffer_get_data()

data_buffer_t data_buffer_get_data ( data_t const * data)

Read the file that data points to into a buffer. NOTE: data must be a file, not a directory.

Returns
The buffer, which is NULL on failure.

◆ data_buffer_get_dict()

data_buffer_t data_buffer_get_dict ( data_t const * data)

Read the dictionary that the data points to into a buffer.

Returns
The buffer, which is NULL on failure.

◆ data_buffer_read()

data_buffer_t data_buffer_read ( char const * filename)

Read the contents of filename into a buffer.

Returns
The buffer, which is NULL on failure.

◆ data_buffers_free()

void data_buffers_free ( data_buffers_t buffers)

Frees the data buffers.

◆ data_buffers_get()

data_buffers_t data_buffers_get ( data_t const * data)
Returns
a list of buffers for every file in data. It is zero sized on error.

data buffers helpers.

◆ data_finish()

void data_finish ( void )

Must be called at exit to free resources allocated by data_init().

◆ data_has_dict()

int data_has_dict ( data_t const * data)

data helpers.

◆ data_init()

int data_init ( char const * dir)

Initializes the data module and downloads the data necessary. Caches the downloads in dir. We add a stamp file in the directory after a successful download. If a stamp file already exists, and matches our current data stamp, we will use the cached data without downloading.

Parameters
dirThe directory to cache the downloaded data into.
Returns
0 on success.

Variable Documentation

◆ data

data_t const* const* data
extern

The NULL-terminated list of data objects.