Skip to contentSkip to conversation

gobex: Add "cd ../dir" handling in setpath

PATCH Applied Bartosz Szatkowski 2 participants 2 messages Nov 17, 2011 – Nov 18, 2011 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gobex: Add "cd ../dir" handling in setpath

---
 gobex/gobex.c     |   14 ++++++++++----
 unit/test-gobex.c |   42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 4 deletions(-)
gobex/gobex.c +10 -4
index 7840304..b374b06 100644
@@ -1088,6 +1088,7 @@ guint g_obex_setpath(GObex *obex, const char *path, GObexResponseFunc func,
 {
 	GObexPacket *req;
 	struct setpath_data data;
+	const char *folder;
 
 	g_obex_debug(G_OBEX_DEBUG_COMMAND, "conn %u", obex->conn_id);
 
@@ -1095,12 +1096,17 @@ guint g_obex_setpath(GObex *obex, const char *path, GObexResponseFunc func,
 
 	memset(&data, 0, sizeof(data));
 
-	if (strcmp(path, "..") == 0)
+	if (path != NULL && strncmp("..", path, 2) == 0) {
 		data.flags = 0x03;
-	else {
-		GObexHeader *hdr;
+		folder = (path[2] == '/') ? &path[3] : NULL;
+	} else {
 		data.flags = 0x02;
-		hdr = g_obex_header_new_unicode(G_OBEX_HDR_NAME, path);
+		folder = path;
+	}
+
+	if (folder != NULL) {
+		GObexHeader *hdr;
+		hdr = g_obex_header_new_unicode(G_OBEX_HDR_NAME, folder);
 		g_obex_packet_add_header(req, hdr);
 	}
 
unit/test-gobex.c +42 -0

60 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#1 lore raw

Hi Bartosz,

Quoted 4 lines · Bartosz Szatkowski
---
 gobex/gobex.c     |   14 ++++++++++----
 unit/test-gobex.c |   42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 4 deletions(-)

Applied. Thanks.

Johan