<commit_before>#include <stdio.h>
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include "getBufferFromFile.c"
#include "io.h"
#include "log.h"
#include "comm.h"

#ifdef BENCHMARK
#include <time.h>
#endif

/* prototypes */
void parse_filename_to_timeStruct(char *infile, timeStruct * time);

void parse_filename_to_timeStruct(char *inf, timeStruct * time)
{
	int offset = strlen(inf) - 43;
	// infile is of the form testing_2014_09_22-23_43_55_984_cam_bot.raw
	//                       0         1         2         3         4
	//                       0123456789012345678901234567890123456789012
	time->year = (inf[offset +  8] - '0') * 1000 + (inf[offset +  9] - '0') * 100 + (inf[offset + 10] - '0') * 10 + inf[offset + 11] - '0';
	time->mon  = (inf[offset + 13] - '0') * 10 + inf[offset + 14] - '0';
	time->day  = (inf[offset + 16] - '0') * 10 + inf[offset + 17] - '0';
	time->hour = (inf[offset + 19] - '0') * 10 + inf[offset + 20] - '0';
	time->min  = (inf[offset + 22] - '0') * 10 + inf[offset + 23] - '0';
	time->sec  = (inf[offset + 25] - '0') * 10 + inf[offset + 26] - '0';
	time->milli= (inf[offset + 28] - '0') * 100 + (inf[offset + 29] - '0') * 10 + inf[offset + 30] - '0';
}

int main(int argc, char *argv[])
{
	char *infile = argv[1];
	char *outfolder = argv[2];
	int rawdump = argv[3] ? 1 : 2;
	short *buffer;
	timeStruct time;
	int status = 1;
	sParameterStruct sSO2Parameters;
	sConfigStruct config;
	config.debug = 0;
	if (log_init(&config)) {
		printf("could not start log file, stop.\n");
	}

	config.comm_port = 9999;
	comm_init(&config);

#ifdef BENCHMARK
	float startTime;
#endif

	if (argc < 3 || argc > 4) {
		printf("Usage: %s in.raw outfolder [write_raw_dump]\n", argv[0]);
		printf("i.e. %s tests/fixtures/testing_2014_09_22-23_43_55_984_cam_top.raw ./ 1\n", argv[0]);
		return 1;
	}
#ifdef BENCHMARK
	startTime = (float)clock() / CLOCKS_PER_SEC;
#endif

	buffer = getBufferFromFile(infile, 64);

	if (!buffer)
		return 1;

#ifdef BENCHMARK
	log_debug("reading file took %fms \n", ((float)clock() / CLOCKS_PER_SEC - startTime) * 1000);
#endif

	parse_filename_to_timeStruct(infile, &time);

	sSO2Parameters.identifier = strstr(infile, "top") ? 'a' : 'b';
	sSO2Parameters.stBuffer = buffer;
	sSO2Parameters.timestampBefore = &time;
	sSO2Parameters.timestampAfter = &time;
	sSO2Parameters.dark = 0;
	sSO2Parameters.dExposureTime = 0.000000;

	config.dImageCounter = 0;
	config.dBufferlength = 1376256;
	config.dInterFrameDelay = 10;
	config.dFixTime = 0.000000;
	config.cFileNamePrefix = "image";
	config.cConfigFileName = "";
	config.createsubfolders = 0;
	config.cImagePath = (char *)calloc(sizeof(char), strlen(outfolder) + 1);
	strcpy(config.cImagePath, outfolder);
	config.processing = rawdump;

	io_init(&config);

	status = io_write(&sSO2Parameters, &config);
	if (status == 0) {<commit_msg>fixup io-cli<commit_after>#include <stdio.h>
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include "getBufferFromFile.c"
#include "io.h"
#include "log.h"
#include "comm.h"

#ifdef BENCHMARK
#include <time.h>
#endif

/* prototypes */
void parse_filename_to_timeStruct(char *infile, timeStruct * time);

void parse_filename_to_timeStruct(char *inf, timeStruct * time)
{
	int offset = strlen(inf) - 43;
	// infile is of the form testing_2014_09_22-23_43_55_984_cam_bot.raw
	//                       0         1         2         3         4
	//                       0123456789012345678901234567890123456789012
	time->year = (inf[offset +  8] - '0') * 1000 + (inf[offset +  9] - '0') * 100 + (inf[offset + 10] - '0') * 10 + inf[offset + 11] - '0';
	time->mon  = (inf[offset + 13] - '0') * 10 + inf[offset + 14] - '0';
	time->day  = (inf[offset + 16] - '0') * 10 + inf[offset + 17] - '0';
	time->hour = (inf[offset + 19] - '0') * 10 + inf[offset + 20] - '0';
	time->min  = (inf[offset + 22] - '0') * 10 + inf[offset + 23] - '0';
	time->sec  = (inf[offset + 25] - '0') * 10 + inf[offset + 26] - '0';
	time->milli= (inf[offset + 28] - '0') * 100 + (inf[offset + 29] - '0') * 10 + inf[offset + 30] - '0';
}

int main(int argc, char *argv[])
{
	char *infile = argv[1];
	char *outfolder = argv[2];
	int rawdump = argv[3] ? 1 : 2;
	short *buffer;
	timeStruct time;
	int status = 1;
	sParameterStruct sSO2Parameters;
	sConfigStruct config;
	config.debug = 0;
	config.cImagePath = "-";
	if (log_init(&config)) {
		printf("could not start log file, stop.\n");
	}

	config.comm_port = 9999;
	comm_init(&config);

#ifdef BENCHMARK
	float startTime;
#endif

	if (argc < 3 || argc > 4) {
		printf("Usage: %s in.raw outfolder [write_raw_dump]\n", argv[0]);
		printf("i.e. %s tests/fixtures/testing_2014_09_22-23_43_55_984_cam_top.raw ./ 1\n", argv[0]);
		return 1;
	}
#ifdef BENCHMARK
	startTime = (float)clock() / CLOCKS_PER_SEC;
#endif

	buffer = getBufferFromFile(infile, 64);

	if (!buffer)
		return 1;

#ifdef BENCHMARK
	log_debug("reading file took %fms \n", ((float)clock() / CLOCKS_PER_SEC - startTime) * 1000);
#endif

	parse_filename_to_timeStruct(infile, &time);

	sSO2Parameters.identifier = strstr(infile, "top") ? 'a' : 'b';
	sSO2Parameters.stBuffer = buffer;
	sSO2Parameters.timestampBefore = &time;
	sSO2Parameters.timestampAfter = &time;
	sSO2Parameters.dark = 0;
	sSO2Parameters.dExposureTime = 0.000000;

	config.rotate_a = 0;
	config.rotate_b = 0;
	config.dImageCounter = 0;
	config.dBufferlength = 1376256;
	config.dInterFrameDelay = 10;
	config.dFixTime = 0.000000;
	config.cFileNamePrefix = "image";
	config.cConfigFileName = "";
	config.createsubfolders = 0;
	config.cImagePath = (char *)calloc(sizeof(char), strlen(outfolder) + 1);
	strcpy(config.cImagePath, outfolder);
	config.processing = rawdump;

	io_init(&config);

	status = io_write(&sSO2Parameters, &config);
	if (status == 0) {
{'fraction_non_alphanumeric': 0.16838248124236607, 'fraction_numerical': 0.07607747339033327, 'mean_word_length': 3.679183673469388, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4775268', 'n_tokens_mistral': 2563, 'n_tokens_neox': 2230, 'n_words': 502}