summaryrefslogtreecommitdiff
path: root/src/tipideed/tipideed-internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/tipideed/tipideed-internal.h')
-rw-r--r--src/tipideed/tipideed-internal.h73
1 files changed, 37 insertions, 36 deletions
diff --git a/src/tipideed/tipideed-internal.h b/src/tipideed/tipideed-internal.h
index fe01152..a4f6d95 100644
--- a/src/tipideed/tipideed-internal.h
+++ b/src/tipideed/tipideed-internal.h
@@ -71,42 +71,38 @@ extern void tipideed_harden (unsigned int) ;
/* Responses */
-extern void response_error (tipidee_rql const *, unsigned int, char const *, char const *, uint32_t) ; /* set bit 0 for Connection: close, bit 1 for preexit */
-extern void response_error_and_exit (tipidee_rql const *, unsigned int, char const *, char const *, uint32_t) gccattr_noreturn ;
-extern void response_error_and_die (tipidee_rql const *, int e, unsigned int, char const *, char const *, char const *const *, unsigned int, uint32_t) gccattr_noreturn ;
-
- /*
- preexit is meant to be called before tipidee_log_request(), it won't log an answer line.
- Use for early parsing, when the request isn't even validated yet.
- exit is meant to be called after tipidee_log_request(), it will log an answer line.
- respond can only happen after tipidee_log_request(), it will log an answer line.
-
- exit will log an informational exit line.
- die will not; there will be a fatal line instead.
- die will log an answer line. There is no "predie", we just use strerr_die instead.
- */
-
-#define preexit_400(r, s) response_error_and_exit(r, 400, "Bad Request", s, 2)
-#define exit_400(r, s) response_error_and_exit(r, 400, "Bad Request", s, 0)
-extern void exit_405 (tipidee_rql const *, uint32_t) gccattr_noreturn ; /* set bit 0 for Allow: POST, bit 1 for preexit */
-#define preexit_408(r) response_error_and_exit(r, 408, "Request Timeout", "", 2)
-#define exit_408(r) response_error_and_exit(r, 408, "Request Timeout", "", 0)
-#define preexit_413(r, s) response_error_and_exit(r, 413, "Request Entity Too Large", s, 2)
-#define exit_413(r, s) response_error_and_exit(r, 413, "Request Entity Too Large", s, 0)
-#define preexit_501(r, s) response_error_and_exit(r, 501, "Not Implemented", s, 2)
-#define exit_501(r, s) response_error_and_exit(r, 501, "Not Implemented", s, 0)
-
-#define respond_403(r) response_error(r, 403, "Forbidden", "Missing credentials to access the URI.", 0)
-#define respond_404(r) response_error(r, 404, "Not Found", "The request URI was not found.", 0)
-#define respond_414(r) response_error(r, 414, "URI Too Long", "The request URI had an oversized component.", 0)
+extern void response_error_early (tipidee_rql const *, unsigned int, char const *, char const *, uint32_t) ; /* set bit 0 for Connection: close */
+extern void response_error_early_and_exit (tipidee_rql const *, unsigned int, char const *, char const *) gccattr_noreturn ;
+extern void exit_405_ (tipidee_rql const *, uint32_t) gccattr_noreturn ; /* set bit 0 for Allow: POST, bit 1 for preexit */
+
+#define eexit_400(r, s) response_error_early_and_exit(r, 400, "Bad Request", s)
+#define eexit_405(r) exit_405_((r), 3)
+#define eexit_408(r) response_error_early_and_exit((r), 408, "Request Timeout", 0)
+#define eexit_413(r, s) response_error_early_and_exit(r, 413, "Request Entity Too Large", s)
+#define eexit_501(r, s) response_error_early_and_exit(r, 501, "Not Implemented", s)
+
+
+extern void response_error (tipidee_rql const *, char const *, unsigned int, uint32_t) ; /* set bit 0 for Connection: close */
+extern void response_error_and_exit (tipidee_rql const *, char const *, unsigned int) gccattr_noreturn ;
+extern void response_error_and_die (tipidee_rql const *, int, char const *, unsigned int, char const *const *, unsigned int, uint32_t) gccattr_noreturn ; /* set bit 0 for diesys */
+
+#define exit_400(r, d) response_error_and_exit(r, (d), 400)
+#define exit_405(r) exit_405_((r), 0)
+#define exit_408(r, d) response_error_and_exit(r, (d), 408)
+#define exit_413(r, d) response_error_and_exit(r, (d), 413)
+#define exit_501(r, d) response_error_and_exit(r, (d), 501)
+
extern void respond_30x (tipidee_rql const *, tipidee_redirection const *) ;
-#define respond_504(r) response_error(r, 504, "Gateway Timeout", "The CGI script took too long to answer.", 0)
+#define respond_403(r, d) response_error(r, (d), 403, 0)
+#define respond_404(r, d) response_error(r, (d), 404, 0)
+#define respond_414(r, d) response_error(r, (d), 414, 0)
+#define respond_504(r, d) response_error(r, (d), 504, 0)
-#define diefx(r, e, status, rsl, text, ...) response_error_and_die(r, e, status, rsl, text, strerr_array(PROG, ": fatal: ", __VA_ARGS__), sizeof(strerr_array(__VA_ARGS__))/sizeof(char const *)+2, 0)
-#define diefusys(r, e, status, rsl, text, ...) response_error_and_die(r, e, status, rsl, text, strerr_array(PROG, ": fatal: ", "unable to ", __VA_ARGS__), sizeof(strerr_array(__VA_ARGS__))/sizeof(char const *)+3, 1)
-#define die500x(r, e, ...) diefx(r, e, 500, "Internal Server Error", "Bad server configuration.", __VA_ARGS__)
-#define die500sys(r, e, ...) diefusys(r, e, 500, "Internal Server Error", "System error.", __VA_ARGS__)
-#define die502x(r, e, ...) diefx(r, e, 502, "Bad Gateway", "Bad CGI script.", __VA_ARGS__)
+#define diefx(r, e, d, status, ...) response_error_and_die(r, e, d, status, strerr_array(PROG, ": fatal: ", __VA_ARGS__), sizeof(strerr_array(__VA_ARGS__))/sizeof(char const *)+2, 0)
+#define diefusys(r, e, d, status, ...) response_error_and_die(r, e, d, status, strerr_array(PROG, ": fatal: ", "unable to ", __VA_ARGS__), sizeof(strerr_array(__VA_ARGS__))/sizeof(char const *)+3, 1)
+#define die500x(r, e, d, ...) diefx(r, e, d, 500, __VA_ARGS__)
+#define die500sys(r, e, d, ...) diefusys(r, e, d, 500, __VA_ARGS__)
+#define die502x(r, e, d, ...) diefx(r, e, d, 502, __VA_ARGS__)
/* Trace */
@@ -127,12 +123,17 @@ extern void send_file (int, uint64_t, char const *) ;
/* regular */
-extern int respond_regular (tipidee_rql const *, char const *, struct stat const *, tipidee_resattr const *) ;
+extern int respond_regular (tipidee_rql const *, char const *, char const *, struct stat const *, tipidee_resattr const *) ;
extern int respond_304 (tipidee_rql const *, char const *, struct stat const *) ;
/* cgi */
-extern int respond_cgi (tipidee_rql *, char const *, size_t, char const *, char *, tipidee_headers const *, tipidee_resattr const *, char const *, size_t) ;
+extern int respond_cgi (tipidee_rql *, char const *, char const *, size_t, char const *, char *, tipidee_headers const *, tipidee_resattr const *, char const *, size_t) ;
+
+
+ /* main */
+
+extern void log_and_exit (int) gccattr_noreturn ;
#endif