Hi all
Two little patches for quark:
1. use strsignal()
2. clean up whitespace/indentation
If useful, you'd maybe want to apply them upstream.
Regards
--
Džen
diff -r d982c42802b4 quark.c
--- a/quark.c Wed Feb 16 20:29:55 2011 +0000
+++ b/quark.c Wed Apr 20 08:56:03 2011 +0200
@@ -472,14 +472,6 @@
void
sighandler(int sig) {
- static const char *signame[64] = {
- [SIGHUP] = "SIGHUP",
- [SIGINT] = "SIGINT",
- [SIGQUIT] = "SIGQUIT",
- [SIGABRT] = "SIGABRT",
- [SIGTERM] = "SIGTERM",
- [SIGCHLD] = "SIGCHLD"
- };
switch(sig) {
default: break;
case SIGHUP:
@@ -487,7 +479,7 @@
case SIGQUIT:
case SIGABRT:
case SIGTERM:
- logerrmsg("received signal %s, closing down\n", signame[sig] ?
signame[sig] : "");
+ logerrmsg("received signal %s, closing down\n", strsignal(sig));
close(fd);
running = 0;
break;
diff -r d982c42802b4 quark.c
--- a/quark.c Wed Apr 20 08:57:13 2011 +0200
+++ b/quark.c Wed Apr 20 09:00:29 2011 +0200
@@ -18,12 +18,12 @@
#include <time.h>
#include <unistd.h>
-#define LENGTH(x) (sizeof x / sizeof x[0])
-#define MAXBUFLEN 1024
+#define LENGTH(x) (sizeof x / sizeof x[0])
+#define MAXBUFLEN 1024
enum {
- GET = 4,
- HEAD = 5,
+ GET = 4,
+ HEAD = 5,
};
typedef struct {
@@ -52,11 +52,11 @@
void (*handle)(const Request *r);
} RequestHandler;
-static const char HttpOk[] = "200 OK";
-static const char HttpMoved[] = "302 Moved Permanently";
-static const char HttpUnauthorized[] = "401 Unauthorized";
-static const char HttpNotFound[] = "404 Not Found";
-static const char texthtml[] = "text/html";
+static const char HttpOk[] = "200 OK";
+static const char HttpMoved[] = "302 Moved Permanently";
+static const char HttpUnauthorized[] = "401 Unauthorized";
+static const char HttpNotFound[] = "404 Not Found";
+static const char texthtml[] = "text/html";
static ssize_t writetext(const char *buf);
static ssize_t writedata(const char *buf, size_t buflen);
@@ -265,7 +265,7 @@
if(e->d_name[0] == '.') /* ignore hidden files, ., .. */
continue;
if(snprintf(resbuf, MAXBUFLEN, "<a
href='%s%s'>%s</a><br>\r\n",
- reqbuf, e->d_name, e->d_name) >= MAXBUFLEN)
+ reqbuf, e->d_name, e->d_name) >= MAXBUFLEN)
{
logerrmsg("snprintf failed, buffer sizeof
exceeded");
return;