[DGD] comm_write question

pete at ana.sk pete at ana.sk
Thu Jan 3 14:32:14 CET 2002


Hi

A question about IAC handling in comm_write (comm.c): as far as i can 
understand, IAC is handled as normal output character by duplicating it, 
which is normal telnet protocol behaviour. What i dont fully underastand is 
IAC condition in if at the beggining and then inside for in the snippet below. 
Apparently the IAC is being sent only as first char of string, and sending 
breaks any other one (which is actually working since connection object is 
handling partial sends). Is there any reason for it be this way (maybe some 
broken clients)?

snippet from comm.c:

        for (;;) {
            if (len == 0 || size >= OUTBUF_SIZE - 1 || UCHAR(*p) == IAC) {
                n = comm_write(usr, obj, (string *) NULL, outbuf, size);
                if (n != size) {
                    /*
                     * count how many bytes of original string were written
                     */
                    for (n = size - n; n != 0; --n) {
                        if (*--p == *--q) {
                            len++;
                            if (UCHAR(*p) == IAC) {
                                break;
                            }
                        } else if (*q == CR) {
                            /* inserted CR */
                            p++;
                        } else {
                            /* skipped char */
                            q++;
                            len++;
                        }
                    }
                    return str->len - len;
                }
                if (len == 0) {
                    return str->len;
                }
                size = 0;
                q = outbuf;
            }
            if (UCHAR(*p) == IAC) {
                /*
                 * double the telnet IAC character
                 */
                *q++ = (char) IAC;
                size++;
            } else if (*p == LF) {

Pete

_________________________________________________________________
List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list