<commit_before>#include "common.h"
#include "umonitor.h"
#include "autoload.h"
#include "load.h"

/*! \file
	\brief Detect which profile to load

*/

#define PVAR ((autoload_pvar *) (self->pvar))

static void find_profile_and_load(autoload_class * self, int load, int print);
static void get_profile_found(autoload_class * self, int * profile_found, const char **profile_name);
static void determine_profile_match(autoload_class * self);
static void wait_for_event(autoload_class * self);
static void validate_timestamp_and_load(autoload_class * self);
static void count_output_match(void *self_void,
			       xcb_randr_output_t * output_p);
static void determine_output_match(autoload_class * self,
				   xcb_randr_output_t * output_p,
				   char *output_name);
static void print_connected_outputs(void *self_void,
				    xcb_randr_output_t * output_p);




// Autoload class private variables
typedef struct {
	// Inheriting classes
	screen_class *screen_o;	/*!< Connection information to server */
	/*! load object for loading after matching profile is found */
	load_class *load_o;

	// Variables
	config_t *config;	/*!< config handle */
	config_setting_t *mon_group, *cur_profile;	/*!< current monitor group */
	/*! how many outputs in configuration file match current display settings */
	int output_match;
	int num_out_pp;		/*!< Number of outputs per profile */
	int num_conn_outputs;	/*!< number of connected outputs */
	int load;
	int print;
	int profile_found;
	xcb_randr_screen_change_notify_event_t *randr_evt;
	const char *profile_name;

} autoload_pvar;


/*! Autload constructor*/
void autoload_constructor(autoload_class ** self_p,
			  screen_class * screen_o, config_t * config)
{
	autoload_class *self;

	self = (autoload_class *) umalloc(sizeof(autoload_class));
	self->pvar = (void *) umalloc(sizeof(autoload_pvar));

	PVAR->screen_o = screen_o;
	PVAR->config = config;
	self->wait_for_event = wait_for_event;

	self->find_profile_and_load = find_profile_and_load;
	self->get_profile_found = get_profile_found;
	load_class_constructor(&(PVAR->load_o), screen_o);

	xcb_randr_select_input(screen_o->c, screen_o->screen->root,
			       XCB_RANDR_NOTIFY_MASK_SCREEN_CHANGE);
	xcb_flush(screen_o->c);

	*self_p = self;
<commit_msg>Initialize profile_name in autoload class<commit_after>#include "common.h"
#include "umonitor.h"
#include "autoload.h"
#include "load.h"

/*! \file
	\brief Detect which profile to load

*/

#define PVAR ((autoload_pvar *) (self->pvar))

static void find_profile_and_load(autoload_class * self, int load, int print);
static void get_profile_found(autoload_class * self, int * profile_found, const char **profile_name);
static void determine_profile_match(autoload_class * self);
static void wait_for_event(autoload_class * self);
static void validate_timestamp_and_load(autoload_class * self);
static void count_output_match(void *self_void,
			       xcb_randr_output_t * output_p);
static void determine_output_match(autoload_class * self,
				   xcb_randr_output_t * output_p,
				   char *output_name);
static void print_connected_outputs(void *self_void,
				    xcb_randr_output_t * output_p);




// Autoload class private variables
typedef struct {
	// Inheriting classes
	screen_class *screen_o;	/*!< Connection information to server */
	/*! load object for loading after matching profile is found */
	load_class *load_o;

	// Variables
	config_t *config;	/*!< config handle */
	config_setting_t *mon_group, *cur_profile;	/*!< current monitor group */
	/*! how many outputs in configuration file match current display settings */
	int output_match;
	int num_out_pp;		/*!< Number of outputs per profile */
	int num_conn_outputs;	/*!< number of connected outputs */
	int load;
	int print;
	int profile_found;
	xcb_randr_screen_change_notify_event_t *randr_evt;
	const char *profile_name;

} autoload_pvar;


/*! Autload constructor*/
void autoload_constructor(autoload_class ** self_p,
			  screen_class * screen_o, config_t * config)
{
	autoload_class *self;

	self = (autoload_class *) umalloc(sizeof(autoload_class));
	self->pvar = (void *) umalloc(sizeof(autoload_pvar));

	PVAR->screen_o = screen_o;
	PVAR->config = config;
	PVAR->profile_name = NULL;
	self->wait_for_event = wait_for_event;

	self->find_profile_and_load = find_profile_and_load;
	self->get_profile_found = get_profile_found;
	load_class_constructor(&(PVAR->load_o), screen_o);

	xcb_randr_select_input(screen_o->c, screen_o->screen->root,
			       XCB_RANDR_NOTIFY_MASK_SCREEN_CHANGE);
	xcb_flush(screen_o->c);

	*self_p = self;

{'fraction_non_alphanumeric': 0.104340201665936, 'fraction_numerical': 0.0, 'mean_word_length': 5.267857142857143, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 28, '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': '3165648', 'n_tokens_mistral': 1626, 'n_tokens_neox': 1566, 'n_words': 358}