list_t: add some functions, append and pull to be used with Queue lists

This commit is contained in:
2025-04-30 23:07:18 +02:00
parent 9674422b1e
commit 840276d8b9
2 changed files with 35 additions and 1 deletions
+32
View File
@@ -32,6 +32,8 @@
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)
@@ -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);\
}\
+2
View File
@@ -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));