static void parse_menu_item(xmlNodePtr node, gpointer data) { ObMenuParseState *state = data; gchar *label; gchar *icon; ObMenuEntry *e; if (state->parent) { /* Don't try to extract "icon" attribute if icons in user-defined menus are not enabled. */ if (obt_xml_attr_string(node, "label", &label)) { xmlNodePtr c; GSList *acts = NULL; c = obt_xml_find_node(node->children, "action"); while (c) { ObActionsAct *action = actions_parse(c); if (action) acts = g_slist_append(acts, action); c = obt_xml_find_node(node->next, "action"); } e = menu_add_normal(state->parent, -1, label, acts, TRUE); if (config_menu_show_icons && obt_xml_attr_string(node, "icon", &icon)) { RrImage *ic; ic = RrImageCacheFindName(ob_rr_icons, icon); if (ic) RrImageRef(ic); else { ic = RrImageNew(ob_rr_icons); if (!RrImageAddPictureName(ic, icon)) { RrImageUnref(ic); /* no need to keep it around */ ic = NULL; } } e->data.normal.icon = ic; if (e->data.normal.icon) e->data.normal.icon_alpha = 0xff; g_free(icon); } g_free(label); } } }
/* Like actions_parse(), but the actions are taken from 's'. */ char * OVS_WARN_UNUSED_RESULT actions_parse_string(const char *s, const struct action_params *ap, struct ofpbuf *ofpacts, struct expr **prereqsp) { struct lexer lexer; char *error; lexer_init(&lexer, s); lexer_get(&lexer); error = actions_parse(&lexer, ap, ofpacts, prereqsp); lexer_destroy(&lexer); return error; }
/* Like actions_parse(), but the actions are taken from 's'. */ char * OVS_WARN_UNUSED_RESULT actions_parse_string(const char *s, const struct shash *symtab, const struct simap *ports, const struct simap *ct_zones, uint8_t first_table, uint8_t n_tables, uint8_t cur_table, uint8_t output_table, struct ofpbuf *ofpacts, struct expr **prereqsp) { struct lexer lexer; char *error; lexer_init(&lexer, s); lexer_get(&lexer); error = actions_parse(&lexer, symtab, ports, ct_zones, first_table, n_tables, cur_table, output_table, ofpacts, prereqsp); lexer_destroy(&lexer); return error; }