module NHC.DErrNo where

{- Automatically generated from /usr/include/errno.h -}

data ErrNo =
    Edummy
  | EPERM
  | ENOENT
  | ESRCH
  | EINTR
  | EIO
  | ENXIO
  | E2BIG
  | ENOEXEC
  | EBADF
  | ECHILD
  | EDEADLK
  | ENOMEM
  | EACCES
  | EFAULT
  | ENOTBLK
  | EBUSY
  | EEXIST
  | EXDEV
  | ENODEV
  | ENOTDIR
  | EISDIR
  | EINVAL
  | ENFILE
  | EMFILE
  | ENOTTY
  | ETXTBSY
  | EFBIG
  | ENOSPC
  | ESPIPE
  | EROFS
  | EMLINK
  | EPIPE
  | EDOM
  | ERANGE
  | EAGAIN
  | EINPROGRESS
  | EALREADY
  | ENOTSOCK
  | EDESTADDRREQ
  | EMSGSIZE
  | EPROTOTYPE
  | ENOPROTOOPT
  | EPROTONOSUPPORT
  | ESOCKTNOSUPPORT
  | EOPNOTSUPP
  | EPFNOSUPPORT
  | EAFNOSUPPORT
  | EADDRINUSE
  | EADDRNOTAVAIL
  | ENETDOWN
  | ENETUNREACH
  | ENETRESET
  | ECONNABORTED
  | ECONNRESET
  | ENOBUFS
  | EISCONN
  | ENOTCONN
  | ESHUTDOWN
  | ETOOMANYREFS
  | ETIMEDOUT
  | ECONNREFUSED
  | ELOOP
  | ENAMETOOLONG
  | EHOSTDOWN
  | EHOSTUNREACH
  | ENOTEMPTY
  | EPROCLIM
  | EUSERS
  | EDQUOT
  | ESTALE
  | EREMOTE
  | EWOULDBLOCK
  | ENOLCK
  | ENOSYS
  | EIDRM
  | ENOMSG
  | EOVERFLOW
  | EILSEQ
  | ENOTSUP
  | ECANCELED
  | EBADMSG
  | ENODATA
  | ENOSR
  | ENOSTR
  | ETIME
  | ENOATTR
  | EMULTIHOP
  | ENOLINK
  | EPROTO
  deriving (Eq,Show)

