Config is now saved and added /save command
This commit is contained in:
parent
b4ff775f03
commit
77e0d01d7a
@ -1,11 +1,12 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
ChangeLog - 2003-09-29
|
||||
ChangeLog - 2003-10-01
|
||||
|
||||
|
||||
Version 0.0.2 (under dev!):
|
||||
* added new WeeChat commands: server, connect, disconnect
|
||||
* config is now saved automatically when quitting WeeChat
|
||||
* added new WeeChat commands: server, connect, disconnect, save
|
||||
* added autoconnect flag for each server in config file
|
||||
* term window title is modified with WeeChat name and version
|
||||
* fixed nicklist display bug
|
||||
|
5
TODO
5
TODO
@ -1,7 +1,7 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
TODO - 2003-09-29
|
||||
TODO - 2003-10-01
|
||||
|
||||
Legend:
|
||||
# done
|
||||
@ -23,6 +23,7 @@ v0.0.2:
|
||||
# "/connect" and "/disconnect" commands (for multiservers use)
|
||||
# "/server" command to add, remove or list servers
|
||||
- "/reload" command: reload the WeeChat's config file
|
||||
# "/save" command: save configuration to disk
|
||||
+ "/set" command: allow the user to set the WeeChat variables
|
||||
under WeeChat without editing the config file (colours, time
|
||||
format, etc)
|
||||
@ -36,7 +37,7 @@ v0.0.2:
|
||||
- connect to server with child process (background)
|
||||
|
||||
* Configuration:
|
||||
- write config file
|
||||
# write config file
|
||||
- add an option for each server in order to run commands on join
|
||||
(example: /msg nickserv identify password)
|
||||
- channel list for auto-join (for each server)
|
||||
|
@ -71,6 +71,9 @@ t_weechat_command weechat_commands[] =
|
||||
"username: user name\n"
|
||||
"realname: real name of user\n"),
|
||||
0, MAX_ARGS, weechat_cmd_server, NULL },
|
||||
{ "save", N_("save config to disk"),
|
||||
N_("[file]"), N_("file: filename for writing config"),
|
||||
0, 1, weechat_cmd_save, NULL },
|
||||
{ "set", N_("set config parameters"),
|
||||
N_("[option [value]]"), N_("option: name of an option\nvalue: value for option"),
|
||||
0, 2, weechat_cmd_set, NULL },
|
||||
@ -942,6 +945,16 @@ weechat_cmd_server (int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_cmd_save: set options
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_cmd_save (int argc, char **argv)
|
||||
{
|
||||
return (config_write ((argc == 1) ? argv[0] : NULL));
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_cmd_set: set options
|
||||
*/
|
||||
|
@ -60,6 +60,7 @@ extern int weechat_cmd_connect (int, char **);
|
||||
extern int weechat_cmd_disconnect (int, char **);
|
||||
extern int weechat_cmd_help (int, char **);
|
||||
extern int weechat_cmd_server (int, char **);
|
||||
extern int weechat_cmd_save (int, char **);
|
||||
extern int weechat_cmd_set (int, char **);
|
||||
extern int weechat_cmd_unalias (int, char **);
|
||||
|
||||
|
176
src/config.c
176
src/config.c
@ -889,6 +889,8 @@ config_read ()
|
||||
|
||||
/*
|
||||
* config_create_default: create default WeeChat config
|
||||
* return: 0 if ok
|
||||
* < 0 if error
|
||||
*/
|
||||
|
||||
int
|
||||
@ -905,20 +907,19 @@ config_create_default ()
|
||||
sprintf (filename, "%s/.weechat/" WEECHAT_CONFIG_NAME, getenv ("HOME"));
|
||||
if ((file = fopen (filename, "wt")) == NULL)
|
||||
{
|
||||
free (filename);
|
||||
gui_printf (NULL, _("%s cannot create file \"%s\"\n"),
|
||||
WEECHAT_ERROR, filename);
|
||||
free (filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf (_(WEECHAT_NAME ": creating default config file...\n"));
|
||||
log_printf (_("creating default config file\n"));
|
||||
|
||||
current_time = time (NULL);
|
||||
sprintf (line, _("#\n# " WEECHAT_NAME " configuration file, generated by "
|
||||
WEECHAT_NAME " " WEECHAT_VERSION " on %s"), ctime (¤t_time));
|
||||
sprintf (line, _("#\n# " WEECHAT_NAME " configuration file, created by "
|
||||
WEECHAT_NAME " " WEECHAT_VERSION " on %s#\n"), ctime (¤t_time));
|
||||
fputs (line, file);
|
||||
fputs (_("# This file may be edited by user. Invalid syntax will prevent "
|
||||
WEECHAT_NAME " from running!\n#\n"), file);
|
||||
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
@ -938,24 +939,24 @@ config_create_default ()
|
||||
{
|
||||
switch (weechat_options[i][j].option_type)
|
||||
{
|
||||
case OPTION_TYPE_BOOLEAN:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].
|
||||
default_int) ? "on" : "off");
|
||||
break;
|
||||
case OPTION_TYPE_INT:
|
||||
sprintf (line, "%s=%d\n",
|
||||
weechat_options[i][j].option_name,
|
||||
weechat_options[i][j].default_int);
|
||||
break;
|
||||
case OPTION_TYPE_INT_WITH_STRING:
|
||||
case OPTION_TYPE_COLOR:
|
||||
case OPTION_TYPE_STRING:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
weechat_options[i][j].default_string);
|
||||
break;
|
||||
case OPTION_TYPE_BOOLEAN:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].default_int) ?
|
||||
"on" : "off");
|
||||
break;
|
||||
case OPTION_TYPE_INT:
|
||||
sprintf (line, "%s=%d\n",
|
||||
weechat_options[i][j].option_name,
|
||||
weechat_options[i][j].default_int);
|
||||
break;
|
||||
case OPTION_TYPE_INT_WITH_STRING:
|
||||
case OPTION_TYPE_COLOR:
|
||||
case OPTION_TYPE_STRING:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
weechat_options[i][j].default_string);
|
||||
break;
|
||||
}
|
||||
fputs (line, file);
|
||||
}
|
||||
@ -982,10 +983,133 @@ config_create_default ()
|
||||
|
||||
/*
|
||||
* config_write: write WeeChat configurtion
|
||||
* return: 0 if ok
|
||||
* < 0 if error
|
||||
*/
|
||||
|
||||
void
|
||||
config_write ()
|
||||
int
|
||||
config_write (char *config_name)
|
||||
{
|
||||
/* TODO: write "config_write" function! */
|
||||
char *filename;
|
||||
char line[1024];
|
||||
FILE *file;
|
||||
int i, j;
|
||||
time_t current_time;
|
||||
t_irc_server *ptr_server;
|
||||
|
||||
if (config_name)
|
||||
filename = strdup (config_name);
|
||||
else
|
||||
{
|
||||
filename =
|
||||
(char *) malloc ((strlen (getenv ("HOME")) + 64) * sizeof (char));
|
||||
sprintf (filename, "%s/.weechat/" WEECHAT_CONFIG_NAME, getenv ("HOME"));
|
||||
}
|
||||
|
||||
if ((file = fopen (filename, "wt")) == NULL)
|
||||
{
|
||||
gui_printf (NULL, _("%s cannot create file \"%s\"\n"),
|
||||
WEECHAT_ERROR, filename);
|
||||
free (filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
log_printf (_("saving config to disk\n"));
|
||||
|
||||
current_time = time (NULL);
|
||||
sprintf (line, _("#\n# " WEECHAT_NAME " configuration file, created by "
|
||||
WEECHAT_NAME " " WEECHAT_VERSION " on %s#\n"), ctime (¤t_time));
|
||||
fputs (line, file);
|
||||
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
if (i != CONFIG_SECTION_SERVER)
|
||||
{
|
||||
sprintf (line, "\n[%s]\n", config_sections[i].section_name);
|
||||
fputs (line, file);
|
||||
if ((i == CONFIG_SECTION_HISTORY) || (i == CONFIG_SECTION_LOG) ||
|
||||
(i == CONFIG_SECTION_DCC) || (i == CONFIG_SECTION_PROXY))
|
||||
{
|
||||
sprintf (line,
|
||||
"# WARNING!!! Options for section \"%s\" are not developed!\n",
|
||||
config_sections[i].section_name);
|
||||
fputs (line, file);
|
||||
}
|
||||
for (j = 0; weechat_options[i][j].option_name; j++)
|
||||
{
|
||||
switch (weechat_options[i][j].option_type)
|
||||
{
|
||||
case OPTION_TYPE_BOOLEAN:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].ptr_int &&
|
||||
*weechat_options[i][j].ptr_int) ?
|
||||
"on" : "off");
|
||||
break;
|
||||
case OPTION_TYPE_INT:
|
||||
sprintf (line, "%s=%d\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].ptr_int) ?
|
||||
*weechat_options[i][j].ptr_int :
|
||||
weechat_options[i][j].default_int);
|
||||
break;
|
||||
case OPTION_TYPE_INT_WITH_STRING:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].ptr_int) ?
|
||||
weechat_options[i][j].array_values[*weechat_options[i][j].ptr_int] :
|
||||
weechat_options[i][j].array_values[weechat_options[i][j].default_int]);
|
||||
break;
|
||||
case OPTION_TYPE_COLOR:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].ptr_int) ?
|
||||
gui_get_color_by_value (*weechat_options[i][j].ptr_int) :
|
||||
weechat_options[i][j].default_string);
|
||||
break;
|
||||
case OPTION_TYPE_STRING:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].ptr_string) ?
|
||||
*weechat_options[i][j].ptr_string :
|
||||
weechat_options[i][j].default_string);
|
||||
break;
|
||||
}
|
||||
fputs (line, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
/* default server is freenode */
|
||||
fputs ("\n[server]\n", file);
|
||||
sprintf (line, "server_name=%s\n", ptr_server->name);
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_autoconnect=%s\n",
|
||||
(ptr_server->autoconnect) ? "on" : "off");
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_address=%s\n", ptr_server->address);
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_port=%d\n", ptr_server->port);
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_password=%s\n",
|
||||
(ptr_server->password) ? ptr_server->password : "");
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_nick1=%s\n", ptr_server->nick1);
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_nick2=%s\n", ptr_server->nick2);
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_nick3=%s\n", ptr_server->nick3);
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_username=%s\n", ptr_server->username);
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_realname=%s\n", ptr_server->realname);
|
||||
fputs (line, file);
|
||||
}
|
||||
|
||||
fclose (file);
|
||||
free (filename);
|
||||
return 0;
|
||||
}
|
||||
|
@ -150,6 +150,6 @@ extern t_config_option * weechat_options [CONFIG_NUMBER_SECTIONS];
|
||||
|
||||
extern int config_read ();
|
||||
extern int config_create_default ();
|
||||
extern void config_write ();
|
||||
extern int config_write ();
|
||||
|
||||
#endif /* config.h */
|
||||
|
@ -306,6 +306,9 @@ main (int argc, char *argv[])
|
||||
gui_main_loop ();
|
||||
server_disconnect_all ();
|
||||
|
||||
/* save config file */
|
||||
config_write (NULL);
|
||||
|
||||
/* program ending */
|
||||
wee_shutdown ();
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
ChangeLog - 2003-09-29
|
||||
ChangeLog - 2003-10-01
|
||||
|
||||
|
||||
Version 0.0.2 (under dev!):
|
||||
* added new WeeChat commands: server, connect, disconnect
|
||||
* config is now saved automatically when quitting WeeChat
|
||||
* added new WeeChat commands: server, connect, disconnect, save
|
||||
* added autoconnect flag for each server in config file
|
||||
* term window title is modified with WeeChat name and version
|
||||
* fixed nicklist display bug
|
||||
|
@ -1,7 +1,7 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
TODO - 2003-09-29
|
||||
TODO - 2003-10-01
|
||||
|
||||
Legend:
|
||||
# done
|
||||
@ -23,6 +23,7 @@ v0.0.2:
|
||||
# "/connect" and "/disconnect" commands (for multiservers use)
|
||||
# "/server" command to add, remove or list servers
|
||||
- "/reload" command: reload the WeeChat's config file
|
||||
# "/save" command: save configuration to disk
|
||||
+ "/set" command: allow the user to set the WeeChat variables
|
||||
under WeeChat without editing the config file (colours, time
|
||||
format, etc)
|
||||
@ -36,7 +37,7 @@ v0.0.2:
|
||||
- connect to server with child process (background)
|
||||
|
||||
* Configuration:
|
||||
- write config file
|
||||
# write config file
|
||||
- add an option for each server in order to run commands on join
|
||||
(example: /msg nickserv identify password)
|
||||
- channel list for auto-join (for each server)
|
||||
|
@ -71,6 +71,9 @@ t_weechat_command weechat_commands[] =
|
||||
"username: user name\n"
|
||||
"realname: real name of user\n"),
|
||||
0, MAX_ARGS, weechat_cmd_server, NULL },
|
||||
{ "save", N_("save config to disk"),
|
||||
N_("[file]"), N_("file: filename for writing config"),
|
||||
0, 1, weechat_cmd_save, NULL },
|
||||
{ "set", N_("set config parameters"),
|
||||
N_("[option [value]]"), N_("option: name of an option\nvalue: value for option"),
|
||||
0, 2, weechat_cmd_set, NULL },
|
||||
@ -942,6 +945,16 @@ weechat_cmd_server (int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_cmd_save: set options
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_cmd_save (int argc, char **argv)
|
||||
{
|
||||
return (config_write ((argc == 1) ? argv[0] : NULL));
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_cmd_set: set options
|
||||
*/
|
||||
|
@ -60,6 +60,7 @@ extern int weechat_cmd_connect (int, char **);
|
||||
extern int weechat_cmd_disconnect (int, char **);
|
||||
extern int weechat_cmd_help (int, char **);
|
||||
extern int weechat_cmd_server (int, char **);
|
||||
extern int weechat_cmd_save (int, char **);
|
||||
extern int weechat_cmd_set (int, char **);
|
||||
extern int weechat_cmd_unalias (int, char **);
|
||||
|
||||
|
@ -889,6 +889,8 @@ config_read ()
|
||||
|
||||
/*
|
||||
* config_create_default: create default WeeChat config
|
||||
* return: 0 if ok
|
||||
* < 0 if error
|
||||
*/
|
||||
|
||||
int
|
||||
@ -905,20 +907,19 @@ config_create_default ()
|
||||
sprintf (filename, "%s/.weechat/" WEECHAT_CONFIG_NAME, getenv ("HOME"));
|
||||
if ((file = fopen (filename, "wt")) == NULL)
|
||||
{
|
||||
free (filename);
|
||||
gui_printf (NULL, _("%s cannot create file \"%s\"\n"),
|
||||
WEECHAT_ERROR, filename);
|
||||
free (filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf (_(WEECHAT_NAME ": creating default config file...\n"));
|
||||
log_printf (_("creating default config file\n"));
|
||||
|
||||
current_time = time (NULL);
|
||||
sprintf (line, _("#\n# " WEECHAT_NAME " configuration file, generated by "
|
||||
WEECHAT_NAME " " WEECHAT_VERSION " on %s"), ctime (¤t_time));
|
||||
sprintf (line, _("#\n# " WEECHAT_NAME " configuration file, created by "
|
||||
WEECHAT_NAME " " WEECHAT_VERSION " on %s#\n"), ctime (¤t_time));
|
||||
fputs (line, file);
|
||||
fputs (_("# This file may be edited by user. Invalid syntax will prevent "
|
||||
WEECHAT_NAME " from running!\n#\n"), file);
|
||||
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
@ -938,24 +939,24 @@ config_create_default ()
|
||||
{
|
||||
switch (weechat_options[i][j].option_type)
|
||||
{
|
||||
case OPTION_TYPE_BOOLEAN:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].
|
||||
default_int) ? "on" : "off");
|
||||
break;
|
||||
case OPTION_TYPE_INT:
|
||||
sprintf (line, "%s=%d\n",
|
||||
weechat_options[i][j].option_name,
|
||||
weechat_options[i][j].default_int);
|
||||
break;
|
||||
case OPTION_TYPE_INT_WITH_STRING:
|
||||
case OPTION_TYPE_COLOR:
|
||||
case OPTION_TYPE_STRING:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
weechat_options[i][j].default_string);
|
||||
break;
|
||||
case OPTION_TYPE_BOOLEAN:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].default_int) ?
|
||||
"on" : "off");
|
||||
break;
|
||||
case OPTION_TYPE_INT:
|
||||
sprintf (line, "%s=%d\n",
|
||||
weechat_options[i][j].option_name,
|
||||
weechat_options[i][j].default_int);
|
||||
break;
|
||||
case OPTION_TYPE_INT_WITH_STRING:
|
||||
case OPTION_TYPE_COLOR:
|
||||
case OPTION_TYPE_STRING:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
weechat_options[i][j].default_string);
|
||||
break;
|
||||
}
|
||||
fputs (line, file);
|
||||
}
|
||||
@ -982,10 +983,133 @@ config_create_default ()
|
||||
|
||||
/*
|
||||
* config_write: write WeeChat configurtion
|
||||
* return: 0 if ok
|
||||
* < 0 if error
|
||||
*/
|
||||
|
||||
void
|
||||
config_write ()
|
||||
int
|
||||
config_write (char *config_name)
|
||||
{
|
||||
/* TODO: write "config_write" function! */
|
||||
char *filename;
|
||||
char line[1024];
|
||||
FILE *file;
|
||||
int i, j;
|
||||
time_t current_time;
|
||||
t_irc_server *ptr_server;
|
||||
|
||||
if (config_name)
|
||||
filename = strdup (config_name);
|
||||
else
|
||||
{
|
||||
filename =
|
||||
(char *) malloc ((strlen (getenv ("HOME")) + 64) * sizeof (char));
|
||||
sprintf (filename, "%s/.weechat/" WEECHAT_CONFIG_NAME, getenv ("HOME"));
|
||||
}
|
||||
|
||||
if ((file = fopen (filename, "wt")) == NULL)
|
||||
{
|
||||
gui_printf (NULL, _("%s cannot create file \"%s\"\n"),
|
||||
WEECHAT_ERROR, filename);
|
||||
free (filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
log_printf (_("saving config to disk\n"));
|
||||
|
||||
current_time = time (NULL);
|
||||
sprintf (line, _("#\n# " WEECHAT_NAME " configuration file, created by "
|
||||
WEECHAT_NAME " " WEECHAT_VERSION " on %s#\n"), ctime (¤t_time));
|
||||
fputs (line, file);
|
||||
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
if (i != CONFIG_SECTION_SERVER)
|
||||
{
|
||||
sprintf (line, "\n[%s]\n", config_sections[i].section_name);
|
||||
fputs (line, file);
|
||||
if ((i == CONFIG_SECTION_HISTORY) || (i == CONFIG_SECTION_LOG) ||
|
||||
(i == CONFIG_SECTION_DCC) || (i == CONFIG_SECTION_PROXY))
|
||||
{
|
||||
sprintf (line,
|
||||
"# WARNING!!! Options for section \"%s\" are not developed!\n",
|
||||
config_sections[i].section_name);
|
||||
fputs (line, file);
|
||||
}
|
||||
for (j = 0; weechat_options[i][j].option_name; j++)
|
||||
{
|
||||
switch (weechat_options[i][j].option_type)
|
||||
{
|
||||
case OPTION_TYPE_BOOLEAN:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].ptr_int &&
|
||||
*weechat_options[i][j].ptr_int) ?
|
||||
"on" : "off");
|
||||
break;
|
||||
case OPTION_TYPE_INT:
|
||||
sprintf (line, "%s=%d\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].ptr_int) ?
|
||||
*weechat_options[i][j].ptr_int :
|
||||
weechat_options[i][j].default_int);
|
||||
break;
|
||||
case OPTION_TYPE_INT_WITH_STRING:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].ptr_int) ?
|
||||
weechat_options[i][j].array_values[*weechat_options[i][j].ptr_int] :
|
||||
weechat_options[i][j].array_values[weechat_options[i][j].default_int]);
|
||||
break;
|
||||
case OPTION_TYPE_COLOR:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].ptr_int) ?
|
||||
gui_get_color_by_value (*weechat_options[i][j].ptr_int) :
|
||||
weechat_options[i][j].default_string);
|
||||
break;
|
||||
case OPTION_TYPE_STRING:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].ptr_string) ?
|
||||
*weechat_options[i][j].ptr_string :
|
||||
weechat_options[i][j].default_string);
|
||||
break;
|
||||
}
|
||||
fputs (line, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
/* default server is freenode */
|
||||
fputs ("\n[server]\n", file);
|
||||
sprintf (line, "server_name=%s\n", ptr_server->name);
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_autoconnect=%s\n",
|
||||
(ptr_server->autoconnect) ? "on" : "off");
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_address=%s\n", ptr_server->address);
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_port=%d\n", ptr_server->port);
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_password=%s\n",
|
||||
(ptr_server->password) ? ptr_server->password : "");
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_nick1=%s\n", ptr_server->nick1);
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_nick2=%s\n", ptr_server->nick2);
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_nick3=%s\n", ptr_server->nick3);
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_username=%s\n", ptr_server->username);
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_realname=%s\n", ptr_server->realname);
|
||||
fputs (line, file);
|
||||
}
|
||||
|
||||
fclose (file);
|
||||
free (filename);
|
||||
return 0;
|
||||
}
|
||||
|
@ -150,6 +150,6 @@ extern t_config_option * weechat_options [CONFIG_NUMBER_SECTIONS];
|
||||
|
||||
extern int config_read ();
|
||||
extern int config_create_default ();
|
||||
extern void config_write ();
|
||||
extern int config_write ();
|
||||
|
||||
#endif /* config.h */
|
||||
|
@ -306,6 +306,9 @@ main (int argc, char *argv[])
|
||||
gui_main_loop ();
|
||||
server_disconnect_all ();
|
||||
|
||||
/* save config file */
|
||||
config_write (NULL);
|
||||
|
||||
/* program ending */
|
||||
wee_shutdown ();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user