home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / gcc / ixemulsrc.lha / ixemul / general / uname.c < prev    next >
C/C++ Source or Header  |  1996-12-11  |  2KB  |  60 lines

  1. /*
  2.  *  This file is part of ixemul.library for the Amiga.
  3.  *  Copyright (C) 1995 Lars G. Hecking
  4.  *
  5.  *  This library is free software; you can redistribute it and/or
  6.  *  modify it under the terms of the GNU Library General Public
  7.  *  License as published by the Free Software Foundation; either
  8.  *  version 2 of the License, or (at your option) any later version.
  9.  *
  10.  *  This library is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  *  Library General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU Library General Public
  16.  *  License along with this library; if not, write to the Free
  17.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  */
  19.  
  20. #include <sys/utsname.h>
  21.  
  22. #define _KERNEL
  23. #include "ixemul.h"
  24. #include "kprintf.h"
  25. #include <stdio.h>
  26. #include <string.h>
  27. #include <unistd.h>
  28.  
  29. static char sysname[] = "AmigaOS";
  30. static char version[] = "1";
  31. static char machine[] = "m68k";
  32.  
  33. int
  34. uname (struct utsname *name)
  35. {
  36.   char host[__SYS_NMLN];
  37.   char release[__SYS_NMLN];
  38.   int res = -1, err = EFAULT;
  39.  
  40.   if (name)
  41.     {
  42.  
  43.       if (gethostname(&host[0],__SYS_NMLN) == 0)
  44.     {
  45.  
  46.       sprintf (release, "%d.%d", SysBase->LibNode.lib_Version, SysBase->SoftVer);
  47.       strncpy (name->sysname, sysname,__SYS_NMLN);
  48.       strncpy (name->nodename, &host[0],__SYS_NMLN);
  49.       strncpy (name->release, release,__SYS_NMLN);
  50.       strncpy (name->version, version,__SYS_NMLN);
  51.       strncpy (name->machine, machine,__SYS_NMLN);
  52.       res = err = 0;
  53.     }
  54.     }
  55.  
  56.   errno = err;
  57.   KPRINTF (("&errno = %lx, errno = %ld\n", &errno, errno));
  58.   return res;
  59. }
  60.