#include "common.h"
#include <stdlib.h>
{
int i;
if(folderlist==NULL) {
return;
}
for(i=0;i<level;i++) printf(" ");
printf(
"%s\n", folderlist->
name);
dump_folder_list(folderlist->
child, level+1);
dump_folder_list(folderlist->
sibling, level);
}
int main (int argc, char **argv)
{
int numrawdevices;
int i;
printf("Attempting to connect device(s)\n");
case LIBMTP_ERROR_NO_DEVICE_ATTACHED:
printf("mtp-folders: no devices found\n");
return 0;
case LIBMTP_ERROR_CONNECTING:
fprintf(stderr, "mtp-folders: There has been an error connecting. Exit\n");
return 1;
case LIBMTP_ERROR_MEMORY_ALLOCATION:
fprintf(stderr, "mtp-folders: Memory Allocation Error. Exit\n");
return 1;
case LIBMTP_ERROR_GENERAL:
default:
fprintf(stderr, "mtp-folders: Unknown error, please report "
"this to the libmtp developers\n");
return 1;
case LIBMTP_ERROR_NONE:
printf("mtp-folders: Successfully connected\n");
}
for (i = 0; i < numrawdevices; i++) {
char *friendlyname;
int ret;
device = LIBMTP_Open_Raw_Device(&rawdevices[i]);
if (device == NULL) {
fprintf(stderr, "Unable to open raw device %d\n", i);
continue;
}
if (friendlyname == NULL) {
printf("Friendly name: (NULL)\n");
} else {
printf("Friendly name: %s\n", friendlyname);
free(friendlyname);
}
if (ret != 0) {
perror("LIBMTP_Get_Storage()\n");
continue;
}
for (storage = device->
storage; storage != 0; storage = storage->
next) {
if (folders == NULL) {
fprintf(stdout, "No folders found\n");
} else {
dump_folder_list(folders,0);
}
}
}
free(rawdevices);
printf("OK.\n");
return 0;
}