<commit_before>#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "include/fjk.h"

void print_usage(char *selfname);
void run(FILE *from, FILE *to, int decrypt);

int main(int argc, char **argv)
{
	int dec = 0;
	int opt;
	char *infile = "", *outfile = "";
	FILE *input, *output;

	while((opt = getopt(argc, argv, "di:o:")) != -1) {
		switch (opt) {
		case 'd':
			dec = 1;
			break;
		case 'i':
			infile = optarg;
			break;
		case 'o':
			outfile = optarg;
			break;
		default:
			print_usage(argv[0]);
			exit(1);
		}
	}

	set_io(input,  infile,  stdin,  "rb", 2)
	set_io(output, outfile, stdout, "wb", 3)

	run(input, output, dec);
	return 0;
}

void run(FILE *from, FILE *to, int dec)
{
	char *indat;
	char *outdat;
	long int size;

	fseek(from, 0, SEEK_END);
	assert((size = ftell(from)) != -1);
	fseek(from, 0, SEEK_SET);

	indat = malloc(size+1);
	assert((size_t) size == fread(indat, 1, size, from));
	fclose(from);

	if (dec) {
		outdat = fjk_decrypt(indat, size);
	} else {
		outdat = fjk_encrypt(indat, size);
	}

	fwrite(outdat, 1, size, to);
	fclose(to);

	free(indat);
	free(outdat);<commit_msg>stdin fixed<commit_after>#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "include/fjk.h"

void print_usage(char *selfname);
void run(FILE *from, FILE *to, int decrypt);

int main(int argc, char **argv)
{
	int dec = 0;
	int opt;
	char *infile = "", *outfile = "";
	FILE *input, *output;

	while((opt = getopt(argc, argv, "di:o:")) != -1) {
		switch (opt) {
		case 'd':
			dec = 1;
			break;
		case 'i':
			infile = optarg;
			break;
		case 'o':
			outfile = optarg;
			break;
		default:
			print_usage(argv[0]);
			exit(1);
		}
	}

	set_io(input,  infile,  stdin,  "rb", 2)
	set_io(output, outfile, stdout, "wb", 3)

	run(input, output, dec);
	return 0;
}

void run(FILE *from, FILE *to, int dec)
{
	char *indat;
	char *outdat;
	size_t buffsize = 2;
	size_t size = 0;

	indat = malloc(buffsize * sizeof(char));
	size += fread(indat, sizeof(char), buffsize, from);

	while (size == buffsize) {
		buffsize = buffsize << 1;
		indat = realloc(indat, buffsize * sizeof(char));
		size += fread((indat + size), sizeof(char), buffsize >> 1, from);
	}

	fclose(from);

	if (dec) {
		outdat = fjk_decrypt(indat, size);
	} else {
		outdat = fjk_encrypt(indat, size);
	}

	fwrite(outdat, sizeof(char), size, to);
	fclose(to);

	free(indat);
	free(outdat);
{'fraction_non_alphanumeric': 0.18354943273905996, 'fraction_numerical': 0.01053484602917342, 'mean_word_length': 3.822265625, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '5458239', 'n_tokens_mistral': 1145, 'n_tokens_neox': 1052, 'n_words': 263}