Commit 74a44780 74a4478087159a708de6cf5295a66bee91394cf1 by Sergey Poznyakoff

(MU_ERR_CONN_CLOSED,MU_ERR_PARSE): New error codes.

(MU_ERR_NOENT): New error code. Use it instead
of ENOENT to avoid misguiding diagnostics
'No such file or directory'. Use ENOENT only for its
direct purpose.
1 parent a463985d
...@@ -89,6 +89,13 @@ extern "C" { ...@@ -89,6 +89,13 @@ extern "C" {
89 #define MU_ERR_PROCESS_UNKNOWN_FAILURE (MU_ERR_BASE + 36) 89 #define MU_ERR_PROCESS_UNKNOWN_FAILURE (MU_ERR_BASE + 36)
90 /* Unknown failure while executing subprocess */ 90 /* Unknown failure while executing subprocess */
91 91
92 #define MU_ERR_CONN_CLOSED (MU_ERR_BASE + 37)
93 /* Connection closed by remote host */
94 #define MU_ERR_PARSE (MU_ERR_BASE + 38)
95 /* Parse error */
96 #define MU_ERR_NOENT (MU_ERR_BASE + 39)
97 /* Requested item not found */
98
92 const char *mu_errname __P((int e)); 99 const char *mu_errname __P((int e));
93 const char *mu_strerror __P((int e)); 100 const char *mu_strerror __P((int e));
94 101
......
1 /* GNU Mailutils -- a suite of utilities for electronic mail 1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2000, 2001, 2002, 2003,
3 2004 Free Software Foundation, Inc.
3 4
4 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public 6 modify it under the terms of the GNU Lesser General Public
...@@ -32,6 +33,8 @@ ...@@ -32,6 +33,8 @@
32 const char* 33 const char*
33 mu_errname (int e) 34 mu_errname (int e)
34 { 35 {
36 static char buf[128];
37
35 switch (e) 38 switch (e)
36 { 39 {
37 #define EN(x) case x: return #x 40 #define EN(x) case x: return #x
...@@ -90,17 +93,25 @@ mu_errname (int e) ...@@ -90,17 +93,25 @@ mu_errname (int e)
90 EN(MU_ERR_PROCESS_EXITED); 93 EN(MU_ERR_PROCESS_EXITED);
91 EN(MU_ERR_PROCESS_SIGNALED); 94 EN(MU_ERR_PROCESS_SIGNALED);
92 EN(MU_ERR_PROCESS_UNKNOWN_FAILURE); 95 EN(MU_ERR_PROCESS_UNKNOWN_FAILURE);
96
97 EN(MU_ERR_CONN_CLOSED);
98 EN(MU_ERR_PARSE);
99 EN(MU_ERR_NOENT);
93 } 100 }
94 101
95 return "SYSTEM ERROR"; 102 snprintf (buf, sizeof buf, _("Error %d"), e);
103 return buf;
96 } 104 }
97 105
98 const char * 106 const char *
99 mu_strerror (int e) 107 mu_strerror (int e)
100 { 108 {
109 const char *msg = NULL;
110 char *p;
111
101 switch (e) 112 switch (e)
102 { 113 {
103 #define ES(x, d) case x: return d 114 #define ES(x, d) case x: msg = d; break;
104 ES(EOK, _("Success")); 115 ES(EOK, _("Success"));
105 116
106 ES(MU_ERR_FAILURE, _("Operation failed")); 117 ES(MU_ERR_FAILURE, _("Operation failed"));
...@@ -151,8 +162,11 @@ mu_strerror (int e) ...@@ -151,8 +162,11 @@ mu_strerror (int e)
151 ES(MU_ERR_PROCESS_SIGNALED, _("Process exited on signal")); 162 ES(MU_ERR_PROCESS_SIGNALED, _("Process exited on signal"));
152 ES(MU_ERR_PROCESS_UNKNOWN_FAILURE, 163 ES(MU_ERR_PROCESS_UNKNOWN_FAILURE,
153 _("Unknown failure while executing subprocess")); 164 _("Unknown failure while executing subprocess"));
165 ES(MU_ERR_CONN_CLOSED, _("Connection closed by remote host"));
166 ES(MU_ERR_PARSE, _("Parse error"));
167 ES(MU_ERR_NOENT, _("Requested item not found"));
154 } 168 }
155 169
156 return strerror (e); 170 return msg ? msg : strerror (e);
157 } 171 }
158 172
......