]> granicus.if.org Git - php/commitdiff
@Added php_uname() function (Stig)
authorStig Bakken <ssb@php.net>
Sun, 27 Aug 2000 19:42:45 +0000 (19:42 +0000)
committerStig Bakken <ssb@php.net>
Sun, 27 Aug 2000 19:42:45 +0000 (19:42 +0000)
Added php_uname() function.

ext/standard/basic_functions.c
ext/standard/info.c
ext/standard/info.h

index 3061d0fabdc073bb098a8ff70d38ca9ce711d047..924ae50bba89cb1b5f01d1d6a61211e435c616c6 100644 (file)
@@ -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)
index 3e6942c083c7c2b2c5deb881c0251de6dfb4aaf8..c3b5fcec9090bb431926d86505d9b2ebf06f2d95 100644 (file)
@@ -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();
 
@@ -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();
 
@@ -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) {  
@@ -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)
 {
@@ -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
index 6936b58dba7869e88e207e9d2a7075900a0ba2da..72beafcfdcdaeee9e4628b77d449e9e76d0e71bf 100644 (file)
@@ -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);