<commit_before>/* Copyright (c) 2013-2021 <NAME>
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <mgba/feature/updater.h>

#include <mgba-util/string.h>
#include <mgba-util/table.h>
#include <mgba-util/vector.h>
#include <mgba-util/vfs.h>

#define UPDATE_SECTION "update"

struct mUpdateMatch {
	const char* channel;
	struct mUpdate* out;
};

static void _updateListSections(const char* sectionName, void* user) {
	struct StringList* out = user;
	if (strncmp("platform.", sectionName, 9) == 0) {
		*StringListAppend(out) = (char*) &sectionName[9];
	}
}

static void _updateUpdate(struct mUpdate* update, const char* item, const char* value) {
	if (strcmp("name", item) == 0) {
		update->path = value;
	} else if (strcmp("version", item) == 0) {
		update->version = value;
	} else if (strcmp("size", item) == 0) {
		update->size = strtoull(value, NULL, 10);
	} else if (strcmp("rev", item) == 0) {
		update->rev = strtol(value, NULL, 10);
	} else if (strcmp("commit", item) == 0) {
		update->commit = value;
	} else if (strcmp("sha256", item) == 0) {
		update->sha256 = value;
	}
}

static void _updateList(const char* key, const char* value, void* user) {
	char channel[64] = {};
	const char* dotLoc;
	if (strncmp("medusa.", key, 7) == 0) {
		dotLoc = strchr(&key[7], '.');
	} else {
		dotLoc = strchr(key, '.');		
	}
	if (!dotLoc) {
		return;
	}
	size_t size = dotLoc - key;
	if (size >= sizeof(channel)) {
		return;<commit_msg>Windows: Fix MSVC build<commit_after>/* Copyright (c) 2013-2021 <NAME>
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <mgba/feature/updater.h>

#include <mgba-util/string.h>
#include <mgba-util/table.h>
#include <mgba-util/vector.h>
#include <mgba-util/vfs.h>

#define UPDATE_SECTION "update"

struct mUpdateMatch {
	const char* channel;
	struct mUpdate* out;
};

static void _updateListSections(const char* sectionName, void* user) {
	struct StringList* out = user;
	if (strncmp("platform.", sectionName, 9) == 0) {
		*StringListAppend(out) = (char*) &sectionName[9];
	}
}

static void _updateUpdate(struct mUpdate* update, const char* item, const char* value) {
	if (strcmp("name", item) == 0) {
		update->path = value;
	} else if (strcmp("version", item) == 0) {
		update->version = value;
	} else if (strcmp("size", item) == 0) {
		update->size = strtoull(value, NULL, 10);
	} else if (strcmp("rev", item) == 0) {
		update->rev = strtol(value, NULL, 10);
	} else if (strcmp("commit", item) == 0) {
		update->commit = value;
	} else if (strcmp("sha256", item) == 0) {
		update->sha256 = value;
	}
}

static void _updateList(const char* key, const char* value, void* user) {
	char channel[64] = {0};
	const char* dotLoc;
	if (strncmp("medusa.", key, 7) == 0) {
		dotLoc = strchr(&key[7], '.');
	} else {
		dotLoc = strchr(key, '.');		
	}
	if (!dotLoc) {
		return;
	}
	size_t size = dotLoc - key;
	if (size >= sizeof(channel)) {
		return;
{'fraction_non_alphanumeric': 0.17368256937948237, 'fraction_numerical': 0.022762706579357656, 'mean_word_length': 3.9353846153846153, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 29, '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': '6472978', 'n_tokens_mistral': 1262, 'n_tokens_neox': 1192, 'n_words': 345}