#include "i18n.h"
-#define _XOPEN_SOURCE 600 // force XSI for non-GNU strerror_r()
-
#include <sstream>
+
#include <cstring>
#include <cerrno>
-
using namespace std;
using namespace Mackie;
//cout << "~SurfacePort::SurfacePort() finished" << endl;
}
+// wrapper for one day when strerror_r is working properly
+string fetch_errmsg( int error_number )
+{
+ char * msg = strerror( error_number );
+ return msg;
+}
+
MidiByteArray SurfacePort::read()
{
const int max_buf_size = 512;
if ( errno != EAGAIN )
{
ostringstream os;
- os << "Surface: error reading from port: " << port().name() << ": " << errno;
+ os << "Surface: error reading from port: " << port().name();
+ os << ": " << errno << fetch_errmsg( errno );
- char buf[512];
- int result = strerror_r( errno, buf, 512 );
- if (!result) {
- os << " " << buf;
- }
-
cout << os.str() << endl;
inactive_event();
throw MackieControlException( os.str() );
if ( errno != EAGAIN )
{
ostringstream os;
- os << "Surface: couldn't write to port " << port().name() << ": " << errno;
- char buf[512];
- int result = strerror_r( errno, buf, 512 );
-
- if (!result) {
- os << " " << buf;
- }
-
+ os << "Surface: couldn't write to port " << port().name();
+ os << ": " << errno << fetch_errmsg( errno );
+
cout << os.str();
inactive_event();
throw MackieControlException( os.str() );