mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 22:45:05 +00:00
New functions to get and set metadata into static files.
This commit is contained in:
parent
73e7195e6c
commit
8c4850df50
2 changed files with 35 additions and 0 deletions
33
data.c
33
data.c
|
@ -1366,6 +1366,39 @@ void static_put(snac *snac, const char *id, const char *data, int size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void status_put_meta(snac *snac, const char *id, const char *str)
|
||||||
|
/* puts metadata (i.e. a media description string) to id */
|
||||||
|
{
|
||||||
|
xs *fn = _static_fn(snac, id);
|
||||||
|
fn = xs_str_cat(fn, ".txt");
|
||||||
|
FILE *f;
|
||||||
|
|
||||||
|
if ((f = fopen(fn, "w")) != NULL) {
|
||||||
|
fprintf(f, "%s\n", str);
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
xs_str *status_get_meta(snac *snac, const char *id)
|
||||||
|
/* gets metadata from a media */
|
||||||
|
{
|
||||||
|
xs *fn = _static_fn(snac, id);
|
||||||
|
fn = xs_str_cat(fn, ".txt");
|
||||||
|
xs_str *r = NULL;
|
||||||
|
FILE *f;
|
||||||
|
|
||||||
|
if ((f = fopen(fn, "r")) != NULL) {
|
||||||
|
r = xs_strip_i(xs_readline(f));
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
r = xs_str_new("");
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
d_char *_history_fn(snac *snac, char *id)
|
d_char *_history_fn(snac *snac, char *id)
|
||||||
/* gets the filename for the history */
|
/* gets the filename for the history */
|
||||||
{
|
{
|
||||||
|
|
2
snac.h
2
snac.h
|
@ -130,6 +130,8 @@ int actor_get(snac *snac, const char *actor, d_char **data);
|
||||||
|
|
||||||
int static_get(snac *snac, const char *id, d_char **data, int *size);
|
int static_get(snac *snac, const char *id, d_char **data, int *size);
|
||||||
void static_put(snac *snac, const char *id, const char *data, int size);
|
void static_put(snac *snac, const char *id, const char *data, int size);
|
||||||
|
void status_put_meta(snac *snac, const char *id, const char *str);
|
||||||
|
xs_str *status_get_meta(snac *snac, const char *id);
|
||||||
|
|
||||||
double history_mtime(snac *snac, char *id);
|
double history_mtime(snac *snac, char *id);
|
||||||
void history_add(snac *snac, char *id, char *content, int size);
|
void history_add(snac *snac, char *id, char *content, int size);
|
||||||
|
|
Loading…
Reference in a new issue