<commit_before>/* Command line utility to practice habit forming using randomised rewards *
 * Author: <NAME>							   *
 * 09/04/2012
 * 02/03/2014 - minor improvements
 */
#include "habit.h"

#include <stdbool.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <assert.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
static habit *habits;
static size_t nrec = 10;
static int nhabit = 1;

static char *get_default_storage_path();
static int get_id();
static int get_line(char **line, size_t * len, FILE * f);
static char *get_habit(char *line);
static char *get_reward(char *line);
static char *get_string_at_field(char *line, int nfield);
static int get_int_at_field(char *line, int nfield);
static int get_score(char *line);
static int get_ngates(char *line);
static int get_record_score();
static void record_habit(char *id);
static void usage();

static int add_habit(char *habit, char *reward)
{
	FILE *f;
	char *path;
	int id;

	path = get_default_storage_path();
	f = fopen(path, "a");
	if (f == NULL) {
		fprintf(stderr, "Unable to open file \"%s\": %s\n", path,
			__func__);<commit_msg>Add decleration of add_habit function<commit_after>/* Command line utility to practice habit forming using randomised rewards *
 * Author: <NAME>							   *
 * 09/04/2012
 * 02/03/2014 - minor improvements
 */
#include "habit.h"

#include <stdbool.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <assert.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
static habit *habits;
static size_t nrec = 10;
static int nhabit = 1;

static int add_habit(char *habit, char *reward);
static char *get_default_storage_path();
static int get_id();
static int get_line(char **line, size_t * len, FILE * f);
static char *get_habit(char *line);
static char *get_reward(char *line);
static char *get_string_at_field(char *line, int nfield);
static int get_int_at_field(char *line, int nfield);
static int get_score(char *line);
static int get_ngates(char *line);
static int get_record_score();
static void record_habit(char *id);
static void usage();

static int add_habit(char *habit, char *reward)
{
	FILE *f;
	char *path;
	int id;

	path = get_default_storage_path();
	f = fopen(path, "a");
	if (f == NULL) {
		fprintf(stderr, "Unable to open file \"%s\": %s\n", path,
			__func__);
{'fraction_non_alphanumeric': 0.14315266859743483, 'fraction_numerical': 0.015721969383533305, 'mean_word_length': 4.970370370370371, 'pattern_counts': {'":': 2, '<': 25, '<?xml version=': 0, '>': 25, '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': '3410362', 'n_tokens_mistral': 938, 'n_tokens_neox': 888, 'n_words': 271}