Skip to content

Commit

Permalink
@added php_uname() function (Stig)
Browse files Browse the repository at this point in the history
Added php_uname() function.
  • Loading branch information
stigsb committed Aug 27, 2000
1 parent 390d1cd commit 7eeda99
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 18 deletions.
1 change: 1 addition & 0 deletions ext/standard/basic_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ function_entry basic_functions[] = {
PHP_FE(php_logo_guid, NULL)
PHP_FE(zend_logo_guid, NULL)
PHP_FE(php_sapi_name, NULL)
PHP_FE(php_uname, NULL)

PHP_FE(strnatcmp, NULL)
PHP_FE(strnatcasecmp, NULL)
Expand Down
52 changes: 34 additions & 18 deletions ext/standard/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,37 @@ void php_info_print_style(void)
}


PHPAPI void php_print_info(int flag)
PHPAPI char *php_get_uname()
{
char **env,*tmp1,*tmp2;
char *php_uname;
int expose_php = INI_INT("expose_php");
time_t the_time;
struct tm *ta, tmbuf;
#ifdef PHP_WIN32
char php_windows_uname[256];
DWORD dwBuild=0;
DWORD dwVersion = GetVersion();
DWORD dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
DWORD dwWindowsMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));

/* Get build numbers for Windows NT or Win95 */
if (dwVersion < 0x80000000){
dwBuild = (DWORD)(HIWORD(dwVersion));
snprintf(php_windows_uname,255,"%s %d.%d build %d","Windows NT",dwWindowsMajorVersion,dwWindowsMinorVersion,dwBuild);
} else {
snprintf(php_windows_uname,255,"%s %d.%d","Windows 95/98",dwWindowsMajorVersion,dwWindowsMinorVersion);
}
php_uname = php_windows_uname;
#else
php_uname=PHP_UNAME;
#endif
return estrdup(php_uname);
}

PHPAPI void php_print_info(int flag)
{
char **env,*tmp1,*tmp2;
char *php_uname;
int expose_php = INI_INT("expose_php");
time_t the_time;
struct tm *ta, tmbuf;
ELS_FETCH();
SLS_FETCH();

Expand All @@ -146,18 +163,7 @@ PHPAPI void php_print_info(int flag)
if (flag & PHP_INFO_GENERAL) {
char *zend_version = get_zend_version();

#ifdef PHP_WIN32
/* Get build numbers for Windows NT or Win95 */
if (dwVersion < 0x80000000){
dwBuild = (DWORD)(HIWORD(dwVersion));
snprintf(php_windows_uname,255,"%s %d.%d build %d","Windows NT",dwWindowsMajorVersion,dwWindowsMinorVersion,dwBuild);
} else {
snprintf(php_windows_uname,255,"%s %d.%d","Windows 95/98",dwWindowsMajorVersion,dwWindowsMinorVersion);
}
php_uname = php_windows_uname;
#else
php_uname=PHP_UNAME;
#endif
php_uname = php_get_uname();

php_info_print_style();

Expand Down Expand Up @@ -219,6 +225,7 @@ PHPAPI void php_print_info(int flag)
zend_html_puts(zend_version, strlen(zend_version));
php_printf("</BR>\n");
php_info_print_box_end();
efree(php_uname);
}

if ((flag & PHP_INFO_CREDITS) && expose_php) {
Expand Down Expand Up @@ -642,7 +649,7 @@ PHP_FUNCTION(zend_logo_guid)
RETURN_STRINGL(ZEND_LOGO_GUID, sizeof(ZEND_LOGO_GUID)-1, 1);
}

/* {{{ proto string sapi_module_name(void)
/* {{{ proto string php_sapi_name(void)
Return the current SAPI module name */
PHP_FUNCTION(php_sapi_name)
{
Expand All @@ -655,6 +662,15 @@ PHP_FUNCTION(php_sapi_name)

/* }}} */

/* {{{ proto string php_uname(void)
Return information about the system PHP was built on */
PHP_FUNCTION(php_uname)
{
RETURN_STRING(php_get_uname(), 0);
}

/* }}} */

/*
* Local variables:
* tab-width: 4
Expand Down
1 change: 1 addition & 0 deletions ext/standard/info.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ PHP_FUNCTION(php_logo_guid);
PHP_FUNCTION(zend_logo_guid);
PHP_FUNCTION(php_egg_logo_guid);
PHP_FUNCTION(php_sapi_name);
PHP_FUNCTION(php_uname);
PHPAPI void php_print_info(int flag);
PHPAPI void php_print_credits(int flag);
PHPAPI void php_print_style(void);
Expand Down

0 comments on commit 7eeda99

Please sign in to comment.