3 Copyright (C) 2012 Belledonne Communications SARL
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (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.
23 void cb_function(void *ctx, xml2lpc_log_level level, const char *msg, va_list list) {
24 const char *header = "";
39 fprintf(stdout, "%s - ", header);
40 vfprintf(stdout, msg, list);
41 fprintf(stdout, "\n");
44 void show_usage(int argc, char *argv[]) {
45 fprintf(stderr, "usage %s convert <xml_file> <lpc_file>\n"
46 " %s validate <xml_file> <xsd_file>\n",
50 int main(int argc, char *argv[]) {
52 show_usage(argc, argv);
56 xml2lpc_context *ctx = xml2lpc_context_new(cb_function, NULL);
57 xml2lpc_set_xml_file(ctx, argv[2]);
58 if(strcmp("convert", argv[1]) == 0) {
59 LpConfig *lpc = lp_config_new(argv[3]);
60 xml2lpc_convert(ctx, lpc);
62 lp_config_destroy(lpc);
63 } else if(strcmp("validate", argv[1]) == 0) {
64 xml2lpc_set_xsd_file(ctx, argv[3]);
65 xml2lpc_validate(ctx);
67 show_usage(argc, argv);
69 xml2lpc_context_destroy(ctx);