From 67f12d4a5174e421570ab0f97370bb0f7cffc0cb Mon Sep 17 00:00:00 2001 From: nishi Date: Wed, 14 Feb 2024 05:59:11 +0000 Subject: [PATCH] format and nntp git-svn-id: file:///raid/svn-main/nishi-libw3/trunk@219 d27a3e52-49c5-7645-884c-6793ebffc270 --- Example/nntp-list/nntp-list.c | 21 +-------------------- Library/FTP.c | 3 ++- Library/URL.c | 2 ++ W3Version.h.p | 2 +- 4 files changed, 6 insertions(+), 22 deletions(-) diff --git a/Example/nntp-list/nntp-list.c b/Example/nntp-list/nntp-list.c index 10201b7..7fd4acf 100644 --- a/Example/nntp-list/nntp-list.c +++ b/Example/nntp-list/nntp-list.c @@ -22,11 +22,7 @@ struct W3URL* w3url; void resp_handler(struct W3* w3, int status, char* data) { printf("%d\n%s\n", status, data); if(status == 230) { - W3_Set_Method(w3, "CWD"); - W3_Set_Path(w3, w3url->path); - W3_FTP_Send_Request(w3); W3_Set_Method(w3, "LIST"); - W3_Set_Path(w3, "/"); W3_FTP_Send_Request(w3); } else if(status == 226) { W3_FTP_Disconnect(w3); @@ -43,22 +39,7 @@ int main(int argc, char** argv) { W3_Library_Init(); w3url = W3_Parse_URL(argv[1]); if(w3url != NULL) { - bool err = false; - if(w3url->username == NULL) { - err = true; - fprintf(stderr, "%s: missing username\n", argv[0]); - } - if(w3url->password == NULL) { - err = true; - fprintf(stderr, "%s: missing password\n", argv[0]); - } - if(err) { - W3_Free_URL(w3url); - return 1; - } - struct W3* w3 = W3_Create("ftp", w3url->host, w3url->port); - W3_FTP_Set_Username(w3, w3url->username); - W3_FTP_Set_Password(w3, w3url->password); + struct W3* w3 = W3_Create("nntp", w3url->host, w3url->port); W3_On(w3, "ftpresp", resp_handler); W3_On(w3, "data", data_handler); W3_Send_Request(w3); diff --git a/Library/FTP.c b/Library/FTP.c index b4b2157..930c05b 100644 --- a/Library/FTP.c +++ b/Library/FTP.c @@ -136,7 +136,8 @@ void __W3_FTP_Request(struct W3* w3) { free(numbuf); pasvsock = __W3_DNS_Connect(addr, false, port #ifdef SSL_SUPPORT - ,NULL, NULL + , + NULL, NULL #endif ); free(addr); diff --git a/Library/URL.c b/Library/URL.c index cf214b6..9f31c1a 100644 --- a/Library/URL.c +++ b/Library/URL.c @@ -128,6 +128,8 @@ struct W3URL* W3_Parse_URL(const char* _url) { r->port = 1900; } else if(strcmp(r->protocol, "ftp") == 0) { r->port = 21; + } else if(strcmp(r->protocol, "nntp") == 0) { + r->port = 119; } } r->host = __W3_Strdup(url + start + (atmark == 0 ? 0 : (atmark - 1))); diff --git a/W3Version.h.p b/W3Version.h.p index 00c9918..0b0ff38 100644 --- a/W3Version.h.p +++ b/W3Version.h.p @@ -6,7 +6,7 @@ extern "C" { #endif -#define LIBW3_VERSION "2.12C" \ +#define LIBW3_VERSION "2.12D" \ SUFFIX #ifdef __cplusplus -- 2.43.0