Get rid of E_FCHDIR.
[paraslash.git] / error.h
diff --git a/error.h b/error.h
index 5ed3830450b2b1e19bf76600513f1c7e7ebc562d..d248190002fac3860157717dd6b0da55acebcfcb 100644 (file)
--- a/error.h
+++ b/error.h
@@ -408,20 +408,8 @@ extern const char **para_errlist[];
 
 
 #define FD_ERRORS \
-       PARA_ERROR(NOTDIR, "error: not a directory"), \
-       PARA_ERROR(F_GETFL, "failed to get fd flags"), \
-       PARA_ERROR(F_SETFL, "failed to set fd flags"), \
        PARA_ERROR(FGETS, "fgets error"), \
-       PARA_ERROR(EXIST, "file or directory already exists"), \
-       PARA_ERROR(ISDIR, "error: is a directory"), \
-       PARA_ERROR(NOENT, "no such file or directory"), \
-       PARA_ERROR(OPEN_PERM, "open error (permission denied)"), \
-       PARA_ERROR(MKDIR_PERM, "mkdir error (permission denied)"), \
-       PARA_ERROR(MKDIR, "failed to create directory"), \
        PARA_ERROR(CHDIR, "failed to change directory"), \
-       PARA_ERROR(FCHDIR, "fchdir failed"), \
-       PARA_ERROR(OPENDIR, "can not open directory"), \
-       PARA_ERROR(NOSPC, "no space left on device"), \
        PARA_ERROR(OPEN, "failed to open file"), \
        PARA_ERROR(CHDIR_PERM, "insufficient permissions to chdir"), \
 
@@ -516,17 +504,27 @@ extern const char **para_errlist[];
  */
 #define ERRNUM_TO_INDEX(num) (((1 << SS_SHIFT) - 1) & (num))
 
+#define SYSTEM_ERROR_BIT 30
+
+#define IS_SYSTEM_ERROR(num) (!!((num) & (1 << SYSTEM_ERROR_BIT)))
+
+#define ERRNO_TO_PARA_ERROR(num) ((num) | (1 << SYSTEM_ERROR_BIT))
+
+static inline int is_errno(int val, int _errno)
+{
+       assert(val > 0 && _errno > 0);
+       return ERRNO_TO_PARA_ERROR(_errno) == val;
+}
+
 /**
  * paraslash's version of strerror(3)
  *
  * expands to the error text of \a num (a string constant).
  */
-#define PARA_STRERROR(num) (num) & (1 << 30)? \
-       strerror((num) & ((1 << 30) - 1)) : \
+#define PARA_STRERROR(num) IS_SYSTEM_ERROR(num)? \
+       strerror((num) & ((1 << SYSTEM_ERROR_BIT) - 1)) : \
        para_errlist[ERRNUM_TO_SS(num)] [ERRNUM_TO_INDEX(num)]
 
-#define ERRNO_TO_PARA_ERROR(num) (-((num) | (1 << 30)))
-
 /**
  * define the error list for one subsystem
  #