From 3dda177c744c077736fd99308b3f58438b92b439 Mon Sep 17 00:00:00 2001 From: nishi Date: Sat, 27 Jan 2024 13:48:02 +0000 Subject: [PATCH] pop3-list example fix git-svn-id: file:///raid/svn-main/nishi-libw3/trunk@119 d27a3e52-49c5-7645-884c-6793ebffc270 --- Example/pop3-list/pop3-list.c | 8 ++++---- Library/POP3.c | 6 +++++- W3Version.h.p | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Example/pop3-list/pop3-list.c b/Example/pop3-list/pop3-list.c index dbb3ead..0a35b12 100644 --- a/Example/pop3-list/pop3-list.c +++ b/Example/pop3-list/pop3-list.c @@ -17,10 +17,9 @@ #include #include -void list_handler(struct W3* w3, bool ok, char* data) { - printf("[%s] %s\n", ok ? " OK " : " FAIL ", data); - W3_POP3_Disconnect(w3); -} +void list_handler(struct W3* w3, bool ok, char* data) { printf("[%s] %s\n", ok ? " OK " : " FAIL ", data); } + +void finish_handler(struct W3* w3) { W3_POP3_Disconnect(w3); } void login_handler(struct W3* w3) { printf("Logged in\n"); @@ -40,5 +39,6 @@ int main(int argc, char** argv) { W3_POP3_Set_Password(w3, argv[3]); W3_On(w3, "pop3login", login_handler); W3_On(w3, "pop3data", list_handler); + W3_On(w3, "pop3finish", finish_handler); W3_Send_Request(w3); } diff --git a/Library/POP3.c b/Library/POP3.c index 6474701..684a9db 100644 --- a/Library/POP3.c +++ b/Library/POP3.c @@ -73,10 +73,14 @@ void __W3_POP3_Request(struct W3* w3) { func(w3, true, buffer); free(buffer); } - printf("%d\n", octets); if(octets == 0) { __W3_Debug("LibW3-POP3", "Received all"); newl_cond &= ~(1 << 1); + funcptr = __W3_Get_Event(w3, "pop3finish"); + if(funcptr != NULL) { + void (*func)(struct W3*) = (void (*)(struct W3*))funcptr; + func(w3); + } } i += readlen; } else if(newl_cond & (1 << 4)) { diff --git a/W3Version.h.p b/W3Version.h.p index 9f4f893..79c85ba 100644 --- a/W3Version.h.p +++ b/W3Version.h.p @@ -6,7 +6,7 @@ extern "C" { #endif -#define LIBW3_VERSION "2.0B" \ +#define LIBW3_VERSION "2.0C" \ SUFFIX #ifdef __cplusplus -- 2.43.0