Index: src/common/command.c
===================================================================
RCS file: /sources/weechat/weechat/src/common/command.c,v
retrieving revision 1.164
diff -u -d -p -B -r1.164 command.c
--- src/common/command.c	16 Mar 2007 08:40:11 -0000	1.164
+++ src/common/command.c	23 Mar 2007 11:16:59 -0000
@@ -2830,13 +2830,13 @@ weechat_cmd_server (t_irc_server *server
             if (argv[i][0] == '-')
             {
                 if (ascii_strcasecmp (argv[i], "-auto") == 0)
-                    server_tmp.autoconnect = 1;
+                    SERVER_SET(&server_tmp, autoconnect, 1);
                 if (ascii_strcasecmp (argv[i], "-noauto") == 0)
-                    server_tmp.autoconnect = 0;
+                    SERVER_SET(&server_tmp, autoconnect, 0);
                 if (ascii_strcasecmp (argv[i], "-ipv6") == 0)
-                    server_tmp.ipv6 = 1;
+                    SERVER_SET(&server_tmp, ipv6, 1);
                 if (ascii_strcasecmp (argv[i], "-ssl") == 0)
-                    server_tmp.ssl = 1;
+                    SERVER_SET(&server_tmp, ssl, 1);
                 if (ascii_strcasecmp (argv[i], "-pwd") == 0)
                 {
                     if (i == (argc - 1))
@@ -2861,9 +2861,9 @@ weechat_cmd_server (t_irc_server *server
                         server_destroy (&server_tmp);
                         return -1;
                     }
-                    server_tmp.nick1 = strdup (argv[++i]);
-                    server_tmp.nick2 = strdup (argv[++i]);
-                    server_tmp.nick3 = strdup (argv[++i]);
+                    SERVER_SET(&server_tmp, nick1, strdup(argv[++i]));
+                    SERVER_SET(&server_tmp, nick2, strdup(argv[++i]));
+                    SERVER_SET(&server_tmp, nick3, strdup(argv[++i]));
                 }
                 if (ascii_strcasecmp (argv[i], "-username") == 0)
                 {
@@ -2876,7 +2876,7 @@ weechat_cmd_server (t_irc_server *server
                         server_destroy (&server_tmp);
                         return -1;
                     }
-                    server_tmp.username = strdup (argv[++i]);
+                    SERVER_SET(&server_tmp, username, strdup(argv[++i]));
                 }
                 if (ascii_strcasecmp (argv[i], "-realname") == 0)
                 {
@@ -2889,7 +2889,7 @@ weechat_cmd_server (t_irc_server *server
                         server_destroy (&server_tmp);
                         return -1;
                     }
-                    server_tmp.realname = strdup (argv[++i]);
+                    SERVER_SET(&server_tmp, realname, strdup(argv[++i]));
                 }
                 if (ascii_strcasecmp (argv[i], "-command") == 0)
                 {
@@ -2921,16 +2921,7 @@ weechat_cmd_server (t_irc_server *server
         }
         
         /* create new server */
-        new_server = server_new (server_tmp.name, server_tmp.autoconnect,
-                                 server_tmp.autoreconnect,
-                                 server_tmp.autoreconnect_delay,
-                                 0, server_tmp.address, server_tmp.port,
-                                 server_tmp.ipv6, server_tmp.ssl,
-                                 server_tmp.password, server_tmp.nick1,
-                                 server_tmp.nick2, server_tmp.nick3,
-                                 server_tmp.username, server_tmp.realname,
-                                 server_tmp.hostname,
-                                 server_tmp.command, 1, server_tmp.autojoin, 1, NULL);
+        new_server = server_clone(&server_tmp);
         if (new_server)
         {
             irc_display_prefix (NULL, NULL, PREFIX_INFO);
@@ -2949,7 +2940,7 @@ weechat_cmd_server (t_irc_server *server
             return -1;
         }
         
-        if (new_server->autoconnect)
+        if (SERVER_GET(new_server, autoconnect))
         {
             (void) gui_buffer_new (window, new_server, NULL,
                                    BUFFER_TYPE_STANDARD, 1);
@@ -2966,7 +2957,7 @@ weechat_cmd_server (t_irc_server *server
  */
 
 void
-weechat_cmd_set_display_option (t_config_option *option, char *prefix, void *value)
+weechat_cmd_set_display_option (t_config_option *option, char *prefix, const void *value)
 {
     char *color_name, *value2;
     
@@ -3047,7 +3038,7 @@ weechat_cmd_set (t_irc_server *server, t
     t_config_option *ptr_option;
     t_irc_server *ptr_server;
     char option_name[256];
-    void *ptr_option_value;
+    const void *ptr_option_value;
     int last_section, last_option, number_found;
     
     /* make C compiler happy */
@@ -3138,7 +3129,7 @@ weechat_cmd_set (t_irc_server *server, t
                         if (weechat_options[CONFIG_SECTION_SERVER][i].option_name)
                         {
                             ptr_option_value = config_get_server_option_ptr (ptr_server,
-                                weechat_options[CONFIG_SECTION_SERVER][i].option_name);
+                                &weechat_options[CONFIG_SECTION_SERVER][i]);
                             weechat_cmd_set_display_option (&weechat_options[CONFIG_SECTION_SERVER][i],
                                                             ptr_server->name,
                                                             ptr_option_value);
@@ -3262,7 +3253,7 @@ weechat_cmd_set (t_irc_server *server, t
                         section_displayed = 1;
                     }
                     ptr_option_value = config_get_server_option_ptr (ptr_server,
-                        weechat_options[CONFIG_SECTION_SERVER][i].option_name);
+                        &weechat_options[CONFIG_SECTION_SERVER][i]);
                     if (ptr_option_value)
                     {
                         weechat_cmd_set_display_option (&weechat_options[CONFIG_SECTION_SERVER][i],
Index: src/common/session.c
===================================================================
RCS file: /sources/weechat/weechat/src/common/session.c,v
retrieving revision 1.32
diff -u -d -p -B -r1.32 session.c
--- src/common/session.c	20 Mar 2007 12:22:32 -0000	1.32
+++ src/common/session.c	23 Mar 2007 11:16:59 -0000
@@ -217,26 +217,42 @@ session_save_servers (FILE *file)
     {
         rc = rc && (session_write_id  (file, SESSION_OBJ_SERVER));
         rc = rc && (session_write_str (file, SESSION_SERV_NAME, ptr_server->name));
-        rc = rc && (session_write_int (file, SESSION_SERV_AUTOCONNECT, ptr_server->autoconnect));
-        rc = rc && (session_write_int (file, SESSION_SERV_AUTORECONNECT, ptr_server->autoreconnect));
-        rc = rc && (session_write_int (file, SESSION_SERV_AUTORECONNECT_DELAY, ptr_server->autoreconnect_delay));
         rc = rc && (session_write_int (file, SESSION_SERV_COMMAND_LINE, ptr_server->command_line));
         rc = rc && (session_write_str (file, SESSION_SERV_ADDRESS, ptr_server->address));
         rc = rc && (session_write_int (file, SESSION_SERV_PORT, ptr_server->port));
-        rc = rc && (session_write_int (file, SESSION_SERV_IPV6, ptr_server->ipv6));
-        rc = rc && (session_write_int (file, SESSION_SERV_SSL, ptr_server->ssl));
         rc = rc && (session_write_str (file, SESSION_SERV_PASSWORD, ptr_server->password));
-        rc = rc && (session_write_str (file, SESSION_SERV_NICK1, ptr_server->nick1));
-        rc = rc && (session_write_str (file, SESSION_SERV_NICK2, ptr_server->nick2));
-        rc = rc && (session_write_str (file, SESSION_SERV_NICK3, ptr_server->nick3));
-        rc = rc && (session_write_str (file, SESSION_SERV_USERNAME, ptr_server->username));
-        rc = rc && (session_write_str (file, SESSION_SERV_REALNAME, ptr_server->realname));
-        rc = rc && (session_write_str (file, SESSION_SERV_HOSTNAME, ptr_server->hostname));
         rc = rc && (session_write_str (file, SESSION_SERV_COMMAND, ptr_server->command));
-        rc = rc && (session_write_int (file, SESSION_SERV_COMMAND_DELAY, ptr_server->command_delay));
         rc = rc && (session_write_str (file, SESSION_SERV_AUTOJOIN, ptr_server->autojoin));
-        rc = rc && (session_write_int (file, SESSION_SERV_AUTOREJOIN, ptr_server->autorejoin));
         rc = rc && (session_write_str (file, SESSION_SERV_NOTIFY_LEVELS, ptr_server->notify_levels));
+        
+        rc = rc && (session_write_int (file, SESSION_SERV_ISSET_AUTOCONNECT, ptr_server->isset.autoconnect));
+        rc = rc && (session_write_int (file, SESSION_SERV_ISSET_AUTORECONNECT, ptr_server->isset.autoreconnect));
+        rc = rc && (session_write_int (file, SESSION_SERV_ISSET_AUTORECONNECT_DELAY, ptr_server->isset.autoreconnect_delay));
+        rc = rc && (session_write_int (file, SESSION_SERV_ISSET_IPV6, ptr_server->isset.ipv6));
+        rc = rc && (session_write_int (file, SESSION_SERV_ISSET_SSL, ptr_server->isset.ssl));
+        rc = rc && (session_write_int (file, SESSION_SERV_ISSET_NICK1, ptr_server->isset.nick1));
+        rc = rc && (session_write_int (file, SESSION_SERV_ISSET_NICK2, ptr_server->isset.nick2));
+        rc = rc && (session_write_int (file, SESSION_SERV_ISSET_NICK3, ptr_server->isset.nick3));
+        rc = rc && (session_write_int (file, SESSION_SERV_ISSET_USERNAME, ptr_server->isset.username));
+        rc = rc && (session_write_int (file, SESSION_SERV_ISSET_REALNAME, ptr_server->isset.realname));
+        rc = rc && (session_write_int (file, SESSION_SERV_ISSET_HOSTNAME, ptr_server->isset.hostname));
+        rc = rc && (session_write_int (file, SESSION_SERV_ISSET_COMMAND_DELAY, ptr_server->isset.command_delay));
+        rc = rc && (session_write_int (file, SESSION_SERV_ISSET_AUTOREJOIN, ptr_server->isset.autorejoin));
+        
+        rc = rc && (session_write_int (file, SESSION_SERV_SETTING_AUTOCONNECT, ptr_server->setting.autoconnect));
+        rc = rc && (session_write_int (file, SESSION_SERV_SETTING_AUTORECONNECT, ptr_server->setting.autoreconnect));
+        rc = rc && (session_write_int (file, SESSION_SERV_SETTING_AUTORECONNECT_DELAY, ptr_server->setting.autoreconnect_delay));
+        rc = rc && (session_write_int (file, SESSION_SERV_SETTING_IPV6, ptr_server->setting.ipv6));
+        rc = rc && (session_write_int (file, SESSION_SERV_SETTING_SSL, ptr_server->setting.ssl));
+        rc = rc && (session_write_str (file, SESSION_SERV_SETTING_NICK1, ptr_server->setting.nick1));
+        rc = rc && (session_write_str (file, SESSION_SERV_SETTING_NICK2, ptr_server->setting.nick2));
+        rc = rc && (session_write_str (file, SESSION_SERV_SETTING_NICK3, ptr_server->setting.nick3));
+        rc = rc && (session_write_str (file, SESSION_SERV_SETTING_USERNAME, ptr_server->setting.username));
+        rc = rc && (session_write_str (file, SESSION_SERV_SETTING_REALNAME, ptr_server->setting.realname));
+        rc = rc && (session_write_str (file, SESSION_SERV_SETTING_HOSTNAME, ptr_server->setting.hostname));
+        rc = rc && (session_write_int (file, SESSION_SERV_SETTING_COMMAND_DELAY, ptr_server->setting.command_delay));
+        rc = rc && (session_write_int (file, SESSION_SERV_SETTING_AUTOREJOIN, ptr_server->setting.autorejoin));
+        
         rc = rc && (session_write_int (file, SESSION_SERV_CHILD_PID, ptr_server->child_pid));
         rc = rc && (session_write_int (file, SESSION_SERV_CHILD_READ, ptr_server->child_read));
         rc = rc && (session_write_int (file, SESSION_SERV_CHILD_WRITE, ptr_server->child_write));
@@ -872,65 +888,101 @@ session_load_server (FILE *file)
         {
             case SESSION_SERV_END:
                 return 1;
-            case SESSION_SERV_AUTOCONNECT:
-                rc = rc && (session_read_int (file, &(session_current_server->autoconnect)));
-                break;
-            case SESSION_SERV_AUTORECONNECT:
-                rc = rc && (session_read_int (file, &(session_current_server->autoreconnect)));
-                break;
-            case SESSION_SERV_AUTORECONNECT_DELAY:
-                rc = rc && (session_read_int (file, &(session_current_server->autoreconnect_delay)));
-                break;
-            case SESSION_SERV_COMMAND_LINE:
-                rc = rc && (session_read_int (file, &(session_current_server->command_line)));
-                break;
             case SESSION_SERV_ADDRESS:
                 rc = rc && (session_read_str (file, &(session_current_server->address)));
                 break;
             case SESSION_SERV_PORT:
                 rc = rc && (session_read_int (file, &(session_current_server->port)));
                 break;
-            case SESSION_SERV_IPV6:
-                rc = rc && (session_read_int (file, &(session_current_server->ipv6)));
-                break;
-            case SESSION_SERV_SSL:
-                rc = rc && (session_read_int (file, &(session_current_server->ssl)));
-                break;
             case SESSION_SERV_PASSWORD:
                 rc = rc && (session_read_str (file, &(session_current_server->password)));
                 break;
-            case SESSION_SERV_NICK1:
-                rc = rc && (session_read_str (file, &(session_current_server->nick1)));
+            case SESSION_SERV_COMMAND:
+                rc = rc && (session_read_str (file, &(session_current_server->command)));
                 break;
-            case SESSION_SERV_NICK2:
-                rc = rc && (session_read_str (file, &(session_current_server->nick2)));
+            case SESSION_SERV_AUTOJOIN:
+                rc = rc && (session_read_str (file, &(session_current_server->autojoin)));
                 break;
-            case SESSION_SERV_NICK3:
-                rc = rc && (session_read_str (file, &(session_current_server->nick3)));
+            case SESSION_SERV_NOTIFY_LEVELS:
+                rc = rc && (session_read_str (file, &(session_current_server->notify_levels)));
                 break;
-            case SESSION_SERV_USERNAME:
-                rc = rc && (session_read_str (file, &(session_current_server->username)));
+            case SESSION_SERV_ISSET_AUTOCONNECT:
+                rc = rc && (session_read_int (file, &(session_current_server->isset.autoconnect)));
                 break;
-            case SESSION_SERV_REALNAME:
-                rc = rc && (session_read_str (file, &(session_current_server->realname)));
+            case SESSION_SERV_ISSET_AUTORECONNECT:
+                rc = rc && (session_read_int (file, &(session_current_server->isset.autoreconnect)));
                 break;
-            case SESSION_SERV_HOSTNAME:
-                rc = rc && (session_read_str (file, &(session_current_server->hostname)));
+            case SESSION_SERV_ISSET_AUTORECONNECT_DELAY:
+                rc = rc && (session_read_int (file, &(session_current_server->isset.autoreconnect_delay)));
                 break;
-            case SESSION_SERV_COMMAND:
-                rc = rc && (session_read_str (file, &(session_current_server->command)));
+            case SESSION_SERV_ISSET_IPV6:
+                rc = rc && (session_read_int (file, &(session_current_server->isset.ipv6)));
                 break;
-            case SESSION_SERV_COMMAND_DELAY:
-                rc = rc && (session_read_int (file, &(session_current_server->command_delay)));
+            case SESSION_SERV_ISSET_SSL:
+                rc = rc && (session_read_int (file, &(session_current_server->isset.ssl)));
                 break;
-            case SESSION_SERV_AUTOJOIN:
-                rc = rc && (session_read_str (file, &(session_current_server->autojoin)));
+            case SESSION_SERV_ISSET_NICK1:
+                rc = rc && (session_read_int (file, &(session_current_server->isset.nick1)));
                 break;
-            case SESSION_SERV_AUTOREJOIN:
-                rc = rc && (session_read_int (file, &(session_current_server->autorejoin)));
+            case SESSION_SERV_ISSET_NICK2:
+                rc = rc && (session_read_int (file, &(session_current_server->isset.nick2)));
                 break;
-            case SESSION_SERV_NOTIFY_LEVELS:
-                rc = rc && (session_read_str (file, &(session_current_server->notify_levels)));
+            case SESSION_SERV_ISSET_NICK3:
+                rc = rc && (session_read_int (file, &(session_current_server->isset.nick3)));
+                break;
+            case SESSION_SERV_ISSET_USERNAME:
+                rc = rc && (session_read_int (file, &(session_current_server->isset.username)));
+                break;
+            case SESSION_SERV_ISSET_REALNAME:
+                rc = rc && (session_read_int (file, &(session_current_server->isset.realname)));
+                break;
+            case SESSION_SERV_ISSET_HOSTNAME:
+                rc = rc && (session_read_int (file, &(session_current_server->isset.hostname)));
+                break;
+            case SESSION_SERV_ISSET_COMMAND_DELAY:
+                rc = rc && (session_read_int (file, &(session_current_server->isset.command_delay)));
+                break;
+            case SESSION_SERV_ISSET_AUTOREJOIN:
+                rc = rc && (session_read_int (file, &(session_current_server->isset.autorejoin)));
+                break;
+            case SESSION_SERV_SETTING_AUTOCONNECT:
+                rc = rc && (session_read_int (file, &(session_current_server->setting.autoconnect)));
+                break;
+            case SESSION_SERV_SETTING_AUTORECONNECT:
+                rc = rc && (session_read_int (file, &(session_current_server->setting.autoreconnect)));
+                break;
+            case SESSION_SERV_SETTING_AUTORECONNECT_DELAY:
+                rc = rc && (session_read_int (file, &(session_current_server->setting.autoreconnect_delay)));
+                break;
+            case SESSION_SERV_SETTING_IPV6:
+                rc = rc && (session_read_int (file, &(session_current_server->setting.ipv6)));
+                break;
+            case SESSION_SERV_SETTING_SSL:
+                rc = rc && (session_read_int (file, &(session_current_server->setting.ssl)));
+                break;
+            case SESSION_SERV_SETTING_NICK1:
+                rc = rc && (session_read_str (file, &(session_current_server->setting.nick1)));
+                break;
+            case SESSION_SERV_SETTING_NICK2:
+                rc = rc && (session_read_str (file, &(session_current_server->setting.nick2)));
+                break;
+            case SESSION_SERV_SETTING_NICK3:
+                rc = rc && (session_read_str (file, &(session_current_server->setting.nick3)));
+                break;
+            case SESSION_SERV_SETTING_USERNAME:
+                rc = rc && (session_read_str (file, &(session_current_server->setting.username)));
+                break;
+            case SESSION_SERV_SETTING_REALNAME:
+                rc = rc && (session_read_str (file, &(session_current_server->setting.realname)));
+                break;
+            case SESSION_SERV_SETTING_HOSTNAME:
+                rc = rc && (session_read_str (file, &(session_current_server->setting.hostname)));
+                break;
+            case SESSION_SERV_SETTING_COMMAND_DELAY:
+                rc = rc && (session_read_int (file, &(session_current_server->setting.command_delay)));
+                break;
+            case SESSION_SERV_SETTING_AUTOREJOIN:
+                rc = rc && (session_read_int (file, &(session_current_server->setting.autorejoin)));
                 break;
             case SESSION_SERV_CHILD_PID:
                 rc = rc && (session_read_int (file, &(session_current_server->child_pid)));
Index: src/common/session.h
===================================================================
RCS file: /sources/weechat/weechat/src/common/session.h,v
retrieving revision 1.20
diff -u -d -p -B -r1.20 session.h
--- src/common/session.h	5 Jan 2007 23:41:39 -0000	1.20
+++ src/common/session.h	23 Mar 2007 11:16:59 -0000
@@ -52,24 +52,24 @@ enum t_session_server
 {
     SESSION_SERV_END = 0,
     SESSION_SERV_NAME,
-    SESSION_SERV_AUTOCONNECT,
-    SESSION_SERV_AUTORECONNECT,
-    SESSION_SERV_AUTORECONNECT_DELAY,
+    SESSION_SERV_AUTOCONNECT__UNUSED,
+    SESSION_SERV_AUTORECONNECT__UNUSED,
+    SESSION_SERV_AUTORECONNECT_DELAY__UNUSED,
     SESSION_SERV_COMMAND_LINE,
     SESSION_SERV_ADDRESS,
     SESSION_SERV_PORT,
-    SESSION_SERV_IPV6,
-    SESSION_SERV_SSL,
+    SESSION_SERV_IPV6__UNUSED,
+    SESSION_SERV_SSL__UNUSED,
     SESSION_SERV_PASSWORD,
-    SESSION_SERV_NICK1,
-    SESSION_SERV_NICK2,
-    SESSION_SERV_NICK3,
-    SESSION_SERV_USERNAME,
-    SESSION_SERV_REALNAME,
+    SESSION_SERV_NICK1__UNUSED,
+    SESSION_SERV_NICK2__UNUSED,
+    SESSION_SERV_NICK3__UNUSED,
+    SESSION_SERV_USERNAME__UNUSED,
+    SESSION_SERV_REALNAME__UNUSED,
     SESSION_SERV_COMMAND,
-    SESSION_SERV_COMMAND_DELAY,
+    SESSION_SERV_COMMAND_DELAY__UNUSED,
     SESSION_SERV_AUTOJOIN,
-    SESSION_SERV_AUTOREJOIN,
+    SESSION_SERV_AUTOREJOIN__UNUSED,
     SESSION_SERV_NOTIFY_LEVELS,
     SESSION_SERV_CHILD_PID,
     SESSION_SERV_CHILD_READ,
@@ -90,9 +90,36 @@ enum t_session_server
     SESSION_SERV_CHARSET_DECODE_ISO__UNUSED,
     SESSION_SERV_CHARSET_DECODE_UTF__UNUSED,
     SESSION_SERV_CHARSET_ENCODE__UNUSED,
-    SESSION_SERV_HOSTNAME,
+    SESSION_SERV_HOSTNAME__UNUSED,
     SESSION_SERV_NICK_MODES,
-    SESSION_SERV_AWAY_MESSAGE
+    SESSION_SERV_AWAY_MESSAGE,
+
+    SESSION_SERV_ISSET_AUTOCONNECT,
+    SESSION_SERV_SETTING_AUTOCONNECT,
+    SESSION_SERV_ISSET_AUTORECONNECT,
+    SESSION_SERV_SETTING_AUTORECONNECT,
+    SESSION_SERV_ISSET_AUTORECONNECT_DELAY,
+    SESSION_SERV_SETTING_AUTORECONNECT_DELAY,
+    SESSION_SERV_ISSET_IPV6,
+    SESSION_SERV_SETTING_IPV6,
+    SESSION_SERV_ISSET_SSL,
+    SESSION_SERV_SETTING_SSL,
+    SESSION_SERV_ISSET_NICK1,
+    SESSION_SERV_SETTING_NICK1,
+    SESSION_SERV_ISSET_NICK2,
+    SESSION_SERV_SETTING_NICK2,
+    SESSION_SERV_ISSET_NICK3,
+    SESSION_SERV_SETTING_NICK3,
+    SESSION_SERV_ISSET_USERNAME,
+    SESSION_SERV_SETTING_USERNAME,
+    SESSION_SERV_ISSET_REALNAME,
+    SESSION_SERV_SETTING_REALNAME,
+    SESSION_SERV_ISSET_HOSTNAME,
+    SESSION_SERV_SETTING_HOSTNAME,
+    SESSION_SERV_ISSET_COMMAND_DELAY,
+    SESSION_SERV_SETTING_COMMAND_DELAY,
+    SESSION_SERV_ISSET_AUTOREJOIN,
+    SESSION_SERV_SETTING_AUTOREJOIN,
 };
 
 enum t_session_channel
Index: src/common/weechat.c
===================================================================
RCS file: /sources/weechat/weechat/src/common/weechat.c,v
retrieving revision 1.93
diff -u -d -p -B -r1.93 weechat.c
--- src/common/weechat.c	12 Feb 2007 17:39:35 -0000	1.93
+++ src/common/weechat.c	23 Mar 2007 11:17:00 -0000
@@ -413,15 +413,8 @@ weechat_parse_args (int argc, char *argv
             }
             else
             {
-                if (!server_new (server_tmp.name, server_tmp.autoconnect,
-                                 server_tmp.autoreconnect,
-                                 server_tmp.autoreconnect_delay,
-                                 1, server_tmp.address, server_tmp.port,
-                                 server_tmp.ipv6, server_tmp.ssl,
-                                 server_tmp.password, server_tmp.nick1,
-                                 server_tmp.nick2, server_tmp.nick3,
-                                 NULL, NULL, NULL, NULL, 0,
-                                 server_tmp.autojoin, 1, NULL))
+                server_tmp.command_line = 1;
+                if (!server_clone(&server_tmp))
                     weechat_iconv_fprintf (stderr,
                                            _("%s unable to create server ('%s'), ignored\n"),
                                            WEECHAT_WARNING, argv[i]);
Index: src/common/weeconfig.c
===================================================================
RCS file: /sources/weechat/weechat/src/common/weeconfig.c,v
retrieving revision 1.147
diff -u -d -p -B -r1.147 weeconfig.c
--- src/common/weeconfig.c	12 Feb 2007 17:39:35 -0000	1.147
+++ src/common/weeconfig.c	23 Mar 2007 11:17:01 -0000
@@ -61,7 +61,8 @@ t_config_section config_sections[CONFIG_
   { CONFIG_SECTION_KEYS, "keys" },
   { CONFIG_SECTION_ALIAS, "alias" },
   { CONFIG_SECTION_IGNORE, "ignore" },
-  { CONFIG_SECTION_SERVER, "server" }
+  { CONFIG_SECTION_SERVER, "server" },
+  { CONFIG_SECTION_SERVER_DEFAULTS, "server_defaults" }
 };
 
 /* config, look & feel section */
@@ -114,166 +115,166 @@ t_config_option weechat_options_look[] =
 { { "look_save_on_exit", N_("save config file on exit"),
     N_("save config file on exit"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
-    NULL, NULL, &cfg_look_save_on_exit, NULL, config_change_save_on_exit },
+    NULL, NULL, &cfg_look_save_on_exit, NULL, -1, config_change_save_on_exit },
   { "look_set_title", N_("set title for window (terminal for Curses GUI) with name and version"),
     N_("set title for window (terminal for Curses GUI) with name and version"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
-    NULL, NULL, &cfg_look_set_title, NULL, config_change_title },
+    NULL, NULL, &cfg_look_set_title, NULL, -1, config_change_title },
   { "look_startup_logo", N_("display WeeChat logo at startup"),
     N_("display WeeChat logo at startup"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
-    NULL, NULL, &cfg_look_startup_logo, NULL, config_change_noop },
+    NULL, NULL, &cfg_look_startup_logo, NULL, -1, config_change_noop },
   { "look_startup_version", N_("display WeeChat version at startup"),
     N_("display WeeChat version at startup"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
-    NULL, NULL, &cfg_look_startup_version, NULL, config_change_noop },
+    NULL, NULL, &cfg_look_startup_version, NULL, -1, config_change_noop },
   { "look_weechat_slogan", N_("WeeChat slogan"),
     N_("WeeChat slogan (if empty, slogan is not used)"),
     OPTION_TYPE_STRING, 0, 0, 0,
-    "the geekest IRC client!", NULL, NULL, &cfg_look_weechat_slogan, config_change_noop },
+    "the geekest IRC client!", NULL, NULL, &cfg_look_weechat_slogan, -1, config_change_noop },
   { "look_one_server_buffer", N_("use same buffer for all servers"),
     N_("use same buffer for all servers"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
-    NULL, NULL, &cfg_look_one_server_buffer, NULL, config_change_one_server_buffer },
+    NULL, NULL, &cfg_look_one_server_buffer, NULL, -1, config_change_one_server_buffer },
   { "look_open_near_server", N_("open new channels/privates near server"),
     N_("open new channels/privates near server"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
-    NULL, NULL, &cfg_look_open_near_server, NULL, config_change_noop },
+    NULL, NULL, &cfg_look_open_near_server, NULL, -1, config_change_noop },
   { "look_scroll_amount", N_("how many lines to scroll by with scroll_up and scroll_down"),
     N_("how many lines to scroll by with scroll_up and scroll_down"),
     OPTION_TYPE_INT, 1, INT_MAX, 3,
-    NULL, NULL, &cfg_look_scroll_amount, NULL, config_change_buffer_content },
+    NULL, NULL, &cfg_look_scroll_amount, NULL, -1, config_change_buffer_content },
   { "look_buffer_timestamp", N_("timestamp for buffers"),
     N_("timestamp for buffers"),
     OPTION_TYPE_STRING, 0, 0, 0,
-    "[%H:%M:%S]", NULL, NULL, &cfg_look_buffer_timestamp, config_change_buffer_content },
+    "[%H:%M:%S]", NULL, NULL, &cfg_look_buffer_timestamp, -1, config_change_buffer_content },
   { "look_color_nicks_number", N_("number of colors to use for nicks colors"),
     N_("number of colors to use for nicks colors"),
     OPTION_TYPE_INT, 1, 10, 10,
-    NULL, NULL, &cfg_look_color_nicks_number, NULL, config_change_nicks_colors },
+    NULL, NULL, &cfg_look_color_nicks_number, NULL, -1, config_change_nicks_colors },
   { "look_color_actions", N_("display actions with different colors"),
     N_("display actions with different colors"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
-    NULL, NULL, &cfg_look_color_actions, NULL, config_change_noop },
+    NULL, NULL, &cfg_look_color_actions, NULL, -1, config_change_noop },
   { "look_nicklist", N_("display nicklist window"),
     N_("display nicklist window (for channel windows)"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
-    NULL, NULL, &cfg_look_nicklist, NULL, config_change_buffers },
+    NULL, NULL, &cfg_look_nicklist, NULL, -1, config_change_buffers },
   { "look_nicklist_position", N_("nicklist position"),
     N_("nicklist position (top, left, right (default), bottom)"),
     OPTION_TYPE_INT_WITH_STRING, 0, 0, 0,
-    "right", cfg_look_nicklist_position_values, &cfg_look_nicklist_position, NULL, config_change_buffers },
+    "right", cfg_look_nicklist_position_values, &cfg_look_nicklist_position, NULL, -1, config_change_buffers },
   { "look_nicklist_min_size", N_("min size for nicklist"),
     N_("min size for nicklist (width or height, depending on look_nicklist_position "
        "(0 = no min size))"),
     OPTION_TYPE_INT, 0, 100, 0,
-    NULL, NULL, &cfg_look_nicklist_min_size, NULL, config_change_buffers },
+    NULL, NULL, &cfg_look_nicklist_min_size, NULL, -1, config_change_buffers },
   { "look_nicklist_max_size", N_("max size for nicklist"),
     N_("max size for nicklist (width or height, depending on look_nicklist_position "
        "(0 = no max size; if min == max and > 0, then size is fixed))"),
     OPTION_TYPE_INT, 0, 100, 0,
-    NULL, NULL, &cfg_look_nicklist_max_size, NULL, config_change_buffers },
+    NULL, NULL, &cfg_look_nicklist_max_size, NULL, -1, config_change_buffers },
   { "look_nicklist_separator", N_("separator between chat and nicklist"),
     N_("separator between chat and nicklist"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
-    NULL, NULL, &cfg_look_nicklist_separator, NULL, config_change_buffers },
+    NULL, NULL, &cfg_look_nicklist_separator, NULL, -1, config_change_buffers },
   { "look_no_nickname", N_("text to display instead of nick when not connected"),
     N_("text to display instead of nick when not connected"),
     OPTION_TYPE_STRING, 0, 0, 0,
-    "-cmd-", NULL, NULL, &cfg_look_no_nickname, config_change_buffer_content },
+    "-cmd-", NULL, NULL, &cfg_look_no_nickname, -1, config_change_buffer_content },
   { "look_nickmode", N_("display nick mode ((half)op/voice) before each nick"),
     N_("display nick mode ((half)op/voice) before each nick"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
-    NULL, NULL, &cfg_look_nickmode, NULL, config_change_buffers },
+    NULL, NULL, &cfg_look_nickmode, NULL, -1, config_change_buffers },
   { "look_nickmode_empty", N_("display space if nick mode is not (half)op/voice"),
     N_("display space if nick mode is not (half)op/voice"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
-    NULL, NULL, &cfg_look_nickmode_empty, NULL, config_change_buffers },
+    NULL, NULL, &cfg_look_nickmode_empty, NULL, -1, config_change_buffers },
   { "look_nick_prefix", N_("text to display before nick in chat window"),
     N_("text to display before nick in chat window"),
     OPTION_TYPE_STRING, 0, 0, 0,
-    "", NULL, NULL, &cfg_look_nick_prefix, config_change_noop },
+    "", NULL, NULL, &cfg_look_nick_prefix, -1, config_change_noop },
   { "look_nick_suffix", N_("text to display after nick in chat window"),
     N_("text to display after nick in chat window"),
     OPTION_TYPE_STRING, 0, 0, 0,
-    " |", NULL, NULL, &cfg_look_nick_suffix, config_change_noop },
+    " |", NULL, NULL, &cfg_look_nick_suffix, -1, config_change_noop },
   { "look_align_nick", N_("nick alignment (fixed size for nicks in chat window)"),
     N_("nick alignment (fixed size for nicks in chat window (none, left, right))"),
     OPTION_TYPE_INT_WITH_STRING, 0, 0, 0,
-    "right", cfg_look_align_nick_values, &cfg_look_align_nick, NULL, config_change_noop },
+    "right", cfg_look_align_nick_values, &cfg_look_align_nick, NULL, -1, config_change_noop },
   { "look_align_other", N_("alignment for other messages (not beginning with a nick)"),
     N_("alignment for other messages (not beginning with a nick)"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
-    NULL, NULL, &cfg_look_align_other, NULL, config_change_noop },
+    NULL, NULL, &cfg_look_align_other, NULL, -1, config_change_noop },
   { "look_align_size", N_("size for aligning nick and other messages"),
     N_("size for aligning nick and other messages"),
     OPTION_TYPE_INT, 8, 64, 14,
-    NULL, NULL, &cfg_look_align_size, NULL, config_change_noop },
+    NULL, NULL, &cfg_look_align_size, NULL, -1, config_change_noop },
   { "look_align_size_max", N_("max size for aligning nick and other messages"),
     N_("max size for aligning nick and other messages (should be >= to "
        "look_align_size)"),
     OPTION_TYPE_INT, 8, 64, 20,
-    NULL, NULL, &cfg_look_align_size_max, NULL, config_change_noop },
+    NULL, NULL, &cfg_look_align_size_max, NULL, -1, config_change_noop },
   { "look_nick_completor", N_("the string inserted after nick completion"),
     N_("the string inserted after nick completion"),
     OPTION_TYPE_STRING, 0, 0, 0,
-    ":", NULL, NULL, &cfg_look_nick_completor, config_change_noop },
+    ":", NULL, NULL, &cfg_look_nick_completor, -1, config_change_noop },
   { "look_nick_completion_ignore", N_("chars ignored for nick completion"),
     N_("chars ignored for nick completion"),
     OPTION_TYPE_STRING, 0, 0, 0,
-    "[]-^", NULL, NULL, &cfg_look_nick_completion_ignore, config_change_noop },
+    "[]-^", NULL, NULL, &cfg_look_nick_completion_ignore, -1, config_change_noop },
   { "look_nick_complete_first", N_("complete only with first nick found"),
     N_("complete only with first nick found"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
-    NULL, NULL, &cfg_look_nick_complete_first, NULL, config_change_noop },
+    NULL, NULL, &cfg_look_nick_complete_first, NULL, -1, config_change_noop },
   { "look_infobar", N_("enable info bar"),
     N_("enable info bar"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
-    NULL, NULL, &cfg_look_infobar, NULL, config_change_buffers },
+    NULL, NULL, &cfg_look_infobar, NULL, -1, config_change_buffers },
   { "look_infobar_timestamp", N_("timestamp for time in infobar"),
     N_("timestamp for time in infobar"),
     OPTION_TYPE_STRING, 0, 0, 0,
-    "%B, %A %d %Y", NULL, NULL, &cfg_look_infobar_timestamp, config_change_buffer_content },
+    "%B, %A %d %Y", NULL, NULL, &cfg_look_infobar_timestamp, -1, config_change_buffer_content },
   { "look_infobar_seconds", N_("display seconds in infobar time"),
     N_("display seconds in infobar time"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
-    NULL, NULL, &cfg_look_infobar_seconds, NULL, config_change_buffer_content },
+    NULL, NULL, &cfg_look_infobar_seconds, NULL, -1, config_change_buffer_content },
   { "look_infobar_delay_highlight", N_("delay (in seconds) for highlight messages in infobar"),
     N_("delay (in seconds) for highlight messages in infobar "
        "(0 = disable highlight notifications in infobar)"),
     OPTION_TYPE_INT, 0, INT_MAX, 7,
-    NULL, NULL, &cfg_look_infobar_delay_highlight, NULL, config_change_noop },
+    NULL, NULL, &cfg_look_infobar_delay_highlight, NULL, -1, config_change_noop },
   { "look_hotlist_names_count", N_("max number of names in hotlist"),
     N_("max number of names in hotlist (0 = no name displayed, only buffer numbers)"),
     OPTION_TYPE_INT, 0, 32, 3,
-    NULL, NULL, &cfg_look_hotlist_names_count, NULL, config_change_buffer_content },
+    NULL, NULL, &cfg_look_hotlist_names_count, NULL, -1, config_change_buffer_content },
   { "look_hotlist_names_level", N_("level for displaying names in hotlist"),
     N_("level for displaying names in hotlist (combination of: 1=join/part, 2=message, "
        "4=private, 8=highlight, for example: 12=private+highlight)"),
     OPTION_TYPE_INT, 1, 15, 12,
-    NULL, NULL, &cfg_look_hotlist_names_level, NULL, config_change_buffer_content },
+    NULL, NULL, &cfg_look_hotlist_names_level, NULL, -1, config_change_buffer_content },
   { "look_hotlist_names_length", N_("max length of names in hotlist"),
     N_("max length of names in hotlist (0 = no limit)"),
     OPTION_TYPE_INT, 0, 32, 0,
-    NULL, NULL, &cfg_look_hotlist_names_length, NULL, config_change_buffer_content },
+    NULL, NULL, &cfg_look_hotlist_names_length, NULL, -1, config_change_buffer_content },
   { "look_day_change", N_("display special message when day changes"),
     N_("display special message when day changes"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
-    NULL, NULL, &cfg_look_day_change, NULL, config_change_noop },
+    NULL, NULL, &cfg_look_day_change, NULL, -1, config_change_noop },
   { "look_day_change_timestamp", N_("timestamp for date displayed when day changed"),
     N_("timestamp for date displayed when day changed"),
     OPTION_TYPE_STRING, 0, 0, 0,
-    "%a, %d %b %Y", NULL, NULL, &cfg_look_day_change_timestamp, config_change_noop },
+    "%a, %d %b %Y", NULL, NULL, &cfg_look_day_change_timestamp, -1, config_change_noop },
   { "look_read_marker", N_("use a marker on servers/channels to show first unread line"),
     N_("use a marker on servers/channels to show first unread line"),
     OPTION_TYPE_STRING, 0, 0, 0,
-    " ", NULL, NULL, &cfg_look_read_marker, config_change_read_marker },
+    " ", NULL, NULL, &cfg_look_read_marker, -1, config_change_read_marker },
   { "look_input_format", N_("format for input prompt"),
     N_("format for input prompt ('%c' is replaced by channel or server, "
        "'%n' by nick and '%m' by nick modes)"),
     OPTION_TYPE_STRING, 0, 0, 0,
-    "[%n(%m)] ", NULL, NULL, &cfg_look_input_format, config_change_buffer_content },
-  { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
+    "[%n(%m)] ", NULL, NULL, &cfg_look_input_format, -1, config_change_buffer_content },
+  { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, -1, NULL }
 };
 
 /* config, colors section */
