summaryrefslogtreecommitdiff
path: root/src/core/wee-config.c
blob: 191df3be540aa1eed52d7d0fb398b54c5af213dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
/*
 * Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
 * See README for License detail, AUTHORS for developers list.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/* wee-config.c: WeeChat configuration options */


#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>

#include "weechat.h"
#include "wee-config.h"
#include "wee-config-file.h"
#include "wee-log.h"
#include "wee-util.h"
#include "wee-list.h"
#include "../gui/gui-chat.h"
#include "../gui/gui-color.h"
#include "../gui/gui-hotlist.h"
#include "../gui/gui-keyboard.h"
#include "../gui/gui-status.h"
#include "../gui/gui-window.h"


struct t_config_file *weechat_config_file = NULL;

/* config, look & feel section */

struct t_config_option *config_look_color_real_white;
struct t_config_option *config_look_save_on_exit;
struct t_config_option *config_look_set_title;
struct t_config_option *config_look_startup_logo;
struct t_config_option *config_look_startup_version;
struct t_config_option *config_look_weechat_slogan;
struct t_config_option *config_look_scroll_amount;
struct t_config_option *config_look_buffer_time_format;
struct t_config_option *config_look_color_nicks_number;
struct t_config_option *config_look_nicklist;
struct t_config_option *config_look_nicklist_position;
struct t_config_option *config_look_nicklist_min_size;
struct t_config_option *config_look_nicklist_max_size;
struct t_config_option *config_look_nicklist_separator;
struct t_config_option *config_look_nickmode;
struct t_config_option *config_look_nickmode_empty;
struct t_config_option *config_look_no_nickname;
struct t_config_option *config_look_prefix[GUI_CHAT_PREFIX_NUMBER];
struct t_config_option *config_look_prefix_align;
struct t_config_option *config_look_prefix_align_max;
struct t_config_option *config_look_prefix_suffix;
struct t_config_option *config_look_nick_completor;
struct t_config_option *config_look_nick_completion_ignore;
struct t_config_option *config_look_nick_completion_smart;
struct t_config_option *config_look_nick_complete_first;
struct t_config_option *config_look_infobar;
struct t_config_option *config_look_infobar_time_format;
struct t_config_option *config_look_infobar_seconds;
struct t_config_option *config_look_infobar_delay_highlight;
struct t_config_option *config_look_hotlist_names_count;
struct t_config_option *config_look_hotlist_names_level;
struct t_config_option *config_look_hotlist_names_length;
struct t_config_option *config_look_hotlist_sort;
struct t_config_option *config_look_day_change;
struct t_config_option *config_look_day_change_time_format;
struct t_config_option *config_look_read_marker;
struct t_config_option *config_look_input_format;
struct t_config_option *config_look_paste_max_lines;
struct t_config_option *config_look_default_msg_quit;

/* config, colors section */

struct t_config_option *config_color_separator;
struct t_config_option *config_color_title;
struct t_config_option *config_color_title_bg;
struct t_config_option *config_color_title_more;
struct t_config_option *config_color_chat;
struct t_config_option *config_color_chat_bg;
struct t_config_option *config_color_chat_time;
struct t_config_option *config_color_chat_time_delimiters;
struct t_config_option *config_color_chat_prefix[GUI_CHAT_PREFIX_NUMBER];
struct t_config_option *config_color_chat_prefix_more;
struct t_config_option *config_color_chat_prefix_suffix;
struct t_config_option *config_color_chat_buffer;
struct t_config_option *config_color_chat_server;
struct t_config_option *config_color_chat_channel;
struct t_config_option *config_color_chat_nick;
struct t_config_option *config_color_chat_nick_self;
struct t_config_option *config_color_chat_nick_other;
struct t_config_option *config_color_chat_nick_colors[GUI_COLOR_NICK_NUMBER];
struct t_config_option *config_color_chat_host;
struct t_config_option *config_color_chat_delimiters;
struct t_config_option *config_color_chat_highlight;
struct t_config_option *config_color_chat_read_marker;
struct t_config_option *config_color_chat_read_marker_bg;
struct t_config_option *config_color_status;
struct t_config_option *config_color_status_bg;
struct t_config_option *config_color_status_delimiters;
struct t_config_option *config_color_status_channel;
struct t_config_option *config_color_status_data_msg;
struct t_config_option *config_color_status_data_private;
struct t_config_option *config_color_status_data_highlight;
struct t_config_option *config_color_status_data_other;
struct t_config_option *config_color_status_more;
struct t_config_option *config_color_infobar;
struct t_config_option *config_color_infobar_bg;
struct t_config_option *config_color_infobar_delimiters;
struct t_config_option *config_color_infobar_highlight;
struct t_config_option *config_color_infobar_bg;
struct t_config_option *config_color_input;
struct t_config_option *config_color_input_bg;
struct t_config_option *config_color_input_server;
struct t_config_option *config_color_input_channel;
struct t_config_option *config_color_input_nick;
struct t_config_option *config_color_input_delimiters;
struct t_config_option *config_color_input_text_not_found;
struct t_config_option *config_color_input_actions;
struct t_config_option *config_color_nicklist;
struct t_config_option *config_color_nicklist_bg;
struct t_config_option *config_color_nicklist_away;
struct t_config_option *config_color_nicklist_prefix1;
struct t_config_option *config_color_nicklist_prefix2;
struct t_config_option *config_color_nicklist_prefix3;
struct t_config_option *config_color_nicklist_prefix4;
struct t_config_option *config_color_nicklist_prefix5;
struct t_config_option *config_color_nicklist_more;
struct t_config_option *config_color_nicklist_separator;
struct t_config_option *config_color_info;
struct t_config_option *config_color_info_bg;
struct t_config_option *config_color_info_waiting;
struct t_config_option *config_color_info_connecting;
struct t_config_option *config_color_info_active;
struct t_config_option *config_color_info_done;
struct t_config_option *config_color_info_failed;
struct t_config_option *config_color_info_aborted;

