1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-23 19:36:37 +02:00

Compare commits

...

45 Commits

Author SHA1 Message Date
Sébastien Helleu 0ba30fc217 core: use function util_parse_longlong to parse date in command /print 2026-06-20 11:54:32 +02:00
Sébastien Helleu 9cf398afa1 core: use function util_parse_longlong to parse time in function hdata_set 2026-06-20 11:54:32 +02:00
Sébastien Helleu c150f67cf9 xfer: use util functions to parse integers 2026-06-20 11:33:47 +02:00
Sébastien Helleu 3df0d2d4d3 trigger: use util functions to parse integers 2026-06-20 11:32:44 +02:00
Sébastien Helleu 4d2d93a694 script: use util functions to parse integers 2026-06-20 11:31:33 +02:00
Sébastien Helleu cb0a9a3c42 relay: use util functions to parse integers 2026-06-20 11:27:42 +02:00
Sébastien Helleu 15f0cef09e api: use util functions to parse integers 2026-06-20 11:16:19 +02:00
Sébastien Helleu 49c4c2267a python: use function util_parse_int in API function hook_signal_send 2026-06-20 11:12:54 +02:00
Sébastien Helleu b6f4343d78 javascript: use function util_parse_int in API function hook_signal_send 2026-06-20 11:12:13 +02:00
Sébastien Helleu 0ae7ce165e irc: use util functions to parse integers 2026-06-20 11:09:20 +02:00
Sébastien Helleu 8d69194398 fset: use util functions to parse integers 2026-06-20 10:41:42 +02:00
Sébastien Helleu 054b7ff600 exec: use util functions to parse integers 2026-06-20 10:41:42 +02:00
Sébastien Helleu 0ade9757eb buflist: use util functions to parse integers 2026-06-20 10:41:42 +02:00
Sébastien Helleu 64c0c34735 core: use util functions to parse integers in buffer functions 2026-06-20 10:41:42 +02:00
Sébastien Helleu 6d89ea1324 core: use util functions to parse integers in window functions 2026-06-20 09:51:33 +02:00
Sébastien Helleu bbab9eceb9 core: use util functions to parse integers in nicklist functions 2026-06-20 09:51:33 +02:00
Sébastien Helleu 958c1b84fa core: use util functions to parse integers in function gui_line_hook_update 2026-06-20 09:51:33 +02:00
Sébastien Helleu c545cf75f3 core: use function util_parse_int in function gui_key_grab_init 2026-06-20 09:50:55 +02:00
Sébastien Helleu f34cb85ca3 core: use function util_parse_int in function gui_hotlist_clear_level_string 2026-06-20 09:50:55 +02:00
Sébastien Helleu bed3467efb core: use function util_parse_int in function gui_focus_info_hashtable_gui_focus_info_cb 2026-06-20 09:21:24 +02:00
Sébastien Helleu d5bb81fd2b core: use function util_parse_int in color functions 2026-06-20 09:21:22 +02:00
Sébastien Helleu c03bb825c4 core: use function util_parse_longlong in function gui_chat_hsignal_quote_line_cb 2026-06-20 09:18:36 +02:00
Sébastien Helleu 3200a05c00 relay/api: fix memory leak in resources "handshake", "input" and "completion" 2026-06-17 21:54:15 +02:00
Sébastien Helleu 861f589fc2 core: update ChangeLog (#2326) 2026-06-17 21:31:03 +02:00
aizu-m c40261aed1 xfer: fix out-of-bounds write in xfer_dcc_resume_hash (#2326) 2026-06-17 21:29:45 +02:00
Sébastien Helleu 770e733303 ci: switch from Ubuntu 24.04 to 26.04 2026-06-15 21:55:54 +02:00
Sébastien Helleu 9bd2aaa25d core: mute compiler warning on calls to dup() function 2026-06-15 08:22:03 +02:00
Sébastien Helleu 4e206ee3ae trigger: use "const char *" variables for result of string functions with const parameter 2026-06-15 07:55:20 +02:00
Sébastien Helleu 7ff71d2b0e spell: use "const char *" variables for result of string functions with const parameter 2026-06-15 07:55:10 +02:00
Sébastien Helleu 203fdca3e8 script: use "const char *" variables for result of string functions with const parameter 2026-06-15 07:54:40 +02:00
Sébastien Helleu e3ba25df19 relay: use "const char *" variables for result of string functions with const parameter 2026-06-15 07:54:10 +02:00
Sébastien Helleu 64566629c5 irc: use "const char *" variables for result of string functions with const parameter 2026-06-15 07:52:12 +02:00
Sébastien Helleu 7e3afaf46d core, api: use "const char *" variables for result of string functions with const parameter 2026-06-15 07:52:10 +02:00
Sébastien Helleu cf702d541f api: change type of parameter "pos_option_name" to "const char **" in function config_search_with_string 2026-06-15 07:29:33 +02:00
Sébastien Helleu a8067751eb doc/plugin: fix parameters of mkdir functions
The directory parameter is always `const char *` and not `char *`.
2026-06-15 07:29:28 +02:00
Sébastien Helleu a696a100d8 core: update ChangeLog (#2325) 2026-06-12 13:02:05 +02:00
aizu-m e60786d059 core: fix buffer overflow in function network_pass_socks5proxy (#2325)
bound the configured proxy username and password before they are copied into the fixed stack buffer in network_pass_socks5proxy, otherwise a login longer than the buffer (a long password or token) overruns it while building the SOCKS5 auth request.
2026-06-12 13:00:17 +02:00
Sébastien Helleu d78105ddf5 core: add CVE IDs in ChangeLog 2026-06-09 22:10:17 +02:00
weechatter 2a8c86242b core: update German translations 2026-06-09 10:42:23 +02:00
Sébastien Helleu dd9ef2f4d9 tests: add missing include of string.h 2026-06-08 23:17:19 +02:00
Sébastien Helleu 4c6c55befe core: update translations 2026-06-08 23:15:00 +02:00
Sébastien Helleu de878b2303 relay/api: remove error 400 which is never returned in response to GET /api/scripts 2026-06-08 23:11:27 +02:00
Sébastien Helleu 80a47b6731 relay/api: add missing fields in script object in OpenAPI document 2026-06-08 23:11:06 +02:00
Sébastien Helleu 551c12e049 relay/api: add resource GET /api/scripts 2026-06-08 23:04:40 +02:00
Sébastien Helleu 12016c4c05 script: add info "script_languages" 2026-06-08 18:54:06 +02:00
109 changed files with 1346 additions and 1059 deletions
+10 -11
View File
@@ -118,7 +118,7 @@ jobs:
strategy: strategy:
matrix: matrix:
os: os:
- ubuntu-24.04 - ubuntu-26.04
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
@@ -153,7 +153,7 @@ jobs:
strategy: strategy:
matrix: matrix:
os: os:
- ubuntu-24.04 - ubuntu-26.04
config: config:
- name: "gcc" - name: "gcc"
cc: "gcc" cc: "gcc"
@@ -194,6 +194,8 @@ jobs:
name: "install (${{ matrix.os }}, ${{ matrix.config.name }})" name: "install (${{ matrix.os }}, ${{ matrix.config.name }})"
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
env:
PHP_INI_SCAN_DIR: /tmp/php-noscan # embed PHP loads no add-on extensions (see #2009)
steps: steps:
@@ -203,8 +205,7 @@ jobs:
run: | run: |
sudo apt-get update -qq sudo apt-get update -qq
sudo apt-get --yes --no-install-recommends install ${{ env.WEECHAT_DEPS_UBUNTU }} sudo apt-get --yes --no-install-recommends install ${{ env.WEECHAT_DEPS_UBUNTU }}
# uninstall php imagick as is causes a crash when loading php plugin (see #2009) mkdir -p /tmp/php-noscan
sudo apt-get --yes purge php8.3-imagick
pipx install schemathesis pipx install schemathesis
- name: Build and run tests - name: Build and run tests
@@ -258,7 +259,7 @@ jobs:
strategy: strategy:
matrix: matrix:
os: os:
- ubuntu-24.04 - ubuntu-26.04
config: config:
- name: "gcc" - name: "gcc"
cc: "gcc" cc: "gcc"
@@ -304,7 +305,7 @@ jobs:
strategy: strategy:
matrix: matrix:
os: os:
- ubuntu-24.04 - ubuntu-26.04
config: config:
- name: "gcc" - name: "gcc"
cc: "gcc" cc: "gcc"
@@ -355,7 +356,7 @@ jobs:
strategy: strategy:
matrix: matrix:
os: os:
- ubuntu-24.04 - ubuntu-26.04
config: config:
# - name: "gcc" # - name: "gcc"
# cc: "gcc" # cc: "gcc"
@@ -450,7 +451,7 @@ jobs:
strategy: strategy:
matrix: matrix:
os: os:
- ubuntu-24.04 - ubuntu-26.04
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
@@ -487,7 +488,7 @@ jobs:
strategy: strategy:
matrix: matrix:
os: os:
- ubuntu-24.04 - ubuntu-26.04
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
@@ -505,8 +506,6 @@ jobs:
run: | run: |
sudo apt-get update -qq sudo apt-get update -qq
sudo apt-get --yes --no-install-recommends install ${{ env.WEECHAT_DEPS_UBUNTU }} sudo apt-get --yes --no-install-recommends install ${{ env.WEECHAT_DEPS_UBUNTU }}
# uninstall php imagick as is causes a crash when loading php plugin (see #2009)
sudo apt-get --yes purge php8.3-imagick
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v3 uses: github/codeql-action/init@v3
+12 -6
View File
@@ -12,28 +12,34 @@ SPDX-License-Identifier: GPL-3.0-or-later
- core: add condition on connected relay api clients in default value of option weechat.look.hotlist_add_conditions - core: add condition on connected relay api clients in default value of option weechat.look.hotlist_add_conditions
- core: add `/mute` in default command for key `Alt`+`=` (toggle filters) - core: add `/mute` in default command for key `Alt`+`=` (toggle filters)
- api: change type of parameter "pos_option_name" to "const char **" in function config_search_with_string
- relay/api: add field "last_read_line_id" in GET /api/buffers - relay/api: add field "last_read_line_id" in GET /api/buffers
### Added ### Added
- relay/api: add resource `GET /api/scripts`
- relay: add option relay.network.unix_socket_permissions ([#2317](https://github.com/weechat/weechat/issues/2317)) - relay: add option relay.network.unix_socket_permissions ([#2317](https://github.com/weechat/weechat/issues/2317))
- script: add info "script_languages"
### Fixed ### Fixed
- core: fix option weechat.look.color_real_white not applied when color is "white" on 16+ colors terminals ([#1742](https://github.com/weechat/weechat/issues/1742)) - core: fix option weechat.look.color_real_white not applied when color is "white" on 16+ colors terminals ([#1742](https://github.com/weechat/weechat/issues/1742))
- core: fix buffer overflow in connection to SOCKS5 proxy ([#2325](https://github.com/weechat/weechat/issues/2325))
- api: fix infinite loop in function string_replace when the search string is empty - api: fix infinite loop in function string_replace when the search string is empty
- irc: fix tag in message with list of names when joining a channel - irc: fix tag in message with list of names when joining a channel
- fset: remove error displayed in core buffer when clicking with the mouse below the last option displayed - fset: remove error displayed in core buffer when clicking with the mouse below the last option displayed
- irc: limit size of data received from the server to prevent memory exhaustion - irc: limit size of data received from the server to prevent memory exhaustion
- irc: fix out-of-bounds read on incoming DCC command with a quoted filename ending the message ([#2322](https://github.com/weechat/weechat/issues/2322)) - irc: fix out-of-bounds read on incoming DCC command with a quoted filename ending the message ([#2322](https://github.com/weechat/weechat/issues/2322))
- relay: limit size of decompressed websocket frame with permessage-deflate to prevent memory exhaustion ([GHSA-v2v4-45wm-5cr3](https://github.com/weechat/weechat/security/advisories/GHSA-v2v4-45wm-5cr3)) - relay: limit size of decompressed websocket frame with permessage-deflate to prevent memory exhaustion ([GHSA-v2v4-45wm-5cr3](https://github.com/weechat/weechat/security/advisories/GHSA-v2v4-45wm-5cr3), [CVE-2026-53524](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2026-53524))
- relay: limit size of received websocket frame and HTTP body to prevent memory exhaustion - relay: limit size of received websocket frame and HTTP body to prevent memory exhaustion
- relay: limit size of partial message received while reading an HTTP request to prevent memory exhaustion - relay: limit size of partial message received while reading an HTTP request to prevent memory exhaustion
- relay: fix timing attack on password authentication ([GHSA-vhv8-g2r9-cwcc](https://github.com/weechat/weechat/security/advisories/GHSA-vhv8-g2r9-cwcc)) - relay: fix timing attack on password authentication ([GHSA-vhv8-g2r9-cwcc](https://github.com/weechat/weechat/security/advisories/GHSA-vhv8-g2r9-cwcc), [CVE-2026-53525](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2026-53525))
- relay: fix out-of-bounds read in dump of data ([#2324](https://github.com/weechat/weechat/issues/2324)) - relay: fix out-of-bounds read in dump of data ([#2324](https://github.com/weechat/weechat/issues/2324))
- api, relay: fix timing attack on TOTP validation ([GHSA-vhv8-g2r9-cwcc](https://github.com/weechat/weechat/security/advisories/GHSA-vhv8-g2r9-cwcc)) - relay/api: fix memory leak in resources "handshake", "input" and "completion"
- api, relay: fix timing attack on TOTP validation ([GHSA-vhv8-g2r9-cwcc](https://github.com/weechat/weechat/security/advisories/GHSA-vhv8-g2r9-cwcc), [CVE-2026-53525](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2026-53525))
- xfer: replace directory separator in remote nick by underscore in download filename to prevent writing the file outside the download directory ([#2321](https://github.com/weechat/weechat/issues/2321)) - xfer: replace directory separator in remote nick by underscore in download filename to prevent writing the file outside the download directory ([#2321](https://github.com/weechat/weechat/issues/2321))
- xfer: fix out-of-bounds read when receiving empty line in DCC chat ([#2323](https://github.com/weechat/weechat/issues/2323)) - xfer: fix out-of-bounds read when receiving empty line in DCC chat ([#2323](https://github.com/weechat/weechat/issues/2323))
- xfer: fix out-of-bounds write in xfer file transfer resume ([#2326](https://github.com/weechat/weechat/issues/2326))
## Version 4.9.2 (2026-06-07) ## Version 4.9.2 (2026-06-07)
@@ -54,9 +60,9 @@ SPDX-License-Identifier: GPL-3.0-or-later
- core: fix option weechat.look.color_real_white not applied when color is "white" on 16+ colors terminals ([#1742](https://github.com/weechat/weechat/issues/1742)) - core: fix option weechat.look.color_real_white not applied when color is "white" on 16+ colors terminals ([#1742](https://github.com/weechat/weechat/issues/1742))
- irc: fix tag in message with list of names when joining a channel - irc: fix tag in message with list of names when joining a channel
- relay: limit size of decompressed websocket frame with permessage-deflate to prevent memory exhaustion ([GHSA-v2v4-45wm-5cr3](https://github.com/weechat/weechat/security/advisories/GHSA-v2v4-45wm-5cr3)) - relay: limit size of decompressed websocket frame with permessage-deflate to prevent memory exhaustion ([GHSA-v2v4-45wm-5cr3](https://github.com/weechat/weechat/security/advisories/GHSA-v2v4-45wm-5cr3), [CVE-2026-53524](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2026-53524))
- relay: fix timing attack on password authentication ([GHSA-vhv8-g2r9-cwcc](https://github.com/weechat/weechat/security/advisories/GHSA-vhv8-g2r9-cwcc)) - relay: fix timing attack on password authentication ([GHSA-vhv8-g2r9-cwcc](https://github.com/weechat/weechat/security/advisories/GHSA-vhv8-g2r9-cwcc), [CVE-2026-53525](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2026-53525))
- api, relay: fix timing attack on TOTP validation ([GHSA-vhv8-g2r9-cwcc](https://github.com/weechat/weechat/security/advisories/GHSA-vhv8-g2r9-cwcc)) - api, relay: fix timing attack on TOTP validation ([GHSA-vhv8-g2r9-cwcc](https://github.com/weechat/weechat/security/advisories/GHSA-vhv8-g2r9-cwcc), [CVE-2026-53525](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2026-53525))
## Version 4.9.0 (2026-03-29) ## Version 4.9.0 (2026-03-29)
+5 -5
View File
@@ -4348,7 +4348,7 @@ Prototype:
[source,c] [source,c]
---- ----
int weechat_mkdir_home (char *directory, int mode); int weechat_mkdir_home (const char *directory, int mode);
---- ----
Arguments: Arguments:
@@ -4395,7 +4395,7 @@ Prototype:
[source,c] [source,c]
---- ----
int weechat_mkdir (char *directory, int mode); int weechat_mkdir (const char *directory, int mode);
---- ----
Arguments: Arguments:
@@ -4436,7 +4436,7 @@ Prototype:
[source,c] [source,c]
---- ----
int weechat_mkdir_parents (char *directory, int mode); int weechat_mkdir_parents (const char *directory, int mode);
---- ----
Arguments: Arguments:
@@ -7709,7 +7709,7 @@ void weechat_config_search_with_string (const char *option_name,
struct t_config_file **config_file, struct t_config_file **config_file,
struct t_config_section **section, struct t_config_section **section,
struct t_config_option **option, struct t_config_option **option,
char **pos_option_name); const char **pos_option_name);
---- ----
Arguments: Arguments:
@@ -7731,7 +7731,7 @@ C example:
struct t_config_file *ptr_config_file; struct t_config_file *ptr_config_file;
struct t_config_section *ptr_section; struct t_config_section *ptr_section;
struct t_config_option *ptr_option; struct t_config_option *ptr_option;
char *option_name; const char *option_name;
weechat_config_search_with_string ("file.section.option", weechat_config_search_with_string ("file.section.option",
&ptr_config_file, &ptr_config_file,
+46
View File
@@ -1179,6 +1179,51 @@ HTTP/1.1 200 OK
] ]
---- ----
[[resource_scripts]]
=== Scripts
Return loaded scripts (all languages).
Endpoint:
----
GET /api/scripts
----
Request example:
[source,shell]
----
curl -L -u 'plain:secret_password' 'https://localhost:9000/api/scripts'
----
Response:
[source,http]
----
HTTP/1.1 200 OK
----
[source,json]
----
[
{
"name": "highmon.pl",
"version": "2.7",
"description": "Highlight Monitor",
"author": "KenjiE20",
"license": "GPL3"
},
{
"name": "go.py",
"version": "3.1.1",
"description": "Quick jump to buffers",
"author": "Sébastien Helleu <flashcode@flashtux.org>",
"license": "GPL3"
}
]
----
[[resource_input]] [[resource_input]]
=== Input === Input
@@ -1510,6 +1555,7 @@ Body types that can be returned:
* `nick_group` (object) * `nick_group` (object)
* `nick` (object) * `nick` (object)
* `hotlist` (object) * `hotlist` (object)
* `scripts` (array)
* `ping` (object) * `ping` (object)
[TIP] [TIP]
+5 -5
View File
@@ -4424,7 +4424,7 @@ Prototype :
[source,c] [source,c]
---- ----
int weechat_mkdir_home (char *directory, int mode); int weechat_mkdir_home (const char *directory, int mode);
---- ----
Paramètres : Paramètres :
@@ -4471,7 +4471,7 @@ Prototype :
[source,c] [source,c]
---- ----
int weechat_mkdir (char *directory, int mode); int weechat_mkdir (const char *directory, int mode);
---- ----
Paramètres : Paramètres :
@@ -4512,7 +4512,7 @@ Prototype :
[source,c] [source,c]
---- ----
int weechat_mkdir_parents (char *directory, int mode); int weechat_mkdir_parents (const char *directory, int mode);
---- ----
Paramètres : Paramètres :
@@ -7838,7 +7838,7 @@ void weechat_config_search_with_string (const char *option_name,
struct t_config_file **config_file, struct t_config_file **config_file,
struct t_config_section **section, struct t_config_section **section,
struct t_config_option **option, struct t_config_option **option,
char **pos_option_name); const char **pos_option_name);
---- ----
Paramètres : Paramètres :
@@ -7861,7 +7861,7 @@ Exemple en C :
struct t_config_file *ptr_config_file; struct t_config_file *ptr_config_file;
struct t_config_section *ptr_section; struct t_config_section *ptr_section;
struct t_config_option *ptr_option; struct t_config_option *ptr_option;
char *option_name; const char *option_name;
weechat_config_search_with_string ("fichier.section.option", weechat_config_search_with_string ("fichier.section.option",
&ptr_config_file, &ptr_config_file,
+46
View File
@@ -1191,6 +1191,51 @@ HTTP/1.1 200 OK
] ]
---- ----
[[resource_scripts]]
=== Scripts
Retourner la liste des scripts chargés (tous les langages).
Point de terminaison:
----
GET /api/scripts
----
Exemple de requête:
[source,shell]
----
curl -L -u 'plain:secret_password' 'https://localhost:9000/api/scripts'
----
Réponse:
[source,http]
----
HTTP/1.1 200 OK
----
[source,json]
----
[
{
"name": "highmon.pl",
"version": "2.7",
"description": "Highlight Monitor",
"author": "KenjiE20",
"license": "GPL3"
},
{
"name": "go.py",
"version": "3.1.1",
"description": "Quick jump to buffers",
"author": "Sébastien Helleu <flashcode@flashtux.org>",
"license": "GPL3"
}
]
----
[[resource_input]] [[resource_input]]
=== Entrée === Entrée
@@ -1530,6 +1575,7 @@ Les types de corps qui peuvent être retournés :
* `nick_group` (objet) * `nick_group` (objet)
* `nick` (objet) * `nick` (objet)
* `hotlist` (objet) * `hotlist` (objet)
* `scripts` (tableau)
* `ping` (objet) * `ping` (objet)
[TIP] [TIP]
+5 -5
View File
@@ -4549,7 +4549,7 @@ Prototipo:
[source,c] [source,c]
---- ----
int weechat_mkdir_home (char *directory, int mode); int weechat_mkdir_home (const char *directory, int mode);
---- ----
Argomenti: Argomenti:
@@ -4597,7 +4597,7 @@ Prototipo:
[source,c] [source,c]
---- ----
int weechat_mkdir (char *directory, int mode); int weechat_mkdir (const char *directory, int mode);
---- ----
Argomenti: Argomenti:
@@ -4638,7 +4638,7 @@ Prototipo:
[source,c] [source,c]
---- ----
int weechat_mkdir_parents (char *directory, int mode); int weechat_mkdir_parents (const char *directory, int mode);
---- ----
Argomenti: Argomenti:
@@ -8011,7 +8011,7 @@ void weechat_config_search_with_string (const char *option_name,
struct t_config_file **config_file, struct t_config_file **config_file,
struct t_config_section **section, struct t_config_section **section,
struct t_config_option **option, struct t_config_option **option,
char **pos_option_name); const char **pos_option_name);
---- ----
Argomenti: Argomenti:
@@ -8034,7 +8034,7 @@ Esempio in C:
struct t_config_file *ptr_config_file; struct t_config_file *ptr_config_file;
struct t_config_section *ptr_section; struct t_config_section *ptr_section;
struct t_config_option *ptr_option; struct t_config_option *ptr_option;
char *option_name; const char *option_name;
weechat_config_search_with_string ("file.section.option", weechat_config_search_with_string ("file.section.option",
&ptr_config_file, &ptr_config_file,
+5 -5
View File
@@ -4477,7 +4477,7 @@ WeeChat ホームディレクトリの下にディレクトリを作成。
[source,c] [source,c]
---- ----
int weechat_mkdir_home (char *directory, int mode); int weechat_mkdir_home (const char *directory, int mode);
---- ----
引数: 引数:
@@ -4525,7 +4525,7 @@ weechat.mkdir_home("${weechat_cache_dir}/temp", 0755)
[source,c] [source,c]
---- ----
int weechat_mkdir (char *directory, int mode); int weechat_mkdir (const char *directory, int mode);
---- ----
引数: 引数:
@@ -4566,7 +4566,7 @@ weechat.mkdir("/tmp/mydir", 0755)
[source,c] [source,c]
---- ----
int weechat_mkdir_parents (char *directory, int mode); int weechat_mkdir_parents (const char *directory, int mode);
---- ----
引数: 引数:
@@ -7816,7 +7816,7 @@ void weechat_config_search_with_string (const char *option_name,
struct t_config_file **config_file, struct t_config_file **config_file,
struct t_config_section **section, struct t_config_section **section,
struct t_config_option **option, struct t_config_option **option,
char **pos_option_name); const char **pos_option_name);
---- ----
引数: 引数:
@@ -7838,7 +7838,7 @@ C 言語での使用例:
struct t_config_file *ptr_config_file; struct t_config_file *ptr_config_file;
struct t_config_section *ptr_section; struct t_config_section *ptr_section;
struct t_config_option *ptr_option; struct t_config_option *ptr_option;
char *option_name; const char *option_name;
weechat_config_search_with_string ("file.section.option", weechat_config_search_with_string ("file.section.option",
&ptr_config_file, &ptr_config_file,
+5 -5
View File
@@ -4209,7 +4209,7 @@ _Ажурирано у верзији 3.2._
[source,c] [source,c]
---- ----
int weechat_mkdir_home (char *directory, int mode); int weechat_mkdir_home (const char *directory, int mode);
---- ----
Аргументи: Аргументи:
@@ -4255,7 +4255,7 @@ weechat.mkdir_home("${weechat_cache_dir}/temp", 0755)
[source,c] [source,c]
---- ----
int weechat_mkdir (char *directory, int mode); int weechat_mkdir (const char *directory, int mode);
---- ----
Аргументи: Аргументи:
@@ -4296,7 +4296,7 @@ weechat.mkdir("/tmp/mydir", 0755)
[source,c] [source,c]
---- ----
int weechat_mkdir_parents (char *directory, int mode); int weechat_mkdir_parents (const char *directory, int mode);
---- ----
Аргументи: Аргументи:
@@ -7492,7 +7492,7 @@ void weechat_config_search_with_string (const char *option_name,
struct t_config_file **config_file, struct t_config_file **config_file,
struct t_config_section **section, struct t_config_section **section,
struct t_config_option **option, struct t_config_option **option,
char **pos_option_name); const char **pos_option_name);
---- ----
Аргументи: Аргументи:
@@ -7510,7 +7510,7 @@ C пример:
struct t_config_file *ptr_config_file; struct t_config_file *ptr_config_file;
struct t_config_section *ptr_section; struct t_config_section *ptr_section;
struct t_config_option *ptr_option; struct t_config_option *ptr_option;
char *option_name; const char *option_name;
weechat_config_search_with_string ("file.section.option", weechat_config_search_with_string ("file.section.option",
&ptr_config_file, &ptr_config_file,
+48
View File
@@ -1181,6 +1181,53 @@ HTTP/1.1 200 OK
] ]
---- ----
// TRANSLATION MISSING
[[resource_scripts]]
=== Scripts
// TRANSLATION MISSING
Return loaded scripts (all languages).
Крајња тачка:
----
GET /api/scripts
----
Пример захтева:
[source,shell]
----
curl -L -u 'plain:secret_password' 'https://localhost:9000/api/scripts'
----
Одговор:
[source,http]
----
HTTP/1.1 200 OK
----
[source,json]
----
[
{
"name": "highmon.pl",
"version": "2.7",
"description": "Highlight Monitor",
"author": "KenjiE20",
"license": "GPL3"
},
{
"name": "go.py",
"version": "3.1.1",
"description": "Quick jump to buffers",
"author": "Sébastien Helleu <flashcode@flashtux.org>",
"license": "GPL3"
}
]
----
[[resource_input]] [[resource_input]]
=== Input === Input
@@ -1510,6 +1557,7 @@ GUID `258EAFA5-E914-47DA-95CA-C5AB0DC85B11` (SHA-1 се кодира у base64).
* `nick_group` (објекат) * `nick_group` (објекат)
* `nick` (објекат) * `nick` (објекат)
* `hotlist` (објекат) * `hotlist` (објекат)
* `scripts` (низ)
* `ping` (објекат) * `ping` (објекат)
[TIP] [TIP]
+5 -1
View File
@@ -23,7 +23,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat\n" "Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-05-30 14:00+0200\n" "POT-Creation-Date: 2026-06-08 22:23+0200\n"
"PO-Revision-Date: 2026-05-30 14:01+0200\n" "PO-Revision-Date: 2026-05-30 14:01+0200\n"
"Last-Translator: Ondřej Súkup <mimi.vx@gmail.com>\n" "Last-Translator: Ondřej Súkup <mimi.vx@gmail.com>\n"
"Language-Team: Czech <weechat-dev@nongnu.org>\n" "Language-Team: Czech <weechat-dev@nongnu.org>\n"
@@ -16068,6 +16068,10 @@ msgstr "načteny %s skripty:"
msgid "script name with extension" msgid "script name with extension"
msgstr "seznam skriptů" msgstr "seznam skriptů"
#, fuzzy
msgid "comma-separated list of plugin:extension with supported languages"
msgstr "čárkami oddělený seznam slovníků, které použít pro tento buffer"
#, fuzzy #, fuzzy
msgid "script name with extension (wildcard \"*\" is allowed) (optional)" msgid "script name with extension (wildcard \"*\" is allowed) (optional)"
msgstr "jméno serveru (zástupný znak \"*\" je povolen) (volitelné)" msgstr "jméno serveru (zástupný znak \"*\" je povolen) (volitelné)"
+7 -2
View File
@@ -29,8 +29,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat\n" "Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-05-30 14:00+0200\n" "POT-Creation-Date: 2026-06-08 22:23+0200\n"
"PO-Revision-Date: 2026-05-30 14:01+0200\n" "PO-Revision-Date: 2026-06-09 10:41+0200\n"
"Last-Translator: Nils Görs <weechatter@arcor.de>\n" "Last-Translator: Nils Görs <weechatter@arcor.de>\n"
"Language-Team: German - Germany <weechat-dev@nongnu.org>\n" "Language-Team: German - Germany <weechat-dev@nongnu.org>\n"
"Language: de\n" "Language: de\n"
@@ -17510,6 +17510,11 @@ msgstr "1 falls Skript geladen wurde"
msgid "script name with extension" msgid "script name with extension"
msgstr "Skriptname mit Erweiterung" msgstr "Skriptname mit Erweiterung"
msgid "comma-separated list of plugin:extension with supported languages"
msgstr ""
"durch Kommata getrennte Liste von Erweiterungen: Endung mit unterstützen "
"Sprachen"
msgid "script name with extension (wildcard \"*\" is allowed) (optional)" msgid "script name with extension (wildcard \"*\" is allowed) (optional)"
msgstr "" msgstr ""
"Name des Skriptes, mit Dateierweiterung (Platzhalter \"*\" kann verwendet " "Name des Skriptes, mit Dateierweiterung (Platzhalter \"*\" kann verwendet "
+6 -1
View File
@@ -24,7 +24,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat\n" "Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-05-30 14:00+0200\n" "POT-Creation-Date: 2026-06-08 22:23+0200\n"
"PO-Revision-Date: 2026-05-30 14:01+0200\n" "PO-Revision-Date: 2026-05-30 14:01+0200\n"
"Last-Translator: Santiago Forero <santiago@forero.xyz>\n" "Last-Translator: Santiago Forero <santiago@forero.xyz>\n"
"Language-Team: Spanish - Spain <weechat-dev@nongnu.org>\n" "Language-Team: Spanish - Spain <weechat-dev@nongnu.org>\n"
@@ -16346,6 +16346,11 @@ msgstr "scripts en %s cargados:"
msgid "script name with extension" msgid "script name with extension"
msgstr "lista de scripts" msgstr "lista de scripts"
#, fuzzy
#| msgid "comma separated list of file name extensions for plugins"
msgid "comma-separated list of plugin:extension with supported languages"
msgstr "lista separada por comas de extensiones de archivo para plugins"
#, fuzzy #, fuzzy
msgid "script name with extension (wildcard \"*\" is allowed) (optional)" msgid "script name with extension (wildcard \"*\" is allowed) (optional)"
msgstr "" msgstr ""
+5 -2
View File
@@ -23,8 +23,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat\n" "Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-05-30 14:00+0200\n" "POT-Creation-Date: 2026-06-08 22:23+0200\n"
"PO-Revision-Date: 2026-05-30 14:01+0200\n" "PO-Revision-Date: 2026-06-08 23:14+0200\n"
"Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n" "Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: French - France <weechat-dev@nongnu.org>\n" "Language-Team: French - France <weechat-dev@nongnu.org>\n"
"Language: fr\n" "Language: fr\n"
@@ -17182,6 +17182,9 @@ msgstr "1 si le script est chargé"
msgid "script name with extension" msgid "script name with extension"
msgstr "nom du script avec l'extension" msgstr "nom du script avec l'extension"
msgid "comma-separated list of plugin:extension with supported languages"
msgstr "liste de extension:extension_fichier avec les langages supportés"
msgid "script name with extension (wildcard \"*\" is allowed) (optional)" msgid "script name with extension (wildcard \"*\" is allowed) (optional)"
msgstr "" msgstr ""
"nom du script avec extension (le caractère joker \"*\" est autorisé) " "nom du script avec extension (le caractère joker \"*\" est autorisé) "
+4 -1
View File
@@ -22,7 +22,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat\n" "Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-05-30 14:00+0200\n" "POT-Creation-Date: 2026-06-08 22:23+0200\n"
"PO-Revision-Date: 2026-03-08 08:59+0100\n" "PO-Revision-Date: 2026-03-08 08:59+0100\n"
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n" "Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
"Language-Team: Hungarian <weechat-dev@nongnu.org>\n" "Language-Team: Hungarian <weechat-dev@nongnu.org>\n"
@@ -15314,6 +15314,9 @@ msgstr "FIFO cső bezárva\n"
msgid "script name with extension" msgid "script name with extension"
msgstr "Aliaszok listája:\n" msgstr "Aliaszok listája:\n"
msgid "comma-separated list of plugin:extension with supported languages"
msgstr ""
msgid "script name with extension (wildcard \"*\" is allowed) (optional)" msgid "script name with extension (wildcard \"*\" is allowed) (optional)"
msgstr "" msgstr ""
+6 -1
View File
@@ -22,7 +22,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat\n" "Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-05-30 14:00+0200\n" "POT-Creation-Date: 2026-06-08 22:23+0200\n"
"PO-Revision-Date: 2026-05-30 14:02+0200\n" "PO-Revision-Date: 2026-05-30 14:02+0200\n"
"Last-Translator: Esteban I. Ruiz Moreno <exio4.com@gmail.com>\n" "Last-Translator: Esteban I. Ruiz Moreno <exio4.com@gmail.com>\n"
"Language-Team: Italian <weechat-dev@nongnu.org>\n" "Language-Team: Italian <weechat-dev@nongnu.org>\n"
@@ -16432,6 +16432,11 @@ msgstr "script %s caricati:"
msgid "script name with extension" msgid "script name with extension"
msgstr "elenco degli script" msgstr "elenco degli script"
#, fuzzy
#| msgid "comma separated list of file name extensions for plugins"
msgid "comma-separated list of plugin:extension with supported languages"
msgstr "elenco separato da virgole di estensioni dei nomi file per i plugin"
#, fuzzy #, fuzzy
msgid "script name with extension (wildcard \"*\" is allowed) (optional)" msgid "script name with extension (wildcard \"*\" is allowed) (optional)"
msgstr "" msgstr ""
+6 -1
View File
@@ -22,7 +22,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat\n" "Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-05-30 14:00+0200\n" "POT-Creation-Date: 2026-06-08 22:23+0200\n"
"PO-Revision-Date: 2026-05-30 14:02+0200\n" "PO-Revision-Date: 2026-05-30 14:02+0200\n"
"Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n" "Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n"
"Language-Team: Japanese <weechat-dev@nongnu.org>\n" "Language-Team: Japanese <weechat-dev@nongnu.org>\n"
@@ -16996,6 +16996,11 @@ msgstr "ロードされた %s スクリプト:"
msgid "script name with extension" msgid "script name with extension"
msgstr "スクリプトの拡張子のリスト" msgstr "スクリプトの拡張子のリスト"
#, fuzzy
#| msgid "comma separated list of file name extensions for plugins"
msgid "comma-separated list of plugin:extension with supported languages"
msgstr "プラグインのファイル拡張子のコンマ区切りリスト"
msgid "script name with extension (wildcard \"*\" is allowed) (optional)" msgid "script name with extension (wildcard \"*\" is allowed) (optional)"
msgstr "" msgstr ""
"拡張子を含めたスクリプト名 (ワイルドカード \"*\" を使うことができます) (任意)" "拡張子を含めたスクリプト名 (ワイルドカード \"*\" を使うことができます) (任意)"
+6 -1
View File
@@ -24,7 +24,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat\n" "Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-05-30 14:00+0200\n" "POT-Creation-Date: 2026-06-08 22:23+0200\n"
"PO-Revision-Date: 2026-05-30 14:02+0200\n" "PO-Revision-Date: 2026-05-30 14:02+0200\n"
"Last-Translator: Krzysztof Korościk <soltys@soltys.info>\n" "Last-Translator: Krzysztof Korościk <soltys@soltys.info>\n"
"Language-Team: Polish <weechat-dev@nongnu.org>\n" "Language-Team: Polish <weechat-dev@nongnu.org>\n"
@@ -16747,6 +16747,11 @@ msgstr "1 jeśli skrypt jest załadowany"
msgid "script name with extension" msgid "script name with extension"
msgstr "nazwa skryptu z rozszerzeniem" msgstr "nazwa skryptu z rozszerzeniem"
#, fuzzy
#| msgid "comma separated list of file name extensions for plugins"
msgid "comma-separated list of plugin:extension with supported languages"
msgstr "oddzielona przecinkami lista rozszerzeń nazw plików dla wtyczek"
msgid "script name with extension (wildcard \"*\" is allowed) (optional)" msgid "script name with extension (wildcard \"*\" is allowed) (optional)"
msgstr "" msgstr ""
"nazwa skryptu z rozszerzeniem (wildcard \"*\" jest dozwolony) (opcjonalne)\"" "nazwa skryptu z rozszerzeniem (wildcard \"*\" jest dozwolony) (opcjonalne)\""
+6 -1
View File
@@ -22,7 +22,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat\n" "Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-05-30 14:00+0200\n" "POT-Creation-Date: 2026-06-08 22:23+0200\n"
"PO-Revision-Date: 2026-05-30 14:02+0200\n" "PO-Revision-Date: 2026-05-30 14:02+0200\n"
"Last-Translator: Vasco Almeida <vascomalmeida@sapo.pt>\n" "Last-Translator: Vasco Almeida <vascomalmeida@sapo.pt>\n"
"Language-Team: Portuguese - Portugal <weechat-dev@nongnu.org>\n" "Language-Team: Portuguese - Portugal <weechat-dev@nongnu.org>\n"
@@ -16869,6 +16869,11 @@ msgstr "scripts %s carregados:"
msgid "script name with extension" msgid "script name with extension"
msgstr "lista de extensões de script" msgstr "lista de extensões de script"
#, fuzzy
#| msgid "comma separated list of file name extensions for plugins"
msgid "comma-separated list of plugin:extension with supported languages"
msgstr "lista de extensões de ficheiros separadas por vírgula para os plugins"
msgid "script name with extension (wildcard \"*\" is allowed) (optional)" msgid "script name with extension (wildcard \"*\" is allowed) (optional)"
msgstr "" msgstr ""
"nome do script com extensão (o caráter universal \"*\" é permitido) " "nome do script com extensão (o caráter universal \"*\" é permitido) "
+5 -1
View File
@@ -46,7 +46,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat\n" "Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-05-30 14:00+0200\n" "POT-Creation-Date: 2026-06-08 22:23+0200\n"
"PO-Revision-Date: 2026-05-30 14:02+0200\n" "PO-Revision-Date: 2026-05-30 14:02+0200\n"
"Last-Translator: Érico Nogueira <ericonr@disroot.org>\n" "Last-Translator: Érico Nogueira <ericonr@disroot.org>\n"
"Language-Team: Portuguese - Brazil <weechat-dev@nongnu.org>\n" "Language-Team: Portuguese - Brazil <weechat-dev@nongnu.org>\n"
@@ -15838,6 +15838,10 @@ msgstr "scripts %s carregados:"
msgid "script name with extension" msgid "script name with extension"
msgstr "list de scripts" msgstr "list de scripts"
#, fuzzy
msgid "comma-separated list of plugin:extension with supported languages"
msgstr "lista de dicionários (separados por vírgula) para uso neste buffer"
#, fuzzy #, fuzzy
msgid "script name with extension (wildcard \"*\" is allowed) (optional)" msgid "script name with extension (wildcard \"*\" is allowed) (optional)"
msgstr "" msgstr ""
+4 -1
View File
@@ -23,7 +23,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat\n" "Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-05-30 14:00+0200\n" "POT-Creation-Date: 2026-06-08 22:23+0200\n"
"PO-Revision-Date: 2026-03-08 08:59+0100\n" "PO-Revision-Date: 2026-03-08 08:59+0100\n"
"Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n" "Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n"
"Language-Team: Russian <weechat-dev@nongnu.org>\n" "Language-Team: Russian <weechat-dev@nongnu.org>\n"
@@ -15367,6 +15367,9 @@ msgstr "FIFO pipe закрыт\n"
msgid "script name with extension" msgid "script name with extension"
msgstr "Список сокращений:\n" msgstr "Список сокращений:\n"
msgid "comma-separated list of plugin:extension with supported languages"
msgstr ""
msgid "script name with extension (wildcard \"*\" is allowed) (optional)" msgid "script name with extension (wildcard \"*\" is allowed) (optional)"
msgstr "" msgstr ""
+6 -1
View File
@@ -22,7 +22,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat\n" "Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-05-30 14:00+0200\n" "POT-Creation-Date: 2026-06-08 22:23+0200\n"
"PO-Revision-Date: 2026-05-30 14:02+0200\n" "PO-Revision-Date: 2026-05-30 14:02+0200\n"
"Last-Translator: Ivan Pešić <ivan.pesic@gmail.com>\n" "Last-Translator: Ivan Pešić <ivan.pesic@gmail.com>\n"
"Language-Team: Serbian <weechat-dev@nongnu.org>\n" "Language-Team: Serbian <weechat-dev@nongnu.org>\n"
@@ -16695,6 +16695,11 @@ msgstr "1 ако је скрипта учитана"
msgid "script name with extension" msgid "script name with extension"
msgstr "име скрипте са екстензијом" msgstr "име скрипте са екстензијом"
#, fuzzy
#| msgid "comma separated list of file name extensions for plugins"
msgid "comma-separated list of plugin:extension with supported languages"
msgstr "листа екстензија имена фајлова за додатке раздвојених запетама"
msgid "script name with extension (wildcard \"*\" is allowed) (optional)" msgid "script name with extension (wildcard \"*\" is allowed) (optional)"
msgstr "име скрипте са екстензијом (дозвољен је џокер „*”) (није обавезно)" msgstr "име скрипте са екстензијом (дозвољен је џокер „*”) (није обавезно)"
+6 -1
View File
@@ -23,7 +23,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat\n" "Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-05-30 14:00+0200\n" "POT-Creation-Date: 2026-06-08 22:23+0200\n"
"PO-Revision-Date: 2026-05-30 14:02+0200\n" "PO-Revision-Date: 2026-05-30 14:02+0200\n"
"Last-Translator: Emir SARI <emir_sari@icloud.com>\n" "Last-Translator: Emir SARI <emir_sari@icloud.com>\n"
"Language-Team: Turkish <weechat-dev@nongnu.org>\n" "Language-Team: Turkish <weechat-dev@nongnu.org>\n"
@@ -17120,6 +17120,11 @@ msgstr "Hiçbir betik yüklenmedi"
msgid "script name with extension" msgid "script name with extension"
msgstr "betik uzantılarının listesi" msgstr "betik uzantılarının listesi"
#, fuzzy
#| msgid "comma separated list of file name extensions for plugins"
msgid "comma-separated list of plugin:extension with supported languages"
msgstr "eklentiler için dosya adı uzantılarının virgülle ayrılmış listesi"
msgid "script name with extension (wildcard \"*\" is allowed) (optional)" msgid "script name with extension (wildcard \"*\" is allowed) (optional)"
msgstr "betik adı, uzantı ile (\"*\" jokerine izin verilir) (isteğe bağlı)" msgstr "betik adı, uzantı ile (\"*\" jokerine izin verilir) (isteğe bağlı)"
+4 -1
View File
@@ -23,7 +23,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat\n" "Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-05-30 14:00+0200\n" "POT-Creation-Date: 2026-06-08 22:23+0200\n"
"PO-Revision-Date: 2014-08-16 10:27+0200\n" "PO-Revision-Date: 2014-08-16 10:27+0200\n"
"Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n" "Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -14018,6 +14018,9 @@ msgstr ""
msgid "script name with extension" msgid "script name with extension"
msgstr "" msgstr ""
msgid "comma-separated list of plugin:extension with supported languages"
msgstr ""
msgid "script name with extension (wildcard \"*\" is allowed) (optional)" msgid "script name with extension (wildcard \"*\" is allowed) (optional)"
msgstr "" msgstr ""
+2 -2
View File
@@ -5536,7 +5536,7 @@ COMMAND_CALLBACK(print)
struct timeval tv_date; struct timeval tv_date;
char *tags, *pos, *text, *text2, empty_string[1] = { '\0' }; char *tags, *pos, *text, *text2, empty_string[1] = { '\0' };
const char *prefix, *ptr_text; const char *prefix, *ptr_text;
long value; long long value;
/* make C compiler happy */ /* make C compiler happy */
(void) pointer; (void) pointer;
@@ -5609,7 +5609,7 @@ COMMAND_CALLBACK(print)
i++; i++;
if ((argv[i][0] == '-') || (argv[i][0] == '+')) if ((argv[i][0] == '-') || (argv[i][0] == '+'))
{ {
if (!util_parse_long (argv[i] + 1, 10, &value)) if (!util_parse_longlong (argv[i] + 1, 10, &value))
COMMAND_ERROR; COMMAND_ERROR;
gettimeofday (&tv_date, NULL); gettimeofday (&tv_date, NULL);
tv_date.tv_sec += (argv[i][0] == '+') ? value : value * -1; tv_date.tv_sec += (argv[i][0] == '+') ? value : value * -1;
+6 -4
View File
@@ -705,7 +705,8 @@ config_file_new_option (struct t_config_file *config_file,
{ {
struct t_config_option *new_option; struct t_config_option *new_option;
int var_type, int_value, argc, i, index_value, number; int var_type, int_value, argc, i, index_value, number;
char *pos, *option_name, *parent_name; const char *pos;
char *option_name, *parent_name;
new_option = NULL; new_option = NULL;
option_name = NULL; option_name = NULL;
@@ -1095,12 +1096,13 @@ config_file_search_with_string (const char *option_name,
struct t_config_file **config_file, struct t_config_file **config_file,
struct t_config_section **section, struct t_config_section **section,
struct t_config_option **option, struct t_config_option **option,
char **pos_option_name) const char **pos_option_name)
{ {
struct t_config_file *ptr_config; struct t_config_file *ptr_config;
struct t_config_section *ptr_section; struct t_config_section *ptr_section;
struct t_config_option *ptr_option; struct t_config_option *ptr_option;
char *file_name, *pos_section, *section_name, *pos_option; const char *pos_section, *pos_option;
char *file_name, *section_name;
if (config_file) if (config_file)
*config_file = NULL; *config_file = NULL;
@@ -2553,7 +2555,7 @@ config_file_option_set_with_string (const char *option_name, const char *value)
struct t_config_file *ptr_config; struct t_config_file *ptr_config;
struct t_config_section *ptr_section; struct t_config_section *ptr_section;
struct t_config_option *ptr_option; struct t_config_option *ptr_option;
char *pos_option; const char *pos_option;
rc = WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND; rc = WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND;
+1 -1
View File
@@ -286,7 +286,7 @@ extern void config_file_search_with_string (const char *option_name,
struct t_config_file **config_file, struct t_config_file **config_file,
struct t_config_section **section, struct t_config_section **section,
struct t_config_option **option, struct t_config_option **option,
char **pos_option_name); const char **pos_option_name);
extern int config_file_string_to_boolean (const char *text); extern int config_file_string_to_boolean (const char *text);
extern int config_file_option_reset (struct t_config_option *option, extern int config_file_option_reset (struct t_config_option *option,
int run_callback); int run_callback);
+10 -6
View File
@@ -1709,7 +1709,7 @@ config_weechat_update_cb (const void *pointer, void *data,
int version_read, int version_read,
struct t_hashtable *data_read) struct t_hashtable *data_read)
{ {
const char *ptr_config, *ptr_section, *ptr_option, *ptr_value; const char *ptr_config, *ptr_section, *ptr_option, *ptr_value, *pos_option;
char *new_commands[][2] = { char *new_commands[][2] = {
/* old command, new command */ /* old command, new command */
{ "/input jump_smart", "/buffer jump smart" }, { "/input jump_smart", "/buffer jump smart" },
@@ -1739,7 +1739,7 @@ config_weechat_update_cb (const void *pointer, void *data,
{ "number_desc" "-buffer.number" }, { "number_desc" "-buffer.number" },
{ NULL, NULL }, { NULL, NULL },
}; };
char *new_option, *new_value, *pos_option; char *new_option, *new_value;
int changes, i; int changes, i;
/* make C compiler happy */ /* make C compiler happy */
@@ -2262,7 +2262,8 @@ config_weechat_proxy_read_cb (const void *pointer, void *data,
struct t_config_section *section, struct t_config_section *section,
const char *option_name, const char *value) const char *option_name, const char *value)
{ {
char *pos_option, *proxy_name; const char *pos_option;
char *proxy_name;
struct t_proxy *ptr_temp_proxy; struct t_proxy *ptr_temp_proxy;
int index_option; int index_option;
@@ -2341,7 +2342,8 @@ config_weechat_bar_read_cb (const void *pointer, void *data,
struct t_config_section *section, struct t_config_section *section,
const char *option_name, const char *value) const char *option_name, const char *value)
{ {
char *pos_option, *bar_name; const char *pos_option;
char *bar_name;
struct t_gui_bar *ptr_temp_bar; struct t_gui_bar *ptr_temp_bar;
int index_option; int index_option;
@@ -2421,7 +2423,8 @@ config_weechat_custom_bar_item_read_cb (const void *pointer, void *data,
struct t_config_section *section, struct t_config_section *section,
const char *option_name, const char *value) const char *option_name, const char *value)
{ {
char *pos_option, *item_name; const char *pos_option;
char *item_name;
struct t_gui_bar_item_custom *ptr_temp_item; struct t_gui_bar_item_custom *ptr_temp_item;
int index_option; int index_option;
@@ -2512,7 +2515,8 @@ config_weechat_layout_read_cb (const void *pointer, void *data,
const char *option_name, const char *value) const char *option_name, const char *value)
{ {
int argc, force_current_layout, number1, number2, number3, number4; int argc, force_current_layout, number1, number2, number3, number4;
char **argv, *pos, *layout_name; const char *pos;
char **argv, *layout_name;
const char *ptr_option_name; const char *ptr_option_name;
struct t_gui_layout *ptr_layout; struct t_gui_layout *ptr_layout;
struct t_gui_layout_window *parent; struct t_gui_layout_window *parent;
+14 -9
View File
@@ -508,7 +508,8 @@ eval_string_repeat (const char *text)
char * char *
eval_string_split (const char *text) eval_string_split (const char *text)
{ {
char *pos, *pos2, *pos3, *str_number, *separators, **items, *value; const char *pos, *pos2, *pos3;
char *str_number, *separators, **items, *value;
char str_value[32], *str_flags, **list_flags, *strip_items, **ptr_flag; char str_value[32], *str_flags, **list_flags, *strip_items, **ptr_flag;
int num_items, count_items, random_item, flags, max_items; int num_items, count_items, random_item, flags, max_items;
long number; long number;
@@ -655,7 +656,8 @@ end:
char * char *
eval_string_split_shell (const char *text) eval_string_split_shell (const char *text)
{ {
char *pos, *str_number, **items, *value, str_value[32]; const char *pos;
char *str_number, **items, *value, str_value[32];
int num_items, count_items, random_item; int num_items, count_items, random_item;
long number; long number;
@@ -1046,7 +1048,8 @@ eval_string_if (const char *text, struct t_eval_context *eval_context)
char * char *
eval_string_random (const char *text) eval_string_random (const char *text)
{ {
char *pos, *tmp, result[128]; const char *pos;
char *tmp, result[128];
long long min_number, max_number; long long min_number, max_number;
if (!text || !text[0]) if (!text || !text[0])
@@ -1112,7 +1115,8 @@ eval_string_translate (const char *text)
void void
eval_string_define (const char *text, struct t_eval_context *eval_context) eval_string_define (const char *text, struct t_eval_context *eval_context)
{ {
char *pos, *name; const char *pos;
char *name;
pos = strchr (text, ','); pos = strchr (text, ',');
if (!pos) if (!pos)
@@ -1139,7 +1143,8 @@ eval_hdata_count (const char *text, struct t_eval_context *eval_context)
struct t_hdata *hdata; struct t_hdata *hdata;
unsigned long ptr_value; unsigned long ptr_value;
void *pointer; void *pointer;
char *pos1, *pos2, *value, *hdata_name, *pointer_name, str_count[64]; const char *pos1, *pos2;
char *value, *hdata_name, *pointer_name, str_count[64];
int rc, count; int rc, count;
value = NULL; value = NULL;
@@ -1211,8 +1216,8 @@ char *
eval_hdata_get_value (struct t_hdata *hdata, void *pointer, const char *path, eval_hdata_get_value (struct t_hdata *hdata, void *pointer, const char *path,
struct t_eval_context *eval_context) struct t_eval_context *eval_context)
{ {
char *value, *var_name, str_value[128], *pos, *property; char *value, *var_name, str_value[128], *property;
const char *ptr_value, *hdata_name, *ptr_var_name, *pos_open_paren; const char *ptr_value, *hdata_name, *ptr_var_name, *pos, *pos_open_paren;
int type, debug_id; int type, debug_id;
struct t_hashtable *hashtable; struct t_hashtable *hashtable;
@@ -1539,8 +1544,8 @@ eval_syntax_highlight_add_markers (const char *prefix, const char *text,
char * char *
eval_syntax_highlight_colorize (const char *value) eval_syntax_highlight_colorize (const char *value)
{ {
const char *ptr_value; const char *ptr_value, *pos;
char **result, *pos; char **result;
int color; int color;
if (!value) if (!value)
+4 -3
View File
@@ -688,7 +688,8 @@ hdata_count (struct t_hdata *hdata, void *pointer)
void void
hdata_get_index_and_name (const char *name, int *index, const char **ptr_name) hdata_get_index_and_name (const char *name, int *index, const char **ptr_name)
{ {
char *pos, *str_index; const char *pos;
char *str_index;
int number; int number;
if (index) if (index)
@@ -1312,9 +1313,9 @@ hdata_set (struct t_hdata *hdata, void *pointer, const char *name,
} }
break; break;
case WEECHAT_HDATA_TIME: case WEECHAT_HDATA_TIME:
if (util_parse_long (value, 10, &number_long) && (number_long >= 0)) if (util_parse_longlong (value, 10, &number_longlong) && (number_longlong >= 0))
{ {
*((time_t *)(pointer + var->offset)) = (time_t)number_long; *((time_t *)(pointer + var->offset)) = (time_t)number_longlong;
return 1; return 1;
} }
break; break;
+8 -3
View File
@@ -242,8 +242,8 @@ int
input_data (struct t_gui_buffer *buffer, const char *data, input_data (struct t_gui_buffer *buffer, const char *data,
const char *commands_allowed, int split_newline, int user_data) const char *commands_allowed, int split_newline, int user_data)
{ {
char *pos, str_buffer[128], *new_data, *buffer_full_name; const char *ptr_data_for_buffer;
const char *ptr_data, *ptr_data_for_buffer; char *pos, str_buffer[128], *new_data, *buffer_full_name, *ptr_data;
int first_command, rc; int first_command, rc;
if (!buffer || !gui_buffer_valid (buffer) || !data) if (!buffer || !gui_buffer_valid (buffer) || !data)
@@ -272,8 +272,13 @@ input_data (struct t_gui_buffer *buffer, const char *data,
if (data[0] && new_data && !new_data[0]) if (data[0] && new_data && !new_data[0])
goto end; goto end;
if (!new_data)
new_data = strdup (data);
if (!new_data)
goto end;
first_command = 1; first_command = 1;
ptr_data = (new_data) ? new_data : data; ptr_data = new_data;
while (ptr_data) while (ptr_data)
{ {
/* /*
+19 -1
View File
@@ -582,7 +582,13 @@ network_pass_socks5proxy (struct t_proxy *proxy, int sock, const char *address,
int port) int port)
{ {
struct t_network_socks5 socks5; struct t_network_socks5 socks5;
unsigned char buffer[288]; /*
* buffer must be large enough for the username/password authentication
* request, which is the longest message sent/received here; according to
* RFC 1929 it is: version (1) + username length (1) + username (max 255)
* + password length (1) + password (max 255)
*/
unsigned char buffer[2 + 255 + 1 + 255];
int username_len, password_len, addr_len, addr_buffer_len; int username_len, password_len, addr_len, addr_buffer_len;
unsigned char *addr_buffer; unsigned char *addr_buffer;
char *username, *password; char *username, *password;
@@ -631,6 +637,18 @@ network_pass_socks5proxy (struct t_proxy *proxy, int sock, const char *address,
username_len = strlen (username); username_len = strlen (username);
password_len = strlen (password); password_len = strlen (password);
/*
* username and password length are each stored on a single byte
* (RFC 1929), so they cannot exceed 255 bytes: reject longer values,
* otherwise the memcpy calls below would overflow the buffer
*/
if ((username_len > 255) || (password_len > 255))
{
free (username);
free (password);
return 0;
}
/* make username/password buffer */ /* make username/password buffer */
buffer[0] = 1; buffer[0] = 1;
buffer[1] = (unsigned char) username_len; buffer[1] = (unsigned char) username_len;
+6 -6
View File
@@ -1686,9 +1686,8 @@ string_mask_to_regex (const char *mask)
const char * const char *
string_regex_flags (const char *regex, int default_flags, int *flags) string_regex_flags (const char *regex, int default_flags, int *flags)
{ {
const char *ptr_regex, *ptr_flags; const char *ptr_regex, *ptr_flags, *pos;
int set_flag, flag; int set_flag, flag;
char *pos;
if (flags) if (flags)
*flags = default_flags; *flags = default_flags;
@@ -2966,8 +2965,9 @@ char **
string_split_command (const char *command, char separator) string_split_command (const char *command, char separator)
{ {
int nb_substr, arr_idx, str_idx, type; int nb_substr, arr_idx, str_idx, type;
const char *p;
char **array, **array2; char **array, **array2;
char *buffer, *p; char *buffer;
const char *ptr; const char *ptr;
if (!command || !command[0]) if (!command || !command[0])
@@ -4138,8 +4138,7 @@ string_is_command_char (const char *string)
const char * const char *
string_input_for_buffer (const char *string) string_input_for_buffer (const char *string)
{ {
char *pos_slash, *pos_space, *pos_newline; const char *pos_slash, *pos_space, *pos_newline, *next_char;
const char *next_char;
if (!string) if (!string)
return NULL; return NULL;
@@ -4476,7 +4475,8 @@ string_get_priority_and_name (const char *string,
int *priority, const char **name, int *priority, const char **name,
int default_priority) int default_priority)
{ {
char *pos, *str_priority; const char *pos;
char *str_priority;
int number; int number;
if (priority) if (priority)
+2 -2
View File
@@ -416,8 +416,8 @@ util_strftimeval (char *string, int max, const char *format, struct timeval *tv)
int int
util_parse_time (const char *datetime, struct timeval *tv) util_parse_time (const char *datetime, struct timeval *tv)
{ {
char *string, *pos, *pos2, *pos_colon, *pos_hyphen, *pos_dot; const char *pos_colon, *pos_hyphen, *pos_dot;
char str_usec[16], str_date[128]; char *pos, *pos2, *string, str_usec[16], str_date[128];
struct tm tm_date, tm_date_gm, tm_date_local, *local_time; struct tm tm_date, tm_date_gm, tm_date_local, *local_time;
time_t time_now, time_gm, time_local; time_t time_now, time_gm, time_local;
long long value; long long value;
+2 -2
View File
@@ -597,8 +597,8 @@ hook_command_exec (struct t_gui_buffer *buffer, int any_plugin,
struct t_hook *hook_plugin, *hook_other_plugin, *hook_other_plugin2; struct t_hook *hook_plugin, *hook_other_plugin, *hook_other_plugin2;
struct t_hook *hook_incomplete_command; struct t_hook *hook_incomplete_command;
struct t_hook_exec_cb hook_exec_cb; struct t_hook_exec_cb hook_exec_cb;
char **argv, **argv_eol, *command_name, *pos; char **argv, **argv_eol, *command_name;
const char *ptr_string; const char *ptr_string, *pos;
int argc, rc, length_command_name, allow_incomplete_commands; int argc, rc, length_command_name, allow_incomplete_commands;
int count_other_plugin, count_incomplete_commands, flags; int count_other_plugin, count_incomplete_commands, flags;
+2 -1
View File
@@ -132,7 +132,8 @@ void
hook_signal_extract_flags (const char *signal, const char **ptr_signal, hook_signal_extract_flags (const char *signal, const char **ptr_signal,
int *stop_on_error, int *ignore_eat) int *stop_on_error, int *ignore_eat)
{ {
char *pos, *str_flags, **flags; const char *pos;
char *str_flags, **flags;
int i, num_flags; int i, num_flags;
if (!signal || !ptr_signal || !stop_on_error || !ignore_eat) if (!signal || !ptr_signal || !stop_on_error || !ignore_eat)
+4 -3
View File
@@ -47,7 +47,7 @@ void
daemonize (void) daemonize (void)
{ {
pid_t pid; pid_t pid;
int fd, i; int fd, i, rc;
printf ("%s ", _("Running WeeChat in background...")); printf ("%s ", _("Running WeeChat in background..."));
@@ -77,8 +77,9 @@ daemonize (void)
close (i); close (i);
} }
fd = open ("/dev/null", O_RDWR); fd = open ("/dev/null", O_RDWR);
(void) dup (fd); rc = dup (fd);
(void) dup (fd); rc = dup (fd);
(void) rc;
} }
/* /*
+2 -1
View File
@@ -138,7 +138,8 @@ gui_bar_item_custom_search (const char *item_name)
struct t_gui_bar_item_custom * struct t_gui_bar_item_custom *
gui_bar_item_custom_search_with_option_name (const char *option_name) gui_bar_item_custom_search_with_option_name (const char *option_name)
{ {
char *item_name, *pos_option; const char *pos_option;
char *item_name;
struct t_gui_bar_item_custom *ptr_item; struct t_gui_bar_item_custom *ptr_item;
if (!option_name) if (!option_name)
+9 -9
View File
@@ -1880,9 +1880,9 @@ gui_bar_item_buffer_nicklist_cb (const void *pointer, void *data,
{ {
if (strchr (ptr_nick->prefix_color, '.')) if (strchr (ptr_nick->prefix_color, '.'))
{ {
config_file_search_with_string (ptr_nick->prefix_color, config_file_search_with_string (
NULL, NULL, &ptr_option, ptr_nick->prefix_color,
NULL); NULL, NULL, &ptr_option, NULL);
if (ptr_option) if (ptr_option)
{ {
string_dyn_concat ( string_dyn_concat (
@@ -1907,9 +1907,9 @@ gui_bar_item_buffer_nicklist_cb (const void *pointer, void *data,
{ {
if (strchr (ptr_nick->color, '.')) if (strchr (ptr_nick->color, '.'))
{ {
config_file_search_with_string (ptr_nick->color, config_file_search_with_string (
NULL, NULL, &ptr_option, ptr_nick->color,
NULL); NULL, NULL, &ptr_option, NULL);
if (ptr_option) if (ptr_option)
{ {
string_dyn_concat ( string_dyn_concat (
@@ -1940,9 +1940,9 @@ gui_bar_item_buffer_nicklist_cb (const void *pointer, void *data,
{ {
if (strchr (ptr_group->color, '.')) if (strchr (ptr_group->color, '.'))
{ {
config_file_search_with_string (ptr_group->color, config_file_search_with_string (
NULL, NULL, &ptr_option, ptr_group->color,
NULL); NULL, NULL, &ptr_option, NULL);
if (ptr_option) if (ptr_option)
{ {
string_dyn_concat ( string_dyn_concat (
+2 -1
View File
@@ -515,7 +515,8 @@ gui_bar_search (const char *name)
struct t_gui_bar * struct t_gui_bar *
gui_bar_search_with_option_name (const char *option_name) gui_bar_search_with_option_name (const char *option_name)
{ {
char *bar_name, *pos_option; const char *pos_option;
char *bar_name;
struct t_gui_bar *ptr_bar; struct t_gui_bar *ptr_bar;
if (!option_name) if (!option_name)
+39 -98
View File
@@ -1764,17 +1764,13 @@ void
gui_buffer_set_notify (struct t_gui_buffer *buffer, const char *notify) gui_buffer_set_notify (struct t_gui_buffer *buffer, const char *notify)
{ {
const char *ptr_notify; const char *ptr_notify;
char *error; int mute_old, number;
long number;
int mute_old;
if (!buffer) if (!buffer)
return; return;
ptr_notify = NULL; ptr_notify = NULL;
error = NULL; if (util_parse_int (notify, 10, &number))
number = strtol (notify, &error, 10);
if (error && !error[0])
{ {
if (number < GUI_BUFFER_NUM_NOTIFY) if (number < GUI_BUFFER_NUM_NOTIFY)
{ {
@@ -2232,9 +2228,8 @@ void
gui_buffer_set_hotlist_max_level_nicks (struct t_gui_buffer *buffer, gui_buffer_set_hotlist_max_level_nicks (struct t_gui_buffer *buffer,
const char *new_hotlist_max_level_nicks) const char *new_hotlist_max_level_nicks)
{ {
char **nicks, *pos, *error; char **nicks, *pos;
int nicks_count, value, i; int nicks_count, number, value, i;
long number;
if (!buffer) if (!buffer)
return; return;
@@ -2260,13 +2255,10 @@ gui_buffer_set_hotlist_max_level_nicks (struct t_gui_buffer *buffer,
{ {
pos[0] = '\0'; pos[0] = '\0';
pos++; pos++;
error = NULL; if (util_parse_int (pos, 10, &number))
number = strtol (pos, &error, 10); value = number;
if (error && !error[0])
value = (int)number;
} }
hashtable_set (buffer->hotlist_max_level_nicks, nicks[i], hashtable_set (buffer->hotlist_max_level_nicks, nicks[i], &value);
&value);
} }
string_free_split (nicks); string_free_split (nicks);
} }
@@ -2279,9 +2271,8 @@ void
gui_buffer_add_hotlist_max_level_nicks (struct t_gui_buffer *buffer, gui_buffer_add_hotlist_max_level_nicks (struct t_gui_buffer *buffer,
const char *nicks_to_add) const char *nicks_to_add)
{ {
char **nicks, *pos, *error; char **nicks, *pos;
int nicks_count, value, i; int nicks_count, number, value, i;
long number;
if (!buffer || !nicks_to_add) if (!buffer || !nicks_to_add)
return; return;
@@ -2302,13 +2293,10 @@ gui_buffer_add_hotlist_max_level_nicks (struct t_gui_buffer *buffer,
{ {
pos[0] = '\0'; pos[0] = '\0';
pos++; pos++;
error = NULL; if (util_parse_int (pos, 10, &number))
number = strtol (pos, &error, 10); value = number;
if (error && !error[0])
value = (int)number;
} }
hashtable_set (buffer->hotlist_max_level_nicks, nicks[i], hashtable_set (buffer->hotlist_max_level_nicks, nicks[i], &value);
&value);
} }
string_free_split (nicks); string_free_split (nicks);
} }
@@ -2454,9 +2442,7 @@ void
gui_buffer_set_unread (struct t_gui_buffer *buffer, const char *argument) gui_buffer_set_unread (struct t_gui_buffer *buffer, const char *argument)
{ {
struct t_gui_line *old_last_read_line; struct t_gui_line *old_last_read_line;
int i, old_first_line_not_read; int i, number, old_first_line_not_read;
long number;
char *error;
if (!buffer || (buffer->type != GUI_BUFFER_TYPE_FORMATTED)) if (!buffer || (buffer->type != GUI_BUFFER_TYPE_FORMATTED))
return; return;
@@ -2479,9 +2465,7 @@ gui_buffer_set_unread (struct t_gui_buffer *buffer, const char *argument)
else if (argument[0] == '-') else if (argument[0] == '-')
{ {
/* move the unread marker N lines towards the first line */ /* move the unread marker N lines towards the first line */
error = NULL; if (util_parse_int (argument, 10, &number) && (number < 0))
number = strtol (argument, &error, 10);
if (error && !error[0] && (number < 0))
{ {
for (i = 0; i > number; i--) for (i = 0; i > number; i--)
{ {
@@ -2507,9 +2491,7 @@ gui_buffer_set_unread (struct t_gui_buffer *buffer, const char *argument)
else if (argument[0] == '+') else if (argument[0] == '+')
{ {
/* move the unread marker N lines towards the last line */ /* move the unread marker N lines towards the last line */
error = NULL; if (util_parse_int (argument, 10, &number) && (number > 0))
number = strtol (argument, &error, 10);
if (error && !error[0] && (number > 0))
{ {
for (i = 0; i < number; i++) for (i = 0; i < number; i++)
{ {
@@ -2533,9 +2515,7 @@ gui_buffer_set_unread (struct t_gui_buffer *buffer, const char *argument)
else else
{ {
/* move the unread marker N lines from the end towards the first line */ /* move the unread marker N lines from the end towards the first line */
error = NULL; if (util_parse_int (argument, 10, &number) && (number > 0))
number = strtol (argument, &error, 10);
if (error && !error[0] && (number > 0))
{ {
buffer->lines->last_read_line = buffer->lines->last_line; buffer->lines->last_read_line = buffer->lines->last_line;
buffer->lines->first_line_not_read = 0; buffer->lines->first_line_not_read = 0;
@@ -2569,8 +2549,7 @@ void
gui_buffer_set (struct t_gui_buffer *buffer, const char *property, gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
const char *value) const char *value)
{ {
long number; int number;
char *error;
if (!property || !value) if (!property || !value)
return; return;
@@ -2584,9 +2563,7 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
gui_add_hotlist = 1; gui_add_hotlist = 1;
else if (buffer) else if (buffer)
{ {
error = NULL; if (util_parse_int (value, 10, &number))
number = strtol (value, &error, 10);
if (error && !error[0])
{ {
if (number < 0) if (number < 0)
{ {
@@ -2614,9 +2591,7 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
/* properties that need a buffer */ /* properties that need a buffer */
if (strcmp (property, "hotlist_conditions") == 0) if (strcmp (property, "hotlist_conditions") == 0)
{ {
error = NULL; if (util_parse_int (value, 10, &number))
number = strtol (value, &error, 10);
if (error && !error[0])
{ {
if (number < 0) if (number < 0)
{ {
@@ -2650,9 +2625,7 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
} }
else if (strcmp (property, "hidden") == 0) else if (strcmp (property, "hidden") == 0)
{ {
error = NULL; if (util_parse_int (value, 10, &number))
number = strtol (value, &error, 10);
if (error && !error[0])
{ {
if (number) if (number)
gui_buffer_hide (buffer); gui_buffer_hide (buffer);
@@ -2662,37 +2635,27 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
} }
else if (strcmp (property, "print_hooks_enabled") == 0) else if (strcmp (property, "print_hooks_enabled") == 0)
{ {
error = NULL; if (util_parse_int (value, 10, &number))
number = strtol (value, &error, 10);
if (error && !error[0])
buffer->print_hooks_enabled = (number) ? 1 : 0; buffer->print_hooks_enabled = (number) ? 1 : 0;
} }
else if (strcmp (property, "day_change") == 0) else if (strcmp (property, "day_change") == 0)
{ {
error = NULL; if (util_parse_int (value, 10, &number))
number = strtol (value, &error, 10);
if (error && !error[0])
gui_buffer_set_day_change (buffer, number); gui_buffer_set_day_change (buffer, number);
} }
else if (strcmp (property, "clear") == 0) else if (strcmp (property, "clear") == 0)
{ {
error = NULL; if (util_parse_int (value, 10, &number))
number = strtol (value, &error, 10);
if (error && !error[0])
buffer->clear = (number) ? 1 : 0; buffer->clear = (number) ? 1 : 0;
} }
else if (strcmp (property, "filter") == 0) else if (strcmp (property, "filter") == 0)
{ {
error = NULL; if (util_parse_int (value, 10, &number))
number = strtol (value, &error, 10);
if (error && !error[0])
gui_buffer_set_filter (buffer, number); gui_buffer_set_filter (buffer, number);
} }
else if (strcmp (property, "number") == 0) else if (strcmp (property, "number") == 0)
{ {
error = NULL; if (util_parse_int (value, 10, &number) && (number >= 1))
number = strtol (value, &error, 10);
if (error && !error[0] && (number >= 1))
gui_buffer_move_to_number (buffer, number); gui_buffer_move_to_number (buffer, number);
} }
else if (strcmp (property, "name") == 0) else if (strcmp (property, "name") == 0)
@@ -2724,30 +2687,22 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
} }
else if (strcmp (property, "time_for_each_line") == 0) else if (strcmp (property, "time_for_each_line") == 0)
{ {
error = NULL; if (util_parse_int (value, 10, &number))
number = strtol (value, &error, 10);
if (error && !error[0])
gui_buffer_set_time_for_each_line (buffer, number); gui_buffer_set_time_for_each_line (buffer, number);
} }
else if (strcmp (property, "nicklist") == 0) else if (strcmp (property, "nicklist") == 0)
{ {
error = NULL; if (util_parse_int (value, 10, &number))
number = strtol (value, &error, 10);
if (error && !error[0])
gui_buffer_set_nicklist (buffer, number); gui_buffer_set_nicklist (buffer, number);
} }
else if (strcmp (property, "nicklist_case_sensitive") == 0) else if (strcmp (property, "nicklist_case_sensitive") == 0)
{ {
error = NULL; if (util_parse_int (value, 10, &number))
number = strtol (value, &error, 10);
if (error && !error[0])
gui_buffer_set_nicklist_case_sensitive (buffer, number); gui_buffer_set_nicklist_case_sensitive (buffer, number);
} }
else if (strcmp (property, "nicklist_display_groups") == 0) else if (strcmp (property, "nicklist_display_groups") == 0)
{ {
error = NULL; if (util_parse_int (value, 10, &number))
number = strtol (value, &error, 10);
if (error && !error[0])
gui_buffer_set_nicklist_display_groups (buffer, number); gui_buffer_set_nicklist_display_groups (buffer, number);
} }
else if (strcmp (property, "highlight_words") == 0) else if (strcmp (property, "highlight_words") == 0)
@@ -2816,37 +2771,27 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
} }
else if (strcmp (property, "input_pos") == 0) else if (strcmp (property, "input_pos") == 0)
{ {
error = NULL; if (util_parse_int (value, 10, &number))
number = strtol (value, &error, 10);
if (error && !error[0])
gui_input_set_pos (buffer, number); gui_input_set_pos (buffer, number);
} }
else if (strcmp (property, "input_get_any_user_data") == 0) else if (strcmp (property, "input_get_any_user_data") == 0)
{ {
error = NULL; if (util_parse_int (value, 10, &number))
number = strtol (value, &error, 10);
if (error && !error[0])
gui_buffer_set_input_get_any_user_data (buffer, number); gui_buffer_set_input_get_any_user_data (buffer, number);
} }
else if (strcmp (property, "input_get_unknown_commands") == 0) else if (strcmp (property, "input_get_unknown_commands") == 0)
{ {
error = NULL; if (util_parse_int (value, 10, &number))
number = strtol (value, &error, 10);
if (error && !error[0])
gui_buffer_set_input_get_unknown_commands (buffer, number); gui_buffer_set_input_get_unknown_commands (buffer, number);
} }
else if (strcmp (property, "input_get_empty") == 0) else if (strcmp (property, "input_get_empty") == 0)
{ {
error = NULL; if (util_parse_int (value, 10, &number))
number = strtol (value, &error, 10);
if (error && !error[0])
gui_buffer_set_input_get_empty (buffer, number); gui_buffer_set_input_get_empty (buffer, number);
} }
else if (strcmp (property, "input_multiline") == 0) else if (strcmp (property, "input_multiline") == 0)
{ {
error = NULL; if (util_parse_int (value, 10, &number))
number = strtol (value, &error, 10);
if (error && !error[0])
gui_buffer_set_input_multiline (buffer, number); gui_buffer_set_input_multiline (buffer, number);
} }
else if (strncmp (property, "localvar_set_", 13) == 0) else if (strncmp (property, "localvar_set_", 13) == 0)
@@ -3076,7 +3021,6 @@ gui_buffer_search (const char *plugin, const char *name)
struct t_gui_buffer *ptr_buffer; struct t_gui_buffer *ptr_buffer;
int plugin_match, plugin_case_sensitive, name_case_sensitive; int plugin_match, plugin_case_sensitive, name_case_sensitive;
long long id; long long id;
char *error;
if (!name || !name[0]) if (!name || !name[0])
return gui_current_window->buffer; return gui_current_window->buffer;
@@ -3086,9 +3030,9 @@ gui_buffer_search (const char *plugin, const char *name)
if (plugin && (strcmp (plugin, "==id") == 0)) if (plugin && (strcmp (plugin, "==id") == 0))
{ {
error = NULL; if (util_parse_longlong (name, 10, &id))
id = strtoll (name, &error, 10); return gui_buffer_search_by_id (id);
return (error && !error[0]) ? gui_buffer_search_by_id (id) : NULL; return NULL;
} }
plugin_case_sensitive = 1; plugin_case_sensitive = 1;
@@ -3317,16 +3261,13 @@ gui_buffer_search_by_id_number_name (const char *string)
{ {
struct t_gui_buffer *ptr_buffer; struct t_gui_buffer *ptr_buffer;
long long number; long long number;
char *error;
if (!string) if (!string || !string[0])
return NULL; return NULL;
ptr_buffer = NULL; ptr_buffer = NULL;
error = NULL; if (util_parse_longlong (string, 10, &number))
number = strtoll (string, &error, 10);
if (error && !error[0])
{ {
ptr_buffer = gui_buffer_search_by_id (number); ptr_buffer = gui_buffer_search_by_id (number);
if (!ptr_buffer) if (!ptr_buffer)
+5 -9
View File
@@ -118,8 +118,8 @@ gui_chat_init (void)
void void
gui_chat_prefix_build (void) gui_chat_prefix_build (void)
{ {
const char *ptr_prefix; const char *ptr_prefix, *pos_color;
char prefix[512], *pos_color; char prefix[512];
int prefix_color[GUI_CHAT_NUM_PREFIXES] = int prefix_color[GUI_CHAT_NUM_PREFIXES] =
{ GUI_COLOR_CHAT_PREFIX_ERROR, GUI_COLOR_CHAT_PREFIX_NETWORK, { GUI_COLOR_CHAT_PREFIX_ERROR, GUI_COLOR_CHAT_PREFIX_NETWORK,
GUI_COLOR_CHAT_PREFIX_ACTION, GUI_COLOR_CHAT_PREFIX_JOIN, GUI_COLOR_CHAT_PREFIX_ACTION, GUI_COLOR_CHAT_PREFIX_JOIN,
@@ -1400,7 +1400,7 @@ gui_chat_hsignal_quote_line_cb (const void *pointer, void *data,
struct timeval tv; struct timeval tv;
struct t_gui_line *ptr_line; struct t_gui_line *ptr_line;
int is_nick, rc; int is_nick, rc;
char str_time[128], *str, *error; char str_time[128], *str;
/* make C compiler happy */ /* make C compiler happy */
(void) pointer; (void) pointer;
@@ -1415,9 +1415,7 @@ gui_chat_hsignal_quote_line_cb (const void *pointer, void *data,
hashtable_get (hashtable, "_chat_line_date") : NULL; hashtable_get (hashtable, "_chat_line_date") : NULL;
if (ptr_date) if (ptr_date)
{ {
error = NULL; if (util_parse_longlong (ptr_date, 10, &number))
number = strtoll (ptr_date, &error, 10);
if (error && !error[0])
{ {
tv.tv_sec = (time_t)number; tv.tv_sec = (time_t)number;
tv.tv_usec = 0; tv.tv_usec = 0;
@@ -1425,9 +1423,7 @@ gui_chat_hsignal_quote_line_cb (const void *pointer, void *data,
hashtable_get (hashtable, "_chat_line_date_usec") : NULL; hashtable_get (hashtable, "_chat_line_date_usec") : NULL;
if (ptr_date_usec) if (ptr_date_usec)
{ {
error = NULL; if (util_parse_longlong (ptr_date_usec, 10, &number))
number = strtoll (ptr_date_usec, &error, 10);
if (error && !error[0])
tv.tv_usec = (long)number; tv.tv_usec = (long)number;
} }
util_strftimeval (str_time, sizeof (str_time), util_strftimeval (str_time, sizeof (str_time),
+17 -41
View File
@@ -41,6 +41,7 @@
#include "../core/core-list.h" #include "../core/core-list.h"
#include "../core/core-string.h" #include "../core/core-string.h"
#include "../core/core-utf8.h" #include "../core/core-utf8.h"
#include "../core/core-util.h"
#include "../plugins/plugin.h" #include "../plugins/plugin.h"
#include "gui-color.h" #include "gui-color.h"
#include "gui-chat.h" #include "gui-chat.h"
@@ -170,8 +171,7 @@ gui_color_search_config (const char *color_name)
/* search in any configuration file (example: "irc.color.message_quit") */ /* search in any configuration file (example: "irc.color.message_quit") */
if (strchr (color_name, '.')) if (strchr (color_name, '.'))
{ {
config_file_search_with_string (color_name, NULL, NULL, &ptr_option, config_file_search_with_string (color_name, NULL, NULL, &ptr_option, NULL);
NULL);
if (ptr_option) if (ptr_option)
return gui_color_from_option (ptr_option); return gui_color_from_option (ptr_option);
} }
@@ -255,8 +255,8 @@ gui_color_get_custom (const char *color_name)
static char color[32][96]; static char color[32][96];
static int index_color = 0; static int index_color = 0;
char color_fg[32], color_bg[32]; char color_fg[32], color_bg[32];
char *pos_delim, *str_fg, *pos_bg, *error, *color_attr; char *str_fg, *color_attr;
const char *ptr_color_name; const char *ptr_color_name, *pos_delim, *pos_bg;
/* attribute or other color name (GUI dependent) */ /* attribute or other color name (GUI dependent) */
index_color = (index_color + 1) % 32; index_color = (index_color + 1) % 32;
@@ -439,9 +439,7 @@ gui_color_get_custom (const char *color_name)
fg_term = gui_color_palette_get_alias (str_fg); fg_term = gui_color_palette_get_alias (str_fg);
if (fg_term < 0) if (fg_term < 0)
{ {
error = NULL; if (util_parse_int (str_fg, 10, &term_color))
term_color = (int)strtol (str_fg, &error, 10);
if (error && !error[0])
{ {
fg_term = term_color; fg_term = term_color;
if (fg_term < 0) if (fg_term < 0)
@@ -458,9 +456,7 @@ gui_color_get_custom (const char *color_name)
bg_term = gui_color_palette_get_alias (pos_bg); bg_term = gui_color_palette_get_alias (pos_bg);
if (bg_term < 0) if (bg_term < 0)
{ {
error = NULL; if (util_parse_int (pos_bg, 10, &term_color))
term_color = (int)strtol (pos_bg, &error, 10);
if (error && !error[0])
{ {
bg_term = term_color; bg_term = term_color;
if (bg_term < 0) if (bg_term < 0)
@@ -1287,7 +1283,7 @@ char *
gui_color_encode_ansi (const char *string) gui_color_encode_ansi (const char *string)
{ {
const unsigned char *ptr_string; const unsigned char *ptr_string;
char **out, str_concat[128], str_color[8], *error; char **out, str_concat[128], str_color[8];
int flag, color, length, ansi_color, fg, bg, attrs; int flag, color, length, ansi_color, fg, bg, attrs;
if (!string) if (!string)
@@ -1321,9 +1317,7 @@ gui_color_encode_ansi (const char *string)
{ {
memcpy (str_color, ptr_string, 5); memcpy (str_color, ptr_string, 5);
str_color[5] = '\0'; str_color[5] = '\0';
error = NULL; if (util_parse_int (str_color, 10, &color))
color = (int)strtol (str_color, &error, 10);
if (error && !error[0])
{ {
snprintf (str_concat, sizeof (str_concat), snprintf (str_concat, sizeof (str_concat),
"\x1B[38;5;%dm", "\x1B[38;5;%dm",
@@ -1344,9 +1338,7 @@ gui_color_encode_ansi (const char *string)
{ {
memcpy (str_color, ptr_string, 2); memcpy (str_color, ptr_string, 2);
str_color[2] = '\0'; str_color[2] = '\0';
error = NULL; if (util_parse_int (str_color, 10, &color))
color = (int)strtol (str_color, &error, 10);
if (error && !error[0])
{ {
ansi_color = gui_color_weechat_to_ansi (color); ansi_color = gui_color_weechat_to_ansi (color);
snprintf (str_concat, sizeof (str_concat), snprintf (str_concat, sizeof (str_concat),
@@ -1371,9 +1363,7 @@ gui_color_encode_ansi (const char *string)
{ {
memcpy (str_color, ptr_string, 5); memcpy (str_color, ptr_string, 5);
str_color[5] = '\0'; str_color[5] = '\0';
error = NULL; if (util_parse_int (str_color, 10, &color))
color = (int)strtol (str_color, &error, 10);
if (error && !error[0])
{ {
snprintf (str_concat, sizeof (str_concat), snprintf (str_concat, sizeof (str_concat),
"\x1B[48;5;%dm", "\x1B[48;5;%dm",
@@ -1389,9 +1379,7 @@ gui_color_encode_ansi (const char *string)
{ {
memcpy (str_color, ptr_string, 2); memcpy (str_color, ptr_string, 2);
str_color[2] = '\0'; str_color[2] = '\0';
error = NULL; if (util_parse_int (str_color, 10, &color))
color = (int)strtol (str_color, &error, 10);
if (error && !error[0])
{ {
ansi_color = gui_color_weechat_to_ansi (color); ansi_color = gui_color_weechat_to_ansi (color);
snprintf (str_concat, sizeof (str_concat), snprintf (str_concat, sizeof (str_concat),
@@ -1421,9 +1409,7 @@ gui_color_encode_ansi (const char *string)
{ {
memcpy (str_color, ptr_string, 5); memcpy (str_color, ptr_string, 5);
str_color[5] = '\0'; str_color[5] = '\0';
error = NULL; if (util_parse_int (str_color, 10, &color))
color = (int)strtol (str_color, &error, 10);
if (error && !error[0])
{ {
snprintf (str_concat, sizeof (str_concat), snprintf (str_concat, sizeof (str_concat),
"\x1B[38;5;%dm", "\x1B[38;5;%dm",
@@ -1444,9 +1430,7 @@ gui_color_encode_ansi (const char *string)
{ {
memcpy (str_color, ptr_string, 2); memcpy (str_color, ptr_string, 2);
str_color[2] = '\0'; str_color[2] = '\0';
error = NULL; if (util_parse_int (str_color, 10, &color))
color = (int)strtol (str_color, &error, 10);
if (error && !error[0])
{ {
ansi_color = gui_color_weechat_to_ansi (color); ansi_color = gui_color_weechat_to_ansi (color);
snprintf (str_concat, sizeof (str_concat), snprintf (str_concat, sizeof (str_concat),
@@ -1477,9 +1461,7 @@ gui_color_encode_ansi (const char *string)
{ {
memcpy (str_color, ptr_string, 5); memcpy (str_color, ptr_string, 5);
str_color[5] = '\0'; str_color[5] = '\0';
error = NULL; if (util_parse_int (str_color, 10, &color))
color = (int)strtol (str_color, &error, 10);
if (error && !error[0])
{ {
snprintf (str_concat, sizeof (str_concat), snprintf (str_concat, sizeof (str_concat),
"\x1B[48;5;%dm", "\x1B[48;5;%dm",
@@ -1496,9 +1478,7 @@ gui_color_encode_ansi (const char *string)
{ {
memcpy (str_color, ptr_string, 2); memcpy (str_color, ptr_string, 2);
str_color[2] = '\0'; str_color[2] = '\0';
error = NULL; if (util_parse_int (str_color, 10, &color))
color = (int)strtol (str_color, &error, 10);
if (error && !error[0])
{ {
ansi_color = gui_color_weechat_to_ansi (color); ansi_color = gui_color_weechat_to_ansi (color);
snprintf (str_concat, sizeof (str_concat), snprintf (str_concat, sizeof (str_concat),
@@ -1522,9 +1502,7 @@ gui_color_encode_ansi (const char *string)
{ {
memcpy (str_color, ptr_string, 5); memcpy (str_color, ptr_string, 5);
str_color[5] = '\0'; str_color[5] = '\0';
error = NULL; if (util_parse_int (str_color, 10, &color))
color = (int)strtol (str_color, &error, 10);
if (error && !error[0])
{ {
snprintf (str_concat, sizeof (str_concat), snprintf (str_concat, sizeof (str_concat),
"\x1B[38;5;%dm", "\x1B[38;5;%dm",
@@ -1596,9 +1574,7 @@ gui_color_encode_ansi (const char *string)
{ {
memcpy (str_color, ptr_string, 2); memcpy (str_color, ptr_string, 2);
str_color[2] = '\0'; str_color[2] = '\0';
error = NULL; if (util_parse_int (str_color, 10, &color)
color = (int)strtol (str_color, &error, 10);
if (error && !error[0]
&& (color >= 0) && (color >= 0)
&& (color < GUI_COLOR_NUM_COLORS)) && (color < GUI_COLOR_NUM_COLORS))
{ {
+2 -2
View File
@@ -366,8 +366,8 @@ gui_filter_new (int enabled, const char *name, const char *buffer_name,
{ {
struct t_gui_filter *new_filter; struct t_gui_filter *new_filter;
regex_t *regex1, *regex2; regex_t *regex1, *regex2;
char *pos_tab, *regex_prefix, buf[512], str_error[1024]; char *regex_prefix, buf[512], str_error[1024];
const char *ptr_start_regex, *pos_regex_message; const char *ptr_start_regex, *pos_regex_message, *pos_tab;
int rc; int rc;
if (!name || !buffer_name || !tags || !regex) if (!name || !buffer_name || !tags || !regex)
+5 -9
View File
@@ -32,6 +32,7 @@
#include "../core/core-hashtable.h" #include "../core/core-hashtable.h"
#include "../core/core-hook.h" #include "../core/core-hook.h"
#include "../core/core-string.h" #include "../core/core-string.h"
#include "../core/core-util.h"
#include "../plugins/plugin.h" #include "../plugins/plugin.h"
#include "gui-bar.h" #include "gui-bar.h"
#include "gui-bar-window.h" #include "gui-bar-window.h"
@@ -280,11 +281,10 @@ gui_focus_info_hashtable_gui_focus_info_cb (const void *pointer, void *data,
const char *info_name, const char *info_name,
struct t_hashtable *hashtable) struct t_hashtable *hashtable)
{ {
char *error;
const char *ptr_value;
int x, y;
struct t_gui_focus_info *focus_info; struct t_gui_focus_info *focus_info;
struct t_hashtable *focus_hashtable, *ret_hashtable; struct t_hashtable *focus_hashtable, *ret_hashtable;
const char *ptr_value;
int x, y;
/* make C compiler happy */ /* make C compiler happy */
(void) pointer; (void) pointer;
@@ -298,17 +298,13 @@ gui_focus_info_hashtable_gui_focus_info_cb (const void *pointer, void *data,
ptr_value = hashtable_get (hashtable, "x"); ptr_value = hashtable_get (hashtable, "x");
if (!ptr_value) if (!ptr_value)
return NULL; return NULL;
error = NULL; if (!util_parse_int (ptr_value, 10, &x))
x = (int)strtol (ptr_value, &error, 10);
if (!error || error[0])
return NULL; return NULL;
ptr_value = hashtable_get (hashtable, "y"); ptr_value = hashtable_get (hashtable, "y");
if (!ptr_value) if (!ptr_value)
return NULL; return NULL;
error = NULL; if (!util_parse_int (ptr_value, 10, &y))
y = (int)strtol (ptr_value, &error, 10);
if (!error || error[0])
return NULL; return NULL;
/* get focus info */ /* get focus info */
+3 -7
View File
@@ -623,10 +623,8 @@ void
gui_hotlist_clear_level_string (struct t_gui_buffer *buffer, gui_hotlist_clear_level_string (struct t_gui_buffer *buffer,
const char *str_level_mask) const char *str_level_mask)
{ {
long level_mask;
char *error;
struct t_gui_hotlist *ptr_hotlist; struct t_gui_hotlist *ptr_hotlist;
int priority; int level_mask, priority;
if (str_level_mask) if (str_level_mask)
{ {
@@ -665,11 +663,9 @@ gui_hotlist_clear_level_string (struct t_gui_buffer *buffer,
else else
{ {
/* clear hotlist using a mask of levels */ /* clear hotlist using a mask of levels */
error = NULL; if (util_parse_int (str_level_mask, 10, &level_mask) && (level_mask > 0))
level_mask = strtol (str_level_mask, &error, 10);
if (error && !error[0] && (level_mask > 0))
{ {
gui_hotlist_clear ((int)level_mask); gui_hotlist_clear (level_mask);
gui_hotlist_initial_buffer = buffer; gui_hotlist_initial_buffer = buffer;
} }
} }
+4 -6
View File
@@ -44,6 +44,7 @@
#include "../core/core-log.h" #include "../core/core-log.h"
#include "../core/core-string.h" #include "../core/core-string.h"
#include "../core/core-utf8.h" #include "../core/core-utf8.h"
#include "../core/core-util.h"
#include "../plugins/plugin.h" #include "../plugins/plugin.h"
#include "gui-key.h" #include "gui-key.h"
#include "gui-bar.h" #include "gui-bar.h"
@@ -193,8 +194,7 @@ gui_key_get_current_context (void)
void void
gui_key_grab_init (int grab_command, const char *delay) gui_key_grab_init (int grab_command, const char *delay)
{ {
long milliseconds; int milliseconds;
char *error;
gui_key_grab = 1; gui_key_grab = 1;
gui_key_grab_count = 0; gui_key_grab_count = 0;
@@ -203,9 +203,7 @@ gui_key_grab_init (int grab_command, const char *delay)
gui_key_grab_delay = CONFIG_INTEGER(config_look_key_grab_delay); gui_key_grab_delay = CONFIG_INTEGER(config_look_key_grab_delay);
if (delay != NULL) if (delay != NULL)
{ {
error = NULL; if (util_parse_int (delay, 10, &milliseconds) && (milliseconds >= 0))
milliseconds = strtol (delay, &error, 10);
if (error && !error[0] && (milliseconds >= 0))
{ {
gui_key_grab_delay = milliseconds; gui_key_grab_delay = milliseconds;
if (gui_key_grab_delay == 0) if (gui_key_grab_delay == 0)
@@ -1076,7 +1074,7 @@ gui_key_set_area_type_name (const char *area,
int *area_type, char **area_name) int *area_type, char **area_name)
{ {
int focus, length; int focus, length;
char *pos_end; const char *pos_end;
for (focus = 0; focus < GUI_KEY_NUM_FOCUS; focus++) for (focus = 0; focus < GUI_KEY_NUM_FOCUS; focus++)
{ {
+24 -28
View File
@@ -39,6 +39,7 @@
#include "../core/core-infolist.h" #include "../core/core-infolist.h"
#include "../core/core-log.h" #include "../core/core-log.h"
#include "../core/core-string.h" #include "../core/core-string.h"
#include "../core/core-util.h"
#include "../plugins/plugin.h" #include "../plugins/plugin.h"
#include "gui-line.h" #include "gui-line.h"
#include "gui-buffer.h" #include "gui-buffer.h"
@@ -1674,10 +1675,10 @@ gui_line_hook_update (struct t_gui_line *line,
const char *ptr_value, *ptr_value2; const char *ptr_value, *ptr_value2;
struct t_gui_buffer *ptr_buffer; struct t_gui_buffer *ptr_buffer;
unsigned long value_pointer; unsigned long value_pointer;
long value; long long value_longlong;
char *error, *new_message, *pos_newline; char *new_message, *pos_newline;
int rc, tags_updated, notify_level_updated, highlight_updated; int rc, tags_updated, notify_level_updated, highlight_updated;
int max_notify_level; int max_notify_level, value;
tags_updated = 0; tags_updated = 0;
notify_level_updated = 0; notify_level_updated = 0;
@@ -1730,9 +1731,7 @@ gui_line_hook_update (struct t_gui_line *line,
ptr_value = hashtable_get (hashtable2, "y"); ptr_value = hashtable_get (hashtable2, "y");
if (ptr_value) if (ptr_value)
{ {
error = NULL; if (util_parse_int (ptr_value, 10, &value) && (value >= 0))
value = strtol (ptr_value, &error, 10);
if (error && !error[0] && (value >= 0))
line->data->y = value; line->data->y = value;
} }
} }
@@ -1740,9 +1739,8 @@ gui_line_hook_update (struct t_gui_line *line,
ptr_value2 = hashtable_get (hashtable2, "notify_level"); ptr_value2 = hashtable_get (hashtable2, "notify_level");
if (ptr_value2) if (ptr_value2)
{ {
error = NULL; if (util_parse_int (ptr_value2, 10, &value)
value = strtol (ptr_value2, &error, 10); && (value >= -1) && (value <= GUI_HOTLIST_MAX))
if (error && !error[0] && (value >= -1) && (value <= GUI_HOTLIST_MAX))
{ {
notify_level_updated = 1; notify_level_updated = 1;
line->data->notify_level = value; line->data->notify_level = value;
@@ -1752,9 +1750,7 @@ gui_line_hook_update (struct t_gui_line *line,
ptr_value2 = hashtable_get (hashtable2, "highlight"); ptr_value2 = hashtable_get (hashtable2, "highlight");
if (ptr_value2) if (ptr_value2)
{ {
error = NULL; if (util_parse_int (ptr_value2, 10, &value))
value = strtol (ptr_value2, &error, 10);
if (error && !error[0])
{ {
highlight_updated = 1; highlight_updated = 1;
line->data->highlight = (value) ? 1 : 0; line->data->highlight = (value) ? 1 : 0;
@@ -1764,11 +1760,10 @@ gui_line_hook_update (struct t_gui_line *line,
ptr_value2 = hashtable_get (hashtable2, "date"); ptr_value2 = hashtable_get (hashtable2, "date");
if (ptr_value2) if (ptr_value2)
{ {
error = NULL; if (util_parse_longlong (ptr_value2, 10, &value_longlong)
value = strtol (ptr_value2, &error, 10); && (value_longlong >= 0))
if (error && !error[0] && (value >= 0))
{ {
line->data->date = (time_t)value; line->data->date = (time_t)value_longlong;
free (line->data->str_time); free (line->data->str_time);
line->data->str_time = gui_chat_get_time_string ( line->data->str_time = gui_chat_get_time_string (
line->data->date, line->data->date,
@@ -1780,11 +1775,10 @@ gui_line_hook_update (struct t_gui_line *line,
ptr_value2 = hashtable_get (hashtable2, "date_usec"); ptr_value2 = hashtable_get (hashtable2, "date_usec");
if (ptr_value2) if (ptr_value2)
{ {
error = NULL; if (util_parse_int (ptr_value2, 10, &value)
value = strtol (ptr_value2, &error, 10); && (value >= 0) && (value <= 999999))
if (error && !error[0] && (value >= 0) && (value <= 999999))
{ {
line->data->date_usec = (int)value; line->data->date_usec = value;
free (line->data->str_time); free (line->data->str_time);
line->data->str_time = gui_chat_get_time_string ( line->data->str_time = gui_chat_get_time_string (
line->data->date, line->data->date,
@@ -1796,19 +1790,21 @@ gui_line_hook_update (struct t_gui_line *line,
ptr_value2 = hashtable_get (hashtable2, "date_printed"); ptr_value2 = hashtable_get (hashtable2, "date_printed");
if (ptr_value2) if (ptr_value2)
{ {
error = NULL; if (util_parse_longlong (ptr_value2, 10, &value_longlong)
value = strtol (ptr_value2, &error, 10); && (value_longlong >= 0))
if (error && !error[0] && (value >= 0)) {
line->data->date_printed = (time_t)value; line->data->date_printed = (time_t)value_longlong;
}
} }
ptr_value2 = hashtable_get (hashtable2, "date_usec_printed"); ptr_value2 = hashtable_get (hashtable2, "date_usec_printed");
if (ptr_value2) if (ptr_value2)
{ {
error = NULL; if (util_parse_int (ptr_value2, 10, &value)
value = strtol (ptr_value2, &error, 10); && (value >= 0) && (value <= 999999))
if (error && !error[0] && (value >= 0) && (value <= 999999)) {
line->data->date_usec_printed = (int)value; line->data->date_usec_printed = value;
}
} }
ptr_value = hashtable_get (hashtable, "str_time"); ptr_value = hashtable_get (hashtable, "str_time");
+9 -22
View File
@@ -44,6 +44,7 @@
#include "../core/core-log.h" #include "../core/core-log.h"
#include "../core/core-string.h" #include "../core/core-string.h"
#include "../core/core-utf8.h" #include "../core/core-utf8.h"
#include "../core/core-util.h"
#include "../plugins/plugin.h" #include "../plugins/plugin.h"
#include "gui-nicklist.h" #include "gui-nicklist.h"
#include "gui-buffer.h" #include "gui-buffer.h"
@@ -275,7 +276,6 @@ gui_nicklist_search_group (struct t_gui_buffer *buffer,
const char *name) const char *name)
{ {
const char *ptr_name; const char *ptr_name;
char *error;
long long id; long long id;
if ((!buffer && !from_group) if ((!buffer && !from_group)
@@ -287,8 +287,7 @@ gui_nicklist_search_group (struct t_gui_buffer *buffer,
if (strncmp (name, "==id:", 5) == 0) if (strncmp (name, "==id:", 5) == 0)
{ {
id = strtoll (name + 5, &error, 10); if (util_parse_longlong (name + 5, 10, &id))
if (error && !error[0])
return gui_nicklist_search_group_id (buffer, from_group, id); return gui_nicklist_search_group_id (buffer, from_group, id);
} }
@@ -570,7 +569,6 @@ gui_nicklist_search_nick (struct t_gui_buffer *buffer,
const char *name) const char *name)
{ {
long long id; long long id;
char *error;
if ((!buffer && !from_group) if ((!buffer && !from_group)
|| !name || !name
@@ -581,8 +579,7 @@ gui_nicklist_search_nick (struct t_gui_buffer *buffer,
if (strncmp (name, "==id:", 5) == 0) if (strncmp (name, "==id:", 5) == 0)
{ {
id = strtoll (name + 5, &error, 10); if (util_parse_longlong (name + 5, 10, &id))
if (error && !error[0])
return gui_nicklist_search_nick_id (buffer, from_group, id); return gui_nicklist_search_nick_id (buffer, from_group, id);
} }
@@ -1036,9 +1033,7 @@ gui_nicklist_group_set (struct t_gui_buffer *buffer,
const char *property, const char *value) const char *property, const char *value)
{ {
long long id; long long id;
long number; int group_changed, number;
char *error;
int group_changed;
if (!buffer || !group || !property || !value) if (!buffer || !group || !property || !value)
return; return;
@@ -1047,8 +1042,7 @@ gui_nicklist_group_set (struct t_gui_buffer *buffer,
if (strcmp (property, "id") == 0) if (strcmp (property, "id") == 0)
{ {
id = strtoll (value, &error, 10); if (util_parse_longlong (value, 10, &id)
if (error && !error[0]
&& (id != group->id) && (id != group->id)
&& !gui_nicklist_search_group_id (buffer, NULL, id)) && !gui_nicklist_search_group_id (buffer, NULL, id))
{ {
@@ -1064,9 +1058,7 @@ gui_nicklist_group_set (struct t_gui_buffer *buffer,
} }
else if (strcmp (property, "visible") == 0) else if (strcmp (property, "visible") == 0)
{ {
error = NULL; if (util_parse_int (value, 10, &number))
number = strtol (value, &error, 10);
if (error && !error[0])
group->visible = (number) ? 1 : 0; group->visible = (number) ? 1 : 0;
group_changed = 1; group_changed = 1;
} }
@@ -1158,9 +1150,7 @@ gui_nicklist_nick_set (struct t_gui_buffer *buffer,
const char *property, const char *value) const char *property, const char *value)
{ {
long long id; long long id;
long number; int nick_changed, number;
char *error;
int nick_changed;
if (!buffer || !nick || !property || !value) if (!buffer || !nick || !property || !value)
return; return;
@@ -1169,8 +1159,7 @@ gui_nicklist_nick_set (struct t_gui_buffer *buffer,
if (strcmp (property, "id") == 0) if (strcmp (property, "id") == 0)
{ {
id = strtoll (value, &error, 10); if (util_parse_longlong (value, 10, &id)
if (error && !error[0]
&& (id != nick->id) && (id != nick->id)
&& !gui_nicklist_search_nick_id (buffer, NULL, id)) && !gui_nicklist_search_nick_id (buffer, NULL, id))
{ {
@@ -1198,9 +1187,7 @@ gui_nicklist_nick_set (struct t_gui_buffer *buffer,
} }
else if (strcmp (property, "visible") == 0) else if (strcmp (property, "visible") == 0)
{ {
error = NULL; if (util_parse_int (value, 10, &number))
number = strtol (value, &error, 10);
if (error && !error[0])
nick->visible = (number) ? 1 : 0; nick->visible = (number) ? 1 : 0;
nick_changed = 1; nick_changed = 1;
} }
+6 -10
View File
@@ -43,6 +43,7 @@
#include "../core/core-log.h" #include "../core/core-log.h"
#include "../core/core-string.h" #include "../core/core-string.h"
#include "../core/core-utf8.h" #include "../core/core-utf8.h"
#include "../core/core-util.h"
#include "../plugins/plugin.h" #include "../plugins/plugin.h"
#include "gui-window.h" #include "gui-window.h"
#include "gui-bar.h" #include "gui-bar.h"
@@ -1182,7 +1183,7 @@ gui_window_scroll (struct t_gui_window *window, char *scroll)
int direction, stop, count_msg, scroll_from_end_free_buffer; int direction, stop, count_msg, scroll_from_end_free_buffer;
char time_letter, saved_char; char time_letter, saved_char;
time_t old_date, diff_date; time_t old_date, diff_date;
char *pos, *error; char *pos;
long number; long number;
struct t_gui_line *ptr_line; struct t_gui_line *ptr_line;
struct tm *date_tmp, line_date, old_line_date; struct tm *date_tmp, line_date, old_line_date;
@@ -1231,9 +1232,7 @@ gui_window_scroll (struct t_gui_window *window, char *scroll)
time_letter = pos[0]; time_letter = pos[0];
saved_char = pos[0]; saved_char = pos[0];
pos[0] = '\0'; pos[0] = '\0';
error = NULL; if (!util_parse_long (scroll, 10, &number))
number = strtol (scroll, &error, 10);
if (!error || error[0])
number = 0; number = 0;
pos[0] = saved_char; pos[0] = saved_char;
} }
@@ -1430,9 +1429,8 @@ gui_window_scroll (struct t_gui_window *window, char *scroll)
void void
gui_window_scroll_horiz (struct t_gui_window *window, char *scroll) gui_window_scroll_horiz (struct t_gui_window *window, char *scroll)
{ {
int direction, percentage, start_col; int direction, percentage, start_col, number;
char saved_char, *pos, *error; char saved_char, *pos;
long number;
if (!window || !window->buffer->lines->first_line) if (!window || !window->buffer->lines->first_line)
return; return;
@@ -1464,9 +1462,7 @@ gui_window_scroll_horiz (struct t_gui_window *window, char *scroll)
percentage = (pos[0] == '%') ? 1 : 0; percentage = (pos[0] == '%') ? 1 : 0;
saved_char = pos[0]; saved_char = pos[0];
pos[0] = '\0'; pos[0] = '\0';
error = NULL; if (!util_parse_int (scroll, 10, &number))
number = strtol (scroll, &error, 10);
if (!error || error[0])
number = 0; number = 0;
pos[0] = saved_char; pos[0] = saved_char;
} }
+8 -19
View File
@@ -40,9 +40,8 @@ struct t_hashtable *
buflist_focus_cb (const void *pointer, void *data, struct t_hashtable *info) buflist_focus_cb (const void *pointer, void *data, struct t_hashtable *info)
{ {
const char *ptr_bar_item_name, *ptr_bar_item_line, *keys, *ptr_value; const char *ptr_bar_item_name, *ptr_bar_item_line, *keys, *ptr_value;
long item_line; char str_value[128], **list_keys;
char *error, str_value[128], **list_keys; int i, item_index, item_line, num_keys, type;
int i, item_index, num_keys, type;
struct t_gui_buffer *ptr_buffer; struct t_gui_buffer *ptr_buffer;
/* make C compiler happy */ /* make C compiler happy */
@@ -64,15 +63,10 @@ buflist_focus_cb (const void *pointer, void *data, struct t_hashtable *info)
ptr_bar_item_line = weechat_hashtable_get (info, "_bar_item_line"); ptr_bar_item_line = weechat_hashtable_get (info, "_bar_item_line");
if (!ptr_bar_item_line) if (!ptr_bar_item_line)
goto end; goto end;
error = NULL; if (!weechat_util_parse_int (ptr_bar_item_line, 10, &item_line)
item_line = strtol (ptr_bar_item_line, &error, 10); || (item_line < 0)
if (!error || error[0])
goto end;
if ((item_line < 0)
|| (item_line >= weechat_arraylist_size (buflist_list_buffers[item_index]))) || (item_line >= weechat_arraylist_size (buflist_list_buffers[item_index])))
{
goto end; goto end;
}
/* check if buffer pointer is still valid */ /* check if buffer pointer is still valid */
ptr_buffer = weechat_arraylist_get (buflist_list_buffers[item_index], ptr_buffer = weechat_arraylist_get (buflist_list_buffers[item_index],
@@ -333,10 +327,9 @@ buflist_hsignal_cb (const void *pointer, void *data, const char *signal,
const char *ptr_key, *ptr_pointer, *ptr_number, *ptr_number2; const char *ptr_key, *ptr_pointer, *ptr_number, *ptr_number2;
const char *ptr_full_name; const char *ptr_full_name;
struct t_gui_buffer *ptr_buffer; struct t_gui_buffer *ptr_buffer;
char *error, str_command[1024]; char str_command[1024];
long number, number2;
unsigned long value; unsigned long value;
int rc, current_buffer_number; int rc, current_buffer_number, number, number2;
/* make C compiler happy */ /* make C compiler happy */
(void) pointer; (void) pointer;
@@ -360,13 +353,9 @@ buflist_hsignal_cb (const void *pointer, void *data, const char *signal,
return WEECHAT_RC_OK; return WEECHAT_RC_OK;
ptr_buffer = (struct t_gui_buffer *)value; ptr_buffer = (struct t_gui_buffer *)value;
error = NULL; if (!weechat_util_parse_int (ptr_number, 10, &number))
number = strtol (ptr_number, &error, 10);
if (!error || error[0])
return WEECHAT_RC_OK; return WEECHAT_RC_OK;
error = NULL; if (!weechat_util_parse_int (ptr_number2, 10, &number2))
number2 = strtol (ptr_number2, &error, 10);
if (!error || error[0])
return WEECHAT_RC_OK; return WEECHAT_RC_OK;
current_buffer_number = weechat_buffer_get_integer ( current_buffer_number = weechat_buffer_get_integer (
+3 -5
View File
@@ -185,8 +185,7 @@ exec_command_parse_options (struct t_exec_cmd_options *cmd_options,
int argc, char **argv, int start_arg, int argc, char **argv, int start_arg,
int set_command_index) int set_command_index)
{ {
int i, j, end, length, length_total; int i, j, end, length, length_total, timeout;
char *error;
for (i = start_arg; i < argc; i++) for (i = start_arg; i < argc; i++)
{ {
@@ -318,10 +317,9 @@ exec_command_parse_options (struct t_exec_cmd_options *cmd_options,
if (i + 1 >= argc) if (i + 1 >= argc)
return 0; return 0;
i++; i++;
error = NULL; if (!weechat_util_parse_int (argv[i], 10, &timeout))
cmd_options->timeout = strtol (argv[i], &error, 10);
if (!error || error[0])
return 0; return 0;
cmd_options->timeout = timeout;
} }
else if (weechat_strcmp (argv[i], "-name") == 0) else if (weechat_strcmp (argv[i], "-name") == 0)
{ {
+1 -4
View File
@@ -85,15 +85,12 @@ struct t_exec_cmd *
exec_search_by_id (const char *id) exec_search_by_id (const char *id)
{ {
struct t_exec_cmd* ptr_exec_cmd; struct t_exec_cmd* ptr_exec_cmd;
char *error;
long number; long number;
if (!id) if (!id)
return NULL; return NULL;
error = NULL; if (!weechat_util_parse_long (id, 10, &number))
number = strtol (id, &error, 10);
if (!error || error[0])
number = -1; number = -1;
for (ptr_exec_cmd = exec_cmds; ptr_exec_cmd; for (ptr_exec_cmd = exec_cmds; ptr_exec_cmd;
+2 -5
View File
@@ -60,15 +60,12 @@ int
fset_command_get_int_arg (int argc, char **argv, int arg_number, fset_command_get_int_arg (int argc, char **argv, int arg_number,
int default_value) int default_value)
{ {
long value; int value;
char *error;
value = default_value; value = default_value;
if (argc > arg_number) if (argc > arg_number)
{ {
error = NULL; if (!weechat_util_parse_int (argv[arg_number], 10, &value))
value = strtol (argv[arg_number], &error, 10);
if (!error || error[0])
value = default_value; value = default_value;
} }
return (int)value; return (int)value;
+8 -14
View File
@@ -42,11 +42,10 @@ struct t_hashtable *
fset_mouse_focus_cb (const void *pointer, void *data, struct t_hashtable *info) fset_mouse_focus_cb (const void *pointer, void *data, struct t_hashtable *info)
{ {
const char *buffer; const char *buffer;
int rc, format_number; int rc, format_number, y, option_index;
unsigned long value; unsigned long value;
struct t_gui_buffer *ptr_buffer; struct t_gui_buffer *ptr_buffer;
long y, option_index; char str_value[128];
char *error, str_value[128];
struct t_fset_option *ptr_fset_option; struct t_fset_option *ptr_fset_option;
/* make C compiler happy */ /* make C compiler happy */
@@ -69,13 +68,11 @@ fset_mouse_focus_cb (const void *pointer, void *data, struct t_hashtable *info)
if (!ptr_buffer || (ptr_buffer != fset_buffer)) if (!ptr_buffer || (ptr_buffer != fset_buffer))
return info; return info;
error = NULL; if (!weechat_util_parse_int (weechat_hashtable_get (info, "_chat_line_y"), 10, &y)
y = strtol (weechat_hashtable_get (info, "_chat_line_y"), &error, 10); || (y < 0))
if (!error || error[0]) {
return info;
if (y < 0)
return info; return info;
}
format_number = weechat_config_integer (fset_config_look_format_number); format_number = weechat_config_integer (fset_config_look_format_number);
option_index = y / fset_config_format_option_num_lines[format_number - 1]; option_index = y / fset_config_format_option_num_lines[format_number - 1];
@@ -87,7 +84,7 @@ fset_mouse_focus_cb (const void *pointer, void *data, struct t_hashtable *info)
snprintf (str_value, sizeof (str_value), snprintf (str_value, sizeof (str_value),
"0x%lx", (unsigned long)ptr_fset_option); "0x%lx", (unsigned long)ptr_fset_option);
weechat_hashtable_set (info, "fset_option", str_value); weechat_hashtable_set (info, "fset_option", str_value);
snprintf (str_value, sizeof (str_value), "%ld", option_index); snprintf (str_value, sizeof (str_value), "%d", option_index);
weechat_hashtable_set (info, "fset_option_index", str_value); weechat_hashtable_set (info, "fset_option_index", str_value);
weechat_hashtable_set (info, "fset_option_name", ptr_fset_option->name); weechat_hashtable_set (info, "fset_option_name", ptr_fset_option->name);
weechat_hashtable_set (info, "fset_option_parent_name", ptr_fset_option->parent_name); weechat_hashtable_set (info, "fset_option_parent_name", ptr_fset_option->parent_name);
@@ -137,15 +134,12 @@ fset_mouse_get_hashtable_int (struct t_hashtable *hashtable,
int default_value) int default_value)
{ {
const char *ptr_value; const char *ptr_value;
char *error;
int value; int value;
ptr_value = weechat_hashtable_get (hashtable, variable); ptr_value = weechat_hashtable_get (hashtable, variable);
if (!ptr_value) if (!ptr_value)
return default_value; return default_value;
error = NULL; if (!weechat_util_parse_int (ptr_value, 10, &value))
value = (int)strtol (ptr_value, &error, 10);
if (!error || error[0])
return default_value; return default_value;
return value; return value;
+15 -28
View File
@@ -96,8 +96,8 @@ char *irc_color_string_decoded[32];
int int
irc_color_convert_rgb2term (long rgb) irc_color_convert_rgb2term (long rgb)
{ {
char str_color[64], *info_color, *error; char str_color[64], *info_color;
long number; int number;
if (rgb < 0) if (rgb < 0)
return -1; return -1;
@@ -111,9 +111,7 @@ irc_color_convert_rgb2term (long rgb)
return -1; return -1;
} }
error = NULL; if (!weechat_util_parse_int (info_color, 10, &number))
number = strtol (info_color, &error, 10);
if (!error || error[0])
{ {
free (info_color); free (info_color);
return -1; return -1;
@@ -121,7 +119,7 @@ irc_color_convert_rgb2term (long rgb)
free (info_color); free (info_color);
return (int)number; return number;
} }
/* /*
@@ -133,8 +131,8 @@ irc_color_convert_rgb2term (long rgb)
int int
irc_color_convert_rgb2irc (long rgb) irc_color_convert_rgb2irc (long rgb)
{ {
char str_color[64], *error, *info_color; char str_color[64], *info_color;
long number; int number;
if (rgb < 0) if (rgb < 0)
return -1; return -1;
@@ -151,9 +149,7 @@ irc_color_convert_rgb2irc (long rgb)
return -1; return -1;
} }
error = NULL; if (!weechat_util_parse_int (info_color, 10, &number)
number = strtol (info_color, &error, 10);
if (!error || error[0]
|| (number < 0) || (number >= IRC_COLOR_TERM2IRC_NUM_COLORS)) || (number < 0) || (number >= IRC_COLOR_TERM2IRC_NUM_COLORS))
{ {
free (info_color); free (info_color);
@@ -174,7 +170,7 @@ irc_color_convert_rgb2irc (long rgb)
int int
irc_color_convert_term2irc (int color) irc_color_convert_term2irc (int color)
{ {
char str_color[64], *error, *info_color; char str_color[64], *info_color;
long number; long number;
snprintf (str_color, sizeof (str_color), "%d", color); snprintf (str_color, sizeof (str_color), "%d", color);
@@ -186,9 +182,8 @@ irc_color_convert_term2irc (int color)
return -1; return -1;
} }
error = NULL; if (!weechat_util_parse_long (info_color, 10, &number)
number = strtol (info_color, &error, 10); || (number < 0) || (number > 0xFFFFFF))
if (!error || error[0] || (number < 0) || (number > 0xFFFFFF))
{ {
free (info_color); free (info_color);
return -1; return -1;
@@ -211,7 +206,7 @@ irc_color_convert_term2irc (int color)
char * char *
irc_color_decode (const char *string, int keep_colors) irc_color_decode (const char *string, int keep_colors)
{ {
char **out, *error; char **out;
char str_fg[16], str_bg[16], str_color[128], str_key[128], str_to_add[128]; char str_fg[16], str_bg[16], str_color[128], str_key[128], str_to_add[128];
const char *remapped_color; const char *remapped_color;
unsigned char *ptr_string; unsigned char *ptr_string;
@@ -337,18 +332,14 @@ irc_color_decode (const char *string, int keep_colors)
bg = -1; bg = -1;
if (str_fg[0]) if (str_fg[0])
{ {
error = NULL; if (weechat_util_parse_int (str_fg, 10, &fg))
fg = (int)strtol (str_fg, &error, 10);
if (error && !error[0])
fg %= IRC_NUM_COLORS; fg %= IRC_NUM_COLORS;
else else
fg = -1; fg = -1;
} }
if (str_bg[0]) if (str_bg[0])
{ {
error = NULL; if (weechat_util_parse_int (str_bg, 10, &bg))
bg = (int)strtol (str_bg, &error, 10);
if (error && !error[0])
bg %= IRC_NUM_COLORS; bg %= IRC_NUM_COLORS;
else else
bg = -1; bg = -1;
@@ -422,16 +413,12 @@ irc_color_decode (const char *string, int keep_colors)
bg_rgb = -1; bg_rgb = -1;
if (str_fg[0]) if (str_fg[0])
{ {
error = NULL; if (!weechat_util_parse_long (str_fg, 16, &fg_rgb))
fg_rgb = strtol (str_fg, &error, 16);
if (!error || error[0])
fg_rgb = -1; fg_rgb = -1;
} }
if (str_bg[0]) if (str_bg[0])
{ {
error = NULL; if (!weechat_util_parse_long (str_bg, 16, &bg_rgb))
bg_rgb = strtol (str_bg, &error, 16);
if (!error || error[0])
bg_rgb = -1; bg_rgb = -1;
} }
str_fg[0] = '\0'; str_fg[0] = '\0';
+15 -30
View File
@@ -232,9 +232,8 @@ irc_command_mode_nicks (struct t_irc_server *server,
char ** char **
irc_command_mode_masks_convert_ranges (char **argv, int arg_start) irc_command_mode_masks_convert_ranges (char **argv, int arg_start)
{ {
char **str_masks, **masks, *error1, *error2, *pos, str_number[32]; char **str_masks, **masks, *pos, str_number[32];
int i, length, added; int i, j, length, added, number1, number2;
long j, number1, number2;
if (!argv || (arg_start < 0)) if (!argv || (arg_start < 0))
return NULL; return NULL;
@@ -255,12 +254,8 @@ irc_command_mode_masks_convert_ranges (char **argv, int arg_start)
&& (argv[i][length - 1] != '-')) && (argv[i][length - 1] != '-'))
{ {
pos[0] = '\0'; pos[0] = '\0';
error1 = NULL; if (weechat_util_parse_int (argv[i], 10, &number1)
number1 = strtol (argv[i], &error1, 10); && weechat_util_parse_int (pos + 1, 10, &number2)
error2 = NULL;
number2 = strtol (pos + 1, &error2, 10);
if (error1 && !error1[0]
&& error2 && !error2[0]
&& (number1 > 0) && (number1 < 128) && (number1 > 0) && (number1 < 128)
&& (number2 > 0) && (number2 < 128) && (number2 > 0) && (number2 < 128)
&& (number1 < number2)) && (number1 < number2))
@@ -269,8 +264,7 @@ irc_command_mode_masks_convert_ranges (char **argv, int arg_start)
{ {
if ((*str_masks)[0]) if ((*str_masks)[0])
weechat_string_dyn_concat (str_masks, " ", -1); weechat_string_dyn_concat (str_masks, " ", -1);
snprintf (str_number, sizeof (str_number), snprintf (str_number, sizeof (str_number), "%d", j);
"%ld", j);
weechat_string_dyn_concat (str_masks, str_number, -1); weechat_string_dyn_concat (str_masks, str_number, -1);
} }
added = 1; added = 1;
@@ -312,14 +306,12 @@ irc_command_mode_masks (struct t_irc_server *server,
const char *set, const char *mode, const char *set, const char *mode,
char **argv, int pos_masks) char **argv, int pos_masks)
{ {
int max_modes, modes_added, msg_priority; int max_modes, modes_added, msg_priority, number;
char **modes, **masks, *mask; char **modes, **masks, *mask;
struct t_irc_channel *ptr_channel; struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick; struct t_irc_nick *ptr_nick;
struct t_irc_modelist *ptr_modelist; struct t_irc_modelist *ptr_modelist;
struct t_irc_modelist_item *ptr_item; struct t_irc_modelist_item *ptr_item;
long number;
char *error;
if (irc_mode_get_chanmode_type (server, mode[0]) != 'A') if (irc_mode_get_chanmode_type (server, mode[0]) != 'A')
{ {
@@ -367,9 +359,7 @@ irc_command_mode_masks (struct t_irc_server *server,
/* use modelist item for number arguments */ /* use modelist item for number arguments */
if (ptr_modelist && (set[0] == '-')) if (ptr_modelist && (set[0] == '-'))
{ {
error = NULL; if (weechat_util_parse_int (argv[pos_masks], 10, &number))
number = strtol (argv[pos_masks], &error, 10);
if (error && !error[0])
{ {
ptr_item = irc_modelist_item_search_number (ptr_modelist, ptr_item = irc_modelist_item_search_number (ptr_modelist,
number - 1); number - 1);
@@ -2622,9 +2612,8 @@ irc_command_ignore_display (struct t_irc_ignore *ignore)
IRC_COMMAND_CALLBACK(ignore) IRC_COMMAND_CALLBACK(ignore)
{ {
struct t_irc_ignore *ptr_ignore; struct t_irc_ignore *ptr_ignore;
char *mask, *regex, *regex2, *ptr_regex, *pos, *server, *channel, *error; char *mask, *regex, *regex2, *ptr_regex, *pos, *server, *channel;
int length, update; int length, number, update;
long number;
/* make C compiler happy */ /* make C compiler happy */
(void) pointer; (void) pointer;
@@ -2767,9 +2756,7 @@ IRC_COMMAND_CALLBACK(ignore)
} }
else else
{ {
error = NULL; if (weechat_util_parse_int (argv[2], 10, &number))
number = strtol (argv[2], &error, 10);
if (error && !error[0])
{ {
ptr_ignore = irc_ignore_search_by_number (number); ptr_ignore = irc_ignore_search_by_number (number);
if (ptr_ignore) if (ptr_ignore)
@@ -2925,7 +2912,8 @@ void
irc_command_join_server (struct t_irc_server *server, const char *arguments, irc_command_join_server (struct t_irc_server *server, const char *arguments,
int manual_join, int noswitch) int manual_join, int noswitch)
{ {
char *new_args, **channels, **keys, *pos_space, *pos_keys, *pos_channel; const char *pos_space, *pos_keys;
char *new_args, **channels, **keys, *pos_channel;
char *channel_name_lower; char *channel_name_lower;
int i, num_channels, num_keys, length; int i, num_channels, num_keys, length;
time_t time_now; time_t time_now;
@@ -3429,18 +3417,15 @@ int
irc_command_list_get_int_arg (int argc, char **argv, int arg_number, irc_command_list_get_int_arg (int argc, char **argv, int arg_number,
int default_value) int default_value)
{ {
long value; int value;
char *error;
value = default_value; value = default_value;
if (argc > arg_number) if (argc > arg_number)
{ {
error = NULL; if (!weechat_util_parse_int (argv[arg_number], 10, &value))
value = strtol (argv[arg_number], &error, 10);
if (!error || error[0])
value = default_value; value = default_value;
} }
return (int)value; return value;
} }
/* /*
+3 -2
View File
@@ -470,7 +470,7 @@ irc_completion_modelist_masks_cb (const void *pointer, void *data,
struct t_gui_buffer *buffer, struct t_gui_buffer *buffer,
struct t_gui_completion *completion) struct t_gui_completion *completion)
{ {
char *pos; const char *pos;
struct t_irc_modelist *ptr_modelist; struct t_irc_modelist *ptr_modelist;
struct t_irc_modelist_item *ptr_item; struct t_irc_modelist_item *ptr_item;
@@ -512,7 +512,8 @@ irc_completion_modelist_numbers_cb (const void *pointer, void *data,
struct t_gui_buffer *buffer, struct t_gui_buffer *buffer,
struct t_gui_completion *completion) struct t_gui_completion *completion)
{ {
char *pos, str_number[32]; const char *pos;
char str_number[32];
struct t_irc_modelist *ptr_modelist; struct t_irc_modelist *ptr_modelist;
struct t_irc_modelist_item *ptr_item; struct t_irc_modelist_item *ptr_item;
+13 -15
View File
@@ -201,7 +201,8 @@ struct t_irc_server *
irc_config_get_server_from_option_name (const char *name) irc_config_get_server_from_option_name (const char *name)
{ {
struct t_irc_server *ptr_server; struct t_irc_server *ptr_server;
char *pos_option, *server_name; const char *pos_option;
char *server_name;
ptr_server = NULL; ptr_server = NULL;
@@ -274,7 +275,7 @@ irc_config_compute_nick_colors (void)
int int
irc_config_display_channel_modes_arguments (const char *modes) irc_config_display_channel_modes_arguments (const char *modes)
{ {
char *pos_space, *pos; const char *pos_space, *pos;
const char *ptr_mode; const char *ptr_mode;
pos_space = strchr (modes, ' '); pos_space = strchr (modes, ' ');
@@ -1287,10 +1288,8 @@ irc_config_server_check_value_cb (const void *pointer, void *data,
struct t_config_option *option, struct t_config_option *option,
const char *value) const char *value)
{ {
int index_option, proxy_found; int index_option, number, proxy_found;
const char *pos_error, *proxy_name; const char *pos_error, *proxy_name;
char *error;
long number;
struct t_infolist *infolist; struct t_infolist *infolist;
/* make C compiler happy */ /* make C compiler happy */
@@ -1363,9 +1362,7 @@ irc_config_server_check_value_cb (const void *pointer, void *data,
case IRC_SERVER_OPTION_SPLIT_MSG_MAX_LENGTH: case IRC_SERVER_OPTION_SPLIT_MSG_MAX_LENGTH:
if (!value || !value[0]) if (!value || !value[0])
break; break;
error = NULL; if (!weechat_util_parse_int (value, 10, &number))
number = strtol (value, &error, 10);
if (!error || error[0])
{ {
/* /*
* not a valid number, but we return 1 (OK) to let WeeChat * not a valid number, but we return 1 (OK) to let WeeChat
@@ -2811,7 +2808,8 @@ irc_config_server_read_cb (const void *pointer, void *data,
{ {
struct t_irc_server *ptr_server; struct t_irc_server *ptr_server;
int index_option, rc, i; int index_option, rc, i;
char *pos_option, *server_name; const char *pos_option;
char *server_name;
/* make C compiler happy */ /* make C compiler happy */
(void) pointer; (void) pointer;
@@ -2940,9 +2938,9 @@ irc_config_update_cb (const void *pointer, void *data,
int version_read, int version_read,
struct t_hashtable *data_read) struct t_hashtable *data_read)
{ {
const char *ptr_config, *ptr_section, *ptr_option, *ptr_value; const char *ptr_config, *ptr_section, *ptr_option, *ptr_value, *pos_option;
const char *option_autojoin_delay = "autojoin_delay"; const char *option_autojoin_delay = "autojoin_delay";
char *new_option, *pos_option, *new_value; char *new_option, *pos_new_option, *new_value;
int changes, length; int changes, length;
/* make C compiler happy */ /* make C compiler happy */
@@ -2997,11 +2995,11 @@ irc_config_update_cb (const void *pointer, void *data,
new_option = strdup (ptr_option); new_option = strdup (ptr_option);
if (new_option) if (new_option)
{ {
pos_option = strrchr (new_option, '.'); pos_new_option = strrchr (new_option, '.');
if (pos_option) if (pos_new_option)
{ {
pos_option++; pos_new_option++;
memcpy (pos_option, "tls", 3); memcpy (pos_new_option, "tls", 3);
weechat_printf ( weechat_printf (
NULL, NULL,
_("IRC option renamed: \"irc.%s.%s\" => \"irc.%s.%s\""), _("IRC option renamed: \"irc.%s.%s\" => \"irc.%s.%s\""),
+20 -23
View File
@@ -67,8 +67,8 @@ irc_info_info_irc_is_channel_cb (const void *pointer, void *data,
const char *info_name, const char *info_name,
const char *arguments) const char *arguments)
{ {
char *pos_comma, *server; char *server;
const char *pos_channel; const char *pos_channel, *pos_comma;
struct t_irc_server *ptr_server; struct t_irc_server *ptr_server;
/* make C compiler happy */ /* make C compiler happy */
@@ -106,8 +106,8 @@ irc_info_info_irc_is_nick_cb (const void *pointer, void *data,
const char *info_name, const char *info_name,
const char *arguments) const char *arguments)
{ {
char *pos_comma, *server; char *server;
const char *pos_nick; const char *pos_nick, *pos_comma;
struct t_irc_server *ptr_server; struct t_irc_server *ptr_server;
/* make C compiler happy */ /* make C compiler happy */
@@ -233,8 +233,8 @@ irc_info_info_irc_buffer_cb (const void *pointer, void *data,
const char *info_name, const char *info_name,
const char *arguments) const char *arguments)
{ {
char *pos_comma, *pos_comma2, *server, *channel, *host; char *server, *channel, *host;
const char *nick; const char *nick, *pos_comma, *pos_comma2;
struct t_irc_server *ptr_server; struct t_irc_server *ptr_server;
struct t_irc_channel *ptr_channel; struct t_irc_channel *ptr_channel;
@@ -332,8 +332,8 @@ irc_info_info_irc_server_isupport_cb (const void *pointer, void *data,
const char *info_name, const char *info_name,
const char *arguments) const char *arguments)
{ {
char *pos_comma, *server; char *server;
const char *isupport_value; const char *isupport_value, *pos_comma;
struct t_irc_server *ptr_server; struct t_irc_server *ptr_server;
/* make C compiler happy */ /* make C compiler happy */
@@ -373,8 +373,8 @@ irc_info_info_irc_server_isupport_value_cb (const void *pointer, void *data,
const char *info_name, const char *info_name,
const char *arguments) const char *arguments)
{ {
char *pos_comma, *server; char *server;
const char *isupport_value; const char *isupport_value, *pos_comma;
struct t_irc_server *ptr_server; struct t_irc_server *ptr_server;
/* make C compiler happy */ /* make C compiler happy */
@@ -414,7 +414,8 @@ irc_info_info_irc_server_cap_cb (const void *pointer, void *data,
const char *info_name, const char *info_name,
const char *arguments) const char *arguments)
{ {
char *pos_comma, *server; char *server;
const char *pos_comma;
int has_cap; int has_cap;
struct t_irc_server *ptr_server; struct t_irc_server *ptr_server;
@@ -455,8 +456,8 @@ irc_info_info_irc_server_cap_value_cb (const void *pointer, void *data,
const char *info_name, const char *info_name,
const char *arguments) const char *arguments)
{ {
char *pos_comma, *server; char *server;
const char *cap_value; const char *cap_value, *pos_comma;
struct t_irc_server *ptr_server; struct t_irc_server *ptr_server;
/* make C compiler happy */ /* make C compiler happy */
@@ -496,8 +497,8 @@ irc_info_info_irc_is_message_ignored_cb (const void *pointer, void *data,
const char *info_name, const char *info_name,
const char *arguments) const char *arguments)
{ {
char *pos_comma, *server; char *server;
const char *pos_message; const char *pos_message, *pos_comma;
struct t_irc_server *ptr_server; struct t_irc_server *ptr_server;
/* make C compiler happy */ /* make C compiler happy */
@@ -984,9 +985,8 @@ irc_info_infolist_irc_modelist_item_cb (const void *pointer, void *data,
struct t_irc_channel *ptr_channel; struct t_irc_channel *ptr_channel;
struct t_irc_modelist *ptr_modelist; struct t_irc_modelist *ptr_modelist;
struct t_irc_modelist_item *ptr_item; struct t_irc_modelist_item *ptr_item;
char **argv, *error; char **argv;
int argc; int argc, number;
long number;
/* make C compiler happy */ /* make C compiler happy */
(void) pointer; (void) pointer;
@@ -1028,15 +1028,12 @@ irc_info_infolist_irc_modelist_item_cb (const void *pointer, void *data,
} }
if (!obj_pointer && (argc >= 4)) if (!obj_pointer && (argc >= 4))
{ {
error = NULL; if (!weechat_util_parse_int (argv[3], 10, &number) || (number < 0))
number = strtol (argv[3], &error, 10);
if (!error || error[0] || (number < 0))
{ {
weechat_string_free_split (argv); weechat_string_free_split (argv);
return NULL; return NULL;
} }
obj_pointer = irc_modelist_item_search_number (ptr_modelist, obj_pointer = irc_modelist_item_search_number (ptr_modelist, number);
(int)number);
if (!obj_pointer) if (!obj_pointer)
{ {
weechat_string_free_split (argv); weechat_string_free_split (argv);
+1 -1
View File
@@ -457,7 +457,7 @@ irc_input_send_cb (const void *pointer, void *data,
const char *type_data, void *signal_data) const char *type_data, void *signal_data)
{ {
const char *ptr_string, *ptr_message; const char *ptr_string, *ptr_message;
char *pos_semicol1, *pos_semicol2, *pos_semicol3, *pos_semicol4; const char *pos_semicol1, *pos_semicol2, *pos_semicol3, *pos_semicol4;
char *server, *channel, *options, *tags, *data_with_colors, **list_options; char *server, *channel, *options, *tags, *data_with_colors, **list_options;
int i, num_options, flags, force_user_message; int i, num_options, flags, force_user_message;
struct t_irc_server *ptr_server; struct t_irc_server *ptr_server;
+13 -18
View File
@@ -234,9 +234,8 @@ int
irc_list_channel_match_filter (struct t_irc_server *server, irc_list_channel_match_filter (struct t_irc_server *server,
struct t_irc_list_channel *channel) struct t_irc_list_channel *channel)
{ {
char *error, *result; char *result;
long number; int match, number;
int match;
/* no filter? then any channel is matching */ /* no filter? then any channel is matching */
if (!server->list->filter) if (!server->list->filter)
@@ -280,25 +279,22 @@ irc_list_channel_match_filter (struct t_irc_server *server,
else if (strncmp (server->list->filter, "u:>", 3) == 0) else if (strncmp (server->list->filter, "u:>", 3) == 0)
{ {
/* filter by users (> N)*/ /* filter by users (> N)*/
error = NULL; if (weechat_util_parse_int (server->list->filter + 3, 10, &number)
number = strtol (server->list->filter + 3, &error, 10); && (channel->users > number))
if (error && !error[0] && channel->users > (int)number)
return 1; return 1;
} }
else if (strncmp (server->list->filter, "u:<", 3) == 0) else if (strncmp (server->list->filter, "u:<", 3) == 0)
{ {
/* filter by users (< N)*/ /* filter by users (< N)*/
error = NULL; if (weechat_util_parse_int (server->list->filter + 3, 10, &number)
number = strtol (server->list->filter + 3, &error, 10); && (channel->users < number))
if (error && !error[0] && channel->users < (int)number)
return 1; return 1;
} }
else if (strncmp (server->list->filter, "u:", 2) == 0) else if (strncmp (server->list->filter, "u:", 2) == 0)
{ {
/* filter by users */ /* filter by users */
error = NULL; if (weechat_util_parse_int (server->list->filter + 2, 10, &number)
number = strtol (server->list->filter + 2, &error, 10); && (channel->users >= number))
if (error && !error[0] && channel->users >= (int)number)
return 1; return 1;
} }
else else
@@ -375,10 +371,9 @@ int
irc_list_parse_messages (struct t_irc_server *server, const char *output) irc_list_parse_messages (struct t_irc_server *server, const char *output)
{ {
struct t_irc_list_channel *channel; struct t_irc_list_channel *channel;
char **irc_msgs, *command, **params, *error; char **irc_msgs, *command, **params;
const char *ptr_name; const char *ptr_name;
int i, count_irc_msgs, num_params, length, keep_colors; int i, count_irc_msgs, num_params, length, keep_colors, number;
long number;
if (server->list->channels) if (server->list->channels)
{ {
@@ -439,9 +434,9 @@ irc_list_parse_messages (struct t_irc_server *server, const char *output)
ptr_name++; ptr_name++;
} }
channel->name2 = strdup (ptr_name); channel->name2 = strdup (ptr_name);
error = NULL; if (!weechat_util_parse_int (params[2], 10, &number))
number = strtol (params[2], &error, 10); number = 0;
channel->users = (error && !error[0]) ? number : 0; channel->users = number;
channel->topic = (num_params > 3) ? channel->topic = (num_params > 3) ?
irc_color_decode (params[3], keep_colors) : NULL; irc_color_decode (params[3], keep_colors) : NULL;
length = weechat_utf8_strlen_screen (channel->name); length = weechat_utf8_strlen_screen (channel->name);
+12 -15
View File
@@ -598,8 +598,7 @@ irc_message_parse_cap_multiline_value (struct t_irc_server *server,
{ {
struct t_hashtable *values; struct t_hashtable *values;
const char *ptr_value; const char *ptr_value;
char *error; int number;
long number;
if (!server) if (!server)
return; return;
@@ -617,18 +616,14 @@ irc_message_parse_cap_multiline_value (struct t_irc_server *server,
ptr_value = (const char *)weechat_hashtable_get (values, "max-bytes"); ptr_value = (const char *)weechat_hashtable_get (values, "max-bytes");
if (ptr_value) if (ptr_value)
{ {
error = NULL; if (weechat_util_parse_int (ptr_value, 10, &number))
number = strtol (ptr_value, &error, 10);
if (error && !error[0])
server->multiline_max_bytes = number; server->multiline_max_bytes = number;
} }
ptr_value = (const char *)weechat_hashtable_get (values, "max-lines"); ptr_value = (const char *)weechat_hashtable_get (values, "max-lines");
if (ptr_value) if (ptr_value)
{ {
error = NULL; if (weechat_util_parse_int (ptr_value, 10, &number))
number = strtol (ptr_value, &error, 10);
if (error && !error[0])
server->multiline_max_lines = number; server->multiline_max_lines = number;
} }
@@ -707,8 +702,8 @@ const char *
irc_message_get_nick_from_host (const char *host) irc_message_get_nick_from_host (const char *host)
{ {
static char nick[128]; static char nick[128];
char host2[128], *pos_space, *pos; char host2[128];
const char *ptr_host; const char *ptr_host, *pos_space, *pos;
if (!host) if (!host)
return NULL; return NULL;
@@ -756,8 +751,8 @@ const char *
irc_message_get_address_from_host (const char *host) irc_message_get_address_from_host (const char *host)
{ {
static char address[256]; static char address[256];
char host2[256], *pos_space, *pos; char host2[256];
const char *ptr_host; const char *ptr_host, *pos_space, *pos;
if (!host) if (!host)
return NULL; return NULL;
@@ -1182,8 +1177,9 @@ irc_message_split_join (struct t_irc_message_split_context *context,
{ {
int channels_count, keys_count, length, length_no_channel; int channels_count, keys_count, length, length_no_channel;
int length_to_add, index_channel; int length_to_add, index_channel;
char **channels, **keys, *pos, *str; char **channels, **keys, *str;
char msg_to_send[16384], keys_to_add[16384]; char msg_to_send[16384], keys_to_add[16384];
const char *pos;
max_length -= 2; /* by default: 512 - 2 = 510 bytes */ max_length -= 2; /* by default: 512 - 2 = 510 bytes */
@@ -1510,7 +1506,7 @@ irc_message_split_privmsg_notice (struct t_irc_message_split_context *context,
int int
irc_message_split_005 (struct t_irc_message_split_context *context, irc_message_split_005 (struct t_irc_message_split_context *context,
const char *tags, const char *host, const char *command, const char *tags, const char *host, const char *command,
const char *target, const char *arguments, const char *target, char *arguments,
int max_length) int max_length)
{ {
char *pos, suffix[4096]; char *pos, suffix[4096];
@@ -1570,7 +1566,8 @@ irc_message_split (struct t_irc_server *server, const char *message)
{ {
struct t_irc_message_split_context split_context; struct t_irc_message_split_context split_context;
char **argv, **argv_eol, *tags, *host, *command, *arguments, target[4096]; char **argv, **argv_eol, *tags, *host, *command, *arguments, target[4096];
char *pos, monitor_action[3]; char monitor_action[3];
const char *pos;
int split_ok, split_privmsg, argc, index_args, max_length_nick; int split_ok, split_privmsg, argc, index_args, max_length_nick;
int max_length_user, max_length_host, max_length_nick_user_host; int max_length_user, max_length_host, max_length_nick_user_host;
int split_msg_max_length, multiline, multiline_max_bytes; int split_msg_max_length, multiline, multiline_max_bytes;
+2 -2
View File
@@ -104,8 +104,8 @@ irc_mode_get_arguments_colors (const char *arguments)
char char
irc_mode_get_chanmode_type (struct t_irc_server *server, char chanmode) irc_mode_get_chanmode_type (struct t_irc_server *server, char chanmode)
{ {
char chanmode_type, *pos; char chanmode_type;
const char *chanmodes, *ptr_chanmodes; const char *chanmodes, *ptr_chanmodes, *pos;
/* /*
* assume it is type 'B' if mode is in prefix * assume it is type 'B' if mode is in prefix
+2 -3
View File
@@ -785,9 +785,8 @@ int
irc_notify_hsignal_cb (const void *pointer, void *data, const char *signal, irc_notify_hsignal_cb (const void *pointer, void *data, const char *signal,
struct t_hashtable *hashtable) struct t_hashtable *hashtable)
{ {
const char *error, *server, *pattern, *command, *output; const char *error, *server, *pattern, *command, *output, *ptr_args;
char **messages, **nicks_sent, **nicks_recv, *irc_cmd, *arguments; char **messages, **nicks_sent, **nicks_recv, *irc_cmd, *arguments, *pos;
char *ptr_args, *pos;
int i, j, num_messages, num_nicks_sent, num_nicks_recv, nick_was_sent; int i, j, num_messages, num_nicks_sent, num_nicks_recv, nick_was_sent;
int away_message_updated, no_such_nick; int away_message_updated, no_such_nick;
struct t_irc_server *ptr_server; struct t_irc_server *ptr_server;
+19 -31
View File
@@ -2499,8 +2499,8 @@ IRC_PROTOCOL_CALLBACK(note)
IRC_PROTOCOL_CALLBACK(notice) IRC_PROTOCOL_CALLBACK(notice)
{ {
char *notice_args, *pos, end_char, *channel, str_tags[1024]; char *notice_args, end_char, *channel, str_tags[1024];
const char *pos_target, *pos_args, *nick_address; const char *pos, *pos_target, *pos_args, *nick_address;
struct t_irc_channel *ptr_channel; struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick; struct t_irc_nick *ptr_nick;
int notify_private, is_channel, is_channel_orig, display_host; int notify_private, is_channel, is_channel_orig, display_host;
@@ -4061,9 +4061,8 @@ IRC_PROTOCOL_CALLBACK(001)
IRC_PROTOCOL_CALLBACK(005) IRC_PROTOCOL_CALLBACK(005)
{ {
char *str_info, *error, *isupport2; char *str_info, *isupport2;
int i, arg_last, length_isupport, length, casemapping, utf8mapping; int i, arg_last, length_isupport, length, casemapping, utf8mapping, value;
long value;
IRC_PROTOCOL_MIN_PARAMS(2); IRC_PROTOCOL_MIN_PARAMS(2);
@@ -4081,34 +4080,26 @@ IRC_PROTOCOL_CALLBACK(005)
else if (strncmp (ctxt->params[i], "LINELEN=", 8) == 0) else if (strncmp (ctxt->params[i], "LINELEN=", 8) == 0)
{ {
/* save max message length */ /* save max message length */
error = NULL; if (weechat_util_parse_int (ctxt->params[i] + 8, 10, &value) && (value > 0))
value = strtol (ctxt->params[i] + 8, &error, 10); ctxt->server->msg_max_length = value;
if (error && !error[0] && (value > 0))
ctxt->server->msg_max_length = (int)value;
} }
else if (strncmp (ctxt->params[i], "NICKLEN=", 8) == 0) else if (strncmp (ctxt->params[i], "NICKLEN=", 8) == 0)
{ {
/* save max nick length */ /* save max nick length */
error = NULL; if (weechat_util_parse_int (ctxt->params[i] + 8, 10, &value) && (value > 0))
value = strtol (ctxt->params[i] + 8, &error, 10); ctxt->server->nick_max_length = value;
if (error && !error[0] && (value > 0))
ctxt->server->nick_max_length = (int)value;
} }
else if (strncmp (ctxt->params[i], "USERLEN=", 8) == 0) else if (strncmp (ctxt->params[i], "USERLEN=", 8) == 0)
{ {
/* save max user length */ /* save max user length */
error = NULL; if (weechat_util_parse_int (ctxt->params[i] + 8, 10, &value) && (value > 0))
value = strtol (ctxt->params[i] + 8, &error, 10); ctxt->server->user_max_length = value;
if (error && !error[0] && (value > 0))
ctxt->server->user_max_length = (int)value;
} }
else if (strncmp (ctxt->params[i], "HOSTLEN=", 8) == 0) else if (strncmp (ctxt->params[i], "HOSTLEN=", 8) == 0)
{ {
/* save max host length */ /* save max host length */
error = NULL; if (weechat_util_parse_int (ctxt->params[i] + 8, 10, &value) && (value > 0))
value = strtol (ctxt->params[i] + 8, &error, 10); ctxt->server->host_max_length = value;
if (error && !error[0] && (value > 0))
ctxt->server->host_max_length = (int)value;
} }
else if (strncmp (ctxt->params[i], "CASEMAPPING=", 12) == 0) else if (strncmp (ctxt->params[i], "CASEMAPPING=", 12) == 0)
{ {
@@ -4144,10 +4135,8 @@ IRC_PROTOCOL_CALLBACK(005)
else if (strncmp (ctxt->params[i], "MONITOR=", 8) == 0) else if (strncmp (ctxt->params[i], "MONITOR=", 8) == 0)
{ {
/* save monitor (limit) */ /* save monitor (limit) */
error = NULL; if (weechat_util_parse_int (ctxt->params[i] + 8, 10, &value) && (value > 0))
value = strtol (ctxt->params[i] + 8, &error, 10); ctxt->server->monitor = value;
if (error && !error[0] && (value > 0))
ctxt->server->monitor = (int)value;
} }
else if (strncmp (ctxt->params[i], "CLIENTTAGDENY=", 14) == 0) else if (strncmp (ctxt->params[i], "CLIENTTAGDENY=", 14) == 0)
{ {
@@ -7921,12 +7910,11 @@ irc_protocol_recv_command (struct t_irc_server *server,
int ignore_batch_tag) int ignore_batch_tag)
{ {
int i, cmd_found, return_code, ignored; int i, cmd_found, return_code, ignored;
char *pos_space, *tags;
struct t_irc_channel *ptr_channel; struct t_irc_channel *ptr_channel;
t_irc_recv_func *cmd_recv_func; t_irc_recv_func *cmd_recv_func;
const char *ptr_msg_after_tags, *ptr_batch_ref, *ptr_tag_time; const char *ptr_msg_after_tags, *ptr_batch_ref, *ptr_tag_time;
const char *nick1, *address1, *host1; const char *pos_space, *nick1, *address1, *host1;
char *host, *host_no_color; char *tags, *host, *host_no_color, *pos_space_host;
struct t_irc_protocol_ctxt ctxt; struct t_irc_protocol_ctxt ctxt;
struct timeval tv; struct timeval tv;
@@ -8198,9 +8186,9 @@ irc_protocol_recv_command (struct t_irc_server *server,
host = (host1) ? strdup (host1) : NULL; host = (host1) ? strdup (host1) : NULL;
if (host) if (host)
{ {
pos_space = strchr (host, ' '); pos_space_host = strchr (host, ' ');
if (pos_space) if (pos_space_host)
pos_space[0] = '\0'; pos_space_host[0] = '\0';
} }
host_no_color = (host) ? irc_color_decode (host, 0) : NULL; host_no_color = (host) ? irc_color_decode (host, 0) : NULL;
ctxt.host = (host) ? ctxt.host = (host) ?
+7 -18
View File
@@ -404,9 +404,8 @@ irc_redirect_new_with_commands (struct t_irc_server *server,
const char *cmd_filter) const char *cmd_filter)
{ {
struct t_irc_redirect *new_redirect; struct t_irc_redirect *new_redirect;
char **items[4], *item_upper, *pos, *error; char **items[4], *item_upper, *pos;
int i, j, num_items[4]; int i, j, num_items[4], value;
long value;
struct t_hashtable *hash_cmd[4]; struct t_hashtable *hash_cmd[4];
new_redirect = malloc (sizeof (*new_redirect)); new_redirect = malloc (sizeof (*new_redirect));
@@ -460,9 +459,7 @@ irc_redirect_new_with_commands (struct t_irc_server *server,
if (pos) if (pos)
{ {
pos[0] = '\0'; pos[0] = '\0';
error = NULL; if (!weechat_util_parse_int (pos + 1, 10, &value))
value = strtol (pos + 1, &error, 10);
if (!error || error[0])
value = -1; value = -1;
} }
item_upper = weechat_string_toupper (items[i][j]); item_upper = weechat_string_toupper (items[i][j]);
@@ -616,7 +613,7 @@ void
irc_redirect_init_command (struct t_irc_redirect *redirect, irc_redirect_init_command (struct t_irc_redirect *redirect,
const char *command) const char *command)
{ {
char *pos; const char *pos;
if (!redirect) if (!redirect)
return; return;
@@ -1257,7 +1254,6 @@ irc_redirect_pattern_hsignal_cb (const void *pointer, void *data,
struct t_hashtable *hashtable) struct t_hashtable *hashtable)
{ {
const char *pattern, *str_timeout, *cmd_start, *cmd_stop, *cmd_extra; const char *pattern, *str_timeout, *cmd_start, *cmd_stop, *cmd_extra;
char *error;
int number, timeout; int number, timeout;
/* make C compiler happy */ /* make C compiler happy */
@@ -1295,9 +1291,7 @@ irc_redirect_pattern_hsignal_cb (const void *pointer, void *data,
timeout = 0; timeout = 0;
if (str_timeout && str_timeout[0]) if (str_timeout && str_timeout[0])
{ {
error = NULL; if (weechat_util_parse_int (str_timeout, 10, &number))
number = (int)strtol (str_timeout, &error, 10);
if (error && !error[0])
timeout = number; timeout = number;
} }
@@ -1325,7 +1319,6 @@ irc_redirect_command_hsignal_cb (const void *pointer, void *data,
{ {
const char *server, *pattern, *redirect_signal, *str_count, *string; const char *server, *pattern, *redirect_signal, *str_count, *string;
const char *str_timeout, *cmd_filter; const char *str_timeout, *cmd_filter;
char *error;
struct t_irc_server *ptr_server; struct t_irc_server *ptr_server;
int number, count, timeout; int number, count, timeout;
@@ -1366,18 +1359,14 @@ irc_redirect_command_hsignal_cb (const void *pointer, void *data,
count = 1; count = 1;
if (str_count && str_count[0]) if (str_count && str_count[0])
{ {
error = NULL; if (weechat_util_parse_int (str_count, 10, &number))
number = (int)strtol (str_count, &error, 10);
if (error && !error[0])
count = number; count = number;
} }
timeout = 0; timeout = 0;
if (str_timeout && str_timeout[0]) if (str_timeout && str_timeout[0])
{ {
error = NULL; if (weechat_util_parse_int (str_timeout, 10, &number))
number = (int)strtol (str_timeout, &error, 10);
if (error && !error[0])
timeout = number; timeout = number;
} }
+5 -7
View File
@@ -109,7 +109,7 @@ irc_sasl_mechanism_scram (struct t_irc_server *server,
const char *sasl_password, const char *sasl_password,
char **sasl_error) char **sasl_error)
{ {
char *answer_base64, *string, *username, *username2, *data, **attrs, *error; char *answer_base64, *string, *username, *username2, *data, **attrs;
char nonce_client[18], nonce_client_base64[24 + 1], *nonce_server; char nonce_client[18], nonce_client_base64[24 + 1], *nonce_server;
char *salt_base64, *salt, *verifier_base64, *verifier, *attr_error; char *salt_base64, *salt, *verifier_base64, *verifier, *attr_error;
char *auth_no_proof, *auth_message; char *auth_no_proof, *auth_message;
@@ -117,10 +117,10 @@ irc_sasl_mechanism_scram (struct t_irc_server *server,
char client_signature[512 / 8], client_proof[512 / 8]; char client_signature[512 / 8], client_proof[512 / 8];
char client_proof_base64[((512 / 8) * 4) + 1], server_key[512 / 8]; char client_proof_base64[((512 / 8) * 4) + 1], server_key[512 / 8];
char server_signature[512 / 8]; char server_signature[512 / 8];
int i, rc, length, num_attrs, iterations, salt_size, salted_password_size; int i, rc, length, num_attrs, iterations, number;
int salt_size, salted_password_size;
int client_key_size, stored_key_size, client_signature_size; int client_key_size, stored_key_size, client_signature_size;
int server_key_size, server_signature_size, verifier_size; int server_key_size, server_signature_size, verifier_size;
long number;
if (!server || !hash_algo || !data_base64 || !sasl_username if (!server || !hash_algo || !data_base64 || !sasl_username
|| !sasl_password) || !sasl_password)
@@ -202,10 +202,8 @@ irc_sasl_mechanism_scram (struct t_irc_server *server,
} }
else if (strncmp (attrs[i], "i=", 2) == 0) else if (strncmp (attrs[i], "i=", 2) == 0)
{ {
error = NULL; if (weechat_util_parse_int (attrs[i] + 2, 10, &number))
number = strtol (attrs[i] + 2, &error, 10); iterations = number;
if (error && !error[0])
iterations = (int)number;
} }
else if (strncmp (attrs[i], "v=", 2) == 0) else if (strncmp (attrs[i], "v=", 2) == 0)
{ {
+155 -169
View File
@@ -588,7 +588,7 @@ irc_server_sasl_enabled (struct t_irc_server *server)
char * char *
irc_server_get_name_without_port (const char *name) irc_server_get_name_without_port (const char *name)
{ {
char *pos; const char *pos;
if (!name) if (!name)
return NULL; return NULL;
@@ -676,10 +676,9 @@ int
irc_server_set_addresses (struct t_irc_server *server, const char *addresses, irc_server_set_addresses (struct t_irc_server *server, const char *addresses,
int tls) int tls)
{ {
int rc, i, default_port; int rc, i, default_port, number;
char *pos, *error, *addresses_eval; char *pos, *addresses_eval;
const char *ptr_addresses; const char *ptr_addresses;
long number;
if (!server) if (!server)
return 0; return 0;
@@ -753,19 +752,14 @@ irc_server_set_addresses (struct t_irc_server *server, const char *addresses,
server->addresses_count * sizeof (server->retry_array[0])); server->addresses_count * sizeof (server->retry_array[0]));
for (i = 0; i < server->addresses_count; i++) for (i = 0; i < server->addresses_count; i++)
{ {
server->ports_array[i] = default_port;
pos = strchr (server->addresses_array[i], '/'); pos = strchr (server->addresses_array[i], '/');
if (pos) if (pos)
{ {
pos[0] = 0; pos[0] = 0;
pos++; pos++;
error = NULL; if (weechat_util_parse_int (pos, 10, &number))
number = strtol (pos, &error, 10); server->ports_array[i] = number;
server->ports_array[i] = (error && !error[0]) ?
number : default_port;
}
else
{
server->ports_array[i] = default_port;
} }
server->retry_array[i] = 0; server->retry_array[i] = 0;
} }
@@ -1134,7 +1128,7 @@ void
irc_server_set_prefix_modes_chars (struct t_irc_server *server, irc_server_set_prefix_modes_chars (struct t_irc_server *server,
const char *prefix) const char *prefix)
{ {
char *pos; const char *pos;
int i, old_length_chars, length_modes, length_chars; int i, old_length_chars, length_modes, length_chars;
if (!server || !prefix) if (!server || !prefix)
@@ -1379,8 +1373,7 @@ irc_server_get_prefix_chars (struct t_irc_server *server)
int int
irc_server_get_prefix_mode_index (struct t_irc_server *server, char mode) irc_server_get_prefix_mode_index (struct t_irc_server *server, char mode)
{ {
const char *prefix_modes; const char *prefix_modes, *pos;
char *pos;
if (server) if (server)
{ {
@@ -1405,8 +1398,7 @@ int
irc_server_get_prefix_char_index (struct t_irc_server *server, irc_server_get_prefix_char_index (struct t_irc_server *server,
char prefix_char) char prefix_char)
{ {
const char *prefix_chars; const char *prefix_chars, *pos;
char *pos;
if (server) if (server)
{ {
@@ -1520,18 +1512,14 @@ int
irc_server_get_max_modes (struct t_irc_server *server) irc_server_get_max_modes (struct t_irc_server *server)
{ {
const char *support_modes; const char *support_modes;
char *error; int max_modes, number;
long number;
int max_modes;
max_modes = 4; max_modes = 4;
support_modes = irc_server_get_isupport_value (server, "MODES"); support_modes = irc_server_get_isupport_value (server, "MODES");
if (support_modes) if (support_modes)
{ {
error = NULL; if (weechat_util_parse_int (support_modes, 10, &number))
number = strtol (support_modes, &error, 10);
if (error && !error[0])
{ {
max_modes = number; max_modes = number;
if (max_modes < 1) if (max_modes < 1)
@@ -2443,8 +2431,8 @@ irc_server_copy (struct t_irc_server *server, const char *new_name)
{ {
struct t_irc_server *new_server; struct t_irc_server *new_server;
struct t_infolist *infolist; struct t_infolist *infolist;
char *mask, *pos; const char *option_name, *pos;
const char *option_name; char *mask;
int index_option; int index_option;
/* check if another server exists with this name */ /* check if another server exists with this name */
@@ -2502,9 +2490,9 @@ irc_server_copy (struct t_irc_server *server, const char *new_name)
int int
irc_server_rename (struct t_irc_server *server, const char *new_name) irc_server_rename (struct t_irc_server *server, const char *new_name)
{ {
char *mask, *pos_option, *new_option_name, charset_modifier[1024]; char *mask, *new_option_name, charset_modifier[1024];
char *buffer_name; char *buffer_name;
const char *option_name; const char *option_name, *pos_option;
struct t_infolist *infolist; struct t_infolist *infolist;
struct t_config_option *ptr_option; struct t_config_option *ptr_option;
struct t_irc_channel *ptr_channel; struct t_irc_channel *ptr_channel;
@@ -2999,8 +2987,8 @@ irc_server_send_one_msg (struct t_irc_server *server, int flags,
const char *tags) const char *tags)
{ {
static char buffer[4096]; static char buffer[4096];
const char *ptr_msg, *ptr_chan_nick; const char *ptr_chan_nick;
char *new_msg, *pos, *tags_to_send, *msg_encoded; char *new_msg, *ptr_msg, *pos, *tags_to_send, *msg_encoded;
char str_modifier[128], modifier_data[1024]; char str_modifier[128], modifier_data[1024];
int first_message, queue_msg, pos_channel, pos_text, pos_encode; int first_message, queue_msg, pos_channel, pos_text, pos_encode;
struct t_irc_redirect *ptr_redirect; struct t_irc_redirect *ptr_redirect;
@@ -3013,150 +3001,148 @@ irc_server_send_one_msg (struct t_irc_server *server, int flags,
server->name, server->name,
message); message);
/* no changes in new message */ /* message dropped? */
if (new_msg && (strcmp (message, new_msg) == 0)) if (new_msg && !new_msg[0])
{
free (new_msg);
new_msg = NULL;
}
/* message not dropped? */
if (!new_msg || new_msg[0])
{
first_message = 1;
ptr_msg = (new_msg) ? new_msg : message;
msg_encoded = NULL;
irc_message_parse (server,
ptr_msg,
NULL, /* tags */
NULL, /* message_without_tags */
NULL, /* nick */
NULL, /* user */
NULL, /* host */
NULL, /* command */
NULL, /* channel */
NULL, /* arguments */
NULL, /* text */
NULL, /* params */
NULL, /* num_params */
NULL, /* pos_command */
NULL, /* pos_arguments */
&pos_channel,
&pos_text);
switch (IRC_SERVER_OPTION_ENUM(server,
IRC_SERVER_OPTION_CHARSET_MESSAGE))
{
case IRC_SERVER_CHARSET_MESSAGE_MESSAGE:
pos_encode = 0;
break;
case IRC_SERVER_CHARSET_MESSAGE_CHANNEL:
pos_encode = (pos_channel >= 0) ? pos_channel : pos_text;
break;
case IRC_SERVER_CHARSET_MESSAGE_TEXT:
pos_encode = pos_text;
break;
default:
pos_encode = 0;
break;
}
if (pos_encode >= 0)
{
ptr_chan_nick = (channel) ? channel : nick;
if (ptr_chan_nick)
{
snprintf (modifier_data, sizeof (modifier_data),
"%s.%s.%s",
weechat_plugin->name,
server->name,
ptr_chan_nick);
}
else
{
snprintf (modifier_data, sizeof (modifier_data),
"%s.%s",
weechat_plugin->name,
server->name);
}
/*
* when UTF8ONLY is enabled, clients must not send non-UTF-8 data
* to the server; the charset encoding below is then done only if
* UTF8ONLY is *NOT* enabled
* (see: https://ircv3.net/specs/extensions/utf8-only)
*/
if (!server->utf8only)
{
msg_encoded = irc_message_convert_charset (ptr_msg, pos_encode,
"charset_encode",
modifier_data);
}
}
if (msg_encoded)
ptr_msg = msg_encoded;
while (ptr_msg && ptr_msg[0])
{
pos = strchr (ptr_msg, '\n');
if (pos)
pos[0] = '\0';
snprintf (buffer, sizeof (buffer), "%s\r\n", ptr_msg);
if (flags & IRC_SERVER_SEND_OUTQ_PRIO_IMMEDIATE)
queue_msg = 0;
else if (flags & IRC_SERVER_SEND_OUTQ_PRIO_HIGH)
queue_msg = 1;
else if (flags & IRC_SERVER_SEND_OUTQ_PRIO_LOW)
queue_msg = 2;
else
{
/*
* if connected to server (message 001 received), consider
* it's low priority (otherwise send immediately)
*/
queue_msg = (server->is_connected) ? 2 : 0;
}
tags_to_send = irc_server_get_tags_to_send (tags);
ptr_redirect = irc_redirect_search_available (server);
/* queue message (do not send anything now) */
irc_server_outqueue_add (server,
queue_msg,
command,
(new_msg && first_message) ? message : NULL,
buffer,
(new_msg) ? 1 : 0,
tags_to_send,
ptr_redirect);
/* mark redirect as "used" */
if (ptr_redirect)
ptr_redirect->assigned_to_command = 1;
free (tags_to_send);
if (pos)
{
pos[0] = '\n';
ptr_msg = pos + 1;
}
else
ptr_msg = NULL;
first_message = 0;
}
free (msg_encoded);
}
else
{ {
irc_raw_print (server, IRC_RAW_FLAG_SEND | IRC_RAW_FLAG_MODIFIED, irc_raw_print (server, IRC_RAW_FLAG_SEND | IRC_RAW_FLAG_MODIFIED,
_("(message dropped)")); _("(message dropped)"));
free (new_msg);
return;
} }
if (!new_msg)
new_msg = strdup (message);
if (!new_msg)
return;
first_message = 1;
ptr_msg = new_msg;
msg_encoded = NULL;
irc_message_parse (server,
ptr_msg,
NULL, /* tags */
NULL, /* message_without_tags */
NULL, /* nick */
NULL, /* user */
NULL, /* host */
NULL, /* command */
NULL, /* channel */
NULL, /* arguments */
NULL, /* text */
NULL, /* params */
NULL, /* num_params */
NULL, /* pos_command */
NULL, /* pos_arguments */
&pos_channel,
&pos_text);
switch (IRC_SERVER_OPTION_ENUM(server,
IRC_SERVER_OPTION_CHARSET_MESSAGE))
{
case IRC_SERVER_CHARSET_MESSAGE_MESSAGE:
pos_encode = 0;
break;
case IRC_SERVER_CHARSET_MESSAGE_CHANNEL:
pos_encode = (pos_channel >= 0) ? pos_channel : pos_text;
break;
case IRC_SERVER_CHARSET_MESSAGE_TEXT:
pos_encode = pos_text;
break;
default:
pos_encode = 0;
break;
}
if (pos_encode >= 0)
{
ptr_chan_nick = (channel) ? channel : nick;
if (ptr_chan_nick)
{
snprintf (modifier_data, sizeof (modifier_data),
"%s.%s.%s",
weechat_plugin->name,
server->name,
ptr_chan_nick);
}
else
{
snprintf (modifier_data, sizeof (modifier_data),
"%s.%s",
weechat_plugin->name,
server->name);
}
/*
* when UTF8ONLY is enabled, clients must not send non-UTF-8 data
* to the server; the charset encoding below is then done only if
* UTF8ONLY is *NOT* enabled
* (see: https://ircv3.net/specs/extensions/utf8-only)
*/
if (!server->utf8only)
{
msg_encoded = irc_message_convert_charset (ptr_msg, pos_encode,
"charset_encode",
modifier_data);
}
}
if (msg_encoded)
ptr_msg = msg_encoded;
while (ptr_msg && ptr_msg[0])
{
pos = strchr (ptr_msg, '\n');
if (pos)
pos[0] = '\0';
snprintf (buffer, sizeof (buffer), "%s\r\n", ptr_msg);
if (flags & IRC_SERVER_SEND_OUTQ_PRIO_IMMEDIATE)
queue_msg = 0;
else if (flags & IRC_SERVER_SEND_OUTQ_PRIO_HIGH)
queue_msg = 1;
else if (flags & IRC_SERVER_SEND_OUTQ_PRIO_LOW)
queue_msg = 2;
else
{
/*
* if connected to server (message 001 received), consider
* it's low priority (otherwise send immediately)
*/
queue_msg = (server->is_connected) ? 2 : 0;
}
tags_to_send = irc_server_get_tags_to_send (tags);
ptr_redirect = irc_redirect_search_available (server);
/* queue message (do not send anything now) */
irc_server_outqueue_add (server,
queue_msg,
command,
(new_msg && first_message) ? message : NULL,
buffer,
(new_msg) ? 1 : 0,
tags_to_send,
ptr_redirect);
/* mark redirect as "used" */
if (ptr_redirect)
ptr_redirect->assigned_to_command = 1;
free (tags_to_send);
if (pos)
{
pos[0] = '\n';
ptr_msg = pos + 1;
}
else
ptr_msg = NULL;
first_message = 0;
}
free (msg_encoded);
free (new_msg); free (new_msg);
} }
@@ -3450,7 +3436,7 @@ irc_server_msgq_add_unterminated (struct t_irc_server *server,
*/ */
void void
irc_server_msgq_add_buffer (struct t_irc_server *server, const char *buffer) irc_server_msgq_add_buffer (struct t_irc_server *server, char *buffer)
{ {
char *pos_cr, *pos_lf; char *pos_cr, *pos_lf;
+1 -1
View File
@@ -427,7 +427,7 @@ extern struct t_arraylist *irc_server_sendf (struct t_irc_server *server,
const char *tags, const char *tags,
const char *format, ...); const char *format, ...);
extern void irc_server_msgq_add_buffer (struct t_irc_server *server, extern void irc_server_msgq_add_buffer (struct t_irc_server *server,
const char *buffer); char *buffer);
extern void irc_server_msgq_flush (void); extern void irc_server_msgq_flush (void);
extern void irc_server_set_buffer_title (struct t_irc_server *server); extern void irc_server_set_buffer_title (struct t_irc_server *server);
extern struct t_gui_buffer *irc_server_create_buffer (struct t_irc_server *server); extern struct t_gui_buffer *irc_server_create_buffer (struct t_irc_server *server);
+13 -24
View File
@@ -356,11 +356,10 @@ irc_upgrade_read_cb (const void *pointer, void *data,
int object_id, int object_id,
struct t_infolist *infolist) struct t_infolist *infolist)
{ {
int flags, sock, size, i, index, nicks_count, num_items, utf8mapping; int flags, sock, size, i, index, nicks_count, num_items, number, utf8mapping;
long number; long long number_longlong;
time_t join_time; time_t join_time;
char *buf, option_name[64], **nicks, *nick_join, *pos, *error; char *buf, option_name[64], **nicks, *nick_join, *pos, **items;
char **items;
const char *buffer_name, *str, *nick; const char *buffer_name, *str, *nick;
struct t_irc_server *ptr_server; struct t_irc_server *ptr_server;
struct t_irc_nick *ptr_nick; struct t_irc_nick *ptr_nick;
@@ -521,10 +520,8 @@ irc_upgrade_read_cb (const void *pointer, void *data,
"LINELEN"); "LINELEN");
if (str) if (str)
{ {
error = NULL; if (weechat_util_parse_int (str, 10, &number))
number = strtol (str, &error, 10); irc_upgrade_current_server->msg_max_length = number;
if (error && !error[0])
irc_upgrade_current_server->msg_max_length = (int)number;
} }
} }
irc_upgrade_current_server->nick_max_length = weechat_infolist_integer (infolist, "nick_max_length"); irc_upgrade_current_server->nick_max_length = weechat_infolist_integer (infolist, "nick_max_length");
@@ -540,10 +537,8 @@ irc_upgrade_read_cb (const void *pointer, void *data,
"USERLEN"); "USERLEN");
if (str) if (str)
{ {
error = NULL; if (weechat_util_parse_int (str, 10, &number))
number = strtol (str, &error, 10); irc_upgrade_current_server->user_max_length = number;
if (error && !error[0])
irc_upgrade_current_server->user_max_length = (int)number;
} }
} }
/* "host_max_length" is new in WeeChat 2.6 */ /* "host_max_length" is new in WeeChat 2.6 */
@@ -558,10 +553,8 @@ irc_upgrade_read_cb (const void *pointer, void *data,
"HOSTLEN"); "HOSTLEN");
if (str) if (str)
{ {
error = NULL; if (weechat_util_parse_int (str, 10, &number))
number = strtol (str, &error, 10); irc_upgrade_current_server->host_max_length = number;
if (error && !error[0])
irc_upgrade_current_server->host_max_length = (int)number;
} }
} }
irc_upgrade_current_server->casemapping = weechat_infolist_integer (infolist, "casemapping"); irc_upgrade_current_server->casemapping = weechat_infolist_integer (infolist, "casemapping");
@@ -621,10 +614,8 @@ irc_upgrade_read_cb (const void *pointer, void *data,
"MONITOR"); "MONITOR");
if (str) if (str)
{ {
error = NULL; if (weechat_util_parse_int (str, 10, &number))
number = strtol (str, &error, 10); irc_upgrade_current_server->monitor = number;
if (error && !error[0])
irc_upgrade_current_server->monitor = (int)number;
} }
} }
/* "clienttagdeny" is new in WeeChat 3.3 */ /* "clienttagdeny" is new in WeeChat 3.3 */
@@ -771,11 +762,9 @@ irc_upgrade_read_cb (const void *pointer, void *data,
pos - nicks[i]); pos - nicks[i]);
if (nick_join) if (nick_join)
{ {
error = NULL; if (weechat_util_parse_longlong (pos + 1, 10, &number_longlong))
number = strtol (pos + 1, &error, 10);
if (error && !error[0])
{ {
join_time = (time_t)number; join_time = (time_t)number_longlong;
irc_channel_join_smart_filtered_add (irc_upgrade_current_channel, irc_channel_join_smart_filtered_add (irc_upgrade_current_channel,
nick_join, nick_join,
join_time); join_time);
+1 -4
View File
@@ -2982,7 +2982,6 @@ API_FUNC(hook_signal)
API_FUNC(hook_signal_send) API_FUNC(hook_signal_send)
{ {
char *error;
int number, rc; int number, rc;
API_INIT_FUNC(1, "hook_signal_send", "sss", API_RETURN_INT(WEECHAT_RC_ERROR)); API_INIT_FUNC(1, "hook_signal_send", "sss", API_RETURN_INT(WEECHAT_RC_ERROR));
@@ -2998,9 +2997,7 @@ API_FUNC(hook_signal_send)
} }
else if (strcmp (*type_data, WEECHAT_HOOK_SIGNAL_INT) == 0) else if (strcmp (*type_data, WEECHAT_HOOK_SIGNAL_INT) == 0)
{ {
error = NULL; if (weechat_util_parse_int (*signal_data, 10, &number))
number = (int)strtol (*signal_data, &error, 10);
if (error && !error[0])
rc = weechat_hook_signal_send (*signal, *type_data, &number); rc = weechat_hook_signal_send (*signal, *type_data, &number);
else else
rc = WEECHAT_RC_ERROR; rc = WEECHAT_RC_ERROR;
+28 -46
View File
@@ -802,7 +802,8 @@ plugin_api_info_color_rgb2term_cb (const void *pointer, void *data,
const char *info_name, const char *info_name,
const char *arguments) const char *arguments)
{ {
char value[32], *pos, *color; const char *pos;
char value[32], *color;
int rgb, limit; int rgb, limit;
/* make C compiler happy */ /* make C compiler happy */
@@ -903,9 +904,8 @@ plugin_api_info_nick_color_ignore_case_cb (const void *pointer, void *data,
const char *info_name, const char *info_name,
const char *arguments) const char *arguments)
{ {
char **items, *result, *error; char **items, *result;
int num_items, case_range; int num_items, case_range, number;
long number;
/* make C compiler happy */ /* make C compiler happy */
(void) pointer; (void) pointer;
@@ -917,10 +917,8 @@ plugin_api_info_nick_color_ignore_case_cb (const void *pointer, void *data,
case_range = -1; case_range = -1;
if (num_items >= 2) if (num_items >= 2)
{ {
error = NULL; if (util_parse_int (items[1], 10, &number))
number = strtol (items[1], &error, 10); case_range = number;
if (error && !error[0])
case_range = (int)number;
} }
result = gui_nick_find_color ( result = gui_nick_find_color (
@@ -942,9 +940,8 @@ plugin_api_info_nick_color_name_ignore_case_cb (const void *pointer, void *data,
const char *info_name, const char *info_name,
const char *arguments) const char *arguments)
{ {
char **items, *result, *error; char **items, *result;
int num_items, case_range; int num_items, case_range, number;
long number;
/* make C compiler happy */ /* make C compiler happy */
(void) pointer; (void) pointer;
@@ -956,10 +953,8 @@ plugin_api_info_nick_color_name_ignore_case_cb (const void *pointer, void *data,
case_range = -1; case_range = -1;
if (num_items >= 2) if (num_items >= 2)
{ {
error = NULL; if (util_parse_int (items[1], 10, &number))
number = strtol (items[1], &error, 10); case_range = number;
if (error && !error[0])
case_range = (int)number;
} }
result = gui_nick_find_color_name ( result = gui_nick_find_color_name (
@@ -1063,9 +1058,9 @@ plugin_api_info_totp_generate_cb (const void *pointer, void *data,
const char *info_name, const char *info_name,
const char *arguments) const char *arguments)
{ {
char **argv, *ptr_secret, *error, *totp; char **argv, *ptr_secret, *totp;
int argc, digits; int argc, digits, number_int;
long number; long long number_longlong;
time_t totp_time; time_t totp_time;
/* make C compiler happy */ /* make C compiler happy */
@@ -1093,19 +1088,15 @@ plugin_api_info_totp_generate_cb (const void *pointer, void *data,
if (argc > 1) if (argc > 1)
{ {
error = NULL; if (!util_parse_longlong (argv[1], 10, &number_longlong) || (number_longlong < 0))
number = (int)strtol (argv[1], &error, 10);
if (!error || error[0] || (number < 0))
goto error; goto error;
totp_time = (time_t)number; totp_time = (time_t)number_longlong;
} }
if (argc > 2) if (argc > 2)
{ {
error = NULL; if (!util_parse_int (argv[2], 10, &number_int) || (number_int < 0))
number = (int)strtol (argv[2], &error, 10);
if (!error || error[0] || (number < 0))
goto error; goto error;
digits = number; digits = number_int;
} }
totp = weecrypto_totp_generate (ptr_secret, totp_time, digits); totp = weecrypto_totp_generate (ptr_secret, totp_time, digits);
@@ -1134,9 +1125,9 @@ plugin_api_info_totp_validate_cb (const void *pointer, void *data,
const char *info_name, const char *info_name,
const char *arguments) const char *arguments)
{ {
char value[16], **argv, *ptr_secret, *ptr_otp, *error; char value[16], **argv, *ptr_secret, *ptr_otp;
int argc, window, rc; int argc, window, rc, number_int;
long number; long long number_longlong;
time_t totp_time; time_t totp_time;
/* make C compiler happy */ /* make C compiler happy */
@@ -1164,19 +1155,15 @@ plugin_api_info_totp_validate_cb (const void *pointer, void *data,
if (argc > 2) if (argc > 2)
{ {
error = NULL; if (!util_parse_longlong (argv[2], 10, &number_longlong) || (number_longlong < 0))
number = (int)strtol (argv[2], &error, 10);
if (!error || error[0] || (number < 0))
goto error; goto error;
totp_time = (time_t)number; totp_time = (time_t)number_longlong;
} }
if (argc > 3) if (argc > 3)
{ {
error = NULL; if (!util_parse_int (argv[3], 10, &number_int) || (number_int < 0))
number = (int)strtol (argv[3], &error, 10);
if (!error || error[0] || (number < 0))
goto error; goto error;
window = number; window = number_int;
} }
rc = weecrypto_totp_validate (ptr_secret, totp_time, window, ptr_otp); rc = weecrypto_totp_validate (ptr_secret, totp_time, window, ptr_otp);
@@ -1235,8 +1222,8 @@ plugin_api_info_window_cb (const void *pointer, void *data,
const char *arguments) const char *arguments)
{ {
struct t_gui_window *ptr_window; struct t_gui_window *ptr_window;
long number; int number;
char *error, value[64]; char value[64];
/* make C compiler happy */ /* make C compiler happy */
(void) pointer; (void) pointer;
@@ -1246,9 +1233,7 @@ plugin_api_info_window_cb (const void *pointer, void *data,
if (!arguments || !arguments[0]) if (!arguments || !arguments[0])
return NULL; return NULL;
error = NULL; if (!util_parse_int (arguments, 10, &number))
number = (int)strtol (arguments, &error, 10);
if (!error || error[0])
return NULL; return NULL;
ptr_window = gui_window_search_by_number (number); ptr_window = gui_window_search_by_number (number);
@@ -2040,7 +2025,6 @@ plugin_api_infolist_window_cb (const void *pointer, void *data,
struct t_infolist *ptr_infolist; struct t_infolist *ptr_infolist;
struct t_gui_window *ptr_window; struct t_gui_window *ptr_window;
int number; int number;
char *error;
/* make C compiler happy */ /* make C compiler happy */
(void) pointer; (void) pointer;
@@ -2084,9 +2068,7 @@ plugin_api_infolist_window_cb (const void *pointer, void *data,
return NULL; return NULL;
} }
/* check if argument is a window number */ /* check if argument is a window number */
error = NULL; if (util_parse_int (arguments, 10, &number))
number = (int)strtol (arguments, &error, 10);
if (error && !error[0])
{ {
ptr_window = gui_window_search_by_number (number); ptr_window = gui_window_search_by_number (number);
if (ptr_window) if (ptr_window)
+3 -4
View File
@@ -38,6 +38,7 @@
#include "../core/core-input.h" #include "../core/core-input.h"
#include "../core/core-proxy.h" #include "../core/core-proxy.h"
#include "../core/core-string.h" #include "../core/core-string.h"
#include "../core/core-util.h"
#include "../gui/gui-bar.h" #include "../gui/gui-bar.h"
#include "../gui/gui-bar-item.h" #include "../gui/gui-bar-item.h"
#include "../gui/gui-bar-window.h" #include "../gui/gui-bar-window.h"
@@ -394,7 +395,7 @@ plugin_api_command_options (struct t_weechat_plugin *plugin,
struct t_gui_buffer *buffer, const char *command, struct t_gui_buffer *buffer, const char *command,
struct t_hashtable *options) struct t_hashtable *options)
{ {
char *command2, *error; char *command2;
const char *ptr_commands_allowed, *ptr_delay, *ptr_split_newline; const char *ptr_commands_allowed, *ptr_delay, *ptr_split_newline;
long delay; long delay;
int rc, split_newline; int rc, split_newline;
@@ -412,9 +413,7 @@ plugin_api_command_options (struct t_weechat_plugin *plugin,
ptr_delay = hashtable_get (options, "delay"); ptr_delay = hashtable_get (options, "delay");
if (ptr_delay) if (ptr_delay)
{ {
error = NULL; if (!util_parse_long (ptr_delay, 10, &delay))
delay = strtol (ptr_delay, &error, 10);
if (!error || error[0])
delay = 0; delay = 0;
} }
ptr_split_newline = hashtable_get (options, "split_newline"); ptr_split_newline = hashtable_get (options, "split_newline");
+2 -4
View File
@@ -3120,7 +3120,7 @@ API_FUNC(hook_signal)
API_FUNC(hook_signal_send) API_FUNC(hook_signal_send)
{ {
char *signal, *type_data, *signal_data, *error; char *signal, *type_data, *signal_data;
int number, rc; int number, rc;
API_INIT_FUNC(1, "hook_signal_send", API_RETURN_INT(WEECHAT_RC_ERROR)); API_INIT_FUNC(1, "hook_signal_send", API_RETURN_INT(WEECHAT_RC_ERROR));
@@ -3137,9 +3137,7 @@ API_FUNC(hook_signal_send)
} }
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_INT) == 0) else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_INT) == 0)
{ {
error = NULL; if (weechat_util_parse_int (signal_data, 10, &number))
number = (int)strtol (signal_data, &error, 10);
if (error && !error[0])
rc = weechat_hook_signal_send (signal, type_data, &number); rc = weechat_hook_signal_send (signal, type_data, &number);
else else
rc = WEECHAT_RC_ERROR; rc = WEECHAT_RC_ERROR;
+37
View File
@@ -848,3 +848,40 @@ relay_api_msg_hotlist_to_json (struct t_gui_hotlist *hotlist)
return json; return json;
} }
/*
* Create a JSON object with a script.
*/
cJSON *
relay_api_msg_script_to_json (struct t_hdata *hdata, void *script, const char *extension)
{
cJSON *json;
void *pointer;
const char *ptr_string;
char name[1024];
if (!hdata)
return NULL;
pointer = script;
json = cJSON_CreateObject ();
if (!json)
return NULL;
if (!script)
return json;
snprintf (name, sizeof (name),
"%s.%s",
weechat_hdata_string (hdata, script, "name"),
extension);
MSG_ADD_STR_BUF("name", name);
MSG_ADD_HDATA_STR("version", "version");
MSG_ADD_HDATA_STR("description", "description");
MSG_ADD_HDATA_STR("author", "author");
MSG_ADD_HDATA_STR("license", "license");
return json;
}
+2
View File
@@ -58,5 +58,7 @@ extern cJSON *relay_api_msg_nick_group_to_json (struct t_gui_nick_group *nick_gr
enum t_relay_api_colors colors); enum t_relay_api_colors colors);
extern cJSON *relay_api_msg_completion_to_json (struct t_gui_completion *completion); extern cJSON *relay_api_msg_completion_to_json (struct t_gui_completion *completion);
extern cJSON *relay_api_msg_hotlist_to_json (struct t_gui_hotlist *hotlist); extern cJSON *relay_api_msg_hotlist_to_json (struct t_gui_hotlist *hotlist);
extern cJSON *relay_api_msg_script_to_json (struct t_hdata *hdata, void *script,
const char *extension);
#endif /* WEECHAT_PLUGIN_RELAY_API_MSG_H */ #endif /* WEECHAT_PLUGIN_RELAY_API_MSG_H */
+83 -16
View File
@@ -77,7 +77,6 @@ relay_api_protocol_signal_buffer_cb (const void *pointer, void *data,
long long buffer_id; long long buffer_id;
int nicks; int nicks;
const char *ptr_id; const char *ptr_id;
char *error;
/* make C compiler happy */ /* make C compiler happy */
(void) data; (void) data;
@@ -119,9 +118,7 @@ relay_api_protocol_signal_buffer_cb (const void *pointer, void *data,
ptr_buffer); ptr_buffer);
if (ptr_id) if (ptr_id)
{ {
error = NULL; if (!weechat_util_parse_longlong (ptr_id, 10, &buffer_id))
buffer_id = strtoll (ptr_id, &error, 10);
if (!error || error[0])
buffer_id = -1; buffer_id = -1;
weechat_hashtable_remove ( weechat_hashtable_remove (
RELAY_API_DATA(ptr_client, buffers_closing), RELAY_API_DATA(ptr_client, buffers_closing),
@@ -402,7 +399,10 @@ RELAY_API_PROTOCOL_CALLBACK(handshake)
if (json_body) if (json_body)
{ {
if (!cJSON_IsObject (json_body)) if (!cJSON_IsObject (json_body))
{
cJSON_Delete (json_body);
return RELAY_API_PROTOCOL_RC_BAD_REQUEST; return RELAY_API_PROTOCOL_RC_BAD_REQUEST;
}
json_algos = cJSON_GetObjectItem (json_body, "password_hash_algo"); json_algos = cJSON_GetObjectItem (json_body, "password_hash_algo");
if (json_algos) if (json_algos)
{ {
@@ -496,7 +496,7 @@ invalid_hash_algo:
RELAY_API_PROTOCOL_CALLBACK(version) RELAY_API_PROTOCOL_CALLBACK(version)
{ {
cJSON *json; cJSON *json;
char *version, *error; char *version;
long number; long number;
json = cJSON_CreateObject (); json = cJSON_CreateObject ();
@@ -514,9 +514,7 @@ RELAY_API_PROTOCOL_CALLBACK(version)
free (version); free (version);
version = weechat_info_get ("version_number", NULL); version = weechat_info_get ("version_number", NULL);
error = NULL; if (weechat_util_parse_long (version, 10, &number))
number = strtol (version, &error, 10);
if (error && !error[0])
{ {
cJSON_AddItemToObject (json, cJSON_AddItemToObject (json,
"weechat_version_number", "weechat_version_number",
@@ -558,10 +556,9 @@ RELAY_API_PROTOCOL_CALLBACK(buffers)
struct t_gui_buffer *ptr_buffer; struct t_gui_buffer *ptr_buffer;
struct t_gui_line *ptr_line; struct t_gui_line *ptr_line;
struct t_gui_line_data *ptr_line_data; struct t_gui_line_data *ptr_line_data;
long lines, lines_free, line_id; long lines, lines_free;
int colors, nicks; int colors, nicks, line_id;
const char *ptr_colors; const char *ptr_colors;
char *error;
json = NULL; json = NULL;
@@ -607,9 +604,10 @@ RELAY_API_PROTOCOL_CALLBACK(buffers)
{ {
if (client->http_req->num_path_items > 4) if (client->http_req->num_path_items > 4)
{ {
line_id = strtol (client->http_req->path_items[4], &error, 10); if (weechat_util_parse_int (client->http_req->path_items[4], 10, &line_id))
ptr_line = (error && !error[0]) ? ptr_line = weechat_line_search_by_id (ptr_buffer, line_id);
weechat_line_search_by_id (ptr_buffer, line_id) : NULL; else
ptr_line = NULL;
ptr_line_data = (ptr_line) ? ptr_line_data = (ptr_line) ?
weechat_hdata_pointer (relay_hdata_line, ptr_line, "data") : NULL; weechat_hdata_pointer (relay_hdata_line, ptr_line, "data") : NULL;
if (!ptr_line_data) if (!ptr_line_data)
@@ -764,6 +762,64 @@ RELAY_API_PROTOCOL_CALLBACK(hotlist)
return RELAY_API_PROTOCOL_RC_OK; return RELAY_API_PROTOCOL_RC_OK;
} }
/*
* Callback for resource "scripts".
*
* Routes:
* GET /api/scripts
*/
RELAY_API_PROTOCOL_CALLBACK(scripts)
{
cJSON *json;
char *info_languages, **languages, hdata_name[256], *pos;
int num_languages, i;
struct t_hdata *ptr_hdata;
void *ptr_script;
json = cJSON_CreateArray ();
if (!json)
return RELAY_API_PROTOCOL_RC_MEMORY;
info_languages = weechat_info_get ("script_languages", NULL);
if (info_languages)
{
languages = weechat_string_split (info_languages, ",", NULL,
WEECHAT_STRING_SPLIT_STRIP_LEFT
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
0, &num_languages);
if (languages)
{
for (i = 0; i < num_languages; i++)
{
pos = strchr (languages[i], ':');
if (pos)
{
pos[0] = '\0';
snprintf (hdata_name, sizeof (hdata_name),
"%s_script", languages[i]);
ptr_hdata = weechat_hdata_get (hdata_name);
ptr_script = weechat_hdata_get_list (ptr_hdata, "scripts");
while (ptr_script)
{
cJSON_AddItemToArray (
json,
relay_api_msg_script_to_json (ptr_hdata, ptr_script, pos + 1));
ptr_script = weechat_hdata_move (ptr_hdata, ptr_script, 1);
}
}
}
weechat_string_free_split (languages);
}
free (info_languages);
}
relay_api_msg_send_json (client, RELAY_HTTP_200_OK, NULL, "scripts", json);
cJSON_Delete (json);
return RELAY_API_PROTOCOL_RC_OK;
}
/* /*
* Callback for resource "input". * Callback for resource "input".
* *
@@ -781,8 +837,13 @@ RELAY_API_PROTOCOL_CALLBACK(input)
char str_delay[32]; char str_delay[32];
json_body = cJSON_Parse (client->http_req->body); json_body = cJSON_Parse (client->http_req->body);
if (!json_body || !cJSON_IsObject (json_body)) if (!json_body)
return RELAY_API_PROTOCOL_RC_BAD_REQUEST; return RELAY_API_PROTOCOL_RC_BAD_REQUEST;
if (!cJSON_IsObject (json_body))
{
cJSON_Delete (json_body);
return RELAY_API_PROTOCOL_RC_BAD_REQUEST;
}
/* get buffer either by name or by id */ /* get buffer either by name or by id */
ptr_buffer = NULL; ptr_buffer = NULL;
@@ -908,8 +969,13 @@ RELAY_API_PROTOCOL_CALLBACK(completion)
struct t_gui_buffer *ptr_buffer; struct t_gui_buffer *ptr_buffer;
json_body = cJSON_Parse (client->http_req->body); json_body = cJSON_Parse (client->http_req->body);
if (!json_body || !cJSON_IsObject(json_body)) if (!json_body)
return RELAY_API_PROTOCOL_RC_BAD_REQUEST; return RELAY_API_PROTOCOL_RC_BAD_REQUEST;
if (!cJSON_IsObject(json_body))
{
cJSON_Delete (json_body);
return RELAY_API_PROTOCOL_RC_BAD_REQUEST;
}
/* get buffer either by name or by id */ /* get buffer either by name or by id */
ptr_buffer = NULL; ptr_buffer = NULL;
@@ -1286,6 +1352,7 @@ relay_api_protocol_recv_http (struct t_relay_client *client)
{ "GET", "version", 1, 0, 0, RELAY_API_CB(version) }, { "GET", "version", 1, 0, 0, RELAY_API_CB(version) },
{ "GET", "buffers", 1, 0, 3, RELAY_API_CB(buffers) }, { "GET", "buffers", 1, 0, 3, RELAY_API_CB(buffers) },
{ "GET", "hotlist", 1, 0, 3, RELAY_API_CB(hotlist) }, { "GET", "hotlist", 1, 0, 3, RELAY_API_CB(hotlist) },
{ "GET", "scripts", 1, 0, 0, RELAY_API_CB(scripts) },
{ "POST", "input", 1, 0, 0, RELAY_API_CB(input) }, { "POST", "input", 1, 0, 0, RELAY_API_CB(input) },
{ "POST", "completion", 1, 0, 0, RELAY_API_CB(completion) }, { "POST", "completion", 1, 0, 0, RELAY_API_CB(completion) },
{ "POST", "ping", 1, 0, 0, RELAY_API_CB(ping) }, { "POST", "ping", 1, 0, 0, RELAY_API_CB(ping) },
+1 -4
View File
@@ -51,7 +51,6 @@ long long
relay_api_get_buffer_id (struct t_gui_buffer *buffer) relay_api_get_buffer_id (struct t_gui_buffer *buffer)
{ {
const char *ptr_id; const char *ptr_id;
char *error;
long long id; long long id;
if (!buffer) if (!buffer)
@@ -61,9 +60,7 @@ relay_api_get_buffer_id (struct t_gui_buffer *buffer)
if (!ptr_id) if (!ptr_id)
return -1; return -1;
error = NULL; if (!weechat_util_parse_longlong (ptr_id, 10, &id))
id = strtoll (ptr_id, &error, 10);
if (!error || error[0])
return -1; return -1;
return id; return id;
+1 -1
View File
@@ -26,7 +26,7 @@ struct t_relay_client;
enum t_relay_status; enum t_relay_status;
#define RELAY_API_VERSION_MAJOR 0 #define RELAY_API_VERSION_MAJOR 0
#define RELAY_API_VERSION_MINOR 5 #define RELAY_API_VERSION_MINOR 6
#define RELAY_API_VERSION_PATCH 0 #define RELAY_API_VERSION_PATCH 0
#define RELAY_API_VERSION_NUMBER \ #define RELAY_API_VERSION_NUMBER \
((RELAY_API_VERSION_MAJOR << 16) \ ((RELAY_API_VERSION_MAJOR << 16) \
@@ -113,7 +113,6 @@ long long
relay_remote_event_get_buffer_id (struct t_gui_buffer *buffer) relay_remote_event_get_buffer_id (struct t_gui_buffer *buffer)
{ {
const char *ptr_id; const char *ptr_id;
char *error;
long long buffer_id; long long buffer_id;
if (!buffer) if (!buffer)
@@ -123,9 +122,7 @@ relay_remote_event_get_buffer_id (struct t_gui_buffer *buffer)
if (!ptr_id) if (!ptr_id)
return -1; return -1;
error = NULL; if (!weechat_util_parse_longlong (ptr_id, 10, &buffer_id))
buffer_id = strtoll (ptr_id, &error, 10);
if (!error || error[0])
return -1; return -1;
return buffer_id; return buffer_id;
+60 -3
View File
@@ -17,7 +17,7 @@ info:
license: license:
name: CC BY-NC-SA 4.0 name: CC BY-NC-SA 4.0
url: https://creativecommons.org/licenses/by-nc-sa/4.0/ url: https://creativecommons.org/licenses/by-nc-sa/4.0/
version: 0.5.0 version: 0.6.0
externalDocs: externalDocs:
url: https://weechat.org/doc/ url: https://weechat.org/doc/
@@ -32,6 +32,7 @@ tags:
- name: version - name: version
- name: buffers - name: buffers
- name: hotlist - name: hotlist
- name: scripts
- name: input - name: input
- name: completion - name: completion
- name: ping - name: ping
@@ -96,7 +97,7 @@ paths:
get: get:
tags: tags:
- version - version
description: Get the WeeChat and API versions description: Get the WeeChat and API versions.
parameters: parameters:
- $ref: '#/components/parameters/totp' - $ref: '#/components/parameters/totp'
operationId: getVersion operationId: getVersion
@@ -531,7 +532,7 @@ paths:
get: get:
tags: tags:
- hotlist - hotlist
description: Get hotlist description: Get hotlist.
operationId: getHotlist operationId: getHotlist
parameters: parameters:
- $ref: '#/components/parameters/totp' - $ref: '#/components/parameters/totp'
@@ -564,6 +565,37 @@ paths:
$ref: '#/components/schemas/Error' $ref: '#/components/schemas/Error'
security: security:
- password: [] - password: []
/scripts:
get:
tags:
- scripts
description: Get list of loaded scripts.
operationId: getScripts
parameters:
- $ref: '#/components/parameters/totp'
responses:
'200':
description: Successful operation
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Script'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'503':
description: Out of memory
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
security:
- password: []
/input: /input:
post: post:
tags: tags:
@@ -1336,6 +1368,31 @@ components:
- date - date
- buffer_id - buffer_id
- count - count
Script:
type: object
properties:
name:
type: string
description: script name
example: 'go.py'
version:
type: string
example: '3.1.1'
description:
type: string
example: 'Quick jump to buffers'
author:
type: string
example: 'Sébastien Helleu <flashcode@flashtux.org>'
license:
type: string
example: 'GPL3'
required:
- name
- version
- description
- author
- license
Completion: Completion:
type: object type: object
properties: properties:
+25 -23
View File
@@ -202,9 +202,9 @@ void
relay_irc_sendf (struct t_relay_client *client, const char *format, ...) relay_irc_sendf (struct t_relay_client *client, const char *format, ...)
{ {
int number; int number;
char *pos, hash_key[32], *message, *new_msg1, *new_msg2; char *pos, hash_key[32], *message, *new_msg1, *new_msg2, *ptr_msg1, *ptr_msg2;
char modifier_data[128]; char modifier_data[128];
const char *str_message, *ptr_msg1, *ptr_msg2; const char *str_message;
struct t_hashtable *hashtable_in, *hashtable_out; struct t_hashtable *hashtable_in, *hashtable_out;
if (!client || !format) if (!client || !format)
@@ -234,7 +234,12 @@ relay_irc_sendf (struct t_relay_client *client, const char *format, ...)
if (new_msg1 && !new_msg1[0]) if (new_msg1 && !new_msg1[0])
goto end; goto end;
ptr_msg1 = (new_msg1) ? new_msg1 : vbuffer; if (!new_msg1)
new_msg1 = strdup (vbuffer);
if (!new_msg1)
goto end;
ptr_msg1 = new_msg1;
pos = strchr (ptr_msg1, '\r'); pos = strchr (ptr_msg1, '\r');
if (pos) if (pos)
@@ -275,7 +280,11 @@ relay_irc_sendf (struct t_relay_client *client, const char *format, ...)
/* message not dropped? */ /* message not dropped? */
if (!new_msg2 || new_msg2[0]) if (!new_msg2 || new_msg2[0])
{ {
ptr_msg2 = (new_msg2) ? new_msg2 : str_message; if (!new_msg2)
new_msg2 = strdup (str_message);
if (!new_msg2)
break;
ptr_msg2 = new_msg2;
if (weechat_asprintf (&message, "%s\r\n", ptr_msg2) >= 0) if (weechat_asprintf (&message, "%s\r\n", ptr_msg2) >= 0)
{ {
relay_client_send (client, RELAY_MSG_STANDARD, relay_client_send (client, RELAY_MSG_STANDARD,
@@ -420,9 +429,8 @@ relay_irc_signal_irc_in2_cb (const void *pointer, void *data,
int int
relay_irc_tag_relay_client_id (const char *tags) relay_irc_tag_relay_client_id (const char *tags)
{ {
char **argv, *error; char **argv;
int result, argc, i; int number, result, argc, i;
long number;
result = -1; result = -1;
@@ -440,9 +448,7 @@ relay_irc_tag_relay_client_id (const char *tags)
{ {
if (strncmp (argv[i], "relay_client_", 13) == 0) if (strncmp (argv[i], "relay_client_", 13) == 0)
{ {
error = NULL; if (weechat_util_parse_int (argv[i] + 13, 10, &number))
number = strtol (argv[i] + 13, &error, 10);
if (error && !error[0])
{ {
result = number; result = number;
break; break;
@@ -470,10 +476,9 @@ relay_irc_signal_irc_outtags_cb (const void *pointer, void *data,
{ {
struct t_relay_client *client; struct t_relay_client *client;
struct t_hashtable *hash_parsed; struct t_hashtable *hash_parsed;
const char *irc_command, *irc_args, *host, *ptr_message; const char *irc_command, *irc_args, *host, *ptr_message, *pos;
char *pos, *tags, *irc_channel, *message; char *pos_cr, *tags, *irc_channel, *message, str_infolist_args[256];
struct t_infolist *infolist_nick; struct t_infolist *infolist_nick;
char str_infolist_args[256];
/* make C compiler happy */ /* make C compiler happy */
(void) data; (void) data;
@@ -487,9 +492,9 @@ relay_irc_signal_irc_outtags_cb (const void *pointer, void *data,
message = strdup ((char *)signal_data); message = strdup ((char *)signal_data);
if (!message) if (!message)
goto end; goto end;
pos = strchr (message, '\r'); pos_cr = strchr (message, '\r');
if (pos) if (pos_cr)
pos[0] = '\0'; pos_cr[0] = '\0';
ptr_message = message; ptr_message = message;
@@ -1595,13 +1600,12 @@ relay_irc_recv (struct t_relay_client *client, const char *data)
struct t_hashtable *hash_parsed, *hash_redirect; struct t_hashtable *hash_parsed, *hash_redirect;
struct t_infolist *infolist_server; struct t_infolist *infolist_server;
const char *irc_command, *str_num_params, *isupport, *pos_password; const char *irc_command, *str_num_params, *isupport, *pos_password;
const char *ptr_data, *ptr_nick_modes; const char *ptr_data, *ptr_nick_modes, *pos;
char str_time[128], str_signal[128], str_server_channel[256], *nick; char str_time[128], str_signal[128], str_server_channel[256], *nick;
char str_param[128], *str_args, *version, str_command[128], **params; char str_param[128], *str_args, *version, str_command[128], **params;
char *pos, *password, *irc_is_channel, *info, *error, *str_cmd_lower; char *password, *irc_is_channel, *info, *str_cmd_lower;
char modifier_data[128], *new_data, *ctcp_type, *ctcp_params, *nick_modes; char modifier_data[128], *new_data, *ctcp_type, *ctcp_params, *nick_modes;
long num_params; int i, num_params, redirect_msg;
int i, redirect_msg;
new_data = NULL; new_data = NULL;
hash_parsed = NULL; hash_parsed = NULL;
@@ -1642,9 +1646,7 @@ relay_irc_recv (struct t_relay_client *client, const char *data)
goto end; goto end;
irc_command = weechat_hashtable_get (hash_parsed, "command"); irc_command = weechat_hashtable_get (hash_parsed, "command");
str_num_params = weechat_hashtable_get (hash_parsed, "num_params"); str_num_params = weechat_hashtable_get (hash_parsed, "num_params");
error = NULL; if (!weechat_util_parse_int (str_num_params, 10, &num_params))
num_params = strtol (str_num_params, &error, 10);
if (!error || error[0])
num_params = 0; num_params = 0;
if (num_params > 0) if (num_params > 0)
{ {
+5 -11
View File
@@ -283,7 +283,7 @@ relay_auth_parse_pbkdf2 (const char *parameters,
char **salt_hexa, char **salt, int *salt_size, char **salt_hexa, char **salt, int *salt_size,
int *iterations, char **hash) int *iterations, char **hash)
{ {
char **argv, *error; char **argv;
int argc; int argc;
if (salt_hexa) if (salt_hexa)
@@ -329,9 +329,7 @@ relay_auth_parse_pbkdf2 (const char *parameters,
} }
/* parameter 2: iterations */ /* parameter 2: iterations */
error = NULL; if (!weechat_util_parse_int (argv[1], 10, iterations))
*iterations = (int)strtol (argv[1], &error, 10);
if (!error || error[0])
*iterations = 0; *iterations = 0;
/* parameter 3: the PBKDF2 hash */ /* parameter 3: the PBKDF2 hash */
@@ -362,9 +360,7 @@ int
relay_auth_check_salt (struct t_relay_client *client, relay_auth_check_salt (struct t_relay_client *client,
const char *salt_hexa, const char *salt, int salt_size) const char *salt_hexa, const char *salt, int salt_size)
{ {
long number; long long number, time_window;
int time_window;
char *error;
time_t time_now; time_t time_now;
if (!client) if (!client)
@@ -374,12 +370,10 @@ relay_auth_check_salt (struct t_relay_client *client,
{ {
if (!salt || (salt_size < 1)) if (!salt || (salt_size < 1))
return 0; return 0;
error = NULL; if (!weechat_util_parse_longlong (salt, 10, &number))
number = strtol (salt, &error, 10);
if (!error || error[0])
return 0; return 0;
time_now = time (NULL); time_now = time (NULL);
time_window = weechat_config_integer (relay_config_network_time_window); time_window = (long long)weechat_config_integer (relay_config_network_time_window);
return ((number >= time_now - time_window) return ((number >= time_now - time_window)
&& (number <= time_now + time_window)) ? 1 : 0; && (number <= time_now + time_window)) ? 1 : 0;
} }
+40 -15
View File
@@ -652,23 +652,46 @@ relay_config_check_port_cb (const void *pointer, void *data,
struct t_config_option *option, struct t_config_option *option,
const char *value) const char *value)
{ {
char *error;
long port;
struct t_relay_server *ptr_server; struct t_relay_server *ptr_server;
int number, port;
long long new_port;
/* make C compiler happy */ /* make C compiler happy */
(void) pointer; (void) pointer;
(void) data; (void) data;
(void) option;
error = NULL; if (strncmp (value, "++", 2) == 0)
port = strtol (value, &error, 10); {
ptr_server = relay_server_search_port ((int)port); /* relative value: add to the current port */
if (!weechat_util_parse_int (value + 2, 10, &number))
return 1;
new_port = (long long)weechat_config_integer (option) + number;
}
else if (strncmp (value, "--", 2) == 0)
{
/* relative value: subtract from the current port */
if (!weechat_util_parse_int (value + 2, 10, &number))
return 1;
new_port = (long long)weechat_config_integer (option) - number;
}
else
{
/* let WeeChat display the error if value is not a valid integer */
if (!weechat_util_parse_int (value, 10, &port))
return 1;
new_port = port;
}
/* if port is out of range, let WeeChat validate and display the error */
if ((new_port < 0) || (new_port > 65535))
return 1;
ptr_server = relay_server_search_port ((int)new_port);
if (ptr_server) if (ptr_server)
{ {
weechat_printf (NULL, _("%s%s: error: port \"%d\" is already used"), weechat_printf (NULL, _("%s%s: error: port \"%d\" is already used"),
weechat_prefix ("error"), weechat_prefix ("error"),
RELAY_PLUGIN_NAME, (int)port); RELAY_PLUGIN_NAME, (int)new_port);
return 0; return 0;
} }
@@ -866,9 +889,8 @@ relay_config_create_option_port_path (const void *pointer, void *data,
const char *option_name, const char *option_name,
const char *value) const char *value)
{ {
int rc, protocol_number, ipv4, ipv6, tls, unix_socket; int rc, protocol_number, ipv4, ipv6, tls, unix_socket, port;
char *error, *protocol, *protocol_args; char *protocol, *protocol_args;
long port;
struct t_relay_server *ptr_server; struct t_relay_server *ptr_server;
/* make C compiler happy */ /* make C compiler happy */
@@ -925,9 +947,10 @@ relay_config_create_option_port_path (const void *pointer, void *data,
} }
else else
{ {
error = NULL; if (weechat_util_parse_int (value, 10, &port))
port = strtol (value, &error, 10); ptr_server = relay_server_search_port (port);
ptr_server = relay_server_search_port ((int)port); else
ptr_server = NULL;
} }
if (ptr_server) if (ptr_server)
{ {
@@ -999,7 +1022,8 @@ struct t_relay_remote *
relay_config_get_remote_from_option_name (const char *name) relay_config_get_remote_from_option_name (const char *name)
{ {
struct t_relay_remote *ptr_remote; struct t_relay_remote *ptr_remote;
char *pos_option, *remote_name; const char *pos_option;
char *remote_name;
ptr_remote = NULL; ptr_remote = NULL;
@@ -1244,7 +1268,8 @@ relay_config_remote_read_cb (const void *pointer, void *data,
struct t_config_section *section, struct t_config_section *section,
const char *option_name, const char *value) const char *option_name, const char *value)
{ {
char *pos_option, *remote_name; const char *pos_option;
char *remote_name;
struct t_relay_remote *ptr_temp_remote; struct t_relay_remote *ptr_temp_remote;
int index_option; int index_option;
+22 -29
View File
@@ -212,7 +212,6 @@ relay_http_get_param_long (struct t_relay_http_request *request,
long *value) long *value)
{ {
const char *ptr_value; const char *ptr_value;
char *error;
long number; long number;
if (!value) if (!value)
@@ -223,8 +222,7 @@ relay_http_get_param_long (struct t_relay_http_request *request,
return 0; return 0;
if (ptr_value) if (ptr_value)
{ {
number = strtol (ptr_value, &error, 10); if (!weechat_util_parse_long (ptr_value, 10, &number))
if (!error || error[0])
return 0; return 0;
*value = number; *value = number;
} }
@@ -244,7 +242,8 @@ relay_http_parse_path (const char *path,
char ***paths, int *num_paths, char ***paths, int *num_paths,
struct t_hashtable *params) struct t_hashtable *params)
{ {
char *pos, *str_path, *str_params, **items_path, **items2_path; const char *pos;
char *str_path, *str_params, **items_path, **items2_path;
char **items_params, *name, *value; char **items_params, *name, *value;
int i, num_items_path, num_items_params; int i, num_items_path, num_items_params;
@@ -410,10 +409,9 @@ relay_http_parse_header (struct t_relay_http_request *request,
const char *header, const char *header,
int ws_deflate_allowed) int ws_deflate_allowed)
{ {
char *pos, *name, *name_lower, *error, **items; char *name, *name_lower, **items;
const char *existing_value, *ptr_value; const char *pos, *existing_value, *ptr_value;
int i, num_items; int i, number, num_items;
long number;
weechat_string_dyn_concat (request->raw, header, -1); weechat_string_dyn_concat (request->raw, header, -1);
weechat_string_dyn_concat (request->raw, "\n", -1); weechat_string_dyn_concat (request->raw, "\n", -1);
@@ -474,10 +472,8 @@ relay_http_parse_header (struct t_relay_http_request *request,
/* if header is "Content-Length", save the length */ /* if header is "Content-Length", save the length */
if (strcmp (name_lower, "content-length") == 0) if (strcmp (name_lower, "content-length") == 0)
{ {
error = NULL; if (weechat_util_parse_int (ptr_value, 10, &number))
number = strtol (ptr_value, &error, 10); request->content_length = number;
if (error && !error[0])
request->content_length = (int)number;
} }
/* /*
@@ -605,7 +601,7 @@ relay_http_get_auth_status (struct t_relay_client *client)
{ {
const char *auth, *sec_websocket_protocol, *client_totp, *pos; const char *auth, *sec_websocket_protocol, *client_totp, *pos;
char *relay_password, *totp_secret, *info_totp_args, *info_totp; char *relay_password, *totp_secret, *info_totp_args, *info_totp;
char *user_pass, **protocol_array, *error; char *user_pass, **protocol_array;
int rc, i, length, protocol_count, use_base64url, totp_ok; int rc, i, length, protocol_count, use_base64url, totp_ok;
long number; long number;
@@ -625,8 +621,8 @@ relay_http_get_auth_status (struct t_relay_client *client)
rc = -4; rc = -4;
goto end; goto end;
} }
number = strtol (client_totp, &error, 10); if (!weechat_util_parse_long (client_totp, 10, &number)
if (!error || error[0] || (number < 0) || (number > 999999)) || (number < 0) || (number > 999999))
{ {
rc = -4; rc = -4;
goto end; goto end;
@@ -999,7 +995,8 @@ relay_http_process_request (struct t_relay_client *client)
void void
relay_http_recv (struct t_relay_client *client, const char *data, int size) relay_http_recv (struct t_relay_client *client, const char *data, int size)
{ {
char *new_partial, *pos, **null_char; const void *null_char;
char *new_partial, *pos;
int length, ws_deflate_allowed; int length, ws_deflate_allowed;
null_char = memchr (data, 0, size); null_char = memchr (data, 0, size);
@@ -1494,8 +1491,8 @@ relay_http_parse_response_code (struct t_relay_http_response *response,
const char *response_code) const char *response_code)
{ {
const char *pos, *pos2; const char *pos, *pos2;
char *error, *return_code; char *return_code;
long value; int value;
if (!response) if (!response)
return 0; return 0;
@@ -1526,10 +1523,8 @@ relay_http_parse_response_code (struct t_relay_http_response *response,
if (!return_code) if (!return_code)
goto error; goto error;
error = NULL; if (weechat_util_parse_int (return_code, 10, &value))
value = strtol (return_code, &error, 10); response->return_code = value;
if (error && !error[0])
response->return_code = (int)value;
free (return_code); free (return_code);
@@ -1564,9 +1559,9 @@ int
relay_http_parse_response_header (struct t_relay_http_response *response, relay_http_parse_response_header (struct t_relay_http_response *response,
const char *header) const char *header)
{ {
char *pos, *name, *name_lower, *error; char *name, *name_lower;
const char *ptr_value; const char *pos, *ptr_value;
long number; int number;
/* empty line => end of headers */ /* empty line => end of headers */
if (!header || !header[0]) if (!header || !header[0])
@@ -1606,10 +1601,8 @@ relay_http_parse_response_header (struct t_relay_http_response *response,
/* if header is "Content-Length", save the length */ /* if header is "Content-Length", save the length */
if (strcmp (name_lower, "content-length") == 0) if (strcmp (name_lower, "content-length") == 0)
{ {
error = NULL; if (weechat_util_parse_int (ptr_value, 10, &number))
number = strtol (ptr_value, &error, 10); response->content_length = number;
if (error && !error[0])
response->content_length = (int)number;
} }
free (name); free (name);
+5 -6
View File
@@ -202,8 +202,8 @@ int
relay_remote_parse_url (const char *url, relay_remote_parse_url (const char *url,
int *tls, char **address, int *port) int *tls, char **address, int *port)
{ {
const char *ptr_url; const char *ptr_url, *pos;
char *pos, *str_port, *error; char *str_port;
long number; long number;
if (tls) if (tls)
@@ -270,12 +270,11 @@ relay_remote_parse_url (const char *url,
weechat_strndup (ptr_url, pos - ptr_url) : strdup (ptr_url); weechat_strndup (ptr_url, pos - ptr_url) : strdup (ptr_url);
if (!str_port) if (!str_port)
return 0; return 0;
error = NULL; if (weechat_util_parse_long (str_port, 10, &number)
number = strtol (str_port, &error, 10); && (number >= 0) && (number <= 65535))
if (error && !error[0] && (number >= 0) && (number <= 65535))
{ {
if (port) if (port)
*port = number; *port = (int)number;
free (str_port); free (str_port);
} }
else else
+1 -1
View File
@@ -79,7 +79,7 @@ relay_server_get_protocol_args (const char *protocol_and_args,
char **protocol, char **protocol_args) char **protocol, char **protocol_args)
{ {
int opt_ipv4, opt_ipv6, opt_tls, opt_unix_socket; int opt_ipv4, opt_ipv6, opt_tls, opt_unix_socket;
char *pos; const char *pos;
opt_ipv4 = -1; opt_ipv4 = -1;
opt_ipv6 = -1; opt_ipv6 = -1;
+5 -8
View File
@@ -306,9 +306,8 @@ relay_websocket_parse_extensions (const char *extensions,
struct t_relay_websocket_deflate *ws_deflate, struct t_relay_websocket_deflate *ws_deflate,
int ws_deflate_allowed) int ws_deflate_allowed)
{ {
char **exts, **params, **items, *error; char **exts, **params, **items;
int i, j, num_exts, num_params, num_items; int i, j, number, num_exts, num_params, num_items;
long number;
if (!extensions || !ws_deflate) if (!extensions || !ws_deflate)
return; return;
@@ -351,9 +350,7 @@ relay_websocket_parse_extensions (const char *extensions,
number = 15; number = 15;
if (num_items >= 2) if (num_items >= 2)
{ {
error = NULL; if (weechat_util_parse_int (items[1], 10, &number))
number = strtol (items[1], &error, 10);
if (error && !error[0])
{ {
if (number < 8) if (number < 8)
number = 8; number = 8;
@@ -368,12 +365,12 @@ relay_websocket_parse_extensions (const char *extensions,
if (strcmp (items[0], "server_max_window_bits") == 0) if (strcmp (items[0], "server_max_window_bits") == 0)
{ {
ws_deflate->server_max_window_bits_recv = 1; ws_deflate->server_max_window_bits_recv = 1;
ws_deflate->window_bits_deflate = (int)number; ws_deflate->window_bits_deflate = number;
} }
else else
{ {
ws_deflate->client_max_window_bits_recv = 1; ws_deflate->client_max_window_bits_recv = 1;
ws_deflate->window_bits_inflate = (int)number; ws_deflate->window_bits_inflate = number;
} }
} }
} }
+15 -17
View File
@@ -362,7 +362,7 @@ relay_weechat_msg_add_hdata_path (struct t_relay_weechat_msg *msg,
{ {
int num_added, i, j, count, count_all, var_type, array_size, max_array_size; int num_added, i, j, count, count_all, var_type, array_size, max_array_size;
int length; int length;
char *pos, *pos2, *str_count, *error, *name; char *pos, *pos2, *str_count, *name;
void *sub_pointer; void *sub_pointer;
struct t_hdata *sub_hdata; struct t_hdata *sub_hdata;
const char *sub_hdata_name; const char *sub_hdata_name;
@@ -384,9 +384,7 @@ relay_weechat_msg_add_hdata_path (struct t_relay_weechat_msg *msg,
count_all = 1; count_all = 1;
else else
{ {
error = NULL; if (weechat_util_parse_int (str_count, 10, &count))
count = (int)strtol (str_count, &error, 10);
if (error && !error[0])
{ {
if (count > 0) if (count > 0)
count--; count--;
@@ -586,9 +584,9 @@ relay_weechat_msg_add_hdata (struct t_relay_weechat_msg *msg,
const char *path, const char *keys) const char *path, const char *keys)
{ {
struct t_hdata *ptr_hdata_head, *ptr_hdata; struct t_hdata *ptr_hdata_head, *ptr_hdata;
char *hdata_head, *pos, **list_keys, *keys_types, **list_path; char *hdata_head, **list_keys, *keys_types, **list_path;
char *path_returned; char *path_returned, *pos_paren;
const char *hdata_name, *array_size; const char *hdata_name, *array_size, *pos;
void *pointer, **path_pointers; void *pointer, **path_pointers;
unsigned long value; unsigned long value;
int rc, num_keys, num_path, i, type, pos_count, count, rc_sscanf; int rc, num_keys, num_path, i, type, pos_count, count, rc_sscanf;
@@ -626,9 +624,9 @@ relay_weechat_msg_add_hdata (struct t_relay_weechat_msg *msg,
/* extract pointer from first path (direct pointer or list name) */ /* extract pointer from first path (direct pointer or list name) */
pointer = NULL; pointer = NULL;
pos = strchr (list_path[0], '('); pos_paren = strchr (list_path[0], '(');
if (pos) if (pos_paren)
pos[0] = '\0'; pos_paren[0] = '\0';
if (strncmp (list_path[0], "0x", 2) == 0) if (strncmp (list_path[0], "0x", 2) == 0)
{ {
rc_sscanf = sscanf (list_path[0], "%lx", &value); rc_sscanf = sscanf (list_path[0], "%lx", &value);
@@ -651,8 +649,8 @@ relay_weechat_msg_add_hdata (struct t_relay_weechat_msg *msg,
} }
else else
pointer = weechat_hdata_get_list (ptr_hdata_head, list_path[0]); pointer = weechat_hdata_get_list (ptr_hdata_head, list_path[0]);
if (pos) if (pos_paren)
pos[0] = '('; pos_paren[0] = '(';
if (!pointer) if (!pointer)
goto end; goto end;
@@ -668,9 +666,9 @@ relay_weechat_msg_add_hdata (struct t_relay_weechat_msg *msg,
strcpy (path_returned, hdata_head); strcpy (path_returned, hdata_head);
for (i = 1; i < num_path; i++) for (i = 1; i < num_path; i++)
{ {
pos = strchr (list_path[i], '('); pos_paren = strchr (list_path[i], '(');
if (pos) if (pos_paren)
pos[0] = '\0'; pos_paren[0] = '\0';
hdata_name = weechat_hdata_get_var_hdata (ptr_hdata, list_path[i]); hdata_name = weechat_hdata_get_var_hdata (ptr_hdata, list_path[i]);
if (!hdata_name) if (!hdata_name)
goto end; goto end;
@@ -679,8 +677,8 @@ relay_weechat_msg_add_hdata (struct t_relay_weechat_msg *msg,
goto end; goto end;
strcat (path_returned, "/"); strcat (path_returned, "/");
strcat (path_returned, hdata_name); strcat (path_returned, hdata_name);
if (pos) if (pos_paren)
pos[0] = '('; pos_paren[0] = '(';
} }
/* split keys */ /* split keys */
@@ -684,7 +684,7 @@ RELAY_WEECHAT_PROTOCOL_CALLBACK(completion)
struct t_gui_completion_word *word; struct t_gui_completion_word *word;
struct t_arraylist *ptr_list; struct t_arraylist *ptr_list;
struct t_relay_weechat_msg *msg; struct t_relay_weechat_msg *msg;
char *error, *pos_data; char *pos_data;
int i, position, length_data, context, pos_start, size; int i, position, length_data, context, pos_start, size;
RELAY_WEECHAT_PROTOCOL_MIN_ARGS(0); RELAY_WEECHAT_PROTOCOL_MIN_ARGS(0);
@@ -709,9 +709,7 @@ RELAY_WEECHAT_PROTOCOL_CALLBACK(completion)
goto error; goto error;
} }
error = NULL; if (!weechat_util_parse_int (argv[1], 10, &position))
position = (int)strtol (argv[1], &error, 10);
if (!error || error[0])
goto error; goto error;
pos_data = strchr (argv_eol[1], ' '); pos_data = strchr (argv_eol[1], ' ');
@@ -1740,8 +1738,8 @@ RELAY_WEECHAT_PROTOCOL_CALLBACK(quit)
void void
relay_weechat_protocol_recv (struct t_relay_client *client, const char *data) relay_weechat_protocol_recv (struct t_relay_client *client, const char *data)
{ {
const char *ptr_data; const char *ptr_data, *pos;
char *data_unescaped, *pos, *id, *command, **argv, **argv_eol; char *data_unescaped, *id, *command, **argv, **argv_eol;
int i, argc, return_code; int i, argc, return_code;
struct t_relay_weechat_protocol_cb protocol_cb[] = struct t_relay_weechat_protocol_cb protocol_cb[] =
{ { "handshake", &relay_weechat_protocol_cb_handshake }, { { "handshake", &relay_weechat_protocol_cb_handshake },
+8 -6
View File
@@ -184,7 +184,8 @@ script_action_run_list_input (struct t_gui_buffer *buffer,
void void
script_action_run_load (const char *name, int quiet) script_action_run_load (const char *name, int quiet)
{ {
char *pos, str_command[1024]; const char *pos;
char str_command[1024];
int language; int language;
language = -1; language = -1;
@@ -227,8 +228,8 @@ script_action_run_load (const char *name, int quiet)
void void
script_action_run_unload (const char *name, int quiet) script_action_run_unload (const char *name, int quiet)
{ {
char *pos, hdata_name[128], *filename, *ptr_base_name, str_command[1024]; char hdata_name[128], *filename, *ptr_base_name, str_command[1024];
const char *ptr_filename, *ptr_registered_name; const char *pos, *ptr_filename, *ptr_registered_name;
int language, found, i; int language, found, i;
struct t_hdata *hdata; struct t_hdata *hdata;
void *ptr_script; void *ptr_script;
@@ -332,8 +333,8 @@ script_action_run_unload (const char *name, int quiet)
void void
script_action_run_reload (const char *name, int quiet) script_action_run_reload (const char *name, int quiet)
{ {
char *pos, hdata_name[128], *filename, *ptr_base_name, str_command[1024]; char hdata_name[128], *filename, *ptr_base_name, str_command[1024];
const char *ptr_filename, *ptr_registered_name; const char *pos, *ptr_filename, *ptr_registered_name;
int language, found, i; int language, found, i;
struct t_hdata *hdata; struct t_hdata *hdata;
void *ptr_script; void *ptr_script;
@@ -443,7 +444,8 @@ void
script_action_run_autoload (const char *name, int quiet, int autoload) script_action_run_autoload (const char *name, int quiet, int autoload)
{ {
struct t_script_repo *ptr_script; struct t_script_repo *ptr_script;
char *pos, str_signal[256], *weechat_data_dir, *filename; char str_signal[256], *weechat_data_dir, *filename;
const char *pos;
int language, script_found, script_autoloaded; int language, script_found, script_autoloaded;
struct stat st; struct stat st;
+7 -18
View File
@@ -45,9 +45,7 @@ script_command_action (struct t_gui_buffer *buffer,
{ {
struct t_script_repo *ptr_script; struct t_script_repo *ptr_script;
char str_action[4096]; char str_action[4096];
long value; int quiet, value;
char *error;
int quiet;
if (arguments) if (arguments)
{ {
@@ -62,9 +60,7 @@ script_command_action (struct t_gui_buffer *buffer,
arguments++; arguments++;
} }
} }
error = NULL; if (weechat_util_parse_int (arguments, 10, &value))
value = strtol (arguments, &error, 10);
if (error && !error[0])
{ {
ptr_script = script_repo_search_displayed_by_number (value); ptr_script = script_repo_search_displayed_by_number (value);
if (ptr_script) if (ptr_script)
@@ -132,9 +128,8 @@ script_command_script (const void *pointer, void *data,
struct t_gui_buffer *buffer, int argc, struct t_gui_buffer *buffer, int argc,
char **argv, char **argv_eol) char **argv, char **argv_eol)
{ {
char *error, command[128]; char command[128];
long value; int line, value;
int line;
/* make C compiler happy */ /* make C compiler happy */
(void) pointer; (void) pointer;
@@ -227,9 +222,7 @@ script_command_script (const void *pointer, void *data,
} }
else else
{ {
error = NULL; if (weechat_util_parse_int (argv[2], 10, &value))
value = strtol (argv[2], &error, 10);
if (error && !error[0])
line = value; line = value;
} }
if (line >= 0) if (line >= 0)
@@ -248,9 +241,7 @@ script_command_script (const void *pointer, void *data,
value = 1; value = 1;
if (argc > 2) if (argc > 2)
{ {
error = NULL; if (!weechat_util_parse_int (argv[2], 10, &value))
value = strtol (argv[2], &error, 10);
if (!error || error[0])
value = 1; value = 1;
} }
if (script_buffer_detail_script) if (script_buffer_detail_script)
@@ -282,9 +273,7 @@ script_command_script (const void *pointer, void *data,
value = 1; value = 1;
if (argc > 2) if (argc > 2)
{ {
error = NULL; if (!weechat_util_parse_int (argv[2], 10, &value))
value = strtol (argv[2], &error, 10);
if (!error || error[0])
value = 1; value = 1;
} }
if (script_buffer_detail_script) if (script_buffer_detail_script)
+2 -2
View File
@@ -156,8 +156,8 @@ void
script_completion_exec_file_cb (void *data, const char *filename) script_completion_exec_file_cb (void *data, const char *filename)
{ {
struct t_gui_completion *completion; struct t_gui_completion *completion;
const char *extension; const char *extension, *pos;
char *pos, *filename2, *ptr_base_name; char *filename2, *ptr_base_name;
completion = (struct t_gui_completion *)(((void **)data)[0]); completion = (struct t_gui_completion *)(((void **)data)[0]);
extension = (const char *)(((void **)data)[1]); extension = (const char *)(((void **)data)[1]);
+36
View File
@@ -159,6 +159,37 @@ script_info_info_script_loaded_cb (const void *pointer, void *data,
return NULL; return NULL;
} }
/*
* Return script info "script_languages".
*/
char *
script_info_info_languages_cb (const void *pointer, void *data,
const char *info_name,
const char *arguments)
{
char **output;
int i;
/* make C compiler happy */
(void) pointer;
(void) data;
(void) info_name;
(void) arguments;
output = weechat_string_dyn_alloc (256);
for (i = 0; i < SCRIPT_NUM_LANGUAGES; i++)
{
if (i > 0)
weechat_string_dyn_concat (output, ",", -1);
weechat_string_dyn_concat (output, script_language[i], -1);
weechat_string_dyn_concat (output, ":", -1);
weechat_string_dyn_concat (output, script_extension[i], -1);
}
return weechat_string_dyn_free (output, 0);
}
/* /*
* Return script infolist "script_script". * Return script infolist "script_script".
*/ */
@@ -235,6 +266,11 @@ script_info_init (void)
N_("1 if script is loaded"), N_("1 if script is loaded"),
N_("script name with extension"), N_("script name with extension"),
&script_info_info_script_loaded_cb, NULL, NULL); &script_info_info_script_loaded_cb, NULL, NULL);
weechat_hook_info (
"script_languages",
N_("comma-separated list of plugin:extension with supported languages"),
NULL,
&script_info_info_languages_cb, NULL, NULL);
/* infolist hooks */ /* infolist hooks */
weechat_hook_infolist ( weechat_hook_infolist (
+7 -10
View File
@@ -40,11 +40,10 @@ script_mouse_focus_chat_cb (const void *pointer, void *data,
struct t_hashtable *info) struct t_hashtable *info)
{ {
const char *buffer; const char *buffer;
int rc; int rc, y;
unsigned long value; unsigned long value;
struct t_gui_buffer *ptr_buffer; struct t_gui_buffer *ptr_buffer;
long x; char str_date[64];
char *error, str_date[64];
struct t_script_repo *ptr_script; struct t_script_repo *ptr_script;
struct tm *tm; struct tm *tm;
@@ -72,15 +71,13 @@ script_mouse_focus_chat_cb (const void *pointer, void *data,
ptr_script = script_buffer_detail_script; ptr_script = script_buffer_detail_script;
else else
{ {
error = NULL; if (!weechat_util_parse_int (weechat_hashtable_get (info, "_chat_line_y"), 10, &y)
x = strtol (weechat_hashtable_get (info, "_chat_line_y"), &error, 10); || (y < 0))
if (!error || error[0]) {
return info; return info;
}
if (x < 0) ptr_script = script_repo_search_displayed_by_number (y);
return info;
ptr_script = script_repo_search_displayed_by_number (x);
if (!ptr_script) if (!ptr_script)
return info; return info;
} }
+2 -7
View File
@@ -714,8 +714,7 @@ script_repo_remove_all (void)
int int
script_repo_script_is_held (struct t_script_repo *script) script_repo_script_is_held (struct t_script_repo *script)
{ {
const char *hold; const char *hold, *pos;
char *pos;
int length; int length;
hold = weechat_config_string (script_config_scripts_hold); hold = weechat_config_string (script_config_scripts_hold);
@@ -1313,11 +1312,7 @@ script_repo_file_read (int quiet)
script->url = strdup (value); script->url = strdup (value);
else if (strcmp (name, "popularity") == 0) else if (strcmp (name, "popularity") == 0)
{ {
error = NULL; if (!weechat_util_parse_int (value, 10, &(script->popularity)))
script->popularity = (int)strtol (value,
&error,
10);
if (!error || error[0])
script->popularity = 0; script->popularity = 0;
} }
else if (strcmp (name, "added") == 0) else if (strcmp (name, "added") == 0)
+2 -1
View File
@@ -140,7 +140,8 @@ void
spell_command_speller_list_dicts (void) spell_command_speller_list_dicts (void)
{ {
#ifndef USE_ENCHANT #ifndef USE_ENCHANT
char *country, *lang, *pos, *iso; const char *pos;
char *country, *lang, *iso;
char str_dict[256], str_country[128]; char str_dict[256], str_country[128];
struct AspellConfig *config; struct AspellConfig *config;
AspellDictInfoList *list; AspellDictInfoList *list;
+1 -1
View File
@@ -391,7 +391,7 @@ spell_string_is_url (const char *word)
*/ */
int int
spell_string_is_nick (struct t_gui_buffer *buffer, const char *word) spell_string_is_nick (struct t_gui_buffer *buffer, char *word)
{ {
char *pos, *pos_nick_completer, *pos_space, saved_char; char *pos, *pos_nick_completer, *pos_space, saved_char;
const char *buffer_type, *buffer_nick, *buffer_channel; const char *buffer_type, *buffer_nick, *buffer_channel;
+2 -2
View File
@@ -810,8 +810,8 @@ trigger_callback_modifier_cb (const void *pointer, void *data,
const char *modifier, const char *modifier_data, const char *modifier, const char *modifier_data,
const char *string) const char *string)
{ {
const char *ptr_string; const char *ptr_string, *pos;
char *string_modified, *pos, *buffer_pointer; char *string_modified, *buffer_pointer;
char *str_tags, **tags, *prefix, *string_no_color; char *str_tags, **tags, *prefix, *string_no_color;
unsigned long value; unsigned long value;
int num_tags, rc; int num_tags, rc;

Some files were not shown because too many files have changed in this diff Show More