return NULL;
}
+int expo_edit_str(struct expo *exp, uint id, struct abuf *orig,
+ struct abuf **copyp)
+{
+ struct expo_string *estr;
+ struct abuf old;
+
+ list_for_each_entry(estr, &exp->str_head, sibling) {
+ if (estr->id == id) {
+ old = estr->buf;
+ if (!abuf_copy(&old, &estr->buf))
+ return -ENOMEM;
+ *copyp = &estr->buf;
+ if (orig)
+ *orig = old;
+ return 0;
+ }
+ }
+
+ return -ENOENT;
+}
+
int expo_set_display(struct expo *exp, struct udevice *dev)
{
struct udevice *cons;
*/
const char *expo_get_str(struct expo *exp, uint id);
+/**
+ * expo_edit_str() - Make a string writeable
+ *
+ * This allows a string to be updated under the control of the caller. The
+ * buffer must remain valid while the expo is active.
+ *
+ * @exp: Expo to use
+ * @id: String ID to look up
+ * @orig: If non-NULL, returns the original buffer, which can be used by the
+ * caller. It is no-longer used by expo so must be uninited by the caller.
+ * It contains a snapshot of the string contents
+ * @copyp: Returns a pointer to the new, writeable buffer
+ * Return: 0 if OK, -ENOENT if the id was not found, -ENOMEM if out of memory
+ */
+int expo_edit_str(struct expo *exp, uint id, struct abuf *orig,
+ struct abuf **copyp);
+
/**
* expo_set_display() - set the display to use for a expo
*
struct scene_obj_menu *menu;
struct scene_menitem *item;
struct scene_obj_txt *txt;
+ struct abuf orig, *copy;
struct scene_obj *obj;
struct scene *scn;
struct expo *exp;
count = list_count_nodes(&menu->item_head);
ut_asserteq(3, count);
+ /* try editing some text */
+ ut_assertok(expo_edit_str(exp, txt->gen.str_id, &orig, ©));
+ ut_asserteq_str("2 GHz", orig.data);
+ ut_asserteq_str("2 GHz", copy->data);
+
+ /* change it and check that things look right */
+ abuf_printf(copy, "atlantic %d", 123);
+ ut_asserteq_str("2 GHz", orig.data);
+ ut_asserteq_str("atlantic 123", copy->data);
+
expo_destroy(exp);
return 0;