1/*++ 2/* NAME 3/* basename 3 4/* SUMMARY 5/* extract file basename 6/* SYNOPSIS 7/* #include <stringops.h> 8/* 9/* char *basename(path) 10/* const char *path; 11/* DESCRIPTION 12/* The \fBbasename\fR routine skips over the last '/' in 13/* \fIpath\fR and returns a pointer to the result. 14/* LICENSE 15/* .ad 16/* .fi 17/* The Secure Mailer license must be distributed with this software. 18/* AUTHOR(S) 19/* Wietse Venema 20/* IBM T.J. Watson Research 21/* P.O. Box 704 22/* Yorktown Heights, NY 10598, USA 23/*--*/ 24 25/* System library. */ 26 27#include <sys_defs.h> 28#include <string.h> 29 30#ifndef HAVE_BASENAME 31 32/* Utility library. */ 33 34#include "stringops.h" 35 36/* basename - skip directory prefix */ 37 38char *basename(const char *path) 39{ 40 char *result; 41 42 if ((result = strrchr(path, '/')) == 0) 43 result = (char *) path; 44 else 45 result += 1; 46 return (result); 47} 48 49#endif 50