/* config, history section */

struct t_config_option *config_history_max_lines;
struct t_config_option *config_history_max_commands;
struct t_config_option *config_history_display_default;

/* config, proxy section */

struct t_config_option *config_proxy_use;
struct t_config_option *config_proxy_type;
struct t_config_option *config_proxy_ipv6;
struct t_config_option *config_proxy_address;
struct t_config_option *config_proxy_port;
struct t_config_option *config_proxy_username;
struct t_config_option *config_proxy_password;

/* config, plugins section */

struct t_config_option *config_plugins_path;
struct t_config_option *config_plugins_autoload;
struct t_config_option *config_plugins_extension;


/*
 * config_change_save_on_exit: called when "save_on_exit" flag is changed
 */

void
config_change_save_on_exit ()
{
    if (!config_look_save_on_exit)
    {
        gui_chat_printf (NULL, "\n");
        gui_chat_printf (NULL,
                         _("Warning: you should now issue /save to write "
                           "\"save_on_exit\" option in configuration file.\n"));
    }
}

/*
 * config_change_title: called when title is changed
 */

void
config_change_title ()
{
    if (config_look_set_title)
	gui_window_title_set ();
    else
	gui_window_title_reset ();
}

/*
 * config_change_buffers: called when buffers change (for example nicklist)
 */

void
config_change_buffers ()
{
    gui_window_refresh_windows ();
}

/*
 * config_change_buffer_content: called when content of a buffer changes
 */

void
config_change_buffer_content ()
{
    gui_window_redraw_buffer (gui_current_window->buffer);
}

/*
 * config_change_buffer_time_format: called when buffer time format changes
 */

void
config_change_buffer_time_format ()
{
    gui_chat_time_length = util_get_time_length (CONFIG_STRING(config_look_buffer_time_format));
    gui_chat_change_time_format ();
    gui_window_redraw_buffer (gui_current_window->buffer);
}

/*
 * config_change_hotlist: called when hotlist changes
 */

void
config_change_hotlist ()
{
    gui_hotlist_resort ();
    gui_status_draw (gui_current_window->buffer, 1);
}

/*
 * config_change_read_marker: called when read marker is changed
 */

void
config_change_read_marker ()
{
    gui_window_redraw_all_buffers ();
}

/*
 * config_change_prefix: called when a prefix is changed
 */

void
config_change_prefix ()
{
    int i;
    
    for (i = 0; i < GUI_CHAT_PREFIX_NUMBER; i++)
    {
        if (gui_chat_prefix[i])
            free (gui_chat_prefix[i]);
    }
    gui_chat_prefix_build ();
}

/*
 * config_change_color: called when a color is changed by /set command
 */

void
config_change_color ()
{
    if (gui_ok)
    {
        gui_color_init_pairs ();
        gui_color_rebuild_weechat ();
        gui_window_refresh_windows ();
    }
}

/*
 * config_change_nicks_colors: called when number of nicks color changed
 */

void
config_change_nicks_colors ()
{
    struct t_gui_buffer *ptr_buffer;
    struct t_gui_nick *ptr_nick;

    for (ptr_buffer = gui_buffers; ptr_buffer;
         ptr_buffer = ptr_buffer->next_buffer)
    {
        if (ptr_buffer->nicks)
        {
            for (ptr_nick = ptr_buffer->nicks; ptr_nick;
                 ptr_nick = ptr_nick->next_nick)
            {
                //gui_nick_find_color (ptr_nick);
            }   
        }
    }
}

/*
 * config_weechat_read_key: read a key in configuration file
 */

void
config_weechat_read_key (void *config_file,
                         char *option_name, char *value)
{
    /* make C compiler happy */
    (void) config_file;
    
    if (option_name)
    {
        if (value && value[0])
        {
            /* bind key (overwrite any binding with same key) */
            gui_keyboard_bind (option_name, value);
        }
        else
        {
            /* unbin key if no value given */
            gui_keyboard_unbind (option_name);
        }
    }
}

/*
 * config_weechat_write_keys: write alias section in configuration file
 *                            Return:  0 = successful
 *                                    -1 = write error
 */

void
config_weechat_write_keys (void *config_file, char *section_name)
{
    t_gui_key *ptr_key;
    char *expanded_name, *function_name;
    
    config_file_write_line (config_file, section_name, NULL);
    
    for (ptr_key = gui_keys; ptr_key; ptr_key = ptr_key->next_key)
    {
        expanded_name = gui_keyboard_get_expanded_name (ptr_key->key);
        if (ptr_key->function)
        {
            function_name = gui_keyboard_function_search_by_ptr (ptr_key->function);
            if (function_name)
            {
                config_file_write_line (config_file,
                                        (expanded_name) ?
                                        expanded_name : ptr_key->key,
                                        "\"%s%s%s\"",
                                        function_name,
                                        (ptr_key->args) ? " " : "",
                                        (ptr_key->args) ? ptr_key->args : "");
            }
        }
        else
        {
            config_file_write_line (config_file,
                                    (expanded_name) ?
                                    expanded_name : ptr_key->key,
                                    "\"%s\"",
                                    ptr_key->command);
        }
        if (expanded_name)
            free (expanded_name);
    }
}

/*
 * config_weechat_init: init WeeChat config structure
 *                      return: 1 if ok, 0 if error
 */

