/* * Copyright (c) 2000 David Parsons. All rights reserved. * * This software is released under a berkeley-style copyright; the * details can be found in the file COPYRIGHT. */ #include /* * ask for a message */ void why_why_why_are_we(char *reason, char *msg, int len) { char *tail = msg; if (isatty(0)) printf("What is %s [%d bytes or less],\n" "terminated with single ``.'' or end of file:\n", reason, len); while (1) { if (isatty(0)) { printf("%4d> ", len - (tail-msg)); fflush(stdout); } if (fgets(tail, len-(msg-tail),stdin) == NULL) break; if (tail[0] == '.' && tail[1] == '\n') break; tail += strlen(tail); if (tail[-1] == '\n') { tail[-1] = '\r'; tail[0] = '\n'; tail++; } if (tail == msg+len) error("message too long -- please keep it under %d bytes", len); } *tail = 0; } /* why_why_why_are_we */