@@ -347,294 +348,294 @@ t_config_option weechat_options_colors[]
        "background (if you never use white background, you should turn on "
        "this option to see real white instead of default term foreground color)"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
-    NULL, NULL, &cfg_col_real_white, NULL, config_change_color },
+    NULL, NULL, &cfg_col_real_white, NULL, -1, config_change_color },
   { "col_separator", N_("color for window separators (when splited)"),
     N_("color for window separators (when splited)"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "blue", NULL, &cfg_col_separator, NULL, &config_change_color },
+    "blue", NULL, &cfg_col_separator, NULL, -1, &config_change_color },
   /* title window */
   { "col_title", N_("color for title bar"),
     N_("color for title bar"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "default", NULL, &cfg_col_title, NULL, &config_change_color },
+    "default", NULL, &cfg_col_title, NULL, -1, &config_change_color },
   { "col_title_more", N_("color for '+' when scrolling topic"),
     N_("color for '+' when scrolling topic"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "lightmagenta", NULL, &cfg_col_title_more, NULL, &config_change_color },
+    "lightmagenta", NULL, &cfg_col_title_more, NULL, -1, &config_change_color },
   { "col_title_bg", N_("background for title bar"),
     N_("background for title bar"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "blue", NULL, &cfg_col_title_bg, NULL, &config_change_color },
+    "blue", NULL, &cfg_col_title_bg, NULL, -1, &config_change_color },
   
   /* chat window */
   { "col_chat", N_("color for chat text"),
     N_("color for chat text"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "default", NULL, &cfg_col_chat, NULL, &config_change_color },
+    "default", NULL, &cfg_col_chat, NULL, -1, &config_change_color },
   { "col_chat_time", N_("color for time"),
     N_("color for time in chat window"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "default", NULL, &cfg_col_chat_time, NULL, &config_change_color },
+    "default", NULL, &cfg_col_chat_time, NULL, -1, &config_change_color },
   { "col_chat_time_sep", N_("color for time separator"),
     N_("color for time separator (chat window)"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "brown", NULL, &cfg_col_chat_time_sep, NULL, &config_change_color },
+    "brown", NULL, &cfg_col_chat_time_sep, NULL, -1, &config_change_color },
   { "col_chat_prefix1", N_("color for 1st and 3rd char of prefix"),
     N_("color for 1st and 3rd char of prefix"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "lightcyan", NULL, &cfg_col_chat_prefix1, NULL, &config_change_color },
+    "lightcyan", NULL, &cfg_col_chat_prefix1, NULL, -1, &config_change_color },
   { "col_chat_prefix2", N_("color for middle char of prefix"),
     N_("color for middle char of prefix"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "white", NULL, &cfg_col_chat_prefix2, NULL, &config_change_color },
+    "white", NULL, &cfg_col_chat_prefix2, NULL, -1, &config_change_color },
   { "col_chat_server", N_("color for server name"),
     N_("color for server name"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "brown", NULL, &cfg_col_chat_server, NULL, &config_change_color },
+    "brown", NULL, &cfg_col_chat_server, NULL, -1, &config_change_color },
   { "col_chat_join", N_("color for join arrow (prefix)"),
     N_("color for join arrow (prefix)"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "lightgreen", NULL, &cfg_col_chat_join, NULL, &config_change_color },
+    "lightgreen", NULL, &cfg_col_chat_join, NULL, -1, &config_change_color },
   { "col_chat_part", N_("color for part/quit arrow (prefix)"),
     N_("color for part/quit arrow (prefix)"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "lightred", NULL, &cfg_col_chat_part, NULL, &config_change_color },
+    "lightred", NULL, &cfg_col_chat_part, NULL, -1, &config_change_color },
   { "col_chat_nick", N_("color for nicks in actions"),
     N_("color for nicks in actions (chat window)"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "lightcyan", NULL, &cfg_col_chat_nick, NULL, &config_change_color },
+    "lightcyan", NULL, &cfg_col_chat_nick, NULL, -1, &config_change_color },
   { "col_chat_host", N_("color for hostnames"),
     N_("color for hostnames (chat window)"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "cyan", NULL, &cfg_col_chat_host, NULL, &config_change_color },
+    "cyan", NULL, &cfg_col_chat_host, NULL, -1, &config_change_color },
   { "col_chat_channel", N_("color for channel names in actions"),
     N_("color for channel names in actions (chat window)"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "white", NULL, &cfg_col_chat_channel, NULL, &config_change_color },
+    "white", NULL, &cfg_col_chat_channel, NULL, -1, &config_change_color },
   { "col_chat_dark", N_("color for dark separators"),
     N_("color for dark separators (chat window)"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "green", NULL, &cfg_col_chat_dark, NULL, &config_change_color },
+    "green", NULL, &cfg_col_chat_dark, NULL, -1, &config_change_color },
   { "col_chat_highlight", N_("color for highlighted nick"),
     N_("color for highlighted nick (chat window)"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "yellow", NULL, &cfg_col_chat_highlight, NULL, &config_change_color },
+    "yellow", NULL, &cfg_col_chat_highlight, NULL, -1, &config_change_color },
   { "col_chat_bg", N_("background for chat"),
     N_("background for chat window"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "default", NULL, &cfg_col_chat_bg, NULL, &config_change_color },
+    "default", NULL, &cfg_col_chat_bg, NULL, -1, &config_change_color },
   { "col_chat_read_marker", N_("color for unread data marker"),
     N_("color for unread data marker"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "yellow", NULL, &cfg_col_chat_read_marker, NULL, &config_change_color },
+    "yellow", NULL, &cfg_col_chat_read_marker, NULL, -1, &config_change_color },
   { "col_chat_read_marker_bg", N_("background for unread data marker"),
     N_("background for unread data marker"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "magenta", NULL, &cfg_col_chat_read_marker_bg, NULL, &config_change_color },
+    "magenta", NULL, &cfg_col_chat_read_marker_bg, NULL, -1, &config_change_color },
   
   /* status window */
   { "col_status", N_("color for status bar"),
     N_("color for status bar"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "default", NULL, &cfg_col_status, NULL, &config_change_color },
+    "default", NULL, &cfg_col_status, NULL, -1, &config_change_color },
   { "col_status_delimiters", N_("color for status bar delimiters"),
     N_("color for status bar delimiters"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "cyan", NULL, &cfg_col_status_delimiters, NULL, &config_change_color },
+    "cyan", NULL, &cfg_col_status_delimiters, NULL, -1, &config_change_color },
   { "col_status_channel", N_("color for current channel in status bar"),
     N_("color for current channel in status bar"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "white", NULL, &cfg_col_status_channel, NULL, &config_change_color },
+    "white", NULL, &cfg_col_status_channel, NULL, -1, &config_change_color },
   { "col_status_data_msg", N_("color for window with new messages"),
     N_("color for window with new messages (status bar)"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "yellow", NULL, &cfg_col_status_data_msg, NULL, &config_change_color },
+    "yellow", NULL, &cfg_col_status_data_msg, NULL, -1, &config_change_color },
   { "col_status_private", N_("color for window with private message"),
     N_("color for window with private message (status bar)"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "lightmagenta", NULL, &cfg_col_status_data_private, NULL, &config_change_color },
+    "lightmagenta", NULL, &cfg_col_status_data_private, NULL, -1, &config_change_color },
   { "col_status_highlight", N_("color for window with highlight"),
     N_("color for window with highlight (status bar)"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "lightred", NULL, &cfg_col_status_data_highlight, NULL, &config_change_color },
+    "lightred", NULL, &cfg_col_status_data_highlight, NULL, -1, &config_change_color },
   { "col_status_data_other", N_("color for window with new data (not messages)"),
     N_("color for window with new data (not messages) (status bar)"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "default", NULL, &cfg_col_status_data_other, NULL, &config_change_color },
+    "default", NULL, &cfg_col_status_data_other, NULL, -1, &config_change_color },
   { "col_status_more", N_("color for \"-MORE-\" text"),
     N_("color for window with new data (status bar)"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "white", NULL, &cfg_col_status_more, NULL, &config_change_color },
+    "white", NULL, &cfg_col_status_more, NULL, -1, &config_change_color },
   { "col_status_bg", N_("background for status window"),
     N_("background for status window"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "blue", NULL, &cfg_col_status_bg, NULL, &config_change_color },
+    "blue", NULL, &cfg_col_status_bg, NULL, -1, &config_change_color },
 
   /* infobar window */
   { "col_infobar", N_("color for info bar text"),
     N_("color for info bar text"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "black", NULL, &cfg_col_infobar, NULL, &config_change_color },
+    "black", NULL, &cfg_col_infobar, NULL, -1, &config_change_color },
   { "col_infobar_delimiters", N_("color for infobar delimiters"),
     N_("color for infobar delimiters"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "blue", NULL, &cfg_col_infobar_delimiters, NULL, &config_change_color },
+    "blue", NULL, &cfg_col_infobar_delimiters, NULL, -1, &config_change_color },
   { "col_infobar_highlight", N_("color for info bar highlight notification"),
     N_("color for info bar highlight notification"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "white", NULL, &cfg_col_infobar_highlight, NULL, &config_change_color },
+    "white", NULL, &cfg_col_infobar_highlight, NULL, -1, &config_change_color },
   { "col_infobar_bg", N_("background for info bar window"),
     N_("background for info bar window"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "cyan", NULL, &cfg_col_infobar_bg, NULL, &config_change_color },
+    "cyan", NULL, &cfg_col_infobar_bg, NULL, -1, &config_change_color },
   
   /* input window */
   { "col_input", N_("color for input text"),
     N_("color for input text"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "default", NULL, &cfg_col_input, NULL, &config_change_color },
+    "default", NULL, &cfg_col_input, NULL, -1, &config_change_color },
   { "col_input_server", N_("color for input text (server name)"),
     N_("color for input text (server name)"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "brown", NULL, &cfg_col_input_server, NULL, &config_change_color },
+    "brown", NULL, &cfg_col_input_server, NULL, -1, &config_change_color },
   { "col_input_channel", N_("color for input text (channel name)"),
     N_("color for input text (channel name)"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "white", NULL, &cfg_col_input_channel, NULL, &config_change_color },
+    "white", NULL, &cfg_col_input_channel, NULL, -1, &config_change_color },
   { "col_input_nick", N_("color for input text (nick name)"),
     N_("color for input text (nick name)"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "lightcyan", NULL, &cfg_col_input_nick, NULL, &config_change_color },
+    "lightcyan", NULL, &cfg_col_input_nick, NULL, -1, &config_change_color },
   { "col_input_delimiters", N_("color for input text (delimiters)"),
     N_("color for input text (delimiters)"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "cyan", NULL, &cfg_col_input_delimiters, NULL, &config_change_color },
+    "cyan", NULL, &cfg_col_input_delimiters, NULL, -1, &config_change_color },
   { "col_input_bg", N_("background for input window"),
     N_("background for input window"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "default", NULL, &cfg_col_input_bg, NULL, &config_change_color },
+    "default", NULL, &cfg_col_input_bg, NULL, -1, &config_change_color },
   
   /* nick window */
   { "col_nick", N_("color for nicknames"),
     N_("color for nicknames"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "default", NULL, &cfg_col_nick, NULL, &config_change_color },
+    "default", NULL, &cfg_col_nick, NULL, -1, &config_change_color },
   { "col_nick_away", N_("color for away nicknames"),
     N_("color for away nicknames"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "cyan", NULL, &cfg_col_nick_away, NULL, &config_change_color },
+    "cyan", NULL, &cfg_col_nick_away, NULL, -1, &config_change_color },
   { "col_nick_chanowner", N_("color for chan owner symbol"),
     N_("color for chan owner symbol (specific to unrealircd)"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "lightgreen", NULL, &cfg_col_nick_chanowner, NULL, &config_change_color },
+    "lightgreen", NULL, &cfg_col_nick_chanowner, NULL, -1, &config_change_color },
   { "col_nick_chanadmin", N_("color for chan admin symbol"),
     N_("color for chan admin symbol (specific to unrealircd)"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "lightgreen", NULL, &cfg_col_nick_chanadmin, NULL, &config_change_color },
+    "lightgreen", NULL, &cfg_col_nick_chanadmin, NULL, -1, &config_change_color },
   { "col_nick_op", N_("color for operator symbol"),
     N_("color for operator symbol"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "lightgreen", NULL, &cfg_col_nick_op, NULL, &config_change_color },
+    "lightgreen", NULL, &cfg_col_nick_op, NULL, -1, &config_change_color },
   { "col_nick_halfop", N_("color for half-operator symbol"),
     N_("color for half-operator symbol"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "lightmagenta", NULL, &cfg_col_nick_halfop, NULL, &config_change_color },
+    "lightmagenta", NULL, &cfg_col_nick_halfop, NULL, -1, &config_change_color },
   { "col_nick_voice", N_("color for voice symbol"),
     N_("color for voice symbol"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "yellow", NULL, &cfg_col_nick_voice, NULL, &config_change_color },
+    "yellow", NULL, &cfg_col_nick_voice, NULL, -1, &config_change_color },
   { "col_nick_more", N_("color for '+' when scrolling nicks"),
     N_("color for '+' when scrolling nicks"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "lightmagenta", NULL, &cfg_col_nick_more, NULL, &config_change_color },
+    "lightmagenta", NULL, &cfg_col_nick_more, NULL, -1, &config_change_color },
   { "col_nick_sep", N_("color for nick separator"),
     N_("color for nick separator"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "blue", NULL, &cfg_col_nick_sep, NULL, &config_change_color },
+    "blue", NULL, &cfg_col_nick_sep, NULL, -1, &config_change_color },
   { "col_nick_self", N_("color for local nick"),
     N_("color for local nick"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "white", NULL, &cfg_col_nick_self, NULL, &config_change_color },
+    "white", NULL, &cfg_col_nick_self, NULL, -1, &config_change_color },
   { "col_nick_color1", N_("color for nick"),
     N_("color for nick"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "cyan", NULL, &cfg_col_nick_colors[0], NULL, &config_change_color },
+    "cyan", NULL, &cfg_col_nick_colors[0], NULL, -1, &config_change_color },
   { "col_nick_color2", N_("color for nick"),
     N_("color for nick"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "magenta", NULL, &cfg_col_nick_colors[1], NULL, &config_change_color },
+    "magenta", NULL, &cfg_col_nick_colors[1], NULL, -1, &config_change_color },
   { "col_nick_color3", N_("color for nick"),
     N_("color for nick"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "green", NULL, &cfg_col_nick_colors[2], NULL, &config_change_color },
+    "green", NULL, &cfg_col_nick_colors[2], NULL, -1, &config_change_color },
   { "col_nick_color4", N_("color for nick"),
     N_("color for nick"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "brown", NULL, &cfg_col_nick_colors[3], NULL, &config_change_color },
+    "brown", NULL, &cfg_col_nick_colors[3], NULL, -1, &config_change_color },
   { "col_nick_color5", N_("color for nick"),
     N_("color for nick"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "lightblue", NULL, &cfg_col_nick_colors[4], NULL, &config_change_color },
+    "lightblue", NULL, &cfg_col_nick_colors[4], NULL, -1, &config_change_color },
   { "col_nick_color6", N_("color for nick"),
     N_("color for nick"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "default", NULL, &cfg_col_nick_colors[5], NULL, &config_change_color },
+    "default", NULL, &cfg_col_nick_colors[5], NULL, -1, &config_change_color },
   { "col_nick_color7", N_("color for nick"),
     N_("color for nick"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "lightcyan", NULL, &cfg_col_nick_colors[6], NULL, &config_change_color },
+    "lightcyan", NULL, &cfg_col_nick_colors[6], NULL, -1, &config_change_color },
   { "col_nick_color8", N_("color for nick"),
     N_("color for nick"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "lightmagenta", NULL, &cfg_col_nick_colors[7], NULL, &config_change_color },
+    "lightmagenta", NULL, &cfg_col_nick_colors[7], NULL, -1, &config_change_color },
   { "col_nick_color9", N_("color for nick"),
     N_("color for nick"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "lightgreen", NULL, &cfg_col_nick_colors[8], NULL, &config_change_color },
+    "lightgreen", NULL, &cfg_col_nick_colors[8], NULL, -1, &config_change_color },
   { "col_nick_color10", N_("color for nick"),
     N_("color for nick"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "blue", NULL, &cfg_col_nick_colors[9], NULL, &config_change_color },
+    "blue", NULL, &cfg_col_nick_colors[9], NULL, -1, &config_change_color },
   { "col_nick_private", N_("color for other nick in private window"),
     N_("color for other nick in private window"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "default", NULL, &cfg_col_nick_private, NULL, &config_change_color },
+    "default", NULL, &cfg_col_nick_private, NULL, -1, &config_change_color },
   { "col_nick_bg", N_("background for nicknames"),
     N_("background for nicknames"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "default", NULL, &cfg_col_nick_bg, NULL, &config_change_color },
+    "default", NULL, &cfg_col_nick_bg, NULL, -1, &config_change_color },
   
   /* DCC */
   { "col_chat_dcc_selected", N_("color for selected DCC"),
     N_("color for selected DCC (chat window)"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "white", NULL, &cfg_col_dcc_selected, NULL, &config_change_color },
+    "white", NULL, &cfg_col_dcc_selected, NULL, -1, &config_change_color },
   { "col_dcc_waiting", N_("color for \"waiting\" dcc status"),
     N_("color for \"waiting\" dcc status"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "lightcyan", NULL, &cfg_col_dcc_waiting, NULL, &config_change_color },
+    "lightcyan", NULL, &cfg_col_dcc_waiting, NULL, -1, &config_change_color },
   { "col_dcc_connecting", N_("color for \"connecting\" dcc status"),
     N_("color for \"connecting\" dcc status"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "yellow", NULL, &cfg_col_dcc_connecting, NULL, &config_change_color },
+    "yellow", NULL, &cfg_col_dcc_connecting, NULL, -1, &config_change_color },
   { "col_dcc_active", N_("color for \"active\" dcc status"),
     N_("color for \"active\" dcc status"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "lightblue", NULL, &cfg_col_dcc_active, NULL, &config_change_color },
+    "lightblue", NULL, &cfg_col_dcc_active, NULL, -1, &config_change_color },
   { "col_dcc_done", N_("color for \"done\" dcc status"),
     N_("color for \"done\" dcc status"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "lightgreen", NULL, &cfg_col_dcc_done, NULL, &config_change_color },
+    "lightgreen", NULL, &cfg_col_dcc_done, NULL, -1, &config_change_color },
   { "col_dcc_failed", N_("color for \"failed\" dcc status"),
     N_("color for \"failed\" dcc status"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "lightred", NULL, &cfg_col_dcc_failed, NULL, &config_change_color },
+    "lightred", NULL, &cfg_col_dcc_failed, NULL, -1, &config_change_color },
   { "col_dcc_aborted", N_("color for \"aborted\" dcc status"),
     N_("color for \"aborted\" dcc status"),
     OPTION_TYPE_COLOR, 0, 0, 0,
-    "lightred", NULL, &cfg_col_dcc_aborted, NULL, &config_change_color },
+    "lightred", NULL, &cfg_col_dcc_aborted, NULL, -1, &config_change_color },
   
