summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorGravatar default2022-09-27 09:51:39 +0200
committerGravatar default2022-09-27 09:51:39 +0200
commit55226d3e6b2e468a13b17994fa8564604104dc30 (patch)
tree0bde94b1076eecaa8b8e5519014e9d18c174ed2a /main.c
parentStarted function not_really_markdown(). (diff)
downloadsnac2-55226d3e6b2e468a13b17994fa8564604104dc30.tar.gz
snac2-55226d3e6b2e468a13b17994fa8564604104dc30.tar.xz
snac2-55226d3e6b2e468a13b17994fa8564604104dc30.zip
Started command-line command 'note'.
Diffstat (limited to 'main.c')
-rw-r--r--main.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/main.c b/main.c
index 4fd0a87..4b965b3 100644
--- a/main.c
+++ b/main.c
@@ -2,6 +2,7 @@
2/* copyright (c) 2022 grunfink - MIT license */ 2/* copyright (c) 2022 grunfink - MIT license */
3 3
4#include "xs.h" 4#include "xs.h"
5#include "xs_io.h"
5#include "xs_encdec.h" 6#include "xs_encdec.h"
6#include "xs_json.h" 7#include "xs_json.h"
7 8
@@ -34,6 +35,7 @@ int usage(void)
34 35
35 printf("request {basedir} {uid} {url} Requests an object\n"); 36 printf("request {basedir} {uid} {url} Requests an object\n");
36 printf("actor {basedir} {uid} {url} Requests an actor\n"); 37 printf("actor {basedir} {uid} {url} Requests an actor\n");
38 printf("note {basedir} {uid} {'text'} Sends a note to followers\n");
37 39
38 return 1; 40 return 1;
39} 41}
@@ -161,6 +163,39 @@ int main(int argc, char *argv[])
161 return 0; 163 return 0;
162 } 164 }
163 165
166 if (strcmp(cmd, "note") == 0) {
167 int status;
168 xs *data = NULL;
169 xs *content = NULL;
170 xs *f_content = NULL;
171
172 if (strcmp(url, "-") == 0) {
173 /* get the content from an editor */
174 FILE *f;
175
176 system("$EDITOR /tmp/snac-edit.txt");
177
178 if ((f = fopen("/tmp/snac-edit.txt", "r")) != NULL) {
179 content = xs_readall(f);
180 fclose(f);
181
182 unlink("/tmp/snac-edit.txt");
183 }
184 else {
185 printf("Nothing to send\n");
186 return 1;
187 }
188 }
189 else
190 content = xs_dup(url);
191
192 not_really_markdown(content, &f_content);
193
194 printf("%s\n", f_content);
195
196 return 0;
197 }
198
164 return 0; 199 return 0;
165} 200}
166 201