/* -*-c-*-
*
- * $Id: xmsg.c,v 1.1 2002/01/13 14:42:18 mdw Exp $
+ * $Id$
*
* Display a message to the user
*
* 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 <ctype.h>
button_v bv = DA_INIT;
button *b;
dstr d = DSTR_INIT;
+ dstr msgbuf = DSTR_INIT;
size_t n, i;
unsigned f = 0;
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);