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