📄 st-oldcache-load.c
字号:
st_oldcache_load_value_array_value(&info); break; case STATEMENT_HANDLER_CATEGORY_STREAMS_STREAM_FIELDS_ARRAY_ARRAY: st_oldcache_load_child_value_array_value(&info); break; default: g_scanner_warn(info.parser->scanner, _("unexpected value")); } } sg_parser_statement_evaluate(info.statement); sg_parser_statement_free(info.statement); } sg_parser_free(info.parser); return TRUE;}static voidst_oldcache_load_handler_begin (LoadInfo *info){ const char *name; name = g_value_get_string(&info->statement->value); if (! strcmp(name, "live365") || ! strcmp(name, "local") || ! strcmp(name, "xiph")) { g_scanner_warn(info->parser->scanner, _("obsolete cache format, ignoring handler")); return; } info->handler = st_handlers_find_by_name(name); if (info->handler) { info->handler_parents = g_hash_table_new(g_str_hash, g_str_equal); info->handler_categories = st_handler_get_categories(info->handler); } else g_scanner_warn(info->parser->scanner, _("%s: no such handler"), name);}static voidst_oldcache_load_handler_end (LoadInfo *info){ if (! info->handler) return; g_hash_table_destroy(info->handler_parents); g_object_unref(info->handler_categories); info->handler = NULL; info->handler_categories = NULL; info->handler_parents = NULL;}static voidst_oldcache_load_category_begin (LoadInfo *info){ const char *category_name; if (! info->handler) return; category_name = g_value_get_string(&info->statement->value); if (ST_CATEGORY_BAG_NAME_IS_STOCK(category_name)) { info->category_bag = st_handler_get_stock_category(info->handler, category_name); if (! info->category_bag) g_scanner_warn(info->parser->scanner, _("%s: no such stock category"), category_name); } else { info->category_bag = st_category_bag_new(info->handler); ST_CATEGORY(info->category_bag)->name = g_strdup(category_name); }}static voidst_oldcache_load_category_end (LoadInfo *info){ if (! (info->handler && info->category_bag)) return; if (! ST_CATEGORY_BAG_IS_STOCK(info->category_bag)) { STCategoryBag *parent = NULL; if (info->category_parent_name) { parent = g_hash_table_lookup(info->handler_parents, info->category_parent_name); if (! parent) g_scanner_warn(info->parser->scanner, _("parent category \"%s\" not found"), info->category_parent_name); } g_hash_table_insert(info->handler_parents, ST_CATEGORY(info->category_bag)->name, info->category_bag); st_category_store_append(info->handler_categories, info->category_bag, parent); g_object_unref(info->category_bag); } if (info->category_streams) { st_handler_set_streams(info->handler, ST_CATEGORY(info->category_bag)->name, info->category_streams); g_object_unref(info->category_streams); } g_free(info->category_parent_name); info->category_bag = NULL; info->category_parent_name = NULL; info->category_streams = NULL;}static voidst_oldcache_load_stream_begin (LoadInfo *info){ if (! (info->handler && info->category_bag)) return; info->stream_bag = st_stream_bag_new(info->handler); ST_STREAM(info->stream_bag)->name = g_value_dup_string(&info->statement->value);}static voidst_oldcache_load_stream_end (LoadInfo *info){ if (! (info->handler && info->stream_bag)) return; if (! info->category_streams) { info->category_streams = st_stream_store_new(info->handler); st_stream_store_touch(info->category_streams); } st_stream_store_append(info->category_streams, info->stream_bag); g_object_unref(info->stream_bag); info->stream_bag = NULL; info->stream_field_iter = NULL; info->stream_field = NULL;}static voidst_oldcache_load_pop_field (LoadInfo *info){ while (info->stream_field_iter) { info->stream_field = info->stream_field_iter->data; info->stream_field_iter = info->stream_field_iter->next; if (! ST_HANDLER_FIELD_IS_VOLATILE(info->stream_field)) return; } info->stream_field = NULL; /* not found */ g_scanner_warn(info->parser->scanner, _("too many fields"));}static voidst_oldcache_load_stream_field (LoadInfo *info){ if (! (info->handler && info->stream_bag)) return; st_oldcache_load_pop_field(info); if (info->stream_field) { if (st_handler_field_get_type(info->stream_field) == GDK_TYPE_PIXBUF && G_VALUE_HOLDS_STRING(&info->statement->value)) { const char *filename; filename = g_value_get_string(&info->statement->value); if (filename) { GdkPixbuf *pixbuf; GError *err = NULL; pixbuf = gdk_pixbuf_new_from_file(filename, &err); if (pixbuf) { GValue value = { 0, }; g_value_init(&value, GDK_TYPE_PIXBUF); g_value_set_object(&value, pixbuf); g_object_unref(pixbuf); st_stream_bag_set_field(info->stream_bag, info->stream_field, &value); g_value_unset(&value); } else { g_scanner_warn(info->parser->scanner, "%s", err->message); g_error_free(err); } } } else if (G_VALUE_HOLDS(&info->statement->value, st_handler_field_get_type(info->stream_field))) st_stream_bag_set_field(info->stream_bag, info->stream_field, &info->statement->value); else g_scanner_warn(info->parser->scanner, _("wrong field type")); }}static voidst_oldcache_load_value_array_begin (LoadInfo *info){ if (! (info->handler && info->stream_bag)) return; st_oldcache_load_pop_field(info); if (info->stream_field) { if (st_handler_field_get_type(info->stream_field) == G_TYPE_VALUE_ARRAY) info->value_array = g_value_array_new(0); else g_scanner_warn(info->parser->scanner, _("wrong field type")); }}static voidst_oldcache_load_value_array_value (LoadInfo *info){ if (! (info->handler && info->value_array)) return; g_value_array_append(info->value_array, &info->statement->value);}static voidst_oldcache_load_value_array_end (LoadInfo *info){ GValue value = { 0, }; if (! (info->handler && info->value_array)) return; g_value_init(&value, G_TYPE_VALUE_ARRAY); g_value_take_boxed(&value, info->value_array); st_stream_bag_set_field(info->stream_bag, info->stream_field, &value); g_value_unset(&value); info->value_array = NULL;}static voidst_oldcache_load_child_value_array_begin (LoadInfo *info){ if (! (info->handler && info->value_array)) return; info->child_value_array = g_value_array_new(0);}static voidst_oldcache_load_child_value_array_value (LoadInfo *info){ if (! (info->handler && info->child_value_array)) return; g_value_array_append(info->child_value_array, &info->statement->value);}static voidst_oldcache_load_child_value_array_end (LoadInfo *info){ GValue value = { 0, }; if (! (info->handler && info->child_value_array)) return; g_value_init(&value, G_TYPE_VALUE_ARRAY); g_value_take_boxed(&value, info->child_value_array); st_stream_bag_set_field(info->stream_bag, info->stream_field, &value); g_value_array_append(info->value_array, &value); g_value_unset(&value); info->child_value_array = NULL;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -