[hackers] [quark] Streamline the code || FRIGN

From: <git_AT_suckless.org>
Date: Tue, 12 Aug 2014 10:32:27 +0200

commit 390b5855f5cd263e652b636e43496d32f5ec8e0e
Author: FRIGN <dev_AT_frign.de>
Date: Tue Aug 12 10:34:06 2014 +0200

    Streamline the code

diff --git a/quark.c b/quark.c
index 30bff89..5a4c69b 100644
--- a/quark.c
+++ b/quark.c
_AT_@ -56,7 +56,10 @@ enum {
 };
 
 static const char *resentry[] = {
- [HEADER] = "HTTP/1.1 %s
Connection: close
Date: %s
Server: quark-"VERSION"
",
+ [HEADER] = "HTTP/1.1 %s
"
+ "Connection: close
"
+ "Date: %s
"
+ "Server: quark-"VERSION"
",
         [CONTENTLEN] = "Content-Length: %lu
",
         [LOCATION] = "Location: %s%s
",
         [CONTENTTYPE] = "Content-Type: %s
",
_AT_@ -185,7 +188,8 @@ responsefiledata(int fd, off_t size) {
 
         for (; (n = read(fd, buf, MIN(size, sizeof buf))) > 0; size -= n)
                 if (write(req.fd, buf, n) != n)
- logerrmsg("error writing to client %s at %ls: %s
", host, n, strerror(errno));
+ logerrmsg("error writing to client %s at %ls: %s
",
+ host, n, strerror(errno));
         if (n == -1)
                 logerrmsg("error reading from file: %s
", strerror(errno));
 }
_AT_@ -207,7 +211,8 @@ responsefile(void) {
                         writetext("
<html><body>"HttpNotFound"</body></html>
");
         } else {
                 /* check if modified */
- if (!strcmp(reqmod, tstamp(st.st_mtim.tv_sec)) && !putresentry(HEADER, HttpNotModified, tstamp(0))) {
+ if (!strcmp(reqmod, tstamp(st.st_mtim.tv_sec))
+ && !putresentry(HEADER, HttpNotModified, tstamp(0))) {
                         /* not modified, we're done here*/
                         status = 304;
                 } else {
_AT_@ -288,7 +293,8 @@ responsedir(void) {
                         responsedirdata(d);
                         closedir(d);
                 } else {
- logerrmsg("client %s requests %s but opendir failed: %s
", host, reqbuf, strerror(errno));
+ logerrmsg("client %s requests %s but opendir failed: %s
",
+ host, reqbuf, strerror(errno));
                 }
         } else {
                 responsefile(); /* docindex */
_AT_@ -310,9 +316,11 @@ responsecgi(void) {
                 setenv("SERVER_NAME", reqhost, 1);
         setenv("SCRIPT_NAME", cgi_script, 1);
         setenv("REQUEST_URI", reqbuf, 1);
- logmsg("CGI SERVER_NAME=%s SCRIPT_NAME=%s REQUEST_URI=%s
", reqhost, cgi_script, reqbuf);
+ logmsg("CGI SERVER_NAME=%s SCRIPT_NAME=%s REQUEST_URI=%s
",
+ reqhost, cgi_script, reqbuf);
         if (chdir(cgi_dir) == -1)
- logerrmsg("error chdir to cgi directory %s failed: %s
", cgi_dir, strerror(errno));
+ logerrmsg("error chdir to cgi directory %s failed: %s
",
+ cgi_dir, strerror(errno));
         if ((cgi = popen(cgi_script, "r"))) {
                 if (putresentry(HEADER, HttpOk, tstamp(0)))
                         return;
_AT_@ -325,7 +333,8 @@ responsecgi(void) {
                 }
                 pclose(cgi);
         } else {
- logerrmsg("error %s requests %s, but cannot run cgi script %s
", host, cgi_script, reqbuf);
+ logerrmsg("error %s requests %s, but cannot run cgi script %s
",
+ host, cgi_script, reqbuf);
                 if (putresentry(HEADER, HttpNotFound, tstamp(0))
                  || putresentry(CONTENTTYPE, texthtml))
                         return;
_AT_@ -341,7 +350,8 @@ response(void) {
         struct stat st;
 
         for (p = reqbuf; *p; p++)
- if (*p == '\' || (*p == '/' && *(p + 1) == '.')) { /* don't serve bogus or hidden files */
+ if (*p == '\' || (*p == '/' && *(p + 1) == '.')) {
+ /* don't serve bogus or hidden files */
                         if (putresentry(HEADER, HttpForbidden, tstamp(0))
                          || putresentry(CONTENTTYPE, texthtml))
                                 return;
Received on Tue Aug 12 2014 - 10:32:27 CEST

This archive was generated by hypermail 2.3.0 : Tue Aug 12 2014 - 10:36:08 CEST