summaryrefslogtreecommitdiffstats
path: root/plugins/utils.c
diff options
context:
space:
mode:
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 *