Fixed regression errors for windows

This commit is contained in:
Stefan Persson 2012-12-04 15:14:40 +01:00
parent 9f68c2083a
commit 05197abf6e
10 changed files with 42 additions and 10 deletions

View file

@ -1,6 +1,6 @@
#include "ConnectionListener.h" #include "ConnectionListener.h"
#include "Event.h" #include "Event.h"
#include "Socket.h" #include "common/Socket.h"
#include <windows.h> #include <windows.h>
#include <AccCtrl.h> #include <AccCtrl.h>

View file

@ -4,6 +4,7 @@
// Copyright: See COPYING file that comes with this distribution // Copyright: See COPYING file that comes with this distribution
// //
// //
#define _CRT_RAND_S
#include "service/Controller.h" #include "service/Controller.h"
#include <stdlib.h> #include <stdlib.h>
#include <map> #include <map>
@ -14,6 +15,16 @@
#include "common/Strings.h" #include "common/Strings.h"
#include "common/common.h" //debug #include "common/common.h" //debug
inline int random( unsigned int* seed ){
#ifdef _WINDOWS
unsigned int randomNumber;
rand_s( &randomNumber ); //no seed needed
return randomNumber;
#else
return rand_r( seed );
#endif
}
class Controller::PrivateData { class Controller::PrivateData {
public: public:
TelldusCore::EventRef event, updateEvent; TelldusCore::EventRef event, updateEvent;
@ -44,7 +55,7 @@ void Controller::publishData(const std::string &msg) const {
void Controller::decodePublishData(const std::string &data) const { void Controller::decodePublishData(const std::string &data) const {
// Garbange collect? // Garbange collect?
if (rand_r(&d->randSeed) % 1000 == 1) { if (random(&d->randSeed) % 1000 == 1) {
time_t t = time(NULL); time_t t = time(NULL);
// Standard associative-container erase idiom // Standard associative-container erase idiom
for (std::map<std::string, time_t>::iterator it = d->duplicates.begin(); it != d->duplicates.end(); /* no increment */) { for (std::map<std::string, time_t>::iterator it = d->duplicates.begin(); it != d->duplicates.end(); /* no increment */) {

View file

@ -7,7 +7,11 @@
#ifndef TELLDUS_CORE_SERVICE_CONTROLLERMESSAGE_H_ #ifndef TELLDUS_CORE_SERVICE_CONTROLLERMESSAGE_H_
#define TELLDUS_CORE_SERVICE_CONTROLLERMESSAGE_H_ #define TELLDUS_CORE_SERVICE_CONTROLLERMESSAGE_H_
#ifdef _MSC_VER
typedef unsigned __int64 uint64_t;
#else
#include <stdint.h> #include <stdint.h>
#endif
#include <string> #include <string>
class ControllerMessage { class ControllerMessage {

View file

@ -11,8 +11,8 @@
#include <syslog.h> #include <syslog.h>
#elif defined(_WINDOWS) #elif defined(_WINDOWS)
#include <windows.h> #include <windows.h>
#include "service/Strings.h" #include "common/Strings.h"
#include "service/Messages.h" #include "Messages.h"
#endif #endif
class Log::PrivateData { class Log::PrivateData {
@ -159,16 +159,16 @@ void Log::message(Log::LogLevel logLevel, const char *format, va_list ap) const
switch (logLevel) { switch (logLevel) {
case Debug: case Debug:
ReportEvent(d->eventSource, EVENTLOG_SUCCESS, NULL, LOG_DEBUG, NULL, 1, 0, reinterpret_cast<LPCWSTR*>(pInsertStrings), NULL); ReportEvent(d->eventSource, EVENTLOG_SUCCESS, NULL, LOG_DEBUG, NULL, 1, 0, (LPCWSTR*)pInsertStrings, NULL);
break; break;
case Notice: case Notice:
ReportEvent(d->eventSource, EVENTLOG_INFORMATION_TYPE, NULL, LOG_NOTICE, NULL, 1, 0, reinterpret_cast<LPCWSTR*>(pInsertStrings), NULL); ReportEvent(d->eventSource, EVENTLOG_INFORMATION_TYPE, NULL, LOG_NOTICE, NULL, 1, 0, (LPCWSTR*)pInsertStrings, NULL);
break; break;
case Warning: case Warning:
ReportEvent(d->eventSource, EVENTLOG_WARNING_TYPE, NULL, LOG_WARNING, NULL, 1, 0, reinterpret_cast<LPCWSTR*>(pInsertStrings), NULL); ReportEvent(d->eventSource, EVENTLOG_WARNING_TYPE, NULL, LOG_WARNING, NULL, 1, 0, (LPCWSTR*)pInsertStrings, NULL);
break; break;
case Error: case Error:
ReportEvent(d->eventSource, EVENTLOG_ERROR_TYPE, NULL, LOG_ERR, NULL, 1, 0, reinterpret_cast<LPCWSTR*>(pInsertStrings), NULL); ReportEvent(d->eventSource, EVENTLOG_ERROR_TYPE, NULL, LOG_ERR, NULL, 1, 0, (LPCWSTR*)pInsertStrings, NULL);
break; break;
} }
#endif #endif

View file

@ -10,6 +10,9 @@
#include <string.h> #include <string.h>
#include <string> #include <string>
#include "common/Strings.h" #include "common/Strings.h"
#ifdef _WINDOWS
#define strtok_r(s,d,p) strtok_s(s,d,p)
#endif
int ProtocolIkea::methods() const { int ProtocolIkea::methods() const {
return TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_DIM; return TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_DIM;

View file

@ -7,7 +7,11 @@
#ifndef TELLDUS_CORE_SERVICE_PROTOCOLNEXA_H_ #ifndef TELLDUS_CORE_SERVICE_PROTOCOLNEXA_H_
#define TELLDUS_CORE_SERVICE_PROTOCOLNEXA_H_ #define TELLDUS_CORE_SERVICE_PROTOCOLNEXA_H_
#ifdef _MSC_VER
typedef unsigned __int64 uint64_t;
#else
#include <stdint.h> #include <stdint.h>
#endif
#include <string> #include <string>
#include "service/ControllerMessage.h" #include "service/ControllerMessage.h"
#include "service/Device.h" #include "service/Device.h"

View file

@ -5,7 +5,11 @@
// //
// //
#include "service/ProtocolSartano.h" #include "service/ProtocolSartano.h"
#ifdef _MSC_VER
typedef unsigned __int16 uint16_t;
#else
#include <stdint.h> #include <stdint.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <sstream> #include <sstream>
#include <string> #include <string>

View file

@ -5,7 +5,10 @@
// //
// //
#include "service/ProtocolWaveman.h" #include "service/ProtocolWaveman.h"
#ifdef _MSC_VER
#else
#include <stdint.h> #include <stdint.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <sstream> #include <sstream>
#include <string> #include <string>

View file

@ -5,7 +5,10 @@
// //
// //
#include "service/ProtocolX10.h" #include "service/ProtocolX10.h"
#ifdef _MSC_VER
#else
#include <stdint.h> #include <stdint.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <sstream> #include <sstream>
#include <string> #include <string>

View file

@ -1,12 +1,12 @@
#include "Settings.h" #include "Settings.h"
#include "Strings.h" #include "common/Strings.h"
#include <Windows.h> #include <Windows.h>
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <vector> #include <vector>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include "common.h" #include "common/common.h"
#include "../client/telldus-core.h" #include "../client/telldus-core.h"