Fixed codes which may occur potential bugs.
[sdk/target/sdbd.git] / src / sdb_client.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 _SDB_CLIENT_H_
18 #define _SDB_CLIENT_H_
19
20 #include "sdb.h"
21
22 /* connect to sdb, connect to the named service, and return
23 ** a valid fd for interacting with that service upon success
24 ** or a negative number on failure
25 */
26 int sdb_connect(const char *service);
27 int _sdb_connect(const char *service);
28
29 /* connect to sdb, connect to the named service, return 0 if
30 ** the connection succeeded AND the service returned OKAY
31 */
32 int sdb_command(const char *service);
33
34 /* connect to sdb, connect to the named service, return
35 ** a malloc'd string of its response upon success or NULL
36 ** on failure.
37 */
38
39 char *sdb_query(const char *service);
40
41 /* Set the preferred transport to connect to.
42 */
43 void sdb_set_transport(transport_type type, const char* serial);
44
45 /* Set TCP specifics of the transport to use
46 */
47 void sdb_set_tcp_specifics(int server_port);
48
49 /* Return the console port of the currently connected emulator (if any)
50  * of -1 if there is no emulator, and -2 if there is more than one.
51  * assumes sdb_set_transport() was alled previously...
52  */
53 int  sdb_get_emulator_console_port(void);
54
55 /* send commands to the current emulator instance. will fail if there
56  * is zero, or more than one emulator connected (or if you use -s <serial>
57  * with a <serial> that does not designate an emulator)
58  */
59 int  sdb_send_emulator_command(int  argc, char**  argv);
60
61 /* return verbose error string from last operation */
62 const char *sdb_error(void);
63
64 /* read a standard sdb status response (OKAY|FAIL) and
65 ** return 0 in the event of OKAY, -1 in the event of FAIL
66 ** or protocol error
67 */
68 int sdb_status(int fd);
69
70 #endif