Commit ebcdaaf0 ebcdaaf0a4293c81229f6b8e5287d3a6a77b8f83 by Sergey Poznyakoff
2 parents 56e4e27f 243dee23
...@@ -23,22 +23,13 @@ if len (sys.argv) != 3: ...@@ -23,22 +23,13 @@ if len (sys.argv) != 3:
23 sys.exit (0) 23 sys.exit (0)
24 24
25 sti = stream.StdioStream (stream.MU_STDIN_FD) 25 sti = stream.StdioStream (stream.MU_STDIN_FD)
26 sti.open ()
27
28 cvt = filter.FilterIconvStream (sti, sys.argv[1], sys.argv[2]) 26 cvt = filter.FilterIconvStream (sti, sys.argv[1], sys.argv[2])
29 cvt.open ()
30
31 out = stream.StdioStream (stream.MU_STDOUT_FD, 0) 27 out = stream.StdioStream (stream.MU_STDOUT_FD, 0)
32 out.open ()
33 28
34 total = 0 29 total = 0
35 while True: 30 while True:
36 buf = cvt.read (total) 31 buf = cvt.read ()
37 out.write (buf) 32 out.write (buf)
38 total += cvt.read_count 33 total += cvt.read_count
39 if not cvt.read_count: 34 if not cvt.read_count:
40 break 35 break
41
42 out.flush ()
43 out.close ()
44 sti.close ()
......
...@@ -17,8 +17,6 @@ ...@@ -17,8 +17,6 @@
17 from mailutils import stream, mailcap 17 from mailutils import stream, mailcap
18 18
19 stm = stream.FileStream ("/etc/mailcap") 19 stm = stream.FileStream ("/etc/mailcap")
20 stm.open ()
21
22 mc = mailcap.Mailcap (stm) 20 mc = mailcap.Mailcap (stm)
23 21
24 for i, entry in enumerate (mc): 22 for i, entry in enumerate (mc):
......
...@@ -21,7 +21,6 @@ from mailutils.error import * ...@@ -21,7 +21,6 @@ from mailutils.error import *
21 def parse (str): 21 def parse (str):
22 try: 22 try:
23 u = url.Url (str) 23 u = url.Url (str)
24 u.parse ()
25 print "URL: %s" % u 24 print "URL: %s" % u
26 25
27 print "\tscheme <%s>" % u.get_scheme () 26 print "\tscheme <%s>" % u.get_scheme ()
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
19 # include <config.h> 19 # include <config.h>
20 #endif 20 #endif
21 #include <fcntl.h> 21 #include <fcntl.h>
22 #include <unistd.h>
22 #include <stdlib.h> 23 #include <stdlib.h>
23 #include <string.h> 24 #include <string.h>
24 #include <sys/stat.h> 25 #include <sys/stat.h>
...@@ -38,6 +39,7 @@ struct kc_descr ...@@ -38,6 +39,7 @@ struct kc_descr
38 { 39 {
39 KCDB *db; /* db */ 40 KCDB *db; /* db */
40 KCCUR *cur; /* cursor */ 41 KCCUR *cur; /* cursor */
42 int fd;
41 }; 43 };
42 44
43 static int 45 static int
...@@ -49,7 +51,17 @@ _kc_file_safety (mu_dbm_file_t db, int mode, uid_t owner) ...@@ -49,7 +51,17 @@ _kc_file_safety (mu_dbm_file_t db, int mode, uid_t owner)
49 int 51 int
50 _kc_get_fd (mu_dbm_file_t db, int *pag, int *dir) 52 _kc_get_fd (mu_dbm_file_t db, int *pag, int *dir)
51 { 53 {
52 return ENOSYS; 54 struct kc_descr *kcd = db->db_descr;
55 if (kcd->fd == -1)
56 {
57 kcd->fd = open (db->db_name, O_RDONLY);
58 if (kcd->fd == -1)
59 return errno;
60 }
61 *pag = kcd->fd;
62 if (dir)
63 *dir = kcd->fd;
64 return 0;
53 } 65 }
54 66
55 static int 67 static int
...@@ -93,6 +105,7 @@ _kc_open (mu_dbm_file_t db, int flags, int mode) ...@@ -93,6 +105,7 @@ _kc_open (mu_dbm_file_t db, int flags, int mode)
93 kcd->db = kdb; 105 kcd->db = kdb;
94 kcd->cur = NULL; 106 kcd->cur = NULL;
95 db->db_descr = kcd; 107 db->db_descr = kcd;
108 kcd->fd = -1;
96 return 0; 109 return 0;
97 } 110 }
98 111
...@@ -102,6 +115,8 @@ _kc_close (mu_dbm_file_t db) ...@@ -102,6 +115,8 @@ _kc_close (mu_dbm_file_t db)
102 if (db->db_descr) 115 if (db->db_descr)
103 { 116 {
104 struct kc_descr *kcd = db->db_descr; 117 struct kc_descr *kcd = db->db_descr;
118 if (kcd->fd != -1)
119 close (kcd->fd);
105 kcdbclose (kcd->db); 120 kcdbclose (kcd->db);
106 kcdbdel (kcd->db); 121 kcdbdel (kcd->db);
107 free (kcd); 122 free (kcd);
......
...@@ -66,8 +66,8 @@ api_filter_iconv_create (PyObject *self, PyObject *args) ...@@ -66,8 +66,8 @@ api_filter_iconv_create (PyObject *self, PyObject *args)
66 66
67 argv[1] = fromcode; 67 argv[1] = fromcode;
68 argv[2] = tocode; 68 argv[2] = tocode;
69 mu_filter_create_args (&py_stm->stm, py_transport->stm, argv[0], 3, argv, 69 status = mu_filter_create_args (&py_stm->stm, py_transport->stm, argv[0], 3,
70 MU_FILTER_DECODE, flags); 70 argv, MU_FILTER_DECODE, flags);
71 return _ro (PyInt_FromLong (status)); 71 return _ro (PyInt_FromLong (status));
72 } 72 }
73 73
......
...@@ -102,18 +102,6 @@ api_url_destroy (PyObject *self, PyObject *args) ...@@ -102,18 +102,6 @@ api_url_destroy (PyObject *self, PyObject *args)
102 return _ro (Py_None); 102 return _ro (Py_None);
103 } 103 }
104 104
105 /* FIXME: Remove */
106 static PyObject *
107 api_url_parse (PyObject *self, PyObject *args)
108 {
109 PyUrl *py_url;
110
111 if (!PyArg_ParseTuple (args, "O!", &PyUrlType, &py_url))
112 return NULL;
113
114 return _ro (0);
115 }
116
117 static PyObject * 105 static PyObject *
118 api_url_get_port (PyObject *self, PyObject *args) 106 api_url_get_port (PyObject *self, PyObject *args)
119 { 107 {
...@@ -255,9 +243,6 @@ static PyMethodDef methods[] = { ...@@ -255,9 +243,6 @@ static PyMethodDef methods[] = {
255 { "destroy", (PyCFunction) api_url_destroy, METH_VARARGS, 243 { "destroy", (PyCFunction) api_url_destroy, METH_VARARGS,
256 "Destroy the url and free its resources." }, 244 "Destroy the url and free its resources." },
257 245
258 { "parse", (PyCFunction) api_url_parse, METH_VARARGS,
259 "Parse the url, after calling this the get functions can be called." },
260
261 { "to_string", (PyCFunction) api_url_to_string, METH_VARARGS, 246 { "to_string", (PyCFunction) api_url_to_string, METH_VARARGS,
262 "" }, 247 "" },
263 248
......
...@@ -48,11 +48,11 @@ MU_ERR_BASE = 0x1000 ...@@ -48,11 +48,11 @@ MU_ERR_BASE = 0x1000
48 48
49 MU_ERR_FAILURE = (MU_ERR_BASE+0) 49 MU_ERR_FAILURE = (MU_ERR_BASE+0)
50 MU_ERR_CANCELED = (MU_ERR_BASE+1) 50 MU_ERR_CANCELED = (MU_ERR_BASE+1)
51 MU_ERR_NO_HANDLER = (MU_ERR_BASE+2) 51 MU_ERR_EMPTY_VFN = (MU_ERR_BASE+2)
52 MU_ERR_EMPTY_VFN = (MU_ERR_BASE+3) 52 MU_ERR_OUT_PTR_NULL = (MU_ERR_BASE+3)
53 MU_ERR_OUT_NULL = (MU_ERR_BASE+4) 53 MU_ERR_MBX_REMOVED = (MU_ERR_BASE+4)
54 MU_ERR_OUT_PTR_NULL = (MU_ERR_BASE+5) 54 MU_ERR_NOT_OPEN = (MU_ERR_BASE+5)
55 MU_ERR_MBX_NULL = (MU_ERR_BASE+6) 55 MU_ERR_OPEN = (MU_ERR_BASE+6)
56 MU_ERR_INVALID_EMAIL = (MU_ERR_BASE+7) 56 MU_ERR_INVALID_EMAIL = (MU_ERR_BASE+7)
57 MU_ERR_EMPTY_ADDRESS = (MU_ERR_BASE+8) 57 MU_ERR_EMPTY_ADDRESS = (MU_ERR_BASE+8)
58 MU_ERR_LOCKER_NULL = (MU_ERR_BASE+9) 58 MU_ERR_LOCKER_NULL = (MU_ERR_BASE+9)
...@@ -65,38 +65,60 @@ MU_ERR_LOCK_EXT_ERR = (MU_ERR_BASE+15) ...@@ -65,38 +65,60 @@ MU_ERR_LOCK_EXT_ERR = (MU_ERR_BASE+15)
65 MU_ERR_LOCK_EXT_KILLED = (MU_ERR_BASE+16) 65 MU_ERR_LOCK_EXT_KILLED = (MU_ERR_BASE+16)
66 MU_ERR_NO_SUCH_USER = (MU_ERR_BASE+17) 66 MU_ERR_NO_SUCH_USER = (MU_ERR_BASE+17)
67 MU_ERR_GETHOSTBYNAME = (MU_ERR_BASE+18) 67 MU_ERR_GETHOSTBYNAME = (MU_ERR_BASE+18)
68 MU_ERR_BAD_RESUMPTION = (MU_ERR_BASE+19) 68 MU_ERR_MAILER_BAD_FROM = (MU_ERR_BASE+19)
69 MU_ERR_MAILER_BAD_FROM = (MU_ERR_BASE+20) 69 MU_ERR_MAILER_BAD_TO = (MU_ERR_BASE+20)
70 MU_ERR_MAILER_BAD_TO = (MU_ERR_BASE+21) 70 MU_ERR_MAILER_NO_RCPT_TO = (MU_ERR_BASE+21)
71 MU_ERR_MAILER_NO_RCPT_TO = (MU_ERR_BASE+22) 71 MU_ERR_MAILER_BAD_URL = (MU_ERR_BASE+22)
72 MU_ERR_MAILER_BAD_URL = (MU_ERR_BASE+23) 72 MU_ERR_SMTP_RCPT_FAILED = (MU_ERR_BASE+23)
73 MU_ERR_SMTP_RCPT_FAILED = (MU_ERR_BASE+24) 73 MU_ERR_TCP_NO_HOST = (MU_ERR_BASE+24)
74 MU_ERR_TCP_NO_HOST = (MU_ERR_BASE+25) 74 MU_ERR_TCP_NO_PORT = (MU_ERR_BASE+25)
75 MU_ERR_TCP_NO_PORT = (MU_ERR_BASE+26) 75 MU_ERR_BAD_2047_INPUT = (MU_ERR_BASE+26)
76 MU_ERR_BAD_2047_INPUT = (MU_ERR_BASE+27) 76 MU_ERR_BAD_2047_ENCODING = (MU_ERR_BASE+27)
77 MU_ERR_BAD_2047_ENCODING = (MU_ERR_BASE+28) 77 MU_ERR_NOUSERNAME = (MU_ERR_BASE+28)
78 MU_ERR_NOUSERNAME = (MU_ERR_BASE+29) 78 MU_ERR_NOPASSWORD = (MU_ERR_BASE+29)
79 MU_ERR_NOPASSWORD = (MU_ERR_BASE+30) 79 MU_ERR_BADREPLY = (MU_ERR_BASE+30)
80 MU_ERR_UNSAFE_PERMS = (MU_ERR_BASE+31) 80 MU_ERR_SEQ = (MU_ERR_BASE+31)
81 MU_ERR_BAD_AUTH_SCHEME = (MU_ERR_BASE+32) 81 MU_ERR_REPLY = (MU_ERR_BASE+32)
82 MU_ERR_AUTH_FAILURE = (MU_ERR_BASE+33) 82 MU_ERR_BAD_AUTH_SCHEME = (MU_ERR_BASE+33)
83 MU_ERR_PROCESS_NOEXEC = (MU_ERR_BASE+34) 83 MU_ERR_AUTH_FAILURE = (MU_ERR_BASE+34)
84 MU_ERR_PROCESS_EXITED = (MU_ERR_BASE+35) 84 MU_ERR_PROCESS_NOEXEC = (MU_ERR_BASE+35)
85 MU_ERR_PROCESS_SIGNALED = (MU_ERR_BASE+36) 85 MU_ERR_PROCESS_EXITED = (MU_ERR_BASE+36)
86 MU_ERR_PROCESS_UNKNOWN_FAILURE = (MU_ERR_BASE+37) 86 MU_ERR_PROCESS_SIGNALED = (MU_ERR_BASE+37)
87 MU_ERR_CONN_CLOSED = (MU_ERR_BASE+38) 87 MU_ERR_PROCESS_UNKNOWN_FAILURE = (MU_ERR_BASE+38)
88 MU_ERR_PARSE = (MU_ERR_BASE+39) 88 MU_ERR_CONN_CLOSED = (MU_ERR_BASE+39)
89 MU_ERR_NOENT = (MU_ERR_BASE+40) 89 MU_ERR_PARSE = (MU_ERR_BASE+40)
90 MU_ERR_EXISTS = (MU_ERR_BASE+41) 90 MU_ERR_NOENT = (MU_ERR_BASE+41)
91 MU_ERR_BUFSPACE = (MU_ERR_BASE+42) 91 MU_ERR_EXISTS = (MU_ERR_BASE+42)
92 MU_ERR_SQL = (MU_ERR_BASE+43) 92 MU_ERR_BUFSPACE = (MU_ERR_BASE+43)
93 MU_ERR_DB_ALREADY_CONNECTED = (MU_ERR_BASE+44) 93 MU_ERR_SQL = (MU_ERR_BASE+44)
94 MU_ERR_DB_NOT_CONNECTED = (MU_ERR_BASE+45) 94 MU_ERR_DB_ALREADY_CONNECTED = (MU_ERR_BASE+45)
95 MU_ERR_RESULT_NOT_RELEASED = (MU_ERR_BASE+46) 95 MU_ERR_DB_NOT_CONNECTED = (MU_ERR_BASE+46)
96 MU_ERR_NO_QUERY = (MU_ERR_BASE+47) 96 MU_ERR_RESULT_NOT_RELEASED = (MU_ERR_BASE+47)
97 MU_ERR_BAD_COLUMN = (MU_ERR_BASE+48) 97 MU_ERR_NO_QUERY = (MU_ERR_BASE+48)
98 MU_ERR_NO_RESULT = (MU_ERR_BASE+49) 98 MU_ERR_BAD_COLUMN = (MU_ERR_BASE+49)
99 MU_ERR_NO_INTERFACE = (MU_ERR_BASE+50) 99 MU_ERR_NO_RESULT = (MU_ERR_BASE+50)
100 MU_ERR_BADOP = (MU_ERR_BASE+51) 100 MU_ERR_NO_INTERFACE = (MU_ERR_BASE+51)
101 MU_ERR_BAD_FILENAME = (MU_ERR_BASE+52) 101 MU_ERR_BADOP = (MU_ERR_BASE+52)
102 MU_ERR_READ = (MU_ERR_BASE+53) 102 MU_ERR_BAD_FILENAME = (MU_ERR_BASE+53)
103 MU_ERR_READ = (MU_ERR_BASE+54)
104 MU_ERR_NO_TRANSPORT = (MU_ERR_BASE+55)
105 MU_ERR_AUTH_NO_CRED = (MU_ERR_BASE+56)
106 MU_ERR_URL_MISS_PARTS = (MU_ERR_BASE+57)
107 MU_ERR_URL_EXTRA_PARTS = (MU_ERR_BASE+58)
108 MU_ERR_URL_INVALID_PARAMETER = (MU_ERR_BASE+59)
109 MU_ERR_INFO_UNAVAILABLE = (MU_ERR_BASE+60)
110 MU_ERR_NONAME = (MU_ERR_BASE+61)
111 MU_ERR_BADFLAGS = (MU_ERR_BASE+62)
112 MU_ERR_SOCKTYPE = (MU_ERR_BASE+63)
113 MU_ERR_FAMILY = (MU_ERR_BASE+64)
114 MU_ERR_SERVICE = (MU_ERR_BASE+65)
115 MU_ERR_PERM_OWNER_MISMATCH = (MU_ERR_BASE+66)
116 MU_ERR_PERM_GROUP_WRITABLE = (MU_ERR_BASE+67)
117 MU_ERR_PERM_WORLD_WRITABLE = (MU_ERR_BASE+68)
118 MU_ERR_PERM_GROUP_READABLE = (MU_ERR_BASE+69)
119 MU_ERR_PERM_WORLD_READABLE = (MU_ERR_BASE+70)
120 MU_ERR_PERM_LINKED_WRDIR = (MU_ERR_BASE+71)
121 MU_ERR_PERM_DIR_IWGRP = (MU_ERR_BASE+72)
122 MU_ERR_PERM_DIR_IWOTH = (MU_ERR_BASE+73)
123 MU_ERR_DISABLED = (MU_ERR_BASE+74)
124 MU_ERR_LAST = (MU_ERR_BASE+75)
......
...@@ -40,14 +40,6 @@ class Url: ...@@ -40,14 +40,6 @@ class Url:
40 def __str__ (self): 40 def __str__ (self):
41 return url.to_string (self.url) 41 return url.to_string (self.url)
42 42
43 def parse (self):
44 """Parses the url, after calling this the get functions
45 can be called."""
46 if self.__owner:
47 status = url.parse (self.url)
48 if status:
49 raise UrlError (status)
50
51 def get_port (self): 43 def get_port (self):
52 status, port = url.get_port (self.url) 44 status, port = url.get_port (self.url)
53 if status: 45 if status:
......