Programatically retrieve Platform Name

Programatically retrieve Platform Name

Post by Enda Mannioo » Sat, 12 Feb 2005 23:05:02



Hi,

I want to Programatically (c,c++) retrieve the Platform name on a
Sparc 7 machine.

uname -a returns:
SunOS mymachine 5.7 Generic_106541-18 sun4u sparc SUNW,Ultra-5_10

I want the "SUNW,Ultra-5_10" bit.

Unfortunatly the

struct utsname {
        char    sysname[_SYS_NMLN];
        char    nodename[_SYS_NMLN];
        char    release[_SYS_NMLN];
        char    version[_SYS_NMLN];
        char    machine[_SYS_NMLN];

Quote:};

in utsname.h

does not give the platform name is there some other api\structure that
can give it to me.

Thanks,
Enda

 
 
 

Programatically retrieve Platform Name

Post by Tony Walto » Sat, 12 Feb 2005 23:37:03


User-Agent: Unison/1.5.2


Mannioooo) said:

Quote:> Hi,

> I want to Programatically (c,c++) retrieve the Platform name on a
> Sparc 7 machine.

Sounds like you need sysinfo(2)

#include <sys/systeminfo.h>
#define BUFLEN 20
main()
{

        char buf[BUFLEN];
        sysinfo(SI_PLATFORM,buf,BUFLEN);
        printf("%s\n",buf);

Quote:}

--
Tony

 
 
 

Programatically retrieve Platform Name

Post by Rich Tee » Sun, 13 Feb 2005 01:08:49



> does not give the platform name is there some other api\structure that
> can give it to me.

You want sysinfo().  See Chapter 8 of my book for more details.

--
Rich Teer, SCNA, SCSA, author of "Solaris Systems Programming"

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-group.com/rich

 
 
 

Programatically retrieve Platform Name

Post by Kalafiorczy » Sun, 13 Feb 2005 04:02:56


Hi Enda!


Quote:> I want the "SUNW,Ultra-5_10" bit.

Here is the hack program that shows how to get it cheaply.
Instead of comments it has printf()s to show what is going
on. xp[0] is the value that you need.

Good luck,

S
======================================================================
#include <stdio.h>
#include <string.h>
int main(int ac,char **av,char **ep)
{
 int i;
 char *xp;

 printf("ac=%i\n",ac);
 for (i=0; i<ac; i++)
  printf("av[%i]='%s' %p-%p\n",i,av[i],av[i],av[i]+strlen(av[i]));
 for (i=0; ep[i]; i++)
  printf("ep[%i]='%s' %p-%p\n",i,ep[i],ep[i],ep[i]+strlen(ep[i]));
 xp = ep[i-1] + strlen(ep[i-1]) + 1;
 for (i = 0; *xp; i++)
  printf("xp[%i]='%s' %p-%p\n",i,xp,xp,xp+strlen(xp)),
  xp += strlen(xp) + 1;
 return 0;

Quote:}

======================================================================
 
 
 

1. Getting ODM Processor Names programatically ... Urgent

Hi,

Few questions pertaining Processors on AIX SMP m/c -
1. Can the ODM Processor Names be retrived by some system call
(subroutine)?
2. After cpu deallocation its known that the logical number of the
cpus after the one deallocated is decremented by 1, does the ODM
Processor Names also change or it remains static between reboots.

I want to handle an issue with cpu deallocation on the fly wherein I
need a variable which is static/unique for Processors active and
unactive (made unactive by cpu_deallocate) between reboots and can be
retrieved programatically.

Does anyone have clues to this? A sample code if available will be
conducive.

Thx,
-Adi

2. Anyone familiar with the zsh shell, and/or regular expressions?

3. Getting fetchmail to only retrieve email it's retrieved before?

4. nfs Solaris --> AIX

5. Retrieve mounted file system name for a directory

6. arp reply and ip blocking

7. HOWTO: Retrieve path name of an opened file?

8. Access denied when copying files to Windows partition.

9. newbie: retrieve name of tmpfile problem

10. Retrieving NT login name

11. how to retrieve the graphic-board name ?

12. Howto retrieve a pid by proces name in C?

13. How retrieve names from DNS?