summary refs log tree commit diff
path: root/archive.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--archive.c13
1 files changed, 9 insertions, 4 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;