#ifndef _ERRNO_H
#define _ERRNO_H

/* The last error encountered during a call to a library or system function. */
extern int errno;

#define EPERM 1         // Operation not permitted
#define ENOENT 2        // No such file or directory
#define ESRCH 3         // No such process
#define EINTR 4         // Interrupted system call. Not implemented.
#define EIO 5           // Input/output error. Not implemented.
#define ENXIO 6         // No such device or address. Not implemented.
#define E2BIG 7         // Argument list too long
#define ENOEXEC 8       // Exec format error
#define EBADF 9         // Bad file descriptor
#define ECHILD 10       // No child processes
#define EAGAIN 11       // Resource temporarily unavailable
#define EWOULDBLOCK 11  // Resource temporarily unavailable
#define ENOMEM 12       // Cannot allocate memory
#define EACCES 13       // Permission denied
#define EFAULT 14       // Bad address
#define EBUSY 16        // Device or resource busy. Not implemented.
#define EEXIST 17       // File exists
#define EXDEV 18        // Invalid cross-device link. Not implemented.
#define ENODEV 19       // No such device. Not implemented.
#define ENOTDIR 20      // Not a directory
#define EISDIR 21       // Is a directory
#define EINVAL 22       // Invalid argument
#define ENFILE 23       // Too many open files in system. Not implemented.
#define EMFILE 24       // Too many open files
#define ENOTTY 25       // Inappropriate ioctl for device
#define EFBIG 27        // File too large. Not implemented.
#define ENOSPC 28       // No space left on device
#define ESPIPE 29       // Illegal seek. Not implemented.
#define EROFS 30        // Read-only file system. Not implemented.
#define EMLINK 31       // Too many links. Not implemented.
#define EPIPE 32        // Broken pipe. Not implemented.
#define EDOM 33         // Numerical argument out of domain. Not implemented.
#define ERANGE 34       // Numerical result out of range
#define EDEADLK 35      // Resource deadlock avoided. Not implemented.
#define ENAMETOOLONG 36 // File name too long. Not implemented.
#define ENOLCK 37       // No locks available. Not implemented.
#define ENOSYS 38       // Function not implemented
#define ENOTEMPTY 39    // Directory not empty. Not implemented.
#define ELOOP 40        // Too many levels of symbolic links. Not implemented.
#define ENOMSG 42       // No message of desired type. Not implemented.
#define EOVERFLOW 75    // Value too large for defined data type. Not implemented.
#define EILSEQ 84       // Invalid or incomplete multibyte or wide character. Not implemented.
#define ENOTSOCK 88     // Socket operation on non-socket. Not implemented.
#define ENOTSUP 95      // Operation not supported
#define EOPNOTSUPP 95   // Operation not supported
#define EADDRINUSE 98   // Address already in use. Not implemented.
#define ENETRESET 102   // Network dropped connection on reset. Not implemented.
#define ECONNRESET 104  // Connection reset by peer. Not implemented.
#define EISCONN 106     // Transport endpoint is already connected. Not implemented.
#define ETIMEDOUT 110   // Connection timed out. Not implemented.
#define EALREADY 114    // Operation already in progress. Not implemented.

// FIXME: Right now I don't want to have to order and label these, since we have no net support anyways.
#define EADDRNOTAVAIL -1
#define EAFNOSUPPORT -2
#define ECONNABORTED -3
#define ECONNREFUSED -4
#define EDESTADDRREQ -5
#define EHOSTUNREACH -6
#define EINPROGRESS -7
#define EMSGSIZE -8
#define ENETDOWN -9
#define ENETRESET -10
#define ENETUNREACH -11
#define ENOBUFS -12
#define ENOMSG -13
#define ENOPROTOOPT -14
#define ENOTCONN -15
#define ENOTSOCK -16
#define EPROTONOSUPPORT -17
#define EPROTOTYPE -18

#ifdef _GNU_SOURCE // Give it only to programs that ask for it.
/* Name used to invoke calling program. Same value as argv[0] in main(), but can be used globally. */
extern char* program_invocation_name;
#endif

#endif