Firstly, I'll say how much I appreciate this forum. I can't count how many times during my undergrad that I have come here for information.
Ok, so the language is C. I have a doubly-linked list (ready_list) that I would like to print the contents of. The lists (there are 4 others) have been declared globally for reasons that I believe are outside the scope of my question.
The following is the segment of my code declaring structures. At the bottom of the code inside the signal handler for SIGHUP, I am trying to print the data of my nodes from my linked list. My programming environment is telling me there are some errors. Would someone mind looking at it and letting me know where I have made my mistake?
Thanks in advance, Darrell
typedef struct ready_node { //ready process nodes
void *data;
struct ready_node *next;
struct ready_node *prev;
} ready_node;
typedef struct ready_printer { //ready process list pointer for printing
void *data;
struct ready_printer *next;
struct ready_printer *prev;
} ready_printer;
typedef struct ready_list{ //ready process list
ready_node *head;
ready_node *tail;
} ready_list;
typedef struct {
char name[NAME_MAX];
int lifetime;
} pcb_t;
void sig_handler(int signal) { //signal handlers
if (signal == SIGALRM)
printf("recieved SIGALRM\n");
else if (signal == SIGUSR1)
printf("recieved SIGUSR1\n");
else if (signal == SIGUSR2)
printf("revieved SIGUSR2\n");
else if (signal == SIGHUP) {
printf("recieved SUGHUP\n");
ready_printer = ready_list; // <- Expected Identifier or ‘('
while (ready_printer != NULL) { // <- Unexpected type name ‘ready_printer’:expected expression
printf("%d", ready_printer->data);
ready_printer=ready_printer->next; // <- Expected Identifier or ‘('
}
}
}
UPDATE
Ok, now that I understand the meaning of typdef and struct, here is what I have now:
typedef struct {
int data;
void *next;
void *prev;
} ready_node;
typedef struct {
ready_node *head;
ready_node *tail;
} list;
list ready_list;
static int sighup_flag = 0;
void sig_handler(int signal) { //signal handlers
if (signal == SIGALRM)
printf("recieved SIGALRM\n");
else if (signal == SIGUSR1)
printf("recieved SIGUSR1\n");
else if (signal == SIGUSR2)
printf("revieved SIGUSR2\n");
else if (signal == SIGHUP)
sighup_flag = 1;
}
...
main prog
...
if (sighup_flag == 1) {
printf("recieved SIGHUP\n");
ready_node *printer = ready_list.head;
while (printer != NULL) {
printf("%d", printer->data);
printer = printer->next;
}
}
I do appreciate the help. Bruceg posed the question that pointed me in the right direction. As usual, this is a great place to 'receive' help. :)