Implementation of automatic command exchange feature.
[sdk/target/sdbd.git] / src / plugin.h
1 /*
2  * Copyright (c) 2011 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 #ifndef __PLUGIN_H
18 #define __PLUGIN_H
19
20 #include "sdbd_plugin.h"
21
22 #define PLUGIN_PATH        "/usr/lib/libsdbd_plugin.so"
23 #define PLUGIN_XML_PATH    "/etc/sdbd/commands.xml"
24
25 extern char* extcmd;
26
27 int default_plugin_init ( eventfunc event_cb, registerfunc register_func );
28 int default_plugin_sync_proc ( int cmd, parameters* in, parameters* out );
29 int default_plugin_async_proc ( int cmd, parameters* in, int out_fd );
30
31 void load_sdbd_plugin();
32 void unload_sdbd_plugin();
33
34 int request_sync_cmd ( int cmd, parameters* in, parameters* out );
35
36 // return 1 if plugin support given command
37 // return 0 if plugin does not support given command
38 int is_supported_by_plugin ( int cmd );
39
40 // return 1 if succeed to get capability from plugin
41 // return 0 otherwise
42 int request_capability_to_plugin ( int cap, char* out_buf, unsigned int out_len );
43
44 // return 1 if allowed by plugin (valid)
45 // return 0 if disallowed by plugin (invalid)
46 int request_validity_to_plugin ( int cmd, const char* in_buf );
47
48 // return 1 if succeed to convert
49 // return 0 otherwise
50 int request_conversion_to_plugin ( int cmd, const char* in_buf, char* out_buf, unsigned int out_len );
51
52 // return 1 if locked
53 // return 0 if unlocked
54 // return -1 if request failed
55 int request_lock_state_to_plugin ( int lock_type );
56
57 // return nonnegative integer that is a socket descriptor for communication
58 //        with async proc thread if success to create async proc thread
59 // return -1 if failed to create async proc thread
60 int request_appcmd_to_plugin ( const char* in_buf );
61
62 #endif //__PLUGIN_H