From 11133da587ebc1c78478cfcd05d5e8298bd61b84 Mon Sep 17 00:00:00 2001 From: Chantry Xavier Date: Sun, 25 Nov 2007 16:13:30 -0600 Subject: Move mbasename from pacman.c to util.c This function can be useful in other places. Signed-off-by: Chantry Xavier Signed-off-by: Dan McGee --- src/pacman/pacman.c | 22 ---------------------- src/pacman/util.c | 22 ++++++++++++++++++++++ src/pacman/util.h | 1 + 3 files changed, 23 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 4c24d10b..3f4af22c 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -229,28 +229,6 @@ static void cleanup(int signum) exit(signum); } -/** 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 '/' -*/ -static char *mbasename(const char *path) -{ - const char *s; - const char *p; - - p = s = path; - - while (*s) { - if (*s++ == '/') { - p = s; - } - } - - return (char *)p; -} - /** Parse command-line arguments for each operation. * @param argc argc * @param argv argv 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) diff --git a/src/pacman/util.h b/src/pacman/util.h index 931b456b..e46555e0 100644 --- a/src/pacman/util.h +++ b/src/pacman/util.h @@ -42,6 +42,7 @@ int needs_transaction(); int getcols(); int makepath(const char *path); int rmrf(const char *path); +char *mbasename(const char *path); void indentprint(const char *str, int indent); char *strtoupper(char *str); char *strtrim(char *str); -- cgit v1.2.3-24-g4f1b