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