diff options
| author | 2022-10-16 18:03:28 +0200 | |
|---|---|---|
| committer | 2022-10-16 18:03:28 +0200 | |
| commit | d9a15b8af7da2bc27d4d55ee745242f5b4e39071 (patch) | |
| tree | f890fe2b2f0a327f08da31404fd267c675fac690 /data.c | |
| parent | Use multipart/form-data for posts (on the way to supporting uploads). (diff) | |
| download | snac2-d9a15b8af7da2bc27d4d55ee745242f5b4e39071.tar.gz snac2-d9a15b8af7da2bc27d4d55ee745242f5b4e39071.tar.xz snac2-d9a15b8af7da2bc27d4d55ee745242f5b4e39071.zip | |
Attachments are now starting to get real.
Diffstat (limited to 'data.c')
| -rw-r--r-- | data.c | 17 |
1 files changed, 15 insertions, 2 deletions
| @@ -805,14 +805,14 @@ int actor_get(snac *snac, char *actor, d_char **data) | |||
| 805 | } | 805 | } |
| 806 | 806 | ||
| 807 | 807 | ||
| 808 | d_char *_static_fn(snac *snac, char *id) | 808 | d_char *_static_fn(snac *snac, const char *id) |
| 809 | /* gets the filename for a static file */ | 809 | /* gets the filename for a static file */ |
| 810 | { | 810 | { |
| 811 | return xs_fmt("%s/static/%s", snac->basedir, id); | 811 | return xs_fmt("%s/static/%s", snac->basedir, id); |
| 812 | } | 812 | } |
| 813 | 813 | ||
| 814 | 814 | ||
| 815 | int static_get(snac *snac, char *id, d_char **data, int *size) | 815 | int static_get(snac *snac, const char *id, d_char **data, int *size) |
| 816 | /* returns static content */ | 816 | /* returns static content */ |
| 817 | { | 817 | { |
| 818 | xs *fn = _static_fn(snac, id); | 818 | xs *fn = _static_fn(snac, id); |
| @@ -830,6 +830,19 @@ int static_get(snac *snac, char *id, d_char **data, int *size) | |||
| 830 | } | 830 | } |
| 831 | 831 | ||
| 832 | 832 | ||
| 833 | void static_put(snac *snac, const char *id, const char *data, int size) | ||
| 834 | /* writes status content */ | ||
| 835 | { | ||
| 836 | xs *fn = _static_fn(snac, id); | ||
| 837 | FILE *f; | ||
| 838 | |||
| 839 | if ((f = fopen(fn, "wb")) != NULL) { | ||
| 840 | fwrite(data, size, 1, f); | ||
| 841 | fclose(f); | ||
| 842 | } | ||
| 843 | } | ||
| 844 | |||
| 845 | |||
| 833 | d_char *_history_fn(snac *snac, char *id) | 846 | d_char *_history_fn(snac *snac, char *id) |
| 834 | /* gets the filename for the history */ | 847 | /* gets the filename for the history */ |
| 835 | { | 848 | { |