Esempio n. 1
0
void reload_config() 
{
	free_cfg(0);
	ini = iniparser_load(DEF_CFG);
	if (ini==NULL) {
		write_to_log(FATAL, "cannot parse file: %s\n", DEF_CFG);
		goto err;
	}

	if (!section_list) {
		section_list = malloc(sizeof(struct sectionList));
		if(!section_list) {
			write_to_log(FATAL, "%s - %d - %s", __func__, __LINE__, "Unable to allocate memory");
			goto err;
		}
	}

	if (_get_sections() != 0) {
		write_to_log(FATAL, "%s - %d - %s", __func__, __LINE__, "Section List could not be filled");
		goto err;
	}

	write_to_log(INFO, "%s", "Configuration reloaded without error");

	return;
	err:
		exit(EXIT_FAILURE);
}
Esempio n. 2
0
int main(int argc, char** argv) 
{
	double		begin;
	double		end;
	size_t		nsym;
	size_t		nactive;
	size_t		n;
	size_t		max_succ;
	cfg_t*		cfg;
	bool		print;
	int		seed = 0;

	progname	= argv[0];

	if (argc == 7) {
		nsym	 	= atoi(argv[1]);
		n		= atoi(argv[2]);
		max_succ	= atoi(argv[3]);
		nactive	 	= atoi(argv[4]);
		print	 	= atoi(argv[6]);
	} else {
		nsym	 	= 100;
		n		= 10;
		max_succ	= 4;
		nactive	 	= 10;
		print		= 1;
	}

	printf("nsymbol   = %zu\n", nsym);
	printf("nvertex   = %zu\n", n);
	printf("max-succ  = %zu\n", max_succ);
	printf("nactive   = %zu\n", nactive);
	
	if (seed == 1)
		init_random(seed);
	else {
		printf("pid %d\n", getpid());
		init_random(getpid());
	}

	printf("generating cfg...\n");
	cfg = new_cfg(n, nsym, max_succ);
	generate_cfg(cfg, n, max_succ);

	printf("generating usedefs...\n");
	generate_usedefs(cfg, n, nsym, nactive);

	printf("liveness...\n\n");
	begin = sec();
	liveness(cfg);
	end = sec();

	printf("T = %8.4lf s\n\n", end-begin);

	if (print)
		print_sets(cfg, stdout);

	free_cfg(cfg);
	return 0;
}
Esempio n. 3
0
/* this function free the memory allocated and exit
 * and it is called on signals */
void destroyall(int status)
{

	odbc_free();
	disconnect_db();
	close(portfd);
	free_emb_info();
	free_cfg();
	exit(-1);

}
Esempio n. 4
0
/* this is the main body */
int main(int argc, char *argv[])
{

	if (cfg.verbose)
		printf("%s version %s\n", APPNAME, VERSION);

	/* fill the cfg struct with the default options */
	fill_default_options();
	/* parse options from config file */
	parse_cfgfile(cfg.cfgfile);
	/* parse the command line options */
	parse_opts(argc, argv);

	odbc_alloc();
	connect_db(cfg.dsn, cfg.dbuser, cfg.dbpass);
	get_embedded_infos();
	disconnect_db();

	/* if cfg.daemon option is set to 1 we go to background */
	if (cfg.daemon)
		daemon(0, 0);

	/* set signal hook function */
	signal(SIGHUP, &destroyall);
	signal(SIGINT, &destroyall);
	signal(SIGQUIT, &destroyall);
	signal(SIGTERM, &destroyall);
	signal(SIGABRT, &destroyall);

	/* open and configure the serial port */
	cfgport();
	/* enter the main loop */
	serial_mainloop();

	odbc_free();
	disconnect_db();
	free_cfg();
	free_emb_info();

	exit(0);
}
Esempio n. 5
0
void update_userlist_callback(GtkWidget *wiggy, gpointer data)
{
	GtkWidget		*w;
	GtkListStore	*lstore = NULL;
	int				totalusers;
	int				i;
	GtkTreeIter		curr;
	char			str[1024];

	free_cfg(&cfg);
	if(!load_cfg(&cfg, NULL, TRUE, str)) {
		display_message("Load Error","Cannot load configuration data","gtk-dialog-error");
		return;
    }

	w=glade_xml_get_widget(lxml, "lUserList");
	lstore=GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(w)));
	gtk_list_store_clear(lstore);
	totalusers=lastuser(&cfg);
	for(i=1; i<=totalusers; i++) {
		gtk_list_store_insert(lstore, &curr, i-1);
		update_userlist_item(lstore, &curr, i);
	}
}
Esempio n. 6
0
BOOL DLLCALL load_cfg(scfg_t* cfg, char* text[], BOOL prep, char* error)
{
	int		i;
#ifdef SBBS
	long	line=0L;
	FILE 	*instream;
	char	str[256],fname[13];
#endif

	if(cfg->size!=sizeof(scfg_t)) {
		sprintf(error,"cfg->size (%"PRIu32") != sizeof(scfg_t) (%d)"
			,cfg->size,sizeof(scfg_t));
		return(FALSE);
	}

	free_cfg(cfg);	/* free allocated config parameters */

	cfg->prepped=FALSE;	/* reset prepped flag */

	if(cfg->node_num<1)
		cfg->node_num=1;

	backslash(cfg->ctrl_dir);
	if(read_main_cfg(cfg, error)==FALSE)
		return(FALSE);

	if(prep)
		for(i=0;i<cfg->sys_nodes;i++) 
			prep_dir(cfg->ctrl_dir, cfg->node_path[i], sizeof(cfg->node_path[i]));

	SAFECOPY(cfg->node_dir,cfg->node_path[cfg->node_num-1]);
	prep_dir(cfg->ctrl_dir, cfg->node_dir, sizeof(cfg->node_dir));
	if(read_node_cfg(cfg, error)==FALSE)
		return(FALSE);
	if(read_msgs_cfg(cfg, error)==FALSE)
		return(FALSE);
	if(read_file_cfg(cfg, error)==FALSE)
		return(FALSE);
	if(read_xtrn_cfg(cfg, error)==FALSE)
		return(FALSE);
	if(read_chat_cfg(cfg, error)==FALSE)
		return(FALSE);
	if(read_attr_cfg(cfg, error)==FALSE)
		return(FALSE);

#ifdef SBBS
	if(text!=NULL) {

		/* Free existing text if allocated */
		free_text(text);

		strcpy(fname,"text.dat");
		sprintf(str,"%s%s",cfg->ctrl_dir,fname);
		if((instream=fnopen(NULL,str,O_RDONLY))==NULL) {
			sprintf(error,"%d opening %s",errno,str);
			return(FALSE); 
		}
		for(i=0;i<TOTAL_TEXT;i++)
			if((text[i]=readtext(&line,instream,i))==NULL) {
				i--;
				break;
			}
		fclose(instream);

		if(i<TOTAL_TEXT) {
			sprintf(error,"line %d in %s: Less than TOTAL_TEXT (%u) strings defined in %s."
				,i,fname
				,TOTAL_TEXT,fname);
			return(FALSE); 
		}
	}
#endif

    /* Override com-port settings */
    cfg->com_base=0xf;	/* All nodes use FOSSIL */
    cfg->com_port=1;	/* All nodes use "COM1" */

	if(prep)
		prep_cfg(cfg);

	/* Auto-toggle daylight savings time in US time-zones */
	sys_timezone(cfg);

	return(TRUE);
}