Commit 5f796a9c 5f796a9c31d4ab9c281af3a072ae4d150fd2a1fb by Sergey Poznyakoff

Reorganize error codes.

* libmailutils/diag/errors (MU_ERR_TCP_NO_HOST)
(MU_ERR_TCP_NO_PORT): Change wording.
(MU_ERR_UNSAFE_PERMS): Remove error code.
(MU_ERR_NO_HANDLER): Remove. All uses replaced by ENOSYS.
(MU_ERR_OUT_NULL): Remove. MU_ERR_OUT_PTR_NULL is used instead.
(MU_ERR_MBX_NULL): Remove. Use EINVAL instead.
(MU_ERR_BAD_822_FORMAT): Rename to MU_ERR_INVALID_EMAIL. Change wording.
(MU_ERR_REPLY): Change wording.

* libmailutils/url/create.c: Remove misguiding comments
* libmailutils/url/set-service.c: Likewise.

* libmailutils/mailbox/mailbox.c (mu_mailbox_open): Return EACCES
if trying to update quick-access mailboxes.
(mu_mailbox_get_stream): Mark for deletion.
* libmailutils/stream/fltstream.c (filter_read)
(filter_write_internal): Return MU_ERR_BUFSPACE if requested more
space than available in I/O buffers.
* libproto/mbox/mbox.c (mbox_expunge_unlocked): Send MU_EVT_MAILBOX_CORRUPT
event if the mailbox shrunk.
* libproto/mbox/mboxscan.c (mbox_scan_internal): Return MU_ERR_NOENT if
unable to locate message in quick-access mode.
1 parent fb994e0a
...@@ -97,7 +97,7 @@ actually help. ...@@ -97,7 +97,7 @@ actually help.
97 #endif 97 #endif
98 98
99 #define EOK 0 99 #define EOK 0
100 #define EPARSE MU_ERR_BAD_822_FORMAT 100 #define EPARSE MU_ERR_INVALID_EMAIL
101 101
102 /* 102 /*
103 * Some convenience functions for dealing with dynamically re-sized 103 * Some convenience functions for dealing with dynamically re-sized
......
...@@ -409,7 +409,7 @@ amd_init_mailbox (mu_mailbox_t mailbox, size_t amd_size, ...@@ -409,7 +409,7 @@ amd_init_mailbox (mu_mailbox_t mailbox, size_t amd_size,
409 struct _amd_data *amd; 409 struct _amd_data *amd;
410 410
411 if (mailbox == NULL) 411 if (mailbox == NULL)
412 return MU_ERR_MBX_NULL; 412 return EINVAL;
413 if (amd_size < sizeof (*amd)) 413 if (amd_size < sizeof (*amd))
414 return EINVAL; 414 return EINVAL;
415 415
...@@ -533,7 +533,7 @@ amd_close (mu_mailbox_t mailbox) ...@@ -533,7 +533,7 @@ amd_close (mu_mailbox_t mailbox)
533 int i; 533 int i;
534 534
535 if (!mailbox) 535 if (!mailbox)
536 return MU_ERR_MBX_NULL; 536 return EINVAL;
537 537
538 amd = mailbox->data; 538 amd = mailbox->data;
539 539
...@@ -1018,9 +1018,7 @@ amd_append_message (mu_mailbox_t mailbox, mu_message_t msg) ...@@ -1018,9 +1018,7 @@ amd_append_message (mu_mailbox_t mailbox, mu_message_t msg)
1018 struct _amd_data *amd = mailbox->data; 1018 struct _amd_data *amd = mailbox->data;
1019 struct _amd_message *mhm; 1019 struct _amd_message *mhm;
1020 1020
1021 if (!mailbox) 1021 if (!mailbox || !msg)
1022 return MU_ERR_MBX_NULL;
1023 if (!msg)
1024 return EINVAL; 1022 return EINVAL;
1025 1023
1026 mhm = calloc (1, amd->msg_size); 1024 mhm = calloc (1, amd->msg_size);
......
1
2 # Error messages for GNU Mailutils 1 # Error messages for GNU Mailutils
3 # Copyright (C) 2005, 2006, 2007, 2010, 2011 Free Software Foundation, 2 # Copyright (C) 2005, 2006, 2007, 2010, 2011 Free Software Foundation,
4 # Inc. 3 # Inc.
...@@ -19,20 +18,20 @@ ...@@ -19,20 +18,20 @@
19 MU_ERR_FAILURE _("Operation failed") 18 MU_ERR_FAILURE _("Operation failed")
20 MU_ERR_CANCELED _("Operation canceled") 19 MU_ERR_CANCELED _("Operation canceled")
21 20
22 MU_ERR_NO_HANDLER _("No registered handler")
23 MU_ERR_EMPTY_VFN _("Empty virtual function") 21 MU_ERR_EMPTY_VFN _("Empty virtual function")
24 22
25 MU_ERR_OUT_NULL _("Pointer to output null") 23 # A counterpart of EINVAL. Functions receiving invalid input arguments
26 MU_ERR_OUT_PTR_NULL _("Pointer to output pointer null") 24 # return EINVAL, those receiving invalid output arguments return this
25 # code:
26 MU_ERR_OUT_PTR_NULL _("Null output pointer")
27 27
28 MU_ERR_MBX_NULL _("Mailbox null")
29 MU_ERR_MBX_REMOVED _("Mailbox removed") 28 MU_ERR_MBX_REMOVED _("Mailbox removed")
30 29
31 MU_ERR_NOT_OPEN _("Resource not open") 30 MU_ERR_NOT_OPEN _("Resource not open")
32 MU_ERR_OPEN _("Resource is already open") 31 MU_ERR_OPEN _("Resource is already open")
33 32
34 MU_ERR_BAD_822_FORMAT _("Format of RFC822 object is bad") 33 MU_ERR_INVALID_EMAIL _("Malformed email address")
35 MU_ERR_EMPTY_ADDRESS _("Address contains no addr specs") 34 MU_ERR_EMPTY_ADDRESS _("Empty address list")
36 35
37 MU_ERR_LOCKER_NULL _("Locker null") 36 MU_ERR_LOCKER_NULL _("Locker null")
38 MU_ERR_LOCK_CONFLICT _("Conflict with previous locker") 37 MU_ERR_LOCK_CONFLICT _("Conflict with previous locker")
...@@ -47,13 +46,14 @@ MU_ERR_NO_SUCH_USER _("No such user name") ...@@ -47,13 +46,14 @@ MU_ERR_NO_SUCH_USER _("No such user name")
47 46
48 MU_ERR_GETHOSTBYNAME _("DNS name resolution failed") 47 MU_ERR_GETHOSTBYNAME _("DNS name resolution failed")
49 MU_ERR_BAD_RESUMPTION _("State busy must resume operation") 48 MU_ERR_BAD_RESUMPTION _("State busy must resume operation")
50 MU_ERR_MAILER_BAD_FROM _("Not a valid mailer from address") 49 MU_ERR_MAILER_BAD_FROM _("Not a valid sender address")
51 MU_ERR_MAILER_BAD_TO _("Not a valid mailer to address") 50 MU_ERR_MAILER_BAD_TO _("Not a valid recipient address")
52 MU_ERR_MAILER_NO_RCPT_TO _("No receipt addresses found") 51 MU_ERR_MAILER_NO_RCPT_TO _("No recipient addresses found")
53 MU_ERR_MAILER_BAD_URL _("Malformed or unsupported mailer URL") 52 MU_ERR_MAILER_BAD_URL _("Malformed or unsupported mailer URL")
54 MU_ERR_SMTP_RCPT_FAILED _("SMTP rcpt to command failed") 53 MU_ERR_SMTP_RCPT_FAILED _("SMTP RCPT command failed")
55 MU_ERR_TCP_NO_HOST _("Tcp connections need a host") 54
56 MU_ERR_TCP_NO_PORT _("Tcp connections need a positive port") 55 MU_ERR_TCP_NO_HOST _("Required host specification is missing")
56 MU_ERR_TCP_NO_PORT _("Invalid port or service specification")
57 57
58 MU_ERR_BAD_2047_INPUT _("Input string is not RFC 2047 encoded") 58 MU_ERR_BAD_2047_INPUT _("Input string is not RFC 2047 encoded")
59 MU_ERR_BAD_2047_ENCODING _("Not a valid RFC 2047 encoding") 59 MU_ERR_BAD_2047_ENCODING _("Not a valid RFC 2047 encoding")
...@@ -63,7 +63,7 @@ MU_ERR_NOPASSWORD _("User password is not supplied") ...@@ -63,7 +63,7 @@ MU_ERR_NOPASSWORD _("User password is not supplied")
63 MU_ERR_BADREPLY _("Invalid reply from the remote host") 63 MU_ERR_BADREPLY _("Invalid reply from the remote host")
64 64
65 MU_ERR_SEQ _("Bad command sequence") 65 MU_ERR_SEQ _("Bad command sequence")
66 MU_ERR_REPLY _("Erroneous reply received") 66 MU_ERR_REPLY _("Operation rejected by remote party")
67 67
68 MU_ERR_BAD_AUTH_SCHEME _("Unsupported authentication scheme") 68 MU_ERR_BAD_AUTH_SCHEME _("Unsupported authentication scheme")
69 MU_ERR_AUTH_FAILURE _("Authentication failed") 69 MU_ERR_AUTH_FAILURE _("Authentication failed")
...@@ -78,6 +78,7 @@ MU_ERR_NOENT _("Requested item not found") ...@@ -78,6 +78,7 @@ MU_ERR_NOENT _("Requested item not found")
78 MU_ERR_EXISTS _("Item already exists") 78 MU_ERR_EXISTS _("Item already exists")
79 MU_ERR_BUFSPACE _("Not enough buffer space") 79 MU_ERR_BUFSPACE _("Not enough buffer space")
80 80
81 # Database errors
81 MU_ERR_SQL _("SQL error") 82 MU_ERR_SQL _("SQL error")
82 MU_ERR_DB_ALREADY_CONNECTED _("Already connected to the database") 83 MU_ERR_DB_ALREADY_CONNECTED _("Already connected to the database")
83 MU_ERR_DB_NOT_CONNECTED _("Not connected to the database") 84 MU_ERR_DB_NOT_CONNECTED _("Not connected to the database")
...@@ -94,9 +95,15 @@ MU_ERR_READ _("Read error") ...@@ -94,9 +95,15 @@ MU_ERR_READ _("Read error")
94 MU_ERR_NO_TRANSPORT _("Transport stream not set") 95 MU_ERR_NO_TRANSPORT _("Transport stream not set")
95 MU_ERR_AUTH_NO_CRED _("No credentials supplied") 96 MU_ERR_AUTH_NO_CRED _("No credentials supplied")
96 97
98 # URL-related errors
97 MU_ERR_URL_MISS_PARTS _("URL missing required parts") 99 MU_ERR_URL_MISS_PARTS _("URL missing required parts")
98 MU_ERR_URL_EXTRA_PARTS _("URL has parts not allowed by its scheme") 100 MU_ERR_URL_EXTRA_PARTS _("URL has parts not allowed by its scheme")
101 MU_ERR_URL_INVALID_PARAMETER _("Invalid parameter in URL")
99 102
103 # This error is returned when the requested data cannot be obtained right
104 # now or by the given means, or obtaining them is too costly, e.g. as
105 # obtaining number of lines in a message via POP3 (which would involve
106 # downloading entire message) by mu_message_quick_lines.
100 MU_ERR_INFO_UNAVAILABLE _("Information is not yet available") 107 MU_ERR_INFO_UNAVAILABLE _("Information is not yet available")
101 108
102 # The following are mapped to the corresponding EAI_ errors 109 # The following are mapped to the corresponding EAI_ errors
...@@ -106,7 +113,7 @@ MU_ERR_SOCKTYPE _("Socket type not supported") ...@@ -106,7 +113,7 @@ MU_ERR_SOCKTYPE _("Socket type not supported")
106 MU_ERR_FAMILY _("Address family not supported") 113 MU_ERR_FAMILY _("Address family not supported")
107 MU_ERR_SERVICE _("Requested service not supported") 114 MU_ERR_SERVICE _("Requested service not supported")
108 115
109 # File safety check 116 # File safety checks
110 MU_ERR_PERM_OWNER_MISMATCH _("File owner mismatch") 117 MU_ERR_PERM_OWNER_MISMATCH _("File owner mismatch")
111 MU_ERR_PERM_GROUP_WRITABLE _("Group writable file") 118 MU_ERR_PERM_GROUP_WRITABLE _("Group writable file")
112 MU_ERR_PERM_WORLD_WRITABLE _("World writable file") 119 MU_ERR_PERM_WORLD_WRITABLE _("World writable file")
...@@ -116,5 +123,3 @@ MU_ERR_PERM_LINKED_WRDIR _("Linked file in a writable directory") ...@@ -116,5 +123,3 @@ MU_ERR_PERM_LINKED_WRDIR _("Linked file in a writable directory")
116 MU_ERR_PERM_DIR_IWGRP _("File in group writable directory") 123 MU_ERR_PERM_DIR_IWGRP _("File in group writable directory")
117 MU_ERR_PERM_DIR_IWOTH _("File in world writable directory") 124 MU_ERR_PERM_DIR_IWOTH _("File in world writable directory")
118 125
119 # A simpler version of the above. Possibly will be removed in the future.
120 MU_ERR_UNSAFE_PERMS _("Unsafe file permissions")
......
...@@ -145,7 +145,7 @@ _mailbox_create_from_record (mu_mailbox_t *pmbox, ...@@ -145,7 +145,7 @@ _mailbox_create_from_record (mu_mailbox_t *pmbox,
145 *pmbox = mbox; 145 *pmbox = mbox;
146 return status; 146 return status;
147 } 147 }
148 return MU_ERR_NO_HANDLER; 148 return ENOSYS;
149 } 149 }
150 150
151 static int 151 static int
...@@ -156,7 +156,7 @@ _create_mailbox0 (mu_mailbox_t *pmbox, mu_url_t url, const char *name) ...@@ -156,7 +156,7 @@ _create_mailbox0 (mu_mailbox_t *pmbox, mu_url_t url, const char *name)
156 if (mu_registrar_lookup_url (url, MU_FOLDER_ATTRIBUTE_FILE, &record, NULL) 156 if (mu_registrar_lookup_url (url, MU_FOLDER_ATTRIBUTE_FILE, &record, NULL)
157 == 0) 157 == 0)
158 return _mailbox_create_from_record (pmbox, record, url, name); 158 return _mailbox_create_from_record (pmbox, record, url, name);
159 return MU_ERR_NO_HANDLER; 159 return ENOSYS;
160 } 160 }
161 161
162 static int 162 static int
...@@ -268,7 +268,7 @@ mu_mailbox_open (mu_mailbox_t mbox, int flag) ...@@ -268,7 +268,7 @@ mu_mailbox_open (mu_mailbox_t mbox, int flag)
268 int rc; 268 int rc;
269 269
270 if (!mbox) 270 if (!mbox)
271 return MU_ERR_MBX_NULL; 271 return EINVAL;
272 if (mbox->_open == NULL) 272 if (mbox->_open == NULL)
273 return MU_ERR_EMPTY_VFN; 273 return MU_ERR_EMPTY_VFN;
274 if (mbox->flags & _MU_MAILBOX_OPEN) 274 if (mbox->flags & _MU_MAILBOX_OPEN)
...@@ -278,7 +278,7 @@ mu_mailbox_open (mu_mailbox_t mbox, int flag) ...@@ -278,7 +278,7 @@ mu_mailbox_open (mu_mailbox_t mbox, int flag)
278 /* Quick access mailboxes are read-only */ 278 /* Quick access mailboxes are read-only */
279 if (flag & (MU_STREAM_WRITE 279 if (flag & (MU_STREAM_WRITE
280 | MU_STREAM_APPEND | MU_STREAM_CREAT)) 280 | MU_STREAM_APPEND | MU_STREAM_CREAT))
281 return EINVAL; /* FIXME: Better error code, please? */ 281 return EACCES;
282 } 282 }
283 rc = mbox->_open (mbox, flag); 283 rc = mbox->_open (mbox, flag);
284 if (rc == 0) 284 if (rc == 0)
...@@ -292,7 +292,7 @@ mu_mailbox_close (mu_mailbox_t mbox) ...@@ -292,7 +292,7 @@ mu_mailbox_close (mu_mailbox_t mbox)
292 int rc; 292 int rc;
293 293
294 if (!mbox) 294 if (!mbox)
295 return MU_ERR_MBX_NULL; 295 return EINVAL;
296 if (!(mbox->flags & _MU_MAILBOX_OPEN)) 296 if (!(mbox->flags & _MU_MAILBOX_OPEN))
297 return MU_ERR_NOT_OPEN; 297 return MU_ERR_NOT_OPEN;
298 if (mbox == NULL || mbox->_close == NULL) 298 if (mbox == NULL || mbox->_close == NULL)
...@@ -308,7 +308,7 @@ int ...@@ -308,7 +308,7 @@ int
308 mu_mailbox_remove (mu_mailbox_t mbox) 308 mu_mailbox_remove (mu_mailbox_t mbox)
309 { 309 {
310 if (!mbox) 310 if (!mbox)
311 return MU_ERR_MBX_NULL; 311 return EINVAL;
312 if (mbox->flags & _MU_MAILBOX_OPEN) 312 if (mbox->flags & _MU_MAILBOX_OPEN)
313 return MU_ERR_OPEN; 313 return MU_ERR_OPEN;
314 if (mbox->flags & _MU_MAILBOX_REMOVED) 314 if (mbox->flags & _MU_MAILBOX_REMOVED)
...@@ -325,7 +325,7 @@ mu_mailbox_flush (mu_mailbox_t mbox, int expunge) ...@@ -325,7 +325,7 @@ mu_mailbox_flush (mu_mailbox_t mbox, int expunge)
325 int status = 0; 325 int status = 0;
326 326
327 if (!mbox) 327 if (!mbox)
328 return MU_ERR_MBX_NULL; 328 return EINVAL;
329 if (mbox->flags & _MU_MAILBOX_REMOVED) 329 if (mbox->flags & _MU_MAILBOX_REMOVED)
330 return MU_ERR_MBX_REMOVED; 330 return MU_ERR_MBX_REMOVED;
331 if (!(mbox->flags & _MU_MAILBOX_OPEN)) 331 if (!(mbox->flags & _MU_MAILBOX_OPEN))
...@@ -354,7 +354,7 @@ mu_mailbox_flush (mu_mailbox_t mbox, int expunge) ...@@ -354,7 +354,7 @@ mu_mailbox_flush (mu_mailbox_t mbox, int expunge)
354 354
355 #define _MBOX_CHECK_FLAGS(mbox) \ 355 #define _MBOX_CHECK_FLAGS(mbox) \
356 if (mbox == NULL) \ 356 if (mbox == NULL) \
357 return MU_ERR_MBX_NULL; \ 357 return EINVAL; \
358 if (mbox->flags & _MU_MAILBOX_REMOVED) \ 358 if (mbox->flags & _MU_MAILBOX_REMOVED) \
359 return MU_ERR_MBX_REMOVED; \ 359 return MU_ERR_MBX_REMOVED; \
360 if (!(mbox->flags & _MU_MAILBOX_OPEN)) \ 360 if (!(mbox->flags & _MU_MAILBOX_OPEN)) \
...@@ -517,7 +517,7 @@ int ...@@ -517,7 +517,7 @@ int
517 mu_mailbox_set_locker (mu_mailbox_t mbox, mu_locker_t locker) 517 mu_mailbox_set_locker (mu_mailbox_t mbox, mu_locker_t locker)
518 { 518 {
519 if (mbox == NULL) 519 if (mbox == NULL)
520 return MU_ERR_MBX_NULL; 520 return EINVAL;
521 if (mbox->locker) 521 if (mbox->locker)
522 mu_locker_destroy (&mbox->locker); 522 mu_locker_destroy (&mbox->locker);
523 mbox->locker = locker; 523 mbox->locker = locker;
...@@ -528,7 +528,7 @@ int ...@@ -528,7 +528,7 @@ int
528 mu_mailbox_get_locker (mu_mailbox_t mbox, mu_locker_t *plocker) 528 mu_mailbox_get_locker (mu_mailbox_t mbox, mu_locker_t *plocker)
529 { 529 {
530 if (mbox == NULL) 530 if (mbox == NULL)
531 return MU_ERR_MBX_NULL; 531 return EINVAL;
532 if (plocker == NULL) 532 if (plocker == NULL)
533 return MU_ERR_OUT_PTR_NULL; 533 return MU_ERR_OUT_PTR_NULL;
534 *plocker = mbox->locker; 534 *plocker = mbox->locker;
...@@ -539,9 +539,9 @@ int ...@@ -539,9 +539,9 @@ int
539 mu_mailbox_get_flags (mu_mailbox_t mbox, int *flags) 539 mu_mailbox_get_flags (mu_mailbox_t mbox, int *flags)
540 { 540 {
541 if (mbox == NULL) 541 if (mbox == NULL)
542 return MU_ERR_MBX_NULL; 542 return EINVAL;
543 if (!*flags) 543 if (!flags)
544 return MU_ERR_OUT_NULL; 544 return MU_ERR_OUT_PTR_NULL;
545 *flags = mbox->flags & ~_MU_MAILBOX_MASK; 545 *flags = mbox->flags & ~_MU_MAILBOX_MASK;
546 return 0; 546 return 0;
547 } 547 }
...@@ -550,7 +550,7 @@ int ...@@ -550,7 +550,7 @@ int
550 mu_mailbox_set_stream (mu_mailbox_t mbox, mu_stream_t stream) 550 mu_mailbox_set_stream (mu_mailbox_t mbox, mu_stream_t stream)
551 { 551 {
552 if (mbox == NULL) 552 if (mbox == NULL)
553 return MU_ERR_MBX_NULL; 553 return EINVAL;
554 if (mbox->flags & MU_STREAM_QACCESS) 554 if (mbox->flags & MU_STREAM_QACCESS)
555 return MU_ERR_BADOP; 555 return MU_ERR_BADOP;
556 if (mbox->stream) 556 if (mbox->stream)
...@@ -560,19 +560,20 @@ mu_mailbox_set_stream (mu_mailbox_t mbox, mu_stream_t stream) ...@@ -560,19 +560,20 @@ mu_mailbox_set_stream (mu_mailbox_t mbox, mu_stream_t stream)
560 } 560 }
561 561
562 /* FIXME: This is a problem. We provide a mu_mailbox_get_stream () 562 /* FIXME: This is a problem. We provide a mu_mailbox_get_stream ()
563 and this stream is special it should, in theory, represent 563 and this stream is special: it should, in theory, represent
564 a "view" of a flow of messages. But providing this perspective 564 a "view" of a flow of messages. However, providing this perspective
565 may make sense for local mailboxes but downright impossible 565 may make sense for local mailboxes, but downright impossible
566 for a remote mailbox, short on downloading the entire mailbox 566 for remote mailboxes, short on downloading entire mailbox
567 locally. 567 locally.
568 The question is : should this function be removed? 568
569 So far it as been used on local mailboxes to get offsets. */ 569 This function will be removed in the short run. It is no longer
570 used by MU. */
570 int 571 int
571 mu_mailbox_get_stream (mu_mailbox_t mbox, mu_stream_t *pstream) 572 mu_mailbox_get_stream (mu_mailbox_t mbox, mu_stream_t *pstream)
572 { 573 {
573 /* FIXME: Deprecation warning */ 574 /* FIXME: Deprecation warning */
574 if (mbox == NULL) 575 if (mbox == NULL)
575 return MU_ERR_MBX_NULL; 576 return EINVAL;
576 if (pstream == NULL) 577 if (pstream == NULL)
577 return MU_ERR_OUT_PTR_NULL; 578 return MU_ERR_OUT_PTR_NULL;
578 579
...@@ -592,7 +593,7 @@ int ...@@ -592,7 +593,7 @@ int
592 mu_mailbox_get_streamref (mu_mailbox_t mbox, mu_stream_t *pstream) 593 mu_mailbox_get_streamref (mu_mailbox_t mbox, mu_stream_t *pstream)
593 { 594 {
594 if (mbox == NULL) 595 if (mbox == NULL)
595 return MU_ERR_MBX_NULL; 596 return EINVAL;
596 if (pstream == NULL) 597 if (pstream == NULL)
597 return MU_ERR_OUT_PTR_NULL; 598 return MU_ERR_OUT_PTR_NULL;
598 599
...@@ -611,7 +612,7 @@ int ...@@ -611,7 +612,7 @@ int
611 mu_mailbox_get_observable (mu_mailbox_t mbox, mu_observable_t *pobservable) 612 mu_mailbox_get_observable (mu_mailbox_t mbox, mu_observable_t *pobservable)
612 { 613 {
613 if (mbox == NULL) 614 if (mbox == NULL)
614 return MU_ERR_MBX_NULL; 615 return EINVAL;
615 if (pobservable == NULL) 616 if (pobservable == NULL)
616 return MU_ERR_OUT_PTR_NULL; 617 return MU_ERR_OUT_PTR_NULL;
617 618
...@@ -629,7 +630,7 @@ int ...@@ -629,7 +630,7 @@ int
629 mu_mailbox_set_property (mu_mailbox_t mbox, mu_property_t property) 630 mu_mailbox_set_property (mu_mailbox_t mbox, mu_property_t property)
630 { 631 {
631 if (mbox == NULL) 632 if (mbox == NULL)
632 return MU_ERR_MBX_NULL; 633 return EINVAL;
633 if (mbox->property) 634 if (mbox->property)
634 mu_property_unref (mbox->property); 635 mu_property_unref (mbox->property);
635 mbox->property = property; 636 mbox->property = property;
...@@ -641,7 +642,7 @@ int ...@@ -641,7 +642,7 @@ int
641 mu_mailbox_get_property (mu_mailbox_t mbox, mu_property_t *pproperty) 642 mu_mailbox_get_property (mu_mailbox_t mbox, mu_property_t *pproperty)
642 { 643 {
643 if (mbox == NULL) 644 if (mbox == NULL)
644 return MU_ERR_MBX_NULL; 645 return EINVAL;
645 if (pproperty == NULL) 646 if (pproperty == NULL)
646 return MU_ERR_OUT_PTR_NULL; 647 return MU_ERR_OUT_PTR_NULL;
647 648
...@@ -665,7 +666,7 @@ int ...@@ -665,7 +666,7 @@ int
665 mu_mailbox_get_url (mu_mailbox_t mbox, mu_url_t *purl) 666 mu_mailbox_get_url (mu_mailbox_t mbox, mu_url_t *purl)
666 { 667 {
667 if (mbox == NULL) 668 if (mbox == NULL)
668 return MU_ERR_MBX_NULL; 669 return EINVAL;
669 if (purl == NULL) 670 if (purl == NULL)
670 return MU_ERR_OUT_PTR_NULL; 671 return MU_ERR_OUT_PTR_NULL;
671 *purl = mbox->url; 672 *purl = mbox->url;
...@@ -676,7 +677,7 @@ int ...@@ -676,7 +677,7 @@ int
676 mu_mailbox_get_folder (mu_mailbox_t mbox, mu_folder_t *pfolder) 677 mu_mailbox_get_folder (mu_mailbox_t mbox, mu_folder_t *pfolder)
677 { 678 {
678 if (mbox == NULL) 679 if (mbox == NULL)
679 return MU_ERR_MBX_NULL; 680 return EINVAL;
680 if (pfolder == NULL) 681 if (pfolder == NULL)
681 return MU_ERR_OUT_PTR_NULL; 682 return MU_ERR_OUT_PTR_NULL;
682 *pfolder = mbox->folder; 683 *pfolder = mbox->folder;
...@@ -687,7 +688,7 @@ int ...@@ -687,7 +688,7 @@ int
687 mu_mailbox_set_folder (mu_mailbox_t mbox, mu_folder_t folder) 688 mu_mailbox_set_folder (mu_mailbox_t mbox, mu_folder_t folder)
688 { 689 {
689 if (mbox == NULL) 690 if (mbox == NULL)
690 return MU_ERR_MBX_NULL; 691 return EINVAL;
691 mbox->folder = folder; 692 mbox->folder = folder;
692 return 0; 693 return 0;
693 } 694 }
...@@ -715,9 +716,9 @@ mu_mailbox_get_uidls (mu_mailbox_t mbox, mu_list_t *plist) ...@@ -715,9 +716,9 @@ mu_mailbox_get_uidls (mu_mailbox_t mbox, mu_list_t *plist)
715 int status; 716 int status;
716 717
717 if (mbox == NULL) 718 if (mbox == NULL)
718 return MU_ERR_MBX_NULL;
719 if (plist == NULL)
720 return EINVAL; 719 return EINVAL;
720 if (plist == NULL)
721 return MU_ERR_OUT_PTR_NULL;
721 status = mu_list_create (&list); 722 status = mu_list_create (&list);
722 if (status) 723 if (status)
723 return status; 724 return status;
...@@ -847,9 +848,9 @@ mu_mailbox_translate (mu_mailbox_t mbox, int cmd, size_t from, size_t *to) ...@@ -847,9 +848,9 @@ mu_mailbox_translate (mu_mailbox_t mbox, int cmd, size_t from, size_t *to)
847 mu_message_t msg; 848 mu_message_t msg;
848 849
849 if (mbox == NULL) 850 if (mbox == NULL)
850 return MU_ERR_MBX_NULL;
851 if (to == NULL)
852 return EINVAL; 851 return EINVAL;
852 if (to == NULL)
853 return MU_ERR_OUT_PTR_NULL;
853 if (mbox->flags & MU_STREAM_QACCESS) 854 if (mbox->flags & MU_STREAM_QACCESS)
854 return MU_ERR_BADOP; 855 return MU_ERR_BADOP;
855 856
......
...@@ -372,7 +372,7 @@ safe_address_create (mu_address_t *paddr, const char *addr_str, ...@@ -372,7 +372,7 @@ safe_address_create (mu_address_t *paddr, const char *addr_str,
372 const char *who) 372 const char *who)
373 { 373 {
374 int status = mu_address_create (paddr, addr_str); 374 int status = mu_address_create (paddr, addr_str);
375 if (status == MU_ERR_BAD_822_FORMAT) 375 if (status == MU_ERR_INVALID_EMAIL)
376 { 376 {
377 int rc; 377 int rc;
378 char *p; 378 char *p;
...@@ -394,7 +394,7 @@ safe_address_create (mu_address_t *paddr, const char *addr_str, ...@@ -394,7 +394,7 @@ safe_address_create (mu_address_t *paddr, const char *addr_str,
394 rc = mu_address_create (paddr, p); 394 rc = mu_address_create (paddr, p);
395 if (rc == 0) 395 if (rc == 0)
396 status = 0; 396 status = 0;
397 else if (rc == MU_ERR_BAD_822_FORMAT) 397 else if (rc == MU_ERR_INVALID_EMAIL)
398 mu_debug (MU_DEBCAT_MAILER, MU_DEBUG_TRACE1, 398 mu_debug (MU_DEBCAT_MAILER, MU_DEBUG_TRACE1,
399 ("%s address guess failed", who)); 399 ("%s address guess failed", who));
400 else 400 else
......
...@@ -197,7 +197,7 @@ filter_read (mu_stream_t stream, char *buf, size_t size, size_t *pret) ...@@ -197,7 +197,7 @@ filter_read (mu_stream_t stream, char *buf, size_t size, size_t *pret)
197 197
198 if (iobuf.isize > MFB_RDBYTES (fs->inbuf) 198 if (iobuf.isize > MFB_RDBYTES (fs->inbuf)
199 || iobuf.osize > MFB_FREESIZE (fs->outbuf)) 199 || iobuf.osize > MFB_FREESIZE (fs->outbuf))
200 return MU_ERR_FAILURE; /* FIXME: special error code? */ 200 return MU_ERR_BUFSPACE;
201 201
202 /* iobuf.osize contains number of bytes written to output */ 202 /* iobuf.osize contains number of bytes written to output */
203 MFB_advance_level (&fs->outbuf, iobuf.osize); 203 MFB_advance_level (&fs->outbuf, iobuf.osize);
...@@ -334,7 +334,7 @@ filter_write_internal (mu_stream_t stream, enum mu_filter_command cmd, ...@@ -334,7 +334,7 @@ filter_write_internal (mu_stream_t stream, enum mu_filter_command cmd,
334 334
335 if (iobuf.isize > MFB_RDBYTES (fs->inbuf) 335 if (iobuf.isize > MFB_RDBYTES (fs->inbuf)
336 || iobuf.osize > MFB_FREESIZE (fs->outbuf)) 336 || iobuf.osize > MFB_FREESIZE (fs->outbuf))
337 return MU_ERR_FAILURE; /* FIXME: special error code? */ 337 return MU_ERR_BUFSPACE;
338 338
339 /* iobuf.osize contains number of bytes written to output */ 339 /* iobuf.osize contains number of bytes written to output */
340 MFB_advance_level (&fs->outbuf, iobuf.osize); 340 MFB_advance_level (&fs->outbuf, iobuf.osize);
......
...@@ -230,7 +230,7 @@ _message_open (mu_stream_t stream) ...@@ -230,7 +230,7 @@ _message_open (mu_stream_t stream)
230 offset += len; 230 offset += len;
231 continue; 231 continue;
232 } 232 }
233 return MU_ERR_BAD_822_FORMAT; 233 return MU_ERR_INVALID_EMAIL;
234 } 234 }
235 has_headers = 1; 235 has_headers = 1;
236 if (!env_from || !env_date) 236 if (!env_from || !env_date)
......
...@@ -34,7 +34,7 @@ AT_CLEANUP ...@@ -34,7 +34,7 @@ AT_CLEANUP
34 TESTADDR([Sam <@[matrix (smtp)], @[nexus: [node 12]]:sroberts@[10].[1]>],[], 34 TESTADDR([Sam <@[matrix (smtp)], @[nexus: [node 12]]:sroberts@[10].[1]>],[],
35 [1], 35 [1],
36 [], 36 [],
37 [MU_ERR_BAD_822_FORMAT 37 [MU_ERR_INVALID_EMAIL
38 ]) 38 ])
39 39
40 TESTADDR([a@b,z@y],[], 40 TESTADDR([a@b,z@y],[],
...@@ -226,7 +226,7 @@ TESTADDR([a group: ,, ;],[group], ...@@ -226,7 +226,7 @@ TESTADDR([a group: ,, ;],[group],
226 TESTADDR([Sam <@[matrix (smtp)], @[nexus: [node 12]]:sroberts@[10].[1]> ;],[], 226 TESTADDR([Sam <@[matrix (smtp)], @[nexus: [node 12]]:sroberts@[10].[1]> ;],[],
227 [1], 227 [1],
228 [], 228 [],
229 [MU_ERR_BAD_822_FORMAT 229 [MU_ERR_INVALID_EMAIL
230 ]) 230 ])
231 231
232 TESTADDR([Aliens: Sam <@[matrix (smtp)]: sam@sam>, sroberts@[10].[1];],[], 232 TESTADDR([Aliens: Sam <@[matrix (smtp)]: sam@sam>, sroberts@[10].[1];],[],
...@@ -296,7 +296,7 @@ route <@mail2.uniserve.com> ...@@ -296,7 +296,7 @@ route <@mail2.uniserve.com>
296 TESTADDR([< (hey) @ (hey, )smtp1.sympatico.ca, mail2.uniserve.com (hoo!):sroberts@uniserve.com>],[], 296 TESTADDR([< (hey) @ (hey, )smtp1.sympatico.ca, mail2.uniserve.com (hoo!):sroberts@uniserve.com>],[],
297 [1], 297 [1],
298 [], 298 [],
299 [MU_ERR_BAD_822_FORMAT 299 [MU_ERR_INVALID_EMAIL
300 ]) 300 ])
301 301
302 TESTADDR([hw@570.com (Hardware Support Account)],[], 302 TESTADDR([hw@570.com (Hardware Support Account)],[],
...@@ -374,7 +374,7 @@ local-part <paul> domain <pitbull-productions.com> ...@@ -374,7 +374,7 @@ local-part <paul> domain <pitbull-productions.com>
374 TESTADDR(["'sam@cogent.ca'" <sam@cogent.ca>, "'sroberts@uniserve.com'"],[], 374 TESTADDR(["'sam@cogent.ca'" <sam@cogent.ca>, "'sroberts@uniserve.com'"],[],
375 [0], 375 [0],
376 [], 376 [],
377 [MU_ERR_BAD_822_FORMAT 377 [MU_ERR_INVALID_EMAIL
378 ]) 378 ])
379 379
380 TESTADDR(["'sroberts\@certicom\.ca'" <sroberts@certicom.ca>],[], 380 TESTADDR(["'sroberts\@certicom\.ca'" <sroberts@certicom.ca>],[],
...@@ -603,7 +603,7 @@ local-part <zwk%f36.n480.z2.fidonet.org> domain <f36.n480.z2.fidonet.org> ...@@ -603,7 +603,7 @@ local-part <zwk%f36.n480.z2.fidonet.org> domain <f36.n480.z2.fidonet.org>
603 TESTADDR(['Dan Dall'Acqua' <ddallacqua@noetic.ab.ca>, 'Dave Shyong'],[], 603 TESTADDR(['Dan Dall'Acqua' <ddallacqua@noetic.ab.ca>, 'Dave Shyong'],[],
604 [0], 604 [0],
605 [], 605 [],
606 [MU_ERR_BAD_822_FORMAT 606 [MU_ERR_INVALID_EMAIL
607 ]) 607 ])
608 608
609 TESTADDR([0xdeadbeef-request@petting-zoo.net],[], 609 TESTADDR([0xdeadbeef-request@petting-zoo.net],[],
...@@ -657,7 +657,7 @@ local-part <Nick_Shelness> domain <motorcity2.lotus.com> ...@@ -657,7 +657,7 @@ local-part <Nick_Shelness> domain <motorcity2.lotus.com>
657 TESTADDR([<all: >],[], 657 TESTADDR([<all: >],[],
658 [1], 658 [1],
659 [], 659 [],
660 [MU_ERR_BAD_822_FORMAT 660 [MU_ERR_INVALID_EMAIL
661 ]) 661 ])
662 662
663 TESTADDR([<fyi-admin@emyr.net>],[], 663 TESTADDR([<fyi-admin@emyr.net>],[],
...@@ -1008,7 +1008,7 @@ local-part <Kieran.O'Leary> domain <anpost.ie> ...@@ -1008,7 +1008,7 @@ local-part <Kieran.O'Leary> domain <anpost.ie>
1008 TESTADDR([rfunk@wks.uts.ohio-state.eduofflinemailer-bounce@dikke.penguin.nl],[], 1008 TESTADDR([rfunk@wks.uts.ohio-state.eduofflinemailer-bounce@dikke.penguin.nl],[],
1009 [1], 1009 [1],
1010 [], 1010 [],
1011 [MU_ERR_BAD_822_FORMAT 1011 [MU_ERR_INVALID_EMAIL
1012 ]) 1012 ])
1013 1013
1014 TESTADDR([root],[], 1014 TESTADDR([root],[],
...@@ -1021,7 +1021,7 @@ local-part <root> domain <localhost> ...@@ -1021,7 +1021,7 @@ local-part <root> domain <localhost>
1021 TESTADDR([whom it may concern: ;;whom.it.may.concern: ;],[], 1021 TESTADDR([whom it may concern: ;;whom.it.may.concern: ;],[],
1022 [1], 1022 [1],
1023 [], 1023 [],
1024 [MU_ERR_BAD_822_FORMAT 1024 [MU_ERR_INVALID_EMAIL
1025 ]) 1025 ])
1026 1026
1027 TESTADDR([whom it may concern: mutt-dev@mutt.org, mutt-users@mutt.org;],[], 1027 TESTADDR([whom it may concern: mutt-dev@mutt.org, mutt-users@mutt.org;],[],
...@@ -1052,7 +1052,7 @@ local-part <bach> domain <somewhere.org> ...@@ -1052,7 +1052,7 @@ local-part <bach> domain <somewhere.org>
1052 TESTADDR(["A bad quote\" <devnull@localhost>],[], 1052 TESTADDR(["A bad quote\" <devnull@localhost>],[],
1053 [1], 1053 [1],
1054 [], 1054 [],
1055 [MU_ERR_BAD_822_FORMAT 1055 [MU_ERR_INVALID_EMAIL
1056 ]) 1056 ])
1057 1057
1058 1058
......
...@@ -476,7 +476,7 @@ _mu_url_create_internal (struct mu_url_ctx *ctx, mu_url_t hint) ...@@ -476,7 +476,7 @@ _mu_url_create_internal (struct mu_url_ctx *ctx, mu_url_t hint)
476 /* FIXME: Another proto? */ 476 /* FIXME: Another proto? */
477 struct servent *sp = getservbyname (url->portstr, "tcp"); 477 struct servent *sp = getservbyname (url->portstr, "tcp");
478 if (!sp) 478 if (!sp)
479 return MU_ERR_TCP_NO_PORT; //FIXME: Error code? 479 return MU_ERR_TCP_NO_PORT;
480 url->port = ntohs (sp->s_port); 480 url->port = ntohs (sp->s_port);
481 } 481 }
482 else 482 else
......
...@@ -53,7 +53,7 @@ mu_url_set_service (mu_url_t url, const char *str) ...@@ -53,7 +53,7 @@ mu_url_set_service (mu_url_t url, const char *str)
53 /* FIXME: 2. Another proto? */ 53 /* FIXME: 2. Another proto? */
54 struct servent *sp = getservbyname (str, "tcp"); 54 struct servent *sp = getservbyname (str, "tcp");
55 if (!sp) 55 if (!sp)
56 return MU_ERR_TCP_NO_PORT; /*FIXME: Error code?*/ 56 return MU_ERR_TCP_NO_PORT;
57 port = ntohs (sp->s_port); 57 port = ntohs (sp->s_port);
58 } 58 }
59 else if (n > USHRT_MAX) 59 else if (n > USHRT_MAX)
......
...@@ -204,7 +204,7 @@ mu_dbm_create_from_url (mu_url_t url, mu_dbm_file_t *db) ...@@ -204,7 +204,7 @@ mu_dbm_create_from_url (mu_url_t url, mu_dbm_file_t *db)
204 } 204 }
205 } 205 }
206 else if (name[5]) 206 else if (name[5])
207 return MU_ERR_URL_EXTRA_PARTS;//FIXME: better error code 207 return MU_ERR_URL_INVALID_PARAMETER;
208 } 208 }
209 else if (strcmp (name, "none") == 0) 209 else if (strcmp (name, "none") == 0)
210 { 210 {
...@@ -221,7 +221,7 @@ mu_dbm_create_from_url (mu_url_t url, mu_dbm_file_t *db) ...@@ -221,7 +221,7 @@ mu_dbm_create_from_url (mu_url_t url, mu_dbm_file_t *db)
221 val = DEFAULT_DBM_SAFETY_FLAGS; 221 val = DEFAULT_DBM_SAFETY_FLAGS;
222 } 222 }
223 else if (mu_file_safety_name_to_code (name, &val)) 223 else if (mu_file_safety_name_to_code (name, &val))
224 return MU_ERR_URL_EXTRA_PARTS;//FIXME: better error code 224 return MU_ERR_URL_INVALID_PARAMETER;
225 225
226 if (negate) 226 if (negate)
227 safety_flags &= ~val; 227 safety_flags &= ~val;
......
...@@ -128,7 +128,7 @@ _mailbox_imap_and_imaps_init (mu_mailbox_t mailbox, int imaps) ...@@ -128,7 +128,7 @@ _mailbox_imap_and_imaps_init (mu_mailbox_t mailbox, int imaps)
128 m_imap_t m_imap; 128 m_imap_t m_imap;
129 129
130 if (!mailbox) 130 if (!mailbox)
131 return MU_ERR_MBX_NULL; 131 return EINVAL;
132 if (mailbox->folder == NULL) 132 if (mailbox->folder == NULL)
133 return EINVAL; 133 return EINVAL;
134 134
......
...@@ -166,7 +166,7 @@ sendmail_send_message (mu_mailer_t mailer, mu_message_t msg, mu_address_t from, ...@@ -166,7 +166,7 @@ sendmail_send_message (mu_mailer_t mailer, mu_message_t msg, mu_address_t from,
166 mu_debug (MU_DEBCAT_MAILER, MU_DEBUG_TRACE, 166 mu_debug (MU_DEBCAT_MAILER, MU_DEBUG_TRACE,
167 ("envelope from (%s) not fully qualifed\n", 167 ("envelope from (%s) not fully qualifed\n",
168 emailfrom)); 168 emailfrom));
169 return MU_ERR_BAD_822_FORMAT; 169 return MU_ERR_INVALID_EMAIL;
170 } 170 }
171 171
172 argc += 2; /* -f from */ 172 argc += 2; /* -f from */
...@@ -239,7 +239,7 @@ sendmail_send_message (mu_mailer_t mailer, mu_message_t msg, mu_address_t from, ...@@ -239,7 +239,7 @@ sendmail_send_message (mu_mailer_t mailer, mu_message_t msg, mu_address_t from,
239 ("envelope to (%s) not fully qualifed", 239 ("envelope to (%s) not fully qualifed",
240 email)); 240 email));
241 free (argvec); 241 free (argvec);
242 return MU_ERR_BAD_822_FORMAT; 242 return MU_ERR_INVALID_EMAIL;
243 } 243 }
244 argvec[argc++] = email; 244 argvec[argc++] = email;
245 } 245 }
......
...@@ -1307,6 +1307,8 @@ mbox_expunge_unlocked (mu_mailbox_t mailbox, size_t dirty, int remove_deleted, ...@@ -1307,6 +1307,8 @@ mbox_expunge_unlocked (mu_mailbox_t mailbox, size_t dirty, int remove_deleted,
1307 else if (size < mud->size) 1307 else if (size < mud->size)
1308 { 1308 {
1309 /* Corrupted mailbox. */ 1309 /* Corrupted mailbox. */
1310 mu_observable_notify (mailbox->observable, MU_EVT_MAILBOX_CORRUPT,
1311 mailbox);
1310 mu_error (_("%s:%d: mailbox shrunk while expunging"), 1312 mu_error (_("%s:%d: mailbox shrunk while expunging"),
1311 __FILE__, __LINE__); 1313 __FILE__, __LINE__);
1312 return MU_ERR_FAILURE; /* FIXME: need an error code for that */ 1314 return MU_ERR_FAILURE; /* FIXME: need an error code for that */
......
...@@ -346,7 +346,7 @@ mbox_scan_internal (mu_mailbox_t mailbox, mbox_message_t mum, ...@@ -346,7 +346,7 @@ mbox_scan_internal (mu_mailbox_t mailbox, mbox_message_t mum,
346 { 346 {
347 /* In one-message mode, the positioning should be exact. */ 347 /* In one-message mode, the positioning should be exact. */
348 if (!isfrom) 348 if (!isfrom)
349 return EINVAL; /* FIXME: Better error code, please? */ 349 return MU_ERR_NOENT;
350 } 350 }
351 351
352 /* Which part of the message are we in ? */ 352 /* Which part of the message are we in ? */
......
...@@ -34,7 +34,7 @@ mu_pop3_list (mu_pop3_t pop3, unsigned int msgno, size_t *psize) ...@@ -34,7 +34,7 @@ mu_pop3_list (mu_pop3_t pop3, unsigned int msgno, size_t *psize)
34 if (pop3 == NULL || msgno == 0) 34 if (pop3 == NULL || msgno == 0)
35 return EINVAL; 35 return EINVAL;
36 if (psize == NULL) 36 if (psize == NULL)
37 return MU_ERR_OUT_NULL; 37 return MU_ERR_OUT_PTR_NULL;
38 38
39 switch (pop3->state) 39 switch (pop3->state)
40 { 40 {
......
...@@ -53,7 +53,7 @@ MU_ERR_EMPTY_VFN = (MU_ERR_BASE+3) ...@@ -53,7 +53,7 @@ MU_ERR_EMPTY_VFN = (MU_ERR_BASE+3)
53 MU_ERR_OUT_NULL = (MU_ERR_BASE+4) 53 MU_ERR_OUT_NULL = (MU_ERR_BASE+4)
54 MU_ERR_OUT_PTR_NULL = (MU_ERR_BASE+5) 54 MU_ERR_OUT_PTR_NULL = (MU_ERR_BASE+5)
55 MU_ERR_MBX_NULL = (MU_ERR_BASE+6) 55 MU_ERR_MBX_NULL = (MU_ERR_BASE+6)
56 MU_ERR_BAD_822_FORMAT = (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)
59 MU_ERR_LOCK_CONFLICT = (MU_ERR_BASE+10) 59 MU_ERR_LOCK_CONFLICT = (MU_ERR_BASE+10)
......