📄 getenv.c
字号:
/* * Copyright (c) 1987 Regents of the University of California. * This file may be freely redistributed provided that this * notice remains attached. */#ifndef lintstatic char *sccsid = "@(#)getenv.c 4.1 (ULTRIX) 7/3/90";#endif lint/************************************************************************ * * * Copyright (c) 1984,86 by * * Digital Equipment Corporation, Maynard, MA * * All rights reserved. * * * * This software is furnished under a license and may be used and * * copied only in accordance with the terms of such license and * * with the inclusion of the above copyright notice. This * * software or any other copies thereof may not be provided or * * otherwise made available to any other person. No title to and * * ownership of the software is hereby transferred. * * * * This software is derived from software received from the * * University of California, Berkeley, and from Bell * * Laboratories. Use, duplication, or disclosure is subject to * * restrictions under license agreements with University of * * California and with AT&T. * * * * The information in this software is subject to change without * * notice and should not be construed as a commitment by Digital * * Equipment Corporation. * * * * Digital assumes no responsibility for the use or reliability * * of its software on equipment which is not supplied by Digital. * * * ************************************************************************//************************************************************************ * Modification History * ************************************************************************//* * Jon Reeves, 1989-Sept-15 * Changed environ to __environ for ANSI compliance */#include <stdio.h>/* * getenv(name) -- * Returns ptr to value associated with name, if any, else NULL. */char *getenv(name) char *name;{ int offset; char *_findenv(); return(_findenv(name,&offset));}/* * _findenv(name,offset) -- * 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. */char *_findenv(name,offset) register char *name; int *offset;{ extern char **__environ; register int 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);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -