summaryrefslogtreecommitdiffstats
path: root/plugins/utils.c
diff options
context:
space:
mode:
authorTon Voon <tonvoon@users.sourceforge.net>2006-04-27 13:25:10 +0000
committerTon Voon <tonvoon@users.sourceforge.net>2006-04-27 13:25:10 +0000
commit34cb16d283298885b73f75146433a703e93c0d4f (patch)
treec1e7b1b0ff0ad3e59e4921dd5e65d4527cd23d3f /plugins/utils.c
parent37ebbab7fbd251c4c357459ff738847f5a5a4883 (diff)
downloadmonitoring-plugins-34cb16d283298885b73f75146433a703e93c0d4f.tar.gz
Internal version of basename if one not found in system
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1383 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/utils.c')
-rw-r--r--plugins/utils.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/plugins/utils.c b/plugins/utils.c
index bb4ffbc2..f2593a16 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -5,6 +5,7 @@
5 * Library of useful functions for plugins 5 * Library of useful functions for plugins
6 * 6 *
7 * Copyright (c) 2000 Karl DeBisschop (karl@debisschop.net) 7 * Copyright (c) 2000 Karl DeBisschop (karl@debisschop.net)
8 * Copyright (c) 2006 Nagios Plugin Development Team
8 * License: GPL 9 * License: GPL
9 * 10 *
10 * $Revision$ 11 * $Revision$
@@ -639,6 +640,32 @@ strpcat (char *dest, const char *src, const char *str)
639 return dest; 640 return dest;
640} 641}
641 642
643#ifndef HAVE_BASENAME
644/* function modified from coreutils base_name function - see ACKNOWLEDGEMENTS */
645char *basename(const char *path) {
646 char const *base = path;
647 char const *p;
648 for (p = base; *p; p++) {
649 if (*p == '/') {
650 /* Treat multiple adjacent slashes like single slash */
651 do p++;
652 while (*p == '/');
653
654 /* If filename ends in slash, use trailing slash
655 as basename if no non-slashes found */
656 if (! *p) {
657 if (*base == '/')
658 base = p - 1;
659 break;
660 }
661
662 /* *p is non-slash preceded by slash */
663 base = p;
664 }
665 }
666 return (char *) base;
667}
668#endif
642 669
643/****************************************************************************** 670/******************************************************************************
644 * 671 *