2 BCU SDK bcu development enviroment
3 Copyright (C) 2005-2007 Martin Koegler <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 writecontent (xmlNodePtr n
, const char *file
)
29 const uchar
*c
= (const uchar
*) xmlNodeGetContent (n
);
31 p
.set (c
, strlen ((const char *) c
));
34 FILE *f
= fopen (file
, "w");
36 die (_("can not write to %s"), file
);
37 fwrite (p
.array (), 1, p (), f
);
43 main (int ac
, char *ag
[])
50 die (_("%s input output"), ag
[0]);
52 f
= xmlParseFile (ag
[1]);
54 die (_("can not parse %s"), ag
[1]);
56 xmlNodePtr n
= xmlDocGetRootElement (f
);
58 if (n
->type
!= XML_ELEMENT_NODE
59 || (strcmp ((const char *) n
->name
, "DeviceConfig")
60 && strcmp ((const char *) n
->name
, "DeviceDesc")))
61 die (_("wrong format"));
63 xmlNodePtr cld
= n
->children
;
67 if (cld
->type
== XML_ELEMENT_NODE
)
69 const char *name
= (const char *) cld
->name
;
70 if (!strcmp (name
, "ProgramID"))
72 writecontent (cld
, ag
[2]);
79 die (_("ProgramID not found"));