Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

DerDakon
Copy link
Member

Depends on #173.

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.
Copy link

@josuah josuah left a 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 Show resolved Hide resolved
qmail-remote.c Outdated
Comment on lines 288 to 302
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");
}
Copy link

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.

Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants