diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-03-16 20:05:50 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-03-17 01:55:48 -0400 |
commit | e7216d112aff3ba4ce196db95b86d77d5a1b234e (patch) | |
tree | 26b7e09325919ebff2cb06396250e3c4e7ea2982 /src/journal/microhttpd-util.h | |
parent | cc64d0175a3c2c974709e9962c00fbe04d74c43f (diff) |
microhttpd-util: use static buffer for static messages
Most of the messages we send do not require a allocating and
freeing a buffer, to optimize this by using const strings.
Also, rename respond_error to mhd_respond*, since it is used
not only for errors.
Make use of information from printf to avoid one extra call to
strlen.
Diffstat (limited to 'src/journal/microhttpd-util.h')
-rw-r--r-- | src/journal/microhttpd-util.h | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/journal/microhttpd-util.h b/src/journal/microhttpd-util.h index cd14ac4dcf..df4d003eb9 100644 --- a/src/journal/microhttpd-util.h +++ b/src/journal/microhttpd-util.h @@ -28,14 +28,18 @@ void microhttpd_logger(void *arg, const char *fmt, va_list ap) _printf_(2, 0); -int respond_oom_internal(struct MHD_Connection *connection); - /* respond_oom() must be usable with return, hence this form. */ -#define respond_oom(connection) log_oom(), respond_oom_internal(connection) +#define respond_oom(connection) log_oom(), mhd_respond_oom(connection) + +int mhd_respondf(struct MHD_Connection *connection, + unsigned code, + const char *format, ...) _printf_(3,4); + +int mhd_respond(struct MHD_Connection *connection, + unsigned code, + const char *message); -int respond_error(struct MHD_Connection *connection, - unsigned code, - const char *format, ...); +int mhd_respond_oom(struct MHD_Connection *connection); int check_permissions(struct MHD_Connection *connection, int *code); |