1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
/*
* Copyright 2012 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <dirent.h>
#include <sys/types.h>
#include <string.h>
#include <glib.h>
#include "mf-ug-dlog.h"
#include "mf-ug-search.h"
#include "mf-ug-search-internal.h"
/*+++++++++++++++++++++++ APIs +++++++++++++++++++++++*/
int mf_ug_search_init(mf_search_handle *handle)
{
int ret = 0;
ms_handle_t *ms_handle = NULL;
if (!handle) {
return -1;
}
if (!g_thread_supported()) {
g_thread_init(NULL);
}
ret = _mf_ug_search_init(&ms_handle);
if (ret < 0) {
ms_error("Fail to init search handle ");
*handle = (mf_search_handle) 0;
return ret;
}
*handle = (mf_search_handle) ms_handle;
return MF_SEARCH_ERROR_NONE;
}
int mf_ug_search_start(mf_search_handle handle,
const char **root_path, unsigned int path_num, const char *needle, mf_search_option option, void *user_data)
{
int ret = 0;
if (!handle) {
return MF_SEARCH_ERROR_INVAL_P;
}
if (!root_path || !needle || path_num < 1) {
return MF_SEARCH_ERROR_INVAL_P;
}
ret = _mf_ug_search_start((ms_handle_t *) handle, root_path, path_num, needle, option, user_data);
if (ret < 0) {
ms_error("Fail to start search ");
}
return ret;
}
int mf_ug_search_stop(mf_search_handle handle)
{
int ret = 0;
ret = _mf_ug_search_stop((ms_handle_t *) handle);
if (ret < 0) {
ms_error("Fail to stop search ");
}
return ret;
}
void mf_ug_search_finalize(mf_search_handle *handle)
{
_mf_ug_search_finalize((ms_handle_t **) handle);
return;
}
/*+++++++++++++++++++++++ UTIL APIs +++++++++++++++++++++++*/
char *mf_ug_search_result_dir_get(mf_search_result_t *result)
{
return _mf_ug_search_result_dir_get(result);
}
char *mf_ug_search_result_file_get(mf_search_result_t *result)
{
return _mf_ug_search_result_file_get(result);
}
int mf_ug_search_result_is_end(mf_search_result_t *result, int *is_end)
{
if (result) {
*is_end = _mf_ug_search_result_is_end(result);
} else {
return MF_SEARCH_ERROR_INVAL_P;
}
return MF_SEARCH_ERROR_NONE;
}
int mf_ug_search_result_total_count_get(mf_search_result_t *result, unsigned int *count)
{
if (result) {
*count = _mf_ug_search_result_total_count_get(result);
} else {
return MF_SEARCH_ERROR_INVAL_P;
}
return MF_SEARCH_ERROR_NONE;
}
char *mf_ug_search_result_current_dir_get(mf_search_result_t *result)
{
return _mf_ug_search_result_current_dir_get(result);
}
|