static void _parse_audio_info (source_t *source, const char *s) { const char *start = s; unsigned int len; while (start != NULL && *start != '\0') { if ((s = strchr (start, ';')) == NULL) len = strlen (start); else { len = (int)(s - start); s++; /* skip passed the ';' */ } if (len) { char name[100], value[200]; char *esc; sscanf (start, "%99[^=]=%199[^;\r\n]", name, value); esc = util_url_unescape (value); if (esc) { util_dict_set (source->audio_info, name, esc); stats_event (source->mount, name, esc); free (esc); } } start = s; } }
/* Custom xslt loader */ static xmlDocPtr custom_loader(const xmlChar *URI, xmlDictPtr dict, int options, void *ctxt, xsltLoadType type) { xmlDocPtr ret; xmlChar *rel_path, *fn, *final_URI = NULL; char *path_URI = NULL; xsltStylesheet *c; ice_config_t *config; switch (type) { /* In case an include is loaded */ case XSLT_LOAD_STYLESHEET: /* URI is an escaped URI, make an unescaped version */ path_URI = util_url_unescape((const char*)URI); /* Error if we can't unescape */ if (path_URI == NULL) return NULL; /* Not look in admindir if the include file exists */ if (access(path_URI, F_OK) == 0) { free(path_URI); break; } free(path_URI); c = (xsltStylesheet *) ctxt; /* Check if we actually have context/path */ if (ctxt == NULL || c->doc->URL == NULL) break; /* Construct the right path */ rel_path = xmlBuildRelativeURI(URI, c->doc->URL); if (rel_path != NULL && admin_path != NULL) { fn = xmlBuildURI(rel_path, admin_path); final_URI = fn; xmlFree(rel_path); } /* Fail if there was an error constructing the path */ if (final_URI == NULL) { if (rel_path) xmlFree(rel_path); return NULL; } break; /* In case a top stylesheet is loaded */ case XSLT_LOAD_START: config = config_get_config(); /* Admin path is cached, so that we don't need to get it from * the config every time we load a xsl include. * Whenever a new top stylesheet is loaded, we check here * if the path in the config has changed and adjust it, if needed. */ if (admin_path != NULL && strcmp(config->adminroot_dir, (char *)admin_path) != 0) { xmlFree(admin_path); admin_path = NULL; } /* Do we need to load the admin path? */ if (!admin_path) { size_t len = strlen(config->adminroot_dir); admin_path = xmlMalloc(len+2); if (!admin_path) return NULL; /* Copy over admin path and add a tailing slash. */ xmlStrPrintf(admin_path, len+2, XMLSTR("%s/"), XMLSTR(config->adminroot_dir)); } config_release_config(); break; /* Avoid warnings about other events we don't care for */ default: break; } /* Get the actual xmlDoc */ if (final_URI) { ret = xslt_loader(final_URI, dict, options, ctxt, type); xmlFree(final_URI); } else { ret = xslt_loader(URI, dict, options, ctxt, type); } return ret; }