Remove ->init() of struct receiver.
[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 para_printf(&aca->pbout, "cannot list %s\n", name);
104 return ret;
105 }
106 id = *(uint32_t *)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 para_printf(&aca->pbout, "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;
270 unsigned num_rows;
271 int ret;
272
273 ret = osl(osl_get_num_rows(table, &num_rows));
274 if (ret < 0)
275 goto out;
276 if (!num_rows) { /* this is the first entry ever added */
277 /* insert dummy row containing the id */
278 id = 2; /* this entry will be entry #1, so 2 is the next */
279 objs[BLOBCOL_ID].data = &id;
280 objs[BLOBCOL_ID].size = sizeof(id);
281 objs[BLOBCOL_NAME].data = "";
282 objs[BLOBCOL_NAME].size = 1;
283 objs[BLOBCOL_DEF].data = "";
284 objs[BLOBCOL_DEF].size = 1;
285 ret = osl(osl_add_row(table, objs));
286 if (ret < 0)
287 goto out;
288 } else {
289 /* check if name already exists */
290 struct osl_row *row;
291 struct osl_object obj = {.data = name, .size = name_len};
292 ret = osl(osl_get_row(table, BLOBCOL_NAME, &obj, &row));
293 if (ret < 0 && ret != -OSL_ERRNO_TO_PARA_ERROR(E_OSL_RB_KEY_NOT_FOUND))
294 goto out;
295 if (ret >= 0) { /* we already have a blob with this name */
296 ret = osl(osl_get_object(table, row, BLOBCOL_ID, &obj));
297 if (ret < 0)
298 goto out;
299 id = *(uint32_t *)obj.data;
300 obj.data = name + name_len;
301 obj.size = aca->query.size - name_len;
302 ret = osl(osl_update_object(table, row, BLOBCOL_DEF, &obj));
303 goto out;
304 }
305 /* new blob, get id of the dummy row and increment it */
306 obj.data = "";
307 obj.size = 1;
308 ret = osl(osl_get_row(table, BLOBCOL_NAME, &obj, &row));
309 if (ret < 0)
310 goto out;
311 ret = osl(osl_get_object(table, row, BLOBCOL_ID, &obj));
312 if (ret < 0)
313 goto out;
314 id = *(uint32_t *)obj.data + 1;
315 obj.data = &id;
316 ret = osl(osl_update_object(table, row, BLOBCOL_ID, &obj));
317 if (ret < 0)
318 goto out;
319 }
320 id--;
321 objs[BLOBCOL_ID].data = &id;
322 objs[BLOBCOL_ID].size = sizeof(id);
323 objs[BLOBCOL_NAME].data = name;
324 objs[BLOBCOL_NAME].size = name_len;
325 objs[BLOBCOL_DEF].data = name + name_len;
326 objs[BLOBCOL_DEF].size = aca->query.size - name_len;
327 ret = osl(osl_add_row(table, objs));
328 if (ret < 0)
329 goto out;
330 ret = afs_event(BLOB_ADD, NULL, table);
331 out:
332 if (ret < 0)
333 para_printf(&aca->pbout, "cannot add %s\n", name);
334 else
335 para_printf(&aca->pbout, "added %s as id %u\n", name, id);
336 return ret;
337 }
338
339 /* Write input from fd to dynamically allocated buffer, but maximal 10M. */
340 static int fd2buf(struct stream_cipher_context *scc, struct osl_object *obj)
341 {
342 size_t max_size = 10 * 1024 * 1024;
343 int ret;
344 struct iovec iov;
345
346 obj->data = NULL;
347 obj->size = 0;
348 again:
349 do {
350 ret = recv_sb(scc, SBD_BLOB_DATA, max_size, &iov);
351 } while (ret == 0);
352
353 if (ret < 0) {
354 free(obj->data);
355 obj->data = NULL;
356 obj->size = 0;
357 return ret;
358 }
359 if (iov.iov_len == 0) /* end of blob */
360 return 1;
361 if (!obj->data) {
362 obj->data = iov.iov_base;
363 obj->size = iov.iov_len;
364 } else {
365 obj->data = para_realloc(obj->data, obj->size + iov.iov_len);
366 memcpy(obj->data + obj->size, iov.iov_base, iov.iov_len);
367 obj->size += iov.iov_len;
368 free(iov.iov_base);
369 max_size -= iov.iov_len;
370 }
371 goto again;
372 return 1;
373 }
374
375 /*
376 * Read blob from a file descriptor and send it to afs.
377 *
378 * This function is called from the addblob command handlers to instruct the
379 * afs process to store the input in a blob table. Input is read and decrypted
380 * from the file descriptor given by cc and appended to a buffer which also contains
381 * the name of the blob to create. The combined buffer is made available to the
382 * afs process via the callback method.
383 */
384 static int stdin_command(struct command_context *cc,
385 struct lls_parse_result *lpr, afs_callback *f)
386 {
387 struct osl_object query, stdin_obj;
388 int ret;
389 size_t len = strlen(lls_input(0, lpr));
390
391 ret = send_sb(&cc->scc, NULL, 0, SBD_AWAITING_DATA, false);
392 if (ret < 0)
393 return ret;
394 ret = fd2buf(&cc->scc, &stdin_obj);
395 if (ret < 0)
396 return ret;
397 query.size = len + 1 + stdin_obj.size;
398 query.data = para_malloc(query.size);
399 memcpy(query.data, lls_input(0, lpr), len + 1);
400 if (stdin_obj.size > 0)
401 memcpy((char *)query.data + len + 1, stdin_obj.data,
402 stdin_obj.size);
403 free(stdin_obj.data);
404 ret = send_callback_request(f, &query, afs_cb_result_handler, cc);
405 free(query.data);
406 return ret;
407 }
408
409 static int com_addblob(afs_callback *f, __a_unused const struct lls_command * const cmd,
410 struct command_context *cc, struct lls_parse_result *lpr)
411 {
412 char *errctx;
413 int ret = lls(lls_check_arg_count(lpr, 1, 1, &errctx));
414
415 if (ret < 0) {
416 send_errctx(cc, errctx);
417 return ret;
418 }
419 if (!lls_input(0, lpr)[0]) /* empty name is reserved for the dummy row */
420 return -E_BLOB_SYNTAX;
421 return stdin_command(cc, lpr, f);
422 }
423
424 static int com_mvblob_callback(const struct lls_command * const cmd,
425 struct osl_table *table, struct afs_callback_arg *aca)
426 {
427 const char *src, *dest;
428 struct osl_object obj;
429 struct osl_row *row;
430 int ret;
431
432 ret = lls_deserialize_parse_result(aca->query.data, cmd, &aca->lpr);
433 assert(ret >= 0);
434 src = lls_input(0, aca->lpr);
435 dest = lls_input(1, aca->lpr);
436 obj.data = (char *)src;
437 obj.size = strlen(src) + 1;
438 ret = osl(osl_get_row(table, BLOBCOL_NAME, &obj, &row));
439
440 if (ret < 0) {
441 para_printf(&aca->pbout, "cannot find source blob %s\n", src);
442 goto out;
443 }
444 obj.data = (char *)dest;
445 obj.size = strlen(dest) + 1;
446 ret = osl(osl_update_object(table, row, BLOBCOL_NAME, &obj));
447 if (ret < 0) {
448 para_printf(&aca->pbout, "cannot rename blob %s to %s\n",
449 src, dest);
450 goto out;
451 }
452 ret = afs_event(BLOB_RENAME, NULL, table);
453 out:
454 lls_free_parse_result(aca->lpr, cmd);
455 return ret;
456 }
457
458 static int com_mvblob(afs_callback *f, const struct lls_command * const cmd,
459 struct command_context *cc, struct lls_parse_result *lpr)
460 {
461 char *errctx;
462 int ret = lls(lls_check_arg_count(lpr, 2, 2, &errctx));
463
464 if (ret < 0) {
465 send_errctx(cc, errctx);
466 return ret;
467 }
468 return send_lls_callback_request(f, cmd, lpr, cc);
469 }
470
471 #define DEFINE_BLOB_COMMAND(cmd_name, c_cmd_name, table_name, short_name, c_short_name) \
472 static int com_ ## cmd_name ## short_name ## _callback(struct afs_callback_arg *aca) \
473 { \
474 const struct lls_command *cmd = SERVER_CMD_CMD_PTR(c_cmd_name ## c_short_name); \
475 return com_ ## cmd_name ## blob_callback(cmd, table_name ## _table, aca); \
476 } \
477 static int com_ ## cmd_name ## short_name(struct command_context *cc, struct lls_parse_result *lpr) \
478 { \
479 const struct lls_command *cmd = SERVER_CMD_CMD_PTR(c_cmd_name ## c_short_name); \
480 return com_ ## cmd_name ## blob(com_ ## cmd_name ## short_name ## _callback, cmd, cc, lpr); \
481 } \
482 EXPORT_SERVER_CMD_HANDLER(cmd_name ## short_name);
483
484 static int blob_get_name_by_id(struct osl_table *table, uint32_t id,
485 char **name)
486 {
487 struct osl_row *row;
488 struct osl_object obj = {.data = &id, .size = sizeof(id)};
489 int ret;
490
491 if (name)
492 *name = NULL;
493 if (!id)
494 return 1;
495 ret = osl(osl_get_row(table, BLOBCOL_ID, &obj, &row));
496 if (ret < 0)
497 return ret;
498 ret = osl(osl_get_object(table, row, BLOBCOL_NAME, &obj));
499 if (ret < 0)
500 return ret;
501 if (*(char *)obj.data == '\0')
502 return -E_DUMMY_ROW;
503 if (name)
504 *name = (char *)obj.data;
505 return 1;
506 }
507
508 /** Define the \p get_name_by_id function for this blob type. */
509 #define DEFINE_GET_NAME_BY_ID(table_name, cmd_prefix) \
510 int cmd_prefix ## _get_name_by_id(uint32_t id, char **name) \
511 { \
512 return blob_get_name_by_id(table_name ## _table, id, name); \
513 }
514
515 static int blob_get_def_by_name(struct osl_table *table, char *name,
516 struct osl_object *def)
517 {
518 struct osl_row *row;
519 struct osl_object obj = {.data = name, .size = strlen(name) + 1};
520 int ret;
521
522 def->data = NULL;
523 if (!*name)
524 return 1;
525 ret = osl(osl_get_row(table, BLOBCOL_NAME, &obj, &row));
526 if (ret < 0)
527 return ret;
528 return osl(osl_open_disk_object(table, row, BLOBCOL_DEF, def));
529 }
530
531 /** Define the \p get_def_by_id function for this blob type. */
532 #define DEFINE_GET_DEF_BY_NAME(table_name, cmd_prefix) \
533 int cmd_prefix ## _get_def_by_name(char *name, struct osl_object *def) \
534 { \
535 return blob_get_def_by_name(table_name ## _table, name, def); \
536 }
537
538 static int blob_get_def_by_id(struct osl_table *table, uint32_t id,
539 struct osl_object *def)
540 {
541 struct osl_row *row;
542 struct osl_object obj = {.data = &id, .size = sizeof(id)};
543 int ret;
544
545 def->data = NULL;
546 if (!id)
547 return 1;
548 ret = osl(osl_get_row(table, BLOBCOL_ID, &obj, &row));
549 if (ret < 0)
550 return ret;
551 return osl(osl_open_disk_object(table, row, BLOBCOL_DEF, def));
552 }
553
554 /** Define the \p get_def_by_id function for this blob type. */
555 #define DEFINE_GET_DEF_BY_ID(table_name, cmd_prefix) \
556 int cmd_prefix ## _get_def_by_id(uint32_t id, struct osl_object *def) \
557 { \
558 return blob_get_def_by_id(table_name ## _table, id, def); \
559 }
560
561 static int blob_get_name_and_def_by_row(struct osl_table *table,
562 const struct osl_row *row, char **name, struct osl_object *def)
563 {
564 struct osl_object obj;
565 int ret = osl(osl_get_object(table, row, BLOBCOL_NAME, &obj));
566
567 if (ret < 0)
568 return ret;
569 *name = obj.data;
570 return osl(osl_open_disk_object(table, row, BLOBCOL_DEF, def));
571 }
572 /** Define the \p get_name_and_def_by_row function for this blob type. */
573 #define DEFINE_GET_NAME_AND_DEF_BY_ROW(table_name, cmd_prefix) \
574 int cmd_prefix ## _get_name_and_def_by_row(const struct osl_row *row, \
575 char **name, struct osl_object *def) \
576 { \
577 return blob_get_name_and_def_by_row(table_name ## _table, \
578 row, name, def); \
579 }
580
581 /** Define the \p close function for this blob type. */
582 #define DEFINE_BLOB_CLOSE(table_name) \
583 static void table_name ## _close(void) \
584 { \
585 osl_close_table(table_name ## _table, OSL_MARK_CLEAN); \
586 table_name ## _table = NULL; \
587 }
588
589 /** Define the \p create function for this blob type. */
590 #define DEFINE_BLOB_CREATE(table_name) \
591 static int table_name ## _create(const char *dir) \
592 { \
593 table_name ## _table_desc.dir = dir; \
594 return osl(osl_create_table(&table_name ## _table_desc)); \
595 }
596
597 static int blob_open(struct osl_table **table,
598 struct osl_table_description *desc,
599 const char *dir)
600 {
601 int ret;
602
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 static 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->open = table_name ## _open; \
626 t->close = table_name ## _close; \
627 t->create = table_name ## _create;\
628 t->event_handler = table_name ##_event_handler; \
629 table_name ## _table = NULL; \
630 }
631
632
633 /** Define all functions for this blob type. */
634 #define DEFINE_BLOB_FUNCTIONS(table_name, short_name, c_short_name) \
635 DEFINE_BLOB_OPEN(table_name) \
636 DEFINE_BLOB_CLOSE(table_name) \
637 DEFINE_BLOB_CREATE(table_name) \
638 DEFINE_BLOB_INIT(table_name) \
639 DEFINE_BLOB_COMMAND(ls, LS, table_name, short_name, c_short_name) \
640 DEFINE_BLOB_COMMAND(cat, CAT, table_name, short_name, c_short_name) \
641 DEFINE_BLOB_COMMAND(add, ADD, table_name, short_name, c_short_name) \
642 DEFINE_BLOB_COMMAND(rm, RM, table_name, short_name, c_short_name) \
643 DEFINE_BLOB_COMMAND(mv, MV, table_name, short_name, c_short_name) \
644 DEFINE_GET_NAME_BY_ID(table_name, short_name); \
645 DEFINE_GET_DEF_BY_ID(table_name, short_name); \
646 DEFINE_GET_DEF_BY_NAME(table_name, short_name); \
647 DEFINE_GET_NAME_AND_DEF_BY_ROW(table_name, short_name); \
648
649 /* doxygen isn't smart enough to recognize these */
650 /** \cond blob_function */
651 DEFINE_BLOB_FUNCTIONS(lyrics, lyr, LYR);
652 DEFINE_BLOB_FUNCTIONS(images, img, IMG);
653 DEFINE_BLOB_FUNCTIONS(moods, mood, MOOD);
654 DEFINE_BLOB_FUNCTIONS(playlists, pl, PL);
655 /** \endcond blob_function */