1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. #define _TEST
  6.  
  7. typedef struct linklist{
  8. char * cIP;
  9. struct linklist * iNext;
  10. }sList;
  11.  
  12. void
  13. listAdd(sList ** Node, char * ip_address)
  14. {
  15. //Node = malloc(sizeof(Node));
  16. if( *Node == NULL )
  17. {
  18. /* Allocate a Node */
  19. Node = malloc(sizeof(Node));
  20. if( *Node == NULL )
  21. {
  22. /* This means we couldn't allocate a Node*/
  23. perror("malloc");
  24. }
  25. /* Lets check exactly what happened */
  26. perror("malloc");
  27. }
  28. /* If we are here then we know we have allocated a Node */
  29. strcpy((*Node)->cIP,ip_address);
  30. #ifdef _TEST
  31. printf("\nIP Address = %s",ip_address);
  32. printf("\nIP Address in Node = %s",(*Node)->cIP);
  33. fflush(stdout);
  34. fflush(stdin);
  35. #endif
  36. /* Advance the linked list */
  37. }
  38.  
  39. int
  40. main(int argc, char *argv[])
  41. {
  42. /* What we need to do
  43.   *
  44.   * We need to open a file with the IP's of the servers in it
  45.   * we add the IP to a Linked List we then send the command
  46.   * to the server to change the password
  47.   */
  48. struct sList * List;
  49. List = malloc(sizeof(sList));
  50. listAdd(&List, "0.0.0.0");
  51. listAdd(&List, "0.0.0.1");
  52. listAdd(&List, "0.0.0.2");
  53. listAdd(&List, "0.0.0.3");
  54. #ifdef _TEST
  55. printf("\nI've come back from List Add");
  56. fflush(stdout);
  57. fflush(stdin);
  58. getc(stdin);
  59. #endif
  60. free(List);
  61. List = NULL;
  62. exit(0);
  63. }
  64.