| Index: src/util.c
|
| diff --git a/src/util.c b/src/util.c
|
| index 7e3b39a04832d0ee64340000c7607b309990295a..7f778a527205c9c29e108acb8680ab540ff76880 100644
|
| --- a/src/util.c
|
| +++ b/src/util.c
|
| @@ -34,9 +34,36 @@
|
| #include <sys/stat.h>
|
| #include <fcntl.h>
|
| #include <string.h>
|
| +#include "config.h"
|
| #include "libmtp.h"
|
| #include "util.h"
|
|
|
| +
|
| +/**
|
| + * This prints to stdout info about device being UNKNOWN, its
|
| + * ids, and libmtp's version number.
|
| + *
|
| + * @param dev_number the device number
|
| + * @param id_vendor vendor ID from the usb_device_desc struct
|
| + * @param id_product product ID from the usb_device_desc struct
|
| + */
|
| +void device_unknown(const int dev_number, const int id_vendor, const int id_product)
|
| +{
|
| + // This device is unknown to the developers
|
| + LIBMTP_ERROR("Device %d (VID=%04x and PID=%04x) is UNKNOWN in libmtp v%s.\n",
|
| + dev_number,
|
| + id_vendor,
|
| + id_product,
|
| + LIBMTP_VERSION_STRING);
|
| + LIBMTP_ERROR("Please report this VID/PID and the device model to the "
|
| + "libmtp development team\n");
|
| + /*
|
| + * Trying to get iManufacturer or iProduct from the device at this
|
| + * point would require opening a device handle, that we don't want
|
| + * to do right now. (Takes time for no good enough reason.)
|
| + */
|
| +}
|
| +
|
| /**
|
| * This dumps out a number of bytes to a textual, hexadecimal
|
| * dump.
|
| @@ -50,7 +77,7 @@ void data_dump (FILE *f, void *buf, uint32_t n)
|
| {
|
| unsigned char *bp = (unsigned char *) buf;
|
| uint32_t i;
|
| -
|
| +
|
| for (i = 0; i < n; i++) {
|
| fprintf(f, "%02x ", *bp);
|
| bp++;
|
| @@ -76,31 +103,31 @@ void data_dump_ascii (FILE *f, void *buf, uint32_t n, uint32_t dump_boundry)
|
| uint32_t ln, lc;
|
| int i;
|
| unsigned char *bp = (unsigned char *) buf;
|
| -
|
| +
|
| lc = 0;
|
| while (remain) {
|
| fprintf(f, "\t%04x:", dump_boundry-0x10);
|
| -
|
| +
|
| ln = ( remain > 16 ) ? 16 : remain;
|
| -
|
| +
|
| for (i = 0; i < ln; i++) {
|
| if ( ! (i%2) ) fprintf(f, " ");
|
| fprintf(f, "%02x", bp[16*lc+i]);
|
| }
|
| -
|
| +
|
| if ( ln < 16 ) {
|
| int width = ((16-ln)/2)*5 + (2*(ln%2));
|
| fprintf(f, "%*.*s", width, width, "");
|
| }
|
| -
|
| +
|
| fprintf(f, "\t");
|
| for (i = 0; i < ln; i++) {
|
| unsigned char ch= bp[16*lc+i];
|
| - fprintf(f, "%c", ( ch >= 0x20 && ch <= 0x7e ) ?
|
| + fprintf(f, "%c", ( ch >= 0x20 && ch <= 0x7e ) ?
|
| ch : '.');
|
| }
|
| fprintf(f, "\n");
|
| -
|
| +
|
| lc++;
|
| remain -= ln;
|
| dump_boundry += ln;
|
|
|