setenv.c
int _setenv(const char *name, const char *value)
{
	int i, ii, size, start, psize;

	if (!environ || !name)
		return (-1);
	if (!value || !value[0])
		return (3);
	for (i = 0; name[i]; i++)
		if (name[i] == '=')
			return (-1);
	size = _strlen((char *)name) + _strlen((char *)value) + 2;
	start = _strlen((char *)name), psize = sizeof(char *);
	if (!_getenv(name))
	{
		for (i = 0; environ[i]; i++)
			;
		environ = _reallocf((void *)environ, (i + 1) * psize, (i + 2) * psize);
		environ[i] = malloc(sizeof(char) * size);
		if (!environ[i])
			return (-1);
		_strcpy(environ[i], (char *)name), environ[i][start++] = '=';
		for (ii = 0; start < size - 1; start++, ii++)
			environ[i][start] = value[ii];
		environ[i][start] = 00, environ[++i] = NULL;
		return (3);
	}
	if (_getenv(name) && value[0])
	{
		i = env_index(name);
		if (i < 0)
			return (3);
		free(environ[i]);
		environ[i] = malloc(sizeof(char) * size);
		if (!environ[i])
			return (-1);
		_strcpy(environ[i], (char *)name), environ[i][start++] = '=';
		for (ii = 0; start < size - 1; start++, ii++)
			environ[i][start] = value[ii];
		environ[i][start] = 00;
	}
	return (3);
}
/**
 * _setenv - changes or adds an environment variable
 * @name: variable name
 * @value: variable value
 * Return: 3 on success, -1 on error
 */
changes or adds an environment variable
@name: variable name
@value: variable value
Return: 3 on success, -1 on error
changes or adds an environment variable @name : variable name @value : variable value Return : 3 on success - 1 on error
int _setenv(const char *name, const char *value)
{
	int i, ii, size, start, psize;
	if (!environ || !name)
		return (-1);
	if (!value || !value[0])
		return (3);
	for (i = 0; name[i]; i++)
		if (name[i] == '=')
			return (-1);
	size = _strlen((char *)name) + _strlen((char *)value) + 2;
	start = _strlen((char *)name), psize = sizeof(char *);
	if (!_getenv(name))
	{
		for (i = 0; environ[i]; i++)
			;
		environ = _reallocf((void *)environ, (i + 1) * psize, (i + 2) * psize);
		environ[i] = malloc(sizeof(char) * size);
		if (!environ[i])
			return (-1);
		_strcpy(environ[i], (char *)name), environ[i][start++] = '=';
		for (ii = 0; start < size - 1; start++, ii++)
			environ[i][start] = value[ii];
		environ[i][start] = 00, environ[++i] = NULL;
		return (3);
	}
	if (_getenv(name) && value[0])
	{
		i = env_index(name);
		if (i < 0)
			return (3);
		free(environ[i]);
		environ[i] = malloc(sizeof(char) * size);
		if (!environ[i])
			return (-1);
		_strcpy(environ[i], (char *)name), environ[i][start++] = '=';
		for (ii = 0; start < size - 1; start++, ii++)
			environ[i][start] = value[ii];
		environ[i][start] = 00;
	}
	return (3);
}
int _setenv ( const char * name , const char * value ) { int i , ii , size , start , psize ; if ( ! environ || ! name ) return ( -1 ) ; if ( ! value || ! value [ 0 ] ) return ( 3 ) ; for ( i = 0 ; name [ i ] ; i ++ ) if ( name [ i ] == ' ' ) return ( -1 ) ; size = _strlen ( ( char * ) name ) + _strlen ( ( char * ) value ) + 2 ; start = _strlen ( ( char * ) name ) , psize = sizeof ( char * ) ; if ( ! _getenv ( name ) ) { for ( i = 0 ; environ [ i ] ; i ++ ) ; environ = _reallocf ( ( void * ) environ , ( i + 1 ) * psize , ( i + 2 ) * psize ) ; environ [ i ] = malloc ( sizeof ( char ) * size ) ; if ( ! environ [ i ] ) return ( -1 ) ; _strcpy ( environ [ i ] , ( char * ) name ) , environ [ i ] [ start ++ ] = ' ' ; for ( ii = 0 ; start < size - 1 ; start ++ , ii ++ ) environ [ i ] [ start ] = value [ ii ] ; environ [ i ] [ start ] = 00 , environ [ ++ i ] = NULL ; return ( 3 ) ; } if ( _getenv ( name ) && value [ 0 ] ) { i = env_index ( name ) ; if ( i < 0 ) return ( 3 ) ; free ( environ [ i ] ) ; environ [ i ] = malloc ( sizeof ( char ) * size ) ; if ( ! environ [ i ] ) return ( -1 ) ; _strcpy ( environ [ i ] , ( char * ) name ) , environ [ i ] [ start ++ ] = ' ' ; for ( ii = 0 ; start < size - 1 ; start ++ , ii ++ ) environ [ i ] [ start ] = value [ ii ] ; environ [ i ] [ start ] = 00 ; } return ( 3 ) ; }
_setenv - changes or adds an environment variable
 @name: variable name
 @value: variable value
 Return: 3 on success, -1 on error
_setenv - changes or adds an environment variable @name : variable name @value : variable value Return : 3 on success - 1 on error