-  { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
+  { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, -1, NULL }
 };
 
 /* config, history section */
@@ -648,16 +649,16 @@ t_config_option weechat_options_history[
     N_("maximum number of lines in history "
     "for one server/channel/private window (0 = unlimited)"),
     OPTION_TYPE_INT, 0, INT_MAX, 4096,
-    NULL, NULL, &cfg_history_max_lines, NULL, &config_change_noop },
+    NULL, NULL, &cfg_history_max_lines, NULL, -1, &config_change_noop },
   { "history_max_commands", N_("max user commands in history"),
     N_("maximum number of user commands in history (0 = unlimited)"),
     OPTION_TYPE_INT, 0, INT_MAX, 100,
-    NULL, NULL, &cfg_history_max_commands, NULL, &config_change_noop },
+    NULL, NULL, &cfg_history_max_commands, NULL, -1, &config_change_noop },
   { "history_display_default", N_("max commands to display"),
     N_("maximum number of commands to display by default in history listing (0 = unlimited)"),
     OPTION_TYPE_INT, 0, INT_MAX, 5,
-    NULL, NULL, &cfg_history_display_default, NULL, &config_change_noop },
-  { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
+    NULL, NULL, &cfg_history_display_default, NULL, -1, &config_change_noop },
+  { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, -1, NULL }
 };
 
 /* config, log section */
