diff options
Diffstat (limited to 'data.c')
| -rw-r--r-- | data.c | 33 |
1 files changed, 33 insertions, 0 deletions
| @@ -1366,6 +1366,39 @@ void static_put(snac *snac, const char *id, const char *data, int size) | |||
| 1366 | } | 1366 | } |
| 1367 | 1367 | ||
| 1368 | 1368 | ||
| 1369 | void status_put_meta(snac *snac, const char *id, const char *str) | ||
| 1370 | /* puts metadata (i.e. a media description string) to id */ | ||
| 1371 | { | ||
| 1372 | xs *fn = _static_fn(snac, id); | ||
| 1373 | fn = xs_str_cat(fn, ".txt"); | ||
| 1374 | FILE *f; | ||
| 1375 | |||
| 1376 | if ((f = fopen(fn, "w")) != NULL) { | ||
| 1377 | fprintf(f, "%s\n", str); | ||
| 1378 | fclose(f); | ||
| 1379 | } | ||
| 1380 | } | ||
| 1381 | |||
| 1382 | |||
| 1383 | xs_str *status_get_meta(snac *snac, const char *id) | ||
| 1384 | /* gets metadata from a media */ | ||
| 1385 | { | ||
| 1386 | xs *fn = _static_fn(snac, id); | ||
| 1387 | fn = xs_str_cat(fn, ".txt"); | ||
| 1388 | xs_str *r = NULL; | ||
| 1389 | FILE *f; | ||
| 1390 | |||
| 1391 | if ((f = fopen(fn, "r")) != NULL) { | ||
| 1392 | r = xs_strip_i(xs_readline(f)); | ||
| 1393 | fclose(f); | ||
| 1394 | } | ||
| 1395 | else | ||
| 1396 | r = xs_str_new(""); | ||
| 1397 | |||
| 1398 | return r; | ||
| 1399 | } | ||
| 1400 | |||
| 1401 | |||
| 1369 | d_char *_history_fn(snac *snac, char *id) | 1402 | d_char *_history_fn(snac *snac, char *id) |
| 1370 | /* gets the filename for the history */ | 1403 | /* gets the filename for the history */ |
| 1371 | { | 1404 | { |