Astyle and fixes.

This commit is contained in:
irungentoo 2014-06-10 18:35:55 -04:00
parent 99d5940140
commit 07936960df
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98
19 changed files with 67 additions and 60 deletions

View File

@ -19,7 +19,7 @@
#define c_sleep(x) usleep(1000*x)
#endif
void accept_friend_request(Tox *m, uint8_t *public_key, uint8_t *data, uint16_t length, void *userdata)
void accept_friend_request(Tox *m, const uint8_t *public_key, const uint8_t *data, uint16_t length, void *userdata)
{
if (*((uint32_t *)userdata) != 974536)
return;

View File

@ -52,7 +52,7 @@ typedef struct _Status {
ACall calls[3]; /* Make 3 calls for this test */
} Status;
void accept_friend_request(Tox *m, uint8_t *public_key, uint8_t *data, uint16_t length, void *userdata)
void accept_friend_request(Tox *m, const uint8_t *public_key, const uint8_t *data, uint16_t length, void *userdata)
{
if (length == 7 && memcmp("gentoo", data, 7) == 0) {
tox_add_friend_norequest(m, public_key);

View File

@ -864,7 +864,7 @@ void do_refresh()
refresh();
}
void print_request(Tox *m, uint8_t *public_key, uint8_t *data, uint16_t length, void *userdata)
void print_request(Tox *m, const uint8_t *public_key, const uint8_t *data, uint16_t length, void *userdata)
{
new_lines("[i] received friend request with message:");
new_lines((char *)data);
@ -1181,6 +1181,7 @@ char timeout_getch(Tox *m)
c = ERR;
int n = select(1, &fds, NULL, NULL, &tv);
if (n < 0) {
new_lines("select error: maybe interupted");
} else if (n == 0) {

View File

@ -544,8 +544,8 @@ static void get_close_nodes_inner(const uint8_t *client_id, Node_format *nodes_l
*
* want_good : do we want only good nodes as checked with the hardening returned or not?
*/
static int get_somewhat_close_nodes(const DHT *dht, const uint8_t *client_id, Node_format *nodes_list, sa_family_t sa_family,
uint8_t is_LAN, uint8_t want_good)
static int get_somewhat_close_nodes(const DHT *dht, const uint8_t *client_id, Node_format *nodes_list,
sa_family_t sa_family, uint8_t is_LAN, uint8_t want_good)
{
uint32_t num_nodes = 0, i;
get_close_nodes_inner(client_id, nodes_list, sa_family,
@ -565,8 +565,8 @@ static int get_somewhat_close_nodes(const DHT *dht, const uint8_t *client_id, No
return num_nodes;
}
int get_close_nodes(const DHT *dht, const uint8_t *client_id, Node_format *nodes_list, sa_family_t sa_family, uint8_t is_LAN,
uint8_t want_good)
int get_close_nodes(const DHT *dht, const uint8_t *client_id, Node_format *nodes_list, sa_family_t sa_family,
uint8_t is_LAN, uint8_t want_good)
{
memset(nodes_list, 0, MAX_SENT_NODES * sizeof(Node_format));
#ifdef ENABLE_ASSOC_DHT
@ -961,7 +961,8 @@ end:
/* Send a getnodes request.
sendback_node is the node that it will send back the response to (set to NULL to disable this) */
static int getnodes(DHT *dht, IP_Port ip_port, const uint8_t *public_key, const uint8_t *client_id, const Node_format *sendback_node)
static int getnodes(DHT *dht, IP_Port ip_port, const uint8_t *public_key, const uint8_t *client_id,
const Node_format *sendback_node)
{
/* Check if packet is going to be sent to ourself. */
if (id_equal(public_key, dht->self_public_key))
@ -1017,8 +1018,8 @@ static int getnodes(DHT *dht, IP_Port ip_port, const uint8_t *public_key, const
}
/* Send a send nodes response: message for IPv6 nodes */
static int sendnodes_ipv6(const DHT *dht, IP_Port ip_port, const uint8_t *public_key, const uint8_t *client_id, const uint8_t *sendback_data,
uint16_t length, const uint8_t *shared_encryption_key)
static int sendnodes_ipv6(const DHT *dht, IP_Port ip_port, const uint8_t *public_key, const uint8_t *client_id,
const uint8_t *sendback_data, uint16_t length, const uint8_t *shared_encryption_key)
{
/* Check if packet is going to be sent to ourself. */
if (id_equal(public_key, dht->self_public_key))
@ -1128,8 +1129,8 @@ static uint8_t sent_getnode_to_node(DHT *dht, const uint8_t *client_id, IP_Port
}
/* Function is needed in following functions. */
static int send_hardening_getnode_res(const DHT *dht, const Node_format *sendto, const uint8_t *queried_client_id, const uint8_t *nodes_data,
uint16_t nodes_data_length);
static int send_hardening_getnode_res(const DHT *dht, const Node_format *sendto, const uint8_t *queried_client_id,
const uint8_t *nodes_data, uint16_t nodes_data_length);
static int handle_sendnodes_core(void *object, IP_Port source, const uint8_t *packet, uint32_t length,
Node_format *plain_nodes, uint16_t size_plain_nodes, uint32_t *num_nodes_out)
@ -1753,7 +1754,8 @@ static int send_NATping(DHT *dht, const uint8_t *public_key, uint64_t ping_id, u
}
/* Handle a received ping request for. */
static int handle_NATping(void *object, IP_Port source, const uint8_t *source_pubkey, const uint8_t *packet, uint32_t length)
static int handle_NATping(void *object, IP_Port source, const uint8_t *source_pubkey, const uint8_t *packet,
uint32_t length)
{
if (length != sizeof(uint64_t) + 1)
return 1;
@ -1962,8 +1964,8 @@ static int send_hardening_getnode_req(DHT *dht, Node_format *dest, Node_format *
}
/* Send a get node hardening response */
static int send_hardening_getnode_res(const DHT *dht, const Node_format *sendto, const uint8_t *queried_client_id, const uint8_t *nodes_data,
uint16_t nodes_data_length)
static int send_hardening_getnode_res(const DHT *dht, const Node_format *sendto, const uint8_t *queried_client_id,
const uint8_t *nodes_data, uint16_t nodes_data_length)
{
if (!ip_isset(&sendto->ip_port.ip))
return -1;
@ -2032,7 +2034,8 @@ static uint32_t have_nodes_closelist(DHT *dht, Node_format *nodes, uint16_t num)
#define HARDEN_TIMEOUT 1200
/* Handle a received hardening packet */
static int handle_hardening(void *object, IP_Port source, const uint8_t *source_pubkey, const uint8_t *packet, uint32_t length)
static int handle_hardening(void *object, IP_Port source, const uint8_t *source_pubkey, const uint8_t *packet,
uint32_t length)
{
DHT *dht = object;

View File

@ -176,8 +176,8 @@ typedef struct {
/*----------------------------------------------------------------------------------*/
typedef int (*cryptopacket_handler_callback)(void *object, IP_Port ip_port, const uint8_t *source_pubkey, const uint8_t *data,
uint32_t len);
typedef int (*cryptopacket_handler_callback)(void *object, IP_Port ip_port, const uint8_t *source_pubkey,
const uint8_t *data, uint32_t len);
typedef struct {
cryptopacket_handler_callback function;
@ -290,8 +290,8 @@ int id_closest(const uint8_t *id, const uint8_t *id1, const uint8_t *id2);
* return the number of nodes returned.
*
*/
int get_close_nodes(const DHT *dht, const uint8_t *client_id, Node_format *nodes_list, sa_family_t sa_family, uint8_t is_LAN,
uint8_t want_good);
int get_close_nodes(const DHT *dht, const uint8_t *client_id, Node_format *nodes_list, sa_family_t sa_family,
uint8_t is_LAN, uint8_t want_good);
/* Put up to max_num nodes in nodes from the closelist.

View File

@ -373,7 +373,8 @@ uint32_t m_sendmessage(Messenger *m, int32_t friendnumber, const uint8_t *messag
return 0;
}
uint32_t m_sendmessage_withid(Messenger *m, int32_t friendnumber, uint32_t theid, const uint8_t *message, uint32_t length)
uint32_t m_sendmessage_withid(Messenger *m, int32_t friendnumber, uint32_t theid, const uint8_t *message,
uint32_t length)
{
if (length >= (MAX_CRYPTO_DATA_SIZE - sizeof(theid)))
return 0;
@ -722,8 +723,8 @@ void m_set_sends_receipts(Messenger *m, int32_t friendnumber, int yesno)
/* static void (*friend_request)(uint8_t *, uint8_t *, uint16_t); */
/* Set the function that will be executed when a friend request is received. */
void m_callback_friendrequest(Messenger *m, void (*function)(Messenger *m, const uint8_t *, const uint8_t *, uint16_t, void *),
void *userdata)
void m_callback_friendrequest(Messenger *m, void (*function)(Messenger *m, const uint8_t *, const uint8_t *, uint16_t,
void *), void *userdata)
{
void (*handle_friendrequest)(void *, const uint8_t *, const uint8_t *, uint16_t, void *) = (void *)function;
callback_friendrequest(&(m->fr), handle_friendrequest, m, userdata);
@ -1294,8 +1295,7 @@ static void do_allgroupchats(Messenger *m)
* Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata)
*/
void callback_file_sendrequest(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint64_t, uint8_t *,
uint16_t,
void *), void *userdata)
uint16_t, void *), void *userdata)
{
m->file_sendrequest = function;
m->file_sendrequest_userdata = userdata;
@ -1307,8 +1307,7 @@ void callback_file_sendrequest(Messenger *m, void (*function)(Messenger *m, int3
*
*/
void callback_file_control(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint8_t, uint8_t, uint8_t *,
uint16_t,
void *), void *userdata)
uint16_t, void *), void *userdata)
{
m->file_filecontrol = function;
m->file_filecontrol_userdata = userdata;
@ -1320,8 +1319,7 @@ void callback_file_control(Messenger *m, void (*function)(Messenger *m, int32_t,
*
*/
void callback_file_data(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint8_t *, uint16_t length,
void *),
void *userdata)
void *), void *userdata)
{
m->file_filedata = function;
m->file_filedata_userdata = userdata;

View File

@ -322,7 +322,8 @@ int m_friend_exists(Messenger *m, int32_t friendnumber);
* however we can generate an id for you by calling plain m_sendmessage.
*/
uint32_t m_sendmessage(Messenger *m, int32_t friendnumber, const uint8_t *message, uint32_t length);
uint32_t m_sendmessage_withid(Messenger *m, int32_t friendnumber, uint32_t theid, const uint8_t *message, uint32_t length);
uint32_t m_sendmessage_withid(Messenger *m, int32_t friendnumber, uint32_t theid, const uint8_t *message,
uint32_t length);
/* Send an action to an online friend.
*
@ -442,8 +443,8 @@ void m_set_sends_receipts(Messenger *m, int32_t friendnumber, int yesno);
/* Set the function that will be executed when a friend request is received.
* Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length)
*/
void m_callback_friendrequest(Messenger *m, void (*function)(Messenger *m, const uint8_t *, const uint8_t *, uint16_t, void *),
void *userdata);
void m_callback_friendrequest(Messenger *m, void (*function)(Messenger *m, const uint8_t *, const uint8_t *, uint16_t,
void *), void *userdata);
/* Set the function that will be executed when a message from a friend is received.
* Function format is: function(int32_t friendnumber, uint8_t * message, uint32_t length)
@ -612,8 +613,7 @@ int group_names(Messenger *m, int groupnumber, uint8_t names[][MAX_NICK_BYTES],
* Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata)
*/
void callback_file_sendrequest(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint64_t, uint8_t *,
uint16_t,
void *), void *userdata);
uint16_t, void *), void *userdata);
/* Set the callback for file control requests.
*
@ -629,8 +629,7 @@ void callback_file_control(Messenger *m, void (*function)(Messenger *m, int32_t,
*
*/
void callback_file_data(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint8_t *, uint16_t length,
void *),
void *userdata);
void *), void *userdata);
/* Send a file send request.
* Maximum filename length is 255 bytes.

View File

@ -76,7 +76,8 @@ void encrypt_precompute(const uint8_t *public_key, const uint8_t *secret_key, ui
crypto_box_beforenm(enc_key, public_key, secret_key);
}
int encrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *nonce, const uint8_t *plain, uint32_t length, uint8_t *encrypted)
int encrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *nonce, const uint8_t *plain, uint32_t length,
uint8_t *encrypted)
{
if (length == 0)
return -1;
@ -95,7 +96,8 @@ int encrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *nonce, cons
return length + crypto_box_MACBYTES;
}
int decrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *nonce, const uint8_t *encrypted, uint32_t length, uint8_t *plain)
int decrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *nonce, const uint8_t *encrypted, uint32_t length,
uint8_t *plain)
{
if (length <= crypto_box_BOXZEROBYTES)
return -1;
@ -202,8 +204,8 @@ void new_nonce(uint8_t *nonce)
* return -1 on failure.
* return the length of the created packet on success.
*/
int create_request(const uint8_t *send_public_key, const uint8_t *send_secret_key, uint8_t *packet, const uint8_t *recv_public_key,
const uint8_t *data, uint32_t length, uint8_t request_id)
int create_request(const uint8_t *send_public_key, const uint8_t *send_secret_key, uint8_t *packet,
const uint8_t *recv_public_key, const uint8_t *data, uint32_t length, uint8_t request_id)
{
if (MAX_CRYPTO_REQUEST_SIZE < length + 1 + crypto_box_PUBLICKEYBYTES * 2 + crypto_box_NONCEBYTES + 1 +
crypto_box_MACBYTES)

View File

@ -84,7 +84,8 @@ void encrypt_precompute(const uint8_t *public_key, const uint8_t *secret_key, ui
* return -1 if there was a problem.
* return length of encrypted data if everything was fine.
*/
int encrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *nonce, const uint8_t *plain, uint32_t length, uint8_t *encrypted);
int encrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *nonce, const uint8_t *plain, uint32_t length,
uint8_t *encrypted);
/* Decrypts encrypted of length length to plain of length length - 16 using a
* secret key crypto_box_KEYBYTES big and a 24 byte nonce.
@ -92,7 +93,8 @@ int encrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *nonce, cons
* return -1 if there was a problem (decryption failed).
* return length of plain data if everything was fine.
*/
int decrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *nonce, const uint8_t *encrypted, uint32_t length, uint8_t *plain);
int decrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *nonce, const uint8_t *encrypted, uint32_t length,
uint8_t *plain);
/* Increment the given nonce by 1. */
void increment_nonce(uint8_t *nonce);
@ -128,8 +130,8 @@ void new_nonce(uint8_t *nonce);
* return -1 on failure.
* return the length of the created packet on success.
*/
int create_request(const uint8_t *send_public_key, const uint8_t *send_secret_key, uint8_t *packet, const uint8_t *recv_public_key,
const uint8_t *data, uint32_t length, uint8_t request_id);
int create_request(const uint8_t *send_public_key, const uint8_t *send_secret_key, uint8_t *packet,
const uint8_t *recv_public_key, const uint8_t *data, uint32_t length, uint8_t request_id);
/* puts the senders public key in the request in public_key, the data from the request
in data if a friend or ping request was sent to us and returns the length of the data.

View File

@ -72,8 +72,8 @@ uint32_t get_nospam(Friend_Requests *fr)
/* Set the function that will be executed when a friend request is received. */
void callback_friendrequest(Friend_Requests *fr, void (*function)(void *, const uint8_t *, const uint8_t *, uint16_t, void *),
void *object, void *userdata)
void callback_friendrequest(Friend_Requests *fr, void (*function)(void *, const uint8_t *, const uint8_t *, uint16_t,
void *), void *object, void *userdata)
{
fr->handle_friendrequest = function;
fr->handle_friendrequest_isset = 1;

View File

@ -66,8 +66,8 @@ int remove_request_received(Friend_Requests *fr, uint8_t *client_id);
/* Set the function that will be executed when a friend request for us is received.
* Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length, void * userdata)
*/
void callback_friendrequest(Friend_Requests *fr, void (*function)(void *, const uint8_t *, const uint8_t *, uint16_t, void *),
void *object, void *userdata);
void callback_friendrequest(Friend_Requests *fr, void (*function)(void *, const uint8_t *, const uint8_t *, uint16_t,
void *), void *object, void *userdata);
/* Set the function used to check if a friend request should be displayed to the user or not.
* Function format is int function(uint8_t * public_key, void * userdata)

View File

@ -115,7 +115,7 @@ void bs_list_init(BS_LIST *list, uint32_t element_size)
list->ids = NULL;
}
void bs_list_free(const BS_LIST *list)
void bs_list_free(BS_LIST *list)
{
//free both arrays
free(list->data);

View File

@ -41,7 +41,7 @@ typedef struct {
void bs_list_init(BS_LIST *list, uint32_t element_size);
/* Free a list initiated with list_init */
void bs_list_free(const BS_LIST *list);
void bs_list_free(BS_LIST *list);
/* Retrieve the id of an element in the list
*

View File

@ -45,7 +45,7 @@
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
static const char *inet_ntop(sa_family_t family, void *addr, const char *buf, size_t bufsize)
static const char *inet_ntop(sa_family_t family, void *addr, char *buf, size_t bufsize)
{
if (family == AF_INET) {
struct sockaddr_in saddr;
@ -78,7 +78,7 @@ static const char *inet_ntop(sa_family_t family, void *addr, const char *buf, si
return NULL;
}
static int inet_pton(sa_family_t family, const char *addrString, const void *addrbuf)
static int inet_pton(sa_family_t family, const char *addrString, void *addrbuf)
{
if (family == AF_INET) {
struct sockaddr_in saddr;
@ -404,7 +404,7 @@ void networking_registerhandler(Networking_Core *net, uint8_t byte, packet_handl
net->packethandlers[byte].object = object;
}
void networking_poll(const Networking_Core *net)
void networking_poll(Networking_Core *net)
{
unix_time_update();

View File

@ -338,7 +338,7 @@ int sendpacket(Networking_Core *net, IP_Port ip_port, const uint8_t *data, uint3
void networking_registerhandler(Networking_Core *net, uint8_t byte, packet_handler_callback cb, void *object);
/* Call this several times a second. */
void networking_poll(const Networking_Core *net);
void networking_poll(Networking_Core *net);
/* Initialize networking.
* bind to ip and port.

View File

@ -623,7 +623,8 @@ static int send_dht_fakeid(Onion_Client *onion_c, int friend_num, uint8_t *data,
return route_tofriend(onion_c->dht, onion_c->friends_list[friend_num].fake_client_id, packet, len);
}
static int handle_dht_fakeid(void *object, IP_Port source, const uint8_t *source_pubkey, const uint8_t *packet, uint32_t length)
static int handle_dht_fakeid(void *object, IP_Port source, const uint8_t *source_pubkey, const uint8_t *packet,
uint32_t length)
{
Onion_Client *onion_c = object;

View File

@ -102,7 +102,8 @@ typedef struct {
uint32_t tcp_relay_node_callback_number;
} Onion_Friend;
typedef int (*oniondata_handler_callback)(void *object, const uint8_t *source_pubkey, const uint8_t *data, uint32_t len);
typedef int (*oniondata_handler_callback)(void *object, const uint8_t *source_pubkey, const uint8_t *data,
uint32_t len);
typedef struct {
DHT *dht;

View File

@ -362,8 +362,8 @@ uint32_t tox_get_friendlist(Tox *tox, int32_t *out_list, uint32_t list_size)
/* Set the function that will be executed when a friend request is received.
* Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length)
*/
void tox_callback_friend_request(Tox *tox, void (*function)(Tox *tox, const uint8_t *, const uint8_t *, uint16_t, void *),
void *userdata)
void tox_callback_friend_request(Tox *tox, void (*function)(Tox *tox, const uint8_t *, const uint8_t *, uint16_t,
void *), void *userdata)
{
Messenger *m = tox;
m_callback_friendrequest(m, function, userdata);

View File

@ -289,8 +289,8 @@ uint32_t tox_get_friendlist(Tox *tox, int32_t *out_list, uint32_t list_size);
/* Set the function that will be executed when a friend request is received.
* Function format is function(Tox *tox, uint8_t * public_key, uint8_t * data, uint16_t length, void *userdata)
*/
void tox_callback_friend_request(Tox *tox, void (*function)(Tox *tox, const uint8_t *, const uint8_t *, uint16_t, void *),
void *userdata);
void tox_callback_friend_request(Tox *tox, void (*function)(Tox *tox, const uint8_t *, const uint8_t *, uint16_t,
void *), void *userdata);
/* Set the function that will be executed when a message from a friend is received.
* Function format is: function(Tox *tox, int32_t friendnumber, uint8_t * message, uint32_t length, void *userdata)