diff options
author | Chantry Xavier <shiningxc@gmail.com> | 2007-11-25 16:13:30 -0600 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2007-11-25 16:13:30 -0600 |
commit | 11133da587ebc1c78478cfcd05d5e8298bd61b84 (patch) | |
tree | e97f332ff9fa5ed765149693eec6db6917254278 /src/pacman/util.c | |
parent | 7d37d9278d0ab6eb46ec4689c8091780382cbb95 (diff) |
Move mbasename from pacman.c to util.c
This function can be useful in other places.
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'src/pacman/util.c')
-rw-r--r-- | src/pacman/util.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/pacman/util.c b/src/pacman/util.c index 77773bf5..a925be36 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -167,6 +167,28 @@ int rmrf(const char *path) } } +/** Parse the basename of a program from a path. +* Grabbed from the uClibc source. +* @param path path to parse basename from +* +* @return everything following the final '/' +*/ +char *mbasename(const char *path) +{ + const char *s; + const char *p; + + p = s = path; + + while (*s) { + if (*s++ == '/') { + p = s; + } + } + + return (char *)p; +} + /* output a string, but wrap words properly with a specified indentation */ void indentprint(const char *str, int indent) |