Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=5d140f8aba2c4752f7d7b735c9bcd9f7ce71289f

commit 5d140f8aba2c4752f7d7b735c9bcd9f7ce71289f
Author: Michel Hermier <[email protected]>
Date:   Thu Dec 12 19:16:19 2013 +0100

libpacman: Rename _pacman_basename to f_basename and move it to fstring. Add 
f_dirname while at it.

diff --git a/lib/libpacman/CMakeLists.txt b/lib/libpacman/CMakeLists.txt
index 474612a..93e0ce9 100644
--- a/lib/libpacman/CMakeLists.txt
+++ b/lib/libpacman/CMakeLists.txt
@@ -6,6 +6,8 @@ CONFIGURE_FILE("pacman.pc.in" "pacman.pc" @ONLY)

set(FLIB_SOURCES
fstdlib/canonicalize.c
+       fstring/basename.c
+       fstring/dirname.c
hash/md5.c
hash/md5driver.c
hash/sha1.c
diff --git a/lib/libpacman/fstring.h b/lib/libpacman/fstring.h
index 2cebd32..fcb53eb 100644
--- a/lib/libpacman/fstring.h
+++ b/lib/libpacman/fstring.h
@@ -25,6 +25,9 @@

#include "util/fcallback.h"

+char *f_basename(const char *path);
+char *f_dirname(const char *path);
+
static inline
int f_strempty(const char *s)
{
diff --git a/lib/libpacman/fstring/basename.c b/lib/libpacman/fstring/basename.c
new file mode 100644
index 0000000..13ca6a0
--- /dev/null
+++ b/lib/libpacman/fstring/basename.c
@@ -0,0 +1,40 @@
+/*
+ *  basename.c
+ *
+ *  Copyright (c) 2013 by Michel Hermier <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ *  USA.
+ */
+
+#include "config.h"
+
+#include <libgen.h> // Must be before string.h
+
+#include "fstring.h"
+
+#include <limits.h>
+
+char *f_basename(const char *path)
+{
+       static char buffer[PATH_MAX];
+
+       ASSERT(!_pacman_strempty(path), RET_ERR(PM_ERR_WRONG_ARGS, NULL));
+
+       STRNCPY(buffer, path, sizeof(buffer));
+       return basename(buffer);
+}
+
+/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libpacman/fstring/dirname.c b/lib/libpacman/fstring/dirname.c
new file mode 100644
index 0000000..2259fd0
--- /dev/null
+++ b/lib/libpacman/fstring/dirname.c
@@ -0,0 +1,40 @@
+/*
+ *  dirname.c
+ *
+ *  Copyright (c) 2013 by Michel Hermier <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ *  USA.
+ */
+
+#include "config.h"
+
+#include <libgen.h> // Must be before string.h
+
+#include "fstring.h"
+
+#include <limits.h>
+
+char *f_dirname(const char *path)
+{
+       static char buffer[PATH_MAX];
+
+       ASSERT(!_pacman_strempty(path), RET_ERR(PM_ERR_WRONG_ARGS, NULL));
+
+       STRNCPY(buffer, path, sizeof(buffer));
+       return dirname(buffer);
+}
+
+/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libpacman/util.c b/lib/libpacman/util.c
index 5ed1827..3e4b462 100644
--- a/lib/libpacman/util.c
+++ b/lib/libpacman/util.c
@@ -121,16 +121,6 @@ char * mkdtemp(char *template)
}
#endif

-char *_pacman_basename(const char *path)
-{
-       static char buffer[PATH_MAX];
-
-       ASSERT(!_pacman_strempty(path), RET_ERR(PM_ERR_WRONG_ARGS, NULL));
-
-       STRNCPY(buffer, path, sizeof(buffer));
-       return basename(buffer);
-}
-
/* does the same thing as 'mkdir -p' */
int _pacman_makepath(const char *path)
{
diff --git a/lib/libpacman/util.h b/lib/libpacman/util.h
index f162a47..3af143c 100644
--- a/lib/libpacman/util.h
+++ b/lib/libpacman/util.h
@@ -52,7 +52,7 @@
#define STARTSTR "START "
#define DONESTR "DONE "

-char *_pacman_basename(const char *path);
+#define _pacman_basename f_basename
int _pacman_makepath(const char *path);
int _pacman_copyfile(char *src, char *dest);
int _pacman_lckmk(char *file);
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to