[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

procps: Regarding FROM field in "w" command



Hi,

The "FROM" field in output of "w" command prints the value of the remote-host. But the output for this field can contain just 16 characters as depicted in the code snippet (taken from w.c, release 3.2.8) below.
This truncates the value in case FROM field is an IPV6 address or a hostname. Is there any specific reason that this is limited to 16 chars only?  


/* This routine is careful since some programs leave utmp strings
 * unprintable.  Always outputs at least 16 chars padded with spaces
 * on the right if necessary.
 */
static void print_host(const char *restrict host, int len) {
    const char *last;
    int width = 0;

    /* FIXME: there should really be a way to configure this... */
    /* for now, we'll just limit it to the 16 that the libc5 version
     * of utmp uses.
     */
    if (len > 16) len = 16;
    last = host + len;
    for ( ; host < last ; host++){
        if (isprint(*host) && *host != ' ') {
            fputc(*host, stdout);
            ++width;
        } else {
            break;
        }
    }
    // space-fill, and a '-' too if needed to ensure the column exists
    if(width < 16) fputs("-               "+width, stdout);
}


Thanks.


Regards,
Navdeep

Reply to: