More string literal workarounds
authorMikko Rasa <tdb@tdb.fi>
Wed, 2 Nov 2011 10:52:33 +0000 (12:52 +0200)
committerMikko Rasa <tdb@tdb.fi>
Wed, 2 Nov 2011 10:52:33 +0000 (12:52 +0200)
src/iButton.cpp

index 6ec8209..77c3916 100644 (file)
@@ -8,11 +8,14 @@ extern "C" {
 #include "ibutton/shaib.h"
 }
 
+// owAcquireEx is stupid and takes a char * when it really won't modify it
+char serial_port[] =
 #ifdef WIN32
-#define SERIAL_PORT "COM1"
+       "COM1"
 #else
-#define SERIAL_PORT "/dev/ttyS0"
+       "/dev/ttyS0"
 #endif
+;
 
 bool iButton::GetAESKey(const uchar *subkey, uchar *output)
 {
@@ -21,7 +24,7 @@ bool iButton::GetAESKey(const uchar *subkey, uchar *output)
 
        memcpy(firstDataPage, subkey, 32);
 
-       if ((copr.portnum = owAcquireEx(SERIAL_PORT)) == -1)
+       if ((copr.portnum = owAcquireEx(serial_port)) == -1)
        {
                LOG->Warn( "GetAESKey(): failed to acquire port." );
                return false;
@@ -51,7 +54,7 @@ CString iButton::GetSerialNumber()
        SHACopr copr;
        uchar spBuf[32];
 
-       if( (copr.portnum = owAcquireEx(SERIAL_PORT)) == -1 )
+       if( (copr.portnum = owAcquireEx(serial_port)) == -1 )
        {
                LOG->Warn("GetSerialNumber(): failed to acquire port.");
                return CString();