added cURL downloading into why2_chat_init_config

This commit is contained in:
Václav Šmejkal 2023-04-20 21:23:53 +02:00
parent ab2bd02318
commit 8dacaf7873
Signed by: ENGO150
GPG Key ID: 4A57E86482968843

View File

@ -21,12 +21,25 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <stdio.h>
#include <unistd.h>
#include <curl/curl.h>
#include <why2/chat/flags.h>
#include <why2/flags.h>
void why2_chat_init_config(void)
{
if (access(WHY2_CHAT_CONFIG, R_OK) != 0) //CONFIG DOESN'T EXIST
{
//DO STUFF
CURL *curl = curl_easy_init();
FILE *fileBuffer = why2_fopen(WHY2_CHAT_CONFIG, "w+");
curl_easy_setopt(curl, CURLOPT_URL, WHY2_CHAT_CONFIG_URL);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fileBuffer);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, WHY2_CURL_TIMEOUT);
curl_easy_perform(curl);
//CLEANUP
curl_easy_cleanup(curl);
why2_deallocate(fileBuffer);
}
}