@@ -674,33 +675,33 @@ t_config_option weechat_options_log[] =
 { { "log_auto_server", N_("automatically log server messages"),
     N_("automatically log server messages"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
-    NULL, NULL, &cfg_log_auto_server, NULL, &config_change_log },
+    NULL, NULL, &cfg_log_auto_server, NULL, -1, &config_change_log },
   { "log_auto_channel", N_("automatically log channel chats"),
     N_("automatically log channel chats"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
-    NULL, NULL, &cfg_log_auto_channel, NULL, &config_change_log },
+    NULL, NULL, &cfg_log_auto_channel, NULL, -1, &config_change_log },
   { "log_auto_private", N_("automatically log private chats"),
     N_("automatically log private chats"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
-    NULL, NULL, &cfg_log_auto_private, NULL, &config_change_log },
+    NULL, NULL, &cfg_log_auto_private, NULL, -1, &config_change_log },
   { "log_plugin_msg", N_("log messages from plugins (scripts)"),
     N_("log messages from plugins (scripts)"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
-    NULL, NULL, &cfg_log_plugin_msg, NULL, &config_change_noop },
+    NULL, NULL, &cfg_log_plugin_msg, NULL, -1, &config_change_noop },
   { "log_path", N_("path for log files"),
     N_("path for WeeChat log files ('%h' will be replaced by WeeChat home, "
        "~/.weechat by default)"),
     OPTION_TYPE_STRING, 0, 0, 0,
-    "%h/logs/", NULL, NULL, &cfg_log_path, &config_change_noop },
+    "%h/logs/", NULL, NULL, &cfg_log_path, -1, &config_change_noop },
   { "log_timestamp", N_("timestamp for log"),
     N_("timestamp for log (see man strftime for date/time specifiers)"),
     OPTION_TYPE_STRING, 0, 0, 0,
-    "%Y %b %d %H:%M:%S", NULL, NULL, &cfg_log_timestamp, &config_change_noop },
+    "%Y %b %d %H:%M:%S", NULL, NULL, &cfg_log_timestamp, -1, &config_change_noop },
   { "log_hide_nickserv_pwd", N_("hide password displayed by nickserv"),
     N_("hide password displayed by nickserv"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
-    NULL, NULL, &cfg_log_hide_nickserv_pwd, NULL, &config_change_noop },
-  { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
+    NULL, NULL, &cfg_log_hide_nickserv_pwd, NULL, -1, &config_change_noop },
+  { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, -1, NULL }
 };
 
 /* config, irc section */
@@ -728,72 +729,72 @@ t_config_option weechat_options_irc[] =
 { { "irc_display_away", N_("display message for away"),
     N_("display message when (un)marking as away"),
     OPTION_TYPE_INT_WITH_STRING, 0, 0, 0,
-    "off", cfg_irc_display_away_values, &cfg_irc_display_away, NULL, &config_change_noop },
+    "off", cfg_irc_display_away_values, &cfg_irc_display_away, NULL, -1, &config_change_noop },
   { "irc_show_away_once", N_("show remote away message only once in private"),
     N_("show remote away message only once in private"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
-    NULL, NULL, &cfg_irc_show_away_once, NULL, &config_change_noop },
+    NULL, NULL, &cfg_irc_show_away_once, NULL, -1, &config_change_noop },
   { "irc_default_msg_part", N_("default part message (leaving channel)"),
     N_("default part message (leaving channel) ('%v' will be replaced by "
        "WeeChat version in string)"),
     OPTION_TYPE_STRING, 0, 0, 0,
-    "WeeChat %v", NULL, NULL, &cfg_irc_default_msg_part, &config_change_noop },
+    "WeeChat %v", NULL, NULL, &cfg_irc_default_msg_part, -1, &config_change_noop },
   { "irc_default_msg_quit", N_("default quit message"),
     N_("default quit message ('%v' will be replaced by WeeChat version in string)"),
     OPTION_TYPE_STRING, 0, 0, 0,
-    "WeeChat %v", NULL, NULL, &cfg_irc_default_msg_quit, &config_change_noop },
+    "WeeChat %v", NULL, NULL, &cfg_irc_default_msg_quit, -1, &config_change_noop },
   { "irc_notice_as_pv", N_("display notices as private messages"),
     N_("display notices as private messages"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
-    NULL, NULL, &cfg_irc_notice_as_pv, NULL, &config_change_noop },
+    NULL, NULL, &cfg_irc_notice_as_pv, NULL, -1, &config_change_noop },
   { "irc_away_check", N_("interval between two checks for away"),
     N_("interval between two checks for away (in minutes, 0 = never check)"),
     OPTION_TYPE_INT, 0, INT_MAX, 0,
-    NULL, NULL, &cfg_irc_away_check, NULL, &config_change_away_check },
+    NULL, NULL, &cfg_irc_away_check, NULL, -1, &config_change_away_check },
   { "irc_away_check_max_nicks", N_("max number of nicks for away check"),
     N_("do not check away nicks on channels with high number of nicks (0 = unlimited)"),
     OPTION_TYPE_INT, 0, INT_MAX, 0,
-    NULL, NULL, &cfg_irc_away_check_max_nicks, NULL, &config_change_away_check },
+    NULL, NULL, &cfg_irc_away_check_max_nicks, NULL, -1, &config_change_away_check },
   { "irc_lag_check", N_("interval between two checks for lag"),
     N_("interval between two checks for lag (in seconds)"),
     OPTION_TYPE_INT, 30, INT_MAX, 60,
-    NULL, NULL, &cfg_irc_lag_check, NULL, &config_change_noop },
+    NULL, NULL, &cfg_irc_lag_check, NULL, -1, &config_change_noop },
   { "irc_lag_min_show", N_("minimum lag to show"),
     N_("minimum lag to show (in seconds)"),
     OPTION_TYPE_INT, 0, INT_MAX, 1,
-    NULL, NULL, &cfg_irc_lag_min_show, NULL, &config_change_noop },
+    NULL, NULL, &cfg_irc_lag_min_show, NULL, -1, &config_change_noop },
   { "irc_lag_disconnect", N_("disconnect after important lag"),
     N_("disconnect after important lag (in minutes, 0 = never disconnect)"),
     OPTION_TYPE_INT, 0, INT_MAX, 5,
-    NULL, NULL, &cfg_irc_lag_disconnect, NULL, &config_change_noop },
+    NULL, NULL, &cfg_irc_lag_disconnect, NULL, -1, &config_change_noop },
   { "irc_anti_flood", N_("anti-flood"),
     N_("anti-flood: # seconds between two user messages (0 = no anti-flood)"),
     OPTION_TYPE_INT, 0, 5, 2,
-    NULL, NULL, &cfg_irc_anti_flood, NULL, &config_change_noop },
+    NULL, NULL, &cfg_irc_anti_flood, NULL, -1, &config_change_noop },
   { "irc_fifo_pipe", N_("create a FIFO pipe for remote control"),
     N_("create a FIFO pipe for remote control"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
-    NULL, NULL, &cfg_irc_fifo_pipe, NULL, &config_change_fifo_pipe },
+    NULL, NULL, &cfg_irc_fifo_pipe, NULL, -1, &config_change_fifo_pipe },
   { "irc_highlight", N_("list of words to highlight"),
     N_("comma separated list of words to highlight (case insensitive comparison, "
        "words may begin or end with \"*\" for partial match)"),
     OPTION_TYPE_STRING, 0, 0, 0,
-    "", NULL, NULL, &cfg_irc_highlight, &config_change_noop },
+    "", NULL, NULL, &cfg_irc_highlight, -1, &config_change_noop },
   { "irc_colors_receive", N_("when off, colors codes are ignored in "
                              "incoming messages"),
     N_("when off, colors codes are ignored in incoming messages"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
-    NULL, NULL, &cfg_irc_colors_receive, NULL, config_change_noop },
+    NULL, NULL, &cfg_irc_colors_receive, NULL, -1, config_change_noop },
   { "irc_colors_send", N_("allow user to send colors"),
     N_("allow user to send colors with special codes (%B=bold, %Cxx,yy=color, "
        "%U=underline, %R=reverse)"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
-    NULL, NULL, &cfg_irc_colors_send, NULL, config_change_noop },
+    NULL, NULL, &cfg_irc_colors_send, NULL, -1, config_change_noop },
   { "irc_send_unknown_commands", N_("send unknown commands to IRC server"),
     N_("send unknown commands to IRC server"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
-    NULL, NULL, &cfg_irc_send_unknown_commands, NULL, &config_change_noop },
-  { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
+    NULL, NULL, &cfg_irc_send_unknown_commands, NULL, -1, &config_change_noop },
+  { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, -1, NULL }
 };
 
 /* config, dcc section */
@@ -815,60 +816,59 @@ t_config_option weechat_options_dcc[] =
 { { "dcc_auto_accept_files", N_("automatically accept dcc files"),
     N_("automatically accept incoming dcc files"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
-    NULL, NULL, &cfg_dcc_auto_accept_files, NULL, &config_change_noop },
+    NULL, NULL, &cfg_dcc_auto_accept_files, NULL, -1, &config_change_noop },
   { "dcc_auto_accept_chats", N_("automatically accept dcc chats"),
     N_("automatically accept dcc chats (use carefully!)"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
-    NULL, NULL, &cfg_dcc_auto_accept_chats, NULL, &config_change_noop },
+    NULL, NULL, &cfg_dcc_auto_accept_chats, NULL, -1, &config_change_noop },
   { "dcc_timeout", N_("timeout for dcc request"),
     N_("timeout for dcc request (in seconds)"),
     OPTION_TYPE_INT, 5, INT_MAX, 300,
-    NULL, NULL, &cfg_dcc_timeout, NULL, &config_change_noop },
+    NULL, NULL, &cfg_dcc_timeout, NULL, -1, &config_change_noop },
   { "dcc_blocksize", N_("block size for dcc packets"),
     N_("block size for dcc packets in bytes (default: 65536)"),
     OPTION_TYPE_INT, DCC_MIN_BLOCKSIZE, DCC_MAX_BLOCKSIZE, 65536,
-    NULL, NULL, &cfg_dcc_blocksize, NULL, &config_change_noop },
+    NULL, NULL, &cfg_dcc_blocksize, NULL, -1, &config_change_noop },
   { "dcc_fast_send", N_("does not wait for ACK when sending file"),
     N_("does not wait for ACK when sending file"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
-    NULL, NULL, &cfg_dcc_fast_send, NULL, &config_change_noop },
+    NULL, NULL, &cfg_dcc_fast_send, NULL, -1, &config_change_noop },
   { "dcc_port_range", N_("allowed ports for outgoing dcc"),
     N_("restricts outgoing dcc to use only ports in the given range "
        "(useful for NAT) (syntax: a single port, ie. 5000 or a port "
        "range, ie. 5000-5015, empty value means any port)"),
     OPTION_TYPE_STRING, 0, 0, 0, "",
-    NULL, NULL, &cfg_dcc_port_range, &config_change_noop },
+    NULL, NULL, &cfg_dcc_port_range, -1, &config_change_noop },
   { "dcc_own_ip", N_("IP address for outgoing dcc"),
     N_("IP or DNS address used for outgoing dcc "
        "(if empty, local interface IP is used)"),
     OPTION_TYPE_STRING, 0, 0, 0, "",
-    NULL, NULL, &cfg_dcc_own_ip, &config_change_noop },
+    NULL, NULL, &cfg_dcc_own_ip, -1, &config_change_noop },
   { "dcc_download_path", N_("path for incoming files with dcc"),
     N_("path for writing incoming files with dcc (default: user home)"),
     OPTION_TYPE_STRING, 0, 0, 0,
-    "%h/dcc", NULL, NULL, &cfg_dcc_download_path, &config_change_noop },
+    "%h/dcc", NULL, NULL, &cfg_dcc_download_path, -1, &config_change_noop },
   { "dcc_upload_path", N_("default path for sending files with dcc"),
     N_("path for reading files when sending thru dcc (when no path is specified)"),
     OPTION_TYPE_STRING, 0, 0, 0, "~",
-    NULL, NULL, &cfg_dcc_upload_path, &config_change_noop },
+    NULL, NULL, &cfg_dcc_upload_path, -1, &config_change_noop },
   { "dcc_convert_spaces", N_("convert spaces to underscores when sending files"),
     N_("convert spaces to underscores when sending files"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
-    NULL, NULL, &cfg_dcc_convert_spaces, NULL, &config_change_noop },
+    NULL, NULL, &cfg_dcc_convert_spaces, NULL, -1, &config_change_noop },
   { "dcc_auto_rename", N_("automatically rename dcc files if already exists"),
     N_("rename incoming files if already exists (add '.1', '.2', ...)"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
-    NULL, NULL, &cfg_dcc_auto_rename, NULL, &config_change_noop },
+    NULL, NULL, &cfg_dcc_auto_rename, NULL, -1, &config_change_noop },
   { "dcc_auto_resume", N_("automatically resume aborted transfers"),
     N_("automatically resume dcc transfer if connection with remote host is loosed"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
-    NULL, NULL, &cfg_dcc_auto_resume, NULL, &config_change_noop },
-  { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
+    NULL, NULL, &cfg_dcc_auto_resume, NULL, -1, &config_change_noop },
+  { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, -1, NULL }
 };
 
 /* config, proxy section */
 
-int cfg_proxy_use;
 int cfg_proxy_type;
 int cfg_proxy_ipv6;
 char *cfg_proxy_type_values[] =
@@ -879,35 +879,31 @@ char *cfg_proxy_username;
 char *cfg_proxy_password;
 
 t_config_option weechat_options_proxy[] =
-{ { "proxy_use", N_("use proxy"),
-    N_("use a proxy server to connect to irc server"),
-    OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
-    NULL, NULL, &cfg_proxy_use, NULL, &config_change_noop },
-  { "proxy_type", N_("proxy type"),
+{ { "proxy_type", N_("proxy type"),
     N_("proxy type (http (default), socks4, socks5)"),
     OPTION_TYPE_INT_WITH_STRING, 0, 0, 0,
-    "http", cfg_proxy_type_values, &cfg_proxy_type, NULL, &config_change_noop },
+    "http", cfg_proxy_type_values, &cfg_proxy_type, NULL, -1, &config_change_noop },
   { "proxy_ipv6", N_("use ipv6 proxy"),
     N_("connect to proxy in ipv6"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
-    NULL, NULL, &cfg_proxy_ipv6, NULL, &config_change_noop },
+    NULL, NULL, &cfg_proxy_ipv6, NULL, -1, &config_change_noop },
   { "proxy_address", N_("proxy address"),
     N_("proxy server address (IP or hostname)"),
     OPTION_TYPE_STRING, 0, 0, 0,
-    "", NULL, NULL, &cfg_proxy_address, &config_change_noop },
+    "", NULL, NULL, &cfg_proxy_address, -1, &config_change_noop },
   { "proxy_port", N_("port for proxy"),
     N_("port for connecting to proxy server"),
     OPTION_TYPE_INT, 0, 65535, 3128,
-    NULL, NULL, &cfg_proxy_port, NULL, &config_change_noop },
+    NULL, NULL, &cfg_proxy_port, NULL, -1, &config_change_noop },
   { "proxy_username", N_("proxy username"),
     N_("username for proxy server"),
     OPTION_TYPE_STRING, 0, 0, 0,
-    "", NULL, NULL, &cfg_proxy_username, &config_change_noop },
+    "", NULL, NULL, &cfg_proxy_username, -1, &config_change_noop },
   { "proxy_password", N_("proxy password"),
     N_("password for proxy server"),
     OPTION_TYPE_STRING, 0, 0, 0,
-    "", NULL, NULL, &cfg_proxy_password, &config_change_noop },
-  { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
+    "", NULL, NULL, &cfg_proxy_password, -1, &config_change_noop },
+  { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, -1, NULL }
 };
 
 /* config, plugins section */
