From 597682ea063f1548d8d35e8b2ec0f8c971774af6 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Fri, 4 Dec 2020 00:44:52 -0500 Subject: Infer hostname from username --- archive.c | 13 +++++++++---- bubger.1 | 29 ++++++++++++++++------------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/archive.c b/archive.c index e0ad6ad..ca218af 100644 --- a/archive.c +++ b/archive.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -88,15 +89,16 @@ int main(int argc, char *argv[]) { const char *algo = "REFERENCES"; const char *search = "ALL"; - for (int opt; 0 < (opt = getopt(argc, argv, "C:S:a:h:m:p:qs:t:u:vw:y:"));) { + for (int opt; 0 < (opt = getopt(argc, argv, "C:H:S:a:h:m:p:qs:t:u:vw:y:"));) { switch (opt) { break; case 'C': { int error = chdir(optarg); if (error) err(EX_NOINPUT, "%s", optarg); } + break; case 'H': concatHead = optarg; break; case 'S': search = optarg; break; case 'a': algo = optarg; - break; case 'h': concatHead = optarg; + break; case 'h': host = optarg; break; case 'm': baseMailto = optarg; break; case 'p': port = optarg; break; case 'q': exitStatus = EXIT_FAILURE; @@ -108,12 +110,15 @@ int main(int argc, char *argv[]) { break; case 'y': baseStylesheet = optarg; } } - if (optind < argc) host = argv[optind++]; if (optind < argc) user = argv[optind++]; if (optind < argc) mailbox = argv[optind++]; - if (!host) errx(EX_USAGE, "host required"); if (!user) errx(EX_USAGE, "user required"); + if (!host) { + host = strchr(user, '@'); + if (!host) errx(EX_USAGE, "host required"); + host++; + } if (!baseTitle) baseTitle = mailbox; if (!baseMailto) baseMailto = user; diff --git a/bubger.1 b/bubger.1 index e83ff8a..d31f9b4 100644 --- a/bubger.1 +++ b/bubger.1 @@ -10,9 +10,10 @@ .Nm .Op Fl qv .Op Fl C Ar path +.Op Fl H Ar head .Op Fl S Ar search .Op Fl a Ar algo -.Op Fl h Ar head +.Op Fl h Ar host .Op Fl m Ar addr .Op Fl p Ar port .Op Fl s Ar url @@ -20,7 +21,6 @@ .Op Fl u Ar base .Op Fl w Ar file .Op Fl y Ar css -.Ar host .Ar user .Op Ar mailbox . @@ -43,6 +43,13 @@ Change directory to .Ar path before reading and writing files. . +.It Fl H Ar head +Append the contents of the file +.Ar head +to the +.Sy +element of HTML pages. +. .It Fl S Ar search Limit threads to messages matching .Ar search . @@ -57,12 +64,12 @@ or The default algorithm is .Sy REFERENCES . . -.It Fl h Ar head -Append the contents of the file -.Ar head -to the -.Sy -element of HTML pages. +.It Fl h Ar host +Connect to IMAP on +.Ar host . +The default host is determined by +SRV record lookup on the domain name of +.Ar user . . .It Fl m Ar addr Set the mailto and reply Cc address for the archive. @@ -109,10 +116,6 @@ Use the stylesheet URL .Ar css . The default is an inline stylesheet. . -.It Ar host -Connect to IMAP on -.Ar host . -. .It Ar user Log in to IMAP as .Ar user . @@ -154,7 +157,7 @@ Stores the mailbox UID validity. . .Sh EXAMPLES .Bd -literal -bubger -q imap.example.org list@example.org \e +bubger -q list@example.org \e && rsync -a index.* message thread attachment example.org:public_html/ .Ed . -- cgit 1.4.1