summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/sys/posix/StrError.cpp
diff options
context:
space:
mode:
authorAndrew Stitcher <astitcher@apache.org>2008-07-30 06:29:16 +0000
committerAndrew Stitcher <astitcher@apache.org>2008-07-30 06:29:16 +0000
commitf1f80e7b3b1e17e663113382219d992680461063 (patch)
tree793644f4345437ed0c60ace0c5b7fdf07504e661 /cpp/src/qpid/sys/posix/StrError.cpp
parentab27cb344e9d2e1ea18c1c89cda65a02a7513e4b (diff)
downloadqpid-python-f1f80e7b3b1e17e663113382219d992680461063.tar.gz
Related to QPID-1198: Moved posix platform specific "strerror" code to
platform specific directory git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@680920 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/sys/posix/StrError.cpp')
-rw-r--r--cpp/src/qpid/sys/posix/StrError.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/cpp/src/qpid/sys/posix/StrError.cpp b/cpp/src/qpid/sys/posix/StrError.cpp
new file mode 100644
index 0000000000..deb2fca7eb
--- /dev/null
+++ b/cpp/src/qpid/sys/posix/StrError.cpp
@@ -0,0 +1,44 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "qpid/sys/StrError.h"
+
+// Ensure we get the POSIX verion of strerror_r
+#ifndef _XOPEN_SOURCE
+#define _XOPEN_SOURCE 600
+#include <string.h>
+#undef _XOPEN_SOURCE
+#else
+#include <string.h>
+#endif
+
+
+namespace qpid {
+namespace sys {
+
+std::string strError(int err) {
+ char buf[512];
+ //POSIX strerror_r doesn't return the buffer
+ ::strerror_r(err, buf, sizeof(buf));
+ return std::string(buf);
+}
+
+}}