1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
/* Copyright (c) 2007, Christophe Fergeau <teuf@gnome.org>
*
* The code contained in this file is free software; you can redistribute
* it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either version
* 2.1 of the License, or (at your option) any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this code; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* iTunes and iPod are trademarks of Apple
*
* This product is not supported/written/published by Apple!
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <glib.h>
#include <glib/gi18n.h>
#include "itdb.h"
extern char *read_sysinfo_extended (const char *device);
int
main (int argc, char **argv)
{
char *xml;
if (argc < 3) {
g_print (_("usage: %s <device> <mountpoint>\n"), g_basename (argv[0]));
return 1;
}
xml = read_sysinfo_extended (argv[1]);
if (xml == NULL) {
g_print (_("Couldn't read xml sysinfo from %s\n"), argv[1]);
return 1;
} else {
const char *mountpoint = argv[2];
char *device_path;
char *filename;
gboolean success;
device_path = itdb_get_device_dir (mountpoint);
if (device_path == NULL) {
g_free (xml);
g_print (_("Couldn't resolve Device directory path on %s"),
mountpoint);
return 1;
}
filename = g_build_filename (device_path, "SysInfoExtended", NULL);
g_free (device_path);
if (filename == NULL) {
g_print (_("Couldn't resolve SysInfoExtended path on %s"),
mountpoint);
g_free (xml);
return 1;
}
success = g_file_set_contents (filename, xml, -1, NULL);
g_free (xml);
g_free (filename);
if (!success) {
g_print (_("Couldn't write SysInfoExtended to %s"), mountpoint);
return 1;
}
}
return 0;
}
|