| | |
A C Program to display as much information about system as possible
This Program gives the details (name, kernel, machine type, domain, groups, sizeof data types, etc) of the host it is running on.
/* hostDetails.c - display as much information about system as possible */ #include <unistd.h> #include <sys/types.h> #include <stdio.h> #include <sys/utsname.h> #include <pwd.h> #include <stdlib.h> #define MAX_DOMAIN_LEN 512 #define MAX_HOST_LEN 512 int main(int argc, char *argv[]) { int counter; /* to be used by uname() */ struct utsname uname_buf; /* to be used by getdomainname() */ char domain[MAX_DOMAIN_LEN]; /* to be used by getgroups() */ gid_t *list=NULL; int num_gid; /* to be used by gethostname() */ char host_buf[MAX_HOST_LEN]; /* check all things are provided */ if (argc != 1 ) { printf("call with no parameter\n usage: maxInfo\n\n"); exit(-1); } uname(&uname_buf); printf("Result of uname()\n"); printf("sysname = %s\n", uname_buf.sysname); printf("nodename = %s\n", uname_buf.nodename); printf("release = %s\n", uname_buf.release); printf("version = %s\n", uname_buf.version); printf("machine = %s\n", uname_buf.machine); printf("\n"); printf("Result of getdomainname()\n"); getdomainname(domain, MAX_DOMAIN_LEN); printf("domain name = %s\n", domain); printf("\n"); printf("Result of getegid()/getgid()\n"); printf("gid = %lu\n", (unsigned long) getgid()); printf("effective gid = %lu\n", (unsigned long) getegid()); printf("\n"); printf("Result of getgroups()\n"); num_gid = getgroups(0, list); list = (gid_t *) malloc (sizeof(gid_t)*num_gid); num_gid = getgroups(num_gid, list); if (list != NULL) { for (counter=0; counter<num_gid; counter++) { printf("%lu ", (unsigned long) list[counter]); } } printf("\n"); printf("\n"); printf("Result of gethostid()/gethostname()\n"); printf("host id = 0x%lx\n", gethostid()); gethostname(host_buf, MAX_HOST_LEN); printf("host name = %s\n", host_buf); printf("\n"); printf("Result of sizeof() (in bytes)\n"); printf("sizeof(char) = %d\n", sizeof(char)); printf("sizeof(short) = %d\n", sizeof(short)); printf("sizeof(int) = %d\n", sizeof(int)); printf("sizeof(long) = %d\n", sizeof(long)); printf("sizeof(long long) = %d\n", sizeof(long long)); printf("sizeof(float) = %d\n", sizeof(float)); printf("sizeof(double) = %d\n", sizeof(double)); printf("sizeof(long double) = %d\n", sizeof(long double)); return 0; }
0
•
•
•
•
I'm compiling with the old TC 2.0v and some syntax errors come up, may be because the 'ancient' compiler I'm using.
Bofarull
Bofarull
Similar Threads
- can two ms sql table display information on one vb datagrid??? (Visual Basic 4 / 5 / 6)
- display information from access table in a combobox (Visual Basic 4 / 5 / 6)
- Getting information from database and display on the screen (PHP)
- ActiveX or Java program to collect system/hardware information (Existing Scripts)
- Program to display System date and Time in VC++ 6.0 (C++)
| Thread Tools | Search this Thread |
#include adobe ansi api array asterisks binarysearch changingto char character cm copyimagefile cprogramme creafecopyofanytypeoffileinc createcopyoffile csyntax database directory dynamic execv feet fgets file fork forloop frequency function getlasterror givemetehcodez global grade graphics gtkgcurlcompiling hacking hardware highest histogram i/o include incrementoperators infiniteloop input interest kernel keyboard kilometer license linked linkedlist linux linuxsegmentationfault list locate logical_drives looping loopinsideloop. lowest match matrix meter microsoft motherboard mqqueue number odf opensource owf pattern pdf performance pointer posix probleminc process program programming radix recursion recv repetition research reversing scanf scripting segmentationfault sequential shape socket socketprograming standard string systemcall threads turboc unix user voidmain() wab windows.h windowsapi



