Commit 38e3ef3d 38e3ef3d1bf8ead953d9f0231c39a90fbdac63a9 by Wojciech Polak

Split Python interface into libmu_py and c_api.so.

* include/mailutils/python.h: New file.
* python/c_api: Rename to python/libmu_py.
1 parent 5b1a5402
Showing 45 changed files with 613 additions and 917 deletions
......@@ -50,6 +50,7 @@ AC_SUBST(MU_LIB_SIEVE,'${top_builddir}/libmu_sieve/libmu_sieve.la')
AC_SUBST(MU_LIB_SCM,'${top_builddir}/libmu_scm/libmu_scm.la')
AC_SUBST(MU_LIB_CPP,'${top_builddir}/libmu_cpp/libmu_cpp.la')
AC_SUBST(MU_LIB_ARGP,'${top_builddir}/libmu_argp/libmu_argp.la')
AC_SUBST(MU_LIB_PY, '${top_builddir}/python/libmu_py/libmu_py.la')
dnl Other variables
AC_SUBST(SIEVE_MODDIR,'$(libdir)/$(PACKAGE)')
......@@ -1104,9 +1105,11 @@ case "${withval}" in
*) AC_MSG_ERROR(bad value ${withval} for --without-python) ;;
esac],[status_python=yes])
AC_SUBST(MU_PY)
if test "$status_python" = yes; then
AM_PATH_PYTHON(2.5.0,, [status_python=no])
if test "$status_python" = yes; then
MU_PY=libmu_py.la
AC_ARG_VAR([PYTHON_CONFIG], [The name of python-config binary])
AC_PATH_PROG([PYTHON_CONFIG], python-config)
if test -n "$PYTHON_CONFIG"; then
......@@ -1117,6 +1120,7 @@ if test "$status_python" = yes; then
fi
if test "$status_python" = yes; then
AC_DEFINE(WITH_PYTHON,1,[Enable Python support])
AC_SUBST(MU_PYTHON_LTLIBS,'$(MU_PYTHON_LTLIBS)')
fi
fi
......@@ -1305,7 +1309,7 @@ AC_CONFIG_FILES([Makefile
pop3d/Makefile
pop3d/testsuite/Makefile
python/Makefile
python/c_api/Makefile
python/libmu_py/Makefile
python/mailutils/Makefile
readmsg/Makefile
readmsg/testsuite/Makefile
......
......@@ -80,6 +80,7 @@ pkginclude_HEADERS = \
pop3.h\
progmailer.h\
property.h\
python.h\
radius.h\
refcount.h\
registrar.h\
......
/* 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 */
#ifndef _MAILUTILS_PYTHON_H
#define _MAILUTILS_PYTHON_H
#include <Python.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
PyObject_HEAD;
mu_address_t addr;
} PyAddress;
typedef struct {
PyObject_HEAD;
mu_attribute_t attr;
} PyAttribute;
typedef struct {
PyObject_HEAD;
mu_authority_t auth;
} PyAuthority;
typedef struct {
PyObject_HEAD;
mu_ticket_t ticket;
} PyTicket;
typedef struct {
PyObject_HEAD;
mu_wicket_t wicket;
} PyWicket;
typedef struct {
PyObject_HEAD;
struct mu_auth_data *auth_data;
} PyAuthData;
typedef struct {
PyObject_HEAD;
mu_body_t body;
} PyBody;
typedef struct {
PyObject_HEAD;
mu_debug_t dbg;
} PyDebug;
typedef struct {
PyObject_HEAD;
mu_envelope_t env;
} PyEnvelope;
typedef struct {
PyObject_HEAD;
mu_folder_t folder;
} PyFolder;
typedef struct {
PyObject_HEAD;
mu_header_t hdr;
} PyHeader;
typedef struct {
PyObject_HEAD;
mu_mailbox_t mbox;
} PyMailbox;
typedef struct {
PyObject_HEAD;
mu_mailcap_t mc;
} PyMailcap;
typedef struct {
PyObject_HEAD;
mu_mailcap_entry_t entry;
} PyMailcapEntry;
typedef struct {
PyObject_HEAD;
mu_mailer_t mlr;
} PyMailer;
typedef struct {
PyObject_HEAD;
mu_message_t msg;
} PyMessage;
typedef struct {
PyObject_HEAD;
mu_mime_t mime;
} PyMime;
typedef struct {
PyObject_HEAD;
mu_stream_t stm;
} PyStream;
typedef struct {
PyObject_HEAD;
mu_url_t url;
} PyUrl;
typedef int (*mulist_extractor_fp) (void *data, PyObject **dst);
extern void mu_py_init (void);
extern void mu_py_init_address (void);
extern void mu_py_init_attribute (void);
extern void mu_py_init_auth (void);
extern void mu_py_init_body (void);
extern void mu_py_init_debug (void);
extern void mu_py_init_envelope (void);
extern void mu_py_init_header (void);
extern void mu_py_init_folder (void);
extern void mu_py_init_mailer (void);
extern void mu_py_init_mailbox (void);
extern void mu_py_init_mailcap (void);
extern void mu_py_init_message (void);
extern void mu_py_init_mime (void);
extern void mu_py_init_stream (void);
extern void mu_py_init_url (void);
extern PyObject * mu_py_mulist_to_pylist (mu_list_t list,
mulist_extractor_fp fnc);
extern PyAttribute * PyAttribute_NEW ();
extern PyAddress * PyAddress_NEW ();
extern PyAuthority * PyAuthority_NEW ();
extern PyTicket * PyTicket_NEW ();
extern PyWicket * PyWicket_NEW ();
extern PyAuthData * PyAuthData_NEW ();
extern PyBody * PyBody_NEW ();
extern PyDebug * PyDebug_NEW ();
extern PyEnvelope * PyEnvelope_NEW ();
extern PyFolder * PyFolder_NEW ();
extern PyHeader * PyHeader_NEW ();
extern PyMailcap * PyMailcap_NEW ();
extern PyMailcapEntry * PyMailcapEntry_NEW ();
extern PyMailer * PyMailer_NEW ();
extern PyMessage * PyMessage_NEW ();
extern PyMime * PyMime_NEW ();
extern PyStream * PyStream_NEW ();
extern PyUrl * PyUrl_NEW ();
extern int PyAddress_Check (PyObject *x);
extern int PyAuthority_Check (PyObject *x);
extern int PyTicket_Check (PyObject *x);
extern int PyWicket_Check (PyObject *x);
extern int PyAuthData_Check (PyObject *x);
extern int PyMessage_Check (PyObject *x);
extern int PyStream_Check (PyObject *x);
#ifdef __cplusplus
}
#endif
#endif /* _MAILUTILS_PYTHON_H */
......@@ -79,6 +79,9 @@ static struct mu_conf_option mu_conf_option[] = {
#ifdef WITH_GUILE
{ "WITH_GUILE", N_("Support for Guile as extension language") },
#endif
#ifdef WITH_PYTHON
{ "WITH_PYTHON", N_("Support for Python as extension language") },
#endif
#ifdef WITH_PTHREAD
{ "WITH_PTHREAD", N_("Support for POSIX threads") },
#endif
......
......@@ -17,5 +17,5 @@
## Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA
## 02110-1301 USA
SUBDIRS = c_api mailutils
SUBDIRS = libmu_py mailutils
......
/*
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
*/
#ifndef _MUCAPI_ADDRESS_H
#define _MUCAPI_ADDRESS_H
#include <mailutils/address.h>
typedef struct {
PyObject_HEAD;
mu_address_t addr;
} PyAddress;
extern PyAddress * PyAddress_NEW ();
extern int PyAddress_Check (PyObject *x);
#endif /* not _MUCAPI_ADDRESS_H */
/*
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
*/
#ifndef _MUCAPI_ATTRIBUTE_H
#define _MUCAPI_ATTRIBUTE_H
#include <mailutils/attribute.h>
typedef struct {
PyObject_HEAD;
mu_attribute_t attr;
} PyAttribute;
extern PyAttribute * PyAttribute_NEW ();
#endif /* not _MUCAPI_ATTRIBUTE_H */
/*
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
*/
#ifndef _MUCAPI_AUTH_H
#define _MUCAPI_AUTH_H
#include <mailutils/auth.h>
#include <mailutils/mu_auth.h>
typedef struct {
PyObject_HEAD;
mu_authority_t auth;
} PyAuthority;
typedef struct {
PyObject_HEAD;
mu_ticket_t ticket;
} PyTicket;
typedef struct {
PyObject_HEAD;
mu_wicket_t wicket;
} PyWicket;
typedef struct {
PyObject_HEAD;
struct mu_auth_data *auth_data;
} PyAuthData;
extern PyAuthority * PyAuthority_NEW ();
extern int PyAuthority_Check (PyObject *x);
extern PyTicket * PyTicket_NEW ();
extern int PyTicket_Check (PyObject *x);
extern PyWicket * PyWicket_NEW ();
extern int PyWicket_Check (PyObject *x);
extern PyAuthData * PyAuthData_NEW ();
extern int PyAuthData_Check (PyObject *x);
#endif /* not _MUCAPI_AUTH_H */
/*
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
*/
#ifndef _MUCAPI_BODY_H
#define _MUCAPI_BODY_H
#include <mailutils/body.h>
typedef struct {
PyObject_HEAD;
mu_body_t body;
} PyBody;
extern PyBody * PyBody_NEW ();
#endif /* not _MUCAPI_BODY_H */
/*
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
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <Python.h>
#define PY_PACKAGE_NAME "mailutils"
#define PY_ROOT_NAME "c_api"
#define PY_PACKAGE_VERSION PACKAGE_VERSION
extern inline PyObject * _ro (PyObject *obj);
extern void py_dealloc (PyObject *self);
extern PyObject * status_object (int status, PyObject *py_obj);
extern PyObject * attach_module (const char *name, PyMethodDef *methods);
extern void init_error ();
extern void init_address ();
extern void init_attribute ();
extern void init_auth ();
extern void init_body ();
extern void init_debug ();
extern void init_envelope ();
extern void init_header ();
extern void init_filter ();
extern void init_folder ();
extern void init_mailer ();
extern void init_mailbox ();
extern void init_mailcap ();
extern void init_message ();
extern void init_mime ();
extern void init_registrar ();
extern void init_stream ();
extern void init_url ();
extern void init_util ();
/*
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
*/
#ifndef _MUCAPI_DEBUG_H
#define _MUCAPI_DEBUG_H
#include <mailutils/debug.h>
typedef struct {
PyObject_HEAD;
mu_debug_t dbg;
} PyDebug;
extern PyDebug * PyDebug_NEW ();
#endif /* not _MUCAPI_DEBUG_H */
/*
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
*/
#ifndef _MUCAPI_ENVELOPE_H
#define _MUCAPI_ENVELOPE_H
#include <mailutils/envelope.h>
typedef struct {
PyObject_HEAD;
mu_envelope_t env;
} PyEnvelope;
extern PyEnvelope * PyEnvelope_NEW ();
#endif /* not _MUCAPI_ENVELOPE_H */
/*
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
*/
#ifndef _MUCAPI_FOLDER_H
#define _MUCAPI_FOLDER_H
#include <mailutils/folder.h>
typedef struct {
PyObject_HEAD;
mu_folder_t folder;
} PyFolder;
extern PyFolder * PyFolder_NEW ();
#endif /* not _MUCAPI_FOLDER_H */
/*
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
*/
#ifndef _MUCAPI_HEADER_H
#define _MUCAPI_HEADER_H
#include <mailutils/header.h>
typedef struct {
PyObject_HEAD;
mu_header_t hdr;
} PyHeader;
extern PyHeader * PyHeader_NEW ();
#endif /* not _MUCAPI_HEADER_H */
/*
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
*/
#ifndef _MUCAPI_MAILBOX_H
#define _MUCAPI_MAILBOX_H
#include <mailutils/mailbox.h>
typedef struct {
PyObject_HEAD;
mu_mailbox_t mbox;
} PyMailbox;
#endif /* not _MUCAPI_MAILBOX_H */
/*
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
*/
#ifndef _MUCAPI_MAILCAP_H
#define _MUCAPI_MAILCAP_H
#include <mailutils/mailcap.h>
typedef struct {
PyObject_HEAD;
mu_mailcap_t mc;
} PyMailcap;
typedef struct {
PyObject_HEAD;
mu_mailcap_entry_t entry;
} PyMailcapEntry;
extern PyMailcap * PyMailcap_NEW ();
extern PyMailcapEntry * PyMailcapEntry_NEW ();
#endif /* not _MUCAPI_MAILCAP_H */
/*
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
*/
#ifndef _MUCAPI_MAILER_H
#define _MUCAPI_MAILER_H
#include <mailutils/mailer.h>
typedef struct {
PyObject_HEAD;
mu_mailer_t mlr;
} PyMailer;
extern PyMailer * PyMailer_NEW ();
#endif /* not _MUCAPI_MAILER_H */
/*
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
*/
#ifndef _MUCAPI_MESSAGE_H
#define _MUCAPI_MESSAGE_H
#include <mailutils/message.h>
typedef struct {
PyObject_HEAD;
mu_message_t msg;
} PyMessage;
extern PyMessage * PyMessage_NEW ();
extern int PyMessage_Check (PyObject *x);
#endif /* not _MUCAPI_MESSAGE_H */
/*
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
*/
#ifndef _MUCAPI_MIME_H
#define _MUCAPI_MIME_H
#include <mailutils/mime.h>
typedef struct {
PyObject_HEAD;
mu_mime_t mime;
} PyMime;
extern PyMime * PyMime_NEW ();
#endif /* not _MUCAPI_MIME_H */
/*
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
*/
#ifndef _MUCAPI_STREAM_H
#define _MUCAPI_STREAM_H
#include <mailutils/stream.h>
typedef struct {
PyObject_HEAD;
mu_stream_t stm;
} PyStream;
extern PyStream * PyStream_NEW ();
extern int PyStream_Check (PyObject *x);
#endif /* not _MUCAPI_STREAM_H */
/*
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
*/
#ifndef _MUCAPI_URL_H
#define _MUCAPI_URL_H
#include <mailutils/url.h>
typedef struct {
PyObject_HEAD;
mu_url_t url;
} PyUrl;
extern PyUrl * PyUrl_NEW ();
#endif /* not _MUCAPI_URL_H */
......@@ -19,59 +19,49 @@
INCLUDES = @MU_COMMON_INCLUDES@ $(PYTHON_INCLUDES)
MU_PYTHON_LTLIBS = c_api.la
EXTRA_LTLIBRARIES = c_api.la
pkgpyexec_LTLIBRARIES = @MU_PYTHON_LTLIBS@
c_api_la_LDFLAGS = -avoid-version -module -rpath $(pkgpyexecdir)
c_api_la_LIBADD = $(PYTHON_LIBS) @MU_COMMON_LIBRARIES@ \
${MU_LIB_MBOX}\
${MU_LIB_IMAP}\
${MU_LIB_POP}\
${MU_LIB_NNTP}\
${MU_LIB_MH}\
${MU_LIB_MAILDIR}\
${MU_LIB_AUTH}\
${MU_LIB_MAILER}\
@MU_AUTHLIBS@\
${MU_LIB_MAILUTILS}
EXTRA_LTLIBRARIES = libmu_py.la c_api.la
c_api_la_SOURCES = \
c_api.c \
c_api.h \
lib_LTLIBRARIES=@MU_PY@
libmu_py_la_SOURCES = \
error.c \
address.c \
address-private.h \
attribute.c \
attribute-private.h \
auth.c \
auth-private.h \
body.c \
body-private.h \
debug.c \
debug-private.h \
envelope.c \
envelope-private.h \
filter.c \
folder.c \
folder-private.h \
libmu_py.c \
libmu_py.h \
list.c \
list-private.h \
header.c \
header-private.h \
mailer.c \
mailer-private.h \
mailbox.c \
mailbox-private.h \
mailcap.c \
mailcap-private.h \
message.c \
message-private.h \
mime.c \
mime-private.h \
stream.c \
stream-private.h \
registrar.c \
url.c \
url-private.h \
util.c
libmu_py_la_LDFLAGS = -rpath $(libdir) \
-export-symbols-regex '^(mu_py_|Py).*' \
-version-info @VI_CURRENT@:@VI_REVISION@:@VI_AGE@
libmu_py_la_LIBADD = $(PYTHON_LIBS) @MU_COMMON_LIBRARIES@ \
${MU_LIB_MBOX}\
${MU_LIB_IMAP}\
${MU_LIB_POP}\
${MU_LIB_NNTP}\
${MU_LIB_MH}\
${MU_LIB_MAILDIR}\
${MU_LIB_AUTH}\
${MU_LIB_MAILER}\
@MU_AUTHLIBS@\
${MU_LIB_MAILUTILS}
MU_PYTHON_LTLIBS = c_api.la
pkgpyexec_LTLIBRARIES = @MU_PYTHON_LTLIBS@
c_api_la_LDFLAGS = -avoid-version -module -rpath $(pkgpyexecdir)
c_api_la_LIBADD = $(PYTHON_LIBS) ${MU_LIB_PY}
c_api_la_SOURCES = c_api.c
......
......@@ -18,8 +18,7 @@
Boston, MA 02110-1301 USA
*/
#include "c_api.h"
#include "address-private.h"
#include "libmu_py.h"
#define PY_MODULE "address"
#define PY_CSNAME "AddressType"
......@@ -38,7 +37,7 @@ static PyTypeObject PyAddressType = {
PY_MODULE "." PY_CSNAME, /* tp_name */
sizeof (PyAddress), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)py_dealloc, /* tp_dealloc */
(destructor)_py_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr; __getattr__ */
0, /* tp_setattr; __setattr__ */
......@@ -55,12 +54,12 @@ static PyTypeObject PyAddressType = {
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
......@@ -326,15 +325,18 @@ static PyMethodDef methods[] = {
};
void
init_address ()
mu_py_init_address (void)
{
PyObject *m;
PyAddressType.tp_new = PyType_GenericNew;
if (PyType_Ready (&PyAddressType) < 0)
return;
}
if ((m = attach_module (PY_MODULE, methods)))
void
_mu_py_attach_address (void)
{
PyObject *m;
if ((m = _mu_py_attach_module (PY_MODULE, methods)))
{
Py_INCREF (&PyAddressType);
PyModule_AddObject (m, PY_CSNAME, (PyObject *)&PyAddressType);
......
......@@ -18,8 +18,7 @@
Boston, MA 02110-1301 USA
*/
#include "c_api.h"
#include "attribute-private.h"
#include "libmu_py.h"
#define PY_MODULE "attribute"
#define PY_CSNAME "AttributeType"
......@@ -38,7 +37,7 @@ static PyTypeObject PyAttributeType = {
PY_MODULE "." PY_CSNAME, /* tp_name */
sizeof (PyAttribute), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)py_dealloc, /* tp_dealloc */
(destructor)_py_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr; __getattr__ */
0, /* tp_setattr; __setattr__ */
......@@ -55,12 +54,12 @@ static PyTypeObject PyAttributeType = {
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
......@@ -229,15 +228,18 @@ static PyMethodDef methods[] = {
};
void
init_attribute ()
mu_py_init_attribute (void)
{
PyObject *m;
PyAttributeType.tp_new = PyType_GenericNew;
if (PyType_Ready (&PyAttributeType) < 0)
return;
}
if ((m = attach_module (PY_MODULE, methods)))
void
_mu_py_attach_attribute (void)
{
PyObject *m;
if ((m = _mu_py_attach_module (PY_MODULE, methods)))
{
Py_INCREF (&PyAttributeType);
PyModule_AddObject (m, PY_CSNAME, (PyObject *)&PyAttributeType);
......
......@@ -18,8 +18,7 @@
Boston, MA 02110-1301 USA
*/
#include "c_api.h"
#include "auth-private.h"
#include "libmu_py.h"
#define PY_MODULE "auth"
#define PY_CSNAME1 "AuthorityType"
......@@ -66,7 +65,7 @@ static PyTypeObject PyAuthorityType = {
PY_MODULE "." PY_CSNAME1, /* tp_name */
sizeof (PyAuthority), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)py_dealloc, /* tp_dealloc */
(destructor)_py_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr; __getattr__ */
0, /* tp_setattr; __setattr__ */
......@@ -83,12 +82,12 @@ static PyTypeObject PyAuthorityType = {
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
......@@ -108,7 +107,7 @@ static PyTypeObject PyTicketType = {
PY_MODULE "." PY_CSNAME2, /* tp_name */
sizeof (PyTicket), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)py_dealloc, /* tp_dealloc */
(destructor)_py_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr; __getattr__ */
0, /* tp_setattr; __setattr__ */
......@@ -125,12 +124,12 @@ static PyTypeObject PyTicketType = {
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
......@@ -150,7 +149,7 @@ static PyTypeObject PyWicketType = {
PY_MODULE "." PY_CSNAME3, /* tp_name */
sizeof (PyWicket), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)py_dealloc, /* tp_dealloc */
(destructor)_py_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr; __getattr__ */
0, /* tp_setattr; __setattr__ */
......@@ -167,12 +166,12 @@ static PyTypeObject PyWicketType = {
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
......@@ -266,12 +265,12 @@ static PyTypeObject PyAuthDataType = {
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
......@@ -668,10 +667,8 @@ static PyMethodDef methods[] = {
};
void
init_auth ()
mu_py_init_auth (void)
{
PyObject *m;
PyAuthorityType.tp_new = PyType_GenericNew;
PyTicketType.tp_new = PyType_GenericNew;
PyWicketType.tp_new = PyType_GenericNew;
......@@ -685,8 +682,13 @@ init_auth ()
return;
if (PyType_Ready (&PyAuthDataType) < 0)
return;
}
if ((m = attach_module (PY_MODULE, methods)))
void
_mu_py_attach_auth (void)
{
PyObject *m;
if ((m = _mu_py_attach_module (PY_MODULE, methods)))
{
Py_INCREF (&PyAuthorityType);
Py_INCREF (&PyTicketType);
......
......@@ -18,9 +18,7 @@
Boston, MA 02110-1301 USA
*/
#include "c_api.h"
#include "body-private.h"
#include "stream-private.h"
#include "libmu_py.h"
#define PY_MODULE "body"
#define PY_CSNAME "BodyType"
......@@ -39,7 +37,7 @@ static PyTypeObject PyBodyType = {
PY_MODULE "." PY_CSNAME, /* tp_name */
sizeof (PyBody), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)py_dealloc, /* tp_dealloc */
(destructor)_py_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr; __getattr__ */
0, /* tp_setattr; __setattr__ */
......@@ -56,12 +54,12 @@ static PyTypeObject PyBodyType = {
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
......@@ -140,15 +138,18 @@ static PyMethodDef methods[] = {
};
void
init_body ()
mu_py_init_body (void)
{
PyObject *m;
PyBodyType.tp_new = PyType_GenericNew;
if (PyType_Ready (&PyBodyType) < 0)
return;
}
if ((m = attach_module (PY_MODULE, methods)))
void
_mu_py_attach_body (void)
{
PyObject *m;
if ((m = _mu_py_attach_module (PY_MODULE, methods)))
{
Py_INCREF (&PyBodyType);
PyModule_AddObject (m, PY_CSNAME, (PyObject *)&PyBodyType);
......
......@@ -18,13 +18,11 @@
Boston, MA 02110-1301 USA
*/
#ifndef _MUCAPI_LIST_H
#define _MUCAPI_LIST_H
#include <mailutils/list.h>
typedef int (*mulist_extractor_fp) (void *data, PyObject **dst);
extern PyObject * mulist_to_pylist (mu_list_t list, mulist_extractor_fp fnc);
#endif /* not _MUCAPI_LIST_H */
#include "libmu_py.h"
PyMODINIT_FUNC
initc_api (void)
{
mu_py_init ();
mu_py_attach_modules ();
}
......
......@@ -18,8 +18,7 @@
Boston, MA 02110-1301 USA
*/
#include "c_api.h"
#include "debug-private.h"
#include "libmu_py.h"
#define PY_MODULE "debug"
#define PY_CSNAME "DebugType"
......@@ -38,7 +37,7 @@ static PyTypeObject PyDebugType = {
PY_MODULE "." PY_CSNAME, /* tp_name */
sizeof (PyDebug), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)py_dealloc, /* tp_dealloc */
(destructor)_py_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr; __getattr__ */
0, /* tp_setattr; __setattr__ */
......@@ -55,12 +54,12 @@ static PyTypeObject PyDebugType = {
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
......@@ -102,15 +101,18 @@ static PyMethodDef methods[] = {
};
void
init_debug ()
mu_py_init_debug (void)
{
PyObject *m;
PyDebugType.tp_new = PyType_GenericNew;
if (PyType_Ready (&PyDebugType) < 0)
return;
}
if ((m = attach_module (PY_MODULE, methods)))
void
_mu_py_attach_debug (void)
{
PyObject *m;
if ((m = _mu_py_attach_module (PY_MODULE, methods)))
{
Py_INCREF (&PyDebugType);
PyModule_AddObject (m, PY_CSNAME, (PyObject *)&PyDebugType);
......
......@@ -18,8 +18,7 @@
Boston, MA 02110-1301 USA
*/
#include "c_api.h"
#include "envelope-private.h"
#include "libmu_py.h"
#define PY_MODULE "envelope"
#define PY_CSNAME "EnvelopeType"
......@@ -38,7 +37,7 @@ static PyTypeObject PyEnvelopeType = {
PY_MODULE "." PY_CSNAME, /* tp_name */
sizeof (PyEnvelope), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)py_dealloc, /* tp_dealloc */
(destructor)_py_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr; __getattr__ */
0, /* tp_setattr; __setattr__ */
......@@ -55,12 +54,12 @@ static PyTypeObject PyEnvelopeType = {
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
......@@ -150,15 +149,18 @@ static PyMethodDef methods[] = {
};
void
init_envelope ()
mu_py_init_envelope ()
{
PyObject *m;
PyEnvelopeType.tp_new = PyType_GenericNew;
if (PyType_Ready (&PyEnvelopeType) < 0)
return;
}
if ((m = attach_module (PY_MODULE, methods)))
void
_mu_py_attach_envelope (void)
{
PyObject *m;
if ((m = _mu_py_attach_module (PY_MODULE, methods)))
{
Py_INCREF (&PyEnvelopeType);
PyModule_AddObject (m, PY_CSNAME, (PyObject *)&PyEnvelopeType);
......
......@@ -18,7 +18,7 @@
Boston, MA 02110-1301 USA
*/
#include "c_api.h"
#include "libmu_py.h"
#define PY_MODULE "error"
......@@ -44,7 +44,7 @@ static PyMethodDef methods[] = {
};
void
init_error ()
_mu_py_attach_error (void)
{
attach_module (PY_MODULE, methods);
_mu_py_attach_module (PY_MODULE, methods);
}
......
......@@ -18,9 +18,7 @@
Boston, MA 02110-1301 USA
*/
#include "c_api.h"
#include "stream-private.h"
#include <mailutils/filter.h>
#include "libmu_py.h"
#define PY_MODULE "filter"
......@@ -85,7 +83,7 @@ static PyMethodDef methods[] = {
};
void
init_filter ()
_mu_py_attach_filter (void)
{
attach_module (PY_MODULE, methods);
_mu_py_attach_module (PY_MODULE, methods);
}
......
......@@ -18,11 +18,7 @@
Boston, MA 02110-1301 USA
*/
#include "c_api.h"
#include "folder-private.h"
#include "stream-private.h"
#include "auth-private.h"
#include "url-private.h"
#include "libmu_py.h"
#define PY_MODULE "folder"
#define PY_CSNAME "FolderType"
......@@ -41,7 +37,7 @@ static PyTypeObject PyFolderType = {
PY_MODULE "." PY_CSNAME, /* tp_name */
sizeof (PyFolder), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)py_dealloc, /* tp_dealloc */
(destructor)_py_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr; __getattr__ */
0, /* tp_setattr; __setattr__ */
......@@ -58,12 +54,12 @@ static PyTypeObject PyFolderType = {
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
......@@ -260,7 +256,7 @@ api_folder_list (PyObject *self, PyObject *args)
&c_list);
if (c_list)
py_list = mulist_to_pylist (c_list, folderdata_extractor);
py_list = mu_py_mulist_to_pylist (c_list, folderdata_extractor);
else
py_list = PyTuple_New (0);
......@@ -302,15 +298,18 @@ static PyMethodDef methods[] = {
};
void
init_folder ()
mu_py_init_folder (void)
{
PyObject *m;
PyFolderType.tp_new = PyType_GenericNew;
if (PyType_Ready (&PyFolderType) < 0)
return;
}
if ((m = attach_module (PY_MODULE, methods)))
void
_mu_py_attach_folder (void)
{
PyObject *m;
if ((m = _mu_py_attach_module (PY_MODULE, methods)))
{
Py_INCREF (&PyFolderType);
PyModule_AddObject (m, PY_CSNAME, (PyObject *)&PyFolderType);
......
......@@ -18,8 +18,7 @@
Boston, MA 02110-1301 USA
*/
#include "c_api.h"
#include "header-private.h"
#include "libmu_py.h"
#define PY_MODULE "header"
#define PY_CSNAME "HeaderType"
......@@ -38,7 +37,7 @@ static PyTypeObject PyHeaderType = {
PY_MODULE "." PY_CSNAME, /* tp_name */
sizeof (PyHeader), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)py_dealloc, /* tp_dealloc */
(destructor)_py_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr; __getattr__ */
0, /* tp_setattr; __setattr__ */
......@@ -55,12 +54,12 @@ static PyTypeObject PyHeaderType = {
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
......@@ -208,15 +207,18 @@ static PyMethodDef methods[] = {
};
void
init_header ()
mu_py_init_header (void)
{
PyObject *m;
PyHeaderType.tp_new = PyType_GenericNew;
if (PyType_Ready (&PyHeaderType) < 0)
return;
}
if ((m = attach_module (PY_MODULE, methods)))
void
_mu_py_attach_header (void)
{
PyObject *m;
if ((m = _mu_py_attach_module (PY_MODULE, methods)))
{
Py_INCREF (&PyHeaderType);
PyModule_AddObject (m, PY_CSNAME, (PyObject *)&PyHeaderType);
......
......@@ -18,7 +18,7 @@
Boston, MA 02110-1301 USA
*/
#include "c_api.h"
#include "libmu_py.h"
inline PyObject *
_ro (PyObject *obj)
......@@ -28,7 +28,7 @@ _ro (PyObject *obj)
}
void
py_dealloc (PyObject *self)
_py_dealloc (PyObject *self)
{
self->ob_type->tp_free (self);
}
......@@ -42,15 +42,11 @@ status_object (int status, PyObject *py_obj)
return _ro (py_ret);
}
static PyMethodDef nomethods[] = {
{ NULL, NULL }
};
static PyObject *package;
static PyObject *all;
PyObject *
attach_module (const char *name, PyMethodDef *methods)
_mu_py_attach_module (const char *name, PyMethodDef *methods)
{
PyObject *module, *m;
......@@ -72,8 +68,32 @@ attach_module (const char *name, PyMethodDef *methods)
return m;
}
PyMODINIT_FUNC
initc_api (void)
void
mu_py_init (void)
{
mu_py_init_address ();
mu_py_init_attribute ();
mu_py_init_auth ();
mu_py_init_body ();
mu_py_init_debug ();
mu_py_init_envelope ();
mu_py_init_header ();
mu_py_init_folder ();
mu_py_init_mailer ();
mu_py_init_mailbox ();
mu_py_init_mailcap ();
mu_py_init_message ();
mu_py_init_mime ();
mu_py_init_stream ();
mu_py_init_url ();
}
static PyMethodDef nomethods[] = {
{ NULL, NULL }
};
void
mu_py_attach_modules (void)
{
package = Py_InitModule (PY_ROOT_NAME, nomethods);
if (!package)
......@@ -87,23 +107,23 @@ initc_api (void)
return;
}
init_error ();
init_address ();
init_attribute ();
init_auth ();
init_body ();
init_debug ();
init_envelope ();
init_header ();
init_filter ();
init_folder ();
init_mailer ();
init_mailbox ();
init_mailcap ();
init_message ();
init_mime ();
init_registrar ();
init_stream ();
init_url ();
init_util ();
_mu_py_attach_error ();
_mu_py_attach_address ();
_mu_py_attach_attribute ();
_mu_py_attach_auth ();
_mu_py_attach_body ();
_mu_py_attach_debug ();
_mu_py_attach_envelope ();
_mu_py_attach_header ();
_mu_py_attach_filter ();
_mu_py_attach_folder ();
_mu_py_attach_mailer ();
_mu_py_attach_mailbox ();
_mu_py_attach_mailcap ();
_mu_py_attach_message ();
_mu_py_attach_mime ();
_mu_py_attach_registrar ();
_mu_py_attach_stream ();
_mu_py_attach_url ();
_mu_py_attach_util ();
}
......
/*
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
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <mailutils/address.h>
#include <mailutils/attribute.h>
#include <mailutils/auth.h>
#include <mailutils/body.h>
#include <mailutils/debug.h>
#include <mailutils/envelope.h>
#include <mailutils/error.h>
#include <mailutils/filter.h>
#include <mailutils/folder.h>
#include <mailutils/header.h>
#include <mailutils/list.h>
#include <mailutils/mailbox.h>
#include <mailutils/mailcap.h>
#include <mailutils/mailer.h>
#include <mailutils/message.h>
#include <mailutils/mime.h>
#include <mailutils/mu_auth.h>
#include <mailutils/mutil.h>
#include <mailutils/registrar.h>
#include <mailutils/tls.h>
#include <mailutils/stream.h>
#include <mailutils/url.h>
#include <mailutils/python.h>
#define PY_PACKAGE_NAME "mailutils"
#define PY_ROOT_NAME "c_api"
#define PY_PACKAGE_VERSION PACKAGE_VERSION
extern inline PyObject * _ro (PyObject *obj);
extern void _py_dealloc (PyObject *self);
extern PyObject * status_object (int status, PyObject *py_obj);
extern PyObject * _mu_py_attach_module (const char *name, PyMethodDef *methods);
extern void mu_py_attach_modules (void);
extern void _mu_py_attach_error (void);
extern void _mu_py_attach_address (void);
extern void _mu_py_attach_attribute (void);
extern void _mu_py_attach_auth (void);
extern void _mu_py_attach_body (void);
extern void _mu_py_attach_debug (void);
extern void _mu_py_attach_envelope (void);
extern void _mu_py_attach_header (void);
extern void _mu_py_attach_filter (void);
extern void _mu_py_attach_folder (void);
extern void _mu_py_attach_mailer (void);
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_registrar (void);
extern void _mu_py_attach_stream (void);
extern void _mu_py_attach_url (void);
extern void _mu_py_attach_util (void);
......@@ -18,11 +18,10 @@
Boston, MA 02110-1301 USA
*/
#include "c_api.h"
#include "list-private.h"
#include "libmu_py.h"
PyObject *
mulist_to_pylist (mu_list_t list, mulist_extractor_fp extractor)
mu_py_mulist_to_pylist (mu_list_t list, mulist_extractor_fp extractor)
{
int status, i;
size_t list_count;
......
......@@ -18,12 +18,7 @@
Boston, MA 02110-1301 USA
*/
#include "c_api.h"
#include "mailbox-private.h"
#include "message-private.h"
#include "folder-private.h"
#include "url-private.h"
#include "debug-private.h"
#include "libmu_py.h"
#define PY_MODULE "mailbox"
#define PY_CSNAME "MailboxType"
......@@ -42,7 +37,7 @@ static PyTypeObject PyMailboxType = {
PY_MODULE "." PY_CSNAME, /* tp_name */
sizeof (PyMailbox), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)py_dealloc, /* tp_dealloc */
(destructor)_py_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr; __getattr__ */
0, /* tp_setattr; __setattr__ */
......@@ -59,12 +54,12 @@ static PyTypeObject PyMailboxType = {
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
......@@ -418,15 +413,18 @@ static PyMethodDef methods[] = {
};
void
init_mailbox ()
mu_py_init_mailbox (void)
{
PyObject *m;
PyMailboxType.tp_new = PyType_GenericNew;
if (PyType_Ready (&PyMailboxType) < 0)
return;
}
if ((m = attach_module (PY_MODULE, methods)))
void
_mu_py_attach_mailbox (void)
{
PyObject *m;
if ((m = _mu_py_attach_module (PY_MODULE, methods)))
{
Py_INCREF (&PyMailboxType);
PyModule_AddObject (m, PY_CSNAME, (PyObject *)&PyMailboxType);
......
......@@ -18,9 +18,7 @@
Boston, MA 02110-1301 USA
*/
#include "c_api.h"
#include "mailcap-private.h"
#include "stream-private.h"
#include "libmu_py.h"
#define PY_MODULE "mailcap"
#define PY_CSNAME1 "MailcapType"
......@@ -40,7 +38,7 @@ static PyTypeObject PyMailcapType = {
PY_MODULE "." PY_CSNAME1, /* tp_name */
sizeof (PyMailcap), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)py_dealloc, /* tp_dealloc */
(destructor)_py_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr; __getattr__ */
0, /* tp_setattr; __setattr__ */
......@@ -57,12 +55,12 @@ static PyTypeObject PyMailcapType = {
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
......@@ -96,7 +94,7 @@ static PyTypeObject PyMailcapEntryType = {
PY_MODULE "." PY_CSNAME2, /* tp_name */
sizeof (PyMailcapEntry), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)py_dealloc, /* tp_dealloc */
(destructor)_py_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr; __getattr__ */
0, /* tp_setattr; __setattr__ */
......@@ -113,12 +111,12 @@ static PyTypeObject PyMailcapEntryType = {
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
......@@ -295,17 +293,20 @@ static PyMethodDef methods[] = {
};
void
init_mailcap ()
mu_py_init_mailcap (void)
{
PyObject *m;
PyMailcapType.tp_new = PyType_GenericNew;
PyMailcapEntryType.tp_new = PyType_GenericNew;
if (PyType_Ready (&PyMailcapType) < 0 ||
PyType_Ready (&PyMailcapEntryType) < 0)
return;
}
if ((m = attach_module (PY_MODULE, methods)))
void
_mu_py_attach_mailcap (void)
{
PyObject *m;
if ((m = _mu_py_attach_module (PY_MODULE, methods)))
{
Py_INCREF (&PyMailcapType);
Py_INCREF (&PyMailcapEntryType);
......
......@@ -18,11 +18,7 @@
Boston, MA 02110-1301 USA
*/
#include "c_api.h"
#include "mailer-private.h"
#include "address-private.h"
#include "message-private.h"
#include "debug-private.h"
#include "libmu_py.h"
#define PY_MODULE "mailer"
#define PY_CSNAME "MailerType"
......@@ -41,7 +37,7 @@ static PyTypeObject PyMailerType = {
PY_MODULE "." PY_CSNAME, /* tp_name */
sizeof (PyMailer), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)py_dealloc, /* tp_dealloc */
(destructor)_py_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr; __getattr__ */
0, /* tp_setattr; __setattr__ */
......@@ -58,12 +54,12 @@ static PyTypeObject PyMailerType = {
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
......@@ -214,15 +210,18 @@ static PyMethodDef methods[] = {
};
void
init_mailer ()
mu_py_init_mailer (void)
{
PyObject *m;
PyMailerType.tp_new = PyType_GenericNew;
if (PyType_Ready (&PyMailerType) < 0)
return;
}
if ((m = attach_module (PY_MODULE, methods)))
void
_mu_py_attach_mailer (void)
{
PyObject *m;
if ((m = _mu_py_attach_module (PY_MODULE, methods)))
{
Py_INCREF (&PyMailerType);
PyModule_AddObject (m, PY_CSNAME, (PyObject *)&PyMailerType);
......
......@@ -18,13 +18,7 @@
Boston, MA 02110-1301 USA
*/
#include "c_api.h"
#include "message-private.h"
#include "envelope-private.h"
#include "header-private.h"
#include "body-private.h"
#include "attribute-private.h"
#include "stream-private.h"
#include "libmu_py.h"
#define PY_MODULE "message"
#define PY_CSNAME "MessageType"
......@@ -43,7 +37,7 @@ static PyTypeObject PyMessageType = {
PY_MODULE "." PY_CSNAME, /* tp_name */
sizeof (PyMessage), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)py_dealloc, /* tp_dealloc */
(destructor)_py_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr; __getattr__ */
0, /* tp_setattr; __setattr__ */
......@@ -60,12 +54,12 @@ static PyTypeObject PyMessageType = {
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
......@@ -411,15 +405,18 @@ static PyMethodDef methods[] = {
};
void
init_message ()
mu_py_init_message (void)
{
PyObject *m;
PyMessageType.tp_new = PyType_GenericNew;
if (PyType_Ready (&PyMessageType) < 0)
return;
}
if ((m = attach_module (PY_MODULE, methods)))
void
_mu_py_attach_message (void)
{
PyObject *m;
if ((m = _mu_py_attach_module (PY_MODULE, methods)))
{
Py_INCREF (&PyMessageType);
PyModule_AddObject (m, PY_CSNAME, (PyObject *)&PyMessageType);
......
......@@ -18,9 +18,7 @@
Boston, MA 02110-1301 USA
*/
#include "c_api.h"
#include "mime-private.h"
#include "message-private.h"
#include "libmu_py.h"
#define PY_MODULE "mime"
#define PY_CSNAME "MimeType"
......@@ -39,7 +37,7 @@ static PyTypeObject PyMimeType = {
PY_MODULE "." PY_CSNAME, /* tp_name */
sizeof (PyMime), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)py_dealloc, /* tp_dealloc */
(destructor)_py_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr; __getattr__ */
0, /* tp_setattr; __setattr__ */
......@@ -56,12 +54,12 @@ static PyTypeObject PyMimeType = {
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
......@@ -254,15 +252,18 @@ static PyMethodDef methods[] = {
};
void
init_mime ()
mu_py_init_mime (void)
{
PyObject *m;
PyMimeType.tp_new = PyType_GenericNew;
if (PyType_Ready (&PyMimeType) < 0)
return;
}
if ((m = attach_module (PY_MODULE, methods)))
void
_mu_py_attach_mime (void)
{
PyObject *m;
if ((m = _mu_py_attach_module (PY_MODULE, methods)))
{
Py_INCREF (&PyMimeType);
PyModule_AddObject (m, PY_CSNAME, (PyObject *)&PyMimeType);
......
......@@ -18,9 +18,7 @@
Boston, MA 02110-1301 USA
*/
#include "c_api.h"
#include <mailutils/registrar.h>
#include <mailutils/tls.h>
#include "libmu_py.h"
#define PY_MODULE "registrar"
......@@ -130,9 +128,9 @@ static PyMethodDef methods[] = {
};
void
init_registrar ()
_mu_py_attach_registrar ()
{
attach_module (PY_MODULE, methods);
_mu_py_attach_module (PY_MODULE, methods);
mu_registrar_record (MU_DEFAULT_RECORD);
mu_registrar_set_default_record (MU_DEFAULT_RECORD);
......
......@@ -18,8 +18,7 @@
Boston, MA 02110-1301 USA
*/
#include "c_api.h"
#include "stream-private.h"
#include "libmu_py.h"
#define PY_MODULE "stream"
#define PY_CSNAME "StreamType"
......@@ -38,7 +37,7 @@ static PyTypeObject PyStreamType = {
PY_MODULE "." PY_CSNAME, /* tp_name */
sizeof (PyStream), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)py_dealloc, /* tp_dealloc */
(destructor)_py_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr; __getattr__ */
0, /* tp_setattr; __setattr__ */
......@@ -55,12 +54,12 @@ static PyTypeObject PyStreamType = {
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
......@@ -393,15 +392,18 @@ static PyMethodDef methods[] = {
};
void
init_stream ()
mu_py_init_stream (void)
{
PyObject *m;
PyStreamType.tp_new = PyType_GenericNew;
if (PyType_Ready (&PyStreamType) < 0)
return;
}
if ((m = attach_module (PY_MODULE, methods)))
void
_mu_py_attach_stream (void)
{
PyObject *m;
if ((m = _mu_py_attach_module (PY_MODULE, methods)))
{
Py_INCREF (&PyStreamType);
PyModule_AddObject (m, PY_CSNAME, (PyObject *)&PyStreamType);
......
......@@ -18,8 +18,7 @@
Boston, MA 02110-1301 USA
*/
#include "c_api.h"
#include "url-private.h"
#include "libmu_py.h"
#define PY_MODULE "url"
#define PY_CSNAME "UrlType"
......@@ -38,7 +37,7 @@ static PyTypeObject PyUrlType = {
PY_MODULE "." PY_CSNAME, /* tp_name */
sizeof (PyUrl), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)py_dealloc, /* tp_dealloc */
(destructor)_py_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr; __getattr__ */
0, /* tp_setattr; __setattr__ */
......@@ -55,12 +54,12 @@ static PyTypeObject PyUrlType = {
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
......@@ -278,15 +277,18 @@ static PyMethodDef methods[] = {
};
void
init_url ()
mu_py_init_url (void)
{
PyObject *m;
PyUrlType.tp_new = PyType_GenericNew;
if (PyType_Ready (&PyUrlType) < 0)
return;
}
if ((m = attach_module (PY_MODULE, methods)))
void
_mu_py_attach_url (void)
{
PyObject *m;
if ((m = _mu_py_attach_module (PY_MODULE, methods)))
{
Py_INCREF (&PyUrlType);
PyModule_AddObject (m, PY_CSNAME, (PyObject *)&PyUrlType);
......
......@@ -18,8 +18,7 @@
Boston, MA 02110-1301 USA
*/
#include "c_api.h"
#include <mailutils/mutil.h>
#include "libmu_py.h"
#define PY_MODULE "util"
......@@ -107,7 +106,7 @@ static PyMethodDef methods[] = {
};
void
init_util ()
_mu_py_attach_util (void)
{
attach_module (PY_MODULE, methods);
_mu_py_attach_module (PY_MODULE, methods);
}
......