libnetapi: second pass of style cleanup
* remarks from Axel
This commit is contained in:
@@ -97,8 +97,9 @@ BAbstractSocket::SetTimeout(bigtime_t timeout)
|
|||||||
|
|
||||||
if (setsockopt(fSocket, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(timeval)) != 0
|
if (setsockopt(fSocket, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(timeval)) != 0
|
||||||
|| setsockopt(fSocket, SOL_SOCKET, SO_RCVTIMEO, &tv,
|
|| setsockopt(fSocket, SOL_SOCKET, SO_RCVTIMEO, &tv,
|
||||||
sizeof(timeval)) != 0)
|
sizeof(timeval)) != 0) {
|
||||||
return errno;
|
return errno;
|
||||||
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,9 +153,8 @@ DynamicBuffer::_GrowToFit(size_t size, bool exact)
|
|||||||
if (newBuffer == NULL)
|
if (newBuffer == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
if (fDataStart != fDataEnd) {
|
if (fDataStart != fDataEnd)
|
||||||
memcpy(newBuffer, fBuffer + fDataStart, fDataEnd - fDataStart);
|
memcpy(newBuffer, fBuffer + fDataStart, fDataEnd - fDataStart);
|
||||||
}
|
|
||||||
|
|
||||||
delete[] fBuffer;
|
delete[] fBuffer;
|
||||||
fBuffer = newBuffer;
|
fBuffer = newBuffer;
|
||||||
|
|||||||
@@ -154,9 +154,9 @@ BHttpAuthentication::Initialize(const BString& wwwAuthenticate)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
else if (fAuthenticationMethod == B_HTTP_AUTHENTICATION_DIGEST
|
else if (fAuthenticationMethod == B_HTTP_AUTHENTICATION_DIGEST
|
||||||
&& fDigestNonce.Length() > 0
|
&& fDigestNonce.Length() > 0
|
||||||
&& fDigestAlgorithm != B_HTTP_AUTHENTICATION_ALGORITHM_NONE)
|
&& fDigestAlgorithm != B_HTTP_AUTHENTICATION_ALGORITHM_NONE) {
|
||||||
return B_OK;
|
return B_OK;
|
||||||
else
|
} else
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -778,7 +778,6 @@ BHttpForm::Iterator::_FindNext()
|
|||||||
if (fStdIterator != fForm->fFields.end()) {
|
if (fStdIterator != fForm->fFields.end()) {
|
||||||
fElement = &fStdIterator->second;
|
fElement = &fStdIterator->second;
|
||||||
fStdIterator++;
|
fStdIterator++;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
fElement = NULL;
|
fElement = NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -607,7 +607,8 @@ BHttpRequest::_MakeRequest()
|
|||||||
// 2 more bytes to handle the closing CR+LF
|
// 2 more bytes to handle the closing CR+LF
|
||||||
bytesRead = chunkSize;
|
bytesRead = chunkSize;
|
||||||
inputTempBuffer = new char[chunkSize + 2];
|
inputTempBuffer = new char[chunkSize + 2];
|
||||||
fInputBuffer.RemoveData(inputTempBuffer, chunkSize+2);
|
fInputBuffer.RemoveData(inputTempBuffer,
|
||||||
|
chunkSize + 2);
|
||||||
chunkSize = -1;
|
chunkSize = -1;
|
||||||
} else {
|
} else {
|
||||||
// Not enough data, try again later
|
// Not enough data, try again later
|
||||||
@@ -634,9 +635,8 @@ BHttpRequest::_MakeRequest()
|
|||||||
chunkSize = strtol(chunkHeader.String(), NULL, 16);
|
chunkSize = strtol(chunkHeader.String(), NULL, 16);
|
||||||
PRINT(("BHP[%p] Chunk %s=%ld\n", this,
|
PRINT(("BHP[%p] Chunk %s=%ld\n", this,
|
||||||
chunkHeader.String(), chunkSize));
|
chunkHeader.String(), chunkSize));
|
||||||
if (chunkSize == 0) {
|
if (chunkSize == 0)
|
||||||
fRequestStatus = kRequestContentReceived;
|
fRequestStatus = kRequestContentReceived;
|
||||||
}
|
|
||||||
|
|
||||||
bytesRead = -1;
|
bytesRead = -1;
|
||||||
inputTempBuffer = NULL;
|
inputTempBuffer = NULL;
|
||||||
|
|||||||
@@ -92,9 +92,8 @@ BNetBuffer::Archive(BMessage* into, bool deep) const
|
|||||||
BArchivable*
|
BArchivable*
|
||||||
BNetBuffer::Instantiate(BMessage* archive)
|
BNetBuffer::Instantiate(BMessage* archive)
|
||||||
{
|
{
|
||||||
if (!validate_instantiation(archive, "BNetBuffer")) {
|
if (!validate_instantiation(archive, "BNetBuffer"))
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
BNetBuffer* buffer = new (std::nothrow) BNetBuffer(archive);
|
BNetBuffer* buffer = new (std::nothrow) BNetBuffer(archive);
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
@@ -345,7 +344,6 @@ BNetBuffer::RemoveMessage(BMessage& data)
|
|||||||
if (*(int32*)bufferPtr != B_MESSAGE_TYPE)
|
if (*(int32*)bufferPtr != B_MESSAGE_TYPE)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
|
|
||||||
bufferPtr += sizeof(int32);
|
bufferPtr += sizeof(int32);
|
||||||
int32 dataSize = *(int32*)bufferPtr;
|
int32 dataSize = *(int32*)bufferPtr;
|
||||||
|
|
||||||
|
|||||||
@@ -187,4 +187,3 @@ void BNetDebug::Dump(const char* data, size_t size, const char* title)
|
|||||||
|
|
||||||
|
|
||||||
/*=------------------------------------------------------------------- End -=*/
|
/*=------------------------------------------------------------------- End -=*/
|
||||||
|
|
||||||
|
|||||||
@@ -1008,8 +1008,9 @@ BNetworkAddress::Equals(const BNetworkAddress& other, bool includePort) const
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (Family() != other.Family()
|
if (Family() != other.Family()
|
||||||
|| (includePort && Port() != other.Port()))
|
|| (includePort && Port() != other.Port())) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
switch (fAddress.ss_family) {
|
switch (fAddress.ss_family) {
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
|
|||||||
@@ -18,8 +18,9 @@ strip_port(BString& host, BString& port)
|
|||||||
int32 first = host.FindFirst(':');
|
int32 first = host.FindFirst(':');
|
||||||
int32 separator = host.FindLast(':');
|
int32 separator = host.FindLast(':');
|
||||||
if (separator != first
|
if (separator != first
|
||||||
&& (separator == 0 || host.ByteAt(separator - 1) != ']'))
|
&& (separator == 0 || host.ByteAt(separator - 1) != ']')) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (separator != -1) {
|
if (separator != -1) {
|
||||||
// looks like there is a port
|
// looks like there is a port
|
||||||
|
|||||||
@@ -453,11 +453,8 @@ BNetworkCookie::IsValidForDomain(const BString& domain) const
|
|||||||
// Otherwise, the domains must match exactly, or the domain must have a dot
|
// Otherwise, the domains must match exactly, or the domain must have a dot
|
||||||
// character just before the common suffix.
|
// character just before the common suffix.
|
||||||
const char* suffix = domain.String() + difference;
|
const char* suffix = domain.String() + difference;
|
||||||
if (strcmp(suffix, cookieDomain.String()) == 0 && (difference == 0
|
return (strcmp(suffix, cookieDomain.String()) == 0 && (difference == 0
|
||||||
|| domain[difference - 1] == '.'))
|
|| domain[difference - 1] == '.'));
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -512,8 +512,7 @@ BNetworkCookieJar::Iterator::Remove()
|
|||||||
if (fLastList->CountItems() == 1) {
|
if (fLastList->CountItems() == 1) {
|
||||||
fIterator->fCookieMapIterator.Remove();
|
fIterator->fCookieMapIterator.Remove();
|
||||||
delete fLastList;
|
delete fLastList;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
fLastList->RemoveItemAt(fLastList->CountItems() - 1);
|
fLastList->RemoveItemAt(fLastList->CountItems() - 1);
|
||||||
} else {
|
} else {
|
||||||
fIndex--;
|
fIndex--;
|
||||||
|
|||||||
@@ -844,8 +844,9 @@ BNetworkDevice::GetNextAssociatedNetwork(uint32& cookie,
|
|||||||
return status;
|
return status;
|
||||||
|
|
||||||
if (mac[0] == 0 && mac[1] == 0 && mac[2] == 0 && mac[3] == 0 && mac[4] == 0
|
if (mac[0] == 0 && mac[1] == 0 && mac[2] == 0 && mac[3] == 0 && mac[4] == 0
|
||||||
&& mac[5] == 0)
|
&& mac[5] == 0) {
|
||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
address.SetToLinkLevel(mac, IEEE80211_ADDR_LEN);
|
address.SetToLinkLevel(mac, IEEE80211_ADDR_LEN);
|
||||||
cookie++;
|
cookie++;
|
||||||
|
|||||||
@@ -401,8 +401,9 @@ BNetworkInterface::FindAddress(const BNetworkAddress& address)
|
|||||||
memcpy(&request.ifra_addr, &address.SockAddr(), address.Length());
|
memcpy(&request.ifra_addr, &address.SockAddr(), address.Length());
|
||||||
|
|
||||||
if (ioctl(socket, B_SOCKET_GET_ALIAS, &request, sizeof(struct ifaliasreq))
|
if (ioctl(socket, B_SOCKET_GET_ALIAS, &request, sizeof(struct ifaliasreq))
|
||||||
< 0)
|
< 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return request.ifra_index;
|
return request.ifra_index;
|
||||||
}
|
}
|
||||||
@@ -425,8 +426,9 @@ BNetworkInterface::FindFirstAddress(int family)
|
|||||||
request.ifra_addr.ss_family = AF_UNSPEC;
|
request.ifra_addr.ss_family = AF_UNSPEC;
|
||||||
|
|
||||||
if (ioctl(socket, B_SOCKET_GET_ALIAS, &request, sizeof(struct ifaliasreq))
|
if (ioctl(socket, B_SOCKET_GET_ALIAS, &request, sizeof(struct ifaliasreq))
|
||||||
< 0)
|
< 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return request.ifra_index;
|
return request.ifra_index;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -759,9 +759,9 @@ BUrl::_DoUrlEncodeChunk(const BString& chunk, bool strict, bool directory)
|
|||||||
|
|
||||||
for (int32 i = 0; i < chunk.Length(); i++) {
|
for (int32 i = 0; i < chunk.Length(); i++) {
|
||||||
if (_IsUnreserved(chunk[i])
|
if (_IsUnreserved(chunk[i])
|
||||||
|| (directory && (chunk[i] == '/' || chunk[i] == '\\')))
|
|| (directory && (chunk[i] == '/' || chunk[i] == '\\'))) {
|
||||||
result << chunk[i];
|
result << chunk[i];
|
||||||
else {
|
} else {
|
||||||
if (chunk[i] == ' ' && !strict) {
|
if (chunk[i] == ' ' && !strict) {
|
||||||
result << '+';
|
result << '+';
|
||||||
// In non-strict mode, spaces are encoded by a plus sign
|
// In non-strict mode, spaces are encoded by a plus sign
|
||||||
@@ -818,31 +818,22 @@ BUrl::_IsProtocolValid()
|
|||||||
bool
|
bool
|
||||||
BUrl::_IsUnreserved(char c)
|
BUrl::_IsUnreserved(char c)
|
||||||
{
|
{
|
||||||
if (isalnum(c) || c == '-' || c == '.' || c == '_' || c == '~')
|
return isalnum(c) || c == '-' || c == '.' || c == '_' || c == '~';
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BUrl::_IsGenDelim(char c)
|
BUrl::_IsGenDelim(char c)
|
||||||
{
|
{
|
||||||
if (c == ':' || c == '/' || c == '?' || c == '#' || c == '['
|
return c == ':' || c == '/' || c == '?' || c == '#' || c == '['
|
||||||
|| c == ']' || c == '@')
|
|| c == ']' || c == '@';
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BUrl::_IsSubDelim(char c)
|
BUrl::_IsSubDelim(char c)
|
||||||
{
|
{
|
||||||
if (c == '!' || c == '$' || c == '&' || c == '\'' || c == '('
|
return c == '!' || c == '$' || c == '&' || c == '\'' || c == '('
|
||||||
|| c == ')' || c == '*' || c == '+' || c == ',' || c == ';'
|
|| c == ')' || c == '*' || c == '+' || c == ',' || c == ';'
|
||||||
|| c == '=')
|
|| c == '=';
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,10 +30,11 @@ BUrlProtocolAsynchronousListener::BUrlProtocolAsynchronousListener(
|
|||||||
else
|
else
|
||||||
PRINT(("Cannot lock be_app\n"));
|
PRINT(("Cannot lock be_app\n"));
|
||||||
|
|
||||||
if (transparent)
|
if (transparent) {
|
||||||
fSynchronousListener
|
fSynchronousListener
|
||||||
= new(std::nothrow) BUrlProtocolDispatchingListener(this);
|
= new(std::nothrow) BUrlProtocolDispatchingListener(this);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BUrlProtocolAsynchronousListener::~BUrlProtocolAsynchronousListener()
|
BUrlProtocolAsynchronousListener::~BUrlProtocolAsynchronousListener()
|
||||||
@@ -65,13 +66,11 @@ BUrlProtocolAsynchronousListener::MessageReceived(BMessage* message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
BUrlRequest* caller;
|
BUrlRequest* caller;
|
||||||
if (message->FindPointer(kUrlProtocolCaller,
|
if (message->FindPointer(kUrlProtocolCaller, (void**)&caller) != B_OK)
|
||||||
reinterpret_cast<void**>(&caller)) != B_OK)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int8 notification;
|
int8 notification;
|
||||||
if (message->FindInt8(kUrlProtocolMessageType, ¬ification)
|
if (message->FindInt8(kUrlProtocolMessageType, ¬ification) != B_OK)
|
||||||
!= B_OK)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (notification) {
|
switch (notification) {
|
||||||
|
|||||||
Reference in New Issue
Block a user