aboutsummaryrefslogtreecommitdiffstats
path: root/src/libgamma_native_error.pyx
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-09-02 10:03:38 +0200
committerMattias Andrée <maandree@operamail.com>2014-09-02 10:03:38 +0200
commit22045dfb614da1ecd9192937c609591e4bdb606d (patch)
tree70513c9c0895714a9cd61aadfc7b6fe3a634568c /src/libgamma_native_error.pyx
parentderp (diff)
downloadpylibgamma-22045dfb614da1ecd9192937c609591e4bdb606d.tar.gz
pylibgamma-22045dfb614da1ecd9192937c609591e4bdb606d.tar.bz2
pylibgamma-22045dfb614da1ecd9192937c609591e4bdb606d.tar.xz
m
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/libgamma_native_error.pyx15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libgamma_native_error.pyx b/src/libgamma_native_error.pyx
index d88f7fe..5c419cc 100644
--- a/src/libgamma_native_error.pyx
+++ b/src/libgamma_native_error.pyx
@@ -20,6 +20,7 @@ along with this library. If not, see <http://www.gnu.org/licenses/>.
cimport cython
from posix.unistd cimport gid_t
+from libc.string cimport strerror as c_strerror
cdef extern gid_t libgamma_group_gid
@@ -184,3 +185,17 @@ def libgamma_native_value_of_error(name : str) -> int:
bs = name.encode('utf-8') + bytes([0])
return int(libgamma_value_of_error(bs))
+
+def strerror(error : int) -> str:
+ '''
+ Get a textual description of an error.
+
+ @param error The number of the error.
+ @return The description of the error.
+ '''
+ cdef const char* text
+ cdef bytes bs
+ text = c_strerror(<int>error)
+ bs = text
+ return bs.decode('utf-8', 'strict')
+