|
|
|
@ -664,55 +664,6 @@ error:
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
struct message * |
|
|
|
|
blaze822_mmap(char *file) |
|
|
|
|
{ |
|
|
|
|
int fd = open(file, O_RDONLY); |
|
|
|
|
if (fd < 0) |
|
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
struct stat st; |
|
|
|
|
if (fstat(fd, &st) < 0) |
|
|
|
|
goto error; |
|
|
|
|
|
|
|
|
|
size_t len = st.st_size; |
|
|
|
|
|
|
|
|
|
struct message *mesg = malloc(sizeof (struct message)); |
|
|
|
|
if (!mesg) |
|
|
|
|
goto error; |
|
|
|
|
|
|
|
|
|
char *buf = mmap(0, len+1, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); |
|
|
|
|
if (buf == MAP_FAILED) { |
|
|
|
|
free(mesg); |
|
|
|
|
perror("mmap"); |
|
|
|
|
goto error; |
|
|
|
|
} |
|
|
|
|
close(fd); |
|
|
|
|
|
|
|
|
|
char *end; |
|
|
|
|
if ((end = mymemmem(buf, len, "\n\n", 2))) { |
|
|
|
|
mesg->body = end+2; |
|
|
|
|
} else if ((end = mymemmem(buf, len, "\r\n\r\n", 4))) { |
|
|
|
|
mesg->body = end+4; |
|
|
|
|
} else { |
|
|
|
|
end = buf + len; |
|
|
|
|
mesg->body = end; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
unfold_hdr(buf, end); |
|
|
|
|
|
|
|
|
|
mesg->msg = mesg->bodychunk = buf; |
|
|
|
|
mesg->end = end; |
|
|
|
|
mesg->bodyend = buf + len; |
|
|
|
|
mesg->orig_header = 0; |
|
|
|
|
|
|
|
|
|
return mesg; |
|
|
|
|
|
|
|
|
|
error: |
|
|
|
|
close(fd); |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
size_t |
|
|
|
|
blaze822_headerlen(struct message *mesg) |
|
|
|
|
{ |
|
|
|
|