[Programming] getenv() |
18/09/2010 09:49:33 (+0700) | #1 | 220948 |
|
panfider
Member
|
0 |
|
|
Joined: 12/05/2010 01:51:04
Messages: 448
Offline
|
|
hàm getenv() làm việc như thế nào ? |
|
[Unix] live free or die
|
|
|
|
[Programming] getenv() |
20/09/2010 08:53:11 (+0700) | #2 | 221070 |
mR.Bi
Member
|
0 |
|
|
Joined: 22/03/2006 13:17:49
Messages: 812
Offline
|
|
http://www.unix.com/man-page/freebsd/3/getenv/ |
|
All of my life I have lived by a code and the code is simple: "honour your parent, love your woman and defend your children" |
|
|
|
[Programming] getenv() |
20/09/2010 20:06:22 (+0700) | #3 | 221144 |
|
panfider
Member
|
0 |
|
|
Joined: 12/05/2010 01:51:04
Messages: 448
Offline
|
|
mình không nghĩ link trên giải thích đầy đủ
mình chỉ hiểu sơ sơ
nó nằm ở vùng nhớ chung nào đó mà ai truy suất cũng được,
nó được bash quản lý,
nhưng cơ chế quản lý như thế nào còn là mystery,
với lại bây giờ đang xài windows |
|
[Unix] live free or die
|
|
|
|
[Programming] getenv() |
20/09/2010 22:11:37 (+0700) | #4 | 221152 |
facialz
Elite Member
|
0 |
|
|
Joined: 20/07/2004 03:48:17
Messages: 197
Location: HoChiMinh city
Offline
|
|
Bác đang dùng Windows, hãy thử xuất ra vài giá trị này xem:
getenv("OS")
getenv("ComSpec")
getenv("windir")
|
|
|
|
|
[Programming] getenv() |
20/09/2010 22:13:36 (+0700) | #5 | 221153 |
|
Z0rr0
Q+WRtaW5pc3RyYXRvc+g
|
Joined: 14/08/2002 12:52:01
Messages: 1323
Location: Underground
Offline
|
|
- Thế nào là Environment variables: http://en.wikipedia.org/wiki/Environment_variable
- getenv(): http://www.cplusplus.com/reference/clibrary/cstdlib/getenv/
Nếu đang dùng trên Windows thì chuyển câu hỏi này sang box Windows sẽ phù hợp hơn. |
|
Hibernating |
|
|
|
[Programming] getenv() |
22/09/2010 20:39:10 (+0700) | #6 | 221252 |
|
panfider
Member
|
0 |
|
|
Joined: 12/05/2010 01:51:04
Messages: 448
Offline
|
|
ok, minh tu tim hieu vay
cai nay hoi kho |
|
[Unix] live free or die
|
|
|
|
[Programming] getenv() |
22/09/2010 20:41:30 (+0700) | #7 | 221253 |
TQN
Elite Member
|
0 |
|
|
Joined: 29/06/2006 22:28:01
Messages: 888
Location: Biết làm chi ?
Offline
|
|
getenv = Get enviroment variables. Coder C mà không tự tìm hiểu hàm đơn giản này được à ?
<stdlib.h>
getenv
char *getenv(const char *name);
The function searches an environment list, which each implementation defines, for an entry whose name matches the string name. If the function finds a match, it returns a pointer to a static-duration object that holds the definition associated with the target environment name. Otherwise, it returns a null pointer. Do not alter the value stored in the object. If you call getenv again, the value stored in the object can change. No target environment names are required of all environments.
|
|
|
|
|
[Programming] getenv() |
23/09/2010 13:14:59 (+0700) | #8 | 221293 |
|
panfider
Member
|
0 |
|
|
Joined: 12/05/2010 01:51:04
Messages: 448
Offline
|
|
trời xài thư viện chuẩn thì sao không xài được.
mình đang bàn luận hàm getenv làm việc như thế nào ? |
|
[Unix] live free or die
|
|
|
|
[Programming] getenv() |
24/09/2010 06:30:01 (+0700) | #9 | 221342 |
TQN
Elite Member
|
0 |
|
|
Joined: 29/06/2006 22:28:01
Messages: 888
Location: Biết làm chi ?
Offline
|
|
Source cua Borland:
/*--------------------------------------------------------------------------*
Name getenv, _wgetenv - get string from environment
Usage char *getenv(const char *envvar);
whar_t *_wgetenv(const wchar_t *envvar);
Prototype in stdlib.h
Description The environment consists of a series of entries that
are of the form:
name=string\0
The global variable environ points to an array of pointers
to these entries. The last pointer in the array is NULL.
getenv searches the environment for the entry corresponding
to envvar, then returns a pointer to string.
The string comparison is NOT case-sensitive.
Return value On success, getenv and _wgetenv return a pointer to the value
associated with envvar.
*---------------------------------------------------------------------------*/
_TCHAR * _RTLENTRY _EXPFUNC _tgetenv_nolock(const _TCHAR *nameP)
{
#if defined(_UNICODE)
if (_ostype & _WINNT)
{
#endif
_TCHAR **envP;
int len;
len = _tcslen(nameP); /* save length of name */
if (len == 0)
return NULL;
for (envP = _tenviron; *envP != NULL; envP++)
if (_tcsnicmp(*envP,nameP,len) == 0 && (*envP)[len] == _TEXT('='))
break;
if (*envP)
return ((*envP)+len+1); /* point past the '=' */
else
return (NULL);
#if defined(_UNICODE)
}
else
return NULL;
#endif
}
May em khong co *nix nen khong co source |
|
|
|
|
[Programming] getenv() |
25/09/2010 07:51:57 (+0700) | #10 | 221426 |
|
panfider
Member
|
0 |
|
|
Joined: 12/05/2010 01:51:04
Messages: 448
Offline
|
|
ok, thanks
mình sẽ reverse cái hàm này sớm thôi,
|
|
[Unix] live free or die
|
|
Users currently in here |
1 Anonymous
|
|
Powered by JForum - Extended by HVAOnline
hvaonline.net | hvaforum.net | hvazone.net | hvanews.net | vnhacker.org
1999 - 2013 ©
v2012|0504|218|
|
|