summaryrefslogtreecommitdiff
path: root/src/ptp-pack.c
diff options
context:
space:
mode:
authorLinus Walleij <triad@df.lth.se>2006-11-20 14:57:46 +0000
committerLinus Walleij <triad@df.lth.se>2006-11-20 14:57:46 +0000
commit277cd539ff4c4fdf591d92c1d0cd9c2e26eaaee0 (patch)
treebd8e2063d2973a6edd8abb8b14da236bc31e15ee /src/ptp-pack.c
parent33744bba0981fbb27dafdd4134ee6e61f50d673e (diff)
downloadlibmtp-277cd539ff4c4fdf591d92c1d0cd9c2e26eaaee0.tar.gz
Sync to upstream libgphoto2
Diffstat (limited to 'src/ptp-pack.c')
-rw-r--r--src/ptp-pack.c83
1 files changed, 36 insertions, 47 deletions
diff --git a/src/ptp-pack.c b/src/ptp-pack.c
index c52cbe3..2d7104c 100644
--- a/src/ptp-pack.c
+++ b/src/ptp-pack.c
@@ -892,53 +892,42 @@ ptp_pack_OPL (PTPParams *params, MTPPropList *proplist, unsigned char** opldatap
static inline int
ptp_unpack_OPL (PTPParams *params, unsigned char* data, MTPPropList **proplist, unsigned int len)
{
- //data_dump_ascii (stdout, data, len, 16);
-
- uint32_t prop_count = dtoh32a(data);
- MTPPropList *prop = NULL;
- int offset = 0;
- int i = 0;
-
- if (prop_count == 0)
- {
- *proplist = NULL;
- return 0;
- }
-
- data += sizeof(uint32_t);
-
- *proplist = malloc(sizeof(MTPPropList));
- prop = *proplist;
-
- for (i = 0; i < prop_count; i++)
- {
- // we ignore the object handle
- data += sizeof(uint32_t);
- len -= sizeof(uint32_t);
-
- prop->property = dtoh32a(data);
- data += sizeof(uint16_t);
- len -= sizeof(uint16_t);
-
- prop->datatype = dtoh32a(data);
- data += sizeof(uint16_t);
- len -= sizeof(uint16_t);
-
- offset = 0;
- ptp_unpack_DPV(params, data, &offset, len, &prop->propval, prop->datatype);
- data += offset;
- len -= offset;
-
- if (i != prop_count - 1)
- {
- prop->next = malloc(sizeof(MTPPropList));
- prop = prop->next;
- }
- else
- prop->next = NULL;
- }
-
- return prop_count;
+ uint32_t prop_count = dtoh32a(data);
+ MTPPropList *prop = NULL;
+ int offset = 0, i;
+
+ if (prop_count == 0) {
+ *proplist = NULL;
+ return 0;
+ }
+ data += sizeof(uint32_t);
+ *proplist = malloc(sizeof(MTPPropList));
+ prop = *proplist;
+ for (i = 0; i < prop_count; i++) {
+ /* we ignore the object handle */
+ data += sizeof(uint32_t);
+ len -= sizeof(uint32_t);
+
+ prop->property = dtoh32a(data);
+ data += sizeof(uint16_t);
+ len -= sizeof(uint16_t);
+
+ prop->datatype = dtoh32a(data);
+ data += sizeof(uint16_t);
+ len -= sizeof(uint16_t);
+
+ offset = 0;
+ ptp_unpack_DPV(params, data, &offset, len, &prop->propval, prop->datatype);
+ data += offset;
+ len -= offset;
+
+ if (i != prop_count - 1) {
+ prop->next = malloc(sizeof(MTPPropList));
+ prop = prop->next;
+ } else
+ prop->next = NULL;
+ }
+ return prop_count;
}
/*