Skip to content

Commit

Permalink
blaze822: remove blaze822_mmap, never used.
Browse files Browse the repository at this point in the history
  • Loading branch information
leahneukirchen committed Aug 30, 2021
1 parent 4ccf2f0 commit 4be6e0c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 50 deletions.
49 changes: 0 additions & 49 deletions blaze822.c
Original file line number Diff line number Diff line change
Expand Up @@ -664,55 +664,6 @@ blaze822_file(char *file)
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)
{
Expand Down
1 change: 0 additions & 1 deletion blaze822.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ struct message;

struct message *blaze822(char *file); // just header
struct message *blaze822_file(char *file); // header + body (read(2))
struct message *blaze822_mmap(char *file); // header + body (mmap(2))
struct message *blaze822_mem(char *buf, size_t len); // header + body

char *blaze822_hdr_(struct message *mesg, const char *hdr, size_t len);
Expand Down

0 comments on commit 4be6e0c

Please sign in to comment.