#include "net.h" int initNetwork() { // Load in Windows' socket networking support #if defined(WIN32) WORD wVersionRequested; WSADATA wsaData; int err; /* Use the MAKEWORD(lowbyte, highbyte) macro declared in Windef.h */ wVersionRequested = MAKEWORD(2, 2); err = WSAStartup(wVersionRequested, &wsaData); if (err != 0) { /* Tell the user that we could not find a usable */ /* Winsock DLL. */ printf("WSAStartup failed with error: %d\n", err); } #endif // @@TODO: move port initialization elswhere setConfig("port", "7332"); // Get the env USER and hostname then build user@hostname nickname char *username = getenv("USER"); char hostname[15]; // cap hostname to 16 chars, I guess gethostname(hostname, 16); size_t nick_length = strlen(hostname)+strlen(username)+1; char nick[nick_length]; int i = 0; int j = 0; while(jsin_addr, ip, sizeof(ip))) return; ip_list[i] = malloc(strlen(ip)); setString(ip_list[i], ip); printf("%s - %s\n", ifreq[i].ifr_name, ip); dev_list[i] = malloc(strlen(ifreq[i].ifr_name)); setString(dev_list[i], ifreq[i].ifr_name); } close(test_socket); setConfig("ip", ip_list[interfaces-1]); } void freeInterfaces() { int i; for (i = 0;i < interfaces;i++) { if (ip_list[i]) { free(ip_list[i]); } } }