Here is two examples of name resolving in linux.. I use getaddrinfo() and getnameinfo() respectively..getaddrinfo: given a name retuns all translated IPs, one per line/* * File: getaddrinfo.c * Compile: gcc getaddrinfo.c -o getaddrinfo * Usage: ./getaddrinfo FQN */#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/types.h>#include <sys/socket.h>#include <netdb.h>#include <netinet/in.h>#include <arpa/inet.h>int main(int argc, char **argv){ int error; struct addrinfo saddr, *psaddr, *ptr; memset(&saddr, '\0', sizeof(saddr)); saddr.ai_family = AF_INET; saddr.ai_socktype = SOCK_STREAM; error = getaddrinfo(argv[1], NULL, &saddr, &psaddr); if (error) { fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(error)); exit(EXIT_FAILURE); } for (ptr = psaddr; ptr; ptr = ptr->ai_next) { puts(inet_ntoa(((struct sockaddr_in *) ptr->ai_addr)->sin_addr)); } return 0;}getnameinfo: Given an IP returns the name that first resolves to it. /* * File: getnameinfo.c * Compile: gcc getnameinfo.c -o getnameinfo * Usage: ./getnameinfo IP */#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/types.h>#include <sys/socket.h>#include <netdb.h>#include <netinet/in.h>#include <arpa/inet.h>static char hostname[255];int main(int argc, char **argv){ int error; struct sockaddr_in saddr_in; memset(&saddr_in, '\0', sizeof(saddr_in)); saddr_in.sin_family = AF_INET; error = inet_aton(argv[1], &saddr_in.sin_addr); if (error == 0) { perror("inet_aton"); exit(EXIT_FAILURE); } error = getnameinfo((struct sockaddr *)&saddr_in, sizeof(saddr_in), hostname, sizeof(hostname), NULL, 0, NI_NAMEREQD); if (error) { fprintf(stderr, "getnameinfo: %s\n", gai_strerror(error)); exit(EXIT_FAILURE); } puts(hostname); return 0;}Cheers This program will read /proc/stat an calculum the amount of time that computer was idle...#include <stdio.h>#include <string.h>#include <stdlib.h>#include <unistd.h>#define BUFLEN 256static char buf[BUFLEN];int strsplit (char *string, char **fields, size_t size);int main(void){ FILE *stat; char *fields[9]; int numfields; unsigned int ncores; unsigned int idle; unsigned int old_idle = 0; while (1) { /* * The cpu sum line SHOULD be the first line * on /proc/stat, or things will get wrong. */ if ((stat = fopen("/proc/stat", "r")) == NULL) { perror("fopen"); exit(EXIT_FAILURE); } fgets(buf, BUFLEN, stat); numfields = strsplit (buf, fields, 9); if (numfields < 5) { fprintf(stderr, "To few fields\n"); exit(EXIT_FAILURE); } ncores = sysconf(_SC_NPROCESSORS_ONLN); /* number of cores */ idle = atoi(fields[4]); printf("idle %d%%\n", (idle - old_idle) / ncores); old_idle = idle; fclose(stat); sleep(1); } return 0;}int strsplit (char *string, char **fields, size_t size){ size_t i; char *ptr; char *saveptr; i = 0; ptr = string; saveptr = NULL; while ((fields[i] = strtok_r (ptr, " \t\r\n", &saveptr)) != NULL) { ptr = NULL; i++; if (i >= size) break; } return ((int) i);} /* * File: shello.c * * Generated from this assembly code: * pushl %ebp * movl %esp, %ebp * * subl $12, %esp * movl $0x6c6c6548, -12(%ebp) * movl $0x6f57206f, -8(%ebp) * movl $0x0a646c72, -4(%ebp) * * movl $4, %eax * movl $1, %ebx * leal -12(%ebp), %ecx * movl $12, %edx * * int $0x80 * addl $12, %esp * * leave * ret * *//* * Tested on Linux hilstdsk 3.2.7-1-ARCH #1 SMP PREEMPT Tue Feb 21 * 16:59:04 UTC 2012 i686 AMD Athlon(tm) 64 X2 Dual Core Processor * 4400+ AuthenticAMD GNU/Linux * Archlinux *//* * Compile: gcc -o shello shello.c * Run: ./shello * Output: Hello World */ /* * Thats pretty cool! */#include static char shellcode[] = "\x55" "\x89\xe5" "\x83\xec\x0c" "\xc7\x45\xf4\x48\x65\x6c\x6c" "\xc7\x45\xf8\x6f\x20\x57\x6f" "\xc7\x45\xfc\x72\x6c\x64\x0a" "\xb8\x04\x00\x00\x00" "\xbb\x01\x00\x00\x00" "\x8d\x4d\xf4" "\xba\x0c\x00\x00\x00" "\xcd\x80" "\x83\xc4\x0c" "\xc9" "\xc3";int main(void){ void (*p)(void); p = shellcode; p(); return 0;} Understading the Linux Kernel amd Linux Device Drivers So