Karl was right: realpath() is pretty much what I wanted:


#include <stdio.h>
#include <string.h>


/*
 * ----------------------------------------------------------------------------
 * Read lines from stdin, assume they're pathnames, attempt
 * to convert them to their "canonical" form, print canonical
 * version if successful else just echo unconverted input.
 */
int
main(
    int    argc,
    char **argv  )
{
    char   pathname[  102400 ];
    char   canonical[ 102400 ];
    char  *ptr;


    while( fgets( pathname, (sizeof( pathname ) - 1), stdin )  )  {
        ptr = strchr( pathname, '\n' );
        if( ptr )  {
            *ptr = 0;
        }

        if( realpath( pathname, canonical )  )  {
            ptr = canonical;
        } else  {
            ptr = pathname;
        }
        printf( "%s\n", ptr );
    }

    return( 0 );
}



**********************************************************
To unsubscribe from this list, send mail to
[EMAIL PROTECTED] with the following text in the
*body* (*not* the subject line) of the letter:
unsubscribe gnhlug
**********************************************************

Reply via email to