X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f From: Waldemar Schultz Newsgroups: comp.os.msdos.djgpp Subject: int uname(struct utsname *u) Date: Mon, 04 Mar 2002 11:29:21 +0100 Organization: [posted via] Leibniz-Rechenzentrum, Muenchen (Germany) Lines: 75 Message-ID: <3C834C81.F2139B3B@ma.tum.de> NNTP-Posting-Host: pcritter14.mathematik.tu-muenchen.de Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: wsc10.lrz-muenchen.de 1015237748 14111 131.159.68.151 (4 Mar 2002 10:29:08 GMT) X-Complaints-To: news AT lrz-muenchen DOT de NNTP-Posting-Date: 4 Mar 2002 10:29:08 GMT X-Mailer: Mozilla 4.75 [de] (Win98; U) X-Accept-Language: de,en-US To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hello, since int uname(struct utsname *u) returns only up to 8 characters in u->nodename, I'd like to suggest this version, which takes part of the code from \DJGPP\SRC\LIBC\COMPAT\UNISTD\gethostn.c: '\DJGPP\SRC\LIBC\POSIX\UTSNAME\uname.c' ( 4. Mar 2002 11:18:58) ------------- /* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #include #include #include #include #include #include #include #include int uname(struct utsname *u) { static char pc_n[]= "pc"; __dpmi_regs r; unsigned short dos_version; char *h; if (!u) { errno = EFAULT; return -1; } dos_version = _get_dos_version(1); strncpy(u->sysname, _os_flavor, sizeof(u->sysname) - 1); u->sysname[sizeof(u->sysname) - 1] = '\0'; sprintf(u->release, "%d", dos_version >> 8); sprintf(u->version, "%02d", dos_version & 0xff); strcpy(u->machine, pc_n); r.x.ax = 0x5e00; /* Try asking [a lan extension of] dos for a name. */ r.h.ch = 0; /* Try to detect overloading of 0x5e00 */ r.x.ds = __tb >> 4; r.x.dx = __tb & 0x0f; __dpmi_int (0x21, &r); if ((r.x.flags & 1) || r.h.ch == 0) /* Failed. Try $HOSTNAME, then "pc". */ { /* should we uncomment this and update the docs ? static char host_n[]= "HOSTNAME"; h = getenv (host_n); if (h == NULL) */ h = pc_n; strcpy(u->nodename,h); } else { dosmemget (__tb, sizeof (u->nodename), u->nodename); h = u->nodename + strlen (u->nodename); while (h > u->nodename && h[-1] <= ' ') h--; *h = '\0'; } return 0; } -------------- I apologize for this post, if this is the wrong place for suggesting such changes. -- Gruss Waldemar Schultz. schultz AT ma DOT tum DOT de Technische Universität München, Zentrum Mathematik M1, D 80290 München Tel: +49 (0)89 2892 8226 FAX: +49 (0)89 2892 8228