From 840276d8b91e5a81e4033889856b856ea3d28374 Mon Sep 17 00:00:00 2001 From: fanasina Date: Wed, 30 Apr 2025 23:07:18 +0200 Subject: [PATCH] list_t: add some functions, append and pull to be used with Queue lists --- list_t/src/list_t/list_t.h | 34 +++++++++++++++++++++++++- y_socket_t/src/y_socket_t/y_socket_t.c | 2 ++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/list_t/src/list_t/list_t.h b/list_t/src/list_t/list_t.h index fc4db83..c2445b7 100644 --- a/list_t/src/list_t/list_t.h +++ b/list_t/src/list_t/list_t.h @@ -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);\ + }\ diff --git a/y_socket_t/src/y_socket_t/y_socket_t.c b/y_socket_t/src/y_socket_t/y_socket_t.c index 1640f0e..f0839fa 100644 --- a/y_socket_t/src/y_socket_t/y_socket_t.c +++ b/y_socket_t/src/y_socket_t/y_socket_t.c @@ -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));