Move function definition to aul header
[platform/core/appfw/aul-1.git] / src / aul_error.c
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #define _GNU_SOURCE
18 #include <errno.h>
19
20 #include "aul_util.h"
21 #include "aul_error.h"
22 #include "aul_sock.h"
23 #include "aul.h"
24
25 int aul_error_convert(int res)
26 {
27         int ret;
28
29         switch (res) {
30         case -ENOMEM:
31                 ret = AUL_R_ENOMEM;
32                 break;
33         case -EREJECTED:
34                 ret = AUL_R_EREJECTED;
35                 break;
36         case -ENOENT:
37                 ret = AUL_R_ENOAPP;
38                 break;
39         case -ETERMINATING:
40                 ret = AUL_R_ETERMINATING;
41                 break;
42         case -EILLEGALACCESS:
43                 ret = AUL_R_EILLACC;
44                 break;
45         case -ELOCALLAUNCH_ID:
46                 ret = AUL_R_LOCAL;
47                 break;
48         case -EAGAIN:
49                 ret = AUL_R_ETIMEOUT;
50                 break;
51         case -EINVAL:
52                 ret = AUL_R_EINVAL;
53                 break;
54         case -ECOMM:
55                 ret = AUL_R_ECOMM;
56                 break;
57         case -ECANCELED:
58                 ret = AUL_R_ECANCELED;
59                 break;
60         default:
61                 ret = AUL_R_ERROR;
62                 break;
63         }
64
65         return ret;
66 }
67