From 08f03cde6b469428494d3870ac54f740fd4641c4 Mon Sep 17 00:00:00 2001 From: grunfink Date: Tue, 8 Jul 2025 17:30:45 +0200 Subject: Added some const here and there. --- snac.h | 2 +- webfinger.c | 2 +- xs_fcgi.h | 4 ++-- xs_httpd.h | 12 ++++++------ xs_version.h | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/snac.h b/snac.h index cc66686..b50f345 100644 --- a/snac.h +++ b/snac.h @@ -325,7 +325,7 @@ void httpd(void); int webfinger_request_signed(snac *snac, const char *qs, xs_str **actor, xs_str **user); int webfinger_request(const char *qs, xs_str **actor, xs_str **user); int webfinger_request_fake(const char *qs, xs_str **actor, xs_str **user); -int webfinger_get_handler(xs_dict *req, const char *q_path, +int webfinger_get_handler(const xs_dict *req, const char *q_path, xs_val **body, int *b_size, char **ctype); const char *default_avatar_base64(void); diff --git a/webfinger.c b/webfinger.c index dc0855a..46b7edb 100644 --- a/webfinger.c +++ b/webfinger.c @@ -152,7 +152,7 @@ int webfinger_request_fake(const char *qs, xs_str **actor, xs_str **user) } -int webfinger_get_handler(xs_dict *req, const char *q_path, +int webfinger_get_handler(const xs_dict *req, const char *q_path, xs_val **body, int *b_size, char **ctype) /* serves webfinger queries */ { diff --git a/xs_fcgi.h b/xs_fcgi.h index 0b53dac..b3cb892 100644 --- a/xs_fcgi.h +++ b/xs_fcgi.h @@ -13,7 +13,7 @@ #define _XS_FCGI_H xs_dict *xs_fcgi_request(FILE *f, xs_str **payload, int *p_size, int *id); - void xs_fcgi_response(FILE *f, int status, xs_dict *headers, xs_str *body, int b_size, int id); + void xs_fcgi_response(FILE *f, int status, const xs_dict *headers, const xs_str *body, int b_size, int id); #ifdef XS_IMPLEMENTATION @@ -290,7 +290,7 @@ end: } -void xs_fcgi_response(FILE *f, int status, xs_dict *headers, xs_str *body, int b_size, int fcgi_id) +void xs_fcgi_response(FILE *f, int status, const xs_dict *headers, const xs_str *body, int b_size, int fcgi_id) /* writes an FCGI response */ { struct fcgi_record_header hdr = {0}; diff --git a/xs_httpd.h b/xs_httpd.h index 4cc8263..57759c4 100644 --- a/xs_httpd.h +++ b/xs_httpd.h @@ -5,7 +5,8 @@ #define _XS_HTTPD_H xs_dict *xs_httpd_request(FILE *f, xs_str **payload, int *p_size); -void xs_httpd_response(FILE *f, int status, const char *status_text, xs_dict *headers, xs_str *body, int b_size); +void xs_httpd_response(FILE *f, int status, const char *status_text, + const xs_dict *headers, const xs_val *body, int b_size); #ifdef XS_IMPLEMENTATION @@ -109,16 +110,15 @@ xs_dict *xs_httpd_request(FILE *f, xs_str **payload, int *p_size) } -void xs_httpd_response(FILE *f, int status, const char *status_text, xs_dict *headers, xs_str *body, int b_size) +void xs_httpd_response(FILE *f, int status, const char *status_text, + const xs_dict *headers, const xs_val *body, int b_size) /* sends an httpd response */ { - xs *proto; + fprintf(f, "HTTP/1.1 %d %s\r\n", status, status_text ? status_text : ""); + const xs_str *k; const xs_val *v; - proto = xs_fmt("HTTP/1.1 %d %s", status, status_text); - fprintf(f, "%s\r\n", proto); - xs_dict_foreach(headers, k, v) { fprintf(f, "%s: %s\r\n", k, v); } diff --git a/xs_version.h b/xs_version.h index 09b1bdc..466535b 100644 --- a/xs_version.h +++ b/xs_version.h @@ -1 +1 @@ -/* a32c0d513ae24ad28ffc5c6c2c1cde75bb758e09 2025-06-23T17:43:10+02:00 */ +/* 401d229ffbec89b4a5cf97793926b7afb84a4f26 2025-07-08T15:44:54+02:00 */ -- cgit v1.2.3