return m;
}
-static int load_mood(const struct osl_row *mood_row, struct mood **m,
- char **errmsg)
+static int init_mood_parser(const char *mood_name, struct mood **m, char **err)
{
- char *mood_name;
struct osl_object mood_def;
int ret;
- ret = mood_get_name_and_def_by_row(mood_row, &mood_name, &mood_def);
+ if (!*mood_name) {
+ if (err)
+ *err = make_message("empty mood name\n");
+ return -ERRNO_TO_PARA_ERROR(EINVAL);
+ }
+ ret = mood_get_def_by_name(mood_name, &mood_def);
if (ret < 0) {
- if (errmsg)
- *errmsg = make_message(
- "could not read mood definition");
+ if (err)
+ *err = make_message("could not read mood definition\n");
return ret;
}
- assert(*mood_name);
*m = alloc_new_mood(mood_name);
PARA_INFO_LOG("opening mood %s\n", mood_name);
- ret = mp_init(mood_def.data, mood_def.size, &(*m)->parser_context, errmsg);
+ ret = mp_init(mood_def.data, mood_def.size, &(*m)->parser_context, err);
osl_close_disk_object(&mood_def);
if (ret < 0)
destroy_mood(*m);
if (mood_name) {
struct mood *m;
- struct osl_row *row;
- struct osl_object obj;
-
- if (!*mood_name) {
- *errmsg = make_message("empty mood name");
- return -ERRNO_TO_PARA_ERROR(EINVAL);
- }
- obj.data = (char *)mood_name;
- obj.size = strlen(mood_name) + 1;
- ret = osl(osl_get_row(moods_table, BLOBCOL_NAME, &obj, &row));
- if (ret < 0) {
- if (errmsg)
- *errmsg = make_message("no such mood: %s",
- mood_name);
- return ret;
- }
- ret = load_mood(row, &m, errmsg);
+ ret = init_mood_parser(mood_name, &m, errmsg);
if (ret < 0)
return ret;
close_current_mood();