7 changed files with 587 additions and 69 deletions
@ -0,0 +1,157 @@
|
||||
/*
|
||||
** cdefs.h: ISO C interface |
||||
** Most of this file was developed by Sendmail, Incorporated, so: |
||||
** |
||||
** Copyright (c) 2000-2002 Sendmail, Inc. and its suppliers. |
||||
** |
||||
** Permission to use, copy, modify, and distribute this software for |
||||
** any purpose with or without fee is hereby granted, provided that |
||||
** the above copyright notice and this permission notice appear in all |
||||
** copies. |
||||
** |
||||
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
||||
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
||||
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR |
||||
** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
||||
** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
||||
** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
||||
** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
||||
** OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
||||
** SUCH DAMAGE. |
||||
** |
||||
*/ |
||||
|
||||
/*
|
||||
** libsm C language portability macros |
||||
** See libsm/cdefs.html for documentation. |
||||
*/ |
||||
|
||||
#ifndef HOND_CDEFS_H |
||||
# define HOND_CDEFS_H |
||||
|
||||
/*
|
||||
** BSD and Linux have <sys/cdefs.h> which defines a set of C language |
||||
** portability macros that are a defacto standard in the open source |
||||
** community. |
||||
*/ |
||||
|
||||
# if HOND_CONF_SYS_CDEFS_H |
||||
# include <sys/cdefs.h> |
||||
# endif /* HOND_CONF_SYS_CDEFS_H */ |
||||
|
||||
/*
|
||||
** Define the standard C language portability macros |
||||
** for platforms that lack <sys/cdefs.h>. |
||||
*/ |
||||
|
||||
# if !HOND_CONF_SYS_CDEFS_H |
||||
# if defined(__cplusplus) |
||||
# define __BEGIN_DECLS extern "C" { |
||||
# define __END_DECLS }; |
||||
# else /* defined(__cplusplus) */ |
||||
# define __BEGIN_DECLS |
||||
# define __END_DECLS |
||||
# endif /* defined(__cplusplus) */ |
||||
# if defined(__STDC__) || defined(__cplusplus) |
||||
# ifndef __P |
||||
# define __P(protos) protos |
||||
# endif /* __P */ |
||||
# define __CONCAT(x,y) x ## y |
||||
# define __STRING(x) #x |
||||
# else /* defined(__STDC__) || defined(__cplusplus) */ |
||||
# define __P(protos) () |
||||
# define __CONCAT(x,y) x/**/y |
||||
# define __STRING(x) "x" |
||||
# define const |
||||
# define signed |
||||
# define volatile |
||||
# endif /* defined(__STDC__) || defined(__cplusplus) */ |
||||
# endif /* !HOND_CONF_SYS_CDEFS_H */ |
||||
|
||||
/*
|
||||
** Define HOND_DEAD, a macro used to declare functions that do not return |
||||
** to their caller. |
||||
*/ |
||||
|
||||
# ifndef HOND_DEAD |
||||
# if __GNUC__ >= 2 |
||||
# if __GNUC__ == 2 && __GNUC_MINOR__ < 5 |
||||
# define HOND_DEAD(proto) volatile proto |
||||
# else /* __GNUC__ == 2 && __GNUC_MINOR__ < 5 */ |
||||
# define HOND_DEAD(proto) proto __attribute__((__noreturn__)) |
||||
# endif /* __GNUC__ == 2 && __GNUC_MINOR__ < 5 */ |
||||
# else /* __GNUC__ >= 2 */ |
||||
# define HOND_DEAD(proto) proto |
||||
# endif /* __GNUC__ >= 2 */ |
||||
# endif /* HOND_DEAD */ |
||||
|
||||
/*
|
||||
** Define HOND_UNUSED, a macro used to declare variables that may be unused. |
||||
*/ |
||||
|
||||
# ifndef HOND_UNUSED |
||||
# if __GNUC__ >= 2 |
||||
# if __GNUC__ == 2 && __GNUC_MINOR__ < 7 |
||||
# define HOND_UNUSED(decl) decl |
||||
# else /* __GNUC__ == 2 && __GNUC_MINOR__ < 7 */ |
||||
# define HOND_UNUSED(decl) decl __attribute__((__unused__)) |
||||
# endif /* __GNUC__ == 2 && __GNUC_MINOR__ < 7 */ |
||||
# else /* __GNUC__ >= 2 */ |
||||
# define HOND_UNUSED(decl) decl |
||||
# endif /* __GNUC__ >= 2 */ |
||||
# endif /* HOND_UNUSED */ |
||||
|
||||
/*
|
||||
** The HOND_NONVOLATILE macro is used to declare variables that are not |
||||
** volatile, but which must be declared volatile when compiling with |
||||
** gcc -O -Wall in order to suppress bogus warning messages. |
||||
** |
||||
** Variables that actually are volatile should be declared volatile |
||||
** using the "volatile" keyword. If a variable actually is volatile, |
||||
** then HOND_NONVOLATILE should not be used. |
||||
** |
||||
** To compile sendmail with gcc and see all non-bogus warnings, |
||||
** you should use |
||||
** gcc -O -Wall -DHOND_OMIT_BOGUS_WARNINGS ... |
||||
** Do not use -DHOND_OMIT_BOGUS_WARNINGS when compiling the production |
||||
** version of sendmail, because there is a performance hit. |
||||
*/ |
||||
|
||||
# ifdef HOND_OMIT_BOGUS_WARNINGS |
||||
# define HOND_NONVOLATILE volatile |
||||
# else /* HOND_OMIT_BOGUS_WARNINGS */ |
||||
# define HOND_NONVOLATILE |
||||
# endif /* HOND_OMIT_BOGUS_WARNINGS */ |
||||
|
||||
/*
|
||||
** Turn on format string argument checking. |
||||
*/ |
||||
|
||||
# ifndef HOND_CONF_FORMAT_TEST |
||||
# if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 |
||||
# define HOND_CONF_FORMAT_TEST 1 |
||||
# else /* __GNUC__ == 2 && __GNUC_MINOR__ >= 7 */ |
||||
# define HOND_CONF_FORMAT_TEST 0 |
||||
# endif /* __GNUC__ == 2 && __GNUC_MINOR__ >= 7 */ |
||||
# endif /* HOND_CONF_FORMAT_TEST */ |
||||
|
||||
# ifndef PRINTFLIKE |
||||
# if HOND_CONF_FORMAT_TEST |
||||
# define PRINTFLIKE(x,y) __attribute__ ((__format__ (__printf__, x, y))) |
||||
# else /* HOND_CONF_FORMAT_TEST */ |
||||
# define PRINTFLIKE(x,y) |
||||
# endif /* HOND_CONF_FORMAT_TEST */ |
||||
# endif /* ! PRINTFLIKE */ |
||||
|
||||
# ifndef SCANFLIKE |
||||
# if HOND_CONF_FORMAT_TEST |
||||
# define SCANFLIKE(x,y) __attribute__ ((__format__ (__scanf__, x, y))) |
||||
# else /* HOND_CONF_FORMAT_TEST */ |
||||
# define SCANFLIKE(x,y) |
||||
# endif /* HOND_CONF_FORMAT_TEST */ |
||||
# endif /* ! SCANFLIKE */ |
||||
|
||||
#endif /* ! HOND_CDEFS_H */ |
||||
@ -0,0 +1,60 @@
|
||||
/*
|
||||
** setenv.c: ISO C implementation |
||||
** Copyright (c) 2003 Michael Schloh von Bennewitz <michael@schloh.com> |
||||
** Copyright (c) 2003 Cable & Wireless <http://www.cw.com/de/>
|
||||
** |
||||
** Permission to use, copy, modify, and distribute this software for |
||||
** any purpose with or without fee is hereby granted, provided that |
||||
** the above copyright notice and this permission notice appear in all |
||||
** copies. |
||||
** |
||||
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
||||
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
||||
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR |
||||
** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
||||
** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
||||
** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
||||
** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
||||
** OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
||||
** SUCH DAMAGE. |
||||
** |
||||
*/ |
||||
|
||||
#ifdef HAVE_CONFIG_H |
||||
#include "config.h" |
||||
#endif |
||||
|
||||
#ifndef HAVE_SETENV |
||||
#include <stdlib.h> /* For putenv(3) and malloc(3) */ |
||||
#include <string.h> /* For strcpy(3) and strcat(3) */ |
||||
|
||||
|
||||
/*
|
||||
** Implements setenv C library function for platforms not including it |
||||
** |
||||
*/ |
||||
int setenv(const char *kszName, const char *kszValue, int nOverwrite) |
||||
{ |
||||
char *szPair = NULL; /* String we will pass to putenv(3) */ |
||||
|
||||
/* Allocate space for name, value, equals, and string terminator */ |
||||
szPair = malloc(strlen(kszName) + strlen(kszValue) + strlen("=") + 1); |
||||
|
||||
if (szPair == NULL) /* Memory error */ |
||||
return 1; /* Unsuccessful */ |
||||
|
||||
/* Copy the incoming variables */ |
||||
strcpy(szPair, kszName); |
||||
strcat(szPair, "="); |
||||
strcat(szPair, kszValue); |
||||
|
||||
if (getenv(szPair) != NULL) |
||||
putenv(szPair); /* Handoff */ |
||||
|
||||
return 0; /* Success */ |
||||
} |
||||
#endif /* !HAVE_SETENV */ |
||||
|
||||
@ -0,0 +1,29 @@
|
||||
/*
|
||||
** setenv.h: ISO C interface |
||||
** Copyright (c) 2003 Michael Schloh von Bennewitz <michael@schloh.com> |
||||
** Copyright (c) 2003 Cable & Wireless <http://www.cw.com/de/>
|
||||
** |
||||
** Permission to use, copy, modify, and distribute this software for |
||||
** any purpose with or without fee is hereby granted, provided that |
||||
** the above copyright notice and this permission notice appear in all |
||||
** copies. |
||||
** |
||||
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
||||
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
||||
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR |
||||
** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
||||
** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
||||
** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
||||
** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
||||
** OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
||||
** SUCH DAMAGE. |
||||
** |
||||
*/ |
||||
|
||||
#ifndef HOND_SETENV_H |
||||
# define HOND_SETENV_H |
||||
int setenv(const char *kszName, const char *kszValue, int nOverwrite); |
||||
#endif /* not HOND_SETENV_H */ |
||||
Loading…
Reference in new issue