int main(void) { printf ("libnet chat client version %d.%d\n", VER_MAJOR, VER_MINOR); printf ("built at " __TIME__ " on " __DATE__ "\n"); printf ("\n"); net_init(); net_loadconfig (NULL); get_driver(); init(); do_client(); return 0; }
int main (void) { NET_DRIVERNAME *drivers; char buffer[NET_MAX_ADDRESS_LENGTH], buffer2[NET_MAX_ADDRESS_LENGTH]; char *ch; int not_ok, x, choice; NET_DRIVERLIST avail; net_init(); net_loadconfig (NULL); printf ("Detecting available drivers...\n"); avail = net_detectdrivers (net_drivers_all); printf ("Getting detected driver names...\n"); drivers = net_getdrivernames (avail); do { list_drivers (drivers, "Available drivers"); printf ("Please choose a driver from the above list.\n"); fgets (buffer, 10, stdin); choice = atoi (buffer); } while (!in_list (drivers, choice)); free (drivers); avail = net_driverlist_create(); net_driverlist_add (avail, choice); if (!net_initdrivers (avail)) { printf("Error initialising driver.\n"); exit (1); } do { printf ("Enter address to prepare:\n"); fgets (buffer, sizeof buffer, stdin); if (feof (stdin)) break; ch = strchr (buffer, '\n'); if (!ch) { printf ("Too long for this lame program...\n"); while (1) { char ch = getchar(); if (ch == EOF || ch == '\n') break; } } else { NET_PREPADDR_DATA *data; *ch = '\0'; printf ("Converting...\n"); data = net_prepareaddress (choice, buffer, buffer2); if (!data) { printf ("Failed to initiate\n"); } else { int x; printf ("Waiting..."); do { printf ("."); fflush(stdout); sleep (1); x = net_poll_prepareaddress (data); } while (!x); printf ("\n"); if (x < 0) { printf ("Failed to convert address\n"); } else { printf ("%s => %s\n", buffer, buffer2); } } } } while (!feof (stdin)); printf ("Quitting...\n"); return 0; }