]> Nishi Git Mirror - libw3.git/commitdiff
adding
authornishi <nishi@d27a3e52-49c5-7645-884c-6793ebffc270>
Sat, 27 Jan 2024 09:20:11 +0000 (09:20 +0000)
committernishi <nishi@d27a3e52-49c5-7645-884c-6793ebffc270>
Sat, 27 Jan 2024 09:20:11 +0000 (09:20 +0000)
git-svn-id: file:///raid/svn-main/nishi-libw3/trunk@114 d27a3e52-49c5-7645-884c-6793ebffc270

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

index 2ccf98d2016430e88fb668d1906fa9278fa88c82..3a14eb0693a7a2d2adce0527493d6ce5bd86796f 100644 (file)
@@ -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);
 }
 
index ae94ffc79d01111ea1789ad153af434ea7b682ef..8a580a99a1c101f9f15ff3889c0bdb2154141fb8 100644 (file)
@@ -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) {
index b8b9036dd663587eed4df56240bf37f4a3cc0ef3..0421edaecb5ac160406387d4d8b3d0d221d61893 100644 (file)
@@ -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);
        }
 }
 
index 982fb3f7d5edc25331323ea5ad934e73dd701227..434ab9f87cf27fde3fd5b109f84b6d1774109898 100644 (file)
@@ -6,7 +6,7 @@
 extern "C" {
 #endif
 
-#define LIBW3_VERSION "2.0" \
+#define LIBW3_VERSION "2.0A" \
 SUFFIX
 
 #ifdef __cplusplus