OFFTOPIC: binarisok olvashatosaga... miert? - egy kis hack a dolo ghoz...

Zelenak.Gabor at ans.lri.hu Zelenak.Gabor at ans.lri.hu
2001. Május. 2., Sze, 16:22:17 CEST


az alabbiakat ajanlom figyelmebe annak, aki
minden aron szeretne tudni, hogy mi van terminal
promptja mogott...

tesztelt kornyezetek: SCO UNIXWARE, OpenServer, OpenBSD
		        FreeBSD, Digital Unix V3.2 - V4.0D

ha lefuttatod, akkor - legalabbis a fobb kerdesekben - tajekozott lehetsz, 
olyanokban, hogy milyen nevu host-on vagy es igy tovabb (lasd lentebb)...

forditasa: cc -o $HOME/sysinfo ./sysinfo.c

[itt kezdodik: file name = sysinfo.c]

static char rcsid[] = "@(#) $RCSfile: sysinfo.c,v $ $Revision: 1.2 $ $Date:
2000/12/04 13:
07:42 $";
/*
 *  SYSINFO - prints out the basic system information, using the following
 *            system calls:     uname( struct utsname *) and
 *                              	   sysinfo( int, char *, long)
 *  Written by G.Z. 1998.11.15. MATIAS
 * ....a tobbivel nem zargatlak benneteket....
 */
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/utsname.h>
#include <sys/systeminfo.h>

#define ARGS    "hsu"

typedef struct{
        int command;
        char *string;
}Info;

Info info[]={
  SI_SYSNAME,   "SI_SYSNAME",
  SI_HOSTNAME,  "SI_HOSTNAME",
  SI_ARCHITECTURE, "SI_ARCHITECTURE",
  SI_HW_PROVIDER, "SI_HW_PROVIDER",
  SI_HW_SERIAL, "SI_HW_SERIAL",
  SI_MACHINE, "SI_MACHINE",
  SI_RELEASE, "SI_RELEASE",
  SI_SRPC_DOMAIN, "SI_SRPC_DOMAIN",
  0, NULL
};

char buf[BUFSIZ];
Info *ip;
struct utsname name;

void usage(void)
{
  printf("Usage:\n\tsysinfo -[hsu] where\n\t-h for help\n\t-u for
uname\n\t-s for sysinfo\
n");
  exit(1);
}

main(int argc, char *argv[])
{
  int c;

  if (argc != 2)
  {
    usage();
  }
  while((c = getopt( argc, argv, ARGS)) != -1)
    switch(c)
    {
      case 'h':
        usage();
        break;
      case 's':
        printf("SYSINFO :\n");
        for ( ip = info; ip->string != NULL; ip++)
        {
          if ( sysinfo( ip->command, buf, sizeof(buf)) < 0)
          {
            perror( ip->string);
            exit(1);
          }
          printf("%16s : %s\n", ip->string, buf);
        }
        break;
      case 'u':
        if ( uname( &name) < 0)
        {
          perror("uname");
          exit(1);
        }
        printf("UNAME information:\n");
        printf("\t SYSNAME: %s\n", name.sysname);
        printf("\tnodename: %s\n", name.nodename);
        printf("\t release: %s\n", name.release);
        printf("\t version: %s\n", name.version);
        break;
      default:
        usage();
    }
}

/****************************************
                 Zelenak Gabor			
            system programmer			
----------------------------------------------------------
 MATIAS Air Traffic Control Center Hungary
 (36)1-296-9106{FAX}
 (36)1 296-9107
----------------------------------------------------------
 mailto:zelenak.gabor at ans.lri.hu
*****************************************/
int
main(){
  printf("Hello World!");
  exit(0);
}




További információk a(z) BSD levelezőlistáról