"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "camlibs/ptp2/ptp-pack.c" between
libgphoto2-2.5.26.tar.bz2 and libgphoto2-2.5.27.tar.bz2

About: libgphoto2 is a library that can be used by applications to access various digital cameras.

ptp-pack.c  (libgphoto2-2.5.26.tar.bz2):ptp-pack.c  (libgphoto2-2.5.27.tar.bz2)
skipping to change at line 130 skipping to change at line 130
#define dtoh8a(x) (*(uint8_t*)(x)) #define dtoh8a(x) (*(uint8_t*)(x))
#define dtoh16a(a) dtoh16ap(params,a) #define dtoh16a(a) dtoh16ap(params,a)
#define dtoh32a(a) dtoh32ap(params,a) #define dtoh32a(a) dtoh32ap(params,a)
#define dtoh64a(a) dtoh64ap(params,a) #define dtoh64a(a) dtoh64ap(params,a)
#define dtoh16(x) dtoh16p(params,x) #define dtoh16(x) dtoh16p(params,x)
#define dtoh32(x) dtoh32p(params,x) #define dtoh32(x) dtoh32p(params,x)
#define dtoh64(x) dtoh64p(params,x) #define dtoh64(x) dtoh64p(params,x)
/* /*
* PTP strings ... if the size field is: * PTP strings ... if the size field is:
* size 0 : "empty string" ... we interpret that as NULL, return 1 * size 0 : "empty string" ... we interpret that as string with just \0 termina
tor, return 1
* (the whole PTP standard is not that clear, it occasionaly refers to strings
as optional in such cases, but no clear guidance).
* size > 0: all other strings have a terminating \0, included in the length (no t sure how conforming everyone is here) * size > 0: all other strings have a terminating \0, included in the length (no t sure how conforming everyone is here)
* *
* len - in ptp string characters currently * len - in ptp string characters currently
*/ */
static inline int static inline int
ptp_unpack_string(PTPParams *params, unsigned char* data, uint32_t offset, uint3 2_t total, uint8_t *len, char **retstr) ptp_unpack_string(PTPParams *params, unsigned char* data, uint32_t offset, uint3 2_t total, uint8_t *len, char **retstr)
{ {
uint8_t length; uint8_t length;
uint16_t string[PTP_MAXSTRLEN+1]; uint16_t string[PTP_MAXSTRLEN+1];
/* allow for UTF-8: max of 3 bytes per UCS-2 char, plus final null */ /* allow for UTF-8: max of 3 bytes per UCS-2 char, plus final null */
skipping to change at line 154 skipping to change at line 155
*len = 0; *len = 0;
*retstr = NULL; *retstr = NULL;
if (offset + 1 > total) if (offset + 1 > total)
return 0; return 0;
length = dtoh8a(&data[offset]); /* PTP_MAXSTRLEN == 255, 8 bit len */ length = dtoh8a(&data[offset]); /* PTP_MAXSTRLEN == 255, 8 bit len */
if (length == 0) { /* nothing to do? */ if (length == 0) { /* nothing to do? */
*len = 0; *len = 0;
*retstr = strdup(""); /* return an empty string, not NULL */
return 1; return 1;
} }
if (offset + 1 + length*sizeof(string[0]) > total) if (offset + 1 + length*sizeof(string[0]) > total)
return 0; return 0;
*len = length; *len = length;
/* copy to string[] to ensure correct alignment for iconv(3) */ /* copy to string[] to ensure correct alignment for iconv(3) */
memcpy(string, &data[offset+1], length * sizeof(string[0])); memcpy(string, &data[offset+1], length * sizeof(string[0]));
skipping to change at line 304 skipping to change at line 306
if (n >= UINT_MAX/sizeof(uint32_t)) if (n >= UINT_MAX/sizeof(uint32_t))
return 0; return 0;
if (!n) if (!n)
return 0; return 0;
if (offset + sizeof(uint32_t)*(n+1) > datalen) { if (offset + sizeof(uint32_t)*(n+1) > datalen) {
ptp_debug (params ,"array runs over datalen bufferend (%d vs %d)" , offset + sizeof(uint32_t)*(n+1) , datalen); ptp_debug (params ,"array runs over datalen bufferend (%d vs %d)" , offset + sizeof(uint32_t)*(n+1) , datalen);
return 0; return 0;
} }
*array = malloc (n*sizeof(uint32_t)); *array = calloc (n,sizeof(uint32_t));
if (!*array) if (!*array)
return 0; return 0;
for (i=0;i<n;i++) for (i=0;i<n;i++)
(*array)[i]=dtoh32a(&data[offset+(sizeof(uint32_t)*(i+1))]); (*array)[i]=dtoh32a(&data[offset+(sizeof(uint32_t)*(i+1))]);
return n; return n;
} }
static inline uint32_t static inline uint32_t
ptp_pack_uint32_t_array(PTPParams *params, uint32_t *array, uint32_t arraylen, u nsigned char **data ) ptp_pack_uint32_t_array(PTPParams *params, uint32_t *array, uint32_t arraylen, u nsigned char **data )
{ {
uint32_t i=0; uint32_t i=0;
*data = malloc ((arraylen+1)*sizeof(uint32_t)); *data = calloc ((arraylen+1),sizeof(uint32_t));
if (!*data) if (!*data)
return 0; return 0;
htod32a(&(*data)[0],arraylen); htod32a(&(*data)[0],arraylen);
for (i=0;i<arraylen;i++) for (i=0;i<arraylen;i++)
htod32a(&(*data)[sizeof(uint32_t)*(i+1)], array[i]); htod32a(&(*data)[sizeof(uint32_t)*(i+1)], array[i]);
return (arraylen+1)*sizeof(uint32_t); return (arraylen+1)*sizeof(uint32_t);
} }
static inline uint32_t static inline uint32_t
ptp_unpack_uint16_t_array(PTPParams *params, unsigned char* data, unsigned int o ffset, unsigned int datalen, uint16_t **array) ptp_unpack_uint16_t_array(PTPParams *params, unsigned char* data, unsigned int o ffset, unsigned int datalen, uint16_t **array)
skipping to change at line 349 skipping to change at line 351
if (n >= (UINT_MAX - offset - sizeof(uint32_t))/sizeof(uint16_t)) if (n >= (UINT_MAX - offset - sizeof(uint32_t))/sizeof(uint16_t))
return 0; return 0;
if (!n) if (!n)
return 0; return 0;
if (offset + sizeof(uint32_t) > datalen) if (offset + sizeof(uint32_t) > datalen)
return 0; return 0;
if (offset + sizeof(uint32_t)+sizeof(uint16_t)*n > datalen) { if (offset + sizeof(uint32_t)+sizeof(uint16_t)*n > datalen) {
ptp_debug (params ,"array runs over datalen bufferend (%d vs %d)" , offset + sizeof(uint32_t)+n*sizeof(uint16_t) , datalen); ptp_debug (params ,"array runs over datalen bufferend (%d vs %d)" , offset + sizeof(uint32_t)+n*sizeof(uint16_t) , datalen);
return 0; return 0;
} }
*array = malloc (n*sizeof(uint16_t)); *array = calloc (n,sizeof(uint16_t));
if (!*array) if (!*array)
return 0; return 0;
for (i=0;i<n;i++) for (i=0;i<n;i++)
(*array)[i]=dtoh16a(&data[offset+(sizeof(uint16_t)*(i+2))]); (*array)[i]=dtoh16a(&data[offset+(sizeof(uint16_t)*(i+2))]);
return n; return n;
} }
/* DeviceInfo pack/unpack */ /* DeviceInfo pack/unpack */
#define PTP_di_StandardVersion 0 #define PTP_di_StandardVersion 0
skipping to change at line 820 skipping to change at line 822
if (total - *offset < sizeof(uint32_t)) \ if (total - *offset < sizeof(uint32_t)) \
return 0; \ return 0; \
n = dtoh32a (&data[*offset]); \ n = dtoh32a (&data[*offset]); \
*offset += sizeof(uint32_t); \ *offset += sizeof(uint32_t); \
\ \
if (n >= UINT_MAX/sizeof(val->a.v[0])) \ if (n >= UINT_MAX/sizeof(val->a.v[0])) \
return 0; \ return 0; \
if (n > (total - (*offset))/sizeof(val->a.v[0]))\ if (n > (total - (*offset))/sizeof(val->a.v[0]))\
return 0; \ return 0; \
val->a.count = n; \ val->a.count = n; \
val->a.v = malloc(sizeof(val->a.v[0])*n); \ val->a.v = calloc(sizeof(val->a.v[0]),n); \
if (!val->a.v) return 0; \ if (!val->a.v) return 0; \
for (j=0;j<n;j++) \ for (j=0;j<n;j++) \
CTVAL(val->a.v[j].member, func); \ CTVAL(val->a.v[j].member, func); \
} }
static inline unsigned int static inline unsigned int
ptp_unpack_DPV ( ptp_unpack_DPV (
PTPParams *params, unsigned char* data, unsigned int *offset, unsigned in t total, PTPParams *params, unsigned char* data, unsigned int *offset, unsigned in t total,
PTPPropertyValue* value, uint16_t datatype PTPPropertyValue* value, uint16_t datatype
) { ) {
skipping to change at line 974 skipping to change at line 976
if (!ret) goto outofmemory; if (!ret) goto outofmemory;
break; break;
case PTP_DPFF_Enumeration: { case PTP_DPFF_Enumeration: {
int i; int i;
#define N dpd->FORM.Enum.NumberOfValues #define N dpd->FORM.Enum.NumberOfValues
if (offset + sizeof(uint16_t) > dpdlen) goto outofmemory; if (offset + sizeof(uint16_t) > dpdlen) goto outofmemory;
N = dtoh16a(&data[offset]); N = dtoh16a(&data[offset]);
offset+=sizeof(uint16_t); offset+=sizeof(uint16_t);
dpd->FORM.Enum.SupportedValue = malloc(N*sizeof(dpd->FORM.Enum.Su pportedValue[0])); dpd->FORM.Enum.SupportedValue = calloc(N,sizeof(dpd->FORM.Enum.Su pportedValue[0]));
if (!dpd->FORM.Enum.SupportedValue) if (!dpd->FORM.Enum.SupportedValue)
goto outofmemory; goto outofmemory;
memset (dpd->FORM.Enum.SupportedValue,0 , N*sizeof(dpd->FORM.Enum .SupportedValue[0]));
for (i=0;i<N;i++) { for (i=0;i<N;i++) {
ret = ptp_unpack_DPV (params, data, &offset, dpdlen, &dpd ->FORM.Enum.SupportedValue[i], dpd->DataType); ret = ptp_unpack_DPV (params, data, &offset, dpdlen, &dpd ->FORM.Enum.SupportedValue[i], dpd->DataType);
/* Slightly different handling here. The HP PhotoSmart 12 0 /* Slightly different handling here. The HP PhotoSmart 12 0
* specifies an enumeration with N in wrong endian * specifies an enumeration with N in wrong endian
* 00 01 instead of 01 00, so we count the enum just unti l the * 00 01 instead of 01 00, so we count the enum just unti l the
* the end of the packet. * the end of the packet.
*/ */
if (!ret) { if (!ret) {
if (!i) if (!i)
skipping to change at line 1072 skipping to change at line 1073
ret = ptp_unpack_DPV (params, data, poffset, dpdlen, &dpd->FORM.R ange.MaximumValue, dpd->DataType); ret = ptp_unpack_DPV (params, data, poffset, dpdlen, &dpd->FORM.R ange.MaximumValue, dpd->DataType);
if (!ret) goto outofmemory; if (!ret) goto outofmemory;
ret = ptp_unpack_DPV (params, data, poffset, dpdlen, &dpd->FORM.R ange.StepSize, dpd->DataType); ret = ptp_unpack_DPV (params, data, poffset, dpdlen, &dpd->FORM.R ange.StepSize, dpd->DataType);
if (!ret) goto outofmemory; if (!ret) goto outofmemory;
break; break;
case PTP_DPFF_Enumeration: { case PTP_DPFF_Enumeration: {
int i; int i;
#define N dpd->FORM.Enum.NumberOfValues #define N dpd->FORM.Enum.NumberOfValues
N = dtoh16a(&data[*poffset]); N = dtoh16a(&data[*poffset]);
*poffset+=sizeof(uint16_t); *poffset+=sizeof(uint16_t);
dpd->FORM.Enum.SupportedValue = malloc(N*sizeof(dpd->FORM.Enum.Su pportedValue[0])); dpd->FORM.Enum.SupportedValue = calloc(N,sizeof(dpd->FORM.Enum.Su pportedValue[0]));
if (!dpd->FORM.Enum.SupportedValue) if (!dpd->FORM.Enum.SupportedValue)
goto outofmemory; goto outofmemory;
memset (dpd->FORM.Enum.SupportedValue,0 , N*sizeof(dpd->FORM.Enum .SupportedValue[0]));
for (i=0;i<N;i++) { for (i=0;i<N;i++) {
ret = ptp_unpack_DPV (params, data, poffset, dpdlen, &dpd ->FORM.Enum.SupportedValue[i], dpd->DataType); ret = ptp_unpack_DPV (params, data, poffset, dpdlen, &dpd ->FORM.Enum.SupportedValue[i], dpd->DataType);
/* Slightly different handling here. The HP PhotoSmart 12 0 /* Slightly different handling here. The HP PhotoSmart 12 0
* specifies an enumeration with N in wrong endian * specifies an enumeration with N in wrong endian
* 00 01 instead of 01 00, so we count the enum just unti l the * 00 01 instead of 01 00, so we count the enum just unti l the
* the end of the packet. * the end of the packet.
*/ */
if (!ret) { if (!ret) {
if (!i) if (!i)
skipping to change at line 1115 skipping to change at line 1115
dst->str = strdup(src->str); dst->str = strdup(src->str);
else else
dst->str = NULL; dst->str = NULL;
return; return;
} }
if (type & PTP_DTC_ARRAY_MASK) { if (type & PTP_DTC_ARRAY_MASK) {
unsigned int i; unsigned int i;
dst->a.count = src->a.count; dst->a.count = src->a.count;
dst->a.v = malloc (sizeof(src->a.v[0])*src->a.count); dst->a.v = calloc (sizeof(src->a.v[0]),src->a.count);
for (i=0;i<src->a.count;i++) for (i=0;i<src->a.count;i++)
duplicate_PropertyValue (&src->a.v[i], &dst->a.v[i], type & ~PTP_DTC_ARRAY_MASK); duplicate_PropertyValue (&src->a.v[i], &dst->a.v[i], type & ~PTP_DTC_ARRAY_MASK);
return; return;
} }
switch (type & ~PTP_DTC_ARRAY_MASK) { switch (type & ~PTP_DTC_ARRAY_MASK) {
case PTP_DTC_INT8: dst->i8 = src->i8; break; case PTP_DTC_INT8: dst->i8 = src->i8; break;
case PTP_DTC_UINT8: dst->u8 = src->u8; break; case PTP_DTC_UINT8: dst->u8 = src->u8; break;
case PTP_DTC_INT16: dst->i16 = src->i16; break; case PTP_DTC_INT16: dst->i16 = src->i16; break;
case PTP_DTC_UINT16: dst->u16 = src->u16; break; case PTP_DTC_UINT16: dst->u16 = src->u16; break;
case PTP_DTC_INT32: dst->i32 = src->i32; break; case PTP_DTC_INT32: dst->i32 = src->i32; break;
skipping to change at line 1158 skipping to change at line 1158
dst->FormFlag = src->FormFlag; dst->FormFlag = src->FormFlag;
switch (src->FormFlag) { switch (src->FormFlag) {
case PTP_DPFF_Range: case PTP_DPFF_Range:
duplicate_PropertyValue (&src->FORM.Range.MinimumValue, &dst->FOR M.Range.MinimumValue, src->DataType); duplicate_PropertyValue (&src->FORM.Range.MinimumValue, &dst->FOR M.Range.MinimumValue, src->DataType);
duplicate_PropertyValue (&src->FORM.Range.MaximumValue, &dst->FOR M.Range.MaximumValue, src->DataType); duplicate_PropertyValue (&src->FORM.Range.MaximumValue, &dst->FOR M.Range.MaximumValue, src->DataType);
duplicate_PropertyValue (&src->FORM.Range.StepSize, &dst->FOR M.Range.StepSize, src->DataType); duplicate_PropertyValue (&src->FORM.Range.StepSize, &dst->FOR M.Range.StepSize, src->DataType);
break; break;
case PTP_DPFF_Enumeration: case PTP_DPFF_Enumeration:
dst->FORM.Enum.NumberOfValues = src->FORM.Enum.NumberOfValues; dst->FORM.Enum.NumberOfValues = src->FORM.Enum.NumberOfValues;
dst->FORM.Enum.SupportedValue = malloc (sizeof(dst->FORM.Enum.Sup portedValue[0])*src->FORM.Enum.NumberOfValues); dst->FORM.Enum.SupportedValue = calloc (sizeof(dst->FORM.Enum.Sup portedValue[0]),src->FORM.Enum.NumberOfValues);
for (i = 0; i<src->FORM.Enum.NumberOfValues ; i++) for (i = 0; i<src->FORM.Enum.NumberOfValues ; i++)
duplicate_PropertyValue (&src->FORM.Enum.SupportedValue[i ], &dst->FORM.Enum.SupportedValue[i], src->DataType); duplicate_PropertyValue (&src->FORM.Enum.SupportedValue[i ], &dst->FORM.Enum.SupportedValue[i], src->DataType);
break; break;
case PTP_DPFF_None: case PTP_DPFF_None:
break; break;
} }
} }
#define PTP_opd_ObjectPropertyCode 0 #define PTP_opd_ObjectPropertyCode 0
#define PTP_opd_DataType 2 #define PTP_opd_DataType 2
#define PTP_opd_GetSet 4 #define PTP_opd_GetSet 4
#define PTP_opd_FactoryDefaultValue 5 #define PTP_opd_FactoryDefaultValue 5
static inline int static inline int
ptp_unpack_OPD (PTPParams *params, unsigned char* data, PTPObjectPropDesc *opd, unsigned int opdlen) ptp_unpack_OPD (PTPParams *params, unsigned char* data, PTPObjectPropDesc *opd, unsigned int opdlen)
{ {
unsigned int offset=0, ret; unsigned int offset=0, ret;
uint8_t len;
memset (opd, 0, sizeof(*opd)); memset (opd, 0, sizeof(*opd));
if (opdlen < 5) if (opdlen < 5)
return 0; return 0;
opd->ObjectPropertyCode=dtoh16a(&data[PTP_opd_ObjectPropertyCode]); opd->ObjectPropertyCode=dtoh16a(&data[PTP_opd_ObjectPropertyCode]);
opd->DataType=dtoh16a(&data[PTP_opd_DataType]); opd->DataType=dtoh16a(&data[PTP_opd_DataType]);
opd->GetSet=dtoh8a(&data[PTP_opd_GetSet]); opd->GetSet=dtoh8a(&data[PTP_opd_GetSet]);
skipping to change at line 1215 skipping to change at line 1216
if (!ret) goto outofmemory; if (!ret) goto outofmemory;
break; break;
case PTP_OPFF_Enumeration: { case PTP_OPFF_Enumeration: {
unsigned int i; unsigned int i;
#define N opd->FORM.Enum.NumberOfValues #define N opd->FORM.Enum.NumberOfValues
if (offset + sizeof(uint16_t) > opdlen) goto outofmemory; if (offset + sizeof(uint16_t) > opdlen) goto outofmemory;
N = dtoh16a(&data[offset]); N = dtoh16a(&data[offset]);
offset+=sizeof(uint16_t); offset+=sizeof(uint16_t);
opd->FORM.Enum.SupportedValue = malloc(N*sizeof(opd->FORM.Enum.Su pportedValue[0])); opd->FORM.Enum.SupportedValue = calloc(N,sizeof(opd->FORM.Enum.Su pportedValue[0]));
if (!opd->FORM.Enum.SupportedValue) if (!opd->FORM.Enum.SupportedValue)
goto outofmemory; goto outofmemory;
memset (opd->FORM.Enum.SupportedValue,0 , N*sizeof(opd->FORM.Enum .SupportedValue[0]));
for (i=0;i<N;i++) { for (i=0;i<N;i++) {
ret = ptp_unpack_DPV (params, data, &offset, opdlen, &opd ->FORM.Enum.SupportedValue[i], opd->DataType); ret = ptp_unpack_DPV (params, data, &offset, opdlen, &opd ->FORM.Enum.SupportedValue[i], opd->DataType);
/* Slightly different handling here. The HP PhotoSmart 12 0 /* Slightly different handling here. The HP PhotoSmart 12 0
* specifies an enumeration with N in wrong endian * specifies an enumeration with N in wrong endian
* 00 01 instead of 01 00, so we count the enum just unti l the * 00 01 instead of 01 00, so we count the enum just unti l the
* the end of the packet. * the end of the packet.
*/ */
if (!ret) { if (!ret) {
if (!i) if (!i)
goto outofmemory; goto outofmemory;
opd->FORM.Enum.NumberOfValues = i; opd->FORM.Enum.NumberOfValues = i;
break; break;
} }
} }
#undef N #undef N
} }
break;
case PTP_OPFF_DateTime:
if (!ptp_unpack_string(params, data, offset, opdlen, &len, &opd->
FORM.DateTime.String))
opd->FORM.DateTime.String = NULL;
offset += 2*len+1; /* offset not used afterwards anymore */
break;
case PTP_OPFF_RegularExpression:
if (!ptp_unpack_string(params, data, offset, opdlen, &len, &opd->
FORM.RegularExpression.String))
opd->FORM.RegularExpression.String = NULL;
offset += 2*len+1; /* offset not used afterwards anymore */
break;
case PTP_OPFF_FixedLengthArray:
if (offset + sizeof(uint16_t) > opdlen) goto outofmemory;
opd->FORM.FixedLengthArray.NumberOfValues = dtoh16a(&data[offset]
);
offset += sizeof(uint16_t); /* offset not used afterwards anymore
*/
break;
case PTP_OPFF_ByteArray:
if (offset + sizeof(uint16_t) > opdlen) goto outofmemory;
opd->FORM.ByteArray.NumberOfValues = dtoh16a(&data[offset]);
offset += sizeof(uint16_t); /* offset not used afterwards anymore
*/
break;
case PTP_OPFF_LongString:
break;
} }
return 1; return 1;
outofmemory: outofmemory:
ptp_free_objectpropdesc(opd); ptp_free_objectpropdesc(opd);
return 0; return 0;
} }
static inline uint32_t static inline uint32_t
ptp_pack_DPV (PTPParams *params, PTPPropertyValue* value, unsigned char** dpvptr , uint16_t datatype) ptp_pack_DPV (PTPParams *params, PTPPropertyValue* value, unsigned char** dpvptr , uint16_t datatype)
{ {
skipping to change at line 1450 skipping to change at line 1473
return 0; return 0;
if (prop_count >= INT_MAX/sizeof(MTPProperties)) { if (prop_count >= INT_MAX/sizeof(MTPProperties)) {
ptp_debug (params ,"prop_count %d is too large", prop_count); ptp_debug (params ,"prop_count %d is too large", prop_count);
return 0; return 0;
} }
ptp_debug (params ,"Unpacking MTP OPL, size %d (prop_count %d)", len, pro p_count); ptp_debug (params ,"Unpacking MTP OPL, size %d (prop_count %d)", len, pro p_count);
data += sizeof(uint32_t); data += sizeof(uint32_t);
len -= sizeof(uint32_t); len -= sizeof(uint32_t);
props = malloc(prop_count * sizeof(MTPProperties)); props = calloc(prop_count , sizeof(MTPProperties));
if (!props) return 0; if (!props) return 0;
for (i = 0; i < prop_count; i++) { for (i = 0; i < prop_count; i++) {
if (len <= (sizeof(uint32_t) + sizeof(uint16_t) + sizeof(uint16_t ))) { if (len <= (sizeof(uint32_t) + sizeof(uint16_t) + sizeof(uint16_t ))) {
ptp_debug (params ,"short MTP Object Property List at pro perty %d (of %d)", i, prop_count); ptp_debug (params ,"short MTP Object Property List at pro perty %d (of %d)", i, prop_count);
ptp_debug (params ,"device probably needs DEVICE_FLAG_BRO KEN_MTPGETOBJPROPLIST_ALL"); ptp_debug (params ,"device probably needs DEVICE_FLAG_BRO KEN_MTPGETOBJPROPLIST_ALL");
ptp_debug (params ,"or even DEVICE_FLAG_BROKEN_MTPGETOBJP ROPLIST", i); ptp_debug (params ,"or even DEVICE_FLAG_BROKEN_MTPGETOBJP ROPLIST");
qsort (props, i, sizeof(MTPProperties),_compare_func); qsort (props, i, sizeof(MTPProperties),_compare_func);
*pprops = props; *pprops = props;
return i; return i;
} }
props[i].ObjectHandle = dtoh32a(data); props[i].ObjectHandle = dtoh32a(data);
data += sizeof(uint32_t); data += sizeof(uint32_t);
len -= sizeof(uint32_t); len -= sizeof(uint32_t);
props[i].property = dtoh16a(data); props[i].property = dtoh16a(data);
skipping to change at line 1998 skipping to change at line 2021
entries++; entries++;
if (size >= 12+2) { if (size >= 12+2) {
for (j=0;j<31;j++) for (j=0;j<31;j++)
if (dtoh16a(curdata+12) & (1<<j)) if (dtoh16a(curdata+12) & (1<<j))
entries++; entries++;
} }
} }
curdata += size; curdata += size;
entries++; entries++;
} }
ce = malloc (sizeof(PTPCanon_changes_entry)*(entries+1)); ce = calloc (sizeof(PTPCanon_changes_entry),(entries+1));
if (!ce) return 0; if (!ce) return 0;
curdata = data; curdata = data;
while (curdata - data + 8 < datasize) { while (curdata - data + 8 < datasize) {
uint32_t size = dtoh32a(&curdata[PTP_ece_Size]); uint32_t size = dtoh32a(&curdata[PTP_ece_Size]);
uint32_t type = dtoh32a(&curdata[PTP_ece_Type]); uint32_t type = dtoh32a(&curdata[PTP_ece_Type]);
if (size > datasize) { if (size > datasize) {
ptp_debug (params, "size %d is larger than datasize %d", size, datasize); ptp_debug (params, "size %d is larger than datasize %d", size, datasize);
break; break;
skipping to change at line 2096 skipping to change at line 2119
uint32_t propxcnt = dtoh32a(&curdata[PTP_ece_Prop_ Desc_Count]); uint32_t propxcnt = dtoh32a(&curdata[PTP_ece_Prop_ Desc_Count]);
unsigned char *xdata = &curdata[PTP_ece_Prop_Desc_Data] ; unsigned char *xdata = &curdata[PTP_ece_Prop_Desc_Data] ;
unsigned int j; unsigned int j;
PTPDevicePropDesc *dpd; PTPDevicePropDesc *dpd;
if (size < PTP_ece_Prop_Desc_Data) { if (size < PTP_ece_Prop_Desc_Data) {
ptp_debug (params, "size %d is smaller than %d", size, PTP_ece_Prop_Desc_Data); ptp_debug (params, "size %d is smaller than %d", size, PTP_ece_Prop_Desc_Data);
break; break;
} }
ptp_debug (params, "event %d: EOS prop %04x desc record, datasize %d, propxtype %d", i, proptype, size-PTP_ece_Prop_Desc_Data, propxtype) ; ptp_debug (params, "event %d: EOS prop %04x (%s) desc rec ord, datasize %d, propxtype %d", i, proptype, ptp_get_property_description (para ms, proptype), size-PTP_ece_Prop_Desc_Data, propxtype);
for (j=0;j<params->nrofcanon_props;j++) for (j=0;j<params->nrofcanon_props;j++)
if (params->canon_props[j].proptype == proptype) if (params->canon_props[j].proptype == proptype)
break; break;
if (j==params->nrofcanon_props) { if (j==params->nrofcanon_props) {
ptp_debug (params, "event %d: propdesc %x, defaul t value not found.", i, proptype); ptp_debug (params, "event %d: propdesc %x, defaul t value not found.", i, proptype);
break; break;
} }
dpd = &params->canon_props[j].dpd; dpd = &params->canon_props[j].dpd;
/* 1 - uint16 ? /* 1 - uint16 ?
* 3 - uint16 * 3 - uint16
skipping to change at line 2125 skipping to change at line 2148
if (! propxcnt) if (! propxcnt)
break; break;
if (propxcnt >= 2<<16) /* buggy or exploit */ if (propxcnt >= 2<<16) /* buggy or exploit */
break; break;
ptp_debug (params, "event %d: propxtype is %x, prop is 0x %04x, data type is 0x%04x, propxcnt is %d.", ptp_debug (params, "event %d: propxtype is %x, prop is 0x %04x, data type is 0x%04x, propxcnt is %d.",
i, propxtype, proptype, dpd->DataType, propxcn t); i, propxtype, proptype, dpd->DataType, propxcn t);
dpd->FormFlag = PTP_DPFF_Enumeration; dpd->FormFlag = PTP_DPFF_Enumeration;
dpd->FORM.Enum.NumberOfValues = propxcnt; dpd->FORM.Enum.NumberOfValues = propxcnt;
free (dpd->FORM.Enum.SupportedValue); free (dpd->FORM.Enum.SupportedValue);
dpd->FORM.Enum.SupportedValue = malloc (sizeof (PTPProper tyValue)*propxcnt); dpd->FORM.Enum.SupportedValue = calloc (sizeof (PTPProper tyValue),propxcnt);
switch (proptype) { switch (proptype) {
case PTP_DPC_CANON_EOS_ImageFormat: case PTP_DPC_CANON_EOS_ImageFormat:
case PTP_DPC_CANON_EOS_ImageFormatCF: case PTP_DPC_CANON_EOS_ImageFormatCF:
case PTP_DPC_CANON_EOS_ImageFormatSD: case PTP_DPC_CANON_EOS_ImageFormatSD:
case PTP_DPC_CANON_EOS_ImageFormatExtHD: case PTP_DPC_CANON_EOS_ImageFormatExtHD:
/* special handling of ImageFormat properties */ /* special handling of ImageFormat properties */
for (j=0;j<propxcnt;j++) { for (j=0;j<propxcnt;j++) {
dpd->FORM.Enum.SupportedValue[j].u16 = dpd->FORM.Enum.SupportedValue[j].u16 =
ptp_unpack_EOS_ImageForma t( params, &xdata ); ptp_unpack_EOS_ImageForma t( params, &xdata );
skipping to change at line 2184 skipping to change at line 2207
if (size >= 0xc) { /* property info */ if (size >= 0xc) { /* property info */
unsigned int j; unsigned int j;
uint32_t proptype = dtoh32a(&curdata[PTP_e ce_Prop_Subtype]); uint32_t proptype = dtoh32a(&curdata[PTP_e ce_Prop_Subtype]);
unsigned char *xdata = &curdata[PTP_ece_Prop_Va l_Data]; unsigned char *xdata = &curdata[PTP_ece_Prop_Va l_Data];
PTPDevicePropDesc *dpd; PTPDevicePropDesc *dpd;
if (size < PTP_ece_Prop_Val_Data) { if (size < PTP_ece_Prop_Val_Data) {
ptp_debug (params, "size %d is smaller th an %d", size, PTP_ece_Prop_Val_Data); ptp_debug (params, "size %d is smaller th an %d", size, PTP_ece_Prop_Val_Data);
break; break;
} }
ptp_debug (params, "event %d: EOS prop %04x info record, datasize is %d", i, proptype, size-PTP_ece_Prop_Val_Data); ptp_debug (params, "event %d: EOS prop %04x (%s) info record, datasize is %d", i, proptype, ptp_get_property_description(params,p roptype), size-PTP_ece_Prop_Val_Data);
for (j=0;j<params->nrofcanon_props;j++) for (j=0;j<params->nrofcanon_props;j++)
if (params->canon_props[j].proptype == pr optype) if (params->canon_props[j].proptype == pr optype)
break; break;
if (j<params->nrofcanon_props) { if (j<params->nrofcanon_props) {
if ( (params->canon_props[j].size != s ize) || if ( (params->canon_props[j].size != s ize) ||
(memcmp(params->canon_props[j].da ta,xdata,size-PTP_ece_Prop_Val_Data))) { (memcmp(params->canon_props[j].da ta,xdata,size-PTP_ece_Prop_Val_Data))) {
params->canon_props[j].data = rea lloc(params->canon_props[j].data,size-PTP_ece_Prop_Val_Data); params->canon_props[j].data = rea lloc(params->canon_props[j].data,size-PTP_ece_Prop_Val_Data);
params->canon_props[j].size = siz e; params->canon_props[j].size = siz e;
memcpy (params->canon_props[j].da ta,xdata,size-PTP_ece_Prop_Val_Data); memcpy (params->canon_props[j].da ta,xdata,size-PTP_ece_Prop_Val_Data);
} }
skipping to change at line 2245 skipping to change at line 2268
XX(EOS_SerialNumber) XX(EOS_SerialNumber)
XX(EOS_DepthOfFieldPreview) XX(EOS_DepthOfFieldPreview)
XX(EOS_EVFRecordStatus) XX(EOS_EVFRecordStatus)
XX(EOS_LvAfSystem) XX(EOS_LvAfSystem)
XX(EOS_FocusInfoEx) XX(EOS_FocusInfoEx)
XX(EOS_DepthOfField) XX(EOS_DepthOfField)
XX(EOS_Brightness) XX(EOS_Brightness)
XX(EOS_EFComp) XX(EOS_EFComp)
XX(EOS_LensName) XX(EOS_LensName)
XX(EOS_LensID) XX(EOS_LensID)
XX(EOS_FixedMovie)
#undef XX #undef XX
dpd->GetSet = PTP_DPGS_Get; dpd->GetSet = PTP_DPGS_Get;
break; break;
} }
/* set DataType */ /* set DataType */
switch (proptype) { switch (proptype) {
case PTP_DPC_CANON_EOS_CameraTime: case PTP_DPC_CANON_EOS_CameraTime:
case PTP_DPC_CANON_EOS_UTCTime: case PTP_DPC_CANON_EOS_UTCTime:
case PTP_DPC_CANON_EOS_Summertime: /* basical the DST flag */ case PTP_DPC_CANON_EOS_Summertime: /* basical the DST flag */
skipping to change at line 2274 skipping to change at line 2298
case PTP_DPC_CANON_EOS_StroboFiring: case PTP_DPC_CANON_EOS_StroboFiring:
case PTP_DPC_CANON_EOS_AFSelectFocusArea: case PTP_DPC_CANON_EOS_AFSelectFocusArea:
case PTP_DPC_CANON_EOS_ContinousAFMode: case PTP_DPC_CANON_EOS_ContinousAFMode:
case PTP_DPC_CANON_EOS_MirrorUpSetting: case PTP_DPC_CANON_EOS_MirrorUpSetting:
case PTP_DPC_CANON_EOS_OLCInfoVersion: case PTP_DPC_CANON_EOS_OLCInfoVersion:
case PTP_DPC_CANON_EOS_PowerZoomPosition: case PTP_DPC_CANON_EOS_PowerZoomPosition:
case PTP_DPC_CANON_EOS_PowerZoomSpeed: case PTP_DPC_CANON_EOS_PowerZoomSpeed:
case PTP_DPC_CANON_EOS_BuiltinStroboMode: case PTP_DPC_CANON_EOS_BuiltinStroboMode:
case PTP_DPC_CANON_EOS_StroboETTL2Metering: case PTP_DPC_CANON_EOS_StroboETTL2Metering:
case PTP_DPC_CANON_EOS_ColorTemperature: case PTP_DPC_CANON_EOS_ColorTemperature:
case PTP_DPC_CANON_EOS_FixedMovie:
case PTP_DPC_CANON_EOS_AutoPowerOff:
case PTP_DPC_CANON_EOS_AloMode:
case PTP_DPC_CANON_EOS_LvViewTypeSelect:
case PTP_DPC_CANON_EOS_EVFColorTemp:
case PTP_DPC_CANON_EOS_LvAfSystem:
case PTP_DPC_CANON_EOS_OneShotRawOn:
case PTP_DPC_CANON_EOS_FlashChargingState:
dpd->DataType = PTP_DTC_UINT32; dpd->DataType = PTP_DTC_UINT32;
break; break;
/* enumeration for AEM is never provided, but is available to set */ /* enumeration for AEM is never provided, but is available to set */
case PTP_DPC_CANON_EOS_AEModeDial:
case PTP_DPC_CANON_EOS_AutoExposureMode: case PTP_DPC_CANON_EOS_AutoExposureMode:
dpd->DataType = PTP_DTC_UINT16; dpd->DataType = PTP_DTC_UINT16;
dpd->FormFlag = PTP_DPFF_Enumeration; dpd->FormFlag = PTP_DPFF_Enumeration;
dpd->FORM.Enum.NumberOfValues = 0; dpd->FORM.Enum.NumberOfValues = 0;
break; break;
case PTP_DPC_CANON_EOS_Aperture: case PTP_DPC_CANON_EOS_Aperture:
case PTP_DPC_CANON_EOS_ShutterSpeed: case PTP_DPC_CANON_EOS_ShutterSpeed:
case PTP_DPC_CANON_EOS_ISOSpeed: case PTP_DPC_CANON_EOS_ISOSpeed:
case PTP_DPC_CANON_EOS_FocusMode: case PTP_DPC_CANON_EOS_FocusMode:
case PTP_DPC_CANON_EOS_ColorSpace: case PTP_DPC_CANON_EOS_ColorSpace:
case PTP_DPC_CANON_EOS_BatteryPower: case PTP_DPC_CANON_EOS_BatteryPower:
case PTP_DPC_CANON_EOS_BatterySelect: case PTP_DPC_CANON_EOS_BatterySelect:
case PTP_DPC_CANON_EOS_PTPExtensionVersion: case PTP_DPC_CANON_EOS_PTPExtensionVersion:
case PTP_DPC_CANON_EOS_DriveMode: case PTP_DPC_CANON_EOS_DriveMode:
case PTP_DPC_CANON_EOS_AEB: case PTP_DPC_CANON_EOS_AEB:
case PTP_DPC_CANON_EOS_BracketMode: case PTP_DPC_CANON_EOS_BracketMode:
case PTP_DPC_CANON_EOS_QuickReviewTime: case PTP_DPC_CANON_EOS_QuickReviewTime:
case PTP_DPC_CANON_EOS_EVFMode: case PTP_DPC_CANON_EOS_EVFMode:
case PTP_DPC_CANON_EOS_EVFOutputDevice: case PTP_DPC_CANON_EOS_EVFOutputDevice:
case PTP_DPC_CANON_EOS_AutoPowerOff:
case PTP_DPC_CANON_EOS_EVFRecordStatus: case PTP_DPC_CANON_EOS_EVFRecordStatus:
case PTP_DPC_CANON_EOS_HighISOSettingNoiseReducti on: case PTP_DPC_CANON_EOS_HighISOSettingNoiseReducti on:
case PTP_DPC_CANON_EOS_MultiAspect: /* actually a 32bit value, but lets try it for easyness */ case PTP_DPC_CANON_EOS_MultiAspect: /* actually a 32bit value, but lets try it for easyness */
dpd->DataType = PTP_DTC_UINT16; dpd->DataType = PTP_DTC_UINT16;
break; break;
case PTP_DPC_CANON_EOS_PictureStyle: case PTP_DPC_CANON_EOS_PictureStyle:
case PTP_DPC_CANON_EOS_WhiteBalance: case PTP_DPC_CANON_EOS_WhiteBalance:
case PTP_DPC_CANON_EOS_MeteringMode: case PTP_DPC_CANON_EOS_MeteringMode:
case PTP_DPC_CANON_EOS_ExpCompensation: case PTP_DPC_CANON_EOS_ExpCompensation:
dpd->DataType = PTP_DTC_UINT8; dpd->DataType = PTP_DTC_UINT8;
break; break;
case PTP_DPC_CANON_EOS_Owner: case PTP_DPC_CANON_EOS_Owner:
case PTP_DPC_CANON_EOS_Artist: case PTP_DPC_CANON_EOS_Artist:
case PTP_DPC_CANON_EOS_Copyright: case PTP_DPC_CANON_EOS_Copyright:
case PTP_DPC_CANON_EOS_SerialNumber: case PTP_DPC_CANON_EOS_SerialNumber:
case PTP_DPC_CANON_EOS_LensName: case PTP_DPC_CANON_EOS_LensName:
case PTP_DPC_CANON_EOS_CameraNickname:
dpd->DataType = PTP_DTC_STR; dpd->DataType = PTP_DTC_STR;
break; break;
case PTP_DPC_CANON_EOS_WhiteBalanceAdjustA: case PTP_DPC_CANON_EOS_WhiteBalanceAdjustA:
case PTP_DPC_CANON_EOS_WhiteBalanceAdjustB: case PTP_DPC_CANON_EOS_WhiteBalanceAdjustB:
dpd->DataType = PTP_DTC_INT32; dpd->DataType = PTP_DTC_INT32;
break; break;
/* unknown props, listed from dump.... all 16 bit , but vals might be smaller */ /* unknown props, listed from dump.... all 16 bit , but vals might be smaller */
case PTP_DPC_CANON_EOS_DPOFVersion: case PTP_DPC_CANON_EOS_DPOFVersion:
dpd->DataType = PTP_DTC_UINT16; dpd->DataType = PTP_DTC_UINT16;
ptp_debug (params, "event %d: Unknown EOS property %04x, datasize is %d, using uint16", i ,proptype, size-PTP_ece_Prop_Va l_Data); ptp_debug (params, "event %d: Unknown EOS property %04x, datasize is %d, using uint16", i ,proptype, size-PTP_ece_Prop_Va l_Data);
skipping to change at line 2354 skipping to change at line 2387
/* yet unknown 32bit props */ /* yet unknown 32bit props */
case PTP_DPC_CANON_EOS_WftStatus: case PTP_DPC_CANON_EOS_WftStatus:
case PTP_DPC_CANON_EOS_LensStatus: case PTP_DPC_CANON_EOS_LensStatus:
case PTP_DPC_CANON_EOS_CardExtension: case PTP_DPC_CANON_EOS_CardExtension:
case PTP_DPC_CANON_EOS_TempStatus: case PTP_DPC_CANON_EOS_TempStatus:
case PTP_DPC_CANON_EOS_PhotoStudioMode: case PTP_DPC_CANON_EOS_PhotoStudioMode:
case PTP_DPC_CANON_EOS_DepthOfFieldPreview: case PTP_DPC_CANON_EOS_DepthOfFieldPreview:
case PTP_DPC_CANON_EOS_EVFSharpness: case PTP_DPC_CANON_EOS_EVFSharpness:
case PTP_DPC_CANON_EOS_EVFWBMode: case PTP_DPC_CANON_EOS_EVFWBMode:
case PTP_DPC_CANON_EOS_EVFClickWBCoeffs: case PTP_DPC_CANON_EOS_EVFClickWBCoeffs:
case PTP_DPC_CANON_EOS_EVFColorTemp:
case PTP_DPC_CANON_EOS_ExposureSimMode: case PTP_DPC_CANON_EOS_ExposureSimMode:
case PTP_DPC_CANON_EOS_LvAfSystem:
case PTP_DPC_CANON_EOS_MovSize: case PTP_DPC_CANON_EOS_MovSize:
case PTP_DPC_CANON_EOS_DepthOfField: case PTP_DPC_CANON_EOS_DepthOfField:
case PTP_DPC_CANON_EOS_LvViewTypeSelect:
case PTP_DPC_CANON_EOS_AloMode:
case PTP_DPC_CANON_EOS_Brightness: case PTP_DPC_CANON_EOS_Brightness:
case PTP_DPC_CANON_EOS_GPSLogCtrl: case PTP_DPC_CANON_EOS_GPSLogCtrl:
case PTP_DPC_CANON_EOS_GPSDeviceActive: case PTP_DPC_CANON_EOS_GPSDeviceActive:
dpd->DataType = PTP_DTC_UINT32; dpd->DataType = PTP_DTC_UINT32;
ptp_debug (params, "event %d: Unknown EOS property %04x, datasize is %d, using uint32", i ,proptype, size-PTP_ece_Prop_Va l_Data); ptp_debug (params, "event %d: Unknown EOS property %04x, datasize is %d, using uint32", i ,proptype, size-PTP_ece_Prop_Va l_Data);
if ((size-PTP_ece_Prop_Val_Data) % sizeof (uint32_t) != 0) if ((size-PTP_ece_Prop_Val_Data) % sizeof (uint32_t) != 0)
ptp_debug (params, "event %d: War ning: datasize modulo sizeof(uint32) is not 0: ", i, (size-PTP_ece_Prop_Val_Data ) % sizeof(uint32_t) ); ptp_debug (params, "event %d: War ning: datasize modulo sizeof(uint32) is not 0: ", i, (size-PTP_ece_Prop_Val_Data ) % sizeof(uint32_t) );
for (j=0;j<(size-PTP_ece_Prop_Val_Data)/s izeof(uint32_t);j++) for (j=0;j<(size-PTP_ece_Prop_Val_Data)/s izeof(uint32_t);j++)
ptp_debug (params, " %d: 0x%8x ", j, dtoh32a(xdata+j*4)); ptp_debug (params, " %d: 0x%8x ", j, dtoh32a(xdata+j*4));
break; break;
skipping to change at line 2471 skipping to change at line 2500
/* one more information record handed to us */ /* one more information record handed to us */
/* Versions seen: (d199) /* Versions seen: (d199)
* 100D: 7 (original reference) * 100D: 7 (original reference)
* 5d Mark 3: 7 * 5d Mark 3: 7
* 650D: 7 * 650D: 7
* 6D: 7 * 6D: 7
* M10: 8 * M10: 8
* 70D: 8 * 70D: 8
* 5Dsr: b * 5Dsr: b
* 200D: f * 200D: f
* EOS R: 11 * EOS R: 0x11
* EOS M6 Mark2 0x12
* EOS R5: 0x13
*/ */
case PTP_EC_CANON_EOS_OLCInfoChanged: { case PTP_EC_CANON_EOS_OLCInfoChanged: {
uint32_t len, curoff; uint32_t len, curoff;
uint16_t mask,proptype; uint16_t mask,proptype;
PTPDevicePropDesc *dpd; PTPDevicePropDesc *dpd;
int olcver = 0; int olcver = 0;
dpd = _lookup_or_allocate_canon_prop(params, PTP_DPC_CANO N_EOS_OLCInfoVersion); dpd = _lookup_or_allocate_canon_prop(params, PTP_DPC_CANO N_EOS_OLCInfoVersion);
if (dpd) { if (dpd) {
ptp_debug (params, "olcinfoversion is %d", dpd->C urrentValue.u32); ptp_debug (params, "olcinfoversion is %d", dpd->C urrentValue.u32);
skipping to change at line 2517 skipping to change at line 2548
if (mask & CANON_EOS_OLC_BUTTON) { if (mask & CANON_EOS_OLC_BUTTON) {
ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN; ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN;
ce[i].u.info = malloc(strlen("Button 1234567")); ce[i].u.info = malloc(strlen("Button 1234567"));
sprintf(ce[i].u.info, "Button %d", dtoh16a(curda ta+curoff)); sprintf(ce[i].u.info, "Button %d", dtoh16a(curda ta+curoff));
i++; i++;
curoff += 2; /* 7, 8 , f */ curoff += 2; /* 7, 8 , f */
} }
if (mask & CANON_EOS_OLC_SHUTTERSPEED) { if (mask & CANON_EOS_OLC_SHUTTERSPEED) {
/* 6 bytes: 01 01 98 10 00 60 */ /* 6 bytes: 01 01 98 10 00 60 */
/* this seesm to be the shutter speed record */ /* this seem to be the shutter speed record */
/* EOS 200D seems to have 7 bytes here, sample: /* EOS 200D seems to have 7 bytes here, sample:
* 7 bytes: 01 03 98 10 00 70 00 * 7 bytes: 01 03 98 10 00 70 00
* EOS R also 7 bytes * EOS R also 7 bytes
* 7 bytes: 01 01 a0 0c 00 0c 00 * 7 bytes: 01 01 a0 0c 00 0c 00
*/ */
proptype = PTP_DPC_CANON_EOS_ShutterSpeed; proptype = PTP_DPC_CANON_EOS_ShutterSpeed;
dpd = _lookup_or_allocate_canon_prop(params, prop type); dpd = _lookup_or_allocate_canon_prop(params, prop type);
dpd->CurrentValue.u16 = curdata[curoff+5]; /* jus t use last byte */ dpd->CurrentValue.u16 = curdata[curoff+5]; /* jus t use last byte */
ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_PROPERTY; ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_PROPERTY;
ce[i].u.propid = proptype; ce[i].u.propid = proptype;
/* hack to differ between older EOS and EOS 200D newer */ /* hack to differ between older EOS and EOS 200D newer */
switch (olcver) { switch (olcver) {
case 0xf: case 0xf:
case 0x11: case 0x11:
curoff += 7; /* f (200D), 8 (M10) ???, case 0x12:
11 is EOS R */ case 0x13:
curoff += 7; /* f (200D), 8 (M10) ???,
11 is EOS R , 12 is EOS m6 Mark2*/
break; break;
case 0x7: case 0x7:
case 0x8: /* EOS 70D */ case 0x8: /* EOS 70D */
case 0xb: /* EOS 5Ds */ case 0xb: /* EOS 5Ds */
curoff += 6; /* 7 , b (5ds) */ curoff += 6; /* 7 , b (5ds) */
break; break;
default: default:
if (olcver >= 0xf) if (olcver >= 0xf)
curoff += 7; curoff += 7;
else else
curoff += 6; curoff += 6;
break; break;
} }
i++; i++;
} }
if (mask & CANON_EOS_OLC_APERTURE) { if (mask & CANON_EOS_OLC_APERTURE) {
/* 5 bytes: 01 01 5b 30 30 */ /* 5 bytes: 01 01 5b 30 30 */
/* this seesm to be the aperture record */ /* this seem to be the aperture record */
/* EOS 200D seems to have 6 bytes here? /* EOS 200D seems to have 6 bytes here?
* 6 bytes: 01 01 50 20 20 00 * * 6 bytes: 01 01 50 20 20 00 *
* EOS M6 Mark 2:
* 9 bytes: 01 03 00 58 00 2d 00 30 00
*/ */
proptype = PTP_DPC_CANON_EOS_Aperture; proptype = PTP_DPC_CANON_EOS_Aperture;
dpd = _lookup_or_allocate_canon_prop(params, prop type); dpd = _lookup_or_allocate_canon_prop(params, prop type);
dpd->CurrentValue.u16 = curdata[curoff+4]; /* jus if (olcver >= 0x12)
t use last byte */ dpd->CurrentValue.u16 = curdata[curoff+5]
; /* CHECK */
else
dpd->CurrentValue.u16 = curdata[curoff+4]
; /* just use last byte */
ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_PROPERTY; ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_PROPERTY;
ce[i].u.propid = proptype; ce[i].u.propid = proptype;
if (olcver >= 0xf) { if (olcver >= 0x12) {
curoff += 6; /* f, 11 */ curoff += 9; /* m6 mark 2, r5 */
} else { } else {
curoff += 5; /* 7, 8, b */ if (olcver >= 0xf) {
curoff += 6; /* f, 11 */
} else {
curoff += 5; /* 7, 8, b */
}
} }
i++; i++;
} }
if (mask & CANON_EOS_OLC_ISO) { if (mask & CANON_EOS_OLC_ISO) {
/* 4 bytes: 01 01 00 78 */ /* 4 bytes: 01 01 00 78 */
/* this seesm to be the aperture record */ /* EOS M6 Mark2: 01 01 00 6b 68 28 */
/* this seem to be the ISO record */
proptype = PTP_DPC_CANON_EOS_ISOSpeed; proptype = PTP_DPC_CANON_EOS_ISOSpeed;
dpd = _lookup_or_allocate_canon_prop(params, prop type); dpd = _lookup_or_allocate_canon_prop(params, prop type);
dpd->CurrentValue.u16 = curdata[curoff+3]; /* jus t use last byte */ dpd->CurrentValue.u16 = curdata[curoff+3]; /* jus t use last byte */
ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_PROPERTY; ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_PROPERTY;
ce[i].u.propid = proptype; ce[i].u.propid = proptype;
curoff += 4; /* 7, 8, b, f*/ if (curoff >= 0x12)
curoff += 6; /* m6 mark 2 */
else
curoff += 4; /* 7, 8, b, f*/
i++; i++;
} }
if (mask & 0x0010) { if (mask & 0x0010) {
/* mask 0x0010: 4 bytes, 04 00 00 00 observed */ /* mask 0x0010: 4 bytes, 04 00 00 00 observed */
ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN; ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN;
ce[i].u.info = malloc(strlen("OLCInfo event 0x001 0 content 01234567")+1); ce[i].u.info = malloc(strlen("OLCInfo event 0x001 0 content 01234567")+1);
sprintf(ce[i].u.info,"OLCInfo event 0x0010 conten t %02x%02x%02x%02x", sprintf(ce[i].u.info,"OLCInfo event 0x0010 conten t %02x%02x%02x%02x",
curdata[curoff], curdata[curoff],
curdata[curoff+1], curdata[curoff+1],
curdata[curoff+2], curdata[curoff+2],
skipping to change at line 2626 skipping to change at line 2672
ce[i].u.info = malloc(strlen("OLCInfo exposure in dicator 012345678901234567890123456789abcd")+1); ce[i].u.info = malloc(strlen("OLCInfo exposure in dicator 012345678901234567890123456789abcd")+1);
sprintf(ce[i].u.info,"OLCInfo exposure indicator %d,%d,%d.%d (%02x%02x%02x%02x)", sprintf(ce[i].u.info,"OLCInfo exposure indicator %d,%d,%d.%d (%02x%02x%02x%02x)",
curdata[curoff], curdata[curoff],
curdata[curoff+1], curdata[curoff+1],
value/10,abs(value)%10, value/10,abs(value)%10,
curdata[curoff+3], curdata[curoff+3],
curdata[curoff+4], curdata[curoff+4],
curdata[curoff+5], curdata[curoff+5],
curdata[curoff+6] curdata[curoff+6]
); );
curoff += 7; if (olcver >= 0x12) {
curoff += 8;
} else {
curoff += 7;
}
i++; i++;
} }
if (mask & 0x0080) { if (mask & 0x0080) {
/* mask 0x0080: 4 bytes, 00 00 00 00 observed */ /* mask 0x0080: 4 bytes, 00 00 00 00 observed */
ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN; ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN;
ce[i].u.info = malloc(strlen("OLCInfo event 0x008 0 content 01234567")+1); ce[i].u.info = malloc(strlen("OLCInfo event 0x008 0 content 01234567")+1);
sprintf(ce[i].u.info,"OLCInfo event 0x0080 conten t %02x%02x%02x%02x", sprintf(ce[i].u.info,"OLCInfo event 0x0080 conten t %02x%02x%02x%02x",
curdata[curoff], curdata[curoff],
curdata[curoff+1], curdata[curoff+1],
curdata[curoff+2], curdata[curoff+2],
skipping to change at line 2654 skipping to change at line 2704
ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_FOCUSINFO ; ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_FOCUSINFO ;
ce[i].u.info = malloc(strlen("0123456789ab")+1); ce[i].u.info = malloc(strlen("0123456789ab")+1);
sprintf(ce[i].u.info,"%02x%02x%02x%02x%02x%02x", sprintf(ce[i].u.info,"%02x%02x%02x%02x%02x%02x",
curdata[curoff], curdata[curoff],
curdata[curoff+1], curdata[curoff+1],
curdata[curoff+2], curdata[curoff+2],
curdata[curoff+3], curdata[curoff+3],
curdata[curoff+4], curdata[curoff+4],
curdata[curoff+5] curdata[curoff+5]
); );
curoff += 6; if (olcver >= 0x12)
curoff += 7;
else
curoff += 6;
i++; i++;
} }
if (mask & 0x0200) { if (mask & 0x0200) {
/* mask 0x0200: 7 bytes, 00 00 00 00 00 00 00 obs erved */ /* mask 0x0200: 7 bytes, 00 00 00 00 00 00 00 obs erved */
ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_FOCUSMASK ; ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_FOCUSMASK ;
ce[i].u.info = malloc(strlen("0123456789abcd01234 56789abcdef")+1); ce[i].u.info = malloc(strlen("0123456789abcd01234 56789abcdef")+1);
sprintf(ce[i].u.info,"%02x%02x%02x%02x%02x%02x%02 x", sprintf(ce[i].u.info,"%02x%02x%02x%02x%02x%02x%02 x",
curdata[curoff], curdata[curoff],
curdata[curoff+1], curdata[curoff+1],
curdata[curoff+2], curdata[curoff+2],
skipping to change at line 2739 skipping to change at line 2792
case 0: /* end marker */ case 0: /* end marker */
if (size == 8) /* no output */ if (size == 8) /* no output */
break; break;
ptp_debug (params, "event %d: EOS event 0, but size %d", i, size); ptp_debug (params, "event %d: EOS event 0, but size %d", i, size);
break; break;
case PTP_EC_CANON_EOS_BulbExposureTime: case PTP_EC_CANON_EOS_BulbExposureTime:
ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN; ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN;
ce[i].u.info = malloc(strlen("BulbExposureTime 1234567890 12345678")); ce[i].u.info = malloc(strlen("BulbExposureTime 1234567890 12345678"));
sprintf (ce[i].u.info, "BulbExposureTime %u", dtoh32a(cu rdata+8)); sprintf (ce[i].u.info, "BulbExposureTime %u", dtoh32a(cu rdata+8));
break; break;
case PTP_EC_CANON_EOS_CTGInfoCheckComplete: /* some form of stora
ge catalog ? */
ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN;
ce[i].u.info = malloc(strlen("CTGInfoCheckComplete 0x0123
45678"));
sprintf (ce[i].u.info, "CTGInfoCheckComplete 0x%08x", dt
oh32a(curdata+8));
break;
case PTP_EC_CANON_EOS_StorageStatusChanged:
ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN;
ce[i].u.info = malloc(strlen("StorageStatusChanged 0x0123
45678"));
sprintf (ce[i].u.info, "StorageStatusChanged 0x%08x", dt
oh32a(curdata+8));
break;
case PTP_EC_CANON_EOS_StorageInfoChanged:
ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN;
ce[i].u.info = malloc(strlen("StorageInfoChanged 0x012345
678"));
sprintf (ce[i].u.info, "StorageInfoChanged 0x%08x", dtoh
32a(curdata+8));
break;
case PTP_EC_CANON_EOS_StoreAdded:
ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN;
ce[i].u.info = malloc(strlen("StoreAdded 0x012345678"));
sprintf (ce[i].u.info, "StoreAdded 0x%08x", dtoh32a(curd
ata+8));
break;
case PTP_EC_CANON_EOS_StoreRemoved:
ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN;
ce[i].u.info = malloc(strlen("StoreRemoved 0x012345678"))
;
sprintf (ce[i].u.info, "StoreRemoved 0x%08x", dtoh32a(cu
rdata+8));
break;
case PTP_EC_CANON_EOS_ObjectRemoved: case PTP_EC_CANON_EOS_ObjectRemoved:
ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_OBJECTREMOVED; ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_OBJECTREMOVED;
ce[i].u.object.oid = dtoh32a(curdata+8); ce[i].u.object.oid = dtoh32a(curdata+8);
break; break;
default: default:
switch (type) { switch (type) {
#define XX(x) case PTP_EC_CANON_EOS_##x: \ #define XX(x) case PTP_EC_CANON_EOS_##x: \
ptp_debug (params, "event %u: unhandled EOS event "#x" (size %u)", i, size); \ ptp_debug (params, "event %u: unhandled EOS event "#x" (size %u)", i, size); \
ce[i].u.info = malloc(strlen("unhandled EOS event "#x" (size 12345678901)")+1); \ ce[i].u.info = malloc(strlen("unhandled EOS event "#x" (size 12345678901)")+1); \
sprintf (ce[i].u.info, "unhandled EOS event "#x" (size %u)", size); \ sprintf (ce[i].u.info, "unhandled EOS event "#x" (size %u)", size); \
break; break;
XX(RequestGetEvent) XX(RequestGetEvent)
XX(RequestGetObjectInfoEx) XX(RequestGetObjectInfoEx)
XX(StorageStatusChanged)
XX(StorageInfoChanged)
XX(ObjectInfoChangedEx) XX(ObjectInfoChangedEx)
XX(ObjectContentChanged) XX(ObjectContentChanged)
XX(WillSoonShutdown) XX(WillSoonShutdown)
XX(ShutdownTimerUpdated) XX(ShutdownTimerUpdated)
XX(RequestCancelTransfer) XX(RequestCancelTransfer)
XX(RequestObjectTransferDT) XX(RequestObjectTransferDT)
XX(RequestCancelTransferDT) XX(RequestCancelTransferDT)
XX(StoreAdded)
XX(StoreRemoved)
XX(BulbExposureTime) XX(BulbExposureTime)
XX(RecordingTime) XX(RecordingTime)
XX(RequestObjectTransferTS) XX(RequestObjectTransferTS)
XX(AfResult) XX(AfResult)
XX(PowerZoomInfoChanged) XX(PowerZoomInfoChanged)
XX(CTGInfoCheckComplete)
#undef XX #undef XX
default: default:
ptp_debug (params, "event %d: unknown EOS event % 04x", i, type); ptp_debug (params, "event %d: unknown EOS event % 04x", i, type);
break; break;
} }
if (size >= 0x8) { /* event info */ if (size >= 0x8) { /* event info */
unsigned int j; unsigned int j;
/*ptp_debug (params, "data=%p, curdata=%p, datsiz e=%d, size=%d", data, curdata, datasize, size);*/ /*ptp_debug (params, "data=%p, curdata=%p, datsiz e=%d, size=%d", data, curdata, datasize, size);*/
for (j=8;j<size;j++) for (j=8;j<size;j++)
ptp_debug (params, " %d: %02x", j, cur data[j]); ptp_debug (params, " %d: %02x", j, cur data[j]);
skipping to change at line 2822 skipping to change at line 2895
if (len < PTP_nikon_ec_Code) if (len < PTP_nikon_ec_Code)
return; return;
*cnt = dtoh16a(&data[PTP_nikon_ec_Length]); *cnt = dtoh16a(&data[PTP_nikon_ec_Length]);
if (*cnt > (len-PTP_nikon_ec_Code)/PTP_nikon_ec_Size) { /* broken cnt? */ if (*cnt > (len-PTP_nikon_ec_Code)/PTP_nikon_ec_Size) { /* broken cnt? */
*cnt = 0; *cnt = 0;
return; return;
} }
if (!*cnt) if (!*cnt)
return; return;
*ec = malloc(sizeof(PTPContainer)*(*cnt)); *ec = calloc(sizeof(PTPContainer),(*cnt));
for (i=0;i<*cnt;i++) { for (i=0;i<*cnt;i++) {
memset(&(*ec)[i],0,sizeof(PTPContainer)); memset(&(*ec)[i],0,sizeof(PTPContainer));
(*ec)[i].Code = dtoh16a(&data[PTP_nikon_ec_Code+PTP_nikon_ec_Si ze*i]); (*ec)[i].Code = dtoh16a(&data[PTP_nikon_ec_Code+PTP_nikon_ec_Si ze*i]);
(*ec)[i].Param1 = dtoh32a(&data[PTP_nikon_ec_Param1+PTP_nikon_ec_ Size*i]); (*ec)[i].Param1 = dtoh32a(&data[PTP_nikon_ec_Param1+PTP_nikon_ec_ Size*i]);
(*ec)[i].Nparam = 1; (*ec)[i].Nparam = 1;
} }
} }
/*
* PTP USB Event container unpack for Nikon events, 2nd generation.
*/
#define PTP_nikon_ec_ex_Length 0
#define PTP_nikon_ec_ex_Code 2
static inline int
ptp_unpack_Nikon_EC_EX (PTPParams *params, unsigned char* data, unsigned int len
, PTPContainer **ec, unsigned int *cnt)
{
unsigned int i, offset;
*ec = NULL;
if (data == NULL)
return 0;
if (len < PTP_nikon_ec_ex_Code)
return 0;
*cnt = dtoh16a(&data[PTP_nikon_ec_ex_Length]);
if (*cnt > (len-PTP_nikon_ec_ex_Code)/4) { /* broken cnt? simple first ch
eck ... due to dynamic size, we need to do more later */
*cnt = 0;
return 0;
}
if (!*cnt)
return 1;
*ec = calloc(sizeof(PTPContainer),(*cnt));
offset = PTP_nikon_ec_ex_Code+sizeof(uint16_t);
for (i=0;i<*cnt;i++) {
memset(&(*ec)[i],0,sizeof(PTPContainer));
if (len - offset < 4) {
free (*ec);
*ec = NULL;
*cnt = 0;
return 0;
}
(*ec)[i].Code = dtoh16a(&data[offset]);
(*ec)[i].Nparam = dtoh16a(&data[offset+2]);
ptp_debug (params, "nikon eventex %d: code 0x%04x, params %d", i,
(*ec)[i].Code, (*ec)[i].Nparam);
if ( ((*ec)[i].Nparam > 5) |
|
(len < ((*ec)[i].Nparam*sizeof(uint32_t)) + 4 + offset)
) {
free (*ec);
*ec = NULL;
*cnt = 0;
return 0;
}
switch ((*ec)[i].Nparam) {
case 5: (*ec)[i].Param5 = dtoh32a(&data[offset+4+sizeof(uint32_t)
*4]);/* fallthrough */
case 4: (*ec)[i].Param4 = dtoh32a(&data[offset+4+sizeof(uint32_t)
*3]);/* fallthrough */
case 3: (*ec)[i].Param3 = dtoh32a(&data[offset+4+sizeof(uint32_t)
*2]);/* fallthrough */
case 2: (*ec)[i].Param2 = dtoh32a(&data[offset+4+sizeof(uint32_t)
*1]);/* fallthrough */
case 1: (*ec)[i].Param1 = dtoh32a(&data[offset+4]);
/* fallthrough */
case 0: break;
}
offset += (*ec)[i].Nparam*sizeof(uint32_t) + 4;
}
return 1;
}
static inline uint32_t static inline uint32_t
ptp_pack_EK_text(PTPParams *params, PTPEKTextParams *text, unsigned char **data) { ptp_pack_EK_text(PTPParams *params, PTPEKTextParams *text, unsigned char **data) {
int i, len = 0; int i, len = 0;
uint8_t retlen; uint8_t retlen;
unsigned char *curdata; unsigned char *curdata;
len = 2*(strlen(text->title)+1)+1+ len = 2*(strlen(text->title)+1)+1+
2*(strlen(text->line[0])+1)+1+ 2*(strlen(text->line[0])+1)+1+
2*(strlen(text->line[1])+1)+1+ 2*(strlen(text->line[1])+1)+1+
2*(strlen(text->line[2])+1)+1+ 2*(strlen(text->line[2])+1)+1+
 End of changes. 48 change blocks. 
44 lines changed or deleted 203 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)