diff --git a/src/camlib.h b/src/camlib.h index b2e135b..9367ea5 100644 --- a/src/camlib.h +++ b/src/camlib.h @@ -247,11 +247,11 @@ int ptp_buffer_resize(struct PtpRuntime *r, size_t size); // Packet builder/unpacker helper functions. These accept a pointer-to-pointer // and will advance the dereferenced pointer by amount read. Mostly for internal use. // These functions accept (void *), but really wants (void **), but (void **) would require casting in every call -uint8_t ptp_read_uint8(void *dat); -uint16_t ptp_read_uint16(void *dat); -uint32_t ptp_read_uint32(void *dat); -void ptp_write_uint8(void *dat, uint8_t b); -int ptp_write_uint32(void *dat, uint32_t b); +//uint8_t ptp_read_uint8(void *dat); +//uint16_t ptp_read_uint16(void *dat); +//uint32_t ptp_read_uint32(void *dat); +//void ptp_write_uint8(void *dat, uint8_t b); +//int ptp_write_uint32(void *dat, uint32_t b); int ptp_write_unicode_string(char *dat, char *string); int ptp_read_unicode_string(char *buffer, char *dat, int max); diff --git a/src/cl_data.h b/src/cl_data.h index d480d41..8ea808e 100644 --- a/src/cl_data.h +++ b/src/cl_data.h @@ -230,7 +230,7 @@ int ptp_eos_get_shutter(int data, int dir); int ptp_eos_get_iso(int data, int dir); int ptp_eos_get_aperture(int data, int dir); int ptp_eos_get_white_balance(int data, int dir); -int ptp_eos_get_imgformat_value(int data[5]); +int ptp_eos_get_imgformat_value(uint32_t data[5]); void *ptp_pack_chdk_upload_file(struct PtpRuntime *r, char *in, char *out, int *length); diff --git a/src/conv.c b/src/conv.c index 1d13835..943acdf 100644 --- a/src/conv.c +++ b/src/conv.c @@ -219,7 +219,7 @@ int ptp_eos_get_aperture(int data, int dir) { // Converts to camlib wrapper types (enum ImageFormats) struct CanonImageFormats { int value; - int data[9]; + uint32_t data[9]; }canon_imgformats[] = { {IMG_FORMAT_RAW, {1, 16, 6, 0, 4}}, // RAW {IMG_FORMAT_STD, {1, 16, 1, 0, 2}}, // STD @@ -227,7 +227,7 @@ struct CanonImageFormats { {IMG_FORMAT_RAW_JPEG, {2, 16, 6, 0, 4, 16, 1, 0, 3}}, // RAW + HIGH JPG }; -int ptp_eos_get_imgformat_value(int data[5]) { +int ptp_eos_get_imgformat_value(uint32_t data[5]) { for (int i = 0; i < (int)(sizeof(canon_imgformats) / sizeof(struct CanonImageFormats)); i++) { if (!memcmp(canon_imgformats[i].data, data, sizeof(int) * 5)) { return canon_imgformats[i].value; diff --git a/src/data.c b/src/data.c index c039fb7..b664753 100644 --- a/src/data.c +++ b/src/data.c @@ -243,14 +243,14 @@ void *ptp_pack_chdk_upload_file(struct PtpRuntime *r, char *in, char *out, int * int size_all = 4 + strlen(out) + 1 + file_size; *length = size_all; - char *data = malloc(size_all); + uint8_t *data = malloc(size_all); if (data == NULL) return NULL; - void *d_ptr = (void *)data; - ptp_write_uint32(&d_ptr, strlen(out) + 1); - ptp_write_utf8_string(&d_ptr, out); + int of = 0; + of += ptp_write_u32(data + of, strlen(out) + 1); + of += ptp_write_utf8_string(data + of, out); - fread(d_ptr, 1, file_size, f); + fread(data + of, 1, file_size, f); return data; } @@ -388,7 +388,7 @@ int ptp_storage_info_json(struct PtpStorageInfo *so, char *buffer, int max) { return len; } -int ptp_eos_prop_next(void *d, struct PtpGenericEvent *p) { +int ptp_eos_prop_next(uint8_t *d, struct PtpGenericEvent *p) { uint32_t code, value, tmp; int of = 0; @@ -417,7 +417,7 @@ int ptp_eos_prop_next(void *d, struct PtpGenericEvent *p) { name = "battery"; break; case PTP_PC_EOS_ImageFormat: { - int data[5] = {value}; + uint32_t data[5] = {value}; of += ptp_read_u32(d + of, &data[1]); of += ptp_read_u32(d + of, &data[2]); of += ptp_read_u32(d + of, &data[3]); @@ -519,7 +519,7 @@ int ptp_eos_events(struct PtpRuntime *r, struct PtpGenericEvent **p) { struct PtpGenericEvent *cur = &p_base[i]; memset(cur, 0, sizeof(struct PtpGenericEvent)); - void *d = dp; + uint8_t *d = dp; uint32_t size, type; d += ptp_read_u32(d, &size); @@ -616,7 +616,7 @@ int ptp_fuji_get_init_info(struct PtpRuntime *r, struct PtpFujiInitResp *resp) { d += ptp_read_u32(d, &resp->x3); d += ptp_read_u32(d, &resp->x4); - ptp_read_unicode_string(resp->cam_name, (char *)(dat), sizeof(resp->cam_name)); + ptp_read_unicode_string(resp->cam_name, (char *)d, sizeof(resp->cam_name)); return 0; } diff --git a/src/packet.c b/src/packet.c index c59f34c..373835d 100644 --- a/src/packet.c +++ b/src/packet.c @@ -9,34 +9,34 @@ #include #include -uint8_t ptp_read_uint8(void *dat) { +static uint8_t ptp_read_uint8(void *dat) { uint8_t **p = (uint8_t **)dat; uint8_t x = (**p); (*p)++; return x; } -uint16_t ptp_read_uint16(void *dat) { +static uint16_t ptp_read_uint16(void *dat) { uint16_t **p = (uint16_t **)dat; uint16_t x = (**p); (*p)++; return x; } -uint32_t ptp_read_uint32(void *dat) { +static uint32_t ptp_read_uint32(void *dat) { uint32_t **p = (uint32_t **)dat; uint32_t x = (**p); (*p)++; return x; } -void ptp_write_uint8(void *dat, uint8_t b) { +static void ptp_write_uint8(void *dat, uint8_t b) { uint8_t **ptr = (uint8_t **)dat; (**ptr) = b; (*ptr)++; } -int ptp_write_uint32(void *dat, uint32_t b) { +static int ptp_write_uint32(void *dat, uint32_t b) { uint32_t **ptr = (uint32_t **)dat; (**ptr) = b; (*ptr)++;