Parolin 0.7.9 6796
Console (soon DLLs) to do a tar like job
Loading...
Searching...
No Matches
data.c File Reference
#include "data.h"
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <curl/curl.h>
#include "mem.h"
#include "util.h"
#include "xxhash.h"

Data Structures

struct  curl_data_t
 

Macros

#define XXH_STATIC_LINKING_ONLY
 
#define REGRESSION_RELEASE(x)
 

Functions

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

Variables

data_t silesia
 
data_t silesia_tar
 
data_t github
 
data_t github_tar
 
data_t const *constdata = (data_t const* const*)g_data
 

Macro Definition Documentation

◆ REGRESSION_RELEASE

#define REGRESSION_RELEASE ( x)
Value:
"https://github.com/facebook/zstd/releases/download/regression-data/" x

Data objects

◆ XXH_STATIC_LINKING_ONLY

#define XXH_STATIC_LINKING_ONLY

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)

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)

data buffers helpers.

◆ data_filenames_get()

FileNamesTable * data_filenames_get ( data_t const * data)

data filenames 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 = (data_t const* const*)g_data

The NULL-terminated list of data objects.

◆ github

data_t github
Initial value:
= {
.name = "github",
.type = data_type_dir,
.data =
{
.url = REGRESSION_RELEASE("github.tar.zst"),
.xxhash64 = 0xa9b1b44b020df292LL,
},
.dict =
{
.url = REGRESSION_RELEASE("github.dict.zst"),
.xxhash64 = 0x1eddc6f737d3cb53LL,
},
}
#define REGRESSION_RELEASE(x)
Definition data.c:32
@ data_type_dir
Definition data.h:19

◆ github_tar

data_t github_tar
Initial value:
= {
.name = "github.tar",
.type = data_type_file,
.data =
{
.url = REGRESSION_RELEASE("github.tar.zst"),
.xxhash64 = 0xa9b1b44b020df292LL,
},
.dict =
{
.url = REGRESSION_RELEASE("github.dict.zst"),
.xxhash64 = 0x1eddc6f737d3cb53LL,
},
}
@ data_type_file
Definition data.h:18

◆ silesia

data_t silesia
Initial value:
= {
.name = "silesia",
.type = data_type_dir,
.data =
{
.url = REGRESSION_RELEASE("silesia.tar.zst"),
.xxhash64 = 0x48a199f92f93e977LL,
},
}

◆ silesia_tar

data_t silesia_tar
Initial value:
= {
.name = "silesia.tar",
.type = data_type_file,
.data =
{
.url = REGRESSION_RELEASE("silesia.tar.zst"),
.xxhash64 = 0x48a199f92f93e977LL,
},
}