libnetapi: style cleanup

This commit is contained in:
Jérôme Duval
2013-11-25 18:29:06 +01:00
parent 72086dfe17
commit 97ddf9019d
7 changed files with 68 additions and 73 deletions
+2 -3
View File
@@ -35,7 +35,7 @@ BFileRequest::_ProtocolLoop()
// FIXME error handling (file does not exists, etc.)
BFile file(fUrl.Path().String(), B_READ_ONLY);
if(file.InitCheck() != B_OK || !file.IsFile())
if (file.InitCheck() != B_OK || !file.IsFile())
return B_PROT_CONNECTION_FAILED;
// Send all notifications to listener, if any
@@ -47,10 +47,9 @@ BFileRequest::_ProtocolLoop()
ssize_t chunkSize;
char chunk[4096];
while((chunkSize = file.Read(chunk, sizeof(chunk))) > 0)
while ((chunkSize = file.Read(chunk, sizeof(chunk))) > 0)
fListener->DataReceived(this, chunk, chunkSize);
}
return B_PROT_SUCCESS;
}
+5 -6
View File
@@ -203,7 +203,7 @@ BNetworkCookie::SetValue(const BString& value)
status_t
BNetworkCookie::SetPath(const BString& path)
{
if(path[0] != '/')
if (path[0] != '/')
return B_BAD_DATA;
// TODO: canonicalize the path
@@ -225,11 +225,11 @@ BNetworkCookie::SetDomain(const BString& domain)
// not specified at all (in this case it has to exactly match the Url of
// the page that set the cookie). In any case, we don't need to handle
// dot-cookies specifically anymore, so just remove the extra dot.
if(newDomain[0] == '.')
if (newDomain[0] == '.')
newDomain.Remove(0, 1);
// check we're not trying to set a cookie on a TLD or empty domain
if(newDomain.FindLast('.') <= 0)
if (newDomain.FindLast('.') <= 0)
return B_BAD_DATA;
fDomain = newDomain.ToLower();
@@ -468,7 +468,7 @@ BNetworkCookie::IsValidForPath(const BString& path) const
BString normalizedPath = path;
int slashPos = normalizedPath.FindLast('/');
if(slashPos != normalizedPath.Length() - 1)
if (slashPos != normalizedPath.Length() - 1)
normalizedPath.Truncate(slashPos + 1);
if (normalizedPath.Length() < cookiePath.Length())
@@ -745,8 +745,7 @@ BNetworkCookie::_ExtractAttributeValuePair(const BString& cookieString,
value.SetTo("");
// values may (or may not) have quotes around them.
if(value[0] == '"' && value[value.Length() - 1] == '"')
{
if (value[0] == '"' && value[value.Length() - 1] == '"') {
value.Remove(0, 1);
value.Remove(value.Length() - 1, 1);
}
@@ -361,7 +361,7 @@ BNetworkCookieJar::Unflatten(type_code, const void* buffer, ssize_t size)
BNetworkCookieJar&
BNetworkCookieJar::operator=(const BNetworkCookieJar& other)
{
if(&other == this)
if (&other == this)
return *this;
BArchivable::operator=(other);
@@ -372,8 +372,7 @@ BNetworkCookieJar::operator=(const BNetworkCookieJar& other)
delete fCookieHashMap;
fCookieHashMap = new PrivateHashMap();
for (Iterator it = other.GetIterator(); it.HasNext();)
{
for (Iterator it = other.GetIterator(); it.HasNext();) {
BNetworkCookie* cookie = it.Next();
AddCookie(*cookie); // Pass by reference so the cookie is copied.
}
+10 -11
View File
@@ -89,20 +89,20 @@ BUrl::BUrl(const BUrl& base, const BString& location)
// This implements the algorithm in RFC3986, Section 5.2.
BUrl relative(location);
if(relative.HasProtocol()) {
if (relative.HasProtocol()) {
SetProtocol(relative.Protocol());
SetAuthority(relative.Authority());
SetPath(relative.Path()); // TODO _RemoveDotSegments()
SetRequest(relative.Request());
} else {
if(relative.HasAuthority()) {
if (relative.HasAuthority()) {
SetAuthority(relative.Authority());
SetPath(relative.Path()); // TODO _RemoveDotSegments()
SetRequest(relative.Request());
} else {
if(relative.Path().IsEmpty()) {
if (relative.Path().IsEmpty()) {
SetPath(base.Path());
if(relative.HasRequest())
if (relative.HasRequest())
SetRequest(relative.Request());
else
SetRequest(Request());
@@ -644,7 +644,7 @@ BUrl::_ExplodeUrlString(const BString& url)
RegExp::MatchResult match = urlMatcher.Match(url.String());
if(!match.HasMatched())
if (!match.HasMatched())
return; // TODO error reporting
// Scheme/Protocol
@@ -664,19 +664,19 @@ BUrl::_ExplodeUrlString(const BString& url)
// Path
url.CopyInto(fPath, match.GroupStartOffsetAt(4),
match.GroupEndOffsetAt(4) - match.GroupStartOffsetAt(4));
if(!fPath.IsEmpty())
if (!fPath.IsEmpty())
fHasPath = true;
// Query
url.CopyInto(fRequest, match.GroupStartOffsetAt(6),
match.GroupEndOffsetAt(6) - match.GroupStartOffsetAt(6));
if(!fRequest.IsEmpty())
if (!fRequest.IsEmpty())
fHasRequest = true;
// Fragment
url.CopyInto(fFragment, match.GroupStartOffsetAt(8),
match.GroupEndOffsetAt(8) - match.GroupStartOffsetAt(8));
if(!fFragment.IsEmpty())
if (!fFragment.IsEmpty())
fHasFragment = true;
}
@@ -690,7 +690,7 @@ BUrl::SetAuthority(const BString& authority)
fHasUserInfo = false;
fHasHost = false;
if(fAuthority.IsEmpty())
if (fAuthority.IsEmpty())
return;
fHasAuthority = true;
@@ -723,8 +723,7 @@ BUrl::SetAuthority(const BString& authority)
int16 hostEnd = fAuthority.FindFirst(':', userInfoEnd);
userInfoEnd++;
if(hostEnd < 0)
{
if (hostEnd < 0) {
// no ':' found, the host extends to the end of the URL
hostEnd = fAuthority.Length() + 1;
}
+3 -3
View File
@@ -33,7 +33,7 @@ BUrlContext::~BUrlContext()
{
BHttpAuthenticationMap::Iterator iterator =
fAuthenticationMap->GetIterator();
while(iterator.HasNext())
while (iterator.HasNext())
delete *iterator.NextValue();
delete fAuthenticationMap;
@@ -62,7 +62,7 @@ BUrlContext::AddAuthentication(const BUrl& url,
// Make sure we don't leak memory by overriding a previous
// authentication for the same domain.
if(authentication != previous) {
if (authentication != previous) {
fAuthenticationMap->Put(hostHash, authentication);
// replaces the old one
delete previous;
@@ -94,7 +94,7 @@ BUrlContext::GetAuthentication(const BUrl& url)
domain.Truncate(domain.FindLast('/'));
} while(authentication == NULL);
} while (authentication == NULL);
return *authentication;
}
@@ -100,9 +100,8 @@ BUrlProtocolAsynchronousListener::MessageReceived(BMessage* message)
{
const char* data;
ssize_t size = 0;
if(message->FindData("url:data", B_STRING_TYPE,
reinterpret_cast<const void**>(&data), &size) != B_OK)
{
if (message->FindData("url:data", B_STRING_TYPE,
reinterpret_cast<const void**>(&data), &size) != B_OK) {
printf("BOGUS DATA MESSAGE\n");
message->PrintToStream();
return;
@@ -24,7 +24,7 @@ static BUrlContext gDefaultContext;
BUrlProtocolRoster::MakeRequest(const BUrl& url,
BUrlProtocolListener* listener, BUrlContext* context)
{
if(context == NULL)
if (context == NULL)
context = &gDefaultContext;
// TODO: instanciate the correct BUrlProtocol using add-on interface