[hackers] [quark] Change HTTP-status-codes to defines || FRIGN
commit 00e2aa8da6fddcdc59f867d55326d157b9acd490
Author: FRIGN <dev_AT_frign.de>
Date: Mon Aug 11 13:40:30 2014 +0200
Change HTTP-status-codes to defines
Doesn't change binary-size, but allows using them inside the
error-page-generation-routines.
diff --git a/quark.c b/quark.c
index 0631248..dadc78e 100644
--- a/quark.c
+++ b/quark.c
_AT_@ -24,6 +24,13 @@ char *argv0;
#define MAXBUFLEN 1024
#define MIN(x,y) ((x) < (y) ? (x) : (y))
+#define HttpOk "200 OK"
+#define HttpMoved "301 Moved Permanently"
+#define HttpNotModified "304 Not Modified"
+#define HttpUnauthorized "401 Unauthorized"
+#define HttpNotFound "404 Not Found"
+#define texthtml "text/html"
+
enum {
GET = 4,
HEAD = 5,
_AT_@ -39,13 +46,6 @@ typedef struct {
int fd;
} Request;
-static const char HttpOk[] = "200 OK";
-static const char HttpMoved[] = "301 Moved Permanently";
-static const char HttpNotModified[] = "304 Not Modified";
-static const char HttpUnauthorized[] = "401 Unauthorized";
-static const char HttpNotFound[] = "404 Not Found";
-static const char texthtml[] = "text/html";
-
enum {
HEADER,
CONTENTLEN,
_AT_@ -203,7 +203,7 @@ responsefile(void) {
return;
status = 404;
if (req.type == GET)
- writetext("
<html><body>404 Not Found</body></html>
");
+ writetext("
<html><body>"HttpNotFound"</body></html>
");
} else {
/* check if modified */
t = st.st_mtim.tv_sec;
_AT_@ -278,7 +278,7 @@ responsedir(void) {
status = 301;
reqbuf[len] = 0;
if (req.type == GET)
- writetext("
<html><body>301 Moved Permanently</a></body></html>
");
+ writetext("
<html><body>"HttpMoved"</a></body></html>
");
return;
}
if (len + strlen(docindex) + 1 < MAXBUFLEN)
_AT_@ -332,7 +332,7 @@ responsecgi(void) {
return;
status = 404;
if (req.type == GET)
- writetext("
<html><body>404 Not Found</body></html>
");
+ writetext("
<html><body>"HttpNotFound"</body></html>
");
}
}
_AT_@ -348,7 +348,7 @@ response(void) {
return;
status = 401;
if (req.type == GET)
- writetext("
<html><body>401 Unauthorized</body></html>
");
+ writetext("
<html><body>"HttpUnauthorized"</body></html>
");
return;
}
if (cgi_mode) {
Received on Mon Aug 11 2014 - 13:49:23 CEST
This archive was generated by hypermail 2.3.0
: Mon Aug 11 2014 - 14:00:11 CEST