diff --git a/usr.sbin/pkg_install/lib/lib.h b/usr.sbin/pkg_install/lib/lib.h index 31bd696b8631..b9f6a15efec2 100644 --- a/usr.sbin/pkg_install/lib/lib.h +++ b/usr.sbin/pkg_install/lib/lib.h @@ -1,4 +1,4 @@ -/* $Id: lib.h,v 1.9 1994/09/29 13:19:42 jkh Exp $ */ +/* $Id: lib.h,v 1.10 1994/10/04 16:07:50 jkh Exp $ */ /* * FreeBSD install - a package for the installation and maintainance @@ -109,6 +109,7 @@ char *copy_string(char *); Boolean suffix(char *, char *); void nuke_suffix(char *); void str_lowercase(char *); +char *basename_of(char *); /* File */ Boolean fexists(char *); diff --git a/usr.sbin/pkg_install/lib/str.c b/usr.sbin/pkg_install/lib/str.c index 8d68f9291f1d..7c61f96f67bf 100644 --- a/usr.sbin/pkg_install/lib/str.c +++ b/usr.sbin/pkg_install/lib/str.c @@ -24,6 +24,18 @@ static const char *rcsid = "$Id"; #include "lib.h" +/* Return the filename portion of a path */ +char * +basename_of(char *str) +{ + char *basename = str + strlen(str) - 1; + + while (basename != str && basename[-1] != '/') + --basename; + return basename; +} + +/* Get a string parameter as a file spec or as a "contents follow -" spec */ char * get_dash_string(char **str) { @@ -36,6 +48,7 @@ get_dash_string(char **str) return *str; } +/* Rather Obvious */ char * copy_string(char *str) {