[prev in list] [next in list] [prev in thread] [next in thread]
List: haiku-commits
Subject: [haiku-commits] haiku: hrev46450 - src/kits/network/libnetapi
From: korli () users ! berlios ! de
Date: 2013-11-26 22:37:19
Message-ID: 20131126223719.ED5975C0D95 () vmrepo ! haiku-os ! org
[Download RAW message or body]
hrev46450 adds 1 changeset to branch 'master'
old head: 8d23c440f7b0433f0daccf7e4018f99b8d3c3459
new head: 754bbf4866278ecd2da2c517560bc90c67a3a6f5
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=754bbf4+%5E8d23c44
----------------------------------------------------------------------------
754bbf4: libnetapi: second pass of style cleanup
* remarks from Axel
[ Jérôme Duval <jerome.duval@gmail.com> ]
----------------------------------------------------------------------------
Revision: hrev46450
Commit: 754bbf4866278ecd2da2c517560bc90c67a3a6f5
URL: http://cgit.haiku-os.org/haiku/commit/?id=754bbf4
Author: Jérôme Duval <jerome.duval@gmail.com>
Date: Tue Nov 26 22:24:46 2013 UTC
----------------------------------------------------------------------------
16 files changed, 148 insertions(+), 161 deletions(-)
src/kits/network/libnetapi/AbstractSocket.cpp | 3 +-
src/kits/network/libnetapi/DynamicBuffer.cpp | 25 ++--
.../network/libnetapi/HttpAuthentication.cpp | 130 +++++++++----------
src/kits/network/libnetapi/HttpForm.cpp | 9 +-
src/kits/network/libnetapi/HttpRequest.cpp | 10 +-
src/kits/network/libnetapi/NetBuffer.cpp | 58 ++++-----
src/kits/network/libnetapi/NetDebug.cpp | 13 +-
src/kits/network/libnetapi/NetworkAddress.cpp | 3 +-
.../network/libnetapi/NetworkAddressResolver.cpp | 3 +-
src/kits/network/libnetapi/NetworkCookie.cpp | 7 +-
src/kits/network/libnetapi/NetworkCookieJar.cpp | 3 +-
src/kits/network/libnetapi/NetworkDevice.cpp | 3 +-
src/kits/network/libnetapi/NetworkInterface.cpp | 6 +-
src/kits/network/libnetapi/Url.cpp | 25 ++--
.../UrlProtocolAsynchronousListener.cpp | 9 +-
src/kits/network/libnetapi/UrlRequest.cpp | 2 +-
----------------------------------------------------------------------------
diff --git a/src/kits/network/libnetapi/AbstractSocket.cpp \
b/src/kits/network/libnetapi/AbstractSocket.cpp index e8ccf53..b42b4af 100644
--- a/src/kits/network/libnetapi/AbstractSocket.cpp
+++ b/src/kits/network/libnetapi/AbstractSocket.cpp
@@ -97,8 +97,9 @@ BAbstractSocket::SetTimeout(bigtime_t timeout)
if (setsockopt(fSocket, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(timeval)) != 0
|| setsockopt(fSocket, SOL_SOCKET, SO_RCVTIMEO, &tv,
- sizeof(timeval)) != 0)
+ sizeof(timeval)) != 0) {
return errno;
+ }
return B_OK;
}
diff --git a/src/kits/network/libnetapi/DynamicBuffer.cpp \
b/src/kits/network/libnetapi/DynamicBuffer.cpp index 851dba0..7bbffe7 100644
--- a/src/kits/network/libnetapi/DynamicBuffer.cpp
+++ b/src/kits/network/libnetapi/DynamicBuffer.cpp
@@ -28,7 +28,7 @@ DynamicBuffer::DynamicBuffer(size_t initialSize) :
if (fBuffer != NULL) {
fBufferSize = initialSize;
fInit = B_OK;
- }
+ }
}
}
@@ -73,15 +73,15 @@ status_t
DynamicBuffer::Insert(const void* data, size_t size)
{
if (fInit != B_OK)
- return fInit;
+ return fInit;
status_t result = _GrowToFit(size);
if (result != B_OK)
return result;
-
+
memcpy(fBuffer + fDataEnd, data, size);
fDataEnd += size;
-
+
return B_OK;
}
@@ -94,13 +94,13 @@ DynamicBuffer::Remove(void* data, size_t size)
if (fDataStart + size > fDataEnd)
return B_BUFFER_OVERFLOW;
-
+
memcpy(data, fBuffer + fDataStart, size);
fDataStart += size;
-
+
if (fDataStart == fDataEnd)
fDataStart = fDataEnd = 0;
-
+
return B_OK;
}
@@ -133,7 +133,7 @@ DynamicBuffer::PrintToStream()
printf("Data start position : %ld\n", fDataStart);
printf("Data end position : %ld\n", fDataEnd);
printf("Bytes wasted : %ld\n", fDataStart);
- printf("Bytes available : %ld\n", fBufferSize - fDataEnd);
+ printf("Bytes available : %ld\n", fBufferSize - fDataEnd);
}
@@ -144,7 +144,7 @@ DynamicBuffer::_GrowToFit(size_t size, bool exact)
return B_OK;
size_t newSize;
- if (!exact)
+ if (!exact)
newSize = (fBufferSize + size) * 2;
else
newSize = size;
@@ -153,10 +153,9 @@ DynamicBuffer::_GrowToFit(size_t size, bool exact)
if (newBuffer == NULL)
return B_NO_MEMORY;
- if (fDataStart != fDataEnd) {
- memcpy(newBuffer, fBuffer + fDataStart, fDataEnd - fDataStart);
- }
-
+ if (fDataStart != fDataEnd)
+ memcpy(newBuffer, fBuffer + fDataStart, fDataEnd - fDataStart);
+
delete[] fBuffer;
fBuffer = newBuffer;
fDataEnd -= fDataStart;
diff --git a/src/kits/network/libnetapi/HttpAuthentication.cpp \
b/src/kits/network/libnetapi/HttpAuthentication.cpp index 5a6f5a4..633632b 100644
--- a/src/kits/network/libnetapi/HttpAuthentication.cpp
+++ b/src/kits/network/libnetapi/HttpAuthentication.cpp
@@ -26,7 +26,7 @@ extern "C" {
#define MD5_DIGEST_LENGTH 16
#endif
-static const char* kBase64Symbols
+static const char* kBase64Symbols
= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
@@ -75,22 +75,22 @@ BHttpAuthentication::Initialize(const BString& wwwAuthenticate)
{
fAuthenticationMethod = B_HTTP_AUTHENTICATION_NONE;
fDigestQop = B_HTTP_QOP_NONE;
-
+
if (wwwAuthenticate.Length() == 0)
return B_BAD_VALUE;
-
+
BString authRequired;
BString additionalData;
int32 firstSpace = wwwAuthenticate.FindFirst(' ');
-
+
if (firstSpace == -1)
wwwAuthenticate.CopyInto(authRequired, 0, wwwAuthenticate.Length());
else {
wwwAuthenticate.CopyInto(authRequired, 0, firstSpace);
- wwwAuthenticate.CopyInto(additionalData, firstSpace+1,
+ wwwAuthenticate.CopyInto(additionalData, firstSpace + 1,
wwwAuthenticate.Length());
}
-
+
authRequired.ToLower();
if (authRequired == "basic")
fAuthenticationMethod = B_HTTP_AUTHENTICATION_BASIC;
@@ -99,35 +99,35 @@ BHttpAuthentication::Initialize(const BString& wwwAuthenticate)
fDigestAlgorithm = B_HTTP_AUTHENTICATION_ALGORITHM_MD5;
} else
return B_ERROR;
-
-
+
+
while (additionalData.Length()) {
int32 firstColon = additionalData.FindFirst(',');
if (firstColon == -1)
firstColon = additionalData.Length();
-
+
BString value;
additionalData.MoveInto(value, 0, firstColon);
additionalData.Remove(0, 1);
additionalData.Trim();
-
+
int32 equal = value.FindFirst('=');
if (equal == -1)
continue;
-
+
BString name;
value.MoveInto(name, 0, equal);
value.Remove(0, 1);
name.ToLower();
-
+
if (value[0] == '"') {
value.Remove(0, 1);
value.Remove(value.Length()-1, 1);
}
-
- PRINT(("HttpAuth: name=%s, value=%s\n", name.String(),
+
+ PRINT(("HttpAuth: name=%s, value=%s\n", name.String(),
value.String()));
-
+
if (name == "realm")
fRealm = value;
else if (name == "nonce")
@@ -139,7 +139,7 @@ BHttpAuthentication::Initialize(const BString& wwwAuthenticate)
fDigestStale = (value == "true");
} else if (name == "algorithm") {
value.ToLower();
-
+
if (value == "md5")
fDigestAlgorithm = B_HTTP_AUTHENTICATION_ALGORITHM_MD5;
else if (value == "md5-sess")
@@ -148,15 +148,15 @@ BHttpAuthentication::Initialize(const BString& wwwAuthenticate)
fDigestAlgorithm = B_HTTP_AUTHENTICATION_ALGORITHM_NONE;
} else if (name == "qop")
fDigestQop = B_HTTP_QOP_AUTH;
- }
-
+ }
+
if (fAuthenticationMethod == B_HTTP_AUTHENTICATION_BASIC)
return B_OK;
else if (fAuthenticationMethod == B_HTTP_AUTHENTICATION_DIGEST
- && fDigestNonce.Length() > 0
- && fDigestAlgorithm != B_HTTP_AUTHENTICATION_ALGORITHM_NONE)
+ && fDigestNonce.Length() > 0
+ && fDigestAlgorithm != B_HTTP_AUTHENTICATION_ALGORITHM_NONE) {
return B_OK;
- else
+ } else
return B_ERROR;
}
@@ -189,11 +189,11 @@ BString
BHttpAuthentication::Authorization(const BUrl& url, const BString& method) const
{
BString authorizationString;
-
+
switch (fAuthenticationMethod) {
case B_HTTP_AUTHENTICATION_NONE:
break;
-
+
case B_HTTP_AUTHENTICATION_BASIC:
{
BString basicEncode;
@@ -201,43 +201,43 @@ BHttpAuthentication::Authorization(const BUrl& url, const \
BString& method) const authorizationString << "Basic " << Base64Encode(basicEncode);
break;
}
-
+
case B_HTTP_AUTHENTICATION_DIGEST:
case B_HTTP_AUTHENTICATION_IE_DIGEST:
- authorizationString << "Digest " << "username=\"" << fUserName
+ authorizationString << "Digest " << "username=\"" << fUserName
<< "\", realm=\"" << fRealm << "\", nonce=\"" << fDigestNonce
<< "\", algorithm=";
-
+
if (fDigestAlgorithm == B_HTTP_AUTHENTICATION_ALGORITHM_MD5)
authorizationString << "MD5";
else
authorizationString << "MD5-sess";
-
+
if (fDigestOpaque.Length() > 0)
authorizationString << ", opaque=\"" << fDigestOpaque << "\"";
-
+
if (fDigestQop != B_HTTP_QOP_NONE) {
if (fDigestCnonce.Length() == 0) {
fDigestCnonce = _H(fDigestOpaque);
//fDigestCnonce = "03c6790a055cbbac";
- fDigestNc = 0;
+ fDigestNc = 0;
}
-
+
authorizationString << ", uri=\"" << url.Path() << "\"";
authorizationString << ", qop=auth, cnonce=\"" << fDigestCnonce
<< "\"";
-
+
char strNc[9];
snprintf(strNc, 9, "%08x", ++fDigestNc);
authorizationString << ", nc=" << strNc;
-
+
}
-
- authorizationString << ", response=\""
+
+ authorizationString << ", response=\""
<< _DigestResponse(url.Path(), method) << "\"";
break;
}
-
+
return authorizationString;
}
@@ -250,22 +250,22 @@ BHttpAuthentication::Base64Encode(const BString& string)
{
BString result;
BString tmpString = string;
-
+
while (tmpString.Length()) {
char in[3] = { 0, 0, 0 };
char out[4] = { 0, 0, 0, 0 };
int8 remaining = tmpString.Length();
-
+
tmpString.MoveInto(in, 0, 3);
-
+
out[0] = (in[0] & 0xFC) >> 2;
out[1] = ((in[0] & 0x03) << 4) | ((in[1] & 0xF0) >> 4);
out[2] = ((in[1] & 0x0F) << 2) | ((in[2] & 0xC0) >> 6);
out[3] = in[2] & 0x3F;
-
+
for (int i = 0; i < 4; i++)
out[i] = kBase64Symbols[(int)out[i]];
-
+
// Add padding if the input length is not a multiple
// of 3
switch (remaining) {
@@ -273,13 +273,13 @@ BHttpAuthentication::Base64Encode(const BString& string)
out[2] = '=';
// Fall through
case 2:
- out[3] = '=';
+ out[3] = '=';
break;
}
-
+
result.Append(out, 4);
}
-
+
return result;
}
@@ -289,33 +289,33 @@ BHttpAuthentication::Base64Decode(const BString& string)
{
BString base64Reverse(kBase64Symbols);
BString result;
-
+
// Invalid input
if (string.Length() % 4 != 0)
return BString("");
-
-
+
+
BString tmpString(string);
while (tmpString.Length()) {
char in[4] = { 0, 0, 0, 0 };
char out[3] = { 0, 0, 0 };
-
+
tmpString.MoveInto(in, 0, 4);
-
+
for (int i = 0; i < 4; i++) {
if (in[i] == '=')
in[i] = 0;
else
in[i] = base64Reverse.FindFirst(in[i], 0);
}
-
+
out[0] = (in[0] << 2) | ((in[1] & 0x30) >> 4);
out[1] = ((in[1] & 0x0F) << 4) | ((in[2] & 0x3C) >> 2);
out[2] = ((in[2] & 0x03) << 6) | in[3];
-
+
result.Append(out, 3);
}
-
+
return result;
}
@@ -332,39 +332,39 @@ BHttpAuthentication::_DigestResponse(const BString& uri, const \
BString& method) PRINT(("HttpAuth: > nc = %08x\n", fDigestNc));
PRINT(("HttpAuth: > uri = %s\n", uri.String()));
PRINT(("HttpAuth: > method = %s\n", method.String()));
- PRINT(("HttpAuth: > algorithm = %d (MD5:%d, MD5-sess:%d)\n",
+ PRINT(("HttpAuth: > algorithm = %d (MD5:%d, MD5-sess:%d)\n",
fDigestAlgorithm, B_HTTP_AUTHENTICATION_ALGORITHM_MD5,
B_HTTP_AUTHENTICATION_ALGORITHM_MD5_SESS));
-
+
BString A1;
A1 << fUserName << ':' << fRealm << ':' << fPassword;
-
+
if (fDigestAlgorithm == B_HTTP_AUTHENTICATION_ALGORITHM_MD5_SESS) {
A1 = _H(A1);
A1 << ':' << fDigestNonce << ':' << fDigestCnonce;
}
-
+
BString A2;
A2 << method << ':' << uri;
-
+
PRINT(("HttpAuth: > A1 = %s\n", A1.String()));
PRINT(("HttpAuth: > A2 = %s\n", A2.String()));
PRINT(("HttpAuth: > H(A1) = %s\n", _H(A1).String()));
PRINT(("HttpAuth: > H(A2) = %s\n", _H(A2).String()));
-
+
char strNc[9];
snprintf(strNc, 9, "%08x", fDigestNc);
-
+
BString secretResp;
secretResp << fDigestNonce << ':' << strNc << ':' << fDigestCnonce
<< ":auth:" << _H(A2);
-
+
PRINT(("HttpAuth: > R2 = %s\n", secretResp.String()));
-
+
BString response = _KD(_H(A1), secretResp);
PRINT(("HttpAuth: > response = %s\n", response.String()));
-
+
return response;
}
@@ -377,7 +377,7 @@ BHttpAuthentication::_H(const BString& value) const
MD5_Init(&context);
MD5_Update(&context, (void *)(value.String()), value.Length());
MD5_Final(hashResult, &context);
-
+
BString result;
// TODO: This is slower than it needs to be. If we already know the
// final hash string length, we can use
@@ -387,12 +387,12 @@ BHttpAuthentication::_H(const BString& value) const
char c = ((hashResult[i] & 0xF0) >> 4);
c += (c > 9) ? 'a' - 10 : '0';
result << c;
-
+
c = hashResult[i] & 0x0F;
c += (c > 9) ? 'a' - 10 : '0';
result << c;
}
-
+
return result;
}
@@ -402,6 +402,6 @@ BHttpAuthentication::_KD(const BString& secret, const BString& \
data) const {
BString encode;
encode << secret << ':' << data;
-
+
return _H(encode);
}
diff --git a/src/kits/network/libnetapi/HttpForm.cpp \
b/src/kits/network/libnetapi/HttpForm.cpp index ce2b3eb..4fd8690 100644
--- a/src/kits/network/libnetapi/HttpForm.cpp
+++ b/src/kits/network/libnetapi/HttpForm.cpp
@@ -638,7 +638,7 @@ BHttpForm::_ExtractNameValuePair(const BString& formString, \
int32* index)
*index = firstAmpersand + 1;
}
-
+
AddString(name, value);
}
@@ -675,10 +675,10 @@ BHttpForm::_GetMultipartHeader(const BHttpFormData* element) \
const case B_HTTPFORM_FILE:
{
result << "; filename=\"" << element->File().Leaf() << '"';
-
+
BNode fileNode(element->File().Path());
BNodeInfo fileInfo(&fileNode);
-
+
result << "\r\nContent-Type: ";
char tempMime[128];
if (fileInfo.GetType(tempMime) == B_OK)
@@ -778,7 +778,6 @@ BHttpForm::Iterator::_FindNext()
if (fStdIterator != fForm->fFields.end()) {
fElement = &fStdIterator->second;
fStdIterator++;
- }
- else
+ } else
fElement = NULL;
}
diff --git a/src/kits/network/libnetapi/HttpRequest.cpp \
b/src/kits/network/libnetapi/HttpRequest.cpp index 28cebb2..3460b0f 100644
--- a/src/kits/network/libnetapi/HttpRequest.cpp
+++ b/src/kits/network/libnetapi/HttpRequest.cpp
@@ -603,11 +603,12 @@ BHttpRequest::_MakeRequest()
// chunk in buffer before handling it
if (readByChunks) {
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
bytesRead = chunkSize;
- inputTempBuffer = new char[chunkSize+2];
- fInputBuffer.RemoveData(inputTempBuffer, chunkSize+2);
+ inputTempBuffer = new char[chunkSize + 2];
+ fInputBuffer.RemoveData(inputTempBuffer,
+ chunkSize + 2);
chunkSize = -1;
} else {
// Not enough data, try again later
@@ -634,9 +635,8 @@ BHttpRequest::_MakeRequest()
chunkSize = strtol(chunkHeader.String(), NULL, 16);
PRINT(("BHP[%p] Chunk %s=%ld\n", this,
chunkHeader.String(), chunkSize));
- if (chunkSize == 0) {
+ if (chunkSize == 0)
fRequestStatus = kRequestContentReceived;
- }
bytesRead = -1;
inputTempBuffer = NULL;
diff --git a/src/kits/network/libnetapi/NetBuffer.cpp \
b/src/kits/network/libnetapi/NetBuffer.cpp index b068931..d2a0911 100644
--- a/src/kits/network/libnetapi/NetBuffer.cpp
+++ b/src/kits/network/libnetapi/NetBuffer.cpp
@@ -49,7 +49,7 @@ BNetBuffer::BNetBuffer(BMessage* archive) :
{
const unsigned char* bufferPtr;
ssize_t bufferSize;
-
+
if (archive->FindData("buffer", B_RAW_TYPE, (const void**)&bufferPtr,
&bufferSize) == B_OK) {
fImpl = new (std::nothrow) DynamicBuffer(bufferSize);
@@ -67,11 +67,11 @@ BNetBuffer&
BNetBuffer::operator=(const BNetBuffer& buffer)
{
delete fImpl;
-
+
fImpl = new (std::nothrow) DynamicBuffer(*buffer.GetImpl());
if (fImpl != NULL)
fInit = fImpl->InitCheck();
-
+
return *this;
}
@@ -81,10 +81,10 @@ BNetBuffer::Archive(BMessage* into, bool deep) const
{
if (fInit != B_OK)
return B_NO_INIT;
-
+
status_t result = into->AddData("buffer", B_RAW_TYPE, fImpl->Data(),
fImpl->BytesRemaining());
-
+
return result;
}
@@ -92,9 +92,8 @@ BNetBuffer::Archive(BMessage* into, bool deep) const
BArchivable*
BNetBuffer::Instantiate(BMessage* archive)
{
- if (!validate_instantiation(archive, "BNetBuffer")) {
+ if (!validate_instantiation(archive, "BNetBuffer"))
return NULL;
- }
BNetBuffer* buffer = new (std::nothrow) BNetBuffer(archive);
if (buffer == NULL)
@@ -207,16 +206,16 @@ BNetBuffer::AppendMessage(const BMessage& data)
char* flattenedData = new (std::nothrow) char[dataSize];
if (flattenedData == NULL)
return B_NO_MEMORY;
-
- if (data.Flatten(flattenedData, dataSize) == B_OK)
+
+ if (data.Flatten(flattenedData, dataSize) == B_OK)
result = AppendData((const void*)&flattenedData, dataSize);
-
+
delete[] flattenedData;
} else {
if (data.Flatten(stackFlattenedData, dataSize) == B_OK)
result = AppendData((const void*)&stackFlattenedData, dataSize);
}
-
+
return result;
}
@@ -258,9 +257,9 @@ BNetBuffer::RemoveInt16(int16& data)
status_t result = RemoveData((void*)&be_data, sizeof(int16));
if (result != B_OK)
return result;
-
+
data = B_BENDIAN_TO_HOST_INT16(be_data);
-
+
return B_OK;
}
@@ -272,9 +271,9 @@ BNetBuffer::RemoveUint16(uint16& data)
status_t result = RemoveData((void*)&be_data, sizeof(uint16));
if (result != B_OK)
return result;
-
+
data = B_BENDIAN_TO_HOST_INT16(be_data);
-
+
return B_OK;
}
@@ -286,9 +285,9 @@ BNetBuffer::RemoveInt32(int32& data)
status_t result = RemoveData((void*)&be_data, sizeof(int32));
if (result != B_OK)
return result;
-
+
data = B_BENDIAN_TO_HOST_INT32(be_data);
-
+
return B_OK;
}
@@ -300,9 +299,9 @@ BNetBuffer::RemoveUint32(uint32& data)
status_t result = RemoveData((void*)&be_data, sizeof(uint32));
if (result != B_OK)
return result;
-
+
data = B_BENDIAN_TO_HOST_INT32(be_data);
-
+
return B_OK;
}
@@ -341,24 +340,23 @@ status_t
BNetBuffer::RemoveMessage(BMessage& data)
{
unsigned char* bufferPtr = fImpl->Data();
-
+
if (*(int32*)bufferPtr != B_MESSAGE_TYPE)
return B_ERROR;
-
-
+
bufferPtr += sizeof(int32);
int32 dataSize = *(int32*)bufferPtr;
-
+
char* flattenedData = new (std::nothrow) char[dataSize];
if (flattenedData == NULL)
return B_NO_MEMORY;
-
+
status_t result = RemoveData(flattenedData, dataSize);
if (result == B_OK)
result = data.Unflatten(flattenedData);
-
+
delete[] flattenedData;
-
+
return result;
}
@@ -370,9 +368,9 @@ BNetBuffer::RemoveInt64(int64& data)
status_t result = RemoveData((void*)&be_data, sizeof(int64));
if (result != B_OK)
return result;
-
+
data = B_BENDIAN_TO_HOST_INT64(be_data);
-
+
return B_OK;
}
@@ -384,9 +382,9 @@ BNetBuffer::RemoveUint64(uint64& data)
status_t result = RemoveData((void*)&be_data, sizeof(uint64));
if (result != B_OK)
return result;
-
+
data = B_BENDIAN_TO_HOST_INT64(be_data);
-
+
return B_OK;
}
diff --git a/src/kits/network/libnetapi/NetDebug.cpp \
b/src/kits/network/libnetapi/NetDebug.cpp index 5e07ab9..cdcc848 100644
--- a/src/kits/network/libnetapi/NetDebug.cpp
+++ b/src/kits/network/libnetapi/NetDebug.cpp
@@ -142,10 +142,10 @@ void BNetDebug::Dump(const char* data, size_t size, const char* \
title)
if ( ! g_NetDebugEnabled)
return;
-
+
fprintf( stderr, "----------\n%s\n(dumping %ld bytes)\n",
title ? title : "(untitled)", size );
-
+
if (! data)
fprintf(stderr, "NULL data!\n");
else {
@@ -157,18 +157,18 @@ void BNetDebug::Dump(const char* data, size_t size, const char* \
title) for ( i = 0; i < size; i += 16 ) {
ptr = text;
- for ( j = i; j < i+16 ; j++ ) {
+ for ( j = i; j < i + 16 ; j++ ) {
if ( j < size )
sprintf(ptr, "%02x ", byte[j]);
else
sprintf(ptr, " ");
ptr += 3;
};
-
+
strcat(ptr, "| ");
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 )
*ptr = byte[j];
else
@@ -187,4 +187,3 @@ void BNetDebug::Dump(const char* data, size_t size, const char* \
title)
/*=------------------------------------------------------------------- End -=*/
-
diff --git a/src/kits/network/libnetapi/NetworkAddress.cpp \
b/src/kits/network/libnetapi/NetworkAddress.cpp index e28f007..d8b1e80 100644
--- a/src/kits/network/libnetapi/NetworkAddress.cpp
+++ b/src/kits/network/libnetapi/NetworkAddress.cpp
@@ -1008,8 +1008,9 @@ BNetworkAddress::Equals(const BNetworkAddress& other, bool \
includePort) const return true;
if (Family() != other.Family()
- || (includePort && Port() != other.Port()))
+ || (includePort && Port() != other.Port())) {
return false;
+ }
switch (fAddress.ss_family) {
case AF_INET:
diff --git a/src/kits/network/libnetapi/NetworkAddressResolver.cpp \
b/src/kits/network/libnetapi/NetworkAddressResolver.cpp index 27ceaa4..970767c 100644
--- a/src/kits/network/libnetapi/NetworkAddressResolver.cpp
+++ b/src/kits/network/libnetapi/NetworkAddressResolver.cpp
@@ -18,8 +18,9 @@ strip_port(BString& host, BString& port)
int32 first = host.FindFirst(':');
int32 separator = host.FindLast(':');
if (separator != first
- && (separator == 0 || host.ByteAt(separator - 1) != ']'))
+ && (separator == 0 || host.ByteAt(separator - 1) != ']')) {
return false;
+ }
if (separator != -1) {
// looks like there is a port
diff --git a/src/kits/network/libnetapi/NetworkCookie.cpp \
b/src/kits/network/libnetapi/NetworkCookie.cpp index a4b993e..bb85614 100644
--- a/src/kits/network/libnetapi/NetworkCookie.cpp
+++ b/src/kits/network/libnetapi/NetworkCookie.cpp
@@ -453,11 +453,8 @@ BNetworkCookie::IsValidForDomain(const BString& domain) const
// Otherwise, the domains must match exactly, or the domain must have a dot
// character just before the common suffix.
const char* suffix = domain.String() + difference;
- if (strcmp(suffix, cookieDomain.String()) == 0 && (difference == 0
- || domain[difference - 1] == '.'))
- return true;
-
- return false;
+ return (strcmp(suffix, cookieDomain.String()) == 0 && (difference == 0
+ || domain[difference - 1] == '.'));
}
diff --git a/src/kits/network/libnetapi/NetworkCookieJar.cpp \
b/src/kits/network/libnetapi/NetworkCookieJar.cpp index f360ebe..ae97f37 100644
--- a/src/kits/network/libnetapi/NetworkCookieJar.cpp
+++ b/src/kits/network/libnetapi/NetworkCookieJar.cpp
@@ -512,8 +512,7 @@ BNetworkCookieJar::Iterator::Remove()
if (fLastList->CountItems() == 1) {
fIterator->fCookieMapIterator.Remove();
delete fLastList;
- }
- else
+ } else
fLastList->RemoveItemAt(fLastList->CountItems() - 1);
} else {
fIndex--;
diff --git a/src/kits/network/libnetapi/NetworkDevice.cpp \
b/src/kits/network/libnetapi/NetworkDevice.cpp index 827ee06..57b8dd1 100644
--- a/src/kits/network/libnetapi/NetworkDevice.cpp
+++ b/src/kits/network/libnetapi/NetworkDevice.cpp
@@ -844,8 +844,9 @@ BNetworkDevice::GetNextAssociatedNetwork(uint32& cookie,
return status;
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;
+ }
address.SetToLinkLevel(mac, IEEE80211_ADDR_LEN);
cookie++;
diff --git a/src/kits/network/libnetapi/NetworkInterface.cpp \
b/src/kits/network/libnetapi/NetworkInterface.cpp index 95b41f1..fcb0413 100644
--- a/src/kits/network/libnetapi/NetworkInterface.cpp
+++ b/src/kits/network/libnetapi/NetworkInterface.cpp
@@ -401,8 +401,9 @@ BNetworkInterface::FindAddress(const BNetworkAddress& address)
memcpy(&request.ifra_addr, &address.SockAddr(), address.Length());
if (ioctl(socket, B_SOCKET_GET_ALIAS, &request, sizeof(struct ifaliasreq))
- < 0)
+ < 0) {
return -1;
+ }
return request.ifra_index;
}
@@ -425,8 +426,9 @@ BNetworkInterface::FindFirstAddress(int family)
request.ifra_addr.ss_family = AF_UNSPEC;
if (ioctl(socket, B_SOCKET_GET_ALIAS, &request, sizeof(struct ifaliasreq))
- < 0)
+ < 0) {
return -1;
+ }
return request.ifra_index;
}
diff --git a/src/kits/network/libnetapi/Url.cpp b/src/kits/network/libnetapi/Url.cpp
index d0952ef..d29e166 100644
--- a/src/kits/network/libnetapi/Url.cpp
+++ b/src/kits/network/libnetapi/Url.cpp
@@ -759,9 +759,9 @@ BUrl::_DoUrlEncodeChunk(const BString& chunk, bool strict, bool \
directory)
for (int32 i = 0; i < chunk.Length(); i++) {
if (_IsUnreserved(chunk[i])
- || (directory && (chunk[i] == '/' || chunk[i] == '\\')))
+ || (directory && (chunk[i] == '/' || chunk[i] == '\\'))) {
result << chunk[i];
- else {
+ } else {
if (chunk[i] == ' ' && !strict) {
result << '+';
// 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] != '%')
result << chunk[i];
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);
i += 2;
@@ -818,31 +818,22 @@ BUrl::_IsProtocolValid()
bool
BUrl::_IsUnreserved(char c)
{
- if (isalnum(c) || c == '-' || c == '.' || c == '_' || c == '~')
- return true;
- else
- return false;
+ return isalnum(c) || c == '-' || c == '.' || c == '_' || c == '~';
}
bool
BUrl::_IsGenDelim(char c)
{
- if (c == ':' || c == '/' || c == '?' || c == '#' || c == '['
- || c == ']' || c == '@')
- return true;
- else
- return false;
+ return c == ':' || c == '/' || c == '?' || c == '#' || c == '['
+ || c == ']' || c == '@';
}
bool
BUrl::_IsSubDelim(char c)
{
- if (c == '!' || c == '$' || c == '&' || c == '\'' || c == '('
+ return c == '!' || c == '$' || c == '&' || c == '\'' || c == '('
|| c == ')' || c == '*' || c == '+' || c == ',' || c == ';'
- || c == '=')
- return true;
- else
- return false;
+ || c == '=';
}
diff --git a/src/kits/network/libnetapi/UrlProtocolAsynchronousListener.cpp \
b/src/kits/network/libnetapi/UrlProtocolAsynchronousListener.cpp index \
e7e1ed6..9262eb4 100644
--- a/src/kits/network/libnetapi/UrlProtocolAsynchronousListener.cpp
+++ b/src/kits/network/libnetapi/UrlProtocolAsynchronousListener.cpp
@@ -30,9 +30,10 @@ BUrlProtocolAsynchronousListener::BUrlProtocolAsynchronousListener(
else
PRINT(("Cannot lock be_app\n"));
- if (transparent)
+ if (transparent) {
fSynchronousListener
= new(std::nothrow) BUrlProtocolDispatchingListener(this);
+ }
}
@@ -65,13 +66,11 @@ BUrlProtocolAsynchronousListener::MessageReceived(BMessage* \
message) }
BUrlRequest* caller;
- if (message->FindPointer(kUrlProtocolCaller,
- reinterpret_cast<void**>(&caller)) != B_OK)
+ if (message->FindPointer(kUrlProtocolCaller, (void**)&caller) != B_OK)
return;
int8 notification;
- if (message->FindInt8(kUrlProtocolMessageType, ¬ification)
- != B_OK)
+ if (message->FindInt8(kUrlProtocolMessageType, ¬ification) != B_OK)
return;
switch (notification) {
diff --git a/src/kits/network/libnetapi/UrlRequest.cpp \
b/src/kits/network/libnetapi/UrlRequest.cpp index bb34988..e14696e 100644
--- a/src/kits/network/libnetapi/UrlRequest.cpp
+++ b/src/kits/network/libnetapi/UrlRequest.cpp
@@ -12,7 +12,7 @@
#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 running",
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic