Remove the leftovers of mu_debug_t and obsoleted sieve interfaces.
* include/mailutils/cpp/debug.h: Remove. * include/mailutils/cpp/Makefile.am (cppinclude_HEADERS): Remove debug.h * libmu_cpp/debug.cc: Remove * libmu_cpp/Makefile.am (libmu_cpp_la_SOURCES): Remove debug.cc. * python/libmu_py/debug.c: Remove. * python/libmu_py/Makefile.am (libmu_py_la_SOURCES): Remove debug.c * include/mailutils/cpp/mailbox.h: Remove objects and methods derived from mu_debug_t. * include/mailutils/cpp/mailer.h: Likewise. * include/mailutils/cpp/stream.h: Likewise. * libmu_cpp/mailbox.cc: Likewise. * libmu_cpp/mailer.cc: Likewise. * libmu_cpp/sieve.cc: Likewise. Ditto for mu_sieve_printf_t, mu_sieve_parse_error_t. * include/mailutils/cpp/sieve.h: Likewise. * libmu_cpp/stream.cc: Remove objects and methods derived from mu_debug_t. (ProgStream::ProgStream): Use mu_command_stream_create (see FIXME). (FilterProgStream::FilterProgStream): Rewrite. * include/mailutils/python.h: Remove objects and methods derived from mu_debug_t. * python/libmu_py/filter.c (api_filter_iconv_create): Rewrite using mu_filter_create_args. * python/libmu_py/libmu_py.c: Likewise. * python/libmu_py/libmu_py.h: Likewise. * python/libmu_py/mailbox.c: Likewise. * python/libmu_py/mailer.c: Likewise. * python/libmu_py/stream.c: Likewise. * python/libmu_py/url.c: Likewise. * python/libmu_py/sieve.c: Likewise. Same for mu_sieve_printf_t, mu_sieve_parse_error_t.
Showing
23 changed files
with
94 additions
and
607 deletions
include/mailutils/cpp/debug.h
deleted
100644 → 0
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2009, 2010 Free Software Foundation, Inc. | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 3 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library 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 GNU | ||
12 | Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Lesser General | ||
15 | Public License along with this library. If not, see | ||
16 | <http://www.gnu.org/licenses/>. */ | ||
17 | |||
18 | #ifndef _MUCPP_DEBUG_H | ||
19 | #define _MUCPP_DEBUG_H | ||
20 | |||
21 | #include <string> | ||
22 | #include <errno.h> | ||
23 | #include <mailutils/debug.h> | ||
24 | #include <mailutils/cpp/error.h> | ||
25 | |||
26 | namespace mailutils | ||
27 | { | ||
28 | |||
29 | class Debug | ||
30 | { | ||
31 | protected: | ||
32 | mu_debug_t debug; | ||
33 | |||
34 | public: | ||
35 | Debug (); | ||
36 | Debug (const mu_debug_t); | ||
37 | |||
38 | void set_level (const mu_log_level_t level); | ||
39 | }; | ||
40 | |||
41 | } | ||
42 | |||
43 | #endif // not _MUCPP_DEBUG_H | ||
44 |
... | @@ -22,7 +22,6 @@ | ... | @@ -22,7 +22,6 @@ |
22 | #include <errno.h> | 22 | #include <errno.h> |
23 | #include <mailutils/mailbox.h> | 23 | #include <mailutils/mailbox.h> |
24 | #include <mailutils/cpp/error.h> | 24 | #include <mailutils/cpp/error.h> |
25 | #include <mailutils/cpp/debug.h> | ||
26 | #include <mailutils/cpp/folder.h> | 25 | #include <mailutils/cpp/folder.h> |
27 | #include <mailutils/cpp/message.h> | 26 | #include <mailutils/cpp/message.h> |
28 | #include <mailutils/cpp/url.h> | 27 | #include <mailutils/cpp/url.h> |
... | @@ -54,7 +53,6 @@ class MailboxBase | ... | @@ -54,7 +53,6 @@ class MailboxBase |
54 | void unlock (); | 53 | void unlock (); |
55 | mu_off_t get_size (); | 54 | mu_off_t get_size (); |
56 | 55 | ||
57 | Debug& get_debug (); | ||
58 | Folder& get_folder (); | 56 | Folder& get_folder (); |
59 | Url& get_url (); | 57 | Url& get_url (); |
60 | 58 | ... | ... |
... | @@ -22,7 +22,6 @@ | ... | @@ -22,7 +22,6 @@ |
22 | #include <string> | 22 | #include <string> |
23 | #include <errno.h> | 23 | #include <errno.h> |
24 | #include <mailutils/mailer.h> | 24 | #include <mailutils/mailer.h> |
25 | #include <mailutils/cpp/debug.h> | ||
26 | #include <mailutils/cpp/message.h> | 25 | #include <mailutils/cpp/message.h> |
27 | #include <mailutils/cpp/address.h> | 26 | #include <mailutils/cpp/address.h> |
28 | 27 | ||
... | @@ -45,7 +44,6 @@ class Mailer | ... | @@ -45,7 +44,6 @@ class Mailer |
45 | void send_message (const Message& msg, const Address& from, | 44 | void send_message (const Message& msg, const Address& from, |
46 | const Address& to); | 45 | const Address& to); |
47 | 46 | ||
48 | Debug& get_debug (); | ||
49 | }; | 47 | }; |
50 | 48 | ||
51 | } | 49 | } | ... | ... |
... | @@ -44,9 +44,6 @@ class SieveMachine | ... | @@ -44,9 +44,6 @@ class SieveMachine |
44 | void disass (); | 44 | void disass (); |
45 | void mailbox (const Mailbox& mbox); | 45 | void mailbox (const Mailbox& mbox); |
46 | void message (const Message& msg); | 46 | void message (const Message& msg); |
47 | void set_debug (mu_sieve_printf_t printer); | ||
48 | void set_error (mu_sieve_printf_t printer); | ||
49 | void set_parse_error (mu_sieve_parse_error_t printer); | ||
50 | void set_logger (mu_sieve_action_log_t printer); | 47 | void set_logger (mu_sieve_action_log_t printer); |
51 | }; | 48 | }; |
52 | 49 | ... | ... |
... | @@ -22,6 +22,8 @@ | ... | @@ -22,6 +22,8 @@ |
22 | #include <string> | 22 | #include <string> |
23 | #include <errno.h> | 23 | #include <errno.h> |
24 | #include <mailutils/stream.h> | 24 | #include <mailutils/stream.h> |
25 | #include <mailutils/prog.h> | ||
26 | #include <mailutils/wordsplit.h> | ||
25 | #include <mailutils/cpp/error.h> | 27 | #include <mailutils/cpp/error.h> |
26 | 28 | ||
27 | namespace mailutils | 29 | namespace mailutils | ... | ... |
... | @@ -69,12 +69,6 @@ typedef struct | ... | @@ -69,12 +69,6 @@ typedef struct |
69 | typedef struct | 69 | typedef struct |
70 | { | 70 | { |
71 | PyObject_HEAD; | 71 | PyObject_HEAD; |
72 | mu_debug_t dbg; | ||
73 | } PyDebug; | ||
74 | |||
75 | typedef struct | ||
76 | { | ||
77 | PyObject_HEAD; | ||
78 | mu_envelope_t env; | 72 | mu_envelope_t env; |
79 | } PyEnvelope; | 73 | } PyEnvelope; |
80 | 74 | ||
... | @@ -158,7 +152,6 @@ extern int mu_py_init_address (void); | ... | @@ -158,7 +152,6 @@ extern int mu_py_init_address (void); |
158 | extern int mu_py_init_attribute (void); | 152 | extern int mu_py_init_attribute (void); |
159 | extern int mu_py_init_auth (void); | 153 | extern int mu_py_init_auth (void); |
160 | extern int mu_py_init_body (void); | 154 | extern int mu_py_init_body (void); |
161 | extern int mu_py_init_debug (void); | ||
162 | extern int mu_py_init_envelope (void); | 155 | extern int mu_py_init_envelope (void); |
163 | extern int mu_py_init_header (void); | 156 | extern int mu_py_init_header (void); |
164 | extern int mu_py_init_folder (void); | 157 | extern int mu_py_init_folder (void); |
... | @@ -182,7 +175,6 @@ extern PyTicket * PyTicket_NEW (); | ... | @@ -182,7 +175,6 @@ extern PyTicket * PyTicket_NEW (); |
182 | extern PyWicket * PyWicket_NEW (); | 175 | extern PyWicket * PyWicket_NEW (); |
183 | extern PyAuthData * PyAuthData_NEW (); | 176 | extern PyAuthData * PyAuthData_NEW (); |
184 | extern PyBody * PyBody_NEW (); | 177 | extern PyBody * PyBody_NEW (); |
185 | extern PyDebug * PyDebug_NEW (); | ||
186 | extern PyEnvelope * PyEnvelope_NEW (); | 178 | extern PyEnvelope * PyEnvelope_NEW (); |
187 | extern PyFolder * PyFolder_NEW (); | 179 | extern PyFolder * PyFolder_NEW (); |
188 | extern PyHeader * PyHeader_NEW (); | 180 | extern PyHeader * PyHeader_NEW (); |
... | @@ -223,9 +215,6 @@ extern void mu_py_script_finish (void); | ... | @@ -223,9 +215,6 @@ extern void mu_py_script_finish (void); |
223 | extern int mu_py_script_run (const char *filename, | 215 | extern int mu_py_script_run (const char *filename, |
224 | mu_py_script_data *data); | 216 | mu_py_script_data *data); |
225 | 217 | ||
226 | extern void mu_py_capture_stdout (mu_debug_t debug); | ||
227 | extern void mu_py_capture_stderr (mu_debug_t debug); | ||
228 | |||
229 | extern int mu_py_script_process_mailbox (int argc, char *argv[], | 218 | extern int mu_py_script_process_mailbox (int argc, char *argv[], |
230 | const char *python_filename, | 219 | const char *python_filename, |
231 | const char *module_name, | 220 | const char *module_name, | ... | ... |
libmu_cpp/debug.cc
deleted
100644 → 0
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2009, 2010 Free Software Foundation, Inc. | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 3 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library 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 GNU | ||
12 | Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Lesser General | ||
15 | Public License along with this library. If not, see | ||
16 | <http://www.gnu.org/licenses/>. */ | ||
17 | |||
18 | #include <mailutils/cpp/debug.h> | ||
19 | |||
20 | using namespace mailutils; | ||
21 | |||
22 | // | ||
23 | // Debug | ||
24 | // | ||
25 | |||
26 | Debug :: Debug () | ||
27 | { | ||
28 | this->debug = NULL; | ||
29 | } | ||
30 | |||
31 | Debug :: Debug (const mu_debug_t debug) | ||
32 | { | ||
33 | if (debug == 0) | ||
34 | throw Exception ("Debug::Debug", EINVAL); | ||
35 | |||
36 | this->debug = debug; | ||
37 | } | ||
38 | |||
39 | void | ||
40 | Debug :: set_level (const mu_log_level_t level) | ||
41 | { | ||
42 | int status = mu_debug_set_level (debug, level); | ||
43 | if (status) | ||
44 | throw Exception ("Debug::set_level", status); | ||
45 | } | ||
46 |
... | @@ -160,18 +160,6 @@ MailboxBase :: get_size () | ... | @@ -160,18 +160,6 @@ MailboxBase :: get_size () |
160 | return size; | 160 | return size; |
161 | } | 161 | } |
162 | 162 | ||
163 | Debug& | ||
164 | MailboxBase :: get_debug () | ||
165 | { | ||
166 | mu_debug_t c_dbg; | ||
167 | |||
168 | int status = mu_mailbox_get_debug (mbox, &c_dbg); | ||
169 | if (status) | ||
170 | throw Exception ("MailboxBase::get_debug", status); | ||
171 | |||
172 | return *new Debug (c_dbg); | ||
173 | } | ||
174 | |||
175 | Folder& | 163 | Folder& |
176 | MailboxBase :: get_folder () | 164 | MailboxBase :: get_folder () |
177 | { | 165 | { | ... | ... |
... | @@ -78,15 +78,3 @@ Mailer :: send_message (const Message& msg, const Address& from, | ... | @@ -78,15 +78,3 @@ Mailer :: send_message (const Message& msg, const Address& from, |
78 | throw Exception ("Mailer::send_message", status); | 78 | throw Exception ("Mailer::send_message", status); |
79 | } | 79 | } |
80 | 80 | ||
81 | Debug& | ||
82 | Mailer :: get_debug () | ||
83 | { | ||
84 | mu_debug_t c_dbg; | ||
85 | |||
86 | int status = mu_mailer_get_debug (mailer, &c_dbg); | ||
87 | if (status) | ||
88 | throw Exception ("Mailer::get_debug", status); | ||
89 | |||
90 | return *new Debug (c_dbg); | ||
91 | } | ||
92 | ... | ... |
... | @@ -25,7 +25,7 @@ using namespace mailutils; | ... | @@ -25,7 +25,7 @@ using namespace mailutils; |
25 | 25 | ||
26 | SieveMachine :: SieveMachine () | 26 | SieveMachine :: SieveMachine () |
27 | { | 27 | { |
28 | int status = mu_sieve_machine_init (&mach, NULL); | 28 | int status = mu_sieve_machine_init (&mach); |
29 | if (status) | 29 | if (status) |
30 | throw Exception ("SieveMachine::SieveMachine", status); | 30 | throw Exception ("SieveMachine::SieveMachine", status); |
31 | } | 31 | } |
... | @@ -88,27 +88,4 @@ SieveMachine :: message (const Message& msg) | ... | @@ -88,27 +88,4 @@ SieveMachine :: message (const Message& msg) |
88 | throw Exception ("SieveMachine::message", status); | 88 | throw Exception ("SieveMachine::message", status); |
89 | } | 89 | } |
90 | 90 | ||
91 | void | ||
92 | SieveMachine :: set_debug (mu_sieve_printf_t printer) | ||
93 | { | ||
94 | mu_sieve_set_debug (mach, printer); | ||
95 | } | ||
96 | |||
97 | void | ||
98 | SieveMachine :: set_error (mu_sieve_printf_t printer) | ||
99 | { | ||
100 | mu_sieve_set_error (mach, printer); | ||
101 | } | ||
102 | |||
103 | void | ||
104 | SieveMachine :: set_parse_error (mu_sieve_parse_error_t printer) | ||
105 | { | ||
106 | mu_sieve_set_parse_error (mach, printer); | ||
107 | } | ||
108 | |||
109 | void | ||
110 | SieveMachine :: set_logger (mu_sieve_action_log_t printer) | ||
111 | { | ||
112 | mu_sieve_set_logger (mach, printer); | ||
113 | } | ||
114 | 91 | ... | ... |
... | @@ -211,11 +211,13 @@ StdioStream :: StdioStream (int fd, int flags) | ... | @@ -211,11 +211,13 @@ StdioStream :: StdioStream (int fd, int flags) |
211 | 211 | ||
212 | // | 212 | // |
213 | // ProgStream | 213 | // ProgStream |
214 | // | 214 | /* FIXME: This must be revised using the real prog_stream interface, instead |
215 | of the command_stream | ||
216 | */ | ||
215 | 217 | ||
216 | ProgStream :: ProgStream (const std::string& progname, int flags) | 218 | ProgStream :: ProgStream (const std::string& progname, int flags) |
217 | { | 219 | { |
218 | int status = mu_prog_stream_create (&stm, progname.c_str (), flags); | 220 | int status = mu_command_stream_create (&stm, progname.c_str (), flags); |
219 | if (status) | 221 | if (status) |
220 | throw Exception ("ProgStream::ProgStream", status); | 222 | throw Exception ("ProgStream::ProgStream", status); |
221 | } | 223 | } |
... | @@ -227,20 +229,28 @@ ProgStream :: ProgStream (const std::string& progname, int flags) | ... | @@ -227,20 +229,28 @@ ProgStream :: ProgStream (const std::string& progname, int flags) |
227 | FilterProgStream :: FilterProgStream (const std::string& progname, | 229 | FilterProgStream :: FilterProgStream (const std::string& progname, |
228 | Stream& input) | 230 | Stream& input) |
229 | { | 231 | { |
230 | int status = mu_filter_prog_stream_create (&stm, progname.c_str (), | 232 | struct mu_prog_hints hints; |
231 | input.stm); | 233 | struct mu_wordsplit ws; |
232 | this->input = new Stream (input); | 234 | int status; |
235 | |||
236 | if (mu_wordsplit (progname.c_str (), &ws, MU_WRDSF_DEFFLAGS)) | ||
237 | throw Exception ("FilterProgStream::FilterProgStream", errno); | ||
238 | |||
239 | hints.mu_prog_input = input.stm; | ||
240 | status = mu_prog_stream_create (&stm, ws.ws_wordv[0], | ||
241 | ws.ws_wordc, ws.ws_wordv, | ||
242 | MU_PROG_HINT_INPUT, | ||
243 | &hints, | ||
244 | MU_STREAM_READ); | ||
245 | mu_wordsplit_free (&ws); | ||
233 | if (status) | 246 | if (status) |
234 | throw Exception ("FilterProgStream::FilterProgStream", status); | 247 | throw Exception ("FilterProgStream::FilterProgStream", status); |
248 | this->input = new Stream (input); | ||
235 | } | 249 | } |
236 | 250 | ||
237 | FilterProgStream :: FilterProgStream (const std::string& progname, | 251 | FilterProgStream :: FilterProgStream (const std::string& progname, |
238 | Stream* input) | 252 | Stream* input) |
239 | { | 253 | { |
240 | int status = mu_filter_prog_stream_create (&stm, progname.c_str (), | 254 | FilterProgStream (progname, input); |
241 | input->stm); | ||
242 | this->input = new Stream (*input); | ||
243 | if (status) | ||
244 | throw Exception ("FilterProgStream::FilterProgStream", status); | ||
245 | } | 255 | } |
246 | 256 | ... | ... |
python/libmu_py/debug.c
deleted
100644 → 0
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2009, 2010 Free Software Foundation, Inc. | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 3 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library 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 GNU | ||
12 | Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Lesser General | ||
15 | Public License along with this library. If not, see | ||
16 | <http://www.gnu.org/licenses/>. */ | ||
17 | |||
18 | #include "libmu_py.h" | ||
19 | |||
20 | #define PY_MODULE "debug" | ||
21 | #define PY_CSNAME "DebugType" | ||
22 | |||
23 | static PyObject * | ||
24 | _repr (PyObject *self) | ||
25 | { | ||
26 | char buf[80]; | ||
27 | sprintf (buf, "<" PY_MODULE "." PY_CSNAME " instance at %p>", self); | ||
28 | return PyString_FromString (buf); | ||
29 | } | ||
30 | |||
31 | static PyTypeObject PyDebugType = { | ||
32 | PyObject_HEAD_INIT(NULL) | ||
33 | 0, /* ob_size */ | ||
34 | PY_MODULE "." PY_CSNAME, /* tp_name */ | ||
35 | sizeof (PyDebug), /* tp_basicsize */ | ||
36 | 0, /* tp_itemsize */ | ||
37 | (destructor)_py_dealloc, /* tp_dealloc */ | ||
38 | 0, /* tp_print */ | ||
39 | 0, /* tp_getattr; __getattr__ */ | ||
40 | 0, /* tp_setattr; __setattr__ */ | ||
41 | 0, /* tp_compare; __cmp__ */ | ||
42 | _repr, /* tp_repr; __repr__ */ | ||
43 | 0, /* tp_as_number */ | ||
44 | 0, /* tp_as_sequence */ | ||
45 | 0, /* tp_as_mapping */ | ||
46 | 0, /* tp_hash; __hash__ */ | ||
47 | 0, /* tp_call; __call__ */ | ||
48 | _repr, /* tp_str; __str__ */ | ||
49 | 0, /* tp_getattro */ | ||
50 | 0, /* tp_setattro */ | ||
51 | 0, /* tp_as_buffer */ | ||
52 | Py_TPFLAGS_DEFAULT, /* tp_flags */ | ||
53 | "", /* tp_doc */ | ||
54 | 0, /* tp_traverse */ | ||
55 | 0, /* tp_clear */ | ||
56 | 0, /* tp_richcompare */ | ||
57 | 0, /* tp_weaklistoffset */ | ||
58 | 0, /* tp_iter */ | ||
59 | 0, /* tp_iternext */ | ||
60 | 0, /* tp_methods */ | ||
61 | 0, /* tp_members */ | ||
62 | 0, /* tp_getset */ | ||
63 | 0, /* tp_base */ | ||
64 | 0, /* tp_dict */ | ||
65 | 0, /* tp_descr_get */ | ||
66 | 0, /* tp_descr_set */ | ||
67 | 0, /* tp_dictoffset */ | ||
68 | 0, /* tp_init */ | ||
69 | 0, /* tp_alloc */ | ||
70 | 0, /* tp_new */ | ||
71 | }; | ||
72 | |||
73 | PyDebug * | ||
74 | PyDebug_NEW () | ||
75 | { | ||
76 | return (PyDebug *)PyObject_NEW (PyDebug, &PyDebugType); | ||
77 | } | ||
78 | |||
79 | static PyObject * | ||
80 | api_debug_set_level (PyObject *self, PyObject *args) | ||
81 | { | ||
82 | int status, level; | ||
83 | PyDebug *py_dbg; | ||
84 | |||
85 | if (!PyArg_ParseTuple (args, "O!i", &PyDebugType, &py_dbg, &level)) | ||
86 | return NULL; | ||
87 | |||
88 | status = mu_debug_set_level (py_dbg->dbg, | ||
89 | MU_DEBUG_LEVEL_UPTO (level)); | ||
90 | return _ro (PyInt_FromLong (status)); | ||
91 | } | ||
92 | |||
93 | static PyMethodDef methods[] = { | ||
94 | { "set_level", (PyCFunction) api_debug_set_level, METH_VARARGS, | ||
95 | "" }, | ||
96 | |||
97 | { NULL, NULL, 0, NULL } | ||
98 | }; | ||
99 | |||
100 | static mu_debug_t _mu_prog_debug_stdout; | ||
101 | static mu_debug_t _mu_prog_debug_stderr; | ||
102 | |||
103 | static PyObject * | ||
104 | _capture_stdout (PyObject *self, PyObject *args) | ||
105 | { | ||
106 | char *buf = ""; | ||
107 | if (!PyArg_ParseTuple (args, "s", &buf)) | ||
108 | return NULL; | ||
109 | if (_mu_prog_debug_stdout) | ||
110 | mu_debug_printf (_mu_prog_debug_stdout, MU_DIAG_INFO, "%.*s", | ||
111 | (int) strlen (buf), buf); | ||
112 | return _ro (Py_None); | ||
113 | } | ||
114 | |||
115 | static PyObject * | ||
116 | _capture_stderr (PyObject *self, PyObject *args) | ||
117 | { | ||
118 | char *buf = ""; | ||
119 | if (!PyArg_ParseTuple (args, "s", &buf)) | ||
120 | return NULL; | ||
121 | if (_mu_prog_debug_stderr) | ||
122 | mu_debug_printf (_mu_prog_debug_stderr, MU_DIAG_ERROR, "%.*s", | ||
123 | (int) strlen (buf), buf); | ||
124 | return _ro (Py_None); | ||
125 | } | ||
126 | |||
127 | static PyMethodDef capture_stdout_method[] = | ||
128 | { | ||
129 | { "write", _capture_stdout, 1 }, | ||
130 | { NULL, NULL, 0, NULL } | ||
131 | }; | ||
132 | |||
133 | static PyMethodDef capture_stderr_method[] = | ||
134 | { | ||
135 | { "write", _capture_stderr, 1 }, | ||
136 | { NULL, NULL, 0, NULL } | ||
137 | }; | ||
138 | |||
139 | void | ||
140 | mu_py_capture_stdout (mu_debug_t debug) | ||
141 | { | ||
142 | PyObject *py_out; | ||
143 | _mu_prog_debug_stdout = debug; | ||
144 | py_out = Py_InitModule ("stdout", capture_stdout_method); | ||
145 | if (py_out) | ||
146 | PySys_SetObject ("stdout", py_out); | ||
147 | } | ||
148 | |||
149 | void | ||
150 | mu_py_capture_stderr (mu_debug_t debug) | ||
151 | { | ||
152 | PyObject *py_err; | ||
153 | _mu_prog_debug_stderr = debug; | ||
154 | py_err = Py_InitModule ("stderr", capture_stderr_method); | ||
155 | if (py_err) | ||
156 | PySys_SetObject ("stderr", py_err); | ||
157 | } | ||
158 | |||
159 | int | ||
160 | mu_py_init_debug (void) | ||
161 | { | ||
162 | PyDebugType.tp_new = PyType_GenericNew; | ||
163 | return PyType_Ready (&PyDebugType); | ||
164 | } | ||
165 | |||
166 | void | ||
167 | _mu_py_attach_debug (void) | ||
168 | { | ||
169 | PyObject *m; | ||
170 | if ((m = _mu_py_attach_module (PY_MODULE, methods))) | ||
171 | { | ||
172 | Py_INCREF (&PyDebugType); | ||
173 | PyModule_AddObject (m, PY_CSNAME, (PyObject *)&PyDebugType); | ||
174 | } | ||
175 | } |
... | @@ -50,7 +50,8 @@ api_filter_iconv_create (PyObject *self, PyObject *args) | ... | @@ -50,7 +50,8 @@ api_filter_iconv_create (PyObject *self, PyObject *args) |
50 | char *fromcode = NULL; | 50 | char *fromcode = NULL; |
51 | char *tocode = NULL; | 51 | char *tocode = NULL; |
52 | PyStream *py_stm, *py_transport; | 52 | PyStream *py_stm, *py_transport; |
53 | 53 | const char *argv[4] = { "iconv", NULL, NULL, NULL }; | |
54 | |||
54 | if (!PyArg_ParseTuple (args, "OOssi", | 55 | if (!PyArg_ParseTuple (args, "OOssi", |
55 | &py_stm, &py_transport, | 56 | &py_stm, &py_transport, |
56 | &fromcode, &tocode, &flags)) | 57 | &fromcode, &tocode, &flags)) |
... | @@ -63,9 +64,10 @@ api_filter_iconv_create (PyObject *self, PyObject *args) | ... | @@ -63,9 +64,10 @@ api_filter_iconv_create (PyObject *self, PyObject *args) |
63 | return NULL; | 64 | return NULL; |
64 | } | 65 | } |
65 | 66 | ||
66 | status = mu_filter_iconv_create (&py_stm->stm, py_transport->stm, | 67 | argv[1] = fromcode; |
67 | fromcode, tocode, flags, | 68 | argv[2] = tocode; |
68 | mu_fallback_none); | 69 | mu_filter_create_args (&py_stm->stm, py_transport->stm, argv[0], 3, argv, |
70 | MU_FILTER_DECODE, flags); | ||
69 | return _ro (PyInt_FromLong (status)); | 71 | return _ro (PyInt_FromLong (status)); |
70 | } | 72 | } |
71 | 73 | ... | ... |
... | @@ -72,7 +72,6 @@ mu_py_init (void) | ... | @@ -72,7 +72,6 @@ mu_py_init (void) |
72 | mu_py_init_attribute (); | 72 | mu_py_init_attribute (); |
73 | mu_py_init_auth (); | 73 | mu_py_init_auth (); |
74 | mu_py_init_body (); | 74 | mu_py_init_body (); |
75 | mu_py_init_debug (); | ||
76 | mu_py_init_envelope (); | 75 | mu_py_init_envelope (); |
77 | mu_py_init_header (); | 76 | mu_py_init_header (); |
78 | mu_py_init_folder (); | 77 | mu_py_init_folder (); | ... | ... |
... | @@ -45,6 +45,8 @@ | ... | @@ -45,6 +45,8 @@ |
45 | #include <mailutils/stream.h> | 45 | #include <mailutils/stream.h> |
46 | #include <mailutils/url.h> | 46 | #include <mailutils/url.h> |
47 | #include <mailutils/python.h> | 47 | #include <mailutils/python.h> |
48 | #include <mailutils/wordsplit.h> | ||
49 | #include <mailutils/prog.h> | ||
48 | 50 | ||
49 | #define PY_PACKAGE_NAME "mailutils" | 51 | #define PY_PACKAGE_NAME "mailutils" |
50 | #define PY_ROOT_NAME "c_api" | 52 | #define PY_ROOT_NAME "c_api" | ... | ... |
... | @@ -340,22 +340,6 @@ api_mailbox_get_size (PyObject *self, PyObject *args) | ... | @@ -340,22 +340,6 @@ api_mailbox_get_size (PyObject *self, PyObject *args) |
340 | } | 340 | } |
341 | 341 | ||
342 | static PyObject * | 342 | static PyObject * |
343 | api_mailbox_get_debug (PyObject *self, PyObject *args) | ||
344 | { | ||
345 | int status; | ||
346 | PyMailbox *py_mbox; | ||
347 | PyDebug *py_dbg = PyDebug_NEW (); | ||
348 | |||
349 | if (!PyArg_ParseTuple (args, "O!", &PyMailboxType, &py_mbox)) | ||
350 | return NULL; | ||
351 | |||
352 | status = mu_mailbox_get_debug (py_mbox->mbox, &py_dbg->dbg); | ||
353 | |||
354 | Py_INCREF (py_dbg); | ||
355 | return status_object (status, (PyObject *)py_dbg); | ||
356 | } | ||
357 | |||
358 | static PyObject * | ||
359 | api_mailbox_get_folder (PyObject *self, PyObject *args) | 343 | api_mailbox_get_folder (PyObject *self, PyObject *args) |
360 | { | 344 | { |
361 | int status; | 345 | int status; |
... | @@ -444,9 +428,6 @@ static PyMethodDef methods[] = { | ... | @@ -444,9 +428,6 @@ static PyMethodDef methods[] = { |
444 | { "get_size", (PyCFunction) api_mailbox_get_size, METH_VARARGS, | 428 | { "get_size", (PyCFunction) api_mailbox_get_size, METH_VARARGS, |
445 | "" }, | 429 | "" }, |
446 | 430 | ||
447 | { "get_debug", (PyCFunction) api_mailbox_get_debug, METH_VARARGS, | ||
448 | "" }, | ||
449 | |||
450 | { "get_folder", (PyCFunction) api_mailbox_get_folder, METH_VARARGS, | 431 | { "get_folder", (PyCFunction) api_mailbox_get_folder, METH_VARARGS, |
451 | "" }, | 432 | "" }, |
452 | 433 | ... | ... |
... | @@ -168,22 +168,6 @@ api_mailer_send_message (PyObject *self, PyObject *args) | ... | @@ -168,22 +168,6 @@ api_mailer_send_message (PyObject *self, PyObject *args) |
168 | return _ro (PyInt_FromLong (status)); | 168 | return _ro (PyInt_FromLong (status)); |
169 | } | 169 | } |
170 | 170 | ||
171 | static PyObject * | ||
172 | api_mailer_get_debug (PyObject *self, PyObject *args) | ||
173 | { | ||
174 | int status; | ||
175 | PyMailer *py_mlr; | ||
176 | PyDebug *py_dbg = PyDebug_NEW (); | ||
177 | |||
178 | if (!PyArg_ParseTuple (args, "O!", &PyMailerType, &py_mlr)) | ||
179 | return NULL; | ||
180 | |||
181 | status = mu_mailer_get_debug (py_mlr->mlr, &py_dbg->dbg); | ||
182 | |||
183 | Py_INCREF (py_dbg); | ||
184 | return status_object (status, (PyObject *)py_dbg); | ||
185 | } | ||
186 | |||
187 | static PyMethodDef methods[] = { | 171 | static PyMethodDef methods[] = { |
188 | { "create", (PyCFunction) api_mailer_create, METH_VARARGS, | 172 | { "create", (PyCFunction) api_mailer_create, METH_VARARGS, |
189 | "Create mailer." }, | 173 | "Create mailer." }, |
... | @@ -200,9 +184,6 @@ static PyMethodDef methods[] = { | ... | @@ -200,9 +184,6 @@ static PyMethodDef methods[] = { |
200 | { "send_message", (PyCFunction) api_mailer_send_message, METH_VARARGS, | 184 | { "send_message", (PyCFunction) api_mailer_send_message, METH_VARARGS, |
201 | "" }, | 185 | "" }, |
202 | 186 | ||
203 | { "get_debug", (PyCFunction) api_mailer_get_debug, METH_VARARGS, | ||
204 | "" }, | ||
205 | |||
206 | { NULL, NULL, 0, NULL } | 187 | { NULL, NULL, 0, NULL } |
207 | }; | 188 | }; |
208 | 189 | ... | ... |
... | @@ -94,15 +94,11 @@ api_sieve_machine_init (PyObject *self, PyObject *args) | ... | @@ -94,15 +94,11 @@ api_sieve_machine_init (PyObject *self, PyObject *args) |
94 | { | 94 | { |
95 | int status; | 95 | int status; |
96 | PySieveMachine *py_mach; | 96 | PySieveMachine *py_mach; |
97 | struct _mu_py_sieve_logger *s; | ||
98 | 97 | ||
99 | if (!PyArg_ParseTuple (args, "O!", &PySieveMachineType, &py_mach)) | 98 | if (!PyArg_ParseTuple (args, "O!", &PySieveMachineType, &py_mach)) |
100 | return NULL; | 99 | return NULL; |
101 | 100 | ||
102 | if (!(s = calloc (1, sizeof (*s)))) | 101 | status = mu_sieve_machine_init (&py_mach->mach); |
103 | return NULL; | ||
104 | |||
105 | status = mu_sieve_machine_init (&py_mach->mach, s); | ||
106 | return _ro (PyInt_FromLong (status)); | 102 | return _ro (PyInt_FromLong (status)); |
107 | } | 103 | } |
108 | 104 | ||
... | @@ -190,224 +186,71 @@ api_sieve_message (PyObject *self, PyObject *args) | ... | @@ -190,224 +186,71 @@ api_sieve_message (PyObject *self, PyObject *args) |
190 | return _ro (PyInt_FromLong (status)); | 186 | return _ro (PyInt_FromLong (status)); |
191 | } | 187 | } |
192 | 188 | ||
193 | static int | ||
194 | _sieve_error_printer (void *data, const char *fmt, va_list ap) | ||
195 | { | ||
196 | char *buf = NULL; | ||
197 | size_t buflen = 0; | ||
198 | PyObject *py_args = PyTuple_New (1); | ||
199 | |||
200 | if (py_args) | ||
201 | { | ||
202 | struct _mu_py_sieve_logger *s = data; | ||
203 | PyObject *py_fnc = s->py_error_printer; | ||
204 | |||
205 | if (mu_vasnprintf (&buf, &buflen, fmt, ap)) | ||
206 | return 0; | ||
207 | PyTuple_SetItem (py_args, 0, PyString_FromString (buf ? buf : "")); | ||
208 | if (buf) | ||
209 | free (buf); | ||
210 | |||
211 | if (py_fnc && PyCallable_Check (py_fnc)) | ||
212 | PyObject_CallObject (py_fnc, py_args); | ||
213 | |||
214 | Py_DECREF (py_args); | ||
215 | } | ||
216 | return 0; | ||
217 | } | ||
218 | |||
219 | static int | ||
220 | _sieve_parse_error_printer (void *data, const char *filename, int lineno, | ||
221 | const char *fmt, va_list ap) | ||
222 | { | ||
223 | PyObject *py_args; | ||
224 | PyObject *py_dict; | ||
225 | |||
226 | py_dict = PyDict_New (); | ||
227 | if (py_dict) | ||
228 | { | ||
229 | char *buf = NULL; | ||
230 | size_t buflen = 0; | ||
231 | |||
232 | PyDict_SetItemString (py_dict, "filename", | ||
233 | PyString_FromString (filename)); | ||
234 | PyDict_SetItemString (py_dict, "lineno", PyInt_FromLong (lineno)); | ||
235 | |||
236 | if (mu_vasnprintf (&buf, &buflen, fmt, ap)) | ||
237 | return 0; | ||
238 | PyDict_SetItemString (py_dict, "text", | ||
239 | PyString_FromString (buf ? buf : "")); | ||
240 | if (buf) | ||
241 | free (buf); | ||
242 | |||
243 | py_args = PyTuple_New (1); | ||
244 | if (py_args) | ||
245 | { | ||
246 | struct _mu_py_sieve_logger *s = data; | ||
247 | PyObject *py_fnc = s->py_parse_error_printer; | ||
248 | |||
249 | Py_INCREF (py_dict); | ||
250 | PyTuple_SetItem (py_args, 0, py_dict); | ||
251 | |||
252 | if (py_fnc && PyCallable_Check (py_fnc)) | ||
253 | PyObject_CallObject (py_fnc, py_args); | ||
254 | |||
255 | Py_DECREF (py_dict); | ||
256 | Py_DECREF (py_args); | ||
257 | } | ||
258 | } | ||
259 | return 0; | ||
260 | } | ||
261 | |||
262 | static int | ||
263 | _sieve_debug_printer (void *data, const char *fmt, va_list ap) | ||
264 | { | ||
265 | char *buf = NULL; | ||
266 | size_t buflen = 0; | ||
267 | PyObject *py_args = PyTuple_New (1); | ||
268 | |||
269 | if (py_args) | ||
270 | { | ||
271 | struct _mu_py_sieve_logger *s = data; | ||
272 | PyObject *py_fnc = s->py_debug_printer; | ||
273 | |||
274 | if (mu_vasnprintf (&buf, &buflen, fmt, ap)) | ||
275 | return 0; | ||
276 | PyTuple_SetItem (py_args, 0, PyString_FromString (buf ? buf : "")); | ||
277 | if (buf) | ||
278 | free (buf); | ||
279 | |||
280 | if (py_fnc && PyCallable_Check (py_fnc)) | ||
281 | PyObject_CallObject (py_fnc, py_args); | ||
282 | |||
283 | Py_DECREF (py_args); | ||
284 | } | ||
285 | return 0; | ||
286 | } | ||
287 | |||
288 | static void | 189 | static void |
289 | _sieve_action_printer (void *data, const struct mu_locus *locus, | 190 | _sieve_action_printer (void *data, mu_stream_t stream, |
290 | size_t msgno, mu_message_t msg, | 191 | size_t msgno, mu_message_t msg, |
291 | const char *action, const char *fmt, va_list ap) | 192 | const char *action, const char *fmt, va_list ap) |
292 | { | 193 | { |
293 | PyObject *py_args; | 194 | PyObject *py_args; |
294 | PyObject *py_dict; | 195 | PyObject *py_dict = PyDict_New (); |
196 | PyStream *py_stm; | ||
295 | 197 | ||
296 | py_dict = PyDict_New (); | 198 | if (!py_dict) |
297 | if (py_dict) | 199 | return; |
200 | py_stm = PyStream_NEW (); | ||
201 | if (py_stm) | ||
298 | { | 202 | { |
203 | PyMessage *py_msg = PyMessage_NEW (); | ||
299 | char *buf = NULL; | 204 | char *buf = NULL; |
300 | size_t buflen = 0; | 205 | size_t buflen = 0; |
301 | PyMessage *py_msg = PyMessage_NEW (); | ||
302 | 206 | ||
303 | py_msg->msg = msg; | 207 | if (py_msg) |
304 | Py_INCREF (py_msg); | ||
305 | |||
306 | PyDict_SetItemString (py_dict, "source_file", | ||
307 | PyString_FromString (locus->source_file)); | ||
308 | PyDict_SetItemString (py_dict, "source_line", | ||
309 | PyInt_FromLong (locus->source_line)); | ||
310 | PyDict_SetItemString (py_dict, "msgno", | ||
311 | PyInt_FromLong (msgno)); | ||
312 | PyDict_SetItemString (py_dict, "msg", (PyObject *)py_msg); | ||
313 | PyDict_SetItemString (py_dict, "action", | ||
314 | PyString_FromString (action ? action : "")); | ||
315 | |||
316 | if (mu_vasnprintf (&buf, &buflen, fmt, ap)) | ||
317 | return; | ||
318 | PyDict_SetItemString (py_dict, "text", | ||
319 | PyString_FromString (buf ? buf : "")); | ||
320 | if (buf) | ||
321 | free (buf); | ||
322 | |||
323 | py_args = PyTuple_New (1); | ||
324 | if (py_args) | ||
325 | { | 208 | { |
326 | struct _mu_py_sieve_logger *s = data; | 209 | PyStream *py_stm = PyStream_NEW (); |
327 | PyObject *py_fnc = s->py_action_printer; | 210 | if (py_stm) |
328 | 211 | { | |
329 | Py_INCREF (py_dict); | 212 | py_stm->stm = stream; |
330 | PyTuple_SetItem (py_args, 0, py_dict); | 213 | mu_stream_ref (stream); |
331 | 214 | ||
332 | if (py_fnc && PyCallable_Check (py_fnc)) | 215 | py_msg->msg = msg; |
333 | PyObject_CallObject (py_fnc, py_args); | 216 | Py_INCREF (py_msg); |
334 | 217 | ||
335 | Py_DECREF (py_dict); | 218 | PyDict_SetItemString (py_dict, "msgno", |
336 | Py_DECREF (py_args); | 219 | PyInt_FromLong (msgno)); |
220 | PyDict_SetItemString (py_dict, "msg", (PyObject *)py_msg); | ||
221 | PyDict_SetItemString (py_dict, "action", | ||
222 | PyString_FromString (action ? action : "")); | ||
223 | |||
224 | if (mu_vasnprintf (&buf, &buflen, fmt, ap)) | ||
225 | { | ||
226 | mu_stream_unref (stream); | ||
227 | return; | ||
228 | } | ||
229 | PyDict_SetItemString (py_dict, "text", | ||
230 | PyString_FromString (buf ? buf : "")); | ||
231 | free (buf); | ||
232 | |||
233 | py_args = PyTuple_New (1); | ||
234 | if (py_args) | ||
235 | { | ||
236 | struct _mu_py_sieve_logger *s = data; | ||
237 | PyObject *py_fnc = s->py_action_printer; | ||
238 | |||
239 | Py_INCREF (py_dict); | ||
240 | PyTuple_SetItem (py_args, 0, py_dict); | ||
241 | |||
242 | if (py_fnc && PyCallable_Check (py_fnc)) | ||
243 | PyObject_CallObject (py_fnc, py_args); | ||
244 | |||
245 | Py_DECREF (py_dict); | ||
246 | Py_DECREF (py_args); | ||
247 | } | ||
248 | } | ||
337 | } | 249 | } |
338 | } | 250 | } |
339 | } | 251 | } |
340 | 252 | ||
341 | static PyObject * | 253 | static PyObject * |
342 | api_sieve_set_error (PyObject *self, PyObject *args) | ||
343 | { | ||
344 | PySieveMachine *py_mach; | ||
345 | PyObject *py_fnc; | ||
346 | |||
347 | if (!PyArg_ParseTuple (args, "O!O", &PySieveMachineType, &py_mach, &py_fnc)) | ||
348 | return NULL; | ||
349 | |||
350 | if (py_fnc && PyCallable_Check (py_fnc)) { | ||
351 | mu_sieve_machine_t mach = py_mach->mach; | ||
352 | struct _mu_py_sieve_logger *s = mu_sieve_get_data (mach); | ||
353 | s->py_error_printer = py_fnc; | ||
354 | Py_INCREF (py_fnc); | ||
355 | mu_sieve_set_error (py_mach->mach, _sieve_error_printer); | ||
356 | } | ||
357 | else { | ||
358 | PyErr_SetString (PyExc_TypeError, ""); | ||
359 | return NULL; | ||
360 | } | ||
361 | return _ro (Py_None); | ||
362 | } | ||
363 | |||
364 | static PyObject * | ||
365 | api_sieve_set_parse_error (PyObject *self, PyObject *args) | ||
366 | { | ||
367 | PySieveMachine *py_mach; | ||
368 | PyObject *py_fnc; | ||
369 | |||
370 | if (!PyArg_ParseTuple (args, "O!O", &PySieveMachineType, &py_mach, &py_fnc)) | ||
371 | return NULL; | ||
372 | |||
373 | if (py_fnc && PyCallable_Check (py_fnc)) { | ||
374 | mu_sieve_machine_t mach = py_mach->mach; | ||
375 | struct _mu_py_sieve_logger *s = mu_sieve_get_data (mach); | ||
376 | s->py_parse_error_printer = py_fnc; | ||
377 | Py_INCREF (py_fnc); | ||
378 | mu_sieve_set_parse_error (py_mach->mach, _sieve_parse_error_printer); | ||
379 | } | ||
380 | else { | ||
381 | PyErr_SetString (PyExc_TypeError, ""); | ||
382 | return NULL; | ||
383 | } | ||
384 | return _ro (Py_None); | ||
385 | } | ||
386 | |||
387 | static PyObject * | ||
388 | api_sieve_set_debug (PyObject *self, PyObject *args) | ||
389 | { | ||
390 | PySieveMachine *py_mach; | ||
391 | PyObject *py_fnc; | ||
392 | |||
393 | if (!PyArg_ParseTuple (args, "O!O", &PySieveMachineType, &py_mach, &py_fnc)) | ||
394 | return NULL; | ||
395 | |||
396 | if (py_fnc && PyCallable_Check (py_fnc)) { | ||
397 | mu_sieve_machine_t mach = py_mach->mach; | ||
398 | struct _mu_py_sieve_logger *s = mu_sieve_get_data (mach); | ||
399 | s->py_debug_printer = py_fnc; | ||
400 | Py_INCREF (py_fnc); | ||
401 | mu_sieve_set_debug (py_mach->mach, _sieve_debug_printer); | ||
402 | } | ||
403 | else { | ||
404 | PyErr_SetString (PyExc_TypeError, ""); | ||
405 | return NULL; | ||
406 | } | ||
407 | return _ro (Py_None); | ||
408 | } | ||
409 | |||
410 | static PyObject * | ||
411 | api_sieve_set_logger (PyObject *self, PyObject *args) | 254 | api_sieve_set_logger (PyObject *self, PyObject *args) |
412 | { | 255 | { |
413 | PySieveMachine *py_mach; | 256 | PySieveMachine *py_mach; |
... | @@ -451,15 +294,6 @@ static PyMethodDef methods[] = { | ... | @@ -451,15 +294,6 @@ static PyMethodDef methods[] = { |
451 | "Execute the code from the given instance of sieve machine " | 294 | "Execute the code from the given instance of sieve machine " |
452 | "'mach' over the 'message'. " }, | 295 | "'mach' over the 'message'. " }, |
453 | 296 | ||
454 | { "set_debug", (PyCFunction) api_sieve_set_debug, METH_VARARGS, | ||
455 | "" }, | ||
456 | |||
457 | { "set_error", (PyCFunction) api_sieve_set_error, METH_VARARGS, | ||
458 | "" }, | ||
459 | |||
460 | { "set_parse_error", (PyCFunction) api_sieve_set_parse_error, METH_VARARGS, | ||
461 | "" }, | ||
462 | |||
463 | { "set_logger", (PyCFunction) api_sieve_set_logger, METH_VARARGS, | 297 | { "set_logger", (PyCFunction) api_sieve_set_logger, METH_VARARGS, |
464 | "" }, | 298 | "" }, |
465 | 299 | ... | ... |
... | @@ -136,7 +136,7 @@ api_prog_stream_create (PyObject *self, PyObject *args) | ... | @@ -136,7 +136,7 @@ api_prog_stream_create (PyObject *self, PyObject *args) |
136 | &progname, &flags)) | 136 | &progname, &flags)) |
137 | return NULL; | 137 | return NULL; |
138 | 138 | ||
139 | status = mu_prog_stream_create (&py_stm->stm, progname, flags); | 139 | status = mu_command_stream_create (&py_stm->stm, progname, flags); |
140 | return _ro (PyInt_FromLong (status)); | 140 | return _ro (PyInt_FromLong (status)); |
141 | } | 141 | } |
142 | 142 | ||
... | @@ -146,6 +146,8 @@ api_filter_prog_stream_create (PyObject *self, PyObject *args) | ... | @@ -146,6 +146,8 @@ api_filter_prog_stream_create (PyObject *self, PyObject *args) |
146 | int status; | 146 | int status; |
147 | char *progname; | 147 | char *progname; |
148 | PyStream *py_stm, *py_input; | 148 | PyStream *py_stm, *py_input; |
149 | struct mu_prog_hints hints; | ||
150 | struct mu_wordsplit ws; | ||
149 | 151 | ||
150 | if (!PyArg_ParseTuple (args, "O!sO!", | 152 | if (!PyArg_ParseTuple (args, "O!sO!", |
151 | &PyStreamType, &py_stm, | 153 | &PyStreamType, &py_stm, |
... | @@ -153,8 +155,16 @@ api_filter_prog_stream_create (PyObject *self, PyObject *args) | ... | @@ -153,8 +155,16 @@ api_filter_prog_stream_create (PyObject *self, PyObject *args) |
153 | &PyStreamType, &py_input)) | 155 | &PyStreamType, &py_input)) |
154 | return NULL; | 156 | return NULL; |
155 | 157 | ||
156 | status = mu_filter_prog_stream_create (&py_stm->stm, progname, | 158 | if (mu_wordsplit (progname, &ws, MU_WRDSF_DEFFLAGS)) |
157 | py_input->stm); | 159 | return _ro (PyInt_FromLong (errno)); |
160 | |||
161 | hints.mu_prog_input = py_input->stm; | ||
162 | status = mu_prog_stream_create (&py_stm->stm, ws.ws_wordv[0], | ||
163 | ws.ws_wordc, ws.ws_wordv, | ||
164 | MU_PROG_HINT_INPUT, | ||
165 | &hints, | ||
166 | MU_STREAM_READ); | ||
167 | mu_wordsplit_free (&ws); | ||
158 | return _ro (PyInt_FromLong (status)); | 168 | return _ro (PyInt_FromLong (status)); |
159 | } | 169 | } |
160 | 170 | ... | ... |
... | @@ -106,7 +106,6 @@ api_url_destroy (PyObject *self, PyObject *args) | ... | @@ -106,7 +106,6 @@ api_url_destroy (PyObject *self, PyObject *args) |
106 | static PyObject * | 106 | static PyObject * |
107 | api_url_parse (PyObject *self, PyObject *args) | 107 | api_url_parse (PyObject *self, PyObject *args) |
108 | { | 108 | { |
109 | int status; | ||
110 | PyUrl *py_url; | 109 | PyUrl *py_url; |
111 | 110 | ||
112 | if (!PyArg_ParseTuple (args, "O!", &PyUrlType, &py_url)) | 111 | if (!PyArg_ParseTuple (args, "O!", &PyUrlType, &py_url)) | ... | ... |
-
Please register or sign in to post a comment