errstring.c
上传用户:xu_441
上传日期:2007-01-04
资源大小:1640k
文件大小:4k
源码类别:

Email客户端

开发平台:

Unix_Linux

  1. /*
  2.  * Copyright (c) 1998, 1999 Sendmail, Inc. and its suppliers.
  3.  * All rights reserved.
  4.  * Copyright (c) 1983, 1995-1997 Eric P. Allman.  All rights reserved.
  5.  * Copyright (c) 1988, 1993
  6.  * The Regents of the University of California.  All rights reserved.
  7.  *
  8.  * By using this file, you agree to the terms and conditions set
  9.  * forth in the LICENSE file which can be found at the top level of
  10.  * the sendmail distribution.
  11.  *
  12.  */
  13. #ifndef lint
  14. static char id[] = "@(#)$Id: errstring.c,v 8.5 1999/08/31 08:42:34 gshapiro Exp $";
  15. #endif /* ! lint */
  16. #include <sendmail.h>
  17. /*
  18. **  ERRSTRING -- return string description of error code
  19. **
  20. ** Parameters:
  21. ** errnum -- the error number to translate
  22. **
  23. ** Returns:
  24. ** A string description of errnum.
  25. **
  26. ** Side Effects:
  27. ** none.
  28. */
  29. const char *
  30. errstring(errnum)
  31. int errnum;
  32. {
  33. #if !HASSTRERROR && !defined(ERRLIST_PREDEFINED)
  34. extern char *sys_errlist[];
  35. extern int sys_nerr;
  36. #endif /* !HASSTRERROR && !defined(ERRLIST_PREDEFINED) */
  37. /*
  38. **  Handle special network error codes.
  39. **
  40. ** These are 4.2/4.3bsd specific; they should be in daemon.c.
  41. */
  42. switch (errnum)
  43. {
  44.   case EPERM:
  45. /* SunOS gives "Not owner" -- this is the POSIX message */
  46. return "Operation not permitted";
  47. /*
  48. **  Error messages used internally in sendmail.
  49. */
  50.   case E_SM_OPENTIMEOUT:
  51. return "Timeout on file open";
  52.   case E_SM_NOSLINK:
  53. return "Symbolic links not allowed";
  54.   case E_SM_NOHLINK:
  55. return "Hard links not allowed";
  56.   case E_SM_REGONLY:
  57. return "Regular files only";
  58.   case E_SM_ISEXEC:
  59. return "Executable files not allowed";
  60.   case E_SM_WWDIR:
  61. return "World writable directory";
  62.   case E_SM_GWDIR:
  63. return "Group writable directory";
  64.   case E_SM_FILECHANGE:
  65. return "File changed after open";
  66.   case E_SM_WWFILE:
  67. return "World writable file";
  68.   case E_SM_GWFILE:
  69. return "Group writable file";
  70.   case E_SM_RFILE:
  71. return "Group/other readable file";
  72. /*
  73. **  DNS error messages.
  74. */
  75. #if NAMED_BIND
  76.   case HOST_NOT_FOUND + E_DNSBASE:
  77. return "Name server: host not found";
  78.   case TRY_AGAIN + E_DNSBASE:
  79. return "Name server: host name lookup failure";
  80.   case NO_RECOVERY + E_DNSBASE:
  81. return "Name server: non-recoverable error";
  82.   case NO_DATA + E_DNSBASE:
  83. return "Name server: no data known";
  84. #endif /* NAMED_BIND */
  85. /*
  86. **  libsmdb error messages.
  87. */
  88.   case SMDBE_MALLOC:
  89. return "Memory allocation failed";
  90.   case SMDBE_GDBM_IS_BAD:
  91. return "GDBM is not supported";
  92.   case SMDBE_UNSUPPORTED:
  93. return "Unsupported action";
  94.   case SMDBE_DUPLICATE:
  95. return "Key already exists";
  96.   case SMDBE_BAD_OPEN:
  97. return "Database open failed";
  98.   case SMDBE_NOT_FOUND:
  99. return "Key not found";
  100.   case SMDBE_UNKNOWN_DB_TYPE:
  101. return "Unknown database type";
  102.   case SMDBE_UNSUPPORTED_DB_TYPE:
  103. return "Support for database type not compiled into this program";
  104.   case SMDBE_INCOMPLETE:
  105. return "DB sync did not finish";
  106.   case SMDBE_KEY_EMPTY:
  107. return "Key is empty";
  108.   case SMDBE_KEY_EXIST:
  109. return "Key already exists";
  110.   case SMDBE_LOCK_DEADLOCK:
  111. return "Locker killed to resolve deadlock";
  112.   case SMDBE_LOCK_NOT_GRANTED:
  113. return "Lock unavailable";
  114.   case SMDBE_LOCK_NOT_HELD:
  115. return "Lock not held by locker";
  116.   case SMDBE_RUN_RECOVERY:
  117. return "Database panic, run recovery";
  118.   case SMDBE_IO_ERROR:
  119. return "I/O error";
  120.   case SMDBE_READ_ONLY:
  121. return "Database opened read-only";
  122.   case SMDBE_DB_NAME_TOO_LONG:
  123. return "Name too long";
  124.   case SMDBE_INVALID_PARAMETER:
  125. return "Invalid parameter";
  126.   case SMDBE_ONLY_SUPPORTS_ONE_CURSOR:
  127. return "Only one cursor allowed";
  128.   case SMDBE_NOT_A_VALID_CURSOR:
  129. return "Invalid cursor";
  130.   case SMDBE_OLD_VERSION:
  131. return "Berkeley DB file is an old version, recreate it";
  132. }
  133. /*
  134. **  LDAP error messages.
  135. */
  136. #ifdef LDAPMAP
  137. if (errnum >= E_LDAPBASE)
  138. return ldap_err2string(errnum - E_LDAPBASE);
  139. #endif /* LDAPMAP */
  140. #if HASSTRERROR
  141. return strerror(errnum);
  142. #else /* HASSTRERROR */
  143. if (errnum > 0 && errnum < sys_nerr)
  144. return sys_errlist[errnum];
  145. else
  146. {
  147. static char buf[MAXLINE];
  148. (void) snprintf(buf, sizeof buf, "Error %d", errnum);
  149. return buf;
  150. }
  151. #endif /* HASSTRERROR */
  152. }