All pastes #441815 Raw Edit

Mine

public text v1 · immutable
·published 2007-04-15 21:33 UTC
rendered paste body
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <ifaddrs.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <err.h>


int main() {

        struct ifaddrs *ifaddr, *ifhead;

        if ( getifaddrs(&ifaddr) < 0 )
                errx(1, "hmmm");

        ifhead = ifaddr;

        while (ifaddr->ifa_next != NULL) {
                printf("karta %s\n", ifaddr->ifa_name);
                printf("flags 0x%x\n", ifaddr->ifa_flags);
                printf("addresa %s\n", inet_ntoa(
                       ((struct sockaddr_in *)ifaddr->ifa_addr)->sin_addr));
                ifaddr = ifaddr->ifa_next;
        }

        freeifaddrs(ifhead);

        return 0;
}