code-style fixes

This commit is contained in:
Hiltjo Posthuma 2014-11-30 14:42:16 +01:00 committed by FRIGN
parent e42bb27846
commit 192f44046c

60
quark.c
View file

@ -102,7 +102,8 @@ static int listenfd = -1;
static Request req; static Request req;
char * char *
tstamp(time_t t) { tstamp(time_t t)
{
static char res[30]; static char res[30];
if (!t) if (!t)
@ -112,7 +113,8 @@ tstamp(time_t t) {
} }
int int
writedata(const char *buf, size_t buf_len) { writedata(const char *buf, size_t buf_len)
{
ssize_t r, offset; ssize_t r, offset;
for (offset = 0; offset < buf_len; offset += r) { for (offset = 0; offset < buf_len; offset += r) {
@ -125,12 +127,14 @@ writedata(const char *buf, size_t buf_len) {
} }
int int
writetext(const char *buf) { writetext(const char *buf)
{
return writedata(buf, strlen(buf)); return writedata(buf, strlen(buf));
} }
void void
atomiclog(int fd, const char *errstr, va_list ap) { atomiclog(int fd, const char *errstr, va_list ap)
{
static char buf[512]; static char buf[512];
size_t n; size_t n;
@ -144,7 +148,8 @@ atomiclog(int fd, const char *errstr, va_list ap) {
} }
void void
logmsg(const char *errstr, ...) { logmsg(const char *errstr, ...)
{
va_list ap; va_list ap;
va_start(ap, errstr); va_start(ap, errstr);
@ -153,7 +158,8 @@ logmsg(const char *errstr, ...) {
} }
void void
logerrmsg(const char *errstr, ...) { logerrmsg(const char *errstr, ...)
{
va_list ap; va_list ap;
va_start(ap, errstr); va_start(ap, errstr);
@ -162,7 +168,8 @@ logerrmsg(const char *errstr, ...) {
} }
void void
die(const char *errstr, ...) { die(const char *errstr, ...)
{
va_list ap; va_list ap;
va_start(ap, errstr); va_start(ap, errstr);
@ -172,7 +179,8 @@ die(const char *errstr, ...) {
} }
int int
putresentry(int type, ...) { putresentry(int type, ...)
{
va_list ap; va_list ap;
va_start(ap, type); va_start(ap, type);
@ -185,7 +193,8 @@ putresentry(int type, ...) {
} }
void void
responsefiledata(int fd, off_t size) { responsefiledata(int fd, off_t size)
{
char buf[BUFSIZ]; char buf[BUFSIZ];
ssize_t n, m = 0, size_in; ssize_t n, m = 0, size_in;
@ -199,7 +208,8 @@ responsefiledata(int fd, off_t size) {
} }
void void
responsefile(void) { responsefile(void)
{
const char *mimetype = "application/octet-stream"; const char *mimetype = "application/octet-stream";
char mod[30], *p; char mod[30], *p;
int r, ffd; int r, ffd;
@ -245,7 +255,8 @@ responsefile(void) {
} }
void void
responsedirdata(struct dirent **e, int len) { responsedirdata(struct dirent **e, int len)
{
int n; int n;
if (putresentry(HEADER, HttpOk, tstamp(0)) if (putresentry(HEADER, HttpOk, tstamp(0))
@ -272,7 +283,8 @@ responsedirdata(struct dirent **e, int len) {
} }
void void
responsedir(void) { responsedir(void)
{
size_t len = strlen(reqbuf); size_t len = strlen(reqbuf);
struct dirent **namelist = NULL; struct dirent **namelist = NULL;
int n; int n;
@ -317,7 +329,8 @@ responsedir(void) {
} }
void void
responsecgi(void) { responsecgi(void)
{
FILE *cgi; FILE *cgi;
size_t r, linesiz = 0; size_t r, linesiz = 0;
char *q, *line = NULL, *statusline = HttpOk; char *q, *line = NULL, *statusline = HttpOk;
@ -389,7 +402,8 @@ responsecgi(void) {
} }
void void
response(void) { response(void)
{
char *p; char *p;
struct stat st; struct stat st;
int r; int r;
@ -422,7 +436,8 @@ response(void) {
} }
int int
getreqentry(char *name, char *target, size_t targetlen, char *breakchars) { getreqentry(char *name, char *target, size_t targetlen, char *breakchars)
{
char *p, *res; char *p, *res;
if ((res = strstr(reqbuf, name))) { if ((res = strstr(reqbuf, name))) {
@ -442,7 +457,8 @@ getreqentry(char *name, char *target, size_t targetlen, char *breakchars) {
} }
int int
request(void) { request(void)
{
char *p, *res; char *p, *res;
ssize_t r; ssize_t r;
size_t offset = 0; size_t offset = 0;
@ -496,7 +512,8 @@ invalid_request:
} }
void void
serve(int fd) { serve(int fd)
{
int result; int result;
struct timeval tv; struct timeval tv;
socklen_t salen; socklen_t salen;
@ -551,7 +568,8 @@ serve(int fd) {
} }
void void
sighandler(int sig) { sighandler(int sig)
{
if (sig == SIGCHLD) { if (sig == SIGCHLD) {
while (0 < waitpid(-1, NULL, WNOHANG)); while (0 < waitpid(-1, NULL, WNOHANG));
} else { } else {
@ -562,7 +580,8 @@ sighandler(int sig) {
} }
void void
usage(void) { usage(void)
{
fprintf(stderr, "usage: quark [-c] [-C chrootdir] [-d cgidir] " fprintf(stderr, "usage: quark [-c] [-C chrootdir] [-d cgidir] "
"[-e cgiscript] [-g group] [-i index] [-l] [-p port] " "[-e cgiscript] [-g group] [-i index] [-l] [-p port] "
"[-r docroot] [-s server] [-u user] [-v]\n"); "[-r docroot] [-s server] [-u user] [-v]\n");
@ -570,7 +589,8 @@ usage(void) {
} }
int int
main(int argc, char *argv[]) { main(int argc, char *argv[])
{
struct addrinfo hints, *ai = NULL; struct addrinfo hints, *ai = NULL;
struct passwd *upwd = NULL; struct passwd *upwd = NULL;
struct group *gpwd = NULL; struct group *gpwd = NULL;