diff --git a/src/backend.c b/src/backend.c deleted file mode 100644 index e12a139..0000000 --- a/src/backend.c +++ /dev/null @@ -1,2 +0,0 @@ -#warning "Use transport.c instead" -#include "transport.c" diff --git a/src/camlib.h b/src/camlib.h index 9367ea5..62b2645 100644 --- a/src/camlib.h +++ b/src/camlib.h @@ -242,26 +242,16 @@ int ptp_check_opcode(struct PtpRuntime *r, int opcode); int ptp_check_prop(struct PtpRuntime *r, int code); /// @brief Mostly for internal use - realloc the data buffer +/// @note r->data will be reassigned, any old references must be updated 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); - int ptp_write_unicode_string(char *dat, char *string); int ptp_read_unicode_string(char *buffer, char *dat, int max); int ptp_read_utf8_string(void *dat, char *string, int max); - int ptp_read_string(uint8_t *dat, char *string, int max); int ptp_write_string(uint8_t *dat, char *string); int ptp_write_utf8_string(void *dat, char *string); int ptp_read_uint16_array(uint8_t *dat, uint16_t *buf, int max, int *length); - inline static int ptp_write_u8 (void *buf, uint8_t out) { ((uint8_t *)buf)[0] = out; return 1; } inline static int ptp_write_u16(void *buf, uint16_t out) { ((uint16_t *)buf)[0] = out; return 2; } inline static int ptp_write_u32(void *buf, uint32_t out) { ((uint32_t *)buf)[0] = out; return 4; } diff --git a/src/lib.c b/src/lib.c index 886c910..e896599 100644 --- a/src/lib.c +++ b/src/lib.c @@ -159,9 +159,10 @@ int ptp_send(struct PtpRuntime *r, struct PtpCommand *cmd) { return PTP_IO_ERR; } - if (ptp_receive_bulk_packets(r) < 0) { + int rc = ptp_receive_bulk_packets(r); + if (rc < 0) { ptp_mutex_unlock_thread(r); - ptp_verbose_log("Failed to recieve packets\n"); + ptp_verbose_log("Failed to recieve packets: %d\n", rc); return PTP_IO_ERR; } diff --git a/src/pack.c b/src/pack.c deleted file mode 100644 index c4eacc2..0000000 --- a/src/pack.c +++ /dev/null @@ -1,2 +0,0 @@ -#include -// ... diff --git a/src/ptp.h b/src/ptp.h index 8d10081..9605c1b 100644 --- a/src/ptp.h +++ b/src/ptp.h @@ -1,5 +1,4 @@ // This file describes Picture Transfer Protocol (ISO 15740) -// Written by Daniel Cook, licensed under GPL2.0 or later #ifndef PTP_H #define PTP_H diff --git a/src/transport.c b/src/transport.c index de3b34c..20f2f89 100644 --- a/src/transport.c +++ b/src/transport.c @@ -318,84 +318,3 @@ int ptp_receive_bulk_packets(struct PtpRuntime *r) { return PTP_IO_ERR; } } - -#if 0 -// Pipe-routing IO, untested, don't use yet -int ptp_fsend_packets(struct PtpRuntime *r, int length, FILE *stream) { - int x = ptp_cmd_write(r, r->data, length); - if (x < 0) { - ptp_verbose_log("send_bulk_packet: %d\n", x); - return PTP_IO_ERR; - } - - int sent = x; - - while (1) { - x = fread(r->data, 1, r->max_packet_size, stream); - if (x <= 0) { - ptp_verbose_log("fread: %d", x); - return PTP_IO_ERR; - } - - if (r->connection_type == PTP_USB) { - x = ptp_cmd_write(r, r->data, x); - } else if (r->connection_type == PTP_IP || r->connection_type == PTP_IP_USB) { - x = ptpip_cmd_write(r, r->data, x); - } - - if (x < 0) { - ptp_verbose_log("send_bulk_packet: %d\n", x); - return PTP_IO_ERR; - } - - sent += x; - - if (sent >= length) { - ptp_verbose_log("send_bulk_packet: Sent %d bytes\n", sent); - return sent; - } - } -} - -// TODO: Fix for IP -int ptp_freceive_bulk_packets(struct PtpRuntime *r, FILE *stream, int of) { - int read = 0; - - // Since the data is written to file, we must remember the packet type - int type = -1; - while (1) { - int x = ptp_cmd_read(r, r->data, r->max_packet_size); - if (x < 0) { - ptp_verbose_log("receive_bulk_packet: %d\n", x); - return PTP_IO_ERR; - } - - if (type == -1) { - struct PtpBulkContainer *c = (struct PtpBulkContainer *)(r->data); - type = c->type; - } - - int fr = fwrite(r->data + of, 1, x - of, stream); - of = 0; - if (fr <= 0) { - ptp_verbose_log("fwrite: %d\n", fr); - } - - read += x; - - if (x != r->max_packet_size) { - ptp_verbose_log("ptp_freceive_bulk_packets: Read %d bytes\n", read); - - // Read the response packet if only a data packet was sent - if (type == PTP_PACKET_TYPE_DATA) { - x = ptp_cmd_read(r, r->data, r->max_packet_size); - ptp_verbose_log("ptp_freceive_bulk_packets: Return code: 0x%X\n", ptp_get_return_code(r)); - } else { - // TODO: Why send a small packet with stream reader? - } - - return read; - } - } -} -#endif diff --git a/src/util.c b/src/util.c deleted file mode 100644 index 578b7d1..0000000 --- a/src/util.c +++ /dev/null @@ -1,2 +0,0 @@ -#warning "util.c has been renamed to lib.c" -#include "lib.c"