From: nishi Date: Sat, 27 Jan 2024 09:20:11 +0000 (+0000) Subject: adding X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=d62264cb98e2393c9404c15062d732fff10941f6;p=libw3.git adding git-svn-id: file:///raid/svn-main/nishi-libw3/trunk@114 d27a3e52-49c5-7645-884c-6793ebffc270 --- diff --git a/Example/pop3-list/pop3-list.c b/Example/pop3-list/pop3-list.c index 2ccf98d..3a14eb0 100644 --- a/Example/pop3-list/pop3-list.c +++ b/Example/pop3-list/pop3-list.c @@ -24,7 +24,8 @@ void list_handler(struct W3* w3, bool ok, char* data) { void login_handler(struct W3* w3) { printf("Logged in\n"); - W3_Set_Method(w3, "LIST"); + W3_Set_Method(w3, "RETR"); + W3_Set_Path(w3, "1"); W3_POP3_Send_Request(w3); } diff --git a/Library/Core.c b/Library/Core.c index ae94ffc..8a580a9 100644 --- a/Library/Core.c +++ b/Library/Core.c @@ -101,12 +101,20 @@ void W3_Set_Read_Size(struct W3* w3, size_t size) { w3->readsize = size; } void W3_Set_Method(struct W3* w3, const char* method) { if(w3->method != NULL) free(w3->method); - w3->method = __W3_Strdup(method); + if(method == NULL){ + w3->method = NULL; + }else{ + w3->method = __W3_Strdup(method); + } } void W3_Set_Path(struct W3* w3, const char* path) { if(w3->path != NULL) free(w3->path); - w3->path = __W3_Strdup(path); + if(path == NULL){ + w3->path = NULL; + }else{ + w3->path = __W3_Strdup(path); + } } void W3_Send_Request(struct W3* w3) { diff --git a/Library/POP3.c b/Library/POP3.c index b8b9036..0421eda 100644 --- a/Library/POP3.c +++ b/Library/POP3.c @@ -59,13 +59,13 @@ void __W3_POP3_Request(struct W3* w3) { /* OK */ if(login == 2) { /* Login success */ + __W3_Debug("LibW3-POP3", "Login successful"); login = 3; void* funcptr = __W3_Get_Event(w3, "pop3login"); if(funcptr != NULL) { void (*func)(struct W3*, int) = (void (*)(struct W3*, int))funcptr; func(w3, 512); } - __W3_Debug("LibW3-POP3", "Login successful"); } else { void* funcptr = __W3_Get_Event(w3, "pop3data"); if(funcptr != NULL) { @@ -77,6 +77,7 @@ void __W3_POP3_Request(struct W3* w3) { /* ERR */ if(login == 2) { /* Login failed */ + __W3_Debug("LibW3-POP3", "Login failed"); void* funcptr = __W3_Get_Event(w3, "error"); if(funcptr != NULL) { void (*func)(struct W3*, const char*) = (void (*)(struct W3*, const char*))funcptr; @@ -110,7 +111,7 @@ void __W3_POP3_Request(struct W3* w3) { } else if(c == '-') { phase = 2; } - } else if(phase == 1) { + } else if(phase == 1 || phase == 2) { if(c == ' ') phase += 2; } } @@ -126,8 +127,20 @@ void W3_POP3_Set_Password(struct W3* w3, const char* password) { __W3_Add_Prop(w void W3_POP3_Send_Request(struct W3* w3) { if(strcasecmp(w3->method, "LIST") == 0) { - *((bool*)w3->generic) = false; - __W3_Auto_Write(w3, "LIST\r\n", 6); + __W3_Auto_Write(w3, "LIST ", 5); + if(w3->path != NULL && strlen(w3->path) != 0){ + __W3_Auto_Write(w3, w3->path, strlen(w3->path)); + }else{ + *((bool*)w3->generic) = false; + } + __W3_Auto_Write(w3, "\r\n", 2); + }else if(strcasecmp(w3->method, "RETR") == 0) { + __W3_Auto_Write(w3, "RETR ", 5); + if(w3->path != NULL && strlen(w3->path) != 0){ + __W3_Auto_Write(w3, w3->path, strlen(w3->path)); + *((bool*)w3->generic) = false; + } + __W3_Auto_Write(w3, "\r\n", 2); } } diff --git a/W3Version.h.p b/W3Version.h.p index 982fb3f..434ab9f 100644 --- a/W3Version.h.p +++ b/W3Version.h.p @@ -6,7 +6,7 @@ extern "C" { #endif -#define LIBW3_VERSION "2.0" \ +#define LIBW3_VERSION "2.0A" \ SUFFIX #ifdef __cplusplus