@@ -921,13 +917,13 @@ t_config_option weechat_options_plugins[
     N_("path for searching plugins ('%h' will be replaced by WeeChat home, "
        "~/.weechat by default)"),
     OPTION_TYPE_STRING, 0, 0, 0,
-    "%h/plugins", NULL, NULL, &cfg_plugins_path, &config_change_noop },
+    "%h/plugins", NULL, NULL, &cfg_plugins_path, -1, &config_change_noop },
   { "plugins_autoload", N_("list of plugins to load automatically"),
     N_("comma separated list of plugins to load automatically at startup, "
        "\"*\" means all plugins found "
        "(names may be partial, for example \"perl\" is ok for \"libperl.so\")"),
     OPTION_TYPE_STRING, 0, 0, 0,
-    "*", NULL, NULL, &cfg_plugins_autoload, &config_change_noop },
+    "*", NULL, NULL, &cfg_plugins_autoload, -1, &config_change_noop },
   { "plugins_extension", N_("standard plugins extension in filename"),
     N_("standard plugins extension in filename, used for autoload "
        "(if empty, then all files are loaded when autoload is \"*\")"),
@@ -937,109 +933,126 @@ t_config_option weechat_options_plugins[
 #else
     ".so",
 #endif
-    NULL, NULL, &cfg_plugins_extension, &config_change_noop },
-  { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
+    NULL, NULL, &cfg_plugins_extension, -1, &config_change_noop },
+  { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, -1, NULL }
 };
 
 /* config, server section */
 
+/* XXX: there is code, that relies that weechat_options_server
+ * point to cfg_server structure */
 static t_irc_server cfg_server;
 
 t_config_option weechat_options_server[] =
 { { "server_name", N_("server name"),
     N_("name associated to IRC server (for display only)"),
     OPTION_TYPE_STRING, 0, 0, 0,
-    "", NULL, NULL, &(cfg_server.name), NULL },
+    "", NULL, NULL, &(cfg_server.name), -1, NULL },
+  { "server_address", N_("server address or hostname"),
+    N_("IP address or hostname of IRC server"),
+    OPTION_TYPE_STRING, 0, 0, 0,
+    "", NULL, NULL, &(cfg_server.address), -1, NULL },
+  { "server_port", N_("port for IRC server"),
+    N_("port for connecting to server"),
+    OPTION_TYPE_INT, 0, 65535, 6667,
+    NULL, NULL, &(cfg_server.port), NULL, -1, NULL },
+  { "server_password", N_("server password"),
+    N_("password for IRC server"),
+    OPTION_TYPE_STRING, 0, 0, 0,
+    "", NULL, NULL, &(cfg_server.password), -1, NULL },
+  { "server_autojoin", N_("list of channels to join when connected to server"),
+    N_("comma separated list of channels to join when connected to server (example: \"#chan1,#chan2,#chan3 key1,key2\")"),
+    OPTION_TYPE_STRING, 0, 0, 0,
+    "", NULL, NULL, &(cfg_server.autojoin), -1, NULL },
+  { "server_command", N_("command(s) to run when connected to server"),
+    N_("command(s) to run when connected to server (many commands should be "
+       "separated by ';', use '\\;' for a semicolon, special variables $nick, "
+       "$channel and $server are replaced by their value)"),
+    OPTION_TYPE_STRING, 0, 0, 0,
+    "", NULL, NULL, &(cfg_server.command), -1, NULL },
+  { "server_notify_levels", N_("notify levels for channels of this server"),
+    N_("comma separated list of notify levels for channels of this server "
+       "(format: #channel:1,..), a channel name '*' is reserved for server "
+       "default notify level"),
+    OPTION_TYPE_STRING, 0, 0, 0,
+    "", NULL, NULL, &(cfg_server.notify_levels), -1, config_change_notify_levels },
+  /* options, that can have defaults, they are copied during initialization */
   { "server_autoconnect", N_("automatically connect to server"),
     N_("automatically connect to server when WeeChat is starting"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
-    NULL, NULL, &(cfg_server.autoconnect), NULL, NULL },
+    NULL, NULL, &(cfg_server.setting.autoconnect), NULL, offsetof(t_irc_server, isset.autoconnect), NULL },
   { "server_autoreconnect", N_("automatically reconnect to server"),
     N_("automatically reconnect to server when disconnected"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
-    NULL, NULL, &(cfg_server.autoreconnect), NULL, NULL },
+    NULL, NULL, &(cfg_server.setting.autoreconnect), NULL, offsetof(t_irc_server, isset.autoreconnect), NULL },
   { "server_autoreconnect_delay", N_("delay before trying again to reconnect"),
     N_("delay (in seconds) before trying again to reconnect to server"),
     OPTION_TYPE_INT, 0, 65535, 30,
-    NULL, NULL, &(cfg_server.autoreconnect_delay), NULL, NULL },
-  { "server_address", N_("server address or hostname"),
-    N_("IP address or hostname of IRC server"),
-    OPTION_TYPE_STRING, 0, 0, 0,
-    "", NULL, NULL, &(cfg_server.address), NULL },
-  { "server_port", N_("port for IRC server"),
-    N_("port for connecting to server"),
-    OPTION_TYPE_INT, 0, 65535, 6667,
-    NULL, NULL, &(cfg_server.port), NULL, NULL },
+    NULL, NULL, &(cfg_server.setting.autoreconnect_delay), NULL, offsetof(t_irc_server, isset.autoreconnect_delay), NULL },
   { "server_ipv6", N_("use IPv6 protocol for server communication"),
     N_("use IPv6 protocol for server communication"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
-    NULL, NULL, &(cfg_server.ipv6), NULL, NULL },
+    NULL, NULL, &(cfg_server.setting.ipv6), NULL, offsetof(t_irc_server, isset.ipv6), NULL },
   { "server_ssl", N_("use SSL for server communication"),
     N_("use SSL for server communication"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
-    NULL, NULL, &(cfg_server.ssl), NULL, NULL },
-  { "server_password", N_("server password"),
-    N_("password for IRC server"),
-    OPTION_TYPE_STRING, 0, 0, 0,
-    "", NULL, NULL, &(cfg_server.password), NULL },
+    NULL, NULL, &(cfg_server.setting.ssl), NULL, offsetof(t_irc_server, isset.ssl), NULL },
   { "server_nick1", N_("nickname for server"),
     N_("nickname to use on IRC server"),
     OPTION_TYPE_STRING, 0, 0, 0,
-    "", NULL, NULL, &(cfg_server.nick1), NULL },
+    "", NULL, NULL, &(cfg_server.setting.nick1), offsetof(t_irc_server, isset.nick1), NULL },
   { "server_nick2", N_("alternate nickname for server"),
     N_("alternate nickname to use on IRC server (if nickname is already used)"),
     OPTION_TYPE_STRING, 0, 0, 0,
-    "", NULL, NULL, &(cfg_server.nick2), NULL },
+    "", NULL, NULL, &(cfg_server.setting.nick2), offsetof(t_irc_server, isset.nick2), NULL },
   { "server_nick3", N_("2nd alternate nickname for server"),
     N_("2nd alternate nickname to use on IRC server (if alternate nickname is already used)"),
     OPTION_TYPE_STRING, 0, 0, 0,
-    "", NULL, NULL, &(cfg_server.nick3), NULL },
+    "", NULL, NULL, &(cfg_server.setting.nick3), offsetof(t_irc_server, isset.nick3), NULL },
   { "server_username", N_("user name for server"),
     N_("user name to use on IRC server"),
     OPTION_TYPE_STRING, 0, 0, 0,
-    "", NULL, NULL, &(cfg_server.username), NULL },
+    "", NULL, NULL, &(cfg_server.setting.username), offsetof(t_irc_server, isset.username), NULL },
   { "server_realname", N_("real name for server"),
     N_("real name to use on IRC server"),
     OPTION_TYPE_STRING, 0, 0, 0,
-    "", NULL, NULL, &(cfg_server.realname), NULL },
+    "", NULL, NULL, &(cfg_server.setting.realname), offsetof(t_irc_server, isset.realname), NULL },
   { "server_hostname", N_("custom hostname/IP for server"),
     N_("custom hostname/IP for server (optional, if empty local hostname is used)"),
     OPTION_TYPE_STRING, 0, 0, 0,
-    "", NULL, NULL, &(cfg_server.hostname), NULL },
-  { "server_command", N_("command(s) to run when connected to server"),
-    N_("command(s) to run when connected to server (many commands should be "
-       "separated by ';', use '\\;' for a semicolon, special variables $nick, "
-       "$channel and $server are replaced by their value)"),
-    OPTION_TYPE_STRING, 0, 0, 0,
-    "", NULL, NULL, &(cfg_server.command), NULL },
+    "", NULL, NULL, &(cfg_server.setting.hostname), offsetof(t_irc_server, isset.hostname), NULL },
   { "server_command_delay", N_("delay (in seconds) after command was executed"),
     N_("delay (in seconds) after command was executed (example: give some time for authentication)"),
     OPTION_TYPE_INT, 0, 5, 0,
-    NULL, NULL, &(cfg_server.command_delay), NULL, NULL },
-  { "server_autojoin", N_("list of channels to join when connected to server"),
-    N_("comma separated list of channels to join when connected to server (example: \"#chan1,#chan2,#chan3 key1,key2\")"),
-    OPTION_TYPE_STRING, 0, 0, 0,
-    "", NULL, NULL, &(cfg_server.autojoin), NULL },
+    NULL, NULL, &(cfg_server.setting.command_delay), NULL, offsetof(t_irc_server, isset.command_delay), NULL },
   { "server_autorejoin", N_("automatically rejoin channels when kicked"),
     N_("automatically rejoin channels when kicked"),
     OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
-    NULL, NULL, &(cfg_server.autorejoin), NULL, NULL },
-  { "server_notify_levels", N_("notify levels for channels of this server"),
-    N_("comma separated list of notify levels for channels of this server "
-       "(format: #channel:1,..), a channel name '*' is reserved for server "
-       "default notify level"),
-    OPTION_TYPE_STRING, 0, 0, 0,
-    "", NULL, NULL, &(cfg_server.notify_levels), config_change_notify_levels },
-  { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
+    NULL, NULL, &(cfg_server.setting.autorejoin), NULL, offsetof(t_irc_server, isset.autorejoin), NULL },
+  { "server_proxy_use", N_("use proxy"),
+    N_("use a proxy server to connect to irc server"),
+    OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
+    NULL, NULL, &(cfg_server.setting.proxy_use), NULL, offsetof(t_irc_server, isset.proxy_use), NULL },
+  { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, -1, NULL }
 };
 
+/* config, server_defaults section */
+
+/* XXX: we don't maintain .isset. in server_defaults,
+ * weechat_options_server_defaults is initialized basing on 
+ * weechat_options_server later */
+t_irc_server server_defaults;
+
+t_config_option *weechat_options_server_defaults = NULL;
+
 /* all weechat options */
 
 t_config_option *weechat_options[CONFIG_NUMBER_SECTIONS] =
 { weechat_options_look, weechat_options_colors, weechat_options_history,
   weechat_options_log, weechat_options_irc, weechat_options_dcc,
   weechat_options_proxy, weechat_options_plugins, NULL, NULL, NULL,
-  weechat_options_server
+  weechat_options_server, 
+  NULL /* note, it's reinitialized later */
 };
 
 
