<commit_before>/*
 * Helper functions to perform basic hostname validation using OpenSSL.
 *
 * Please read "everything-you-wanted-to-know-about-openssl.pdf" before
 * attempting to use this code. This whitepaper describes how the code works, 
 * how it should be used, and what its limitations are.
 *
 * Author:  <NAME>
 * License: See LICENSE
 *
 */
 

#include <strings.h>
#include <openssl/x509v3.h>
#include <openssl/ssl.h>

#include "openssl_hostname_validation.h"


#define HOSTNAME_MAX_SIZE 255

static int tolower(int ch) {
	if ('A' <= ch && ch <= 'Z')
		return ch - 'A' + 'a';
	return ch;
}

static int memeq_ncase(const char *x, const char *y, size_t l) {
	if (l == 0)
		return 1;
	do {
		if (tolower(*x++) != tolower(*y++))
			return 0;
	} while (--l != 0);
	return 1;
}<commit_msg>extract https://github.com/kazuho/ssl-conservatory @ 8b83b71 () at deps/ssl-conservatory<commit_after>/*
 * Helper functions to perform basic hostname validation using OpenSSL.
 *
 * Please read "everything-you-wanted-to-know-about-openssl.pdf" before
 * attempting to use this code. This whitepaper describes how the code works, 
 * how it should be used, and what its limitations are.
 *
 * Author:  <NAME>
 * License: See LICENSE
 *
 */
 

#include <strings.h>
#include <openssl/x509v3.h>
#include <openssl/ssl.h>

#include "openssl_hostname_validation.h"


#define HOSTNAME_MAX_SIZE 255

static int lowercase(int ch) {
	if ('A' <= ch && ch <= 'Z')
		return ch - 'A' + 'a';
	return ch;
}

static int memeq_ncase(const char *x, const char *y, size_t l) {
	if (l == 0)
		return 1;
	do {
		if (lowercase(*x++) != lowercase(*y++))
			return 0;
	} while (--l != 0);
	return 1;
}
{'fraction_non_alphanumeric': 0.1448234590065829, 'fraction_numerical': 0.017354877318970677, 'mean_word_length': 3.6573816155988856, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 11, 'https://': 1, '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': '3869746', 'n_tokens_mistral': 647, 'n_tokens_neox': 594, 'n_words': 190}