+
+static int blob_get_def_by_name(struct osl_table *table, char *name,
+ struct osl_object *def)
+{
+ struct osl_row *row;
+ struct osl_object obj = {.data = name, .size = strlen(name) + 1};
+ int ret;
+
+ def->data = NULL;
+ if (!*name)
+ return 1;
+ ret = osl_get_row(table, BLOBCOL_NAME, &obj, &row);
+ if (ret < 0)
+ return ret;
+ return osl_open_disk_object(table, row, BLOBCOL_DEF, def);
+}
+
+/** Define the \p get_def_by_id function for this blob type. */
+#define DEFINE_GET_DEF_BY_NAME(table_name, cmd_prefix) \
+ int cmd_prefix ## _get_def_by_name(char *name, struct osl_object *def) \
+ { \
+ return blob_get_def_by_name(table_name ## _table, name, def); \
+ }
+
+static int blob_get_def_by_id(struct osl_table *table, uint32_t id,
+ struct osl_object *def)
+{
+ struct osl_row *row;
+ struct osl_object obj = {.data = &id, .size = sizeof(id)};
+ int ret;
+
+ def->data = NULL;
+ if (!id)
+ return 1;
+ ret = osl_get_row(table, BLOBCOL_ID, &obj, &row);
+ if (ret < 0)
+ return ret;
+ return osl_open_disk_object(table, row, BLOBCOL_DEF, def);
+}
+
+/** Define the \p get_def_by_id function for this blob type. */
+#define DEFINE_GET_DEF_BY_ID(table_name, cmd_prefix) \
+ int cmd_prefix ## _get_def_by_id(uint32_t id, struct osl_object *def) \
+ { \
+ return blob_get_def_by_id(table_name ## _table, id, def); \
+ }
+