2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * This file implements exceptions entity handler methods.
20 * @file stc-exception.c
23 #include "stc-manager.h"
24 #include "stc-exception.h"
26 #define EXCEPTION_BUF_MAX 64
27 #define EXCEPTION_STORAGE "/var/lib/stc/exceptions"
29 stc_error_e table_exceptions_foreach(const table_exceptions_info_cb exception_cb,
32 __STC_LOG_FUNC_ENTER__;
34 stc_error_e error_code = STC_ERROR_NONE;
35 table_exceptions_info data;
38 char buf[EXCEPTION_BUF_MAX] = {0, };
40 fp = fopen(EXCEPTION_STORAGE, "r");
41 ret_value_msg_if(!fp, STC_ERROR_FAIL, "Failed to open %s file");
43 while (fgets(buf, sizeof(buf), fp) != NULL) {
44 char *process_name, *exe_type;
45 char *save_ptr = NULL;
47 process_name = strtok_r(buf, ":", &save_ptr);
48 if (process_name != NULL)
49 data.process_name = process_name;
51 data.process_name = "none";
53 exe_type = strtok_r(NULL, "\n", &save_ptr);
55 data.exe_type = exe_type;
57 data.exe_type = "none";
59 if (exception_cb(&data, user_data) == STC_CANCEL)
64 __STC_LOG_FUNC_EXIT__;