From: nishi Date: Wed, 17 Jan 2024 03:54:39 +0000 (+0000) Subject: different api X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=024ca6603c2855f736855d07e2554d207500a619;p=libw3.git different api git-svn-id: file:///raid/svn-main/nishi-libw3/trunk@7 d27a3e52-49c5-7645-884c-6793ebffc270 --- diff --git a/Example/fetch.c b/Example/fetch.c index c95bdf8..b352622 100644 --- a/Example/fetch.c +++ b/Example/fetch.c @@ -15,5 +15,5 @@ int main(int argc, char** argv){ return 1; } W3_Library_Init(); - struct W3* w3 = W3_Create(true, argv[1], 443); + struct W3* w3 = W3_Create("https", argv[1], 443); } diff --git a/Library/Core.c b/Library/Core.c index 3d6d6e7..c9beb0e 100644 --- a/Library/Core.c +++ b/Library/Core.c @@ -5,6 +5,7 @@ #include "W3Util.h" #include +#include #include #ifdef SSL_SUPPORT @@ -28,9 +29,16 @@ int W3_Library_Init(void){ return 0; } -struct W3* W3_Create(bool ssl, const char* hostname, int port){ +struct W3* W3_Create(const char* protocol, const char* hostname, int port){ __W3_Debug("Create", "Creating a struct"); struct W3* w3 = malloc(sizeof(*w3)); + bool ssl = false; + if( + strcmp(protocol, "https") == 0 + ){ + ssl = true; + } + if(ssl) __W3_Debug("Protocol", "Enabled SSL"); w3->sock = __W3_DNS_Connect(hostname, ssl, port #ifdef SSL_SUPPORT , diff --git a/Library/W3Core.h b/Library/W3Core.h index 05552ea..1fe8084 100644 --- a/Library/W3Core.h +++ b/Library/W3Core.h @@ -14,7 +14,7 @@ struct W3 { #endif }; -int W3_Library_Init(void); /* Initialize the Library */ -struct W3* W3_Create(bool ssl, const char* hostname, int port); /* Create the struct */ +int W3_Library_Init(void); /* Initialize the Library */ +struct W3* W3_Create(const char* protocol, const char* hostname, int port); /* Create the struct */ #endif