trexist.c
#include "common.h"
#include <stdlib.h>
#include <limits.h>
static void usage (void)
{
fprintf(stderr, "trexist <trackid>\n");
}
int main (int argc, char **argv)
{
LIBMTP_mtpdevice_t *device;
uint32_t id;
char *endptr;
fprintf(stdout, "libmtp version: " LIBMTP_VERSION_STRING "\n\n");
// We need track ID
if ( argc != 2 ) {
usage();
return 1;
}
// Sanity check song ID
id = strtoul(argv[1], &endptr, 10);
if ( *endptr != 0 ) {
fprintf(stderr, "illegal value %s\n", argv[1]);
return 1;
} else if ( ! id ) {
fprintf(stderr, "bad song id %u\n", id);
return 1;
}
LIBMTP_Init();
device = LIBMTP_Get_First_Device();
if (device == NULL) {
printf("No devices. Connect/replug device and try again.\n");
exit (0);
}
printf("%s\n", LIBMTP_Track_Exists(device, id) ? "Yes" : "No");
LIBMTP_Release_Device(device);
printf("OK.\n");
exit (0);
}
LIBMTP_Get_First_Device
LIBMTP_mtpdevice_t * LIBMTP_Get_First_Device(void)
Definition libmtp.c:1719
LIBMTP_Release_Device
void LIBMTP_Release_Device(LIBMTP_mtpdevice_t *device)
Definition libmtp.c:2513
LIBMTP_Init
void LIBMTP_Init(void)
Definition libmtp.c:774
LIBMTP_Track_Exists
int LIBMTP_Track_Exists(LIBMTP_mtpdevice_t *device, uint32_t const id)
Definition libmtp.c:7308
LIBMTP_mtpdevice_struct
Definition libmtp.h:635