diff options
author | June McEnroe <june@causal.agency> | 2020-12-04 00:44:52 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-12-04 17:45:06 -0500 |
commit | 597682ea063f1548d8d35e8b2ec0f8c971774af6 (patch) | |
tree | 1ae8504f6b1a3fcc57f3a6663d2f166ebf965042 /archive.c | |
parent | Add DNS and SRV RFCs to STANDARDS (diff) | |
download | bubger-597682ea063f1548d8d35e8b2ec0f8c971774af6.tar.gz bubger-597682ea063f1548d8d35e8b2ec0f8c971774af6.zip |
Infer hostname from username
Diffstat (limited to '')
-rw-r--r-- | archive.c | 13 |
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; |