Merge topic branch t/ff-compat into master
[paraslash.git] / blob.c
1 /* Copyright (C) 2007 Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */
2
3 /** \file blob.c Macros and functions for blob handling. */
4
5 #include <regex.h>
6 #include <fnmatch.h>
7 #include <osl.h>
8 #include <lopsub.h>
9
10 #include "server_cmd.lsg.h"
11 #include "para.h"
12 #include "error.h"
13 #include "crypt.h"
14 #include "string.h"
15 #include "afh.h"
16 #include "afs.h"
17 #include "ipc.h"
18 #include "portable_io.h"
19 #include "sideband.h"
20 #include "command.h"
21
22 /**
23 * Compare two osl objects pointing to unsigned integers of 32 bit size.
24 *
25 * \param obj1 Pointer to the first integer.
26 * \param obj2 Pointer to the second integer.
27 *
28 * \return The values required for an osl compare function.
29 */
30 static int uint32_compare(const struct osl_object *obj1, const struct osl_object *obj2)
31 {
32 uint32_t d1 = read_u32(obj1->data);
33 uint32_t d2 = read_u32(obj2->data);
34
35 if (d1 < d2)
36 return 1;
37 if (d1 > d2)
38 return -1;
39 return 0;
40 }
41
42 static struct osl_column_description blob_cols[] = {
43 [BLOBCOL_ID] = {
44 .storage_type = OSL_MAPPED_STORAGE,
45 .storage_flags = OSL_RBTREE | OSL_UNIQUE | OSL_FIXED_SIZE,
46 .name = "id",
47 .data_size = 4,
48 .compare_function = uint32_compare
49 },
50 [BLOBCOL_NAME] = {
51 .storage_type = OSL_MAPPED_STORAGE,
52 .storage_flags = OSL_RBTREE | OSL_UNIQUE,
53 .name = "name",
54 .compare_function = string_compare
55 },
56 [BLOBCOL_DEF] = {
57 .storage_type = OSL_DISK_STORAGE,
58 .storage_flags = 0,
59 .name = "definition"
60 }
61 };
62
63 /** Define an osl table description for a blob table. */
64 #define DEFINE_BLOB_TABLE_DESC(table_name) \
65 static struct osl_table_description table_name ## _table_desc = { \
66 .name = #table_name, \
67 .num_columns = NUM_BLOB_COLUMNS, \
68 .flags = OSL_LARGE_TABLE, \
69 .column_descriptions = blob_cols \
70 };
71
72 /** Define a pointer to an osl blob table with a canonical name. */
73 #define DEFINE_BLOB_TABLE_PTR(table_name) struct osl_table *table_name ## _table;
74
75 /** Define a blob table. */
76 #define INIT_BLOB_TABLE(table_name) \
77 DEFINE_BLOB_TABLE_DESC(table_name); \
78 DEFINE_BLOB_TABLE_PTR(table_name);
79
80 /* doxygen isn't smart enough to recognize these */
81 /** \cond blob_table */
82 INIT_BLOB_TABLE(lyrics);
83 INIT_BLOB_TABLE(images);
84 INIT_BLOB_TABLE(moods);
85 INIT_BLOB_TABLE(playlists);
86 /** \endcond blob_table */
87
88 static int print_blob(struct osl_table *table, struct osl_row *row,
89 const char *name, void *data)
90 {
91 struct afs_callback_arg *aca = data;
92 bool l_given = SERVER_CMD_OPT_GIVEN(LSMOOD, LONG, aca->lpr);
93 struct osl_object obj;
94 uint32_t id;
95 int ret;
96
97 if (!l_given) {
98 para_printf(&aca->pbout, "%s\n", name);
99 return 0;
100 }
101 ret = osl(osl_get_object(table, row, BLOBCOL_ID, &obj));
102 if (ret < 0) {
103 afs_error(aca, "cannot list %s\n", name);
104 return ret;
105 }
106 id = read_u32(obj.data);
107 para_printf(&aca->pbout, "%u\t%s\n", id, name);
108 return 1;
109 }
110
111 static int com_lsblob_callback(const struct lls_command * const cmd,
112 struct osl_table *table, struct afs_callback_arg *aca)
113 {
114 bool i_given, r_given;
115 struct pattern_match_data pmd = {
116 .table = table,
117 .pm_flags = PM_NO_PATTERN_MATCHES_EVERYTHING | PM_SKIP_EMPTY_NAME,
118 .match_col_num = BLOBCOL_NAME,
119 .data = aca,
120 .action = print_blob,
121 };
122 int ret;
123
124 ret = lls_deserialize_parse_result(aca->query.data, cmd, &aca->lpr);
125 pmd.lpr = aca->lpr;
126 assert(ret >= 0);
127 i_given = SERVER_CMD_OPT_GIVEN(LSMOOD, ID_SORT, aca->lpr);
128 r_given = SERVER_CMD_OPT_GIVEN(LSMOOD, REVERSE, aca->lpr);
129
130 if (r_given)
131 pmd.pm_flags |= PM_REVERSE_LOOP;
132 if (i_given)
133 pmd.loop_col_num = BLOBCOL_ID;
134 else
135 pmd.loop_col_num = BLOBCOL_NAME;
136 ret = for_each_matching_row(&pmd);
137 if (ret < 0)
138 goto out;
139 if (pmd.num_matches == 0 && lls_num_inputs(aca->lpr) > 0)
140 ret = -E_NO_MATCH;
141 out:
142 lls_free_parse_result(aca->lpr, cmd);
143 return ret;
144 }
145
146 static int com_lsblob(afs_callback *f, const struct lls_command * const cmd,
147 struct command_context *cc, struct lls_parse_result *lpr)
148 {
149 return send_lls_callback_request(f, cmd, lpr, cc);
150 }
151
152 static int cat_blob(struct osl_table *table, struct osl_row *row,
153 __a_unused const char *name, void *data)
154 {
155 int ret = 0, ret2, fd = *(int *)data;
156 struct osl_object obj;
157
158 ret = osl(osl_open_disk_object(table, row, BLOBCOL_DEF, &obj));
159 if (ret < 0)
160 return (ret == osl(-E_OSL_EMPTY))? 0 : ret;
161 assert(obj.size > 0);
162 ret = pass_buffer_as_shm(fd, SBD_OUTPUT, obj.data, obj.size);
163 ret2 = osl(osl_close_disk_object(&obj));
164 return (ret < 0)? ret : ret2;
165 }
166
167 static int com_catblob_callback(const struct lls_command * const cmd,
168 struct osl_table *table, struct afs_callback_arg *aca)
169 {
170 int ret;
171 struct pattern_match_data pmd = {
172 .table = table,
173 .loop_col_num = BLOBCOL_NAME,
174 .match_col_num = BLOBCOL_NAME,
175 .pm_flags = PM_SKIP_EMPTY_NAME,
176 .data = &aca->fd,
177 .action = cat_blob
178 };
179
180 ret = lls_deserialize_parse_result(aca->query.data, cmd, &aca->lpr);
181 assert(ret >= 0);
182 pmd.lpr = aca->lpr;
183 ret = for_each_matching_row(&pmd);
184 if (ret < 0)
185 goto out;
186 if (pmd.num_matches == 0)
187 ret = -E_NO_MATCH;
188 out:
189 lls_free_parse_result(aca->lpr, cmd);
190 return ret;
191 }
192
193 static int com_catblob(afs_callback *f, const struct lls_command * const cmd,
194 struct command_context *cc, struct lls_parse_result *lpr)
195 {
196 char *errctx;
197 int ret = lls(lls_check_arg_count(lpr, 1, INT_MAX, &errctx));
198
199 if (ret < 0) {
200 send_errctx(cc, errctx);
201 return ret;
202 }
203 return send_lls_callback_request(f, cmd, lpr, cc);
204 }
205
206 static int remove_blob(struct osl_table *table, struct osl_row *row,
207 const char *name, void *data)
208 {
209 struct afs_callback_arg *aca = data;
210 int ret = osl(osl_del_row(table, row));
211
212 if (ret < 0) {
213 afs_error(aca, "cannot remove %s\n", name);
214 return ret;
215 }
216 return 1;
217 }
218
219 static int com_rmblob_callback(const struct lls_command * const cmd,
220 struct osl_table *table, struct afs_callback_arg *aca)
221 {
222 int ret;
223 struct pattern_match_data pmd = {
224 .table = table,
225 .loop_col_num = BLOBCOL_NAME,
226 .match_col_num = BLOBCOL_NAME,
227 .pm_flags = PM_SKIP_EMPTY_NAME,
228 .data = aca,
229 .action = remove_blob
230 };
231
232 ret = lls_deserialize_parse_result(aca->query.data, cmd, &aca->lpr);
233 assert(ret >= 0);
234 pmd.lpr = aca->lpr;
235 ret = for_each_matching_row(&pmd);
236 if (ret < 0)
237 goto out;
238 if (pmd.num_matches == 0)
239 ret = -E_NO_MATCH;
240 else {
241 para_printf(&aca->pbout, "removed %u blob(s)\n",
242 pmd.num_matches);
243 ret = afs_event(BLOB_REMOVE, NULL, table);
244 }
245 out:
246 lls_free_parse_result(aca->lpr, cmd);
247 return ret;
248 }
249
250 static int com_rmblob(afs_callback *f, const struct lls_command * const cmd,
251 struct command_context *cc, struct lls_parse_result *lpr)
252 {
253 char *errctx;
254 int ret = lls(lls_check_arg_count(lpr, 1, INT_MAX, &errctx));
255
256 if (ret < 0) {
257 send_errctx(cc, errctx);
258 return ret;
259 }
260 return send_lls_callback_request(f, cmd, lpr, cc);
261 }
262
263 static int com_addblob_callback(__a_unused const struct lls_command * const cmd,
264 struct osl_table *table, struct afs_callback_arg *aca)
265 {
266 struct osl_object objs[NUM_BLOB_COLUMNS];
267 char *name = aca->query.data;
268 size_t name_len = strlen(name) + 1;
269 uint32_t id = (uint32_t)-1; /* STFU, gcc */
270 char id_buf[sizeof(id)];
271 unsigned num_rows;
272 int ret;
273
274 ret = osl(osl_get_num_rows(table, &num_rows));
275 if (ret < 0)
276 goto out;
277 if (!num_rows) { /* this is the first entry ever added */
278 /*
279 * Insert dummy row containing the next free ID. Since we are
280 * about to insert the first blob with ID 1, the next free ID
281 * will be 2.
282 */
283 id = 2U;
284 write_u32(id_buf, id);
285 objs[BLOBCOL_ID].data = id_buf;
286 objs[BLOBCOL_ID].size = sizeof(id_buf);
287 objs[BLOBCOL_NAME].data = "";
288 objs[BLOBCOL_NAME].size = 1;
289 objs[BLOBCOL_DEF].data = "";
290 objs[BLOBCOL_DEF].size = 1;
291 ret = osl(osl_add_row(table, objs));
292 if (ret < 0)
293 goto out;
294 } else {
295 /* check if name already exists */
296 struct osl_row *row;
297 struct osl_object obj = {.data = name, .size = name_len};
298 ret = osl(osl_get_row(table, BLOBCOL_NAME, &obj, &row));
299 if (ret < 0 && ret != -OSL_ERRNO_TO_PARA_ERROR(E_OSL_RB_KEY_NOT_FOUND))
300 goto out;
301 if (ret >= 0) { /* we already have a blob with this name */
302 ret = osl(osl_get_object(table, row, BLOBCOL_ID, &obj));
303 if (ret < 0)
304 goto out;
305 id = read_u32(obj.data);
306 obj.data = name + name_len;
307 obj.size = aca->query.size - name_len;
308 ret = osl(osl_update_object(table, row, BLOBCOL_DEF, &obj));
309 goto out;
310 }
311 /* new blob, get id of the dummy row and increment it */
312 obj.data = "";
313 obj.size = 1;
314 ret = osl(osl_get_row(table, BLOBCOL_NAME, &obj, &row));
315 if (ret < 0)
316 goto out;
317 ret = osl(osl_get_object(table, row, BLOBCOL_ID, &obj));
318 if (ret < 0)
319 goto out;
320 id = read_u32(obj.data) + 1;
321 write_u32(id_buf, id);
322 obj.data = &id_buf;
323 ret = osl(osl_update_object(table, row, BLOBCOL_ID, &obj));
324 if (ret < 0)
325 goto out;
326 }
327 id--;
328 write_u32(id_buf, id);
329 objs[BLOBCOL_ID].data = &id_buf;
330 objs[BLOBCOL_ID].size = sizeof(id_buf);
331 objs[BLOBCOL_NAME].data = name;
332 objs[BLOBCOL_NAME].size = name_len;
333 objs[BLOBCOL_DEF].data = name + name_len;
334 objs[BLOBCOL_DEF].size = aca->query.size - name_len;
335 ret = osl(osl_add_row(table, objs));
336 if (ret < 0)
337 goto out;
338 ret = afs_event(BLOB_ADD, NULL, table);
339 out:
340 if (ret < 0)
341 afs_error(aca, "cannot add %s\n", name);
342 else
343 para_printf(&aca->pbout, "added %s as id %u\n", name, id);
344 return ret;
345 }
346
347 /* Write input from fd to dynamically allocated buffer, but maximal 10M. */
348 static int fd2buf(struct stream_cipher_context *scc, struct osl_object *obj)
349 {
350 size_t max_size = 10 * 1024 * 1024;
351 int ret;
352 struct iovec iov;
353
354 obj->data = NULL;
355 obj->size = 0;
356 again:
357 do {
358 ret = recv_sb(scc, SBD_BLOB_DATA, max_size, &iov);
359 } while (ret == 0);
360
361 if (ret < 0) {
362 free(obj->data);
363 obj->data = NULL;
364 obj->size = 0;
365 return ret;
366 }
367 if (iov.iov_len == 0) /* end of blob */
368 return 1;
369 if (!obj->data) {
370 obj->data = iov.iov_base;
371 obj->size = iov.iov_len;
372 } else {
373 obj->data = para_realloc(obj->data, obj->size + iov.iov_len);
374 memcpy(obj->data + obj->size, iov.iov_base, iov.iov_len);
375 obj->size += iov.iov_len;
376 free(iov.iov_base);
377 max_size -= iov.iov_len;
378 }
379 goto again;
380 return 1;
381 }
382
383 /*
384 * Read blob from a file descriptor and send it to afs.
385 *
386 * This function is called from the addblob command handlers to instruct the
387 * afs process to store the input in a blob table. Input is read and decrypted
388 * from the file descriptor given by cc and appended to a buffer which also contains
389 * the name of the blob to create. The combined buffer is made available to the
390 * afs process via the callback method.
391 */
392 static int stdin_command(struct command_context *cc,
393 struct lls_parse_result *lpr, afs_callback *f)
394 {
395 struct osl_object query, stdin_obj;
396 int ret;
397 size_t len = strlen(lls_input(0, lpr));
398
399 ret = send_sb(&cc->scc, NULL, 0, SBD_AWAITING_DATA, false);
400 if (ret < 0)
401 return ret;
402 ret = fd2buf(&cc->scc, &stdin_obj);
403 if (ret < 0)
404 return ret;
405 query.size = len + 1 + stdin_obj.size;
406 query.data = alloc(query.size);
407 memcpy(query.data, lls_input(0, lpr), len + 1);
408 if (stdin_obj.size > 0)
409 memcpy((char *)query.data + len + 1, stdin_obj.data,
410 stdin_obj.size);
411 free(stdin_obj.data);
412 ret = send_callback_request(f, &query, afs_cb_result_handler, cc);
413 free(query.data);
414 return ret;
415 }
416
417 static int com_addblob(afs_callback *f, __a_unused const struct lls_command * const cmd,
418 struct command_context *cc, struct lls_parse_result *lpr)
419 {
420 char *errctx;
421 int ret = lls(lls_check_arg_count(lpr, 1, 1, &errctx));
422
423 if (ret < 0) {
424 send_errctx(cc, errctx);
425 return ret;
426 }
427 if (!lls_input(0, lpr)[0]) /* empty name is reserved for the dummy row */
428 return -E_BLOB_SYNTAX;
429 return stdin_command(cc, lpr, f);
430 }
431
432 static int com_mvblob_callback(const struct lls_command * const cmd,
433 struct osl_table *table, struct afs_callback_arg *aca)
434 {
435 const char *src, *dest;
436 struct osl_object obj;
437 struct osl_row *row;
438 int ret;
439
440 ret = lls_deserialize_parse_result(aca->query.data, cmd, &aca->lpr);
441 assert(ret >= 0);
442 src = lls_input(0, aca->lpr);
443 dest = lls_input(1, aca->lpr);
444 obj.data = (char *)src;
445 obj.size = strlen(src) + 1;
446 ret = osl(osl_get_row(table, BLOBCOL_NAME, &obj, &row));
447
448 if (ret < 0) {
449 afs_error(aca, "cannot find source blob %s\n", src);
450 goto out;
451 }
452 obj.data = (char *)dest;
453 obj.size = strlen(dest) + 1;
454 ret = osl(osl_update_object(table, row, BLOBCOL_NAME, &obj));
455 if (ret < 0) {
456 afs_error(aca, "cannot rename blob %s to %s\n", src, dest);
457 goto out;
458 }
459 ret = afs_event(BLOB_RENAME, NULL, table);
460 out:
461 lls_free_parse_result(aca->lpr, cmd);
462 return ret;
463 }
464
465 static int com_mvblob(afs_callback *f, const struct lls_command * const cmd,
466 struct command_context *cc, struct lls_parse_result *lpr)
467 {
468 char *errctx;
469 int ret = lls(lls_check_arg_count(lpr, 2, 2, &errctx));
470
471 if (ret < 0) {
472 send_errctx(cc, errctx);
473 return ret;
474 }
475 return send_lls_callback_request(f, cmd, lpr, cc);
476 }
477
478 #define DEFINE_BLOB_COMMAND(cmd_name, c_cmd_name, table_name, short_name, c_short_name) \
479 static int com_ ## cmd_name ## short_name ## _callback(struct afs_callback_arg *aca) \
480 { \
481 const struct lls_command *cmd = SERVER_CMD_CMD_PTR(c_cmd_name ## c_short_name); \
482 return com_ ## cmd_name ## blob_callback(cmd, table_name ## _table, aca); \
483 } \
484 static int com_ ## cmd_name ## short_name(struct command_context *cc, struct lls_parse_result *lpr) \
485 { \
486 const struct lls_command *cmd = SERVER_CMD_CMD_PTR(c_cmd_name ## c_short_name); \
487 return com_ ## cmd_name ## blob(com_ ## cmd_name ## short_name ## _callback, cmd, cc, lpr); \
488 } \
489 EXPORT_SERVER_CMD_HANDLER(cmd_name ## short_name);
490
491 static int blob_get_name_by_id(struct osl_table *table, uint32_t id,
492 char **name)
493 {
494 struct osl_row *row;
495 struct osl_object obj = {.data = &id, .size = sizeof(id)};
496 int ret;
497
498 if (name)
499 *name = NULL;
500 if (!id)
501 return 1;
502 ret = osl(osl_get_row(table, BLOBCOL_ID, &obj, &row));
503 if (ret < 0)
504 return ret;
505 ret = osl(osl_get_object(table, row, BLOBCOL_NAME, &obj));
506 if (ret < 0)
507 return ret;
508 if (*(char *)obj.data == '\0')
509 return -E_DUMMY_ROW;
510 if (name)
511 *name = (char *)obj.data;
512 return 1;
513 }
514
515 /** Define the \p get_name_by_id function for this blob type. */
516 #define DEFINE_GET_NAME_BY_ID(table_name, cmd_prefix) \
517 int cmd_prefix ## _get_name_by_id(uint32_t id, char **name) \
518 { \
519 return blob_get_name_by_id(table_name ## _table, id, name); \
520 }
521
522 static int blob_get_def_by_name(struct osl_table *table, const char *name,
523 struct osl_object *def)
524 {
525 struct osl_row *row;
526 struct osl_object obj = {.data = (void *)name, .size = strlen(name) + 1};
527 int ret;
528
529 def->data = NULL;
530 if (!*name)
531 return 1;
532 ret = osl(osl_get_row(table, BLOBCOL_NAME, &obj, &row));
533 if (ret < 0)
534 return ret;
535 return osl(osl_open_disk_object(table, row, BLOBCOL_DEF, def));
536 }
537
538 /** Define the \p get_def_by_id function for this blob type. */
539 #define DEFINE_GET_DEF_BY_NAME(table_name, cmd_prefix) \
540 int cmd_prefix ## _get_def_by_name(const char *name, struct osl_object *def) \
541 { \
542 return blob_get_def_by_name(table_name ## _table, name, def); \
543 }
544
545 static int blob_get_def_by_id(struct osl_table *table, uint32_t id,
546 struct osl_object *def)
547 {
548 struct osl_row *row;
549 struct osl_object obj = {.data = &id, .size = sizeof(id)};
550 int ret;
551
552 def->data = NULL;
553 if (!id)
554 return 1;
555 ret = osl(osl_get_row(table, BLOBCOL_ID, &obj, &row));
556 if (ret < 0)
557 return ret;
558 return osl(osl_open_disk_object(table, row, BLOBCOL_DEF, def));
559 }
560
561 /** Define the \p get_def_by_id function for this blob type. */
562 #define DEFINE_GET_DEF_BY_ID(table_name, cmd_prefix) \
563 int cmd_prefix ## _get_def_by_id(uint32_t id, struct osl_object *def) \
564 { \
565 return blob_get_def_by_id(table_name ## _table, id, def); \
566 }
567
568 static int blob_get_name_and_def_by_row(struct osl_table *table,
569 const struct osl_row *row, char **name, struct osl_object *def)
570 {
571 struct osl_object obj;
572 int ret = osl(osl_get_object(table, row, BLOBCOL_NAME, &obj));
573
574 if (ret < 0)
575 return ret;
576 *name = obj.data;
577 return osl(osl_open_disk_object(table, row, BLOBCOL_DEF, def));
578 }
579 /** Define the \p get_name_and_def_by_row function for this blob type. */
580 #define DEFINE_GET_NAME_AND_DEF_BY_ROW(table_name, cmd_prefix) \
581 int cmd_prefix ## _get_name_and_def_by_row(const struct osl_row *row, \
582 char **name, struct osl_object *def) \
583 { \
584 return blob_get_name_and_def_by_row(table_name ## _table, \
585 row, name, def); \
586 }
587
588 /** Define the \p close function for this blob type. */
589 #define DEFINE_BLOB_CLOSE(table_name) \
590 static void table_name ## _close(void) \
591 { \
592 osl_close_table(table_name ## _table, OSL_MARK_CLEAN); \
593 table_name ## _table = NULL; \
594 }
595
596 /** Define the \p create function for this blob type. */
597 #define DEFINE_BLOB_CREATE(table_name) \
598 static int table_name ## _create(const char *dir) \
599 { \
600 table_name ## _table_desc.dir = dir; \
601 return osl(osl_create_table(&table_name ## _table_desc)); \
602 }
603
604 static int blob_open(struct osl_table **table,
605 struct osl_table_description *desc,
606 const char *dir)
607 {
608 int ret;
609
610 desc->dir = dir;
611 ret = osl(osl_open_table(desc, table));
612 if (ret >= 0)
613 return ret;
614 *table = NULL;
615 if (ret >= 0 || ret == -OSL_ERRNO_TO_PARA_ERROR(E_OSL_NOENT))
616 return 1;
617 return ret;
618 }
619
620 #define DEFINE_BLOB_OPEN(table_name) \
621 static int table_name ## _open(const char *dir) \
622 { \
623 return blob_open(&table_name ## _table, \
624 &table_name ## _table_desc, dir); \
625 }
626
627 /** Blob tables map integers to blobs. */
628 #define DEFINE_BLOB_AFS_TABLE_OPS(table_name) \
629 const struct afs_table_operations table_name ## _ops = { \
630 .open = table_name ## _open, \
631 .close = table_name ## _close, \
632 .create = table_name ## _create, \
633 .event_handler = table_name ##_event_handler, \
634 };
635
636 /** Define all functions for this blob type. */
637 #define DEFINE_BLOB_FUNCTIONS(table_name, short_name, c_short_name) \
638 DEFINE_BLOB_OPEN(table_name) \
639 DEFINE_BLOB_CLOSE(table_name) \
640 DEFINE_BLOB_CREATE(table_name) \
641 DEFINE_BLOB_AFS_TABLE_OPS(table_name) \
642 DEFINE_BLOB_COMMAND(ls, LS, table_name, short_name, c_short_name) \
643 DEFINE_BLOB_COMMAND(cat, CAT, table_name, short_name, c_short_name) \
644 DEFINE_BLOB_COMMAND(add, ADD, table_name, short_name, c_short_name) \
645 DEFINE_BLOB_COMMAND(rm, RM, table_name, short_name, c_short_name) \
646 DEFINE_BLOB_COMMAND(mv, MV, table_name, short_name, c_short_name) \
647 DEFINE_GET_NAME_BY_ID(table_name, short_name); \
648 DEFINE_GET_DEF_BY_ID(table_name, short_name); \
649 DEFINE_GET_DEF_BY_NAME(table_name, short_name); \
650 DEFINE_GET_NAME_AND_DEF_BY_ROW(table_name, short_name); \
651
652 /* doxygen isn't smart enough to recognize these */
653 /** \cond blob_function */
654 DEFINE_BLOB_FUNCTIONS(lyrics, lyr, LYR);
655 DEFINE_BLOB_FUNCTIONS(images, img, IMG);
656 DEFINE_BLOB_FUNCTIONS(moods, mood, MOOD);
657 DEFINE_BLOB_FUNCTIONS(playlists, pl, PL);
658 /** \endcond blob_function */