[server] Update completename(...)

This commit is contained in:
RD42 2024-06-23 22:13:14 +08:00
parent 2dbf9d9f61
commit a503b7be9b

View File

@ -307,7 +307,7 @@ static wchar_t buffer[_MAX_PATH];
return buffer[0]!=L'\0' ? buffer : NULL; return buffer[0]!=L'\0' ? buffer : NULL;
} }
#else #else
char *getenv(const char *name) char *amx_getenv(const char *name)
{ {
static char buffer[_MAX_PATH]; static char buffer[_MAX_PATH];
buffer[0]='\0'; buffer[0]='\0';
@ -315,6 +315,8 @@ static char buffer[_MAX_PATH];
return buffer[0]!='\0' ? buffer : NULL; return buffer[0]!='\0' ? buffer : NULL;
} }
#endif #endif
#else
#define amx_getenv getenv
#endif #endif
static char *completename(TCHAR *dest, TCHAR *src, size_t size) static char *completename(TCHAR *dest, TCHAR *src, size_t size)
@ -323,16 +325,17 @@ static char *completename(TCHAR *dest, TCHAR *src, size_t size)
TCHAR *prefix,*ptr; TCHAR *prefix,*ptr;
size_t len; size_t len;
/* only files below a specific path are accessible */ /* only files below a specific path are accessible */
prefix=getenv(AMXFILE_VAR); prefix=amx_getenv(AMXFILE_VAR);
/* if no specific path for files is present, use the "temporary" path */ /* if no specific path for files is present, use the "temporary" path */
if (prefix==NULL) if (prefix==NULL)
prefix=getenv(__T("tmp")); /* common under Windows and Unix */ prefix=amx_getenv(__T("tmp")); /* common under Windows and Unix */
if (prefix==NULL) if (prefix==NULL)
prefix=getenv(__T("temp")); /* common under Windows */ prefix=amx_getenv(__T("temp")); /* common under Windows */
if (prefix==NULL) if (prefix==NULL)
prefix=getenv(__T("tmpdir")); /* common under Unix */ prefix=amx_getenv(__T("tmpdir")); /* common under Unix */
/* if no path for files is defined, and no temporary directory exists, /* if no path for files is defined, and no temporary directory exists,
* fail the function; this is for security reasons. * fail the function; this is for security reasons.