#include #include #include #if 0 struct node { char *uuid; char *data; struct node *next; }; typedef struct node Node; #if 0 void createq(); int showfront(char *uuid, char *data); void addq(char *uuid, char *data); void delq(); void showqueue(); #endif Node *front, *rear; void createq() { printf("createq \n"); front = rear = (Node*) malloc(sizeof(Node)); front->next = rear->next = NULL; if(front == NULL) { printf("front is NULL \n"); } else { printf("front is not NULL \n"); } printf(" front: (@%p)\n",&(front->next)); if(front->next == NULL) { printf("front->next is NULL \n"); } else { printf("front->next is not NULL \n"); } } int showfront(char *uuid, char *data){ Node* tmpnode; front = rear = (Node*) malloc(sizeof(Node)); front->next = rear->next = NULL; if(front->next == NULL) { printf("\n queue is null"); strcpy(uuid,""); strcpy(data,""); return 0; } else { printf("test test 11111 !!! \n"); printf("\n uuid:%s", front->next->uuid); printf("\n頂端值:%s", front->next->data); strcpy(uuid,front->next->uuid); strcpy(data,front->next->data); return 1; } } void addq(char *uuid, char *data) { Node *newnode; newnode = (Node*) malloc(sizeof(Node)); if(front->next == NULL) front->next = newnode; newnode->uuid = uuid; newnode->data = data; newnode->next = NULL; rear->next = newnode; rear = newnode; } void delq() { Node* tmpnode; if(front->next == NULL) { printf("\n佇列已空!"); return; } tmpnode = front->next; front->next = tmpnode->next; free(tmpnode); } void showqueue() { Node* tmpnode; tmpnode = front->next; printf("\n佇列內容:"); while(tmpnode != NULL) { printf("%s ", tmpnode->data); tmpnode = tmpnode->next; } } #endif