1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-09 19:23:13 +02:00

Add function "string_decode_base64" in plugin API

This commit is contained in:
Sebastien Helleu
2010-02-16 16:57:22 +01:00
parent 341551f2f2
commit ce1b23311c
7 changed files with 153 additions and 5 deletions
+34 -1
View File
@@ -1124,7 +1124,8 @@ Arguments:
* 'from': string to encode
* 'length': length of string to encode (for example `strlen(from)`)
* 'to': pointer to string to store result (must be long enough)
* 'to': pointer to string to store result (must be long enough, result is
longer than initial string)
Example:
@@ -1135,6 +1136,38 @@ weechat_string_encode_base64 (string, strlen (string), result);
/* result == "YWJjZGVmZ2g=" */
----------------------------------------
weechat_string_decode_base64
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Decode a base64 string.
Prototype:
[source,C]
----------------------------------------
int weechat_string_decode_base64 (const char *from, char *to);
----------------------------------------
Arguments:
* 'from': string to decode
* 'to': pointer to string to store result (must be long enough, result is
shorter than initial string)
Return value:
* length of string stored in *to (does not count final '\0')
Example:
[source,C]
----------------------------------------
char *string = "YWJjZGVmZ2g=", result[128];
int length;
length = weechat_string_decode_base64 (string, result);
/* length == 8, result == "abcdefgh" */
----------------------------------------
[[utf-8]]
UTF-8
~~~~~
+33 -1
View File
@@ -1139,7 +1139,7 @@ Paramètres :
* 'from': chaîne à encoder
* 'length': longueur de chaîne à encoder (par exemple `strlen(from)`)
* 'to': pointeur vers la chaîne pour stocker le résultat (doit être suffisamment
long)
long, le résultat est plus long que la chaîne initiale)
Exemple :
@@ -1150,6 +1150,38 @@ weechat_string_encode_base64 (string, strlen (string), result);
/* result == "YWJjZGVmZ2g=" */
----------------------------------------
weechat_string_decode_base64
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Décode une chaîne base64.
Prototype :
[source,C]
----------------------------------------
int weechat_string_decode_base64 (const char *from, char *to);
----------------------------------------
Paramètres :
* 'from': chaîne à décoder
* 'to': pointeur vers la chaîne pour stocker le résultat (doit être suffisamment
long, le résultat est plus court que la chaîne initiale)
Valeur de retour :
* longueur de la chaîne stockée dans *to (ne compte pas le '\0' final)
Example:
[source,C]
----------------------------------------
char *string = "YWJjZGVmZ2g=", result[128];
int length;
length = weechat_string_decode_base64 (string, result);
/* length == 8, result == "abcdefgh" */
----------------------------------------
[[utf-8]]
UTF-8
~~~~~