From 775f5ffcca323001cf17ce5473008906b90c4217 Mon Sep 17 00:00:00 2001 From: Vinicius Costa Gomes Date: Wed, 2 Jul 2008 11:21:42 -0300 Subject: [PATCH] obexd: Fixing going to parent folder and some folder listing optimizations. --- obexd/src/ftp.c | 23 +++++++++-------------- obexd/src/obex.c | 7 +------ 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/obexd/src/ftp.c b/obexd/src/ftp.c index 25aae3f03..b4dc42509 100644 --- a/obexd/src/ftp.c +++ b/obexd/src/ftp.c @@ -73,12 +73,11 @@ "modified=\"%s\" created=\"%s\"/>" EOL_CHARS -static gchar *file_stat_line(gchar *filename, struct stat fstat, - struct stat dstat) +static gchar *file_stat_line(gchar *filename, struct stat fstat, struct stat dstat) { - gchar *perm, atime[17], ctime[17], mtime[17], *result; + gchar perm[50], atime[17], ctime[17], mtime[17]; - perm = g_strdup_printf("user-perm=\"%s%s%s\" group-perm=\"%s%s%s\" " + snprintf(perm, 49, "user-perm=\"%s%s%s\" group-perm=\"%s%s%s\" " "other-perm=\"%s%s%s\"", (fstat.st_mode & S_IRUSR ? "R" : ""), (fstat.st_mode & S_IWUSR ? "W" : ""), @@ -95,15 +94,11 @@ static gchar *file_stat_line(gchar *filename, struct stat fstat, strftime(mtime, 16, "%Y%m%dT%H%M%S", gmtime(&fstat.st_mtime)); if (S_ISDIR(fstat.st_mode)) - result = g_strdup_printf(FL_FOLDER_ELEMENT, filename, - perm, atime, mtime, ctime); - else - result = g_strdup_printf(FL_FILE_ELEMENT, filename, fstat.st_size, - perm, atime, mtime, ctime); + return g_strdup_printf(FL_FOLDER_ELEMENT, filename, + perm, atime, mtime, ctime); - g_free(perm); - - return result; + return g_strdup_printf(FL_FILE_ELEMENT, filename, fstat.st_size, + perm, atime, mtime, ctime); } static gboolean folder_listing(struct obex_session *os, guint32 *size) @@ -120,8 +115,8 @@ static gboolean folder_listing(struct obex_session *os, guint32 *size) if (strcmp(os->current_folder,os->server->folder)) listing = g_string_append(listing, FL_PARENT_FOLDER_ELEMENT); - if (stat(os->current_folder, &dstat) < 0) { - error("get_folder_listing: %s(%d)", strerror(errno), errno); + if (lstat(os->current_folder, &dstat) < 0) { + error("lstat: %s(%d)", strerror(errno), errno); return FALSE; } diff --git a/obexd/src/obex.c b/obexd/src/obex.c index f83133798..f9d278421 100644 --- a/obexd/src/obex.c +++ b/obexd/src/obex.c @@ -371,12 +371,6 @@ static void cmd_setpath(struct obex_session *os, } } - if (!os->name) { - OBEX_ObjectSetRsp(obj, OBEX_RSP_BAD_REQUEST, - OBEX_RSP_BAD_REQUEST); - return; - } - os->cmds->setpath(obex, obj); } @@ -649,6 +643,7 @@ static void obex_event(obex_t *obex, obex_object_t *obj, gint mode, emit_transfer_progress(os->cid, os->size, os->offset); break; case OBEX_EV_ABORT: + os_reset_session(os); OBEX_ObjectSetRsp(obj, OBEX_RSP_SUCCESS, OBEX_RSP_SUCCESS); break; case OBEX_EV_REQDONE: -- 2.47.3