/* * Load from console.conf XML file the section: * <keybindings> * <key name="1" value="show calls"/> * </keybindings> */ static switch_status_t console_xml_config(void) { char *cf = "switch.conf"; switch_xml_t cfg, xml, settings, param; /* clear the keybind array */ int i; for (i = 0; i < 12; i++) { console_fnkeys[i] = NULL; } if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf); return SWITCH_STATUS_TERM; } if ((settings = switch_xml_child(cfg, "cli-keybindings"))) { for (param = switch_xml_child(settings, "key"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); i = atoi(var); if ((i < 1) || (i > 12)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Keybind %s is invalid, range is from 1 to 12\n", var); } else { /* Add the command to the fnkey array */ console_fnkeys[i - 1] = switch_core_permanent_strdup(val); } } } switch_xml_free(xml); return SWITCH_STATUS_SUCCESS; }
static switch_status_t setup_formats(void) { SF_FORMAT_INFO info; char buffer[128]; int format, major_count, subtype_count, m, s; int len, x, skip; char *extras[] = { "r8", "r16", "r24", "r32", "gsm", "ul", "ulaw", "al", "alaw", "adpcm", "vox", NULL }; int exlen = (sizeof(extras) / sizeof(extras[0])); buffer[0] = 0; sf_command(NULL, SFC_GET_LIB_VERSION, buffer, sizeof(buffer)); if (strlen(buffer) < 1) { switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "Line %d: could not retrieve lib version.\n", __LINE__); return SWITCH_STATUS_FALSE; } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "\nLibSndFile Version : %s Supported Formats\n", buffer); switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "================================================================================\n"); sf_command(NULL, SFC_GET_FORMAT_MAJOR_COUNT, &major_count, sizeof(int)); sf_command(NULL, SFC_GET_FORMAT_SUBTYPE_COUNT, &subtype_count, sizeof(int)); //sfinfo.channels = 1; len = ((major_count + (exlen + 2)) * sizeof(char *)); supported_formats = switch_core_permanent_alloc(len); len = 0; for (m = 0; m < major_count; m++) { skip = 0; info.format = m; sf_command(NULL, SFC_GET_FORMAT_MAJOR, &info, sizeof(info)); switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "%s (extension \"%s\")\n", info.name, info.extension); for (x = 0; x < len; x++) { if (supported_formats[x] == info.extension) { skip++; break; } } if (!skip) { char *p; struct format_map *map = switch_core_permanent_alloc(sizeof(*map)); switch_assert(map); map->ext = switch_core_permanent_strdup(info.extension); map->uext = switch_core_permanent_strdup(info.extension); map->format = info.format; if (map->ext) { for (p = map->ext; *p; p++) { *p = (char) switch_tolower(*p); } switch_core_hash_insert(globals.format_hash, map->ext, map); } if (map->uext) { for (p = map->uext; *p; p++) { *p = (char) switch_toupper(*p); } switch_core_hash_insert(globals.format_hash, map->uext, map); } supported_formats[len++] = (char *) info.extension; } format = info.format; for (s = 0; s < subtype_count; s++) { info.format = s; sf_command(NULL, SFC_GET_FORMAT_SUBTYPE, &info, sizeof(info)); format = (format & SF_FORMAT_TYPEMASK) | info.format; //sfinfo.format = format; /* if (sf_format_check(&sfinfo)) { switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, " %s\n", info.name); } */ } } for (m = 0; m < exlen; m++) { supported_formats[len++] = extras[m]; } switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_NOTICE, "================================================================================\n"); return SWITCH_STATUS_SUCCESS; }