]> Nishi Git Mirror - libw3.git/commitdiff
pop3-list example fix
authornishi <nishi@d27a3e52-49c5-7645-884c-6793ebffc270>
Sat, 27 Jan 2024 13:48:02 +0000 (13:48 +0000)
committernishi <nishi@d27a3e52-49c5-7645-884c-6793ebffc270>
Sat, 27 Jan 2024 13:48:02 +0000 (13:48 +0000)
git-svn-id: file:///raid/svn-main/nishi-libw3/trunk@119 d27a3e52-49c5-7645-884c-6793ebffc270

Example/pop3-list/pop3-list.c
Library/POP3.c
W3Version.h.p

index dbb3ead7f97b47a2179665f7e921adff389935c7..0a35b12f49576725a60f309c74ae89ae1eebd645 100644 (file)
 #include <string.h>
 #include <unistd.h>
 
-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);
 }
index 64747018c13f9ed1b4abc964d7ddfb45663181fd..684a9db59819a0536cfe5fd5f023f3d9b44afdc2 100644 (file)
@@ -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)) {
index 9f4f893c14bad0d650fe697085d12c19c31ba49f..79c85ba9d82aefd58ffef2af3281d1fc7cd22e2f 100644 (file)
@@ -6,7 +6,7 @@
 extern "C" {
 #endif
 
-#define LIBW3_VERSION "2.0B" \
+#define LIBW3_VERSION "2.0C" \
 SUFFIX
 
 #ifdef __cplusplus