Example #1
0
void conf_time(char *timefile)
{
	lion_t *conf_file = NULL;
    char *tmp, *r;

    if (!timefile) {
        tmp = misc_strjoin(conf_file_name, "timestamp");
        if ((r = strrchr(tmp, '/'))) *r = '.';
        conf_file = lion_open(tmp, O_RDONLY, 0600,
                              LION_FLAG_NONE, NULL);
        SAFE_FREE(tmp);
    } else {
        conf_file = lion_open(timefile, O_RDONLY, 0600,
                              LION_FLAG_NONE, NULL);
    }

    // Not having a timestamp file is OK
	if (!conf_file) {
        return;
	}

	lion_set_handler(conf_file, conf_file_handler);

	do_exit = 0;
	while(!do_exit)
		lion_poll(0,1);
	do_exit = 0;

}
Example #2
0
void site_savecfg(char *timefile)
{
	int i;
	lion_t *save_file = NULL;

	// Assigning last_check
	for (i = 0; i < num_sites; i++) {

		if (sites[i]->num_files) {

			// Save last check for autoq
			sites[i]->last_check_autoq = sites[i]->last_check;

			sites[i]->last_check = sites[i]->files[0]->date;
			debugf("'%s' new last_check %lu\n", sites[i]->name,
				   sites[i]->last_check);
		}
	}

	// Saving info

	if (conf_do_save) {
        char *tmpname, *r;

        if (!timefile) {
            tmpname = misc_strjoin(conf_file_name, "timestamp");
            if ((r = strrchr(tmpname, '/'))) *r = '.';

            printf("Attempting to save '%s'\n", tmpname);
            save_file = lion_open(tmpname,
                                  O_WRONLY|O_TRUNC|O_CREAT,
                                  0600, LION_FLAG_NONE, NULL);
            SAFE_FREE(tmpname);
        } else {
            printf("Attempting to save '%s'\n", timefile);
            save_file = lion_open(timefile,
                                  O_WRONLY|O_TRUNC|O_CREAT,
                                  0600, LION_FLAG_NONE, NULL);
        }

		if (save_file) {
			lion_disable_read(save_file);
			debugf("saving conf...\n");
			conf_save(save_file);
			lion_close(save_file);
		}

	}

}
Example #3
0
void sites_init(void)
{

	// Read the sites file into memory. This can be issued many times
	// to re-read it if there are changes.



	// Free any memory first incase we are to re-load the file.
	sites_free();

	sites_id = 0;

	sites_file = lion_open(SITES_CONF,
						   O_RDONLY,
						   0600,
						   LION_FLAG_NONE, NULL);


	if (sites_file) {

		lion_set_handler(sites_file, sites_handler);

		if (sites_key) {

			lion_ssl_set(sites_file, LION_SSL_FILE);

			lion_ssl_setkey(sites_file, sites_key, strlen(sites_key));

		}

	}


}
Example #4
0
void settings_save(void)
{

	lion_t *conf_file;

	// Using lion to read a config file, well, well...

	conf_file = lion_open(".FXP.One.settings", O_WRONLY|O_TRUNC|O_CREAT, 0600,
						  LION_FLAG_NONE, NULL);

	if (!conf_file) {
		printf("settings: failed to create settings file!\n");
		return;
	}

	// Write only, disable read or LiON thinks its at EOF
	lion_disable_read(conf_file);

	// Not needed but we don't want events in the main handlers.
	lion_set_handler(conf_file, settings_handler);

	lion_printf(conf_file, "# FXP.One settings file. Written automatically.\r\n");

	lion_printf(conf_file, "CONF|VERSION=1.0\r\n");

	// Command settings
	lion_printf(conf_file, "CONF|command_port=%d|command_ssl_only=%d",
				settings_values.command_port,
				(int)settings_values.command_ssl_only);
	lion_printf(conf_file, "|http_port=%d|http_ssl_only=%d",
				settings_values.http_port,
				(int)settings_values.http_ssl_only);

	if (settings_values.command_iface)
		lion_printf(conf_file, "|command_iface=%s",
					lion_ntoa(settings_values.command_iface));
	if (settings_values.http_iface)
		lion_printf(conf_file, "|http_iface=%s",
					lion_ntoa(settings_values.http_iface));

	lion_printf(conf_file, "\r\n");

	lion_close(conf_file);

	settings_initialising = 0;
}
Example #5
0
void settings_init(void)
{
	lion_t *conf_file;


	settings_defaults();

	settings_initialising = 1;

	// Using lion to read a config file, well, well...
	conf_file = lion_open(".FXP.One.settings", O_RDONLY, 0600,
						  LION_FLAG_NONE, NULL);


	if (conf_file) lion_set_handler(conf_file, settings_handler);
	else settings_save();

}
Example #6
0
void conf_read(void)
{
	lion_t *conf_file;

	conf_file = lion_open(conf_file_name, O_RDONLY, 0600,
						  LION_FLAG_NONE, NULL);

	if (!conf_file) {
		perror("open:");
		exit(1);
	}

	lion_set_handler(conf_file, conf_file_handler);

	do_exit = 0;
	while(!do_exit)
		lion_poll(0,1);
	do_exit = 0;

}
Example #7
0
void sites_save(void)
{

	sites_file = lion_open(SITES_CONF,
						   O_WRONLY|O_CREAT|O_TRUNC,
						   0600,
						   LION_FLAG_NONE, NULL);


	if (sites_file) {

		lion_set_handler(sites_file, sites_handler);

		// We are writing, don't try to read the file.
		lion_disable_read(sites_file);

		if (sites_key) {

			lion_ssl_set(sites_file, LION_SSL_FILE);

			lion_ssl_setkey(sites_file, sites_key, strlen(sites_key));

		}

		sites_listentries(sites_file, SITES_LIST_SAVE);



		// Write something to the file
		lion_close(sites_file);
		return;

	}

	printf("[sites]: Warning, failed to create sites file? Permissions? Disk full?\n");

}