diff options
author | Linus Walleij <triad@df.lth.se> | 2006-02-13 13:21:57 +0000 |
---|---|---|
committer | Linus Walleij <triad@df.lth.se> | 2006-02-13 13:21:57 +0000 |
commit | 6d6d8f6da283af6cda880ac06677cf947ccf81cf (patch) | |
tree | e844a022039062367ab769c7223cf41eda966f9e | |
parent | 56d3e187fef24e0b347040ba25adaceec3ea3428 (diff) | |
download | libmtp-6d6d8f6da283af6cda880ac06677cf947ccf81cf.tar.gz |
Bang in some stuff.
-rw-r--r-- | configure.ac | 5 | ||||
-rw-r--r-- | examples/Makefile.am | 3 | ||||
-rw-r--r-- | examples/detect.c | 13 | ||||
-rw-r--r-- | examples/tracks.c | 56 |
4 files changed, 75 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac index e269cbb..cc1ea8e 100644 --- a/configure.ac +++ b/configure.ac @@ -88,6 +88,11 @@ AC_CHECK_FUNCS(basename memset select strdup strerror strrchr strtoul usleep) CFLAGS="$CFLAGS -Wall -Wmissing-prototypes" # Output files +dnl Create a header file containing NetBSD-style byte swapping macros +AC_NEED_BYTEORDER_H(src/libptp-endian.h) +dnl Create a stdint.h-like file containing size-specific integer definitions +dnl that will always be available +AC_NEED_STDINT_H(src/libptp-stdint.h) AC_CONFIG_FILES([src/libmtp.h doc/Doxyfile Makefile doc/Makefile src/Makefile examples/Makefile libmtp.sh hotplug.sh libmtp.pc]) AC_OUTPUT diff --git a/examples/Makefile.am b/examples/Makefile.am index 448c44c..6c2fcba 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,6 +1,7 @@ -bin_PROGRAMS=detect +bin_PROGRAMS=detect tracks detect_SOURCES=detect.c common.h +tracks_SOURCES=tracks.c common.h AM_CFLAGS=-I$(top_builddir)/src LDADD=../src/libmtp.la diff --git a/examples/detect.c b/examples/detect.c index 22da6c2..8e0f35c 100644 --- a/examples/detect.c +++ b/examples/detect.c @@ -2,7 +2,8 @@ int main (int argc, char **argv) { - mtpdevice_t *device; + LIBMTP_mtpdevice_t *device; + char *owner; LIBMTP_Init(); device = LIBMTP_Get_First_Device(); @@ -10,6 +11,16 @@ int main (int argc, char **argv) printf("No devices.\n"); exit (0); } + + // Get owners name + owner = LIBMTP_Get_Ownername(device); + if (owner == NULL) { + printf("Owner name: (NULL)\n"); + } else { + printf("Owner name: %s\n", owner); + free(owner); + } + LIBMTP_Release_Device(device); printf("OK.\n"); exit (0); diff --git a/examples/tracks.c b/examples/tracks.c new file mode 100644 index 0000000..02ab263 --- /dev/null +++ b/examples/tracks.c @@ -0,0 +1,56 @@ +#include "common.h" + +static void dump_trackinfo(LIBMTP_track_t *track) +{ + printf("Track ID: %d\n", track->item_id); + if (track->title != NULL) + printf(" Title: %s\n", track->title); + if (track->artist != NULL) + printf(" Artist: %s\n", track->artist); + if (track->genre != NULL) + printf(" Genre: %s\n", track->genre); + if (track->album != NULL) + printf(" Album: %s\n", track->album); + if (track->date != NULL) + printf(" Date: %s\n", track->date); + if (track->filename != NULL) + printf(" Origfilename: %s\n", track->filename); + printf(" Track number: %d\n", track->tracknumber); + printf(" Duration: %d milliseconds\n", track->duration); + printf(" File size %llu bytes\n", track->filesize); + printf(" Codec: %d\n", track->codec); +} + +int main (int argc, char **argv) +{ + LIBMTP_mtpdevice_t *device; + LIBMTP_track_t *tracks; + char *owner; + + LIBMTP_Init(); + device = LIBMTP_Get_First_Device(); + if (device == NULL) { + printf("No devices.\n"); + exit (0); + } + + // Get track listing. + tracks = LIBMTP_Get_Tracklisting(device); + if (tracks == NULL) { + printf("No tracks.\n"); + } else { + LIBMTP_track_t *track, *tmp; + track = tracks; + while (track != NULL) { + dump_trackinfo(track); + tmp = track; + track = track->next; + LIBMTP_destroy_track_t(tmp); + } + } + + LIBMTP_Release_Device(device); + printf("OK.\n"); + exit (0); +} + |