list_t: add some functions, append and pull to be used with Queue lists
This commit is contained in:
@@ -32,7 +32,9 @@
|
||||
void decrement_list_##type(struct main_list_##type * var_list);\
|
||||
struct list_##type * search_first_occ_with_mov_from_curr_in_list_##type(struct main_list_##type *var_list, type value, int (*funcCmp)(type, type), void (*incr_or_decr_mov)(struct main_list_##type *));\
|
||||
struct list_##type * search_first_occ_from_begin_in_list_##type(struct main_list_##type *var_list, type value, int (*funcCmp)(type, type));\
|
||||
|
||||
struct list_##type * pull_end_from_list_##type(struct main_list_##type *var_list);\
|
||||
void append_list_##type(struct main_list_##type *var_list, struct list_##type *list);\
|
||||
|
||||
|
||||
GENERATE_LIST_ALL(TYPE_CHAR)
|
||||
GENERATE_LIST_ALL(TYPE_U_CHAR)
|
||||
@@ -215,6 +217,36 @@ GENERATE_LIST_ALL(TYPE_PTR)
|
||||
move_current_to_begin_list_##type(var_list);\
|
||||
return search_first_occ_with_mov_from_curr_in_list_##type(var_list, value, funcCmp, increment_list_##type);\
|
||||
}\
|
||||
struct list_##type * pull_end_from_list_##type(struct main_list_##type *var_list){\
|
||||
struct list_##type *ret = var_list->end_list;\
|
||||
if(ret != NULL){\
|
||||
struct list_##type * prevL = ret->preview;\
|
||||
if(prevL != NULL){\
|
||||
prevL->next=NULL;\
|
||||
}else{\
|
||||
var_list->begin_list=NULL;\
|
||||
var_list->current_index = 0;\
|
||||
var_list->current_list=NULL;\
|
||||
}\
|
||||
var_list->end_list = prevL;\
|
||||
--(var_list->size);\
|
||||
}\
|
||||
return ret;\
|
||||
}\
|
||||
void append_list_##type(struct main_list_##type *var_list, struct list_##type *list){\
|
||||
if(var_list->end_list == NULL){\
|
||||
list->preview = NULL;\
|
||||
var_list->end_list = list;\
|
||||
var_list->begin_list = list;\
|
||||
var_list->current_list = list;\
|
||||
var_list->current_index = 0;\
|
||||
}else{\
|
||||
var_list->end_list->next = list;\
|
||||
list->preview = var_list->end_list;\
|
||||
var_list->end_list = list;\
|
||||
}\
|
||||
++(var_list->size);\
|
||||
}\
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -185,6 +185,7 @@ void *y_pollSocketsFunc(void *arg){
|
||||
// char msgRet[BUF_SIZE + NI_MAXHOST + NI_MAXSERV + 100];
|
||||
// int len_msgRet;
|
||||
for(;;){
|
||||
printf("poll: wait events\n");
|
||||
status = poll(fds, nbIpVersion, -1);
|
||||
if(status <= 0){
|
||||
if(status == -1 && errno != EINTR){
|
||||
@@ -264,6 +265,7 @@ printf("msg : %s\n",buf);
|
||||
}
|
||||
}
|
||||
close(fd_file);
|
||||
printf("fd=%d closede: filename=%s\n",fd_file,buf);
|
||||
}
|
||||
}
|
||||
// printf("nread = %ld: buf=%s\nlen_buf=%ld\ncmp=%d\n",nread,buf,strlen(buf),strncmp(buf,"SHUTDOWN SERVER",15));
|
||||
|
||||
Reference in New Issue
Block a user