/* * Copyright (c) 2004 Sendmail, Inc. and its suppliers. * All rights reserved. * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of * the sendmail distribution. * */ #include "sm/generic.h" SM_RCSID("@(#)$Id: errno2err.c,v 1.1 2004/11/18 00:57:55 ca Exp $") #include "sm/error.h" /* ** errno2err -- convert errno to sm_ret_T, tries to figure out whether it ** is a temporary failure ** ** Parameters: ** err -- the errno code to convert. ** module -- module in which error happened ** ** Returns: ** "embedded" error code */ sm_ret_T errno2err(int err, int module) { switch (err) { case EIO: /* I/O error */ case ENXIO: /* Device not configured */ case EAGAIN: /* Resource temporarily unavailable */ case ENOMEM: /* Cannot allocate memory */ case ENODEV: /* Operation not supported by device */ case ENFILE: /* Too many open files in system */ case EMFILE: /* Too many open files */ case ENOSPC: /* No space left on device */ case ETIMEDOUT: /* Connection timed out */ #ifdef ESTALE case ESTALE: /* Stale NFS file handle */ #endif #ifdef ENETDOWN case ENETDOWN: /* Network is down */ #endif #ifdef ENETUNREACH case ENETUNREACH: /* Network is unreachable */ #endif #ifdef ENETRESET case ENETRESET: /* Network dropped connection on reset */ #endif #ifdef ECONNABORTED case ECONNABORTED: /* Software caused connection abort */ #endif #ifdef ECONNRESET case ECONNRESET: /* Connection reset by peer */ #endif #ifdef ENOBUFS case ENOBUFS: /* No buffer space available */ #endif #ifdef ESHUTDOWN case ESHUTDOWN: /* Can't send after socket shutdown */ #endif #ifdef ECONNREFUSED case ECONNREFUSED: /* Connection refused */ #endif #ifdef EHOSTDOWN case EHOSTDOWN: /* Host is down */ #endif #ifdef EHOSTUNREACH case EHOSTUNREACH: /* No route to host */ #endif #ifdef EDQUOT case EDQUOT: /* Disc quota exceeded */ #endif #ifdef EPROCLIM case EPROCLIM: /* Too many processes */ #endif #ifdef EUSERS case EUSERS: /* Too many users */ #endif #ifdef EDEADLK case EDEADLK: /* Resource deadlock avoided */ #endif #ifdef EISCONN case EISCONN: /* Socket already connected */ #endif #ifdef EINPROGRESS case EINPROGRESS: /* Operation now in progress */ #endif #ifdef EALREADY case EALREADY: /* Operation already in progress */ #endif #ifdef EADDRINUSE case EADDRINUSE: /* Address already in use */ #endif #ifdef EADDRNOTAVAIL case EADDRNOTAVAIL: /* Can't assign requested address */ #endif #ifdef ETXTBSY case ETXTBSY: /* (Apollo) file locked */ #endif #if defined(ENOSR) && (!defined(ENOBUFS) || (ENOBUFS != ENOSR)) case ENOSR: /* Out of streams resources */ #endif #ifdef ENOLCK case ENOLCK: /* No locks available */ #endif return (module == SM_EM_NONE) ? sm_err_temp(err) : sm_error_temp(module, err); } return (module == SM_EM_NONE) ? sm_err_perm(err) : sm_error_perm(module, err); }