X-Git-Url: http://git.home-dn.net/?p=manu%2Fsuphp.git;a=blobdiff_plain;f=src%2Fcompat.c;fp=src%2Fcompat.c;h=0000000000000000000000000000000000000000;hp=791ccb47b74949dd21325cece954beb4ee8de31f;hb=873afb00229b8e205345b6895eaad6602d5e10f4;hpb=728a5b3f000f892e52ecea98fcc8f0c5d7275b7b diff --git a/src/compat.c b/src/compat.c deleted file mode 100644 index 791ccb4..0000000 --- a/src/compat.c +++ /dev/null @@ -1,105 +0,0 @@ -/* - suPHP - (c)2002-2004 Sebastian Marsching - - This file is part of suPHP. - - suPHP is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - suPHP is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with suPHP; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include -#include - -#include "suphp.h" - -int suphp_setenv(const char *name, const char *value, int overwrite) -{ - char *putstr = NULL; - char *temp = NULL; - int retval = 0; - if (!overwrite && getenv(name) != NULL) - return 0; - temp = NULL; - putstr = malloc(strlen(name) + strlen(value) + 2); - if (putstr == NULL) - error_sysmsg_exit(ERRCODE_MEMORY, "Could not allocate memory", __FILE__, __LINE__); - strcpy(putstr, name); - temp = putstr + strlen(name); - *temp = '='; - temp++; - strcpy(temp, value); - retval = putenv(putstr); - return retval; -} - -int suphp_unsetenv(const char *name) -{ - char *putstr = malloc(strlen(name) + 2); - char *temp = NULL; - int retval = 0; - if (putstr == NULL) - error_sysmsg_exit(ERRCODE_MEMORY, "Could not allocate memory", __FILE__, __LINE__); - strcpy(putstr, name); - temp = putstr + strlen(name); - *temp = '='; - temp++; - *temp = 0; - retval = putenv(putstr); - return retval; -} - -char** suphp_copyenv(const char **old_env) -{ - char** new_env = NULL; - char** element = NULL; - char** new_element = NULL; - char* firsteqchr = NULL; - int num_elements = 0; - - element = (char **) old_env; - while (*element != NULL) - { - firsteqchr = strchr(*element, '='); - if (*(firsteqchr + 1) != 0) - { - num_elements++; - } - element++; - } - - new_env = (char**) malloc(sizeof(char*) * (num_elements + 1)); - if (new_env == NULL) - { - error_sysmsg_exit(ERRCODE_MEMORY, "Could not allocate memory", __FILE__, __LINE__); - } - new_element = new_env; - element = (char **) old_env; - while (*element != NULL) - { - firsteqchr = strchr(*element, '='); - if (*(firsteqchr + 1) != 0) - { - *new_element = malloc(strlen(*element) + 1); - if (*new_element == NULL) - { - error_sysmsg_exit(ERRCODE_MEMORY, "Could not allocate memory", __FILE__, __LINE__); - } - strcpy(*new_element, *element); - new_element++; - } - element++; - } - *new_element = NULL; - return new_env; -}