3 * Example program that formats the device storage.
5 * Copyright (C) 2006-2007 Linus Walleij <triad@df.lth.se>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
25 * Returns 0 if OK (yes), 1 if not OK (no)
32 fprintf(stdout, "> ");
33 if ( fgets(buff, sizeof(buff), stdin) == NULL ) {
35 fprintf(stderr, "File error on stdin\n");
37 fprintf(stderr, "EOF on stdin\n");
43 } else if (buff[0] == 'n') {
49 int main (int argc, char **argv)
51 LIBMTP_mtpdevice_t *device;
54 fprintf(stdout, "libmtp version: " LIBMTP_VERSION_STRING "\n\n");
57 device = LIBMTP_Get_First_Device();
59 printf("No devices.\n");
63 printf("I will now format your device. This means that\n");
64 printf("all content (and licenses) will be lost forever.\n");
65 printf("you will not be able to undo this operation.\n");
66 printf("Continue? (y/n)\n");
68 // This will just format the first storage.
69 ret = LIBMTP_Format_Storage(device, device->storage);
76 printf("Failed to format device.\n");
77 LIBMTP_Dump_Errorstack(device);
78 LIBMTP_Clear_Errorstack(device);
79 LIBMTP_Release_Device(device);
83 LIBMTP_Release_Device(device);