• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2012 W. Trevor King <wking@tremily.us>
2#
3# This file is part of python-kmod.
4#
5# python-kmod is free software: you can redistribute it and/or modify it under
6# the terms of the GNU Lesser General Public License version 2.1 as published
7# by the Free Software Foundation.
8#
9# python-kmod is distributed in the hope that it will be useful, but WITHOUT
10# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
12# details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with python-kmod.  If not, see <http://www.gnu.org/licenses/>.
16
17import sys as _sys
18
19cimport _libkmod_h
20
21
22cdef object char_ptr_to_str(_libkmod_h.const_char_ptr char_ptr):
23    if char_ptr is NULL:
24        return None
25    if _sys.version_info >= (3,):  # Python 3
26        return str(char_ptr, 'ascii')
27    # Python 2
28    return unicode(char_ptr, 'ascii')
29