uint16_t len = 0;
int supported = SYNCWINSZ_UNSUPPORTED;
int fd = -1;
+ char* failmsg = NULL;
snprintf(full_cmd, sizeof(full_cmd), "capability:");
- fd = sdb_connect(full_cmd);
+ fd = sdb_connect_getfailmsg(full_cmd, &failmsg);
if (fd >= 0) {
readx(fd, &len, sizeof(uint16_t));
if (len > CAPBUF_SIZE-1) {
if (ret == 1) {
supported = SYNCWINSZ_SUPPORTED;
}
+ } else {
+ D("This platform does not support the capability service.\n");
+ if (failmsg != NULL) {
+ D("sdb_connect() fail message : %s\n", failmsg);
+ SAFE_FREE(failmsg);
+ }
}
+
return supported;
}
return -1;
}
-int sdb_status(int fd, int host_fd)
+#define SDB_FAILMSG_BUF_SIZE 255
+int sdb_status_getfailmsg(int fd, int host_fd, char** pp_failmsg)
{
unsigned char buf[5];
if(len > 254) len = 254;
- char error[255];
+ char error[SDB_FAILMSG_BUF_SIZE] = {0,};
if(readx(fd, error, len)) {
if(host_fd == 0) {
print_error(SDB_MESSAGE_ERROR, "protocol fault", "status read");
}
error[len] = '\0';
if(host_fd == 0) {
- fprintf(stderr,"%s\n", error);
+ if (pp_failmsg != NULL) {
+ *pp_failmsg = malloc(SDB_FAILMSG_BUF_SIZE);
+ if ((*pp_failmsg) == NULL) {
+ return -1;
+ }
+ strncpy(*pp_failmsg, error, SDB_FAILMSG_BUF_SIZE);
+ } else {
+ fprintf(stderr,"%s\n", error);
+ }
}
else {
char err_msg[255];
return -1;
}
+int sdb_status(int fd, int host_fd)
+{
+ return sdb_status_getfailmsg(fd, host_fd, NULL);
+}
+
/**
* First check whether host service or transport service,
* If transport service, send transport prefix. Then, do the service.
* If host service, do the service. does not have to get transport.
*/
-int _sdb_connect(const char *service)
+int _sdb_connect_getfailmsg(const char *service, char** pp_failmsg)
{
int fd;
return -1;
}
- if(sdb_status(fd, 0)) {
+ if(sdb_status_getfailmsg(fd, 0, pp_failmsg)) {
sdb_close(fd);
return -1;
}
return fd;
}
+int _sdb_connect(const char *service)
+{
+ return _sdb_connect_getfailmsg(service, NULL);
+}
+
int read_msg_size(int fd) {
char buf[5];
* First, check the host version.
* Then, send the service using _sdb_connect
*/
-int sdb_connect(const char *service)
+int sdb_connect_getfailmsg(const char *service, char** pp_failmsg)
{
int only_detect_tizen_device;
// check version before sending a sdb command
}
}
- fd = _sdb_connect(service);
+ fd = _sdb_connect_getfailmsg(service, pp_failmsg);
if(fd == -2) {
print_error(SDB_MESSAGE_ERROR, ERR_GENERAL_SERVER_NOT_RUN, NULL);
}
return fd;
}
+int sdb_connect(const char *service)
+{
+ return sdb_connect_getfailmsg(service, NULL);
+}
int sdb_command(const char *service)
{
int send_service_with_length(int fd, const char* service, int host_fd);
int sdb_status(int fd, int host_fd);
+int sdb_status_getfailmsg(int fd, int host_fd, char** pp_failmsg);
/* connect to sdb, connect to the named service, and return
** a valid fd for interacting with that service upon success
*/
int sdb_connect(const char *service);
int _sdb_connect(const char *service);
+/* function to get a failmsg.
+** pp_failmsg :
+** If pp_failmsg is NULL, outputs a failmsg to stderr.
+** If pp_failmsg is not NULL, returns allocated failmsg buffer pointer.
+** The failmsg buffer must be free in the caller.
+*/
+int sdb_connect_getfailmsg(const char *service, char** pp_failmsg);
+int _sdb_connect_getfailmsg(const char *service, char** pp_failmsg);
/* connect to sdb, connect to the named service, return 0 if
** the connection succeeded AND the service returned OKAY