X-Git-Url: https://git.distorted.org.uk/~mdw/xtoys/blobdiff_plain/2b6e1eca160e4ee835c26c4b1d6cf67552707413..4954eef226519a87cd932f72f2119d1866153619:/xmsg.c diff --git a/xmsg.c b/xmsg.c index 23336a9..edce12a 100644 --- a/xmsg.c +++ b/xmsg.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: xmsg.c,v 1.1 2002/01/13 14:42:18 mdw Exp $ + * $Id$ * * Display a message to the user * @@ -26,14 +26,6 @@ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/*----- Revision history --------------------------------------------------* - * - * $Log: xmsg.c,v $ - * Revision 1.1 2002/01/13 14:42:18 mdw - * New program to display messages and get answers. - * - */ - /*----- Header files ------------------------------------------------------*/ #include @@ -116,6 +108,7 @@ int main(int argc, char *argv[]) button_v bv = DA_INIT; button *b; dstr d = DSTR_INIT; + dstr msgbuf = DSTR_INIT; size_t n, i; unsigned f = 0; @@ -201,6 +194,24 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } message = argv[optind++]; + if (*message == '%') + message++; + else if (strcmp(message, "-") == 0) { + for (;;) { + size_t n; + + dstr_ensure(&msgbuf, 4096); + n = fread(msgbuf.buf + msgbuf.len, 1, + msgbuf.sz - msgbuf.len, stdin); + if (!n) + break; + msgbuf.len += n; + } + if (msgbuf.len && msgbuf.buf[msgbuf.len - 1]) + msgbuf.len--; + dstr_putz(&msgbuf); + message = msgbuf.buf; + } if (optind >= argc) { DA_ENSURE(&bv, 1);