Index: lib/obex.c
===================================================================
RCS file: /cvsroot/openobex/openobex/lib/obex.c,v
retrieving revision 1.54
diff -u -r1.54 obex.c
--- lib/obex.c	25 Jan 2007 08:44:43 -0000	1.54
+++ lib/obex.c	3 Jun 2008 10:46:02 -0000
@@ -623,6 +623,26 @@
 
 
 /**
+ * OBEX_ObjectGetSpace - Get available space in object
+ * @self: OBEX handle
+ * @object: OBEX object
+ * @flags: OBEX_FL_FIT_ONE_PACKET or 0
+ *
+ * Get available space in object
+ * 
+ * This can be useful e.g. if the caller wants to check the size of the biggest
+ * body header that can be added to the current packet.
+ *
+ */
+int OBEX_ObjectGetSpace(obex_t *self, obex_object_t *object,
+				unsigned int flags)
+{
+	obex_return_val_if_fail(self != NULL, -1);
+	obex_return_val_if_fail(object != NULL, -1);
+	return obex_object_getspace(self, object, flags);
+}
+
+/**
  * OBEX_ObjectAddHeader - Attach a header to an object
  * @self: OBEX handle
  * @object: OBEX object
Index: lib/obex_object.c
===================================================================
RCS file: /cvsroot/openobex/openobex/lib/obex_object.c,v
retrieving revision 1.30
diff -u -r1.30 obex_object.c
--- lib/obex_object.c	11 Sep 2006 11:01:24 -0000	1.30
+++ lib/obex_object.c	3 Jun 2008 10:46:02 -0000
@@ -140,6 +140,14 @@
 	return 1;
 }
 
+int obex_object_getspace(obex_t *self, obex_object_t *object, unsigned int flags)
+{
+	if (flags & OBEX_FL_FIT_ONE_PACKET)
+		return self->mtu_tx - object->totallen - sizeof(struct obex_common_hdr);
+	else
+		return self->mtu_tx - sizeof(struct obex_common_hdr);
+}
+
 /*
  * Function int obex_object_addheader(obex_object_t *object, uint8_t hi, 
  *                      obex_headerdata_t hv, uint32_t hv_size, unsigned int flags)
