diff options
Diffstat (limited to '')
| -rw-r--r-- | Makefile | 6 | ||||
| -rw-r--r-- | Makefile.NetBSD | 6 | ||||
| -rw-r--r-- | main.c | 23 |
3 files changed, 25 insertions, 10 deletions
| @@ -60,10 +60,10 @@ html.o: html.c xs.h xs_io.h xs_json.h xs_regex.h xs_set.h xs_openssl.h \ | |||
| 60 | http.o: http.c xs.h xs_io.h xs_openssl.h xs_curl.h xs_time.h xs_json.h \ | 60 | http.o: http.c xs.h xs_io.h xs_openssl.h xs_curl.h xs_time.h xs_json.h \ |
| 61 | snac.h http_codes.h | 61 | snac.h http_codes.h |
| 62 | httpd.o: httpd.c xs.h xs_io.h xs_json.h xs_socket.h xs_unix_socket.h \ | 62 | httpd.o: httpd.c xs.h xs_io.h xs_json.h xs_socket.h xs_unix_socket.h \ |
| 63 | xs_httpd.h xs_mime.h xs_time.h xs_openssl.h xs_fcgi.h xs_html.h snac.h \ | 63 | xs_httpd.h xs_mime.h xs_time.h xs_openssl.h xs_fcgi.h xs_html.h \ |
| 64 | http_codes.h | 64 | xs_webmention.h snac.h http_codes.h |
| 65 | main.o: main.c xs.h xs_io.h xs_json.h xs_time.h xs_openssl.h xs_match.h \ | 65 | main.o: main.c xs.h xs_io.h xs_json.h xs_time.h xs_openssl.h xs_match.h \ |
| 66 | snac.h http_codes.h | 66 | xs_random.h snac.h http_codes.h |
| 67 | mastoapi.o: mastoapi.c xs.h xs_hex.h xs_openssl.h xs_json.h xs_io.h \ | 67 | mastoapi.o: mastoapi.c xs.h xs_hex.h xs_openssl.h xs_json.h xs_io.h \ |
| 68 | xs_time.h xs_glob.h xs_set.h xs_random.h xs_url.h xs_mime.h xs_match.h \ | 68 | xs_time.h xs_glob.h xs_set.h xs_random.h xs_url.h xs_mime.h xs_match.h \ |
| 69 | xs_unicode.h snac.h http_codes.h | 69 | xs_unicode.h snac.h http_codes.h |
diff --git a/Makefile.NetBSD b/Makefile.NetBSD index d19ab2d..ac5b052 100644 --- a/Makefile.NetBSD +++ b/Makefile.NetBSD | |||
| @@ -49,10 +49,10 @@ html.o: html.c xs.h xs_io.h xs_json.h xs_regex.h xs_set.h xs_openssl.h \ | |||
| 49 | http.o: http.c xs.h xs_io.h xs_openssl.h xs_curl.h xs_time.h xs_json.h \ | 49 | http.o: http.c xs.h xs_io.h xs_openssl.h xs_curl.h xs_time.h xs_json.h \ |
| 50 | snac.h http_codes.h | 50 | snac.h http_codes.h |
| 51 | httpd.o: httpd.c xs.h xs_io.h xs_json.h xs_socket.h xs_unix_socket.h \ | 51 | httpd.o: httpd.c xs.h xs_io.h xs_json.h xs_socket.h xs_unix_socket.h \ |
| 52 | xs_httpd.h xs_mime.h xs_time.h xs_openssl.h xs_fcgi.h xs_html.h snac.h \ | 52 | xs_httpd.h xs_mime.h xs_time.h xs_openssl.h xs_fcgi.h xs_html.h \ |
| 53 | http_codes.h | 53 | xs_webmention.h snac.h http_codes.h |
| 54 | main.o: main.c xs.h xs_io.h xs_json.h xs_time.h xs_openssl.h xs_match.h \ | 54 | main.o: main.c xs.h xs_io.h xs_json.h xs_time.h xs_openssl.h xs_match.h \ |
| 55 | snac.h http_codes.h | 55 | xs_random.h snac.h http_codes.h |
| 56 | mastoapi.o: mastoapi.c xs.h xs_hex.h xs_openssl.h xs_json.h xs_io.h \ | 56 | mastoapi.o: mastoapi.c xs.h xs_hex.h xs_openssl.h xs_json.h xs_io.h \ |
| 57 | xs_time.h xs_glob.h xs_set.h xs_random.h xs_url.h xs_mime.h xs_match.h \ | 57 | xs_time.h xs_glob.h xs_set.h xs_random.h xs_url.h xs_mime.h xs_match.h \ |
| 58 | xs_unicode.h snac.h http_codes.h | 58 | xs_unicode.h snac.h http_codes.h |
| @@ -7,6 +7,7 @@ | |||
| 7 | #include "xs_time.h" | 7 | #include "xs_time.h" |
| 8 | #include "xs_openssl.h" | 8 | #include "xs_openssl.h" |
| 9 | #include "xs_match.h" | 9 | #include "xs_match.h" |
| 10 | #include "xs_random.h" | ||
| 10 | 11 | ||
| 11 | #include "snac.h" | 12 | #include "snac.h" |
| 12 | 13 | ||
| @@ -779,12 +780,24 @@ int main(int argc, char *argv[]) | |||
| 779 | xs *msg = NULL; | 780 | xs *msg = NULL; |
| 780 | xs *c_msg = NULL; | 781 | xs *c_msg = NULL; |
| 781 | xs *attl = xs_list_new(); | 782 | xs *attl = xs_list_new(); |
| 782 | char *fn = NULL; | 783 | const char *fn = NULL; |
| 784 | const char *in_reply_to = NULL; | ||
| 785 | const char **next = NULL; | ||
| 783 | 786 | ||
| 784 | /* iterate possible attachments */ | 787 | /* iterate possible attachments */ |
| 785 | while ((fn = GET_ARGV())) { | 788 | while ((fn = GET_ARGV())) { |
| 786 | FILE *f; | 789 | FILE *f; |
| 787 | 790 | ||
| 791 | if (next) { | ||
| 792 | *next = fn; | ||
| 793 | next = NULL; | ||
| 794 | } | ||
| 795 | else | ||
| 796 | if (strcmp(fn, "-r") == 0) { | ||
| 797 | /* next argument is an inReplyTo */ | ||
| 798 | next = &in_reply_to; | ||
| 799 | } | ||
| 800 | else | ||
| 788 | if ((f = fopen(fn, "rb")) != NULL) { | 801 | if ((f = fopen(fn, "rb")) != NULL) { |
| 789 | /* get the file size and content */ | 802 | /* get the file size and content */ |
| 790 | fseek(f, 0, SEEK_END); | 803 | fseek(f, 0, SEEK_END); |
| @@ -794,8 +807,10 @@ int main(int argc, char *argv[]) | |||
| 794 | fclose(f); | 807 | fclose(f); |
| 795 | 808 | ||
| 796 | char *ext = strrchr(fn, '.'); | 809 | char *ext = strrchr(fn, '.'); |
| 797 | xs *hash = xs_md5_hex(fn, strlen(fn)); | 810 | char rnd[32]; |
| 798 | xs *id = xs_fmt("%s%s", hash, ext); | 811 | xs_rnd_buf(rnd, sizeof(rnd)); |
| 812 | xs *hash = xs_md5_hex(rnd, sizeof(rnd)); | ||
| 813 | xs *id = xs_fmt("post-%s%s", hash, ext ? ext : ""); | ||
| 799 | xs *url = xs_fmt("%s/s/%s", snac.actor, id); | 814 | xs *url = xs_fmt("%s/s/%s", snac.actor, id); |
| 800 | 815 | ||
| 801 | /* store */ | 816 | /* store */ |
| @@ -856,7 +871,7 @@ int main(int argc, char *argv[]) | |||
| 856 | if (strcmp(cmd, "note_unlisted") == 0) | 871 | if (strcmp(cmd, "note_unlisted") == 0) |
| 857 | scope = 2; | 872 | scope = 2; |
| 858 | 873 | ||
| 859 | msg = msg_note(&snac, content, NULL, NULL, attl, scope, getenv("LANG"), NULL); | 874 | msg = msg_note(&snac, content, NULL, in_reply_to, attl, scope, getenv("LANG"), NULL); |
| 860 | 875 | ||
| 861 | c_msg = msg_create(&snac, msg); | 876 | c_msg = msg_create(&snac, msg); |
| 862 | 877 | ||