-#if SDB_HOST
- // "transport:" is used for switching transport with a specified serial number
- // "transport-usb:" is used for switching transport to the only USB transport
- // "transport-local:" is used for switching transport to the only local transport
- // "transport-any:" is used for switching transport to the only transport
- if (!strncmp(service, "transport", strlen("transport"))) {
- char* error_string = "unknown failure";
- transport_type type = kTransportAny;
-
- if (!strncmp(service, "transport-usb", strlen("transport-usb"))) {
- type = kTransportUsb;
- } else if (!strncmp(service, "transport-local", strlen("transport-local"))) {
- type = kTransportLocal;
- } else if (!strncmp(service, "transport-any", strlen("transport-any"))) {
- type = kTransportAny;
- } else if (!strncmp(service, "transport:", strlen("transport:"))) {
- service += strlen("transport:");
- serial = service;
- }
-
- transport = acquire_one_transport(CS_ANY, type, serial, &error_string);
-
- if (transport) {
- s->transport = transport;
- sdb_write(reply_fd, "OKAY", 4);
- } else {
- sendfailmsg(reply_fd, error_string);
- }
- return 1;
- }
-
- // return a list of all connected devices
- if (!strcmp(service, "devices")) {
- char buffer[4096];
- memset(buf, 0, sizeof(buf));
- memset(buffer, 0, sizeof(buffer));
- D("Getting device list \n");
- list_transports(buffer, sizeof(buffer));
- snprintf(buf, sizeof(buf), "OKAY%04x%s",(unsigned)strlen(buffer),buffer);
- D("Wrote device list \n");
- writex(reply_fd, buf, strlen(buf));
- return 0;
- }
-
- // add a new TCP transport, device or emulator
- if (!strncmp(service, "connect:", 8)) {
- char buffer[4096];
- char* host = service + 8;
- if (!strncmp(host, "emu:", 4)) {
- connect_emulator(host + 4, buffer, sizeof(buffer));
- } else {
- connect_device(host, buffer, sizeof(buffer));
- }
- // Send response for emulator and device
- snprintf(buf, sizeof(buf), "OKAY%04x%s",(unsigned)strlen(buffer), buffer);
- writex(reply_fd, buf, strlen(buf));
- return 0;
- }
-
- // remove TCP transport
- if (!strncmp(service, "disconnect:", 11)) {
- char buffer[4096];
- memset(buffer, 0, sizeof(buffer));
- char* serial = service + 11;
- if (serial[0] == 0) {
- // disconnect from all TCP devices
- unregister_all_tcp_transports();
- } else {
- char hostbuf[100];
- // assume port 26101 if no port is specified
- if (!strchr(serial, ':')) {
- snprintf(hostbuf, sizeof(hostbuf) - 1, "%s:26101", serial);
- serial = hostbuf;
- }
- atransport *t = find_transport(serial);
-
- if (t) {
- unregister_transport(t);
- } else {
- snprintf(buffer, sizeof(buffer), "No such device %s", serial);
- }
- }
-
- snprintf(buf, sizeof(buf), "OKAY%04x%s",(unsigned)strlen(buffer), buffer);
- writex(reply_fd, buf, strlen(buf));
- return 0;
- }
-
- // returns our value for SDB_SERVER_VERSION
- if (!strcmp(service, "version")) {
- char version[12];
- snprintf(version, sizeof version, "%04x", SDB_SERVER_VERSION);
- snprintf(buf, sizeof buf, "OKAY%04x%s", (unsigned)strlen(version), version);
- writex(reply_fd, buf, strlen(buf));
- return 0;
- }
-
- if(!strncmp(service,"get-serialno",strlen("get-serialno"))) {
- char *out = "unknown";
- transport = acquire_one_transport(CS_ANY, ttype, serial, NULL);
- if (transport && transport->serial) {
- out = transport->serial;
- }
- snprintf(buf, sizeof buf, "OKAY%04x%s",(unsigned)strlen(out),out);
- writex(reply_fd, buf, strlen(buf));
- return 0;
- }
- // indicates a new emulator instance has started
- if (!strncmp(service,"emulator:",9)) { /* tizen specific */
- char *tmp = strtok(service+9, DEVICEMAP_SEPARATOR);
- int port = 0;
-
- if (tmp == NULL) {
- port = atoi(service+9);
- } else {
- port = atoi(tmp);
- tmp = strtok(NULL, DEVICEMAP_SEPARATOR);
- if (tmp != NULL) {
- local_connect(port, tmp);
- }
- }
- local_connect(port, NULL);
- return 0;
- }
-#endif // SDB_HOST
-