Formatting cleanup

This commit is contained in:
Ziver Koc 2021-03-23 21:54:29 +01:00
parent c7e286f51e
commit 5a1be3c2e4
50 changed files with 283 additions and 282 deletions

View file

@ -97,7 +97,7 @@ bool Protocol::checkBit(int data, int bitno) {
Protocol *Protocol::getProtocolInstance(const std::wstring &protocolname) {
if(TelldusCore::comparei(protocolname, L"arctech")) {
if (TelldusCore::comparei(protocolname, L"arctech")) {
return new ProtocolNexa();
} else if (TelldusCore::comparei(protocolname, L"brateck")) {
@ -151,7 +151,7 @@ Protocol *Protocol::getProtocolInstance(const std::wstring &protocolname) {
std::list<std::string> Protocol::getParametersForProtocol(const std::wstring &protocolName) {
std::list<std::string> parameters;
if(TelldusCore::comparei(protocolName, L"arctech")) {
if (TelldusCore::comparei(protocolName, L"arctech")) {
parameters.push_back("house");
parameters.push_back("unit");
@ -218,7 +218,7 @@ std::list<std::string> Protocol::decodeData(const std::string &fullData) {
std::string decoded = "";
ControllerMessage dataMsg(fullData);
if( TelldusCore::comparei(dataMsg.protocol(), L"arctech") ) {
if ( TelldusCore::comparei(dataMsg.protocol(), L"arctech") ) {
decoded = ProtocolNexa::decodeData(dataMsg);
if (decoded != "") {
retval.push_back(decoded);
@ -231,32 +231,32 @@ std::list<std::string> Protocol::decodeData(const std::string &fullData) {
if (decoded != "") {
retval.push_back(decoded);
}
} else if(TelldusCore::comparei(dataMsg.protocol(), L"everflourish") ) {
} else if (TelldusCore::comparei(dataMsg.protocol(), L"everflourish") ) {
decoded = ProtocolEverflourish::decodeData(dataMsg);
if (decoded != "") {
retval.push_back(decoded);
}
} else if(TelldusCore::comparei(dataMsg.protocol(), L"fineoffset") ) {
} else if (TelldusCore::comparei(dataMsg.protocol(), L"fineoffset") ) {
decoded = ProtocolFineoffset::decodeData(dataMsg);
if (decoded != "") {
retval.push_back(decoded);
}
} else if(TelldusCore::comparei(dataMsg.protocol(), L"mandolyn") ) {
} else if (TelldusCore::comparei(dataMsg.protocol(), L"mandolyn") ) {
decoded = ProtocolMandolyn::decodeData(dataMsg);
if (decoded != "") {
retval.push_back(decoded);
}
} else if(TelldusCore::comparei(dataMsg.protocol(), L"oregon") ) {
} else if (TelldusCore::comparei(dataMsg.protocol(), L"oregon") ) {
decoded = ProtocolOregon::decodeData(dataMsg);
if (decoded != "") {
retval.push_back(decoded);
}
} else if(TelldusCore::comparei(dataMsg.protocol(), L"x10") ) {
} else if (TelldusCore::comparei(dataMsg.protocol(), L"x10") ) {
decoded = ProtocolX10::decodeData(dataMsg);
if (decoded != "") {
retval.push_back(decoded);
}
} else if(TelldusCore::comparei(dataMsg.protocol(), L"hasta") ) {
} else if (TelldusCore::comparei(dataMsg.protocol(), L"hasta") ) {
decoded = ProtocolHasta::decodeData(dataMsg);
if (decoded != "") {
retval.push_back(decoded);

View file

@ -175,7 +175,7 @@ std::string ProtocolX10::decodeData(const ControllerMessage& dataMsg) {
retString << "house:" << static_cast<char>('A' + intHouse);
retString << ";unit:" << unit+1;
retString << ";method:";
if(method == 0) {
if (method == 0) {
retString << "turnon;";
} else {
retString << "turnoff;";

View file

@ -37,7 +37,7 @@ int usbWriteFtdi(char *cmdstr)
char *err = ftdi_get_error_string(&ctx);
// FreeBSD says -3 when another rfcmd is running...
// Same on other systems?
if(retval == -3) {
if (retval == -3) {
fprintf(stderr, "usb - open error: %s. Is it busy?\n", err);
} else {
fprintf(stderr, "usb - open error: %s\n", err);
@ -68,8 +68,8 @@ int usbWriteFtdi(char *cmdstr)
fprintf(stderr, "usb - write failed: %s\n", err);
ftdiCleanup(&ctx);
return 5;
} else if(retval != strlen(cmdstr)) {
fprintf(stderr, "usb - warning: %d bytes written instead of %d\n",
} else if (retval != strlen(cmdstr)) {
fprintf(stderr, "usb - warning: %d bytes written instead of %d\n",
retval, (int)strlen(cmdstr));
}
@ -90,7 +90,7 @@ int usbWriteFtdi(char *cmdstr)
usleep(1000);
} else if (bytes > 0) {
// Done when newline is received
if(inb == '\n') {
if (inb == '\n') {
ftdiCleanup(&ctx);
return retval;
}

View file

@ -39,8 +39,8 @@
/*******************************************************************************
* Modifications to rfcmd.c ver 2.1.0 done by Tord Andersson
* Introduced semaphore protection to avoid problems with simultaneous port
* access from several processes (typically cron jobs). Note! Need rt lib.
* Introduced semaphore protection to avoid problems with simultaneous port
* access from several processes (typically cron jobs). Note! Need rt lib.
******************************************************************************/
/*******************************************************************************
@ -48,10 +48,10 @@
* Added support for RISINGSUN
* Note:
* 1. Command line syntax:
* /usr/local/bin/rfcmd /dev/ttyUSB0 RISINGSUN 4 1 0"
* /usr/local/bin/rfcmd /dev/ttyUSB0 RISINGSUN 4 1 0"
* Arg 1: device
* Arg 2: protocol
* Arg 3: code
* Arg 3: code
* Arg 4: device number
* Arg 5: Level (0=off, 1 = on)
******************************************************************************/
@ -70,7 +70,7 @@
******************************************************************************/
/*******************************************************************************
* Modifications from rfcmd ver 2.1.1 done by Johan Ström
* Modifications from rfcmd ver 2.1.1 done by Johan Str<EFBFBD>m
* Default disabled semaphores for FreeBSD.
* Added status readback in ftdi.c, instead of wasting time in sleep.
*
@ -99,7 +99,7 @@
#define PROG_NAME "rfcmd"
#define PROG_VERSION "2.1.1"
/* #define RFCMD_DEBUG */
/* #define RFCMD_DEBUG */
/* Local function declarations */
int createNexaString(const char * pHouseStr, const char * pChannelStr,
@ -132,18 +132,18 @@ int main( int argc, char **argv )
char txStr[100];
if( (argc == 6) && (strcmp(*(argv+2), "NEXA") == 0)) {
if ((argc == 6) && (strcmp(*(argv+2), "NEXA") == 0)) {
if (createNexaString(*(argv+3), *(argv+4), *(argv+5), txStr, 0) == 0) {
printUsage();
exit(1);
}
/* else - a send cmd string was created */
} else if( (argc == 6) && (strcmp(*(argv+2), "WAVEMAN") == 0)) {
} else if ( (argc == 6) && (strcmp(*(argv+2), "WAVEMAN") == 0)) {
if (createNexaString(*(argv+3),*(argv+4), *(argv+5), txStr, 1) == 0) {
printUsage();
exit(1);
}
} else if( (argc == 5) && (strcmp(*(argv+2), "SARTANO") == 0)) {
} else if ( (argc == 5) && (strcmp(*(argv+2), "SARTANO") == 0)) {
if (createSartanoString(*(argv+3), *(argv+4), txStr) == 0) {
printUsage();
exit(1);
@ -183,11 +183,11 @@ int main( int argc, char **argv )
#endif
if(strlen(txStr) > 0) {
if (strlen(txStr) > 0) {
#ifndef NO_SEMAPHORES
/* create the semaphore - will reuse an existing one if it exists */
portMutex = sem_open(SEM_NAME,O_CREAT,0644,1);
if( portMutex == SEM_FAILED) {
if (portMutex == SEM_FAILED) {
fprintf(stderr, "%s - Error creating port semaphore\n", PROG_NAME);
perror("Semaphore open error");
sem_unlink(SEM_NAME);
@ -195,24 +195,24 @@ int main( int argc, char **argv )
}
/* lock semaphore to protect port from multiple access */
if(sem_wait(portMutex) != 0) {
if (sem_wait(portMutex) != 0) {
fprintf(stderr, "%s - Error aquiring port semaphore\n", PROG_NAME);
sem_unlink(SEM_NAME);
sem_close(portMutex);
exit(1);
exit(1);
}
#endif
if (strcmp(*(argv+1), "LIBUSB") != 0) {
if( 0 > ( fd = open( *(argv+1), O_RDWR ) ) ) {
if ( 0 > ( fd = open( *(argv+1), O_RDWR ) ) ) {
#ifdef __FreeBSD__
fprintf(stderr, "%s - Error opening %s; You're on a FreeBSD system, you should probably use LIBUSB.\n", PROG_NAME, *(argv+1));
#else
fprintf(stderr, "%s - Error opening %s\n", PROG_NAME, *(argv+1));
#endif
#ifndef NO_SEMAPHORES
if(sem_post(portMutex) != 0) {
if (sem_post(portMutex) != 0) {
fprintf(stderr, "%s - Error releasing port semaphore\n", PROG_NAME);
}
sem_unlink(SEM_NAME);
@ -251,7 +251,7 @@ int main( int argc, char **argv )
exit(1);
} else {
sem_unlink(SEM_NAME);
sem_close(portMutex);
sem_close(portMutex);
}
#endif
}
@ -342,7 +342,7 @@ int createSartanoString(const char * pChannelStr, const char * pOn_offStr,
strcat(pTxStr,"S");
for(bit=0;bit<=9;bit++)
{
if(strncmp(pChannelStr+bit, "1", 1) == 0) { //If it is a "1"
if (strncmp(pChannelStr+bit, "1", 1) == 0) { //If it is a "1"
strcat(pTxStr,"$k$k");
} else {
strcat(pTxStr,"$kk$");
@ -364,9 +364,9 @@ int createIkeaString( const char * pSystemStr, const char * pChannelStr, const c
{
*pStrReturn = '\0'; /* Make sure tx string is empty */
const char STARTCODE[] = "STTTTTTª";
const char STARTCODE[] = "STTTTTT<EFBFBD>";
const char TT[] = "TT";
const char A[] = "ª";
const char A[] = "<EFBFBD>";
int systemCode = atoi(pSystemStr) - 1; /* System 1..16 */
int channelCode = atoi(pChannelStr); /* Channel 1..10 */
int Level = atoi(pLevelStr); /* off,10,20,..,90,on */
@ -658,6 +658,6 @@ void printVersion(void) {
printf("\n");
printf("Written by:\n");
printf("Tord Andersson, Micke Prag, Gudmund Berggren, Tapani Rintala\n");
printf("and Johan Ström\n");
printf("and Johan Str<EFBFBD>m\n");
}