}
char buf[100] = "";
- int rl_result = read_line(result, buf, 100);
- if(rl_result < 0) {
- D("Error to read buffer (fd=%d)\n", rl_result);
- return rl_result;
+ int rl_result = read_lines(result, buf, 100);
+ if(rl_result <= 0) {
+ fprintf(stderr, "error: package '%s' does not exist\n", app_id);
+ return -1;
+ }
+
+ if(rl_result > 1) {
+ fprintf(stderr, "error: '%s' is not unique package id\n", app_id);
+ return -1;
}
sdb_close(result);
result = -1;
+ char* end_line = strchr(buf, '\n');
+
+ if(end_line != NULL) {
+ *end_line = '\0';
+ }
+
if(strstr(buf, "[tpk]") != NULL) {
result = 1;
- } else if(strstr(buf, "[wgt]") != NULL) {
+ }
+ else if(strstr(buf, "[wgt]") != NULL) {
result = 0;
}
+ else {
+ if(strstr(buf, "error") != NULL) {
+ fprintf(stderr, "%s\n", buf);
+ }
+ else {
+ fprintf(stderr, "error: not supported package type '%s'\n", buf);
+ }
+ }
return result;
}
int fd = sdb_connect("sync:", extargv);
if(fd < 0) {
- fprintf(stderr,"cannot sync remote: %s\n", strerror(errno));
return -1;
}
const char* COMMANDLINE_UNINSTALL_NAME = "uninstall";
const char* COMMANDLINE_UNINSTALL_DESC[] = {
- "uninstall an app from the device"
+ "uninstall an app from the device",
+ "the <pkg_id> is an unique 10-digit unique identifier for the application. The following command shows an example:",
+ "Ex.) sdb uninstall ko983dw33q"
};
const int COMMANDLINE_UNINSTALL_DESC_SIZE = GET_ARRAY_SIZE(COMMANDLINE_UNINSTALL_DESC, char*);
- const char* COMMANDLINE_UNINSTALL_ARG_DESC = "<app_id>";
+ const char* COMMANDLINE_UNINSTALL_ARG_DESC = "<pkg_id>";
const int COMMANDLINE_UNINSTALL_MAX_ARG = 1;
const int COMMANDLINE_UNINSTALL_MIN_ARG = 1;
}
}
+int read_lines(const int fd, char* ptr, unsigned int maxlen)
+{
+ int lines = 0;
+ while (1) {
+ int len = read_line(fd, ptr, maxlen);
+ if(len < 0) {
+ break;
+ }
+ ptr += len;
+ *ptr++ = '\n';
+ len++;
+ maxlen -= len;
+ lines++;
+ }
+ return lines;
+}
+
int read_line(const int fd, char* ptr, const unsigned int maxlen)
{
unsigned int n = 0;
size_t tokenize(const char *str, const char *delim, char *tokens[], size_t max_tokens);
void free_strings(char **array, int n);
+int read_lines(const int fd, char* ptr, const unsigned int maxlen);
int read_line(const int fd, char* ptr, const unsigned int maxlen);
char *s_strncpy(char *dest, const char *source, size_t n);
size_t s_strnlen(const char *s, size_t maxlen);