mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 22:45:05 +00:00
More httpd work.
This commit is contained in:
parent
7efb6d5833
commit
e7c886beb7
4 changed files with 53 additions and 4 deletions
4
Makefile
4
Makefile
|
@ -2,7 +2,7 @@ CFLAGS=-g -Wall
|
||||||
|
|
||||||
all: snac
|
all: snac
|
||||||
|
|
||||||
snac: snac.o main.o data.o http.o
|
snac: snac.o main.o data.o http.o httpd.o
|
||||||
$(CC) -L/usr/local/lib *.o -lcurl -lcrypto -o $@
|
$(CC) -L/usr/local/lib *.o -lcurl -lcrypto -o $@
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
|
@ -19,3 +19,5 @@ main.o: main.c snac.h xs.h
|
||||||
data.o: data.c snac.h xs.h xs_json.h xs_openssl.h
|
data.o: data.c snac.h xs.h xs_json.h xs_openssl.h
|
||||||
|
|
||||||
http.o: http.c snac.h xs.h xs_io.h xs_encdec.h xs_openssl.h xs_curl.h
|
http.o: http.c snac.h xs.h xs_io.h xs_encdec.h xs_openssl.h xs_curl.h
|
||||||
|
|
||||||
|
httpd.o: http.c snac.h xs.h xs_encdec.h xs_socket.h xs_httpd.h
|
||||||
|
|
8
httpd.c
8
httpd.c
|
@ -2,11 +2,8 @@
|
||||||
/* copyright (c) 2022 grunfink - MIT license */
|
/* copyright (c) 2022 grunfink - MIT license */
|
||||||
|
|
||||||
#include "xs.h"
|
#include "xs.h"
|
||||||
#include "xs_io.h"
|
|
||||||
#include "xs_encdec.h"
|
#include "xs_encdec.h"
|
||||||
#include "xs_json.h"
|
#include "xs_json.h"
|
||||||
#include "xs_curl.h"
|
|
||||||
#include "xs_openssl.h"
|
|
||||||
#include "xs_socket.h"
|
#include "xs_socket.h"
|
||||||
#include "xs_httpd.h"
|
#include "xs_httpd.h"
|
||||||
|
|
||||||
|
@ -23,6 +20,11 @@ void httpd_connection(int rs)
|
||||||
|
|
||||||
req = xs_httpd_request(f);
|
req = xs_httpd_request(f);
|
||||||
|
|
||||||
|
{
|
||||||
|
xs *j = xs_json_dumps_pp(req, 4);
|
||||||
|
printf("%s\n", j);
|
||||||
|
}
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
43
main.c
43
main.c
|
@ -7,7 +7,49 @@
|
||||||
|
|
||||||
#include "snac.h"
|
#include "snac.h"
|
||||||
|
|
||||||
|
int usage(void)
|
||||||
|
{
|
||||||
|
printf("usage:\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
char *cmd;
|
||||||
|
char *basedir;
|
||||||
|
int argi = 1;
|
||||||
|
|
||||||
|
argc--;
|
||||||
|
if (argc < argi)
|
||||||
|
return usage();
|
||||||
|
|
||||||
|
cmd = argv[argi++];
|
||||||
|
|
||||||
|
if (strcmp(cmd, "init") == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc < argi)
|
||||||
|
return usage();
|
||||||
|
|
||||||
|
basedir = argv[argi++];
|
||||||
|
|
||||||
|
if (!srv_open(basedir)) {
|
||||||
|
srv_log(xs_fmt("error opening database at %s", basedir));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(cmd, "httpd") == 0) {
|
||||||
|
httpd();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
{
|
{
|
||||||
snac snac;
|
snac snac;
|
||||||
|
|
||||||
|
@ -85,3 +127,4 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
2
snac.h
2
snac.h
|
@ -67,3 +67,5 @@ d_char *http_signed_request(snac *snac, char *method, char *url,
|
||||||
d_char *headers,
|
d_char *headers,
|
||||||
d_char *body, int b_size,
|
d_char *body, int b_size,
|
||||||
int *status, d_char **payload, int *p_size);
|
int *status, d_char **payload, int *p_size);
|
||||||
|
|
||||||
|
void httpd(void);
|
||||||
|
|
Loading…
Reference in a new issue