Annotation of coherent/g/usr/lib/misc/basename.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * basename.c - find the rightmost component of a pathname.
                      3:  */
                      4: #include <stdio.h>
                      5: 
                      6: /*
                      7:  * Return a pointer to the basename of a full path (everthing to the
                      8:  * right of the rightmost '/'.
                      9:  */
                     10: char *
                     11: basename(path)
                     12: char *path;
                     13: {
                     14:        char *retval;
                     15:        extern char *strrchr();
                     16: 
                     17:        if (NULL == path)
                     18:                return(NULL);
                     19:        return ((NULL == (retval = strrchr(path, '/'))) ? path : (retval + 1));
                     20: } /* basename() */
                     21: 
                     22: #ifdef TEST
                     23: 
                     24: main(argc, argv)
                     25: int argc;
                     26: char *argv[];
                     27: {
                     28:        while (--argc > 0)
                     29:                printf("%s\n", basename(argv[argc]));
                     30: } /* main() */
                     31: 
                     32: #endif /* TEST */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.