Skip to content

Commit 5154c09

Browse files
author
Virens
committed
format code with astyle error
1 parent 4d95273 commit 5154c09

File tree

2 files changed

+78
-78
lines changed

2 files changed

+78
-78
lines changed

cores/arduino/IPv6Address.cpp

+14-14
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,26 @@ IPv6Address::IPv6Address(const uint32_t *address)
3636
memcpy(_address.bytes, (const uint8_t *)address, sizeof(_address.bytes));
3737
}
3838

39-
IPv6Address& IPv6Address::operator=(const uint8_t *address)
39+
IPv6Address &IPv6Address::operator=(const uint8_t *address)
4040
{
4141
memcpy(_address.bytes, address, sizeof(_address.bytes));
4242
return *this;
4343
}
4444

45-
bool IPv6Address::operator==(const uint8_t* addr) const
45+
bool IPv6Address::operator==(const uint8_t *addr) const
4646
{
4747
return memcmp(addr, _address.bytes, sizeof(_address.bytes)) == 0;
4848
}
4949

50-
size_t IPv6Address::printTo(Print& p) const
50+
size_t IPv6Address::printTo(Print &p) const
5151
{
5252
size_t n = 0;
53-
for(int i = 0; i < 16; i+=2) {
54-
if(i){
53+
for (int i = 0; i < 16; i += 2) {
54+
if(i) {
5555
n += p.print(':');
5656
}
5757
n += p.printf("%02x", _address.bytes[i]);
58-
n += p.printf("%02x", _address.bytes[i+1]);
58+
n += p.printf("%02x", _address.bytes[i + 1]);
5959

6060
}
6161
return n;
@@ -64,24 +64,24 @@ size_t IPv6Address::printTo(Print& p) const
6464
String IPv6Address::toString() const
6565
{
6666
char szRet[40];
67-
sprintf(szRet,"%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
68-
_address.bytes[0], _address.bytes[1], _address.bytes[2], _address.bytes[3],
69-
_address.bytes[4], _address.bytes[5], _address.bytes[6], _address.bytes[7],
70-
_address.bytes[8], _address.bytes[9], _address.bytes[10], _address.bytes[11],
71-
_address.bytes[12], _address.bytes[13], _address.bytes[14], _address.bytes[15]);
67+
sprintf(szRet, "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
68+
_address.bytes[0], _address.bytes[1], _address.bytes[2], _address.bytes[3],
69+
_address.bytes[4], _address.bytes[5], _address.bytes[6], _address.bytes[7],
70+
_address.bytes[8], _address.bytes[9], _address.bytes[10], _address.bytes[11],
71+
_address.bytes[12], _address.bytes[13], _address.bytes[14], _address.bytes[15]);
7272
return String(szRet);
7373
}
7474

7575
bool IPv6Address::fromString(const char *address)
7676
{
7777
//format 0011:2233:4455:6677:8899:aabb:ccdd:eeff
78-
if(strlen(address) != 39){
78+
if (strlen(address) != 39) {
7979
return false;
8080
}
8181
char * pos = (char *)address;
8282
size_t i = 0;
83-
for(i = 0; i < 16; i+=2) {
84-
if(!sscanf(pos, "%2hhx", &_address.bytes[i]) || !sscanf(pos+2, "%2hhx", &_address.bytes[i+1])){
83+
for (i = 0; i < 16; i += 2) {
84+
if (!sscanf(pos, "%2hhx", &_address.bytes[i]) || !sscanf(pos + 2, "%2hhx", &_address.bytes[i + 1])) {
8585
return false;
8686
}
8787
pos += 5;

cores/arduino/IPv6Address.h

+64-64
Original file line numberDiff line numberDiff line change
@@ -26,70 +26,70 @@
2626

2727
// A class to make it easier to handle and pass around IP addresses
2828

29-
class IPv6Address: public Printable
30-
{
31-
private:
32-
union {
33-
uint8_t bytes[16]; // IPv4 address
34-
uint32_t dword[4];
35-
} _address;
36-
37-
// Access the raw byte array containing the address. Because this returns a pointer
38-
// to the internal structure rather than a copy of the address this function should only
39-
// be used when you know that the usage of the returned uint8_t* will be transient and not
40-
// stored.
41-
uint8_t* raw_address()
42-
{
43-
return _address.bytes;
44-
}
45-
46-
public:
47-
// Constructors
48-
IPv6Address();
49-
IPv6Address(const uint8_t *address);
50-
IPv6Address(const uint32_t *address);
51-
52-
bool fromString(const char *address);
53-
bool fromString(const String &address) {
54-
return fromString(address.c_str());
55-
}
56-
57-
operator const uint8_t*() const
58-
{
59-
return _address.bytes;
60-
}
61-
operator const uint32_t*() const
62-
{
63-
return _address.dword;
64-
}
65-
bool operator==(const IPv6Address& addr) const
66-
{
67-
return (_address.dword[0] == addr._address.dword[0])
68-
&& (_address.dword[1] == addr._address.dword[1])
69-
&& (_address.dword[2] == addr._address.dword[2])
70-
&& (_address.dword[3] == addr._address.dword[3]);
71-
}
72-
bool operator==(const uint8_t* addr) const;
73-
74-
// Overloaded index operator to allow getting and setting individual octets of the address
75-
uint8_t operator[](int index) const
76-
{
77-
return _address.bytes[index];
78-
}
79-
uint8_t& operator[](int index)
80-
{
81-
return _address.bytes[index];
82-
}
83-
84-
// Overloaded copy operators to allow initialisation of IPv6Address objects from other types
85-
IPv6Address& operator=(const uint8_t *address);
86-
87-
virtual size_t printTo(Print& p) const;
88-
String toString() const;
89-
90-
friend class UDP;
91-
friend class Client;
92-
friend class Server;
29+
class IPv6Address: public Printable {
30+
private:
31+
union {
32+
uint8_t bytes[16]; // IPv4 address
33+
uint32_t dword[4];
34+
} _address;
35+
36+
// Access the raw byte array containing the address. Because this returns a pointer
37+
// to the internal structure rather than a copy of the address this function should only
38+
// be used when you know that the usage of the returned uint8_t* will be transient and not
39+
// stored.
40+
uint8_t *raw_address()
41+
{
42+
return _address.bytes;
43+
}
44+
45+
public:
46+
// Constructors
47+
IPv6Address();
48+
IPv6Address(const uint8_t *address);
49+
IPv6Address(const uint32_t *address);
50+
51+
bool fromString(const char *address);
52+
bool fromString(const String &address)
53+
{
54+
return fromString(address.c_str());
55+
}
56+
57+
operator const uint8_t *() const
58+
{
59+
return _address.bytes;
60+
}
61+
operator const uint32_t *() const
62+
{
63+
return _address.dword;
64+
}
65+
bool operator==(const IPv6Address &addr) const
66+
{
67+
return (_address.dword[0] == addr._address.dword[0])
68+
&& (_address.dword[1] == addr._address.dword[1])
69+
&& (_address.dword[2] == addr._address.dword[2])
70+
&& (_address.dword[3] == addr._address.dword[3]);
71+
}
72+
bool operator==(const uint8_t *addr) const;
73+
74+
// Overloaded index operator to allow getting and setting individual octets of the address
75+
uint8_t operator[](int index) const
76+
{
77+
return _address.bytes[index];
78+
}
79+
uint8_t &operator[](int index)
80+
{
81+
return _address.bytes[index];
82+
}
83+
84+
// Overloaded copy operators to allow initialisation of IPv6Address objects from other types
85+
IPv6Address &operator=(const uint8_t *address);
86+
87+
virtual size_t printTo(Print &p) const;
88+
String toString() const;
89+
90+
friend class UDP;
91+
friend class Client;
92+
friend class Server;
9393
};
9494

9595
#endif

0 commit comments

Comments
 (0)