#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _TEST
typedef struct linklist{
char * cIP;
struct linklist * iNext;
}sList;
void
listAdd(sList ** Node, char * ip_address)
{
//Node = malloc(sizeof(Node));
if( *Node == NULL )
{
/* Allocate a Node */
Node = malloc(sizeof(Node));
if( *Node == NULL )
{
/* This means we couldn't allocate a Node*/
perror("malloc");
}
/* Lets check exactly what happened */
perror("malloc");
}
/* If we are here then we know we have allocated a Node */
strcpy((*Node)->cIP,ip_address);
#ifdef _TEST
printf("\nIP Address = %s",ip_address
);
printf("\nIP Address in Node = %s",
(*Node
)->cIP
);
fflush(stdout);
fflush(stdin);
#endif
/* Advance the linked list */
}
int
main(int argc, char *argv[])
{
/* What we need to do
*
* We need to open a file with the IP's of the servers in it
* we add the IP to a Linked List we then send the command
* to the server to change the password
*/
struct sList * List;
List = malloc(sizeof(sList));
listAdd(&List, "0.0.0.0");
listAdd(&List, "0.0.0.1");
listAdd(&List, "0.0.0.2");
listAdd(&List, "0.0.0.3");
#ifdef _TEST
printf("\nI've come back from List Add");
fflush(stdout);
fflush(stdin);
getc(stdin);
#endif
free(List);
List = NULL;
exit(0);
}