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