diff options
author | nicklas79 <nicklas79> | 2009-09-28 18:19:34 +0000 |
---|---|---|
committer | nicklas79 <nicklas79> | 2009-09-28 18:19:34 +0000 |
commit | daadbf2e26eca84c9d250f0e09d9efbe2c70d77a (patch) | |
tree | e38fea9dffb0cc3dbfc999253d156cf73ca74762 /examples | |
parent | aac4729a1797831465f3d45b840e22749fbf1095 (diff) | |
download | libmtp-daadbf2e26eca84c9d250f0e09d9efbe2c70d77a.tar.gz |
Add a new function to API to enable debug mode
To avoid build and build only to enable (or disable) debug mode, we
work now as the lib libusb :)
As libusb, you can do :
LIBMTP_Set_Debug(flags);
or use an environnement variable :
export LIBMTP_DEBUG=flags
flags value details :
* 0x00 [0000 0000] : no debug (default)
* 0x01 [0000 0001] : PTP debug
* 0x02 [0000 0010] : Playlist debug
* 0x04 [0000 0100] : USB debug
* 0x08 [0000 1000] : USB data debug
Diffstat (limited to 'examples')
-rw-r--r-- | examples/albumart.c | 7 | ||||
-rw-r--r-- | examples/albums.c | 17 | ||||
-rw-r--r-- | examples/detect.c | 15 |
3 files changed, 36 insertions, 3 deletions
diff --git a/examples/albumart.c b/examples/albumart.c index 51ab400..7fe9077 100644 --- a/examples/albumart.c +++ b/examples/albumart.c @@ -34,7 +34,7 @@ #endif static void usage(void) { - printf("Usage: albumart -i <fileid/trackid> -n <albumname> -s <storage_id> -p <parent_id> <imagefile>\n"); + printf("Usage: albumart -d -i <fileid/trackid> -n <albumname> -s <storage_id> -p <parent_id> <imagefile>\n"); exit(0); } @@ -58,10 +58,13 @@ int main (int argc, char **argv) { fprintf(stdout, "libmtp version: " LIBMTP_VERSION_STRING "\n\n"); - while ( (opt = getopt(argc, argv, "hn:i:s:p:")) != -1 ) { + while ( (opt = getopt(argc, argv, "dhn:i:s:p:")) != -1 ) { switch (opt) { case 'h': usage(); + case 'd': + LIBMTP_Set_Debug(9); + break; case 'i': idcount++; if ((tmp = realloc(ids, sizeof(uint32_t) * (idcount))) == NULL) { diff --git a/examples/albums.c b/examples/albums.c index a653126..8296e35 100644 --- a/examples/albums.c +++ b/examples/albums.c @@ -34,9 +34,24 @@ static void dump_albuminfo(LIBMTP_album_t *album) printf(" Tracks: %d\n\n",album->no_tracks); } -int main () { +int main (int argc, char *argv[]) { LIBMTP_mtpdevice_t *device_list, *iter; + int opt; + extern int optind; + extern char *optarg; + + while ((opt = getopt(argc, argv, "d")) != -1 ) { + switch (opt) { + case 'd': + LIBMTP_Set_Debug(9); + break; + } + } + + argc -= optind; + argv += optind; + LIBMTP_Init(); fprintf(stdout, "libmtp version: " LIBMTP_VERSION_STRING "\n\n"); diff --git a/examples/detect.c b/examples/detect.c index 393fd2c..8dba1b4 100644 --- a/examples/detect.c +++ b/examples/detect.c @@ -64,6 +64,21 @@ int main (int argc, char **argv) LIBMTP_error_number_t err; int i; + int opt; + extern int optind; + extern char *optarg; + + while ((opt = getopt(argc, argv, "d")) != -1 ) { + switch (opt) { + case 'd': + LIBMTP_Set_Debug(9); + break; + } + } + + argc -= optind; + argv += optind; + LIBMTP_Init(); fprintf(stdout, "libmtp version: " LIBMTP_VERSION_STRING "\n\n"); |