unsetenv.c

来自「unix/linux下的路由守护程序」· C语言 代码 · 共 68 行

C
68
字号
/* * *$Id: unsetenv.c,v 1.4 1998/09/15 16:48:15 wfs Exp $ * * Copyright (c) 1987 Regents of the University of California. * This file may be freely redistributed provided that this * notice remains attached. */#if defined(LIBC_SCCS) && !defined(lint)static char sccsid[] = "@(#)setenv.c	1.3 (Berkeley) 6/16/87";#endif /* LIBC_SCCS and not lint */#include "include.h"#if	__GNUC__ >= 2PROTOTYPE(unsetenv,	  void,	  (char *));#endif	/* __GNUC__ >= 2*//* * _findenv -- *      Returns pointer to value associated with name, if any, else NULL. *      Sets offset to be the offset of the name/value combination in the *      environmental array, for use by setenv(3) and unsetenv(3). *      Explicitly removes '=' in argument name. * *      This routine *should* be a static; don't use it. */static char *_findenv __PF2(name, register char *,	       offset, int *){        extern char **ENVIRON;        register size_t len;        register char **P, *C;        for (C = name, len = 0; *C && *C != '='; ++C, ++len);        for (P = ENVIRON; *P; ++P)                if (!strncmp(*P, name, len))                        if (*(C = *P + len) == '=') {                                *offset = P - ENVIRON;                                return(++C);                        }        return(NULL);}/* * unsetenv(name) -- *	Delete environmental variable "name". */voidunsetenv(name)	char	*name;{	extern	char	**ENVIRON;	register char	**P;	int	offset;	while (_findenv(name,&offset))		/* if set multiple times */		for (P = &ENVIRON[offset];;++P)			if (!(*P = *(P + 1)))				break;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?