diff options
Diffstat (limited to 'data.c')
| -rw-r--r-- | data.c | 25 |
1 files changed, 25 insertions, 0 deletions
| @@ -801,6 +801,31 @@ int actor_get(snac *snac, char *actor, d_char **data) | |||
| 801 | } | 801 | } |
| 802 | 802 | ||
| 803 | 803 | ||
| 804 | d_char *_static_fn(snac *snac, char *id) | ||
| 805 | /* gets the filename for a static file */ | ||
| 806 | { | ||
| 807 | return xs_fmt("%s/static/%s", snac->basedir, id); | ||
| 808 | } | ||
| 809 | |||
| 810 | |||
| 811 | int static_get(snac *snac, char *id, d_char **data, int *size) | ||
| 812 | /* returns static content */ | ||
| 813 | { | ||
| 814 | xs *fn = _static_fn(snac, id); | ||
| 815 | FILE *f; | ||
| 816 | int status = 404; | ||
| 817 | |||
| 818 | *size = 0xfffffff; | ||
| 819 | |||
| 820 | if ((f = fopen(fn, "rb")) != NULL) { | ||
| 821 | *data = xs_read(f, size); | ||
| 822 | status = 200; | ||
| 823 | } | ||
| 824 | |||
| 825 | return status; | ||
| 826 | } | ||
| 827 | |||
| 828 | |||
| 804 | void enqueue_input(snac *snac, char *msg, char *req) | 829 | void enqueue_input(snac *snac, char *msg, char *req) |
| 805 | /* enqueues an input message */ | 830 | /* enqueues an input message */ |
| 806 | { | 831 | { |