本文整理汇总了C++中config_write函数的典型用法代码示例。如果您正苦于以下问题:C++ config_write函数的具体用法?C++ config_write怎么用?C++ config_write使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了config_write函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: controltype_button_notify
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//controltype_button_notify
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void controltype_button_notify(control *c, int notifytype, void *messagedata)
{
//Variables
controltype_button_details *details;
bool *newvalueptr;
//Get details
details = (controltype_button_details *) c->controldetails;
//Find out what to do
switch (notifytype)
{
case NOTIFY_NEEDUPDATE:
//When we are told we need an update, figure out what to do
//Update the caption first
if (details->agents[CONTROLTYPE_BUTTON_CAPTION])
{
details->caption = (char *) agent_getdata(details->agents[CONTROLTYPE_BUTTON_CAPTION], DATAFETCH_VALUE_TEXT);
}
else
{
details->caption = NULL;
}
//Only two state buttons need updates at this point
if (details->is_twostate)
{
//Get the value
newvalueptr = (bool *)(agent_getdata(details->agents[CONTROLTYPE_TWOSTATEBUTTON_AGENT_VALUECHANGE], DATAFETCH_VALUE_BOOL));
if (newvalueptr)
{
//Set the new value
details->is_on = *newvalueptr;
}
}
//Tell the button to draw itself again
style_draw_invalidate(c);
break;
case NOTIFY_SAVE_CONTROL:
//Save all local values
config_write(config_get_control_setcontrolprop_c(c, "HAlign", button_haligns[details->halign]));
config_write(config_get_control_setcontrolprop_c(c, "VAlign", button_valigns[details->valign]));
int i;
for (i = 0; i < CONTROLTYPE_BUTTON_AGENTCOUNT; i++)
agent_notify(details->agents[i], NOTIFY_SAVE_AGENT, NULL);
if (details->is_twostate)
config_write(config_get_control_setcontrolprop_b(c, "Pressed", &details->is_on));
break;
case NOTIFY_DRAGACCEPT:
DragAcceptFiles(c->windowptr->hwnd, NULL != details->agents[details->is_twostate ? CONTROLTYPE_TWOSTATEBUTTON_AGENT_ONDROP : CONTROLTYPE_BUTTON_AGENT_ONDROP]);
break;
}
}
示例2: controltype_label_notify
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//controltype_label_notify
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void controltype_label_notify(control *c, int notifytype, void *messagedata)
{
//Variables
controltype_label_details *details;
int i;
//Get details
details = (controltype_label_details *) c->controldetails;
//Find out what to do
switch (notifytype)
{
case NOTIFY_NEEDUPDATE:
//When we are told we need an update, figure out what to do
//Update the caption first
if (details->agents[CONTROLTYPE_LABEL_AGENT_CAPTION])
{
details->caption = (char *) agent_getdata(details->agents[CONTROLTYPE_LABEL_AGENT_CAPTION], DATAFETCH_VALUE_TEXT);
}
else
{
details->caption = NULL;
}
//Tell the label to draw itself again
style_draw_invalidate(c);
break;
case NOTIFY_SAVE_CONTROL:
//Save all local values
config_write(config_get_control_setcontrolprop_c(c, "HAlign", label_haligns[details->halign]));
config_write(config_get_control_setcontrolprop_c(c, "VAlign", label_valigns[details->valign]));
if (details->is_frame)
{
config_write(config_get_control_setcontrolprop_b(c, "HasTitleBar", &details->has_titlebar));
config_write(config_get_control_setcontrolprop_b(c, "IsLocked", &details->is_locked));
}
for (i = 0; i < CONTROLTYPE_LABEL_AGENT_COUNT; i++)
agent_notify(details->agents[i], NOTIFY_SAVE_AGENT, NULL);
if (details->is_frame)
controltype_frame_saveplugins(c);
break;
case NOTIFY_DRAGACCEPT:
DragAcceptFiles(c->windowptr->hwnd, NULL != details->agents[CONTROLTYPE_LABEL_AGENT_ONDROP]);
break;
}
}
示例3: config_initialize
void config_initialize()
{
// Build config directory name
gchar * config_dir = g_build_filename(g_get_user_config_dir(),
CONFIG_DIRNAME, NULL);
m_config_file = g_build_filename(config_dir, CONFIG_FILENAME, NULL);
// Make sure config directory exists
if(!g_file_test(config_dir, G_FILE_TEST_IS_DIR))
g_mkdir(config_dir, 0777);
// If a config file doesn't exist, create one with defaults otherwise
// read the existing one.
if(!g_file_test(m_config_file, G_FILE_TEST_EXISTS))
{
config_load_default();
config_write();
}
else
{
config_read();
}
g_free(config_dir);
}
示例4: agenttype_switchedstate_notify
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//agenttype_switchedstate_notify
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void agenttype_switchedstate_notify(agent *a, int notifytype, void *messagedata)
{
//Get the agent details
agenttype_switchedstate_details *details = (agenttype_switchedstate_details *) a->agentdetails;
//Declare variables
bool *boolptr;
switch(notifytype)
{
case NOTIFY_DRAW:
case NOTIFY_CHANGE:
//Get the boolean value
boolptr = (bool *) agent_getdata(details->agents[AGENTTYPE_SWITCHEDSTATE_AGENT_BOOL], DATAFETCH_VALUE_BOOL);
//Do the appropriate action
if (boolptr != NULL && *boolptr == true) return agent_notify(details->agents[AGENTTYPE_SWITCHEDSTATE_AGENT_WHENTRUE], notifytype, messagedata);
else return agent_notify(details->agents[AGENTTYPE_SWITCHEDSTATE_AGENT_WHENFALSE], notifytype, messagedata);
break;
case NOTIFY_SAVE_AGENT:
//Write existance
config_write(config_get_control_setagent_c(a->controlptr, a->agentaction, a->agenttypeptr->agenttypename, agenttype_switchedstate_typenames[details->datatype]));
//Save all child agents, if necessary
for (int i = 0; i < 3; i++) agent_notify(details->agents[i], NOTIFY_SAVE_AGENT, NULL);
break;
}
}
示例5: config_init
/**
* Start up the configuration system, using the configuration file given
* to get the current values. If the configuration file given does not exist,
* go ahead and write out the default config to the file.
*/
gint config_init (const gchar *config_file)
{
gint ret = 0;
tc = cfg_init (config_opts, 0);
/* I know that this is racy, but I can't think of a good
* way to fix it ... */
if (g_file_test (config_file, G_FILE_TEST_IS_REGULAR)) {
/* Read the file, and try to upgrade it */
ret = cfg_parse (tc, config_file);
if (ret == CFG_SUCCESS)
try_to_update_config_file (config_file);
else {
DEBUG_ERROR ("Problem parsing config");
g_printerr (_("Problem parsing config file\n"));
return 1;
}
}
/* This is commented out because we don't want to do this. Basically, there
* is no need to write the config until we have shown the wizard, which is
* automatically shown on the first run. */
#if 0
else {
/* Write out the defaults */
config_write (config_file);
}
#endif
return 0;
}
示例6: application_function_config_write
irom static app_action_t application_function_config_write(application_parameters_t ap)
{
config_write();
strlcpy(ap.dst, "config write OK\n", ap.size);
return(app_action_normal);
}
示例7: quit
//quit
void quit()
{
free_lists();
config_write();
SetWindowLong( plugin.hwndParent, GWL_WNDPROC, ( LONG )lpWndProcOld );
}
示例8: plugin_save
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//plugin_save
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void plugin_save()
{
config_printf("!---- %s ----", szVersion);
for (struct plugin_properties *p = plugin_properties; p->key; p++)
if (p->data) switch (p->type) {
case M_BOL: config_write(config_get_plugin_setpluginprop_b(p->key, (bool*)p->data)); break;
case M_INT: config_write(config_get_plugin_setpluginprop_i(p->key, (const int*)p->data)); break;
case M_STR: config_write(config_get_plugin_setpluginprop_c(p->key, *(const char**)p->data)); break;
}
//Save OnLoad/OnUnload actions
config_write(config_get_plugin_onload());
config_write(config_get_plugin_onunload());
variables_save();
}
示例9: OnDestroy
static void OnDestroy(HWND hwnd)
{
write_text();
config_write();
systray_del(hwnd,1024);
PostQuitMessage(0);
}
示例10: cmd_upgrade
/* SYNTAX: UPGRADE [<irssi binary path>] */
static void cmd_upgrade(const char *data)
{
CONFIG_REC *session;
char *session_file, *str;
char *binary;
if (*data == '\0')
data = irssi_binary;
if ((binary = g_find_program_in_path(data)) == NULL)
cmd_return_error(CMDERR_PROGRAM_NOT_FOUND);
/* save the session */
session_file = g_strdup_printf("%s/session", get_irssi_dir());
session = config_open(session_file, 0600);
unlink(session_file);
signal_emit("session save", 1, session);
config_write(session, NULL, -1);
config_close(session);
/* data may contain some other program as well, like
/UPGRADE /usr/bin/screen irssi */
str = g_strdup_printf("%s --noconnect --session=%s --home=%s --config=%s",
binary, session_file, get_irssi_dir(), get_irssi_config());
g_free(binary);
g_free(session_file);
session_args = g_strsplit(str, " ", -1);
g_free(str);
signal_emit("gui exit", 0);
}
示例11: write_server
static void
write_server(GQServerList* list, GqServer* server, gpointer user_data) {
gpointer* wc_and_cfg = user_data;
struct writeconfig* wc = wc_and_cfg[0];
struct gq_config * cfg = wc_and_cfg[1];
/* GString *pw = g_string_new(); */
config_write(wc, "<ldapserver>\n");
wc->indent++;
config_write_string(wc, server->name, "name", NULL);
config_write_string(wc, server->ldaphost, "ldaphost", NULL);
config_write_int(wc, server->ldapport, "ldapport", NULL);
config_write_string_ne(wc, server->basedn, "basedn", NULL);
config_write_string_ne(wc, server->binddn, "binddn", NULL);
if (cfg->config_version == 0) {
config_write_string_ne(wc, server->bindpw, "bindpw", NULL);
} else if(server->bindpw && *server->bindpw) {
gq_keyring_save_server_password(server);
}
if(server->bindtype != DEFAULT_BINDTYPE)
config_write_string_ne(wc, detokenize(token_bindtype, server->bindtype), "bindtype", NULL);
config_write_string_ne(wc, server->searchattr,
"search-attribute", NULL);
if(server->maxentries != DEFAULT_MAXENTRIES)
config_write_int(wc, server->maxentries, "maxentries", NULL);
if(server->cacheconn != DEFAULT_CACHECONN)
config_write_bool(wc, server->cacheconn,
"cache-connection", NULL);
if(server->enabletls != DEFAULT_ENABLETLS)
config_write_bool(wc, server->enabletls, "enable-tls", NULL);
if(server->local_cache_timeout != DEFAULT_LOCAL_CACHE_TIMEOUT)
config_write_int(wc, server->local_cache_timeout,
"local-cache-timeout", NULL);
if(server->ask_pw != DEFAULT_ASK_PW)
config_write_bool(wc, server->ask_pw, "ask-pw", NULL);
if(server->hide_internal != DEFAULT_HIDE_INTERNAL)
config_write_bool(wc, server->hide_internal,
"hide-internal", NULL);
if(server->show_ref != DEFAULT_SHOW_REF)
config_write_bool(wc, server->show_ref, "show-ref", NULL);
wc->indent--;
config_write(wc, "</ldapserver>\n\n");
}
示例12: wallet_save_keys
static int
wallet_save_keys(struct wallet *wallet)
{
struct config *cfg;
int res;
int n;
n = hashtable_getnumentries(wallet->hash_keys);
Log(LGPFX" saving %u key%s in %sencrypted wallet %s.\n",
n, n > 1 ? "s" : "",
wallet->pass ? "encrypted" : "NON-",
wallet->filename);
cfg = config_create();
config_setint64(cfg, n, "numKeys");
if (wallet->pass) {
char saltStr[80];
int64 count = 0;
bool s;
res = RAND_bytes(wallet->ckey->salt, sizeof wallet->ckey->salt);
if (res != 1) {
res = ERR_get_error();
Log(LGPFX" RAND_bytes failed: %d\n", res);
goto exit;
}
str_snprintf_bytes(saltStr, sizeof saltStr, NULL,
wallet->ckey->salt, sizeof wallet->ckey->salt);
config_setstring(cfg, saltStr, "encryption.salt");
s = crypt_set_key_from_passphrase(wallet->pass, wallet->ckey, &count);
ASSERT(s);
ASSERT(count >= CRYPT_NUM_ITERATIONS_OLD);
config_setint64(cfg, count, "encryption.numIterations");
}
hashtable_for_each(wallet->hash_keys, wallet_save_key_cb, cfg);
file_rotate(wallet->filename, 1);
res = file_create(wallet->filename);
if (res) {
Log(LGPFX" failed to create file '%s': %s\n",
wallet->filename, strerror(res));
goto exit;
}
res = file_chmod(wallet->filename, 0600);
if (res) {
Log(LGPFX" failed to chmod 0600 wallet.dat: %s\n",
strerror(res));
goto exit;
}
res = config_write(cfg, wallet->filename);
exit:
config_free(cfg);
return res;
}
示例13: sig_write_users
static int sig_write_users(void)
{
if (last_write + WRITE_USERS_INTERVAL <= time(NULL)) {
last_write = time(NULL);
config_write(userconfig, NULL, -1);
}
return 1;
}
示例14: config_write_end_tag
void config_write_end_tag(struct writeconfig *wc, const char *entity)
{
GString *outstr = g_string_sized_new(128);
end_tag(outstr, entity);
config_write(wc, outstr->str);
g_string_free(outstr, TRUE);
}
示例15: agenttype_diskspacemonitor_notify
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//agenttype_diskspacemonitor_notify
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void agenttype_diskspacemonitor_notify(agent *a, int notifytype, void *messagedata)
{
//Get the agent details
agenttype_diskspacemonitor_details *details = (agenttype_diskspacemonitor_details *) a->agentdetails;
switch(notifytype)
{
case NOTIFY_CHANGE:
control_notify(a->controlptr, NOTIFY_NEEDUPDATE, NULL);
break;
case NOTIFY_SAVE_AGENT:
//Write existance
config_write(config_get_control_setagent_c(a->controlptr, a->agentaction, a->agenttypeptr->agenttypename, agenttype_diskspacemonitor_types[details->monitor_type]));
config_write(config_get_control_setagentprop_c(a->controlptr, a->agentaction, "MonitoringPath",details->path));
break;
}
}