2 BCU SDK bcu development enviroment
3 Copyright (C) 2005-2007 Martin Kögler <mkoegler@auto.tuwien.ac.at>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <libxml/parser.h>
27 setcontent (xmlNodePtr n
, CArray data
)
29 CArray d
= encode_hex (data
);
30 xmlNodeSetContent (n
, (const xmlChar
*) d
.array ());
34 main (int ac
, char *ag
[])
41 die (_("%s input file output"), ag
[0]);
44 FILE *f
= fopen (ag
[2], "r");
46 die (_("open of %s failed"), ag
[1]);
50 int i
= fread (buf
, 1, sizeof (buf
), f
);
51 p
.setpart (buf
, p (), i
);
57 f
= xmlParseFile (ag
[1]);
59 die (_("can not parse %s"), ag
[1]);
61 xmlNodePtr n
= xmlDocGetRootElement (f
);
63 if (n
->type
!= XML_ELEMENT_NODE
64 || (strcmp ((const char *) n
->name
, "DeviceConfig")
65 && strcmp ((const char *) n
->name
, "DeviceDesc")))
66 die (_("wrong format"));
68 xmlNodePtr cld
= n
->children
;
71 if (cld
->type
== XML_ELEMENT_NODE
)
73 const char *name
= (const char *) cld
->name
;
74 if (!strcmp (name
, "ProgramID"))
83 die (_("ProgramID not found"));
85 if (xmlSaveFormatFileEnc (ag
[3], f
, "UTF-8", 1) < 0)
86 die (_("write to %s failed"), ag
[3]);