summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/core/CMakeLists.txt2
-rw-r--r--src/core/Makefile.am2
-rw-r--r--src/core/wee-arraylist.c2
-rw-r--r--src/core/wee-arraylist.h2
-rw-r--r--src/core/wee-backtrace.c4
-rw-r--r--src/core/wee-backtrace.h2
-rw-r--r--src/core/wee-command.c544
-rw-r--r--src/core/wee-command.h11
-rw-r--r--src/core/wee-completion.c182
-rw-r--r--src/core/wee-completion.h5
-rw-r--r--src/core/wee-config-file.c988
-rw-r--r--src/core/wee-config-file.h95
-rw-r--r--src/core/wee-config.c1439
-rw-r--r--src/core/wee-config.h20
-rw-r--r--src/core/wee-debug.c55
-rw-r--r--src/core/wee-debug.h2
-rw-r--r--src/core/wee-eval.c2
-rw-r--r--src/core/wee-eval.h2
-rw-r--r--src/core/wee-hashtable.c2
-rw-r--r--src/core/wee-hashtable.h2
-rw-r--r--src/core/wee-hdata.c2
-rw-r--r--src/core/wee-hdata.h2
-rw-r--r--src/core/wee-hook.c361
-rw-r--r--src/core/wee-hook.h88
-rw-r--r--src/core/wee-infolist.c2
-rw-r--r--src/core/wee-infolist.h2
-rw-r--r--src/core/wee-input.c5
-rw-r--r--src/core/wee-input.h2
-rw-r--r--src/core/wee-list.c2
-rw-r--r--src/core/wee-list.h2
-rw-r--r--src/core/wee-log.c30
-rw-r--r--src/core/wee-log.h2
-rw-r--r--src/core/wee-network.c122
-rw-r--r--src/core/wee-network.h2
-rw-r--r--src/core/wee-proxy.c18
-rw-r--r--src/core/wee-proxy.h6
-rw-r--r--src/core/wee-secure.c68
-rw-r--r--src/core/wee-secure.h2
-rw-r--r--src/core/wee-string.c176
-rw-r--r--src/core/wee-string.h7
-rw-r--r--src/core/wee-upgrade-file.c70
-rw-r--r--src/core/wee-upgrade-file.h21
-rw-r--r--src/core/wee-upgrade.c26
-rw-r--r--src/core/wee-upgrade.h2
-rw-r--r--src/core/wee-url.c68
-rw-r--r--src/core/wee-url.h2
-rw-r--r--src/core/wee-utf8.c2
-rw-r--r--src/core/wee-utf8.h2
-rw-r--r--src/core/wee-util.c59
-rw-r--r--src/core/wee-util.h6
-rw-r--r--src/core/wee-version.c2
-rw-r--r--src/core/wee-version.h2
-rw-r--r--src/core/weechat.c150
-rw-r--r--src/core/weechat.h4
-rw-r--r--src/gui/CMakeLists.txt4
-rw-r--r--src/gui/Makefile.am4
-rw-r--r--src/gui/curses/CMakeLists.txt4
-rw-r--r--src/gui/curses/Makefile.am2
-rw-r--r--src/gui/curses/gui-curses-bar-window.c2
-rw-r--r--src/gui/curses/gui-curses-chat.c6
-rw-r--r--src/gui/curses/gui-curses-color.c29
-rw-r--r--src/gui/curses/gui-curses-key.c5
-rw-r--r--src/gui/curses/gui-curses-main.c10
-rw-r--r--src/gui/curses/gui-curses-mouse.c7
-rw-r--r--src/gui/curses/gui-curses-term.c2
-rw-r--r--src/gui/curses/gui-curses-window.c11
-rw-r--r--src/gui/curses/gui-curses.h4
-rw-r--r--src/gui/curses/main.c2
-rw-r--r--src/gui/gui-bar-item.c447
-rw-r--r--src/gui/gui-bar-item.h16
-rw-r--r--src/gui/gui-bar-window.c6
-rw-r--r--src/gui/gui-bar-window.h5
-rw-r--r--src/gui/gui-bar.c130
-rw-r--r--src/gui/gui-bar.h5
-rw-r--r--src/gui/gui-buffer.c468
-rw-r--r--src/gui/gui-buffer.h33
-rw-r--r--src/gui/gui-chat.c20
-rw-r--r--src/gui/gui-chat.h5
-rw-r--r--src/gui/gui-color.c27
-rw-r--r--src/gui/gui-color.h6
-rw-r--r--src/gui/gui-completion.c29
-rw-r--r--src/gui/gui-completion.h8
-rw-r--r--src/gui/gui-cursor.c2
-rw-r--r--src/gui/gui-cursor.h2
-rw-r--r--src/gui/gui-filter.c59
-rw-r--r--src/gui/gui-filter.h5
-rw-r--r--src/gui/gui-focus.c8
-rw-r--r--src/gui/gui-focus.h2
-rw-r--r--src/gui/gui-history.c6
-rw-r--r--src/gui/gui-history.h5
-rw-r--r--src/gui/gui-hotlist.c49
-rw-r--r--src/gui/gui-hotlist.h9
-rw-r--r--src/gui/gui-input.c63
-rw-r--r--src/gui/gui-input.h5
-rw-r--r--src/gui/gui-key.c28
-rw-r--r--src/gui/gui-key.h5
-rw-r--r--src/gui/gui-layout.c14
-rw-r--r--src/gui/gui-layout.h11
-rw-r--r--src/gui/gui-line.c14
-rw-r--r--src/gui/gui-line.h11
-rw-r--r--src/gui/gui-main.h2
-rw-r--r--src/gui/gui-mouse.c2
-rw-r--r--src/gui/gui-mouse.h2
-rw-r--r--src/gui/gui-nick.c259
-rw-r--r--src/gui/gui-nick.h26
-rw-r--r--src/gui/gui-nicklist.c16
-rw-r--r--src/gui/gui-nicklist.h8
-rw-r--r--src/gui/gui-window.c311
-rw-r--r--src/gui/gui-window.h11
-rw-r--r--src/plugins/CMakeLists.txt5
-rw-r--r--src/plugins/Makefile.am4
-rw-r--r--src/plugins/alias/CMakeLists.txt2
-rw-r--r--src/plugins/alias/Makefile.am2
-rw-r--r--src/plugins/alias/alias-command.c45
-rw-r--r--src/plugins/alias/alias-command.h2
-rw-r--r--src/plugins/alias/alias-completion.c14
-rw-r--r--src/plugins/alias/alias-completion.h2
-rw-r--r--src/plugins/alias/alias-config.c78
-rw-r--r--src/plugins/alias/alias-config.h2
-rw-r--r--src/plugins/alias/alias-info.c16
-rw-r--r--src/plugins/alias/alias-info.h2
-rw-r--r--src/plugins/alias/alias.c48
-rw-r--r--src/plugins/alias/alias.h2
-rw-r--r--src/plugins/aspell/CMakeLists.txt2
-rw-r--r--src/plugins/aspell/Makefile.am2
-rw-r--r--src/plugins/aspell/weechat-aspell-bar-item.c16
-rw-r--r--src/plugins/aspell/weechat-aspell-command.c8
-rw-r--r--src/plugins/aspell/weechat-aspell-command.h2
-rw-r--r--src/plugins/aspell/weechat-aspell-completion.c13
-rw-r--r--src/plugins/aspell/weechat-aspell-completion.h2
-rw-r--r--src/plugins/aspell/weechat-aspell-config.c140
-rw-r--r--src/plugins/aspell/weechat-aspell-config.h2
-rw-r--r--src/plugins/aspell/weechat-aspell-info.c8
-rw-r--r--src/plugins/aspell/weechat-aspell-info.h2
-rw-r--r--src/plugins/aspell/weechat-aspell-speller.c11
-rw-r--r--src/plugins/aspell/weechat-aspell-speller.h2
-rw-r--r--src/plugins/aspell/weechat-aspell.c34
-rw-r--r--src/plugins/aspell/weechat-aspell.h2
-rw-r--r--src/plugins/charset/CMakeLists.txt2
-rw-r--r--src/plugins/charset/Makefile.am2
-rw-r--r--src/plugins/charset/charset.c85
-rw-r--r--src/plugins/exec/CMakeLists.txt2
-rw-r--r--src/plugins/exec/Makefile.am2
-rw-r--r--src/plugins/exec/exec-buffer.c14
-rw-r--r--src/plugins/exec/exec-buffer.h2
-rw-r--r--src/plugins/exec/exec-command.c16
-rw-r--r--src/plugins/exec/exec-command.h2
-rw-r--r--src/plugins/exec/exec-completion.c8
-rw-r--r--src/plugins/exec/exec-completion.h2
-rw-r--r--src/plugins/exec/exec-config.c39
-rw-r--r--src/plugins/exec/exec-config.h2
-rw-r--r--src/plugins/exec/exec.c56
-rw-r--r--src/plugins/exec/exec.h5
-rw-r--r--src/plugins/fifo/CMakeLists.txt3
-rw-r--r--src/plugins/fifo/Makefile.am4
-rw-r--r--src/plugins/fifo/fifo-command.c119
-rw-r--r--src/plugins/fifo/fifo-command.h25
-rw-r--r--src/plugins/fifo/fifo-info.c8
-rw-r--r--src/plugins/fifo/fifo-info.h2
-rw-r--r--src/plugins/fifo/fifo.c50
-rw-r--r--src/plugins/fifo/fifo.h4
-rw-r--r--src/plugins/guile/CMakeLists.txt2
-rw-r--r--src/plugins/guile/Makefile.am2
-rw-r--r--src/plugins/guile/weechat-guile-api.c701
-rw-r--r--src/plugins/guile/weechat-guile-api.h8
-rw-r--r--src/plugins/guile/weechat-guile.c73
-rw-r--r--src/plugins/guile/weechat-guile.h2
-rw-r--r--src/plugins/irc/CMakeLists.txt2
-rw-r--r--src/plugins/irc/Makefile.am2
-rw-r--r--src/plugins/irc/irc-bar-item.c126
-rw-r--r--src/plugins/irc/irc-bar-item.h2
-rw-r--r--src/plugins/irc/irc-buffer.c15
-rw-r--r--src/plugins/irc/irc-buffer.h10
-rw-r--r--src/plugins/irc/irc-channel.c36
-rw-r--r--src/plugins/irc/irc-channel.h18
-rw-r--r--src/plugins/irc/irc-color.c8
-rw-r--r--src/plugins/irc/irc-color.h5
-rw-r--r--src/plugins/irc/irc-command.c1005
-rw-r--r--src/plugins/irc/irc-command.h17
-rw-r--r--src/plugins/irc/irc-completion.c180
-rw-r--r--src/plugins/irc/irc-completion.h2
-rw-r--r--src/plugins/irc/irc-config.c1293
-rw-r--r--src/plugins/irc/irc-config.h32
-rw-r--r--src/plugins/irc/irc-ctcp.c5
-rw-r--r--src/plugins/irc/irc-ctcp.h2
-rw-r--r--src/plugins/irc/irc-debug.c9
-rw-r--r--src/plugins/irc/irc-debug.h2
-rw-r--r--src/plugins/irc/irc-ignore.c6
-rw-r--r--src/plugins/irc/irc-ignore.h5
-rw-r--r--src/plugins/irc/irc-info.c181
-rw-r--r--src/plugins/irc/irc-info.h2
-rw-r--r--src/plugins/irc/irc-input.c87
-rw-r--r--src/plugins/irc/irc-input.h10
-rw-r--r--src/plugins/irc/irc-message.c50
-rw-r--r--src/plugins/irc/irc-message.h2
-rw-r--r--src/plugins/irc/irc-mode.c2
-rw-r--r--src/plugins/irc/irc-mode.h2
-rw-r--r--src/plugins/irc/irc-msgbuffer.c2
-rw-r--r--src/plugins/irc/irc-msgbuffer.h2
-rw-r--r--src/plugins/irc/irc-nick.c198
-rw-r--r--src/plugins/irc/irc-nick.h11
-rw-r--r--src/plugins/irc/irc-notify.c34
-rw-r--r--src/plugins/irc/irc-notify.h11
-rw-r--r--src/plugins/irc/irc-protocol.c269
-rw-r--r--src/plugins/irc/irc-protocol.h2
-rw-r--r--src/plugins/irc/irc-raw.c145
-rw-r--r--src/plugins/irc/irc-raw.h3
-rw-r--r--src/plugins/irc/irc-redirect.c24
-rw-r--r--src/plugins/irc/irc-redirect.h14
-rw-r--r--src/plugins/irc/irc-sasl.c4
-rw-r--r--src/plugins/irc/irc-sasl.h2
-rw-r--r--src/plugins/irc/irc-server.c404
-rw-r--r--src/plugins/irc/irc-server.h42
-rw-r--r--src/plugins/irc/irc-upgrade.c32
-rw-r--r--src/plugins/irc/irc-upgrade.h2
-rw-r--r--src/plugins/irc/irc.c46
-rw-r--r--src/plugins/irc/irc.h2
-rw-r--r--src/plugins/javascript/CMakeLists.txt2
-rw-r--r--src/plugins/javascript/Makefile.am2
-rw-r--r--src/plugins/javascript/weechat-js-api.cpp773
-rw-r--r--src/plugins/javascript/weechat-js-api.h8
-rw-r--r--src/plugins/javascript/weechat-js-v8.cpp2
-rw-r--r--src/plugins/javascript/weechat-js-v8.h2
-rw-r--r--src/plugins/javascript/weechat-js.cpp77
-rw-r--r--src/plugins/javascript/weechat-js.h2
-rw-r--r--src/plugins/logger/CMakeLists.txt2
-rw-r--r--src/plugins/logger/Makefile.am2
-rw-r--r--src/plugins/logger/logger-buffer.c21
-rw-r--r--src/plugins/logger/logger-buffer.h2
-rw-r--r--src/plugins/logger/logger-config.c174
-rw-r--r--src/plugins/logger/logger-config.h2
-rw-r--r--src/plugins/logger/logger-info.c17
-rw-r--r--src/plugins/logger/logger-info.h2
-rw-r--r--src/plugins/logger/logger-tail.c2
-rw-r--r--src/plugins/logger/logger-tail.h2
-rw-r--r--src/plugins/logger/logger.c158
-rw-r--r--src/plugins/logger/logger.h5
-rw-r--r--src/plugins/lua/CMakeLists.txt2
-rw-r--r--src/plugins/lua/Makefile.am2
-rw-r--r--src/plugins/lua/weechat-lua-api.c704
-rw-r--r--src/plugins/lua/weechat-lua-api.h8
-rw-r--r--src/plugins/lua/weechat-lua.c86
-rw-r--r--src/plugins/lua/weechat-lua.h2
-rw-r--r--src/plugins/perl/CMakeLists.txt2
-rw-r--r--src/plugins/perl/Makefile.am2
-rw-r--r--src/plugins/perl/weechat-perl-api.c705
-rw-r--r--src/plugins/perl/weechat-perl-api.h8
-rw-r--r--src/plugins/perl/weechat-perl.c85
-rw-r--r--src/plugins/perl/weechat-perl.h2
-rw-r--r--src/plugins/plugin-api.c456
-rw-r--r--src/plugins/plugin-api.h2
-rw-r--r--src/plugins/plugin-config.c64
-rw-r--r--src/plugins/plugin-config.h2
-rw-r--r--src/plugins/plugin-script-api.c899
-rw-r--r--src/plugins/plugin-script-api.h134
-rw-r--r--src/plugins/plugin-script-callback.c202
-rw-r--r--src/plugins/plugin-script-callback.h50
-rw-r--r--src/plugins/plugin-script.c397
-rw-r--r--src/plugins/plugin-script.h45
-rw-r--r--src/plugins/plugin.c22
-rw-r--r--src/plugins/plugin.h5
-rw-r--r--src/plugins/python/CMakeLists.txt2
-rw-r--r--src/plugins/python/Makefile.am2
-rw-r--r--src/plugins/python/weechat-python-api.c691
-rw-r--r--src/plugins/python/weechat-python-api.h8
-rw-r--r--src/plugins/python/weechat-python.c83
-rw-r--r--src/plugins/python/weechat-python.h2
-rw-r--r--src/plugins/relay/CMakeLists.txt2
-rw-r--r--src/plugins/relay/Makefile.am2
-rw-r--r--src/plugins/relay/irc/relay-irc.c91
-rw-r--r--src/plugins/relay/irc/relay-irc.h2
-rw-r--r--src/plugins/relay/relay-buffer.c14
-rw-r--r--src/plugins/relay/relay-buffer.h10
-rw-r--r--src/plugins/relay/relay-client.c486
-rw-r--r--src/plugins/relay/relay-client.h26
-rw-r--r--src/plugins/relay/relay-command.c19
-rw-r--r--src/plugins/relay/relay-command.h2
-rw-r--r--src/plugins/relay/relay-completion.c20
-rw-r--r--src/plugins/relay/relay-completion.h2
-rw-r--r--src/plugins/relay/relay-config.c243
-rw-r--r--src/plugins/relay/relay-config.h6
-rw-r--r--src/plugins/relay/relay-info.c22
-rw-r--r--src/plugins/relay/relay-info.h2
-rw-r--r--src/plugins/relay/relay-network.c2
-rw-r--r--src/plugins/relay/relay-network.h2
-rw-r--r--src/plugins/relay/relay-raw.c156
-rw-r--r--src/plugins/relay/relay-raw.h7
-rw-r--r--src/plugins/relay/relay-server.c90
-rw-r--r--src/plugins/relay/relay-server.h2
-rw-r--r--src/plugins/relay/relay-upgrade.c15
-rw-r--r--src/plugins/relay/relay-upgrade.h2
-rw-r--r--src/plugins/relay/relay-websocket.c21
-rw-r--r--src/plugins/relay/relay-websocket.h11
-rw-r--r--src/plugins/relay/relay.c16
-rw-r--r--src/plugins/relay/relay.h2
-rw-r--r--src/plugins/relay/weechat/relay-weechat-msg.c11
-rw-r--r--src/plugins/relay/weechat/relay-weechat-msg.h2
-rw-r--r--src/plugins/relay/weechat/relay-weechat-nicklist.c2
-rw-r--r--src/plugins/relay/weechat/relay-weechat-nicklist.h2
-rw-r--r--src/plugins/relay/weechat/relay-weechat-protocol.c61
-rw-r--r--src/plugins/relay/weechat/relay-weechat-protocol.h17
-rw-r--r--src/plugins/relay/weechat/relay-weechat.c35
-rw-r--r--src/plugins/relay/weechat/relay-weechat.h2
-rw-r--r--src/plugins/ruby/CMakeLists.txt2
-rw-r--r--src/plugins/ruby/Makefile.am2
-rw-r--r--src/plugins/ruby/weechat-ruby-api.c731
-rw-r--r--src/plugins/ruby/weechat-ruby-api.h8
-rw-r--r--src/plugins/ruby/weechat-ruby.c80
-rw-r--r--src/plugins/ruby/weechat-ruby.h2
-rw-r--r--src/plugins/script/CMakeLists.txt2
-rw-r--r--src/plugins/script/Makefile.am2
-rw-r--r--src/plugins/script/script-action.c54
-rw-r--r--src/plugins/script/script-action.h2
-rw-r--r--src/plugins/script/script-buffer.c246
-rw-r--r--src/plugins/script/script-buffer.h11
-rw-r--r--src/plugins/script/script-command.c17
-rw-r--r--src/plugins/script/script-command.h2
-rw-r--r--src/plugins/script/script-completion.c94
-rw-r--r--src/plugins/script/script-completion.h2
-rw-r--r--src/plugins/script/script-config.c207
-rw-r--r--src/plugins/script/script-config.h3
-rw-r--r--src/plugins/script/script-info.c19
-rw-r--r--src/plugins/script/script-info.h2
-rw-r--r--src/plugins/script/script-repo.c62
-rw-r--r--src/plugins/script/script-repo.h5
-rw-r--r--src/plugins/script/script.c44
-rw-r--r--src/plugins/script/script.h2
-rw-r--r--src/plugins/tcl/CMakeLists.txt2
-rw-r--r--src/plugins/tcl/Makefile.am2
-rw-r--r--src/plugins/tcl/weechat-tcl-api.c720
-rw-r--r--src/plugins/tcl/weechat-tcl-api.h8
-rw-r--r--src/plugins/tcl/weechat-tcl.c75
-rw-r--r--src/plugins/tcl/weechat-tcl.h2
-rw-r--r--src/plugins/trigger/CMakeLists.txt2
-rw-r--r--src/plugins/trigger/Makefile.am2
-rw-r--r--src/plugins/trigger/trigger-buffer.c72
-rw-r--r--src/plugins/trigger/trigger-buffer.h4
-rw-r--r--src/plugins/trigger/trigger-callback.c110
-rw-r--r--src/plugins/trigger/trigger-callback.h61
-rw-r--r--src/plugins/trigger/trigger-command.c469
-rw-r--r--src/plugins/trigger/trigger-command.h2
-rw-r--r--src/plugins/trigger/trigger-completion.c99
-rw-r--r--src/plugins/trigger/trigger-completion.h2
-rw-r--r--src/plugins/trigger/trigger-config.c160
-rw-r--r--src/plugins/trigger/trigger-config.h3
-rw-r--r--src/plugins/trigger/trigger.c76
-rw-r--r--src/plugins/trigger/trigger.h17
-rw-r--r--src/plugins/weechat-plugin.h332
-rw-r--r--src/plugins/xfer/CMakeLists.txt2
-rw-r--r--src/plugins/xfer/Makefile.am2
-rw-r--r--src/plugins/xfer/xfer-buffer.c14
-rw-r--r--src/plugins/xfer/xfer-buffer.h8
-rw-r--r--src/plugins/xfer/xfer-chat.c134
-rw-r--r--src/plugins/xfer/xfer-chat.h4
-rw-r--r--src/plugins/xfer/xfer-command.c33
-rw-r--r--src/plugins/xfer/xfer-command.h2
-rw-r--r--src/plugins/xfer/xfer-completion.c8
-rw-r--r--src/plugins/xfer/xfer-completion.h2
-rw-r--r--src/plugins/xfer/xfer-config.c138
-rw-r--r--src/plugins/xfer/xfer-config.h8
-rw-r--r--src/plugins/xfer/xfer-dcc.c13
-rw-r--r--src/plugins/xfer/xfer-dcc.h2
-rw-r--r--src/plugins/xfer/xfer-file.c2
-rw-r--r--src/plugins/xfer/xfer-file.h2
-rw-r--r--src/plugins/xfer/xfer-info.c16
-rw-r--r--src/plugins/xfer/xfer-info.h2
-rw-r--r--src/plugins/xfer/xfer-network.c42
-rw-r--r--src/plugins/xfer/xfer-network.h2
-rw-r--r--src/plugins/xfer/xfer-upgrade.c18
-rw-r--r--src/plugins/xfer/xfer-upgrade.h2
-rw-r--r--src/plugins/xfer/xfer.c56
-rw-r--r--src/plugins/xfer/xfer.h2
374 files changed, 14813 insertions, 9855 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b044f8b96..e7ef8d7ba 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
# Copyright (C) 2007-2008 Julien Louis <ptitlouis@sysif.net>
# Copyright (C) 2008-2009 Emmanuel Bouthenot <kolter@openics.org>
#
diff --git a/src/Makefile.am b/src/Makefile.am
index 48bfbb785..75edfa4bb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index bb1bf43f4..c2903809c 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
# Copyright (C) 2008 Julien Louis <ptitlouis@sysif.net>
# Copyright (C) 2009 Emmanuel Bouthenot <kolter@openics.org>
#
diff --git a/src/core/Makefile.am b/src/core/Makefile.am
index 8b015c061..b70f63598 100644
--- a/src/core/Makefile.am
+++ b/src/core/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/core/wee-arraylist.c b/src/core/wee-arraylist.c
index ec6052d65..3bc04c77f 100644
--- a/src/core/wee-arraylist.c
+++ b/src/core/wee-arraylist.c
@@ -1,7 +1,7 @@
/*
* wee-arraylist.c - array lists management
*
- * Copyright (C) 2014-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2014-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/core/wee-arraylist.h b/src/core/wee-arraylist.h
index f8c43a3f7..33a404dcc 100644
--- a/src/core/wee-arraylist.h
+++ b/src/core/wee-arraylist.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2014-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/core/wee-backtrace.c b/src/core/wee-backtrace.c
index 6e934de2d..8441d3155 100644
--- a/src/core/wee-backtrace.c
+++ b/src/core/wee-backtrace.c
@@ -1,7 +1,7 @@
/*
* wee-backtrace.c - backtrace after a segfault
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -56,7 +56,7 @@ weechat_backtrace_printf (const char *message, ...)
weechat_va_format (message);
if (vbuffer)
{
- string_iconv_fprintf (stderr, "%s\n", vbuffer);
+ string_fprintf (stderr, "%s\n", vbuffer);
log_printf ("%s", vbuffer);
free (vbuffer);
}
diff --git a/src/core/wee-backtrace.h b/src/core/wee-backtrace.h
index c77843554..9cecf4244 100644
--- a/src/core/wee-backtrace.h
+++ b/src/core/wee-backtrace.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index 87bf62fc7..504f13298 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -1,7 +1,7 @@
/*
* wee-command.c - WeeChat core commands
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2005-2006 Emmanuel Bouthenot <kolter@openics.org>
*
* This file is part of WeeChat, the extensible chat client.
@@ -180,6 +180,7 @@ COMMAND_CALLBACK(bar)
struct t_gui_window *ptr_window;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
@@ -238,8 +239,9 @@ COMMAND_CALLBACK(bar)
if (!str_type)
{
gui_chat_printf (NULL,
- _("%sNot enough memory"),
- gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
+ _("%sNot enough memory (%s)"),
+ gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
+ "/bar");
return WEECHAT_RC_OK;
}
type = gui_bar_search_type (str_type);
@@ -540,13 +542,15 @@ command_buffer_display_localvar (void *data,
COMMAND_CALLBACK(buffer)
{
- struct t_gui_buffer *ptr_buffer, *ptr_buffer2, *ptr_prev_buffer;
- struct t_gui_buffer *weechat_buffer;
+ struct t_gui_buffer *ptr_buffer, *ptr_buffer1, *ptr_buffer2;
+ struct t_gui_buffer *ptr_prev_buffer, *weechat_buffer;
long number, number1, number2, numbers[3];
char *error, *value, *pos, *str_number1, *pos_number2;
int i, error_main_buffer, num_buffers, count, prev_number, clear_number;
+ int buffer_found;
/* make C compiler happy */
+ (void) pointer;
(void) data;
if ((argc == 1)
@@ -704,6 +708,54 @@ COMMAND_CALLBACK(buffer)
return WEECHAT_RC_OK;
}
+ /* cycle between a list of buffers */
+ if (string_strcasecmp (argv[1], "cycle") == 0)
+ {
+ COMMAND_MIN_ARGS(3, "cycle");
+
+ /* first buffer found different from current one */
+ ptr_buffer1 = NULL;
+
+ /* boolean to check if current buffer was found in list */
+ buffer_found = 0;
+
+ for (i = 2; i < argc; i++)
+ {
+ ptr_buffer = gui_buffer_search_by_number_or_name (argv[i]);
+ if (!ptr_buffer)
+ continue;
+ if (ptr_buffer == buffer)
+ {
+ /* current buffer found */
+ buffer_found = 1;
+ }
+ else
+ {
+ if (!ptr_buffer1)
+ ptr_buffer1 = ptr_buffer;
+ if (buffer_found)
+ {
+ /*
+ * we already found the current buffer in list,
+ * so let's jump to this buffer
+ */
+ gui_window_switch_to_buffer (gui_current_window,
+ ptr_buffer, 1);
+ return WEECHAT_RC_OK;
+ }
+ }
+ }
+
+ /* cycle on the first buffer found if no other buffer was found */
+ if (ptr_buffer1)
+ {
+ gui_window_switch_to_buffer (gui_current_window,
+ ptr_buffer1, 1);
+ }
+
+ return WEECHAT_RC_OK;
+ }
+
/* merge buffer with another number in the list */
if (string_strcasecmp (argv[1], "merge") == 0)
{
@@ -1293,6 +1345,7 @@ COMMAND_CALLBACK(color)
struct t_gui_color_palette *color_palette;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv_eol;
@@ -1484,6 +1537,7 @@ COMMAND_CALLBACK(command)
struct t_gui_buffer *ptr_buffer;
/* make C compiler happy */
+ (void) pointer;
(void) data;
COMMAND_MIN_ARGS(3, "");
@@ -1548,6 +1602,7 @@ COMMAND_CALLBACK(cursor)
int x, y;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
(void) argv_eol;
@@ -1636,6 +1691,7 @@ COMMAND_CALLBACK(debug)
int debug;
/* make C compiler happy */
+ (void) pointer;
(void) data;
if ((argc == 1)
@@ -1820,6 +1876,7 @@ COMMAND_CALLBACK(eval)
struct t_hashtable *pointers, *options;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv;
@@ -1996,6 +2053,7 @@ COMMAND_CALLBACK(filter)
struct t_gui_filter *ptr_filter;
/* make C compiler happy */
+ (void) pointer;
(void) data;
if ((argc == 1)
@@ -2184,14 +2242,6 @@ COMMAND_CALLBACK(filter)
if (string_strcasecmp (argv[1], "add") == 0)
{
COMMAND_MIN_ARGS(6, "add");
- if (gui_filter_search_by_name (argv[2]))
- {
- gui_chat_printf_date_tags (NULL, 0, GUI_FILTER_TAG_NO_FILTER,
- _("%sError: filter \"%s\" already exists"),
- gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
- argv[2]);
- return WEECHAT_RC_OK;
- }
if ((strcmp (argv[4], "*") == 0) && (strcmp (argv_eol[5], "*") == 0))
{
gui_chat_printf_date_tags (NULL, 0, GUI_FILTER_TAG_NO_FILTER,
@@ -2201,7 +2251,8 @@ COMMAND_CALLBACK(filter)
return WEECHAT_RC_OK;
}
- ptr_filter = gui_filter_new (1, argv[2], argv[3], argv[4], argv_eol[5]);
+ ptr_filter = gui_filter_new (1, argv[2], argv[3], argv[4],
+ argv_eol[5]);
if (ptr_filter)
{
gui_filter_all_buffers ();
@@ -2211,12 +2262,6 @@ COMMAND_CALLBACK(filter)
argv[2]);
command_filter_display (ptr_filter);
}
- else
- {
- gui_chat_printf_date_tags (NULL, 0, GUI_FILTER_TAG_NO_FILTER,
- _("%sError adding filter"),
- gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
- }
return WEECHAT_RC_OK;
}
@@ -2479,6 +2524,7 @@ COMMAND_CALLBACK(help)
char empty_string[1] = { '\0' }, str_format[64];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
(void) argv_eol;
@@ -2869,6 +2915,7 @@ COMMAND_CALLBACK(history)
int n, n_total, n_user, displayed;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv_eol;
@@ -2921,6 +2968,7 @@ COMMAND_CALLBACK(history)
COMMAND_CALLBACK(input)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
COMMAND_MIN_ARGS(2, "");
@@ -2999,7 +3047,7 @@ COMMAND_CALLBACK(input)
else if (string_strcasecmp (argv[1], "jump_next_visited_buffer") == 0)
gui_input_jump_next_visited_buffer (buffer);
else if (string_strcasecmp (argv[1], "hotlist_clear") == 0)
- gui_input_hotlist_clear (buffer);
+ gui_input_hotlist_clear (buffer, (argc > 2) ? argv[2] : NULL);
else if (string_strcasecmp (argv[1], "grab_key") == 0)
gui_input_grab_key (buffer, 0, (argc > 2) ? argv[2] : NULL);
else if (string_strcasecmp (argv[1], "grab_key_command") == 0)
@@ -3293,6 +3341,7 @@ COMMAND_CALLBACK(key)
int old_keys_count, keys_added, i, context, rc;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
@@ -3710,6 +3759,7 @@ COMMAND_CALLBACK(layout)
int flag_buffers, flag_windows, layout_is_current;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
(void) argv_eol;
@@ -3897,9 +3947,10 @@ COMMAND_CALLBACK(layout)
*/
int
-command_mouse_timer_cb (void *data, int remaining_calls)
+command_mouse_timer_cb (const void *pointer, void *data, int remaining_calls)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) remaining_calls;
@@ -3924,7 +3975,8 @@ command_mouse_timer (const char *delay)
seconds = strtol (delay, &error, 10);
if (error && !error[0] && (seconds > 0))
{
- hook_timer (NULL, seconds * 1000, 0, 1, &command_mouse_timer_cb, NULL);
+ hook_timer (NULL, seconds * 1000, 0, 1,
+ &command_mouse_timer_cb, NULL, NULL);
}
}
@@ -3935,6 +3987,7 @@ command_mouse_timer (const char *delay)
COMMAND_CALLBACK(mouse)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
(void) argv_eol;
@@ -3997,6 +4050,7 @@ COMMAND_CALLBACK(mute)
struct t_gui_buffer *mute_buffer, *ptr_buffer, *gui_chat_mute_buffer_old;
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (argc < 2)
@@ -4382,6 +4436,7 @@ COMMAND_CALLBACK(plugin)
char **plugin_argv, *full_name;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
@@ -4494,6 +4549,7 @@ COMMAND_CALLBACK(print)
long value;
/* make C compiler happy */
+ (void) pointer;
(void) data;
ptr_buffer = buffer;
@@ -4724,6 +4780,7 @@ COMMAND_CALLBACK(proxy)
struct t_proxy *ptr_proxy;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
@@ -4846,6 +4903,7 @@ COMMAND_CALLBACK(quit)
char *pos_args;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
@@ -4897,7 +4955,9 @@ command_reload_file (struct t_config_file *config_file)
if (config_file->callback_reload)
rc = (int) (config_file->callback_reload)
- (config_file->callback_reload_data, config_file);
+ (config_file->callback_reload_pointer,
+ config_file->callback_reload_data,
+ config_file);
else
rc = config_file_reload (config_file);
@@ -4926,6 +4986,7 @@ COMMAND_CALLBACK(reload)
int i;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
(void) argv_eol;
@@ -4964,13 +5025,16 @@ COMMAND_CALLBACK(reload)
*/
int
-command_repeat_timer_cb (void *data, int remaining_calls)
+command_repeat_timer_cb (const void *pointer, void *data, int remaining_calls)
{
char **repeat_args;
int i;
struct t_gui_buffer *ptr_buffer;
- repeat_args = (char **)data;
+ /* make C compiler happy */
+ (void) data;
+
+ repeat_args = (char **)pointer;
if (!repeat_args)
return WEECHAT_RC_ERROR;
@@ -5010,6 +5074,7 @@ COMMAND_CALLBACK(repeat)
char *error, *command, **repeat_args;
/* make C compiler happy */
+ (void) pointer;
(void) data;
COMMAND_MIN_ARGS(3, "");
@@ -5066,14 +5131,15 @@ COMMAND_CALLBACK(repeat)
if (!repeat_args)
{
gui_chat_printf (NULL,
- _("%sNot enough memory"),
- gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
+ _("%sNot enough memory (%s)"),
+ gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
+ "/repeat");
return WEECHAT_RC_OK;
}
repeat_args[0] = strdup (buffer->full_name);
repeat_args[1] = command;
hook_timer (NULL, interval, 0, count - 1,
- &command_repeat_timer_cb, repeat_args);
+ &command_repeat_timer_cb, repeat_args, NULL);
}
}
else
@@ -5117,6 +5183,7 @@ COMMAND_CALLBACK(save)
int i;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
(void) argv_eol;
@@ -5179,6 +5246,7 @@ COMMAND_CALLBACK(secure)
int passphrase_was_set, count_encrypted;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
@@ -5341,183 +5409,85 @@ void
command_set_display_option (struct t_config_option *option,
const char *message)
{
- const char *color_name;
- const char *display_undefined = _("(undefined)");
- const char *display_default;
- char str_default[128];
- int is_file_plugins_conf;
+ struct t_config_option *ptr_parent_option;
+ char *value, *inherited_value, *default_value;
+ int is_file_plugins_conf, is_value_inherited, is_default_value_inherited;
+
+ ptr_parent_option = NULL;
+
+ value = NULL;
+ inherited_value = NULL;
+ default_value = NULL;
- display_default = NULL;
is_file_plugins_conf = (option->config_file && option->config_file->name
&& (strcmp (option->config_file->name, "plugins") == 0));
+ is_value_inherited = 0;
+ is_default_value_inherited = 0;
- if (option->value)
+ /* check if option has a parent option */
+ if (option->parent_name)
{
- if (!is_file_plugins_conf && !option->default_value)
- {
- display_default = display_undefined;
- }
- switch (option->type)
- {
- case CONFIG_OPTION_TYPE_BOOLEAN:
- if (!is_file_plugins_conf && option->default_value
- && (CONFIG_BOOLEAN(option) != CONFIG_BOOLEAN_DEFAULT(option)))
- {
- snprintf (str_default, sizeof (str_default), "%s",
- (CONFIG_BOOLEAN_DEFAULT(option)) ? "on" : "off");
- display_default = str_default;
- }
- gui_chat_printf_date_tags (NULL, 0,
- "no_trigger," GUI_CHAT_TAG_NO_HIGHLIGHT,
- "%s%s.%s.%s%s = %s%s%s%s%s%s%s%s%s%s",
- (message) ? message : " ",
- (option->config_file) ? option->config_file->name : "",
- (option->section) ? option->section->name : "",
- option->name,
- GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
- GUI_COLOR(GUI_COLOR_CHAT_VALUE),
- (CONFIG_BOOLEAN(option) == CONFIG_BOOLEAN_TRUE) ? "on" : "off",
- (display_default) ? GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS) : "",
- (display_default) ? " (" : "",
- (display_default) ? GUI_COLOR(GUI_COLOR_CHAT) : "",
- (display_default) ? _("default: ") : "",
- (display_default) ? GUI_COLOR(GUI_COLOR_CHAT_VALUE) : "",
- (display_default) ? display_default : "",
- (display_default) ? GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS) : "",
- (display_default) ? ")" : "");
- break;
- case CONFIG_OPTION_TYPE_INTEGER:
- if (!is_file_plugins_conf && option->default_value
- && (CONFIG_INTEGER(option) != CONFIG_INTEGER_DEFAULT(option)))
- {
- if (option->string_values)
- {
- display_default = option->string_values[CONFIG_INTEGER_DEFAULT(option)];
- }
- else
- {
- snprintf (str_default, sizeof (str_default),
- "%d", CONFIG_INTEGER_DEFAULT(option));
- display_default = str_default;
- }
- }
- if (option->string_values)
- {
- gui_chat_printf_date_tags (NULL, 0,
- "no_trigger," GUI_CHAT_TAG_NO_HIGHLIGHT,
- "%s%s.%s.%s%s = %s%s%s%s%s%s%s%s%s%s",
- (message) ? message : " ",
- (option->config_file) ? option->config_file->name : "",
- (option->section) ? option->section->name : "",
- option->name,
- GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
- GUI_COLOR(GUI_COLOR_CHAT_VALUE),
- option->string_values[CONFIG_INTEGER(option)],
- (display_default) ? GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS) : "",
- (display_default) ? " (" : "",
- (display_default) ? GUI_COLOR(GUI_COLOR_CHAT) : "",
- (display_default) ? _("default: ") : "",
- (display_default) ? GUI_COLOR(GUI_COLOR_CHAT_VALUE) : "",
- (display_default) ? display_default : "",
- (display_default) ? GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS) : "",
- (display_default) ? ")" : "");
- }
- else
- {
- gui_chat_printf_date_tags (NULL, 0,
- "no_trigger," GUI_CHAT_TAG_NO_HIGHLIGHT,
- "%s%s.%s.%s%s = %s%d%s%s%s%s%s%s%s%s",
- (message) ? message : " ",
- (option->config_file) ? option->config_file->name : "",
- (option->section) ? option->section->name : "",
- option->name,
- GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
- GUI_COLOR(GUI_COLOR_CHAT_VALUE),
- CONFIG_INTEGER(option),
- (display_default) ? GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS) : "",
- (display_default) ? " (" : "",
- (display_default) ? GUI_COLOR(GUI_COLOR_CHAT) : "",
- (display_default) ? _("default: ") : "",
- (display_default) ? GUI_COLOR(GUI_COLOR_CHAT_VALUE) : "",
- (display_default) ? display_default : "",
- (display_default) ? GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS) : "",
- (display_default) ? ")" : "");
- }
- break;
- case CONFIG_OPTION_TYPE_STRING:
- if (!is_file_plugins_conf && option->default_value
- && (strcmp (CONFIG_STRING(option), CONFIG_STRING_DEFAULT(option)) != 0))
- {
- display_default = CONFIG_STRING_DEFAULT(option);
- }
- gui_chat_printf_date_tags (NULL, 0,
- "no_trigger," GUI_CHAT_TAG_NO_HIGHLIGHT,
- "%s%s.%s.%s%s = \"%s%s%s\"%s%s%s%s%s%s%s%s%s%s%s",
- (message) ? message : " ",
- (option->config_file) ? option->config_file->name : "",
- (option->section) ? option->section->name : "",
- option->name,
- GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
- GUI_COLOR(GUI_COLOR_CHAT_VALUE),
- CONFIG_STRING(option),
- GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
- (display_default) ? GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS) : "",
- (display_default) ? " (" : "",
- (display_default) ? GUI_COLOR(GUI_COLOR_CHAT) : "",
- (display_default) ? _("default: ") : "",
- (display_default) ? GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS) : "",
- (display_default) && display_default != display_undefined ? "\"" : "",
- (display_default) ? GUI_COLOR(GUI_COLOR_CHAT_VALUE) : "",
- (display_default) ? display_default : "",
- (display_default) ? GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS) : "",
- (display_default) && display_default != display_undefined ? "\"" : "",
- (display_default) ? ")" : "");
- break;
- case CONFIG_OPTION_TYPE_COLOR:
- if (!is_file_plugins_conf && option->default_value
- && (CONFIG_COLOR(option) != CONFIG_COLOR_DEFAULT(option)))
- {
- display_default = gui_color_get_name (CONFIG_COLOR_DEFAULT(option));
- if (display_default == NULL)
- {
- display_default = _("(unknown)");
- }
- }
- color_name = gui_color_get_name (CONFIG_COLOR(option));
- gui_chat_printf_date_tags (NULL, 0,
- "no_trigger," GUI_CHAT_TAG_NO_HIGHLIGHT,
- "%s%s.%s.%s%s = %s%s%s%s%s%s%s%s%s%s",
- (message) ? message : " ",
- (option->config_file) ? option->config_file->name : "",
- (option->section) ? option->section->name : "",
- option->name,
- GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
- GUI_COLOR(GUI_COLOR_CHAT_VALUE),
- (color_name) ? color_name : _("(unknown)"),
- (display_default) ? GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS) : "",
- (display_default) ? " (" : "",
- (display_default) ? GUI_COLOR(GUI_COLOR_CHAT) : "",
- (display_default) ? _("default: ") : "",
- (display_default) ? GUI_COLOR(GUI_COLOR_CHAT_VALUE) : "",
- (display_default) ? display_default : "",
- (display_default) ? GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS) : "",
- (display_default) ? ")" : "");
- break;
- case CONFIG_NUM_OPTION_TYPES:
- /* make C compiler happy */
- break;
- }
+ config_file_search_with_string (option->parent_name, NULL, NULL,
+ &ptr_parent_option, NULL);
+ if (ptr_parent_option && (ptr_parent_option->type != option->type))
+ ptr_parent_option = NULL;
}
- else
+
+ /* check if the value is inherited from parent option */
+ if (!option->value && ptr_parent_option && ptr_parent_option->value)
+ is_value_inherited = 1;
+
+ value = config_file_option_value_to_string (option, 0, 1, 1);
+
+ if (is_value_inherited)
{
- gui_chat_printf_date_tags (NULL, 0,
- "no_trigger," GUI_CHAT_TAG_NO_HIGHLIGHT,
- "%s%s.%s.%s",
- (message) ? message : " ",
- (option->config_file) ? option->config_file->name : "",
- (option->section) ? option->section->name : "",
- option->name);
+ inherited_value = config_file_option_value_to_string (
+ ptr_parent_option, 0, 1, 1);
}
+
+ if (option->value)
+ {
+ if (ptr_parent_option)
+ {
+ is_default_value_inherited = 1;
+ default_value = config_file_option_value_to_string (
+ ptr_parent_option, 0, 1, 1);
+ }
+ else if (!is_file_plugins_conf
+ && config_file_option_has_changed (option))
+ {
+ default_value = config_file_option_value_to_string (
+ option, 1, 1, 1);
+ }
+ }
+
+ gui_chat_printf_date_tags (
+ NULL, 0,
+ "no_trigger," GUI_CHAT_TAG_NO_HIGHLIGHT,
+ "%s%s.%s.%s%s = %s%s%s%s%s%s%s%s%s%s%s",
+ (message) ? message : " ",
+ (option->config_file) ? option->config_file->name : "",
+ (option->section) ? option->section->name : "",
+ option->name,
+ GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
+ (value) ? value : "?",
+ (inherited_value) ? GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS) : "",
+ (inherited_value) ? " -> " : "",
+ (inherited_value) ? inherited_value : "",
+ (default_value) ? GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS) : "",
+ (default_value) ? " (" : "",
+ (default_value) ? GUI_COLOR(GUI_COLOR_CHAT) : "",
+ (default_value) ? ((is_default_value_inherited) ? _("default if null: ") : _("default: ")) : "",
+ (default_value) ? default_value : "",
+ (default_value) ? GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS) : "",
+ (default_value) ? ")" : "");
+
+ if (value)
+ free (value);
+ if (inherited_value)
+ free (inherited_value);
+ if (default_value)
+ free (default_value);
}
/*
@@ -5698,6 +5668,7 @@ COMMAND_CALLBACK(set)
struct t_weelist_item *item;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
@@ -5928,6 +5899,7 @@ COMMAND_CALLBACK(unset)
int mask, length, number_reset, number_removed;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
@@ -6023,6 +5995,7 @@ COMMAND_CALLBACK(upgrade)
int confirm_ok, index_args, rc, quit;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
@@ -6118,8 +6091,9 @@ COMMAND_CALLBACK(upgrade)
if (!ptr_binary && !quit)
{
gui_chat_printf (NULL,
- _("%sNot enough memory"),
- gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
+ _("%sNot enough memory (%s)"),
+ gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
+ "/upgrade");
return WEECHAT_RC_OK;
}
@@ -6174,12 +6148,12 @@ COMMAND_CALLBACK(upgrade)
execvp (exec_args[0], exec_args);
/* this code should not be reached if execvp is OK */
- string_iconv_fprintf (stderr, "\n\n*****\n");
- string_iconv_fprintf (stderr,
- _("***** Error: exec failed (program: \"%s\"), "
- "exiting WeeChat"),
- exec_args[0]);
- string_iconv_fprintf (stderr, "\n*****\n\n");
+ string_fprintf (stderr, "\n\n*****\n");
+ string_fprintf (stderr,
+ _("***** Error: exec failed (program: \"%s\"), "
+ "exiting WeeChat"),
+ exec_args[0]);
+ string_fprintf (stderr, "\n*****\n\n");
free (exec_args[0]);
free (exec_args[3]);
@@ -6201,6 +6175,7 @@ COMMAND_CALLBACK(uptime)
char string[512];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv_eol;
@@ -6215,7 +6190,7 @@ COMMAND_CALLBACK(uptime)
snprintf (string, sizeof (string),
"WeeChat uptime: %d %s %02d:%02d:%02d, started on %s",
day,
- (day > 1) ? "days" : "day",
+ (day != 1) ? "days" : "day",
hour,
min,
sec,
@@ -6350,6 +6325,7 @@ COMMAND_CALLBACK(version)
int send_to_buffer_as_input, translated_string;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv_eol;
@@ -6378,16 +6354,17 @@ COMMAND_CALLBACK(version)
*/
int
-command_wait_timer_cb (void *data, int remaining_calls)
+command_wait_timer_cb (const void *pointer, void *data, int remaining_calls)
{
char **timer_args;
int i;
struct t_gui_buffer *ptr_buffer;
/* make C compiler happy */
+ (void) data;
(void) remaining_calls;
- timer_args = (char **)data;
+ timer_args = (char **)pointer;
if (!timer_args)
return WEECHAT_RC_ERROR;
@@ -6425,6 +6402,7 @@ COMMAND_CALLBACK(wait)
char **timer_args;
/* make C compiler happy */
+ (void) pointer;
(void) data;
COMMAND_MIN_ARGS(3, "");
@@ -6474,8 +6452,9 @@ COMMAND_CALLBACK(wait)
if (!timer_args)
{
gui_chat_printf (NULL,
- _("%sNot enough memory"),
- gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
+ _("%sNot enough memory (%s)"),
+ gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
+ "/wait");
return WEECHAT_RC_OK;
}
timer_args[0] = strdup (buffer->full_name);
@@ -6483,7 +6462,7 @@ COMMAND_CALLBACK(wait)
/* schedule command, execute it after "delay" milliseconds */
hook_timer (NULL, delay, 0, 1,
- &command_wait_timer_cb, timer_args);
+ &command_wait_timer_cb, timer_args, NULL);
return WEECHAT_RC_OK;
}
@@ -6500,6 +6479,7 @@ COMMAND_CALLBACK(window)
int win_args;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
(void) argv_eol;
@@ -6872,7 +6852,7 @@ command_init ()
N_(" -all: set or remove away status on all connected servers\n"
"message: message for away (if no message is given, away status is "
"removed)"),
- "-all", &command_away, NULL);
+ "-all", &command_away, NULL, NULL);
hook_command (
NULL, "bar",
N_("manage bars"),
@@ -6944,7 +6924,7 @@ command_init ()
" || show %(bars_names)"
" || toggle %(bars_names)"
" || scroll %(bars_names) %(windows_numbers)|*",
- &command_bar, NULL);
+ &command_bar, NULL, NULL);
hook_command (
NULL, "buffer",
N_("manage buffers"),
@@ -6952,6 +6932,7 @@ command_init ()
" || clear [<number>|<name>|-merged|-all [<number>|<name>...]]"
" || move <number>|-|+"
" || swap <number1>|<name1> [<number2>|<name2>]"
+ " || cycle <number>|<name> [<number>|<name>...]]"
" || merge <number>"
" || unmerge [<number>|-all]"
" || hide [<number>|<name>|-all [<number>|<name>...]]"
@@ -6971,6 +6952,7 @@ command_init ()
"number + 1\n"
" swap: swap two buffers (swap with current buffer if only one "
"number/name given)\n"
+ " cycle: jump loop between a list of buffers\n"
" merge: merge current buffer to another buffer (chat area will "
"be mix of both buffers)\n"
" (by default ctrl-x switches between merged buffers)\n"
@@ -7008,6 +6990,8 @@ command_init ()
" /buffer swap 1 3\n"
" swap buffer #weechat with current buffer:\n"
" /buffer swap #weechat\n"
+ " jump on #chan1, #chan2, #chan3 and loop:\n"
+ " /buffer cycle #chan1 #chan2 #chan3\n"
" merge with core buffer:\n"
" /buffer merge 1\n"
" unmerge buffer:\n"
@@ -7025,7 +7009,9 @@ command_init ()
"clear -merged|-all|%(buffers_numbers)|%(buffers_plugins_names) "
"%(buffers_numbers)|%(buffers_plugins_names)|%*"
" || move %(buffers_numbers)"
- " || swap %(buffers_numbers)"
+ " || swap %(buffers_numbers)|%(buffers_plugins_names) "
+ "%(buffers_numbers)|%(buffers_plugins_names)"
+ " || cycle %(buffers_numbers)|%(buffers_plugins_names)|%*"
" || merge %(buffers_numbers)"
" || unmerge %(buffers_numbers)|-all"
" || hide %(buffers_numbers)|%(buffers_plugins_names)|-all "
@@ -7041,7 +7027,7 @@ command_init ()
" || get %(buffer_properties_get)"
" || %(buffers_plugins_names)|%(buffers_names)|%(irc_channels)|"
"%(irc_privates)|%(buffers_numbers)|-|-1|+|+1",
- &command_buffer, NULL);
+ &command_buffer, NULL, NULL);
hook_command (
NULL, "color",
N_("define color aliases and display palette of colors"),
@@ -7058,7 +7044,7 @@ command_init ()
" name: alias name for color (for example: \"orange\")\n"
" reset: reset all color pairs (required when no more color pairs "
"are available if automatic reset is disabled, see option "
- "weechat.look.color_pairs_auto_reset)\n"
+ "\"weechat.look.color_pairs_auto_reset\")\n"
"term2rgb: convert a terminal color (0-255) to RGB color\n"
"rgb2term: convert a RGB color to terminal color (0-255)\n"
" limit: number of colors to use in terminal table (starting from "
@@ -7078,7 +7064,7 @@ command_init ()
" || term2rgb"
" || rgb2term"
" || -o",
- &command_color, NULL);
+ &command_color, NULL, NULL);
/*
* give high priority (50000) so that an alias will not take precedence
* over this command
@@ -7096,7 +7082,7 @@ command_init ()
"-buffer %(buffers_plugins_names) "
"%(plugins_names)|" PLUGIN_CORE " %(plugins_commands)"
" || %(plugins_names)|" PLUGIN_CORE " %(plugins_commands)",
- &command_command, NULL);
+ &command_command, NULL, NULL);
hook_command (
NULL, "cursor",
N_("free movement of cursor on screen to execute actions on specific "
@@ -7134,7 +7120,7 @@ command_init ()
"go %(cursor_areas)"
" || move up|down|left|right|area_up|area_down|area_left|area_right"
" || stop",
- &command_cursor, NULL);
+ &command_cursor, NULL, NULL);
hook_command (
NULL, "debug",
N_("control debug for core/plugins"),
@@ -7180,7 +7166,7 @@ command_init ()
" || tags"
" || term"
" || windows",
- &command_debug, NULL);
+ &command_debug, NULL, NULL);
hook_command (
NULL, "eval",
N_("evaluate expression"),
@@ -7271,7 +7257,7 @@ command_init ()
" /eval -n -c abcd =~ (?-i)^abc ==> 1\n"
" /eval -n -c abcd !~ abc ==> 0"),
"-n|-s|-c -n|-s|-c",
- &command_eval, NULL);
+ &command_eval, NULL, NULL);
hook_command (
NULL, "filter",
N_("filter messages in buffers, to hide/show them according to tags or "
@@ -7354,7 +7340,7 @@ command_init ()
" || add %(filters_names) %(buffers_plugins_names)|*"
" || rename %(filters_names) %(filters_names)"
" || del %(filters_names)|-all",
- &command_filter, NULL);
+ &command_filter, NULL, NULL);
hook_command (
NULL, "help",
N_("display help about commands and options"),
@@ -7368,7 +7354,7 @@ command_init ()
"-list %(plugins_names)|" PLUGIN_CORE "|%*"
" || -listfull %(plugins_names)|" PLUGIN_CORE "|%*"
" || %(commands)|%(config_options)",
- &command_help, NULL);
+ &command_help, NULL, NULL);
hook_command (
NULL, "history",
N_("show buffer command history"),
@@ -7376,7 +7362,7 @@ command_init ()
N_("clear: clear history\n"
"value: number of history entries to show"),
"clear",
- &command_history, NULL);
+ &command_history, NULL, NULL);
/*
* give high priority (50000) so that an alias will not take precedence
* over this command
@@ -7426,7 +7412,10 @@ command_init ()
"last jump to a buffer)\n"
" jump_previously_visited_buffer: jump to previously visited buffer\n"
" jump_next_visited_buffer: jump to next visited buffer\n"
- " hotlist_clear: clear hotlist\n"
+ " hotlist_clear: clear hotlist (optional argument: \"lowest\" to "
+ "clear only lowest level in hotlist, \"highest\" to clear only "
+ "highest level in hotlist, or level mask: integer which is a "
+ "combination of 1=join/part, 2=message, 4=private, 8=highlight)\n"
" grab_key: grab a key (optional argument: delay for end of grab, "
"default is 500 milliseconds)\n"
" grab_key_command: grab a key with its associated command (optional "
@@ -7445,21 +7434,24 @@ command_init ()
" paste_stop: stop paste (bracketed paste mode)\n"
"\n"
"This command is used by key bindings or plugins."),
- "return|complete_next|complete_previous|search_text_here|search_text|"
- "search_switch_case|search_switch_regex|search_switch_where|"
- "search_previous|search_next|search_stop_here|search_stop|"
- "delete_previous_char|delete_next_char|delete_previous_word|"
- "delete_next_word|delete_beginning_of_line|delete_end_of_line|"
- "delete_line|clipboard_paste|transpose_chars|undo|redo|"
- "move_beginning_of_line|move_end_of_line|move_previous_char|"
- "move_next_char|move_previous_word|move_next_word|history_previous|"
- "history_next|history_global_previous|history_global_next|jump_smart|"
- "jump_last_buffer_displayed|jump_previously_visited_buffer|"
- "jump_next_visited_buffer|hotlist_clear|grab_key|grab_key_command|"
- "grab_mouse|grab_mouse_area|set_unread|set_unread_current_buffer|"
- "switch_active_buffer|switch_active_buffer_previous|"
- "zoom_merged_buffer|insert|send|paste_start|paste_stop",
- &command_input, NULL);
+ "return || complete_next || complete_previous || search_text_here || "
+ "search_text || search_switch_case || search_switch_regex || "
+ "search_switch_where || search_previous || search_next || "
+ "search_stop_here || search_stop || delete_previous_char || "
+ "delete_next_char || delete_previous_word || delete_next_word || "
+ "delete_beginning_of_line || delete_end_of_line || delete_line || "
+ "clipboard_paste || transpose_chars || undo || redo || "
+ "move_beginning_of_line || move_end_of_line || move_previous_char || "
+ "move_next_char || move_previous_word || move_next_word || "
+ "history_previous || history_next || history_global_previous || "
+ "history_global_next || jump_smart || jump_last_buffer_displayed || "
+ "jump_previously_visited_buffer || jump_next_visited_buffer || "
+ "hotlist_clear 1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|lowest|highest || "
+ "grab_key || grab_key_command || grab_mouse || grab_mouse_area || "
+ "set_unread || set_unread_current_buffer || switch_active_buffer || "
+ "switch_active_buffer_previous || zoom_merged_buffer || insert || "
+ "send || paste_start || paste_stop",
+ &command_input, NULL, NULL);
hook_command (
NULL, "key",
N_("bind/unbind keys"),
@@ -7515,8 +7507,8 @@ command_init ()
"ignored when looking for keys).\n"
"\n"
"Examples:\n"
- " key alt-x to toggle nicklist bar:\n"
- " /key bind meta-x /bar toggle nicklist\n"
+ " key alt-t to toggle nicklist bar:\n"
+ " /key bind meta-t /bar toggle nicklist\n"
" key alt-r to jump to #weechat IRC channel:\n"
" /key bind meta-r /buffer #weechat\n"
" restore default binding for key alt-r:\n"
@@ -7537,7 +7529,7 @@ command_init ()
" || resetctxt %(keys_contexts) %(keys_codes_for_reset)"
" || resetall %- %(keys_contexts)"
" || missing %(keys_contexts)",
- &command_key, NULL);
+ &command_key, NULL, NULL);
hook_command (
NULL, "layout",
N_("manage buffers/windows layouts"),
@@ -7555,15 +7547,19 @@ command_init ()
" rename: rename a layout\n"
" name: name for stored layout (default is \"default\")\n"
"buffers: store/apply only buffers (order of buffers)\n"
- "windows: store/apply only windows (buffer displayed by each window)\n"
+ "windows: store/apply only windows (buffer displayed by each "
+ "window)\n"
+ "\n"
+ "Without argument, this command displays stored layouts.\n"
"\n"
- "Without argument, this command displays stored layouts."),
+ "The current layout can be saved on /quit command with the option "
+ "\"weechat.look.save_layout_on_exit\"."),
"store %(layouts_names)|buffers|windows buffers|windows"
" || apply %(layouts_names)|buffers|windows buffers|windows"
" || leave"
" || del %(layouts_names)|buffers|windows buffers|windows"
" || rename %(layouts_names) %(layouts_names)",
- &command_layout, NULL);
+ &command_layout, NULL, NULL);
hook_command (
NULL, "mouse",
N_("mouse control"),
@@ -7582,7 +7578,7 @@ command_init ()
" toggle mouse for 5 seconds:\n"
" /mouse toggle 5"),
"enable|disable|toggle",
- &command_mouse, NULL);
+ &command_mouse, NULL, NULL);
hook_command (
NULL, "mute",
N_("execute a command silently"),
@@ -7608,7 +7604,7 @@ command_init ()
"-core|-current %(commands)|%*"
" || -buffer %(buffers_plugins_names) %(commands)|%*"
" || %(commands)|%*",
- &command_mute, NULL);
+ &command_mute, NULL, NULL);
hook_command (
NULL, "plugin",
N_("list/load/unload plugins"),
@@ -7635,7 +7631,7 @@ command_init ()
" || autoload"
" || reload %(plugins_names)|* -a|-s"
" || unload %(plugins_names)",
- &command_plugin, NULL);
+ &command_plugin, NULL, NULL);
hook_command (
NULL, "print",
N_("display text on a buffer"),
@@ -7689,7 +7685,7 @@ command_init ()
" || -stdout"
" || -stderr"
" || -beep",
- &command_print, NULL);
+ &command_print, NULL, NULL);
hook_command (
NULL, "proxy",
N_("manage proxies"),
@@ -7725,17 +7721,23 @@ command_init ()
" || add %(proxies_names) http|socks4|socks5"
" || del %(proxies_names)"
" || set %(proxies_names) %(proxies_options)",
- &command_proxy, NULL);
+ &command_proxy, NULL, NULL);
hook_command (
NULL, "quit",
N_("quit WeeChat"),
N_("[-yes] [<arguments>]"),
- N_(" -yes: required if option weechat.look.confirm_quit is enabled\n"
+ N_(" -yes: required if option \"weechat.look.confirm_quit\" "
+ "is enabled\n"
"arguments: text sent with signal \"quit\"\n"
" (for example irc plugin uses this text to send quit "
- "message to server)"),
+ "message to server)\n"
+ "\n"
+ "By default when quitting the configuration files are saved "
+ "(see option \"weechat.look.save_config_on_exit\") and the current "
+ "layout can be saved (see option "
+ "\"weechat.look.save_layout_on_exit\")."),
"",
- &command_quit, NULL);
+ &command_quit, NULL, NULL);
hook_command (
NULL, "reload",
N_("reload configuration files from disk"),
@@ -7744,7 +7746,7 @@ command_init ()
"\n"
"Without argument, all files (WeeChat and plugins) are reloaded."),
"%(config_files)|%*",
- &command_reload, NULL);
+ &command_reload, NULL, NULL);
hook_command (
NULL, "repeat",
N_("execute a command several times"),
@@ -7760,16 +7762,19 @@ command_init ()
" scroll 2 pages up:\n"
" /repeat 2 /window page_up"),
"%- %(commands)",
- &command_repeat, NULL);
+ &command_repeat, NULL, NULL);
hook_command (
NULL, "save",
N_("save configuration files to disk"),
N_("[<file> [<file>...]]"),
N_("file: configuration file to save (without extension \".conf\")\n"
"\n"
- "Without argument, all files (WeeChat and plugins) are saved."),
+ "Without argument, all files (WeeChat and plugins) are saved.\n"
+ "\n"
+ "By default all configuration files are saved to disk on /quit "
+ "command (see option \"weechat.look.save_config_on_exit\")."),
"%(config_files)|%*",
- &command_save, NULL);
+ &command_save, NULL, NULL);
hook_command (
NULL, "secure",
N_("manage secured data (passwords or private data encrypted in file "
@@ -7790,6 +7795,9 @@ command_init ()
"Without argument, this command displays secured data in a new "
"buffer.\n"
"\n"
+ "Keys on secure buffer:\n"
+ " alt+v toggle values\n"
+ "\n"
"When a passphrase is used (data encrypted), it is asked by WeeChat "
"on startup.\n"
"It is possible to set environment variable \"WEECHAT_PASSPHRASE\" "
@@ -7821,7 +7829,7 @@ command_init ()
" || decrypt -discard"
" || set %(secured_data)"
" || del %(secured_data)",
- &command_secure, NULL);
+ &command_secure, NULL, NULL);
hook_command (
NULL, "set",
N_("set config options and environment variables"),
@@ -7860,7 +7868,7 @@ command_init ()
"%(config_options) %(config_option_values)"
" || diff %(config_options)|%*"
" || env %(env_vars) %(env_value)",
- &command_set, NULL);
+ &command_set, NULL, NULL);
hook_command (
NULL, "unset",
N_("unset/reset config options"),
@@ -7880,12 +7888,12 @@ command_init ()
" /unset -mask weechat.color.*"),
"%(config_options)"
" || -mask %(config_options)",
- &command_unset, NULL);
+ &command_unset, NULL, NULL);
hook_command (
NULL, "upgrade",
N_("upgrade WeeChat without disconnecting from servers"),
N_("[-yes] [<path_to_binary>|-quit]"),
- N_(" -yes: required if option weechat.look.confirm_upgrade "
+ N_(" -yes: required if option \"weechat.look.confirm_upgrade\" "
"is enabled\n"
"path_to_binary: path to WeeChat binary (default is current binary)\n"
" -dummy: do nothing (option used to prevent accidental "
@@ -7921,7 +7929,7 @@ command_init ()
"It is possible to restore WeeChat session on another machine if you "
"copy the content of directory \"~/.weechat\"."),
"%(filename)|-dummy|-quit",
- &command_upgrade, NULL);
+ &command_upgrade, NULL, NULL);
hook_command (
NULL, "uptime",
N_("show WeeChat uptime"),
@@ -7929,7 +7937,7 @@ command_init ()
N_(" -o: send uptime to current buffer as input (English string)\n"
"-ol: send uptime to current buffer as input (translated string)"),
"-o|-ol",
- &command_uptime, NULL);
+ &command_uptime, NULL, NULL);
hook_command (
NULL, "version",
N_("show WeeChat version and compilation date"),
@@ -7941,7 +7949,7 @@ command_init ()
"all buffers (otherwise the irc command /version is used on irc "
"buffers)."),
"-o|-ol",
- &command_version, NULL);
+ &command_version, NULL, NULL);
hook_command (
NULL, "wait",
N_("schedule a command execution in future"),
@@ -7968,7 +7976,7 @@ command_init ()
" say 'hello' in 2 minutes:\n"
" /wait 2m hello"),
"%- %(commands)",
- &command_wait, NULL);
+ &command_wait, NULL, NULL);
hook_command (
NULL, "window",
N_("manage windows"),
@@ -8074,7 +8082,7 @@ command_init ()
" || merge all|-window %(windows_numbers)"
" || bare"
" || %(windows_numbers)",
- &command_window, NULL);
+ &command_window, NULL, NULL);
}
/*
diff --git a/src/core/wee-command.h b/src/core/wee-command.h
index 759f911a5..365fe7a3f 100644
--- a/src/core/wee-command.h
+++ b/src/core/wee-command.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2005-2006 Emmanuel Bouthenot <kolter@openics.org>
*
* This file is part of WeeChat, the extensible chat client.
@@ -23,7 +23,8 @@
#define COMMAND_CALLBACK(__command) \
int \
- command_##__command (void *data, struct t_gui_buffer *buffer, \
+ command_##__command (const void *pointer, void *data, \
+ struct t_gui_buffer *buffer, \
int argc, char **argv, char **argv_eol)
/*
@@ -34,9 +35,11 @@
*/
#define COMMAND_EMPTY(__command) \
int \
- command_##__command (void *data, struct t_gui_buffer *buffer, \
+ command_##__command (const void *pointer, void *data, \
+ struct t_gui_buffer *buffer, \
int argc, char **argv, char **argv_eol) \
{ \
+ (void) pointer; \
(void) data; \
(void) buffer; \
(void) argc; \
@@ -80,8 +83,6 @@
struct t_gui_buffer;
-extern int command_reload (void *data, struct t_gui_buffer *buffer,
- int argc, char **argv, char **argv_eol);
extern void command_init ();
extern void command_startup (int plugins_loaded);
extern void command_version_display (struct t_gui_buffer *buffer,
diff --git a/src/core/wee-completion.c b/src/core/wee-completion.c
index 489b5fecf..a1faeeae8 100644
--- a/src/core/wee-completion.c
+++ b/src/core/wee-completion.c
@@ -1,7 +1,7 @@
/*
* wee-completion.c - completion for WeeChat commands
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org>
*
* This file is part of WeeChat, the extensible chat client.
@@ -64,7 +64,7 @@ extern char **environ;
*/
int
-completion_list_add_bars_names_cb (void *data,
+completion_list_add_bars_names_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -72,6 +72,7 @@ completion_list_add_bars_names_cb (void *data,
struct t_gui_bar *ptr_bar;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -90,7 +91,7 @@ completion_list_add_bars_names_cb (void *data,
*/
int
-completion_list_add_bars_options_cb (void *data,
+completion_list_add_bars_options_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -98,6 +99,7 @@ completion_list_add_bars_options_cb (void *data,
int i;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -116,7 +118,7 @@ completion_list_add_bars_options_cb (void *data,
*/
int
-completion_list_add_buffers_names_cb (void *data,
+completion_list_add_buffers_names_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -124,6 +126,7 @@ completion_list_add_buffers_names_cb (void *data,
struct t_gui_buffer *ptr_buffer;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -143,7 +146,7 @@ completion_list_add_buffers_names_cb (void *data,
*/
int
-completion_list_add_buffers_numbers_cb (void *data,
+completion_list_add_buffers_numbers_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -152,6 +155,7 @@ completion_list_add_buffers_numbers_cb (void *data,
char str_number[32];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -172,7 +176,7 @@ completion_list_add_buffers_numbers_cb (void *data,
*/
int
-completion_list_add_buffers_plugins_names_cb (void *data,
+completion_list_add_buffers_plugins_names_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -180,6 +184,7 @@ completion_list_add_buffers_plugins_names_cb (void *data,
struct t_gui_buffer *ptr_buffer;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -199,7 +204,7 @@ completion_list_add_buffers_plugins_names_cb (void *data,
*/
int
-completion_list_add_buffer_properties_set_cb (void *data,
+completion_list_add_buffer_properties_set_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -207,6 +212,7 @@ completion_list_add_buffer_properties_set_cb (void *data,
int i;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -226,7 +232,7 @@ completion_list_add_buffer_properties_set_cb (void *data,
*/
int
-completion_list_add_buffer_properties_get_cb (void *data,
+completion_list_add_buffer_properties_get_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -234,6 +240,7 @@ completion_list_add_buffer_properties_get_cb (void *data,
int i;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -265,7 +272,7 @@ completion_list_add_buffer_properties_get_cb (void *data,
*/
int
-completion_list_add_windows_numbers_cb (void *data,
+completion_list_add_windows_numbers_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -274,6 +281,7 @@ completion_list_add_windows_numbers_cb (void *data,
char str_number[32];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -293,7 +301,7 @@ completion_list_add_windows_numbers_cb (void *data,
*/
int
-completion_list_add_colors_cb (void *data,
+completion_list_add_colors_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -304,6 +312,7 @@ completion_list_add_colors_cb (void *data,
struct t_gui_color_palette *color_palette;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -367,12 +376,13 @@ completion_list_map_add_palette_color_cb (void *data,
*/
int
-completion_list_add_palette_colors_cb (void *data,
+completion_list_add_palette_colors_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -389,7 +399,7 @@ completion_list_add_palette_colors_cb (void *data,
*/
int
-completion_list_add_config_files_cb (void *data,
+completion_list_add_config_files_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -397,6 +407,7 @@ completion_list_add_config_files_cb (void *data,
struct t_config_file *ptr_config_file;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -416,7 +427,7 @@ completion_list_add_config_files_cb (void *data,
*/
int
-completion_list_add_filename_cb (void *data,
+completion_list_add_filename_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -430,6 +441,7 @@ completion_list_add_filename_cb (void *data,
struct stat statbuf;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -549,7 +561,7 @@ end:
*/
int
-completion_list_add_filters_cb (void *data,
+completion_list_add_filters_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -557,6 +569,7 @@ completion_list_add_filters_cb (void *data,
struct t_gui_filter *ptr_filter;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -576,7 +589,7 @@ completion_list_add_filters_cb (void *data,
*/
int
-completion_list_add_commands_cb (void *data,
+completion_list_add_commands_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -584,6 +597,7 @@ completion_list_add_commands_cb (void *data,
struct t_hook *ptr_hook;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -607,7 +621,7 @@ completion_list_add_commands_cb (void *data,
*/
int
-completion_list_add_infos_cb (void *data,
+completion_list_add_infos_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -615,6 +629,7 @@ completion_list_add_infos_cb (void *data,
struct t_hook *ptr_hook;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -638,7 +653,7 @@ completion_list_add_infos_cb (void *data,
*/
int
-completion_list_add_infolists_cb (void *data,
+completion_list_add_infolists_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -646,6 +661,7 @@ completion_list_add_infolists_cb (void *data,
struct t_hook *ptr_hook;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -669,7 +685,7 @@ completion_list_add_infolists_cb (void *data,
*/
int
-completion_list_add_nicks_cb (void *data,
+completion_list_add_nicks_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -679,6 +695,7 @@ completion_list_add_nicks_cb (void *data,
int count_before;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -719,7 +736,7 @@ completion_list_add_nicks_cb (void *data,
*/
int
-completion_list_add_config_options_cb (void *data,
+completion_list_add_config_options_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -731,6 +748,7 @@ completion_list_add_config_options_cb (void *data,
char *option_full_name;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -770,7 +788,7 @@ completion_list_add_config_options_cb (void *data,
*/
int
-completion_list_add_plugins_cb (void *data,
+completion_list_add_plugins_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -778,6 +796,7 @@ completion_list_add_plugins_cb (void *data,
struct t_weechat_plugin *ptr_plugin;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -797,7 +816,8 @@ completion_list_add_plugins_cb (void *data,
*/
void
-completion_list_add_plugins_installed_exec_cb (void *data, const char *filename)
+completion_list_add_plugins_installed_exec_cb (void *data,
+ const char *filename)
{
struct t_gui_completion *completion;
const char *pos, *pos2;
@@ -831,7 +851,7 @@ completion_list_add_plugins_installed_exec_cb (void *data, const char *filename)
*/
int
-completion_list_add_plugins_installed_cb (void *data,
+completion_list_add_plugins_installed_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -840,6 +860,7 @@ completion_list_add_plugins_installed_cb (void *data,
int length;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -858,8 +879,8 @@ completion_list_add_plugins_installed_cb (void *data,
plugin_path2 : ((plugin_path) ?
plugin_path : CONFIG_STRING(config_plugin_path)),
0,
- completion,
- &completion_list_add_plugins_installed_exec_cb);
+ &completion_list_add_plugins_installed_exec_cb,
+ completion);
if (plugin_path)
free (plugin_path);
if (plugin_path2)
@@ -872,8 +893,9 @@ completion_list_add_plugins_installed_cb (void *data,
if (dir_name)
{
snprintf (dir_name, length, "%s/plugins", WEECHAT_LIBDIR);
- util_exec_on_files (dir_name, 0, completion,
- &completion_list_add_plugins_installed_exec_cb);
+ util_exec_on_files (dir_name, 0,
+ &completion_list_add_plugins_installed_exec_cb,
+ completion);
free (dir_name);
}
@@ -887,7 +909,7 @@ completion_list_add_plugins_installed_cb (void *data,
*/
int
-completion_list_add_plugins_commands_cb (void *data,
+completion_list_add_plugins_commands_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -898,6 +920,7 @@ completion_list_add_plugins_commands_cb (void *data,
struct t_hook *ptr_hook;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -951,7 +974,7 @@ completion_list_add_plugins_commands_cb (void *data,
*/
int
-completion_list_add_config_option_values_cb (void *data,
+completion_list_add_config_option_values_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -965,7 +988,6 @@ completion_list_add_config_option_values_cb (void *data,
struct t_config_option *option_found;
/* make C compiler happy */
- (void) data;
(void) completion_item;
(void) buffer;
@@ -1122,7 +1144,8 @@ completion_list_add_config_option_values_cb (void *data,
break;
case CONFIG_OPTION_TYPE_COLOR:
completion_list_add_colors_cb (
- data, completion_item, buffer, completion);
+ pointer, data, completion_item, buffer,
+ completion);
gui_completion_list_add (completion, "++1",
0, WEECHAT_LIST_POS_END);
gui_completion_list_add (completion, "--1",
@@ -1175,7 +1198,7 @@ completion_list_add_config_option_values_cb (void *data,
*/
int
-completion_list_add_weechat_commands_cb (void *data,
+completion_list_add_weechat_commands_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -1183,6 +1206,7 @@ completion_list_add_weechat_commands_cb (void *data,
struct t_hook *ptr_hook;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -1209,7 +1233,7 @@ completion_list_add_weechat_commands_cb (void *data,
*/
int
-completion_list_add_proxies_names_cb (void *data,
+completion_list_add_proxies_names_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -1217,6 +1241,7 @@ completion_list_add_proxies_names_cb (void *data,
struct t_proxy *ptr_proxy;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -1236,7 +1261,7 @@ completion_list_add_proxies_names_cb (void *data,
*/
int
-completion_list_add_proxies_options_cb (void *data,
+completion_list_add_proxies_options_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -1244,6 +1269,7 @@ completion_list_add_proxies_options_cb (void *data,
int i;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -1262,7 +1288,7 @@ completion_list_add_proxies_options_cb (void *data,
*/
int
-completion_list_add_keys_contexts_cb (void *data,
+completion_list_add_keys_contexts_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -1270,6 +1296,7 @@ completion_list_add_keys_contexts_cb (void *data,
int i;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -1288,7 +1315,7 @@ completion_list_add_keys_contexts_cb (void *data,
*/
int
-completion_list_add_keys_codes_cb (void *data,
+completion_list_add_keys_codes_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -1298,6 +1325,7 @@ completion_list_add_keys_codes_cb (void *data,
char *expanded_name;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -1325,7 +1353,7 @@ completion_list_add_keys_codes_cb (void *data,
*/
int
-completion_list_add_keys_codes_for_reset_cb (void *data,
+completion_list_add_keys_codes_for_reset_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -1335,6 +1363,7 @@ completion_list_add_keys_codes_for_reset_cb (void *data,
char *expanded_name;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -1385,7 +1414,7 @@ completion_list_add_keys_codes_for_reset_cb (void *data,
*/
int
-completion_list_add_cursor_areas_cb (void *data,
+completion_list_add_cursor_areas_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -1394,6 +1423,7 @@ completion_list_add_cursor_areas_cb (void *data,
struct t_gui_bar *ptr_bar;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -1425,7 +1455,7 @@ completion_list_add_cursor_areas_cb (void *data,
*/
int
-completion_list_add_layouts_names_cb (void *data,
+completion_list_add_layouts_names_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -1433,6 +1463,7 @@ completion_list_add_layouts_names_cb (void *data,
struct t_gui_layout *ptr_layout;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -1470,12 +1501,13 @@ completion_list_map_add_secured_data_cb (void *data,
*/
int
-completion_list_add_secured_data_cb (void *data,
+completion_list_add_secured_data_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -1492,7 +1524,7 @@ completion_list_add_secured_data_cb (void *data,
*/
int
-completion_list_add_env_vars_cb (void *data,
+completion_list_add_env_vars_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -1501,6 +1533,7 @@ completion_list_add_env_vars_cb (void *data,
char *pos, *name;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -1528,7 +1561,7 @@ completion_list_add_env_vars_cb (void *data,
*/
int
-completion_list_add_env_value_cb (void *data,
+completion_list_add_env_value_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -1537,6 +1570,7 @@ completion_list_add_env_value_cb (void *data,
int argc, arg_index;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -1574,106 +1608,106 @@ completion_init ()
{
hook_completion (NULL, "buffers_names", /* formerly "%b" */
N_("names of buffers"),
- &completion_list_add_buffers_names_cb, NULL);
+ &completion_list_add_buffers_names_cb, NULL, NULL);
hook_completion (NULL, "buffers_numbers",
N_("numbers of buffers"),
- &completion_list_add_buffers_numbers_cb, NULL);
+ &completion_list_add_buffers_numbers_cb, NULL, NULL);
hook_completion (NULL, "buffers_plugins_names", /* formerly "%B" */
N_("names of buffers (including plugins names)"),
- &completion_list_add_buffers_plugins_names_cb, NULL);
+ &completion_list_add_buffers_plugins_names_cb, NULL, NULL);
hook_completion (NULL, "buffer_properties_set",
N_("properties that can be set on a buffer"),
- &completion_list_add_buffer_properties_set_cb, NULL);
+ &completion_list_add_buffer_properties_set_cb, NULL, NULL);
hook_completion (NULL, "buffer_properties_get",
N_("properties that can be read on a buffer"),
- &completion_list_add_buffer_properties_get_cb, NULL);
+ &completion_list_add_buffer_properties_get_cb, NULL, NULL);
hook_completion (NULL, "windows_numbers",
N_("numbers of windows"),
- &completion_list_add_windows_numbers_cb, NULL);
+ &completion_list_add_windows_numbers_cb, NULL, NULL);
hook_completion (NULL, "colors",
N_("color names"),
- &completion_list_add_colors_cb, NULL);
+ &completion_list_add_colors_cb, NULL, NULL);
hook_completion (NULL, "palette_colors",
N_("palette colors"),
- &completion_list_add_palette_colors_cb, NULL);
+ &completion_list_add_palette_colors_cb, NULL, NULL);
hook_completion (NULL, "config_files", /* formerly "%c" */
N_("configuration files"),
- &completion_list_add_config_files_cb, NULL);
+ &completion_list_add_config_files_cb, NULL, NULL);
hook_completion (NULL, "filename", /* formerly "%f" */
N_("filename"),
- &completion_list_add_filename_cb, NULL);
+ &completion_list_add_filename_cb, NULL, NULL);
hook_completion (NULL, "filters_names", /* formerly "%F" */
N_("names of filters"),
- &completion_list_add_filters_cb, NULL);
+ &completion_list_add_filters_cb, NULL, NULL);
hook_completion (NULL, "commands", /* formerly "%h" */
N_("commands (weechat and plugins)"),
- &completion_list_add_commands_cb, NULL);
+ &completion_list_add_commands_cb, NULL, NULL);
hook_completion (NULL, "infos", /* formerly "%i" */
N_("names of infos hooked"),
- &completion_list_add_infos_cb, NULL);
+ &completion_list_add_infos_cb, NULL, NULL);
hook_completion (NULL, "infolists", /* formerly "%I" */
N_("names of infolists hooked"),
- &completion_list_add_infolists_cb, NULL);
+ &completion_list_add_infolists_cb, NULL, NULL);
hook_completion (NULL, "nicks", /* formerly "%n" */
N_("nicks in nicklist of current buffer"),
- &completion_list_add_nicks_cb, NULL);
+ &completion_list_add_nicks_cb, NULL, NULL);
hook_completion (NULL, "config_options", /* formerly "%o" */
N_("configuration options"),
- &completion_list_add_config_options_cb, NULL);
+ &completion_list_add_config_options_cb, NULL, NULL);
hook_completion (NULL, "plugins_names", /* formerly "%p" */
N_("names of plugins"),
- &completion_list_add_plugins_cb, NULL);
+ &completion_list_add_plugins_cb, NULL, NULL);
hook_completion (NULL, "plugins_installed",
N_("names of plugins installed"),
- &completion_list_add_plugins_installed_cb, NULL);
+ &completion_list_add_plugins_installed_cb, NULL, NULL);
hook_completion (NULL, "plugins_commands", /* formerly "%P" */
N_("commands defined by plugins"),
- &completion_list_add_plugins_commands_cb, NULL);
+ &completion_list_add_plugins_commands_cb, NULL, NULL);
hook_completion (NULL, "bars_names", /* formerly "%r" */
N_("names of bars"),
- &completion_list_add_bars_names_cb, NULL);
+ &completion_list_add_bars_names_cb, NULL, NULL);
hook_completion (NULL, "config_option_values", /* formerly "%v" */
N_("values for a configuration option"),
- &completion_list_add_config_option_values_cb, NULL);
+ &completion_list_add_config_option_values_cb, NULL, NULL);
hook_completion (NULL, "weechat_commands", /* formerly "%w" */
N_("weechat commands"),
- &completion_list_add_weechat_commands_cb, NULL);
+ &completion_list_add_weechat_commands_cb, NULL, NULL);
hook_completion (NULL, "proxies_names", /* formerly "%y" */
N_("names of proxies"),
- &completion_list_add_proxies_names_cb, NULL);
+ &completion_list_add_proxies_names_cb, NULL, NULL);
hook_completion (NULL, "proxies_options",
N_("options for proxies"),
- &completion_list_add_proxies_options_cb, NULL);
+ &completion_list_add_proxies_options_cb, NULL, NULL);
hook_completion (NULL, "bars_options",
N_("options for bars"),
- &completion_list_add_bars_options_cb, NULL);
+ &completion_list_add_bars_options_cb, NULL, NULL);
hook_completion (NULL, "keys_contexts",
/* TRANSLATORS: "key" means "key on the keyboard" */
N_("key contexts"),
- &completion_list_add_keys_contexts_cb, NULL);
+ &completion_list_add_keys_contexts_cb, NULL, NULL);
hook_completion (NULL, "keys_codes",
/* TRANSLATORS: "key" means "key on the keyboard" */
N_("key codes"),
- &completion_list_add_keys_codes_cb, NULL);
+ &completion_list_add_keys_codes_cb, NULL, NULL);
hook_completion (NULL, "keys_codes_for_reset",
/* TRANSLATORS: "key" means "key on the keyboard" */
N_("key codes that can be reset (keys added, redefined "
"or removed)"),
- &completion_list_add_keys_codes_for_reset_cb, NULL);
+ &completion_list_add_keys_codes_for_reset_cb, NULL, NULL);
hook_completion (NULL, "cursor_areas",
N_("areas (\"chat\" or bar name) for free cursor "
"movement"),
- &completion_list_add_cursor_areas_cb, NULL);
+ &completion_list_add_cursor_areas_cb, NULL, NULL);
hook_completion (NULL, "layouts_names",
N_("names of layouts"),
- &completion_list_add_layouts_names_cb, NULL);
+ &completion_list_add_layouts_names_cb, NULL, NULL);
hook_completion (NULL, "secured_data",
N_("names of secured data (file sec.conf, section data)"),
- &completion_list_add_secured_data_cb, NULL);
+ &completion_list_add_secured_data_cb, NULL, NULL);
hook_completion (NULL, "env_vars",
N_("environment variables"),
- &completion_list_add_env_vars_cb, NULL);
+ &completion_list_add_env_vars_cb, NULL, NULL);
hook_completion (NULL, "env_value",
N_("value of an environment variable"),
- &completion_list_add_env_value_cb, NULL);
+ &completion_list_add_env_value_cb, NULL, NULL);
}
diff --git a/src/core/wee-completion.h b/src/core/wee-completion.h
index 96204b4e5..1763b341f 100644
--- a/src/core/wee-completion.h
+++ b/src/core/wee-completion.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -23,7 +23,8 @@
struct t_gui_buffer;
struct t_gui_completion;
-extern int completion_list_add_filename_cb (void *data,
+extern int completion_list_add_filename_cb (const void *pointer,
+ void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion);
diff --git a/src/core/wee-config-file.c b/src/core/wee-config-file.c
index 473efb640..7a6f3591f 100644
--- a/src/core/wee-config-file.c
+++ b/src/core/wee-config-file.c
@@ -1,7 +1,7 @@
/*
* wee-config-file.c - configuration files/sections/options management
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2005-2006 Emmanuel Bouthenot <kolter@openics.org>
*
* This file is part of WeeChat, the extensible chat client.
@@ -160,8 +160,10 @@ config_file_config_insert (struct t_config_file *config_file)
struct t_config_file *
config_file_new (struct t_weechat_plugin *plugin, const char *name,
- int (*callback_reload)(void *data,
+ int (*callback_reload)(const void *pointer,
+ void *data,
struct t_config_file *config_file),
+ const void *callback_reload_pointer,
void *callback_reload_data)
{
struct t_config_file *new_config_file;
@@ -203,6 +205,7 @@ config_file_new (struct t_weechat_plugin *plugin, const char *name,
}
new_config_file->file = NULL;
new_config_file->callback_reload = callback_reload;
+ new_config_file->callback_reload_pointer = callback_reload_pointer;
new_config_file->callback_reload_data = callback_reload_data;
new_config_file->sections = NULL;
new_config_file->last_section = NULL;
@@ -299,30 +302,40 @@ config_file_section_insert_in_config (struct t_config_section *section)
struct t_config_section *
config_file_new_section (struct t_config_file *config_file, const char *name,
int user_can_add_options, int user_can_delete_options,
- int (*callback_read)(void *data,
+ int (*callback_read)(const void *pointer,
+ void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
const char *value),
+ const void *callback_read_pointer,
void *callback_read_data,
- int (*callback_write)(void *data,
+ int (*callback_write)(const void *pointer,
+ void *data,
struct t_config_file *config_file,
const char *section_name),
+ const void *callback_write_pointer,
void *callback_write_data,
- int (*callback_write_default)(void *data,
+ int (*callback_write_default)(const void *pointer,
+ void *data,
struct t_config_file *config_file,
const char *section_name),
+ const void *callback_write_default_pointer,
void *callback_write_default_data,
- int (*callback_create_option)(void *data,
+ int (*callback_create_option)(const void *pointer,
+ void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
const char *value),
+ const void *callback_create_option_pointer,
void *callback_create_option_data,
- int (*callback_delete_option)(void *data,
+ int (*callback_delete_option)(const void *pointer,
+ void *data,
struct t_config_file *config_file,
struct t_config_section *section,
struct t_config_option *option),
+ const void *callback_delete_option_pointer,
void *callback_delete_option_data)
{
struct t_config_section *new_section;
@@ -346,14 +359,19 @@ config_file_new_section (struct t_config_file *config_file, const char *name,
new_section->user_can_add_options = user_can_add_options;
new_section->user_can_delete_options = user_can_delete_options;
new_section->callback_read = callback_read;
+ new_section->callback_read_pointer = callback_read_pointer;
new_section->callback_read_data = callback_read_data;
new_section->callback_write = callback_write;
+ new_section->callback_write_pointer = callback_write_pointer;
new_section->callback_write_data = callback_write_data;
new_section->callback_write_default = callback_write_default;
+ new_section->callback_write_default_pointer = callback_write_default_pointer;
new_section->callback_write_default_data = callback_write_default_data;
new_section->callback_create_option = callback_create_option;
+ new_section->callback_create_option_pointer = callback_create_option_pointer;
new_section->callback_create_option_data = callback_create_option_data;
new_section->callback_delete_option = callback_delete_option;
+ new_section->callback_delete_option_pointer = callback_delete_option_pointer;
new_section->callback_delete_option_data = callback_delete_option_data;
new_section->options = NULL;
new_section->last_option = NULL;
@@ -565,6 +583,7 @@ config_file_option_malloc ()
new_option->config_file = NULL;
new_option->section = NULL;
new_option->name = NULL;
+ new_option->parent_name = NULL;
new_option->type = 0;
new_option->description = NULL;
new_option->string_values = NULL;
@@ -574,10 +593,13 @@ config_file_option_malloc ()
new_option->value = NULL;
new_option->null_value_allowed = 0;
new_option->callback_check_value = NULL;
+ new_option->callback_check_value_pointer = NULL;
new_option->callback_check_value_data = NULL;
new_option->callback_change = NULL;
+ new_option->callback_change_pointer = NULL;
new_option->callback_change_data = NULL;
new_option->callback_delete = NULL;
+ new_option->callback_delete_pointer = NULL;
new_option->callback_delete_data = NULL;
new_option->loaded = 0;
new_option->prev_option = NULL;
@@ -601,28 +623,51 @@ config_file_new_option (struct t_config_file *config_file,
const char *default_value,
const char *value,
int null_value_allowed,
- int (*callback_check_value)(void *data,
+ int (*callback_check_value)(const void *pointer,
+ void *data,
struct t_config_option *option,
const char *value),
+ const void *callback_check_value_pointer,
void *callback_check_value_data,
- void (*callback_change)(void *data,
+ void (*callback_change)(const void *pointer,
+ void *data,
struct t_config_option *option),
+ const void *callback_change_pointer,
void *callback_change_data,
- void (*callback_delete)(void *data,
+ void (*callback_delete)(const void *pointer,
+ void *data,
struct t_config_option *option),
+ const void *callback_delete_pointer,
void *callback_delete_data)
{
struct t_config_option *new_option;
int var_type, int_value, argc, i, index_value;
long number;
- char *error;
+ char *error, *pos, *option_name, *parent_name;
+
+ new_option = NULL;
+ option_name = NULL;
+ parent_name = NULL;
if (!name)
- return NULL;
+ goto error;
+
+ pos = strstr (name, " << ");
+ if (pos)
+ {
+ option_name = string_strndup (name, pos - name);
+ parent_name = strdup (pos + 4);
+ }
+ else
+ {
+ option_name = strdup (name);
+ }
if (config_file && section
- && config_file_search_option (config_file, section, name))
- return NULL;
+ && config_file_search_option (config_file, section, option_name))
+ {
+ goto error;
+ }
var_type = -1;
for (i = 0; i < CONFIG_NUM_OPTION_TYPES; i++)
@@ -638,7 +683,7 @@ config_file_new_option (struct t_config_file *config_file,
gui_chat_printf (NULL, "%sError: unknown option type \"%s\"",
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
type);
- return NULL;
+ goto error;
}
if (!null_value_allowed)
@@ -648,7 +693,7 @@ config_file_new_option (struct t_config_file *config_file,
else if (!default_value && value)
default_value = value;
if (!default_value || !value)
- return NULL;
+ goto error;
}
new_option = config_file_option_malloc ();
@@ -656,9 +701,10 @@ config_file_new_option (struct t_config_file *config_file,
{
new_option->config_file = config_file;
new_option->section = section;
- new_option->name = strdup (name);
+ new_option->name = strdup (option_name);
if (!new_option->name)
goto error;
+ new_option->parent_name = (parent_name) ? strdup (parent_name) : NULL;
new_option->type = var_type;
if (description)
{
@@ -814,10 +860,13 @@ config_file_new_option (struct t_config_file *config_file,
}
new_option->null_value_allowed = null_value_allowed;
new_option->callback_check_value = callback_check_value;
+ new_option->callback_check_value_pointer = callback_check_value_pointer;
new_option->callback_check_value_data = callback_check_value_data;
new_option->callback_change = callback_change;
+ new_option->callback_change_pointer = callback_change_pointer;
new_option->callback_change_data = callback_change_data;
new_option->callback_delete = callback_delete;
+ new_option->callback_delete_pointer = callback_delete_pointer;
new_option->callback_delete_data = callback_delete_data;
new_option->loaded = 1;
@@ -838,15 +887,22 @@ config_file_new_option (struct t_config_file *config_file,
}
}
- return new_option;
+ goto end;
error:
if (new_option)
{
config_file_option_free_data (new_option);
free (new_option);
+ new_option = NULL;
}
- return NULL;
+
+end:
+ if (option_name)
+ free (option_name);
+ if (parent_name)
+ free (parent_name);
+ return new_option;
}
/*
@@ -1190,7 +1246,10 @@ config_file_option_reset (struct t_config_option *option, int run_callback)
if ((rc == WEECHAT_CONFIG_OPTION_SET_OK_CHANGED)
&& run_callback && option->callback_change)
{
- (void)(option->callback_change)(option->callback_change_data, option);
+ (void) (option->callback_change) (
+ option->callback_change_pointer,
+ option->callback_change_data,
+ option);
}
/* run config hook(s) */
@@ -1227,11 +1286,14 @@ config_file_option_set (struct t_config_option *option, const char *value,
if (option->callback_check_value)
{
- if (!(int)(option->callback_check_value)
- (option->callback_check_value_data,
- option,
- value))
+ if (!(int)(option->callback_check_value) (
+ option->callback_check_value_pointer,
+ option->callback_check_value_data,
+ option,
+ value))
+ {
return WEECHAT_CONFIG_OPTION_SET_ERROR;
+ }
}
if (value)
@@ -1503,7 +1565,10 @@ config_file_option_set (struct t_config_option *option, const char *value,
if ((rc == WEECHAT_CONFIG_OPTION_SET_OK_CHANGED)
&& run_callback && option->callback_change)
{
- (void)(option->callback_change)(option->callback_change_data, option);
+ (void) (option->callback_change) (
+ option->callback_change_pointer,
+ option->callback_change_data,
+ option);
}
/* run config hook(s) */
@@ -1554,7 +1619,10 @@ config_file_option_set_null (struct t_config_option *option, int run_callback)
if ((rc == WEECHAT_CONFIG_OPTION_SET_OK_CHANGED)
&& run_callback && option->callback_change)
{
- (void)(option->callback_change)(option->callback_change_data, option);
+ (void) (option->callback_change) (
+ option->callback_change_pointer,
+ option->callback_change_data,
+ option);
}
/* run config hook(s) */
@@ -1593,20 +1661,22 @@ config_file_option_unset (struct t_config_option *option)
/* delete option */
if (option->callback_delete)
{
- (void)(option->callback_delete)
- (option->callback_delete_data,
- option);
+ (void) (option->callback_delete) (
+ option->callback_delete_pointer,
+ option->callback_delete_data,
+ option);
}
option_full_name = config_file_option_full_name (option);
if (option->section->callback_delete_option)
{
- rc = (int)(option->section->callback_delete_option)
- (option->section->callback_delete_option_data,
- option->config_file,
- option->section,
- option);
+ rc = (int) (option->section->callback_delete_option) (
+ option->section->callback_delete_option_pointer,
+ option->section->callback_delete_option_data,
+ option->config_file,
+ option->section,
+ option);
}
else
{
@@ -1648,12 +1718,17 @@ void
config_file_option_rename (struct t_config_option *option,
const char *new_name)
{
- char *str_new_name;
+ char *str_new_name, *full_old_name, *full_new_name;
+ struct t_config_file *ptr_config;
+ struct t_config_section *ptr_section;
+ struct t_config_option *ptr_option;
if (!option || !new_name || !new_name[0]
|| config_file_search_option (option->config_file, option->section, new_name))
return;
+ full_old_name = config_file_option_full_name (option);
+
str_new_name = strdup (new_name);
if (str_new_name)
{
@@ -1679,6 +1754,155 @@ config_file_option_rename (struct t_config_option *option,
if (option->section)
config_file_option_insert_in_section (option);
}
+
+ full_new_name = config_file_option_full_name (option);
+
+ /* rename "parent_name" in any option using the old option name */
+ if (full_old_name && full_new_name)
+ {
+ for (ptr_config = config_files; ptr_config;
+ ptr_config = ptr_config->next_config)
+ {
+ for (ptr_section = ptr_config->sections; ptr_section;
+ ptr_section = ptr_section->next_section)
+ {
+ for (ptr_option = ptr_section->options; ptr_option;
+ ptr_option = ptr_option->next_option)
+ {
+ if (ptr_option->parent_name
+ && (strcmp (ptr_option->parent_name, full_old_name) == 0))
+ {
+ free (ptr_option->parent_name);
+ ptr_option->parent_name = strdup (full_new_name);
+ }
+ }
+ }
+ }
+ }
+
+ if (full_old_name)
+ free (full_old_name);
+ if (full_new_name)
+ free (full_new_name);
+}
+
+/*
+ * Builds a string with the value or default value of option,
+ * depending on the type of option.
+ *
+ * According to default_value:
+ * 0: value of option is returned
+ * 1: default value of option is returned
+ *
+ * Note: result must be freed after use.
+ */
+
+char *
+config_file_option_value_to_string (struct t_config_option *option,
+ int default_value,
+ int use_colors,
+ int use_delimiters)
+{
+ char *value;
+ const char *ptr_value;
+ int enabled, length;
+
+ if ((default_value && !option->default_value)
+ || (!default_value && !option->value))
+ {
+ length = 7 + ((use_colors) ? 64 : 0) + 1;
+ value = malloc (length);
+ if (!value)
+ return NULL;
+ snprintf (value, length,
+ "%s%s",
+ (use_colors) ? GUI_COLOR(GUI_COLOR_CHAT_VALUE_NULL) : "",
+ "null");
+ return value;
+ }
+
+ switch (option->type)
+ {
+ case CONFIG_OPTION_TYPE_BOOLEAN:
+ enabled = (default_value) ?
+ CONFIG_BOOLEAN_DEFAULT(option) : CONFIG_BOOLEAN(option);
+ length = 7 + ((use_colors) ? 64 : 0) + 1;
+ value = malloc (length);
+ if (!value)
+ return NULL;
+ snprintf (value, length,
+ "%s%s",
+ (use_colors) ? GUI_COLOR(GUI_COLOR_CHAT_VALUE) : "",
+ (enabled) ? "on" : "off");
+ return value;
+ break;
+ case CONFIG_OPTION_TYPE_INTEGER:
+ if (option->string_values)
+ {
+ ptr_value = (default_value) ?
+ option->string_values[CONFIG_INTEGER_DEFAULT(option)] :
+ option->string_values[CONFIG_INTEGER(option)];
+ length = strlen (ptr_value) + ((use_colors) ? 64 : 0) + 1;
+ value = malloc (length);
+ if (!value)
+ return NULL;
+ snprintf (value, length,
+ "%s%s",
+ (use_colors) ? GUI_COLOR(GUI_COLOR_CHAT_VALUE) : "",
+ ptr_value);
+ return value;
+ }
+ else
+ {
+ length = 31 + ((use_colors) ? 64 : 0) + 1;
+ value = malloc (length);
+ if (!value)
+ return NULL;
+ snprintf (value, length,
+ "%s%d",
+ (use_colors) ? GUI_COLOR(GUI_COLOR_CHAT_VALUE) : "",
+ (default_value) ? CONFIG_INTEGER_DEFAULT(option) : CONFIG_INTEGER(option));
+ return value;
+ }
+ break;
+ case CONFIG_OPTION_TYPE_STRING:
+ ptr_value = (default_value) ? CONFIG_STRING_DEFAULT(option) : CONFIG_STRING(option);
+ length = strlen (ptr_value) + ((use_colors) ? 64 : 0) + 1;
+ value = malloc (length);
+ if (!value)
+ return NULL;
+ snprintf (value, length,
+ "%s%s%s%s%s%s",
+ (use_colors && use_delimiters) ? GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS) : "",
+ (use_delimiters) ? "\"" : "",
+ (use_colors) ? GUI_COLOR(GUI_COLOR_CHAT_VALUE) : "",
+ ptr_value,
+ (use_colors && use_delimiters) ? GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS) : "",
+ (use_delimiters) ? "\"" : "");
+ return value;
+ break;
+ case CONFIG_OPTION_TYPE_COLOR:
+ ptr_value = gui_color_get_name (
+ (default_value) ? CONFIG_COLOR_DEFAULT(option) : CONFIG_COLOR(option));
+ if (!ptr_value)
+ return NULL;
+ length = strlen (ptr_value) + ((use_colors) ? 64 : 0) + 1;
+ value = malloc (length);
+ if (!value)
+ return NULL;
+ snprintf (value, length,
+ "%s%s",
+ (use_colors) ? GUI_COLOR(GUI_COLOR_CHAT_VALUE) : "",
+ ptr_value);
+ return value;
+ break;
+ case CONFIG_NUM_OPTION_TYPES:
+ /* make C compiler happy */
+ break;
+ }
+
+ /* make C static analyzer happy (never executed) */
+ return NULL;
}
/*
@@ -1698,6 +1922,8 @@ config_file_option_get_pointer (struct t_config_option *option,
return option->section;
else if (string_strcasecmp (property, "name") == 0)
return option->name;
+ else if (string_strcasecmp (property, "parent_name") == 0)
+ return option->parent_name;
else if (string_strcasecmp (property, "type") == 0)
return &option->type;
else if (string_strcasecmp (property, "description") == 0)
@@ -1833,12 +2059,13 @@ config_file_option_set_with_string (const char *option_name, const char *value)
if (ptr_section->user_can_add_options
&& ptr_section->callback_create_option)
{
- rc = (int)(ptr_section->callback_create_option)
- (ptr_section->callback_create_option_data,
- ptr_config,
- ptr_section,
- pos_option,
- value);
+ rc = (int) (ptr_section->callback_create_option) (
+ ptr_section->callback_create_option_pointer,
+ ptr_section->callback_create_option_data,
+ ptr_config,
+ ptr_section,
+ pos_option,
+ value);
}
}
}
@@ -2074,35 +2301,35 @@ config_file_write_option (struct t_config_file *config_file,
switch (option->type)
{
case CONFIG_OPTION_TYPE_BOOLEAN:
- rc = string_iconv_fprintf (config_file->file, "%s%s = %s\n",
- config_file_option_escape (option->name),
- option->name,
- (CONFIG_BOOLEAN(option) == CONFIG_BOOLEAN_TRUE) ?
- "on" : "off");
+ rc = string_fprintf (config_file->file, "%s%s = %s\n",
+ config_file_option_escape (option->name),
+ option->name,
+ (CONFIG_BOOLEAN(option) == CONFIG_BOOLEAN_TRUE) ?
+ "on" : "off");
break;
case CONFIG_OPTION_TYPE_INTEGER:
if (option->string_values)
- rc = string_iconv_fprintf (config_file->file, "%s%s = %s\n",
- config_file_option_escape (option->name),
- option->name,
- option->string_values[CONFIG_INTEGER(option)]);
+ rc = string_fprintf (config_file->file, "%s%s = %s\n",
+ config_file_option_escape (option->name),
+ option->name,
+ option->string_values[CONFIG_INTEGER(option)]);
else
- rc = string_iconv_fprintf (config_file->file, "%s%s = %d\n",
- config_file_option_escape (option->name),
- option->name,
- CONFIG_INTEGER(option));
+ rc = string_fprintf (config_file->file, "%s%s = %d\n",
+ config_file_option_escape (option->name),
+ option->name,
+ CONFIG_INTEGER(option));
break;
case CONFIG_OPTION_TYPE_STRING:
- rc = string_iconv_fprintf (config_file->file, "%s%s = \"%s\"\n",
- config_file_option_escape (option->name),
- option->name,
- (char *)option->value);
+ rc = string_fprintf (config_file->file, "%s%s = \"%s\"\n",
+ config_file_option_escape (option->name),
+ option->name,
+ (char *)option->value);
break;
case CONFIG_OPTION_TYPE_COLOR:
- rc = string_iconv_fprintf (config_file->file, "%s%s = %s\n",
- config_file_option_escape (option->name),
- option->name,
- gui_color_get_name (CONFIG_COLOR(option)));
+ rc = string_fprintf (config_file->file, "%s%s = %s\n",
+ config_file_option_escape (option->name),
+ option->name,
+ gui_color_get_name (CONFIG_COLOR(option)));
break;
case CONFIG_NUM_OPTION_TYPES:
break;
@@ -2110,9 +2337,9 @@ config_file_write_option (struct t_config_file *config_file,
}
else
{
- rc = string_iconv_fprintf (config_file->file, "%s%s\n",
- config_file_option_escape (option->name),
- option->name);
+ rc = string_fprintf (config_file->file, "%s%s\n",
+ config_file_option_escape (option->name),
+ option->name);
}
return rc;
@@ -2144,9 +2371,9 @@ config_file_write_line (struct t_config_file *config_file,
{
if (vbuffer[0])
{
- rc = string_iconv_fprintf (config_file->file, "%s%s = %s\n",
- config_file_option_escape (option_name),
- option_name, vbuffer);
+ rc = string_fprintf (config_file->file, "%s%s = %s\n",
+ config_file_option_escape (option_name),
+ option_name, vbuffer);
free (vbuffer);
return rc;
}
@@ -2154,8 +2381,8 @@ config_file_write_line (struct t_config_file *config_file,
}
}
- return (string_iconv_fprintf (config_file->file, "\n[%s]\n",
- option_name));
+ return (string_fprintf (config_file->file, "\n[%s]\n",
+ option_name));
}
/*
@@ -2232,12 +2459,12 @@ config_file_write_internal (struct t_config_file *config_file,
}
/* write header with name of config file and WeeChat version */
- if (!string_iconv_fprintf (config_file->file, "#\n"))
+ if (!string_fprintf (config_file->file, "#\n"))
goto error;
- if (!string_iconv_fprintf (config_file->file,
- "# %s -- %s\n#\n",
- version_get_name (),
- config_file->filename))
+ if (!string_fprintf (config_file->file,
+ "# %s -- %s\n#\n",
+ version_get_name (),
+ config_file->filename))
goto error;
/* write all sections */
@@ -2247,23 +2474,27 @@ config_file_write_internal (struct t_config_file *config_file,
/* call write callback if defined for section */
if (default_options && ptr_section->callback_write_default)
{
- if ((ptr_section->callback_write_default) (ptr_section->callback_write_default_data,
- config_file,
- ptr_section->name) != WEECHAT_CONFIG_WRITE_OK)
+ if ((ptr_section->callback_write_default) (
+ ptr_section->callback_write_default_pointer,
+ ptr_section->callback_write_default_data,
+ config_file,
+ ptr_section->name) != WEECHAT_CONFIG_WRITE_OK)
goto error;
}
else if (!default_options && ptr_section->callback_write)
{
- if ((ptr_section->callback_write) (ptr_section->callback_write_data,
- config_file,
- ptr_section->name) != WEECHAT_CONFIG_WRITE_OK)
+ if ((ptr_section->callback_write) (
+ ptr_section->callback_write_pointer,
+ ptr_section->callback_write_data,
+ config_file,
+ ptr_section->name) != WEECHAT_CONFIG_WRITE_OK)
goto error;
}
else
{
/* write all options for section */
- if (!string_iconv_fprintf (config_file->file,
- "\n[%s]\n", ptr_section->name))
+ if (!string_fprintf (config_file->file,
+ "\n[%s]\n", ptr_section->name))
goto error;
for (ptr_option = ptr_section->options; ptr_option;
ptr_option = ptr_option->next_option)
@@ -2506,7 +2737,8 @@ config_file_read_internal (struct t_config_file *config_file, int reload)
{
ptr_option = NULL;
rc = (ptr_section->callback_read)
- (ptr_section->callback_read_data,
+ (ptr_section->callback_read_pointer,
+ ptr_section->callback_read_data,
config_file,
ptr_section,
ptr_option_name,
@@ -2531,12 +2763,13 @@ config_file_read_internal (struct t_config_file *config_file, int reload)
if (ptr_section
&& ptr_section->callback_create_option)
{
- rc = (int)(ptr_section->callback_create_option)
- (ptr_section->callback_create_option_data,
- config_file,
- ptr_section,
- ptr_option_name,
- (undefined_value) ? NULL : pos);
+ rc = (int) (ptr_section->callback_create_option) (
+ ptr_section->callback_create_option_pointer,
+ ptr_section->callback_create_option_data,
+ config_file,
+ ptr_section,
+ ptr_option_name,
+ (undefined_value) ? NULL : pos);
}
}
}
@@ -2667,6 +2900,8 @@ config_file_option_free_data (struct t_config_option *option)
{
if (option->name)
free (option->name);
+ if (option->parent_name)
+ free (option->parent_name);
if (option->description)
free (option->description);
if (option->string_values)
@@ -2675,6 +2910,12 @@ config_file_option_free_data (struct t_config_option *option)
free (option->default_value);
if (option->value)
free (option->value);
+ if (option->callback_check_value_data)
+ free (option->callback_check_value_data);
+ if (option->callback_change_data)
+ free (option->callback_change_data);
+ if (option->callback_delete_data)
+ free (option->callback_delete_data);
}
/*
@@ -2750,6 +2991,16 @@ config_file_section_free (struct t_config_section *section)
config_file_section_free_options (section);
if (section->name)
free (section->name);
+ if (section->callback_read_data)
+ free (section->callback_read_data);
+ if (section->callback_write_data)
+ free (section->callback_write_data);
+ if (section->callback_write_default_data)
+ free (section->callback_write_default_data);
+ if (section->callback_create_option_data)
+ free (section->callback_create_option_data);
+ if (section->callback_delete_option_data)
+ free (section->callback_delete_option_data);
/* remove section from list */
if (ptr_config->last_section == section)
@@ -2806,6 +3057,10 @@ config_file_free (struct t_config_file *config_file)
if (config_file->next_config)
(config_file->next_config)->prev_config = config_file->prev_config;
+ /* free data */
+ if (config_file->callback_reload_data)
+ free (config_file->callback_reload_data);
+
free (config_file);
config_files = new_config_files;
@@ -2850,11 +3105,13 @@ config_file_free_all_plugin (struct t_weechat_plugin *plugin)
*/
struct t_hdata *
-config_file_hdata_config_file_cb (void *data, const char *hdata_name)
+config_file_hdata_config_file_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_config", "next_config",
@@ -2866,6 +3123,7 @@ config_file_hdata_config_file_cb (void *data, const char *hdata_name)
HDATA_VAR(struct t_config_file, filename, STRING, 0, NULL, NULL);
HDATA_VAR(struct t_config_file, file, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_config_file, callback_reload, POINTER, 0, NULL, NULL);
+ HDATA_VAR(struct t_config_file, callback_reload_pointer, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_config_file, callback_reload_data, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_config_file, sections, POINTER, 0, NULL, "config_section");
HDATA_VAR(struct t_config_file, last_section, POINTER, 0, NULL, "config_section");
@@ -2882,11 +3140,13 @@ config_file_hdata_config_file_cb (void *data, const char *hdata_name)
*/
struct t_hdata *
-config_file_hdata_config_section_cb (void *data, const char *hdata_name)
+config_file_hdata_config_section_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_section", "next_section",
@@ -2898,14 +3158,19 @@ config_file_hdata_config_section_cb (void *data, const char *hdata_name)
HDATA_VAR(struct t_config_section, user_can_add_options, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_config_section, user_can_delete_options, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_config_section, callback_read, POINTER, 0, NULL, NULL);
+ HDATA_VAR(struct t_config_section, callback_read_pointer, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_config_section, callback_read_data, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_config_section, callback_write, POINTER, 0, NULL, NULL);
+ HDATA_VAR(struct t_config_section, callback_write_pointer, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_config_section, callback_write_data, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_config_section, callback_write_default, POINTER, 0, NULL, NULL);
+ HDATA_VAR(struct t_config_section, callback_write_default_pointer, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_config_section, callback_write_default_data, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_config_section, callback_create_option, POINTER, 0, NULL, NULL);
+ HDATA_VAR(struct t_config_section, callback_create_option_pointer, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_config_section, callback_create_option_data, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_config_section, callback_delete_option, POINTER, 0, NULL, NULL);
+ HDATA_VAR(struct t_config_section, callback_delete_option_pointer, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_config_section, callback_delete_option_data, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_config_section, options, POINTER, 0, NULL, "config_option");
HDATA_VAR(struct t_config_section, last_option, POINTER, 0, NULL, "config_option");
@@ -2920,11 +3185,13 @@ config_file_hdata_config_section_cb (void *data, const char *hdata_name)
*/
struct t_hdata *
-config_file_hdata_config_option_cb (void *data, const char *hdata_name)
+config_file_hdata_config_option_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_option", "next_option",
@@ -2934,6 +3201,7 @@ config_file_hdata_config_option_cb (void *data, const char *hdata_name)
HDATA_VAR(struct t_config_option, config_file, POINTER, 0, NULL, "config_file");
HDATA_VAR(struct t_config_option, section, POINTER, 0, NULL, "config_section");
HDATA_VAR(struct t_config_option, name, STRING, 0, NULL, NULL);
+ HDATA_VAR(struct t_config_option, parent_name, STRING, 0, NULL, NULL);
HDATA_VAR(struct t_config_option, type, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_config_option, description, STRING, 0, NULL, NULL);
HDATA_VAR(struct t_config_option, string_values, STRING, 0, "*", NULL);
@@ -2943,10 +3211,13 @@ config_file_hdata_config_option_cb (void *data, const char *hdata_name)
HDATA_VAR(struct t_config_option, value, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_config_option, null_value_allowed, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_config_option, callback_check_value, POINTER, 0, NULL, NULL);
+ HDATA_VAR(struct t_config_option, callback_check_value_pointer, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_config_option, callback_check_value_data, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_config_option, callback_change, POINTER, 0, NULL, NULL);
+ HDATA_VAR(struct t_config_option, callback_change_pointer, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_config_option, callback_change_data, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_config_option, callback_delete, POINTER, 0, NULL, NULL);
+ HDATA_VAR(struct t_config_option, callback_delete_pointer, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_config_option, callback_delete_data, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_config_option, loaded, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_config_option, prev_option, POINTER, 0, NULL, hdata_name);
@@ -2956,6 +3227,150 @@ config_file_hdata_config_option_cb (void *data, const char *hdata_name)
}
/*
+ * Adds a configuration option in an infolist.
+ *
+ * Returns:
+ * 1: OK
+ * 0: error
+ */
+
+int
+config_file_add_option_to_infolist(struct t_infolist *infolist,
+ struct t_config_file *config_file,
+ struct t_config_section *section,
+ struct t_config_option *option,
+ const char *option_name)
+{
+ char *option_full_name, *value, *string_values;
+ struct t_config_option *ptr_parent_option;
+ struct t_infolist_item *ptr_item;
+ int rc;
+
+ rc = 1;
+
+ option_full_name = config_file_option_full_name (option);
+ if (!option_full_name)
+ goto error;
+
+ if (option_name && option_name[0]
+ && (!string_match (option_full_name, option_name, 0)))
+ {
+ goto end;
+ }
+
+ ptr_item = infolist_new_item (infolist);
+ if (!ptr_item)
+ goto error;
+
+ if (!infolist_new_var_string (ptr_item, "full_name", option_full_name))
+ goto error;
+ if (!infolist_new_var_string (ptr_item, "config_name", config_file->name))
+ goto error;
+ if (!infolist_new_var_string (ptr_item, "section_name", section->name))
+ goto error;
+ if (!infolist_new_var_string (ptr_item, "option_name", option->name))
+ goto error;
+ if (!infolist_new_var_string (ptr_item, "parent_name", option->parent_name))
+ goto error;
+ if (!infolist_new_var_string (ptr_item, "description", option->description))
+ goto error;
+ if (!infolist_new_var_string (ptr_item, "description_nls",
+ (option->description
+ && option->description[0]) ?
+ _(option->description) : ""))
+ {
+ goto error;
+ }
+ string_values = string_build_with_split_string (
+ (const char **)option->string_values, "|");
+ if (!infolist_new_var_string (ptr_item, "string_values", string_values))
+ {
+ if (string_values)
+ free (string_values);
+ goto error;
+ }
+ if (string_values)
+ free (string_values);
+ if (!infolist_new_var_integer (ptr_item, "min", option->min))
+ goto error;
+ if (!infolist_new_var_integer (ptr_item, "max", option->max))
+ goto error;
+ if (!infolist_new_var_integer (ptr_item, "null_value_allowed",
+ option->null_value_allowed))
+ {
+ goto error;
+ }
+ if (!infolist_new_var_integer (ptr_item, "value_is_null",
+ (option->value) ? 0 : 1))
+ {
+ goto error;
+ }
+ if (!infolist_new_var_integer (ptr_item,
+ "default_value_is_null",
+ (option->default_value) ?
+ 0 : 1))
+ {
+ goto error;
+ }
+ if (!infolist_new_var_string (ptr_item, "type",
+ config_option_type_string[option->type]))
+ {
+ goto error;
+ }
+ if (option->value)
+ {
+ value = config_file_option_value_to_string (option, 0, 0, 0);
+ if (!value)
+ goto error;
+ if (!infolist_new_var_string (ptr_item, "value", value))
+ {
+ free (value);
+ goto error;
+ }
+ free (value);
+ }
+ if (option->default_value)
+ {
+ value = config_file_option_value_to_string (option, 1, 0, 0);
+ if (!value)
+ goto error;
+ if (!infolist_new_var_string (ptr_item, "default_value", value))
+ {
+ free (value);
+ goto error;
+ }
+ free (value);
+ }
+ if (option->parent_name)
+ {
+ config_file_search_with_string (option->parent_name,
+ NULL, NULL, &ptr_parent_option, NULL);
+ if (ptr_parent_option && ptr_parent_option->value)
+ {
+ value = config_file_option_value_to_string (ptr_parent_option,
+ 0, 0, 0);
+ if (!value)
+ goto error;
+ if (!infolist_new_var_string (ptr_item, "parent_value", value))
+ {
+ free (value);
+ goto error;
+ }
+ free (value);
+ }
+ }
+
+ goto end;
+
+error:
+ rc = 0;
+
+end:
+ free (option_full_name);
+ return rc;
+}
+
+/*
* Adds configuration options in an infolist.
*
* Returns:
@@ -2970,9 +3385,6 @@ config_file_add_to_infolist (struct t_infolist *infolist,
struct t_config_file *ptr_config;
struct t_config_section *ptr_section;
struct t_config_option *ptr_option;
- struct t_infolist_item *ptr_item;
- int length;
- char *option_full_name, value[128], *string_values;
if (!infolist)
return 0;
@@ -2986,280 +3398,13 @@ config_file_add_to_infolist (struct t_infolist *infolist,
for (ptr_option = ptr_section->options; ptr_option;
ptr_option = ptr_option->next_option)
{
- length = strlen (ptr_config->name) + 1 +
- strlen (ptr_section->name) + 1 +
- strlen (ptr_option->name) + 1;
- option_full_name = malloc (length);
- if (option_full_name)
+ if (!config_file_add_option_to_infolist (infolist,
+ ptr_config,
+ ptr_section,
+ ptr_option,
+ option_name))
{
- snprintf (option_full_name, length, "%s.%s.%s",
- ptr_config->name,
- ptr_section->name,
- ptr_option->name);
- if (!option_name || !option_name[0]
- || string_match (option_full_name, option_name, 0))
- {
- ptr_item = infolist_new_item (infolist);
- if (!ptr_item)
- {
- free (option_full_name);
- return 0;
- }
- if (!infolist_new_var_string (ptr_item,
- "full_name",
- option_full_name))
- {
- free (option_full_name);
- return 0;
- }
- if (!infolist_new_var_string (ptr_item,
- "config_name",
- ptr_config->name))
- {
- free (option_full_name);
- return 0;
- }
- if (!infolist_new_var_string (ptr_item,
- "section_name",
- ptr_section->name))
- {
- free (option_full_name);
- return 0;
- }
- if (!infolist_new_var_string (ptr_item,
- "option_name",
- ptr_option->name))
- {
- free (option_full_name);
- return 0;
- }
- if (!infolist_new_var_string (ptr_item,
- "description",
- ptr_option->description))
- {
- free (option_full_name);
- return 0;
- }
- if (!infolist_new_var_string (ptr_item,
- "description_nls",
- (ptr_option->description
- && ptr_option->description[0]) ?
- _(ptr_option->description) : ""))
- {
- free (option_full_name);
- return 0;
- }
- string_values = string_build_with_split_string ((const char **)ptr_option->string_values,
- "|");
- if (!infolist_new_var_string (ptr_item,
- "string_values",
- string_values))
- {
- if (string_values)
- free (string_values);
- free (option_full_name);
- return 0;
- }
- if (string_values)
- free (string_values);
- if (!infolist_new_var_integer (ptr_item,
- "min",
- ptr_option->min))
- {
- free (option_full_name);
- return 0;
- }
- if (!infolist_new_var_integer (ptr_item,
- "max",
- ptr_option->max))
- {
- free (option_full_name);
- return 0;
- }
- if (!infolist_new_var_integer (ptr_item,
- "null_value_allowed",
- ptr_option->null_value_allowed))
- {
- free (option_full_name);
- return 0;
- }
- if (!infolist_new_var_integer (ptr_item,
- "value_is_null",
- (ptr_option->value) ?
- 0 : 1))
- {
- free (option_full_name);
- return 0;
- }
- if (!infolist_new_var_integer (ptr_item,
- "default_value_is_null",
- (ptr_option->default_value) ?
- 0 : 1))
- {
- free (option_full_name);
- return 0;
- }
- switch (ptr_option->type)
- {
- case CONFIG_OPTION_TYPE_BOOLEAN:
- if (!infolist_new_var_string (ptr_item,
- "type",
- "boolean"))
- {
- free (option_full_name);
- return 0;
- }
- if (ptr_option->value)
- {
- if (CONFIG_BOOLEAN(ptr_option) == CONFIG_BOOLEAN_TRUE)
- snprintf (value, sizeof (value), "on");
- else
- snprintf (value, sizeof (value), "off");
- if (!infolist_new_var_string (ptr_item,
- "value",
- value))
- {
- free (option_full_name);
- return 0;
- }
- }
- if (ptr_option->default_value)
- {
- if (CONFIG_BOOLEAN_DEFAULT(ptr_option) == CONFIG_BOOLEAN_TRUE)
- snprintf (value, sizeof (value), "on");
- else
- snprintf (value, sizeof (value), "off");
- if (!infolist_new_var_string (ptr_item,
- "default_value",
- value))
- {
- free (option_full_name);
- return 0;
- }
- }
- break;
- case CONFIG_OPTION_TYPE_INTEGER:
- if (!infolist_new_var_string (ptr_item,
- "type",
- "integer"))
- {
- free (option_full_name);
- return 0;
- }
- if (ptr_option->string_values)
- {
- if (ptr_option->value)
- {
- if (!infolist_new_var_string (ptr_item,
- "value",
- ptr_option->string_values[CONFIG_INTEGER(ptr_option)]))
- {
- free (option_full_name);
- return 0;
- }
- }
- if (ptr_option->default_value)
- {
- if (!infolist_new_var_string (ptr_item,
- "default_value",
- ptr_option->string_values[CONFIG_INTEGER_DEFAULT(ptr_option)]))
- {
- free (option_full_name);
- return 0;
- }
- }
- }
- else
- {
- if (ptr_option->value)
- {
- snprintf (value, sizeof (value), "%d",
- CONFIG_INTEGER(ptr_option));
- if (!infolist_new_var_string (ptr_item,
- "value",
- value))
- {
- free (option_full_name);
- return 0;
- }
- }
- if (ptr_option->default_value)
- {
- snprintf (value, sizeof (value), "%d",
- CONFIG_INTEGER_DEFAULT(ptr_option));
- if (!infolist_new_var_string (ptr_item,
- "default_value",
- value))
- {
- free (option_full_name);
- return 0;
- }
- }
- }
- break;
- case CONFIG_OPTION_TYPE_STRING:
- if (!infolist_new_var_string (ptr_item,
- "type",
- "string"))
- {
- free (option_full_name);
- return 0;
- }
- if (ptr_option->value)
- {
- if (!infolist_new_var_string (ptr_item,
- "value",
- CONFIG_STRING(ptr_option)))
- {
- free (option_full_name);
- return 0;
- }
- }
- if (ptr_option->default_value)
- {
- if (!infolist_new_var_string (ptr_item,
- "default_value",
- CONFIG_STRING_DEFAULT(ptr_option)))
- {
- free (option_full_name);
- return 0;
- }
- }
- break;
- case CONFIG_OPTION_TYPE_COLOR:
- if (!infolist_new_var_string (ptr_item,
- "type",
- "color"))
- {
- free (option_full_name);
- return 0;
- }
- if (ptr_option->value)
- {
- if (!infolist_new_var_string (ptr_item,
- "value",
- gui_color_get_name (CONFIG_COLOR(ptr_option))))
- {
- free (option_full_name);
- return 0;
- }
- }
- if (ptr_option->default_value)
- {
- if (!infolist_new_var_string (ptr_item,
- "default_value",
- gui_color_get_name (CONFIG_COLOR_DEFAULT(ptr_option))))
- {
- free (option_full_name);
- return 0;
- }
- }
- break;
- case CONFIG_NUM_OPTION_TYPES:
- break;
- }
- }
- free (option_full_name);
+ return 0;
}
}
}
@@ -3291,6 +3436,7 @@ config_file_print_log ()
log_printf (" filename . . . . . . . : '%s'", ptr_config_file->filename);
log_printf (" file . . . . . . . . . : 0x%lx", ptr_config_file->file);
log_printf (" callback_reload. . . . : 0x%lx", ptr_config_file->callback_reload);
+ log_printf (" callback_reload_pointer: 0x%lx", ptr_config_file->callback_reload_pointer);
log_printf (" callback_reload_data . : 0x%lx", ptr_config_file->callback_reload_data);
log_printf (" sections . . . . . . . : 0x%lx", ptr_config_file->sections);
log_printf (" last_section . . . . . : 0x%lx", ptr_config_file->last_section);
@@ -3302,44 +3448,50 @@ config_file_print_log ()
{
log_printf ("");
log_printf (" [section (addr:0x%lx)]", ptr_section);
- log_printf (" config_file. . . . . . . . : 0x%lx", ptr_section->config_file);
- log_printf (" name . . . . . . . . . . . : '%s'", ptr_section->name);
- log_printf (" callback_read. . . . . . . : 0x%lx", ptr_section->callback_read);
- log_printf (" callback_read_data . . . . : 0x%lx", ptr_section->callback_read_data);
- log_printf (" callback_write . . . . . . : 0x%lx", ptr_section->callback_write);
- log_printf (" callback_write_data. . . . : 0x%lx", ptr_section->callback_write_data);
- log_printf (" callback_write_default . . : 0x%lx", ptr_section->callback_write_default);
- log_printf (" callback_write_default_data: 0x%lx", ptr_section->callback_write_default_data);
- log_printf (" callback_create_option. . .: 0x%lx", ptr_section->callback_create_option);
- log_printf (" callback_create_option_data: 0x%lx", ptr_section->callback_create_option_data);
- log_printf (" callback_delete_option. . .: 0x%lx", ptr_section->callback_delete_option);
- log_printf (" callback_delete_option_data: 0x%lx", ptr_section->callback_delete_option_data);
- log_printf (" options. . . . . . . . . . : 0x%lx", ptr_section->options);
- log_printf (" last_option. . . . . . . . : 0x%lx", ptr_section->last_option);
- log_printf (" prev_section . . . . . . . : 0x%lx", ptr_section->prev_section);
- log_printf (" next_section . . . . . . . : 0x%lx", ptr_section->next_section);
+ log_printf (" config_file . . . . . . . . . : 0x%lx", ptr_section->config_file);
+ log_printf (" name. . . . . . . . . . . . . : '%s'", ptr_section->name);
+ log_printf (" callback_read . . . . . . . . : 0x%lx", ptr_section->callback_read);
+ log_printf (" callback_read_pointer . . . . : 0x%lx", ptr_section->callback_read_pointer);
+ log_printf (" callback_read_data. . . . . . : 0x%lx", ptr_section->callback_read_data);
+ log_printf (" callback_write. . . . . . . . : 0x%lx", ptr_section->callback_write);
+ log_printf (" callback_write_pointer. . . . : 0x%lx", ptr_section->callback_write_pointer);
+ log_printf (" callback_write_data . . . . . : 0x%lx", ptr_section->callback_write_data);
+ log_printf (" callback_write_default. . . . : 0x%lx", ptr_section->callback_write_default);
+ log_printf (" callback_write_default_pointer: 0x%lx", ptr_section->callback_write_default_pointer);
+ log_printf (" callback_write_default_data . : 0x%lx", ptr_section->callback_write_default_data);
+ log_printf (" callback_create_option. . . . : 0x%lx", ptr_section->callback_create_option);
+ log_printf (" callback_create_option_pointer: 0x%lx", ptr_section->callback_create_option_pointer);
+ log_printf (" callback_create_option_data . : 0x%lx", ptr_section->callback_create_option_data);
+ log_printf (" callback_delete_option. . . . : 0x%lx", ptr_section->callback_delete_option);
+ log_printf (" callback_delete_option_pointer: 0x%lx", ptr_section->callback_delete_option_pointer);
+ log_printf (" callback_delete_option_data . : 0x%lx", ptr_section->callback_delete_option_data);
+ log_printf (" options . . . . . . . . . . . : 0x%lx", ptr_section->options);
+ log_printf (" last_option . . . . . . . . . : 0x%lx", ptr_section->last_option);
+ log_printf (" prev_section. . . . . . . . . : 0x%lx", ptr_section->prev_section);
+ log_printf (" next_section. . . . . . . . . : 0x%lx", ptr_section->next_section);
for (ptr_option = ptr_section->options; ptr_option;
ptr_option = ptr_option->next_option)
{
log_printf ("");
log_printf (" [option (addr:0x%lx)]", ptr_option);
- log_printf (" config_file. . . . . : 0x%lx", ptr_option->config_file);
- log_printf (" section. . . . . . . : 0x%lx", ptr_option->section);
- log_printf (" name . . . . . . . . : '%s'", ptr_option->name);
- log_printf (" type . . . . . . . . : %d", ptr_option->type);
- log_printf (" description. . . . . : '%s'", ptr_option->description);
- log_printf (" string_values. . . . : 0x%lx", ptr_option->string_values);
- log_printf (" min. . . . . . . . . : %d", ptr_option->min);
- log_printf (" max. . . . . . . . . : %d", ptr_option->max);
+ log_printf (" config_file. . . . . . . . . : 0x%lx", ptr_option->config_file);
+ log_printf (" section. . . . . . . . . . . : 0x%lx", ptr_option->section);
+ log_printf (" name . . . . . . . . . . . . : '%s'", ptr_option->name);
+ log_printf (" parent_name. . . . . . . . . : '%s'", ptr_option->parent_name);
+ log_printf (" type . . . . . . . . . . . . : %d", ptr_option->type);
+ log_printf (" description. . . . . . . . . : '%s'", ptr_option->description);
+ log_printf (" string_values. . . . . . . . : 0x%lx", ptr_option->string_values);
+ log_printf (" min. . . . . . . . . . . . . : %d", ptr_option->min);
+ log_printf (" max. . . . . . . . . . . . . : %d", ptr_option->max);
switch (ptr_option->type)
{
case CONFIG_OPTION_TYPE_BOOLEAN:
- log_printf (" default value. . . . : %s",
+ log_printf (" default value. . . . . . . . : %s",
(ptr_option->default_value) ?
((CONFIG_BOOLEAN_DEFAULT(ptr_option) == CONFIG_BOOLEAN_TRUE) ?
"on" : "off") : "null");
- log_printf (" value (boolean). . . : %s",
+ log_printf (" value (boolean). . . . . . . : %s",
(ptr_option->value) ?
((CONFIG_BOOLEAN(ptr_option) == CONFIG_BOOLEAN_TRUE) ?
"on" : "off") : "null");
@@ -3347,61 +3499,69 @@ config_file_print_log ()
case CONFIG_OPTION_TYPE_INTEGER:
if (ptr_option->string_values)
{
- log_printf (" default value. . . . : '%s'",
+ log_printf (" default value. . . . . . . . : '%s'",
(ptr_option->default_value) ?
ptr_option->string_values[CONFIG_INTEGER_DEFAULT(ptr_option)] : "null");
- log_printf (" value (integer/str). : '%s'",
+ log_printf (" value (integer/str). . . . . : '%s'",
(ptr_option->value) ?
ptr_option->string_values[CONFIG_INTEGER(ptr_option)] : "null");
}
else
{
if (ptr_option->default_value)
- log_printf (" default value. . . . : %d",
+ log_printf (" default value. . . . . . . . : %d",
CONFIG_INTEGER_DEFAULT(ptr_option));
else
- log_printf (" default value. . . . : null");
+ log_printf (" default value. . . . . . . . : null");
if (ptr_option->value)
- log_printf (" value (integer). . . : %d",
+ log_printf (" value (integer). . . . . . . : %d",
CONFIG_INTEGER(ptr_option));
else
- log_printf (" value (integer). . . : null");
+ log_printf (" value (integer). . . . . . . : null");
}
break;
case CONFIG_OPTION_TYPE_STRING:
if (ptr_option->default_value)
- log_printf (" default value. . . . : '%s'",
+ log_printf (" default value. . . . . . . . : '%s'",
CONFIG_STRING_DEFAULT(ptr_option));
else
- log_printf (" default value. . . . : null");
+ log_printf (" default value. . . . . . . . : null");
if (ptr_option->value)
- log_printf (" value (string) . . . : '%s'",
+ log_printf (" value (string) . . . . . . . : '%s'",
CONFIG_STRING(ptr_option));
else
- log_printf (" value (string) . . . : null");
+ log_printf (" value (string) . . . . . . . : null");
break;
case CONFIG_OPTION_TYPE_COLOR:
if (ptr_option->default_value)
- log_printf (" default value. . . . : %d ('%s')",
+ log_printf (" default value. . . . . . . . : %d ('%s')",
CONFIG_COLOR_DEFAULT(ptr_option),
gui_color_get_name (CONFIG_COLOR_DEFAULT(ptr_option)));
else
- log_printf (" default value. . . . : null");
+ log_printf (" default value. . . . . . . . : null");
if (ptr_option->value)
- log_printf (" value (color). . . . : %d ('%s')",
+ log_printf (" value (color). . . . . . . . : %d ('%s')",
CONFIG_COLOR(ptr_option),
gui_color_get_name (CONFIG_COLOR(ptr_option)));
else
- log_printf (" value (color). . . . : null");
+ log_printf (" value (color). . . . . . . . : null");
break;
case CONFIG_NUM_OPTION_TYPES:
break;
}
- log_printf (" null_value_allowed . : %d", ptr_option->null_value_allowed);
- log_printf (" callback_change. . . : 0x%lx", ptr_option->callback_change);
- log_printf (" loaded . . . . . . . : %d", ptr_option->loaded);
- log_printf (" prev_option. . . . . : 0x%lx", ptr_option->prev_option);
- log_printf (" next_option. . . . . : 0x%lx", ptr_option->next_option);
+ log_printf (" null_value_allowed . . . . . : %d", ptr_option->null_value_allowed);
+ log_printf (" callback_check_value . . . . : 0x%lx", ptr_option->callback_check_value);
+ log_printf (" callback_check_value_pointer : 0x%lx", ptr_option->callback_check_value_pointer);
+ log_printf (" callback_check_value_data. . : 0x%lx", ptr_option->callback_check_value_data);
+ log_printf (" callback_change. . . . . . . : 0x%lx", ptr_option->callback_change);
+ log_printf (" callback_change_pointer. . . : 0x%lx", ptr_option->callback_change_pointer);
+ log_printf (" callback_change_data . . . . : 0x%lx", ptr_option->callback_change_data);
+ log_printf (" callback_delete. . . . . . . : 0x%lx", ptr_option->callback_delete);
+ log_printf (" callback_delete_pointer. . . : 0x%lx", ptr_option->callback_delete_pointer);
+ log_printf (" callback_delete_data . . . . : 0x%lx", ptr_option->callback_delete_data);
+ log_printf (" loaded . . . . . . . . . . . : %d", ptr_option->loaded);
+ log_printf (" prev_option. . . . . . . . . : 0x%lx", ptr_option->prev_option);
+ log_printf (" next_option. . . . . . . . . : 0x%lx", ptr_option->next_option);
}
}
}
diff --git a/src/core/wee-config-file.h b/src/core/wee-config-file.h
index 29d454418..2b662443f 100644
--- a/src/core/wee-config-file.h
+++ b/src/core/wee-config-file.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2005-2006 Emmanuel Bouthenot <kolter@openics.org>
*
* This file is part of WeeChat, the extensible chat client.
@@ -49,8 +49,10 @@ struct t_config_file
/* (example: "weechat.conf") */
FILE *file; /* file pointer */
int (*callback_reload) /* callback for reloading file */
- (void *data,
+ (const void *pointer,
+ void *data,
struct t_config_file *config_file);
+ const void *callback_reload_pointer; /* pointer sent to callback */
void *callback_reload_data; /* data sent to callback */
struct t_config_section *sections; /* config sections */
struct t_config_section *last_section; /* last config section */
@@ -65,34 +67,44 @@ struct t_config_section
int user_can_add_options; /* user can add with /set ? */
int user_can_delete_options; /* user can del with /unset ? */
int (*callback_read) /* called to read a line from */
- (void *data, /* config file (only for some */
- struct t_config_file *config_file, /* special sections) */
+ (const void *pointer, /* config file (only for some */
+ void *data, /* special sections) */
+ struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
const char *value);
+ const void *callback_read_pointer; /* pointer sent to read callback */
void *callback_read_data; /* data sent to read callback */
int (*callback_write) /* called to write options */
- (void *data, /* in config file (only for some */
- struct t_config_file *config_file, /* special sections) */
+ (const void *pointer, /* in config file (only for some */
+ void *data, /* special sections) */
+ struct t_config_file *config_file,
const char *section_name);
+ const void *callback_write_pointer; /* pointer sent to write cb */
void *callback_write_data; /* data sent to write callback */
int (*callback_write_default) /* called to write default */
- (void *data, /* options in config file */
+ (const void *pointer, /* options in config file */
+ void *data,
struct t_config_file *config_file,
const char *section_name);
+ const void *callback_write_default_pointer; /* ptr sent to write def.cb */
void *callback_write_default_data; /* data sent to write def. callb.*/
int (*callback_create_option) /* called to create option in */
- (void *data, /* section */
+ (const void *pointer, /* section */
+ void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
const char *value);
+ const void *callback_create_option_pointer; /* ptr sent to create cb */
void *callback_create_option_data; /* data sent to create callback */
int (*callback_delete_option) /* called to delete option in */
- (void *data, /* section */
+ (const void *pointer, /* section */
+ void *data,
struct t_config_file *config_file,
struct t_config_section *section,
struct t_config_option *option);
+ const void *callback_delete_option_pointer; /* ptr sent to delete cb */
void *callback_delete_option_data; /* data sent to delete callback */
struct t_config_option *options; /* options in section */
struct t_config_option *last_option; /* last option in section */
@@ -115,6 +127,8 @@ struct t_config_option
struct t_config_file *config_file; /* configuration file */
struct t_config_section *section; /* section */
char *name; /* name */
+ char *parent_name; /* parent name (to inherit the */
+ /* value from another option) */
enum t_config_option_type type; /* type */
char *description; /* description */
char **string_values; /* allowed string values */
@@ -123,17 +137,23 @@ struct t_config_option
void *value; /* value */
int null_value_allowed; /* null value allowed ? */
int (*callback_check_value) /* called to check value before */
- (void *data, /* assigning new value */
+ (const void *pointer, /* assigning new value */
+ void *data,
struct t_config_option *option,
const char *value);
+ const void *callback_check_value_pointer; /* pointer sent to check cb */
void *callback_check_value_data; /* data sent to check callback */
void (*callback_change) /* called when value is changed */
- (void *data,
+ (const void *pointer,
+ void *data,
struct t_config_option *option);
+ const void *callback_change_pointer; /* pointer sent to change cb */
void *callback_change_data; /* data sent to change callback */
void (*callback_delete) /* called when option is deleted */
- (void *data,
+ (const void *pointer,
+ void *data,
struct t_config_option *option);
+ const void *callback_delete_pointer; /* pointer sent to delete cb */
void *callback_delete_data; /* data sent to delete callback */
int loaded; /* 1 if opt was found in config */
struct t_config_option *prev_option; /* link to previous option */
@@ -146,37 +166,49 @@ extern struct t_config_file *last_config_file;
extern struct t_config_file *config_file_search (const char *name);
extern struct t_config_file *config_file_new (struct t_weechat_plugin *plugin,
const char *name,
- int (*callback_reload)(void *data,
+ int (*callback_reload)(const void *pointer,
+ void *data,
struct t_config_file *config_file),
- void *callback_data);
+ const void *callback_reload_pointer,
+ void *callback_reload_data);
extern struct t_config_section *config_file_new_section (struct t_config_file *config_file,
const char *name,
int user_can_add_options,
int user_can_delete_options,
- int (*callback_read)(void *data,
+ int (*callback_read)(const void *pointer,
+ void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
const char *value),
+ const void *callback_read_pointer,
void *callback_read_data,
- int (*callback_write)(void *data,
+ int (*callback_write)(const void *pointer,
+ void *data,
struct t_config_file *config_file,
const char *section_name),
+ const void *callback_write_pointer,
void *callback_write_data,
- int (*callback_write_default)(void *data,
+ int (*callback_write_default)(const void *pointer,
+ void *data,
struct t_config_file *config_file,
const char *section_name),
+ const void *callback_write_default_pointer,
void *callback_write_default_data,
- int (*callback_create_option)(void *data,
+ int (*callback_create_option)(const void *pointer,
+ void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
const char *value),
+ const void *callback_create_option_pointer,
void *callback_create_option_data,
- int (*callback_delete_option)(void *data,
+ int (*callback_delete_option)(const void *pointer,
+ void *data,
struct t_config_file *config_file,
struct t_config_section *section,
struct t_config_option *option),
+ const void *callback_delete_option_pointer,
void *callback_delete_option_data);
extern struct t_config_section *config_file_search_section (struct t_config_file *config_file,
const char *section_name);
@@ -189,15 +221,21 @@ extern struct t_config_option *config_file_new_option (struct t_config_file *con
const char *default_value,
const char *value,
int null_value_allowed,
- int (*callback_check_value)(void *data,
+ int (*callback_check_value)(const void *pointer,
+ void *data,
struct t_config_option *option,
const char *value),
+ const void *callback_check_value_pointer,
void *callback_check_value_data,
- void (*callback_change)(void *data,
+ void (*callback_change)(const void *pointer,
+ void *data,
struct t_config_option *option),
+ const void *callback_change_pointer,
void *callback_change_data,
- void (*callback_delete)(void *data,
+ void (*callback_delete)(const void *pointer,
+ void *data,
struct t_config_option *option),
+ const void *callback_delete_pointer,
void *callback_delete_data);
extern struct t_config_option *config_file_search_option (struct t_config_file *config_file,
struct t_config_section *section,
@@ -222,6 +260,10 @@ extern int config_file_option_set_null (struct t_config_option *option,
extern int config_file_option_unset (struct t_config_option *option);
extern void config_file_option_rename (struct t_config_option *option,
const char *new_name);
+extern char *config_file_option_value_to_string (struct t_config_option *option,
+ int default_value,
+ int add_delimiters,
+ int use_colors);
extern void *config_file_option_get_pointer (struct t_config_option *option,
const char *property);
extern int config_file_option_is_null (struct t_config_option *option);
@@ -249,11 +291,14 @@ extern void config_file_section_free (struct t_config_section *section);
extern void config_file_free (struct t_config_file *config_file);
extern void config_file_free_all ();
extern void config_file_free_all_plugin (struct t_weechat_plugin *plugin);
-extern struct t_hdata *config_file_hdata_config_file_cb (void *data,
+extern struct t_hdata *config_file_hdata_config_file_cb (const void *pointer,
+ void *data,
const char *hdata_name);
-extern struct t_hdata *config_file_hdata_config_section_cb (void *data,
+extern struct t_hdata *config_file_hdata_config_section_cb (const void *pointer,
+ void *data,
const char *hdata_name);
-extern struct t_hdata *config_file_hdata_config_option_cb (void *data,
+extern struct t_hdata *config_file_hdata_config_option_cb (const void *pointer,
+ void *data,
const char *hdata_name);
extern int config_file_add_to_infolist (struct t_infolist *infolist,
const char *option_name);
diff --git a/src/core/wee-config.c b/src/core/wee-config.c
index 78a570d0f..c1e50202b 100644
--- a/src/core/wee-config.c
+++ b/src/core/wee-config.c
@@ -1,7 +1,7 @@
/*
* wee-config.c - WeeChat configuration options (file weechat.conf)
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2005-2006 Emmanuel Bouthenot <kolter@openics.org>
*
* This file is part of WeeChat, the extensible chat client.
@@ -37,6 +37,7 @@
#include "weechat.h"
#include "wee-config.h"
+#include "wee-hashtable.h"
#include "wee-hook.h"
#include "wee-log.h"
#include "wee-network.h"
@@ -47,6 +48,7 @@
#include "wee-string.h"
#include "wee-version.h"
#include "../gui/gui-bar.h"
+#include "../gui/gui-bar-item.h"
#include "../gui/gui-buffer.h"
#include "../gui/gui-chat.h"
#include "../gui/gui-color.h"
@@ -135,6 +137,7 @@ struct t_config_option *config_look_input_cursor_scroll;
struct t_config_option *config_look_input_share;
struct t_config_option *config_look_input_share_overwrite;
struct t_config_option *config_look_input_undo_max;
+struct t_config_option *config_look_item_away_message;
struct t_config_option *config_look_item_buffer_filter;
struct t_config_option *config_look_item_buffer_zoom;
struct t_config_option *config_look_item_mouse_status;
@@ -146,8 +149,12 @@ struct t_config_option *config_look_key_bind_safe;
struct t_config_option *config_look_key_grab_delay;
struct t_config_option *config_look_mouse;
struct t_config_option *config_look_mouse_timer_delay;
+struct t_config_option *config_look_nick_color_force;
+struct t_config_option *config_look_nick_color_hash;
+struct t_config_option *config_look_nick_color_stop_chars;
struct t_config_option *config_look_nick_prefix;
struct t_config_option *config_look_nick_suffix;
+struct t_config_option *config_look_paste_auto_add_newline;
struct t_config_option *config_look_paste_bracketed;
struct t_config_option *config_look_paste_bracketed_timer_delay;
struct t_config_option *config_look_paste_max_lines;
@@ -223,13 +230,14 @@ struct t_config_option *config_color_chat_text_found_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_value;
+struct t_config_option *config_color_chat_value_null;
struct t_config_option *config_color_emphasized;
struct t_config_option *config_color_emphasized_bg;
struct t_config_option *config_color_input_actions;
struct t_config_option *config_color_input_text_not_found;
+struct t_config_option *config_color_item_away;
struct t_config_option *config_color_nicklist_away;
struct t_config_option *config_color_nicklist_group;
-struct t_config_option *config_color_nicklist_offline;
struct t_config_option *config_color_separator;
struct t_config_option *config_color_status_count_highlight;
struct t_config_option *config_color_status_count_msg;
@@ -303,6 +311,9 @@ struct t_config_look_word_char_item *config_word_chars_highlight = NULL;
int config_word_chars_highlight_count = 0;
struct t_config_look_word_char_item *config_word_chars_input = NULL;
int config_word_chars_input_count = 0;
+char **config_nick_colors = NULL;
+int config_num_nick_colors = 0;
+struct t_hashtable *config_hashtable_nick_color_force = NULL;
/*
@@ -310,9 +321,11 @@ int config_word_chars_input_count = 0;
*/
void
-config_change_sys_rlimit (void *data, struct t_config_option *option)
+config_change_sys_rlimit (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -342,9 +355,11 @@ config_change_save_config_layout_on_exit ()
*/
void
-config_change_save_config_on_exit (void *data, struct t_config_option *option)
+config_change_save_config_on_exit (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -364,9 +379,11 @@ config_change_save_config_on_exit (void *data, struct t_config_option *option)
*/
void
-config_change_save_layout_on_exit (void *data, struct t_config_option *option)
+config_change_save_layout_on_exit (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -378,9 +395,11 @@ config_change_save_layout_on_exit (void *data, struct t_config_option *option)
*/
void
-config_change_window_title (void *data, struct t_config_option *option)
+config_change_window_title (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -490,9 +509,11 @@ config_set_word_chars (const char *str_word_chars,
*/
void
-config_change_word_chars_highlight (void *data, struct t_config_option *option)
+config_change_word_chars_highlight (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -506,9 +527,11 @@ config_change_word_chars_highlight (void *data, struct t_config_option *option)
*/
void
-config_change_word_chars_input (void *data, struct t_config_option *option)
+config_change_word_chars_input (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -522,9 +545,11 @@ config_change_word_chars_input (void *data, struct t_config_option *option)
*/
void
-config_change_buffers (void *data, struct t_config_option *option)
+config_change_buffers (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -536,9 +561,11 @@ config_change_buffers (void *data, struct t_config_option *option)
*/
void
-config_change_buffer_content (void *data, struct t_config_option *option)
+config_change_buffer_content (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -551,9 +578,11 @@ config_change_buffer_content (void *data, struct t_config_option *option)
*/
void
-config_change_mouse (void *data, struct t_config_option *option)
+config_change_mouse (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -571,9 +600,11 @@ config_change_mouse (void *data, struct t_config_option *option)
*/
void
-config_change_buffer_auto_renumber (void *data, struct t_config_option *option)
+config_change_buffer_auto_renumber (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -586,9 +617,11 @@ config_change_buffer_auto_renumber (void *data, struct t_config_option *option)
*/
void
-config_change_buffer_notify_default (void *data, struct t_config_option *option)
+config_change_buffer_notify_default (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -600,9 +633,11 @@ config_change_buffer_notify_default (void *data, struct t_config_option *option)
*/
void
-config_change_buffer_time_format (void *data, struct t_config_option *option)
+config_change_buffer_time_format (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -632,14 +667,84 @@ config_compute_prefix_max_length_all_buffers ()
}
/*
+ * Sets nick colors using option "weechat.color.chat_nick_colors".
+ */
+
+void
+config_set_nick_colors ()
+{
+ if (config_nick_colors)
+ {
+ string_free_split (config_nick_colors);
+ config_nick_colors = NULL;
+ config_num_nick_colors = 0;
+ }
+
+ config_nick_colors = string_split (
+ CONFIG_STRING(config_color_chat_nick_colors),
+ ",", 0, 0,
+ &config_num_nick_colors);
+}
+
+/*
+ * Callback for changes on option "weechat.look.nick_color_force".
+ */
+
+void
+config_change_look_nick_color_force (const void *pointer, void *data,
+ struct t_config_option *option)
+{
+ char **items, *pos;
+ int num_items, i;
+
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+ (void) option;
+
+ if (!config_hashtable_nick_color_force)
+ {
+ config_hashtable_nick_color_force = hashtable_new (
+ 32,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING,
+ NULL, NULL);
+ }
+ else
+ {
+ hashtable_remove_all (config_hashtable_nick_color_force);
+ }
+
+ items = string_split (CONFIG_STRING(config_look_nick_color_force),
+ ";", 0, 0, &num_items);
+ if (items)
+ {
+ for (i = 0; i < num_items; i++)
+ {
+ pos = strchr (items[i], ':');
+ if (pos)
+ {
+ pos[0] = '\0';
+ hashtable_set (config_hashtable_nick_color_force,
+ items[i],
+ pos + 1);
+ }
+ }
+ string_free_split (items);
+ }
+}
+
+/*
* Callback for changes on options "weechat.look.nick_prefix" and
* "weechat.look.nick_suffix".
*/
void
-config_change_nick_prefix_suffix (void *data, struct t_config_option *option)
+config_change_nick_prefix_suffix (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -656,9 +761,11 @@ config_change_nick_prefix_suffix (void *data, struct t_config_option *option)
*/
void
-config_change_prefix_same_nick (void *data, struct t_config_option *option)
+config_change_prefix_same_nick (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -674,9 +781,11 @@ config_change_prefix_same_nick (void *data, struct t_config_option *option)
*/
void
-config_change_eat_newline_glitch (void *data, struct t_config_option *option)
+config_change_eat_newline_glitch (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -700,12 +809,14 @@ config_change_eat_newline_glitch (void *data, struct t_config_option *option)
*/
void
-config_change_emphasized_attributes (void *data, struct t_config_option *option)
+config_change_emphasized_attributes (const void *pointer, void *data,
+ struct t_config_option *option)
{
int i;
const char *ptr_attr;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -728,9 +839,11 @@ config_change_emphasized_attributes (void *data, struct t_config_option *option)
*/
void
-config_change_highlight_regex (void *data, struct t_config_option *option)
+config_change_highlight_regex (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -763,12 +876,14 @@ config_change_highlight_regex (void *data, struct t_config_option *option)
*/
void
-config_change_highlight_tags (void *data, struct t_config_option *option)
+config_change_highlight_tags (const void *pointer, void *data,
+ struct t_config_option *option)
{
int i;
char **tags_array;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -810,9 +925,11 @@ config_change_highlight_tags (void *data, struct t_config_option *option)
*/
void
-config_change_hotlist_sort (void *data, struct t_config_option *option)
+config_change_hotlist_sort (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -820,13 +937,32 @@ config_change_hotlist_sort (void *data, struct t_config_option *option)
}
/*
+ * Callback for changes on options "weechat.look.item_away_message"
+ * and "weechat.color.item_away".
+ */
+
+void
+config_change_item_away (const void *pointer, void *data,
+ struct t_config_option *option)
+{
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+ (void) option;
+
+ gui_bar_item_update ("away");
+}
+
+/*
* Callback for changes on option "weechat.look.paste_bracketed".
*/
void
-config_change_paste_bracketed (void *data, struct t_config_option *option)
+config_change_paste_bracketed (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -839,9 +975,11 @@ config_change_paste_bracketed (void *data, struct t_config_option *option)
*/
void
-config_change_read_marker (void *data, struct t_config_option *option)
+config_change_read_marker (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -853,9 +991,11 @@ config_change_read_marker (void *data, struct t_config_option *option)
*/
void
-config_change_prefix (void *data, struct t_config_option *option)
+config_change_prefix (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -867,9 +1007,11 @@ config_change_prefix (void *data, struct t_config_option *option)
*/
void
-config_change_prefix_align_min (void *data, struct t_config_option *option)
+config_change_prefix_align_min (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -882,10 +1024,12 @@ config_change_prefix_align_min (void *data, struct t_config_option *option)
*/
int
-config_check_prefix_align_more (void *data, struct t_config_option *option,
+config_check_prefix_align_more (const void *pointer, void *data,
+ struct t_config_option *option,
const char *value)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -897,11 +1041,12 @@ config_check_prefix_align_more (void *data, struct t_config_option *option,
*/
int
-config_check_prefix_buffer_align_more (void *data,
+config_check_prefix_buffer_align_more (const void *pointer, void *data,
struct t_config_option *option,
const char *value)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -913,10 +1058,12 @@ config_check_prefix_buffer_align_more (void *data,
*/
int
-config_check_separator (void *data, struct t_config_option *option,
+config_check_separator (const void *pointer, void *data,
+ struct t_config_option *option,
const char *value)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -928,9 +1075,11 @@ config_check_separator (void *data, struct t_config_option *option,
*/
void
-config_change_tab_width (void *data, struct t_config_option *option)
+config_change_tab_width (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -945,9 +1094,11 @@ config_change_tab_width (void *data, struct t_config_option *option)
*/
void
-config_change_color (void *data, struct t_config_option *option)
+config_change_color (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -963,12 +1114,15 @@ config_change_color (void *data, struct t_config_option *option)
*/
void
-config_change_nick_colors (void *data, struct t_config_option *option)
+config_change_nick_colors (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
+ config_set_nick_colors ();
gui_color_buffer_display ();
}
@@ -977,10 +1131,11 @@ config_change_nick_colors (void *data, struct t_config_option *option)
*/
void
-config_change_network_gnutls_ca_file (void *data,
+config_change_network_gnutls_ca_file (const void *pointer, void *data,
struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -993,10 +1148,12 @@ config_change_network_gnutls_ca_file (void *data,
*/
int
-config_check_proxy_curl (void *data, struct t_config_option *option,
+config_check_proxy_curl (const void *pointer, void *data,
+ struct t_config_option *option,
const char *value)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -1016,9 +1173,11 @@ config_check_proxy_curl (void *data, struct t_config_option *option,
*/
void
-config_change_plugin_extension (void *data, struct t_config_option *option)
+config_change_plugin_extension (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -1044,7 +1203,8 @@ config_change_plugin_extension (void *data, struct t_config_option *option)
*/
int
-config_day_change_timer_cb (void *data, int remaining_calls)
+config_day_change_timer_cb (const void *pointer, void *data,
+ int remaining_calls)
{
struct timeval tv_time;
struct tm *local_time;
@@ -1053,6 +1213,7 @@ config_day_change_timer_cb (void *data, int remaining_calls)
char str_time[256];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) remaining_calls;
@@ -1123,6 +1284,8 @@ config_weechat_init_after_read ()
/* apply filters on all buffers */
gui_filter_all_buffers ();
+
+ config_change_look_nick_color_force (NULL, NULL, NULL);
}
/*
@@ -1135,11 +1298,13 @@ config_weechat_init_after_read ()
*/
int
-config_weechat_reload_cb (void *data, struct t_config_file *config_file)
+config_weechat_reload_cb (const void *pointer, void *data,
+ struct t_config_file *config_file)
{
int i, rc;
/* make C compiler happy */
+ (void) pointer;
(void) data;
/* remove all keys */
@@ -1214,10 +1379,11 @@ config_weechat_debug_set_all ()
*/
void
-config_weechat_debug_change_cb (void *data,
+config_weechat_debug_change_cb (const void *pointer, void *data,
struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -1229,7 +1395,7 @@ config_weechat_debug_change_cb (void *data,
*/
int
-config_weechat_debug_create_option_cb (void *data,
+config_weechat_debug_create_option_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
@@ -1239,6 +1405,7 @@ config_weechat_debug_create_option_cb (void *data,
int rc;
/* make C compiler happy */
+ (void) pointer;
(void) data;
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
@@ -1265,9 +1432,10 @@ config_weechat_debug_create_option_cb (void *data,
config_file, section,
option_name, "integer",
_("debug level for plugin (\"core\" for WeeChat core)"),
- NULL, 0, 32, "0", value, 0, NULL, NULL,
- &config_weechat_debug_change_cb, NULL,
- NULL, NULL);
+ NULL, 0, 32, "0", value, 0,
+ NULL, NULL, NULL,
+ &config_weechat_debug_change_cb, NULL, NULL,
+ NULL, NULL, NULL);
rc = (ptr_option) ?
WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
}
@@ -1287,12 +1455,13 @@ config_weechat_debug_create_option_cb (void *data,
*/
int
-config_weechat_debug_delete_option_cb (void *data,
+config_weechat_debug_delete_option_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) config_file;
(void) section;
@@ -1311,7 +1480,7 @@ config_weechat_debug_delete_option_cb (void *data,
int
config_weechat_debug_set (const char *plugin_name, const char *value)
{
- return config_weechat_debug_create_option_cb (NULL,
+ return config_weechat_debug_create_option_cb (NULL, NULL,
weechat_config_file,
weechat_config_section_debug,
plugin_name,
@@ -1323,13 +1492,14 @@ config_weechat_debug_set (const char *plugin_name, const char *value)
*/
void
-config_weechat_palette_change_cb (void *data,
+config_weechat_palette_change_cb (const void *pointer, void *data,
struct t_config_option *option)
{
char *error;
int number;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -1346,7 +1516,7 @@ config_weechat_palette_change_cb (void *data,
*/
int
-config_weechat_palette_create_option_cb (void *data,
+config_weechat_palette_create_option_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
@@ -1357,6 +1527,7 @@ config_weechat_palette_create_option_cb (void *data,
int rc, number;
/* make C compiler happy */
+ (void) pointer;
(void) data;
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
@@ -1387,9 +1558,10 @@ config_weechat_palette_create_option_cb (void *data,
config_file, section,
option_name, "string",
_("alias for color"),
- NULL, 0, 0, "", value, 0, NULL, NULL,
- &config_weechat_palette_change_cb, NULL,
- NULL, NULL);
+ NULL, 0, 0, "", value, 0,
+ NULL, NULL, NULL,
+ &config_weechat_palette_change_cb, NULL, NULL,
+ NULL, NULL, NULL);
rc = (ptr_option) ?
WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
if (ptr_option)
@@ -1415,7 +1587,7 @@ config_weechat_palette_create_option_cb (void *data,
*/
int
-config_weechat_palette_delete_option_cb (void *data,
+config_weechat_palette_delete_option_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
struct t_config_option *option)
@@ -1424,6 +1596,7 @@ config_weechat_palette_delete_option_cb (void *data,
int number;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) config_file;
(void) section;
@@ -1443,7 +1616,8 @@ config_weechat_palette_delete_option_cb (void *data,
*/
int
-config_weechat_proxy_read_cb (void *data, struct t_config_file *config_file,
+config_weechat_proxy_read_cb (const void *pointer, void *data,
+ struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name, const char *value)
{
@@ -1452,6 +1626,7 @@ config_weechat_proxy_read_cb (void *data, struct t_config_file *config_file,
int index_option;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) config_file;
@@ -1520,7 +1695,8 @@ config_weechat_proxy_read_cb (void *data, struct t_config_file *config_file,
*/
int
-config_weechat_bar_read_cb (void *data, struct t_config_file *config_file,
+config_weechat_bar_read_cb (const void *pointer, void *data,
+ struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name, const char *value)
{
@@ -1529,6 +1705,7 @@ config_weechat_bar_read_cb (void *data, struct t_config_file *config_file,
int index_option;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) config_file;
(void) section;
@@ -1598,7 +1775,8 @@ config_weechat_bar_read_cb (void *data, struct t_config_file *config_file,
*/
int
-config_weechat_layout_read_cb (void *data, struct t_config_file *config_file,
+config_weechat_layout_read_cb (const void *pointer, void *data,
+ struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name, const char *value)
{
@@ -1610,6 +1788,7 @@ config_weechat_layout_read_cb (void *data, struct t_config_file *config_file,
struct t_gui_layout_window *parent;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) config_file;
(void) section;
@@ -1762,7 +1941,8 @@ config_weechat_layout_write_tree (struct t_config_file *config_file,
*/
int
-config_weechat_layout_write_cb (void *data, struct t_config_file *config_file,
+config_weechat_layout_write_cb (const void *pointer, void *data,
+ struct t_config_file *config_file,
const char *section_name)
{
struct t_gui_layout *ptr_layout;
@@ -1770,6 +1950,7 @@ config_weechat_layout_write_cb (void *data, struct t_config_file *config_file,
char option_name[1024];
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (!config_file_write_line (config_file, section_name, NULL))
@@ -1820,9 +2001,11 @@ config_weechat_layout_write_cb (void *data, struct t_config_file *config_file,
*/
void
-config_weechat_notify_change_cb (void *data, struct t_config_option *option)
+config_weechat_notify_change_cb (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -1834,7 +2017,7 @@ config_weechat_notify_change_cb (void *data, struct t_config_option *option)
*/
int
-config_weechat_notify_create_option_cb (void *data,
+config_weechat_notify_create_option_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
@@ -1844,6 +2027,7 @@ config_weechat_notify_create_option_cb (void *data,
int rc;
/* make C compiler happy */
+ (void) pointer;
(void) data;
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
@@ -1870,9 +2054,10 @@ config_weechat_notify_create_option_cb (void *data,
config_file, section,
option_name, "integer", _("Notify level for buffer"),
"none|highlight|message|all",
- 0, 0, "", value, 0, NULL, NULL,
- &config_weechat_notify_change_cb, NULL,
- NULL, NULL);
+ 0, 0, "", value, 0,
+ NULL, NULL, NULL,
+ &config_weechat_notify_change_cb, NULL, NULL,
+ NULL, NULL, NULL);
rc = (ptr_option) ?
WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
}
@@ -1892,12 +2077,13 @@ config_weechat_notify_create_option_cb (void *data,
*/
int
-config_weechat_notify_delete_option_cb (void *data,
+config_weechat_notify_delete_option_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) config_file;
(void) section;
@@ -1941,12 +2127,13 @@ config_weechat_notify_set (struct t_gui_buffer *buffer, const char *notify)
return 0;
/* create/update option */
- return (config_weechat_notify_create_option_cb (NULL,
- weechat_config_file,
- weechat_config_section_notify,
- buffer->full_name,
- (value < 0) ?
- NULL : gui_buffer_notify_string[value]) != WEECHAT_CONFIG_OPTION_SET_ERROR) ? 1 : 0;
+ return (config_weechat_notify_create_option_cb (
+ NULL, NULL,
+ weechat_config_file,
+ weechat_config_section_notify,
+ buffer->full_name,
+ (value < 0) ?
+ NULL : gui_buffer_notify_string[value]) != WEECHAT_CONFIG_OPTION_SET_ERROR) ? 1 : 0;
}
/*
@@ -1954,7 +2141,7 @@ config_weechat_notify_set (struct t_gui_buffer *buffer, const char *notify)
*/
int
-config_weechat_filter_read_cb (void *data,
+config_weechat_filter_read_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name, const char *value)
@@ -1963,6 +2150,7 @@ config_weechat_filter_read_cb (void *data,
int argc;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) config_file;
(void) section;
@@ -1990,12 +2178,14 @@ config_weechat_filter_read_cb (void *data,
*/
int
-config_weechat_filter_write_cb (void *data, struct t_config_file *config_file,
+config_weechat_filter_write_cb (const void *pointer, void *data,
+ struct t_config_file *config_file,
const char *section_name)
{
struct t_gui_filter *ptr_filter;
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (!config_file_write_line (config_file, section_name, NULL))
@@ -2022,7 +2212,8 @@ config_weechat_filter_write_cb (void *data, struct t_config_file *config_file,
*/
int
-config_weechat_key_read_cb (void *data, struct t_config_file *config_file,
+config_weechat_key_read_cb (const void *pointer, void *data,
+ struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name, const char *value)
{
@@ -2030,6 +2221,7 @@ config_weechat_key_read_cb (void *data, struct t_config_file *config_file,
char *pos;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) config_file;
@@ -2064,7 +2256,8 @@ config_weechat_key_read_cb (void *data, struct t_config_file *config_file,
*/
int
-config_weechat_key_write_cb (void *data, struct t_config_file *config_file,
+config_weechat_key_write_cb (const void *pointer, void *data,
+ struct t_config_file *config_file,
const char *section_name)
{
struct t_gui_key *ptr_key;
@@ -2072,6 +2265,7 @@ config_weechat_key_write_cb (void *data, struct t_config_file *config_file,
int rc, context;
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (!config_file_write_line (config_file, section_name, NULL))
@@ -2119,18 +2313,20 @@ config_weechat_init_options ()
int i;
char section_name[128];
- weechat_config_file = config_file_new (NULL, WEECHAT_CONFIG_NAME,
- &config_weechat_reload_cb, NULL);
+ weechat_config_file = config_file_new (
+ NULL, WEECHAT_CONFIG_NAME, &config_weechat_reload_cb, NULL, NULL);
if (!weechat_config_file)
return 0;
/* debug */
- ptr_section = config_file_new_section (weechat_config_file, "debug",
- 1, 1,
- NULL, NULL, NULL, NULL,
- NULL, NULL,
- &config_weechat_debug_create_option_cb, NULL,
- &config_weechat_debug_delete_option_cb, NULL);
+ ptr_section = config_file_new_section (
+ weechat_config_file, "debug",
+ 1, 1,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ &config_weechat_debug_create_option_cb, NULL, NULL,
+ &config_weechat_debug_delete_option_cb, NULL, NULL);
if (!ptr_section)
{
config_file_free (weechat_config_file);
@@ -2142,8 +2338,11 @@ config_weechat_init_options ()
/* startup */
ptr_section = config_file_new_section (weechat_config_file, "startup",
0, 0,
- NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
config_file_free (weechat_config_file);
@@ -2155,23 +2354,27 @@ config_weechat_init_options ()
"command_after_plugins", "string",
N_("command executed when WeeChat starts, after loading plugins "
"(note: content is evaluated, see /help eval)"),
- NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_startup_command_before_plugins = config_file_new_option (
weechat_config_file, ptr_section,
"command_before_plugins", "string",
N_("command executed when WeeChat starts, before loading plugins "
"(note: content is evaluated, see /help eval)"),
- NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_startup_display_logo = config_file_new_option (
weechat_config_file, ptr_section,
"display_logo", "boolean",
N_("display WeeChat logo at startup"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_startup_display_version = config_file_new_option (
weechat_config_file, ptr_section,
"display_version", "boolean",
N_("display WeeChat version at startup"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_startup_sys_rlimit = config_file_new_option (
weechat_config_file, ptr_section,
"sys_rlimit", "string",
@@ -2180,14 +2383,20 @@ config_weechat_init_options ()
"(RLIMIT_XXX) in lower case (see man setrlimit for values); limit "
"-1 means \"unlimited\"; example: set unlimited size for core file "
"and max 1GB of virtual memory: \"core:-1,as:1000000000\""),
- NULL, 0, 0, "", NULL, 0, NULL, NULL,
- &config_change_sys_rlimit, NULL, NULL, NULL);
+ NULL, 0, 0, "", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_sys_rlimit, NULL, NULL,
+ NULL, NULL, NULL);
/* look */
- ptr_section = config_file_new_section (weechat_config_file, "look",
- 0, 0,
- NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ ptr_section = config_file_new_section (
+ weechat_config_file, "look",
+ 0, 0,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
config_file_free (weechat_config_file);
@@ -2200,50 +2409,71 @@ config_weechat_init_options ()
N_("alignment for end of lines (all lines after the first): they "
"are starting under this data (time, buffer, prefix, suffix, "
"message (default))"),
- "time|buffer|prefix|suffix|message", 0, 0, "message", NULL, 0, NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
+ "time|buffer|prefix|suffix|message", 0, 0, "message", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffers, NULL, NULL,
+ NULL, NULL, NULL);
config_look_bar_more_down = config_file_new_option (
weechat_config_file, ptr_section,
"bar_more_down", "string",
N_("string displayed when bar can be scrolled down "
"(for bars with filling different from \"horizontal\")"),
- NULL, 0, 0, "++", NULL, 0, NULL, NULL, &config_change_buffer_content, NULL, NULL, NULL);
+ NULL, 0, 0, "++", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffer_content, NULL, NULL,
+ NULL, NULL, NULL);
config_look_bar_more_left = config_file_new_option (
weechat_config_file, ptr_section,
"bar_more_left", "string",
N_("string displayed when bar can be scrolled to the left "
"(for bars with filling \"horizontal\")"),
- NULL, 0, 0, "<<", NULL, 0, NULL, NULL, &config_change_buffer_content, NULL, NULL, NULL);
+ NULL, 0, 0, "<<", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffer_content, NULL, NULL,
+ NULL, NULL, NULL);
config_look_bar_more_right = config_file_new_option (
weechat_config_file, ptr_section,
"bar_more_right", "string",
N_("string displayed when bar can be scrolled to the right "
"(for bars with filling \"horizontal\")"),
- NULL, 0, 0, ">>", NULL, 0, NULL, NULL, &config_change_buffer_content, NULL, NULL, NULL);
+ NULL, 0, 0, ">>", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffer_content, NULL, NULL,
+ NULL, NULL, NULL);
config_look_bar_more_up = config_file_new_option (
weechat_config_file, ptr_section,
"bar_more_up", "string",
N_("string displayed when bar can be scrolled up "
"(for bars with filling different from \"horizontal\")"),
- NULL, 0, 0, "--", NULL, 0, NULL, NULL, &config_change_buffer_content, NULL, NULL, NULL);
+ NULL, 0, 0, "--", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffer_content, NULL, NULL,
+ NULL, NULL, NULL);
config_look_bare_display_exit_on_input = config_file_new_option (
weechat_config_file, ptr_section,
"bare_display_exit_on_input", "boolean",
N_("exit the bare display mode on any changes in input"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_bare_display_time_format = config_file_new_option (
weechat_config_file, ptr_section,
"bare_display_time_format", "string",
N_("time format in bare display mode (see man strftime for date/time "
"specifiers)"),
- NULL, 0, 0, "%H:%M", NULL, 0, NULL, NULL, &config_change_buffer_content, NULL, NULL, NULL);
+ NULL, 0, 0, "%H:%M", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffer_content, NULL, NULL,
+ NULL, NULL, NULL);
config_look_buffer_auto_renumber = config_file_new_option (
weechat_config_file, ptr_section,
"buffer_auto_renumber", "boolean",
N_("automatically renumber buffers to have only consecutive numbers "
"and start with number 1; if disabled, gaps between buffer numbers "
"are allowed and the first buffer can have a number greater than 1"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL,
- &config_change_buffer_auto_renumber, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffer_auto_renumber, NULL, NULL,
+ NULL, NULL, NULL);
config_look_buffer_notify_default = config_file_new_option (
weechat_config_file, ptr_section,
"buffer_notify_default", "integer",
@@ -2253,7 +2483,9 @@ config_weechat_init_options ()
"message=messages+highlights, highlight=highlights only, "
"none=never display in hotlist"),
"none|highlight|message|all", 0, 0, "all", NULL, 0,
- NULL, NULL, &config_change_buffer_notify_default, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_buffer_notify_default, NULL, NULL,
+ NULL, NULL, NULL);
config_look_buffer_position = config_file_new_option (
weechat_config_file, ptr_section,
"buffer_position", "integer",
@@ -2262,31 +2494,36 @@ config_weechat_init_options ()
"number in the list (after the end of list if no number is "
"available); this option is used only if the buffer has no layout "
"number"),
- "end|first_gap", 0, 0, "end", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ "end|first_gap", 0, 0, "end", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_buffer_search_case_sensitive = config_file_new_option (
weechat_config_file, ptr_section,
"buffer_search_case_sensitive", "boolean",
N_("default text search in buffer: case sensitive or not"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_buffer_search_force_default = config_file_new_option (
weechat_config_file, ptr_section,
"buffer_search_force_default", "boolean",
N_("force default values for text search in buffer (instead of using "
"values from last search in buffer)"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_buffer_search_regex = config_file_new_option (
weechat_config_file, ptr_section,
"buffer_search_regex", "boolean",
N_("default text search in buffer: if enabled, search POSIX extended "
"regular expression, otherwise search simple string"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_buffer_search_where = config_file_new_option (
weechat_config_file, ptr_section,
"buffer_search_where", "integer",
N_("default text search in buffer: in message, prefix, prefix and "
"message"),
"prefix|message|prefix_message", 0, 0, "prefix_message",
- NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_buffer_time_format = config_file_new_option (
weechat_config_file, ptr_section,
"buffer_time_format", "string",
@@ -2296,56 +2533,83 @@ config_weechat_init_options ()
"use colors with format \"${color:xxx}\", see /help eval); for "
"example time using grayscale (requires support of 256 colors): "
"\"${color:252}%H${color:245}%M${color:240}%S\""),
- NULL, 0, 0, "%H:%M:%S", NULL, 0, NULL, NULL, &config_change_buffer_time_format, NULL, NULL, NULL);
+ NULL, 0, 0, "%H:%M:%S", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffer_time_format, NULL, NULL,
+ NULL, NULL, NULL);
config_look_color_basic_force_bold = config_file_new_option (
weechat_config_file, ptr_section,
"color_basic_force_bold", "boolean",
N_("force \"bold\" attribute for light colors and \"darkgray\" in "
"basic colors (this option is disabled by default: bold is used "
"only if terminal has less than 16 colors)"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_look_color_inactive_buffer = config_file_new_option (
weechat_config_file, ptr_section,
"color_inactive_buffer", "boolean",
N_("use a different color for lines in inactive buffer (when line is "
"from a merged buffer not selected)"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffers, NULL, NULL,
+ NULL, NULL, NULL);
config_look_color_inactive_message = config_file_new_option (
weechat_config_file, ptr_section,
"color_inactive_message", "boolean",
N_("use a different color for inactive message (when window is not "
"current window, or if line is from a merged buffer not selected)"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffers, NULL, NULL,
+ NULL, NULL, NULL);
config_look_color_inactive_prefix = config_file_new_option (
weechat_config_file, ptr_section,
"color_inactive_prefix", "boolean",
N_("use a different color for inactive prefix (when window is not "
"current window, or if line is from a merged buffer not selected)"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffers, NULL, NULL,
+ NULL, NULL, NULL);
config_look_color_inactive_prefix_buffer = config_file_new_option (
weechat_config_file, ptr_section,
"color_inactive_prefix_buffer", "boolean",
N_("use a different color for inactive buffer name in prefix (when "
"window is not current window, or if line is from a merged buffer "
"not selected)"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffers, NULL, NULL,
+ NULL, NULL, NULL);
config_look_color_inactive_time = config_file_new_option (
weechat_config_file, ptr_section,
"color_inactive_time", "boolean",
N_("use a different color for inactive time (when window is not "
"current window, or if line is from a merged buffer not selected)"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffers, NULL, NULL,
+ NULL, NULL, NULL);
config_look_color_inactive_window = config_file_new_option (
weechat_config_file, ptr_section,
"color_inactive_window", "boolean",
N_("use a different color for lines in inactive window (when window "
"is not current window)"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffers, NULL, NULL,
+ NULL, NULL, NULL);
config_look_color_nick_offline = config_file_new_option (
weechat_config_file, ptr_section,
"color_nick_offline", "boolean",
N_("use a different color for offline nicks (not in nicklist any more)"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffers, NULL, NULL,
+ NULL, NULL, NULL);
config_look_color_pairs_auto_reset = config_file_new_option (
weechat_config_file, ptr_section,
"color_pairs_auto_reset", "integer",
@@ -2353,7 +2617,8 @@ config_weechat_init_options ()
"pairs is lower or equal to this number (-1 = disable automatic "
"reset, and then a manual \"/color reset\" is needed when table "
"is full)"),
- NULL, -1, 256, "5", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, -1, 256, "5", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_color_real_white = config_file_new_option (
weechat_config_file, ptr_section,
"color_real_white", "boolean",
@@ -2362,37 +2627,47 @@ config_weechat_init_options ()
"white background, you should turn on this option to "
"see real white instead of default term foreground "
"color)"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_look_command_chars = config_file_new_option (
weechat_config_file, ptr_section,
"command_chars", "string",
N_("chars used to determine if input string is a command or not: "
"input must start with one of these chars; the slash (\"/\") is "
"always considered as command prefix (example: \".$\")"),
- NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_command_incomplete = config_file_new_option (
weechat_config_file, ptr_section,
"command_incomplete", "boolean",
N_("if set, incomplete and unambiguous commands are allowed, for "
"example /he for /help"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_confirm_quit = config_file_new_option (
weechat_config_file, ptr_section,
"confirm_quit", "boolean",
N_("if set, /quit command must be confirmed with extra argument "
"\"-yes\" (see /help quit)"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_confirm_upgrade = config_file_new_option (
weechat_config_file, ptr_section,
"confirm_upgrade", "boolean",
N_("if set, /upgrade command must be confirmed with extra argument "
"\"-yes\" (see /help upgrade)"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_day_change = config_file_new_option (
weechat_config_file, ptr_section,
"day_change", "boolean",
N_("display special message when day changes"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffers, NULL, NULL,
+ NULL, NULL, NULL);
config_look_day_change_message_1date = config_file_new_option (
weechat_config_file, ptr_section,
"day_change_message_1date", "string",
@@ -2401,7 +2676,10 @@ config_weechat_init_options ()
"(for example at beginning of buffer) (see man strftime for "
"date/time specifiers) (note: content is evaluated, so you can use "
"colors with format \"${color:xxx}\", see /help eval)"),
- NULL, 0, 0, "-- %a, %d %b %Y --", NULL, 0, NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
+ NULL, 0, 0, "-- %a, %d %b %Y --", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffers, NULL, NULL,
+ NULL, NULL, NULL);
config_look_day_change_message_2dates = config_file_new_option (
weechat_config_file, ptr_section,
"day_change_message_2dates", "string",
@@ -2412,8 +2690,10 @@ config_weechat_init_options ()
"(see man strftime for date/time specifiers) (note: content is "
"evaluated, so you can use colors with format \"${color:xxx}\", "
"see /help eval)"),
- NULL, 0, 0, "-- %%a, %%d %%b %%Y (%a, %d %b %Y) --", NULL, 0, NULL, NULL,
- &config_change_buffers, NULL, NULL, NULL);
+ NULL, 0, 0, "-- %%a, %%d %%b %%Y (%a, %d %b %Y) --", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffers, NULL, NULL,
+ NULL, NULL, NULL);
config_look_eat_newline_glitch = config_file_new_option (
weechat_config_file, ptr_section,
"eat_newline_glitch", "boolean",
@@ -2422,8 +2702,10 @@ config_weechat_init_options ()
"text when you copy/paste text from WeeChat to another application "
"(this option is disabled by default because it can cause serious "
"display bugs)"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL,
- &config_change_eat_newline_glitch, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_eat_newline_glitch, NULL, NULL,
+ NULL, NULL, NULL);
config_look_emphasized_attributes = config_file_new_option (
weechat_config_file, ptr_section,
"emphasized_attributes", "string",
@@ -2431,7 +2713,10 @@ config_weechat_init_options ()
"\"*\" for bold, \"!\" for reverse, \"/\" for italic, \"_\" for "
"underline); if the string is empty, the colors "
"weechat.color.emphasized* are used"),
- NULL, 0, 0, "", NULL, 0, NULL, NULL, &config_change_emphasized_attributes, NULL, NULL, NULL);
+ NULL, 0, 0, "", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_emphasized_attributes, NULL, NULL,
+ NULL, NULL, NULL);
config_look_highlight = config_file_new_option (
weechat_config_file, ptr_section,
"highlight", "string",
@@ -2439,7 +2724,8 @@ config_weechat_init_options ()
"comparison (use \"(?-i)\" at beginning of words to make them case "
"sensitive), words may begin or end with \"*\" for partial match; "
"example: \"test,(?-i)*toto*,flash*\""),
- NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_highlight_regex = config_file_new_option (
weechat_config_file, ptr_section,
"highlight_regex", "string",
@@ -2449,7 +2735,10 @@ config_weechat_init_options ()
"and \"|\"), regular expression is case insensitive (use \"(?-i)\" "
"at beginning to make it case sensitive), examples: "
"\"flashcode|flashy\", \"(?-i)FlashCode|flashy\""),
- NULL, 0, 0, "", NULL, 0, NULL, NULL, &config_change_highlight_regex, NULL, NULL, NULL);
+ NULL, 0, 0, "", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_highlight_regex, NULL, NULL,
+ NULL, NULL, NULL);
config_look_highlight_tags = config_file_new_option (
weechat_config_file, ptr_section,
"highlight_tags", "string",
@@ -2459,7 +2748,10 @@ config_weechat_init_options ()
"examples: \"nick_flashcode\" for messages from nick \"FlashCode\", "
"\"irc_notice+nick_toto*\" for notices from a nick starting with "
"\"toto\""),
- NULL, 0, 0, "", NULL, 0, NULL, NULL, &config_change_highlight_tags, NULL, NULL, NULL);
+ NULL, 0, 0, "", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_highlight_tags, NULL, NULL,
+ NULL, NULL, NULL);
config_look_hotlist_add_conditions = config_file_new_option (
weechat_config_file, ptr_section,
"hotlist_add_conditions", "string",
@@ -2470,65 +2762,94 @@ config_weechat_init_options ()
"by default a buffer is added to hotlist if you are away, or if the "
"buffer is not visible on screen (not displayed in any window)"),
NULL, 0, 0, "${away} || ${buffer.num_displayed} == 0",
- NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_hotlist_buffer_separator = config_file_new_option (
weechat_config_file, ptr_section,
"hotlist_buffer_separator", "string",
N_("string displayed between buffers in hotlist"),
- NULL, 0, 0, ", ", NULL, 0, NULL, NULL, &config_change_buffer_content, NULL, NULL, NULL);
+ NULL, 0, 0, ", ", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffer_content, NULL, NULL,
+ NULL, NULL, NULL);
config_look_hotlist_count_max = config_file_new_option (
weechat_config_file, ptr_section,
"hotlist_count_max", "integer",
N_("max number of messages count to display in hotlist for a buffer "
"(0 = never display messages count)"),
- NULL, 0, GUI_HOTLIST_NUM_PRIORITIES, "2", NULL, 0, NULL, NULL, &config_change_buffer_content, NULL, NULL, NULL);
+ NULL, 0, GUI_HOTLIST_NUM_PRIORITIES, "2", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffer_content, NULL, NULL,
+ NULL, NULL, NULL);
config_look_hotlist_count_min_msg = config_file_new_option (
weechat_config_file, ptr_section,
"hotlist_count_min_msg", "integer",
N_("display messages count if number of messages is greater or equal "
"to this value"),
- NULL, 1, 100, "2", NULL, 0, NULL, NULL, &config_change_buffer_content, NULL, NULL, NULL);
+ NULL, 1, 100, "2", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffer_content, NULL, NULL,
+ NULL, NULL, NULL);
config_look_hotlist_names_count = config_file_new_option (
weechat_config_file, ptr_section,
"hotlist_names_count", "integer",
N_("max number of names in hotlist (0 = no name displayed, only buffer "
"numbers)"),
- NULL, 0, GUI_BUFFERS_MAX, "3", NULL, 0, NULL, NULL, &config_change_buffer_content, NULL, NULL, NULL);
+ NULL, 0, GUI_BUFFERS_MAX, "3", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffer_content, NULL, NULL,
+ NULL, NULL, NULL);
config_look_hotlist_names_length = config_file_new_option (
weechat_config_file, ptr_section,
"hotlist_names_length", "integer",
N_("max length of names in hotlist (0 = no limit)"),
- NULL, 0, 32, "0", NULL, 0, NULL, NULL, &config_change_buffer_content, NULL, NULL, NULL);
+ NULL, 0, 32, "0", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffer_content, NULL, NULL,
+ NULL, NULL, NULL);
config_look_hotlist_names_level = config_file_new_option (
weechat_config_file, ptr_section,
"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", NULL, 0, NULL, NULL, &config_change_buffer_content, NULL, NULL, NULL);
+ NULL, 1, GUI_HOTLIST_MASK_MAX, "12", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffer_content, NULL, NULL,
+ NULL, NULL, NULL);
config_look_hotlist_names_merged_buffers = config_file_new_option (
weechat_config_file, ptr_section,
"hotlist_names_merged_buffers", "boolean",
N_("if set, force display of names in hotlist for merged buffers"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, &config_change_buffer_content, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffer_content, NULL, NULL,
+ NULL, NULL, NULL);
config_look_hotlist_prefix = config_file_new_option (
weechat_config_file, ptr_section,
"hotlist_prefix", "string",
N_("text displayed at the beginning of the hotlist"),
- NULL, 0, 0, "H: ", NULL, 0, NULL, NULL, &config_change_buffer_content, NULL, NULL, NULL);
+ NULL, 0, 0, "H: ", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffer_content, NULL, NULL,
+ NULL, NULL, NULL);
config_look_hotlist_remove = config_file_new_option (
weechat_config_file, ptr_section,
"hotlist_remove", "integer",
N_("remove buffers in hotlist: buffer = remove buffer by buffer, "
"merged = remove all visible merged buffers at once"),
"buffer|merged",
- 0, 0, "merged", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ 0, 0, "merged", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_hotlist_short_names = config_file_new_option (
weechat_config_file, ptr_section,
"hotlist_short_names", "boolean",
N_("if set, uses short names to display buffer names in hotlist (start "
- "after first '.' in name)"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, &config_change_buffer_content, NULL, NULL, NULL);
+ "after first \".\" in name)"),
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffer_content, NULL, NULL,
+ NULL, NULL, NULL);
config_look_hotlist_sort = config_file_new_option (
weechat_config_file, ptr_section,
"hotlist_sort", "integer",
@@ -2538,121 +2859,205 @@ config_weechat_init_options ()
"asc = ascending sort, desc = descending sort"),
"group_time_asc|group_time_desc|group_number_asc|"
"group_number_desc|number_asc|number_desc",
- 0, 0, "group_time_asc", NULL, 0, NULL, NULL, &config_change_hotlist_sort, NULL, NULL, NULL);
+ 0, 0, "group_time_asc", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_hotlist_sort, NULL, NULL,
+ NULL, NULL, NULL);
config_look_hotlist_suffix = config_file_new_option (
weechat_config_file, ptr_section,
"hotlist_suffix", "string",
N_("text displayed at the end of the hotlist"),
- NULL, 0, 0, "", NULL, 0, NULL, NULL, &config_change_buffer_content, NULL, NULL, NULL);
+ NULL, 0, 0, "", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffer_content, NULL, NULL,
+ NULL, NULL, NULL);
config_look_hotlist_unique_numbers = config_file_new_option (
weechat_config_file, ptr_section,
"hotlist_unique_numbers", "boolean",
N_("keep only unique numbers in hotlist (this applies only on hotlist "
"items where name is NOT displayed after number)"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, &config_change_buffer_content, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffer_content, NULL, NULL,
+ NULL, NULL, NULL);
config_look_input_cursor_scroll = config_file_new_option (
weechat_config_file, ptr_section,
"input_cursor_scroll", "integer",
N_("number of chars displayed after end of input line when scrolling "
"to display end of line"),
- NULL, 0, 100, "20", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 100, "20", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_input_share = config_file_new_option (
weechat_config_file, ptr_section,
"input_share", "integer",
N_("share commands, text, or both in input for all buffers (there is "
"still local history for each buffer)"),
"none|commands|text|all",
- 0, 0, "none", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ 0, 0, "none", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_input_share_overwrite = config_file_new_option (
weechat_config_file, ptr_section,
"input_share_overwrite", "boolean",
N_("if set and input is shared, always overwrite input in target "
"buffer"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_input_undo_max = config_file_new_option (
weechat_config_file, ptr_section,
"input_undo_max", "integer",
N_("max number of \"undo\" for command line, by buffer (0 = undo "
"disabled)"),
- NULL, 0, 65535, "32", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 65535, "32", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ config_look_item_away_message = config_file_new_option (
+ weechat_config_file, ptr_section,
+ "item_away_message", "boolean",
+ N_("display server away message in away bar item"),
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_item_away, NULL, NULL,
+ NULL, NULL, NULL);
config_look_item_buffer_filter = config_file_new_option (
weechat_config_file, ptr_section,
"item_buffer_filter", "string",
N_("string used to show that some lines are filtered in current buffer "
"(bar item \"buffer_filter\")"),
- NULL, 0, 0, "*", NULL, 0, NULL, NULL, &config_change_buffer_content, NULL, NULL, NULL);
+ NULL, 0, 0, "*", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffer_content, NULL, NULL,
+ NULL, NULL, NULL);
config_look_item_buffer_zoom = config_file_new_option (
weechat_config_file, ptr_section,
"item_buffer_zoom", "string",
N_("string used to show zoom on merged buffer "
"(bar item \"buffer_zoom\")"),
- NULL, 0, 0, "!", NULL, 0, NULL, NULL, &config_change_buffer_content, NULL, NULL, NULL);
+ NULL, 0, 0, "!", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffer_content, NULL, NULL,
+ NULL, NULL, NULL);
config_look_item_mouse_status = config_file_new_option (
weechat_config_file, ptr_section,
"item_mouse_status", "string",
N_("string used to show if mouse is enabled "
"(bar item \"mouse_status\")"),
- NULL, 0, 0, "M", NULL, 0, NULL, NULL, &config_change_buffer_content, NULL, NULL, NULL);
+ NULL, 0, 0, "M", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffer_content, NULL, NULL,
+ NULL, NULL, NULL);
config_look_item_time_format = config_file_new_option (
weechat_config_file, ptr_section,
"item_time_format", "string",
N_("time format for \"time\" bar item (see man strftime for date/time "
"specifiers)"),
- NULL, 0, 0, "%H:%M", NULL, 0, NULL, NULL, &config_change_buffer_content, NULL, NULL, NULL);
+ NULL, 0, 0, "%H:%M", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffer_content, NULL, NULL,
+ NULL, NULL, NULL);
config_look_jump_current_to_previous_buffer = config_file_new_option (
weechat_config_file, ptr_section,
"jump_current_to_previous_buffer", "boolean",
N_("jump to previous buffer displayed when jumping to current buffer "
"number with /buffer *N (where N is a buffer number), to easily "
"switch to another buffer, then come back to current buffer"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_jump_previous_buffer_when_closing = config_file_new_option (
weechat_config_file, ptr_section,
"jump_previous_buffer_when_closing", "boolean",
N_("jump to previously visited buffer when closing a buffer (if "
"disabled, then jump to buffer number - 1)"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_jump_smart_back_to_buffer = config_file_new_option (
weechat_config_file, ptr_section,
"jump_smart_back_to_buffer", "boolean",
N_("jump back to initial buffer after reaching end of hotlist"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_key_bind_safe = config_file_new_option (
weechat_config_file, ptr_section,
"key_bind_safe", "boolean",
N_("allow only binding of \"safe\" keys (beginning with a ctrl or meta "
"code)"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_key_grab_delay = config_file_new_option (
weechat_config_file, ptr_section,
"key_grab_delay", "integer",
N_("default delay (in milliseconds) to grab a key (using default key "
"alt-k); this delay can be overridden in the /input command (see "
"/help input)"),
- NULL, 1, 10000, "800", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 1, 10000, "800", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_mouse = config_file_new_option (
weechat_config_file, ptr_section,
"mouse", "boolean",
N_("enable mouse support"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, &config_change_mouse, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_mouse, NULL, NULL,
+ NULL, NULL, NULL);
config_look_mouse_timer_delay = config_file_new_option (
weechat_config_file, ptr_section,
"mouse_timer_delay", "integer",
N_("delay (in milliseconds) to grab a mouse event: WeeChat will "
"wait this delay before processing event"),
- NULL, 1, 10000, "100", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 1, 10000, "100", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ config_look_nick_color_force = config_file_new_option (
+ weechat_config_file, ptr_section,
+ "nick_color_force", "string",
+ N_("force color for some nicks: hash computed with nickname "
+ "to find color will not be used for these nicks (format is: "
+ "\"nick1:color1;nick2:color2\"); look up for nicks is with "
+ "exact case then lower case, so it's possible to use only lower "
+ "case for nicks in this option"),
+ NULL, 0, 0, "", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_look_nick_color_force, NULL, NULL,
+ NULL, NULL, NULL);
+ config_look_nick_color_hash = config_file_new_option (
+ weechat_config_file, ptr_section,
+ "nick_color_hash", "integer",
+ N_("hash algorithm used to find the color for a nick: djb2 = variant "
+ "of djb2 (position of letters matters: anagrams of a nick have "
+ "different color), sum = sum of letters"),
+ "djb2|sum", 0, 0, "djb2", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ config_look_nick_color_stop_chars = config_file_new_option (
+ weechat_config_file, ptr_section,
+ "nick_color_stop_chars", "string",
+ N_("chars used to stop in nick when computing color with letters of "
+ "nick (at least one char outside this list must be in string before "
+ "stopping) (example: nick \"|nick|away\" with \"|\" in chars will "
+ "return color of nick \"|nick\")"),
+ NULL, 0, 0, "_|[", NULL, 0,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
config_look_nick_prefix = config_file_new_option (
weechat_config_file, ptr_section,
"nick_prefix", "string",
N_("text to display before nick in prefix of message, example: \"<\""),
- NULL, 0, 0, "", NULL, 0, NULL, NULL,
- &config_change_nick_prefix_suffix, NULL, NULL, NULL);
+ NULL, 0, 0, "", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_nick_prefix_suffix, NULL, NULL,
+ NULL, NULL, NULL);
config_look_nick_suffix = config_file_new_option (
weechat_config_file, ptr_section,
"nick_suffix", "string",
N_("text to display after nick in prefix of message, example: \">\""),
- NULL, 0, 0, "", NULL, 0, NULL, NULL,
- &config_change_nick_prefix_suffix, NULL, NULL, NULL);
+ NULL, 0, 0, "", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_nick_prefix_suffix, NULL, NULL,
+ NULL, NULL, NULL);
+ config_look_paste_auto_add_newline = config_file_new_option (
+ weechat_config_file, ptr_section,
+ "paste_auto_add_newline", "boolean",
+ N_("automatically add a newline at the end of pasted text if there "
+ "are at least two lines and if a confirmation is asked"),
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_paste_bracketed = config_file_new_option (
weechat_config_file, ptr_section,
"paste_bracketed", "boolean",
@@ -2661,82 +3066,108 @@ config_weechat_init_options ()
"with control sequences so that WeeChat can differentiate pasted "
"text from typed-in text (\"ESC[200~\", followed by the pasted text, "
"followed by \"ESC[201~\")"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, &config_change_paste_bracketed, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_paste_bracketed, NULL, NULL,
+ NULL, NULL, NULL);
config_look_paste_bracketed_timer_delay = config_file_new_option (
weechat_config_file, ptr_section,
"paste_bracketed_timer_delay", "integer",
N_("force end of bracketed paste after this delay (in seconds) if the "
"control sequence for end of bracketed paste (\"ESC[201~\") was not "
"received in time"),
- NULL, 1, 60, "10", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 1, 60, "10", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_paste_max_lines = config_file_new_option (
weechat_config_file, ptr_section,
"paste_max_lines", "integer",
N_("max number of lines for paste without asking user "
"(-1 = disable this feature)"),
- NULL, -1, INT_MAX, "1", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, -1, INT_MAX, "1", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_prefix[GUI_CHAT_PREFIX_ERROR] = config_file_new_option (
weechat_config_file, ptr_section,
"prefix_error", "string",
/* TRANSLATORS: string "${color:xxx}" must NOT be translated */
N_("prefix for error messages (note: content is evaluated, so you can "
"use colors with format \"${color:xxx}\", see /help eval)"),
- NULL, 0, 0, GUI_CHAT_PREFIX_ERROR_DEFAULT,
- NULL, 0, NULL, NULL, &config_change_prefix, NULL, NULL, NULL);
+ NULL, 0, 0, GUI_CHAT_PREFIX_ERROR_DEFAULT, NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_prefix, NULL, NULL,
+ NULL, NULL, NULL);
config_look_prefix[GUI_CHAT_PREFIX_NETWORK] = config_file_new_option (
weechat_config_file, ptr_section,
"prefix_network", "string",
/* TRANSLATORS: string "${color:xxx}" must NOT be translated */
N_("prefix for network messages (note: content is evaluated, so you can "
"use colors with format \"${color:xxx}\", see /help eval)"),
- NULL, 0, 0, GUI_CHAT_PREFIX_NETWORK_DEFAULT,
- NULL, 0, NULL, NULL, &config_change_prefix, NULL, NULL, NULL);
+ NULL, 0, 0, GUI_CHAT_PREFIX_NETWORK_DEFAULT, NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_prefix, NULL, NULL,
+ NULL, NULL, NULL);
config_look_prefix[GUI_CHAT_PREFIX_ACTION] = config_file_new_option (
weechat_config_file, ptr_section,
"prefix_action", "string",
/* TRANSLATORS: string "${color:xxx}" must NOT be translated */
N_("prefix for action messages (note: content is evaluated, so you can "
"use colors with format \"${color:xxx}\", see /help eval)"),
- NULL, 0, 0, GUI_CHAT_PREFIX_ACTION_DEFAULT,
- NULL, 0, NULL, NULL, &config_change_prefix, NULL, NULL, NULL);
+ NULL, 0, 0, GUI_CHAT_PREFIX_ACTION_DEFAULT, NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_prefix, NULL, NULL,
+ NULL, NULL, NULL);
config_look_prefix[GUI_CHAT_PREFIX_JOIN] = config_file_new_option (
weechat_config_file, ptr_section,
"prefix_join", "string",
/* TRANSLATORS: string "${color:xxx}" must NOT be translated */
N_("prefix for join messages (note: content is evaluated, so you can "
"use colors with format \"${color:xxx}\", see /help eval)"),
- NULL, 0, 0, GUI_CHAT_PREFIX_JOIN_DEFAULT,
- NULL, 0, NULL, NULL, &config_change_prefix, NULL, NULL, NULL);
+ NULL, 0, 0, GUI_CHAT_PREFIX_JOIN_DEFAULT, NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_prefix, NULL, NULL,
+ NULL, NULL, NULL);
config_look_prefix[GUI_CHAT_PREFIX_QUIT] = config_file_new_option (
weechat_config_file, ptr_section,
"prefix_quit", "string",
/* TRANSLATORS: string "${color:xxx}" must NOT be translated */
N_("prefix for quit messages (note: content is evaluated, so you can "
"use colors with format \"${color:xxx}\", see /help eval)"),
- NULL, 0, 0, GUI_CHAT_PREFIX_QUIT_DEFAULT,
- NULL, 0, NULL, NULL, &config_change_prefix, NULL, NULL, NULL);
+ NULL, 0, 0, GUI_CHAT_PREFIX_QUIT_DEFAULT, NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_prefix, NULL, NULL,
+ NULL, NULL, NULL);
config_look_prefix_align = config_file_new_option (
weechat_config_file, ptr_section,
"prefix_align", "integer",
N_("prefix alignment (none, left, right (default))"),
- "none|left|right", 0, 0, "right", NULL, 0, NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
+ "none|left|right", 0, 0, "right", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffers, NULL, NULL,
+ NULL, NULL, NULL);
config_look_prefix_align_max = config_file_new_option (
weechat_config_file, ptr_section,
"prefix_align_max", "integer",
N_("max size for prefix (0 = no max size)"),
- NULL, 0, 128, "0", NULL, 0, NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
+ NULL, 0, 128, "0", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffers, NULL, NULL,
+ NULL, NULL, NULL);
config_look_prefix_align_min = config_file_new_option (
weechat_config_file, ptr_section,
"prefix_align_min", "integer",
N_("min size for prefix"),
- NULL, 0, 128, "0", NULL, 0, NULL, NULL, &config_change_prefix_align_min, NULL, NULL, NULL);
+ NULL, 0, 128, "0", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_prefix_align_min, NULL, NULL,
+ NULL, NULL, NULL);
config_look_prefix_align_more = config_file_new_option (
weechat_config_file, ptr_section,
"prefix_align_more", "string",
N_("char to display if prefix is truncated (must be exactly one char "
"on screen)"),
NULL, 0, 0, "+", NULL, 0,
- &config_check_prefix_align_more, NULL, &config_change_buffers, NULL, NULL, NULL);
+ &config_check_prefix_align_more, NULL, NULL,
+ &config_change_buffers, NULL, NULL,
+ NULL, NULL, NULL);
config_look_prefix_align_more_after = config_file_new_option (
weechat_config_file, ptr_section,
"prefix_align_more_after", "boolean",
@@ -2744,26 +3175,36 @@ config_weechat_init_options ()
"replacing the space that should be displayed here); if disabled, "
"the truncature char replaces last char of text"),
NULL, 0, 0, "on", NULL, 0,
- NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_buffers, NULL, NULL,
+ NULL, NULL, NULL);
config_look_prefix_buffer_align = config_file_new_option (
weechat_config_file, ptr_section,
"prefix_buffer_align", "integer",
N_("prefix alignment for buffer name, when many buffers are merged "
"with same number (none, left, right (default))"),
- "none|left|right", 0, 0, "right", NULL, 0, NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
+ "none|left|right", 0, 0, "right", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffers, NULL, NULL,
+ NULL, NULL, NULL);
config_look_prefix_buffer_align_max = config_file_new_option (
weechat_config_file, ptr_section,
"prefix_buffer_align_max", "integer",
N_("max size for buffer name, when many buffers are merged with same "
"number (0 = no max size)"),
- NULL, 0, 128, "0", NULL, 0, NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
+ NULL, 0, 128, "0", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffers, NULL, NULL,
+ NULL, NULL, NULL);
config_look_prefix_buffer_align_more = config_file_new_option (
weechat_config_file, ptr_section,
"prefix_buffer_align_more", "string",
N_("char to display if buffer name is truncated (when many buffers are "
"merged with same number) (must be exactly one char on screen)"),
NULL, 0, 0, "+", NULL, 0,
- &config_check_prefix_buffer_align_more, NULL, &config_change_buffers, NULL, NULL, NULL);
+ &config_check_prefix_buffer_align_more, NULL, NULL,
+ &config_change_buffers, NULL, NULL,
+ NULL, NULL, NULL);
config_look_prefix_buffer_align_more_after = config_file_new_option (
weechat_config_file, ptr_section,
"prefix_buffer_align_more_after", "boolean",
@@ -2771,7 +3212,9 @@ config_weechat_init_options ()
"replacing the space that should be displayed here); if disabled, "
"the truncature char replaces last char of text"),
NULL, 0, 0, "on", NULL, 0,
- NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_buffers, NULL, NULL,
+ NULL, NULL, NULL);
config_look_prefix_same_nick = config_file_new_option (
weechat_config_file, ptr_section,
"prefix_same_nick", "string",
@@ -2779,81 +3222,108 @@ config_weechat_init_options ()
"message: use a space \" \" to hide prefix, another string to "
"display this string instead of prefix, or an empty string to "
"disable feature (display prefix)"),
- NULL, 0, 0, "", NULL, 0, NULL, NULL, &config_change_prefix_same_nick, NULL, NULL, NULL);
+ NULL, 0, 0, "", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_prefix_same_nick, NULL, NULL,
+ NULL, NULL, NULL);
config_look_prefix_suffix = config_file_new_option (
weechat_config_file, ptr_section,
"prefix_suffix", "string",
N_("string displayed after prefix"),
- NULL, 0, 0, "|", NULL, 0, NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
+ NULL, 0, 0, "|", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffers, NULL, NULL,
+ NULL, NULL, NULL);
config_look_quote_nick_prefix = config_file_new_option (
weechat_config_file, ptr_section,
"quote_nick_prefix", "string",
N_("text to display before nick when quoting a message (see /help "
"cursor)"),
- NULL, 0, 0, "<", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "<", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_quote_nick_suffix = config_file_new_option (
weechat_config_file, ptr_section,
"quote_nick_suffix", "string",
N_("text to display after nick when quoting a message (see /help "
"cursor)"),
- NULL, 0, 0, ">", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, ">", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_quote_time_format = config_file_new_option (
weechat_config_file, ptr_section,
"quote_time_format", "string",
N_("time format when quoting a message (see /help cursor)"),
- NULL, 0, 0, "%H:%M:%S", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "%H:%M:%S", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_read_marker = config_file_new_option (
weechat_config_file, ptr_section,
"read_marker", "integer",
N_("use a marker (line or char) on buffers to show first unread line"),
"none|line|char",
- 0, 0, "line", NULL, 0, NULL, NULL, &config_change_read_marker, NULL, NULL, NULL);
+ 0, 0, "line", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_read_marker, NULL, NULL,
+ NULL, NULL, NULL);
config_look_read_marker_always_show = config_file_new_option (
weechat_config_file, ptr_section,
"read_marker_always_show", "boolean",
N_("always show read marker, even if it is after last buffer line"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_read_marker_string = config_file_new_option (
weechat_config_file, ptr_section,
"read_marker_string", "string",
N_("string used to draw read marker line (string is repeated until "
"end of line)"),
- NULL, 0, 0, "- ", NULL, 0, NULL, NULL, &config_change_read_marker, NULL, NULL, NULL);
+ NULL, 0, 0, "- ", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_read_marker, NULL, NULL,
+ NULL, NULL, NULL);
config_look_save_config_on_exit = config_file_new_option (
weechat_config_file, ptr_section,
"save_config_on_exit", "boolean",
N_("save configuration file on exit"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, &config_change_save_config_on_exit, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_save_config_on_exit, NULL, NULL,
+ NULL, NULL, NULL);
config_look_save_layout_on_exit = config_file_new_option (
weechat_config_file, ptr_section,
"save_layout_on_exit", "integer",
N_("save layout on exit (buffers, windows, or both)"),
- "none|buffers|windows|all", 0, 0, "none", NULL, 0, NULL, NULL,
- &config_change_save_layout_on_exit, NULL, NULL, NULL);
+ "none|buffers|windows|all", 0, 0, "none", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_save_layout_on_exit, NULL, NULL,
+ NULL, NULL, NULL);
config_look_scroll_amount = config_file_new_option (
weechat_config_file, ptr_section,
"scroll_amount", "integer",
N_("how many lines to scroll by with scroll_up and "
"scroll_down"),
- NULL, 1, INT_MAX, "3", NULL, 0, NULL, NULL, &config_change_buffer_content, NULL, NULL, NULL);
+ NULL, 1, INT_MAX, "3", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffer_content, NULL, NULL,
+ NULL, NULL, NULL);
config_look_scroll_bottom_after_switch = config_file_new_option (
weechat_config_file, ptr_section,
"scroll_bottom_after_switch", "boolean",
N_("scroll to bottom of window after switch to another buffer (do not "
"remember scroll position in windows); the scroll is done only for "
"buffers with formatted content (not free content)"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_scroll_page_percent = config_file_new_option (
weechat_config_file, ptr_section,
"scroll_page_percent", "integer",
N_("percent of screen to scroll when scrolling one page up or down "
"(for example 100 means one page, 50 half-page)"),
- NULL, 1, 100, "100", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 1, 100, "100", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_search_text_not_found_alert = config_file_new_option (
weechat_config_file, ptr_section,
"search_text_not_found_alert", "boolean",
N_("alert user when text sought is not found in buffer"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_separator_horizontal = config_file_new_option (
weechat_config_file, ptr_section,
"separator_horizontal", "string",
@@ -2862,7 +3332,9 @@ config_weechat_init_options ()
"with URL selection under some terminals); "
"width on screen must be exactly one char"),
NULL, 0, 0, "-", NULL, 0,
- &config_check_separator, NULL, &config_change_buffers, NULL, NULL, NULL);
+ &config_check_separator, NULL, NULL,
+ &config_change_buffers, NULL, NULL,
+ NULL, NULL, NULL);
config_look_separator_vertical = config_file_new_option (
weechat_config_file, ptr_section,
"separator_vertical", "string",
@@ -2870,44 +3342,58 @@ config_weechat_init_options ()
"(empty value will draw a real line with ncurses); "
"width on screen must be exactly one char"),
NULL, 0, 0, "", NULL, 0,
- &config_check_separator, NULL, &config_change_buffers, NULL, NULL, NULL);
+ &config_check_separator, NULL, NULL,
+ &config_change_buffers, NULL, NULL,
+ NULL, NULL, NULL);
config_look_tab_width = config_file_new_option (
weechat_config_file, ptr_section,
"tab_width", "integer",
N_("number of spaces used to display tabs in messages"),
- NULL, 1, TAB_MAX_WIDTH, "1", NULL, 0, NULL, NULL,
- &config_change_tab_width, NULL, NULL, NULL);
+ NULL, 1, TAB_MAX_WIDTH, "1", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_tab_width, NULL, NULL,
+ NULL, NULL, NULL);
config_look_time_format = config_file_new_option (
weechat_config_file, ptr_section,
"time_format", "string",
N_("time format for dates converted to strings and displayed in "
"messages (see man strftime for date/time specifiers)"),
- NULL, 0, 0, "%a, %d %b %Y %T", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "%a, %d %b %Y %T", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_window_auto_zoom = config_file_new_option (
weechat_config_file, ptr_section,
"window_auto_zoom", "boolean",
N_("automatically zoom on current window if the terminal becomes too "
"small to display all windows (use alt-z to unzoom windows when the "
"terminal is big enough)"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_window_separator_horizontal = config_file_new_option (
weechat_config_file, ptr_section,
"window_separator_horizontal", "boolean",
N_("display an horizontal separator between windows"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffers, NULL, NULL,
+ NULL, NULL, NULL);
config_look_window_separator_vertical = config_file_new_option (
weechat_config_file, ptr_section,
"window_separator_vertical", "boolean",
N_("display a vertical separator between windows"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_buffers, NULL, NULL,
+ NULL, NULL, NULL);
config_look_window_title = config_file_new_option (
weechat_config_file, ptr_section,
"window_title", "string",
N_("title for window (terminal for Curses GUI), set on startup; "
"an empty string will keep title unchanged "
"(note: content is evaluated, see /help eval)"),
- NULL, 0, 0, "WeeChat ${info:version}", NULL, 0, NULL, NULL,
- &config_change_window_title, NULL, NULL, NULL);
+ NULL, 0, 0, "WeeChat ${info:version}", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_window_title, NULL, NULL,
+ NULL, NULL, NULL);
config_look_word_chars_highlight = config_file_new_option (
weechat_config_file, ptr_section,
"word_chars_highlight", "string",
@@ -2920,8 +3406,10 @@ config_weechat_init_options ()
"matches any char; unicode chars are allowed with the format "
"\\u1234, for example \\u00A0 for unbreakable space "
"(see /help print for supported formats)"),
- NULL, 0, 0, "!\\u00A0,-,_,|,alnum", NULL, 0, NULL, NULL,
- &config_change_word_chars_highlight, NULL, NULL, NULL);
+ NULL, 0, 0, "!\\u00A0,-,_,|,alnum", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_word_chars_highlight, NULL, NULL,
+ NULL, NULL, NULL);
config_look_word_chars_input = config_file_new_option (
weechat_config_file, ptr_section,
"word_chars_input", "string",
@@ -2934,16 +3422,20 @@ config_weechat_init_options ()
"matches any char; unicode chars are allowed with the format "
"\\u1234, for example \\u00A0 for unbreakable space "
"(see /help print for supported formats)"),
- NULL, 0, 0, "!\\u00A0,-,_,|,alnum", NULL, 0, NULL, NULL,
- &config_change_word_chars_input, NULL, NULL, NULL);
+ NULL, 0, 0, "!\\u00A0,-,_,|,alnum", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_word_chars_input, NULL, NULL,
+ NULL, NULL, NULL);
/* palette */
- ptr_section = config_file_new_section (weechat_config_file, "palette",
- 1, 1,
- NULL, NULL, NULL, NULL,
- NULL, NULL,
- &config_weechat_palette_create_option_cb, NULL,
- &config_weechat_palette_delete_option_cb, NULL);
+ ptr_section = config_file_new_section (
+ weechat_config_file, "palette",
+ 1, 1,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ &config_weechat_palette_create_option_cb, NULL, NULL,
+ &config_weechat_palette_delete_option_cb, NULL, NULL);
if (!ptr_section)
{
config_file_free (weechat_config_file);
@@ -2953,8 +3445,11 @@ config_weechat_init_options ()
/* colors */
ptr_section = config_file_new_section (weechat_config_file, "color",
0, 0,
- NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
config_file_free (weechat_config_file);
@@ -2967,84 +3462,110 @@ config_weechat_init_options ()
config_color_bar_more = config_file_new_option (
weechat_config_file, ptr_section,
"bar_more", "color",
- N_("text color for '+' when scrolling bars"),
+ N_("text color for \"+\" when scrolling bars"),
NULL, -1, 0, "lightmagenta", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
/* chat area */
config_color_chat = config_file_new_option (
weechat_config_file, ptr_section,
"chat", "color",
N_("text color for chat"),
NULL, GUI_COLOR_CHAT, 0, "default", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_bg = config_file_new_option (
weechat_config_file, ptr_section,
"chat_bg", "color",
N_("background color for chat"),
NULL, -1, 0, "default", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_buffer = config_file_new_option (
weechat_config_file, ptr_section,
"chat_buffer", "color",
N_("text color for buffer names"),
NULL, GUI_COLOR_CHAT_BUFFER, 0, "white", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_channel = config_file_new_option (
weechat_config_file, ptr_section,
"chat_channel", "color",
N_("text color for channel names"),
NULL, GUI_COLOR_CHAT_CHANNEL, 0, "white", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_day_change = config_file_new_option (
weechat_config_file, ptr_section,
"chat_day_change", "color",
N_("text color for message displayed when the day has changed"),
NULL, GUI_COLOR_CHAT_DAY_CHANGE, 0, "cyan", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_delimiters = config_file_new_option (
weechat_config_file, ptr_section,
"chat_delimiters", "color",
N_("text color for delimiters"),
NULL, GUI_COLOR_CHAT_DELIMITERS, 0, "green", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_highlight = config_file_new_option (
weechat_config_file, ptr_section,
"chat_highlight", "color",
N_("text color for highlighted prefix"),
NULL, GUI_COLOR_CHAT_HIGHLIGHT, 0, "yellow", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_highlight_bg = config_file_new_option (
weechat_config_file, ptr_section,
"chat_highlight_bg", "color",
N_("background color for highlighted prefix"),
NULL, -1, 0, "magenta", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_host = config_file_new_option (
weechat_config_file, ptr_section,
"chat_host", "color",
N_("text color for hostnames"),
NULL, GUI_COLOR_CHAT_HOST, 0, "cyan", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_inactive_buffer = config_file_new_option (
weechat_config_file, ptr_section,
"chat_inactive_buffer", "color",
N_("text color for chat when line is inactive (buffer is merged with "
"other buffers and is not selected)"),
NULL, GUI_COLOR_CHAT_INACTIVE_BUFFER, 0, "default", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_inactive_window = config_file_new_option (
weechat_config_file, ptr_section,
"chat_inactive_window", "color",
N_("text color for chat when window is inactive (not current selected "
"window)"),
NULL, GUI_COLOR_CHAT_INACTIVE_WINDOW, 0, "default", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_nick = config_file_new_option (
weechat_config_file, ptr_section,
"chat_nick", "color",
N_("text color for nicks in chat window"),
NULL, GUI_COLOR_CHAT_NICK, 0, "lightcyan", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_nick_colors = config_file_new_option (
weechat_config_file, ptr_section,
"chat_nick_colors", "string",
@@ -3054,7 +3575,9 @@ config_weechat_init_options ()
"\"lightred:blue\")"),
NULL, 0, 0, "cyan,magenta,green,brown,lightblue,default,lightcyan,"
"lightmagenta,lightgreen,blue", NULL, 0,
- NULL, NULL, &config_change_nick_colors, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_nick_colors, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_nick_offline = config_file_new_option (
weechat_config_file, ptr_section,
"chat_nick_offline", "color",
@@ -3062,58 +3585,76 @@ config_weechat_init_options ()
"color is used only if option weechat.look.color_nick_offline is "
"enabled"),
NULL, GUI_COLOR_CHAT_NICK_OFFLINE, 0, "default", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_nick_offline_highlight = config_file_new_option (
weechat_config_file, ptr_section,
"chat_nick_offline_highlight", "color",
N_("text color for offline nick with highlight; this color is used "
"only if option weechat.look.color_nick_offline is enabled"),
NULL, -1, 0, "default", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_nick_offline_highlight_bg = config_file_new_option (
weechat_config_file, ptr_section,
"chat_nick_offline_highlight_bg", "color",
N_("background color for offline nick with highlight; this color is "
"used only if option weechat.look.color_nick_offline is enabled"),
NULL, -1, 0, "blue", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_nick_other = config_file_new_option (
weechat_config_file, ptr_section,
"chat_nick_other", "color",
N_("text color for other nick in private buffer"),
NULL, GUI_COLOR_CHAT_NICK_OTHER, 0, "cyan", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_nick_prefix = config_file_new_option (
weechat_config_file, ptr_section,
"chat_nick_prefix", "color",
N_("color for nick prefix (string displayed before nick in prefix)"),
- NULL, GUI_COLOR_CHAT_NICK_PREFIX, 0, "green", NULL, 0, NULL, NULL,
- &config_change_color, NULL, NULL, NULL);
+ NULL, GUI_COLOR_CHAT_NICK_PREFIX, 0, "green", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_nick_self = config_file_new_option (
weechat_config_file, ptr_section,
"chat_nick_self", "color",
N_("text color for local nick in chat window"),
NULL, GUI_COLOR_CHAT_NICK_SELF, 0, "white", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_nick_suffix = config_file_new_option (
weechat_config_file, ptr_section,
"chat_nick_suffix", "color",
N_("color for nick suffix (string displayed after nick in prefix)"),
- NULL, GUI_COLOR_CHAT_NICK_SUFFIX, 0, "green", NULL, 0, NULL, NULL,
- &config_change_color, NULL, NULL, NULL);
+ NULL, GUI_COLOR_CHAT_NICK_SUFFIX, 0, "green", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_prefix[GUI_CHAT_PREFIX_ERROR] = config_file_new_option (
weechat_config_file, ptr_section,
"chat_prefix_error", "color",
N_("text color for error prefix"),
NULL, GUI_COLOR_CHAT_PREFIX_ERROR, 0, "yellow", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_prefix_buffer = config_file_new_option (
weechat_config_file, ptr_section,
"chat_prefix_buffer", "color",
N_("text color for buffer name (before prefix, when many buffers are "
"merged with same number)"),
NULL, GUI_COLOR_CHAT_PREFIX_BUFFER, 0, "brown", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_prefix_buffer_inactive_buffer = config_file_new_option (
weechat_config_file, ptr_section,
"chat_prefix_buffer_inactive_buffer", "color",
@@ -3121,98 +3662,138 @@ config_weechat_init_options ()
"buffers are merged with same number and if buffer is not "
"selected)"),
NULL, GUI_COLOR_CHAT_PREFIX_BUFFER_INACTIVE_BUFFER, 0, "default", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_prefix[GUI_CHAT_PREFIX_NETWORK] = config_file_new_option (
weechat_config_file, ptr_section,
"chat_prefix_network", "color",
N_("text color for network prefix"),
NULL, GUI_COLOR_CHAT_PREFIX_NETWORK, 0, "magenta", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_prefix[GUI_CHAT_PREFIX_ACTION] = config_file_new_option (
weechat_config_file, ptr_section,
"chat_prefix_action", "color",
N_("text color for action prefix"),
NULL, GUI_COLOR_CHAT_PREFIX_ACTION, 0, "white", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_prefix[GUI_CHAT_PREFIX_JOIN] = config_file_new_option (
weechat_config_file, ptr_section,
"chat_prefix_join", "color",
N_("text color for join prefix"),
NULL, GUI_COLOR_CHAT_PREFIX_JOIN, 0, "lightgreen", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_prefix[GUI_CHAT_PREFIX_QUIT] = config_file_new_option (
weechat_config_file, ptr_section,
"chat_prefix_quit", "color",
N_("text color for quit prefix"),
NULL, GUI_COLOR_CHAT_PREFIX_QUIT, 0, "lightred", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_prefix_more = config_file_new_option (
weechat_config_file, ptr_section,
"chat_prefix_more", "color",
- N_("text color for '+' when prefix is too long"),
+ N_("text color for \"+\" when prefix is too long"),
NULL, GUI_COLOR_CHAT_PREFIX_MORE, 0, "lightmagenta", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_prefix_suffix = config_file_new_option (
weechat_config_file, ptr_section,
"chat_prefix_suffix", "color",
N_("text color for suffix (after prefix)"),
NULL, GUI_COLOR_CHAT_PREFIX_SUFFIX, 0, "green", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_read_marker = config_file_new_option (
weechat_config_file, ptr_section,
"chat_read_marker", "color",
N_("text color for unread data marker"),
NULL, GUI_COLOR_CHAT_READ_MARKER, 0, "magenta", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_read_marker_bg = config_file_new_option (
weechat_config_file, ptr_section,
"chat_read_marker_bg", "color",
N_("background color for unread data marker"),
NULL, -1, 0, "default", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_server = config_file_new_option (
weechat_config_file, ptr_section,
"chat_server", "color",
N_("text color for server names"),
NULL, GUI_COLOR_CHAT_SERVER, 0, "brown", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_tags = config_file_new_option (
weechat_config_file, ptr_section,
"chat_tags", "color",
N_("text color for tags after messages (displayed with command /debug "
"tags)"),
NULL, GUI_COLOR_CHAT_TAGS, 0, "red", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_text_found = config_file_new_option (
weechat_config_file, ptr_section,
"chat_text_found", "color",
N_("text color for marker on lines where text sought is found"),
NULL, GUI_COLOR_CHAT_TEXT_FOUND, 0, "yellow", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_text_found_bg = config_file_new_option (
weechat_config_file, ptr_section,
"chat_text_found_bg", "color",
N_("background color for marker on lines where text sought is found"),
NULL, -1, 0, "lightmagenta", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_time = config_file_new_option (
weechat_config_file, ptr_section,
"chat_time", "color",
N_("text color for time in chat window"),
NULL, GUI_COLOR_CHAT_TIME, 0, "default", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_time_delimiters = config_file_new_option (
weechat_config_file, ptr_section,
"chat_time_delimiters", "color",
N_("text color for time delimiters"),
NULL, GUI_COLOR_CHAT_TIME_DELIMITERS, 0, "brown", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_chat_value = config_file_new_option (
weechat_config_file, ptr_section,
"chat_value", "color",
N_("text color for values"),
NULL, GUI_COLOR_CHAT_VALUE, 0, "cyan", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
+ config_color_chat_value_null = config_file_new_option (
+ weechat_config_file, ptr_section,
+ "chat_value_null", "color",
+ N_("text color for null values (undefined)"),
+ NULL, GUI_COLOR_CHAT_VALUE_NULL, 0, "blue", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
/* emphasis (chat/bars) */
config_color_emphasized = config_file_new_option (
weechat_config_file, ptr_section,
@@ -3221,7 +3802,9 @@ config_weechat_init_options ()
"this option is used only if option weechat.look.emphasized_attributes "
"is an empty string (default value)"),
NULL, GUI_COLOR_EMPHASIS, 0, "yellow", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_emphasized_bg = config_file_new_option (
weechat_config_file, ptr_section,
"emphasized_bg", "color",
@@ -3229,39 +3812,52 @@ config_weechat_init_options ()
"text); used only if option weechat.look.emphasized_attributes is an "
"empty string (default value)"),
NULL, -1, 0, "magenta", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
/* input bar */
config_color_input_actions = config_file_new_option (
weechat_config_file, ptr_section,
"input_actions", "color",
N_("text color for actions in input line"),
NULL, -1, 0, "lightgreen", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_input_text_not_found = config_file_new_option (
weechat_config_file, ptr_section,
"input_text_not_found", "color",
N_("text color for unsuccessful text search in input line"),
NULL, -1, 0, "red", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
+ /* items */
+ config_color_item_away = config_file_new_option (
+ weechat_config_file, ptr_section,
+ "item_away", "color",
+ N_("text color for away item"),
+ NULL, -1, 0, "yellow", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_item_away, NULL, NULL,
+ NULL, NULL, NULL);
/* nicklist bar */
config_color_nicklist_away = config_file_new_option (
weechat_config_file, ptr_section,
"nicklist_away", "color",
N_("text color for away nicknames"),
NULL, -1, 0, "cyan", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_nicklist_group = config_file_new_option (
weechat_config_file, ptr_section,
"nicklist_group", "color",
N_("text color for groups in nicklist"),
NULL, -1, 0, "green", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
- config_color_nicklist_offline = config_file_new_option (
- weechat_config_file, ptr_section,
- "nicklist_offline", "color",
- N_("text color for offline nicknames"),
- NULL, -1, 0, "blue", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
/* general color settings */
config_color_separator = config_file_new_option (
weechat_config_file, ptr_section,
@@ -3269,112 +3865,149 @@ config_weechat_init_options ()
N_("color for window separators (when split) and separators beside bars "
"(like nicklist)"),
NULL, GUI_COLOR_SEPARATOR, 0, "blue", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
/* status bar */
config_color_status_count_highlight = config_file_new_option (
weechat_config_file, ptr_section,
"status_count_highlight", "color",
N_("text color for count of highlight messages in hotlist (status bar)"),
NULL, -1, 0, "magenta", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_status_count_msg = config_file_new_option (
weechat_config_file, ptr_section,
"status_count_msg", "color",
N_("text color for count of messages in hotlist (status bar)"),
NULL, -1, 0, "brown", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_status_count_other = config_file_new_option (
weechat_config_file, ptr_section,
"status_count_other", "color",
N_("text color for count of other messages in hotlist (status bar)"),
NULL, -1, 0, "default", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_status_count_private = config_file_new_option (
weechat_config_file, ptr_section,
"status_count_private", "color",
N_("text color for count of private messages in hotlist (status bar)"),
NULL, -1, 0, "green", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_status_data_highlight = config_file_new_option (
weechat_config_file, ptr_section,
"status_data_highlight", "color",
N_("text color for buffer with highlight (status bar)"),
NULL, -1, 0, "lightmagenta", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_status_data_msg = config_file_new_option (
weechat_config_file, ptr_section,
"status_data_msg", "color",
N_("text color for buffer with new messages (status bar)"),
NULL, -1, 0, "yellow", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_status_data_other = config_file_new_option (
weechat_config_file, ptr_section,
"status_data_other", "color",
N_("text color for buffer with new data (not messages) "
"(status bar)"),
NULL, -1, 0, "default", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_status_data_private = config_file_new_option (
weechat_config_file, ptr_section,
"status_data_private", "color",
N_("text color for buffer with private message (status bar)"),
NULL, -1, 0, "lightgreen", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_status_filter = config_file_new_option (
weechat_config_file, ptr_section,
"status_filter", "color",
N_("text color for filter indicator in status bar"),
NULL, -1, 0, "green", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_status_more = config_file_new_option (
weechat_config_file, ptr_section,
"status_more", "color",
N_("text color for buffer with new data (status bar)"),
NULL, -1, 0, "yellow", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_status_mouse = config_file_new_option (
weechat_config_file, ptr_section,
"status_mouse", "color",
N_("text color for mouse indicator in status bar"),
NULL, -1, 0, "green", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_status_name = config_file_new_option (
weechat_config_file, ptr_section,
"status_name", "color",
N_("text color for current buffer name in status bar"),
NULL, -1, 0, "white", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_status_name_ssl = config_file_new_option (
weechat_config_file, ptr_section,
"status_name_ssl", "color",
N_("text color for current buffer name in status bar, if data are "
"secured with a protocol like SSL"),
NULL, -1, 0, "lightgreen", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_status_nicklist_count = config_file_new_option (
weechat_config_file, ptr_section,
"status_nicklist_count", "color",
N_("text color for number of nicks in nicklist (status bar)"),
NULL, -1, 0, "default", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_status_number = config_file_new_option (
weechat_config_file, ptr_section,
"status_number", "color",
N_("text color for current buffer number in status bar"),
NULL, -1, 0, "yellow", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
config_color_status_time = config_file_new_option (
weechat_config_file, ptr_section,
"status_time", "color",
N_("text color for time (status bar)"),
NULL, -1, 0, "default", NULL, 0,
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
/* completion */
ptr_section = config_file_new_section (weechat_config_file, "completion",
0, 0,
- NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
config_file_free (weechat_config_file);
@@ -3386,16 +4019,18 @@ config_weechat_init_options ()
"base_word_until_cursor", "boolean",
N_("if enabled, the base word to complete ends at char before cursor; "
"otherwise the base word ends at first space after cursor"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_completion_command_inline = config_file_new_option (
weechat_config_file, ptr_section,
"command_inline", "boolean",
N_("if enabled, the commands inside command line are completed (the "
"command at beginning of line has higher priority and is used "
"first); note: when this option is enabled, there is no more "
- "automatic completion of paths beginning with '/' (outside "
+ "automatic completion of paths beginning with \"/\" (outside "
"commands arguments)"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_completion_default_template = config_file_new_option (
weechat_config_file, ptr_section,
"default_template", "string",
@@ -3403,63 +4038,75 @@ config_weechat_init_options ()
"codes and values: plugin API reference, function "
"\"weechat_hook_command\")"),
NULL, 0, 0, "%(nicks)|%(irc_channels)", NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_completion_nick_add_space = config_file_new_option (
weechat_config_file, ptr_section,
"nick_add_space", "boolean",
N_("add space after nick completion (when nick is not first word on "
"command line)"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_completion_nick_completer = config_file_new_option (
weechat_config_file, ptr_section,
"nick_completer", "string",
N_("string inserted after nick completion (when nick is first word on "
"command line)"),
- NULL, 0, 0, ":", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, ":", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_completion_nick_first_only = config_file_new_option (
weechat_config_file, ptr_section,
"nick_first_only", "boolean",
N_("complete only with first nick found"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_completion_nick_ignore_chars = config_file_new_option (
weechat_config_file, ptr_section,
"nick_ignore_chars", "string",
N_("chars ignored for nick completion"),
- NULL, 0, 0, "[]`_-^", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "[]`_-^", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_completion_partial_completion_alert = config_file_new_option (
weechat_config_file, ptr_section,
"partial_completion_alert", "boolean",
N_("alert user when a partial completion occurs"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_completion_partial_completion_command = config_file_new_option (
weechat_config_file, ptr_section,
"partial_completion_command", "boolean",
N_("partially complete command names (stop when many commands found "
"begin with same letters)"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_completion_partial_completion_command_arg = config_file_new_option (
weechat_config_file, ptr_section,
"partial_completion_command_arg", "boolean",
N_("partially complete command arguments (stop when many arguments "
"found begin with same prefix)"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_completion_partial_completion_count = config_file_new_option (
weechat_config_file, ptr_section,
"partial_completion_count", "boolean",
N_("display count for each partial completion in bar item"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_completion_partial_completion_other = config_file_new_option (
weechat_config_file, ptr_section,
"partial_completion_other", "boolean",
N_("partially complete outside commands (stop when many words found "
"begin with same letters)"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
/* history */
ptr_section = config_file_new_section (weechat_config_file, "history",
0, 0,
- NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
config_file_free (weechat_config_file);
@@ -3471,7 +4118,8 @@ config_weechat_init_options ()
"display_default", "integer",
N_("maximum number of commands to display by default in "
"history listing (0 = unlimited)"),
- NULL, 0, INT_MAX, "5", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, INT_MAX, "5", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_history_max_buffer_lines_minutes = config_file_new_option (
weechat_config_file, ptr_section,
"max_buffer_lines_minutes", "integer",
@@ -3479,32 +4127,39 @@ config_weechat_init_options ()
"(0 = unlimited); examples: 1440 = one day, 10080 = one week, "
"43200 = one month, 525600 = one year; use 0 ONLY if option "
"weechat.history.max_buffer_lines_number is NOT set to 0"),
- NULL, 0, INT_MAX, "0", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, INT_MAX, "0", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_history_max_buffer_lines_number = config_file_new_option (
weechat_config_file, ptr_section,
"max_buffer_lines_number", "integer",
N_("maximum number of lines in history per buffer "
"(0 = unlimited); use 0 ONLY if option "
"weechat.history.max_buffer_lines_minutes is NOT set to 0"),
- NULL, 0, INT_MAX, "4096", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, INT_MAX, "4096", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_history_max_commands = config_file_new_option (
weechat_config_file, ptr_section,
"max_commands", "integer",
N_("maximum number of user commands in history (0 = "
"unlimited, NOT RECOMMENDED: no limit in memory usage)"),
- NULL, 0, INT_MAX, "100", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, INT_MAX, "100", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_history_max_visited_buffers = config_file_new_option (
weechat_config_file, ptr_section,
"max_visited_buffers", "integer",
N_("maximum number of visited buffers to keep in memory"),
- NULL, 0, 1000, "50", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 1000, "50", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
/* proxies */
- ptr_section = config_file_new_section (weechat_config_file, "proxy",
- 0, 0,
- &config_weechat_proxy_read_cb, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL);
+ ptr_section = config_file_new_section (
+ weechat_config_file, "proxy",
+ 0, 0,
+ &config_weechat_proxy_read_cb, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
config_file_free (weechat_config_file);
@@ -3516,8 +4171,11 @@ config_weechat_init_options ()
/* network */
ptr_section = config_file_new_section (weechat_config_file, "network",
0, 0,
- NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
config_file_free (weechat_config_file);
@@ -3529,19 +4187,23 @@ config_weechat_init_options ()
"connection_timeout", "integer",
N_("timeout (in seconds) for connection to a remote host (made in a "
"child process)"),
- NULL, 1, INT_MAX, "60", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 1, INT_MAX, "60", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_network_gnutls_ca_file = config_file_new_option (
weechat_config_file, ptr_section,
"gnutls_ca_file", "string",
N_("file containing the certificate authorities (\"%h\" will be "
"replaced by WeeChat home, \"~/.weechat\" by default)"),
- NULL, 0, 0, CA_FILE, NULL, 0, NULL, NULL,
- &config_change_network_gnutls_ca_file, NULL, NULL, NULL);
+ NULL, 0, 0, CA_FILE, NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_network_gnutls_ca_file, NULL, NULL,
+ NULL, NULL, NULL);
config_network_gnutls_handshake_timeout = config_file_new_option (
weechat_config_file, ptr_section,
"gnutls_handshake_timeout", "integer",
N_("timeout (in seconds) for gnutls handshake"),
- NULL, 1, INT_MAX, "30", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 1, INT_MAX, "30", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_network_proxy_curl = config_file_new_option (
weechat_config_file, ptr_section,
"proxy_curl", "string",
@@ -3549,13 +4211,18 @@ config_weechat_init_options ()
"list of scripts and in scripts calling function hook_process); the "
"proxy must be defined with command /proxy"),
NULL, 0, 0, "", NULL, 0,
- &config_check_proxy_curl, NULL, NULL, NULL, NULL, NULL);
+ &config_check_proxy_curl, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
/* plugin */
ptr_section = config_file_new_section (weechat_config_file, "plugin",
0, 0,
- NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
config_file_free (weechat_config_file);
@@ -3570,37 +4237,46 @@ config_weechat_init_options ()
"\"!\" is a negative value to prevent a plugin from being loaded, "
"wildcard \"*\" is allowed in names (examples: \"*\" or "
"\"*,!lua,!tcl\")"),
- NULL, 0, 0, "*", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "*", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_plugin_debug = config_file_new_option (
weechat_config_file, ptr_section,
"debug", "boolean",
N_("enable debug messages by default in all plugins (option disabled "
"by default, which is highly recommended)"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_plugin_extension = config_file_new_option (
weechat_config_file, ptr_section,
"extension", "string",
N_("comma separated list of file name extensions for plugins"),
- NULL, 0, 0, ".so,.dll", NULL, 0, NULL, NULL,
- &config_change_plugin_extension, NULL, NULL, NULL);
+ NULL, 0, 0, ".so,.dll", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_plugin_extension, NULL, NULL,
+ NULL, NULL, NULL);
config_plugin_path = config_file_new_option (
weechat_config_file, ptr_section,
"path", "string",
N_("path for searching plugins (\"%h\" will be replaced by "
"WeeChat home, \"~/.weechat\" by default)"),
- NULL, 0, 0, "%h/plugins", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "%h/plugins", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_plugin_save_config_on_unload = config_file_new_option (
weechat_config_file, ptr_section,
"save_config_on_unload", "boolean",
N_("save configuration files when unloading plugins"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
/* bars */
- ptr_section = config_file_new_section (weechat_config_file, "bar",
- 0, 0,
- &config_weechat_bar_read_cb, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL);
+ ptr_section = config_file_new_section (
+ weechat_config_file, "bar",
+ 0, 0,
+ &config_weechat_bar_read_cb, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
config_file_free (weechat_config_file);
@@ -3610,11 +4286,14 @@ config_weechat_init_options ()
weechat_config_section_bar = ptr_section;
/* layout */
- ptr_section = config_file_new_section (weechat_config_file, "layout",
- 0, 0,
- &config_weechat_layout_read_cb, NULL,
- &config_weechat_layout_write_cb, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ ptr_section = config_file_new_section (
+ weechat_config_file, "layout",
+ 0, 0,
+ &config_weechat_layout_read_cb, NULL, NULL,
+ &config_weechat_layout_write_cb, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
config_file_free (weechat_config_file);
@@ -3622,13 +4301,14 @@ config_weechat_init_options ()
}
/* notify */
- ptr_section = config_file_new_section (weechat_config_file, "notify",
- 1, 1,
- NULL, NULL,
- NULL, NULL,
- NULL, NULL,
- &config_weechat_notify_create_option_cb, NULL,
- &config_weechat_notify_delete_option_cb, NULL);
+ ptr_section = config_file_new_section (
+ weechat_config_file, "notify",
+ 1, 1,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ &config_weechat_notify_create_option_cb, NULL, NULL,
+ &config_weechat_notify_delete_option_cb, NULL, NULL);
if (!ptr_section)
{
config_file_free (weechat_config_file);
@@ -3638,12 +4318,14 @@ config_weechat_init_options ()
weechat_config_section_notify = ptr_section;
/* filters */
- ptr_section = config_file_new_section (weechat_config_file, "filter",
- 0, 0,
- &config_weechat_filter_read_cb, NULL,
- &config_weechat_filter_write_cb, NULL,
- &config_weechat_filter_write_cb, NULL,
- NULL, NULL, NULL, NULL);
+ ptr_section = config_file_new_section (
+ weechat_config_file, "filter",
+ 0, 0,
+ &config_weechat_filter_read_cb, NULL, NULL,
+ &config_weechat_filter_write_cb, NULL, NULL,
+ &config_weechat_filter_write_cb, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
config_file_free (weechat_config_file);
@@ -3657,12 +4339,14 @@ config_weechat_init_options ()
"key%s%s",
(i == GUI_KEY_CONTEXT_DEFAULT) ? "" : "_",
(i == GUI_KEY_CONTEXT_DEFAULT) ? "" : gui_key_context_string[i]);
- ptr_section = config_file_new_section (weechat_config_file, section_name,
- 0, 0,
- &config_weechat_key_read_cb, NULL,
- &config_weechat_key_write_cb, NULL,
- &config_weechat_key_write_cb, NULL,
- NULL, NULL, NULL, NULL);
+ ptr_section = config_file_new_section (
+ weechat_config_file, section_name,
+ 0, 0,
+ &config_weechat_key_read_cb, NULL, NULL,
+ &config_weechat_key_write_cb, NULL, NULL,
+ &config_weechat_key_write_cb, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
config_file_free (weechat_config_file);
@@ -3711,18 +4395,18 @@ config_weechat_init ()
60, /* when second is 00 */
0,
&config_day_change_timer_cb,
- NULL);
+ NULL, NULL);
}
if (!config_highlight_regex)
- config_change_highlight_regex (NULL, NULL);
+ config_change_highlight_regex (NULL, NULL, NULL);
if (!config_highlight_tags)
- config_change_highlight_tags (NULL, NULL);
+ config_change_highlight_tags (NULL, NULL, NULL);
if (!config_plugin_extensions)
- config_change_plugin_extension (NULL, NULL);
+ config_change_plugin_extension (NULL, NULL, NULL);
if (!config_word_chars_highlight)
- config_change_word_chars_highlight (NULL, NULL);
+ config_change_word_chars_highlight (NULL, NULL, NULL);
if (!config_word_chars_input)
- config_change_word_chars_input (NULL, NULL);
+ config_change_word_chars_input (NULL, NULL, NULL);
return rc;
}
@@ -3812,4 +4496,17 @@ config_weechat_free ()
config_word_chars_input = NULL;
config_word_chars_input_count = 0;
}
+
+ if (config_nick_colors)
+ {
+ string_free_split (config_nick_colors);
+ config_nick_colors = NULL;
+ config_num_nick_colors = 0;
+ }
+
+ if (config_hashtable_nick_color_force)
+ {
+ hashtable_free (config_hashtable_nick_color_force);
+ config_hashtable_nick_color_force = NULL;
+ }
}
diff --git a/src/core/wee-config.h b/src/core/wee-config.h
index 9ce97a4f9..e4c4a3d33 100644
--- a/src/core/wee-config.h
+++ b/src/core/wee-config.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2005-2006 Emmanuel Bouthenot <kolter@openics.org>
*
* This file is part of WeeChat, the extensible chat client.
@@ -53,6 +53,12 @@ enum t_config_look_buffer_search_where
CONFIG_LOOK_BUFFER_SEARCH_PREFIX_MESSAGE,
};
+enum t_config_look_nick_color_hash
+{
+ CONFIG_LOOK_NICK_COLOR_HASH_DJB2 = 0,
+ CONFIG_LOOK_NICK_COLOR_HASH_SUM,
+};
+
enum t_config_look_prefix_align
{
CONFIG_LOOK_PREFIX_ALIGN_NONE = 0,
@@ -181,6 +187,7 @@ extern struct t_config_option *config_look_input_cursor_scroll;
extern struct t_config_option *config_look_input_share;
extern struct t_config_option *config_look_input_share_overwrite;
extern struct t_config_option *config_look_input_undo_max;
+extern struct t_config_option *config_look_item_away_message;
extern struct t_config_option *config_look_item_buffer_filter;
extern struct t_config_option *config_look_item_buffer_zoom;
extern struct t_config_option *config_look_item_mouse_status;
@@ -192,8 +199,12 @@ extern struct t_config_option *config_look_key_bind_safe;
extern struct t_config_option *config_look_key_grab_delay;
extern struct t_config_option *config_look_mouse;
extern struct t_config_option *config_look_mouse_timer_delay;
+extern struct t_config_option *config_look_nick_color_force;
+extern struct t_config_option *config_look_nick_color_hash;
+extern struct t_config_option *config_look_nick_color_stop_chars;
extern struct t_config_option *config_look_nick_prefix;
extern struct t_config_option *config_look_nick_suffix;
+extern struct t_config_option *config_look_paste_auto_add_newline;
extern struct t_config_option *config_look_paste_bracketed;
extern struct t_config_option *config_look_paste_bracketed_timer_delay;
extern struct t_config_option *config_look_paste_max_lines;
@@ -267,13 +278,14 @@ extern struct t_config_option *config_color_chat_text_found_bg;
extern struct t_config_option *config_color_chat_time;
extern struct t_config_option *config_color_chat_time_delimiters;
extern struct t_config_option *config_color_chat_value;
+extern struct t_config_option *config_color_chat_value_null;
extern struct t_config_option *config_color_emphasized;
extern struct t_config_option *config_color_emphasized_bg;
extern struct t_config_option *config_color_input_actions;
extern struct t_config_option *config_color_input_text_not_found;
+extern struct t_config_option *config_color_item_away;
extern struct t_config_option *config_color_nicklist_away;
extern struct t_config_option *config_color_nicklist_group;
-extern struct t_config_option *config_color_nicklist_offline;
extern struct t_config_option *config_color_separator;
extern struct t_config_option *config_color_status_count_highlight;
extern struct t_config_option *config_color_status_count_msg;
@@ -335,7 +347,11 @@ extern struct t_config_look_word_char_item *config_word_chars_highlight;
extern int config_word_chars_highlight_count;
extern struct t_config_look_word_char_item *config_word_chars_input;
extern int config_word_chars_input_count;
+extern char **config_nick_colors;
+extern int config_num_nick_colors;
+extern struct t_hashtable *config_hashtable_nick_color_force;
+extern void config_set_nick_colors ();
extern struct t_config_option *config_weechat_debug_get (const char *plugin_name);
extern int config_weechat_debug_set (const char *plugin_name,
const char *value);
diff --git a/src/core/wee-debug.c b/src/core/wee-debug.c
index bb82027ab..d6ab2118b 100644
--- a/src/core/wee-debug.c
+++ b/src/core/wee-debug.c
@@ -1,7 +1,7 @@
/*
* wee-debug.c - debug functions
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -127,10 +127,12 @@ debug_dump (int crash)
*/
int
-debug_dump_cb (void *data, const char *signal, const char *type_data,
+debug_dump_cb (const void *pointer, void *data,
+ const char *signal, const char *type_data,
void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -154,20 +156,26 @@ debug_sigsegv ()
unhook_all ();
gui_main_end (0);
- string_iconv_fprintf (stderr, "\n");
- string_iconv_fprintf (stderr, "*** Very bad! WeeChat is crashing (SIGSEGV received)\n");
+ string_fprintf (stderr,
+ "\n*** Very bad! WeeChat is crashing (SIGSEGV received)"
+ "\n");
if (!log_crash_rename ())
- string_iconv_fprintf (stderr,
- "*** Full crash dump was saved to %s/weechat.log file.\n",
- weechat_home);
- string_iconv_fprintf (stderr, "***\n");
- string_iconv_fprintf (stderr, "*** Please help WeeChat developers to fix this bug:\n");
- string_iconv_fprintf (stderr, "*** 1. If you have a core file, please run: gdb /path/to/weechat core\n");
- string_iconv_fprintf (stderr, "*** then issue command: \"bt full\" and send result to developers\n");
- string_iconv_fprintf (stderr, "*** (see user's guide for more info about report of crashes).\n");
- string_iconv_fprintf (stderr, "*** 2. Otherwise send backtrace (below), only if it is a complete trace.\n");
- string_iconv_fprintf (stderr, "*** Keep the crash log file, just in case developers ask you some info\n");
- string_iconv_fprintf (stderr, "*** (be careful, private info like passwords may be in this file).\n\n");
+ {
+ string_fprintf (stderr,
+ "*** Full crash dump was saved to %s/weechat.log file."
+ "\n",
+ weechat_home);
+ }
+ string_fprintf (
+ stderr,
+ "***\n"
+ "*** Please help WeeChat developers to fix this bug:\n"
+ "*** 1. If you have a core file, please run: gdb /path/to/weechat core\n"
+ "*** then issue command: \"bt full\" and send result to developers\n"
+ "*** (see user's guide for more info about report of crashes).\n"
+ "*** 2. Otherwise send backtrace (below), only if it is a complete trace.\n"
+ "*** Keep the crash log file, just in case developers ask you some info\n"
+ "*** (be careful, private info like passwords may be in this file).\n\n");
weechat_backtrace ();
@@ -317,7 +325,8 @@ debug_hdata_hash_list_map_cb (void *data,
*/
void
-debug_hdata_map_cb (void *data, struct t_hashtable *hashtable,
+debug_hdata_map_cb (void *data,
+ struct t_hashtable *hashtable,
const void *key, const void *value)
{
struct t_hdata *ptr_hdata;
@@ -338,13 +347,11 @@ debug_hdata_map_cb (void *data, struct t_hashtable *hashtable,
ptr_hdata->hash_list->items_count);
/* display lists */
- hashtable_map (ptr_hdata->hash_list,
- &debug_hdata_hash_list_map_cb, NULL);
+ hashtable_map (ptr_hdata->hash_list, &debug_hdata_hash_list_map_cb, NULL);
/* display vars */
list = weelist_new ();
- hashtable_map (ptr_hdata->hash_var,
- &debug_hdata_hash_var_map_cb, list);
+ hashtable_map (ptr_hdata->hash_var, &debug_hdata_hash_var_map_cb, list);
for (ptr_item = list->items; ptr_item;
ptr_item = ptr_item->next_item)
{
@@ -503,10 +510,12 @@ debug_infolists ()
*/
int
-debug_libs_cb (void *data, const char *signal, const char *type_data,
+debug_libs_cb (const void *pointer, void *data,
+ const char *signal, const char *type_data,
void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -641,8 +650,8 @@ debug_init ()
* plugins (they should anyway because this function is called before load
* of plugins)
*/
- hook_signal (NULL, "2000|debug_dump", &debug_dump_cb, NULL);
- hook_signal (NULL, "2000|debug_libs", &debug_libs_cb, NULL);
+ hook_signal (NULL, "2000|debug_dump", &debug_dump_cb, NULL, NULL);
+ hook_signal (NULL, "2000|debug_libs", &debug_libs_cb, NULL, NULL);
}
/*
diff --git a/src/core/wee-debug.h b/src/core/wee-debug.h
index 6b7394fc5..ab018aece 100644
--- a/src/core/wee-debug.h
+++ b/src/core/wee-debug.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/core/wee-eval.c b/src/core/wee-eval.c
index 4889a671d..2531107dc 100644
--- a/src/core/wee-eval.c
+++ b/src/core/wee-eval.c
@@ -1,7 +1,7 @@
/*
* wee-eval.c - evaluate expressions with references to internal vars
*
- * Copyright (C) 2012-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2012-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/core/wee-eval.h b/src/core/wee-eval.h
index 7aaf81f78..0670cb77c 100644
--- a/src/core/wee-eval.h
+++ b/src/core/wee-eval.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2012-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/core/wee-hashtable.c b/src/core/wee-hashtable.c
index 63916ee20..eb9613b12 100644
--- a/src/core/wee-hashtable.c
+++ b/src/core/wee-hashtable.c
@@ -1,7 +1,7 @@
/*
* wee-hashtable.c - implementation of hashtable
*
- * Copyright (C) 2010-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2010-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/core/wee-hashtable.h b/src/core/wee-hashtable.h
index c203b9636..941a95b13 100644
--- a/src/core/wee-hashtable.h
+++ b/src/core/wee-hashtable.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2010-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/core/wee-hdata.c b/src/core/wee-hdata.c
index 84c2fbae7..16c8abaab 100644
--- a/src/core/wee-hdata.c
+++ b/src/core/wee-hdata.c
@@ -1,7 +1,7 @@
/*
* wee-hdata.c - direct access to WeeChat data using hashtables
*
- * Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/core/wee-hdata.h b/src/core/wee-hdata.h
index 860da7e54..869e431b5 100644
--- a/src/core/wee-hdata.h
+++ b/src/core/wee-hdata.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c
index c0c195eef..40396facc 100644
--- a/src/core/wee-hook.c
+++ b/src/core/wee-hook.c
@@ -1,7 +1,7 @@
/*
* wee-hook.c - WeeChat hooks management
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2012 Simon Arlott
*
* This file is part of WeeChat, the extensible chat client.
@@ -76,6 +76,8 @@ int real_delete_pending = 0; /* 1 if some hooks must be deleted */
struct pollfd *hook_fd_pollfd = NULL; /* file descriptors for poll() */
int hook_fd_pollfd_count = 0; /* number of file descriptors */
+int hook_process_pending = 0; /* 1 if there are some process to */
+ /* run (via fork) */
void hook_process_run (struct t_hook *hook_process);
@@ -364,7 +366,8 @@ hook_get_priority_and_name (const char *string,
void
hook_init_data (struct t_hook *hook, struct t_weechat_plugin *plugin,
- int type, int priority, void *callback_data)
+ int type, int priority,
+ const void *callback_pointer, void *callback_data)
{
hook->plugin = plugin;
hook->subplugin = NULL;
@@ -372,16 +375,18 @@ hook_init_data (struct t_hook *hook, struct t_weechat_plugin *plugin,
hook->deleted = 0;
hook->running = 0;
hook->priority = priority;
+ hook->callback_pointer = callback_pointer;
hook->callback_data = callback_data;
hook->hook_data = NULL;
if (weechat_debug_core >= 2)
{
gui_chat_printf (NULL,
- "debug: adding hook: type=%d (%s), plugin=%lx (%s), "
+ "debug: adding hook: type=%d (%s), plugin=\"%s\", "
"priority=%d",
- hook->type, hook_type_string[hook->type],
- hook->plugin, plugin_get_name (hook->plugin),
+ hook->type,
+ hook_type_string[hook->type],
+ plugin_get_name (hook->plugin),
hook->priority);
}
}
@@ -647,7 +652,9 @@ hook_command (struct t_weechat_plugin *plugin, const char *command,
const char *description,
const char *args, const char *args_description,
const char *completion,
- t_hook_callback_command *callback, void *callback_data)
+ t_hook_callback_command *callback,
+ const void *callback_pointer,
+ void *callback_data)
{
struct t_hook *new_hook;
struct t_hook_command *new_hook_command;
@@ -680,7 +687,7 @@ hook_command (struct t_weechat_plugin *plugin, const char *command,
hook_get_priority_and_name (command, &priority, &ptr_command);
hook_init_data (new_hook, plugin, HOOK_TYPE_COMMAND, priority,
- callback_data);
+ callback_pointer, callback_data);
new_hook->hook_data = new_hook_command;
new_hook_command->callback = callback;
@@ -858,7 +865,12 @@ hook_command_exec (struct t_gui_buffer *buffer, int any_plugin,
/* execute the command! */
ptr_hook->running++;
rc = (int) (HOOK_COMMAND(ptr_hook, callback))
- (ptr_hook->callback_data, buffer, argc, argv, argv_eol);
+ (ptr_hook->callback_pointer,
+ ptr_hook->callback_data,
+ buffer,
+ argc,
+ argv,
+ argv_eol);
ptr_hook->running--;
if (rc == WEECHAT_RC_ERROR)
rc = HOOK_COMMAND_EXEC_ERROR;
@@ -882,8 +894,11 @@ hook_command_exec (struct t_gui_buffer *buffer, int any_plugin,
*/
struct t_hook *
-hook_command_run (struct t_weechat_plugin *plugin, const char *command,
- t_hook_callback_command_run *callback, void *callback_data)
+hook_command_run (struct t_weechat_plugin *plugin,
+ const char *command,
+ t_hook_callback_command_run *callback,
+ const void *callback_pointer,
+ void *callback_data)
{
struct t_hook *new_hook;
struct t_hook_command_run *new_hook_command_run;
@@ -905,7 +920,7 @@ hook_command_run (struct t_weechat_plugin *plugin, const char *command,
hook_get_priority_and_name (command, &priority, &ptr_command);
hook_init_data (new_hook, plugin, HOOK_TYPE_COMMAND_RUN, priority,
- callback_data);
+ callback_pointer, callback_data);
new_hook->hook_data = new_hook_command_run;
new_hook_command_run->callback = callback;
@@ -967,9 +982,11 @@ hook_command_run_exec (struct t_gui_buffer *buffer, const char *command)
if (hook_matching)
{
ptr_hook->running = 1;
- rc = (HOOK_COMMAND_RUN(ptr_hook, callback)) (ptr_hook->callback_data,
- buffer,
- ptr_command);
+ rc = (HOOK_COMMAND_RUN(ptr_hook, callback)) (
+ ptr_hook->callback_pointer,
+ ptr_hook->callback_data,
+ buffer,
+ ptr_command);
ptr_hook->running = 0;
if (rc == WEECHAT_RC_OK_EAT)
{
@@ -1054,6 +1071,7 @@ hook_timer_init (struct t_hook *hook)
struct t_hook *
hook_timer (struct t_weechat_plugin *plugin, long interval, int align_second,
int max_calls, t_hook_callback_timer *callback,
+ const void *callback_pointer,
void *callback_data)
{
struct t_hook *new_hook;
@@ -1073,7 +1091,7 @@ hook_timer (struct t_weechat_plugin *plugin, long interval, int align_second,
}
hook_init_data (new_hook, plugin, HOOK_TYPE_TIMER, HOOK_PRIORITY_DEFAULT,
- callback_data);
+ callback_pointer, callback_data);
new_hook->hook_data = new_hook_timer;
new_hook_timer->callback = callback;
@@ -1236,7 +1254,8 @@ hook_timer_exec ()
{
ptr_hook->running = 1;
(void) (HOOK_TIMER(ptr_hook, callback))
- (ptr_hook->callback_data,
+ (ptr_hook->callback_pointer,
+ ptr_hook->callback_data,
(HOOK_TIMER(ptr_hook, remaining_calls) > 0) ?
HOOK_TIMER(ptr_hook, remaining_calls) - 1 : -1);
ptr_hook->running = 0;
@@ -1295,7 +1314,9 @@ hook_search_fd (int fd)
struct t_hook *
hook_fd (struct t_weechat_plugin *plugin, int fd, int flag_read,
int flag_write, int flag_exception,
- t_hook_callback_fd *callback, void *callback_data)
+ t_hook_callback_fd *callback,
+ const void *callback_pointer,
+ void *callback_data)
{
struct t_hook *new_hook;
struct t_hook_fd *new_hook_fd;
@@ -1314,7 +1335,7 @@ hook_fd (struct t_weechat_plugin *plugin, int fd, int flag_read,
}
hook_init_data (new_hook, plugin, HOOK_TYPE_FD, HOOK_PRIORITY_DEFAULT,
- callback_data);
+ callback_pointer, callback_data);
new_hook->hook_data = new_hook_fd;
new_hook_fd->callback = callback;
@@ -1386,6 +1407,8 @@ hook_fd_exec ()
/* perform the poll() */
timeout = hook_timer_get_time_to_next ();
+ if (hook_process_pending)
+ timeout = 0;
ready = poll (hook_fd_pollfd, num_fd, timeout);
if (ready <= 0)
return;
@@ -1414,8 +1437,10 @@ hook_fd_exec ()
if (found)
{
ptr_hook->running = 1;
- (void) (HOOK_FD(ptr_hook, callback)) (ptr_hook->callback_data,
- HOOK_FD(ptr_hook, fd));
+ (void) (HOOK_FD(ptr_hook, callback)) (
+ ptr_hook->callback_pointer,
+ ptr_hook->callback_data,
+ HOOK_FD(ptr_hook, fd));
ptr_hook->running = 0;
}
}
@@ -1434,9 +1459,12 @@ hook_fd_exec ()
struct t_hook *
hook_process_hashtable (struct t_weechat_plugin *plugin,
- const char *command, struct t_hashtable *options,
+ const char *command,
+ struct t_hashtable *options,
int timeout,
- t_hook_callback_process *callback, void *callback_data)
+ t_hook_callback_process *callback,
+ const void *callback_pointer,
+ void *callback_data)
{
struct t_hook *new_hook;
struct t_hook_process *new_hook_process;
@@ -1469,7 +1497,7 @@ hook_process_hashtable (struct t_weechat_plugin *plugin,
goto error;
hook_init_data (new_hook, plugin, HOOK_TYPE_PROCESS, HOOK_PRIORITY_DEFAULT,
- callback_data);
+ callback_pointer, callback_data);
new_hook->hook_data = new_hook_process;
new_hook_process->callback = callback;
@@ -1523,7 +1551,10 @@ hook_process_hashtable (struct t_weechat_plugin *plugin,
new_hook_process->timeout);
}
- hook_process_run (new_hook);
+ if (strncmp (new_hook_process->command, "func:", 5) == 0)
+ hook_process_pending = 1;
+ else
+ hook_process_run (new_hook);
return new_hook;
@@ -1547,11 +1578,14 @@ error:
struct t_hook *
hook_process (struct t_weechat_plugin *plugin,
- const char *command, int timeout,
- t_hook_callback_process *callback, void *callback_data)
+ const char *command,
+ int timeout,
+ t_hook_callback_process *callback,
+ const void *callback_pointer,
+ void *callback_data)
{
return hook_process_hashtable (plugin, command, NULL, timeout,
- callback, callback_data);
+ callback, callback_pointer, callback_data);
}
/*
@@ -1629,6 +1663,16 @@ hook_process_child (struct t_hook *hook_process)
}
rc = weeurl_download (ptr_url, HOOK_PROCESS(hook_process, options));
}
+ else if (strncmp (HOOK_PROCESS(hook_process, command), "func:", 5) == 0)
+ {
+ /* run a function (via the hook callback) */
+ rc = (int) (HOOK_PROCESS(hook_process, callback))
+ (hook_process->callback_pointer,
+ hook_process->callback_data,
+ HOOK_PROCESS(hook_process, command),
+ WEECHAT_HOOK_PROCESS_CHILD,
+ NULL, NULL);
+ }
else
{
/* launch command */
@@ -1732,7 +1776,8 @@ hook_process_send_buffers (struct t_hook *hook_process, int callback_rc)
/* send buffers to callback */
(void) (HOOK_PROCESS(hook_process, callback))
- (hook_process->callback_data,
+ (hook_process->callback_pointer,
+ hook_process->callback_data,
HOOK_PROCESS(hook_process, command),
callback_rc,
(HOOK_PROCESS(hook_process, buffer_size[HOOK_PROCESS_STDOUT]) > 0) ?
@@ -1800,11 +1845,15 @@ hook_process_child_read (struct t_hook *hook_process, int fd,
*/
int
-hook_process_child_read_stdout_cb (void *arg_hook_process, int fd)
+hook_process_child_read_stdout_cb (const void *pointer, void *data, int fd)
{
struct t_hook *hook_process;
- hook_process = (struct t_hook *)arg_hook_process;
+ /* make C compiler happy */
+ (void) data;
+
+ hook_process = (struct t_hook *)pointer;
+
hook_process_child_read (hook_process, fd, HOOK_PROCESS_STDOUT,
&(HOOK_PROCESS(hook_process, hook_fd[HOOK_PROCESS_STDOUT])));
return WEECHAT_RC_OK;
@@ -1815,11 +1864,15 @@ hook_process_child_read_stdout_cb (void *arg_hook_process, int fd)
*/
int
-hook_process_child_read_stderr_cb (void *arg_hook_process, int fd)
+hook_process_child_read_stderr_cb (const void *pointer, void *data, int fd)
{
struct t_hook *hook_process;
- hook_process = (struct t_hook *)arg_hook_process;
+ /* make C compiler happy */
+ (void) data;
+
+ hook_process = (struct t_hook *)pointer;
+
hook_process_child_read (hook_process, fd, HOOK_PROCESS_STDERR,
&(HOOK_PROCESS(hook_process, hook_fd[HOOK_PROCESS_STDERR])));
return WEECHAT_RC_OK;
@@ -1882,6 +1935,7 @@ hook_process_child_read_until_eof (struct t_hook *hook_process)
{
(void) hook_process_child_read_stdout_cb (
hook_process,
+ NULL,
HOOK_PROCESS(hook_process,
child_read[HOOK_PROCESS_STDOUT]));
}
@@ -1889,6 +1943,7 @@ hook_process_child_read_until_eof (struct t_hook *hook_process)
{
(void) hook_process_child_read_stderr_cb (
hook_process,
+ NULL,
HOOK_PROCESS(hook_process,
child_read[HOOK_PROCESS_STDERR]));
}
@@ -1904,15 +1959,16 @@ hook_process_child_read_until_eof (struct t_hook *hook_process)
*/
int
-hook_process_timer_cb (void *arg_hook_process, int remaining_calls)
+hook_process_timer_cb (const void *pointer, void *data, int remaining_calls)
{
struct t_hook *hook_process;
int status, rc;
/* make C compiler happy */
+ (void) data;
(void) remaining_calls;
- hook_process = (struct t_hook *)arg_hook_process;
+ hook_process = (struct t_hook *)pointer;
if (hook_process->deleted)
return WEECHAT_RC_OK;
@@ -2006,7 +2062,8 @@ hook_process_run (struct t_hook *hook_process)
/* fork failed */
case -1:
(void) (HOOK_PROCESS(hook_process, callback))
- (hook_process->callback_data,
+ (hook_process->callback_pointer,
+ hook_process->callback_data,
HOOK_PROCESS(hook_process, command),
WEECHAT_HOOK_PROCESS_ERROR,
NULL, NULL);
@@ -2047,7 +2104,7 @@ hook_process_run (struct t_hook *hook_process)
HOOK_PROCESS(hook_process, child_read[HOOK_PROCESS_STDOUT]),
1, 0, 0,
&hook_process_child_read_stdout_cb,
- hook_process);
+ hook_process, NULL);
}
if (HOOK_PROCESS(hook_process, child_read[HOOK_PROCESS_STDERR]) >= 0)
@@ -2057,7 +2114,7 @@ hook_process_run (struct t_hook *hook_process)
HOOK_PROCESS(hook_process, child_read[HOOK_PROCESS_STDERR]),
1, 0, 0,
&hook_process_child_read_stderr_cb,
- hook_process);
+ hook_process, NULL);
}
timeout = HOOK_PROCESS(hook_process, timeout);
@@ -2081,7 +2138,8 @@ hook_process_run (struct t_hook *hook_process)
HOOK_PROCESS(hook_process, hook_timer) = hook_timer (hook_process->plugin,
interval, 0, max_calls,
&hook_process_timer_cb,
- hook_process);
+ hook_process,
+ NULL);
return;
error:
@@ -2093,7 +2151,8 @@ error:
close (pipes[i][1]);
}
(void) (HOOK_PROCESS(hook_process, callback))
- (hook_process->callback_data,
+ (hook_process->callback_pointer,
+ hook_process->callback_data,
HOOK_PROCESS(hook_process, command),
WEECHAT_HOOK_PROCESS_ERROR,
NULL, NULL);
@@ -2101,6 +2160,39 @@ error:
}
/*
+ * Executes all process commands pending.
+ */
+
+void
+hook_process_exec ()
+{
+ struct t_hook *ptr_hook, *next_hook;
+
+ hook_exec_start ();
+
+ ptr_hook = weechat_hooks[HOOK_TYPE_PROCESS];
+ while (ptr_hook)
+ {
+ next_hook = ptr_hook->next_hook;
+
+ if (!ptr_hook->deleted
+ && !ptr_hook->running
+ && (HOOK_PROCESS(ptr_hook, child_pid) == 0))
+ {
+ ptr_hook->running = 1;
+ hook_process_run (ptr_hook);
+ ptr_hook->running = 0;
+ }
+
+ ptr_hook = next_hook;
+ }
+
+ hook_exec_end ();
+
+ hook_process_pending = 0;
+}
+
+/*
* Hooks a connection to a peer (using fork).
*
* Returns pointer to new hook, NULL if error.
@@ -2111,7 +2203,9 @@ hook_connect (struct t_weechat_plugin *plugin, const char *proxy,
const char *address, int port, int ipv6, int retry,
void *gnutls_sess, void *gnutls_cb, int gnutls_dhkey_size,
const char *gnutls_priorities, const char *local_hostname,
- t_hook_callback_connect *callback, void *callback_data)
+ t_hook_callback_connect *callback,
+ const void *callback_pointer,
+ void *callback_data)
{
struct t_hook *new_hook;
struct t_hook_connect *new_hook_connect;
@@ -2141,7 +2235,7 @@ hook_connect (struct t_weechat_plugin *plugin, const char *proxy,
}
hook_init_data (new_hook, plugin, HOOK_TYPE_CONNECT, HOOK_PRIORITY_DEFAULT,
- callback_data);
+ callback_pointer, callback_data);
new_hook->hook_data = new_hook_connect;
new_hook_connect->callback = callback;
@@ -2207,7 +2301,9 @@ hook_connect_gnutls_verify_certificates (gnutls_session_t tls_session)
&& (*(HOOK_CONNECT(ptr_hook, gnutls_sess)) == tls_session))
{
rc = (int) (HOOK_CONNECT(ptr_hook, gnutls_cb))
- (ptr_hook->callback_data, tls_session, NULL, 0,
+ (ptr_hook->callback_pointer,
+ ptr_hook->callback_data,
+ tls_session, NULL, 0,
NULL, 0, NULL,
WEECHAT_HOOK_CONNECT_GNUTLS_CB_VERIFY_CERT);
break;
@@ -2248,7 +2344,9 @@ hook_connect_gnutls_set_certificates (gnutls_session_t tls_session,
&& (*(HOOK_CONNECT(ptr_hook, gnutls_sess)) == tls_session))
{
rc = (int) (HOOK_CONNECT(ptr_hook, gnutls_cb))
- (ptr_hook->callback_data, tls_session, req_ca, nreq,
+ (ptr_hook->callback_pointer,
+ ptr_hook->callback_data,
+ tls_session, req_ca, nreq,
pk_algos, pk_algos_len, answer,
WEECHAT_HOOK_CONNECT_GNUTLS_CB_SET_CERT);
break;
@@ -2269,7 +2367,9 @@ hook_connect_gnutls_set_certificates (gnutls_session_t tls_session,
struct t_hook *
hook_print (struct t_weechat_plugin *plugin, struct t_gui_buffer *buffer,
const char *tags, const char *message, int strip_colors,
- t_hook_callback_print *callback, void *callback_data)
+ t_hook_callback_print *callback,
+ const void *callback_pointer,
+ void *callback_data)
{
struct t_hook *new_hook;
struct t_hook_print *new_hook_print;
@@ -2290,7 +2390,7 @@ hook_print (struct t_weechat_plugin *plugin, struct t_gui_buffer *buffer,
}
hook_init_data (new_hook, plugin, HOOK_TYPE_PRINT, HOOK_PRIORITY_DEFAULT,
- callback_data);
+ callback_pointer, callback_data);
new_hook->hook_data = new_hook_print;
new_hook_print->callback = callback;
@@ -2374,7 +2474,8 @@ hook_print_exec (struct t_gui_buffer *buffer, struct t_gui_line *line)
/* run callback */
ptr_hook->running = 1;
(void) (HOOK_PRINT(ptr_hook, callback))
- (ptr_hook->callback_data, buffer, line->data->date,
+ (ptr_hook->callback_pointer,
+ ptr_hook->callback_data, buffer, line->data->date,
line->data->tags_count,
(const char **)line->data->tags_array,
(int)line->data->displayed, (int)line->data->highlight,
@@ -2403,7 +2504,9 @@ hook_print_exec (struct t_gui_buffer *buffer, struct t_gui_line *line)
struct t_hook *
hook_signal (struct t_weechat_plugin *plugin, const char *signal,
- t_hook_callback_signal *callback, void *callback_data)
+ t_hook_callback_signal *callback,
+ const void *callback_pointer,
+ void *callback_data)
{
struct t_hook *new_hook;
struct t_hook_signal *new_hook_signal;
@@ -2425,7 +2528,7 @@ hook_signal (struct t_weechat_plugin *plugin, const char *signal,
hook_get_priority_and_name (signal, &priority, &ptr_signal);
hook_init_data (new_hook, plugin, HOOK_TYPE_SIGNAL, priority,
- callback_data);
+ callback_pointer, callback_data);
new_hook->hook_data = new_hook_signal;
new_hook_signal->callback = callback;
@@ -2461,7 +2564,11 @@ hook_signal_send (const char *signal, const char *type_data, void *signal_data)
{
ptr_hook->running = 1;
rc = (HOOK_SIGNAL(ptr_hook, callback))
- (ptr_hook->callback_data, signal, type_data, signal_data);
+ (ptr_hook->callback_pointer,
+ ptr_hook->callback_data,
+ signal,
+ type_data,
+ signal_data);
ptr_hook->running = 0;
if (rc == WEECHAT_RC_OK_EAT)
@@ -2484,7 +2591,9 @@ hook_signal_send (const char *signal, const char *type_data, void *signal_data)
struct t_hook *
hook_hsignal (struct t_weechat_plugin *plugin, const char *signal,
- t_hook_callback_hsignal *callback, void *callback_data)
+ t_hook_callback_hsignal *callback,
+ const void *callback_pointer,
+ void *callback_data)
{
struct t_hook *new_hook;
struct t_hook_hsignal *new_hook_hsignal;
@@ -2506,7 +2615,7 @@ hook_hsignal (struct t_weechat_plugin *plugin, const char *signal,
hook_get_priority_and_name (signal, &priority, &ptr_signal);
hook_init_data (new_hook, plugin, HOOK_TYPE_HSIGNAL, priority,
- callback_data);
+ callback_pointer, callback_data);
new_hook->hook_data = new_hook_hsignal;
new_hook_hsignal->callback = callback;
@@ -2542,7 +2651,10 @@ hook_hsignal_send (const char *signal, struct t_hashtable *hashtable)
{
ptr_hook->running = 1;
rc = (HOOK_HSIGNAL(ptr_hook, callback))
- (ptr_hook->callback_data, signal, hashtable);
+ (ptr_hook->callback_pointer,
+ ptr_hook->callback_data,
+ signal,
+ hashtable);
ptr_hook->running = 0;
if (rc == WEECHAT_RC_OK_EAT)
@@ -2565,7 +2677,9 @@ hook_hsignal_send (const char *signal, struct t_hashtable *hashtable)
struct t_hook *
hook_config (struct t_weechat_plugin *plugin, const char *option,
- t_hook_callback_config *callback, void *callback_data)
+ t_hook_callback_config *callback,
+ const void *callback_pointer,
+ void *callback_data)
{
struct t_hook *new_hook;
struct t_hook_config *new_hook_config;
@@ -2587,7 +2701,7 @@ hook_config (struct t_weechat_plugin *plugin, const char *option,
hook_get_priority_and_name (option, &priority, &ptr_option);
hook_init_data (new_hook, plugin, HOOK_TYPE_CONFIG, priority,
- callback_data);
+ callback_pointer, callback_data);
new_hook->hook_data = new_hook_config;
new_hook_config->callback = callback;
@@ -2622,7 +2736,10 @@ hook_config_exec (const char *option, const char *value)
{
ptr_hook->running = 1;
(void) (HOOK_CONFIG(ptr_hook, callback))
- (ptr_hook->callback_data, option, value);
+ (ptr_hook->callback_pointer,
+ ptr_hook->callback_data,
+ option,
+ value);
ptr_hook->running = 0;
}
@@ -2641,7 +2758,9 @@ hook_config_exec (const char *option, const char *value)
struct t_hook *
hook_completion (struct t_weechat_plugin *plugin, const char *completion_item,
const char *description,
- t_hook_callback_completion *callback, void *callback_data)
+ t_hook_callback_completion *callback,
+ const void *callback_pointer,
+ void *callback_data)
{
struct t_hook *new_hook;
struct t_hook_completion *new_hook_completion;
@@ -2664,7 +2783,7 @@ hook_completion (struct t_weechat_plugin *plugin, const char *completion_item,
hook_get_priority_and_name (completion_item, &priority, &ptr_completion_item);
hook_init_data (new_hook, plugin, HOOK_TYPE_COMPLETION, priority,
- callback_data);
+ callback_pointer, callback_data);
new_hook->hook_data = new_hook_completion;
new_hook_completion->callback = callback;
@@ -2730,7 +2849,11 @@ hook_completion_exec (struct t_weechat_plugin *plugin,
{
ptr_hook->running = 1;
(void) (HOOK_COMPLETION(ptr_hook, callback))
- (ptr_hook->callback_data, completion_item, buffer, completion);
+ (ptr_hook->callback_pointer,
+ ptr_hook->callback_data,
+ completion_item,
+ buffer,
+ completion);
ptr_hook->running = 0;
}
@@ -2748,7 +2871,9 @@ hook_completion_exec (struct t_weechat_plugin *plugin,
struct t_hook *
hook_modifier (struct t_weechat_plugin *plugin, const char *modifier,
- t_hook_callback_modifier *callback, void *callback_data)
+ t_hook_callback_modifier *callback,
+ const void *callback_pointer,
+ void *callback_data)
{
struct t_hook *new_hook;
struct t_hook_modifier *new_hook_modifier;
@@ -2770,7 +2895,7 @@ hook_modifier (struct t_weechat_plugin *plugin, const char *modifier,
hook_get_priority_and_name (modifier, &priority, &ptr_modifier);
hook_init_data (new_hook, plugin, HOOK_TYPE_MODIFIER, priority,
- callback_data);
+ callback_pointer, callback_data);
new_hook->hook_data = new_hook_modifier;
new_hook_modifier->callback = callback;
@@ -2819,7 +2944,10 @@ hook_modifier_exec (struct t_weechat_plugin *plugin, const char *modifier,
{
ptr_hook->running = 1;
new_msg = (HOOK_MODIFIER(ptr_hook, callback))
- (ptr_hook->callback_data, modifier, modifier_data,
+ (ptr_hook->callback_pointer,
+ ptr_hook->callback_data,
+ modifier,
+ modifier_data,
message_modified);
ptr_hook->running = 0;
@@ -2856,7 +2984,9 @@ hook_modifier_exec (struct t_weechat_plugin *plugin, const char *modifier,
struct t_hook *
hook_info (struct t_weechat_plugin *plugin, const char *info_name,
const char *description, const char *args_description,
- t_hook_callback_info *callback, void *callback_data)
+ t_hook_callback_info *callback,
+ const void *callback_pointer,
+ void *callback_data)
{
struct t_hook *new_hook;
struct t_hook_info *new_hook_info;
@@ -2877,7 +3007,8 @@ hook_info (struct t_weechat_plugin *plugin, const char *info_name,
}
hook_get_priority_and_name (info_name, &priority, &ptr_info_name);
- hook_init_data (new_hook, plugin, HOOK_TYPE_INFO, priority, callback_data);
+ hook_init_data (new_hook, plugin, HOOK_TYPE_INFO, priority,
+ callback_pointer, callback_data);
new_hook->hook_data = new_hook_info;
new_hook_info->callback = callback;
@@ -2923,7 +3054,10 @@ hook_info_get (struct t_weechat_plugin *plugin, const char *info_name,
{
ptr_hook->running = 1;
value = (HOOK_INFO(ptr_hook, callback))
- (ptr_hook->callback_data, info_name, arguments);
+ (ptr_hook->callback_pointer,
+ ptr_hook->callback_data,
+ info_name,
+ arguments);
ptr_hook->running = 0;
hook_exec_end ();
@@ -2950,6 +3084,7 @@ hook_info_hashtable (struct t_weechat_plugin *plugin, const char *info_name,
const char *description, const char *args_description,
const char *output_description,
t_hook_callback_info_hashtable *callback,
+ const void *callback_pointer,
void *callback_data)
{
struct t_hook *new_hook;
@@ -2972,7 +3107,7 @@ hook_info_hashtable (struct t_weechat_plugin *plugin, const char *info_name,
hook_get_priority_and_name (info_name, &priority, &ptr_info_name);
hook_init_data (new_hook, plugin, HOOK_TYPE_INFO_HASHTABLE, priority,
- callback_data);
+ callback_pointer, callback_data);
new_hook->hook_data = new_hook_info_hashtable;
new_hook_info_hashtable->callback = callback;
@@ -3020,7 +3155,10 @@ hook_info_get_hashtable (struct t_weechat_plugin *plugin, const char *info_name,
{
ptr_hook->running = 1;
value = (HOOK_INFO_HASHTABLE(ptr_hook, callback))
- (ptr_hook->callback_data, info_name, hashtable);
+ (ptr_hook->callback_pointer,
+ ptr_hook->callback_data,
+ info_name,
+ hashtable);
ptr_hook->running = 0;
hook_exec_end ();
@@ -3046,7 +3184,9 @@ struct t_hook *
hook_infolist (struct t_weechat_plugin *plugin, const char *infolist_name,
const char *description, const char *pointer_description,
const char *args_description,
- t_hook_callback_infolist *callback, void *callback_data)
+ t_hook_callback_infolist *callback,
+ const void *callback_pointer,
+ void *callback_data)
{
struct t_hook *new_hook;
struct t_hook_infolist *new_hook_infolist;
@@ -3068,7 +3208,7 @@ hook_infolist (struct t_weechat_plugin *plugin, const char *infolist_name,
hook_get_priority_and_name (infolist_name, &priority, &ptr_infolist_name);
hook_init_data (new_hook, plugin, HOOK_TYPE_INFOLIST, priority,
- callback_data);
+ callback_pointer, callback_data);
new_hook->hook_data = new_hook_infolist;
new_hook_infolist->callback = callback;
@@ -3116,7 +3256,11 @@ hook_infolist_get (struct t_weechat_plugin *plugin, const char *infolist_name,
{
ptr_hook->running = 1;
value = (HOOK_INFOLIST(ptr_hook, callback))
- (ptr_hook->callback_data, infolist_name, pointer, arguments);
+ (ptr_hook->callback_pointer,
+ ptr_hook->callback_data,
+ infolist_name,
+ pointer,
+ arguments);
ptr_hook->running = 0;
hook_exec_end ();
@@ -3141,7 +3285,9 @@ hook_infolist_get (struct t_weechat_plugin *plugin, const char *infolist_name,
struct t_hook *
hook_hdata (struct t_weechat_plugin *plugin, const char *hdata_name,
const char *description,
- t_hook_callback_hdata *callback, void *callback_data)
+ t_hook_callback_hdata *callback,
+ const void *callback_pointer,
+ void *callback_data)
{
struct t_hook *new_hook;
struct t_hook_hdata *new_hook_hdata;
@@ -3163,7 +3309,7 @@ hook_hdata (struct t_weechat_plugin *plugin, const char *hdata_name,
hook_get_priority_and_name (hdata_name, &priority, &ptr_hdata_name);
hook_init_data (new_hook, plugin, HOOK_TYPE_HDATA, priority,
- callback_data);
+ callback_pointer, callback_data);
new_hook->hook_data = new_hook_hdata;
new_hook_hdata->callback = callback;
@@ -3212,7 +3358,8 @@ hook_hdata_get (struct t_weechat_plugin *plugin, const char *hdata_name)
{
ptr_hook->running = 1;
value = (HOOK_HDATA(ptr_hook, callback))
- (ptr_hook->callback_data,
+ (ptr_hook->callback_pointer,
+ ptr_hook->callback_data,
HOOK_HDATA(ptr_hook, hdata_name));
ptr_hook->running = 0;
@@ -3236,8 +3383,11 @@ hook_hdata_get (struct t_weechat_plugin *plugin, const char *hdata_name)
*/
struct t_hook *
-hook_focus (struct t_weechat_plugin *plugin, const char *area,
- t_hook_callback_focus *callback, void *callback_data)
+hook_focus (struct t_weechat_plugin *plugin,
+ const char *area,
+ t_hook_callback_focus *callback,
+ const void *callback_pointer,
+ void *callback_data)
{
struct t_hook *new_hook;
struct t_hook_focus *new_hook_focus;
@@ -3259,7 +3409,7 @@ hook_focus (struct t_weechat_plugin *plugin, const char *area,
hook_get_priority_and_name (area, &priority, &ptr_area);
hook_init_data (new_hook, plugin, HOOK_TYPE_FOCUS, priority,
- callback_data);
+ callback_pointer, callback_data);
new_hook->hook_data = new_hook_focus;
new_hook_focus->callback = callback;
@@ -3275,7 +3425,8 @@ hook_focus (struct t_weechat_plugin *plugin, const char *area,
*/
void
-hook_focus_hashtable_map_cb (void *data, struct t_hashtable *hashtable,
+hook_focus_hashtable_map_cb (void *data,
+ struct t_hashtable *hashtable,
const void *key, const void *value)
{
struct t_hashtable *hashtable1;
@@ -3294,7 +3445,8 @@ hook_focus_hashtable_map_cb (void *data, struct t_hashtable *hashtable,
*/
void
-hook_focus_hashtable_map2_cb (void *data, struct t_hashtable *hashtable,
+hook_focus_hashtable_map2_cb (void *data,
+ struct t_hashtable *hashtable,
const void *key, const void *value)
{
struct t_hashtable *hashtable1;
@@ -3363,7 +3515,9 @@ hook_focus_get_data (struct t_hashtable *hashtable_focus1,
/* run callback for focus #1 */
ptr_hook->running = 1;
hashtable_ret = (HOOK_FOCUS(ptr_hook, callback))
- (ptr_hook->callback_data, hashtable1);
+ (ptr_hook->callback_pointer,
+ ptr_hook->callback_data,
+ hashtable1);
ptr_hook->running = 0;
if (hashtable_ret)
{
@@ -3385,7 +3539,9 @@ hook_focus_get_data (struct t_hashtable *hashtable_focus1,
{
ptr_hook->running = 1;
hashtable_ret = (HOOK_FOCUS(ptr_hook, callback))
- (ptr_hook->callback_data, hashtable2);
+ (ptr_hook->callback_pointer,
+ ptr_hook->callback_data,
+ hashtable2);
ptr_hook->running = 0;
if (hashtable_ret)
{
@@ -3409,7 +3565,8 @@ hook_focus_get_data (struct t_hashtable *hashtable_focus1,
if (hashtable2)
{
- hashtable_map (hashtable2, &hook_focus_hashtable_map2_cb, hashtable1);
+ hashtable_map (hashtable2,
+ &hook_focus_hashtable_map2_cb, hashtable1);
hashtable_free (hashtable2);
}
else
@@ -3538,17 +3695,13 @@ unhook (struct t_hook *hook)
if (weechat_debug_core >= 2)
{
gui_chat_printf (NULL,
- "debug: removing hook: type=%d (%s), plugin=%lx (%s)",
- hook->type, hook_type_string[hook->type],
- hook->plugin, plugin_get_name (hook->plugin));
+ "debug: removing hook: type=%d (%s), plugin=\"%s\"",
+ hook->type,
+ hook_type_string[hook->type],
+ plugin_get_name (hook->plugin));
}
- /* free data */
- if (hook->subplugin)
- {
- free (hook->subplugin);
- hook->subplugin = NULL;
- }
+ /* free data specific to the hook */
if (hook->hook_data)
{
switch (hook->type)
@@ -3949,6 +4102,18 @@ unhook (struct t_hook *hook)
hook->hook_data = NULL;
}
+ /* free data common to all hooks */
+ if (hook->subplugin)
+ {
+ free (hook->subplugin);
+ hook->subplugin = NULL;
+ }
+ if (hook->callback_data)
+ {
+ free (hook->callback_data);
+ hook->callback_data = NULL;
+ }
+
/* remove hook from list (if there's no hook exec pending) */
if (hook_exec_recursion == 0)
{
@@ -3963,11 +4128,11 @@ unhook (struct t_hook *hook)
}
/*
- * Unhooks everything for a plugin.
+ * Unhooks everything for a plugin/subplugin.
*/
void
-unhook_all_plugin (struct t_weechat_plugin *plugin)
+unhook_all_plugin (struct t_weechat_plugin *plugin, const char *subplugin)
{
int type;
struct t_hook *ptr_hook, *next_hook;
@@ -3979,7 +4144,14 @@ unhook_all_plugin (struct t_weechat_plugin *plugin)
{
next_hook = ptr_hook->next_hook;
if (ptr_hook->plugin == plugin)
- unhook (ptr_hook);
+ {
+ if (!subplugin
+ || (ptr_hook->subplugin &&
+ strcmp (ptr_hook->subplugin, subplugin) == 0))
+ {
+ unhook (ptr_hook);
+ }
+ }
ptr_hook = next_hook;
}
}
@@ -4043,6 +4215,10 @@ hook_add_to_infolist_pointer (struct t_infolist *infolist, struct t_hook *hook)
return 0;
if (!infolist_new_var_integer (ptr_item, "priority", hook->priority))
return 0;
+ if (!infolist_new_var_pointer (ptr_item, "callback_pointer", (void *)hook->callback_pointer))
+ return 0;
+ if (!infolist_new_var_pointer (ptr_item, "callback_data", (void *)hook->callback_data))
+ return 0;
switch (hook->type)
{
case HOOK_TYPE_COMMAND:
@@ -4519,6 +4695,7 @@ hook_print_log ()
log_printf (" deleted . . . . . . . . : %d", ptr_hook->deleted);
log_printf (" running . . . . . . . . : %d", ptr_hook->running);
log_printf (" priority. . . . . . . . : %d", ptr_hook->priority);
+ log_printf (" callback_pointer. . . . : 0x%lx", ptr_hook->callback_pointer);
log_printf (" callback_data . . . . . : 0x%lx", ptr_hook->callback_data);
if (ptr_hook->deleted)
continue;
diff --git a/src/core/wee-hook.h b/src/core/wee-hook.h
index 82de5b7bd..ae6ba5600 100644
--- a/src/core/wee-hook.h
+++ b/src/core/wee-hook.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2012 Simon Arlott
*
* This file is part of WeeChat, the extensible chat client.
@@ -27,7 +27,7 @@
#include <gnutls/gnutls.h>
#endif
-#if defined(__CYGWIN__) || defined(__APPLE__) || defined(__MACH__)
+#if !defined(HAVE_SOCKETPAIR_SOCK_DGRAM) || defined(__CYGWIN__) || defined(__APPLE__) || defined(__MACH__)
/*
* For the connect hook, when this is defined an array of sockets will
* be passed from the parent process to the child process instead of using
@@ -133,6 +133,7 @@ struct t_hook
int deleted; /* hook marked for deletion ? */
int running; /* 1 if hook is currently running */
int priority; /* priority (to sort hooks) */
+ const void *callback_pointer; /* pointer sent to callback */
void *callback_data; /* data sent to callback */
/* hook data (depends on hook type) */
@@ -143,7 +144,8 @@ struct t_hook
/* hook command */
-typedef int (t_hook_callback_command)(void *data, struct t_gui_buffer *buffer,
+typedef int (t_hook_callback_command)(const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol);
struct t_hook_command
@@ -172,7 +174,7 @@ struct t_hook_command
/* hook command run */
-typedef int (t_hook_callback_command_run)(void *data,
+typedef int (t_hook_callback_command_run)(const void *pointer, void *data,
struct t_gui_buffer *buffer,
const char *command);
@@ -184,7 +186,8 @@ struct t_hook_command_run
/* hook timer */
-typedef int (t_hook_callback_timer)(void *data, int remaining_calls);
+typedef int (t_hook_callback_timer)(const void *pointer, void *data,
+ int remaining_calls);
struct t_hook_timer
{
@@ -199,7 +202,7 @@ struct t_hook_timer
/* hook fd */
-typedef int (t_hook_callback_fd)(void *data, int fd);
+typedef int (t_hook_callback_fd)(const void *pointer, void *data, int fd);
struct t_hook_fd
{
@@ -212,9 +215,10 @@ struct t_hook_fd
/* hook process */
-typedef int (t_hook_callback_process)(void *data, const char *command,
- int return_code, const char *out,
- const char *err);
+typedef int (t_hook_callback_process)(const void *pointer, void *data,
+ const char *command,
+ int return_code,
+ const char *out, const char *err);
struct t_hook_process
{
@@ -235,13 +239,14 @@ struct t_hook_process
/* hook connect */
-typedef int (t_hook_callback_connect)(void *data, int status,
- int gnutls_rc, int sock,
+typedef int (t_hook_callback_connect)(const void *pointer, void *data,
+ int status, int gnutls_rc, int sock,
const char *error,
const char *ip_address);
#ifdef HAVE_GNUTLS
-typedef int (gnutls_callback_t)(void *data, gnutls_session_t tls_session,
+typedef int (gnutls_callback_t)(const void *pointer, void *data,
+ gnutls_session_t tls_session,
const gnutls_datum_t *req_ca, int nreq,
const gnutls_pk_algorithm_t *pk_algos,
int pk_algos_len,
@@ -288,7 +293,8 @@ struct t_hook_connect
/* hook print */
-typedef int (t_hook_callback_print)(void *data, struct t_gui_buffer *buffer,
+typedef int (t_hook_callback_print)(const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
time_t date, int tags_count,
const char **tags, int displayed,
int highlight, const char *prefix,
@@ -306,8 +312,9 @@ struct t_hook_print
/* hook signal */
-typedef int (t_hook_callback_signal)(void *data, const char *signal,
- const char *type_data, void *signal_data);
+typedef int (t_hook_callback_signal)(const void *pointer, void *data,
+ const char *signal, const char *type_data,
+ void *signal_data);
struct t_hook_signal
{
@@ -318,7 +325,8 @@ struct t_hook_signal
/* hook hsignal */
-typedef int (t_hook_callback_hsignal)(void *data, const char *signal,
+typedef int (t_hook_callback_hsignal)(const void *pointer, void *data,
+ const char *signal,
struct t_hashtable *hashtable);
struct t_hook_hsignal
@@ -330,8 +338,8 @@ struct t_hook_hsignal
/* hook config */
-typedef int (t_hook_callback_config)(void *data, const char *option,
- const char *value);
+typedef int (t_hook_callback_config)(const void *pointer, void *data,
+ const char *option, const char *value);
struct t_hook_config
{
@@ -342,7 +350,7 @@ struct t_hook_config
/* hook completion */
-typedef int (t_hook_callback_completion)(void *data,
+typedef int (t_hook_callback_completion)(const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion);
@@ -356,7 +364,8 @@ struct t_hook_completion
/* hook modifier */
-typedef char *(t_hook_callback_modifier)(void *data, const char *modifier,
+typedef char *(t_hook_callback_modifier)(const void *pointer, void *data,
+ const char *modifier,
const char *modifier_data,
const char *string);
@@ -368,7 +377,8 @@ struct t_hook_modifier
/* hook info */
-typedef const char *(t_hook_callback_info)(void *data, const char *info_name,
+typedef const char *(t_hook_callback_info)(const void *pointer, void *data,
+ const char *info_name,
const char *arguments);
struct t_hook_info
@@ -381,7 +391,8 @@ struct t_hook_info
/* hook info (hashtable) */
-typedef struct t_hashtable *(t_hook_callback_info_hashtable)(void *data,
+typedef struct t_hashtable *(t_hook_callback_info_hashtable)(const void *pointer,
+ void *data,
const char *info_name,
struct t_hashtable *hashtable);
@@ -396,9 +407,10 @@ struct t_hook_info_hashtable
/* hook infolist */
-typedef struct t_infolist *(t_hook_callback_infolist)(void *data,
+typedef struct t_infolist *(t_hook_callback_infolist)(const void *pointer,
+ void *data,
const char *infolist_name,
- void *pointer,
+ void *obj_pointer,
const char *arguments);
struct t_hook_infolist
@@ -412,7 +424,8 @@ struct t_hook_infolist
/* hook hdata */
-typedef struct t_hdata *(t_hook_callback_hdata)(void *data,
+typedef struct t_hdata *(t_hook_callback_hdata)(const void *pointer,
+ void *data,
const char *hdata_name);
struct t_hook_hdata
@@ -424,7 +437,8 @@ struct t_hook_hdata
/* hook focus */
-typedef struct t_hashtable *(t_hook_callback_focus)(void *data,
+typedef struct t_hashtable *(t_hook_callback_focus)(const void *pointer,
+ void *data,
struct t_hashtable *info);
struct t_hook_focus
@@ -452,6 +466,7 @@ extern struct t_hook *hook_command (struct t_weechat_plugin *plugin,
const char *args_description,
const char *completion,
t_hook_callback_command *callback,
+ const void *callback_pointer,
void *callback_data);
extern int hook_command_exec (struct t_gui_buffer *buffer, int any_plugin,
struct t_weechat_plugin *plugin,
@@ -459,6 +474,7 @@ extern int hook_command_exec (struct t_gui_buffer *buffer, int any_plugin,
extern struct t_hook *hook_command_run (struct t_weechat_plugin *plugin,
const char *command,
t_hook_callback_command_run *callback,
+ const void *callback_pointer,
void *callback_data);
extern int hook_command_run_exec (struct t_gui_buffer *buffer,
const char *command);
@@ -466,25 +482,30 @@ extern struct t_hook *hook_timer (struct t_weechat_plugin *plugin,
long interval, int align_second,
int max_calls,
t_hook_callback_timer *callback,
+ const void *callback_pointer,
void *callback_data);
extern void hook_timer_exec ();
extern struct t_hook *hook_fd (struct t_weechat_plugin *plugin, int fd,
int flag_read, int flag_write,
int flag_exception,
t_hook_callback_fd *callback,
+ const void *callback_pointer,
void *callback_data);
extern void hook_fd_exec ();
extern struct t_hook *hook_process (struct t_weechat_plugin *plugin,
const char *command,
int timeout,
t_hook_callback_process *callback,
+ const void *callback_pointer,
void *callback_data);
extern struct t_hook *hook_process_hashtable (struct t_weechat_plugin *plugin,
const char *command,
struct t_hashtable *options,
int timeout,
t_hook_callback_process *callback,
+ const void *callback_pointer,
void *callback_data);
+extern void hook_process_exec ();
extern struct t_hook *hook_connect (struct t_weechat_plugin *plugin,
const char *proxy, const char *address,
int port, int ipv6, int retry,
@@ -493,6 +514,7 @@ extern struct t_hook *hook_connect (struct t_weechat_plugin *plugin,
const char *gnutls_priorities,
const char *local_hostname,
t_hook_callback_connect *callback,
+ const void *callback_pointer,
void *callback_data);
#ifdef HAVE_GNUTLS
extern int hook_connect_gnutls_verify_certificates (gnutls_session_t tls_session);
@@ -511,30 +533,35 @@ extern struct t_hook *hook_print (struct t_weechat_plugin *plugin,
const char *tags, const char *message,
int strip_colors,
t_hook_callback_print *callback,
+ const void *callback_pointer,
void *callback_data);
extern void hook_print_exec (struct t_gui_buffer *buffer,
struct t_gui_line *line);
extern struct t_hook *hook_signal (struct t_weechat_plugin *plugin,
const char *signal,
t_hook_callback_signal *callback,
+ const void *callback_pointer,
void *callback_data);
extern int hook_signal_send (const char *signal, const char *type_data,
void *signal_data);
extern struct t_hook *hook_hsignal (struct t_weechat_plugin *plugin,
const char *signal,
t_hook_callback_hsignal *callback,
+ const void *callback_pointer,
void *callback_data);
extern int hook_hsignal_send (const char *signal,
struct t_hashtable *hashtable);
extern struct t_hook *hook_config (struct t_weechat_plugin *plugin,
const char *option,
t_hook_callback_config *callback,
+ const void *callback_pointer,
void *callback_data);
extern void hook_config_exec (const char *option, const char *value);
extern struct t_hook *hook_completion (struct t_weechat_plugin *plugin,
const char *completion_item,
const char *description,
t_hook_callback_completion *callback,
+ const void *callback_pointer,
void *callback_data);
extern const char *hook_completion_get_string (struct t_gui_completion *completion,
const char *property);
@@ -548,6 +575,7 @@ extern void hook_completion_exec (struct t_weechat_plugin *plugin,
extern struct t_hook *hook_modifier (struct t_weechat_plugin *plugin,
const char *modifier,
t_hook_callback_modifier *callback,
+ const void *callback_pointer,
void *callback_data);
extern char *hook_modifier_exec (struct t_weechat_plugin *plugin,
const char *modifier,
@@ -558,6 +586,7 @@ extern struct t_hook *hook_info (struct t_weechat_plugin *plugin,
const char *description,
const char *args_description,
t_hook_callback_info *callback,
+ const void *callback_pointer,
void *callback_data);
extern const char *hook_info_get (struct t_weechat_plugin *plugin,
const char *info_name,
@@ -568,6 +597,7 @@ extern struct t_hook *hook_info_hashtable (struct t_weechat_plugin *plugin,
const char *args_description,
const char *output_description,
t_hook_callback_info_hashtable *callback,
+ const void *callback_pointer,
void *callback_data);
extern struct t_hashtable *hook_info_get_hashtable (struct t_weechat_plugin *plugin,
const char *info_name,
@@ -578,6 +608,7 @@ extern struct t_hook *hook_infolist (struct t_weechat_plugin *plugin,
const char *pointer_description,
const char *args_description,
t_hook_callback_infolist *callback,
+ const void *callback_pointer,
void *callback_data);
extern struct t_infolist *hook_infolist_get (struct t_weechat_plugin *plugin,
const char *infolist_name,
@@ -587,19 +618,22 @@ extern struct t_hook *hook_hdata (struct t_weechat_plugin *plugin,
const char *hdata_name,
const char *description,
t_hook_callback_hdata *callback,
+ const void *callback_pointer,
void *callback_data);
extern struct t_hdata *hook_hdata_get (struct t_weechat_plugin *plugin,
const char *hdata_name);
extern struct t_hook *hook_focus (struct t_weechat_plugin *plugin,
const char *area,
t_hook_callback_focus *callback,
+ const void *callback_pointer,
void *callback_data);
extern struct t_hashtable *hook_focus_get_data (struct t_hashtable *hashtable_focus1,
struct t_hashtable *hashtable_focus2);
extern void hook_set (struct t_hook *hook, const char *property,
const char *value);
extern void unhook (struct t_hook *hook);
-extern void unhook_all_plugin (struct t_weechat_plugin *plugin);
+extern void unhook_all_plugin (struct t_weechat_plugin *plugin,
+ const char *subplugin);
extern void unhook_all ();
extern int hook_add_to_infolist (struct t_infolist *infolist,
struct t_hook *hook,
diff --git a/src/core/wee-infolist.c b/src/core/wee-infolist.c
index 70f0c8ff5..fc2508479 100644
--- a/src/core/wee-infolist.c
+++ b/src/core/wee-infolist.c
@@ -1,7 +1,7 @@
/*
* wee-infolist.c - info lists management
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/core/wee-infolist.h b/src/core/wee-infolist.h
index 1a890f81b..1c753c815 100644
--- a/src/core/wee-infolist.h
+++ b/src/core/wee-infolist.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/core/wee-input.c b/src/core/wee-input.c
index aba0b04cb..7be24b810 100644
--- a/src/core/wee-input.c
+++ b/src/core/wee-input.c
@@ -1,7 +1,7 @@
/*
* wee-input.c - default input callback for buffers
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -48,7 +48,8 @@ input_exec_data (struct t_gui_buffer *buffer, const char *data)
{
if (buffer->input_callback)
{
- (void)(buffer->input_callback) (buffer->input_callback_data,
+ (void)(buffer->input_callback) (buffer->input_callback_pointer,
+ buffer->input_callback_data,
buffer,
data);
}
diff --git a/src/core/wee-input.h b/src/core/wee-input.h
index 1a1d6fce9..f4add7a39 100644
--- a/src/core/wee-input.h
+++ b/src/core/wee-input.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/core/wee-list.c b/src/core/wee-list.c
index 7ea9027a4..b14f78358 100644
--- a/src/core/wee-list.c
+++ b/src/core/wee-list.c
@@ -1,7 +1,7 @@
/*
* wee-list.c - sorted lists
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/core/wee-list.h b/src/core/wee-list.h
index 0376d784b..203347337 100644
--- a/src/core/wee-list.h
+++ b/src/core/wee-list.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/core/wee-log.c b/src/core/wee-log.c
index 89c844294..397ae911c 100644
--- a/src/core/wee-log.c
+++ b/src/core/wee-log.c
@@ -1,7 +1,7 @@
/*
* wee-log.c - WeeChat log file (weechat.log)
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org>
*
* This file is part of WeeChat, the extensible chat client.
@@ -112,10 +112,10 @@ log_init ()
{
if (!log_open (NULL, "w"))
{
- string_iconv_fprintf (stderr,
- _("Error: unable to create/append to log file (weechat.log)\n"
- "If another WeeChat process is using this file, try to run WeeChat\n"
- "with another home using \"--dir\" command line option.\n"));
+ string_fprintf (stderr,
+ _("Error: unable to create/append to log file (weechat.log)\n"
+ "If another WeeChat process is using this file, try to run WeeChat\n"
+ "with another home using the \"--dir\" command line option.\n"));
exit (1);
}
log_printf ("WeeChat %s (%s %s %s)",
@@ -159,18 +159,18 @@ log_printf (const char *message, ...)
date_tmp = localtime (&seconds);
if (date_tmp)
{
- string_iconv_fprintf (weechat_log_file,
- "[%04d-%02d-%02d %02d:%02d:%02d] %s\n",
- date_tmp->tm_year + 1900, date_tmp->tm_mon + 1,
- date_tmp->tm_mday, date_tmp->tm_hour,
- date_tmp->tm_min, date_tmp->tm_sec,
- vbuffer);
+ string_fprintf (weechat_log_file,
+ "[%04d-%02d-%02d %02d:%02d:%02d] %s\n",
+ date_tmp->tm_year + 1900, date_tmp->tm_mon + 1,
+ date_tmp->tm_mday, date_tmp->tm_hour,
+ date_tmp->tm_min, date_tmp->tm_sec,
+ vbuffer);
}
else
- string_iconv_fprintf (weechat_log_file, "%s\n", vbuffer);
+ string_fprintf (weechat_log_file, "%s\n", vbuffer);
}
else
- string_iconv_fprintf (weechat_log_file, "%s\n", vbuffer);
+ string_fprintf (weechat_log_file, "%s\n", vbuffer);
fflush (weechat_log_file);
@@ -276,8 +276,8 @@ log_crash_rename ()
getpid());
if (rename (old_name, new_name) == 0)
{
- string_iconv_fprintf (stderr, "*** Full crash dump was saved to %s file.\n",
- new_name);
+ string_fprintf (stderr, "*** Full crash dump was saved to %s file.\n",
+ new_name);
log_open (new_name, "a");
free (old_name);
free (new_name);
diff --git a/src/core/wee-log.h b/src/core/wee-log.h
index 9763afa3c..ee9b4f462 100644
--- a/src/core/wee-log.h
+++ b/src/core/wee-log.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/core/wee-network.c b/src/core/wee-network.c
index 7eb94ca49..a221ff134 100644
--- a/src/core/wee-network.c
+++ b/src/core/wee-network.c
@@ -1,7 +1,7 @@
/*
* wee-network.c - network functions
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2005-2010 Emmanuel Bouthenot <kolter@openics.org>
* Copyright (C) 2010 Gu1ll4um3r0m41n <aeroxteam@gmail.com>
* Copyright (C) 2012 Simon Arlott
@@ -42,7 +42,9 @@
#include <poll.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <arpa/nameser.h>
#include <netdb.h>
+#include <resolv.h>
#include <errno.h>
#include <gcrypt.h>
#include <sys/time.h>
@@ -311,6 +313,8 @@ network_resolve (const char *hostname, char *ip, int *version)
res = NULL;
+ res_init ();
+
if (getaddrinfo (hostname, NULL, NULL, &res) != 0)
return 0;
@@ -696,6 +700,7 @@ network_connect_to (const char *proxy, struct sockaddr *address,
hints.ai_flags = AI_NUMERICSERV;
snprintf (str_port, sizeof (str_port), "%d",
CONFIG_INTEGER(ptr_proxy->options[PROXY_OPTION_PORT]));
+ res_init ();
if (getaddrinfo (CONFIG_STRING(ptr_proxy->options[PROXY_OPTION_ADDRESS]),
str_port, &hints, &proxy_addrinfo) != 0)
{
@@ -806,6 +811,7 @@ network_connect_child (struct t_hook *hook_connect)
#ifdef AI_ADDRCONFIG
hints.ai_flags = AI_ADDRCONFIG;
#endif /* AI_ADDRCONFIG */
+ res_init ();
if (ptr_proxy)
{
hints.ai_family = (CONFIG_BOOLEAN(ptr_proxy->options[PROXY_OPTION_IPV6])) ?
@@ -1233,19 +1239,22 @@ end:
*/
int
-network_connect_child_timer_cb (void *arg_hook_connect, int remaining_calls)
+network_connect_child_timer_cb (const void *pointer, void *data,
+ int remaining_calls)
{
struct t_hook *hook_connect;
/* make C compiler happy */
+ (void) data;
(void) remaining_calls;
- hook_connect = (struct t_hook *)arg_hook_connect;
+ hook_connect = (struct t_hook *)pointer;
HOOK_CONNECT(hook_connect, hook_child_timer) = NULL;
(void) (HOOK_CONNECT(hook_connect, callback))
- (hook_connect->callback_data,
+ (hook_connect->callback_pointer,
+ hook_connect->callback_data,
WEECHAT_HOOK_CONNECT_TIMEOUT,
0, -1, NULL, NULL);
unhook (hook_connect);
@@ -1262,15 +1271,17 @@ network_connect_child_timer_cb (void *arg_hook_connect, int remaining_calls)
#ifdef HAVE_GNUTLS
int
-network_connect_gnutls_handshake_fd_cb (void *arg_hook_connect, int fd)
+network_connect_gnutls_handshake_fd_cb (const void *pointer, void *data,
+ int fd)
{
struct t_hook *hook_connect;
int rc, direction, flags;
/* make C compiler happy */
+ (void) data;
(void) fd;
- hook_connect = (struct t_hook *)arg_hook_connect;
+ hook_connect = (struct t_hook *)pointer;
rc = gnutls_handshake (*HOOK_CONNECT(hook_connect, gnutls_sess));
@@ -1290,7 +1301,8 @@ network_connect_gnutls_handshake_fd_cb (void *arg_hook_connect, int fd)
else if (rc != GNUTLS_E_SUCCESS)
{
(void) (HOOK_CONNECT(hook_connect, callback))
- (hook_connect->callback_data,
+ (hook_connect->callback_pointer,
+ hook_connect->callback_data,
WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR, rc,
HOOK_CONNECT(hook_connect, sock),
gnutls_strerror (rc),
@@ -1310,7 +1322,8 @@ network_connect_gnutls_handshake_fd_cb (void *arg_hook_connect, int fd)
if (hook_connect_gnutls_verify_certificates (*HOOK_CONNECT(hook_connect, gnutls_sess)) != 0)
{
(void) (HOOK_CONNECT(hook_connect, callback))
- (hook_connect->callback_data,
+ (hook_connect->callback_pointer,
+ hook_connect->callback_data,
WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR, rc,
HOOK_CONNECT(hook_connect, sock),
"Error in the certificate.",
@@ -1321,10 +1334,11 @@ network_connect_gnutls_handshake_fd_cb (void *arg_hook_connect, int fd)
#endif /* LIBGNUTLS_VERSION_NUMBER < 0x02090a */
unhook (HOOK_CONNECT(hook_connect, handshake_hook_fd));
(void) (HOOK_CONNECT(hook_connect, callback))
- (hook_connect->callback_data,
- WEECHAT_HOOK_CONNECT_OK, 0,
- HOOK_CONNECT(hook_connect, sock),
- NULL, HOOK_CONNECT(hook_connect, handshake_ip_address));
+ (hook_connect->callback_pointer,
+ hook_connect->callback_data,
+ WEECHAT_HOOK_CONNECT_OK, 0,
+ HOOK_CONNECT(hook_connect, sock),
+ NULL, HOOK_CONNECT(hook_connect, handshake_ip_address));
unhook (hook_connect);
}
@@ -1338,25 +1352,28 @@ network_connect_gnutls_handshake_fd_cb (void *arg_hook_connect, int fd)
#ifdef HAVE_GNUTLS
int
-network_connect_gnutls_handshake_timer_cb (void *arg_hook_connect,
+network_connect_gnutls_handshake_timer_cb (const void *pointer,
+ void *data,
int remaining_calls)
{
struct t_hook *hook_connect;
/* make C compiler happy */
+ (void) data;
(void) remaining_calls;
- hook_connect = (struct t_hook *)arg_hook_connect;
+ hook_connect = (struct t_hook *)pointer;
HOOK_CONNECT(hook_connect, handshake_hook_timer) = NULL;
(void) (HOOK_CONNECT(hook_connect, callback))
- (hook_connect->callback_data,
- WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR,
- GNUTLS_E_EXPIRED,
- HOOK_CONNECT(hook_connect, sock),
- gnutls_strerror (GNUTLS_E_EXPIRED),
- HOOK_CONNECT(hook_connect, handshake_ip_address));
+ (hook_connect->callback_pointer,
+ hook_connect->callback_data,
+ WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR,
+ GNUTLS_E_EXPIRED,
+ HOOK_CONNECT(hook_connect, sock),
+ gnutls_strerror (GNUTLS_E_EXPIRED),
+ HOOK_CONNECT(hook_connect, handshake_ip_address));
unhook (hook_connect);
return WEECHAT_RC_OK;
@@ -1368,7 +1385,7 @@ network_connect_gnutls_handshake_timer_cb (void *arg_hook_connect,
*/
int
-network_connect_child_read_cb (void *arg_hook_connect, int fd)
+network_connect_child_read_cb (const void *pointer, void *data, int fd)
{
struct t_hook *hook_connect;
char buffer[1], buf_size[6], *cb_error, *cb_ip_address, *error;
@@ -1389,9 +1406,10 @@ network_connect_child_read_cb (void *arg_hook_connect, int fd)
#endif /* HOOK_CONNECT_MAX_SOCKETS */
/* make C compiler happy */
+ (void) data;
(void) fd;
- hook_connect = (struct t_hook *)arg_hook_connect;
+ hook_connect = (struct t_hook *)pointer;
cb_error = NULL;
cb_ip_address = NULL;
@@ -1507,19 +1525,20 @@ network_connect_child_read_cb (void *arg_hook_connect, int fd)
HOOK_CONNECT(hook_connect, sock),
(!direction ? 1 : 0), (direction ? 1 : 0), 0,
&network_connect_gnutls_handshake_fd_cb,
- hook_connect);
+ hook_connect, NULL);
HOOK_CONNECT(hook_connect, handshake_hook_timer) =
hook_timer (hook_connect->plugin,
CONFIG_INTEGER(config_network_gnutls_handshake_timeout) * 1000,
0, 1,
&network_connect_gnutls_handshake_timer_cb,
- hook_connect);
+ hook_connect, NULL);
return WEECHAT_RC_OK;
}
else if (rc != GNUTLS_E_SUCCESS)
{
(void) (HOOK_CONNECT(hook_connect, callback))
- (hook_connect->callback_data,
+ (hook_connect->callback_pointer,
+ hook_connect->callback_data,
WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR,
rc, sock,
gnutls_strerror (rc),
@@ -1540,7 +1559,8 @@ network_connect_child_read_cb (void *arg_hook_connect, int fd)
if (hook_connect_gnutls_verify_certificates (*HOOK_CONNECT(hook_connect, gnutls_sess)) != 0)
{
(void) (HOOK_CONNECT(hook_connect, callback))
- (hook_connect->callback_data,
+ (hook_connect->callback_pointer,
+ hook_connect->callback_data,
WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR,
rc, sock,
"Error in the certificate.",
@@ -1583,15 +1603,19 @@ network_connect_child_read_cb (void *arg_hook_connect, int fd)
}
}
(void) (HOOK_CONNECT(hook_connect, callback))
- (hook_connect->callback_data, buffer[0] - '0', 0,
+ (hook_connect->callback_pointer,
+ hook_connect->callback_data,
+ buffer[0] - '0', 0,
sock, cb_error, cb_ip_address);
unhook (hook_connect);
}
else
{
(void) (HOOK_CONNECT(hook_connect, callback))
- (hook_connect->callback_data, WEECHAT_HOOK_CONNECT_MEMORY_ERROR,
- 0, sock, cb_error, cb_ip_address);
+ (hook_connect->callback_pointer,
+ hook_connect->callback_data,
+ WEECHAT_HOOK_CONNECT_MEMORY_ERROR,
+ 0, sock, "child_read_cb", NULL);
unhook (hook_connect);
}
@@ -1628,19 +1652,35 @@ network_connect_with_fork (struct t_hook *hook_connect)
if (gnutls_init (HOOK_CONNECT(hook_connect, gnutls_sess), GNUTLS_CLIENT) != GNUTLS_E_SUCCESS)
{
(void) (HOOK_CONNECT(hook_connect, callback))
- (hook_connect->callback_data,
+ (hook_connect->callback_pointer,
+ hook_connect->callback_data,
WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR,
0, -1, NULL, NULL);
unhook (hook_connect);
return;
}
+ rc = gnutls_server_name_set (*HOOK_CONNECT(hook_connect, gnutls_sess),
+ GNUTLS_NAME_DNS,
+ HOOK_CONNECT(hook_connect, address),
+ strlen (HOOK_CONNECT(hook_connect, address)));
+ if (rc != GNUTLS_E_SUCCESS)
+ {
+ (void) (HOOK_CONNECT(hook_connect, callback))
+ (hook_connect->callback_pointer,
+ hook_connect->callback_data,
+ WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR,
+ 0, -1, _("set server name indication (SNI) failed"), NULL);
+ unhook (hook_connect);
+ return;
+ }
rc = gnutls_priority_set_direct (*HOOK_CONNECT(hook_connect, gnutls_sess),
HOOK_CONNECT(hook_connect, gnutls_priorities),
&pos_error);
if (rc != GNUTLS_E_SUCCESS)
{
(void) (HOOK_CONNECT(hook_connect, callback))
- (hook_connect->callback_data,
+ (hook_connect->callback_pointer,
+ hook_connect->callback_data,
WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR,
0, -1, _("invalid priorities"), NULL);
unhook (hook_connect);
@@ -1658,9 +1698,10 @@ network_connect_with_fork (struct t_hook *hook_connect)
if (pipe (child_pipe) < 0)
{
(void) (HOOK_CONNECT(hook_connect, callback))
- (hook_connect->callback_data,
+ (hook_connect->callback_pointer,
+ hook_connect->callback_data,
WEECHAT_HOOK_CONNECT_MEMORY_ERROR,
- 0, -1, NULL, NULL);
+ 0, -1, "pipe", NULL);
unhook (hook_connect);
return;
}
@@ -1672,9 +1713,10 @@ network_connect_with_fork (struct t_hook *hook_connect)
if (socketpair (AF_LOCAL, SOCK_DGRAM, 0, child_socket) < 0)
{
(void) (HOOK_CONNECT(hook_connect, callback))
- (hook_connect->callback_data,
+ (hook_connect->callback_pointer,
+ hook_connect->callback_data,
WEECHAT_HOOK_CONNECT_MEMORY_ERROR,
- 0, -1, NULL, NULL);
+ 0, -1, "socketpair", NULL);
unhook (hook_connect);
return;
}
@@ -1693,9 +1735,10 @@ network_connect_with_fork (struct t_hook *hook_connect)
/* fork failed */
case -1:
(void) (HOOK_CONNECT(hook_connect, callback))
- (hook_connect->callback_data,
+ (hook_connect->callback_pointer,
+ hook_connect->callback_data,
WEECHAT_HOOK_CONNECT_MEMORY_ERROR,
- 0, -1, NULL, NULL);
+ 0, -1, "fork", NULL);
unhook (hook_connect);
return;
/* child process */
@@ -1721,10 +1764,11 @@ network_connect_with_fork (struct t_hook *hook_connect)
CONFIG_INTEGER(config_network_connection_timeout) * 1000,
0, 1,
&network_connect_child_timer_cb,
- hook_connect);
+ hook_connect,
+ NULL);
HOOK_CONNECT(hook_connect, hook_fd) = hook_fd (hook_connect->plugin,
HOOK_CONNECT(hook_connect, child_read),
1, 0, 0,
&network_connect_child_read_cb,
- hook_connect);
+ hook_connect, NULL);
}
diff --git a/src/core/wee-network.h b/src/core/wee-network.h
index 29e712d79..bcf5d6b69 100644
--- a/src/core/wee-network.h
+++ b/src/core/wee-network.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/core/wee-proxy.c b/src/core/wee-proxy.c
index de9e36f8a..df24dffb3 100644
--- a/src/core/wee-proxy.c
+++ b/src/core/wee-proxy.c
@@ -1,7 +1,7 @@
/*
* wee-proxy.c - proxy functions
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -308,7 +308,7 @@ proxy_create_option (const char *proxy_name, int index_option,
option_name, "integer",
N_("proxy type (http (default), socks4, socks5)"),
"http|socks4|socks5", 0, 0, value, NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
break;
case PROXY_OPTION_IPV6:
ptr_option = config_file_new_option (
@@ -316,7 +316,7 @@ proxy_create_option (const char *proxy_name, int index_option,
option_name, "boolean",
N_("connect to proxy using ipv6"),
NULL, 0, 0, value, NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
break;
case PROXY_OPTION_ADDRESS:
ptr_option = config_file_new_option (
@@ -324,7 +324,7 @@ proxy_create_option (const char *proxy_name, int index_option,
option_name, "string",
N_("proxy server address (IP or hostname)"),
NULL, 0, 0, value, NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
break;
case PROXY_OPTION_PORT:
ptr_option = config_file_new_option (
@@ -332,7 +332,7 @@ proxy_create_option (const char *proxy_name, int index_option,
option_name, "integer",
N_("port for connecting to proxy server"),
NULL, 0, 65535, value, NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
break;
case PROXY_OPTION_USERNAME:
ptr_option = config_file_new_option (
@@ -341,7 +341,7 @@ proxy_create_option (const char *proxy_name, int index_option,
N_("username for proxy server "
"(note: content is evaluated, see /help eval)"),
NULL, 0, 0, value, NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
break;
case PROXY_OPTION_PASSWORD:
ptr_option = config_file_new_option (
@@ -350,7 +350,7 @@ proxy_create_option (const char *proxy_name, int index_option,
N_("password for proxy server "
"(note: content is evaluated, see /help eval)"),
NULL, 0, 0, value, NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
break;
case PROXY_NUM_OPTIONS:
break;
@@ -621,11 +621,13 @@ proxy_free_all ()
*/
struct t_hdata *
-proxy_hdata_proxy_cb (void *data, const char *hdata_name)
+proxy_hdata_proxy_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_proxy", "next_proxy",
diff --git a/src/core/wee-proxy.h b/src/core/wee-proxy.h
index d1ffb05bc..92574a400 100644
--- a/src/core/wee-proxy.h
+++ b/src/core/wee-proxy.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -82,7 +82,9 @@ extern struct t_proxy *proxy_new (const char *name,
extern void proxy_use_temp_proxies ();
extern void proxy_free (struct t_proxy *proxy);
extern void proxy_free_all ();
-extern struct t_hdata *proxy_hdata_proxy_cb (void *data, const char *hdata_name);
+extern struct t_hdata *proxy_hdata_proxy_cb (const void *pointer,
+ void *data,
+ const char *hdata_name);
extern int proxy_add_to_infolist (struct t_infolist *infolist,
struct t_proxy *proxy);
extern void proxy_print_log ();
diff --git a/src/core/wee-secure.c b/src/core/wee-secure.c
index cc8da3346..d64e201ea 100644
--- a/src/core/wee-secure.c
+++ b/src/core/wee-secure.c
@@ -1,7 +1,7 @@
/*
* wee-secure.c - secured data configuration options (file sec.conf)
*
- * Copyright (C) 2013-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2013-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -657,13 +657,14 @@ secure_get_passphrase_from_file (const char *filename)
*/
int
-secure_check_crypt_passphrase_file (void *data,
+secure_check_crypt_passphrase_file (const void *pointer, void *data,
struct t_config_option *option,
const char *value)
{
char *passphrase;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -696,9 +697,11 @@ secure_check_crypt_passphrase_file (void *data,
*/
int
-secure_reload_cb (void *data, struct t_config_file *config_file)
+secure_reload_cb (const void *pointer, void *data,
+ struct t_config_file *config_file)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (secure_hashtable_data_encrypted->items_count > 0)
@@ -724,7 +727,7 @@ secure_reload_cb (void *data, struct t_config_file *config_file)
*/
int
-secure_data_read_cb (void *data,
+secure_data_read_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name, const char *value)
@@ -733,6 +736,7 @@ secure_data_read_cb (void *data,
int length_buffer, length_decrypted, rc;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) config_file;
(void) section;
@@ -924,10 +928,12 @@ secure_data_write_map_encrypted_cb (void *data,
*/
int
-secure_data_write_cb (void *data, struct t_config_file *config_file,
+secure_data_write_cb (const void *pointer, void *data,
+ struct t_config_file *config_file,
const char *section_name)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
/* write name of section */
@@ -983,15 +989,18 @@ secure_init_options ()
struct t_config_section *ptr_section;
secure_config_file = config_file_new (NULL, SECURE_CONFIG_NAME,
- &secure_reload_cb, NULL);
+ &secure_reload_cb, NULL, NULL);
if (!secure_config_file)
return 0;
/* crypt */
ptr_section = config_file_new_section (secure_config_file, "crypt",
0, 0,
- NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
config_file_free (secure_config_file);
@@ -1004,13 +1013,13 @@ secure_init_options ()
N_("cipher used to crypt data (the number after algorithm is the size "
"of the key in bits)"),
"aes128|aes192|aes256", 0, 0, "aes256", NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
secure_config_crypt_hash_algo = config_file_new_option (
secure_config_file, ptr_section,
"hash_algo", "integer",
N_("hash algorithm used to check the decrypted data"),
"sha224|sha256|sha384|sha512", 0, 0, "sha256", NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
secure_config_crypt_passphrase_file = config_file_new_option (
secure_config_file, ptr_section,
"passphrase_file", "string",
@@ -1023,7 +1032,9 @@ secure_init_options ()
"outside WeeChat home (for example in your home); example: "
"\"~/.weechat-passphrase\""),
NULL, 0, 0, "", NULL, 0,
- &secure_check_crypt_passphrase_file, NULL, NULL, NULL, NULL, NULL);
+ &secure_check_crypt_passphrase_file, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
secure_config_crypt_salt = config_file_new_option (
secure_config_file, ptr_section,
"salt", "boolean",
@@ -1032,15 +1043,18 @@ secure_init_options ()
"file sec.conf will be different on each write of the file; if you "
"put the file sec.conf in a version control system, then you "
"can turn off this option to have always same content in file"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
/* data */
- ptr_section = config_file_new_section (secure_config_file, "data",
- 0, 0,
- &secure_data_read_cb, NULL,
- &secure_data_write_cb, NULL,
- &secure_data_write_cb, NULL,
- NULL, NULL, NULL, NULL);
+ ptr_section = config_file_new_section (
+ secure_config_file, "data",
+ 0, 0,
+ &secure_data_read_cb, NULL, NULL,
+ &secure_data_write_cb, NULL, NULL,
+ &secure_data_write_cb, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
config_file_free (secure_config_file);
@@ -1079,16 +1093,14 @@ secure_init ()
secure_hashtable_data = hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
if (!secure_hashtable_data)
return 0;
secure_hashtable_data_encrypted = hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
if (!secure_hashtable_data_encrypted)
{
hashtable_free (secure_hashtable_data);
@@ -1264,10 +1276,12 @@ secure_buffer_display ()
*/
int
-secure_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
+secure_buffer_input_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
const char *input_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (string_strcasecmp (input_data, "q") == 0)
@@ -1283,9 +1297,11 @@ secure_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
*/
int
-secure_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
+secure_buffer_close_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
@@ -1322,8 +1338,8 @@ secure_buffer_open ()
if (!secure_buffer)
{
secure_buffer = gui_buffer_new (NULL, SECURE_BUFFER_NAME,
- &secure_buffer_input_cb, NULL,
- &secure_buffer_close_cb, NULL);
+ &secure_buffer_input_cb, NULL, NULL,
+ &secure_buffer_close_cb, NULL, NULL);
if (secure_buffer)
{
if (!secure_buffer->short_name)
diff --git a/src/core/wee-secure.h b/src/core/wee-secure.h
index 563b60b49..8ed18461d 100644
--- a/src/core/wee-secure.h
+++ b/src/core/wee-secure.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2013-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/core/wee-string.c b/src/core/wee-string.c
index 2f1adb7d9..1481e6361 100644
--- a/src/core/wee-string.c
+++ b/src/core/wee-string.c
@@ -1,7 +1,7 @@
/*
* wee-string.c - string functions
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -787,9 +787,12 @@ string_convert_escaped_chars (const char *string)
}
break;
default:
- output[pos_output++] = '\\';
- output[pos_output++] = ptr_string[0];
- ptr_string++;
+ if (ptr_string[0])
+ {
+ output[pos_output++] = '\\';
+ output[pos_output++] = ptr_string[0];
+ ptr_string++;
+ }
break;
}
}
@@ -1584,17 +1587,30 @@ string_replace_regex (const char *string, void *regex, const char *replace,
* This function must not be called directly (call string_split or
* string_split_shared instead).
*
+ * According to keep_eol value:
+ * 0: standard split
+ * 1: each argument contains the argument and all the following arguments
+ * 2: same as 1, and separator is kept at the end of string.
+ *
* Examples:
- * string_split ("abc de fghi", " ", 0, 0, NULL)
- * ==> array[0] = "abc"
- * array[1] = "de"
- * array[2] = "fghi"
- * array[3] = NULL
- * string_split ("abc de fghi", " ", 1, 0, NULL)
- * ==> array[0] = "abc de fghi"
- * array[1] = "de fghi"
- * array[2] = "fghi"
- * array[3] = NULL
+ * string_split ("abc de fghi ", " ", 0, 0, &argc)
+ * ==> array[0] == "abc"
+ * array[1] == "de"
+ * array[2] == "fghi"
+ * array[3] == NULL
+ * argc == 3
+ * string_split ("abc de fghi ", " ", 1, 0, &argc)
+ * ==> array[0] == "abc de fghi"
+ * array[1] == "de fghi"
+ * array[2] == "fghi"
+ * array[3] == NULL
+ * argc == 3
+ * string_split ("abc de fghi ", " ", 2, 0, &argc)
+ * ==> array[0] == "abc de fghi "
+ * array[1] == "de fghi "
+ * array[2] == "fghi "
+ * array[3] == NULL
+ * argc == 3
*/
char **
@@ -1625,7 +1641,8 @@ string_split_internal (const char *string, const char *separators, int keep_eol,
{
ptr++;
}
- i++;
+ if (ptr[0])
+ i++;
}
n_items = i;
@@ -2101,7 +2118,7 @@ string_split_command (const char *command, char separator)
while(*ptr != '\0')
{
type = 0;
- if (*ptr == ';')
+ if (*ptr == separator)
{
if (ptr == command)
type = 1;
@@ -2342,7 +2359,7 @@ string_iconv_from_internal (const char *charset, const char *string)
/*
* optimized for UTF-8: if charset is NULL => we use term charset => if
- * this charset is already UTF-8, then no iconv needed
+ * this charset is already UTF-8, then no iconv is needed
*/
if (local_utf8 && (!charset || !charset[0]))
return input;
@@ -2368,7 +2385,7 @@ string_iconv_from_internal (const char *charset, const char *string)
*/
int
-string_iconv_fprintf (FILE *file, const char *data, ...)
+string_fprintf (FILE *file, const char *data, ...)
{
char *buf2;
int rc, num_written;
@@ -2669,6 +2686,111 @@ string_decode_base64 (const char *from, char *to)
}
/*
+ * Dumps a data buffer as hexadecimal + ascii.
+ *
+ * Note: result must be freed after use.
+ */
+
+char *
+string_hex_dump (const char *data, int data_size, int bytes_per_line,
+ const char *prefix, const char *suffix)
+{
+ char *buf, *str_hexa, *str_ascii, str_format_line[64], *str_line;
+ int length_hexa, length_ascii, length_prefix, length_suffix, length_line;
+ int hexa_pos, ascii_pos, i;
+
+ if (!data || (data_size < 1) || (bytes_per_line < 1))
+ return NULL;
+
+ str_hexa = NULL;
+ str_ascii = NULL;
+ str_line = NULL;
+ buf = NULL;
+
+ length_hexa = bytes_per_line * 3;
+ str_hexa = malloc (length_hexa + 1);
+ if (!str_hexa)
+ goto end;
+
+ length_ascii = bytes_per_line * 2;
+ str_ascii = malloc (length_ascii + 1);
+ if (!str_ascii)
+ goto end;
+
+ length_prefix = (prefix) ? strlen (prefix) : 0;
+ length_suffix = (suffix) ? strlen (suffix) : 0;
+
+ length_line = length_prefix + (bytes_per_line * 3) + 2 + length_ascii +
+ length_suffix;
+ str_line = malloc (length_line + 1);
+ if (!str_line)
+ goto end;
+
+ buf = malloc ((((data_size / bytes_per_line) + 1) * (length_line + 1)) + 1);
+ if (!buf)
+ goto end;
+ buf[0] = '\0';
+
+ snprintf (str_format_line, sizeof (str_format_line),
+ "%%s%%-%ds %%-%ds%%s",
+ length_hexa,
+ length_ascii);
+
+ hexa_pos = 0;
+ ascii_pos = 0;
+ for (i = 0; i < data_size; i++)
+ {
+ snprintf (str_hexa + hexa_pos, 4,
+ "%02X ", (unsigned char)(data[i]));
+ hexa_pos += 3;
+ snprintf (str_ascii + ascii_pos, 3, "%c ",
+ ((((unsigned char)data[i]) < 32)
+ || (((unsigned char)data[i]) > 127)) ?
+ '.' : (unsigned char)(data[i]));
+ ascii_pos += 2;
+ if (ascii_pos == bytes_per_line * 2)
+ {
+ if (buf[0])
+ strcat (buf, "\n");
+ str_ascii[ascii_pos - 1] = '\0';
+ snprintf (str_line, length_line + 1,
+ str_format_line,
+ (prefix) ? prefix : "",
+ str_hexa,
+ str_ascii,
+ (suffix) ? suffix : "");
+ strcat (buf, str_line);
+ hexa_pos = 0;
+ ascii_pos = 0;
+ }
+ }
+ if (ascii_pos > 0)
+ {
+ if (buf[0])
+ strcat (buf, "\n");
+ str_ascii[ascii_pos - 1] = '\0';
+ str_ascii[ascii_pos] = '\0';
+ snprintf (str_line, length_line + 1,
+ str_format_line,
+ (prefix) ? prefix : "",
+ str_hexa,
+ str_ascii,
+ (suffix) ? suffix : "");
+ strcat (buf, str_line);
+ }
+
+end:
+ if (str_hexa)
+ free (str_hexa);
+ if (str_ascii)
+ free (str_ascii);
+ if (str_line)
+ free (str_line);
+
+ return buf;
+}
+
+/*
* Checks if a string is a command.
*
* Returns:
@@ -2717,6 +2839,14 @@ string_input_for_buffer (const char *string)
if (!string)
return NULL;
+ /* a single "/" is not a command */
+ if (strcmp (string, "/") == 0)
+ return string;
+
+ /* "/ " is not a command */
+ if (strncmp (string, "/ ", 2) == 0)
+ return string;
+
/* special case for C comments pasted in input line */
if (strncmp (string, "/*", 2) == 0)
return string;
@@ -2731,7 +2861,7 @@ string_input_for_buffer (const char *string)
pos_space = strchr (string + 1, ' ');
/*
- * if there's no other '/' or if '/' is after first space,
+ * if there are no other '/' or if '/' is after first space,
* then it is a command, and return NULL
*/
if (!pos_slash || (pos_space && pos_slash > pos_space))
@@ -2746,9 +2876,13 @@ string_input_for_buffer (const char *string)
next_char = utf8_next_char (string);
- /* there's no next char, then it's a command */
+ /* there's no next char, then it's a not command */
if (!next_char || !next_char[0])
- return NULL;
+ return string;
+
+ /* next char is a space, then it's not a command */
+ if (next_char[0] == ' ')
+ return string;
/* check if first char is doubled: if yes, then it's not a command */
if (utf8_charcmp (string, next_char) == 0)
diff --git a/src/core/wee-string.h b/src/core/wee-string.h
index 45df857b5..5db751df2 100644
--- a/src/core/wee-string.h
+++ b/src/core/wee-string.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -85,12 +85,15 @@ extern char *string_iconv (int from_utf8, const char *from_code,
extern char *string_iconv_to_internal (const char *charset, const char *string);
extern char *string_iconv_from_internal (const char *charset,
const char *string);
-extern int string_iconv_fprintf (FILE *file, const char *data, ...);
+extern int string_fprintf (FILE *file, const char *data, ...);
extern char *string_format_size (unsigned long long size);
extern void string_encode_base16 (const char *from, int length, char *to);
extern int string_decode_base16 (const char *from, char *to);
extern void string_encode_base64 (const char *from, int length, char *to);
extern int string_decode_base64 (const char *from, char *to);
+extern char *string_hex_dump (const char *data, int data_size,
+ int bytes_per_line,
+ const char *prefix, const char *suffix);
extern int string_is_command_char (const char *string);
extern const char *string_input_for_buffer (const char *string);
extern char *string_replace_with_callback (const char *string,
diff --git a/src/core/wee-upgrade-file.c b/src/core/wee-upgrade-file.c
index 60bf14bae..07b2d88d4 100644
--- a/src/core/wee-upgrade-file.c
+++ b/src/core/wee-upgrade-file.c
@@ -1,7 +1,7 @@
/*
* wee-upgrade-file.c - save/restore data for upgrading WeeChat
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -184,7 +184,14 @@ upgrade_file_write_buffer (struct t_upgrade_file *upgrade_file, void *pointer,
*/
struct t_upgrade_file *
-upgrade_file_new (const char *filename, int write)
+upgrade_file_new (const char *filename,
+ int (*callback_read)(const void *pointer,
+ void *data,
+ struct t_upgrade_file *upgrade_file,
+ int object_id,
+ struct t_infolist *infolist),
+ const void *callback_read_pointer,
+ void *callback_read_data)
{
int length;
struct t_upgrade_file *new_upgrade_file;
@@ -205,12 +212,15 @@ upgrade_file_new (const char *filename, int write)
}
snprintf (new_upgrade_file->filename, length, "%s/%s.upgrade",
weechat_home, filename);
+ new_upgrade_file->callback_read = callback_read;
+ new_upgrade_file->callback_read_pointer = callback_read_pointer;
+ new_upgrade_file->callback_read_data = callback_read_data;
/* open file in read or write mode */
- if (write)
- new_upgrade_file->file = fopen (new_upgrade_file->filename, "wb");
- else
+ if (callback_read)
new_upgrade_file->file = fopen (new_upgrade_file->filename, "rb");
+ else
+ new_upgrade_file->file = fopen (new_upgrade_file->filename, "wb");
if (!new_upgrade_file->file)
{
@@ -220,7 +230,7 @@ upgrade_file_new (const char *filename, int write)
}
/* change permissions if write mode */
- if (write)
+ if (!callback_read)
{
chmod (new_upgrade_file->filename, 0600);
@@ -241,6 +251,7 @@ upgrade_file_new (const char *filename, int write)
upgrade_files = new_upgrade_file;
last_upgrade_file = new_upgrade_file;
}
+
return new_upgrade_file;
}
@@ -704,11 +715,15 @@ upgrade_file_read_object (struct t_upgrade_file *upgrade_file)
if (upgrade_file->callback_read)
{
- if ((int)(upgrade_file->callback_read) (upgrade_file->callback_read_data,
- upgrade_file,
- object_id,
- infolist) == WEECHAT_RC_ERROR)
+ if ((int)(upgrade_file->callback_read) (
+ upgrade_file->callback_read_pointer,
+ upgrade_file->callback_read_data,
+ upgrade_file,
+ object_id,
+ infolist) == WEECHAT_RC_ERROR)
+ {
rc = 0;
+ }
}
end:
@@ -733,21 +748,13 @@ end:
*/
int
-upgrade_file_read (struct t_upgrade_file *upgrade_file,
- int (*callback_read)(void *data,
- struct t_upgrade_file *upgrade_file,
- int object_id,
- struct t_infolist *infolist),
- void *callback_read_data)
+upgrade_file_read (struct t_upgrade_file *upgrade_file)
{
char *signature;
- if (!upgrade_file)
+ if (!upgrade_file || !upgrade_file->callback_read)
return 0;
- upgrade_file->callback_read = callback_read;
- upgrade_file->callback_read_data = callback_read_data;
-
signature = NULL;
if (!upgrade_file_read_string (upgrade_file, &signature))
{
@@ -776,12 +783,31 @@ upgrade_file_read (struct t_upgrade_file *upgrade_file,
}
/*
- * Closes an upgrade file.
+ * Closes and frees an upgrade file.
*/
void
upgrade_file_close (struct t_upgrade_file *upgrade_file)
{
- if (upgrade_file && upgrade_file->file)
+ if (!upgrade_file)
+ return;
+
+ if (upgrade_file->filename)
+ free (upgrade_file->filename);
+ if (upgrade_file->file)
fclose (upgrade_file->file);
+ if (upgrade_file->callback_read_data)
+ free (upgrade_file->callback_read_data);
+
+ /* remove upgrade file list */
+ if (upgrade_file->prev_upgrade)
+ (upgrade_file->prev_upgrade)->next_upgrade = upgrade_file->next_upgrade;
+ if (upgrade_file->next_upgrade)
+ (upgrade_file->next_upgrade)->prev_upgrade = upgrade_file->prev_upgrade;
+ if (upgrade_files == upgrade_file)
+ upgrade_files = upgrade_file->next_upgrade;
+ if (last_upgrade_file == upgrade_file)
+ last_upgrade_file = upgrade_file->prev_upgrade;
+
+ free (upgrade_file);
}
diff --git a/src/core/wee-upgrade-file.h b/src/core/wee-upgrade-file.h
index b991868bf..eb0cd7d14 100644
--- a/src/core/wee-upgrade-file.h
+++ b/src/core/wee-upgrade-file.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -41,26 +41,29 @@ struct t_upgrade_file
long last_read_pos; /* last read position */
int last_read_length; /* last read length */
int (*callback_read) /* callback called when reading */
- (void *data, /* file */
+ (const void *pointer, /* file */
+ void *data,
struct t_upgrade_file *upgrade_file,
int object_id,
struct t_infolist *infolist);
+ const void *callback_read_pointer; /* pointer sent to callback */
void *callback_read_data; /* data sent to callback */
struct t_upgrade_file *prev_upgrade; /* link to previous upgrade file */
struct t_upgrade_file *next_upgrade; /* link to next upgrade file */
};
extern struct t_upgrade_file *upgrade_file_new (const char *filename,
- int write);
+ int (*callback_read)(const void *pointer,
+ void *data,
+ struct t_upgrade_file *upgrade_file,
+ int object_id,
+ struct t_infolist *infolist),
+ const void *callback_read_pointer,
+ void *callback_read_data);
extern int upgrade_file_write_object (struct t_upgrade_file *upgrade_file,
int object_id,
struct t_infolist *infolist);
-extern int upgrade_file_read (struct t_upgrade_file *upgrade_file,
- int (*callback_read)(void *data,
- struct t_upgrade_file *upgrade_file,
- int object_id,
- struct t_infolist *infolist),
- void *callback_read_data);
+extern int upgrade_file_read (struct t_upgrade_file *upgrade_file);
extern void upgrade_file_close (struct t_upgrade_file *upgrade_file);
#endif /* WEECHAT_UPGRADE_FILE_H */
diff --git a/src/core/wee-upgrade.c b/src/core/wee-upgrade.c
index 806809f40..b0bff36c8 100644
--- a/src/core/wee-upgrade.c
+++ b/src/core/wee-upgrade.c
@@ -1,7 +1,7 @@
/*
* wee-upgrade.c - save/restore session data of WeeChat core
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -379,7 +379,8 @@ upgrade_weechat_save ()
int rc;
struct t_upgrade_file *upgrade_file;
- upgrade_file = upgrade_file_new (WEECHAT_UPGRADE_FILENAME, 1);
+ upgrade_file = upgrade_file_new (WEECHAT_UPGRADE_FILENAME,
+ NULL, NULL, NULL);
if (!upgrade_file)
return 0;
@@ -425,8 +426,8 @@ upgrade_weechat_read_buffer (struct t_infolist *infolist)
upgrade_current_buffer = gui_buffer_new (NULL,
infolist_string (infolist,
"name"),
- NULL, NULL,
- NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
}
if (!upgrade_current_buffer)
return;
@@ -722,7 +723,7 @@ upgrade_weechat_read_hotlist (struct t_infolist *infolist)
if (!hotlist_reset)
{
- gui_hotlist_clear ();
+ gui_hotlist_clear (GUI_HOTLIST_MASK_MAX);
hotlist_reset = 1;
}
plugin_name = infolist_string (infolist, "plugin_name");
@@ -760,12 +761,13 @@ upgrade_weechat_read_hotlist (struct t_infolist *infolist)
*/
int
-upgrade_weechat_read_cb (void *data,
+upgrade_weechat_read_cb (const void *pointer, void *data,
struct t_upgrade_file *upgrade_file,
int object_id,
struct t_infolist *infolist)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) upgrade_file;
@@ -834,14 +836,17 @@ upgrade_weechat_load ()
upgrade_layout = gui_layout_alloc (GUI_LAYOUT_UPGRADE);
- upgrade_file = upgrade_file_new (WEECHAT_UPGRADE_FILENAME, 0);
+ upgrade_file = upgrade_file_new (WEECHAT_UPGRADE_FILENAME,
+ &upgrade_weechat_read_cb, NULL, NULL);
if (!upgrade_file)
return 0;
- rc = upgrade_file_read (upgrade_file, &upgrade_weechat_read_cb, NULL);
+
+ rc = upgrade_file_read (upgrade_file);
+
upgrade_file_close (upgrade_file);
if (!hotlist_reset)
- gui_hotlist_clear ();
+ gui_hotlist_clear (GUI_HOTLIST_MASK_MAX);
gui_color_buffer_assign ();
gui_color_buffer_display ();
@@ -903,8 +908,7 @@ upgrade_weechat_end ()
/* remove .upgrade files */
util_exec_on_files (weechat_home,
0,
- NULL,
- &upgrade_weechat_remove_file_cb);
+ &upgrade_weechat_remove_file_cb, NULL);
/* display message for end of /upgrade with duration */
gettimeofday (&tv_now, NULL);
diff --git a/src/core/wee-upgrade.h b/src/core/wee-upgrade.h
index ebb77a559..28da38e7f 100644
--- a/src/core/wee-upgrade.h
+++ b/src/core/wee-upgrade.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/core/wee-url.c b/src/core/wee-url.c
index 8994233e9..2f30d2ec7 100644
--- a/src/core/wee-url.c
+++ b/src/core/wee-url.c
@@ -1,7 +1,7 @@
/*
* wee-url.c - URL transfer
*
- * Copyright (C) 2012-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2012-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -46,7 +46,7 @@
char *url_type_string[] = { "string", "long", "long long", "mask" };
/*
- * Constants/options for Curl 7.38.0
+ * Constants/options for Curl 7.49.0
* (this list of options must be updated on every new Curl release)
*/
@@ -104,6 +104,10 @@ struct t_url_constant url_protocols[] =
#if LIBCURL_VERSION_NUM >= 0x071502 /* 7.21.2 */
URL_DEF_CONST(PROTO, GOPHER),
#endif
+#if LIBCURL_VERSION_NUM >= 0x072800 /* 7.40.0 */
+ URL_DEF_CONST(PROTO, SMB),
+ URL_DEF_CONST(PROTO, SMBS),
+#endif
{ NULL, 0 },
};
@@ -123,7 +127,6 @@ struct t_url_constant url_auth[] =
URL_DEF_CONST(AUTH, NONE),
URL_DEF_CONST(AUTH, BASIC),
URL_DEF_CONST(AUTH, DIGEST),
- URL_DEF_CONST(AUTH, GSSNEGOTIATE),
URL_DEF_CONST(AUTH, NTLM),
URL_DEF_CONST(AUTH, ANY),
URL_DEF_CONST(AUTH, ANYSAFE),
@@ -137,6 +140,9 @@ struct t_url_constant url_auth[] =
#if LIBCURL_VERSION_NUM >= 0x071600 /* 7.22.0 */
URL_DEF_CONST(AUTH, NTLM_WB),
#endif
+#if LIBCURL_VERSION_NUM >= 0x070A06 && LIBCURL_VERSION_NUM < 0x072600 /* 7.10.6 - 7.38.0 */
+ URL_DEF_CONST(AUTH, GSSNEGOTIATE),
+#endif
#if LIBCURL_VERSION_NUM >= 0x072600 /* 7.38.0 */
URL_DEF_CONST(AUTH, NEGOTIATE),
#endif
@@ -168,6 +174,18 @@ struct t_url_constant url_http_version[] =
URL_DEF_CONST(_HTTP_VERSION, 1_0),
URL_DEF_CONST(_HTTP_VERSION, 1_1),
#endif
+#if LIBCURL_VERSION_NUM >= 0x072100 /* 7.33.0 */
+ URL_DEF_CONST(_HTTP_VERSION, 2_0),
+#endif
+#if LIBCURL_VERSION_NUM >= 0x072B00 /* 7.43.0 */
+ URL_DEF_CONST(_HTTP_VERSION, 2),
+#endif
+#if LIBCURL_VERSION_NUM >= 0x072F00 /* 7.47.0 */
+ URL_DEF_CONST(_HTTP_VERSION, 2TLS),
+#endif
+#if LIBCURL_VERSION_NUM >= 0x073100 /* 7.49.0 */
+ URL_DEF_CONST(_HTTP_VERSION, 2_PRIOR_KNOWLEDGE),
+#endif
{ NULL, 0 },
};
@@ -269,6 +287,9 @@ struct t_url_constant url_ssl_options[] =
#if LIBCURL_VERSION_NUM >= 0x071900 /* 7.25.0 */
URL_DEF_CONST(SSLOPT, ALLOW_BEAST),
#endif
+#if LIBCURL_VERSION_NUM >= 0x072C00 /* 7.44.0 */
+ URL_DEF_CONST(SSLOPT, NO_REVOKE),
+#endif
{ NULL, 0 },
};
@@ -365,7 +386,6 @@ struct t_url_option url_options[] =
URL_DEF_OPTION(PROTOCOLS, MASK, url_protocols),
URL_DEF_OPTION(REDIR_PROTOCOLS, MASK, url_protocols),
URL_DEF_OPTION(NOPROXY, STRING, NULL),
- URL_DEF_OPTION(SOCKS5_GSSAPI_SERVICE, STRING, NULL),
URL_DEF_OPTION(SOCKS5_GSSAPI_NEC, LONG, NULL),
#endif
#if LIBCURL_VERSION_NUM >= 0x071900 /* 7.25.0 */
@@ -373,6 +393,25 @@ struct t_url_option url_options[] =
URL_DEF_OPTION(TCP_KEEPIDLE, LONG, NULL),
URL_DEF_OPTION(TCP_KEEPINTVL, LONG, NULL),
#endif
+#if LIBCURL_VERSION_NUM >= 0x072800 /* 7.40.0 */
+ URL_DEF_OPTION(UNIX_SOCKET_PATH, STRING, NULL),
+#endif
+#if LIBCURL_VERSION_NUM >= 0x072A00 /* 7.42.0 */
+ URL_DEF_OPTION(PATH_AS_IS, LONG, NULL),
+#endif
+#if LIBCURL_VERSION_NUM >= 0x072B00 /* 7.43.0 */
+ URL_DEF_OPTION(PROXY_SERVICE_NAME, STRING, NULL),
+ URL_DEF_OPTION(SERVICE_NAME, STRING, NULL),
+#endif
+#if LIBCURL_VERSION_NUM >= 0x072D00 /* 7.45.0 */
+ URL_DEF_OPTION(DEFAULT_PROTOCOL, STRING, NULL),
+#endif
+#if LIBCURL_VERSION_NUM >= 0x071304 && LIBCURL_VERSION_NUM < 0x073100 /* 7.19.4 - 7.49.0 */
+ URL_DEF_OPTION(SOCKS5_GSSAPI_SERVICE, STRING, NULL),
+#endif
+#if LIBCURL_VERSION_NUM >= 0x073100 /* 7.49.0 */
+ URL_DEF_OPTION(TCP_FASTOPEN, LONG, NULL),
+#endif
/*
* name and password options (authentication)
@@ -480,6 +519,12 @@ struct t_url_option url_options[] =
URL_DEF_OPTION(HEADEROPT, MASK, url_header),
/*URL_DEF_OPTION(PROXYHEADER, LIST, NULL),*/
#endif
+#if LIBCURL_VERSION_NUM >= 0x072B00 /* 7.43.0 */
+ URL_DEF_OPTION(PIPEWAIT, LONG, NULL),
+#endif
+#if LIBCURL_VERSION_NUM >= 0x072E00 /* 7.46.0 */
+ URL_DEF_OPTION(STREAM_WEIGHT, LONG, NULL),
+#endif
/*
* SMTP options
@@ -498,6 +543,9 @@ struct t_url_option url_options[] =
#if LIBCURL_VERSION_NUM >= 0x071304 /* 7.19.4 */
URL_DEF_OPTION(TFTP_BLKSIZE, LONG, NULL),
#endif
+#if LIBCURL_VERSION_NUM >= 0x073000 /* 7.48.0 */
+ URL_DEF_OPTION(TFTP_NO_OPTIONS, LONG, NULL),
+#endif
/*
* FTP options
@@ -637,6 +685,9 @@ struct t_url_option url_options[] =
URL_DEF_OPTION(DNS_LOCAL_IP4, STRING, NULL),
URL_DEF_OPTION(DNS_LOCAL_IP6, STRING, NULL),
#endif
+#if LIBCURL_VERSION_NUM >= 0x073100 /* 7.49.0 */
+ /*URL_DEF_OPTION(CONNECT_TO, LIST, NULL),*/
+#endif
/*
* SSL and security options
@@ -695,6 +746,15 @@ struct t_url_option url_options[] =
URL_DEF_OPTION(SSL_ENABLE_ALPN, LONG, NULL),
URL_DEF_OPTION(SSL_ENABLE_NPN, LONG, NULL),
#endif
+#if LIBCURL_VERSION_NUM >= 0x072700 /* 7.39.0 */
+ URL_DEF_OPTION(PINNEDPUBLICKEY, STRING, NULL),
+#endif
+#if LIBCURL_VERSION_NUM >= 0x072900 /* 7.41.0 */
+ URL_DEF_OPTION(SSL_VERIFYSTATUS, LONG, NULL),
+#endif
+#if LIBCURL_VERSION_NUM >= 0x072A00 /* 7.42.0 */
+ URL_DEF_OPTION(SSL_FALSESTART, LONG, NULL),
+#endif
/*
* SSH options
diff --git a/src/core/wee-url.h b/src/core/wee-url.h
index be90abda3..cabd242e5 100644
--- a/src/core/wee-url.h
+++ b/src/core/wee-url.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2012-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/core/wee-utf8.c b/src/core/wee-utf8.c
index 7cfb8a875..bcff2340a 100644
--- a/src/core/wee-utf8.c
+++ b/src/core/wee-utf8.c
@@ -1,7 +1,7 @@
/*
* wee-utf8.c - UTF-8 string functions
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org>
*
* This file is part of WeeChat, the extensible chat client.
diff --git a/src/core/wee-utf8.h b/src/core/wee-utf8.h
index abdf96b2b..29391280f 100644
--- a/src/core/wee-utf8.h
+++ b/src/core/wee-utf8.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/core/wee-util.c b/src/core/wee-util.c
index d4d4e8d8f..b1f567916 100644
--- a/src/core/wee-util.c
+++ b/src/core/wee-util.c
@@ -1,7 +1,7 @@
/*
* wee-util.c - some useful functions
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -484,8 +484,9 @@ util_mkdir_parents (const char *directory, int mode)
*/
void
-util_exec_on_files (const char *directory, int hidden_files, void *data,
- void (*callback)(void *data, const char *filename))
+util_exec_on_files (const char *directory, int hidden_files,
+ void (*callback)(void *data, const char *filename),
+ void *callback_data)
{
char complete_filename[1024];
DIR *dir;
@@ -507,7 +508,7 @@ util_exec_on_files (const char *directory, int hidden_files, void *data,
lstat (complete_filename, &statbuf);
if (!S_ISDIR(statbuf.st_mode))
{
- (*callback) (data, complete_filename);
+ (*callback) (callback_data, complete_filename);
}
}
}
@@ -666,39 +667,35 @@ util_file_get_content (const char *filename)
fp = 0;
f = fopen (filename, "r");
- if (f)
+ if (!f)
+ goto error;
+
+ while (!feof (f))
{
- while (!feof (f))
- {
- buffer2 = (char *) realloc (buffer, (fp + (1024 * sizeof (char))));
- if (!buffer2)
- {
- if (buffer)
- free (buffer);
- return NULL;
- }
- buffer = buffer2;
- count = fread (&buffer[fp], sizeof(char), 1024, f);
- if (count <= 0)
- {
- free (buffer);
- return NULL;
- }
- fp += count;
- }
- buffer2 = (char *) realloc (buffer, fp + sizeof (char));
+ buffer2 = (char *) realloc (buffer, (fp + (1024 * sizeof (char))));
if (!buffer2)
- {
- if (buffer)
- free (buffer);
- return NULL;
- }
+ goto error;
buffer = buffer2;
- buffer[fp] = '\0';
- fclose (f);
+ count = fread (&buffer[fp], sizeof(char), 1024, f);
+ if (count <= 0)
+ goto error;
+ fp += count;
}
+ buffer2 = (char *) realloc (buffer, fp + sizeof (char));
+ if (!buffer2)
+ goto error;
+ buffer = buffer2;
+ buffer[fp] = '\0';
+ fclose (f);
return buffer;
+
+error:
+ if (buffer)
+ free (buffer);
+ if (f)
+ fclose(f);
+ return NULL;
}
/*
diff --git a/src/core/wee-util.h b/src/core/wee-util.h
index 583dfc0d9..47a24575f 100644
--- a/src/core/wee-util.h
+++ b/src/core/wee-util.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -45,9 +45,9 @@ extern int util_mkdir_home (const char *directory, int mode);
extern int util_mkdir (const char *directory, int mode);
extern int util_mkdir_parents (const char *directory, int mode);
extern void util_exec_on_files (const char *directory, int hidden_files,
- void *data,
void (*callback)(void *data,
- const char *filename));
+ const char *filename),
+ void *callback_data);
extern char *util_search_full_lib_name (const char *filename,
const char *sys_directory);
extern char *util_file_get_content (const char *filename);
diff --git a/src/core/wee-version.c b/src/core/wee-version.c
index 54942e65d..252907f16 100644
--- a/src/core/wee-version.c
+++ b/src/core/wee-version.c
@@ -1,7 +1,7 @@
/*
* wee-version.c - functions for WeeChat version
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/core/wee-version.h b/src/core/wee-version.h
index 8a6ff6648..63c189269 100644
--- a/src/core/wee-version.h
+++ b/src/core/wee-version.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/core/weechat.c b/src/core/weechat.c
index db11e991a..f0b7d44e5 100644
--- a/src/core/weechat.c
+++ b/src/core/weechat.c
@@ -17,7 +17,7 @@
*
* weechat.c - WeeChat main functions
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -110,8 +110,8 @@ char *weechat_startup_commands = NULL; /* startup commands (-r flag) */
void
weechat_display_copyright ()
{
- string_iconv_fprintf (stdout, "\n");
- string_iconv_fprintf (
+ string_fprintf (stdout, "\n");
+ string_fprintf (
stdout,
/* TRANSLATORS: "%s %s" after "compiled on" is date and time */
_("WeeChat %s Copyright %s, compiled on %s %s\n"
@@ -122,7 +122,7 @@ weechat_display_copyright ()
version_get_compilation_date (),
version_get_compilation_time (),
WEECHAT_WEBSITE);
- string_iconv_fprintf (stdout, "\n");
+ string_fprintf (stdout, "\n");
}
/*
@@ -133,12 +133,12 @@ void
weechat_display_usage (char *exec_name)
{
weechat_display_copyright ();
- string_iconv_fprintf (stdout, "\n");
- string_iconv_fprintf (stdout,
- _("Usage: %s [option...] [plugin:option...]\n"),
- exec_name, exec_name);
- string_iconv_fprintf (stdout, "\n");
- string_iconv_fprintf (
+ string_fprintf (stdout, "\n");
+ string_fprintf (stdout,
+ _("Usage: %s [option...] [plugin:option...]\n"),
+ exec_name, exec_name);
+ string_fprintf (stdout, "\n");
+ string_fprintf (
stdout,
_(" -a, --no-connect disable auto-connect to servers at "
"startup\n"
@@ -158,7 +158,7 @@ weechat_display_usage (char *exec_name)
"(see /help upgrade in WeeChat)\n"
" -v, --version display WeeChat version\n"
" plugin:option option for plugin (see man weechat)\n"));
- string_iconv_fprintf(stdout, "\n");
+ string_fprintf(stdout, "\n");
}
/*
@@ -191,13 +191,16 @@ weechat_parse_args (int argc, char *argv[])
|| (strcmp (argv[i], "--dir") == 0))
{
if (i + 1 < argc)
+ {
+ if (weechat_home)
+ free (weechat_home);
weechat_home = strdup (argv[++i]);
+ }
else
{
- string_iconv_fprintf (stderr,
- _("Error: missing argument for \"%s\" "
- "option\n"),
- argv[i]);
+ string_fprintf (stderr,
+ _("Error: missing argument for \"%s\" option\n"),
+ argv[i]);
weechat_shutdown (EXIT_FAILURE, 0);
}
}
@@ -211,8 +214,8 @@ weechat_parse_args (int argc, char *argv[])
|| (strcmp (argv[i], "--license") == 0))
{
weechat_display_copyright ();
- string_iconv_fprintf (stdout, "\n");
- string_iconv_fprintf (stdout, "%s%s", WEECHAT_LICENSE_TEXT);
+ string_fprintf (stdout, "\n");
+ string_fprintf (stdout, "%s%s", WEECHAT_LICENSE_TEXT);
weechat_shutdown (EXIT_SUCCESS, 0);
}
else if (strcmp (argv[i], "--no-dlclose") == 0)
@@ -255,13 +258,16 @@ weechat_parse_args (int argc, char *argv[])
|| (strcmp (argv[i], "--run-command") == 0))
{
if (i + 1 < argc)
+ {
+ if (weechat_startup_commands)
+ free (weechat_startup_commands);
weechat_startup_commands = strdup (argv[++i]);
+ }
else
{
- string_iconv_fprintf (stderr,
- _("Error: missing argument for \"%s\" "
- "option\n"),
- argv[i]);
+ string_fprintf (stderr,
+ _("Error: missing argument for \"%s\" option\n"),
+ argv[i]);
weechat_shutdown (EXIT_FAILURE, 0);
}
}
@@ -272,7 +278,7 @@ weechat_parse_args (int argc, char *argv[])
else if ((strcmp (argv[i], "-v") == 0)
|| (strcmp (argv[i], "--version") == 0))
{
- string_iconv_fprintf (stdout, version_get_version ());
+ string_fprintf (stdout, version_get_version ());
fprintf (stdout, "\n");
weechat_shutdown (EXIT_SUCCESS, 0);
}
@@ -295,8 +301,7 @@ weechat_set_home_path (char *home_path)
ptr_home = getenv ("HOME");
if (!ptr_home)
{
- string_iconv_fprintf (stderr,
- _("Error: unable to get HOME directory\n"));
+ string_fprintf (stderr, _("Error: unable to get HOME directory\n"));
weechat_shutdown (EXIT_FAILURE, 0);
/* make C static analyzer happy (never executed) */
return;
@@ -316,9 +321,8 @@ weechat_set_home_path (char *home_path)
if (!weechat_home)
{
- string_iconv_fprintf (stderr,
- _("Error: not enough memory for home "
- "directory\n"));
+ string_fprintf (stderr,
+ _("Error: not enough memory for home directory\n"));
weechat_shutdown (EXIT_FAILURE, 0);
/* make C static analyzer happy (never executed) */
return;
@@ -355,9 +359,9 @@ weechat_create_home_dir ()
config_weechat_home = WEECHAT_HOME;
if (!config_weechat_home[0])
{
- string_iconv_fprintf (stderr,
- _("Error: WEECHAT_HOME is undefined, check "
- "build options\n"));
+ string_fprintf (stderr,
+ _("Error: WEECHAT_HOME is undefined, check build "
+ "options\n"));
weechat_shutdown (EXIT_FAILURE, 0);
/* make C static analyzer happy (never executed) */
return;
@@ -370,9 +374,9 @@ weechat_create_home_dir ()
{
if (!S_ISDIR (statinfo.st_mode))
{
- string_iconv_fprintf (stderr,
- _("Error: home (%s) is not a directory\n"),
- weechat_home);
+ string_fprintf (stderr,
+ _("Error: home (%s) is not a directory\n"),
+ weechat_home);
weechat_shutdown (EXIT_FAILURE, 0);
/* make C static analyzer happy (never executed) */
return;
@@ -382,9 +386,9 @@ weechat_create_home_dir ()
/* create home directory; error is fatal */
if (!util_mkdir (weechat_home, 0755))
{
- string_iconv_fprintf (stderr,
- _("Error: cannot create directory \"%s\"\n"),
- weechat_home);
+ string_fprintf (stderr,
+ _("Error: cannot create directory \"%s\"\n"),
+ weechat_home);
weechat_shutdown (EXIT_FAILURE, 0);
/* make C static analyzer happy (never executed) */
return;
@@ -462,35 +466,62 @@ void
weechat_term_check ()
{
char *term, *sty, *tmux;
+ const char *screen_terms = "screen-256color, screen";
+ const char *tmux_terms = "tmux-256color, tmux, screen-256color, screen";
+ const char *ptr_terms;
int is_term_ok, is_screen, is_tmux;
term = getenv ("TERM");
sty = getenv ("STY");
tmux = getenv ("TMUX");
- is_term_ok = (term && (strncmp (term, "screen", 6) == 0));
is_screen = (sty && sty[0]);
is_tmux = (tmux && tmux[0]);
- if ((is_screen || is_tmux) && !is_term_ok)
+ if (is_screen || is_tmux)
{
- gui_chat_printf (
- NULL,
- /* TRANSLATORS: the "under %s" can be "under screen" or "under tmux" */
- _("%sWarning: WeeChat is running under %s and $TERM is \"%s\", "
- "which can cause display bugs; $TERM should be set to "
- "\"screen-256color\" or \"screen\""),
- gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
- (is_screen) ? "screen" : "tmux",
- (term) ? term : "");
- gui_chat_printf (
- NULL,
- _("%sYou should add this line in the file %s: %s"),
- gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
- (is_screen) ? "~/.screenrc" : "~/.tmux.conf",
- (is_screen) ?
- "term screen-256color" :
- "set -g default-terminal \"screen-256color\"");
+ /* check if $TERM is OK (according to screen/tmux) */
+ is_term_ok = 0;
+ ptr_terms = NULL;
+ if (is_screen)
+ {
+ is_term_ok = (term && (strncmp (term, "screen", 6) == 0));
+ ptr_terms = screen_terms;
+ }
+ else if (is_tmux)
+ {
+ is_term_ok = (term
+ && ((strncmp (term, "screen", 6) == 0)
+ || (strncmp (term, "tmux", 4) == 0)));
+ ptr_terms = tmux_terms;
+ }
+
+ /* display a warning if $TERM is NOT OK */
+ if (!is_term_ok)
+ {
+ gui_chat_printf_date_tags (
+ NULL,
+ 0,
+ "term_warning",
+ /* TRANSLATORS: the "under %s" can be "under screen" or "under tmux" */
+ _("%sWarning: WeeChat is running under %s and $TERM is \"%s\", "
+ "which can cause display bugs; $TERM should be set to one "
+ "of these values: %s"),
+ gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
+ (is_screen) ? "screen" : "tmux",
+ (term) ? term : "",
+ ptr_terms);
+ gui_chat_printf_date_tags (
+ NULL,
+ 0,
+ "term_warning",
+ _("%sYou should add this line in the file %s: %s"),
+ gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
+ (is_screen) ? "~/.screenrc" : "~/.tmux.conf",
+ (is_screen) ?
+ "term screen-256color" :
+ "set -g default-terminal \"tmux-256color\"");
+ }
}
}
@@ -578,18 +609,17 @@ weechat_shutdown (int return_code, int crash)
{
gui_chat_print_lines_waiting_buffer (stderr);
+ log_close ();
+ network_end ();
+ debug_end ();
+
if (weechat_argv0)
free (weechat_argv0);
if (weechat_home)
free (weechat_home);
- log_close ();
if (weechat_local_charset)
free (weechat_local_charset);
- network_end ();
-
- debug_end ();
-
if (crash)
abort();
else if (return_code >= 0)
diff --git a/src/core/weechat.h b/src/core/weechat.h
index fb895a63e..16c3011cc 100644
--- a/src/core/weechat.h
+++ b/src/core/weechat.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org>
*
* This file is part of WeeChat, the extensible chat client.
@@ -51,7 +51,7 @@
#endif /* !defined(_) */
-#define WEECHAT_COPYRIGHT_DATE "(C) 2003-2015"
+#define WEECHAT_COPYRIGHT_DATE "(C) 2003-2016"
#define WEECHAT_WEBSITE "https://weechat.org/"
#define WEECHAT_WEBSITE_DOWNLOAD "https://weechat.org/download"
diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt
index b9cdf0654..26da7e7f0 100644
--- a/src/gui/CMakeLists.txt
+++ b/src/gui/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
@@ -36,11 +36,13 @@ gui-layout.c gui-layout.h
gui-line.c gui-line.h
gui-main.h
gui-mouse.c gui-mouse.h
+gui-nick.c gui-nick.h
gui-nicklist.c gui-nicklist.h
gui-window.c gui-window.h)
include_directories(${CMAKE_BINARY_DIR})
add_library(weechat_gui_common STATIC ${LIB_GUI_COMMON_SRC})
+list(APPEND STATIC_LIBS weechat_gui_common)
if(ENABLE_NCURSES)
subdirs(curses)
diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am
index d7db9d549..528a7a66f 100644
--- a/src/gui/Makefile.am
+++ b/src/gui/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
@@ -56,6 +56,8 @@ lib_weechat_gui_common_a_SOURCES = gui-bar.c \
gui-main.h \
gui-mouse.c \
gui-mouse.h \
+ gui-nick.c \
+ gui-nick.h \
gui-nicklist.c \
gui-nicklist.h \
gui-window.c \
diff --git a/src/gui/curses/CMakeLists.txt b/src/gui/curses/CMakeLists.txt
index 284956f70..8fadce2d2 100644
--- a/src/gui/curses/CMakeLists.txt
+++ b/src/gui/curses/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
# Copyright (C) 2007-2008 Julien Louis <ptitlouis@sysif.net>
# Copyright (C) 2009 Emmanuel Bouthenot <kolter@openics.org>
#
@@ -81,7 +81,7 @@ add_executable(${EXECUTABLE} ${WEECHAT_CURSES_MAIN_SRC})
add_dependencies(${EXECUTABLE} weechat_gui_curses)
-# Due to circular references, we must link two times with libweechat_core.a
+# Due to circular references, we must link two times with libweechat_core.a and libweechat_gui_common.a
target_link_libraries(${EXECUTABLE} ${STATIC_LIBS} weechat_gui_curses ${EXTRA_LIBS} ${STATIC_LIBS})
# Create a symbolic link weechat-curses -> weechat
diff --git a/src/gui/curses/Makefile.am b/src/gui/curses/Makefile.am
index bdcc0f4f5..2e04ff820 100644
--- a/src/gui/curses/Makefile.am
+++ b/src/gui/curses/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/gui/curses/gui-curses-bar-window.c b/src/gui/curses/gui-curses-bar-window.c
index 8c6749cd8..393c65b16 100644
--- a/src/gui/curses/gui-curses-bar-window.c
+++ b/src/gui/curses/gui-curses-bar-window.c
@@ -1,7 +1,7 @@
/*
* gui-curses-bar-window.c - bar window functions for Curses GUI
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c
index c1cf10a82..05586d037 100644
--- a/src/gui/curses/gui-curses-chat.c
+++ b/src/gui/curses/gui-curses-chat.c
@@ -1,7 +1,7 @@
/*
* gui-curses-chat.c - chat display functions for Curses GUI
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -1365,13 +1365,13 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
ptr_end_offset = ptr_data + word_end_offset;
/* if message ends with spaces, display them */
- if ((word_length == 0) && (word_length_with_spaces > 0)
+ if ((word_length <= 0) && (word_length_with_spaces > 0)
&& !ptr_data[word_end_offset + 1])
{
word_length = word_length_with_spaces;
}
- if (word_length > 0)
+ if (word_length >= 0)
{
line_align = gui_line_get_align (window->buffer, line, 1,
(lines_displayed == 0) ? 1 : 0);
diff --git a/src/gui/curses/gui-curses-color.c b/src/gui/curses/gui-curses-color.c
index 2bdfc52da..340efccb0 100644
--- a/src/gui/curses/gui-curses-color.c
+++ b/src/gui/curses/gui-curses-color.c
@@ -1,7 +1,7 @@
/*
* gui-curses-color.c - color functions for Curses GUI
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -351,9 +351,11 @@ error:
*/
int
-gui_color_timer_warning_pairs_full (void *data, int remaining_calls)
+gui_color_timer_warning_pairs_full (const void *pointer, void *data,
+ int remaining_calls)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) remaining_calls;
@@ -402,7 +404,7 @@ gui_color_get_pair (int fg, int bg)
{
/* display warning if auto reset of pairs is disabled */
hook_timer (NULL, 1, 0, 1,
- &gui_color_timer_warning_pairs_full, NULL);
+ &gui_color_timer_warning_pairs_full, NULL, NULL);
gui_color_warning_pairs_full = 1;
}
return 1;
@@ -1034,9 +1036,10 @@ gui_color_buffer_display ()
*/
int
-gui_color_timer_cb (void *data, int remaining_calls)
+gui_color_timer_cb (const void *pointer, void *data, int remaining_calls)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) remaining_calls;
@@ -1101,7 +1104,7 @@ gui_color_switch_colors ()
if (gui_color_use_term_colors)
{
gui_color_hook_timer = hook_timer (NULL, 1000, 0, 0,
- &gui_color_timer_cb, NULL);
+ &gui_color_timer_cb, NULL, NULL);
}
}
@@ -1132,10 +1135,12 @@ gui_color_reset_pairs ()
*/
int
-gui_color_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
+gui_color_buffer_input_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
const char *input_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (string_strcasecmp (input_data, "e") == 0)
@@ -1164,9 +1169,11 @@ gui_color_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
*/
int
-gui_color_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
+gui_color_buffer_close_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
@@ -1203,9 +1210,10 @@ gui_color_buffer_open ()
{
if (!gui_color_buffer)
{
- gui_color_buffer = gui_buffer_new (NULL, GUI_COLOR_BUFFER_NAME,
- &gui_color_buffer_input_cb, NULL,
- &gui_color_buffer_close_cb, NULL);
+ gui_color_buffer = gui_buffer_new (
+ NULL, GUI_COLOR_BUFFER_NAME,
+ &gui_color_buffer_input_cb, NULL, NULL,
+ &gui_color_buffer_close_cb, NULL, NULL);
if (gui_color_buffer)
{
if (!gui_color_buffer->short_name)
@@ -1462,6 +1470,7 @@ gui_color_init_weechat ()
gui_color_build (GUI_COLOR_CHAT_NICK_SUFFIX, CONFIG_COLOR(config_color_chat_nick_suffix), CONFIG_COLOR(config_color_chat_bg));
gui_color_build (GUI_COLOR_EMPHASIS, CONFIG_COLOR(config_color_emphasized), CONFIG_COLOR(config_color_emphasized_bg));
gui_color_build (GUI_COLOR_CHAT_DAY_CHANGE, CONFIG_COLOR(config_color_chat_day_change), CONFIG_COLOR(config_color_chat_bg));
+ gui_color_build (GUI_COLOR_CHAT_VALUE_NULL, CONFIG_COLOR(config_color_chat_value_null), CONFIG_COLOR(config_color_chat_bg));
/*
* define old nick colors for compatibility on /upgrade with previous
diff --git a/src/gui/curses/gui-curses-key.c b/src/gui/curses/gui-curses-key.c
index d9fd89367..cd267064a 100644
--- a/src/gui/curses/gui-curses-key.c
+++ b/src/gui/curses/gui-curses-key.c
@@ -1,7 +1,7 @@
/*
* gui-curses-key.c - keyboard functions for Curses GUI
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -507,12 +507,13 @@ gui_key_flush (int paste)
*/
int
-gui_key_read_cb (void *data, int fd)
+gui_key_read_cb (const void *pointer, void *data, int fd)
{
int ret, i, accept_paste, cancel_paste, text_added_to_buffer, pos;
unsigned char buffer[4096];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) fd;
diff --git a/src/gui/curses/gui-curses-main.c b/src/gui/curses/gui-curses-main.c
index 090c1ef04..8407f8c63 100644
--- a/src/gui/curses/gui-curses-main.c
+++ b/src/gui/curses/gui-curses-main.c
@@ -1,7 +1,7 @@
/*
* gui-curses-main.c - main loop for Curses GUI
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -181,7 +181,8 @@ gui_main_init ()
/* create core buffer */
ptr_buffer = gui_buffer_new (NULL, GUI_BUFFER_MAIN,
- NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (ptr_buffer)
{
gui_init_ok = 1;
@@ -388,7 +389,7 @@ gui_main_loop ()
/* hook stdin (read keyboard) */
hook_fd_keyboard = hook_fd (NULL, STDIN_FILENO, 1, 0, 0,
- &gui_key_read_cb, NULL);
+ &gui_key_read_cb, NULL, NULL);
gui_window_ask_refresh (1);
@@ -421,6 +422,9 @@ gui_main_loop ()
/* execute fd hooks */
hook_fd_exec ();
+
+ /* run process (with fork) */
+ hook_process_exec ();
}
/* remove keyboard hook */
diff --git a/src/gui/curses/gui-curses-mouse.c b/src/gui/curses/gui-curses-mouse.c
index dcd9c1070..8620bbeee 100644
--- a/src/gui/curses/gui-curses-mouse.c
+++ b/src/gui/curses/gui-curses-mouse.c
@@ -1,7 +1,7 @@
/*
* gui-curses-mouse.c - mouse functions for Curses GUI
*
- * Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -218,9 +218,10 @@ gui_mouse_grab_end (const char *mouse_key)
*/
int
-gui_mouse_event_timer_cb (void *data, int remaining_calls)
+gui_mouse_event_timer_cb (const void *pointer, void *data, int remaining_calls)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) remaining_calls;
@@ -244,7 +245,7 @@ gui_mouse_event_init ()
gui_mouse_event_timer = hook_timer (NULL,
CONFIG_INTEGER(config_look_mouse_timer_delay),
0, 1,
- &gui_mouse_event_timer_cb, NULL);
+ &gui_mouse_event_timer_cb, NULL, NULL);
}
/*
diff --git a/src/gui/curses/gui-curses-term.c b/src/gui/curses/gui-curses-term.c
index c5408bbcd..53a16f373 100644
--- a/src/gui/curses/gui-curses-term.c
+++ b/src/gui/curses/gui-curses-term.c
@@ -1,7 +1,7 @@
/*
* gui-curses-term.c - terminal functions for Curses GUI
*
- * Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c
index af0a69c91..3a8804998 100644
--- a/src/gui/curses/gui-curses-window.c
+++ b/src/gui/curses/gui-curses-window.c
@@ -1,7 +1,7 @@
/*
* gui-curses-window.c - window display functions for Curses GUI
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -2362,9 +2362,11 @@ gui_window_refresh_screen (int full_refresh)
*/
int
-gui_window_bare_display_timer_cb (void *data, int remaining_calls)
+gui_window_bare_display_timer_cb (const void *pointer, void *data,
+ int remaining_calls)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (gui_window_bare_display)
@@ -2408,7 +2410,7 @@ gui_window_bare_display_toggle (const char *delay)
gui_window_bare_display_timer = hook_timer (
NULL,
seconds * 1000, 0, 1,
- &gui_window_bare_display_timer_cb, NULL);
+ &gui_window_bare_display_timer_cb, NULL, NULL);
}
}
}
@@ -2467,7 +2469,8 @@ gui_window_set_title (const char *title)
{
printf ("\33]0;%s\7", new_title);
}
- else if (strncmp (envterm, "screen", 6) == 0)
+ else if ((strncmp (envterm, "screen", 6) == 0)
+ || (strncmp (envterm, "tmux", 4) == 0))
{
if (title && title[0])
{
diff --git a/src/gui/curses/gui-curses.h b/src/gui/curses/gui-curses.h
index 682c98596..cbf162c27 100644
--- a/src/gui/curses/gui-curses.h
+++ b/src/gui/curses/gui-curses.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -98,7 +98,7 @@ extern void gui_chat_calculate_line_diff (struct t_gui_window *window,
/* key functions */
extern void gui_key_default_bindings (int context);
-extern int gui_key_read_cb (void *data, int fd);
+extern int gui_key_read_cb (const void *pointer, void *data, int fd);
/* window functions */
extern void gui_window_read_terminal_size ();
diff --git a/src/gui/curses/main.c b/src/gui/curses/main.c
index 9a7211272..09df7bbea 100644
--- a/src/gui/curses/main.c
+++ b/src/gui/curses/main.c
@@ -1,7 +1,7 @@
/*
* main.c - entry point for Curses GUI
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/gui/gui-bar-item.c b/src/gui/gui-bar-item.c
index d3eea0512..980d9cbe1 100644
--- a/src/gui/gui-bar-item.c
+++ b/src/gui/gui-bar-item.c
@@ -1,7 +1,7 @@
/*
* gui-bar-item.c - bar item functions (used by all GUI)
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -63,7 +63,7 @@ char *gui_bar_item_names[GUI_BAR_NUM_ITEMS] =
"buffer_count", "buffer_last_number", "buffer_plugin", "buffer_number",
"buffer_name", "buffer_short_name", "buffer_modes", "buffer_filter",
"buffer_zoom", "buffer_nicklist_count", "scroll", "hotlist", "completion",
- "buffer_title", "buffer_nicklist", "window_number", "mouse_status"
+ "buffer_title", "buffer_nicklist", "window_number", "mouse_status", "away"
};
char *gui_bar_items_default_for_bars[][2] =
{ { GUI_BAR_DEFAULT_NAME_INPUT,
@@ -399,9 +399,13 @@ gui_bar_item_get_value (struct t_gui_bar *bar, struct t_gui_window *window,
bar->items_name[item][subitem]);
if (ptr_item && ptr_item->build_callback)
{
- item_value = (ptr_item->build_callback) (ptr_item->build_callback_data,
- ptr_item, window, buffer,
- NULL);
+ item_value = (ptr_item->build_callback) (
+ ptr_item->build_callback_pointer,
+ ptr_item->build_callback_data,
+ ptr_item,
+ window,
+ buffer,
+ NULL);
}
if (item_value && !item_value[0])
{
@@ -526,11 +530,13 @@ gui_bar_item_count_lines (char *string)
struct t_gui_bar_item *
gui_bar_item_new (struct t_weechat_plugin *plugin, const char *name,
- char *(*build_callback)(void *data,
+ char *(*build_callback)(const void *pointer,
+ void *data,
struct t_gui_bar_item *item,
struct t_gui_window *window,
struct t_gui_buffer *buffer,
struct t_hashtable *extra_info),
+ const void *build_callback_pointer,
void *build_callback_data)
{
struct t_gui_bar_item *new_bar_item;
@@ -549,6 +555,7 @@ gui_bar_item_new (struct t_weechat_plugin *plugin, const char *name,
new_bar_item->plugin = plugin;
new_bar_item->name = strdup (name);
new_bar_item->build_callback = build_callback;
+ new_bar_item->build_callback_pointer = build_callback_pointer;
new_bar_item->build_callback_data = build_callback_data;
/* add bar item to bar items queue */
@@ -685,6 +692,8 @@ gui_bar_item_free (struct t_gui_bar_item *item)
/* free data */
if (item->name)
free (item->name);
+ if (item->build_callback_data)
+ free (item->build_callback_data);
free (item);
}
@@ -724,19 +733,21 @@ gui_bar_item_free_all_plugin (struct t_weechat_plugin *plugin)
}
/*
- * Default item for input paste question.
+ * Bar item with input paste question.
*/
char *
-gui_bar_item_default_input_paste (void *data, struct t_gui_bar_item *item,
- struct t_gui_window *window,
- struct t_gui_buffer *buffer,
- struct t_hashtable *extra_info)
+gui_bar_item_input_paste_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
+ struct t_gui_window *window,
+ struct t_gui_buffer *buffer,
+ struct t_hashtable *extra_info)
{
char str_paste[1024];
int lines;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) buffer;
@@ -759,18 +770,20 @@ gui_bar_item_default_input_paste (void *data, struct t_gui_bar_item *item,
}
/*
- * Default item for input prompt.
+ * Bar item with input prompt.
*/
char *
-gui_bar_item_default_input_prompt (void *data, struct t_gui_bar_item *item,
- struct t_gui_window *window,
- struct t_gui_buffer *buffer,
- struct t_hashtable *extra_info)
+gui_bar_item_input_prompt_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
+ struct t_gui_window *window,
+ struct t_gui_buffer *buffer,
+ struct t_hashtable *extra_info)
{
const char *nick;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) window;
@@ -785,18 +798,20 @@ gui_bar_item_default_input_prompt (void *data, struct t_gui_bar_item *item,
}
/*
- * Default item for input search status.
+ * Bar item with input search status.
*/
char *
-gui_bar_item_default_input_search (void *data, struct t_gui_bar_item *item,
- struct t_gui_window *window,
- struct t_gui_buffer *buffer,
- struct t_hashtable *extra_info)
+gui_bar_item_input_search_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
+ struct t_gui_window *window,
+ struct t_gui_buffer *buffer,
+ struct t_hashtable *extra_info)
{
char str_search[1024];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) window;
@@ -826,14 +841,15 @@ gui_bar_item_default_input_search (void *data, struct t_gui_bar_item *item,
}
/*
- * Default item for input text.
+ * Bar item with input text.
*/
char *
-gui_bar_item_default_input_text (void *data, struct t_gui_bar_item *item,
- struct t_gui_window *window,
- struct t_gui_buffer *buffer,
- struct t_hashtable *extra_info)
+gui_bar_item_input_text_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
+ struct t_gui_window *window,
+ struct t_gui_buffer *buffer,
+ struct t_hashtable *extra_info)
{
char *ptr_input, *ptr_input2, str_buffer[128], str_start_input[16];
char str_cursor[16], *buf;
@@ -841,6 +857,7 @@ gui_bar_item_default_input_text (void *data, struct t_gui_bar_item *item,
int length, length_cursor, length_start_input, buf_pos;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) window;
@@ -953,20 +970,22 @@ gui_bar_item_default_input_text (void *data, struct t_gui_bar_item *item,
}
/*
- * Default item for time.
+ * Bar item with time.
*/
char *
-gui_bar_item_default_time (void *data, struct t_gui_bar_item *item,
- struct t_gui_window *window,
- struct t_gui_buffer *buffer,
- struct t_hashtable *extra_info)
+gui_bar_item_time_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
+ struct t_gui_window *window,
+ struct t_gui_buffer *buffer,
+ struct t_hashtable *extra_info)
{
time_t date;
struct tm *local_time;
char text_time[128], text_time2[128];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) window;
@@ -988,18 +1007,20 @@ gui_bar_item_default_time (void *data, struct t_gui_bar_item *item,
}
/*
- * Default item for number of buffers.
+ * Bar item with number of buffers.
*/
char *
-gui_bar_item_default_buffer_count (void *data, struct t_gui_bar_item *item,
- struct t_gui_window *window,
- struct t_gui_buffer *buffer,
- struct t_hashtable *extra_info)
+gui_bar_item_buffer_count_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
+ struct t_gui_window *window,
+ struct t_gui_buffer *buffer,
+ struct t_hashtable *extra_info)
{
char buf[32];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) window;
@@ -1012,19 +1033,20 @@ gui_bar_item_default_buffer_count (void *data, struct t_gui_bar_item *item,
}
/*
- * Default item for last buffer number.
+ * Bar item with last buffer number.
*/
char *
-gui_bar_item_default_buffer_last_number (void *data,
- struct t_gui_bar_item *item,
- struct t_gui_window *window,
- struct t_gui_buffer *buffer,
- struct t_hashtable *extra_info)
+gui_bar_item_buffer_last_number_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
+ struct t_gui_window *window,
+ struct t_gui_buffer *buffer,
+ struct t_hashtable *extra_info)
{
char buf[32];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) window;
@@ -1038,18 +1060,20 @@ gui_bar_item_default_buffer_last_number (void *data,
}
/*
- * Default item for name of buffer plugin.
+ * Bar item with name of buffer plugin.
*/
char *
-gui_bar_item_default_buffer_plugin (void *data, struct t_gui_bar_item *item,
- struct t_gui_window *window,
- struct t_gui_buffer *buffer,
- struct t_hashtable *extra_info)
+gui_bar_item_buffer_plugin_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
+ struct t_gui_window *window,
+ struct t_gui_buffer *buffer,
+ struct t_hashtable *extra_info)
{
const char *plugin_name;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) window;
@@ -1064,18 +1088,20 @@ gui_bar_item_default_buffer_plugin (void *data, struct t_gui_bar_item *item,
}
/*
- * Default item for number of buffer.
+ * Bar item with number of buffer.
*/
char *
-gui_bar_item_default_buffer_number (void *data, struct t_gui_bar_item *item,
- struct t_gui_window *window,
- struct t_gui_buffer *buffer,
- struct t_hashtable *extra_info)
+gui_bar_item_buffer_number_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
+ struct t_gui_window *window,
+ struct t_gui_buffer *buffer,
+ struct t_hashtable *extra_info)
{
char str_number[64];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) window;
@@ -1092,18 +1118,20 @@ gui_bar_item_default_buffer_number (void *data, struct t_gui_bar_item *item,
}
/*
- * Default item for name of buffer.
+ * Bar item with name of buffer.
*/
char *
-gui_bar_item_default_buffer_name (void *data, struct t_gui_bar_item *item,
- struct t_gui_window *window,
- struct t_gui_buffer *buffer,
- struct t_hashtable *extra_info)
+gui_bar_item_buffer_name_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
+ struct t_gui_window *window,
+ struct t_gui_buffer *buffer,
+ struct t_hashtable *extra_info)
{
char str_name[256];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) window;
@@ -1121,19 +1149,20 @@ gui_bar_item_default_buffer_name (void *data, struct t_gui_bar_item *item,
}
/*
- * Default item for short name of buffer.
+ * Bar item with short name of buffer.
*/
char *
-gui_bar_item_default_buffer_short_name (void *data,
- struct t_gui_bar_item *item,
- struct t_gui_window *window,
- struct t_gui_buffer *buffer,
- struct t_hashtable *extra_info)
+gui_bar_item_buffer_short_name_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
+ struct t_gui_window *window,
+ struct t_gui_buffer *buffer,
+ struct t_hashtable *extra_info)
{
char str_short_name[256];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) window;
@@ -1151,19 +1180,21 @@ gui_bar_item_default_buffer_short_name (void *data,
}
/*
- * Default item for modes of buffer.
+ * Bar item with modes of buffer.
*
* Note: this bar item is empty for WeeChat core, this is used only by plugins
* like irc to display channel modes.
*/
char *
-gui_bar_item_default_buffer_modes (void *data, struct t_gui_bar_item *item,
- struct t_gui_window *window,
- struct t_gui_buffer *buffer,
- struct t_hashtable *extra_info)
+gui_bar_item_buffer_modes_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
+ struct t_gui_window *window,
+ struct t_gui_buffer *buffer,
+ struct t_hashtable *extra_info)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) window;
@@ -1174,18 +1205,20 @@ gui_bar_item_default_buffer_modes (void *data, struct t_gui_bar_item *item,
}
/*
- * Default item for buffer filter.
+ * Bar item with buffer filter indicator.
*/
char *
-gui_bar_item_default_buffer_filter (void *data, struct t_gui_bar_item *item,
- struct t_gui_window *window,
- struct t_gui_buffer *buffer,
- struct t_hashtable *extra_info)
+gui_bar_item_buffer_filter_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
+ struct t_gui_window *window,
+ struct t_gui_buffer *buffer,
+ struct t_hashtable *extra_info)
{
char str_filter[512];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) window;
@@ -1209,19 +1242,20 @@ gui_bar_item_default_buffer_filter (void *data, struct t_gui_bar_item *item,
}
/*
- * Default item for number of nicks in buffer nicklist.
+ * Bar item with number of nicks in buffer nicklist.
*/
char *
-gui_bar_item_default_buffer_nicklist_count (void *data,
- struct t_gui_bar_item *item,
- struct t_gui_window *window,
- struct t_gui_buffer *buffer,
- struct t_hashtable *extra_info)
+gui_bar_item_buffer_nicklist_count_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
+ struct t_gui_window *window,
+ struct t_gui_buffer *buffer,
+ struct t_hashtable *extra_info)
{
char str_count[64];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) window;
@@ -1239,19 +1273,21 @@ gui_bar_item_default_buffer_nicklist_count (void *data,
}
/*
- * Default item for zoom on merged buffer.
+ * Bar item with zoom on merged buffer.
*/
char *
-gui_bar_item_buffer_zoom (void *data, struct t_gui_bar_item *item,
- struct t_gui_window *window,
- struct t_gui_buffer *buffer,
- struct t_hashtable *extra_info)
+gui_bar_item_buffer_zoom_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
+ struct t_gui_window *window,
+ struct t_gui_buffer *buffer,
+ struct t_hashtable *extra_info)
{
char buf[512];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) window;
@@ -1271,18 +1307,20 @@ gui_bar_item_buffer_zoom (void *data, struct t_gui_bar_item *item,
}
/*
- * Default item for scrolling indicator.
+ * Bar item with scrolling indicator.
*/
char *
-gui_bar_item_default_scroll (void *data, struct t_gui_bar_item *item,
- struct t_gui_window *window,
- struct t_gui_buffer *buffer,
- struct t_hashtable *extra_info)
+gui_bar_item_scroll_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
+ struct t_gui_window *window,
+ struct t_gui_buffer *buffer,
+ struct t_hashtable *extra_info)
{
char str_scroll[512];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) buffer;
@@ -1302,22 +1340,24 @@ gui_bar_item_default_scroll (void *data, struct t_gui_bar_item *item,
}
/*
- * Default item for hotlist.
+ * Bar item with hotlist.
*/
char *
-gui_bar_item_default_hotlist (void *data, struct t_gui_bar_item *item,
- struct t_gui_window *window,
- struct t_gui_buffer *buffer,
- struct t_hashtable *extra_info)
+gui_bar_item_hotlist_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
+ struct t_gui_window *window,
+ struct t_gui_buffer *buffer,
+ struct t_hashtable *extra_info)
{
- char str_hotlist[4096], format[32], *buffer_without_name_displayed;
- const char *hotlist_suffix;
+ char str_hotlist[4096], *buffer_without_name_displayed, *buffer_name;
+ const char *hotlist_suffix, *ptr_buffer_name;
struct t_gui_hotlist *ptr_hotlist;
int numbers_count, names_count, display_name, count_max;
int priority, priority_min, priority_min_displayed, private;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) window;
@@ -1417,19 +1457,25 @@ gui_bar_item_default_hotlist (void *data, struct t_gui_bar_item *item,
strcat (str_hotlist, GUI_COLOR_CUSTOM_BAR_DELIM);
strcat (str_hotlist, ":");
strcat (str_hotlist, GUI_COLOR_CUSTOM_BAR_FG);
+ ptr_buffer_name = (CONFIG_BOOLEAN(config_look_hotlist_short_names)) ?
+ gui_buffer_get_short_name (ptr_hotlist->buffer) : ptr_hotlist->buffer->name;
if (CONFIG_INTEGER(config_look_hotlist_names_length) == 0)
{
- snprintf (format, sizeof (format), "%%s");
+ buffer_name = strdup (ptr_buffer_name);
}
else
{
- snprintf (format, sizeof (format),
- "%%.%ds",
- CONFIG_INTEGER(config_look_hotlist_names_length));
+ buffer_name = utf8_strndup (
+ ptr_buffer_name,
+ CONFIG_INTEGER(config_look_hotlist_names_length));
+ }
+ if (buffer_name)
+ {
+ if (strlen (buffer_name) > 128)
+ buffer_name[128] = '\0';
+ strcat (str_hotlist, buffer_name);
+ free (buffer_name);
}
- snprintf (str_hotlist + strlen (str_hotlist), 128, format,
- (CONFIG_BOOLEAN(config_look_hotlist_short_names)) ?
- gui_buffer_get_short_name (ptr_hotlist->buffer) : ptr_hotlist->buffer->name);
}
else
{
@@ -1532,20 +1578,22 @@ gui_bar_item_default_hotlist (void *data, struct t_gui_bar_item *item,
}
/*
- * Default item for (partial) completion.
+ * Bar item with (partial) completion.
*/
char *
-gui_bar_item_default_completion (void *data, struct t_gui_bar_item *item,
- struct t_gui_window *window,
- struct t_gui_buffer *buffer,
- struct t_hashtable *extra_info)
+gui_bar_item_completion_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
+ struct t_gui_window *window,
+ struct t_gui_buffer *buffer,
+ struct t_hashtable *extra_info)
{
int length, i;
char *buf, str_number[64];
struct t_gui_completion_word *ptr_completion_word;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) window;
@@ -1593,16 +1641,18 @@ gui_bar_item_default_completion (void *data, struct t_gui_bar_item *item,
}
/*
- * Default item for buffer title.
+ * Bar item with buffer title.
*/
char *
-gui_bar_item_default_buffer_title (void *data, struct t_gui_bar_item *item,
- struct t_gui_window *window,
- struct t_gui_buffer *buffer,
- struct t_hashtable *extra_info)
+gui_bar_item_buffer_title_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
+ struct t_gui_window *window,
+ struct t_gui_buffer *buffer,
+ struct t_hashtable *extra_info)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) window;
@@ -1615,14 +1665,15 @@ gui_bar_item_default_buffer_title (void *data, struct t_gui_bar_item *item,
}
/*
- * Default item for nicklist.
+ * Bar item with nicklist.
*/
char *
-gui_bar_item_default_buffer_nicklist (void *data, struct t_gui_bar_item *item,
- struct t_gui_window *window,
- struct t_gui_buffer *buffer,
- struct t_hashtable *extra_info)
+gui_bar_item_buffer_nicklist_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
+ struct t_gui_window *window,
+ struct t_gui_buffer *buffer,
+ struct t_hashtable *extra_info)
{
struct t_gui_nick_group *ptr_group;
struct t_gui_nick *ptr_nick;
@@ -1631,6 +1682,7 @@ gui_bar_item_default_buffer_nicklist (void *data, struct t_gui_bar_item *item,
char *str_nicklist;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) window;
@@ -1756,18 +1808,20 @@ gui_bar_item_default_buffer_nicklist (void *data, struct t_gui_bar_item *item,
}
/*
- * Default item for number of window.
+ * Bar item with number of window.
*/
char *
-gui_bar_item_default_window_number (void *data, struct t_gui_bar_item *item,
- struct t_gui_window *window,
- struct t_gui_buffer *buffer,
- struct t_hashtable *extra_info)
+gui_bar_item_window_number_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
+ struct t_gui_window *window,
+ struct t_gui_buffer *buffer,
+ struct t_hashtable *extra_info)
{
char str_number[64];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) buffer;
@@ -1782,18 +1836,20 @@ gui_bar_item_default_window_number (void *data, struct t_gui_bar_item *item,
}
/*
- * Default item for mouse status.
+ * Bar item with mouse status.
*/
char *
-gui_bar_item_default_mouse_status (void *data, struct t_gui_bar_item *item,
- struct t_gui_window *window,
- struct t_gui_buffer *buffer,
- struct t_hashtable *extra_info)
+gui_bar_item_mouse_status_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
+ struct t_gui_window *window,
+ struct t_gui_buffer *buffer,
+ struct t_hashtable *extra_info)
{
char str_mouse[512];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) window;
@@ -1811,12 +1867,61 @@ gui_bar_item_default_mouse_status (void *data, struct t_gui_bar_item *item,
}
/*
+ * Bar item with away message.
+ */
+
+char *
+gui_bar_item_away_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
+ struct t_gui_window *window,
+ struct t_gui_buffer *buffer,
+ struct t_hashtable *extra_info)
+{
+ const char *away;
+ char *buf, *message;
+ int length;
+
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+ (void) item;
+ (void) window;
+ (void) extra_info;
+
+ if (!buffer)
+ return NULL;
+
+ away = (const char *)hashtable_get (buffer->local_variables, "away");
+ if (!away)
+ return NULL;
+
+ buf = NULL;
+ message = (CONFIG_BOOLEAN(config_look_item_away_message)) ?
+ strdup (away) : strdup (_("away"));
+ if (message)
+ {
+ length = strlen (message) + 64 + 1;
+ buf = malloc (length);
+ if (buf)
+ {
+ snprintf (buf, length, "%s%s",
+ gui_color_get_custom (gui_color_get_name (CONFIG_COLOR(config_color_item_away))),
+ message);
+ }
+ free (message);
+ }
+
+ return buf;
+}
+
+/*
* Focus on nicklist.
*/
struct t_hashtable *
-gui_bar_item_focus_buffer_nicklist (void *data,
- struct t_hashtable *info)
+gui_bar_item_focus_buffer_nicklist_cb (const void *pointer,
+ void *data,
+ struct t_hashtable *info)
{
struct t_gui_nick_group *ptr_group;
struct t_gui_nick *ptr_nick;
@@ -1828,6 +1933,7 @@ gui_bar_item_focus_buffer_nicklist (void *data,
char *error;
/* make C compiler happy */
+ (void) pointer;
(void) data;
str_bar_item_line = hashtable_get (info, "_bar_item_line");
@@ -1909,7 +2015,7 @@ gui_bar_item_focus_buffer_nicklist (void *data,
*/
int
-gui_bar_item_timer_cb (void *data, int remaining_calls)
+gui_bar_item_timer_cb (const void *pointer, void *data, int remaining_calls)
{
time_t date;
struct tm *local_time;
@@ -1917,6 +2023,7 @@ gui_bar_item_timer_cb (void *data, int remaining_calls)
char new_item_time_text[128];
/* make C compiler happy */
+ (void) data;
(void) remaining_calls;
date = time (NULL);
@@ -1935,7 +2042,7 @@ gui_bar_item_timer_cb (void *data, int remaining_calls)
{
snprintf (item_time_text, sizeof (item_time_text),
"%s", new_item_time_text);
- gui_bar_item_update ((char *)data);
+ gui_bar_item_update ((char *)pointer);
}
return WEECHAT_RC_OK;
@@ -1946,15 +2053,17 @@ gui_bar_item_timer_cb (void *data, int remaining_calls)
*/
int
-gui_bar_item_signal_cb (void *data, const char *signal,
+gui_bar_item_signal_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
/* make C compiler happy */
+ (void) data;
(void) signal;
(void) type_data;
(void) signal_data;
- gui_bar_item_update ((char *)data);
+ gui_bar_item_update ((char *)pointer);
return WEECHAT_RC_OK;
}
@@ -1973,7 +2082,7 @@ gui_bar_item_hook_signal (const char *signal, const char *item)
{
bar_item_hook->hook = hook_signal (NULL, signal,
&gui_bar_item_signal_cb,
- (void *)item);
+ (void *)item, NULL);
bar_item_hook->next_hook = gui_bar_item_hooks;
gui_bar_item_hooks = bar_item_hook;
}
@@ -1991,14 +2100,14 @@ gui_bar_item_init ()
/* input paste */
gui_bar_item_new (NULL,
gui_bar_item_names[GUI_BAR_ITEM_INPUT_PASTE],
- &gui_bar_item_default_input_paste, NULL);
+ &gui_bar_item_input_paste_cb, NULL, NULL);
gui_bar_item_hook_signal ("input_paste_pending",
gui_bar_item_names[GUI_BAR_ITEM_INPUT_PASTE]);
/* input prompt */
gui_bar_item_new (NULL,
gui_bar_item_names[GUI_BAR_ITEM_INPUT_PROMPT],
- &gui_bar_item_default_input_prompt, NULL);
+ &gui_bar_item_input_prompt_cb, NULL, NULL);
gui_bar_item_hook_signal ("window_switch",
gui_bar_item_names[GUI_BAR_ITEM_INPUT_PROMPT]);
gui_bar_item_hook_signal ("buffer_switch",
@@ -2009,7 +2118,7 @@ gui_bar_item_init ()
/* input search */
gui_bar_item_new (NULL,
gui_bar_item_names[GUI_BAR_ITEM_INPUT_SEARCH],
- &gui_bar_item_default_input_search, NULL);
+ &gui_bar_item_input_search_cb, NULL, NULL);
gui_bar_item_hook_signal ("window_switch",
gui_bar_item_names[GUI_BAR_ITEM_INPUT_SEARCH]);
gui_bar_item_hook_signal ("input_search",
@@ -2020,7 +2129,7 @@ gui_bar_item_init ()
/* input text */
gui_bar_item_new (NULL,
gui_bar_item_names[GUI_BAR_ITEM_INPUT_TEXT],
- &gui_bar_item_default_input_text, NULL);
+ &gui_bar_item_input_text_cb, NULL, NULL);
gui_bar_item_hook_signal ("window_switch",
gui_bar_item_names[GUI_BAR_ITEM_INPUT_TEXT]);
gui_bar_item_hook_signal ("buffer_switch",
@@ -2031,14 +2140,16 @@ gui_bar_item_init ()
/* time */
gui_bar_item_new (NULL,
gui_bar_item_names[GUI_BAR_ITEM_TIME],
- &gui_bar_item_default_time, NULL);
- gui_bar_item_timer = hook_timer (NULL, 1000, 1, 0, &gui_bar_item_timer_cb,
- gui_bar_item_names[GUI_BAR_ITEM_TIME]);
+ &gui_bar_item_time_cb, NULL, NULL);
+ gui_bar_item_timer = hook_timer (NULL, 1000, 1, 0,
+ &gui_bar_item_timer_cb,
+ gui_bar_item_names[GUI_BAR_ITEM_TIME],
+ NULL);
/* buffer count */
gui_bar_item_new (NULL,
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_COUNT],
- &gui_bar_item_default_buffer_count, NULL);
+ &gui_bar_item_buffer_count_cb, NULL, NULL);
gui_bar_item_hook_signal ("buffer_opened",
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_COUNT]);
gui_bar_item_hook_signal ("buffer_closed",
@@ -2047,7 +2158,7 @@ gui_bar_item_init ()
/* last buffer number */
gui_bar_item_new (NULL,
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_LAST_NUMBER],
- &gui_bar_item_default_buffer_last_number, NULL);
+ &gui_bar_item_buffer_last_number_cb, NULL, NULL);
gui_bar_item_hook_signal ("buffer_opened",
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_LAST_NUMBER]);
gui_bar_item_hook_signal ("buffer_closed",
@@ -2062,7 +2173,7 @@ gui_bar_item_init ()
/* buffer plugin */
gui_bar_item_new (NULL,
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_PLUGIN],
- &gui_bar_item_default_buffer_plugin, NULL);
+ &gui_bar_item_buffer_plugin_cb, NULL, NULL);
gui_bar_item_hook_signal ("window_switch",
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_PLUGIN]);
gui_bar_item_hook_signal ("buffer_switch",
@@ -2073,7 +2184,7 @@ gui_bar_item_init ()
/* buffer number */
gui_bar_item_new (NULL,
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NUMBER],
- &gui_bar_item_default_buffer_number, NULL);
+ &gui_bar_item_buffer_number_cb, NULL, NULL);
gui_bar_item_hook_signal ("window_switch",
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NUMBER]);
gui_bar_item_hook_signal ("buffer_switch",
@@ -2090,7 +2201,7 @@ gui_bar_item_init ()
/* buffer name */
gui_bar_item_new (NULL,
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NAME],
- &gui_bar_item_default_buffer_name, NULL);
+ &gui_bar_item_buffer_name_cb, NULL, NULL);
gui_bar_item_hook_signal ("window_switch",
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NAME]);
gui_bar_item_hook_signal ("buffer_switch",
@@ -2103,7 +2214,7 @@ gui_bar_item_init ()
/* buffer short name */
gui_bar_item_new (NULL,
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_SHORT_NAME],
- &gui_bar_item_default_buffer_short_name, NULL);
+ &gui_bar_item_buffer_short_name_cb, NULL, NULL);
gui_bar_item_hook_signal ("window_switch",
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_SHORT_NAME]);
gui_bar_item_hook_signal ("buffer_switch",
@@ -2116,7 +2227,7 @@ gui_bar_item_init ()
/* buffer modes */
gui_bar_item_new (NULL,
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_MODES],
- &gui_bar_item_default_buffer_modes, NULL);
+ &gui_bar_item_buffer_modes_cb, NULL, NULL);
gui_bar_item_hook_signal ("window_switch",
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_MODES]);
gui_bar_item_hook_signal ("buffer_switch",
@@ -2125,7 +2236,7 @@ gui_bar_item_init ()
/* buffer filter */
gui_bar_item_new (NULL,
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_FILTER],
- &gui_bar_item_default_buffer_filter, NULL);
+ &gui_bar_item_buffer_filter_cb, NULL, NULL);
gui_bar_item_hook_signal ("window_switch",
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_FILTER]);
gui_bar_item_hook_signal ("buffer_switch",
@@ -2138,7 +2249,7 @@ gui_bar_item_init ()
/* buffer zoom */
gui_bar_item_new (NULL,
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_ZOOM],
- &gui_bar_item_buffer_zoom, NULL);
+ &gui_bar_item_buffer_zoom_cb, NULL, NULL);
gui_bar_item_hook_signal ("buffer_zoomed",
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_ZOOM]);
gui_bar_item_hook_signal ("buffer_unzoomed",
@@ -2149,7 +2260,7 @@ gui_bar_item_init ()
/* buffer nicklist count */
gui_bar_item_new (NULL,
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NICKLIST_COUNT],
- &gui_bar_item_default_buffer_nicklist_count, NULL);
+ &gui_bar_item_buffer_nicklist_count_cb, NULL, NULL);
gui_bar_item_hook_signal ("window_switch",
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NICKLIST_COUNT]);
gui_bar_item_hook_signal ("buffer_switch",
@@ -2160,7 +2271,7 @@ gui_bar_item_init ()
/* scroll indicator */
gui_bar_item_new (NULL,
gui_bar_item_names[GUI_BAR_ITEM_SCROLL],
- &gui_bar_item_default_scroll, NULL);
+ &gui_bar_item_scroll_cb, NULL, NULL);
gui_bar_item_hook_signal ("window_switch",
gui_bar_item_names[GUI_BAR_ITEM_SCROLL]);
gui_bar_item_hook_signal ("buffer_switch",
@@ -2171,7 +2282,7 @@ gui_bar_item_init ()
/* hotlist */
gui_bar_item_new (NULL,
gui_bar_item_names[GUI_BAR_ITEM_HOTLIST],
- &gui_bar_item_default_hotlist, NULL);
+ &gui_bar_item_hotlist_cb, NULL, NULL);
gui_bar_item_hook_signal ("hotlist_changed",
gui_bar_item_names[GUI_BAR_ITEM_HOTLIST]);
gui_bar_item_hook_signal ("buffer_moved",
@@ -2182,14 +2293,14 @@ gui_bar_item_init ()
/* completion (possible words when a partial completion occurs) */
gui_bar_item_new (NULL,
gui_bar_item_names[GUI_BAR_ITEM_COMPLETION],
- &gui_bar_item_default_completion, NULL);
+ &gui_bar_item_completion_cb, NULL, NULL);
gui_bar_item_hook_signal ("partial_completion",
gui_bar_item_names[GUI_BAR_ITEM_COMPLETION]);
/* buffer title */
gui_bar_item_new (NULL,
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_TITLE],
- &gui_bar_item_default_buffer_title, NULL);
+ &gui_bar_item_buffer_title_cb, NULL, NULL);
gui_bar_item_hook_signal ("window_switch",
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_TITLE]);
gui_bar_item_hook_signal ("buffer_switch",
@@ -2200,7 +2311,7 @@ gui_bar_item_init ()
/* buffer nicklist */
gui_bar_item_new (NULL,
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NICKLIST],
- &gui_bar_item_default_buffer_nicklist, NULL);
+ &gui_bar_item_buffer_nicklist_cb, NULL, NULL);
gui_bar_item_hook_signal ("nicklist_*",
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NICKLIST]);
gui_bar_item_hook_signal ("window_switch",
@@ -2209,12 +2320,13 @@ gui_bar_item_init ()
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NICKLIST]);
snprintf (name, sizeof (name), "2000|%s",
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NICKLIST]);
- hook_focus (NULL, name, &gui_bar_item_focus_buffer_nicklist, NULL);
+ hook_focus (NULL, name,
+ &gui_bar_item_focus_buffer_nicklist_cb, NULL, NULL);
/* window number */
gui_bar_item_new (NULL,
gui_bar_item_names[GUI_BAR_ITEM_WINDOW_NUMBER],
- &gui_bar_item_default_window_number, NULL);
+ &gui_bar_item_window_number_cb, NULL, NULL);
gui_bar_item_hook_signal ("window_switch",
gui_bar_item_names[GUI_BAR_ITEM_WINDOW_NUMBER]);
gui_bar_item_hook_signal ("window_closed",
@@ -2223,11 +2335,18 @@ gui_bar_item_init ()
/* mouse status */
gui_bar_item_new (NULL,
gui_bar_item_names[GUI_BAR_ITEM_MOUSE_STATUS],
- &gui_bar_item_default_mouse_status, NULL);
+ &gui_bar_item_mouse_status_cb, NULL, NULL);
gui_bar_item_hook_signal ("mouse_enabled",
gui_bar_item_names[GUI_BAR_ITEM_MOUSE_STATUS]);
gui_bar_item_hook_signal ("mouse_disabled",
gui_bar_item_names[GUI_BAR_ITEM_MOUSE_STATUS]);
+
+ /* away message */
+ gui_bar_item_new (NULL,
+ gui_bar_item_names[GUI_BAR_ITEM_AWAY],
+ &gui_bar_item_away_cb, NULL, NULL);
+ gui_bar_item_hook_signal ("buffer_localvar_*",
+ gui_bar_item_names[GUI_BAR_ITEM_AWAY]);
}
/*
@@ -2259,11 +2378,13 @@ gui_bar_item_end ()
*/
struct t_hdata *
-gui_bar_item_hdata_bar_item_cb (void *data, const char *hdata_name)
+gui_bar_item_hdata_bar_item_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_item", "next_item",
@@ -2273,6 +2394,7 @@ gui_bar_item_hdata_bar_item_cb (void *data, const char *hdata_name)
HDATA_VAR(struct t_gui_bar_item, plugin, POINTER, 0, NULL, "plugin");
HDATA_VAR(struct t_gui_bar_item, name, STRING, 0, NULL, NULL);
HDATA_VAR(struct t_gui_bar_item, build_callback, POINTER, 0, NULL, NULL);
+ HDATA_VAR(struct t_gui_bar_item, build_callback_pointer, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_bar_item, build_callback_data, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_bar_item, prev_item, POINTER, 0, NULL, hdata_name);
HDATA_VAR(struct t_gui_bar_item, next_item, POINTER, 0, NULL, hdata_name);
@@ -2309,6 +2431,8 @@ gui_bar_item_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!infolist_new_var_pointer (ptr_item, "build_callback", bar_item->build_callback))
return 0;
+ if (!infolist_new_var_pointer (ptr_item, "build_callback_pointer", (void *)bar_item->build_callback_pointer))
+ return 0;
if (!infolist_new_var_pointer (ptr_item, "build_callback_data", bar_item->build_callback_data))
return 0;
@@ -2332,6 +2456,7 @@ gui_bar_item_print_log ()
ptr_item->plugin, plugin_get_name (ptr_item->plugin));
log_printf (" name . . . . . . . . . : '%s'", ptr_item->name);
log_printf (" build_callback . . . . : 0x%lx", ptr_item->build_callback);
+ log_printf (" build_callback_pointer : 0x%lx", ptr_item->build_callback_pointer);
log_printf (" build_callback_data. . : 0x%lx", ptr_item->build_callback_data);
log_printf (" prev_item. . . . . . . : 0x%lx", ptr_item->prev_item);
log_printf (" next_item. . . . . . . : 0x%lx", ptr_item->next_item);
diff --git a/src/gui/gui-bar-item.h b/src/gui/gui-bar-item.h
index b70bd7934..21bfc2ca7 100644
--- a/src/gui/gui-bar-item.h
+++ b/src/gui/gui-bar-item.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -44,6 +44,7 @@ enum t_gui_bar_item_weechat
GUI_BAR_ITEM_BUFFER_NICKLIST,
GUI_BAR_ITEM_WINDOW_NUMBER,
GUI_BAR_ITEM_MOUSE_STATUS,
+ GUI_BAR_ITEM_AWAY,
/* number of bar items */
GUI_BAR_NUM_ITEMS,
};
@@ -54,13 +55,15 @@ struct t_gui_bar_item
{
struct t_weechat_plugin *plugin; /* plugin */
char *name; /* bar item name */
- char *(*build_callback)(void *data,
+ char *(*build_callback)(const void *pointer,
+ void *data,
struct t_gui_bar_item *item,
struct t_gui_window *window,
struct t_gui_buffer *buffer,
struct t_hashtable *extra_info);
/* callback called for building item */
- void *build_callback_data; /* data for callback */
+ const void *build_callback_pointer; /* pointer for callback */
+ void *build_callback_data; /* data for callback */
struct t_gui_bar_item *prev_item; /* link to previous bar item */
struct t_gui_bar_item *next_item; /* link to next bar item */
};
@@ -97,11 +100,13 @@ extern char *gui_bar_item_get_value (struct t_gui_bar *bar,
extern int gui_bar_item_count_lines (char *string);
extern struct t_gui_bar_item *gui_bar_item_new (struct t_weechat_plugin *plugin,
const char *name,
- char *(*build_callback)(void *data,
+ char *(*build_callback)(const void *pointer,
+ void *data,
struct t_gui_bar_item *item,
struct t_gui_window *window,
struct t_gui_buffer *buffer,
struct t_hashtable *extra_info),
+ const void *build_callback_pointer,
void *build_callback_data);
extern void gui_bar_item_update (const char *name);
extern void gui_bar_item_free (struct t_gui_bar_item *item);
@@ -109,7 +114,8 @@ extern void gui_bar_item_free_all ();
extern void gui_bar_item_free_all_plugin (struct t_weechat_plugin *plugin);
extern void gui_bar_item_init ();
extern void gui_bar_item_end ();
-extern struct t_hdata *gui_bar_item_hdata_bar_item_cb (void *data,
+extern struct t_hdata *gui_bar_item_hdata_bar_item_cb (const void *pointer,
+ void *data,
const char *hdata_name);
extern int gui_bar_item_add_to_infolist (struct t_infolist *infolist,
struct t_gui_bar_item *bar_item);
diff --git a/src/gui/gui-bar-window.c b/src/gui/gui-bar-window.c
index ad09d563d..e630565d1 100644
--- a/src/gui/gui-bar-window.c
+++ b/src/gui/gui-bar-window.c
@@ -1,7 +1,7 @@
/*
* gui-bar-window.c - bar window functions (used by all GUI)
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -1524,11 +1524,13 @@ gui_bar_window_scroll (struct t_gui_bar_window *bar_window,
*/
struct t_hdata *
-gui_bar_window_hdata_bar_window_cb (void *data, const char *hdata_name)
+gui_bar_window_hdata_bar_window_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_bar_window", "next_bar_window",
diff --git a/src/gui/gui-bar-window.h b/src/gui/gui-bar-window.h
index 485c9c219..1e625ee40 100644
--- a/src/gui/gui-bar-window.h
+++ b/src/gui/gui-bar-window.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -104,7 +104,8 @@ extern void gui_bar_window_scroll (struct t_gui_bar_window *bar_window,
int add_x, int scroll_beginning,
int scroll_end, int add, int percent,
int value);
-extern struct t_hdata *gui_bar_window_hdata_bar_window_cb (void *data,
+extern struct t_hdata *gui_bar_window_hdata_bar_window_cb (const void *pointer,
+ void *data,
const char *hdata_name);
extern int gui_bar_window_add_to_infolist (struct t_infolist *infolist,
struct t_gui_bar_window *bar_window);
diff --git a/src/gui/gui-bar.c b/src/gui/gui-bar.c
index f71bc8147..d656be48c 100644
--- a/src/gui/gui-bar.c
+++ b/src/gui/gui-bar.c
@@ -1,7 +1,7 @@
/*
* gui-bar.c - bar functions (used by all GUI)
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -410,8 +410,7 @@ gui_bar_check_conditions (struct t_gui_bar *bar,
pointers = hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_POINTER,
- NULL,
- NULL);
+ NULL, NULL);
if (pointers)
{
hashtable_set (pointers, "window", window);
@@ -421,8 +420,7 @@ gui_bar_check_conditions (struct t_gui_bar *bar,
extra_vars = hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_POINTER,
- NULL,
- NULL);
+ NULL, NULL);
if (extra_vars)
{
hashtable_set (extra_vars, "active",
@@ -435,8 +433,7 @@ gui_bar_check_conditions (struct t_gui_bar *bar,
options = hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_POINTER,
- NULL,
- NULL);
+ NULL, NULL);
if (options)
hashtable_set (options, "type", "condition");
@@ -827,10 +824,12 @@ gui_bar_set_items_array (struct t_gui_bar *bar, const char *items)
*/
int
-gui_bar_config_check_type (void *data, struct t_config_option *option,
+gui_bar_config_check_type (const void *pointer, void *data,
+ struct t_config_option *option,
const char *value)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
(void) value;
@@ -847,7 +846,8 @@ gui_bar_config_check_type (void *data, struct t_config_option *option,
*/
void
-gui_bar_config_change_hidden (void *data, struct t_config_option *option)
+gui_bar_config_change_hidden (const void *pointer, void *data,
+ struct t_config_option *option)
{
struct t_gui_bar *ptr_bar;
struct t_gui_window *ptr_win;
@@ -855,6 +855,7 @@ gui_bar_config_change_hidden (void *data, struct t_config_option *option)
int bar_window_exists;
/* make C compiler happy */
+ (void) pointer;
(void) data;
ptr_bar = gui_bar_search_with_option_name (option->name);
@@ -909,13 +910,15 @@ gui_bar_config_change_hidden (void *data, struct t_config_option *option)
*/
void
-gui_bar_config_change_priority (void *data, struct t_config_option *option)
+gui_bar_config_change_priority (const void *pointer, void *data,
+ struct t_config_option *option)
{
struct t_gui_bar *ptr_bar;
struct t_gui_window *ptr_win;
struct t_gui_bar_window *bar_windows, *ptr_bar_win, *next_bar_win;
/* make C compiler happy */
+ (void) pointer;
(void) data;
ptr_bar = gui_bar_search_with_option_name (option->name);
@@ -964,9 +967,11 @@ gui_bar_config_change_priority (void *data, struct t_config_option *option)
*/
void
-gui_bar_config_change_conditions (void *data, struct t_config_option *option)
+gui_bar_config_change_conditions (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -978,11 +983,13 @@ gui_bar_config_change_conditions (void *data, struct t_config_option *option)
*/
void
-gui_bar_config_change_position (void *data, struct t_config_option *option)
+gui_bar_config_change_position (const void *pointer, void *data,
+ struct t_config_option *option)
{
struct t_gui_bar *ptr_bar;
/* make C compiler happy */
+ (void) pointer;
(void) data;
ptr_bar = gui_bar_search_with_option_name (option->name);
@@ -997,11 +1004,13 @@ gui_bar_config_change_position (void *data, struct t_config_option *option)
*/
void
-gui_bar_config_change_filling (void *data, struct t_config_option *option)
+gui_bar_config_change_filling (const void *pointer, void *data,
+ struct t_config_option *option)
{
struct t_gui_bar *ptr_bar;
/* make C compiler happy */
+ (void) pointer;
(void) data;
ptr_bar = gui_bar_search_with_option_name (option->name);
@@ -1020,7 +1029,8 @@ gui_bar_config_change_filling (void *data, struct t_config_option *option)
*/
int
-gui_bar_config_check_size (void *data, struct t_config_option *option,
+gui_bar_config_check_size (const void *pointer, void *data,
+ struct t_config_option *option,
const char *value)
{
struct t_gui_bar *ptr_bar;
@@ -1029,6 +1039,7 @@ gui_bar_config_check_size (void *data, struct t_config_option *option,
int new_value;
/* make C compiler happy */
+ (void) pointer;
(void) data;
ptr_bar = gui_bar_search_with_option_name (option->name);
@@ -1086,11 +1097,13 @@ gui_bar_config_check_size (void *data, struct t_config_option *option,
*/
void
-gui_bar_config_change_size (void *data, struct t_config_option *option)
+gui_bar_config_change_size (const void *pointer, void *data,
+ struct t_config_option *option)
{
struct t_gui_bar *ptr_bar;
/* make C compiler happy */
+ (void) pointer;
(void) data;
ptr_bar = gui_bar_search_with_option_name (option->name);
@@ -1106,12 +1119,14 @@ gui_bar_config_change_size (void *data, struct t_config_option *option)
*/
void
-gui_bar_config_change_size_max (void *data, struct t_config_option *option)
+gui_bar_config_change_size_max (const void *pointer, void *data,
+ struct t_config_option *option)
{
struct t_gui_bar *ptr_bar;
char value[32];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -1135,11 +1150,13 @@ gui_bar_config_change_size_max (void *data, struct t_config_option *option)
*/
void
-gui_bar_config_change_color (void *data, struct t_config_option *option)
+gui_bar_config_change_color (const void *pointer, void *data,
+ struct t_config_option *option)
{
struct t_gui_bar *ptr_bar;
/* make C compiler happy */
+ (void) pointer;
(void) data;
ptr_bar = gui_bar_search_with_option_name (option->name);
@@ -1152,11 +1169,13 @@ gui_bar_config_change_color (void *data, struct t_config_option *option)
*/
void
-gui_bar_config_change_separator (void *data, struct t_config_option *option)
+gui_bar_config_change_separator (const void *pointer, void *data,
+ struct t_config_option *option)
{
struct t_gui_bar *ptr_bar;
/* make C compiler happy */
+ (void) pointer;
(void) data;
ptr_bar = gui_bar_search_with_option_name (option->name);
@@ -1169,11 +1188,13 @@ gui_bar_config_change_separator (void *data, struct t_config_option *option)
*/
void
-gui_bar_config_change_items (void *data, struct t_config_option *option)
+gui_bar_config_change_items (const void *pointer, void *data,
+ struct t_config_option *option)
{
struct t_gui_bar *ptr_bar;
/* make C compiler happy */
+ (void) pointer;
(void) data;
ptr_bar = gui_bar_search_with_option_name (option->name);
@@ -1390,7 +1411,9 @@ gui_bar_create_option (const char *bar_name, int index_option, const char *value
option_name, "boolean",
N_("true if bar is hidden, false if it is displayed"),
NULL, 0, 0, value, NULL, 0,
- NULL, NULL, &gui_bar_config_change_hidden, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &gui_bar_config_change_hidden, NULL, NULL,
+ NULL, NULL, NULL);
break;
case GUI_BAR_OPTION_PRIORITY:
ptr_option = config_file_new_option (
@@ -1398,7 +1421,9 @@ gui_bar_create_option (const char *bar_name, int index_option, const char *value
option_name, "integer",
N_("bar priority (high number means bar displayed first)"),
NULL, 0, INT_MAX, value, NULL, 0,
- NULL, NULL, &gui_bar_config_change_priority, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &gui_bar_config_change_priority, NULL, NULL,
+ NULL, NULL, NULL);
break;
case GUI_BAR_OPTION_TYPE:
ptr_option = config_file_new_option (
@@ -1406,7 +1431,9 @@ gui_bar_create_option (const char *bar_name, int index_option, const char *value
option_name, "integer",
N_("bar type (root, window, window_active, window_inactive)"),
"root|window|window_active|window_inactive", 0, 0, value, NULL, 0,
- &gui_bar_config_check_type, NULL, NULL, NULL, NULL, NULL);
+ &gui_bar_config_check_type, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
break;
case GUI_BAR_OPTION_CONDITIONS:
ptr_option = config_file_new_option (
@@ -1416,11 +1443,13 @@ gui_bar_create_option (const char *bar_name, int index_option, const char *value
"\"active\", \"inactive\", \"nicklist\" (window must be "
"active/inactive, buffer must have a nicklist), or an "
"expression with condition(s) (see /help eval), "
- "like: \"${nicklist} && ${window.win_width} > 100\" "
+ "like: \"${nicklist} && ${info:term_width} > 100\" "
"(local variables for expression are ${active}, "
"${inactive} and ${nicklist})"),
NULL, 0, 0, value, NULL, 0,
- NULL, NULL, &gui_bar_config_change_conditions, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &gui_bar_config_change_conditions, NULL, NULL,
+ NULL, NULL, NULL);
break;
case GUI_BAR_OPTION_POSITION:
ptr_option = config_file_new_option (
@@ -1428,7 +1457,9 @@ gui_bar_create_option (const char *bar_name, int index_option, const char *value
option_name, "integer",
N_("bar position (bottom, top, left, right)"),
"bottom|top|left|right", 0, 0, value, NULL, 0,
- NULL, NULL, &gui_bar_config_change_position, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &gui_bar_config_change_position, NULL, NULL,
+ NULL, NULL, NULL);
break;
case GUI_BAR_OPTION_FILLING_TOP_BOTTOM:
ptr_option = config_file_new_option (
@@ -1439,7 +1470,9 @@ gui_bar_create_option (const char *bar_name, int index_option, const char *value
"top or bottom"),
"horizontal|vertical|columns_horizontal|columns_vertical",
0, 0, value, NULL, 0,
- NULL, NULL, &gui_bar_config_change_filling, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &gui_bar_config_change_filling, NULL, NULL,
+ NULL, NULL, NULL);
break;
case GUI_BAR_OPTION_FILLING_LEFT_RIGHT:
ptr_option = config_file_new_option (
@@ -1450,7 +1483,9 @@ gui_bar_create_option (const char *bar_name, int index_option, const char *value
"left or right"),
"horizontal|vertical|columns_horizontal|columns_vertical",
0, 0, value, NULL, 0,
- NULL, NULL, &gui_bar_config_change_filling, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &gui_bar_config_change_filling, NULL, NULL,
+ NULL, NULL, NULL);
break;
case GUI_BAR_OPTION_SIZE:
ptr_option = config_file_new_option (
@@ -1458,9 +1493,9 @@ gui_bar_create_option (const char *bar_name, int index_option, const char *value
option_name, "integer",
N_("bar size in chars (0 = auto size)"),
NULL, 0, INT_MAX, value, NULL, 0,
- &gui_bar_config_check_size, NULL,
- &gui_bar_config_change_size, NULL,
- NULL, NULL);
+ &gui_bar_config_check_size, NULL, NULL,
+ &gui_bar_config_change_size, NULL, NULL,
+ NULL, NULL, NULL);
break;
case GUI_BAR_OPTION_SIZE_MAX:
ptr_option = config_file_new_option (
@@ -1468,9 +1503,9 @@ gui_bar_create_option (const char *bar_name, int index_option, const char *value
option_name, "integer",
N_("max bar size in chars (0 = no limit)"),
NULL, 0, INT_MAX, value, NULL, 0,
- NULL, NULL,
- &gui_bar_config_change_size_max, NULL,
- NULL, NULL);
+ NULL, NULL, NULL,
+ &gui_bar_config_change_size_max, NULL, NULL,
+ NULL, NULL, NULL);
break;
case GUI_BAR_OPTION_COLOR_FG:
ptr_option = config_file_new_option (
@@ -1478,9 +1513,9 @@ gui_bar_create_option (const char *bar_name, int index_option, const char *value
option_name, "color",
N_("default text color for bar"),
NULL, 0, 0, value, NULL, 0,
- NULL, NULL,
- &gui_bar_config_change_color, NULL,
- NULL, NULL);
+ NULL, NULL, NULL,
+ &gui_bar_config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
break;
case GUI_BAR_OPTION_COLOR_DELIM:
ptr_option = config_file_new_option (
@@ -1488,9 +1523,9 @@ gui_bar_create_option (const char *bar_name, int index_option, const char *value
option_name, "color",
N_("default delimiter color for bar"),
NULL, 0, 0, value, NULL, 0,
- NULL, NULL,
- &gui_bar_config_change_color, NULL,
- NULL, NULL);
+ NULL, NULL, NULL,
+ &gui_bar_config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
break;
case GUI_BAR_OPTION_COLOR_BG:
ptr_option = config_file_new_option (
@@ -1498,9 +1533,9 @@ gui_bar_create_option (const char *bar_name, int index_option, const char *value
option_name, "color",
N_("default background color for bar"),
NULL, 0, 0, value, NULL, 0,
- NULL, NULL,
- &gui_bar_config_change_color, NULL,
- NULL, NULL);
+ NULL, NULL, NULL,
+ &gui_bar_config_change_color, NULL, NULL,
+ NULL, NULL, NULL);
break;
case GUI_BAR_OPTION_SEPARATOR:
ptr_option = config_file_new_option (
@@ -1508,7 +1543,9 @@ gui_bar_create_option (const char *bar_name, int index_option, const char *value
option_name, "boolean",
N_("separator line between bar and other bars/windows"),
NULL, 0, 0, value, NULL, 0,
- NULL, NULL, &gui_bar_config_change_separator, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &gui_bar_config_change_separator, NULL, NULL,
+ NULL, NULL, NULL);
break;
case GUI_BAR_OPTION_ITEMS:
ptr_option = config_file_new_option (
@@ -1519,7 +1556,9 @@ gui_bar_create_option (const char *bar_name, int index_option, const char *value
"\"@buffer:item\" can be used to force buffer used when "
"displaying the bar item"),
NULL, 0, 0, gui_bar_default_items (bar_name), value, 0,
- NULL, NULL, &gui_bar_config_change_items, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &gui_bar_config_change_items, NULL, NULL,
+ NULL, NULL, NULL);
break;
case GUI_BAR_NUM_OPTIONS:
break;
@@ -2263,11 +2302,12 @@ gui_bar_free_bar_windows (struct t_gui_bar *bar)
*/
struct t_hdata *
-gui_bar_hdata_bar_cb (void *data, const char *hdata_name)
+gui_bar_hdata_bar_cb (const void *pointer, void *data, const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_bar", "next_bar",
diff --git a/src/gui/gui-bar.h b/src/gui/gui-bar.h
index bde879822..6a2af0fa3 100644
--- a/src/gui/gui-bar.h
+++ b/src/gui/gui-bar.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -153,7 +153,8 @@ extern int gui_bar_scroll (struct t_gui_bar *bar, struct t_gui_window *window,
const char *scroll);
extern void gui_bar_free (struct t_gui_bar *bar);
extern void gui_bar_free_all ();
-extern struct t_hdata *gui_bar_hdata_bar_cb (void *data,
+extern struct t_hdata *gui_bar_hdata_bar_cb (const void *pointer,
+ void *data,
const char *hdata_name);
extern int gui_bar_add_to_infolist (struct t_infolist *infolist,
struct t_gui_bar *bar);
diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c
index 3ff61f171..d85f06aff 100644
--- a/src/gui/gui-buffer.c
+++ b/src/gui/gui-buffer.c
@@ -1,7 +1,7 @@
/*
* gui-buffer.c - buffer functions (used by all GUI)
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -121,6 +121,9 @@ char *gui_buffer_properties_set[] =
const char *
gui_buffer_get_plugin_name (struct t_gui_buffer *buffer)
{
+ if (!buffer)
+ return NULL;
+
if (buffer->plugin_name_for_upgrade)
return buffer->plugin_name_for_upgrade;
@@ -136,6 +139,9 @@ gui_buffer_get_plugin_name (struct t_gui_buffer *buffer)
const char *
gui_buffer_get_short_name (struct t_gui_buffer *buffer)
{
+ if (!buffer)
+ return NULL;
+
return (buffer->short_name) ? buffer->short_name : buffer->name;
}
@@ -149,6 +155,9 @@ gui_buffer_build_full_name (struct t_gui_buffer *buffer)
{
int length;
+ if (!buffer)
+ return;
+
if (buffer->full_name)
free (buffer->full_name);
length = strlen (gui_buffer_get_plugin_name (buffer)) + 1 +
@@ -231,6 +240,9 @@ gui_buffer_notify_get (struct t_gui_buffer *buffer)
int length;
struct t_config_option *ptr_option;
+ if (!buffer)
+ return CONFIG_INTEGER(config_look_buffer_notify_default);
+
length = strlen (buffer->full_name) + 1;
option_name = malloc (length);
if (option_name)
@@ -279,6 +291,9 @@ gui_buffer_notify_set (struct t_gui_buffer *buffer)
{
int old_notify, new_notify;
+ if (!buffer)
+ return;
+
old_notify = buffer->notify;
new_notify = gui_buffer_notify_get (buffer);
@@ -328,6 +343,9 @@ gui_buffer_find_pos (struct t_gui_buffer *buffer)
{
struct t_gui_buffer *ptr_buffer;
+ if (!buffer)
+ return NULL;
+
/* if no number is asked by layout, position is undefined */
if (buffer->layout_number < 1)
return NULL;
@@ -519,7 +537,8 @@ gui_buffer_input_buffer_init (struct t_gui_buffer *buffer)
{
buffer->input_buffer_alloc = GUI_BUFFER_INPUT_BLOCK_SIZE;
buffer->input_buffer = malloc (GUI_BUFFER_INPUT_BLOCK_SIZE);
- buffer->input_buffer[0] = '\0';
+ if (buffer->input_buffer)
+ buffer->input_buffer[0] = '\0';
buffer->input_buffer_size = 0;
buffer->input_buffer_length = 0;
buffer->input_buffer_pos = 0;
@@ -535,12 +554,16 @@ gui_buffer_input_buffer_init (struct t_gui_buffer *buffer)
struct t_gui_buffer *
gui_buffer_new (struct t_weechat_plugin *plugin,
const char *name,
- int (*input_callback)(void *data,
+ int (*input_callback)(const void *pointer,
+ void *data,
struct t_gui_buffer *buffer,
const char *input_data),
+ const void *input_callback_pointer,
void *input_callback_data,
- int (*close_callback)(void *data,
+ int (*close_callback)(const void *pointer,
+ void *data,
struct t_gui_buffer *buffer),
+ const void *close_callback_pointer,
void *close_callback_data)
{
struct t_gui_buffer *new_buffer;
@@ -602,6 +625,7 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
/* close callback */
new_buffer->close_callback = close_callback;
+ new_buffer->close_callback_pointer = close_callback_pointer;
new_buffer->close_callback_data = close_callback_data;
new_buffer->closing = 0;
@@ -626,12 +650,14 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
new_buffer->nicklist_nicks_count = 0;
new_buffer->nicklist_visible_count = 0;
new_buffer->nickcmp_callback = NULL;
+ new_buffer->nickcmp_callback_pointer = NULL;
new_buffer->nickcmp_callback_data = NULL;
gui_nicklist_add_group (new_buffer, NULL, "root", NULL, 0);
/* input */
new_buffer->input = 1;
new_buffer->input_callback = input_callback;
+ new_buffer->input_callback_pointer = input_callback_pointer;
new_buffer->input_callback_data = input_callback_data;
new_buffer->input_get_unknown_commands = 0;
gui_buffer_input_buffer_init (new_buffer);
@@ -682,11 +708,11 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
new_buffer->highlight_tags_array = NULL;
/* hotlist */
- new_buffer->hotlist_max_level_nicks = hashtable_new (32,
- WEECHAT_HASHTABLE_STRING,
- WEECHAT_HASHTABLE_INTEGER,
- NULL,
- NULL);
+ new_buffer->hotlist_max_level_nicks = hashtable_new (
+ 32,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_INTEGER,
+ NULL, NULL);
/* keys */
new_buffer->keys = NULL;
@@ -697,8 +723,7 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
new_buffer->local_variables = hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
hashtable_set (new_buffer->local_variables,
"plugin", plugin_get_name (plugin));
hashtable_set (new_buffer->local_variables, "name", name);
@@ -770,7 +795,7 @@ gui_buffer_string_replace_local_var (struct t_gui_buffer *buffer,
char *result, *result2, *local_var;
const char *pos_end_name, *ptr_value;
- if (!string)
+ if (!buffer || !string)
return NULL;
length = strlen (string) + 1;
@@ -854,6 +879,9 @@ gui_buffer_match_list_split (struct t_gui_buffer *buffer,
int i, match;
char *ptr_name;
+ if (!buffer)
+ return 0;
+
match = 0;
for (i = 0; i < num_buffers; i++)
@@ -893,7 +921,7 @@ gui_buffer_match_list (struct t_gui_buffer *buffer, const char *string)
char **buffers;
int num_buffers, match;
- if (!string || !string[0])
+ if (!buffer || !string || !string[0])
return 0;
match = 0;
@@ -966,85 +994,85 @@ gui_buffer_property_in_list (char *properties[], char *property)
int
gui_buffer_get_integer (struct t_gui_buffer *buffer, const char *property)
{
- if (buffer && property)
- {
- if (string_strcasecmp (property, "number") == 0)
- return buffer->number;
- else if (string_strcasecmp (property, "layout_number") == 0)
- return buffer->layout_number;
- else if (string_strcasecmp (property, "layout_number_merge_order") == 0)
- return buffer->layout_number_merge_order;
- else if (string_strcasecmp (property, "short_name_is_set") == 0)
- return (buffer->short_name) ? 1 : 0;
- else if (string_strcasecmp (property, "type") == 0)
- return buffer->type;
- else if (string_strcasecmp (property, "notify") == 0)
- return buffer->notify;
- else if (string_strcasecmp (property, "num_displayed") == 0)
- return buffer->num_displayed;
- else if (string_strcasecmp (property, "active") == 0)
- return buffer->active;
- else if (string_strcasecmp (property, "hidden") == 0)
- return buffer->hidden;
- else if (string_strcasecmp (property, "zoomed") == 0)
- return buffer->zoomed;
- else if (string_strcasecmp (property, "print_hooks_enabled") == 0)
- return buffer->print_hooks_enabled;
- else if (string_strcasecmp (property, "day_change") == 0)
- return buffer->day_change;
- else if (string_strcasecmp (property, "clear") == 0)
- return buffer->clear;
- else if (string_strcasecmp (property, "filter") == 0)
- return buffer->filter;
- else if (string_strcasecmp (property, "closing") == 0)
- return buffer->closing;
- else if (string_strcasecmp (property, "lines_hidden") == 0)
- return buffer->lines->lines_hidden;
- else if (string_strcasecmp (property, "prefix_max_length") == 0)
- return buffer->lines->prefix_max_length;
- else if (string_strcasecmp (property, "time_for_each_line") == 0)
- return buffer->time_for_each_line;
- else if (string_strcasecmp (property, "nicklist") == 0)
- return buffer->nicklist;
- else if (string_strcasecmp (property, "nicklist_case_sensitive") == 0)
- return buffer->nicklist_case_sensitive;
- else if (string_strcasecmp (property, "nicklist_max_length") == 0)
- return buffer->nicklist_max_length;
- else if (string_strcasecmp (property, "nicklist_display_groups") == 0)
- return buffer->nicklist_display_groups;
- else if (string_strcasecmp (property, "nicklist_count") == 0)
- return buffer->nicklist_count;
- else if (string_strcasecmp (property, "nicklist_groups_count") == 0)
- return buffer->nicklist_groups_count;
- else if (string_strcasecmp (property, "nicklist_nicks_count") == 0)
- return buffer->nicklist_nicks_count;
- else if (string_strcasecmp (property, "nicklist_visible_count") == 0)
- return buffer->nicklist_visible_count;
- else if (string_strcasecmp (property, "input") == 0)
- return buffer->input;
- else if (string_strcasecmp (property, "input_get_unknown_commands") == 0)
- return buffer->input_get_unknown_commands;
- else if (string_strcasecmp (property, "input_size") == 0)
- return buffer->input_buffer_size;
- else if (string_strcasecmp (property, "input_length") == 0)
- return buffer->input_buffer_length;
- else if (string_strcasecmp (property, "input_pos") == 0)
- return buffer->input_buffer_pos;
- else if (string_strcasecmp (property, "input_1st_display") == 0)
- return buffer->input_buffer_1st_display;
- else if (string_strcasecmp (property, "num_history") == 0)
- return buffer->num_history;
- else if (string_strcasecmp (property, "text_search") == 0)
- return buffer->text_search;
- else if (string_strcasecmp (property, "text_search_exact") == 0)
- return buffer->text_search_exact;
- else if (string_strcasecmp (property, "text_search_regex") == 0)
- return buffer->text_search_regex;
- else if (string_strcasecmp (property, "text_search_where") == 0)
- return buffer->text_search_where;
- else if (string_strcasecmp (property, "text_search_found") == 0)
- return buffer->text_search_found;
- }
+ if (!buffer || !property)
+ return 0;
+
+ if (string_strcasecmp (property, "number") == 0)
+ return buffer->number;
+ else if (string_strcasecmp (property, "layout_number") == 0)
+ return buffer->layout_number;
+ else if (string_strcasecmp (property, "layout_number_merge_order") == 0)
+ return buffer->layout_number_merge_order;
+ else if (string_strcasecmp (property, "short_name_is_set") == 0)
+ return (buffer->short_name) ? 1 : 0;
+ else if (string_strcasecmp (property, "type") == 0)
+ return buffer->type;
+ else if (string_strcasecmp (property, "notify") == 0)
+ return buffer->notify;
+ else if (string_strcasecmp (property, "num_displayed") == 0)
+ return buffer->num_displayed;
+ else if (string_strcasecmp (property, "active") == 0)
+ return buffer->active;
+ else if (string_strcasecmp (property, "hidden") == 0)
+ return buffer->hidden;
+ else if (string_strcasecmp (property, "zoomed") == 0)
+ return buffer->zoomed;
+ else if (string_strcasecmp (property, "print_hooks_enabled") == 0)
+ return buffer->print_hooks_enabled;
+ else if (string_strcasecmp (property, "day_change") == 0)
+ return buffer->day_change;
+ else if (string_strcasecmp (property, "clear") == 0)
+ return buffer->clear;
+ else if (string_strcasecmp (property, "filter") == 0)
+ return buffer->filter;
+ else if (string_strcasecmp (property, "closing") == 0)
+ return buffer->closing;
+ else if (string_strcasecmp (property, "lines_hidden") == 0)
+ return buffer->lines->lines_hidden;
+ else if (string_strcasecmp (property, "prefix_max_length") == 0)
+ return buffer->lines->prefix_max_length;
+ else if (string_strcasecmp (property, "time_for_each_line") == 0)
+ return buffer->time_for_each_line;
+ else if (string_strcasecmp (property, "nicklist") == 0)
+ return buffer->nicklist;
+ else if (string_strcasecmp (property, "nicklist_case_sensitive") == 0)
+ return buffer->nicklist_case_sensitive;
+ else if (string_strcasecmp (property, "nicklist_max_length") == 0)
+ return buffer->nicklist_max_length;
+ else if (string_strcasecmp (property, "nicklist_display_groups") == 0)
+ return buffer->nicklist_display_groups;
+ else if (string_strcasecmp (property, "nicklist_count") == 0)
+ return buffer->nicklist_count;
+ else if (string_strcasecmp (property, "nicklist_groups_count") == 0)
+ return buffer->nicklist_groups_count;
+ else if (string_strcasecmp (property, "nicklist_nicks_count") == 0)
+ return buffer->nicklist_nicks_count;
+ else if (string_strcasecmp (property, "nicklist_visible_count") == 0)
+ return buffer->nicklist_visible_count;
+ else if (string_strcasecmp (property, "input") == 0)
+ return buffer->input;
+ else if (string_strcasecmp (property, "input_get_unknown_commands") == 0)
+ return buffer->input_get_unknown_commands;
+ else if (string_strcasecmp (property, "input_size") == 0)
+ return buffer->input_buffer_size;
+ else if (string_strcasecmp (property, "input_length") == 0)
+ return buffer->input_buffer_length;
+ else if (string_strcasecmp (property, "input_pos") == 0)
+ return buffer->input_buffer_pos;
+ else if (string_strcasecmp (property, "input_1st_display") == 0)
+ return buffer->input_buffer_1st_display;
+ else if (string_strcasecmp (property, "num_history") == 0)
+ return buffer->num_history;
+ else if (string_strcasecmp (property, "text_search") == 0)
+ return buffer->text_search;
+ else if (string_strcasecmp (property, "text_search_exact") == 0)
+ return buffer->text_search_exact;
+ else if (string_strcasecmp (property, "text_search_regex") == 0)
+ return buffer->text_search_regex;
+ else if (string_strcasecmp (property, "text_search_where") == 0)
+ return buffer->text_search_where;
+ else if (string_strcasecmp (property, "text_search_found") == 0)
+ return buffer->text_search_found;
return 0;
}
@@ -1058,39 +1086,39 @@ gui_buffer_get_string (struct t_gui_buffer *buffer, const char *property)
{
const char *ptr_value;
- if (buffer && property)
- {
- if (string_strcasecmp (property, "plugin") == 0)
- return gui_buffer_get_plugin_name (buffer);
- else if (string_strcasecmp (property, "name") == 0)
- return buffer->name;
- else if (string_strcasecmp (property, "full_name") == 0)
- return buffer->full_name;
- else if (string_strcasecmp (property, "short_name") == 0)
- return gui_buffer_get_short_name (buffer);
- else if (string_strcasecmp (property, "title") == 0)
- return buffer->title;
- else if (string_strcasecmp (property, "input") == 0)
- return buffer->input_buffer;
- else if (string_strcasecmp (property, "text_search_input") == 0)
- return buffer->text_search_input;
- else if (string_strcasecmp (property, "highlight_words") == 0)
- return buffer->highlight_words;
- else if (string_strcasecmp (property, "highlight_regex") == 0)
- return buffer->highlight_regex;
- else if (string_strcasecmp (property, "highlight_tags_restrict") == 0)
- return buffer->highlight_tags_restrict;
- else if (string_strcasecmp (property, "highlight_tags") == 0)
- return buffer->highlight_tags;
- else if (string_strcasecmp (property, "hotlist_max_level_nicks") == 0)
- return hashtable_get_string (buffer->hotlist_max_level_nicks, "keys_values");
- else if (string_strncasecmp (property, "localvar_", 9) == 0)
- {
- ptr_value = (const char *)hashtable_get (buffer->local_variables,
- property + 9);
- if (ptr_value)
- return ptr_value;
- }
+ if (!buffer || !property)
+ return NULL;
+
+ if (string_strcasecmp (property, "plugin") == 0)
+ return gui_buffer_get_plugin_name (buffer);
+ else if (string_strcasecmp (property, "name") == 0)
+ return buffer->name;
+ else if (string_strcasecmp (property, "full_name") == 0)
+ return buffer->full_name;
+ else if (string_strcasecmp (property, "short_name") == 0)
+ return gui_buffer_get_short_name (buffer);
+ else if (string_strcasecmp (property, "title") == 0)
+ return buffer->title;
+ else if (string_strcasecmp (property, "input") == 0)
+ return buffer->input_buffer;
+ else if (string_strcasecmp (property, "text_search_input") == 0)
+ return buffer->text_search_input;
+ else if (string_strcasecmp (property, "highlight_words") == 0)
+ return buffer->highlight_words;
+ else if (string_strcasecmp (property, "highlight_regex") == 0)
+ return buffer->highlight_regex;
+ else if (string_strcasecmp (property, "highlight_tags_restrict") == 0)
+ return buffer->highlight_tags_restrict;
+ else if (string_strcasecmp (property, "highlight_tags") == 0)
+ return buffer->highlight_tags;
+ else if (string_strcasecmp (property, "hotlist_max_level_nicks") == 0)
+ return hashtable_get_string (buffer->hotlist_max_level_nicks, "keys_values");
+ else if (string_strncasecmp (property, "localvar_", 9) == 0)
+ {
+ ptr_value = (const char *)hashtable_get (buffer->local_variables,
+ property + 9);
+ if (ptr_value)
+ return ptr_value;
}
return NULL;
@@ -1103,15 +1131,15 @@ gui_buffer_get_string (struct t_gui_buffer *buffer, const char *property)
void *
gui_buffer_get_pointer (struct t_gui_buffer *buffer, const char *property)
{
- if (buffer && property)
- {
- if (string_strcasecmp (property, "plugin") == 0)
- return buffer->plugin;
- else if (string_strcasecmp (property, "text_search_regex_compiled") == 0)
- return buffer->text_search_regex_compiled;
- else if (string_strcasecmp (property, "highlight_regex_compiled") == 0)
- return buffer->highlight_regex_compiled;
- }
+ if (!buffer || !property)
+ return NULL;
+
+ if (string_strcasecmp (property, "plugin") == 0)
+ return buffer->plugin;
+ else if (string_strcasecmp (property, "text_search_regex_compiled") == 0)
+ return buffer->text_search_regex_compiled;
+ else if (string_strcasecmp (property, "highlight_regex_compiled") == 0)
+ return buffer->highlight_regex_compiled;
return NULL;
}
@@ -1123,6 +1151,9 @@ gui_buffer_get_pointer (struct t_gui_buffer *buffer, const char *property)
void
gui_buffer_ask_chat_refresh (struct t_gui_buffer *buffer, int refresh)
{
+ if (!buffer)
+ return;
+
if (refresh > buffer->chat_refresh_needed)
buffer->chat_refresh_needed = refresh;
}
@@ -1134,18 +1165,18 @@ gui_buffer_ask_chat_refresh (struct t_gui_buffer *buffer, int refresh)
void
gui_buffer_set_name (struct t_gui_buffer *buffer, const char *name)
{
- if (name && name[0])
- {
- if (buffer->name)
- free (buffer->name);
- buffer->name = strdup (name);
- gui_buffer_build_full_name (buffer);
+ if (!buffer || !name || !name[0])
+ return;
+
+ if (buffer->name)
+ free (buffer->name);
+ buffer->name = strdup (name);
+ gui_buffer_build_full_name (buffer);
- gui_buffer_local_var_add (buffer, "name", name);
+ gui_buffer_local_var_add (buffer, "name", name);
- (void) hook_signal_send ("buffer_renamed",
- WEECHAT_HOOK_SIGNAL_POINTER, buffer);
- }
+ (void) hook_signal_send ("buffer_renamed",
+ WEECHAT_HOOK_SIGNAL_POINTER, buffer);
}
/*
@@ -1155,6 +1186,9 @@ gui_buffer_set_name (struct t_gui_buffer *buffer, const char *name)
void
gui_buffer_set_short_name (struct t_gui_buffer *buffer, const char *short_name)
{
+ if (!buffer)
+ return;
+
if (buffer->short_name)
{
free (buffer->short_name);
@@ -1178,7 +1212,7 @@ gui_buffer_set_short_name (struct t_gui_buffer *buffer, const char *short_name)
void
gui_buffer_set_type (struct t_gui_buffer *buffer, enum t_gui_buffer_type type)
{
- if (buffer->type == type)
+ if (!buffer || (buffer->type == type))
return;
gui_line_free_all (buffer);
@@ -1200,6 +1234,9 @@ gui_buffer_set_type (struct t_gui_buffer *buffer, enum t_gui_buffer_type type)
void
gui_buffer_set_title (struct t_gui_buffer *buffer, const char *new_title)
{
+ if (!buffer)
+ return;
+
if (buffer->title)
free (buffer->title);
buffer->title = (new_title && new_title[0]) ? strdup (new_title) : NULL;
@@ -1216,6 +1253,9 @@ void
gui_buffer_set_time_for_each_line (struct t_gui_buffer *buffer,
int time_for_each_line)
{
+ if (!buffer)
+ return;
+
buffer->time_for_each_line = (time_for_each_line) ? 1 : 0;
gui_buffer_ask_chat_refresh (buffer, 2);
}
@@ -1227,6 +1267,9 @@ gui_buffer_set_time_for_each_line (struct t_gui_buffer *buffer,
void
gui_buffer_set_nicklist (struct t_gui_buffer *buffer, int nicklist)
{
+ if (!buffer)
+ return;
+
buffer->nicklist = (nicklist) ? 1 : 0;
gui_window_ask_refresh (1);
}
@@ -1239,6 +1282,9 @@ void
gui_buffer_set_nicklist_case_sensitive (struct t_gui_buffer *buffer,
int case_sensitive)
{
+ if (!buffer)
+ return;
+
buffer->nicklist_case_sensitive = (case_sensitive) ? 1 : 0;
}
@@ -1250,6 +1296,9 @@ void
gui_buffer_set_nicklist_display_groups (struct t_gui_buffer *buffer,
int display_groups)
{
+ if (!buffer)
+ return;
+
buffer->nicklist_display_groups = (display_groups) ? 1 : 0;
buffer->nicklist_visible_count = 0;
gui_nicklist_compute_visible_count (buffer, buffer->nicklist_root);
@@ -1264,6 +1313,9 @@ void
gui_buffer_set_highlight_words (struct t_gui_buffer *buffer,
const char *new_highlight_words)
{
+ if (!buffer)
+ return;
+
if (buffer->highlight_words)
free (buffer->highlight_words);
buffer->highlight_words = (new_highlight_words && new_highlight_words[0]) ?
@@ -1283,6 +1335,9 @@ gui_buffer_set_highlight_words_list (struct t_gui_buffer *buffer,
const char *ptr_string;
char *words;
+ if (!buffer)
+ return;
+
/* compute length */
length = 0;
for (ptr_list_item = weelist_get (list, 0); ptr_list_item;
@@ -1330,7 +1385,7 @@ gui_buffer_add_highlight_words (struct t_gui_buffer *buffer,
int current_count, add_count, i;
struct t_weelist *list;
- if (!words_to_add)
+ if (!buffer || !words_to_add)
return;
list = weelist_new ();
@@ -1375,7 +1430,7 @@ gui_buffer_remove_highlight_words (struct t_gui_buffer *buffer,
int current_count, remove_count, i, j, to_remove;
struct t_weelist *list;
- if (!words_to_remove)
+ if (!buffer || !words_to_remove)
return;
list = weelist_new ();
@@ -1421,6 +1476,9 @@ void
gui_buffer_set_highlight_regex (struct t_gui_buffer *buffer,
const char *new_highlight_regex)
{
+ if (!buffer)
+ return;
+
if (buffer->highlight_regex)
{
free (buffer->highlight_regex);
@@ -1465,6 +1523,9 @@ gui_buffer_set_highlight_tags_restrict (struct t_gui_buffer *buffer,
int i;
char **tags_array;
+ if (!buffer)
+ return;
+
if (buffer->highlight_tags_restrict)
{
free (buffer->highlight_tags_restrict);
@@ -1519,6 +1580,9 @@ gui_buffer_set_highlight_tags (struct t_gui_buffer *buffer,
int i;
char **tags_array;
+ if (!buffer)
+ return;
+
if (buffer->highlight_tags)
{
free (buffer->highlight_tags);
@@ -1574,6 +1638,9 @@ gui_buffer_set_hotlist_max_level_nicks (struct t_gui_buffer *buffer,
int nicks_count, value, i;
long number;
+ if (!buffer)
+ return;
+
hashtable_remove_all (buffer->hotlist_max_level_nicks);
if (new_hotlist_max_level_nicks && new_hotlist_max_level_nicks[0])
@@ -1615,7 +1682,7 @@ gui_buffer_add_hotlist_max_level_nicks (struct t_gui_buffer *buffer,
int nicks_count, value, i;
long number;
- if (!nicks_to_add)
+ if (!buffer || !nicks_to_add)
return;
nicks = string_split (nicks_to_add, ",", 0, 0, &nicks_count);
@@ -1652,7 +1719,7 @@ gui_buffer_remove_hotlist_max_level_nicks (struct t_gui_buffer *buffer,
char **nicks, *pos;
int nicks_count, i;
- if (!nicks_to_remove)
+ if (!buffer || !nicks_to_remove)
return;
nicks = string_split (nicks_to_remove, ",", 0, 0, &nicks_count);
@@ -1677,6 +1744,9 @@ void
gui_buffer_set_input_get_unknown_commands (struct t_gui_buffer *buffer,
int input_get_unknown_commands)
{
+ if (!buffer)
+ return;
+
buffer->input_get_unknown_commands = (input_get_unknown_commands) ? 1 : 0;
}
@@ -1689,17 +1759,17 @@ gui_buffer_set_unread (struct t_gui_buffer *buffer)
{
int refresh;
- if (buffer->type == GUI_BUFFER_TYPE_FORMATTED)
- {
- refresh = ((buffer->lines->last_read_line != NULL)
- && (buffer->lines->last_read_line != buffer->lines->last_line));
+ if (!buffer || (buffer->type != GUI_BUFFER_TYPE_FORMATTED))
+ return;
- buffer->lines->last_read_line = buffer->lines->last_line;
- buffer->lines->first_line_not_read = (buffer->lines->last_read_line) ? 0 : 1;
+ refresh = ((buffer->lines->last_read_line != NULL)
+ && (buffer->lines->last_read_line != buffer->lines->last_line));
- if (refresh)
- gui_buffer_ask_chat_refresh (buffer, 2);
- }
+ buffer->lines->last_read_line = buffer->lines->last_line;
+ buffer->lines->first_line_not_read = (buffer->lines->last_read_line) ? 0 : 1;
+
+ if (refresh)
+ gui_buffer_ask_chat_refresh (buffer, 2);
}
/*
@@ -1971,6 +2041,10 @@ gui_buffer_set_pointer (struct t_gui_buffer *buffer, const char *property,
{
buffer->close_callback = pointer;
}
+ else if (string_strcasecmp (property, "close_callback_pointer") == 0)
+ {
+ buffer->close_callback_pointer = pointer;
+ }
else if (string_strcasecmp (property, "close_callback_data") == 0)
{
buffer->close_callback_data = pointer;
@@ -1979,6 +2053,10 @@ gui_buffer_set_pointer (struct t_gui_buffer *buffer, const char *property,
{
buffer->nickcmp_callback = pointer;
}
+ else if (string_strcasecmp (property, "nickcmp_callback_pointer") == 0)
+ {
+ buffer->nickcmp_callback_pointer = pointer;
+ }
else if (string_strcasecmp (property, "nickcmp_callback_data") == 0)
{
buffer->nickcmp_callback_data = pointer;
@@ -1987,6 +2065,10 @@ gui_buffer_set_pointer (struct t_gui_buffer *buffer, const char *property,
{
buffer->input_callback = pointer;
}
+ else if (string_strcasecmp (property, "input_callback_pointer") == 0)
+ {
+ buffer->input_callback_pointer = pointer;
+ }
else if (string_strcasecmp (property, "input_callback_data") == 0)
{
buffer->input_callback_data = pointer;
@@ -2036,6 +2118,9 @@ gui_buffer_add_value_num_displayed (struct t_gui_buffer *buffer, int value)
{
struct t_gui_buffer *ptr_buffer;
+ if (!buffer)
+ return;
+
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
@@ -2505,6 +2590,9 @@ gui_buffer_close (struct t_gui_buffer *buffer)
int index, i;
struct t_gui_buffer_visited *ptr_buffer_visited;
+ if (!buffer)
+ return;
+
buffer->closing = 1;
(void) hook_signal_send ("buffer_closing",
@@ -2512,7 +2600,9 @@ gui_buffer_close (struct t_gui_buffer *buffer)
if (buffer->close_callback)
{
- (void)(buffer->close_callback) (buffer->close_callback_data, buffer);
+ (void)(buffer->close_callback) (buffer->close_callback_pointer,
+ buffer->close_callback_data,
+ buffer);
}
ptr_back_to_buffer = NULL;
@@ -2674,6 +2764,12 @@ gui_buffer_close (struct t_gui_buffer *buffer)
}
free (buffer->highlight_tags_array);
}
+ if (buffer->input_callback_data)
+ free (buffer->input_callback_data);
+ if (buffer->close_callback_data)
+ free (buffer->close_callback_data);
+ if (buffer->nickcmp_callback_data)
+ free (buffer->nickcmp_callback_data);
/* remove buffer from buffers list */
if (buffer->prev_buffer)
@@ -2713,6 +2809,9 @@ gui_buffer_switch_by_number (struct t_gui_window *window, int number)
{
struct t_gui_buffer *ptr_buffer;
+ if (!window || !window->buffer)
+ return;
+
/* invalid buffer */
if ((number < 0) || (number == window->buffer->number))
return;
@@ -2739,6 +2838,9 @@ gui_buffer_set_active_buffer (struct t_gui_buffer *buffer)
struct t_gui_buffer *ptr_buffer;
int active;
+ if (!buffer)
+ return;
+
active = 1;
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
@@ -2785,6 +2887,9 @@ gui_buffer_get_next_active_buffer (struct t_gui_buffer *buffer,
{
struct t_gui_buffer *ptr_buffer;
+ if (!buffer)
+ return NULL;
+
/* search after buffer */
for (ptr_buffer = buffer->next_buffer; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
@@ -2825,6 +2930,9 @@ gui_buffer_get_previous_active_buffer (struct t_gui_buffer *buffer,
{
struct t_gui_buffer *ptr_buffer;
+ if (!buffer)
+ return NULL;
+
/* search before buffer */
for (ptr_buffer = buffer->prev_buffer; ptr_buffer;
ptr_buffer = ptr_buffer->prev_buffer)
@@ -2975,6 +3083,9 @@ gui_buffer_move_to_number (struct t_gui_buffer *buffer, int number)
auto_renumber = CONFIG_BOOLEAN(config_look_buffer_auto_renumber);
+ if (!buffer)
+ return;
+
/* nothing to do if auto renumber is ON and that there is only one buffer */
if (auto_renumber && (gui_buffers == last_gui_buffer))
return;
@@ -3191,6 +3302,9 @@ gui_buffer_merge (struct t_gui_buffer *buffer,
{
struct t_gui_buffer *ptr_buffer, *ptr_first_buffer[2], *ptr_last_buffer[2];
+ if (!buffer || !target_buffer)
+ return;
+
/*
* nothing to do if:
* - there is only one buffer
@@ -3296,6 +3410,9 @@ gui_buffer_unmerge (struct t_gui_buffer *buffer, int number)
int num_merged;
struct t_gui_buffer *ptr_buffer, *ptr_new_active_buffer;
+ if (!buffer)
+ return;
+
/* nothing to do if there is only one buffer */
if (gui_buffers == last_gui_buffer)
return;
@@ -3570,6 +3687,9 @@ gui_buffer_sort_by_layout_number ()
void
gui_buffer_undo_snap (struct t_gui_buffer *buffer)
{
+ if (!buffer)
+ return;
+
if ((buffer->input_undo_snap)->data)
{
free ((buffer->input_undo_snap)->data);
@@ -3592,6 +3712,9 @@ gui_buffer_undo_snap (struct t_gui_buffer *buffer)
void
gui_buffer_undo_snap_free (struct t_gui_buffer *buffer)
{
+ if (!buffer)
+ return;
+
if ((buffer->input_undo_snap)->data)
{
free ((buffer->input_undo_snap)->data);
@@ -3612,6 +3735,9 @@ gui_buffer_undo_add (struct t_gui_buffer *buffer)
{
struct t_gui_input_undo *new_undo;
+ if (!buffer)
+ return;
+
/* undo disabled by configuration */
if (CONFIG_INTEGER(config_look_input_undo_max) == 0)
goto end;
@@ -3692,6 +3818,9 @@ void
gui_buffer_undo_free (struct t_gui_buffer *buffer,
struct t_gui_input_undo *undo)
{
+ if (!buffer || !undo)
+ return;
+
/* update current undo if needed */
if (buffer->ptr_input_undo == undo)
{
@@ -3727,6 +3856,9 @@ gui_buffer_undo_free (struct t_gui_buffer *buffer,
void
gui_buffer_undo_free_all (struct t_gui_buffer *buffer)
{
+ if (!buffer)
+ return;
+
gui_buffer_undo_snap_free (buffer);
while (buffer->input_undo)
@@ -3925,11 +4057,13 @@ gui_buffer_visited_get_index_next ()
*/
struct t_hdata *
-gui_buffer_hdata_buffer_cb (void *data, const char *hdata_name)
+gui_buffer_hdata_buffer_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_buffer", "next_buffer",
@@ -3955,6 +4089,7 @@ gui_buffer_hdata_buffer_cb (void *data, const char *hdata_name)
HDATA_VAR(struct t_gui_buffer, clear, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, filter, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, close_callback, POINTER, 0, NULL, NULL);
+ HDATA_VAR(struct t_gui_buffer, close_callback_pointer, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, close_callback_data, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, closing, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, title, STRING, 0, NULL, NULL);
@@ -3973,9 +4108,11 @@ gui_buffer_hdata_buffer_cb (void *data, const char *hdata_name)
HDATA_VAR(struct t_gui_buffer, nicklist_nicks_count, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, nicklist_visible_count, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, nickcmp_callback, POINTER, 0, NULL, NULL);
+ HDATA_VAR(struct t_gui_buffer, nickcmp_callback_pointer, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, nickcmp_callback_data, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, input, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, input_callback, POINTER, 0, NULL, NULL);
+ HDATA_VAR(struct t_gui_buffer, input_callback_pointer, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, input_callback_data, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, input_get_unknown_commands, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, input_buffer, STRING, 0, NULL, NULL);
@@ -4029,11 +4166,13 @@ gui_buffer_hdata_buffer_cb (void *data, const char *hdata_name)
*/
struct t_hdata *
-gui_buffer_hdata_input_undo_cb (void *data, const char *hdata_name)
+gui_buffer_hdata_input_undo_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_undo", "next_undo",
@@ -4053,11 +4192,13 @@ gui_buffer_hdata_input_undo_cb (void *data, const char *hdata_name)
*/
struct t_hdata *
-gui_buffer_hdata_buffer_visited_cb (void *data, const char *hdata_name)
+gui_buffer_hdata_buffer_visited_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_buffer", "next_buffer",
@@ -4352,6 +4493,7 @@ gui_buffer_print_log ()
log_printf (" clear . . . . . . . . . : %d", ptr_buffer->clear);
log_printf (" filter. . . . . . . . . : %d", ptr_buffer->filter);
log_printf (" close_callback. . . . . : 0x%lx", ptr_buffer->close_callback);
+ log_printf (" close_callback_pointer. : 0x%lx", ptr_buffer->close_callback_pointer);
log_printf (" close_callback_data . . : 0x%lx", ptr_buffer->close_callback_data);
log_printf (" closing . . . . . . . . : %d", ptr_buffer->closing);
log_printf (" title . . . . . . . . . : '%s'", ptr_buffer->title);
@@ -4372,9 +4514,11 @@ gui_buffer_print_log ()
log_printf (" nicklist_nicks_count. . : %d", ptr_buffer->nicklist_nicks_count);
log_printf (" nicklist_visible_count. : %d", ptr_buffer->nicklist_visible_count);
log_printf (" nickcmp_callback. . . . : 0x%lx", ptr_buffer->nickcmp_callback);
+ log_printf (" nickcmp_callback_pointer: 0x%lx", ptr_buffer->nickcmp_callback_pointer);
log_printf (" nickcmp_callback_data . : 0x%lx", ptr_buffer->nickcmp_callback_data);
log_printf (" input . . . . . . . . . : %d", ptr_buffer->input);
log_printf (" input_callback. . . . . : 0x%lx", ptr_buffer->input_callback);
+ log_printf (" input_callback_pointer. : 0x%lx", ptr_buffer->input_callback_pointer);
log_printf (" input_callback_data . . : 0x%lx", ptr_buffer->input_callback_data);
log_printf (" input_get_unknown_cmd . : %d", ptr_buffer->input_get_unknown_commands);
log_printf (" input_buffer. . . . . . : '%s'", ptr_buffer->input_buffer);
diff --git a/src/gui/gui-buffer.h b/src/gui/gui-buffer.h
index d533d0ba6..6414978c5 100644
--- a/src/gui/gui-buffer.h
+++ b/src/gui/gui-buffer.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -106,8 +106,10 @@ struct t_gui_buffer
int filter; /* 1 if filters enabled for buffer */
/* close callback */
- int (*close_callback)(void *data, /* called when buffer is closed */
+ int (*close_callback)(const void *pointer, /* called when buffer is */
+ void *data, /* closed */
struct t_gui_buffer *buffer);
+ const void *close_callback_pointer; /* pointer for callback */
void *close_callback_data; /* data for callback */
int closing; /* 1 if the buffer is being closed */
@@ -133,17 +135,21 @@ struct t_gui_buffer
int nicklist_groups_count; /* number of groups */
int nicklist_nicks_count; /* number of nicks */
int nicklist_visible_count; /* number of nicks/groups to display */
- int (*nickcmp_callback)(void *data, /* called to compare nicks (search */
- struct t_gui_buffer *buffer, /* in nicklist) */
+ int (*nickcmp_callback)(const void *pointer, /* called to compare nicks */
+ void *data, /* (search in nicklist) */
+ struct t_gui_buffer *buffer,
const char *nick1,
const char *nick2);
+ const void *nickcmp_callback_pointer; /* pointer for callback */
void *nickcmp_callback_data; /* data for callback */
/* input */
int input; /* = 1 if input is enabled */
- int (*input_callback)(void *data, /* called when user send data */
+ int (*input_callback)(const void *pointer, /* called when user sends */
+ void *data, /* data */
struct t_gui_buffer *buffer,
const char *input_data);
+ const void *input_callback_pointer; /* pointer for callback */
void *input_callback_data; /* data for callback */
/* to this buffer */
int input_get_unknown_commands; /* 1 if unknown commands are sent to */
@@ -241,12 +247,16 @@ extern void gui_buffer_notify_set_all ();
extern void gui_buffer_input_buffer_init (struct t_gui_buffer *buffer);
extern struct t_gui_buffer *gui_buffer_new (struct t_weechat_plugin *plugin,
const char *name,
- int (*input_callback)(void *data,
+ int (*input_callback)(const void *pointer,
+ void *data,
struct t_gui_buffer *buffer,
const char *input_data),
+ const void *input_callback_pointer,
void *input_callback_data,
- int (*close_callback)(void *data,
+ int (*close_callback)(const void *pointer,
+ void *data,
struct t_gui_buffer *buffer),
+ const void *close_callback_pointer,
void *close_callback_data);
extern int gui_buffer_valid (struct t_gui_buffer *buffer);
extern char *gui_buffer_string_replace_local_var (struct t_gui_buffer *buffer,
@@ -333,11 +343,14 @@ extern void gui_buffer_visited_remove_by_buffer (struct t_gui_buffer *buffer);
extern struct t_gui_buffer_visited *gui_buffer_visited_add (struct t_gui_buffer *buffer);
extern int gui_buffer_visited_get_index_previous ();
extern int gui_buffer_visited_get_index_next ();
-extern struct t_hdata *gui_buffer_hdata_buffer_cb (void *data,
+extern struct t_hdata *gui_buffer_hdata_buffer_cb (const void *pointer,
+ void *data,
const char *hdata_name);
-extern struct t_hdata *gui_buffer_hdata_input_undo_cb (void *data,
+extern struct t_hdata *gui_buffer_hdata_input_undo_cb (const void *pointer,
+ void *data,
const char *hdata_name);
-extern struct t_hdata *gui_buffer_hdata_buffer_visited_cb (void *data,
+extern struct t_hdata *gui_buffer_hdata_buffer_visited_cb (const void *pointer,
+ void *data,
const char *hdata_name);
extern int gui_buffer_add_to_infolist (struct t_infolist *infolist,
struct t_gui_buffer *buffer);
diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c
index 163e2d9c0..1e912387f 100644
--- a/src/gui/gui-chat.c
+++ b/src/gui/gui-chat.c
@@ -1,7 +1,7 @@
/*
* gui-chat.c - chat functions (used by all GUI)
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -83,11 +83,11 @@ gui_chat_init ()
/* some hsignals */
hook_hsignal (NULL, "chat_quote_time_prefix_message",
- &gui_chat_hsignal_quote_line_cb, NULL);
+ &gui_chat_hsignal_quote_line_cb, NULL, NULL);
hook_hsignal (NULL, "chat_quote_prefix_message",
- &gui_chat_hsignal_quote_line_cb, NULL);
+ &gui_chat_hsignal_quote_line_cb, NULL, NULL);
hook_hsignal (NULL, "chat_quote_message",
- &gui_chat_hsignal_quote_line_cb, NULL);
+ &gui_chat_hsignal_quote_line_cb, NULL, NULL);
}
/*
@@ -332,7 +332,7 @@ gui_chat_get_word_info (struct t_gui_window *window,
*word_start_offset = 0;
*word_end_offset = 0;
*word_length_with_spaces = 0;
- *word_length = 0;
+ *word_length = -1;
start_data = data;
@@ -354,6 +354,8 @@ gui_chat_get_word_info (struct t_gui_window *window,
*word_end_offset = next_char2 - start_data - 1;
char_size_screen = gui_chat_char_size_screen (next_char);
(*word_length_with_spaces) += char_size_screen;
+ if (*word_length < 0)
+ *word_length = 0;
(*word_length) += char_size_screen;
}
else
@@ -925,7 +927,7 @@ gui_chat_printf_y (struct t_gui_buffer *buffer, int y, const char *message, ...)
gui_buffer_ask_chat_refresh (buffer, 1);
}
else
- string_iconv_fprintf (stdout, "%s\n", vbuffer);
+ string_fprintf (stdout, "%s\n", vbuffer);
}
free (vbuffer);
@@ -957,7 +959,7 @@ gui_chat_print_lines_waiting_buffer (FILE *f)
if (!f && gui_init_ok)
gui_chat_printf (NULL, "%s", lines[i]);
else
- string_iconv_fprintf ((f) ? f : stdout, "%s\n", lines[i]);
+ string_fprintf ((f) ? f : stdout, "%s\n", lines[i]);
}
string_free_split (lines);
}
@@ -978,7 +980,8 @@ gui_chat_print_lines_waiting_buffer (FILE *f)
*/
int
-gui_chat_hsignal_quote_line_cb (void *data, const char *signal,
+gui_chat_hsignal_quote_line_cb (const void *pointer, void *data,
+ const char *signal,
struct t_hashtable *hashtable)
{
const char *date, *line, *prefix, *ptr_prefix, *message;
@@ -992,6 +995,7 @@ gui_chat_hsignal_quote_line_cb (void *data, const char *signal,
char str_time[128], *str, *error;
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (!gui_current_window->buffer->input)
diff --git a/src/gui/gui-chat.h b/src/gui/gui-chat.h
index 70c73edd9..db2a84908 100644
--- a/src/gui/gui-chat.h
+++ b/src/gui/gui-chat.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -89,7 +89,8 @@ extern void gui_chat_printf_date_tags (struct t_gui_buffer *buffer,
extern void gui_chat_printf_y (struct t_gui_buffer *buffer, int y,
const char *message, ...);
extern void gui_chat_print_lines_waiting_buffer (FILE *f);
-extern int gui_chat_hsignal_quote_line_cb (void *data, const char *signal,
+extern int gui_chat_hsignal_quote_line_cb (const void *pointer, void *data,
+ const char *signal,
struct t_hashtable *hashtable);
extern void gui_chat_end ();
diff --git a/src/gui/gui-color.c b/src/gui/gui-color.c
index 470bc7a97..7ffd619a5 100644
--- a/src/gui/gui-color.c
+++ b/src/gui/gui-color.c
@@ -1,7 +1,7 @@
/*
* gui-color.c - color functions (used by all GUI)
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -760,11 +760,10 @@ gui_color_decode (const char *string, const char *replacement)
char *
gui_color_decode_ansi_cb (void *data, const char *text)
{
- unsigned long keep_colors;
char *text2, **items, *output, str_color[128];
- int i, length, num_items, value;
+ int i, keep_colors, length, num_items, value;
- keep_colors = (unsigned long)data;
+ keep_colors = (data) ? 1 : 0;;
/* if we don't keep colors of if text is empty, just return empty string */
if (!keep_colors || !text || !text[0])
@@ -1186,20 +1185,20 @@ gui_color_palette_alloc_structs ()
{
if (!gui_color_hash_palette_color)
{
- gui_color_hash_palette_color = hashtable_new (32,
- WEECHAT_HASHTABLE_STRING,
- WEECHAT_HASHTABLE_POINTER,
- NULL,
- NULL);
+ gui_color_hash_palette_color = hashtable_new (
+ 32,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_POINTER,
+ NULL, NULL);
gui_color_hash_palette_color->callback_free_value = &gui_color_palette_free_value_cb;
}
if (!gui_color_hash_palette_alias)
{
- gui_color_hash_palette_alias = hashtable_new (32,
- WEECHAT_HASHTABLE_STRING,
- WEECHAT_HASHTABLE_INTEGER,
- NULL,
- NULL);
+ gui_color_hash_palette_alias = hashtable_new (
+ 32,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_INTEGER,
+ NULL, NULL);
}
if (!gui_color_list_with_alias)
{
diff --git a/src/gui/gui-color.h b/src/gui/gui-color.h
index b67d2876d..184e6d8ae 100644
--- a/src/gui/gui-color.h
+++ b/src/gui/gui-color.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -26,10 +26,13 @@ struct t_config_option;
/*
* Color from configuration options.
+ *
* When changing some colors below:
* - always add to the end
* - never remove a color (mark it as obsolete if needed)
* - do not re-use an obsolete color
+ * - add build of color in file src/gui/curses/gui-curses-color.c,
+ * function gui_color_init_weechat ()
* - update the Developer's guide
*/
@@ -84,6 +87,7 @@ enum t_gui_color_enum
GUI_COLOR_CHAT_NICK_SUFFIX,
GUI_COLOR_EMPHASIS,
GUI_COLOR_CHAT_DAY_CHANGE,
+ GUI_COLOR_CHAT_VALUE_NULL,
/* number of colors */
GUI_COLOR_NUM_COLORS,
diff --git a/src/gui/gui-completion.c b/src/gui/gui-completion.c
index 0e07b96da..22af93fb5 100644
--- a/src/gui/gui-completion.c
+++ b/src/gui/gui-completion.c
@@ -1,7 +1,7 @@
/*
* gui-completion.c - word completion according to context (used by all GUI)
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -56,7 +56,8 @@ int gui_completion_freeze = 0; /* 1 to freeze completions (do not */
*/
int
-gui_completion_word_compare_cb (void *data, struct t_arraylist *arraylist,
+gui_completion_word_compare_cb (void *data,
+ struct t_arraylist *arraylist,
void *pointer1, void *pointer2)
{
struct t_gui_completion_word *completion_word1, *completion_word2;
@@ -76,7 +77,8 @@ gui_completion_word_compare_cb (void *data, struct t_arraylist *arraylist,
*/
void
-gui_completion_word_free_cb (void *data, struct t_arraylist *arraylist,
+gui_completion_word_free_cb (void *data,
+ struct t_arraylist *arraylist,
void *pointer)
{
struct t_gui_completion_word *completion_word;
@@ -113,9 +115,10 @@ gui_completion_buffer_init (struct t_gui_completion *completion,
completion->add_space = 1;
completion->force_partial_completion = 0;
- completion->list = arraylist_new (32, 1, 0,
- &gui_completion_word_compare_cb, NULL,
- &gui_completion_word_free_cb, NULL);
+ completion->list = arraylist_new (
+ 32, 1, 0,
+ &gui_completion_word_compare_cb, NULL,
+ &gui_completion_word_free_cb, NULL);
completion->word_found = NULL;
completion->word_found_is_nick = 0;
@@ -1239,7 +1242,8 @@ gui_completion_auto (struct t_gui_completion *completion)
|| (completion->base_word[0] == '~'))
{
if (completion->list->size == 0)
- completion_list_add_filename_cb (NULL, NULL, NULL, completion);
+ completion_list_add_filename_cb (NULL, NULL, NULL, NULL,
+ completion);
gui_completion_complete (completion);
return;
}
@@ -1349,15 +1353,16 @@ gui_completion_get_string (struct t_gui_completion *completion,
*/
struct t_hdata *
-gui_completion_hdata_completion_cb (void *data, const char *hdata_name)
+gui_completion_hdata_completion_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
- hdata = hdata_new (NULL, hdata_name, NULL, NULL,
- 0, 0, NULL, NULL);
+ hdata = hdata_new (NULL, hdata_name, NULL, NULL, 0, 0, NULL, NULL);
if (hdata)
{
HDATA_VAR(struct t_gui_completion, buffer, POINTER, 0, NULL, "buffer");
@@ -1387,11 +1392,13 @@ gui_completion_hdata_completion_cb (void *data, const char *hdata_name)
*/
struct t_hdata *
-gui_completion_hdata_completion_word_cb (void *data, const char *hdata_name)
+gui_completion_hdata_completion_word_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_item", "next_item",
diff --git a/src/gui/gui-completion.h b/src/gui/gui-completion.h
index ce214a0e3..1529e4dac 100644
--- a/src/gui/gui-completion.h
+++ b/src/gui/gui-completion.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -80,9 +80,11 @@ extern void gui_completion_search (struct t_gui_completion *completion,
int pos);
extern const char *gui_completion_get_string (struct t_gui_completion *completion,
const char *property);
-extern struct t_hdata *gui_completion_hdata_completion_cb (void *data,
+extern struct t_hdata *gui_completion_hdata_completion_cb (const void *pointer,
+ void *data,
const char *hdata_name);
-extern struct t_hdata *gui_completion_hdata_completion_partial_cb (void *data,
+extern struct t_hdata *gui_completion_hdata_completion_partial_cb (const void *pointer,
+ void *data,
const char *hdata_name);
extern void gui_completion_print_log (struct t_gui_completion *completion);
diff --git a/src/gui/gui-cursor.c b/src/gui/gui-cursor.c
index 7fabd6941..f876375e7 100644
--- a/src/gui/gui-cursor.c
+++ b/src/gui/gui-cursor.c
@@ -1,7 +1,7 @@
/*
* gui-cursor.c - functions for free movement of cursor (used by all GUI)
*
- * Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/gui/gui-cursor.h b/src/gui/gui-cursor.h
index ce2257313..3958ec165 100644
--- a/src/gui/gui-cursor.h
+++ b/src/gui/gui-cursor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/gui/gui-filter.c b/src/gui/gui-filter.c
index df0fa1619..ab279483d 100644
--- a/src/gui/gui-filter.c
+++ b/src/gui/gui-filter.c
@@ -1,7 +1,7 @@
/*
* gui-filter.c - filter functions (used by all GUI)
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -38,6 +38,7 @@
#include "../plugins/plugin.h"
#include "gui-filter.h"
#include "gui-buffer.h"
+#include "gui-chat.h"
#include "gui-line.h"
#include "gui-window.h"
@@ -254,6 +255,21 @@ gui_filter_search_by_name (const char *name)
}
/*
+ * Displays an error when a new filter is created.
+ */
+
+void
+gui_filter_new_error (const char *name, const char *error)
+{
+ gui_chat_printf_date_tags (
+ NULL, 0, GUI_FILTER_TAG_NO_FILTER,
+ _("%sError adding filter \"%s\": %s"),
+ gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
+ (name) ? name : "",
+ error);
+}
+
+/*
* Creates a new filter.
*
* Returns pointer to new filter, NULL if error.
@@ -265,15 +281,22 @@ gui_filter_new (int enabled, const char *name, const char *buffer_name,
{
struct t_gui_filter *new_filter;
regex_t *regex1, *regex2;
- char *pos_tab, *regex_prefix, **tags_array;
+ char *pos_tab, *regex_prefix, **tags_array, buf[512], str_error[512];
const char *ptr_start_regex, *pos_regex_message;
- int i;
+ int i, rc;
if (!name || !buffer_name || !tags || !regex)
+ {
+ gui_filter_new_error (name, _("not enough arguments"));
return NULL;
+ }
if (gui_filter_search_by_name (name))
+ {
+ gui_filter_new_error (name,
+ _("a filter with same name already exists"));
return NULL;
+ }
ptr_start_regex = regex;
if ((ptr_start_regex[0] == '!')
@@ -305,9 +328,16 @@ gui_filter_new (int enabled, const char *name, const char *buffer_name,
regex1 = malloc (sizeof (*regex1));
if (regex1)
{
- if (string_regcomp (regex1, regex_prefix,
- REG_EXTENDED | REG_ICASE | REG_NOSUB) != 0)
+ rc = string_regcomp (regex1, regex_prefix,
+ REG_EXTENDED | REG_ICASE | REG_NOSUB);
+ if (rc != 0)
{
+ regerror (rc, regex1, buf, sizeof (buf));
+ snprintf (str_error, sizeof (str_error),
+ /* TRANSLATORS: %s is the error returned by regerror */
+ _("invalid regular expression (%s)"),
+ buf);
+ gui_filter_new_error (name, str_error);
free (regex_prefix);
free (regex1);
return NULL;
@@ -320,9 +350,16 @@ gui_filter_new (int enabled, const char *name, const char *buffer_name,
regex2 = malloc (sizeof (*regex2));
if (regex2)
{
- if (string_regcomp (regex2, pos_regex_message,
- REG_EXTENDED | REG_ICASE | REG_NOSUB) != 0)
+ rc = string_regcomp (regex2, pos_regex_message,
+ REG_EXTENDED | REG_ICASE | REG_NOSUB);
+ if (rc != 0)
{
+ regerror (rc, regex2, buf, sizeof (buf));
+ snprintf (str_error, sizeof (str_error),
+ /* TRANSLATORS: %s is the error returned by regerror */
+ _("invalid regular expression (%s)"),
+ buf);
+ gui_filter_new_error (name, str_error);
if (regex_prefix)
free (regex_prefix);
if (regex1)
@@ -390,6 +427,10 @@ gui_filter_new (int enabled, const char *name, const char *buffer_name,
(void) hook_signal_send ("filter_added",
WEECHAT_HOOK_SIGNAL_POINTER, new_filter);
}
+ else
+ {
+ gui_filter_new_error (name, _("not enough memory"));
+ }
return new_filter;
}
@@ -492,11 +533,13 @@ gui_filter_free_all ()
*/
struct t_hdata *
-gui_filter_hdata_filter_cb (void *data, const char *hdata_name)
+gui_filter_hdata_filter_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_filter", "next_filter",
diff --git a/src/gui/gui-filter.h b/src/gui/gui-filter.h
index 4c89d46b6..9c383a263 100644
--- a/src/gui/gui-filter.h
+++ b/src/gui/gui-filter.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -69,7 +69,8 @@ extern int gui_filter_rename (struct t_gui_filter *filter,
const char *new_name);
extern void gui_filter_free (struct t_gui_filter *filter);
extern void gui_filter_free_all ();
-extern struct t_hdata *gui_filter_hdata_filter_cb (void *data,
+extern struct t_hdata *gui_filter_hdata_filter_cb (const void *pointer,
+ void *data,
const char *hdata_name);
extern int gui_filter_add_to_infolist (struct t_infolist *infolist,
struct t_gui_filter *filter);
diff --git a/src/gui/gui-focus.c b/src/gui/gui-focus.c
index 91606e4f1..a712886e2 100644
--- a/src/gui/gui-focus.c
+++ b/src/gui/gui-focus.c
@@ -1,7 +1,7 @@
/*
* gui-focus.c - functions about focus (cursor mode and mouse) (used by all GUI)
*
- * Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -134,7 +134,8 @@ gui_focus_free_info (struct t_gui_focus_info *focus_info)
*/
void
-gui_focus_buffer_localvar_map_cb (void *data, struct t_hashtable *hashtable,
+gui_focus_buffer_localvar_map_cb (void *data,
+ struct t_hashtable *hashtable,
const void *key, const void *value)
{
struct t_hashtable *hashtable_focus;
@@ -171,8 +172,7 @@ gui_focus_to_hashtable (struct t_gui_focus_info *focus_info, const char *key)
hashtable = hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
if (!hashtable)
return NULL;
diff --git a/src/gui/gui-focus.h b/src/gui/gui-focus.h
index 771b9db97..22c3bc4a4 100644
--- a/src/gui/gui-focus.h
+++ b/src/gui/gui-focus.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/gui/gui-history.c b/src/gui/gui-history.c
index 74d04256e..9f07c4fb4 100644
--- a/src/gui/gui-history.c
+++ b/src/gui/gui-history.c
@@ -1,7 +1,7 @@
/*
* gui-history.c - memorize commands or text for buffers (used by all GUI)
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2005 Emmanuel Bouthenot <kolter@openics.org>
*
* This file is part of WeeChat, the extensible chat client.
@@ -277,11 +277,13 @@ gui_history_hdata_history_update_cb (void *data,
*/
struct t_hdata *
-gui_history_hdata_history_cb (void *data, const char *hdata_name)
+gui_history_hdata_history_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_history", "next_history",
diff --git a/src/gui/gui-history.h b/src/gui/gui-history.h
index b7ff62c71..dc7e86434 100644
--- a/src/gui/gui-history.h
+++ b/src/gui/gui-history.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -39,7 +39,8 @@ extern void gui_history_global_add (const char *string);
extern void gui_history_add (struct t_gui_buffer *buffer, const char *string);
extern void gui_history_global_free ();
extern void gui_history_buffer_free (struct t_gui_buffer *buffer);
-extern struct t_hdata *gui_history_hdata_history_cb (void *data,
+extern struct t_hdata *gui_history_hdata_history_cb (const void *pointer,
+ void *data,
const char *hdata_name);
extern int gui_history_add_to_infolist (struct t_infolist *infolist,
struct t_gui_history *history);
diff --git a/src/gui/gui-hotlist.c b/src/gui/gui-hotlist.c
index e15236a63..205c0bbe9 100644
--- a/src/gui/gui-hotlist.c
+++ b/src/gui/gui-hotlist.c
@@ -1,7 +1,7 @@
/*
* gui-hotlist.c - hotlist management (used by all GUI)
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -317,8 +317,7 @@ gui_hotlist_add (struct t_gui_buffer *buffer,
32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_POINTER,
- NULL,
- NULL);
+ NULL, NULL);
if (!gui_hotlist_hashtable_add_conditions_pointers)
return NULL;
}
@@ -328,8 +327,7 @@ gui_hotlist_add (struct t_gui_buffer *buffer,
32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
if (!gui_hotlist_hashtable_add_conditions_vars)
return NULL;
}
@@ -339,8 +337,7 @@ gui_hotlist_add (struct t_gui_buffer *buffer,
32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
if (!gui_hotlist_hashtable_add_conditions_options)
return NULL;
hashtable_set (gui_hotlist_hashtable_add_conditions_options,
@@ -473,13 +470,41 @@ gui_hotlist_resort ()
/*
* Clears hotlist.
+ *
+ * Argument "level_mask" is a combination of:
+ * 1 = join/part
+ * 2 = message
+ * 4 = private
+ * 8 = highlight
+ *
+ * So for example :
+ * 1 = clear only join/part
+ * 12 = clear only private and highlight
+ * 15 = clear whole hotlist
*/
void
-gui_hotlist_clear ()
+gui_hotlist_clear (int level_mask)
{
- gui_hotlist_free_all (&gui_hotlist, &last_gui_hotlist);
- gui_hotlist_changed_signal ();
+ struct t_gui_hotlist *ptr_hotlist, *ptr_next_hotlist;
+ int hotlist_changed;
+
+ hotlist_changed = 0;
+
+ ptr_hotlist = gui_hotlist;
+ while (ptr_hotlist)
+ {
+ ptr_next_hotlist = ptr_hotlist->next_hotlist;
+ if (level_mask & (1 << ptr_hotlist->priority))
+ {
+ gui_hotlist_free (&gui_hotlist, &last_gui_hotlist, ptr_hotlist);
+ hotlist_changed = 1;
+ }
+ ptr_hotlist = ptr_next_hotlist;
+ }
+
+ if (hotlist_changed)
+ gui_hotlist_changed_signal ();
}
/*
@@ -539,11 +564,13 @@ gui_hotlist_remove_buffer (struct t_gui_buffer *buffer,
*/
struct t_hdata *
-gui_hotlist_hdata_hotlist_cb (void *data, const char *hdata_name)
+gui_hotlist_hdata_hotlist_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_hotlist", "next_hotlist",
diff --git a/src/gui/gui-hotlist.h b/src/gui/gui-hotlist.h
index 15f1bce25..dab59ace2 100644
--- a/src/gui/gui-hotlist.h
+++ b/src/gui/gui-hotlist.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -34,6 +34,8 @@ enum t_gui_hotlist_priority
#define GUI_HOTLIST_MIN 0
#define GUI_HOTLIST_MAX (GUI_HOTLIST_NUM_PRIORITIES - 1)
+#define GUI_HOTLIST_MASK_MAX ((1 << GUI_HOTLIST_NUM_PRIORITIES) - 1)
+
struct t_gui_hotlist
{
enum t_gui_hotlist_priority priority; /* 0=crappy msg (join/part), */
@@ -58,10 +60,11 @@ extern struct t_gui_hotlist *gui_hotlist_add (struct t_gui_buffer *buffer,
enum t_gui_hotlist_priority priority,
struct timeval *creation_time);
extern void gui_hotlist_resort ();
-extern void gui_hotlist_clear ();
+extern void gui_hotlist_clear (int level_mask);
extern void gui_hotlist_remove_buffer (struct t_gui_buffer *buffer,
int force_remove_buffer);
-extern struct t_hdata *gui_hotlist_hdata_hotlist_cb (void *data,
+extern struct t_hdata *gui_hotlist_hdata_hotlist_cb (const void *pointer,
+ void *data,
const char *hdata_name);
extern int gui_hotlist_add_to_infolist (struct t_infolist *infolist,
struct t_gui_hotlist *hotlist);
diff --git a/src/gui/gui-input.c b/src/gui/gui-input.c
index a635c021f..2f373b373 100644
--- a/src/gui/gui-input.c
+++ b/src/gui/gui-input.c
@@ -1,7 +1,7 @@
/*
* gui-input.c - input functions (used by all GUI)
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -1540,10 +1540,65 @@ gui_input_jump_next_visited_buffer (struct t_gui_buffer *buffer)
*/
void
-gui_input_hotlist_clear (struct t_gui_buffer *buffer)
+gui_input_hotlist_clear (struct t_gui_buffer *buffer,
+ const char *str_level_mask)
{
- gui_hotlist_clear ();
- gui_hotlist_initial_buffer = buffer;
+ long level_mask;
+ char *error;
+ struct t_gui_hotlist *ptr_hotlist;
+ int priority;
+
+ if (str_level_mask)
+ {
+ if (strcmp (str_level_mask, "lowest") == 0)
+ {
+ /* clear only lowest priority currently in hotlist */
+ priority = GUI_HOTLIST_MAX + 1;
+ for (ptr_hotlist = gui_hotlist; ptr_hotlist;
+ ptr_hotlist = ptr_hotlist->next_hotlist)
+ {
+ if ((int)ptr_hotlist->priority < priority)
+ priority = ptr_hotlist->priority;
+ }
+ if (priority <= GUI_HOTLIST_MAX)
+ {
+ gui_hotlist_clear (1 << priority);
+ gui_hotlist_initial_buffer = buffer;
+ }
+ }
+ else if (strcmp (str_level_mask, "highest") == 0)
+ {
+ /* clear only highest priority currently in hotlist */
+ priority = GUI_HOTLIST_MIN - 1;
+ for (ptr_hotlist = gui_hotlist; ptr_hotlist;
+ ptr_hotlist = ptr_hotlist->next_hotlist)
+ {
+ if ((int)ptr_hotlist->priority > priority)
+ priority = ptr_hotlist->priority;
+ }
+ if (priority >= GUI_HOTLIST_MIN)
+ {
+ gui_hotlist_clear (1 << priority);
+ gui_hotlist_initial_buffer = buffer;
+ }
+ }
+ else
+ {
+ /* clear hotlist using a mask of levels */
+ error = NULL;
+ level_mask = strtol (str_level_mask, &error, 10);
+ if (error && !error[0] && (level_mask > 0))
+ {
+ gui_hotlist_clear ((int)level_mask);
+ gui_hotlist_initial_buffer = buffer;
+ }
+ }
+ }
+ else
+ {
+ gui_hotlist_clear (GUI_HOTLIST_MASK_MAX);
+ gui_hotlist_initial_buffer = buffer;
+ }
}
/*
diff --git a/src/gui/gui-input.h b/src/gui/gui-input.h
index 832c80671..415056e28 100644
--- a/src/gui/gui-input.h
+++ b/src/gui/gui-input.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -75,7 +75,8 @@ extern void gui_input_jump_smart (struct t_gui_buffer *buffer);
extern void gui_input_jump_last_buffer_displayed (struct t_gui_buffer *buffer);
extern void gui_input_jump_previously_visited_buffer (struct t_gui_buffer *buffer);
extern void gui_input_jump_next_visited_buffer (struct t_gui_buffer *buffer);
-extern void gui_input_hotlist_clear (struct t_gui_buffer *buffer);
+extern void gui_input_hotlist_clear (struct t_gui_buffer *buffer,
+ const char *level_mask);
extern void gui_input_grab_key (struct t_gui_buffer *buffer, int command,
const char *delay);
extern void gui_input_grab_mouse (struct t_gui_buffer *buffer, int area);
diff --git a/src/gui/gui-key.c b/src/gui/gui-key.c
index 97c50c5c3..51ae755e5 100644
--- a/src/gui/gui-key.c
+++ b/src/gui/gui-key.c
@@ -1,7 +1,7 @@
/*
* gui-key.c - keyboard functions (used by all GUI)
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -196,12 +196,14 @@ gui_key_grab_init (int grab_command, const char *delay)
*/
int
-gui_key_grab_end_timer_cb (void *data, int remaining_calls)
+gui_key_grab_end_timer_cb (const void *pointer, void *data,
+ int remaining_calls)
{
char *expanded_key, *expanded_key2;
struct t_gui_key *ptr_key;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) remaining_calls;
@@ -1292,7 +1294,7 @@ gui_key_pressed (const char *key_str)
if (gui_key_grab_count == 0)
{
hook_timer (NULL, gui_key_grab_delay, 0, 1,
- &gui_key_grab_end_timer_cb, NULL);
+ &gui_key_grab_end_timer_cb, NULL, NULL);
}
gui_key_grab_count++;
return 0;
@@ -1740,9 +1742,11 @@ gui_key_paste_check (int bracketed_paste)
*/
int
-gui_key_paste_bracketed_timer_cb (void *data, int remaining_calls)
+gui_key_paste_bracketed_timer_cb (const void *pointer, void *data,
+ int remaining_calls)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) remaining_calls;
@@ -1776,10 +1780,11 @@ void
gui_key_paste_bracketed_timer_add ()
{
gui_key_paste_bracketed_timer_remove ();
- gui_key_paste_bracketed_timer = hook_timer (NULL,
- CONFIG_INTEGER(config_look_paste_bracketed_timer_delay) * 1000,
- 0, 1,
- &gui_key_paste_bracketed_timer_cb, NULL);
+ gui_key_paste_bracketed_timer = hook_timer (
+ NULL,
+ CONFIG_INTEGER(config_look_paste_bracketed_timer_delay) * 1000,
+ 0, 1,
+ &gui_key_paste_bracketed_timer_cb, NULL, NULL);
}
/*
@@ -1816,7 +1821,8 @@ gui_key_paste_accept ()
* add final newline if there is not in pasted text
* (for at least 2 lines pasted)
*/
- if ((gui_key_get_paste_lines () > 1)
+ if (CONFIG_BOOLEAN(config_look_paste_auto_add_newline)
+ && (gui_key_get_paste_lines () > 1)
&& (gui_key_buffer_size > 0)
&& (gui_key_buffer[gui_key_buffer_size - 1] != '\r')
&& (gui_key_buffer[gui_key_buffer_size - 1] != '\n'))
@@ -1869,13 +1875,15 @@ gui_key_end ()
*/
struct t_hdata *
-gui_key_hdata_key_cb (void *data, const char *hdata_name)
+gui_key_hdata_key_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
int i;
char str_list[128];
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_key", "next_key",
diff --git a/src/gui/gui-key.h b/src/gui/gui-key.h
index e6af2d88a..acda6a991 100644
--- a/src/gui/gui-key.h
+++ b/src/gui/gui-key.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -129,7 +129,8 @@ extern void gui_key_paste_bracketed_stop ();
extern void gui_key_paste_accept ();
extern void gui_key_paste_cancel ();
extern void gui_key_end ();
-extern struct t_hdata *gui_key_hdata_key_cb (void *data,
+extern struct t_hdata *gui_key_hdata_key_cb (const void *pointer,
+ void *data,
const char *hdata_name);
extern int gui_key_add_to_infolist (struct t_infolist *infolist,
struct t_gui_key *key);
diff --git a/src/gui/gui-layout.c b/src/gui/gui-layout.c
index 14e33e489..d0a957239 100644
--- a/src/gui/gui-layout.c
+++ b/src/gui/gui-layout.c
@@ -1,7 +1,7 @@
/*
* gui-layout.c - layout functions (used by all GUI)
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -883,11 +883,13 @@ gui_layout_remove_all ()
*/
struct t_hdata *
-gui_layout_hdata_layout_buffer_cb (void *data, const char *hdata_name)
+gui_layout_hdata_layout_buffer_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_layout", "next_layout",
@@ -908,11 +910,13 @@ gui_layout_hdata_layout_buffer_cb (void *data, const char *hdata_name)
*/
struct t_hdata *
-gui_layout_hdata_layout_window_cb (void *data, const char *hdata_name)
+gui_layout_hdata_layout_window_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = hdata_new (NULL, hdata_name, NULL, NULL, 0, 0, NULL, NULL);
@@ -935,11 +939,13 @@ gui_layout_hdata_layout_window_cb (void *data, const char *hdata_name)
*/
struct t_hdata *
-gui_layout_hdata_layout_cb (void *data, const char *hdata_name)
+gui_layout_hdata_layout_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_layout", "next_layout",
diff --git a/src/gui/gui-layout.h b/src/gui/gui-layout.h
index 61d149128..24833a253 100644
--- a/src/gui/gui-layout.h
+++ b/src/gui/gui-layout.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -113,11 +113,14 @@ extern void gui_layout_store_on_exit ();
extern void gui_layout_free (struct t_gui_layout *layout);
extern void gui_layout_remove (struct t_gui_layout *layout);
extern void gui_layout_remove_all ();
-extern struct t_hdata *gui_layout_hdata_layout_buffer_cb (void *data,
+extern struct t_hdata *gui_layout_hdata_layout_buffer_cb (const void *pointer,
+ void *data,
const char *hdata_name);
-extern struct t_hdata *gui_layout_hdata_layout_window_cb (void *data,
+extern struct t_hdata *gui_layout_hdata_layout_window_cb (const void *pointer,
+ void *data,
const char *hdata_name);
-extern struct t_hdata *gui_layout_hdata_layout_cb (void *data,
+extern struct t_hdata *gui_layout_hdata_layout_cb (const void *pointer,
+ void *data,
const char *hdata_name);
extern int gui_layout_buffer_add_to_infolist (struct t_infolist *infolist,
struct t_gui_layout_buffer *layout_buffer);
diff --git a/src/gui/gui-line.c b/src/gui/gui-line.c
index 9b3ad32fe..e5c1d30f7 100644
--- a/src/gui/gui-line.c
+++ b/src/gui/gui-line.c
@@ -1,7 +1,7 @@
/*
* gui-line.c - line functions (used by all GUI)
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -1562,11 +1562,13 @@ gui_line_mix_buffers (struct t_gui_buffer *buffer)
*/
struct t_hdata *
-gui_line_hdata_lines_cb (void *data, const char *hdata_name)
+gui_line_hdata_lines_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = hdata_new (NULL, hdata_name, NULL, NULL, 0, 0, NULL, NULL);
@@ -1591,11 +1593,13 @@ gui_line_hdata_lines_cb (void *data, const char *hdata_name)
*/
struct t_hdata *
-gui_line_hdata_line_cb (void *data, const char *hdata_name)
+gui_line_hdata_line_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_line", "next_line",
@@ -1704,11 +1708,13 @@ gui_line_hdata_line_data_update_cb (void *data,
*/
struct t_hdata *
-gui_line_hdata_line_data_cb (void *data, const char *hdata_name)
+gui_line_hdata_line_data_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = hdata_new (NULL, hdata_name, NULL, NULL,
diff --git a/src/gui/gui-line.h b/src/gui/gui-line.h
index d8660f643..1089b9b3a 100644
--- a/src/gui/gui-line.h
+++ b/src/gui/gui-line.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -113,11 +113,14 @@ extern void gui_line_add_y (struct t_gui_buffer *buffer, int y,
const char *message);
extern void gui_line_clear (struct t_gui_line *line);
extern void gui_line_mix_buffers (struct t_gui_buffer *buffer);
-extern struct t_hdata *gui_line_hdata_lines_cb (void *data,
+extern struct t_hdata *gui_line_hdata_lines_cb (const void *pointer,
+ void *data,
const char *hdata_name);
-extern struct t_hdata *gui_line_hdata_line_cb (void *data,
+extern struct t_hdata *gui_line_hdata_line_cb (const void *pointer,
+ void *data,
const char *hdata_name);
-extern struct t_hdata *gui_line_hdata_line_data_cb (void *data,
+extern struct t_hdata *gui_line_hdata_line_data_cb (const void *pointer,
+ void *data,
const char *hdata_name);
extern int gui_line_add_to_infolist (struct t_infolist *infolist,
struct t_gui_lines *lines,
diff --git a/src/gui/gui-main.h b/src/gui/gui-main.h
index 251f8b7dc..13e164efd 100644
--- a/src/gui/gui-main.h
+++ b/src/gui/gui-main.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/gui/gui-mouse.c b/src/gui/gui-mouse.c
index b60c52a0e..2002162c1 100644
--- a/src/gui/gui-mouse.c
+++ b/src/gui/gui-mouse.c
@@ -1,7 +1,7 @@
/*
* gui-mouse.c - functions for mouse (used by all GUI)
*
- * Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/gui/gui-mouse.h b/src/gui/gui-mouse.h
index 41f703c97..b5315c79e 100644
--- a/src/gui/gui-mouse.h
+++ b/src/gui/gui-mouse.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/gui/gui-nick.c b/src/gui/gui-nick.c
new file mode 100644
index 000000000..899ee444f
--- /dev/null
+++ b/src/gui/gui-nick.c
@@ -0,0 +1,259 @@
+/*
+ * gui-nick.c - nick functions (used by all GUI)
+ *
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
+ *
+ * This file is part of WeeChat, the extensible chat client.
+ *
+ * WeeChat 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.
+ *
+ * WeeChat 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 WeeChat. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "../core/weechat.h"
+#include "../core/wee-config.h"
+#include "../core/wee-hashtable.h"
+#include "../core/wee-string.h"
+#include "../core/wee-utf8.h"
+#include "gui-nick.h"
+#include "gui-color.h"
+
+
+/*
+ * Hashes a nickname to find color.
+ *
+ * Returns a number which is the index of color in the nicks colors of option
+ * "weechat.color.chat_nick_colors".
+ */
+
+int
+gui_nick_hash_color (const char *nickname)
+{
+ unsigned long color;
+ const char *ptr_nick;
+
+ if (!nickname || !nickname[0])
+ return 0;
+
+ if (!config_nick_colors)
+ config_set_nick_colors ();
+
+ if (config_num_nick_colors == 0)
+ return 0;
+
+ ptr_nick = nickname;
+ color = 0;
+
+ switch (CONFIG_INTEGER(config_look_nick_color_hash))
+ {
+ case CONFIG_LOOK_NICK_COLOR_HASH_DJB2:
+ /* variant of djb2 hash */
+ color = 5381;
+ while (ptr_nick && ptr_nick[0])
+ {
+ color ^= (color << 5) + (color >> 2) + utf8_char_int (ptr_nick);
+ ptr_nick = utf8_next_char (ptr_nick);
+ }
+ break;
+ case CONFIG_LOOK_NICK_COLOR_HASH_SUM:
+ /* sum of letters */
+ color = 0;
+ while (ptr_nick && ptr_nick[0])
+ {
+ color += utf8_char_int (ptr_nick);
+ ptr_nick = utf8_next_char (ptr_nick);
+ }
+ break;
+ }
+
+ return (color % config_num_nick_colors);
+}
+
+/*
+ * Gets forced color for a nick.
+ *
+ * Returns the name of color (for example: "green"), NULL if no color is forced
+ * for nick.
+ */
+
+const char *
+gui_nick_get_forced_color (const char *nickname)
+{
+ const char *forced_color;
+ char *nick_lower;
+
+ if (!nickname || !nickname[0])
+ return NULL;
+
+ forced_color = hashtable_get (config_hashtable_nick_color_force, nickname);
+ if (forced_color)
+ return forced_color;
+
+ nick_lower = strdup (nickname);
+ if (nick_lower)
+ {
+ string_tolower (nick_lower);
+ forced_color = hashtable_get (config_hashtable_nick_color_force,
+ nick_lower);
+ free (nick_lower);
+ }
+
+ return forced_color;
+}
+
+/*
+ * Duplicates a nick and stops at first char in list (using option
+ * weechat.look.nick_color_stop_chars).
+ *
+ * Note: result must be freed after use.
+ */
+
+char *
+gui_nick_strdup_for_color (const char *nickname)
+{
+ int char_size, other_char_seen;
+ char *result, *pos, utf_char[16];
+
+ if (!nickname)
+ return NULL;
+
+ result = malloc (strlen (nickname) + 1);
+ pos = result;
+ other_char_seen = 0;
+ while (nickname[0])
+ {
+ char_size = utf8_char_size (nickname);
+ memcpy (utf_char, nickname, char_size);
+ utf_char[char_size] = '\0';
+
+ if (strstr (CONFIG_STRING(config_look_nick_color_stop_chars),
+ utf_char))
+ {
+ if (other_char_seen)
+ {
+ pos[0] = '\0';
+ return result;
+ }
+ }
+ else
+ {
+ other_char_seen = 1;
+ }
+ memcpy (pos, utf_char, char_size);
+ pos += char_size;
+
+ nickname += char_size;
+ }
+ pos[0] = '\0';
+ return result;
+}
+
+/*
+ * Finds a color code for a nick (according to nick letters).
+ *
+ * Returns a WeeChat color code (that can be used for display).
+ */
+
+const char *
+gui_nick_find_color (const char *nickname)
+{
+ int color;
+ char *nickname2;
+ const char *forced_color, *str_color;
+
+ if (!nickname || !nickname[0])
+ return gui_color_get_custom ("default");
+
+ if (!config_nick_colors)
+ config_set_nick_colors ();
+
+ if (config_num_nick_colors == 0)
+ return gui_color_get_custom ("default");
+
+ nickname2 = gui_nick_strdup_for_color (nickname);
+
+ /* look if color is forced */
+ forced_color = gui_nick_get_forced_color (
+ (nickname2) ? nickname2 : nickname);
+ if (forced_color)
+ {
+ forced_color = gui_color_get_custom (forced_color);
+ if (forced_color && forced_color[0])
+ {
+ if (nickname2)
+ free (nickname2);
+ return forced_color;
+ }
+ }
+
+ /* hash nickname to get color */
+ color = gui_nick_hash_color ((nickname2) ? nickname2 : nickname);
+
+ if (nickname2)
+ free (nickname2);
+
+ /* return color */
+ str_color = gui_color_get_custom (config_nick_colors[color]);
+ return (str_color[0]) ? str_color : gui_color_get_custom ("default");
+}
+
+/*
+ * Finds a color name for a nick (according to nick letters).
+ *
+ * Returns the name of a color (for example: "green").
+ */
+
+const char *
+gui_nick_find_color_name (const char *nickname)
+{
+ int color;
+ char *nickname2;
+ const char *forced_color;
+ static char *default_color = "default";
+
+ if (!nickname || !nickname[0])
+ return default_color;
+
+ if (!config_nick_colors)
+ config_set_nick_colors ();
+
+ if (config_num_nick_colors == 0)
+ return default_color;
+
+ nickname2 = gui_nick_strdup_for_color (nickname);
+
+ /* look if color is forced */
+ forced_color = gui_nick_get_forced_color (
+ (nickname2) ? nickname2 : nickname);
+ if (forced_color)
+ {
+ if (nickname2)
+ free (nickname2);
+ return forced_color;
+ }
+
+ /* hash nickname to get color */
+ color = gui_nick_hash_color ((nickname2) ? nickname2 : nickname);
+
+ if (nickname2)
+ free (nickname2);
+
+ /* return color name */
+ return config_nick_colors[color];
+}
diff --git a/src/gui/gui-nick.h b/src/gui/gui-nick.h
new file mode 100644
index 000000000..7c6bf896f
--- /dev/null
+++ b/src/gui/gui-nick.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
+ *
+ * This file is part of WeeChat, the extensible chat client.
+ *
+ * WeeChat 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.
+ *
+ * WeeChat 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 WeeChat. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef WEECHAT_GUI_NICK_H
+#define WEECHAT_GUI_NICK_H 1
+
+extern const char *gui_nick_find_color (const char *nickname);
+extern const char *gui_nick_find_color_name (const char *nickname);
+
+#endif /* WEECHAT_GUI_NICK_H */
diff --git a/src/gui/gui-nicklist.c b/src/gui/gui-nicklist.c
index 7b533a80b..c81cd3c82 100644
--- a/src/gui/gui-nicklist.c
+++ b/src/gui/gui-nicklist.c
@@ -1,7 +1,7 @@
/*
* gui-nicklist.c - nicklist functions (used by all GUI)
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -98,8 +98,7 @@ gui_nicklist_send_hsignal (const char *signal, struct t_gui_buffer *buffer,
gui_nicklist_hsignal = hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_POINTER,
- NULL,
- NULL);
+ NULL, NULL);
}
if (!gui_nicklist_hsignal)
@@ -394,7 +393,8 @@ gui_nicklist_search_nick (struct t_gui_buffer *buffer,
{
if (buffer->nickcmp_callback)
{
- if ((buffer->nickcmp_callback) (buffer->nickcmp_callback_data,
+ if ((buffer->nickcmp_callback) (buffer->nickcmp_callback_pointer,
+ buffer->nickcmp_callback_data,
buffer,
ptr_nick->name,
name) == 0)
@@ -1036,11 +1036,13 @@ gui_nicklist_nick_set (struct t_gui_buffer *buffer,
*/
struct t_hdata *
-gui_nicklist_hdata_nick_group_cb (void *data, const char *hdata_name)
+gui_nicklist_hdata_nick_group_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_group", "next_group",
@@ -1067,11 +1069,13 @@ gui_nicklist_hdata_nick_group_cb (void *data, const char *hdata_name)
*/
struct t_hdata *
-gui_nicklist_hdata_nick_cb (void *data, const char *hdata_name)
+gui_nicklist_hdata_nick_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_nick", "next_nick",
diff --git a/src/gui/gui-nicklist.h b/src/gui/gui-nicklist.h
index 81b815ec6..1a2e316ca 100644
--- a/src/gui/gui-nicklist.h
+++ b/src/gui/gui-nicklist.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -108,9 +108,11 @@ extern void *gui_nicklist_nick_get_pointer (struct t_gui_buffer *buffer,
extern void gui_nicklist_nick_set (struct t_gui_buffer *buffer,
struct t_gui_nick *nick,
const char *property, const char *value);
-extern struct t_hdata *gui_nicklist_hdata_nick_group_cb (void *data,
+extern struct t_hdata *gui_nicklist_hdata_nick_group_cb (const void *pointer,
+ void *data,
const char *hdata_name);
-extern struct t_hdata *gui_nicklist_hdata_nick_cb (void *data,
+extern struct t_hdata *gui_nicklist_hdata_nick_cb (const void *pointer,
+ void *data,
const char *hdata_name);
extern int gui_nicklist_add_to_infolist (struct t_infolist *infolist,
struct t_gui_buffer *buffer,
diff --git a/src/gui/gui-window.c b/src/gui/gui-window.c
index 825fd47ba..263fc938f 100644
--- a/src/gui/gui-window.c
+++ b/src/gui/gui-window.c
@@ -1,7 +1,7 @@
/*
* gui-window.c - window functions (used by all GUI)
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -465,41 +465,41 @@ gui_window_scroll_switch (struct t_gui_window *window,
{
struct t_gui_window_scroll *ptr_scroll, *new_scroll;
- if (window && buffer)
- {
- ptr_scroll = gui_window_scroll_search (window, buffer);
+ if (!window || !buffer)
+ return;
- /* scroll is already selected (first in list)? */
- if (ptr_scroll && (ptr_scroll == window->scroll))
- return;
+ ptr_scroll = gui_window_scroll_search (window, buffer);
- if (ptr_scroll)
- {
- /* scroll found, move it in first position */
- if (ptr_scroll->prev_scroll)
- (ptr_scroll->prev_scroll)->next_scroll = ptr_scroll->next_scroll;
- if (ptr_scroll->next_scroll)
- (ptr_scroll->next_scroll)->prev_scroll = ptr_scroll->prev_scroll;
- (window->scroll)->prev_scroll = ptr_scroll;
- ptr_scroll->prev_scroll = NULL;
- ptr_scroll->next_scroll = window->scroll;
- window->scroll = ptr_scroll;
- }
- else
+ /* scroll is already selected (first in list)? */
+ if (ptr_scroll && (ptr_scroll == window->scroll))
+ return;
+
+ if (ptr_scroll)
+ {
+ /* scroll found, move it in first position */
+ if (ptr_scroll->prev_scroll)
+ (ptr_scroll->prev_scroll)->next_scroll = ptr_scroll->next_scroll;
+ if (ptr_scroll->next_scroll)
+ (ptr_scroll->next_scroll)->prev_scroll = ptr_scroll->prev_scroll;
+ (window->scroll)->prev_scroll = ptr_scroll;
+ ptr_scroll->prev_scroll = NULL;
+ ptr_scroll->next_scroll = window->scroll;
+ window->scroll = ptr_scroll;
+ }
+ else
+ {
+ /* scroll not found, create one and add it at first position */
+ new_scroll = malloc (sizeof (*new_scroll));
+ if (new_scroll)
{
- /* scroll not found, create one and add it at first position */
- new_scroll = malloc (sizeof (*new_scroll));
- if (new_scroll)
- {
- gui_window_scroll_init (new_scroll, buffer);
- new_scroll->next_scroll = window->scroll;
- (window->scroll)->prev_scroll = new_scroll;
- window->scroll = new_scroll;
- }
+ gui_window_scroll_init (new_scroll, buffer);
+ new_scroll->next_scroll = window->scroll;
+ (window->scroll)->prev_scroll = new_scroll;
+ window->scroll = new_scroll;
}
-
- gui_window_scroll_remove_not_scrolled (window);
}
+
+ gui_window_scroll_remove_not_scrolled (window);
}
/*
@@ -512,12 +512,12 @@ gui_window_scroll_remove_buffer (struct t_gui_window *window,
{
struct t_gui_window_scroll *ptr_scroll;
- if (window && buffer)
- {
- ptr_scroll = gui_window_scroll_search (window, buffer);
- if (ptr_scroll)
- gui_window_scroll_free (window, ptr_scroll);
- }
+ if (!window || !buffer)
+ return;
+
+ ptr_scroll = gui_window_scroll_search (window, buffer);
+ if (ptr_scroll)
+ gui_window_scroll_free (window, ptr_scroll);
}
/*
@@ -738,37 +738,37 @@ gui_window_search_with_buffer (struct t_gui_buffer *buffer)
int
gui_window_get_integer (struct t_gui_window *window, const char *property)
{
- if (window && property)
- {
- if (string_strcasecmp (property, "number") == 0)
- return window->number;
- if (string_strcasecmp (property, "win_x") == 0)
- return window->win_x;
- if (string_strcasecmp (property, "win_y") == 0)
- return window->win_y;
- if (string_strcasecmp (property, "win_width") == 0)
- return window->win_width;
- if (string_strcasecmp (property, "win_height") == 0)
- return window->win_height;
- if (string_strcasecmp (property, "win_width_pct") == 0)
- return window->win_width_pct;
- if (string_strcasecmp (property, "win_height_pct") == 0)
- return window->win_height_pct;
- if (string_strcasecmp (property, "win_chat_x") == 0)
- return window->win_chat_x;
- if (string_strcasecmp (property, "win_chat_y") == 0)
- return window->win_chat_y;
- if (string_strcasecmp (property, "win_chat_width") == 0)
- return window->win_chat_width;
- if (string_strcasecmp (property, "win_chat_height") == 0)
- return window->win_chat_height;
- if (string_strcasecmp (property, "first_line_displayed") == 0)
- return window->scroll->first_line_displayed;
- if (string_strcasecmp (property, "scrolling") == 0)
- return window->scroll->scrolling;
- if (string_strcasecmp (property, "lines_after") == 0)
- return window->scroll->lines_after;
- }
+ if (!window || !property)
+ return 0;
+
+ if (string_strcasecmp (property, "number") == 0)
+ return window->number;
+ if (string_strcasecmp (property, "win_x") == 0)
+ return window->win_x;
+ if (string_strcasecmp (property, "win_y") == 0)
+ return window->win_y;
+ if (string_strcasecmp (property, "win_width") == 0)
+ return window->win_width;
+ if (string_strcasecmp (property, "win_height") == 0)
+ return window->win_height;
+ if (string_strcasecmp (property, "win_width_pct") == 0)
+ return window->win_width_pct;
+ if (string_strcasecmp (property, "win_height_pct") == 0)
+ return window->win_height_pct;
+ if (string_strcasecmp (property, "win_chat_x") == 0)
+ return window->win_chat_x;
+ if (string_strcasecmp (property, "win_chat_y") == 0)
+ return window->win_chat_y;
+ if (string_strcasecmp (property, "win_chat_width") == 0)
+ return window->win_chat_width;
+ if (string_strcasecmp (property, "win_chat_height") == 0)
+ return window->win_chat_height;
+ if (string_strcasecmp (property, "first_line_displayed") == 0)
+ return window->scroll->first_line_displayed;
+ if (string_strcasecmp (property, "scrolling") == 0)
+ return window->scroll->scrolling;
+ if (string_strcasecmp (property, "lines_after") == 0)
+ return window->scroll->lines_after;
return 0;
}
@@ -780,9 +780,8 @@ gui_window_get_integer (struct t_gui_window *window, const char *property)
const char *
gui_window_get_string (struct t_gui_window *window, const char *property)
{
- if (window && property)
- {
- }
+ if (!window || !property)
+ return NULL;
return NULL;
}
@@ -817,6 +816,9 @@ void
gui_window_set_layout_plugin_name (struct t_gui_window *window,
const char *plugin_name)
{
+ if (!window)
+ return;
+
if (window->layout_plugin_name)
{
free (window->layout_plugin_name);
@@ -835,6 +837,9 @@ void
gui_window_set_layout_buffer_name (struct t_gui_window *window,
const char *buffer_name)
{
+ if (!window)
+ return;
+
if (window->layout_buffer_name)
{
free (window->layout_buffer_name);
@@ -852,8 +857,11 @@ gui_window_set_layout_buffer_name (struct t_gui_window *window,
void
gui_window_coords_init_line (struct t_gui_window *window, int line)
{
- if (!window->coords || (line < 0) || (line >= window->coords_size))
+ if (!window || !window->coords || (line < 0)
+ || (line >= window->coords_size))
+ {
return;
+ }
window->coords[line].line = NULL;
window->coords[line].data = NULL;
@@ -876,7 +884,7 @@ gui_window_coords_remove_line (struct t_gui_window *window,
{
int i;
- if (!window->coords)
+ if (!window || !window->coords)
return;
for (i = 0; i < window->coords_size; i++)
@@ -897,7 +905,7 @@ gui_window_coords_remove_line_data (struct t_gui_window *window,
{
int i;
- if (!window->coords)
+ if (!window || !window->coords)
return;
for (i = 0; i < window->coords_size; i++)
@@ -919,6 +927,9 @@ gui_window_coords_alloc (struct t_gui_window *window)
{
int i;
+ if (!window)
+ return;
+
if (window->coords && (window->coords_size != window->win_chat_height))
{
free (window->coords);
@@ -947,6 +958,9 @@ gui_window_free (struct t_gui_window *window)
struct t_gui_window *ptr_win, *old_current_window;
int i;
+ if (!window)
+ return;
+
old_current_window = gui_current_window;
(void) hook_signal_send ("window_closing",
@@ -1021,7 +1035,7 @@ gui_window_free (struct t_gui_window *window)
void
gui_window_switch_previous (struct t_gui_window *window)
{
- if (!gui_init_ok)
+ if (!gui_init_ok || !window)
return;
gui_window_switch ((window->prev_window) ?
@@ -1035,7 +1049,7 @@ gui_window_switch_previous (struct t_gui_window *window)
void
gui_window_switch_next (struct t_gui_window *window)
{
- if (!gui_init_ok)
+ if (!gui_init_ok || !window)
return;
gui_window_switch ((window->next_window) ?
@@ -1068,7 +1082,7 @@ gui_window_switch_by_buffer (struct t_gui_window *window, int buffer_number)
{
struct t_gui_window *ptr_win;
- if (!gui_init_ok)
+ if (!gui_init_ok || !window)
return;
ptr_win = (window->next_window) ? window->next_window : gui_windows;
@@ -1098,7 +1112,7 @@ gui_window_scroll (struct t_gui_window *window, char *scroll)
struct t_gui_line *ptr_line;
struct tm *date_tmp, line_date, old_line_date;
- if (!window->buffer->lines->first_line)
+ if (!window || !window->buffer->lines->first_line)
return;
direction = 1;
@@ -1345,61 +1359,61 @@ gui_window_scroll_horiz (struct t_gui_window *window, char *scroll)
char saved_char, *pos, *error;
long number;
- if (window->buffer->lines->first_line)
- {
- direction = 1;
- number = 0;
- percentage = 0;
+ if (!window || !window->buffer->lines->first_line)
+ return;
- /* search direction */
- if (scroll[0] == '-')
- {
- direction = -1;
- scroll++;
- }
- else if (scroll[0] == '+')
- {
- direction = +1;
- scroll++;
- }
+ direction = 1;
+ number = 0;
+ percentage = 0;
- /* search number and percentage */
- pos = scroll;
- while (pos && pos[0] && isdigit ((unsigned char)pos[0]))
- {
- pos++;
- }
- if (pos && (pos > scroll))
- {
- percentage = (pos[0] == '%') ? 1 : 0;
- saved_char = pos[0];
- pos[0] = '\0';
- error = NULL;
- number = strtol (scroll, &error, 10);
- if (!error || error[0])
- number = 0;
- pos[0] = saved_char;
- }
+ /* search direction */
+ if (scroll[0] == '-')
+ {
+ direction = -1;
+ scroll++;
+ }
+ else if (scroll[0] == '+')
+ {
+ direction = +1;
+ scroll++;
+ }
- /* for percentage, compute number of columns */
- if (percentage)
- {
- number = (window->win_chat_width * number) / 100;
- }
+ /* search number and percentage */
+ pos = scroll;
+ while (pos && pos[0] && isdigit ((unsigned char)pos[0]))
+ {
+ pos++;
+ }
+ if (pos && (pos > scroll))
+ {
+ percentage = (pos[0] == '%') ? 1 : 0;
+ saved_char = pos[0];
+ pos[0] = '\0';
+ error = NULL;
+ number = strtol (scroll, &error, 10);
+ if (!error || error[0])
+ number = 0;
+ pos[0] = saved_char;
+ }
- /* number must be different from 0 */
- if (number == 0)
- return;
+ /* for percentage, compute number of columns */
+ if (percentage)
+ {
+ number = (window->win_chat_width * number) / 100;
+ }
- /* do the horizontal scroll! */
- start_col = window->scroll->start_col + (number * direction);
- if (start_col < 0)
- start_col = 0;
- if (start_col != window->scroll->start_col)
- {
- window->scroll->start_col = start_col;
- gui_buffer_ask_chat_refresh (window->buffer, 2);
- }
+ /* number must be different from 0 */
+ if (number == 0)
+ return;
+
+ /* do the horizontal scroll! */
+ start_col = window->scroll->start_col + (number * direction);
+ if (start_col < 0)
+ start_col = 0;
+ if (start_col != window->scroll->start_col)
+ {
+ window->scroll->start_col = start_col;
+ gui_buffer_ask_chat_refresh (window->buffer, 2);
}
}
@@ -1412,6 +1426,9 @@ gui_window_scroll_previous_highlight (struct t_gui_window *window)
{
struct t_gui_line *ptr_line;
+ if (!window)
+ return;
+
if ((window->buffer->type == GUI_BUFFER_TYPE_FORMATTED)
&& (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED))
{
@@ -1447,6 +1464,9 @@ gui_window_scroll_next_highlight (struct t_gui_window *window)
{
struct t_gui_line *ptr_line;
+ if (!window)
+ return;
+
if ((window->buffer->type == GUI_BUFFER_TYPE_FORMATTED)
&& (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED))
{
@@ -1480,6 +1500,9 @@ gui_window_scroll_next_highlight (struct t_gui_window *window)
void
gui_window_scroll_unread (struct t_gui_window *window)
{
+ if (!window)
+ return;
+
if (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)
{
if (CONFIG_STRING(config_look_read_marker) &&
@@ -1519,6 +1542,9 @@ gui_window_search_text (struct t_gui_window *window)
{
struct t_gui_line *ptr_line;
+ if (!window)
+ return 0;
+
if (window->buffer->text_search == GUI_TEXT_SEARCH_BACKWARD)
{
if (window->buffer->lines->first_line
@@ -1577,6 +1603,9 @@ void
gui_window_search_start (struct t_gui_window *window,
struct t_gui_line *text_search_start_line)
{
+ if (!window)
+ return;
+
window->scroll->text_search_start_line = text_search_start_line;
window->buffer->text_search =
(window->buffer->type == GUI_BUFFER_TYPE_FORMATTED) ?
@@ -1630,6 +1659,9 @@ gui_window_search_start (struct t_gui_window *window,
void
gui_window_search_restart (struct t_gui_window *window)
{
+ if (!window)
+ return;
+
window->scroll->start_line = window->scroll->text_search_start_line;
window->scroll->start_line_pos = 0;
window->buffer->text_search =
@@ -1658,6 +1690,9 @@ gui_window_search_restart (struct t_gui_window *window)
void
gui_window_search_end (struct t_gui_window *window)
{
+ if (!window)
+ return;
+
window->buffer->text_search = GUI_TEXT_SEARCH_DISABLED;
window->buffer->text_search = 0;
if (window->buffer->text_search_regex_compiled)
@@ -1686,6 +1721,9 @@ gui_window_search_end (struct t_gui_window *window)
void
gui_window_search_stop_here (struct t_gui_window *window)
{
+ if (!window)
+ return;
+
gui_window_search_end (window);
window->scroll->text_search_start_line = NULL;
gui_buffer_ask_chat_refresh (window->buffer, 2);
@@ -1698,6 +1736,9 @@ gui_window_search_stop_here (struct t_gui_window *window)
void
gui_window_search_stop (struct t_gui_window *window)
{
+ if (!window)
+ return;
+
gui_window_search_end (window);
window->scroll->start_line = window->scroll->text_search_start_line;
window->scroll->start_line_pos = 0;
@@ -1715,7 +1756,7 @@ gui_window_zoom (struct t_gui_window *window)
{
struct t_gui_layout *ptr_layout;
- if (!gui_init_ok)
+ if (!gui_init_ok || !window)
return;
ptr_layout = gui_layout_search (GUI_LAYOUT_ZOOM);
@@ -1756,11 +1797,13 @@ gui_window_zoom (struct t_gui_window *window)
*/
struct t_hdata *
-gui_window_hdata_window_cb (void *data, const char *hdata_name)
+gui_window_hdata_window_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_window", "next_window",
@@ -1803,11 +1846,13 @@ gui_window_hdata_window_cb (void *data, const char *hdata_name)
*/
struct t_hdata *
-gui_window_hdata_window_scroll_cb (void *data, const char *hdata_name)
+gui_window_hdata_window_scroll_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_scroll", "next_scroll",
@@ -1833,11 +1878,13 @@ gui_window_hdata_window_scroll_cb (void *data, const char *hdata_name)
*/
struct t_hdata *
-gui_window_hdata_window_tree_cb (void *data, const char *hdata_name)
+gui_window_hdata_window_tree_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = hdata_new (NULL, hdata_name, NULL, NULL, 0, 0, NULL, NULL);
diff --git a/src/gui/gui-window.h b/src/gui/gui-window.h
index f0f9387ec..cea5c5a37 100644
--- a/src/gui/gui-window.h
+++ b/src/gui/gui-window.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -190,11 +190,14 @@ extern void gui_window_search_stop_here (struct t_gui_window *window);
extern void gui_window_search_stop (struct t_gui_window *window);
extern int gui_window_search_text (struct t_gui_window *window);
extern void gui_window_zoom (struct t_gui_window *window);
-extern struct t_hdata *gui_window_hdata_window_cb (void *data,
+extern struct t_hdata *gui_window_hdata_window_cb (const void *pointer,
+ void *data,
const char *hdata_name);
-extern struct t_hdata *gui_window_hdata_window_scroll_cb (void *data,
+extern struct t_hdata *gui_window_hdata_window_scroll_cb (const void *pointer,
+ void *data,
const char *hdata_name);
-extern struct t_hdata *gui_window_hdata_window_tree_cb (void *data,
+extern struct t_hdata *gui_window_hdata_window_tree_cb (const void *pointer,
+ void *data,
const char *hdata_name);
extern int gui_window_add_to_infolist (struct t_infolist *infolist,
struct t_gui_window *window);
diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt
index ce7546859..d10fd58f2 100644
--- a/src/plugins/CMakeLists.txt
+++ b/src/plugins/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
# Copyright (C) 2009 Emmanuel Bouthenot <kolter@openics.org>
#
# This file is part of WeeChat, the extensible chat client.
@@ -26,8 +26,7 @@ plugin-config.h plugin-config.c)
set(LIB_PLUGINS_SCRIPTS_SRC
plugin-script.c plugin-script.h
-plugin-script-api.c plugin-script-api.h
-plugin-script-callback.c plugin-script-callback.h)
+plugin-script-api.c plugin-script-api.h)
include_directories(${CMAKE_BINARY_DIR})
add_library(weechat_plugins STATIC ${LIB_PLUGINS_SRC})
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 4836aec07..20a29cc19 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
# Copyright (C) 2006-2009 Emmanuel Bouthenot <kolter@openics.org>
#
# This file is part of WeeChat, the extensible chat client.
@@ -34,8 +34,6 @@ noinst_LTLIBRARIES = lib_weechat_plugins_scripts.la
lib_weechat_plugins_scripts_la_SOURCES = plugin-script.c \
plugin-script.h \
- plugin-script-callback.c \
- plugin-script-callback.h \
plugin-script-api.c \
plugin-script-api.h
diff --git a/src/plugins/alias/CMakeLists.txt b/src/plugins/alias/CMakeLists.txt
index 7214efbc3..8f1c39958 100644
--- a/src/plugins/alias/CMakeLists.txt
+++ b/src/plugins/alias/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/alias/Makefile.am b/src/plugins/alias/Makefile.am
index 0214ef60d..fb9cffa96 100644
--- a/src/plugins/alias/Makefile.am
+++ b/src/plugins/alias/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/alias/alias-command.c b/src/plugins/alias/alias-command.c
index 74c1964ff..f492faaa5 100644
--- a/src/plugins/alias/alias-command.c
+++ b/src/plugins/alias/alias-command.c
@@ -1,7 +1,7 @@
/*
* alias-command.c - alias commands
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -76,7 +76,8 @@ alias_command_add (const char *alias_name, const char *command,
*/
int
-alias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
+alias_command_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer, int argc,
char **argv, char **argv_eol)
{
char *ptr_alias_name;
@@ -85,6 +86,7 @@ alias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
int alias_found, i;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
@@ -123,11 +125,36 @@ alias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
weechat_printf (NULL, _("All aliases:"));
}
}
- weechat_printf (NULL, " %s %s=>%s %s",
- ptr_alias->name,
- weechat_color ("chat_delimiters"),
- weechat_color ("chat"),
- ptr_alias->command);
+ ptr_option = weechat_config_search_option (
+ alias_config_file,
+ alias_config_section_completion,
+ ptr_alias->name);
+ if (ptr_option)
+ {
+ weechat_printf (
+ NULL,
+ " %s %s=>%s %s %s(%s%s %s%s)%s",
+ ptr_alias->name,
+ weechat_color ("chat_delimiters"),
+ weechat_color ("chat"),
+ ptr_alias->command,
+ weechat_color ("chat_delimiters"),
+ weechat_color ("chat"),
+ _("completion:"),
+ weechat_config_string (ptr_option),
+ weechat_color ("chat_delimiters"),
+ weechat_color ("chat"));
+ }
+ else
+ {
+ weechat_printf (
+ NULL,
+ " %s %s=>%s %s",
+ ptr_alias->name,
+ weechat_color ("chat_delimiters"),
+ weechat_color ("chat"),
+ ptr_alias->command);
+ }
alias_found = 1;
}
}
@@ -190,7 +217,7 @@ alias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
ptr_option = weechat_config_search_option (
alias_config_file,
alias_config_section_cmd,
- ptr_alias_name);
+ ptr_alias_name);
if (ptr_option)
weechat_config_option_free (ptr_option);
ptr_option = weechat_config_search_option (
@@ -262,5 +289,5 @@ alias_command_init ()
" || add %(alias) %(commands)|%(alias_value)"
" || addcompletion %- %(alias) %(commands)|%(alias_value)"
" || del %(alias)|%*",
- &alias_command_cb, NULL);
+ &alias_command_cb, NULL, NULL);
}
diff --git a/src/plugins/alias/alias-command.h b/src/plugins/alias/alias-command.h
index 14b75dbef..033a9bf28 100644
--- a/src/plugins/alias/alias-command.h
+++ b/src/plugins/alias/alias-command.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2013-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/alias/alias-completion.c b/src/plugins/alias/alias-completion.c
index 44a590abc..fd90b1c5d 100644
--- a/src/plugins/alias/alias-completion.c
+++ b/src/plugins/alias/alias-completion.c
@@ -1,7 +1,7 @@
/*
* alias-completion.c - completion for alias commands
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -32,13 +32,15 @@
*/
int
-alias_completion_alias_cb (void *data, const char *completion_item,
+alias_completion_alias_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
struct t_alias *ptr_alias;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -58,7 +60,8 @@ alias_completion_alias_cb (void *data, const char *completion_item,
*/
int
-alias_completion_alias_value_cb (void *data, const char *completion_item,
+alias_completion_alias_value_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
@@ -68,6 +71,7 @@ alias_completion_alias_value_cb (void *data, const char *completion_item,
struct t_alias *ptr_alias;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -110,7 +114,7 @@ void
alias_completion_init ()
{
weechat_hook_completion ("alias", N_("list of aliases"),
- &alias_completion_alias_cb, NULL);
+ &alias_completion_alias_cb, NULL, NULL);
weechat_hook_completion ("alias_value", N_("value of alias"),
- &alias_completion_alias_value_cb, NULL);
+ &alias_completion_alias_value_cb, NULL, NULL);
}
diff --git a/src/plugins/alias/alias-completion.h b/src/plugins/alias/alias-completion.h
index eb5ca1e0d..3808c9319 100644
--- a/src/plugins/alias/alias-completion.h
+++ b/src/plugins/alias/alias-completion.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2013-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/alias/alias-config.c b/src/plugins/alias/alias-config.c
index 2a892649c..1ad8780c3 100644
--- a/src/plugins/alias/alias-config.c
+++ b/src/plugins/alias/alias-config.c
@@ -1,7 +1,7 @@
/*
* alias-config.c - alias configuration options (file alias.conf)
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -78,11 +78,13 @@ char *alias_default_completion[][2] =
*/
void
-alias_config_cmd_change_cb (void *data, struct t_config_option *option)
+alias_config_cmd_change_cb (const void *pointer, void *data,
+ struct t_config_option *option)
{
struct t_config_option *ptr_option_completion;
/* make C compiler happy */
+ (void) pointer;
(void) data;
ptr_option_completion = weechat_config_search_option (alias_config_file,
@@ -100,12 +102,14 @@ alias_config_cmd_change_cb (void *data, struct t_config_option *option)
*/
void
-alias_config_cmd_delete_cb (void *data, struct t_config_option *option)
+alias_config_cmd_delete_cb (const void *pointer, void *data,
+ struct t_config_option *option)
{
struct t_config_option *ptr_option_completion;
struct t_alias *ptr_alias;
/* make C compiler happy */
+ (void) pointer;
(void) data;
ptr_option_completion = weechat_config_search_option (alias_config_file,
@@ -125,11 +129,13 @@ alias_config_cmd_delete_cb (void *data, struct t_config_option *option)
*/
void
-alias_config_completion_change_cb (void *data, struct t_config_option *option)
+alias_config_completion_change_cb (const void *pointer, void *data,
+ struct t_config_option *option)
{
struct t_alias *ptr_alias;
/* make C compiler happy */
+ (void) pointer;
(void) data;
ptr_alias = alias_search (weechat_config_option_get_pointer (option, "name"));
@@ -145,11 +151,13 @@ alias_config_completion_change_cb (void *data, struct t_config_option *option)
*/
void
-alias_config_completion_delete_cb (void *data, struct t_config_option *option)
+alias_config_completion_delete_cb (const void *pointer, void *data,
+ struct t_config_option *option)
{
struct t_alias *ptr_alias;
/* make C compiler happy */
+ (void) pointer;
(void) data;
ptr_alias = alias_search (weechat_config_option_get_pointer (option, "name"));
@@ -164,9 +172,11 @@ alias_config_completion_delete_cb (void *data, struct t_config_option *option)
*/
int
-alias_config_reload (void *data, struct t_config_file *config_file)
+alias_config_reload (const void *pointer, void *data,
+ struct t_config_file *config_file)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
weechat_config_section_free_options (alias_config_section_cmd);
@@ -181,13 +191,14 @@ alias_config_reload (void *data, struct t_config_file *config_file)
*/
int
-alias_config_cmd_write_default_cb (void *data,
+alias_config_cmd_write_default_cb (const void *pointer, void *data,
struct t_config_file *config_file,
const char *section_name)
{
int i;
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (!weechat_config_write_line (config_file, section_name, NULL))
@@ -214,9 +225,9 @@ alias_config_cmd_new_option (const char *name, const char *command)
weechat_config_new_option (alias_config_file, alias_config_section_cmd,
name, "string", NULL,
NULL, 0, 0, NULL, command, 0,
- NULL, NULL,
- &alias_config_cmd_change_cb, NULL,
- &alias_config_cmd_delete_cb, NULL);
+ NULL, NULL, NULL,
+ &alias_config_cmd_change_cb, NULL, NULL,
+ &alias_config_cmd_delete_cb, NULL, NULL);
}
/*
@@ -224,7 +235,7 @@ alias_config_cmd_new_option (const char *name, const char *command)
*/
int
-alias_config_cmd_create_option_cb (void *data,
+alias_config_cmd_create_option_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name, const char *value)
@@ -233,6 +244,7 @@ alias_config_cmd_create_option_cb (void *data,
int rc;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) config_file;
(void) section;
@@ -266,13 +278,14 @@ alias_config_cmd_create_option_cb (void *data,
*/
int
-alias_config_completion_write_default_cb (void *data,
+alias_config_completion_write_default_cb (const void *pointer, void *data,
struct t_config_file *config_file,
const char *section_name)
{
int i;
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (!weechat_config_write_line (config_file, section_name, NULL))
@@ -300,9 +313,9 @@ alias_config_completion_new_option (const char *name, const char *completion)
alias_config_section_completion,
name, "string", NULL,
NULL, 0, 0, NULL, completion, 0,
- NULL, NULL,
- &alias_config_completion_change_cb, NULL,
- &alias_config_completion_delete_cb, NULL);
+ NULL, NULL, NULL,
+ &alias_config_completion_change_cb, NULL, NULL,
+ &alias_config_completion_delete_cb, NULL, NULL);
}
/*
@@ -310,7 +323,7 @@ alias_config_completion_new_option (const char *name, const char *completion)
*/
int
-alias_config_completion_create_option_cb (void *data,
+alias_config_completion_create_option_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
@@ -319,6 +332,7 @@ alias_config_completion_create_option_cb (void *data,
struct t_alias *ptr_alias;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) config_file;
(void) section;
@@ -357,18 +371,19 @@ alias_config_init ()
struct t_config_section *ptr_section;
alias_config_file = weechat_config_new (ALIAS_CONFIG_NAME,
- &alias_config_reload, NULL);
+ &alias_config_reload, NULL, NULL);
if (!alias_config_file)
return 0;
/* cmd */
- ptr_section = weechat_config_new_section (alias_config_file, "cmd",
- 1, 1,
- NULL, NULL,
- NULL, NULL,
- &alias_config_cmd_write_default_cb, NULL,
- &alias_config_cmd_create_option_cb, NULL,
- NULL, NULL);
+ ptr_section = weechat_config_new_section (
+ alias_config_file, "cmd",
+ 1, 1,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ &alias_config_cmd_write_default_cb, NULL, NULL,
+ &alias_config_cmd_create_option_cb, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (alias_config_file);
@@ -377,13 +392,14 @@ alias_config_init ()
alias_config_section_cmd = ptr_section;
/* completion */
- ptr_section = weechat_config_new_section (alias_config_file, "completion",
- 1, 1,
- NULL, NULL,
- NULL, NULL,
- &alias_config_completion_write_default_cb, NULL,
- &alias_config_completion_create_option_cb, NULL,
- NULL, NULL);
+ ptr_section = weechat_config_new_section (
+ alias_config_file, "completion",
+ 1, 1,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ &alias_config_completion_write_default_cb, NULL, NULL,
+ &alias_config_completion_create_option_cb, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (alias_config_file);
diff --git a/src/plugins/alias/alias-config.h b/src/plugins/alias/alias-config.h
index 9d7ce25ec..714abfcde 100644
--- a/src/plugins/alias/alias-config.h
+++ b/src/plugins/alias/alias-config.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/alias/alias-info.c b/src/plugins/alias/alias-info.c
index f91a12487..484c6082b 100644
--- a/src/plugins/alias/alias-info.c
+++ b/src/plugins/alias/alias-info.c
@@ -1,7 +1,7 @@
/*
* alias-info.c - info and infolist hooks for alias plugin
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -30,28 +30,30 @@
*/
struct t_infolist *
-alias_info_infolist_alias_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+alias_info_infolist_alias_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
struct t_infolist *ptr_infolist;
struct t_alias *ptr_alias;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) infolist_name;
(void) arguments;
- if (pointer && !alias_valid (pointer))
+ if (obj_pointer && !alias_valid (obj_pointer))
return NULL;
ptr_infolist = weechat_infolist_new ();
if (!ptr_infolist)
return NULL;
- if (pointer)
+ if (obj_pointer)
{
/* build list with only one alias */
- if (!alias_add_to_infolist (ptr_infolist, pointer))
+ if (!alias_add_to_infolist (ptr_infolist, obj_pointer))
{
weechat_infolist_free (ptr_infolist);
return NULL;
@@ -90,5 +92,5 @@ alias_info_init ()
"alias", N_("list of aliases"),
N_("alias pointer (optional)"),
N_("alias name (wildcard \"*\" is allowed) (optional)"),
- &alias_info_infolist_alias_cb, NULL);
+ &alias_info_infolist_alias_cb, NULL, NULL);
}
diff --git a/src/plugins/alias/alias-info.h b/src/plugins/alias/alias-info.h
index 3d0a65ba1..a06373a74 100644
--- a/src/plugins/alias/alias-info.h
+++ b/src/plugins/alias/alias-info.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/alias/alias.c b/src/plugins/alias/alias.c
index d4e3126ff..961748757 100644
--- a/src/plugins/alias/alias.c
+++ b/src/plugins/alias/alias.c
@@ -1,7 +1,7 @@
/*
* alias.c - alias plugin for WeeChat: command aliases
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -337,7 +337,8 @@ alias_run_command (struct t_gui_buffer **buffer, const char *command)
*/
int
-alias_cb (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
+alias_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer, int argc, char **argv,
char **argv_eol)
{
struct t_alias *ptr_alias;
@@ -346,9 +347,10 @@ alias_cb (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
int some_args_replaced, length1, length2;
/* make C compiler happy */
+ (void) data;
(void) argv;
- ptr_alias = (struct t_alias *)data;
+ ptr_alias = (struct t_alias *)pointer;
if (ptr_alias->running)
{
@@ -545,7 +547,7 @@ alias_hook_command (struct t_alias *alias)
alias->command,
NULL, NULL,
(str_completion) ? str_completion : alias->completion,
- &alias_cb, alias);
+ &alias_cb, alias, NULL);
if (str_priority_name)
free (str_priority_name);
@@ -572,6 +574,33 @@ alias_update_completion (struct t_alias *alias, const char *completion)
}
/*
+ * Checks if an alias name is valid: it must not contain any slashes nor
+ * any spaces.
+ *
+ * Returns:
+ * 1: name is valid
+ * 0: name is invalid
+ */
+
+int
+alias_name_valid (const char *name)
+{
+ if (!name || !name[0])
+ return 0;
+
+ /* no spaces allowed */
+ if (strchr (name, ' '))
+ return 0;
+
+ /* no slashes allowed */
+ if (strchr (name, '/'))
+ return 0;
+
+ /* name is valid */
+ return 1;
+}
+
+/*
* Creates a new alias and adds it to alias list.
*
* Returns pointer to new alias, NULL if error.
@@ -582,7 +611,16 @@ alias_new (const char *name, const char *command, const char *completion)
{
struct t_alias *new_alias, *ptr_alias, *pos_alias;
- if (!name || !name[0] || !command || !command[0])
+ if (!alias_name_valid (name))
+ {
+ weechat_printf (NULL,
+ _("%s%s: invalid alias name: \"%s\""),
+ weechat_prefix ("error"), ALIAS_PLUGIN_NAME,
+ name);
+ return NULL;
+ }
+
+ if (!command || !command[0])
return NULL;
while (weechat_string_is_command_char (name))
diff --git a/src/plugins/alias/alias.h b/src/plugins/alias/alias.h
index 1fd47f378..58c78a8d4 100644
--- a/src/plugins/alias/alias.h
+++ b/src/plugins/alias/alias.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/aspell/CMakeLists.txt b/src/plugins/aspell/CMakeLists.txt
index 846ef4c4e..2002871af 100644
--- a/src/plugins/aspell/CMakeLists.txt
+++ b/src/plugins/aspell/CMakeLists.txt
@@ -1,6 +1,6 @@
#
# Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org>
-# Copyright (C) 2006-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2006-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/aspell/Makefile.am b/src/plugins/aspell/Makefile.am
index 70464ca3c..0e50bf45a 100644
--- a/src/plugins/aspell/Makefile.am
+++ b/src/plugins/aspell/Makefile.am
@@ -1,6 +1,6 @@
#
# Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org>
-# Copyright (C) 2006-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2006-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/aspell/weechat-aspell-bar-item.c b/src/plugins/aspell/weechat-aspell-bar-item.c
index f088cbf0c..efb73ae8c 100644
--- a/src/plugins/aspell/weechat-aspell-bar-item.c
+++ b/src/plugins/aspell/weechat-aspell-bar-item.c
@@ -2,7 +2,7 @@
* weechat-aspell-bar-item.c - bar items for aspell plugin
*
* Copyright (C) 2012 Nils Görs <weechatter@arcor.de>
- * Copyright (C) 2012-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2012-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -35,7 +35,8 @@
*/
char *
-weechat_aspell_bar_item_dict (void *data, struct t_gui_bar_item *item,
+weechat_aspell_bar_item_dict (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
struct t_gui_window *window,
struct t_gui_buffer *buffer,
struct t_hashtable *extra_info)
@@ -43,6 +44,7 @@ weechat_aspell_bar_item_dict (void *data, struct t_gui_bar_item *item,
const char *dict_list;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) window;
@@ -61,7 +63,8 @@ weechat_aspell_bar_item_dict (void *data, struct t_gui_bar_item *item,
*/
char *
-weechat_aspell_bar_item_suggest (void *data, struct t_gui_bar_item *item,
+weechat_aspell_bar_item_suggest (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
struct t_gui_window *window,
struct t_gui_buffer *buffer,
struct t_hashtable *extra_info)
@@ -71,6 +74,7 @@ weechat_aspell_bar_item_suggest (void *data, struct t_gui_bar_item *item,
int i, num_suggestions, length;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) window;
@@ -132,6 +136,8 @@ weechat_aspell_bar_item_suggest (void *data, struct t_gui_bar_item *item,
void
weechat_aspell_bar_item_init ()
{
- weechat_bar_item_new ("aspell_dict", &weechat_aspell_bar_item_dict, NULL);
- weechat_bar_item_new ("aspell_suggest", &weechat_aspell_bar_item_suggest, NULL);
+ weechat_bar_item_new ("aspell_dict",
+ &weechat_aspell_bar_item_dict, NULL, NULL);
+ weechat_bar_item_new ("aspell_suggest",
+ &weechat_aspell_bar_item_suggest, NULL, NULL);
}
diff --git a/src/plugins/aspell/weechat-aspell-command.c b/src/plugins/aspell/weechat-aspell-command.c
index 343467a36..740f5aac4 100644
--- a/src/plugins/aspell/weechat-aspell-command.c
+++ b/src/plugins/aspell/weechat-aspell-command.c
@@ -1,7 +1,7 @@
/*
* weechat-aspell-command.c - aspell commands
*
- * Copyright (C) 2013-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2013-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -330,7 +330,8 @@ end:
*/
int
-weechat_aspell_command_cb (void *data, struct t_gui_buffer *buffer,
+weechat_aspell_command_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
char *dicts;
@@ -339,6 +340,7 @@ weechat_aspell_command_cb (void *data, struct t_gui_buffer *buffer,
int number;
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (argc == 1)
@@ -499,5 +501,5 @@ weechat_aspell_command_init ()
" || setdict %(aspell_dicts)"
" || deldict"
" || addword",
- &weechat_aspell_command_cb, NULL);
+ &weechat_aspell_command_cb, NULL, NULL);
}
diff --git a/src/plugins/aspell/weechat-aspell-command.h b/src/plugins/aspell/weechat-aspell-command.h
index 1cbf8f391..920b00b3b 100644
--- a/src/plugins/aspell/weechat-aspell-command.h
+++ b/src/plugins/aspell/weechat-aspell-command.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2013-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/aspell/weechat-aspell-completion.c b/src/plugins/aspell/weechat-aspell-completion.c
index f0b3ef191..30917a012 100644
--- a/src/plugins/aspell/weechat-aspell-completion.c
+++ b/src/plugins/aspell/weechat-aspell-completion.c
@@ -1,7 +1,7 @@
/*
* weechat-aspell-completion.c - completion for aspell commands
*
- * Copyright (C) 2013-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2013-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -33,13 +33,15 @@
*/
int
-weechat_aspell_completion_langs_cb (void *data, const char *completion_item,
+weechat_aspell_completion_langs_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
int i;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -81,7 +83,7 @@ weechat_aspell_completion_enchant_add_dict_cb (const char *lang_tag,
*/
int
-weechat_aspell_completion_dicts_cb (void *data,
+weechat_aspell_completion_dicts_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -94,6 +96,7 @@ weechat_aspell_completion_dicts_cb (void *data,
#endif /* USE_ENCHANT */
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -129,8 +132,8 @@ weechat_aspell_completion_init ()
{
weechat_hook_completion ("aspell_langs",
N_("list of all languages supported by aspell"),
- &weechat_aspell_completion_langs_cb, NULL);
+ &weechat_aspell_completion_langs_cb, NULL, NULL);
weechat_hook_completion ("aspell_dicts",
N_("list of aspell installed dictionaries"),
- &weechat_aspell_completion_dicts_cb, NULL);
+ &weechat_aspell_completion_dicts_cb, NULL, NULL);
}
diff --git a/src/plugins/aspell/weechat-aspell-completion.h b/src/plugins/aspell/weechat-aspell-completion.h
index cba724bb4..afa15770a 100644
--- a/src/plugins/aspell/weechat-aspell-completion.h
+++ b/src/plugins/aspell/weechat-aspell-completion.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2013-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/aspell/weechat-aspell-config.c b/src/plugins/aspell/weechat-aspell-config.c
index ac381359d..b3a1bb11e 100644
--- a/src/plugins/aspell/weechat-aspell-config.c
+++ b/src/plugins/aspell/weechat-aspell-config.c
@@ -2,7 +2,7 @@
* weechat-aspell-config.c - aspell configuration options (file aspell.conf)
*
* Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org>
- * Copyright (C) 2006-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2006-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -61,13 +61,14 @@ int *weechat_aspell_length_commands_to_check = NULL;
*/
void
-weechat_aspell_config_change_commands (void *data,
+weechat_aspell_config_change_commands (const void *pointer, void *data,
struct t_config_option *option)
{
const char *value;
int i;
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (weechat_aspell_commands_to_check)
@@ -106,10 +107,11 @@ weechat_aspell_config_change_commands (void *data,
*/
void
-weechat_aspell_config_change_default_dict (void *data,
+weechat_aspell_config_change_default_dict (const void *pointer, void *data,
struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -123,9 +125,11 @@ weechat_aspell_config_change_default_dict (void *data,
*/
void
-weechat_aspell_config_change_enabled (void *data, struct t_config_option *option)
+weechat_aspell_config_change_enabled (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
aspell_enabled = weechat_config_boolean (option);
@@ -140,10 +144,11 @@ weechat_aspell_config_change_enabled (void *data, struct t_config_option *option
*/
void
-weechat_aspell_config_change_suggestions (void *data,
+weechat_aspell_config_change_suggestions (const void *pointer, void *data,
struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -155,10 +160,11 @@ weechat_aspell_config_change_suggestions (void *data,
*/
void
-weechat_aspell_config_dict_change (void *data,
+weechat_aspell_config_dict_change (const void *pointer, void *data,
struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -172,12 +178,13 @@ weechat_aspell_config_dict_change (void *data,
*/
int
-weechat_aspell_config_dict_delete_option (void *data,
+weechat_aspell_config_dict_delete_option (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) config_file;
(void) section;
@@ -196,7 +203,7 @@ weechat_aspell_config_dict_delete_option (void *data,
*/
int
-weechat_aspell_config_dict_create_option (void *data,
+weechat_aspell_config_dict_create_option (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
@@ -206,6 +213,7 @@ weechat_aspell_config_dict_create_option (void *data,
int rc;
/* make C compiler happy */
+ (void) pointer;
(void) data;
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
@@ -236,9 +244,9 @@ weechat_aspell_config_dict_create_option (void *data,
option_name, "string",
_("comma separated list of dictionaries to use on this buffer"),
NULL, 0, 0, "", value, 0,
- NULL, NULL,
- &weechat_aspell_config_dict_change, NULL,
- NULL, NULL);
+ NULL, NULL, NULL,
+ &weechat_aspell_config_dict_change, NULL, NULL,
+ NULL, NULL, NULL);
rc = (ptr_option) ?
WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
}
@@ -269,10 +277,11 @@ weechat_aspell_config_dict_create_option (void *data,
*/
void
-weechat_aspell_config_option_change (void *data,
+weechat_aspell_config_option_change (const void *pointer, void *data,
struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -286,12 +295,13 @@ weechat_aspell_config_option_change (void *data,
*/
int
-weechat_aspell_config_option_delete_option (void *data,
+weechat_aspell_config_option_delete_option (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) config_file;
(void) section;
@@ -310,7 +320,7 @@ weechat_aspell_config_option_delete_option (void *data,
*/
int
-weechat_aspell_config_option_create_option (void *data,
+weechat_aspell_config_option_create_option (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
@@ -320,6 +330,7 @@ weechat_aspell_config_option_create_option (void *data,
int rc;
/* make C compiler happy */
+ (void) pointer;
(void) data;
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
@@ -348,9 +359,9 @@ weechat_aspell_config_option_create_option (void *data,
_("option for aspell (for list of available options and "
"format, run command \"aspell config\" in a shell)"),
NULL, 0, 0, "", value, 0,
- NULL, NULL,
- &weechat_aspell_config_option_change, NULL,
- NULL, NULL);
+ NULL, NULL, NULL,
+ &weechat_aspell_config_option_change, NULL, NULL,
+ NULL, NULL, NULL);
rc = (ptr_option) ?
WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
}
@@ -395,7 +406,7 @@ weechat_aspell_config_get_dict (const char *name)
int
weechat_aspell_config_set_dict (const char *name, const char *value)
{
- return weechat_aspell_config_dict_create_option (NULL,
+ return weechat_aspell_config_dict_create_option (NULL, NULL,
weechat_aspell_config_file,
weechat_aspell_config_section_dict,
name,
@@ -416,16 +427,19 @@ weechat_aspell_config_init ()
struct t_config_section *ptr_section;
weechat_aspell_config_file = weechat_config_new (ASPELL_CONFIG_NAME,
- NULL, NULL);
+ NULL, NULL, NULL);
if (!weechat_aspell_config_file)
return 0;
/* color */
- ptr_section = weechat_config_new_section (weechat_aspell_config_file, "color",
- 0, 0,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL);
+ ptr_section = weechat_config_new_section (
+ weechat_aspell_config_file, "color",
+ 0, 0,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (weechat_aspell_config_file);
@@ -436,19 +450,24 @@ weechat_aspell_config_init ()
weechat_aspell_config_file, ptr_section,
"misspelled", "color",
N_("text color for misspelled words (input bar)"),
- NULL, 0, 0, "lightred", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "lightred", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
weechat_aspell_config_color_suggestions = weechat_config_new_option (
weechat_aspell_config_file, ptr_section,
"suggestions", "color",
N_("text color for suggestions on a misspelled word (status bar)"),
- NULL, 0, 0, "default", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "default", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
/* check */
- ptr_section = weechat_config_new_section (weechat_aspell_config_file, "check",
- 0, 0,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL);
+ ptr_section = weechat_config_new_section (
+ weechat_aspell_config_file, "check",
+ 0, 0,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (weechat_aspell_config_file);
@@ -463,7 +482,9 @@ weechat_aspell_config_init ()
NULL, 0, 0,
"ame,amsg,away,command,cycle,kick,kickban,me,msg,notice,part,query,"
"quit,topic", NULL, 0,
- NULL, NULL, &weechat_aspell_config_change_commands, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &weechat_aspell_config_change_commands, NULL, NULL,
+ NULL, NULL, NULL);
weechat_aspell_config_check_default_dict = weechat_config_new_option (
weechat_aspell_config_file, ptr_section,
"default_dict", "string",
@@ -471,24 +492,30 @@ weechat_aspell_config_init ()
"use when buffer has no dictionary defined (leave blank to disable "
"aspell on buffers for which you didn't explicitly enabled it)"),
NULL, 0, 0, "", NULL, 0,
- NULL, NULL, &weechat_aspell_config_change_default_dict, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &weechat_aspell_config_change_default_dict, NULL, NULL,
+ NULL, NULL, NULL);
weechat_aspell_config_check_during_search = weechat_config_new_option (
weechat_aspell_config_file, ptr_section,
"during_search", "boolean",
N_("check words during text search in buffer"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
weechat_aspell_config_check_enabled = weechat_config_new_option (
weechat_aspell_config_file, ptr_section,
"enabled", "boolean",
N_("enable aspell check for command line"),
NULL, 0, 0, "off", NULL, 0,
- NULL, NULL, &weechat_aspell_config_change_enabled, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &weechat_aspell_config_change_enabled, NULL, NULL,
+ NULL, NULL, NULL);
weechat_aspell_config_check_real_time = weechat_config_new_option (
weechat_aspell_config_file, ptr_section,
"real_time", "boolean",
N_("real-time spell checking of words (slower, disabled by default: "
"words are checked only if there's delimiter after)"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
weechat_aspell_config_check_suggestions = weechat_config_new_option (
weechat_aspell_config_file, ptr_section,
"suggestions", "integer",
@@ -496,22 +523,26 @@ weechat_aspell_config_init ()
"for each dictionary set in buffer (-1 = disable suggestions, "
"0 = display all possible suggestions in all languages)"),
NULL, -1, INT_MAX, "-1", NULL, 0,
- NULL, NULL, &weechat_aspell_config_change_suggestions, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &weechat_aspell_config_change_suggestions, NULL, NULL,
+ NULL, NULL, NULL);
weechat_aspell_config_check_word_min_length = weechat_config_new_option (
weechat_aspell_config_file, ptr_section,
"word_min_length", "integer",
N_("minimum length for a word to be spell checked (use 0 to check all "
"words)"),
- NULL, 0, INT_MAX, "2", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, INT_MAX, "2", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
/* dict */
- ptr_section = weechat_config_new_section (weechat_aspell_config_file, "dict",
- 1, 1,
- NULL, NULL,
- NULL, NULL,
- NULL, NULL,
- &weechat_aspell_config_dict_create_option, NULL,
- &weechat_aspell_config_dict_delete_option, NULL);
+ ptr_section = weechat_config_new_section (
+ weechat_aspell_config_file, "dict",
+ 1, 1,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ &weechat_aspell_config_dict_create_option, NULL, NULL,
+ &weechat_aspell_config_dict_delete_option, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (weechat_aspell_config_file);
@@ -521,13 +552,14 @@ weechat_aspell_config_init ()
weechat_aspell_config_section_dict = ptr_section;
/* option */
- ptr_section = weechat_config_new_section (weechat_aspell_config_file, "option",
- 1, 1,
- NULL, NULL,
- NULL, NULL,
- NULL, NULL,
- &weechat_aspell_config_option_create_option, NULL,
- &weechat_aspell_config_option_delete_option, NULL);
+ ptr_section = weechat_config_new_section (
+ weechat_aspell_config_file, "option",
+ 1, 1,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ &weechat_aspell_config_option_create_option, NULL, NULL,
+ &weechat_aspell_config_option_delete_option, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (weechat_aspell_config_file);
@@ -551,8 +583,8 @@ weechat_aspell_config_read ()
weechat_aspell_config_loading = 0;
if (rc == WEECHAT_CONFIG_READ_OK)
{
- weechat_aspell_config_change_commands (NULL,
- weechat_aspell_config_check_commands);
+ weechat_aspell_config_change_commands (
+ NULL, NULL, weechat_aspell_config_check_commands);
}
weechat_aspell_speller_remove_unused ();
diff --git a/src/plugins/aspell/weechat-aspell-config.h b/src/plugins/aspell/weechat-aspell-config.h
index 010350209..266af1774 100644
--- a/src/plugins/aspell/weechat-aspell-config.h
+++ b/src/plugins/aspell/weechat-aspell-config.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org>
- * Copyright (C) 2006-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2006-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/aspell/weechat-aspell-info.c b/src/plugins/aspell/weechat-aspell-info.c
index 8860c9bba..3e298c063 100644
--- a/src/plugins/aspell/weechat-aspell-info.c
+++ b/src/plugins/aspell/weechat-aspell-info.c
@@ -1,7 +1,7 @@
/*
* weechat-aspell-info.c - info for aspell plugin
*
- * Copyright (C) 2013-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2013-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -32,7 +32,8 @@
*/
const char *
-weechat_aspell_info_info_aspell_dict_cb (void *data, const char *info_name,
+weechat_aspell_info_info_aspell_dict_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
int rc;
@@ -41,6 +42,7 @@ weechat_aspell_info_info_aspell_dict_cb (void *data, const char *info_name,
const char *buffer_full_name;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
@@ -83,5 +85,5 @@ weechat_aspell_info_init ()
N_("comma-separated list of dictionaries used in buffer"),
N_("buffer pointer (\"0x12345678\") or buffer full name "
"(\"irc.freenode.#weechat\")"),
- &weechat_aspell_info_info_aspell_dict_cb, NULL);
+ &weechat_aspell_info_info_aspell_dict_cb, NULL, NULL);
}
diff --git a/src/plugins/aspell/weechat-aspell-info.h b/src/plugins/aspell/weechat-aspell-info.h
index e170709b8..f1b50bc7f 100644
--- a/src/plugins/aspell/weechat-aspell-info.h
+++ b/src/plugins/aspell/weechat-aspell-info.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2013-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/aspell/weechat-aspell-speller.c b/src/plugins/aspell/weechat-aspell-speller.c
index 460c7509c..65b236e3a 100644
--- a/src/plugins/aspell/weechat-aspell-speller.c
+++ b/src/plugins/aspell/weechat-aspell-speller.c
@@ -2,7 +2,7 @@
* weechat-aspell-speller.c - speller management for aspell plugin
*
* Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org>
- * Copyright (C) 2006-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2006-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -272,8 +272,7 @@ weechat_aspell_speller_remove_unused ()
used_spellers = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
if (!used_spellers)
return;
@@ -448,8 +447,7 @@ weechat_aspell_speller_init ()
weechat_aspell_spellers = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_POINTER,
- NULL,
- NULL);
+ NULL, NULL);
if (!weechat_aspell_spellers)
return 0;
weechat_hashtable_set_pointer (weechat_aspell_spellers,
@@ -459,8 +457,7 @@ weechat_aspell_speller_init ()
weechat_aspell_speller_buffer = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_POINTER,
WEECHAT_HASHTABLE_POINTER,
- NULL,
- NULL);
+ NULL, NULL);
if (!weechat_aspell_speller_buffer)
{
weechat_hashtable_free (weechat_aspell_spellers);
diff --git a/src/plugins/aspell/weechat-aspell-speller.h b/src/plugins/aspell/weechat-aspell-speller.h
index cc696f4e2..705afa553 100644
--- a/src/plugins/aspell/weechat-aspell-speller.h
+++ b/src/plugins/aspell/weechat-aspell-speller.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org>
- * Copyright (C) 2006-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2006-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/aspell/weechat-aspell.c b/src/plugins/aspell/weechat-aspell.c
index ae2775b2c..1513e2f51 100644
--- a/src/plugins/aspell/weechat-aspell.c
+++ b/src/plugins/aspell/weechat-aspell.c
@@ -2,7 +2,7 @@
* weechat-aspell.c - aspell plugin for WeeChat: color for misspelled words
*
* Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org>
- * Copyright (C) 2006-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2006-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2012 Nils Görs <weechatter@arcor.de>
*
* This file is part of WeeChat, the extensible chat client.
@@ -604,7 +604,8 @@ weechat_aspell_get_suggestions (struct t_aspell_speller_buffer *speller_buffer,
*/
char *
-weechat_aspell_modifier_cb (void *data, const char *modifier,
+weechat_aspell_modifier_cb (const void *pointer, void *data,
+ const char *modifier,
const char *modifier_data, const char *string)
{
long unsigned int value;
@@ -621,6 +622,7 @@ weechat_aspell_modifier_cb (void *data, const char *modifier,
int input_pos, current_pos, word_start_pos, word_end_pos, word_end_pos_valid;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) modifier;
@@ -932,10 +934,12 @@ weechat_aspell_modifier_cb (void *data, const char *modifier,
*/
int
-weechat_aspell_buffer_switch_cb (void *data, const char *signal,
- const char *type_data, void *signal_data)
+weechat_aspell_buffer_switch_cb (const void *pointer, void *data,
+ const char *signal, const char *type_data,
+ void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -953,10 +957,12 @@ weechat_aspell_buffer_switch_cb (void *data, const char *signal,
*/
int
-weechat_aspell_window_switch_cb (void *data, const char *signal,
+weechat_aspell_window_switch_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -975,10 +981,12 @@ weechat_aspell_window_switch_cb (void *data, const char *signal,
*/
int
-weechat_aspell_buffer_closed_cb (void *data, const char *signal,
+weechat_aspell_buffer_closed_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -993,10 +1001,12 @@ weechat_aspell_buffer_closed_cb (void *data, const char *signal,
*/
int
-weechat_aspell_debug_libs_cb (void *data, const char *signal,
+weechat_aspell_debug_libs_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -1059,20 +1069,20 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
* (from other plugins) will be called before this one
*/
weechat_hook_modifier ("500|input_text_display",
- &weechat_aspell_modifier_cb, NULL);
+ &weechat_aspell_modifier_cb, NULL, NULL);
weechat_aspell_bar_item_init ();
weechat_aspell_info_init ();
weechat_hook_signal ("buffer_switch",
- &weechat_aspell_buffer_switch_cb, NULL);
+ &weechat_aspell_buffer_switch_cb, NULL, NULL);
weechat_hook_signal ("window_switch",
- &weechat_aspell_window_switch_cb, NULL);
+ &weechat_aspell_window_switch_cb, NULL, NULL);
weechat_hook_signal ("buffer_closed",
- &weechat_aspell_buffer_closed_cb, NULL);
+ &weechat_aspell_buffer_closed_cb, NULL, NULL);
weechat_hook_signal ("debug_libs",
- &weechat_aspell_debug_libs_cb, NULL);
+ &weechat_aspell_debug_libs_cb, NULL, NULL);
return WEECHAT_RC_OK;
}
diff --git a/src/plugins/aspell/weechat-aspell.h b/src/plugins/aspell/weechat-aspell.h
index fbcbc3fb8..e947f83bd 100644
--- a/src/plugins/aspell/weechat-aspell.h
+++ b/src/plugins/aspell/weechat-aspell.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org>
- * Copyright (C) 2006-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2006-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/charset/CMakeLists.txt b/src/plugins/charset/CMakeLists.txt
index 052b46711..16cf17d05 100644
--- a/src/plugins/charset/CMakeLists.txt
+++ b/src/plugins/charset/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/charset/Makefile.am b/src/plugins/charset/Makefile.am
index 9f746b83f..1a2ed9805 100644
--- a/src/plugins/charset/Makefile.am
+++ b/src/plugins/charset/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/charset/charset.c b/src/plugins/charset/charset.c
index ad275e848..919f900eb 100644
--- a/src/plugins/charset/charset.c
+++ b/src/plugins/charset/charset.c
@@ -1,7 +1,7 @@
/*
* charset.c - charset plugin for WeeChat: encode/decode strings
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -59,9 +59,11 @@ const char *charset_internal = NULL;
*/
int
-charset_config_reload (void *data, struct t_config_file *config_file)
+charset_config_reload (const void *pointer, void *data,
+ struct t_config_file *config_file)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
/* free all decode/encode charsets */
@@ -107,10 +109,12 @@ charset_decode_is_allowed (const char *charset)
*/
int
-charset_check_charset_decode_cb (void *data, struct t_config_option *option,
+charset_check_charset_decode_cb (const void *pointer, void *data,
+ struct t_config_option *option,
const char *value)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -122,7 +126,8 @@ charset_check_charset_decode_cb (void *data, struct t_config_option *option,
*/
int
-charset_config_create_option (void *data, struct t_config_file *config_file,
+charset_config_create_option (const void *pointer, void *data,
+ struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name, const char *value)
{
@@ -130,6 +135,7 @@ charset_config_create_option (void *data, struct t_config_file *config_file,
int rc;
/* make C compiler happy */
+ (void) pointer;
(void) data;
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
@@ -159,8 +165,9 @@ charset_config_create_option (void *data, struct t_config_file *config_file,
config_file, section,
option_name, "string", NULL,
NULL, 0, 0, "", value, 0,
- (section == charset_config_section_decode) ? &charset_check_charset_decode_cb : NULL, NULL,
- NULL, NULL, NULL, NULL);
+ (section == charset_config_section_decode) ? &charset_check_charset_decode_cb : NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
rc = (ptr_option) ?
WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
}
@@ -195,15 +202,17 @@ charset_config_init ()
struct t_config_section *ptr_section;
charset_config_file = weechat_config_new (CHARSET_CONFIG_NAME,
- &charset_config_reload, NULL);
+ &charset_config_reload, NULL, NULL);
if (!charset_config_file)
return 0;
ptr_section = weechat_config_new_section (charset_config_file, "default",
0, 0,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (charset_config_file);
@@ -220,7 +229,9 @@ charset_config_init ()
&& (weechat_strcasecmp (charset_terminal,
charset_internal) != 0)) ?
charset_terminal : "iso-8859-1", NULL, 0,
- &charset_check_charset_decode_cb, NULL, NULL, NULL, NULL, NULL);
+ &charset_check_charset_decode_cb, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
charset_default_encode = weechat_config_new_option (
charset_config_file, ptr_section,
"encode", "string",
@@ -228,14 +239,16 @@ charset_config_init ()
"(if empty, default is UTF-8 because it is the WeeChat internal "
"charset)"),
NULL, 0, 0, "", NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
-
- ptr_section = weechat_config_new_section (charset_config_file, "decode",
- 1, 1,
- NULL, NULL, NULL, NULL,
- NULL, NULL,
- &charset_config_create_option, NULL,
- NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+
+ ptr_section = weechat_config_new_section (
+ charset_config_file, "decode",
+ 1, 1,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ &charset_config_create_option, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (charset_config_file);
@@ -244,12 +257,14 @@ charset_config_init ()
charset_config_section_decode = ptr_section;
- ptr_section = weechat_config_new_section (charset_config_file, "encode",
- 1, 1,
- NULL, NULL, NULL, NULL,
- NULL, NULL,
- &charset_config_create_option, NULL,
- NULL, NULL);
+ ptr_section = weechat_config_new_section (
+ charset_config_file, "encode",
+ 1, 1,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ &charset_config_create_option, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (charset_config_file);
@@ -365,12 +380,14 @@ charset_get (struct t_config_section *section, const char *name,
*/
char *
-charset_decode_cb (void *data, const char *modifier, const char *modifier_data,
+charset_decode_cb (const void *pointer, void *data,
+ const char *modifier, const char *modifier_data,
const char *string)
{
const char *charset;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) modifier;
@@ -394,12 +411,14 @@ charset_decode_cb (void *data, const char *modifier, const char *modifier_data,
*/
char *
-charset_encode_cb (void *data, const char *modifier, const char *modifier_data,
+charset_encode_cb (const void *pointer, void *data,
+ const char *modifier, const char *modifier_data,
const char *string)
{
const char *charset;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) modifier;
@@ -426,7 +445,7 @@ void
charset_set (struct t_config_section *section, const char *type,
const char *name, const char *value)
{
- if (charset_config_create_option (NULL,
+ if (charset_config_create_option (NULL, NULL,
charset_config_file,
section,
name,
@@ -458,7 +477,8 @@ charset_display_charsets ()
*/
int
-charset_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
+charset_command_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer, int argc,
char **argv, char **argv_eol)
{
struct t_config_section *ptr_section;
@@ -467,6 +487,7 @@ charset_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
const char *plugin_name, *name, *charset_modifier;
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (argc < 2)
@@ -594,11 +615,11 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
"charset: new charset for current buffer\n"
" reset: reset charsets for current buffer"),
"decode|encode|reset",
- &charset_command_cb, NULL);
+ &charset_command_cb, NULL, NULL);
/* modifiers hooks */
- weechat_hook_modifier ("charset_decode", &charset_decode_cb, NULL);
- weechat_hook_modifier ("charset_encode", &charset_encode_cb, NULL);
+ weechat_hook_modifier ("charset_decode", &charset_decode_cb, NULL, NULL);
+ weechat_hook_modifier ("charset_encode", &charset_encode_cb, NULL, NULL);
return WEECHAT_RC_OK;
}
diff --git a/src/plugins/exec/CMakeLists.txt b/src/plugins/exec/CMakeLists.txt
index f250dc720..8c1e115ed 100644
--- a/src/plugins/exec/CMakeLists.txt
+++ b/src/plugins/exec/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2014-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2014-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/exec/Makefile.am b/src/plugins/exec/Makefile.am
index 9413e12e2..eb1908724 100644
--- a/src/plugins/exec/Makefile.am
+++ b/src/plugins/exec/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2014-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2014-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/exec/exec-buffer.c b/src/plugins/exec/exec-buffer.c
index 48c8f3e5c..908d0d044 100644
--- a/src/plugins/exec/exec-buffer.c
+++ b/src/plugins/exec/exec-buffer.c
@@ -1,7 +1,7 @@
/*
* exec-buffer.c - buffers with output of commands
*
- * Copyright (C) 2014-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2014-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -35,13 +35,15 @@
*/
int
-exec_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
+exec_buffer_input_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
const char *input_data)
{
char **argv, **argv_eol;
int argc;
/* make C compiler happy */
+ (void) pointer;
(void) data;
/* close buffer */
@@ -70,12 +72,14 @@ exec_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
*/
int
-exec_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
+exec_buffer_close_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer)
{
const char *full_name;
struct t_exec_cmd *ptr_exec_cmd;
/* make C compiler happy */
+ (void) pointer;
(void) data;
/* kill any command whose output is on this buffer */
@@ -153,8 +157,8 @@ exec_buffer_new (const char *name, int free_content, int clear_buffer,
}
new_buffer = weechat_buffer_new (name,
- &exec_buffer_input_cb, NULL,
- &exec_buffer_close_cb, NULL);
+ &exec_buffer_input_cb, NULL, NULL,
+ &exec_buffer_close_cb, NULL, NULL);
/* failed to create buffer ? then return */
if (!new_buffer)
diff --git a/src/plugins/exec/exec-buffer.h b/src/plugins/exec/exec-buffer.h
index 0b7f1a956..d0ee022ee 100644
--- a/src/plugins/exec/exec-buffer.h
+++ b/src/plugins/exec/exec-buffer.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2014-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/exec/exec-command.c b/src/plugins/exec/exec-command.c
index 4d75f6dd6..91e8cbdcd 100644
--- a/src/plugins/exec/exec-command.c
+++ b/src/plugins/exec/exec-command.c
@@ -1,7 +1,7 @@
/*
* exec-command.c - exec command
*
- * Copyright (C) 2014-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2014-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -458,8 +458,7 @@ exec_command_run (struct t_gui_buffer *buffer,
process_options = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
if (!process_options)
{
exec_free (new_exec_cmd);
@@ -570,7 +569,8 @@ exec_command_run (struct t_gui_buffer *buffer,
process_options,
cmd_options.timeout * 1000,
&exec_process_cb,
- new_exec_cmd);
+ new_exec_cmd,
+ NULL);
if (new_exec_cmd->hook)
{
@@ -605,7 +605,8 @@ exec_command_run (struct t_gui_buffer *buffer,
*/
int
-exec_command_exec (void *data, struct t_gui_buffer *buffer, int argc,
+exec_command_exec (const void *pointer, void *data,
+ struct t_gui_buffer *buffer, int argc,
char **argv, char **argv_eol)
{
int i, length, count;
@@ -613,6 +614,7 @@ exec_command_exec (void *data, struct t_gui_buffer *buffer, int argc,
struct t_exec_cmd *ptr_exec_cmd, *ptr_next_exec_cmd;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
@@ -862,7 +864,7 @@ exec_command_init ()
"\n"
"Examples:\n"
" /exec -n ls -l /tmp\n"
- " /exec -n ps xu | grep weechat\n"
+ " /exec -sh -n ps xu | grep weechat\n"
" /exec -n -norc url:http://pastebin.com/raw.php?i=xxxxxxxx\n"
" /exec -nf -noln links -dump "
"https://weechat.org/files/doc/devel/weechat_user.en.html\n"
@@ -878,5 +880,5 @@ exec_command_init ()
" || -killall"
" || -set %(exec_commands_ids) stdin|stdin_close|signal"
" || -del %(exec_commands_ids)|-all %(exec_commands_ids)|%*",
- &exec_command_exec, NULL);
+ &exec_command_exec, NULL, NULL);
}
diff --git a/src/plugins/exec/exec-command.h b/src/plugins/exec/exec-command.h
index ab5fb474e..eb4d737fe 100644
--- a/src/plugins/exec/exec-command.h
+++ b/src/plugins/exec/exec-command.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2014-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/exec/exec-completion.c b/src/plugins/exec/exec-completion.c
index 9eb430cad..52475cfdf 100644
--- a/src/plugins/exec/exec-completion.c
+++ b/src/plugins/exec/exec-completion.c
@@ -1,7 +1,7 @@
/*
* exec-completion.c - completion for exec commands
*
- * Copyright (C) 2014-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2014-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -32,7 +32,8 @@
*/
int
-exec_completion_commands_ids_cb (void *data, const char *completion_item,
+exec_completion_commands_ids_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
@@ -40,6 +41,7 @@ exec_completion_commands_ids_cb (void *data, const char *completion_item,
char str_number[32];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -69,5 +71,5 @@ exec_completion_init ()
{
weechat_hook_completion ("exec_commands_ids",
N_("ids (numbers and names) of executed commands"),
- &exec_completion_commands_ids_cb, NULL);
+ &exec_completion_commands_ids_cb, NULL, NULL);
}
diff --git a/src/plugins/exec/exec-completion.h b/src/plugins/exec/exec-completion.h
index 7012ac6e7..4b6bf8c8b 100644
--- a/src/plugins/exec/exec-completion.h
+++ b/src/plugins/exec/exec-completion.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2014-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/exec/exec-config.c b/src/plugins/exec/exec-config.c
index 8c4145fe8..77c3152c6 100644
--- a/src/plugins/exec/exec-config.c
+++ b/src/plugins/exec/exec-config.c
@@ -1,7 +1,7 @@
/*
* exec-config.c - exec configuration options (file exec.conf)
*
- * Copyright (C) 2014-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2014-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -49,10 +49,11 @@ int exec_config_cmd_num_options = 0;
*/
void
-exec_config_change_command_default_options (void *data,
+exec_config_change_command_default_options (const void *pointer, void *data,
struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -69,9 +70,11 @@ exec_config_change_command_default_options (void *data,
*/
int
-exec_config_reload_cb (void *data, struct t_config_file *config_file)
+exec_config_reload_cb (const void *pointer, void *data,
+ struct t_config_file *config_file)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
return weechat_config_reload (config_file);
@@ -91,16 +94,18 @@ exec_config_init ()
struct t_config_section *ptr_section;
exec_config_file = weechat_config_new (EXEC_CONFIG_NAME,
- &exec_config_reload_cb, NULL);
+ &exec_config_reload_cb, NULL, NULL);
if (!exec_config_file)
return 0;
/* command */
ptr_section = weechat_config_new_section (exec_config_file, "command",
0, 0,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (exec_config_file);
@@ -113,22 +118,26 @@ exec_config_init ()
N_("default options for command /exec (see /help exec); example: "
"\"-nosh -bg\" to run all commands in background (no output), and "
"without using the shell"),
- NULL, 0, 0, "", NULL, 0, NULL, NULL,
- &exec_config_change_command_default_options, NULL, NULL, NULL);
+ NULL, 0, 0, "", NULL, 0,
+ NULL, NULL, NULL,
+ &exec_config_change_command_default_options, NULL, NULL,
+ NULL, NULL, NULL);
exec_config_command_purge_delay = weechat_config_new_option (
exec_config_file, ptr_section,
"purge_delay", "integer",
N_("delay for purging finished commands (in seconds, 0 = purge "
"commands immediately, -1 = never purge)"),
NULL, -1, 36000 * 24 * 30, "0", NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
/* color */
ptr_section = weechat_config_new_section (exec_config_file, "color",
0, 0,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (exec_config_file);
@@ -140,13 +149,13 @@ exec_config_init ()
"flag_running", "color",
N_("text color for a running command flag in list of commands"),
NULL, 0, 0, "lightgreen", NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
exec_config_color_flag_finished = weechat_config_new_option (
exec_config_file, ptr_section,
"flag_finished", "color",
N_("text color for a finished command flag in list of commands"),
NULL, 0, 0, "lightred", NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
return 1;
}
diff --git a/src/plugins/exec/exec-config.h b/src/plugins/exec/exec-config.h
index 679bafac1..04ebcb065 100644
--- a/src/plugins/exec/exec-config.h
+++ b/src/plugins/exec/exec-config.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2014-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/exec/exec.c b/src/plugins/exec/exec.c
index 7363700b4..dd686c41f 100644
--- a/src/plugins/exec/exec.c
+++ b/src/plugins/exec/exec.c
@@ -1,7 +1,7 @@
/*
* exec.c - execution of external commands in WeeChat
*
- * Copyright (C) 2014-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2014-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -175,14 +175,15 @@ exec_add ()
*/
int
-exec_timer_delete_cb (void *data, int remaining_calls)
+exec_timer_delete_cb (const void *pointer, void *data, int remaining_calls)
{
struct t_exec_cmd *exec_cmd, *ptr_exec_cmd;
/* make C compiler happy */
+ (void) data;
(void) remaining_calls;
- exec_cmd = (struct t_exec_cmd *)data;
+ exec_cmd = (struct t_exec_cmd *)pointer;
if (!exec_cmd)
return WEECHAT_RC_OK;
@@ -332,10 +333,11 @@ exec_display_line (struct t_exec_cmd *exec_cmd, struct t_gui_buffer *buffer,
{
snprintf (str_number, sizeof (str_number),
"%d\t", exec_cmd->output_line_nb);
- weechat_printf_tags (buffer, str_tags,
- "%s%s",
- (exec_cmd->line_numbers) ? str_number : " \t",
- line_color);
+ weechat_printf_date_tags (
+ buffer, 0, str_tags,
+ "%s%s",
+ (exec_cmd->line_numbers) ? str_number : " \t",
+ line_color);
}
}
}
@@ -424,8 +426,7 @@ exec_end_command (struct t_exec_cmd *exec_cmd, int return_code)
hashtable = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
if (hashtable)
{
weechat_hashtable_set (hashtable, "command", exec_cmd->command);
@@ -477,11 +478,12 @@ exec_end_command (struct t_exec_cmd *exec_cmd, int return_code)
}
else
{
- weechat_printf_tags (ptr_buffer, "exec_rc",
- _("%s: end of command %d (\"%s\"), "
- "return code: %d"),
- EXEC_PLUGIN_NAME, exec_cmd->number,
- exec_cmd->command, return_code);
+ weechat_printf_date_tags (
+ ptr_buffer, 0, "exec_rc",
+ _("%s: end of command %d (\"%s\"), "
+ "return code: %d"),
+ EXEC_PLUGIN_NAME, exec_cmd->number,
+ exec_cmd->command, return_code);
}
}
else
@@ -496,11 +498,12 @@ exec_end_command (struct t_exec_cmd *exec_cmd, int return_code)
}
else
{
- weechat_printf_tags (ptr_buffer, "exec_rc",
- _("%s: unexpected end of command %d "
- "(\"%s\")"),
- EXEC_PLUGIN_NAME, exec_cmd->number,
- exec_cmd->command);
+ weechat_printf_date_tags (
+ ptr_buffer, 0, "exec_rc",
+ _("%s: unexpected end of command %d "
+ "(\"%s\")"),
+ EXEC_PLUGIN_NAME, exec_cmd->number,
+ exec_cmd->command);
}
}
}
@@ -526,7 +529,7 @@ exec_end_command (struct t_exec_cmd *exec_cmd, int return_code)
{
weechat_hook_timer (1 + (1000 * weechat_config_integer (exec_config_command_purge_delay)),
0, 1,
- &exec_timer_delete_cb, exec_cmd);
+ &exec_timer_delete_cb, exec_cmd, NULL);
}
}
@@ -535,16 +538,17 @@ exec_end_command (struct t_exec_cmd *exec_cmd, int return_code)
*/
int
-exec_process_cb (void *data, const char *command, int return_code,
- const char *out, const char *err)
+exec_process_cb (const void *pointer, void *data, const char *command,
+ int return_code, const char *out, const char *err)
{
struct t_exec_cmd *ptr_exec_cmd;
struct t_gui_buffer *ptr_buffer;
/* make C compiler happy */
+ (void) data;
(void) command;
- ptr_exec_cmd = (struct t_exec_cmd *)data;
+ ptr_exec_cmd = (struct t_exec_cmd *)pointer;
if (!ptr_exec_cmd)
return WEECHAT_RC_ERROR;
@@ -681,10 +685,12 @@ exec_print_log ()
*/
int
-exec_debug_dump_cb (void *data, const char *signal, const char *type_data,
+exec_debug_dump_cb (const void *pointer, void *data,
+ const char *signal, const char *type_data,
void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -725,7 +731,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
exec_config_read ();
/* hook some signals */
- weechat_hook_signal ("debug_dump", &exec_debug_dump_cb, NULL);
+ weechat_hook_signal ("debug_dump", &exec_debug_dump_cb, NULL, NULL);
/* hook completions */
exec_completion_init ();
diff --git a/src/plugins/exec/exec.h b/src/plugins/exec/exec.h
index 2efea0402..2adb1435f 100644
--- a/src/plugins/exec/exec.h
+++ b/src/plugins/exec/exec.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2014-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -80,7 +80,8 @@ extern int exec_cmds_count;
extern int exec_search_color (const char *color);
extern struct t_exec_cmd *exec_search_by_id (const char *id);
extern struct t_exec_cmd *exec_add ();
-extern int exec_process_cb (void *data, const char *command, int return_code,
+extern int exec_process_cb (const void *pointer, void *data,
+ const char *command, int return_code,
const char *out, const char *err);
extern void exec_free (struct t_exec_cmd *exec_cmd);
extern void exec_free_all ();
diff --git a/src/plugins/fifo/CMakeLists.txt b/src/plugins/fifo/CMakeLists.txt
index 9a547d86e..b1c27b62f 100644
--- a/src/plugins/fifo/CMakeLists.txt
+++ b/src/plugins/fifo/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
@@ -19,6 +19,7 @@
add_library(fifo MODULE
fifo.c fifo.h
+fifo-command.c fifo-command.h
fifo-info.c fifo-info.h)
set_target_properties(fifo PROPERTIES PREFIX "")
diff --git a/src/plugins/fifo/Makefile.am b/src/plugins/fifo/Makefile.am
index b7fb2ec7e..8a51e9fb2 100644
--- a/src/plugins/fifo/Makefile.am
+++ b/src/plugins/fifo/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
@@ -25,6 +25,8 @@ lib_LTLIBRARIES = fifo.la
fifo_la_SOURCES = fifo.c \
fifo.h \
+ fifo-command.c \
+ fifo-command.h \
fifo-info.c \
fifo-info.h
fifo_la_LDFLAGS = -module -no-undefined
diff --git a/src/plugins/fifo/fifo-command.c b/src/plugins/fifo/fifo-command.c
new file mode 100644
index 000000000..19ea553a5
--- /dev/null
+++ b/src/plugins/fifo/fifo-command.c
@@ -0,0 +1,119 @@
+/*
+ * fifo-command.c - fifo command
+ *
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
+ *
+ * This file is part of WeeChat, the extensible chat client.
+ *
+ * WeeChat 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.
+ *
+ * WeeChat 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 WeeChat. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdlib.h>
+
+#include "../weechat-plugin.h"
+#include "fifo.h"
+
+
+/*
+ * Callback for command "/fifo": manages FIFO pipe.
+ */
+
+int
+fifo_command_fifo (const void *pointer, void *data,
+ struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
+{
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+ (void) buffer;
+ (void) argv_eol;
+
+ if (argc == 1)
+ {
+ if (fifo_fd != -1)
+ {
+ weechat_printf (NULL,
+ _("%s: pipe is enabled (file: %s)"),
+ FIFO_PLUGIN_NAME,
+ fifo_filename);
+ }
+ else
+ {
+ weechat_printf (NULL,
+ _("%s: pipe is disabled"), FIFO_PLUGIN_NAME);
+ }
+ return WEECHAT_RC_OK;
+ }
+
+ /* enable pipe */
+ if (weechat_strcasecmp (argv[1], "enable") == 0)
+ {
+ weechat_config_set_plugin (FIFO_OPTION_NAME, "on");
+ return WEECHAT_RC_OK;
+ }
+
+ /* disable pipe */
+ if (weechat_strcasecmp (argv[1], "disable") == 0)
+ {
+ weechat_config_set_plugin (FIFO_OPTION_NAME, "off");
+ return WEECHAT_RC_OK;
+ }
+
+ /* toggle pipe */
+ if (weechat_strcasecmp (argv[1], "toggle") == 0)
+ {
+ weechat_config_set_plugin (FIFO_OPTION_NAME,
+ (fifo_fd == -1) ? "on" : "off");
+ return WEECHAT_RC_OK;
+ }
+
+ WEECHAT_COMMAND_ERROR;
+}
+
+/*
+ * Hooks fifo command.
+ */
+
+void
+fifo_command_init ()
+{
+ weechat_hook_command (
+ "fifo",
+ N_("fifo plugin configuration"),
+ N_("enable|disable|toggle"),
+ N_(" enable: enable FIFO pipe\n"
+ "disable: disable FIFO pipe\n"
+ " toggle: toggle FIFO pipe\n"
+ "\n"
+ "FIFO pipe is used as remote control of WeeChat: you can send "
+ "commands or text to the FIFO pipe from your shell.\n"
+ "By default the FIFO pipe is in ~/.weechat/weechat_fifo_xxx "
+ "(\"xxx\" is the WeeChat PID).\n"
+ "\n"
+ "The expected format is one of:\n"
+ " plugin.buffer *text or command here\n"
+ " *text or command here\n"
+ "\n"
+ "For example to change your freenode nick:\n"
+ " echo 'irc.server.freenode */nick newnick' "
+ ">~/.weechat/weechat_fifo_12345\n"
+ "\n"
+ "Please read the user's guide for more info and examples.\n"
+ "\n"
+ "Examples:\n"
+ " /fifo toggle"),
+ "enable|disable|toggle",
+ &fifo_command_fifo, NULL, NULL);
+}
diff --git a/src/plugins/fifo/fifo-command.h b/src/plugins/fifo/fifo-command.h
new file mode 100644
index 000000000..0b7f29b81
--- /dev/null
+++ b/src/plugins/fifo/fifo-command.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
+ *
+ * This file is part of WeeChat, the extensible chat client.
+ *
+ * WeeChat 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.
+ *
+ * WeeChat 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 WeeChat. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef WEECHAT_FIFO_COMMAND_H
+#define WEECHAT_FIFO_COMMAND_H 1
+
+extern void fifo_command_init ();
+
+#endif /* WEECHAT_FIFO_COMMAND_H */
diff --git a/src/plugins/fifo/fifo-info.c b/src/plugins/fifo/fifo-info.c
index 6c5fe2d35..8be53ff9c 100644
--- a/src/plugins/fifo/fifo-info.c
+++ b/src/plugins/fifo/fifo-info.c
@@ -1,7 +1,7 @@
/*
* fifo-info.c - info and infolist hooks for fifo plugin
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -30,10 +30,12 @@
*/
const char *
-fifo_info_info_fifo_filename_cb (void *data, const char *info_name,
+fifo_info_info_fifo_filename_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
(void) arguments;
@@ -49,5 +51,5 @@ void
fifo_info_init ()
{
weechat_hook_info ("fifo_filename", N_("name of FIFO pipe"), NULL,
- &fifo_info_info_fifo_filename_cb, NULL);
+ &fifo_info_info_fifo_filename_cb, NULL, NULL);
}
diff --git a/src/plugins/fifo/fifo-info.h b/src/plugins/fifo/fifo-info.h
index 234c0b6ab..0a41e7817 100644
--- a/src/plugins/fifo/fifo-info.h
+++ b/src/plugins/fifo/fifo-info.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/fifo/fifo.c b/src/plugins/fifo/fifo.c
index 8694b57c8..e438fc4a1 100644
--- a/src/plugins/fifo/fifo.c
+++ b/src/plugins/fifo/fifo.c
@@ -1,7 +1,7 @@
/*
* fifo.c - fifo plugin for WeeChat: remote control with FIFO pipe
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -32,6 +32,7 @@
#include "../weechat-plugin.h"
#include "fifo.h"
+#include "fifo-command.h"
#include "fifo-info.h"
@@ -54,7 +55,7 @@ char *fifo_filename;
char *fifo_unterminated = NULL;
-int fifo_read();
+int fifo_fd_cb ();
/*
@@ -158,11 +159,12 @@ fifo_create ()
if ((weechat_fifo_plugin->debug >= 1) || !fifo_quiet)
{
weechat_printf (NULL,
- _("%s: pipe opened"),
- FIFO_PLUGIN_NAME);
+ _("%s: pipe opened (file: %s)"),
+ FIFO_PLUGIN_NAME,
+ fifo_filename);
}
fifo_fd_hook = weechat_hook_fd (fifo_fd, 1, 0, 0,
- &fifo_read, NULL);
+ &fifo_fd_cb, NULL, NULL);
}
else
weechat_printf (NULL,
@@ -259,7 +261,7 @@ fifo_exec (const char *text)
if (!pos_msg)
{
weechat_printf (NULL,
- _("%s%s: error, invalid text received on pipe"),
+ _("%s%s: invalid text received in pipe"),
weechat_prefix ("error"), FIFO_PLUGIN_NAME);
free (text2);
return;
@@ -267,15 +269,15 @@ fifo_exec (const char *text)
pos_msg[0] = '\0';
pos_msg += 2;
ptr_buffer = weechat_buffer_search ("==", text2);
- }
-
- if (!ptr_buffer)
- {
- weechat_printf (NULL,
- _("%s%s: error, buffer not found for pipe data"),
- weechat_prefix ("error"), FIFO_PLUGIN_NAME);
- free (text2);
- return;
+ if (!ptr_buffer)
+ {
+ weechat_printf (NULL,
+ _("%s%s: buffer \"%s\" not found"),
+ weechat_prefix ("error"), FIFO_PLUGIN_NAME,
+ text2);
+ free (text2);
+ return;
+ }
}
weechat_command (ptr_buffer, pos_msg);
@@ -288,13 +290,14 @@ fifo_exec (const char *text)
*/
int
-fifo_read (void *data, int fd)
+fifo_fd_cb (const void *pointer, void *data, int fd)
{
static char buffer[4096 + 2];
char *buf2, *pos, *ptr_buf, *next_ptr_buf;
int num_read;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) fd;
@@ -384,8 +387,10 @@ fifo_read (void *data, int fd)
fifo_remove ();
}
else
+ {
fifo_fd_hook = weechat_hook_fd (fifo_fd, 1, 0, 0,
- &fifo_read, NULL);
+ &fifo_fd_cb, NULL, NULL);
+ }
}
}
@@ -397,9 +402,11 @@ fifo_read (void *data, int fd)
*/
int
-fifo_config_cb (void *data, const char *option, const char *value)
+fifo_config_cb (const void *pointer, void *data,
+ const char *option, const char *value)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -424,6 +431,8 @@ fifo_config_cb (void *data, const char *option, const char *value)
int
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
{
+ char str_option[256];
+
/* make C compiler happy */
(void) argc;
(void) argv;
@@ -434,8 +443,11 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
fifo_create ();
- weechat_hook_config ("plugins.var.fifo.fifo", &fifo_config_cb, NULL);
+ snprintf (str_option, sizeof (str_option),
+ "plugins.var.fifo.%s", FIFO_OPTION_NAME);
+ weechat_hook_config (str_option, &fifo_config_cb, NULL, NULL);
+ fifo_command_init ();
fifo_info_init ();
fifo_quiet = 0;
diff --git a/src/plugins/fifo/fifo.h b/src/plugins/fifo/fifo.h
index 008251ef5..35eb72b0d 100644
--- a/src/plugins/fifo/fifo.h
+++ b/src/plugins/fifo/fifo.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -22,8 +22,10 @@
#define weechat_plugin weechat_fifo_plugin
#define FIFO_PLUGIN_NAME "fifo"
+#define FIFO_OPTION_NAME "fifo"
extern struct t_weechat_plugin *weechat_fifo_plugin;
+extern int fifo_fd;
extern char *fifo_filename;
#endif /* WEECHAT_FIFO_H */
diff --git a/src/plugins/guile/CMakeLists.txt b/src/plugins/guile/CMakeLists.txt
index 3076fe948..16bfa4c0c 100644
--- a/src/plugins/guile/CMakeLists.txt
+++ b/src/plugins/guile/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/guile/Makefile.am b/src/plugins/guile/Makefile.am
index 5ef2cded9..170fecef1 100644
--- a/src/plugins/guile/Makefile.am
+++ b/src/plugins/guile/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/guile/weechat-guile-api.c b/src/plugins/guile/weechat-guile-api.c
index 676a85e50..acf0f8080 100644
--- a/src/plugins/guile/weechat-guile-api.c
+++ b/src/plugins/guile/weechat-guile-api.c
@@ -1,7 +1,7 @@
/*
* weechat-guile-api.c - guile API functions
*
- * Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2012 Simon Arlott
*
* This file is part of WeeChat, the extensible chat client.
@@ -28,7 +28,6 @@
#include "../weechat-plugin.h"
#include "../plugin-script.h"
#include "../plugin-script-api.h"
-#include "../plugin-script-callback.h"
#include "weechat-guile.h"
@@ -773,24 +772,26 @@ weechat_guile_api_list_free (SCM weelist)
}
int
-weechat_guile_api_config_reload_cb (void *data,
+weechat_guile_api_config_reload_cb (const void *pointer, void *data,
struct t_config_file *config_file)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
- rc = (int *) weechat_guile_exec (script_callback->script,
+ rc = (int *) weechat_guile_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (!rc)
@@ -831,29 +832,31 @@ weechat_guile_api_config_new (SCM name, SCM function, SCM data)
}
int
-weechat_guile_api_config_read_cb (void *data,
+weechat_guile_api_config_read_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name, const char *value)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[5];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = API_PTR2STR(section);
func_argv[3] = (option_name) ? (char *)option_name : empty_arg;
func_argv[4] = (value) ? (char *)value : empty_arg;
- rc = (int *) weechat_guile_exec (script_callback->script,
+ rc = (int *) weechat_guile_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sssss", func_argv);
if (!rc)
@@ -875,26 +878,28 @@ weechat_guile_api_config_read_cb (void *data,
}
int
-weechat_guile_api_config_section_write_cb (void *data,
+weechat_guile_api_config_section_write_cb (const void *pointer, void *data,
struct t_config_file *config_file,
const char *section_name)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = (section_name) ? (char *)section_name : empty_arg;
- rc = (int *) weechat_guile_exec (script_callback->script,
+ rc = (int *) weechat_guile_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -914,26 +919,28 @@ weechat_guile_api_config_section_write_cb (void *data,
}
int
-weechat_guile_api_config_section_write_default_cb (void *data,
+weechat_guile_api_config_section_write_default_cb (const void *pointer, void *data,
struct t_config_file *config_file,
const char *section_name)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = (section_name) ? (char *)section_name : empty_arg;
- rc = (int *) weechat_guile_exec (script_callback->script,
+ rc = (int *) weechat_guile_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -953,30 +960,32 @@ weechat_guile_api_config_section_write_default_cb (void *data,
}
int
-weechat_guile_api_config_section_create_option_cb (void *data,
+weechat_guile_api_config_section_create_option_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
const char *value)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[5];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = API_PTR2STR(section);
func_argv[3] = (option_name) ? (char *)option_name : empty_arg;
func_argv[4] = (value) ? (char *)value : empty_arg;
- rc = (int *) weechat_guile_exec (script_callback->script,
+ rc = (int *) weechat_guile_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sssss", func_argv);
if (!rc)
@@ -998,28 +1007,30 @@ weechat_guile_api_config_section_create_option_cb (void *data,
}
int
-weechat_guile_api_config_section_delete_option_cb (void *data,
+weechat_guile_api_config_section_delete_option_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
struct t_config_option *option)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = API_PTR2STR(section);
func_argv[3] = API_PTR2STR(option);
- rc = (int *) weechat_guile_exec (script_callback->script,
+ rc = (int *) weechat_guile_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssss", func_argv);
if (!rc)
@@ -1080,27 +1091,29 @@ weechat_guile_api_config_new_section (SCM args)
|| !scm_is_string (function_delete_option) || !scm_is_string (data_delete_option))
API_WRONG_ARGS(API_RETURN_EMPTY);
- result = API_PTR2STR(plugin_script_api_config_new_section (weechat_guile_plugin,
- guile_current_script,
- API_STR2PTR(API_SCM_TO_STRING(config_file)),
- API_SCM_TO_STRING(name),
- scm_to_int (user_can_add_options),
- scm_to_int (user_can_delete_options),
- &weechat_guile_api_config_read_cb,
- API_SCM_TO_STRING(function_read),
- API_SCM_TO_STRING(data_read),
- &weechat_guile_api_config_section_write_cb,
- API_SCM_TO_STRING(function_write),
- API_SCM_TO_STRING(data_write),
- &weechat_guile_api_config_section_write_default_cb,
- API_SCM_TO_STRING(function_write_default),
- API_SCM_TO_STRING(data_write_default),
- &weechat_guile_api_config_section_create_option_cb,
- API_SCM_TO_STRING(function_create_option),
- API_SCM_TO_STRING(data_create_option),
- &weechat_guile_api_config_section_delete_option_cb,
- API_SCM_TO_STRING(function_delete_option),
- API_SCM_TO_STRING(data_delete_option)));
+ result = API_PTR2STR(
+ plugin_script_api_config_new_section (
+ weechat_guile_plugin,
+ guile_current_script,
+ API_STR2PTR(API_SCM_TO_STRING(config_file)),
+ API_SCM_TO_STRING(name),
+ scm_to_int (user_can_add_options),
+ scm_to_int (user_can_delete_options),
+ &weechat_guile_api_config_read_cb,
+ API_SCM_TO_STRING(function_read),
+ API_SCM_TO_STRING(data_read),
+ &weechat_guile_api_config_section_write_cb,
+ API_SCM_TO_STRING(function_write),
+ API_SCM_TO_STRING(data_write),
+ &weechat_guile_api_config_section_write_default_cb,
+ API_SCM_TO_STRING(function_write_default),
+ API_SCM_TO_STRING(data_write_default),
+ &weechat_guile_api_config_section_create_option_cb,
+ API_SCM_TO_STRING(function_create_option),
+ API_SCM_TO_STRING(data_create_option),
+ &weechat_guile_api_config_section_delete_option_cb,
+ API_SCM_TO_STRING(function_delete_option),
+ API_SCM_TO_STRING(data_delete_option)));
API_RETURN_STRING_FREE(result);
}
@@ -1122,26 +1135,28 @@ weechat_guile_api_config_search_section (SCM config_file, SCM section_name)
}
int
-weechat_guile_api_config_option_check_value_cb (void *data,
+weechat_guile_api_config_option_check_value_cb (const void *pointer, void *data,
struct t_config_option *option,
const char *value)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(option);
func_argv[2] = (value) ? (char *)value : empty_arg;
- rc = (int *) weechat_guile_exec (script_callback->script,
+ rc = (int *) weechat_guile_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -1161,24 +1176,26 @@ weechat_guile_api_config_option_check_value_cb (void *data,
}
void
-weechat_guile_api_config_option_change_cb (void *data,
+weechat_guile_api_config_option_change_cb (const void *pointer, void *data,
struct t_config_option *option)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(option);
- rc = (int *) weechat_guile_exec (script_callback->script,
+ rc = (int *) weechat_guile_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (func_argv[1])
@@ -1190,24 +1207,26 @@ weechat_guile_api_config_option_change_cb (void *data,
}
void
-weechat_guile_api_config_option_delete_cb (void *data,
+weechat_guile_api_config_option_delete_cb (const void *pointer, void *data,
struct t_config_option *option)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(option);
- rc = (int *) weechat_guile_exec (script_callback->script,
+ rc = (int *) weechat_guile_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (func_argv[1])
@@ -1614,9 +1633,7 @@ weechat_guile_api_config_option_free (SCM option)
if (!scm_is_string (option))
API_WRONG_ARGS(API_RETURN_ERROR);
- plugin_script_api_config_option_free (weechat_guile_plugin,
- guile_current_script,
- API_STR2PTR(API_SCM_TO_STRING(option)));
+ weechat_config_option_free (API_STR2PTR(API_SCM_TO_STRING(option)));
API_RETURN_OK;
}
@@ -1628,9 +1645,8 @@ weechat_guile_api_config_section_free_options (SCM section)
if (!scm_is_string (section))
API_WRONG_ARGS(API_RETURN_ERROR);
- plugin_script_api_config_section_free_options (weechat_guile_plugin,
- guile_current_script,
- API_STR2PTR(API_SCM_TO_STRING(section)));
+ weechat_config_section_free_options (
+ API_STR2PTR(API_SCM_TO_STRING(section)));
API_RETURN_OK;
}
@@ -1642,9 +1658,7 @@ weechat_guile_api_config_section_free (SCM section)
if (!scm_is_string (section))
API_WRONG_ARGS(API_RETURN_ERROR);
- plugin_script_api_config_section_free (weechat_guile_plugin,
- guile_current_script,
- API_STR2PTR(API_SCM_TO_STRING(section)));
+ weechat_config_section_free (API_STR2PTR(API_SCM_TO_STRING(section)));
API_RETURN_OK;
}
@@ -1656,9 +1670,7 @@ weechat_guile_api_config_free (SCM config_file)
if (!scm_is_string (config_file))
API_WRONG_ARGS(API_RETURN_ERROR);
- plugin_script_api_config_free (weechat_guile_plugin,
- guile_current_script,
- API_STR2PTR(API_SCM_TO_STRING(config_file)));
+ weechat_config_free (API_STR2PTR(API_SCM_TO_STRING(config_file)));
API_RETURN_OK;
}
@@ -1889,28 +1901,31 @@ weechat_guile_api_log_print (SCM message)
}
int
-weechat_guile_api_hook_command_cb (void *data, struct t_gui_buffer *buffer,
+weechat_guile_api_hook_command_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
/* make C compiler happy */
(void) argv;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
func_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg;
- rc = (int *) weechat_guile_exec (script_callback->script,
+ rc = (int *) weechat_guile_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -1959,25 +1974,28 @@ weechat_guile_api_hook_command (SCM command, SCM description, SCM args,
}
int
-weechat_guile_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
+weechat_guile_api_hook_command_run_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
const char *command)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
func_argv[2] = (command) ? (char *)command : empty_arg;
- rc = (int *) weechat_guile_exec (script_callback->script,
+ rc = (int *) weechat_guile_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -2018,26 +2036,29 @@ weechat_guile_api_hook_command_run (SCM command, SCM function, SCM data)
}
int
-weechat_guile_api_hook_timer_cb (void *data, int remaining_calls)
+weechat_guile_api_hook_timer_cb (const void *pointer, void *data,
+ int remaining_calls)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char str_remaining_calls[32], empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (str_remaining_calls, sizeof (str_remaining_calls),
"%d", remaining_calls);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = str_remaining_calls;
- rc = (int *) weechat_guile_exec (script_callback->script,
+ rc = (int *) weechat_guile_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (!rc)
@@ -2080,25 +2101,27 @@ weechat_guile_api_hook_timer (SCM interval, SCM align_second, SCM max_calls,
}
int
-weechat_guile_api_hook_fd_cb (void *data, int fd)
+weechat_guile_api_hook_fd_cb (const void *pointer, void *data, int fd)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char str_fd[32], empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (str_fd, sizeof (str_fd), "%d", fd);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = str_fd;
- rc = (int *) weechat_guile_exec (script_callback->script,
+ rc = (int *) weechat_guile_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (!rc)
@@ -2142,28 +2165,49 @@ weechat_guile_api_hook_fd (SCM fd, SCM read, SCM write, SCM exception,
}
int
-weechat_guile_api_hook_process_cb (void *data,
+weechat_guile_api_hook_process_cb (const void *pointer, void *data,
const char *command, int return_code,
const char *out, const char *err)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[5];
- char empty_arg[1] = { '\0' };
+ char empty_arg[1] = { '\0' }, *result;
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (return_code == WEECHAT_HOOK_PROCESS_CHILD)
+ {
+ if (strncmp (command, "func:", 5) == 0)
+ {
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
+
+ result = (char *) weechat_guile_exec (script,
+ WEECHAT_SCRIPT_EXEC_STRING,
+ command + 5,
+ "s", func_argv);
+ if (result)
+ {
+ printf ("%s", result);
+ free (result);
+ return 0;
+ }
+ }
+ return 1;
+ }
+ else if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (command) ? (char *)command : empty_arg;
func_argv[2] = &return_code;
func_argv[3] = (out) ? (char *)out : empty_arg;
func_argv[4] = (err) ? (char *)err : empty_arg;
- rc = (int *) weechat_guile_exec (script_callback->script,
+ rc = (int *) weechat_guile_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssiss", func_argv);
if (!rc)
@@ -2238,34 +2282,37 @@ weechat_guile_api_hook_process_hashtable (SCM command, SCM options, SCM timeout,
}
int
-weechat_guile_api_hook_connect_cb (void *data, int status, int gnutls_rc,
+weechat_guile_api_hook_connect_cb (const void *pointer, void *data,
+ int status, int gnutls_rc,
int sock, const char *error,
const char *ip_address)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[6];
char str_status[32], str_gnutls_rc[32], str_sock[32];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (str_status, sizeof (str_status), "%d", status);
snprintf (str_gnutls_rc, sizeof (str_gnutls_rc), "%d", gnutls_rc);
snprintf (str_sock, sizeof (str_sock), "%d", sock);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = str_status;
func_argv[2] = str_gnutls_rc;
func_argv[3] = str_sock;
func_argv[4] = (ip_address) ? (char *)ip_address : empty_arg;
func_argv[5] = (error) ? (char *)error : empty_arg;
- rc = (int *) weechat_guile_exec (script_callback->script,
+ rc = (int *) weechat_guile_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssssss", func_argv);
if (!rc)
@@ -2317,28 +2364,31 @@ weechat_guile_api_hook_connect (SCM proxy, SCM address, SCM port, SCM ipv6,
}
int
-weechat_guile_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
+weechat_guile_api_hook_print_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
time_t date,
int tags_count, const char **tags,
int displayed, int highlight,
const char *prefix, const char *message)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[8];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
static char timebuffer[64];
int *rc, ret;
/* make C compiler happy */
(void) tags_count;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (timebuffer, sizeof (timebuffer), "%ld", (long int)date);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
func_argv[2] = timebuffer;
func_argv[3] = weechat_string_build_with_split_string (tags, ",");
@@ -2349,9 +2399,9 @@ weechat_guile_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
func_argv[6] = (prefix) ? (char *)prefix : empty_arg;
func_argv[7] = (message) ? (char *)message : empty_arg;
- rc = (int *) weechat_guile_exec (script_callback->script,
+ rc = (int *) weechat_guile_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssssiiss", func_argv);
if (!rc)
@@ -2399,20 +2449,23 @@ weechat_guile_api_hook_print (SCM buffer, SCM tags, SCM message,
}
int
-weechat_guile_api_hook_signal_cb (void *data, const char *signal,
+weechat_guile_api_hook_signal_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
static char str_value[64];
int *rc, ret, free_needed;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (signal) ? (char *)signal : empty_arg;
free_needed = 0;
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
@@ -2437,9 +2490,9 @@ weechat_guile_api_hook_signal_cb (void *data, const char *signal,
else
func_argv[2] = empty_arg;
- rc = (int *) weechat_guile_exec (script_callback->script,
+ rc = (int *) weechat_guile_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -2521,25 +2574,28 @@ weechat_guile_api_hook_signal_send (SCM signal, SCM type_data,
}
int
-weechat_guile_api_hook_hsignal_cb (void *data, const char *signal,
+weechat_guile_api_hook_hsignal_cb (const void *pointer, void *data,
+ const char *signal,
struct t_hashtable *hashtable)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (signal) ? (char *)signal : empty_arg;
func_argv[2] = hashtable;
- rc = (int *) weechat_guile_exec (script_callback->script,
+ rc = (int *) weechat_guile_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssh", func_argv);
if (!rc)
@@ -2601,24 +2657,27 @@ weechat_guile_api_hook_hsignal_send (SCM signal, SCM hashtable)
}
int
-weechat_guile_api_hook_config_cb (void *data, const char *option, const char *value)
+weechat_guile_api_hook_config_cb (const void *pointer, void *data,
+ const char *option, const char *value)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (option) ? (char *)option : empty_arg;
func_argv[2] = (value) ? (char *)value : empty_arg;
- rc = (int *) weechat_guile_exec (script_callback->script,
+ rc = (int *) weechat_guile_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -2657,27 +2716,30 @@ weechat_guile_api_hook_config (SCM option, SCM function, SCM data)
}
int
-weechat_guile_api_hook_completion_cb (void *data, const char *completion_item,
+weechat_guile_api_hook_completion_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (completion_item) ? (char *)completion_item : empty_arg;
func_argv[2] = API_PTR2STR(buffer);
func_argv[3] = API_PTR2STR(completion);
- rc = (int *) weechat_guile_exec (script_callback->script,
+ rc = (int *) weechat_guile_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssss", func_argv);
if (!rc)
@@ -2755,25 +2817,29 @@ weechat_guile_api_hook_completion_list_add (SCM completion, SCM word,
}
char *
-weechat_guile_api_hook_modifier_cb (void *data, const char *modifier,
- const char *modifier_data, const char *string)
+weechat_guile_api_hook_modifier_cb (const void *pointer, void *data,
+ const char *modifier,
+ const char *modifier_data,
+ const char *string)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (modifier) ? (char *)modifier : empty_arg;
func_argv[2] = (modifier_data) ? (char *)modifier_data : empty_arg;
func_argv[3] = (string) ? (char *)string : empty_arg;
- return (char *)weechat_guile_exec (script_callback->script,
+ return (char *)weechat_guile_exec (script,
WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function,
+ ptr_function,
"ssss", func_argv);
}
@@ -2821,24 +2887,27 @@ weechat_guile_api_hook_modifier_exec (SCM modifier, SCM modifier_data,
}
const char *
-weechat_guile_api_hook_info_cb (void *data, const char *info_name,
+weechat_guile_api_hook_info_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (info_name) ? (char *)info_name : empty_arg;
func_argv[2] = (arguments) ? (char *)arguments : empty_arg;
- return (const char *)weechat_guile_exec (script_callback->script,
+ return (const char *)weechat_guile_exec (script,
WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
}
@@ -2871,25 +2940,29 @@ weechat_guile_api_hook_info (SCM info_name, SCM description,
}
struct t_hashtable *
-weechat_guile_api_hook_info_hashtable_cb (void *data, const char *info_name,
+weechat_guile_api_hook_info_hashtable_cb (const void *pointer, void *data,
+ const char *info_name,
struct t_hashtable *hashtable)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (info_name) ? (char *)info_name : empty_arg;
func_argv[2] = hashtable;
- return (struct t_hashtable *)weechat_guile_exec (script_callback->script,
- WEECHAT_SCRIPT_EXEC_HASHTABLE,
- script_callback->function,
- "ssh", func_argv);
+ return (struct t_hashtable *)weechat_guile_exec (
+ script,
+ WEECHAT_SCRIPT_EXEC_HASHTABLE,
+ ptr_function,
+ "ssh", func_argv);
}
return NULL;
@@ -2924,27 +2997,31 @@ weechat_guile_api_hook_info_hashtable (SCM info_name, SCM description,
}
struct t_infolist *
-weechat_guile_api_hook_infolist_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+weechat_guile_api_hook_infolist_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
struct t_infolist *result;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (infolist_name) ? (char *)infolist_name : empty_arg;
- func_argv[2] = API_PTR2STR(pointer);
+ func_argv[2] = API_PTR2STR(obj_pointer);
func_argv[3] = (arguments) ? (char *)arguments : empty_arg;
- result = (struct t_infolist *)weechat_guile_exec (script_callback->script,
- WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function,
- "ssss", func_argv);
+ result = (struct t_infolist *)weechat_guile_exec (
+ script,
+ WEECHAT_SCRIPT_EXEC_STRING,
+ ptr_function,
+ "ssss", func_argv);
if (func_argv[2])
free (func_argv[2]);
@@ -2983,23 +3060,27 @@ weechat_guile_api_hook_infolist (SCM infolist_name, SCM description,
}
struct t_hashtable *
-weechat_guile_api_hook_focus_cb (void *data, struct t_hashtable *info)
+weechat_guile_api_hook_focus_cb (const void *pointer, void *data,
+ struct t_hashtable *info)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = info;
- return (struct t_hashtable *)weechat_guile_exec (script_callback->script,
- WEECHAT_SCRIPT_EXEC_HASHTABLE,
- script_callback->function,
- "sh", func_argv);
+ return (struct t_hashtable *)weechat_guile_exec (
+ script,
+ WEECHAT_SCRIPT_EXEC_HASHTABLE,
+ ptr_function,
+ "sh", func_argv);
}
return NULL;
@@ -3048,9 +3129,7 @@ weechat_guile_api_unhook (SCM hook)
if (!scm_is_string (hook))
API_WRONG_ARGS(API_RETURN_ERROR);
- plugin_script_api_unhook (weechat_guile_plugin,
- guile_current_script,
- API_STR2PTR(API_SCM_TO_STRING(hook)));
+ weechat_unhook (API_STR2PTR(API_SCM_TO_STRING(hook)));
API_RETURN_OK;
}
@@ -3060,31 +3139,34 @@ weechat_guile_api_unhook_all ()
{
API_INIT_FUNC(1, "unhook_all", API_RETURN_ERROR);
- plugin_script_api_unhook_all (weechat_guile_plugin, guile_current_script);
+ weechat_unhook_all (guile_current_script->name);
API_RETURN_OK;
}
int
-weechat_guile_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
+weechat_guile_api_buffer_input_data_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
const char *input_data)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
func_argv[2] = (input_data) ? (char *)input_data : empty_arg;
- rc = (int *) weechat_guile_exec (script_callback->script,
+ rc = (int *) weechat_guile_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -3104,23 +3186,26 @@ weechat_guile_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
}
int
-weechat_guile_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
+weechat_guile_api_buffer_close_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
- rc = (int *) weechat_guile_exec (script_callback->script,
+ rc = (int *) weechat_guile_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (!rc)
@@ -3226,9 +3311,7 @@ weechat_guile_api_buffer_close (SCM buffer)
if (!scm_is_string (buffer))
API_WRONG_ARGS(API_RETURN_ERROR);
- plugin_script_api_buffer_close (weechat_guile_plugin,
- guile_current_script,
- API_STR2PTR(API_SCM_TO_STRING(buffer)));
+ weechat_buffer_close (API_STR2PTR(API_SCM_TO_STRING(buffer)));
API_RETURN_OK;
}
@@ -3715,31 +3798,34 @@ weechat_guile_api_bar_item_search (SCM name)
}
char *
-weechat_guile_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
+weechat_guile_api_bar_item_build_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
struct t_gui_window *window,
struct t_gui_buffer *buffer,
struct t_hashtable *extra_info)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[5];
char empty_arg[1] = { '\0' }, *ret;
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- if (strncmp (script_callback->function, "(extra)", 7) == 0)
+ if (strncmp (ptr_function, "(extra)", 7) == 0)
{
/* new callback: data, item, window, buffer, extra_info */
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(item);
func_argv[2] = API_PTR2STR(window);
func_argv[3] = API_PTR2STR(buffer);
func_argv[4] = extra_info;
- ret = (char *)weechat_guile_exec (script_callback->script,
+ ret = (char *)weechat_guile_exec (script,
WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function + 7,
+ ptr_function + 7,
"ssssh", func_argv);
if (func_argv[1])
@@ -3752,13 +3838,13 @@ weechat_guile_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
else
{
/* old callback: data, item, window */
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(item);
func_argv[2] = API_PTR2STR(window);
- ret = (char *)weechat_guile_exec (script_callback->script,
+ ret = (char *)weechat_guile_exec (script,
WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (func_argv[1])
@@ -3813,9 +3899,7 @@ weechat_guile_api_bar_item_remove (SCM item)
if (!scm_is_string (item))
API_WRONG_ARGS(API_RETURN_ERROR);
- plugin_script_api_bar_item_remove (weechat_guile_plugin,
- guile_current_script,
- API_STR2PTR(API_SCM_TO_STRING(item)));
+ weechat_bar_item_remove (API_STR2PTR(API_SCM_TO_STRING(item)));
API_RETURN_OK;
}
@@ -4587,65 +4671,33 @@ weechat_guile_api_hdata_get_string (SCM hdata, SCM property)
API_RETURN_STRING(result);
}
-SCM
-weechat_guile_api_upgrade_new (SCM filename, SCM write)
-{
- char *result;
- SCM return_value;
-
- API_INIT_FUNC(1, "upgrade_new", API_RETURN_EMPTY);
- if (!scm_is_string (filename) || !scm_is_integer (write))
- API_WRONG_ARGS(API_RETURN_EMPTY);
-
- result = API_PTR2STR(weechat_upgrade_new (API_SCM_TO_STRING(filename),
- scm_to_int (write)));
-
- API_RETURN_STRING_FREE(result);
-}
-
-SCM
-weechat_guile_api_upgrade_write_object (SCM upgrade_file, SCM object_id,
- SCM infolist)
-{
- int rc;
-
- API_INIT_FUNC(1, "upgrade_write_object", API_RETURN_INT(0));
- if (!scm_is_string (upgrade_file) || !scm_is_integer (object_id)
- || !scm_is_string (infolist))
- API_WRONG_ARGS(API_RETURN_INT(0));
-
- rc = weechat_upgrade_write_object (API_STR2PTR(API_SCM_TO_STRING(upgrade_file)),
- scm_to_int (object_id),
- API_STR2PTR(API_SCM_TO_STRING(infolist)));
-
- API_RETURN_INT(rc);
-}
-
int
-weechat_guile_api_upgrade_read_cb (void *data,
+weechat_guile_api_upgrade_read_cb (const void *pointer, void *data,
struct t_upgrade_file *upgrade_file,
int object_id,
struct t_infolist *infolist)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' }, str_object_id[32];
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (str_object_id, sizeof (str_object_id), "%d", object_id);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(upgrade_file);
func_argv[2] = str_object_id;
func_argv[3] = API_PTR2STR(infolist);
- rc = (int *) weechat_guile_exec (script_callback->script,
+ rc = (int *) weechat_guile_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssss", func_argv);
if (!rc)
@@ -4667,21 +4719,56 @@ weechat_guile_api_upgrade_read_cb (void *data,
}
SCM
-weechat_guile_api_upgrade_read (SCM upgrade_file, SCM function, SCM data)
+weechat_guile_api_upgrade_new (SCM filename, SCM function, SCM data)
+{
+ char *result;
+ SCM return_value;
+
+ API_INIT_FUNC(1, "upgrade_new", API_RETURN_EMPTY);
+ if (!scm_is_string (filename) || !scm_is_string (function)
+ || !scm_is_string (data))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = API_PTR2STR(
+ plugin_script_api_upgrade_new (
+ weechat_guile_plugin,
+ guile_current_script,
+ API_SCM_TO_STRING(filename),
+ &weechat_guile_api_upgrade_read_cb,
+ API_SCM_TO_STRING(function),
+ API_SCM_TO_STRING(data)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+SCM
+weechat_guile_api_upgrade_write_object (SCM upgrade_file, SCM object_id,
+ SCM infolist)
+{
+ int rc;
+
+ API_INIT_FUNC(1, "upgrade_write_object", API_RETURN_INT(0));
+ if (!scm_is_string (upgrade_file) || !scm_is_integer (object_id)
+ || !scm_is_string (infolist))
+ API_WRONG_ARGS(API_RETURN_INT(0));
+
+ rc = weechat_upgrade_write_object (API_STR2PTR(API_SCM_TO_STRING(upgrade_file)),
+ scm_to_int (object_id),
+ API_STR2PTR(API_SCM_TO_STRING(infolist)));
+
+ API_RETURN_INT(rc);
+}
+
+SCM
+weechat_guile_api_upgrade_read (SCM upgrade_file)
{
int rc;
API_INIT_FUNC(1, "upgrade_read", API_RETURN_INT(0));
- if (!scm_is_string (upgrade_file) || !scm_is_string (function)
- || !scm_is_string (data))
+ if (!scm_is_string (upgrade_file))
API_WRONG_ARGS(API_RETURN_INT(0));
- rc = plugin_script_api_upgrade_read (weechat_guile_plugin,
- guile_current_script,
- API_STR2PTR(API_SCM_TO_STRING(upgrade_file)),
- &weechat_guile_api_upgrade_read_cb,
- API_SCM_TO_STRING(function),
- API_SCM_TO_STRING(data));
+ rc = weechat_upgrade_read (API_STR2PTR(API_SCM_TO_STRING(upgrade_file)));
API_RETURN_INT(rc);
}
@@ -4906,9 +4993,9 @@ weechat_guile_api_module_init (void *data)
API_DEF_FUNC(hdata_hashtable, 3);
API_DEF_FUNC(hdata_update, 3);
API_DEF_FUNC(hdata_get_string, 2);
- API_DEF_FUNC(upgrade_new, 2);
+ API_DEF_FUNC(upgrade_new, 3);
API_DEF_FUNC(upgrade_write_object, 3);
- API_DEF_FUNC(upgrade_read, 3);
+ API_DEF_FUNC(upgrade_read, 1);
API_DEF_FUNC(upgrade_close, 1);
/* interface constants */
diff --git a/src/plugins/guile/weechat-guile-api.h b/src/plugins/guile/weechat-guile-api.h
index 42dae4a4c..bb0972677 100644
--- a/src/plugins/guile/weechat-guile-api.h
+++ b/src/plugins/guile/weechat-guile-api.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -20,10 +20,12 @@
#ifndef WEECHAT_GUILE_API_H
#define WEECHAT_GUILE_API_H 1
-extern int weechat_guile_api_buffer_input_data_cb (void *data,
+extern int weechat_guile_api_buffer_input_data_cb (const void *pointer,
+ void *data,
struct t_gui_buffer *buffer,
const char *input_data);
-extern int weechat_guile_api_buffer_close_cb (void *data,
+extern int weechat_guile_api_buffer_close_cb (const void *pointer,
+ void *data,
struct t_gui_buffer *buffer);
extern void weechat_guile_api_module_init (void *data);
diff --git a/src/plugins/guile/weechat-guile.c b/src/plugins/guile/weechat-guile.c
index fa962ea43..b24cf7203 100644
--- a/src/plugins/guile/weechat-guile.c
+++ b/src/plugins/guile/weechat-guile.c
@@ -1,7 +1,7 @@
/*
* weechat-guile.c - guile (scheme) plugin for WeeChat
*
- * Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -587,13 +587,15 @@ weechat_guile_reload_name (const char *name)
*/
int
-weechat_guile_command_cb (void *data, struct t_gui_buffer *buffer,
+weechat_guile_command_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
char *ptr_name, *path_script;
SCM value;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
@@ -700,11 +702,13 @@ weechat_guile_command_cb (void *data, struct t_gui_buffer *buffer,
*/
int
-weechat_guile_completion_cb (void *data, const char *completion_item,
+weechat_guile_completion_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -719,9 +723,11 @@ weechat_guile_completion_cb (void *data, const char *completion_item,
*/
struct t_hdata *
-weechat_guile_hdata_cb (void *data, const char *hdata_name)
+weechat_guile_hdata_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
return plugin_script_hdata_script (weechat_plugin,
@@ -734,10 +740,12 @@ weechat_guile_hdata_cb (void *data, const char *hdata_name)
*/
struct t_infolist *
-weechat_guile_infolist_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+weechat_guile_infolist_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (!infolist_name || !infolist_name[0])
@@ -746,7 +754,7 @@ weechat_guile_infolist_cb (void *data, const char *infolist_name,
if (weechat_strcasecmp (infolist_name, "guile_script") == 0)
{
return plugin_script_infolist_list_scripts (weechat_guile_plugin,
- guile_scripts, pointer,
+ guile_scripts, obj_pointer,
arguments);
}
@@ -758,10 +766,12 @@ weechat_guile_infolist_cb (void *data, const char *infolist_name,
*/
int
-weechat_guile_signal_debug_dump_cb (void *data, const char *signal,
+weechat_guile_signal_debug_dump_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -780,10 +790,12 @@ weechat_guile_signal_debug_dump_cb (void *data, const char *signal,
*/
int
-weechat_guile_signal_debug_libs_cb (void *data, const char *signal,
+weechat_guile_signal_debug_libs_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -803,38 +815,20 @@ weechat_guile_signal_debug_libs_cb (void *data, const char *signal,
}
/*
- * Callback called when a buffer is closed.
- */
-
-int
-weechat_guile_signal_buffer_closed_cb (void *data, const char *signal,
- const char *type_data,
- void *signal_data)
-{
- /* make C compiler happy */
- (void) data;
- (void) signal;
- (void) type_data;
-
- if (signal_data)
- plugin_script_remove_buffer_callbacks (guile_scripts, signal_data);
-
- return WEECHAT_RC_OK;
-}
-
-/*
* Timer for executing actions.
*/
int
-weechat_guile_timer_action_cb (void *data, int remaining_calls)
+weechat_guile_timer_action_cb (const void *pointer, void *data,
+ int remaining_calls)
{
/* make C compiler happy */
+ (void) data;
(void) remaining_calls;
- if (data)
+ if (pointer)
{
- if (data == &guile_action_install_list)
+ if (pointer == &guile_action_install_list)
{
plugin_script_action_install (weechat_guile_plugin,
guile_scripts,
@@ -843,7 +837,7 @@ weechat_guile_timer_action_cb (void *data, int remaining_calls)
&guile_quiet,
&guile_action_install_list);
}
- else if (data == &guile_action_remove_list)
+ else if (pointer == &guile_action_remove_list)
{
plugin_script_action_remove (weechat_guile_plugin,
guile_scripts,
@@ -851,7 +845,7 @@ weechat_guile_timer_action_cb (void *data, int remaining_calls)
&guile_quiet,
&guile_action_remove_list);
}
- else if (data == &guile_action_autoload_list)
+ else if (pointer == &guile_action_autoload_list)
{
plugin_script_action_autoload (weechat_guile_plugin,
&guile_quiet,
@@ -867,11 +861,13 @@ weechat_guile_timer_action_cb (void *data, int remaining_calls)
*/
int
-weechat_guile_signal_script_action_cb (void *data, const char *signal,
+weechat_guile_signal_script_action_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data,
void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
@@ -882,7 +878,7 @@ weechat_guile_signal_script_action_cb (void *data, const char *signal,
(const char *)signal_data);
weechat_hook_timer (1, 0, 1,
&weechat_guile_timer_action_cb,
- &guile_action_install_list);
+ &guile_action_install_list, NULL);
}
else if (strcmp (signal, "guile_script_remove") == 0)
{
@@ -890,7 +886,7 @@ weechat_guile_signal_script_action_cb (void *data, const char *signal,
(const char *)signal_data);
weechat_hook_timer (1, 0, 1,
&weechat_guile_timer_action_cb,
- &guile_action_remove_list);
+ &guile_action_remove_list, NULL);
}
else if (strcmp (signal, "guile_script_autoload") == 0)
{
@@ -898,7 +894,7 @@ weechat_guile_signal_script_action_cb (void *data, const char *signal,
(const char *)signal_data);
weechat_hook_timer (1, 0, 1,
&weechat_guile_timer_action_cb,
- &guile_action_autoload_list);
+ &guile_action_autoload_list, NULL);
}
}
@@ -996,7 +992,6 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
init.callback_infolist = &weechat_guile_infolist_cb;
init.callback_signal_debug_dump = &weechat_guile_signal_debug_dump_cb;
init.callback_signal_debug_libs = &weechat_guile_signal_debug_libs_cb;
- init.callback_signal_buffer_closed = &weechat_guile_signal_buffer_closed_cb;
init.callback_signal_script_action = &weechat_guile_signal_script_action_cb;
init.callback_load_file = &weechat_guile_load_cb;
diff --git a/src/plugins/guile/weechat-guile.h b/src/plugins/guile/weechat-guile.h
index 7d5446568..537757623 100644
--- a/src/plugins/guile/weechat-guile.h
+++ b/src/plugins/guile/weechat-guile.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/CMakeLists.txt b/src/plugins/irc/CMakeLists.txt
index 399dc89c4..b773dcf3e 100644
--- a/src/plugins/irc/CMakeLists.txt
+++ b/src/plugins/irc/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/irc/Makefile.am b/src/plugins/irc/Makefile.am
index 85af3f343..a086e3edf 100644
--- a/src/plugins/irc/Makefile.am
+++ b/src/plugins/irc/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/irc/irc-bar-item.c b/src/plugins/irc/irc-bar-item.c
index 740a6f6a9..fb599fb02 100644
--- a/src/plugins/irc/irc-bar-item.c
+++ b/src/plugins/irc/irc-bar-item.c
@@ -1,7 +1,7 @@
/*
* irc-bar-item.c - bar items for IRC plugin
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -34,65 +34,12 @@
/*
- * Returns content of bar item "away": bar item with away indicator.
- */
-
-char *
-irc_bar_item_away (void *data, struct t_gui_bar_item *item,
- struct t_gui_window *window, struct t_gui_buffer *buffer,
- struct t_hashtable *extra_info)
-{
- struct t_irc_server *server;
- char *buf, *message;
- int length;
-
- /* make C compiler happy */
- (void) data;
- (void) item;
- (void) window;
- (void) extra_info;
-
- if (!buffer)
- return NULL;
-
- buf = NULL;
-
- irc_buffer_get_server_and_channel (buffer, &server, NULL);
-
- if (server && server->is_away)
- {
- if (weechat_config_boolean (irc_config_look_item_away_message)
- && server->away_message && server->away_message[0])
- {
- message = strdup (server->away_message);
- }
- else
- {
- message = strdup (_("away"));
- }
- if (message)
- {
- length = strlen (message) + 64 + 1;
- buf = malloc (length);
- if (buf)
- {
- snprintf (buf, length, "%s%s",
- IRC_COLOR_ITEM_AWAY,
- message);
- }
- free (message);
- }
- }
-
- return buf;
-}
-
-/*
* Returns content of bar item "buffer_plugin": bar item with buffer plugin.
*/
char *
-irc_bar_item_buffer_plugin (void *data, struct t_gui_bar_item *item,
+irc_bar_item_buffer_plugin (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
struct t_gui_window *window,
struct t_gui_buffer *buffer,
struct t_hashtable *extra_info)
@@ -104,6 +51,7 @@ irc_bar_item_buffer_plugin (void *data, struct t_gui_bar_item *item,
struct t_irc_channel *channel;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) window;
@@ -252,12 +200,14 @@ irc_bar_item_buffer_name_content (struct t_gui_buffer *buffer, int short_name)
*/
char *
-irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item,
+irc_bar_item_buffer_name (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
struct t_gui_window *window,
struct t_gui_buffer *buffer,
struct t_hashtable *extra_info)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) window;
@@ -272,12 +222,14 @@ irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item,
*/
char *
-irc_bar_item_buffer_short_name (void *data, struct t_gui_bar_item *item,
+irc_bar_item_buffer_short_name (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
struct t_gui_window *window,
struct t_gui_buffer *buffer,
struct t_hashtable *extra_info)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) window;
@@ -291,7 +243,8 @@ irc_bar_item_buffer_short_name (void *data, struct t_gui_bar_item *item,
*/
char *
-irc_bar_item_buffer_modes (void *data, struct t_gui_bar_item *item,
+irc_bar_item_buffer_modes (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
struct t_gui_window *window,
struct t_gui_buffer *buffer,
struct t_hashtable *extra_info)
@@ -303,6 +256,7 @@ irc_bar_item_buffer_modes (void *data, struct t_gui_bar_item *item,
struct t_irc_channel *channel;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) window;
@@ -351,7 +305,8 @@ irc_bar_item_buffer_modes (void *data, struct t_gui_bar_item *item,
*/
char *
-irc_bar_item_channel (void *data, struct t_gui_bar_item *item,
+irc_bar_item_channel (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
struct t_gui_window *window, struct t_gui_buffer *buffer,
struct t_hashtable *extra_info)
{
@@ -362,6 +317,7 @@ irc_bar_item_channel (void *data, struct t_gui_bar_item *item,
struct t_irc_channel *channel;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) window;
@@ -428,7 +384,8 @@ irc_bar_item_channel (void *data, struct t_gui_bar_item *item,
*/
char *
-irc_bar_item_lag (void *data, struct t_gui_bar_item *item,
+irc_bar_item_lag (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
struct t_gui_window *window, struct t_gui_buffer *buffer,
struct t_hashtable *extra_info)
{
@@ -436,6 +393,7 @@ irc_bar_item_lag (void *data, struct t_gui_bar_item *item,
struct t_irc_server *server;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) window;
@@ -467,7 +425,8 @@ irc_bar_item_lag (void *data, struct t_gui_bar_item *item,
*/
char *
-irc_bar_item_input_prompt (void *data, struct t_gui_bar_item *item,
+irc_bar_item_input_prompt (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
struct t_gui_window *window,
struct t_gui_buffer *buffer,
struct t_hashtable *extra_info)
@@ -479,6 +438,7 @@ irc_bar_item_input_prompt (void *data, struct t_gui_bar_item *item,
int length;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) window;
@@ -548,7 +508,8 @@ irc_bar_item_input_prompt (void *data, struct t_gui_bar_item *item,
*/
char *
-irc_bar_item_nick_modes (void *data, struct t_gui_bar_item *item,
+irc_bar_item_nick_modes (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
struct t_gui_window *window,
struct t_gui_buffer *buffer,
struct t_hashtable *extra_info)
@@ -558,6 +519,7 @@ irc_bar_item_nick_modes (void *data, struct t_gui_bar_item *item,
int length;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) item;
(void) window;
@@ -587,7 +549,7 @@ irc_bar_item_nick_modes (void *data, struct t_gui_bar_item *item,
*/
struct t_hashtable *
-irc_bar_item_focus_buffer_nicklist (void *data,
+irc_bar_item_focus_buffer_nicklist (const void *pointer, void *data,
struct t_hashtable *info)
{
long unsigned int value;
@@ -609,6 +571,7 @@ irc_bar_item_focus_buffer_nicklist (void *data,
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (ptr_server && ptr_channel)
@@ -633,10 +596,12 @@ irc_bar_item_focus_buffer_nicklist (void *data,
*/
int
-irc_bar_item_buffer_switch (void *data, const char *signal,
+irc_bar_item_buffer_switch (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -673,17 +638,26 @@ irc_bar_item_update_channel ()
void
irc_bar_item_init ()
{
- weechat_bar_item_new ("away", &irc_bar_item_away, NULL);
- weechat_bar_item_new ("buffer_plugin", &irc_bar_item_buffer_plugin, NULL);
- weechat_bar_item_new ("buffer_name", &irc_bar_item_buffer_name, NULL);
- weechat_bar_item_new ("buffer_short_name", &irc_bar_item_buffer_short_name, NULL);
- weechat_bar_item_new ("buffer_modes", &irc_bar_item_buffer_modes, NULL);
- weechat_bar_item_new ("irc_channel", &irc_bar_item_channel, NULL);
- weechat_bar_item_new ("lag", &irc_bar_item_lag, NULL);
- weechat_bar_item_new ("input_prompt", &irc_bar_item_input_prompt, NULL);
- weechat_bar_item_new ("irc_nick_modes", &irc_bar_item_nick_modes, NULL);
+ weechat_bar_item_new ("buffer_plugin",
+ &irc_bar_item_buffer_plugin, NULL, NULL);
+ weechat_bar_item_new ("buffer_name",
+ &irc_bar_item_buffer_name, NULL, NULL);
+ weechat_bar_item_new ("buffer_short_name",
+ &irc_bar_item_buffer_short_name, NULL, NULL);
+ weechat_bar_item_new ("buffer_modes",
+ &irc_bar_item_buffer_modes, NULL, NULL);
+ weechat_bar_item_new ("irc_channel",
+ &irc_bar_item_channel, NULL, NULL);
+ weechat_bar_item_new ("lag",
+ &irc_bar_item_lag, NULL, NULL);
+ weechat_bar_item_new ("input_prompt",
+ &irc_bar_item_input_prompt, NULL, NULL);
+ weechat_bar_item_new ("irc_nick_modes",
+ &irc_bar_item_nick_modes, NULL, NULL);
+
weechat_hook_focus ("buffer_nicklist",
- &irc_bar_item_focus_buffer_nicklist, NULL);
+ &irc_bar_item_focus_buffer_nicklist, NULL, NULL);
+
weechat_hook_signal ("buffer_switch",
- &irc_bar_item_buffer_switch, NULL);
+ &irc_bar_item_buffer_switch, NULL, NULL);
}
diff --git a/src/plugins/irc/irc-bar-item.h b/src/plugins/irc/irc-bar-item.h
index 688e9f665..948abd75d 100644
--- a/src/plugins/irc/irc-bar-item.h
+++ b/src/plugins/irc/irc-bar-item.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-buffer.c b/src/plugins/irc/irc-buffer.c
index a1be1c361..bee87ed56 100644
--- a/src/plugins/irc/irc-buffer.c
+++ b/src/plugins/irc/irc-buffer.c
@@ -1,7 +1,7 @@
/*
* irc-buffer.c - buffer functions for IRC plugin
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -112,13 +112,15 @@ irc_buffer_build_name (const char *server, const char *channel)
*/
int
-irc_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
+irc_buffer_close_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer)
{
struct t_irc_channel *next_channel;
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (buffer == irc_raw_buffer)
@@ -175,15 +177,18 @@ irc_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
*/
int
-irc_buffer_nickcmp_cb (void *data,
+irc_buffer_nickcmp_cb (const void *pointer, void *data,
struct t_gui_buffer *buffer,
const char *nick1,
const char *nick2)
{
struct t_irc_server *server;
- if (data)
- server = (struct t_irc_server *)data;
+ /* make C compiler happy */
+ (void) data;
+
+ if (pointer)
+ server = (struct t_irc_server *)pointer;
else
irc_buffer_get_server_and_channel (buffer, &server, NULL);
diff --git a/src/plugins/irc/irc-buffer.h b/src/plugins/irc/irc-buffer.h
index e02ffea1e..c58dfe73e 100644
--- a/src/plugins/irc/irc-buffer.h
+++ b/src/plugins/irc/irc-buffer.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -53,11 +53,11 @@ extern void irc_buffer_get_server_and_channel (struct t_gui_buffer *buffer,
struct t_irc_channel **channel);
extern const char *irc_buffer_build_name (const char *server,
const char *channel);
-extern int irc_buffer_close_cb (void *data, struct t_gui_buffer *buffer);
-extern int irc_buffer_nickcmp_cb (void *data,
+extern int irc_buffer_close_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer);
+extern int irc_buffer_nickcmp_cb (const void *pointer, void *data,
struct t_gui_buffer *buffer,
- const char *nick1,
- const char *nick2);
+ const char *nick1, const char *nick2);
extern struct t_gui_buffer *irc_buffer_search_server_lowest_number ();
extern struct t_gui_buffer *irc_buffer_search_private_lowest_number (struct t_irc_server *server);
diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c
index 11d0c4df1..019c94a0a 100644
--- a/src/plugins/irc/irc-channel.c
+++ b/src/plugins/irc/irc-channel.c
@@ -1,7 +1,7 @@
/*
* irc-channel.c - channel and private chat management for IRC plugin
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -270,8 +270,8 @@ irc_channel_create_buffer (struct t_irc_server *server,
weechat_current_buffer (), "number");
ptr_buffer = weechat_buffer_new (buffer_name,
- &irc_input_data_cb, NULL,
- &irc_buffer_close_cb, NULL);
+ &irc_input_data_cb, NULL, NULL,
+ &irc_buffer_close_cb, NULL, NULL);
if (!ptr_buffer)
return NULL;
@@ -351,7 +351,7 @@ irc_channel_create_buffer (struct t_irc_server *server,
weechat_buffer_set (ptr_buffer, "nicklist_display_groups", "0");
weechat_buffer_set_pointer (ptr_buffer, "nickcmp_callback",
&irc_buffer_nickcmp_cb);
- weechat_buffer_set_pointer (ptr_buffer, "nickcmp_callback_data",
+ weechat_buffer_set_pointer (ptr_buffer, "nickcmp_callback_pointer",
server);
}
@@ -463,8 +463,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
new_channel->checking_whox = 0;
new_channel->away_message = NULL;
new_channel->has_quit_server = 0;
@@ -655,7 +654,7 @@ irc_channel_remove_account (struct t_irc_server *server,
{
if (ptr_nick->account)
free (ptr_nick->account);
- ptr_nick->account = strdup ("*");
+ ptr_nick->account = NULL;
}
}
}
@@ -1024,8 +1023,7 @@ irc_channel_join_smart_filtered_add (struct t_irc_channel *channel,
64,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_TIME,
- NULL,
- NULL);
+ NULL, NULL);
}
if (!channel->join_smart_filtered)
return;
@@ -1224,8 +1222,7 @@ irc_channel_join_smart_filtered_unmask (struct t_irc_channel *channel,
hashtable = weechat_hashtable_new (4,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
if (hashtable)
{
/* update tags in line (remove tag "irc_smart_filter") */
@@ -1280,15 +1277,17 @@ irc_channel_rejoin (struct t_irc_server *server, struct t_irc_channel *channel)
*/
int
-irc_channel_autorejoin_cb (void *data, int remaining_calls)
+irc_channel_autorejoin_cb (const void *pointer, void *data,
+ int remaining_calls)
{
struct t_irc_server *ptr_server, *ptr_server_found;
struct t_irc_channel *ptr_channel_arg, *ptr_channel;
/* make C compiler happy */
+ (void) data;
(void) remaining_calls;
- ptr_channel_arg = (struct t_irc_channel *)data;
+ ptr_channel_arg = (struct t_irc_channel *)pointer;
ptr_server_found = NULL;
for (ptr_server = irc_servers; ptr_server;
@@ -1338,8 +1337,9 @@ irc_channel_display_nick_back_in_pv (struct t_irc_server *server,
{
if (weechat_config_boolean (irc_config_look_display_pv_back))
{
- weechat_printf_tags (
+ weechat_printf_date_tags (
ptr_channel->buffer,
+ 0,
"irc_nick_back",
_("%s%s%s %s(%s%s%s)%s is back on server"),
weechat_prefix ("join"),
@@ -1435,11 +1435,13 @@ irc_channel_free_all (struct t_irc_server *server)
*/
struct t_hdata *
-irc_channel_hdata_channel_cb (void *data, const char *hdata_name)
+irc_channel_hdata_channel_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = weechat_hdata_new (hdata_name, "prev_channel", "next_channel",
@@ -1481,11 +1483,13 @@ irc_channel_hdata_channel_cb (void *data, const char *hdata_name)
*/
struct t_hdata *
-irc_channel_hdata_channel_speaking_cb (void *data, const char *hdata_name)
+irc_channel_hdata_channel_speaking_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = weechat_hdata_new (hdata_name, "prev_nick", "next_nick",
diff --git a/src/plugins/irc/irc-channel.h b/src/plugins/irc/irc-channel.h
index 08f7f1e9b..5c8dd6a9e 100644
--- a/src/plugins/irc/irc-channel.h
+++ b/src/plugins/irc/irc-channel.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -78,6 +78,11 @@ struct t_irc_channel
extern int irc_channel_valid (struct t_irc_server *server,
struct t_irc_channel *channel);
+extern struct t_irc_channel *irc_channel_search (struct t_irc_server *server,
+ const char *channel_name);
+extern struct t_gui_buffer *irc_channel_search_buffer (struct t_irc_server *server,
+ int channel_type,
+ const char *channel_name);
extern struct t_gui_buffer *irc_channel_create_buffer (struct t_irc_server *server,
int channel_type,
const char *channel_name,
@@ -98,8 +103,6 @@ extern void irc_channel_set_modes (struct t_irc_channel *channel,
extern void irc_channel_free (struct t_irc_server *server,
struct t_irc_channel *channel);
extern void irc_channel_free_all (struct t_irc_server *server);
-extern struct t_irc_channel *irc_channel_search (struct t_irc_server *server,
- const char *channel_name);
extern int irc_channel_is_channel (struct t_irc_server *server,
const char *string);
extern const char *irc_channel_get_auto_chantype (struct t_irc_server *server,
@@ -148,13 +151,16 @@ extern void irc_channel_join_smart_filtered_unmask (struct t_irc_channel *channe
const char *nick);
extern void irc_channel_rejoin (struct t_irc_server *server,
struct t_irc_channel *channel);
-extern int irc_channel_autorejoin_cb (void *data, int remaining_calls);
+extern int irc_channel_autorejoin_cb (const void *pointer, void *data,
+ int remaining_calls);
extern void irc_channel_display_nick_back_in_pv (struct t_irc_server *server,
struct t_irc_nick *nick,
const char *nickname);
-extern struct t_hdata *irc_channel_hdata_channel_cb (void *data,
+extern struct t_hdata *irc_channel_hdata_channel_cb (const void *pointer,
+ void *data,
const char *hdata_name);
-extern struct t_hdata *irc_channel_hdata_channel_speaking_cb (void *data,
+extern struct t_hdata *irc_channel_hdata_channel_speaking_cb (const void *pointer,
+ void *data,
const char *hdata_name);
extern int irc_channel_add_to_infolist (struct t_infolist *infolist,
struct t_irc_channel *channel);
diff --git a/src/plugins/irc/irc-color.c b/src/plugins/irc/irc-color.c
index f5f4d2688..5f9c1e52e 100644
--- a/src/plugins/irc/irc-color.c
+++ b/src/plugins/irc/irc-color.c
@@ -1,7 +1,7 @@
/*
* irc-color.c - IRC color decoding/encoding in messages
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -767,12 +767,14 @@ irc_color_decode_ansi (const char *string, int keep_colors)
*/
char *
-irc_color_modifier_cb (void *data, const char *modifier,
- const char *modifier_data, const char *string)
+irc_color_modifier_cb (const void *pointer, void *data,
+ const char *modifier, const char *modifier_data,
+ const char *string)
{
int keep_colors;
/* make C compiler happy */
+ (void) pointer;
(void) data;
keep_colors = (modifier_data && (strcmp (modifier_data, "1") == 0)) ? 1 : 0;
diff --git a/src/plugins/irc/irc-color.h b/src/plugins/irc/irc-color.h
index cc8f58bf6..4bc9ffb8f 100644
--- a/src/plugins/irc/irc-color.h
+++ b/src/plugins/irc/irc-color.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -106,7 +106,8 @@ struct t_irc_color_ansi_state
extern char *irc_color_decode (const char *string, int keep_colors);
extern char *irc_color_encode (const char *string, int keep_colors);
-extern char *irc_color_modifier_cb (void *data, const char *modifier,
+extern char *irc_color_modifier_cb (const void *pointer, void *data,
+ const char *modifier,
const char *modifier_data,
const char *string);
extern char *irc_color_for_tags (const char *color);
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c
index 3edb5433a..41ce07719 100644
--- a/src/plugins/irc/irc-command.c
+++ b/src/plugins/irc/irc-command.c
@@ -1,7 +1,7 @@
/*
* irc-command.c - IRC commands
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org>
*
* This file is part of WeeChat, the extensible chat client.
@@ -142,8 +142,7 @@ irc_command_mode_nicks (struct t_irc_server *server,
nicks_sent = weechat_hashtable_new (128,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
if (!nicks_sent)
return;
@@ -241,14 +240,13 @@ irc_command_mode_nicks (struct t_irc_server *server,
* the server.
*/
-int
-irc_command_admin (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(admin)
{
IRC_BUFFER_GET_SERVER(buffer);
IRC_COMMAND_CHECK_SERVER("admin", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv;
@@ -390,9 +388,7 @@ irc_command_exec_all_channels (struct t_irc_server *server,
* connected servers.
*/
-int
-irc_command_allchan (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(allchan)
{
int i, current_server;
const char *ptr_exclude_channels, *ptr_command;
@@ -400,6 +396,7 @@ irc_command_allchan (void *data, struct t_gui_buffer *buffer, int argc,
IRC_BUFFER_GET_SERVER(buffer);
/* make C compiler happy */
+ (void) pointer;
(void) data;
WEECHAT_COMMAND_MIN_ARGS(2, "");
@@ -441,9 +438,7 @@ irc_command_allchan (void *data, struct t_gui_buffer *buffer, int argc,
* connected servers.
*/
-int
-irc_command_allpv (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(allpv)
{
int i, current_server;
const char *ptr_exclude_channels, *ptr_command;
@@ -451,6 +446,7 @@ irc_command_allpv (void *data, struct t_gui_buffer *buffer, int argc,
IRC_BUFFER_GET_SERVER(buffer);
/* make C compiler happy */
+ (void) pointer;
(void) data;
WEECHAT_COMMAND_MIN_ARGS(2, "");
@@ -593,14 +589,13 @@ irc_command_exec_all_servers (const char *exclude_servers, const char *command)
* Callback for command "/allserv": executes a command on all connected servers.
*/
-int
-irc_command_allserv (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(allserv)
{
int i;
const char *ptr_exclude_servers, *ptr_command;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
@@ -645,8 +640,9 @@ irc_command_me_channel_display (struct t_irc_server *server,
irc_color_decode (arguments,
weechat_config_boolean (irc_config_network_colors_send)) : NULL;
ptr_nick = irc_nick_search (server, channel, server->nick);
- weechat_printf_tags (
+ weechat_printf_date_tags (
channel->buffer,
+ 0,
irc_protocol_tags ("privmsg", "irc_action,notify_none,no_highlight",
server->nick, NULL),
"%s%s%s%s%s%s%s",
@@ -731,16 +727,17 @@ irc_command_display_away (struct t_irc_server *server, const char *string1,
if ((ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
|| (ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE))
{
- weechat_printf_tags (ptr_channel->buffer,
- "away_info",
- "%s[%s%s%s %s: %s%s]",
- IRC_COLOR_CHAT_DELIMITERS,
- IRC_COLOR_CHAT_NICK_SELF,
- server->nick,
- IRC_COLOR_RESET,
- string1,
- string2,
- IRC_COLOR_CHAT_DELIMITERS);
+ weechat_printf_date_tags (ptr_channel->buffer,
+ 0,
+ "away_info",
+ "%s[%s%s%s %s: %s%s]",
+ IRC_COLOR_CHAT_DELIMITERS,
+ IRC_COLOR_CHAT_NICK_SELF,
+ server->nick,
+ IRC_COLOR_RESET,
+ string1,
+ string2,
+ IRC_COLOR_CHAT_DELIMITERS);
}
}
}
@@ -889,13 +886,12 @@ irc_command_away_server (struct t_irc_server *server, const char *arguments,
* Callback for command "/away": toggles away status.
*/
-int
-irc_command_away (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(away)
{
IRC_BUFFER_GET_SERVER(buffer);
/* make C compiler happy */
+ (void) pointer;
(void) data;
if ((argc >= 2) && (weechat_strcasecmp (argv[1], "-all") == 0))
@@ -928,7 +924,8 @@ irc_command_away (void *data, struct t_gui_buffer *buffer, int argc,
*/
int
-irc_command_run_away (void *data, struct t_gui_buffer *buffer,
+irc_command_run_away (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
const char *command)
{
int argc;
@@ -939,7 +936,7 @@ irc_command_run_away (void *data, struct t_gui_buffer *buffer,
if (argv && argv_eol)
{
- irc_command_away (data, buffer, argc, argv, argv_eol);
+ irc_command_away (pointer, data, buffer, argc, argv, argv_eol);
}
if (argv)
@@ -993,9 +990,7 @@ irc_command_send_ban (struct t_irc_server *server,
* Callback for command "/ban": bans nicks or hosts.
*/
-int
-irc_command_ban (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(ban)
{
char *pos_channel;
int pos_args;
@@ -1004,6 +999,7 @@ irc_command_ban (void *data, struct t_gui_buffer *buffer, int argc,
IRC_COMMAND_CHECK_SERVER("ban", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv_eol;
@@ -1072,6 +1068,47 @@ irc_command_ban (void *data, struct t_gui_buffer *buffer, int argc,
}
/*
+ * Callback for command "/cap": client capability negotiation.
+ *
+ * Docs on capability negotiation:
+ * https://tools.ietf.org/html/draft-mitchell-irc-capabilities-01
+ * http://ircv3.net/specs/core/capability-negotiation-3.1.html
+ * http://ircv3.net/specs/core/capability-negotiation-3.2.html
+ */
+
+IRC_COMMAND_CALLBACK(cap)
+{
+ IRC_BUFFER_GET_SERVER(buffer);
+ IRC_COMMAND_CHECK_SERVER("cap", 1);
+
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+
+ if (argc > 1)
+ {
+ irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
+ "CAP %s%s%s",
+ argv[1],
+ (argv_eol[2]) ? " :" : "",
+ (argv_eol[2]) ? argv_eol[2] : "");
+ }
+ else
+ {
+ /*
+ * by default, show supported capabilities and capabilities currently
+ * enabled
+ */
+ irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
+ "CAP LS");
+ irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
+ "CAP LIST");
+ }
+
+ return WEECHAT_RC_OK;
+}
+
+/*
* Connects to one server.
*
* Returns:
@@ -1123,9 +1160,7 @@ irc_command_connect_one_server (struct t_irc_server *server,
* Callback for command "/connect": connects to server(s).
*/
-int
-irc_command_connect (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(connect)
{
int i, nb_connect, connect_ok, all_servers, all_opened, switch_address;
int no_join, autoconnect;
@@ -1134,6 +1169,7 @@ irc_command_connect (void *data, struct t_gui_buffer *buffer, int argc,
IRC_BUFFER_GET_SERVER(buffer);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv_eol;
@@ -1320,73 +1356,109 @@ irc_command_connect (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/ctcp": sends a CTCP message.
*/
-int
-irc_command_ctcp (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(ctcp)
{
- char *irc_cmd, str_time[512];
+ char **targets, *ctcp_type, str_time[512];
+ const char *ctcp_target, *ctcp_args;
+ int num_targets, arg_target, arg_type, arg_args, i;
struct timeval tv;
- IRC_BUFFER_GET_SERVER(buffer);
- IRC_COMMAND_CHECK_SERVER("ctcp", 1);
+ IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
/* make C compiler happy */
+ (void) pointer;
(void) data;
WEECHAT_COMMAND_MIN_ARGS(3, "");
- irc_cmd = strdup (argv[2]);
- if (!irc_cmd)
+ arg_target = 1;
+ arg_type = 2;
+ arg_args = 3;
+
+ if ((argc >= 5) && (weechat_strcasecmp (argv[1], "-server") == 0))
+ {
+ ptr_server = irc_server_search (argv[2]);
+ ptr_channel = NULL;
+ arg_target = 3;
+ arg_type = 4;
+ arg_args = 5;
+ }
+
+ IRC_COMMAND_CHECK_SERVER("ctcp", 1);
+
+ targets = weechat_string_split (argv[arg_target], ",", 0, 0, &num_targets);
+ if (!targets)
+ WEECHAT_COMMAND_ERROR;
+
+ ctcp_type = strdup (argv[arg_type]);
+ if (!ctcp_type)
+ {
+ weechat_string_free_split (targets);
WEECHAT_COMMAND_ERROR;
+ }
- weechat_string_toupper (irc_cmd);
+ weechat_string_toupper (ctcp_type);
- if ((weechat_strcasecmp (argv[2], "ping") == 0) && !argv_eol[3])
+ if ((strcmp (ctcp_type, "PING") == 0) && !argv_eol[arg_args])
{
+ /* generate argument for PING if not provided */
gettimeofday (&tv, NULL);
snprintf (str_time, sizeof (str_time), "%ld %ld",
(long)tv.tv_sec, (long)tv.tv_usec);
- irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
- "PRIVMSG %s :\01PING %s\01",
- argv[1], str_time);
- weechat_printf (
- irc_msgbuffer_get_target_buffer (
- ptr_server, argv[1], NULL, "ctcp", NULL),
- _("%sCTCP query to %s%s%s: %s%s%s%s%s"),
- weechat_prefix ("network"),
- irc_nick_color_for_msg (ptr_server, 0, NULL, argv[1]),
- argv[1],
- IRC_COLOR_RESET,
- IRC_COLOR_CHAT_CHANNEL,
- irc_cmd,
- IRC_COLOR_RESET,
- " ",
- str_time);
+ ctcp_args = str_time;
}
else
{
- irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
- "PRIVMSG %s :\01%s%s%s\01",
- argv[1],
- irc_cmd,
- (argv_eol[3]) ? " " : "",
- (argv_eol[3]) ? argv_eol[3] : "");
- weechat_printf (
- irc_msgbuffer_get_target_buffer (
- ptr_server, argv[1], NULL, "ctcp", NULL),
- _("%sCTCP query to %s%s%s: %s%s%s%s%s"),
- weechat_prefix ("network"),
- irc_nick_color_for_msg (ptr_server, 0, NULL, argv[1]),
- argv[1],
- IRC_COLOR_RESET,
- IRC_COLOR_CHAT_CHANNEL,
- irc_cmd,
- IRC_COLOR_RESET,
- (argv_eol[3]) ? " " : "",
- (argv_eol[3]) ? argv_eol[3] : "");
- }
-
- free (irc_cmd);
+ ctcp_args = argv_eol[arg_args];
+ }
+
+ for (i = 0; i < num_targets; i++)
+ {
+ ctcp_target = targets[i];
+
+ if (strcmp (targets[i], "*") == 0)
+ {
+ if (!ptr_channel
+ || ((ptr_channel->type != IRC_CHANNEL_TYPE_CHANNEL)
+ && (ptr_channel->type != IRC_CHANNEL_TYPE_PRIVATE)))
+ {
+ weechat_printf (
+ ptr_server->buffer,
+ _("%s%s: \"%s\" command can only be executed in a channel "
+ "or private buffer"),
+ weechat_prefix ("error"), IRC_PLUGIN_NAME, "ctcp *");
+ ctcp_target = NULL;
+ }
+ else
+ ctcp_target = ptr_channel->name;
+ }
+
+ if (ctcp_target)
+ {
+ irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
+ "PRIVMSG %s :\01%s%s%s\01",
+ ctcp_target,
+ ctcp_type,
+ (ctcp_args) ? " " : "",
+ (ctcp_args) ? ctcp_args : "");
+ weechat_printf (
+ irc_msgbuffer_get_target_buffer (
+ ptr_server, ctcp_target, NULL, "ctcp", NULL),
+ _("%sCTCP query to %s%s%s: %s%s%s%s%s"),
+ weechat_prefix ("network"),
+ irc_nick_color_for_msg (ptr_server, 0, NULL, ctcp_target),
+ ctcp_target,
+ IRC_COLOR_RESET,
+ IRC_COLOR_CHAT_CHANNEL,
+ ctcp_type,
+ IRC_COLOR_RESET,
+ (ctcp_args) ? " " : "",
+ (ctcp_args) ? ctcp_args : "");
+ }
+ }
+
+ free (ctcp_type);
+ weechat_string_free_split (targets);
return WEECHAT_RC_OK;
}
@@ -1395,12 +1467,10 @@ irc_command_ctcp (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/cycle": leaves and rejoins a channel.
*/
-int
-irc_command_cycle (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(cycle)
{
- char *channel_name, *pos_args, *buf;
- const char *version, *ptr_arg, *msg_part;
+ char *channel_name, *pos_args, *msg;
+ const char *ptr_arg;
char **channels;
int i, num_channels;
@@ -1408,6 +1478,7 @@ irc_command_cycle (void *data, struct t_gui_buffer *buffer, int argc,
IRC_COMMAND_CHECK_SERVER("cycle", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv;
@@ -1474,24 +1545,24 @@ irc_command_cycle (void *data, struct t_gui_buffer *buffer, int argc,
ptr_channel->cycle = 1;
}
- msg_part = IRC_SERVER_OPTION_STRING(ptr_server,
- IRC_SERVER_OPTION_DEFAULT_MSG_PART);
- ptr_arg = (pos_args) ? pos_args :
- ((msg_part && msg_part[0]) ? msg_part : NULL);
-
- if (ptr_arg)
+ msg = NULL;
+ ptr_arg = (pos_args) ?
+ pos_args : IRC_SERVER_OPTION_STRING(ptr_server,
+ IRC_SERVER_OPTION_MSG_PART);
+ if (ptr_arg && ptr_arg[0])
{
- version = weechat_info_get ("version", "");
- buf = weechat_string_replace (ptr_arg, "%v", (version) ? version : "");
+ msg = irc_server_get_default_msg (ptr_arg, ptr_server, channel_name);
irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
- "PART %s :%s", channel_name,
- (buf) ? buf : ptr_arg);
- if (buf)
- free (buf);
+ "PART %s :%s", channel_name, msg);
}
else
+ {
irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
"PART %s", channel_name);
+ }
+
+ if (msg)
+ free (msg);
return WEECHAT_RC_OK;
}
@@ -1500,9 +1571,7 @@ irc_command_cycle (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/dcc": DCC control (file or chat).
*/
-int
-irc_command_dcc (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(dcc)
{
struct sockaddr_storage addr;
socklen_t length;
@@ -1515,6 +1584,7 @@ irc_command_dcc (void *data, struct t_gui_buffer *buffer, int argc,
IRC_COMMAND_CHECK_SERVER("dcc", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
WEECHAT_COMMAND_MIN_ARGS(3, "");
@@ -1599,14 +1669,13 @@ irc_command_dcc (void *data, struct t_gui_buffer *buffer, int argc,
* nickname(s).
*/
-int
-irc_command_dehalfop (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(dehalfop)
{
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
IRC_COMMAND_CHECK_SERVER("dehalfop", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv_eol;
@@ -1639,14 +1708,13 @@ irc_command_dehalfop (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/deop": removes operator privileges from nickname(s).
*/
-int
-irc_command_deop (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(deop)
{
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
IRC_COMMAND_CHECK_SERVER("deop", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv_eol;
@@ -1679,14 +1747,13 @@ irc_command_deop (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/devoice": removes voice from nickname(s).
*/
-int
-irc_command_devoice (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(devoice)
{
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
IRC_COMMAND_CHECK_SERVER("devoice", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv_eol;
@@ -1719,14 +1786,13 @@ irc_command_devoice (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/die": shutdowns the server.
*/
-int
-irc_command_die (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(die)
{
IRC_BUFFER_GET_SERVER(buffer);
IRC_COMMAND_CHECK_SERVER("die", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv;
@@ -1751,29 +1817,28 @@ irc_command_die (void *data, struct t_gui_buffer *buffer, int argc,
void
irc_command_quit_server (struct t_irc_server *server, const char *arguments)
{
- const char *ptr_arg, *version, *msg_quit;
- char *buf;
+ const char *ptr_arg;
+ char *msg;
if (!server || !server->is_connected)
return;
- msg_quit = IRC_SERVER_OPTION_STRING(server,
- IRC_SERVER_OPTION_DEFAULT_MSG_QUIT);
- ptr_arg = (arguments) ? arguments :
- ((msg_quit && msg_quit[0]) ? msg_quit : NULL);
-
- if (ptr_arg)
+ msg = NULL;
+ ptr_arg = (arguments) ?
+ arguments : IRC_SERVER_OPTION_STRING(server,
+ IRC_SERVER_OPTION_MSG_QUIT);
+ if (ptr_arg && ptr_arg[0])
{
- version = weechat_info_get ("version", "");
- buf = weechat_string_replace (ptr_arg, "%v",
- (version) ? version : "");
- irc_server_sendf (server, 0, NULL, "QUIT :%s",
- (buf) ? buf : ptr_arg);
- if (buf)
- free (buf);
+ msg = irc_server_get_default_msg (ptr_arg, server, NULL);
+ irc_server_sendf (server, 0, NULL, "QUIT :%s", msg);
}
else
+ {
irc_server_sendf (server, 0, NULL, "QUIT");
+ }
+
+ if (msg)
+ free (msg);
}
/*
@@ -1821,9 +1886,7 @@ irc_command_disconnect_one_server (struct t_irc_server *server,
* Callback for command "/disconnect": disconnects from server(s).
*/
-int
-irc_command_disconnect (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(disconnect)
{
int disconnect_ok;
const char *reason;
@@ -1831,6 +1894,7 @@ irc_command_disconnect (void *data, struct t_gui_buffer *buffer, int argc,
IRC_BUFFER_GET_SERVER(buffer);
/* make C compiler happy */
+ (void) pointer;
(void) data;
reason = (argc > 2) ? argv_eol[2] : NULL;
@@ -1897,14 +1961,13 @@ irc_command_disconnect (void *data, struct t_gui_buffer *buffer, int argc,
* nickname(s).
*/
-int
-irc_command_halfop (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(halfop)
{
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
IRC_COMMAND_CHECK_SERVER("halfop", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv_eol;
@@ -1964,9 +2027,7 @@ irc_command_ignore_display (struct t_irc_ignore *ignore)
* Callback for command "/ignore": adds or removes ignore.
*/
-int
-irc_command_ignore (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(ignore)
{
struct t_irc_ignore *ptr_ignore;
char *mask, *regex, *regex2, *ptr_regex, *server, *channel, *error;
@@ -1974,6 +2035,7 @@ irc_command_ignore (void *data, struct t_gui_buffer *buffer, int argc,
long number;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
(void) argv_eol;
@@ -2126,14 +2188,13 @@ irc_command_ignore (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/info": gets information describing the server.
*/
-int
-irc_command_info (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(info)
{
IRC_BUFFER_GET_SERVER(buffer);
IRC_COMMAND_CHECK_SERVER("info", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv;
@@ -2155,9 +2216,7 @@ irc_command_info (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/invite": invites a nick on a channel.
*/
-int
-irc_command_invite (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(invite)
{
int i, arg_last_nick;
char *ptr_channel_name;
@@ -2166,6 +2225,7 @@ irc_command_invite (void *data, struct t_gui_buffer *buffer, int argc,
IRC_COMMAND_CHECK_SERVER("invite", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv_eol;
@@ -2220,14 +2280,13 @@ error:
* Callback for command "/ison": checks if a nickname is currently on IRC.
*/
-int
-irc_command_ison (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(ison)
{
IRC_BUFFER_GET_SERVER(buffer);
IRC_COMMAND_CHECK_SERVER("ison", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv;
@@ -2384,9 +2443,7 @@ irc_command_join_server (struct t_irc_server *server, const char *arguments,
* Callback for command "/join": joins a new channel.
*/
-int
-irc_command_join (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(join)
{
int i, arg_channels, noswitch;
const char *ptr_type, *ptr_server_name, *ptr_channel_name;
@@ -2394,6 +2451,7 @@ irc_command_join (void *data, struct t_gui_buffer *buffer, int argc,
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
/* make C compiler happy */
+ (void) pointer;
(void) data;
noswitch = 0;
@@ -2480,23 +2538,19 @@ irc_command_kick_channel (struct t_irc_server *server,
const char *channel_name, const char *nick_name,
const char *message)
{
- const char *msg_kick;
- char *msg_vars_replaced;
+ const char *ptr_msg;
+ char *msg;
- msg_kick = (message && message[0]) ?
+ msg = NULL;
+ ptr_msg = (message && message[0]) ?
message : IRC_SERVER_OPTION_STRING(server,
- IRC_SERVER_OPTION_DEFAULT_MSG_KICK);
- if (msg_kick && msg_kick[0])
+ IRC_SERVER_OPTION_MSG_KICK);
+ if (ptr_msg && ptr_msg[0])
{
- msg_vars_replaced = irc_message_replace_vars (server,
- channel_name,
- msg_kick);
+ msg = irc_server_get_default_msg (ptr_msg, server, channel_name);
irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
"KICK %s %s :%s",
- channel_name, nick_name,
- (msg_vars_replaced) ? msg_vars_replaced : msg_kick);
- if (msg_vars_replaced)
- free (msg_vars_replaced);
+ channel_name, nick_name, msg);
}
else
{
@@ -2504,15 +2558,16 @@ irc_command_kick_channel (struct t_irc_server *server,
"KICK %s %s",
channel_name, nick_name);
}
+
+ if (msg)
+ free (msg);
}
/*
* Callback for command "/kick": forcibly removes a user from a channel.
*/
-int
-irc_command_kick (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(kick)
{
char *pos_channel, *pos_nick, *pos_comment;
@@ -2520,6 +2575,7 @@ irc_command_kick (void *data, struct t_gui_buffer *buffer, int argc,
IRC_COMMAND_CHECK_SERVER("kick", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
WEECHAT_COMMAND_MIN_ARGS(2, "");
@@ -2558,9 +2614,7 @@ irc_command_kick (void *data, struct t_gui_buffer *buffer, int argc,
* bans it.
*/
-int
-irc_command_kickban (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(kickban)
{
char *pos_channel, *pos_nick, *nick_only, *pos_comment, *pos, *mask;
int length;
@@ -2569,6 +2623,7 @@ irc_command_kickban (void *data, struct t_gui_buffer *buffer, int argc,
IRC_COMMAND_CHECK_SERVER("kickban", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
WEECHAT_COMMAND_MIN_ARGS(2, "");
@@ -2653,14 +2708,13 @@ irc_command_kickban (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/kill": closes client-server connection.
*/
-int
-irc_command_kill (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(kill)
{
IRC_BUFFER_GET_SERVER(buffer);
IRC_COMMAND_CHECK_SERVER("kill", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
WEECHAT_COMMAND_MIN_ARGS(2, "");
@@ -2684,14 +2738,13 @@ irc_command_kill (void *data, struct t_gui_buffer *buffer, int argc,
* server answering the query.
*/
-int
-irc_command_links (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(links)
{
IRC_BUFFER_GET_SERVER(buffer);
IRC_COMMAND_CHECK_SERVER("links", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv;
@@ -2713,9 +2766,7 @@ irc_command_links (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/list": lists channels and their topic.
*/
-int
-irc_command_list (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(list)
{
char buf[512], *ptr_channel_name, *ptr_server_name, *ptr_regex;
int i, ret;
@@ -2724,6 +2775,7 @@ irc_command_list (void *data, struct t_gui_buffer *buffer, int argc,
IRC_COMMAND_CHECK_SERVER("list", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (ptr_server->cmd_list_regexp)
@@ -2817,14 +2869,13 @@ irc_command_list (void *data, struct t_gui_buffer *buffer, int argc,
* network.
*/
-int
-irc_command_lusers (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(lusers)
{
IRC_BUFFER_GET_SERVER(buffer);
IRC_COMMAND_CHECK_SERVER("lusers", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv;
@@ -2846,14 +2897,13 @@ irc_command_lusers (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/map": shows a graphical map of the IRC network.
*/
-int
-irc_command_map (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(map)
{
IRC_BUFFER_GET_SERVER(buffer);
IRC_COMMAND_CHECK_SERVER("map", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv;
@@ -2875,14 +2925,13 @@ irc_command_map (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/me": sends a ctcp action to the current channel.
*/
-int
-irc_command_me (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
- char **argv_eol)
+IRC_COMMAND_CALLBACK(me)
{
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
IRC_COMMAND_CHECK_SERVER("me", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv;
@@ -2934,14 +2983,13 @@ irc_command_mode_server (struct t_irc_server *server,
* Callback for command "/mode": changes mode for channel/nickname.
*/
-int
-irc_command_mode (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(mode)
{
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
IRC_COMMAND_CHECK_SERVER("mode", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (argc > 1)
@@ -2991,14 +3039,13 @@ irc_command_mode (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/motd": gets the "Message Of The Day".
*/
-int
-irc_command_motd (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(motd)
{
IRC_BUFFER_GET_SERVER(buffer);
IRC_COMMAND_CHECK_SERVER("motd", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv;
@@ -3020,17 +3067,17 @@ irc_command_motd (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/msg": sends a message to a nick or channel.
*/
-int
-irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(msg)
{
char **targets, *msg_pwd_hidden, *string;
int num_targets, i, j, arg_target, arg_text, is_channel, status_msg;
int hide_password;
+ struct t_irc_channel *ptr_channel2;
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
/* make C compiler happy */
+ (void) pointer;
(void) data;
WEECHAT_COMMAND_MIN_ARGS(3, "");
@@ -3066,42 +3113,46 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
_("%s%s: \"%s\" command can only be executed in a channel "
"or private buffer"),
weechat_prefix ("error"), IRC_PLUGIN_NAME, "msg *");
- return WEECHAT_RC_OK;
}
- string = irc_color_decode (argv_eol[arg_text],
- weechat_config_boolean (irc_config_network_colors_send));
- irc_input_user_message_display (ptr_channel->buffer, 0,
- (string) ? string : argv_eol[arg_text]);
- if (string)
- free (string);
+ else
+ {
+ string = irc_color_decode (
+ argv_eol[arg_text],
+ weechat_config_boolean (irc_config_network_colors_send));
+ irc_input_user_message_display (
+ ptr_channel->buffer, 0,
+ (string) ? string : argv_eol[arg_text]);
+ if (string)
+ free (string);
- irc_server_sendf (ptr_server,
- IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
- "PRIVMSG %s :%s",
- ptr_channel->name, argv_eol[arg_text]);
+ irc_server_sendf (ptr_server,
+ IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
+ "PRIVMSG %s :%s",
+ ptr_channel->name, argv_eol[arg_text]);
+ }
}
else
{
is_channel = 0;
- ptr_channel = NULL;
+ ptr_channel2 = NULL;
status_msg = 0;
if (irc_server_prefix_char_statusmsg (ptr_server,
targets[i][0])
&& irc_channel_is_channel (ptr_server, targets[i] + 1))
{
- ptr_channel = irc_channel_search (ptr_server, targets[i] + 1);
+ ptr_channel2 = irc_channel_search (ptr_server, targets[i] + 1);
is_channel = 1;
status_msg = 1;
}
else
{
- ptr_channel = irc_channel_search (ptr_server, targets[i]);
- if (ptr_channel)
+ ptr_channel2 = irc_channel_search (ptr_server, targets[i]);
+ if (ptr_channel2)
is_channel = 1;
}
if (is_channel)
{
- if (ptr_channel)
+ if (ptr_channel2)
{
string = irc_color_decode (
argv_eol[arg_text],
@@ -3112,8 +3163,9 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
* message to channel ops/voiced
* (to "@#channel" or "+#channel")
*/
- weechat_printf_tags (
- ptr_channel->buffer,
+ weechat_printf_date_tags (
+ ptr_channel2->buffer,
+ 0,
"notify_none,no_highlight",
"%s%s%s -> %s%s%s: %s",
weechat_prefix ("network"),
@@ -3128,7 +3180,7 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
{
/* standard message (to "#channel") */
irc_input_user_message_display (
- ptr_channel->buffer,
+ ptr_channel2->buffer,
0,
(string) ? string : argv_eol[arg_text]);
}
@@ -3189,19 +3241,20 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
string = irc_color_decode (
argv_eol[arg_text],
weechat_config_boolean (irc_config_network_colors_send));
- ptr_channel = irc_channel_search (ptr_server,
- targets[i]);
- if (ptr_channel)
+ ptr_channel2 = irc_channel_search (ptr_server,
+ targets[i]);
+ if (ptr_channel2)
{
irc_input_user_message_display (
- ptr_channel->buffer,
+ ptr_channel2->buffer,
0,
(string) ? string : argv_eol[arg_text]);
}
else
{
- weechat_printf_tags (
+ weechat_printf_date_tags (
ptr_server->buffer,
+ 0,
irc_protocol_tags (
"privmsg", "notify_none,no_highlight",
ptr_server->nick, NULL),
@@ -3235,14 +3288,13 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/names": lists nicknames on channels.
*/
-int
-irc_command_names (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(names)
{
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
IRC_COMMAND_CHECK_SERVER("names", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv;
@@ -3292,14 +3344,13 @@ irc_send_nick_server (struct t_irc_server *server, const char *nickname)
* Callback for command "/nick": changes nickname.
*/
-int
-irc_command_nick (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(nick)
{
IRC_BUFFER_GET_SERVER(buffer);
IRC_COMMAND_CHECK_SERVER("nick", 0);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv_eol;
@@ -3325,9 +3376,7 @@ irc_command_nick (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/notice": sends notice message.
*/
-int
-irc_command_notice (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(notice)
{
char *string, hash_key[32], *str_args;
int arg_target, arg_text, number, is_channel;
@@ -3337,6 +3386,7 @@ irc_command_notice (void *data, struct t_gui_buffer *buffer, int argc,
IRC_BUFFER_GET_SERVER(buffer);
/* make C compiler happy */
+ (void) pointer;
(void) data;
WEECHAT_COMMAND_MIN_ARGS(3, "");
@@ -3382,10 +3432,11 @@ irc_command_notice (void *data, struct t_gui_buffer *buffer, int argc,
string = irc_color_decode (
str_args,
weechat_config_boolean (irc_config_network_colors_send));
- weechat_printf_tags (
+ weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
ptr_server, argv[arg_target], "notice", NULL,
(ptr_channel) ? ptr_channel->buffer : NULL),
+ 0,
"notify_none,no_highlight",
"%s%s%s%s -> %s%s%s: %s",
weechat_prefix ("network"),
@@ -3411,9 +3462,7 @@ irc_command_notice (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/notify": adds or removes notify.
*/
-int
-irc_command_notify (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(notify)
{
struct t_irc_notify *ptr_notify;
int i, check_away;
@@ -3421,6 +3470,7 @@ irc_command_notify (void *data, struct t_gui_buffer *buffer, int argc,
IRC_BUFFER_GET_SERVER(buffer);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
(void) argv_eol;
@@ -3598,14 +3648,13 @@ irc_command_notify (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/op": gives operator privileges to nickname(s).
*/
-int
-irc_command_op (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
- char **argv_eol)
+IRC_COMMAND_CALLBACK(op)
{
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
IRC_COMMAND_CHECK_SERVER("op", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv_eol;
@@ -3638,14 +3687,13 @@ irc_command_op (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
* Callback for command "/oper": gets oper privileges.
*/
-int
-irc_command_oper (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(oper)
{
IRC_BUFFER_GET_SERVER(buffer);
IRC_COMMAND_CHECK_SERVER("oper", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv;
@@ -3665,39 +3713,34 @@ void
irc_command_part_channel (struct t_irc_server *server, const char *channel_name,
const char *part_message)
{
- const char *ptr_arg, *version, *msg_part;
- char *buf;
-
- msg_part = IRC_SERVER_OPTION_STRING(server,
- IRC_SERVER_OPTION_DEFAULT_MSG_PART);
- ptr_arg = (part_message) ? part_message :
- ((msg_part && msg_part[0]) ? msg_part : NULL);
+ const char *ptr_arg;
+ char *msg;
- if (ptr_arg)
+ msg = NULL;
+ ptr_arg = (part_message) ?
+ part_message : IRC_SERVER_OPTION_STRING(server,
+ IRC_SERVER_OPTION_MSG_PART);
+ if (ptr_arg && ptr_arg[0])
{
- version = weechat_info_get ("version", "");
- buf = weechat_string_replace (ptr_arg, "%v", (version) ? version : "");
+ msg = irc_server_get_default_msg (ptr_arg, server, channel_name);
irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
- "PART %s :%s",
- channel_name,
- (buf) ? buf : ptr_arg);
- if (buf)
- free (buf);
+ "PART %s :%s", channel_name, msg);
}
else
{
irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
"PART %s", channel_name);
}
+
+ if (msg)
+ free (msg);
}
/*
* Callback for command "/part": leaves a channel or close a private window.
*/
-int
-irc_command_part (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(part)
{
char *channel_name, *pos_args;
@@ -3705,6 +3748,7 @@ irc_command_part (void *data, struct t_gui_buffer *buffer, int argc,
IRC_COMMAND_CHECK_SERVER("part", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (argc > 1)
@@ -3764,14 +3808,13 @@ irc_command_part (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/ping": pings a server.
*/
-int
-irc_command_ping (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(ping)
{
IRC_BUFFER_GET_SERVER(buffer);
IRC_COMMAND_CHECK_SERVER("ping", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv;
@@ -3787,14 +3830,13 @@ irc_command_ping (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/pong": sends pong answer to a daemon.
*/
-int
-irc_command_pong (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(pong)
{
IRC_BUFFER_GET_SERVER(buffer);
IRC_COMMAND_CHECK_SERVER("pong", 0);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv;
@@ -3810,9 +3852,7 @@ irc_command_pong (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/query": starts private conversation with a nick.
*/
-int
-irc_command_query (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(query)
{
char *string, **nicks;
int i, arg_nick, arg_text, num_nicks, noswitch;
@@ -3820,6 +3860,7 @@ irc_command_query (void *data, struct t_gui_buffer *buffer, int argc,
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
/* make C compiler happy */
+ (void) pointer;
(void) data;
WEECHAT_COMMAND_MIN_ARGS(2, "");
@@ -3928,9 +3969,7 @@ irc_command_query (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/quiet": quiets nicks or hosts.
*/
-int
-irc_command_quiet (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(quiet)
{
char *pos_channel;
int pos_args;
@@ -3939,6 +3978,7 @@ irc_command_quiet (void *data, struct t_gui_buffer *buffer, int argc,
IRC_COMMAND_CHECK_SERVER("quiet", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv_eol;
@@ -4011,13 +4051,12 @@ irc_command_quiet (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/quote": sends raw data to server.
*/
-int
-irc_command_quote (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(quote)
{
IRC_BUFFER_GET_SERVER(buffer);
/* make C compiler happy */
+ (void) pointer;
(void) data;
WEECHAT_COMMAND_MIN_ARGS(2, "");
@@ -4088,15 +4127,14 @@ irc_command_reconnect_one_server (struct t_irc_server *server,
* Callback for command "/reconnect": reconnects to server(s).
*/
-int
-irc_command_reconnect (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(reconnect)
{
int i, nb_reconnect, reconnect_ok, all_servers, switch_address, no_join;
IRC_BUFFER_GET_SERVER(buffer);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv_eol;
@@ -4177,14 +4215,13 @@ irc_command_reconnect (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/rehash": tells the server to reload its config file.
*/
-int
-irc_command_rehash (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(rehash)
{
IRC_BUFFER_GET_SERVER(buffer);
IRC_COMMAND_CHECK_SERVER("rehash", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv;
@@ -4206,9 +4243,7 @@ irc_command_rehash (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/remove": remove a user from a channel.
*/
-int
-irc_command_remove (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(remove)
{
const char *ptr_channel_name;
char *msg_vars_replaced;
@@ -4218,6 +4253,7 @@ irc_command_remove (void *data, struct t_gui_buffer *buffer, int argc,
IRC_COMMAND_CHECK_SERVER("remove", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
WEECHAT_COMMAND_MIN_ARGS(2, "");
@@ -4269,14 +4305,13 @@ irc_command_remove (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/restart": tells the server to restart itself.
*/
-int
-irc_command_restart (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(restart)
{
IRC_BUFFER_GET_SERVER(buffer);
IRC_COMMAND_CHECK_SERVER("restart", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv;
@@ -4298,14 +4333,13 @@ irc_command_restart (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/sajoin": forces a user to join channel(s).
*/
-int
-irc_command_sajoin (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(sajoin)
{
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
IRC_COMMAND_CHECK_SERVER("sajoin", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
WEECHAT_COMMAND_MIN_ARGS(3, "");
@@ -4321,14 +4355,13 @@ irc_command_sajoin (void *data, struct t_gui_buffer *buffer, int argc,
* operator status.
*/
-int
-irc_command_samode (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(samode)
{
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
IRC_COMMAND_CHECK_SERVER("samode", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (argc > 1)
@@ -4381,14 +4414,13 @@ irc_command_samode (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/sanick": forces a user to use another nick.
*/
-int
-irc_command_sanick (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(sanick)
{
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
IRC_COMMAND_CHECK_SERVER("sanick", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
WEECHAT_COMMAND_MIN_ARGS(3, "");
@@ -4403,14 +4435,13 @@ irc_command_sanick (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/sapart": forces a user to leave channel(s).
*/
-int
-irc_command_sapart (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(sapart)
{
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
IRC_COMMAND_CHECK_SERVER("sapart", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
WEECHAT_COMMAND_MIN_ARGS(3, "");
@@ -4425,14 +4456,13 @@ irc_command_sapart (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/saquit": forces a user to quit server with a reason.
*/
-int
-irc_command_saquit (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(saquit)
{
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
IRC_COMMAND_CHECK_SERVER("saquit", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
WEECHAT_COMMAND_MIN_ARGS(3, "");
@@ -4490,7 +4520,7 @@ irc_command_display_server (struct t_irc_server *server, int with_detail)
else
weechat_printf (NULL, " ipv6 . . . . . . . . : %s%s",
IRC_COLOR_CHAT_VALUE,
- weechat_config_boolean (server->options[IRC_SERVER_OPTION_IPV6]) ?
+ (weechat_config_boolean (server->options[IRC_SERVER_OPTION_IPV6])) ?
_("on") : _("off"));
/* ssl */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SSL]))
@@ -4500,7 +4530,7 @@ irc_command_display_server (struct t_irc_server *server, int with_detail)
else
weechat_printf (NULL, " ssl. . . . . . . . . : %s%s",
IRC_COLOR_CHAT_VALUE,
- weechat_config_boolean (server->options[IRC_SERVER_OPTION_SSL]) ?
+ (weechat_config_boolean (server->options[IRC_SERVER_OPTION_SSL])) ?
_("on") : _("off"));
/* ssl_cert */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SSL_CERT]))
@@ -4542,7 +4572,7 @@ irc_command_display_server (struct t_irc_server *server, int with_detail)
else
weechat_printf (NULL, " ssl_verify . . . . . : %s%s",
IRC_COLOR_CHAT_VALUE,
- weechat_config_boolean (server->options[IRC_SERVER_OPTION_SSL_VERIFY]) ?
+ (weechat_config_boolean (server->options[IRC_SERVER_OPTION_SSL_VERIFY])) ?
_("on") : _("off"));
/* password */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_PASSWORD]))
@@ -4618,7 +4648,7 @@ irc_command_display_server (struct t_irc_server *server, int with_detail)
else
weechat_printf (NULL, " autoconnect. . . . . : %s%s",
IRC_COLOR_CHAT_VALUE,
- weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTOCONNECT]) ?
+ (weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTOCONNECT])) ?
_("on") : _("off"));
/* autoreconnect */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTORECONNECT]))
@@ -4628,7 +4658,7 @@ irc_command_display_server (struct t_irc_server *server, int with_detail)
else
weechat_printf (NULL, " autoreconnect. . . . : %s%s",
IRC_COLOR_CHAT_VALUE,
- weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTORECONNECT]) ?
+ (weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTORECONNECT])) ?
_("on") : _("off"));
/* autoreconnect_delay */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTORECONNECT_DELAY]))
@@ -4648,6 +4678,16 @@ irc_command_display_server (struct t_irc_server *server, int with_detail)
weechat_printf (NULL, " nicks. . . . . . . . : %s'%s'",
IRC_COLOR_CHAT_VALUE,
weechat_config_string (server->options[IRC_SERVER_OPTION_NICKS]));
+ /* nicks_alternate */
+ if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_NICKS_ALTERNATE]))
+ weechat_printf (NULL, " nicks_alternate. . . : (%s)",
+ (IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_NICKS_ALTERNATE)) ?
+ _("on") : _("off"));
+ else
+ weechat_printf (NULL, " nicks_alternate. . . : %s%s",
+ IRC_COLOR_CHAT_VALUE,
+ (weechat_config_boolean (server->options[IRC_SERVER_OPTION_NICKS_ALTERNATE])) ?
+ _("on") : _("off"));
/* username */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_USERNAME]))
weechat_printf (NULL, " username . . . . . . : ('%s')",
@@ -4720,7 +4760,7 @@ irc_command_display_server (struct t_irc_server *server, int with_detail)
else
weechat_printf (NULL, " autorejoin . . . . . : %s%s",
IRC_COLOR_CHAT_VALUE,
- weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTOREJOIN]) ?
+ (weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTOREJOIN])) ?
_("on") : _("off"));
/* autorejoin_delay */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTOREJOIN_DELAY]))
@@ -4780,30 +4820,30 @@ irc_command_display_server (struct t_irc_server *server, int with_detail)
weechat_printf (NULL, " away_check_max_nicks : %s%d",
IRC_COLOR_CHAT_VALUE,
weechat_config_integer (server->options[IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS]));
- /* default_msg_kick */
- if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_DEFAULT_MSG_KICK]))
- weechat_printf (NULL, " default_msg_kick . . : ('%s')",
- IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_DEFAULT_MSG_KICK));
+ /* msg_kick */
+ if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_MSG_KICK]))
+ weechat_printf (NULL, " msg_kick . . . . . . : ('%s')",
+ IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_MSG_KICK));
else
- weechat_printf (NULL, " default_msg_kick . . : %s'%s'",
+ weechat_printf (NULL, " msg_kick . . . . . . : %s'%s'",
IRC_COLOR_CHAT_VALUE,
- weechat_config_string (server->options[IRC_SERVER_OPTION_DEFAULT_MSG_KICK]));
- /* default_msg_part */
- if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_DEFAULT_MSG_PART]))
- weechat_printf (NULL, " default_msg_part . . : ('%s')",
- IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_DEFAULT_MSG_PART));
+ weechat_config_string (server->options[IRC_SERVER_OPTION_MSG_KICK]));
+ /* msg_part */
+ if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_MSG_PART]))
+ weechat_printf (NULL, " msg_part . . . . . . : ('%s')",
+ IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_MSG_PART));
else
- weechat_printf (NULL, " default_msg_part . . : %s'%s'",
+ weechat_printf (NULL, " msg_part . . . . . . : %s'%s'",
IRC_COLOR_CHAT_VALUE,
- weechat_config_string (server->options[IRC_SERVER_OPTION_DEFAULT_MSG_PART]));
- /* default_msg_quit */
- if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_DEFAULT_MSG_QUIT]))
- weechat_printf (NULL, " default_msg_quit . . : ('%s')",
- IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_DEFAULT_MSG_QUIT));
+ weechat_config_string (server->options[IRC_SERVER_OPTION_MSG_PART]));
+ /* msg_quit */
+ if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_MSG_QUIT]))
+ weechat_printf (NULL, " msg_quit . . . . . . : ('%s')",
+ IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_MSG_QUIT));
else
- weechat_printf (NULL, " default_msg_quit . . : %s'%s'",
+ weechat_printf (NULL, " msg_quit . . . . . . : %s'%s'",
IRC_COLOR_CHAT_VALUE,
- weechat_config_string (server->options[IRC_SERVER_OPTION_DEFAULT_MSG_QUIT]));
+ weechat_config_string (server->options[IRC_SERVER_OPTION_MSG_QUIT]));
/* notify */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_NOTIFY]))
weechat_printf (NULL, " notify . . . . . . . : ('%s')",
@@ -4853,9 +4893,7 @@ irc_command_display_server (struct t_irc_server *server, int with_detail)
* Callback for command "/server": manages IRC servers.
*/
-int
-irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(server)
{
int i, detailed_list, one_server_found, length, count;
struct t_irc_server *ptr_server2, *server_found, *new_server;
@@ -4864,6 +4902,7 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
@@ -5219,14 +5258,13 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/service": registers a new service.
*/
-int
-irc_command_service (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(service)
{
IRC_BUFFER_GET_SERVER(buffer);
IRC_COMMAND_CHECK_SERVER("service", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv;
@@ -5243,14 +5281,13 @@ irc_command_service (void *data, struct t_gui_buffer *buffer, int argc,
* network.
*/
-int
-irc_command_servlist (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(servlist)
{
IRC_BUFFER_GET_SERVER(buffer);
IRC_COMMAND_CHECK_SERVER("servlist", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv;
@@ -5272,14 +5309,13 @@ irc_command_servlist (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/squery": delivers a message to a service.
*/
-int
-irc_command_squery (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(squery)
{
IRC_BUFFER_GET_SERVER(buffer);
IRC_COMMAND_CHECK_SERVER("squery", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
WEECHAT_COMMAND_MIN_ARGS(2, "");
@@ -5302,14 +5338,13 @@ irc_command_squery (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/squit": disconnects server links.
*/
-int
-irc_command_squit (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(squit)
{
IRC_BUFFER_GET_SERVER(buffer);
IRC_COMMAND_CHECK_SERVER("squit", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv;
@@ -5324,14 +5359,13 @@ irc_command_squit (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/stats": queries statistics about server.
*/
-int
-irc_command_stats (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(stats)
{
IRC_BUFFER_GET_SERVER(buffer);
IRC_COMMAND_CHECK_SERVER("stats", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv;
@@ -5354,14 +5388,13 @@ irc_command_stats (void *data, struct t_gui_buffer *buffer, int argc,
* server a message asking them to please join IRC.
*/
-int
-irc_command_summon (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(summon)
{
IRC_BUFFER_GET_SERVER(buffer);
IRC_COMMAND_CHECK_SERVER("summon", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv;
@@ -5377,14 +5410,13 @@ irc_command_summon (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/time": queries local time from server.
*/
-int
-irc_command_time (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(time)
{
IRC_BUFFER_GET_SERVER(buffer);
IRC_COMMAND_CHECK_SERVER("time", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv;
@@ -5406,9 +5438,7 @@ irc_command_time (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/topic": gets/sets topic for a channel.
*/
-int
-irc_command_topic (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(topic)
{
char *channel_name, *new_topic, *new_topic_color;
@@ -5416,6 +5446,7 @@ irc_command_topic (void *data, struct t_gui_buffer *buffer, int argc,
IRC_COMMAND_CHECK_SERVER("topic", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv;
@@ -5484,14 +5515,13 @@ irc_command_topic (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/trace": finds the route to specific server.
*/
-int
-irc_command_trace (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(trace)
{
IRC_BUFFER_GET_SERVER(buffer);
IRC_COMMAND_CHECK_SERVER("trace", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv;
@@ -5513,9 +5543,7 @@ irc_command_trace (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/unban": unbans nicks or hosts.
*/
-int
-irc_command_unban (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(unban)
{
char *pos_channel;
int pos_args;
@@ -5524,6 +5552,7 @@ irc_command_unban (void *data, struct t_gui_buffer *buffer, int argc,
IRC_COMMAND_CHECK_SERVER("unban", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv_eol;
@@ -5571,9 +5600,7 @@ irc_command_unban (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/unquiet": unquiets nicks or hosts.
*/
-int
-irc_command_unquiet (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(unquiet)
{
char *pos_channel;
int pos_args;
@@ -5582,6 +5609,7 @@ irc_command_unquiet (void *data, struct t_gui_buffer *buffer, int argc,
IRC_COMMAND_CHECK_SERVER("unquiet", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv_eol;
@@ -5640,14 +5668,13 @@ irc_command_unquiet (void *data, struct t_gui_buffer *buffer, int argc,
* nicknames.
*/
-int
-irc_command_userhost (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(userhost)
{
IRC_BUFFER_GET_SERVER(buffer);
IRC_COMMAND_CHECK_SERVER("userhost", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv;
@@ -5663,14 +5690,13 @@ irc_command_userhost (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/users": list of users logged into the server.
*/
-int
-irc_command_users (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(users)
{
IRC_BUFFER_GET_SERVER(buffer);
IRC_COMMAND_CHECK_SERVER("users", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv;
@@ -5693,14 +5719,13 @@ irc_command_users (void *data, struct t_gui_buffer *buffer, int argc,
* (current or specified).
*/
-int
-irc_command_version (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(version)
{
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
IRC_COMMAND_CHECK_SERVER("version", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv_eol;
@@ -5731,14 +5756,13 @@ irc_command_version (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/voice": gives voice to nickname(s).
*/
-int
-irc_command_voice (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(voice)
{
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
IRC_COMMAND_CHECK_SERVER("voice", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv_eol;
@@ -5771,9 +5795,7 @@ irc_command_voice (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/wallchops": sends a notice to channel ops.
*/
-int
-irc_command_wallchops (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(wallchops)
{
char *pos_channel;
int pos_args;
@@ -5784,6 +5806,7 @@ irc_command_wallchops (void *data, struct t_gui_buffer *buffer, int argc,
IRC_COMMAND_CHECK_SERVER("wallchops", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
WEECHAT_COMMAND_MIN_ARGS(2, "");
@@ -5883,14 +5906,13 @@ irc_command_wallchops (void *data, struct t_gui_buffer *buffer, int argc,
* users who have set the 'w' user mode for themselves.
*/
-int
-irc_command_wallops (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(wallops)
{
IRC_BUFFER_GET_SERVER(buffer);
IRC_COMMAND_CHECK_SERVER("wallops", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv;
@@ -5907,14 +5929,13 @@ irc_command_wallops (void *data, struct t_gui_buffer *buffer, int argc,
* information.
*/
-int
-irc_command_who (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(who)
{
IRC_BUFFER_GET_SERVER(buffer);
IRC_COMMAND_CHECK_SERVER("who", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv;
@@ -5936,9 +5957,7 @@ irc_command_who (void *data, struct t_gui_buffer *buffer, int argc,
* Callback for command "/whois": queries information about user(s).
*/
-int
-irc_command_whois (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(whois)
{
int double_nick;
const char *ptr_nick;
@@ -5947,6 +5966,7 @@ irc_command_whois (void *data, struct t_gui_buffer *buffer, int argc,
IRC_COMMAND_CHECK_SERVER("whois", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
double_nick = weechat_config_boolean (irc_config_network_whois_double_nick);
@@ -5988,14 +6008,13 @@ irc_command_whois (void *data, struct t_gui_buffer *buffer, int argc,
* no longer exists.
*/
-int
-irc_command_whowas (void *data, struct t_gui_buffer *buffer, int argc,
- char **argv, char **argv_eol)
+IRC_COMMAND_CALLBACK(whowas)
{
IRC_BUFFER_GET_SERVER(buffer);
IRC_COMMAND_CHECK_SERVER("whowas", 1);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv;
@@ -6019,7 +6038,7 @@ irc_command_init ()
N_("find information about the administrator of the server"),
N_("[<target>]"),
N_("target: server name"),
- NULL, &irc_command_admin, NULL);
+ NULL, &irc_command_admin, NULL, NULL);
weechat_hook_command (
"allchan",
N_("execute a command on all channels of all connected servers"),
@@ -6039,7 +6058,7 @@ irc_command_init ()
" say 'hello' everywhere but not on #weechat and channels beginning "
"with #linux:\n"
" /allchan -exclude=#weechat,#linux* msg * hello"),
- "-current", &irc_command_allchan, NULL);
+ "-current", &irc_command_allchan, NULL, NULL);
weechat_hook_command (
"allpv",
N_("execute a command on all private buffers of all connected servers"),
@@ -6062,7 +6081,7 @@ irc_command_init ()
" /allpv -exclude=foo,bar* msg * hello\n"
" close all private buffers:\n"
" /allpv close"),
- "-current", &irc_command_allpv, NULL);
+ "-current", &irc_command_allpv, NULL, NULL);
weechat_hook_command (
"allserv",
N_("execute a command on all connected servers"),
@@ -6080,8 +6099,8 @@ irc_command_init ()
" /allserv away I'm away\n"
" do a whois on my nick on all servers:\n"
" /allserv whois $nick"),
- NULL, &irc_command_allserv, NULL);
- weechat_hook_command_run ("/away", &irc_command_run_away, NULL);
+ NULL, &irc_command_allserv, NULL, NULL);
+ weechat_hook_command_run ("/away", &irc_command_run_away, NULL, NULL);
weechat_hook_command (
"ban",
N_("ban nicks or hosts"),
@@ -6089,8 +6108,40 @@ irc_command_init ()
N_("channel: channel name\n"
" nick: nick or host\n"
"\n"
- "Without argument, this command display ban list for current channel."),
- "%(irc_channel_nicks_hosts)", &irc_command_ban, NULL);
+ "Without argument, this command displays the ban list for current "
+ "channel."),
+ "%(irc_channel_nicks_hosts)", &irc_command_ban, NULL, NULL);
+ weechat_hook_command (
+ "cap",
+ N_("client capability negotiation"),
+ N_("ls || list || req|ack [<capability> [<capability>...]]"
+ " || end"),
+ N_(" ls: list the capabilities supported by the server\n"
+ " list: list the capabilities currently enabled\n"
+ " req: request a capability\n"
+ " ack: acknowledge capabilities which require client-side "
+ "acknowledgement\n"
+ " end: end the capability negotiation\n"
+ "\n"
+ "Without argument, \"ls\" and \"list\" are sent.\n"
+ "\n"
+ "Capabilities supported by WeeChat are: "
+ "account-notify, away-notify, cap-notify, extended-join, "
+ "multi-prefix, server-time, userhost-in-names.\n"
+ "\n"
+ "The capabilities to automatically enable on servers can be set "
+ "in option irc.server_default.capabilities (or by server in "
+ "option irc.server.xxx.capabilities).\n"
+ "\n"
+ "Examples:\n"
+ " /cap\n"
+ " /cap req multi-prefix away-notify"),
+ "ls"
+ " || list"
+ " || req " IRC_COMMAND_CAP_SUPPORTED_COMPLETION
+ " || ack " IRC_COMMAND_CAP_SUPPORTED_COMPLETION
+ " || end",
+ &irc_command_cap, NULL, NULL);
weechat_hook_command (
"connect",
N_("connect to IRC server(s)"),
@@ -6128,24 +6179,32 @@ irc_command_init ()
" /connect irc://nick@irc.oftc.net/#channel\n"
" /connect -switch"),
"%(irc_servers)|-all|-auto|-open|-nojoin|-switch|%*",
- &irc_command_connect, NULL);
+ &irc_command_connect, NULL, NULL);
weechat_hook_command (
"ctcp",
N_("send a CTCP message (Client-To-Client Protocol)"),
- N_("<target> <type> [<arguments>]"),
- N_(" target: nick or channel name to send CTCP to\n"
- " type: CTCP type (examples: \"version\", \"ping\", ..)\n"
- "arguments: arguments for CTCP"),
- "%(irc_channel)|%(nicks) action|clientinfo|finger|ping|source|time|"
- "userinfo|version",
- &irc_command_ctcp, NULL);
+ N_("[-server <server>] <target>[,<target>...] <type> [<arguments>]"),
+ N_(" server: send to this server (internal name)\n"
+ " target: nick or channel ('*' = current channel)\n"
+ " type: CTCP type (examples: \"version\", \"ping\", ..)\n"
+ "arguments: arguments for CTCP\n"
+ "\n"
+ "Examples:\n"
+ " /ctcp toto time\n"
+ " /ctcp toto version\n"
+ " /ctcp * version"),
+ "-server %(irc_servers) %(irc_channel)|%(nicks)|* "
+ IRC_COMMAND_CTCP_SUPPORTED_COMPLETION
+ " || %(irc_channel)|%(nicks)|* "
+ IRC_COMMAND_CTCP_SUPPORTED_COMPLETION,
+ &irc_command_ctcp, NULL, NULL);
weechat_hook_command (
"cycle",
N_("leave and rejoin a channel"),
N_("[<channel>[,<channel>...]] [<message>]"),
N_("channel: channel name\n"
"message: part message (displayed to other users)"),
- "%(irc_msg_part)", &irc_command_cycle, NULL);
+ "%(irc_msg_part)", &irc_command_cycle, NULL, NULL);
weechat_hook_command (
"dcc",
N_("start a DCC (file transfer or direct chat)"),
@@ -6160,7 +6219,7 @@ irc_command_init ()
" /dcc send toto /home/foo/bar.txt"),
"chat %(nicks)"
" || send %(nicks) %(filename)",
- &irc_command_dcc, NULL);
+ &irc_command_dcc, NULL, NULL);
weechat_hook_command (
"dehalfop",
N_("remove channel half-operator status from nick(s)"),
@@ -6168,7 +6227,7 @@ irc_command_init ()
N_("nick: nick or mask (wildcard \"*\" is allowed)\n"
" *: remove channel half-operator status from everybody on channel "
"except yourself"),
- "%(nicks)", &irc_command_dehalfop, NULL);
+ "%(nicks)", &irc_command_dehalfop, NULL, NULL);
weechat_hook_command (
"deop",
N_("remove channel operator status from nick(s)"),
@@ -6176,20 +6235,20 @@ irc_command_init ()
N_("nick: nick or mask (wildcard \"*\" is allowed)\n"
" *: remove channel operator status from everybody on channel "
"except yourself"),
- "%(nicks)|%*", &irc_command_deop, NULL);
+ "%(nicks)|%*", &irc_command_deop, NULL, NULL);
weechat_hook_command (
"devoice",
N_("remove voice from nick(s)"),
N_("<nick> [<nick>...] || * -yes"),
N_("nick: nick or mask (wildcard \"*\" is allowed)\n"
" *: remove voice from everybody on channel"),
- "%(nicks)|%*", &irc_command_devoice, NULL);
+ "%(nicks)|%*", &irc_command_devoice, NULL, NULL);
weechat_hook_command (
"die",
N_("shutdown the server"),
N_("[<target>]"),
N_("target: server name"),
- NULL, &irc_command_die, NULL);
+ NULL, &irc_command_die, NULL, NULL);
weechat_hook_command (
"disconnect",
N_("disconnect from one or all IRC servers"),
@@ -6200,14 +6259,14 @@ irc_command_init ()
"reconnecting\n"
" reason: reason for the \"quit\""),
"%(irc_servers)|-all|-pending",
- &irc_command_disconnect, NULL);
+ &irc_command_disconnect, NULL, NULL);
weechat_hook_command (
"halfop",
N_("give channel half-operator status to nick(s)"),
N_("<nick> [<nick>...] || * -yes"),
N_("nick: nick or mask (wildcard \"*\" is allowed)\n"
" *: give channel half-operator status to everybody on channel"),
- "%(nicks)", &irc_command_halfop, NULL);
+ "%(nicks)", &irc_command_halfop, NULL, NULL);
weechat_hook_command (
"ignore",
N_("ignore nicks/hosts from servers or channels"),
@@ -6238,26 +6297,26 @@ irc_command_init ()
"list"
" || add %(irc_channel_nicks_hosts) %(irc_servers) %(irc_channels) %-"
" || del -all|%(irc_ignores_numbers) %-",
- &irc_command_ignore, NULL);
+ &irc_command_ignore, NULL, NULL);
weechat_hook_command (
"info",
N_("get information describing the server"),
N_("[<target>]"),
N_("target: server name"),
- NULL, &irc_command_info, NULL);
+ NULL, &irc_command_info, NULL, NULL);
weechat_hook_command (
"invite",
N_("invite a nick on a channel"),
N_("<nick> [<nick>...] [<channel>]"),
N_(" nick: nick\n"
"channel: channel name"),
- "%(nicks) %(irc_server_channels)", &irc_command_invite, NULL);
+ "%(nicks) %(irc_server_channels)", &irc_command_invite, NULL, NULL);
weechat_hook_command (
"ison",
N_("check if a nick is currently on IRC"),
N_("<nick> [<nick>...]"),
N_("nick: nick"),
- "%(nicks)|%*", &irc_command_ison, NULL);
+ "%(nicks)|%*", &irc_command_ison, NULL, NULL);
weechat_hook_command (
"join",
N_("join a channel"),
@@ -6275,7 +6334,7 @@ irc_command_init ()
" /join -server freenode #weechat\n"
" /join -noswitch #weechat"),
"%(irc_channels)|-noswitch|-server|%(irc_servers)|%*",
- &irc_command_join, NULL);
+ &irc_command_join, NULL, NULL);
weechat_hook_command (
"kick",
N_("kick a user out of a channel"),
@@ -6284,7 +6343,7 @@ irc_command_init ()
" nick: nick\n"
" reason: reason (special variables $nick, $channel and $server are "
"replaced by their value)"),
- "%(nicks) %(irc_msg_kick) %-", &irc_command_kick, NULL);
+ "%(nicks) %(irc_msg_kick) %-", &irc_command_kick, NULL, NULL);
weechat_hook_command (
"kickban",
N_("kick a user out of a channel and ban the host"),
@@ -6301,14 +6360,14 @@ irc_command_init ()
" ban \"*!*@host.com\" and then kick \"toto\":\n"
" /kickban toto!*@host.com"),
"%(irc_channel_nicks_hosts) %(irc_msg_kick) %-",
- &irc_command_kickban, NULL);
+ &irc_command_kickban, NULL, NULL);
weechat_hook_command (
"kill",
N_("close client-server connection"),
N_("<nick> [<reason>]"),
N_(" nick: nick\n"
"reason: reason"),
- "%(nicks) %-", &irc_command_kill, NULL);
+ "%(nicks) %-", &irc_command_kill, NULL, NULL);
weechat_hook_command (
"links",
N_("list all servernames which are known by the server answering the "
@@ -6316,7 +6375,7 @@ irc_command_init ()
N_("[[<server>] <server_mask>]"),
N_(" server: this server should answer the query\n"
"server_mask: list of servers must match this mask"),
- NULL, &irc_command_links, NULL);
+ NULL, &irc_command_links, NULL, NULL);
weechat_hook_command (
"list",
N_("list channels and their topic"),
@@ -6336,26 +6395,26 @@ irc_command_init ()
" list all channels beginning with \"#weechat\" (can be very slow "
"on large networks):\n"
" /list -re #weechat.*"),
- NULL, &irc_command_list, NULL);
+ NULL, &irc_command_list, NULL, NULL);
weechat_hook_command (
"lusers",
N_("get statistics about the size of the IRC network"),
N_("[<mask> [<target>]]"),
N_(" mask: servers matching the mask only\n"
"target: server for forwarding request"),
- NULL, &irc_command_lusers, NULL);
+ NULL, &irc_command_lusers, NULL, NULL);
weechat_hook_command (
"map",
N_("show a graphical map of the IRC network"),
"",
"",
- NULL, &irc_command_map, NULL);
+ NULL, &irc_command_map, NULL, NULL);
weechat_hook_command (
"me",
N_("send a CTCP action to the current channel"),
N_("<message>"),
N_("message: message to send"),
- NULL, &irc_command_me, NULL);
+ NULL, &irc_command_me, NULL, NULL);
weechat_hook_command (
"mode",
N_("change channel or user mode"),
@@ -6390,13 +6449,13 @@ irc_command_init ()
" /mode #weechat +t\n"
" become invisible on server:\n"
" /mode nick +i"),
- "%(irc_channel)|%(irc_server_nick)", &irc_command_mode, NULL);
+ "%(irc_channel)|%(irc_server_nick)", &irc_command_mode, NULL, NULL);
weechat_hook_command (
"motd",
N_("get the \"Message Of The Day\""),
N_("[<target>]"),
N_("target: server name"),
- NULL, &irc_command_motd, NULL);
+ NULL, &irc_command_motd, NULL, NULL);
weechat_hook_command (
"msg",
N_("send message to a nick or channel"),
@@ -6404,15 +6463,15 @@ irc_command_init ()
N_("server: send to this server (internal name)\n"
"target: nick or channel (may be mask, '*' = current channel)\n"
" text: text to send"),
- "-server %(irc_servers) %(nicks)"
- " || %(nicks)",
- &irc_command_msg, NULL);
+ "-server %(irc_servers) %(nicks)|*"
+ " || %(nicks)|*",
+ &irc_command_msg, NULL, NULL);
weechat_hook_command (
"names",
N_("list nicks on channels"),
N_("[<channel>[,<channel>...]]"),
N_("channel: channel name"),
- "%(irc_channels)", &irc_command_names, NULL);
+ "%(irc_channels)", &irc_command_names, NULL, NULL);
weechat_hook_command (
"nick",
N_("change current nick"),
@@ -6421,7 +6480,7 @@ irc_command_init ()
"nick: new nick"),
"-all %(irc_server_nick)"
" || %(irc_server_nick)",
- &irc_command_nick, NULL);
+ &irc_command_nick, NULL, NULL);
weechat_hook_command (
"notice",
N_("send notice message to user"),
@@ -6431,7 +6490,7 @@ irc_command_init ()
" text: text to send"),
"-server %(irc_servers) %(nicks)"
" || %(nicks)",
- &irc_command_notice, NULL);
+ &irc_command_notice, NULL, NULL);
weechat_hook_command (
"notify",
N_("add a notification for presence or away status of nicks on servers"),
@@ -6457,42 +6516,42 @@ irc_command_init ()
" /notify add toto freenode -away"),
"add %(irc_channel_nicks) %(irc_servers) -away %-"
" || del -all|%(irc_notify_nicks) %(irc_servers) %-",
- &irc_command_notify, NULL);
+ &irc_command_notify, NULL, NULL);
weechat_hook_command (
"op",
N_("give channel operator status to nick(s)"),
N_("<nick> [<nick>...] || * -yes"),
N_("nick: nick or mask (wildcard \"*\" is allowed)\n"
" *: give channel operator status to everybody on channel"),
- "%(nicks)|%*", &irc_command_op, NULL);
+ "%(nicks)|%*", &irc_command_op, NULL, NULL);
weechat_hook_command (
"oper",
N_("get operator privileges"),
N_("<user> <password>"),
N_(" user: user\n"
"password: password"),
- NULL, &irc_command_oper, NULL);
+ NULL, &irc_command_oper, NULL, NULL);
weechat_hook_command (
"part",
N_("leave a channel"),
N_("[<channel>[,<channel>...]] [<message>]"),
N_("channel: channel name to leave\n"
"message: part message (displayed to other users)"),
- "%(irc_msg_part)", &irc_command_part, NULL);
+ "%(irc_msg_part)", &irc_command_part, NULL, NULL);
weechat_hook_command (
"ping",
N_("send a ping to server"),
N_("<server1> [<server2>]"),
N_("server1: server\n"
"server2: forward ping to this server"),
- NULL, &irc_command_ping, NULL);
+ NULL, &irc_command_ping, NULL, NULL);
weechat_hook_command (
"pong",
N_("answer to a ping message"),
N_("<daemon> [<daemon2>]"),
N_(" daemon: daemon who has responded to Ping message\n"
"daemon2: forward message to this daemon"),
- NULL, &irc_command_pong, NULL);
+ NULL, &irc_command_pong, NULL, NULL);
weechat_hook_command (
"query",
N_("send a private message to a nick"),
@@ -6503,7 +6562,7 @@ irc_command_init ()
" text: text to send"),
"-noswitch|-server %(irc_servers) %(nicks)"
" || %(nicks)",
- &irc_command_query, NULL);
+ &irc_command_query, NULL, NULL);
weechat_hook_command (
"quiet",
N_("quiet nicks or hosts"),
@@ -6511,16 +6570,16 @@ irc_command_init ()
N_("channel: channel name\n"
" nick: nick or host\n"
"\n"
- "Without argument, this command display quiet list for current "
- "channel."),
- "%(irc_channel_nicks_hosts)", &irc_command_quiet, NULL);
+ "Without argument, this command displays the quiet list for "
+ "current channel."),
+ "%(irc_channel_nicks_hosts)", &irc_command_quiet, NULL, NULL);
weechat_hook_command (
"quote",
N_("send raw data to server without parsing"),
N_("[-server <server>] <data>"),
N_("server: send to this server (internal name)\n"
" data: raw data to send"),
- "-server %(irc_servers)", &irc_command_quote, NULL);
+ "-server %(irc_servers)", &irc_command_quote, NULL, NULL);
weechat_hook_command (
"reconnect",
N_("reconnect to server(s)"),
@@ -6532,13 +6591,13 @@ irc_command_init ()
"server)\n"
"-switch: switch to next server address"),
"%(irc_servers)|-all|-nojoin|-switch|%*",
- &irc_command_reconnect, NULL);
+ &irc_command_reconnect, NULL, NULL);
weechat_hook_command (
"rehash",
N_("tell the server to reload its config file"),
N_("[<option>]"),
N_("option: extra option, for some servers"),
- NULL, &irc_command_rehash, NULL);
+ NULL, &irc_command_rehash, NULL, NULL);
weechat_hook_command (
"remove",
N_("force a user to leave a channel"),
@@ -6547,55 +6606,55 @@ irc_command_init ()
" nick: nick\n"
" reason: reason (special variables $nick, $channel and $server are "
"replaced by their value)"),
- "%(irc_channel)|%(nicks) %(nicks)", &irc_command_remove, NULL);
+ "%(irc_channel)|%(nicks) %(nicks)", &irc_command_remove, NULL, NULL);
weechat_hook_command (
"restart",
N_("tell the server to restart itself"),
N_("[<target>]"),
N_("target: server name"),
- NULL, &irc_command_restart, NULL);
+ NULL, &irc_command_restart, NULL, NULL);
weechat_hook_command (
"sajoin",
N_("force a user to join channel(s)"),
N_("<nick> <channel>[,<channel>...]"),
N_(" nick: nick\n"
"channel: channel name"),
- "%(nicks) %(irc_server_channels)", &irc_command_sajoin, NULL);
+ "%(nicks) %(irc_server_channels)", &irc_command_sajoin, NULL, NULL);
weechat_hook_command (
"samode",
N_("change mode on channel, without having operator status"),
N_("[<channel>] <mode>"),
N_("channel: channel name\n"
" mode: mode for channel"),
- "%(irc_server_channels)", &irc_command_samode, NULL);
+ "%(irc_server_channels)", &irc_command_samode, NULL, NULL);
weechat_hook_command (
"sanick",
N_("force a user to use another nick"),
N_("<nick> <new_nick>"),
N_(" nick: nick\n"
"new_nick: new nick"),
- "%(nicks) %(nicks)", &irc_command_sanick, NULL);
+ "%(nicks) %(nicks)", &irc_command_sanick, NULL, NULL);
weechat_hook_command (
"sapart",
N_("force a user to leave channel(s)"),
N_("<nick> <channel>[,<channel>...]"),
N_(" nick: nick\n"
"channel: channel name"),
- "%(nicks) %(irc_server_channels)", &irc_command_sapart, NULL);
+ "%(nicks) %(irc_server_channels)", &irc_command_sapart, NULL, NULL);
weechat_hook_command (
"saquit",
N_("force a user to quit server with a reason"),
N_("<nick> <reason>"),
N_(" nick: nick\n"
"reason: reason"),
- "%(nicks)", &irc_command_saquit, NULL);
+ "%(nicks)", &irc_command_saquit, NULL, NULL);
weechat_hook_command (
"service",
N_("register a new service"),
N_("<nick> <reserved> <distribution> <type> <reserved> <info>"),
N_("distribution: visibility of service\n"
" type: reserved for future usage"),
- NULL, &irc_command_service, NULL);
+ NULL, &irc_command_service, NULL, NULL);
weechat_hook_command (
"server",
N_("list, add or remove IRC servers"),
@@ -6648,35 +6707,35 @@ irc_command_init ()
" || deloutq"
" || jump"
" || raw",
- &irc_command_server, NULL);
+ &irc_command_server, NULL, NULL);
weechat_hook_command (
"servlist",
N_("list services currently connected to the network"),
N_("[<mask> [<type>]]"),
N_("mask: list only services matching this mask\n"
"type: list only services of this type"),
- NULL, &irc_command_servlist, NULL);
+ NULL, &irc_command_servlist, NULL, NULL);
weechat_hook_command (
"squery",
N_("deliver a message to a service"),
N_("<service> <text>"),
N_("service: name of service\n"
" text: text to send"),
- NULL, &irc_command_squery, NULL);
+ NULL, &irc_command_squery, NULL, NULL);
weechat_hook_command (
"squit",
N_("disconnect server links"),
N_("<server> <comment>"),
N_( " server: server name\n"
"comment: comment"),
- NULL, &irc_command_squit, NULL);
+ NULL, &irc_command_squit, NULL, NULL);
weechat_hook_command (
"stats",
N_("query statistics about server"),
N_("[<query> [<server>]]"),
N_(" query: c/h/i/k/l/m/o/y/u (see RFC1459)\n"
"server: server name"),
- NULL, &irc_command_stats, NULL);
+ NULL, &irc_command_stats, NULL, NULL);
weechat_hook_command (
"summon",
N_("give users who are on a host running an IRC "
@@ -6686,13 +6745,13 @@ irc_command_init ()
N_(" user: username\n"
" target: server name\n"
"channel: channel name"),
- NULL, &irc_command_summon, NULL);
+ NULL, &irc_command_summon, NULL, NULL);
weechat_hook_command (
"time",
N_("query local time from server"),
N_("[<target>]"),
N_("target: query time from specified server"),
- NULL, &irc_command_time, NULL);
+ NULL, &irc_command_time, NULL, NULL);
weechat_hook_command (
"topic",
N_("get/set channel topic"),
@@ -6700,74 +6759,74 @@ irc_command_init ()
N_("channel: channel name\n"
" topic: new topic\n"
"-delete: delete channel topic"),
- "%(irc_channel_topic)|-delete", &irc_command_topic, NULL);
+ "%(irc_channel_topic)|-delete", &irc_command_topic, NULL, NULL);
weechat_hook_command (
"trace",
N_("find the route to specific server"),
N_("[<target>]"),
N_("target: server name"),
- NULL, &irc_command_trace, NULL);
+ NULL, &irc_command_trace, NULL, NULL);
weechat_hook_command (
"unban",
N_("unban nicks or hosts"),
N_("[<channel>] <nick> [<nick>...]"),
N_("channel: channel name\n"
" nick: nick or host"),
- NULL, &irc_command_unban, NULL);
+ NULL, &irc_command_unban, NULL, NULL);
weechat_hook_command (
"unquiet",
N_("unquiet nicks or hosts"),
N_("[<channel>] <nick> [<nick>...]"),
N_("channel: channel name\n"
" nick: nick or host"),
- "%(irc_channel_nicks_hosts)", &irc_command_unquiet, NULL);
+ "%(irc_channel_nicks_hosts)", &irc_command_unquiet, NULL, NULL);
weechat_hook_command (
"userhost",
N_("return a list of information about nicks"),
N_("<nick> [<nick>...]"),
N_("nick: nick"),
- "%(nicks)", &irc_command_userhost, NULL);
+ "%(nicks)", &irc_command_userhost, NULL, NULL);
weechat_hook_command (
"users",
N_("list of users logged into the server"),
N_("[<target>]"),
N_("target: server name"),
- NULL, &irc_command_users, NULL);
+ NULL, &irc_command_users, NULL, NULL);
weechat_hook_command (
"version",
N_("give the version info of nick or server (current or specified)"),
N_("[<server>|<nick>]"),
N_("server: server name\n"
" nick: nick"),
- "%(nicks)", &irc_command_version, NULL);
+ "%(nicks)", &irc_command_version, NULL, NULL);
weechat_hook_command (
"voice",
N_("give voice to nick(s)"),
N_("<nick> [<nick>...]"),
N_("nick: nick or mask (wildcard \"*\" is allowed)\n"
" *: give voice to everybody on channel"),
- "%(nicks)|%*", &irc_command_voice, NULL);
+ "%(nicks)|%*", &irc_command_voice, NULL, NULL);
weechat_hook_command (
"wallchops",
N_("send a notice to channel ops"),
N_("[<channel>] <text>"),
N_("channel: channel name\n"
" text: text to send"),
- NULL, &irc_command_wallchops, NULL);
+ NULL, &irc_command_wallchops, NULL, NULL);
weechat_hook_command (
"wallops",
N_("send a message to all currently connected users who have set the "
"'w' user mode for themselves"),
N_("<text>"),
N_("text: text to send"),
- NULL, &irc_command_wallops, NULL);
+ NULL, &irc_command_wallops, NULL, NULL);
weechat_hook_command (
"who",
N_("generate a query which returns a list of information"),
N_("[<mask> [o]]"),
N_("mask: only information which match this mask\n"
" o: only operators are returned according to the mask supplied"),
- "%(irc_channels)", &irc_command_who, NULL);
+ "%(irc_channels)", &irc_command_who, NULL, NULL);
weechat_hook_command (
"whois",
N_("query information about user(s)"),
@@ -6781,7 +6840,7 @@ irc_command_init ()
"\n"
"If option irc.network.whois_double_nick is enabled, two nicks are "
"sent (if only one nick is given), to get idle time in answer."),
- "%(nicks)", &irc_command_whois, NULL);
+ "%(nicks)", &irc_command_whois, NULL, NULL);
weechat_hook_command (
"whowas",
N_("ask for information about a nick which no longer exists"),
@@ -6790,5 +6849,5 @@ irc_command_init ()
" count: number of replies to return (full search if negative "
"number)\n"
"target: reply should match this mask"),
- "%(nicks)", &irc_command_whowas, NULL);
+ "%(nicks)", &irc_command_whowas, NULL, NULL);
}
diff --git a/src/plugins/irc/irc-command.h b/src/plugins/irc/irc-command.h
index acedfa926..196394755 100644
--- a/src/plugins/irc/irc-command.h
+++ b/src/plugins/irc/irc-command.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -23,6 +23,12 @@
struct t_irc_server;
struct t_irc_channel;
+#define IRC_COMMAND_CALLBACK(__command) \
+ int \
+ irc_command_##__command (const void *pointer, void *data, \
+ struct t_gui_buffer *buffer, \
+ int argc, char **argv, char **argv_eol)
+
#define IRC_COMMAND_CHECK_SERVER(__command, __check_connection) \
if (!ptr_server) \
{ \
@@ -43,6 +49,15 @@ struct t_irc_channel;
return WEECHAT_RC_OK; \
}
+/* list of supported capabilities (for completion in command /cap) */
+#define IRC_COMMAND_CAP_SUPPORTED_COMPLETION \
+ "account-notify|away-notify|cap-notify|extended-join|" \
+ "multi-prefix|server-time|userhost-in-names|%*"
+
+/* list of supported CTCPs (for completion in command /ctcp) */
+#define IRC_COMMAND_CTCP_SUPPORTED_COMPLETION \
+ "action|clientinfo|finger|ping|source|time|userinfo|version"
+
extern void irc_command_away_server (struct t_irc_server *server,
const char *arguments,
int reset_unread_marker);
diff --git a/src/plugins/irc/irc-completion.c b/src/plugins/irc/irc-completion.c
index 831429fe9..56b2bf21e 100644
--- a/src/plugins/irc/irc-completion.c
+++ b/src/plugins/irc/irc-completion.c
@@ -1,7 +1,7 @@
/*
* irc-completion.c - completion for IRC commands
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -41,13 +41,15 @@
*/
int
-irc_completion_server_cb (void *data, const char *completion_item,
+irc_completion_server_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
IRC_BUFFER_GET_SERVER(buffer);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
@@ -65,13 +67,15 @@ irc_completion_server_cb (void *data, const char *completion_item,
*/
int
-irc_completion_server_nick_cb (void *data, const char *completion_item,
+irc_completion_server_nick_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
IRC_BUFFER_GET_SERVER(buffer);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
@@ -89,30 +93,38 @@ irc_completion_server_nick_cb (void *data, const char *completion_item,
*/
int
-irc_completion_server_channels_cb (void *data, const char *completion_item,
+irc_completion_server_channels_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
- struct t_irc_channel *ptr_channel;
+ struct t_irc_channel *ptr_channel2;
- IRC_BUFFER_GET_SERVER(buffer);
+ IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
- (void) buffer;
if (ptr_server)
{
- for (ptr_channel = ptr_server->channels; ptr_channel;
- ptr_channel = ptr_channel->next_channel)
+ for (ptr_channel2 = ptr_server->channels; ptr_channel2;
+ ptr_channel2 = ptr_channel2->next_channel)
{
- if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
+ if (ptr_channel2->type == IRC_CHANNEL_TYPE_CHANNEL)
{
- weechat_hook_completion_list_add (completion, ptr_channel->name,
+ weechat_hook_completion_list_add (completion, ptr_channel2->name,
0, WEECHAT_LIST_POS_SORT);
}
}
+
+ /* add current channel first in list */
+ if (ptr_channel)
+ {
+ weechat_hook_completion_list_add (completion, ptr_channel->name,
+ 0, WEECHAT_LIST_POS_BEGINNING);
+ }
}
return WEECHAT_RC_OK;
@@ -123,7 +135,8 @@ irc_completion_server_channels_cb (void *data, const char *completion_item,
*/
int
-irc_completion_server_privates_cb (void *data, const char *completion_item,
+irc_completion_server_privates_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
@@ -132,9 +145,9 @@ irc_completion_server_privates_cb (void *data, const char *completion_item,
IRC_BUFFER_GET_SERVER(buffer);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
- (void) buffer;
if (ptr_server)
{
@@ -157,7 +170,8 @@ irc_completion_server_privates_cb (void *data, const char *completion_item,
*/
int
-irc_completion_server_nicks_cb (void *data, const char *completion_item,
+irc_completion_server_nicks_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
@@ -167,6 +181,7 @@ irc_completion_server_nicks_cb (void *data, const char *completion_item,
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
@@ -199,13 +214,15 @@ irc_completion_server_nicks_cb (void *data, const char *completion_item,
*/
int
-irc_completion_servers_cb (void *data, const char *completion_item,
+irc_completion_servers_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
struct t_irc_server *ptr_server;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -225,13 +242,15 @@ irc_completion_servers_cb (void *data, const char *completion_item,
*/
int
-irc_completion_channel_cb (void *data, const char *completion_item,
+irc_completion_channel_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
@@ -280,7 +299,8 @@ irc_completion_channel_nicks_add_speakers (struct t_gui_completion *completion,
*/
int
-irc_completion_channel_nicks_cb (void *data, const char *completion_item,
+irc_completion_channel_nicks_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
@@ -289,6 +309,7 @@ irc_completion_channel_nicks_cb (void *data, const char *completion_item,
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
@@ -345,7 +366,8 @@ irc_completion_channel_nicks_cb (void *data, const char *completion_item,
*/
int
-irc_completion_channel_nicks_hosts_cb (void *data, const char *completion_item,
+irc_completion_channel_nicks_hosts_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
@@ -356,6 +378,7 @@ irc_completion_channel_nicks_hosts_cb (void *data, const char *completion_item,
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
@@ -402,7 +425,8 @@ irc_completion_channel_nicks_hosts_cb (void *data, const char *completion_item,
*/
int
-irc_completion_channel_topic_cb (void *data, const char *completion_item,
+irc_completion_channel_topic_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
@@ -412,6 +436,7 @@ irc_completion_channel_topic_cb (void *data, const char *completion_item,
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
@@ -454,32 +479,71 @@ irc_completion_channel_topic_cb (void *data, const char *completion_item,
*/
int
-irc_completion_channels_cb (void *data, const char *completion_item,
+irc_completion_channels_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
- struct t_irc_server *ptr_server;
- struct t_irc_channel *ptr_channel;
+ struct t_irc_server *ptr_server2;
+ struct t_irc_channel *ptr_channel2;
+ struct t_weelist *channels_current_server;
+ int i;
+
+ IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
- (void) buffer;
- for (ptr_server = irc_servers; ptr_server;
- ptr_server = ptr_server->next_server)
+ channels_current_server = weechat_list_new ();
+
+ for (ptr_server2 = irc_servers; ptr_server2;
+ ptr_server2 = ptr_server2->next_server)
{
- for (ptr_channel = ptr_server->channels; ptr_channel;
- ptr_channel = ptr_channel->next_channel)
+ for (ptr_channel2 = ptr_server2->channels; ptr_channel2;
+ ptr_channel2 = ptr_channel2->next_channel)
{
- if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
+ if (ptr_channel2->type == IRC_CHANNEL_TYPE_CHANNEL)
{
- weechat_hook_completion_list_add (completion, ptr_channel->name,
- 0, WEECHAT_LIST_POS_SORT);
+ if (ptr_server2 == ptr_server)
+ {
+ /* will be added later to completions */
+ weechat_list_add (channels_current_server,
+ ptr_channel2->name,
+ WEECHAT_LIST_POS_SORT,
+ NULL);
+ }
+ else
+ {
+ weechat_hook_completion_list_add (completion,
+ ptr_channel2->name,
+ 0,
+ WEECHAT_LIST_POS_SORT);
+ }
}
}
}
+ /* add channels of current server first in list */
+ for (i = weechat_list_size (channels_current_server) - 1; i >= 0; i--)
+ {
+ weechat_hook_completion_list_add (
+ completion,
+ weechat_list_string (
+ weechat_list_get (channels_current_server, i)),
+ 0,
+ WEECHAT_LIST_POS_BEGINNING);
+ }
+ weechat_list_free (channels_current_server);
+
+ /* add current channel first in list */
+ if (ptr_channel)
+ {
+ weechat_hook_completion_list_add (completion, ptr_channel->name,
+ 0, WEECHAT_LIST_POS_BEGINNING);
+ }
+
return WEECHAT_RC_OK;
}
@@ -488,7 +552,8 @@ irc_completion_channels_cb (void *data, const char *completion_item,
*/
int
-irc_completion_privates_cb (void *data, const char *completion_item,
+irc_completion_privates_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
@@ -496,6 +561,7 @@ irc_completion_privates_cb (void *data, const char *completion_item,
struct t_irc_channel *ptr_channel;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -522,7 +588,8 @@ irc_completion_privates_cb (void *data, const char *completion_item,
*/
int
-irc_completion_msg_kick_cb (void *data, const char *completion_item,
+irc_completion_msg_kick_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
@@ -531,13 +598,14 @@ irc_completion_msg_kick_cb (void *data, const char *completion_item,
IRC_BUFFER_GET_SERVER(buffer);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
if (ptr_server)
{
msg_kick = IRC_SERVER_OPTION_STRING(ptr_server,
- IRC_SERVER_OPTION_DEFAULT_MSG_KICK);
+ IRC_SERVER_OPTION_MSG_KICK);
if (msg_kick && msg_kick[0])
{
weechat_hook_completion_list_add (completion, msg_kick,
@@ -553,7 +621,8 @@ irc_completion_msg_kick_cb (void *data, const char *completion_item,
*/
int
-irc_completion_msg_part_cb (void *data, const char *completion_item,
+irc_completion_msg_part_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
@@ -562,13 +631,14 @@ irc_completion_msg_part_cb (void *data, const char *completion_item,
IRC_BUFFER_GET_SERVER(buffer);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
if (ptr_server)
{
msg_part = IRC_SERVER_OPTION_STRING(ptr_server,
- IRC_SERVER_OPTION_DEFAULT_MSG_PART);
+ IRC_SERVER_OPTION_MSG_PART);
if (msg_part && msg_part[0])
{
weechat_hook_completion_list_add (completion, msg_part,
@@ -584,7 +654,8 @@ irc_completion_msg_part_cb (void *data, const char *completion_item,
*/
int
-irc_completion_ignores_numbers_cb (void *data, const char *completion_item,
+irc_completion_ignores_numbers_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
@@ -592,6 +663,7 @@ irc_completion_ignores_numbers_cb (void *data, const char *completion_item,
char str_number[32];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -612,7 +684,8 @@ irc_completion_ignores_numbers_cb (void *data, const char *completion_item,
*/
int
-irc_completion_notify_nicks_cb (void *data, const char *completion_item,
+irc_completion_notify_nicks_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
@@ -621,6 +694,7 @@ irc_completion_notify_nicks_cb (void *data, const char *completion_item,
IRC_BUFFER_GET_SERVER(buffer);
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
@@ -659,50 +733,50 @@ irc_completion_init ()
{
weechat_hook_completion ("irc_server",
N_("current IRC server"),
- &irc_completion_server_cb, NULL);
+ &irc_completion_server_cb, NULL, NULL);
weechat_hook_completion ("irc_server_nick",
N_("nick on current IRC server"),
- &irc_completion_server_nick_cb, NULL);
+ &irc_completion_server_nick_cb, NULL, NULL);
weechat_hook_completion ("irc_server_channels",
N_("channels on current IRC server"),
- &irc_completion_server_channels_cb, NULL);
+ &irc_completion_server_channels_cb, NULL, NULL);
weechat_hook_completion ("irc_server_privates",
N_("privates on current IRC server"),
- &irc_completion_server_privates_cb, NULL);
+ &irc_completion_server_privates_cb, NULL, NULL);
weechat_hook_completion ("irc_server_nicks",
N_("nicks on all channels of current IRC server"),
- &irc_completion_server_nicks_cb, NULL);
+ &irc_completion_server_nicks_cb, NULL, NULL);
weechat_hook_completion ("irc_servers",
N_("IRC servers (internal names)"),
- &irc_completion_servers_cb, NULL);
+ &irc_completion_servers_cb, NULL, NULL);
weechat_hook_completion ("irc_channel",
N_("current IRC channel"),
- &irc_completion_channel_cb, NULL);
+ &irc_completion_channel_cb, NULL, NULL);
weechat_hook_completion ("nick",
N_("nicks of current IRC channel"),
- &irc_completion_channel_nicks_cb, NULL);
+ &irc_completion_channel_nicks_cb, NULL, NULL);
weechat_hook_completion ("irc_channel_nicks_hosts",
N_("nicks and hostnames of current IRC channel"),
- &irc_completion_channel_nicks_hosts_cb, NULL);
+ &irc_completion_channel_nicks_hosts_cb, NULL, NULL);
weechat_hook_completion ("irc_channel_topic",
N_("topic of current IRC channel"),
- &irc_completion_channel_topic_cb, NULL);
+ &irc_completion_channel_topic_cb, NULL, NULL);
weechat_hook_completion ("irc_channels",
N_("channels on all IRC servers"),
- &irc_completion_channels_cb, NULL);
+ &irc_completion_channels_cb, NULL, NULL);
weechat_hook_completion ("irc_privates",
N_("privates on all IRC servers"),
- &irc_completion_privates_cb, NULL);
+ &irc_completion_privates_cb, NULL, NULL);
weechat_hook_completion ("irc_msg_kick",
N_("default kick message"),
- &irc_completion_msg_kick_cb, NULL);
+ &irc_completion_msg_kick_cb, NULL, NULL);
weechat_hook_completion ("irc_msg_part",
N_("default part message for IRC channel"),
- &irc_completion_msg_part_cb, NULL);
+ &irc_completion_msg_part_cb, NULL, NULL);
weechat_hook_completion ("irc_ignores_numbers",
N_("numbers for defined ignores"),
- &irc_completion_ignores_numbers_cb, NULL);
+ &irc_completion_ignores_numbers_cb, NULL, NULL);
weechat_hook_completion ("irc_notify_nicks",
N_("nicks in notify list"),
- &irc_completion_notify_nicks_cb, NULL);
+ &irc_completion_notify_nicks_cb, NULL, NULL);
}
diff --git a/src/plugins/irc/irc-completion.h b/src/plugins/irc/irc-completion.h
index aa2eb1a6f..20dacb576 100644
--- a/src/plugins/irc/irc-completion.h
+++ b/src/plugins/irc/irc-completion.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c
index 6828834fe..d4acd7ba3 100644
--- a/src/plugins/irc/irc-config.c
+++ b/src/plugins/irc/irc-config.c
@@ -1,7 +1,7 @@
/*
* irc-config.c - IRC configuration options (file irc.conf)
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -75,7 +75,6 @@ struct t_config_option *irc_config_look_highlight_channel;
struct t_config_option *irc_config_look_highlight_pv;
struct t_config_option *irc_config_look_highlight_server;
struct t_config_option *irc_config_look_highlight_tags_restrict;
-struct t_config_option *irc_config_look_item_away_message;
struct t_config_option *irc_config_look_item_channel_modes_hide_args;
struct t_config_option *irc_config_look_item_display_server;
struct t_config_option *irc_config_look_item_nick_modes;
@@ -84,9 +83,6 @@ struct t_config_option *irc_config_look_join_auto_add_chantype;
struct t_config_option *irc_config_look_msgbuffer_fallback;
struct t_config_option *irc_config_look_new_channel_position;
struct t_config_option *irc_config_look_new_pv_position;
-struct t_config_option *irc_config_look_nick_color_force;
-struct t_config_option *irc_config_look_nick_color_hash;
-struct t_config_option *irc_config_look_nick_color_stop_chars;
struct t_config_option *irc_config_look_nick_completion_smart;
struct t_config_option *irc_config_look_nick_mode;
struct t_config_option *irc_config_look_nick_mode_empty;
@@ -114,7 +110,6 @@ struct t_config_option *irc_config_look_topic_strip_colors;
/* IRC config, color section */
struct t_config_option *irc_config_color_input_nick;
-struct t_config_option *irc_config_color_item_away;
struct t_config_option *irc_config_color_item_channel_modes;
struct t_config_option *irc_config_color_item_lag_counting;
struct t_config_option *irc_config_color_item_lag_finished;
@@ -131,7 +126,6 @@ struct t_config_option *irc_config_color_topic_old;
/* IRC config, network section */
-struct t_config_option *irc_config_network_alternate_nick;
struct t_config_option *irc_config_network_autoreconnect_delay_growing;
struct t_config_option *irc_config_network_autoreconnect_delay_max;
struct t_config_option *irc_config_network_ban_mask_default;
@@ -145,6 +139,7 @@ struct t_config_option *irc_config_network_lag_reconnect;
struct t_config_option *irc_config_network_lag_refresh_interval;
struct t_config_option *irc_config_network_notify_check_ison;
struct t_config_option *irc_config_network_notify_check_whois;
+struct t_config_option *irc_config_network_sasl_fail_unavailable;
struct t_config_option *irc_config_network_send_unknown_commands;
struct t_config_option *irc_config_network_whois_double_nick;
@@ -152,11 +147,9 @@ struct t_config_option *irc_config_network_whois_double_nick;
struct t_config_option *irc_config_server_default[IRC_SERVER_NUM_OPTIONS];
-struct t_hook *irc_config_hook_config_nick_colors = NULL;
-char **irc_config_nick_colors = NULL;
-int irc_config_num_nick_colors = 0;
+struct t_hook *irc_config_hook_config_nick_color_options = NULL;
+struct t_hook *irc_config_hook_config_chat_nick_colors = NULL;
struct t_hashtable *irc_config_hashtable_display_join_message = NULL;
-struct t_hashtable *irc_config_hashtable_nick_color_force = NULL;
struct t_hashtable *irc_config_hashtable_nick_prefixes = NULL;
struct t_hashtable *irc_config_hashtable_color_mirc_remap = NULL;
char **irc_config_nicks_hide_password = NULL;
@@ -236,28 +229,6 @@ irc_config_compute_nick_colors ()
}
/*
- * Sets nick colors using option "weechat.color.chat_nick_colors".
- */
-
-void
-irc_config_set_nick_colors ()
-{
- if (irc_config_nick_colors)
- {
- weechat_string_free_split (irc_config_nick_colors);
- irc_config_nick_colors = NULL;
- irc_config_num_nick_colors = 0;
- }
-
- irc_config_nick_colors =
- weechat_string_split (
- weechat_config_string (
- weechat_config_get ("weechat.color.chat_nick_colors")),
- ",", 0, 0,
- &irc_config_num_nick_colors);
-}
-
-/*
* Checks if channel modes arguments must be displayed or hidden
* (according to option irc.look.item_channel_modes_hide_args).
*
@@ -297,19 +268,19 @@ irc_config_display_channel_modes_arguments (const char *modes)
}
/*
- * Callback for changes on option "weechat.color.chat_nick_colors".
+ * Callback for changes on options changing nick colors.
*/
int
-irc_config_change_nick_colors_cb (void *data, const char *option,
- const char *value)
+irc_config_change_nick_colors_cb (const void *pointer, void *data,
+ const char *option, const char *value)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
(void) value;
- irc_config_set_nick_colors ();
irc_config_compute_nick_colors ();
return WEECHAT_RC_OK;
@@ -320,10 +291,12 @@ irc_config_change_nick_colors_cb (void *data, const char *option,
*/
void
-irc_config_change_look_color_nicks_in_nicklist (void *data,
+irc_config_change_look_color_nicks_in_nicklist (const void *pointer,
+ void *data,
struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -335,10 +308,11 @@ irc_config_change_look_color_nicks_in_nicklist (void *data,
*/
void
-irc_config_change_look_display_away (void *data,
+irc_config_change_look_display_away (const void *pointer, void *data,
struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -360,13 +334,14 @@ irc_config_change_look_display_away (void *data,
*/
void
-irc_config_change_look_display_join_message (void *data,
+irc_config_change_look_display_join_message (const void *pointer, void *data,
struct t_config_option *option)
{
char **items;
int num_items, i;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -376,8 +351,7 @@ irc_config_change_look_display_join_message (void *data,
32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
}
else
weechat_hashtable_remove_all (irc_config_hashtable_display_join_message);
@@ -401,13 +375,14 @@ irc_config_change_look_display_join_message (void *data,
*/
void
-irc_config_change_look_server_buffer (void *data,
+irc_config_change_look_server_buffer (const void *pointer, void *data,
struct t_config_option *option)
{
struct t_irc_server *ptr_server;
struct t_gui_buffer *ptr_buffer;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -447,7 +422,7 @@ irc_config_change_look_server_buffer (void *data,
*/
void
-irc_config_change_look_pv_buffer (void *data,
+irc_config_change_look_pv_buffer (const void *pointer, void *data,
struct t_config_option *option)
{
struct t_irc_server *ptr_server;
@@ -455,6 +430,7 @@ irc_config_change_look_pv_buffer (void *data,
struct t_gui_buffer *ptr_buffer;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -507,29 +483,16 @@ irc_config_change_look_pv_buffer (void *data,
}
/*
- * Callback for changes on option "irc.look.item_away_message".
- */
-
-void
-irc_config_change_look_item_away_message (void *data,
- struct t_config_option *option)
-{
- /* make C compiler happy */
- (void) data;
- (void) option;
-
- weechat_bar_item_update ("away");
-}
-
-/*
* Callback for changes on option "irc.look.item_channel_modes_hide_args".
*/
void
-irc_config_change_look_item_channel_modes_hide_args (void *data,
+irc_config_change_look_item_channel_modes_hide_args (const void *pointer,
+ void *data,
struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -541,13 +504,14 @@ irc_config_change_look_item_channel_modes_hide_args (void *data,
*/
void
-irc_config_change_look_highlight_tags_restrict (void *data,
+irc_config_change_look_highlight_tags_restrict (const void *pointer, void *data,
struct t_config_option *option)
{
struct t_irc_server *ptr_server;
struct t_irc_channel *ptr_channel;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -574,78 +538,15 @@ irc_config_change_look_highlight_tags_restrict (void *data,
}
/*
- * Callback for changes on option "irc.look.nick_color_force".
- */
-
-void
-irc_config_change_look_nick_color_force (void *data,
- struct t_config_option *option)
-{
- char **items, *pos;
- int num_items, i;
-
- /* make C compiler happy */
- (void) data;
- (void) option;
-
- if (!irc_config_hashtable_nick_color_force)
- {
- irc_config_hashtable_nick_color_force = weechat_hashtable_new (
- 32,
- WEECHAT_HASHTABLE_STRING,
- WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
- }
- else
- weechat_hashtable_remove_all (irc_config_hashtable_nick_color_force);
-
- items = weechat_string_split (
- weechat_config_string (irc_config_look_nick_color_force),
- ";", 0, 0, &num_items);
- if (items)
- {
- for (i = 0; i < num_items; i++)
- {
- pos = strchr (items[i], ':');
- if (pos)
- {
- pos[0] = '\0';
- weechat_hashtable_set (irc_config_hashtable_nick_color_force,
- items[i],
- pos + 1);
- }
- }
- weechat_string_free_split (items);
- }
-
- irc_config_compute_nick_colors ();
-}
-
-/*
- * Callback for changes on options that change nick colors.
- */
-
-void
-irc_config_change_look_nick_colors (void *data,
- struct t_config_option *option)
-{
- /* make C compiler happy */
- (void) data;
- (void) option;
-
- irc_config_compute_nick_colors ();
-}
-
-/*
* Callback for changes on option "irc.look.item_display_server".
*/
void
-irc_config_change_look_item_display_server (void *data,
+irc_config_change_look_item_display_server (const void *pointer, void *data,
struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -659,12 +560,13 @@ irc_config_change_look_item_display_server (void *data,
*/
void
-irc_config_change_look_nicks_hide_password (void *data,
+irc_config_change_look_nicks_hide_password (const void *pointer, void *data,
struct t_config_option *option)
{
const char *nicks_hide_password;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -689,13 +591,14 @@ irc_config_change_look_nicks_hide_password (void *data,
*/
void
-irc_config_change_look_topic_strip_colors (void *data,
+irc_config_change_look_topic_strip_colors (const void *pointer, void *data,
struct t_config_option *option)
{
struct t_irc_server *ptr_server;
struct t_irc_channel *ptr_channel;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -716,10 +619,11 @@ irc_config_change_look_topic_strip_colors (void *data,
*/
void
-irc_config_change_bar_item_input_prompt (void *data,
+irc_config_change_bar_item_input_prompt (const void *pointer, void *data,
struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -727,29 +631,15 @@ irc_config_change_bar_item_input_prompt (void *data,
}
/*
- * Callback for changes on option "irc.color.item_away".
- */
-
-void
-irc_config_change_color_item_away (void *data,
- struct t_config_option *option)
-{
- /* make C compiler happy */
- (void) data;
- (void) option;
-
- weechat_bar_item_update ("away");
-}
-
-/*
* Callback for changes on option "irc.color.item_channel_modes".
*/
void
-irc_config_change_color_item_channel_modes (void *data,
+irc_config_change_color_item_channel_modes (const void *pointer, void *data,
struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -762,10 +652,11 @@ irc_config_change_color_item_channel_modes (void *data,
*/
void
-irc_config_change_color_item_lag (void *data,
+irc_config_change_color_item_lag (const void *pointer, void *data,
struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -777,10 +668,11 @@ irc_config_change_color_item_lag (void *data,
*/
void
-irc_config_change_color_item_nick_modes (void *data,
+irc_config_change_color_item_nick_modes (const void *pointer, void *data,
struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -793,12 +685,14 @@ irc_config_change_color_item_nick_modes (void *data,
*/
void
-irc_config_change_color_mirc_remap (void *data, struct t_config_option *option)
+irc_config_change_color_mirc_remap (const void *pointer, void *data,
+ struct t_config_option *option)
{
char **items, *pos;
int num_items, i;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -808,8 +702,7 @@ irc_config_change_color_mirc_remap (void *data, struct t_config_option *option)
32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
}
else
weechat_hashtable_remove_all (irc_config_hashtable_color_mirc_remap);
@@ -839,13 +732,14 @@ irc_config_change_color_mirc_remap (void *data, struct t_config_option *option)
*/
void
-irc_config_change_color_nick_prefixes (void *data,
+irc_config_change_color_nick_prefixes (const void *pointer, void *data,
struct t_config_option *option)
{
char **items, *pos;
int num_items, i;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -855,8 +749,7 @@ irc_config_change_color_nick_prefixes (void *data,
32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
}
else
weechat_hashtable_remove_all (irc_config_hashtable_nick_prefixes);
@@ -890,13 +783,14 @@ irc_config_change_color_nick_prefixes (void *data,
*/
void
-irc_config_change_network_lag_check (void *data,
+irc_config_change_network_lag_check (const void *pointer, void *data,
struct t_config_option *option)
{
time_t time_next_check;
struct t_irc_server *ptr_server;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -916,10 +810,11 @@ irc_config_change_network_lag_check (void *data,
*/
void
-irc_config_change_network_lag_min_show (void *data,
+irc_config_change_network_lag_min_show (const void *pointer, void *data,
struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -931,10 +826,11 @@ irc_config_change_network_lag_min_show (void *data,
*/
void
-irc_config_change_network_notify_check_ison (void *data,
+irc_config_change_network_notify_check_ison (const void *pointer, void *data,
struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -946,10 +842,11 @@ irc_config_change_network_notify_check_ison (void *data,
*/
void
-irc_config_change_network_notify_check_whois (void *data,
- struct t_config_option *option)
+irc_config_change_network_notify_check_whois (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -961,7 +858,8 @@ irc_config_change_network_notify_check_whois (void *data,
*/
void
-irc_config_change_network_send_unknown_commands (void *data,
+irc_config_change_network_send_unknown_commands (const void *pointer,
+ void *data,
struct t_config_option *option)
{
char value[2];
@@ -969,6 +867,7 @@ irc_config_change_network_send_unknown_commands (void *data,
struct t_irc_channel *ptr_channel;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -1006,12 +905,16 @@ irc_config_change_network_send_unknown_commands (void *data,
*/
void
-irc_config_server_default_change_cb (void *data, struct t_config_option *option)
+irc_config_server_default_change_cb (const void *pointer, void *data,
+ struct t_config_option *option)
{
int index_option;
struct t_irc_server *ptr_server;
- index_option = irc_server_search_option (data);
+ /* make C compiler happy */
+ (void) data;
+
+ index_option = irc_server_search_option (pointer);
if (index_option >= 0)
{
for (ptr_server = irc_servers; ptr_server;
@@ -1086,7 +989,7 @@ irc_config_check_gnutls_priorities (const char *priorities)
*/
int
-irc_config_server_check_value_cb (void *data,
+irc_config_server_check_value_cb (const void *pointer, void *data,
struct t_config_option *option,
const char *value)
{
@@ -1099,9 +1002,10 @@ irc_config_server_check_value_cb (void *data,
#endif /* HAVE_GNUTLS */
/* make C compiler happy */
+ (void) data;
(void) option;
- index_option = irc_server_search_option (data);
+ index_option = irc_server_search_option (pointer);
if (index_option >= 0)
{
switch (index_option)
@@ -1217,13 +1121,17 @@ irc_config_server_check_value_cb (void *data,
*/
void
-irc_config_server_change_cb (void *data, struct t_config_option *option)
+irc_config_server_change_cb (const void *pointer, void *data,
+ struct t_config_option *option)
{
int index_option;
char *name;
struct t_irc_server *ptr_server;
- index_option = irc_server_search_option (data);
+ /* make C compiler happy */
+ (void) data;
+
+ index_option = irc_server_search_option (pointer);
if (index_option >= 0)
{
name = weechat_config_option_get_pointer (option, "name");
@@ -1272,11 +1180,12 @@ irc_config_server_change_cb (void *data, struct t_config_option *option)
*/
int
-irc_config_server_default_check_notify (void *data,
+irc_config_server_default_check_notify (const void *pointer, void *data,
struct t_config_option *option,
const char *value)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -1291,12 +1200,14 @@ irc_config_server_default_check_notify (void *data,
*/
int
-irc_config_reload (void *data, struct t_config_file *config_file)
+irc_config_reload (const void *pointer, void *data,
+ struct t_config_file *config_file)
{
int rc;
struct t_irc_server *ptr_server, *next_server;
/* make C compiler happy */
+ (void) pointer;
(void) data;
for (ptr_server = irc_servers; ptr_server;
@@ -1350,7 +1261,7 @@ irc_config_reload (void *data, struct t_config_file *config_file)
*/
int
-irc_config_msgbuffer_create_option (void *data,
+irc_config_msgbuffer_create_option (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name, const char *value)
@@ -1359,6 +1270,7 @@ irc_config_msgbuffer_create_option (void *data,
int rc;
/* make C compiler happy */
+ (void) pointer;
(void) data;
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
@@ -1387,7 +1299,7 @@ irc_config_msgbuffer_create_option (void *data,
_("buffer used to display message received from IRC "
"server"),
"weechat|server|current|private", 0, 0, value, value, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
rc = (ptr_option) ?
WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE :
WEECHAT_CONFIG_OPTION_SET_ERROR;
@@ -1413,7 +1325,8 @@ irc_config_msgbuffer_create_option (void *data,
*/
int
-irc_config_ctcp_create_option (void *data, struct t_config_file *config_file,
+irc_config_ctcp_create_option (const void *pointer, void *data,
+ struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name, const char *value)
{
@@ -1424,6 +1337,7 @@ irc_config_ctcp_create_option (void *data, struct t_config_file *config_file,
const char *pos_name;
/* make C compiler happy */
+ (void) pointer;
(void) data;
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
@@ -1467,7 +1381,7 @@ irc_config_ctcp_create_option (void *data, struct t_config_file *config_file,
"$username (username on server), "
"$realname (realname on server)"),
NULL, 0, 0, default_value, value, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
rc = (ptr_option) ?
WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE :
WEECHAT_CONFIG_OPTION_SET_ERROR;
@@ -1497,7 +1411,7 @@ irc_config_ctcp_create_option (void *data, struct t_config_file *config_file,
*/
int
-irc_config_ignore_read_cb (void *data,
+irc_config_ignore_read_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name, const char *value)
@@ -1506,6 +1420,7 @@ irc_config_ignore_read_cb (void *data,
int argc;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) config_file;
(void) section;
@@ -1535,12 +1450,14 @@ irc_config_ignore_read_cb (void *data,
*/
int
-irc_config_ignore_write_cb (void *data, struct t_config_file *config_file,
+irc_config_ignore_write_cb (const void *pointer, void *data,
+ struct t_config_file *config_file,
const char *section_name)
{
struct t_irc_ignore *ptr_ignore;
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (!weechat_config_write_line (config_file, section_name, NULL))
@@ -1575,12 +1492,16 @@ irc_config_server_new_option (struct t_config_file *config_file,
const char *default_value,
const char *value,
int null_value_allowed,
- int (*callback_check_value)(void *data,
+ int (*callback_check_value)(const void *pointer,
+ void *data,
struct t_config_option *option,
const char *value),
+ const void *callback_check_value_pointer,
void *callback_check_value_data,
- void (*callback_change)(void *data,
+ void (*callback_change)(const void *pointer,
+ void *data,
struct t_config_option *option),
+ const void *callback_change_pointer,
void *callback_change_data)
{
struct t_config_option *new_option;
@@ -1594,13 +1515,18 @@ irc_config_server_new_option (struct t_config_file *config_file,
config_file, section,
option_name, "string",
N_("list of hostname/port or IP/port for server (separated by "
- "comma)"),
+ "comma) "
+ "(note: content is evaluated, see /help eval)"),
NULL, 0, 0,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_PROXY:
new_option = weechat_config_new_option (
@@ -1611,9 +1537,13 @@ irc_config_server_new_option (struct t_config_file *config_file,
NULL, 0, 0,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_IPV6:
new_option = weechat_config_new_option (
@@ -1624,9 +1554,13 @@ irc_config_server_new_option (struct t_config_file *config_file,
NULL, 0, 0,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_SSL:
new_option = weechat_config_new_option (
@@ -1636,9 +1570,13 @@ irc_config_server_new_option (struct t_config_file *config_file,
NULL, 0, 0,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_SSL_CERT:
new_option = weechat_config_new_option (
@@ -1650,9 +1588,13 @@ irc_config_server_new_option (struct t_config_file *config_file,
NULL, 0, 0,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_SSL_PRIORITIES:
new_option = weechat_config_new_option (
@@ -1665,9 +1607,13 @@ irc_config_server_new_option (struct t_config_file *config_file,
NULL, 0, 0,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_SSL_DHKEY_SIZE:
new_option = weechat_config_new_option (
@@ -1678,9 +1624,13 @@ irc_config_server_new_option (struct t_config_file *config_file,
NULL, 0, INT_MAX,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_SSL_FINGERPRINT:
new_option = weechat_config_new_option (
@@ -1696,9 +1646,13 @@ irc_config_server_new_option (struct t_config_file *config_file,
NULL, 0, 0,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_SSL_VERIFY:
new_option = weechat_config_new_option (
@@ -1708,9 +1662,13 @@ irc_config_server_new_option (struct t_config_file *config_file,
NULL, 0, 0,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_PASSWORD:
new_option = weechat_config_new_option (
@@ -1721,9 +1679,13 @@ irc_config_server_new_option (struct t_config_file *config_file,
NULL, 0, 0,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_CAPABILITIES:
new_option = weechat_config_new_option (
@@ -1731,16 +1693,19 @@ irc_config_server_new_option (struct t_config_file *config_file,
option_name, "string",
/* TRANSLATORS: please keep words "client capabilities" between brackets if translation is different (see fr.po) */
N_("comma-separated list of client capabilities to enable for "
- "server if they are available; capabilities supported by "
- "WeeChat are: account-notify, away-notify, extended-join, "
- "multi-prefix, server-time, userhost-in-names (example: "
- "\"away-notify,multi-prefix\")"),
+ "server if they are available (see /help cap for a list of "
+ "capabilities supported by WeeChat) "
+ "(example: \"away-notify,multi-prefix\")"),
NULL, 0, 0,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_SASL_MECHANISM:
new_option = weechat_config_new_option (
@@ -1760,9 +1725,13 @@ irc_config_server_new_option (struct t_config_file *config_file,
0, 0,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_SASL_USERNAME:
new_option = weechat_config_new_option (
@@ -1774,9 +1743,13 @@ irc_config_server_new_option (struct t_config_file *config_file,
NULL, 0, 0,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_SASL_PASSWORD:
new_option = weechat_config_new_option (
@@ -1789,9 +1762,13 @@ irc_config_server_new_option (struct t_config_file *config_file,
NULL, 0, 0,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_SASL_KEY:
new_option = weechat_config_new_option (
@@ -1804,9 +1781,13 @@ irc_config_server_new_option (struct t_config_file *config_file,
NULL, 0, 0,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_SASL_TIMEOUT:
new_option = weechat_config_new_option (
@@ -1817,9 +1798,13 @@ irc_config_server_new_option (struct t_config_file *config_file,
NULL, 1, 3600,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_SASL_FAIL:
new_option = weechat_config_new_option (
@@ -1828,13 +1813,18 @@ irc_config_server_new_option (struct t_config_file *config_file,
N_("action to perform if SASL authentication fails: "
"\"continue\" to ignore the authentication problem, "
"\"reconnect\" to schedule a reconnection to the server, "
- "\"disconnect\" to disconnect from server"),
+ "\"disconnect\" to disconnect from server "
+ "(see also option irc.network.sasl_fail_unavailable)"),
"continue|reconnect|disconnect", 0, 0,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_AUTOCONNECT:
new_option = weechat_config_new_option (
@@ -1844,9 +1834,13 @@ irc_config_server_new_option (struct t_config_file *config_file,
NULL, 0, 0,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_AUTORECONNECT:
new_option = weechat_config_new_option (
@@ -1856,9 +1850,13 @@ irc_config_server_new_option (struct t_config_file *config_file,
NULL, 0, 0,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_AUTORECONNECT_DELAY:
new_option = weechat_config_new_option (
@@ -1869,9 +1867,13 @@ irc_config_server_new_option (struct t_config_file *config_file,
NULL, 1, 65535,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_NICKS:
new_option = weechat_config_new_option (
@@ -1882,9 +1884,33 @@ irc_config_server_new_option (struct t_config_file *config_file,
NULL, 0, 0,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
+ break;
+ case IRC_SERVER_OPTION_NICKS_ALTERNATE:
+ new_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "boolean",
+ N_("get an alternate nick when all the declared nicks are "
+ "already used on server: add some \"_\" until the nick has "
+ "a length of 9, and then replace last char (or the two "
+ "last chars) by a number from 1 to 99, until we find "
+ "a nick not used on server"),
+ NULL, 0, 0,
+ default_value, value,
+ null_value_allowed,
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_USERNAME:
new_option = weechat_config_new_option (
@@ -1895,9 +1921,13 @@ irc_config_server_new_option (struct t_config_file *config_file,
NULL, 0, 0,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_REALNAME:
new_option = weechat_config_new_option (
@@ -1908,9 +1938,13 @@ irc_config_server_new_option (struct t_config_file *config_file,
NULL, 0, 0,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_LOCAL_HOSTNAME:
new_option = weechat_config_new_option (
@@ -1921,9 +1955,13 @@ irc_config_server_new_option (struct t_config_file *config_file,
NULL, 0, 0,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_COMMAND:
new_option = weechat_config_new_option (
@@ -1937,9 +1975,13 @@ irc_config_server_new_option (struct t_config_file *config_file,
NULL, 0, 0,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_COMMAND_DELAY:
new_option = weechat_config_new_option (
@@ -1951,9 +1993,13 @@ irc_config_server_new_option (struct t_config_file *config_file,
NULL, 0, 3600,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_AUTOJOIN:
new_option = weechat_config_new_option (
@@ -1970,9 +2016,13 @@ irc_config_server_new_option (struct t_config_file *config_file,
NULL, 0, 0,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_AUTOREJOIN:
new_option = weechat_config_new_option (
@@ -1985,9 +2035,13 @@ irc_config_server_new_option (struct t_config_file *config_file,
NULL, 0, 0,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_AUTOREJOIN_DELAY:
new_option = weechat_config_new_option (
@@ -1997,9 +2051,13 @@ irc_config_server_new_option (struct t_config_file *config_file,
NULL, 0, 3600*24,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_CONNECTION_TIMEOUT:
new_option = weechat_config_new_option (
@@ -2012,9 +2070,13 @@ irc_config_server_new_option (struct t_config_file *config_file,
NULL, 1, 3600,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_HIGH:
new_option = weechat_config_new_option (
@@ -2026,9 +2088,13 @@ irc_config_server_new_option (struct t_config_file *config_file,
NULL, 0, 60,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_LOW:
new_option = weechat_config_new_option (
@@ -2040,9 +2106,13 @@ irc_config_server_new_option (struct t_config_file *config_file,
NULL, 0, 60,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_AWAY_CHECK:
new_option = weechat_config_new_option (
@@ -2053,9 +2123,13 @@ irc_config_server_new_option (struct t_config_file *config_file,
NULL, 0, 60 * 24 * 7,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS:
new_option = weechat_config_new_option (
@@ -2066,49 +2140,73 @@ irc_config_server_new_option (struct t_config_file *config_file,
NULL, 0, 1000000,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
- case IRC_SERVER_OPTION_DEFAULT_MSG_KICK:
+ case IRC_SERVER_OPTION_MSG_KICK:
new_option = weechat_config_new_option (
config_file, section,
option_name, "string",
N_("default kick message used by commands \"/kick\" and "
- "\"/kickban\" (special variables $nick, $channel and $server "
- "are replaced by their value)"),
+ "\"/kickban\" "
+ "(note: content is evaluated, see /help eval; special "
+ "variables ${nick}, ${channel} and ${server} are replaced "
+ "by their value)"),
NULL, 0, 0,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
- case IRC_SERVER_OPTION_DEFAULT_MSG_PART:
+ case IRC_SERVER_OPTION_MSG_PART:
new_option = weechat_config_new_option (
config_file, section,
option_name, "string",
- N_("default part message (leaving channel) (\"%v\" will be "
- "replaced by WeeChat version in string)"),
+ N_("default part message (leaving channel) "
+ "(note: content is evaluated, see /help eval; special "
+ "variables ${nick}, ${channel} and ${server} are replaced "
+ "by their value; \"%v\" is replaced by WeeChat version if "
+ "there is no ${...} in string)"),
NULL, 0, 0,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
- case IRC_SERVER_OPTION_DEFAULT_MSG_QUIT:
+ case IRC_SERVER_OPTION_MSG_QUIT:
new_option = weechat_config_new_option (
config_file, section,
option_name, "string",
- N_("default quit message (disconnecting from server) (\"%v\" "
- "will be replaced by WeeChat version in string)"),
+ N_("default quit message (disconnecting from server) "
+ "(note: content is evaluated, see /help eval; special "
+ "variables ${nick}, ${channel} and ${server} are replaced "
+ "by their value; \"%v\" is replaced by WeeChat version if "
+ "there is no ${...} in string)"),
NULL, 0, 0,
default_value, value,
null_value_allowed,
- callback_check_value, callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_check_value,
+ callback_check_value_pointer,
+ callback_check_value_data,
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_NOTIFY:
new_option = weechat_config_new_option (
@@ -2121,9 +2219,12 @@ irc_config_server_new_option (struct t_config_file *config_file,
null_value_allowed,
(section == irc_config_section_server_default) ?
&irc_config_server_default_check_notify : callback_check_value,
+ callback_check_value_pointer,
callback_check_value_data,
- callback_change, callback_change_data,
- NULL, NULL);
+ callback_change,
+ callback_change_pointer,
+ callback_change_data,
+ NULL, NULL, NULL);
break;
case IRC_SERVER_NUM_OPTIONS:
break;
@@ -2137,7 +2238,8 @@ irc_config_server_new_option (struct t_config_file *config_file,
*/
int
-irc_config_server_read_cb (void *data, struct t_config_file *config_file,
+irc_config_server_read_cb (const void *pointer, void *data,
+ struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name, const char *value)
{
@@ -2146,6 +2248,7 @@ irc_config_server_read_cb (void *data, struct t_config_file *config_file,
char *pos_option, *server_name;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) config_file;
(void) section;
@@ -2213,13 +2316,15 @@ irc_config_server_read_cb (void *data, struct t_config_file *config_file,
*/
int
-irc_config_server_write_cb (void *data, struct t_config_file *config_file,
+irc_config_server_write_cb (const void *pointer, void *data,
+ struct t_config_file *config_file,
const char *section_name)
{
struct t_irc_server *ptr_server;
int i;
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (!weechat_config_write_line (config_file, section_name, NULL))
@@ -2308,8 +2413,10 @@ irc_config_server_create_default_options (struct t_config_section *section)
0,
&irc_config_server_check_value_cb,
irc_server_options[i][0],
+ NULL,
&irc_config_server_default_change_cb,
- irc_server_options[i][0]);
+ irc_server_options[i][0],
+ NULL);
}
if (nicks)
@@ -2337,38 +2444,31 @@ irc_config_init ()
32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
- irc_config_hashtable_nick_color_force = weechat_hashtable_new (
- 32,
- WEECHAT_HASHTABLE_STRING,
- WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
irc_config_hashtable_nick_prefixes = weechat_hashtable_new (
32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
irc_config_hashtable_color_mirc_remap = weechat_hashtable_new (
32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
irc_config_file = weechat_config_new (IRC_CONFIG_NAME,
- &irc_config_reload, NULL);
+ &irc_config_reload, NULL, NULL);
if (!irc_config_file)
return 0;
/* look */
ptr_section = weechat_config_new_section (irc_config_file, "look",
0, 0,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (irc_config_file);
@@ -2382,104 +2482,108 @@ irc_config_init ()
"when it is auto joined (with server option \"autojoin\"); "
"this is useful to open channels with always the same buffer "
"numbers on startup"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_buffer_open_before_join = weechat_config_new_option (
irc_config_file, ptr_section,
"buffer_open_before_join", "boolean",
N_("open channel buffer before the JOIN is received from server "
"when it is manually joined (with /join command)"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_buffer_switch_autojoin = weechat_config_new_option (
irc_config_file, ptr_section,
"buffer_switch_autojoin", "boolean",
N_("auto switch to channel buffer when it is auto joined (with "
"server option \"autojoin\")"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_buffer_switch_join = weechat_config_new_option (
irc_config_file, ptr_section,
"buffer_switch_join", "boolean",
N_("auto switch to channel buffer when it is manually joined "
"(with /join command)"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_color_nicks_in_names = weechat_config_new_option (
irc_config_file, ptr_section,
"color_nicks_in_names", "boolean",
N_("use nick color in output of /names (or list of nicks displayed "
"when joining a channel)"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_color_nicks_in_nicklist = weechat_config_new_option (
irc_config_file, ptr_section,
"color_nicks_in_nicklist", "boolean",
N_("use nick color in nicklist"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL,
- &irc_config_change_look_color_nicks_in_nicklist, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL,
+ &irc_config_change_look_color_nicks_in_nicklist, NULL, NULL,
+ NULL, NULL, NULL);
irc_config_look_color_nicks_in_server_messages = weechat_config_new_option (
irc_config_file, ptr_section,
"color_nicks_in_server_messages", "boolean",
N_("use nick color in messages from server"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_color_pv_nick_like_channel = weechat_config_new_option (
irc_config_file, ptr_section,
"color_pv_nick_like_channel", "boolean",
N_("use same nick color for channel and private"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_ctcp_time_format = weechat_config_new_option (
irc_config_file, ptr_section,
"ctcp_time_format", "string",
N_("time format used in answer to message CTCP TIME (see man strftime "
"for date/time specifiers)"),
- NULL, 0, 0, "%a, %d %b %Y %T %z", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "%a, %d %b %Y %T %z", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_display_away = weechat_config_new_option (
irc_config_file, ptr_section,
"display_away", "integer",
N_("display message when (un)marking as away (off: do not display/send "
"anything, local: display locally, channel: send action to channels)"),
- "off|local|channel", 0, 0, "local", NULL, 0, NULL, NULL,
- &irc_config_change_look_display_away, NULL,
- NULL, NULL);
+ "off|local|channel", 0, 0, "local", NULL, 0,
+ NULL, NULL, NULL,
+ &irc_config_change_look_display_away, NULL, NULL,
+ NULL, NULL, NULL);
irc_config_look_display_ctcp_blocked = weechat_config_new_option (
irc_config_file, ptr_section,
"display_ctcp_blocked", "boolean",
N_("display CTCP message even if it is blocked"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_display_ctcp_reply = weechat_config_new_option (
irc_config_file, ptr_section,
"display_ctcp_reply", "boolean",
N_("display CTCP reply sent by WeeChat"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_display_ctcp_unknown = weechat_config_new_option (
irc_config_file, ptr_section,
"display_ctcp_unknown", "boolean",
N_("display CTCP message even if it is unknown CTCP"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_display_host_join = weechat_config_new_option (
irc_config_file, ptr_section,
"display_host_join", "boolean",
N_("display host in join messages"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_display_host_join_local = weechat_config_new_option (
irc_config_file, ptr_section,
"display_host_join_local", "boolean",
N_("display host in join messages from local client"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_display_host_quit = weechat_config_new_option (
irc_config_file, ptr_section,
"display_host_quit", "boolean",
N_("display host in part/quit messages"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_display_join_message = weechat_config_new_option (
irc_config_file, ptr_section,
"display_join_message", "string",
@@ -2487,25 +2591,29 @@ irc_config_init ()
"channel: 324 = channel modes, 329 = channel creation date, "
"332 = topic, 333 = nick/date for topic, 353 = names on channel, "
"366 = names count"),
- NULL, 0, 0, "329,332,333,366", NULL, 0, NULL, NULL,
- &irc_config_change_look_display_join_message, NULL, NULL, NULL);
+ NULL, 0, 0, "329,332,333,366", NULL, 0,
+ NULL, NULL, NULL,
+ &irc_config_change_look_display_join_message, NULL, NULL,
+ NULL, NULL, NULL);
irc_config_look_display_old_topic = weechat_config_new_option (
irc_config_file, ptr_section,
"display_old_topic", "boolean",
N_("display old topic when channel topic is changed"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_display_pv_away_once = weechat_config_new_option (
irc_config_file, ptr_section,
"display_pv_away_once", "boolean",
N_("display remote away message only once in private"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_display_pv_back = weechat_config_new_option (
irc_config_file, ptr_section,
"display_pv_back", "boolean",
N_("display a message in private when user is back (after quit on "
"server)"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_highlight_channel = weechat_config_new_option (
irc_config_file, ptr_section,
"highlight_channel", "string",
@@ -2516,7 +2624,8 @@ irc_config_init ()
"buffer property \"highlight_words\" only when buffer is created "
"(it does not affect current buffers), an empty string disables "
"default highlight on nick, examples: \"$nick\", \"(?-i)$nick\""),
- NULL, 0, 0, "$nick", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "$nick", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_highlight_pv = weechat_config_new_option (
irc_config_file, ptr_section,
"highlight_pv", "string",
@@ -2527,7 +2636,8 @@ irc_config_init ()
"buffer property \"highlight_words\" only when buffer is created "
"(it does not affect current buffers), an empty string disables "
"default highlight on nick, examples: \"$nick\", \"(?-i)$nick\""),
- NULL, 0, 0, "$nick", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "$nick", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_highlight_server = weechat_config_new_option (
irc_config_file, ptr_section,
"highlight_server", "string",
@@ -2538,7 +2648,8 @@ irc_config_init ()
"buffer property \"highlight_words\" only when buffer is created "
"(it does not affect current buffers), an empty string disables "
"default highlight on nick, examples: \"$nick\", \"(?-i)$nick\""),
- NULL, 0, 0, "$nick", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "$nick", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_highlight_tags_restrict = weechat_config_new_option (
irc_config_file, ptr_section,
"highlight_tags_restrict", "string",
@@ -2547,14 +2658,10 @@ irc_config_init ()
"must be separated by a comma and \"+\" can be used to make a "
"logical \"and\" between tags; wildcard \"*\" is allowed in tags; "
"an empty value allows highlight on any tag"),
- NULL, 0, 0, "irc_privmsg,irc_notice", NULL, 0, NULL, NULL,
- &irc_config_change_look_highlight_tags_restrict, NULL, NULL, NULL);
- irc_config_look_item_away_message = weechat_config_new_option (
- irc_config_file, ptr_section,
- "item_away_message", "boolean",
- N_("display server away message in away bar item"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL,
- &irc_config_change_look_item_away_message, NULL, NULL, NULL);
+ NULL, 0, 0, "irc_privmsg,irc_notice", NULL, 0,
+ NULL, NULL, NULL,
+ &irc_config_change_look_highlight_tags_restrict, NULL, NULL,
+ NULL, NULL, NULL);
irc_config_look_item_channel_modes_hide_args = weechat_config_new_option (
irc_config_file, ptr_section,
"item_channel_modes_hide_args", "string",
@@ -2562,26 +2669,34 @@ irc_config_init ()
"channel modes (\"*\" to always hide all arguments, empty value to "
"never hide arguments); example: \"kf\" to hide arguments if \"k\" "
"or \"f\" are in channel modes"),
- NULL, 0, 0, "k", NULL, 0, NULL, NULL,
- &irc_config_change_look_item_channel_modes_hide_args, NULL, NULL, NULL);
+ NULL, 0, 0, "k", NULL, 0,
+ NULL, NULL, NULL,
+ &irc_config_change_look_item_channel_modes_hide_args, NULL, NULL,
+ NULL, NULL, NULL);
irc_config_look_item_display_server = weechat_config_new_option (
irc_config_file, ptr_section,
"item_display_server", "integer",
N_("name of bar item where IRC server is displayed (for status bar)"),
- "buffer_plugin|buffer_name", 0, 0, "buffer_plugin", NULL, 0, NULL, NULL,
- &irc_config_change_look_item_display_server, NULL, NULL, NULL);
+ "buffer_plugin|buffer_name", 0, 0, "buffer_plugin", NULL, 0,
+ NULL, NULL, NULL,
+ &irc_config_change_look_item_display_server, NULL, NULL,
+ NULL, NULL, NULL);
irc_config_look_item_nick_modes = weechat_config_new_option (
irc_config_file, ptr_section,
"item_nick_modes", "boolean",
N_("display nick modes in bar item \"input_prompt\""),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL,
- &irc_config_change_bar_item_input_prompt, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL,
+ &irc_config_change_bar_item_input_prompt, NULL, NULL,
+ NULL, NULL, NULL);
irc_config_look_item_nick_prefix = weechat_config_new_option (
irc_config_file, ptr_section,
"item_nick_prefix", "boolean",
N_("display nick prefix in bar item \"input_prompt\""),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL,
- &irc_config_change_bar_item_input_prompt, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL,
+ &irc_config_change_bar_item_input_prompt, NULL, NULL,
+ NULL, NULL, NULL);
irc_config_look_join_auto_add_chantype = weechat_config_new_option (
irc_config_file, ptr_section,
"join_auto_add_chantype", "boolean",
@@ -2589,15 +2704,15 @@ irc_config_init ()
"command /join if the channel name does not start with a valid "
"channel type for the server; for example: \"/join weechat\" will "
"in fact send: \"/join #weechat\""),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_msgbuffer_fallback = weechat_config_new_option (
irc_config_file, ptr_section,
"msgbuffer_fallback", "integer",
N_("default target buffer for msgbuffer options when target is "
"private and that private buffer is not found"),
- "current|server", 0, 0, "current", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ "current|server", 0, 0, "current", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_new_channel_position = weechat_config_new_option (
irc_config_file, ptr_section,
"new_channel_position", "integer",
@@ -2605,8 +2720,8 @@ irc_config_init ()
"(none = default position (should be last buffer), "
"next = current buffer + 1, near_server = after last channel/pv "
"of server)"),
- "none|next|near_server", 0, 0, "none",
- NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ "none|next|near_server", 0, 0, "none", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_new_pv_position = weechat_config_new_option (
irc_config_file, ptr_section,
"new_pv_position", "integer",
@@ -2614,58 +2729,33 @@ irc_config_init ()
"(none = default position (should be last buffer), "
"next = current buffer + 1, near_server = after last channel/pv "
"of server)"),
- "none|next|near_server", 0, 0, "none",
- NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
- irc_config_look_nick_color_force = weechat_config_new_option (
- irc_config_file, ptr_section,
- "nick_color_force", "string",
- N_("force color for some nicks: hash computed with nickname "
- "to find color will not be used for these nicks (format is: "
- "\"nick1:color1;nick2:color2\"); look up for nicks is with "
- "exact case then lower case, so it's possible to use only lower "
- "case for nicks in this option"),
- NULL, 0, 0, "", NULL, 0, NULL, NULL,
- &irc_config_change_look_nick_color_force, NULL, NULL, NULL);
- irc_config_look_nick_color_hash = weechat_config_new_option (
- irc_config_file, ptr_section,
- "nick_color_hash", "integer",
- N_("hash algorithm used to find the color for a nick: djb2 = variant "
- "of djb2 (position of letters matters: anagrams of a nick have "
- "different color), sum = sum of letters"),
- "djb2|sum", 0, 0, "sum", NULL, 0, NULL, NULL,
- &irc_config_change_look_nick_colors, NULL, NULL, NULL);
- irc_config_look_nick_color_stop_chars = weechat_config_new_option (
- irc_config_file, ptr_section,
- "nick_color_stop_chars", "string",
- N_("chars used to stop in nick when computing color with letters of "
- "nick (at least one char outside this list must be in string before "
- "stopping) (example: nick \"|nick|away\" with \"|\" in chars will "
- "return color of nick \"|nick\")"),
- NULL, 0, 0, "_|[", NULL, 0, NULL, NULL,
- &irc_config_change_look_nick_colors, NULL, NULL, NULL);
+ "none|next|near_server", 0, 0, "none", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_nick_completion_smart = weechat_config_new_option (
irc_config_file, ptr_section,
"nick_completion_smart", "integer",
N_("smart completion for nicks (completes first with last speakers): "
"speakers = all speakers (including highlights), "
"speakers_highlights = only speakers with highlight"),
- "off|speakers|speakers_highlights", 0, 0, "speakers", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ "off|speakers|speakers_highlights", 0, 0, "speakers", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_nick_mode = weechat_config_new_option (
irc_config_file, ptr_section,
"nick_mode", "integer",
N_("display nick mode (op, voice, ...) before nick (none = never, "
"prefix = in prefix only (default), action = in action messages "
"only, both = prefix + action messages)"),
- "none|prefix|action|both", 0, 0, "prefix",
- NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ "none|prefix|action|both", 0, 0, "prefix", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_nick_mode_empty = weechat_config_new_option (
irc_config_file, ptr_section,
"nick_mode_empty", "boolean",
N_("display a space if nick mode is enabled but nick has no mode (not "
"op, voice, ...)"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL,
- &irc_config_change_bar_item_input_prompt, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL,
+ &irc_config_change_bar_item_input_prompt, NULL, NULL,
+ NULL, NULL, NULL);
irc_config_look_nicks_hide_password = weechat_config_new_option (
irc_config_file, ptr_section,
"nicks_hide_password", "string",
@@ -2673,14 +2763,17 @@ irc_config_init ()
"when a message is sent, for example to hide password in message "
"displayed by \"/msg nickserv identify password\", example: "
"\"nickserv,nickbot\""),
- NULL, 0, 0, "nickserv", NULL, 0, NULL, NULL,
- &irc_config_change_look_nicks_hide_password, NULL, NULL, NULL);
+ NULL, 0, 0, "nickserv", NULL, 0,
+ NULL, NULL, NULL,
+ &irc_config_change_look_nicks_hide_password, NULL, NULL,
+ NULL, NULL, NULL);
irc_config_look_notice_as_pv = weechat_config_new_option (
irc_config_file, ptr_section,
"notice_as_pv", "integer",
N_("display notices as private messages (if auto, use private buffer "
"if found)"),
- "auto|never|always", 0, 0, "auto", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ "auto|never|always", 0, 0, "auto", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_notice_welcome_redirect = weechat_config_new_option (
irc_config_file, ptr_section,
"notice_welcome_redirect", "boolean",
@@ -2688,14 +2781,15 @@ irc_config_init ()
"buffer; such notices have the nick as target but a channel name in "
"beginning of notice message, for example notices sent by freenode "
"server which look like: \"[#channel] Welcome to this channel...\""),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_notice_welcome_tags = weechat_config_new_option (
irc_config_file, ptr_section,
"notice_welcome_tags", "string",
N_("comma separated list of tags used in a welcome notices redirected "
"to a channel, for example: \"notify_private\""),
- NULL, 0, 0, "", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_notify_tags_ison = weechat_config_new_option (
irc_config_file, ptr_section,
"notify_tags_ison", "string",
@@ -2703,8 +2797,8 @@ irc_config_init ()
"when a nick joins or quits server (result of command ison or "
"monitor), for example: \"notify_message\", \"notify_private\" or "
"\"notify_highlight\""),
- NULL, 0, 0, "notify_message", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "notify_message", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_notify_tags_whois = weechat_config_new_option (
irc_config_file, ptr_section,
"notify_tags_whois", "string",
@@ -2712,60 +2806,68 @@ irc_config_init ()
"when a nick away status changes (result of command whois), "
"for example: \"notify_message\", \"notify_private\" or "
"\"notify_highlight\""),
- NULL, 0, 0, "notify_message", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "notify_message", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_part_closes_buffer = weechat_config_new_option (
irc_config_file, ptr_section,
"part_closes_buffer", "boolean",
N_("close buffer when /part is issued on a channel"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_pv_buffer = weechat_config_new_option (
irc_config_file, ptr_section,
"pv_buffer", "integer",
N_("merge private buffers"),
- "independent|merge_by_server|merge_all", 0, 0, "independent",
- NULL, 0, NULL, NULL,
- &irc_config_change_look_pv_buffer, NULL, NULL, NULL);
+ "independent|merge_by_server|merge_all", 0, 0, "independent", NULL, 0,
+ NULL, NULL, NULL,
+ &irc_config_change_look_pv_buffer, NULL, NULL,
+ NULL, NULL, NULL);
irc_config_look_pv_tags = weechat_config_new_option (
irc_config_file, ptr_section,
"pv_tags", "string",
N_("comma separated list of tags used in private messages, for example: "
"\"notify_message\", \"notify_private\" or \"notify_highlight\""),
- NULL, 0, 0, "notify_private", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "notify_private", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_raw_messages = weechat_config_new_option (
irc_config_file, ptr_section,
"raw_messages", "integer",
N_("number of raw messages to save in memory when raw data buffer is "
"closed (messages will be displayed when opening raw data buffer)"),
- NULL, 0, 65535, "256", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 65535, "256", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_server_buffer = weechat_config_new_option (
irc_config_file, ptr_section,
"server_buffer", "integer",
N_("merge server buffers"),
"merge_with_core|merge_without_core|independent", 0, 0, "merge_with_core",
- NULL, 0, NULL, NULL,
- &irc_config_change_look_server_buffer, NULL, NULL, NULL);
+ NULL, 0,
+ NULL, NULL, NULL,
+ &irc_config_change_look_server_buffer, NULL, NULL,
+ NULL, NULL, NULL);
irc_config_look_smart_filter = weechat_config_new_option (
irc_config_file, ptr_section,
"smart_filter", "boolean",
N_("filter join/part/quit/nick messages for a nick if not speaking "
"for some minutes on channel (you must create a filter on tag "
"\"irc_smart_filter\")"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_smart_filter_delay = weechat_config_new_option (
irc_config_file, ptr_section,
"smart_filter_delay", "integer",
N_("delay for filtering join/part/quit messages (in minutes): if the "
"nick did not speak during the last N minutes, the join/part/quit is "
"filtered"),
- NULL, 1, 60*24*7, "5", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 1, 60*24*7, "5", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_smart_filter_join = weechat_config_new_option (
irc_config_file, ptr_section,
"smart_filter_join", "boolean",
/* TRANSLATORS: please do not translate "join" */
N_("enable smart filter for \"join\" messages"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_smart_filter_join_unmask = weechat_config_new_option (
irc_config_file, ptr_section,
"smart_filter_join_unmask", "integer",
@@ -2774,7 +2876,8 @@ irc_config_init ()
"minutes ago and then says something on channel (message, notice or "
"update on topic), the join is unmasked, as well as nick changes "
"after this join (0 = disable: never unmask a join)"),
- NULL, 0, 60*24*7, "30", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 60*24*7, "30", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_smart_filter_mode = weechat_config_new_option (
irc_config_file, ptr_section,
"smart_filter_mode", "string",
@@ -2784,38 +2887,46 @@ irc_config_init ()
"\"ovh\"), \"xyz\" to filter only modes x/y/z, \"-xyz\" to filter "
"all modes but not x/y/z; examples: \"ovh\": filter modes o/v/h, "
"\"-bkl\": filter all modes but not b/k/l"),
- NULL, 0, 0, "+", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "+", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_smart_filter_nick = weechat_config_new_option (
irc_config_file, ptr_section,
"smart_filter_nick", "boolean",
/* TRANSLATORS: please do not translate "nick" */
N_("enable smart filter for \"nick\" messages (nick changes)"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_smart_filter_quit = weechat_config_new_option (
irc_config_file, ptr_section,
"smart_filter_quit", "boolean",
/* TRANSLATORS: please do not translate "part" and "quit" */
N_("enable smart filter for \"part\" and \"quit\" messages"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_temporary_servers = weechat_config_new_option (
irc_config_file, ptr_section,
"temporary_servers", "boolean",
N_("enable automatic addition of temporary servers with command "
"/connect"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_topic_strip_colors = weechat_config_new_option (
irc_config_file, ptr_section,
"topic_strip_colors", "boolean",
N_("strip colors in topic (used only when displaying buffer title)"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL,
- &irc_config_change_look_topic_strip_colors, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL,
+ &irc_config_change_look_topic_strip_colors, NULL, NULL,
+ NULL, NULL, NULL);
/* color */
ptr_section = weechat_config_new_section (irc_config_file, "color",
0, 0,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (irc_config_file);
@@ -2826,51 +2937,55 @@ irc_config_init ()
irc_config_file, ptr_section,
"input_nick", "color",
N_("color for nick in input bar"),
- NULL, -1, 0, "lightcyan", NULL, 0, NULL, NULL,
- &irc_config_change_bar_item_input_prompt, NULL, NULL, NULL);
- irc_config_color_item_away = weechat_config_new_option (
- irc_config_file, ptr_section,
- "item_away", "color",
- N_("color for away item"),
- NULL, -1, 0, "yellow", NULL, 0, NULL, NULL,
- &irc_config_change_color_item_away, NULL, NULL, NULL);
+ NULL, -1, 0, "lightcyan", NULL, 0,
+ NULL, NULL, NULL,
+ &irc_config_change_bar_item_input_prompt, NULL, NULL,
+ NULL, NULL, NULL);
irc_config_color_item_channel_modes = weechat_config_new_option (
irc_config_file, ptr_section,
"item_channel_modes", "color",
N_("color for channel modes, near channel name"),
- NULL, -1, 0, "default", NULL, 0, NULL, NULL,
- &irc_config_change_color_item_channel_modes, NULL, NULL, NULL);
+ NULL, -1, 0, "default", NULL, 0,
+ NULL, NULL, NULL,
+ &irc_config_change_color_item_channel_modes, NULL, NULL,
+ NULL, NULL, NULL);
irc_config_color_item_lag_counting = weechat_config_new_option (
irc_config_file, ptr_section,
"item_lag_counting", "color",
N_("color for lag indicator, when counting (pong not received from "
"server, lag is increasing)"),
- NULL, -1, 0, "default", NULL, 0, NULL, NULL,
- &irc_config_change_color_item_lag, NULL, NULL, NULL);
+ NULL, -1, 0, "default", NULL, 0,
+ NULL, NULL, NULL,
+ &irc_config_change_color_item_lag, NULL, NULL,
+ NULL, NULL, NULL);
irc_config_color_item_lag_finished = weechat_config_new_option (
irc_config_file, ptr_section,
"item_lag_finished", "color",
N_("color for lag indicator, when pong has been received from server"),
- NULL, -1, 0, "yellow", NULL, 0, NULL, NULL,
- &irc_config_change_color_item_lag, NULL, NULL, NULL);
+ NULL, -1, 0, "yellow", NULL, 0,
+ NULL, NULL, NULL,
+ &irc_config_change_color_item_lag, NULL, NULL,
+ NULL, NULL, NULL);
irc_config_color_item_nick_modes = weechat_config_new_option (
irc_config_file, ptr_section,
"item_nick_modes", "color",
N_("color for nick modes in bar item \"input_prompt\""),
- NULL, -1, 0, "default", NULL, 0, NULL, NULL,
- &irc_config_change_color_item_nick_modes, NULL, NULL, NULL);
+ NULL, -1, 0, "default", NULL, 0,
+ NULL, NULL, NULL,
+ &irc_config_change_color_item_nick_modes, NULL, NULL,
+ NULL, NULL, NULL);
irc_config_color_message_join = weechat_config_new_option (
irc_config_file, ptr_section,
"message_join", "color",
N_("color for text in join messages"),
- NULL, -1, 0, "green", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, -1, 0, "green", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_color_message_quit = weechat_config_new_option (
irc_config_file, ptr_section,
"message_quit", "color",
N_("color for text in part/quit messages"),
- NULL, -1, 0, "red", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, -1, 0, "red", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_color_mirc_remap = weechat_config_new_option (
irc_config_file, ptr_section,
"mirc_remap", "string",
@@ -2884,8 +2999,10 @@ irc_config_init ()
"4=lightred, 5=red, 6=magenta, 7=brown, 8=yellow, 9=lightgreen, "
"10=cyan, 11=lightcyan, 12=lightblue, 13=lightmagenta, 14=gray, "
"15=white"),
- NULL, 0, 0, "1,-1:darkgray", NULL, 0, NULL, NULL,
- &irc_config_change_color_mirc_remap, NULL, NULL, NULL);
+ NULL, 0, 0, "1,-1:darkgray", NULL, 0,
+ NULL, NULL, NULL,
+ &irc_config_change_color_mirc_remap, NULL, NULL,
+ NULL, NULL, NULL);
irc_config_color_nick_prefixes = weechat_config_new_option (
irc_config_file, ptr_section,
"nick_prefixes", "string",
@@ -2894,74 +3011,70 @@ irc_config_init ()
"found, WeeChat will try with next modes received from server "
"(\"PREFIX\"); a special mode \"*\" can be used as default color "
"if no mode has been found in list)"),
- NULL, 0, 0, "q:lightred;a:lightcyan;o:lightgreen;h:lightmagenta;"
- "v:yellow;*:lightblue", NULL, 0, NULL, NULL,
- &irc_config_change_color_nick_prefixes, NULL, NULL, NULL);
+ NULL, 0, 0, "y:lightred;q:lightred;a:lightcyan;o:lightgreen;"
+ "h:lightmagenta;v:yellow;*:lightblue", NULL, 0,
+ NULL, NULL, NULL,
+ &irc_config_change_color_nick_prefixes, NULL, NULL,
+ NULL, NULL, NULL);
irc_config_color_notice = weechat_config_new_option (
irc_config_file, ptr_section,
"notice", "color",
N_("color for text \"Notice\" in notices"),
- NULL, -1, 0, "green", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, -1, 0, "green", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_color_reason_quit = weechat_config_new_option (
irc_config_file, ptr_section,
"reason_quit", "color",
N_("color for reason in part/quit messages"),
- NULL, -1, 0, "default", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, -1, 0, "default", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_color_topic_current = weechat_config_new_option (
irc_config_file, ptr_section,
"topic_current", "color",
N_("color for current channel topic (when joining a channel or "
"using /topic)"),
- NULL, -1, 0, "default", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, -1, 0, "default", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_color_topic_new = weechat_config_new_option (
irc_config_file, ptr_section,
"topic_new", "color",
N_("color for new channel topic (when topic is changed)"),
- NULL, -1, 0, "white", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, -1, 0, "white", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_color_topic_old = weechat_config_new_option (
irc_config_file, ptr_section,
"topic_old", "color",
N_("color for old channel topic (when topic is changed)"),
- NULL, -1, 0, "default", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, -1, 0, "default", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
/* network */
ptr_section = weechat_config_new_section (irc_config_file, "network",
0, 0,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (irc_config_file);
return 0;
}
- irc_config_network_alternate_nick = weechat_config_new_option (
- irc_config_file, ptr_section,
- "alternate_nick", "boolean",
- N_("get an alternate nick when the nick is already used on server: add "
- "some \"_\" until the nick has a length of 9, and then replace last "
- "char (or the two last chars) by a number from 1 to 99, until we "
- "find a nick not used on server"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_network_autoreconnect_delay_growing = weechat_config_new_option (
irc_config_file, ptr_section,
"autoreconnect_delay_growing", "integer",
N_("growing factor for autoreconnect delay to server (1 = always same "
"delay, 2 = delay*2 for each retry, ..)"),
- NULL, 1, 100, "2", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, 1, 100, "2", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_network_autoreconnect_delay_max = weechat_config_new_option (
irc_config_file, ptr_section,
"autoreconnect_delay_max", "integer",
N_("maximum autoreconnect delay to server (in seconds, 0 = no maximum)"),
- NULL, 0, 3600 * 24 * 7, "600", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, 0, 3600 * 24 * 7, "600", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_network_ban_mask_default = weechat_config_new_option (
irc_config_file, ptr_section,
"ban_mask_default", "string",
@@ -2970,8 +3083,8 @@ irc_config_init ()
"(extracted from \"nick!user@host\"); $ident is the same as $user if "
"$user does not start with \"~\", otherwise it is set to \"*\"; this "
"default mask is used only if WeeChat knows the host for the nick"),
- NULL, 0, 0, "*!$ident@$host", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "*!$ident@$host", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_network_channel_encode = weechat_config_new_option (
irc_config_file, ptr_section,
"channel_encode", "boolean",
@@ -2979,89 +3092,115 @@ irc_config_init ()
"it is recommended to keep that off if you use only UTF-8 in "
"channel names; you can enable this option if you are using an "
"exotic charset like ISO in channel names"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_network_colors_receive = weechat_config_new_option (
irc_config_file, ptr_section,
"colors_receive", "boolean",
N_("when off, colors codes are ignored in incoming messages"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_network_colors_send = weechat_config_new_option (
irc_config_file, ptr_section,
"colors_send", "boolean",
N_("allow user to send colors with special codes (ctrl-c + a code and "
"optional color: b=bold, cxx=color, cxx,yy=color+background, "
"i=italic, o=disable color/attributes, r=reverse, u=underline)"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_network_lag_check = weechat_config_new_option (
irc_config_file, ptr_section,
"lag_check", "integer",
N_("interval between two checks for lag (in seconds, 0 = never "
"check)"),
- NULL, 0, 3600 * 24 * 7, "60", NULL, 0, NULL, NULL,
- &irc_config_change_network_lag_check, NULL, NULL, NULL);
+ NULL, 0, 3600 * 24 * 7, "60", NULL, 0,
+ NULL, NULL, NULL,
+ &irc_config_change_network_lag_check, NULL, NULL,
+ NULL, NULL, NULL);
irc_config_network_lag_max = weechat_config_new_option (
irc_config_file, ptr_section,
"lag_max", "integer",
N_("maximum lag (in seconds): if this lag is reached, WeeChat will "
"consider that the answer from server (pong) will never be received "
"and will give up counting the lag (0 = never give up)"),
- NULL, 0, 3600 * 24 * 7, "1800", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, 0, 3600 * 24 * 7, "1800", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_network_lag_min_show = weechat_config_new_option (
irc_config_file, ptr_section,
"lag_min_show", "integer",
N_("minimum lag to show (in milliseconds)"),
- NULL, 0, 1000 * 3600 * 24, "500", NULL, 0, NULL, NULL,
- &irc_config_change_network_lag_min_show, NULL, NULL, NULL);
+ NULL, 0, 1000 * 3600 * 24, "500", NULL, 0,
+ NULL, NULL, NULL,
+ &irc_config_change_network_lag_min_show, NULL, NULL,
+ NULL, NULL, NULL);
irc_config_network_lag_reconnect = weechat_config_new_option (
irc_config_file, ptr_section,
"lag_reconnect", "integer",
N_("reconnect to server if lag is greater than or equal to this value "
"(in seconds, 0 = never reconnect); this value must be less than or "
"equal to irc.network.lag_max"),
- NULL, 0, 3600 * 24 * 7, "0", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, 0, 3600 * 24 * 7, "0", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_network_lag_refresh_interval = weechat_config_new_option (
irc_config_file, ptr_section,
"lag_refresh_interval", "integer",
N_("interval between two refreshs of lag item, when lag is increasing "
"(in seconds)"),
- NULL, 1, 3600, "1", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 1, 3600, "1", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_network_notify_check_ison = weechat_config_new_option (
irc_config_file, ptr_section,
"notify_check_ison", "integer",
N_("interval between two checks for notify with IRC command \"ison\" "
"(in minutes)"),
- NULL, 1, 60 * 24 * 7, "1", NULL, 0, NULL, NULL,
- &irc_config_change_network_notify_check_ison, NULL, NULL, NULL);
+ NULL, 1, 60 * 24 * 7, "1", NULL, 0,
+ NULL, NULL, NULL,
+ &irc_config_change_network_notify_check_ison, NULL, NULL,
+ NULL, NULL, NULL);
irc_config_network_notify_check_whois = weechat_config_new_option (
irc_config_file, ptr_section,
"notify_check_whois", "integer",
N_("interval between two checks for notify with IRC command \"whois\" "
"(in minutes)"),
- NULL, 1, 60 * 24 * 7, "5", NULL, 0, NULL, NULL,
- &irc_config_change_network_notify_check_whois, NULL, NULL, NULL);
+ NULL, 1, 60 * 24 * 7, "5", NULL, 0,
+ NULL, NULL, NULL,
+ &irc_config_change_network_notify_check_whois, NULL, NULL,
+ NULL, NULL, NULL);
+ irc_config_network_sasl_fail_unavailable = weechat_config_new_option (
+ irc_config_file, ptr_section,
+ "sasl_fail_unavailable", "boolean",
+ N_("cause SASL authentication failure when SASL is requested but "
+ "unavailable on the server; when this option is enabled, it has "
+ "effect only if option \"sasl_fail\" is set to \"reconnect\" or "
+ "\"disconnect\" in the server"),
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_network_send_unknown_commands = weechat_config_new_option (
irc_config_file, ptr_section,
"send_unknown_commands", "boolean",
N_("send unknown commands to server"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL,
- &irc_config_change_network_send_unknown_commands, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL,
+ &irc_config_change_network_send_unknown_commands, NULL, NULL,
+ NULL, NULL, NULL);
irc_config_network_whois_double_nick = weechat_config_new_option (
irc_config_file, ptr_section,
"whois_double_nick", "boolean",
N_("double the nick in /whois command (if only one nick is given), to "
"get idle time in answer; for example: \"/whois nick\" will send "
"\"whois nick nick\""),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
/* msgbuffer */
- ptr_section = weechat_config_new_section (irc_config_file, "msgbuffer",
- 1, 1,
- NULL, NULL, NULL, NULL,
- NULL, NULL,
- &irc_config_msgbuffer_create_option, NULL,
- NULL, NULL);
+ ptr_section = weechat_config_new_section (
+ irc_config_file, "msgbuffer",
+ 1, 1,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ &irc_config_msgbuffer_create_option, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (irc_config_file);
@@ -3070,12 +3209,14 @@ irc_config_init ()
irc_config_section_msgbuffer = ptr_section;
/* CTCP */
- ptr_section = weechat_config_new_section (irc_config_file, "ctcp",
- 1, 1,
- NULL, NULL, NULL, NULL,
- NULL, NULL,
- &irc_config_ctcp_create_option, NULL,
- NULL, NULL);
+ ptr_section = weechat_config_new_section (
+ irc_config_file, "ctcp",
+ 1, 1,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ &irc_config_ctcp_create_option, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (irc_config_file);
@@ -3084,12 +3225,14 @@ irc_config_init ()
irc_config_section_ctcp = ptr_section;
/* ignore */
- ptr_section = weechat_config_new_section (irc_config_file, "ignore",
- 0, 0,
- &irc_config_ignore_read_cb, NULL,
- &irc_config_ignore_write_cb, NULL,
- &irc_config_ignore_write_cb, NULL,
- NULL, NULL, NULL, NULL);
+ ptr_section = weechat_config_new_section (
+ irc_config_file, "ignore",
+ 0, 0,
+ &irc_config_ignore_read_cb, NULL, NULL,
+ &irc_config_ignore_write_cb, NULL, NULL,
+ &irc_config_ignore_write_cb, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (irc_config_file);
@@ -3097,11 +3240,14 @@ irc_config_init ()
}
/* server_default */
- ptr_section = weechat_config_new_section (irc_config_file, "server_default",
- 0, 0,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL);
+ ptr_section = weechat_config_new_section (
+ irc_config_file, "server_default",
+ 0, 0,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (irc_config_file);
@@ -3112,13 +3258,14 @@ irc_config_init ()
irc_config_server_create_default_options (ptr_section);
/* server */
- ptr_section = weechat_config_new_section (irc_config_file, "server",
- 0, 0,
- &irc_config_server_read_cb, NULL,
- &irc_config_server_write_cb, NULL,
- NULL, NULL,
- NULL, NULL,
- NULL, NULL);
+ ptr_section = weechat_config_new_section (
+ irc_config_file, "server",
+ 0, 0,
+ &irc_config_server_read_cb, NULL, NULL,
+ &irc_config_server_write_cb, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (irc_config_file);
@@ -3126,9 +3273,12 @@ irc_config_init ()
}
irc_config_section_server = ptr_section;
- irc_config_hook_config_nick_colors = weechat_hook_config (
+ irc_config_hook_config_nick_color_options = weechat_hook_config (
+ "weechat.look.nick_color_*",
+ &irc_config_change_nick_colors_cb, NULL, NULL);
+ irc_config_hook_config_chat_nick_colors = weechat_hook_config (
"weechat.color.chat_nick_colors",
- &irc_config_change_nick_colors_cb, NULL);
+ &irc_config_change_nick_colors_cb, NULL, NULL);
return 1;
}
@@ -3149,13 +3299,12 @@ irc_config_read ()
if (rc == WEECHAT_CONFIG_READ_OK)
{
irc_notify_new_for_all_servers ();
- irc_config_change_look_display_join_message (NULL, NULL);
- irc_config_change_look_nick_color_force (NULL, NULL);
- irc_config_change_look_nicks_hide_password (NULL, NULL);
- irc_config_change_color_nick_prefixes (NULL, NULL);
- irc_config_change_color_mirc_remap (NULL, NULL);
- irc_config_change_network_notify_check_ison (NULL, NULL);
- irc_config_change_network_notify_check_whois (NULL, NULL);
+ irc_config_change_look_display_join_message (NULL, NULL, NULL);
+ irc_config_change_look_nicks_hide_password (NULL, NULL, NULL);
+ irc_config_change_color_nick_prefixes (NULL, NULL, NULL);
+ irc_config_change_color_mirc_remap (NULL, NULL, NULL);
+ irc_config_change_network_notify_check_ison (NULL, NULL, NULL);
+ irc_config_change_network_notify_check_whois (NULL, NULL, NULL);
}
return rc;
@@ -3182,16 +3331,16 @@ irc_config_free ()
{
weechat_config_free (irc_config_file);
- if (irc_config_hook_config_nick_colors)
+ if (irc_config_hook_config_nick_color_options)
{
- weechat_unhook (irc_config_hook_config_nick_colors);
- irc_config_hook_config_nick_colors = NULL;
+ weechat_unhook (irc_config_hook_config_nick_color_options);
+ irc_config_hook_config_nick_color_options = NULL;
}
- if (irc_config_nick_colors)
+
+ if (irc_config_hook_config_chat_nick_colors)
{
- weechat_string_free_split (irc_config_nick_colors);
- irc_config_nick_colors = NULL;
- irc_config_num_nick_colors = 0;
+ weechat_unhook (irc_config_hook_config_chat_nick_colors);
+ irc_config_hook_config_chat_nick_colors = NULL;
}
if (irc_config_nicks_hide_password)
@@ -3207,12 +3356,6 @@ irc_config_free ()
irc_config_hashtable_display_join_message = NULL;
}
- if (irc_config_hashtable_nick_color_force)
- {
- weechat_hashtable_free (irc_config_hashtable_nick_color_force);
- irc_config_hashtable_nick_color_force = NULL;
- }
-
if (irc_config_hashtable_nick_prefixes)
{
weechat_hashtable_free (irc_config_hashtable_nick_prefixes);
diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h
index cd0a766b5..ca1f5b531 100644
--- a/src/plugins/irc/irc-config.h
+++ b/src/plugins/irc/irc-config.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -62,12 +62,6 @@ enum t_irc_config_look_notice_as_pv
IRC_CONFIG_LOOK_NOTICE_AS_PV_ALWAYS,
};
-enum t_irc_config_look_nick_color_hash
-{
- IRC_CONFIG_LOOK_NICK_COLOR_HASH_DJB2 = 0,
- IRC_CONFIG_LOOK_NICK_COLOR_HASH_SUM,
-};
-
enum t_irc_config_look_nick_mode
{
IRC_CONFIG_LOOK_NICK_MODE_NONE = 0,
@@ -120,7 +114,6 @@ extern struct t_config_option *irc_config_look_highlight_channel;
extern struct t_config_option *irc_config_look_highlight_pv;
extern struct t_config_option *irc_config_look_highlight_server;
extern struct t_config_option *irc_config_look_highlight_tags_restrict;
-extern struct t_config_option *irc_config_look_item_away_message;
extern struct t_config_option *irc_config_look_item_channel_modes_hide_args;
extern struct t_config_option *irc_config_look_item_display_server;
extern struct t_config_option *irc_config_look_item_nick_modes;
@@ -129,9 +122,6 @@ extern struct t_config_option *irc_config_look_join_auto_add_chantype;
extern struct t_config_option *irc_config_look_msgbuffer_fallback;
extern struct t_config_option *irc_config_look_new_channel_position;
extern struct t_config_option *irc_config_look_new_pv_position;
-extern struct t_config_option *irc_config_look_nick_color_force;
-extern struct t_config_option *irc_config_look_nick_color_hash;
-extern struct t_config_option *irc_config_look_nick_color_stop_chars;
extern struct t_config_option *irc_config_look_nick_completion_smart;
extern struct t_config_option *irc_config_look_nick_mode;
extern struct t_config_option *irc_config_look_nick_mode_empty;
@@ -157,7 +147,6 @@ extern struct t_config_option *irc_config_look_temporary_servers;
extern struct t_config_option *irc_config_look_topic_strip_colors;
extern struct t_config_option *irc_config_color_input_nick;
-extern struct t_config_option *irc_config_color_item_away;
extern struct t_config_option *irc_config_color_item_channel_modes;
extern struct t_config_option *irc_config_color_item_lag_counting;
extern struct t_config_option *irc_config_color_item_lag_finished;
@@ -172,7 +161,6 @@ extern struct t_config_option *irc_config_color_topic_current;
extern struct t_config_option *irc_config_color_topic_new;
extern struct t_config_option *irc_config_color_topic_old;
-extern struct t_config_option *irc_config_network_alternate_nick;
extern struct t_config_option *irc_config_network_autoreconnect_delay_growing;
extern struct t_config_option *irc_config_network_autoreconnect_delay_max;
extern struct t_config_option *irc_config_network_ban_mask_default;
@@ -186,27 +174,23 @@ extern struct t_config_option *irc_config_network_lag_reconnect;
extern struct t_config_option *irc_config_network_lag_refresh_interval;
extern struct t_config_option *irc_config_network_notify_check_ison;
extern struct t_config_option *irc_config_network_notify_check_whois;
+extern struct t_config_option *irc_config_network_sasl_fail_unavailable;
extern struct t_config_option *irc_config_network_send_unknown_commands;
extern struct t_config_option *irc_config_network_whois_double_nick;
extern struct t_config_option *irc_config_server_default[];
-extern char **irc_config_nick_colors;
-extern int irc_config_num_nick_colors;
-
extern struct t_hashtable *irc_config_hashtable_display_join_message;
-extern struct t_hashtable *irc_config_hashtable_nick_color_force;
extern struct t_hashtable *irc_config_hashtable_nick_prefixes;
extern struct t_hashtable *irc_config_hashtable_color_mirc_remap;
extern char **irc_config_nicks_hide_password;
extern int irc_config_num_nicks_hide_password;
-extern void irc_config_set_nick_colors ();
extern int irc_config_display_channel_modes_arguments (const char *modes);
-extern int irc_config_server_check_value_cb (void *data,
+extern int irc_config_server_check_value_cb (const void *pointer, void *data,
struct t_config_option *option,
const char *value);
-extern void irc_config_server_change_cb (void *data,
+extern void irc_config_server_change_cb (const void *pointer, void *data,
struct t_config_option *option);
struct t_config_option *irc_config_server_new_option (struct t_config_file *config_file,
struct t_config_section *section,
@@ -215,12 +199,16 @@ struct t_config_option *irc_config_server_new_option (struct t_config_file *conf
const char *default_value,
const char *value,
int null_value_allowed,
- int (*callback_check_value)(void *data,
+ int (*callback_check_value)(const void *pointer,
+ void *data,
struct t_config_option *option,
const char *value),
+ const void *callback_check_value_pointer,
void *callback_check_value_data,
- void (*callback_change)(void *data,
+ void (*callback_change)(const void *pointer,
+ void *data,
struct t_config_option *option),
+ const void *callback_change_pointer,
void *callback_change_data);
extern int irc_config_init ();
extern int irc_config_read ();
diff --git a/src/plugins/irc/irc-ctcp.c b/src/plugins/irc/irc-ctcp.c
index 55d7c6b2e..5f2aeec95 100644
--- a/src/plugins/irc/irc-ctcp.c
+++ b/src/plugins/irc/irc-ctcp.c
@@ -1,7 +1,7 @@
/*
* irc-ctcp.c - IRC CTCP protocol
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -291,10 +291,11 @@ irc_ctcp_reply_to_nick (struct t_irc_server *server,
str_args_color = irc_color_decode (str_args, 1);
if (!str_args_color)
break;
- weechat_printf_tags (
+ weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
server, nick, NULL, "ctcp",
(channel) ? channel->buffer : NULL),
+ 0,
irc_protocol_tags (
command,
"irc_ctcp,irc_ctcp_reply,notify_none,no_highlight",
diff --git a/src/plugins/irc/irc-ctcp.h b/src/plugins/irc/irc-ctcp.h
index 179f2ed21..0febcd0cc 100644
--- a/src/plugins/irc/irc-ctcp.h
+++ b/src/plugins/irc/irc-ctcp.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-debug.c b/src/plugins/irc/irc-debug.c
index ea33f0a37..22e1c255c 100644
--- a/src/plugins/irc/irc-debug.c
+++ b/src/plugins/irc/irc-debug.c
@@ -1,7 +1,7 @@
/*
* irc-debug.c - debug functions for IRC plugin
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -35,10 +35,12 @@
*/
int
-irc_debug_signal_debug_dump_cb (void *data, const char *signal,
+irc_debug_signal_debug_dump_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -69,5 +71,6 @@ irc_debug_signal_debug_dump_cb (void *data, const char *signal,
void
irc_debug_init ()
{
- weechat_hook_signal ("debug_dump", &irc_debug_signal_debug_dump_cb, NULL);
+ weechat_hook_signal ("debug_dump",
+ &irc_debug_signal_debug_dump_cb, NULL, NULL);
}
diff --git a/src/plugins/irc/irc-debug.h b/src/plugins/irc/irc-debug.h
index 199d9e7af..8daa12139 100644
--- a/src/plugins/irc/irc-debug.h
+++ b/src/plugins/irc/irc-debug.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-ignore.c b/src/plugins/irc/irc-ignore.c
index 2f18a4fea..0d69a9dfc 100644
--- a/src/plugins/irc/irc-ignore.c
+++ b/src/plugins/irc/irc-ignore.c
@@ -1,7 +1,7 @@
/*
* irc-ignore.c - ignore (nicks/hosts) management for IRC plugin
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -308,11 +308,13 @@ irc_ignore_free_all ()
*/
struct t_hdata *
-irc_ignore_hdata_ignore_cb (void *data, const char *hdata_name)
+irc_ignore_hdata_ignore_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = weechat_hdata_new (hdata_name, "prev_ignore", "next_ignore",
diff --git a/src/plugins/irc/irc-ignore.h b/src/plugins/irc/irc-ignore.h
index 70d37c85f..0c6335e49 100644
--- a/src/plugins/irc/irc-ignore.h
+++ b/src/plugins/irc/irc-ignore.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -51,7 +51,8 @@ extern int irc_ignore_check (struct t_irc_server *server,
const char *host);
extern void irc_ignore_free (struct t_irc_ignore *ignore);
extern void irc_ignore_free_all ();
-extern struct t_hdata *irc_ignore_hdata_ignore_cb (void *data,
+extern struct t_hdata *irc_ignore_hdata_ignore_cb (const void *pointer,
+ void *data,
const char *hdata_name);
extern int irc_ignore_add_to_infolist (struct t_infolist *infolist,
struct t_irc_ignore *ignore);
diff --git a/src/plugins/irc/irc-info.c b/src/plugins/irc/irc-info.c
index f905a6a4b..d4f75439d 100644
--- a/src/plugins/irc/irc-info.c
+++ b/src/plugins/irc/irc-info.c
@@ -1,7 +1,7 @@
/*
* irc-info.c - info, infolist and hdata hooks for IRC plugin
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -64,7 +64,8 @@ irc_info_create_string_with_pointer (char **string, void *pointer)
*/
const char *
-irc_info_info_irc_is_channel_cb (void *data, const char *info_name,
+irc_info_info_irc_is_channel_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
char *pos_comma, *server;
@@ -73,6 +74,7 @@ irc_info_info_irc_is_channel_cb (void *data, const char *info_name,
struct t_irc_server *ptr_server;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
@@ -99,12 +101,14 @@ irc_info_info_irc_is_channel_cb (void *data, const char *info_name,
*/
const char *
-irc_info_info_irc_is_nick_cb (void *data, const char *info_name,
+irc_info_info_irc_is_nick_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
static char str_true[2] = "1";
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
@@ -118,12 +122,14 @@ irc_info_info_irc_is_nick_cb (void *data, const char *info_name,
*/
const char *
-irc_info_info_irc_nick_cb (void *data, const char *info_name,
+irc_info_info_irc_nick_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
struct t_irc_server *ptr_server;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
@@ -142,10 +148,12 @@ irc_info_info_irc_nick_cb (void *data, const char *info_name,
*/
const char *
-irc_info_info_irc_nick_from_host_cb (void *data, const char *info_name,
+irc_info_info_irc_nick_from_host_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
@@ -158,10 +166,12 @@ irc_info_info_irc_nick_from_host_cb (void *data, const char *info_name,
*/
const char *
-irc_info_info_irc_nick_color_cb (void *data, const char *info_name,
+irc_info_info_irc_nick_color_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
@@ -174,10 +184,12 @@ irc_info_info_irc_nick_color_cb (void *data, const char *info_name,
*/
const char *
-irc_info_info_irc_nick_color_name_cb (void *data, const char *info_name,
+irc_info_info_irc_nick_color_name_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
@@ -190,7 +202,8 @@ irc_info_info_irc_nick_color_name_cb (void *data, const char *info_name,
*/
const char *
-irc_info_info_irc_buffer_cb (void *data, const char *info_name,
+irc_info_info_irc_buffer_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
char *pos_comma, *pos_comma2, *server, *channel, *host;
@@ -199,6 +212,7 @@ irc_info_info_irc_buffer_cb (void *data, const char *info_name,
struct t_irc_channel *ptr_channel;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
@@ -282,7 +296,8 @@ irc_info_info_irc_buffer_cb (void *data, const char *info_name,
*/
const char *
-irc_info_info_irc_server_isupport_cb (void *data, const char *info_name,
+irc_info_info_irc_server_isupport_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
char *pos_comma, *server;
@@ -291,6 +306,7 @@ irc_info_info_irc_server_isupport_cb (void *data, const char *info_name,
struct t_irc_server *ptr_server;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
@@ -317,7 +333,8 @@ irc_info_info_irc_server_isupport_cb (void *data, const char *info_name,
*/
const char *
-irc_info_info_irc_server_isupport_value_cb (void *data, const char *info_name,
+irc_info_info_irc_server_isupport_value_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
char *pos_comma, *server;
@@ -325,6 +342,7 @@ irc_info_info_irc_server_isupport_value_cb (void *data, const char *info_name,
struct t_irc_server *ptr_server;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
@@ -351,7 +369,7 @@ irc_info_info_irc_server_isupport_value_cb (void *data, const char *info_name,
*/
struct t_hashtable *
-irc_info_info_hashtable_irc_message_parse_cb (void *data,
+irc_info_info_hashtable_irc_message_parse_cb (const void *pointer, void *data,
const char *info_name,
struct t_hashtable *hashtable)
{
@@ -360,6 +378,7 @@ irc_info_info_hashtable_irc_message_parse_cb (void *data,
struct t_hashtable *value;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
@@ -383,7 +402,7 @@ irc_info_info_hashtable_irc_message_parse_cb (void *data,
*/
struct t_hashtable *
-irc_info_info_hashtable_irc_message_split_cb (void *data,
+irc_info_info_hashtable_irc_message_split_cb (const void *pointer, void *data,
const char *info_name,
struct t_hashtable *hashtable)
{
@@ -392,6 +411,7 @@ irc_info_info_hashtable_irc_message_split_cb (void *data,
struct t_hashtable *value;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
@@ -415,27 +435,29 @@ irc_info_info_hashtable_irc_message_split_cb (void *data,
*/
struct t_infolist *
-irc_info_infolist_irc_server_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+irc_info_infolist_irc_server_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
struct t_infolist *ptr_infolist;
struct t_irc_server *ptr_server;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) infolist_name;
- if (pointer && !irc_server_valid (pointer))
+ if (obj_pointer && !irc_server_valid (obj_pointer))
return NULL;
ptr_infolist = weechat_infolist_new ();
if (!ptr_infolist)
return NULL;
- if (pointer)
+ if (obj_pointer)
{
/* build list with only one server */
- if (!irc_server_add_to_infolist (ptr_infolist, pointer))
+ if (!irc_server_add_to_infolist (ptr_infolist, obj_pointer))
{
weechat_infolist_free (ptr_infolist);
return NULL;
@@ -469,8 +491,9 @@ irc_info_infolist_irc_server_cb (void *data, const char *infolist_name,
*/
struct t_infolist *
-irc_info_infolist_irc_channel_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+irc_info_infolist_irc_channel_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
struct t_infolist *ptr_infolist;
struct t_irc_server *ptr_server;
@@ -479,6 +502,7 @@ irc_info_infolist_irc_channel_cb (void *data, const char *infolist_name,
int argc;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) infolist_name;
@@ -499,10 +523,10 @@ irc_info_infolist_irc_channel_cb (void *data, const char *infolist_name,
weechat_string_free_split (argv);
return NULL;
}
- if (!pointer && (argc >= 2))
+ if (!obj_pointer && (argc >= 2))
{
- pointer = irc_channel_search (ptr_server, argv[1]);
- if (!pointer)
+ obj_pointer = irc_channel_search (ptr_server, argv[1]);
+ if (!obj_pointer)
{
weechat_string_free_split (argv);
return NULL;
@@ -514,17 +538,17 @@ irc_info_infolist_irc_channel_cb (void *data, const char *infolist_name,
if (!ptr_server)
return NULL;
- if (pointer && !irc_channel_valid (ptr_server, pointer))
+ if (obj_pointer && !irc_channel_valid (ptr_server, obj_pointer))
return NULL;
ptr_infolist = weechat_infolist_new ();
if (!ptr_infolist)
return NULL;
- if (pointer)
+ if (obj_pointer)
{
/* build list with only one channel */
- if (!irc_channel_add_to_infolist (ptr_infolist, pointer))
+ if (!irc_channel_add_to_infolist (ptr_infolist, obj_pointer))
{
weechat_infolist_free (ptr_infolist);
return NULL;
@@ -554,8 +578,9 @@ irc_info_infolist_irc_channel_cb (void *data, const char *infolist_name,
*/
struct t_infolist *
-irc_info_infolist_irc_nick_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+irc_info_infolist_irc_nick_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
struct t_infolist *ptr_infolist;
struct t_irc_server *ptr_server;
@@ -565,6 +590,7 @@ irc_info_infolist_irc_nick_cb (void *data, const char *infolist_name,
int argc;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) infolist_name;
@@ -591,11 +617,11 @@ irc_info_infolist_irc_nick_cb (void *data, const char *infolist_name,
weechat_string_free_split (argv);
return NULL;
}
- if (!pointer && (argc >= 3))
+ if (!obj_pointer && (argc >= 3))
{
- pointer = irc_nick_search (ptr_server, ptr_channel,
+ obj_pointer = irc_nick_search (ptr_server, ptr_channel,
argv[2]);
- if (!pointer)
+ if (!obj_pointer)
{
weechat_string_free_split (argv);
return NULL;
@@ -607,18 +633,18 @@ irc_info_infolist_irc_nick_cb (void *data, const char *infolist_name,
if (!ptr_server || !ptr_channel)
return NULL;
- if (pointer && !irc_nick_valid (ptr_channel, pointer))
+ if (obj_pointer && !irc_nick_valid (ptr_channel, obj_pointer))
return NULL;
ptr_infolist = weechat_infolist_new ();
if (!ptr_infolist)
return NULL;
- if (pointer)
+ if (obj_pointer)
{
/* build list with only one nick */
if (!irc_nick_add_to_infolist (ptr_infolist,
- pointer))
+ obj_pointer))
{
weechat_infolist_free (ptr_infolist);
return NULL;
@@ -649,28 +675,30 @@ irc_info_infolist_irc_nick_cb (void *data, const char *infolist_name,
*/
struct t_infolist *
-irc_info_infolist_irc_ignore_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+irc_info_infolist_irc_ignore_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
struct t_infolist *ptr_infolist;
struct t_irc_ignore *ptr_ignore;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) infolist_name;
(void) arguments;
- if (pointer && !irc_ignore_valid (pointer))
+ if (obj_pointer && !irc_ignore_valid (obj_pointer))
return NULL;
ptr_infolist = weechat_infolist_new ();
if (!ptr_infolist)
return NULL;
- if (pointer)
+ if (obj_pointer)
{
/* build list with only one ignore */
- if (!irc_ignore_add_to_infolist (ptr_infolist, pointer))
+ if (!irc_ignore_add_to_infolist (ptr_infolist, obj_pointer))
{
weechat_infolist_free (ptr_infolist);
return NULL;
@@ -700,28 +728,30 @@ irc_info_infolist_irc_ignore_cb (void *data, const char *infolist_name,
*/
struct t_infolist *
-irc_info_infolist_irc_notify_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+irc_info_infolist_irc_notify_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
struct t_infolist *ptr_infolist;
struct t_irc_server *ptr_server;
struct t_irc_notify *ptr_notify;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) infolist_name;
- if (pointer && !irc_notify_valid (NULL, pointer))
+ if (obj_pointer && !irc_notify_valid (NULL, obj_pointer))
return NULL;
ptr_infolist = weechat_infolist_new ();
if (!ptr_infolist)
return NULL;
- if (pointer)
+ if (obj_pointer)
{
/* build list with only one notify */
- if (!irc_notify_add_to_infolist (ptr_infolist, pointer))
+ if (!irc_notify_add_to_infolist (ptr_infolist, obj_pointer))
{
weechat_infolist_free (ptr_infolist);
return NULL;
@@ -760,15 +790,18 @@ irc_info_infolist_irc_notify_cb (void *data, const char *infolist_name,
*/
struct t_infolist *
-irc_info_infolist_irc_color_weechat_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+irc_info_infolist_irc_color_weechat_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer,
+ const char *arguments)
{
struct t_infolist *ptr_infolist;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) infolist_name;
- (void) pointer;
+ (void) obj_pointer;
(void) arguments;
ptr_infolist = weechat_infolist_new ();
@@ -796,47 +829,49 @@ irc_info_init ()
"irc_is_channel",
N_("1 if string is a valid IRC channel name for server"),
N_("server,channel (server is optional)"),
- &irc_info_info_irc_is_channel_cb, NULL);
+ &irc_info_info_irc_is_channel_cb, NULL, NULL);
weechat_hook_info (
"irc_is_nick",
N_("1 if string is a valid IRC nick name"),
N_("nickname"),
- &irc_info_info_irc_is_nick_cb, NULL);
+ &irc_info_info_irc_is_nick_cb, NULL, NULL);
weechat_hook_info (
"irc_nick",
N_("get current nick on a server"),
N_("server name"),
- &irc_info_info_irc_nick_cb, NULL);
+ &irc_info_info_irc_nick_cb, NULL, NULL);
weechat_hook_info (
"irc_nick_from_host",
N_("get nick from IRC host"),
N_("IRC host (like `:nick!name@server.com`)"),
- &irc_info_info_irc_nick_from_host_cb, NULL);
+ &irc_info_info_irc_nick_from_host_cb, NULL, NULL);
weechat_hook_info (
"irc_nick_color",
- N_("get nick color code"),
+ N_("get nick color code "
+ "(*deprecated* since version 1.5, replaced by \"nick_color\")"),
N_("nickname"),
- &irc_info_info_irc_nick_color_cb, NULL);
+ &irc_info_info_irc_nick_color_cb, NULL, NULL);
weechat_hook_info (
"irc_nick_color_name",
- N_("get nick color name"),
+ N_("get nick color name "
+ "(*deprecated* since version 1.5, replaced by \"nick_color_name\")"),
N_("nickname"),
- &irc_info_info_irc_nick_color_name_cb, NULL);
+ &irc_info_info_irc_nick_color_name_cb, NULL, NULL);
weechat_hook_info (
"irc_buffer",
N_("get buffer pointer for an IRC server/channel/nick"),
N_("server,channel,nick (channel and nicks are optional)"),
- &irc_info_info_irc_buffer_cb, NULL);
+ &irc_info_info_irc_buffer_cb, NULL, NULL);
weechat_hook_info (
"irc_server_isupport",
N_("1 if server supports this feature (from IRC message 005)"),
N_("server,feature"),
- &irc_info_info_irc_server_isupport_cb, NULL);
+ &irc_info_info_irc_server_isupport_cb, NULL, NULL);
weechat_hook_info (
"irc_server_isupport_value",
N_("value of feature, if supported by server (from IRC message 005)"),
N_("server,feature"),
- &irc_info_info_irc_server_isupport_value_cb, NULL);
+ &irc_info_info_irc_server_isupport_value_cb, NULL, NULL);
/* info_hashtable hooks */
weechat_hook_info_hashtable (
@@ -860,7 +895,7 @@ irc_info_init ()
"\"channel\" was not found), "
"\"pos_text\": index of \"text\" message (\"-1\" if "
"\"text\" was not found)"),
- &irc_info_info_hashtable_irc_message_parse_cb, NULL);
+ &irc_info_info_hashtable_irc_message_parse_cb, NULL, NULL);
weechat_hook_info_hashtable (
"irc_message_split",
N_("split an IRC message (to fit in 512 bytes)"),
@@ -869,7 +904,7 @@ irc_info_init ()
N_("\"msg1\" ... \"msgN\": messages to send (without final \"\\r\\n\"), "
"\"args1\" ... \"argsN\": arguments of messages, \"count\": number "
"of messages"),
- &irc_info_info_hashtable_irc_message_split_cb, NULL);
+ &irc_info_info_hashtable_irc_message_split_cb, NULL, NULL);
/* infolist hooks */
weechat_hook_infolist (
@@ -877,61 +912,61 @@ irc_info_init ()
N_("list of IRC servers"),
N_("server pointer (optional)"),
N_("server name (wildcard \"*\" is allowed) (optional)"),
- &irc_info_infolist_irc_server_cb, NULL);
+ &irc_info_infolist_irc_server_cb, NULL, NULL);
weechat_hook_infolist (
"irc_channel",
N_("list of channels for an IRC server"),
N_("channel pointer (optional)"),
N_("server,channel (channel is optional)"),
- &irc_info_infolist_irc_channel_cb, NULL);
+ &irc_info_infolist_irc_channel_cb, NULL, NULL);
weechat_hook_infolist (
"irc_nick",
N_("list of nicks for an IRC channel"),
N_("nick pointer (optional)"),
N_("server,channel,nick (nick is optional)"),
- &irc_info_infolist_irc_nick_cb, NULL);
+ &irc_info_infolist_irc_nick_cb, NULL, NULL);
weechat_hook_infolist (
"irc_ignore",
N_("list of IRC ignores"),
N_("ignore pointer (optional)"),
NULL,
- &irc_info_infolist_irc_ignore_cb, NULL);
+ &irc_info_infolist_irc_ignore_cb, NULL, NULL);
weechat_hook_infolist (
"irc_notify",
N_("list of notify"),
N_("notify pointer (optional)"),
N_("server name (wildcard \"*\" is allowed) (optional)"),
- &irc_info_infolist_irc_notify_cb, NULL);
+ &irc_info_infolist_irc_notify_cb, NULL, NULL);
weechat_hook_infolist (
"irc_color_weechat",
N_("mapping between IRC color codes and WeeChat color names"),
NULL,
NULL,
- &irc_info_infolist_irc_color_weechat_cb, NULL);
+ &irc_info_infolist_irc_color_weechat_cb, NULL, NULL);
/* hdata hooks */
weechat_hook_hdata (
"irc_nick", N_("irc nick"),
- &irc_nick_hdata_nick_cb, NULL);
+ &irc_nick_hdata_nick_cb, NULL, NULL);
weechat_hook_hdata (
"irc_channel", N_("irc channel"),
- &irc_channel_hdata_channel_cb, NULL);
+ &irc_channel_hdata_channel_cb, NULL, NULL);
weechat_hook_hdata (
"irc_channel_speaking", N_("irc channel_speaking"),
- &irc_channel_hdata_channel_speaking_cb, NULL);
+ &irc_channel_hdata_channel_speaking_cb, NULL, NULL);
weechat_hook_hdata (
"irc_ignore", N_("irc ignore"),
- &irc_ignore_hdata_ignore_cb, NULL);
+ &irc_ignore_hdata_ignore_cb, NULL, NULL);
weechat_hook_hdata (
"irc_notify", N_("irc notify"),
- &irc_notify_hdata_notify_cb, NULL);
+ &irc_notify_hdata_notify_cb, NULL, NULL);
weechat_hook_hdata (
"irc_redirect_pattern", N_("pattern for irc redirect"),
- &irc_redirect_hdata_redirect_pattern_cb, NULL);
+ &irc_redirect_hdata_redirect_pattern_cb, NULL, NULL);
weechat_hook_hdata (
"irc_redirect", N_("irc redirect"),
- &irc_redirect_hdata_redirect_cb, NULL);
+ &irc_redirect_hdata_redirect_cb, NULL, NULL);
weechat_hook_hdata (
"irc_server", N_("irc server"),
- &irc_server_hdata_server_cb, NULL);
+ &irc_server_hdata_server_cb, NULL, NULL);
}
diff --git a/src/plugins/irc/irc-info.h b/src/plugins/irc/irc-info.h
index 888a1d93a..7f50323a8 100644
--- a/src/plugins/irc/irc-info.h
+++ b/src/plugins/irc/irc-info.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-input.c b/src/plugins/irc/irc-input.c
index f7e3b5af3..bad329b77 100644
--- a/src/plugins/irc/irc-input.c
+++ b/src/plugins/irc/irc-input.c
@@ -1,7 +1,7 @@
/*
* irc-input.c - input data management for IRC buffers
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -98,8 +98,9 @@ irc_input_user_message_display (struct t_gui_buffer *buffer, int action,
ptr_text = (text_decoded) ? text_decoded : ((text2) ? text2 : text);
if (action)
{
- weechat_printf_tags (
+ weechat_printf_date_tags (
buffer,
+ 0,
irc_protocol_tags (
"privmsg", str_tags,
(ptr_nick) ? ptr_nick->name : ptr_server->nick,
@@ -114,8 +115,9 @@ irc_input_user_message_display (struct t_gui_buffer *buffer, int action,
}
else
{
- weechat_printf_tags (
+ weechat_printf_date_tags (
buffer,
+ 0,
irc_protocol_tags (
"privmsg", str_tags,
(ptr_nick) ? ptr_nick->name : ptr_server->nick,
@@ -189,7 +191,8 @@ irc_input_send_user_message (struct t_gui_buffer *buffer, int flags,
*/
int
-irc_input_data (struct t_gui_buffer *buffer, const char *input_data, int flags)
+irc_input_data (struct t_gui_buffer *buffer, const char *input_data, int flags,
+ int force_user_message)
{
const char *ptr_data;
char *data_with_colors, *msg;
@@ -207,7 +210,8 @@ irc_input_data (struct t_gui_buffer *buffer, const char *input_data, int flags)
* if send unknown commands is enabled and that input data is a
* command, then send this command to IRC server
*/
- if (weechat_config_boolean (irc_config_network_send_unknown_commands)
+ if (!force_user_message
+ && weechat_config_boolean (irc_config_network_send_unknown_commands)
&& !weechat_string_input_for_buffer (input_data))
{
if (ptr_server)
@@ -220,9 +224,13 @@ irc_input_data (struct t_gui_buffer *buffer, const char *input_data, int flags)
if (ptr_channel)
{
- ptr_data = weechat_string_input_for_buffer (input_data);
- if (!ptr_data)
- ptr_data = input_data;
+ ptr_data = input_data;
+ if (!force_user_message)
+ {
+ ptr_data = weechat_string_input_for_buffer (input_data);
+ if (!ptr_data)
+ ptr_data = input_data;
+ }
data_with_colors = irc_color_encode (
ptr_data,
weechat_config_boolean (irc_config_network_colors_send));
@@ -253,13 +261,16 @@ irc_input_data (struct t_gui_buffer *buffer, const char *input_data, int flags)
*/
int
-irc_input_data_cb (void *data, struct t_gui_buffer *buffer,
+irc_input_data_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
const char *input_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
- return irc_input_data (buffer, input_data, IRC_SERVER_SEND_OUTQ_PRIO_HIGH);
+ return irc_input_data (buffer, input_data,
+ IRC_SERVER_SEND_OUTQ_PRIO_HIGH, 0);
}
/*
@@ -268,28 +279,32 @@ irc_input_data_cb (void *data, struct t_gui_buffer *buffer,
* This signal can be used by other plugins/scripts, it simulates input or
* command from user on an IRC buffer (it is used for example by Relay plugin).
*
- * Format of signal_data (string) is "server;channel;flags;tags;text"
+ * Format of signal_data (string) is "server;channel;options;tags;text"
* server: server name (required)
* channel: channel name (optional)
- * flags: flags for irc_server_sendf() (optional)
+ * options: comma-separated list of options (optional):
+ * "priority_high": send with high priority (default)
+ * "priority_low": send with low priority
+ * "user_message": force user message (don't execute a command)
* tags: tags for irc_server_sendf() (optional)
* text: text or command (required).
*/
int
-irc_input_send_cb (void *data, const char *signal,
+irc_input_send_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
const char *ptr_string, *ptr_message;
- char *pos_semicol1, *pos_semicol2, *pos_semicol3, *pos_semicol4, *error;
- char *server, *channel, *flags, *tags;
- long flags_value;
- char *data_with_colors;
+ char *pos_semicol1, *pos_semicol2, *pos_semicol3, *pos_semicol4;
+ char *server, *channel, *options, *tags, *data_with_colors, **list_options;
+ int i, num_options, flags, force_user_message;
struct t_irc_server *ptr_server;
struct t_irc_channel *ptr_channel;
struct t_gui_buffer *ptr_buffer;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -298,7 +313,9 @@ irc_input_send_cb (void *data, const char *signal,
server = NULL;
channel = NULL;
- flags = NULL;
+ options = NULL;
+ flags = IRC_SERVER_SEND_OUTQ_PRIO_HIGH;
+ force_user_message = 0;
tags = NULL;
ptr_message = NULL;
ptr_server = NULL;
@@ -324,8 +341,8 @@ irc_input_send_cb (void *data, const char *signal,
{
if (pos_semicol3 > pos_semicol2 + 1)
{
- flags = weechat_strndup (pos_semicol2 + 1,
- pos_semicol3 - pos_semicol2 - 1);
+ options = weechat_strndup (pos_semicol2 + 1,
+ pos_semicol3 - pos_semicol2 - 1);
}
pos_semicol4 = strchr (pos_semicol3 + 1, ';');
if (pos_semicol4)
@@ -341,13 +358,22 @@ irc_input_send_cb (void *data, const char *signal,
}
}
- flags_value = IRC_SERVER_SEND_OUTQ_PRIO_HIGH;
- if (flags)
+ if (options && options[0])
{
- error = NULL;
- flags_value = strtol (flags, &error, 10);
- if (flags_value < 0)
- flags_value = IRC_SERVER_SEND_OUTQ_PRIO_HIGH;
+ list_options = weechat_string_split (options, ",", 0, 0, &num_options);
+ if (list_options)
+ {
+ for (i = 0; i < num_options; i++)
+ {
+ if (strcmp (list_options[i], "priority_high") == 0)
+ flags = IRC_SERVER_SEND_OUTQ_PRIO_HIGH;
+ else if (strcmp (list_options[i], "priority_low") == 0)
+ flags = IRC_SERVER_SEND_OUTQ_PRIO_LOW;
+ else if (strcmp (list_options[i], "user_message") == 0)
+ force_user_message = 1;
+ }
+ weechat_string_free_split (list_options);
+ }
}
if (server && ptr_message)
@@ -367,10 +393,11 @@ irc_input_send_cb (void *data, const char *signal,
irc_server_set_send_default_tags (tags);
/* send text to buffer, or execute command */
- if (weechat_string_input_for_buffer (ptr_message))
+ if (force_user_message
+ || weechat_string_input_for_buffer (ptr_message))
{
/* text as input */
- irc_input_data (ptr_buffer, ptr_message, flags_value);
+ irc_input_data (ptr_buffer, ptr_message, flags, 1);
}
else
{
@@ -394,8 +421,8 @@ irc_input_send_cb (void *data, const char *signal,
free (server);
if (channel)
free (channel);
- if (flags)
- free (flags);
+ if (options)
+ free (options);
if (tags)
free (tags);
diff --git a/src/plugins/irc/irc-input.h b/src/plugins/irc/irc-input.h
index f4fc4bdb4..4d8315992 100644
--- a/src/plugins/irc/irc-input.h
+++ b/src/plugins/irc/irc-input.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -24,9 +24,11 @@ struct t_gui_buffer;
extern void irc_input_user_message_display (struct t_gui_buffer *buffer,
int action, const char *text);
-extern int irc_input_data_cb (void *data, struct t_gui_buffer *buffer,
+extern int irc_input_data_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
const char *input_data);
-extern int irc_input_send_cb (void *data, const char *signal,
- const char *type_data, void *signal_data);
+extern int irc_input_send_cb (const void *pointer, void *data,
+ const char *signal, const char *type_data,
+ void *signal_data);
#endif /* WEECHAT_IRC_INPUT_H */
diff --git a/src/plugins/irc/irc-message.c b/src/plugins/irc/irc-message.c
index e0c4dcf4f..5e1e1b604 100644
--- a/src/plugins/irc/irc-message.c
+++ b/src/plugins/irc/irc-message.c
@@ -1,7 +1,7 @@
/*
* irc-message.c - functions for IRC messages
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -70,7 +70,7 @@ irc_message_parse (struct t_irc_server *server, const char *message,
int *pos_command, int *pos_arguments, int *pos_channel,
int *pos_text)
{
- const char *ptr_message, *pos, *pos2, *pos3, *pos4;
+ const char *ptr_message, *pos, *pos2, *pos3, *pos4, *ptr_channel_found;
if (tags)
*tags = NULL;
@@ -96,6 +96,7 @@ irc_message_parse (struct t_irc_server *server, const char *message,
*pos_channel = -1;
if (pos_text)
*pos_text = -1;
+ ptr_channel_found = NULL;
if (!message)
return;
@@ -209,6 +210,7 @@ irc_message_parse (struct t_irc_server *server, const char *message,
{
if (irc_channel_is_channel (server, pos))
{
+ ptr_channel_found = pos;
pos2 = strchr (pos, ' ');
if (channel)
{
@@ -253,6 +255,7 @@ irc_message_parse (struct t_irc_server *server, const char *message,
}
if (irc_channel_is_channel (server, pos2))
{
+ ptr_channel_found = pos2;
pos4 = strchr (pos2, ' ');
if (channel)
{
@@ -277,13 +280,38 @@ irc_message_parse (struct t_irc_server *server, const char *message,
*pos_text = pos4 - message;
}
}
- else if ((channel && !*channel)
- || (pos_channel && (*pos_channel < 0)))
+ else
{
- if (channel)
- *channel = weechat_strndup (pos, pos3 - pos);
- if (pos_channel)
- *pos_channel = pos - message;
+ if (ptr_channel_found)
+ {
+ if (pos[0] == ':')
+ pos++;
+ if (text)
+ *text = strdup (pos);
+ if (pos_text)
+ *pos_text = pos - message;
+ }
+ else
+ {
+ if (channel)
+ *channel = weechat_strndup (pos, pos3 - pos);
+ if (pos_channel)
+ *pos_channel = pos - message;
+ pos4 = strchr (pos3, ' ');
+ if (pos4)
+ {
+ while (pos4[0] == ' ')
+ {
+ pos4++;
+ }
+ if (pos4[0] == ':')
+ pos4++;
+ if (text)
+ *text = strdup (pos4);
+ if (pos_text)
+ *pos_text = pos4 - message;
+ }
+ }
}
}
}
@@ -334,8 +362,7 @@ irc_message_parse_to_hashtable (struct t_irc_server *server,
hashtable = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
if (!hashtable)
return NULL;
@@ -980,8 +1007,7 @@ irc_message_split (struct t_irc_server *server, const char *message)
hashtable = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
if (!hashtable)
return NULL;
diff --git a/src/plugins/irc/irc-message.h b/src/plugins/irc/irc-message.h
index 026595b7e..a4478115c 100644
--- a/src/plugins/irc/irc-message.h
+++ b/src/plugins/irc/irc-message.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-mode.c b/src/plugins/irc/irc-mode.c
index 163e9cdd7..a31d64388 100644
--- a/src/plugins/irc/irc-mode.c
+++ b/src/plugins/irc/irc-mode.c
@@ -1,7 +1,7 @@
/*
* irc-mode.c - IRC channel/user modes management
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-mode.h b/src/plugins/irc/irc-mode.h
index f6a498626..8dbd2220e 100644
--- a/src/plugins/irc/irc-mode.h
+++ b/src/plugins/irc/irc-mode.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-msgbuffer.c b/src/plugins/irc/irc-msgbuffer.c
index 0e58a417a..27708fccb 100644
--- a/src/plugins/irc/irc-msgbuffer.c
+++ b/src/plugins/irc/irc-msgbuffer.c
@@ -1,7 +1,7 @@
/*
* irc-msgbuffer.c - target buffer for IRC messages
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-msgbuffer.h b/src/plugins/irc/irc-msgbuffer.h
index 370c2dd92..a27e7daa2 100644
--- a/src/plugins/irc/irc-msgbuffer.h
+++ b/src/plugins/irc/irc-msgbuffer.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c
index 0877f331a..6f01f48d8 100644
--- a/src/plugins/irc/irc-nick.c
+++ b/src/plugins/irc/irc-nick.c
@@ -1,7 +1,7 @@
/*
* irc-nick.c - nick management for IRC plugin
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -93,130 +93,6 @@ irc_nick_is_nick (const char *string)
}
/*
- * Duplicates a nick and stops at first char in list (using option
- * irc.look.nick_color_stop_chars).
- *
- * Note: result must be freed after use.
- */
-
-char *
-irc_nick_strdup_for_color (const char *nickname)
-{
- int char_size, other_char_seen;
- char *result, *pos, utf_char[16];
-
- result = malloc (strlen (nickname) + 1);
- pos = result;
- other_char_seen = 0;
- while (nickname[0])
- {
- char_size = weechat_utf8_char_size (nickname);
- memcpy (utf_char, nickname, char_size);
- utf_char[char_size] = '\0';
-
- if (strstr (weechat_config_string (irc_config_look_nick_color_stop_chars),
- utf_char))
- {
- if (other_char_seen)
- {
- pos[0] = '\0';
- return result;
- }
- }
- else
- {
- other_char_seen = 1;
- }
- memcpy (pos, utf_char, char_size);
- pos += char_size;
-
- nickname += char_size;
- }
- pos[0] = '\0';
- return result;
-}
-
-/*
- * Hashes a nickname to find color.
- *
- * Returns a number which is the index of color in the nicks colors of option
- * "weechat.color.chat_nick_colors".
- */
-
-int
-irc_nick_hash_color (const char *nickname)
-{
- unsigned long color;
- const char *ptr_nick;
-
- if (!irc_config_nick_colors)
- irc_config_set_nick_colors ();
-
- if (irc_config_num_nick_colors == 0)
- return 0;
-
- ptr_nick = nickname;
- color = 0;
-
- switch (weechat_config_integer (irc_config_look_nick_color_hash))
- {
- case IRC_CONFIG_LOOK_NICK_COLOR_HASH_DJB2:
- /* variant of djb2 hash */
- color = 5381;
- while (ptr_nick && ptr_nick[0])
- {
- color ^= (color << 5) + (color >> 2) + weechat_utf8_char_int (ptr_nick);
- ptr_nick = weechat_utf8_next_char (ptr_nick);
- }
- break;
- case IRC_CONFIG_LOOK_NICK_COLOR_HASH_SUM:
- /* sum of letters */
- color = 0;
- while (ptr_nick && ptr_nick[0])
- {
- color += weechat_utf8_char_int (ptr_nick);
- ptr_nick = weechat_utf8_next_char (ptr_nick);
- }
- break;
- }
-
- return (color % irc_config_num_nick_colors);
-}
-
-/*
- * Gets forced color for a nick.
- *
- * Returns the name of color (for example: "green"), NULL if no color is forced
- * for nick.
- */
-
-const char *
-irc_nick_get_forced_color (const char *nickname)
-{
- const char *forced_color;
- char *nick_lower;
-
- if (!nickname)
- return NULL;
-
- forced_color = weechat_hashtable_get (irc_config_hashtable_nick_color_force,
- nickname);
- if (forced_color)
- return forced_color;
-
- nick_lower = strdup (nickname);
- if (nick_lower)
- {
- weechat_string_tolower (nick_lower);
- forced_color = weechat_hashtable_get (irc_config_hashtable_nick_color_force,
- nick_lower);
- free (nick_lower);
- }
-
- return forced_color;
-}
-
-/*
* Finds a color code for a nick (according to nick letters).
*
* Returns a WeeChat color code (that can be used for display).
@@ -225,34 +101,7 @@ irc_nick_get_forced_color (const char *nickname)
const char *
irc_nick_find_color (const char *nickname)
{
- int color;
- char *nickname2;
- const char *forced_color, *str_color;
-
- if (!irc_config_nick_colors)
- irc_config_set_nick_colors ();
-
- if (irc_config_num_nick_colors == 0)
- return weechat_color ("default");
-
- /* look if color is forced */
- forced_color = irc_nick_get_forced_color (nickname);
- if (forced_color)
- {
- forced_color = weechat_color (forced_color);
- if (forced_color && forced_color[0])
- return forced_color;
- }
-
- /* hash nickname to get color */
- nickname2 = irc_nick_strdup_for_color (nickname);
- color = irc_nick_hash_color ((nickname2) ? nickname2 : nickname);
- if (nickname2)
- free (nickname2);
-
- /* return color */
- str_color = weechat_color (irc_config_nick_colors[color]);
- return (str_color[0]) ? str_color : weechat_color("default");
+ return weechat_info_get ("nick_color", nickname);
}
/*
@@ -264,30 +113,7 @@ irc_nick_find_color (const char *nickname)
const char *
irc_nick_find_color_name (const char *nickname)
{
- int color;
- char *nickname2;
- const char *forced_color;
- static char *default_color = "default";
-
- if (!irc_config_nick_colors)
- irc_config_set_nick_colors ();
-
- if (irc_config_num_nick_colors == 0)
- return default_color;
-
- /* look if color is forced */
- forced_color = irc_nick_get_forced_color (nickname);
- if (forced_color)
- return forced_color;
-
- /* hash nickname to get color */
- nickname2 = irc_nick_strdup_for_color (nickname);
- color = irc_nick_hash_color ((nickname2) ? nickname2 : nickname);
- if (nickname2)
- free (nickname2);
-
- /* return color name */
- return irc_config_nick_colors[color];
+ return weechat_info_get ("nick_color_name", nickname);
}
/*
@@ -626,7 +452,7 @@ irc_nick_nicklist_set_color_all ()
struct t_irc_nick *
irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
const char *nickname, const char *host, const char *prefixes,
- int away, const char *account)
+ int away, const char *account, const char *realname)
{
struct t_irc_nick *new_nick, *ptr_nick;
int length;
@@ -650,6 +476,9 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
if (ptr_nick->account)
free (ptr_nick->account);
ptr_nick->account = (account) ? strdup (account) : NULL;
+ if (ptr_nick->realname)
+ free (ptr_nick->realname);
+ ptr_nick->realname = (realname) ? strdup (realname) : NULL;
/* add new nick in nicklist */
irc_nick_nicklist_add (server, channel, ptr_nick);
@@ -665,6 +494,7 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
new_nick->name = strdup (nickname);
new_nick->host = (host) ? strdup (host) : NULL;
new_nick->account = (account) ? strdup (account) : NULL;
+ new_nick->realname = (realname) ? strdup (realname) : NULL;
length = strlen (irc_server_get_prefix_chars (server));
new_nick->prefixes = malloc (length + 1);
if (!new_nick->name || !new_nick->prefixes)
@@ -675,6 +505,8 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
free (new_nick->host);
if (new_nick->account)
free (new_nick->account);
+ if (new_nick->realname)
+ free (new_nick->realname);
if (new_nick->prefixes)
free (new_nick->prefixes);
free (new_nick);
@@ -817,6 +649,8 @@ irc_nick_free (struct t_irc_server *server, struct t_irc_channel *channel,
free (nick->prefixes);
if (nick->account)
free (nick->account);
+ if (nick->realname)
+ free (nick->realname);
if (nick->color)
free (nick->color);
@@ -1120,11 +954,13 @@ irc_nick_default_ban_mask (struct t_irc_nick *nick)
*/
struct t_hdata *
-irc_nick_hdata_nick_cb (void *data, const char *hdata_name)
+irc_nick_hdata_nick_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = weechat_hdata_new (hdata_name, "prev_nick", "next_nick",
@@ -1137,6 +973,7 @@ irc_nick_hdata_nick_cb (void *data, const char *hdata_name)
WEECHAT_HDATA_VAR(struct t_irc_nick, prefix, STRING, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_nick, away, INTEGER, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_nick, account, STRING, 0, NULL, NULL);
+ WEECHAT_HDATA_VAR(struct t_irc_nick, realname, STRING, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_nick, color, STRING, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_nick, prev_nick, POINTER, 0, NULL, hdata_name);
WEECHAT_HDATA_VAR(struct t_irc_nick, next_nick, POINTER, 0, NULL, hdata_name);
@@ -1177,6 +1014,8 @@ irc_nick_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "account", nick->account))
return 0;
+ if (!weechat_infolist_new_var_string (ptr_item, "realname", nick->realname))
+ return 0;
if (!weechat_infolist_new_var_string (ptr_item, "color", nick->color))
return 0;
@@ -1197,6 +1036,7 @@ irc_nick_print_log (struct t_irc_nick *nick)
weechat_log_printf (" prefix . . . . : '%s'", nick->prefix);
weechat_log_printf (" away . . . . . : %d", nick->away);
weechat_log_printf (" account. . . . : '%s'", nick->account);
+ weechat_log_printf (" realname . . . : '%s'", nick->realname);
weechat_log_printf (" color. . . . . : '%s'", nick->color);
weechat_log_printf (" prev_nick. . . : 0x%lx", nick->prev_nick);
weechat_log_printf (" next_nick. . . : 0x%lx", nick->next_nick);
diff --git a/src/plugins/irc/irc-nick.h b/src/plugins/irc/irc-nick.h
index 3079a437b..b8109a7cc 100644
--- a/src/plugins/irc/irc-nick.h
+++ b/src/plugins/irc/irc-nick.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -39,6 +39,7 @@ struct t_irc_nick
/* prefixes) */
int away; /* 1 if nick is away */
char *account; /* account name of the user */
+ char *realname; /* realname (aka gecos) of the user */
char *color; /* color for nickname */
struct t_irc_nick *prev_nick; /* link to previous nick on channel */
struct t_irc_nick *next_nick; /* link to next nick on channel */
@@ -47,8 +48,6 @@ struct t_irc_nick
extern int irc_nick_valid (struct t_irc_channel *channel,
struct t_irc_nick *nick);
extern int irc_nick_is_nick (const char *string);
-extern int irc_nick_config_colors_cb (void *data, const char *option,
- const char *value);
extern const char *irc_nick_find_color (const char *nickname);
extern const char *irc_nick_find_color_name (const char *nickname);
extern int irc_nick_is_op (struct t_irc_server *server,
@@ -66,7 +65,8 @@ extern struct t_irc_nick *irc_nick_new (struct t_irc_server *server,
const char *host,
const char *prefixes,
int away,
- const char *account);
+ const char *account,
+ const char *realname);
extern void irc_nick_change (struct t_irc_server *server,
struct t_irc_channel *channel,
struct t_irc_nick *nick, const char *new_nick);
@@ -102,7 +102,8 @@ extern const char *irc_nick_color_for_msg (struct t_irc_server *server,
extern const char * irc_nick_color_for_pv (struct t_irc_channel *channel,
const char *nickname);
extern char *irc_nick_default_ban_mask (struct t_irc_nick *nick);
-extern struct t_hdata *irc_nick_hdata_nick_cb (void *data,
+extern struct t_hdata *irc_nick_hdata_nick_cb (const void *pointer,
+ void *data,
const char *hdata_name);
extern int irc_nick_add_to_infolist (struct t_infolist *infolist,
struct t_irc_nick *nick);
diff --git a/src/plugins/irc/irc-notify.c b/src/plugins/irc/irc-notify.c
index cb9a2e590..c58c668fe 100644
--- a/src/plugins/irc/irc-notify.c
+++ b/src/plugins/irc/irc-notify.c
@@ -1,7 +1,7 @@
/*
* irc-notify.c - notify lists for IRC plugin
*
- * Copyright (C) 2010-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2010-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -672,8 +672,9 @@ irc_notify_set_is_on_server (struct t_irc_notify *notify, const char *host,
if (notify->is_on_server == is_on_server)
return;
- weechat_printf_tags (
+ weechat_printf_date_tags (
notify->server->buffer,
+ 0,
irc_notify_get_tags (irc_config_look_notify_tags_ison,
(is_on_server) ? "join" : "quit",
notify->nick),
@@ -719,8 +720,9 @@ irc_notify_set_away_message (struct t_irc_notify *notify,
if (!notify->away_message && away_message)
{
- weechat_printf_tags (
+ weechat_printf_date_tags (
notify->server->buffer,
+ 0,
irc_notify_get_tags (
irc_config_look_notify_tags_whois, "away", notify->nick),
_("%snotify: %s%s%s is now away: \"%s\""),
@@ -733,8 +735,9 @@ irc_notify_set_away_message (struct t_irc_notify *notify,
}
else if (notify->away_message && !away_message)
{
- weechat_printf_tags (
+ weechat_printf_date_tags (
notify->server->buffer,
+ 0,
irc_notify_get_tags (
irc_config_look_notify_tags_whois, "back", notify->nick),
_("%snotify: %s%s%s is back"),
@@ -746,8 +749,9 @@ irc_notify_set_away_message (struct t_irc_notify *notify,
}
else if (notify->away_message && away_message)
{
- weechat_printf_tags (
+ weechat_printf_date_tags (
notify->server->buffer,
+ 0,
irc_notify_get_tags (
irc_config_look_notify_tags_whois, "still_away", notify->nick),
_("%snotify: %s%s%s is still away: \"%s\""),
@@ -769,7 +773,7 @@ irc_notify_set_away_message (struct t_irc_notify *notify,
*/
int
-irc_notify_hsignal_cb (void *data, const char *signal,
+irc_notify_hsignal_cb (const void *pointer, void *data, const char *signal,
struct t_hashtable *hashtable)
{
const char *error, *server, *pattern, *command, *output;
@@ -781,6 +785,7 @@ irc_notify_hsignal_cb (void *data, const char *signal,
struct t_irc_notify *ptr_notify;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
@@ -962,7 +967,7 @@ irc_notify_hsignal_cb (void *data, const char *signal,
*/
int
-irc_notify_timer_ison_cb (void *data, int remaining_calls)
+irc_notify_timer_ison_cb (const void *pointer, void *data, int remaining_calls)
{
char *message, hash_key[32];
const char *str_message;
@@ -971,6 +976,7 @@ irc_notify_timer_ison_cb (void *data, int remaining_calls)
struct t_hashtable *hashtable;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) remaining_calls;
@@ -1021,12 +1027,14 @@ irc_notify_timer_ison_cb (void *data, int remaining_calls)
*/
int
-irc_notify_timer_whois_cb (void *data, int remaining_calls)
+irc_notify_timer_whois_cb (const void *pointer, void *data,
+ int remaining_calls)
{
struct t_irc_server *ptr_server;
struct t_irc_notify *ptr_notify, *ptr_next_notify;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) remaining_calls;
@@ -1067,11 +1075,13 @@ irc_notify_timer_whois_cb (void *data, int remaining_calls)
*/
struct t_hdata *
-irc_notify_hdata_notify_cb (void *data, const char *hdata_name)
+irc_notify_hdata_notify_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = weechat_hdata_new (hdata_name, "prev_notify", "next_notify",
@@ -1164,7 +1174,7 @@ irc_notify_hook_timer_ison ()
irc_notify_timer_ison = weechat_hook_timer (
60 * 1000 * weechat_config_integer (irc_config_network_notify_check_ison),
- 0, 0, &irc_notify_timer_ison_cb, NULL);
+ 0, 0, &irc_notify_timer_ison_cb, NULL, NULL);
}
/*
@@ -1179,7 +1189,7 @@ irc_notify_hook_timer_whois ()
irc_notify_timer_whois = weechat_hook_timer (
60 * 1000 * weechat_config_integer (irc_config_network_notify_check_whois),
- 0, 0, &irc_notify_timer_whois_cb, NULL);
+ 0, 0, &irc_notify_timer_whois_cb, NULL, NULL);
}
/*
@@ -1194,7 +1204,7 @@ irc_notify_init ()
irc_notify_hsignal = weechat_hook_hsignal ("irc_redirection_notify_*",
&irc_notify_hsignal_cb,
- NULL);
+ NULL, NULL);
}
/*
diff --git a/src/plugins/irc/irc-notify.h b/src/plugins/irc/irc-notify.h
index 19c310dba..f290cd0b0 100644
--- a/src/plugins/irc/irc-notify.h
+++ b/src/plugins/irc/irc-notify.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2010-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -60,9 +60,12 @@ extern void irc_notify_set_is_on_server (struct t_irc_notify *notify,
extern void irc_notify_free_all (struct t_irc_server *server);
extern void irc_notify_display_list (struct t_irc_server *server);
extern void irc_notify_send_monitor (struct t_irc_server *server);
-extern int irc_notify_timer_ison_cb (void *data, int remaining_calls);
-extern int irc_notify_timer_whois_cb (void *data, int remaining_calls);
-extern struct t_hdata *irc_notify_hdata_notify_cb (void *data,
+extern int irc_notify_timer_ison_cb (const void *pointer, void *data,
+ int remaining_calls);
+extern int irc_notify_timer_whois_cb (const void *pointer, void *data,
+ int remaining_calls);
+extern struct t_hdata *irc_notify_hdata_notify_cb (const void *pointer,
+ void *data,
const char *hdata_name);
extern int irc_notify_add_to_infolist (struct t_infolist *infolist,
struct t_irc_notify *notify);
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index f3d7bff92..26f497d5d 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -1,7 +1,7 @@
/*
* irc-protocol.c - implementation of IRC protocol (RFCs 1459/2810/2811/2812/2813)
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org>
* Copyright (C) 2014 Shawn Smith <ShawnSmith0828@gmail.com>
*
@@ -206,9 +206,12 @@ IRC_PROTOCOL_CALLBACK(account)
{
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
+ char *pos_account;
IRC_PROTOCOL_MIN_ARGS(3);
+ pos_account = (strcmp (argv[2], "*") != 0) ? argv[2] : NULL;
+
for (ptr_channel = server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
@@ -217,8 +220,8 @@ IRC_PROTOCOL_CALLBACK(account)
{
if (ptr_nick->account)
free (ptr_nick->account);
- ptr_nick->account = (server->cap_account_notify) ?
- strdup (argv[2]) : strdup ("*");
+ ptr_nick->account = (server->cap_account_notify && pos_account) ?
+ strdup (pos_account) : NULL;
}
}
@@ -337,12 +340,12 @@ IRC_PROTOCOL_CALLBACK(away)
IRC_PROTOCOL_CALLBACK(cap)
{
- char *ptr_caps, **caps_supported, **caps_requested, *cap_option, *cap_req;
- char str_msg_auth[512];
+ char *ptr_caps, **caps_supported, **caps_requested, **caps_added;
+ char **caps_removed, *cap_option, *cap_req, str_msg_auth[512];
const char *ptr_cap_option;
- int num_caps_supported, num_caps_requested;
- int sasl_requested, sasl_to_do, sasl_mechanism;
- int i, j, timeout, length;
+ int num_caps_supported, num_caps_requested, num_caps_added;
+ int num_caps_removed, sasl_requested, sasl_to_do, sasl_mechanism;
+ int sasl_fail, i, j, timeout, length;
IRC_PROTOCOL_MIN_ARGS(4);
@@ -363,9 +366,11 @@ IRC_PROTOCOL_CALLBACK(cap)
{
sasl_requested = irc_server_sasl_enabled (server);
sasl_to_do = 0;
- ptr_cap_option = IRC_SERVER_OPTION_STRING(server,
- IRC_SERVER_OPTION_CAPABILITIES);
- length = ((ptr_cap_option && ptr_cap_option[0]) ? strlen (ptr_cap_option) : 0) + 16;
+ ptr_cap_option = IRC_SERVER_OPTION_STRING(
+ server,
+ IRC_SERVER_OPTION_CAPABILITIES);
+ length = ((ptr_cap_option && ptr_cap_option[0]) ?
+ strlen (ptr_cap_option) : 0) + 16;
cap_option = malloc (length);
cap_req = malloc (length);
if (cap_option && cap_req)
@@ -422,8 +427,21 @@ IRC_PROTOCOL_CALLBACK(cap)
{
weechat_printf (
server->buffer,
- _("%s%s: client capability: sasl not supported"),
+ _("%s%s: client capability: SASL not supported"),
weechat_prefix ("network"), IRC_PLUGIN_NAME);
+
+ if (weechat_config_boolean (irc_config_network_sasl_fail_unavailable))
+ {
+ /* same handling as for sasl_end_fail */
+ sasl_fail = IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_SASL_FAIL);
+ if ((sasl_fail == IRC_SERVER_SASL_FAIL_RECONNECT)
+ || (sasl_fail == IRC_SERVER_SASL_FAIL_DISCONNECT))
+ {
+ irc_server_disconnect (
+ server, 0,
+ (sasl_fail == IRC_SERVER_SASL_FAIL_RECONNECT) ? 1 : 0);
+ }
+ }
}
}
if (cap_option)
@@ -442,7 +460,7 @@ IRC_PROTOCOL_CALLBACK(cap)
server->buffer, date, NULL,
_("%s%s: client capability, currently enabled: %s"),
weechat_prefix ("network"), IRC_PLUGIN_NAME, ptr_caps);
- }
+ }
}
else if (strcmp (argv[3], "ACK") == 0)
{
@@ -473,6 +491,10 @@ IRC_PROTOCOL_CALLBACK(cap)
{
server->cap_account_notify = 1;
}
+ else if (strcmp (caps_supported[i], "extended-join") == 0)
+ {
+ server->cap_extended_join = 1;
+ }
}
weechat_string_free_split (caps_supported);
}
@@ -496,7 +518,7 @@ IRC_PROTOCOL_CALLBACK(cap)
timeout * 1000,
0, 1,
&irc_server_timer_sasl_cb,
- server);
+ server, NULL);
}
}
}
@@ -514,6 +536,103 @@ IRC_PROTOCOL_CALLBACK(cap)
irc_server_sendf (server, 0, NULL, "CAP END");
}
}
+ else if (strcmp (argv[3], "NEW") == 0)
+ {
+ if (argc > 4)
+ {
+ ptr_caps = (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4];
+ weechat_printf_date_tags (
+ server->buffer, date, NULL,
+ _("%s%s: client capability, now available: %s"),
+ weechat_prefix ("network"), IRC_PLUGIN_NAME, ptr_caps);
+
+ /*
+ * assume that we're not requesting any already-enabled
+ * capabilities
+ * TODO: SASL Reauthentication
+ */
+ ptr_cap_option = IRC_SERVER_OPTION_STRING(
+ server,
+ IRC_SERVER_OPTION_CAPABILITIES);
+ length = ((ptr_cap_option && ptr_cap_option[0]) ?
+ strlen (ptr_cap_option) : 0) + 16;
+ cap_option = malloc (length);
+ cap_req = malloc (length);
+ if (cap_option && cap_req)
+ {
+ cap_option[0] = '\0';
+ if (ptr_cap_option && ptr_cap_option[0])
+ strcat (cap_option, ptr_cap_option);
+ cap_req[0] = '\0';
+ caps_requested = weechat_string_split (cap_option, ",", 0, 0,
+ &num_caps_requested);
+ caps_added = weechat_string_split (ptr_caps, " ", 0, 0,
+ &num_caps_added);
+ if (caps_requested && caps_added)
+ {
+ for (i = 0; i < num_caps_requested; i++)
+ {
+ for (j = 0; j < num_caps_added; j++)
+ {
+ if (weechat_strcasecmp (caps_requested[i],
+ caps_added[j]) == 0)
+ {
+ if (cap_req[0])
+ strcat (cap_req, " ");
+ strcat (cap_req, caps_added[j]);
+ }
+ }
+ }
+ }
+ if (caps_requested)
+ weechat_string_free_split (caps_requested);
+ if (caps_added)
+ weechat_string_free_split (caps_added);
+ if (cap_req[0])
+ {
+ weechat_printf (
+ server->buffer,
+ _("%s%s: client capability, requesting: %s"),
+ weechat_prefix ("network"), IRC_PLUGIN_NAME,
+ cap_req);
+ irc_server_sendf (server, 0, NULL,
+ "CAP REQ :%s", cap_req);
+ }
+ }
+ if (cap_option)
+ free (cap_option);
+ if (cap_req)
+ free (cap_req);
+ }
+ }
+ else if (strcmp (argv[3], "DEL") == 0)
+ {
+ if (argc > 4)
+ {
+ ptr_caps = (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4];
+ weechat_printf_date_tags (
+ server->buffer, date, NULL,
+ _("%s%s: client capability, removed: %s"),
+ weechat_prefix ("network"), IRC_PLUGIN_NAME, ptr_caps);
+ caps_removed = weechat_string_split (ptr_caps, " ", 0, 0,
+ &num_caps_removed);
+ if (caps_removed)
+ {
+ for (i = 0; i < num_caps_removed; i++)
+ {
+ if (strcmp (caps_removed[i], "away-notify") == 0)
+ {
+ server->cap_away_notify = 0;
+ }
+ else if (strcmp (caps_removed[i], "account-notify") == 0)
+ {
+ server->cap_account_notify = 0;
+ }
+ }
+ weechat_string_free_split (caps_removed);
+ }
+ }
+ }
return WEECHAT_RC_OK;
}
@@ -648,7 +767,7 @@ IRC_PROTOCOL_CALLBACK(invite)
*
* With extended-join capability:
* :nick!user@host JOIN :#channel * :real name
- * *nick!user@host JOIN :#channel account :real name
+ * :nick!user@host JOIN :#channel account :real name
*/
IRC_PROTOCOL_CALLBACK(join)
@@ -743,7 +862,8 @@ IRC_PROTOCOL_CALLBACK(join)
/* add nick in channel */
ptr_nick = irc_nick_new (server, ptr_channel, nick, address, NULL, 0,
- (pos_account) ? pos_account : "*");
+ (pos_account) ? pos_account : NULL,
+ (pos_realname) ? pos_realname : NULL);
/* rename the nick if it was in list with a different case */
irc_channel_nick_speaking_rename_if_present (server, ptr_channel, nick);
@@ -915,7 +1035,7 @@ IRC_PROTOCOL_CALLBACK(kick)
IRC_SERVER_OPTION_AUTOREJOIN_DELAY) * 1000,
0, 1,
&irc_channel_autorejoin_cb,
- ptr_channel);
+ ptr_channel, NULL);
}
}
@@ -1179,7 +1299,7 @@ IRC_PROTOCOL_CALLBACK(nick)
/* temporary disable hotlist */
weechat_buffer_set (NULL, "hotlist", "-");
- /* set host for nick if needed */
+ /* set host in nick if needed */
if (!ptr_nick->host)
ptr_nick->host = strdup (address);
@@ -4068,7 +4188,7 @@ IRC_PROTOCOL_CALLBACK(352)
ptr_nick = (ptr_channel) ?
irc_nick_search (server, ptr_channel, argv[7]) : NULL;
- /* update host for nick */
+ /* update host in nick */
if (ptr_nick)
{
if (ptr_nick->host)
@@ -4079,13 +4199,22 @@ IRC_PROTOCOL_CALLBACK(352)
snprintf (ptr_nick->host, length, "%s@%s", argv[4], argv[5]);
}
- /* update away flag for nick */
+ /* update away flag in nick */
if (ptr_channel && ptr_nick && pos_attr)
{
irc_nick_set_away (server, ptr_channel, ptr_nick,
(pos_attr[0] == 'G') ? 1 : 0);
}
+ /* update realname in nick */
+ if (ptr_channel && ptr_nick && pos_realname)
+ {
+ if (ptr_nick->realname)
+ free (ptr_nick->realname);
+ ptr_nick->realname = (pos_realname && server->cap_extended_join) ?
+ strdup (pos_realname) : NULL;
+ }
+
/* display output of who (manual who from user) */
if (!ptr_channel || (ptr_channel->checking_whox <= 0))
{
@@ -4196,7 +4325,7 @@ IRC_PROTOCOL_CALLBACK(353)
if (ptr_channel && ptr_channel->nicks)
{
if (!irc_nick_new (server, ptr_channel, nickname, pos_host,
- prefixes, 0, "*"))
+ prefixes, 0, NULL, NULL))
{
weechat_printf (
server->buffer,
@@ -4291,7 +4420,7 @@ IRC_PROTOCOL_CALLBACK(354)
ptr_nick = (ptr_channel) ?
irc_nick_search (server, ptr_channel, argv[7]) : NULL;
- /* update host for nick */
+ /* update host in nick */
if (ptr_nick)
{
if (ptr_nick->host)
@@ -4305,7 +4434,7 @@ IRC_PROTOCOL_CALLBACK(354)
snprintf (ptr_nick->host, length, "%s@%s", argv[4], argv[5]);
}
- /* update away flag for nick */
+ /* update away flag in nick */
if (ptr_channel && ptr_nick)
{
if (pos_attr
@@ -4326,14 +4455,24 @@ IRC_PROTOCOL_CALLBACK(354)
}
}
- /* update account flag for nick */
+ /* update account flag in nick */
if (ptr_nick)
{
if (ptr_nick->account)
free (ptr_nick->account);
ptr_nick->account = (ptr_channel && pos_account
&& server->cap_account_notify) ?
- strdup (pos_account) : strdup ("*");
+ strdup (pos_account) : NULL;
+ }
+
+ /* update realname in nick */
+ if (ptr_nick)
+ {
+ if (ptr_nick->realname)
+ free (ptr_nick->realname);
+ ptr_nick->realname = (ptr_channel && pos_realname
+ && server->cap_extended_join) ?
+ strdup (pos_realname) : NULL;
}
/* display output of who (manual who from user) */
@@ -4912,6 +5051,74 @@ IRC_PROTOCOL_CALLBACK(438)
}
/*
+ * Callback for the IRC message "470": forwarding to another channel.
+ *
+ * Message looks like:
+ * :server 470 mynick #channel ##channel :Forwarding to another channel
+ */
+
+IRC_PROTOCOL_CALLBACK(470)
+{
+ struct t_gui_buffer *ptr_buffer;
+ struct t_gui_lines *own_lines;
+ const char *buffer_name, *short_name, *localvar_channel;
+ int lines_count;
+
+ irc_protocol_cb_generic_error (server,
+ date, nick, address, host, command,
+ ignored, argc, argv, argv_eol);
+
+ if ((argc >= 5) && !irc_channel_search (server, argv[3]))
+ {
+ ptr_buffer = irc_channel_search_buffer (server,
+ IRC_CHANNEL_TYPE_CHANNEL,
+ argv[3]);
+ if (ptr_buffer)
+ {
+ short_name = weechat_buffer_get_string (ptr_buffer, "short_name");
+ localvar_channel = weechat_buffer_get_string (ptr_buffer,
+ "localvar_channel");
+ if (!short_name
+ || (localvar_channel
+ && (strcmp (localvar_channel, short_name) == 0)))
+ {
+ /*
+ * update the short_name only if it was not changed by the
+ * user
+ */
+ weechat_buffer_set (ptr_buffer, "short_name", argv[4]);
+ }
+ buffer_name = irc_buffer_build_name (server->name, argv[4]);
+ weechat_buffer_set (ptr_buffer, "name", buffer_name);
+ weechat_buffer_set (ptr_buffer, "localvar_set_channel", argv[4]);
+
+ /*
+ * check if logger backlog should be displayed for the new channel
+ * name: it is displayed only if the buffer is currently completely
+ * empty (no messages at all)
+ */
+ lines_count = 0;
+ own_lines = weechat_hdata_pointer (weechat_hdata_get ("buffer"),
+ ptr_buffer, "own_lines");
+ if (own_lines)
+ {
+ lines_count = weechat_hdata_integer (
+ weechat_hdata_get ("lines"),
+ own_lines, "lines_count");
+ }
+ if (lines_count == 0)
+ {
+ (void) weechat_hook_signal_send ("logger_backlog",
+ WEECHAT_HOOK_SIGNAL_POINTER,
+ ptr_buffer);
+ }
+ }
+ }
+
+ return WEECHAT_RC_OK;
+}
+
+/*
* Callback for the IRC message "728": quietlist.
*
* Message looks like:
@@ -5177,8 +5384,13 @@ IRC_PROTOCOL_CALLBACK(733)
IRC_PROTOCOL_CALLBACK(734)
{
+ char *pos_args;
+
IRC_PROTOCOL_MIN_ARGS(5);
+ pos_args = (argc > 5) ?
+ ((argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5]) : NULL;
+
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
server, NULL, command, "monitor", NULL),
@@ -5186,7 +5398,7 @@ IRC_PROTOCOL_CALLBACK(734)
irc_protocol_tags (command, "irc_numeric", NULL, NULL),
"%s%s (%s)",
weechat_prefix ("error"),
- (argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5],
+ (pos_args && pos_args[0]) ? pos_args : "",
argv[3]);
return WEECHAT_RC_OK;
@@ -5324,8 +5536,7 @@ irc_protocol_get_message_tags (const char *tags)
hashtable = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
if (!hashtable)
return NULL;
@@ -5544,7 +5755,7 @@ irc_protocol_recv_command (struct t_irc_server *server,
{ "464", /* password incorrect */ 1, 0, &irc_protocol_cb_generic_error },
{ "465", /* you are banned from this server */ 1, 0, &irc_protocol_cb_generic_error },
{ "467", /* channel key already set */ 1, 0, &irc_protocol_cb_generic_error },
- { "470", /* forwarding to another channel */ 1, 0, &irc_protocol_cb_generic_error },
+ { "470", /* forwarding to another channel */ 1, 0, &irc_protocol_cb_470 },
{ "471", /* channel is already full */ 1, 0, &irc_protocol_cb_generic_error },
{ "472", /* unknown mode char to me */ 1, 0, &irc_protocol_cb_generic_error },
{ "473", /* cannot join channel (invite only) */ 1, 0, &irc_protocol_cb_generic_error },
diff --git a/src/plugins/irc/irc-protocol.h b/src/plugins/irc/irc-protocol.h
index c1f88d0d5..186a0729b 100644
--- a/src/plugins/irc/irc-protocol.h
+++ b/src/plugins/irc/irc-protocol.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-raw.c b/src/plugins/irc/irc-raw.c
index 598e2abee..fb560eea6 100644
--- a/src/plugins/irc/irc-raw.c
+++ b/src/plugins/irc/irc-raw.c
@@ -1,7 +1,7 @@
/*
* irc-raw.c - functions for IRC raw data messages
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -72,9 +72,10 @@ irc_raw_open (int switch_to_buffer)
IRC_RAW_BUFFER_NAME);
if (!irc_raw_buffer)
{
- irc_raw_buffer = weechat_buffer_new (IRC_RAW_BUFFER_NAME,
- &irc_input_data_cb, NULL,
- &irc_buffer_close_cb, NULL);
+ irc_raw_buffer = weechat_buffer_new (
+ IRC_RAW_BUFFER_NAME,
+ &irc_input_data_cb, NULL, NULL,
+ &irc_buffer_close_cb, NULL, NULL);
/* failed to create buffer ? then return */
if (!irc_raw_buffer)
@@ -229,71 +230,85 @@ irc_raw_message_add (struct t_irc_server *server, int flags,
int pos_buf, pos_buf2, char_size, i;
struct t_irc_raw_message *new_raw_message;
- buf = weechat_iconv_to_internal (NULL, message);
- buf2 = malloc ((strlen (buf) * 4) + 1);
- if (buf2)
+ buf = NULL;
+ buf2 = NULL;
+
+ if (flags & IRC_RAW_FLAG_BINARY)
+ {
+ buf = weechat_string_hex_dump (message, strlen (message), 16,
+ " > ", NULL);
+ snprintf (prefix, sizeof (prefix), " ");
+ }
+ else
{
- ptr_buf = (buf) ? (unsigned char *)buf : (unsigned char *)message;
- pos_buf = 0;
- pos_buf2 = 0;
- while (ptr_buf[pos_buf])
+ buf = weechat_iconv_to_internal (NULL, message);
+ buf2 = malloc ((strlen (buf) * 4) + 1);
+ if (buf2)
{
- if (ptr_buf[pos_buf] < 32)
+ ptr_buf = (buf) ? (unsigned char *)buf : (unsigned char *)message;
+ pos_buf = 0;
+ pos_buf2 = 0;
+ while (ptr_buf[pos_buf])
{
- buf2[pos_buf2++] = '\\';
- buf2[pos_buf2++] = 'x';
- buf2[pos_buf2++] = hexa[ptr_buf[pos_buf] / 16];
- buf2[pos_buf2++] = hexa[ptr_buf[pos_buf] % 16];
- pos_buf++;
- }
- else
- {
- char_size = weechat_utf8_char_size ((const char *)(ptr_buf + pos_buf));
- for (i = 0; i < char_size; i++)
+ if ((ptr_buf[pos_buf] < 32)
+ || !weechat_utf8_is_valid ((const char *)(ptr_buf + pos_buf),
+ 1, NULL))
{
- buf2[pos_buf2++] = ptr_buf[pos_buf++];
+ buf2[pos_buf2++] = '\\';
+ buf2[pos_buf2++] = 'x';
+ buf2[pos_buf2++] = hexa[ptr_buf[pos_buf] / 16];
+ buf2[pos_buf2++] = hexa[ptr_buf[pos_buf] % 16];
+ pos_buf++;
+ }
+ else
+ {
+ char_size = weechat_utf8_char_size ((const char *)(ptr_buf + pos_buf));
+ for (i = 0; i < char_size; i++)
+ {
+ buf2[pos_buf2++] = ptr_buf[pos_buf++];
+ }
}
}
+ buf2[pos_buf2] = '\0';
}
- buf2[pos_buf2] = '\0';
- }
- /* build prefix with arrow */
- prefix_arrow[0] = '\0';
- switch (flags & (IRC_RAW_FLAG_RECV | IRC_RAW_FLAG_SEND
- | IRC_RAW_FLAG_MODIFIED | IRC_RAW_FLAG_REDIRECT))
- {
- case IRC_RAW_FLAG_RECV:
- strcpy (prefix_arrow, IRC_RAW_PREFIX_RECV);
- break;
- case IRC_RAW_FLAG_RECV | IRC_RAW_FLAG_MODIFIED:
- strcpy (prefix_arrow, IRC_RAW_PREFIX_RECV_MODIFIED);
- break;
- case IRC_RAW_FLAG_RECV | IRC_RAW_FLAG_REDIRECT:
- strcpy (prefix_arrow, IRC_RAW_PREFIX_RECV_REDIRECT);
- break;
- case IRC_RAW_FLAG_SEND:
- strcpy (prefix_arrow, IRC_RAW_PREFIX_SEND);
- break;
- case IRC_RAW_FLAG_SEND | IRC_RAW_FLAG_MODIFIED:
- strcpy (prefix_arrow, IRC_RAW_PREFIX_SEND_MODIFIED);
- break;
- default:
- if (flags & IRC_RAW_FLAG_RECV)
+ /* build prefix with arrow */
+ prefix_arrow[0] = '\0';
+ switch (flags & (IRC_RAW_FLAG_RECV | IRC_RAW_FLAG_SEND
+ | IRC_RAW_FLAG_MODIFIED | IRC_RAW_FLAG_REDIRECT))
+ {
+ case IRC_RAW_FLAG_RECV:
strcpy (prefix_arrow, IRC_RAW_PREFIX_RECV);
- else
+ break;
+ case IRC_RAW_FLAG_RECV | IRC_RAW_FLAG_MODIFIED:
+ strcpy (prefix_arrow, IRC_RAW_PREFIX_RECV_MODIFIED);
+ break;
+ case IRC_RAW_FLAG_RECV | IRC_RAW_FLAG_REDIRECT:
+ strcpy (prefix_arrow, IRC_RAW_PREFIX_RECV_REDIRECT);
+ break;
+ case IRC_RAW_FLAG_SEND:
strcpy (prefix_arrow, IRC_RAW_PREFIX_SEND);
- break;
- }
+ break;
+ case IRC_RAW_FLAG_SEND | IRC_RAW_FLAG_MODIFIED:
+ strcpy (prefix_arrow, IRC_RAW_PREFIX_SEND_MODIFIED);
+ break;
+ default:
+ if (flags & IRC_RAW_FLAG_RECV)
+ strcpy (prefix_arrow, IRC_RAW_PREFIX_RECV);
+ else
+ strcpy (prefix_arrow, IRC_RAW_PREFIX_SEND);
+ break;
+ }
- snprintf (prefix, sizeof (prefix), "%s%s%s%s%s",
- (server) ? weechat_color ("chat_server") : "",
- (server) ? server->name : "",
- (server) ? " " : "",
- (flags & IRC_RAW_FLAG_SEND) ?
- weechat_color ("chat_prefix_quit") :
- weechat_color ("chat_prefix_join"),
- prefix_arrow);
+ snprintf (prefix, sizeof (prefix), "%s%s%s%s%s",
+ (flags & IRC_RAW_FLAG_SEND) ?
+ weechat_color ("chat_prefix_quit") :
+ weechat_color ("chat_prefix_join"),
+ prefix_arrow,
+ (server) ? weechat_color ("chat_server") : "",
+ (server) ? " " : "",
+ (server) ? server->name : "");
+ }
new_raw_message = irc_raw_message_add_to_list (time (NULL),
prefix,
@@ -332,6 +347,20 @@ irc_raw_print (struct t_irc_server *server, int flags,
if (weechat_config_integer (irc_config_look_raw_messages) == 0)
irc_raw_message_free (new_raw_message);
}
+
+ if (weechat_irc_plugin->debug >= 2)
+ {
+ new_raw_message = irc_raw_message_add (server,
+ flags | IRC_RAW_FLAG_BINARY,
+ message);
+ if (new_raw_message)
+ {
+ if (irc_raw_buffer)
+ irc_raw_message_print (new_raw_message);
+ if (weechat_config_integer (irc_config_look_raw_messages) == 0)
+ irc_raw_message_free (new_raw_message);
+ }
+ }
}
/*
diff --git a/src/plugins/irc/irc-raw.h b/src/plugins/irc/irc-raw.h
index 0dc25d0ba..6d9b23d78 100644
--- a/src/plugins/irc/irc-raw.h
+++ b/src/plugins/irc/irc-raw.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -32,6 +32,7 @@
#define IRC_RAW_FLAG_SEND 2
#define IRC_RAW_FLAG_MODIFIED 4
#define IRC_RAW_FLAG_REDIRECT 8
+#define IRC_RAW_FLAG_BINARY 16
struct t_irc_raw_message
{
diff --git a/src/plugins/irc/irc-redirect.c b/src/plugins/irc/irc-redirect.c
index 576d6fd24..ab88a4469 100644
--- a/src/plugins/irc/irc-redirect.c
+++ b/src/plugins/irc/irc-redirect.c
@@ -1,7 +1,7 @@
/*
* irc-redirect.c - redirection of IRC command output
*
- * Copyright (C) 2010-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2010-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -436,8 +436,7 @@ irc_redirect_new_with_commands (struct t_irc_server *server,
hash_cmd[i] = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_INTEGER,
- NULL,
- NULL);
+ NULL, NULL);
for (j = 0; j < num_items[i]; j++)
{
if (i < 3)
@@ -732,8 +731,7 @@ irc_redirect_stop (struct t_irc_redirect *redirect, const char *error)
hashtable = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
if (hashtable)
{
/* set error and output (main fields) */
@@ -993,11 +991,13 @@ irc_redirect_free_all (struct t_irc_server *server)
*/
struct t_hdata *
-irc_redirect_hdata_redirect_pattern_cb (void *data, const char *hdata_name)
+irc_redirect_hdata_redirect_pattern_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = weechat_hdata_new (hdata_name, "prev_redirect", "next_redirect",
@@ -1023,11 +1023,13 @@ irc_redirect_hdata_redirect_pattern_cb (void *data, const char *hdata_name)
*/
struct t_hdata *
-irc_redirect_hdata_redirect_cb (void *data, const char *hdata_name)
+irc_redirect_hdata_redirect_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = weechat_hdata_new (hdata_name, "prev_redirect", "next_redirect",
@@ -1237,7 +1239,8 @@ irc_redirect_print_log (struct t_irc_server *server)
*/
int
-irc_redirect_pattern_hsignal_cb (void *data, const char *signal,
+irc_redirect_pattern_hsignal_cb (const void *pointer, void *data,
+ const char *signal,
struct t_hashtable *hashtable)
{
const char *pattern, *str_timeout, *cmd_start, *cmd_stop, *cmd_extra;
@@ -1245,6 +1248,7 @@ irc_redirect_pattern_hsignal_cb (void *data, const char *signal,
int number, timeout;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
@@ -1301,7 +1305,8 @@ irc_redirect_pattern_hsignal_cb (void *data, const char *signal,
*/
int
-irc_redirect_command_hsignal_cb (void *data, const char *signal,
+irc_redirect_command_hsignal_cb (const void *pointer, void *data,
+ const char *signal,
struct t_hashtable *hashtable)
{
const char *server, *pattern, *redirect_signal, *str_count, *string;
@@ -1311,6 +1316,7 @@ irc_redirect_command_hsignal_cb (void *data, const char *signal,
int number, count, timeout;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
diff --git a/src/plugins/irc/irc-redirect.h b/src/plugins/irc/irc-redirect.h
index b78db090a..632e4e840 100644
--- a/src/plugins/irc/irc-redirect.h
+++ b/src/plugins/irc/irc-redirect.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2010-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -109,9 +109,11 @@ extern int irc_redirect_message (struct t_irc_server *server,
const char *arguments);
extern void irc_redirect_free (struct t_irc_redirect *redirect);
extern void irc_redirect_free_all (struct t_irc_server *server);
-extern struct t_hdata *irc_redirect_hdata_redirect_pattern_cb (void *data,
+extern struct t_hdata *irc_redirect_hdata_redirect_pattern_cb (const void *pointer,
+ void *data,
const char *hdata_name);
-extern struct t_hdata *irc_redirect_hdata_redirect_cb (void *data,
+extern struct t_hdata *irc_redirect_hdata_redirect_cb (const void *pointer,
+ void *data,
const char *hdata_name);
extern int irc_redirect_pattern_add_to_infolist (struct t_infolist *infolist,
struct t_irc_redirect_pattern *redirect_pattern);
@@ -119,9 +121,11 @@ extern int irc_redirect_add_to_infolist (struct t_infolist *infolist,
struct t_irc_redirect *redirect);
extern void irc_redirect_pattern_print_log ();
extern void irc_redirect_print_log (struct t_irc_server *server);
-extern int irc_redirect_pattern_hsignal_cb (void *data, const char *signal,
+extern int irc_redirect_pattern_hsignal_cb (const void *pointer, void *data,
+ const char *signal,
struct t_hashtable *hashtable);
-extern int irc_redirect_command_hsignal_cb (void *data, const char *signal,
+extern int irc_redirect_command_hsignal_cb (const void *pointer, void *data,
+ const char *signal,
struct t_hashtable *hashtable);
extern void irc_redirect_init ();
extern void irc_redirect_end ();
diff --git a/src/plugins/irc/irc-sasl.c b/src/plugins/irc/irc-sasl.c
index 623d12a27..57f4050fc 100644
--- a/src/plugins/irc/irc-sasl.c
+++ b/src/plugins/irc/irc-sasl.c
@@ -1,7 +1,7 @@
/*
* irc-sasl.c - SASL authentication with IRC server
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -343,6 +343,8 @@ irc_sasl_dh (const char *data_base64,
/* decode data */
data = malloc (strlen (data_base64) + 1);
+ if (!data)
+ goto dhend;
length_data = weechat_string_decode_base64 (data_base64, data);
ptr_data = (unsigned char *)data;
diff --git a/src/plugins/irc/irc-sasl.h b/src/plugins/irc/irc-sasl.h
index 2677f5247..d3b61ddd9 100644
--- a/src/plugins/irc/irc-sasl.h
+++ b/src/plugins/irc/irc-sasl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index 83759ee53..aa09d47c9 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -1,7 +1,7 @@
/*
* irc-server.c - I/O communication with IRC servers
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2005-2010 Emmanuel Bouthenot <kolter@openics.org>
* Copyright (C) 2012 Simon Arlott
*
@@ -40,6 +40,8 @@
#include <netdb.h>
#include <arpa/inet.h>
#include <netinet/in.h>
+#include <arpa/nameser.h>
+#include <resolv.h>
#ifdef HAVE_GNUTLS
#include <gnutls/gnutls.h>
@@ -75,44 +77,45 @@ char *irc_server_sasl_fail_string[IRC_SERVER_NUM_SASL_FAIL] =
{ "continue", "reconnect", "disconnect" };
char *irc_server_options[IRC_SERVER_NUM_OPTIONS][2] =
-{ { "addresses", "" },
- { "proxy", "" },
- { "ipv6", "on" },
- { "ssl", "off" },
- { "ssl_cert", "" },
- { "ssl_priorities", "NORMAL:-VERS-SSL3.0" },
- { "ssl_dhkey_size", "2048" },
- { "ssl_fingerprint", "" },
- { "ssl_verify", "on" },
- { "password", "" },
- { "capabilities", "" },
- { "sasl_mechanism", "plain" },
- { "sasl_username", "" },
- { "sasl_password", "" },
- { "sasl_key", "", },
- { "sasl_timeout", "15" },
- { "sasl_fail", "continue" },
- { "autoconnect", "off" },
- { "autoreconnect", "on" },
- { "autoreconnect_delay", "10" },
- { "nicks", "" },
- { "username", "" },
- { "realname", "" },
- { "local_hostname", "" },
- { "command", "" },
- { "command_delay", "0" },
- { "autojoin", "" },
- { "autorejoin", "off" },
- { "autorejoin_delay", "30" },
- { "connection_timeout", "60" },
- { "anti_flood_prio_high", "2" },
- { "anti_flood_prio_low", "2" },
- { "away_check", "0" },
- { "away_check_max_nicks", "25" },
- { "default_msg_kick", "" },
- { "default_msg_part", "WeeChat %v" },
- { "default_msg_quit", "WeeChat %v" },
- { "notify", "" },
+{ { "addresses", "" },
+ { "proxy", "" },
+ { "ipv6", "on" },
+ { "ssl", "off" },
+ { "ssl_cert", "" },
+ { "ssl_priorities", "NORMAL:-VERS-SSL3.0" },
+ { "ssl_dhkey_size", "2048" },
+ { "ssl_fingerprint", "" },
+ { "ssl_verify", "on" },
+ { "password", "" },
+ { "capabilities", "" },
+ { "sasl_mechanism", "plain" },
+ { "sasl_username", "" },
+ { "sasl_password", "" },
+ { "sasl_key", "", },
+ { "sasl_timeout", "15" },
+ { "sasl_fail", "continue" },
+ { "autoconnect", "off" },
+ { "autoreconnect", "on" },
+ { "autoreconnect_delay", "10" },
+ { "nicks", "" },
+ { "nicks_alternate", "on" },
+ { "username", "" },
+ { "realname", "" },
+ { "local_hostname", "" },
+ { "command", "" },
+ { "command_delay", "0" },
+ { "autojoin", "" },
+ { "autorejoin", "off" },
+ { "autorejoin_delay", "30" },
+ { "connection_timeout", "60" },
+ { "anti_flood_prio_high", "2" },
+ { "anti_flood_prio_low", "2" },
+ { "away_check", "0" },
+ { "away_check_max_nicks", "25" },
+ { "msg_kick", "" },
+ { "msg_part", "WeeChat ${info:version}" },
+ { "msg_quit", "WeeChat ${info:version}" },
+ { "notify", "" },
};
char *irc_server_casemapping_string[IRC_SERVER_NUM_CASEMAPPING] =
@@ -407,7 +410,7 @@ void
irc_server_set_addresses (struct t_irc_server *server, const char *addresses)
{
int i;
- char *pos, *error;
+ char *pos, *error, *addresses_eval;
long number;
/* free data */
@@ -431,8 +434,11 @@ irc_server_set_addresses (struct t_irc_server *server, const char *addresses)
/* set new addresses/ports */
if (addresses && addresses[0])
{
+ addresses_eval = weechat_string_eval_expression (addresses,
+ NULL, NULL, NULL);
server->addresses_array = weechat_string_split (
- addresses, ",", 0, 0, &server->addresses_count);
+ (addresses_eval) ? addresses_eval : addresses,
+ ",", 0, 0, &server->addresses_count);
server->ports_array = malloc (
server->addresses_count * sizeof (server->ports_array[0]));
server->retry_array = malloc (
@@ -455,6 +461,8 @@ irc_server_set_addresses (struct t_irc_server *server, const char *addresses)
}
server->retry_array[i] = 0;
}
+ if (addresses_eval)
+ free (addresses_eval);
}
}
@@ -624,8 +632,8 @@ irc_server_get_alternate_nick (struct t_irc_server *server)
/* now we have tried all nicks in list */
- /* if alternate nick is disabled, just return NULL */
- if (!weechat_config_boolean (irc_config_network_alternate_nick))
+ /* if alternate nicks are disabled, just return NULL */
+ if (!IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_NICKS_ALTERNATE))
return NULL;
/* use main nick and we will add "_" and then number if needed */
@@ -884,7 +892,7 @@ irc_server_get_prefix_mode_for_char (struct t_irc_server *server,
*
* For example mode 'o' can return '@'.
*
- * Returns return ' ' (space) if mode is not found.
+ * Returns a space if mode is not found.
*/
char
@@ -944,6 +952,55 @@ irc_server_prefix_char_statusmsg (struct t_irc_server *server,
}
/*
+ * Gets an evaluated default_msg server option: replaces "%v" by WeeChat
+ * version if there's no ${...} in string, or just evaluates the string.
+ *
+ * Note: result must be freed after use.
+ */
+
+char *
+irc_server_get_default_msg (const char *default_msg,
+ struct t_irc_server *server,
+ const char *channel_name)
+{
+ const char *version;
+ struct t_hashtable *extra_vars;
+ char *msg;
+
+ /*
+ * "%v" for version is deprecated since WeeChat 1.6, where
+ * an expression ${info:version} is preferred, so we replace
+ * the "%v" with version only if there's no "${...}" in string
+ */
+ if (strstr (default_msg, "%v") && !strstr (default_msg, "${"))
+ {
+ version = weechat_info_get ("version", "");
+ return weechat_string_replace (default_msg, "%v",
+ (version) ? version : "");
+ }
+
+ extra_vars = weechat_hashtable_new (32,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_POINTER,
+ NULL,
+ NULL);
+ if (extra_vars)
+ {
+ weechat_hashtable_set (extra_vars, "server", server->name);
+ weechat_hashtable_set (extra_vars, "channel",
+ (channel_name) ? channel_name : "");
+ weechat_hashtable_set (extra_vars, "nick", server->nick);
+ }
+
+ msg = weechat_string_eval_expression (default_msg, NULL, extra_vars, NULL);
+
+ if (extra_vars)
+ weechat_hashtable_free (extra_vars);
+
+ return msg;
+}
+
+/*
* Allocates a new server and adds it to the servers queue.
*
* Returns pointer to new server, NULL if error.
@@ -1011,6 +1068,7 @@ irc_server_alloc (const char *name)
new_server->nick_modes = NULL;
new_server->cap_away_notify = 0;
new_server->cap_account_notify = 0;
+ new_server->cap_extended_join = 0;
new_server->isupport = NULL;
new_server->prefix_modes = NULL;
new_server->prefix_chars = NULL;
@@ -1049,21 +1107,21 @@ irc_server_alloc (const char *name)
new_server->notify_list = NULL;
new_server->last_notify = NULL;
new_server->notify_count = 0;
- new_server->join_manual = weechat_hashtable_new (32,
- WEECHAT_HASHTABLE_STRING,
- WEECHAT_HASHTABLE_TIME,
- NULL,
- NULL);
- new_server->join_channel_key = weechat_hashtable_new (32,
- WEECHAT_HASHTABLE_STRING,
- WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
- new_server->join_noswitch = weechat_hashtable_new (32,
- WEECHAT_HASHTABLE_STRING,
- WEECHAT_HASHTABLE_TIME,
- NULL,
- NULL);
+ new_server->join_manual = weechat_hashtable_new (
+ 32,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_TIME,
+ NULL, NULL);
+ new_server->join_channel_key = weechat_hashtable_new (
+ 32,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING,
+ NULL, NULL);
+ new_server->join_noswitch = weechat_hashtable_new (
+ 32,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_TIME,
+ NULL, NULL);
new_server->buffer = NULL;
new_server->buffer_as_string = NULL;
new_server->channels = NULL;
@@ -1073,26 +1131,31 @@ irc_server_alloc (const char *name)
for (i = 0; i < IRC_SERVER_NUM_OPTIONS; i++)
{
length = strlen (new_server->name) + 1 +
- strlen (irc_server_options[i][0]) + 1;
+ strlen (irc_server_options[i][0]) +
+ 512 + /* inherited option name (irc.server_default.xxx) */
+ 1;
option_name = malloc (length);
if (option_name)
{
- snprintf (option_name, length, "%s.%s",
+ snprintf (option_name, length, "%s.%s << irc.server_default.%s",
new_server->name,
+ irc_server_options[i][0],
irc_server_options[i][0]);
- new_server->options[i] =
- irc_config_server_new_option (irc_config_file,
- irc_config_section_server,
- i,
- option_name,
- NULL,
- NULL,
- 1,
- &irc_config_server_check_value_cb,
- irc_server_options[i][0],
- &irc_config_server_change_cb,
- irc_server_options[i][0]);
- irc_config_server_change_cb (irc_server_options[i][0],
+ new_server->options[i] = irc_config_server_new_option (
+ irc_config_file,
+ irc_config_section_server,
+ i,
+ option_name,
+ NULL,
+ NULL,
+ 1,
+ &irc_config_server_check_value_cb,
+ irc_server_options[i][0],
+ NULL,
+ &irc_config_server_change_cb,
+ irc_server_options[i][0],
+ NULL);
+ irc_config_server_change_cb (irc_server_options[i][0], NULL,
new_server->options[i]);
free (option_name);
}
@@ -2278,8 +2341,7 @@ irc_server_sendf (struct t_irc_server *server, int flags, const char *tags,
ret_hashtable = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
}
rc = 1;
@@ -2751,16 +2813,17 @@ irc_server_msgq_flush ()
*/
int
-irc_server_recv_cb (void *data, int fd)
+irc_server_recv_cb (const void *pointer, void *data, int fd)
{
struct t_irc_server *server;
static char buffer[4096 + 2];
int num_read, msgq_flush, end_recv;
/* make C compiler happy */
+ (void) data;
(void) fd;
- server = (struct t_irc_server *)data;
+ server = (struct t_irc_server *)pointer;
if (!server)
return WEECHAT_RC_ERROR;
@@ -2854,14 +2917,16 @@ irc_server_recv_cb (void *data, int fd)
*/
int
-irc_server_timer_connection_cb (void *data, int remaining_calls)
+irc_server_timer_connection_cb (const void *pointer, void *data,
+ int remaining_calls)
{
struct t_irc_server *server;
/* make C compiler happy */
+ (void) data;
(void) remaining_calls;
- server = (struct t_irc_server *)data;
+ server = (struct t_irc_server *)pointer;
if (!server)
return WEECHAT_RC_ERROR;
@@ -2887,15 +2952,16 @@ irc_server_timer_connection_cb (void *data, int remaining_calls)
*/
int
-irc_server_timer_sasl_cb (void *data, int remaining_calls)
+irc_server_timer_sasl_cb (const void *pointer, void *data, int remaining_calls)
{
struct t_irc_server *server;
int sasl_fail;
/* make C compiler happy */
+ (void) data;
(void) remaining_calls;
- server = (struct t_irc_server *)data;
+ server = (struct t_irc_server *)pointer;
if (!server)
return WEECHAT_RC_ERROR;
@@ -2905,7 +2971,7 @@ irc_server_timer_sasl_cb (void *data, int remaining_calls)
if (!server->is_connected)
{
weechat_printf (server->buffer,
- _("%s%s: sasl authentication timeout"),
+ _("%s%s: SASL authentication timeout"),
weechat_prefix ("error"), IRC_PLUGIN_NAME);
sasl_fail = IRC_SERVER_OPTION_INTEGER(server,
IRC_SERVER_OPTION_SASL_FAIL);
@@ -2929,7 +2995,8 @@ irc_server_timer_sasl_cb (void *data, int remaining_calls)
*/
void
-irc_server_check_join_manual_cb (void *data, struct t_hashtable *hashtable,
+irc_server_check_join_manual_cb (void *data,
+ struct t_hashtable *hashtable,
const void *key, const void *value)
{
/* make C compiler happy */
@@ -2945,7 +3012,8 @@ irc_server_check_join_manual_cb (void *data, struct t_hashtable *hashtable,
*/
void
-irc_server_check_join_noswitch_cb (void *data, struct t_hashtable *hashtable,
+irc_server_check_join_noswitch_cb (void *data,
+ struct t_hashtable *hashtable,
const void *key, const void *value)
{
/* make C compiler happy */
@@ -2983,7 +3051,7 @@ irc_server_check_join_smart_filtered_cb (void *data,
*/
int
-irc_server_timer_cb (void *data, int remaining_calls)
+irc_server_timer_cb (const void *pointer, void *data, int remaining_calls)
{
struct t_irc_server *ptr_server;
struct t_irc_channel *ptr_channel;
@@ -2993,6 +3061,7 @@ irc_server_timer_cb (void *data, int remaining_calls)
int away_check;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) remaining_calls;
@@ -3327,7 +3396,13 @@ irc_server_login (struct t_irc_server *server)
server, IRC_SERVER_OPTION_CAPABILITIES);
if (password && password[0])
- irc_server_sendf (server, 0, NULL, "PASS %s", password);
+ {
+ irc_server_sendf (
+ server, 0, NULL,
+ "PASS %s%s",
+ ((password[0] == ':') || (strchr (password, ' '))) ? ":" : "",
+ password);
+ }
if (!server->nick)
{
@@ -3364,7 +3439,7 @@ irc_server_login (struct t_irc_server *server)
IRC_SERVER_OPTION_INTEGER (server, IRC_SERVER_OPTION_CONNECTION_TIMEOUT) * 1000,
0, 1,
&irc_server_timer_connection_cb,
- server);
+ server, NULL);
if (password)
free (password);
@@ -3414,13 +3489,17 @@ irc_server_switch_address (struct t_irc_server *server, int connection)
*/
int
-irc_server_connect_cb (void *data, int status, int gnutls_rc, int sock,
+irc_server_connect_cb (const void *pointer, void *data,
+ int status, int gnutls_rc, int sock,
const char *error, const char *ip_address)
{
struct t_irc_server *server;
const char *proxy;
- server = (struct t_irc_server *)data;
+ /* make C compiler happy */
+ (void) data;
+
+ server = (struct t_irc_server *)pointer;
proxy = IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_PROXY);
@@ -3445,7 +3524,7 @@ irc_server_connect_cb (void *data, int status, int gnutls_rc, int sock,
server->hook_fd = weechat_hook_fd (server->sock,
1, 0, 0,
&irc_server_recv_cb,
- server);
+ server, NULL);
/* login to server */
irc_server_login (server);
break;
@@ -3590,8 +3669,9 @@ irc_server_connect_cb (void *data, int status, int gnutls_rc, int sock,
case WEECHAT_HOOK_CONNECT_MEMORY_ERROR:
weechat_printf (
server->buffer,
- _("%s%s: not enough memory"),
- weechat_prefix ("error"), IRC_PLUGIN_NAME);
+ _("%s%s: not enough memory (%s)"),
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ (error) ? error : "-");
if (error && error[0])
{
weechat_printf (
@@ -3702,8 +3782,8 @@ irc_server_create_buffer (struct t_irc_server *server)
snprintf (buffer_name, sizeof (buffer_name),
"server.%s", server->name);
server->buffer = weechat_buffer_new (buffer_name,
- &irc_input_data_cb, NULL,
- &irc_buffer_close_cb, NULL);
+ &irc_input_data_cb, NULL, NULL,
+ &irc_buffer_close_cb, NULL, NULL);
if (!server->buffer)
return NULL;
@@ -3911,8 +3991,9 @@ irc_server_check_certificate_fingerprint (struct t_irc_server *server,
{
weechat_printf (
server->buffer,
- _("%s%s: not enough memory"),
- weechat_prefix ("error"), IRC_PLUGIN_NAME);
+ _("%s%s: not enough memory (%s)"),
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ "fingerprint");
}
}
@@ -3951,7 +4032,8 @@ irc_server_check_certificate_fingerprint (struct t_irc_server *server,
#ifdef HAVE_GNUTLS
int
-irc_server_gnutls_callback (void *data, gnutls_session_t tls_session,
+irc_server_gnutls_callback (const void *pointer, void *data,
+ gnutls_session_t tls_session,
const gnutls_datum_t *req_ca, int nreq,
const gnutls_pk_algorithm_t *pk_algos,
int pk_algos_len,
@@ -3982,6 +4064,7 @@ irc_server_gnutls_callback (void *data, gnutls_session_t tls_session,
#endif /* LIBGNUTLS_VERSION_NUMBER >= 0x010706 */
/* make C compiler happy */
+ (void) data;
(void) req_ca;
(void) nreq;
(void) pk_algos;
@@ -3989,10 +4072,10 @@ irc_server_gnutls_callback (void *data, gnutls_session_t tls_session,
rc = 0;
- if (!data)
+ if (!pointer)
return -1;
- server = (struct t_irc_server *) data;
+ server = (struct t_irc_server *) pointer;
cert_temp_init = 0;
cert_list = NULL;
cert_list_len = 0;
@@ -4402,8 +4485,9 @@ irc_server_connect (struct t_irc_server *server)
{
weechat_printf (
server->buffer,
- _("%s%s: not enough memory"),
- weechat_prefix ("error"), IRC_PLUGIN_NAME);
+ _("%s%s: not enough memory (%s)"),
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ "proxy");
return 0;
}
snprintf (option_name, length, "weechat.proxy.%s.type", proxy);
@@ -4527,12 +4611,13 @@ irc_server_connect (struct t_irc_server *server)
proxy_type ? weechat_config_integer (proxy_ipv6) : IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_IPV6),
server->current_retry,
(server->ssl_connected) ? &server->gnutls_sess : NULL,
- (server->ssl_connected) ? irc_server_gnutls_callback : NULL,
+ (server->ssl_connected) ? &irc_server_gnutls_callback : NULL,
IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_SSL_DHKEY_SIZE),
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_SSL_PRIORITIES),
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_LOCAL_HOSTNAME),
&irc_server_connect_cb,
- server);
+ server,
+ NULL);
#else
server->hook_connect = weechat_hook_connect (
proxy,
@@ -4543,7 +4628,8 @@ irc_server_connect (struct t_irc_server *server)
NULL, NULL, 0, NULL,
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_LOCAL_HOSTNAME),
&irc_server_connect_cb,
- server);
+ server,
+ NULL);
#endif /* HAVE_GNUTLS */
/* send signal "irc_server_connecting" with server name */
@@ -4578,15 +4664,17 @@ irc_server_reconnect (struct t_irc_server *server)
*/
int
-irc_server_auto_connect_timer_cb (void *data, int remaining_calls)
+irc_server_auto_connect_timer_cb (const void *pointer, void *data,
+ int remaining_calls)
{
struct t_irc_server *ptr_server;
- void *auto_connect;
+ int auto_connect;
/* make C compiler happy */
+ (void) data;
(void) remaining_calls;
- auto_connect = data;
+ auto_connect = (pointer) ? 1 : 0;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
@@ -4612,8 +4700,10 @@ irc_server_auto_connect_timer_cb (void *data, int remaining_calls)
void
irc_server_auto_connect (int auto_connect)
{
- weechat_hook_timer (1, 0, 1, &irc_server_auto_connect_timer_cb,
- (auto_connect) ? (void *)1 : (void *)0);
+ weechat_hook_timer (1, 0, 1,
+ &irc_server_auto_connect_timer_cb,
+ (auto_connect) ? (void *)1 : (void *)0,
+ NULL);
}
/*
@@ -4677,6 +4767,7 @@ irc_server_disconnect (struct t_irc_server *server, int switch_address,
}
server->cap_away_notify = 0;
server->cap_account_notify = 0;
+ server->cap_extended_join = 0;
server->is_away = 0;
server->away_time = 0;
server->lag = 0;
@@ -5008,7 +5099,8 @@ irc_server_set_away (struct t_irc_server *server, const char *nick, int is_away)
*/
int
-irc_server_xfer_send_ready_cb (void *data, const char *signal,
+irc_server_xfer_send_ready_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
struct t_infolist *infolist;
@@ -5020,6 +5112,7 @@ irc_server_xfer_send_ready_cb (void *data, const char *signal,
int spaces_in_name, rc;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -5041,6 +5134,7 @@ irc_server_xfer_send_ready_cb (void *data, const char *signal,
"local_address");
if (local_address)
{
+ res_init ();
rc = getaddrinfo (local_address, NULL, NULL, &ainfo);
if ((rc == 0) && ainfo && ainfo->ai_addr)
{
@@ -5109,7 +5203,8 @@ irc_server_xfer_send_ready_cb (void *data, const char *signal,
*/
int
-irc_server_xfer_resume_ready_cb (void *data, const char *signal,
+irc_server_xfer_resume_ready_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
struct t_infolist *infolist;
@@ -5118,6 +5213,7 @@ irc_server_xfer_resume_ready_cb (void *data, const char *signal,
int spaces_in_name;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -5162,7 +5258,8 @@ irc_server_xfer_resume_ready_cb (void *data, const char *signal,
*/
int
-irc_server_xfer_send_accept_resume_cb (void *data, const char *signal,
+irc_server_xfer_send_accept_resume_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data,
void *signal_data)
{
@@ -5172,6 +5269,7 @@ irc_server_xfer_send_accept_resume_cb (void *data, const char *signal,
int spaces_in_name;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -5213,11 +5311,13 @@ irc_server_xfer_send_accept_resume_cb (void *data, const char *signal,
*/
struct t_hdata *
-irc_server_hdata_server_cb (void *data, const char *hdata_name)
+irc_server_hdata_server_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = weechat_hdata_new (hdata_name, "prev_server", "next_server",
@@ -5260,6 +5360,7 @@ irc_server_hdata_server_cb (void *data, const char *hdata_name)
WEECHAT_HDATA_VAR(struct t_irc_server, nick_modes, STRING, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, cap_away_notify, INTEGER, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, cap_account_notify, INTEGER, 0, NULL, NULL);
+ WEECHAT_HDATA_VAR(struct t_irc_server, cap_extended_join, INTEGER, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, isupport, STRING, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, prefix_modes, STRING, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, prefix_chars, STRING, 0, NULL, NULL);
@@ -5401,6 +5502,9 @@ irc_server_add_to_infolist (struct t_infolist *infolist,
if (!weechat_infolist_new_var_string (ptr_item, "nicks",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_NICKS)))
return 0;
+ if (!weechat_infolist_new_var_integer (ptr_item, "nicks_alternate",
+ IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_NICKS_ALTERNATE)))
+ return 0;
if (!weechat_infolist_new_var_string (ptr_item, "username",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_USERNAME)))
return 0;
@@ -5440,14 +5544,14 @@ irc_server_add_to_infolist (struct t_infolist *infolist,
if (!weechat_infolist_new_var_integer (ptr_item, "away_check_max_nicks",
IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS)))
return 0;
- if (!weechat_infolist_new_var_string (ptr_item, "default_msg_kick",
- IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_DEFAULT_MSG_KICK)))
+ if (!weechat_infolist_new_var_string (ptr_item, "msg_kick",
+ IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_MSG_KICK)))
return 0;
- if (!weechat_infolist_new_var_string (ptr_item, "default_msg_part",
- IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_DEFAULT_MSG_PART)))
+ if (!weechat_infolist_new_var_string (ptr_item, "msg_part",
+ IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_MSG_PART)))
return 0;
- if (!weechat_infolist_new_var_string (ptr_item, "default_msg_quit",
- IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_DEFAULT_MSG_QUIT)))
+ if (!weechat_infolist_new_var_string (ptr_item, "msg_quit",
+ IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_MSG_QUIT)))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "temp_server", server->temp_server))
return 0;
@@ -5479,6 +5583,8 @@ irc_server_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "cap_account_notify", server->cap_account_notify))
return 0;
+ if (!weechat_infolist_new_var_integer (ptr_item, "cap_extended_join", server->cap_extended_join))
+ return 0;
if (!weechat_infolist_new_var_string (ptr_item, "isupport", server->isupport))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "prefix_modes", server->prefix_modes))
@@ -5572,7 +5678,7 @@ irc_server_print_log ()
"on" : "off");
else
weechat_log_printf (" ipv6 . . . . . . . . : %s",
- weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_IPV6]) ?
+ (weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_IPV6])) ?
"on" : "off");
/* ssl */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_SSL]))
@@ -5581,7 +5687,7 @@ irc_server_print_log ()
"on" : "off");
else
weechat_log_printf (" ssl. . . . . . . . . : %s",
- weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_SSL]) ?
+ (weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_SSL])) ?
"on" : "off");
/* ssl_cert */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_SSL_CERT]))
@@ -5618,7 +5724,7 @@ irc_server_print_log ()
"on" : "off");
else
weechat_log_printf (" ssl_verify . . . . . : %s",
- weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_SSL_VERIFY]) ?
+ (weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_SSL_VERIFY])) ?
"on" : "off");
/* password */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_PASSWORD]))
@@ -5672,7 +5778,7 @@ irc_server_print_log ()
"on" : "off");
else
weechat_log_printf (" autoconnect. . . . . : %s",
- weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_AUTOCONNECT]) ?
+ (weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_AUTOCONNECT])) ?
"on" : "off");
/* autoreconnect */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_AUTORECONNECT]))
@@ -5681,7 +5787,7 @@ irc_server_print_log ()
"on" : "off");
else
weechat_log_printf (" autoreconnect. . . . : %s",
- weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_AUTORECONNECT]) ?
+ (weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_AUTORECONNECT])) ?
"on" : "off");
/* autoreconnect_delay */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_AUTORECONNECT_DELAY]))
@@ -5697,6 +5803,15 @@ irc_server_print_log ()
else
weechat_log_printf (" nicks. . . . . . . . : '%s'",
weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_NICKS]));
+ /* nicks_alternate */
+ if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_NICKS_ALTERNATE]))
+ weechat_log_printf (" nicks_alternate. . . : null (%s)",
+ (IRC_SERVER_OPTION_BOOLEAN(ptr_server, IRC_SERVER_OPTION_NICKS_ALTERNATE)) ?
+ "on" : "off");
+ else
+ weechat_log_printf (" nicks_alternate. . . : %s",
+ (weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_NICKS_ALTERNATE])) ?
+ "on" : "off");
/* username */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_USERNAME]))
weechat_log_printf (" username . . . . . . : null ('%s')",
@@ -5744,7 +5859,7 @@ irc_server_print_log ()
"on" : "off");
else
weechat_log_printf (" autorejoin . . . . . : %s",
- weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_AUTOREJOIN]) ?
+ (weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_AUTOREJOIN])) ?
"on" : "off");
/* autorejoin_delay */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_AUTOREJOIN_DELAY]))
@@ -5788,27 +5903,27 @@ irc_server_print_log ()
else
weechat_log_printf (" away_check_max_nicks : %d",
weechat_config_integer (ptr_server->options[IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS]));
- /* default_msg_kick */
- if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_DEFAULT_MSG_KICK]))
- weechat_log_printf (" default_msg_kick . . : null ('%s')",
- IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_DEFAULT_MSG_KICK));
+ /* msg_kick */
+ if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_MSG_KICK]))
+ weechat_log_printf (" msg_kick . . . . . . : null ('%s')",
+ IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_MSG_KICK));
else
- weechat_log_printf (" default_msg_kick . . : '%s'",
- weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_DEFAULT_MSG_KICK]));
- /* default_msg_part */
- if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_DEFAULT_MSG_PART]))
- weechat_log_printf (" default_msg_part . . : null ('%s')",
- IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_DEFAULT_MSG_PART));
+ weechat_log_printf (" msg_kick . . . . . . : '%s'",
+ weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_MSG_KICK]));
+ /* msg_part */
+ if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_MSG_PART]))
+ weechat_log_printf (" msg_part . . . . . . : null ('%s')",
+ IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_MSG_PART));
else
- weechat_log_printf (" default_msg_part . . : '%s'",
- weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_DEFAULT_MSG_PART]));
- /* default_msg_quit */
- if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_DEFAULT_MSG_QUIT]))
- weechat_log_printf (" default_msg_quit . . : null ('%s')",
- IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_DEFAULT_MSG_QUIT));
+ weechat_log_printf (" msg_part . . . . . . : '%s'",
+ weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_MSG_PART]));
+ /* msg_quit */
+ if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_MSG_QUIT]))
+ weechat_log_printf (" msg_quit . . . . . . : null ('%s')",
+ IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_MSG_QUIT));
else
- weechat_log_printf (" default_msg_quit . . : '%s'",
- weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_DEFAULT_MSG_QUIT]));
+ weechat_log_printf (" msg_quit . . . . . . : '%s'",
+ weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_MSG_QUIT]));
/* other server variables */
weechat_log_printf (" temp_server. . . . . : %d", ptr_server->temp_server);
weechat_log_printf (" reloading_from_config: %d", ptr_server->reloaded_from_config);
@@ -5842,6 +5957,7 @@ irc_server_print_log ()
weechat_log_printf (" nick_modes . . . . . : '%s'", ptr_server->nick_modes);
weechat_log_printf (" cap_away_notify. . . : %d", ptr_server->cap_away_notify);
weechat_log_printf (" cap_account_notify . : %d", ptr_server->cap_account_notify);
+ weechat_log_printf (" cap_extended_join. . : %d", ptr_server->cap_extended_join);
weechat_log_printf (" isupport . . . . . . : '%s'", ptr_server->isupport);
weechat_log_printf (" prefix_modes . . . . : '%s'", ptr_server->prefix_modes);
weechat_log_printf (" prefix_chars . . . . : '%s'", ptr_server->prefix_chars);
diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h
index dd650c325..663b0d085 100644
--- a/src/plugins/irc/irc-server.h
+++ b/src/plugins/irc/irc-server.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2012 Simon Arlott
*
* This file is part of WeeChat, the extensible chat client.
@@ -57,13 +57,14 @@ enum t_irc_server_option
IRC_SERVER_OPTION_SASL_MECHANISM,/* mechanism for SASL authentication */
IRC_SERVER_OPTION_SASL_USERNAME, /* username for SASL authentication */
IRC_SERVER_OPTION_SASL_PASSWORD, /* password for SASL authentication */
- IRC_SERVER_OPTION_SASL_KEY, /* key for ECDSA-NIST256P-CHALLENCE */
+ IRC_SERVER_OPTION_SASL_KEY, /* key for ECDSA-NIST256P-CHALLENGE */
IRC_SERVER_OPTION_SASL_TIMEOUT, /* timeout for SASL authentication */
IRC_SERVER_OPTION_SASL_FAIL, /* action on SASL fail */
IRC_SERVER_OPTION_AUTOCONNECT, /* autoconnect to server at startup */
IRC_SERVER_OPTION_AUTORECONNECT, /* autoreconnect when disconnected */
IRC_SERVER_OPTION_AUTORECONNECT_DELAY, /* delay before trying again reco */
IRC_SERVER_OPTION_NICKS, /* nicknames (comma separated list) */
+ IRC_SERVER_OPTION_NICKS_ALTERNATE, /* use alternate nicknames */
IRC_SERVER_OPTION_USERNAME, /* user name */
IRC_SERVER_OPTION_REALNAME, /* real name */
IRC_SERVER_OPTION_LOCAL_HOSTNAME,/* custom local hostname */
@@ -77,9 +78,9 @@ enum t_irc_server_option
IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_LOW, /* anti-flood (low priority) */
IRC_SERVER_OPTION_AWAY_CHECK, /* delay between away checks */
IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS, /* max nicks for away check */
- IRC_SERVER_OPTION_DEFAULT_MSG_KICK, /* default kick message */
- IRC_SERVER_OPTION_DEFAULT_MSG_PART, /* default part message */
- IRC_SERVER_OPTION_DEFAULT_MSG_QUIT, /* default quit message */
+ IRC_SERVER_OPTION_MSG_KICK, /* default kick message */
+ IRC_SERVER_OPTION_MSG_PART, /* default part message */
+ IRC_SERVER_OPTION_MSG_QUIT, /* default quit message */
IRC_SERVER_OPTION_NOTIFY, /* notify list */
/* number of server options */
IRC_SERVER_NUM_OPTIONS,
@@ -186,6 +187,7 @@ struct t_irc_server
char *nick_modes; /* nick modes */
int cap_away_notify; /* 1 if capability away-notify is enabled*/
int cap_account_notify; /* 1 if CAP account-notify is enabled */
+ int cap_extended_join; /* 1 if CAP extended-join is enabled */
char *isupport; /* copy of message 005 (ISUPPORT) */
char *prefix_modes; /* prefix modes from msg 005 (eg "ohv") */
char *prefix_chars; /* prefix chars from msg 005 (eg "@%+") */
@@ -298,6 +300,9 @@ extern char irc_server_get_prefix_char_for_mode (struct t_irc_server *server,
extern const char *irc_server_get_chanmodes (struct t_irc_server *server);
extern int irc_server_prefix_char_statusmsg (struct t_irc_server *server,
char prefix_char);
+extern char *irc_server_get_default_msg (const char *default_msg,
+ struct t_irc_server *server,
+ const char *channel_name);
extern struct t_irc_server *irc_server_alloc (const char *name);
extern struct t_irc_server *irc_server_alloc_with_url (const char *irc_url);
extern void irc_server_apply_command_line_options (struct t_irc_server *server,
@@ -328,9 +333,11 @@ char *irc_server_fingerprint_str_sizes ();
extern int irc_server_connect (struct t_irc_server *server);
extern void irc_server_auto_connect (int auto_connect);
extern void irc_server_autojoin_channels ();
-extern int irc_server_recv_cb (void *data, int fd);
-extern int irc_server_timer_sasl_cb (void *data, int remaining_calls);
-extern int irc_server_timer_cb (void *data, int remaining_calls);
+extern int irc_server_recv_cb (const void *pointer, void *data, int fd);
+extern int irc_server_timer_sasl_cb (const void *pointer, void *data,
+ int remaining_calls);
+extern int irc_server_timer_cb (const void *pointer, void *data,
+ int remaining_calls);
extern void irc_server_outqueue_free_all (struct t_irc_server *server,
int priority);
extern int irc_server_get_channel_count (struct t_irc_server *server);
@@ -345,14 +352,21 @@ extern void irc_server_disconnect (struct t_irc_server *server,
int switch_address, int reconnect);
extern void irc_server_disconnect_all ();
extern void irc_server_free (struct t_irc_server *server);
-extern int irc_server_xfer_send_ready_cb (void *data, const char *signal,
- const char *type_data, void *signal_data);
-extern int irc_server_xfer_resume_ready_cb (void *data, const char *signal,
- const char *type_data, void *signal_data);
-extern int irc_server_xfer_send_accept_resume_cb (void *data, const char *signal,
+extern int irc_server_xfer_send_ready_cb (const void *pointer, void *data,
+ const char *signal,
+ const char *type_data,
+ void *signal_data);
+extern int irc_server_xfer_resume_ready_cb (const void *pointer, void *data,
+ const char *signal,
+ const char *type_data,
+ void *signal_data);
+extern int irc_server_xfer_send_accept_resume_cb (const void *pointer,
+ void *data,
+ const char *signal,
const char *type_data,
void *signal_data);
-extern struct t_hdata *irc_server_hdata_server_cb (void *data,
+extern struct t_hdata *irc_server_hdata_server_cb (const void *pointer,
+ void *data,
const char *hdata_name);
extern int irc_server_add_to_infolist (struct t_infolist *infolist,
struct t_irc_server *server);
diff --git a/src/plugins/irc/irc-upgrade.c b/src/plugins/irc/irc-upgrade.c
index 2169df3bd..e5623eccf 100644
--- a/src/plugins/irc/irc-upgrade.c
+++ b/src/plugins/irc/irc-upgrade.c
@@ -1,7 +1,7 @@
/*
* irc-upgrade.c - save/restore IRC plugin data when upgrading WeeChat
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -224,7 +224,8 @@ irc_upgrade_save ()
int rc;
struct t_upgrade_file *upgrade_file;
- upgrade_file = weechat_upgrade_new (IRC_UPGRADE_FILENAME, 1);
+ upgrade_file = weechat_upgrade_new (IRC_UPGRADE_FILENAME,
+ NULL, NULL, NULL);
if (!upgrade_file)
return 0;
@@ -269,7 +270,7 @@ irc_upgrade_set_buffer_callbacks ()
if (ptr_server)
{
weechat_buffer_set_pointer (ptr_buffer,
- "nickcmp_callback_data",
+ "nickcmp_callback_pointer",
ptr_server);
}
}
@@ -289,7 +290,7 @@ irc_upgrade_set_buffer_callbacks ()
*/
int
-irc_upgrade_read_cb (void *data,
+irc_upgrade_read_cb (const void *pointer, void *data,
struct t_upgrade_file *upgrade_file,
int object_id,
struct t_infolist *infolist)
@@ -306,6 +307,7 @@ irc_upgrade_read_cb (void *data,
struct t_gui_buffer *ptr_buffer;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) upgrade_file;
@@ -354,10 +356,12 @@ irc_upgrade_read_cb (void *data,
if (sock >= 0)
{
irc_upgrade_current_server->sock = sock;
- irc_upgrade_current_server->hook_fd = weechat_hook_fd (irc_upgrade_current_server->sock,
- 1, 0, 0,
- &irc_server_recv_cb,
- irc_upgrade_current_server);
+ irc_upgrade_current_server->hook_fd = weechat_hook_fd (
+ irc_upgrade_current_server->sock,
+ 1, 0, 0,
+ &irc_server_recv_cb,
+ irc_upgrade_current_server,
+ NULL);
}
irc_upgrade_current_server->is_connected = weechat_infolist_integer (infolist, "is_connected");
irc_upgrade_current_server->ssl_connected = weechat_infolist_integer (infolist, "ssl_connected");
@@ -373,6 +377,7 @@ irc_upgrade_read_cb (void *data,
irc_upgrade_current_server->nick_modes = strdup (str);
irc_upgrade_current_server->cap_away_notify = weechat_infolist_integer (infolist, "cap_away_notify");
irc_upgrade_current_server->cap_account_notify = weechat_infolist_integer (infolist, "cap_account_notify");
+ irc_upgrade_current_server->cap_extended_join = weechat_infolist_integer (infolist, "cap_extended_join");
str = weechat_infolist_string (infolist, "isupport");
if (str)
irc_upgrade_current_server->isupport = strdup (str);
@@ -574,7 +579,8 @@ irc_upgrade_read_cb (void *data,
weechat_infolist_string (infolist, "host"),
weechat_infolist_string (infolist, "prefixes"),
weechat_infolist_integer (infolist, "away"),
- weechat_infolist_string (infolist, "account"));
+ weechat_infolist_string (infolist, "account"),
+ weechat_infolist_string (infolist, "realname"));
if (ptr_nick)
{
/*
@@ -732,12 +738,14 @@ irc_upgrade_load ()
irc_upgrade_set_buffer_callbacks ();
- upgrade_file = weechat_upgrade_new (IRC_UPGRADE_FILENAME, 0);
+ upgrade_file = weechat_upgrade_new (IRC_UPGRADE_FILENAME,
+ &irc_upgrade_read_cb, NULL, NULL);
if (!upgrade_file)
return 0;
- rc = weechat_upgrade_read (upgrade_file, &irc_upgrade_read_cb, NULL);
+
+ rc = weechat_upgrade_read (upgrade_file);
+
weechat_upgrade_close (upgrade_file);
return rc;
}
-
diff --git a/src/plugins/irc/irc-upgrade.h b/src/plugins/irc/irc-upgrade.h
index 17da632cd..0c9ab8730 100644
--- a/src/plugins/irc/irc-upgrade.h
+++ b/src/plugins/irc/irc-upgrade.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc.c b/src/plugins/irc/irc.c
index 9222d3f88..a75c9b48a 100644
--- a/src/plugins/irc/irc.c
+++ b/src/plugins/irc/irc.c
@@ -1,7 +1,7 @@
/*
* irc.c - IRC (Internet Relay Chat) plugin for WeeChat
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -64,12 +64,14 @@ int irc_signal_upgrade_received = 0; /* signal "upgrade" received ? */
*/
int
-irc_signal_quit_cb (void *data, const char *signal, const char *type_data,
+irc_signal_quit_cb (const void *pointer, void *data,
+ const char *signal, const char *type_data,
void *signal_data)
{
struct t_irc_server *ptr_server;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
@@ -92,13 +94,15 @@ irc_signal_quit_cb (void *data, const char *signal, const char *type_data,
*/
int
-irc_signal_upgrade_cb (void *data, const char *signal, const char *type_data,
+irc_signal_upgrade_cb (const void *pointer, void *data,
+ const char *signal, const char *type_data,
void *signal_data)
{
struct t_irc_server *ptr_server;
int quit, ssl_disconnected;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -179,21 +183,32 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
/* hook some signals */
irc_debug_init ();
- weechat_hook_signal ("quit", &irc_signal_quit_cb, NULL);
- weechat_hook_signal ("upgrade", &irc_signal_upgrade_cb, NULL);
- weechat_hook_signal ("xfer_send_ready", &irc_server_xfer_send_ready_cb, NULL);
- weechat_hook_signal ("xfer_resume_ready", &irc_server_xfer_resume_ready_cb, NULL);
- weechat_hook_signal ("xfer_send_accept_resume", &irc_server_xfer_send_accept_resume_cb, NULL);
- weechat_hook_signal ("irc_input_send", &irc_input_send_cb, NULL);
+ weechat_hook_signal ("quit",
+ &irc_signal_quit_cb, NULL, NULL);
+ weechat_hook_signal ("upgrade",
+ &irc_signal_upgrade_cb, NULL, NULL);
+ weechat_hook_signal ("xfer_send_ready",
+ &irc_server_xfer_send_ready_cb, NULL, NULL);
+ weechat_hook_signal ("xfer_resume_ready",
+ &irc_server_xfer_resume_ready_cb, NULL, NULL);
+ weechat_hook_signal ("xfer_send_accept_resume",
+ &irc_server_xfer_send_accept_resume_cb, NULL, NULL);
+ weechat_hook_signal ("irc_input_send",
+ &irc_input_send_cb, NULL, NULL);
/* hook hsignals for redirection */
- weechat_hook_hsignal ("irc_redirect_pattern", &irc_redirect_pattern_hsignal_cb, NULL);
- weechat_hook_hsignal ("irc_redirect_command", &irc_redirect_command_hsignal_cb, NULL);
+ weechat_hook_hsignal ("irc_redirect_pattern",
+ &irc_redirect_pattern_hsignal_cb, NULL, NULL);
+ weechat_hook_hsignal ("irc_redirect_command",
+ &irc_redirect_command_hsignal_cb, NULL, NULL);
/* modifiers */
- weechat_hook_modifier ("irc_color_decode", &irc_color_modifier_cb, NULL);
- weechat_hook_modifier ("irc_color_encode", &irc_color_modifier_cb, NULL);
- weechat_hook_modifier ("irc_color_decode_ansi", &irc_color_modifier_cb, NULL);
+ weechat_hook_modifier ("irc_color_decode",
+ &irc_color_modifier_cb, NULL, NULL);
+ weechat_hook_modifier ("irc_color_encode",
+ &irc_color_modifier_cb, NULL, NULL);
+ weechat_hook_modifier ("irc_color_decode_ansi",
+ &irc_color_modifier_cb, NULL, NULL);
/* hook completions */
irc_completion_init ();
@@ -245,7 +260,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
}
irc_hook_timer = weechat_hook_timer (1 * 1000, 0, 0,
- &irc_server_timer_cb, NULL);
+ &irc_server_timer_cb,
+ NULL, NULL);
return WEECHAT_RC_OK;
}
diff --git a/src/plugins/irc/irc.h b/src/plugins/irc/irc.h
index 1ee4d538b..3e4cce9f2 100644
--- a/src/plugins/irc/irc.h
+++ b/src/plugins/irc/irc.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org>
*
* This file is part of WeeChat, the extensible chat client.
diff --git a/src/plugins/javascript/CMakeLists.txt b/src/plugins/javascript/CMakeLists.txt
index 91a56a340..a2911a218 100644
--- a/src/plugins/javascript/CMakeLists.txt
+++ b/src/plugins/javascript/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2015-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/javascript/Makefile.am b/src/plugins/javascript/Makefile.am
index 5a81350f3..983108751 100644
--- a/src/plugins/javascript/Makefile.am
+++ b/src/plugins/javascript/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2015-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/javascript/weechat-js-api.cpp b/src/plugins/javascript/weechat-js-api.cpp
index a5a07c432..4a09b130b 100644
--- a/src/plugins/javascript/weechat-js-api.cpp
+++ b/src/plugins/javascript/weechat-js-api.cpp
@@ -2,7 +2,7 @@
* weechat-js-api.cpp - javascript API functions
*
* Copyright (C) 2013 Koka El Kiwi <kokakiwi@kokakiwi.net>
- * Copyright (C) 2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2015-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -25,13 +25,13 @@
#include <cstdlib>
#include <cstring>
#include <string>
+#include <ctime>
extern "C"
{
#include "../weechat-plugin.h"
#include "../plugin-script.h"
#include "../plugin-script-api.h"
-#include "../plugin-script-callback.h"
}
#include "weechat-js.h"
@@ -718,25 +718,27 @@ API_FUNC(list_free)
}
int
-weechat_js_api_config_reload_cb (void *data, struct t_config_file *config_file)
+weechat_js_api_config_reload_cb (const void *pointer, void *data,
+ struct t_config_file *config_file)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
- rc = (int *)weechat_js_exec (
- (struct t_plugin_script *)script_callback->script,
- WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
- "ss", func_argv);
+ rc = (int *)weechat_js_exec (script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ ptr_function,
+ "ss", func_argv);
if (!rc)
ret = WEECHAT_CONFIG_READ_FILE_NOT_FOUND;
@@ -776,31 +778,32 @@ API_FUNC(config_new)
}
int
-weechat_js_api_config_read_cb (void *data,
+weechat_js_api_config_read_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name, const char *value)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[5];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = API_PTR2STR(section);
func_argv[3] = (option_name) ? (char *)option_name : empty_arg;
func_argv[4] = (value) ? (char *)value : empty_arg;
- rc = (int *)weechat_js_exec (
- (struct t_plugin_script *)script_callback->script,
- WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
- "sssss", func_argv);
+ rc = (int *)weechat_js_exec (script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ ptr_function,
+ "sssss", func_argv);
if (!rc)
ret = WEECHAT_CONFIG_OPTION_SET_ERROR;
@@ -821,28 +824,29 @@ weechat_js_api_config_read_cb (void *data,
}
int
-weechat_js_api_config_section_write_cb (void *data,
+weechat_js_api_config_section_write_cb (const void *pointer, void *data,
struct t_config_file *config_file,
const char *section_name)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = (section_name) ? (char *)section_name : empty_arg;
- rc = (int *)weechat_js_exec (
- (struct t_plugin_script *)script_callback->script,
- WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
- "sss", func_argv);
+ rc = (int *)weechat_js_exec (script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ ptr_function,
+ "sss", func_argv);
if (!rc)
ret = WEECHAT_CONFIG_WRITE_ERROR;
@@ -861,28 +865,29 @@ weechat_js_api_config_section_write_cb (void *data,
}
int
-weechat_js_api_config_section_write_default_cb (void *data,
+weechat_js_api_config_section_write_default_cb (const void *pointer, void *data,
struct t_config_file *config_file,
const char *section_name)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = (section_name) ? (char *)section_name : empty_arg;
- rc = (int *)weechat_js_exec (
- (struct t_plugin_script *)script_callback->script,
- WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
- "sss", func_argv);
+ rc = (int *)weechat_js_exec (script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ ptr_function,
+ "sss", func_argv);
if (!rc)
ret = WEECHAT_CONFIG_WRITE_ERROR;
@@ -901,32 +906,33 @@ weechat_js_api_config_section_write_default_cb (void *data,
}
int
-weechat_js_api_config_section_create_option_cb (void *data,
+weechat_js_api_config_section_create_option_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
const char *value)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[5];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = API_PTR2STR(section);
func_argv[3] = (option_name) ? (char *)option_name : empty_arg;
func_argv[4] = (value) ? (char *)value : empty_arg;
- rc = (int *)weechat_js_exec (
- (struct t_plugin_script *)script_callback->script,
- WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
- "sssss", func_argv);
+ rc = (int *)weechat_js_exec (script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ ptr_function,
+ "sssss", func_argv);
if (!rc)
ret = WEECHAT_CONFIG_OPTION_SET_ERROR;
@@ -947,30 +953,31 @@ weechat_js_api_config_section_create_option_cb (void *data,
}
int
-weechat_js_api_config_section_delete_option_cb (void *data,
+weechat_js_api_config_section_delete_option_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
struct t_config_option *option)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = API_PTR2STR(section);
func_argv[3] = API_PTR2STR(option);
- rc = (int *)weechat_js_exec (
- (struct t_plugin_script *)script_callback->script,
- WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
- "ssss", func_argv);
+ rc = (int *)weechat_js_exec (script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ ptr_function,
+ "ssss", func_argv);
if (!rc)
ret = WEECHAT_CONFIG_OPTION_UNSET_ERROR;
@@ -1059,28 +1066,29 @@ API_FUNC(config_search_section)
}
int
-weechat_js_api_config_option_check_value_cb (void *data,
+weechat_js_api_config_option_check_value_cb (const void *pointer, void *data,
struct t_config_option *option,
const char *value)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(option);
func_argv[2] = (value) ? (char *)value : empty_arg;
- rc = (int *)weechat_js_exec (
- (struct t_plugin_script *)script_callback->script,
- WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
- "sss", func_argv);
+ rc = (int *)weechat_js_exec (script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ ptr_function,
+ "sss", func_argv);
if (!rc)
ret = 0;
@@ -1099,26 +1107,27 @@ weechat_js_api_config_option_check_value_cb (void *data,
}
void
-weechat_js_api_config_option_change_cb (void *data,
+weechat_js_api_config_option_change_cb (const void *pointer, void *data,
struct t_config_option *option)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(option);
- rc = (int *)weechat_js_exec (
- (struct t_plugin_script *)script_callback->script,
- WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
- "ss", func_argv);
+ rc = (int *)weechat_js_exec (script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ ptr_function,
+ "ss", func_argv);
if (func_argv[1])
free (func_argv[1]);
@@ -1129,26 +1138,27 @@ weechat_js_api_config_option_change_cb (void *data,
}
void
-weechat_js_api_config_option_delete_cb (void *data,
+weechat_js_api_config_option_delete_cb (const void *pointer, void *data,
struct t_config_option *option)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(option);
- rc = (int *)weechat_js_exec (
- (struct t_plugin_script *)script_callback->script,
- WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
- "ss", func_argv);
+ rc = (int *)weechat_js_exec (script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ ptr_function,
+ "ss", func_argv);
if (func_argv[1])
free (func_argv[1]);
@@ -1535,9 +1545,7 @@ API_FUNC(config_option_free)
v8::String::Utf8Value option(args[0]);
- plugin_script_api_config_option_free (
- weechat_js_plugin,
- js_current_script,
+ weechat_config_option_free (
(struct t_config_option *)API_STR2PTR(*option));
API_RETURN_OK;
@@ -1549,9 +1557,7 @@ API_FUNC(config_section_free_options)
v8::String::Utf8Value section(args[0]);
- plugin_script_api_config_section_free_options (
- weechat_js_plugin,
- js_current_script,
+ weechat_config_section_free_options (
(struct t_config_section *)API_STR2PTR(*section));
API_RETURN_OK;
@@ -1563,9 +1569,7 @@ API_FUNC(config_section_free)
v8::String::Utf8Value section(args[0]);
- plugin_script_api_config_section_free (
- weechat_js_plugin,
- js_current_script,
+ weechat_config_section_free (
(struct t_config_section *)API_STR2PTR(*section));
API_RETURN_OK;
@@ -1577,10 +1581,7 @@ API_FUNC(config_free)
v8::String::Utf8Value config_file(args[0]);
- plugin_script_api_config_free (
- weechat_js_plugin,
- js_current_script,
- (struct t_config_file *)API_STR2PTR(*config_file));
+ weechat_config_free ((struct t_config_file *)API_STR2PTR(*config_file));
API_RETURN_OK;
}
@@ -1808,30 +1809,32 @@ API_FUNC(log_print)
}
int
-weechat_js_api_hook_command_cb (void *data, struct t_gui_buffer *buffer,
+weechat_js_api_hook_command_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
/* make C++ compiler happy */
(void) argv;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
func_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg;
- rc = (int *)weechat_js_exec (
- (struct t_plugin_script *)script_callback->script,
- WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
- "sss", func_argv);
+ rc = (int *)weechat_js_exec (script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ ptr_function,
+ "sss", func_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@@ -1879,27 +1882,29 @@ API_FUNC(hook_command)
}
int
-weechat_js_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
+weechat_js_api_hook_command_run_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
const char *command)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
func_argv[2] = (command) ? (char *)command : empty_arg;
- rc = (int *)weechat_js_exec (
- (struct t_plugin_script *)script_callback->script,
- WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
- "sss", func_argv);
+ rc = (int *)weechat_js_exec (script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ ptr_function,
+ "sss", func_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@@ -1940,28 +1945,30 @@ API_FUNC(hook_command_run)
}
int
-weechat_js_api_hook_timer_cb (void *data, int remaining_calls)
+weechat_js_api_hook_timer_cb (const void *pointer, void *data,
+ int remaining_calls)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char str_remaining_calls[32], empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (str_remaining_calls, sizeof (str_remaining_calls),
"%d", remaining_calls);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = str_remaining_calls;
- rc = (int *)weechat_js_exec (
- (struct t_plugin_script *)script_callback->script,
- WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
- "ss", func_argv);
+ rc = (int *)weechat_js_exec (script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ ptr_function,
+ "ss", func_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@@ -2005,27 +2012,28 @@ API_FUNC(hook_timer)
}
int
-weechat_js_api_hook_fd_cb (void *data, int fd)
+weechat_js_api_hook_fd_cb (const void *pointer, void *data, int fd)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char str_fd[32], empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (str_fd, sizeof (str_fd), "%d", fd);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = str_fd;
- rc = (int *)weechat_js_exec (
- (struct t_plugin_script *)script_callback->script,
- WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
- "ss", func_argv);
+ rc = (int *)weechat_js_exec (script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ ptr_function,
+ "ss", func_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@@ -2071,30 +2079,50 @@ API_FUNC(hook_fd)
}
int
-weechat_js_api_hook_process_cb (void *data,
+weechat_js_api_hook_process_cb (const void *pointer, void *data,
const char *command, int return_code,
const char *out, const char *err)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[5];
- char empty_arg[1] = { '\0' };
+ char empty_arg[1] = { '\0' }, *result;
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (return_code == WEECHAT_HOOK_PROCESS_CHILD)
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ if (strncmp (command, "func:", 5) == 0)
+ {
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
+
+ result = (char *) weechat_js_exec (script,
+ WEECHAT_SCRIPT_EXEC_STRING,
+ command + 5,
+ "s", func_argv);
+ if (result)
+ {
+ printf ("%s", result);
+ free (result);
+ return 0;
+ }
+ }
+ return 1;
+ }
+ else if (ptr_function && ptr_function[0])
+ {
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (command) ? (char *)command : empty_arg;
func_argv[2] = &return_code;
func_argv[3] = (out) ? (char *)out : empty_arg;
func_argv[4] = (err) ? (char *)err : empty_arg;
- rc = (int *)weechat_js_exec (
- (struct t_plugin_script *)script_callback->script,
- WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
- "ssiss", func_argv);
+ rc = (int *)weechat_js_exec (script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ ptr_function,
+ "ssiss", func_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@@ -2171,36 +2199,38 @@ API_FUNC(hook_process_hashtable)
}
int
-weechat_js_api_hook_connect_cb (void *data, int status, int gnutls_rc,
+weechat_js_api_hook_connect_cb (const void *pointer, void *data,
+ int status, int gnutls_rc,
int sock, const char *error,
const char *ip_address)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[6];
char str_status[32], str_gnutls_rc[32], str_sock[32];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (str_status, sizeof (str_status), "%d", status);
snprintf (str_gnutls_rc, sizeof (str_gnutls_rc), "%d", gnutls_rc);
snprintf (str_sock, sizeof (str_sock), "%d", sock);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = str_status;
func_argv[2] = str_gnutls_rc;
func_argv[3] = str_sock;
func_argv[4] = (ip_address) ? (char *)ip_address : empty_arg;
func_argv[5] = (error) ? (char *)error : empty_arg;
- rc = (int *)weechat_js_exec (
- (struct t_plugin_script *)script_callback->script,
- WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
- "ssssss", func_argv);
+ rc = (int *)weechat_js_exec (script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ ptr_function,
+ "ssssss", func_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@@ -2254,28 +2284,31 @@ API_FUNC(hook_connect)
}
int
-weechat_js_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
+weechat_js_api_hook_print_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
time_t date,
int tags_count, const char **tags,
int displayed, int highlight,
const char *prefix, const char *message)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[8];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
static char timebuffer[64];
int *rc, ret;
/* make C compiler happy */
(void) tags_count;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (timebuffer, sizeof (timebuffer), "%ld", (long int)date);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
func_argv[2] = timebuffer;
func_argv[3] = weechat_string_build_with_split_string (tags, ",");
@@ -2286,11 +2319,10 @@ weechat_js_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
func_argv[6] = (prefix) ? (char *)prefix : empty_arg;
func_argv[7] = (message) ? (char *)message : empty_arg;
- rc = (int *)weechat_js_exec (
- (struct t_plugin_script *)script_callback->script,
- WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
- "ssssiiss", func_argv);
+ rc = (int *)weechat_js_exec (script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ ptr_function,
+ "ssssiiss", func_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@@ -2340,20 +2372,23 @@ API_FUNC(hook_print)
}
int
-weechat_js_api_hook_signal_cb (void *data, const char *signal,
+weechat_js_api_hook_signal_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
static char str_value[64];
int *rc, ret, free_needed;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (signal) ? (char *)signal : empty_arg;
free_needed = 0;
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
@@ -2378,11 +2413,10 @@ weechat_js_api_hook_signal_cb (void *data, const char *signal,
else
func_argv[2] = empty_arg;
- rc = (int *)weechat_js_exec (
- (struct t_plugin_script *)script_callback->script,
- WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
- "sss", func_argv);
+ rc = (int *)weechat_js_exec (script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ ptr_function,
+ "sss", func_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@@ -2459,27 +2493,29 @@ API_FUNC(hook_signal_send)
}
int
-weechat_js_api_hook_hsignal_cb (void *data, const char *signal,
+weechat_js_api_hook_hsignal_cb (const void *pointer, void *data,
+ const char *signal,
struct t_hashtable *hashtable)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (signal) ? (char *)signal : empty_arg;
func_argv[2] = hashtable;
- rc = (int *)weechat_js_exec (
- (struct t_plugin_script *)script_callback->script,
- WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
- "ssh", func_argv);
+ rc = (int *)weechat_js_exec (script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ ptr_function,
+ "ssh", func_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@@ -2540,27 +2576,28 @@ API_FUNC(hook_hsignal_send)
}
int
-weechat_js_api_hook_config_cb (void *data, const char *option,
- const char *value)
+weechat_js_api_hook_config_cb (const void *pointer, void *data,
+ const char *option, const char *value)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (option) ? (char *)option : empty_arg;
func_argv[2] = (value) ? (char *)value : empty_arg;
- rc = (int *)weechat_js_exec (
- (struct t_plugin_script *)script_callback->script,
- WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
- "sss", func_argv);
+ rc = (int *)weechat_js_exec (script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ ptr_function,
+ "sss", func_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@@ -2599,29 +2636,31 @@ API_FUNC(hook_config)
}
int
-weechat_js_api_hook_completion_cb (void *data, const char *completion_item,
+weechat_js_api_hook_completion_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (completion_item) ? (char *)completion_item : empty_arg;
func_argv[2] = API_PTR2STR(buffer);
func_argv[3] = API_PTR2STR(completion);
- rc = (int *)weechat_js_exec (
- (struct t_plugin_script *)script_callback->script,
- WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
- "ssss", func_argv);
+ rc = (int *)weechat_js_exec (script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ ptr_function,
+ "ssss", func_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@@ -2702,27 +2741,29 @@ API_FUNC(hook_completion_list_add)
}
char *
-weechat_js_api_hook_modifier_cb (void *data, const char *modifier,
+weechat_js_api_hook_modifier_cb (const void *pointer, void *data,
+ const char *modifier,
const char *modifier_data, const char *string)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (modifier) ? (char *)modifier : empty_arg;
func_argv[2] = (modifier_data) ? (char *)modifier_data : empty_arg;
func_argv[3] = (string) ? (char *)string : empty_arg;
- return (char *)weechat_js_exec (
- (struct t_plugin_script *)script_callback->script,
- WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function,
- "ssss", func_argv);
+ return (char *)weechat_js_exec (script,
+ WEECHAT_SCRIPT_EXEC_STRING,
+ ptr_function,
+ "ssss", func_argv);
}
return NULL;
@@ -2766,26 +2807,28 @@ API_FUNC(hook_modifier_exec)
}
const char *
-weechat_js_api_hook_info_cb (void *data, const char *info_name,
+weechat_js_api_hook_info_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (info_name) ? (char *)info_name : empty_arg;
func_argv[2] = (arguments) ? (char *)arguments : empty_arg;
- return (const char *)weechat_js_exec (
- (struct t_plugin_script *)script_callback->script,
- WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function,
- "sss", func_argv);
+ return (const char *)weechat_js_exec (script,
+ WEECHAT_SCRIPT_EXEC_STRING,
+ ptr_function,
+ "sss", func_argv);
}
return NULL;
@@ -2818,26 +2861,29 @@ API_FUNC(hook_info)
}
struct t_hashtable *
-weechat_js_api_hook_info_hashtable_cb (void *data, const char *info_name,
+weechat_js_api_hook_info_hashtable_cb (const void *pointer, void *data,
+ const char *info_name,
struct t_hashtable *hashtable)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
struct t_hashtable *ret_hashtable;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (info_name) ? (char *)info_name : empty_arg;
func_argv[2] = hashtable;
ret_hashtable = (struct t_hashtable *)weechat_js_exec (
- (struct t_plugin_script *)script_callback->script,
+ script,
WEECHAT_SCRIPT_EXEC_HASHTABLE,
- script_callback->function,
+ ptr_function,
"ssh", func_argv);
return ret_hashtable;
@@ -2875,27 +2921,30 @@ API_FUNC(hook_info_hashtable)
}
struct t_infolist *
-weechat_js_api_hook_infolist_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+weechat_js_api_hook_infolist_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
struct t_infolist *result;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (infolist_name) ? (char *)infolist_name : empty_arg;
- func_argv[2] = API_PTR2STR(pointer);
+ func_argv[2] = API_PTR2STR(obj_pointer);
func_argv[3] = (arguments) ? (char *)arguments : empty_arg;
result = (struct t_infolist *)weechat_js_exec (
- (struct t_plugin_script *)script_callback->script,
+ script,
WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function,
+ ptr_function,
"ssss", func_argv);
if (func_argv[2])
@@ -2936,25 +2985,27 @@ API_FUNC(hook_infolist)
}
struct t_hashtable *
-weechat_js_api_hook_focus_cb (void *data,
+weechat_js_api_hook_focus_cb (const void *pointer, void *data,
struct t_hashtable *info)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
struct t_hashtable *ret_hashtable;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = info;
ret_hashtable = (struct t_hashtable *)weechat_js_exec (
- (struct t_plugin_script *)script_callback->script,
+ script,
WEECHAT_SCRIPT_EXEC_HASHTABLE,
- script_callback->function,
+ ptr_function,
"sh", func_argv);
return ret_hashtable;
@@ -3004,9 +3055,7 @@ API_FUNC(unhook)
v8::String::Utf8Value hook(args[0]);
- plugin_script_api_unhook (weechat_js_plugin,
- js_current_script,
- (struct t_hook *)API_STR2PTR(*hook));
+ weechat_unhook ((struct t_hook *)API_STR2PTR(*hook));
API_RETURN_OK;
}
@@ -3017,33 +3066,35 @@ API_FUNC(unhook_all)
v8::String::Utf8Value hook(args[0]);
- plugin_script_api_unhook_all (weechat_js_plugin, js_current_script);
+ weechat_unhook_all (js_current_script->name);
API_RETURN_OK;
}
int
-weechat_js_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
+weechat_js_api_buffer_input_data_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
const char *input_data)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
func_argv[2] = (input_data) ? (char *)input_data : empty_arg;
- rc = (int *)weechat_js_exec (
- (struct t_plugin_script *)script_callback->script,
- WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
- "sss", func_argv);
+ rc = (int *)weechat_js_exec (script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ ptr_function,
+ "sss", func_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@@ -3063,25 +3114,27 @@ weechat_js_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
}
int
-weechat_js_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
+weechat_js_api_buffer_close_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
- rc = (int *)weechat_js_exec (
- (struct t_plugin_script *)script_callback->script,
- WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
- "ss", func_argv);
+ rc = (int *)weechat_js_exec (script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ ptr_function,
+ "ss", func_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@@ -3180,10 +3233,7 @@ API_FUNC(buffer_close)
v8::String::Utf8Value buffer(args[0]);
- plugin_script_api_buffer_close (
- weechat_js_plugin,
- js_current_script,
- (struct t_gui_buffer *)API_STR2PTR(*buffer));
+ weechat_buffer_close ((struct t_gui_buffer *)API_STR2PTR(*buffer));
API_RETURN_OK;
}
@@ -3688,33 +3738,35 @@ API_FUNC(bar_item_search)
}
char *
-weechat_js_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
+weechat_js_api_bar_item_build_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
struct t_gui_window *window,
struct t_gui_buffer *buffer,
struct t_hashtable *extra_info)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[5];
char empty_arg[1] = { '\0' }, *ret;
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- if (strncmp (script_callback->function, "(extra)", 7) == 0)
+ if (strncmp (ptr_function, "(extra)", 7) == 0)
{
/* new callback: data, item, window, buffer, extra_info */
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(item);
func_argv[2] = API_PTR2STR(window);
func_argv[3] = API_PTR2STR(buffer);
func_argv[4] = extra_info;
- ret = (char *)weechat_js_exec (
- (struct t_plugin_script *)script_callback->script,
- WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function + 7,
- "ssssh", func_argv);
+ ret = (char *)weechat_js_exec (script,
+ WEECHAT_SCRIPT_EXEC_STRING,
+ ptr_function + 7,
+ "ssssh", func_argv);
if (func_argv[1])
free (func_argv[1]);
@@ -3726,15 +3778,14 @@ weechat_js_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
else
{
/* old callback: data, item, window */
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(item);
func_argv[2] = API_PTR2STR(window);
- ret = (char *)weechat_js_exec (
- (struct t_plugin_script *)script_callback->script,
- WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function,
- "sss", func_argv);
+ ret = (char *)weechat_js_exec (script,
+ WEECHAT_SCRIPT_EXEC_STRING,
+ ptr_function,
+ "sss", func_argv);
if (func_argv[1])
free (func_argv[1]);
@@ -3787,10 +3838,7 @@ API_FUNC(bar_item_remove)
v8::String::Utf8Value item(args[0]);
- plugin_script_api_bar_item_remove (
- weechat_js_plugin,
- js_current_script,
- (struct t_gui_bar_item *)API_STR2PTR(*item));
+ weechat_bar_item_remove ((struct t_gui_bar_item *)API_STR2PTR(*item));
API_RETURN_OK;
}
@@ -4566,66 +4614,34 @@ API_FUNC(hdata_get_string)
API_RETURN_STRING(result);
}
-API_FUNC(upgrade_new)
-{
- int write;
- char *result;
-
- API_INIT_FUNC(1, "upgrade_new", "si", API_RETURN_EMPTY);
-
- v8::String::Utf8Value filename(args[0]);
- write = args[1]->IntegerValue();
-
- result = API_PTR2STR(weechat_upgrade_new (*filename, write));
-
- API_RETURN_STRING_FREE(result);
-}
-
-API_FUNC(upgrade_write_object)
-{
- int object_id, rc;
-
- API_INIT_FUNC(1, "upgrade_write_object", "sis", API_RETURN_INT(0));
-
- v8::String::Utf8Value upgrade_file(args[0]);
- object_id = args[1]->IntegerValue();
- v8::String::Utf8Value infolist(args[2]);
-
- rc = weechat_upgrade_write_object (
- (struct t_upgrade_file *)API_STR2PTR(*upgrade_file),
- object_id,
- (struct t_infolist *)API_STR2PTR(*infolist));
-
- API_RETURN_INT(rc);
-}
-
int
-weechat_js_api_upgrade_read_cb (void *data,
+weechat_js_api_upgrade_read_cb (const void *pointer, void *data,
struct t_upgrade_file *upgrade_file,
int object_id,
struct t_infolist *infolist)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' }, str_object_id[32];
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (str_object_id, sizeof (str_object_id), "%d", object_id);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(upgrade_file);
func_argv[2] = str_object_id;
func_argv[3] = API_PTR2STR(infolist);
- rc = (int *)weechat_js_exec (
- (struct t_plugin_script *)script_callback->script,
- WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
- "ssss", func_argv);
+ rc = (int *)weechat_js_exec (script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ ptr_function,
+ "ssss", func_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@@ -4645,23 +4661,56 @@ weechat_js_api_upgrade_read_cb (void *data,
return WEECHAT_RC_ERROR;
}
+API_FUNC(upgrade_new)
+{
+ char *result;
+
+ API_INIT_FUNC(1, "upgrade_new", "sss", API_RETURN_EMPTY);
+
+ v8::String::Utf8Value filename(args[0]);
+ v8::String::Utf8Value function(args[0]);
+ v8::String::Utf8Value data(args[0]);
+
+ result = API_PTR2STR(
+ plugin_script_api_upgrade_new (
+ weechat_js_plugin,
+ js_current_script,
+ *filename,
+ &weechat_js_api_upgrade_read_cb,
+ *function,
+ *data));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+API_FUNC(upgrade_write_object)
+{
+ int object_id, rc;
+
+ API_INIT_FUNC(1, "upgrade_write_object", "sis", API_RETURN_INT(0));
+
+ v8::String::Utf8Value upgrade_file(args[0]);
+ object_id = args[1]->IntegerValue();
+ v8::String::Utf8Value infolist(args[2]);
+
+ rc = weechat_upgrade_write_object (
+ (struct t_upgrade_file *)API_STR2PTR(*upgrade_file),
+ object_id,
+ (struct t_infolist *)API_STR2PTR(*infolist));
+
+ API_RETURN_INT(rc);
+}
+
API_FUNC(upgrade_read)
{
int rc;
- API_INIT_FUNC(1, "upgrade_read", "sss", API_RETURN_INT(0));
+ API_INIT_FUNC(1, "upgrade_read", "s", API_RETURN_INT(0));
v8::String::Utf8Value upgrade_file(args[0]);
- v8::String::Utf8Value function(args[1]);
- v8::String::Utf8Value data(args[2]);
- rc = plugin_script_api_upgrade_read (
- weechat_js_plugin,
- js_current_script,
- (struct t_upgrade_file *)API_STR2PTR(*upgrade_file),
- &weechat_js_api_upgrade_read_cb,
- *function,
- *data);
+ rc = weechat_upgrade_read (
+ (struct t_upgrade_file *)API_STR2PTR(*upgrade_file));
API_RETURN_INT(rc);
}
diff --git a/src/plugins/javascript/weechat-js-api.h b/src/plugins/javascript/weechat-js-api.h
index 74de77941..61e240362 100644
--- a/src/plugins/javascript/weechat-js-api.h
+++ b/src/plugins/javascript/weechat-js-api.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2013 Koka El Kiwi <kokakiwi@kokakiwi.net>
- * Copyright (C) 2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2015-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -21,10 +21,12 @@
#ifndef WEECHAT_JS_API_H
#define WEECHAT_JS_API_H 1
-extern int weechat_js_api_buffer_input_data_cb (void *data,
+extern int weechat_js_api_buffer_input_data_cb (const void *pointer,
+ void *data,
struct t_gui_buffer *buffer,
const char *input_data);
-extern int weechat_js_api_buffer_close_cb (void *data,
+extern int weechat_js_api_buffer_close_cb (const void *pointer,
+ void *data,
struct t_gui_buffer *buffer);
#endif /* WEECHAT_JS_API_H */
diff --git a/src/plugins/javascript/weechat-js-v8.cpp b/src/plugins/javascript/weechat-js-v8.cpp
index 3effbd02c..2633c7a97 100644
--- a/src/plugins/javascript/weechat-js-v8.cpp
+++ b/src/plugins/javascript/weechat-js-v8.cpp
@@ -2,7 +2,7 @@
* weechat-js-v8.cpp - v8 javascript functions
*
* Copyright (C) 2013 Koka El Kiwi <kokakiwi@kokakiwi.net>
- * Copyright (C) 2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2015-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/javascript/weechat-js-v8.h b/src/plugins/javascript/weechat-js-v8.h
index 65aa930fe..d71965418 100644
--- a/src/plugins/javascript/weechat-js-v8.h
+++ b/src/plugins/javascript/weechat-js-v8.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2013 Koka El Kiwi <kokakiwi@kokakiwi.net>
- * Copyright (C) 2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2015-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/javascript/weechat-js.cpp b/src/plugins/javascript/weechat-js.cpp
index 5636cda12..00033c8d6 100644
--- a/src/plugins/javascript/weechat-js.cpp
+++ b/src/plugins/javascript/weechat-js.cpp
@@ -2,7 +2,7 @@
* weechat-js.cpp - javascript plugin for WeeChat
*
* Copyright (C) 2013 Koka El Kiwi <kokakiwi@kokakiwi.net>
- * Copyright (C) 2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2015-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -215,7 +215,7 @@ weechat_js_exec (struct t_plugin_script *script,
if ((ret_type == WEECHAT_SCRIPT_EXEC_STRING) && (ret_js->IsString()))
{
v8::String::Utf8Value temp_str(ret_js);
- ret_value = *temp_str;
+ ret_value = (*temp_str) ? strdup(*temp_str) : NULL;
}
else if ((ret_type == WEECHAT_SCRIPT_EXEC_INT) && (ret_js->IsInt32()))
{
@@ -516,12 +516,14 @@ weechat_js_reload_name (const char *name)
*/
int
-weechat_js_command_cb (void *data, struct t_gui_buffer *buffer,
+weechat_js_command_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
char *ptr_name, *path_script;
/* make C++ compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
@@ -615,11 +617,13 @@ weechat_js_command_cb (void *data, struct t_gui_buffer *buffer,
*/
int
-weechat_js_completion_cb (void *data, const char *completion_item,
+weechat_js_completion_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
/* make C++ compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -634,9 +638,11 @@ weechat_js_completion_cb (void *data, const char *completion_item,
*/
struct t_hdata *
-weechat_js_hdata_cb (void *data, const char *hdata_name)
+weechat_js_hdata_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
/* make C++ compiler happy */
+ (void) pointer;
(void) data;
return plugin_script_hdata_script (weechat_plugin,
@@ -649,10 +655,12 @@ weechat_js_hdata_cb (void *data, const char *hdata_name)
*/
struct t_infolist *
-weechat_js_infolist_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+weechat_js_infolist_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
/* make C++ compiler happy */
+ (void) pointer;
(void) data;
if (!infolist_name || !infolist_name[0])
@@ -661,7 +669,7 @@ weechat_js_infolist_cb (void *data, const char *infolist_name,
if (weechat_strcasecmp (infolist_name, "javascript_script") == 0)
{
return plugin_script_infolist_list_scripts (weechat_js_plugin,
- js_scripts, pointer,
+ js_scripts, obj_pointer,
arguments);
}
@@ -673,10 +681,12 @@ weechat_js_infolist_cb (void *data, const char *infolist_name,
*/
int
-weechat_js_signal_debug_dump_cb (void *data, const char *signal,
+weechat_js_signal_debug_dump_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
/* make C++ compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -695,10 +705,12 @@ weechat_js_signal_debug_dump_cb (void *data, const char *signal,
*/
int
-weechat_js_signal_debug_libs_cb (void *data, const char *signal,
+weechat_js_signal_debug_libs_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
/* make C++ compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -711,40 +723,20 @@ weechat_js_signal_debug_libs_cb (void *data, const char *signal,
}
/*
- * Callback called when a buffer is closed.
- */
-
-int
-weechat_js_signal_buffer_closed_cb (void *data, const char *signal,
- const char *type_data, void *signal_data)
-{
- /* make C++ compiler happy */
- (void) data;
- (void) signal;
- (void) type_data;
-
- if (signal_data)
- {
- plugin_script_remove_buffer_callbacks (js_scripts,
- (struct t_gui_buffer *)signal_data);
- }
-
- return WEECHAT_RC_OK;
-}
-
-/*
* Timer for executing actions.
*/
int
-weechat_js_timer_action_cb (void *data, int remaining_calls)
+weechat_js_timer_action_cb (const void *pointer, void *data,
+ int remaining_calls)
{
/* make C++ compiler happy */
+ (void) data;
(void) remaining_calls;
- if (data)
+ if (pointer)
{
- if (data == &js_action_install_list)
+ if (pointer == &js_action_install_list)
{
plugin_script_action_install (weechat_js_plugin,
js_scripts,
@@ -753,7 +745,7 @@ weechat_js_timer_action_cb (void *data, int remaining_calls)
&js_quiet,
&js_action_install_list);
}
- else if (data == &js_action_remove_list)
+ else if (pointer == &js_action_remove_list)
{
plugin_script_action_remove (weechat_js_plugin,
js_scripts,
@@ -761,7 +753,7 @@ weechat_js_timer_action_cb (void *data, int remaining_calls)
&js_quiet,
&js_action_remove_list);
}
- else if (data == &js_action_autoload_list)
+ else if (pointer == &js_action_autoload_list)
{
plugin_script_action_autoload (weechat_js_plugin,
&js_quiet,
@@ -778,11 +770,13 @@ weechat_js_timer_action_cb (void *data, int remaining_calls)
*/
int
-weechat_js_signal_script_action_cb (void *data, const char *signal,
+weechat_js_signal_script_action_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data,
void *signal_data)
{
/* make C++ compiler happy */
+ (void) pointer;
(void) data;
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
@@ -793,7 +787,7 @@ weechat_js_signal_script_action_cb (void *data, const char *signal,
(const char *)signal_data);
weechat_hook_timer (1, 0, 1,
&weechat_js_timer_action_cb,
- &js_action_install_list);
+ &js_action_install_list, NULL);
}
else if (strcmp (signal, "javascript_script_remove") == 0)
{
@@ -801,7 +795,7 @@ weechat_js_signal_script_action_cb (void *data, const char *signal,
(const char *)signal_data);
weechat_hook_timer (1, 0, 1,
&weechat_js_timer_action_cb,
- &js_action_remove_list);
+ &js_action_remove_list, NULL);
}
else if (strcmp (signal, "javascript_script_autoload") == 0)
{
@@ -809,7 +803,7 @@ weechat_js_signal_script_action_cb (void *data, const char *signal,
(const char *)signal_data);
weechat_hook_timer (1, 0, 1,
&weechat_js_timer_action_cb,
- &js_action_autoload_list);
+ &js_action_autoload_list, NULL);
}
}
@@ -833,7 +827,6 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
init.callback_infolist = &weechat_js_infolist_cb;
init.callback_signal_debug_dump = &weechat_js_signal_debug_dump_cb;
init.callback_signal_debug_libs = &weechat_js_signal_debug_libs_cb;
- init.callback_signal_buffer_closed = &weechat_js_signal_buffer_closed_cb;
init.callback_signal_script_action = &weechat_js_signal_script_action_cb;
init.callback_load_file = &weechat_js_load_cb;
diff --git a/src/plugins/javascript/weechat-js.h b/src/plugins/javascript/weechat-js.h
index a6412f347..4d26e9c6f 100644
--- a/src/plugins/javascript/weechat-js.h
+++ b/src/plugins/javascript/weechat-js.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2013 Koka El Kiwi <kokakiwi@kokakiwi.net>
- * Copyright (C) 2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2015-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/logger/CMakeLists.txt b/src/plugins/logger/CMakeLists.txt
index 85d1ab885..8b2a61b17 100644
--- a/src/plugins/logger/CMakeLists.txt
+++ b/src/plugins/logger/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/logger/Makefile.am b/src/plugins/logger/Makefile.am
index a0c5b7708..b150a4392 100644
--- a/src/plugins/logger/Makefile.am
+++ b/src/plugins/logger/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/logger/logger-buffer.c b/src/plugins/logger/logger-buffer.c
index 1a4d3e4c6..7acdb13f7 100644
--- a/src/plugins/logger/logger-buffer.c
+++ b/src/plugins/logger/logger-buffer.c
@@ -1,7 +1,7 @@
/*
* logger-buffer.c - logger buffer list management
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -79,11 +79,10 @@ logger_buffer_add (struct t_gui_buffer *buffer, int log_level)
if (weechat_logger_plugin->debug)
{
- weechat_printf_tags (NULL,
- "no_log",
- "%s: start logging for buffer \"%s\"",
- LOGGER_PLUGIN_NAME,
- weechat_buffer_get_string (buffer, "name"));
+ weechat_printf_date_tags (NULL, 0, "no_log",
+ "%s: start logging for buffer \"%s\"",
+ LOGGER_PLUGIN_NAME,
+ weechat_buffer_get_string (buffer, "name"));
}
new_logger_buffer = malloc (sizeof (*new_logger_buffer));
@@ -197,11 +196,11 @@ logger_buffer_free (struct t_logger_buffer *logger_buffer)
if (weechat_logger_plugin->debug)
{
- weechat_printf_tags (NULL,
- "no_log",
- "%s: stop logging for buffer \"%s\"",
- LOGGER_PLUGIN_NAME,
- weechat_buffer_get_string (ptr_buffer, "name"));
+ weechat_printf_date_tags (
+ NULL, 0, "no_log",
+ "%s: stop logging for buffer \"%s\"",
+ LOGGER_PLUGIN_NAME,
+ weechat_buffer_get_string (ptr_buffer, "name"));
}
}
diff --git a/src/plugins/logger/logger-buffer.h b/src/plugins/logger/logger-buffer.h
index 45d6799e1..4168fe736 100644
--- a/src/plugins/logger/logger-buffer.h
+++ b/src/plugins/logger/logger-buffer.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/logger/logger-config.c b/src/plugins/logger/logger-config.c
index cac61d8a9..0e9a8d75c 100644
--- a/src/plugins/logger/logger-config.c
+++ b/src/plugins/logger/logger-config.c
@@ -1,7 +1,7 @@
/*
* logger-config.c - logger configuration options (file logger.conf)
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -62,10 +62,11 @@ struct t_config_option *logger_config_file_time_format;
*/
void
-logger_config_change_file_option_restart_log (void *data,
+logger_config_change_file_option_restart_log (const void *pointer, void *data,
struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -78,10 +79,11 @@ logger_config_change_file_option_restart_log (void *data,
*/
void
-logger_config_flush_delay_change (void *data,
+logger_config_flush_delay_change (const void *pointer, void *data,
struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -92,9 +94,9 @@ logger_config_flush_delay_change (void *data,
{
if (weechat_logger_plugin->debug)
{
- weechat_printf_tags (NULL,
- "no_log",
- "%s: stopping timer", LOGGER_PLUGIN_NAME);
+ weechat_printf_date_tags (
+ NULL, 0, "no_log",
+ "%s: stopping timer", LOGGER_PLUGIN_NAME);
}
weechat_unhook (logger_timer);
logger_timer = NULL;
@@ -104,15 +106,15 @@ logger_config_flush_delay_change (void *data,
{
if (weechat_logger_plugin->debug)
{
- weechat_printf_tags (NULL,
- "no_log",
- "%s: starting timer (interval: %d seconds)",
- LOGGER_PLUGIN_NAME,
- weechat_config_integer (logger_config_file_flush_delay));
+ weechat_printf_date_tags (
+ NULL, 0, "no_log",
+ "%s: starting timer (interval: %d seconds)",
+ LOGGER_PLUGIN_NAME,
+ weechat_config_integer (logger_config_file_flush_delay));
}
logger_timer = weechat_hook_timer (weechat_config_integer (logger_config_file_flush_delay) * 1000,
0, 0,
- &logger_timer_cb, NULL);
+ &logger_timer_cb, NULL, NULL);
}
}
@@ -121,10 +123,11 @@ logger_config_flush_delay_change (void *data,
*/
void
-logger_config_level_change (void *data,
+logger_config_level_change (const void *pointer, void *data,
struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -137,12 +140,13 @@ logger_config_level_change (void *data,
*/
int
-logger_config_level_delete_option (void *data,
+logger_config_level_delete_option (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) config_file;
(void) section;
@@ -159,7 +163,7 @@ logger_config_level_delete_option (void *data,
*/
int
-logger_config_level_create_option (void *data,
+logger_config_level_create_option (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
@@ -169,6 +173,7 @@ logger_config_level_create_option (void *data,
int rc;
/* make C compiler happy */
+ (void) pointer;
(void) data;
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
@@ -196,9 +201,10 @@ logger_config_level_create_option (void *data,
option_name, "integer",
_("logging level for this buffer (0 = logging disabled, "
"1 = a few messages (most important) .. 9 = all messages)"),
- NULL, 0, 9, "9", value, 0, NULL, NULL,
- &logger_config_level_change, NULL,
- NULL, NULL);
+ NULL, 0, 9, "9", value, 0,
+ NULL, NULL, NULL,
+ &logger_config_level_change, NULL, NULL,
+ NULL, NULL, NULL);
rc = (ptr_option) ?
WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
}
@@ -232,7 +238,7 @@ logger_config_get_level (const char *name)
int
logger_config_set_level (const char *name, const char *value)
{
- return logger_config_level_create_option (NULL,
+ return logger_config_level_create_option (NULL, NULL,
logger_config_file,
logger_config_section_level,
name,
@@ -244,10 +250,11 @@ logger_config_set_level (const char *name, const char *value)
*/
void
-logger_config_mask_change (void *data,
+logger_config_mask_change (const void *pointer, void *data,
struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -260,12 +267,13 @@ logger_config_mask_change (void *data,
*/
int
-logger_config_mask_delete_option (void *data,
+logger_config_mask_delete_option (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) config_file;
(void) section;
@@ -282,7 +290,7 @@ logger_config_mask_delete_option (void *data,
*/
int
-logger_config_mask_create_option (void *data,
+logger_config_mask_create_option (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
@@ -292,6 +300,7 @@ logger_config_mask_create_option (void *data,
int rc;
/* make C compiler happy */
+ (void) pointer;
(void) data;
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
@@ -319,9 +328,10 @@ logger_config_mask_create_option (void *data,
option_name, "string",
_("file mask for log file; local buffer variables are "
"permitted"),
- NULL, 0, 0, "", value, 0, NULL, NULL,
- &logger_config_mask_change, NULL,
- NULL, NULL);
+ NULL, 0, 0, "", value, 0,
+ NULL, NULL, NULL,
+ &logger_config_mask_change, NULL, NULL,
+ NULL, NULL, NULL);
rc = (ptr_option) ?
WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
}
@@ -362,16 +372,18 @@ logger_config_init ()
struct t_config_section *ptr_section;
logger_config_file = weechat_config_new (LOGGER_CONFIG_NAME,
- NULL, NULL);
+ NULL, NULL, NULL);
if (!logger_config_file)
return 0;
/* look */
ptr_section = weechat_config_new_section (logger_config_file, "look",
0, 0,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (logger_config_file);
@@ -383,14 +395,17 @@ logger_config_init ()
"backlog", "integer",
N_("maximum number of lines to display from log file when creating "
"new buffer (0 = no backlog)"),
- NULL, 0, INT_MAX, "20", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, INT_MAX, "20", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
/* color */
ptr_section = weechat_config_new_section (logger_config_file, "color",
0, 0,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (logger_config_file);
@@ -401,19 +416,23 @@ logger_config_init ()
logger_config_file, ptr_section,
"backlog_end", "color",
N_("color for line ending the backlog"),
- NULL, -1, 0, "default", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, -1, 0, "default", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
logger_config_color_backlog_line = weechat_config_new_option (
logger_config_file, ptr_section,
"backlog_line", "color",
N_("color for backlog lines"),
- NULL, -1, 0, "default", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, -1, 0, "default", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
/* file */
ptr_section = weechat_config_new_section (logger_config_file, "file",
0, 0,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (logger_config_file);
@@ -425,46 +444,58 @@ logger_config_init ()
"auto_log", "boolean",
N_("automatically save content of buffers to files (unless a buffer "
"disables log)"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
logger_config_file_flush_delay = weechat_config_new_option (
logger_config_file, ptr_section,
"flush_delay", "integer",
N_("number of seconds between flush of log files (0 = write in log "
"files immediately for each line printed)"),
- NULL, 0, 3600, "120", NULL, 0, NULL, NULL,
- &logger_config_flush_delay_change, NULL, NULL, NULL);
+ NULL, 0, 3600, "120", NULL, 0,
+ NULL, NULL, NULL,
+ &logger_config_flush_delay_change, NULL, NULL,
+ NULL, NULL, NULL);
logger_config_file_info_lines = weechat_config_new_option (
logger_config_file, ptr_section,
"info_lines", "boolean",
N_("write information line in log file when log starts or ends for a "
"buffer"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
logger_config_file_mask = weechat_config_new_option (
logger_config_file, ptr_section,
"mask", "string",
N_("default file name mask for log files (format is "
"\"directory/to/file\" or \"file\", without first \"/\" because "
"\"path\" option is used to build complete path to file); local "
- "buffer variables are permitted; date specifiers are permitted "
+ "buffer variables are permitted (you should use only variables "
+ "that are defined on all buffers, so for example you should NOT "
+ "use $server nor $channel); date specifiers are permitted "
"(see man strftime)"),
- NULL, 0, 0, "$plugin.$name.weechatlog", NULL, 0, NULL, NULL,
- &logger_config_change_file_option_restart_log, NULL, NULL, NULL);
+ NULL, 0, 0, "$plugin.$name.weechatlog", NULL, 0,
+ NULL, NULL, NULL,
+ &logger_config_change_file_option_restart_log, NULL, NULL,
+ NULL, NULL, NULL);
logger_config_file_name_lower_case = weechat_config_new_option (
logger_config_file, ptr_section,
"name_lower_case", "boolean",
N_("use only lower case for log filenames"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL,
- &logger_config_change_file_option_restart_log, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL,
+ &logger_config_change_file_option_restart_log, NULL, NULL,
+ NULL, NULL, NULL);
logger_config_file_nick_prefix = weechat_config_new_option (
logger_config_file, ptr_section,
"nick_prefix", "string",
N_("text to write before nick in prefix of message, example: \"<\""),
- NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
logger_config_file_nick_suffix = weechat_config_new_option (
logger_config_file, ptr_section,
"nick_suffix", "string",
N_("text to write after nick in prefix of message, example: \">\""),
- NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
logger_config_file_path = weechat_config_new_option (
logger_config_file, ptr_section,
"path", "string",
@@ -472,29 +503,36 @@ logger_config_init ()
"replaced by WeeChat home (\"~/.weechat\" by default); date "
"specifiers are permitted (see man strftime) "
"(note: content is evaluated, see /help eval)"),
- NULL, 0, 0, "%h/logs/", NULL, 0, NULL, NULL,
- &logger_config_change_file_option_restart_log, NULL, NULL, NULL);
+ NULL, 0, 0, "%h/logs/", NULL, 0,
+ NULL, NULL, NULL,
+ &logger_config_change_file_option_restart_log, NULL, NULL,
+ NULL, NULL, NULL);
logger_config_file_replacement_char = weechat_config_new_option (
logger_config_file, ptr_section,
"replacement_char", "string",
N_("replacement char for special chars in filename built with mask "
"(like directory delimiter)"),
- NULL, 0, 0, "_", NULL, 0, NULL, NULL,
- &logger_config_change_file_option_restart_log, NULL, NULL, NULL);
+ NULL, 0, 0, "_", NULL, 0,
+ NULL, NULL, NULL,
+ &logger_config_change_file_option_restart_log, NULL, NULL,
+ NULL, NULL, NULL);
logger_config_file_time_format = weechat_config_new_option (
logger_config_file, ptr_section,
"time_format", "string",
N_("timestamp used in log files (see man strftime for date/time "
"specifiers)"),
- NULL, 0, 0, "%Y-%m-%d %H:%M:%S", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "%Y-%m-%d %H:%M:%S", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
/* level */
- ptr_section = weechat_config_new_section (logger_config_file, "level",
- 1, 1,
- NULL, NULL, NULL, NULL,
- NULL, NULL,
- &logger_config_level_create_option, NULL,
- &logger_config_level_delete_option, NULL);
+ ptr_section = weechat_config_new_section (
+ logger_config_file, "level",
+ 1, 1,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ &logger_config_level_create_option, NULL, NULL,
+ &logger_config_level_delete_option, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (logger_config_file);
@@ -504,12 +542,14 @@ logger_config_init ()
logger_config_section_level = ptr_section;
/* mask */
- ptr_section = weechat_config_new_section (logger_config_file, "mask",
- 1, 1,
- NULL, NULL, NULL, NULL,
- NULL, NULL,
- &logger_config_mask_create_option, NULL,
- &logger_config_mask_delete_option, NULL);
+ ptr_section = weechat_config_new_section (
+ logger_config_file, "mask",
+ 1, 1,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ &logger_config_mask_create_option, NULL, NULL,
+ &logger_config_mask_delete_option, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (logger_config_file);
@@ -534,7 +574,7 @@ logger_config_read ()
rc = weechat_config_read (logger_config_file);
logger_config_loading = 0;
- logger_config_flush_delay_change (NULL, NULL);
+ logger_config_flush_delay_change (NULL, NULL, NULL);
return rc;
}
diff --git a/src/plugins/logger/logger-config.h b/src/plugins/logger/logger-config.h
index c930ae0f5..834da3ab6 100644
--- a/src/plugins/logger/logger-config.h
+++ b/src/plugins/logger/logger-config.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/logger/logger-info.c b/src/plugins/logger/logger-info.c
index cb3db8bf2..4eb0a0202 100644
--- a/src/plugins/logger/logger-info.c
+++ b/src/plugins/logger/logger-info.c
@@ -1,7 +1,7 @@
/*
* logger-info.c - info and infolist hooks for logger plugin
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -32,28 +32,31 @@
*/
struct t_infolist *
-logger_info_infolist_logger_buffer_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+logger_info_infolist_logger_buffer_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer,
+ const char *arguments)
{
struct t_infolist *ptr_infolist;
struct t_logger_buffer *ptr_logger_buffer;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) infolist_name;
(void) arguments;
- if (pointer && !logger_buffer_valid (pointer))
+ if (obj_pointer && !logger_buffer_valid (obj_pointer))
return NULL;
ptr_infolist = weechat_infolist_new ();
if (!ptr_infolist)
return NULL;
- if (pointer)
+ if (obj_pointer)
{
/* build list with only one logger buffer */
- if (!logger_buffer_add_to_infolist (ptr_infolist, pointer))
+ if (!logger_buffer_add_to_infolist (ptr_infolist, obj_pointer))
{
weechat_infolist_free (ptr_infolist);
return NULL;
@@ -90,5 +93,5 @@ logger_info_init ()
"logger_buffer", N_("list of logger buffers"),
N_("logger pointer (optional)"),
NULL,
- &logger_info_infolist_logger_buffer_cb, NULL);
+ &logger_info_infolist_logger_buffer_cb, NULL, NULL);
}
diff --git a/src/plugins/logger/logger-info.h b/src/plugins/logger/logger-info.h
index 1d6a6fa14..21f4963e7 100644
--- a/src/plugins/logger/logger-info.h
+++ b/src/plugins/logger/logger-info.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/logger/logger-tail.c b/src/plugins/logger/logger-tail.c
index 6325366af..d62dc13f9 100644
--- a/src/plugins/logger/logger-tail.c
+++ b/src/plugins/logger/logger-tail.c
@@ -1,7 +1,7 @@
/*
* logger-tail.c - return last lines of a file
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/logger/logger-tail.h b/src/plugins/logger/logger-tail.h
index 086ef349a..fa5ef473d 100644
--- a/src/plugins/logger/logger-tail.h
+++ b/src/plugins/logger/logger-tail.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/logger/logger.c b/src/plugins/logger/logger.c
index 06e0ff4ca..159557f20 100644
--- a/src/plugins/logger/logger.c
+++ b/src/plugins/logger/logger.c
@@ -1,7 +1,7 @@
/*
* logger.c - logger plugin for WeeChat: save buffer lines to disk files
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -97,10 +97,9 @@ logger_get_file_path ()
if (weechat_logger_plugin->debug)
{
- weechat_printf_tags (NULL,
- "no_log",
- "%s: file path = \"%s\"",
- LOGGER_PLUGIN_NAME, path2);
+ weechat_printf_date_tags (NULL, 0, "no_log",
+ "%s: file path = \"%s\"",
+ LOGGER_PLUGIN_NAME, path2);
}
end:
@@ -364,13 +363,12 @@ logger_get_mask_expanded (struct t_gui_buffer *buffer, const char *mask)
if (weechat_logger_plugin->debug)
{
- weechat_printf_tags (NULL,
- "no_log",
- "%s: buffer = \"%s\", mask = \"%s\", "
- "decoded mask = \"%s\"",
- LOGGER_PLUGIN_NAME,
- weechat_buffer_get_string (buffer, "name"),
- mask, mask_decoded5);
+ weechat_printf_date_tags (NULL, 0, "no_log",
+ "%s: buffer = \"%s\", mask = \"%s\", "
+ "decoded mask = \"%s\"",
+ LOGGER_PLUGIN_NAME,
+ weechat_buffer_get_string (buffer, "name"),
+ mask, mask_decoded5);
}
end:
@@ -417,12 +415,12 @@ logger_get_filename (struct t_gui_buffer *buffer)
mask = logger_get_mask_for_buffer (buffer);
if (!mask)
{
- weechat_printf_tags (NULL,
- "no_log",
- _("%s%s: unable to find filename mask for buffer "
- "\"%s\", logging is disabled for this buffer"),
- weechat_prefix ("error"), LOGGER_PLUGIN_NAME,
- weechat_buffer_get_string (buffer, "name"));
+ weechat_printf_date_tags (
+ NULL, 0, "no_log",
+ _("%s%s: unable to find filename mask for buffer "
+ "\"%s\", logging is disabled for this buffer"),
+ weechat_prefix ("error"), LOGGER_PLUGIN_NAME,
+ weechat_buffer_get_string (buffer, "name"));
return NULL;
}
@@ -470,11 +468,10 @@ logger_set_log_filename (struct t_logger_buffer *logger_buffer)
log_filename = logger_get_filename (logger_buffer->buffer);
if (!log_filename)
{
- weechat_printf_tags (NULL,
- "no_log",
- _("%s%s: not enough memory"),
- weechat_prefix ("error"),
- LOGGER_PLUGIN_NAME);
+ weechat_printf_date_tags (NULL, 0, "no_log",
+ _("%s%s: not enough memory"),
+ weechat_prefix ("error"),
+ LOGGER_PLUGIN_NAME);
return;
}
@@ -482,15 +479,15 @@ logger_set_log_filename (struct t_logger_buffer *logger_buffer)
ptr_logger_buffer = logger_buffer_search_log_filename (log_filename);
if (ptr_logger_buffer)
{
- weechat_printf_tags (NULL,
- "no_log",
- _("%s%s: unable to start logging for buffer "
- "\"%s\": filename \"%s\" is already used by "
- "another buffer (check your log settings)"),
- weechat_prefix ("error"),
- LOGGER_PLUGIN_NAME,
- weechat_buffer_get_string (logger_buffer->buffer, "name"),
- log_filename);
+ weechat_printf_date_tags (
+ NULL, 0, "no_log",
+ _("%s%s: unable to start logging for buffer "
+ "\"%s\": filename \"%s\" is already used by "
+ "another buffer (check your log settings)"),
+ weechat_prefix ("error"),
+ LOGGER_PLUGIN_NAME,
+ weechat_buffer_get_string (logger_buffer->buffer, "name"),
+ log_filename);
free (log_filename);
return;
}
@@ -538,12 +535,12 @@ logger_write_line (struct t_logger_buffer *logger_buffer,
}
if (!logger_create_directory ())
{
- weechat_printf_tags (NULL,
- "no_log",
- _("%s%s: unable to create directory for logs "
- "(\"%s\")"),
- weechat_prefix ("error"), LOGGER_PLUGIN_NAME,
- weechat_config_string (logger_config_file_path));
+ weechat_printf_date_tags (
+ NULL, 0, "no_log",
+ _("%s%s: unable to create directory for logs "
+ "(\"%s\")"),
+ weechat_prefix ("error"), LOGGER_PLUGIN_NAME,
+ weechat_config_string (logger_config_file_path));
logger_buffer_free (logger_buffer);
return;
}
@@ -559,11 +556,11 @@ logger_write_line (struct t_logger_buffer *logger_buffer,
fopen (logger_buffer->log_filename, "a");
if (!logger_buffer->log_file)
{
- weechat_printf_tags (NULL,
- "no_log",
- _("%s%s: unable to write log file \"%s\""),
- weechat_prefix ("error"), LOGGER_PLUGIN_NAME,
- logger_buffer->log_filename);
+ weechat_printf_date_tags (
+ NULL, 0, "no_log",
+ _("%s%s: unable to write log file \"%s\": %s"),
+ weechat_prefix ("error"), LOGGER_PLUGIN_NAME,
+ logger_buffer->log_filename, strerror (errno));
logger_buffer_free (logger_buffer);
return;
}
@@ -838,11 +835,10 @@ logger_flush ()
{
if (weechat_logger_plugin->debug >= 2)
{
- weechat_printf_tags (NULL,
- "no_log",
- "%s: flush file %s",
- LOGGER_PLUGIN_NAME,
- ptr_logger_buffer->log_filename);
+ weechat_printf_date_tags (NULL, 0, "no_log",
+ "%s: flush file %s",
+ LOGGER_PLUGIN_NAME,
+ ptr_logger_buffer->log_filename);
}
fflush (ptr_logger_buffer->log_file);
ptr_logger_buffer->flush_needed = 0;
@@ -855,10 +851,12 @@ logger_flush ()
*/
int
-logger_command_cb (void *data, struct t_gui_buffer *buffer,
+logger_command_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argv_eol;
@@ -896,10 +894,12 @@ logger_command_cb (void *data, struct t_gui_buffer *buffer,
*/
int
-logger_buffer_opened_signal_cb (void *data, const char *signal,
+logger_buffer_opened_signal_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -914,10 +914,12 @@ logger_buffer_opened_signal_cb (void *data, const char *signal,
*/
int
-logger_buffer_closing_signal_cb (void *data, const char *signal,
+logger_buffer_closing_signal_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -932,10 +934,12 @@ logger_buffer_closing_signal_cb (void *data, const char *signal,
*/
int
-logger_buffer_renamed_signal_cb (void *data, const char *signal,
+logger_buffer_renamed_signal_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -1034,12 +1038,14 @@ logger_backlog (struct t_gui_buffer *buffer, const char *filename, int lines)
*/
int
-logger_backlog_signal_cb (void *data, const char *signal,
+logger_backlog_signal_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
struct t_logger_buffer *ptr_logger_buffer;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -1073,10 +1079,12 @@ logger_backlog_signal_cb (void *data, const char *signal,
*/
int
-logger_start_signal_cb (void *data, const char *signal, const char *type_data,
+logger_start_signal_cb (const void *pointer, void *data,
+ const char *signal, const char *type_data,
void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -1091,12 +1099,14 @@ logger_start_signal_cb (void *data, const char *signal, const char *type_data,
*/
int
-logger_stop_signal_cb (void *data, const char *signal, const char *type_data,
+logger_stop_signal_cb (const void *pointer, void *data,
+ const char *signal, const char *type_data,
void *signal_data)
{
struct t_logger_buffer *ptr_logger_buffer;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -1157,10 +1167,12 @@ logger_adjust_log_filenames ()
*/
int
-logger_day_changed_signal_cb (void *data, const char *signal,
+logger_day_changed_signal_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -1225,7 +1237,8 @@ logger_get_line_tag_info (int tags_count, const char **tags,
*/
int
-logger_print_cb (void *data, struct t_gui_buffer *buffer, time_t date,
+logger_print_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer, time_t date,
int tags_count, const char **tags,
int displayed, int highlight,
const char *prefix, const char *message)
@@ -1236,6 +1249,7 @@ logger_print_cb (void *data, struct t_gui_buffer *buffer, time_t date,
int line_log_level, prefix_is_nick;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) displayed;
(void) highlight;
@@ -1277,9 +1291,10 @@ logger_print_cb (void *data, struct t_gui_buffer *buffer, time_t date,
*/
int
-logger_timer_cb (void *data, int remaining_calls)
+logger_timer_cb (const void *pointer, void *data, int remaining_calls)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) remaining_calls;
@@ -1346,19 +1361,26 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
" || set 1|2|3|4|5|6|7|8|9"
" || flush"
" || disable",
- &logger_command_cb, NULL);
+ &logger_command_cb, NULL, NULL);
logger_start_buffer_all (1);
- weechat_hook_signal ("buffer_opened", &logger_buffer_opened_signal_cb, NULL);
- weechat_hook_signal ("buffer_closing", &logger_buffer_closing_signal_cb, NULL);
- weechat_hook_signal ("buffer_renamed", &logger_buffer_renamed_signal_cb, NULL);
- weechat_hook_signal ("logger_backlog", &logger_backlog_signal_cb, NULL);
- weechat_hook_signal ("logger_start", &logger_start_signal_cb, NULL);
- weechat_hook_signal ("logger_stop", &logger_stop_signal_cb, NULL);
- weechat_hook_signal ("day_changed", &logger_day_changed_signal_cb, NULL);
-
- weechat_hook_print (NULL, NULL, NULL, 1, &logger_print_cb, NULL);
+ weechat_hook_signal ("buffer_opened",
+ &logger_buffer_opened_signal_cb, NULL, NULL);
+ weechat_hook_signal ("buffer_closing",
+ &logger_buffer_closing_signal_cb, NULL, NULL);
+ weechat_hook_signal ("buffer_renamed",
+ &logger_buffer_renamed_signal_cb, NULL, NULL);
+ weechat_hook_signal ("logger_backlog",
+ &logger_backlog_signal_cb, NULL, NULL);
+ weechat_hook_signal ("logger_start",
+ &logger_start_signal_cb, NULL, NULL);
+ weechat_hook_signal ("logger_stop",
+ &logger_stop_signal_cb, NULL, NULL);
+ weechat_hook_signal ("day_changed",
+ &logger_day_changed_signal_cb, NULL, NULL);
+
+ weechat_hook_print (NULL, NULL, NULL, 1, &logger_print_cb, NULL, NULL);
logger_info_init ();
diff --git a/src/plugins/logger/logger.h b/src/plugins/logger/logger.h
index dc40d1df8..195f7d8da 100644
--- a/src/plugins/logger/logger.h
+++ b/src/plugins/logger/logger.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -32,6 +32,7 @@ extern struct t_hook *logger_timer;
extern void logger_start_buffer_all (int write_info_line);
extern void logger_stop_all (int write_info_line);
extern void logger_adjust_log_filenames ();
-extern int logger_timer_cb (void *data, int remaining_calls);
+extern int logger_timer_cb (const void *pointer, void *data,
+ int remaining_calls);
#endif /* WEECHAT_LOGGER_H */
diff --git a/src/plugins/lua/CMakeLists.txt b/src/plugins/lua/CMakeLists.txt
index 4a075264c..b661285fe 100644
--- a/src/plugins/lua/CMakeLists.txt
+++ b/src/plugins/lua/CMakeLists.txt
@@ -1,6 +1,6 @@
#
# Copyright (C) 2006-2007 Emmanuel Bouthenot <kolter@openics.org>
-# Copyright (C) 2006-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2006-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/lua/Makefile.am b/src/plugins/lua/Makefile.am
index 3ab660885..15a1a4d56 100644
--- a/src/plugins/lua/Makefile.am
+++ b/src/plugins/lua/Makefile.am
@@ -1,6 +1,6 @@
#
# Copyright (C) 2006-2007 Emmanuel Bouthenot <kolter@openics.org>
-# Copyright (C) 2006-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2006-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/lua/weechat-lua-api.c b/src/plugins/lua/weechat-lua-api.c
index cfbe45f9c..ba75aad74 100644
--- a/src/plugins/lua/weechat-lua-api.c
+++ b/src/plugins/lua/weechat-lua-api.c
@@ -2,7 +2,7 @@
* weechat-lua-api.c - lua API functions
*
* Copyright (C) 2006-2007 Emmanuel Bouthenot <kolter@openics.org>
- * Copyright (C) 2006-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2006-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2012 Simon Arlott
*
* This file is part of WeeChat, the extensible chat client.
@@ -33,7 +33,6 @@
#include "../weechat-plugin.h"
#include "../plugin-script.h"
#include "../plugin-script-api.h"
-#include "../plugin-script-callback.h"
#include "weechat-lua.h"
@@ -782,24 +781,26 @@ API_FUNC(list_free)
}
int
-weechat_lua_api_config_reload_cb (void *data,
+weechat_lua_api_config_reload_cb (const void *pointer, void *data,
struct t_config_file *config_file)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
- rc = (int *) weechat_lua_exec (script_callback->script,
+ rc = (int *) weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (!rc)
@@ -842,29 +843,31 @@ API_FUNC(config_new)
}
int
-weechat_lua_api_config_read_cb (void *data,
+weechat_lua_api_config_read_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name, const char *value)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[5];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = API_PTR2STR(section);
func_argv[3] = (option_name) ? (char *)option_name : empty_arg;
func_argv[4] = (value) ? (char *)value : empty_arg;
- rc = (int *) weechat_lua_exec (script_callback->script,
+ rc = (int *) weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sssss", func_argv);
if (!rc)
@@ -886,26 +889,28 @@ weechat_lua_api_config_read_cb (void *data,
}
int
-weechat_lua_api_config_section_write_cb (void *data,
+weechat_lua_api_config_section_write_cb (const void *pointer, void *data,
struct t_config_file *config_file,
const char *section_name)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = (section_name) ? (char *)section_name : empty_arg;
- rc = (int *) weechat_lua_exec (script_callback->script,
+ rc = (int *) weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -925,26 +930,28 @@ weechat_lua_api_config_section_write_cb (void *data,
}
int
-weechat_lua_api_config_section_write_default_cb (void *data,
+weechat_lua_api_config_section_write_default_cb (const void *pointer, void *data,
struct t_config_file *config_file,
const char *section_name)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = (section_name) ? (char *)section_name : empty_arg;
- rc = (int *) weechat_lua_exec (script_callback->script,
+ rc = (int *) weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -964,30 +971,32 @@ weechat_lua_api_config_section_write_default_cb (void *data,
}
int
-weechat_lua_api_config_section_create_option_cb (void *data,
+weechat_lua_api_config_section_create_option_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
const char *value)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[5];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = API_PTR2STR(section);
func_argv[3] = (option_name) ? (char *)option_name : empty_arg;
func_argv[4] = (value) ? (char *)value : empty_arg;
- rc = (int *) weechat_lua_exec (script_callback->script,
+ rc = (int *) weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sssss", func_argv);
if (!rc)
@@ -1009,28 +1018,30 @@ weechat_lua_api_config_section_create_option_cb (void *data,
}
int
-weechat_lua_api_config_section_delete_option_cb (void *data,
+weechat_lua_api_config_section_delete_option_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
struct t_config_option *option)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = API_PTR2STR(section);
func_argv[3] = API_PTR2STR(option);
- rc = (int *) weechat_lua_exec (script_callback->script,
+ rc = (int *) weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssss", func_argv);
if (!rc)
@@ -1082,27 +1093,29 @@ API_FUNC(config_new_section)
function_delete_option = lua_tostring (L, -2);
data_delete_option = lua_tostring (L, -1);
- result = API_PTR2STR(plugin_script_api_config_new_section (weechat_lua_plugin,
- lua_current_script,
- API_STR2PTR(config_file),
- name,
- user_can_add_options,
- user_can_delete_options,
- &weechat_lua_api_config_read_cb,
- function_read,
- data_read,
- &weechat_lua_api_config_section_write_cb,
- function_write,
- data_write,
- &weechat_lua_api_config_section_write_default_cb,
- function_write_default,
- data_write_default,
- &weechat_lua_api_config_section_create_option_cb,
- function_create_option,
- data_create_option,
- &weechat_lua_api_config_section_delete_option_cb,
- function_delete_option,
- data_delete_option));
+ result = API_PTR2STR(
+ plugin_script_api_config_new_section (
+ weechat_lua_plugin,
+ lua_current_script,
+ API_STR2PTR(config_file),
+ name,
+ user_can_add_options,
+ user_can_delete_options,
+ &weechat_lua_api_config_read_cb,
+ function_read,
+ data_read,
+ &weechat_lua_api_config_section_write_cb,
+ function_write,
+ data_write,
+ &weechat_lua_api_config_section_write_default_cb,
+ function_write_default,
+ data_write_default,
+ &weechat_lua_api_config_section_create_option_cb,
+ function_create_option,
+ data_create_option,
+ &weechat_lua_api_config_section_delete_option_cb,
+ function_delete_option,
+ data_delete_option));
API_RETURN_STRING_FREE(result);
}
@@ -1126,26 +1139,28 @@ API_FUNC(config_search_section)
}
int
-weechat_lua_api_config_option_check_value_cb (void *data,
+weechat_lua_api_config_option_check_value_cb (const void *pointer, void *data,
struct t_config_option *option,
const char *value)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(option);
func_argv[2] = (value) ? (char *)value : empty_arg;
- rc = (int *) weechat_lua_exec (script_callback->script,
+ rc = (int *) weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -1165,24 +1180,26 @@ weechat_lua_api_config_option_check_value_cb (void *data,
}
void
-weechat_lua_api_config_option_change_cb (void *data,
+weechat_lua_api_config_option_change_cb (const void *pointer, void *data,
struct t_config_option *option)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(option);
- rc = (int *) weechat_lua_exec (script_callback->script,
+ rc = (int *) weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (func_argv[1])
@@ -1194,24 +1211,26 @@ weechat_lua_api_config_option_change_cb (void *data,
}
void
-weechat_lua_api_config_option_delete_cb (void *data,
+weechat_lua_api_config_option_delete_cb (const void *pointer, void *data,
struct t_config_option *option)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(option);
- rc = (int *) weechat_lua_exec (script_callback->script,
+ rc = (int *) weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (func_argv[1])
@@ -1655,9 +1674,7 @@ API_FUNC(config_option_free)
option = lua_tostring (L, -1);
- plugin_script_api_config_option_free (weechat_lua_plugin,
- lua_current_script,
- API_STR2PTR(option));
+ weechat_config_option_free (API_STR2PTR(option));
API_RETURN_OK;
}
@@ -1672,9 +1689,7 @@ API_FUNC(config_section_free_options)
section = lua_tostring (L, -1);
- plugin_script_api_config_section_free_options (weechat_lua_plugin,
- lua_current_script,
- API_STR2PTR(section));
+ weechat_config_section_free_options (API_STR2PTR(section));
API_RETURN_OK;
}
@@ -1689,9 +1704,7 @@ API_FUNC(config_section_free)
section = lua_tostring (L, -1);
- plugin_script_api_config_section_free (weechat_lua_plugin,
- lua_current_script,
- API_STR2PTR(section));
+ weechat_config_section_free (API_STR2PTR(section));
API_RETURN_OK;
}
@@ -1706,9 +1719,7 @@ API_FUNC(config_free)
config_file = lua_tostring (L, -1);
- plugin_script_api_config_free (weechat_lua_plugin,
- lua_current_script,
- API_STR2PTR(config_file));
+ weechat_config_free (API_STR2PTR(config_file));
API_RETURN_OK;
}
@@ -1975,28 +1986,31 @@ API_FUNC(log_print)
}
int
-weechat_lua_api_hook_command_cb (void *data, struct t_gui_buffer *buffer,
+weechat_lua_api_hook_command_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
/* make C compiler happy */
(void) argv;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
func_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg;
- rc = (int *) weechat_lua_exec (script_callback->script,
+ rc = (int *) weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -2048,25 +2062,28 @@ API_FUNC(hook_command)
}
int
-weechat_lua_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
+weechat_lua_api_hook_command_run_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
const char *command)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
func_argv[2] = (command) ? (char *)command : empty_arg;
- rc = (int *) weechat_lua_exec (script_callback->script,
+ rc = (int *) weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -2109,26 +2126,29 @@ API_FUNC(hook_command_run)
}
int
-weechat_lua_api_hook_timer_cb (void *data, int remaining_calls)
+weechat_lua_api_hook_timer_cb (const void *pointer, void *data,
+ int remaining_calls)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char str_remaining_calls[32], empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (str_remaining_calls, sizeof (str_remaining_calls),
"%d", remaining_calls);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = str_remaining_calls;
- rc = (int *) weechat_lua_exec (script_callback->script,
+ rc = (int *) weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (!rc)
@@ -2174,25 +2194,27 @@ API_FUNC(hook_timer)
}
int
-weechat_lua_api_hook_fd_cb (void *data, int fd)
+weechat_lua_api_hook_fd_cb (const void *pointer, void *data, int fd)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char str_fd[32], empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (str_fd, sizeof (str_fd), "%d", fd);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = str_fd;
- rc = (int *) weechat_lua_exec (script_callback->script,
+ rc = (int *) weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (!rc)
@@ -2240,28 +2262,49 @@ API_FUNC(hook_fd)
}
int
-weechat_lua_api_hook_process_cb (void *data,
+weechat_lua_api_hook_process_cb (const void *pointer, void *data,
const char *command, int return_code,
const char *out, const char *err)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[5];
- char empty_arg[1] = { '\0' };
+ char empty_arg[1] = { '\0' }, *result;
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (return_code == WEECHAT_HOOK_PROCESS_CHILD)
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ if (strncmp (command, "func:", 5) == 0)
+ {
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
+
+ result = (char *) weechat_lua_exec (script,
+ WEECHAT_SCRIPT_EXEC_STRING,
+ command + 5,
+ "s", func_argv);
+ if (result)
+ {
+ printf ("%s", result);
+ free (result);
+ return 0;
+ }
+ }
+ return 1;
+ }
+ else if (ptr_function && ptr_function[0])
+ {
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (command) ? (char *)command : empty_arg;
func_argv[2] = &return_code;
func_argv[3] = (out) ? (char *)out : empty_arg;
func_argv[4] = (err) ? (char *)err : empty_arg;
- rc = (int *) weechat_lua_exec (script_callback->script,
+ rc = (int *) weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssiss", func_argv);
if (!rc)
@@ -2340,34 +2383,37 @@ API_FUNC(hook_process_hashtable)
}
int
-weechat_lua_api_hook_connect_cb (void *data, int status, int gnutls_rc,
+weechat_lua_api_hook_connect_cb (const void *pointer, void *data,
+ int status, int gnutls_rc,
int sock, const char *error,
const char *ip_address)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[6];
char str_status[32], str_gnutls_rc[32], str_sock[32];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (str_status, sizeof (str_status), "%d", status);
snprintf (str_gnutls_rc, sizeof (str_gnutls_rc), "%d", gnutls_rc);
snprintf (str_sock, sizeof (str_sock), "%d", sock);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = str_status;
func_argv[2] = str_gnutls_rc;
func_argv[3] = str_sock;
func_argv[4] = (ip_address) ? (char *)ip_address : empty_arg;
func_argv[5] = (error) ? (char *)error : empty_arg;
- rc = (int *) weechat_lua_exec (script_callback->script,
+ rc = (int *) weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssssss", func_argv);
if (!rc)
@@ -2423,28 +2469,31 @@ API_FUNC(hook_connect)
}
int
-weechat_lua_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
+weechat_lua_api_hook_print_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
time_t date,
int tags_count, const char **tags,
int displayed, int highlight,
const char *prefix, const char *message)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[8];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
static char timebuffer[64];
int *rc, ret;
/* make C compiler happy */
(void) tags_count;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (timebuffer, sizeof (timebuffer), "%ld", (long int)date);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
func_argv[2] = timebuffer;
func_argv[3] = weechat_string_build_with_split_string (tags, ",");
@@ -2455,9 +2504,9 @@ weechat_lua_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
func_argv[6] = (prefix) ? (char *)prefix : empty_arg;
func_argv[7] = (message) ? (char *)message : empty_arg;
- rc = (int *) weechat_lua_exec (script_callback->script,
+ rc = (int *) weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssssiiss", func_argv);
if (!rc)
@@ -2509,20 +2558,23 @@ API_FUNC(hook_print)
}
int
-weechat_lua_api_hook_signal_cb (void *data, const char *signal,
+weechat_lua_api_hook_signal_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
static char str_value[64];
int *rc, ret, free_needed;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (signal) ? (char *)signal : empty_arg;
free_needed = 0;
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
@@ -2547,9 +2599,9 @@ weechat_lua_api_hook_signal_cb (void *data, const char *signal,
else
func_argv[2] = empty_arg;
- rc = (int *) weechat_lua_exec (script_callback->script,
+ rc = (int *) weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -2629,25 +2681,28 @@ API_FUNC(hook_signal_send)
}
int
-weechat_lua_api_hook_hsignal_cb (void *data, const char *signal,
+weechat_lua_api_hook_hsignal_cb (const void *pointer, void *data,
+ const char *signal,
struct t_hashtable *hashtable)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (signal) ? (char *)signal : empty_arg;
func_argv[2] = hashtable;
- rc = (int *) weechat_lua_exec (script_callback->script,
+ rc = (int *) weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssh", func_argv);
if (!rc)
@@ -2712,25 +2767,27 @@ API_FUNC(hook_hsignal_send)
}
int
-weechat_lua_api_hook_config_cb (void *data, const char *option,
- const char *value)
+weechat_lua_api_hook_config_cb (const void *pointer, void *data,
+ const char *option, const char *value)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (option) ? (char *)option : empty_arg;
func_argv[2] = (value) ? (char *)value : empty_arg;
- rc = (int *) weechat_lua_exec (script_callback->script,
+ rc = (int *) weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -2771,27 +2828,30 @@ API_FUNC(hook_config)
}
int
-weechat_lua_api_hook_completion_cb (void *data, const char *completion_item,
+weechat_lua_api_hook_completion_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (completion_item) ? (char *)completion_item : empty_arg;
func_argv[2] = API_PTR2STR(buffer);
func_argv[3] = API_PTR2STR(completion);
- rc = (int *) weechat_lua_exec (script_callback->script,
+ rc = (int *) weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssss", func_argv);
if (!rc)
@@ -2877,26 +2937,29 @@ API_FUNC(hook_completion_list_add)
}
char *
-weechat_lua_api_hook_modifier_cb (void *data, const char *modifier,
+weechat_lua_api_hook_modifier_cb (const void *pointer, void *data,
+ const char *modifier,
const char *modifier_data,
const char *string)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (modifier) ? (char *)modifier : empty_arg;
func_argv[2] = (modifier_data) ? (char *)modifier_data : empty_arg;
func_argv[3] = (string) ? (char *)string : empty_arg;
- return (char *)weechat_lua_exec (script_callback->script,
+ return (char *)weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function,
+ ptr_function,
"ssss", func_argv);
}
@@ -2945,24 +3008,27 @@ API_FUNC(hook_modifier_exec)
}
const char *
-weechat_lua_api_hook_info_cb (void *data, const char *info_name,
+weechat_lua_api_hook_info_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (info_name) ? (char *)info_name : empty_arg;
func_argv[2] = (arguments) ? (char *)arguments : empty_arg;
- return (const char *)weechat_lua_exec (script_callback->script,
+ return (const char *)weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
}
@@ -2997,25 +3063,29 @@ API_FUNC(hook_info)
}
struct t_hashtable *
-weechat_lua_api_hook_info_hashtable_cb (void *data, const char *info_name,
+weechat_lua_api_hook_info_hashtable_cb (const void *pointer, void *data,
+ const char *info_name,
struct t_hashtable *hashtable)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (info_name) ? (char *)info_name : empty_arg;
func_argv[2] = hashtable;
- return (struct t_hashtable *)weechat_lua_exec (script_callback->script,
- WEECHAT_SCRIPT_EXEC_HASHTABLE,
- script_callback->function,
- "ssh", func_argv);
+ return (struct t_hashtable *)weechat_lua_exec (
+ script,
+ WEECHAT_SCRIPT_EXEC_HASHTABLE,
+ ptr_function,
+ "ssh", func_argv);
}
return NULL;
@@ -3052,27 +3122,31 @@ API_FUNC(hook_info_hashtable)
}
struct t_infolist *
-weechat_lua_api_hook_infolist_cb (void *data, const char *info_name,
- void *pointer, const char *arguments)
+weechat_lua_api_hook_infolist_cb (const void *pointer, void *data,
+ const char *info_name,
+ void *obj_pointer, const char *arguments)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
struct t_infolist *result;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (info_name) ? (char *)info_name : empty_arg;
- func_argv[2] = API_PTR2STR(pointer);
+ func_argv[2] = API_PTR2STR(obj_pointer);
func_argv[3] = (arguments) ? (char *)arguments : empty_arg;
- result = (struct t_infolist *)weechat_lua_exec (script_callback->script,
- WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function,
- "ssss", func_argv);
+ result = (struct t_infolist *)weechat_lua_exec (
+ script,
+ WEECHAT_SCRIPT_EXEC_STRING,
+ ptr_function,
+ "ssss", func_argv);
if (func_argv[2])
free (func_argv[2]);
@@ -3114,24 +3188,27 @@ API_FUNC(hook_infolist)
}
struct t_hashtable *
-weechat_lua_api_hook_focus_cb (void *data,
+weechat_lua_api_hook_focus_cb (const void *pointer, void *data,
struct t_hashtable *info)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = info;
- return (struct t_hashtable *)weechat_lua_exec (script_callback->script,
- WEECHAT_SCRIPT_EXEC_HASHTABLE,
- script_callback->function,
- "sh", func_argv);
+ return (struct t_hashtable *)weechat_lua_exec (
+ script,
+ WEECHAT_SCRIPT_EXEC_HASHTABLE,
+ ptr_function,
+ "sh", func_argv);
}
return NULL;
@@ -3187,9 +3264,7 @@ API_FUNC(unhook)
hook = lua_tostring (L, -1);
- plugin_script_api_unhook (weechat_lua_plugin,
- lua_current_script,
- API_STR2PTR(hook));
+ weechat_unhook (API_STR2PTR(hook));
API_RETURN_OK;
}
@@ -3198,31 +3273,34 @@ API_FUNC(unhook_all)
{
API_INIT_FUNC(1, "unhook_all", API_RETURN_ERROR);
- plugin_script_api_unhook_all (weechat_lua_plugin, lua_current_script);
+ weechat_unhook_all (lua_current_script->name);
API_RETURN_OK;
}
int
-weechat_lua_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
+weechat_lua_api_buffer_input_data_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
const char *input_data)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
func_argv[2] = (input_data) ? (char *)input_data : empty_arg;
- rc = (int *) weechat_lua_exec (script_callback->script,
+ rc = (int *) weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -3242,23 +3320,26 @@ weechat_lua_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
}
int
-weechat_lua_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
+weechat_lua_api_buffer_close_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
- rc = (int *) weechat_lua_exec (script_callback->script,
+ rc = (int *) weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (!rc)
@@ -3370,9 +3451,7 @@ API_FUNC(buffer_close)
buffer = lua_tostring (L, -1);
- plugin_script_api_buffer_close (weechat_lua_plugin,
- lua_current_script,
- API_STR2PTR(buffer));
+ weechat_buffer_close (API_STR2PTR(buffer));
API_RETURN_OK;
}
@@ -3931,31 +4010,34 @@ API_FUNC(bar_item_search)
}
char *
-weechat_lua_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
+weechat_lua_api_bar_item_build_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
struct t_gui_window *window,
struct t_gui_buffer *buffer,
struct t_hashtable *extra_info)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[5];
char empty_arg[1] = { '\0' }, *ret;
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- if (strncmp (script_callback->function, "(extra)", 7) == 0)
+ if (strncmp (ptr_function, "(extra)", 7) == 0)
{
/* new callback: data, item, window, buffer, extra_info */
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(item);
func_argv[2] = API_PTR2STR(window);
func_argv[3] = API_PTR2STR(buffer);
func_argv[4] = extra_info;
- ret = (char *)weechat_lua_exec (script_callback->script,
+ ret = (char *)weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function + 7,
+ ptr_function + 7,
"ssssh", func_argv);
if (func_argv[1])
@@ -3968,13 +4050,13 @@ weechat_lua_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
else
{
/* old callback: data, item, window */
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(item);
func_argv[2] = API_PTR2STR(window);
- ret = (char *)weechat_lua_exec (script_callback->script,
+ ret = (char *)weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (func_argv[1])
@@ -4037,9 +4119,7 @@ API_FUNC(bar_item_remove)
item = lua_tostring (L, -1);
- plugin_script_api_bar_item_remove (weechat_lua_plugin,
- lua_current_script,
- API_STR2PTR(item));
+ weechat_bar_item_remove (API_STR2PTR(item));
API_RETURN_OK;
}
@@ -4887,69 +4967,33 @@ API_FUNC(hdata_get_string)
API_RETURN_STRING(result);
}
-API_FUNC(upgrade_new)
-{
- const char *filename;
- char *result;
- int write;
-
- API_INIT_FUNC(1, "upgrade_new", API_RETURN_EMPTY);
- if (lua_gettop (L) < 2)
- API_WRONG_ARGS(API_RETURN_EMPTY);
-
- filename = lua_tostring (L, -2);
- write = lua_tonumber (L, -1);
-
- result = API_PTR2STR(weechat_upgrade_new (filename, write));
-
- API_RETURN_STRING_FREE(result);
-}
-
-API_FUNC(upgrade_write_object)
-{
- const char *upgrade_file, *infolist;
- int object_id, rc;
-
- API_INIT_FUNC(1, "upgrade_write_object", API_RETURN_INT(0));
- if (lua_gettop (L) < 3)
- API_WRONG_ARGS(API_RETURN_INT(0));
-
- upgrade_file = lua_tostring (L, -3);
- object_id = lua_tonumber (L, -2);
- infolist = lua_tostring (L, -1);
-
- rc = weechat_upgrade_write_object (API_STR2PTR(upgrade_file),
- object_id,
- API_STR2PTR(infolist));
-
- API_RETURN_INT(rc);
-}
-
int
-weechat_lua_api_upgrade_read_cb (void *data,
+weechat_lua_api_upgrade_read_cb (const void *pointer, void *data,
struct t_upgrade_file *upgrade_file,
int object_id,
struct t_infolist *infolist)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' }, str_object_id[32];
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (str_object_id, sizeof (str_object_id), "%d", object_id);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(upgrade_file);
func_argv[2] = str_object_id;
func_argv[3] = API_PTR2STR(infolist);
- rc = (int *) weechat_lua_exec (script_callback->script,
+ rc = (int *) weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssss", func_argv);
if (!rc)
@@ -4970,25 +5014,63 @@ weechat_lua_api_upgrade_read_cb (void *data,
return WEECHAT_RC_ERROR;
}
+API_FUNC(upgrade_new)
+{
+ const char *filename, *function, *data;
+ char *result;
+
+ API_INIT_FUNC(1, "upgrade_new", API_RETURN_EMPTY);
+ if (lua_gettop (L) < 3)
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ filename = lua_tostring (L, -3);
+ function = lua_tostring (L, -2);
+ data = lua_tostring (L, -1);
+
+ result = API_PTR2STR(
+ plugin_script_api_upgrade_new (
+ weechat_lua_plugin,
+ lua_current_script,
+ filename,
+ &weechat_lua_api_upgrade_read_cb,
+ function,
+ data));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+API_FUNC(upgrade_write_object)
+{
+ const char *upgrade_file, *infolist;
+ int object_id, rc;
+
+ API_INIT_FUNC(1, "upgrade_write_object", API_RETURN_INT(0));
+ if (lua_gettop (L) < 3)
+ API_WRONG_ARGS(API_RETURN_INT(0));
+
+ upgrade_file = lua_tostring (L, -3);
+ object_id = lua_tonumber (L, -2);
+ infolist = lua_tostring (L, -1);
+
+ rc = weechat_upgrade_write_object (API_STR2PTR(upgrade_file),
+ object_id,
+ API_STR2PTR(infolist));
+
+ API_RETURN_INT(rc);
+}
+
API_FUNC(upgrade_read)
{
- const char *upgrade_file, *function, *data;
+ const char *upgrade_file;
int rc;
API_INIT_FUNC(1, "upgrade_read", API_RETURN_INT(0));
- if (lua_gettop (L) < 3)
+ if (lua_gettop (L) < 1)
API_WRONG_ARGS(API_RETURN_INT(0));
- upgrade_file = lua_tostring (L, -3);
- function = lua_tostring (L, -2);
- data = lua_tostring (L, -1);
+ upgrade_file = lua_tostring (L, -1);
- rc = plugin_script_api_upgrade_read (weechat_lua_plugin,
- lua_current_script,
- API_STR2PTR(upgrade_file),
- &weechat_lua_api_upgrade_read_cb,
- function,
- data);
+ rc = weechat_upgrade_read (API_STR2PTR(upgrade_file));
API_RETURN_INT(rc);
}
diff --git a/src/plugins/lua/weechat-lua-api.h b/src/plugins/lua/weechat-lua-api.h
index 65abd09fc..5143a5041 100644
--- a/src/plugins/lua/weechat-lua-api.h
+++ b/src/plugins/lua/weechat-lua-api.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2006-2007 Emmanuel Bouthenot <kolter@openics.org>
- * Copyright (C) 2006-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2006-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -24,10 +24,12 @@
extern struct luaL_Reg weechat_lua_api_funcs[];
extern struct t_lua_const weechat_lua_api_consts[];
-extern int weechat_lua_api_buffer_input_data_cb (void *data,
+extern int weechat_lua_api_buffer_input_data_cb (const void *pointer,
+ void *data,
struct t_gui_buffer *buffer,
const char *input_data);
-extern int weechat_lua_api_buffer_close_cb (void *data,
+extern int weechat_lua_api_buffer_close_cb (const void *pointer,
+ void *data,
struct t_gui_buffer *buffer);
#endif /* WEECHAT_LUA_API_H */
diff --git a/src/plugins/lua/weechat-lua.c b/src/plugins/lua/weechat-lua.c
index e78ebddf2..fbb08cad1 100644
--- a/src/plugins/lua/weechat-lua.c
+++ b/src/plugins/lua/weechat-lua.c
@@ -2,7 +2,7 @@
* weechat-lua.c - lua plugin for WeeChat
*
* Copyright (C) 2006-2007 Emmanuel Bouthenot <kolter@openics.org>
- * Copyright (C) 2006-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2006-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -204,7 +204,19 @@ weechat_lua_exec (struct t_plugin_script *script, int ret_type,
{
if (ret_type == WEECHAT_SCRIPT_EXEC_STRING)
{
- ret_value = strdup ((char *) lua_tostring (lua_current_interpreter, -1));
+ ret_value = (char *) lua_tostring (lua_current_interpreter, -1);
+ if (ret_value)
+ {
+ ret_value = strdup (ret_value);
+ }
+ else
+ {
+ weechat_printf (NULL,
+ weechat_gettext ("%s%s: function \"%s\" must "
+ "return a valid value"),
+ weechat_prefix ("error"), LUA_PLUGIN_NAME,
+ function);
+ }
}
else if (ret_type == WEECHAT_SCRIPT_EXEC_INT)
{
@@ -606,12 +618,14 @@ weechat_lua_unload_all ()
*/
int
-weechat_lua_command_cb (void *data, struct t_gui_buffer *buffer,
+weechat_lua_command_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
char *ptr_name, *path_script;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
@@ -707,11 +721,13 @@ weechat_lua_command_cb (void *data, struct t_gui_buffer *buffer,
*/
int
-weechat_lua_completion_cb (void *data, const char *completion_item,
+weechat_lua_completion_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -726,9 +742,11 @@ weechat_lua_completion_cb (void *data, const char *completion_item,
*/
struct t_hdata *
-weechat_lua_hdata_cb (void *data, const char *hdata_name)
+weechat_lua_hdata_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
return plugin_script_hdata_script (weechat_plugin,
@@ -741,10 +759,12 @@ weechat_lua_hdata_cb (void *data, const char *hdata_name)
*/
struct t_infolist *
-weechat_lua_infolist_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+weechat_lua_infolist_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (!infolist_name || !infolist_name[0])
@@ -753,7 +773,7 @@ weechat_lua_infolist_cb (void *data, const char *infolist_name,
if (weechat_strcasecmp (infolist_name, "lua_script") == 0)
{
return plugin_script_infolist_list_scripts (weechat_lua_plugin,
- lua_scripts, pointer,
+ lua_scripts, obj_pointer,
arguments);
}
@@ -765,10 +785,12 @@ weechat_lua_infolist_cb (void *data, const char *infolist_name,
*/
int
-weechat_lua_signal_debug_dump_cb (void *data, const char *signal,
+weechat_lua_signal_debug_dump_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -787,10 +809,12 @@ weechat_lua_signal_debug_dump_cb (void *data, const char *signal,
*/
int
-weechat_lua_signal_debug_libs_cb (void *data, const char *signal,
+weechat_lua_signal_debug_libs_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -806,37 +830,20 @@ weechat_lua_signal_debug_libs_cb (void *data, const char *signal,
}
/*
- * Callback called when a buffer is closed.
- */
-
-int
-weechat_lua_signal_buffer_closed_cb (void *data, const char *signal,
- const char *type_data, void *signal_data)
-{
- /* make C compiler happy */
- (void) data;
- (void) signal;
- (void) type_data;
-
- if (signal_data)
- plugin_script_remove_buffer_callbacks (lua_scripts, signal_data);
-
- return WEECHAT_RC_OK;
-}
-
-/*
* Timer for executing actions.
*/
int
-weechat_lua_timer_action_cb (void *data, int remaining_calls)
+weechat_lua_timer_action_cb (const void *pointer, void *data,
+ int remaining_calls)
{
/* make C compiler happy */
+ (void) data;
(void) remaining_calls;
- if (data)
+ if (pointer)
{
- if (data == &lua_action_install_list)
+ if (pointer == &lua_action_install_list)
{
plugin_script_action_install (weechat_lua_plugin,
lua_scripts,
@@ -845,7 +852,7 @@ weechat_lua_timer_action_cb (void *data, int remaining_calls)
&lua_quiet,
&lua_action_install_list);
}
- else if (data == &lua_action_remove_list)
+ else if (pointer == &lua_action_remove_list)
{
plugin_script_action_remove (weechat_lua_plugin,
lua_scripts,
@@ -853,7 +860,7 @@ weechat_lua_timer_action_cb (void *data, int remaining_calls)
&lua_quiet,
&lua_action_remove_list);
}
- else if (data == &lua_action_autoload_list)
+ else if (pointer == &lua_action_autoload_list)
{
plugin_script_action_autoload (weechat_lua_plugin,
&lua_quiet,
@@ -869,11 +876,13 @@ weechat_lua_timer_action_cb (void *data, int remaining_calls)
*/
int
-weechat_lua_signal_script_action_cb (void *data, const char *signal,
+weechat_lua_signal_script_action_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data,
void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
@@ -884,7 +893,7 @@ weechat_lua_signal_script_action_cb (void *data, const char *signal,
(const char *)signal_data);
weechat_hook_timer (1, 0, 1,
&weechat_lua_timer_action_cb,
- &lua_action_install_list);
+ &lua_action_install_list, NULL);
}
else if (strcmp (signal, "lua_script_remove") == 0)
{
@@ -892,7 +901,7 @@ weechat_lua_signal_script_action_cb (void *data, const char *signal,
(const char *)signal_data);
weechat_hook_timer (1, 0, 1,
&weechat_lua_timer_action_cb,
- &lua_action_remove_list);
+ &lua_action_remove_list, NULL);
}
else if (strcmp (signal, "lua_script_autoload") == 0)
{
@@ -900,7 +909,7 @@ weechat_lua_signal_script_action_cb (void *data, const char *signal,
(const char *)signal_data);
weechat_hook_timer (1, 0, 1,
&weechat_lua_timer_action_cb,
- &lua_action_autoload_list);
+ &lua_action_autoload_list, NULL);
}
}
@@ -924,7 +933,6 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
init.callback_infolist = &weechat_lua_infolist_cb;
init.callback_signal_debug_dump = &weechat_lua_signal_debug_dump_cb;
init.callback_signal_debug_libs = &weechat_lua_signal_debug_libs_cb;
- init.callback_signal_buffer_closed = &weechat_lua_signal_buffer_closed_cb;
init.callback_signal_script_action = &weechat_lua_signal_script_action_cb;
init.callback_load_file = &weechat_lua_load_cb;
diff --git a/src/plugins/lua/weechat-lua.h b/src/plugins/lua/weechat-lua.h
index 0a760babf..dee5d2f09 100644
--- a/src/plugins/lua/weechat-lua.h
+++ b/src/plugins/lua/weechat-lua.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2006-2007 Emmanuel Bouthenot <kolter@openics.org>
- * Copyright (C) 2006-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2006-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/perl/CMakeLists.txt b/src/plugins/perl/CMakeLists.txt
index 41b2f8fa1..5dac3d925 100644
--- a/src/plugins/perl/CMakeLists.txt
+++ b/src/plugins/perl/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/perl/Makefile.am b/src/plugins/perl/Makefile.am
index b011f0caf..49eedeae3 100644
--- a/src/plugins/perl/Makefile.am
+++ b/src/plugins/perl/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/perl/weechat-perl-api.c b/src/plugins/perl/weechat-perl-api.c
index 61631c72b..4233f70c6 100644
--- a/src/plugins/perl/weechat-perl-api.c
+++ b/src/plugins/perl/weechat-perl-api.c
@@ -1,7 +1,7 @@
/*
* weechat-perl-api.c - perl API functions
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2005-2008 Emmanuel Bouthenot <kolter@openics.org>
* Copyright (C) 2012 Simon Arlott
*
@@ -31,7 +31,6 @@
#include "../weechat-plugin.h"
#include "../plugin-script.h"
#include "../plugin-script-api.h"
-#include "../plugin-script-callback.h"
#include "weechat-perl.h"
@@ -762,24 +761,26 @@ API_FUNC(list_free)
}
int
-weechat_perl_api_config_reload_cb (void *data,
+weechat_perl_api_config_reload_cb (const void *pointer, void *data,
struct t_config_file *config_file)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
- rc = (int *) weechat_perl_exec (script_callback->script,
+ rc = (int *) weechat_perl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (!rc)
@@ -822,30 +823,32 @@ API_FUNC(config_new)
}
int
-weechat_perl_api_config_section_read_cb (void *data,
+weechat_perl_api_config_section_read_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
const char *value)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[5];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = API_PTR2STR(section);
func_argv[3] = (option_name) ? (char *)option_name : empty_arg;
func_argv[4] = (value) ? (char *)value : empty_arg;
- rc = (int *) weechat_perl_exec (script_callback->script,
+ rc = (int *) weechat_perl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sssss", func_argv);
if (!rc)
@@ -867,26 +870,28 @@ weechat_perl_api_config_section_read_cb (void *data,
}
int
-weechat_perl_api_config_section_write_cb (void *data,
+weechat_perl_api_config_section_write_cb (const void *pointer, void *data,
struct t_config_file *config_file,
const char *section_name)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = (section_name) ? (char *)section_name : empty_arg;
- rc = (int *) weechat_perl_exec (script_callback->script,
+ rc = (int *) weechat_perl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -906,26 +911,28 @@ weechat_perl_api_config_section_write_cb (void *data,
}
int
-weechat_perl_api_config_section_write_default_cb (void *data,
+weechat_perl_api_config_section_write_default_cb (const void *pointer, void *data,
struct t_config_file *config_file,
const char *section_name)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = (section_name) ? (char *)section_name : empty_arg;
- rc = (int *) weechat_perl_exec (script_callback->script,
+ rc = (int *) weechat_perl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -945,30 +952,32 @@ weechat_perl_api_config_section_write_default_cb (void *data,
}
int
-weechat_perl_api_config_section_create_option_cb (void *data,
+weechat_perl_api_config_section_create_option_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
const char *value)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[5];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = API_PTR2STR(section);
func_argv[3] = (option_name) ? (char *)option_name : empty_arg;
func_argv[4] = (value) ? (char *)value : empty_arg;
- rc = (int *) weechat_perl_exec (script_callback->script,
+ rc = (int *) weechat_perl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sssss", func_argv);
if (!rc)
@@ -990,28 +999,30 @@ weechat_perl_api_config_section_create_option_cb (void *data,
}
int
-weechat_perl_api_config_section_delete_option_cb (void *data,
+weechat_perl_api_config_section_delete_option_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
struct t_config_option *option)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = API_PTR2STR(section);
func_argv[3] = API_PTR2STR(option);
- rc = (int *) weechat_perl_exec (script_callback->script,
+ rc = (int *) weechat_perl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssss", func_argv);
if (!rc)
@@ -1060,27 +1071,29 @@ API_FUNC(config_new_section)
function_delete_option = SvPV_nolen (ST (12));
data_delete_option = SvPV_nolen (ST (13));
- result = API_PTR2STR(plugin_script_api_config_new_section (weechat_perl_plugin,
- perl_current_script,
- API_STR2PTR(cfg_file),
- name,
- SvIV (ST (2)), /* user_can_add_options */
- SvIV (ST (3)), /* user_can_delete_options */
- &weechat_perl_api_config_section_read_cb,
- function_read,
- data_read,
- &weechat_perl_api_config_section_write_cb,
- function_write,
- data_write,
- &weechat_perl_api_config_section_write_default_cb,
- function_write_default,
- data_write_default,
- &weechat_perl_api_config_section_create_option_cb,
- function_create_option,
- data_create_option,
- &weechat_perl_api_config_section_delete_option_cb,
- function_delete_option,
- data_delete_option));
+ result = API_PTR2STR(
+ plugin_script_api_config_new_section (
+ weechat_perl_plugin,
+ perl_current_script,
+ API_STR2PTR(cfg_file),
+ name,
+ SvIV (ST (2)), /* user_can_add_options */
+ SvIV (ST (3)), /* user_can_delete_options */
+ &weechat_perl_api_config_section_read_cb,
+ function_read,
+ data_read,
+ &weechat_perl_api_config_section_write_cb,
+ function_write,
+ data_write,
+ &weechat_perl_api_config_section_write_default_cb,
+ function_write_default,
+ data_write_default,
+ &weechat_perl_api_config_section_create_option_cb,
+ function_create_option,
+ data_create_option,
+ &weechat_perl_api_config_section_delete_option_cb,
+ function_delete_option,
+ data_delete_option));
API_RETURN_STRING_FREE(result);
}
@@ -1104,26 +1117,28 @@ API_FUNC(config_search_section)
}
int
-weechat_perl_api_config_option_check_value_cb (void *data,
+weechat_perl_api_config_option_check_value_cb (const void *pointer, void *data,
struct t_config_option *option,
const char *value)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(option);
func_argv[2] = (value) ? (char *)value : empty_arg;
- rc = (int *) weechat_perl_exec (script_callback->script,
+ rc = (int *) weechat_perl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -1143,24 +1158,26 @@ weechat_perl_api_config_option_check_value_cb (void *data,
}
void
-weechat_perl_api_config_option_change_cb (void *data,
+weechat_perl_api_config_option_change_cb (const void *pointer, void *data,
struct t_config_option *option)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(option);
- rc = (int *) weechat_perl_exec (script_callback->script,
+ rc = (int *) weechat_perl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (func_argv[1])
@@ -1172,24 +1189,26 @@ weechat_perl_api_config_option_change_cb (void *data,
}
void
-weechat_perl_api_config_option_delete_cb (void *data,
+weechat_perl_api_config_option_delete_cb (const void *pointer, void *data,
struct t_config_option *option)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(option);
- rc = (int *) weechat_perl_exec (script_callback->script,
+ rc = (int *) weechat_perl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (func_argv[1])
@@ -1605,9 +1624,7 @@ API_FUNC(config_option_free)
if (items < 1)
API_WRONG_ARGS(API_RETURN_ERROR);
- plugin_script_api_config_option_free (weechat_perl_plugin,
- perl_current_script,
- API_STR2PTR(SvPV_nolen (ST (0)))); /* option */
+ weechat_config_option_free (API_STR2PTR(SvPV_nolen (ST (0)))); /* option */
API_RETURN_OK;
}
@@ -1620,9 +1637,8 @@ API_FUNC(config_section_free_options)
if (items < 1)
API_WRONG_ARGS(API_RETURN_ERROR);
- plugin_script_api_config_section_free_options (weechat_perl_plugin,
- perl_current_script,
- API_STR2PTR(SvPV_nolen (ST (0)))); /* section */
+ weechat_config_section_free_options (
+ API_STR2PTR(SvPV_nolen (ST (0)))); /* section */
API_RETURN_OK;
}
@@ -1635,9 +1651,8 @@ API_FUNC(config_section_free)
if (items < 1)
API_WRONG_ARGS(API_RETURN_ERROR);
- plugin_script_api_config_section_free (weechat_perl_plugin,
- perl_current_script,
- API_STR2PTR(SvPV_nolen (ST (0)))); /* section */
+ weechat_config_section_free (
+ API_STR2PTR(SvPV_nolen (ST (0)))); /* section */
API_RETURN_OK;
}
@@ -1650,9 +1665,7 @@ API_FUNC(config_free)
if (items < 1)
API_WRONG_ARGS(API_RETURN_ERROR);
- plugin_script_api_config_free (weechat_perl_plugin,
- perl_current_script,
- API_STR2PTR(SvPV_nolen (ST (0)))); /* config_file */
+ weechat_config_free (API_STR2PTR(SvPV_nolen (ST (0)))); /* config_file */
API_RETURN_OK;
}
@@ -1918,28 +1931,31 @@ API_FUNC(log_print)
}
int
-weechat_perl_api_hook_command_cb (void *data, struct t_gui_buffer *buffer,
+weechat_perl_api_hook_command_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
/* make C compiler happy */
(void) argv;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
func_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg;
- rc = (int *) weechat_perl_exec (script_callback->script,
+ rc = (int *) weechat_perl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -1991,25 +2007,28 @@ API_FUNC(hook_command)
}
int
-weechat_perl_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
+weechat_perl_api_hook_command_run_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
const char *command)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
func_argv[2] = (command) ? (char *)command : empty_arg;
- rc = (int *) weechat_perl_exec (script_callback->script,
+ rc = (int *) weechat_perl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -2052,26 +2071,29 @@ API_FUNC(hook_command_run)
}
int
-weechat_perl_api_hook_timer_cb (void *data, int remaining_calls)
+weechat_perl_api_hook_timer_cb (const void *pointer, void *data,
+ int remaining_calls)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char str_remaining_calls[32], empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (str_remaining_calls, sizeof (str_remaining_calls),
"%d", remaining_calls);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = str_remaining_calls;
- rc = (int *) weechat_perl_exec (script_callback->script,
+ rc = (int *) weechat_perl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (!rc)
@@ -2110,25 +2132,27 @@ API_FUNC(hook_timer)
}
int
-weechat_perl_api_hook_fd_cb (void *data, int fd)
+weechat_perl_api_hook_fd_cb (const void *pointer, void *data, int fd)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char str_fd[32], empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (str_fd, sizeof (str_fd), "%d", fd);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = str_fd;
- rc = (int *) weechat_perl_exec (script_callback->script,
+ rc = (int *) weechat_perl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (!rc)
@@ -2168,28 +2192,49 @@ API_FUNC(hook_fd)
}
int
-weechat_perl_api_hook_process_cb (void *data,
+weechat_perl_api_hook_process_cb (const void *pointer, void *data,
const char *command, int return_code,
const char *out, const char *err)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[5];
- char empty_arg[1] = { '\0' };
+ char empty_arg[1] = { '\0' }, *result;
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (return_code == WEECHAT_HOOK_PROCESS_CHILD)
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ if (strncmp (command, "func:", 5) == 0)
+ {
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
+
+ result = (char *) weechat_perl_exec (script,
+ WEECHAT_SCRIPT_EXEC_STRING,
+ command + 5,
+ "s", func_argv);
+ if (result)
+ {
+ printf ("%s", result);
+ free (result);
+ return 0;
+ }
+ }
+ return 1;
+ }
+ else if (ptr_function && ptr_function[0])
+ {
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (command) ? (char *)command : empty_arg;
func_argv[2] = &return_code;
func_argv[3] = (out) ? (char *)out : empty_arg;
func_argv[4] = (err) ? (char *)err : empty_arg;
- rc = (int *) weechat_perl_exec (script_callback->script,
+ rc = (int *) weechat_perl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssiss", func_argv);
if (!rc)
@@ -2264,34 +2309,37 @@ API_FUNC(hook_process_hashtable)
}
int
-weechat_perl_api_hook_connect_cb (void *data, int status, int gnutls_rc,
+weechat_perl_api_hook_connect_cb (const void *pointer, void *data,
+ int status, int gnutls_rc,
int sock, const char *error,
const char *ip_address)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[6];
char str_status[32], str_gnutls_rc[32], str_sock[32];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (str_status, sizeof (str_status), "%d", status);
snprintf (str_gnutls_rc, sizeof (str_gnutls_rc), "%d", gnutls_rc);
snprintf (str_sock, sizeof (str_sock), "%d", sock);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = str_status;
func_argv[2] = str_gnutls_rc;
func_argv[3] = str_sock;
func_argv[4] = (ip_address) ? (char *)ip_address : empty_arg;
func_argv[5] = (error) ? (char *)error : empty_arg;
- rc = (int *) weechat_perl_exec (script_callback->script,
+ rc = (int *) weechat_perl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssssss", func_argv);
if (!rc)
@@ -2343,28 +2391,31 @@ API_FUNC(hook_connect)
}
int
-weechat_perl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
+weechat_perl_api_hook_print_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
time_t date,
int tags_count, const char **tags,
int displayed, int highlight,
const char *prefix, const char *message)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[8];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
static char timebuffer[64];
int *rc, ret;
/* make C compiler happy */
(void) tags_count;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (timebuffer, sizeof (timebuffer), "%ld", (long int)date);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
func_argv[2] = timebuffer;
func_argv[3] = weechat_string_build_with_split_string (tags, ",");
@@ -2375,9 +2426,9 @@ weechat_perl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
func_argv[6] = (prefix) ? (char *)prefix : empty_arg;
func_argv[7] = (message) ? (char *)message : empty_arg;
- rc = (int *) weechat_perl_exec (script_callback->script,
+ rc = (int *) weechat_perl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssssiiss", func_argv);
if (!rc)
@@ -2427,20 +2478,23 @@ API_FUNC(hook_print)
}
int
-weechat_perl_api_hook_signal_cb (void *data, const char *signal, const char *type_data,
+weechat_perl_api_hook_signal_cb (const void *pointer, void *data,
+ const char *signal, const char *type_data,
void *signal_data)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
static char str_value[64];
int *rc, ret, free_needed;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (signal) ? (char *)signal : empty_arg;
free_needed = 0;
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
@@ -2465,9 +2519,9 @@ weechat_perl_api_hook_signal_cb (void *data, const char *signal, const char *typ
else
func_argv[2] = empty_arg;
- rc = (int *) weechat_perl_exec (script_callback->script,
+ rc = (int *) weechat_perl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -2548,25 +2602,28 @@ API_FUNC(hook_signal_send)
}
int
-weechat_perl_api_hook_hsignal_cb (void *data, const char *signal,
+weechat_perl_api_hook_hsignal_cb (const void *pointer, void *data,
+ const char *signal,
struct t_hashtable *hashtable)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (signal) ? (char *)signal : empty_arg;
func_argv[2] = hashtable;
- rc = (int *) weechat_perl_exec (script_callback->script,
+ rc = (int *) weechat_perl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssh", func_argv);
if (!rc)
@@ -2632,24 +2689,27 @@ API_FUNC(hook_hsignal_send)
}
int
-weechat_perl_api_hook_config_cb (void *data, const char *option, const char *value)
+weechat_perl_api_hook_config_cb (const void *pointer, void *data,
+ const char *option, const char *value)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (option) ? (char *)option : empty_arg;
func_argv[2] = (value) ? (char *)value : empty_arg;
- rc = (int *) weechat_perl_exec (script_callback->script,
+ rc = (int *) weechat_perl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -2690,27 +2750,30 @@ API_FUNC(hook_config)
}
int
-weechat_perl_api_hook_completion_cb (void *data, const char *completion_item,
+weechat_perl_api_hook_completion_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (completion_item) ? (char *)completion_item : empty_arg;
func_argv[2] = API_PTR2STR(buffer);
func_argv[3] = API_PTR2STR(completion);
- rc = (int *) weechat_perl_exec (script_callback->script,
+ rc = (int *) weechat_perl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssss", func_argv);
if (!rc)
@@ -2797,25 +2860,29 @@ API_FUNC(hook_completion_list_add)
}
char *
-weechat_perl_api_hook_modifier_cb (void *data, const char *modifier,
- const char *modifier_data, const char *string)
+weechat_perl_api_hook_modifier_cb (const void *pointer, void *data,
+ const char *modifier,
+ const char *modifier_data,
+ const char *string)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (modifier) ? (char *)modifier : empty_arg;
func_argv[2] = (modifier_data) ? (char *)modifier_data : empty_arg;
func_argv[3] = (string) ? (char *)string : empty_arg;
- return (char *)weechat_perl_exec (script_callback->script,
+ return (char *)weechat_perl_exec (script,
WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function,
+ ptr_function,
"ssss", func_argv);
}
@@ -2864,24 +2931,27 @@ API_FUNC(hook_modifier_exec)
}
const char *
-weechat_perl_api_hook_info_cb (void *data, const char *info_name,
+weechat_perl_api_hook_info_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (info_name) ? (char *)info_name : empty_arg;
func_argv[2] = (arguments) ? (char *)arguments : empty_arg;
- return (const char *)weechat_perl_exec (script_callback->script,
+ return (const char *)weechat_perl_exec (script,
WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
}
@@ -2916,25 +2986,29 @@ API_FUNC(hook_info)
}
struct t_hashtable *
-weechat_perl_api_hook_info_hashtable_cb (void *data, const char *info_name,
+weechat_perl_api_hook_info_hashtable_cb (const void *pointer, void *data,
+ const char *info_name,
struct t_hashtable *hashtable)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (info_name) ? (char *)info_name : empty_arg;
func_argv[2] = hashtable;
- return (struct t_hashtable *)weechat_perl_exec (script_callback->script,
- WEECHAT_SCRIPT_EXEC_HASHTABLE,
- script_callback->function,
- "ssh", func_argv);
+ return (struct t_hashtable *)weechat_perl_exec (
+ script,
+ WEECHAT_SCRIPT_EXEC_HASHTABLE,
+ ptr_function,
+ "ssh", func_argv);
}
return NULL;
@@ -2971,27 +3045,31 @@ API_FUNC(hook_info_hashtable)
}
struct t_infolist *
-weechat_perl_api_hook_infolist_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+weechat_perl_api_hook_infolist_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
struct t_infolist *result;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (infolist_name) ? (char *)infolist_name : empty_arg;
- func_argv[2] = API_PTR2STR(pointer);
+ func_argv[2] = API_PTR2STR(obj_pointer);
func_argv[3] = (arguments) ? (char *)arguments : empty_arg;
- result = (struct t_infolist *)weechat_perl_exec (script_callback->script,
- WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function,
- "ssss", func_argv);
+ result = (struct t_infolist *)weechat_perl_exec (
+ script,
+ WEECHAT_SCRIPT_EXEC_STRING,
+ ptr_function,
+ "ssss", func_argv);
if (func_argv[2])
free (func_argv[2]);
@@ -3033,24 +3111,27 @@ API_FUNC(hook_infolist)
}
struct t_hashtable *
-weechat_perl_api_hook_focus_cb (void *data,
+weechat_perl_api_hook_focus_cb (const void *pointer, void *data,
struct t_hashtable *info)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = info;
- return (struct t_hashtable *)weechat_perl_exec (script_callback->script,
- WEECHAT_SCRIPT_EXEC_HASHTABLE,
- script_callback->function,
- "sh", func_argv);
+ return (struct t_hashtable *)weechat_perl_exec (
+ script,
+ WEECHAT_SCRIPT_EXEC_HASHTABLE,
+ ptr_function,
+ "sh", func_argv);
}
return NULL;
@@ -3105,9 +3186,7 @@ API_FUNC(unhook)
if (items < 1)
API_WRONG_ARGS(API_RETURN_ERROR);
- plugin_script_api_unhook (weechat_perl_plugin,
- perl_current_script,
- API_STR2PTR(SvPV_nolen (ST (0)))); /* hook */
+ weechat_unhook (API_STR2PTR(SvPV_nolen (ST (0)))); /* hook */
API_RETURN_OK;
}
@@ -3122,31 +3201,34 @@ API_FUNC(unhook_all)
API_INIT_FUNC(1, "unhook_all", API_RETURN_ERROR);
- plugin_script_api_unhook_all (weechat_perl_plugin, perl_current_script);
+ weechat_unhook_all (perl_current_script->name);
API_RETURN_OK;
}
int
-weechat_perl_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
+weechat_perl_api_buffer_input_data_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
const char *input_data)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
func_argv[2] = (input_data) ? (char *)input_data : empty_arg;
- rc = (int *) weechat_perl_exec (script_callback->script,
+ rc = (int *) weechat_perl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@@ -3165,23 +3247,26 @@ weechat_perl_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
}
int
-weechat_perl_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
+weechat_perl_api_buffer_close_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
- rc = (int *) weechat_perl_exec (script_callback->script,
+ rc = (int *) weechat_perl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@@ -3298,9 +3383,7 @@ API_FUNC(buffer_close)
if (items < 1)
API_WRONG_ARGS(API_RETURN_ERROR);
- plugin_script_api_buffer_close (weechat_perl_plugin,
- perl_current_script,
- API_STR2PTR(SvPV_nolen (ST (0)))); /* buffer */
+ weechat_buffer_close (API_STR2PTR(SvPV_nolen (ST (0)))); /* buffer */
API_RETURN_OK;
}
@@ -3860,31 +3943,34 @@ API_FUNC(bar_item_search)
}
char *
-weechat_perl_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
+weechat_perl_api_bar_item_build_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
struct t_gui_window *window,
struct t_gui_buffer *buffer,
struct t_hashtable *extra_info)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[5];
char empty_arg[1] = { '\0' }, *ret;
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- if (strncmp (script_callback->function, "(extra)", 7) == 0)
+ if (strncmp (ptr_function, "(extra)", 7) == 0)
{
/* new callback: data, item, window, buffer, extra_info */
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(item);
func_argv[2] = API_PTR2STR(window);
func_argv[3] = API_PTR2STR(buffer);
func_argv[4] = extra_info;
- ret = (char *)weechat_perl_exec (script_callback->script,
+ ret = (char *)weechat_perl_exec (script,
WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function + 7,
+ ptr_function + 7,
"ssssh", func_argv);
if (func_argv[1])
@@ -3897,13 +3983,13 @@ weechat_perl_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
else
{
/* old callback: data, item, window */
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(item);
func_argv[2] = API_PTR2STR(window);
- ret = (char *)weechat_perl_exec (script_callback->script,
+ ret = (char *)weechat_perl_exec (script,
WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (func_argv[1])
@@ -3962,9 +4048,7 @@ API_FUNC(bar_item_remove)
if (items < 1)
API_WRONG_ARGS(API_RETURN_ERROR);
- plugin_script_api_bar_item_remove (weechat_perl_plugin,
- perl_current_script,
- API_STR2PTR(SvPV_nolen (ST (0)))); /* item */
+ weechat_bar_item_remove (API_STR2PTR(SvPV_nolen (ST (0)))); /* item */
API_RETURN_OK;
}
@@ -4823,68 +4907,33 @@ API_FUNC(hdata_get_string)
API_RETURN_STRING(result);
}
-API_FUNC(upgrade_new)
-{
- char *result, *filename;
- dXSARGS;
-
- API_INIT_FUNC(1, "upgrade_new", API_RETURN_EMPTY);
- if (items < 2)
- API_WRONG_ARGS(API_RETURN_EMPTY);
-
- filename = SvPV_nolen (ST (0));
-
- result = API_PTR2STR(weechat_upgrade_new (filename,
- SvIV (ST (1)))); /* write */
-
- API_RETURN_STRING_FREE(result);
-}
-
-API_FUNC(upgrade_write_object)
-{
- char *upgrade_file, *infolist;
- int rc;
- dXSARGS;
-
- API_INIT_FUNC(1, "upgrade_write_object", API_RETURN_INT(0));
- if (items < 3)
- API_WRONG_ARGS(API_RETURN_INT(0));
-
- upgrade_file = SvPV_nolen (ST (0));
- infolist = SvPV_nolen (ST (2));
-
- rc = weechat_upgrade_write_object (API_STR2PTR(upgrade_file),
- SvIV (ST (1)), /* object_id */
- API_STR2PTR(infolist));
-
- API_RETURN_INT(rc);
-}
-
int
-weechat_perl_api_upgrade_read_cb (void *data,
+weechat_perl_api_upgrade_read_cb (const void *pointer, void *data,
struct t_upgrade_file *upgrade_file,
int object_id,
struct t_infolist *infolist)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' }, str_object_id[32];
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (str_object_id, sizeof (str_object_id), "%d", object_id);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(upgrade_file);
func_argv[2] = str_object_id;
func_argv[3] = API_PTR2STR(infolist);
- rc = (int *) weechat_perl_exec (script_callback->script,
+ rc = (int *) weechat_perl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssss", func_argv);
if (!rc)
@@ -4905,26 +4954,64 @@ weechat_perl_api_upgrade_read_cb (void *data,
return WEECHAT_RC_ERROR;
}
+API_FUNC(upgrade_new)
+{
+ char *result, *filename, *function, *data;
+ dXSARGS;
+
+ API_INIT_FUNC(1, "upgrade_new", API_RETURN_EMPTY);
+ if (items < 3)
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ filename = SvPV_nolen (ST (0));
+ function = SvPV_nolen (ST (1));
+ data = SvPV_nolen (ST (2));
+
+ result = API_PTR2STR(
+ plugin_script_api_upgrade_new (
+ weechat_perl_plugin,
+ perl_current_script,
+ filename,
+ &weechat_perl_api_upgrade_read_cb,
+ function,
+ data));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+API_FUNC(upgrade_write_object)
+{
+ char *upgrade_file, *infolist;
+ int rc;
+ dXSARGS;
+
+ API_INIT_FUNC(1, "upgrade_write_object", API_RETURN_INT(0));
+ if (items < 3)
+ API_WRONG_ARGS(API_RETURN_INT(0));
+
+ upgrade_file = SvPV_nolen (ST (0));
+ infolist = SvPV_nolen (ST (2));
+
+ rc = weechat_upgrade_write_object (API_STR2PTR(upgrade_file),
+ SvIV (ST (1)), /* object_id */
+ API_STR2PTR(infolist));
+
+ API_RETURN_INT(rc);
+}
+
API_FUNC(upgrade_read)
{
- char *upgrade_file, *function, *data;
+ char *upgrade_file;
int rc;
dXSARGS;
API_INIT_FUNC(1, "upgrade_read", API_RETURN_INT(0));
- if (items < 3)
+ if (items < 1)
API_WRONG_ARGS(API_RETURN_INT(0));
upgrade_file = SvPV_nolen (ST (0));
- function = SvPV_nolen (ST (1));
- data = SvPV_nolen (ST (2));
- rc = plugin_script_api_upgrade_read (weechat_perl_plugin,
- perl_current_script,
- API_STR2PTR(upgrade_file),
- &weechat_perl_api_upgrade_read_cb,
- function,
- data);
+ rc = weechat_upgrade_read (API_STR2PTR(upgrade_file));
API_RETURN_INT(rc);
}
diff --git a/src/plugins/perl/weechat-perl-api.h b/src/plugins/perl/weechat-perl-api.h
index 2a3c31c00..9d8a72c79 100644
--- a/src/plugins/perl/weechat-perl-api.h
+++ b/src/plugins/perl/weechat-perl-api.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -20,10 +20,12 @@
#ifndef WEECHAT_PERL_API_H
#define WEECHAT_PERL_API_H 1
-extern int weechat_perl_api_buffer_input_data_cb (void *data,
+extern int weechat_perl_api_buffer_input_data_cb (const void *pointer,
+ void *data,
struct t_gui_buffer *buffer,
const char *input_data);
-extern int weechat_perl_api_buffer_close_cb (void *data,
+extern int weechat_perl_api_buffer_close_cb (const void *pointer,
+ void *data,
struct t_gui_buffer *buffer);
extern void weechat_perl_api_init (pTHX);
diff --git a/src/plugins/perl/weechat-perl.c b/src/plugins/perl/weechat-perl.c
index eed230b52..2692df598 100644
--- a/src/plugins/perl/weechat-perl.c
+++ b/src/plugins/perl/weechat-perl.c
@@ -1,7 +1,7 @@
/*
* weechat-perl.c - perl plugin for WeeChat
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2005-2008 Emmanuel Bouthenot <kolter@openics.org>
*
* This file is part of WeeChat, the extensible chat client.
@@ -132,8 +132,7 @@ weechat_perl_hashtable_to_hash (struct t_hashtable *hashtable)
if (!hash)
return NULL;
- weechat_hashtable_map_string (hashtable,
- &weechat_perl_hashtable_map_cb,
+ weechat_hashtable_map_string (hashtable, &weechat_perl_hashtable_map_cb,
hash);
return hash;
@@ -638,12 +637,14 @@ weechat_perl_reload_name (const char *name)
*/
int
-weechat_perl_command_cb (void *data, struct t_gui_buffer *buffer,
+weechat_perl_command_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
char *ptr_name, *path_script;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
@@ -739,11 +740,13 @@ weechat_perl_command_cb (void *data, struct t_gui_buffer *buffer,
*/
int
-weechat_perl_completion_cb (void *data, const char *completion_item,
+weechat_perl_completion_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -758,9 +761,11 @@ weechat_perl_completion_cb (void *data, const char *completion_item,
*/
struct t_hdata *
-weechat_perl_hdata_cb (void *data, const char *hdata_name)
+weechat_perl_hdata_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
return plugin_script_hdata_script (weechat_plugin,
@@ -773,10 +778,12 @@ weechat_perl_hdata_cb (void *data, const char *hdata_name)
*/
struct t_infolist *
-weechat_perl_infolist_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+weechat_perl_infolist_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (!infolist_name || !infolist_name[0])
@@ -785,7 +792,7 @@ weechat_perl_infolist_cb (void *data, const char *infolist_name,
if (weechat_strcasecmp (infolist_name, "perl_script") == 0)
{
return plugin_script_infolist_list_scripts (weechat_perl_plugin,
- perl_scripts, pointer,
+ perl_scripts, obj_pointer,
arguments);
}
@@ -797,10 +804,12 @@ weechat_perl_infolist_cb (void *data, const char *infolist_name,
*/
int
-weechat_perl_signal_debug_dump_cb (void *data, const char *signal,
+weechat_perl_signal_debug_dump_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -819,10 +828,12 @@ weechat_perl_signal_debug_dump_cb (void *data, const char *signal,
*/
int
-weechat_perl_signal_debug_libs_cb (void *data, const char *signal,
+weechat_perl_signal_debug_libs_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -838,37 +849,20 @@ weechat_perl_signal_debug_libs_cb (void *data, const char *signal,
}
/*
- * Callback called when a buffer is closed.
- */
-
-int
-weechat_perl_signal_buffer_closed_cb (void *data, const char *signal,
- const char *type_data, void *signal_data)
-{
- /* make C compiler happy */
- (void) data;
- (void) signal;
- (void) type_data;
-
- if (signal_data)
- plugin_script_remove_buffer_callbacks (perl_scripts, signal_data);
-
- return WEECHAT_RC_OK;
-}
-
-/*
* Timer for executing actions.
*/
int
-weechat_perl_timer_action_cb (void *data, int remaining_calls)
+weechat_perl_timer_action_cb (const void *pointer, void *data,
+ int remaining_calls)
{
/* make C compiler happy */
+ (void) data;
(void) remaining_calls;
- if (data)
+ if (pointer)
{
- if (data == &perl_action_install_list)
+ if (pointer == &perl_action_install_list)
{
plugin_script_action_install (weechat_perl_plugin,
perl_scripts,
@@ -877,7 +871,7 @@ weechat_perl_timer_action_cb (void *data, int remaining_calls)
&perl_quiet,
&perl_action_install_list);
}
- else if (data == &perl_action_remove_list)
+ else if (pointer == &perl_action_remove_list)
{
plugin_script_action_remove (weechat_perl_plugin,
perl_scripts,
@@ -885,7 +879,7 @@ weechat_perl_timer_action_cb (void *data, int remaining_calls)
&perl_quiet,
&perl_action_remove_list);
}
- else if (data == &perl_action_autoload_list)
+ else if (pointer == &perl_action_autoload_list)
{
plugin_script_action_autoload (weechat_perl_plugin,
&perl_quiet,
@@ -901,11 +895,13 @@ weechat_perl_timer_action_cb (void *data, int remaining_calls)
*/
int
-weechat_perl_signal_script_action_cb (void *data, const char *signal,
+weechat_perl_signal_script_action_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data,
void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
@@ -916,7 +912,7 @@ weechat_perl_signal_script_action_cb (void *data, const char *signal,
(const char *)signal_data);
weechat_hook_timer (1, 0, 1,
&weechat_perl_timer_action_cb,
- &perl_action_install_list);
+ &perl_action_install_list, NULL);
}
else if (strcmp (signal, "perl_script_remove") == 0)
{
@@ -924,7 +920,7 @@ weechat_perl_signal_script_action_cb (void *data, const char *signal,
(const char *)signal_data);
weechat_hook_timer (1, 0, 1,
&weechat_perl_timer_action_cb,
- &perl_action_remove_list);
+ &perl_action_remove_list, NULL);
}
else if (strcmp (signal, "perl_script_autoload") == 0)
{
@@ -932,7 +928,7 @@ weechat_perl_signal_script_action_cb (void *data, const char *signal,
(const char *)signal_data);
weechat_hook_timer (1, 0, 1,
&weechat_perl_timer_action_cb,
- &perl_action_autoload_list);
+ &perl_action_autoload_list, NULL);
}
}
@@ -944,11 +940,13 @@ weechat_perl_signal_script_action_cb (void *data, const char *signal,
*/
int
-weechat_perl_signal_quit_upgrade_cb (void *data, const char *signal,
+weechat_perl_signal_quit_upgrade_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data,
void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -1002,7 +1000,6 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
init.callback_infolist = &weechat_perl_infolist_cb;
init.callback_signal_debug_dump = &weechat_perl_signal_debug_dump_cb;
init.callback_signal_debug_libs = &weechat_perl_signal_debug_libs_cb;
- init.callback_signal_buffer_closed = &weechat_perl_signal_buffer_closed_cb;
init.callback_signal_script_action = &weechat_perl_signal_script_action_cb;
init.callback_load_file = &weechat_perl_load_cb;
@@ -1013,8 +1010,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
plugin_script_display_short_list (weechat_perl_plugin,
perl_scripts);
- weechat_hook_signal ("quit", &weechat_perl_signal_quit_upgrade_cb, NULL);
- weechat_hook_signal ("upgrade", &weechat_perl_signal_quit_upgrade_cb, NULL);
+ weechat_hook_signal ("quit",
+ &weechat_perl_signal_quit_upgrade_cb, NULL, NULL);
+ weechat_hook_signal ("upgrade",
+ &weechat_perl_signal_quit_upgrade_cb, NULL, NULL);
/* init OK */
return WEECHAT_RC_OK;
diff --git a/src/plugins/perl/weechat-perl.h b/src/plugins/perl/weechat-perl.h
index 1d31fa794..107806ac0 100644
--- a/src/plugins/perl/weechat-perl.h
+++ b/src/plugins/perl/weechat-perl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c
index 157a94d04..cc4e4b0a9 100644
--- a/src/plugins/plugin-api.c
+++ b/src/plugins/plugin-api.c
@@ -1,7 +1,7 @@
/*
* plugin-api.c - extra functions for plugin API
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -59,6 +59,7 @@
#include "../gui/gui-key.h"
#include "../gui/gui-layout.h"
#include "../gui/gui-line.h"
+#include "../gui/gui-nick.h"
#include "../gui/gui-nicklist.h"
#include "../gui/gui-window.h"
#include "plugin.h"
@@ -285,12 +286,13 @@ plugin_api_command (struct t_weechat_plugin *plugin,
*/
char *
-plugin_api_modifier_color_decode_ansi_cb (void *data,
+plugin_api_modifier_color_decode_ansi_cb (const void *pointer, void *data,
const char *modifier,
const char *modifier_data,
const char *string)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) modifier;
@@ -305,10 +307,12 @@ plugin_api_modifier_color_decode_ansi_cb (void *data,
*/
const char *
-plugin_api_info_version_cb (void *data, const char *info_name,
+plugin_api_info_version_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
(void) arguments;
@@ -321,12 +325,14 @@ plugin_api_info_version_cb (void *data, const char *info_name,
*/
const char *
-plugin_api_info_version_number_cb (void *data, const char *info_name,
+plugin_api_info_version_number_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
static char version_number[32] = { '\0' };
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
(void) arguments;
@@ -344,10 +350,12 @@ plugin_api_info_version_number_cb (void *data, const char *info_name,
*/
const char *
-plugin_api_info_version_git_cb (void *data, const char *info_name,
+plugin_api_info_version_git_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
(void) arguments;
@@ -360,10 +368,12 @@ plugin_api_info_version_git_cb (void *data, const char *info_name,
*/
const char *
-plugin_api_info_date_cb (void *data, const char *info_name,
+plugin_api_info_date_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
(void) arguments;
@@ -376,10 +386,12 @@ plugin_api_info_date_cb (void *data, const char *info_name,
*/
const char *
-plugin_api_info_dir_separator_cb (void *data, const char *info_name,
+plugin_api_info_dir_separator_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
(void) arguments;
@@ -392,12 +404,14 @@ plugin_api_info_dir_separator_cb (void *data, const char *info_name,
*/
const char *
-plugin_api_info_weechat_dir_cb (void *data, const char *info_name,
+plugin_api_info_weechat_dir_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
static char weechat_dir_absolute_path[PATH_MAX] = { '\0' };
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
(void) arguments;
@@ -416,10 +430,12 @@ plugin_api_info_weechat_dir_cb (void *data, const char *info_name,
*/
const char *
-plugin_api_info_weechat_libdir_cb (void *data, const char *info_name,
+plugin_api_info_weechat_libdir_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
(void) arguments;
@@ -432,10 +448,12 @@ plugin_api_info_weechat_libdir_cb (void *data, const char *info_name,
*/
const char *
-plugin_api_info_weechat_sharedir_cb (void *data, const char *info_name,
+plugin_api_info_weechat_sharedir_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
(void) arguments;
@@ -448,10 +466,12 @@ plugin_api_info_weechat_sharedir_cb (void *data, const char *info_name,
*/
const char *
-plugin_api_info_weechat_localedir_cb (void *data, const char *info_name,
+plugin_api_info_weechat_localedir_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
(void) arguments;
@@ -464,10 +484,12 @@ plugin_api_info_weechat_localedir_cb (void *data, const char *info_name,
*/
const char *
-plugin_api_info_weechat_site_cb (void *data, const char *info_name,
+plugin_api_info_weechat_site_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
(void) arguments;
@@ -480,10 +502,12 @@ plugin_api_info_weechat_site_cb (void *data, const char *info_name,
*/
const char *
-plugin_api_info_weechat_site_download_cb (void *data, const char *info_name,
+plugin_api_info_weechat_site_download_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
(void) arguments;
@@ -496,12 +520,14 @@ plugin_api_info_weechat_site_download_cb (void *data, const char *info_name,
*/
const char *
-plugin_api_info_weechat_upgrading_cb (void *data, const char *info_name,
+plugin_api_info_weechat_upgrading_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
static char value[32];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
(void) arguments;
@@ -515,10 +541,12 @@ plugin_api_info_weechat_upgrading_cb (void *data, const char *info_name,
*/
const char *
-plugin_api_info_charset_terminal_cb (void *data, const char *info_name,
+plugin_api_info_charset_terminal_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
(void) arguments;
@@ -531,10 +559,12 @@ plugin_api_info_charset_terminal_cb (void *data, const char *info_name,
*/
const char *
-plugin_api_info_charset_internal_cb (void *data, const char *info_name,
+plugin_api_info_charset_internal_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
(void) arguments;
@@ -547,10 +577,12 @@ plugin_api_info_charset_internal_cb (void *data, const char *info_name,
*/
const char *
-plugin_api_info_locale_cb (void *data, const char *info_name,
+plugin_api_info_locale_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
(void) arguments;
@@ -563,13 +595,15 @@ plugin_api_info_locale_cb (void *data, const char *info_name,
*/
const char *
-plugin_api_info_inactivity_cb (void *data, const char *info_name,
+plugin_api_info_inactivity_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
time_t inactivity;
static char value[32];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
(void) arguments;
@@ -587,12 +621,14 @@ plugin_api_info_inactivity_cb (void *data, const char *info_name,
*/
const char *
-plugin_api_info_filters_enabled_cb (void *data, const char *info_name,
+plugin_api_info_filters_enabled_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
static char value[32];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
(void) arguments;
@@ -606,12 +642,14 @@ plugin_api_info_filters_enabled_cb (void *data, const char *info_name,
*/
const char *
-plugin_api_info_cursor_mode_cb (void *data, const char *info_name,
+plugin_api_info_cursor_mode_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
static char value[32];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
(void) arguments;
@@ -625,12 +663,14 @@ plugin_api_info_cursor_mode_cb (void *data, const char *info_name,
*/
const char *
-plugin_api_info_term_width_cb (void *data, const char *info_name,
+plugin_api_info_term_width_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
static char value[32];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
(void) arguments;
@@ -644,12 +684,14 @@ plugin_api_info_term_width_cb (void *data, const char *info_name,
*/
const char *
-plugin_api_info_term_height_cb (void *data, const char *info_name,
+plugin_api_info_term_height_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
static char value[32];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
(void) arguments;
@@ -663,10 +705,12 @@ plugin_api_info_term_height_cb (void *data, const char *info_name,
*/
const char *
-plugin_api_info_color_ansi_regex_cb (void *data, const char *info_name,
+plugin_api_info_color_ansi_regex_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
(void) arguments;
@@ -679,12 +723,14 @@ plugin_api_info_color_ansi_regex_cb (void *data, const char *info_name,
*/
const char *
-plugin_api_info_color_term2rgb_cb (void *data, const char *info_name,
+plugin_api_info_color_term2rgb_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
static char value[32];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
@@ -702,7 +748,8 @@ plugin_api_info_color_term2rgb_cb (void *data, const char *info_name,
*/
const char *
-plugin_api_info_color_rgb2term_cb (void *data, const char *info_name,
+plugin_api_info_color_rgb2term_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
static char value[32];
@@ -710,6 +757,7 @@ plugin_api_info_color_rgb2term_cb (void *data, const char *info_name,
char *pos, *color;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
@@ -739,34 +787,70 @@ plugin_api_info_color_rgb2term_cb (void *data, const char *info_name,
}
/*
+ * Returns nick color code for a nickname.
+ */
+
+const char *
+plugin_api_info_nick_color_cb (const void *pointer, void *data,
+ const char *info_name,
+ const char *arguments)
+{
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+ (void) info_name;
+
+ return gui_nick_find_color (arguments);
+}
+
+/*
+ * Returns nick color name for a nickname.
+ */
+
+const char *
+plugin_api_info_nick_color_name_cb (const void *pointer, void *data,
+ const char *info_name,
+ const char *arguments)
+{
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+ (void) info_name;
+
+ return gui_nick_find_color_name (arguments);
+}
+
+/*
* Returns WeeChat infolist "bar".
*
* Note: result must be freed after use with function weechat_infolist_free().
*/
struct t_infolist *
-plugin_api_infolist_bar_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+plugin_api_infolist_bar_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
struct t_infolist *ptr_infolist;
struct t_gui_bar *ptr_bar;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) infolist_name;
/* invalid bar pointer ? */
- if (pointer && (!gui_bar_valid (pointer)))
+ if (obj_pointer && (!gui_bar_valid (obj_pointer)))
return NULL;
ptr_infolist = infolist_new (NULL);
if (!ptr_infolist)
return NULL;
- if (pointer)
+ if (obj_pointer)
{
/* build list with only one bar */
- if (!gui_bar_add_to_infolist (ptr_infolist, pointer))
+ if (!gui_bar_add_to_infolist (ptr_infolist, obj_pointer))
{
infolist_free (ptr_infolist);
return NULL;
@@ -801,28 +885,30 @@ plugin_api_infolist_bar_cb (void *data, const char *infolist_name,
*/
struct t_infolist *
-plugin_api_infolist_bar_item_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+plugin_api_infolist_bar_item_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
struct t_infolist *ptr_infolist;
struct t_gui_bar_item *ptr_bar_item;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) infolist_name;
/* invalid bar item pointer ? */
- if (pointer && (!gui_bar_item_valid (pointer)))
+ if (obj_pointer && (!gui_bar_item_valid (obj_pointer)))
return NULL;
ptr_infolist = infolist_new (NULL);
if (!ptr_infolist)
return NULL;
- if (pointer)
+ if (obj_pointer)
{
/* build list with only one bar item */
- if (!gui_bar_item_add_to_infolist (ptr_infolist, pointer))
+ if (!gui_bar_item_add_to_infolist (ptr_infolist, obj_pointer))
{
infolist_free (ptr_infolist);
return NULL;
@@ -858,8 +944,9 @@ plugin_api_infolist_bar_item_cb (void *data, const char *infolist_name,
*/
struct t_infolist *
-plugin_api_infolist_bar_window_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+plugin_api_infolist_bar_window_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
struct t_infolist *ptr_infolist;
struct t_gui_bar *ptr_bar;
@@ -867,22 +954,23 @@ plugin_api_infolist_bar_window_cb (void *data, const char *infolist_name,
struct t_gui_window *ptr_window;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) infolist_name;
(void) arguments;
/* invalid bar window pointer ? */
- if (pointer && (!gui_bar_window_valid (pointer)))
+ if (obj_pointer && (!gui_bar_window_valid (obj_pointer)))
return NULL;
ptr_infolist = infolist_new (NULL);
if (!ptr_infolist)
return NULL;
- if (pointer)
+ if (obj_pointer)
{
/* build list with only one bar window */
- if (!gui_bar_window_add_to_infolist (ptr_infolist, pointer))
+ if (!gui_bar_window_add_to_infolist (ptr_infolist, obj_pointer))
{
infolist_free (ptr_infolist);
return NULL;
@@ -930,28 +1018,30 @@ plugin_api_infolist_bar_window_cb (void *data, const char *infolist_name,
*/
struct t_infolist *
-plugin_api_infolist_buffer_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+plugin_api_infolist_buffer_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
struct t_infolist *ptr_infolist;
struct t_gui_buffer *ptr_buffer;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) infolist_name;
/* invalid buffer pointer ? */
- if (pointer && (!gui_buffer_valid (pointer)))
+ if (obj_pointer && (!gui_buffer_valid (obj_pointer)))
return NULL;
ptr_infolist = infolist_new (NULL);
if (!ptr_infolist)
return NULL;
- if (pointer)
+ if (obj_pointer)
{
/* build list with only one buffer */
- if (!gui_buffer_add_to_infolist (ptr_infolist, pointer))
+ if (!gui_buffer_add_to_infolist (ptr_infolist, obj_pointer))
{
infolist_free (ptr_infolist);
return NULL;
@@ -987,23 +1077,25 @@ plugin_api_infolist_buffer_cb (void *data, const char *infolist_name,
*/
struct t_infolist *
-plugin_api_infolist_buffer_lines_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+plugin_api_infolist_buffer_lines_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
struct t_infolist *ptr_infolist;
struct t_gui_line *ptr_line;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) infolist_name;
(void) arguments;
- if (!pointer)
- pointer = gui_buffers;
+ if (!obj_pointer)
+ obj_pointer = gui_buffers;
else
{
/* invalid buffer pointer ? */
- if (!gui_buffer_valid (pointer))
+ if (!gui_buffer_valid (obj_pointer))
return NULL;
}
@@ -1011,11 +1103,11 @@ plugin_api_infolist_buffer_lines_cb (void *data, const char *infolist_name,
if (!ptr_infolist)
return NULL;
- for (ptr_line = ((struct t_gui_buffer *)pointer)->own_lines->first_line;
+ for (ptr_line = ((struct t_gui_buffer *)obj_pointer)->own_lines->first_line;
ptr_line; ptr_line = ptr_line->next_line)
{
if (!gui_line_add_to_infolist (ptr_infolist,
- ((struct t_gui_buffer *)pointer)->own_lines,
+ ((struct t_gui_buffer *)obj_pointer)->own_lines,
ptr_line))
{
infolist_free (ptr_infolist);
@@ -1032,16 +1124,18 @@ plugin_api_infolist_buffer_lines_cb (void *data, const char *infolist_name,
*/
struct t_infolist *
-plugin_api_infolist_filter_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+plugin_api_infolist_filter_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
struct t_infolist *ptr_infolist;
struct t_gui_filter *ptr_filter;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) infolist_name;
- (void) pointer;
+ (void) obj_pointer;
ptr_infolist = infolist_new (NULL);
if (!ptr_infolist)
@@ -1070,27 +1164,29 @@ plugin_api_infolist_filter_cb (void *data, const char *infolist_name,
*/
struct t_infolist *
-plugin_api_infolist_history_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+plugin_api_infolist_history_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
struct t_infolist *ptr_infolist;
struct t_gui_history *ptr_history;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) infolist_name;
(void) arguments;
/* invalid buffer pointer ? */
- if (pointer && (!gui_buffer_valid (pointer)))
+ if (obj_pointer && (!gui_buffer_valid (obj_pointer)))
return NULL;
ptr_infolist = infolist_new (NULL);
if (!ptr_infolist)
return NULL;
- for (ptr_history = (pointer) ?
- ((struct t_gui_buffer *)pointer)->history : gui_history;
+ for (ptr_history = (obj_pointer) ?
+ ((struct t_gui_buffer *)obj_pointer)->history : gui_history;
ptr_history; ptr_history = ptr_history->next_history)
{
if (!gui_history_add_to_infolist (ptr_infolist, ptr_history))
@@ -1109,24 +1205,26 @@ plugin_api_infolist_history_cb (void *data, const char *infolist_name,
*/
struct t_infolist *
-plugin_api_infolist_hook_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+plugin_api_infolist_hook_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
struct t_infolist *ptr_infolist;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) infolist_name;
/* invalid hook pointer ? */
- if (pointer && !hook_valid (pointer))
+ if (obj_pointer && !hook_valid (obj_pointer))
return NULL;
ptr_infolist = infolist_new (NULL);
if (!ptr_infolist)
return NULL;
- if (!hook_add_to_infolist (ptr_infolist, pointer, arguments))
+ if (!hook_add_to_infolist (ptr_infolist, obj_pointer, arguments))
{
infolist_free (ptr_infolist);
return NULL;
@@ -1141,16 +1239,18 @@ plugin_api_infolist_hook_cb (void *data, const char *infolist_name,
*/
struct t_infolist *
-plugin_api_infolist_hotlist_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+plugin_api_infolist_hotlist_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
struct t_infolist *ptr_infolist;
struct t_gui_hotlist *ptr_hotlist;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) infolist_name;
- (void) pointer;
+ (void) obj_pointer;
(void) arguments;
ptr_infolist = infolist_new (NULL);
@@ -1176,17 +1276,19 @@ plugin_api_infolist_hotlist_cb (void *data, const char *infolist_name,
*/
struct t_infolist *
-plugin_api_infolist_key_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+plugin_api_infolist_key_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
struct t_infolist *ptr_infolist;
struct t_gui_key *ptr_key;
int context;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) infolist_name;
- (void) pointer;
+ (void) obj_pointer;
ptr_infolist = infolist_new (NULL);
if (!ptr_infolist)
@@ -1218,16 +1320,18 @@ plugin_api_infolist_key_cb (void *data, const char *infolist_name,
*/
struct t_infolist *
-plugin_api_infolist_layout_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+plugin_api_infolist_layout_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
struct t_infolist *ptr_infolist;
struct t_gui_layout *ptr_layout;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) infolist_name;
- (void) pointer;
+ (void) obj_pointer;
(void) arguments;
ptr_infolist = infolist_new (NULL);
@@ -1253,24 +1357,26 @@ plugin_api_infolist_layout_cb (void *data, const char *infolist_name,
*/
struct t_infolist *
-plugin_api_infolist_nicklist_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+plugin_api_infolist_nicklist_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
struct t_infolist *ptr_infolist;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) infolist_name;
/* invalid buffer pointer ? */
- if (!pointer || (!gui_buffer_valid (pointer)))
+ if (!obj_pointer || (!gui_buffer_valid (obj_pointer)))
return NULL;
ptr_infolist = infolist_new (NULL);
if (!ptr_infolist)
return NULL;
- if (!gui_nicklist_add_to_infolist (ptr_infolist, pointer, arguments))
+ if (!gui_nicklist_add_to_infolist (ptr_infolist, obj_pointer, arguments))
{
infolist_free (ptr_infolist);
return NULL;
@@ -1285,15 +1391,17 @@ plugin_api_infolist_nicklist_cb (void *data, const char *infolist_name,
*/
struct t_infolist *
-plugin_api_infolist_option_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+plugin_api_infolist_option_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
struct t_infolist *ptr_infolist;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) infolist_name;
- (void) pointer;
+ (void) obj_pointer;
ptr_infolist = infolist_new (NULL);
if (!ptr_infolist)
@@ -1314,28 +1422,30 @@ plugin_api_infolist_option_cb (void *data, const char *infolist_name,
*/
struct t_infolist *
-plugin_api_infolist_plugin_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+plugin_api_infolist_plugin_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
struct t_infolist *ptr_infolist;
struct t_weechat_plugin *ptr_plugin;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) infolist_name;
/* invalid plugin pointer ? */
- if (pointer && (!plugin_valid (pointer)))
+ if (obj_pointer && (!plugin_valid (obj_pointer)))
return NULL;
ptr_infolist = infolist_new (NULL);
if (!ptr_infolist)
return NULL;
- if (pointer)
+ if (obj_pointer)
{
/* build list with only one plugin */
- if (!plugin_add_to_infolist (ptr_infolist, pointer))
+ if (!plugin_add_to_infolist (ptr_infolist, obj_pointer))
{
infolist_free (ptr_infolist);
return NULL;
@@ -1371,28 +1481,30 @@ plugin_api_infolist_plugin_cb (void *data, const char *infolist_name,
*/
struct t_infolist *
-plugin_api_infolist_proxy_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+plugin_api_infolist_proxy_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
struct t_infolist *ptr_infolist;
struct t_proxy *ptr_proxy;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) infolist_name;
/* invalid proxy pointer ? */
- if (pointer && (!proxy_valid (pointer)))
+ if (obj_pointer && (!proxy_valid (obj_pointer)))
return NULL;
ptr_infolist = infolist_new (NULL);
if (!ptr_infolist)
return NULL;
- if (pointer)
+ if (obj_pointer)
{
/* build list with only one proxy */
- if (!proxy_add_to_infolist (ptr_infolist, pointer))
+ if (!proxy_add_to_infolist (ptr_infolist, obj_pointer))
{
infolist_free (ptr_infolist);
return NULL;
@@ -1428,16 +1540,18 @@ plugin_api_infolist_proxy_cb (void *data, const char *infolist_name,
*/
struct t_infolist *
-plugin_api_infolist_url_options_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+plugin_api_infolist_url_options_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
struct t_infolist *ptr_infolist;
int i;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) infolist_name;
- (void) pointer;
+ (void) obj_pointer;
(void) arguments;
ptr_infolist = infolist_new (NULL);
@@ -1462,8 +1576,9 @@ plugin_api_infolist_url_options_cb (void *data, const char *infolist_name,
*/
struct t_infolist *
-plugin_api_infolist_window_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+plugin_api_infolist_window_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
struct t_infolist *ptr_infolist;
struct t_gui_window *ptr_window;
@@ -1471,21 +1586,22 @@ plugin_api_infolist_window_cb (void *data, const char *infolist_name,
char *error;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) infolist_name;
/* invalid window pointer ? */
- if (pointer && (!gui_window_valid (pointer)))
+ if (obj_pointer && (!gui_window_valid (obj_pointer)))
return NULL;
ptr_infolist = infolist_new (NULL);
if (!ptr_infolist)
return NULL;
- if (pointer)
+ if (obj_pointer)
{
/* build list with only one window */
- if (!gui_window_add_to_infolist (ptr_infolist, pointer))
+ if (!gui_window_add_to_infolist (ptr_infolist, obj_pointer))
{
infolist_free (ptr_infolist);
return NULL;
@@ -1697,228 +1813,236 @@ plugin_api_init ()
{
/* WeeChat core modifiers */
hook_modifier (NULL, "color_decode_ansi",
- &plugin_api_modifier_color_decode_ansi_cb, NULL);
+ &plugin_api_modifier_color_decode_ansi_cb, NULL, NULL);
/* WeeChat core info hooks */
hook_info (NULL, "version",
N_("WeeChat version"),
- NULL, &plugin_api_info_version_cb, NULL);
+ NULL, &plugin_api_info_version_cb, NULL, NULL);
hook_info (NULL, "version_number",
N_("WeeChat version (as number)"),
- NULL, &plugin_api_info_version_number_cb, NULL);
+ NULL, &plugin_api_info_version_number_cb, NULL, NULL);
hook_info (NULL, "version_git",
N_("WeeChat git version (output of command \"git describe\" "
"for a development version only, empty for a stable "
"release)"),
- NULL, &plugin_api_info_version_git_cb, NULL);
+ NULL, &plugin_api_info_version_git_cb, NULL, NULL);
hook_info (NULL, "date",
N_("WeeChat compilation date"),
- NULL, &plugin_api_info_date_cb, NULL);
+ NULL, &plugin_api_info_date_cb, NULL, NULL);
hook_info (NULL, "dir_separator",
N_("directory separator"),
- NULL, &plugin_api_info_dir_separator_cb, NULL);
+ NULL, &plugin_api_info_dir_separator_cb, NULL, NULL);
hook_info (NULL, "weechat_dir",
N_("WeeChat directory"),
- NULL, &plugin_api_info_weechat_dir_cb, NULL);
+ NULL, &plugin_api_info_weechat_dir_cb, NULL, NULL);
hook_info (NULL, "weechat_libdir",
N_("WeeChat \"lib\" directory"),
- NULL, &plugin_api_info_weechat_libdir_cb, NULL);
+ NULL, &plugin_api_info_weechat_libdir_cb, NULL, NULL);
hook_info (NULL, "weechat_sharedir",
N_("WeeChat \"share\" directory"),
- NULL, &plugin_api_info_weechat_sharedir_cb, NULL);
+ NULL, &plugin_api_info_weechat_sharedir_cb, NULL, NULL);
hook_info (NULL, "weechat_localedir",
N_("WeeChat \"locale\" directory"),
- NULL, &plugin_api_info_weechat_localedir_cb, NULL);
+ NULL, &plugin_api_info_weechat_localedir_cb, NULL, NULL);
hook_info (NULL, "weechat_site",
N_("WeeChat site"),
- NULL, &plugin_api_info_weechat_site_cb, NULL);
+ NULL, &plugin_api_info_weechat_site_cb, NULL, NULL);
hook_info (NULL, "weechat_site_download",
N_("WeeChat site, download page"),
- NULL, &plugin_api_info_weechat_site_download_cb, NULL);
+ NULL, &plugin_api_info_weechat_site_download_cb, NULL, NULL);
hook_info (NULL, "weechat_upgrading",
N_("1 if WeeChat is upgrading (command `/upgrade`)"),
- NULL, &plugin_api_info_weechat_upgrading_cb, NULL);
+ NULL, &plugin_api_info_weechat_upgrading_cb, NULL, NULL);
hook_info (NULL, "charset_terminal",
N_("terminal charset"),
- NULL, &plugin_api_info_charset_terminal_cb, NULL);
+ NULL, &plugin_api_info_charset_terminal_cb, NULL, NULL);
hook_info (NULL, "charset_internal",
N_("WeeChat internal charset"),
- NULL, &plugin_api_info_charset_internal_cb, NULL);
+ NULL, &plugin_api_info_charset_internal_cb, NULL, NULL);
hook_info (NULL, "locale",
N_("locale used for translating messages"),
- NULL, &plugin_api_info_locale_cb, NULL);
+ NULL, &plugin_api_info_locale_cb, NULL, NULL);
hook_info (NULL, "inactivity",
N_("keyboard inactivity (seconds)"),
- NULL, &plugin_api_info_inactivity_cb, NULL);
+ NULL, &plugin_api_info_inactivity_cb, NULL, NULL);
hook_info (NULL, "filters_enabled",
N_("1 if filters are enabled"),
- NULL, &plugin_api_info_filters_enabled_cb, NULL);
+ NULL, &plugin_api_info_filters_enabled_cb, NULL, NULL);
hook_info (NULL, "cursor_mode",
N_("1 if cursor mode is enabled"),
- NULL, &plugin_api_info_cursor_mode_cb, NULL);
+ NULL, &plugin_api_info_cursor_mode_cb, NULL, NULL);
hook_info (NULL, "term_width",
N_("width of terminal"),
- NULL, &plugin_api_info_term_width_cb, NULL);
+ NULL, &plugin_api_info_term_width_cb, NULL, NULL);
hook_info (NULL, "term_height",
N_("height of terminal"),
- NULL, &plugin_api_info_term_height_cb, NULL);
+ NULL, &plugin_api_info_term_height_cb, NULL, NULL);
hook_info (NULL, "color_ansi_regex",
N_("POSIX extended regular expression to search ANSI escape "
"codes"),
- NULL, &plugin_api_info_color_ansi_regex_cb, NULL);
+ NULL, &plugin_api_info_color_ansi_regex_cb, NULL, NULL);
hook_info (NULL, "color_term2rgb",
N_("terminal color (0-255) converted to RGB color"),
N_("color (terminal color: 0-255)"),
- &plugin_api_info_color_term2rgb_cb, NULL);
+ &plugin_api_info_color_term2rgb_cb, NULL, NULL);
hook_info (NULL, "color_rgb2term",
N_("RGB color converted to terminal color (0-255)"),
N_("rgb,limit (limit is optional and is set to 256 by default)"),
- &plugin_api_info_color_rgb2term_cb, NULL);
+ &plugin_api_info_color_rgb2term_cb, NULL, NULL);
+ hook_info (NULL, "nick_color",
+ N_("get nick color code"),
+ N_("nickname"),
+ &plugin_api_info_nick_color_cb, NULL, NULL);
+ hook_info (NULL, "nick_color_name",
+ N_("get nick color name"),
+ N_("nickname"),
+ &plugin_api_info_nick_color_name_cb, NULL, NULL);
/* WeeChat core infolist hooks */
hook_infolist (NULL, "bar",
N_("list of bars"),
N_("bar pointer (optional)"),
N_("bar name (wildcard \"*\" is allowed) (optional)"),
- &plugin_api_infolist_bar_cb, NULL);
+ &plugin_api_infolist_bar_cb, NULL, NULL);
hook_infolist (NULL, "bar_item",
N_("list of bar items"),
N_("bar item pointer (optional)"),
N_("bar item name (wildcard \"*\" is allowed) (optional)"),
- &plugin_api_infolist_bar_item_cb, NULL);
+ &plugin_api_infolist_bar_item_cb, NULL, NULL);
hook_infolist (NULL, "bar_window",
N_("list of bar windows"),
N_("bar window pointer (optional)"),
NULL,
- &plugin_api_infolist_bar_window_cb, NULL);
+ &plugin_api_infolist_bar_window_cb, NULL, NULL);
hook_infolist (NULL, "buffer",
N_("list of buffers"),
N_("buffer pointer (optional)"),
N_("buffer name (wildcard \"*\" is allowed) (optional)"),
- &plugin_api_infolist_buffer_cb, NULL);
+ &plugin_api_infolist_buffer_cb, NULL, NULL);
hook_infolist (NULL, "buffer_lines",
N_("lines of a buffer"),
N_("buffer pointer"),
NULL,
- &plugin_api_infolist_buffer_lines_cb, NULL);
+ &plugin_api_infolist_buffer_lines_cb, NULL, NULL);
hook_infolist (NULL, "filter",
N_("list of filters"),
NULL,
N_("filter name (wildcard \"*\" is allowed) (optional)"),
- &plugin_api_infolist_filter_cb, NULL);
+ &plugin_api_infolist_filter_cb, NULL, NULL);
hook_infolist (NULL, "history",
N_("history of commands"),
N_("buffer pointer (if not set, return global history) (optional)"),
NULL,
- &plugin_api_infolist_history_cb, NULL);
+ &plugin_api_infolist_history_cb, NULL, NULL);
hook_infolist (NULL, "hook",
N_("list of hooks"),
N_("hook pointer (optional)"),
N_("type,arguments (type is command/timer/.., arguments to "
"get only some hooks (wildcard \"*\" is allowed), "
"both are optional)"),
- &plugin_api_infolist_hook_cb, NULL);
+ &plugin_api_infolist_hook_cb, NULL, NULL);
hook_infolist (NULL, "hotlist",
N_("list of buffers in hotlist"),
NULL,
NULL,
- &plugin_api_infolist_hotlist_cb, NULL);
+ &plugin_api_infolist_hotlist_cb, NULL, NULL);
hook_infolist (NULL, "key",
N_("list of key bindings"),
NULL,
N_("context (\"default\", \"search\", \"cursor\" or "
"\"mouse\") (optional)"),
- &plugin_api_infolist_key_cb, NULL);
+ &plugin_api_infolist_key_cb, NULL, NULL);
hook_infolist (NULL, "layout",
N_("list of layouts"),
NULL,
NULL,
- &plugin_api_infolist_layout_cb, NULL);
+ &plugin_api_infolist_layout_cb, NULL, NULL);
hook_infolist (NULL, "nicklist",
N_("nicks in nicklist for a buffer"),
N_("buffer pointer"),
N_("nick_xxx or group_xxx to get only nick/group xxx "
"(optional)"),
- &plugin_api_infolist_nicklist_cb, NULL);
+ &plugin_api_infolist_nicklist_cb, NULL, NULL);
hook_infolist (NULL, "option",
N_("list of options"),
NULL,
N_("option name (wildcard \"*\" is allowed) (optional)"),
- &plugin_api_infolist_option_cb, NULL);
+ &plugin_api_infolist_option_cb, NULL, NULL);
hook_infolist (NULL, "plugin",
N_("list of plugins"),
N_("plugin pointer (optional)"),
N_("plugin name (wildcard \"*\" is allowed) (optional)"),
- &plugin_api_infolist_plugin_cb, NULL);
+ &plugin_api_infolist_plugin_cb, NULL, NULL);
hook_infolist (NULL, "proxy",
N_("list of proxies"),
N_("proxy pointer (optional)"),
N_("proxy name (wildcard \"*\" is allowed) (optional)"),
- &plugin_api_infolist_proxy_cb, NULL);
+ &plugin_api_infolist_proxy_cb, NULL, NULL);
hook_infolist (NULL, "url_options",
N_("options for URL"),
NULL,
NULL,
- &plugin_api_infolist_url_options_cb, NULL);
+ &plugin_api_infolist_url_options_cb, NULL, NULL);
hook_infolist (NULL, "window",
N_("list of windows"),
N_("window pointer (optional)"),
N_("\"current\" for current window or a window number (optional)"),
- &plugin_api_infolist_window_cb, NULL);
+ &plugin_api_infolist_window_cb, NULL, NULL);
/* WeeChat core hdata */
hook_hdata (NULL, "bar", N_("bar"),
- &gui_bar_hdata_bar_cb, NULL);
+ &gui_bar_hdata_bar_cb, NULL, NULL);
hook_hdata (NULL, "bar_item", N_("bar item"),
- &gui_bar_item_hdata_bar_item_cb, NULL);
+ &gui_bar_item_hdata_bar_item_cb, NULL, NULL);
hook_hdata (NULL, "bar_window", N_("bar window"),
- &gui_bar_window_hdata_bar_window_cb, NULL);
+ &gui_bar_window_hdata_bar_window_cb, NULL, NULL);
hook_hdata (NULL, "buffer", N_("buffer"),
- &gui_buffer_hdata_buffer_cb, NULL);
+ &gui_buffer_hdata_buffer_cb, NULL, NULL);
hook_hdata (NULL, "buffer_visited", N_("visited buffer"),
- &gui_buffer_hdata_buffer_visited_cb, NULL);
+ &gui_buffer_hdata_buffer_visited_cb, NULL, NULL);
hook_hdata (NULL, "completion", N_("structure with completion"),
- &gui_completion_hdata_completion_cb, NULL);
+ &gui_completion_hdata_completion_cb, NULL, NULL);
hook_hdata (NULL, "config_file", N_("config file"),
- &config_file_hdata_config_file_cb, NULL);
+ &config_file_hdata_config_file_cb, NULL, NULL);
hook_hdata (NULL, "config_section", N_("config section"),
- &config_file_hdata_config_section_cb, NULL);
+ &config_file_hdata_config_section_cb, NULL, NULL);
hook_hdata (NULL, "config_option", N_("config option"),
- &config_file_hdata_config_option_cb, NULL);
+ &config_file_hdata_config_option_cb, NULL, NULL);
hook_hdata (NULL, "filter", N_("filter"),
- &gui_filter_hdata_filter_cb, NULL);
+ &gui_filter_hdata_filter_cb, NULL, NULL);
hook_hdata (NULL, "history", N_("history of commands in buffer"),
- &gui_history_hdata_history_cb, NULL);
+ &gui_history_hdata_history_cb, NULL, NULL);
hook_hdata (NULL, "hotlist", N_("hotlist"),
- &gui_hotlist_hdata_hotlist_cb, NULL);
+ &gui_hotlist_hdata_hotlist_cb, NULL, NULL);
hook_hdata (NULL, "input_undo", N_("structure with undo for input line"),
- &gui_buffer_hdata_input_undo_cb, NULL);
+ &gui_buffer_hdata_input_undo_cb, NULL, NULL);
hook_hdata (NULL, "key", N_("a key (keyboard shortcut)"),
- &gui_key_hdata_key_cb, NULL);
+ &gui_key_hdata_key_cb, NULL, NULL);
hook_hdata (NULL, "layout", N_("layout"),
- &gui_layout_hdata_layout_cb, NULL);
+ &gui_layout_hdata_layout_cb, NULL, NULL);
hook_hdata (NULL, "layout_buffer", N_("buffer layout"),
- &gui_layout_hdata_layout_buffer_cb, NULL);
+ &gui_layout_hdata_layout_buffer_cb, NULL, NULL);
hook_hdata (NULL, "layout_window", N_("window layout"),
- &gui_layout_hdata_layout_window_cb, NULL);
+ &gui_layout_hdata_layout_window_cb, NULL, NULL);
hook_hdata (NULL, "lines", N_("structure with lines"),
- &gui_line_hdata_lines_cb, NULL);
+ &gui_line_hdata_lines_cb, NULL, NULL);
hook_hdata (NULL, "line", N_("structure with one line"),
- &gui_line_hdata_line_cb, NULL);
+ &gui_line_hdata_line_cb, NULL, NULL);
hook_hdata (NULL, "line_data", N_("structure with one line data"),
- &gui_line_hdata_line_data_cb, NULL);
+ &gui_line_hdata_line_data_cb, NULL, NULL);
hook_hdata (NULL, "nick_group", N_("group in nicklist"),
- &gui_nicklist_hdata_nick_group_cb, NULL);
+ &gui_nicklist_hdata_nick_group_cb, NULL, NULL);
hook_hdata (NULL, "nick", N_("nick in nicklist"),
- &gui_nicklist_hdata_nick_cb, NULL);
+ &gui_nicklist_hdata_nick_cb, NULL, NULL);
hook_hdata (NULL, "plugin", N_("plugin"),
- &plugin_hdata_plugin_cb, NULL);
+ &plugin_hdata_plugin_cb, NULL, NULL);
hook_hdata (NULL, "proxy", N_("proxy"),
- &proxy_hdata_proxy_cb, NULL);
+ &proxy_hdata_proxy_cb, NULL, NULL);
hook_hdata (NULL, "window", N_("window"),
- &gui_window_hdata_window_cb, NULL);
+ &gui_window_hdata_window_cb, NULL, NULL);
hook_hdata (NULL, "window_scroll", N_("scroll info in window"),
- &gui_window_hdata_window_scroll_cb, NULL);
+ &gui_window_hdata_window_scroll_cb, NULL, NULL);
hook_hdata (NULL, "window_tree", N_("tree of windows"),
- &gui_window_hdata_window_tree_cb, NULL);
+ &gui_window_hdata_window_tree_cb, NULL, NULL);
}
diff --git a/src/plugins/plugin-api.h b/src/plugins/plugin-api.h
index 672eac8c9..963cc874b 100644
--- a/src/plugins/plugin-api.h
+++ b/src/plugins/plugin-api.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/plugin-config.c b/src/plugins/plugin-config.c
index a1c779fbb..8ba100a75 100644
--- a/src/plugins/plugin-config.c
+++ b/src/plugins/plugin-config.c
@@ -1,7 +1,7 @@
/*
* plugin-config.c - plugin configuration options (file plugins.conf)
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -94,7 +94,8 @@ plugin_config_set_internal (const char *option, const char *value)
ptr_option = config_file_new_option (
plugin_config_file, plugin_config_section_var,
option, "string", NULL,
- NULL, 0, 0, "", value, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "", value, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
rc = (ptr_option) ? WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
}
@@ -133,11 +134,13 @@ plugin_config_set (const char *plugin_name, const char *option_name,
*/
void
-plugin_config_desc_changed_cb (void *data, struct t_config_option *option)
+plugin_config_desc_changed_cb (const void *pointer, void *data,
+ struct t_config_option *option)
{
struct t_config_option *ptr_option;
/* make C compiler happy */
+ (void) pointer;
(void) data;
ptr_option = config_file_search_option (plugin_config_file,
@@ -177,12 +180,14 @@ plugin_config_set_desc_internal (const char *option, const char *value)
ptr_option = config_file_new_option (
plugin_config_file, plugin_config_section_desc,
option, "string", _("description of plugin option"),
- NULL, 0, 0, "", value, 0, NULL, NULL,
- &plugin_config_desc_changed_cb, NULL, NULL, NULL);
+ NULL, 0, 0, "", value, 0,
+ NULL, NULL, NULL,
+ &plugin_config_desc_changed_cb, NULL, NULL,
+ NULL, NULL, NULL);
}
if (ptr_option)
- plugin_config_desc_changed_cb (NULL, ptr_option);
+ plugin_config_desc_changed_cb (NULL, NULL, ptr_option);
}
/*
@@ -213,9 +218,11 @@ plugin_config_set_desc (const char *plugin_name, const char *option_name,
*/
int
-plugin_config_reload (void *data, struct t_config_file *config_file)
+plugin_config_reload (const void *pointer, void *data,
+ struct t_config_file *config_file)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
/* remove all plugin options and descriptions */
@@ -231,13 +238,15 @@ plugin_config_reload (void *data, struct t_config_file *config_file)
*/
int
-plugin_config_create_option (void *data, struct t_config_file *config_file,
+plugin_config_create_option (const void *pointer, void *data,
+ struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name, const char *value)
{
struct t_config_option *ptr_option_desc, *ptr_option;
/* make C compiler happy */
+ (void) pointer;
(void) data;
ptr_option_desc = config_file_search_option (config_file,
@@ -248,7 +257,8 @@ plugin_config_create_option (void *data, struct t_config_file *config_file,
config_file, section,
option_name, "string",
(ptr_option_desc) ? CONFIG_STRING(ptr_option_desc) : NULL,
- NULL, 0, 0, "", value, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "", value, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
return (ptr_option) ?
WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
@@ -259,13 +269,15 @@ plugin_config_create_option (void *data, struct t_config_file *config_file,
*/
int
-plugin_config_create_desc (void *data, struct t_config_file *config_file,
+plugin_config_create_desc (const void *pointer, void *data,
+ struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name, const char *value)
{
struct t_config_option *ptr_option_var, *ptr_option;
/* make C compiler happy */
+ (void) pointer;
(void) data;
ptr_option_var = config_file_search_option (config_file,
@@ -285,8 +297,10 @@ plugin_config_create_desc (void *data, struct t_config_file *config_file,
ptr_option = config_file_new_option (
config_file, section,
option_name, "string", _("description of plugin option"),
- NULL, 0, 0, "", value, 0, NULL, NULL,
- &plugin_config_desc_changed_cb, NULL, NULL, NULL);
+ NULL, 0, 0, "", value, 0,
+ NULL, NULL, NULL,
+ &plugin_config_desc_changed_cb, NULL, NULL,
+ NULL, NULL, NULL);
return (ptr_option) ?
WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
@@ -297,13 +311,15 @@ plugin_config_create_desc (void *data, struct t_config_file *config_file,
*/
int
-plugin_config_delete_desc (void *data, struct t_config_file *config_file,
+plugin_config_delete_desc (const void *pointer, void *data,
+ struct t_config_file *config_file,
struct t_config_section *section,
struct t_config_option *option)
{
struct t_config_option *ptr_option_var;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) section;
@@ -332,23 +348,23 @@ void
plugin_config_init ()
{
plugin_config_file = config_file_new (NULL, PLUGIN_CONFIG_NAME,
- &plugin_config_reload, NULL);
+ &plugin_config_reload, NULL, NULL);
if (plugin_config_file)
{
plugin_config_section_var = config_file_new_section (
plugin_config_file, "var", 1, 1,
- NULL, NULL,
- NULL, NULL,
- NULL, NULL,
- &plugin_config_create_option, NULL,
- NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ &plugin_config_create_option, NULL, NULL,
+ NULL, NULL, NULL);
plugin_config_section_desc = config_file_new_section (
plugin_config_file, "desc", 1, 1,
- NULL, NULL,
- NULL, NULL,
- NULL, NULL,
- &plugin_config_create_desc, NULL,
- &plugin_config_delete_desc, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ &plugin_config_create_desc, NULL, NULL,
+ &plugin_config_delete_desc, NULL, NULL);
}
else
{
diff --git a/src/plugins/plugin-config.h b/src/plugins/plugin-config.h
index c7a0498fa..271d8eee9 100644
--- a/src/plugins/plugin-config.h
+++ b/src/plugins/plugin-config.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/plugin-script-api.c b/src/plugins/plugin-script-api.c
index a8b38b3a8..b8ce32176 100644
--- a/src/plugins/plugin-script-api.c
+++ b/src/plugins/plugin-script-api.c
@@ -1,7 +1,7 @@
/*
* script-api.c - script API functions, used by script plugins
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2012 Simon Arlott
*
* This file is part of WeeChat, the extensible chat client.
@@ -28,7 +28,6 @@
#include "weechat-plugin.h"
#include "plugin-script.h"
#include "plugin-script-api.h"
-#include "plugin-script-callback.h"
/*
@@ -55,24 +54,28 @@ struct t_config_file *
plugin_script_api_config_new (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *name,
- int (*callback_reload)(void *data,
+ int (*callback_reload)(const void *pointer,
+ void *data,
struct t_config_file *config_file),
const char *function,
const char *data)
{
- struct t_plugin_script_cb *script_cb;
+ char *function_and_data;
struct t_config_file *new_config_file;
- script_cb = plugin_script_callback_add (script, function, data);
- if (!script_cb)
- return NULL;
+ function_and_data = plugin_script_build_function_and_data (function, data);
- new_config_file = weechat_config_new (name, callback_reload,
- (function && function[0]) ? script_cb : NULL);
- if (new_config_file)
- script_cb->config_file = new_config_file;
- else
- plugin_script_callback_remove (script, script_cb);
+ new_config_file = weechat_config_new
+ (name,
+ (function_and_data) ? callback_reload : NULL,
+ script,
+ function_and_data);
+
+ if (!new_config_file)
+ {
+ if (function_and_data)
+ free (function_and_data);
+ }
return new_config_file;
}
@@ -90,97 +93,91 @@ plugin_script_api_config_new_section (struct t_weechat_plugin *weechat_plugin,
const char *name,
int user_can_add_options,
int user_can_delete_options,
- int (*callback_read)(void *data,
+ int (*callback_read)(const void *pointer,
+ void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
const char *value),
const char *function_read,
const char *data_read,
- int (*callback_write)(void *data,
+ int (*callback_write)(const void *pointer,
+ void *data,
struct t_config_file *config_file,
const char *section_name),
const char *function_write,
const char *data_write,
- int (*callback_write_default)(void *data,
+ int (*callback_write_default)(const void *pointer,
+ void *data,
struct t_config_file *config_file,
const char *section_name),
const char *function_write_default,
const char *data_write_default,
- int (*callback_create_option)(void *data,
+ int (*callback_create_option)(const void *pointer,
+ void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
const char *value),
const char *function_create_option,
const char *data_create_option,
- int (*callback_delete_option)(void *data,
+ int (*callback_delete_option)(const void *pointer,
+ void *data,
struct t_config_file *config_file,
struct t_config_section *section,
struct t_config_option *option),
const char *function_delete_option,
const char *data_delete_option)
{
- struct t_plugin_script_cb *script_cb_read, *script_cb_write;
- struct t_plugin_script_cb *script_cb_write_default, *script_cb_create_option;
- struct t_plugin_script_cb *script_cb_delete_option;
+ char *function_and_data_read, *function_and_data_write;
+ char *function_and_data_write_default, *function_and_data_create_option;
+ char *function_and_data_delete_option;
struct t_config_section *new_section;
- script_cb_read = plugin_script_callback_add (script, function_read, data_read);
- script_cb_write = plugin_script_callback_add (script, function_write, data_write);
- script_cb_write_default = plugin_script_callback_add (script, function_write_default, data_write_default);
- script_cb_create_option = plugin_script_callback_add (script, function_create_option, data_create_option);
- script_cb_delete_option = plugin_script_callback_add (script, function_delete_option, data_delete_option);
- if (!script_cb_read || !script_cb_write || !script_cb_write_default
- || !script_cb_create_option || !script_cb_delete_option)
+ function_and_data_read = plugin_script_build_function_and_data (
+ function_read, data_read);
+ function_and_data_write = plugin_script_build_function_and_data (
+ function_write, data_write);
+ function_and_data_write_default = plugin_script_build_function_and_data (
+ function_write_default, data_write_default);
+ function_and_data_create_option = plugin_script_build_function_and_data (
+ function_create_option, data_create_option);
+ function_and_data_delete_option = plugin_script_build_function_and_data (
+ function_delete_option, data_delete_option);
+
+ new_section = weechat_config_new_section (
+ config_file,
+ name,
+ user_can_add_options,
+ user_can_delete_options,
+ (function_and_data_read) ? callback_read : NULL,
+ script,
+ function_and_data_read,
+ (function_and_data_write) ? callback_write : NULL,
+ script,
+ function_and_data_write,
+ (function_and_data_write_default) ? callback_write_default : NULL,
+ script,
+ function_and_data_write_default,
+ (function_and_data_create_option) ? callback_create_option : NULL,
+ script,
+ function_and_data_create_option,
+ (function_and_data_delete_option) ? callback_delete_option : NULL,
+ script,
+ function_and_data_delete_option);;
+
+ if (!new_section)
{
- if (script_cb_read)
- plugin_script_callback_remove (script, script_cb_read);
- if (script_cb_write)
- plugin_script_callback_remove (script, script_cb_write);
- if (script_cb_write_default)
- plugin_script_callback_remove (script, script_cb_write_default);
- if (script_cb_create_option)
- plugin_script_callback_remove (script, script_cb_create_option);
- if (script_cb_delete_option)
- plugin_script_callback_remove (script, script_cb_delete_option);
- return NULL;
- }
-
- new_section = weechat_config_new_section (config_file,
- name,
- user_can_add_options,
- user_can_delete_options,
- (function_read && function_read[0]) ? callback_read : NULL,
- (function_read && function_read[0]) ? script_cb_read : NULL,
- (function_write && function_write[0]) ? callback_write : NULL,
- (function_write && function_write[0]) ? script_cb_write : NULL,
- (function_write_default && function_write_default[0]) ? callback_write_default : NULL,
- (function_write_default && function_write_default[0]) ? script_cb_write_default : NULL,
- (function_create_option && function_create_option[0]) ? callback_create_option : NULL,
- (function_create_option && function_create_option[0]) ? script_cb_create_option : NULL,
- (function_delete_option && function_delete_option[0]) ? callback_delete_option : NULL,
- (function_delete_option && function_delete_option[0]) ? script_cb_delete_option : NULL);
- if (new_section)
- {
- script_cb_read->config_file = config_file;
- script_cb_read->config_section = new_section;
- script_cb_write->config_file = config_file;
- script_cb_write->config_section = new_section;
- script_cb_write_default->config_file = config_file;
- script_cb_write_default->config_section = new_section;
- script_cb_create_option->config_file = config_file;
- script_cb_create_option->config_section = new_section;
- script_cb_delete_option->config_file = config_file;
- script_cb_delete_option->config_section = new_section;
- }
- else
- {
- plugin_script_callback_remove (script, script_cb_read);
- plugin_script_callback_remove (script, script_cb_write);
- plugin_script_callback_remove (script, script_cb_write_default);
- plugin_script_callback_remove (script, script_cb_create_option);
- plugin_script_callback_remove (script, script_cb_delete_option);
+ if (function_and_data_read)
+ free (function_and_data_read);
+ if (function_and_data_write)
+ free (function_and_data_write);
+ if (function_and_data_write_default)
+ free (function_and_data_write_default);
+ if (function_and_data_create_option)
+ free (function_and_data_create_option);
+ if (function_and_data_delete_option)
+ free (function_and_data_delete_option);
}
return new_section;
@@ -203,184 +200,63 @@ plugin_script_api_config_new_option (struct t_weechat_plugin *weechat_plugin,
const char *default_value,
const char *value,
int null_value_allowed,
- int (*callback_check_value)(void *data,
+ int (*callback_check_value)(const void *pointer,
+ void *data,
struct t_config_option *option,
const char *value),
const char *function_check_value,
const char *data_check_value,
- void (*callback_change)(void *data,
+ void (*callback_change)(const void *pointer,
+ void *data,
struct t_config_option *option),
const char *function_change,
const char *data_change,
- void (*callback_delete)(void *data,
+ void (*callback_delete)(const void *pointer,
+ void *data,
struct t_config_option *option),
const char *function_delete,
const char *data_delete)
{
- struct t_plugin_script_cb *script_cb_check_value, *script_cb_change;
- struct t_plugin_script_cb *script_cb_delete;
+ char *function_and_data_check_value, *function_and_data_change;
+ char *function_and_data_delete;
struct t_config_option *new_option;
- script_cb_check_value = plugin_script_callback_add (script, function_check_value, data_check_value);
- script_cb_change = plugin_script_callback_add (script, function_change, data_change);
- script_cb_delete = plugin_script_callback_add (script, function_delete, data_delete);
- if (!script_cb_check_value || !script_cb_change || !script_cb_delete)
+ function_and_data_check_value = plugin_script_build_function_and_data (
+ function_check_value, data_check_value);
+ function_and_data_change = plugin_script_build_function_and_data (
+ function_change, data_change);
+ function_and_data_delete = plugin_script_build_function_and_data (
+ function_delete, data_delete);
+
+ new_option = weechat_config_new_option (
+ config_file, section, name, type,
+ description, string_values, min,
+ max, default_value, value,
+ null_value_allowed,
+ (function_and_data_check_value) ? callback_check_value : NULL,
+ script,
+ function_and_data_check_value,
+ (function_and_data_change) ? callback_change : NULL,
+ script,
+ function_and_data_change,
+ (function_and_data_delete) ? callback_delete : NULL,
+ script,
+ function_and_data_delete);
+
+ if (!new_option)
{
- if (script_cb_check_value)
- plugin_script_callback_remove (script, script_cb_check_value);
- if (script_cb_change)
- plugin_script_callback_remove (script, script_cb_change);
- if (script_cb_delete)
- plugin_script_callback_remove (script, script_cb_delete);
- return NULL;
- }
-
- new_option = weechat_config_new_option (config_file, section, name, type,
- description, string_values, min,
- max, default_value, value,
- null_value_allowed,
- (function_check_value && function_check_value[0]) ? callback_check_value : NULL,
- (function_check_value && function_check_value[0]) ? script_cb_check_value : NULL,
- (function_change && function_change[0]) ? callback_change : NULL,
- (function_change && function_change[0]) ? script_cb_change : NULL,
- (function_delete && function_delete[0]) ? callback_delete : NULL,
- (function_delete && function_delete[0]) ? script_cb_delete : NULL);
- if (new_option)
- {
- script_cb_check_value->config_file = config_file;
- script_cb_check_value->config_section = section;
- script_cb_check_value->config_option = new_option;
- script_cb_change->config_file = config_file;
- script_cb_change->config_section = section;
- script_cb_change->config_option = new_option;
- script_cb_delete->config_file = config_file;
- script_cb_delete->config_section = section;
- script_cb_delete->config_option = new_option;
- }
- else
- {
- plugin_script_callback_remove (script, script_cb_check_value);
- plugin_script_callback_remove (script, script_cb_change);
- plugin_script_callback_remove (script, script_cb_delete);
+ if (function_and_data_check_value)
+ free (function_and_data_check_value);
+ if (function_and_data_change)
+ free (function_and_data_change);
+ if (function_and_data_delete)
+ free (function_and_data_delete);
}
return new_option;
}
/*
- * Frees an option in configuration file.
- */
-
-void
-plugin_script_api_config_option_free (struct t_weechat_plugin *weechat_plugin,
- struct t_plugin_script *script,
- struct t_config_option *option)
-{
- struct t_plugin_script_cb *ptr_script_cb, *next_callback;
-
- if (!weechat_plugin || !script || !option)
- return;
-
- weechat_config_option_free (option);
-
- ptr_script_cb = script->callbacks;
- while (ptr_script_cb)
- {
- next_callback = ptr_script_cb->next_callback;
-
- if (ptr_script_cb->config_option == option)
- plugin_script_callback_remove (script, ptr_script_cb);
-
- ptr_script_cb = next_callback;
- }
-}
-
-/*
- * Frees all option of a section in configuration file.
- */
-
-void
-plugin_script_api_config_section_free_options (struct t_weechat_plugin *weechat_plugin,
- struct t_plugin_script *script,
- struct t_config_section *section)
-{
- struct t_plugin_script_cb *ptr_script_cb, *next_callback;
-
- if (!weechat_plugin || !script || !section)
- return;
-
- weechat_config_section_free_options (section);
-
- ptr_script_cb = script->callbacks;
- while (ptr_script_cb)
- {
- next_callback = ptr_script_cb->next_callback;
-
- if ((ptr_script_cb->config_section == section)
- && ptr_script_cb->config_option)
- plugin_script_callback_remove (script, ptr_script_cb);
-
- ptr_script_cb = next_callback;
- }
-}
-
-/*
- * Frees a section in configuration file.
- */
-
-void
-plugin_script_api_config_section_free (struct t_weechat_plugin *weechat_plugin,
- struct t_plugin_script *script,
- struct t_config_section *section)
-{
- struct t_plugin_script_cb *ptr_script_cb, *next_callback;
-
- if (!weechat_plugin || !script || !section)
- return;
-
- weechat_config_section_free (section);
-
- ptr_script_cb = script->callbacks;
- while (ptr_script_cb)
- {
- next_callback = ptr_script_cb->next_callback;
-
- if (ptr_script_cb->config_section == section)
- plugin_script_callback_remove (script, ptr_script_cb);
-
- ptr_script_cb = next_callback;
- }
-}
-
-/*
- * Frees a configuration file.
- */
-
-void
-plugin_script_api_config_free (struct t_weechat_plugin *weechat_plugin,
- struct t_plugin_script *script,
- struct t_config_file *config_file)
-{
- struct t_plugin_script_cb *ptr_script_cb, *next_callback;
-
- if (!weechat_plugin || !script || !config_file)
- return;
-
- weechat_config_free (config_file);
-
- ptr_script_cb = script->callbacks;
- while (ptr_script_cb)
- {
- next_callback = ptr_script_cb->next_callback;
-
- if (ptr_script_cb->config_file == config_file)
- plugin_script_callback_remove (script, ptr_script_cb);
-
- ptr_script_cb = next_callback;
- }
-}
-
-/*
* Prints a message.
*/
@@ -492,30 +368,32 @@ plugin_script_api_hook_command (struct t_weechat_plugin *weechat_plugin,
const char *command, const char *description,
const char *args, const char *args_description,
const char *completion,
- int (*callback)(void *data,
+ int (*callback)(const void *pointer,
+ void *data,
struct t_gui_buffer *buffer,
int argc, char **argv,
char **argv_eol),
const char *function,
const char *data)
{
- struct t_plugin_script_cb *script_cb;
+ char *function_and_data;
struct t_hook *new_hook;
- script_cb = plugin_script_callback_add (script, function, data);
- if (!script_cb)
- return NULL;
+ function_and_data = plugin_script_build_function_and_data (function, data);
new_hook = weechat_hook_command (command, description, args,
args_description, completion,
- callback, script_cb);
+ callback, script, function_and_data);
+
if (new_hook)
{
weechat_hook_set (new_hook, "subplugin", script->name);
- script_cb->hook = new_hook;
}
else
- plugin_script_callback_remove (script, script_cb);
+ {
+ if (function_and_data)
+ free (function_and_data);
+ }
return new_hook;
}
@@ -530,28 +408,30 @@ struct t_hook *
plugin_script_api_hook_command_run (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *command,
- int (*callback)(void *data,
+ int (*callback)(const void *pointer,
+ void *data,
struct t_gui_buffer *buffer,
const char *command),
const char *function,
const char *data)
{
- struct t_plugin_script_cb *script_cb;
+ char *function_and_data;
struct t_hook *new_hook;
- script_cb = plugin_script_callback_add (script, function, data);
- if (!script_cb)
- return NULL;
+ function_and_data = plugin_script_build_function_and_data (function, data);
new_hook = weechat_hook_command_run (command,
- callback, script_cb);
+ callback, script, function_and_data);
+
if (new_hook)
{
weechat_hook_set (new_hook, "subplugin", script->name);
- script_cb->hook = new_hook;
}
else
- plugin_script_callback_remove (script, script_cb);
+ {
+ if (function_and_data)
+ free (function_and_data);
+ }
return new_hook;
}
@@ -566,27 +446,29 @@ struct t_hook *
plugin_script_api_hook_timer (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
int interval, int align_second, int max_calls,
- int (*callback)(void *data,
+ int (*callback)(const void *pointer,
+ void *data,
int remaining_calls),
const char *function,
const char *data)
{
- struct t_plugin_script_cb *script_cb;
+ char *function_and_data;
struct t_hook *new_hook;
- script_cb = plugin_script_callback_add (script, function, data);
- if (!script_cb)
- return NULL;
+ function_and_data = plugin_script_build_function_and_data (function, data);
new_hook = weechat_hook_timer (interval, align_second, max_calls,
- callback, script_cb);
+ callback, script, function_and_data);
+
if (new_hook)
{
weechat_hook_set (new_hook, "subplugin", script->name);
- script_cb->hook = new_hook;
}
else
- plugin_script_callback_remove (script, script_cb);
+ {
+ if (function_and_data)
+ free (function_and_data);
+ }
return new_hook;
}
@@ -602,26 +484,29 @@ plugin_script_api_hook_fd (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
int fd, int flag_read, int flag_write,
int flag_exception,
- int (*callback)(void *data, int fd),
+ int (*callback)(const void *pointer,
+ void *data,
+ int fd),
const char *function,
const char *data)
{
- struct t_plugin_script_cb *script_cb;
+ char *function_and_data;
struct t_hook *new_hook;
- script_cb = plugin_script_callback_add (script, function, data);
- if (!script_cb)
- return NULL;
+ function_and_data = plugin_script_build_function_and_data (function, data);
new_hook = weechat_hook_fd (fd, flag_read, flag_write, flag_exception,
- callback, script_cb);
+ callback, script, function_and_data);
+
if (new_hook)
{
weechat_hook_set (new_hook, "subplugin", script->name);
- script_cb->hook = new_hook;
}
else
- plugin_script_callback_remove (script, script_cb);
+ {
+ if (function_and_data)
+ free (function_and_data);
+ }
return new_hook;
}
@@ -638,7 +523,8 @@ plugin_script_api_hook_process_hashtable (struct t_weechat_plugin *weechat_plugi
const char *command,
struct t_hashtable *options,
int timeout,
- int (*callback)(void *data,
+ int (*callback)(const void *pointer,
+ void *data,
const char *command,
int return_code,
const char *out,
@@ -646,22 +532,24 @@ plugin_script_api_hook_process_hashtable (struct t_weechat_plugin *weechat_plugi
const char *function,
const char *data)
{
- struct t_plugin_script_cb *script_cb;
+ char *function_and_data;
struct t_hook *new_hook;
- script_cb = plugin_script_callback_add (script, function, data);
- if (!script_cb)
- return NULL;
+ function_and_data = plugin_script_build_function_and_data (function, data);
new_hook = weechat_hook_process_hashtable (command, options, timeout,
- callback, script_cb);
+ callback, script,
+ function_and_data);
+
if (new_hook)
{
weechat_hook_set (new_hook, "subplugin", script->name);
- script_cb->hook = new_hook;
}
else
- plugin_script_callback_remove (script, script_cb);
+ {
+ if (function_and_data)
+ free (function_and_data);
+ }
return new_hook;
}
@@ -677,7 +565,8 @@ plugin_script_api_hook_process (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *command,
int timeout,
- int (*callback)(void *data,
+ int (*callback)(const void *pointer,
+ void *data,
const char *command,
int return_code,
const char *out,
@@ -699,37 +588,41 @@ plugin_script_api_hook_process (struct t_weechat_plugin *weechat_plugin,
struct t_hook *
plugin_script_api_hook_connect (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
- const char *proxy, const char *address, int port,
+ const char *proxy,
+ const char *address, int port,
int ipv6, int retry,
void *gnutls_sess, void *gnutls_cb,
int gnutls_dhkey_size,
const char *gnutls_priorities,
const char *local_hostname,
- int (*callback)(void *data, int status,
- int gnutls_rc, int sock,
+ int (*callback)(const void *pointer,
+ void *data,
+ int status, int gnutls_rc,
+ int sock,
const char *error,
const char *ip_address),
const char *function,
const char *data)
{
- struct t_plugin_script_cb *script_cb;
+ char *function_and_data;
struct t_hook *new_hook;
- script_cb = plugin_script_callback_add (script, function, data);
- if (!script_cb)
- return NULL;
+ function_and_data = plugin_script_build_function_and_data (function, data);
new_hook = weechat_hook_connect (proxy, address, port, ipv6, retry,
gnutls_sess, gnutls_cb, gnutls_dhkey_size,
gnutls_priorities, local_hostname,
- callback, script_cb);
+ callback, script, function_and_data);
+
if (new_hook)
{
weechat_hook_set (new_hook, "subplugin", script->name);
- script_cb->hook = new_hook;
}
else
- plugin_script_callback_remove (script, script_cb);
+ {
+ if (function_and_data)
+ free (function_and_data);
+ }
return new_hook;
}
@@ -746,32 +639,35 @@ plugin_script_api_hook_print (struct t_weechat_plugin *weechat_plugin,
struct t_gui_buffer *buffer,
const char *tags, const char *message,
int strip_colors,
- int (*callback)(void *data,
+ int (*callback)(const void *pointer,
+ void *data,
struct t_gui_buffer *buffer,
time_t date,
- int tags_count, const char **tags,
+ int tags_count,
+ const char **tags,
int displayed, int highlight,
const char *prefix,
const char *message),
const char *function,
const char *data)
{
- struct t_plugin_script_cb *script_cb;
+ char *function_and_data;
struct t_hook *new_hook;
- script_cb = plugin_script_callback_add (script, function, data);
- if (!script_cb)
- return NULL;
+ function_and_data = plugin_script_build_function_and_data (function, data);
new_hook = weechat_hook_print (buffer, tags, message, strip_colors,
- callback, script_cb);
+ callback, script, function_and_data);
+
if (new_hook)
{
weechat_hook_set (new_hook, "subplugin", script->name);
- script_cb->hook = new_hook;
}
else
- plugin_script_callback_remove (script, script_cb);
+ {
+ if (function_and_data)
+ free (function_and_data);
+ }
return new_hook;
}
@@ -786,27 +682,31 @@ struct t_hook *
plugin_script_api_hook_signal (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *signal,
- int (*callback)(void *data, const char *signal,
+ int (*callback)(const void *pointer,
+ void *data,
+ const char *signal,
const char *type_data,
void *signal_data),
const char *function,
const char *data)
{
- struct t_plugin_script_cb *script_cb;
+ char *function_and_data;
struct t_hook *new_hook;
- script_cb = plugin_script_callback_add (script, function, data);
- if (!script_cb)
- return NULL;
+ function_and_data = plugin_script_build_function_and_data (function, data);
+
+ new_hook = weechat_hook_signal (signal, callback, script,
+ function_and_data);
- new_hook = weechat_hook_signal (signal, callback, script_cb);
if (new_hook)
{
weechat_hook_set (new_hook, "subplugin", script->name);
- script_cb->hook = new_hook;
}
else
- plugin_script_callback_remove (script, script_cb);
+ {
+ if (function_and_data)
+ free (function_and_data);
+ }
return new_hook;
}
@@ -821,26 +721,30 @@ struct t_hook *
plugin_script_api_hook_hsignal (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *signal,
- int (*callback)(void *data, const char *signal,
+ int (*callback)(const void *pointer,
+ void *data,
+ const char *signal,
struct t_hashtable *hashtable),
const char *function,
const char *data)
{
- struct t_plugin_script_cb *script_cb;
+ char *function_and_data;
struct t_hook *new_hook;
- script_cb = plugin_script_callback_add (script, function, data);
- if (!script_cb)
- return NULL;
+ function_and_data = plugin_script_build_function_and_data (function, data);
+
+ new_hook = weechat_hook_hsignal (signal, callback, script,
+ function_and_data);
- new_hook = weechat_hook_hsignal (signal, callback, script_cb);
if (new_hook)
{
weechat_hook_set (new_hook, "subplugin", script->name);
- script_cb->hook = new_hook;
}
else
- plugin_script_callback_remove (script, script_cb);
+ {
+ if (function_and_data)
+ free (function_and_data);
+ }
return new_hook;
}
@@ -855,26 +759,30 @@ struct t_hook *
plugin_script_api_hook_config (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *option,
- int (*callback)(void *data, const char *option,
+ int (*callback)(const void *pointer,
+ void *data,
+ const char *option,
const char *value),
const char *function,
const char *data)
{
- struct t_plugin_script_cb *script_cb;
+ char *function_and_data;
struct t_hook *new_hook;
- script_cb = plugin_script_callback_add (script, function, data);
- if (!script_cb)
- return NULL;
+ function_and_data = plugin_script_build_function_and_data (function, data);
+
+ new_hook = weechat_hook_config (option, callback, script,
+ function_and_data);
- new_hook = weechat_hook_config (option, callback, script_cb);
if (new_hook)
{
weechat_hook_set (new_hook, "subplugin", script->name);
- script_cb->hook = new_hook;
}
else
- plugin_script_callback_remove (script, script_cb);
+ {
+ if (function_and_data)
+ free (function_and_data);
+ }
return new_hook;
}
@@ -890,29 +798,31 @@ plugin_script_api_hook_completion (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *completion,
const char *description,
- int (*callback)(void *data,
+ int (*callback)(const void *pointer,
+ void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion),
const char *function,
const char *data)
{
- struct t_plugin_script_cb *script_cb;
+ char *function_and_data;
struct t_hook *new_hook;
- script_cb = plugin_script_callback_add (script, function, data);
- if (!script_cb)
- return NULL;
+ function_and_data = plugin_script_build_function_and_data (function, data);
new_hook = weechat_hook_completion (completion, description,
- callback, script_cb);
+ callback, script, function_and_data);
+
if (new_hook)
{
weechat_hook_set (new_hook, "subplugin", script->name);
- script_cb->hook = new_hook;
}
else
- plugin_script_callback_remove (script, script_cb);
+ {
+ if (function_and_data)
+ free (function_and_data);
+ }
return new_hook;
}
@@ -927,27 +837,31 @@ struct t_hook *
plugin_script_api_hook_modifier (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *modifier,
- char *(*callback)(void *data, const char *modifier,
+ char *(*callback)(const void *pointer,
+ void *data,
+ const char *modifier,
const char *modifier_data,
const char *string),
const char *function,
const char *data)
{
- struct t_plugin_script_cb *script_cb;
+ char *function_and_data;
struct t_hook *new_hook;
- script_cb = plugin_script_callback_add (script, function, data);
- if (!script_cb)
- return NULL;
+ function_and_data = plugin_script_build_function_and_data (function, data);
+
+ new_hook = weechat_hook_modifier (modifier,
+ callback, script, function_and_data);
- new_hook = weechat_hook_modifier (modifier, callback, script_cb);
if (new_hook)
{
weechat_hook_set (new_hook, "subplugin", script->name);
- script_cb->hook = new_hook;
}
else
- plugin_script_callback_remove (script, script_cb);
+ {
+ if (function_and_data)
+ free (function_and_data);
+ }
return new_hook;
}
@@ -964,28 +878,30 @@ plugin_script_api_hook_info (struct t_weechat_plugin *weechat_plugin,
const char *info_name,
const char *description,
const char *args_description,
- const char *(*callback)(void *data,
+ const char *(*callback)(const void *pointer,
+ void *data,
const char *info_name,
const char *arguments),
const char *function,
const char *data)
{
- struct t_plugin_script_cb *script_cb;
+ char *function_and_data;
struct t_hook *new_hook;
- script_cb = plugin_script_callback_add (script, function, data);
- if (!script_cb)
- return NULL;
+ function_and_data = plugin_script_build_function_and_data (function, data);
new_hook = weechat_hook_info (info_name, description, args_description,
- callback, script_cb);
+ callback, script, function_and_data);
+
if (new_hook)
{
weechat_hook_set (new_hook, "subplugin", script->name);
- script_cb->hook = new_hook;
}
else
- plugin_script_callback_remove (script, script_cb);
+ {
+ if (function_and_data)
+ free (function_and_data);
+ }
return new_hook;
}
@@ -1003,30 +919,33 @@ plugin_script_api_hook_info_hashtable (struct t_weechat_plugin *weechat_plugin,
const char *description,
const char *args_description,
const char *output_description,
- struct t_hashtable *(*callback)(void *data,
+ struct t_hashtable *(*callback)(const void *pointer,
+ void *data,
const char *info_name,
struct t_hashtable *hashtable),
const char *function,
const char *data)
{
- struct t_plugin_script_cb *script_cb;
+ char *function_and_data;
struct t_hook *new_hook;
- script_cb = plugin_script_callback_add (script, function, data);
- if (!script_cb)
- return NULL;
+ function_and_data = plugin_script_build_function_and_data (function, data);
new_hook = weechat_hook_info_hashtable (info_name, description,
args_description,
output_description,
- callback, script_cb);
+ callback, script,
+ function_and_data);
+
if (new_hook)
{
weechat_hook_set (new_hook, "subplugin", script->name);
- script_cb->hook = new_hook;
}
else
- plugin_script_callback_remove (script, script_cb);
+ {
+ if (function_and_data)
+ free (function_and_data);
+ }
return new_hook;
}
@@ -1044,30 +963,32 @@ plugin_script_api_hook_infolist (struct t_weechat_plugin *weechat_plugin,
const char *description,
const char *pointer_description,
const char *args_description,
- struct t_infolist *(*callback)(void *data,
+ struct t_infolist *(*callback)(const void *pointer,
+ void *data,
const char *infolist_name,
- void *pointer,
+ void *obj_pointer,
const char *arguments),
const char *function,
const char *data)
{
- struct t_plugin_script_cb *script_cb;
+ char *function_and_data;
struct t_hook *new_hook;
- script_cb = plugin_script_callback_add (script, function, data);
- if (!script_cb)
- return NULL;
+ function_and_data = plugin_script_build_function_and_data (function, data);
new_hook = weechat_hook_infolist (infolist_name, description,
pointer_description, args_description,
- callback, script_cb);
+ callback, script, function_and_data);
+
if (new_hook)
{
weechat_hook_set (new_hook, "subplugin", script->name);
- script_cb->hook = new_hook;
}
else
- plugin_script_callback_remove (script, script_cb);
+ {
+ if (function_and_data)
+ free (function_and_data);
+ }
return new_hook;
}
@@ -1082,81 +1003,30 @@ struct t_hook *
plugin_script_api_hook_focus (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *area,
- struct t_hashtable *(*callback)(void *data,
+ struct t_hashtable *(*callback)(const void *pointer,
+ void *data,
struct t_hashtable *info),
const char *function,
const char *data)
{
- struct t_plugin_script_cb *script_cb;
+ char *function_and_data;
struct t_hook *new_hook;
- script_cb = plugin_script_callback_add (script, function, data);
- if (!script_cb)
- return NULL;
+ function_and_data = plugin_script_build_function_and_data (function, data);
+
+ new_hook = weechat_hook_focus (area, callback, script, function_and_data);
- new_hook = weechat_hook_focus (area, callback, script_cb);
if (new_hook)
{
weechat_hook_set (new_hook, "subplugin", script->name);
- script_cb->hook = new_hook;
}
else
- plugin_script_callback_remove (script, script_cb);
-
- return new_hook;
-}
-
-/*
- * Unhooks something.
- */
-
-void
-plugin_script_api_unhook (struct t_weechat_plugin *weechat_plugin,
- struct t_plugin_script *script,
- struct t_hook *hook)
-{
- struct t_plugin_script_cb *ptr_script_cb, *next_callback;
-
- if (!weechat_plugin || !script || !hook)
- return;
-
- weechat_unhook (hook);
-
- ptr_script_cb = script->callbacks;
- while (ptr_script_cb)
{
- next_callback = ptr_script_cb->next_callback;
-
- if (ptr_script_cb->hook == hook)
- plugin_script_callback_remove (script, ptr_script_cb);
-
- ptr_script_cb = next_callback;
+ if (function_and_data)
+ free (function_and_data);
}
-}
-
-/*
- * Unhooks everything for a script.
- */
-
-void
-plugin_script_api_unhook_all (struct t_weechat_plugin *weechat_plugin,
- struct t_plugin_script *script)
-{
- struct t_plugin_script_cb *ptr_script_cb, *next_callback;
-
- ptr_script_cb = script->callbacks;
- while (ptr_script_cb)
- {
- next_callback = ptr_script_cb->next_callback;
- if (ptr_script_cb->hook)
- {
- weechat_unhook (ptr_script_cb->hook);
- plugin_script_callback_remove (script, ptr_script_cb);
- }
-
- ptr_script_cb = next_callback;
- }
+ return new_hook;
}
/*
@@ -1167,86 +1037,61 @@ struct t_gui_buffer *
plugin_script_api_buffer_new (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *name,
- int (*input_callback)(void *data,
+ int (*input_callback)(const void *pointer,
+ void *data,
struct t_gui_buffer *buffer,
const char *input_data),
const char *function_input,
const char *data_input,
- int (*close_callback)(void *data,
+ int (*close_callback)(const void *pointer,
+ void *data,
struct t_gui_buffer *buffer),
const char *function_close,
const char *data_close)
{
- struct t_plugin_script_cb *script_cb_input;
- struct t_plugin_script_cb *script_cb_close;
+ char *function_and_data_input, *function_and_data_close;
struct t_gui_buffer *new_buffer;
- script_cb_input = plugin_script_callback_add (script, function_input, data_input);
- script_cb_close = plugin_script_callback_add (script, function_close, data_close);
- if (!script_cb_input || !script_cb_close)
- {
- if (script_cb_input)
- plugin_script_callback_remove (script, script_cb_input);
- if (script_cb_close)
- plugin_script_callback_remove (script, script_cb_close);
- return NULL;
- }
+ function_and_data_input = plugin_script_build_function_and_data (
+ function_input, data_input);
+ function_and_data_close = plugin_script_build_function_and_data (
+ function_close, data_close);
+
+ new_buffer = weechat_buffer_new (
+ name,
+ (function_and_data_input) ? input_callback : NULL,
+ script,
+ function_and_data_input,
+ (function_and_data_close) ? close_callback : NULL,
+ script,
+ function_and_data_close);
- new_buffer = weechat_buffer_new (name,
- (function_input && function_input[0]) ? input_callback : NULL,
- (function_input && function_input[0]) ? script_cb_input : NULL,
- (function_close && function_close[0]) ? close_callback : NULL,
- (function_close && function_close[0]) ? script_cb_close : NULL);
if (new_buffer)
{
- script_cb_input->buffer = new_buffer;
- script_cb_close->buffer = new_buffer;
-
/* used when upgrading weechat, to set callbacks */
- weechat_buffer_set (new_buffer, "localvar_set_script_name", script->name);
- weechat_buffer_set (new_buffer, "localvar_set_script_input_cb", function_input);
- weechat_buffer_set (new_buffer, "localvar_set_script_input_cb_data", data_input);
- weechat_buffer_set (new_buffer, "localvar_set_script_close_cb", function_close);
- weechat_buffer_set (new_buffer, "localvar_set_script_close_cb_data", data_close);
+ weechat_buffer_set (new_buffer,
+ "localvar_set_script_name", script->name);
+ weechat_buffer_set (new_buffer,
+ "localvar_set_script_input_cb", function_input);
+ weechat_buffer_set (new_buffer,
+ "localvar_set_script_input_cb_data", data_input);
+ weechat_buffer_set (new_buffer,
+ "localvar_set_script_close_cb", function_close);
+ weechat_buffer_set (new_buffer,
+ "localvar_set_script_close_cb_data", data_close);
}
else
{
- plugin_script_callback_remove (script, script_cb_input);
- plugin_script_callback_remove (script, script_cb_close);
+ if (function_and_data_input)
+ free (function_and_data_input);
+ if (function_and_data_close)
+ free (function_and_data_close);
}
return new_buffer;
}
/*
- * Closes a buffer.
- */
-
-void
-plugin_script_api_buffer_close (struct t_weechat_plugin *weechat_plugin,
- struct t_plugin_script *script,
- struct t_gui_buffer *buffer)
-{
- struct t_plugin_script_cb *ptr_script_cb, *next_callback;
-
- if (!weechat_plugin || !script || !buffer)
- return;
-
- weechat_buffer_close (buffer);
-
- ptr_script_cb = script->callbacks;
- while (ptr_script_cb)
- {
- next_callback = ptr_script_cb->next_callback;
-
- if (ptr_script_cb->buffer == buffer)
- plugin_script_callback_remove (script, ptr_script_cb);
-
- ptr_script_cb = next_callback;
- }
-}
-
-/*
* Adds a new bar item.
*
* Returns pointer to new bar item, NULL if error.
@@ -1256,7 +1101,8 @@ struct t_gui_bar_item *
plugin_script_api_bar_item_new (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *name,
- char *(*build_callback)(void *data,
+ char *(*build_callback)(const void *pointer,
+ void *data,
struct t_gui_bar_item *item,
struct t_gui_window *window,
struct t_gui_buffer *buffer,
@@ -1264,9 +1110,8 @@ plugin_script_api_bar_item_new (struct t_weechat_plugin *weechat_plugin,
const char *function,
const char *data)
{
- struct t_plugin_script_cb *script_cb;
struct t_gui_bar_item *new_item;
- char str_function[1024];
+ char str_function[1024], *function_and_data;;
int new_callback;
new_callback = 0;
@@ -1284,47 +1129,16 @@ plugin_script_api_bar_item_new (struct t_weechat_plugin *weechat_plugin,
function);
}
- script_cb = plugin_script_callback_add (script, str_function, data);
- if (!script_cb)
- return NULL;
-
- new_item = weechat_bar_item_new (name,
- (str_function[0]) ? build_callback : NULL,
- (str_function[0]) ? script_cb : NULL);
- if (new_item)
- script_cb->bar_item = new_item;
- else
- plugin_script_callback_remove (script, script_cb);
+ function_and_data = plugin_script_build_function_and_data (str_function,
+ data);
- return new_item;
-}
+ new_item = weechat_bar_item_new (name, build_callback, script,
+ function_and_data);
-/*
- * Removes a bar item.
- */
+ if (!new_item && function_and_data)
+ free (function_and_data);
-void
-plugin_script_api_bar_item_remove (struct t_weechat_plugin *weechat_plugin,
- struct t_plugin_script *script,
- struct t_gui_bar_item *item)
-{
- struct t_plugin_script_cb *ptr_script_cb, *next_callback;
-
- if (!weechat_plugin || !script || !item)
- return;
-
- weechat_bar_item_remove (item);
-
- ptr_script_cb = script->callbacks;
- while (ptr_script_cb)
- {
- next_callback = ptr_script_cb->next_callback;
-
- if (ptr_script_cb->bar_item == item)
- plugin_script_callback_remove (script, ptr_script_cb);
-
- ptr_script_cb = next_callback;
- }
+ return new_item;
}
/*
@@ -1372,6 +1186,7 @@ plugin_script_api_config_get_plugin (struct t_weechat_plugin *weechat_plugin,
strcat (option_fullname, option);
return_value = weechat_config_get_plugin (option_fullname);
+
free (option_fullname);
return return_value;
@@ -1403,6 +1218,7 @@ plugin_script_api_config_is_set_plugin (struct t_weechat_plugin *weechat_plugin,
strcat (option_fullname, option);
return_code = weechat_config_is_set_plugin (option_fullname);
+
free (option_fullname);
return return_code;
@@ -1430,6 +1246,7 @@ plugin_script_api_config_set_plugin (struct t_weechat_plugin *weechat_plugin,
strcat (option_fullname, option);
return_code = weechat_config_set_plugin (option_fullname, value);
+
free (option_fullname);
return return_code;
@@ -1456,6 +1273,7 @@ plugin_script_api_config_set_desc_plugin (struct t_weechat_plugin *weechat_plugi
strcat (option_fullname, option);
weechat_config_set_desc_plugin (option_fullname, description);
+
free (option_fullname);
}
@@ -1481,46 +1299,45 @@ plugin_script_api_config_unset_plugin (struct t_weechat_plugin *weechat_plugin,
strcat (option_fullname, option);
return_code = weechat_config_unset_plugin (option_fullname);
+
free (option_fullname);
return return_code;
}
/*
- * Reads upgrade file.
+ * Creates an upgrade file.
*
* Returns:
* 1: OK
* 0: error
*/
-int
-plugin_script_api_upgrade_read (struct t_weechat_plugin *weechat_plugin,
- struct t_plugin_script *script,
- struct t_upgrade_file *upgrade_file,
- int (*callback_read)(void *data,
- struct t_upgrade_file *upgrade_file,
- int object_id,
- struct t_infolist *infolist),
- const char *function,
- const char *data)
+struct t_upgrade_file *
+plugin_script_api_upgrade_new (struct t_weechat_plugin *weechat_plugin,
+ struct t_plugin_script *script,
+ const char *filename,
+ int (*callback_read)(const void *pointer,
+ void *data,
+ struct t_upgrade_file *upgrade_file,
+ int object_id,
+ struct t_infolist *infolist),
+ const char *function,
+ const char *data)
{
- struct t_plugin_script_cb *script_cb;
- int rc;
+ char *function_and_data;
+ struct t_upgrade_file *new_upgrade_file;
- if (!function || !function[0])
- return 0;
+ function_and_data = plugin_script_build_function_and_data (function, data);
- script_cb = plugin_script_callback_add (script, function, data);
- if (!script_cb)
- return 0;
- script_cb->upgrade_file = upgrade_file;
-
- rc = weechat_upgrade_read (upgrade_file,
- callback_read,
- script_cb);
+ new_upgrade_file = weechat_upgrade_new (
+ filename,
+ (function_and_data) ? callback_read : NULL,
+ script,
+ function_and_data);
- plugin_script_callback_remove (script, script_cb);
+ if (!new_upgrade_file && function_and_data)
+ free (function_and_data);
- return rc;
+ return new_upgrade_file;
}
diff --git a/src/plugins/plugin-script-api.h b/src/plugins/plugin-script-api.h
index 7786c8798..d6cfb68b8 100644
--- a/src/plugins/plugin-script-api.h
+++ b/src/plugins/plugin-script-api.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2012 Simon Arlott
*
* This file is part of WeeChat, the extensible chat client.
@@ -26,7 +26,8 @@ extern void plugin_script_api_charset_set (struct t_plugin_script *script,
extern struct t_config_file *plugin_script_api_config_new (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *name,
- int (*callback_reload)(void *data,
+ int (*callback_reload)(const void *pointer,
+ void *data,
struct t_config_file *config_file),
const char *function,
const char *data);
@@ -36,31 +37,36 @@ extern struct t_config_section *plugin_script_api_config_new_section (struct t_w
const char *name,
int user_can_add_options,
int user_can_delete_options,
- int (*callback_read)(void *data,
+ int (*callback_read)(const void *pointer,
+ void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
const char *value),
const char *function_read,
const char *data_read,
- int (*callback_write)(void *data,
+ int (*callback_write)(const void *pointer,
+ void *data,
struct t_config_file *config_file,
const char *section_name),
const char *function_write,
const char *data_write,
- int (*callback_write_default)(void *data,
+ int (*callback_write_default)(const void *pointer,
+ void *data,
struct t_config_file *config_file,
const char *section_name),
const char *function_write_default,
const char *data_write_default,
- int (*callback_create_option)(void *data,
+ int (*callback_create_option)(const void *pointer,
+ void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
const char *value),
const char *function_create_option,
const char *data_create_option,
- int (*callback_delete_option)(void *data,
+ int (*callback_delete_option)(const void *pointer,
+ void *data,
struct t_config_file *config_file,
struct t_config_section *section,
struct t_config_option *option),
@@ -78,31 +84,22 @@ extern struct t_config_option *plugin_script_api_config_new_option (struct t_wee
const char *default_value,
const char *value,
int null_value_allowed,
- int (*callback_check_value)(void *data,
+ int (*callback_check_value)(const void *pointer,
+ void *data,
struct t_config_option *option,
const char *value),
const char *function_check_value,
const char *data_check_value,
- void (*callback_change)(void *data,
+ void (*callback_change)(const void *pointer,
+ void *data,
struct t_config_option *option),
const char *function_change,
const char *data_change,
- void (*callback_delete)(void *data,
+ void (*callback_delete)(const void *pointer,
+ void *data,
struct t_config_option *option),
const char *function_delete,
const char *data_delete);
-extern void plugin_script_api_config_option_free (struct t_weechat_plugin *weechat_plugin,
- struct t_plugin_script *script,
- struct t_config_option *option);
-extern void plugin_script_api_config_section_free_options (struct t_weechat_plugin *weechat_plugin,
- struct t_plugin_script *script,
- struct t_config_section *section);
-extern void plugin_script_api_config_section_free (struct t_weechat_plugin *weechat_plugin,
- struct t_plugin_script *script,
- struct t_config_section *section);
-extern void plugin_script_api_config_free (struct t_weechat_plugin *weechat_plugin,
- struct t_plugin_script *script,
- struct t_config_file *config_file);
extern void plugin_script_api_printf (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
struct t_gui_buffer *buffer,
@@ -124,7 +121,8 @@ extern struct t_hook *plugin_script_api_hook_command (struct t_weechat_plugin *w
const char *command, const char *description,
const char *args, const char *args_description,
const char *completion,
- int (*callback)(void *data,
+ int (*callback)(const void *pointer,
+ void *data,
struct t_gui_buffer *buffer,
int argc, char **argv,
char **argv_eol),
@@ -133,7 +131,8 @@ extern struct t_hook *plugin_script_api_hook_command (struct t_weechat_plugin *w
extern struct t_hook *plugin_script_api_hook_command_run (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *command,
- int (*callback)(void *data,
+ int (*callback)(const void *pointer,
+ void *data,
struct t_gui_buffer *buffer,
const char *command),
const char *function,
@@ -142,7 +141,8 @@ extern struct t_hook *plugin_script_api_hook_timer (struct t_weechat_plugin *wee
struct t_plugin_script *script,
int interval, int align_second,
int max_calls,
- int (*callback)(void *data,
+ int (*callback)(const void *pointer,
+ void *data,
int remaining_calls),
const char *function,
const char *data);
@@ -150,7 +150,9 @@ extern struct t_hook *plugin_script_api_hook_fd (struct t_weechat_plugin *weecha
struct t_plugin_script *script,
int fd, int flag_read,
int flag_write, int flag_exception,
- int (*callback)(void *data, int fd),
+ int (*callback)(const void *pointer,
+ void *data,
+ int fd),
const char *function,
const char *data);
extern struct t_hook *plugin_script_api_hook_process_hashtable (struct t_weechat_plugin *weechat_plugin,
@@ -158,7 +160,8 @@ extern struct t_hook *plugin_script_api_hook_process_hashtable (struct t_weechat
const char *command,
struct t_hashtable *options,
int timeout,
- int (*callback)(void *data,
+ int (*callback)(const void *pointer,
+ void *data,
const char *command,
int return_code,
const char *out,
@@ -169,7 +172,8 @@ extern struct t_hook *plugin_script_api_hook_process (struct t_weechat_plugin *w
struct t_plugin_script *script,
const char *command,
int timeout,
- int (*callback)(void *data,
+ int (*callback)(const void *pointer,
+ void *data,
const char *command,
int return_code,
const char *out,
@@ -188,7 +192,8 @@ extern struct t_hook *plugin_script_api_hook_connect (struct t_weechat_plugin *w
int gnutls_dhkey_size,
const char *gnutls_priorities,
const char *local_hostname,
- int (*callback)(void *data,
+ int (*callback)(const void *pointer,
+ void *data,
int status,
int gnutls_rc,
int sock,
@@ -202,7 +207,8 @@ extern struct t_hook *plugin_script_api_hook_print (struct t_weechat_plugin *wee
const char *tags,
const char *message,
int strip_colors,
- int (*callback)(void *data,
+ int (*callback)(const void *pointer,
+ void *data,
struct t_gui_buffer *buffer,
time_t date,
int tags_count,
@@ -216,7 +222,8 @@ extern struct t_hook *plugin_script_api_hook_print (struct t_weechat_plugin *wee
extern struct t_hook *plugin_script_api_hook_signal (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *signal,
- int (*callback)(void *data,
+ int (*callback)(const void *pointer,
+ void *data,
const char *signal,
const char *type_data,
void *signal_data),
@@ -225,7 +232,8 @@ extern struct t_hook *plugin_script_api_hook_signal (struct t_weechat_plugin *we
extern struct t_hook *plugin_script_api_hook_hsignal (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *signal,
- int (*callback)(void *data,
+ int (*callback)(const void *pointer,
+ void *data,
const char *signal,
struct t_hashtable *hashtable),
const char *function,
@@ -233,7 +241,8 @@ extern struct t_hook *plugin_script_api_hook_hsignal (struct t_weechat_plugin *w
extern struct t_hook *plugin_script_api_hook_config (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *option,
- int (*callback)(void *data,
+ int (*callback)(const void *pointer,
+ void *data,
const char *option,
const char *value),
const char *function,
@@ -242,7 +251,8 @@ extern struct t_hook *plugin_script_api_hook_completion (struct t_weechat_plugin
struct t_plugin_script *script,
const char *completion,
const char *description,
- int (*callback)(void *data,
+ int (*callback)(const void *pointer,
+ void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion),
@@ -251,7 +261,8 @@ extern struct t_hook *plugin_script_api_hook_completion (struct t_weechat_plugin
extern struct t_hook *plugin_script_api_hook_modifier (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *modifier,
- char *(*callback)(void *data,
+ char *(*callback)(const void *pointer,
+ void *data,
const char *modifier,
const char *modifier_data,
const char *string),
@@ -262,7 +273,8 @@ extern struct t_hook *plugin_script_api_hook_info (struct t_weechat_plugin *weec
const char *info_name,
const char *description,
const char *args_description,
- const char *(*callback)(void *data,
+ const char *(*callback)(const void *pointer,
+ void *data,
const char *info_name,
const char *arguments),
const char *function,
@@ -273,7 +285,8 @@ extern struct t_hook *plugin_script_api_hook_info_hashtable (struct t_weechat_pl
const char *description,
const char *args_description,
const char *output_description,
- struct t_hashtable *(*callback)(void *data,
+ struct t_hashtable *(*callback)(const void *pointer,
+ void *data,
const char *info_name,
struct t_hashtable *hashtable),
const char *function,
@@ -284,52 +297,46 @@ extern struct t_hook *plugin_script_api_hook_infolist (struct t_weechat_plugin *
const char *description,
const char *pointer_description,
const char *args_description,
- struct t_infolist *(*callback)(void *data,
+ struct t_infolist *(*callback)(const void *pointer,
+ void *data,
const char *infolist_name,
- void *pointer,
+ void *obj_pointer,
const char *arguments),
const char *function,
const char *data);
extern struct t_hook *plugin_script_api_hook_focus (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *area,
- struct t_hashtable *(*callback)(void *data,
+ struct t_hashtable *(*callback)(const void *pointer,
+ void *data,
struct t_hashtable *info),
const char *function,
const char *data);
-extern void plugin_script_api_unhook (struct t_weechat_plugin *weechat_plugin,
- struct t_plugin_script *script,
- struct t_hook *hook);
-extern void plugin_script_api_unhook_all (struct t_weechat_plugin *weechat_plugin,
- struct t_plugin_script *script);
extern struct t_gui_buffer *plugin_script_api_buffer_new (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *name,
- int (*input_callback)(void *data,
+ int (*input_callback)(const void *pointer,
+ void *data,
struct t_gui_buffer *buffer,
const char *input_data),
const char *function_input,
const char *data_input,
- int (*close_callback)(void *data,
+ int (*close_callback)(const void *pointer,
+ void *data,
struct t_gui_buffer *buffer),
const char *function_close,
const char *data_close);
-extern void plugin_script_api_buffer_close (struct t_weechat_plugin *weechat_plugin,
- struct t_plugin_script *script,
- struct t_gui_buffer *buffer);
extern struct t_gui_bar_item *plugin_script_api_bar_item_new (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *name,
- char *(*build_callback)(void *data,
+ char *(*build_callback)(const void *pointer,
+ void *data,
struct t_gui_bar_item *item,
struct t_gui_window *window,
struct t_gui_buffer *buffer,
struct t_hashtable *extra_info),
const char *function,
const char *data);
-extern void plugin_script_api_bar_item_remove (struct t_weechat_plugin *weechat_plugin,
- struct t_plugin_script *script,
- struct t_gui_bar_item *item);
extern int plugin_script_api_command (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
struct t_gui_buffer *buffer,
@@ -350,14 +357,15 @@ extern void plugin_script_api_config_set_desc_plugin (struct t_weechat_plugin *w
extern int plugin_script_api_config_unset_plugin (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *option);
-extern int plugin_script_api_upgrade_read (struct t_weechat_plugin *weechat_plugin,
- struct t_plugin_script *script,
- struct t_upgrade_file *upgrade_file,
- int (*callback_read)(void *data,
- struct t_upgrade_file *upgrade_file,
- int object_id,
- struct t_infolist *infolist),
- const char *function,
- const char *data);
+extern struct t_upgrade_file *plugin_script_api_upgrade_new (struct t_weechat_plugin *weechat_plugin,
+ struct t_plugin_script *script,
+ const char *filename,
+ int (*callback_read)(const void *pointer,
+ void *data,
+ struct t_upgrade_file *upgrade_file,
+ int object_id,
+ struct t_infolist *infolist),
+ const char *function,
+ const char *data);
#endif /* WEECHAT_PLUGIN_SCRIPT_API_H */
diff --git a/src/plugins/plugin-script-callback.c b/src/plugins/plugin-script-callback.c
deleted file mode 100644
index 437116c16..000000000
--- a/src/plugins/plugin-script-callback.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * script-callback.c - script callbacks management
- *
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
- *
- * This file is part of WeeChat, the extensible chat client.
- *
- * WeeChat 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.
- *
- * WeeChat 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 WeeChat. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <string.h>
-#include <stddef.h>
-
-#include "weechat-plugin.h"
-#include "plugin-script.h"
-#include "plugin-script-callback.h"
-
-
-/*
- * Allocates a new callback and initializes it.
- */
-
-struct t_plugin_script_cb *
-plugin_script_callback_alloc ()
-{
- struct t_plugin_script_cb *new_script_callback;
-
- new_script_callback = malloc (sizeof (*new_script_callback));
- if (new_script_callback)
- {
- new_script_callback->script = NULL;
- new_script_callback->function = NULL;
- new_script_callback->data = NULL;
- new_script_callback->config_file = NULL;
- new_script_callback->config_section = NULL;
- new_script_callback->config_option = NULL;
- new_script_callback->hook = NULL;
- new_script_callback->buffer = NULL;
- new_script_callback->bar_item = NULL;
- new_script_callback->upgrade_file = NULL;
- return new_script_callback;
- }
-
- return NULL;
-}
-
-/*
- * Adds a callback to list of callbacks.
- *
- * Returns pointer to new callback, NULL if error.
- */
-
-struct t_plugin_script_cb *
-plugin_script_callback_add (struct t_plugin_script *script,
- const char *function,
- const char *data)
-{
- struct t_plugin_script_cb *script_cb;
- if (!script)
- return NULL;
-
- script_cb = plugin_script_callback_alloc ();
- if (!script_cb)
- return NULL;
-
- /* initialize callback */
- script_cb->script = script;
- script_cb->function = (function) ? strdup (function) : NULL;
- script_cb->data = (data) ? strdup (data) : NULL;
-
- /* add callback to list */
- if (script->callbacks)
- script->callbacks->prev_callback = script_cb;
- script_cb->prev_callback = NULL;
- script_cb->next_callback = script->callbacks;
- script->callbacks = script_cb;
-
- return script_cb;
-}
-
-/*
- * Frees data of a script callback.
- */
-
-void
-plugin_script_callback_free_data (struct t_plugin_script_cb *script_callback)
-{
- if (script_callback->function)
- free (script_callback->function);
- if (script_callback->data)
- free (script_callback->data);
-}
-
-/*
- * Removes a callback from a script.
- */
-
-void
-plugin_script_callback_remove (struct t_plugin_script *script,
- struct t_plugin_script_cb *script_callback)
-{
- /* remove callback from list */
- if (script_callback->prev_callback)
- (script_callback->prev_callback)->next_callback =
- script_callback->next_callback;
- if (script_callback->next_callback)
- (script_callback->next_callback)->prev_callback =
- script_callback->prev_callback;
- if (script->callbacks == script_callback)
- script->callbacks = script_callback->next_callback;
-
- plugin_script_callback_free_data (script_callback);
-
- free (script_callback);
-}
-
-/*
- * Removes all callbacks from a script.
- */
-
-void
-plugin_script_callback_remove_all (struct t_plugin_script *script)
-{
- while (script->callbacks)
- {
- plugin_script_callback_remove (script, script->callbacks);
- }
-}
-
-/*
- * Gets hdata for script callback.
- */
-
-struct t_hdata *
-plugin_script_callback_hdata_callback_cb (void *data,
- const char *hdata_name)
-{
- struct t_weechat_plugin *weechat_plugin;
- struct t_hdata *hdata;
- char str_hdata_script[128];
-
- weechat_plugin = (struct t_weechat_plugin *)data;
-
- hdata = weechat_hdata_new (hdata_name, "prev_callback", "next_callback",
- 0, 0, NULL, NULL);
- if (hdata)
- {
- snprintf (str_hdata_script, sizeof (str_hdata_script),
- "%s_script", weechat_plugin->name);
- WEECHAT_HDATA_VAR(struct t_plugin_script_cb, script, POINTER, 0, NULL, str_hdata_script);
- WEECHAT_HDATA_VAR(struct t_plugin_script_cb, function, STRING, 0, NULL, NULL);
- WEECHAT_HDATA_VAR(struct t_plugin_script_cb, data, STRING, 0, NULL, NULL);
- WEECHAT_HDATA_VAR(struct t_plugin_script_cb, config_file, POINTER, 0, NULL, "config_file");
- WEECHAT_HDATA_VAR(struct t_plugin_script_cb, config_section, POINTER, 0, NULL, "config_section");
- WEECHAT_HDATA_VAR(struct t_plugin_script_cb, config_option, POINTER, 0, NULL, "config_option");
- WEECHAT_HDATA_VAR(struct t_plugin_script_cb, hook, POINTER, 0, NULL, NULL);
- WEECHAT_HDATA_VAR(struct t_plugin_script_cb, buffer, POINTER, 0, NULL, "buffer");
- WEECHAT_HDATA_VAR(struct t_plugin_script_cb, bar_item, POINTER, 0, NULL, "bar_item");
- WEECHAT_HDATA_VAR(struct t_plugin_script_cb, upgrade_file, POINTER, 0, NULL, NULL);
- WEECHAT_HDATA_VAR(struct t_plugin_script_cb, prev_callback, POINTER, 0, NULL, hdata_name);
- WEECHAT_HDATA_VAR(struct t_plugin_script_cb, next_callback, POINTER, 0, NULL, hdata_name);
- }
- return hdata;
-}
-
-/*
- * Prints callbacks in WeeChat log file (usually for crash dump).
- */
-
-void
-plugin_script_callback_print_log (struct t_weechat_plugin *weechat_plugin,
- struct t_plugin_script_cb *script_callback)
-{
- weechat_log_printf ("");
- weechat_log_printf (" [callback (addr:0x%lx)]", script_callback);
- weechat_log_printf (" script. . . . . . . : 0x%lx", script_callback->script);
- weechat_log_printf (" function. . . . . . : '%s'", script_callback->function);
- weechat_log_printf (" data. . . . . . . . : '%s'", script_callback->data);
- weechat_log_printf (" config_file . . . . : 0x%lx", script_callback->config_file);
- weechat_log_printf (" config_section. . . : 0x%lx", script_callback->config_section);
- weechat_log_printf (" config_option . . . : 0x%lx", script_callback->config_option);
- weechat_log_printf (" hook. . . . . . . . : 0x%lx", script_callback->hook);
- weechat_log_printf (" buffer. . . . . . . : 0x%lx", script_callback->buffer);
- weechat_log_printf (" bar_item. . . . . . : 0x%lx", script_callback->bar_item);
- weechat_log_printf (" upgrade_file. . . . : 0x%lx", script_callback->upgrade_file);
- weechat_log_printf (" prev_callback . . . : 0x%lx", script_callback->prev_callback);
- weechat_log_printf (" next_callback . . . : 0x%lx", script_callback->next_callback);
-}
diff --git a/src/plugins/plugin-script-callback.h b/src/plugins/plugin-script-callback.h
deleted file mode 100644
index e1b72fd2e..000000000
--- a/src/plugins/plugin-script-callback.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
- *
- * This file is part of WeeChat, the extensible chat client.
- *
- * WeeChat 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.
- *
- * WeeChat 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 WeeChat. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef WEECHAT_PLUGIN_SCRIPT_CALLBACK_H
-#define WEECHAT_PLUGIN_SCRIPT_CALLBACK_H 1
-
-struct t_plugin_script_cb
-{
- void *script; /* pointer to script */
- char *function; /* script function called */
- char *data; /* data string for callback */
- struct t_config_file *config_file; /* not NULL for config file */
- struct t_config_section *config_section; /* not NULL for config section */
- struct t_config_option *config_option; /* not NULL for config option */
- struct t_hook *hook; /* not NULL for hook */
- struct t_gui_buffer *buffer; /* not NULL for buffer */
- struct t_gui_bar_item *bar_item; /* not NULL for bar item */
- struct t_upgrade_file *upgrade_file; /* not NULL for upgrade file */
- struct t_plugin_script_cb *prev_callback; /* link to next callback */
- struct t_plugin_script_cb *next_callback; /* link to previous callback */
-};
-
-extern struct t_plugin_script_cb *plugin_script_callback_add (struct t_plugin_script *script,
- const char *function,
- const char *data);
-extern void plugin_script_callback_remove (struct t_plugin_script *script,
- struct t_plugin_script_cb *script_callback);
-extern void plugin_script_callback_remove_all (struct t_plugin_script *script);
-extern struct t_hdata *plugin_script_callback_hdata_callback_cb (void *data,
- const char *hdata_name);
-extern void plugin_script_callback_print_log (struct t_weechat_plugin *weechat_plugin,
- struct t_plugin_script_cb *script_callback);
-
-#endif /* WEECHAT_PLUGIN_SCRIPT_CALLBACK_H */
diff --git a/src/plugins/plugin-script.c b/src/plugins/plugin-script.c
index ffb003a84..4a2bc98d3 100644
--- a/src/plugins/plugin-script.c
+++ b/src/plugins/plugin-script.c
@@ -1,7 +1,7 @@
/*
* plugin-script.c - common functions used by script plugins
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -33,7 +33,6 @@
#include "weechat-plugin.h"
#include "plugin-script.h"
-#include "plugin-script-callback.h"
#define SCRIPT_OPTION_CHECK_LICENSE "check_license"
@@ -67,13 +66,19 @@ plugin_script_config_read (struct t_weechat_plugin *weechat_plugin)
*/
int
-plugin_script_config_cb (void *data, const char *option, const char *value)
+plugin_script_config_cb (const void *pointer, void *data,
+ const char *option, const char *value)
{
+ struct t_weechat_plugin *plugin;
+
/* make C compiler happy */
+ (void) data;
(void) option;
(void) value;
- plugin_script_config_read (data);
+ plugin = (struct t_weechat_plugin *)pointer;
+
+ plugin_script_config_read (plugin);
return WEECHAT_RC_OK;
}
@@ -130,7 +135,8 @@ plugin_script_init (struct t_weechat_plugin *weechat_plugin,
{
snprintf (string, length, "plugins.var.%s.%s",
weechat_plugin->name, SCRIPT_OPTION_CHECK_LICENSE);
- weechat_hook_config (string, &plugin_script_config_cb, weechat_plugin);
+ weechat_hook_config (string,
+ &plugin_script_config_cb, weechat_plugin, NULL);
free (string);
}
@@ -175,7 +181,7 @@ plugin_script_init (struct t_weechat_plugin *weechat_plugin,
"\n"
"Without argument, this command lists all loaded scripts."),
completion,
- init->callback_command, NULL);
+ init->callback_command, NULL, NULL);
if (string)
free (string);
if (completion)
@@ -188,29 +194,24 @@ plugin_script_init (struct t_weechat_plugin *weechat_plugin,
{
snprintf (string, length, "%s_script", weechat_plugin->name);
weechat_hook_completion (string, N_("list of scripts"),
- init->callback_completion, NULL);
+ init->callback_completion, NULL, NULL);
weechat_hook_hdata (string, N_("list of scripts"),
- init->callback_hdata, weechat_plugin);
+ init->callback_hdata, weechat_plugin, NULL);
weechat_hook_infolist (string, N_("list of scripts"),
N_("script pointer (optional)"),
- N_("script name (wildcard \"*\" is allowed) (optional)"),
- init->callback_infolist, NULL);
- snprintf (string, length, "%s_callback", weechat_plugin->name);
- weechat_hook_hdata (string, N_("callback of a script"),
- &plugin_script_callback_hdata_callback_cb,
- weechat_plugin);
+ N_("script name (wildcard \"*\" is allowed) "
+ "(optional)"),
+ init->callback_infolist, NULL, NULL);
free (string);
}
/* add signal for "debug_dump" */
- weechat_hook_signal ("debug_dump", init->callback_signal_debug_dump, NULL);
+ weechat_hook_signal ("debug_dump",
+ init->callback_signal_debug_dump, NULL, NULL);
/* add signal for "debug_libs" */
- weechat_hook_signal ("debug_libs", init->callback_signal_debug_libs, NULL);
-
- /* add signal for "buffer_closed" */
- weechat_hook_signal ("buffer_closed",
- init->callback_signal_buffer_closed, NULL);
+ weechat_hook_signal ("debug_libs",
+ init->callback_signal_debug_libs, NULL, NULL);
/* add signals for script actions (install/remove/autoload) */
for (i = 0; action_signals[i]; i++)
@@ -219,7 +220,7 @@ plugin_script_init (struct t_weechat_plugin *weechat_plugin,
weechat_plugin->name,
action_signals[i]);
weechat_hook_signal (signal_name,
- init->callback_signal_script_action, NULL);
+ init->callback_signal_script_action, NULL, NULL);
}
/* parse arguments */
@@ -334,12 +335,74 @@ invalid:
}
/*
+ * Builds concatenated function name and data (both are strings).
+ * The result will be sent to callbacks.
+ */
+
+char *
+plugin_script_build_function_and_data (const char *function, const char *data)
+{
+ int length_function, length_data, length;
+ char *result;
+
+ if (!function || !function[0])
+ return NULL;
+
+ length_function = (function) ? strlen (function) : 0;
+ length_data = (data) ? strlen (data) : 0;
+ length = length_function + 1 + length_data + 1;
+
+ result = malloc (length);
+ if (!result)
+ return NULL;
+
+ if (function)
+ memcpy (result, function, length_function + 1);
+ else
+ result[0] = '\0';
+
+ if (data)
+ memcpy (result + length_function + 1, data, length_data + 1);
+ else
+ result[length_function + 1] = '\0';
+
+ return result;
+}
+
+/*
+ * Gets pointer on function name and data from a callback data pointer
+ * (which contains 2 strings separated by '\0').
+ */
+
+void
+plugin_script_get_function_and_data (void *callback_data,
+ const char **function, const char **data)
+{
+ const char *string, *ptr_data;
+
+ string = (const char *)callback_data;
+
+ if (string)
+ {
+ *function = string;
+ ptr_data = string + strlen (string) + 1;
+ *data = (ptr_data[0]) ? ptr_data : NULL;
+ }
+ else
+ {
+ *function = NULL;
+ *data = NULL;
+ }
+}
+
+/*
* Auto-loads all scripts in a directory.
*/
void
plugin_script_auto_load (struct t_weechat_plugin *weechat_plugin,
- void (*callback)(void *data, const char *filename))
+ void (*callback)(void *data,
+ const char *filename))
{
const char *dir_home;
char *dir_name;
@@ -356,7 +419,7 @@ plugin_script_auto_load (struct t_weechat_plugin *weechat_plugin,
snprintf (dir_name, dir_length,
"%s/%s/autoload", dir_home, weechat_plugin->name);
- weechat_exec_on_files (dir_name, 0, NULL, callback);
+ weechat_exec_on_files (dir_name, 0, callback, NULL);
free (dir_name);
}
@@ -605,7 +668,6 @@ plugin_script_add (struct t_weechat_plugin *weechat_plugin,
new_script->shutdown_func = (shutdown_func) ?
strdup (shutdown_func) : NULL;
new_script->charset = (charset) ? strdup (charset) : NULL;
- new_script->callbacks = NULL;
new_script->unloading = 0;
plugin_script_insert_sorted (weechat_plugin, scripts, last_script,
@@ -630,19 +692,21 @@ void
plugin_script_set_buffer_callbacks (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *scripts,
struct t_plugin_script *script,
- int (*callback_buffer_input) (void *data,
+ int (*callback_buffer_input) (const void *pointer,
+ void *data,
struct t_gui_buffer *buffer,
const char *input_data),
- int (*callback_buffer_close) (void *data,
+ int (*callback_buffer_close) (const void *pointer,
+ void *data,
struct t_gui_buffer *buffer))
{
struct t_infolist *infolist;
struct t_gui_buffer *ptr_buffer;
- const char *script_name, *str_script_input_cb, *str_script_input_cb_data;
+ const char *script_name;
+ const char *str_script_input_cb, *str_script_input_cb_data;
const char *str_script_close_cb, *str_script_close_cb_data;
+ char *function_and_data;
struct t_plugin_script *ptr_script;
- struct t_plugin_script_cb *script_cb_input;
- struct t_plugin_script_cb *script_cb_close;
infolist = weechat_infolist_get ("buffer", NULL, NULL);
if (infolist)
@@ -659,46 +723,49 @@ plugin_script_set_buffer_callbacks (struct t_weechat_plugin *weechat_plugin,
script_name);
if (ptr_script && (ptr_script == script))
{
- str_script_input_cb = weechat_buffer_get_string (ptr_buffer,
- "localvar_script_input_cb");
- str_script_input_cb_data = weechat_buffer_get_string (ptr_buffer,
- "localvar_script_input_cb_data");
- str_script_close_cb = weechat_buffer_get_string (ptr_buffer,
- "localvar_script_close_cb");
- str_script_close_cb_data = weechat_buffer_get_string (ptr_buffer,
- "localvar_script_close_cb_data");
-
- if (str_script_input_cb && str_script_input_cb[0])
+ str_script_input_cb = weechat_buffer_get_string (
+ ptr_buffer, "localvar_script_input_cb");
+ str_script_input_cb_data = weechat_buffer_get_string (
+ ptr_buffer, "localvar_script_input_cb_data");
+ str_script_close_cb = weechat_buffer_get_string (
+ ptr_buffer, "localvar_script_close_cb");
+ str_script_close_cb_data = weechat_buffer_get_string (
+ ptr_buffer, "localvar_script_close_cb_data");
+
+ function_and_data = plugin_script_build_function_and_data (
+ str_script_input_cb, str_script_input_cb_data);
+ if (function_and_data)
{
- script_cb_input = plugin_script_callback_add (ptr_script,
- str_script_input_cb,
- str_script_input_cb_data);
- if (script_cb_input)
- {
- script_cb_input->buffer = ptr_buffer;
- weechat_buffer_set_pointer (ptr_buffer,
- "input_callback",
- callback_buffer_input);
- weechat_buffer_set_pointer (ptr_buffer,
- "input_callback_data",
- script_cb_input);
- }
+ weechat_buffer_set_pointer (
+ ptr_buffer,
+ "input_callback",
+ callback_buffer_input);
+ weechat_buffer_set_pointer (
+ ptr_buffer,
+ "input_callback_pointer",
+ ptr_script);
+ weechat_buffer_set_pointer (
+ ptr_buffer,
+ "input_callback_data",
+ function_and_data);
}
- if (str_script_close_cb && str_script_close_cb[0])
+
+ function_and_data = plugin_script_build_function_and_data (
+ str_script_close_cb, str_script_close_cb_data);
+ if (function_and_data)
{
- script_cb_close = plugin_script_callback_add (ptr_script,
- str_script_close_cb,
- str_script_close_cb_data);
- if (script_cb_close)
- {
- script_cb_close->buffer = ptr_buffer;
- weechat_buffer_set_pointer (ptr_buffer,
- "close_callback",
- callback_buffer_close);
- weechat_buffer_set_pointer (ptr_buffer,
- "close_callback_data",
- script_cb_close);
- }
+ weechat_buffer_set_pointer (
+ ptr_buffer,
+ "close_callback",
+ callback_buffer_close);
+ weechat_buffer_set_pointer (
+ ptr_buffer,
+ "close_callback_pointer",
+ ptr_script);
+ weechat_buffer_set_pointer (
+ ptr_buffer,
+ "close_callback_data",
+ function_and_data);
}
}
}
@@ -709,36 +776,136 @@ plugin_script_set_buffer_callbacks (struct t_weechat_plugin *weechat_plugin,
}
/*
- * Removes callbacks for a buffer (called when a buffer is closed by user).
+ * Closes all buffers created by the script.
*/
void
-plugin_script_remove_buffer_callbacks (struct t_plugin_script *scripts,
- struct t_gui_buffer *buffer)
+plugin_script_close_buffers (struct t_weechat_plugin *weechat_plugin,
+ struct t_plugin_script *script)
{
- struct t_plugin_script *ptr_script;
- struct t_plugin_script_cb *ptr_script_cb, *next_script_cb;
+ struct t_hdata *hdata;
+ struct t_gui_buffer *ptr_buffer, *ptr_buffer_to_close;
+ const char *ptr_script_name;
- for (ptr_script = scripts; ptr_script;
- ptr_script = ptr_script->next_script)
+ hdata = weechat_hdata_get ("buffer");
+ while (1)
{
- /*
- * do not remove buffer callbacks if script is being unloaded
- * (because all callbacks will be removed anyway)
- */
- if (!ptr_script->unloading)
+ ptr_buffer = weechat_hdata_get_list (hdata, "gui_buffers");
+ ptr_buffer_to_close = NULL;
+ while (ptr_buffer)
{
- ptr_script_cb = ptr_script->callbacks;
- while (ptr_script_cb)
+ ptr_script_name = weechat_buffer_get_string (
+ ptr_buffer, "localvar_script_name");
+ if (ptr_script_name
+ && (strcmp (ptr_script_name, script->name) == 0))
{
- next_script_cb = ptr_script_cb->next_callback;
+ ptr_buffer_to_close = ptr_buffer;
+ break;
+ }
+ ptr_buffer = weechat_hdata_move (hdata, ptr_buffer, 1);
+ }
+ if (ptr_buffer_to_close)
+ {
+ weechat_buffer_close (ptr_buffer_to_close);
+ }
+ else
+ break;
+ }
+}
- if (ptr_script_cb->buffer == buffer)
- plugin_script_callback_remove (ptr_script, ptr_script_cb);
+/*
+ * Removes all bar items created by the script.
+ */
+
+void
+plugin_script_remove_bar_items (struct t_weechat_plugin *weechat_plugin,
+ struct t_plugin_script *script)
+{
+ struct t_hdata *hdata;
+ struct t_gui_bar_item *ptr_bar_item, *ptr_next_item;
+ void *callback_pointer;
- ptr_script_cb = next_script_cb;
+ hdata = weechat_hdata_get ("bar_item");
+ ptr_bar_item = weechat_hdata_get_list (hdata, "gui_bar_items");
+ while (ptr_bar_item)
+ {
+ ptr_next_item = weechat_hdata_pointer (hdata, ptr_bar_item,
+ "next_item");
+ callback_pointer = weechat_hdata_pointer (hdata, ptr_bar_item,
+ "build_callback_pointer");
+ if (callback_pointer == script)
+ weechat_bar_item_remove (ptr_bar_item);
+ ptr_bar_item = ptr_next_item;
+ }
+}
+
+/*
+ * Removes all configuration files/sections/options created by the script.
+ */
+
+void
+plugin_script_remove_configs (struct t_weechat_plugin *weechat_plugin,
+ struct t_plugin_script *script)
+{
+ struct t_hdata *hdata_config, *hdata_section, *hdata_option;
+ struct t_config_file *ptr_config, *ptr_next_config;
+ struct t_config_section *ptr_section, *ptr_next_section;
+ struct t_config_option *ptr_option, *ptr_next_option;
+ void *callback_pointer;
+
+ hdata_config = weechat_hdata_get ("config_file");
+ hdata_section = weechat_hdata_get ("config_section");
+ hdata_option = weechat_hdata_get ("config_option");
+ ptr_config = weechat_hdata_get_list (hdata_config, "config_files");
+ while (ptr_config)
+ {
+ ptr_next_config = weechat_hdata_pointer (hdata_config, ptr_config,
+ "next_config");
+ callback_pointer = weechat_hdata_pointer (
+ hdata_config, ptr_config, "callback_reload_pointer");
+ if (callback_pointer == script)
+ {
+ if (weechat_config_boolean (weechat_config_get ("weechat.plugin.save_config_on_unload")))
+ weechat_config_write (ptr_config);
+ weechat_config_free (ptr_config);
+ }
+ else
+ {
+ ptr_section = weechat_hdata_pointer (hdata_config, ptr_config,
+ "sections");
+ while (ptr_section)
+ {
+ ptr_next_section = weechat_hdata_pointer (hdata_section,
+ ptr_section,
+ "next_section");
+ callback_pointer = weechat_hdata_pointer (
+ hdata_section, ptr_section, "callback_read_pointer");
+ if (callback_pointer == script)
+ {
+ weechat_config_section_free (ptr_section);
+ }
+ else
+ {
+ ptr_option = weechat_hdata_pointer (hdata_section,
+ ptr_section,
+ "options");
+ while (ptr_option)
+ {
+ ptr_next_option = weechat_hdata_pointer (hdata_option,
+ ptr_option,
+ "next_option");
+ callback_pointer = weechat_hdata_pointer (
+ hdata_option, ptr_option,
+ "callback_check_value_pointer");
+ if (callback_pointer == script)
+ weechat_config_option_free (ptr_option);
+ ptr_option = ptr_next_option;
+ }
+ }
+ ptr_section = ptr_next_section;
}
}
+ ptr_config = ptr_next_config;
}
}
@@ -752,59 +919,16 @@ plugin_script_remove (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script **last_script,
struct t_plugin_script *script)
{
- struct t_plugin_script_cb *ptr_script_cb, *ptr_script_cb2;
-
script->unloading = 1;
- for (ptr_script_cb = script->callbacks; ptr_script_cb;
- ptr_script_cb = ptr_script_cb->next_callback)
- {
- /* free configuration file */
- if (ptr_script_cb->config_file)
- {
- if (weechat_config_boolean (weechat_config_get ("weechat.plugin.save_config_on_unload")))
- weechat_config_write (ptr_script_cb->config_file);
- weechat_config_free (ptr_script_cb->config_file);
- }
-
- /* unhook */
- if (ptr_script_cb->hook)
- weechat_unhook (ptr_script_cb->hook);
+ plugin_script_close_buffers (weechat_plugin, script);
- /* close buffer */
- if (ptr_script_cb->buffer)
- weechat_buffer_close (ptr_script_cb->buffer);
+ plugin_script_remove_bar_items (weechat_plugin, script);
- /* remove bar item */
- if (ptr_script_cb->bar_item)
- weechat_bar_item_remove (ptr_script_cb->bar_item);
-
- /*
- * remove same pointers in other callbacks
- * (to not free 2 times with same pointer!)
- */
- for (ptr_script_cb2 = ptr_script_cb->next_callback; ptr_script_cb2;
- ptr_script_cb2 = ptr_script_cb2->next_callback)
- {
- if (ptr_script_cb2->config_file == ptr_script_cb->config_file)
- ptr_script_cb2->config_file = NULL;
- if (ptr_script_cb2->config_section == ptr_script_cb->config_section)
- ptr_script_cb2->config_section = NULL;
- if (ptr_script_cb2->config_option == ptr_script_cb->config_option)
- ptr_script_cb2->config_option = NULL;
- if (ptr_script_cb2->hook == ptr_script_cb->hook)
- ptr_script_cb2->hook = NULL;
- if (ptr_script_cb2->buffer == ptr_script_cb->buffer)
- ptr_script_cb2->buffer = NULL;
- if (ptr_script_cb2->bar_item == ptr_script_cb->bar_item)
- ptr_script_cb2->bar_item = NULL;
- if (ptr_script_cb2->upgrade_file == ptr_script_cb->upgrade_file)
- ptr_script_cb2->upgrade_file = NULL;
- }
- }
+ plugin_script_remove_configs (weechat_plugin, script);
- /* remove all callbacks created by this script */
- plugin_script_callback_remove_all (script);
+ /* remove all hooks created by this script */
+ weechat_unhook_all (script->name);
/* free data */
if (script->filename)
@@ -1385,7 +1509,6 @@ plugin_script_hdata_script (struct t_weechat_plugin *weechat_plugin,
WEECHAT_HDATA_VAR(struct t_plugin_script, description, STRING, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_plugin_script, shutdown_func, STRING, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_plugin_script, charset, STRING, 0, NULL, NULL);
- WEECHAT_HDATA_VAR(struct t_plugin_script, callbacks, POINTER, 0, NULL, str_hdata_callback);
WEECHAT_HDATA_VAR(struct t_plugin_script, unloading, INTEGER, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_plugin_script, prev_script, POINTER, 0, NULL, hdata_name);
WEECHAT_HDATA_VAR(struct t_plugin_script, next_script, POINTER, 0, NULL, hdata_name);
@@ -1529,7 +1652,6 @@ plugin_script_print_log (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *scripts)
{
struct t_plugin_script *ptr_script;
- struct t_plugin_script_cb *ptr_script_cb;
weechat_log_printf ("");
weechat_log_printf ("***** \"%s\" plugin dump *****",
@@ -1549,16 +1671,9 @@ plugin_script_print_log (struct t_weechat_plugin *weechat_plugin,
weechat_log_printf (" description . . . . : '%s'", ptr_script->description);
weechat_log_printf (" shutdown_func . . . : '%s'", ptr_script->shutdown_func);
weechat_log_printf (" charset . . . . . . : '%s'", ptr_script->charset);
- weechat_log_printf (" callbacks . . . . . : 0x%lx", ptr_script->callbacks);
weechat_log_printf (" unloading . . . . . : %d", ptr_script->unloading);
weechat_log_printf (" prev_script . . . . : 0x%lx", ptr_script->prev_script);
weechat_log_printf (" next_script . . . . : 0x%lx", ptr_script->next_script);
-
- for (ptr_script_cb = ptr_script->callbacks; ptr_script_cb;
- ptr_script_cb = ptr_script_cb->next_callback)
- {
- plugin_script_callback_print_log (weechat_plugin, ptr_script_cb);
- }
}
weechat_log_printf ("");
diff --git a/src/plugins/plugin-script.h b/src/plugins/plugin-script.h
index 3f60191ae..11a93001d 100644
--- a/src/plugins/plugin-script.h
+++ b/src/plugins/plugin-script.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -61,7 +61,6 @@ struct t_plugin_script
char *description; /* plugin description */
char *shutdown_func; /* function when script is unloaded*/
char *charset; /* script charset */
- struct t_plugin_script_cb *callbacks; /* callbacks for script */
int unloading; /* script is being unloaded */
struct t_plugin_script *prev_script; /* link to previous script */
struct t_plugin_script *next_script; /* link to next script */
@@ -69,27 +68,31 @@ struct t_plugin_script
struct t_plugin_script_init
{
- int (*callback_command)(void *data, struct t_gui_buffer *buffer,
+ int (*callback_command)(const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol);
- int (*callback_completion)(void *data, const char *completion_item,
+ int (*callback_completion)(const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion);
- struct t_hdata *(*callback_hdata)(void *data,
+ struct t_hdata *(*callback_hdata)(const void *pointer,
+ void *data,
const char *hdata_name);
- struct t_infolist *(*callback_infolist)(void *data,
+ struct t_infolist *(*callback_infolist)(const void *pointer,
+ void *data,
const char *infolist_name,
- void *pointer,
+ void *obj_pointer,
const char *arguments);
- int (*callback_signal_debug_dump)(void *data, const char *signal,
+ int (*callback_signal_debug_dump)(const void *pointer, void *data,
+ const char *signal,
const char *type_data,
void *signal_data);
- int (*callback_signal_debug_libs)(void *data, const char *signal,
+ int (*callback_signal_debug_libs)(const void *pointer, void *data,
+ const char *signal,
const char *type_data,
void *signal_data);
- int (*callback_signal_buffer_closed)(void *data, const char *signal,
- const char *type_data,
- void *signal_data);
- int (*callback_signal_script_action)(void *data, const char *signal,
+ int (*callback_signal_script_action)(const void *pointer, void *data,
+ const char *signal,
const char *type_data,
void *signal_data);
void (*callback_load_file)(void *data, const char *filename);
@@ -105,8 +108,14 @@ extern void *plugin_script_str2ptr (struct t_weechat_plugin *weechat_plugin,
const char *script_name,
const char *function_name,
const char *pointer_str);
+extern char *plugin_script_build_function_and_data (const char *function,
+ const char *data);
+extern void plugin_script_get_function_and_data (void *callback_data,
+ const char **function,
+ const char **data);
extern void plugin_script_auto_load (struct t_weechat_plugin *weechat_plugin,
- void (*callback)(void *data, const char *filename));
+ void (*callback)(void *data,
+ const char *filename));
extern struct t_plugin_script *plugin_script_search (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *scripts,
const char *name);
@@ -122,13 +131,13 @@ extern struct t_plugin_script *plugin_script_add (struct t_weechat_plugin *weech
extern void plugin_script_set_buffer_callbacks (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *scripts,
struct t_plugin_script *script,
- int (*callback_buffer_input) (void *data,
+ int (*callback_buffer_input) (const void *pointer,
+ void *data,
struct t_gui_buffer *buffer,
const char *input_data),
- int (*callback_buffer_close) (void *data,
+ int (*callback_buffer_close) (const void *pointer,
+ void *data,
struct t_gui_buffer *buffer));
-extern void plugin_script_remove_buffer_callbacks (struct t_plugin_script *scripts,
- struct t_gui_buffer *buffer);
extern void plugin_script_remove (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script **scripts,
struct t_plugin_script **last_script,
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index 7bd76dc5b..7a51698d2 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -1,7 +1,7 @@
/*
* plugin.c - WeeChat plugins management (load/unload dynamic C libraries)
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -634,6 +634,7 @@ plugin_load (const char *filename, int init_plugin, int argc, char **argv)
new_plugin->string_remove_color = &gui_color_decode;
new_plugin->string_encode_base64 = &string_encode_base64;
new_plugin->string_decode_base64 = &string_decode_base64;
+ new_plugin->string_hex_dump = &string_hex_dump;
new_plugin->string_is_command_char = &string_is_command_char;
new_plugin->string_input_for_buffer = &string_input_for_buffer;
new_plugin->string_eval_expression = &eval_expression;
@@ -938,11 +939,11 @@ plugin_load (const char *filename, int init_plugin, int argc, char **argv)
*/
void
-plugin_auto_load_file (void *args, const char *filename)
+plugin_auto_load_file (void *data, const char *filename)
{
struct t_plugin_args *plugin_args;
- plugin_args = (struct t_plugin_args *)args;
+ plugin_args = (struct t_plugin_args *)data;
if (plugin_check_extension_allowed (filename))
plugin_load (filename, 0, plugin_args->argc, plugin_args->argv);
@@ -953,7 +954,8 @@ plugin_auto_load_file (void *args, const char *filename)
*/
int
-plugin_arraylist_cmp_cb (void *data, struct t_arraylist *arraylist,
+plugin_arraylist_cmp_cb (void *data,
+ struct t_arraylist *arraylist,
void *pointer1, void *pointer2)
{
struct t_weechat_plugin *plugin1, *plugin2;
@@ -1008,8 +1010,7 @@ plugin_auto_load (int argc, char **argv)
plugin_path2 : ((plugin_path) ?
plugin_path : CONFIG_STRING(config_plugin_path)),
0,
- &plugin_args,
- &plugin_auto_load_file);
+ &plugin_auto_load_file, &plugin_args);
if (plugin_path)
free (plugin_path);
if (plugin_path2)
@@ -1022,7 +1023,8 @@ plugin_auto_load (int argc, char **argv)
if (dir_name)
{
snprintf (dir_name, length, "%s/plugins", WEECHAT_LIBDIR);
- util_exec_on_files (dir_name, 0, &plugin_args, &plugin_auto_load_file);
+ util_exec_on_files (dir_name, 0,
+ &plugin_auto_load_file, &plugin_args);
free (dir_name);
}
@@ -1105,7 +1107,7 @@ plugin_remove (struct t_weechat_plugin *plugin)
config_file_free_all_plugin (plugin);
/* remove all hooks */
- unhook_all_plugin (plugin);
+ unhook_all_plugin (plugin, NULL);
/* remove all infolists */
infolist_free_all_plugin (plugin);
@@ -1341,11 +1343,13 @@ plugin_end ()
*/
struct t_hdata *
-plugin_hdata_plugin_cb (void *data, const char *hdata_name)
+plugin_hdata_plugin_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_plugin", "next_plugin",
diff --git a/src/plugins/plugin.h b/src/plugins/plugin.h
index 08028f95a..51ad43516 100644
--- a/src/plugins/plugin.h
+++ b/src/plugins/plugin.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -46,7 +46,8 @@ extern void plugin_unload_all ();
extern void plugin_reload_name (const char *name, int argc, char **argv);
extern void plugin_init (int auto_load, int argc, char *argv[]);
extern void plugin_end ();
-extern struct t_hdata *plugin_hdata_plugin_cb (void *data,
+extern struct t_hdata *plugin_hdata_plugin_cb (const void *pointer,
+ void *data,
const char *hdata_name);
extern int plugin_add_to_infolist (struct t_infolist *infolist,
struct t_weechat_plugin *plugin);
diff --git a/src/plugins/python/CMakeLists.txt b/src/plugins/python/CMakeLists.txt
index 2684b889f..6fccb0ab2 100644
--- a/src/plugins/python/CMakeLists.txt
+++ b/src/plugins/python/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/python/Makefile.am b/src/plugins/python/Makefile.am
index 43de0e137..b95ec6913 100644
--- a/src/plugins/python/Makefile.am
+++ b/src/plugins/python/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c
index 1eca2723a..23acaba0b 100644
--- a/src/plugins/python/weechat-python-api.c
+++ b/src/plugins/python/weechat-python-api.c
@@ -1,7 +1,7 @@
/*
* weechat-python-api.c - python API functions
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2005-2007 Emmanuel Bouthenot <kolter@openics.org>
* Copyright (C) 2012 Simon Arlott
*
@@ -29,7 +29,6 @@
#include "../weechat-plugin.h"
#include "../plugin-script.h"
#include "../plugin-script-api.h"
-#include "../plugin-script-callback.h"
#include "weechat-python.h"
@@ -749,24 +748,26 @@ API_FUNC(list_free)
}
int
-weechat_python_api_config_reload_cb (void *data,
+weechat_python_api_config_reload_cb (const void *pointer, void *data,
struct t_config_file *config_file)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
- rc = (int *) weechat_python_exec (script_callback->script,
+ rc = (int *) weechat_python_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (!rc)
@@ -808,29 +809,31 @@ API_FUNC(config_new)
}
int
-weechat_python_api_config_read_cb (void *data,
+weechat_python_api_config_read_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name, const char *value)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[5];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = API_PTR2STR(section);
func_argv[3] = (option_name) ? (char *)option_name : empty_arg;
func_argv[4] = (value) ? (char *)value : empty_arg;
- rc = (int *) weechat_python_exec (script_callback->script,
+ rc = (int *) weechat_python_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sssss", func_argv);
if (!rc)
@@ -852,26 +855,28 @@ weechat_python_api_config_read_cb (void *data,
}
int
-weechat_python_api_config_section_write_cb (void *data,
+weechat_python_api_config_section_write_cb (const void *pointer, void *data,
struct t_config_file *config_file,
const char *section_name)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = (section_name) ? (char *)section_name : empty_arg;
- rc = (int *) weechat_python_exec (script_callback->script,
+ rc = (int *) weechat_python_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -891,26 +896,28 @@ weechat_python_api_config_section_write_cb (void *data,
}
int
-weechat_python_api_config_section_write_default_cb (void *data,
+weechat_python_api_config_section_write_default_cb (const void *pointer, void *data,
struct t_config_file *config_file,
const char *section_name)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = (section_name) ? (char *)section_name : empty_arg;
- rc = (int *) weechat_python_exec (script_callback->script,
+ rc = (int *) weechat_python_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -930,30 +937,32 @@ weechat_python_api_config_section_write_default_cb (void *data,
}
int
-weechat_python_api_config_section_create_option_cb (void *data,
+weechat_python_api_config_section_create_option_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
const char *value)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[5];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = API_PTR2STR(section);
func_argv[3] = (option_name) ? (char *)option_name : empty_arg;
func_argv[4] = (value) ? (char *)value : empty_arg;
- rc = (int *) weechat_python_exec (script_callback->script,
+ rc = (int *) weechat_python_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sssss", func_argv);
if (!rc)
@@ -975,28 +984,30 @@ weechat_python_api_config_section_create_option_cb (void *data,
}
int
-weechat_python_api_config_section_delete_option_cb (void *data,
+weechat_python_api_config_section_delete_option_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
struct t_config_option *option)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = API_PTR2STR(section);
func_argv[3] = API_PTR2STR(option);
- rc = (int *) weechat_python_exec (script_callback->script,
+ rc = (int *) weechat_python_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssss", func_argv);
if (!rc)
@@ -1052,27 +1063,29 @@ API_FUNC(config_new_section)
&data_delete_option))
API_WRONG_ARGS(API_RETURN_EMPTY);
- result = API_PTR2STR(plugin_script_api_config_new_section (weechat_python_plugin,
- python_current_script,
- API_STR2PTR(config_file),
- name,
- user_can_add_options,
- user_can_delete_options,
- &weechat_python_api_config_read_cb,
- function_read,
- data_read,
- &weechat_python_api_config_section_write_cb,
- function_write,
- data_write,
- &weechat_python_api_config_section_write_default_cb,
- function_write_default,
- data_write_default,
- &weechat_python_api_config_section_create_option_cb,
- function_create_option,
- data_create_option,
- &weechat_python_api_config_section_delete_option_cb,
- function_delete_option,
- data_delete_option));
+ result = API_PTR2STR(
+ plugin_script_api_config_new_section (
+ weechat_python_plugin,
+ python_current_script,
+ API_STR2PTR(config_file),
+ name,
+ user_can_add_options,
+ user_can_delete_options,
+ &weechat_python_api_config_read_cb,
+ function_read,
+ data_read,
+ &weechat_python_api_config_section_write_cb,
+ function_write,
+ data_write,
+ &weechat_python_api_config_section_write_default_cb,
+ function_write_default,
+ data_write_default,
+ &weechat_python_api_config_section_create_option_cb,
+ function_create_option,
+ data_create_option,
+ &weechat_python_api_config_section_delete_option_cb,
+ function_delete_option,
+ data_delete_option));
API_RETURN_STRING_FREE(result);
}
@@ -1095,26 +1108,29 @@ API_FUNC(config_search_section)
}
int
-weechat_python_api_config_option_check_value_cb (void *data,
+weechat_python_api_config_option_check_value_cb (const void *pointer,
+ void *data,
struct t_config_option *option,
const char *value)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(option);
func_argv[2] = (value) ? (char *)value : empty_arg;
- rc = (int *) weechat_python_exec (script_callback->script,
+ rc = (int *) weechat_python_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -1134,24 +1150,26 @@ weechat_python_api_config_option_check_value_cb (void *data,
}
void
-weechat_python_api_config_option_change_cb (void *data,
+weechat_python_api_config_option_change_cb (const void *pointer, void *data,
struct t_config_option *option)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(option);
- rc = (int *) weechat_python_exec (script_callback->script,
+ rc = (int *) weechat_python_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (func_argv[1])
@@ -1163,24 +1181,26 @@ weechat_python_api_config_option_change_cb (void *data,
}
void
-weechat_python_api_config_option_delete_cb (void *data,
+weechat_python_api_config_option_delete_cb (const void *pointer, void *data,
struct t_config_option *option)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(option);
- rc = (int *) weechat_python_exec (script_callback->script,
+ rc = (int *) weechat_python_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (func_argv[1])
@@ -1606,9 +1626,7 @@ API_FUNC(config_option_free)
if (!PyArg_ParseTuple (args, "s", &option))
API_WRONG_ARGS(API_RETURN_ERROR);
- plugin_script_api_config_option_free (weechat_python_plugin,
- python_current_script,
- API_STR2PTR(option));
+ weechat_config_option_free (API_STR2PTR(option));
API_RETURN_OK;
}
@@ -1622,9 +1640,7 @@ API_FUNC(config_section_free_options)
if (!PyArg_ParseTuple (args, "s", &section))
API_WRONG_ARGS(API_RETURN_ERROR);
- plugin_script_api_config_section_free_options (weechat_python_plugin,
- python_current_script,
- API_STR2PTR(section));
+ weechat_config_section_free_options (API_STR2PTR(section));
API_RETURN_OK;
}
@@ -1638,9 +1654,7 @@ API_FUNC(config_section_free)
if (!PyArg_ParseTuple (args, "s", &section))
API_WRONG_ARGS(API_RETURN_ERROR);
- plugin_script_api_config_section_free (weechat_python_plugin,
- python_current_script,
- API_STR2PTR(section));
+ weechat_config_section_free (API_STR2PTR(section));
API_RETURN_OK;
}
@@ -1654,9 +1668,7 @@ API_FUNC(config_free)
if (!PyArg_ParseTuple (args, "s", &config_file))
API_WRONG_ARGS(API_RETURN_ERROR);
- plugin_script_api_config_free (weechat_python_plugin,
- python_current_script,
- API_STR2PTR(config_file));
+ weechat_config_free (API_STR2PTR(config_file));
API_RETURN_OK;
}
@@ -1915,28 +1927,31 @@ API_FUNC(log_print)
}
int
-weechat_python_api_hook_command_cb (void *data, struct t_gui_buffer *buffer,
+weechat_python_api_hook_command_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
/* make C compiler happy */
(void) argv;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
func_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg;
- rc = (int *) weechat_python_exec (script_callback->script,
+ rc = (int *) weechat_python_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -1988,25 +2003,28 @@ API_FUNC(hook_command)
}
int
-weechat_python_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
+weechat_python_api_hook_command_run_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
const char *command)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
func_argv[2] = (command) ? (char *)command : empty_arg;
- rc = (int *) weechat_python_exec (script_callback->script,
+ rc = (int *) weechat_python_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -2048,26 +2066,29 @@ API_FUNC(hook_command_run)
}
int
-weechat_python_api_hook_timer_cb (void *data, int remaining_calls)
+weechat_python_api_hook_timer_cb (const void *pointer, void *data,
+ int remaining_calls)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char str_remaining_calls[32], empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (str_remaining_calls, sizeof (str_remaining_calls),
"%d", remaining_calls);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = str_remaining_calls;
- rc = (int *) weechat_python_exec (script_callback->script,
+ rc = (int *) weechat_python_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (!rc)
@@ -2113,25 +2134,27 @@ API_FUNC(hook_timer)
}
int
-weechat_python_api_hook_fd_cb (void *data, int fd)
+weechat_python_api_hook_fd_cb (const void *pointer, void *data, int fd)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char str_fd[32], empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (str_fd, sizeof (str_fd), "%d", fd);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = str_fd;
- rc = (int *) weechat_python_exec (script_callback->script,
+ rc = (int *) weechat_python_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (!rc)
@@ -2179,28 +2202,49 @@ API_FUNC(hook_fd)
}
int
-weechat_python_api_hook_process_cb (void *data,
+weechat_python_api_hook_process_cb (const void *pointer, void *data,
const char *command, int return_code,
const char *out, const char *err)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[5];
- char empty_arg[1] = { '\0' };
+ char empty_arg[1] = { '\0' }, *result;
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (return_code == WEECHAT_HOOK_PROCESS_CHILD)
+ {
+ if (strncmp (command, "func:", 5) == 0)
+ {
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
+
+ result = (char *) weechat_python_exec (script,
+ WEECHAT_SCRIPT_EXEC_STRING,
+ command + 5,
+ "s", func_argv);
+ if (result)
+ {
+ printf ("%s", result);
+ free (result);
+ return 0;
+ }
+ }
+ return 1;
+ }
+ else if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (command) ? (char *)command : empty_arg;
func_argv[2] = PyLong_FromLong((long)return_code);
func_argv[3] = (out) ? (char *)out : empty_arg;
func_argv[4] = (err) ? (char *)err : empty_arg;
- rc = (int *) weechat_python_exec (script_callback->script,
+ rc = (int *) weechat_python_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssOss", func_argv);
if (!rc)
@@ -2284,33 +2328,36 @@ API_FUNC(hook_process_hashtable)
}
int
-weechat_python_api_hook_connect_cb (void *data, int status, int gnutls_rc,
+weechat_python_api_hook_connect_cb (const void *pointer, void *data,
+ int status, int gnutls_rc,
int sock, const char *error,
const char *ip_address)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[6];
char str_status[32], str_gnutls_rc[32], str_sock[32], empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (str_status, sizeof (str_status), "%d", status);
snprintf (str_gnutls_rc, sizeof (str_gnutls_rc), "%d", gnutls_rc);
snprintf (str_sock, sizeof (str_sock), "%d", sock);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = str_status;
func_argv[2] = str_gnutls_rc;
func_argv[3] = str_sock;
func_argv[4] = (ip_address) ? (char *)ip_address : empty_arg;
func_argv[5] = (error) ? (char *)error : empty_arg;
- rc = (int *) weechat_python_exec (script_callback->script,
+ rc = (int *) weechat_python_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssssss", func_argv);
if (!rc)
@@ -2366,28 +2413,31 @@ API_FUNC(hook_connect)
}
int
-weechat_python_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
+weechat_python_api_hook_print_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
time_t date,
int tags_count, const char **tags,
int displayed, int highlight,
const char *prefix, const char *message)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[8];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
static char timebuffer[64];
int *rc, ret;
/* make C compiler happy */
(void) tags_count;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (timebuffer, sizeof (timebuffer), "%ld", (long int)date);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
func_argv[2] = timebuffer;
func_argv[3] = weechat_string_build_with_split_string (tags, ",");
@@ -2398,9 +2448,9 @@ weechat_python_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
func_argv[6] = (prefix) ? (char *)prefix : empty_arg;
func_argv[7] = (message) ? (char *)message : empty_arg;
- rc = (int *) weechat_python_exec (script_callback->script,
+ rc = (int *) weechat_python_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssssOOss", func_argv);
if (!rc)
@@ -2460,20 +2510,23 @@ API_FUNC(hook_print)
}
int
-weechat_python_api_hook_signal_cb (void *data, const char *signal, const char *type_data,
+weechat_python_api_hook_signal_cb (const void *pointer, void *data,
+ const char *signal, const char *type_data,
void *signal_data)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
static char str_value[64];
int *rc, ret, free_needed;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (signal) ? (char *)signal : empty_arg;
free_needed = 0;
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
@@ -2498,9 +2551,9 @@ weechat_python_api_hook_signal_cb (void *data, const char *signal, const char *t
else
func_argv[2] = empty_arg;
- rc = (int *) weechat_python_exec (script_callback->script,
+ rc = (int *) weechat_python_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -2579,25 +2632,28 @@ API_FUNC(hook_signal_send)
}
int
-weechat_python_api_hook_hsignal_cb (void *data, const char *signal,
+weechat_python_api_hook_hsignal_cb (const void *pointer, void *data,
+ const char *signal,
struct t_hashtable *hashtable)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (signal) ? (char *)signal : empty_arg;
func_argv[2] = weechat_python_hashtable_to_dict (hashtable);
- rc = (int *) weechat_python_exec (script_callback->script,
+ rc = (int *) weechat_python_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssO", func_argv);
if (!rc)
@@ -2667,24 +2723,27 @@ API_FUNC(hook_hsignal_send)
}
int
-weechat_python_api_hook_config_cb (void *data, const char *option, const char *value)
+weechat_python_api_hook_config_cb (const void *pointer, void *data,
+ const char *option, const char *value)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (option) ? (char *)option : empty_arg;
func_argv[2] = (value) ? (char *)value : empty_arg;
- rc = (int *) weechat_python_exec (script_callback->script,
+ rc = (int *) weechat_python_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -2724,27 +2783,30 @@ API_FUNC(hook_config)
}
int
-weechat_python_api_hook_completion_cb (void *data, const char *completion_item,
+weechat_python_api_hook_completion_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (completion_item) ? (char *)completion_item : empty_arg;
func_argv[2] = API_PTR2STR(buffer);
func_argv[3] = API_PTR2STR(completion);
- rc = (int *) weechat_python_exec (script_callback->script,
+ rc = (int *) weechat_python_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssss", func_argv);
if (!rc)
@@ -2830,25 +2892,29 @@ API_FUNC(hook_completion_list_add)
}
char *
-weechat_python_api_hook_modifier_cb (void *data, const char *modifier,
- const char *modifier_data, const char *string)
+weechat_python_api_hook_modifier_cb (const void *pointer, void *data,
+ const char *modifier,
+ const char *modifier_data,
+ const char *string)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (modifier) ? (char *)modifier : empty_arg;
func_argv[2] = (modifier_data) ? (char *)modifier_data : empty_arg;
func_argv[3] = (string) ? (char *)string : empty_arg;
- return (char *)weechat_python_exec (script_callback->script,
+ return (char *)weechat_python_exec (script,
WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function,
+ ptr_function,
"ssss", func_argv);
}
@@ -2895,24 +2961,27 @@ API_FUNC(hook_modifier_exec)
}
const char *
-weechat_python_api_hook_info_cb (void *data, const char *info_name,
+weechat_python_api_hook_info_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (info_name) ? (char *)info_name : empty_arg;
func_argv[2] = (arguments) ? (char *)arguments : empty_arg;
- return (const char *)weechat_python_exec (script_callback->script,
+ return (const char *)weechat_python_exec (script,
WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
}
@@ -2947,25 +3016,28 @@ API_FUNC(hook_info)
}
struct t_hashtable *
-weechat_python_api_hook_info_hashtable_cb (void *data, const char *info_name,
+weechat_python_api_hook_info_hashtable_cb (const void *pointer, void *data,
+ const char *info_name,
struct t_hashtable *hashtable)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
struct t_hashtable *ret_hashtable;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (info_name) ? (char *)info_name : empty_arg;
func_argv[2] = weechat_python_hashtable_to_dict (hashtable);
- ret_hashtable = weechat_python_exec (script_callback->script,
+ ret_hashtable = weechat_python_exec (script,
WEECHAT_SCRIPT_EXEC_HASHTABLE,
- script_callback->function,
+ ptr_function,
"ssO", func_argv);
if (func_argv[2])
@@ -3011,27 +3083,31 @@ API_FUNC(hook_info_hashtable)
}
struct t_infolist *
-weechat_python_api_hook_infolist_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+weechat_python_api_hook_infolist_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
struct t_infolist *result;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (infolist_name) ? (char *)infolist_name : empty_arg;
- func_argv[2] = API_PTR2STR(pointer);
+ func_argv[2] = API_PTR2STR(obj_pointer);
func_argv[3] = (arguments) ? (char *)arguments : empty_arg;
- result = (struct t_infolist *)weechat_python_exec (script_callback->script,
- WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function,
- "ssss", func_argv);
+ result = (struct t_infolist *)weechat_python_exec (
+ script,
+ WEECHAT_SCRIPT_EXEC_STRING,
+ ptr_function,
+ "ssss", func_argv);
if (func_argv[2])
free (func_argv[2]);
@@ -3074,24 +3150,26 @@ API_FUNC(hook_infolist)
}
struct t_hashtable *
-weechat_python_api_hook_focus_cb (void *data,
+weechat_python_api_hook_focus_cb (const void *pointer, void *data,
struct t_hashtable *info)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
struct t_hashtable *ret_hashtable;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = weechat_python_hashtable_to_dict (info);
- ret_hashtable = weechat_python_exec (script_callback->script,
+ ret_hashtable = weechat_python_exec (script,
WEECHAT_SCRIPT_EXEC_HASHTABLE,
- script_callback->function,
+ ptr_function,
"sO", func_argv);
if (func_argv[1])
{
@@ -3153,9 +3231,7 @@ API_FUNC(unhook)
if (!PyArg_ParseTuple (args, "s", &hook))
API_WRONG_ARGS(API_RETURN_ERROR);
- plugin_script_api_unhook (weechat_python_plugin,
- python_current_script,
- API_STR2PTR(hook));
+ weechat_unhook (API_STR2PTR(hook));
API_RETURN_OK;
}
@@ -3167,31 +3243,34 @@ API_FUNC(unhook_all)
API_INIT_FUNC(1, "unhook_all", API_RETURN_ERROR);
- plugin_script_api_unhook_all (weechat_python_plugin, python_current_script);
+ weechat_unhook_all (python_current_script->name);
API_RETURN_OK;
}
int
-weechat_python_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
+weechat_python_api_buffer_input_data_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
const char *input_data)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
func_argv[2] = (input_data) ? (char *)input_data : empty_arg;
- rc = (int *) weechat_python_exec (script_callback->script,
+ rc = (int *) weechat_python_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@@ -3210,23 +3289,26 @@ weechat_python_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer
}
int
-weechat_python_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
+weechat_python_api_buffer_close_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
- rc = (int *) weechat_python_exec (script_callback->script,
+ rc = (int *) weechat_python_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@@ -3343,9 +3425,7 @@ API_FUNC(buffer_close)
if (!PyArg_ParseTuple (args, "s", &buffer))
API_WRONG_ARGS(API_RETURN_ERROR);
- plugin_script_api_buffer_close (weechat_python_plugin,
- python_current_script,
- API_STR2PTR(buffer));
+ weechat_buffer_close (API_STR2PTR(buffer));
API_RETURN_OK;
}
@@ -3882,31 +3962,34 @@ API_FUNC(bar_item_search)
}
char *
-weechat_python_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
+weechat_python_api_bar_item_build_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
struct t_gui_window *window,
struct t_gui_buffer *buffer,
struct t_hashtable *extra_info)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[5];
char empty_arg[1] = { '\0' }, *ret;
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- if (strncmp (script_callback->function, "(extra)", 7) == 0)
+ if (strncmp (ptr_function, "(extra)", 7) == 0)
{
/* new callback: data, item, window, buffer, extra_info */
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(item);
func_argv[2] = API_PTR2STR(window);
func_argv[3] = API_PTR2STR(buffer);
func_argv[4] = weechat_python_hashtable_to_dict (extra_info);
- ret = (char *)weechat_python_exec (script_callback->script,
+ ret = (char *)weechat_python_exec (script,
WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function + 7,
+ ptr_function + 7,
"ssssO", func_argv);
if (func_argv[1])
@@ -3923,13 +4006,13 @@ weechat_python_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
else
{
/* old callback: data, item, window */
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(item);
func_argv[2] = API_PTR2STR(window);
- ret = (char *)weechat_python_exec (script_callback->script,
+ ret = (char *)weechat_python_exec (script,
WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (func_argv[1])
@@ -3989,9 +4072,7 @@ API_FUNC(bar_item_remove)
if (!PyArg_ParseTuple (args, "s", &item))
API_WRONG_ARGS(API_RETURN_ERROR);
- plugin_script_api_bar_item_remove (weechat_python_plugin,
- python_current_script,
- API_STR2PTR(item));
+ weechat_bar_item_remove (API_STR2PTR(item));
API_RETURN_OK;
}
@@ -4814,67 +4895,33 @@ API_FUNC(hdata_get_string)
API_RETURN_STRING(result);
}
-API_FUNC(upgrade_new)
-{
- char *filename, *result;
- int write;
- PyObject *return_value;
-
- API_INIT_FUNC(1, "upgrade_new", API_RETURN_EMPTY);
- filename = NULL;
- write = 0;
- if (!PyArg_ParseTuple (args, "si", &filename, &write))
- API_WRONG_ARGS(API_RETURN_EMPTY);
-
- result = API_PTR2STR(weechat_upgrade_new (filename, write));
-
- API_RETURN_STRING_FREE(result);
-}
-
-API_FUNC(upgrade_write_object)
-{
- char *upgrade_file, *infolist;
- int object_id, rc;
-
- API_INIT_FUNC(1, "upgrade_write_object", API_RETURN_INT(0));
- upgrade_file = NULL;
- object_id = 0;
- infolist = NULL;
- if (!PyArg_ParseTuple (args, "sis", &upgrade_file, &object_id, &infolist))
- API_WRONG_ARGS(API_RETURN_INT(0));
-
- rc = weechat_upgrade_write_object (API_STR2PTR(upgrade_file),
- object_id,
- API_STR2PTR(infolist));
-
- API_RETURN_INT(rc);
-}
-
int
-weechat_python_api_upgrade_read_cb (void *data,
+weechat_python_api_upgrade_read_cb (const void *pointer, void *data,
struct t_upgrade_file *upgrade_file,
int object_id,
struct t_infolist *infolist)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' }, str_object_id[32];
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (str_object_id, sizeof (str_object_id), "%d", object_id);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(upgrade_file);
func_argv[2] = str_object_id;
func_argv[3] = API_PTR2STR(infolist);
- rc = (int *) weechat_python_exec (script_callback->script,
+ rc = (int *) weechat_python_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssss", func_argv);
if (!rc)
@@ -4895,24 +4942,60 @@ weechat_python_api_upgrade_read_cb (void *data,
return WEECHAT_RC_ERROR;
}
+API_FUNC(upgrade_new)
+{
+ char *filename, *function, *data, *result;
+ PyObject *return_value;
+
+ API_INIT_FUNC(1, "upgrade_new", API_RETURN_EMPTY);
+ filename = NULL;
+ function = NULL;
+ data = NULL;
+ if (!PyArg_ParseTuple (args, "sss", &filename, &function, &data))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = API_PTR2STR(
+ plugin_script_api_upgrade_new (
+ weechat_python_plugin,
+ python_current_script,
+ filename,
+ &weechat_python_api_upgrade_read_cb,
+ function,
+ data));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+API_FUNC(upgrade_write_object)
+{
+ char *upgrade_file, *infolist;
+ int object_id, rc;
+
+ API_INIT_FUNC(1, "upgrade_write_object", API_RETURN_INT(0));
+ upgrade_file = NULL;
+ object_id = 0;
+ infolist = NULL;
+ if (!PyArg_ParseTuple (args, "sis", &upgrade_file, &object_id, &infolist))
+ API_WRONG_ARGS(API_RETURN_INT(0));
+
+ rc = weechat_upgrade_write_object (API_STR2PTR(upgrade_file),
+ object_id,
+ API_STR2PTR(infolist));
+
+ API_RETURN_INT(rc);
+}
+
API_FUNC(upgrade_read)
{
- char *upgrade_file, *function, *data;
+ char *upgrade_file;
int rc;
API_INIT_FUNC(1, "upgrade_read", API_RETURN_INT(0));
upgrade_file = NULL;
- function = NULL;
- data = NULL;
- if (!PyArg_ParseTuple (args, "sss", &upgrade_file, &function, &data))
+ if (!PyArg_ParseTuple (args, "s", &upgrade_file))
API_WRONG_ARGS(API_RETURN_INT(0));
- rc = plugin_script_api_upgrade_read (weechat_python_plugin,
- python_current_script,
- API_STR2PTR(upgrade_file),
- &weechat_python_api_upgrade_read_cb,
- function,
- data);
+ rc = weechat_upgrade_read (API_STR2PTR(upgrade_file));
API_RETURN_INT(rc);
}
diff --git a/src/plugins/python/weechat-python-api.h b/src/plugins/python/weechat-python-api.h
index 058d28f75..131a4661c 100644
--- a/src/plugins/python/weechat-python-api.h
+++ b/src/plugins/python/weechat-python-api.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2005-2007 Emmanuel Bouthenot <kolter@openics.org>
*
* This file is part of WeeChat, the extensible chat client.
@@ -23,10 +23,12 @@
extern PyMethodDef weechat_python_funcs[];
-extern int weechat_python_api_buffer_input_data_cb (void *data,
+extern int weechat_python_api_buffer_input_data_cb (const void *pointer,
+ void *data,
struct t_gui_buffer *buffer,
const char *input_data);
-extern int weechat_python_api_buffer_close_cb (void *data,
+extern int weechat_python_api_buffer_close_cb (const void *pointer,
+ void *data,
struct t_gui_buffer *buffer);
#endif /* WEECHAT_PYTHON_API_H */
diff --git a/src/plugins/python/weechat-python.c b/src/plugins/python/weechat-python.c
index eb382d0d2..5981df271 100644
--- a/src/plugins/python/weechat-python.c
+++ b/src/plugins/python/weechat-python.c
@@ -1,7 +1,7 @@
/*
* weechat-python.c - python plugin for WeeChat
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2005-2007 Emmanuel Bouthenot <kolter@openics.org>
* Copyright (C) 2012 Simon Arlott
*
@@ -232,8 +232,7 @@ weechat_python_hashtable_to_dict (struct t_hashtable *hashtable)
return Py_None;
}
- weechat_hashtable_map_string (hashtable,
- &weechat_python_hashtable_map_cb,
+ weechat_hashtable_map_string (hashtable, &weechat_python_hashtable_map_cb,
dict);
return dict;
@@ -927,12 +926,14 @@ weechat_python_reload_name (const char *name)
*/
int
-weechat_python_command_cb (void *data, struct t_gui_buffer *buffer,
+weechat_python_command_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
char *ptr_name, *path_script;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
@@ -1028,11 +1029,13 @@ weechat_python_command_cb (void *data, struct t_gui_buffer *buffer,
*/
int
-weechat_python_completion_cb (void *data, const char *completion_item,
+weechat_python_completion_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -1047,13 +1050,15 @@ weechat_python_completion_cb (void *data, const char *completion_item,
*/
const char *
-weechat_python_info_cb (void *data, const char *info_name,
+weechat_python_info_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
int rc;
struct stat stat_buf;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) arguments;
@@ -1079,9 +1084,11 @@ weechat_python_info_cb (void *data, const char *info_name,
*/
struct t_hdata *
-weechat_python_hdata_cb (void *data, const char *hdata_name)
+weechat_python_hdata_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
return plugin_script_hdata_script (weechat_plugin,
@@ -1094,10 +1101,12 @@ weechat_python_hdata_cb (void *data, const char *hdata_name)
*/
struct t_infolist *
-weechat_python_infolist_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+weechat_python_infolist_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (!infolist_name || !infolist_name[0])
@@ -1106,7 +1115,8 @@ weechat_python_infolist_cb (void *data, const char *infolist_name,
if (weechat_strcasecmp (infolist_name, "python_script") == 0)
{
return plugin_script_infolist_list_scripts (weechat_python_plugin,
- python_scripts, pointer,
+ python_scripts,
+ obj_pointer,
arguments);
}
@@ -1118,10 +1128,12 @@ weechat_python_infolist_cb (void *data, const char *infolist_name,
*/
int
-weechat_python_signal_debug_dump_cb (void *data, const char *signal,
+weechat_python_signal_debug_dump_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -1140,10 +1152,12 @@ weechat_python_signal_debug_dump_cb (void *data, const char *signal,
*/
int
-weechat_python_signal_debug_libs_cb (void *data, const char *signal,
+weechat_python_signal_debug_libs_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -1159,38 +1173,20 @@ weechat_python_signal_debug_libs_cb (void *data, const char *signal,
}
/*
- * Callback called when a buffer is closed.
- */
-
-int
-weechat_python_signal_buffer_closed_cb (void *data, const char *signal,
- const char *type_data,
- void *signal_data)
-{
- /* make C compiler happy */
- (void) data;
- (void) signal;
- (void) type_data;
-
- if (signal_data)
- plugin_script_remove_buffer_callbacks (python_scripts, signal_data);
-
- return WEECHAT_RC_OK;
-}
-
-/*
* Timer for executing actions.
*/
int
-weechat_python_timer_action_cb (void *data, int remaining_calls)
+weechat_python_timer_action_cb (const void *pointer, void *data,
+ int remaining_calls)
{
/* make C compiler happy */
+ (void) data;
(void) remaining_calls;
- if (data)
+ if (pointer)
{
- if (data == &python_action_install_list)
+ if (pointer == &python_action_install_list)
{
plugin_script_action_install (weechat_python_plugin,
python_scripts,
@@ -1199,7 +1195,7 @@ weechat_python_timer_action_cb (void *data, int remaining_calls)
&python_quiet,
&python_action_install_list);
}
- else if (data == &python_action_remove_list)
+ else if (pointer == &python_action_remove_list)
{
plugin_script_action_remove (weechat_python_plugin,
python_scripts,
@@ -1207,7 +1203,7 @@ weechat_python_timer_action_cb (void *data, int remaining_calls)
&python_quiet,
&python_action_remove_list);
}
- else if (data == &python_action_autoload_list)
+ else if (pointer == &python_action_autoload_list)
{
plugin_script_action_autoload (weechat_python_plugin,
&python_quiet,
@@ -1224,11 +1220,13 @@ weechat_python_timer_action_cb (void *data, int remaining_calls)
*/
int
-weechat_python_signal_script_action_cb (void *data, const char *signal,
+weechat_python_signal_script_action_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data,
void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
@@ -1239,7 +1237,7 @@ weechat_python_signal_script_action_cb (void *data, const char *signal,
(const char *)signal_data);
weechat_hook_timer (1, 0, 1,
&weechat_python_timer_action_cb,
- &python_action_install_list);
+ &python_action_install_list, NULL);
}
else if (strcmp (signal, "python_script_remove") == 0)
{
@@ -1247,7 +1245,7 @@ weechat_python_signal_script_action_cb (void *data, const char *signal,
(const char *)signal_data);
weechat_hook_timer (1, 0, 1,
&weechat_python_timer_action_cb,
- &python_action_remove_list);
+ &python_action_remove_list, NULL);
}
else if (strcmp (signal, "python_script_autoload") == 0)
{
@@ -1255,7 +1253,7 @@ weechat_python_signal_script_action_cb (void *data, const char *signal,
(const char *)signal_data);
weechat_hook_timer (1, 0, 1,
&weechat_python_timer_action_cb,
- &python_action_autoload_list);
+ &python_action_autoload_list, NULL);
}
}
@@ -1281,7 +1279,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
weechat_hook_info ("python2_bin",
N_("path to python 2.x interpreter"),
NULL,
- &weechat_python_info_cb, NULL);
+ &weechat_python_info_cb, NULL, NULL);
/* init stdout/stderr buffer */
python_buffer_output[0] = '\0';
@@ -1319,7 +1317,6 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
init.callback_infolist = &weechat_python_infolist_cb;
init.callback_signal_debug_dump = &weechat_python_signal_debug_dump_cb;
init.callback_signal_debug_libs = &weechat_python_signal_debug_libs_cb;
- init.callback_signal_buffer_closed = &weechat_python_signal_buffer_closed_cb;
init.callback_signal_script_action = &weechat_python_signal_script_action_cb;
init.callback_load_file = &weechat_python_load_cb;
diff --git a/src/plugins/python/weechat-python.h b/src/plugins/python/weechat-python.h
index 3a4375428..11920c187 100644
--- a/src/plugins/python/weechat-python.h
+++ b/src/plugins/python/weechat-python.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2005-2007 Emmanuel Bouthenot <kolter@openics.org>
*
* This file is part of WeeChat, the extensible chat client.
diff --git a/src/plugins/relay/CMakeLists.txt b/src/plugins/relay/CMakeLists.txt
index e3a0a6f33..4dc1bb2e7 100644
--- a/src/plugins/relay/CMakeLists.txt
+++ b/src/plugins/relay/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/relay/Makefile.am b/src/plugins/relay/Makefile.am
index b27e27690..96c33157c 100644
--- a/src/plugins/relay/Makefile.am
+++ b/src/plugins/relay/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/relay/irc/relay-irc.c b/src/plugins/relay/irc/relay-irc.c
index 3facb21e0..502a7b6b9 100644
--- a/src/plugins/relay/irc/relay-irc.c
+++ b/src/plugins/relay/irc/relay-irc.c
@@ -1,7 +1,7 @@
/*
* relay-irc.c - IRC protocol for relay to client: IRC proxy/bouncer
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -158,8 +158,7 @@ relay_irc_message_parse (const char *message)
hash_msg = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
if (!hash_msg)
{
weechat_printf (NULL,
@@ -214,8 +213,7 @@ relay_irc_sendf (struct t_relay_client *client, const char *format, ...)
hashtable_in = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
if (hashtable_in)
{
weechat_hashtable_set (hashtable_in, "server", client->protocol_args);
@@ -236,7 +234,8 @@ relay_irc_sendf (struct t_relay_client *client, const char *format, ...)
if (message)
{
snprintf (message, length, "%s\r\n", str_message);
- relay_client_send (client, message, strlen (message), NULL);
+ relay_client_send (client, RELAY_CLIENT_MSG_STANDARD,
+ message, strlen (message), NULL);
free (message);
}
number++;
@@ -257,7 +256,8 @@ relay_irc_sendf (struct t_relay_client *client, const char *format, ...)
*/
int
-relay_irc_signal_irc_in2_cb (void *data, const char *signal,
+relay_irc_signal_irc_in2_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
struct t_relay_client *client;
@@ -265,10 +265,11 @@ relay_irc_signal_irc_in2_cb (void *data, const char *signal,
struct t_hashtable *hash_parsed;
/* make C compiler happy */
+ (void) data;
(void) signal;
(void) type_data;
- client = (struct t_relay_client *)data;
+ client = (struct t_relay_client *)pointer;
ptr_msg = (const char *)signal_data;
if (weechat_relay_plugin->debug >= 2)
@@ -367,7 +368,8 @@ relay_irc_tag_relay_client_id (const char *tags)
*/
int
-relay_irc_signal_irc_outtags_cb (void *data, const char *signal,
+relay_irc_signal_irc_outtags_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data,
void *signal_data)
{
@@ -379,10 +381,11 @@ relay_irc_signal_irc_outtags_cb (void *data, const char *signal,
char str_infolist_args[256];
/* make C compiler happy */
+ (void) data;
(void) signal;
(void) type_data;
- client = (struct t_relay_client *)data;
+ client = (struct t_relay_client *)pointer;
tags = NULL;
@@ -482,17 +485,19 @@ end:
*/
int
-relay_irc_signal_irc_disc_cb (void *data, const char *signal,
+relay_irc_signal_irc_disc_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
struct t_relay_client *client;
/* make C compiler happy */
+ (void) data;
(void) signal;
(void) type_data;
(void) signal_data;
- client = (struct t_relay_client *)data;
+ client = (struct t_relay_client *)pointer;
if (weechat_relay_plugin->debug >= 2)
{
@@ -515,7 +520,8 @@ relay_irc_signal_irc_disc_cb (void *data, const char *signal,
*/
int
-relay_irc_hsignal_irc_redir_cb (void *data, const char *signal,
+relay_irc_hsignal_irc_redir_cb (const void *pointer, void *data,
+ const char *signal,
struct t_hashtable *hashtable)
{
struct t_relay_client *client;
@@ -523,7 +529,10 @@ relay_irc_hsignal_irc_redir_cb (void *data, const char *signal,
char pattern[128], **messages;
const char *output;
- client = (struct t_relay_client *)data;
+ /* make C compiler happy */
+ (void) data;
+
+ client = (struct t_relay_client *)pointer;
if (weechat_relay_plugin->debug >= 2)
{
@@ -754,7 +763,7 @@ relay_irc_send_channel_backlog (struct t_relay_client *client,
void *ptr_own_lines, *ptr_line, *ptr_line_data;
void *ptr_hdata_line, *ptr_hdata_line_data;
char *tags, *message;
- const char *ptr_nick, *ptr_nick1, *ptr_nick2, *ptr_host;
+ const char *ptr_nick, *ptr_nick1, *ptr_nick2, *ptr_host, *localvar_nick;
int irc_command, irc_action, count, max_number, max_minutes;
time_t date_min, date_min2, date;
@@ -780,6 +789,10 @@ relay_irc_send_channel_backlog (struct t_relay_client *client,
if (!ptr_hdata_line_data)
return;
+ localvar_nick = NULL;
+ if (weechat_config_boolean (relay_config_irc_backlog_since_last_message))
+ localvar_nick = weechat_buffer_get_string (buffer, "localvar_nick");
+
max_number = weechat_config_integer (relay_config_irc_backlog_max_number);
max_minutes = weechat_config_integer (relay_config_irc_backlog_max_minutes);
date_min = (max_minutes > 0) ? time (NULL) - (max_minutes * 60) : 0;
@@ -810,7 +823,7 @@ relay_irc_send_channel_backlog (struct t_relay_client *client,
&irc_command,
NULL, /* irc_action */
&date,
- NULL, /* nick */
+ &ptr_nick,
NULL, /* nick1 */
NULL, /* nick2 */
NULL, /* host */
@@ -826,6 +839,17 @@ relay_irc_send_channel_backlog (struct t_relay_client *client,
/* if we have reached max number of messages, exit loop */
if ((max_number > 0) && (count > max_number))
break;
+
+ if (localvar_nick && localvar_nick[0]
+ && ptr_nick && (strcmp (ptr_nick, localvar_nick) == 0))
+ {
+ /*
+ * stop when we find a line sent by the current nick
+ * (and include this line)
+ */
+ ptr_line = weechat_hdata_move (ptr_hdata_line, ptr_line, -1);
+ break;
+ }
}
ptr_line = weechat_hdata_move (ptr_hdata_line, ptr_line, -1);
}
@@ -1102,7 +1126,7 @@ relay_irc_send_join_channels (struct t_relay_client *client)
void
relay_irc_input_send (struct t_relay_client *client, const char *irc_channel,
- int flags, const char *format, ...)
+ char *options, const char *format, ...)
{
char buf_beginning[1024], *buf;
int length_beginning, length_vbuffer;
@@ -1112,10 +1136,10 @@ relay_irc_input_send (struct t_relay_client *client, const char *irc_channel,
return;
snprintf (buf_beginning, sizeof (buf_beginning),
- "%s;%s;%d;relay_client_%d;",
+ "%s;%s;%s;relay_client_%d;",
client->protocol_args,
(irc_channel) ? irc_channel : "",
- flags,
+ options,
client->id);
length_beginning = strlen (buf_beginning);
@@ -1163,7 +1187,7 @@ relay_irc_hook_signals (struct t_relay_client *client)
RELAY_IRC_DATA(client, hook_signal_irc_in2) =
weechat_hook_signal (str_signal_name,
&relay_irc_signal_irc_in2_cb,
- client);
+ client, NULL);
/*
* hook signal "xxx,irc_outtags_*" to catch IRC data sent to
@@ -1175,7 +1199,7 @@ relay_irc_hook_signals (struct t_relay_client *client)
RELAY_IRC_DATA(client, hook_signal_irc_outtags) =
weechat_hook_signal (str_signal_name,
&relay_irc_signal_irc_outtags_cb,
- client);
+ client, NULL);
/*
* hook signal "irc_server_disconnected" to disconnect client if
@@ -1184,7 +1208,7 @@ relay_irc_hook_signals (struct t_relay_client *client)
RELAY_IRC_DATA(client, hook_signal_irc_disc) =
weechat_hook_signal ("irc_server_disconnected",
&relay_irc_signal_irc_disc_cb,
- client);
+ client, NULL);
/*
* hook hsignal "irc_redirection_*" to redirect some messages
@@ -1192,7 +1216,7 @@ relay_irc_hook_signals (struct t_relay_client *client)
RELAY_IRC_DATA(client, hook_hsignal_irc_redir) =
weechat_hook_hsignal ("irc_redirection_relay_*",
&relay_irc_hsignal_irc_redir_cb,
- client);
+ client, NULL);
}
/*
@@ -1551,10 +1575,10 @@ relay_irc_recv (struct t_relay_client *client, const char *data)
}
if (irc_args2[0] == ':')
irc_args2++;
- relay_irc_input_send (client, NULL, 1,
+ relay_irc_input_send (client, NULL,
+ "priority_high",
"/notice %s %s",
- target,
- irc_args2);
+ target, irc_args2);
free (target);
}
}
@@ -1575,12 +1599,15 @@ relay_irc_recv (struct t_relay_client *client, const char *data)
irc_is_channel = weechat_info_get ("irc_is_channel", irc_channel);
if (irc_is_channel && (strcmp (irc_is_channel, "1") == 0))
{
- relay_irc_input_send (client, irc_channel, 1,
- "%s", irc_args2);
+ relay_irc_input_send (client, irc_channel,
+ "priority_high,user_message",
+ "%s",
+ irc_args2);
}
else
{
- relay_irc_input_send (client, NULL, 1,
+ relay_irc_input_send (client, NULL,
+ "priority_high",
"/query %s %s",
irc_channel, irc_args2);
}
@@ -1590,8 +1617,7 @@ relay_irc_recv (struct t_relay_client *client, const char *data)
hash_redirect = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
if (hash_redirect)
{
redirect_msg = 0;
@@ -1707,7 +1733,8 @@ relay_irc_recv (struct t_relay_client *client, const char *data)
weechat_hashtable_free (hash_redirect);
}
/* send the IRC message to server */
- relay_irc_input_send (client, NULL, 1,
+ relay_irc_input_send (client, NULL,
+ "priority_high",
"/quote %s",
data);
}
diff --git a/src/plugins/relay/irc/relay-irc.h b/src/plugins/relay/irc/relay-irc.h
index 90775a91d..fa2ea21ce 100644
--- a/src/plugins/relay/irc/relay-irc.h
+++ b/src/plugins/relay/irc/relay-irc.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/relay/relay-buffer.c b/src/plugins/relay/relay-buffer.c
index 4eb355ab6..fe7751c48 100644
--- a/src/plugins/relay/relay-buffer.c
+++ b/src/plugins/relay/relay-buffer.c
@@ -1,7 +1,7 @@
/*
* relay-buffer.c - display clients list on relay buffer
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -152,12 +152,14 @@ relay_buffer_refresh (const char *hotlist)
*/
int
-relay_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
+relay_buffer_input_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
const char *input_data)
{
struct t_relay_client *client, *ptr_client, *next_client;
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (buffer == relay_raw_buffer)
@@ -215,9 +217,11 @@ relay_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
*/
int
-relay_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
+relay_buffer_close_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (buffer == relay_raw_buffer)
@@ -242,8 +246,8 @@ relay_buffer_open ()
if (!relay_buffer)
{
relay_buffer = weechat_buffer_new (RELAY_BUFFER_NAME,
- &relay_buffer_input_cb, NULL,
- &relay_buffer_close_cb, NULL);
+ &relay_buffer_input_cb, NULL, NULL,
+ &relay_buffer_close_cb, NULL, NULL);
/* failed to create buffer ? then exit */
if (!relay_buffer)
diff --git a/src/plugins/relay/relay-buffer.h b/src/plugins/relay/relay-buffer.h
index 72a67d661..09f316a70 100644
--- a/src/plugins/relay/relay-buffer.h
+++ b/src/plugins/relay/relay-buffer.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -26,9 +26,11 @@ extern struct t_gui_buffer *relay_buffer;
extern int relay_buffer_selected_line;
extern void relay_buffer_refresh (const char *hotlist);
-extern int relay_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
- const char *input_data);
-extern int relay_buffer_close_cb (void *data, struct t_gui_buffer *buffer);
+extern int relay_buffer_input_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
+ const char *input_data);
+extern int relay_buffer_close_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer);
extern void relay_buffer_open ();
#endif /* WEECHAT_RELAY_BUFFER_H */
diff --git a/src/plugins/relay/relay-client.c b/src/plugins/relay/relay-client.c
index 4a6a2615b..52a7f4001 100644
--- a/src/plugins/relay/relay-client.c
+++ b/src/plugins/relay/relay-client.c
@@ -1,7 +1,7 @@
/*
* relay-client.c - client functions for relay plugin
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -58,6 +58,9 @@ char *relay_client_status_name[] = /* name of status (for signal/info) */
char *relay_client_data_type_string[] = /* strings for data types */
{ "text", "binary" };
+char *relay_client_msg_type_string[] = /* prefix in raw buffer for message */
+{ "", "[PING]\n", "[PONG]\n" };
+
struct t_relay_client *relay_clients = NULL;
struct t_relay_client *last_relay_client = NULL;
int relay_client_count = 0; /* number of clients */
@@ -159,6 +162,31 @@ relay_client_status_search (const char *name)
}
/*
+ * Returns the number of active clients (connecting or connected) on a given
+ * server port.
+ */
+
+int
+relay_client_count_active_by_port (int server_port)
+{
+ struct t_relay_client *ptr_client;
+ int count;
+
+ count = 0;
+ for (ptr_client = relay_clients; ptr_client;
+ ptr_client = ptr_client->next_client)
+ {
+ if ((ptr_client->server_port == server_port)
+ && !RELAY_CLIENT_HAS_ENDED(ptr_client))
+ {
+ count++;
+ }
+ }
+
+ return count;
+}
+
+/*
* Sends a signal with the status of client ("relay_client_xxx").
*/
@@ -203,12 +231,16 @@ relay_client_set_desc (struct t_relay_client *client)
#ifdef HAVE_GNUTLS
int
-relay_client_handshake_timer_cb (void *data, int remaining_calls)
+relay_client_handshake_timer_cb (const void *pointer, void *data,
+ int remaining_calls)
{
struct t_relay_client *client;
int rc;
- client = (struct t_relay_client *)data;
+ /* make C compiler happy */
+ (void) data;
+
+ client = (struct t_relay_client *)pointer;
rc = gnutls_handshake (client->gnutls_sess);
@@ -225,16 +257,16 @@ relay_client_handshake_timer_cb (void *data, int remaining_calls)
if (gnutls_error_is_fatal (rc))
{
/* handshake error, disconnect client */
- weechat_printf_tags (NULL, "relay_client",
- _("%s%s: TLS handshake failed for client %s%s%s: "
- "error %d %s"),
- weechat_prefix ("error"),
- RELAY_PLUGIN_NAME,
- RELAY_COLOR_CHAT_CLIENT,
- client->desc,
- RELAY_COLOR_CHAT,
- rc,
- gnutls_strerror (rc));
+ weechat_printf_date_tags (
+ NULL, 0, "relay_client",
+ _("%s%s: TLS handshake failed for client %s%s%s: error %d %s"),
+ weechat_prefix ("error"),
+ RELAY_PLUGIN_NAME,
+ RELAY_COLOR_CHAT_CLIENT,
+ client->desc,
+ RELAY_COLOR_CHAT,
+ rc,
+ gnutls_strerror (rc));
weechat_unhook (client->hook_timer_handshake);
client->hook_timer_handshake = NULL;
relay_client_set_status (client, RELAY_STATUS_DISCONNECTED);
@@ -244,13 +276,14 @@ relay_client_handshake_timer_cb (void *data, int remaining_calls)
if (remaining_calls == 0)
{
/* handshake timeout, disconnect client */
- weechat_printf_tags (NULL, "relay_client",
- _("%s%s: TLS handshake timeout for client %s%s%s"),
- weechat_prefix ("error"),
- RELAY_PLUGIN_NAME,
- RELAY_COLOR_CHAT_CLIENT,
- client->desc,
- RELAY_COLOR_CHAT);
+ weechat_printf_date_tags (
+ NULL, 0, "relay_client",
+ _("%s%s: TLS handshake timeout for client %s%s%s"),
+ weechat_prefix ("error"),
+ RELAY_PLUGIN_NAME,
+ RELAY_COLOR_CHAT_CLIENT,
+ client->desc,
+ RELAY_COLOR_CHAT);
weechat_unhook (client->hook_timer_handshake);
client->hook_timer_handshake = NULL;
relay_client_set_status (client, RELAY_STATUS_DISCONNECTED);
@@ -263,8 +296,8 @@ relay_client_handshake_timer_cb (void *data, int remaining_calls)
#endif /* HAVE_GNUTLS */
/*
- * Reads text data from a client: splits data on '\n' and keep a partial message
- * if date does not end with '\n'.
+ * Reads text data from a client: splits data on '\n' and keeps a partial
+ * message if data does not end with '\n'.
*/
void
@@ -295,7 +328,8 @@ relay_client_recv_text (struct t_relay_client *client, const char *data)
pos - client->partial_message + 1);
if (raw_msg)
{
- relay_raw_print (client, RELAY_RAW_FLAG_RECV,
+ relay_raw_print (client, RELAY_CLIENT_MSG_STANDARD,
+ RELAY_RAW_FLAG_RECV,
raw_msg, strlen (raw_msg) + 1);
free (raw_msg);
}
@@ -336,7 +370,9 @@ relay_client_recv_text (struct t_relay_client *client, const char *data)
handshake = relay_websocket_build_handshake (client);
if (handshake)
{
- relay_client_send (client, handshake,
+ relay_client_send (client,
+ RELAY_CLIENT_MSG_STANDARD,
+ handshake,
strlen (handshake), NULL);
free (handshake);
client->websocket = 2;
@@ -351,15 +387,16 @@ relay_client_recv_text (struct t_relay_client *client, const char *data)
"400 Bad Request");
if (weechat_relay_plugin->debug >= 1)
{
- weechat_printf_tags (NULL, "relay_client",
- _("%s%s: invalid websocket "
- "handshake received for "
- "client %s%s%s"),
- weechat_prefix ("error"),
- RELAY_PLUGIN_NAME,
- RELAY_COLOR_CHAT_CLIENT,
- client->desc,
- RELAY_COLOR_CHAT);
+ weechat_printf_date_tags (
+ NULL, 0, "relay_client",
+ _("%s%s: invalid websocket "
+ "handshake received for client "
+ "%s%s%s"),
+ weechat_prefix ("error"),
+ RELAY_PLUGIN_NAME,
+ RELAY_COLOR_CHAT_CLIENT,
+ client->desc,
+ RELAY_COLOR_CHAT);
}
break;
case -2:
@@ -367,13 +404,14 @@ relay_client_recv_text (struct t_relay_client *client, const char *data)
"403 Forbidden");
if (weechat_relay_plugin->debug >= 1)
{
- weechat_printf_tags (NULL, "relay_client",
- _("%s%s: origin \"%s\" "
- "not allowed for websocket"),
- weechat_prefix ("error"),
- RELAY_PLUGIN_NAME,
- weechat_hashtable_get (client->http_headers,
- "Origin"));
+ weechat_printf_date_tags (
+ NULL, 0, "relay_client",
+ _("%s%s: origin \"%s\" "
+ "not allowed for websocket"),
+ weechat_prefix ("error"),
+ RELAY_PLUGIN_NAME,
+ weechat_hashtable_get (client->http_headers,
+ "Origin"));
}
break;
}
@@ -384,8 +422,8 @@ relay_client_recv_text (struct t_relay_client *client, const char *data)
client->http_headers, "X-Real-IP");
if (ptr_real_ip)
{
- weechat_printf_tags (
- NULL, "relay_client",
+ weechat_printf_date_tags (
+ NULL, 0, "relay_client",
_("%s: websocket client %s%s%s has real IP "
"address \"%s\""),
RELAY_PLUGIN_NAME,
@@ -411,7 +449,10 @@ relay_client_recv_text (struct t_relay_client *client, const char *data)
}
else
{
- /* receive text from client */
+ /*
+ * interpret text from client, according to the relay
+ * protocol used
+ */
switch (client->protocol)
{
case RELAY_PROTOCOL_WEECHAT:
@@ -442,22 +483,71 @@ relay_client_recv_text (struct t_relay_client *client, const char *data)
}
/*
+ * Reads text buffer from a client.
+ */
+
+void
+relay_client_recv_text_buffer (struct t_relay_client *client,
+ const char *buffer,
+ unsigned long long length_buffer)
+{
+ unsigned long long index;
+ unsigned char msg_type;
+
+ index = 0;
+ while (index < length_buffer)
+ {
+ msg_type = RELAY_CLIENT_MSG_STANDARD;
+
+ /*
+ * in case of websocket, we can receive PING from client:
+ * trace this PING in raw buffer and answer with a PONG
+ */
+ if (client->websocket == 2)
+ {
+ msg_type = (unsigned char)buffer[index];
+ if (msg_type == RELAY_CLIENT_MSG_PING)
+ {
+ /* print message in raw buffer */
+ relay_raw_print (client, RELAY_CLIENT_MSG_PING,
+ RELAY_RAW_FLAG_RECV | RELAY_RAW_FLAG_BINARY,
+ buffer + index + 1,
+ strlen (buffer + index + 1));
+ /* answer with a PONG */
+ relay_client_send (client,
+ RELAY_CLIENT_MSG_PONG,
+ buffer + index + 1,
+ strlen (buffer + index + 1),
+ NULL);
+ }
+ index++;
+ }
+
+ if (msg_type == RELAY_CLIENT_MSG_STANDARD)
+ relay_client_recv_text (client, buffer + index);
+
+ index += strlen (buffer + index) + 1;
+ }
+}
+
+/*
* Reads data from a client.
*/
int
-relay_client_recv_cb (void *arg_client, int fd)
+relay_client_recv_cb (const void *pointer, void *data, int fd)
{
struct t_relay_client *client;
- static char buffer[4096], decoded[4096 + 1];
+ static char buffer[4096], decoded[8192 + 1];
const char *ptr_buffer;
int num_read, rc;
- unsigned long long decoded_length;
+ unsigned long long decoded_length, length_buffer;
/* make C compiler happy */
+ (void) data;
(void) fd;
- client = (struct t_relay_client *)arg_client;
+ client = (struct t_relay_client *)pointer;
if (client->status != RELAY_STATUS_CONNECTED)
return WEECHAT_RC_OK;
@@ -474,6 +564,7 @@ relay_client_recv_cb (void *arg_client, int fd)
{
buffer[num_read] = '\0';
ptr_buffer = buffer;
+ length_buffer = num_read;
/*
* if we are receiving the first message from client, check if it looks
@@ -489,11 +580,11 @@ relay_client_recv_cb (void *arg_client, int fd)
* valid or not)
*/
client->websocket = 1;
- client->http_headers = weechat_hashtable_new (32,
- WEECHAT_HASHTABLE_STRING,
- WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ client->http_headers = weechat_hashtable_new (
+ 32,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING,
+ NULL, NULL);
}
}
@@ -515,32 +606,33 @@ relay_client_recv_cb (void *arg_client, int fd)
*
* "A Pong frame MAY be sent unsolicited. This serves as a
* unidirectional heartbeat. A response to an unsolicited
- * Pong
- * frame is not expected."
+ * Pong frame is not expected."
*/
return WEECHAT_RC_OK;
}
if (!rc)
{
/* error when decoding frame: close connection */
- weechat_printf_tags (NULL, "relay_client",
- _("%s%s: error decoding websocket frame "
- "for client %s%s%s"),
- weechat_prefix ("error"), RELAY_PLUGIN_NAME,
- RELAY_COLOR_CHAT_CLIENT,
- client->desc,
- RELAY_COLOR_CHAT);
+ weechat_printf_date_tags (
+ NULL, 0, "relay_client",
+ _("%s%s: error decoding websocket frame for client "
+ "%s%s%s"),
+ weechat_prefix ("error"), RELAY_PLUGIN_NAME,
+ RELAY_COLOR_CHAT_CLIENT,
+ client->desc,
+ RELAY_COLOR_CHAT);
relay_client_set_status (client, RELAY_STATUS_DISCONNECTED);
return WEECHAT_RC_OK;
}
ptr_buffer = decoded;
+ length_buffer = decoded_length;
}
if ((client->websocket == 1)
|| (client->recv_data_type == RELAY_CLIENT_DATA_TEXT))
{
/* websocket initializing or text data for this client */
- relay_client_recv_text (client, ptr_buffer);
+ relay_client_recv_text_buffer (client, ptr_buffer, length_buffer);
}
else
{
@@ -557,16 +649,17 @@ relay_client_recv_cb (void *arg_client, int fd)
if ((num_read == 0)
|| ((num_read != GNUTLS_E_AGAIN) && (num_read != GNUTLS_E_INTERRUPTED)))
{
- weechat_printf_tags (NULL, "relay_client",
- _("%s%s: reading data on socket for "
- "client %s%s%s: error %d %s"),
- weechat_prefix ("error"), RELAY_PLUGIN_NAME,
- RELAY_COLOR_CHAT_CLIENT,
- client->desc,
- RELAY_COLOR_CHAT,
- num_read,
- (num_read == 0) ? _("(connection closed by peer)") :
- gnutls_strerror (num_read));
+ weechat_printf_date_tags (
+ NULL, 0, "relay_client",
+ _("%s%s: reading data on socket for client %s%s%s: "
+ "error %d %s"),
+ weechat_prefix ("error"), RELAY_PLUGIN_NAME,
+ RELAY_COLOR_CHAT_CLIENT,
+ client->desc,
+ RELAY_COLOR_CHAT,
+ num_read,
+ (num_read == 0) ? _("(connection closed by peer)") :
+ gnutls_strerror (num_read));
relay_client_set_status (client, RELAY_STATUS_DISCONNECTED);
}
}
@@ -576,16 +669,17 @@ relay_client_recv_cb (void *arg_client, int fd)
if ((num_read == 0)
|| ((errno != EAGAIN) && (errno != EWOULDBLOCK)))
{
- weechat_printf_tags (NULL, "relay_client",
- _("%s%s: reading data on socket for "
- "client %s%s%s: error %d %s"),
- weechat_prefix ("error"), RELAY_PLUGIN_NAME,
- RELAY_COLOR_CHAT_CLIENT,
- client->desc,
- RELAY_COLOR_CHAT,
- errno,
- (num_read == 0) ? _("(connection closed by peer)") :
- strerror (errno));
+ weechat_printf_date_tags (
+ NULL, 0, "relay_client",
+ _("%s%s: reading data on socket for client %s%s%s: "
+ "error %d %s"),
+ weechat_prefix ("error"), RELAY_PLUGIN_NAME,
+ RELAY_COLOR_CHAT_CLIENT,
+ client->desc,
+ RELAY_COLOR_CHAT,
+ errno,
+ (num_read == 0) ? _("(connection closed by peer)") :
+ strerror (errno));
relay_client_set_status (client, RELAY_STATUS_DISCONNECTED);
}
}
@@ -601,7 +695,9 @@ relay_client_recv_cb (void *arg_client, int fd)
void
relay_client_outqueue_add (struct t_relay_client *client,
const char *data, int data_size,
- int raw_flags[2], const char *raw_message[2],
+ enum t_relay_client_msg_type raw_msg_type[2],
+ int raw_flags[2],
+ const char *raw_message[2],
int raw_size[2])
{
struct t_relay_client_outqueue *new_outqueue;
@@ -623,6 +719,7 @@ relay_client_outqueue_add (struct t_relay_client *client,
new_outqueue->data_size = data_size;
for (i = 0; i < 2; i++)
{
+ new_outqueue->raw_msg_type[i] = RELAY_CLIENT_MSG_STANDARD;
new_outqueue->raw_flags[i] = 0;
new_outqueue->raw_message[i] = NULL;
new_outqueue->raw_size[i] = 0;
@@ -631,6 +728,7 @@ relay_client_outqueue_add (struct t_relay_client *client,
new_outqueue->raw_message[i] = malloc (raw_size[i]);
if (new_outqueue->raw_message[i])
{
+ new_outqueue->raw_msg_type[i] = raw_msg_type[i];
new_outqueue->raw_flags[i] = raw_flags[i];
memcpy (new_outqueue->raw_message[i], raw_message[i],
raw_size[i]);
@@ -709,10 +807,13 @@ relay_client_outqueue_free_all (struct t_relay_client *client)
*/
int
-relay_client_send (struct t_relay_client *client, const char *data,
+relay_client_send (struct t_relay_client *client,
+ enum t_relay_client_msg_type msg_type,
+ const char *data,
int data_size, const char *message_raw_buffer)
{
- int num_sent, raw_size[2], raw_flags[2], i;
+ int num_sent, raw_size[2], raw_flags[2], opcode, i;
+ enum t_relay_client_msg_type raw_msg_type[2];
char *websocket_frame;
unsigned long long length_frame;
const char *ptr_data, *raw_msg[2];
@@ -726,6 +827,7 @@ relay_client_send (struct t_relay_client *client, const char *data,
/* set raw messages */
for (i = 0; i < 2; i++)
{
+ raw_msg_type[i] = msg_type;
raw_flags[i] = RELAY_RAW_FLAG_SEND;
raw_msg[i] = NULL;
raw_size[i] = 0;
@@ -755,8 +857,10 @@ relay_client_send (struct t_relay_client *client, const char *data,
{
raw_msg[0] = data;
raw_size[0] = data_size;
- if ((client->websocket != 1)
- && (client->send_data_type == RELAY_CLIENT_DATA_BINARY))
+ if ((msg_type == RELAY_CLIENT_MSG_PING)
+ || (msg_type == RELAY_CLIENT_MSG_PONG)
+ || ((client->websocket != 1)
+ && (client->send_data_type == RELAY_CLIENT_DATA_BINARY)))
{
/*
* set binary flag if we send binary to client
@@ -775,7 +879,21 @@ relay_client_send (struct t_relay_client *client, const char *data,
/* if websocket is initialized, encode data in a websocket frame */
if (client->websocket == 2)
{
- websocket_frame = relay_websocket_encode_frame (client, data, data_size,
+ switch (msg_type)
+ {
+ case RELAY_CLIENT_MSG_PING:
+ opcode = WEBSOCKET_FRAME_OPCODE_PING;
+ break;
+ case RELAY_CLIENT_MSG_PONG:
+ opcode = WEBSOCKET_FRAME_OPCODE_PONG;
+ break;
+ default:
+ opcode = (client->send_data_type == RELAY_CLIENT_DATA_TEXT) ?
+ WEBSOCKET_FRAME_OPCODE_TEXT : WEBSOCKET_FRAME_OPCODE_BINARY;
+ break;
+ }
+ websocket_frame = relay_websocket_encode_frame (opcode, data,
+ data_size,
&length_frame);
if (websocket_frame)
{
@@ -793,7 +911,7 @@ relay_client_send (struct t_relay_client *client, const char *data,
if (client->outqueue)
{
relay_client_outqueue_add (client, ptr_data, data_size,
- raw_flags, raw_msg, raw_size);
+ raw_msg_type, raw_flags, raw_msg, raw_size);
}
else
{
@@ -810,8 +928,8 @@ relay_client_send (struct t_relay_client *client, const char *data,
{
if (raw_msg[i])
{
- relay_raw_print (client,
- raw_flags[i], raw_msg[i], raw_size[i]);
+ relay_raw_print (client, raw_msg_type[i], raw_flags[i],
+ raw_msg[i], raw_size[i]);
}
}
if (num_sent > 0)
@@ -822,9 +940,10 @@ relay_client_send (struct t_relay_client *client, const char *data,
if (num_sent < data_size)
{
/* some data was not sent, add it to outqueue */
- relay_client_outqueue_add (client, ptr_data + num_sent,
+ relay_client_outqueue_add (client,
+ ptr_data + num_sent,
data_size - num_sent,
- NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL);
}
}
else if (num_sent < 0)
@@ -836,21 +955,23 @@ relay_client_send (struct t_relay_client *client, const char *data,
|| (num_sent == GNUTLS_E_INTERRUPTED))
{
/* add message to queue (will be sent later) */
- relay_client_outqueue_add (client, ptr_data, data_size,
- raw_flags, raw_msg, raw_size);
+ relay_client_outqueue_add (client,
+ ptr_data, data_size,
+ raw_msg_type, raw_flags,
+ raw_msg, raw_size);
}
else
{
- weechat_printf_tags (NULL, "relay_client",
- _("%s%s: sending data to client %s%s%s: "
- "error %d %s"),
- weechat_prefix ("error"),
- RELAY_PLUGIN_NAME,
- RELAY_COLOR_CHAT_CLIENT,
- client->desc,
- RELAY_COLOR_CHAT,
- num_sent,
- gnutls_strerror (num_sent));
+ weechat_printf_date_tags (
+ NULL, 0, "relay_client",
+ _("%s%s: sending data to client %s%s%s: error %d %s"),
+ weechat_prefix ("error"),
+ RELAY_PLUGIN_NAME,
+ RELAY_COLOR_CHAT_CLIENT,
+ client->desc,
+ RELAY_COLOR_CHAT,
+ num_sent,
+ gnutls_strerror (num_sent));
relay_client_set_status (client, RELAY_STATUS_DISCONNECTED);
}
}
@@ -861,20 +982,21 @@ relay_client_send (struct t_relay_client *client, const char *data,
{
/* add message to queue (will be sent later) */
relay_client_outqueue_add (client, ptr_data, data_size,
- raw_flags, raw_msg, raw_size);
+ raw_msg_type, raw_flags,
+ raw_msg, raw_size);
}
else
{
- weechat_printf_tags (NULL, "relay_client",
- _("%s%s: sending data to client %s%s%s: "
- "error %d %s"),
- weechat_prefix ("error"),
- RELAY_PLUGIN_NAME,
- RELAY_COLOR_CHAT_CLIENT,
- client->desc,
- RELAY_COLOR_CHAT,
- errno,
- strerror (errno));
+ weechat_printf_date_tags (
+ NULL, 0, "relay_client",
+ _("%s%s: sending data to client %s%s%s: error %d %s"),
+ weechat_prefix ("error"),
+ RELAY_PLUGIN_NAME,
+ RELAY_COLOR_CHAT_CLIENT,
+ client->desc,
+ RELAY_COLOR_CHAT,
+ errno,
+ strerror (errno));
relay_client_set_status (client, RELAY_STATUS_DISCONNECTED);
}
}
@@ -892,7 +1014,7 @@ relay_client_send (struct t_relay_client *client, const char *data,
*/
int
-relay_client_timer_cb (void *data, int remaining_calls)
+relay_client_timer_cb (const void *pointer, void *data, int remaining_calls)
{
struct t_relay_client *ptr_client, *ptr_next_client;
int num_sent, i, purge_delay;
@@ -900,6 +1022,7 @@ relay_client_timer_cb (void *data, int remaining_calls)
time_t current_time;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) remaining_calls;
@@ -943,18 +1066,19 @@ relay_client_timer_cb (void *data, int remaining_calls)
{
for (i = 0; i < 2; i++)
{
- if (ptr_client->outqueue->raw_message
- && ptr_client->outqueue->raw_message[i])
+ if (ptr_client->outqueue->raw_message[i])
{
/*
* print raw message and remove it from outqueue
* (so that it is displayed only one time, even if
* message is sent in many chunks)
*/
- relay_raw_print (ptr_client,
- ptr_client->outqueue->raw_flags[i],
- ptr_client->outqueue->raw_message[i],
- ptr_client->outqueue->raw_size[i]);
+ relay_raw_print (
+ ptr_client,
+ ptr_client->outqueue->raw_msg_type[i],
+ ptr_client->outqueue->raw_flags[i],
+ ptr_client->outqueue->raw_message[i],
+ ptr_client->outqueue->raw_size[i]);
ptr_client->outqueue->raw_flags[i] = 0;
free (ptr_client->outqueue->raw_message[i]);
ptr_client->outqueue->raw_message[i] = NULL;
@@ -1007,16 +1131,17 @@ relay_client_timer_cb (void *data, int remaining_calls)
}
else
{
- weechat_printf_tags (NULL, "relay_client",
- _("%s%s: sending data to client "
- "%s%s%s: error %d %s"),
- weechat_prefix ("error"),
- RELAY_PLUGIN_NAME,
- RELAY_COLOR_CHAT_CLIENT,
- ptr_client->desc,
- RELAY_COLOR_CHAT,
- num_sent,
- gnutls_strerror (num_sent));
+ weechat_printf_date_tags (
+ NULL, 0, "relay_client",
+ _("%s%s: sending data to client %s%s%s: "
+ "error %d %s"),
+ weechat_prefix ("error"),
+ RELAY_PLUGIN_NAME,
+ RELAY_COLOR_CHAT_CLIENT,
+ ptr_client->desc,
+ RELAY_COLOR_CHAT,
+ num_sent,
+ gnutls_strerror (num_sent));
relay_client_set_status (ptr_client,
RELAY_STATUS_DISCONNECTED);
}
@@ -1031,16 +1156,17 @@ relay_client_timer_cb (void *data, int remaining_calls)
}
else
{
- weechat_printf_tags (NULL, "relay_client",
- _("%s%s: sending data to client "
- "%s%s%s: error %d %s"),
- weechat_prefix ("error"),
- RELAY_PLUGIN_NAME,
- RELAY_COLOR_CHAT_CLIENT,
- ptr_client->desc,
- RELAY_COLOR_CHAT,
- errno,
- strerror (errno));
+ weechat_printf_date_tags (
+ NULL, 0, "relay_client",
+ _("%s%s: sending data to client %s%s%s: "
+ "error %d %s"),
+ weechat_prefix ("error"),
+ RELAY_PLUGIN_NAME,
+ RELAY_COLOR_CHAT_CLIENT,
+ ptr_client->desc,
+ RELAY_COLOR_CHAT,
+ errno,
+ strerror (errno));
relay_client_set_status (ptr_client,
RELAY_STATUS_DISCONNECTED);
}
@@ -1076,6 +1202,7 @@ relay_client_new (int sock, const char *address, struct t_relay_server *server)
new_client->id = (relay_clients) ? relay_clients->id + 1 : 1;
new_client->desc = NULL;
new_client->sock = sock;
+ new_client->server_port = server->port;
new_client->ssl = server->ssl;
#ifdef HAVE_GNUTLS
new_client->hook_timer_handshake = NULL;
@@ -1119,12 +1246,12 @@ relay_client_new (int sock, const char *address, struct t_relay_server *server)
{
if (!relay_network_init_ssl_cert_key_ok)
{
- weechat_printf_tags (NULL, "relay_client",
- _("%s%s: warning: no SSL certificate/key "
- "found (option "
- "relay.network.ssl_cert_key)"),
- weechat_prefix ("error"),
- RELAY_PLUGIN_NAME);
+ weechat_printf_date_tags (
+ NULL, 0, "relay_client",
+ _("%s%s: warning: no SSL certificate/key found (option "
+ "relay.network.ssl_cert_key)"),
+ weechat_prefix ("error"),
+ RELAY_PLUGIN_NAME);
}
new_client->status = RELAY_STATUS_CONNECTING;
/*
@@ -1162,7 +1289,8 @@ relay_client_new (int sock, const char *address, struct t_relay_server *server)
(ptr_option) ?
weechat_config_integer (ptr_option) * 10 : 30 * 10,
&relay_client_handshake_timer_cb,
- new_client);
+ new_client,
+ NULL);
}
#endif /* HAVE_GNUTLS */
@@ -1190,18 +1318,18 @@ relay_client_new (int sock, const char *address, struct t_relay_server *server)
last_relay_client = new_client;
relay_clients = new_client;
- weechat_printf_tags (NULL, "relay_client",
- _("%s: new client on port %d: %s%s%s"),
- RELAY_PLUGIN_NAME,
- server->port,
- RELAY_COLOR_CHAT_CLIENT,
- new_client->desc,
- RELAY_COLOR_CHAT);
+ weechat_printf_date_tags (NULL, 0, "relay_client",
+ _("%s: new client on port %d: %s%s%s"),
+ RELAY_PLUGIN_NAME,
+ server->port,
+ RELAY_COLOR_CHAT_CLIENT,
+ new_client->desc,
+ RELAY_COLOR_CHAT);
new_client->hook_fd = weechat_hook_fd (new_client->sock,
1, 0, 0,
&relay_client_recv_cb,
- new_client);
+ new_client, NULL);
relay_client_count++;
@@ -1217,9 +1345,9 @@ relay_client_new (int sock, const char *address, struct t_relay_server *server)
}
else
{
- weechat_printf_tags (NULL, "relay_client",
- _("%s%s: not enough memory for new client"),
- weechat_prefix ("error"), RELAY_PLUGIN_NAME);
+ weechat_printf_date_tags (NULL, 0, "relay_client",
+ _("%s%s: not enough memory for new client"),
+ weechat_prefix ("error"), RELAY_PLUGIN_NAME);
}
return new_client;
@@ -1243,6 +1371,7 @@ relay_client_new_with_infolist (struct t_infolist *infolist)
new_client->id = weechat_infolist_integer (infolist, "id");
new_client->desc = NULL;
new_client->sock = weechat_infolist_integer (infolist, "sock");
+ new_client->server_port = weechat_infolist_integer (infolist, "server_port");
new_client->ssl = weechat_infolist_integer (infolist, "ssl");
#ifdef HAVE_GNUTLS
new_client->gnutls_sess = NULL;
@@ -1266,7 +1395,8 @@ relay_client_new_with_infolist (struct t_infolist *infolist)
new_client->hook_fd = weechat_hook_fd (new_client->sock,
1, 0, 0,
&relay_client_recv_cb,
- new_client);
+ new_client,
+ NULL);
}
else
new_client->hook_fd = NULL;
@@ -1366,22 +1496,23 @@ relay_client_set_status (struct t_relay_client *client,
switch (client->status)
{
case RELAY_STATUS_AUTH_FAILED:
- weechat_printf_tags (NULL, "relay_client",
- _("%s%s: authentication failed with "
- "client %s%s%s"),
- weechat_prefix ("error"),
- RELAY_PLUGIN_NAME,
- RELAY_COLOR_CHAT_CLIENT,
- client->desc,
- RELAY_COLOR_CHAT);
+ weechat_printf_date_tags (NULL, 0, "relay_client",
+ _("%s%s: authentication failed with "
+ "client %s%s%s"),
+ weechat_prefix ("error"),
+ RELAY_PLUGIN_NAME,
+ RELAY_COLOR_CHAT_CLIENT,
+ client->desc,
+ RELAY_COLOR_CHAT);
break;
case RELAY_STATUS_DISCONNECTED:
- weechat_printf_tags (NULL, "relay_client",
- _("%s: disconnected from client %s%s%s"),
- RELAY_PLUGIN_NAME,
- RELAY_COLOR_CHAT_CLIENT,
- client->desc,
- RELAY_COLOR_CHAT);
+ weechat_printf_date_tags (
+ NULL, 0, "relay_client",
+ _("%s: disconnected from client %s%s%s"),
+ RELAY_PLUGIN_NAME,
+ RELAY_COLOR_CHAT_CLIENT,
+ client->desc,
+ RELAY_COLOR_CHAT);
break;
default:
break;
@@ -1549,6 +1680,8 @@ relay_client_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "sock", client->sock))
return 0;
+ if (!weechat_infolist_new_var_integer (ptr_item, "server_port", client->server_port))
+ return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "ssl", client->ssl))
return 0;
#ifdef HAVE_GNUTLS
@@ -1628,6 +1761,7 @@ relay_client_print_log ()
weechat_log_printf (" id. . . . . . . . . . : %d", ptr_client->id);
weechat_log_printf (" desc. . . . . . . . . : '%s'", ptr_client->desc);
weechat_log_printf (" sock. . . . . . . . . : %d", ptr_client->sock);
+ weechat_log_printf (" server_port . . . . . : %d", ptr_client->server_port);
weechat_log_printf (" ssl . . . . . . . . . : %d", ptr_client->ssl);
#ifdef HAVE_GNUTLS
weechat_log_printf (" gnutls_sess . . . . . : 0x%lx", ptr_client->gnutls_sess);
diff --git a/src/plugins/relay/relay-client.h b/src/plugins/relay/relay-client.h
index 8e8a2c59d..f76eaacd7 100644
--- a/src/plugins/relay/relay-client.h
+++ b/src/plugins/relay/relay-client.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -49,6 +49,17 @@ enum t_relay_client_data_type
RELAY_NUM_CLIENT_DATA_TYPES,
};
+/* type of message exchanged with the client (used for websockets) */
+
+enum t_relay_client_msg_type
+{
+ RELAY_CLIENT_MSG_STANDARD,
+ RELAY_CLIENT_MSG_PING,
+ RELAY_CLIENT_MSG_PONG,
+ /* number of message types */
+ RELAY_NUM_CLIENT_MSG_TYPES,
+};
+
/* macros for status */
#define RELAY_CLIENT_HAS_ENDED(client) \
@@ -61,6 +72,7 @@ struct t_relay_client_outqueue
{
char *data; /* data to send */
int data_size; /* number of bytes */
+ int raw_msg_type[2]; /* msgs types */
int raw_flags[2]; /* flags for raw messages */
char *raw_message[2]; /* msgs for raw buffer (can be NULL)*/
int raw_size[2]; /* size (in bytes) of raw messages */
@@ -75,6 +87,7 @@ struct t_relay_client
int id; /* unique id (diff. for each client) */
char *desc; /* description, used for display */
int sock; /* socket for connection */
+ int server_port; /* port used for connection */
int ssl; /* 1 if SSL is enabled */
#ifdef HAVE_GNUTLS
gnutls_session_t gnutls_sess; /* gnutls session (only if SSL used) */
@@ -107,6 +120,7 @@ struct t_relay_client
};
extern char *relay_client_status_string[];
+extern char *relay_client_msg_type_string[];
extern struct t_relay_client *relay_clients;
extern struct t_relay_client *last_relay_client;
extern int relay_client_count;
@@ -115,11 +129,15 @@ extern int relay_client_valid (struct t_relay_client *client);
extern struct t_relay_client *relay_client_search_by_number (int number);
extern struct t_relay_client *relay_client_search_by_id (int id);
extern int relay_client_status_search (const char *name);
+extern int relay_client_count_active_by_port (int server_port);
extern void relay_client_set_desc (struct t_relay_client *client);
-extern int relay_client_recv_cb (void *arg_client, int fd);
-extern int relay_client_send (struct t_relay_client *client, const char *data,
+extern int relay_client_recv_cb (const void *pointer, void *data, int fd);
+extern int relay_client_send (struct t_relay_client *client,
+ enum t_relay_client_msg_type msg_type,
+ const char *data,
int data_size, const char *message_raw_buffer);
-extern int relay_client_timer_cb (void *data, int remaining_calls);
+extern int relay_client_timer_cb (const void *pointer, void *data,
+ int remaining_calls);
extern struct t_relay_client *relay_client_new (int sock, const char *address,
struct t_relay_server *server);
extern struct t_relay_client *relay_client_new_with_infolist (struct t_infolist *infolist);
diff --git a/src/plugins/relay/relay-command.c b/src/plugins/relay/relay-command.c
index b6c958a06..8774d3923 100644
--- a/src/plugins/relay/relay-command.c
+++ b/src/plugins/relay/relay-command.c
@@ -1,7 +1,7 @@
/*
* relay-command.c - relay command
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -183,7 +183,8 @@ relay_command_server_list ()
*/
int
-relay_command_relay (void *data, struct t_gui_buffer *buffer, int argc,
+relay_command_relay (const void *pointer, void *data,
+ struct t_gui_buffer *buffer, int argc,
char **argv, char **argv_eol)
{
struct t_relay_server *ptr_server;
@@ -191,6 +192,7 @@ relay_command_relay (void *data, struct t_gui_buffer *buffer, int argc,
int port;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
@@ -217,11 +219,12 @@ relay_command_relay (void *data, struct t_gui_buffer *buffer, int argc,
if (weechat_strcasecmp (argv[1], "add") == 0)
{
WEECHAT_COMMAND_MIN_ARGS(4, "add");
- if (relay_config_create_option_port (NULL,
- relay_config_file,
- relay_config_section_port,
- argv[2],
- argv_eol[3]) != WEECHAT_CONFIG_OPTION_SET_ERROR)
+ if (relay_config_create_option_port (
+ NULL, NULL,
+ relay_config_file,
+ relay_config_section_port,
+ argv[2],
+ argv_eol[3]) != WEECHAT_CONFIG_OPTION_SET_ERROR)
{
weechat_printf (NULL,
_("%s: relay \"%s\" (port %s) added"),
@@ -420,5 +423,5 @@ relay_command_init ()
" || restart %(relay_relays)"
" || raw"
" || sslcertkey",
- &relay_command_relay, NULL);
+ &relay_command_relay, NULL, NULL);
}
diff --git a/src/plugins/relay/relay-command.h b/src/plugins/relay/relay-command.h
index 0ff5c99d6..23a90dcf0 100644
--- a/src/plugins/relay/relay-command.h
+++ b/src/plugins/relay/relay-command.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/relay/relay-completion.c b/src/plugins/relay/relay-completion.c
index 7c6fd7486..e5253714a 100644
--- a/src/plugins/relay/relay-completion.c
+++ b/src/plugins/relay/relay-completion.c
@@ -1,7 +1,7 @@
/*
* relay-completion.c - completion for relay command
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -33,7 +33,8 @@
*/
int
-relay_completion_protocol_name_cb (void *data, const char *completion_item,
+relay_completion_protocol_name_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
@@ -41,6 +42,7 @@ relay_completion_protocol_name_cb (void *data, const char *completion_item,
char protocol_name[512];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
(void) completion_item;
@@ -75,13 +77,15 @@ relay_completion_protocol_name_cb (void *data, const char *completion_item,
*/
int
-relay_completion_relays_cb (void *data, const char *completion_item,
+relay_completion_relays_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
struct t_relay_server *ptr_server;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
(void) completion_item;
@@ -102,7 +106,8 @@ relay_completion_relays_cb (void *data, const char *completion_item,
*/
int
-relay_completion_free_port_cb (void *data, const char *completion_item,
+relay_completion_free_port_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
@@ -111,6 +116,7 @@ relay_completion_free_port_cb (void *data, const char *completion_item,
int port_max;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
(void) completion_item;
@@ -141,12 +147,12 @@ relay_completion_init ()
{
weechat_hook_completion ("relay_protocol_name",
N_("all possible protocol.name for relay plugin"),
- &relay_completion_protocol_name_cb, NULL);
+ &relay_completion_protocol_name_cb, NULL, NULL);
weechat_hook_completion ("relay_relays",
N_("protocol.name of current relays for relay "
"plugin"),
- &relay_completion_relays_cb, NULL);
+ &relay_completion_relays_cb, NULL, NULL);
weechat_hook_completion ("relay_free_port",
N_("first free port for relay plugin"),
- &relay_completion_free_port_cb, NULL);
+ &relay_completion_free_port_cb, NULL, NULL);
}
diff --git a/src/plugins/relay/relay-completion.h b/src/plugins/relay/relay-completion.h
index f522103d5..e8f36f601 100644
--- a/src/plugins/relay/relay-completion.h
+++ b/src/plugins/relay/relay-completion.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/relay/relay-config.c b/src/plugins/relay/relay-config.c
index cd76bd34d..b6a3cf078 100644
--- a/src/plugins/relay/relay-config.c
+++ b/src/plugins/relay/relay-config.c
@@ -1,7 +1,7 @@
/*
* relay-config.c - relay configuration options (file relay.conf)
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -52,6 +52,7 @@ struct t_config_option *relay_config_color_text_selected;
/* relay config, network section */
+struct t_config_option *relay_config_network_allow_empty_password;
struct t_config_option *relay_config_network_allowed_ips;
struct t_config_option *relay_config_network_bind_address;
struct t_config_option *relay_config_network_clients_purge_delay;
@@ -68,6 +69,7 @@ struct t_config_option *relay_config_network_websocket_allowed_origins;
struct t_config_option *relay_config_irc_backlog_max_minutes;
struct t_config_option *relay_config_irc_backlog_max_number;
struct t_config_option *relay_config_irc_backlog_since_last_disconnect;
+struct t_config_option *relay_config_irc_backlog_since_last_message;
struct t_config_option *relay_config_irc_backlog_tags;
struct t_config_option *relay_config_irc_backlog_time_format;
@@ -83,9 +85,11 @@ struct t_hashtable *relay_config_hashtable_irc_backlog_tags = NULL;
*/
void
-relay_config_refresh_cb (void *data, struct t_config_option *option)
+relay_config_refresh_cb (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -98,12 +102,13 @@ relay_config_refresh_cb (void *data, struct t_config_option *option)
*/
void
-relay_config_change_network_allowed_ips (void *data,
+relay_config_change_network_allowed_ips (const void *pointer, void *data,
struct t_config_option *option)
{
const char *allowed_ips;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -136,12 +141,13 @@ relay_config_change_network_allowed_ips (void *data,
*/
void
-relay_config_change_network_bind_address_cb (void *data,
+relay_config_change_network_bind_address_cb (const void *pointer, void *data,
struct t_config_option *option)
{
struct t_relay_server *ptr_server;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -158,11 +164,13 @@ relay_config_change_network_bind_address_cb (void *data,
*/
void
-relay_config_change_network_ipv6_cb (void *data, struct t_config_option *option)
+relay_config_change_network_ipv6_cb (const void *pointer, void *data,
+ struct t_config_option *option)
{
struct t_relay_server *ptr_server;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -182,10 +190,11 @@ relay_config_change_network_ipv6_cb (void *data, struct t_config_option *option)
*/
void
-relay_config_change_network_ssl_cert_key (void *data,
+relay_config_change_network_ssl_cert_key (const void *pointer, void *data,
struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -198,7 +207,7 @@ relay_config_change_network_ssl_cert_key (void *data,
*/
int
-relay_config_check_network_ssl_priorities (void *data,
+relay_config_check_network_ssl_priorities (const void *pointer, void *data,
struct t_config_option *option,
const char *value)
{
@@ -208,6 +217,7 @@ relay_config_check_network_ssl_priorities (void *data,
int rc;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -245,10 +255,11 @@ relay_config_check_network_ssl_priorities (void *data,
*/
void
-relay_config_change_network_ssl_priorities (void *data,
+relay_config_change_network_ssl_priorities (const void *pointer, void *data,
struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -266,12 +277,13 @@ relay_config_change_network_ssl_priorities (void *data,
*/
void
-relay_config_change_network_websocket_allowed_origins (void *data,
+relay_config_change_network_websocket_allowed_origins (const void *pointer, void *data,
struct t_config_option *option)
{
const char *allowed_origins;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -308,7 +320,7 @@ relay_config_change_network_websocket_allowed_origins (void *data,
*/
int
-relay_config_check_irc_backlog_tags (void *data,
+relay_config_check_irc_backlog_tags (const void *pointer, void *data,
struct t_config_option *option,
const char *value)
{
@@ -316,6 +328,7 @@ relay_config_check_irc_backlog_tags (void *data,
int num_tags, i, rc;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -348,23 +361,24 @@ relay_config_check_irc_backlog_tags (void *data,
*/
void
-relay_config_change_irc_backlog_tags (void *data,
+relay_config_change_irc_backlog_tags (const void *pointer, void *data,
struct t_config_option *option)
{
char **items;
int num_items, i;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
if (!relay_config_hashtable_irc_backlog_tags)
{
- relay_config_hashtable_irc_backlog_tags = weechat_hashtable_new (32,
- WEECHAT_HASHTABLE_STRING,
- WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ relay_config_hashtable_irc_backlog_tags = weechat_hashtable_new (
+ 32,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING,
+ NULL, NULL);
}
else
weechat_hashtable_remove_all (relay_config_hashtable_irc_backlog_tags);
@@ -392,7 +406,8 @@ relay_config_change_irc_backlog_tags (void *data,
*/
int
-relay_config_check_port_cb (void *data, struct t_config_option *option,
+relay_config_check_port_cb (const void *pointer, void *data,
+ struct t_config_option *option,
const char *value)
{
char *error;
@@ -400,6 +415,7 @@ relay_config_check_port_cb (void *data, struct t_config_option *option,
struct t_relay_server *ptr_server;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -422,11 +438,13 @@ relay_config_check_port_cb (void *data, struct t_config_option *option,
*/
void
-relay_config_change_port_cb (void *data, struct t_config_option *option)
+relay_config_change_port_cb (const void *pointer, void *data,
+ struct t_config_option *option)
{
struct t_relay_server *ptr_server;
/* make C compiler happy */
+ (void) pointer;
(void) data;
ptr_server = relay_server_search (weechat_config_option_get_pointer (option, "name"));
@@ -442,11 +460,13 @@ relay_config_change_port_cb (void *data, struct t_config_option *option)
*/
void
-relay_config_delete_port_cb (void *data, struct t_config_option *option)
+relay_config_delete_port_cb (const void *pointer, void *data,
+ struct t_config_option *option)
{
struct t_relay_server *ptr_server;
/* make C compiler happy */
+ (void) pointer;
(void) data;
ptr_server = relay_server_search (weechat_config_option_get_pointer (option, "name"));
@@ -459,7 +479,7 @@ relay_config_delete_port_cb (void *data, struct t_config_option *option)
*/
int
-relay_config_create_option_port (void *data,
+relay_config_create_option_port (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
@@ -471,6 +491,7 @@ relay_config_create_option_port (void *data,
struct t_relay_server *ptr_server;
/* make C compiler happy */
+ (void) pointer;
(void) data;
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
@@ -550,9 +571,9 @@ relay_config_create_option_port (void *data,
config_file, section,
option_name, "integer", NULL,
NULL, 0, 65535, "", value, 0,
- &relay_config_check_port_cb, NULL,
- &relay_config_change_port_cb, NULL,
- &relay_config_delete_port_cb, NULL);
+ &relay_config_check_port_cb, NULL, NULL,
+ &relay_config_change_port_cb, NULL, NULL,
+ &relay_config_delete_port_cb, NULL, NULL);
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
}
else
@@ -572,9 +593,11 @@ relay_config_create_option_port (void *data,
*/
int
-relay_config_reload (void *data, struct t_config_file *config_file)
+relay_config_reload (const void *pointer, void *data,
+ struct t_config_file *config_file)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
weechat_config_section_free_options (relay_config_section_port);
@@ -597,16 +620,18 @@ relay_config_init ()
struct t_config_section *ptr_section;
relay_config_file = weechat_config_new (RELAY_CONFIG_NAME,
- &relay_config_reload, NULL);
+ &relay_config_reload, NULL, NULL);
if (!relay_config_file)
return 0;
/* section look */
ptr_section = weechat_config_new_section (relay_config_file, "look",
0, 0,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (relay_config_file);
@@ -617,20 +642,24 @@ relay_config_init ()
relay_config_file, ptr_section,
"auto_open_buffer", "boolean",
N_("auto open relay buffer when a new client is connecting"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
relay_config_look_raw_messages = weechat_config_new_option (
relay_config_file, ptr_section,
"raw_messages", "integer",
N_("number of raw messages to save in memory when raw data buffer is "
"closed (messages will be displayed when opening raw data buffer)"),
- NULL, 0, 65535, "256", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 65535, "256", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
/* section color */
ptr_section = weechat_config_new_section (relay_config_file, "color",
0, 0,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (relay_config_file);
@@ -642,68 +671,93 @@ relay_config_init ()
"client", "color",
N_("text color for client description"),
NULL, 0, 0, "cyan", NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
relay_config_color_status[RELAY_STATUS_CONNECTING] = weechat_config_new_option (
relay_config_file, ptr_section,
"status_connecting", "color",
N_("text color for \"connecting\" status"),
NULL, 0, 0, "yellow", NULL, 0,
- NULL, NULL, &relay_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &relay_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
relay_config_color_status[RELAY_STATUS_WAITING_AUTH] = weechat_config_new_option (
relay_config_file, ptr_section,
"status_waiting_auth", "color",
N_("text color for \"waiting authentication\" status"),
NULL, 0, 0, "brown", NULL, 0,
- NULL, NULL, &relay_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &relay_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
relay_config_color_status[RELAY_STATUS_CONNECTED] = weechat_config_new_option (
relay_config_file, ptr_section,
"status_active", "color",
N_("text color for \"connected\" status"),
NULL, 0, 0, "lightblue", NULL, 0,
- NULL, NULL, &relay_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &relay_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
relay_config_color_status[RELAY_STATUS_AUTH_FAILED] = weechat_config_new_option (
relay_config_file, ptr_section,
"status_auth_failed", "color",
N_("text color for \"authentication failed\" status"),
NULL, 0, 0, "lightred", NULL, 0,
- NULL, NULL, &relay_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &relay_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
relay_config_color_status[RELAY_STATUS_DISCONNECTED] = weechat_config_new_option (
relay_config_file, ptr_section,
"status_disconnected", "color",
N_("text color for \"disconnected\" status"),
NULL, 0, 0, "lightred", NULL, 0,
- NULL, NULL, &relay_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &relay_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
relay_config_color_text = weechat_config_new_option (
relay_config_file, ptr_section,
"text", "color",
N_("text color in relay buffer"),
NULL, 0, 0, "default", NULL, 0,
- NULL, NULL, &relay_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &relay_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
relay_config_color_text_bg = weechat_config_new_option (
relay_config_file, ptr_section,
"text_bg", "color",
N_("background color in relay buffer"),
NULL, 0, 0, "default", NULL, 0,
- NULL, NULL, &relay_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &relay_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
relay_config_color_text_selected = weechat_config_new_option (
relay_config_file, ptr_section,
"text_selected", "color",
N_("text color of selected line in relay buffer"),
NULL, 0, 0, "white", NULL, 0,
- NULL, NULL, &relay_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &relay_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
/* section network */
ptr_section = weechat_config_new_section (relay_config_file, "network",
0, 0,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (relay_config_file);
return 0;
}
+ relay_config_network_allow_empty_password = weechat_config_new_option (
+ relay_config_file, ptr_section,
+ "allow_empty_password", "boolean",
+ N_("allow empty password in relay (it should be enabled only for "
+ "tests or local network)"),
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
relay_config_network_allowed_ips = weechat_config_new_option (
relay_config_file, ptr_section,
"allowed_ips", "string",
@@ -711,23 +765,25 @@ relay_config_init ()
"(case insensitive, use \"(?-i)\" at beginning to make it case "
"sensitive), example: "
"\"^(123.45.67.89|192.160.*)$\""),
- NULL, 0, 0, "", NULL, 0, NULL, NULL,
- &relay_config_change_network_allowed_ips, NULL, NULL, NULL);
+ NULL, 0, 0, "", NULL, 0,
+ NULL, NULL, NULL,
+ &relay_config_change_network_allowed_ips, NULL, NULL,
+ NULL, NULL, NULL);
relay_config_network_bind_address = weechat_config_new_option (
relay_config_file, ptr_section,
"bind_address", "string",
N_("address for bind (if empty, connection is possible on all "
"interfaces, use \"127.0.0.1\" to allow connections from "
"local machine only)"),
- NULL, 0, 0, "", NULL, 0, NULL, NULL,
- &relay_config_change_network_bind_address_cb, NULL, NULL, NULL);
+ NULL, 0, 0, "", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
relay_config_network_clients_purge_delay = weechat_config_new_option (
relay_config_file, ptr_section,
"clients_purge_delay", "integer",
N_("delay for purging disconnected clients (in minutes, 0 = purge "
"clients immediately, -1 = never purge)"),
NULL, -1, 60 * 24 * 30, "0", NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
relay_config_network_compression_level = weechat_config_new_option (
relay_config_file, ptr_section,
"compression_level", "integer",
@@ -735,35 +791,41 @@ relay_config_init ()
"(0 = disable compression, 1 = low compression ... 9 = best "
"compression)"),
NULL, 0, 9, "6", NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
relay_config_network_ipv6 = weechat_config_new_option (
relay_config_file, ptr_section,
"ipv6", "boolean",
N_("listen on IPv6 socket by default (in addition to IPv4 which is "
"default); protocols IPv4 and IPv6 can be forced (individually or "
"together) in the protocol name (see /help relay)"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL,
- &relay_config_change_network_ipv6_cb, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL,
+ &relay_config_change_network_ipv6_cb, NULL, NULL,
+ NULL, NULL, NULL);
relay_config_network_max_clients = weechat_config_new_option (
relay_config_file, ptr_section,
"max_clients", "integer",
- N_("maximum number of clients connecting to a port"),
- NULL, 1, 1024, "5", NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ N_("maximum number of clients connecting to a port (0 = no limit)"),
+ NULL, 0, INT_MAX, "5", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
relay_config_network_password = weechat_config_new_option (
relay_config_file, ptr_section,
"password", "string",
N_("password required by clients to access this relay (empty value "
- "means no password required) (note: content is evaluated, see "
- "/help eval)"),
- NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ "means no password required, see option "
+ "relay.network.allow_empty_password) (note: content is evaluated, "
+ "see /help eval)"),
+ NULL, 0, 0, "", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
relay_config_network_ssl_cert_key = weechat_config_new_option (
relay_config_file, ptr_section,
"ssl_cert_key", "string",
N_("file with SSL certificate and private key (for serving clients "
"with SSL)"),
- NULL, 0, 0, "%h/ssl/relay.pem", NULL, 0, NULL, NULL,
- &relay_config_change_network_ssl_cert_key, NULL, NULL, NULL);
+ NULL, 0, 0, "%h/ssl/relay.pem", NULL, 0,
+ NULL, NULL, NULL,
+ &relay_config_change_network_ssl_cert_key, NULL, NULL,
+ NULL, NULL, NULL);
relay_config_network_ssl_priorities = weechat_config_new_option (
relay_config_file, ptr_section,
"ssl_priorities", "string",
@@ -772,8 +834,9 @@ relay_config_init ()
"manual, common strings are: \"PERFORMANCE\", \"NORMAL\", "
"\"SECURE128\", \"SECURE256\", \"EXPORT\", \"NONE\")"),
NULL, 0, 0, "NORMAL:-VERS-SSL3.0", NULL, 0,
- &relay_config_check_network_ssl_priorities, NULL,
- &relay_config_change_network_ssl_priorities, NULL, NULL, NULL);
+ &relay_config_check_network_ssl_priorities, NULL, NULL,
+ &relay_config_change_network_ssl_priorities, NULL, NULL,
+ NULL, NULL, NULL);
relay_config_network_websocket_allowed_origins = weechat_config_new_option (
relay_config_file, ptr_section,
"websocket_allowed_origins", "string",
@@ -781,15 +844,19 @@ relay_config_init ()
"websockets (case insensitive, use \"(?-i)\" at beginning to make "
"it case sensitive), example: "
"\"^http://(www\\.)?example\\.(com|org)\""),
- NULL, 0, 0, "", NULL, 0, NULL, NULL,
- &relay_config_change_network_websocket_allowed_origins, NULL, NULL, NULL);
+ NULL, 0, 0, "", NULL, 0,
+ NULL, NULL, NULL,
+ &relay_config_change_network_websocket_allowed_origins, NULL, NULL,
+ NULL, NULL, NULL);
/* section irc */
ptr_section = weechat_config_new_section (relay_config_file, "irc",
0, 0,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (relay_config_file);
@@ -803,19 +870,26 @@ relay_config_init ()
"(0 = unlimited, examples: 1440 = one day, 10080 = one week, "
"43200 = one month, 525600 = one year)"),
NULL, 0, INT_MAX, "1440", NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
relay_config_irc_backlog_max_number = weechat_config_new_option (
relay_config_file, ptr_section,
"backlog_max_number", "integer",
N_("maximum number of lines in backlog per IRC channel "
"(0 = unlimited)"),
NULL, 0, INT_MAX, "256", NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
relay_config_irc_backlog_since_last_disconnect = weechat_config_new_option (
relay_config_file, ptr_section,
"backlog_since_last_disconnect", "boolean",
N_("display backlog starting from last client disconnect"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ relay_config_irc_backlog_since_last_message = weechat_config_new_option (
+ relay_config_file, ptr_section,
+ "backlog_since_last_message", "boolean",
+ N_("display backlog starting from your last message"),
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
relay_config_irc_backlog_tags = weechat_config_new_option (
relay_config_file, ptr_section,
"backlog_tags", "string",
@@ -824,8 +898,9 @@ relay_config_init ()
"\"irc_part\", \"irc_quit\", \"irc_nick\", \"irc_privmsg\"), "
"\"*\" = all supported tags"),
NULL, 0, 0, "irc_privmsg", NULL, 0,
- &relay_config_check_irc_backlog_tags, NULL,
- &relay_config_change_irc_backlog_tags, NULL, NULL, NULL);
+ &relay_config_check_irc_backlog_tags, NULL, NULL,
+ &relay_config_change_irc_backlog_tags, NULL, NULL,
+ NULL, NULL, NULL);
relay_config_irc_backlog_time_format = weechat_config_new_option (
relay_config_file, ptr_section,
"backlog_time_format", "string",
@@ -833,16 +908,18 @@ relay_config_init ()
"(not used if server capability \"server-time\" was enabled by "
"client, because time is sent as irc tag); empty string = disable "
"time in backlog messages"),
- NULL, 0, 0, "[%H:%M] ", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "[%H:%M] ", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
/* section port */
- ptr_section = weechat_config_new_section (relay_config_file, "port",
- 1, 1,
- NULL, NULL,
- NULL, NULL,
- NULL, NULL,
- &relay_config_create_option_port, NULL,
- NULL, NULL);
+ ptr_section = weechat_config_new_section (
+ relay_config_file, "port",
+ 1, 1,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ &relay_config_create_option_port, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (relay_config_file);
@@ -866,8 +943,8 @@ relay_config_read ()
rc = weechat_config_read (relay_config_file);
if (rc == WEECHAT_CONFIG_READ_OK)
{
- relay_config_change_network_allowed_ips (NULL, NULL);
- relay_config_change_irc_backlog_tags (NULL, NULL);
+ relay_config_change_network_allowed_ips (NULL, NULL, NULL);
+ relay_config_change_irc_backlog_tags (NULL, NULL, NULL);
}
return rc;
}
diff --git a/src/plugins/relay/relay-config.h b/src/plugins/relay/relay-config.h
index 09c1851c8..6ce0f7364 100644
--- a/src/plugins/relay/relay-config.h
+++ b/src/plugins/relay/relay-config.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -36,6 +36,7 @@ extern struct t_config_option *relay_config_color_text;
extern struct t_config_option *relay_config_color_text_bg;
extern struct t_config_option *relay_config_color_text_selected;
+extern struct t_config_option *relay_config_network_allow_empty_password;
extern struct t_config_option *relay_config_network_allowed_ips;
extern struct t_config_option *relay_config_network_bind_address;
extern struct t_config_option *relay_config_network_clients_purge_delay;
@@ -50,6 +51,7 @@ extern struct t_config_option *relay_config_network_websocket_allowed_origins;
extern struct t_config_option *relay_config_irc_backlog_max_minutes;
extern struct t_config_option *relay_config_irc_backlog_max_number;
extern struct t_config_option *relay_config_irc_backlog_since_last_disconnect;
+extern struct t_config_option *relay_config_irc_backlog_since_last_message;
extern struct t_config_option *relay_config_irc_backlog_tags;
extern struct t_config_option *relay_config_irc_backlog_time_format;
@@ -57,7 +59,7 @@ extern regex_t *relay_config_regex_allowed_ips;
extern regex_t *relay_config_regex_websocket_allowed_origins;
extern struct t_hashtable *relay_config_hashtable_irc_backlog_tags;
-extern int relay_config_create_option_port (void *data,
+extern int relay_config_create_option_port (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
diff --git a/src/plugins/relay/relay-info.c b/src/plugins/relay/relay-info.c
index 05a0bbaa2..7ec3f46cc 100644
--- a/src/plugins/relay/relay-info.c
+++ b/src/plugins/relay/relay-info.c
@@ -1,7 +1,7 @@
/*
* relay-info.c - info and infolist hooks for relay plugin
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -32,7 +32,8 @@
*/
const char *
-relay_info_info_relay_client_count_cb (void *data, const char *info_name,
+relay_info_info_relay_client_count_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
static char str_count[32];
@@ -40,6 +41,7 @@ relay_info_info_relay_client_count_cb (void *data, const char *info_name,
struct t_relay_client *ptr_client;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) info_name;
@@ -69,28 +71,30 @@ relay_info_info_relay_client_count_cb (void *data, const char *info_name,
*/
struct t_infolist *
-relay_info_infolist_relay_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+relay_info_infolist_relay_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
struct t_infolist *ptr_infolist;
struct t_relay_client *ptr_client;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) infolist_name;
(void) arguments;
- if (pointer && !relay_client_valid (pointer))
+ if (obj_pointer && !relay_client_valid (obj_pointer))
return NULL;
ptr_infolist = weechat_infolist_new ();
if (!ptr_infolist)
return NULL;
- if (pointer)
+ if (obj_pointer)
{
/* build list with only one relay */
- if (!relay_client_add_to_infolist (ptr_infolist, pointer))
+ if (!relay_client_add_to_infolist (ptr_infolist, obj_pointer))
{
weechat_infolist_free (ptr_infolist);
return NULL;
@@ -129,12 +133,12 @@ relay_info_init ()
/* TRANSLATORS: please do not translate the status names, they must be used in English */
N_("status name (optional): connecting, waiting_auth, "
"connected, auth_failed, disconnected"),
- &relay_info_info_relay_client_count_cb, NULL);
+ &relay_info_info_relay_client_count_cb, NULL, NULL);
/* infolist hooks */
weechat_hook_infolist (
"relay", N_("list of relay clients"),
N_("relay pointer (optional)"),
NULL,
- &relay_info_infolist_relay_cb, NULL);
+ &relay_info_infolist_relay_cb, NULL, NULL);
}
diff --git a/src/plugins/relay/relay-info.h b/src/plugins/relay/relay-info.h
index 376fa494f..6d0fbe04e 100644
--- a/src/plugins/relay/relay-info.h
+++ b/src/plugins/relay/relay-info.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/relay/relay-network.c b/src/plugins/relay/relay-network.c
index 88c6125a3..07496051e 100644
--- a/src/plugins/relay/relay-network.c
+++ b/src/plugins/relay/relay-network.c
@@ -1,7 +1,7 @@
/*
* relay-network.c - network functions for relay plugin
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/relay/relay-network.h b/src/plugins/relay/relay-network.h
index c881c3ab9..7e2fc43fa 100644
--- a/src/plugins/relay/relay-network.h
+++ b/src/plugins/relay/relay-network.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/relay/relay-raw.c b/src/plugins/relay/relay-raw.c
index e7981b1cc..8f45a6ddd 100644
--- a/src/plugins/relay/relay-raw.c
+++ b/src/plugins/relay/relay-raw.c
@@ -1,7 +1,7 @@
/*
* relay-raw.c - functions for Relay raw data messages
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -72,9 +72,10 @@ relay_raw_open (int switch_to_buffer)
RELAY_RAW_BUFFER_NAME);
if (!relay_raw_buffer)
{
- relay_raw_buffer = weechat_buffer_new (RELAY_RAW_BUFFER_NAME,
- &relay_buffer_input_cb, NULL,
- &relay_buffer_close_cb, NULL);
+ relay_raw_buffer = weechat_buffer_new (
+ RELAY_RAW_BUFFER_NAME,
+ &relay_buffer_input_cb, NULL, NULL,
+ &relay_buffer_close_cb, NULL, NULL);
/* failed to create buffer ? then return */
if (!relay_raw_buffer)
@@ -218,58 +219,26 @@ relay_raw_message_add_to_list (time_t date, const char *prefix,
*/
void
-relay_raw_message_add (struct t_relay_client *client, int flags,
+relay_raw_message_add (struct t_relay_client *client,
+ enum t_relay_client_msg_type msg_type,
+ int flags,
const char *data, int data_size)
{
- char *buf, *buf2, prefix[256], prefix_arrow[16];
- char str_hexa[(16 * 3) + 1], str_ascii[(16 * 2) + 1], str_line[256];
+ char *buf, *buf2, *buf3, prefix[256], prefix_arrow[16];
const unsigned char *ptr_buf;
const char *hexa = "0123456789ABCDEF";
- int pos_buf, pos_buf2, char_size, i, hexa_pos, ascii_pos;
+ int pos_buf, pos_buf2, char_size, i, length;
struct t_relay_raw_message *new_raw_message;
buf = NULL;
buf2 = NULL;
+ buf3 = NULL;
if (flags & RELAY_RAW_FLAG_BINARY)
{
/* binary message */
- buf = malloc ((data_size * 6) + 128 + 1);
- if (buf)
- {
- buf[0] = '\0';
- hexa_pos = 0;
- ascii_pos = 0;
- for (i = 0; i < data_size; i++)
- {
- snprintf (str_hexa + hexa_pos, 4,
- "%02X ", (unsigned char)(data[i]));
- hexa_pos += 3;
- snprintf (str_ascii + ascii_pos, 3, "%c ",
- ((((unsigned char)data[i]) < 32)
- || (((unsigned char)data[i]) > 127)) ?
- '.' : (unsigned char)(data[i]));
- ascii_pos += 2;
- if (ascii_pos == 32)
- {
- if (buf[0])
- strcat (buf, "\n");
- snprintf (str_line, sizeof (str_line),
- "%-48s %s", str_hexa, str_ascii);
- strcat (buf, str_line);
- hexa_pos = 0;
- ascii_pos = 0;
- }
- }
- if (ascii_pos > 0)
- {
- if (buf[0])
- strcat (buf, "\n");
- snprintf (str_line, sizeof (str_line),
- "%-48s %s", str_hexa, str_ascii);
- strcat (buf, str_line);
- }
- }
+ buf = weechat_string_hex_dump (data, data_size, 16, " > ", NULL);
+ snprintf (prefix, sizeof (prefix), " ");
}
else
{
@@ -311,52 +280,68 @@ relay_raw_message_add (struct t_relay_client *client, int flags,
}
}
- /* build prefix with arrow */
- prefix_arrow[0] = '\0';
- switch (flags & (RELAY_RAW_FLAG_RECV | RELAY_RAW_FLAG_SEND))
+ if (!(flags & RELAY_RAW_FLAG_BINARY)
+ || (msg_type == RELAY_CLIENT_MSG_PING)
+ || (msg_type == RELAY_CLIENT_MSG_PONG))
{
- case RELAY_RAW_FLAG_RECV:
- strcpy (prefix_arrow, RELAY_RAW_PREFIX_RECV);
- break;
- case RELAY_RAW_FLAG_SEND:
- strcpy (prefix_arrow, RELAY_RAW_PREFIX_SEND);
- break;
- default:
- if (flags & RELAY_RAW_FLAG_RECV)
+ /* build prefix with arrow */
+ prefix_arrow[0] = '\0';
+ switch (flags & (RELAY_RAW_FLAG_RECV | RELAY_RAW_FLAG_SEND))
+ {
+ case RELAY_RAW_FLAG_RECV:
strcpy (prefix_arrow, RELAY_RAW_PREFIX_RECV);
- else
+ break;
+ case RELAY_RAW_FLAG_SEND:
strcpy (prefix_arrow, RELAY_RAW_PREFIX_SEND);
- break;
- }
+ break;
+ default:
+ if (flags & RELAY_RAW_FLAG_RECV)
+ strcpy (prefix_arrow, RELAY_RAW_PREFIX_RECV);
+ else
+ strcpy (prefix_arrow, RELAY_RAW_PREFIX_SEND);
+ break;
+ }
- if (client)
- {
- snprintf (prefix, sizeof (prefix), "%s[%s%d%s] %s%s%s%s %s%s",
- weechat_color ("chat_delimiters"),
- weechat_color ("chat"),
- client->id,
- weechat_color ("chat_delimiters"),
- weechat_color ("chat_server"),
- relay_protocol_string[client->protocol],
- (client->protocol_args) ? "." : "",
- (client->protocol_args) ? client->protocol_args : "",
- (flags & RELAY_RAW_FLAG_SEND) ?
- weechat_color ("chat_prefix_quit") :
- weechat_color ("chat_prefix_join"),
- prefix_arrow);
+ if (client)
+ {
+ snprintf (prefix, sizeof (prefix), "%s%s %s[%s%d%s] %s%s%s%s",
+ (flags & RELAY_RAW_FLAG_SEND) ?
+ weechat_color ("chat_prefix_quit") :
+ weechat_color ("chat_prefix_join"),
+ prefix_arrow,
+ weechat_color ("chat_delimiters"),
+ weechat_color ("chat"),
+ client->id,
+ weechat_color ("chat_delimiters"),
+ weechat_color ("chat_server"),
+ relay_protocol_string[client->protocol],
+ (client->protocol_args) ? "." : "",
+ (client->protocol_args) ? client->protocol_args : "");
+ }
+ else
+ {
+ snprintf (prefix, sizeof (prefix), "%s%s",
+ (flags & RELAY_RAW_FLAG_SEND) ?
+ weechat_color ("chat_prefix_quit") :
+ weechat_color ("chat_prefix_join"),
+ prefix_arrow);
+ }
}
- else
+
+ length = strlen (relay_client_msg_type_string[msg_type]) +
+ strlen ((buf2) ? buf2 : ((buf) ? buf : data)) + 1;
+ buf3 = malloc (length);
+ if (buf3)
{
- snprintf (prefix, sizeof (prefix), "%s%s",
- (flags & RELAY_RAW_FLAG_SEND) ?
- weechat_color ("chat_prefix_quit") :
- weechat_color ("chat_prefix_join"),
- prefix_arrow);
+ snprintf (buf3, length, "%s%s",
+ relay_client_msg_type_string[msg_type],
+ (buf2) ? buf2 : ((buf) ? buf : data));
}
- new_raw_message = relay_raw_message_add_to_list (time (NULL),
- prefix,
- (buf2) ? buf2 : ((buf) ? buf : data));
+ new_raw_message = relay_raw_message_add_to_list (
+ time (NULL),
+ prefix,
+ (buf3) ? buf3 : ((buf2) ? buf2 : ((buf) ? buf : data)));
if (new_raw_message)
{
@@ -370,6 +355,8 @@ relay_raw_message_add (struct t_relay_client *client, int flags,
free (buf);
if (buf2)
free (buf2);
+ if (buf3)
+ free (buf3);
}
/*
@@ -377,14 +364,15 @@ relay_raw_message_add (struct t_relay_client *client, int flags,
*/
void
-relay_raw_print (struct t_relay_client *client, int flags,
+relay_raw_print (struct t_relay_client *client,
+ enum t_relay_client_msg_type msg_type, int flags,
const char *data, int data_size)
{
/* auto-open Relay raw buffer if debug for irc plugin is >= 1 */
if (!relay_raw_buffer && (weechat_relay_plugin->debug >= 1))
relay_raw_open (0);
- relay_raw_message_add (client, flags, data, data_size);
+ relay_raw_message_add (client, msg_type, flags, data, data_size);
}
/*
diff --git a/src/plugins/relay/relay-raw.h b/src/plugins/relay/relay-raw.h
index ef0f8a1b3..4546a2b5d 100644
--- a/src/plugins/relay/relay-raw.h
+++ b/src/plugins/relay/relay-raw.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -20,6 +20,8 @@
#ifndef WEECHAT_RELAY_RAW_H
#define WEECHAT_RELAY_RAW_H 1
+#include "relay-client.h"
+
#define RELAY_RAW_BUFFER_NAME "relay_raw"
#define RELAY_RAW_PREFIX_RECV "-->"
#define RELAY_RAW_PREFIX_SEND "<--"
@@ -47,7 +49,8 @@ extern void relay_raw_open (int switch_to_buffer);
extern struct t_relay_raw_message *relay_raw_message_add_to_list (time_t date,
const char *prefix,
const char *message);
-extern void relay_raw_print (struct t_relay_client *client, int flags,
+extern void relay_raw_print (struct t_relay_client *client,
+ enum t_relay_client_msg_type msg_type, int flags,
const char *data, int data_size);
extern void relay_raw_message_free_all ();
extern int relay_raw_add_to_infolist (struct t_infolist *infolist,
diff --git a/src/plugins/relay/relay-server.c b/src/plugins/relay/relay-server.c
index adfe662d1..9dfa38fdd 100644
--- a/src/plugins/relay/relay-server.c
+++ b/src/plugins/relay/relay-server.c
@@ -1,7 +1,7 @@
/*
* relay-server.c - server functions for relay plugin
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -219,21 +219,23 @@ relay_server_close_socket (struct t_relay_server *server)
*/
int
-relay_server_sock_cb (void *data, int fd)
+relay_server_sock_cb (const void *pointer, void *data, int fd)
{
struct t_relay_server *server;
struct sockaddr_in client_addr;
struct sockaddr_in6 client_addr6;
socklen_t client_addr_size;
void *ptr_addr;
- int client_fd, flags, set;
+ int client_fd, flags, set, max_clients, num_clients_on_port;
char ipv4_address[INET_ADDRSTRLEN + 1], ipv6_address[INET6_ADDRSTRLEN + 1];
char *ptr_ip_address;
+ const char *relay_password;
/* make C compiler happy */
+ (void) data;
(void) fd;
- server = (struct t_relay_server *)data;
+ server = (struct t_relay_server *)pointer;
if (server->ipv6)
{
@@ -260,6 +262,44 @@ relay_server_sock_cb (void *data, int fd)
return WEECHAT_RC_OK;
}
+ /* check if relay password is empty and if it is not allowed */
+ relay_password = weechat_string_eval_expression (
+ weechat_config_string (relay_config_network_password),
+ NULL, NULL, NULL);
+ if (!weechat_config_boolean (relay_config_network_allow_empty_password)
+ && (!relay_password || !relay_password[0]))
+ {
+ weechat_printf (NULL,
+ _("%s%s: cannot accept client because relay password "
+ "is empty, and option "
+ "relay.network.allow_empty_password is off"),
+ weechat_prefix ("error"), RELAY_PLUGIN_NAME);
+ close (client_fd);
+ return WEECHAT_RC_OK;
+ }
+
+ /* check if we have reached the max number of clients on this port */
+ max_clients = weechat_config_integer (relay_config_network_max_clients);
+ if (max_clients > 0)
+ {
+ num_clients_on_port = relay_client_count_active_by_port (server->port);
+ if (num_clients_on_port >= max_clients)
+ {
+ weechat_printf (
+ NULL,
+ NG_("%s%s: client not allowed (max %d client is "
+ "allowed at same time)",
+ "%s%s: client not allowed (max %d clients are "
+ "allowed at same time)",
+ max_clients),
+ weechat_prefix ("error"), RELAY_PLUGIN_NAME,
+ max_clients);
+ close (client_fd);
+ return WEECHAT_RC_OK;
+ }
+ }
+
+ /* get the IP address */
ptr_ip_address = NULL;
if (server->ipv6)
{
@@ -474,9 +514,11 @@ relay_server_create_socket (struct t_relay_server *server)
return 0;
}
- max_clients = weechat_config_integer (relay_config_network_max_clients);
-
- if (listen (server->sock, max_clients) != 0)
+#ifdef SOMAXCONN
+ if (listen (server->sock, SOMAXCONN) != 0)
+#else
+ if (listen (server->sock, 1) != 0)
+#endif
{
weechat_printf (NULL,
_("%s%s: cannot \"listen\" on port %d (%s): error %d %s"),
@@ -488,18 +530,34 @@ relay_server_create_socket (struct t_relay_server *server)
return 0;
}
- weechat_printf (NULL,
- _("%s: listening on port %d (relay: %s, %s, max %d clients)"),
- RELAY_PLUGIN_NAME,
- server->port,
- server->protocol_string,
- ((server->ipv4 && server->ipv6) ? "IPv4+6" : ((server->ipv6) ? "IPv6" : "IPv4")),
- max_clients);
-
+ max_clients = weechat_config_integer (relay_config_network_max_clients);
+ if (max_clients > 0)
+ {
+ weechat_printf (
+ NULL,
+ NG_("%s: listening on port %d (relay: %s, %s, max %d client)",
+ "%s: listening on port %d (relay: %s, %s, max %d clients)",
+ max_clients),
+ RELAY_PLUGIN_NAME,
+ server->port,
+ server->protocol_string,
+ ((server->ipv4 && server->ipv6) ? "IPv4+6" : ((server->ipv6) ? "IPv6" : "IPv4")),
+ max_clients);
+ }
+ else
+ {
+ weechat_printf (
+ NULL,
+ _("%s: listening on port %d (relay: %s, %s)"),
+ RELAY_PLUGIN_NAME,
+ server->port,
+ server->protocol_string,
+ ((server->ipv4 && server->ipv6) ? "IPv4+6" : ((server->ipv6) ? "IPv6" : "IPv4")));
+ }
server->hook_fd = weechat_hook_fd (server->sock,
1, 0, 0,
&relay_server_sock_cb,
- server);
+ server, NULL);
server->start_time = time (NULL);
diff --git a/src/plugins/relay/relay-server.h b/src/plugins/relay/relay-server.h
index 2323d21ea..64212bad5 100644
--- a/src/plugins/relay/relay-server.h
+++ b/src/plugins/relay/relay-server.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/relay/relay-upgrade.c b/src/plugins/relay/relay-upgrade.c
index bfdcaa358..5868d94a6 100644
--- a/src/plugins/relay/relay-upgrade.c
+++ b/src/plugins/relay/relay-upgrade.c
@@ -1,7 +1,7 @@
/*
* relay-upgrade.c - save/restore relay plugin data when upgrading WeeChat
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -126,7 +126,8 @@ relay_upgrade_save ()
int rc;
struct t_upgrade_file *upgrade_file;
- upgrade_file = weechat_upgrade_new (RELAY_UPGRADE_FILENAME, 1);
+ upgrade_file = weechat_upgrade_new (RELAY_UPGRADE_FILENAME,
+ NULL, NULL, NULL);
if (!upgrade_file)
return 0;
@@ -179,7 +180,7 @@ relay_upgrade_set_buffer_callbacks ()
*/
int
-relay_upgrade_read_cb (void *data,
+relay_upgrade_read_cb (const void *pointer, void *data,
struct t_upgrade_file *upgrade_file,
int object_id,
struct t_infolist *infolist)
@@ -188,6 +189,7 @@ relay_upgrade_read_cb (void *data,
struct t_relay_server *ptr_server;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) upgrade_file;
@@ -239,10 +241,13 @@ relay_upgrade_load ()
relay_upgrade_set_buffer_callbacks ();
- upgrade_file = weechat_upgrade_new (RELAY_UPGRADE_FILENAME, 0);
+ upgrade_file = weechat_upgrade_new (RELAY_UPGRADE_FILENAME,
+ &relay_upgrade_read_cb, NULL, NULL);
if (!upgrade_file)
return 0;
- rc = weechat_upgrade_read (upgrade_file, &relay_upgrade_read_cb, NULL);
+
+ rc = weechat_upgrade_read (upgrade_file);
+
weechat_upgrade_close (upgrade_file);
return rc;
diff --git a/src/plugins/relay/relay-upgrade.h b/src/plugins/relay/relay-upgrade.h
index ba842f4a3..995d81bc3 100644
--- a/src/plugins/relay/relay-upgrade.h
+++ b/src/plugins/relay/relay-upgrade.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/relay/relay-websocket.c b/src/plugins/relay/relay-websocket.c
index 91862d65a..e9c1fd410 100644
--- a/src/plugins/relay/relay-websocket.c
+++ b/src/plugins/relay/relay-websocket.c
@@ -1,7 +1,7 @@
/*
* relay-websocket.c - websocket server functions for relay plugin (RFC 6455)
*
- * Copyright (C) 2013-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2013-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -29,6 +29,7 @@
#include "relay.h"
#include "relay-client.h"
#include "relay-config.h"
+#include "relay-websocket.h"
/*
@@ -249,7 +250,8 @@ relay_websocket_send_http (struct t_relay_client *client,
if (message)
{
snprintf (message, length, "HTTP/1.1 %s\r\n\r\n", http);
- relay_client_send (client, message, strlen (message), NULL);
+ relay_client_send (client, RELAY_CLIENT_MSG_STANDARD,
+ message, strlen (message), NULL);
free (message);
}
}
@@ -269,6 +271,7 @@ relay_websocket_decode_frame (const unsigned char *buffer,
unsigned long long *decoded_length)
{
unsigned long long i, index_buffer, length_frame_size, length_frame;
+ unsigned char opcode;
*decoded_length = 0;
index_buffer = 0;
@@ -276,6 +279,8 @@ relay_websocket_decode_frame (const unsigned char *buffer,
/* loop to decode all frames in message */
while (index_buffer + 2 <= buffer_length)
{
+ opcode = buffer[index_buffer] & 15;
+
/*
* check if frame is masked: client MUST send a masked frame; if frame is
* not masked, we MUST reject it and close the connection (see RFC 6455)
@@ -311,13 +316,18 @@ relay_websocket_decode_frame (const unsigned char *buffer,
}
index_buffer += 4;
+ /* copy opcode in decoded data */
+ decoded[*decoded_length] = (opcode == WEBSOCKET_FRAME_OPCODE_PING) ?
+ RELAY_CLIENT_MSG_PING : RELAY_CLIENT_MSG_STANDARD;
+ *decoded_length += 1;
+
/* decode data using masks */
for (i = 0; i < length_frame; i++)
{
decoded[*decoded_length + i] = (int)((unsigned char)buffer[index_buffer + i]) ^ masks[i % 4];
}
decoded[*decoded_length + length_frame] = '\0';
- *decoded_length += length_frame;
+ *decoded_length += length_frame + 1;
index_buffer += length_frame;
}
@@ -334,7 +344,7 @@ relay_websocket_decode_frame (const unsigned char *buffer,
*/
char *
-relay_websocket_encode_frame (struct t_relay_client *client,
+relay_websocket_encode_frame (int opcode,
const char *buffer,
unsigned long long length,
unsigned long long *length_frame)
@@ -348,7 +358,8 @@ relay_websocket_encode_frame (struct t_relay_client *client,
if (!frame)
return NULL;
- frame[0] = (client->send_data_type == RELAY_CLIENT_DATA_TEXT) ? 0x81 : 0x82;
+ frame[0] = 0x80;
+ frame[0] |= opcode;
if (length <= 125)
{
diff --git a/src/plugins/relay/relay-websocket.h b/src/plugins/relay/relay-websocket.h
index a88a8fad0..54eab904a 100644
--- a/src/plugins/relay/relay-websocket.h
+++ b/src/plugins/relay/relay-websocket.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2013-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -20,6 +20,13 @@
#ifndef WEECHAT_RELAY_WEBSOCKET_H
#define WEECHAT_RELAY_WEBSOCKET_H 1
+#define WEBSOCKET_FRAME_OPCODE_CONTINUATION 0x00
+#define WEBSOCKET_FRAME_OPCODE_TEXT 0x01
+#define WEBSOCKET_FRAME_OPCODE_BINARY 0x02
+#define WEBSOCKET_FRAME_OPCODE_CLOSE 0x08
+#define WEBSOCKET_FRAME_OPCODE_PING 0x09
+#define WEBSOCKET_FRAME_OPCODE_PONG 0x0A
+
extern int relay_websocket_is_http_get_weechat (const char *message);
extern void relay_websocket_save_header (struct t_relay_client *client,
const char *message);
@@ -31,7 +38,7 @@ extern int relay_websocket_decode_frame (const unsigned char *buffer,
unsigned long long length,
unsigned char *decoded,
unsigned long long *decoded_length);
-extern char *relay_websocket_encode_frame (struct t_relay_client *client,
+extern char *relay_websocket_encode_frame (int opcode,
const char *buffer,
unsigned long long length,
unsigned long long *length_frame);
diff --git a/src/plugins/relay/relay.c b/src/plugins/relay/relay.c
index ead40834c..06585ecd9 100644
--- a/src/plugins/relay/relay.c
+++ b/src/plugins/relay/relay.c
@@ -1,7 +1,7 @@
/*
* relay.c - network communication between WeeChat and remote client
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -81,7 +81,8 @@ relay_protocol_search (const char *name)
*/
int
-relay_signal_upgrade_cb (void *data, const char *signal, const char *type_data,
+relay_signal_upgrade_cb (const void *pointer, void *data,
+ const char *signal, const char *type_data,
void *signal_data)
{
struct t_relay_server *ptr_server;
@@ -89,6 +90,7 @@ relay_signal_upgrade_cb (void *data, const char *signal, const char *type_data,
int quit, ssl_disconnected;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -150,10 +152,12 @@ relay_signal_upgrade_cb (void *data, const char *signal, const char *type_data,
*/
int
-relay_debug_dump_cb (void *data, const char *signal, const char *type_data,
+relay_debug_dump_cb (const void *pointer, void *data,
+ const char *signal, const char *type_data,
void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -203,8 +207,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
/* hook completions */
relay_completion_init ();
- weechat_hook_signal ("upgrade", &relay_signal_upgrade_cb, NULL);
- weechat_hook_signal ("debug_dump", &relay_debug_dump_cb, NULL);
+ weechat_hook_signal ("upgrade", &relay_signal_upgrade_cb, NULL, NULL);
+ weechat_hook_signal ("debug_dump", &relay_debug_dump_cb, NULL, NULL);
relay_info_init ();
@@ -222,7 +226,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
relay_upgrade_load ();
relay_hook_timer = weechat_hook_timer (1 * 1000, 0, 0,
- &relay_client_timer_cb, NULL);
+ &relay_client_timer_cb, NULL, NULL);
return WEECHAT_RC_OK;
}
diff --git a/src/plugins/relay/relay.h b/src/plugins/relay/relay.h
index 8c1c9219d..f802fdec6 100644
--- a/src/plugins/relay/relay.h
+++ b/src/plugins/relay/relay.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/relay/weechat/relay-weechat-msg.c b/src/plugins/relay/weechat/relay-weechat-msg.c
index ff7a19dfb..ff7aee795 100644
--- a/src/plugins/relay/weechat/relay-weechat-msg.c
+++ b/src/plugins/relay/weechat/relay-weechat-msg.c
@@ -1,7 +1,7 @@
/*
* relay-weechat-msg.c - build binary messages for WeeChat protocol
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -253,7 +253,8 @@ relay_weechat_msg_add_time (struct t_relay_weechat_msg *msg, time_t time)
*/
void
-relay_weechat_msg_hashtable_map_cb (void *data, struct t_hashtable *hashtable,
+relay_weechat_msg_hashtable_map_cb (void *data,
+ struct t_hashtable *hashtable,
const void *key, const void *value)
{
struct t_relay_weechat_msg *msg;
@@ -1057,7 +1058,8 @@ relay_weechat_msg_send (struct t_relay_client *client,
msg->id);
/* send compressed data */
- relay_client_send (client, (const char *)dest, dest_size + 5,
+ relay_client_send (client, RELAY_CLIENT_MSG_STANDARD,
+ (const char *)dest, dest_size + 5,
raw_message);
free (dest);
@@ -1082,7 +1084,8 @@ relay_weechat_msg_send (struct t_relay_client *client,
/* send uncompressed data */
snprintf (raw_message, sizeof (raw_message),
"obj: %d bytes, id: %s", msg->data_size, msg->id);
- relay_client_send (client, msg->data, msg->data_size, raw_message);
+ relay_client_send (client, RELAY_CLIENT_MSG_STANDARD,
+ msg->data, msg->data_size, raw_message);
}
/*
diff --git a/src/plugins/relay/weechat/relay-weechat-msg.h b/src/plugins/relay/weechat/relay-weechat-msg.h
index 4cf988109..8c55ab455 100644
--- a/src/plugins/relay/weechat/relay-weechat-msg.h
+++ b/src/plugins/relay/weechat/relay-weechat-msg.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/relay/weechat/relay-weechat-nicklist.c b/src/plugins/relay/weechat/relay-weechat-nicklist.c
index be719b54d..73f997808 100644
--- a/src/plugins/relay/weechat/relay-weechat-nicklist.c
+++ b/src/plugins/relay/weechat/relay-weechat-nicklist.c
@@ -1,7 +1,7 @@
/*
* relay-weechat-nicklist.c - nicklist functions for WeeChat protocol
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/relay/weechat/relay-weechat-nicklist.h b/src/plugins/relay/weechat/relay-weechat-nicklist.h
index 5ba846470..2aebfaf72 100644
--- a/src/plugins/relay/weechat/relay-weechat-nicklist.h
+++ b/src/plugins/relay/weechat/relay-weechat-nicklist.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/relay/weechat/relay-weechat-protocol.c b/src/plugins/relay/weechat/relay-weechat-protocol.c
index 6227a4987..ab9835b18 100644
--- a/src/plugins/relay/weechat/relay-weechat-protocol.c
+++ b/src/plugins/relay/weechat/relay-weechat-protocol.c
@@ -1,7 +1,7 @@
/*
* relay-weechat-protocol.c - WeeChat protocol for relay to client
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -170,14 +170,14 @@ relay_weechat_protocol_is_sync (struct t_relay_client *ptr_client,
RELAY_WEECHAT_PROTOCOL_CALLBACK(init)
{
char **options, *pos, *password;
- int num_options, i, compression;
+ int i, compression;
RELAY_WEECHAT_PROTOCOL_MIN_ARGS(1);
- options = weechat_string_split (argv_eol[0], ",", 0, 0, &num_options);
+ options = weechat_string_split_command (argv_eol[0], ',');
if (options)
{
- for (i = 0; i < num_options; i++)
+ for (i = 0; options[i]; i++)
{
pos = strchr (options[i], '=');
if (pos)
@@ -208,7 +208,7 @@ RELAY_WEECHAT_PROTOCOL_CALLBACK(init)
}
}
}
- weechat_string_free_split (options);
+ weechat_string_free_split_command (options);
}
return WEECHAT_RC_OK;
@@ -231,11 +231,15 @@ RELAY_WEECHAT_PROTOCOL_CALLBACK(hdata)
msg = relay_weechat_msg_new (id);
if (msg)
{
- if (relay_weechat_msg_add_hdata (msg, argv[0],
- (argc > 1) ? argv_eol[1] : NULL))
+ if (!relay_weechat_msg_add_hdata (msg, argv[0],
+ (argc > 1) ? argv_eol[1] : NULL))
{
- relay_weechat_msg_send (client, msg);
+ relay_weechat_msg_add_type (msg, RELAY_WEECHAT_MSG_OBJ_HDATA);
+ relay_weechat_msg_add_string (msg, NULL); /* h-path */
+ relay_weechat_msg_add_string (msg, NULL); /* keys */
+ relay_weechat_msg_add_int (msg, 0); /* count */
}
+ relay_weechat_msg_send (client, msg);
relay_weechat_msg_free (msg);
}
@@ -359,7 +363,8 @@ RELAY_WEECHAT_PROTOCOL_CALLBACK(nicklist)
*/
int
-relay_weechat_protocol_input_timer_cb (void *data,
+relay_weechat_protocol_input_timer_cb (const void *pointer,
+ void *data,
int remaining_calls)
{
char **timer_args;
@@ -367,9 +372,10 @@ relay_weechat_protocol_input_timer_cb (void *data,
struct t_gui_buffer *ptr_buffer;
/* make C compiler happy */
+ (void) data;
(void) remaining_calls;
- timer_args = (char **)data;
+ timer_args = (char **)pointer;
if (!timer_args)
return WEECHAT_RC_ERROR;
@@ -405,7 +411,7 @@ RELAY_WEECHAT_PROTOCOL_CALLBACK(input)
struct t_gui_buffer *ptr_buffer;
char *pos, **timer_args;
- RELAY_WEECHAT_PROTOCOL_MIN_ARGS(2);
+ RELAY_WEECHAT_PROTOCOL_MIN_ARGS(1);
ptr_buffer = relay_weechat_protocol_get_buffer (argv[0]);
if (!ptr_buffer)
@@ -417,7 +423,7 @@ RELAY_WEECHAT_PROTOCOL_CALLBACK(input)
"\"%s %s\""),
RELAY_PLUGIN_NAME,
command,
- argv_eol[0]);
+ argv[0]);
}
return WEECHAT_RC_OK;
}
@@ -438,7 +444,8 @@ RELAY_WEECHAT_PROTOCOL_CALLBACK(input)
timer_args[1] = strdup (pos + 1);
weechat_hook_timer (1, 0, 1,
&relay_weechat_protocol_input_timer_cb,
- timer_args);
+ timer_args,
+ NULL);
}
}
@@ -450,7 +457,8 @@ RELAY_WEECHAT_PROTOCOL_CALLBACK(input)
*/
int
-relay_weechat_protocol_signal_buffer_cb (void *data, const char *signal,
+relay_weechat_protocol_signal_buffer_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data,
void *signal_data)
{
@@ -463,9 +471,10 @@ relay_weechat_protocol_signal_buffer_cb (void *data, const char *signal,
char cmd_hdata[64], str_signal[128];
/* make C compiler happy */
+ (void) data;
(void) type_data;
- ptr_client = (struct t_relay_client *)data;
+ ptr_client = (struct t_relay_client *)pointer;
if (!ptr_client || !relay_client_valid (ptr_client))
return WEECHAT_RC_OK;
@@ -815,14 +824,16 @@ relay_weechat_protocol_nicklist_map_cb (void *data,
*/
int
-relay_weechat_protocol_timer_nicklist_cb (void *data, int remaining_calls)
+relay_weechat_protocol_timer_nicklist_cb (const void *pointer, void *data,
+ int remaining_calls)
{
struct t_relay_client *ptr_client;
/* make C compiler happy */
+ (void) data;
(void) remaining_calls;
- ptr_client = (struct t_relay_client *)data;
+ ptr_client = (struct t_relay_client *)pointer;
if (!ptr_client || !relay_client_valid (ptr_client))
return WEECHAT_RC_OK;
@@ -842,7 +853,8 @@ relay_weechat_protocol_timer_nicklist_cb (void *data, int remaining_calls)
*/
int
-relay_weechat_protocol_hsignal_nicklist_cb (void *data, const char *signal,
+relay_weechat_protocol_hsignal_nicklist_cb (const void *pointer, void *data,
+ const char *signal,
struct t_hashtable *hashtable)
{
struct t_relay_client *ptr_client;
@@ -852,7 +864,10 @@ relay_weechat_protocol_hsignal_nicklist_cb (void *data, const char *signal,
struct t_relay_weechat_nicklist *ptr_nicklist;
char diff;
- ptr_client = (struct t_relay_client *)data;
+ /* make C compiler happy */
+ (void) data;
+
+ ptr_client = (struct t_relay_client *)pointer;
if (!ptr_client || !relay_client_valid (ptr_client))
return WEECHAT_RC_OK;
@@ -935,7 +950,8 @@ relay_weechat_protocol_hsignal_nicklist_cb (void *data, const char *signal,
*/
int
-relay_weechat_protocol_signal_upgrade_cb (void *data, const char *signal,
+relay_weechat_protocol_signal_upgrade_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data,
void *signal_data)
{
@@ -944,10 +960,11 @@ relay_weechat_protocol_signal_upgrade_cb (void *data, const char *signal,
char str_signal[128];
/* make C compiler happy */
+ (void) data;
(void) type_data;
(void) signal_data;
- ptr_client = (struct t_relay_client *)data;
+ ptr_client = (struct t_relay_client *)pointer;
if (!ptr_client || !relay_client_valid (ptr_client))
return WEECHAT_RC_OK;
@@ -1351,7 +1368,7 @@ relay_weechat_protocol_recv (struct t_relay_client *client, const char *data)
pos++;
}
argv = weechat_string_split (pos, " ", 0, 0, &argc);
- argv_eol = weechat_string_split (pos, " ", 1, 0, NULL);
+ argv_eol = weechat_string_split (pos, " ", 2, 0, NULL);
}
for (i = 0; protocol_cb[i].name; i++)
diff --git a/src/plugins/relay/weechat/relay-weechat-protocol.h b/src/plugins/relay/weechat/relay-weechat-protocol.h
index c69bd9662..6f99d2e74 100644
--- a/src/plugins/relay/weechat/relay-weechat-protocol.h
+++ b/src/plugins/relay/weechat/relay-weechat-protocol.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -81,22 +81,27 @@ struct t_relay_weechat_protocol_cb
t_relay_weechat_cmd_func *cmd_function; /* callback */
};
-extern int relay_weechat_protocol_signal_buffer_cb (void *data,
+extern int relay_weechat_protocol_signal_buffer_cb (const void *pointer,
+ void *data,
const char *signal,
const char *type_data,
void *signal_data);
-extern int relay_weechat_protocol_signal_nicklist_cb (void *data,
+extern int relay_weechat_protocol_signal_nicklist_cb (const void *pointer,
+ void *data,
const char *signal,
const char *type_data,
void *signal_data);
-extern int relay_weechat_protocol_hsignal_nicklist_cb (void *data,
+extern int relay_weechat_protocol_hsignal_nicklist_cb (const void *pointer,
+ void *data,
const char *signal,
struct t_hashtable *hashtable);
-extern int relay_weechat_protocol_signal_upgrade_cb (void *data,
+extern int relay_weechat_protocol_signal_upgrade_cb (const void *pointer,
+ void *data,
const char *signal,
const char *type_data,
void *signal_data);
-extern int relay_weechat_protocol_timer_nicklist_cb (void *data,
+extern int relay_weechat_protocol_timer_nicklist_cb (const void *pointer,
+ void *data,
int remaining_calls);
extern void relay_weechat_protocol_recv (struct t_relay_client *client,
const char *data);
diff --git a/src/plugins/relay/weechat/relay-weechat.c b/src/plugins/relay/weechat/relay-weechat.c
index 10b7b84ac..2956f7a93 100644
--- a/src/plugins/relay/weechat/relay-weechat.c
+++ b/src/plugins/relay/weechat/relay-weechat.c
@@ -1,7 +1,7 @@
/*
* relay-weechat.c - WeeChat protocol for relay to client
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -76,15 +76,15 @@ relay_weechat_hook_signals (struct t_relay_client *client)
RELAY_WEECHAT_DATA(client, hook_signal_buffer) =
weechat_hook_signal ("buffer_*",
&relay_weechat_protocol_signal_buffer_cb,
- client);
+ client, NULL);
RELAY_WEECHAT_DATA(client, hook_hsignal_nicklist) =
weechat_hook_hsignal ("nicklist_*",
&relay_weechat_protocol_hsignal_nicklist_cb,
- client);
+ client, NULL);
RELAY_WEECHAT_DATA(client, hook_signal_upgrade) =
weechat_hook_signal ("upgrade*",
&relay_weechat_protocol_signal_upgrade_cb,
- client);
+ client, NULL);
}
/*
@@ -121,7 +121,7 @@ relay_weechat_hook_timer_nicklist (struct t_relay_client *client)
RELAY_WEECHAT_DATA(client, hook_timer_nicklist) =
weechat_hook_timer (100, 0, 1,
&relay_weechat_protocol_timer_nicklist_cb,
- client);
+ client, NULL);
}
/*
@@ -181,8 +181,7 @@ relay_weechat_alloc (struct t_relay_client *client)
weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_INTEGER,
- NULL,
- NULL);
+ NULL, NULL);
RELAY_WEECHAT_DATA(client, hook_signal_buffer) = NULL;
RELAY_WEECHAT_DATA(client, hook_hsignal_nicklist) = NULL;
RELAY_WEECHAT_DATA(client, hook_signal_upgrade) = NULL;
@@ -190,8 +189,7 @@ relay_weechat_alloc (struct t_relay_client *client)
weechat_hashtable_new (32,
WEECHAT_HASHTABLE_POINTER,
WEECHAT_HASHTABLE_POINTER,
- NULL,
- NULL);
+ NULL, NULL);
weechat_hashtable_set_pointer (RELAY_WEECHAT_DATA(client, buffers_nicklist),
"callback_free_value",
&relay_weechat_free_buffers_nicklist);
@@ -223,15 +221,17 @@ relay_weechat_alloc_with_infolist (struct t_relay_client *client,
if (client->protocol_data)
{
/* general stuff */
- RELAY_WEECHAT_DATA(client, password_ok) = weechat_infolist_integer (infolist, "password_ok");
- RELAY_WEECHAT_DATA(client, compression) = weechat_infolist_integer (infolist, "compression");
+ RELAY_WEECHAT_DATA(client, password_ok) = weechat_infolist_integer (
+ infolist, "password_ok");
+ RELAY_WEECHAT_DATA(client, compression) = weechat_infolist_integer (
+ infolist, "compression");
/* sync of buffers */
- RELAY_WEECHAT_DATA(client, buffers_sync) = weechat_hashtable_new (32,
- WEECHAT_HASHTABLE_STRING,
- WEECHAT_HASHTABLE_INTEGER,
- NULL,
- NULL);
+ RELAY_WEECHAT_DATA(client, buffers_sync) = weechat_hashtable_new (
+ 32,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_INTEGER,
+ NULL, NULL);
index = 0;
while (1)
{
@@ -253,8 +253,7 @@ relay_weechat_alloc_with_infolist (struct t_relay_client *client,
weechat_hashtable_new (32,
WEECHAT_HASHTABLE_POINTER,
WEECHAT_HASHTABLE_POINTER,
- NULL,
- NULL);
+ NULL, NULL);
weechat_hashtable_set_pointer (RELAY_WEECHAT_DATA(client, buffers_nicklist),
"callback_free_value",
&relay_weechat_free_buffers_nicklist);
diff --git a/src/plugins/relay/weechat/relay-weechat.h b/src/plugins/relay/weechat/relay-weechat.h
index b07a0c2a7..678845b91 100644
--- a/src/plugins/relay/weechat/relay-weechat.h
+++ b/src/plugins/relay/weechat/relay-weechat.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/ruby/CMakeLists.txt b/src/plugins/ruby/CMakeLists.txt
index eb513f78d..2d03858c5 100644
--- a/src/plugins/ruby/CMakeLists.txt
+++ b/src/plugins/ruby/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/ruby/Makefile.am b/src/plugins/ruby/Makefile.am
index c03eca335..01c3e932d 100644
--- a/src/plugins/ruby/Makefile.am
+++ b/src/plugins/ruby/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/ruby/weechat-ruby-api.c b/src/plugins/ruby/weechat-ruby-api.c
index a8bb43612..9b705afba 100644
--- a/src/plugins/ruby/weechat-ruby-api.c
+++ b/src/plugins/ruby/weechat-ruby-api.c
@@ -1,7 +1,7 @@
/*
* weechat-ruby-api.c - ruby API functions
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2005-2007 Emmanuel Bouthenot <kolter@openics.org>
* Copyright (C) 2012 Simon Arlott
*
@@ -29,7 +29,6 @@
#include "../weechat-plugin.h"
#include "../plugin-script.h"
#include "../plugin-script-api.h"
-#include "../plugin-script-callback.h"
#include "weechat-ruby.h"
@@ -921,24 +920,26 @@ weechat_ruby_api_list_free (VALUE class, VALUE weelist)
}
int
-weechat_ruby_api_config_reload_cb (void *data,
+weechat_ruby_api_config_reload_cb (const void *pointer, void *data,
struct t_config_file *config_file)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
- rc = (int *) weechat_ruby_exec (script_callback->script,
+ rc = (int *) weechat_ruby_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (!rc)
@@ -987,29 +988,31 @@ weechat_ruby_api_config_new (VALUE class, VALUE name, VALUE function,
}
int
-weechat_ruby_api_config_read_cb (void *data,
+weechat_ruby_api_config_read_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name, const char *value)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[5];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = API_PTR2STR(section);
func_argv[3] = (option_name) ? (char *)option_name : empty_arg;
func_argv[4] = (value) ? (char *)value : empty_arg;
- rc = (int *) weechat_ruby_exec (script_callback->script,
+ rc = (int *) weechat_ruby_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sssss", func_argv);
if (!rc)
@@ -1031,26 +1034,28 @@ weechat_ruby_api_config_read_cb (void *data,
}
int
-weechat_ruby_api_config_section_write_cb (void *data,
+weechat_ruby_api_config_section_write_cb (const void *pointer, void *data,
struct t_config_file *config_file,
const char *section_name)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = (section_name) ? (char *)section_name : empty_arg;
- rc = (int *) weechat_ruby_exec (script_callback->script,
+ rc = (int *) weechat_ruby_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -1070,26 +1075,28 @@ weechat_ruby_api_config_section_write_cb (void *data,
}
int
-weechat_ruby_api_config_section_write_default_cb (void *data,
+weechat_ruby_api_config_section_write_default_cb (const void *pointer, void *data,
struct t_config_file *config_file,
const char *section_name)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = (section_name) ? (char *)section_name : empty_arg;
- rc = (int *) weechat_ruby_exec (script_callback->script,
+ rc = (int *) weechat_ruby_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -1109,30 +1116,32 @@ weechat_ruby_api_config_section_write_default_cb (void *data,
}
int
-weechat_ruby_api_config_section_create_option_cb (void *data,
+weechat_ruby_api_config_section_create_option_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
const char *value)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[5];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = API_PTR2STR(section);
func_argv[3] = (option_name) ? (char *)option_name : empty_arg;
func_argv[4] = (value) ? (char *)value : empty_arg;
- rc = (int *) weechat_ruby_exec (script_callback->script,
+ rc = (int *) weechat_ruby_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sssss", func_argv);
if (!rc)
@@ -1154,28 +1163,30 @@ weechat_ruby_api_config_section_create_option_cb (void *data,
}
int
-weechat_ruby_api_config_section_delete_option_cb (void *data,
+weechat_ruby_api_config_section_delete_option_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
struct t_config_option *option)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = API_PTR2STR(section);
func_argv[3] = API_PTR2STR(option);
- rc = (int *) weechat_ruby_exec (script_callback->script,
+ rc = (int *) weechat_ruby_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssss", func_argv);
if (!rc)
@@ -1260,27 +1271,29 @@ weechat_ruby_api_config_new_section (VALUE class, VALUE config_file,
c_function_delete_option = StringValuePtr (function_delete_option);
c_data_delete_option = StringValuePtr (data_delete_option);
- result = API_PTR2STR(plugin_script_api_config_new_section (weechat_ruby_plugin,
- ruby_current_script,
- API_STR2PTR(c_config_file),
- c_name,
- c_user_can_add_options,
- c_user_can_delete_options,
- &weechat_ruby_api_config_read_cb,
- c_function_read,
- c_data_read,
- &weechat_ruby_api_config_section_write_cb,
- c_function_write,
- c_data_write,
- &weechat_ruby_api_config_section_write_default_cb,
- c_function_write_default,
- c_data_write_default,
- &weechat_ruby_api_config_section_create_option_cb,
- c_function_create_option,
- c_data_create_option,
- &weechat_ruby_api_config_section_delete_option_cb,
- c_function_delete_option,
- c_data_delete_option));
+ result = API_PTR2STR(
+ plugin_script_api_config_new_section (
+ weechat_ruby_plugin,
+ ruby_current_script,
+ API_STR2PTR(c_config_file),
+ c_name,
+ c_user_can_add_options,
+ c_user_can_delete_options,
+ &weechat_ruby_api_config_read_cb,
+ c_function_read,
+ c_data_read,
+ &weechat_ruby_api_config_section_write_cb,
+ c_function_write,
+ c_data_write,
+ &weechat_ruby_api_config_section_write_default_cb,
+ c_function_write_default,
+ c_data_write_default,
+ &weechat_ruby_api_config_section_create_option_cb,
+ c_function_create_option,
+ c_data_create_option,
+ &weechat_ruby_api_config_section_delete_option_cb,
+ c_function_delete_option,
+ c_data_delete_option));
API_RETURN_STRING_FREE(result);
}
@@ -1309,26 +1322,28 @@ weechat_ruby_api_config_search_section (VALUE class, VALUE config_file,
}
int
-weechat_ruby_api_config_option_check_value_cb (void *data,
+weechat_ruby_api_config_option_check_value_cb (const void *pointer, void *data,
struct t_config_option *option,
const char *value)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(option);
func_argv[2] = (value) ? (char *)value : empty_arg;
- rc = (int *) weechat_ruby_exec (script_callback->script,
+ rc = (int *) weechat_ruby_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -1348,24 +1363,26 @@ weechat_ruby_api_config_option_check_value_cb (void *data,
}
void
-weechat_ruby_api_config_option_change_cb (void *data,
+weechat_ruby_api_config_option_change_cb (const void *pointer, void *data,
struct t_config_option *option)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(option);
- rc = (int *) weechat_ruby_exec (script_callback->script,
+ rc = (int *) weechat_ruby_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (func_argv[1])
@@ -1377,24 +1394,26 @@ weechat_ruby_api_config_option_change_cb (void *data,
}
void
-weechat_ruby_api_config_option_delete_cb (void *data,
+weechat_ruby_api_config_option_delete_cb (const void *pointer, void *data,
struct t_config_option *option)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(option);
- rc = (int *) weechat_ruby_exec (script_callback->script,
+ rc = (int *) weechat_ruby_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (func_argv[1])
@@ -1965,9 +1984,7 @@ weechat_ruby_api_config_option_free (VALUE class, VALUE option)
c_option = StringValuePtr (option);
- plugin_script_api_config_option_free (weechat_ruby_plugin,
- ruby_current_script,
- API_STR2PTR(c_option));
+ weechat_config_option_free (API_STR2PTR(c_option));
API_RETURN_OK;
}
@@ -1985,9 +2002,7 @@ weechat_ruby_api_config_section_free_options (VALUE class, VALUE section)
c_section = StringValuePtr (section);
- plugin_script_api_config_section_free_options (weechat_ruby_plugin,
- ruby_current_script,
- API_STR2PTR(c_section));
+ weechat_config_section_free_options (API_STR2PTR(c_section));
API_RETURN_OK;
}
@@ -2005,9 +2020,7 @@ weechat_ruby_api_config_section_free (VALUE class, VALUE section)
c_section = StringValuePtr (section);
- plugin_script_api_config_section_free (weechat_ruby_plugin,
- ruby_current_script,
- API_STR2PTR(c_section));
+ weechat_config_section_free (API_STR2PTR(c_section));
API_RETURN_OK;
}
@@ -2025,9 +2038,7 @@ weechat_ruby_api_config_free (VALUE class, VALUE config_file)
c_config_file = StringValuePtr (config_file);
- plugin_script_api_config_free (weechat_ruby_plugin,
- ruby_current_script,
- API_STR2PTR(c_config_file));
+ weechat_config_free (API_STR2PTR(c_config_file));
API_RETURN_OK;
}
@@ -2351,28 +2362,31 @@ weechat_ruby_api_log_print (VALUE class, VALUE message)
}
int
-weechat_ruby_api_hook_command_cb (void *data, struct t_gui_buffer *buffer,
+weechat_ruby_api_hook_command_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
/* make C compiler happy */
(void) argv;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
func_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg;
- rc = (int *) weechat_ruby_exec (script_callback->script,
+ rc = (int *) weechat_ruby_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -2437,25 +2451,28 @@ weechat_ruby_api_hook_command (VALUE class, VALUE command, VALUE description,
}
int
-weechat_ruby_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
+weechat_ruby_api_hook_command_run_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
const char *command)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
func_argv[2] = (command) ? (char *)command : empty_arg;
- rc = (int *) weechat_ruby_exec (script_callback->script,
+ rc = (int *) weechat_ruby_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -2504,26 +2521,29 @@ weechat_ruby_api_hook_command_run (VALUE class, VALUE command, VALUE function,
}
int
-weechat_ruby_api_hook_timer_cb (void *data, int remaining_calls)
+weechat_ruby_api_hook_timer_cb (const void *pointer, void *data,
+ int remaining_calls)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char str_remaining_calls[32], empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (str_remaining_calls, sizeof (str_remaining_calls),
"%d", remaining_calls);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = str_remaining_calls;
- rc = (int *) weechat_ruby_exec (script_callback->script,
+ rc = (int *) weechat_ruby_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (!rc)
@@ -2578,25 +2598,27 @@ weechat_ruby_api_hook_timer (VALUE class, VALUE interval, VALUE align_second,
}
int
-weechat_ruby_api_hook_fd_cb (void *data, int fd)
+weechat_ruby_api_hook_fd_cb (const void *pointer, void *data, int fd)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char str_fd[32], empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (str_fd, sizeof (str_fd), "%d", fd);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = str_fd;
- rc = (int *) weechat_ruby_exec (script_callback->script,
+ rc = (int *) weechat_ruby_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (!rc)
@@ -2654,28 +2676,49 @@ weechat_ruby_api_hook_fd (VALUE class, VALUE fd, VALUE read, VALUE write,
}
int
-weechat_ruby_api_hook_process_cb (void *data,
+weechat_ruby_api_hook_process_cb (const void *pointer, void *data,
const char *command, int return_code,
const char *out, const char *err)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[5];
- char empty_arg[1] = { '\0' };
+ char empty_arg[1] = { '\0' }, *result;
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (return_code == WEECHAT_HOOK_PROCESS_CHILD)
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ if (strncmp (command, "func:", 5) == 0)
+ {
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
+
+ result = (char *) weechat_ruby_exec (script,
+ WEECHAT_SCRIPT_EXEC_STRING,
+ command + 5,
+ "s", func_argv);
+ if (result)
+ {
+ printf ("%s", result);
+ free (result);
+ return 0;
+ }
+ }
+ return 1;
+ }
+ else if (ptr_function && ptr_function[0])
+ {
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (command) ? (char *)command : empty_arg;
func_argv[2] = &return_code;
func_argv[3] = (out) ? (char *)out : empty_arg;
func_argv[4] = (err) ? (char *)err : empty_arg;
- rc = (int *) weechat_ruby_exec (script_callback->script,
+ rc = (int *) weechat_ruby_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssiss", func_argv);
if (!rc)
@@ -2771,34 +2814,37 @@ weechat_ruby_api_hook_process_hashtable (VALUE class, VALUE command,
}
int
-weechat_ruby_api_hook_connect_cb (void *data, int status, int gnutls_rc,
+weechat_ruby_api_hook_connect_cb (const void *pointer, void *data,
+ int status, int gnutls_rc,
int sock, const char *error,
const char *ip_address)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[6];
char str_status[32], str_gnutls_rc[32], str_sock[32];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (str_status, sizeof (str_status), "%d", status);
snprintf (str_gnutls_rc, sizeof (str_gnutls_rc), "%d", gnutls_rc);
snprintf (str_sock, sizeof (str_sock), "%d", sock);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = str_status;
func_argv[2] = str_gnutls_rc;
func_argv[3] = str_sock;
func_argv[4] = (ip_address) ? (char *)ip_address : empty_arg;
func_argv[5] = (error) ? (char *)error : empty_arg;
- rc = (int *) weechat_ruby_exec (script_callback->script,
+ rc = (int *) weechat_ruby_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssssss", func_argv);
if (!rc)
@@ -2869,28 +2915,31 @@ weechat_ruby_api_hook_connect (VALUE class, VALUE proxy, VALUE address,
}
int
-weechat_ruby_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
+weechat_ruby_api_hook_print_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
time_t date,
int tags_count, const char **tags,
int displayed, int highlight,
const char *prefix, const char *message)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[8];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
static char timebuffer[64];
int *rc, ret;
/* make C compiler happy */
(void) tags_count;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (timebuffer, sizeof (timebuffer), "%ld", (long int)date);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
func_argv[2] = timebuffer;
func_argv[3] = weechat_string_build_with_split_string (tags, ",");
@@ -2901,9 +2950,9 @@ weechat_ruby_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
func_argv[6] = (prefix) ? (char *)prefix : empty_arg;
func_argv[7] = (message) ? (char *)message : empty_arg;
- rc = (int *) weechat_ruby_exec (script_callback->script,
+ rc = (int *) weechat_ruby_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssssiiss", func_argv);
if (!rc)
@@ -2966,20 +3015,23 @@ weechat_ruby_api_hook_print (VALUE class, VALUE buffer, VALUE tags,
}
int
-weechat_ruby_api_hook_signal_cb (void *data, const char *signal, const char *type_data,
+weechat_ruby_api_hook_signal_cb (const void *pointer, void *data,
+ const char *signal, const char *type_data,
void *signal_data)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
static char str_value[64];
int *rc, ret, free_needed;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (signal) ? (char *)signal : empty_arg;
free_needed = 0;
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
@@ -3004,9 +3056,9 @@ weechat_ruby_api_hook_signal_cb (void *data, const char *signal, const char *typ
else
func_argv[2] = empty_arg;
- rc = (int *) weechat_ruby_exec (script_callback->script,
+ rc = (int *) weechat_ruby_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -3098,25 +3150,28 @@ weechat_ruby_api_hook_signal_send (VALUE class, VALUE signal, VALUE type_data,
}
int
-weechat_ruby_api_hook_hsignal_cb (void *data, const char *signal,
+weechat_ruby_api_hook_hsignal_cb (const void *pointer, void *data,
+ const char *signal,
struct t_hashtable *hashtable)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (signal) ? (char *)signal : empty_arg;
func_argv[2] = hashtable;
- rc = (int *) weechat_ruby_exec (script_callback->script,
+ rc = (int *) weechat_ruby_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssh", func_argv);
if (!rc)
@@ -3191,24 +3246,27 @@ weechat_ruby_api_hook_hsignal_send (VALUE class, VALUE signal, VALUE hashtable)
}
int
-weechat_ruby_api_hook_config_cb (void *data, const char *option, const char *value)
+weechat_ruby_api_hook_config_cb (const void *pointer, void *data,
+ const char *option, const char *value)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (option) ? (char *)option : empty_arg;
func_argv[2] = (value) ? (char *)value : empty_arg;
- rc = (int *) weechat_ruby_exec (script_callback->script,
+ rc = (int *) weechat_ruby_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -3255,27 +3313,30 @@ weechat_ruby_api_hook_config (VALUE class, VALUE option, VALUE function,
}
int
-weechat_ruby_api_hook_completion_cb (void *data, const char *completion_item,
+weechat_ruby_api_hook_completion_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (completion_item) ? (char *)completion_item : empty_arg;
func_argv[2] = API_PTR2STR(buffer);
func_argv[3] = API_PTR2STR(completion);
- rc = (int *) weechat_ruby_exec (script_callback->script,
+ rc = (int *) weechat_ruby_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssss", func_argv);
if (!rc)
@@ -3385,25 +3446,29 @@ weechat_ruby_api_hook_completion_list_add (VALUE class, VALUE completion,
}
char *
-weechat_ruby_api_hook_modifier_cb (void *data, const char *modifier,
- const char *modifier_data, const char *string)
+weechat_ruby_api_hook_modifier_cb (const void *pointer, void *data,
+ const char *modifier,
+ const char *modifier_data,
+ const char *string)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (modifier) ? (char *)modifier : empty_arg;
func_argv[2] = (modifier_data) ? (char *)modifier_data : empty_arg;
func_argv[3] = (string) ? (char *)string : empty_arg;
- return (char *)weechat_ruby_exec (script_callback->script,
+ return (char *)weechat_ruby_exec (script,
WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function,
+ ptr_function,
"ssss", func_argv);
}
@@ -3464,24 +3529,27 @@ weechat_ruby_api_hook_modifier_exec (VALUE class, VALUE modifier,
}
const char *
-weechat_ruby_api_hook_info_cb (void *data, const char *info_name,
+weechat_ruby_api_hook_info_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (info_name) ? (char *)info_name : empty_arg;
func_argv[2] = (arguments) ? (char *)arguments : empty_arg;
- return (const char *)weechat_ruby_exec (script_callback->script,
+ return (const char *)weechat_ruby_exec (script,
WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
}
@@ -3526,25 +3594,29 @@ weechat_ruby_api_hook_info (VALUE class, VALUE info_name, VALUE description,
}
struct t_hashtable *
-weechat_ruby_api_hook_info_hashtable_cb (void *data, const char *info_name,
+weechat_ruby_api_hook_info_hashtable_cb (const void *pointer, void *data,
+ const char *info_name,
struct t_hashtable *hashtable)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (info_name) ? (char *)info_name : empty_arg;
func_argv[2] = hashtable;
- return (struct t_hashtable *)weechat_ruby_exec (script_callback->script,
- WEECHAT_SCRIPT_EXEC_HASHTABLE,
- script_callback->function,
- "ssh", func_argv);
+ return (struct t_hashtable *)weechat_ruby_exec (
+ script,
+ WEECHAT_SCRIPT_EXEC_HASHTABLE,
+ ptr_function,
+ "ssh", func_argv);
}
return NULL;
@@ -3595,27 +3667,31 @@ weechat_ruby_api_hook_info_hashtable (VALUE class, VALUE info_name,
}
struct t_infolist *
-weechat_ruby_api_hook_infolist_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+weechat_ruby_api_hook_infolist_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
struct t_infolist *result;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (infolist_name) ? (char *)infolist_name : empty_arg;
- func_argv[2] = API_PTR2STR(pointer);
+ func_argv[2] = API_PTR2STR(obj_pointer);
func_argv[3] = (arguments) ? (char *)arguments : empty_arg;
- result = (struct t_infolist *)weechat_ruby_exec (script_callback->script,
- WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function,
- "ssss", func_argv);
+ result = (struct t_infolist *)weechat_ruby_exec (
+ script,
+ WEECHAT_SCRIPT_EXEC_STRING,
+ ptr_function,
+ "ssss", func_argv);
if (func_argv[2])
free (func_argv[2]);
@@ -3670,23 +3746,27 @@ weechat_ruby_api_hook_infolist (VALUE class, VALUE infolist_name,
}
struct t_hashtable *
-weechat_ruby_api_hook_focus_cb (void *data, struct t_hashtable *info)
+weechat_ruby_api_hook_focus_cb (const void *pointer, void *data,
+ struct t_hashtable *info)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = info;
- return (struct t_hashtable *)weechat_ruby_exec (script_callback->script,
- WEECHAT_SCRIPT_EXEC_HASHTABLE,
- script_callback->function,
- "sh", func_argv);
+ return (struct t_hashtable *)weechat_ruby_exec (
+ script,
+ WEECHAT_SCRIPT_EXEC_HASHTABLE,
+ ptr_function,
+ "sh", func_argv);
}
return NULL;
@@ -3759,9 +3839,7 @@ weechat_ruby_api_unhook (VALUE class, VALUE hook)
c_hook = StringValuePtr (hook);
- plugin_script_api_unhook (weechat_ruby_plugin,
- ruby_current_script,
- API_STR2PTR(c_hook));
+ weechat_unhook (API_STR2PTR(c_hook));
API_RETURN_OK;
}
@@ -3771,31 +3849,34 @@ weechat_ruby_api_unhook_all (VALUE class)
{
API_INIT_FUNC(1, "unhook_all", API_RETURN_ERROR);
- plugin_script_api_unhook_all (weechat_ruby_plugin, ruby_current_script);
+ weechat_unhook_all (ruby_current_script->name);
API_RETURN_OK;
}
int
-weechat_ruby_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
+weechat_ruby_api_buffer_input_data_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
const char *input_data)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
func_argv[2] = (input_data) ? (char *)input_data : empty_arg;
- rc = (int *) weechat_ruby_exec (script_callback->script,
+ rc = (int *) weechat_ruby_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -3815,23 +3896,26 @@ weechat_ruby_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
}
int
-weechat_ruby_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
+weechat_ruby_api_buffer_close_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
- rc = (int *) weechat_ruby_exec (script_callback->script,
+ rc = (int *) weechat_ruby_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (!rc)
@@ -3967,9 +4051,7 @@ weechat_ruby_api_buffer_close (VALUE class, VALUE buffer)
c_buffer = StringValuePtr (buffer);
- plugin_script_api_buffer_close (weechat_ruby_plugin,
- ruby_current_script,
- API_STR2PTR(c_buffer));
+ weechat_buffer_close (API_STR2PTR(c_buffer));
API_RETURN_OK;
}
@@ -4687,31 +4769,34 @@ weechat_ruby_api_bar_item_search (VALUE class, VALUE name)
}
char *
-weechat_ruby_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
+weechat_ruby_api_bar_item_build_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
struct t_gui_window *window,
struct t_gui_buffer *buffer,
struct t_hashtable *extra_info)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[5];
char empty_arg[1] = { '\0' }, *ret;
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- if (strncmp (script_callback->function, "(extra)", 7) == 0)
+ if (strncmp (ptr_function, "(extra)", 7) == 0)
{
/* new callback: data, item, window, buffer, extra_info */
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(item);
func_argv[2] = API_PTR2STR(window);
func_argv[3] = API_PTR2STR(buffer);
func_argv[4] = extra_info;
- ret = (char *)weechat_ruby_exec (script_callback->script,
+ ret = (char *)weechat_ruby_exec (script,
WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function + 7,
+ ptr_function + 7,
"ssssh", func_argv);
if (func_argv[1])
@@ -4724,13 +4809,13 @@ weechat_ruby_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
else
{
/* old callback: data, item, window */
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(item);
func_argv[2] = API_PTR2STR(window);
- ret = (char *)weechat_ruby_exec (script_callback->script,
+ ret = (char *)weechat_ruby_exec (script,
WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (func_argv[1])
@@ -4805,9 +4890,7 @@ weechat_ruby_api_bar_item_remove (VALUE class, VALUE item)
c_item = StringValuePtr (item);
- plugin_script_api_bar_item_remove (weechat_ruby_plugin,
- ruby_current_script,
- API_STR2PTR(c_item));
+ weechat_bar_item_remove (API_STR2PTR(c_item));
API_RETURN_OK;
}
@@ -5888,25 +5971,80 @@ weechat_ruby_api_hdata_get_string (VALUE class, VALUE hdata, VALUE property)
API_RETURN_STRING(result);
}
+int
+weechat_ruby_api_upgrade_read_cb (const void *pointer, void *data,
+ struct t_upgrade_file *upgrade_file,
+ int object_id,
+ struct t_infolist *infolist)
+{
+ struct t_plugin_script *script;
+ void *func_argv[4];
+ char empty_arg[1] = { '\0' }, str_object_id[32];
+ const char *ptr_function, *ptr_data;
+ int *rc, ret;
+
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
+
+ if (ptr_function && ptr_function[0])
+ {
+ snprintf (str_object_id, sizeof (str_object_id), "%d", object_id);
+
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
+ func_argv[1] = API_PTR2STR(upgrade_file);
+ func_argv[2] = str_object_id;
+ func_argv[3] = API_PTR2STR(infolist);
+
+ rc = (int *) weechat_ruby_exec (script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ ptr_function,
+ "ssss", func_argv);
+
+ if (!rc)
+ ret = WEECHAT_RC_ERROR;
+ else
+ {
+ ret = *rc;
+ free (rc);
+ }
+ if (func_argv[1])
+ free (func_argv[1]);
+ if (func_argv[3])
+ free (func_argv[3]);
+
+ return ret;
+ }
+
+ return WEECHAT_RC_ERROR;
+}
+
static VALUE
-weechat_ruby_api_upgrade_new (VALUE class, VALUE filename, VALUE write)
+weechat_ruby_api_upgrade_new (VALUE class, VALUE filename, VALUE function,
+ VALUE data)
{
- char *c_filename, *result;
- int c_write;
+ char *c_filename, *c_function, *c_data, *result;
VALUE return_value;
API_INIT_FUNC(1, "upgrade_new", API_RETURN_EMPTY);
- if (NIL_P (filename) || NIL_P (write))
+ if (NIL_P (filename) || NIL_P (function) || NIL_P (data))
API_WRONG_ARGS(API_RETURN_EMPTY);
Check_Type (filename, T_STRING);
- Check_Type (write, T_FIXNUM);
+ Check_Type (function, T_STRING);
+ Check_Type (data, T_STRING);
c_filename = StringValuePtr (filename);
- c_write = FIX2INT (write);
+ c_function = StringValuePtr (function);
+ c_data = StringValuePtr (data);
- result = API_PTR2STR(weechat_upgrade_new (c_filename,
- c_write));
+ result = API_PTR2STR(
+ plugin_script_api_upgrade_new (
+ weechat_ruby_plugin,
+ ruby_current_script,
+ c_filename,
+ &weechat_ruby_api_upgrade_read_cb,
+ c_function,
+ c_data));
API_RETURN_STRING_FREE(result);
}
@@ -5937,76 +6075,21 @@ weechat_ruby_api_upgrade_write_object (VALUE class, VALUE upgrade_file,
API_RETURN_INT(rc);
}
-int
-weechat_ruby_api_upgrade_read_cb (void *data,
- struct t_upgrade_file *upgrade_file,
- int object_id,
- struct t_infolist *infolist)
-{
- struct t_plugin_script_cb *script_callback;
- void *func_argv[4];
- char empty_arg[1] = { '\0' }, str_object_id[32];
- int *rc, ret;
-
- script_callback = (struct t_plugin_script_cb *)data;
-
- if (script_callback && script_callback->function && script_callback->function[0])
- {
- snprintf (str_object_id, sizeof (str_object_id), "%d", object_id);
-
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
- func_argv[1] = API_PTR2STR(upgrade_file);
- func_argv[2] = str_object_id;
- func_argv[3] = API_PTR2STR(infolist);
-
- rc = (int *) weechat_ruby_exec (script_callback->script,
- WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
- "ssss", func_argv);
-
- if (!rc)
- ret = WEECHAT_RC_ERROR;
- else
- {
- ret = *rc;
- free (rc);
- }
- if (func_argv[1])
- free (func_argv[1]);
- if (func_argv[3])
- free (func_argv[3]);
-
- return ret;
- }
-
- return WEECHAT_RC_ERROR;
-}
-
static VALUE
-weechat_ruby_api_upgrade_read (VALUE class, VALUE upgrade_file,
- VALUE function, VALUE data)
+weechat_ruby_api_upgrade_read (VALUE class, VALUE upgrade_file)
{
- char *c_upgrade_file, *c_function, *c_data;
+ char *c_upgrade_file;
int rc;
API_INIT_FUNC(1, "upgrade_read", API_RETURN_INT(0));
- if (NIL_P (upgrade_file) || NIL_P (function) || NIL_P (data))
+ if (NIL_P (upgrade_file))
API_WRONG_ARGS(API_RETURN_INT(0));
Check_Type (upgrade_file, T_STRING);
- Check_Type (function, T_STRING);
- Check_Type (data, T_STRING);
c_upgrade_file = StringValuePtr (upgrade_file);
- c_function = StringValuePtr (function);
- c_data = StringValuePtr (data);
- rc = plugin_script_api_upgrade_read (weechat_ruby_plugin,
- ruby_current_script,
- API_STR2PTR(c_upgrade_file),
- &weechat_ruby_api_upgrade_read_cb,
- c_function,
- c_data);
+ rc = weechat_upgrade_read (API_STR2PTR(c_upgrade_file));
API_RETURN_INT(rc);
}
@@ -6270,8 +6353,8 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
API_DEF_FUNC(hdata_hashtable, 3);
API_DEF_FUNC(hdata_update, 3);
API_DEF_FUNC(hdata_get_string, 2);
- API_DEF_FUNC(upgrade_new, 2);
+ API_DEF_FUNC(upgrade_new, 3);
API_DEF_FUNC(upgrade_write_object, 3);
- API_DEF_FUNC(upgrade_read, 3);
+ API_DEF_FUNC(upgrade_read, 1);
API_DEF_FUNC(upgrade_close, 1);
}
diff --git a/src/plugins/ruby/weechat-ruby-api.h b/src/plugins/ruby/weechat-ruby-api.h
index 3275892ee..39f84c706 100644
--- a/src/plugins/ruby/weechat-ruby-api.h
+++ b/src/plugins/ruby/weechat-ruby-api.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2005-2007 Emmanuel Bouthenot <kolter@openics.org>
*
* This file is part of WeeChat, the extensible chat client.
@@ -21,10 +21,12 @@
#ifndef WEECHAT_RUBY_API_H
#define WEECHAT_RUBY_API_H 1
-extern int weechat_ruby_api_buffer_input_data_cb (void *data,
+extern int weechat_ruby_api_buffer_input_data_cb (const void *pointer,
+ void *data,
struct t_gui_buffer *buffer,
const char *input_data);
-extern int weechat_ruby_api_buffer_close_cb (void *data,
+extern int weechat_ruby_api_buffer_close_cb (const void *pointer,
+ void *data,
struct t_gui_buffer *buffer);
extern void weechat_ruby_api_init (VALUE ruby_mWeechat);
diff --git a/src/plugins/ruby/weechat-ruby.c b/src/plugins/ruby/weechat-ruby.c
index 409806ba5..5a1590fe2 100644
--- a/src/plugins/ruby/weechat-ruby.c
+++ b/src/plugins/ruby/weechat-ruby.c
@@ -1,7 +1,7 @@
/*
* weechat-ruby.c - ruby plugin for WeeChat
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2005-2007 Emmanuel Bouthenot <kolter@openics.org>
*
* This file is part of WeeChat, the extensible chat client.
@@ -146,8 +146,7 @@ weechat_ruby_hashtable_to_hash (struct t_hashtable *hashtable)
if (NIL_P (hash))
return Qnil;
- weechat_hashtable_map_string (hashtable,
- &weechat_ruby_hashtable_map_cb,
+ weechat_hashtable_map_string (hashtable, &weechat_ruby_hashtable_map_cb,
&hash);
return hash;
@@ -776,12 +775,14 @@ weechat_ruby_unload_all ()
*/
int
-weechat_ruby_command_cb (void *data, struct t_gui_buffer *buffer,
+weechat_ruby_command_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
char *ptr_name, *path_script;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
@@ -877,11 +878,13 @@ weechat_ruby_command_cb (void *data, struct t_gui_buffer *buffer,
*/
int
-weechat_ruby_completion_cb (void *data, const char *completion_item,
+weechat_ruby_completion_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -896,9 +899,11 @@ weechat_ruby_completion_cb (void *data, const char *completion_item,
*/
struct t_hdata *
-weechat_ruby_hdata_cb (void *data, const char *hdata_name)
+weechat_ruby_hdata_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
return plugin_script_hdata_script (weechat_plugin,
@@ -911,10 +916,12 @@ weechat_ruby_hdata_cb (void *data, const char *hdata_name)
*/
struct t_infolist *
-weechat_ruby_infolist_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+weechat_ruby_infolist_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (!infolist_name || !infolist_name[0])
@@ -923,7 +930,7 @@ weechat_ruby_infolist_cb (void *data, const char *infolist_name,
if (weechat_strcasecmp (infolist_name, "ruby_script") == 0)
{
return plugin_script_infolist_list_scripts (weechat_ruby_plugin,
- ruby_scripts, pointer,
+ ruby_scripts, obj_pointer,
arguments);
}
@@ -935,10 +942,12 @@ weechat_ruby_infolist_cb (void *data, const char *infolist_name,
*/
int
-weechat_ruby_signal_debug_dump_cb (void *data, const char *signal,
+weechat_ruby_signal_debug_dump_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -957,10 +966,12 @@ weechat_ruby_signal_debug_dump_cb (void *data, const char *signal,
*/
int
-weechat_ruby_signal_debug_libs_cb (void *data, const char *signal,
+weechat_ruby_signal_debug_libs_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -976,37 +987,20 @@ weechat_ruby_signal_debug_libs_cb (void *data, const char *signal,
}
/*
- * Callback called when a buffer is closed.
- */
-
-int
-weechat_ruby_signal_buffer_closed_cb (void *data, const char *signal,
- const char *type_data, void *signal_data)
-{
- /* make C compiler happy */
- (void) data;
- (void) signal;
- (void) type_data;
-
- if (signal_data)
- plugin_script_remove_buffer_callbacks (ruby_scripts, signal_data);
-
- return WEECHAT_RC_OK;
-}
-
-/*
* Timer for executing actions.
*/
int
-weechat_ruby_timer_action_cb (void *data, int remaining_calls)
+weechat_ruby_timer_action_cb (const void *pointer, void *data,
+ int remaining_calls)
{
/* make C compiler happy */
+ (void) data;
(void) remaining_calls;
- if (data)
+ if (pointer)
{
- if (data == &ruby_action_install_list)
+ if (pointer == &ruby_action_install_list)
{
plugin_script_action_install (weechat_ruby_plugin,
ruby_scripts,
@@ -1015,7 +1009,7 @@ weechat_ruby_timer_action_cb (void *data, int remaining_calls)
&ruby_quiet,
&ruby_action_install_list);
}
- else if (data == &ruby_action_remove_list)
+ else if (pointer == &ruby_action_remove_list)
{
plugin_script_action_remove (weechat_ruby_plugin,
ruby_scripts,
@@ -1023,7 +1017,7 @@ weechat_ruby_timer_action_cb (void *data, int remaining_calls)
&ruby_quiet,
&ruby_action_remove_list);
}
- else if (data == &ruby_action_autoload_list)
+ else if (pointer == &ruby_action_autoload_list)
{
plugin_script_action_autoload (weechat_ruby_plugin,
&ruby_quiet,
@@ -1039,11 +1033,13 @@ weechat_ruby_timer_action_cb (void *data, int remaining_calls)
*/
int
-weechat_ruby_signal_script_action_cb (void *data, const char *signal,
+weechat_ruby_signal_script_action_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data,
void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
@@ -1054,7 +1050,7 @@ weechat_ruby_signal_script_action_cb (void *data, const char *signal,
(const char *)signal_data);
weechat_hook_timer (1, 0, 1,
&weechat_ruby_timer_action_cb,
- &ruby_action_install_list);
+ &ruby_action_install_list, NULL);
}
else if (strcmp (signal, "ruby_script_remove") == 0)
{
@@ -1062,7 +1058,7 @@ weechat_ruby_signal_script_action_cb (void *data, const char *signal,
(const char *)signal_data);
weechat_hook_timer (1, 0, 1,
&weechat_ruby_timer_action_cb,
- &ruby_action_remove_list);
+ &ruby_action_remove_list, NULL);
}
else if (strcmp (signal, "ruby_script_autoload") == 0)
{
@@ -1070,7 +1066,7 @@ weechat_ruby_signal_script_action_cb (void *data, const char *signal,
(const char *)signal_data);
weechat_hook_timer (1, 0, 1,
&weechat_ruby_timer_action_cb,
- &ruby_action_autoload_list);
+ &ruby_action_autoload_list, NULL);
}
}
@@ -1093,9 +1089,6 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
" if RUBY_VERSION.split('.')[0] == '1' and RUBY_VERSION.split('.')[1] <= '8'\n"
" require 'rubygems'\n"
" else\n"
- " require 'enc/encdb.so'\n"
- " require 'enc/trans/transdb.so'\n"
- "\n"
" require 'thread'\n"
" class ::Mutex\n"
" def synchronize(*args)\n"
@@ -1118,6 +1111,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
" end\n"
"\n"
" begin\n"
+ " require 'enc/encdb.so'\n"
+ " require 'enc/trans/transdb.so'\n"
" module_eval(lines)\n"
" rescue Exception => e\n"
" @load_eval_file_error = e\n"
@@ -1191,7 +1186,6 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
init.callback_infolist = &weechat_ruby_infolist_cb;
init.callback_signal_debug_dump = &weechat_ruby_signal_debug_dump_cb;
init.callback_signal_debug_libs = &weechat_ruby_signal_debug_libs_cb;
- init.callback_signal_buffer_closed = &weechat_ruby_signal_buffer_closed_cb;
init.callback_signal_script_action = &weechat_ruby_signal_script_action_cb;
init.callback_load_file = &weechat_ruby_load_cb;
diff --git a/src/plugins/ruby/weechat-ruby.h b/src/plugins/ruby/weechat-ruby.h
index f2c8a70bb..cde73fb85 100644
--- a/src/plugins/ruby/weechat-ruby.h
+++ b/src/plugins/ruby/weechat-ruby.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2005-2007 Emmanuel Bouthenot <kolter@openics.org>
*
* This file is part of WeeChat, the extensible chat client.
diff --git a/src/plugins/script/CMakeLists.txt b/src/plugins/script/CMakeLists.txt
index eade5489a..cb7af6d79 100644
--- a/src/plugins/script/CMakeLists.txt
+++ b/src/plugins/script/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/script/Makefile.am b/src/plugins/script/Makefile.am
index 680d103c2..b5f0c7c90 100644
--- a/src/plugins/script/Makefile.am
+++ b/src/plugins/script/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/script/script-action.c b/src/plugins/script/script-action.c
index 032ec223f..3c4510b8e 100644
--- a/src/plugins/script/script-action.c
+++ b/src/plugins/script/script-action.c
@@ -1,7 +1,7 @@
/*
* script-action.c - actions on scripts
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -483,12 +483,14 @@ script_action_autoload (const char *name, int quiet, int autoload)
*/
int
-script_action_installnext_timer_cb (void *data, int remaining_calls)
+script_action_installnext_timer_cb (const void *pointer, void *data,
+ int remaining_calls)
{
/* make C compiler happy */
+ (void) data;
(void) remaining_calls;
- script_action_install ((data) ? 1 : 0);
+ script_action_install ((pointer) ? 1 : 0);
return WEECHAT_RC_OK;
}
@@ -498,7 +500,8 @@ script_action_installnext_timer_cb (void *data, int remaining_calls)
*/
int
-script_action_install_process_cb (void *data, const char *command,
+script_action_install_process_cb (const void *pointer, void *data,
+ const char *command,
int return_code, const char *out,
const char *err)
{
@@ -507,9 +510,10 @@ script_action_install_process_cb (void *data, const char *command,
struct t_script_repo *ptr_script;
/* make C compiler happy */
+ (void) data;
(void) out;
- quiet = (data) ? 1 : 0;
+ quiet = (pointer) ? 1 : 0;
if (return_code >= 0)
{
@@ -558,7 +562,8 @@ script_action_install_process_cb (void *data, const char *command,
/* schedule install of next script */
weechat_hook_timer (10, 0, 1,
&script_action_installnext_timer_cb,
- (quiet) ? (void *)1 : (void *)0);
+ (quiet) ? (void *)1 : (void *)0,
+ NULL);
}
}
}
@@ -633,8 +638,7 @@ script_action_install (int quiet)
options = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
if (options)
{
url = script_build_download_url (ptr_script_to_install->url);
@@ -648,9 +652,13 @@ script_action_install (int quiet)
ptr_script_to_install->name_with_extension);
}
weechat_hashtable_set (options, "file_out", filename);
- weechat_hook_process_hashtable (url, options, 30000,
- &script_action_install_process_cb,
- (quiet) ? (void *)1 : (void *)0);
+ weechat_hook_process_hashtable (
+ url,
+ options,
+ weechat_config_integer (script_config_scripts_download_timeout) * 1000,
+ &script_action_install_process_cb,
+ (quiet) ? (void *)1 : (void *)0,
+ NULL);
free (url);
}
weechat_hashtable_free (options);
@@ -796,7 +804,8 @@ script_action_hold (const char *name, int quiet)
*/
int
-script_action_show_diff_process_cb (void *data, const char *command,
+script_action_show_diff_process_cb (const void *pointer, void *data,
+ const char *command,
int return_code, const char *out,
const char *err)
{
@@ -805,6 +814,7 @@ script_action_show_diff_process_cb (void *data, const char *command,
int num_lines, i, diff_color;
/* make C compiler happy */
+ (void) data;
(void) command;
if (script_buffer && script_buffer_detail_script
@@ -873,7 +883,7 @@ script_action_show_diff_process_cb (void *data, const char *command,
if ((return_code == WEECHAT_HOOK_PROCESS_ERROR) || (return_code >= 0))
{
/* last call to this callback: delete temporary file */
- filename = (char *)data;
+ filename = (char *)pointer;
unlink (filename);
free (filename);
}
@@ -886,7 +896,8 @@ script_action_show_diff_process_cb (void *data, const char *command,
*/
int
-script_action_show_source_process_cb (void *data, const char *command,
+script_action_show_source_process_cb (const void *pointer, void *data,
+ const char *command,
int return_code, const char *out,
const char *err)
{
@@ -898,6 +909,7 @@ script_action_show_source_process_cb (void *data, const char *command,
int length, diff_made;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) out;
@@ -996,7 +1008,7 @@ script_action_show_source_process_cb (void *data, const char *command,
weechat_color ("magenta"));
weechat_hook_process (diff_command, 10000,
&script_action_show_diff_process_cb,
- filename);
+ filename, NULL);
diff_made = 1;
free (diff_command);
}
@@ -1059,17 +1071,19 @@ script_action_show (const char *name, int quiet)
options = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
if (options)
{
url = script_build_download_url (ptr_script->url);
if (url)
{
weechat_hashtable_set (options, "file_out", filename);
- weechat_hook_process_hashtable (url, options, 30000,
- &script_action_show_source_process_cb,
- NULL);
+ weechat_hook_process_hashtable (
+ url,
+ options,
+ weechat_config_integer (script_config_scripts_download_timeout) * 1000,
+ &script_action_show_source_process_cb,
+ NULL, NULL);
free (url);
}
weechat_hashtable_free (options);
diff --git a/src/plugins/script/script-action.h b/src/plugins/script/script-action.h
index 25f6b145c..c11a9fe56 100644
--- a/src/plugins/script/script-action.h
+++ b/src/plugins/script/script-action.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/script/script-buffer.c b/src/plugins/script/script-buffer.c
index 08daebc42..fd23bfbe6 100644
--- a/src/plugins/script/script-buffer.c
+++ b/src/plugins/script/script-buffer.c
@@ -1,7 +1,7 @@
/*
* script-buffer.c - display scripts on script buffer
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -403,12 +403,9 @@ script_buffer_get_script_usage (struct t_script_repo *script)
struct t_weelist *list;
char hdata_name[128], str_option[256], str_info[1024];
int config_files;
- const char *ptr_name_hdata_callback, *type;
- struct t_hdata *ptr_hdata_script, *ptr_hdata_callback;
- struct t_hdata *ptr_hdata_config_file, *ptr_hdata_bar_item;
- void *ptr_script, *ptr_callback;
- struct t_config_file *ptr_config_file;
- struct t_hook *ptr_hook;
+ struct t_hdata *hdata_script, *hdata_config, *hdata_bar_item;
+ void *ptr_script, *callback_pointer;
+ struct t_config_file *ptr_config;
struct t_gui_bar_item *ptr_bar_item;
struct t_infolist *infolist;
@@ -416,126 +413,161 @@ script_buffer_get_script_usage (struct t_script_repo *script)
snprintf (hdata_name, sizeof (hdata_name),
"%s_script", script_language[script->language]);
- ptr_hdata_script = weechat_hdata_get (hdata_name);
- if (!ptr_hdata_script)
+ hdata_script = weechat_hdata_get (hdata_name);
+ if (!hdata_script)
return NULL;
- ptr_script = script_buffer_get_script_pointer (script, ptr_hdata_script);
+ ptr_script = script_buffer_get_script_pointer (script, hdata_script);
if (!ptr_script)
return NULL;
- ptr_name_hdata_callback = weechat_hdata_get_var_hdata (ptr_hdata_script,
- "callbacks");
- if (!ptr_name_hdata_callback)
- return NULL;
- ptr_hdata_callback = weechat_hdata_get (ptr_name_hdata_callback);
- if (!ptr_hdata_callback)
- return NULL;
-
list = weechat_list_new ();
- ptr_hdata_config_file = weechat_hdata_get ("config_file");
- ptr_hdata_bar_item = weechat_hdata_get ("bar_item");
-
- ptr_callback = weechat_hdata_pointer (ptr_hdata_script,
- ptr_script,
- "callbacks");
- while (ptr_callback)
+ /* get configuration files created by the script */
+ hdata_config = weechat_hdata_get ("config_file");
+ ptr_config = weechat_hdata_get_list (hdata_config, "config_files");
+ while (ptr_config)
{
- str_info[0] = '\0';
- ptr_config_file = weechat_hdata_pointer (ptr_hdata_callback,
- ptr_callback,
- "config_file");
- ptr_hook = weechat_hdata_pointer (ptr_hdata_callback,
- ptr_callback,
- "hook");
- ptr_bar_item = weechat_hdata_pointer (ptr_hdata_callback,
- ptr_callback,
- "bar_item");
- if (ptr_config_file)
+ callback_pointer = weechat_hdata_pointer (
+ hdata_config, ptr_config, "callback_reload_pointer");
+ if (callback_pointer == ptr_script)
{
snprintf (str_info, sizeof (str_info),
_("configuration file \"%s\" (options %s.*)"),
- weechat_hdata_string (ptr_hdata_config_file,
- ptr_config_file,
+ weechat_hdata_string (hdata_config, ptr_config,
"filename"),
- weechat_hdata_string (ptr_hdata_config_file,
- ptr_config_file,
+ weechat_hdata_string (hdata_config, ptr_config,
"name"));
+ weechat_list_add (list, str_info, WEECHAT_LIST_POS_END, NULL);
config_files++;
}
- else if (ptr_hook)
+ ptr_config = weechat_hdata_move (hdata_config, ptr_config, 1);
+ }
+
+ /* get the commands created by the script */
+ infolist = weechat_infolist_get ("hook", NULL, "command");
+ if (infolist)
+ {
+ while (weechat_infolist_next (infolist))
{
- infolist = weechat_infolist_get ("hook", ptr_hook, NULL);
- if (infolist)
+ callback_pointer = weechat_infolist_pointer (infolist,
+ "callback_pointer");
+ if (callback_pointer == ptr_script)
{
- if (weechat_infolist_next (infolist))
- {
- type = weechat_infolist_string (infolist, "type");
- if (type)
- {
- if (strcmp (type, "command") == 0)
- {
- snprintf (str_info, sizeof (str_info),
- _("command /%s"),
- weechat_infolist_string (infolist,
- "command"));
- }
- else if (strcmp (type, "completion") == 0)
- {
- snprintf (str_info, sizeof (str_info),
- _("completion %%(%s)"),
- weechat_infolist_string (infolist,
- "completion_item"));
- }
- else if (strcmp (type, "info") == 0)
- {
- snprintf (str_info, sizeof (str_info),
- "info \"%s\"",
- weechat_infolist_string (infolist,
- "info_name"));
- }
- else if (strcmp (type, "info_hashtable") == 0)
- {
- snprintf (str_info, sizeof (str_info),
- "info_hashtable \"%s\"",
- weechat_infolist_string (infolist,
- "info_name"));
- }
- else if (strcmp (type, "infolist") == 0)
- {
- snprintf (str_info, sizeof (str_info),
- "infolist \"%s\"",
- weechat_infolist_string (infolist,
- "infolist_name"));
- }
- }
- }
- weechat_infolist_free (infolist);
+ snprintf (str_info, sizeof (str_info),
+ _("command /%s"),
+ weechat_infolist_string (infolist,
+ "command"));
+ weechat_list_add (list, str_info, WEECHAT_LIST_POS_END, NULL);
+ }
+ }
+ weechat_infolist_free (infolist);
+ }
+
+ /* get the completions created by the script */
+ infolist = weechat_infolist_get ("hook", NULL, "completion");
+ if (infolist)
+ {
+ while (weechat_infolist_next (infolist))
+ {
+ callback_pointer = weechat_infolist_pointer (infolist,
+ "callback_pointer");
+ if (callback_pointer == ptr_script)
+ {
+ snprintf (str_info, sizeof (str_info),
+ _("completion %%(%s)"),
+ weechat_infolist_string (infolist,
+ "completion_item"));
+ weechat_list_add (list, str_info, WEECHAT_LIST_POS_END, NULL);
+ }
+ }
+ weechat_infolist_free (infolist);
+ }
+
+ /* get the infos created by the script */
+ infolist = weechat_infolist_get ("hook", NULL, "info");
+ if (infolist)
+ {
+ while (weechat_infolist_next (infolist))
+ {
+ callback_pointer = weechat_infolist_pointer (infolist,
+ "callback_pointer");
+ if (callback_pointer == ptr_script)
+ {
+ snprintf (str_info, sizeof (str_info),
+ "info \"%s\"",
+ weechat_infolist_string (infolist,
+ "info_name"));
+ weechat_list_add (list, str_info, WEECHAT_LIST_POS_END, NULL);
}
}
- else if (ptr_bar_item)
+ weechat_infolist_free (infolist);
+ }
+
+ /* get the infos (hashtable) created by the script */
+ infolist = weechat_infolist_get ("hook", NULL, "info_hashtable");
+ if (infolist)
+ {
+ while (weechat_infolist_next (infolist))
+ {
+ callback_pointer = weechat_infolist_pointer (infolist,
+ "callback_pointer");
+ if (callback_pointer == ptr_script)
+ {
+ snprintf (str_info, sizeof (str_info),
+ "info_hashtable \"%s\"",
+ weechat_infolist_string (infolist,
+ "info_name"));
+ weechat_list_add (list, str_info, WEECHAT_LIST_POS_END, NULL);
+ }
+ }
+ weechat_infolist_free (infolist);
+ }
+
+ /* get the infolists created by the script */
+ infolist = weechat_infolist_get ("hook", NULL, "infolist");
+ if (infolist)
+ {
+ while (weechat_infolist_next (infolist))
+ {
+ callback_pointer = weechat_infolist_pointer (infolist,
+ "callback_pointer");
+ if (callback_pointer == ptr_script)
+ {
+ snprintf (str_info, sizeof (str_info),
+ "infolist \"%s\"",
+ weechat_infolist_string (infolist,
+ "infolist_name"));
+ weechat_list_add (list, str_info, WEECHAT_LIST_POS_END, NULL);
+ }
+ }
+ weechat_infolist_free (infolist);
+ }
+
+ /* get the bar items created by the script */
+ hdata_bar_item = weechat_hdata_get ("bar_item");
+ ptr_bar_item = weechat_hdata_get_list (hdata_bar_item, "gui_bar_items");
+ while (ptr_bar_item)
+ {
+ callback_pointer = weechat_hdata_pointer (hdata_bar_item, ptr_bar_item,
+ "build_callback_pointer");
+ if (callback_pointer == ptr_script)
{
snprintf (str_info, sizeof (str_info),
_("bar item \"%s\""),
- weechat_hdata_string (ptr_hdata_bar_item,
+ weechat_hdata_string (hdata_bar_item,
ptr_bar_item,
"name"));
+ weechat_list_add (list, str_info, WEECHAT_LIST_POS_END, NULL);
}
- if (str_info[0])
- {
- weechat_list_add (list, str_info,
- WEECHAT_LIST_POS_END, NULL);
- }
- ptr_callback = weechat_hdata_move (ptr_hdata_callback,
- ptr_callback,
- 1);
+ ptr_bar_item = weechat_hdata_move (hdata_bar_item, ptr_bar_item, 1);
}
+ /* get the script options (in plugins.var) */
snprintf (str_option, sizeof (str_option),
"plugins.var.%s.%s.*",
script_language[script->language],
- weechat_hdata_string (ptr_hdata_script, ptr_script, "name"));
+ weechat_hdata_string (hdata_script, ptr_script, "name"));
infolist = weechat_infolist_get ("option", NULL, str_option);
if (infolist)
{
@@ -892,13 +924,14 @@ script_buffer_check_line_outside_window ()
*/
int
-script_buffer_window_scrolled_cb (void *data, const char *signal,
- const char *type_data,
+script_buffer_window_scrolled_cb (const void *pointer, void *data,
+ const char *signal, const char *type_data,
void *signal_data)
{
int start_line_y, chat_height, line;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -936,7 +969,8 @@ script_buffer_window_scrolled_cb (void *data, const char *signal,
*/
int
-script_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
+script_buffer_input_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
const char *input_data)
{
char *actions[][2] = { { "A", "toggleautoload" },
@@ -953,6 +987,7 @@ script_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
int i;
/* make C compiler happy */
+ (void) pointer;
(void) data;
/* close buffer */
@@ -1010,9 +1045,11 @@ script_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
*/
int
-script_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
+script_buffer_close_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
@@ -1089,9 +1126,10 @@ script_buffer_open ()
{
if (!script_buffer)
{
- script_buffer = weechat_buffer_new (SCRIPT_BUFFER_NAME,
- &script_buffer_input_cb, NULL,
- &script_buffer_close_cb, NULL);
+ script_buffer = weechat_buffer_new (
+ SCRIPT_BUFFER_NAME,
+ &script_buffer_input_cb, NULL, NULL,
+ &script_buffer_close_cb, NULL, NULL);
/* failed to create buffer ? then exit */
if (!script_buffer)
diff --git a/src/plugins/script/script-buffer.h b/src/plugins/script/script-buffer.h
index d717dff9b..7f23729c7 100644
--- a/src/plugins/script/script-buffer.h
+++ b/src/plugins/script/script-buffer.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -36,12 +36,15 @@ extern void script_buffer_show_detail_script (struct t_script_repo *script);
extern void script_buffer_get_window_info (struct t_gui_window *window,
int *start_line_y, int *chat_height);
extern void script_buffer_check_line_outside_window ();
-extern int script_buffer_window_scrolled_cb (void *data, const char *signal,
+extern int script_buffer_window_scrolled_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data,
void *signal_data);
-extern int script_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
+extern int script_buffer_input_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
const char *input_data);
-extern int script_buffer_close_cb (void *data, struct t_gui_buffer *buffer);
+extern int script_buffer_close_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer);
extern void script_buffer_set_callbacks ();
extern void script_buffer_set_keys ();
extern void script_buffer_open ();
diff --git a/src/plugins/script/script-command.c b/src/plugins/script/script-command.c
index d7e0cb576..1cf459bac 100644
--- a/src/plugins/script/script-command.c
+++ b/src/plugins/script/script-command.c
@@ -1,7 +1,7 @@
/*
* script-command.c - script command
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -121,7 +121,8 @@ script_command_action (struct t_gui_buffer *buffer, const char *action,
*/
int
-script_command_script (void *data, struct t_gui_buffer *buffer, int argc,
+script_command_script (const void *pointer, void *data,
+ struct t_gui_buffer *buffer, int argc,
char **argv, char **argv_eol)
{
char *error, command[128];
@@ -129,6 +130,7 @@ script_command_script (void *data, struct t_gui_buffer *buffer, int argc,
int line;
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (argc == 1)
@@ -279,7 +281,7 @@ script_command_script (void *data, struct t_gui_buffer *buffer, int argc,
}
/*
- * Hook command.
+ * Hooks script command.
*/
void
@@ -300,8 +302,9 @@ script_command_init ()
" -o: send list of loaded scripts to buffer\n"
" -i: copy list of loaded scripts in command line (for "
"sending to buffer)\n"
- " search: search scripts by tags or text and display result "
- "on scripts buffer\n"
+ " search: search scripts by tags, language (python, "
+ "perl, ...), filename extension (py, pl, ...) or text; result is "
+ "displayed on scripts buffer\n"
" show: show detailed info about a script\n"
" load: load script(s)\n"
" unload: unload script(s)\n"
@@ -366,7 +369,7 @@ script_command_init ()
" /script reload urlserver\n"
" /script upgrade"),
"list -o|-i"
- " || search %(script_tags)"
+ " || search %(script_tags)|%(script_languages)|%(script_extensions)"
" || show %(script_scripts)"
" || load %(script_files)|%*"
" || unload %(python_script)|%(perl_script)|%(ruby_script)|"
@@ -382,5 +385,5 @@ script_command_init ()
" || hold %(script_scripts)|%*"
" || update"
" || upgrade",
- &script_command_script, NULL);
+ &script_command_script, NULL, NULL);
}
diff --git a/src/plugins/script/script-command.h b/src/plugins/script/script-command.h
index c29e82a5a..8ed1ed137 100644
--- a/src/plugins/script/script-command.h
+++ b/src/plugins/script/script-command.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/script/script-completion.c b/src/plugins/script/script-completion.c
index 16749c56e..053873ac1 100644
--- a/src/plugins/script/script-completion.c
+++ b/src/plugins/script/script-completion.c
@@ -1,7 +1,7 @@
/*
* script-completion.c - completions for script command
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -30,17 +30,75 @@
/*
+ * Adds script languages (python, perl, ruby, ...) to completion list.
+ */
+
+int
+script_completion_languages_cb (const void *pointer, void *data,
+ const char *completion_item,
+ struct t_gui_buffer *buffer,
+ struct t_gui_completion *completion)
+{
+ int i;
+
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+ (void) completion_item;
+ (void) buffer;
+
+ for (i = 0; i < SCRIPT_NUM_LANGUAGES; i++)
+ {
+ weechat_hook_completion_list_add (completion,
+ script_language[i],
+ 0, WEECHAT_LIST_POS_SORT);
+ }
+
+ return WEECHAT_RC_OK;
+}
+
+/*
+ * Adds script extensions (py, pl, rb, ...) to completion list.
+ */
+
+int
+script_completion_extensions_cb (const void *pointer, void *data,
+ const char *completion_item,
+ struct t_gui_buffer *buffer,
+ struct t_gui_completion *completion)
+{
+ int i;
+
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+ (void) completion_item;
+ (void) buffer;
+
+ for (i = 0; i < SCRIPT_NUM_LANGUAGES; i++)
+ {
+ weechat_hook_completion_list_add (completion,
+ script_extension[i],
+ 0, WEECHAT_LIST_POS_SORT);
+ }
+
+ return WEECHAT_RC_OK;
+}
+
+/*
* Adds scripts to completion list.
*/
int
-script_completion_scripts_cb (void *data, const char *completion_item,
+script_completion_scripts_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
struct t_script_repo *ptr_script;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -61,13 +119,15 @@ script_completion_scripts_cb (void *data, const char *completion_item,
*/
int
-script_completion_scripts_installed_cb (void *data, const char *completion_item,
+script_completion_scripts_installed_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
struct t_script_repo *ptr_script;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -124,7 +184,8 @@ script_completion_exec_file_cb (void *data, const char *filename)
*/
int
-script_completion_scripts_files_cb (void *data, const char *completion_item,
+script_completion_scripts_files_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
@@ -134,6 +195,7 @@ script_completion_scripts_files_cb (void *data, const char *completion_item,
void *pointers[2];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -153,13 +215,15 @@ script_completion_scripts_files_cb (void *data, const char *completion_item,
snprintf (directory, length,
"%s/%s", weechat_home, script_language[i]);
weechat_exec_on_files (directory, 0,
- pointers, &script_completion_exec_file_cb);
+ &script_completion_exec_file_cb,
+ pointers);
/* look for files in "~/.weechat/<language>/autoload/" */
snprintf (directory, length,
"%s/%s/autoload", weechat_home, script_language[i]);
weechat_exec_on_files (directory, 0,
- pointers, &script_completion_exec_file_cb);
+ &script_completion_exec_file_cb,
+ pointers);
}
free (directory);
}
@@ -172,7 +236,8 @@ script_completion_scripts_files_cb (void *data, const char *completion_item,
*/
int
-script_completion_tags_cb (void *data, const char *completion_item,
+script_completion_tags_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
@@ -181,6 +246,7 @@ script_completion_tags_cb (void *data, const char *completion_item,
int num_tags, i;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -215,16 +281,22 @@ script_completion_tags_cb (void *data, const char *completion_item,
void
script_completion_init ()
{
+ weechat_hook_completion ("script_languages",
+ N_("list of script languages"),
+ &script_completion_languages_cb, NULL, NULL);
+ weechat_hook_completion ("script_extensions",
+ N_("list of script extensions"),
+ &script_completion_extensions_cb, NULL, NULL);
weechat_hook_completion ("script_scripts",
N_("list of scripts in repository"),
- &script_completion_scripts_cb, NULL);
+ &script_completion_scripts_cb, NULL, NULL);
weechat_hook_completion ("script_scripts_installed",
N_("list of scripts installed (from repository)"),
- &script_completion_scripts_installed_cb, NULL);
+ &script_completion_scripts_installed_cb, NULL, NULL);
weechat_hook_completion ("script_files",
N_("files in script directories"),
- &script_completion_scripts_files_cb, NULL);
+ &script_completion_scripts_files_cb, NULL, NULL);
weechat_hook_completion ("script_tags",
N_("tags of scripts in repository"),
- &script_completion_tags_cb, NULL);
+ &script_completion_tags_cb, NULL, NULL);
}
diff --git a/src/plugins/script/script-completion.h b/src/plugins/script/script-completion.h
index 64a3d844d..830be0e12 100644
--- a/src/plugins/script/script-completion.h
+++ b/src/plugins/script/script-completion.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/script/script-config.c b/src/plugins/script/script-config.c
index b5333fe54..ee3d7a187 100644
--- a/src/plugins/script/script-config.c
+++ b/src/plugins/script/script-config.c
@@ -1,7 +1,7 @@
/*
* script-config.c - script configuration options (file script.conf)
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -82,6 +82,7 @@ struct t_config_option *script_config_color_text_version_selected;
struct t_config_option *script_config_scripts_autoload;
struct t_config_option *script_config_scripts_cache_expire;
+struct t_config_option *script_config_scripts_download_timeout;
struct t_config_option *script_config_scripts_path;
struct t_config_option *script_config_scripts_hold;
struct t_config_option *script_config_scripts_url;
@@ -204,9 +205,11 @@ script_config_get_script_download_filename (struct t_script_repo *script,
*/
void
-script_config_refresh_cb (void *data, struct t_config_option *option)
+script_config_refresh_cb (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -220,9 +223,11 @@ script_config_refresh_cb (void *data, struct t_config_option *option)
*/
void
-script_config_reload_scripts_cb (void *data, struct t_config_option *option)
+script_config_reload_scripts_cb (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -239,9 +244,11 @@ script_config_reload_scripts_cb (void *data, struct t_config_option *option)
*/
void
-script_config_change_use_keys_cb (void *data, struct t_config_option *option)
+script_config_change_use_keys_cb (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -254,9 +261,11 @@ script_config_change_use_keys_cb (void *data, struct t_config_option *option)
*/
void
-script_config_change_hold_cb (void *data, struct t_config_option *option)
+script_config_change_hold_cb (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -354,9 +363,11 @@ script_config_unhold (const char *name_with_extension)
*/
int
-script_config_reload (void *data, struct t_config_file *config_file)
+script_config_reload (const void *pointer, void *data,
+ struct t_config_file *config_file)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
return weechat_config_reload (config_file);
@@ -376,16 +387,18 @@ script_config_init ()
struct t_config_section *ptr_section;
script_config_file = weechat_config_new (SCRIPT_CONFIG_NAME,
- &script_config_reload, NULL);
+ &script_config_reload, NULL, NULL);
if (!script_config_file)
return 0;
/* look */
ptr_section = weechat_config_new_section (script_config_file, "look",
0, 0,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (script_config_file);
@@ -402,13 +415,15 @@ script_config_init ()
"%u=date updated, %v=version, %V=version loaded, %w=min_weechat, "
"%W=max_weechat)"),
NULL, 0, 0, "%s %n %V %v %u | %d | %t", NULL, 0,
- NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &script_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
script_config_look_diff_color = weechat_config_new_option (
script_config_file, ptr_section,
"diff_color", "boolean",
N_("colorize output of diff"),
NULL, 0, 0, "on", NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
script_config_look_diff_command = weechat_config_new_option (
script_config_file, ptr_section,
"diff_command", "string",
@@ -417,7 +432,7 @@ script_config_init ()
"or diff), empty value = disable diff, other string = name of "
"command, for example \"diff\")"),
NULL, 0, 0, "auto", NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
script_config_look_display_source = weechat_config_new_option (
script_config_file, ptr_section,
"display_source", "boolean",
@@ -425,7 +440,7 @@ script_config_init ()
"(script is downloaded in a temporary file when detail on script "
"is displayed)"),
NULL, 0, 0, "on", NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
script_config_look_quiet_actions = weechat_config_new_option (
script_config_file, ptr_section,
"quiet_actions", "boolean",
@@ -433,7 +448,7 @@ script_config_init ()
"buffer when scripts are installed/removed/loaded/unloaded (only "
"errors are displayed)"),
NULL, 0, 0, "on", NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
script_config_look_sort = weechat_config_new_option (
script_config_file, ptr_section,
"sort", "string",
@@ -444,14 +459,18 @@ script_config_init ()
"order; example: \"i,u\": installed scripts first, sorted by update "
"date"),
NULL, 0, 0, "p,n", NULL, 0,
- NULL, NULL, &script_config_reload_scripts_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &script_config_reload_scripts_cb, NULL, NULL,
+ NULL, NULL, NULL);
script_config_look_translate_description = weechat_config_new_option (
script_config_file, ptr_section,
"translate_description", "boolean",
N_("translate description of scripts (if translation is available in "
"your language, otherwise English version is used)"),
NULL, 0, 0, "on", NULL, 0,
- NULL, NULL, &script_config_reload_scripts_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &script_config_reload_scripts_cb, NULL, NULL,
+ NULL, NULL, NULL);
script_config_look_use_keys = weechat_config_new_option (
script_config_file, ptr_section,
"use_keys", "boolean",
@@ -459,14 +478,18 @@ script_config_init ()
"install, alt+r = remove, ...); if disabled, only the input is "
"allowed: i, r, ..."),
NULL, 0, 0, "on", NULL, 0,
- NULL, NULL, &script_config_change_use_keys_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &script_config_change_use_keys_cb, NULL, NULL,
+ NULL, NULL, NULL);
/* color */
ptr_section = weechat_config_new_section (script_config_file, "color",
0, 0,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (script_config_file);
@@ -478,164 +501,218 @@ script_config_init ()
"status_autoloaded", "color",
N_("color for status \"autoloaded\" (\"a\")"),
NULL, 0, 0, "cyan", NULL, 0,
- NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &script_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
script_config_color_status_held = weechat_config_new_option (
script_config_file, ptr_section,
"status_held", "color",
N_("color for status \"held\" (\"H\")"),
NULL, 0, 0, "white", NULL, 0,
- NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &script_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
script_config_color_status_installed = weechat_config_new_option (
script_config_file, ptr_section,
"status_installed", "color",
N_("color for status \"installed\" (\"i\")"),
NULL, 0, 0, "lightcyan", NULL, 0,
- NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &script_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
script_config_color_status_obsolete = weechat_config_new_option (
script_config_file, ptr_section,
"status_obsolete", "color",
N_("color for status \"obsolete\" (\"N\")"),
NULL, 0, 0, "lightmagenta", NULL, 0,
- NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &script_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
script_config_color_status_popular = weechat_config_new_option (
script_config_file, ptr_section,
"status_popular", "color",
N_("color for status \"popular\" (\"*\")"),
NULL, 0, 0, "yellow", NULL, 0,
- NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &script_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
script_config_color_status_running = weechat_config_new_option (
script_config_file, ptr_section,
"status_running", "color",
N_("color for status \"running\" (\"r\")"),
NULL, 0, 0, "lightgreen", NULL, 0,
- NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &script_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
script_config_color_status_unknown = weechat_config_new_option (
script_config_file, ptr_section,
"status_unknown", "color",
N_("color for status \"unknown\" (\"?\")"),
NULL, 0, 0, "lightred", NULL, 0,
- NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &script_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
script_config_color_text = weechat_config_new_option (
script_config_file, ptr_section,
"text", "color",
N_("text color in script buffer"),
NULL, 0, 0, "default", NULL, 0,
- NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &script_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
script_config_color_text_bg = weechat_config_new_option (
script_config_file, ptr_section,
"text_bg", "color",
N_("background color in script buffer"),
NULL, 0, 0, "default", NULL, 0,
- NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &script_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
script_config_color_text_bg_selected = weechat_config_new_option (
script_config_file, ptr_section,
"text_bg_selected", "color",
N_("background color for selected line in script buffer"),
NULL, 0, 0, "red", NULL, 0,
- NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &script_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
script_config_color_text_date = weechat_config_new_option (
script_config_file, ptr_section,
"text_date", "color",
N_("text color of dates in script buffer"),
NULL, 0, 0, "default", NULL, 0,
- NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &script_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
script_config_color_text_date_selected = weechat_config_new_option (
script_config_file, ptr_section,
"text_date_selected", "color",
N_("text color of dates for selected line in script buffer"),
NULL, 0, 0, "white", NULL, 0,
- NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &script_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
script_config_color_text_delimiters = weechat_config_new_option (
script_config_file, ptr_section,
"text_delimiters", "color",
N_("text color of delimiters in script buffer"),
NULL, 0, 0, "default", NULL, 0,
- NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &script_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
script_config_color_text_description = weechat_config_new_option (
script_config_file, ptr_section,
"text_description", "color",
N_("text color of description in script buffer"),
NULL, 0, 0, "default", NULL, 0,
- NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &script_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
script_config_color_text_description_selected = weechat_config_new_option (
script_config_file, ptr_section,
"text_description_selected", "color",
N_("text color of description for selected line in script buffer"),
NULL, 0, 0, "white", NULL, 0,
- NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &script_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
script_config_color_text_extension = weechat_config_new_option (
script_config_file, ptr_section,
"text_extension", "color",
N_("text color of extension in script buffer"),
NULL, 0, 0, "default", NULL, 0,
- NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &script_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
script_config_color_text_extension_selected = weechat_config_new_option (
script_config_file, ptr_section,
"text_extension_selected", "color",
N_("text color of extension for selected line in script buffer"),
NULL, 0, 0, "white", NULL, 0,
- NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &script_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
script_config_color_text_name = weechat_config_new_option (
script_config_file, ptr_section,
"text_name", "color",
N_("text color of script name in script buffer"),
NULL, 0, 0, "cyan", NULL, 0,
- NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &script_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
script_config_color_text_name_selected = weechat_config_new_option (
script_config_file, ptr_section,
"text_name_selected", "color",
N_("text color of script name for selected line in script buffer"),
NULL, 0, 0, "lightcyan", NULL, 0,
- NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &script_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
script_config_color_text_selected = weechat_config_new_option (
script_config_file, ptr_section,
"text_selected", "color",
N_("text color for selected line in script buffer"),
NULL, 0, 0, "white", NULL, 0,
- NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &script_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
script_config_color_text_tags = weechat_config_new_option (
script_config_file, ptr_section,
"text_tags", "color",
N_("text color of tags in script buffer"),
NULL, 0, 0, "brown", NULL, 0,
- NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &script_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
script_config_color_text_tags_selected = weechat_config_new_option (
script_config_file, ptr_section,
"text_tags_selected", "color",
N_("text color of tags for selected line in script buffer"),
NULL, 0, 0, "yellow", NULL, 0,
- NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &script_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
script_config_color_text_version = weechat_config_new_option (
script_config_file, ptr_section,
"text_version", "color",
N_("text color of version in script buffer"),
NULL, 0, 0, "magenta", NULL, 0,
- NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &script_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
script_config_color_text_version_loaded = weechat_config_new_option (
script_config_file, ptr_section,
"text_version_loaded", "color",
N_("text color of version loaded in script buffer"),
NULL, 0, 0, "default", NULL, 0,
- NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &script_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
script_config_color_text_version_loaded_selected = weechat_config_new_option (
script_config_file, ptr_section,
"text_version_loaded_selected", "color",
N_("text color of version loaded for selected line in script buffer"),
NULL, 0, 0, "white", NULL, 0,
- NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &script_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
script_config_color_text_version_selected = weechat_config_new_option (
script_config_file, ptr_section,
"text_version_selected", "color",
N_("text color of version for selected line in script buffer"),
NULL, 0, 0, "lightmagenta", NULL, 0,
- NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &script_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
/* scripts */
ptr_section = weechat_config_new_section (script_config_file, "scripts",
0, 0,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (script_config_file);
@@ -648,45 +725,53 @@ script_config_init ()
N_("autoload scripts installed (make a link in \"autoload\" directory "
"to script in parent directory)"),
NULL, 0, 0, "on", NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
script_config_scripts_cache_expire = weechat_config_new_option (
script_config_file, ptr_section,
"cache_expire", "integer",
N_("local cache expiration time, in minutes (-1 = never expires, "
"0 = always expire)"),
- NULL, -1, 525600, "1440", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, -1, 525600, "1440", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ script_config_scripts_download_timeout = weechat_config_new_option (
+ script_config_file, ptr_section,
+ "download_timeout", "integer",
+ N_("timeout (in seconds) for download of scripts and list of scripts"),
+ NULL, 1, 3600, "30", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
script_config_scripts_path = weechat_config_new_option (
script_config_file, ptr_section,
"path", "string",
N_("local cache directory for scripts; \"%h\" at beginning of string "
"is replaced by WeeChat home (\"~/.weechat\" by default) "
"(note: content is evaluated, see /help eval)"),
- NULL, 0, 0, "%h/script", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "%h/script", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
script_config_scripts_hold = weechat_config_new_option (
script_config_file, ptr_section,
"hold", "string",
N_("scripts to \"hold\": comma-separated list of scripts which will "
"never been upgraded and can not be removed, for example: "
"\"buffers.pl,iset.pl\""),
- NULL, 0, 0, "", NULL, 0, NULL, NULL,
- &script_config_change_hold_cb, NULL, NULL, NULL);
+ NULL, 0, 0, "", NULL, 0,
+ NULL, NULL, NULL,
+ &script_config_change_hold_cb, NULL, NULL,
+ NULL, NULL, NULL);
script_config_scripts_url = weechat_config_new_option (
script_config_file, ptr_section,
"url", "string",
N_("URL for file with list of scripts; by default HTTPS is forced, "
"see option script.scripts.url_force_https"),
- NULL, 0, 0, "http://weechat.org/files/plugins.xml.gz", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "http://weechat.org/files/plugins.xml.gz", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
script_config_scripts_url_force_https = weechat_config_new_option (
script_config_file, ptr_section,
"url_force_https", "boolean",
N_("force use of HTTPS for downloads (index and scripts); "
"you should disable this option only if you have problems with "
"the downloads"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
return 1;
}
diff --git a/src/plugins/script/script-config.h b/src/plugins/script/script-config.h
index 6f488bda5..381a94eb3 100644
--- a/src/plugins/script/script-config.h
+++ b/src/plugins/script/script-config.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -62,6 +62,7 @@ extern struct t_config_option *script_config_color_text_version_selected;
extern struct t_config_option *script_config_scripts_autoload;
extern struct t_config_option *script_config_scripts_cache_expire;
+extern struct t_config_option *script_config_scripts_download_timeout;
extern struct t_config_option *script_config_scripts_path;
extern struct t_config_option *script_config_scripts_hold;
extern struct t_config_option *script_config_scripts_url;
diff --git a/src/plugins/script/script-info.c b/src/plugins/script/script-info.c
index c5eb83832..c3111d5b9 100644
--- a/src/plugins/script/script-info.c
+++ b/src/plugins/script/script-info.c
@@ -1,7 +1,7 @@
/*
* script-info.c - info, infolist and hdata hooks for script plugin
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -33,27 +33,30 @@
*/
struct t_infolist *
-script_info_infolist_script_script_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+script_info_infolist_script_script_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer,
+ const char *arguments)
{
struct t_infolist *ptr_infolist;
struct t_script_repo *ptr_script;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) infolist_name;
- if (pointer && !script_repo_script_valid (pointer))
+ if (obj_pointer && !script_repo_script_valid (obj_pointer))
return NULL;
ptr_infolist = weechat_infolist_new ();
if (!ptr_infolist)
return NULL;
- if (pointer)
+ if (obj_pointer)
{
/* build list with only one script */
- if (!script_repo_add_to_infolist (ptr_infolist, pointer))
+ if (!script_repo_add_to_infolist (ptr_infolist, obj_pointer))
{
weechat_infolist_free (ptr_infolist);
return NULL;
@@ -97,10 +100,10 @@ script_info_init ()
N_("script pointer (optional)"),
N_("script name with extension "
"(wildcard \"*\" is allowed) (optional)"),
- &script_info_infolist_script_script_cb, NULL);
+ &script_info_infolist_script_script_cb, NULL, NULL);
/* hdata hooks */
weechat_hook_hdata (
"script_script", N_("scripts from repository"),
- &script_repo_hdata_script_cb, NULL);
+ &script_repo_hdata_script_cb, NULL, NULL);
}
diff --git a/src/plugins/script/script-info.h b/src/plugins/script/script-info.h
index 797ffe205..b506c4cb2 100644
--- a/src/plugins/script/script-info.h
+++ b/src/plugins/script/script-info.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/script/script-repo.c b/src/plugins/script/script-repo.c
index 23db271b2..72b02d4e5 100644
--- a/src/plugins/script/script-repo.c
+++ b/src/plugins/script/script-repo.c
@@ -1,7 +1,7 @@
/*
* script-repo.c - download and read repository file (plugins.xml.gz)
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -948,13 +948,33 @@ script_repo_match_filter (struct t_script_repo *script)
if (!has_tag)
{
match = 0;
+
if (script->name_with_extension
- && weechat_strcasestr (script->name_with_extension, words[i]))
+ && weechat_strcasestr (script->name_with_extension,
+ words[i]))
+ {
+ match = 1;
+ }
+
+ if (!match
+ && (weechat_strcasecmp (script_language[script->language],
+ words[i]) == 0))
+ {
match = 1;
+ }
+
+ if (!match
+ && (weechat_strcasecmp (script_extension[script->language],
+ words[i]) == 0))
+ {
+ match = 1;
+ }
if (!match && script->description
&& weechat_strcasestr (script->description, words[i]))
+ {
match = 1;
+ }
if (!match)
{
@@ -1120,11 +1140,11 @@ script_repo_file_read (int quiet)
if (!script_repo_max_length_field)
{
- script_repo_max_length_field = weechat_hashtable_new (32,
- WEECHAT_HASHTABLE_STRING,
- WEECHAT_HASHTABLE_INTEGER,
- NULL,
- NULL);
+ script_repo_max_length_field = weechat_hashtable_new (
+ 32,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_INTEGER,
+ NULL, NULL);
}
else
weechat_hashtable_remove_all (script_repo_max_length_field);
@@ -1181,8 +1201,7 @@ script_repo_file_read (int quiet)
descriptions = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
/* read plugins.xml.gz */
while (!gzeof (file))
@@ -1402,17 +1421,19 @@ script_repo_file_read (int quiet)
*/
int
-script_repo_file_update_process_cb (void *data, const char *command,
+script_repo_file_update_process_cb (const void *pointer, void *data,
+ const char *command,
int return_code, const char *out,
const char *err)
{
int quiet;
/* make C compiler happy */
+ (void) data;
(void) command;
(void) out;
- quiet = (data == 0) ? 0 : 1;
+ quiet = (pointer) ? 1 : 0;
if (return_code >= 0)
{
@@ -1428,6 +1449,8 @@ script_repo_file_update_process_cb (void *data, const char *command,
if (script_repo_file_read (quiet) && scripts_repo)
{
+ if (script_buffer)
+ script_buffer_refresh (1);
if (!script_action_run ())
script_buffer_refresh (1);
}
@@ -1457,8 +1480,7 @@ script_repo_file_update (int quiet)
options = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
if (options)
{
url = script_build_download_url (
@@ -1472,9 +1494,13 @@ script_repo_file_update (int quiet)
SCRIPT_PLUGIN_NAME);
}
weechat_hashtable_set (options, "file_out", filename);
- weechat_hook_process_hashtable (url, options, 30000,
- &script_repo_file_update_process_cb,
- (quiet) ? (void *)1 : (void *)0);
+ weechat_hook_process_hashtable (
+ url,
+ options,
+ weechat_config_integer (script_config_scripts_download_timeout) * 1000,
+ &script_repo_file_update_process_cb,
+ (quiet) ? (void *)1 : (void *)0,
+ NULL);
free (url);
}
weechat_hashtable_free (options);
@@ -1488,11 +1514,13 @@ script_repo_file_update (int quiet)
*/
struct t_hdata *
-script_repo_hdata_script_cb (void *data, const char *hdata_name)
+script_repo_hdata_script_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
+ (void) pointer;
(void) data;
hdata = weechat_hdata_new (hdata_name, "prev_script", "next_script",
diff --git a/src/plugins/script/script-repo.h b/src/plugins/script/script-repo.h
index 6d6f05f72..c2ff595fd 100644
--- a/src/plugins/script/script-repo.h
+++ b/src/plugins/script/script-repo.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -79,7 +79,8 @@ extern int script_repo_file_exists ();
extern int script_repo_file_is_uptodate ();
extern int script_repo_file_read (int quiet);
extern void script_repo_file_update (int quiet);
-extern struct t_hdata *script_repo_hdata_script_cb (void *data,
+extern struct t_hdata *script_repo_hdata_script_cb (const void *pointer,
+ void *data,
const char *hdata_name);
extern int script_repo_add_to_infolist (struct t_infolist *infolist,
struct t_script_repo *script);
diff --git a/src/plugins/script/script.c b/src/plugins/script/script.c
index 75c4744bd..b95b73628 100644
--- a/src/plugins/script/script.c
+++ b/src/plugins/script/script.c
@@ -1,7 +1,7 @@
/*
* script.c - scripts manager for WeeChat
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -179,8 +179,7 @@ script_get_scripts ()
script_loaded = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
}
else
weechat_hashtable_remove_all (script_loaded);
@@ -217,10 +216,12 @@ script_get_scripts ()
*/
int
-script_debug_dump_cb (void *data, const char *signal, const char *type_data,
+script_debug_dump_cb (const void *pointer, void *data,
+ const char *signal, const char *type_data,
void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -247,9 +248,10 @@ script_debug_dump_cb (void *data, const char *signal, const char *type_data,
*/
int
-script_timer_refresh_cb (void *data, int remaining_calls)
+script_timer_refresh_cb (const void *pointer, void *data, int remaining_calls)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
script_get_loaded_plugins ();
@@ -268,10 +270,12 @@ script_timer_refresh_cb (void *data, int remaining_calls)
*/
int
-script_signal_plugin_cb (void *data, const char *signal, const char *type_data,
+script_signal_plugin_cb (const void *pointer, void *data,
+ const char *signal, const char *type_data,
void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) type_data;
@@ -285,7 +289,8 @@ script_signal_plugin_cb (void *data, const char *signal, const char *type_data,
if (!script_timer_refresh)
{
script_timer_refresh = weechat_hook_timer (50, 0, 1,
- &script_timer_refresh_cb, NULL);
+ &script_timer_refresh_cb,
+ NULL, NULL);
}
return WEECHAT_RC_OK;
@@ -296,10 +301,12 @@ script_signal_plugin_cb (void *data, const char *signal, const char *type_data,
*/
int
-script_signal_script_cb (void *data, const char *signal, const char *type_data,
+script_signal_script_cb (const void *pointer, void *data,
+ const char *signal, const char *type_data,
void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) type_data;
@@ -313,7 +320,8 @@ script_signal_script_cb (void *data, const char *signal, const char *type_data,
if (!script_timer_refresh)
{
script_timer_refresh = weechat_hook_timer (50, 0, 1,
- &script_timer_refresh_cb, NULL);
+ &script_timer_refresh_cb,
+ NULL, NULL);
}
return WEECHAT_RC_OK;
@@ -324,7 +332,8 @@ script_signal_script_cb (void *data, const char *signal, const char *type_data,
*/
struct t_hashtable *
-script_focus_chat_cb (void *data, struct t_hashtable *info)
+script_focus_chat_cb (const void *pointer, void *data,
+ struct t_hashtable *info)
{
const char *buffer;
int rc;
@@ -336,6 +345,7 @@ script_focus_chat_cb (void *data, struct t_hashtable *info)
struct tm *tm;
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (!script_buffer)
@@ -429,12 +439,16 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
script_completion_init ();
script_info_init ();
- weechat_hook_signal ("debug_dump", &script_debug_dump_cb, NULL);
- weechat_hook_signal ("window_scrolled", &script_buffer_window_scrolled_cb, NULL);
- weechat_hook_signal ("plugin_*", &script_signal_plugin_cb, NULL);
- weechat_hook_signal ("*_script_*", &script_signal_script_cb, NULL);
+ weechat_hook_signal ("debug_dump",
+ &script_debug_dump_cb, NULL, NULL);
+ weechat_hook_signal ("window_scrolled",
+ &script_buffer_window_scrolled_cb, NULL, NULL);
+ weechat_hook_signal ("plugin_*",
+ &script_signal_plugin_cb, NULL, NULL);
+ weechat_hook_signal ("*_script_*",
+ &script_signal_script_cb, NULL, NULL);
- weechat_hook_focus ("chat", &script_focus_chat_cb, NULL);
+ weechat_hook_focus ("chat", &script_focus_chat_cb, NULL, NULL);
if (script_repo_file_exists ())
{
diff --git a/src/plugins/script/script.h b/src/plugins/script/script.h
index 0c93a7863..0fd7eb9e7 100644
--- a/src/plugins/script/script.h
+++ b/src/plugins/script/script.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/tcl/CMakeLists.txt b/src/plugins/tcl/CMakeLists.txt
index ed10bad5b..10a89995d 100644
--- a/src/plugins/tcl/CMakeLists.txt
+++ b/src/plugins/tcl/CMakeLists.txt
@@ -1,7 +1,7 @@
#
# Copyright (C) 2008-2010 Dmitry Kobylin <fnfal@academ.tsc.ru>
# Copyright (C) 2008 Julien Louis <ptitlouis@sysif.net>
-# Copyright (C) 2008-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2008-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/tcl/Makefile.am b/src/plugins/tcl/Makefile.am
index 479e23b8b..344959de3 100644
--- a/src/plugins/tcl/Makefile.am
+++ b/src/plugins/tcl/Makefile.am
@@ -1,6 +1,6 @@
#
# Copyright (C) 2008-2010 Dmitry Kobylin <fnfal@academ.tsc.ru>
-# Copyright (C) 2008-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2008-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/tcl/weechat-tcl-api.c b/src/plugins/tcl/weechat-tcl-api.c
index d75436878..75db35ab3 100644
--- a/src/plugins/tcl/weechat-tcl-api.c
+++ b/src/plugins/tcl/weechat-tcl-api.c
@@ -3,7 +3,7 @@
*
* Copyright (C) 2008-2010 Dmitry Kobylin <fnfal@academ.tsc.ru>
* Copyright (C) 2008 Julien Louis <ptitlouis@sysif.net>
- * Copyright (C) 2008-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2008-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2012 Simon Arlott
*
* This file is part of WeeChat, the extensible chat client.
@@ -32,7 +32,6 @@
#include "../weechat-plugin.h"
#include "../plugin-script.h"
#include "../plugin-script-api.h"
-#include "../plugin-script-callback.h"
#include "weechat-tcl.h"
@@ -934,25 +933,27 @@ API_FUNC(list_free)
}
int
-weechat_tcl_api_config_reload_cb (void *data,
+weechat_tcl_api_config_reload_cb (const void *pointer, void *data,
struct t_config_file *config_file)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
- rc = (int *) weechat_tcl_exec (script_callback->script,
+ rc = (int *) weechat_tcl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (!rc)
@@ -996,29 +997,31 @@ API_FUNC(config_new)
}
int
-weechat_tcl_api_config_section_read_cb (void *data,
+weechat_tcl_api_config_section_read_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name, const char *value)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[5];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = API_PTR2STR(section);
func_argv[3] = (option_name) ? (char *)option_name : empty_arg;
func_argv[4] = (value) ? (char *)value : empty_arg;
- rc = (int *) weechat_tcl_exec (script_callback->script,
+ rc = (int *) weechat_tcl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sssss", func_argv);
if (!rc)
@@ -1040,26 +1043,28 @@ weechat_tcl_api_config_section_read_cb (void *data,
}
int
-weechat_tcl_api_config_section_write_cb (void *data,
+weechat_tcl_api_config_section_write_cb (const void *pointer, void *data,
struct t_config_file *config_file,
const char *section_name)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = (section_name) ? (char *)section_name : empty_arg;
- rc = (int *) weechat_tcl_exec (script_callback->script,
+ rc = (int *) weechat_tcl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -1079,26 +1084,28 @@ weechat_tcl_api_config_section_write_cb (void *data,
}
int
-weechat_tcl_api_config_section_write_default_cb (void *data,
+weechat_tcl_api_config_section_write_default_cb (const void *pointer, void *data,
struct t_config_file *config_file,
const char *section_name)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = (section_name) ? (char *)section_name : empty_arg;
- rc = (int *) weechat_tcl_exec (script_callback->script,
+ rc = (int *) weechat_tcl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -1118,30 +1125,32 @@ weechat_tcl_api_config_section_write_default_cb (void *data,
}
int
-weechat_tcl_api_config_section_create_option_cb (void *data,
+weechat_tcl_api_config_section_create_option_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
const char *value)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[5];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = API_PTR2STR(section);
func_argv[3] = (option_name) ? (char *)option_name : empty_arg;
func_argv[4] = (value) ? (char *)value : empty_arg;
- rc = (int *) weechat_tcl_exec (script_callback->script,
+ rc = (int *) weechat_tcl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sssss", func_argv);
if (!rc)
@@ -1163,28 +1172,30 @@ weechat_tcl_api_config_section_create_option_cb (void *data,
}
int
-weechat_tcl_api_config_section_delete_option_cb (void *data,
+weechat_tcl_api_config_section_delete_option_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
struct t_config_option *option)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(config_file);
func_argv[2] = API_PTR2STR(section);
func_argv[3] = API_PTR2STR(option);
- rc = (int *) weechat_tcl_exec (script_callback->script,
+ rc = (int *) weechat_tcl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssss", func_argv);
if (!rc)
@@ -1240,27 +1251,29 @@ API_FUNC(config_new_section)
function_delete_option = Tcl_GetStringFromObj (objv[13], &i);
data_delete_option = Tcl_GetStringFromObj (objv[14], &i);
- result = API_PTR2STR(plugin_script_api_config_new_section (weechat_tcl_plugin,
- tcl_current_script,
- API_STR2PTR(cfg_file),
- name,
- can_add, /* user_can_add_options */
- can_delete, /* user_can_delete_options */
- &weechat_tcl_api_config_section_read_cb,
- function_read,
- data_read,
- &weechat_tcl_api_config_section_write_cb,
- function_write,
- data_write,
- &weechat_tcl_api_config_section_write_default_cb,
- function_write_default,
- data_write_default,
- &weechat_tcl_api_config_section_create_option_cb,
- function_create_option,
- data_create_option,
- &weechat_tcl_api_config_section_delete_option_cb,
- function_delete_option,
- data_delete_option));
+ result = API_PTR2STR(
+ plugin_script_api_config_new_section (
+ weechat_tcl_plugin,
+ tcl_current_script,
+ API_STR2PTR(cfg_file),
+ name,
+ can_add, /* user_can_add_options */
+ can_delete, /* user_can_delete_options */
+ &weechat_tcl_api_config_section_read_cb,
+ function_read,
+ data_read,
+ &weechat_tcl_api_config_section_write_cb,
+ function_write,
+ data_write,
+ &weechat_tcl_api_config_section_write_default_cb,
+ function_write_default,
+ data_write_default,
+ &weechat_tcl_api_config_section_create_option_cb,
+ function_create_option,
+ data_create_option,
+ &weechat_tcl_api_config_section_delete_option_cb,
+ function_delete_option,
+ data_delete_option));
API_RETURN_STRING_FREE(result);
}
@@ -1286,26 +1299,28 @@ API_FUNC(config_search_section)
int
-weechat_tcl_api_config_option_check_value_cb (void *data,
+weechat_tcl_api_config_option_check_value_cb (const void *pointer, void *data,
struct t_config_option *option,
const char *value)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(option);
func_argv[2] = (value) ? (char *)value : empty_arg;
- rc = (int *) weechat_tcl_exec (script_callback->script,
+ rc = (int *) weechat_tcl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -1325,24 +1340,26 @@ weechat_tcl_api_config_option_check_value_cb (void *data,
}
void
-weechat_tcl_api_config_option_change_cb (void *data,
+weechat_tcl_api_config_option_change_cb (const void *pointer, void *data,
struct t_config_option *option)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(option);
- rc = (int *) weechat_tcl_exec (script_callback->script,
+ rc = (int *) weechat_tcl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (func_argv[1])
@@ -1354,24 +1371,26 @@ weechat_tcl_api_config_option_change_cb (void *data,
}
void
-weechat_tcl_api_config_option_delete_cb (void *data,
+weechat_tcl_api_config_option_delete_cb (const void *pointer, void *data,
struct t_config_option *option)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(option);
- rc = (int *) weechat_tcl_exec (script_callback->script,
+ rc = (int *) weechat_tcl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (func_argv[1])
@@ -1818,9 +1837,8 @@ API_FUNC(config_option_free)
if (objc < 2)
API_WRONG_ARGS(API_RETURN_ERROR);
- plugin_script_api_config_option_free (weechat_tcl_plugin,
- tcl_current_script,
- API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i))); /* option */
+ weechat_config_option_free (
+ API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i))); /* option */
API_RETURN_OK;
}
@@ -1834,9 +1852,8 @@ API_FUNC(config_section_free_options)
if (objc < 2)
API_WRONG_ARGS(API_RETURN_ERROR);
- plugin_script_api_config_section_free_options (weechat_tcl_plugin,
- tcl_current_script,
- API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i))); /* section */
+ weechat_config_section_free_options (
+ API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i))); /* section */
API_RETURN_OK;
}
@@ -1850,9 +1867,8 @@ API_FUNC(config_section_free)
if (objc < 2)
API_WRONG_ARGS(API_RETURN_ERROR);
- plugin_script_api_config_section_free (weechat_tcl_plugin,
- tcl_current_script,
- API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i))); /* section */
+ weechat_config_section_free (
+ API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i))); /* section */
API_RETURN_OK;
}
@@ -1866,9 +1882,8 @@ API_FUNC(config_free)
if (objc < 2)
API_WRONG_ARGS(API_RETURN_ERROR);
- plugin_script_api_config_free (weechat_tcl_plugin,
- tcl_current_script,
- API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i))); /* config_file */
+ weechat_config_free (
+ API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i))); /* config_file */
API_RETURN_OK;
}
@@ -2152,28 +2167,31 @@ API_FUNC(log_print)
}
int
-weechat_tcl_api_hook_command_cb (void *data, struct t_gui_buffer *buffer,
+weechat_tcl_api_hook_command_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
/* make C compiler happy */
(void) argv;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
func_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg;
- rc = (int *) weechat_tcl_exec (script_callback->script,
+ rc = (int *) weechat_tcl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -2226,25 +2244,28 @@ API_FUNC(hook_command)
}
int
-weechat_tcl_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
+weechat_tcl_api_hook_command_run_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
const char *command)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
func_argv[2] = (command) ? (char *)command : empty_arg;
- rc = (int *) weechat_tcl_exec (script_callback->script,
+ rc = (int *) weechat_tcl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -2288,26 +2309,29 @@ API_FUNC(hook_command_run)
}
int
-weechat_tcl_api_hook_timer_cb (void *data, int remaining_calls)
+weechat_tcl_api_hook_timer_cb (const void *pointer, void *data,
+ int remaining_calls)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char str_remaining_calls[32], empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (str_remaining_calls, sizeof (str_remaining_calls),
"%d", remaining_calls);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = str_remaining_calls;
- rc = (int *) weechat_tcl_exec (script_callback->script,
+ rc = (int *) weechat_tcl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (!rc)
@@ -2353,25 +2377,27 @@ API_FUNC(hook_timer)
}
int
-weechat_tcl_api_hook_fd_cb (void *data, int fd)
+weechat_tcl_api_hook_fd_cb (const void *pointer, void *data, int fd)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char str_fd[32], empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (str_fd, sizeof (str_fd), "%d", fd);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = str_fd;
- rc = (int *) weechat_tcl_exec (script_callback->script,
+ rc = (int *) weechat_tcl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (!rc)
@@ -2418,28 +2444,49 @@ API_FUNC(hook_fd)
}
int
-weechat_tcl_api_hook_process_cb (void *data,
+weechat_tcl_api_hook_process_cb (const void *pointer, void *data,
const char *command, int return_code,
const char *out, const char *err)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[5];
- char empty_arg[1] = { '\0' };
+ char empty_arg[1] = { '\0' }, *result;
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
+
+ if (return_code == WEECHAT_HOOK_PROCESS_CHILD)
+ {
+ if (strncmp (command, "func:", 5) == 0)
+ {
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
- if (script_callback && script_callback->function && script_callback->function[0])
+ result = (char *) weechat_tcl_exec (script,
+ WEECHAT_SCRIPT_EXEC_STRING,
+ command + 5,
+ "s", func_argv);
+ if (result)
+ {
+ printf ("%s", result);
+ free (result);
+ return 0;
+ }
+ }
+ return 1;
+ }
+ else if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (command) ? (char *)command : empty_arg;
func_argv[2] = &return_code;
func_argv[3] = (out) ? (char *)out : empty_arg;
func_argv[4] = (err) ? (char *)err : empty_arg;
- rc = (int *) weechat_tcl_exec (script_callback->script,
+ rc = (int *) weechat_tcl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssiss", func_argv);
if (!rc)
@@ -2522,34 +2569,37 @@ API_FUNC(hook_process_hashtable)
}
int
-weechat_tcl_api_hook_connect_cb (void *data, int status, int gnutls_rc,
+weechat_tcl_api_hook_connect_cb (const void *pointer, void *data,
+ int status, int gnutls_rc,
int sock, const char *error,
const char *ip_address)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[6];
char str_status[32], str_gnutls_rc[32], str_sock[32];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (str_status, sizeof (str_status), "%d", status);
snprintf (str_gnutls_rc, sizeof (str_gnutls_rc), "%d", gnutls_rc);
snprintf (str_sock, sizeof (str_sock), "%d", sock);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = str_status;
func_argv[2] = str_gnutls_rc;
func_argv[3] = str_sock;
func_argv[4] = (ip_address) ? (char *)ip_address : empty_arg;
func_argv[5] = (error) ? (char *)error : empty_arg;
- rc = (int *) weechat_tcl_exec (script_callback->script,
+ rc = (int *) weechat_tcl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssssss", func_argv);
if (!rc)
@@ -2607,28 +2657,31 @@ API_FUNC(hook_connect)
}
int
-weechat_tcl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
+weechat_tcl_api_hook_print_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
time_t date,
int tags_count, const char **tags,
int displayed, int highlight,
const char *prefix, const char *message)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[8];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
static char timebuffer[64];
int *rc, ret;
/* make C compiler happy */
(void) tags_count;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (timebuffer, sizeof (timebuffer), "%ld", (long int)date);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
func_argv[2] = timebuffer;
func_argv[3] = weechat_string_build_with_split_string (tags, ",");
@@ -2639,9 +2692,9 @@ weechat_tcl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
func_argv[6] = (prefix) ? (char *)prefix : empty_arg;
func_argv[7] = (message) ? (char *)message : empty_arg;
- rc = (int *) weechat_tcl_exec (script_callback->script,
+ rc = (int *) weechat_tcl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssssiiss", func_argv);
if (!rc)
@@ -2695,20 +2748,23 @@ API_FUNC(hook_print)
}
int
-weechat_tcl_api_hook_signal_cb (void *data, const char *signal, const char *type_data,
+weechat_tcl_api_hook_signal_cb (const void *pointer, void *data,
+ const char *signal, const char *type_data,
void *signal_data)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
static char str_value[64];
int *rc, ret, free_needed;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (signal) ? (char *)signal : empty_arg;
free_needed = 0;
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
@@ -2733,9 +2789,9 @@ weechat_tcl_api_hook_signal_cb (void *data, const char *signal, const char *type
else
func_argv[2] = empty_arg;
- rc = (int *) weechat_tcl_exec (script_callback->script,
+ rc = (int *) weechat_tcl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -2820,25 +2876,28 @@ API_FUNC(hook_signal_send)
}
int
-weechat_tcl_api_hook_hsignal_cb (void *data, const char *signal,
+weechat_tcl_api_hook_hsignal_cb (const void *pointer, void *data,
+ const char *signal,
struct t_hashtable *hashtable)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (signal) ? (char *)signal : empty_arg;
func_argv[2] = hashtable;
- rc = (int *) weechat_tcl_exec (script_callback->script,
+ rc = (int *) weechat_tcl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssh", func_argv);
if (!rc)
@@ -2905,24 +2964,27 @@ API_FUNC(hook_hsignal_send)
}
int
-weechat_tcl_api_hook_config_cb (void *data, const char *option, const char *value)
+weechat_tcl_api_hook_config_cb (const void *pointer, void *data,
+ const char *option, const char *value)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (option) ? (char *)option : empty_arg;
func_argv[2] = (value) ? (char *)value : empty_arg;
- rc = (int *) weechat_tcl_exec (script_callback->script,
+ rc = (int *) weechat_tcl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
@@ -2964,27 +3026,30 @@ API_FUNC(hook_config)
}
int
-weechat_tcl_api_hook_completion_cb (void *data, const char *completion_item,
+weechat_tcl_api_hook_completion_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (completion_item) ? (char *)completion_item : empty_arg;
func_argv[2] = API_PTR2STR(buffer);
func_argv[3] = API_PTR2STR(completion);
- rc = (int *) weechat_tcl_exec (script_callback->script,
+ rc = (int *) weechat_tcl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssss", func_argv);
if (!rc)
@@ -3077,25 +3142,29 @@ API_FUNC(hook_completion_list_add)
}
char *
-weechat_tcl_api_hook_modifier_cb (void *data, const char *modifier,
- const char *modifier_data, const char *string)
+weechat_tcl_api_hook_modifier_cb (const void *pointer, void *data,
+ const char *modifier,
+ const char *modifier_data,
+ const char *string)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (modifier) ? (char *)modifier : empty_arg;
func_argv[2] = (modifier_data) ? (char *)modifier_data : empty_arg;
func_argv[3] = (string) ? (char *)string : empty_arg;
- return (char *)weechat_tcl_exec (script_callback->script,
+ return (char *)weechat_tcl_exec (script,
WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function,
+ ptr_function,
"ssss", func_argv);
}
@@ -3146,24 +3215,27 @@ API_FUNC(hook_modifier_exec)
}
const char *
-weechat_tcl_api_hook_info_cb (void *data, const char *info_name,
+weechat_tcl_api_hook_info_cb (const void *pointer, void *data,
+ const char *info_name,
const char *arguments)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (info_name) ? (char *)info_name : empty_arg;
func_argv[2] = (arguments) ? (char *)arguments : empty_arg;
- return (const char *)weechat_tcl_exec (script_callback->script,
+ return (const char *)weechat_tcl_exec (script,
WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
}
@@ -3199,25 +3271,29 @@ API_FUNC(hook_info)
}
struct t_hashtable *
-weechat_tcl_api_hook_info_hashtable_cb (void *data, const char *info_name,
+weechat_tcl_api_hook_info_hashtable_cb (const void *pointer, void *data,
+ const char *info_name,
struct t_hashtable *hashtable)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (info_name) ? (char *)info_name : empty_arg;
func_argv[2] = hashtable;
- return (struct t_hashtable *)weechat_tcl_exec (script_callback->script,
- WEECHAT_SCRIPT_EXEC_HASHTABLE,
- script_callback->function,
- "ssh", func_argv);
+ return (struct t_hashtable *)weechat_tcl_exec (
+ script,
+ WEECHAT_SCRIPT_EXEC_HASHTABLE,
+ ptr_function,
+ "ssh", func_argv);
}
return NULL;
@@ -3255,27 +3331,31 @@ API_FUNC(hook_info_hashtable)
}
struct t_infolist *
-weechat_tcl_api_hook_infolist_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+weechat_tcl_api_hook_infolist_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
struct t_infolist *result;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (infolist_name) ? (char *)infolist_name : empty_arg;
- func_argv[2] = API_PTR2STR(pointer);
+ func_argv[2] = API_PTR2STR(obj_pointer);
func_argv[3] = (arguments) ? (char *)arguments : empty_arg;
- result = (struct t_infolist *)weechat_tcl_exec (script_callback->script,
- WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function,
- "ssss", func_argv);
+ result = (struct t_infolist *)weechat_tcl_exec (
+ script,
+ WEECHAT_SCRIPT_EXEC_STRING,
+ ptr_function,
+ "ssss", func_argv);
if (func_argv[2])
free (func_argv[2]);
@@ -3318,24 +3398,27 @@ API_FUNC(hook_infolist)
}
struct t_hashtable *
-weechat_tcl_api_hook_focus_cb (void *data,
+weechat_tcl_api_hook_focus_cb (const void *pointer, void *data,
struct t_hashtable *info)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = info;
- return (struct t_hashtable *)weechat_tcl_exec (script_callback->script,
- WEECHAT_SCRIPT_EXEC_HASHTABLE,
- script_callback->function,
- "sh", func_argv);
+ return (struct t_hashtable *)weechat_tcl_exec (
+ script,
+ WEECHAT_SCRIPT_EXEC_HASHTABLE,
+ ptr_function,
+ "sh", func_argv);
}
return NULL;
@@ -3393,9 +3476,8 @@ API_FUNC(unhook)
if (objc < 2)
API_WRONG_ARGS(API_RETURN_ERROR);
- plugin_script_api_unhook (weechat_tcl_plugin,
- tcl_current_script,
- API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i))); /* hook */
+ weechat_unhook (
+ API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i))); /* hook */
API_RETURN_OK;
}
@@ -3411,31 +3493,34 @@ API_FUNC(unhook_all)
API_INIT_FUNC(1, "unhook_all", API_RETURN_ERROR);
- plugin_script_api_unhook_all (weechat_tcl_plugin, tcl_current_script);
+ weechat_unhook_all (tcl_current_script->name);
API_RETURN_OK;
}
int
-weechat_tcl_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
+weechat_tcl_api_buffer_input_data_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
const char *input_data)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
func_argv[2] = (input_data) ? (char *)input_data : empty_arg;
- rc = (int *) weechat_tcl_exec (script_callback->script,
+ rc = (int *) weechat_tcl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@@ -3454,23 +3539,26 @@ weechat_tcl_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
}
int
-weechat_tcl_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
+weechat_tcl_api_buffer_close_cb (const void *pointer,
+ void *data, struct t_gui_buffer *buffer)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[2];
char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);
- rc = (int *) weechat_tcl_exec (script_callback->script,
+ rc = (int *) weechat_tcl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ss", func_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@@ -3593,9 +3681,8 @@ API_FUNC(buffer_close)
if (objc < 2)
API_WRONG_ARGS(API_RETURN_ERROR);
- plugin_script_api_buffer_close (weechat_tcl_plugin,
- tcl_current_script,
- API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i))); /* buffer */
+ weechat_buffer_close (
+ API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i))); /* buffer */
API_RETURN_OK;
}
@@ -4198,31 +4285,34 @@ API_FUNC(bar_item_search)
}
char *
-weechat_tcl_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
+weechat_tcl_api_bar_item_build_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
struct t_gui_window *window,
struct t_gui_buffer *buffer,
struct t_hashtable *extra_info)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[5];
char empty_arg[1] = { '\0' }, *ret;
+ const char *ptr_function, *ptr_data;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
- if (strncmp (script_callback->function, "(extra)", 7) == 0)
+ if (strncmp (ptr_function, "(extra)", 7) == 0)
{
/* new callback: data, item, window, buffer, extra_info */
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(item);
func_argv[2] = API_PTR2STR(window);
func_argv[3] = API_PTR2STR(buffer);
func_argv[4] = extra_info;
- ret = (char *)weechat_tcl_exec (script_callback->script,
+ ret = (char *)weechat_tcl_exec (script,
WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function + 7,
+ ptr_function + 7,
"ssssh", func_argv);
if (func_argv[1])
@@ -4235,13 +4325,13 @@ weechat_tcl_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
else
{
/* old callback: data, item, window */
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(item);
func_argv[2] = API_PTR2STR(window);
- ret = (char *)weechat_tcl_exec (script_callback->script,
+ ret = (char *)weechat_tcl_exec (script,
WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function,
+ ptr_function,
"sss", func_argv);
if (func_argv[1])
@@ -4303,9 +4393,8 @@ API_FUNC(bar_item_remove)
if (objc < 2)
API_WRONG_ARGS(API_RETURN_ERROR);
- plugin_script_api_bar_item_remove (weechat_tcl_plugin,
- tcl_current_script,
- API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i))); /* item */
+ weechat_bar_item_remove (
+ API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i))); /* item */
API_RETURN_OK;
}
@@ -5179,74 +5268,33 @@ API_FUNC(hdata_get_string)
API_RETURN_STRING(result);
}
-API_FUNC(upgrade_new)
-{
- Tcl_Obj *objp;
- char *result, *filename;
- int i, write;
-
- API_INIT_FUNC(1, "upgrade_new", API_RETURN_EMPTY);
- if (objc < 3)
- API_WRONG_ARGS(API_RETURN_EMPTY);
-
- if (Tcl_GetIntFromObj (interp, objv[2], &write) != TCL_OK)
- API_WRONG_ARGS(API_RETURN_EMPTY);
-
- filename = Tcl_GetStringFromObj (objv[1], &i);
-
- result = API_PTR2STR(weechat_upgrade_new (filename, write));
-
- API_RETURN_STRING_FREE(result);
-}
-
-API_FUNC(upgrade_write_object)
-{
- Tcl_Obj *objp;
- char *upgrade_file, *infolist;
- int rc, i, object_id;
-
- API_INIT_FUNC(1, "upgrade_write_object", API_RETURN_INT(0));
- if (objc < 4)
- API_WRONG_ARGS(API_RETURN_INT(0));
-
- if (Tcl_GetIntFromObj (interp, objv[2], &object_id) != TCL_OK)
- API_WRONG_ARGS(API_RETURN_INT(0));
-
- upgrade_file = Tcl_GetStringFromObj (objv[1], &i);
- infolist = Tcl_GetStringFromObj (objv[3], &i);
-
- rc = weechat_upgrade_write_object (API_STR2PTR(upgrade_file),
- object_id,
- API_STR2PTR(infolist));
-
- API_RETURN_INT(rc);
-}
-
int
-weechat_tcl_api_upgrade_read_cb (void *data,
+weechat_tcl_api_upgrade_read_cb (const void *pointer, void *data,
struct t_upgrade_file *upgrade_file,
int object_id,
struct t_infolist *infolist)
{
- struct t_plugin_script_cb *script_callback;
+ struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' }, str_object_id[32];
+ const char *ptr_function, *ptr_data;
int *rc, ret;
- script_callback = (struct t_plugin_script_cb *)data;
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (script_callback && script_callback->function && script_callback->function[0])
+ if (ptr_function && ptr_function[0])
{
snprintf (str_object_id, sizeof (str_object_id), "%d", object_id);
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(upgrade_file);
func_argv[2] = str_object_id;
func_argv[3] = API_PTR2STR(infolist);
- rc = (int *) weechat_tcl_exec (script_callback->script,
+ rc = (int *) weechat_tcl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
- script_callback->function,
+ ptr_function,
"ssss", func_argv);
if (!rc)
@@ -5267,26 +5315,68 @@ weechat_tcl_api_upgrade_read_cb (void *data,
return WEECHAT_RC_ERROR;
}
+API_FUNC(upgrade_new)
+{
+ Tcl_Obj *objp;
+ char *result, *filename, *function, *data;
+ int i;
+
+ API_INIT_FUNC(1, "upgrade_new", API_RETURN_EMPTY);
+ if (objc < 4)
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ filename = Tcl_GetStringFromObj (objv[1], &i);
+ function = Tcl_GetStringFromObj (objv[2], &i);
+ data = Tcl_GetStringFromObj (objv[3], &i);
+
+ result = API_PTR2STR(
+ plugin_script_api_upgrade_new (
+ weechat_tcl_plugin,
+ tcl_current_script,
+ filename,
+ &weechat_tcl_api_upgrade_read_cb,
+ function,
+ data));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+API_FUNC(upgrade_write_object)
+{
+ Tcl_Obj *objp;
+ char *upgrade_file, *infolist;
+ int rc, i, object_id;
+
+ API_INIT_FUNC(1, "upgrade_write_object", API_RETURN_INT(0));
+ if (objc < 4)
+ API_WRONG_ARGS(API_RETURN_INT(0));
+
+ if (Tcl_GetIntFromObj (interp, objv[2], &object_id) != TCL_OK)
+ API_WRONG_ARGS(API_RETURN_INT(0));
+
+ upgrade_file = Tcl_GetStringFromObj (objv[1], &i);
+ infolist = Tcl_GetStringFromObj (objv[3], &i);
+
+ rc = weechat_upgrade_write_object (API_STR2PTR(upgrade_file),
+ object_id,
+ API_STR2PTR(infolist));
+
+ API_RETURN_INT(rc);
+}
+
API_FUNC(upgrade_read)
{
Tcl_Obj *objp;
- char *upgrade_file, *function, *data;
+ char *upgrade_file;
int i, rc;
API_INIT_FUNC(1, "upgrade_read", API_RETURN_INT(0));
- if (objc < 4)
+ if (objc < 2)
API_WRONG_ARGS(API_RETURN_INT(0));
upgrade_file = Tcl_GetStringFromObj (objv[1], &i);
- function = Tcl_GetStringFromObj (objv[2], &i);
- data = Tcl_GetStringFromObj (objv[3], &i);
- rc = plugin_script_api_upgrade_read (weechat_tcl_plugin,
- tcl_current_script,
- API_STR2PTR(upgrade_file),
- &weechat_tcl_api_upgrade_read_cb,
- function,
- data);
+ rc = weechat_upgrade_read (API_STR2PTR(upgrade_file));
API_RETURN_INT(rc);
}
diff --git a/src/plugins/tcl/weechat-tcl-api.h b/src/plugins/tcl/weechat-tcl-api.h
index 22675d4b2..758bb7f48 100644
--- a/src/plugins/tcl/weechat-tcl-api.h
+++ b/src/plugins/tcl/weechat-tcl-api.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2008-2010 Dmitry Kobylin <fnfal@academ.tsc.ru>
- * Copyright (C) 2008-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2008-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -21,10 +21,12 @@
#ifndef WEECHAT_TCL_API_H
#define WEECHAT_TCL_API_H 1
-extern int weechat_tcl_api_buffer_input_data_cb (void *data,
+extern int weechat_tcl_api_buffer_input_data_cb (const void *pointer,
+ void *data,
struct t_gui_buffer *buffer,
const char *input_data);
-extern int weechat_tcl_api_buffer_close_cb (void *data,
+extern int weechat_tcl_api_buffer_close_cb (const void *pointer,
+ void *data,
struct t_gui_buffer *buffer);
extern void weechat_tcl_api_init (Tcl_Interp *interp);
diff --git a/src/plugins/tcl/weechat-tcl.c b/src/plugins/tcl/weechat-tcl.c
index e2c32187c..91297e56a 100644
--- a/src/plugins/tcl/weechat-tcl.c
+++ b/src/plugins/tcl/weechat-tcl.c
@@ -2,7 +2,7 @@
* weechat-tcl.c - tcl plugin for WeeChat
*
* Copyright (C) 2008-2010 Dmitry Kobylin <fnfal@academ.tsc.ru>
- * Copyright (C) 2008-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2008-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -122,8 +122,7 @@ weechat_tcl_hashtable_to_dict (Tcl_Interp *interp,
data[0] = interp;
data[1] = dict;
- weechat_hashtable_map_string (hashtable,
- &weechat_tcl_hashtable_map_cb,
+ weechat_hashtable_map_string (hashtable, &weechat_tcl_hashtable_map_cb,
data);
return dict;
@@ -519,12 +518,14 @@ weechat_tcl_reload_name (const char *name)
*/
int
-weechat_tcl_command_cb (void *data, struct t_gui_buffer *buffer,
+weechat_tcl_command_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
char *ptr_name, *path_script;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
@@ -620,11 +621,13 @@ weechat_tcl_command_cb (void *data, struct t_gui_buffer *buffer,
*/
int
-weechat_tcl_completion_cb (void *data, const char *completion_item,
+weechat_tcl_completion_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -639,9 +642,11 @@ weechat_tcl_completion_cb (void *data, const char *completion_item,
*/
struct t_hdata *
-weechat_tcl_hdata_cb (void *data, const char *hdata_name)
+weechat_tcl_hdata_cb (const void *pointer, void *data,
+ const char *hdata_name)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
return plugin_script_hdata_script (weechat_plugin,
@@ -654,10 +659,12 @@ weechat_tcl_hdata_cb (void *data, const char *hdata_name)
*/
struct t_infolist *
-weechat_tcl_infolist_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+weechat_tcl_infolist_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (!infolist_name || !infolist_name[0])
@@ -666,7 +673,7 @@ weechat_tcl_infolist_cb (void *data, const char *infolist_name,
if (weechat_strcasecmp (infolist_name, "tcl_script") == 0)
{
return plugin_script_infolist_list_scripts (weechat_tcl_plugin,
- tcl_scripts, pointer,
+ tcl_scripts, obj_pointer,
arguments);
}
@@ -678,10 +685,12 @@ weechat_tcl_infolist_cb (void *data, const char *infolist_name,
*/
int
-weechat_tcl_signal_debug_dump_cb (void *data, const char *signal,
+weechat_tcl_signal_debug_dump_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -700,10 +709,12 @@ weechat_tcl_signal_debug_dump_cb (void *data, const char *signal,
*/
int
-weechat_tcl_signal_debug_libs_cb (void *data, const char *signal,
+weechat_tcl_signal_debug_libs_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data, void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -719,37 +730,20 @@ weechat_tcl_signal_debug_libs_cb (void *data, const char *signal,
}
/*
- * Callback called when a buffer is closed.
- */
-
-int
-weechat_tcl_signal_buffer_closed_cb (void *data, const char *signal,
- const char *type_data, void *signal_data)
-{
- /* make C compiler happy */
- (void) data;
- (void) signal;
- (void) type_data;
-
- if (signal_data)
- plugin_script_remove_buffer_callbacks (tcl_scripts, signal_data);
-
- return WEECHAT_RC_OK;
-}
-
-/*
* Timer for executing actions.
*/
int
-weechat_tcl_timer_action_cb (void *data, int remaining_calls)
+weechat_tcl_timer_action_cb (const void *pointer, void *data,
+ int remaining_calls)
{
/* make C compiler happy */
+ (void) data;
(void) remaining_calls;
- if (data)
+ if (pointer)
{
- if (data == &tcl_action_install_list)
+ if (pointer == &tcl_action_install_list)
{
plugin_script_action_install (weechat_tcl_plugin,
tcl_scripts,
@@ -758,7 +752,7 @@ weechat_tcl_timer_action_cb (void *data, int remaining_calls)
&tcl_quiet,
&tcl_action_install_list);
}
- else if (data == &tcl_action_remove_list)
+ else if (pointer == &tcl_action_remove_list)
{
plugin_script_action_remove (weechat_tcl_plugin,
tcl_scripts,
@@ -766,7 +760,7 @@ weechat_tcl_timer_action_cb (void *data, int remaining_calls)
&tcl_quiet,
&tcl_action_remove_list);
}
- else if (data == &tcl_action_autoload_list)
+ else if (pointer == &tcl_action_autoload_list)
{
plugin_script_action_autoload (weechat_tcl_plugin,
&tcl_quiet,
@@ -782,11 +776,13 @@ weechat_tcl_timer_action_cb (void *data, int remaining_calls)
*/
int
-weechat_tcl_signal_script_action_cb (void *data, const char *signal,
+weechat_tcl_signal_script_action_cb (const void *pointer, void *data,
+ const char *signal,
const char *type_data,
void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
@@ -797,7 +793,7 @@ weechat_tcl_signal_script_action_cb (void *data, const char *signal,
(const char *)signal_data);
weechat_hook_timer (1, 0, 1,
&weechat_tcl_timer_action_cb,
- &tcl_action_install_list);
+ &tcl_action_install_list, NULL);
}
else if (strcmp (signal, "tcl_script_remove") == 0)
{
@@ -805,7 +801,7 @@ weechat_tcl_signal_script_action_cb (void *data, const char *signal,
(const char *)signal_data);
weechat_hook_timer (1, 0, 1,
&weechat_tcl_timer_action_cb,
- &tcl_action_remove_list);
+ &tcl_action_remove_list, NULL);
}
else if (strcmp (signal, "tcl_script_autoload") == 0)
{
@@ -813,7 +809,7 @@ weechat_tcl_signal_script_action_cb (void *data, const char *signal,
(const char *)signal_data);
weechat_hook_timer (1, 0, 1,
&weechat_tcl_timer_action_cb,
- &tcl_action_autoload_list);
+ &tcl_action_autoload_list, NULL);
}
}
@@ -837,7 +833,6 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
init.callback_infolist = &weechat_tcl_infolist_cb;
init.callback_signal_debug_dump = &weechat_tcl_signal_debug_dump_cb;
init.callback_signal_debug_libs = &weechat_tcl_signal_debug_libs_cb;
- init.callback_signal_buffer_closed = &weechat_tcl_signal_buffer_closed_cb;
init.callback_signal_script_action = &weechat_tcl_signal_script_action_cb;
init.callback_load_file = &weechat_tcl_load_cb;
diff --git a/src/plugins/tcl/weechat-tcl.h b/src/plugins/tcl/weechat-tcl.h
index 3bbf6580a..b2d59277b 100644
--- a/src/plugins/tcl/weechat-tcl.h
+++ b/src/plugins/tcl/weechat-tcl.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2008-2010 Dmitry Kobylin <fnfal@academ.tsc.ru>
- * Copyright (C) 2008-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2008-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/trigger/CMakeLists.txt b/src/plugins/trigger/CMakeLists.txt
index c98ecfb56..c43eb4721 100644
--- a/src/plugins/trigger/CMakeLists.txt
+++ b/src/plugins/trigger/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2014-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2014-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/trigger/Makefile.am b/src/plugins/trigger/Makefile.am
index d612840cb..7a08e8173 100644
--- a/src/plugins/trigger/Makefile.am
+++ b/src/plugins/trigger/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2014-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2014-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/trigger/trigger-buffer.c b/src/plugins/trigger/trigger-buffer.c
index c8aea8af0..a0d67ee3e 100644
--- a/src/plugins/trigger/trigger-buffer.c
+++ b/src/plugins/trigger/trigger-buffer.c
@@ -1,7 +1,7 @@
/*
* trigger-buffer.c - debug buffer for triggers
*
- * Copyright (C) 2014-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2014-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -114,10 +114,12 @@ trigger_buffer_set_title ()
*/
int
-trigger_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
- const char *input_data)
+trigger_buffer_input_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
+ const char *input_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
/* close buffer */
@@ -144,9 +146,11 @@ trigger_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
*/
int
-trigger_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
+trigger_buffer_close_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
@@ -188,9 +192,10 @@ trigger_buffer_open (const char *filter, int switch_to_buffer)
{
if (!trigger_buffer)
{
- trigger_buffer = weechat_buffer_new (TRIGGER_BUFFER_NAME,
- &trigger_buffer_input_cb, NULL,
- &trigger_buffer_close_cb, NULL);
+ trigger_buffer = weechat_buffer_new (
+ TRIGGER_BUFFER_NAME,
+ &trigger_buffer_input_cb, NULL, NULL,
+ &trigger_buffer_close_cb, NULL, NULL);
/* failed to create buffer ? then return */
if (!trigger_buffer)
@@ -249,22 +254,23 @@ trigger_buffer_hashtable_map_cb (void *data,
{
value_no_color = (weechat_config_boolean (trigger_config_look_monitor_strip_colors)) ?
weechat_string_remove_color ((const char *)value, NULL) : NULL;
- weechat_printf_tags (trigger_buffer, "no_trigger",
- "\t %s: %s\"%s%s%s\"",
- (char *)key,
- weechat_color ("chat_delimiters"),
- weechat_color ("reset"),
- (value_no_color) ? value_no_color : (const char *)value,
- weechat_color ("chat_delimiters"));
+ weechat_printf_date_tags (
+ trigger_buffer, 0, "no_trigger",
+ "\t %s: %s\"%s%s%s\"",
+ (char *)key,
+ weechat_color ("chat_delimiters"),
+ weechat_color ("reset"),
+ (value_no_color) ? value_no_color : (const char *)value,
+ weechat_color ("chat_delimiters"));
if (value_no_color)
free (value_no_color);
}
else if (strcmp (value_type, "pointer") == 0)
{
- weechat_printf_tags (trigger_buffer, "no_trigger",
- "\t %s: 0x%lx",
- (char *)key,
- value);
+ weechat_printf_date_tags (trigger_buffer, 0, "no_trigger",
+ "\t %s: 0x%lx",
+ (char *)key,
+ value);
}
}
@@ -279,7 +285,7 @@ trigger_buffer_display_hashtable (const char *name,
if (!trigger_buffer)
return;
- weechat_printf_tags (trigger_buffer, "no_trigger", " %s:", name);
+ weechat_printf_date_tags (trigger_buffer, 0, "no_trigger", " %s:", name);
weechat_hashtable_map (hashtable, &trigger_buffer_hashtable_map_cb, NULL);
}
@@ -305,21 +311,23 @@ trigger_buffer_display_trigger (struct t_trigger *trigger,
if (!trigger_buffer_match_filters (trigger))
return 0;
- weechat_printf_tags (trigger_buffer, "no_trigger",
- "%s\t%s%s %s(%s%s%s)",
- trigger_hook_type_string[weechat_config_integer (trigger->options[TRIGGER_OPTION_HOOK])],
- weechat_color (weechat_config_string (trigger_config_color_trigger)),
- trigger->name,
- weechat_color ("chat_delimiters"),
- weechat_color ("reset"),
- weechat_config_string (trigger->options[TRIGGER_OPTION_ARGUMENTS]),
- weechat_color ("chat_delimiters"));
+ weechat_printf_date_tags (
+ trigger_buffer, 0, "no_trigger",
+ "%s\t%s%s %s(%s%s%s)",
+ trigger_hook_type_string[weechat_config_integer (trigger->options[TRIGGER_OPTION_HOOK])],
+ weechat_color (weechat_config_string (trigger_config_color_trigger)),
+ trigger->name,
+ weechat_color ("chat_delimiters"),
+ weechat_color ("reset"),
+ weechat_config_string (trigger->options[TRIGGER_OPTION_ARGUMENTS]),
+ weechat_color ("chat_delimiters"));
if (buffer)
{
- weechat_printf_tags (trigger_buffer, "no_trigger",
- "\t buffer: %s%s",
- weechat_color ("chat_buffer"),
- weechat_buffer_get_string (buffer, "full_name"));
+ weechat_printf_date_tags (
+ trigger_buffer, 0, "no_trigger",
+ "\t buffer: %s%s",
+ weechat_color ("chat_buffer"),
+ weechat_buffer_get_string (buffer, "full_name"));
}
if (pointers)
trigger_buffer_display_hashtable ("pointers", pointers);
diff --git a/src/plugins/trigger/trigger-buffer.h b/src/plugins/trigger/trigger-buffer.h
index 1b30c7951..d61a9144a 100644
--- a/src/plugins/trigger/trigger-buffer.h
+++ b/src/plugins/trigger/trigger-buffer.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2014-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -22,7 +22,7 @@
#define TRIGGER_BUFFER_NAME "monitor"
-struct t_gui_buffer *trigger_buffer;
+extern struct t_gui_buffer *trigger_buffer;
extern void trigger_buffer_set_callbacks ();
extern void trigger_buffer_open (const char *filter, int switch_to_buffer);
diff --git a/src/plugins/trigger/trigger-callback.c b/src/plugins/trigger/trigger-callback.c
index cd89f6a2c..184394576 100644
--- a/src/plugins/trigger/trigger-callback.c
+++ b/src/plugins/trigger/trigger-callback.c
@@ -1,7 +1,7 @@
/*
* trigger-callback.c - callbacks for triggers
*
- * Copyright (C) 2014-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2014-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -56,8 +56,7 @@ trigger_callback_irc_message_parse (const char *irc_message,
hashtable_in = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
if (hashtable_in)
{
weechat_hashtable_set (hashtable_in, "message", irc_message);
@@ -187,8 +186,7 @@ trigger_callback_replace_regex (struct t_trigger *trigger,
pointers = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_POINTER,
- NULL,
- NULL);
+ NULL, NULL);
if (!pointers)
return;
pointers_allocated = 1;
@@ -207,9 +205,9 @@ trigger_callback_replace_regex (struct t_trigger *trigger,
{
if (trigger_buffer && display_monitor)
{
- weechat_printf_tags (trigger_buffer, "no_trigger",
- "\t regex %d: %s",
- i + 1, _("no variable"));
+ weechat_printf_date_tags (trigger_buffer, 0, "no_trigger",
+ "\t regex %d: %s",
+ i + 1, _("no variable"));
}
continue;
}
@@ -219,9 +217,9 @@ trigger_callback_replace_regex (struct t_trigger *trigger,
{
if (trigger_buffer && display_monitor)
{
- weechat_printf_tags (trigger_buffer, "no_trigger",
- "\t regex %d (%s): %s",
- i + 1, ptr_key, _("empty variable"));
+ weechat_printf_date_tags (trigger_buffer, 0, "no_trigger",
+ "\t regex %d (%s): %s",
+ i + 1, ptr_key, _("empty variable"));
}
continue;
}
@@ -242,19 +240,19 @@ trigger_callback_replace_regex (struct t_trigger *trigger,
/* display debug info on trigger buffer */
if (trigger_buffer && display_monitor)
{
- weechat_printf_tags (trigger_buffer, "no_trigger",
- "\t regex %d %s(%s%s%s)%s: "
- "%s\"%s%s%s\"",
- i + 1,
- weechat_color ("chat_delimiters"),
- weechat_color ("reset"),
- ptr_key,
- weechat_color ("chat_delimiters"),
- weechat_color ("reset"),
- weechat_color ("chat_delimiters"),
- weechat_color ("reset"),
- value,
- weechat_color ("chat_delimiters"));
+ weechat_printf_date_tags (trigger_buffer, 0, "no_trigger",
+ "\t regex %d %s(%s%s%s)%s: "
+ "%s\"%s%s%s\"",
+ i + 1,
+ weechat_color ("chat_delimiters"),
+ weechat_color ("reset"),
+ ptr_key,
+ weechat_color ("chat_delimiters"),
+ weechat_color ("reset"),
+ weechat_color ("chat_delimiters"),
+ weechat_color ("reset"),
+ value,
+ weechat_color ("chat_delimiters"));
}
weechat_hashtable_set (extra_vars, ptr_key, value);
free (value);
@@ -301,19 +299,20 @@ trigger_callback_run_command (struct t_trigger *trigger,
/* display debug info on trigger buffer */
if (trigger_buffer && display_monitor)
{
- weechat_printf_tags (trigger_buffer, "no_trigger",
- _("%s running command %s\"%s%s%s\"%s "
- "on buffer %s%s%s"),
- "\t",
- weechat_color ("chat_delimiters"),
- weechat_color ("reset"),
- command_eval,
- weechat_color ("chat_delimiters"),
- weechat_color ("reset"),
- weechat_color ("chat_buffer"),
- weechat_buffer_get_string (buffer,
- "full_name"),
- weechat_color ("reset"));
+ weechat_printf_date_tags (
+ trigger_buffer, 0, "no_trigger",
+ _("%s running command %s\"%s%s%s\"%s "
+ "on buffer %s%s%s"),
+ "\t",
+ weechat_color ("chat_delimiters"),
+ weechat_color ("reset"),
+ command_eval,
+ weechat_color ("chat_delimiters"),
+ weechat_color ("reset"),
+ weechat_color ("chat_buffer"),
+ weechat_buffer_get_string (buffer,
+ "full_name"),
+ weechat_color ("reset"));
}
weechat_command (buffer, command_eval);
trigger->hook_count_cmd++;
@@ -366,8 +365,9 @@ trigger_callback_execute (struct t_trigger *trigger,
*/
int
-trigger_callback_signal_cb (void *data, const char *signal,
- const char *type_data, void *signal_data)
+trigger_callback_signal_cb (const void *pointer, void *data,
+ const char *signal, const char *type_data,
+ void *signal_data)
{
const char *ptr_signal_data;
char str_data[128], *irc_server;
@@ -463,7 +463,8 @@ end:
*/
int
-trigger_callback_hsignal_cb (void *data, const char *signal,
+trigger_callback_hsignal_cb (const void *pointer, void *data,
+ const char *signal,
struct t_hashtable *hashtable)
{
const char *type_values;
@@ -510,8 +511,9 @@ end:
*/
char *
-trigger_callback_modifier_cb (void *data, const char *modifier,
- const char *modifier_data, const char *string)
+trigger_callback_modifier_cb (const void *pointer, void *data,
+ const char *modifier, const char *modifier_data,
+ const char *string)
{
struct t_gui_buffer *buffer;
const char *ptr_string;
@@ -691,7 +693,8 @@ end:
*/
int
-trigger_callback_print_cb (void *data, struct t_gui_buffer *buffer,
+trigger_callback_print_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
time_t date, int tags_count, const char **tags,
int displayed, int highlight, const char *prefix,
const char *message)
@@ -766,7 +769,8 @@ end:
*/
int
-trigger_callback_command_cb (void *data, struct t_gui_buffer *buffer,
+trigger_callback_command_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
char str_name[32];
@@ -799,7 +803,8 @@ end:
*/
int
-trigger_callback_command_run_cb (void *data, struct t_gui_buffer *buffer,
+trigger_callback_command_run_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
const char *command)
{
TRIGGER_CALLBACK_CB_INIT(WEECHAT_RC_OK);
@@ -823,7 +828,8 @@ end:
*/
int
-trigger_callback_timer_cb (void *data, int remaining_calls)
+trigger_callback_timer_cb (const void *pointer, void *data,
+ int remaining_calls)
{
char str_temp[128];
int i;
@@ -870,7 +876,8 @@ end:
*/
int
-trigger_callback_config_cb (void *data, const char *option, const char *value)
+trigger_callback_config_cb (const void *pointer, void *data,
+ const char *option, const char *value)
{
TRIGGER_CALLBACK_CB_INIT(WEECHAT_RC_OK);
@@ -892,7 +899,8 @@ end:
*/
struct t_hashtable *
-trigger_callback_focus_cb (void *data, struct t_hashtable *info)
+trigger_callback_focus_cb (const void *pointer, void *data,
+ struct t_hashtable *info)
{
const char *ptr_value;
long unsigned int value;
@@ -936,8 +944,7 @@ trigger_callback_init ()
32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
if (trigger_callback_hashtable_options_conditions)
{
weechat_hashtable_set (trigger_callback_hashtable_options_conditions,
@@ -948,8 +955,7 @@ trigger_callback_init ()
32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
- NULL,
- NULL);
+ NULL, NULL);
}
/*
diff --git a/src/plugins/trigger/trigger-callback.h b/src/plugins/trigger/trigger-callback.h
index e0b8b0663..e6bda1730 100644
--- a/src/plugins/trigger/trigger-callback.h
+++ b/src/plugins/trigger/trigger-callback.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2014-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -26,10 +26,11 @@
int trigger_rc; \
pointers = NULL; \
extra_vars = NULL; \
+ (void) data; \
(void) trigger_rc; \
if (!trigger_enabled) \
return __rc; \
- trigger = (struct t_trigger *)data; \
+ trigger = (struct t_trigger *)pointer; \
if (!trigger || trigger->hook_running) \
return __rc; \
trigger->hook_count_cb++; \
@@ -43,8 +44,7 @@
32, \
WEECHAT_HASHTABLE_STRING, \
WEECHAT_HASHTABLE_POINTER, \
- NULL, \
- NULL); \
+ NULL, NULL); \
if (!pointers) \
goto end;
@@ -53,8 +53,7 @@
32, \
WEECHAT_HASHTABLE_STRING, \
WEECHAT_HASHTABLE_STRING, \
- NULL, \
- NULL); \
+ NULL, NULL); \
if (!extra_vars) \
goto end;
@@ -64,29 +63,55 @@
if (extra_vars) \
weechat_hashtable_free (extra_vars); \
trigger->hook_running = 0; \
+ switch (weechat_config_integer ( \
+ trigger->options[TRIGGER_OPTION_POST_ACTION])) \
+ { \
+ case TRIGGER_POST_ACTION_DISABLE: \
+ weechat_config_option_set ( \
+ trigger->options[TRIGGER_OPTION_ENABLED], \
+ "off", 1); \
+ break; \
+ case TRIGGER_POST_ACTION_DELETE: \
+ trigger_free (trigger); \
+ break; \
+ default: \
+ /* do nothing in the other cases */ \
+ break; \
+ } \
return __rc;
-extern int trigger_callback_signal_cb (void *data, const char *signal,
- const char *type_data, void *signal_data);
-extern int trigger_callback_hsignal_cb (void *data, const char *signal,
+extern int trigger_callback_signal_cb (const void *pointer, void *data,
+ const char *signal,
+ const char *type_data,
+ void *signal_data);
+extern int trigger_callback_hsignal_cb (const void *pointer, void *data,
+ const char *signal,
struct t_hashtable *hashtable);
-extern char *trigger_callback_modifier_cb (void *data, const char *modifier,
+extern char *trigger_callback_modifier_cb (const void *pointer, void *data,
+ const char *modifier,
const char *modifier_data,
const char *string);
-extern int trigger_callback_print_cb (void *data, struct t_gui_buffer *buffer,
+extern int trigger_callback_print_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
time_t date, int tags_count,
const char **tags, int displayed,
int highlight, const char *prefix,
const char *message);
-extern int trigger_callback_command_cb (void *data, struct t_gui_buffer *buffer,
- int argc, char **argv, char **argv_eol);
-extern int trigger_callback_command_run_cb (void *data,
+extern int trigger_callback_command_cb (const void *pointer,
+ void *data,
+ struct t_gui_buffer *buffer,
+ int argc, char **argv,
+ char **argv_eol);
+extern int trigger_callback_command_run_cb (const void *pointer,
+ void *data,
struct t_gui_buffer *buffer,
const char *command);
-extern int trigger_callback_timer_cb (void *data, int remaining_calls);
-extern int trigger_callback_config_cb (void *data, const char *option,
- const char *value);
-extern struct t_hashtable *trigger_callback_focus_cb (void *data,
+extern int trigger_callback_timer_cb (const void *pointer, void *data,
+ int remaining_calls);
+extern int trigger_callback_config_cb (const void *pointer, void *data,
+ const char *option, const char *value);
+extern struct t_hashtable *trigger_callback_focus_cb (const void *pointer,
+ void *data,
struct t_hashtable *info);
extern void trigger_callback_init ();
extern void trigger_callback_end ();
diff --git a/src/plugins/trigger/trigger-command.c b/src/plugins/trigger/trigger-command.c
index 9faa77507..c0544405e 100644
--- a/src/plugins/trigger/trigger-command.c
+++ b/src/plugins/trigger/trigger-command.c
@@ -1,7 +1,7 @@
/*
* trigger-command.c - trigger command
*
- * Copyright (C) 2014-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2014-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -36,9 +36,9 @@
void
trigger_command_display_status ()
{
- weechat_printf_tags (NULL, "no_trigger",
- (trigger_enabled) ?
- _("Triggers enabled") : _("Triggers disabled"));
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ (trigger_enabled) ?
+ _("Triggers enabled") : _("Triggers disabled"));
}
/*
@@ -59,16 +59,17 @@ trigger_command_display_trigger_internal (const char *name,
int commands_count,
char **commands,
int return_code,
+ int post_action,
int verbose)
{
char str_conditions[64], str_regex[64], str_command[64], str_rc[64];
- char spaces[256];
+ char str_post_action[64], spaces[256];
int i, length;
if (verbose >= 1)
{
- weechat_printf_tags (
- NULL, "no_trigger",
+ weechat_printf_date_tags (
+ NULL, 0, "no_trigger",
" %s%s%s: %s%s%s%s%s%s%s",
(enabled) ?
weechat_color (weechat_config_string (trigger_config_color_trigger)) :
@@ -89,69 +90,83 @@ trigger_command_display_trigger_internal (const char *name,
spaces[length] = '\0';
if (verbose >= 2)
{
- weechat_printf_tags (NULL, "no_trigger",
- "%s hooks: %d", spaces, hooks_count);
- weechat_printf_tags (NULL, "no_trigger",
- "%s callback: %d",
- spaces, hook_count_cb);
- weechat_printf_tags (NULL, "no_trigger",
- "%s commands: %d",
- spaces, hook_count_cmd);
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ "%s hooks: %d", spaces, hooks_count);
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ "%s callback: %d",
+ spaces, hook_count_cb);
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ "%s commands: %d",
+ spaces, hook_count_cmd);
}
if (conditions && conditions[0])
{
- weechat_printf_tags (NULL, "no_trigger",
- "%s %s=? %s\"%s%s%s\"",
- spaces,
- weechat_color (weechat_config_string (trigger_config_color_flag_conditions)),
- weechat_color ("chat_delimiters"),
- weechat_color ("reset"),
- conditions,
- weechat_color ("chat_delimiters"));
+ weechat_printf_date_tags (
+ NULL, 0, "no_trigger",
+ "%s %s=? %s\"%s%s%s\"",
+ spaces,
+ weechat_color (weechat_config_string (trigger_config_color_flag_conditions)),
+ weechat_color ("chat_delimiters"),
+ weechat_color ("reset"),
+ conditions,
+ weechat_color ("chat_delimiters"));
}
for (i = 0; i < regex_count; i++)
{
- weechat_printf_tags (NULL, "no_trigger",
- "%s %s~%d %s\"%s%s%s\" --> "
- "\"%s%s%s\"%s%s%s%s",
- spaces,
- weechat_color (weechat_config_string (trigger_config_color_flag_regex)),
- i + 1,
- weechat_color ("chat_delimiters"),
- weechat_color (weechat_config_string (trigger_config_color_regex)),
- regex[i].str_regex,
- weechat_color ("chat_delimiters"),
- weechat_color (weechat_config_string (trigger_config_color_replace)),
- regex[i].replace,
- weechat_color ("chat_delimiters"),
- weechat_color ("reset"),
- (regex[i].variable) ? " (" : "",
- (regex[i].variable) ? regex[i].variable : "",
- (regex[i].variable) ? ")" : "");
+ weechat_printf_date_tags (
+ NULL, 0, "no_trigger",
+ "%s %s~%d %s\"%s%s%s\" --> "
+ "\"%s%s%s\"%s%s%s%s",
+ spaces,
+ weechat_color (weechat_config_string (trigger_config_color_flag_regex)),
+ i + 1,
+ weechat_color ("chat_delimiters"),
+ weechat_color (weechat_config_string (trigger_config_color_regex)),
+ regex[i].str_regex,
+ weechat_color ("chat_delimiters"),
+ weechat_color (weechat_config_string (trigger_config_color_replace)),
+ regex[i].replace,
+ weechat_color ("chat_delimiters"),
+ weechat_color ("reset"),
+ (regex[i].variable) ? " (" : "",
+ (regex[i].variable) ? regex[i].variable : "",
+ (regex[i].variable) ? ")" : "");
}
if (commands)
{
for (i = 0; commands[i]; i++)
{
- weechat_printf_tags (NULL, "no_trigger",
- "%s %s/%d %s\"%s%s%s\"",
- spaces,
- weechat_color (weechat_config_string (trigger_config_color_flag_command)),
- i + 1,
- weechat_color ("chat_delimiters"),
- weechat_color ("reset"),
- commands[i],
- weechat_color ("chat_delimiters"));
+ weechat_printf_date_tags (
+ NULL, 0, "no_trigger",
+ "%s %s/%d %s\"%s%s%s\"",
+ spaces,
+ weechat_color (weechat_config_string (trigger_config_color_flag_command)),
+ i + 1,
+ weechat_color ("chat_delimiters"),
+ weechat_color ("reset"),
+ commands[i],
+ weechat_color ("chat_delimiters"));
}
}
if ((return_code >= 0) && (return_code != TRIGGER_RC_OK))
{
- weechat_printf_tags (NULL, "no_trigger",
- "%s %s=> %s%s",
- spaces,
- weechat_color (weechat_config_string (trigger_config_color_flag_return_code)),
- weechat_color ("reset"),
- trigger_return_code_string[return_code]);
+ weechat_printf_date_tags (
+ NULL, 0, "no_trigger",
+ "%s %s=> %s%s",
+ spaces,
+ weechat_color (weechat_config_string (trigger_config_color_flag_return_code)),
+ weechat_color ("reset"),
+ trigger_return_code_string[return_code]);
+ }
+ if ((post_action >= 0) && (post_action != TRIGGER_POST_ACTION_NONE))
+ {
+ weechat_printf_date_tags (
+ NULL, 0, "no_trigger",
+ "%s %s=1 %s%s",
+ spaces,
+ weechat_color (weechat_config_string (trigger_config_color_flag_post_action)),
+ weechat_color ("reset"),
+ trigger_post_action_string[post_action]);
}
}
else
@@ -160,6 +175,7 @@ trigger_command_display_trigger_internal (const char *name,
str_regex[0] = '\0';
str_command[0] = '\0';
str_rc[0] = '\0';
+ str_post_action[0] = '\0';
if (conditions && conditions[0])
{
snprintf (str_conditions, sizeof (str_conditions),
@@ -190,9 +206,16 @@ trigger_command_display_trigger_internal (const char *name,
weechat_color (weechat_config_string (trigger_config_color_flag_return_code)),
weechat_color ("reset"));
}
- weechat_printf_tags (
- NULL, "no_trigger",
- " %s%s%s: %s%s%s%s%s%s%s%s%s%s%s%s",
+ if ((post_action >= 0) && (post_action != TRIGGER_POST_ACTION_NONE))
+ {
+ snprintf (str_post_action, sizeof (str_post_action),
+ " %s=1%s",
+ weechat_color (weechat_config_string (trigger_config_color_flag_post_action)),
+ weechat_color ("reset"));
+ }
+ weechat_printf_date_tags (
+ NULL, 0, "no_trigger",
+ " %s%s%s: %s%s%s%s%s%s%s%s%s%s%s%s%s",
(enabled) ?
weechat_color (weechat_config_string (trigger_config_color_trigger)) :
weechat_color (weechat_config_string (trigger_config_color_trigger_disabled)),
@@ -209,7 +232,8 @@ trigger_command_display_trigger_internal (const char *name,
str_conditions,
str_regex,
str_command,
- str_rc);
+ str_rc,
+ str_post_action);
}
}
@@ -234,6 +258,7 @@ trigger_command_display_trigger (struct t_trigger *trigger, int verbose)
trigger->commands_count,
trigger->commands,
weechat_config_integer (trigger->options[TRIGGER_OPTION_RETURN_CODE]),
+ weechat_config_integer (trigger->options[TRIGGER_OPTION_POST_ACTION]),
verbose);
}
@@ -246,16 +271,17 @@ trigger_command_list (const char *message, int verbose)
{
struct t_trigger *ptr_trigger;
- weechat_printf_tags (NULL, "no_trigger", "");
+ weechat_printf_date_tags (NULL, 0, "no_trigger", "");
trigger_command_display_status ();
if (!triggers)
{
- weechat_printf_tags (NULL, "no_trigger", _("No trigger defined"));
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ _("No trigger defined"));
return;
}
- weechat_printf_tags (NULL, "no_trigger", message);
+ weechat_printf_date_tags (NULL, 0, "no_trigger", message);
for (ptr_trigger = triggers; ptr_trigger;
ptr_trigger = ptr_trigger->next_trigger)
@@ -280,8 +306,9 @@ trigger_command_list_default (int verbose)
commands_count = 0;
commands = NULL;
- weechat_printf_tags (NULL, "no_trigger", "");
- weechat_printf_tags (NULL, "no_trigger", _("List of default triggers:"));
+ weechat_printf_date_tags (NULL, 0, "no_trigger", "");
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ _("List of default triggers:"));
for (i = 0; trigger_config_default_list[i][0]; i++)
{
@@ -306,6 +333,7 @@ trigger_command_list_default (int verbose)
commands_count,
commands,
trigger_search_return_code (trigger_config_default_list[i][7]),
+ trigger_search_post_action (trigger_config_default_list[i][8]),
verbose);
}
@@ -321,11 +349,12 @@ trigger_command_list_default (int verbose)
void
trigger_command_error_running (struct t_trigger *trigger, const char *action)
{
- weechat_printf_tags (NULL, "no_trigger",
- _("%s%s: action \"%s\" can not be executed on "
- "trigger \"%s\" because it is currently running"),
- weechat_prefix ("error"), TRIGGER_PLUGIN_NAME,
- action, trigger->name);
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ _("%s%s: action \"%s\" can not be executed on "
+ "trigger \"%s\" because it is currently "
+ "running"),
+ weechat_prefix ("error"), TRIGGER_PLUGIN_NAME,
+ action, trigger->name);
}
/*
@@ -354,16 +383,17 @@ trigger_command_set_enabled (struct t_trigger *trigger,
if (weechat_config_boolean (trigger->options[TRIGGER_OPTION_ENABLED]))
{
trigger_hook (trigger);
- weechat_printf_tags (NULL, "no_trigger",
- _("Trigger \"%s\" restarted"),
- trigger->name);
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ _("Trigger \"%s\" restarted"),
+ trigger->name);
}
else if (display_error)
{
- weechat_printf_tags (NULL, "no_trigger",
- _("%s%s: a disabled trigger can not be "
- "restarted"),
- weechat_prefix ("error"), TRIGGER_PLUGIN_NAME);
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ _("%s%s: a disabled trigger can not be "
+ "restarted"),
+ weechat_prefix ("error"),
+ TRIGGER_PLUGIN_NAME);
}
}
else
@@ -375,11 +405,11 @@ trigger_command_set_enabled (struct t_trigger *trigger,
}
weechat_config_option_set (trigger->options[TRIGGER_OPTION_ENABLED],
(enable) ? "on" : "off", 1);
- weechat_printf_tags (NULL, "no_trigger",
- (enable) ?
- _("Trigger \"%s\" enabled") :
- _("Trigger \"%s\" disabled"),
- trigger->name);
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ (enable) ?
+ _("Trigger \"%s\" enabled") :
+ _("Trigger \"%s\" disabled"),
+ trigger->name);
}
}
@@ -404,35 +434,38 @@ trigger_command_rename (struct t_trigger *trigger, const char *new_name)
/* check that new name is valid */
if (!trigger_name_valid (name2))
{
- weechat_printf_tags (NULL, "no_trigger",
- _("%s%s: invalid name for trigger"),
- weechat_prefix ("error"), TRIGGER_PLUGIN_NAME);
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ _("%s%s: invalid trigger name: \"%s\""),
+ weechat_prefix ("error"),
+ TRIGGER_PLUGIN_NAME,
+ name2);
goto end;
}
/* check that no trigger already exists with the new name */
if (trigger_search (name2))
{
- weechat_printf_tags (NULL, "no_trigger",
- _("%s%s: trigger \"%s\" already "
- "exists"),
- weechat_prefix ("error"), TRIGGER_PLUGIN_NAME,
- name2);
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ _("%s%s: trigger \"%s\" already "
+ "exists"),
+ weechat_prefix ("error"), TRIGGER_PLUGIN_NAME,
+ name2);
goto end;
}
/* rename the trigger */
if (trigger_rename (trigger, name2))
{
- weechat_printf_tags (NULL, "no_trigger",
- _("Trigger \"%s\" renamed to \"%s\""),
- name, trigger->name);
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ _("Trigger \"%s\" renamed to \"%s\""),
+ name, trigger->name);
}
else
{
- weechat_printf_tags (NULL, "no_trigger",
- _("%s%s: failed to rename trigger "
- "\"%s\""),
- weechat_prefix ("error"), TRIGGER_PLUGIN_NAME,
- name);
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ _("%s%s: failed to rename trigger "
+ "\"%s\""),
+ weechat_prefix ("error"),
+ TRIGGER_PLUGIN_NAME,
+ name);
}
}
@@ -448,7 +481,8 @@ end:
*/
int
-trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc,
+trigger_command_trigger (const void *pointer, void *data,
+ struct t_gui_buffer *buffer, int argc,
char **argv, char **argv_eol)
{
struct t_trigger *ptr_trigger, *ptr_trigger2;
@@ -458,6 +492,7 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc,
int regex_count, regex_rc;
/* make C compiler happy */
+ (void) pointer;
(void) data;
rc = WEECHAT_RC_OK;
@@ -495,18 +530,21 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc,
goto error;
if (!trigger_name_valid (sargv[0]))
{
- weechat_printf_tags (NULL, "no_trigger",
- _("%s%s: invalid name for trigger"),
- weechat_prefix ("error"), TRIGGER_PLUGIN_NAME);
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ _("%s%s: invalid trigger name: \"%s\""),
+ weechat_prefix ("error"),
+ TRIGGER_PLUGIN_NAME,
+ sargv[0]);
goto end;
}
type = trigger_search_hook_type (sargv[1]);
if (type < 0)
{
- weechat_printf_tags (NULL, "no_trigger",
- _("%s%s: invalid hook type \"%s\""),
- weechat_prefix ("error"), TRIGGER_PLUGIN_NAME,
- sargv[1]);
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ _("%s%s: invalid hook type: \"%s\""),
+ weechat_prefix ("error"),
+ TRIGGER_PLUGIN_NAME,
+ sargv[1]);
goto end;
}
if ((sargc > 4) && sargv[4][0])
@@ -547,10 +585,21 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc,
if ((sargc > 6) && sargv[6][0]
&& (trigger_search_return_code (sargv[6]) < 0))
{
- weechat_printf_tags (NULL, "no_trigger",
- _("%s%s: invalid return code \"%s\""),
- weechat_prefix ("error"), TRIGGER_PLUGIN_NAME,
- sargv[6]);
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ _("%s%s: invalid return code: \"%s\""),
+ weechat_prefix ("error"),
+ TRIGGER_PLUGIN_NAME,
+ sargv[6]);
+ goto end;
+ }
+ if ((sargc > 7) && sargv[7][0]
+ && (trigger_search_post_action (sargv[7]) < 0))
+ {
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ _("%s%s: invalid post action \"%s\""),
+ weechat_prefix ("error"),
+ TRIGGER_PLUGIN_NAME,
+ sargv[7]);
goto end;
}
ptr_trigger = trigger_search (sargv[0]);
@@ -570,22 +619,24 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc,
}
else
{
- weechat_printf_tags (NULL, "no_trigger",
- _("%s%s: trigger \"%s\" already exists "
- "(choose another name or use option "
- "\"addreplace\" to overwrite it)"),
- weechat_prefix ("error"),
- TRIGGER_PLUGIN_NAME, sargv[0]);
+ weechat_printf_date_tags (
+ NULL, 0, "no_trigger",
+ _("%s%s: trigger \"%s\" already exists "
+ "(choose another name or use option "
+ "\"addreplace\" to overwrite it)"),
+ weechat_prefix ("error"),
+ TRIGGER_PLUGIN_NAME, sargv[0]);
goto end;
}
}
ptr_trigger = trigger_alloc (sargv[0]);
if (!ptr_trigger)
{
- weechat_printf_tags (NULL, "no_trigger",
- _("%s%s: failed to create trigger \"%s\""),
- weechat_prefix ("error"), TRIGGER_PLUGIN_NAME,
- sargv[0]);
+ weechat_printf_date_tags (
+ NULL, 0, "no_trigger",
+ _("%s%s: failed to create trigger \"%s\""),
+ weechat_prefix ("error"), TRIGGER_PLUGIN_NAME,
+ sargv[0]);
goto end;
}
ptr_trigger = trigger_new (
@@ -596,18 +647,21 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc,
(sargc > 3) ? sargv[3] : "", /* conditions */
(sargc > 4) ? sargv[4] : "", /* regex */
(sargc > 5) ? sargv[5] : "", /* command */
- (sargc > 6) ? sargv[6] : ""); /* return code */
+ (sargc > 6) ? sargv[6] : "", /* return code */
+ (sargc > 7) ? sargv[7] : ""); /* post action */
if (ptr_trigger)
{
- weechat_printf_tags (NULL, "no_trigger",
- _("Trigger \"%s\" created"), sargv[0]);
+ weechat_printf_date_tags (
+ NULL, 0, "no_trigger",
+ _("Trigger \"%s\" created"), sargv[0]);
}
else
{
- weechat_printf_tags (NULL, "no_trigger",
- _("%s%s: failed to create trigger \"%s\""),
- weechat_prefix ("error"), TRIGGER_PLUGIN_NAME,
- sargv[0]);
+ weechat_printf_date_tags (
+ NULL, 0, "no_trigger",
+ _("%s%s: failed to create trigger \"%s\""),
+ weechat_prefix ("error"), TRIGGER_PLUGIN_NAME,
+ sargv[0]);
}
goto end;
}
@@ -621,10 +675,10 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc,
type = trigger_search_hook_type (argv[2]);
if (type < 0)
{
- weechat_printf_tags (NULL, "no_trigger",
- _("%s%s: invalid hook type \"%s\""),
- weechat_prefix ("error"),
- TRIGGER_PLUGIN_NAME, argv[2]);
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ _("%s%s: invalid hook type: \"%s\""),
+ weechat_prefix ("error"),
+ TRIGGER_PLUGIN_NAME, argv[2]);
goto end;
}
}
@@ -660,15 +714,16 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc,
ptr_trigger = trigger_search (argv[2]);
if (!ptr_trigger)
{
- weechat_printf_tags (NULL, "no_trigger",
- _("%s%s: trigger \"%s\" not found"),
- weechat_prefix ("error"), TRIGGER_PLUGIN_NAME,
- argv[2]);
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ _("%s%s: trigger \"%s\" not found"),
+ weechat_prefix ("error"),
+ TRIGGER_PLUGIN_NAME,
+ argv[2]);
goto end;
}
add_rc = trigger_hook_default_rc[weechat_config_integer (ptr_trigger->options[TRIGGER_OPTION_HOOK])][0];
snprintf (input, sizeof (input),
- "//trigger %s %s %s \"%s\" \"%s\" \"%s\" \"%s\"%s%s%s",
+ "//trigger %s %s %s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"",
(weechat_strcasecmp (argv[1], "recreate") == 0) ? "addreplace" : "add",
ptr_trigger->name,
weechat_config_string (ptr_trigger->options[TRIGGER_OPTION_HOOK]),
@@ -676,9 +731,8 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc,
weechat_config_string (ptr_trigger->options[TRIGGER_OPTION_CONDITIONS]),
weechat_config_string (ptr_trigger->options[TRIGGER_OPTION_REGEX]),
weechat_config_string (ptr_trigger->options[TRIGGER_OPTION_COMMAND]),
- (add_rc) ? " \"" : "",
(add_rc) ? weechat_config_string (ptr_trigger->options[TRIGGER_OPTION_RETURN_CODE]) : "",
- (add_rc) ? "\"" : "");
+ weechat_config_string (ptr_trigger->options[TRIGGER_OPTION_POST_ACTION]));
if (weechat_strcasecmp (argv[1], "output") == 0)
{
weechat_command (buffer, input);
@@ -701,10 +755,11 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc,
ptr_trigger = trigger_search (argv[2]);
if (!ptr_trigger)
{
- weechat_printf_tags (NULL, "no_trigger",
- _("%s%s: trigger \"%s\" not found"),
- weechat_prefix ("error"), TRIGGER_PLUGIN_NAME,
- argv[2]);
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ _("%s%s: trigger \"%s\" not found"),
+ weechat_prefix ("error"),
+ TRIGGER_PLUGIN_NAME,
+ argv[2]);
goto end;
}
if (ptr_trigger->hook_running)
@@ -725,17 +780,17 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc,
{
weechat_config_option_set (ptr_trigger->options[index_option],
value, 1);
- weechat_printf_tags (NULL, "no_trigger",
- _("Trigger \"%s\" updated"),
- ptr_trigger->name);
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ _("Trigger \"%s\" updated"),
+ ptr_trigger->name);
}
else
{
- weechat_printf_tags (NULL, "no_trigger",
- _("%s%s: trigger option \"%s\" not "
- "found"),
- weechat_prefix ("error"),
- TRIGGER_PLUGIN_NAME, argv[3]);
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ _("%s%s: trigger option \"%s\" not "
+ "found"),
+ weechat_prefix ("error"),
+ TRIGGER_PLUGIN_NAME, argv[3]);
}
free (value);
}
@@ -750,10 +805,11 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc,
ptr_trigger = trigger_search (argv[2]);
if (!ptr_trigger)
{
- weechat_printf_tags (NULL, "no_trigger",
- _("%s%s: trigger \"%s\" not found"),
- weechat_prefix ("error"), TRIGGER_PLUGIN_NAME,
- argv[2]);
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ _("%s%s: trigger \"%s\" not found"),
+ weechat_prefix ("error"),
+ TRIGGER_PLUGIN_NAME,
+ argv[2]);
goto end;
}
if (ptr_trigger->hook_running)
@@ -773,45 +829,50 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc,
ptr_trigger = trigger_search (argv[2]);
if (!ptr_trigger)
{
- weechat_printf_tags (NULL, "no_trigger",
- _("%s%s: trigger \"%s\" not found"),
- weechat_prefix ("error"), TRIGGER_PLUGIN_NAME,
- argv[2]);
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ _("%s%s: trigger \"%s\" not found"),
+ weechat_prefix ("error"),
+ TRIGGER_PLUGIN_NAME,
+ argv[2]);
goto end;
}
/* check that new name is valid */
if (!trigger_name_valid (argv[3]))
{
- weechat_printf_tags (NULL, "no_trigger",
- _("%s%s: invalid name for trigger"),
- weechat_prefix ("error"), TRIGGER_PLUGIN_NAME);
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ _("%s%s: invalid trigger name: \"%s\""),
+ weechat_prefix ("error"),
+ TRIGGER_PLUGIN_NAME,
+ argv[3]);
goto end;
}
/* check that no trigger already exists with the new name */
if (trigger_search (argv[3]))
{
- weechat_printf_tags (NULL, "no_trigger",
- _("%s%s: trigger \"%s\" already "
- "exists"),
- weechat_prefix ("error"), TRIGGER_PLUGIN_NAME,
- argv[3]);
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ _("%s%s: trigger \"%s\" already "
+ "exists"),
+ weechat_prefix ("error"),
+ TRIGGER_PLUGIN_NAME,
+ argv[3]);
goto end;
}
/* copy the trigger */
ptr_trigger2 = trigger_copy (ptr_trigger, argv[3]);
if (ptr_trigger2)
{
- weechat_printf_tags (NULL, "no_trigger",
- _("Trigger \"%s\" copied to \"%s\""),
- ptr_trigger->name, ptr_trigger2->name);
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ _("Trigger \"%s\" copied to \"%s\""),
+ ptr_trigger->name, ptr_trigger2->name);
}
else
{
- weechat_printf_tags (NULL, "no_trigger",
- _("%s%s: failed to copy trigger "
- "\"%s\""),
- weechat_prefix ("error"), TRIGGER_PLUGIN_NAME,
- ptr_trigger->name);
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ _("%s%s: failed to copy trigger "
+ "\"%s\""),
+ weechat_prefix ("error"),
+ TRIGGER_PLUGIN_NAME,
+ ptr_trigger->name);
}
goto end;
}
@@ -864,9 +925,10 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc,
1);
else
{
- weechat_printf_tags (NULL, "no_trigger",
- _("%sTrigger \"%s\" not found"),
- weechat_prefix ("error"), argv[i]);
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ _("%sTrigger \"%s\" not found"),
+ weechat_prefix ("error"),
+ argv[i]);
}
}
}
@@ -897,8 +959,8 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc,
}
count = count - triggers_count;
if (count > 0)
- weechat_printf_tags (NULL, "no_trigger",
- _("%d triggers removed"), count);
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ _("%d triggers removed"), count);
}
else
{
@@ -914,15 +976,17 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc,
else
{
trigger_free (ptr_trigger);
- weechat_printf_tags (NULL, "no_trigger",
- _("Trigger \"%s\" removed"), argv[i]);
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ _("Trigger \"%s\" removed"),
+ argv[i]);
}
}
else
{
- weechat_printf_tags (NULL, "no_trigger",
- _("%sTrigger \"%s\" not found"),
- weechat_prefix ("error"), argv[i]);
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ _("%sTrigger \"%s\" not found"),
+ weechat_prefix ("error"),
+ argv[i]);
}
}
}
@@ -937,14 +1001,15 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc,
ptr_trigger = trigger_search (argv[2]);
if (!ptr_trigger)
{
- weechat_printf_tags (NULL, "no_trigger",
- _("%s%s: trigger \"%s\" not found"),
- weechat_prefix ("error"), TRIGGER_PLUGIN_NAME,
- argv[2]);
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ _("%s%s: trigger \"%s\" not found"),
+ weechat_prefix ("error"),
+ TRIGGER_PLUGIN_NAME,
+ argv[2]);
goto end;
}
- weechat_printf_tags (NULL, "no_trigger", "");
- weechat_printf_tags (NULL, "no_trigger", _("Trigger:"));
+ weechat_printf_date_tags (NULL, 0, "no_trigger", "");
+ weechat_printf_date_tags (NULL, 0, "no_trigger", _("Trigger:"));
trigger_command_display_trigger (ptr_trigger, 2);
goto end;
}
@@ -983,17 +1048,19 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc,
trigger_config_default_list[j][4], /* conditions */
trigger_config_default_list[j][5], /* regex */
trigger_config_default_list[j][6], /* command */
- trigger_config_default_list[j][7]); /* return code */
- weechat_printf_tags (NULL, "no_trigger",
- _("Trigger \"%s\" restored"),
- argv[i]);
+ trigger_config_default_list[j][7], /* return code */
+ trigger_config_default_list[j][8]); /* post action */
+ weechat_printf_date_tags (NULL, 0, "no_trigger",
+ _("Trigger \"%s\" restored"),
+ argv[i]);
}
}
else
{
- weechat_printf_tags (NULL, "no_trigger",
- _("%sDefault trigger \"%s\" not found"),
- weechat_prefix ("error"), argv[i]);
+ weechat_printf_date_tags (
+ NULL, 0, "no_trigger",
+ _("%sDefault trigger \"%s\" not found"),
+ weechat_prefix ("error"), argv[i]);
}
}
goto end;
@@ -1067,7 +1134,7 @@ trigger_command_init ()
N_("list|listfull|listdefault"
" || add|addoff|addreplace <name> <hook> [\"<arguments>\" "
"[\"<conditions>\" [\"<regex>\" [\"<command>\" "
- "[\"<return_code>\"]]]]]"
+ "[\"<return_code>\" [\"<post_action>\"]]]]]]"
" || addinput [<hook>]"
" || input|output|recreate <name>"
" || set <name> <option> <value>"
@@ -1106,6 +1173,8 @@ trigger_command_init ()
" command: command to execute (many commands can be separated by "
"\";\"\n"
"return_code: return code in callback (ok (default), ok_eat, error)\n"
+ "post_action: action to take after execution (none (default), "
+ "disable, delete)\n"
" addinput: set input with default arguments to create a trigger\n"
" input: set input with the command used to create the trigger\n"
" output: send the command to create the trigger on the buffer\n"
@@ -1144,6 +1213,7 @@ trigger_command_init ()
"defined in trigger)\n"
" 3. execute command(s) (if defined in trigger)\n"
" 4. exit with a return code (except for modifiers and focus)\n"
+ " 5. perform post action\n"
"\n"
"Examples (you can also look at default triggers with /trigger "
"listdefault):\n"
@@ -1166,7 +1236,8 @@ trigger_command_init ()
"list|listfull|listdefault"
" || add|addoff|addreplace %(trigger_names) %(trigger_hooks) "
"%(trigger_hook_arguments) %(trigger_hook_conditions) "
- "%(trigger_hook_regex) %(trigger_hook_command) %(trigger_hook_rc)"
+ "%(trigger_hook_regex) %(trigger_hook_command) %(trigger_hook_rc) "
+ "%(trigger_post_action)"
" || addinput %(trigger_hooks)"
" || input|output|recreate %(trigger_names)"
" || set %(trigger_names) %(trigger_options)|name %(trigger_option_value)"
@@ -1177,5 +1248,5 @@ trigger_command_init ()
" || restore %(trigger_names_default)|%*"
" || default"
" || monitor %(trigger_names)|%(trigger_hooks_filter)",
- &trigger_command_trigger, NULL);
+ &trigger_command_trigger, NULL, NULL);
}
diff --git a/src/plugins/trigger/trigger-command.h b/src/plugins/trigger/trigger-command.h
index b9720c5d3..88e080518 100644
--- a/src/plugins/trigger/trigger-command.h
+++ b/src/plugins/trigger/trigger-command.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2014-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/trigger/trigger-completion.c b/src/plugins/trigger/trigger-completion.c
index 1fede9bfc..1928b1d2e 100644
--- a/src/plugins/trigger/trigger-completion.c
+++ b/src/plugins/trigger/trigger-completion.c
@@ -1,7 +1,7 @@
/*
* trigger-completion.c - completion for trigger commands
*
- * Copyright (C) 2014-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2014-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -33,13 +33,15 @@
*/
int
-trigger_completion_triggers_cb (void *data, const char *completion_item,
+trigger_completion_triggers_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
struct t_trigger *ptr_trigger;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -59,7 +61,8 @@ trigger_completion_triggers_cb (void *data, const char *completion_item,
*/
int
-trigger_completion_triggers_default_cb (void *data,
+trigger_completion_triggers_default_cb (const void *pointer, void *data,
+
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -67,6 +70,7 @@ trigger_completion_triggers_default_cb (void *data,
int i;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -86,13 +90,15 @@ trigger_completion_triggers_default_cb (void *data,
*/
int
-trigger_completion_options_cb (void *data, const char *completion_item,
+trigger_completion_options_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
int i;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -112,7 +118,8 @@ trigger_completion_options_cb (void *data, const char *completion_item,
*/
int
-trigger_completion_option_value_cb (void *data, const char *completion_item,
+trigger_completion_option_value_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
@@ -122,6 +129,7 @@ trigger_completion_option_value_cb (void *data, const char *completion_item,
struct t_trigger *ptr_trigger;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -170,13 +178,15 @@ trigger_completion_option_value_cb (void *data, const char *completion_item,
*/
int
-trigger_completion_hooks_cb (void *data, const char *completion_item,
+trigger_completion_hooks_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
int i;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -196,7 +206,8 @@ trigger_completion_hooks_cb (void *data, const char *completion_item,
*/
int
-trigger_completion_hooks_filter_cb (void *data, const char *completion_item,
+trigger_completion_hooks_filter_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
@@ -204,6 +215,7 @@ trigger_completion_hooks_filter_cb (void *data, const char *completion_item,
char str_hook[128];
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -300,11 +312,13 @@ trigger_completion_add_default_for_hook (struct t_gui_completion *completion,
*/
int
-trigger_completion_hook_arguments_cb (void *data, const char *completion_item,
+trigger_completion_hook_arguments_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -323,11 +337,13 @@ trigger_completion_hook_arguments_cb (void *data, const char *completion_item,
*/
int
-trigger_completion_hook_conditions_cb (void *data, const char *completion_item,
+trigger_completion_hook_conditions_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -347,11 +363,13 @@ trigger_completion_hook_conditions_cb (void *data, const char *completion_item,
*/
int
-trigger_completion_hook_regex_cb (void *data, const char *completion_item,
+trigger_completion_hook_regex_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -371,11 +389,13 @@ trigger_completion_hook_regex_cb (void *data, const char *completion_item,
*/
int
-trigger_completion_hook_command_cb (void *data, const char *completion_item,
+trigger_completion_hook_command_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -395,11 +415,13 @@ trigger_completion_hook_command_cb (void *data, const char *completion_item,
*/
int
-trigger_completion_hook_rc_cb (void *data, const char *completion_item,
+trigger_completion_hook_rc_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -412,6 +434,34 @@ trigger_completion_hook_rc_cb (void *data, const char *completion_item,
}
/*
+ * Adds default post actions to completion list.
+ */
+
+int
+trigger_completion_post_action_cb (const void *pointer, void *data,
+ const char *completion_item,
+ struct t_gui_buffer *buffer,
+ struct t_gui_completion *completion)
+{
+ int i;
+
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+ (void) completion_item;
+ (void) buffer;
+
+ for (i = 0; i < TRIGGER_NUM_POST_ACTIONS; i++)
+ {
+ trigger_completion_add_quoted_word (completion,
+ trigger_post_action_string[i]);
+ }
+
+ return WEECHAT_RC_OK;
+}
+
+
+/*
* Hooks completions.
*/
@@ -420,35 +470,38 @@ trigger_completion_init ()
{
weechat_hook_completion ("trigger_names",
N_("triggers"),
- &trigger_completion_triggers_cb, NULL);
+ &trigger_completion_triggers_cb, NULL, NULL);
weechat_hook_completion ("trigger_names_default",
N_("default triggers"),
- &trigger_completion_triggers_default_cb, NULL);
+ &trigger_completion_triggers_default_cb, NULL, NULL);
weechat_hook_completion ("trigger_options",
N_("options for triggers"),
- &trigger_completion_options_cb, NULL);
+ &trigger_completion_options_cb, NULL, NULL);
weechat_hook_completion ("trigger_option_value",
N_("value of a trigger option"),
- &trigger_completion_option_value_cb, NULL);
+ &trigger_completion_option_value_cb, NULL, NULL);
weechat_hook_completion ("trigger_hooks",
N_("hooks for triggers"),
- &trigger_completion_hooks_cb, NULL);
+ &trigger_completion_hooks_cb, NULL, NULL);
weechat_hook_completion ("trigger_hooks_filter",
N_("hooks for triggers (for filter in monitor buffer)"),
- &trigger_completion_hooks_filter_cb, NULL);
+ &trigger_completion_hooks_filter_cb, NULL, NULL);
weechat_hook_completion ("trigger_hook_arguments",
N_("default arguments for a hook"),
- &trigger_completion_hook_arguments_cb, NULL);
+ &trigger_completion_hook_arguments_cb, NULL, NULL);
weechat_hook_completion ("trigger_hook_conditions",
N_("default conditions for a hook"),
- &trigger_completion_hook_conditions_cb, NULL);
+ &trigger_completion_hook_conditions_cb, NULL, NULL);
weechat_hook_completion ("trigger_hook_regex",
N_("default regular expression for a hook"),
- &trigger_completion_hook_regex_cb, NULL);
+ &trigger_completion_hook_regex_cb, NULL, NULL);
weechat_hook_completion ("trigger_hook_command",
N_("default command for a hook"),
- &trigger_completion_hook_command_cb, NULL);
+ &trigger_completion_hook_command_cb, NULL, NULL);
weechat_hook_completion ("trigger_hook_rc",
N_("default return codes for hook callback"),
- &trigger_completion_hook_rc_cb, NULL);
+ &trigger_completion_hook_rc_cb, NULL, NULL);
+ weechat_hook_completion ("trigger_post_action",
+ N_("trigger post actions"),
+ &trigger_completion_post_action_cb, NULL, NULL);
}
diff --git a/src/plugins/trigger/trigger-completion.h b/src/plugins/trigger/trigger-completion.h
index cbad0a58e..7c72ecbe7 100644
--- a/src/plugins/trigger/trigger-completion.h
+++ b/src/plugins/trigger/trigger-completion.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2014-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/trigger/trigger-config.c b/src/plugins/trigger/trigger-config.c
index c1ea2c5ec..b610a0f48 100644
--- a/src/plugins/trigger/trigger-config.c
+++ b/src/plugins/trigger/trigger-config.c
@@ -1,7 +1,7 @@
/*
* trigger-config.c - trigger configuration options (file trigger.conf)
*
- * Copyright (C) 2014-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2014-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -42,6 +42,7 @@ struct t_config_option *trigger_config_color_flag_command;
struct t_config_option *trigger_config_color_flag_conditions;
struct t_config_option *trigger_config_color_flag_regex;
struct t_config_option *trigger_config_color_flag_return_code;
+struct t_config_option *trigger_config_color_flag_post_action;
struct t_config_option *trigger_config_color_regex;
struct t_config_option *trigger_config_color_replace;
struct t_config_option *trigger_config_color_trigger;
@@ -56,7 +57,8 @@ char *trigger_config_default_list[][1 + TRIGGER_NUM_OPTIONS] =
"${tg_displayed} && (${tg_highlight} || ${tg_msg_pv})",
"",
"/print -beep",
- "ok" },
+ "ok",
+ "" },
/* hide passwords in commands */
{ "cmd_pass", "on",
"modifier",
@@ -64,7 +66,8 @@ char *trigger_config_default_list[][1 + TRIGGER_NUM_OPTIONS] =
"",
"==^("
"(/(msg|m|quote) +nickserv "
- "+(id|identify|register|ghost +[^ ]+|release +[^ ]+|regain +[^ ]+) +)|"
+ "+(id|identify|register|ghost +[^ ]+|release +[^ ]+|regain +[^ ]+|"
+ "recover +[^ ]+) +)|"
"/oper +[^ ]+ +|"
"/quote +pass +|"
"/set +[^ ]*password[^ ]* +|"
@@ -72,15 +75,18 @@ char *trigger_config_default_list[][1 + TRIGGER_NUM_OPTIONS] =
"(.*)"
"==${re:1}${hide:*,${re:+}}",
"",
+ "",
"" },
/* hide password in IRC auth message displayed */
{ "msg_auth", "on",
"modifier",
"5000|irc_message_auth",
"",
- "==^(.*(id|identify|register|ghost +[^ ]+|release +[^ ]+) +)(.*)"
+ "==^(.*(id|identify|register|ghost +[^ ]+|release +[^ ]+|regain +[^ ]+|"
+ "recover +[^ ]+) +)(.*)"
"==${re:1}${hide:*,${re:+}}",
"",
+ "",
"" },
/* hide server password in commands /server and /connect */
{ "server_pass", "on",
@@ -90,8 +96,9 @@ char *trigger_config_default_list[][1 + TRIGGER_NUM_OPTIONS] =
"==^(/(server|connect) .*-(sasl_)?password=)([^ ]+)(.*)"
"==${re:1}${hide:*,${re:4}}${re:5}"
"",
+ "",
"" },
- { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL },
+ { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL },
};
@@ -100,9 +107,11 @@ char *trigger_config_default_list[][1 + TRIGGER_NUM_OPTIONS] =
*/
void
-trigger_config_change_enabled (void *data, struct t_config_option *option)
+trigger_config_change_enabled (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
trigger_enabled = weechat_config_boolean (option);
@@ -113,12 +122,13 @@ trigger_config_change_enabled (void *data, struct t_config_option *option)
*/
void
-trigger_config_change_trigger_enabled (void *data,
+trigger_config_change_trigger_enabled (const void *pointer, void *data,
struct t_config_option *option)
{
struct t_trigger *ptr_trigger;
/* make C compiler happy */
+ (void) pointer;
(void) data;
ptr_trigger = trigger_search_with_option (option);
@@ -136,11 +146,13 @@ trigger_config_change_trigger_enabled (void *data,
*/
void
-trigger_config_change_trigger_hook (void *data, struct t_config_option *option)
+trigger_config_change_trigger_hook (const void *pointer, void *data,
+ struct t_config_option *option)
{
struct t_trigger *ptr_trigger;
/* make C compiler happy */
+ (void) pointer;
(void) data;
ptr_trigger = trigger_search_with_option (option);
@@ -156,12 +168,13 @@ trigger_config_change_trigger_hook (void *data, struct t_config_option *option)
*/
void
-trigger_config_change_trigger_arguments (void *data,
+trigger_config_change_trigger_arguments (const void *pointer, void *data,
struct t_config_option *option)
{
struct t_trigger *ptr_trigger;
/* make C compiler happy */
+ (void) pointer;
(void) data;
ptr_trigger = trigger_search_with_option (option);
@@ -177,11 +190,13 @@ trigger_config_change_trigger_arguments (void *data,
*/
void
-trigger_config_change_trigger_regex (void *data, struct t_config_option *option)
+trigger_config_change_trigger_regex (const void *pointer, void *data,
+ struct t_config_option *option)
{
struct t_trigger *ptr_trigger;
/* make C compiler happy */
+ (void) pointer;
(void) data;
ptr_trigger = trigger_search_with_option (option);
@@ -221,12 +236,13 @@ trigger_config_change_trigger_regex (void *data, struct t_config_option *option)
*/
void
-trigger_config_change_trigger_command (void *data,
+trigger_config_change_trigger_command (const void *pointer, void *data,
struct t_config_option *option)
{
struct t_trigger *ptr_trigger;
/* make C compiler happy */
+ (void) pointer;
(void) data;
ptr_trigger = trigger_search_with_option (option);
@@ -271,8 +287,10 @@ trigger_config_create_trigger_option (const char *trigger_name, int index_option
option_name, "boolean",
N_("if disabled, the hooks are removed from trigger, so it is "
"not called any more"),
- NULL, 0, 0, value, NULL, 0, NULL, NULL,
- &trigger_config_change_trigger_enabled, NULL, NULL, NULL);
+ NULL, 0, 0, value, NULL, 0,
+ NULL, NULL, NULL,
+ &trigger_config_change_trigger_enabled, NULL, NULL,
+ NULL, NULL, NULL);
break;
case TRIGGER_OPTION_HOOK:
ptr_option = weechat_config_new_option (
@@ -280,8 +298,10 @@ trigger_config_create_trigger_option (const char *trigger_name, int index_option
option_name, "integer",
N_("type of hook used"),
trigger_hook_option_values,
- 0, 0, value, NULL, 0, NULL, NULL,
- &trigger_config_change_trigger_hook, NULL, NULL, NULL);
+ 0, 0, value, NULL, 0,
+ NULL, NULL, NULL,
+ &trigger_config_change_trigger_hook, NULL, NULL,
+ NULL, NULL, NULL);
break;
case TRIGGER_OPTION_ARGUMENTS:
ptr_option = weechat_config_new_option (
@@ -289,8 +309,10 @@ trigger_config_create_trigger_option (const char *trigger_name, int index_option
option_name, "string",
N_("arguments for the hook (depend on the hook type, see /help "
"trigger)"),
- NULL, 0, 0, value, NULL, 0, NULL, NULL,
- &trigger_config_change_trigger_arguments, NULL, NULL, NULL);
+ NULL, 0, 0, value, NULL, 0,
+ NULL, NULL, NULL,
+ &trigger_config_change_trigger_arguments, NULL, NULL,
+ NULL, NULL, NULL);
break;
case TRIGGER_OPTION_CONDITIONS:
ptr_option = weechat_config_new_option (
@@ -300,7 +322,7 @@ trigger_config_create_trigger_option (const char *trigger_name, int index_option
"hook callback) (note: content is evaluated when trigger is "
"run, see /help eval)"),
NULL, 0, 0, value, NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
break;
case TRIGGER_OPTION_REGEX:
ptr_option = weechat_config_new_option (
@@ -319,8 +341,10 @@ trigger_config_create_trigger_option (const char *trigger_name, int index_option
"replace: ${re:0} to ${re:99}, ${re:+} for last match and "
"${hide:c,${re:N}} to replace all chars of group N by "
"char 'c'"),
- NULL, 0, 0, value, NULL, 0, NULL, NULL,
- &trigger_config_change_trigger_regex, NULL, NULL, NULL);
+ NULL, 0, 0, value, NULL, 0,
+ NULL, NULL, NULL,
+ &trigger_config_change_trigger_regex, NULL, NULL,
+ NULL, NULL, NULL);
break;
case TRIGGER_OPTION_COMMAND:
ptr_option = weechat_config_new_option (
@@ -328,8 +352,10 @@ trigger_config_create_trigger_option (const char *trigger_name, int index_option
option_name, "string",
N_("command(s) to run if conditions are OK, after regex "
"replacements (many commands can be separated by semicolons)"),
- NULL, 0, 0, value, NULL, 0, NULL, NULL,
- &trigger_config_change_trigger_command, NULL, NULL, NULL);
+ NULL, 0, 0, value, NULL, 0,
+ NULL, NULL, NULL,
+ &trigger_config_change_trigger_command, NULL, NULL,
+ NULL, NULL, NULL);
break;
case TRIGGER_OPTION_RETURN_CODE:
ptr_option = weechat_config_new_option (
@@ -338,7 +364,15 @@ trigger_config_create_trigger_option (const char *trigger_name, int index_option
N_("return code for hook callback (see plugin API reference to "
"know where ok_eat/error can be used efficiently)"),
"ok|ok_eat|error", 0, 0, value, NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ break;
+ case TRIGGER_OPTION_POST_ACTION:
+ ptr_option = weechat_config_new_option (
+ trigger_config_file, trigger_config_section_trigger,
+ option_name, "integer",
+ N_("action to take on the trigger after execution"),
+ "none|disable|delete", 0, 0, value, NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
break;
case TRIGGER_NUM_OPTIONS:
break;
@@ -432,7 +466,8 @@ trigger_config_use_temp_triggers ()
*/
int
-trigger_config_trigger_read_cb (void *data, struct t_config_file *config_file,
+trigger_config_trigger_read_cb (const void *pointer, void *data,
+ struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name, const char *value)
{
@@ -441,6 +476,7 @@ trigger_config_trigger_read_cb (void *data, struct t_config_file *config_file,
int index_option;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) config_file;
(void) section;
@@ -502,7 +538,7 @@ trigger_config_trigger_read_cb (void *data, struct t_config_file *config_file,
*/
int
-trigger_config_trigger_write_default_cb (void *data,
+trigger_config_trigger_write_default_cb (const void *pointer, void *data,
struct t_config_file *config_file,
const char *section_name)
{
@@ -510,6 +546,7 @@ trigger_config_trigger_write_default_cb (void *data,
char option_name[512];
/* make C compiler happy */
+ (void) pointer;
(void) data;
if (!weechat_config_write_line (config_file, section_name, NULL))
@@ -543,11 +580,13 @@ trigger_config_trigger_write_default_cb (void *data,
*/
int
-trigger_config_reload_cb (void *data, struct t_config_file *config_file)
+trigger_config_reload_cb (const void *pointer, void *data,
+ struct t_config_file *config_file)
{
int rc;
/* make C compiler happy */
+ (void) pointer;
(void) data;
trigger_free_all ();
@@ -572,17 +611,19 @@ trigger_config_init ()
{
struct t_config_section *ptr_section;
- trigger_config_file = weechat_config_new (TRIGGER_CONFIG_NAME,
- &trigger_config_reload_cb, NULL);
+ trigger_config_file = weechat_config_new (
+ TRIGGER_CONFIG_NAME, &trigger_config_reload_cb, NULL, NULL);
if (!trigger_config_file)
return 0;
/* look */
ptr_section = weechat_config_new_section (trigger_config_file, "look",
0, 0,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (trigger_config_file);
@@ -593,21 +634,25 @@ trigger_config_init ()
trigger_config_file, ptr_section,
"enabled", "boolean",
N_("enable trigger support"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL,
- &trigger_config_change_enabled, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL,
+ &trigger_config_change_enabled, NULL, NULL,
+ NULL, NULL, NULL);
trigger_config_look_monitor_strip_colors = weechat_config_new_option (
trigger_config_file, ptr_section,
"monitor_strip_colors", "boolean",
N_("strip colors in hashtable values displayed on monitor buffer"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
/* color */
ptr_section = weechat_config_new_section (trigger_config_file, "color",
0, 0,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (trigger_config_file);
@@ -619,59 +664,66 @@ trigger_config_init ()
"flag_command", "color",
N_("text color for command flag (in /trigger list)"),
NULL, 0, 0, "lightgreen", NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
trigger_config_color_flag_conditions = weechat_config_new_option (
trigger_config_file, ptr_section,
"flag_conditions", "color",
N_("text color for conditions flag (in /trigger list)"),
NULL, 0, 0, "yellow", NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
trigger_config_color_flag_regex = weechat_config_new_option (
trigger_config_file, ptr_section,
"flag_regex", "color",
N_("text color for regex flag (in /trigger list)"),
NULL, 0, 0, "lightcyan", NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
trigger_config_color_flag_return_code = weechat_config_new_option (
trigger_config_file, ptr_section,
"flag_return_code", "color",
N_("text color for return code flag (in /trigger list)"),
NULL, 0, 0, "lightmagenta", NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ trigger_config_color_flag_post_action = weechat_config_new_option (
+ trigger_config_file, ptr_section,
+ "flag_post_action", "color",
+ N_("text color for post action flag (in /trigger list)"),
+ NULL, 0, 0, "lightblue", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
trigger_config_color_regex = weechat_config_new_option (
trigger_config_file, ptr_section,
"regex", "color",
N_("text color for regular expressions"),
NULL, 0, 0, "white", NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
trigger_config_color_replace = weechat_config_new_option (
trigger_config_file, ptr_section,
"replace", "color",
N_("text color for replacement text (for regular expressions)"),
NULL, 0, 0, "cyan", NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
trigger_config_color_trigger = weechat_config_new_option (
trigger_config_file, ptr_section,
"trigger", "color",
N_("text color for trigger name"),
NULL, 0, 0, "green", NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
trigger_config_color_trigger_disabled = weechat_config_new_option (
trigger_config_file, ptr_section,
"trigger_disabled", "color",
N_("text color for disabled trigger name"),
NULL, 0, 0, "red", NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
/* trigger */
- ptr_section = weechat_config_new_section (trigger_config_file,
- TRIGGER_CONFIG_SECTION_TRIGGER,
- 0, 0,
- &trigger_config_trigger_read_cb, NULL,
- NULL, NULL,
- &trigger_config_trigger_write_default_cb, NULL,
- NULL, NULL,
- NULL, NULL);
+ ptr_section = weechat_config_new_section (
+ trigger_config_file,
+ TRIGGER_CONFIG_SECTION_TRIGGER,
+ 0, 0,
+ &trigger_config_trigger_read_cb, NULL, NULL,
+ NULL, NULL, NULL,
+ &trigger_config_trigger_write_default_cb, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (trigger_config_file);
diff --git a/src/plugins/trigger/trigger-config.h b/src/plugins/trigger/trigger-config.h
index 8933a00cc..54c18e361 100644
--- a/src/plugins/trigger/trigger-config.h
+++ b/src/plugins/trigger/trigger-config.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2014-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -33,6 +33,7 @@ extern struct t_config_option *trigger_config_color_flag_command;
extern struct t_config_option *trigger_config_color_flag_conditions;
extern struct t_config_option *trigger_config_color_flag_regex;
extern struct t_config_option *trigger_config_color_flag_return_code;
+extern struct t_config_option *trigger_config_color_flag_post_action;
extern struct t_config_option *trigger_config_color_regex;
extern struct t_config_option *trigger_config_color_replace;
extern struct t_config_option *trigger_config_color_trigger;
diff --git a/src/plugins/trigger/trigger.c b/src/plugins/trigger/trigger.c
index c0e435625..b4a121fd2 100644
--- a/src/plugins/trigger/trigger.c
+++ b/src/plugins/trigger/trigger.c
@@ -1,7 +1,7 @@
/*
* trigger.c - trigger plugin for WeeChat
*
- * Copyright (C) 2014-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2014-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -44,9 +44,9 @@ struct t_weechat_plugin *weechat_trigger_plugin = NULL;
char *trigger_option_string[TRIGGER_NUM_OPTIONS] =
{ "enabled", "hook", "arguments", "conditions", "regex", "command",
- "return_code" };
+ "return_code", "post_action" };
char *trigger_option_default[TRIGGER_NUM_OPTIONS] =
-{ "on", "signal", "", "", "", "", "ok" };
+{ "on", "signal", "", "", "", "", "ok", "none" };
char *trigger_hook_type_string[TRIGGER_NUM_HOOK_TYPES] =
{ "signal", "hsignal", "modifier", "print", "command", "command_run", "timer",
@@ -69,6 +69,9 @@ char *trigger_return_code_string[TRIGGER_NUM_RETURN_CODES] =
int trigger_return_code[TRIGGER_NUM_RETURN_CODES] =
{ WEECHAT_RC_OK, WEECHAT_RC_OK_EAT, WEECHAT_RC_ERROR };
+char *trigger_post_action_string[TRIGGER_NUM_POST_ACTIONS] =
+{ "none", "disable", "delete" };
+
struct t_trigger *triggers = NULL; /* first trigger */
struct t_trigger *last_trigger = NULL; /* last trigger */
int triggers_count = 0; /* number of triggers */
@@ -146,6 +149,27 @@ trigger_search_return_code (const char *return_code)
}
/*
+ * Searches for trigger post action.
+ *
+ * Returns index of post action in enum t_trigger_post_action, -1 if not found.
+ */
+
+int
+trigger_search_post_action (const char *post_action)
+{
+ int i;
+
+ for (i = 0; i < TRIGGER_NUM_POST_ACTIONS; i++)
+ {
+ if (weechat_strcasecmp (trigger_post_action_string[i], post_action) == 0)
+ return i;
+ }
+
+ /* post action not found */
+ return -1;
+}
+
+/*
* Searches for a trigger by name.
*
* Returns pointer to trigger found, NULL if not found.
@@ -266,7 +290,7 @@ trigger_hook (struct t_trigger *trigger)
trigger->hooks[i] = weechat_hook_signal (
argv[i],
&trigger_callback_signal_cb,
- trigger);
+ trigger, NULL);
}
}
}
@@ -283,7 +307,7 @@ trigger_hook (struct t_trigger *trigger)
trigger->hooks[i] = weechat_hook_hsignal (
argv[i],
&trigger_callback_hsignal_cb,
- trigger);
+ trigger, NULL);
}
}
}
@@ -300,7 +324,7 @@ trigger_hook (struct t_trigger *trigger)
trigger->hooks[i] = weechat_hook_modifier (
argv[i],
&trigger_callback_modifier_cb,
- trigger);
+ trigger, NULL);
}
}
}
@@ -330,7 +354,7 @@ trigger_hook (struct t_trigger *trigger)
message,
strip_colors,
&trigger_callback_print_cb,
- trigger);
+ trigger, NULL);
}
break;
case TRIGGER_HOOK_COMMAND:
@@ -347,7 +371,7 @@ trigger_hook (struct t_trigger *trigger)
(argc > 3) ? argv[3] : "", /* description of args */
(argc > 4) ? argv[4] : "", /* completion */
&trigger_callback_command_cb,
- trigger);
+ trigger, NULL);
}
}
break;
@@ -363,7 +387,7 @@ trigger_hook (struct t_trigger *trigger)
trigger->hooks[i] = weechat_hook_command_run (
argv[i],
&trigger_callback_command_run_cb,
- trigger);
+ trigger, NULL);
}
}
}
@@ -393,7 +417,7 @@ trigger_hook (struct t_trigger *trigger)
(int)align_second,
(int)max_calls,
&trigger_callback_timer_cb,
- trigger);
+ trigger, NULL);
}
}
}
@@ -410,7 +434,7 @@ trigger_hook (struct t_trigger *trigger)
trigger->hooks[i] = weechat_hook_config (
argv[i],
&trigger_callback_config_cb,
- trigger);
+ trigger, NULL);
}
}
}
@@ -427,7 +451,7 @@ trigger_hook (struct t_trigger *trigger)
trigger->hooks[i] = weechat_hook_focus (
argv[i],
&trigger_callback_focus_cb,
- trigger);
+ trigger, NULL);
}
}
}
@@ -848,7 +872,7 @@ trigger_new_with_options (const char *name, struct t_config_option **options)
&new_trigger->regex) < 0)
{
weechat_printf (NULL,
- _("%s%s: invalid regular expression in trigger "
+ _("%s%s: invalid regular expression in trigger: "
"\"%s\""),
weechat_prefix ("error"), TRIGGER_PLUGIN_NAME,
name);
@@ -872,7 +896,8 @@ trigger_new_with_options (const char *name, struct t_config_option **options)
struct t_trigger *
trigger_new (const char *name, const char *enabled, const char *hook,
const char *arguments, const char *conditions, const char *regex,
- const char *command, const char *return_code)
+ const char *command, const char *return_code,
+ const char *post_action)
{
struct t_config_option *option[TRIGGER_NUM_OPTIONS];
const char *value[TRIGGER_NUM_OPTIONS];
@@ -890,6 +915,13 @@ trigger_new (const char *name, const char *enabled, const char *hook,
return NULL;
}
+ /* look for post action */
+ if (post_action && post_action[0]
+ && (trigger_search_post_action (post_action) < 0))
+ {
+ return NULL;
+ }
+
value[TRIGGER_OPTION_ENABLED] = enabled;
value[TRIGGER_OPTION_HOOK] = hook;
value[TRIGGER_OPTION_ARGUMENTS] = arguments;
@@ -897,6 +929,7 @@ trigger_new (const char *name, const char *enabled, const char *hook,
value[TRIGGER_OPTION_REGEX] = regex;
value[TRIGGER_OPTION_COMMAND] = command;
value[TRIGGER_OPTION_RETURN_CODE] = return_code;
+ value[TRIGGER_OPTION_POST_ACTION] = post_action;
for (i = 0; i < TRIGGER_NUM_OPTIONS; i++)
{
@@ -933,7 +966,8 @@ trigger_create_default ()
trigger_config_default_list[i][4], /* conditions */
trigger_config_default_list[i][5], /* regex */
trigger_config_default_list[i][6], /* command */
- trigger_config_default_list[i][7]); /* return code */
+ trigger_config_default_list[i][7], /* return code */
+ trigger_config_default_list[i][8]); /* post action */
}
}
@@ -1017,7 +1051,8 @@ trigger_copy (struct t_trigger *trigger, const char *name)
weechat_config_string (trigger->options[TRIGGER_OPTION_CONDITIONS]),
weechat_config_string (trigger->options[TRIGGER_OPTION_REGEX]),
weechat_config_string (trigger->options[TRIGGER_OPTION_COMMAND]),
- weechat_config_string (trigger->options[TRIGGER_OPTION_RETURN_CODE]));
+ weechat_config_string (trigger->options[TRIGGER_OPTION_RETURN_CODE]),
+ weechat_config_string (trigger->options[TRIGGER_OPTION_POST_ACTION]));
}
/*
@@ -1105,6 +1140,9 @@ trigger_print_log ()
weechat_log_printf (" return_code . . . . . . : %d ('%s')",
weechat_config_integer (ptr_trigger->options[TRIGGER_OPTION_RETURN_CODE]),
trigger_return_code_string[weechat_config_integer (ptr_trigger->options[TRIGGER_OPTION_RETURN_CODE])]);
+ weechat_log_printf (" post_action . . . . . . : %d ('%s')",
+ weechat_config_integer (ptr_trigger->options[TRIGGER_OPTION_POST_ACTION]),
+ trigger_post_action_string[weechat_config_integer (ptr_trigger->options[TRIGGER_OPTION_POST_ACTION])]);
weechat_log_printf (" hooks_count . . . . . . : %d", ptr_trigger->hooks_count);
weechat_log_printf (" hooks . . . . . . . . . : 0x%lx", ptr_trigger->hooks);
for (i = 0; i < ptr_trigger->hooks_count; i++)
@@ -1151,10 +1189,12 @@ trigger_print_log ()
*/
int
-trigger_debug_dump_cb (void *data, const char *signal, const char *type_data,
+trigger_debug_dump_cb (const void *pointer, void *data,
+ const char *signal, const char *type_data,
void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -1197,7 +1237,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
trigger_config_read ();
/* hook some signals */
- weechat_hook_signal ("debug_dump", &trigger_debug_dump_cb, NULL);
+ weechat_hook_signal ("debug_dump", &trigger_debug_dump_cb, NULL, NULL);
/* hook completions */
trigger_completion_init ();
diff --git a/src/plugins/trigger/trigger.h b/src/plugins/trigger/trigger.h
index 990c02f92..b780dd2de 100644
--- a/src/plugins/trigger/trigger.h
+++ b/src/plugins/trigger/trigger.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2014-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -38,6 +38,7 @@ enum t_trigger_option
TRIGGER_OPTION_REGEX, /* replace text with 1 or more regex */
TRIGGER_OPTION_COMMAND, /* command run if conditions are OK */
TRIGGER_OPTION_RETURN_CODE, /* return code for hook callback */
+ TRIGGER_OPTION_POST_ACTION, /* action to take after execution */
/* number of trigger options */
TRIGGER_NUM_OPTIONS,
};
@@ -66,6 +67,15 @@ enum t_trigger_return_code
TRIGGER_NUM_RETURN_CODES,
};
+enum t_trigger_post_action
+{
+ TRIGGER_POST_ACTION_NONE = 0,
+ TRIGGER_POST_ACTION_DISABLE,
+ TRIGGER_POST_ACTION_DELETE,
+ /* number of post actions */
+ TRIGGER_NUM_POST_ACTIONS,
+};
+
struct t_trigger_regex
{
char *variable; /* the hashtable key used */
@@ -114,6 +124,7 @@ extern char *trigger_hook_default_rc[];
extern char *trigger_hook_regex_default_var[];
extern char *trigger_return_code_string[];
extern int trigger_return_code[];
+extern char *trigger_post_action_string[];
extern struct t_trigger *triggers;
extern struct t_trigger *last_trigger;
extern int triggers_count;
@@ -124,6 +135,7 @@ extern int trigger_enabled;
extern int trigger_search_option (const char *option_name);
extern int trigger_search_hook_type (const char *type);
extern int trigger_search_return_code (const char *return_code);
+extern int trigger_search_post_action (const char *post_action);
extern struct t_trigger *trigger_search (const char *name);
extern struct t_trigger *trigger_search_with_option (struct t_config_option *option);
extern void trigger_regex_free (int *regex_count,
@@ -149,7 +161,8 @@ extern struct t_trigger *trigger_new (const char *name,
const char *conditions,
const char *replace,
const char *command,
- const char *return_code);
+ const char *return_code,
+ const char *post_action);
extern void trigger_create_default ();
extern int trigger_rename (struct t_trigger *trigger, const char *name);
extern struct t_trigger *trigger_copy (struct t_trigger *trigger,
diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h
index ca3e9f86b..0e0b623e0 100644
--- a/src/plugins/weechat-plugin.h
+++ b/src/plugins/weechat-plugin.h
@@ -1,7 +1,7 @@
/*
* weechat-plugin.h - header to compile WeeChat plugins
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -57,7 +57,7 @@ struct timeval;
* please change the date with current one; for a second change at same
* date, increment the 01, otherwise please keep 01.
*/
-#define WEECHAT_PLUGIN_API_VERSION "20150818-01"
+#define WEECHAT_PLUGIN_API_VERSION "20160618-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@@ -138,11 +138,16 @@ struct timeval;
/*
* process return code (for callback):
- * if >= 0, then process ended and it's return code of command
- * if < 0, then it's running or error
+ * if >= 0, the process ended and it's return code of command
+ * if -1, the process is still running
+ * if -2, the process ended with an error
+ * if -3, the callback is called in the child process (exec of function)
+ * (note: the return code -3 is NEVER sent to script plugins,
+ * it can be used only in C API)
*/
#define WEECHAT_HOOK_PROCESS_RUNNING -1
#define WEECHAT_HOOK_PROCESS_ERROR -2
+#define WEECHAT_HOOK_PROCESS_CHILD -3
/* connect status for connection hooked */
#define WEECHAT_HOOK_CONNECT_OK 0
@@ -294,7 +299,8 @@ struct t_weechat_plugin
char *(*string_replace_regex) (const char *string, void *regex,
const char *replace,
const char reference_char,
- char *(*callback)(void *data, const char *text),
+ char *(*callback)(void *data,
+ const char *text),
void *callback_data);
char **(*string_split) (const char *string, const char *separators,
int keep_eol, int num_items_max, int *num_items);
@@ -308,6 +314,9 @@ struct t_weechat_plugin
char *(*string_remove_color) (const char *string, const char *replacement);
void (*string_encode_base64) (const char *from, int length, char *to);
int (*string_decode_base64) (const char *from, char *to);
+ char *(*string_hex_dump) (const char *data, int data_size,
+ int bytes_per_line, const char *prefix,
+ const char *suffix);
int (*string_is_command_char) (const char *string);
const char *(*string_input_for_buffer) (const char *string);
char *(*string_eval_expression )(const char *expr,
@@ -339,8 +348,9 @@ struct t_weechat_plugin
int (*mkdir_home) (const char *directory, int mode);
int (*mkdir) (const char *directory, int mode);
int (*mkdir_parents) (const char *directory, int mode);
- void (*exec_on_files) (const char *directory, int hidden_files, void *data,
- void (*callback)(void *data, const char *filename));
+ void (*exec_on_files) (const char *directory, int hidden_files,
+ void (*callback)(void *data, const char *filename),
+ void *callback_data);
char *(*file_get_content) (const char *filename);
/* util */
@@ -425,37 +435,49 @@ struct t_weechat_plugin
/* config files */
struct t_config_file *(*config_new) (struct t_weechat_plugin *plugin,
const char *name,
- int (*callback_reload)(void *data,
+ int (*callback_reload)(const void *pointer,
+ void *data,
struct t_config_file *config_file),
+ const void *callback_reload_pointer,
void *callback_reload_data);
struct t_config_section *(*config_new_section) (struct t_config_file *config_file,
const char *name,
int user_can_add_options,
int user_can_delete_options,
- int (*callback_read)(void *data,
+ int (*callback_read)(const void *pointer,
+ void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
const char *value),
+ const void *callback_read_pointer,
void *callback_read_data,
- int (*callback_write)(void *data,
+ int (*callback_write)(const void *pointer,
+ void *data,
struct t_config_file *config_file,
const char *section_name),
+ const void *callback_write_pointer,
void *callback_write_data,
- int (*callback_write_default)(void *data,
+ int (*callback_write_default)(const void *pointer,
+ void *data,
struct t_config_file *config_file,
const char *section_name),
+ const void *callback_write_default_pointer,
void *callback_write_default_data,
- int (*callback_create_option)(void *data,
+ int (*callback_create_option)(const void *pointer,
+ void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
const char *value),
+ const void *callback_create_option_pointer,
void *callback_create_option_data,
- int (*callback_delete_option)(void *data,
+ int (*callback_delete_option)(const void *pointer,
+ void *data,
struct t_config_file *config_file,
struct t_config_section *section,
struct t_config_option *option),
+ const void *callback_delete_option_pointer,
void *callback_delete_option_data);
struct t_config_section *(*config_search_section) (struct t_config_file *config_file,
const char *section_name);
@@ -470,15 +492,21 @@ struct t_weechat_plugin
const char *default_value,
const char *value,
int null_value_allowed,
- int (*callback_check_value)(void *data,
+ int (*callback_check_value)(const void *pointer,
+ void *data,
struct t_config_option *option,
const char *value),
+ const void *callback_check_value_pointer,
void *callback_check_value_data,
- void (*callback_change)(void *data,
+ void (*callback_change)(const void *pointer,
+ void *data,
struct t_config_option *option),
+ const void *callback_change_pointer,
void *callback_change_data,
- void (*callback_delete)(void *data,
+ void (*callback_delete)(const void *pointer,
+ void *data,
struct t_config_option *option),
+ const void *callback_delete_pointer,
void *callback_delete_data);
struct t_config_option *(*config_search_option) (struct t_config_file *config_file,
struct t_config_section *section,
@@ -560,49 +588,62 @@ struct t_weechat_plugin
const char *args,
const char *args_description,
const char *completion,
- int (*callback)(void *data,
+ int (*callback)(const void *pointer,
+ void *data,
struct t_gui_buffer *buffer,
int argc, char **argv,
char **argv_eol),
+ const void *callback_pointer,
void *callback_data);
struct t_hook *(*hook_command_run) (struct t_weechat_plugin *plugin,
const char *command,
- int (*callback)(void *data,
+ int (*callback)(const void *pointer,
+ void *data,
struct t_gui_buffer *buffer,
const char *command),
+ const void *callback_pointer,
void *callback_data);
struct t_hook *(*hook_timer) (struct t_weechat_plugin *plugin,
long interval,
int align_second,
int max_calls,
- int (*callback)(void *data,
+ int (*callback)(const void *pointer,
+ void *data,
int remaining_calls),
+ const void *callback_pointer,
void *callback_data);
struct t_hook *(*hook_fd) (struct t_weechat_plugin *plugin,
int fd,
int flag_read,
int flag_write,
int flag_exception,
- int (*callback)(void *data, int fd),
+ int (*callback)(const void *pointer,
+ void *data,
+ int fd),
+ const void *callback_pointer,
void *callback_data);
struct t_hook *(*hook_process) (struct t_weechat_plugin *plugin,
const char *command,
int timeout,
- int (*callback)(void *data,
+ int (*callback)(const void *pointer,
+ void *data,
const char *command,
int return_code,
const char *out,
const char *err),
+ const void *callback_pointer,
void *callback_data);
struct t_hook *(*hook_process_hashtable) (struct t_weechat_plugin *plugin,
const char *command,
struct t_hashtable *options,
int timeout,
- int (*callback)(void *data,
+ int (*callback)(const void *pointer,
+ void *data,
const char *command,
int return_code,
const char *out,
const char *err),
+ const void *callback_pointer,
void *callback_data);
struct t_hook *(*hook_connect) (struct t_weechat_plugin *plugin,
const char *proxy,
@@ -614,19 +655,22 @@ struct t_weechat_plugin
int gnutls_dhkey_size,
const char *gnutls_priorities,
const char *local_hostname,
- int (*callback)(void *data,
+ int (*callback)(const void *pointer,
+ void *data,
int status,
int gnutls_rc,
int sock,
const char *error,
const char *ip_address),
+ const void *callback_pointer,
void *callback_data);
struct t_hook *(*hook_print) (struct t_weechat_plugin *plugin,
struct t_gui_buffer *buffer,
const char *tags,
const char *message,
int strip_colors,
- int (*callback)(void *data,
+ int (*callback)(const void *pointer,
+ void *data,
struct t_gui_buffer *buffer,
time_t date,
int tags_count,
@@ -635,37 +679,46 @@ struct t_weechat_plugin
int highlight,
const char *prefix,
const char *message),
+ const void *callback_pointer,
void *callback_data);
struct t_hook *(*hook_signal) (struct t_weechat_plugin *plugin,
const char *signal,
- int (*callback)(void *data,
+ int (*callback)(const void *pointer,
+ void *data,
const char *signal,
const char *type_data,
void *signal_data),
+ const void *callback_pointer,
void *callback_data);
int (*hook_signal_send) (const char *signal, const char *type_data,
void *signal_data);
struct t_hook *(*hook_hsignal) (struct t_weechat_plugin *plugin,
const char *signal,
- int (*callback)(void *data,
+ int (*callback)(const void *pointer,
+ void *data,
const char *signal,
struct t_hashtable *hashtable),
+ const void *callback_pointer,
void *callback_data);
int (*hook_hsignal_send) (const char *signal,
struct t_hashtable *hashtable);
struct t_hook *(*hook_config) (struct t_weechat_plugin *plugin,
const char *option,
- int (*callback)(void *data,
+ int (*callback)(const void *pointer,
+ void *data,
const char *option,
const char *value),
+ const void *callback_pointer,
void *callback_data);
struct t_hook *(*hook_completion) (struct t_weechat_plugin *plugin,
const char *completion_item,
const char *description,
- int (*callback)(void *data,
+ int (*callback)(const void *pointer,
+ void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion),
+ const void *callback_pointer,
void *callback_data);
const char *(*hook_completion_get_string) (struct t_gui_completion *completion,
const char *property);
@@ -675,10 +728,12 @@ struct t_weechat_plugin
const char *where);
struct t_hook *(*hook_modifier) (struct t_weechat_plugin *plugin,
const char *modifier,
- char *(*callback)(void *data,
+ char *(*callback)(const void *pointer,
+ void *data,
const char *modifier,
const char *modifier_data,
const char *string),
+ const void *callback_pointer,
void *callback_data);
char *(*hook_modifier_exec) (struct t_weechat_plugin *plugin,
const char *modifier,
@@ -688,54 +743,69 @@ struct t_weechat_plugin
const char *info_name,
const char *description,
const char *args_description,
- const char *(*callback)(void *data,
+ const char *(*callback)(const void *pointer,
+ void *data,
const char *info_name,
const char *arguments),
+ const void *callback_pointer,
void *callback_data);
struct t_hook *(*hook_info_hashtable) (struct t_weechat_plugin *plugin,
const char *info_name,
const char *description,
const char *args_description,
const char *output_description,
- struct t_hashtable *(*callback)(void *data,
+ struct t_hashtable *(*callback)(const void *pointer,
+ void *data,
const char *info_name,
struct t_hashtable *hashtable),
+ const void *callback_pointer,
void *callback_data);
struct t_hook *(*hook_infolist) (struct t_weechat_plugin *plugin,
const char *infolist_name,
const char *description,
const char *pointer_description,
const char *args_description,
- struct t_infolist *(*callback)(void *data,
+ struct t_infolist *(*callback)(const void *cb_pointer,
+ void *data,
const char *infolist_name,
- void *pointer,
+ void *obj_pointer,
const char *arguments),
+ const void *callback_pointer,
void *callback_data);
struct t_hook *(*hook_hdata) (struct t_weechat_plugin *plugin,
const char *hdata_name,
const char *description,
- struct t_hdata *(*callback)(void *data,
+ struct t_hdata *(*callback)(const void *pointer,
+ void *data,
const char *hdata_name),
+ const void *callback_pointer,
void *callback_data);
struct t_hook *(*hook_focus) (struct t_weechat_plugin *plugin,
const char *area,
- struct t_hashtable *(*callback)(void *data,
+ struct t_hashtable *(*callback)(const void *pointer,
+ void *data,
struct t_hashtable *info),
+ const void *callback_pointer,
void *callback_data);
void (*hook_set) (struct t_hook *hook, const char *property,
const char *value);
void (*unhook) (struct t_hook *hook);
- void (*unhook_all) (struct t_weechat_plugin *plugin);
+ void (*unhook_all) (struct t_weechat_plugin *plugin,
+ const char *subplugin);
/* buffers */
struct t_gui_buffer *(*buffer_new) (struct t_weechat_plugin *plugin,
const char *name,
- int (*input_callback)(void *data,
+ int (*input_callback)(const void *pointer,
+ void *data,
struct t_gui_buffer *buffer,
const char *input_data),
+ const void *input_callback_pointer,
void *input_callback_data,
- int (*close_callback)(void *data,
+ int (*close_callback)(const void *pointer,
+ void *data,
struct t_gui_buffer *buffer),
+ const void *close_callback_pointer,
void *close_callback_data);
struct t_gui_buffer *(*buffer_search) (const char *plugin, const char *name);
struct t_gui_buffer *(*buffer_search_main) ();
@@ -824,11 +894,13 @@ struct t_weechat_plugin
struct t_gui_bar_item *(*bar_item_search) (const char *name);
struct t_gui_bar_item *(*bar_item_new) (struct t_weechat_plugin *plugin,
const char *name,
- char *(*build_callback)(void *data,
+ char *(*build_callback)(const void *pointer,
+ void *data,
struct t_gui_bar_item *item,
struct t_gui_window *window,
struct t_gui_buffer *buffer,
struct t_hashtable *extra_info),
+ const void *build_callback_pointer,
void *build_callback_data);
void (*bar_item_update) (const char *name);
void (*bar_item_remove) (struct t_gui_bar_item *item);
@@ -970,16 +1042,17 @@ struct t_weechat_plugin
/* upgrade */
struct t_upgrade_file *(*upgrade_new) (const char *filename,
- int write);
+ int (*callback_read)(const void *pointer,
+ void *data,
+ struct t_upgrade_file *upgrade_file,
+ int object_id,
+ struct t_infolist *infolist),
+ const void *callback_read_pointer,
+ void *callback_read_data);
int (*upgrade_write_object) (struct t_upgrade_file *upgrade_file,
int object_id,
struct t_infolist *infolist);
- int (*upgrade_read) (struct t_upgrade_file *upgrade_file,
- int (*callback_read)(void *data,
- struct t_upgrade_file *upgrade_file,
- int object_id,
- struct t_infolist *infolist),
- void *callback_read_data);
+ int (*upgrade_read) (struct t_upgrade_file *upgrade_file);
void (*upgrade_close) (struct t_upgrade_file *upgrade_file);
};
@@ -1098,6 +1171,11 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
(weechat_plugin->string_encode_base64)(__from, __length, __to)
#define weechat_string_decode_base64(__from, __to) \
(weechat_plugin->string_decode_base64)(__from, __to)
+#define weechat_string_hex_dump(__data, __data_size, __bytes_per_line, \
+ __prefix, __suffix) \
+ (weechat_plugin->string_hex_dump)(__data, __data_size, \
+ __bytes_per_line, __prefix, \
+ __suffix)
#define weechat_string_is_command_char(__string) \
(weechat_plugin->string_is_command_char)(__string)
#define weechat_string_input_for_buffer(__string) \
@@ -1150,10 +1228,10 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
(weechat_plugin->mkdir)(__directory, __mode)
#define weechat_mkdir_parents(__directory, __mode) \
(weechat_plugin->mkdir_parents)(__directory, __mode)
-#define weechat_exec_on_files(__directory, __hidden_files, __data, \
- __callback) \
+#define weechat_exec_on_files(__directory, __hidden_files, __callback, \
+ __callback_data) \
(weechat_plugin->exec_on_files)(__directory, __hidden_files, \
- __data, __callback)
+ __callback, __callback_data)
#define weechat_file_get_content(__filename) \
(weechat_plugin->file_get_content)(__filename)
@@ -1203,9 +1281,10 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
/* hash tables */
#define weechat_hashtable_new(__size, __type_keys, __type_values, \
- __hash_key_cb, __keycmp_cb) \
+ __callback_hash_key, __callback_keycmp) \
(weechat_plugin->hashtable_new)(__size, __type_keys, __type_values, \
- __hash_key_cb, __keycmp_cb)
+ __callback_hash_key, \
+ __callback_keycmp)
#define weechat_hashtable_set_with_size(__hashtable, __key, __key_size, \
__value, __value_size) \
(weechat_plugin->hashtable_set_with_size)(__hashtable, __key, \
@@ -1248,31 +1327,47 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
/* config files */
#define weechat_config_new(__name, __callback_reload, \
+ __callback_reload_pointer, \
__callback_reload_data) \
(weechat_plugin->config_new)(weechat_plugin, __name, \
__callback_reload, \
+ __callback_reload_pointer, \
__callback_reload_data)
#define weechat_config_new_section(__config, __name, \
__user_can_add_options, \
__user_can_delete_options, \
- __cb_read, __cb_read_data, \
- __cb_write_std, __cb_write_std_data, \
- __cb_write_def, __cb_write_def_data, \
+ __cb_read, \
+ __cb_read_pointer, \
+ __cb_read_data, \
+ __cb_write_std, \
+ __cb_write_std_pointer, \
+ __cb_write_std_data, \
+ __cb_write_def, \
+ __cb_write_def_pointer, \
+ __cb_write_def_data, \
__cb_create_option, \
+ __cb_create_option_pointer, \
__cb_create_option_data, \
__cb_delete_option, \
+ __cb_delete_option_pointer, \
__cb_delete_option_data) \
(weechat_plugin->config_new_section)(__config, __name, \
__user_can_add_options, \
__user_can_delete_options, \
- __cb_read, __cb_read_data, \
+ __cb_read, \
+ __cb_read_pointer, \
+ __cb_read_data, \
__cb_write_std, \
+ __cb_write_std_pointer, \
__cb_write_std_data, \
__cb_write_def, \
+ __cb_write_def_pointer, \
__cb_write_def_data, \
__cb_create_option, \
+ __cb_create_option_pointer, \
__cb_create_option_data, \
__cb_delete_option, \
+ __cb_delete_option_pointer, \
__cb_delete_option_data)
#define weechat_config_search_section(__config, __name) \
(weechat_plugin->config_search_section)(__config, __name)
@@ -1281,10 +1376,13 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
__max, __default, __value, \
__null_value_allowed, \
__callback_check, \
+ __callback_check_pointer, \
__callback_check_data, \
__callback_change, \
+ __callback_change_pointer, \
__callback_change_data, \
__callback_delete, \
+ __callback_delete_pointer, \
__callback_delete_data) \
(weechat_plugin->config_new_option)(__config, __section, __name, \
__type, __desc, \
@@ -1293,10 +1391,13 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
__value, \
__null_value_allowed, \
__callback_check, \
+ __callback_check_pointer, \
__callback_check_data, \
__callback_change, \
+ __callback_change_pointer, \
__callback_change_data, \
__callback_delete, \
+ __callback_delete_pointer, \
__callback_delete_data)
#define weechat_config_search_option(__config, __section, __name) \
(weechat_plugin->config_search_option)(__config, __section, __name)
@@ -1394,12 +1495,6 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
#define weechat_printf(__buffer, __message, __argz...) \
(weechat_plugin->printf_date_tags)(__buffer, 0, NULL, __message, \
##__argz)
-#define weechat_printf_date(__buffer, __date, __message, __argz...) \
- (weechat_plugin->printf_date_tags)(__buffer, __date, NULL, \
- __message, ##__argz)
-#define weechat_printf_tags(__buffer, __tags, __message, __argz...) \
- (weechat_plugin->printf_date_tags)(__buffer, 0, __tags, __message, \
- ##__argz)
#define weechat_printf_date_tags(__buffer, __date, __tags, __message, \
__argz...) \
(weechat_plugin->printf_date_tags)(__buffer, __date, __tags, \
@@ -1412,69 +1507,75 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
/* hooks */
#define weechat_hook_command(__command, __description, __args, \
__args_desc, __completion, __callback, \
- __data) \
+ __pointer, __data) \
(weechat_plugin->hook_command)(weechat_plugin, __command, \
__description, __args, __args_desc, \
- __completion, __callback, __data)
-#define weechat_hook_command_run(__command, __callback, __data) \
+ __completion, __callback, __pointer, \
+ __data)
+#define weechat_hook_command_run(__command, __callback, __pointer, \
+ __data) \
(weechat_plugin->hook_command_run)(weechat_plugin, __command, \
- __callback, __data)
+ __callback, __pointer, __data)
#define weechat_hook_timer(__interval, __align_second, __max_calls, \
- __callback, __data) \
+ __callback, __pointer, __data) \
(weechat_plugin->hook_timer)(weechat_plugin, __interval, \
__align_second, __max_calls, \
- __callback, __data)
+ __callback, __pointer, __data)
#define weechat_hook_fd(__fd, __flag_read, __flag_write, \
- __flag_exception, __callback, __data) \
+ __flag_exception, __callback, __pointer, \
+ __data) \
(weechat_plugin->hook_fd)(weechat_plugin, __fd, __flag_read, \
__flag_write, __flag_exception, \
- __callback, __data)
+ __callback, __pointer, __data)
#define weechat_hook_process(__command, __timeout, __callback, \
- __callback_data) \
+ __callback_pointer, __callback_data) \
(weechat_plugin->hook_process)(weechat_plugin, __command, \
__timeout, __callback, \
- __callback_data)
+ __callback_pointer, __callback_data)
#define weechat_hook_process_hashtable(__command, __options, __timeout, \
- __callback, __callback_data) \
+ __callback, __callback_pointer, \
+ __callback_data) \
(weechat_plugin->hook_process_hashtable)(weechat_plugin, __command, \
__options, __timeout, \
__callback, \
+ __callback_pointer, \
__callback_data)
#define weechat_hook_connect(__proxy, __address, __port, __ipv6, \
__retry, __gnutls_sess, __gnutls_cb, \
__gnutls_dhkey_size, __gnutls_priorities, \
- __local_hostname, __callback, __data) \
+ __local_hostname, __callback, __pointer, \
+ __data) \
(weechat_plugin->hook_connect)(weechat_plugin, __proxy, __address, \
__port, __ipv6, __retry, \
__gnutls_sess, __gnutls_cb, \
__gnutls_dhkey_size, \
__gnutls_priorities, \
__local_hostname, \
- __callback, __data)
+ __callback, __pointer, __data)
#define weechat_hook_print(__buffer, __tags, __msg, __strip__colors, \
- __callback, __data) \
+ __callback, __pointer, __data) \
(weechat_plugin->hook_print)(weechat_plugin, __buffer, __tags, \
__msg, __strip__colors, __callback, \
- __data)
-#define weechat_hook_signal(__signal, __callback, __data) \
+ __pointer, __data)
+#define weechat_hook_signal(__signal, __callback, __pointer, __data) \
(weechat_plugin->hook_signal)(weechat_plugin, __signal, __callback, \
- __data)
+ __pointer, __data)
#define weechat_hook_signal_send(__signal, __type_data, __signal_data) \
(weechat_plugin->hook_signal_send)(__signal, __type_data, \
__signal_data)
-#define weechat_hook_hsignal(__signal, __callback, __data) \
+#define weechat_hook_hsignal(__signal, __callback, __pointer, __data) \
(weechat_plugin->hook_hsignal)(weechat_plugin, __signal, \
- __callback, __data)
+ __callback, __pointer, __data)
#define weechat_hook_hsignal_send(__signal, __hashtable) \
(weechat_plugin->hook_hsignal_send)(__signal, __hashtable)
-#define weechat_hook_config(__option, __callback, __data) \
+#define weechat_hook_config(__option, __callback, __pointer, __data) \
(weechat_plugin->hook_config)(weechat_plugin, __option, __callback, \
- __data)
+ __pointer, __data)
#define weechat_hook_completion(__completion, __description, \
- __callback, __data) \
+ __callback, __pointer, __data) \
(weechat_plugin->hook_completion)(weechat_plugin, __completion, \
__description, __callback, \
- __data)
+ __pointer, __data)
#define weechat_hook_completion_get_string(__completion, __property) \
(weechat_plugin->hook_completion_get_string)(__completion, \
__property)
@@ -1483,58 +1584,69 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
(weechat_plugin->hook_completion_list_add)(__completion, __word, \
__nick_completion, \
__where)
-#define weechat_hook_modifier(__modifier, __callback, __data) \
+#define weechat_hook_modifier(__modifier, __callback, __pointer, \
+ __data) \
(weechat_plugin->hook_modifier)(weechat_plugin, __modifier, \
- __callback, __data)
+ __callback, __pointer, __data)
#define weechat_hook_modifier_exec(__modifier, __modifier_data, \
__string) \
(weechat_plugin->hook_modifier_exec)(weechat_plugin, __modifier, \
__modifier_data, __string)
#define weechat_hook_info(__info_name, __description, \
- __args_description, __callback, __data) \
+ __args_description, __callback, __pointer, \
+ __data) \
(weechat_plugin->hook_info)(weechat_plugin, __info_name, \
- __description, __args_description, \
- __callback, __data)
+ __description, __args_description, \
+ __callback, __pointer, __data)
#define weechat_hook_info_hashtable(__info_name, __description, \
__args_description, \
__output_description, \
__callback, \
+ __pointer, \
__data) \
(weechat_plugin->hook_info_hashtable)(weechat_plugin, __info_name, \
__description, \
__args_description, \
__output_description, \
- __callback, __data)
+ __callback, __pointer, \
+ __data)
#define weechat_hook_infolist(__infolist_name, __description, \
__pointer_description, \
- __args_description, __callback, __data) \
+ __args_description, __callback, \
+ __pointer, __data) \
(weechat_plugin->hook_infolist)(weechat_plugin, __infolist_name, \
__description, \
__pointer_description, \
__args_description, __callback, \
- __data)
+ __pointer, __data)
#define weechat_hook_hdata(__hdata_name, __description, __callback, \
- __data) \
+ __pointer, __data) \
(weechat_plugin->hook_hdata)(weechat_plugin, __hdata_name, \
- __description, __callback, __data)
-#define weechat_hook_focus(__area, __callback, __data) \
- (weechat_plugin->hook_focus)(weechat_plugin, __area, __callback, \
+ __description, __callback, __pointer, \
__data)
+#define weechat_hook_focus(__area, __callback, __pointer, __data) \
+ (weechat_plugin->hook_focus)(weechat_plugin, __area, __callback, \
+ __pointer, __data)
#define weechat_hook_set(__hook, __property, __value) \
(weechat_plugin->hook_set)(__hook, __property, __value)
#define weechat_unhook(__hook) \
(weechat_plugin->unhook)( __hook)
-#define weechat_unhook_all() \
- (weechat_plugin->unhook_all_plugin)(weechat_plugin)
+#define weechat_unhook_all(__subplugin) \
+ (weechat_plugin->unhook_all)(weechat_plugin, __subplugin)
/* buffers */
#define weechat_buffer_new(__name, __input_callback, \
- __input_callback_data, __close_callback, \
+ __input_callback_pointer, \
+ __input_callback_data, \
+ __close_callback, \
+ __close_callback_pointer, \
__close_callback_data) \
(weechat_plugin->buffer_new)(weechat_plugin, __name, \
__input_callback, \
+ __input_callback_pointer, \
__input_callback_data, \
__close_callback, \
+ __close_callback_pointer, \
__close_callback_data)
#define weechat_buffer_search(__plugin, __name) \
(weechat_plugin->buffer_search)(__plugin, __name)
@@ -1638,9 +1750,13 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
/* bars */
#define weechat_bar_item_search(__name) \
(weechat_plugin->bar_item_search)(__name)
-#define weechat_bar_item_new(__name, __build_callback, __data) \
+#define weechat_bar_item_new(__name, __build_callback, \
+ __build_callback_pointer, \
+ __build_callback_data) \
(weechat_plugin->bar_item_new)(weechat_plugin, __name, \
- __build_callback, __data)
+ __build_callback, \
+ __build_callback_pointer, \
+ __build_callback_data)
#define weechat_bar_item_update(__name) \
(weechat_plugin->bar_item_update)(__name)
#define weechat_bar_item_remove(__item) \
@@ -1810,16 +1926,18 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
(weechat_plugin->hdata_get_string)(__hdata, __property)
/* upgrade */
-#define weechat_upgrade_new(__filename, __write) \
- (weechat_plugin->upgrade_new)(__filename, __write)
+#define weechat_upgrade_new(__filename, __callback_read, \
+ __callback_read_pointer, \
+ __callback_read_data) \
+ (weechat_plugin->upgrade_new)(__filename, __callback_read, \
+ __callback_read_pointer, \
+ __callback_read_data)
#define weechat_upgrade_write_object(__upgrade_file, __object_id, \
__infolist) \
(weechat_plugin->upgrade_write_object)(__upgrade_file, __object_id, \
__infolist)
-#define weechat_upgrade_read(__upgrade_file, __callback_read, \
- __callback_read_data) \
- (weechat_plugin->upgrade_read)(__upgrade_file, __callback_read, \
- __callback_read_data)
+#define weechat_upgrade_read(__upgrade_file) \
+ (weechat_plugin->upgrade_read)(__upgrade_file)
#define weechat_upgrade_close(__upgrade_file) \
(weechat_plugin->upgrade_close)(__upgrade_file)
diff --git a/src/plugins/xfer/CMakeLists.txt b/src/plugins/xfer/CMakeLists.txt
index 54412a8c1..9fb1ce651 100644
--- a/src/plugins/xfer/CMakeLists.txt
+++ b/src/plugins/xfer/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/xfer/Makefile.am b/src/plugins/xfer/Makefile.am
index faa6a1384..bb4fecd22 100644
--- a/src/plugins/xfer/Makefile.am
+++ b/src/plugins/xfer/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/xfer/xfer-buffer.c b/src/plugins/xfer/xfer-buffer.c
index 48272f77f..934797b46 100644
--- a/src/plugins/xfer/xfer-buffer.c
+++ b/src/plugins/xfer/xfer-buffer.c
@@ -1,7 +1,7 @@
/*
* xfer-buffer.c - display xfer list on xfer buffer
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -259,12 +259,14 @@ xfer_buffer_refresh (const char *hotlist)
*/
int
-xfer_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
+xfer_buffer_input_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
const char *input_data)
{
struct t_xfer *xfer, *ptr_xfer, *next_xfer;
/* make C compiler happy */
+ (void) pointer;
(void) data;
xfer = xfer_search_by_number (xfer_buffer_selected_line);
@@ -323,9 +325,11 @@ xfer_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
*/
int
-xfer_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
+xfer_buffer_close_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
@@ -344,8 +348,8 @@ xfer_buffer_open ()
if (!xfer_buffer)
{
xfer_buffer = weechat_buffer_new (XFER_BUFFER_NAME,
- &xfer_buffer_input_cb, NULL,
- &xfer_buffer_close_cb, NULL);
+ &xfer_buffer_input_cb, NULL, NULL,
+ &xfer_buffer_close_cb, NULL, NULL);
/* failed to create buffer ? then exit */
if (!xfer_buffer)
diff --git a/src/plugins/xfer/xfer-buffer.h b/src/plugins/xfer/xfer-buffer.h
index b1cc5f3df..6d5ebb188 100644
--- a/src/plugins/xfer/xfer-buffer.h
+++ b/src/plugins/xfer/xfer-buffer.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -26,9 +26,11 @@ extern struct t_gui_buffer *xfer_buffer;
extern int xfer_buffer_selected_line;
extern void xfer_buffer_refresh (const char *hotlist);
-extern int xfer_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
+extern int xfer_buffer_input_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
const char *input_data);
-extern int xfer_buffer_close_cb (void *data, struct t_gui_buffer *buffer);
+extern int xfer_buffer_close_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer);
extern void xfer_buffer_open ();
#endif /* WEECHAT_XFER_BUFFER_H */
diff --git a/src/plugins/xfer/xfer-chat.c b/src/plugins/xfer/xfer-chat.c
index 94af315b1..33177c930 100644
--- a/src/plugins/xfer/xfer-chat.c
+++ b/src/plugins/xfer/xfer-chat.c
@@ -1,7 +1,7 @@
/*
* xfer-chat.c - chat with direct connection to remote host
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -104,7 +104,7 @@ xfer_chat_sendf (struct t_xfer *xfer, const char *format, ...)
*/
int
-xfer_chat_recv_cb (void *arg_xfer, int fd)
+xfer_chat_recv_cb (const void *pointer, void *data, int fd)
{
struct t_xfer *xfer;
static char buffer[4096 + 2];
@@ -115,9 +115,10 @@ xfer_chat_recv_cb (void *arg_xfer, int fd)
int num_read, length, ctcp_action;
/* make C compiler happy */
+ (void) data;
(void) fd;
- xfer = (struct t_xfer *)arg_xfer;
+ xfer = (struct t_xfer *)pointer;
num_read = recv (xfer->sock, buffer, sizeof (buffer) - 2, 0);
if (num_read > 0)
@@ -199,16 +200,18 @@ xfer_chat_recv_cb (void *arg_xfer, int fd)
(pv_tags && pv_tags[0]) ? pv_tags : "",
(pv_tags && pv_tags[0]) ? "," : "",
xfer->remote_nick);
- weechat_printf_tags (xfer->buffer,
- str_tags,
- "%s%s%s%s%s%s",
- weechat_prefix ("action"),
- weechat_color ((xfer->remote_nick_color) ?
- xfer->remote_nick_color : "chat_nick_other"),
- xfer->remote_nick,
- weechat_color ("chat"),
- (ptr_buf2[0]) ? " " : "",
- ptr_buf2);
+ weechat_printf_date_tags (
+ xfer->buffer,
+ 0,
+ str_tags,
+ "%s%s%s%s%s%s",
+ weechat_prefix ("action"),
+ weechat_color ((xfer->remote_nick_color) ?
+ xfer->remote_nick_color : "chat_nick_other"),
+ xfer->remote_nick,
+ weechat_color ("chat"),
+ (ptr_buf2[0]) ? " " : "",
+ ptr_buf2);
}
else
{
@@ -223,13 +226,16 @@ xfer_chat_recv_cb (void *arg_xfer, int fd)
xfer->remote_nick);
if (str_color)
free (str_color);
- weechat_printf_tags (xfer->buffer,
- str_tags,
- "%s%s\t%s",
- weechat_color ((xfer->remote_nick_color) ?
- xfer->remote_nick_color : "chat_nick_other"),
- xfer->remote_nick,
- ptr_buf2);
+ weechat_printf_date_tags (
+ xfer->buffer,
+ 0,
+ str_tags,
+ "%s%s\t%s",
+ weechat_color (
+ (xfer->remote_nick_color) ?
+ xfer->remote_nick_color : "chat_nick_other"),
+ xfer->remote_nick,
+ ptr_buf2);
}
if (ptr_buf_decoded)
free (ptr_buf_decoded);
@@ -259,13 +265,15 @@ xfer_chat_recv_cb (void *arg_xfer, int fd)
*/
int
-xfer_chat_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
+xfer_chat_buffer_input_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
const char *input_data)
{
struct t_xfer *ptr_xfer;
char *input_data_color, str_tags[256], *str_color;
/* make C compiler happy */
+ (void) pointer;
(void) data;
ptr_xfer = xfer_search_by_buffer (buffer);
@@ -287,12 +295,14 @@ xfer_chat_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
input_data_color = weechat_hook_modifier_exec ("irc_color_decode",
"1",
input_data);
- weechat_printf_tags (buffer,
- str_tags,
- "%s%s\t%s",
- weechat_color ("chat_nick_self"),
- ptr_xfer->local_nick,
- (input_data_color) ? input_data_color : input_data);
+ weechat_printf_date_tags (
+ buffer,
+ 0,
+ str_tags,
+ "%s%s\t%s",
+ weechat_color ("chat_nick_self"),
+ ptr_xfer->local_nick,
+ (input_data_color) ? input_data_color : input_data);
if (input_data_color)
free (input_data_color);
}
@@ -307,11 +317,13 @@ xfer_chat_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
*/
int
-xfer_chat_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
+xfer_chat_buffer_close_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer)
{
struct t_xfer *ptr_xfer;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
@@ -346,44 +358,48 @@ xfer_chat_open_buffer (struct t_xfer *xfer)
length = strlen (xfer->plugin_name) + 8 + strlen (xfer->plugin_id) + 1
+ strlen (xfer->remote_nick) + 1;
name = malloc (length);
- if (name)
+ if (!name)
+ return;
+
+ snprintf (name, length, "%s_dcc.%s.%s",
+ xfer->plugin_name, xfer->plugin_id, xfer->remote_nick);
+ xfer->buffer = weechat_buffer_search (XFER_PLUGIN_NAME, name);
+ if (!xfer->buffer)
{
- snprintf (name, length, "%s_dcc.%s.%s",
- xfer->plugin_name, xfer->plugin_id, xfer->remote_nick);
- xfer->buffer = weechat_buffer_search (XFER_PLUGIN_NAME, name);
+ xfer->buffer = weechat_buffer_new (
+ name,
+ &xfer_chat_buffer_input_cb, NULL, NULL,
+ &xfer_chat_buffer_close_cb, NULL, NULL);
+ buffer_created = 1;
+
+ /* failed to create buffer ? then return */
if (!xfer->buffer)
{
- xfer->buffer = weechat_buffer_new (name,
- &xfer_chat_buffer_input_cb, NULL,
- &xfer_chat_buffer_close_cb, NULL);
- buffer_created = 1;
-
- /* failed to create buffer ? then return */
- if (!xfer->buffer)
- return;
+ free (name);
+ return;
}
+ }
- if (buffer_created)
+ if (buffer_created)
+ {
+ weechat_buffer_set (xfer->buffer, "title", _("xfer chat"));
+ if (!weechat_buffer_get_integer (xfer->buffer, "short_name_is_set"))
{
- weechat_buffer_set (xfer->buffer, "title", _("xfer chat"));
- if (!weechat_buffer_get_integer (xfer->buffer, "short_name_is_set"))
- {
- weechat_buffer_set (xfer->buffer, "short_name",
- xfer->remote_nick);
- }
- weechat_buffer_set (xfer->buffer, "localvar_set_type", "private");
- weechat_buffer_set (xfer->buffer, "localvar_set_nick", xfer->local_nick);
- weechat_buffer_set (xfer->buffer, "localvar_set_channel", xfer->remote_nick);
- weechat_buffer_set (xfer->buffer, "highlight_words_add", "$nick");
+ weechat_buffer_set (xfer->buffer, "short_name",
+ xfer->remote_nick);
}
+ weechat_buffer_set (xfer->buffer, "localvar_set_type", "private");
+ weechat_buffer_set (xfer->buffer, "localvar_set_nick", xfer->local_nick);
+ weechat_buffer_set (xfer->buffer, "localvar_set_channel", xfer->remote_nick);
+ weechat_buffer_set (xfer->buffer, "highlight_words_add", "$nick");
+ }
- weechat_printf (xfer->buffer,
- _("%s%s: connected to %s (%s) via xfer chat"),
- weechat_prefix ("network"),
- XFER_PLUGIN_NAME,
- xfer->remote_nick,
- xfer->remote_address_str);
+ weechat_printf (xfer->buffer,
+ _("%s%s: connected to %s (%s) via xfer chat"),
+ weechat_prefix ("network"),
+ XFER_PLUGIN_NAME,
+ xfer->remote_nick,
+ xfer->remote_address_str);
- free (name);
- }
+ free (name);
}
diff --git a/src/plugins/xfer/xfer-chat.h b/src/plugins/xfer/xfer-chat.h
index bea5ca581..fa1018651 100644
--- a/src/plugins/xfer/xfer-chat.h
+++ b/src/plugins/xfer/xfer-chat.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -21,7 +21,7 @@
#define WEECHAT_XFER_CHAT_H 1
extern void xfer_chat_sendf (struct t_xfer *xfer, const char *format, ...);
-extern int xfer_chat_recv_cb (void *arg_xfer, int fd);
+extern int xfer_chat_recv_cb (const void *pointer, void *data, int fd);
extern void xfer_chat_open_buffer (struct t_xfer *xfer);
#endif /* WEECHAT_XFER_CHAT_H */
diff --git a/src/plugins/xfer/xfer-command.c b/src/plugins/xfer/xfer-command.c
index ff5f18f01..a548c6a62 100644
--- a/src/plugins/xfer/xfer-command.c
+++ b/src/plugins/xfer/xfer-command.c
@@ -1,7 +1,7 @@
/*
* xfer-command.c - xfer command
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -35,12 +35,14 @@
*/
int
-xfer_command_me (void *data, struct t_gui_buffer *buffer, int argc,
+xfer_command_me (const void *pointer, void *data,
+ struct t_gui_buffer *buffer, int argc,
char **argv, char **argv_eol)
{
struct t_xfer *ptr_xfer;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) argc;
(void) argv;
@@ -60,14 +62,15 @@ xfer_command_me (void *data, struct t_gui_buffer *buffer, int argc,
{
xfer_chat_sendf (ptr_xfer, "\01ACTION %s\01\r\n",
(argv_eol[1]) ? argv_eol[1] : "");
- weechat_printf_tags (buffer,
- "no_highlight",
- "%s%s%s %s%s",
- weechat_prefix ("action"),
- weechat_color ("chat_nick_self"),
- ptr_xfer->local_nick,
- weechat_color ("chat"),
- (argv_eol[1]) ? argv_eol[1] : "");
+ weechat_printf_date_tags (buffer,
+ 0,
+ "no_highlight",
+ "%s%s%s %s%s",
+ weechat_prefix ("action"),
+ weechat_color ("chat_nick_self"),
+ ptr_xfer->local_nick,
+ weechat_color ("chat"),
+ (argv_eol[1]) ? argv_eol[1] : "");
}
return WEECHAT_RC_OK;
@@ -192,10 +195,12 @@ xfer_command_xfer_list (int full)
*/
int
-xfer_command_xfer (void *data, struct t_gui_buffer *buffer, int argc,
+xfer_command_xfer (const void *pointer, void *data,
+ struct t_gui_buffer *buffer, int argc,
char **argv, char **argv_eol)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) buffer;
(void) argv_eol;
@@ -251,7 +256,8 @@ xfer_command_init ()
N_("send a CTCP action to remote host"),
N_("<message>"),
N_("message: message to send"),
- NULL, &xfer_command_me, NULL);
+ NULL,
+ &xfer_command_me, NULL, NULL);
weechat_hook_command (
"xfer",
N_("xfer control"),
@@ -260,5 +266,6 @@ xfer_command_init ()
"listfull: list xfer (verbose)\n"
"\n"
"Without argument, this command opens buffer with xfer list."),
- "list|listfull", &xfer_command_xfer, NULL);
+ "list|listfull",
+ &xfer_command_xfer, NULL, NULL);
}
diff --git a/src/plugins/xfer/xfer-command.h b/src/plugins/xfer/xfer-command.h
index 81c3173ed..1b9e79994 100644
--- a/src/plugins/xfer/xfer-command.h
+++ b/src/plugins/xfer/xfer-command.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/xfer/xfer-completion.c b/src/plugins/xfer/xfer-completion.c
index f1a0e3744..75004657e 100644
--- a/src/plugins/xfer/xfer-completion.c
+++ b/src/plugins/xfer/xfer-completion.c
@@ -1,7 +1,7 @@
/*
* xfer-completion.c - nick completion for xfer chats
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -33,13 +33,15 @@
*/
int
-xfer_completion_nick_cb (void *data, const char *completion_item,
+xfer_completion_nick_cb (const void *pointer, void *data,
+ const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
struct t_xfer *ptr_xfer;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) completion_item;
@@ -70,5 +72,5 @@ xfer_completion_init ()
{
weechat_hook_completion ("nick",
N_("nicks of DCC chat"),
- &xfer_completion_nick_cb, NULL);
+ &xfer_completion_nick_cb, NULL, NULL);
}
diff --git a/src/plugins/xfer/xfer-completion.h b/src/plugins/xfer/xfer-completion.h
index 32aece32c..88e06d324 100644
--- a/src/plugins/xfer/xfer-completion.h
+++ b/src/plugins/xfer/xfer-completion.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/xfer/xfer-config.c b/src/plugins/xfer/xfer-config.c
index e2aba74a6..b3971690c 100644
--- a/src/plugins/xfer/xfer-config.c
+++ b/src/plugins/xfer/xfer-config.c
@@ -1,7 +1,7 @@
/*
* xfer-config.c - xfer configuration options (file xfer.conf)
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -71,9 +71,11 @@ struct t_config_option *xfer_config_file_use_nick_in_filename;
*/
void
-xfer_config_refresh_cb (void *data, struct t_config_option *option)
+xfer_config_refresh_cb (const void *pointer, void *data,
+ struct t_config_option *option)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) option;
@@ -86,9 +88,11 @@ xfer_config_refresh_cb (void *data, struct t_config_option *option)
*/
int
-xfer_config_reload (void *data, struct t_config_file *config_file)
+xfer_config_reload (const void *pointer, void *data,
+ struct t_config_file *config_file)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
return weechat_config_reload (config_file);
@@ -108,15 +112,17 @@ xfer_config_init ()
struct t_config_section *ptr_section;
xfer_config_file = weechat_config_new (XFER_CONFIG_NAME,
- &xfer_config_reload, NULL);
+ &xfer_config_reload, NULL, NULL);
if (!xfer_config_file)
return 0;
ptr_section = weechat_config_new_section (xfer_config_file, "look",
0, 0,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (xfer_config_file);
@@ -128,26 +134,31 @@ xfer_config_init ()
"auto_open_buffer", "boolean",
N_("auto open xfer buffer when a new xfer is added "
"to list"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
xfer_config_look_progress_bar_size = weechat_config_new_option (
xfer_config_file, ptr_section,
"progress_bar_size", "integer",
N_("size of progress bar, in chars (if 0, progress bar is disabled)"),
NULL, 0, XFER_CONFIG_PROGRESS_BAR_MAX_SIZE, "20", NULL, 0,
- NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &xfer_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
xfer_config_look_pv_tags = weechat_config_new_option (
xfer_config_file, ptr_section,
"pv_tags", "string",
N_("comma separated list of tags used in private messages, for example: "
"\"notify_message\", \"notify_private\" or \"notify_highlight\""),
- NULL, 0, 0, "notify_private", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "notify_private", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
ptr_section = weechat_config_new_section (xfer_config_file, "color",
0, 0,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (xfer_config_file);
@@ -159,61 +170,81 @@ xfer_config_init ()
"status_waiting", "color",
N_("text color for \"waiting\" status"),
NULL, 0, 0, "lightcyan", NULL, 0,
- NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &xfer_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
xfer_config_color_status[XFER_STATUS_CONNECTING] = weechat_config_new_option (
xfer_config_file, ptr_section,
"status_connecting", "color",
N_("text color for \"connecting\" status"),
NULL, 0, 0, "yellow", NULL, 0,
- NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &xfer_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
xfer_config_color_status[XFER_STATUS_ACTIVE] = weechat_config_new_option (
xfer_config_file, ptr_section,
"status_active", "color",
N_("text color for \"active\" status"),
NULL, 0, 0, "lightblue", NULL, 0,
- NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &xfer_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
xfer_config_color_status[XFER_STATUS_DONE] = weechat_config_new_option (
xfer_config_file, ptr_section,
"status_done", "color",
N_("text color for \"done\" status"),
NULL, 0, 0, "lightgreen", NULL, 0,
- NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &xfer_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
xfer_config_color_status[XFER_STATUS_FAILED] = weechat_config_new_option (
xfer_config_file, ptr_section,
"status_failed", "color",
N_("text color for \"failed\" status"),
NULL, 0, 0, "lightred", NULL, 0,
- NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &xfer_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
xfer_config_color_status[XFER_STATUS_ABORTED] = weechat_config_new_option (
xfer_config_file, ptr_section,
"status_aborted", "color",
N_("text color for \"aborted\" status"),
NULL, 0, 0, "lightred", NULL, 0,
- NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &xfer_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
xfer_config_color_text = weechat_config_new_option (
xfer_config_file, ptr_section,
"text", "color",
N_("text color in xfer buffer"),
NULL, 0, 0, "default", NULL, 0,
- NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &xfer_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
xfer_config_color_text_bg = weechat_config_new_option (
xfer_config_file, ptr_section,
"text_bg", "color",
N_("background color in xfer buffer"),
NULL, 0, 0, "default", NULL, 0,
- NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &xfer_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
xfer_config_color_text_selected = weechat_config_new_option (
xfer_config_file, ptr_section,
"text_selected", "color",
N_("text color of selected line in xfer buffer"),
NULL, 0, 0, "white", NULL, 0,
- NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
+ NULL, NULL, NULL,
+ &xfer_config_refresh_cb, NULL, NULL,
+ NULL, NULL, NULL);
ptr_section = weechat_config_new_section (xfer_config_file, "network",
0, 0,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (xfer_config_file);
@@ -225,18 +256,20 @@ xfer_config_init ()
"blocksize", "integer",
N_("block size for sending packets, in bytes"),
NULL, XFER_BLOCKSIZE_MIN, XFER_BLOCKSIZE_MAX, "65536", NULL, 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
xfer_config_network_fast_send = weechat_config_new_option (
xfer_config_file, ptr_section,
"fast_send", "boolean",
N_("does not wait for ACK when sending file"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
xfer_config_network_own_ip = weechat_config_new_option (
xfer_config_file, ptr_section,
"own_ip", "string",
N_("IP or DNS address used for sending files/chats "
"(if empty, local interface IP is used)"),
- NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
xfer_config_network_port_range = weechat_config_new_option (
xfer_config_file, ptr_section,
"port_range", "string",
@@ -245,24 +278,29 @@ xfer_config_init ()
"range, ie. 5000-5015, empty value means any port, it's recommended "
"to use ports greater than 1024, because only root can use ports "
"below 1024)"),
- NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
xfer_config_network_speed_limit = weechat_config_new_option (
xfer_config_file, ptr_section,
"speed_limit", "integer",
N_("speed limit for sending files, in kilo-bytes by second (0 means "
"no limit)"),
- NULL, 0, INT_MAX, "0", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, INT_MAX, "0", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
xfer_config_network_timeout = weechat_config_new_option (
xfer_config_file, ptr_section,
"timeout", "integer",
N_("timeout for xfer request (in seconds)"),
- NULL, 5, INT_MAX, "300", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 5, INT_MAX, "300", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
ptr_section = weechat_config_new_section (xfer_config_file, "file",
0, 0,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL);
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (xfer_config_file);
@@ -273,12 +311,14 @@ xfer_config_init ()
xfer_config_file, ptr_section,
"auto_accept_chats", "boolean",
N_("automatically accept chat requests (use carefully!)"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
xfer_config_file_auto_accept_files = weechat_config_new_option (
xfer_config_file, ptr_section,
"auto_accept_files", "boolean",
N_("automatically accept incoming files (use carefully!)"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
xfer_config_file_auto_accept_nicks = weechat_config_new_option (
xfer_config_file, ptr_section,
"auto_accept_nicks", "string",
@@ -286,36 +326,42 @@ xfer_config_init ()
"chats are automatically accepted; format is \"server.nick\" (for a "
"specific server) or \"nick\" (for all servers); example: "
"\"freenode.FlashCode,andrew\""),
- NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
xfer_config_file_auto_check_crc32 = weechat_config_new_option (
xfer_config_file, ptr_section,
"auto_check_crc32", "boolean",
N_("automatically check CRC32 file checksum if it is found in the "
"filename (8 hexadecimal chars)"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
xfer_config_file_auto_rename = weechat_config_new_option (
xfer_config_file, ptr_section,
"auto_rename", "boolean",
N_("rename incoming files if already exists (add \".1\", \".2\", ...)"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
xfer_config_file_auto_resume = weechat_config_new_option (
xfer_config_file, ptr_section,
"auto_resume", "boolean",
N_("automatically resume file transfer if connection with remote host "
"is lost"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
xfer_config_file_convert_spaces = weechat_config_new_option (
xfer_config_file, ptr_section,
"convert_spaces", "boolean",
N_("convert spaces to underscores when sending and receiving files"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
xfer_config_file_download_path = weechat_config_new_option (
xfer_config_file, ptr_section,
"download_path", "string",
N_("path for writing incoming files: \"%h\" at beginning of string is "
"replaced by WeeChat home (\"~/.weechat\" by default) "
"(note: content is evaluated, see /help eval)"),
- NULL, 0, 0, "%h/xfer", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "%h/xfer", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
xfer_config_file_upload_path = weechat_config_new_option (
xfer_config_file, ptr_section,
"upload_path", "string",
@@ -323,12 +369,14 @@ xfer_config_init ()
"by user): \"%h\" at beginning of string is replaced by WeeChat "
"home (\"~/.weechat\" by default) "
"(note: content is evaluated, see /help eval)"),
- NULL, 0, 0, "~", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "~", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
xfer_config_file_use_nick_in_filename = weechat_config_new_option (
xfer_config_file, ptr_section,
"use_nick_in_filename", "boolean",
N_("use remote nick as prefix in local filename when receiving a file"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "on", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
return 1;
}
diff --git a/src/plugins/xfer/xfer-config.h b/src/plugins/xfer/xfer-config.h
index 1996fc89c..500f2322e 100644
--- a/src/plugins/xfer/xfer-config.h
+++ b/src/plugins/xfer/xfer-config.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -42,9 +42,9 @@ extern struct t_config_option *xfer_config_network_port_range;
extern struct t_config_option *xfer_config_network_speed_limit;
extern struct t_config_option *xfer_config_network_timeout;
-struct t_config_option *xfer_config_file_auto_accept_chats;
-struct t_config_option *xfer_config_file_auto_accept_files;
-struct t_config_option *xfer_config_file_auto_accept_nicks;
+extern struct t_config_option *xfer_config_file_auto_accept_chats;
+extern struct t_config_option *xfer_config_file_auto_accept_files;
+extern struct t_config_option *xfer_config_file_auto_accept_nicks;
extern struct t_config_option *xfer_config_file_auto_rename;
extern struct t_config_option *xfer_config_file_auto_resume;
extern struct t_config_option *xfer_config_file_auto_check_crc32;
diff --git a/src/plugins/xfer/xfer-dcc.c b/src/plugins/xfer/xfer-dcc.c
index 850585311..24821d7e1 100644
--- a/src/plugins/xfer/xfer-dcc.c
+++ b/src/plugins/xfer/xfer-dcc.c
@@ -1,7 +1,7 @@
/*
* xfer-dcc.c - file transfer via DCC protocol
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -368,9 +368,14 @@ xfer_dcc_recv_file_child (struct t_xfer *xfer)
ready = poll (&poll_fd, 1, -1);
if (ready <= 0)
{
- xfer_network_write_pipe (xfer, XFER_STATUS_FAILED,
- XFER_ERROR_RECV_BLOCK);
- return;
+ if ((errno == EINTR) || (errno == EAGAIN))
+ continue;
+ else
+ {
+ xfer_network_write_pipe (xfer, XFER_STATUS_FAILED,
+ XFER_ERROR_RECV_BLOCK);
+ return;
+ }
}
/* read maximum data on socket (until nothing is available) */
diff --git a/src/plugins/xfer/xfer-dcc.h b/src/plugins/xfer/xfer-dcc.h
index c74a6fddc..1a1ab598c 100644
--- a/src/plugins/xfer/xfer-dcc.h
+++ b/src/plugins/xfer/xfer-dcc.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/xfer/xfer-file.c b/src/plugins/xfer/xfer-file.c
index 65f2cd42c..83b07ec09 100644
--- a/src/plugins/xfer/xfer-file.c
+++ b/src/plugins/xfer/xfer-file.c
@@ -1,7 +1,7 @@
/*
* xfer-file.c - file functions for xfer plugin
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/xfer/xfer-file.h b/src/plugins/xfer/xfer-file.h
index 84ab7012a..65e52e8c4 100644
--- a/src/plugins/xfer/xfer-file.h
+++ b/src/plugins/xfer/xfer-file.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/xfer/xfer-info.c b/src/plugins/xfer/xfer-info.c
index 98719607a..a3f55d84e 100644
--- a/src/plugins/xfer/xfer-info.c
+++ b/src/plugins/xfer/xfer-info.c
@@ -1,7 +1,7 @@
/*
* xfer-info.c - info and infolist hooks for xfer plugin
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -31,28 +31,30 @@
*/
struct t_infolist *
-xfer_info_infolist_xfer_cb (void *data, const char *infolist_name,
- void *pointer, const char *arguments)
+xfer_info_infolist_xfer_cb (const void *pointer, void *data,
+ const char *infolist_name,
+ void *obj_pointer, const char *arguments)
{
struct t_infolist *ptr_infolist;
struct t_xfer *ptr_xfer;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) infolist_name;
(void) arguments;
- if (pointer && !xfer_valid (pointer))
+ if (obj_pointer && !xfer_valid (obj_pointer))
return NULL;
ptr_infolist = weechat_infolist_new ();
if (!ptr_infolist)
return NULL;
- if (pointer)
+ if (obj_pointer)
{
/* build list with only one xfer */
- if (!xfer_add_to_infolist (ptr_infolist, pointer))
+ if (!xfer_add_to_infolist (ptr_infolist, obj_pointer))
{
weechat_infolist_free (ptr_infolist);
return NULL;
@@ -88,5 +90,5 @@ xfer_info_init ()
"xfer", N_("list of xfer"),
N_("xfer pointer (optional)"),
NULL,
- &xfer_info_infolist_xfer_cb, NULL);
+ &xfer_info_infolist_xfer_cb, NULL, NULL);
}
diff --git a/src/plugins/xfer/xfer-info.h b/src/plugins/xfer/xfer-info.h
index ed23010db..7f20b9c6b 100644
--- a/src/plugins/xfer/xfer-info.h
+++ b/src/plugins/xfer/xfer-info.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/xfer/xfer-network.c b/src/plugins/xfer/xfer-network.c
index 9200298a1..a6871376d 100644
--- a/src/plugins/xfer/xfer-network.c
+++ b/src/plugins/xfer/xfer-network.c
@@ -1,7 +1,7 @@
/*
* xfer-network.c - network functions for xfer plugin
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -93,16 +93,17 @@ xfer_network_write_pipe (struct t_xfer *xfer, int status, int error)
*/
int
-xfer_network_child_read_cb (void *arg_xfer, int fd)
+xfer_network_child_read_cb (const void *pointer, void *data, int fd)
{
struct t_xfer *xfer;
char bufpipe[1 + 1 + 32 + 1];
int num_read;
/* make C compiler happy */
+ (void) data;
(void) fd;
- xfer = (struct t_xfer *)arg_xfer;
+ xfer = (struct t_xfer *)pointer;
num_read = read (xfer->child_read, bufpipe, sizeof (bufpipe));
if (num_read > 0)
@@ -270,7 +271,7 @@ xfer_network_send_file_fork (struct t_xfer *xfer)
xfer->hook_fd = weechat_hook_fd (xfer->child_read,
1, 0, 0,
&xfer_network_child_read_cb,
- xfer);
+ xfer, NULL);
}
/*
@@ -328,7 +329,7 @@ xfer_network_recv_file_fork (struct t_xfer *xfer)
xfer->hook_fd = weechat_hook_fd (xfer->child_read,
1, 0, 0,
&xfer_network_child_read_cb,
- xfer);
+ xfer, NULL);
}
/*
@@ -364,7 +365,7 @@ xfer_network_child_kill (struct t_xfer *xfer)
*/
int
-xfer_network_fd_cb (void *arg_xfer, int fd)
+xfer_network_fd_cb (const void *pointer, void *data, int fd)
{
struct t_xfer *xfer;
int sock, flags, error;
@@ -373,11 +374,12 @@ xfer_network_fd_cb (void *arg_xfer, int fd)
char str_address[NI_MAXHOST];
/* make C compiler happy */
+ (void) data;
(void) fd;
length = sizeof (addr);
memset (&addr, 0, length);
- xfer = (struct t_xfer *)arg_xfer;
+ xfer = (struct t_xfer *)pointer;
if (xfer->status == XFER_STATUS_CONNECTING)
{
@@ -484,7 +486,7 @@ xfer_network_fd_cb (void *arg_xfer, int fd)
xfer->hook_fd = weechat_hook_fd (xfer->sock,
1, 0, 0,
&xfer_chat_recv_cb,
- xfer);
+ xfer, NULL);
xfer_chat_open_buffer (xfer);
}
}
@@ -498,14 +500,15 @@ xfer_network_fd_cb (void *arg_xfer, int fd)
*/
int
-xfer_network_timer_cb (void *arg_xfer, int remaining_calls)
+xfer_network_timer_cb (const void *pointer, void *data, int remaining_calls)
{
struct t_xfer *xfer;
/* make C compiler happy */
+ (void) data;
(void) remaining_calls;
- xfer = (struct t_xfer *)arg_xfer;
+ xfer = (struct t_xfer *)pointer;
if ((xfer->status == XFER_STATUS_WAITING)
|| (xfer->status == XFER_STATUS_CONNECTING))
@@ -526,7 +529,8 @@ xfer_network_timer_cb (void *arg_xfer, int remaining_calls)
*/
int
-xfer_network_connect_chat_recv_cb (void *data, int status, int gnutls_rc,
+xfer_network_connect_chat_recv_cb (const void *pointer, void *data,
+ int status, int gnutls_rc,
int sock, const char *error,
const char *ip_address)
{
@@ -534,10 +538,11 @@ xfer_network_connect_chat_recv_cb (void *data, int status, int gnutls_rc,
int flags;
/* make C compiler happy */
+ (void) data;
(void) gnutls_rc;
(void) ip_address;
- xfer = (struct t_xfer*)data;
+ xfer = (struct t_xfer*)pointer;
weechat_unhook (xfer->hook_connect);
xfer->hook_connect = NULL;
@@ -567,7 +572,7 @@ xfer_network_connect_chat_recv_cb (void *data, int status, int gnutls_rc,
xfer->hook_fd = weechat_hook_fd (xfer->sock,
1, 0, 0,
&xfer_chat_recv_cb,
- xfer);
+ xfer, NULL);
xfer_chat_open_buffer (xfer);
xfer->status = XFER_STATUS_ACTIVE;
@@ -615,8 +620,9 @@ xfer_network_connect_chat_recv_cb (void *data, int status, int gnutls_rc,
break;
case WEECHAT_HOOK_CONNECT_MEMORY_ERROR:
weechat_printf (NULL,
- _("%s%s: not enough memory"),
- weechat_prefix ("error"), XFER_PLUGIN_NAME);
+ _("%s%s: not enough memory (%s)"),
+ weechat_prefix ("error"), XFER_PLUGIN_NAME,
+ (error) ? error : "-");
break;
case WEECHAT_HOOK_CONNECT_TIMEOUT:
weechat_printf (NULL,
@@ -691,7 +697,7 @@ xfer_network_connect (struct t_xfer *xfer)
xfer->hook_fd = weechat_hook_fd (xfer->sock,
1, 0, 0,
&xfer_network_fd_cb,
- xfer);
+ xfer, NULL);
/* add timeout */
if (weechat_config_integer (xfer_config_network_timeout) > 0)
@@ -699,7 +705,7 @@ xfer_network_connect (struct t_xfer *xfer)
xfer->hook_timer = weechat_hook_timer (weechat_config_integer (xfer_config_network_timeout) * 1000,
0, 1,
&xfer_network_timer_cb,
- xfer);
+ xfer, NULL);
}
}
@@ -711,7 +717,7 @@ xfer_network_connect (struct t_xfer *xfer)
xfer->port, 1, 0, NULL, NULL,
0, "NONE", NULL,
&xfer_network_connect_chat_recv_cb,
- xfer);
+ xfer, NULL);
}
/* for file receiving, connection is made in child process (blocking) */
diff --git a/src/plugins/xfer/xfer-network.h b/src/plugins/xfer/xfer-network.h
index cacf10619..67b41a56a 100644
--- a/src/plugins/xfer/xfer-network.h
+++ b/src/plugins/xfer/xfer-network.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/xfer/xfer-upgrade.c b/src/plugins/xfer/xfer-upgrade.c
index 52f154c77..8d0cb2809 100644
--- a/src/plugins/xfer/xfer-upgrade.c
+++ b/src/plugins/xfer/xfer-upgrade.c
@@ -1,7 +1,7 @@
/*
* xfer-upgrade.c - save/restore xfer plugin data when upgrading WeeChat
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -58,7 +58,8 @@ xfer_upgrade_save ()
int rc;
struct t_upgrade_file *upgrade_file;
- upgrade_file = weechat_upgrade_new (XFER_UPGRADE_FILENAME, 1);
+ upgrade_file = weechat_upgrade_new (XFER_UPGRADE_FILENAME,
+ NULL, NULL, NULL);
if (!upgrade_file)
return 0;
@@ -106,17 +107,19 @@ xfer_upgrade_set_buffer_callbacks ()
*/
int
-xfer_upgrade_read_cb (void *data,
+xfer_upgrade_read_cb (const void *pointer, void *data,
struct t_upgrade_file *upgrade_file,
int object_id,
struct t_infolist *infolist)
{
- /* TODO: write xfer read cb */
+ /* make C compiler happy */
+ (void) pointer;
(void) data;
(void) upgrade_file;
(void) object_id;
(void) infolist;
+ /* TODO: write xfer read cb */
return WEECHAT_RC_OK;
}
@@ -136,10 +139,13 @@ xfer_upgrade_load ()
xfer_upgrade_set_buffer_callbacks ();
- upgrade_file = weechat_upgrade_new (XFER_UPGRADE_FILENAME, 0);
+ upgrade_file = weechat_upgrade_new (XFER_UPGRADE_FILENAME,
+ &xfer_upgrade_read_cb, NULL, NULL);
if (!upgrade_file)
return 0;
- rc = weechat_upgrade_read (upgrade_file, &xfer_upgrade_read_cb, NULL);
+
+ rc = weechat_upgrade_read (upgrade_file);
+
weechat_upgrade_close (upgrade_file);
return rc;
diff --git a/src/plugins/xfer/xfer-upgrade.h b/src/plugins/xfer/xfer-upgrade.h
index 9c2b290fd..a44563523 100644
--- a/src/plugins/xfer/xfer-upgrade.h
+++ b/src/plugins/xfer/xfer-upgrade.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/xfer/xfer.c b/src/plugins/xfer/xfer.c
index 84d43aade..2032a29f6 100644
--- a/src/plugins/xfer/xfer.c
+++ b/src/plugins/xfer/xfer.c
@@ -1,7 +1,7 @@
/*
* xfer.c - file transfer and direct chat plugin for WeeChat
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -29,7 +29,9 @@
#include <time.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <arpa/nameser.h>
#include <netdb.h>
+#include <resolv.h>
#include <gcrypt.h>
#include <arpa/inet.h>
@@ -116,10 +118,12 @@ xfer_valid (struct t_xfer *xfer)
*/
int
-xfer_signal_upgrade_cb (void *data, const char *signal, const char *type_data,
+xfer_signal_upgrade_cb (const void *pointer, void *data,
+ const char *signal, const char *type_data,
void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -847,7 +851,8 @@ xfer_set_remote_address (struct t_xfer *xfer, const struct sockaddr *address,
free (xfer->remote_address);
xfer->remote_address = malloc (length);
xfer->remote_address_length = length;
- memcpy (xfer->remote_address, address, length);
+ if (xfer->remote_address)
+ memcpy (xfer->remote_address, address, length);
if (xfer->remote_address_str)
free (xfer->remote_address_str);
@@ -865,7 +870,8 @@ xfer_set_local_address (struct t_xfer *xfer, const struct sockaddr *address,
free (xfer->local_address);
xfer->local_address = malloc (length);
xfer->local_address_length = length;
- memcpy (xfer->local_address, address, length);
+ if (xfer->local_address)
+ memcpy (xfer->local_address, address, length);
if (xfer->local_address_str)
free (xfer->local_address_str);
@@ -964,6 +970,7 @@ xfer_resolve_addr (const char *str_address, const char *str_port,
hints.ai_addr = NULL;
hints.ai_next = NULL;
+ res_init ();
rc = getaddrinfo (str_address, str_port, &hints, &ainfo);
if ((rc == 0) && ainfo && ainfo->ai_addr)
{
@@ -997,7 +1004,8 @@ xfer_resolve_addr (const char *str_address, const char *str_port,
*/
int
-xfer_add_cb (void *data, const char *signal, const char *type_data,
+xfer_add_cb (const void *pointer, void *data,
+ const char *signal, const char *type_data,
void *signal_data)
{
struct t_infolist *infolist;
@@ -1014,6 +1022,7 @@ xfer_add_cb (void *data, const char *signal, const char *type_data,
struct t_xfer *ptr_xfer;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -1115,16 +1124,18 @@ xfer_add_cb (void *data, const char *signal, const char *type_data,
if (!path)
{
weechat_printf (NULL,
- _("%s%s: not enough memory"),
- weechat_prefix ("error"), XFER_PLUGIN_NAME);
+ _("%s%s: not enough memory (%s)"),
+ weechat_prefix ("error"), XFER_PLUGIN_NAME,
+ "xfer_add, path");
goto error;
}
filename2 = malloc (strlen (path) + strlen (filename) + 4);
if (!filename2)
{
weechat_printf (NULL,
- _("%s%s: not enough memory"),
- weechat_prefix ("error"), XFER_PLUGIN_NAME);
+ _("%s%s: not enough memory (%s)"),
+ weechat_prefix ("error"), XFER_PLUGIN_NAME,
+ "xfer_add, filename2");
free (path);
goto error;
}
@@ -1367,7 +1378,8 @@ error:
*/
int
-xfer_start_resume_cb (void *data, const char *signal, const char *type_data,
+xfer_start_resume_cb (const void *pointer, void *data,
+ const char *signal, const char *type_data,
void *signal_data)
{
struct t_infolist *infolist;
@@ -1377,6 +1389,7 @@ xfer_start_resume_cb (void *data, const char *signal, const char *type_data,
unsigned long long start_resume;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -1451,7 +1464,8 @@ error:
*/
int
-xfer_accept_resume_cb (void *data, const char *signal, const char *type_data,
+xfer_accept_resume_cb (const void *pointer, void *data,
+ const char *signal, const char *type_data,
void *signal_data)
{
struct t_infolist *infolist;
@@ -1461,6 +1475,7 @@ xfer_accept_resume_cb (void *data, const char *signal, const char *type_data,
unsigned long long start_resume;
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -1737,10 +1752,12 @@ xfer_print_log ()
*/
int
-xfer_debug_dump_cb (void *data, const char *signal, const char *type_data,
+xfer_debug_dump_cb (const void *pointer, void *data,
+ const char *signal, const char *type_data,
void *signal_data)
{
/* make C compiler happy */
+ (void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -1783,11 +1800,16 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
xfer_command_init ();
/* hook some signals */
- weechat_hook_signal ("upgrade", &xfer_signal_upgrade_cb, NULL);
- weechat_hook_signal ("xfer_add", &xfer_add_cb, NULL);
- weechat_hook_signal ("xfer_start_resume", &xfer_start_resume_cb, NULL);
- weechat_hook_signal ("xfer_accept_resume", &xfer_accept_resume_cb, NULL);
- weechat_hook_signal ("debug_dump", &xfer_debug_dump_cb, NULL);
+ weechat_hook_signal ("upgrade",
+ &xfer_signal_upgrade_cb, NULL, NULL);
+ weechat_hook_signal ("xfer_add",
+ &xfer_add_cb, NULL, NULL);
+ weechat_hook_signal ("xfer_start_resume",
+ &xfer_start_resume_cb, NULL, NULL);
+ weechat_hook_signal ("xfer_accept_resume",
+ &xfer_accept_resume_cb, NULL, NULL);
+ weechat_hook_signal ("debug_dump",
+ &xfer_debug_dump_cb, NULL, NULL);
/* hook completions */
xfer_completion_init ();
diff --git a/src/plugins/xfer/xfer.h b/src/plugins/xfer/xfer.h
index 0638151dc..f099abbe2 100644
--- a/src/plugins/xfer/xfer.h
+++ b/src/plugins/xfer/xfer.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*