本文整理汇总了C++中write_config函数的典型用法代码示例。如果您正苦于以下问题:C++ write_config函数的具体用法?C++ write_config怎么用?C++ write_config使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了write_config函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: verifySDownConditions
void verifySDownConditions(void)
{
if(sDown_filtered < SDown_Threshold)
{
if(sd_printing)
{
initPause();
config.status = 9;
write_config();
sd_printing = false;
queue_flush();
reset_current_block();
home_z();
}
else if(printerPause)
{
config.status = 9;
write_config();
sd_printing = false;
queue_flush();
reset_current_block();
home_z();
}
}
}
示例2: notify_action
/*
* the notify_action_* functions get called when the user clicks on
* the respective buttons we put in the notification window.
* user_data contains the string we pass, so "yes" "no" "always" or "never".
*/
static void notify_action(NotifyNotification __unused *notify,
gchar __unused *action, gpointer user_data)
{
char *answer = (char *) user_data;
send_permission(answer);
detail_file_name = NULL;
if (strcmp(answer, "always") == 0)
write_config("always");
if (strcmp(answer, "never") == 0)
write_config("never");
gtk_status_icon_set_visible(statusicon, FALSE);
}
示例3: set_cluster_store
int set_cluster_store(const char *name)
{
memset(config.store, 0, sizeof(config.store));
pstrcpy((char *)config.store, sizeof(config.store), name);
return write_config();
}
示例4: new_array
bool ConfigFile::remove_rom_id_1(std::string package, std::string rom_id) {
const Json::Value syncacross =
m_root[CONF_PACKAGES][package][CONF_SYNC_ACROSS];
if (syncacross.isNull() || !syncacross.isArray()) {
return false;
}
bool removed = false;
// jsoncpp has no built-in way of removing items from an array
Json::Value new_array(Json::arrayValue);
for (unsigned int i = 0; i < syncacross.size(); i++) {
std::string value = syncacross[i].asString();
if (rom_id == value) {
removed = true;
continue;
}
new_array.append(value);
}
if (new_array.size() == 0) {
m_root[CONF_PACKAGES].removeMember(package);
removed = true;
} else {
m_root[CONF_PACKAGES][package][CONF_SYNC_ACROSS] = new_array;
}
if (removed) {
write_config();
}
return removed;
}
示例5: init_config_file
int init_config_file(void)
{
int fd, ret;
check_tmp_config();
fd = open(config_path, O_RDONLY);
if (fd < 0) {
if (errno != ENOENT) {
sd_eprintf("failed to read config file, %m");
return -1;
}
goto create;
}
ret = xread(fd, &config, sizeof(config));
if (ret == 0) {
close(fd);
goto create;
}
if (ret < 0) {
sd_eprintf("failed to read config file, %m");
goto out;
}
if (config.version != SD_FORMAT_VERSION) {
sd_eprintf("This sheep version is not compatible with"
" the existing data layout, %d", config.version);
if (sys->upgrade) {
/* upgrade sheep store */
ret = sd_migrate_store(config.version, SD_FORMAT_VERSION);
if (ret == 0) {
/* reload config file */
ret = xpread(fd, &config, sizeof(config), 0);
if (ret != sizeof(config)) {
sd_eprintf("failed to reload config"
" file, %m");
ret = -1;
} else
ret = 0;
}
goto out;
}
sd_eprintf("use '-u' option to upgrade sheep store");
ret = -1;
goto out;
}
ret = 0;
out:
close(fd);
return ret;
create:
config.version = SD_FORMAT_VERSION;
if (write_config() != SD_RES_SUCCESS)
return -1;
return 0;
}
示例6: terminate
void terminate (void)
{
/*
int fh[10000], i;
char buffer[100];
for (i=0; i<10000; i++)
{
sprintf (buffer, "file%d", i);
fh[i] = open (buffer, O_CREAT|O_WRONLY);
if (fh[i] < 0) break;
}
close (fh[0]);
*/
write_config ();
video_update (0);
set_window_name (wintitle);
fly_terminate ();
#ifdef __MINGW32__
WSACleanup ();
#endif
}
示例7: read_config
static void read_config(void)
{
gchar *path;
gboolean initial = FALSE;
debug_print("autoenc: read_config\n");
path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "autoencrc", NULL);
if (!is_file_exist(path)) {
initial = TRUE;
prefs_set_default(param);
} else {
prefs_read_config(param, "AutoEncrypt", path, NULL);
}
if (!config.autoenc_template_subject) {
config.autoenc_template_subject =
g_strdup(_("Password of encrypted file"));
}
if (!config.autoenc_template_body) {
config.autoenc_template_body =
g_strdup(_("Subject: %s\\n"
"Date: %d\\n"
"The password of the encrypted file attached in the above mail is as follows:\\n"
"\\n"
"File name: %z\\n"
"Password: %p"));
}
if (initial) {
write_config();
}
g_free(path);
}
示例8: project_close
/* open_default will make function reload default session files on close */
void project_close(gboolean open_default)
{
GSList *node;
g_return_if_fail(app->project != NULL);
ui_set_statusbar(TRUE, _("Project \"%s\" closed."), app->project->name);
/* use write_config() to save project session files */
if (!write_config(FALSE))
g_warning("Project file \"%s\" could not be written", app->project->file_name);
/* remove project filetypes build entries */
if (app->project->build_filetypes_list != NULL)
{
g_ptr_array_foreach(app->project->build_filetypes_list, remove_foreach_project_filetype, NULL);
g_ptr_array_free(app->project->build_filetypes_list, FALSE);
}
/* remove project non filetype build menu items */
build_remove_menu_item(GEANY_BCS_PROJ, GEANY_GBG_NON_FT, -1);
build_remove_menu_item(GEANY_BCS_PROJ, GEANY_GBG_EXEC, -1);
g_free(app->project->name);
g_free(app->project->description);
g_free(app->project->file_name);
g_free(app->project->base_path);
g_free(app->project);
app->project = NULL;
foreach_slist(node, stash_groups)
stash_group_free(node->data);
g_slist_free(stash_groups);
stash_groups = NULL;
apply_editor_prefs(); /* ensure that global settings are restored */
if (project_prefs.project_session)
{
/* close all existing tabs first */
document_close_all();
/* after closing all tabs let's open the tabs found in the default config */
if (open_default && cl_options.load_session)
{
configuration_reload_default_session();
configuration_open_files();
/* open a new file if no other file was opened */
document_new_file_if_non_open();
ui_focus_current_document();
}
}
g_signal_emit_by_name(geany_object, "project-close");
update_ui();
}
示例9: write_config
void server::handle_flush(const boost::system::error_code& error)
{
if(error) {
ERR_CS << "Error from reload timer: " << error.message() << "\n";
throw boost::system::system_error(error);
}
write_config();
flush_cfg();
}
示例10: write_config
JNIEXPORT jboolean JNICALL Java_com_fastrunningblog_FastRunningFriend_ConfigState_write_1config
(JNIEnv *env, jobject this_obj, jstring profile_name)
{
jboolean res;
const char* profile_name_s = (*env)->GetStringUTFChars(env,profile_name,0);
res = write_config(env,this_obj,profile_name_s);
(*env)->ReleaseStringUTFChars(env,profile_name,profile_name_s);
return res;
}
示例11: Java_com_fastrunningblog_FastRunningFriend_GPSCoordBuffer_init_1data_1dir
JNIEXPORT jboolean
Java_com_fastrunningblog_FastRunningFriend_GPSCoordBuffer_init_1data_1dir( JNIEnv* env,
jobject this_obj, jstring dir_name_str )
{
struct stat s;
jboolean status = 0;
const char *dir_name = (*env)->GetStringUTFChars(env, dir_name_str, NULL);
int dir_created = 0;
gps_data_dir[0] = 0;
if (!dir_name)
goto err;
if (stat(dir_name,&s))
{
jobject cfg_obj;
if (mkdir(dir_name,0755))
goto err;
dir_created = 1;
if (!(cfg_obj = (*env)->GetObjectField(env,this_obj,gps_buf_fields.cfg_id)))
{
LOGE("Could not find config object while writing default config file");
goto done;
}
if (!write_config(env,cfg_obj,"default"))
LOGE("Error writing default config file");
goto done;
}
if ((s.st_mode & S_IFMT) != S_IFDIR)
goto err;
done:
gps_data_dir_len = strlen(dir_name);
if (gps_data_dir_len > sizeof(gps_data_dir) - 1)
goto err;
memcpy(gps_data_dir,dir_name,gps_data_dir_len+1);
status = 1;
if (!dir_created)
remove_expired_files(env,this_obj,gps_data_dir);
err:
if (dir_name)
(*env)->ReleaseStringUTFChars(env,dir_name_str,dir_name);
return status;
}
示例12: s2e_clear
int s2e_clear (HTTP_INFO *info)
{
int chan;
for (chan = 0; chan < S2E_CHAN_MAX; chan ++) {
default_config (chan, &s2e_conf[chan]);
write_config (chan, &s2e_conf[chan]);
}
return 0;
}
示例13: set_cluster_config
int set_cluster_config(const struct cluster_info *cinfo)
{
config.ctime = cinfo->ctime;
config.copies = cinfo->nr_copies;
config.copy_policy = cinfo->copy_policy;
config.flags = cinfo->flags;
memset(config.store, 0, sizeof(config.store));
pstrcpy((char *)config.store, sizeof(config.store),
(char *)cinfo->store);
return write_config();
}
示例14: Settings
void write_config
(
const Ch* a_filename,
const basic_variant_tree<Ch>& a_tree,
config_format a_format,
const Settings& a_settings = Settings(),
const std::locale & a_loc = std::locale()
) {
write_config(std::basic_string<Ch>(a_filename),
a_tree, a_format, a_settings, a_loc);
}
示例15: write_config
void LoginWidget::set_connected (bool connected)
{
QString status;
if (connected)
{
status = "Connected to " + edit_host_->text();
write_config();
}
else
status = "Offline";
label_status_->setText(status);
}