On 3 Apr 2002, Jered Floyd wrote:
Simon Josefsson <jas(a)extundo.com> writes:
> However, recent Cyrus IMAPD imtest uses some other approach, so it works
> better. Please try it. (I don't remember whether the approach was to not
> use fgets() or set the terminal into returning character-by-characters
> instead of line-by-line.)
The imtest included in cyrus-imapd 2.1.3 which was released 7 Mar 2002
doesn't seem to do this:
if (fgets(buf, sizeof (buf) - 1, stdin) == NULL) {
printf(LOGOUT);
prot_write(pout, LOGOUT, sizeof (LOGOUT));
FD_CLR(0, &read_set);
} else {
count = strlen(buf);
buf[count - 1] = '\r';
buf[count] = '\n';
buf[count + 1] = '\0';
prot_write(pout, buf, count + 1);
}
The solution used the other approach then, not buffering stdin/stoud. Did
you try it?
Index: imtest.c
===================================================================
RCS file: /cvs/src/cyrus/imtest/imtest.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -r1.60 -r1.61
--- imtest.c 2001/02/19 19:32:06 1.60
+++ imtest.c 2001/02/28 02:44:32 1.61
@@ -1185,6 +1185,11 @@
int run_stress_test=0;
int dotls=0;
int server_supports_tls;
+
+ /* do not buffer */
+ setbuf(stdin, NULL);
+ setbuf(stdout, NULL);
+ setbuf(stderr, NULL);
/* look at all the extra args */
while ((c = getopt(argc, argv, "zvk:l:p:u:a:m:f:r:t:")) != EOF)
However this seems like an easy fix... if what fgets reads in
doesn't
end in a \n, don't make the last chars \r\n. I'll send a patch to the
cyrus people later.
Their current approach isn't too unreasonable, it converts from the
IMAP/TCP eol character to the tty eol character. However, it would be the
wrong thing under Windows, but I doubt it build under Windows anyway.