// 将数据形成节点,加入到链表,并唤醒解析线程 int receiver_core(char *buf, int buf_len) { int ret; ret = list_node_add(buf, buf_len); thread_syn_flag_set(&syn_ctrl_parse.mutex_r, &syn_ctrl_parse.cond_r, &syn_ctrl_parse.flag_r); return 0; }
/**************************************************************** * Summary: Converts a line from the dictionary file to a * * list_node_t for the dictionary. * * * * Parameters: line - The line to interpret. * * last - A pointer to the last node in the * * dictionary, the new node is added after * * this node. * * * * Returns: The new node if successful, otherwise NULL. * ****************************************************************/ static list_node_t * interpret_line(char *line, list_node_t *last) { char *temp_word = NULL; list_node_t *new_node = NULL; /* Get the original word and create a node */ temp_word = strtok(line, DICTIONARY_SEPERATOR); if (NULL != temp_word) { new_node = list_node_add(last, temp_word); if (NULL == new_node) { return NULL; } } else { return NULL; } /* Add synonyms */ temp_word = strtok(NULL, DICTIONARY_SEPERATOR); while (NULL != temp_word) { if (NULL == (*new_node).synonyms) { (*new_node).synonyms = circle_node_create(temp_word); } else { circle_node_add_after((*new_node).synonyms, temp_word); } temp_word = strtok(NULL, DICTIONARY_SEPERATOR); } return new_node; }
void list_node_append(struct list_node *new_node, struct list_node *prev_node){ list_node_add(new_node, prev_node, prev_node->next); }
/* prepend the node before following node. * */ void list_node_prepend(struct list_node *new_node, struct list_node *following){ list_node_add(new_node, following->prev, following); }