Add .clang-format. Reformat everything.
This commit is contained in:
parent
2947cc1562
commit
fa579df623
32 changed files with 994 additions and 1126 deletions
|
@ -17,14 +17,14 @@
|
|||
* along with Tox-WeeChat. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <weechat/weechat-plugin.h>
|
||||
#include <tox/tox.h>
|
||||
#include <weechat/weechat-plugin.h>
|
||||
|
||||
#include "twc.h"
|
||||
#include "twc-config.h"
|
||||
#include "twc.h"
|
||||
|
||||
#include "twc-utils.h"
|
||||
|
||||
|
@ -84,9 +84,8 @@ twc_get_name_nt(Tox *tox, int32_t friend_number)
|
|||
TOX_ERR_FRIEND_QUERY err;
|
||||
size_t length = tox_friend_get_name_size(tox, friend_number, &err);
|
||||
|
||||
if ((err != TOX_ERR_FRIEND_QUERY_OK) ||
|
||||
(length == 0))
|
||||
return twc_get_friend_id_short(tox, friend_number);
|
||||
if ((err != TOX_ERR_FRIEND_QUERY_OK) || (length == 0))
|
||||
return twc_get_friend_id_short(tox, friend_number);
|
||||
|
||||
uint8_t name[length];
|
||||
|
||||
|
@ -101,13 +100,14 @@ char *
|
|||
twc_get_status_message_nt(Tox *tox, int32_t friend_number)
|
||||
{
|
||||
TOX_ERR_FRIEND_QUERY err;
|
||||
size_t length = tox_friend_get_status_message_size(tox, friend_number, &err);
|
||||
size_t length =
|
||||
tox_friend_get_status_message_size(tox, friend_number, &err);
|
||||
|
||||
if ((err != TOX_ERR_FRIEND_QUERY_OK) ||
|
||||
(length == SIZE_MAX)) {
|
||||
char *msg = malloc(1);
|
||||
*msg = 0;
|
||||
return msg;
|
||||
if ((err != TOX_ERR_FRIEND_QUERY_OK) || (length == SIZE_MAX))
|
||||
{
|
||||
char *msg = malloc(1);
|
||||
*msg = 0;
|
||||
return msg;
|
||||
}
|
||||
|
||||
uint8_t message[length];
|
||||
|
@ -123,13 +123,16 @@ twc_get_status_message_nt(Tox *tox, int32_t friend_number)
|
|||
char *
|
||||
twc_get_peer_name_nt(Tox *tox, int32_t group_number, int32_t peer_number)
|
||||
{
|
||||
uint8_t name[TOX_MAX_NAME_LENGTH+1] = {0};
|
||||
uint8_t name[TOX_MAX_NAME_LENGTH + 1] = {0};
|
||||
TOX_ERR_CONFERENCE_PEER_QUERY err = TOX_ERR_CONFERENCE_PEER_QUERY_OK;
|
||||
|
||||
int length = tox_conference_peer_get_name_size(tox, group_number, peer_number, &err);
|
||||
if ((err == TOX_ERR_CONFERENCE_PEER_QUERY_OK) && (length <= TOX_MAX_NAME_LENGTH))
|
||||
int length =
|
||||
tox_conference_peer_get_name_size(tox, group_number, peer_number, &err);
|
||||
if ((err == TOX_ERR_CONFERENCE_PEER_QUERY_OK) &&
|
||||
(length <= TOX_MAX_NAME_LENGTH))
|
||||
{
|
||||
tox_conference_peer_get_name(tox, group_number, peer_number, name, &err);
|
||||
tox_conference_peer_get_name(tox, group_number, peer_number, name,
|
||||
&err);
|
||||
if (err == TOX_ERR_CONFERENCE_PEER_QUERY_OK)
|
||||
return twc_null_terminate(name, length);
|
||||
else
|
||||
|
@ -165,13 +168,11 @@ twc_get_friend_id_short(Tox *tox, int32_t friend_number)
|
|||
|
||||
tox_friend_get_public_key(tox, friend_number, client_id, &err);
|
||||
|
||||
// return a zero public key on failure
|
||||
/* return a zero public key on failure */
|
||||
if (err != TOX_ERR_FRIEND_GET_PUBLIC_KEY_OK)
|
||||
memset(client_id, 0, TOX_PUBLIC_KEY_SIZE);
|
||||
memset(client_id, 0, TOX_PUBLIC_KEY_SIZE);
|
||||
|
||||
twc_bin2hex(client_id,
|
||||
short_id_length / 2,
|
||||
hex_address);
|
||||
twc_bin2hex(client_id, short_id_length / 2, hex_address);
|
||||
|
||||
return hex_address;
|
||||
}
|
||||
|
@ -184,9 +185,15 @@ twc_uint32_reverse_bytes(uint32_t num)
|
|||
{
|
||||
uint32_t res = 0;
|
||||
|
||||
res += num & 0xFF; num >>= 8; res <<= 8;
|
||||
res += num & 0xFF; num >>= 8; res <<= 8;
|
||||
res += num & 0xFF; num >>= 8; res <<= 8;
|
||||
res += num & 0xFF;
|
||||
num >>= 8;
|
||||
res <<= 8;
|
||||
res += num & 0xFF;
|
||||
num >>= 8;
|
||||
res <<= 8;
|
||||
res += num & 0xFF;
|
||||
num >>= 8;
|
||||
res <<= 8;
|
||||
res += num & 0xFF;
|
||||
|
||||
return res;
|
||||
|
@ -222,6 +229,6 @@ twc_set_buffer_logging(struct t_gui_buffer *buffer, bool logging)
|
|||
signal = "logger_stop";
|
||||
}
|
||||
|
||||
return weechat_hook_signal_send(signal,
|
||||
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
|
||||
return weechat_hook_signal_send(signal, WEECHAT_HOOK_SIGNAL_POINTER,
|
||||
buffer);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue