[Nut-upsdev] minor building issues (svn HEAD revision 427)

Peter Selinger selinger at mathstat.dal.ca
Sat Jun 3 18:51:21 UTC 2006


Why not simply declare the setenv function static? This way it will
not upset the linker, and would still use the system-provided function
if available. Would the below patch work for you? -- Peter

Mike Patterson wrote:
> 
> Charles Lepple wrote on 5/20/06 10:10 AM:
> > I will look at the autoconf stuff later to see if there is an easy way
> > to try and use netsnmp's setenv call (since it looks like the standard
> > one, from a quick glance at snmplib/system.c).
> 
> Sure, if I have some time in the next couple of days I'll look too,
> although I'm no autoconf expert.
> 
> What about just renaming the function though?

Index: include/proto.h
===================================================================
--- include/proto.h	(revision 428)
+++ include/proto.h	(working copy)
@@ -1,3 +1,6 @@
+#ifndef PROTO_H
+#define PROTO_H
+
 #include "attribute.h"
 
 #if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF)
@@ -36,7 +39,10 @@
 #endif
 
 #ifndef HAVE_SETENV
-int setenv(const char *name, const char *value, int overwrite);
+int nut_setenv(const char *name, const char *value, int overwrite);
+static inline int setenv(const char *name, const char *value, int overwrite) {
+	return nut_setenv(name, value, overwrite);
+}
 #endif
 
 #ifdef __hpux
@@ -59,3 +65,5 @@
 #else
 #define GETPASS getpass
 #endif
+
+#endif /* PROTO_H */
Index: common/setenv.c
===================================================================
--- common/setenv.c	(revision 428)
+++ common/setenv.c	(working copy)
@@ -4,7 +4,7 @@
 #include <string.h>
 #include "common.h"
 
-int setenv(const char *name, const char *value, int overwrite)
+int nut_setenv(const char *name, const char *value, int overwrite)
 {
 	char	*val;
 	char	*buffer;




More information about the Nut-upsdev mailing list