instance Enum ErrNo where
  toEnum 1 = EPERM
  toEnum 2 = ENOENT
  toEnum 3 = ESRCH
  toEnum 4 = EINTR
  toEnum 5 = EIO
  toEnum 6 = ENXIO
  toEnum 7 = E2BIG
  toEnum 8 = ENOEXEC
  toEnum 9 = EBADF
  toEnum 10 = ECHILD
  toEnum 11 = EDEADLK
  toEnum 12 = ENOMEM
  toEnum 13 = EACCES
  toEnum 14 = EFAULT
  toEnum 15 = ENOTBLK
  toEnum 16 = EBUSY
  toEnum 17 = EEXIST
  toEnum 18 = EXDEV
  toEnum 19 = ENODEV
  toEnum 20 = ENOTDIR
  toEnum 21 = EISDIR
  toEnum 22 = EINVAL
  toEnum 23 = ENFILE
  toEnum 24 = EMFILE
  toEnum 25 = ENOTTY
  toEnum 26 = ETXTBSY
  toEnum 27 = EFBIG
  toEnum 28 = ENOSPC
  toEnum 29 = ESPIPE
  toEnum 30 = EROFS
  toEnum 31 = EMLINK
  toEnum 32 = EPIPE
  toEnum 33 = EDOM
  toEnum 34 = ERANGE
  toEnum 35 = EAGAIN
  toEnum 36 = EINPROGRESS
  toEnum 37 = EALREADY
  toEnum 38 = ENOTSOCK
  toEnum 39 = EDESTADDRREQ
  toEnum 40 = EMSGSIZE
  toEnum 41 = EPROTOTYPE
  toEnum 42 = ENOPROTOOPT
  toEnum 43 = EPROTONOSUPPORT
  toEnum 44 = ESOCKTNOSUPPORT
  toEnum 45 = EOPNOTSUPP
  toEnum 46 = EPFNOSUPPORT
  toEnum 47 = EAFNOSUPPORT
  toEnum 48 = EADDRINUSE
  toEnum 49 = EADDRNOTAVAIL
  toEnum 50 = ENETDOWN
  toEnum 51 = ENETUNREACH
  toEnum 52 = ENETRESET
  toEnum 53 = ECONNABORTED
  toEnum 54 = ECONNRESET
  toEnum 55 = ENOBUFS
  toEnum 56 = EISCONN
  toEnum 57 = ENOTCONN
  toEnum 58 = ESHUTDOWN
  toEnum 59 = ETOOMANYREFS
  toEnum 60 = ETIMEDOUT
  toEnum 61 = ECONNREFUSED
  toEnum 62 = ELOOP
  toEnum 63 = ENAMETOOLONG
  toEnum 64 = EHOSTDOWN
  toEnum 65 = EHOSTUNREACH
  toEnum 66 = ENOTEMPTY
  toEnum 67 = EPROCLIM
  toEnum 68 = EUSERS
  toEnum 69 = EDQUOT
  toEnum 70 = ESTALE
  toEnum 71 = EREMOTE
  toEnum 72 = EWOULDBLOCK
  toEnum 77 = ENOLCK
  toEnum 78 = ENOSYS
  toEnum 82 = EIDRM
  toEnum 83 = ENOMSG
  toEnum 84 = EOVERFLOW
  toEnum 85 = EILSEQ
  toEnum 86 = ENOTSUP
  toEnum 87 = ECANCELED
  toEnum 88 = EBADMSG
  toEnum 89 = ENODATA
  toEnum 90 = ENOSR
  toEnum 91 = ENOSTR
  toEnum 92 = ETIME
  toEnum 93 = ENOATTR
  toEnum 94 = EMULTIHOP
  toEnum 95 = ENOLINK
  toEnum 96 = EPROTO
  toEnum _ = Edummy
  fromEnum EPERM = 1
  fromEnum ENOENT = 2
  fromEnum ESRCH = 3
  fromEnum EINTR = 4
  fromEnum EIO = 5
  fromEnum ENXIO = 6
  fromEnum E2BIG = 7
  fromEnum ENOEXEC = 8
  fromEnum EBADF = 9
  fromEnum ECHILD = 10
  fromEnum EDEADLK = 11
  fromEnum ENOMEM = 12
  fromEnum EACCES = 13
  fromEnum EFAULT = 14
  fromEnum ENOTBLK = 15
  fromEnum EBUSY = 16
  fromEnum EEXIST = 17
  fromEnum EXDEV = 18
  fromEnum ENODEV = 19
  fromEnum ENOTDIR = 20
  fromEnum EISDIR = 21
  fromEnum EINVAL = 22
  fromEnum ENFILE = 23
  fromEnum EMFILE = 24
  fromEnum ENOTTY = 25
  fromEnum ETXTBSY = 26
  fromEnum EFBIG = 27
  fromEnum ENOSPC = 28
  fromEnum ESPIPE = 29
  fromEnum EROFS = 30
  fromEnum EMLINK = 31
  fromEnum EPIPE = 32
  fromEnum EDOM = 33
  fromEnum ERANGE = 34
  fromEnum EAGAIN = 35
  fromEnum EINPROGRESS = 36
  fromEnum EALREADY = 37
  fromEnum ENOTSOCK = 38
  fromEnum EDESTADDRREQ = 39
  fromEnum EMSGSIZE = 40
  fromEnum EPROTOTYPE = 41
  fromEnum ENOPROTOOPT = 42
  fromEnum EPROTONOSUPPORT = 43
  fromEnum ESOCKTNOSUPPORT = 44
  fromEnum EOPNOTSUPP = 45
  fromEnum EPFNOSUPPORT = 46
  fromEnum EAFNOSUPPORT = 47
  fromEnum EADDRINUSE = 48
  fromEnum EADDRNOTAVAIL = 49
  fromEnum ENETDOWN = 50
  fromEnum ENETUNREACH = 51
  fromEnum ENETRESET = 52
  fromEnum ECONNABORTED = 53
  fromEnum ECONNRESET = 54
  fromEnum ENOBUFS = 55
  fromEnum EISCONN = 56
  fromEnum ENOTCONN = 57
  fromEnum ESHUTDOWN = 58
  fromEnum ETOOMANYREFS = 59
  fromEnum ETIMEDOUT = 60
  fromEnum ECONNREFUSED = 61
  fromEnum ELOOP = 62
  fromEnum ENAMETOOLONG = 63
  fromEnum EHOSTDOWN = 64
  fromEnum EHOSTUNREACH = 65
  fromEnum ENOTEMPTY = 66
  fromEnum EPROCLIM = 67
  fromEnum EUSERS = 68
  fromEnum EDQUOT = 69
  fromEnum ESTALE = 70
  fromEnum EREMOTE = 71
  fromEnum EWOULDBLOCK = 72
  fromEnum ENOLCK = 77
  fromEnum ENOSYS = 78
  fromEnum EIDRM = 82
  fromEnum ENOMSG = 83
  fromEnum EOVERFLOW = 84
  fromEnum EILSEQ = 85
  fromEnum ENOTSUP = 86
  fromEnum ECANCELED = 87
  fromEnum EBADMSG = 88
  fromEnum ENODATA = 89
  fromEnum ENOSR = 90
  fromEnum ENOSTR = 91
  fromEnum ETIME = 92
  fromEnum ENOATTR = 93
  fromEnum EMULTIHOP = 94
  fromEnum ENOLINK = 95
  fromEnum EPROTO = 96

eqErrNo :: ErrNo -> ErrNo -> Bool
eqErrNo EWOULDBLOCK EAGAIN = True
eqErrNo EAGAIN EWOULDBLOCK = True
eqErrNo a b = a==b

alreadyexists = [  EEXIST, EISDIR ]
doesnotexist = [  ENOENT, ESRCH, ENXIO, ENODEV ]
alreadyinuse = [  EBUSY, ETXTBSY ]
full = [  ENOSPC, EDQUOT ]
illegalop = [  EPERM, ESPIPE ]
nopermission = [  EPERM, EACCES, EROFS ]


