summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-12-04 00:44:52 -0500
committerJune McEnroe <june@causal.agency>2020-12-04 17:45:06 -0500
commit597682ea063f1548d8d35e8b2ec0f8c971774af6 (patch)
tree1ae8504f6b1a3fcc57f3a6663d2f166ebf965042
parentAdd DNS and SRV RFCs to STANDARDS (diff)
downloadbubger-597682ea063f1548d8d35e8b2ec0f8c971774af6.tar.gz
bubger-597682ea063f1548d8d35e8b2ec0f8c971774af6.zip
Infer hostname from username
Diffstat (limited to '')
-rw-r--r--archive.c13
-rw-r--r--bubger.129
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 <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <sys/stat.h>
 #include <sysexits.h>
 #include <unistd.h>
@@ -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 <head>
+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 <head>
-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
 .