1 /* Copyright (c) 2007-2018 Dovecot authors, see the included COPYING file */
2 
3 #include "lib.h"
4 #include "eacces-error.h"
5 #include "mail-error.h"
6 
mail_error_from_errno(enum mail_error * error_r,const char ** error_string_r)7 bool mail_error_from_errno(enum mail_error *error_r,
8 			   const char **error_string_r)
9 {
10 	if (ENOACCESS(errno)) {
11 		*error_r = MAIL_ERROR_PERM;
12 		*error_string_r = MAIL_ERRSTR_NO_PERMISSION;
13 	} else if (ENOQUOTA(errno)) {
14 		*error_r = MAIL_ERROR_NOQUOTA;
15 		*error_string_r = MAIL_ERRSTR_NO_QUOTA;
16 	} else if (ENOTFOUND(errno)) {
17 		*error_r = MAIL_ERROR_NOTFOUND;
18 		*error_string_r = errno != ELOOP ? "Not found" :
19 			"Directory structure is broken";
20 	} else {
21 		return FALSE;
22 	}
23 	return TRUE;
24 }
25 
mail_error_eacces_msg(const char * func,const char * path)26 const char *mail_error_eacces_msg(const char *func, const char *path)
27 {
28 	return eacces_error_get(func, path);
29 }
30 
mail_error_create_eacces_msg(const char * func,const char * path)31 const char *mail_error_create_eacces_msg(const char *func, const char *path)
32 {
33 	return eacces_error_get_creating(func, path);
34 }
35