{ NULL, 0, NULL, 0 }
};
-void read_destination_list(char *filename)
+void read_ip_list(char *filename, struct in_addr **addr_list, unsigned *num, unsigned *room)
{
char buf[256];
FILE *in = fopen(filename, "r");
// just pick the first for now
memcpy(&addr.s_addr, he->h_addr_list[0], sizeof(addr.s_addr));
- // FIXME: store here
+ if (*num >= *room) {
+ if (*room == 0) {
+ *room = 16;
+ } else {
+ *room <<= 1;
+ }
+ *addr_list = (struct in_addr *)realloc(*addr_list, *room * sizeof(struct in_addr));
+ }
+
+ (*addr_list)[*num] = addr;
+ ++*num;
}
fclose(in);
int c = getopt_long(argc, argv, "d:p:", longopts, &option_index);
switch (c) {
case 'd':
- read_destination_list(optarg);
+ read_ip_list(optarg, &destinations, &num_destinations, &room_destinations);
break;
case 'p':
port = atoi(optarg);