Fix build error for toolchain upgrade
[platform/core/api/smart-traffic-control.git] / unittest / utc-stc-common.c
1 //
2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
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 #include <time.h>
18 #include "utc-stc-common.h"
19
20 const char *stc_get_error(int err)
21 {
22         switch (err) {
23         case STC_ERROR_NONE:
24                 return "None";
25         case STC_ERROR_NOT_PERMITTED:
26                 return "Operation not permitted";
27         case STC_ERROR_OUT_OF_MEMORY:
28                 return "Out of memory";
29         case STC_ERROR_PERMISSION_DENIED:
30                 return "Permission denied";
31         case STC_ERROR_RESOURCE_BUSY:
32                 return "Device or resource busy";
33         case STC_ERROR_INVALID_OPERATION:
34                 return "Invalid operation";
35         case STC_ERROR_INVALID_PARAMETER:
36                 return "Invalid parameter";
37         case STC_ERROR_NOT_SUPPORTED:
38                 return "Not supported";
39         case STC_ERROR_OPERATION_FAILED:
40                 return "Operation failed";
41         case STC_ERROR_NOT_INITIALIZED:
42                 return "Cgroup doen't mounted or daemon not started";
43         case STC_ERROR_ALREADY_INITIALIZED:
44                 return "Already initialized";
45         case STC_ERROR_IN_PROGRESS:
46                 return "In progress";
47         default:
48                 return "Unknown";
49         }
50 }
51
52 bool stc_check_feature_supported(char *key)
53 {
54         bool value = false;
55         int ret = system_info_get_platform_bool(key, &value);
56
57         if (ret != SYSTEM_INFO_ERROR_NONE)
58                 return false;
59
60         return value;
61 }
62
63 time_t stc_make_time(int year, int mon, int day, int hour, int min)
64 {
65         struct tm curr = { 0, };
66         curr.tm_year = year - 1900;
67         curr.tm_mon = mon - 1;
68         curr.tm_mday = day;
69         curr.tm_hour = hour;
70         curr.tm_min = min;
71         return mktime(&curr);
72 }