delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2002/03/04/10:35:04

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-workers-bounces using -f
Message-ID: <3C839428.1CEF9D1A@ma.tum.de>
Date: Mon, 04 Mar 2002 16:35:04 +0100
From: Waldemar Schultz <schultz AT mathematik DOT tu-muenchen DOT de>
X-Mailer: Mozilla 4.75 [de] (Win98; U)
X-Accept-Language: de,en-US
MIME-Version: 1.0
To: djgpp-workers AT delorie DOT com
Subject: patch to int uname(struct utsname *u)
X-MIME-Autoconverted: from 8bit to quoted-printable by sunrbg2.mathematik.tu-muenchen.de id g24FYqs11528
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id g24FYvF18418
Reply-To: djgpp-workers 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 patch,
which takes part of the code from
\DJGPP\SRC\LIBC\COMPAT\UNISTD\gethostn.c:

old:www.ludd.luth.se/~ams/djgpp/cvs/djgpp/src/libc/posix/utsname/uname.c  
(01-Jul-2001 06:08) 

*** uname.c.old	Mon Mar  4 16:00:56 2002
--- uname.c	Mon Mar  4 16:23:14 2002
***************
*** 11,16 ****
--- 11,18 ----
  
  int uname(struct utsname *u)
  {
+   static char pc_n[]= "pc";
+   char *h;
    __dpmi_regs r;
    unsigned short dos_version;
    unsigned is_486_or_better;
***************
*** 110,120 ****
    r.x.dx = __tb & 15;
    __dpmi_int(0x21, &r);
    if ((r.x.flags & 1) || (r.h.ch == 0))
!     strcpy(u->nodename, "pc");
    else
    {
!     int i = 8;
!     dosmemget(__tb, 8, u->nodename);
      do {
        u->nodename[i--] = 0;
      } while (i && u->nodename[i] <= ' ');
--- 112,133 ----
    r.x.dx = __tb & 15;
    __dpmi_int(0x21, &r);
    if ((r.x.flags & 1) || (r.h.ch == 0))
!   {
!   /* should we uncomment this and change the docs ?
!   static char host_n[]= "HOSTNAME";
! 
!     h = getenv (host_n);
!     if (h == NULL)
!   */
!       h = pc_n;
!     strcpy(u->nodename, h);
!   }
    else
    {
!   int i;
! 
!     dosmemget(__tb, sizeof(u->nodename), u->nodename);
!     i = strlen(u->nodename);
      do {
        u->nodename[i--] = 0;
      } while (i && u->nodename[i] <= ' ');

-- 
 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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019