/* -*- Mode: C ; c-basic-offset: 4 -*- */ /* Copyright (C) 2007,2008,2011 Nedko Arnaudov This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #if defined(HAVE_CONFIG_H) #include "config.h" #endif #include #include #include #include #include #include #include #include #include #include #include #include "controller_internal.h" #include "jackdbus.h" bool jack_controller_settings_init(void) { return true; } void jack_controller_settings_uninit(void) { } struct parse_context { struct jack_controller *controller_ptr; XML_Bool error; bool option_value_capture; char option[JACK_PARAM_STRING_MAX+1]; int option_used; const char * address[PARAM_ADDRESS_SIZE]; int address_index; char * container; char *name; }; #define context_ptr ((struct parse_context *)data) void jack_controller_settings_callback_chrdata(void *data, const XML_Char *s, int len) { if (context_ptr->error) { return; } if (context_ptr->option_value_capture) { if (context_ptr->option_used + len >= JACK_PARAM_STRING_MAX) { jack_error("xml parse max char data length reached"); context_ptr->error = XML_TRUE; return; } memcpy(context_ptr->option + context_ptr->option_used, s, len); context_ptr->option_used += len; } } void jack_controller_settings_callback_elstart(void *data, const char *el, const char **attr) { if (context_ptr->error) { return; } if (context_ptr->address_index >= PARAM_ADDRESS_SIZE) { assert(context_ptr->address_index == PARAM_ADDRESS_SIZE); jack_error("xml param address max depth reached"); context_ptr->error = XML_TRUE; return; } //jack_info("<%s>", el); if (strcmp(el, "jack") == 0) { return; } if (strcmp(el, PTNODE_ENGINE) == 0) { context_ptr->address[context_ptr->address_index++] = PTNODE_ENGINE; return; } if (strcmp(el, PTNODE_DRIVERS) == 0) { context_ptr->address[context_ptr->address_index++] = PTNODE_DRIVERS; return; } if (strcmp(el, PTNODE_INTERNALS) == 0) { context_ptr->address[context_ptr->address_index++] = PTNODE_INTERNALS; return; } if (strcmp(el, "driver") == 0 || strcmp(el, "internal") == 0) { if ((attr[0] == NULL || attr[2] != NULL) || strcmp(attr[0], "name") != 0) { jack_error("<%s> XML element must contain exactly one attribute, named \"name\"", el); context_ptr->error = XML_TRUE; return; } context_ptr->container = strdup(attr[1]); if (context_ptr->container == NULL) { jack_error("strdup() failed"); context_ptr->error = XML_TRUE; return; } context_ptr->address[context_ptr->address_index++] = context_ptr->container; return; } if (strcmp(el, "option") == 0) { if ((attr[0] == NULL || attr[2] != NULL) || strcmp(attr[0], "name") != 0) { jack_error("