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;
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ BHttpAuthentication::Initialize(const BString& wwwAuthenticate)
|
|||||||
wwwAuthenticate.CopyInto(authRequired, 0, wwwAuthenticate.Length());
|
wwwAuthenticate.CopyInto(authRequired, 0, wwwAuthenticate.Length());
|
||||||
else {
|
else {
|
||||||
wwwAuthenticate.CopyInto(authRequired, 0, firstSpace);
|
wwwAuthenticate.CopyInto(authRequired, 0, firstSpace);
|
||||||
wwwAuthenticate.CopyInto(additionalData, firstSpace+1,
|
wwwAuthenticate.CopyInto(additionalData, firstSpace + 1,
|
||||||
wwwAuthenticate.Length());
|
wwwAuthenticate.Length());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,10 +153,10 @@ BHttpAuthentication::Initialize(const BString& wwwAuthenticate)
|
|||||||
if (fAuthenticationMethod == B_HTTP_AUTHENTICATION_BASIC)
|
if (fAuthenticationMethod == B_HTTP_AUTHENTICATION_BASIC)
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -603,11 +603,12 @@ BHttpRequest::_MakeRequest()
|
|||||||
// chunk in buffer before handling it
|
// chunk in buffer before handling it
|
||||||
if (readByChunks) {
|
if (readByChunks) {
|
||||||
if (chunkSize >= 0) {
|
if (chunkSize >= 0) {
|
||||||
if ((ssize_t)fInputBuffer.Size() >= chunkSize + 2) {
|
if ((ssize_t)fInputBuffer.Size() >= chunkSize + 2) {
|
||||||
// 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;
|
||||||
|
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ void BNetDebug::Dump(const char* data, size_t size, const char* title)
|
|||||||
for ( i = 0; i < size; i += 16 ) {
|
for ( i = 0; i < size; i += 16 ) {
|
||||||
ptr = text;
|
ptr = text;
|
||||||
|
|
||||||
for ( j = i; j < i+16 ; j++ ) {
|
for ( j = i; j < i + 16 ; j++ ) {
|
||||||
if ( j < size )
|
if ( j < size )
|
||||||
sprintf(ptr, "%02x ", byte[j]);
|
sprintf(ptr, "%02x ", byte[j]);
|
||||||
else
|
else
|
||||||
@@ -168,7 +168,7 @@ void BNetDebug::Dump(const char* data, size_t size, const char* title)
|
|||||||
strcat(ptr, "| ");
|
strcat(ptr, "| ");
|
||||||
ptr += 2;
|
ptr += 2;
|
||||||
|
|
||||||
for (j = i; j < size && j < i+16;j++) {
|
for (j = i; j < size && j < i + 16;j++) {
|
||||||
if ( byte[j] >= 0x20 && byte[j] < 0x7e )
|
if ( byte[j] >= 0x20 && byte[j] < 0x7e )
|
||||||
*ptr = byte[j];
|
*ptr = byte[j];
|
||||||
else
|
else
|
||||||
@@ -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
|
||||||
@@ -789,7 +789,7 @@ BUrl::_DoUrlDecodeChunk(const BString& chunk, bool strict)
|
|||||||
else if (chunk[i] != '%')
|
else if (chunk[i] != '%')
|
||||||
result << chunk[i];
|
result << chunk[i];
|
||||||
else {
|
else {
|
||||||
char hexString[] = { chunk[i+1], chunk[i+2], 0 };
|
char hexString[] = { chunk[i + 1], chunk[i + 2], 0 };
|
||||||
result << (char)strtol(hexString, NULL, 16);
|
result << (char)strtol(hexString, NULL, 16);
|
||||||
|
|
||||||
i += 2;
|
i += 2;
|
||||||
@@ -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,9 +30,10 @@ 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -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) {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
static const char* kProtocolThreadStrStatus[B_PROT_THREAD_STATUS__END+1]
|
static const char* kProtocolThreadStrStatus[B_PROT_THREAD_STATUS__END + 1]
|
||||||
= {
|
= {
|
||||||
"Request successfully completed",
|
"Request successfully completed",
|
||||||
"Request running",
|
"Request running",
|
||||||
|
|||||||
Reference in New Issue
Block a user