@@ -1502,50 +1516,23 @@ config_option_list_get_value (char **str
  */
 
 void *
-config_get_server_option_ptr (t_irc_server *server, char *option_name)
+config_get_server_option_ptr (t_irc_server *server, const t_config_option *option)
 {
-    if (ascii_strcasecmp (option_name, "server_name") == 0)
-        return (void *)(&server->name);
-    if (ascii_strcasecmp (option_name, "server_autoconnect") == 0)
-        return (void *)(&server->autoconnect);
-    if (ascii_strcasecmp (option_name, "server_autoreconnect") == 0)
-        return (void *)(&server->autoreconnect);
-    if (ascii_strcasecmp (option_name, "server_autoreconnect_delay") == 0)
-        return (void *)(&server->autoreconnect_delay);
-    if (ascii_strcasecmp (option_name, "server_address") == 0)
-        return (void *)(&server->address);
-    if (ascii_strcasecmp (option_name, "server_port") == 0)
-        return (void *)(&server->port);
-    if (ascii_strcasecmp (option_name, "server_ipv6") == 0)
-        return (void *)(&server->ipv6);
-    if (ascii_strcasecmp (option_name, "server_ssl") == 0)
-        return (void *)(&server->ssl);
-    if (ascii_strcasecmp (option_name, "server_password") == 0)
-        return (void *)(&server->password);
-    if (ascii_strcasecmp (option_name, "server_nick1") == 0)
-        return (void *)(&server->nick1);
-    if (ascii_strcasecmp (option_name, "server_nick2") == 0)
-        return (void *)(&server->nick2);
-    if (ascii_strcasecmp (option_name, "server_nick3") == 0)
-        return (void *)(&server->nick3);
-    if (ascii_strcasecmp (option_name, "server_username") == 0)
-        return (void *)(&server->username);
-    if (ascii_strcasecmp (option_name, "server_realname") == 0)
-        return (void *)(&server->realname);
-    if (ascii_strcasecmp (option_name, "server_hostname") == 0)
-        return (void *)(&server->hostname);
-    if (ascii_strcasecmp (option_name, "server_command") == 0)
-        return (void *)(&server->command);
-    if (ascii_strcasecmp (option_name, "server_command_delay") == 0)
-        return (void *)(&server->command_delay);
-    if (ascii_strcasecmp (option_name, "server_autojoin") == 0)
-        return (void *)(&server->autojoin);
-    if (ascii_strcasecmp (option_name, "server_autorejoin") == 0)
-        return (void *)(&server->autorejoin);
-    if (ascii_strcasecmp (option_name, "server_notify_levels") == 0)
-        return (void *)(&server->notify_levels);
-    /* option not found */
-    return NULL;
+    /* small hack is better than big one */
+    char *pptr = NULL;
+    switch (option->option_type)
+    {
+        case OPTION_TYPE_BOOLEAN:
+        case OPTION_TYPE_INT:
+        case OPTION_TYPE_INT_WITH_STRING:
+        case OPTION_TYPE_COLOR:
+            pptr = (char*)option->ptr_int;
+            break;
+        case OPTION_TYPE_STRING:
+            pptr = (char*)option->ptr_string;
+            break;
+    }
+    return (void*)( (char*)server + (pptr - (char*)&cfg_server) );
 }
 
 /*
@@ -1564,10 +1551,6 @@ config_set_server_value (t_irc_server *s
     void *ptr_data;
     int int_value;
     
-    ptr_data = config_get_server_option_ptr (server, option_name);
-    if (!ptr_data)
-        return -1;
-    
     ptr_option = NULL;
     for (i = 0; weechat_options[CONFIG_SECTION_SERVER][i].option_name; i++)
     {
@@ -1580,6 +1563,10 @@ config_set_server_value (t_irc_server *s
     }
     if (!ptr_option)
         return -1;
+
+    ptr_data = config_get_server_option_ptr (server, ptr_option);
+    if (!ptr_data)
+        return -1;
     
     switch (ptr_option->option_type)
     {
@@ -1620,6 +1607,10 @@ config_set_server_value (t_irc_server *s
             *((char **)ptr_data) = strdup (value);
             break;
     }
+
+    if (ptr_option->offsetof_isset > 0)
+        *(int*)((char*)server + ptr_option->offsetof_isset) = value[0] ? 1 : 0;
+   
     if (ptr_option->handler_change != NULL)
         (void) (ptr_option->handler_change());
     return 0;
@@ -1687,7 +1678,7 @@ config_option_search_option_value (char 
                                 pos + 1) == 0)
                     {
                         ptr_option = &weechat_options[CONFIG_SECTION_SERVER][i];
-                        ptr_value = config_get_server_option_ptr (ptr_server, pos + 1);
+                        ptr_value = config_get_server_option_ptr (ptr_server, ptr_option);
                         break;
                     }
                 }
@@ -1746,12 +1737,7 @@ config_allocate_server (char *filename, 
 {
     if (!cfg_server.name
         || !cfg_server.address
-        || cfg_server.port < 0
-        || !cfg_server.nick1
-        || !cfg_server.nick2
-        || !cfg_server.nick3
-        || !cfg_server.username
-        || !cfg_server.realname)
+        || cfg_server.port < 0)
     {
         server_free_all ();
         gui_printf (NULL,
@@ -1768,15 +1754,7 @@ config_allocate_server (char *filename, 
                     WEECHAT_WARNING, filename, line_number, cfg_server.name);
         return 0;
     }
-    if (!server_new (cfg_server.name,
-                     cfg_server.autoconnect, cfg_server.autoreconnect,
-                     cfg_server.autoreconnect_delay, 0, cfg_server.address,
-                     cfg_server.port, cfg_server.ipv6, cfg_server.ssl,
-                     cfg_server.password, cfg_server.nick1, cfg_server.nick2,
-                     cfg_server.nick3, cfg_server.username, cfg_server.realname,
-                     cfg_server.hostname, cfg_server.command,
-                     cfg_server.command_delay, cfg_server.autojoin,
-                     cfg_server.autorejoin, cfg_server.notify_levels))
+    if (!server_clone (&cfg_server))
     {
         server_free_all ();
         gui_printf (NULL,
@@ -1845,6 +1823,117 @@ config_default_values ()
 }
 
 /*
+ * returns dynamicly allocated nickname
+ */
+static char*
+get_default_nick()
+{
+    struct passwd *my_passwd;
+
+    if ((my_passwd = getpwuid(geteuid ())) != NULL)
+        return strdup(my_passwd->pw_name);
+    weechat_iconv_fprintf (stderr, "%s: %s (%s).",
+            WEECHAT_WARNING,
+            _("unable to get user's name"),
+            strerror(errno));
+    return strdup("weechat");
+}
+
+/*
+ * returns dynamicly allocated realname
+ */
+static char*
+get_default_realname() 
+{
+    struct passwd *my_passwd;
+    char *realname, *pos;
+
+    if ((my_passwd = getpwuid (geteuid ())) != NULL) {
+        if ((!my_passwd->pw_gecos)
+            || (my_passwd->pw_gecos[0] == '\0')
+            || (my_passwd->pw_gecos[0] == ',')
+            || (my_passwd->pw_gecos[0] == ' ')
+        ) {
+            return strdup(my_passwd->pw_name);
+        }
+        else
+        {
+            realname = strdup (my_passwd->pw_gecos);
+            pos = strchr (realname, ',');
+            if (pos)
+                pos[0] = '\0';
+            return realname;
+        }
+    }
+    else {
+        weechat_iconv_fprintf (stderr, "%s: %s (%s).",
+                WEECHAT_WARNING,
+                _("unable to get user's name"),
+                strerror(errno));
+        return strdup("WeeChat default realname");
+    }
+}
+
+/*
+ * initialize "server_defaults" section
+ */
+static void
+config_init_server_defaults() 
+{
+    t_config_option *p, *q, *new;
+    char *nickname, *realname;
+
+    if (weechat_options_server_defaults != NULL)
+        return; /* it's already initialized */
+
+    for (p = weechat_options_server; p->option_name; p++)
+        if (p->offsetof_isset > 0) /* we've found defaultable option! */
+            break;
+    if (!p->option_name )
+        return;
+    for (q = p; q->option_name; q++)
+        ; /* no-op */
+    q++;
+
+    new = calloc(q - p, sizeof(t_config_option));
+
+    /* nickname, realname will be stolen and will not be free()-d */
+    nickname = get_default_nick();
+    realname = get_default_realname();
+    
+    memcpy(new, p, (q - p) * sizeof(t_config_option));
+    for (p = new; p->option_name; p++) {
+        /* some sort of ugly hack */
+        if (p->ptr_string)
+            p->ptr_string = (char**)((unsigned long)p->ptr_string - (unsigned long)&cfg_server + (unsigned long)&server_defaults);
+        if (p->ptr_int)
+            p->ptr_int = (int*)((unsigned long)p->ptr_int - (unsigned long)&cfg_server + (unsigned long)&server_defaults);
+
+        p->handler_change = config_change_noop;
+
+        if (strcmp(p->option_name, "server_nick1") == 0)
+            p->default_string = nickname; /* stolen here */
+        else if (strcmp(p->option_name, "server_nick2") == 0) {
+            p->default_string = calloc(strlen(nickname) + 2, sizeof(char));
+            strcpy(p->default_string, nickname);
+            strcat(p->default_string, "1");
+        }
+        else if (strcmp(p->option_name, "server_nick3") == 0) {
+            p->default_string = calloc(strlen(nickname) + 2, sizeof(char));
+            strcpy(p->default_string, nickname);
+            strcat(p->default_string, "2");
+        }
+        else if (strcmp(p->option_name, "server_username") == 0)
+            p->default_string = strdup(nickname);
+        else if (strcmp(p->option_name, "server_realname") == 0)
+            p->default_string = realname; /* stolen here */
+    }
+
+    weechat_options_server_defaults = new;
+    weechat_options[CONFIG_SECTION_SERVER_DEFAULTS] = new;
+}
+
+/*
  * config_read: read WeeChat configuration
  *              returns:   0 = successful
  *                        -1 = config file file not found
@@ -1861,6 +1950,8 @@ config_read ()
     int server_found;
     char line[1024], *ptr_line, *ptr_line2, *pos, *pos2;
 
+    config_init_server_defaults();
+
     filename_length = strlen (weechat_home) + strlen (WEECHAT_CONFIG_NAME) + 2;
     filename = (char *) malloc (filename_length * sizeof (char));
     if (!filename)
@@ -1875,6 +1966,7 @@ config_read ()
         return -1;
     }
     
+    server_init (&server_defaults);
     config_default_values ();
     server_init (&cfg_server);
     
@@ -2125,7 +2217,7 @@ config_read ()
             return -2;
         }
     }
-    
+
     fclose (file);
     free (filename);
     
@@ -2147,8 +2239,6 @@ config_create_default ()
     FILE *file;
     int i, j;
     time_t current_time;
-    struct passwd *my_passwd;
-    char *realname, *pos;
     t_gui_key *ptr_key;
     char *expanded_name, *function_name;
 
@@ -2271,59 +2361,11 @@ config_create_default ()
     /* default server is freenode */
     weechat_iconv_fprintf (file, "\n[server]\n");
     weechat_iconv_fprintf (file, "server_name = \"freenode\"\n");
-    weechat_iconv_fprintf (file, "server_autoconnect = on\n");
-    weechat_iconv_fprintf (file, "server_autoreconnect = on\n");
-    weechat_iconv_fprintf (file, "server_autoreconnect_delay = 30\n");
     weechat_iconv_fprintf (file, "server_address = \"irc.freenode.net\"\n");
     weechat_iconv_fprintf (file, "server_port = 6667\n");
-    weechat_iconv_fprintf (file, "server_ipv6 = off\n");
-    weechat_iconv_fprintf (file, "server_ssl = off\n");
     weechat_iconv_fprintf (file, "server_password = \"\"\n");
-    
-    /* Get the user's name from /etc/passwd */
-    if ((my_passwd = getpwuid (geteuid ())) != NULL)
-    {
-        weechat_iconv_fprintf (file, "server_nick1 = \"%s\"\n", my_passwd->pw_name);
-        weechat_iconv_fprintf (file, "server_nick2 = \"%s1\"\n", my_passwd->pw_name);
-        weechat_iconv_fprintf (file, "server_nick3 = \"%s2\"\n", my_passwd->pw_name);
-        weechat_iconv_fprintf (file, "server_username = \"%s\"\n", my_passwd->pw_name);
-        if ((!my_passwd->pw_gecos)
-            || (my_passwd->pw_gecos[0] == '\0')
-            || (my_passwd->pw_gecos[0] == ',')
-            || (my_passwd->pw_gecos[0] == ' '))
-            weechat_iconv_fprintf (file, "server_realname = \"%s\"\n", my_passwd->pw_name);
-        else
-        {
-            realname = strdup (my_passwd->pw_gecos);
-            pos = strchr (realname, ',');
-            if (pos)
-                pos[0] = '\0';
-            weechat_iconv_fprintf (file, "server_realname = \"%s\"\n",
-                                   realname);
-            if (pos)
-                pos[0] = ',';
-            free (realname);
-        }
-    }
-    else
-    {
-        /* default values if /etc/passwd can't be read */
-        weechat_iconv_fprintf (stderr, "%s: %s (%s).",
-                               WEECHAT_WARNING,
-                               _("Unable to get user's name"),
-                               strerror (errno));
-        weechat_iconv_fprintf (file, "server_nick1 = \"weechat1\"\n");
-        weechat_iconv_fprintf (file, "server_nick2 = \"weechat2\"\n");
-        weechat_iconv_fprintf (file, "server_nick3 = \"weechat3\"\n");
-        weechat_iconv_fprintf (file, "server_username = \"weechat\"\n");
-        weechat_iconv_fprintf (file, "server_realname = \"WeeChat default realname\"\n");
-    }
-    
-    weechat_iconv_fprintf (file, "server_hostname = \"\"\n");
     weechat_iconv_fprintf (file, "server_command = \"\"\n");
-    weechat_iconv_fprintf (file, "server_command_delay = 0\n");
     weechat_iconv_fprintf (file, "server_autojoin = \"\"\n");
-    weechat_iconv_fprintf (file, "server_autorejoin = on\n");
     weechat_iconv_fprintf (file, "server_notify_levels = \"\"\n");
     
     fclose (file);
@@ -2486,34 +2528,47 @@ config_write (char *config_name)
         {
             weechat_iconv_fprintf (file, "\n[server]\n");
             weechat_iconv_fprintf (file, "server_name = \"%s\"\n", ptr_server->name);
-            weechat_iconv_fprintf (file, "server_autoconnect = %s\n",
-                                   (ptr_server->autoconnect) ? "on" : "off");
-            weechat_iconv_fprintf (file, "server_autoreconnect = %s\n",
-                                   (ptr_server->autoreconnect) ? "on" : "off");
-            weechat_iconv_fprintf (file, "server_autoreconnect_delay = %d\n",
-                                   ptr_server->autoreconnect_delay);
+            if (ptr_server->isset.autoconnect)
+                weechat_iconv_fprintf (file, "server_autoconnect = %s\n",
+                                       (ptr_server->setting.autoconnect) ? "on" : "off");
+            if (ptr_server->isset.autoreconnect)
+                weechat_iconv_fprintf (file, "server_autoreconnect = %s\n",
+                                       (ptr_server->setting.autoreconnect) ? "on" : "off");
+            if (ptr_server->isset.autoreconnect_delay)
+                weechat_iconv_fprintf (file, "server_autoreconnect_delay = %d\n",
+                                       ptr_server->setting.autoreconnect_delay);
             weechat_iconv_fprintf (file, "server_address = \"%s\"\n", ptr_server->address);
             weechat_iconv_fprintf (file, "server_port = %d\n", ptr_server->port);
-            weechat_iconv_fprintf (file, "server_ipv6 = %s\n",
-                                   (ptr_server->ipv6) ? "on" : "off");
-            weechat_iconv_fprintf (file, "server_ssl = %s\n",
-                                   (ptr_server->ssl) ? "on" : "off");
+            if (ptr_server->isset.ipv6)
+                weechat_iconv_fprintf (file, "server_ipv6 = %s\n",
+                                       (ptr_server->setting.ipv6) ? "on" : "off");
+            if (ptr_server->isset.ssl)
+                weechat_iconv_fprintf (file, "server_ssl = %s\n",
+                                       (ptr_server->setting.ssl) ? "on" : "off");
             weechat_iconv_fprintf (file, "server_password = \"%s\"\n",
                                    (ptr_server->password) ? ptr_server->password : "");
-            weechat_iconv_fprintf (file, "server_nick1 = \"%s\"\n", ptr_server->nick1);
-            weechat_iconv_fprintf (file, "server_nick2 = \"%s\"\n", ptr_server->nick2);
-            weechat_iconv_fprintf (file, "server_nick3 = \"%s\"\n", ptr_server->nick3);
-            weechat_iconv_fprintf (file, "server_username = \"%s\"\n", ptr_server->username);
-            weechat_iconv_fprintf (file, "server_realname = \"%s\"\n", ptr_server->realname);
-            weechat_iconv_fprintf (file, "server_hostname = \"%s\"\n",
-                                   (ptr_server->hostname) ? ptr_server->hostname : "");
+            if (ptr_server->isset.nick1)
+                weechat_iconv_fprintf (file, "server_nick1 = \"%s\"\n", ptr_server->setting.nick1);
+            if (ptr_server->isset.nick2)
+                weechat_iconv_fprintf (file, "server_nick2 = \"%s\"\n", ptr_server->setting.nick2);
+            if (ptr_server->isset.nick3)
+                weechat_iconv_fprintf (file, "server_nick3 = \"%s\"\n", ptr_server->setting.nick3);
+            if (ptr_server->isset.username)
+                weechat_iconv_fprintf (file, "server_username = \"%s\"\n", ptr_server->setting.username);
+            if (ptr_server->isset.realname)
+                weechat_iconv_fprintf (file, "server_realname = \"%s\"\n", ptr_server->setting.realname);
+            if (ptr_server->isset.hostname)
+                weechat_iconv_fprintf (file, "server_hostname = \"%s\"\n",
+                                       (ptr_server->setting.hostname) ? ptr_server->setting.hostname : "");
             weechat_iconv_fprintf (file, "server_command = \"%s\"\n",
                                    (ptr_server->command) ? ptr_server->command : "");
-            weechat_iconv_fprintf (file, "server_command_delay = %d\n", ptr_server->command_delay);
+            if (ptr_server->isset.command_delay)
+                weechat_iconv_fprintf (file, "server_command_delay = %d\n", ptr_server->setting.command_delay);
             weechat_iconv_fprintf (file, "server_autojoin = \"%s\"\n",
                                    (ptr_server->autojoin) ? ptr_server->autojoin : "");
-            weechat_iconv_fprintf (file, "server_autorejoin = %s\n",
-                                   (ptr_server->autorejoin) ? "on" : "off");
+            if (ptr_server->isset.autorejoin)
+                weechat_iconv_fprintf (file, "server_autorejoin = %s\n",
+                                       (ptr_server->setting.autorejoin) ? "on" : "off");
             weechat_iconv_fprintf (file, "server_notify_levels = \"%s\"\n",
                                    (ptr_server->notify_levels) ? ptr_server->notify_levels : "");
         }
Index: src/common/weeconfig.h
===================================================================
RCS file: /sources/weechat/weechat/src/common/weeconfig.h,v
retrieving revision 1.78
diff -u -d -p -B -r1.78 weeconfig.h
--- src/common/weeconfig.h	5 Jan 2007 23:41:39 -0000	1.78
+++ src/common/weeconfig.h	23 Mar 2007 11:17:01 -0000
@@ -25,20 +25,21 @@
 
 #define WEECHAT_CONFIG_NAME "weechat.rc"
 
-#define CONFIG_SECTION_NONE    -1
-#define CONFIG_SECTION_LOOK    0
-#define CONFIG_SECTION_COLORS  1
-#define CONFIG_SECTION_HISTORY 2
-#define CONFIG_SECTION_LOG     3
-#define CONFIG_SECTION_IRC     4
-#define CONFIG_SECTION_DCC     5
-#define CONFIG_SECTION_PROXY   6
-#define CONFIG_SECTION_PLUGINS 7
-#define CONFIG_SECTION_KEYS    8
-#define CONFIG_SECTION_ALIAS   9
-#define CONFIG_SECTION_IGNORE  10
-#define CONFIG_SECTION_SERVER  11
-#define CONFIG_NUMBER_SECTIONS 12
+#define CONFIG_SECTION_NONE            -1
+#define CONFIG_SECTION_LOOK            0
+#define CONFIG_SECTION_COLORS          1
+#define CONFIG_SECTION_HISTORY         2
+#define CONFIG_SECTION_LOG             3
+#define CONFIG_SECTION_IRC             4
+#define CONFIG_SECTION_DCC             5
+#define CONFIG_SECTION_PROXY           6
+#define CONFIG_SECTION_PLUGINS         7
+#define CONFIG_SECTION_KEYS            8
+#define CONFIG_SECTION_ALIAS           9
+#define CONFIG_SECTION_IGNORE          10
+#define CONFIG_SECTION_SERVER          11
+#define CONFIG_SECTION_SERVER_DEFAULTS 12
+#define CONFIG_NUMBER_SECTIONS         13
 
 #define OPTION_TYPE_BOOLEAN         1   /* values: on/off                   */
 #define OPTION_TYPE_INT             2   /* values: from min to max          */
@@ -84,6 +85,7 @@ struct t_config_option
     char **array_values;
     int *ptr_int;
     char **ptr_string;
+    ssize_t offsetof_isset;
     void (*handler_change)();
 };
 
@@ -230,7 +232,6 @@ extern int cfg_dcc_convert_spaces;
 extern int cfg_dcc_auto_rename;
 extern int cfg_dcc_auto_resume;
 
-extern int cfg_proxy_use;
 extern int cfg_proxy_type;
 extern char *cfg_proxy_type_values[];
 extern int cfg_proxy_ipv6;
@@ -268,7 +269,7 @@ extern void config_option_list_get_value
 extern t_config_option *config_option_search (char *);
 extern void config_option_search_option_value (char *, t_config_option **, void **);
 extern int config_set_value (char *, char *);
-extern void *config_get_server_option_ptr (t_irc_server *, char *);
+extern void *config_get_server_option_ptr (t_irc_server *, const t_config_option *);
 extern int config_set_server_value (t_irc_server *, char *, char *);
 extern int config_read ();
 extern int config_create_default ();
