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) {
/* 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) {
/* 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;
} else if(c == '-') {
phase = 2;
}
- } else if(phase == 1) {
+ } else if(phase == 1 || phase == 2) {
if(c == ' ') phase += 2;
}
}
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);
}
}