# define telldir PerlDir_tell
# define putenv PerlEnv_putenv
# define getenv PerlEnv_getenv
+# define uname PerlEnv_uname
# define stdin PerlIO_stdin()
# define stdout PerlIO_stdout()
# define stderr PerlIO_stderr()
virtual int Putenv(const char *envstring, int &err) = 0;
virtual char * LibPath(char *patchlevel) =0;
virtual char * SiteLibPath(char *patchlevel) =0;
+ virtual int Uname(struct utsname *name, int &err) =0;
};
#define PerlEnv_putenv(str) PL_piENV->Putenv((str), ErrorNo())
#define PerlEnv_getenv(str) PL_piENV->Getenv((str), ErrorNo())
+#define PerlEnv_uname(name) PL_piENV->Uname((name), ErrorNo())
#ifdef WIN32
#define PerlEnv_lib_path(str) PL_piENV->LibPath((str))
#define PerlEnv_sitelib_path(str) PL_piENV->SiteLibPath((str))
#define PerlEnv_putenv(str) putenv((str))
#define PerlEnv_getenv(str) getenv((str))
+#define PerlEnv_uname(name) uname((name))
#endif /* PERL_OBJECT */
return pPerl->PL_piLIO->Utime((char*)f, t, ErrorNo());
}
+int _win32_uname(struct utsname *name)
+{
+ return pPerl->PL_piENV->Uname(name, ErrorNo());
+}
+
char* _win32_getenv(const char *name)
{
return pPerl->PL_piENV->Getenv(name, ErrorNo());
d_truncate64='undef'
d_tzname='define'
d_umask='define'
-d_uname='undef'
+d_uname='define'
d_union_semun='define'
d_vfork='undef'
d_void_closedir='undef'
d_truncate64='undef'
d_tzname='undef'
d_umask='define'
-d_uname='undef'
+d_uname='define'
d_union_semun='define'
d_vfork='undef'
d_void_closedir='undef'
d_truncate64='undef'
d_tzname='define'
d_umask='define'
-d_uname='undef'
+d_uname='define'
d_union_semun='define'
d_vfork='undef'
d_void_closedir='undef'
* even if used by a process with super-user privileges.
*/
#define HAS_GETHOSTNAME /**/
-/*#define HAS_UNAME /**/
+#define HAS_UNAME /**/
/*#define PHOSTNAME "" / * How to get the host name */
/* HAS_GETLOGIN:
* even if used by a process with super-user privileges.
*/
#define HAS_GETHOSTNAME /**/
-/*#define HAS_UNAME /**/
+#define HAS_UNAME /**/
/*#define PHOSTNAME "" / * How to get the host name */
/* HAS_GETLOGIN:
* even if used by a process with super-user privileges.
*/
#define HAS_GETHOSTNAME /**/
-/*#define HAS_UNAME /**/
+#define HAS_UNAME /**/
/*#define PHOSTNAME "" / * How to get the host name */
/* HAS_GETLOGIN:
win32_get_osfhandle
win32_ioctl
win32_utime
+win32_uname
win32_wait
win32_waitpid
win32_kill
{
return g_win32_get_sitelib(pl);
};
+ virtual int Uname(struct utsname *name, int &err)
+ {
+ return win32_uname(name);
+ };
};
class CPerlSock : public IPerlSock
}
DllExport int
+win32_uname(struct utsname *name)
+{
+ struct hostent *hep;
+ STRLEN nodemax = sizeof(name->nodename)-1;
+ OSVERSIONINFO osver;
+
+ memset(&osver, 0, sizeof(OSVERSIONINFO));
+ osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ if (GetVersionEx(&osver)) {
+ /* sysname */
+ switch (osver.dwPlatformId) {
+ case VER_PLATFORM_WIN32_WINDOWS:
+ strcpy(name->sysname, "Windows");
+ break;
+ case VER_PLATFORM_WIN32_NT:
+ strcpy(name->sysname, "Windows NT");
+ break;
+ case VER_PLATFORM_WIN32s:
+ strcpy(name->sysname, "Win32s");
+ break;
+ default:
+ strcpy(name->sysname, "Win32 Unknown");
+ break;
+ }
+
+ /* version */
+ sprintf(name->version, "%d.%d",
+ osver.dwMajorVersion, osver.dwMinorVersion);
+
+ /* release */
+ sprintf(name->release, "Build %d",
+ osver.dwPlatformId == VER_PLATFORM_WIN32_NT
+ ? osver.dwBuildNumber : (osver.dwBuildNumber & 0xffff));
+ if (osver.szCSDVersion[0]) {
+ char *buf = name->release + strlen(name->release);
+ sprintf(buf, " (%s)", osver.szCSDVersion);
+ }
+ }
+ else {
+ *name->sysname = '\0';
+ *name->version = '\0';
+ *name->release = '\0';
+ }
+
+ /* nodename */
+ hep = win32_gethostbyname("localhost");
+ if (hep) {
+ STRLEN len = strlen(hep->h_name);
+ if (len <= nodemax) {
+ strcpy(name->nodename, hep->h_name);
+ }
+ else {
+ strncpy(name->nodename, hep->h_name, nodemax);
+ name->nodename[nodemax] = '\0';
+ }
+ }
+ else {
+ DWORD sz = nodemax;
+ if (!GetComputerName(name->nodename, &sz))
+ *name->nodename = '\0';
+ }
+
+ /* machine (architecture) */
+ {
+ SYSTEM_INFO info;
+ char *arch;
+ GetSystemInfo(&info);
+ switch (info.wProcessorArchitecture) {
+ case PROCESSOR_ARCHITECTURE_INTEL:
+ arch = "x86"; break;
+ case PROCESSOR_ARCHITECTURE_MIPS:
+ arch = "mips"; break;
+ case PROCESSOR_ARCHITECTURE_ALPHA:
+ arch = "alpha"; break;
+ case PROCESSOR_ARCHITECTURE_PPC:
+ arch = "ppc"; break;
+ default:
+ arch = "unknown"; break;
+ }
+ strcpy(name->machine, arch);
+ }
+ return 0;
+}
+
+DllExport int
win32_waitpid(int pid, int *status, int flags)
{
int retval = -1;
long tms_cstime;
};
+#ifndef SYS_NMLN
+#define SYS_NMLN 257
+#endif
+
+struct utsname {
+ char sysname[SYS_NMLN];
+ char nodename[SYS_NMLN];
+ char release[SYS_NMLN];
+ char version[SYS_NMLN];
+ char machine[SYS_NMLN];
+};
+
#ifndef START_EXTERN_C
#undef EXTERN_C
#ifdef __cplusplus
DllExport int win32_stat(const char *path, struct stat *buf);
DllExport int win32_ioctl(int i, unsigned int u, char *data);
DllExport int win32_utime(const char *f, struct utimbuf *t);
+DllExport int win32_uname(struct utsname *n);
DllExport int win32_wait(int *status);
DllExport int win32_waitpid(int pid, int *status, int flags);
DllExport int win32_kill(int pid, int sig);
#undef alarm
#undef ioctl
#undef utime
+#undef uname
#undef wait
#ifdef __BORLANDC__
#define alarm win32_alarm
#define ioctl win32_ioctl
#define utime win32_utime
+#define uname win32_uname
#define wait win32_wait
#define waitpid win32_waitpid
#define kill win32_kill