File: osname.c

package info (click to toggle)
viewmol 2.3-5
  • links: PTS
  • area: main
  • in suites: woody
  • size: 9,424 kB
  • ctags: 2,239
  • sloc: ansic: 29,098; sh: 909; makefile: 513; python: 238
file content (60 lines) | stat: -rw-r--r-- 1,745 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*******************************************************************************
*                                                                              *
*                                   Viewmol                                    *
*                                                                              *
*                               O S N A M E . C                                *
*                                                                              *
*                 Copyright (c) Joerg-R. Hill, December 2000                   *
*                                                                              *
********************************************************************************
*
* $Id: osname.c,v 1.5 2000/12/10 15:13:38 jrh Exp $
* $Log: osname.c,v $
* Revision 1.5  2000/12/10 15:13:38  jrh
* Release 2.3
*
* Revision 1.4  1999/05/24 01:26:53  jrh
* Release 2.2.1
*
* Revision 1.3  1999/02/07 21:54:13  jrh
* Release 2.2
*
* Revision 1.2  1998/01/26 00:49:00  jrh
* Release 2.1
*
* Revision 1.1  1996/12/10  18:42:54  jrh
* Initial revision
*
*/
#include<stdio.h>
#include<string.h>
#include<sys/utsname.h>

void osname(char *os)
{
  struct utsname sysname;
  FILE *pipe;

  uname(&sysname);

  strcpy(os, sysname.sysname);
  if (!strncmp(sysname.sysname, "AIX", 3))
  {
    strcat(os, "_");
    if (sysname.machine[8] == '7' && sysname.machine[9] == '0')
      strcat(os, "POWER2");
    else
      strcat(os, "POWER");
  }
  else if (strstr(sysname.sysname, "IRIX"))
  {
    strcat(os, "_");
    if ((pipe=popen("hinv | awk '/^CPU/ {print $3}' | cut -d/ -f2", "r")) != NULL)
    {
      fscanf(pipe, "%s", os+strlen(os));
      pclose(pipe);
    }
    else
      strcat(os, "R3000");
  }
}