Skip to content

Commit

Permalink
Remove old crap
Browse files Browse the repository at this point in the history
  • Loading branch information
petabyt committed Mar 25, 2024
1 parent f93b7a0 commit ebd40de
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 101 deletions.
2 changes: 0 additions & 2 deletions src/backend.c

This file was deleted.

12 changes: 1 addition & 11 deletions src/camlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
5 changes: 3 additions & 2 deletions src/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 0 additions & 2 deletions src/pack.c

This file was deleted.

1 change: 0 additions & 1 deletion src/ptp.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down
81 changes: 0 additions & 81 deletions src/transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions src/util.c

This file was deleted.

0 comments on commit ebd40de

Please sign in to comment.