<commit_before>// Copyright 2014-2015 <NAME>
// MIT licensed (see LICENSE for details)

#ifndef STRONGLINK_H
#define STRONGLINK_H

#include "db/db_base.h"
#include "async/async.h"
#include "common.h"

#define URI_MAX (1023+1)

#define SLN_META_TYPE "application/vnd.stronglink.meta"

extern uint32_t SLNSeed;

typedef uint32_t SLNMode;
enum {
	SLN_RDONLY = 1 << 0,
	SLN_WRONLY = 1 << 1,
	SLN_RDWR = SLN_RDONLY | SLN_WRONLY,
	SLN_ROOT = 0xFF,
};

typedef struct SLNRepo* SLNRepoRef;
typedef struct SLNSessionCache* SLNSessionCacheRef;
typedef struct SLNSession* SLNSessionRef;
typedef struct SLNSubmission* SLNSubmissionRef;
typedef struct SLNHasher* SLNHasherRef;
typedef struct SLNFilter* SLNFilterRef;
typedef struct SLNJSONFilterParser* SLNJSONFilterParserRef;
typedef struct SLNPull* SLNPullRef;

// BerkeleyDB uses -30800 to -30999
// MDB uses -30600 to -30799?
#define SLN_HASHMISMATCH (-30599)
#define SLN_INVALIDTARGET (-30598)
#define SLN_LAST_ERRCODE SLN_INVALIDTARGET

static strarg_t sln_strerror(int const rc) {
	if(rc >= 0) return "No error";
	switch(rc) {
		case SLN_HASHMISMATCH: return "Hash mismatch";
		case SLN_INVALIDTARGET: return "Invalid meta-file target";
	}
	strarg_t x = uv_strerror(rc);
	if(!x) x = db_strerror(rc);
	return x;
}

SLNRepoRef SLNRepoCreate(strarg_t const dir, strarg_t const name);
void SLNRepoFree(SLNRepoRef *const repoptr);
strarg_t SLNRepoGetDir(SLNRepoRef const repo);
strarg_t SLNRepoGetDataDir(SLNRepoRef const repo);
str_t *SLNRepoCopyInternalPath(SLNRepoRef const repo, strarg_t const internalHash);<commit_msg>Add SLN_NOSESSION error code. (unused)<commit_after>// Copyright 2014-2015 <NAME>
// MIT licensed (see LICENSE for details)

#ifndef STRONGLINK_H
#define STRONGLINK_H

#include "db/db_base.h"
#include "async/async.h"
#include "common.h"

#define URI_MAX (1023+1)

#define SLN_META_TYPE "application/vnd.stronglink.meta"

extern uint32_t SLNSeed;

typedef uint32_t SLNMode;
enum {
	SLN_RDONLY = 1 << 0,
	SLN_WRONLY = 1 << 1,
	SLN_RDWR = SLN_RDONLY | SLN_WRONLY,
	SLN_ROOT = 0xFF,
};

typedef struct SLNRepo* SLNRepoRef;
typedef struct SLNSessionCache* SLNSessionCacheRef;
typedef struct SLNSession* SLNSessionRef;
typedef struct SLNSubmission* SLNSubmissionRef;
typedef struct SLNHasher* SLNHasherRef;
typedef struct SLNFilter* SLNFilterRef;
typedef struct SLNJSONFilterParser* SLNJSONFilterParserRef;
typedef struct SLNPull* SLNPullRef;

// BerkeleyDB uses -30800 to -30999
// MDB uses -30600 to -30799?
#define SLN_HASHMISMATCH (-30599)
#define SLN_INVALIDTARGET (-30598)
#define SLN_NOSESSION (-30597)
#define SLN_LAST_ERRCODE SLN_INVALIDTARGET

static strarg_t sln_strerror(int const rc) {
	if(rc >= 0) return "No error";
	switch(rc) {
		case SLN_HASHMISMATCH: return "Hash mismatch";
		case SLN_INVALIDTARGET: return "Invalid meta-file target";
		case SLN_NOSESSION: return "No session";
	}
	strarg_t x = uv_strerror(rc);
	if(!x) x = db_strerror(rc);
	return x;
}

SLNRepoRef SLNRepoCreate(strarg_t const dir, strarg_t const name);
void SLNRepoFree(SLNRepoRef *const repoptr);
strarg_t SLNRepoGetDir(SLNRepoRef const repo);
strarg_t SLNRepoGetDataDir(SLNRepoRef const repo);
str_t *SLNRepoCopyInternalPath(SLNRepoRef const repo, strarg_t const internalHash);
{'fraction_non_alphanumeric': 0.09333333333333334, 'fraction_numerical': 0.03441860465116279, 'mean_word_length': 6.1529933481153, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1152497', 'n_tokens_mistral': 1334, 'n_tokens_neox': 1231, 'n_words': 313}