trexist.c

00001 
00022 #include "common.h"
00023 
00024 static void usage (void)
00025 {
00026   fprintf(stderr, "trexist <trackid>\n");
00027 }
00028 
00029 int main (int argc, char **argv)
00030 {
00031   LIBMTP_mtpdevice_t *device;
00032   u_int32_t id;
00033   char *endptr;
00034   
00035   // We need track ID 
00036   if ( argc != 2 ) {
00037     usage();
00038     return 1;
00039   }
00040 
00041   // Sanity check song ID
00042   id = strtoul(argv[1], &endptr, 10);
00043   if ( *endptr != 0 ) {
00044     fprintf(stderr, "illegal value %s\n", argv[1]);
00045     return 1;
00046   } else if ( ! id ) {
00047     fprintf(stderr, "bad song id %u\n", id);
00048     return 1;
00049   }
00050   
00051   LIBMTP_Init();
00052   device = LIBMTP_Get_First_Device();
00053   if (device == NULL) {
00054     printf("No devices. Connect/replug device and try again.\n");
00055     exit (0);
00056   }
00057   
00058   printf("%s\n", LIBMTP_Track_Exists(device, id) ? "Yes" : "No");
00059   
00060   LIBMTP_Release_Device(device);
00061   printf("OK.\n");
00062   exit (0);
00063 }
00064 

Generated on Fri Sep 14 22:09:19 2007 for libmtp by  doxygen 1.5.1