[Nagiosplug-checkins] nagiosplug/plugins check_procs.c,1.48,1.49 utils.c,1.46,1.47 utils.h,1.28,1.29
Ton Voon
tonvoon at users.sourceforge.net
Thu Apr 27 06:26:04 CEST 2006
Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13938/plugins
Modified Files:
check_procs.c utils.c utils.h
Log Message:
Internal version of basename if one not found in system
Index: check_procs.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_procs.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- check_procs.c 5 Apr 2006 08:06:19 -0000 1.48
+++ check_procs.c 27 Apr 2006 13:25:09 -0000 1.49
@@ -96,9 +96,6 @@
char procstat[8];
char procetime[MAX_INPUT_BUFFER] = { '\0' };
char *procargs;
-#ifdef HAVE_BASENAME
- char *temp_string;
-#endif
const char *zombie = "Z";
@@ -179,10 +176,7 @@
strip (procargs);
/* Some ps return full pathname for command. This removes path */
-#ifdef HAVE_BASENAME
- temp_string = strdup(procprog);
- procprog = basename(temp_string);
-#endif /* HAVE_BASENAME */
+ procprog = basename(procprog);
/* we need to convert the elapsed time to seconds */
procseconds = convert_to_seconds(procetime);
Index: utils.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/utils.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- utils.c 6 Apr 2006 10:08:57 -0000 1.46
+++ utils.c 27 Apr 2006 13:25:09 -0000 1.47
@@ -5,6 +5,7 @@
* Library of useful functions for plugins
*
* Copyright (c) 2000 Karl DeBisschop (karl at debisschop.net)
+ * Copyright (c) 2006 Nagios Plugin Development Team
* License: GPL
*
* $Revision$
@@ -639,6 +640,32 @@
return dest;
}
+#ifndef HAVE_BASENAME
+/* function modified from coreutils base_name function - see ACKNOWLEDGEMENTS */
+char *basename(const char *path) {
+ char const *base = path;
+ char const *p;
+ for (p = base; *p; p++) {
+ if (*p == '/') {
+ /* Treat multiple adjacent slashes like single slash */
+ do p++;
+ while (*p == '/');
+
+ /* If filename ends in slash, use trailing slash
+ as basename if no non-slashes found */
+ if (! *p) {
+ if (*base == '/')
+ base = p - 1;
+ break;
+ }
+
+ /* *p is non-slash preceded by slash */
+ base = p;
+ }
+ }
+ return (char *) base;
+}
+#endif
/******************************************************************************
*
Index: utils.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/utils.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- utils.h 29 Mar 2006 16:33:36 -0000 1.28
+++ utils.h 27 Apr 2006 13:25:09 -0000 1.29
@@ -80,6 +80,9 @@
int check_range(double, range *);
int get_status(double, thresholds *);
+/* I think this needs to be defined even if you use the system version */
+char *basename(const char *path);
+
#ifndef HAVE_GETTIMEOFDAY
int gettimeofday(struct timeval *, struct timezone *);
#endif
More information about the Commits
mailing list