Overhaul the daemon uptime functions.
[paraslash.git] / blob.c
1 /*
2 * Copyright (C) 2007-2011 Andre Noll <maan@systemlinux.org>
3 *
4 * Licensed under the GPL v2. For licencing details see COPYING.
5 */
6
7 /** \file blob.c Macros and functions for blob handling. */
8
9 #include <regex.h>
10 #include <fnmatch.h>
11 #include <osl.h>
12
13 #include "para.h"
14 #include "error.h"
15 #include "crypt.h"
16 #include "string.h"
17 #include "afh.h"
18 #include "afs.h"
19 #include "ipc.h"
20 #include "portable_io.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 * \sa osl_compare_func, osl_hash_compare().
31 */
32 static int uint32_compare(const struct osl_object *obj1, const struct osl_object *obj2)
33 {
34 uint32_t d1 = read_u32((const char *)obj1->data);
35 uint32_t d2 = read_u32((const char *)obj2->data);
36
37 if (d1 < d2)
38 return 1;
39 if (d1 > d2)
40 return -1;
41 return 0;
42 }
43
44 static struct osl_column_description blob_cols[] = {
45 [BLOBCOL_ID] = {
46 .storage_type = OSL_MAPPED_STORAGE,
47 .storage_flags = OSL_RBTREE | OSL_UNIQUE | OSL_FIXED_SIZE,
48 .name = "id",
49 .data_size = 4,
50 .compare_function = uint32_compare
51 },
52 [BLOBCOL_NAME] = {
53 .storage_type = OSL_MAPPED_STORAGE,
54 .storage_flags = OSL_RBTREE | OSL_UNIQUE,
55 .name = "name",
56 .compare_function = string_compare
57 },
58 [BLOBCOL_DEF] = {
59 .storage_type = OSL_DISK_STORAGE,
60 .storage_flags = 0,
61 .name = "definition"
62 }
63 };
64
65 /** Define an osl table description for a blob table. */
66 #define DEFINE_BLOB_TABLE_DESC(table_name) \
67 struct osl_table_description table_name ## _table_desc = { \
68 .name = #table_name, \
69 .num_columns = NUM_BLOB_COLUMNS, \
70 .flags = OSL_LARGE_TABLE, \
71 .column_descriptions = blob_cols \
72 };
73
74 /** Define a pointer to an osl blob table with a canonical name. */
75 #define DEFINE_BLOB_TABLE_PTR(table_name) struct osl_table *table_name ## _table;
76
77
78 /** Define a blob table. */
79 #define INIT_BLOB_TABLE(table_name) \
80 DEFINE_BLOB_TABLE_DESC(table_name); \
81 DEFINE_BLOB_TABLE_PTR(table_name);
82
83 /** \cond doxygen isn't smart enough to recognize these */
84 INIT_BLOB_TABLE(lyrics);
85 INIT_BLOB_TABLE(images);
86 INIT_BLOB_TABLE(moods);
87 INIT_BLOB_TABLE(playlists);
88 /** \endcond */
89
90 /** Flags that may be passed to the \p ls functions of each blob type. */
91 enum blob_ls_flags {
92 /** List both id and name. */
93 BLOB_LS_FLAG_LONG = 1,
94 /** Reverse sort order. */
95 BLOB_LS_FLAG_REVERSE = 2,
96 /** Sort by id instead of name. */
97 BLOB_LS_FLAG_SORT_BY_ID = 4,
98 };
99
100 /** Structure passed to the \p print_blob function. */
101 struct lsblob_action_data {
102 /** The flags given at the command line. */
103 uint32_t flags;
104 /** Message buffer. */
105 struct para_buffer pb;
106 };
107
108 static int print_blob(struct osl_table *table, struct osl_row *row,
109 const char *name, void *data)
110 {
111 struct lsblob_action_data *lbad = data;
112 struct osl_object obj;
113 uint32_t id;
114 int ret;
115
116 if (!(lbad->flags & BLOB_LS_FLAG_LONG))
117 return para_printf(&lbad->pb, "%s\n", name);
118 ret = osl(osl_get_object(table, row, BLOBCOL_ID, &obj));
119 if (ret < 0) {
120 para_printf(&lbad->pb, "%s: %s\n", name, para_strerror(-ret));
121 return ret;
122 }
123 id = *(uint32_t *)obj.data;
124 return para_printf(&lbad->pb, "%u\t%s\n", id, name);
125 }
126
127 static void com_lsblob_callback(struct osl_table *table,
128 int fd, const struct osl_object *query)
129 {
130 struct lsblob_action_data lbad = {
131 .flags = *(uint32_t *)query->data,
132 .pb = {
133 .max_size = SHMMAX,
134 .private_data = &fd,
135 .max_size_handler = pass_buffer_as_shm
136 }
137 };
138 struct pattern_match_data pmd = {
139 .table = table,
140 .patterns = {.data = (char *)query->data + sizeof(uint32_t),
141 .size = query->size - sizeof(uint32_t)},
142 .pm_flags = PM_NO_PATTERN_MATCHES_EVERYTHING | PM_SKIP_EMPTY_NAME,
143 .match_col_num = BLOBCOL_NAME,
144 .data = &lbad,
145 .action = print_blob,
146 };
147 int ret;
148
149 if (lbad.flags & BLOB_LS_FLAG_REVERSE)
150 pmd.pm_flags |= PM_REVERSE_LOOP;
151 if (!(lbad.flags & BLOB_LS_FLAG_SORT_BY_ID))
152 pmd.loop_col_num = BLOBCOL_NAME;
153 else
154 pmd.loop_col_num = BLOBCOL_ID;
155 ret = for_each_matching_row(&pmd);
156 if (ret < 0)
157 para_printf(&lbad.pb, "%s\n", para_strerror(-ret));
158 if (lbad.pb.offset)
159 pass_buffer_as_shm(lbad.pb.buf, lbad.pb.offset, &fd);
160 free(lbad.pb.buf);
161 }
162
163 static int com_lsblob(callback_function *f, struct stream_cipher_context *scc, int argc, char * const * const argv)
164 {
165 uint32_t flags = 0;
166 struct osl_object options = {.data = &flags, .size = sizeof(flags)};
167 int i;
168
169 for (i = 1; i < argc; i++) {
170 const char *arg = argv[i];
171 if (arg[0] != '-')
172 break;
173 if (!strcmp(arg, "--")) {
174 i++;
175 break;
176 }
177 if (!strcmp(arg, "-l")) {
178 flags |= BLOB_LS_FLAG_LONG;
179 continue;
180 }
181 if (!strcmp(arg, "-i")) {
182 flags |= BLOB_LS_FLAG_SORT_BY_ID;
183 continue;
184 }
185 if (!strcmp(arg, "-r")) {
186 flags |= BLOB_LS_FLAG_REVERSE;
187 continue;
188 }
189 break;
190 }
191 // if (argc > i)
192 // return -E_BLOB_SYNTAX;
193 return send_option_arg_callback_request(&options, argc - i,
194 argv + i, f, sc_send_result, scc);
195 }
196
197 static int cat_blob(struct osl_table *table, struct osl_row *row,
198 __a_unused const char *name, void *data)
199 {
200 int ret = 0, ret2;
201 struct osl_object obj;
202
203 ret = osl(osl_open_disk_object(table, row, BLOBCOL_DEF, &obj));
204 if (ret < 0)
205 return ret;
206 if (obj.size)
207 ret = pass_buffer_as_shm(obj.data, obj.size, data);
208 ret2 = osl(osl_close_disk_object(&obj));
209 return (ret < 0)? ret : ret2;
210 }
211
212 static void com_catblob_callback(struct osl_table *table, int fd,
213 const struct osl_object *query)
214 {
215 struct pattern_match_data pmd = {
216 .table = table,
217 .patterns = *query,
218 .loop_col_num = BLOBCOL_NAME,
219 .match_col_num = BLOBCOL_NAME,
220 .pm_flags = PM_SKIP_EMPTY_NAME,
221 .data = &fd,
222 .action = cat_blob
223 };
224 for_each_matching_row(&pmd);
225 }
226
227 static int com_catblob(callback_function *f, struct stream_cipher_context *scc, int argc,
228 char * const * const argv)
229 {
230 if (argc < 2)
231 return -E_BLOB_SYNTAX;
232 return send_standard_callback_request(argc - 1, argv + 1, f,
233 sc_send_result, scc);
234 }
235
236 /** Used for removing rows from a blob table. */
237 struct rmblob_data {
238 /** Message buffer. */
239 struct para_buffer pb;
240 /** Number of removed blobs. */
241 unsigned num_removed;
242 };
243
244 static int remove_blob(struct osl_table *table, struct osl_row *row,
245 const char *name, void *data)
246 {
247 struct rmblob_data *rmbd = data;
248 int ret = osl(osl_del_row(table, row));
249 if (ret < 0) {
250 para_printf(&rmbd->pb, "%s: %s\n", name, para_strerror(-ret));
251 return ret;
252 }
253 rmbd->num_removed++;
254 return 1;
255 }
256
257 static void com_rmblob_callback(struct osl_table *table, int fd,
258 const struct osl_object *query)
259 {
260 int ret, ret2 = 0;
261 struct rmblob_data rmbd = {
262 .num_removed = 0,
263 .pb = {
264 .max_size = SHMMAX,
265 .private_data = &fd,
266 .max_size_handler = pass_buffer_as_shm
267 }
268 };
269 struct pattern_match_data pmd = {
270 .table = table,
271 .patterns = *query,
272 .loop_col_num = BLOBCOL_NAME,
273 .match_col_num = BLOBCOL_NAME,
274 .pm_flags = PM_SKIP_EMPTY_NAME,
275 .data = &rmbd,
276 .action = remove_blob
277 };
278 ret = for_each_matching_row(&pmd);
279 if (ret < 0) {
280 ret2 = para_printf(&rmbd.pb, "%s\n", para_strerror(-ret));
281 if (ret2 < 0)
282 goto out;
283 }
284 if (!rmbd.num_removed)
285 ret2 = para_printf(&rmbd.pb, "no matches, nothing removed\n");
286 else {
287 ret2 = para_printf(&rmbd.pb, "removed %d blobs\n", rmbd.num_removed);
288 afs_event(BLOB_RENAME, NULL, table);
289 }
290 out:
291 if (ret2 >= 0 && rmbd.pb.offset)
292 pass_buffer_as_shm(rmbd.pb.buf, rmbd.pb.offset, &fd);
293 free(rmbd.pb.buf);
294 }
295
296 static int com_rmblob(callback_function *f, struct stream_cipher_context *scc, int argc,
297 char * const * const argv)
298 {
299 if (argc < 2)
300 return -E_MOOD_SYNTAX;
301 return send_option_arg_callback_request(NULL, argc - 1, argv + 1, f,
302 sc_send_result, scc);
303 }
304
305 static void com_addblob_callback(struct osl_table *table, __a_unused int fd,
306 const struct osl_object *query)
307 {
308 struct osl_object objs[NUM_BLOB_COLUMNS];
309 char *name = query->data;
310 size_t name_len = strlen(name) + 1;
311 uint32_t id;
312 unsigned num_rows;
313 int ret;
314
315 ret = osl(osl_get_num_rows(table, &num_rows));
316 if (ret < 0)
317 goto out;
318 if (!num_rows) { /* this is the first entry ever added */
319 /* insert dummy row containing the id */
320 id = 2; /* this entry will be entry #1, so 2 is the next */
321 objs[BLOBCOL_ID].data = &id;
322 objs[BLOBCOL_ID].size = sizeof(id);
323 objs[BLOBCOL_NAME].data = "";
324 objs[BLOBCOL_NAME].size = 1;
325 objs[BLOBCOL_DEF].data = "";
326 objs[BLOBCOL_DEF].size = 1;
327 ret = osl(osl_add_row(table, objs));
328 if (ret < 0)
329 goto out;
330 } else {
331 /* check if name already exists */
332 struct osl_row *row;
333 struct osl_object obj = {.data = name, .size = name_len};
334 ret = osl(osl_get_row(table, BLOBCOL_NAME, &obj, &row));
335 if (ret < 0 && ret != -OSL_ERRNO_TO_PARA_ERROR(E_OSL_RB_KEY_NOT_FOUND))
336 goto out;
337 if (ret >= 0) { /* we already have a blob with this name */
338 obj.data = name + name_len;
339 obj.size = query->size - name_len;
340 ret = osl(osl_update_object(table, row, BLOBCOL_DEF, &obj));
341 goto out;
342 }
343 /* new blob, get id of the dummy row and increment it */
344 obj.data = "";
345 obj.size = 1;
346 ret = osl(osl_get_row(table, BLOBCOL_NAME, &obj, &row));
347 if (ret < 0)
348 goto out;
349 ret = osl(osl_get_object(table, row, BLOBCOL_ID, &obj));
350 if (ret < 0)
351 goto out;
352 id = *(uint32_t *)obj.data + 1;
353 obj.data = &id;
354 ret = osl(osl_update_object(table, row, BLOBCOL_ID, &obj));
355 if (ret < 0)
356 goto out;
357 }
358 id--;
359 objs[BLOBCOL_ID].data = &id;
360 objs[BLOBCOL_ID].size = sizeof(id);
361 objs[BLOBCOL_NAME].data = name;
362 objs[BLOBCOL_NAME].size = name_len;
363 objs[BLOBCOL_DEF].data = name + name_len;
364 objs[BLOBCOL_DEF].size = query->size - name_len;
365 ret = osl(osl_add_row(table, objs));
366 if (ret < 0)
367 goto out;
368 afs_event(BLOB_ADD, NULL, table);
369 out:
370 if (ret < 0)
371 PARA_NOTICE_LOG("%s\n", para_strerror(-ret));
372 }
373
374 /*
375 * write input from fd to dynamically allocated buffer,
376 * but maximal max_size byte.
377 */
378 static int fd2buf(struct stream_cipher_context *scc, unsigned max_size, struct osl_object *obj)
379 {
380 const size_t chunk_size = 1024;
381 size_t size = 2048, received = 0;
382 int ret;
383 char *buf = para_malloc(size);
384
385 for (;;) {
386 ret = sc_recv_bin_buffer(scc, buf + received, chunk_size);
387 if (ret <= 0)
388 break;
389 received += ret;
390 if (received + chunk_size >= size) {
391 size *= 2;
392 ret = -E_INPUT_TOO_LARGE;
393 if (size > max_size)
394 break;
395 buf = para_realloc(buf, size);
396 }
397 }
398 obj->data = buf;
399 obj->size = received;
400 if (ret < 0)
401 free(buf);
402 return ret;
403 }
404
405 /*
406 * Read data from a file descriptor, and send it to the afs process.
407 *
408 * \param scc crypt context containing the file descriptor to read data from.
409 * \param arg_obj Pointer to the arguments to \a f.
410 * \param f The callback function.
411 * \param max_len Don't read more than that many bytes from stdin.
412 * \param result_handler See \ref send_callback_request.
413 * \param private_result_data See \ref send_callback_request.
414 *
415 * This function is used by commands that wish to let para_server store
416 * arbitrary data specified by the user (for instance the add_blob family of
417 * commands). First, at most \a max_len bytes are read and decrypted from the
418 * file descriptor given by \a scc. The result is concatenated with the buffer
419 * given by \a arg_obj, and the combined buffer is made available to the afs
420 * process via the callback method. See \ref send_callback_request for details.
421 *
422 * \return Negative on errors, the return value of the underlying call to
423 * send_callback_request() otherwise.
424 */
425 static int stdin_command(struct stream_cipher_context *scc, struct osl_object *arg_obj,
426 callback_function *f, unsigned max_len,
427 callback_result_handler *result_handler,
428 void *private_result_data)
429 {
430 struct osl_object query, stdin_obj;
431 int ret;
432
433 ret = sc_send_buffer(scc, AWAITING_DATA_MSG);
434 if (ret < 0)
435 return ret;
436 ret = fd2buf(scc, max_len, &stdin_obj);
437 if (ret < 0)
438 return ret;
439 query.size = arg_obj->size + stdin_obj.size;
440 query.data = para_malloc(query.size);
441 memcpy(query.data, arg_obj->data, arg_obj->size);
442 memcpy((char *)query.data + arg_obj->size, stdin_obj.data, stdin_obj.size);
443 free(stdin_obj.data);
444 ret = send_callback_request(f, &query, result_handler, private_result_data);
445 free(query.data);
446 return ret;
447 }
448
449 static int com_addblob(callback_function *f, struct stream_cipher_context *scc, int argc,
450 char * const * const argv)
451 {
452 struct osl_object arg_obj;
453
454 if (argc != 2)
455 return -E_BLOB_SYNTAX;
456 if (!*argv[1]) /* empty name is reserved for the dummy row */
457 return -E_BLOB_SYNTAX;
458 arg_obj.size = strlen(argv[1]) + 1;
459 arg_obj.data = (char *)argv[1];
460 return stdin_command(scc, &arg_obj, f, 10 * 1024 * 1024, NULL, NULL);
461 }
462
463 /* FIXME: Print output to client, not to log file */
464 static void com_mvblob_callback(struct osl_table *table, __a_unused int fd,
465 const struct osl_object *query)
466 {
467 char *src = (char *) query->data;
468 struct osl_object obj = {.data = src, .size = strlen(src) + 1};
469 char *dest = src + obj.size;
470 struct osl_row *row;
471 int ret = osl(osl_get_row(table, BLOBCOL_NAME, &obj, &row));
472
473 if (ret < 0)
474 goto out;
475 obj.data = dest;
476 obj.size = strlen(dest) + 1;
477 ret = osl(osl_update_object(table, row, BLOBCOL_NAME, &obj));
478 if (ret < 0)
479 goto out;
480 afs_event(BLOB_RENAME, NULL, table);
481 out:
482 if (ret < 0)
483 PARA_NOTICE_LOG("%s\n", para_strerror(-ret));
484 }
485
486 static int com_mvblob(callback_function *f, __a_unused struct stream_cipher_context *scc,
487 int argc, char * const * const argv)
488 {
489 if (argc != 3)
490 return -E_MOOD_SYNTAX;
491 return send_option_arg_callback_request(NULL, argc - 1, argv + 1, f,
492 NULL, NULL);
493 }
494
495 #define DEFINE_BLOB_COMMAND(cmd_name, table_name, cmd_prefix) \
496 static void com_ ## cmd_name ## cmd_prefix ## _callback(int fd, const struct osl_object *query) \
497 { \
498 return com_ ## cmd_name ## blob_callback(table_name ## _table, fd, query); \
499 } \
500 int com_ ## cmd_name ## cmd_prefix(struct stream_cipher_context *scc, int argc, char * const * const argv) \
501 { \
502 return com_ ## cmd_name ## blob(com_ ## cmd_name ## cmd_prefix ## _callback, scc, argc, argv); \
503 }
504
505 static int blob_get_name_by_id(struct osl_table *table, uint32_t id,
506 char **name)
507 {
508 struct osl_row *row;
509 struct osl_object obj = {.data = &id, .size = sizeof(id)};
510 int ret;
511
512 *name = NULL;
513 if (!id)
514 return 1;
515 ret = osl(osl_get_row(table, BLOBCOL_ID, &obj, &row));
516 if (ret < 0)
517 return ret;
518 ret = osl(osl_get_object(table, row, BLOBCOL_NAME, &obj));
519 if (ret < 0)
520 return ret;
521 *name = (char *)obj.data;
522 return 1;
523 }
524
525 /** Define the \p get_name_by_id function for this blob type. */
526 #define DEFINE_GET_NAME_BY_ID(table_name, cmd_prefix) \
527 int cmd_prefix ## _get_name_by_id(uint32_t id, char **name) \
528 { \
529 return blob_get_name_by_id(table_name ## _table, id, name); \
530 }
531
532
533 static int blob_get_def_by_name(struct osl_table *table, char *name,
534 struct osl_object *def)
535 {
536 struct osl_row *row;
537 struct osl_object obj = {.data = name, .size = strlen(name) + 1};
538 int ret;
539
540 def->data = NULL;
541 if (!*name)
542 return 1;
543 ret = osl(osl_get_row(table, BLOBCOL_NAME, &obj, &row));
544 if (ret < 0)
545 return ret;
546 return osl(osl_open_disk_object(table, row, BLOBCOL_DEF, def));
547 }
548
549 /** Define the \p get_def_by_id function for this blob type. */
550 #define DEFINE_GET_DEF_BY_NAME(table_name, cmd_prefix) \
551 int cmd_prefix ## _get_def_by_name(char *name, struct osl_object *def) \
552 { \
553 return blob_get_def_by_name(table_name ## _table, name, def); \
554 }
555
556 static int blob_get_def_by_id(struct osl_table *table, uint32_t id,
557 struct osl_object *def)
558 {
559 struct osl_row *row;
560 struct osl_object obj = {.data = &id, .size = sizeof(id)};
561 int ret;
562
563 def->data = NULL;
564 if (!id)
565 return 1;
566 ret = osl(osl_get_row(table, BLOBCOL_ID, &obj, &row));
567 if (ret < 0)
568 return ret;
569 return osl(osl_open_disk_object(table, row, BLOBCOL_DEF, def));
570 }
571
572 /** Define the \p get_def_by_id function for this blob type. */
573 #define DEFINE_GET_DEF_BY_ID(table_name, cmd_prefix) \
574 int cmd_prefix ## _get_def_by_id(uint32_t id, struct osl_object *def) \
575 { \
576 return blob_get_def_by_id(table_name ## _table, id, def); \
577 }
578
579 static int blob_get_name_and_def_by_row(struct osl_table *table,
580 const struct osl_row *row, char **name, struct osl_object *def)
581 {
582 struct osl_object obj;
583 int ret = osl(osl_get_object(table, row, BLOBCOL_NAME, &obj));
584 if (ret < 0)
585 return ret;
586 *name = obj.data;
587 return osl(osl_open_disk_object(table, row, BLOBCOL_DEF, def));
588 }
589 /** Define the \p get_name_and_def_by_row function for this blob type. */
590 #define DEFINE_GET_NAME_AND_DEF_BY_ROW(table_name, cmd_prefix) \
591 int cmd_prefix ## _get_name_and_def_by_row(const struct osl_row *row, \
592 char **name, struct osl_object *def) \
593 { \
594 return blob_get_name_and_def_by_row(table_name ## _table, \
595 row, name, def); \
596 }
597
598 /** Define the \p close function for this blob type. */
599 #define DEFINE_BLOB_CLOSE(table_name) \
600 static void table_name ## _close(void) \
601 { \
602 osl_close_table(table_name ## _table, OSL_MARK_CLEAN); \
603 table_name ## _table = NULL; \
604 }
605
606 /** Define the \p create function for this blob type. */
607 #define DEFINE_BLOB_CREATE(table_name) \
608 static int table_name ## _create(const char *dir) \
609 { \
610 table_name ## _table_desc.dir = dir; \
611 return osl_create_table(&table_name ## _table_desc); \
612 }
613
614 static int blob_open(struct osl_table **table,
615 struct osl_table_description *desc,
616 const char *dir)
617 {
618 int ret;
619 desc->dir = dir;
620 ret = osl(osl_open_table(desc, table));
621 if (ret >= 0)
622 return ret;
623 *table = NULL;
624 if (ret >= 0 || ret == -OSL_ERRNO_TO_PARA_ERROR(E_OSL_NOENT))
625 return 1;
626 return ret;
627 }
628
629 #define DEFINE_BLOB_OPEN(table_name) \
630 static int table_name ## _open(const char *dir) \
631 { \
632 return blob_open(&table_name ## _table, \
633 &table_name ## _table_desc, dir); \
634 }
635
636
637 /** Define the \p init function for this blob type. */
638 #define DEFINE_BLOB_INIT(table_name) \
639 void table_name ## _init(struct afs_table *t) \
640 { \
641 t->open = table_name ## _open; \
642 t->close = table_name ## _close; \
643 t->create = table_name ## _create;\
644 t->event_handler = table_name ##_event_handler; \
645 table_name ## _table = NULL; \
646 }
647
648
649 /** Define all functions for this blob type. */
650 #define DEFINE_BLOB_FUNCTIONS(table_name, cmd_prefix) \
651 DEFINE_BLOB_OPEN(table_name) \
652 DEFINE_BLOB_CLOSE(table_name) \
653 DEFINE_BLOB_CREATE(table_name) \
654 DEFINE_BLOB_INIT(table_name) \
655 DEFINE_BLOB_COMMAND(ls, table_name, cmd_prefix) \
656 DEFINE_BLOB_COMMAND(cat, table_name, cmd_prefix) \
657 DEFINE_BLOB_COMMAND(add, table_name, cmd_prefix) \
658 DEFINE_BLOB_COMMAND(rm, table_name, cmd_prefix) \
659 DEFINE_BLOB_COMMAND(mv, table_name, cmd_prefix) \
660 DEFINE_GET_NAME_BY_ID(table_name, cmd_prefix); \
661 DEFINE_GET_DEF_BY_ID(table_name, cmd_prefix); \
662 DEFINE_GET_DEF_BY_NAME(table_name, cmd_prefix); \
663 DEFINE_GET_NAME_AND_DEF_BY_ROW(table_name, cmd_prefix); \
664
665 /** \cond doxygen isn't smart enough to recognize these */
666 DEFINE_BLOB_FUNCTIONS(lyrics, lyr);
667 DEFINE_BLOB_FUNCTIONS(images, img);
668 DEFINE_BLOB_FUNCTIONS(moods, mood);
669 DEFINE_BLOB_FUNCTIONS(playlists, pl);
670 /** \endcond */