Add new Python interface and example programs.
Showing
77 changed files
with
4854 additions
and
3 deletions
... | @@ -17,5 +17,5 @@ Sergey Poznyakoff <gray@Mirddin.farlep.net> | ... | @@ -17,5 +17,5 @@ Sergey Poznyakoff <gray@Mirddin.farlep.net> |
17 | Sam Roberts <sroberts@uniserve.com> | 17 | Sam Roberts <sroberts@uniserve.com> |
18 | The parsing code for email addresses. | 18 | The parsing code for email addresses. |
19 | Wojciech Polak <polak@gnu.org> | 19 | Wojciech Polak <polak@gnu.org> |
20 | TLS, NLS, libmu_cpp, docs, misc hacking. | 20 | TLS, NLS, Python interface, libmu_cpp, docs, misc hacking. |
21 | 21 | ... | ... |
... | @@ -158,6 +158,10 @@ mailutils-specific configuration options: | ... | @@ -158,6 +158,10 @@ mailutils-specific configuration options: |
158 | Enable GSSAPI authentication. For this to work, you will have | 158 | Enable GSSAPI authentication. For this to work, you will have |
159 | to have Kerberos V installed on your system. | 159 | to have Kerberos V installed on your system. |
160 | 160 | ||
161 | --without-python | ||
162 | |||
163 | Do not build Python interface library. | ||
164 | |||
161 | --without-guile | 165 | --without-guile |
162 | 166 | ||
163 | Do not build Guile interface library. | 167 | Do not build Guile interface library. | ... | ... |
... | @@ -22,6 +22,7 @@ AC_CONFIG_SRCDIR([mailbox/mailbox.c]) | ... | @@ -22,6 +22,7 @@ AC_CONFIG_SRCDIR([mailbox/mailbox.c]) |
22 | AC_CONFIG_AUX_DIR([scripts]) | 22 | AC_CONFIG_AUX_DIR([scripts]) |
23 | AM_INIT_AUTOMAKE | 23 | AM_INIT_AUTOMAKE |
24 | AC_CONFIG_HEADERS([config.h]) | 24 | AC_CONFIG_HEADERS([config.h]) |
25 | AC_CONFIG_MACRO_DIR([m4]) | ||
25 | 26 | ||
26 | AC_PREREQ(2.60) | 27 | AC_PREREQ(2.60) |
27 | 28 | ||
... | @@ -1092,6 +1093,35 @@ if test "$EMACS" != "no"; then | ... | @@ -1092,6 +1093,35 @@ if test "$EMACS" != "no"; then |
1092 | fi | 1093 | fi |
1093 | AC_SUBST(lisp_LISP) | 1094 | AC_SUBST(lisp_LISP) |
1094 | 1095 | ||
1096 | # Check for Python | ||
1097 | AC_ARG_WITH([python], | ||
1098 | AC_HELP_STRING([--without-python], | ||
1099 | [do not build Python interface]), | ||
1100 | [ | ||
1101 | case "${withval}" in | ||
1102 | yes) status_python=yes ;; | ||
1103 | no) status_python=no ;; | ||
1104 | *) AC_MSG_ERROR(bad value ${withval} for --without-python) ;; | ||
1105 | esac],[status_python=yes]) | ||
1106 | |||
1107 | if test "$status_python" = yes; then | ||
1108 | AM_PATH_PYTHON(2.5.0,, [status_python=no]) | ||
1109 | if test "$status_python" = yes; then | ||
1110 | AC_ARG_VAR([PYTHON_CONFIG], [The name of python-config binary]) | ||
1111 | AC_PATH_PROG([PYTHON_CONFIG], python-config) | ||
1112 | if test -n "$PYTHON_CONFIG"; then | ||
1113 | AC_SUBST(PYTHON_LIBS,`python-config --libs`) | ||
1114 | AC_SUBST(PYTHON_INCLUDES,`python-config --includes`) | ||
1115 | else | ||
1116 | status_python=no | ||
1117 | fi | ||
1118 | |||
1119 | if test "$status_python" = yes; then | ||
1120 | AC_SUBST(MU_PYTHON_LTLIBS,'$(MU_PYTHON_LTLIBS)') | ||
1121 | fi | ||
1122 | fi | ||
1123 | fi | ||
1124 | |||
1095 | # Default mailbox record | 1125 | # Default mailbox record |
1096 | # Note: 1. Support for mbox type is always enabled. | 1126 | # Note: 1. Support for mbox type is always enabled. |
1097 | # 2. Only local mailbox types are allowed for MU_DEFAULT_SCHEME | 1127 | # 2. Only local mailbox types are allowed for MU_DEFAULT_SCHEME |
... | @@ -1162,6 +1192,7 @@ Use GNU TLS.................... $status_gnutls | ... | @@ -1162,6 +1192,7 @@ Use GNU TLS.................... $status_gnutls |
1162 | Use GSASL...................... $status_gsasl | 1192 | Use GSASL...................... $status_gsasl |
1163 | Use GSSAPI..................... $status_gssapi | 1193 | Use GSSAPI..................... $status_gssapi |
1164 | Use Guile...................... $status_guile | 1194 | Use Guile...................... $status_guile |
1195 | Use Python..................... $status_python | ||
1165 | Use TCP wrappers............... $status_tcpwrap | 1196 | Use TCP wrappers............... $status_tcpwrap |
1166 | Pthread support................ $status_pthread | 1197 | Pthread support................ $status_pthread |
1167 | Readline support............... $status_readline | 1198 | Readline support............... $status_readline |
... | @@ -1198,6 +1229,7 @@ status_gnutls=$WITH_GNUTLS | ... | @@ -1198,6 +1229,7 @@ status_gnutls=$WITH_GNUTLS |
1198 | status_gsasl=$status_gsasl | 1229 | status_gsasl=$status_gsasl |
1199 | status_gssapi=$WITH_GSSAPI | 1230 | status_gssapi=$WITH_GSSAPI |
1200 | status_guile=$useguile | 1231 | status_guile=$useguile |
1232 | status_python=$status_python | ||
1201 | status_tcpwrap=$status_tcpwrap | 1233 | status_tcpwrap=$status_tcpwrap |
1202 | status_pthread=$usepthread | 1234 | status_pthread=$usepthread |
1203 | status_readline=$usereadline | 1235 | status_readline=$usereadline |
... | @@ -1226,6 +1258,7 @@ AC_CONFIG_FILES([Makefile | ... | @@ -1226,6 +1258,7 @@ AC_CONFIG_FILES([Makefile |
1226 | examples/Makefile | 1258 | examples/Makefile |
1227 | examples/config/Makefile | 1259 | examples/config/Makefile |
1228 | examples/cpp/Makefile | 1260 | examples/cpp/Makefile |
1261 | examples/python/Makefile | ||
1229 | examples/scheme/Makefile | 1262 | examples/scheme/Makefile |
1230 | frm/Makefile | 1263 | frm/Makefile |
1231 | frm/testsuite/Makefile | 1264 | frm/testsuite/Makefile |
... | @@ -1271,6 +1304,9 @@ AC_CONFIG_FILES([Makefile | ... | @@ -1271,6 +1304,9 @@ AC_CONFIG_FILES([Makefile |
1271 | po/Makefile.in | 1304 | po/Makefile.in |
1272 | pop3d/Makefile | 1305 | pop3d/Makefile |
1273 | pop3d/testsuite/Makefile | 1306 | pop3d/testsuite/Makefile |
1307 | python/Makefile | ||
1308 | python/c_api/Makefile | ||
1309 | python/mailutils/Makefile | ||
1274 | readmsg/Makefile | 1310 | readmsg/Makefile |
1275 | readmsg/testsuite/Makefile | 1311 | readmsg/testsuite/Makefile |
1276 | scripts/Makefile | 1312 | scripts/Makefile | ... | ... |
... | @@ -17,7 +17,7 @@ | ... | @@ -17,7 +17,7 @@ |
17 | ## Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA | 17 | ## Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA |
18 | ## 02110-1301 USA | 18 | ## 02110-1301 USA |
19 | 19 | ||
20 | SUBDIRS = config cpp scheme | 20 | SUBDIRS = config cpp python scheme |
21 | 21 | ||
22 | noinst_PROGRAMS = \ | 22 | noinst_PROGRAMS = \ |
23 | aclck\ | 23 | aclck\ | ... | ... |
examples/python/Makefile.am
0 → 100644
1 | ## Process this file with GNU Automake to create Makefile.in | ||
2 | |||
3 | ## Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | ## | ||
5 | ## GNU Mailutils is free software; you can redistribute it and/or | ||
6 | ## modify it under the terms of the GNU General Public License as | ||
7 | ## published by the Free Software Foundation; either version 3, or (at | ||
8 | ## your option) any later version. | ||
9 | ## | ||
10 | ## This program is distributed in the hope that it will be useful, but | ||
11 | ## WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | ## General Public License for more details. | ||
14 | ## | ||
15 | ## You should have received a copy of the GNU General Public License | ||
16 | ## along with this program; if not, write to the Free Software | ||
17 | ## Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA | ||
18 | ## 02110-1301 USA | ||
19 | |||
20 | EXTRA_DIST = \ | ||
21 | addr.py\ | ||
22 | auth.py\ | ||
23 | iconv.py\ | ||
24 | lsf.py\ | ||
25 | mailcap.py\ | ||
26 | mimetest.py\ | ||
27 | msg-send.py\ | ||
28 | sfrom.py\ | ||
29 | url-parse.py | ||
30 |
examples/python/addr.py
0 → 100644
1 | # GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | # Copyright (C) 2009 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License as published by | ||
6 | # the Free Software Foundation; either version 3, or (at your option) | ||
7 | # any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | # GNU General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils; if not, write to the Free Software | ||
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
17 | # MA 02110-1301 USA | ||
18 | |||
19 | import sys | ||
20 | from mailutils import address | ||
21 | from mailutils import util | ||
22 | from mailutils.error import * | ||
23 | |||
24 | def parse (str): | ||
25 | util.set_user_email_domain ("localhost") | ||
26 | |||
27 | try: | ||
28 | addr = address.Address (str) | ||
29 | |||
30 | count = addr.get_count () | ||
31 | print "%s => count %d" % (addr, len (addr)) | ||
32 | |||
33 | for no in range (1, count + 1): | ||
34 | isgroup = addr.is_group (no) | ||
35 | print "%d " % no, | ||
36 | |||
37 | if isgroup: | ||
38 | print "group <%s>" % addr.get_personal (no) | ||
39 | else: | ||
40 | print "email <%s>" % addr.get_email (no) | ||
41 | |||
42 | if not isgroup: | ||
43 | print " personal <%s>" % addr.get_personal (no) | ||
44 | |||
45 | print " comments <%s>" % addr.get_comments (no) | ||
46 | print " local-part <%s> domain <%s>" % (addr.get_local_part (no), | ||
47 | addr.get_domain (no)) | ||
48 | print " route <%s>" % addr.get_route (no) | ||
49 | except AddressError, e: | ||
50 | print e | ||
51 | |||
52 | |||
53 | def parseinput (): | ||
54 | try: | ||
55 | while True: | ||
56 | line = sys.stdin.readline ().strip () | ||
57 | if line == '': | ||
58 | break | ||
59 | parse (line) | ||
60 | except KeyboardInterrupt: | ||
61 | sys.exit () | ||
62 | |||
63 | if __name__ == '__main__': | ||
64 | if len (sys.argv) == 1: | ||
65 | parseinput () | ||
66 | sys.exit () | ||
67 | |||
68 | for arg in sys.argv[1:]: | ||
69 | if arg == '-': | ||
70 | parseinput () | ||
71 | else: | ||
72 | parse (arg) |
examples/python/auth.py
0 → 100644
1 | # GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | # Copyright (C) 2009 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License as published by | ||
6 | # the Free Software Foundation; either version 3, or (at your option) | ||
7 | # any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | # GNU General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils; if not, write to the Free Software | ||
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
17 | # MA 02110-1301 USA | ||
18 | |||
19 | import sys | ||
20 | import getopt | ||
21 | import getpass | ||
22 | from mailutils import auth | ||
23 | from mailutils.error import AuthError | ||
24 | |||
25 | if __name__ == '__main__': | ||
26 | key_type = 'name' | ||
27 | |||
28 | try: | ||
29 | opts, args = getopt.getopt (sys.argv[1:], 'p:un', | ||
30 | ['password=', 'uid', 'name']) | ||
31 | for o, arg in opts: | ||
32 | if o in ('-p', '--password'): | ||
33 | password = arg | ||
34 | elif o in ('-u', '--uid'): | ||
35 | key_type = 'uid' | ||
36 | elif o in ('-n', '--name'): | ||
37 | key_type = 'name' | ||
38 | except getopt.GetoptError: | ||
39 | print "Usage: %s [OPTION...] key" % sys.argv[0] | ||
40 | print """%s -- test mailutils authentication and authorization schemes | ||
41 | |||
42 | -n, --name test getpwnam functions | ||
43 | -p, --password=STRING user password | ||
44 | -u, --uid test getpwuid functions | ||
45 | """ % sys.argv[0] | ||
46 | sys.exit (0) | ||
47 | |||
48 | if not len (args): | ||
49 | print "%s: not enough arguments, try --help" % sys.argv[0] | ||
50 | sys.exit (0) | ||
51 | |||
52 | if key_type == 'uid': | ||
53 | key = int (args[0]) | ||
54 | else: | ||
55 | key = args[0] | ||
56 | |||
57 | auth.register_module (('system', 'generic')) | ||
58 | |||
59 | if key_type == 'name': | ||
60 | auth_data = auth.get_auth_by_name (key) | ||
61 | elif key_type == 'uid': | ||
62 | auth_data = auth.get_auth_by_uid (key) | ||
63 | |||
64 | if not auth_data: | ||
65 | print '"%s" not found' % key | ||
66 | sys.exit (0) | ||
67 | |||
68 | print "source: %s" % auth_data.source | ||
69 | print "user name: %s" % auth_data.name | ||
70 | print "password: %s" % auth_data.passwd | ||
71 | print "uid: %d" % auth_data.uid | ||
72 | print "gid: %d" % auth_data.gid | ||
73 | print "gecos: %s" % auth_data.gecos | ||
74 | print "home: %s" % auth_data.dir | ||
75 | print "shell: %s" % auth_data.shell | ||
76 | print "mailbox: %s" % auth_data.mailbox | ||
77 | print "quota: %d" % auth_data.quota | ||
78 | print "change_uid: %d" % auth_data.change_uid | ||
79 | |||
80 | if not vars ().has_key ('password'): | ||
81 | password = getpass.getpass () | ||
82 | |||
83 | try: | ||
84 | auth.authenticate (auth_data, password) | ||
85 | print 'Authenticated!' | ||
86 | except AuthError, e: | ||
87 | print e |
examples/python/iconv.py
0 → 100644
1 | # GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | # Copyright (C) 2009 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License as published by | ||
6 | # the Free Software Foundation; either version 3, or (at your option) | ||
7 | # any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | # GNU General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils; if not, write to the Free Software | ||
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
17 | # MA 02110-1301 USA | ||
18 | |||
19 | import sys | ||
20 | from mailutils import stream | ||
21 | from mailutils import filter | ||
22 | |||
23 | if len (sys.argv) != 3: | ||
24 | print "usage: %s from-code to-code" % sys.argv[0] | ||
25 | sys.exit (0) | ||
26 | |||
27 | sti = stream.StdioStream (sys.stdin) | ||
28 | sti.open () | ||
29 | |||
30 | cvt = filter.FilterIconvStream (sti, sys.argv[1], sys.argv[2]) | ||
31 | cvt.open () | ||
32 | |||
33 | out = stream.StdioStream (sys.stdout, 0) | ||
34 | out.open () | ||
35 | |||
36 | total = 0 | ||
37 | while True: | ||
38 | buf = cvt.read (total) | ||
39 | out.sequential_write (buf) | ||
40 | total += cvt.read_count | ||
41 | if not cvt.read_count: | ||
42 | break | ||
43 | |||
44 | out.flush () | ||
45 | out.close () | ||
46 | sti.close () |
examples/python/lsf.py
0 → 100644
1 | # GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | # Copyright (C) 2009 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License as published by | ||
6 | # the Free Software Foundation; either version 3, or (at your option) | ||
7 | # any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | # GNU General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils; if not, write to the Free Software | ||
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
17 | # MA 02110-1301 USA | ||
18 | |||
19 | import sys | ||
20 | from mailutils import folder | ||
21 | from mailutils import registrar | ||
22 | from mailutils.error import * | ||
23 | |||
24 | def ls_folders (fname, ref, pattern, level): | ||
25 | try: | ||
26 | fld = folder.Folder (fname) | ||
27 | fld.open () | ||
28 | |||
29 | list = fld.list (ref, pattern, level) | ||
30 | for f in list: | ||
31 | print f | ||
32 | print "Number of folders: %d" % len (list) | ||
33 | |||
34 | fld.close () | ||
35 | except Error, e: | ||
36 | print e | ||
37 | |||
38 | if __name__ == '__main__': | ||
39 | pattern = "*" | ||
40 | level = 0 | ||
41 | argc = len (sys.argv) | ||
42 | |||
43 | if argc == 5: | ||
44 | level = int (sys.argv[4]) | ||
45 | pattern = sys.argv[3] | ||
46 | ref = sys.argv[2] | ||
47 | fname = sys.argv[1] | ||
48 | elif argc == 4: | ||
49 | pattern = sys.argv[3] | ||
50 | ref = sys.argv[2] | ||
51 | fname = sys.argv[1] | ||
52 | elif argc == 3: | ||
53 | ref = sys.argv[2] | ||
54 | fname = sys.argv[1] | ||
55 | elif argc == 2: | ||
56 | fname = sys.argv[1] | ||
57 | else: | ||
58 | print "usage: lsf folder [ref] [pattern] [recursion-level]" | ||
59 | sys.exit (0) | ||
60 | |||
61 | registrar.register_format () | ||
62 | ls_folders (fname, ref, pattern, level) |
examples/python/mailcap.py
0 → 100644
1 | # GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | # Copyright (C) 2009 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License as published by | ||
6 | # the Free Software Foundation; either version 3, or (at your option) | ||
7 | # any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | # GNU General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils; if not, write to the Free Software | ||
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
17 | # MA 02110-1301 USA | ||
18 | |||
19 | from mailutils import stream, mailcap | ||
20 | |||
21 | stm = stream.FileStream ("/etc/mailcap") | ||
22 | stm.open () | ||
23 | |||
24 | mc = mailcap.Mailcap (stm) | ||
25 | |||
26 | for i, entry in enumerate (mc): | ||
27 | print "entry[%d]" % (i + 1) | ||
28 | |||
29 | # typefield | ||
30 | print "\ttypefield: %s" % entry.get_typefield () | ||
31 | |||
32 | # view-command | ||
33 | print "\tview-command: %s" % entry.get_viewcommand () | ||
34 | |||
35 | # fields | ||
36 | for j, ent in enumerate (entry): | ||
37 | print "\tfields[%d]: %s" % ((j + 1), ent) | ||
38 | |||
39 |
examples/python/mimetest.py
0 → 100644
1 | # GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | # Copyright (C) 2009 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License as published by | ||
6 | # the Free Software Foundation; either version 3, or (at your option) | ||
7 | # any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | # GNU General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils; if not, write to the Free Software | ||
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
17 | # MA 02110-1301 USA | ||
18 | |||
19 | import sys | ||
20 | import getopt | ||
21 | from mailutils import * | ||
22 | from mailutils.header import * | ||
23 | |||
24 | print_attachments = False | ||
25 | indent_level = 4 | ||
26 | |||
27 | def print_file (fname, indent): | ||
28 | try: | ||
29 | fp = open (fname, 'r') | ||
30 | for line in fp: | ||
31 | print "%*.*s%s" % (indent, indent, '', line) | ||
32 | fp.close () | ||
33 | remove (fname) | ||
34 | except OSError, e: | ||
35 | print e | ||
36 | |||
37 | def print_message_part_sizes (part, indent): | ||
38 | print "%*.*sMessage part size - %d/%d: %d/%d, %d/%d" % \ | ||
39 | (indent, indent, '', | ||
40 | part.size, part.lines, | ||
41 | part.header.size, part.header.lines, | ||
42 | part.body.size, part.body.lines) | ||
43 | |||
44 | def message_display_parts (msg, indent): | ||
45 | # How many parts does the message has? | ||
46 | nparts = msg.get_num_parts () | ||
47 | |||
48 | # Iterate through all the parts. Treat type "message/rfc822" | ||
49 | # differently, since it is a message of its own that can have other | ||
50 | # subparts (recursive). | ||
51 | for j in range (1, nparts + 1): | ||
52 | part = msg.get_part (j) | ||
53 | hdr = part.get_header () | ||
54 | |||
55 | type = hdr.get_value (MU_HEADER_CONTENT_TYPE, 'text/plain') | ||
56 | encoding = hdr.get_value (MU_HEADER_CONTENT_TRANSFER_ENCODING, '7bit') | ||
57 | |||
58 | print "%*.*sType of part %d = %s" % (indent, indent, '', j, type) | ||
59 | print_message_part_sizes (part, indent) | ||
60 | |||
61 | ismulti = part.is_multipart () | ||
62 | if type == "message/rfc822" or ismulti: | ||
63 | if not ismulti: | ||
64 | part = part.unencapsulate () | ||
65 | |||
66 | hdr = part.get_header () | ||
67 | frm = hdr.get_value (MU_HEADER_FROM, "[none]") | ||
68 | subject = hdr.get_value (MU_HEADER_SUBJECT, "[none]") | ||
69 | |||
70 | print "%*.*sEncapsulated message : %s\t%s" % \ | ||
71 | (indent, indent, '', frm, subject) | ||
72 | print "%*.*sBegin" % (indent, indent, '') | ||
73 | |||
74 | nsubparts = part.get_num_parts () | ||
75 | message_display_parts (part, indent + indent_level) | ||
76 | elif (type.startswith ("text/plain") or | ||
77 | type.startswith ("text/html") or type == ''): | ||
78 | print "%*.*sText Message" % (indent, indent, '') | ||
79 | print "%*.*sBegin" % (indent, indent, '') | ||
80 | |||
81 | flt = filter.FilterStream (part.body.get_stream (), encoding) | ||
82 | offset = 0 | ||
83 | |||
84 | while True: | ||
85 | buf = flt.readline (offset) | ||
86 | offset += flt.read_count | ||
87 | if not flt.read_count: | ||
88 | break | ||
89 | print "%*.*s%s" % (indent, indent, '', buf), | ||
90 | else: | ||
91 | # Save the attachements. | ||
92 | try: | ||
93 | fname = part.get_attachment_name () | ||
94 | except: | ||
95 | fname = util.tempname () | ||
96 | |||
97 | print "%*.*sAttachment - saving [%s]" % \ | ||
98 | (indent, indent, '', fname) | ||
99 | print "%*.*sBegin" % (indent, indent, '') | ||
100 | |||
101 | part.save_attachment () | ||
102 | if print_attachments: | ||
103 | print_file (fname, indent) | ||
104 | |||
105 | print "%*.*sEnd" % (indent, indent, '') | ||
106 | |||
107 | |||
108 | if __name__ == '__main__': | ||
109 | optdebug = False | ||
110 | |||
111 | try: | ||
112 | opts, args = getopt.getopt (sys.argv[1:], 'dpi:') | ||
113 | for o, a in opts: | ||
114 | if o == '-d': | ||
115 | optdebug = True | ||
116 | elif o == '-p': | ||
117 | print_attachments = True | ||
118 | elif o == '-i': | ||
119 | indent_level = int (a) | ||
120 | except getopt.GetoptError: | ||
121 | sys.exit (0) | ||
122 | |||
123 | # Registration. | ||
124 | registrar.register_format (('imap', 'pop', 'mbox')) | ||
125 | registrar.set_default_format ('mbox') | ||
126 | |||
127 | if args: | ||
128 | args = args[0] | ||
129 | else: | ||
130 | args = '' | ||
131 | |||
132 | mbox = mailbox.MailboxDefault (args) | ||
133 | |||
134 | # Debugging trace. | ||
135 | if optdebug: | ||
136 | mbox.debug.set_level (debug.MU_DEBUG_PROT) | ||
137 | |||
138 | # Open the mailbox for reading only. | ||
139 | mbox.open () | ||
140 | |||
141 | # Iterate through the entire message set. | ||
142 | for i, msg in enumerate (mbox): | ||
143 | print "Message: %d" % (i + 1) | ||
144 | print "From: %s" % msg.header.get_value (MU_HEADER_FROM, "[none]") | ||
145 | print "Subject: %s" % msg.header.get_value (MU_HEADER_SUBJECT, "[none]") | ||
146 | print "Number of parts in message - %d" % msg.get_num_parts () | ||
147 | print "Total message size - %d/%d" % (msg.size, msg.lines) | ||
148 | |||
149 | try: | ||
150 | message_display_parts (msg, 0) | ||
151 | except Error, e: | ||
152 | print e | ||
153 | |||
154 | mbox.close () |
examples/python/msg-send.py
0 → 100644
1 | # GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | # Copyright (C) 2009 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License as published by | ||
6 | # the Free Software Foundation; either version 3, or (at your option) | ||
7 | # any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | # GNU General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils; if not, write to the Free Software | ||
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
17 | # MA 02110-1301 USA | ||
18 | |||
19 | import sys | ||
20 | import getopt | ||
21 | from mailutils import * | ||
22 | |||
23 | USAGE = "usage: mailer [-hd] [-m mailer] [-f from] [to]..." | ||
24 | HELP = """ | ||
25 | -h print this helpful message | ||
26 | -m a mailer URL (default is \"sendmail:\") | ||
27 | -f the envelope from address (default is from user environment) | ||
28 | to a list of envelope to addresses (default is from message) | ||
29 | |||
30 | An RFC2822 formatted message is read from stdin and delivered using | ||
31 | the mailer.""" | ||
32 | |||
33 | optmailer = "sendmail:" | ||
34 | optfrom = False | ||
35 | optdebug = False | ||
36 | |||
37 | try: | ||
38 | opts, args = getopt.getopt (sys.argv[1:], 'hdm:f:') | ||
39 | for o, a in opts: | ||
40 | if o == '-h': | ||
41 | print USAGE | ||
42 | print HELP | ||
43 | sys.exit (0) | ||
44 | elif o == '-d': | ||
45 | optdebug = True | ||
46 | elif o == '-m': | ||
47 | optmailer = a | ||
48 | elif o == '-f': | ||
49 | optfrom = a | ||
50 | except getopt.GetoptError: | ||
51 | print USAGE | ||
52 | sys.exit (0) | ||
53 | |||
54 | registrar.register_format ('sendmail') | ||
55 | |||
56 | frm = None | ||
57 | to = None | ||
58 | |||
59 | if optfrom: | ||
60 | frm = address.Address (optfrom) | ||
61 | if args: | ||
62 | to = address.Address (args) | ||
63 | |||
64 | sti = stream.StdioStream (sys.stdin, stream.MU_STREAM_SEEKABLE) | ||
65 | sti.open () | ||
66 | |||
67 | msg = message.Message () | ||
68 | msg.set_stream (sti) | ||
69 | |||
70 | mlr = mailer.Mailer (optmailer) | ||
71 | if optdebug: | ||
72 | mlr.debug.set_level (debug.MU_DEBUG_PROT) | ||
73 | |||
74 | mlr.open () | ||
75 | mlr.send_message (msg, frm, to) | ||
76 | mlr.close () |
examples/python/sfrom.py
0 → 100644
1 | # GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | # Copyright (C) 2009 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License as published by | ||
6 | # the Free Software Foundation; either version 3, or (at your option) | ||
7 | # any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | # GNU General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils; if not, write to the Free Software | ||
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
17 | # MA 02110-1301 USA | ||
18 | |||
19 | import sys | ||
20 | from mailutils import * | ||
21 | from mailutils.header import * | ||
22 | |||
23 | args = '' | ||
24 | if len (sys.argv) > 1: | ||
25 | args = sys.argv[1] | ||
26 | |||
27 | registrar.register_format () | ||
28 | |||
29 | mbox = mailbox.MailboxDefault (args) | ||
30 | mbox.open () | ||
31 | |||
32 | print "Total: %d" % len (mbox) | ||
33 | |||
34 | for msg in mbox: | ||
35 | print "%s %s" % (msg.header[MU_HEADER_FROM], | ||
36 | msg.header.get_value (MU_HEADER_SUBJECT, "(NO SUBJECT)")) | ||
37 | |||
38 | mbox.close () |
examples/python/url-parse.py
0 → 100644
1 | # GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | # Copyright (C) 2009 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License as published by | ||
6 | # the Free Software Foundation; either version 3, or (at your option) | ||
7 | # any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | # GNU General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils; if not, write to the Free Software | ||
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
17 | # MA 02110-1301 USA | ||
18 | |||
19 | import sys | ||
20 | from mailutils import url | ||
21 | from mailutils.error import * | ||
22 | |||
23 | def parse (str): | ||
24 | try: | ||
25 | u = url.Url (str) | ||
26 | u.parse () | ||
27 | print "URL: %s" % u | ||
28 | |||
29 | print "\tscheme <%s>" % u.get_scheme () | ||
30 | print "\tuser <%s>" % u.get_user () | ||
31 | print "\tpasswd <%s>" % u.get_passwd () | ||
32 | print "\tauth <%s>" % u.get_auth () | ||
33 | print "\thost <%s>" % u.get_host () | ||
34 | print "\tport %d" % u.get_port () | ||
35 | print "\tpath <%s>" % u.get_path () | ||
36 | |||
37 | for i, param in enumerate (u.get_query ()): | ||
38 | print "\tquery[%d] %s" % (i, param) | ||
39 | |||
40 | except UrlError, e: | ||
41 | print e | ||
42 | |||
43 | def parseinput (): | ||
44 | try: | ||
45 | while True: | ||
46 | line = sys.stdin.readline ().strip () | ||
47 | if line == '': | ||
48 | break | ||
49 | parse (line) | ||
50 | except KeyboardInterrupt: | ||
51 | sys.exit () | ||
52 | |||
53 | if __name__ == '__main__': | ||
54 | if len (sys.argv) == 1: | ||
55 | parseinput () | ||
56 | sys.exit () | ||
57 | |||
58 | for arg in sys.argv[1:]: | ||
59 | if arg == '-': | ||
60 | parseinput () | ||
61 | else: | ||
62 | parse (arg) |
python/Makefile.am
0 → 100644
1 | ## Process this file with GNU Automake to create Makefile.in | ||
2 | |||
3 | ## Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | ## | ||
5 | ## GNU Mailutils is free software; you can redistribute it and/or | ||
6 | ## modify it under the terms of the GNU General Public License as | ||
7 | ## published by the Free Software Foundation; either version 3, or (at | ||
8 | ## your option) any later version. | ||
9 | ## | ||
10 | ## This program is distributed in the hope that it will be useful, but | ||
11 | ## WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | ## General Public License for more details. | ||
14 | ## | ||
15 | ## You should have received a copy of the GNU General Public License | ||
16 | ## along with this program; if not, write to the Free Software | ||
17 | ## Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA | ||
18 | ## 02110-1301 USA | ||
19 | |||
20 | SUBDIRS = c_api mailutils | ||
21 |
python/c_api/Makefile.am
0 → 100644
1 | ## Process this file with GNU Automake to create Makefile.in | ||
2 | |||
3 | ## Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | ## | ||
5 | ## GNU Mailutils is free software; you can redistribute it and/or | ||
6 | ## modify it under the terms of the GNU General Public License as | ||
7 | ## published by the Free Software Foundation; either version 3, or (at | ||
8 | ## your option) any later version. | ||
9 | ## | ||
10 | ## This program is distributed in the hope that it will be useful, but | ||
11 | ## WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | ## General Public License for more details. | ||
14 | ## | ||
15 | ## You should have received a copy of the GNU General Public License | ||
16 | ## along with this program; if not, write to the Free Software | ||
17 | ## Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA | ||
18 | ## 02110-1301 USA | ||
19 | |||
20 | INCLUDES = @MU_COMMON_INCLUDES@ $(PYTHON_INCLUDES) | ||
21 | |||
22 | MU_PYTHON_LTLIBS = c_api.la | ||
23 | EXTRA_LTLIBRARIES = c_api.la | ||
24 | pkgpyexec_LTLIBRARIES = @MU_PYTHON_LTLIBS@ | ||
25 | c_api_la_LDFLAGS = -avoid-version -module -rpath $(pkgpyexecdir) | ||
26 | c_api_la_LIBADD = $(PYTHON_LIBS) @MU_COMMON_LIBRARIES@ \ | ||
27 | ${MU_LIB_MBOX}\ | ||
28 | ${MU_LIB_IMAP}\ | ||
29 | ${MU_LIB_POP}\ | ||
30 | ${MU_LIB_NNTP}\ | ||
31 | ${MU_LIB_MH}\ | ||
32 | ${MU_LIB_MAILDIR}\ | ||
33 | ${MU_LIB_AUTH}\ | ||
34 | ${MU_LIB_MAILER}\ | ||
35 | @MU_AUTHLIBS@\ | ||
36 | ${MU_LIB_MAILUTILS} | ||
37 | |||
38 | c_api_la_SOURCES = \ | ||
39 | c_api.c \ | ||
40 | c_api.h \ | ||
41 | error.c \ | ||
42 | address.c \ | ||
43 | address-private.h \ | ||
44 | attribute.c \ | ||
45 | attribute-private.h \ | ||
46 | auth.c \ | ||
47 | auth-private.h \ | ||
48 | body.c \ | ||
49 | body-private.h \ | ||
50 | debug.c \ | ||
51 | debug-private.h \ | ||
52 | envelope.c \ | ||
53 | envelope-private.h \ | ||
54 | filter.c \ | ||
55 | folder.c \ | ||
56 | folder-private.h \ | ||
57 | list.c \ | ||
58 | list-private.h \ | ||
59 | header.c \ | ||
60 | header-private.h \ | ||
61 | mailer.c \ | ||
62 | mailer-private.h \ | ||
63 | mailbox.c \ | ||
64 | mailbox-private.h \ | ||
65 | mailcap.c \ | ||
66 | mailcap-private.h \ | ||
67 | message.c \ | ||
68 | message-private.h \ | ||
69 | mime.c \ | ||
70 | mime-private.h \ | ||
71 | stream.c \ | ||
72 | stream-private.h \ | ||
73 | registrar.c \ | ||
74 | url.c \ | ||
75 | url-private.h \ | ||
76 | util.c | ||
77 |
python/c_api/address-private.h
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #ifndef _MUCAPI_ADDRESS_H | ||
22 | #define _MUCAPI_ADDRESS_H | ||
23 | |||
24 | #include <mailutils/address.h> | ||
25 | |||
26 | typedef struct { | ||
27 | PyObject_HEAD; | ||
28 | mu_address_t addr; | ||
29 | } PyAddress; | ||
30 | |||
31 | extern PyAddress * PyAddress_NEW (); | ||
32 | extern int PyAddress_Check (PyObject *x); | ||
33 | |||
34 | #endif /* not _MUCAPI_ADDRESS_H */ |
python/c_api/address.c
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #include "c_api.h" | ||
22 | #include "address-private.h" | ||
23 | |||
24 | #define PY_MODULE "address" | ||
25 | #define PY_CSNAME "AddressType" | ||
26 | |||
27 | static PyObject * | ||
28 | _repr (PyObject *self) | ||
29 | { | ||
30 | char buf[80]; | ||
31 | sprintf (buf, "<" PY_MODULE "." PY_CSNAME " instance at %p>", self); | ||
32 | return PyString_FromString (buf); | ||
33 | } | ||
34 | |||
35 | static PyTypeObject PyAddressType = { | ||
36 | PyObject_HEAD_INIT(NULL) | ||
37 | 0, /* ob_size */ | ||
38 | PY_MODULE "." PY_CSNAME, /* tp_name */ | ||
39 | sizeof (PyAddress), /* tp_basicsize */ | ||
40 | 0, /* tp_itemsize */ | ||
41 | (destructor)py_dealloc, /* tp_dealloc */ | ||
42 | 0, /* tp_print */ | ||
43 | 0, /* tp_getattr; __getattr__ */ | ||
44 | 0, /* tp_setattr; __setattr__ */ | ||
45 | 0, /* tp_compare; __cmp__ */ | ||
46 | _repr, /* tp_repr; __repr__ */ | ||
47 | 0, /* tp_as_number */ | ||
48 | 0, /* tp_as_sequence */ | ||
49 | 0, /* tp_as_mapping */ | ||
50 | 0, /* tp_hash; __hash__ */ | ||
51 | 0, /* tp_call; __call__ */ | ||
52 | _repr, /* tp_str; __str__ */ | ||
53 | 0, /* tp_getattro */ | ||
54 | 0, /* tp_setattro */ | ||
55 | 0, /* tp_as_buffer */ | ||
56 | Py_TPFLAGS_DEFAULT, /* tp_flags */ | ||
57 | "", /* tp_doc */ | ||
58 | 0, /* tp_traverse */ | ||
59 | 0, /* tp_clear */ | ||
60 | 0, /* tp_richcompare */ | ||
61 | 0, /* tp_weaklistoffset */ | ||
62 | 0, /* tp_iter */ | ||
63 | 0, /* tp_iternext */ | ||
64 | 0, /* tp_methods */ | ||
65 | 0, /* tp_members */ | ||
66 | 0, /* tp_getset */ | ||
67 | 0, /* tp_base */ | ||
68 | 0, /* tp_dict */ | ||
69 | 0, /* tp_descr_get */ | ||
70 | 0, /* tp_descr_set */ | ||
71 | 0, /* tp_dictoffset */ | ||
72 | 0, /* tp_init */ | ||
73 | 0, /* tp_alloc */ | ||
74 | 0, /* tp_new */ | ||
75 | }; | ||
76 | |||
77 | PyAddress * | ||
78 | PyAddress_NEW () | ||
79 | { | ||
80 | return (PyAddress *)PyObject_NEW (PyAddress, &PyAddressType); | ||
81 | } | ||
82 | |||
83 | int | ||
84 | PyAddress_Check (PyObject *x) | ||
85 | { | ||
86 | return x->ob_type == &PyAddressType; | ||
87 | } | ||
88 | |||
89 | static PyObject * | ||
90 | api_address_create (PyObject *self, PyObject *args) | ||
91 | { | ||
92 | int status; | ||
93 | char *str; | ||
94 | PyAddress *py_addr; | ||
95 | |||
96 | if (!PyArg_ParseTuple (args, "O!s", &PyAddressType, &py_addr, &str)) | ||
97 | return NULL; | ||
98 | |||
99 | status = mu_address_create (&py_addr->addr, str); | ||
100 | return _ro (PyInt_FromLong (status)); | ||
101 | } | ||
102 | |||
103 | static PyObject * | ||
104 | api_address_createv (PyObject *self, PyObject *args) | ||
105 | { | ||
106 | int status; | ||
107 | char *str; | ||
108 | PyAddress *py_addr; | ||
109 | PyObject *py_seq; | ||
110 | char **sv; | ||
111 | size_t len; | ||
112 | |||
113 | if (!PyArg_ParseTuple (args, "O!O", &PyAddressType, &py_addr, &py_seq)) | ||
114 | return NULL; | ||
115 | |||
116 | if (!PySequence_Check (py_seq)) | ||
117 | { | ||
118 | PyErr_SetString (PyExc_TypeError, ""); | ||
119 | return NULL; | ||
120 | } | ||
121 | |||
122 | len = PySequence_Size (py_seq); | ||
123 | sv = (char **) malloc ((len + 1) * sizeof (char *)); | ||
124 | if (!sv) | ||
125 | { | ||
126 | PyErr_NoMemory (); | ||
127 | return NULL; | ||
128 | } | ||
129 | else | ||
130 | { | ||
131 | PyObject *py_item; | ||
132 | int i; | ||
133 | |||
134 | for (i = 0; i < len; i++) { | ||
135 | py_item = PySequence_GetItem (py_seq, i); | ||
136 | if (py_item && PyString_Check (py_item)) | ||
137 | sv[i] = strdup (PyString_AsString (py_item)); | ||
138 | Py_DECREF (py_item); | ||
139 | } | ||
140 | if (PyErr_Occurred ()) { | ||
141 | PyErr_Print (); | ||
142 | return NULL; | ||
143 | } | ||
144 | } | ||
145 | status = mu_address_createv (&py_addr->addr, (const char**)sv, len); | ||
146 | return _ro (PyInt_FromLong (status)); | ||
147 | } | ||
148 | |||
149 | static PyObject * | ||
150 | api_address_destroy (PyObject *self, PyObject *args) | ||
151 | { | ||
152 | PyAddress *py_addr; | ||
153 | |||
154 | if (!PyArg_ParseTuple (args, "O!", &PyAddressType, &py_addr)) | ||
155 | return NULL; | ||
156 | |||
157 | mu_address_destroy (&py_addr->addr); | ||
158 | return _ro (Py_None); | ||
159 | } | ||
160 | |||
161 | static PyObject * | ||
162 | api_address_is_group (PyObject *self, PyObject *args) | ||
163 | { | ||
164 | int status, n, isgroup; | ||
165 | PyAddress *py_addr; | ||
166 | |||
167 | if (!PyArg_ParseTuple (args, "O!i", &PyAddressType, &py_addr, &n)) | ||
168 | return NULL; | ||
169 | |||
170 | status = mu_address_is_group (py_addr->addr, n, &isgroup); | ||
171 | return status_object (status, PyBool_FromLong (isgroup)); | ||
172 | } | ||
173 | |||
174 | static PyObject * | ||
175 | api_address_get_count (PyObject *self, PyObject *args) | ||
176 | { | ||
177 | size_t count = 0; | ||
178 | PyAddress *py_addr; | ||
179 | |||
180 | if (!PyArg_ParseTuple (args, "O!", &PyAddressType, &py_addr)) | ||
181 | return NULL; | ||
182 | |||
183 | mu_address_get_count (py_addr->addr, &count); | ||
184 | return _ro (PyInt_FromLong (count)); | ||
185 | } | ||
186 | |||
187 | static PyObject * | ||
188 | api_address_get_email (PyObject *self, PyObject *args) | ||
189 | { | ||
190 | int status, n; | ||
191 | const char *buf = NULL; | ||
192 | PyAddress *py_addr; | ||
193 | |||
194 | if (!PyArg_ParseTuple (args, "O!i", &PyAddressType, &py_addr, &n)) | ||
195 | return NULL; | ||
196 | |||
197 | status = mu_address_sget_email (py_addr->addr, n, &buf); | ||
198 | return status_object (status, PyString_FromString (buf ? buf : "")); | ||
199 | } | ||
200 | |||
201 | static PyObject * | ||
202 | api_address_get_local_part (PyObject *self, PyObject *args) | ||
203 | { | ||
204 | int status, n; | ||
205 | const char *buf = NULL; | ||
206 | PyAddress *py_addr; | ||
207 | |||
208 | if (!PyArg_ParseTuple (args, "O!i", &PyAddressType, &py_addr, &n)) | ||
209 | return NULL; | ||
210 | |||
211 | status = mu_address_sget_local_part (py_addr->addr, n, &buf); | ||
212 | return status_object (status, PyString_FromString (buf ? buf : "")); | ||
213 | } | ||
214 | |||
215 | static PyObject * | ||
216 | api_address_get_domain (PyObject *self, PyObject *args) | ||
217 | { | ||
218 | int status, n; | ||
219 | const char *buf = NULL; | ||
220 | PyAddress *py_addr; | ||
221 | |||
222 | if (!PyArg_ParseTuple (args, "O!i", &PyAddressType, &py_addr, &n)) | ||
223 | return NULL; | ||
224 | |||
225 | status = mu_address_sget_domain (py_addr->addr, n, &buf); | ||
226 | return status_object (status, PyString_FromString (buf ? buf : "")); | ||
227 | } | ||
228 | |||
229 | static PyObject * | ||
230 | api_address_get_personal (PyObject *self, PyObject *args) | ||
231 | { | ||
232 | int status, n; | ||
233 | const char *buf = NULL; | ||
234 | PyAddress *py_addr; | ||
235 | |||
236 | if (!PyArg_ParseTuple (args, "O!i", &PyAddressType, &py_addr, &n)) | ||
237 | return NULL; | ||
238 | |||
239 | status = mu_address_sget_personal (py_addr->addr, n, &buf); | ||
240 | return status_object (status, PyString_FromString (buf ? buf : "")); | ||
241 | } | ||
242 | |||
243 | static PyObject * | ||
244 | api_address_get_comments (PyObject *self, PyObject *args) | ||
245 | { | ||
246 | int status, n; | ||
247 | const char *buf = NULL; | ||
248 | PyAddress *py_addr; | ||
249 | |||
250 | if (!PyArg_ParseTuple (args, "O!i", &PyAddressType, &py_addr, &n)) | ||
251 | return NULL; | ||
252 | |||
253 | status = mu_address_sget_comments (py_addr->addr, n, &buf); | ||
254 | return status_object (status, PyString_FromString (buf ? buf : "")); | ||
255 | } | ||
256 | |||
257 | static PyObject * | ||
258 | api_address_get_route (PyObject *self, PyObject *args) | ||
259 | { | ||
260 | int status, n; | ||
261 | const char *buf = NULL; | ||
262 | PyAddress *py_addr; | ||
263 | |||
264 | if (!PyArg_ParseTuple (args, "O!i", &PyAddressType, &py_addr, &n)) | ||
265 | return NULL; | ||
266 | |||
267 | status = mu_address_sget_route (py_addr->addr, n, &buf); | ||
268 | return status_object (status, PyString_FromString (buf ? buf : "")); | ||
269 | } | ||
270 | |||
271 | static PyObject * | ||
272 | api_address_to_string (PyObject *self, PyObject *args) | ||
273 | { | ||
274 | int status, n; | ||
275 | char buf[256]; | ||
276 | PyAddress *py_addr; | ||
277 | |||
278 | memset (buf, 0, sizeof (buf)); | ||
279 | |||
280 | if (!PyArg_ParseTuple (args, "O!", &PyAddressType, &py_addr)) | ||
281 | return NULL; | ||
282 | |||
283 | status = mu_address_to_string (py_addr->addr, buf, sizeof (buf), &n); | ||
284 | return status_object (status, PyString_FromString (buf)); | ||
285 | } | ||
286 | |||
287 | static PyMethodDef methods[] = { | ||
288 | { "create", (PyCFunction) api_address_create, METH_VARARGS, | ||
289 | "Allocate and initialize ADDR by parsing the RFC822 " | ||
290 | "address-list STRING." }, | ||
291 | |||
292 | { "createv", (PyCFunction) api_address_createv, METH_VARARGS, | ||
293 | "Allocate and initialize ADDR by parsing the RFC822 address-list." }, | ||
294 | |||
295 | { "destroy", (PyCFunction) api_address_destroy, METH_VARARGS, | ||
296 | "Destroy ADDR." }, | ||
297 | |||
298 | { "is_group", (PyCFunction) api_address_is_group, METH_VARARGS, | ||
299 | "Return True if address is just the name of a group, False otherwise." }, | ||
300 | |||
301 | { "get_count", (PyCFunction) api_address_get_count, METH_VARARGS, | ||
302 | "Return a count of the addresses in the address list." }, | ||
303 | |||
304 | { "get_email", (PyCFunction) api_address_get_email, METH_VARARGS, | ||
305 | "Return the Nth email address component of the address list." }, | ||
306 | |||
307 | { "get_local_part", (PyCFunction) api_address_get_local_part, METH_VARARGS, | ||
308 | "Return local part of the Nth email address from the address list." }, | ||
309 | |||
310 | { "get_domain", (PyCFunction) api_address_get_domain, METH_VARARGS, | ||
311 | "Return domain part of the Nth email address from the address list." }, | ||
312 | |||
313 | { "get_personal", (PyCFunction) api_address_get_personal, METH_VARARGS, | ||
314 | "Return personal part of the Nth email address from the address list." }, | ||
315 | |||
316 | { "get_comments", (PyCFunction) api_address_get_comments, METH_VARARGS, | ||
317 | "Return comment part of the Nth email address from the list." }, | ||
318 | |||
319 | { "get_route", (PyCFunction) api_address_get_route, METH_VARARGS, | ||
320 | "Return route part of the Nth email address from the list." }, | ||
321 | |||
322 | { "to_string", (PyCFunction) api_address_to_string, METH_VARARGS, | ||
323 | "Return the entire address list as a single RFC822 formatted address list." }, | ||
324 | |||
325 | { NULL, NULL, 0, NULL } | ||
326 | }; | ||
327 | |||
328 | void | ||
329 | init_address () | ||
330 | { | ||
331 | PyObject *m; | ||
332 | |||
333 | PyAddressType.tp_new = PyType_GenericNew; | ||
334 | if (PyType_Ready (&PyAddressType) < 0) | ||
335 | return; | ||
336 | |||
337 | if ((m = attach_module (PY_MODULE, methods))) | ||
338 | { | ||
339 | Py_INCREF (&PyAddressType); | ||
340 | PyModule_AddObject (m, PY_CSNAME, (PyObject *)&PyAddressType); | ||
341 | } | ||
342 | } |
python/c_api/attribute-private.h
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #ifndef _MUCAPI_ATTRIBUTE_H | ||
22 | #define _MUCAPI_ATTRIBUTE_H | ||
23 | |||
24 | #include <mailutils/attribute.h> | ||
25 | |||
26 | typedef struct { | ||
27 | PyObject_HEAD; | ||
28 | mu_attribute_t attr; | ||
29 | } PyAttribute; | ||
30 | |||
31 | extern PyAttribute * PyAttribute_NEW (); | ||
32 | |||
33 | #endif /* not _MUCAPI_ATTRIBUTE_H */ |
python/c_api/attribute.c
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #include "c_api.h" | ||
22 | #include "attribute-private.h" | ||
23 | |||
24 | #define PY_MODULE "attribute" | ||
25 | #define PY_CSNAME "AttributeType" | ||
26 | |||
27 | static PyObject * | ||
28 | _repr (PyObject *self) | ||
29 | { | ||
30 | char buf[80]; | ||
31 | sprintf (buf, "<" PY_MODULE "." PY_CSNAME " instance at %p>", self); | ||
32 | return PyString_FromString (buf); | ||
33 | } | ||
34 | |||
35 | static PyTypeObject PyAttributeType = { | ||
36 | PyObject_HEAD_INIT(NULL) | ||
37 | 0, /* ob_size */ | ||
38 | PY_MODULE "." PY_CSNAME, /* tp_name */ | ||
39 | sizeof (PyAttribute), /* tp_basicsize */ | ||
40 | 0, /* tp_itemsize */ | ||
41 | (destructor)py_dealloc, /* tp_dealloc */ | ||
42 | 0, /* tp_print */ | ||
43 | 0, /* tp_getattr; __getattr__ */ | ||
44 | 0, /* tp_setattr; __setattr__ */ | ||
45 | 0, /* tp_compare; __cmp__ */ | ||
46 | _repr, /* tp_repr; __repr__ */ | ||
47 | 0, /* tp_as_number */ | ||
48 | 0, /* tp_as_sequence */ | ||
49 | 0, /* tp_as_mapping */ | ||
50 | 0, /* tp_hash; __hash__ */ | ||
51 | 0, /* tp_call; __call__ */ | ||
52 | _repr, /* tp_str; __str__ */ | ||
53 | 0, /* tp_getattro */ | ||
54 | 0, /* tp_setattro */ | ||
55 | 0, /* tp_as_buffer */ | ||
56 | Py_TPFLAGS_DEFAULT, /* tp_flags */ | ||
57 | "", /* tp_doc */ | ||
58 | 0, /* tp_traverse */ | ||
59 | 0, /* tp_clear */ | ||
60 | 0, /* tp_richcompare */ | ||
61 | 0, /* tp_weaklistoffset */ | ||
62 | 0, /* tp_iter */ | ||
63 | 0, /* tp_iternext */ | ||
64 | 0, /* tp_methods */ | ||
65 | 0, /* tp_members */ | ||
66 | 0, /* tp_getset */ | ||
67 | 0, /* tp_base */ | ||
68 | 0, /* tp_dict */ | ||
69 | 0, /* tp_descr_get */ | ||
70 | 0, /* tp_descr_set */ | ||
71 | 0, /* tp_dictoffset */ | ||
72 | 0, /* tp_init */ | ||
73 | 0, /* tp_alloc */ | ||
74 | 0, /* tp_new */ | ||
75 | }; | ||
76 | |||
77 | PyAttribute * | ||
78 | PyAttribute_NEW () | ||
79 | { | ||
80 | return (PyAttribute *)PyObject_NEW (PyAttribute, &PyAttributeType); | ||
81 | } | ||
82 | |||
83 | static PyObject * | ||
84 | api_attribute_create (PyObject *self, PyObject *args) | ||
85 | { | ||
86 | int status; | ||
87 | PyAttribute *py_attr; | ||
88 | |||
89 | if (!PyArg_ParseTuple (args, "O!", &PyAttributeType, &py_attr)) | ||
90 | return NULL; | ||
91 | |||
92 | status = mu_attribute_create (&py_attr->attr, NULL); | ||
93 | return _ro (PyInt_FromLong (status)); | ||
94 | } | ||
95 | |||
96 | static PyObject * | ||
97 | api_attribute_destroy (PyObject *self, PyObject *args) | ||
98 | { | ||
99 | PyAttribute *py_attr; | ||
100 | |||
101 | if (!PyArg_ParseTuple (args, "O!", &PyAttributeType, &py_attr)) | ||
102 | return NULL; | ||
103 | |||
104 | mu_attribute_destroy (&py_attr->attr, NULL); | ||
105 | return _ro (Py_None); | ||
106 | } | ||
107 | |||
108 | static PyObject * | ||
109 | api_attribute_is_modified (PyObject *self, PyObject *args) | ||
110 | { | ||
111 | int state; | ||
112 | PyAttribute *py_attr; | ||
113 | |||
114 | if (!PyArg_ParseTuple (args, "O!", &PyAttributeType, &py_attr)) | ||
115 | return NULL; | ||
116 | |||
117 | state = mu_attribute_is_modified (py_attr->attr); | ||
118 | return _ro (PyBool_FromLong (state)); | ||
119 | } | ||
120 | |||
121 | static PyObject * | ||
122 | api_attribute_clear_modified (PyObject *self, PyObject *args) | ||
123 | { | ||
124 | PyAttribute *py_attr; | ||
125 | |||
126 | if (!PyArg_ParseTuple (args, "O!", &PyAttributeType, &py_attr)) | ||
127 | return NULL; | ||
128 | |||
129 | mu_attribute_clear_modified (py_attr->attr); | ||
130 | return _ro (Py_None); | ||
131 | } | ||
132 | |||
133 | static PyObject * | ||
134 | api_attribute_set_modified (PyObject *self, PyObject *args) | ||
135 | { | ||
136 | PyAttribute *py_attr; | ||
137 | |||
138 | if (!PyArg_ParseTuple (args, "O!", &PyAttributeType, &py_attr)) | ||
139 | return NULL; | ||
140 | |||
141 | mu_attribute_set_modified (py_attr->attr); | ||
142 | return _ro (Py_None); | ||
143 | } | ||
144 | |||
145 | static PyObject * | ||
146 | api_attribute_get_flags (PyObject *self, PyObject *args) | ||
147 | { | ||
148 | int status, flags = 0; | ||
149 | PyAttribute *py_attr; | ||
150 | |||
151 | if (!PyArg_ParseTuple (args, "O!", &PyAttributeType, &py_attr)) | ||
152 | return NULL; | ||
153 | |||
154 | status = mu_attribute_get_flags (py_attr->attr, &flags); | ||
155 | return status_object (status, PyInt_FromLong (flags)); | ||
156 | } | ||
157 | |||
158 | static PyObject * | ||
159 | api_attribute_set_flags (PyObject *self, PyObject *args) | ||
160 | { | ||
161 | int status, flags; | ||
162 | PyAttribute *py_attr; | ||
163 | |||
164 | if (!PyArg_ParseTuple (args, "O!i", &PyAttributeType, &py_attr, &flags)) | ||
165 | return NULL; | ||
166 | |||
167 | status = mu_attribute_set_flags (py_attr->attr, flags); | ||
168 | return _ro (PyInt_FromLong (status)); | ||
169 | } | ||
170 | |||
171 | static PyObject * | ||
172 | api_attribute_unset_flags (PyObject *self, PyObject *args) | ||
173 | { | ||
174 | int status, flags; | ||
175 | PyAttribute *py_attr; | ||
176 | |||
177 | if (!PyArg_ParseTuple (args, "O!i", &PyAttributeType, &py_attr, &flags)) | ||
178 | return NULL; | ||
179 | |||
180 | status = mu_attribute_unset_flags (py_attr->attr, flags); | ||
181 | return _ro (PyInt_FromLong (status)); | ||
182 | } | ||
183 | |||
184 | static PyObject * | ||
185 | api_attribute_to_string (PyObject *self, PyObject *args) | ||
186 | { | ||
187 | char buf[MU_STATUS_BUF_SIZE]; | ||
188 | size_t na = 0; | ||
189 | PyAttribute *py_attr; | ||
190 | |||
191 | memset (buf, 0, sizeof (buf)); | ||
192 | |||
193 | if (!PyArg_ParseTuple (args, "O!", &PyAttributeType, &py_attr)) | ||
194 | return NULL; | ||
195 | |||
196 | mu_attribute_to_string (py_attr->attr, buf, sizeof (buf), &na); | ||
197 | return _ro (PyString_FromString (buf)); | ||
198 | } | ||
199 | |||
200 | static PyMethodDef methods[] = { | ||
201 | { "create", (PyCFunction) api_attribute_create, METH_VARARGS, | ||
202 | "" }, | ||
203 | |||
204 | { "destroy", (PyCFunction) api_attribute_destroy, METH_VARARGS, | ||
205 | "" }, | ||
206 | |||
207 | { "is_modified", (PyCFunction) api_attribute_is_modified, METH_VARARGS, | ||
208 | "Return TRUE or FALSE whether attribute has been modified." }, | ||
209 | |||
210 | { "clear_modified", (PyCFunction) api_attribute_clear_modified, | ||
211 | METH_VARARGS, "" }, | ||
212 | |||
213 | { "set_modified", (PyCFunction) api_attribute_set_modified, METH_VARARGS, | ||
214 | "" }, | ||
215 | |||
216 | { "get_flags", (PyCFunction) api_attribute_get_flags, METH_VARARGS, | ||
217 | "" }, | ||
218 | |||
219 | { "set_flags", (PyCFunction) api_attribute_set_flags, METH_VARARGS, | ||
220 | "" }, | ||
221 | |||
222 | { "unset_flags", (PyCFunction) api_attribute_unset_flags, METH_VARARGS, | ||
223 | "" }, | ||
224 | |||
225 | { "to_string", (PyCFunction) api_attribute_to_string, METH_VARARGS, | ||
226 | "" }, | ||
227 | |||
228 | { NULL, NULL, 0, NULL } | ||
229 | }; | ||
230 | |||
231 | void | ||
232 | init_attribute () | ||
233 | { | ||
234 | PyObject *m; | ||
235 | |||
236 | PyAttributeType.tp_new = PyType_GenericNew; | ||
237 | if (PyType_Ready (&PyAttributeType) < 0) | ||
238 | return; | ||
239 | |||
240 | if ((m = attach_module (PY_MODULE, methods))) | ||
241 | { | ||
242 | Py_INCREF (&PyAttributeType); | ||
243 | PyModule_AddObject (m, PY_CSNAME, (PyObject *)&PyAttributeType); | ||
244 | } | ||
245 | } |
python/c_api/auth-private.h
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #ifndef _MUCAPI_AUTH_H | ||
22 | #define _MUCAPI_AUTH_H | ||
23 | |||
24 | #include <mailutils/auth.h> | ||
25 | #include <mailutils/mu_auth.h> | ||
26 | |||
27 | typedef struct { | ||
28 | PyObject_HEAD; | ||
29 | mu_authority_t auth; | ||
30 | } PyAuthority; | ||
31 | |||
32 | typedef struct { | ||
33 | PyObject_HEAD; | ||
34 | mu_ticket_t ticket; | ||
35 | } PyTicket; | ||
36 | |||
37 | typedef struct { | ||
38 | PyObject_HEAD; | ||
39 | mu_wicket_t wicket; | ||
40 | } PyWicket; | ||
41 | |||
42 | typedef struct { | ||
43 | PyObject_HEAD; | ||
44 | struct mu_auth_data *auth_data; | ||
45 | } PyAuthData; | ||
46 | |||
47 | extern PyAuthority * PyAuthority_NEW (); | ||
48 | extern int PyAuthority_Check (PyObject *x); | ||
49 | |||
50 | extern PyTicket * PyTicket_NEW (); | ||
51 | extern int PyTicket_Check (PyObject *x); | ||
52 | |||
53 | extern PyWicket * PyWicket_NEW (); | ||
54 | extern int PyWicket_Check (PyObject *x); | ||
55 | |||
56 | extern PyAuthData * PyAuthData_NEW (); | ||
57 | extern int PyAuthData_Check (PyObject *x); | ||
58 | |||
59 | #endif /* not _MUCAPI_AUTH_H */ |
python/c_api/auth.c
0 → 100644
This diff is collapsed.
Click to expand it.
python/c_api/body-private.h
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #ifndef _MUCAPI_BODY_H | ||
22 | #define _MUCAPI_BODY_H | ||
23 | |||
24 | #include <mailutils/body.h> | ||
25 | |||
26 | typedef struct { | ||
27 | PyObject_HEAD; | ||
28 | mu_body_t body; | ||
29 | } PyBody; | ||
30 | |||
31 | extern PyBody * PyBody_NEW (); | ||
32 | |||
33 | #endif /* not _MUCAPI_BODY_H */ |
python/c_api/body.c
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #include "c_api.h" | ||
22 | #include "body-private.h" | ||
23 | #include "stream-private.h" | ||
24 | |||
25 | #define PY_MODULE "body" | ||
26 | #define PY_CSNAME "BodyType" | ||
27 | |||
28 | static PyObject * | ||
29 | _repr (PyObject *self) | ||
30 | { | ||
31 | char buf[80]; | ||
32 | sprintf (buf, "<" PY_MODULE "." PY_CSNAME " instance at %p>", self); | ||
33 | return PyString_FromString (buf); | ||
34 | } | ||
35 | |||
36 | static PyTypeObject PyBodyType = { | ||
37 | PyObject_HEAD_INIT(NULL) | ||
38 | 0, /* ob_size */ | ||
39 | PY_MODULE "." PY_CSNAME, /* tp_name */ | ||
40 | sizeof (PyBody), /* tp_basicsize */ | ||
41 | 0, /* tp_itemsize */ | ||
42 | (destructor)py_dealloc, /* tp_dealloc */ | ||
43 | 0, /* tp_print */ | ||
44 | 0, /* tp_getattr; __getattr__ */ | ||
45 | 0, /* tp_setattr; __setattr__ */ | ||
46 | 0, /* tp_compare; __cmp__ */ | ||
47 | _repr, /* tp_repr; __repr__ */ | ||
48 | 0, /* tp_as_number */ | ||
49 | 0, /* tp_as_sequence */ | ||
50 | 0, /* tp_as_mapping */ | ||
51 | 0, /* tp_hash; __hash__ */ | ||
52 | 0, /* tp_call; __call__ */ | ||
53 | _repr, /* tp_str; __str__ */ | ||
54 | 0, /* tp_getattro */ | ||
55 | 0, /* tp_setattro */ | ||
56 | 0, /* tp_as_buffer */ | ||
57 | Py_TPFLAGS_DEFAULT, /* tp_flags */ | ||
58 | "", /* tp_doc */ | ||
59 | 0, /* tp_traverse */ | ||
60 | 0, /* tp_clear */ | ||
61 | 0, /* tp_richcompare */ | ||
62 | 0, /* tp_weaklistoffset */ | ||
63 | 0, /* tp_iter */ | ||
64 | 0, /* tp_iternext */ | ||
65 | 0, /* tp_methods */ | ||
66 | 0, /* tp_members */ | ||
67 | 0, /* tp_getset */ | ||
68 | 0, /* tp_base */ | ||
69 | 0, /* tp_dict */ | ||
70 | 0, /* tp_descr_get */ | ||
71 | 0, /* tp_descr_set */ | ||
72 | 0, /* tp_dictoffset */ | ||
73 | 0, /* tp_init */ | ||
74 | 0, /* tp_alloc */ | ||
75 | 0, /* tp_new */ | ||
76 | }; | ||
77 | |||
78 | PyBody * | ||
79 | PyBody_NEW () | ||
80 | { | ||
81 | return (PyBody *)PyObject_NEW (PyBody, &PyBodyType); | ||
82 | } | ||
83 | |||
84 | static PyObject * | ||
85 | api_body_size (PyObject *self, PyObject *args) | ||
86 | { | ||
87 | int status; | ||
88 | size_t size; | ||
89 | PyBody *py_body; | ||
90 | |||
91 | if (!PyArg_ParseTuple (args, "O!", &PyBodyType, &py_body)) | ||
92 | return NULL; | ||
93 | |||
94 | status = mu_body_size (py_body->body, &size); | ||
95 | return status_object (status, PyInt_FromLong (size)); | ||
96 | } | ||
97 | |||
98 | static PyObject * | ||
99 | api_body_lines (PyObject *self, PyObject *args) | ||
100 | { | ||
101 | int status; | ||
102 | size_t lines; | ||
103 | PyBody *py_body; | ||
104 | |||
105 | if (!PyArg_ParseTuple (args, "O!", &PyBodyType, &py_body)) | ||
106 | return NULL; | ||
107 | |||
108 | status = mu_body_lines (py_body->body, &lines); | ||
109 | return status_object (status, PyInt_FromLong (lines)); | ||
110 | } | ||
111 | |||
112 | static PyObject * | ||
113 | api_body_get_stream (PyObject *self, PyObject *args) | ||
114 | { | ||
115 | int status; | ||
116 | size_t lines; | ||
117 | PyBody *py_body; | ||
118 | PyStream *py_stm = PyStream_NEW (); | ||
119 | |||
120 | if (!PyArg_ParseTuple (args, "O!", &PyBodyType, &py_body)) | ||
121 | return NULL; | ||
122 | |||
123 | Py_INCREF (py_stm); | ||
124 | |||
125 | status = mu_body_get_stream (py_body->body, &py_stm->stm); | ||
126 | return status_object (status, (PyObject *)py_stm); | ||
127 | } | ||
128 | |||
129 | static PyMethodDef methods[] = { | ||
130 | { "size", (PyCFunction) api_body_size, METH_VARARGS, | ||
131 | "Retrieve BODY size." }, | ||
132 | |||
133 | { "lines", (PyCFunction) api_body_lines, METH_VARARGS, | ||
134 | "Retrieve BODY number of lines." }, | ||
135 | |||
136 | { "get_stream", (PyCFunction) api_body_get_stream, METH_VARARGS, | ||
137 | "" }, | ||
138 | |||
139 | { NULL, NULL, 0, NULL } | ||
140 | }; | ||
141 | |||
142 | void | ||
143 | init_body () | ||
144 | { | ||
145 | PyObject *m; | ||
146 | |||
147 | PyBodyType.tp_new = PyType_GenericNew; | ||
148 | if (PyType_Ready (&PyBodyType) < 0) | ||
149 | return; | ||
150 | |||
151 | if ((m = attach_module (PY_MODULE, methods))) | ||
152 | { | ||
153 | Py_INCREF (&PyBodyType); | ||
154 | PyModule_AddObject (m, PY_CSNAME, (PyObject *)&PyBodyType); | ||
155 | } | ||
156 | } |
python/c_api/c_api.c
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #include "c_api.h" | ||
22 | |||
23 | inline PyObject * | ||
24 | _ro (PyObject *obj) | ||
25 | { | ||
26 | Py_INCREF (obj); | ||
27 | return obj; | ||
28 | } | ||
29 | |||
30 | void | ||
31 | py_dealloc (PyObject *self) | ||
32 | { | ||
33 | self->ob_type->tp_free (self); | ||
34 | } | ||
35 | |||
36 | PyObject * | ||
37 | status_object (int status, PyObject *py_obj) | ||
38 | { | ||
39 | PyObject *py_ret = PyTuple_New (2); | ||
40 | PyTuple_SetItem (py_ret, 0, PyInt_FromLong (status)); | ||
41 | PyTuple_SetItem (py_ret, 1, py_obj); | ||
42 | return _ro (py_ret); | ||
43 | } | ||
44 | |||
45 | static PyMethodDef nomethods[] = { | ||
46 | { NULL, NULL } | ||
47 | }; | ||
48 | |||
49 | static PyObject *package; | ||
50 | static PyObject *all; | ||
51 | |||
52 | PyObject * | ||
53 | attach_module (const char *name, PyMethodDef *methods) | ||
54 | { | ||
55 | PyObject *module, *m; | ||
56 | |||
57 | char ns[64] = PY_PACKAGE_NAME "." PY_ROOT_NAME "."; | ||
58 | strcat (ns, name); | ||
59 | |||
60 | if (!(module = PyImport_AddModule (ns))) | ||
61 | return NULL; | ||
62 | |||
63 | if (PyModule_AddObject (package, name, module)) | ||
64 | return NULL; | ||
65 | |||
66 | Py_INCREF (module); | ||
67 | |||
68 | if (!(m = Py_InitModule (ns, methods))) | ||
69 | return NULL; | ||
70 | |||
71 | PyList_Append (all, PyString_FromString (name)); | ||
72 | return m; | ||
73 | } | ||
74 | |||
75 | PyMODINIT_FUNC | ||
76 | initc_api (void) | ||
77 | { | ||
78 | package = Py_InitModule (PY_ROOT_NAME, nomethods); | ||
79 | if (!package) | ||
80 | return; | ||
81 | |||
82 | PyModule_AddStringConstant (package, "__version__", PY_PACKAGE_VERSION); | ||
83 | if (!PyModule_AddObject (package, "__all__", _ro (PyList_New (0)))) | ||
84 | { | ||
85 | all = PyObject_GetAttrString (package, "__all__"); | ||
86 | if (!all || !PyList_Check (all)) | ||
87 | return; | ||
88 | } | ||
89 | |||
90 | init_error (); | ||
91 | init_address (); | ||
92 | init_attribute (); | ||
93 | init_auth (); | ||
94 | init_body (); | ||
95 | init_debug (); | ||
96 | init_envelope (); | ||
97 | init_header (); | ||
98 | init_filter (); | ||
99 | init_folder (); | ||
100 | init_mailer (); | ||
101 | init_mailbox (); | ||
102 | init_mailcap (); | ||
103 | init_message (); | ||
104 | init_mime (); | ||
105 | init_registrar (); | ||
106 | init_stream (); | ||
107 | init_url (); | ||
108 | init_util (); | ||
109 | } |
python/c_api/c_api.h
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #ifdef HAVE_CONFIG_H | ||
22 | # include <config.h> | ||
23 | #endif | ||
24 | |||
25 | #include <Python.h> | ||
26 | |||
27 | #define PY_PACKAGE_NAME "mailutils" | ||
28 | #define PY_ROOT_NAME "c_api" | ||
29 | #define PY_PACKAGE_VERSION PACKAGE_VERSION | ||
30 | |||
31 | extern inline PyObject * _ro (PyObject *obj); | ||
32 | extern void py_dealloc (PyObject *self); | ||
33 | extern PyObject * status_object (int status, PyObject *py_obj); | ||
34 | extern PyObject * attach_module (const char *name, PyMethodDef *methods); | ||
35 | |||
36 | extern void init_error (); | ||
37 | extern void init_address (); | ||
38 | extern void init_attribute (); | ||
39 | extern void init_auth (); | ||
40 | extern void init_body (); | ||
41 | extern void init_debug (); | ||
42 | extern void init_envelope (); | ||
43 | extern void init_header (); | ||
44 | extern void init_filter (); | ||
45 | extern void init_folder (); | ||
46 | extern void init_mailer (); | ||
47 | extern void init_mailbox (); | ||
48 | extern void init_mailcap (); | ||
49 | extern void init_message (); | ||
50 | extern void init_mime (); | ||
51 | extern void init_registrar (); | ||
52 | extern void init_stream (); | ||
53 | extern void init_url (); | ||
54 | extern void init_util (); |
python/c_api/debug-private.h
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #ifndef _MUCAPI_DEBUG_H | ||
22 | #define _MUCAPI_DEBUG_H | ||
23 | |||
24 | #include <mailutils/debug.h> | ||
25 | |||
26 | typedef struct { | ||
27 | PyObject_HEAD; | ||
28 | mu_debug_t dbg; | ||
29 | } PyDebug; | ||
30 | |||
31 | extern PyDebug * PyDebug_NEW (); | ||
32 | |||
33 | #endif /* not _MUCAPI_DEBUG_H */ |
python/c_api/debug.c
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #include "c_api.h" | ||
22 | #include "debug-private.h" | ||
23 | |||
24 | #define PY_MODULE "debug" | ||
25 | #define PY_CSNAME "DebugType" | ||
26 | |||
27 | static PyObject * | ||
28 | _repr (PyObject *self) | ||
29 | { | ||
30 | char buf[80]; | ||
31 | sprintf (buf, "<" PY_MODULE "." PY_CSNAME " instance at %p>", self); | ||
32 | return PyString_FromString (buf); | ||
33 | } | ||
34 | |||
35 | static PyTypeObject PyDebugType = { | ||
36 | PyObject_HEAD_INIT(NULL) | ||
37 | 0, /* ob_size */ | ||
38 | PY_MODULE "." PY_CSNAME, /* tp_name */ | ||
39 | sizeof (PyDebug), /* tp_basicsize */ | ||
40 | 0, /* tp_itemsize */ | ||
41 | (destructor)py_dealloc, /* tp_dealloc */ | ||
42 | 0, /* tp_print */ | ||
43 | 0, /* tp_getattr; __getattr__ */ | ||
44 | 0, /* tp_setattr; __setattr__ */ | ||
45 | 0, /* tp_compare; __cmp__ */ | ||
46 | _repr, /* tp_repr; __repr__ */ | ||
47 | 0, /* tp_as_number */ | ||
48 | 0, /* tp_as_sequence */ | ||
49 | 0, /* tp_as_mapping */ | ||
50 | 0, /* tp_hash; __hash__ */ | ||
51 | 0, /* tp_call; __call__ */ | ||
52 | _repr, /* tp_str; __str__ */ | ||
53 | 0, /* tp_getattro */ | ||
54 | 0, /* tp_setattro */ | ||
55 | 0, /* tp_as_buffer */ | ||
56 | Py_TPFLAGS_DEFAULT, /* tp_flags */ | ||
57 | "", /* tp_doc */ | ||
58 | 0, /* tp_traverse */ | ||
59 | 0, /* tp_clear */ | ||
60 | 0, /* tp_richcompare */ | ||
61 | 0, /* tp_weaklistoffset */ | ||
62 | 0, /* tp_iter */ | ||
63 | 0, /* tp_iternext */ | ||
64 | 0, /* tp_methods */ | ||
65 | 0, /* tp_members */ | ||
66 | 0, /* tp_getset */ | ||
67 | 0, /* tp_base */ | ||
68 | 0, /* tp_dict */ | ||
69 | 0, /* tp_descr_get */ | ||
70 | 0, /* tp_descr_set */ | ||
71 | 0, /* tp_dictoffset */ | ||
72 | 0, /* tp_init */ | ||
73 | 0, /* tp_alloc */ | ||
74 | 0, /* tp_new */ | ||
75 | }; | ||
76 | |||
77 | PyDebug * | ||
78 | PyDebug_NEW () | ||
79 | { | ||
80 | return (PyDebug *)PyObject_NEW (PyDebug, &PyDebugType); | ||
81 | } | ||
82 | |||
83 | static PyObject * | ||
84 | api_debug_set_level (PyObject *self, PyObject *args) | ||
85 | { | ||
86 | int status, level; | ||
87 | PyDebug *py_dbg; | ||
88 | |||
89 | if (!PyArg_ParseTuple (args, "O!i", &PyDebugType, &py_dbg, &level)) | ||
90 | return NULL; | ||
91 | |||
92 | status = mu_debug_set_level (py_dbg->dbg, | ||
93 | MU_DEBUG_LEVEL_UPTO (level)); | ||
94 | return _ro (PyInt_FromLong (status)); | ||
95 | } | ||
96 | |||
97 | static PyMethodDef methods[] = { | ||
98 | { "set_level", (PyCFunction) api_debug_set_level, METH_VARARGS, | ||
99 | "" }, | ||
100 | |||
101 | { NULL, NULL, 0, NULL } | ||
102 | }; | ||
103 | |||
104 | void | ||
105 | init_debug () | ||
106 | { | ||
107 | PyObject *m; | ||
108 | |||
109 | PyDebugType.tp_new = PyType_GenericNew; | ||
110 | if (PyType_Ready (&PyDebugType) < 0) | ||
111 | return; | ||
112 | |||
113 | if ((m = attach_module (PY_MODULE, methods))) | ||
114 | { | ||
115 | Py_INCREF (&PyDebugType); | ||
116 | PyModule_AddObject (m, PY_CSNAME, (PyObject *)&PyDebugType); | ||
117 | } | ||
118 | } |
python/c_api/envelope-private.h
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #ifndef _MUCAPI_ENVELOPE_H | ||
22 | #define _MUCAPI_ENVELOPE_H | ||
23 | |||
24 | #include <mailutils/envelope.h> | ||
25 | |||
26 | typedef struct { | ||
27 | PyObject_HEAD; | ||
28 | mu_envelope_t env; | ||
29 | } PyEnvelope; | ||
30 | |||
31 | extern PyEnvelope * PyEnvelope_NEW (); | ||
32 | |||
33 | #endif /* not _MUCAPI_ENVELOPE_H */ |
python/c_api/envelope.c
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #include "c_api.h" | ||
22 | #include "envelope-private.h" | ||
23 | |||
24 | #define PY_MODULE "envelope" | ||
25 | #define PY_CSNAME "EnvelopeType" | ||
26 | |||
27 | static PyObject * | ||
28 | _repr (PyObject *self) | ||
29 | { | ||
30 | char buf[80]; | ||
31 | sprintf (buf, "<" PY_MODULE "." PY_CSNAME " instance at %p>", self); | ||
32 | return PyString_FromString (buf); | ||
33 | } | ||
34 | |||
35 | static PyTypeObject PyEnvelopeType = { | ||
36 | PyObject_HEAD_INIT(NULL) | ||
37 | 0, /* ob_size */ | ||
38 | PY_MODULE "." PY_CSNAME, /* tp_name */ | ||
39 | sizeof (PyEnvelope), /* tp_basicsize */ | ||
40 | 0, /* tp_itemsize */ | ||
41 | (destructor)py_dealloc, /* tp_dealloc */ | ||
42 | 0, /* tp_print */ | ||
43 | 0, /* tp_getattr; __getattr__ */ | ||
44 | 0, /* tp_setattr; __setattr__ */ | ||
45 | 0, /* tp_compare; __cmp__ */ | ||
46 | _repr, /* tp_repr; __repr__ */ | ||
47 | 0, /* tp_as_number */ | ||
48 | 0, /* tp_as_sequence */ | ||
49 | 0, /* tp_as_mapping */ | ||
50 | 0, /* tp_hash; __hash__ */ | ||
51 | 0, /* tp_call; __call__ */ | ||
52 | _repr, /* tp_str; __str__ */ | ||
53 | 0, /* tp_getattro */ | ||
54 | 0, /* tp_setattro */ | ||
55 | 0, /* tp_as_buffer */ | ||
56 | Py_TPFLAGS_DEFAULT, /* tp_flags */ | ||
57 | "", /* tp_doc */ | ||
58 | 0, /* tp_traverse */ | ||
59 | 0, /* tp_clear */ | ||
60 | 0, /* tp_richcompare */ | ||
61 | 0, /* tp_weaklistoffset */ | ||
62 | 0, /* tp_iter */ | ||
63 | 0, /* tp_iternext */ | ||
64 | 0, /* tp_methods */ | ||
65 | 0, /* tp_members */ | ||
66 | 0, /* tp_getset */ | ||
67 | 0, /* tp_base */ | ||
68 | 0, /* tp_dict */ | ||
69 | 0, /* tp_descr_get */ | ||
70 | 0, /* tp_descr_set */ | ||
71 | 0, /* tp_dictoffset */ | ||
72 | 0, /* tp_init */ | ||
73 | 0, /* tp_alloc */ | ||
74 | 0, /* tp_new */ | ||
75 | }; | ||
76 | |||
77 | PyEnvelope * | ||
78 | PyEnvelope_NEW () | ||
79 | { | ||
80 | return (PyEnvelope *)PyObject_NEW (PyEnvelope, &PyEnvelopeType); | ||
81 | } | ||
82 | |||
83 | static PyObject * | ||
84 | api_envelope_create (PyObject *self, PyObject *args) | ||
85 | { | ||
86 | int status; | ||
87 | PyEnvelope *py_env; | ||
88 | |||
89 | if (!PyArg_ParseTuple (args, "O!", &PyEnvelopeType, &py_env)) | ||
90 | return NULL; | ||
91 | |||
92 | status = mu_envelope_create (&py_env->env, NULL); | ||
93 | return _ro (PyInt_FromLong (status)); | ||
94 | } | ||
95 | |||
96 | static PyObject * | ||
97 | api_envelope_destroy (PyObject *self, PyObject *args) | ||
98 | { | ||
99 | PyEnvelope *py_env; | ||
100 | |||
101 | if (!PyArg_ParseTuple (args, "O!", &PyEnvelopeType, &py_env)) | ||
102 | return NULL; | ||
103 | |||
104 | mu_envelope_destroy (&py_env->env, NULL); | ||
105 | return _ro (Py_None); | ||
106 | } | ||
107 | |||
108 | static PyObject * | ||
109 | api_envelope_get_sender (PyObject *self, PyObject *args) | ||
110 | { | ||
111 | int status; | ||
112 | const char *sender = NULL; | ||
113 | PyEnvelope *py_env; | ||
114 | |||
115 | if (!PyArg_ParseTuple (args, "O!", &PyEnvelopeType, &py_env)) | ||
116 | return NULL; | ||
117 | |||
118 | status = mu_envelope_sget_sender (py_env->env, &sender); | ||
119 | return status_object (status, PyString_FromString (sender ? sender : "")); | ||
120 | } | ||
121 | |||
122 | static PyObject * | ||
123 | api_envelope_get_date (PyObject *self, PyObject *args) | ||
124 | { | ||
125 | int status; | ||
126 | const char *date = NULL; | ||
127 | PyEnvelope *py_env; | ||
128 | |||
129 | if (!PyArg_ParseTuple (args, "O!", &PyEnvelopeType, &py_env)) | ||
130 | return NULL; | ||
131 | |||
132 | status = mu_envelope_sget_date (py_env->env, &date); | ||
133 | return status_object (status, PyString_FromString (date ? date : "")); | ||
134 | } | ||
135 | |||
136 | static PyMethodDef methods[] = { | ||
137 | { "create", (PyCFunction) api_envelope_create, METH_VARARGS, | ||
138 | "" }, | ||
139 | |||
140 | { "destroy", (PyCFunction) api_envelope_destroy, METH_VARARGS, | ||
141 | "" }, | ||
142 | |||
143 | { "get_sender", (PyCFunction) api_envelope_get_sender, METH_VARARGS, | ||
144 | "Get the address that this message was reportedly received from." }, | ||
145 | |||
146 | { "get_date", (PyCFunction) api_envelope_get_date, METH_VARARGS, | ||
147 | "Get the date that the message was delivered to the mailbox." }, | ||
148 | |||
149 | { NULL, NULL, 0, NULL } | ||
150 | }; | ||
151 | |||
152 | void | ||
153 | init_envelope () | ||
154 | { | ||
155 | PyObject *m; | ||
156 | |||
157 | PyEnvelopeType.tp_new = PyType_GenericNew; | ||
158 | if (PyType_Ready (&PyEnvelopeType) < 0) | ||
159 | return; | ||
160 | |||
161 | if ((m = attach_module (PY_MODULE, methods))) | ||
162 | { | ||
163 | Py_INCREF (&PyEnvelopeType); | ||
164 | PyModule_AddObject (m, PY_CSNAME, (PyObject *)&PyEnvelopeType); | ||
165 | } | ||
166 | } |
python/c_api/error.c
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #include "c_api.h" | ||
22 | |||
23 | #define PY_MODULE "error" | ||
24 | |||
25 | static PyObject * | ||
26 | api_strerror (PyObject *self, PyObject *args) | ||
27 | { | ||
28 | int status; | ||
29 | char *str = NULL; | ||
30 | |||
31 | if (!PyArg_ParseTuple (args, "i", &status)) | ||
32 | return NULL; | ||
33 | |||
34 | str = (char *)mu_strerror (status); | ||
35 | return _ro (PyString_FromString (str)); | ||
36 | } | ||
37 | |||
38 | static PyMethodDef methods[] = { | ||
39 | { "strerror", (PyCFunction) api_strerror, METH_VARARGS, | ||
40 | "Return the error message corresponding to ERR, " | ||
41 | "which must be an integer value." }, | ||
42 | |||
43 | { NULL, NULL, 0, NULL } | ||
44 | }; | ||
45 | |||
46 | void | ||
47 | init_error () | ||
48 | { | ||
49 | attach_module (PY_MODULE, methods); | ||
50 | } |
python/c_api/filter.c
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #include "c_api.h" | ||
22 | #include "stream-private.h" | ||
23 | #include <mailutils/filter.h> | ||
24 | |||
25 | #define PY_MODULE "filter" | ||
26 | |||
27 | static PyObject * | ||
28 | api_filter_create (PyObject *self, PyObject *args) | ||
29 | { | ||
30 | int status, mode, flags; | ||
31 | char *code = NULL; | ||
32 | PyStream *py_stm, *py_transport; | ||
33 | |||
34 | if (!PyArg_ParseTuple (args, "OOsii", | ||
35 | &py_stm, &py_transport, | ||
36 | &code, &mode, &flags)) | ||
37 | return NULL; | ||
38 | |||
39 | if (!PyStream_Check ((PyObject *)py_stm) && | ||
40 | !PyStream_Check ((PyObject *)py_transport)) | ||
41 | { | ||
42 | PyErr_SetString (PyExc_TypeError, ""); | ||
43 | return NULL; | ||
44 | } | ||
45 | |||
46 | status = mu_filter_create (&py_stm->stm, py_transport->stm, | ||
47 | code, mode, flags); | ||
48 | return _ro (PyInt_FromLong (status)); | ||
49 | } | ||
50 | |||
51 | static PyObject * | ||
52 | api_filter_iconv_create (PyObject *self, PyObject *args) | ||
53 | { | ||
54 | int status, flags; | ||
55 | char *fromcode = NULL; | ||
56 | char *tocode = NULL; | ||
57 | PyStream *py_stm, *py_transport; | ||
58 | |||
59 | if (!PyArg_ParseTuple (args, "OOssi", | ||
60 | &py_stm, &py_transport, | ||
61 | &fromcode, &tocode, &flags)) | ||
62 | return NULL; | ||
63 | |||
64 | if (!PyStream_Check ((PyObject *)py_stm) && | ||
65 | !PyStream_Check ((PyObject *)py_transport)) | ||
66 | { | ||
67 | PyErr_SetString (PyExc_TypeError, ""); | ||
68 | return NULL; | ||
69 | } | ||
70 | |||
71 | status = mu_filter_iconv_create (&py_stm->stm, py_transport->stm, | ||
72 | fromcode, tocode, flags, | ||
73 | mu_fallback_none); | ||
74 | return _ro (PyInt_FromLong (status)); | ||
75 | } | ||
76 | |||
77 | static PyMethodDef methods[] = { | ||
78 | { "create", (PyCFunction) api_filter_create, METH_VARARGS, | ||
79 | "" }, | ||
80 | |||
81 | { "iconv_create", (PyCFunction) api_filter_iconv_create, METH_VARARGS, | ||
82 | "" }, | ||
83 | |||
84 | { NULL, NULL, 0, NULL } | ||
85 | }; | ||
86 | |||
87 | void | ||
88 | init_filter () | ||
89 | { | ||
90 | attach_module (PY_MODULE, methods); | ||
91 | } |
python/c_api/folder-private.h
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #ifndef _MUCAPI_FOLDER_H | ||
22 | #define _MUCAPI_FOLDER_H | ||
23 | |||
24 | #include <mailutils/folder.h> | ||
25 | |||
26 | typedef struct { | ||
27 | PyObject_HEAD; | ||
28 | mu_folder_t folder; | ||
29 | } PyFolder; | ||
30 | |||
31 | extern PyFolder * PyFolder_NEW (); | ||
32 | |||
33 | #endif /* not _MUCAPI_FOLDER_H */ |
python/c_api/folder.c
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #include "c_api.h" | ||
22 | #include "folder-private.h" | ||
23 | #include "stream-private.h" | ||
24 | #include "auth-private.h" | ||
25 | #include "url-private.h" | ||
26 | |||
27 | #define PY_MODULE "folder" | ||
28 | #define PY_CSNAME "FolderType" | ||
29 | |||
30 | static PyObject * | ||
31 | _repr (PyObject *self) | ||
32 | { | ||
33 | char buf[80]; | ||
34 | sprintf (buf, "<" PY_MODULE "." PY_CSNAME " instance at %p>", self); | ||
35 | return PyString_FromString (buf); | ||
36 | } | ||
37 | |||
38 | static PyTypeObject PyFolderType = { | ||
39 | PyObject_HEAD_INIT(NULL) | ||
40 | 0, /* ob_size */ | ||
41 | PY_MODULE "." PY_CSNAME, /* tp_name */ | ||
42 | sizeof (PyFolder), /* tp_basicsize */ | ||
43 | 0, /* tp_itemsize */ | ||
44 | (destructor)py_dealloc, /* tp_dealloc */ | ||
45 | 0, /* tp_print */ | ||
46 | 0, /* tp_getattr; __getattr__ */ | ||
47 | 0, /* tp_setattr; __setattr__ */ | ||
48 | 0, /* tp_compare; __cmp__ */ | ||
49 | _repr, /* tp_repr; __repr__ */ | ||
50 | 0, /* tp_as_number */ | ||
51 | 0, /* tp_as_sequence */ | ||
52 | 0, /* tp_as_mapping */ | ||
53 | 0, /* tp_hash; __hash__ */ | ||
54 | 0, /* tp_call; __call__ */ | ||
55 | _repr, /* tp_str; __str__ */ | ||
56 | 0, /* tp_getattro */ | ||
57 | 0, /* tp_setattro */ | ||
58 | 0, /* tp_as_buffer */ | ||
59 | Py_TPFLAGS_DEFAULT, /* tp_flags */ | ||
60 | "", /* tp_doc */ | ||
61 | 0, /* tp_traverse */ | ||
62 | 0, /* tp_clear */ | ||
63 | 0, /* tp_richcompare */ | ||
64 | 0, /* tp_weaklistoffset */ | ||
65 | 0, /* tp_iter */ | ||
66 | 0, /* tp_iternext */ | ||
67 | 0, /* tp_methods */ | ||
68 | 0, /* tp_members */ | ||
69 | 0, /* tp_getset */ | ||
70 | 0, /* tp_base */ | ||
71 | 0, /* tp_dict */ | ||
72 | 0, /* tp_descr_get */ | ||
73 | 0, /* tp_descr_set */ | ||
74 | 0, /* tp_dictoffset */ | ||
75 | 0, /* tp_init */ | ||
76 | 0, /* tp_alloc */ | ||
77 | 0, /* tp_new */ | ||
78 | }; | ||
79 | |||
80 | PyFolder * | ||
81 | PyFolder_NEW () | ||
82 | { | ||
83 | return (PyFolder *)PyObject_NEW (PyFolder, &PyFolderType); | ||
84 | } | ||
85 | |||
86 | static PyObject * | ||
87 | api_folder_create (PyObject *self, PyObject *args) | ||
88 | { | ||
89 | int status; | ||
90 | char *name; | ||
91 | PyFolder *py_folder; | ||
92 | |||
93 | if (!PyArg_ParseTuple (args, "O!s", &PyFolderType, &py_folder, &name)) | ||
94 | return NULL; | ||
95 | |||
96 | status = mu_folder_create (&py_folder->folder, name); | ||
97 | return _ro (PyInt_FromLong (status)); | ||
98 | } | ||
99 | |||
100 | static PyObject * | ||
101 | api_folder_destroy (PyObject *self, PyObject *args) | ||
102 | { | ||
103 | PyFolder *py_folder; | ||
104 | |||
105 | if (!PyArg_ParseTuple (args, "O!", &PyFolderType, &py_folder)) | ||
106 | return NULL; | ||
107 | |||
108 | mu_folder_destroy (&py_folder->folder); | ||
109 | return _ro (Py_None); | ||
110 | } | ||
111 | |||
112 | static PyObject * | ||
113 | api_folder_open (PyObject *self, PyObject *args) | ||
114 | { | ||
115 | int status; | ||
116 | PyFolder *py_folder; | ||
117 | |||
118 | if (!PyArg_ParseTuple (args, "O!", &PyFolderType, &py_folder)) | ||
119 | return NULL; | ||
120 | |||
121 | status = mu_folder_open (py_folder->folder, MU_STREAM_READ); | ||
122 | return _ro (PyInt_FromLong (status)); | ||
123 | } | ||
124 | |||
125 | static PyObject * | ||
126 | api_folder_close (PyObject *self, PyObject *args) | ||
127 | { | ||
128 | int status; | ||
129 | PyFolder *py_folder; | ||
130 | |||
131 | if (!PyArg_ParseTuple (args, "O!", &PyFolderType, &py_folder)) | ||
132 | return NULL; | ||
133 | |||
134 | status = mu_folder_close (py_folder->folder); | ||
135 | return _ro (PyInt_FromLong (status)); | ||
136 | } | ||
137 | |||
138 | static PyObject * | ||
139 | api_folder_get_stream (PyObject *self, PyObject *args) | ||
140 | { | ||
141 | int status; | ||
142 | PyFolder *py_folder; | ||
143 | PyStream *py_stm = PyStream_NEW (); | ||
144 | |||
145 | if (!PyArg_ParseTuple (args, "O!", &PyFolderType, &py_folder)) | ||
146 | return NULL; | ||
147 | |||
148 | Py_INCREF (py_stm); | ||
149 | |||
150 | status = mu_folder_get_stream (py_folder->folder, &py_stm->stm); | ||
151 | return status_object (status, (PyObject *)py_stm); | ||
152 | } | ||
153 | |||
154 | static PyObject * | ||
155 | api_folder_set_stream (PyObject *self, PyObject *args) | ||
156 | { | ||
157 | int status; | ||
158 | PyFolder *py_folder; | ||
159 | PyStream *py_stm; | ||
160 | |||
161 | if (!PyArg_ParseTuple (args, "O!O", &PyFolderType, &py_folder, &py_stm)) | ||
162 | return NULL; | ||
163 | |||
164 | if (!PyStream_Check ((PyObject *)py_stm)) | ||
165 | { | ||
166 | PyErr_SetString (PyExc_TypeError, ""); | ||
167 | return NULL; | ||
168 | } | ||
169 | |||
170 | status = mu_folder_set_stream (py_folder->folder, py_stm->stm); | ||
171 | return _ro (PyInt_FromLong (status)); | ||
172 | } | ||
173 | |||
174 | static PyObject * | ||
175 | api_folder_get_authority (PyObject *self, PyObject *args) | ||
176 | { | ||
177 | int status; | ||
178 | PyFolder *py_folder; | ||
179 | PyAuthority *py_auth = PyAuthority_NEW (); | ||
180 | |||
181 | if (!PyArg_ParseTuple (args, "O!", &PyFolderType, &py_folder)) | ||
182 | return NULL; | ||
183 | |||
184 | Py_INCREF (py_auth); | ||
185 | |||
186 | status = mu_folder_get_authority (py_folder->folder, &py_auth->auth); | ||
187 | return status_object (status, (PyObject *)py_auth); | ||
188 | } | ||
189 | |||
190 | static PyObject * | ||
191 | api_folder_set_authority (PyObject *self, PyObject *args) | ||
192 | { | ||
193 | int status; | ||
194 | PyFolder *py_folder; | ||
195 | PyAuthority *py_auth; | ||
196 | |||
197 | if (!PyArg_ParseTuple (args, "O!O", &PyFolderType, &py_folder, &py_auth)) | ||
198 | return NULL; | ||
199 | |||
200 | if (!PyAuthority_Check ((PyObject *)py_auth)) | ||
201 | { | ||
202 | PyErr_SetString (PyExc_TypeError, ""); | ||
203 | return NULL; | ||
204 | } | ||
205 | |||
206 | status = mu_folder_set_authority (py_folder->folder, py_auth->auth); | ||
207 | return _ro (PyInt_FromLong (status)); | ||
208 | } | ||
209 | |||
210 | static PyObject * | ||
211 | api_folder_get_url (PyObject *self, PyObject *args) | ||
212 | { | ||
213 | int status; | ||
214 | PyFolder *py_folder; | ||
215 | PyUrl *py_url = PyUrl_NEW (); | ||
216 | |||
217 | if (!PyArg_ParseTuple (args, "O!", &PyFolderType, &py_folder)) | ||
218 | return NULL; | ||
219 | |||
220 | Py_INCREF (py_url); | ||
221 | |||
222 | status = mu_folder_get_url (py_folder->folder, &py_url->url); | ||
223 | return status_object (status, (PyObject *)py_url); | ||
224 | } | ||
225 | |||
226 | static int | ||
227 | folderdata_extractor (void *data, PyObject **dst) | ||
228 | { | ||
229 | struct mu_list_response *resp = (struct mu_list_response *)data; | ||
230 | char separator[4]; | ||
231 | |||
232 | char *attr = (resp->type & MU_FOLDER_ATTRIBUTE_DIRECTORY) ? "d" : | ||
233 | (resp->type & MU_FOLDER_ATTRIBUTE_FILE) ? "f" : "-"; | ||
234 | |||
235 | snprintf (separator, sizeof (separator), "%c", resp->separator); | ||
236 | |||
237 | *dst = PyTuple_New (4); | ||
238 | PyTuple_SetItem (*dst, 0, PyString_FromString (attr)); | ||
239 | PyTuple_SetItem (*dst, 1, PyInt_FromLong (resp->level)); | ||
240 | PyTuple_SetItem (*dst, 2, PyString_FromString (separator)); | ||
241 | PyTuple_SetItem (*dst, 3, PyString_FromString (resp->name)); | ||
242 | return 0; | ||
243 | } | ||
244 | |||
245 | static PyObject * | ||
246 | api_folder_list (PyObject *self, PyObject *args) | ||
247 | { | ||
248 | int status = 0; | ||
249 | size_t max_level = 0; | ||
250 | char *dirname, *pattern; | ||
251 | PyFolder *py_folder; | ||
252 | PyObject *py_list; | ||
253 | mu_list_t c_list = NULL; | ||
254 | |||
255 | if (!PyArg_ParseTuple (args, "O!zs|i", &PyFolderType, &py_folder, | ||
256 | &dirname, &pattern, &max_level)) | ||
257 | return NULL; | ||
258 | |||
259 | status = mu_folder_list (py_folder->folder, dirname, pattern, max_level, | ||
260 | &c_list); | ||
261 | |||
262 | if (c_list) | ||
263 | py_list = mulist_to_pylist (c_list, folderdata_extractor); | ||
264 | else | ||
265 | py_list = PyTuple_New (0); | ||
266 | |||
267 | return status_object (status, py_list); | ||
268 | } | ||
269 | |||
270 | static PyMethodDef methods[] = { | ||
271 | { "create", (PyCFunction) api_folder_create, METH_VARARGS, | ||
272 | "" }, | ||
273 | |||
274 | { "destroy", (PyCFunction) api_folder_destroy, METH_VARARGS, | ||
275 | "" }, | ||
276 | |||
277 | { "open", (PyCFunction) api_folder_open, METH_VARARGS, | ||
278 | "" }, | ||
279 | |||
280 | { "close", (PyCFunction) api_folder_close, METH_VARARGS, | ||
281 | "" }, | ||
282 | |||
283 | { "get_stream", (PyCFunction) api_folder_get_stream, METH_VARARGS, | ||
284 | "" }, | ||
285 | |||
286 | { "set_stream", (PyCFunction) api_folder_set_stream, METH_VARARGS, | ||
287 | "" }, | ||
288 | |||
289 | { "get_authority", (PyCFunction) api_folder_get_authority, METH_VARARGS, | ||
290 | "" }, | ||
291 | |||
292 | { "set_authority", (PyCFunction) api_folder_set_authority, METH_VARARGS, | ||
293 | "" }, | ||
294 | |||
295 | { "get_url", (PyCFunction) api_folder_get_url, METH_VARARGS, | ||
296 | "" }, | ||
297 | |||
298 | { "list", (PyCFunction) api_folder_list, METH_VARARGS, | ||
299 | "" }, | ||
300 | |||
301 | { NULL, NULL, 0, NULL } | ||
302 | }; | ||
303 | |||
304 | void | ||
305 | init_folder () | ||
306 | { | ||
307 | PyObject *m; | ||
308 | |||
309 | PyFolderType.tp_new = PyType_GenericNew; | ||
310 | if (PyType_Ready (&PyFolderType) < 0) | ||
311 | return; | ||
312 | |||
313 | if ((m = attach_module (PY_MODULE, methods))) | ||
314 | { | ||
315 | Py_INCREF (&PyFolderType); | ||
316 | PyModule_AddObject (m, PY_CSNAME, (PyObject *)&PyFolderType); | ||
317 | } | ||
318 | } |
python/c_api/header-private.h
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #ifndef _MUCAPI_HEADER_H | ||
22 | #define _MUCAPI_HEADER_H | ||
23 | |||
24 | #include <mailutils/header.h> | ||
25 | |||
26 | typedef struct { | ||
27 | PyObject_HEAD; | ||
28 | mu_header_t hdr; | ||
29 | } PyHeader; | ||
30 | |||
31 | extern PyHeader * PyHeader_NEW (); | ||
32 | |||
33 | #endif /* not _MUCAPI_HEADER_H */ |
python/c_api/header.c
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #include "c_api.h" | ||
22 | #include "header-private.h" | ||
23 | |||
24 | #define PY_MODULE "header" | ||
25 | #define PY_CSNAME "HeaderType" | ||
26 | |||
27 | static PyObject * | ||
28 | _repr (PyObject *self) | ||
29 | { | ||
30 | char buf[80]; | ||
31 | sprintf (buf, "<" PY_MODULE "." PY_CSNAME " instance at %p>", self); | ||
32 | return PyString_FromString (buf); | ||
33 | } | ||
34 | |||
35 | static PyTypeObject PyHeaderType = { | ||
36 | PyObject_HEAD_INIT(NULL) | ||
37 | 0, /* ob_size */ | ||
38 | PY_MODULE "." PY_CSNAME, /* tp_name */ | ||
39 | sizeof (PyHeader), /* tp_basicsize */ | ||
40 | 0, /* tp_itemsize */ | ||
41 | (destructor)py_dealloc, /* tp_dealloc */ | ||
42 | 0, /* tp_print */ | ||
43 | 0, /* tp_getattr; __getattr__ */ | ||
44 | 0, /* tp_setattr; __setattr__ */ | ||
45 | 0, /* tp_compare; __cmp__ */ | ||
46 | _repr, /* tp_repr; __repr__ */ | ||
47 | 0, /* tp_as_number */ | ||
48 | 0, /* tp_as_sequence */ | ||
49 | 0, /* tp_as_mapping */ | ||
50 | 0, /* tp_hash; __hash__ */ | ||
51 | 0, /* tp_call; __call__ */ | ||
52 | _repr, /* tp_str; __str__ */ | ||
53 | 0, /* tp_getattro */ | ||
54 | 0, /* tp_setattro */ | ||
55 | 0, /* tp_as_buffer */ | ||
56 | Py_TPFLAGS_DEFAULT, /* tp_flags */ | ||
57 | "", /* tp_doc */ | ||
58 | 0, /* tp_traverse */ | ||
59 | 0, /* tp_clear */ | ||
60 | 0, /* tp_richcompare */ | ||
61 | 0, /* tp_weaklistoffset */ | ||
62 | 0, /* tp_iter */ | ||
63 | 0, /* tp_iternext */ | ||
64 | 0, /* tp_methods */ | ||
65 | 0, /* tp_members */ | ||
66 | 0, /* tp_getset */ | ||
67 | 0, /* tp_base */ | ||
68 | 0, /* tp_dict */ | ||
69 | 0, /* tp_descr_get */ | ||
70 | 0, /* tp_descr_set */ | ||
71 | 0, /* tp_dictoffset */ | ||
72 | 0, /* tp_init */ | ||
73 | 0, /* tp_alloc */ | ||
74 | 0, /* tp_new */ | ||
75 | }; | ||
76 | |||
77 | PyHeader * | ||
78 | PyHeader_NEW () | ||
79 | { | ||
80 | return (PyHeader *)PyObject_NEW (PyHeader, &PyHeaderType); | ||
81 | } | ||
82 | |||
83 | static PyObject * | ||
84 | api_header_size (PyObject *self, PyObject *args) | ||
85 | { | ||
86 | int status; | ||
87 | size_t size; | ||
88 | PyHeader *py_hdr; | ||
89 | |||
90 | if (!PyArg_ParseTuple (args, "O!", &PyHeaderType, &py_hdr)) | ||
91 | return NULL; | ||
92 | |||
93 | status = mu_header_size (py_hdr->hdr, &size); | ||
94 | return status_object (status, PyInt_FromLong (size)); | ||
95 | } | ||
96 | |||
97 | static PyObject * | ||
98 | api_header_lines (PyObject *self, PyObject *args) | ||
99 | { | ||
100 | int status; | ||
101 | size_t lines; | ||
102 | PyHeader *py_hdr; | ||
103 | |||
104 | if (!PyArg_ParseTuple (args, "O!", &PyHeaderType, &py_hdr)) | ||
105 | return NULL; | ||
106 | |||
107 | status = mu_header_lines (py_hdr->hdr, &lines); | ||
108 | return status_object (status, PyInt_FromLong (lines)); | ||
109 | } | ||
110 | |||
111 | static PyObject * | ||
112 | api_header_get_value (PyObject *self, PyObject *args) | ||
113 | { | ||
114 | int status; | ||
115 | char *name; | ||
116 | const char *value = NULL; | ||
117 | PyHeader *py_hdr; | ||
118 | |||
119 | if (!PyArg_ParseTuple (args, "O!s", &PyHeaderType, &py_hdr, &name)) | ||
120 | return NULL; | ||
121 | |||
122 | status = mu_header_sget_value (py_hdr->hdr, name, &value); | ||
123 | return status_object (status, PyString_FromString (value ? value : "")); | ||
124 | } | ||
125 | |||
126 | static PyObject * | ||
127 | api_header_set_value (PyObject *self, PyObject *args) | ||
128 | { | ||
129 | int status, replace = 1; | ||
130 | char *name, *value; | ||
131 | PyHeader *py_hdr; | ||
132 | |||
133 | if (!PyArg_ParseTuple (args, "O!ss|i", &PyHeaderType, &py_hdr, &name, | ||
134 | &value, &replace)) | ||
135 | return NULL; | ||
136 | |||
137 | status = mu_header_set_value (py_hdr->hdr, name, value, replace); | ||
138 | return _ro (PyInt_FromLong (status)); | ||
139 | } | ||
140 | |||
141 | static PyObject * | ||
142 | api_header_get_field_count (PyObject *self, PyObject *args) | ||
143 | { | ||
144 | int status; | ||
145 | size_t count = 0; | ||
146 | PyHeader *py_hdr; | ||
147 | |||
148 | if (!PyArg_ParseTuple (args, "O!", &PyHeaderType, &py_hdr)) | ||
149 | return NULL; | ||
150 | |||
151 | status = mu_header_get_field_count (py_hdr->hdr, &count); | ||
152 | return status_object (status, PyInt_FromLong (count)); | ||
153 | } | ||
154 | |||
155 | static PyObject * | ||
156 | api_header_get_field_name (PyObject *self, PyObject *args) | ||
157 | { | ||
158 | int status; | ||
159 | size_t idx; | ||
160 | const char *name = NULL; | ||
161 | PyHeader *py_hdr; | ||
162 | |||
163 | if (!PyArg_ParseTuple (args, "O!i", &PyHeaderType, &py_hdr, &idx)) | ||
164 | return NULL; | ||
165 | |||
166 | status = mu_header_sget_field_name (py_hdr->hdr, idx, &name); | ||
167 | return status_object (status, PyString_FromString (name ? name : "")); | ||
168 | } | ||
169 | |||
170 | static PyObject * | ||
171 | api_header_get_field_value (PyObject *self, PyObject *args) | ||
172 | { | ||
173 | int status; | ||
174 | size_t idx; | ||
175 | const char *value = NULL; | ||
176 | PyHeader *py_hdr; | ||
177 | |||
178 | if (!PyArg_ParseTuple (args, "O!i", &PyHeaderType, &py_hdr, &idx)) | ||
179 | return NULL; | ||
180 | |||
181 | status = mu_header_sget_field_value (py_hdr->hdr, idx, &value); | ||
182 | return status_object (status, PyString_FromString (value ? value : "")); | ||
183 | } | ||
184 | |||
185 | static PyMethodDef methods[] = { | ||
186 | { "size", (PyCFunction) api_header_size, METH_VARARGS, | ||
187 | "Retrieve HEADER size." }, | ||
188 | |||
189 | { "lines", (PyCFunction) api_header_lines, METH_VARARGS, | ||
190 | "Retrieve HEADER number of lines." }, | ||
191 | |||
192 | { "get_value", (PyCFunction) api_header_get_value, METH_VARARGS, | ||
193 | "Retrieve header field value." }, | ||
194 | |||
195 | { "set_value", (PyCFunction) api_header_set_value, METH_VARARGS, | ||
196 | "Set header field value." }, | ||
197 | |||
198 | { "get_field_count", (PyCFunction) api_header_get_field_count, METH_VARARGS, | ||
199 | "Retrieve the number of header fields." }, | ||
200 | |||
201 | { "get_field_name", (PyCFunction) api_header_get_field_name, METH_VARARGS, | ||
202 | "Retrieve header field name by field index IDX." }, | ||
203 | |||
204 | { "get_field_value", (PyCFunction) api_header_get_field_value, METH_VARARGS, | ||
205 | "Retrieve header field value by field index IDX." }, | ||
206 | |||
207 | { NULL, NULL, 0, NULL } | ||
208 | }; | ||
209 | |||
210 | void | ||
211 | init_header () | ||
212 | { | ||
213 | PyObject *m; | ||
214 | |||
215 | PyHeaderType.tp_new = PyType_GenericNew; | ||
216 | if (PyType_Ready (&PyHeaderType) < 0) | ||
217 | return; | ||
218 | |||
219 | if ((m = attach_module (PY_MODULE, methods))) | ||
220 | { | ||
221 | Py_INCREF (&PyHeaderType); | ||
222 | PyModule_AddObject (m, PY_CSNAME, (PyObject *)&PyHeaderType); | ||
223 | } | ||
224 | } |
python/c_api/list-private.h
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #ifndef _MUCAPI_LIST_H | ||
22 | #define _MUCAPI_LIST_H | ||
23 | |||
24 | #include <mailutils/list.h> | ||
25 | |||
26 | typedef int (*mulist_extractor_fp) (void *data, PyObject **dst); | ||
27 | |||
28 | extern PyObject * mulist_to_pylist (mu_list_t list, mulist_extractor_fp fnc); | ||
29 | |||
30 | #endif /* not _MUCAPI_LIST_H */ |
python/c_api/list.c
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #include "c_api.h" | ||
22 | #include "list-private.h" | ||
23 | |||
24 | PyObject * | ||
25 | mulist_to_pylist (mu_list_t list, mulist_extractor_fp extractor) | ||
26 | { | ||
27 | int status, i; | ||
28 | size_t list_count; | ||
29 | PyObject *py_list; | ||
30 | |||
31 | if (!list) | ||
32 | return NULL; | ||
33 | |||
34 | status = mu_list_count (list, &list_count); | ||
35 | if (status) | ||
36 | return NULL; | ||
37 | |||
38 | py_list = PyList_New (list_count); | ||
39 | if (!py_list) | ||
40 | return NULL; | ||
41 | |||
42 | for (i = 0; i < list_count; i++) | ||
43 | { | ||
44 | void *item; | ||
45 | PyObject *py_item = NULL; | ||
46 | |||
47 | status = mu_list_get (list, i, &item); | ||
48 | if (!status) | ||
49 | { | ||
50 | status = (*extractor)(item, &py_item); | ||
51 | if (!status && py_item) | ||
52 | PyList_SetItem (py_list, i, py_item); | ||
53 | } | ||
54 | } | ||
55 | return py_list; | ||
56 | } |
python/c_api/mailbox-private.h
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #ifndef _MUCAPI_MAILBOX_H | ||
22 | #define _MUCAPI_MAILBOX_H | ||
23 | |||
24 | #include <mailutils/mailbox.h> | ||
25 | |||
26 | typedef struct { | ||
27 | PyObject_HEAD; | ||
28 | mu_mailbox_t mbox; | ||
29 | } PyMailbox; | ||
30 | |||
31 | #endif /* not _MUCAPI_MAILBOX_H */ |
python/c_api/mailbox.c
0 → 100644
This diff is collapsed.
Click to expand it.
python/c_api/mailcap-private.h
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #ifndef _MUCAPI_MAILCAP_H | ||
22 | #define _MUCAPI_MAILCAP_H | ||
23 | |||
24 | #include <mailutils/mailcap.h> | ||
25 | |||
26 | typedef struct { | ||
27 | PyObject_HEAD; | ||
28 | mu_mailcap_t mc; | ||
29 | } PyMailcap; | ||
30 | |||
31 | typedef struct { | ||
32 | PyObject_HEAD; | ||
33 | mu_mailcap_entry_t entry; | ||
34 | } PyMailcapEntry; | ||
35 | |||
36 | extern PyMailcap * PyMailcap_NEW (); | ||
37 | extern PyMailcapEntry * PyMailcapEntry_NEW (); | ||
38 | |||
39 | #endif /* not _MUCAPI_MAILCAP_H */ |
python/c_api/mailcap.c
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #include "c_api.h" | ||
22 | #include "mailcap-private.h" | ||
23 | #include "stream-private.h" | ||
24 | |||
25 | #define PY_MODULE "mailcap" | ||
26 | #define PY_CSNAME1 "MailcapType" | ||
27 | #define PY_CSNAME2 "MailcapEntryType" | ||
28 | |||
29 | static PyObject * | ||
30 | _repr1 (PyObject *self) | ||
31 | { | ||
32 | char buf[80]; | ||
33 | sprintf (buf, "<" PY_MODULE "." PY_CSNAME1 " instance at %p>", self); | ||
34 | return PyString_FromString (buf); | ||
35 | } | ||
36 | |||
37 | static PyTypeObject PyMailcapType = { | ||
38 | PyObject_HEAD_INIT(NULL) | ||
39 | 0, /* ob_size */ | ||
40 | PY_MODULE "." PY_CSNAME1, /* tp_name */ | ||
41 | sizeof (PyMailcap), /* tp_basicsize */ | ||
42 | 0, /* tp_itemsize */ | ||
43 | (destructor)py_dealloc, /* tp_dealloc */ | ||
44 | 0, /* tp_print */ | ||
45 | 0, /* tp_getattr; __getattr__ */ | ||
46 | 0, /* tp_setattr; __setattr__ */ | ||
47 | 0, /* tp_compare; __cmp__ */ | ||
48 | _repr1, /* tp_repr; __repr__ */ | ||
49 | 0, /* tp_as_number */ | ||
50 | 0, /* tp_as_sequence */ | ||
51 | 0, /* tp_as_mapping */ | ||
52 | 0, /* tp_hash; __hash__ */ | ||
53 | 0, /* tp_call; __call__ */ | ||
54 | _repr1, /* tp_str; __str__ */ | ||
55 | 0, /* tp_getattro */ | ||
56 | 0, /* tp_setattro */ | ||
57 | 0, /* tp_as_buffer */ | ||
58 | Py_TPFLAGS_DEFAULT, /* tp_flags */ | ||
59 | "", /* tp_doc */ | ||
60 | 0, /* tp_traverse */ | ||
61 | 0, /* tp_clear */ | ||
62 | 0, /* tp_richcompare */ | ||
63 | 0, /* tp_weaklistoffset */ | ||
64 | 0, /* tp_iter */ | ||
65 | 0, /* tp_iternext */ | ||
66 | 0, /* tp_methods */ | ||
67 | 0, /* tp_members */ | ||
68 | 0, /* tp_getset */ | ||
69 | 0, /* tp_base */ | ||
70 | 0, /* tp_dict */ | ||
71 | 0, /* tp_descr_get */ | ||
72 | 0, /* tp_descr_set */ | ||
73 | 0, /* tp_dictoffset */ | ||
74 | 0, /* tp_init */ | ||
75 | 0, /* tp_alloc */ | ||
76 | 0, /* tp_new */ | ||
77 | }; | ||
78 | |||
79 | PyMailcap * | ||
80 | PyMailcap_NEW () | ||
81 | { | ||
82 | return (PyMailcap *)PyObject_NEW (PyMailcap, &PyMailcapType); | ||
83 | } | ||
84 | |||
85 | static PyObject * | ||
86 | _repr2 (PyObject *self) | ||
87 | { | ||
88 | char buf[80]; | ||
89 | sprintf (buf, "<" PY_MODULE "." PY_CSNAME2 " instance at %p>", self); | ||
90 | return PyString_FromString (buf); | ||
91 | } | ||
92 | |||
93 | static PyTypeObject PyMailcapEntryType = { | ||
94 | PyObject_HEAD_INIT(NULL) | ||
95 | 0, /* ob_size */ | ||
96 | PY_MODULE "." PY_CSNAME2, /* tp_name */ | ||
97 | sizeof (PyMailcapEntry), /* tp_basicsize */ | ||
98 | 0, /* tp_itemsize */ | ||
99 | (destructor)py_dealloc, /* tp_dealloc */ | ||
100 | 0, /* tp_print */ | ||
101 | 0, /* tp_getattr; __getattr__ */ | ||
102 | 0, /* tp_setattr; __setattr__ */ | ||
103 | 0, /* tp_compare; __cmp__ */ | ||
104 | _repr2, /* tp_repr; __repr__ */ | ||
105 | 0, /* tp_as_number */ | ||
106 | 0, /* tp_as_sequence */ | ||
107 | 0, /* tp_as_mapping */ | ||
108 | 0, /* tp_hash; __hash__ */ | ||
109 | 0, /* tp_call; __call__ */ | ||
110 | _repr2, /* tp_str; __str__ */ | ||
111 | 0, /* tp_getattro */ | ||
112 | 0, /* tp_setattro */ | ||
113 | 0, /* tp_as_buffer */ | ||
114 | Py_TPFLAGS_DEFAULT, /* tp_flags */ | ||
115 | "", /* tp_doc */ | ||
116 | 0, /* tp_traverse */ | ||
117 | 0, /* tp_clear */ | ||
118 | 0, /* tp_richcompare */ | ||
119 | 0, /* tp_weaklistoffset */ | ||
120 | 0, /* tp_iter */ | ||
121 | 0, /* tp_iternext */ | ||
122 | 0, /* tp_methods */ | ||
123 | 0, /* tp_members */ | ||
124 | 0, /* tp_getset */ | ||
125 | 0, /* tp_base */ | ||
126 | 0, /* tp_dict */ | ||
127 | 0, /* tp_descr_get */ | ||
128 | 0, /* tp_descr_set */ | ||
129 | 0, /* tp_dictoffset */ | ||
130 | 0, /* tp_init */ | ||
131 | 0, /* tp_alloc */ | ||
132 | 0, /* tp_new */ | ||
133 | }; | ||
134 | |||
135 | PyMailcapEntry * | ||
136 | PyMailcapEntry_NEW () | ||
137 | { | ||
138 | return (PyMailcapEntry *)PyObject_NEW (PyMailcapEntry, | ||
139 | &PyMailcapEntryType); | ||
140 | } | ||
141 | |||
142 | |||
143 | static PyObject * | ||
144 | api_mailcap_create (PyObject *self, PyObject *args) | ||
145 | { | ||
146 | int status; | ||
147 | PyMailcap *py_mc; | ||
148 | PyStream *py_stm; | ||
149 | |||
150 | if (!PyArg_ParseTuple (args, "O!O", &PyMailcapType, &py_mc, &py_stm)) | ||
151 | return NULL; | ||
152 | |||
153 | if (!PyStream_Check ((PyObject *)py_stm)) | ||
154 | { | ||
155 | PyErr_SetString (PyExc_TypeError, py_stm->ob_type->tp_name); | ||
156 | return NULL; | ||
157 | } | ||
158 | |||
159 | status = mu_mailcap_create (&py_mc->mc, py_stm->stm); | ||
160 | return _ro (PyInt_FromLong (status)); | ||
161 | } | ||
162 | |||
163 | static PyObject * | ||
164 | api_mailcap_destroy (PyObject *self, PyObject *args) | ||
165 | { | ||
166 | PyMailcap *py_mc; | ||
167 | |||
168 | if (!PyArg_ParseTuple (args, "O!", &PyMailcapType, &py_mc)) | ||
169 | return NULL; | ||
170 | |||
171 | mu_mailcap_destroy (&py_mc->mc); | ||
172 | return _ro (Py_None); | ||
173 | } | ||
174 | |||
175 | static PyObject * | ||
176 | api_mailcap_entries_count (PyObject *self, PyObject *args) | ||
177 | { | ||
178 | int status; | ||
179 | size_t count = 0; | ||
180 | PyMailcap *py_mc; | ||
181 | |||
182 | if (!PyArg_ParseTuple (args, "O!", &PyMailcapType, &py_mc)) | ||
183 | return NULL; | ||
184 | |||
185 | status = mu_mailcap_entries_count (py_mc->mc, &count); | ||
186 | return status_object (status, PyInt_FromLong (count)); | ||
187 | } | ||
188 | |||
189 | static PyObject * | ||
190 | api_mailcap_get_entry (PyObject *self, PyObject *args) | ||
191 | { | ||
192 | int status, i; | ||
193 | PyMailcap *py_mc; | ||
194 | PyMailcapEntry *py_entry = PyMailcapEntry_NEW (); | ||
195 | |||
196 | if (!PyArg_ParseTuple (args, "O!i", &PyMailcapType, &py_mc, &i)) | ||
197 | return NULL; | ||
198 | |||
199 | status = mu_mailcap_get_entry (py_mc->mc, i, &py_entry->entry); | ||
200 | |||
201 | Py_INCREF (py_entry); | ||
202 | return status_object (status, (PyObject *)py_entry); | ||
203 | } | ||
204 | |||
205 | static PyObject * | ||
206 | api_mailcap_entry_fields_count (PyObject *self, PyObject *args) | ||
207 | { | ||
208 | int status; | ||
209 | size_t count; | ||
210 | PyMailcapEntry *py_entry; | ||
211 | |||
212 | if (!PyArg_ParseTuple (args, "O!", &PyMailcapEntryType, &py_entry)) | ||
213 | return NULL; | ||
214 | |||
215 | status = mu_mailcap_entry_fields_count (py_entry->entry, &count); | ||
216 | return status_object (status, PyInt_FromLong (count)); | ||
217 | } | ||
218 | |||
219 | static PyObject * | ||
220 | api_mailcap_entry_get_field (PyObject *self, PyObject *args) | ||
221 | { | ||
222 | int status, i; | ||
223 | char buf[256]; | ||
224 | PyMailcapEntry *py_entry; | ||
225 | |||
226 | if (!PyArg_ParseTuple (args, "O!i", &PyMailcapEntryType, &py_entry, | ||
227 | &i)) | ||
228 | return NULL; | ||
229 | |||
230 | status = mu_mailcap_entry_get_field (py_entry->entry, i, buf, | ||
231 | sizeof (buf), NULL); | ||
232 | return status_object (status, PyString_FromString (buf)); | ||
233 | } | ||
234 | |||
235 | static PyObject * | ||
236 | api_mailcap_entry_get_typefield (PyObject *self, PyObject *args) | ||
237 | { | ||
238 | int status; | ||
239 | char buf[256]; | ||
240 | PyMailcapEntry *py_entry; | ||
241 | |||
242 | if (!PyArg_ParseTuple (args, "O!", &PyMailcapEntryType, &py_entry)) | ||
243 | return NULL; | ||
244 | |||
245 | status = mu_mailcap_entry_get_typefield (py_entry->entry, buf, | ||
246 | sizeof (buf), NULL); | ||
247 | return status_object (status, PyString_FromString (buf)); | ||
248 | } | ||
249 | |||
250 | static PyObject * | ||
251 | api_mailcap_entry_get_viewcommand (PyObject *self, PyObject *args) | ||
252 | { | ||
253 | int status; | ||
254 | char buf[256]; | ||
255 | PyMailcapEntry *py_entry; | ||
256 | |||
257 | if (!PyArg_ParseTuple (args, "O!", &PyMailcapEntryType, &py_entry)) | ||
258 | return NULL; | ||
259 | |||
260 | status = mu_mailcap_entry_get_viewcommand (py_entry->entry, buf, | ||
261 | sizeof (buf), NULL); | ||
262 | return status_object (status, PyString_FromString (buf)); | ||
263 | } | ||
264 | |||
265 | static PyMethodDef methods[] = { | ||
266 | { "create", (PyCFunction) api_mailcap_create, METH_VARARGS, | ||
267 | "Allocate, parse the buffer from the STREAM and initializes MAILCAP." }, | ||
268 | |||
269 | { "destroy", (PyCFunction) api_mailcap_destroy, METH_VARARGS, | ||
270 | "Release any resources from the mailcap object." }, | ||
271 | |||
272 | { "entries_count", (PyCFunction) api_mailcap_entries_count, METH_VARARGS, | ||
273 | "Return the number of entries found in the mailcap." }, | ||
274 | |||
275 | { "get_entry", (PyCFunction) api_mailcap_get_entry, METH_VARARGS, | ||
276 | "Return in ENTRY the mailcap entry of NO." }, | ||
277 | |||
278 | { "entry_fields_count", (PyCFunction) api_mailcap_entry_fields_count, | ||
279 | METH_VARARGS, | ||
280 | "Return the number of fields found in the entry." }, | ||
281 | |||
282 | { "entry_get_field", (PyCFunction) api_mailcap_entry_get_field, | ||
283 | METH_VARARGS, | ||
284 | "" }, | ||
285 | |||
286 | { "entry_get_typefield", (PyCFunction) api_mailcap_entry_get_typefield, | ||
287 | METH_VARARGS, | ||
288 | "" }, | ||
289 | |||
290 | { "entry_get_viewcommand", | ||
291 | (PyCFunction) api_mailcap_entry_get_viewcommand, METH_VARARGS, | ||
292 | "" }, | ||
293 | |||
294 | { NULL, NULL, 0, NULL } | ||
295 | }; | ||
296 | |||
297 | void | ||
298 | init_mailcap () | ||
299 | { | ||
300 | PyObject *m; | ||
301 | |||
302 | PyMailcapType.tp_new = PyType_GenericNew; | ||
303 | PyMailcapEntryType.tp_new = PyType_GenericNew; | ||
304 | if (PyType_Ready (&PyMailcapType) < 0 || | ||
305 | PyType_Ready (&PyMailcapEntryType) < 0) | ||
306 | return; | ||
307 | |||
308 | if ((m = attach_module (PY_MODULE, methods))) | ||
309 | { | ||
310 | Py_INCREF (&PyMailcapType); | ||
311 | Py_INCREF (&PyMailcapEntryType); | ||
312 | PyModule_AddObject (m, PY_CSNAME1, (PyObject *)&PyMailcapType); | ||
313 | PyModule_AddObject (m, PY_CSNAME2, (PyObject *)&PyMailcapEntryType); | ||
314 | } | ||
315 | } |
python/c_api/mailer-private.h
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #ifndef _MUCAPI_MAILER_H | ||
22 | #define _MUCAPI_MAILER_H | ||
23 | |||
24 | #include <mailutils/mailer.h> | ||
25 | |||
26 | typedef struct { | ||
27 | PyObject_HEAD; | ||
28 | mu_mailer_t mlr; | ||
29 | } PyMailer; | ||
30 | |||
31 | extern PyMailer * PyMailer_NEW (); | ||
32 | |||
33 | #endif /* not _MUCAPI_MAILER_H */ |
python/c_api/mailer.c
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #include "c_api.h" | ||
22 | #include "mailer-private.h" | ||
23 | #include "address-private.h" | ||
24 | #include "message-private.h" | ||
25 | #include "debug-private.h" | ||
26 | |||
27 | #define PY_MODULE "mailer" | ||
28 | #define PY_CSNAME "MailerType" | ||
29 | |||
30 | static PyObject * | ||
31 | _repr (PyObject *self) | ||
32 | { | ||
33 | char buf[80]; | ||
34 | sprintf (buf, "<" PY_MODULE "." PY_CSNAME " instance at %p>", self); | ||
35 | return PyString_FromString (buf); | ||
36 | } | ||
37 | |||
38 | static PyTypeObject PyMailerType = { | ||
39 | PyObject_HEAD_INIT(NULL) | ||
40 | 0, /* ob_size */ | ||
41 | PY_MODULE "." PY_CSNAME, /* tp_name */ | ||
42 | sizeof (PyMailer), /* tp_basicsize */ | ||
43 | 0, /* tp_itemsize */ | ||
44 | (destructor)py_dealloc, /* tp_dealloc */ | ||
45 | 0, /* tp_print */ | ||
46 | 0, /* tp_getattr; __getattr__ */ | ||
47 | 0, /* tp_setattr; __setattr__ */ | ||
48 | 0, /* tp_compare; __cmp__ */ | ||
49 | _repr, /* tp_repr; __repr__ */ | ||
50 | 0, /* tp_as_number */ | ||
51 | 0, /* tp_as_sequence */ | ||
52 | 0, /* tp_as_mapping */ | ||
53 | 0, /* tp_hash; __hash__ */ | ||
54 | 0, /* tp_call; __call__ */ | ||
55 | _repr, /* tp_str; __str__ */ | ||
56 | 0, /* tp_getattro */ | ||
57 | 0, /* tp_setattro */ | ||
58 | 0, /* tp_as_buffer */ | ||
59 | Py_TPFLAGS_DEFAULT, /* tp_flags */ | ||
60 | "", /* tp_doc */ | ||
61 | 0, /* tp_traverse */ | ||
62 | 0, /* tp_clear */ | ||
63 | 0, /* tp_richcompare */ | ||
64 | 0, /* tp_weaklistoffset */ | ||
65 | 0, /* tp_iter */ | ||
66 | 0, /* tp_iternext */ | ||
67 | 0, /* tp_methods */ | ||
68 | 0, /* tp_members */ | ||
69 | 0, /* tp_getset */ | ||
70 | 0, /* tp_base */ | ||
71 | 0, /* tp_dict */ | ||
72 | 0, /* tp_descr_get */ | ||
73 | 0, /* tp_descr_set */ | ||
74 | 0, /* tp_dictoffset */ | ||
75 | 0, /* tp_init */ | ||
76 | 0, /* tp_alloc */ | ||
77 | 0, /* tp_new */ | ||
78 | }; | ||
79 | |||
80 | PyMailer * | ||
81 | PyMailer_NEW () | ||
82 | { | ||
83 | return (PyMailer *)PyObject_NEW (PyMailer, &PyMailerType); | ||
84 | } | ||
85 | |||
86 | static PyObject * | ||
87 | api_mailer_create (PyObject *self, PyObject *args) | ||
88 | { | ||
89 | int status; | ||
90 | char *url; | ||
91 | PyMailer *py_mlr; | ||
92 | |||
93 | if (!PyArg_ParseTuple (args, "O!s", &PyMailerType, &py_mlr, &url)) | ||
94 | return NULL; | ||
95 | |||
96 | status = mu_mailer_create (&py_mlr->mlr, url); | ||
97 | return _ro (PyInt_FromLong (status)); | ||
98 | } | ||
99 | |||
100 | static PyObject * | ||
101 | api_mailer_destroy (PyObject *self, PyObject *args) | ||
102 | { | ||
103 | PyMailer *py_mlr; | ||
104 | |||
105 | if (!PyArg_ParseTuple (args, "O!", &PyMailerType, &py_mlr)) | ||
106 | return NULL; | ||
107 | |||
108 | mu_mailer_destroy (&py_mlr->mlr); | ||
109 | return _ro (Py_None); | ||
110 | } | ||
111 | |||
112 | static PyObject * | ||
113 | api_mailer_open (PyObject *self, PyObject *args) | ||
114 | { | ||
115 | int status, flags; | ||
116 | PyMailer *py_mlr; | ||
117 | |||
118 | if (!PyArg_ParseTuple (args, "O!i", &PyMailerType, &py_mlr, &flags)) | ||
119 | return NULL; | ||
120 | |||
121 | status = mu_mailer_open (py_mlr->mlr, flags); | ||
122 | return _ro (PyInt_FromLong (status)); | ||
123 | } | ||
124 | |||
125 | static PyObject * | ||
126 | api_mailer_close (PyObject *self, PyObject *args) | ||
127 | { | ||
128 | int status; | ||
129 | PyMailer *py_mlr; | ||
130 | |||
131 | if (!PyArg_ParseTuple (args, "O!", &PyMailerType, &py_mlr)) | ||
132 | return NULL; | ||
133 | |||
134 | status = mu_mailer_close (py_mlr->mlr); | ||
135 | return _ro (PyInt_FromLong (status)); | ||
136 | } | ||
137 | |||
138 | static PyObject * | ||
139 | api_mailer_send_message (PyObject *self, PyObject *args) | ||
140 | { | ||
141 | int status; | ||
142 | PyMailer *py_mlr; | ||
143 | PyMessage *py_msg; | ||
144 | PyAddress *py_from, *py_to; | ||
145 | mu_address_t c_from = NULL, c_to = NULL; | ||
146 | |||
147 | if (!PyArg_ParseTuple (args, "O!OOO", &PyMailerType, &py_mlr, | ||
148 | &py_msg, &py_from, &py_to)) | ||
149 | return NULL; | ||
150 | |||
151 | if (!PyMessage_Check ((PyObject *)py_msg)) | ||
152 | { | ||
153 | PyErr_SetString (PyExc_TypeError, ""); | ||
154 | return NULL; | ||
155 | } | ||
156 | if (!PyAddress_Check ((PyObject *)py_from) && | ||
157 | (PyObject *)py_from != Py_None) | ||
158 | { | ||
159 | PyErr_SetString (PyExc_TypeError, ""); | ||
160 | return NULL; | ||
161 | } | ||
162 | if (!PyAddress_Check ((PyObject *)py_to) && | ||
163 | (PyObject *)py_to != Py_None) | ||
164 | { | ||
165 | PyErr_SetString (PyExc_TypeError, ""); | ||
166 | return NULL; | ||
167 | } | ||
168 | if ((PyObject *)py_from != Py_None) | ||
169 | c_from = py_from->addr; | ||
170 | if ((PyObject *)py_to != Py_None) | ||
171 | c_to = py_to->addr; | ||
172 | |||
173 | status = mu_mailer_send_message (py_mlr->mlr, py_msg->msg, | ||
174 | c_from, c_to); | ||
175 | return _ro (PyInt_FromLong (status)); | ||
176 | } | ||
177 | |||
178 | static PyObject * | ||
179 | api_mailer_get_debug (PyObject *self, PyObject *args) | ||
180 | { | ||
181 | int status; | ||
182 | PyMailer *py_mlr; | ||
183 | PyDebug *py_dbg = PyDebug_NEW (); | ||
184 | |||
185 | if (!PyArg_ParseTuple (args, "O!", &PyMailerType, &py_mlr)) | ||
186 | return NULL; | ||
187 | |||
188 | status = mu_mailer_get_debug (py_mlr->mlr, &py_dbg->dbg); | ||
189 | |||
190 | Py_INCREF (py_dbg); | ||
191 | return status_object (status, (PyObject *)py_dbg); | ||
192 | } | ||
193 | |||
194 | static PyMethodDef methods[] = { | ||
195 | { "create", (PyCFunction) api_mailer_create, METH_VARARGS, | ||
196 | "Create mailer." }, | ||
197 | |||
198 | { "destroy", (PyCFunction) api_mailer_destroy, METH_VARARGS, | ||
199 | "The resources allocate for MSG are freed." }, | ||
200 | |||
201 | { "open", (PyCFunction) api_mailer_open, METH_VARARGS, | ||
202 | "" }, | ||
203 | |||
204 | { "close", (PyCFunction) api_mailer_close, METH_VARARGS, | ||
205 | "" }, | ||
206 | |||
207 | { "send_message", (PyCFunction) api_mailer_send_message, METH_VARARGS, | ||
208 | "" }, | ||
209 | |||
210 | { "get_debug", (PyCFunction) api_mailer_get_debug, METH_VARARGS, | ||
211 | "" }, | ||
212 | |||
213 | { NULL, NULL, 0, NULL } | ||
214 | }; | ||
215 | |||
216 | void | ||
217 | init_mailer () | ||
218 | { | ||
219 | PyObject *m; | ||
220 | |||
221 | PyMailerType.tp_new = PyType_GenericNew; | ||
222 | if (PyType_Ready (&PyMailerType) < 0) | ||
223 | return; | ||
224 | |||
225 | if ((m = attach_module (PY_MODULE, methods))) | ||
226 | { | ||
227 | Py_INCREF (&PyMailerType); | ||
228 | PyModule_AddObject (m, PY_CSNAME, (PyObject *)&PyMailerType); | ||
229 | } | ||
230 | } |
python/c_api/message-private.h
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #ifndef _MUCAPI_MESSAGE_H | ||
22 | #define _MUCAPI_MESSAGE_H | ||
23 | |||
24 | #include <mailutils/message.h> | ||
25 | |||
26 | typedef struct { | ||
27 | PyObject_HEAD; | ||
28 | mu_message_t msg; | ||
29 | } PyMessage; | ||
30 | |||
31 | extern PyMessage * PyMessage_NEW (); | ||
32 | extern int PyMessage_Check (PyObject *x); | ||
33 | |||
34 | #endif /* not _MUCAPI_MESSAGE_H */ |
python/c_api/message.c
0 → 100644
This diff is collapsed.
Click to expand it.
python/c_api/mime-private.h
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #ifndef _MUCAPI_MIME_H | ||
22 | #define _MUCAPI_MIME_H | ||
23 | |||
24 | #include <mailutils/mime.h> | ||
25 | |||
26 | typedef struct { | ||
27 | PyObject_HEAD; | ||
28 | mu_mime_t mime; | ||
29 | } PyMime; | ||
30 | |||
31 | extern PyMime * PyMime_NEW (); | ||
32 | |||
33 | #endif /* not _MUCAPI_MIME_H */ |
python/c_api/mime.c
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #include "c_api.h" | ||
22 | #include "mime-private.h" | ||
23 | #include "message-private.h" | ||
24 | |||
25 | #define PY_MODULE "mime" | ||
26 | #define PY_CSNAME "MimeType" | ||
27 | |||
28 | static PyObject * | ||
29 | _repr (PyObject *self) | ||
30 | { | ||
31 | char buf[80]; | ||
32 | sprintf (buf, "<" PY_MODULE "." PY_CSNAME " instance at %p>", self); | ||
33 | return PyString_FromString (buf); | ||
34 | } | ||
35 | |||
36 | static PyTypeObject PyMimeType = { | ||
37 | PyObject_HEAD_INIT(NULL) | ||
38 | 0, /* ob_size */ | ||
39 | PY_MODULE "." PY_CSNAME, /* tp_name */ | ||
40 | sizeof (PyMime), /* tp_basicsize */ | ||
41 | 0, /* tp_itemsize */ | ||
42 | (destructor)py_dealloc, /* tp_dealloc */ | ||
43 | 0, /* tp_print */ | ||
44 | 0, /* tp_getattr; __getattr__ */ | ||
45 | 0, /* tp_setattr; __setattr__ */ | ||
46 | 0, /* tp_compare; __cmp__ */ | ||
47 | _repr, /* tp_repr; __repr__ */ | ||
48 | 0, /* tp_as_number */ | ||
49 | 0, /* tp_as_sequence */ | ||
50 | 0, /* tp_as_mapping */ | ||
51 | 0, /* tp_hash; __hash__ */ | ||
52 | 0, /* tp_call; __call__ */ | ||
53 | _repr, /* tp_str; __str__ */ | ||
54 | 0, /* tp_getattro */ | ||
55 | 0, /* tp_setattro */ | ||
56 | 0, /* tp_as_buffer */ | ||
57 | Py_TPFLAGS_DEFAULT, /* tp_flags */ | ||
58 | "", /* tp_doc */ | ||
59 | 0, /* tp_traverse */ | ||
60 | 0, /* tp_clear */ | ||
61 | 0, /* tp_richcompare */ | ||
62 | 0, /* tp_weaklistoffset */ | ||
63 | 0, /* tp_iter */ | ||
64 | 0, /* tp_iternext */ | ||
65 | 0, /* tp_methods */ | ||
66 | 0, /* tp_members */ | ||
67 | 0, /* tp_getset */ | ||
68 | 0, /* tp_base */ | ||
69 | 0, /* tp_dict */ | ||
70 | 0, /* tp_descr_get */ | ||
71 | 0, /* tp_descr_set */ | ||
72 | 0, /* tp_dictoffset */ | ||
73 | 0, /* tp_init */ | ||
74 | 0, /* tp_alloc */ | ||
75 | 0, /* tp_new */ | ||
76 | }; | ||
77 | |||
78 | PyMime * | ||
79 | PyMime_NEW () | ||
80 | { | ||
81 | return (PyMime *)PyObject_NEW (PyMime, &PyMimeType); | ||
82 | } | ||
83 | |||
84 | static PyObject * | ||
85 | api_mime_create (PyObject *self, PyObject *args) | ||
86 | { | ||
87 | int status, flags; | ||
88 | PyMime *py_mime; | ||
89 | PyMessage *py_msg; | ||
90 | |||
91 | if (!PyArg_ParseTuple (args, "O!Oi", &PyMimeType, &py_mime, | ||
92 | &py_msg, &flags)) | ||
93 | return NULL; | ||
94 | |||
95 | if (!PyMessage_Check ((PyObject *)py_msg)) | ||
96 | { | ||
97 | PyErr_SetString (PyExc_TypeError, ""); | ||
98 | return NULL; | ||
99 | } | ||
100 | |||
101 | status = mu_mime_create (&py_mime->mime, py_msg->msg, flags); | ||
102 | return _ro (PyInt_FromLong (status)); | ||
103 | } | ||
104 | |||
105 | static PyObject * | ||
106 | api_mime_destroy (PyObject *self, PyObject *args) | ||
107 | { | ||
108 | PyMime *py_mime; | ||
109 | |||
110 | if (!PyArg_ParseTuple (args, "O!", &PyMimeType, &py_mime)) | ||
111 | return NULL; | ||
112 | |||
113 | mu_mime_destroy (&py_mime->mime); | ||
114 | return _ro (Py_None); | ||
115 | } | ||
116 | |||
117 | static PyObject * | ||
118 | api_mime_is_multipart (PyObject *self, PyObject *args) | ||
119 | { | ||
120 | int ismulti; | ||
121 | PyMime *py_mime; | ||
122 | |||
123 | if (!PyArg_ParseTuple (args, "O!", &PyMimeType, &py_mime)) | ||
124 | return NULL; | ||
125 | |||
126 | ismulti = mu_mime_is_multipart (py_mime->mime); | ||
127 | return _ro (PyBool_FromLong (ismulti)); | ||
128 | } | ||
129 | |||
130 | static PyObject * | ||
131 | api_mime_get_num_parts (PyObject *self, PyObject *args) | ||
132 | { | ||
133 | int status; | ||
134 | size_t nparts; | ||
135 | PyMime *py_mime; | ||
136 | |||
137 | if (!PyArg_ParseTuple (args, "O!", &PyMimeType, &py_mime)) | ||
138 | return NULL; | ||
139 | |||
140 | status = mu_mime_get_num_parts (py_mime->mime, &nparts); | ||
141 | return status_object (status, PyInt_FromLong (nparts)); | ||
142 | } | ||
143 | |||
144 | static PyObject * | ||
145 | api_mime_get_part (PyObject *self, PyObject *args) | ||
146 | { | ||
147 | int status; | ||
148 | size_t npart; | ||
149 | PyMime *py_mime; | ||
150 | PyMessage *py_part = PyMessage_NEW (); | ||
151 | |||
152 | if (!PyArg_ParseTuple (args, "O!i", &PyMimeType, &py_mime, &npart)) | ||
153 | return NULL; | ||
154 | |||
155 | status = mu_mime_get_part (py_mime->mime, npart, &py_part->msg); | ||
156 | |||
157 | Py_INCREF (py_part); | ||
158 | return status_object (status, (PyObject *)py_part); | ||
159 | } | ||
160 | |||
161 | static PyObject * | ||
162 | api_mime_add_part (PyObject *self, PyObject *args) | ||
163 | { | ||
164 | int status; | ||
165 | PyMime *py_mime; | ||
166 | PyMessage *py_msg; | ||
167 | |||
168 | if (!PyArg_ParseTuple (args, "O!O", &PyMimeType, &py_mime, &py_msg)) | ||
169 | return NULL; | ||
170 | |||
171 | if (!PyMessage_Check ((PyObject *)py_msg)) | ||
172 | { | ||
173 | PyErr_SetString (PyExc_TypeError, ""); | ||
174 | return NULL; | ||
175 | } | ||
176 | |||
177 | status = mu_mime_add_part (py_mime->mime, py_msg->msg); | ||
178 | return _ro (PyInt_FromLong (status)); | ||
179 | } | ||
180 | |||
181 | static PyObject * | ||
182 | api_mime_get_message (PyObject *self, PyObject *args) | ||
183 | { | ||
184 | int status; | ||
185 | PyMime *py_mime; | ||
186 | PyMessage *py_msg = PyMessage_NEW (); | ||
187 | |||
188 | if (!PyArg_ParseTuple (args, "O!", &PyMimeType, &py_mime)) | ||
189 | return NULL; | ||
190 | |||
191 | status = mu_mime_get_message (py_mime->mime, &py_msg->msg); | ||
192 | |||
193 | Py_INCREF (py_msg); | ||
194 | return status_object (status, (PyObject *)py_msg); | ||
195 | } | ||
196 | |||
197 | static PyObject * | ||
198 | api_rfc2047_decode (PyObject *self, PyObject *args) | ||
199 | { | ||
200 | int status; | ||
201 | char *tocode, *text; | ||
202 | char *buf = NULL; | ||
203 | |||
204 | if (!PyArg_ParseTuple (args, "ss", &tocode, &text)) | ||
205 | return NULL; | ||
206 | |||
207 | status = mu_rfc2047_decode (tocode, text, &buf); | ||
208 | return status_object (status, PyString_FromString (buf ? buf : "")); | ||
209 | } | ||
210 | |||
211 | static PyObject * | ||
212 | api_rfc2047_encode (PyObject *self, PyObject *args) | ||
213 | { | ||
214 | int status; | ||
215 | char *charset, *encoding, *text; | ||
216 | char *buf = NULL; | ||
217 | |||
218 | if (!PyArg_ParseTuple (args, "sss", &charset, &encoding, &text)) | ||
219 | return NULL; | ||
220 | |||
221 | status = mu_rfc2047_encode (charset, encoding, text, &buf); | ||
222 | return status_object (status, PyString_FromString (buf ? buf : "")); | ||
223 | } | ||
224 | |||
225 | static PyMethodDef methods[] = { | ||
226 | { "create", (PyCFunction) api_mime_create, METH_VARARGS, | ||
227 | "" }, | ||
228 | |||
229 | { "destroy", (PyCFunction) api_mime_destroy, METH_VARARGS, | ||
230 | "" }, | ||
231 | |||
232 | { "is_multipart", (PyCFunction) api_mime_is_multipart, METH_VARARGS, | ||
233 | "" }, | ||
234 | |||
235 | { "get_num_parts", (PyCFunction) api_mime_get_num_parts, METH_VARARGS, | ||
236 | "" }, | ||
237 | |||
238 | { "get_part", (PyCFunction) api_mime_get_part, METH_VARARGS, | ||
239 | "" }, | ||
240 | |||
241 | { "add_part", (PyCFunction) api_mime_add_part, METH_VARARGS, | ||
242 | "" }, | ||
243 | |||
244 | { "get_message", (PyCFunction) api_mime_get_message, METH_VARARGS, | ||
245 | "" }, | ||
246 | |||
247 | { "rfc2047_decode", (PyCFunction) api_rfc2047_decode, METH_VARARGS, | ||
248 | "" }, | ||
249 | |||
250 | { "rfc2047_encode", (PyCFunction) api_rfc2047_encode, METH_VARARGS, | ||
251 | "" }, | ||
252 | |||
253 | { NULL, NULL, 0, NULL } | ||
254 | }; | ||
255 | |||
256 | void | ||
257 | init_mime () | ||
258 | { | ||
259 | PyObject *m; | ||
260 | |||
261 | PyMimeType.tp_new = PyType_GenericNew; | ||
262 | if (PyType_Ready (&PyMimeType) < 0) | ||
263 | return; | ||
264 | |||
265 | if ((m = attach_module (PY_MODULE, methods))) | ||
266 | { | ||
267 | Py_INCREF (&PyMimeType); | ||
268 | PyModule_AddObject (m, PY_CSNAME, (PyObject *)&PyMimeType); | ||
269 | } | ||
270 | } |
python/c_api/registrar.c
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #include "c_api.h" | ||
22 | #include <mailutils/registrar.h> | ||
23 | #include <mailutils/tls.h> | ||
24 | |||
25 | #define PY_MODULE "registrar" | ||
26 | |||
27 | struct format_record { | ||
28 | char *name; | ||
29 | mu_record_t *record; | ||
30 | }; | ||
31 | |||
32 | static struct format_record format_table[] = { | ||
33 | { "mbox", &mu_mbox_record }, | ||
34 | { "mh", &mu_mh_record }, | ||
35 | { "maildir", &mu_maildir_record }, | ||
36 | { "pop", &mu_pop_record }, | ||
37 | { "imap", &mu_imap_record }, | ||
38 | #ifdef WITH_TLS | ||
39 | { "pops", &mu_pops_record }, | ||
40 | { "imaps", &mu_imaps_record }, | ||
41 | #endif /* WITH_TLS */ | ||
42 | { "sendmail", &mu_sendmail_record }, | ||
43 | { "smtp", &mu_smtp_record }, | ||
44 | { NULL, NULL }, | ||
45 | }; | ||
46 | |||
47 | static mu_record_t * | ||
48 | find_format (const struct format_record *table, const char *name) | ||
49 | { | ||
50 | for (; table->name; table++) | ||
51 | if (strcmp (table->name, name) == 0) | ||
52 | break; | ||
53 | return table->record; | ||
54 | } | ||
55 | |||
56 | static int | ||
57 | register_format (const char *name) | ||
58 | { | ||
59 | int status = 0; | ||
60 | |||
61 | if (!name) | ||
62 | { | ||
63 | struct format_record *table; | ||
64 | for (table = format_table; table->name; table++) | ||
65 | mu_registrar_record (*table->record); | ||
66 | } | ||
67 | else | ||
68 | { | ||
69 | mu_record_t *record = find_format (format_table, name); | ||
70 | if (record) | ||
71 | status = mu_registrar_record (*record); | ||
72 | else | ||
73 | status = EINVAL; | ||
74 | } | ||
75 | return status; | ||
76 | } | ||
77 | |||
78 | static int | ||
79 | set_default_format (const char *name) | ||
80 | { | ||
81 | int status = 0; | ||
82 | |||
83 | if (name) | ||
84 | { | ||
85 | mu_record_t *record = find_format (format_table, name); | ||
86 | if (record) | ||
87 | mu_registrar_set_default_record (*record); | ||
88 | else | ||
89 | status = EINVAL; | ||
90 | } | ||
91 | return status; | ||
92 | } | ||
93 | |||
94 | static PyObject * | ||
95 | api_registrar_register_format (PyObject *self, PyObject *args) | ||
96 | { | ||
97 | int status; | ||
98 | char *name = NULL; | ||
99 | |||
100 | if (!PyArg_ParseTuple (args, "|s", &name)) | ||
101 | return NULL; | ||
102 | |||
103 | status = register_format (name); | ||
104 | return _ro (PyInt_FromLong (status)); | ||
105 | } | ||
106 | |||
107 | static PyObject * | ||
108 | api_registrar_set_default_format (PyObject *self, PyObject *args) | ||
109 | { | ||
110 | int status; | ||
111 | char *name = NULL; | ||
112 | |||
113 | if (!PyArg_ParseTuple (args, "s", &name)) | ||
114 | return NULL; | ||
115 | |||
116 | status = set_default_format (name); | ||
117 | return _ro (PyInt_FromLong (status)); | ||
118 | } | ||
119 | |||
120 | static PyMethodDef methods[] = { | ||
121 | { "register_format", (PyCFunction) api_registrar_register_format, | ||
122 | METH_VARARGS, | ||
123 | "Register desired mailutils formats. Any number of arguments " | ||
124 | "can be given." }, | ||
125 | |||
126 | { "set_default_format", (PyCFunction) api_registrar_set_default_format, | ||
127 | METH_VARARGS, "" }, | ||
128 | |||
129 | { NULL, NULL, 0, NULL } | ||
130 | }; | ||
131 | |||
132 | void | ||
133 | init_registrar () | ||
134 | { | ||
135 | attach_module (PY_MODULE, methods); | ||
136 | |||
137 | mu_registrar_record (MU_DEFAULT_RECORD); | ||
138 | mu_registrar_set_default_record (MU_DEFAULT_RECORD); | ||
139 | |||
140 | #ifdef WITH_TLS | ||
141 | mu_init_tls_libs (); | ||
142 | #endif /* WITH_TLS */ | ||
143 | |||
144 | } |
python/c_api/stream-private.h
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #ifndef _MUCAPI_STREAM_H | ||
22 | #define _MUCAPI_STREAM_H | ||
23 | |||
24 | #include <mailutils/stream.h> | ||
25 | |||
26 | typedef struct { | ||
27 | PyObject_HEAD; | ||
28 | mu_stream_t stm; | ||
29 | } PyStream; | ||
30 | |||
31 | extern PyStream * PyStream_NEW (); | ||
32 | extern int PyStream_Check (PyObject *x); | ||
33 | |||
34 | #endif /* not _MUCAPI_STREAM_H */ |
python/c_api/stream.c
0 → 100644
This diff is collapsed.
Click to expand it.
python/c_api/url-private.h
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #ifndef _MUCAPI_URL_H | ||
22 | #define _MUCAPI_URL_H | ||
23 | |||
24 | #include <mailutils/url.h> | ||
25 | |||
26 | typedef struct { | ||
27 | PyObject_HEAD; | ||
28 | mu_url_t url; | ||
29 | } PyUrl; | ||
30 | |||
31 | extern PyUrl * PyUrl_NEW (); | ||
32 | |||
33 | #endif /* not _MUCAPI_URL_H */ |
python/c_api/url.c
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #include "c_api.h" | ||
22 | #include "url-private.h" | ||
23 | |||
24 | #define PY_MODULE "url" | ||
25 | #define PY_CSNAME "UrlType" | ||
26 | |||
27 | static PyObject * | ||
28 | _repr (PyObject *self) | ||
29 | { | ||
30 | char buf[80]; | ||
31 | sprintf (buf, "<" PY_MODULE "." PY_CSNAME " instance at %p>", self); | ||
32 | return PyString_FromString (buf); | ||
33 | } | ||
34 | |||
35 | static PyTypeObject PyUrlType = { | ||
36 | PyObject_HEAD_INIT(NULL) | ||
37 | 0, /* ob_size */ | ||
38 | PY_MODULE "." PY_CSNAME, /* tp_name */ | ||
39 | sizeof (PyUrl), /* tp_basicsize */ | ||
40 | 0, /* tp_itemsize */ | ||
41 | (destructor)py_dealloc, /* tp_dealloc */ | ||
42 | 0, /* tp_print */ | ||
43 | 0, /* tp_getattr; __getattr__ */ | ||
44 | 0, /* tp_setattr; __setattr__ */ | ||
45 | 0, /* tp_compare; __cmp__ */ | ||
46 | _repr, /* tp_repr; __repr__ */ | ||
47 | 0, /* tp_as_number */ | ||
48 | 0, /* tp_as_sequence */ | ||
49 | 0, /* tp_as_mapping */ | ||
50 | 0, /* tp_hash; __hash__ */ | ||
51 | 0, /* tp_call; __call__ */ | ||
52 | _repr, /* tp_str; __str__ */ | ||
53 | 0, /* tp_getattro */ | ||
54 | 0, /* tp_setattro */ | ||
55 | 0, /* tp_as_buffer */ | ||
56 | Py_TPFLAGS_DEFAULT, /* tp_flags */ | ||
57 | "", /* tp_doc */ | ||
58 | 0, /* tp_traverse */ | ||
59 | 0, /* tp_clear */ | ||
60 | 0, /* tp_richcompare */ | ||
61 | 0, /* tp_weaklistoffset */ | ||
62 | 0, /* tp_iter */ | ||
63 | 0, /* tp_iternext */ | ||
64 | 0, /* tp_methods */ | ||
65 | 0, /* tp_members */ | ||
66 | 0, /* tp_getset */ | ||
67 | 0, /* tp_base */ | ||
68 | 0, /* tp_dict */ | ||
69 | 0, /* tp_descr_get */ | ||
70 | 0, /* tp_descr_set */ | ||
71 | 0, /* tp_dictoffset */ | ||
72 | 0, /* tp_init */ | ||
73 | 0, /* tp_alloc */ | ||
74 | 0, /* tp_new */ | ||
75 | }; | ||
76 | |||
77 | PyUrl * | ||
78 | PyUrl_NEW () | ||
79 | { | ||
80 | return (PyUrl *)PyObject_NEW (PyUrl, &PyUrlType); | ||
81 | } | ||
82 | |||
83 | static PyObject * | ||
84 | api_url_create (PyObject *self, PyObject *args) | ||
85 | { | ||
86 | int status; | ||
87 | char *str; | ||
88 | PyUrl *py_url; | ||
89 | |||
90 | if (!PyArg_ParseTuple (args, "O!s", &PyUrlType, &py_url, &str)) | ||
91 | return NULL; | ||
92 | |||
93 | status = mu_url_create (&py_url->url, str); | ||
94 | return _ro (PyInt_FromLong (status)); | ||
95 | } | ||
96 | |||
97 | static PyObject * | ||
98 | api_url_destroy (PyObject *self, PyObject *args) | ||
99 | { | ||
100 | PyUrl *py_url; | ||
101 | |||
102 | if (!PyArg_ParseTuple (args, "O!", &PyUrlType, &py_url)) | ||
103 | return NULL; | ||
104 | |||
105 | mu_url_destroy (&py_url->url); | ||
106 | return _ro (Py_None); | ||
107 | } | ||
108 | |||
109 | static PyObject * | ||
110 | api_url_parse (PyObject *self, PyObject *args) | ||
111 | { | ||
112 | int status; | ||
113 | PyUrl *py_url; | ||
114 | |||
115 | if (!PyArg_ParseTuple (args, "O!", &PyUrlType, &py_url)) | ||
116 | return NULL; | ||
117 | |||
118 | status = mu_url_parse (py_url->url); | ||
119 | return _ro (PyInt_FromLong (status)); | ||
120 | } | ||
121 | |||
122 | static PyObject * | ||
123 | api_url_get_port (PyObject *self, PyObject *args) | ||
124 | { | ||
125 | int status; | ||
126 | long port; | ||
127 | PyUrl *py_url; | ||
128 | |||
129 | if (!PyArg_ParseTuple (args, "O!", &PyUrlType, &py_url)) | ||
130 | return NULL; | ||
131 | |||
132 | status = mu_url_get_port (py_url->url, &port); | ||
133 | return status_object (status, PyInt_FromLong (port)); | ||
134 | } | ||
135 | |||
136 | static PyObject * | ||
137 | api_url_get_scheme (PyObject *self, PyObject *args) | ||
138 | { | ||
139 | int status; | ||
140 | const char *buf = NULL; | ||
141 | PyUrl *py_url; | ||
142 | |||
143 | if (!PyArg_ParseTuple (args, "O!", &PyUrlType, &py_url)) | ||
144 | return NULL; | ||
145 | |||
146 | status = mu_url_sget_scheme (py_url->url, &buf); | ||
147 | return status_object (status, PyString_FromString (buf ? buf : "")); | ||
148 | } | ||
149 | |||
150 | static PyObject * | ||
151 | api_url_get_user (PyObject *self, PyObject *args) | ||
152 | { | ||
153 | int status; | ||
154 | const char *buf = NULL; | ||
155 | PyUrl *py_url; | ||
156 | |||
157 | if (!PyArg_ParseTuple (args, "O!", &PyUrlType, &py_url)) | ||
158 | return NULL; | ||
159 | |||
160 | status = mu_url_sget_user (py_url->url, &buf); | ||
161 | return status_object (status, PyString_FromString (buf ? buf : "")); | ||
162 | } | ||
163 | |||
164 | static PyObject * | ||
165 | api_url_get_passwd (PyObject *self, PyObject *args) | ||
166 | { | ||
167 | int status; | ||
168 | const char *buf = NULL; | ||
169 | PyUrl *py_url; | ||
170 | |||
171 | if (!PyArg_ParseTuple (args, "O!", &PyUrlType, &py_url)) | ||
172 | return NULL; | ||
173 | |||
174 | status = mu_url_sget_passwd (py_url->url, &buf); | ||
175 | return status_object (status, PyString_FromString (buf ? buf : "")); | ||
176 | } | ||
177 | |||
178 | static PyObject * | ||
179 | api_url_get_auth (PyObject *self, PyObject *args) | ||
180 | { | ||
181 | int status; | ||
182 | const char *buf = NULL; | ||
183 | PyUrl *py_url; | ||
184 | |||
185 | if (!PyArg_ParseTuple (args, "O!", &PyUrlType, &py_url)) | ||
186 | return NULL; | ||
187 | |||
188 | status = mu_url_sget_auth (py_url->url, &buf); | ||
189 | return status_object (status, PyString_FromString (buf ? buf : "")); | ||
190 | } | ||
191 | |||
192 | static PyObject * | ||
193 | api_url_get_host (PyObject *self, PyObject *args) | ||
194 | { | ||
195 | int status; | ||
196 | const char *buf = NULL; | ||
197 | PyUrl *py_url; | ||
198 | |||
199 | if (!PyArg_ParseTuple (args, "O!", &PyUrlType, &py_url)) | ||
200 | return NULL; | ||
201 | |||
202 | status = mu_url_sget_host (py_url->url, &buf); | ||
203 | return status_object (status, PyString_FromString (buf ? buf : "")); | ||
204 | } | ||
205 | |||
206 | static PyObject * | ||
207 | api_url_get_path (PyObject *self, PyObject *args) | ||
208 | { | ||
209 | int status; | ||
210 | const char *buf = NULL; | ||
211 | PyUrl *py_url; | ||
212 | |||
213 | if (!PyArg_ParseTuple (args, "O!", &PyUrlType, &py_url)) | ||
214 | return NULL; | ||
215 | |||
216 | status = mu_url_sget_path (py_url->url, &buf); | ||
217 | return status_object (status, PyString_FromString (buf ? buf : "")); | ||
218 | } | ||
219 | |||
220 | static PyObject * | ||
221 | api_url_get_query (PyObject *self, PyObject *args) | ||
222 | { | ||
223 | int status, i; | ||
224 | size_t argc; | ||
225 | char **argv; | ||
226 | PyObject *py_list; | ||
227 | PyUrl *py_url; | ||
228 | |||
229 | if (!PyArg_ParseTuple (args, "O!", &PyUrlType, &py_url)) | ||
230 | return NULL; | ||
231 | |||
232 | status = mu_url_sget_query (py_url->url, &argc, &argv); | ||
233 | |||
234 | py_list = PyList_New (0); | ||
235 | for (i = 0; i < argc; i++) | ||
236 | PyList_Append (py_list, PyString_FromString (argv[i])); | ||
237 | |||
238 | return status_object (status, py_list); | ||
239 | } | ||
240 | |||
241 | static PyObject * | ||
242 | api_url_to_string (PyObject *self, PyObject *args) | ||
243 | { | ||
244 | int status; | ||
245 | const char *str; | ||
246 | PyUrl *py_url; | ||
247 | |||
248 | if (!PyArg_ParseTuple (args, "O!", &PyUrlType, &py_url)) | ||
249 | return NULL; | ||
250 | |||
251 | str = mu_url_to_string (py_url->url); | ||
252 | return _ro (PyString_FromString (str ? str : "")); | ||
253 | } | ||
254 | |||
255 | static PyMethodDef methods[] = { | ||
256 | { "create", (PyCFunction) api_url_create, METH_VARARGS, | ||
257 | "Create the url data structure, but do not parse it." }, | ||
258 | |||
259 | { "destroy", (PyCFunction) api_url_destroy, METH_VARARGS, | ||
260 | "Destroy the url and free its resources." }, | ||
261 | |||
262 | { "parse", (PyCFunction) api_url_parse, METH_VARARGS, | ||
263 | "Parse the url, after calling this the get functions can be called." }, | ||
264 | |||
265 | { "to_string", (PyCFunction) api_url_to_string, METH_VARARGS, | ||
266 | "" }, | ||
267 | |||
268 | { "get_port", (PyCFunction) api_url_get_port, METH_VARARGS, "" }, | ||
269 | { "get_scheme", (PyCFunction) api_url_get_scheme, METH_VARARGS, "" }, | ||
270 | { "get_user", (PyCFunction) api_url_get_user, METH_VARARGS, "" }, | ||
271 | { "get_passwd", (PyCFunction) api_url_get_passwd, METH_VARARGS, "" }, | ||
272 | { "get_auth", (PyCFunction) api_url_get_auth, METH_VARARGS, "" }, | ||
273 | { "get_host", (PyCFunction) api_url_get_host, METH_VARARGS, "" }, | ||
274 | { "get_path", (PyCFunction) api_url_get_path, METH_VARARGS, "" }, | ||
275 | { "get_query", (PyCFunction) api_url_get_query, METH_VARARGS, "" }, | ||
276 | |||
277 | { NULL, NULL, 0, NULL } | ||
278 | }; | ||
279 | |||
280 | void | ||
281 | init_url () | ||
282 | { | ||
283 | PyObject *m; | ||
284 | |||
285 | PyUrlType.tp_new = PyType_GenericNew; | ||
286 | if (PyType_Ready (&PyUrlType) < 0) | ||
287 | return; | ||
288 | |||
289 | if ((m = attach_module (PY_MODULE, methods))) | ||
290 | { | ||
291 | Py_INCREF (&PyUrlType); | ||
292 | PyModule_AddObject (m, PY_CSNAME, (PyObject *)&PyUrlType); | ||
293 | } | ||
294 | } |
python/c_api/util.c
0 → 100644
1 | /* | ||
2 | GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #include "c_api.h" | ||
22 | #include <mailutils/mutil.h> | ||
23 | |||
24 | #define PY_MODULE "util" | ||
25 | |||
26 | static PyObject * | ||
27 | api_util_get_user_email (PyObject *self, PyObject *args) | ||
28 | { | ||
29 | int status; | ||
30 | char *name = NULL; | ||
31 | char *email = NULL; | ||
32 | |||
33 | if (!PyArg_ParseTuple (args, "|s", &name)) | ||
34 | return NULL; | ||
35 | |||
36 | email = mu_get_user_email (name); | ||
37 | return _ro (PyString_FromString (email ? email : "")); | ||
38 | } | ||
39 | |||
40 | static PyObject * | ||
41 | api_util_set_user_email (PyObject *self, PyObject *args) | ||
42 | { | ||
43 | int status; | ||
44 | char *email; | ||
45 | |||
46 | if (!PyArg_ParseTuple (args, "s", &email)) | ||
47 | return NULL; | ||
48 | |||
49 | status = mu_set_user_email (email); | ||
50 | return _ro (PyInt_FromLong (status)); | ||
51 | } | ||
52 | |||
53 | static PyObject * | ||
54 | api_util_get_user_email_domain (PyObject *self, PyObject *args) | ||
55 | { | ||
56 | int status; | ||
57 | const char *domain = NULL; | ||
58 | |||
59 | status = mu_get_user_email_domain (&domain); | ||
60 | return status_object (status, PyString_FromString (domain ? domain : "")); | ||
61 | } | ||
62 | |||
63 | static PyObject * | ||
64 | api_util_set_user_email_domain (PyObject *self, PyObject *args) | ||
65 | { | ||
66 | int status; | ||
67 | char *domain; | ||
68 | |||
69 | if (!PyArg_ParseTuple (args, "s", &domain)) | ||
70 | return NULL; | ||
71 | |||
72 | status = mu_set_user_email_domain (domain); | ||
73 | return _ro (PyInt_FromLong (status)); | ||
74 | } | ||
75 | |||
76 | static PyObject * | ||
77 | api_util_tempname (PyObject *self, PyObject *args) | ||
78 | { | ||
79 | char *tmpdir = NULL, *tmpname = NULL; | ||
80 | |||
81 | if (!PyArg_ParseTuple (args, "|z", &tmpdir)) | ||
82 | return NULL; | ||
83 | |||
84 | tmpname = mu_tempname (tmpdir); | ||
85 | return _ro (PyString_FromString (tmpname ? tmpname : "")); | ||
86 | } | ||
87 | |||
88 | static PyMethodDef methods[] = { | ||
89 | { "get_user_email", (PyCFunction) api_util_get_user_email, METH_VARARGS, | ||
90 | "Get the default user email address." }, | ||
91 | |||
92 | { "set_user_email", (PyCFunction) api_util_set_user_email, METH_VARARGS, | ||
93 | "Set the default user email address." }, | ||
94 | |||
95 | { "get_user_email_domain", (PyCFunction) api_util_get_user_email_domain, | ||
96 | METH_VARARGS, | ||
97 | "Get the default user email address domain." }, | ||
98 | |||
99 | { "set_user_email_domain", (PyCFunction) api_util_set_user_email_domain, | ||
100 | METH_VARARGS, | ||
101 | "Set the default user email address domain." }, | ||
102 | |||
103 | { "tempname", (PyCFunction) api_util_tempname, | ||
104 | METH_VARARGS, "" }, | ||
105 | |||
106 | { NULL, NULL, 0, NULL } | ||
107 | }; | ||
108 | |||
109 | void | ||
110 | init_util () | ||
111 | { | ||
112 | attach_module (PY_MODULE, methods); | ||
113 | } |
python/mailutils/Makefile.am
0 → 100644
1 | ## Process this file with GNU Automake to create Makefile.in | ||
2 | |||
3 | ## Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | ## | ||
5 | ## GNU Mailutils is free software; you can redistribute it and/or | ||
6 | ## modify it under the terms of the GNU General Public License as | ||
7 | ## published by the Free Software Foundation; either version 3, or (at | ||
8 | ## your option) any later version. | ||
9 | ## | ||
10 | ## This program is distributed in the hope that it will be useful, but | ||
11 | ## WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | ## General Public License for more details. | ||
14 | ## | ||
15 | ## You should have received a copy of the GNU General Public License | ||
16 | ## along with this program; if not, write to the Free Software | ||
17 | ## Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA | ||
18 | ## 02110-1301 USA | ||
19 | |||
20 | pkgpython_PYTHON = \ | ||
21 | __init__.py \ | ||
22 | error.py \ | ||
23 | address.py \ | ||
24 | attribute.py \ | ||
25 | auth.py \ | ||
26 | body.py \ | ||
27 | debug.py \ | ||
28 | envelope.py \ | ||
29 | filter.py \ | ||
30 | folder.py \ | ||
31 | header.py \ | ||
32 | mailer.py \ | ||
33 | mailbox.py \ | ||
34 | mailcap.py \ | ||
35 | message.py \ | ||
36 | mime.py \ | ||
37 | registrar.py \ | ||
38 | stream.py \ | ||
39 | url.py \ | ||
40 | util.py | ||
41 |
python/mailutils/__init__.py
0 → 100644
1 | # GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | # Copyright (C) 2009 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License as published by | ||
6 | # the Free Software Foundation; either version 3, or (at your option) | ||
7 | # any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | # GNU General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils; if not, write to the Free Software | ||
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
17 | # MA 02110-1301 USA | ||
18 | |||
19 | __all__ = [ | ||
20 | "error", | ||
21 | "address", | ||
22 | "attribute", | ||
23 | "auth", | ||
24 | "body", | ||
25 | "debug", | ||
26 | "envelope", | ||
27 | "filter", | ||
28 | "folder", | ||
29 | "header", | ||
30 | "mailer", | ||
31 | "mailbox", | ||
32 | "mailcap", | ||
33 | "message", | ||
34 | "mime", | ||
35 | "registrar", | ||
36 | "stream", | ||
37 | "url", | ||
38 | "util", | ||
39 | ] |
python/mailutils/address.py
0 → 100644
1 | # | ||
2 | # GNU Mailutils -- a suite of utilities for electronic mail | ||
3 | # Copyright (C) 2009 Free Software Foundation, Inc. | ||
4 | # | ||
5 | # This library is free software; you can redistribute it and/or | ||
6 | # modify it under the terms of the GNU Lesser General Public | ||
7 | # License as published by the Free Software Foundation; either | ||
8 | # version 3 of the License, or (at your option) any later version. | ||
9 | # | ||
10 | # This library is distributed in the hope that it will be useful, | ||
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | # Lesser General Public License for more details. | ||
14 | # | ||
15 | # You should have received a copy of the GNU Lesser General | ||
16 | # Public License along with this library; if not, write to the | ||
17 | # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | # Boston, MA 02110-1301 USA | ||
19 | # | ||
20 | |||
21 | import types | ||
22 | from mailutils.c_api import address | ||
23 | from mailutils.error import AddressError | ||
24 | |||
25 | class Address: | ||
26 | def __init__ (self, addr): | ||
27 | self.addr = address.AddressType () | ||
28 | if isinstance (addr, types.ListType): | ||
29 | status = address.createv (self.addr, addr) | ||
30 | else: | ||
31 | status = address.create (self.addr, addr) | ||
32 | if status: | ||
33 | raise AddressError (status) | ||
34 | |||
35 | def __del__ (self): | ||
36 | address.destroy (self.addr) | ||
37 | del self.addr | ||
38 | |||
39 | def __len__ (self): | ||
40 | return self.get_count () | ||
41 | |||
42 | def __str__ (self): | ||
43 | status, str = address.to_string (self.addr) | ||
44 | if status: | ||
45 | raise AddressError (status) | ||
46 | return str | ||
47 | |||
48 | def __iter__ (self): | ||
49 | self.__count = 0 | ||
50 | self.__len = self.get_count () | ||
51 | return self | ||
52 | |||
53 | def next (self): | ||
54 | if self.__count >= self.__len: | ||
55 | self.__count = 0 | ||
56 | raise StopIteration | ||
57 | else: | ||
58 | self.__count += 1 | ||
59 | return self.get_email (self.__count) | ||
60 | |||
61 | def is_group (self, n): | ||
62 | """Return True if this address is just the name of a group, | ||
63 | False otherwise.""" | ||
64 | status, isgroup = address.is_group (self.addr, n) | ||
65 | if status: | ||
66 | raise AddressError (status) | ||
67 | return isgroup | ||
68 | |||
69 | def get_count (self): | ||
70 | """Return a count of the addresses in the address list.""" | ||
71 | return address.get_count (self.addr) | ||
72 | |||
73 | def get_email (self, n): | ||
74 | """Return email part of the Nth email address.""" | ||
75 | status, email = address.get_email (self.addr, n) | ||
76 | if status: | ||
77 | raise AddressError (status) | ||
78 | return email | ||
79 | |||
80 | def get_local_part (self, n): | ||
81 | """Return local part of the Nth email address.""" | ||
82 | status, local_part = address.get_local_part (self.addr, n) | ||
83 | if status: | ||
84 | raise AddressError (status) | ||
85 | return local_part | ||
86 | |||
87 | def get_domain (self, n): | ||
88 | """Return domain part of the Nth email address.""" | ||
89 | status, domain = address.get_domain (self.addr, n) | ||
90 | if status: | ||
91 | raise AddressError (status) | ||
92 | return domain | ||
93 | |||
94 | def get_personal (self, n): | ||
95 | """Return personal part of the Nth email address.""" | ||
96 | status, personal = address.get_personal (self.addr, n) | ||
97 | if status: | ||
98 | raise AddressError (status) | ||
99 | return personal | ||
100 | |||
101 | def get_comments (self, n): | ||
102 | """Return comment part of the Nth email address.""" | ||
103 | status, comments = address.get_comments (self.addr, n) | ||
104 | if status: | ||
105 | raise AddressError (status) | ||
106 | return comments | ||
107 | |||
108 | def get_route (self, n): | ||
109 | """Return the route part of the Nth email address.""" | ||
110 | status, route = address.get_route (self.addr, n) | ||
111 | if status: | ||
112 | raise AddressError (status) | ||
113 | return route |
python/mailutils/attribute.py
0 → 100644
This diff is collapsed.
Click to expand it.
python/mailutils/auth.py
0 → 100644
This diff is collapsed.
Click to expand it.
python/mailutils/body.py
0 → 100644
This diff is collapsed.
Click to expand it.
python/mailutils/debug.py
0 → 100644
This diff is collapsed.
Click to expand it.
python/mailutils/envelope.py
0 → 100644
This diff is collapsed.
Click to expand it.
python/mailutils/error.py
0 → 100644
This diff is collapsed.
Click to expand it.
python/mailutils/filter.py
0 → 100644
This diff is collapsed.
Click to expand it.
python/mailutils/folder.py
0 → 100644
This diff is collapsed.
Click to expand it.
python/mailutils/header.py
0 → 100644
This diff is collapsed.
Click to expand it.
python/mailutils/mailbox.py
0 → 100644
This diff is collapsed.
Click to expand it.
python/mailutils/mailcap.py
0 → 100644
This diff is collapsed.
Click to expand it.
python/mailutils/mailer.py
0 → 100644
This diff is collapsed.
Click to expand it.
python/mailutils/message.py
0 → 100644
This diff is collapsed.
Click to expand it.
python/mailutils/mime.py
0 → 100644
This diff is collapsed.
Click to expand it.
python/mailutils/registrar.py
0 → 100644
This diff is collapsed.
Click to expand it.
python/mailutils/stream.py
0 → 100644
This diff is collapsed.
Click to expand it.
python/mailutils/url.py
0 → 100644
This diff is collapsed.
Click to expand it.
python/mailutils/util.py
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
-
Please register or sign in to post a comment