Index: src/gui/curses/gui-curses-input.c
===================================================================
RCS file: /sources/weechat/weechat/src/gui/curses/gui-curses-input.c,v
retrieving revision 1.12
diff -u -d -p -B -r1.12 gui-curses-input.c
--- src/gui/curses/gui-curses-input.c	20 Mar 2007 10:18:25 -0000	1.12
+++ src/gui/curses/gui-curses-input.c	23 Mar 2007 11:17:01 -0000
@@ -357,7 +357,7 @@ gui_input_draw (t_gui_buffer *buffer, in
                         
                         if (SERVER(buffer))
                             ptr_nickname = (SERVER(buffer)->nick) ?
-                                SERVER(buffer)->nick : SERVER(buffer)->nick1;
+                                SERVER(buffer)->nick : SERVER_GET(SERVER(buffer), nick1);
                         else
                             ptr_nickname = cfg_look_no_nickname;
                         
Index: src/gui/curses/gui-curses-main.c
===================================================================
RCS file: /sources/weechat/weechat/src/gui/curses/gui-curses-main.c,v
retrieving revision 1.11
diff -u -d -p -B -r1.11 gui-curses-main.c
--- src/gui/curses/gui-curses-main.c	5 Jan 2007 23:41:39 -0000	1.11
+++ src/gui/curses/gui-curses-main.c	23 Mar 2007 11:17:01 -0000
@@ -222,7 +222,7 @@ gui_main_loop ()
             /* check if reconnection is pending */
             if ((!ptr_server->is_connected)
                 && (ptr_server->reconnect_start > 0)
-                && (new_time >= (ptr_server->reconnect_start + ptr_server->autoreconnect_delay)))
+                && (new_time >= (ptr_server->reconnect_start + SERVER_GET(ptr_server, autoreconnect_delay))))
                 server_reconnect (ptr_server);
             else
             {
Index: src/irc/irc-dcc.c
===================================================================
RCS file: /sources/weechat/weechat/src/irc/irc-dcc.c,v
retrieving revision 1.57
diff -u -d -p -B -r1.57 irc-dcc.c
--- src/irc/irc-dcc.c	5 Jan 2007 23:41:38 -0000	1.57
+++ src/irc/irc-dcc.c	23 Mar 2007 11:17:02 -0000
@@ -288,7 +288,7 @@ dcc_connect_to_sender (t_irc_dcc *ptr_dc
     char *ip4;
     int ret;
     
-    if (cfg_proxy_use)
+    if (SERVER_GET(ptr_dcc->server, proxy_use))
     {
         memset (&addr, 0, sizeof (addr));
         addr.sin_addr.s_addr = htonl (ptr_dcc->addr);
@@ -303,7 +303,7 @@ dcc_connect_to_sender (t_irc_dcc *ptr_dc
         ret = connect (ptr_dcc->sock, (struct sockaddr *) &addr, sizeof (addr));
         if ((ret == -1) && (errno != EINPROGRESS))
             return 0;
-        if (pass_proxy (ptr_dcc->sock, ip4, ptr_dcc->port, ptr_dcc->server->username) == -1)
+        if (pass_proxy (ptr_dcc->sock, ip4, ptr_dcc->port, SERVER_GET(ptr_dcc->server, username)) == -1)
             return 0;
     }
     else
Index: src/irc/irc-display.c
===================================================================
RCS file: /sources/weechat/weechat/src/irc/irc-display.c,v
retrieving revision 1.44
diff -u -d -p -B -r1.44 irc-display.c
--- src/irc/irc-display.c	16 Mar 2007 08:40:11 -0000	1.44
+++ src/irc/irc-display.c	23 Mar 2007 11:17:02 -0000
@@ -385,40 +385,52 @@ irc_display_server (t_irc_server *server
                 _("connected") : _("not connected"),
                 GUI_COLOR(COLOR_WIN_CHAT_DARK));
     
-    gui_printf (NULL, "  server_autoconnect . . . . : %s%s\n",
-                (server->autoconnect) ? _("on") : _("off"),
+    gui_printf (NULL, "  server_autoconnect . . . . : %s%s%s\n",
+                SERVER_GET(server, autoconnect) ? _("on") : _("off"),
+                server->isset.autoconnect ? "" : _(" <default>"),
                 (server->command_line) ?
                 _(" (temporary server, will not be saved)") : "");
-    gui_printf (NULL, "  server_autoreconnect . . . : %s\n",
-                (server->autoreconnect) ? _("on") : _("off"));
-    gui_printf (NULL, "  server_autoreconnect_delay : %d %s\n",
-                server->autoreconnect_delay,
-                _("seconds"));
+    gui_printf (NULL, "  server_autoreconnect . . . : %s%s\n",
+                SERVER_GET(server, autoreconnect) ? _("on") : _("off"),
+                server->isset.autoreconnect ? "" : _(" <default>")
+                );
+    gui_printf (NULL, "  server_autoreconnect_delay : %d %s%s\n",
+                SERVER_GET(server, autoreconnect_delay),
+                _("seconds"),
+                server->isset.autoreconnect_delay ? "" : _(" <default>"));
     gui_printf (NULL, "  server_address . . . . . . : %s\n",
                 server->address);
     gui_printf (NULL, "  server_port  . . . . . . . : %d\n",
                 server->port);
-    gui_printf (NULL, "  server_ipv6  . . . . . . . : %s\n",
-                (server->ipv6) ? _("on") : _("off"));
-    gui_printf (NULL, "  server_ssl . . . . . . . . : %s\n",
-                (server->ssl) ? _("on") : _("off"));
+    gui_printf (NULL, "  server_ipv6  . . . . . . . : %s%s\n",
+                SERVER_GET(server, ipv6) ? _("on") : _("off"),
+                server->isset.ipv6 ? "" : _(" <default>"));
+    gui_printf (NULL, "  server_proxy_use . . . . . : %s%s\n",
+                SERVER_GET(server, proxy_use) ? _("on") : _("off"),
+                server->isset.proxy_use ? "" : _(" <default>"));
+    gui_printf (NULL, "  server_ssl . . . . . . . . : %s%s\n",
+                SERVER_GET(server, ssl) ? _("on") : _("off"),
+                server->isset.ssl ? "" : _(" <default>"));
     gui_printf (NULL, "  server_password  . . . . . : %s\n",
                 (server->password && server->password[0]) ?
                 _("(hidden)") : "");
-    gui_printf (NULL, "  server_nick1/2/3 . . . . . : %s %s/ %s%s %s/ %s%s\n",
-                server->nick1,
+    gui_printf (NULL, "  server_nick1/2/3 . . . . . : %s%s %s/ %s%s%s %s/ %s%s%s\n",
+                SERVER_GET(server, nick1), server->isset.nick1 ? "" : _(" <default>"),
                 GUI_COLOR(COLOR_WIN_CHAT_DARK),
                 GUI_COLOR(COLOR_WIN_CHAT),
-                server->nick2,
+                SERVER_GET(server, nick2), server->isset.nick2 ? "" : _(" <default>"),
                 GUI_COLOR(COLOR_WIN_CHAT_DARK),
                 GUI_COLOR(COLOR_WIN_CHAT),
-                server->nick3);
-    gui_printf (NULL, "  server_username  . . . . . : %s\n",
-                server->username);
-    gui_printf (NULL, "  server_realname  . . . . . : %s\n",
-                server->realname);
-    gui_printf (NULL, "  server_hostname  . . . . . : %s\n",
-                (server->hostname) ? server->hostname : "");
+                SERVER_GET(server, nick3), server->isset.nick3 ? "" : _(" <default>"));
+    gui_printf (NULL, "  server_username  . . . . . : %s%s\n",
+                SERVER_GET(server, username),
+                server->isset.username ? "" : _(" <default>"));
+    gui_printf (NULL, "  server_realname  . . . . . : %s%s\n",
+                SERVER_GET(server, realname), 
+                server->isset.realname ? "" : _(" <default>"));
+    gui_printf (NULL, "  server_hostname  . . . . . : %s%s\n",
+                SERVER_GET(server, hostname),
+                server->isset.hostname ? "" : _(" <default>"));
     if (server->command && server->command[0])
         string = strdup (server->command);
     else
@@ -435,9 +447,10 @@ irc_display_server (t_irc_server *server
         gui_printf (NULL, "  server_command . . . . . . : %s\n",
                     (server->command && server->command[0]) ?
                     server->command : "");
-    gui_printf (NULL, "  server_command_delay . . . : %d %s\n",
-                server->command_delay,
-                _("seconds"));
+    gui_printf (NULL, "  server_command_delay . . . : %d %s%s\n",
+                SERVER_GET(server, command_delay),
+                _("seconds"),
+                server->isset.command_delay ? "" : _(" <default>"));
     gui_printf (NULL, "  server_autojoin  . . . . . : %s\n",
                 (server->autojoin && server->autojoin[0]) ?
                 server->autojoin : "");
Index: src/irc/irc-recv.c
===================================================================
RCS file: /sources/weechat/weechat/src/irc/irc-recv.c,v
retrieving revision 1.159
diff -u -d -p -B -r1.159 irc-recv.c
--- src/irc/irc-recv.c	22 Mar 2007 13:26:50 -0000	1.159
+++ src/irc/irc-recv.c	23 Mar 2007 11:17:03 -0000
@@ -592,7 +592,7 @@ irc_cmd_recv_kick (t_irc_server *server,
         nick_free_all (ptr_channel);
         gui_nicklist_draw (ptr_channel->buffer, 1, 1);
         gui_status_draw (ptr_channel->buffer, 1);
-        if (server->autorejoin)
+        if (SERVER_GET(server, autorejoin))
             irc_cmd_send_join (server, NULL, ptr_channel->name);
     }
     {
@@ -2423,8 +2423,8 @@ irc_cmd_recv_001 (t_irc_server *server, 
 	    free_multi_command (commands);
 	}
 	
-	if (server->command_delay > 0)
-	    sleep (server->command_delay);
+	if (SERVER_GET(server, command_delay) > 0)
+	    sleep (SERVER_GET(server, command_delay));
     }
 	
     /* auto-join after disconnection (only rejoins opened channels) */
@@ -4781,31 +4781,31 @@ irc_cmd_recv_433 (t_irc_server *server, 
     
     if (!server->is_connected)
     {
-        if (strcmp (server->nick, server->nick1) == 0)
+        if (strcmp (server->nick, SERVER_GET(server, nick1)) == 0)
         {
             irc_display_prefix (server, server->buffer, PREFIX_INFO);
             gui_printf (server->buffer,
                         _("%s: nickname \"%s\" is already in use, "
                         "trying 2nd nickname \"%s\"\n"),
-                        PACKAGE_NAME, server->nick, server->nick2);
+                        PACKAGE_NAME, server->nick, SERVER_GET(server, nick2));
             free (server->nick);
-            server->nick = strdup (server->nick2);
+            server->nick = strdup (SERVER_GET(server, nick2));
         }
         else
         {
-            if (strcmp (server->nick, server->nick2) == 0)
+            if (strcmp (server->nick, SERVER_GET(server, nick2)) == 0)
             {
                 irc_display_prefix (server, server->buffer, PREFIX_INFO);
                 gui_printf (server->buffer,
                             _("%s: nickname \"%s\" is already in use, "
                             "trying 3rd nickname \"%s\"\n"),
-                            PACKAGE_NAME, server->nick, server->nick3);
+                            PACKAGE_NAME, server->nick, SERVER_GET(server, nick3));
                 free (server->nick);
-                server->nick = strdup (server->nick3);
+                server->nick = strdup (SERVER_GET(server, nick3));
             }
             else
             {
-                if (strcmp (server->nick, server->nick3) == 0)
+                if (strcmp (server->nick, SERVER_GET(server, nick3)) == 0)
                 {
                     irc_display_prefix (server, server->buffer, PREFIX_INFO);
                     gui_printf (server->buffer,
@@ -4821,9 +4821,9 @@ irc_cmd_recv_433 (t_irc_server *server, 
                     gui_printf (server->buffer,
                                 _("%s: nickname \"%s\" is already in use, "
                                 "trying 1st nickname \"%s\"\n"),
-                                PACKAGE_NAME, server->nick, server->nick1);
+                                PACKAGE_NAME, server->nick, SERVER_GET(server, nick1));
                     free (server->nick);
-                    server->nick = strdup (server->nick1);
+                    server->nick = strdup (SERVER_GET(server, nick1));
                 }
             }
         }
Index: src/irc/irc-send.c
===================================================================
RCS file: /sources/weechat/weechat/src/irc/irc-send.c,v
retrieving revision 1.96
diff -u -d -p -B -r1.96 irc-send.c
--- src/irc/irc-send.c	16 Mar 2007 08:40:11 -0000	1.96
+++ src/irc/irc-send.c	23 Mar 2007 11:17:04 -0000
@@ -118,12 +118,12 @@ irc_login (t_irc_server *server)
                 _("%s: using hostname \"%s\"\n"),
                 PACKAGE_NAME, hostname);
     if (!server->nick)
-        server->nick = strdup (server->nick1);
+        server->nick = strdup(SERVER_GET(server, nick1));
     server_sendf (server,
                   "NICK %s\n"
                   "USER %s %s %s :%s",
-                  server->nick, server->username, hostname, "servername",
-                  server->realname);
+                  server->nick, SERVER_GET(server, username), hostname, "servername",
+                  SERVER_GET(server, realname));
     gui_input_draw (gui_current_window->buffer, 1);
 }
 
Index: src/irc/irc-server.c
===================================================================
RCS file: /sources/weechat/weechat/src/irc/irc-server.c,v
retrieving revision 1.105
diff -u -d -p -B -r1.105 irc-server.c
--- src/irc/irc-server.c	16 Jan 2007 14:54:38 -0000	1.105
+++ src/irc/irc-server.c	23 Mar 2007 11:17:05 -0000
@@ -74,26 +74,15 @@ server_init (t_irc_server *server)
 {
     /* user choices */
     server->name = NULL;
-    server->autoconnect = 0;
-    server->autoreconnect = 1;
-    server->autoreconnect_delay = 30;
     server->command_line = 0;
     server->address = NULL;
     server->port = -1;
-    server->ipv6 = 0;
-    server->ssl = 0;
     server->password = NULL;
-    server->nick1 = NULL;
-    server->nick2 = NULL;
-    server->nick3 = NULL;
-    server->username = NULL;
-    server->realname = NULL;
-    server->hostname = NULL;
     server->command = NULL;
-    server->command_delay = 1;
     server->autojoin = NULL;
-    server->autorejoin = 0;
     server->notify_levels = NULL;
+    memset(&server->setting, 0, sizeof(server->setting));
+    memset(&server->isset, 0, sizeof(server->isset));
     
     /* internal vars */
     server->child_pid = 0;
@@ -183,12 +172,12 @@ server_init_with_url (char *irc_url, t_i
             pos2[0] = '\0';
             server->password = strdup (pos2 + 1);
         }
-        server->nick1 = strdup (url);
+        SERVER_SET(server, nick1, strdup(url));
     }
     else
     {
         if ((my_passwd = getpwuid (geteuid ())) != NULL)
-            server->nick1 = strdup (my_passwd->pw_name);
+            SERVER_SET(server, nick1, strdup(my_passwd->pw_name));
         else
         {
             weechat_iconv_fprintf (stderr, "%s: %s (%s).",
@@ -233,18 +222,12 @@ server_init_with_url (char *irc_url, t_i
     
     free (url);
     
-    server->ipv6 = ipv6;
-    server->ssl = ssl;
+    SERVER_SET(server, ipv6, ipv6);
+    SERVER_SET(server, ssl, ssl);
 
     /* some default values */
     if (server->port < 0)
         server->port = DEFAULT_IRC_PORT;
-    server->nick2 = (char *) malloc (strlen (server->nick1) + 2);
-    strcpy (server->nick2, server->nick1);
-    server->nick2 = strcat (server->nick2, "1");
-    server->nick3 = (char *) malloc (strlen (server->nick1) + 2);
-    strcpy (server->nick3, server->nick1);
-    server->nick3 = strcat (server->nick3, "2");
     
     return 0;
 }
@@ -368,18 +351,18 @@ server_destroy (t_irc_server *server)
         free (server->address);
     if (server->password)
         free (server->password);
-    if (server->nick1)
-        free (server->nick1);
-    if (server->nick2)
-        free (server->nick2);
-    if (server->nick3)
-        free (server->nick3);
-    if (server->username)
-        free (server->username);
-    if (server->realname)
-        free (server->realname);
-    if (server->hostname)
-        free (server->hostname);
+    if (server->setting.nick1)
+        free (server->setting.nick1);
+    if (server->setting.nick2)
+        free (server->setting.nick2);
+    if (server->setting.nick3)
+        free (server->setting.nick3);
+    if (server->setting.username)
+        free (server->setting.username);
+    if (server->setting.realname)
+        free (server->setting.realname);
+    if (server->setting.hostname)
+        free (server->setting.hostname);
     if (server->command)
         free (server->command);
     if (server->autojoin)
@@ -448,9 +431,46 @@ server_free_all ()
 }
 
 /*
+ * server_clone: creates a new server, like exising one
+ */
+t_irc_server *
+server_clone(const t_irc_server *orig)
+{
+    t_irc_server *new_server;
+    
+    if ((new_server = server_alloc ()))
+    {
+        new_server->name = strdup(orig->name);
+        new_server->address = strdup(orig->address);
+        new_server->port = orig->port;
+        new_server->password = (orig->password) ? strdup(orig->password) : strdup("");
+        new_server->command = (orig->command) ? strdup(orig->command) : NULL;
+        new_server->autojoin = (orig->autojoin) ? strdup(orig->autojoin) : NULL;
+        new_server->notify_levels = (orig->notify_levels) ? strdup(orig->notify_levels) : NULL;
+        memcpy(&new_server->isset, &orig->isset, sizeof(orig->isset));
+        memcpy(&new_server->setting, &orig->setting, sizeof(orig->setting));
+#define STRDUP_IF_ISSET(setting_) \
+        if (new_server->isset.setting_ && new_server->setting.setting_) \
+            new_server->setting.setting_ = strdup(new_server->setting.setting_);
+        STRDUP_IF_ISSET(nick1);
+        STRDUP_IF_ISSET(nick2);
+        STRDUP_IF_ISSET(nick3);
+        STRDUP_IF_ISSET(username);
+        STRDUP_IF_ISSET(realname);
+        STRDUP_IF_ISSET(hostname);
+#undef STRDUP_IF_ISSET
+    }
+    else
+        return NULL;
+    return new_server;
+}
+
+
+/*
  * server_new: creates a new server, and initialize it
  */
 
+#if 0
 t_irc_server *
 server_new (char *name, int autoconnect, int autoreconnect,
             int autoreconnect_delay, int command_line, char *address,
@@ -480,30 +500,25 @@ server_new (char *name, int autoconnect,
     if ((new_server = server_alloc ()))
     {
         new_server->name = strdup (name);
-        new_server->autoconnect = autoconnect;
-        new_server->autoreconnect = autoreconnect;
-        new_server->autoreconnect_delay = autoreconnect_delay;
+        SERVER_SET(new_server, autoconnect, autoconnect);
+        SERVER_SET(new_server, autoreconnect, autoreconnect);
+        SERVER_SET(new_server, autoreconnect_delay, autoreconnect_delay);
         new_server->command_line = command_line;
         new_server->address = strdup (address);
         new_server->port = port;
-        new_server->ipv6 = ipv6;
-        new_server->ssl = ssl;
+        SERVER_SET(new_server, ipv6, ipv6);
+        SERVER_SET(new_server, ssl, ssl);
         new_server->password = (password) ? strdup (password) : strdup ("");
-        new_server->nick1 = (nick1) ? strdup (nick1) : strdup ("weechat_user");
-        new_server->nick2 = (nick2) ? strdup (nick2) : strdup ("weechat2");
-        new_server->nick3 = (nick3) ? strdup (nick3) : strdup ("weechat3");
-        new_server->username =
-            (username) ? strdup (username) : strdup ("weechat");
-        new_server->realname =
-            (realname) ? strdup (realname) : strdup ("realname");
-        new_server->hostname =
-            (hostname) ? strdup (hostname) : NULL;
-        new_server->command =
-            (command) ? strdup (command) : NULL;
-        new_server->command_delay = command_delay;
-        new_server->autojoin =
-            (autojoin) ? strdup (autojoin) : NULL;
-        new_server->autorejoin = autorejoin;
+        SERVER_SET(new_server, nick1, (nick1) ? strdup (nick1) : strdup ("weechat_user"));
+        SERVER_SET(new_server, nick2, (nick2) ? strdup (nick2) : strdup ("weechat2"));
+        SERVER_SET(new_server, nick3, (nick3) ? strdup (nick3) : strdup ("weechat3"));
+        SERVER_SET(new_server, username, (username) ? strdup (username) : strdup ("weechat"));
+        SERVER_SET(new_server, realname, (realname) ? strdup (realname) : strdup ("realname"));
+        SERVER_SET(new_server, hostname, (hostname) ? strdup (hostname) : NULL);
+        new_server->command = (command) ? strdup (command) : NULL;
+        SERVER_SET(new_server, command_delay, command_delay);
+        new_server->autojoin = (autojoin) ? strdup (autojoin) : NULL;
+        SERVER_SET(new_server, autorejoin, autorejoin);
         new_server->notify_levels =
             (notify_levels) ? strdup (notify_levels) : NULL;
     }
@@ -511,6 +526,7 @@ server_new (char *name, int autoconnect,
         return NULL;
     return new_server;
 }
+#endif
 
 /*
  * server_send: send data to IRC server
@@ -1122,12 +1138,12 @@ server_close_connection (t_irc_server *s
 void
 server_reconnect_schedule (t_irc_server *server)
 {
-    if (server->autoreconnect)
+    if (SERVER_GET(server, autoreconnect))
     {
         server->reconnect_start = time (NULL);
         irc_display_prefix (server, server->buffer, PREFIX_INFO);
         gui_printf (server->buffer, _("%s: Reconnecting to server in %d seconds\n"),
-                    PACKAGE_NAME, server->autoreconnect_delay);
+                    PACKAGE_NAME, SERVER_GET(server, autoreconnect_delay));
     }
     else
         server->reconnect_start = 0;
@@ -1175,7 +1191,7 @@ server_child_read (t_irc_server *server)
             /* adress not found */
             case '1':
                 irc_display_prefix (server, server->buffer, PREFIX_ERROR);
-                if (cfg_proxy_use)
+                if (SERVER_GET(server, proxy_use))
                     gui_printf (server->buffer,
                                 _("%s proxy address \"%s\" not found\n"),
                                 WEECHAT_ERROR, server->address);
@@ -1189,7 +1205,7 @@ server_child_read (t_irc_server *server)
             /* IP address not found */
             case '2':
                 irc_display_prefix (server, server->buffer, PREFIX_ERROR);
-                if (cfg_proxy_use)
+                if (SERVER_GET(server, proxy_use))
                     gui_printf (server->buffer,
                                 _("%s proxy IP address not found\n"), WEECHAT_ERROR);
                 else
@@ -1201,7 +1217,7 @@ server_child_read (t_irc_server *server)
             /* connection refused */
             case '3':
                 irc_display_prefix (server, server->buffer, PREFIX_ERROR);
-                if (cfg_proxy_use)
+                if (SERVER_GET(server, proxy_use))
                     gui_printf (server->buffer,
                                 _("%s proxy connection refused\n"), WEECHAT_ERROR);
                 else
@@ -1602,7 +1618,7 @@ server_child (t_irc_server *server)
     res = NULL;
     res_local = NULL;
     
-    if (cfg_proxy_use)
+    if (SERVER_GET(server, proxy_use))
     {
         /* get info about server */
         memset (&hints, 0, sizeof (hints));
@@ -1639,7 +1655,7 @@ server_child (t_irc_server *server)
             return 0;
         }
         
-        if (pass_proxy(server->sock, server->address, server->port, server->username))
+        if (pass_proxy(server->sock, server->address, server->port, SERVER_GET(server, username)))
         {
             write(server->child_write, "4", 1);
             freeaddrinfo (res);
@@ -1649,15 +1665,15 @@ server_child (t_irc_server *server)
     else
     {
         /* set local hostname/IP if asked by user */
-        if (server->hostname && server->hostname[0])
+        if (SERVER_GET(server, hostname) && SERVER_GET(server, hostname)[0])
         {
             memset (&hints, 0, sizeof(hints));
-            hints.ai_family = (server->ipv6) ? AF_INET6 : AF_INET;
+            hints.ai_family = SERVER_GET(server, ipv6) ? AF_INET6 : AF_INET;
             hints.ai_socktype = SOCK_STREAM;
-            rc = getaddrinfo (server->hostname, NULL, &hints, &res_local);
+            rc = getaddrinfo (SERVER_GET(server, hostname), NULL, &hints, &res_local);
             if ((rc != 0) || !res_local
-                || (server->ipv6 && (res_local->ai_family != AF_INET6))
-                || ((!server->ipv6 && (res_local->ai_family != AF_INET))))
+                || (SERVER_GET(server, ipv6) && (res_local->ai_family != AF_INET6))
+                || ((!SERVER_GET(server, ipv6) && (res_local->ai_family != AF_INET))))
             {
                 write (server->child_write, "5", 1);
                 if (res_local)
@@ -1675,7 +1691,7 @@ server_child (t_irc_server *server)
         
         /* get info about server */
         memset (&hints, 0, sizeof(hints));
-        hints.ai_family = (server->ipv6) ? AF_INET6 : AF_INET;
+        hints.ai_family = SERVER_GET(server, ipv6) ? AF_INET6 : AF_INET;
         hints.ai_socktype = SOCK_STREAM;
         rc = getaddrinfo (server->address, NULL, &hints, &res);
         if ((rc != 0) || !res)
@@ -1685,8 +1701,8 @@ server_child (t_irc_server *server)
                 freeaddrinfo (res);
             return 0;
         }
-        if ((server->ipv6 && (res->ai_family != AF_INET6))
-            || ((!server->ipv6 && (res->ai_family != AF_INET))))
+        if ((SERVER_GET(server, ipv6) && (res->ai_family != AF_INET6))
+            || ((!SERVER_GET(server, ipv6) && (res->ai_family != AF_INET))))
         {
             write (server->child_write, "2", 1);
             if (res)
@@ -1697,7 +1713,7 @@ server_child (t_irc_server *server)
         }
         
         /* connect to server */
-        if (server->ipv6)
+        if (SERVER_GET(server, ipv6))
             ((struct sockaddr_in6 *)(res->ai_addr))->sin6_port = htons (server->port);
         else
             ((struct sockaddr_in *)(res->ai_addr))->sin_port = htons (server->port);
@@ -1745,19 +1761,19 @@ server_connect (t_irc_server *server)
     }
 #endif
     irc_display_prefix (server, server->buffer, PREFIX_INFO);
-    if (cfg_proxy_use)
+    if (SERVER_GET(server, proxy_use))
       {
           gui_printf (server->buffer,
                       _("%s: connecting to server %s:%d%s%s via %s proxy %s:%d%s...\n"),
                       PACKAGE_NAME, server->address, server->port,
-                      (server->ipv6) ? " (IPv6)" : "",
-                      (server->ssl) ? " (SSL)" : "",
+                      SERVER_GET(server, ipv6) ? " (IPv6)" : "",
+                      SERVER_GET(server, ssl) ? " (SSL)" : "",
                       cfg_proxy_type_values[cfg_proxy_type], cfg_proxy_address, cfg_proxy_port,
                       (cfg_proxy_ipv6) ? " (IPv6)" : "");
           weechat_log_printf (_("Connecting to server %s:%d%s%s via %s proxy %s:%d%s...\n"),
                             server->address, server->port,
-                            (server->ipv6) ? " (IPv6)" : "",
-                            (server->ssl) ? " (SSL)" : "",
+                            SERVER_GET(server, ipv6) ? " (IPv6)" : "",
+                            SERVER_GET(server, ssl) ? " (SSL)" : "",
                             cfg_proxy_type_values[cfg_proxy_type], cfg_proxy_address, cfg_proxy_port,
                             (cfg_proxy_ipv6) ? " (IPv6)" : "");
       }
@@ -1766,12 +1782,12 @@ server_connect (t_irc_server *server)
           gui_printf (server->buffer,
                       _("%s: connecting to server %s:%d%s%s...\n"),
                       PACKAGE_NAME, server->address, server->port,
-                      (server->ipv6) ? " (IPv6)" : "",
-                      (server->ssl) ? " (SSL)" : "");
+                      SERVER_GET(server, ipv6) ? " (IPv6)" : "",
+                      SERVER_GET(server, ssl) ? " (SSL)" : "");
           weechat_log_printf (_("Connecting to server %s:%d%s%s...\n"),
                             server->address, server->port,
-                            (server->ipv6) ? " (IPv6)" : "",
-                            (server->ssl) ? " (SSL)" : "");
+                            SERVER_GET(server, ipv6) ? " (IPv6)" : "",
+                            SERVER_GET(server, ssl) ? " (SSL)" : "");
       }
     
     /* close any opened connection and kill child process if running */
@@ -1780,7 +1796,7 @@ server_connect (t_irc_server *server)
     /* init SSL if asked */
     server->ssl_connected = 0;
 #ifdef HAVE_GNUTLS
-    if (server->ssl)
+    if (SERVER_GET(server, ssl))
     {
         if (gnutls_init (&server->gnutls_sess, GNUTLS_CLIENT) != 0)
         {
@@ -1808,10 +1824,10 @@ server_connect (t_irc_server *server)
     server->child_write = child_pipe[1];
     
     /* create socket and set options */
-    if (cfg_proxy_use)
+    if (SERVER_GET(server, proxy_use))
       server->sock = socket ((cfg_proxy_ipv6) ? AF_INET6 : AF_INET, SOCK_STREAM, 0);
     else
-      server->sock = socket ((server->ipv6) ? AF_INET6 : AF_INET, SOCK_STREAM, 0);
+      server->sock = socket (SERVER_GET(server, ipv6) ? AF_INET6 : AF_INET, SOCK_STREAM, 0);
     if (server->sock == -1)
     {
         irc_display_prefix (server, server->buffer, PREFIX_ERROR);
@@ -1892,7 +1908,7 @@ server_auto_connect (int auto_connect, i
          ptr_server = ptr_server->next_server)
     {
         if ( ((command_line) && (ptr_server->command_line))
-            || ((!command_line) && (auto_connect) && (ptr_server->autoconnect)) )
+            || ((!command_line) && (auto_connect) && SERVER_GET(ptr_server, autoconnect)) )
         {
             (void) gui_buffer_new (gui_current_window, ptr_server, NULL,
                                    BUFFER_TYPE_STANDARD, 1);
@@ -1946,7 +1962,7 @@ server_disconnect (t_irc_server *server,
     server->lag_check_time.tv_usec = 0;
     server->lag_next_check = time (NULL) + cfg_irc_lag_check;
     
-    if ((reconnect) && (server->autoreconnect))
+    if ((reconnect) && SERVER_GET(server, autoreconnect))
         server_reconnect_schedule (server);
     else
         server->reconnect_start = 0;
@@ -2173,28 +2189,28 @@ void
 server_print_log (t_irc_server *server)
 {
     weechat_log_printf ("[server %s (addr:0x%X)]\n",      server->name, server);
-    weechat_log_printf ("  autoconnect . . . . : %d\n",   server->autoconnect);
-    weechat_log_printf ("  autoreconnect . . . : %d\n",   server->autoreconnect);
-    weechat_log_printf ("  autoreconnect_delay : %d\n",   server->autoreconnect_delay);
+    weechat_log_printf ("  autoconnect . . . . : %d\n",   SERVER_GET(server, autoconnect));
+    weechat_log_printf ("  autoreconnect . . . : %d\n",   SERVER_GET(server, autoreconnect));
+    weechat_log_printf ("  autoreconnect_delay : %d\n",   SERVER_GET(server, autoreconnect_delay));
     weechat_log_printf ("  command_line. . . . : %d\n",   server->command_line);
     weechat_log_printf ("  address . . . . . . : '%s'\n", server->address);
     weechat_log_printf ("  port. . . . . . . . : %d\n",   server->port);
-    weechat_log_printf ("  ipv6. . . . . . . . : %d\n",   server->ipv6);
-    weechat_log_printf ("  ssl . . . . . . . . : %d\n",   server->ssl);
+    weechat_log_printf ("  ipv6. . . . . . . . : %d\n",   SERVER_GET(server, ipv6));
+    weechat_log_printf ("  ssl . . . . . . . . : %d\n",   SERVER_GET(server, ssl));
     weechat_log_printf ("  password. . . . . . : '%s'\n",
                         (server->password && server->password[0]) ?
                         "(hidden)" : server->password);
-    weechat_log_printf ("  nick1 . . . . . . . : '%s'\n", server->nick1);
-    weechat_log_printf ("  nick2 . . . . . . . : '%s'\n", server->nick2);
-    weechat_log_printf ("  nick3 . . . . . . . : '%s'\n", server->nick3);
-    weechat_log_printf ("  username. . . . . . : '%s'\n", server->username);
-    weechat_log_printf ("  realname. . . . . . : '%s'\n", server->realname);
+    weechat_log_printf ("  nick1 . . . . . . . : '%s'\n", SERVER_GET(server, nick1));
+    weechat_log_printf ("  nick2 . . . . . . . : '%s'\n", SERVER_GET(server, nick2));
+    weechat_log_printf ("  nick3 . . . . . . . : '%s'\n", SERVER_GET(server, nick3));
+    weechat_log_printf ("  username. . . . . . : '%s'\n", SERVER_GET(server, username));
+    weechat_log_printf ("  realname. . . . . . : '%s'\n", SERVER_GET(server, realname));
     weechat_log_printf ("  command . . . . . . : '%s'\n",
                         (server->command && server->command[0]) ?
                         "(hidden)" : server->command);
-    weechat_log_printf ("  command_delay . . . : %d\n",   server->command_delay);
+    weechat_log_printf ("  command_delay . . . : %d\n",   SERVER_GET(server, command_delay));
     weechat_log_printf ("  autojoin. . . . . . : '%s'\n", server->autojoin);
-    weechat_log_printf ("  autorejoin. . . . . : %d\n",   server->autorejoin);
+    weechat_log_printf ("  autorejoin. . . . . : %d\n",   SERVER_GET(server, autorejoin));
     weechat_log_printf ("  notify_levels . . . : %s\n",   server->notify_levels);
     weechat_log_printf ("  child_pid . . . . . : %d\n",   server->child_pid);
     weechat_log_printf ("  child_read  . . . . : %d\n",   server->child_read);
Index: src/irc/irc.h
===================================================================
RCS file: /sources/weechat/weechat/src/irc/irc.h,v
retrieving revision 1.121
diff -u -d -p -B -r1.121 irc.h
--- src/irc/irc.h	16 Mar 2007 08:40:11 -0000	1.121
+++ src/irc/irc.h	23 Mar 2007 11:17:05 -0000
@@ -136,32 +136,64 @@ struct t_irc_outqueue
     t_irc_outqueue *prev_outqueue;  /* pointer to previous message in queue   */
 };
 
+#define SERVER_GET(pserv_, setting_) \
+    ((pserv_)->isset.setting_ ? (pserv_)->setting.setting_ : server_defaults.setting.setting_)
+#define SERVER_SET(pserv_, setting_, value_) \
+    do { (pserv_)->isset.setting_ = 1; (pserv_)->setting.setting_ = (value_); } while(0)
+#define SERVER_UNSET(pserv_, setting_) \
+    do { (pserv_)->isset.setting_ = 0; memset(&(pserv_)->isset.setting_, 0, sizeof((pserv_)->isset.setting_)); } while(0)
+
+extern struct t_irc_server server_defaults;
+
 typedef struct t_irc_server t_irc_server;
 
 struct t_irc_server
 {
     /* user choices */
     char *name;                     /* name of server (only for display)      */
-    int autoconnect;                /* = 1 if auto connect at startup         */
-    int autoreconnect;              /* = 1 if auto reco when disconnected     */
-    int autoreconnect_delay;        /* delay before trying again reconnect    */
     int command_line;               /* server was given on command line       */
     char *address;                  /* address of server (IP or name)         */
     int port;                       /* port for server (6667 by default)      */
-    int ipv6;                       /* use IPv6 protocol                      */
-    int ssl;                        /* SSL protocol                           */
     char *password;                 /* password for server                    */
-    char *nick1;                    /* first nickname for the server          */
-    char *nick2;                    /* alternate nickname                     */
-    char *nick3;                    /* 2nd alternate nickname                 */
-    char *username;                 /* user name                              */
-    char *realname;                 /* real name                              */
-    char *hostname;                 /* custom hostname                        */
     char *command;                  /* command to run once connected          */
-    int command_delay;              /* delay after execution of command       */
     char *autojoin;                 /* channels to automatically join         */
-    int autorejoin;                 /* auto rejoin channels when kicked       */
     char *notify_levels;            /* channels notify levels                 */
+    struct {
+        // server->autoreconnect = 1;
+        // server->autoreconnect_delay = 30;
+        // server->command_delay = 1;
+        // server->autorejoin = 1
+        int autoconnect;            /* = 1 if auto connect at startup         */
+        int autoreconnect;          /* = 1 if auto reco when disconnected     */
+        int autoreconnect_delay;    /* delay before trying again reconnect    */
+        int ipv6;                   /* use IPv6 protocol                      */
+        int ssl;                    /* SSL protocol                           */
+        char *nick1;                /* first nickname for the server          */
+        char *nick2;                /* alternate nickname                     */
+        char *nick3;                /* 2nd alternate nickname                 */
+        char *username;             /* user name                              */
+        char *realname;             /* real name                              */
+        char *hostname;             /* custom hostname                        */
+        int command_delay;          /* delay after execution of command       */
+        int autorejoin;             /* auto rejoin channels when kicked       */
+        int proxy_use;
+    } setting;
+    struct {
+        int autoconnect;
+        int autoreconnect;
+        int autoreconnect_delay;
+        int ipv6;
+        int ssl;
+        int nick1;
+        int nick2;
+        int nick3;
+        int username;
+        int realname;
+        int hostname;
+        int command_delay;
+        int autorejoin;
+        int proxy_use;
+    } isset;
     
     /* internal vars */
     pid_t child_pid;                /* pid of child process (connecting)      */
@@ -359,6 +391,7 @@ extern void server_outqueue_free_all (t_
 extern void server_destroy (t_irc_server *);
 extern void server_free (t_irc_server *);
 extern void server_free_all ();
+extern t_irc_server *server_clone (const t_irc_server *);
 extern t_irc_server *server_new (char *, int, int, int, int, char *, int, int, int,
                                  char *, char *, char *, char *, char *, char *,
                                  char *, char *, int, char *, int, char *);
Index: src/plugins/plugins-interface.c
===================================================================
RCS file: /sources/weechat/weechat/src/plugins/plugins-interface.c,v
retrieving revision 1.45
diff -u -d -p -B -r1.45 plugins-interface.c
--- src/plugins/plugins-interface.c	28 Feb 2007 22:59:47 -0000	1.45
+++ src/plugins/plugins-interface.c	23 Mar 2007 11:17:06 -0000
@@ -785,7 +785,7 @@ weechat_plugin_get_config (t_weechat_plu
                  && (ascii_strcasecmp (option_name, option) == 0)))
             {
                 ptr_option_value = config_get_server_option_ptr (ptr_server,
-                                                                 weechat_options[CONFIG_SECTION_SERVER][i].option_name);
+                                                                 &weechat_options[CONFIG_SECTION_SERVER][i]);
                 if (ptr_option_value)
                 {
                     return weechat_plugin_get_config_str_value (&weechat_options[CONFIG_SECTION_SERVER][i],
@@ -914,24 +914,24 @@ weechat_plugin_get_server_info (t_weecha
 	    if (new_server_info)
 	    {
 		new_server_info->name = (ptr_server->name) ? strdup (ptr_server->name) : strdup ("");
-		new_server_info->autoconnect = ptr_server->autoconnect;
-		new_server_info->autoreconnect = ptr_server->autoreconnect;
-		new_server_info->autoreconnect_delay = ptr_server->autoreconnect_delay;
+		new_server_info->autoconnect = ptr_server->setting.autoconnect;
+		new_server_info->autoreconnect = ptr_server->setting.autoreconnect;
+		new_server_info->autoreconnect_delay = ptr_server->setting.autoreconnect_delay;
 		new_server_info->command_line = ptr_server->command_line;
 		new_server_info->address = (ptr_server->address) ? strdup (ptr_server->address) : strdup ("");
 		new_server_info->port = ptr_server->port;
-		new_server_info->ipv6 = ptr_server->ipv6;
-		new_server_info->ssl = ptr_server->ssl;		
+		new_server_info->ipv6 = ptr_server->setting.ipv6;
+		new_server_info->ssl = ptr_server->setting.ssl;		
 		new_server_info->password = (ptr_server->password) ? strdup (ptr_server->password) : strdup ("");
-		new_server_info->nick1 = (ptr_server->nick1) ? strdup (ptr_server->nick1) : strdup ("");
-		new_server_info->nick2 = (ptr_server->nick2) ? strdup (ptr_server->nick2) : strdup ("");
-		new_server_info->nick3 = (ptr_server->nick3) ? strdup (ptr_server->nick3) : strdup ("");
-		new_server_info->username = (ptr_server->username) ? strdup (ptr_server->username) : strdup ("");
-		new_server_info->realname = (ptr_server->realname) ? strdup (ptr_server->realname) : strdup ("");
+		new_server_info->nick1 = (ptr_server->setting.nick1) ? strdup (ptr_server->setting.nick1) : strdup ("");
+		new_server_info->nick2 = (ptr_server->setting.nick2) ? strdup (ptr_server->setting.nick2) : strdup ("");
+		new_server_info->nick3 = (ptr_server->setting.nick3) ? strdup (ptr_server->setting.nick3) : strdup ("");
+		new_server_info->username = (ptr_server->setting.username) ? strdup (ptr_server->setting.username) : strdup ("");
+		new_server_info->realname = (ptr_server->setting.realname) ? strdup (ptr_server->setting.realname) : strdup ("");
 		new_server_info->command = (ptr_server->command) ? strdup (ptr_server->command) : strdup ("");
-		new_server_info->command_delay = ptr_server->command_delay;
+		new_server_info->command_delay = ptr_server->setting.command_delay;
 		new_server_info->autojoin = (ptr_server->autojoin) ? strdup (ptr_server->autojoin) : strdup ("");
-		new_server_info->autorejoin = ptr_server->autorejoin;
+		new_server_info->autorejoin = ptr_server->setting.autorejoin;
 		new_server_info->notify_levels = (ptr_server->notify_levels) ? strdup (ptr_server->notify_levels) : strdup ("");
 		new_server_info->is_connected = ptr_server->is_connected;
 		new_server_info->ssl_connected = ptr_server->ssl_connected;
