Removed whitespace after line end, accoring to Google style guidelines "whitespace/end_of_line"

This commit is contained in:
Stefan Persson 2012-12-05 11:28:27 +01:00
parent e38eb0f72d
commit fb79664508
6 changed files with 53 additions and 57 deletions

View file

@ -59,7 +59,6 @@ void EventHandler::signal(Event *event) {
}
bool EventHandler::waitForAny() {
while(1) {
int result = WaitForMultipleObjects(d->eventCount, d->eventArray, FALSE, 1000);
if (result == WAIT_TIMEOUT) {

View file

@ -53,25 +53,25 @@ void Socket::connect(const std::wstring &server) {
std::wstring name(L"\\\\.\\pipe\\" + server);
d->hPipe = CreateFile(
(const wchar_t *)name.c_str(), // pipe name
GENERIC_READ | // read and write access
GENERIC_WRITE,
0, // no sharing
(const wchar_t *)name.c_str(), // pipe name
GENERIC_READ | // read and write access
GENERIC_WRITE,
0, // no sharing
NULL, // default security attributes
OPEN_EXISTING, // opens existing pipe
FILE_FLAG_OVERLAPPED, // default attributes
NULL); // no template file
OPEN_EXISTING, // opens existing pipe
FILE_FLAG_OVERLAPPED, // default attributes
NULL); // no template file
if (d->hPipe == INVALID_HANDLE_VALUE) {
return;
}
DWORD dwMode = PIPE_READMODE_MESSAGE;
fSuccess = SetNamedPipeHandleState(
d->hPipe, // pipe handle
&dwMode, // new pipe mode
NULL, // don't set maximum bytes
NULL); // don't set maximum time
DWORD dwMode = PIPE_READMODE_MESSAGE;
fSuccess = SetNamedPipeHandleState(
d->hPipe, // pipe handle
&dwMode, // new pipe mode
NULL, // don't set maximum bytes
NULL); // don't set maximum time
if (!fSuccess) {
return;
@ -92,8 +92,8 @@ std::wstring Socket::read(int timeout) {
wchar_t buf[BUFSIZE];
int result;
DWORD cbBytesRead = 0;
OVERLAPPED oOverlap;
OVERLAPPED oOverlap;
memset(&oOverlap, 0, sizeof(OVERLAPPED));
d->readEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
@ -101,15 +101,15 @@ std::wstring Socket::read(int timeout) {
BOOL fSuccess = false;
std::wstring returnString;
bool moreData = true;
while(moreData) {
moreData = false;
memset(&buf, 0, sizeof(buf));
ReadFile( d->hPipe, &buf, sizeof(buf)-sizeof(wchar_t), &cbBytesRead, &oOverlap);
result = WaitForSingleObject(oOverlap.hEvent, timeout);
if(!d->running) {
CancelIo(d->hPipe);
WaitForSingleObject(oOverlap.hEvent, INFINITE);
@ -123,7 +123,7 @@ std::wstring Socket::read(int timeout) {
// Cancel, we still need to cleanup
}
fSuccess = GetOverlappedResult(d->hPipe, &oOverlap, &cbBytesRead, true);
if (!fSuccess) {
DWORD err = GetLastError();
debuglog(static_cast<int>(err), "Something read error");
@ -151,7 +151,7 @@ std::wstring Socket::read(int timeout) {
}
void Socket::write(const std::wstring &msg) {
OVERLAPPED oOverlap;
DWORD bytesWritten = 0;
int result;
@ -161,7 +161,7 @@ void Socket::write(const std::wstring &msg) {
HANDLE writeEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
oOverlap.hEvent = writeEvent;
BOOL writeSuccess = WriteFile(d->hPipe, msg.data(), (DWORD)msg.length()*sizeof(wchar_t), &bytesWritten, &oOverlap);
result = GetLastError();
if (writeSuccess || result == ERROR_IO_PENDING) {
@ -189,7 +189,7 @@ void Socket::write(const std::wstring &msg) {
d->hPipe = 0;
debuglog(result, "Error in write event, closing socket");
d->connected = false;
return;
return;
}
}

View file

@ -38,12 +38,12 @@ ConnectionListener::ConnectionListener(const std::wstring &name, TelldusCore::Ev
PSID pEveryoneSID = NULL;
SID_IDENTIFIER_AUTHORITY SIDAuthWorld = SECURITY_WORLD_SID_AUTHORITY;
pSD = (PSECURITY_DESCRIPTOR) LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH);
pSD = (PSECURITY_DESCRIPTOR) LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH);
if (pSD == NULL) {
return;
}
if (!InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION)) {
}
if (!InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION)) {
LocalFree(pSD);
return;
}
@ -60,12 +60,11 @@ ConnectionListener::ConnectionListener(const std::wstring &name, TelldusCore::Ev
ea.Trustee.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP;
ea.Trustee.ptstrName = (LPTSTR) pEveryoneSID;
// Add the ACL to the security descriptor.
if (!SetSecurityDescriptorDacl(pSD,
TRUE, // bDaclPresent flag
pACL,
FALSE)) { // not a default DACL
// Add the ACL to the security descriptor.
if (!SetSecurityDescriptorDacl(pSD,
TRUE, // bDaclPresent flag
pACL,
FALSE)) { // not a default DACL
LocalFree(pSD);
FreeSid(pEveryoneSID);
}
@ -97,7 +96,7 @@ void ConnectionListener::run() {
d->hEvent = CreateEvent(NULL, true, false, NULL);
oOverlap.hEvent = d->hEvent;
bool recreate = true;
while (1) {
BOOL alreadyConnected = false;
if (recreate) {
@ -129,7 +128,7 @@ void ConnectionListener::run() {
WaitForSingleObject(oOverlap.hEvent, INFINITE);
break;
}
if(result == WAIT_TIMEOUT) {
//CloseHandle(hPipe);
continue;

View file

@ -7,7 +7,7 @@
#include <Windows.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <sstream>
#include <string>
#include <vector>
@ -58,15 +58,15 @@ int Settings::getNumberOfNodes(Node type) const {
int intNumberOfNodes = 0;
HKEY hk;
long lnExists = RegOpenKeyEx(d->rootKey, d->getNodePath(type).c_str(), 0, KEY_QUERY_VALUE, &hk);
if(lnExists == ERROR_SUCCESS) {
std::wstring strNumSubKeys;
DWORD dNumSubKeys;
RegQueryInfoKey(hk, NULL, NULL, NULL, &dNumSubKeys, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
intNumberOfNodes = static_cast<int>(dNumSubKeys);
RegCloseKey(hk);
@ -80,11 +80,11 @@ int Settings::getNodeId(Node type, int intNodeIndex) const {
int intReturn = -1;
HKEY hk;
long lnExists = RegOpenKeyEx(d->rootKey, d->getNodePath(type).c_str(), 0, KEY_READ, &hk);
if(lnExists == ERROR_SUCCESS) {
wchar_t* Buff = new wchar_t[intMaxRegValueLength];
DWORD size = intMaxRegValueLength;
if (RegEnumKeyEx(hk, intNodeIndex, (LPWSTR)Buff, &size, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) {
@ -111,7 +111,7 @@ int Settings::addNode(Node type) {
std::wstring strCompleteRegPath = d->getNodePath(type);
strCompleteRegPath.append(TelldusCore::intToWstring(intNodeId));
if (RegCreateKeyEx(d->rootKey, strCompleteRegPath.c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hk, &dwDisp)) {
//fail
intNodeId = -1;
@ -131,9 +131,8 @@ int Settings::getNextNodeId(Node type) const {
DWORD dwDisp;
long lnExists = RegCreateKeyEx(d->rootKey, d->getNodePath(type).c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hk, &dwDisp); //create or open if already created
if(lnExists == ERROR_SUCCESS) {
DWORD dwLength = sizeof(DWORD);
DWORD nResult(0);
@ -146,7 +145,6 @@ int Settings::getNextNodeId(Node type) const {
}
DWORD dwVal = intReturn;
RegSetValueEx (hk, L"LastUsedId", 0L, REG_DWORD, (CONST BYTE*) &dwVal, sizeof(DWORD));
}
RegCloseKey(hk);
return intReturn;
@ -157,7 +155,7 @@ int Settings::getNextNodeId(Node type) const {
*/
int Settings::removeNode(Node type, int intNodeId) {
TelldusCore::MutexLocker locker(&mutex);
std::wstring strCompleteRegPath = d->getNodePath(type);
strCompleteRegPath.append(TelldusCore::intToWstring(intNodeId));
@ -177,7 +175,7 @@ std::wstring Settings::getSetting(const std::wstring &strName) const {
std::wstring strCompleteRegPath = d->strRegPath;
long lnExists = RegOpenKeyEx(d->rootKey, strCompleteRegPath.c_str(), 0, KEY_QUERY_VALUE, &hk);
if(lnExists == ERROR_SUCCESS) {
wchar_t* Buff = new wchar_t[intMaxRegValueLength];
DWORD dwLength = sizeof(wchar_t)*intMaxRegValueLength;
@ -205,7 +203,7 @@ std::wstring Settings::getStringSetting(Node type, int intNodeId, const std::wst
std::wstring strCompleteRegPath = d->getNodePath(type);
strCompleteRegPath.append(TelldusCore::intToWstring(intNodeId));
long lnExists = RegOpenKeyEx(d->rootKey, strCompleteRegPath.c_str(), 0, KEY_QUERY_VALUE, &hk);
if(lnExists == ERROR_SUCCESS) {
wchar_t* Buff = new wchar_t[intMaxRegValueLength];
DWORD dwLength = sizeof(wchar_t)*intMaxRegValueLength;
@ -230,12 +228,12 @@ int Settings::setStringSetting(Node type, int intNodeId, const std::wstring &nam
HKEY hk;
int ret = TELLSTICK_SUCCESS;
std::wstring strNodeId = TelldusCore::intToWstring(intNodeId);
std::wstring strCompleteRegPath = d->getNodePath(type);
strCompleteRegPath.append(strNodeId);
long lnExists = RegOpenKeyEx(d->rootKey, strCompleteRegPath.c_str(), 0, KEY_WRITE, &hk);
if (lnExists == ERROR_SUCCESS) {
int length = static_cast<int>(value.length()) * sizeof(wchar_t);
RegSetValueEx(hk, name.c_str(), 0, REG_SZ, (LPBYTE)value.c_str(), length+1);

View file

@ -66,7 +66,7 @@ DWORD WINAPI TelldusWinService::deviceNotificationHandler( DWORD controlCode, DW
if (dwEventType != DBT_DEVICEARRIVAL && dwEventType != DBT_DEVICEREMOVECOMPLETE) {
return ERROR_CALL_NOT_IMPLEMENTED;
}
PDEV_BROADCAST_DEVICEINTERFACE pDevInf = reinterpret_cast<PDEV_BROADCAST_DEVICEINTERFACE>(lpEventData);
if (!pDevInf) {
return ERROR_CALL_NOT_IMPLEMENTED;
@ -101,7 +101,7 @@ DWORD WINAPI TelldusWinService::deviceNotificationHandler( DWORD controlCode, DW
long int vid = strtol(std::string(strVID.begin(), strVID.end()).c_str(), NULL, 16);
long int pid = strtol(std::string(strPID.begin(), strPID.end()).c_str(), NULL, 16);
if (dwEventType == DBT_DEVICEARRIVAL) {
tm->deviceInsertedOrRemoved(vid, pid, true);
} else {
@ -170,7 +170,7 @@ void WINAPI TelldusWinService::serviceMain( DWORD argc, TCHAR* argv[] ) {
Log::notice("TelldusService stopping");
Log::destroy();
// service was stopped
instance.serviceStatus.dwCurrentState = SERVICE_STOP_PENDING;
SetServiceStatus( instance.serviceStatusHandle, &instance.serviceStatus );

View file

@ -22,7 +22,7 @@ public:
~TelldusWinService();
static void WINAPI serviceMain( DWORD /*argc*/, TCHAR* /*argv*/[] );
protected:
void stop();