if (debug) log_d("f_webuserok: %d %d", fd, flen);
static int f_webuserok(const char *authorization, int fd, char *username, int len, int do_crypt){	char fbuf[4096], buf[128], tmp[128], *p, *q;	int fbp, flen, c, gotcr, eof;	size_t bp;	if (strlen(authorization) >= sizeof tmp) {		log_d("authorization string too long");		return 0;	}	if (base64decode(authorization, tmp) == -1) {		log_d("could not decode authorization");		return 0;	}	q = strchr(tmp, ':');	if (q == 0) {		log_d("no colon in decoded authorization");		return 0;	}	if (username && q >= tmp + len) {		log_d("supplied username too long");		return 0;	}	*q++ = 0;	bp = 0;	gotcr = 0;	flen = 0;	fbp = 0;	eof = 0;	while (1) {		if (fbp >= flen) {			if (eof)				return 0;			flen = read(fd, fbuf, sizeof fbuf);			if (debug)				log_d("f_webuserok: %d %d", fd, flen);			if (flen == -1) {				lerror("read");				return 0;			}			if (flen == 0)				return 0;			if (flen < sizeof fbuf)				eof = 1;			fbp = 0;		}		c = fbuf[fbp++];		if (c == '\n') {			if (bp < sizeof buf) {				buf[bp] = 0;				p = strchr(buf, ':');				if (p) {					*p++ = 0;					if (strcmp(tmp, buf) == 0 && pwok(p, q, do_crypt)) {						if (username)							strcpy(username, buf);						return 1;					}				}			}			bp = 0;			gotcr = 0;		} else {			if (gotcr && bp < sizeof buf)				buf[bp++] = '\r';			gotcr = c == '\r';			if (gotcr == 0 && bp < sizeof buf)				buf[bp++] = c;		}	}}