Make read_one_header_line return a flag not a length.
Currently we only use the return value from read_one_header line to tell if the line we have read is a header or not. So make it a flag. This paves the way for better email detection. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
405053d2d9
commit
f8128cfb8d
22
mailinfo.c
22
mailinfo.c
@ -331,7 +331,7 @@ struct header_def {
|
|||||||
int namelen;
|
int namelen;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void check_header(char *line, int len, struct header_def *header)
|
static void check_header(char *line, struct header_def *header)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -349,7 +349,7 @@ static void check_header(char *line, int len, struct header_def *header)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void check_subheader_line(char *line, int len)
|
static void check_subheader_line(char *line)
|
||||||
{
|
{
|
||||||
static struct header_def header[] = {
|
static struct header_def header[] = {
|
||||||
{ "Content-Type", handle_subcontent_type },
|
{ "Content-Type", handle_subcontent_type },
|
||||||
@ -357,9 +357,9 @@ static void check_subheader_line(char *line, int len)
|
|||||||
handle_content_transfer_encoding },
|
handle_content_transfer_encoding },
|
||||||
{ NULL },
|
{ NULL },
|
||||||
};
|
};
|
||||||
check_header(line, len, header);
|
check_header(line, header);
|
||||||
}
|
}
|
||||||
static void check_header_line(char *line, int len)
|
static void check_header_line(char *line)
|
||||||
{
|
{
|
||||||
static struct header_def header[] = {
|
static struct header_def header[] = {
|
||||||
{ "From", handle_from },
|
{ "From", handle_from },
|
||||||
@ -370,7 +370,7 @@ static void check_header_line(char *line, int len)
|
|||||||
handle_content_transfer_encoding },
|
handle_content_transfer_encoding },
|
||||||
{ NULL },
|
{ NULL },
|
||||||
};
|
};
|
||||||
check_header(line, len, header);
|
check_header(line, header);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int read_one_header_line(char *line, int sz, FILE *in)
|
static int read_one_header_line(char *line, int sz, FILE *in)
|
||||||
@ -709,8 +709,8 @@ static void handle_multipart_body(void)
|
|||||||
return;
|
return;
|
||||||
/* We are on boundary line. Start slurping the subhead. */
|
/* We are on boundary line. Start slurping the subhead. */
|
||||||
while (1) {
|
while (1) {
|
||||||
int len = read_one_header_line(line, sizeof(line), stdin);
|
int hdr = read_one_header_line(line, sizeof(line), stdin);
|
||||||
if (!len) {
|
if (!hdr) {
|
||||||
if (handle_multipart_one_part() < 0)
|
if (handle_multipart_one_part() < 0)
|
||||||
return;
|
return;
|
||||||
/* Reset per part headers */
|
/* Reset per part headers */
|
||||||
@ -718,7 +718,7 @@ static void handle_multipart_body(void)
|
|||||||
charset[0] = 0;
|
charset[0] = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
check_subheader_line(line, len);
|
check_subheader_line(line);
|
||||||
}
|
}
|
||||||
fclose(patchfile);
|
fclose(patchfile);
|
||||||
if (!patch_lines) {
|
if (!patch_lines) {
|
||||||
@ -787,15 +787,15 @@ int main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
while (1) {
|
while (1) {
|
||||||
int len = read_one_header_line(line, sizeof(line), stdin);
|
int hdr = read_one_header_line(line, sizeof(line), stdin);
|
||||||
if (!len) {
|
if (!hdr) {
|
||||||
if (multipart_boundary[0])
|
if (multipart_boundary[0])
|
||||||
handle_multipart_body();
|
handle_multipart_body();
|
||||||
else
|
else
|
||||||
handle_body();
|
handle_body();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
check_header_line(line, len);
|
check_header_line(line);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user