int
config_weechat_init ()
{
    struct t_config_section *ptr_section;
    
    weechat_config_file = config_file_new (NULL, WEECHAT_CONFIG_FILENAME);
    if (!weechat_config_file)
        return 0;
    
    /* look */
    ptr_section = config_file_new_section (weechat_config_file, "look",
                                           NULL, NULL, NULL);
    if (!ptr_section)
    {
        config_file_free (weechat_config_file);
        return 0;
    }
    
    config_look_color_real_white = config_file_new_option (
        ptr_section, "look_color_real_white", "boolean",
        N_("if set, uses real white color, disabled by default "
           "for terms with white background (if you never use "
           "white background, you should turn on this option to "
           "see real white instead of default term foreground "
           "color)"),
        NULL, 0, 0, "off", &config_change_color);
    config_look_save_on_exit = config_file_new_option (
        ptr_section, "look_save_on_exit", "boolean",
        N_("save configuration file on exit"),
        NULL, 0, 0, "on", &config_change_save_on_exit);
    config_look_set_title = config_file_new_option (
        ptr_section, "look_set_title", "boolean",
        N_("set title for window (terminal for Curses GUI) with "
           "name and version"),
        NULL, 0, 0, "on", &config_change_title);
    config_look_startup_logo = config_file_new_option (
        ptr_section, "look_startup_logo", "boolean",
        N_("display WeeChat logo at startup"),
        NULL, 0, 0, "on", NULL);
    config_look_startup_version = config_file_new_option (
        ptr_section, "look_startup_version", "boolean",
        N_("display WeeChat version at startup"),
        NULL, 0, 0, "on", NULL);
    config_look_weechat_slogan = config_file_new_option (
        ptr_section, "look_weechat_slogan", "string",
        N_("WeeChat slogan (if empty, slogan is not used)"),
        NULL, 0, 0, "the geekest IRC client!", NULL);
    config_look_scroll_amount = config_file_new_option (
        ptr_section, "look_scroll_amount", "integer",
        N_("how many lines to scroll by with scroll_up and "
           "scroll_down"),
        NULL, 1, INT_MAX, "3", &config_change_buffer_content);
    config_look_buffer_time_format = config_file_new_option (
        ptr_section, "look_buffer_time_format", "string",
        N_("time format for buffers"),
        NULL, 0, 0, "[%H:%M:%S]", &config_change_buffer_time_format);
    config_look_color_nicks_number = config_file_new_option (
        ptr_section, "look_color_nicks_number", "integer",
        N_("number of colors to use for nicks colors"),
        NULL, 1, 10, "10", &config_change_nicks_colors);
    config_look_nicklist = config_file_new_option (
        ptr_section, "look_nicklist", "boolean",
        N_("display nicklist (on buffers with nicklist enabled"),
        NULL, 0, 0, "on", &config_change_buffers);
    config_look_nicklist_position = config_file_new_option (
        ptr_section, "look_nicklist_position", "integer",
        N_("nicklist position (top, left, right (default), "
           "bottom)"),
        "left|right|top|bottom", 0, 0, "right", &config_change_buffers);
    config_look_nicklist_min_size = config_file_new_option (
        ptr_section, "look_nicklist_min_size", "integer",
        N_("min size for nicklist (width or height, depending on "
           "look_nicklist_position "),
        NULL, 0, 100, "0", &config_change_buffers);
    config_look_nicklist_max_size = config_file_new_option (
        ptr_section, "look_nicklist_max_size", "integer",
        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))"),
        NULL, 0, 100, "0", &config_change_buffers);
    config_look_nicklist_separator = config_file_new_option (
        ptr_section, "look_nicklist_separator", "boolean",
        N_("separator between chat and nicklist"),
        NULL, 0, 0, "on", &config_change_buffers);
    config_look_nickmode = config_file_new_option (
        ptr_section, "look_nickmode", "boolean",
        N_("display nick mode ((half)op/voice) before each nick"),
        NULL, 0, 0, "on", &config_change_buffers);
    config_look_nickmode_empty = config_file_new_option (
        ptr_section, "look_nickmode_empty", "boolean",
        N_("display space if nick mode is not (half)op/voice"),
        NULL, 0, 0, "off", &config_change_buffers);
    config_look_prefix[GUI_CHAT_PREFIX_INFO] = config_file_new_option (
        ptr_section, "look_prefix_info", "string",
        N_("prefix for info messages"),
        NULL, 0, 0, "-=-", &config_change_prefix);
    config_look_prefix[GUI_CHAT_PREFIX_ERROR] = config_file_new_option (
        ptr_section, "look_prefix_error", "string",
        N_("prefix for error messages"),
        NULL, 0, 0, "=!=", &config_change_prefix);
    config_look_prefix[GUI_CHAT_PREFIX_NETWORK] = config_file_new_option (
        ptr_section, "look_prefix_network", "string",
        N_("prefix for network messages"),
        NULL, 0, 0, "-@-", &config_change_prefix);
    config_look_prefix[GUI_CHAT_PREFIX_ACTION] = config_file_new_option (
        ptr_section, "look_prefix_action", "string",
        N_("prefix for action messages"),
        NULL, 0, 0, "-*-", &config_change_prefix);
    config_look_prefix[GUI_CHAT_PREFIX_JOIN] = config_file_new_option (
        ptr_section, "look_prefix_join", "string",
        N_("prefix for join messages"),
        NULL, 0, 0, "-->", &config_change_prefix);
    config_look_prefix[GUI_CHAT_PREFIX_QUIT] = config_file_new_option (
        ptr_section, "look_prefix_quit", "string",
        N_("prefix for quit messages"),
        NULL, 0, 0, "<--", &config_change_prefix);
    config_look_prefix_align = config_file_new_option (
        ptr_section, "look_prefix_align", "integer",
        N_("prefix alignment (none, left, right (default))"),
        "none|left|right", 0, 0, "right", &config_change_buffers);
    config_look_prefix_align_max = config_file_new_option (
        ptr_section, "look_prefix_align_max", "integer",
        N_("max size for prefix (0 = no max size)"),
        NULL, 0, 64, "0", &config_change_buffers);
    config_look_prefix_suffix = config_file_new_option (
        ptr_section, "look_prefix_suffix", "string",
        N_("string displayed after prefix"),
        NULL, 0, 0, "|", &config_change_buffers);
    config_look_nick_completor = config_file_new_option (
        ptr_section, "look_nick_completor", "string",
        N_("the string inserted after nick completion"),
        NULL, 0, 0, ":", NULL);
    config_look_nick_completion_ignore = config_file_new_option (
        ptr_section, "look_nick_completion_ignore", "string",
        N_("chars ignored for nick completion"),
        NULL, 0, 0, "[]-^", NULL);
    config_look_nick_completion_smart = config_file_new_option (
        ptr_section, "look_nick_completion_smart", "boolean",
        N_("smart completion for nicks (completes with last speakers first)"),
        NULL, 0, 0, "on", NULL);
    config_look_nick_complete_first = config_file_new_option (
        ptr_section, "look_nick_complete_first", "boolean",
        N_("complete only with first nick found"),
        NULL, 0, 0, "off", NULL);
    config_look_infobar = config_file_new_option (
        ptr_section, "look_infobar", "boolean",
        N_("enable info bar"),
        NULL, 0, 0, "on", &config_change_buffers);
    config_look_infobar_time_format = config_file_new_option (
        ptr_section, "look_infobar_time_format", "string",
        N_("time format for time in infobar"),
        NULL, 0, 0, "%B, %A %d %Y", &config_change_buffer_content);
    config_look_infobar_seconds = config_file_new_option (
        ptr_section, "look_infobar_seconds", "boolean",
        N_("display seconds in infobar time"),
        NULL, 0, 0, "on", &config_change_buffer_content);
    config_look_infobar_delay_highlight = config_file_new_option (
        ptr_section, "look_infobar_delay_highlight", "integer",
        N_("delay (in seconds) for highlight messages in "
           "infobar (0 = disable highlight notifications in "
           "infobar)"),
        NULL, 0, INT_MAX, "7", NULL);
    config_look_hotlist_names_count = config_file_new_option (
        ptr_section, "look_hotlist_names_count", "integer",
        N_("max number of names in hotlist (0 = no name "
           "displayed, only buffer numbers)"),
        NULL, 0, 32, "3", &config_change_buffer_content);
    config_look_hotlist_names_level = config_file_new_option (
        ptr_section, "look_hotlist_names_level", "integer",
        N_("level for displaying names in hotlist (combination "
           "of: 1=join/part, 2=message, 4=private, 8=highlight, "
           "for example: 12=private+highlight)"),
        NULL, 1, 15, "12", &config_change_buffer_content);
    config_look_hotlist_names_length = config_file_new_option (
        ptr_section, "look_hotlist_names_length", "integer",
        N_("max length of names in hotlist (0 = no limit)"),
        NULL, 0, 32, "0", &config_change_buffer_content);
    config_look_hotlist_sort = config_file_new_option (
        ptr_section, "look_hotlist_sort", "integer",
        N_("hotlist sort type (group_time_asc (default), "
           "group_time_desc, group_number_asc, group_number_desc, "
           "number_asc, number_desc)"),
        "group_time_asc|group_time_desc|group_number_asc|"
        "group_number_desc|number_asc|number_desc",
        0, 0, "group_time_asc", &config_change_hotlist);
    config_look_day_change = config_file_new_option (
        ptr_section, "look_day_change", "boolean",
        N_("display special message when day changes"),
        NULL, 0, 0, "on", NULL);
    config_look_day_change_time_format = config_file_new_option (
        ptr_section, "look_day_change_time_format", "string",
        N_("time format for date displayed when day changed"),
        NULL, 0, 0, "%a, %d %b %Y", NULL);
    config_look_read_marker = config_file_new_option (
        ptr_section, "look_read_marker", "string",
        N_("use a marker on servers/channels to show first unread "
           "line"),
        NULL, 0, 1, " ", &config_change_read_marker);
    config_look_input_format = config_file_new_option (
        ptr_section, "look_input_format", "string",
        N_("format for input prompt ('%c' is replaced by channel "
           "or server, '%n' by nick and '%m' by nick modes)"),
        NULL, 0, 0, "[%n(%m)] ", &config_change_buffer_content);
    config_look_paste_max_lines = config_file_new_option (
        ptr_section, "look_paste_max_lines", "integer",
        N_("max number of lines for paste without asking user "
           "(0 = disable this feature)"),
        NULL, 0, INT_MAX, "3", NULL);
    config_look_default_msg_quit = config_file_new_option (
        ptr_section, "look_default_msg_quit", "string",
        N_("default quit message ('%v' will be replaced by WeeChat version in "
           "string)"),
        NULL, 0, 0, "WeeChat %v", NULL);
    
    /* colors */
    ptr_section = config_file_new_section (weechat_config_file, "colors",
                                           NULL, NULL, NULL);
    if (!ptr_section)
    {
        config_file_free (weechat_config_file);
        return 0;
    }
    
    /* general color settings */
    config_color_separator = config_file_new_option (
        ptr_section, "color_separator", "color",
        N_("color for window separators (when splited)"),
        NULL, GUI_COLOR_SEPARATOR, 0, "blue", &config_change_color);
    /* title window */
    config_color_title = config_file_new_option (
        ptr_section, "color_title", "color",
        N_("color for title bar"),
        NULL, GUI_COLOR_TITLE, 0, "default", &config_change_color);
    config_color_title_bg = config_file_new_option (
        ptr_section, "color_title_bg", "color",
        N_("background color for title bar"),
        NULL, -1, 0, "blue", &config_change_color);
    config_color_title_more = config_file_new_option (
        ptr_section, "color_title_more", "color",
        N_("color for '+' when scrolling title"),
        NULL, GUI_COLOR_TITLE_MORE, 0, "lightmagenta", &config_change_color);
    /* chat window */
    config_color_chat = config_file_new_option (
        ptr_section, "color_chat", "color",
        N_("color for chat text"),
        NULL, GUI_COLOR_CHAT, 0, "default", &config_change_color);
    config_color_chat_bg = config_file_new_option (
        ptr_section, "color_chat_bg", "color",
        N_("background for chat text"),
        NULL, -1, 0, "default", &config_change_color);
    config_color_chat_time = config_file_new_option (
        ptr_section, "color_chat_time", "color",
        N_("color for time in chat window"),
        NULL, GUI_COLOR_CHAT_TIME, 0, "default", &config_change_color);
    config_color_chat_time_delimiters = config_file_new_option (
        ptr_section, "color_chat_time_delimiters", "color",
        N_("color for time delimiters)"),
        NULL, GUI_COLOR_CHAT_TIME_DELIMITERS, 0, "brown", &config_change_color);
    config_color_chat_prefix[GUI_CHAT_PREFIX_INFO] = config_file_new_option (
        ptr_section, "color_chat_prefix_info", "color",
        N_("color for info prefix"),
        NULL, GUI_COLOR_CHAT_PREFIX_INFO, 0, "lightcyan", &config_change_color);
    config_color_chat_prefix[GUI_CHAT_PREFIX_ERROR] = config_file_new_option (
        ptr_section, "color_chat_prefix_error", "color",
        N_("color for error prefix"),
        NULL, GUI_COLOR_CHAT_PREFIX_ERROR, 0, "yellow", &config_change_color);
    config_color_chat_prefix[GUI_CHAT_PREFIX_NETWORK] = config_file_new_option (
        ptr_section, "color_chat_prefix_network", "color",
        N_("color for network prefix"),
        NULL, GUI_COLOR_CHAT_PREFIX_NETWORK, 0, "lightmagenta", &config_change_color);
    config_color_chat_prefix[GUI_CHAT_PREFIX_ACTION] = config_file_new_option (
        ptr_section, "color_chat_prefix_action", "color",
        N_("color for action prefix"),
        NULL, GUI_COLOR_CHAT_PREFIX_ACTION, 0, "white", &config_change_color);
    config_color_chat_prefix[GUI_CHAT_PREFIX_JOIN] = config_file_new_option (
        ptr_section, "color_chat_prefix_join", "color",
        N_("color for join prefix"),
        NULL, GUI_COLOR_CHAT_PREFIX_JOIN, 0, "lightgreen", &config_change_color);
    config_color_chat_prefix[GUI_CHAT_PREFIX_QUIT] = config_file_new_option (
        ptr_section, "color_chat_prefix_quit", "color",
        N_("color for quit prefix"),
        NULL, GUI_COLOR_CHAT_PREFIX_QUIT, 0, "lightred", &config_change_color);
    config_color_chat_prefix_more = config_file_new_option (
        ptr_section, "color_chat_prefix_more", "color",
        N_("color for '+' when prefix is too long"),
        NULL, GUI_COLOR_CHAT_PREFIX_MORE, 0, "lightmagenta", &config_change_color);
    config_color_chat_prefix_suffix = config_file_new_option (
        ptr_section, "color_chat_prefix_suffix", "color",
        N_("color for text after prefix"),
        NULL, GUI_COLOR_CHAT_PREFIX_SUFFIX, 0, "green", &config_change_color);
    config_color_chat_buffer = config_file_new_option (
        ptr_section, "color_chat_buffer", "color",
        N_("color for buffer names"),
        NULL, GUI_COLOR_CHAT_BUFFER, 0, "white", &config_change_color);
    config_color_chat_server = config_file_new_option (
        ptr_section, "color_chat_server", "color",
        N_("color for server names"),
        NULL, GUI_COLOR_CHAT_SERVER, 0, "brown", &config_change_color);
    config_color_chat_channel = config_file_new_option (
        ptr_section, "color_chat_channel", "color",
        N_("color for channel names"),
        NULL, GUI_COLOR_CHAT_CHANNEL, 0, "white", &config_change_color);
    config_color_chat_nick = config_file_new_option (
        ptr_section, "color_chat_nick", "color",
        N_("color for nicks"),
        NULL, GUI_COLOR_CHAT_NICK, 0, "lightcyan", &config_change_color);
    config_color_chat_nick_self = config_file_new_option (
        ptr_section, "color_chat_nick_self", "color",
        N_("color for local nick"),
        NULL, GUI_COLOR_CHAT_NICK_SELF, 0, "white", &config_change_color);
    config_color_chat_nick_other = config_file_new_option (
        ptr_section, "color_chat_nick_other", "color",
        N_("color for other nick in private buffer"),
        NULL, GUI_COLOR_CHAT_NICK_OTHER, 0, "default", &config_change_color);
    config_color_chat_nick_colors[0] = config_file_new_option (
        ptr_section, "color_chat_nick_color1", "color",
        N_("color #1 for nick"),
        NULL, GUI_COLOR_CHAT_NICK1, 0, "cyan", &config_change_color);
    config_color_chat_nick_colors[1] = config_file_new_option (
        ptr_section, "color_chat_nick_color2", "color",
        N_("color #2 for nick"),
        NULL, GUI_COLOR_CHAT_NICK2, 0, "magenta", &config_change_color);
    config_color_chat_nick_colors[2] = config_file_new_option (
        ptr_section, "color_chat_nick_color3", "color",
        N_("color #3 for nick"),
        NULL, GUI_COLOR_CHAT_NICK3, 0, "green", &config_change_color);
    config_color_chat_nick_colors[3] = config_file_new_option (
        ptr_section, "color_chat_nick_color4", "color",
        N_("color #4 for nick"),
        NULL, GUI_COLOR_CHAT_NICK4, 0, "brown", &config_change_color);
    config_color_chat_nick_colors[4] = config_file_new_option (
        ptr_section, "color_chat_nick_color5", "color",
        N_("color #5 for nick"),
        NULL, GUI_COLOR_CHAT_NICK5, 0, "lightblue", &config_change_color);
    config_color_chat_nick_colors[5] = config_file_new_option (
        ptr_section, "color_chat_nick_color6", "color",
        N_("color #6 for nick"),
        NULL, GUI_COLOR_CHAT_NICK6, 0, "default", &config_change_color);
    config_color_chat_nick_colors[6] = config_file_new_option (
        ptr_section, "color_chat_nick_color7", "color",
        N_("color #7 for nick"),
        NULL, GUI_COLOR_CHAT_NICK7, 0, "lightcyan", &config_change_color);
    config_color_chat_nick_colors[7] = config_file_new_option (
        ptr_section, "color_chat_nick_color8", "color",
        N_("color #8 for nick"),
        NULL, GUI_COLOR_CHAT_NICK8, 0, "lightmagenta", &config_change_color);
    config_color_chat_nick_colors[8] = config_file_new_option (
        ptr_section, "color_chat_nick_color9", "color",
        N_("color #9 for nick"),
        NULL, GUI_COLOR_CHAT_NICK9, 0, "lightgreen", &config_change_color);
    config_color_chat_nick_colors[9] = config_file_new_option (
        ptr_section, "color_chat_nick_color10", "color",
        N_("color #10 for nick"),
        NULL, GUI_COLOR_CHAT_NICK10, 0, "blue", &config_change_color);
    config_color_chat_host = config_file_new_option (
        ptr_section, "color_chat_host", "color",
        N_("color for hostnames"),
        NULL, GUI_COLOR_CHAT_HOST, 0, "cyan", &config_change_color);
    config_color_chat_delimiters = config_file_new_option (
        ptr_section, "color_chat_delimiters", "color",
        N_("color for delimiters"),
        NULL, GUI_COLOR_CHAT_DELIMITERS, 0, "green", &config_change_color);
    config_color_chat_highlight = config_file_new_option (
        ptr_section, "color_chat_highlight", "color",
        N_("color for highlighted nick"),
        NULL, GUI_COLOR_CHAT_HIGHLIGHT, 0, "yellow", &config_change_color);
    config_color_chat_read_marker = config_file_new_option (
        ptr_section, "color_chat_read_marker", "color",
        N_("color for unread data marker"),
        NULL, GUI_COLOR_CHAT_READ_MARKER, 0, "yellow", &config_change_color);
    config_color_chat_read_marker_bg = config_file_new_option (
        ptr_section, "color_chat_read_marker_bg", "color",
        N_("background color for unread data marker"),
        NULL, -1, 0, "magenta", &config_change_color);
    /* status window */
    config_color_status = config_file_new_option (
        ptr_section, "color_status", "color",
        N_("color for status bar"),
        NULL, GUI_COLOR_STATUS, 0, "default", &config_change_color);
    config_color_status_bg = config_file_new_option (
        ptr_section, "color_status_bg", "color",
        N_("background color for status bar"),
        NULL, -1, 0, "blue", &config_change_color);
    config_color_status_delimiters = config_file_new_option (
        ptr_section, "color_status_delimiters", "color",
        N_("color for status bar delimiters"),
        NULL, GUI_COLOR_STATUS_DELIMITERS, 0, "cyan", &config_change_color);
    config_color_status_channel = config_file_new_option (
        ptr_section, "color_status_channel", "color",
        N_("color for current channel in status bar"),
        NULL, GUI_COLOR_STATUS_CHANNEL, 0, "white", &config_change_color);
    config_color_status_data_msg = config_file_new_option (
        ptr_section, "color_status_data_msg", "color",
        N_("color for window with new messages (status bar)"),
        NULL, GUI_COLOR_STATUS_DATA_MSG, 0, "yellow", &config_change_color);
    config_color_status_data_private = config_file_new_option (
        ptr_section, "color_status_data_private", "color",
        N_("color for window with private message (status bar)"),
        NULL, GUI_COLOR_STATUS_DATA_PRIVATE, 0, "lightgreen", &config_change_color);
    config_color_status_data_highlight = config_file_new_option (
        ptr_section, "color_status_data_highlight", "color",
        N_("color for window with highlight (status bar)"),
        NULL, GUI_COLOR_STATUS_DATA_HIGHLIGHT, 0, "lightmagenta", &config_change_color);
    config_color_status_data_other = config_file_new_option (
        ptr_section, "color_status_data_other", "color",
        N_("color for window with new data (not messages) "
           "(status bar)"),
        NULL, GUI_COLOR_STATUS_DATA_OTHER, 0, "default", &config_change_color);
    config_color_status_more = config_file_new_option (
        ptr_section, "color_status_more", "color",
        N_("color for window with new data (status bar)"),
        NULL, GUI_COLOR_STATUS_MORE, 0, "white", &config_change_color);
    /* infobar window */
    config_color_infobar = config_file_new_option (
        ptr_section, "color_infobar", "color",
        N_("color for infobar text"),
        NULL, GUI_COLOR_INFOBAR, 0, "black", &config_change_color);
    config_color_infobar_bg = config_file_new_option (
        ptr_section, "color_infobar_bg", "color",
        N_("background color for info bar text"),
        NULL, -1, 0, "cyan", &config_change_color);
    config_color_infobar_delimiters = config_file_new_option (
        ptr_section, "color_infobar_delimiters", "color",
        N_("color for infobar delimiters"),
        NULL, GUI_COLOR_INFOBAR_DELIMITERS, 0, "blue", &config_change_color);
    config_color_infobar_highlight = config_file_new_option (
        ptr_section, "color_infobar_highlight", "color",
        N_("color for infobar highlight notification"),
        NULL, GUI_COLOR_INFOBAR_HIGHLIGHT, 0, "white", &config_change_color);
    /* input window */
    config_color_input = config_file_new_option (
        ptr_section, "color_input", "color",
        N_("color for input text"),
        NULL, GUI_COLOR_INPUT, 0, "default", &config_change_color);
    config_color_input_bg = config_file_new_option (
        ptr_section, "color_input_bg", "color",
        N_("background color for input text"),
        NULL, -1, 0, "default", &config_change_color);
    config_color_input_server = config_file_new_option (
        ptr_section, "color_input_server", "color",
        N_("color for input text (server name)"),
        NULL, GUI_COLOR_INPUT_SERVER, 0, "brown", &config_change_color);
    config_color_input_channel = config_file_new_option (
        ptr_section, "color_input_channel", "color",
        N_("color for input text (channel name)"),
        NULL, GUI_COLOR_INPUT_CHANNEL, 0, "white", &config_change_color);
    config_color_input_nick = config_file_new_option (
        ptr_section, "color_input_nick", "color",
        N_("color for input text (nick name)"),
        NULL, GUI_COLOR_INPUT_NICK, 0, "lightcyan", &config_change_color);
    config_color_input_delimiters = config_file_new_option (
        ptr_section, "color_input_delimiters", "color",
        N_("color for input text (delimiters)"),
        NULL, GUI_COLOR_INPUT_DELIMITERS, 0, "cyan", &config_change_color);
    config_color_input_text_not_found = config_file_new_option (
        ptr_section, "color_input_text_not_found", "color",
        N_("color for text not found"),
        NULL, GUI_COLOR_INPUT_TEXT_NOT_FOUND, 0, "red", &config_change_color);
    config_color_input_actions = config_file_new_option (
        ptr_section, "color_input_actions", "color",
        N_("color for actions in input window"),
        NULL, GUI_COLOR_INPUT_ACTIONS, 0, "lightgreen", &config_change_color);
    /* nicklist window */
    config_color_nicklist = config_file_new_option (
        ptr_section, "color_nicklist", "color",
        N_("color for nicklist"),
        NULL, GUI_COLOR_NICKLIST, 0, "default", &config_change_color);
    config_color_nicklist_bg = config_file_new_option (
        ptr_section, "color_nicklist_bg", "color",
        N_("background color for nicklist"),
        NULL, -1, 0, "default", &config_change_color);
    config_color_nicklist_away = config_file_new_option (
        ptr_section, "color_nicklist_away", "color",
        N_("color for away nicknames"),
        NULL, GUI_COLOR_NICKLIST_AWAY, 0, "cyan", &config_change_color);
    config_color_nicklist_prefix1 = config_file_new_option (
        ptr_section, "color_nicklist_prefix1", "color",
        N_("color for prefix 1"),
        NULL, GUI_COLOR_NICKLIST_PREFIX1, 0, "lightgreen", &config_change_color);
    config_color_nicklist_prefix2 = config_file_new_option (
        ptr_section, "color_nicklist_prefix2", "color",
        N_("color for prefix 2"),
        NULL, GUI_COLOR_NICKLIST_PREFIX2, 0, "lightmagenta", &config_change_color);
    config_color_nicklist_prefix3 = config_file_new_option (
        ptr_section, "color_nicklist_prefix3", "color",
        N_("color for prefix 3"),
        NULL, GUI_COLOR_NICKLIST_PREFIX3, 0, "yellow", &config_change_color);
    config_color_nicklist_prefix4 = config_file_new_option (
        ptr_section, "color_nicklist_prefix4", "color",
        N_("color for prefix 4"),
        NULL, GUI_COLOR_NICKLIST_PREFIX4, 0, "blue", &config_change_color);
    config_color_nicklist_prefix5 = config_file_new_option (
        ptr_section, "color_nicklist_prefix5", "color",
        N_("color for prefix 5"),
        NULL, GUI_COLOR_NICKLIST_PREFIX5, 0, "brown", &config_change_color);
    config_color_nicklist_more = config_file_new_option (
        ptr_section, "color_nicklist_more", "color",
        N_("color for '+' when scrolling nicks (nicklist)"),
        NULL, GUI_COLOR_NICKLIST_MORE, 0, "lightmagenta", &config_change_color);
    config_color_nicklist_separator = config_file_new_option (
        ptr_section, "color_nicklist_separator", "color",
        N_("color for nicklist separator"),
        NULL, GUI_COLOR_NICKLIST_SEPARATOR, 0, "blue", &config_change_color);
    /* status info */
    config_color_info = config_file_new_option (
        ptr_section, "color_info", "color",
        N_("color for status info"),
        NULL, GUI_COLOR_INFO, 0, "default", &config_change_color);
    config_color_info_bg = config_file_new_option (
        ptr_section, "color_info_bg", "color",
        N_("background color for status info"),
        NULL, -1, 0, "default", &config_change_color);
    config_color_info_waiting = config_file_new_option (
        ptr_section, "color_info_waiting", "color",
        N_("color for \"waiting\" status info"),
        NULL, GUI_COLOR_INFO_WAITING, 0, "lightcyan", &config_change_color);
    config_color_info_connecting = config_file_new_option (
        ptr_section, "color_info_connecting", "color",
        N_("color for \"connecting\" status info"),
        NULL, GUI_COLOR_INFO_CONNECTING, 0, "yellow", &config_change_color);
    config_color_info_active = config_file_new_option (
        ptr_section, "color_info_active", "color",
        N_("color for \"active\" status info"),
        NULL, GUI_COLOR_INFO_ACTIVE, 0, "lightblue", &config_change_color);
    config_color_info_done = config_file_new_option (
        ptr_section, "color_info_done", "color",
        N_("color for \"done\" status info"),
        NULL, GUI_COLOR_INFO_DONE, 0, "lightgreen", &config_change_color);
    config_color_info_failed = config_file_new_option (
        ptr_section, "color_info_failed", "color",
        N_("color for \"failed\" status info"),
        NULL, GUI_COLOR_INFO_FAILED, 0, "lightred", &config_change_color);
    config_color_info_aborted = config_file_new_option (
        ptr_section, "color_info_aborted", "color",
        N_("color for \"aborted\" status info"),
        NULL, GUI_COLOR_INFO_ABORTED, 0, "lightred", &config_change_color);

    /* history */
    ptr_section = config_file_new_section (weechat_config_file, "history",
                                           NULL, NULL, NULL);
    if (!ptr_section)
    {
        config_file_free (weechat_config_file);
        return 0;
    }
    
    config_history_max_lines = config_file_new_option (
        ptr_section, "history_max_lines", "integer",
        N_("maximum number of lines in history per buffer "
           "(0 = unlimited)"),
        NULL, 0, INT_MAX, "4096", NULL);
    config_history_max_commands = config_file_new_option (
        ptr_section, "history_max_commands", "integer",
        N_("maximum number of user commands in history (0 = "
           "unlimited)"),
        NULL, 0, INT_MAX, "100", NULL);
    config_history_display_default = config_file_new_option (
        ptr_section, "history_display_default", "integer",
        N_("maximum number of commands to display by default in "
           "history listing (0 = unlimited)"),
        NULL, 0, INT_MAX, "5", NULL);

    /* proxy */
    ptr_section = config_file_new_section (weechat_config_file, "proxy",
                                           NULL, NULL, NULL);
    if (!ptr_section)
    {
        config_file_free (weechat_config_file);
        return 0;
    }
    
    config_proxy_use = config_file_new_option (
        ptr_section, "proxy_use", "boolean",
        N_("use a proxy server"),
        NULL, 0, 0, "off", NULL);
    config_proxy_type = config_file_new_option (
        ptr_section, "proxy_type", "integer",
        N_("proxy type (http (default), socks4, socks5)"),
        "http|socks4|socks5", 0, 0, "http", NULL);
    config_proxy_ipv6 = config_file_new_option (
        ptr_section, "proxy_ipv6", "boolean",
        N_("connect to proxy using ipv6"),
        NULL, 0, 0, "off", NULL);
    config_proxy_address = config_file_new_option (
        ptr_section, "proxy_address", "string",
        N_("proxy server address (IP or hostname)"),
        NULL, 0, 0, "", NULL);
    config_proxy_port = config_file_new_option (
        ptr_section, "proxy_port", "integer",
        N_("port for connecting to proxy server"),
        NULL, 0, 65535, "3128", NULL);
    config_proxy_username = config_file_new_option (
        ptr_section, "proxy_username", "string",
        N_("username for proxy server"),
        NULL, 0, 0, "", NULL);
    config_proxy_password = config_file_new_option (
        ptr_section, "proxy_password", "string",
        N_("password for proxy server"),
        NULL, 0, 0, "", NULL);
            
    /* plugins */
    ptr_section = config_file_new_section (weechat_config_file, "plugins",
                                           NULL, NULL, NULL);
    if (!ptr_section)
    {
        config_file_free (weechat_config_file);
        return 0;
    }
    
    config_plugins_path = config_file_new_option (
        ptr_section, "plugins_path", "string",
        N_("path for searching plugins ('%h' will be replaced by "
           "WeeChat home, ~/.weechat by default)"),
        NULL, 0, 0, "%h/plugins", NULL);
    config_plugins_autoload = config_file_new_option (
        ptr_section, "plugins_autoload", "string",
        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 "
           "\"perl.so\")"),
        NULL, 0, 0, "*", NULL);
    config_plugins_extension = config_file_new_option (
        ptr_section, "plugins_extension", "string",
        N_("standard plugins extension in filename (for example "
           "\".so\" under Linux or \".dll\" under Windows)"),
        NULL, 0, 0,
#ifdef WIN32
        ".dll",
#else
        ".so",
#endif              
        NULL);
        
    /* keys */
    ptr_section = config_file_new_section (weechat_config_file, "keys",
                                           &config_weechat_read_key,
                                           &config_weechat_write_keys,
                                           &config_weechat_write_keys);
    if (!ptr_section)
    {
        config_file_free (weechat_config_file);
        return 0;
    }
    
    return 1;
}

/*
 * config_weechat_read: read WeeChat configuration file
 *                      return:  0 = successful
 *                              -1 = configuration file file not found
 *                              -2 = error in configuration file
 */

int
config_weechat_read ()
{
    return config_file_read (weechat_config_file);
}

/*
 * config_weechat_reload: reload WeeChat configuration file
 *                        return:  0 = successful
 *                                -1 = configuration file file not found
 *                                -2 = error in configuration file
 */

int
config_weechat_reload ()
{
    /* remove all keys */
    gui_keyboard_free_all ();
    
    /* reload configuration file */
    return config_file_reload (weechat_config_file);
}

/*
 * config_weechat_write: write WeeChat configuration file
 *                       return:  0 if ok
 *                              < 0 if error
 */

int
config_weechat_write ()
{
    log_printf (_("Saving WeeChat configuration to disk"));
    return config_file_write (weechat_config_file, 0);
}