summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/sendbug/sendbug.16
-rw-r--r--usr.bin/sendbug/sendbug.c29
2 files changed, 31 insertions, 4 deletions
diff --git a/usr.bin/sendbug/sendbug.1 b/usr.bin/sendbug/sendbug.1
index 7fc9771795d..e94f8dd5e89 100644
--- a/usr.bin/sendbug/sendbug.1
+++ b/usr.bin/sendbug/sendbug.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: sendbug.1,v 1.2 2007/03/23 02:45:40 deraadt Exp $
+.\" $OpenBSD: sendbug.1,v 1.3 2007/03/23 03:35:01 deraadt Exp $
.\"
.\" Written by Raymond Lai <ray@cyth.net>.
.\" Public domain.
@@ -57,6 +57,10 @@ the default is
Specifies a directory for temporary files to be created.
The default is
.Pa /tmp .
+.It Ev PR_FORM
+Filename of PR form to use instead of using the built-in form.
+Such a PR form can be partially pre-completed to make the
+process faster.
.El
.Sh AUTHORS
.Nm
diff --git a/usr.bin/sendbug/sendbug.c b/usr.bin/sendbug/sendbug.c
index d1cfa12dbae..fb1e63ac43d 100644
--- a/usr.bin/sendbug/sendbug.c
+++ b/usr.bin/sendbug/sendbug.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sendbug.c,v 1.9 2007/03/23 03:30:52 ray Exp $ */
+/* $OpenBSD: sendbug.c,v 1.10 2007/03/23 03:35:01 deraadt Exp $ */
/*
* Written by Ray Lai <ray@cyth.net>.
@@ -47,7 +47,7 @@ int
main(int argc, char *argv[])
{
const char *editor, *tmpdir;
- char *argp[] = {"sh", "-c", NULL, NULL}, *tmppath = NULL;
+ char *argp[] = {"sh", "-c", NULL, NULL}, *tmppath = NULL, *pr_form;
int ch, c, fd, ret = 1;
struct stat sb;
time_t mtime;
@@ -94,7 +94,30 @@ main(int argc, char *argv[])
if (init() == -1)
goto cleanup;
- template(fp);
+ pr_form = getenv("PR_FORM");
+ if (pr_form) {
+ char buf[BUFSIZ];
+ size_t len;
+ FILE *frfp;
+
+ frfp = fopen(pr_form, "r");
+ if (frfp == NULL) {
+ fprintf(stderr, "sendbug: can't seem to read your"
+ " template file (`%s'), ignoring PR_FORM\n",
+ pr_form);
+ template(fp);
+ } else {
+ while (!feof(frfp)) {
+ len = fread(buf, 1, sizeof buf, frfp);
+ if (len == 0)
+ break;
+ if (fwrite(buf, 1, len, fp) != len)
+ break;
+ }
+ fclose(frfp);
+ }
+ } else
+ template(fp);
if (fflush(fp) == EOF || fstat(fd, &sb) == -1 || fclose(fp) == EOF) {
warn("error creating template");