<commit_before>/*
 * data_extraction.c
 *
 * Copyright (C) 2011		OpenTech Labs
 *				<NAME> <<EMAIL>>
 * Released under the GNU General Public License (GPL) version 3.
 * See COPYING
 */

/* FastCGI stdio wrappers */
#include <fcgi_stdio.h>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>

#include <glib.h>

#include "common.h"
#include "utils.h"
#include "data_extraction.h"

void send_receipt_data(int fd)
{
	ssize_t bytes_read = 1;
	char buf[BUF_SIZE];
	struct stat sb;

	fstat(fd, &sb);

	printf("Content-Type: application/download; text/csv\r\n");
	printf("Content-Length: %ld\r\n", sb.st_size);
	printf("Content-Disposition: attachment; filename=receipt_data.csv"
								"\r\n\r\n");

	lseek(fd, 0, SEEK_SET);
	while (bytes_read > 0) {
		bytes_read = read(fd, &buf, BUF_SIZE);
		fwrite(buf, bytes_read, 1, stdout);
	}<commit_msg>data_extraction.c: include sys/stat.h for fstat<commit_after>/*
 * data_extraction.c
 *
 * Copyright (C) 2011		OpenTech Labs
 *				<NAME> <<EMAIL>>
 * Released under the GNU General Public License (GPL) version 3.
 * See COPYING
 */

/* FastCGI stdio wrappers */
#include <fcgi_stdio.h>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

#include <glib.h>

#include "common.h"
#include "utils.h"
#include "data_extraction.h"

void send_receipt_data(int fd)
{
	ssize_t bytes_read = 1;
	char buf[BUF_SIZE];
	struct stat sb;

	fstat(fd, &sb);

	printf("Content-Type: application/download; text/csv\r\n");
	printf("Content-Length: %ld\r\n", sb.st_size);
	printf("Content-Disposition: attachment; filename=receipt_data.csv"
								"\r\n\r\n");

	lseek(fd, 0, SEEK_SET);
	while (bytes_read > 0) {
		bytes_read = read(fd, &buf, BUF_SIZE);
		fwrite(buf, bytes_read, 1, stdout);
	}
{'fraction_non_alphanumeric': 0.16467391304347825, 'fraction_numerical': 0.009782608695652175, 'mean_word_length': 4.290229885057471, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2092966', 'n_tokens_mistral': 800, 'n_tokens_neox': 736, 'n_words': 168}