<commit_before>/*********************************************************************************************
 **	__________         __           .__            __                 ________   _______   	**
 **	\______   \_____  |  | __  _____|  |__ _____ _/  |______   	___  _\_____  \  \   _  \  	**
 **	 |       _/\__  \ |  |/ / /  ___/  |  \\__  \\   __\__  \  	\  \/ //  ____/  /  /_\  \ 	**
 **	 |    |   \ / __ \|    <  \___ \|   Y  \/ __ \|  |  / __ \__ \   //       \  \  \_/   \	**
 **	 |____|_  /(____  /__|_ \/____  >___|  (____  /__| (____  /	  \_/ \_______ \ /\_____  /	**
 **	        \/      \/     \/     \/     \/     \/          \/ 	              \/ \/     \/ 	**
 **                                                                                         **
 **		Source code and assets are property of Taiki, distribution is stricly forbidden		**
 **                                                                                         **
 *********************************************************************************************/

#include "dbCache.h"

bool copyOutputDBToStruct(sqlite3_stmt *state, PROJECT_DATA* output, bool copyDynamic)
{
	void* buffer;

	MUTEX_LOCK(cacheParseMutex);

	//Repo
	buffer = getRepoForID(sqlite3_column_int64(state, RDB_repo-1));
	if(buffer != NULL)				//Si la team est pas valable, on drop complètement le projet
		output->repo = buffer;
	else
	{
		output->isInitialized = false;
		output->repo = NULL;	//L'appelant est signalé d'ignorer l'élément
		MUTEX_UNLOCK(cacheParseMutex);
		return false;
	}
	
	//ID d'accès rapide
	output->cacheDBID = sqlite3_column_int(state, RDB_ID-1);
	
	//Project ID
	output->projectID = sqlite3_column_int(state, RDB_projectID-1);
	
	//isInstalled est ici, on saute donc son index
	
	//Nom du projet
	buffer = (void*) sqlite3_column_text(state, RDB_projectName-1);
	if(buffer == NULL)
	{
		MUTEX_UNLOCK(cacheParseMutex);
		return false;
	}
	else
	{
		size_t length = strlen(buffer);
		wchar_t converted[length + 1];
		
		length = utf8_to_wchar(buffer, length, converted, length + 1, 0);	converted[length] = 0;
		wstrncpy(output->projectName, LENGTH_PROJECT_NAME, converted);
	}
	
	//Description
	buffer = (void*) sqlite3_column_text(state, RDB_description-1);
	if(buffer == NULL)
		memset(output->description, 0, sizeof(output->description));
	else
	{
		size_t length = strlen(buffer);
		wchar_t converted[length + 1];
		
		length = utf8_to_wchar(buffer, length, converted, length + 1, 0);	converted[length] = 0;
		wstrncpy(output->description, LENGTH_DESCRIPTION, converted);
	}
	
	//Nom de l'auteur
	buffer = (void*) sqlite3_column_text(state, RDB_authors-1);
	if(buffer == NULL)
		memset(output->authorName, 0, sizeof(output->authorName));
	else
	{
		size_t length = strlen(buffer);
		wchar_t converted[length + 1];
		
		length = utf8_to_wchar(buffer, length, converted, length + 1, 0);	converted[length] = 0;
		wstrncpy(output->authorName, LENGTH_AUTHORS, converted);
	}
	
	//Divers données
	output->status = sqlite3_column_int(state, RDB_status-1);	//On pourrait vérifier que c'est une valeur tolérable mais je ne vois pas de raison pour laquelle quelqu'un irait patcher la BDD
	output->category = sqlite3_column_int(state, RDB_category-1);
	output->japaneseOrder = sqlite3_column_int(state, RDB_asianOrder-1);
	output->isPaid = sqlite3_column_int(state, RDB_isPaid-1);
	output->mainTag = sqlite3_column_int(state, RDB_mainTagID-1);
	output->tagMask = sqlite3_column_int64(state, RDB_tagMask-1);
	output->nombreChapitre = sqlite3_column_int(state, RDB_nombreChapitre-1);
	
	if(copyDynamic)
	{
		buffer = (void*) sqlite3_column_int64(state, RDB_chapitresPrice - 1);
		if(buffer != NULL)
		{
			output->chapitresPrix = malloc(output->nombreChapitre * sizeof(uint));<commit_msg>Try to fix weird glyphs in strings<commit_after>/*********************************************************************************************
 **	__________         __           .__            __                 ________   _______   	**
 **	\______   \_____  |  | __  _____|  |__ _____ _/  |______   	___  _\_____  \  \   _  \  	**
 **	 |       _/\__  \ |  |/ / /  ___/  |  \\__  \\   __\__  \  	\  \/ //  ____/  /  /_\  \ 	**
 **	 |    |   \ / __ \|    <  \___ \|   Y  \/ __ \|  |  / __ \__ \   //       \  \  \_/   \	**
 **	 |____|_  /(____  /__|_ \/____  >___|  (____  /__| (____  /	  \_/ \_______ \ /\_____  /	**
 **	        \/      \/     \/     \/     \/     \/          \/ 	              \/ \/     \/ 	**
 **                                                                                         **
 **		Source code and assets are property of Taiki, distribution is stricly forbidden		**
 **                                                                                         **
 *********************************************************************************************/

#include "dbCache.h"

bool copyOutputDBToStruct(sqlite3_stmt *state, PROJECT_DATA* output, bool copyDynamic)
{
	void* buffer;

	MUTEX_LOCK(cacheParseMutex);

	//Repo
	buffer = getRepoForID(sqlite3_column_int64(state, RDB_repo-1));
	if(buffer != NULL)				//Si la team est pas valable, on drop complètement le projet
		output->repo = buffer;
	else
	{
		output->isInitialized = false;
		output->repo = NULL;	//L'appelant est signalé d'ignorer l'élément
		MUTEX_UNLOCK(cacheParseMutex);
		return false;
	}
	
	//ID d'accès rapide
	output->cacheDBID = sqlite3_column_int(state, RDB_ID-1);
	
	//Project ID
	output->projectID = sqlite3_column_int(state, RDB_projectID-1);
	
	//isInstalled est ici, on saute donc son index
	
	//Nom du projet
	buffer = (void*) sqlite3_column_text(state, RDB_projectName-1);
	if(buffer == NULL)
	{
		MUTEX_UNLOCK(cacheParseMutex);
		return false;
	}
	else
	{
		size_t length = strlen(buffer);
		wchar_t converted[LENGTH_PROJECT_NAME];
		
		length = utf8_to_wchar(buffer, length, converted, LENGTH_PROJECT_NAME - 1, 0);	converted[LENGTH_PROJECT_NAME - 1] = 0;
		wstrncpy(output->projectName, LENGTH_PROJECT_NAME, converted);
	}
	
	//Description
	buffer = (void*) sqlite3_column_text(state, RDB_description-1);
	if(buffer == NULL)
		memset(output->description, 0, sizeof(output->description));
	else
	{
		size_t length = strlen(buffer);
		wchar_t converted[LENGTH_DESCRIPTION];
		
		length = utf8_to_wchar(buffer, length, converted, LENGTH_DESCRIPTION - 1, 0);	converted[LENGTH_DESCRIPTION - 1] = 0;
		wstrncpy(output->description, LENGTH_DESCRIPTION, converted);
	}
	
	//Nom de l'auteur
	buffer = (void*) sqlite3_column_text(state, RDB_authors-1);
	if(buffer == NULL)
		memset(output->authorName, 0, sizeof(output->authorName));
	else
	{
		size_t length = strlen(buffer);
		wchar_t converted[LENGTH_AUTHORS];
		
		length = utf8_to_wchar(buffer, length, converted, LENGTH_AUTHORS - 1, 0);	converted[LENGTH_AUTHORS - 1] = 0;
		wstrncpy(output->authorName, LENGTH_AUTHORS, converted);
	}
	
	//Divers données
	output->status = sqlite3_column_int(state, RDB_status-1);	//On pourrait vérifier que c'est une valeur tolérable mais je ne vois pas de raison pour laquelle quelqu'un irait patcher la BDD
	output->category = sqlite3_column_int(state, RDB_category-1);
	output->japaneseOrder = sqlite3_column_int(state, RDB_asianOrder-1);
	output->isPaid = sqlite3_column_int(state, RDB_isPaid-1);
	output->mainTag = sqlite3_column_int(state, RDB_mainTagID-1);
	output->tagMask = sqlite3_column_int64(state, RDB_tagMask-1);
	output->nombreChapitre = sqlite3_column_int(state, RDB_nombreChapitre-1);
	
	if(copyDynamic)
	{
		buffer = (void*) sqlite3_column_int64(state, RDB_chapitresPrice - 1);
		if(buffer != NULL)
		{
			output->chapitresPrix = malloc(output->nombreChapitre * sizeof(uint));
{'fraction_non_alphanumeric': 0.17471924784539045, 'fraction_numerical': 0.013580569339253069, 'mean_word_length': 2.708958837772397, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 6, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1150461', 'n_tokens_mistral': 2844, 'n_tokens_neox': 2608, 'n_words': 453}