diff options
author | Wojciech Polak <polak@gnu.org> | 2009-07-14 13:23:44 +0200 |
---|---|---|
committer | Wojciech Polak <polak@gnu.org> | 2009-07-14 13:23:44 +0200 |
commit | fe1fe3832d7d6febcd163f4854f3a5438db2074c (patch) | |
tree | 3c87d6167df2dd6237a2905d6bff0f9e44f4b3c4 | |
parent | b390f3773720cf07d88a192740c0082504faa7f8 (diff) | |
download | mailutils-fe1fe3832d7d6febcd163f4854f3a5438db2074c.tar.gz mailutils-fe1fe3832d7d6febcd163f4854f3a5438db2074c.tar.bz2 |
Add NLS to libmu_py.
* python/libmu_py/nls.c: New file.
* python/mailutils/nls.py: Likewise.
-rw-r--r-- | python/libmu_py/Makefile.am | 1 | ||||
-rw-r--r-- | python/libmu_py/libmu_py.c | 1 | ||||
-rw-r--r-- | python/libmu_py/libmu_py.h | 2 | ||||
-rw-r--r-- | python/libmu_py/nls.c | 70 | ||||
-rw-r--r-- | python/mailutils/Makefile.am | 1 | ||||
-rw-r--r-- | python/mailutils/__init__.py | 1 | ||||
-rw-r--r-- | python/mailutils/nls.py | 32 |
7 files changed, 108 insertions, 0 deletions
diff --git a/python/libmu_py/Makefile.am b/python/libmu_py/Makefile.am index 0bf87e58e..0b5480aa5 100644 --- a/python/libmu_py/Makefile.am +++ b/python/libmu_py/Makefile.am @@ -42,6 +42,7 @@ libmu_py_la_SOURCES = \ mailcap.c \ message.c \ mime.c \ + nls.c \ script.c \ secret.c \ stream.c \ diff --git a/python/libmu_py/libmu_py.c b/python/libmu_py/libmu_py.c index a4579b3d8..7fd1cb3cb 100644 --- a/python/libmu_py/libmu_py.c +++ b/python/libmu_py/libmu_py.c @@ -123,6 +123,7 @@ mu_py_attach_modules (void) _mu_py_attach_mailcap (); _mu_py_attach_message (); _mu_py_attach_mime (); + _mu_py_attach_nls (); _mu_py_attach_registrar (); _mu_py_attach_secret (); _mu_py_attach_stream (); diff --git a/python/libmu_py/libmu_py.h b/python/libmu_py/libmu_py.h index b42b236d5..e30e32d5f 100644 --- a/python/libmu_py/libmu_py.h +++ b/python/libmu_py/libmu_py.h @@ -40,6 +40,7 @@ #include <mailutils/mime.h> #include <mailutils/mu_auth.h> #include <mailutils/mutil.h> +#include <mailutils/nls.h> #include <mailutils/registrar.h> #include <mailutils/tls.h> #include <mailutils/secret.h> @@ -73,6 +74,7 @@ extern void _mu_py_attach_mailbox (void); extern void _mu_py_attach_mailcap (void); extern void _mu_py_attach_message (void); extern void _mu_py_attach_mime (void); +extern void _mu_py_attach_nls (void); extern void _mu_py_attach_registrar (void); extern void _mu_py_attach_secret (void); extern void _mu_py_attach_stream (void); diff --git a/python/libmu_py/nls.c b/python/libmu_py/nls.c new file mode 100644 index 000000000..8b8131069 --- /dev/null +++ b/python/libmu_py/nls.c @@ -0,0 +1,70 @@ +/* + GNU Mailutils -- a suite of utilities for electronic mail + Copyright (C) 2009 Free Software Foundation, Inc. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 3 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with this library; if not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301 USA +*/ + +#include "libmu_py.h" + +#define PY_MODULE "nls" + +static PyObject * +api_nls_init (PyObject *self) +{ + mu_init_nls (); + return _ro (Py_None); +} + +static PyObject * +api_nls_set_locale (PyObject *self, PyObject *args) +{ + int status; + char *lset; + const char *locale; + + if (!PyArg_ParseTuple (args, "s", &locale)) + return NULL; + + lset = mu_set_locale (locale); + return _ro (PyString_FromString (lset ? lset : "")); +} + +static PyObject * +api_nls_restore_locale (PyObject *self) +{ + mu_restore_locale (); + return _ro (Py_None); +} + +static PyMethodDef methods[] = { + { "init", (PyCFunction) api_nls_init, METH_NOARGS, + "Initialize Native Language Support." }, + + { "set_locale", (PyCFunction) api_nls_set_locale, METH_VARARGS, + "Set locale via LC_ALL." }, + + { "restore_locale", (PyCFunction) api_nls_restore_locale, METH_NOARGS, + "" }, + + { NULL, NULL, 0, NULL } +}; + +void +_mu_py_attach_nls (void) +{ + _mu_py_attach_module (PY_MODULE, methods); +} diff --git a/python/mailutils/Makefile.am b/python/mailutils/Makefile.am index 538632eba..562327e9d 100644 --- a/python/mailutils/Makefile.am +++ b/python/mailutils/Makefile.am @@ -34,6 +34,7 @@ MU_PY_PKGPYTHON_LIST=\ mailcap.py \ message.py \ mime.py \ + nls.py \ registrar.py \ secret.py \ stream.py \ diff --git a/python/mailutils/__init__.py b/python/mailutils/__init__.py index 8b7409829..b4588e628 100644 --- a/python/mailutils/__init__.py +++ b/python/mailutils/__init__.py @@ -32,6 +32,7 @@ __all__ = [ "mailcap", "message", "mime", + "nls", "registrar", "secret", "stream", diff --git a/python/mailutils/nls.py b/python/mailutils/nls.py new file mode 100644 index 000000000..475bf9376 --- /dev/null +++ b/python/mailutils/nls.py @@ -0,0 +1,32 @@ +# +# GNU Mailutils -- a suite of utilities for electronic mail +# Copyright (C) 2009 Free Software Foundation, Inc. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General +# Public License along with this library; if not, write to the +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# + +from mailutils.c_api import nls + +def init (): + """Initialize Native Language Support.""" + nls.init () + +def set_locale (locale): + """Set locale via LC_ALL.""" + nls.set_locale (locale) + +def restore_locale (): + nls.restore_locale () |