about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-03-03 14:14:34 -0500
committerJune McEnroe <june@causal.agency>2021-03-03 14:14:34 -0500
commite446660084f93766a5b6b55ddbeef9023014a249 (patch)
tree5b44f5ee854c93463076688e27d20778b4d6a612
parentSandbox with unveil(2) and pledge(2) on OpenBSD (diff)
downloadbubger-e446660084f93766a5b6b55ddbeef9023014a249.tar.gz
bubger-e446660084f93766a5b6b55ddbeef9023014a249.zip
Output updated paths
-rw-r--r--README.727
-rw-r--r--archive.c3
-rw-r--r--archive.h1
-rw-r--r--bubger.112
-rw-r--r--concat.c5
-rw-r--r--export.c2
6 files changed, 28 insertions, 22 deletions
diff --git a/README.7 b/README.7
index 24b6863..30b72a3 100644
--- a/README.7
+++ b/README.7
@@ -50,27 +50,20 @@ can be run either by
 .Xr cron 8
 or under a process supervisor
 such as
-.Lk https://git.causal.agency/catsit/about catsit .
-The files required to serve the archive are
-.Pa index.* message/ thread/ attachment/ .
+.Lk https://git.causal.agency/catsit/about catsit
+using the
+.Fl i
+flag.
 .
 .Pp
-Under
-.Xr cron 8 ,
-the exit status of
+The list of updated paths
+output by
 .Xr bubger 1
+can be piped to
+.Xr rsync 1
 with the
-.Fl q
-flag can be used
-to determine if
-the archive was updated.
-Under a process supervisor
-with the
-.Fl i
-flag,
-writes to
-.Pa UIDNEXT
-indicate when the archive is updated.
+.Fl \-files\-from
+flag.
 .
 .Sh FILES
 .Bl -tag -width "getservinfo.c" -compact
diff --git a/archive.c b/archive.c
index cc6c182..1ef4f33 100644
--- a/archive.c
+++ b/archive.c
@@ -43,6 +43,7 @@
 
 #define ENV_PASSWORD "BUBGER_IMAP_PASSWORD"
 
+bool quiet;
 const char *baseURL = "";
 const char *baseTitle;
 const char *baseMailto;
@@ -108,7 +109,7 @@ int main(int argc, char *argv[]) {
 			break; case 'i': idle = true;
 			break; case 'm': baseMailto = optarg;
 			break; case 'p': port = optarg;
-			break; case 'q': exitStatus = EXIT_FAILURE;
+			break; case 'q': quiet = true; exitStatus = EXIT_FAILURE;
 			break; case 's': baseSubscribe = optarg;
 			break; case 't': baseTitle = optarg;
 			break; case 'u': baseURL = optarg;
diff --git a/archive.h b/archive.h
index 51dede8..29833e8 100644
--- a/archive.h
+++ b/archive.h
@@ -52,6 +52,7 @@
 
 extern const char Stylesheet[];
 
+extern bool quiet;
 extern const char *baseURL;
 extern const char *baseTitle;
 extern const char *baseMailto;
diff --git a/bubger.1 b/bubger.1
index 794303c..80392bb 100644
--- a/bubger.1
+++ b/bubger.1
@@ -1,4 +1,4 @@
-.Dd March  1, 2021
+.Dd March  3, 2021
 .Dt BUBGER 1
 .Os
 .
@@ -33,6 +33,8 @@ arranged into threads.
 It requires the IMAP SORT and THREAD extensions.
 Partial output is cached and reused
 by subsequent runs.
+The list of updated paths
+is written to standard output.
 .
 .Pp
 The arguments are as follows:
@@ -97,7 +99,9 @@ The default port is
 TLS without STARTTLS is assumed.
 .
 .It Fl q
-Exit non-zero if the mailbox has not changed.
+Suppress output of updated paths
+and exit non-zero
+if the mailbox has not changed.
 .
 .It Fl s Ar url
 Add a
@@ -169,8 +173,8 @@ Stores the mailbox UID validity.
 .
 .Sh EXAMPLES
 .Bd -literal
-bubger -q list@example.org \e
-&& rsync -a index.* message thread attachment example.org:public_html/
+bubger -C archive list@example.org |
+rsync -a --files-from=- archive example.org:public_html/archive
 .Ed
 .
 .Sh STANDARDS
diff --git a/concat.c b/concat.c
index bd41913..64e543f 100644
--- a/concat.c
+++ b/concat.c
@@ -170,6 +170,7 @@ static void concatThread(struct List thread, const struct Envelope *envelope) {
 
 		error = fclose(file);
 		if (error) err(EX_IOERR, "%s", path);
+		if (!quiet) printf("%s\n", path);
 	}
 	free(path);
 
@@ -192,6 +193,7 @@ static void concatThread(struct List thread, const struct Envelope *envelope) {
 
 		error = atomThreadClose(file) || fclose(file);
 		if (error) err(EX_IOERR, "%s", path);
+		if (!quiet) printf("%s\n", path);
 	}
 	free(path);
 
@@ -215,6 +217,7 @@ static void concatThread(struct List thread, const struct Envelope *envelope) {
 			|| htmlThreadClose(file)
 			|| fclose(file);
 		if (error) err(EX_IOERR, "%s", path);
+		if (!quiet) printf("%s\n", path);
 	}
 	free(path);
 
@@ -264,6 +267,7 @@ void concatIndex(struct List threads, const struct Envelope *envelopes) {
 
 	error = atomIndexClose(file) || fclose(file);
 	if (error) err(EX_IOERR, "%s", path);
+	if (!quiet) printf("%s\n", path);
 
 	struct Sort *order = calloc(threads.len, sizeof(*order));
 	if (!order) err(EX_OSERR, "calloc");
@@ -306,4 +310,5 @@ void concatIndex(struct List threads, const struct Envelope *envelopes) {
 
 	error = htmlIndexClose(file) || fclose(file);
 	if (error) err(EX_IOERR, "%s", path);
+	if (!quiet) printf("%s\n", path);
 }
diff --git a/export.c b/export.c
index d195104..ef1d526 100644
--- a/export.c
+++ b/export.c
@@ -106,6 +106,7 @@ static void exportMbox(
 	unlink(dest);
 	error = link(path, dest);
 	if (error) err(EX_CANTCREAT, "%s", dest);
+	if (!quiet) printf("%s\n", dest);
 
 	free(dest);
 	free(path);
@@ -212,6 +213,7 @@ static int exportHTMLAttachment(
 		|| decodeToFile(attachment, part, dataCheck(body, String).string)
 		|| fclose(attachment);
 	if (error) err(EX_IOERR, "%s", path);
+	if (!quiet) printf("%s\n", path);
 	free(path);
 
 	error = htmlAttachment(file, part, vars);