New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for SIZE extension (RfC 1870) #191
base: main
Are you sure you want to change the base?
Conversation
Implementing extensions for qmail-remote often requires the usage of EHLO and checking if the server supports the extension. Every patch therefore usually comes with it's own version of EHLO parsing. Add yet another one that the patches can easily hook into. For the moment it will just send mails using ESMTP instead of SMTP for basically all cases, but not use any of the new information.
130be56
to
bce502e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All so very good. One less external patch to care about, in exchange of a tiny diff.
This looks like the kind of patch to inline.
OTOH, I do not see where this gets actually called by the code. Maybe I missed something or it is a WIP...
qmail-remote.c
Outdated
if (remotesize >= 0) { | ||
struct stat st; | ||
/* in case the input is e.g. a pipe or socket we can't use the size */ | ||
if (fstat(0, &st) != 0 || !S_ISREG(st.st_mode)) { | ||
substdio_puts(&smtpto,">\r\n"); | ||
} else { | ||
char buf[FMT_ULONG + 10] = "> SIZE="; | ||
unsigned int off = 7 + fmt_ulong(buf + 7, st.st_size); | ||
buf[off++] = '\r'; | ||
buf[off++] = '\n'; | ||
buf[off] = '\0'; | ||
} | ||
} else { | ||
substdio_puts(&smtpto,">\r\n"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[up-there]
struct stat st;
[...]
substdio_puts(&smtpto,">");
/* in case the input is e.g. a pipe or socket we can't use the size */
if (fstat(0, &st) == 0 && S_ISREG(st.st_mode)) {
substdio_puts(&smtpto," SIZE=");
substdio_putn(&smtpto,st.st_size);
}
substdio_puts(&smtpto,"\r\n");
This look shorter, but does not mean it is better...
I really like your single fstat() call to check the file descriptor, the file type, and the file size at the same time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be a nice addition to the API and a general cleanup through the code. For the moment I don't want to invent that just for one place.
bce502e
to
23d9022
Compare
Depends on #173.