mirror of
https://github.com/weechat/weechat.git
synced 2026-07-05 17:23:15 +02:00
api: add function "asprintf"
This commit is contained in:
@@ -512,6 +512,60 @@ num_files = 2
|
||||
str = weechat.ngettext("file", "files", num_files)
|
||||
----
|
||||
|
||||
==== asprintf
|
||||
|
||||
_WeeChat ≥ 4.3.0._
|
||||
|
||||
// TRANSLATION MISSING
|
||||
Format a message in a string allocated by the function.
|
||||
|
||||
// TRANSLATION MISSING
|
||||
[NOTE]
|
||||
This function is defined for systems where the GNU function `asprintf()`
|
||||
is not available. +
|
||||
The behavior is almost the same except that `*result` is set to NULL on error.
|
||||
|
||||
Прототип:
|
||||
|
||||
[source,c]
|
||||
----
|
||||
int weechat_asprintf (char **result, const char *fmt, ...);
|
||||
----
|
||||
|
||||
Аргументи:
|
||||
|
||||
// TRANSLATION MISSING
|
||||
* _result_: pointer to a string pointer
|
||||
// TRANSLATION MISSING
|
||||
* _fmt_: format string
|
||||
|
||||
Повратна вредност:
|
||||
|
||||
// TRANSLATION MISSING
|
||||
* number of bytes written in `*result` (excluding the final null byte),
|
||||
a negative value in case of error.
|
||||
|
||||
C пример:
|
||||
|
||||
[source,c]
|
||||
----
|
||||
char *str;
|
||||
|
||||
if (weechat_asprintf (&str, "%s, %d", "test", 42) >= 0)
|
||||
{
|
||||
/* *str == "test, 42" */
|
||||
/* ... */
|
||||
free (str);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* error: *str == NULL */
|
||||
}
|
||||
----
|
||||
|
||||
[NOTE]
|
||||
Ова функција није доступна у API скриптовања.
|
||||
|
||||
==== strndup
|
||||
|
||||
Враћа дуплирани стринг, са максималним бројем бајтова.
|
||||
|
||||
Reference in New Issue
Block a user