1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-08-24 14:48:14 +03:00

Allman now (#6080)

* switch restyle script for CI

* remove confirmation

* restyle with allman
This commit is contained in:
Allman-astyler
2019-05-13 16:41:34 +02:00
committed by david gauchard
parent 625c3a62c4
commit 98125f8860
255 changed files with 51238 additions and 42984 deletions

View File

@@ -10,83 +10,96 @@ extern "C" {
EthernetServer::EthernetServer(uint16_t port)
{
_port = port;
_port = port;
}
void EthernetServer::begin()
{
for (int sock = 0; sock < MAX_SOCK_NUM; sock++) {
EthernetClient client(sock);
if (client.status() == SnSR::CLOSED) {
socket(sock, SnMR::TCP, _port, 0);
listen(sock);
EthernetClass::_server_port[sock] = _port;
break;
for (int sock = 0; sock < MAX_SOCK_NUM; sock++)
{
EthernetClient client(sock);
if (client.status() == SnSR::CLOSED)
{
socket(sock, SnMR::TCP, _port, 0);
listen(sock);
EthernetClass::_server_port[sock] = _port;
break;
}
}
}
}
void EthernetServer::accept()
{
int listening = 0;
int listening = 0;
for (int sock = 0; sock < MAX_SOCK_NUM; sock++) {
EthernetClient client(sock);
for (int sock = 0; sock < MAX_SOCK_NUM; sock++)
{
EthernetClient client(sock);
if (EthernetClass::_server_port[sock] == _port) {
if (client.status() == SnSR::LISTEN) {
listening = 1;
}
else if (client.status() == SnSR::CLOSE_WAIT && !client.available()) {
client.stop();
}
}
}
if (EthernetClass::_server_port[sock] == _port)
{
if (client.status() == SnSR::LISTEN)
{
listening = 1;
}
else if (client.status() == SnSR::CLOSE_WAIT && !client.available())
{
client.stop();
}
}
}
if (!listening) {
begin();
}
if (!listening)
{
begin();
}
}
EthernetClient EthernetServer::available()
{
accept();
accept();
for (int sock = 0; sock < MAX_SOCK_NUM; sock++) {
EthernetClient client(sock);
if (EthernetClass::_server_port[sock] == _port) {
uint8_t s = client.status();
if (s == SnSR::ESTABLISHED || s == SnSR::CLOSE_WAIT) {
if (client.available()) {
// XXX: don't always pick the lowest numbered socket.
return client;
for (int sock = 0; sock < MAX_SOCK_NUM; sock++)
{
EthernetClient client(sock);
if (EthernetClass::_server_port[sock] == _port)
{
uint8_t s = client.status();
if (s == SnSR::ESTABLISHED || s == SnSR::CLOSE_WAIT)
{
if (client.available())
{
// XXX: don't always pick the lowest numbered socket.
return client;
}
}
}
}
}
}
return EthernetClient(MAX_SOCK_NUM);
return EthernetClient(MAX_SOCK_NUM);
}
size_t EthernetServer::write(uint8_t b)
size_t EthernetServer::write(uint8_t b)
{
return write(&b, 1);
return write(&b, 1);
}
size_t EthernetServer::write(const uint8_t *buffer, size_t size)
size_t EthernetServer::write(const uint8_t *buffer, size_t size)
{
size_t n = 0;
accept();
size_t n = 0;
for (int sock = 0; sock < MAX_SOCK_NUM; sock++) {
EthernetClient client(sock);
accept();
if (EthernetClass::_server_port[sock] == _port &&
client.status() == SnSR::ESTABLISHED) {
n += client.write(buffer, size);
for (int sock = 0; sock < MAX_SOCK_NUM; sock++)
{
EthernetClient client(sock);
if (EthernetClass::_server_port[sock] == _port &&
client.status() == SnSR::ESTABLISHED)
{
n += client.write(buffer, size);
}
}
}
return n;
return n;
}