summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authornicklas79 <nicklas79>2009-09-28 18:16:45 +0000
committernicklas79 <nicklas79>2009-09-28 18:16:45 +0000
commitaac4729a1797831465f3d45b840e22749fbf1095 (patch)
tree4eeb002c7f2db64d75a3371717f0e945dc74a127 /examples
parentcea83ff762e155ee4dd4dd0004a26d0411283285 (diff)
downloadlibmtp-aac4729a1797831465f3d45b840e22749fbf1095.tar.gz
Add 'p' and 's' command line options
Add p (parent_id) and s (storage_id) to command mtp-albumart and mtp-newplaylit. It's usefull for the devices who have several mass storage units.
Diffstat (limited to 'examples')
-rw-r--r--examples/albumart.c16
-rw-r--r--examples/newplaylist.c16
2 files changed, 24 insertions, 8 deletions
diff --git a/examples/albumart.c b/examples/albumart.c
index 61b056e..51ab400 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> <imagefile>\n");
+ printf("Usage: albumart -i <fileid/trackid> -n <albumname> -s <storage_id> -p <parent_id> <imagefile>\n");
exit(0);
}
@@ -53,10 +53,12 @@ int main (int argc, char **argv) {
char *path = NULL;
char *rest;
struct stat statbuff;
+ uint32_t storageid = 0;
+ uint32_t parentid = 0;
fprintf(stdout, "libmtp version: " LIBMTP_VERSION_STRING "\n\n");
- while ( (opt = getopt(argc, argv, "hn:i:")) != -1 ) {
+ while ( (opt = getopt(argc, argv, "hn:i:s:p:")) != -1 ) {
switch (opt) {
case 'h':
usage();
@@ -72,6 +74,12 @@ int main (int argc, char **argv) {
case 'n':
albumname = strdup(optarg);
break;
+ case 's':
+ storageid = (uint32_t) strtoul(optarg, NULL, 0);
+ break;
+ case 'p':
+ parentid = (uint32_t) strtoul(optarg, NULL, 0);
+ break;
default:
usage();
}
@@ -133,8 +141,8 @@ int main (int argc, char **argv) {
album->name = albumname;
album->no_tracks = idcount;
album->tracks = ids;
- album->parent_id = 0;
- album->storage_id = 0;
+ album->parent_id = parentid;
+ album->storage_id = storageid;
int ret = LIBMTP_Create_New_Album(device,album);
if (ret == 0) {
ret = LIBMTP_Send_Representative_Sample(device,album->album_id, albumart);
diff --git a/examples/newplaylist.c b/examples/newplaylist.c
index a5caf86..9f47ae5 100644
--- a/examples/newplaylist.c
+++ b/examples/newplaylist.c
@@ -28,7 +28,7 @@
#include <errno.h>
static void usage(void) {
- printf("Usage: newplaylist -i <fileid/trackid> -n <playlistname>\n");
+ printf("Usage: newplaylist -i <fileid/trackid> -n <playlistname> -s <storage_id> -p <parent_id>\n");
exit(0);
}
@@ -42,10 +42,12 @@ int main (int argc, char **argv) {
uint32_t *tmp = NULL;
char *playlistname = NULL;
char *rest;
+ uint32_t storageid = 0;
+ uint32_t parentid = 0;
fprintf(stdout, "libmtp version: " LIBMTP_VERSION_STRING "\n\n");
- while ( (opt = getopt(argc, argv, "hn:i:")) != -1 ) {
+ while ( (opt = getopt(argc, argv, "hn:i:s:p:")) != -1 ) {
switch (opt) {
case 'h':
usage();
@@ -61,6 +63,12 @@ int main (int argc, char **argv) {
case 'n':
playlistname = strdup(optarg);
break;
+ case 's':
+ storageid = (uint32_t) strtoul(optarg, NULL, 0);
+ break;
+ case 'p':
+ parentid = (uint32_t) strtoul(optarg, NULL, 0);
+ break;
default:
usage();
}
@@ -90,8 +98,8 @@ int main (int argc, char **argv) {
playlist->name = playlistname;
playlist->no_tracks = idcount;
playlist->tracks = ids;
- playlist->parent_id = 0;
- playlist->storage_id = 0;
+ playlist->parent_id = parentid;
+ playlist->storage_id = storageid;
int ret = LIBMTP_Create_New_Playlist(device,playlist);
if (ret != 0) {
printf("Couldn't create playlist object\n");