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