#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");
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);
}
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)) {